Next: GWAT, Up: Toolchain reference [Contents][Index]
The (wasm types)
module contains all the core data types that
comprise a Wasm module.
The Wasm module type is the top type, incorporating values of all the types that are to follow.
Return #t
if obj is a Wasm module.
Return the list of types in wasm.
Return the list of imports in wasm.
Return the list of functions in wasm.
Return the list of tables in wasm.
Return the list of memories in wasm.
Return the list of globals in wasm.
Return the list of exports in wasm.
Return the list of element segments in wasm.
Return the list of data segments in wasm.
Return the list of tags in wasm.
Return the list of strings in wasm.
Return the list of custom segments in wasm.
Return the start function index for wasm.
Wasm has four numeric types:
i32
:
32-bit integer (signed or unsigned)
i64
:
64-bit integer (signed or unsigned)
f32
:
32-bit single precision IEEE floating point number.
f64
:
64-bit double precision IEEE floating point number.
There is also the v128
vector type, but it is currently
unsupported.
Then there are a number of reference types that fall into 3 categories: function, external, and internal.
Function reference types:
func
:
Function reference.
nofunc
:
Bottom type for functions. No function is of type nofunc
.
External reference types:
extern
:
External reference introduced by the host.
noextern
:
Bottom type for external references. No external reference is of type
noextern
.
Internal reference types:
any
:
The top type of all internal reference types.
eq
:
Structural equivalence type. Subtype of all
.
i31
:
Used for immediate references (such as the empty list or fixnums in
Scheme.) Subtype of eq
.
array
:
Super type of all array types. Subtype of eq
.
struct
:
Super type of all struct types. Subtype of eq
.
none
:
The bottom type for internal references. No internal reference is of
type none
.
Of course, modules may specify their own compound types assembled from these primitives.
The type hierarchy looks like this:
.-----. .-------. .---------. .--------- | any | ------------. | func | | extern | | `-----' | `-------' `---------' ↓ ↓ ↓ ↓ ↓ .-----. .-----. .---------. .-----------. .-----------. | i31 | | eq | | struct | | all funcs | | noextern | `-----' `-----' `---------' `-----------' `-----------' ↓ ↓ ↓ .-------------. .-------------. .---------. | all arrays | | all structs | | nofunc | `-------------' `-------------' `---------' ↓ .-----. | any | `-----'
A collection of type descriptor objects form a type table that describes all non-primitive types used within a module. Type objects associate an identifier with a function signature or reference type descriptor.
Return #t
if obj is a type.
Return the symbolic ID of type.
Return the type descriptor of type.
Types may also be nested within recursive type groups that allow for circular and self references to the types within the group. Types not within a group can be thought of as belonging to a group of one.
Return #t
if obj is a recursive type group.
Return the types within rec-group.
Note that while each Wasm module contains a full inventory of its
types, structurally identical type groups across Wasm modules are
canonicalized at runtime and are considered to be identical
(eq?
in Scheme terms.) This allows for passing references
between modules.
Type uses refer to function signatures and are used for specifying the
type of a block
, loop
, or if
expression.
Return #t
if obj is a type use.
Return the type index of type-use.
Return the function signature of type-use.
Return #t
if obj is a reference type.
Return #t if ref-type is nullable.
Return the heap type of ref-type.
As mentioned above, reference types support structural subtyping.
Return #t
if obj is a sub type.
Return #t
if sub-type is marked as final.
Return super types of sub-type.
Return the concrete type descriptor of sub-type.
Compound types take the form of arrays and structs.
Return #t
if obj is an array type.
Return #t
if array-type is mutable.
Retun the element type descriptor of array-type.
Return #t
if obj is a struct type.
Return the field descriptors of struct-type.
Struct types are composed of several fields.
Return #t
if obj is a struct field.
Return the symbolic ID of field.
Return #t
if field is mutable.
Return the type descriptor of field.
Both arrays and struct fields allow for packed data using the special
i8
and i16
data types.
Wasm supports both mutable and immutable global variables.
Return #t
if obj is a global.
Return the symbloc ID of global.
Return the type of global.
Return the initialization instructions of global. Only constant instructions are allowed.
Return #t
if obj is a global type.
Return #t
if global-type is mutable.
Return the type descriptor of global-type.
Return #t
if obj is a function.
Return the symbolic ID of func.
Return the signature of func.
Return the locals of func.
Return the body instructions of func.
The type of a function is its signature. Notably, Wasm supports multiple return values, just like Scheme.
Return #t
if obj is a function signature.
Return the parameters of func.
Return the result types of func.
Function parameters pair a local identifier with its type.
Return #t
if obj is a param.
Return the symbolic ID of param.
Return the type descriptor of param.
Locals provide additional mutable variables scoped to the body of a function.
Return #t
if obj is a function local.
Return the symbolic ID of local.
Return the type descriptor of local.
Functions, globals, memories, and tables can be imported from the host or another Wasm module. They are organized into a two layer hierarchy. An import module groups many imports under an umbrella name, and then the individual item names distinguish imported data within a module.
Return #t
if obj is an import.
Return the module name string of import.
Return the name string of import.
Return the kind of import. Either func
, global
,
memory
, or table
.
Return the symbolic ID of import.
Return the type descriptor of import.
Likewise, functions, globals, memories, and tables can be exported from a module to be used by the host or by other modules.
Return #t
if obj is an export.
Return the name string of export.
Return the kind of export. Either func
, global
,
memory
, or table
.
Return the index of export.
Memory objects specify linear chunks of bytes that a module can write to/read from at runtime. The size of a memory is specified in terms of 64KiB pages. While many memory objects coud be included in a module, the Wasm specification currently only allows the use of a single memory at index 0.
Return #t
if obj is a memory.
Return the symbolic ID of memory.
The type of a memory currently just specifies the size limitations.
Return the type of memory.
Return #t
if obj is a memory type.
Return the limits of mem-type.
Instructions that manipulate linear memory use the memory argument type to point to a specific offset within a memory.
Return #t
if obj is a memory argument.
Return the symbolic ID of mem-arg.
Return the offset of mem-arg.
Return the alignment of mem-arg.
Data segments are static chunks of data used to initialize regions of memory. They have two possible modes of use:
memory.init
instruction.
Return #t
if obj is a data segment.
Return the symbolic ID of data.
Return the mode of data. Either passive
or
active
.
Return the memory associated with data.
Return the instructions that compute the offset of data. Only constant instructions are allowed.
Return a bytevector containing the initialization data of data.
Tables specify a vector of heap object references of a particular reference type.
Return #t
if obj is a reference table.
Return the symbolic ID of table.
Return the type of table.
Table types specify the reference type of the elements as well as the size limitations.
Return #t
if obj is a table type.
Return the limts of table-type.
Return the element type of table-type.
Element segments are static vectors of references used to initialize regions of tables (well, mostly.) They have three possible modes of use:
table.init
instruction.
Return #t
if obj is an element segment.
Return the symoblic ID of elem.
Return the mode of elem.
Return the table associated with elem.
Return the type of elem.
Return the instructions that compute the offset of elem. Only constant instructions are allowed.
Return a list of initializer instructions for the items of elem. Only constant instructions are allowed.
Both memories and tables use limits to constrain their minimum and
maximum size. A valid limit must have a minimum of at least 1, but
the maximum may be #f
if unbounded growth is allowed.
Return #t
if obj is a limits.
Return the minimum value of limits.
Return the maximum value of limits or #f
if there is no
maximum.
Tag segments specify types of runtime errors that may be raised.
Return #t
if obj is a tag.
Return the symbolic ID of tag.
Return the type of tag.
Custom segments specify arbitrary data that is not covered by the Wasm specification.
Return #t
if obj is a custom segment.
Return the name of custom.
Return the bytevector of custom.
Next: GWAT, Up: Toolchain reference [Contents][Index]