Types¶
Note
In some places, possible types include both type constructors or types denoted by type indices.
Thus, the binary format for type constructors corresponds to the encodings of small negative
Number Types¶
Number types are encoded by a single byte.
Vector Types¶
Vector types are also encoded by a single byte.
Heap Types¶
Heap types are encoded as either a single byte, or as a type index encoded as a positive signed integer.
Note
The heap type
Reference Types¶
Reference types are either encoded by a single byte followed by a heap type, or, as a short form, directly as an abstract heap type.
Value Types¶
Value types are encoded with their respective encoding as a number type, vector type, or reference type.
Note
The value type
Value types can occur in contexts where type indices are also allowed, such as in the case of block types.
Thus, the binary format for types corresponds to the signed LEB128 encoding of small negative
Result Types¶
Result types are encoded by the respective lists of value types.
Composite Types¶
Composite types are encoded by a distinct byte followed by a type encoding of the respective form.
Recursive Types¶
Recursive types are encoded by the byte
Limits¶
Limits are encoded with a preceding flag indicating whether a maximum is present, and a flag for the address type.
Memory Types¶
Memory types are encoded with their limits.
Table Types¶
Table types are encoded with their limits and the encoding of their element reference type.
Global Types¶
Global types are encoded by their value type and a flag for their mutability.
Tag Types¶
Tag types are encoded by a type index denoting a function type.
Note
In future versions of WebAssembly, the preceding zero byte may encode additional flags.
External Types¶
External types are encoded by a distiguishing byte followed by an encoding of the respective form of type.