TypeUse
data class TypeUse
Fields
Name | Description |
---|---|
val functionType: FunctionType
|
A FunctionType matching the TypeUse. |
val index: Index<Type>?
|
|
val params: List<Param>
|
|
val results: List<Result>
|
Constructors
<init>
constructor(index: Index<Type>?, params: List<Param>, results: List<Result>)
Represents a reference to a Type definition.
From the docs:
It may optionally be augmented by explicit inlined parameter and result declarations. That allows binding symbolic identifiers to name the local indices of parameters. If inline declarations are given, then their types must match the referenced function type.
typeuse(I) ::=
‘(’ ‘type’ x:typeidx(I) ‘)’
=> x,I′ (if I.typedefs[x] = [t^n_1] -> [t*^2] ∧ I′ = {locals (ϵ)^n})
‘(’ ‘type’ x:typeidx(I) ‘)’ (t_1:param)* (t_2:result)*
=> x,I′ (if I.typedefs[x] = [t*_1] -> [t*_2] ∧ I′ = {locals id(param)*} well-formed)
Note:
Both productions overlap for the case that the function type is [] -> []
. However, in that
case, they also produce the same results, so that the choice is immaterial. The well-formedness
condition on I′
ensures that the parameters do not contain duplicate identifier.
A typeuse
may also be replaced entirely by inline parameter and result declarations. In that
case, a type index is automatically inserted:
(t_1:param)* (t_2:result)* ≡ ‘(’ ‘type' x ‘)’ param* result*
where x
is the smallest existing type index whose definition in the current module is the
function type [t*_1] -> [t*_2]
. If no such index exists, then a new type definition of the
form ‘(’ ‘type’ ‘(’ ‘func’ param* result ‘)’ ‘)’
is inserted at the end of the module.
Abbreviations are expanded in the order they appear, such that previously inserted type definitions are reused by consecutive expansions.
Methods
toResultType
fun toResultType(): ResultType
Converts the TypeUse into a ResultType.
ReturnValue
Name | Description |
---|---|
ResultType
|
Represents a reference to a Type definition.
From the docs:
It may optionally be augmented by explicit inlined parameter and result declarations. That allows binding symbolic identifiers to name the local indices of parameters. If inline declarations are given, then their types must match the referenced function type.
Note: Both productions overlap for the case that the function type is
[] -> []
. However, in that case, they also produce the same results, so that the choice is immaterial. The well-formedness condition onI′
ensures that the parameters do not contain duplicate identifier.A
typeuse
may also be replaced entirely by inline parameter and result declarations. In that case, a type index is automatically inserted:where
x
is the smallest existing type index whose definition in the current module is the function type[t*_1] -> [t*_2]
. If no such index exists, then a new type definition of the form‘(’ ‘type’ ‘(’ ‘func’ param* result ‘)’ ‘)’
is inserted at the end of the module.Abbreviations are expanded in the order they appear, such that previously inserted type definitions are reused by consecutive expansions.