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 sN values, such that they can unambiguously occur in the same place as (positive) type indices.

Number Types

Number types are encoded by a single byte.

numtype::=0x7Fi32|0x7Ei64|0x7Df32|0x7Cf64

Vector Types

Vector types are also encoded by a single byte.

vectype::=0x7Bv128

Reference Types

Reference types are also encoded by a single byte.

reftype::=0x70funcref|0x6Fexternref

Value Types

Value types are encoded with their respective encoding as a number type, vector type, or reference type.

valtype::=t:numtypet|t:vectypet|t:reftypet

Note

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 sN values, so that they can coexist with (positive) type indices in the future.

Result Types

Result types are encoded by the respective vectors of value types.

resulttype::=t:vec(valtype)[t]

Function Types

Function types are encoded by the byte 0x60 followed by the respective vectors of parameter and result types.

functype::=0x60  rt1:resulttype  rt2:resulttypert1rt2

Limits

Limits are encoded with a preceding flag indicating whether a maximum is present.

limits::=0x00  n:u32{min n,max ϵ}|0x01  n:u32  m:u32{min n,max m}

Memory Types

Memory types are encoded with their limits.

memtype::=lim:limitslim

Table Types

Table types are encoded with their limits and the encoding of their element reference type.

tabletype::=et:reftype  lim:limitslim et

Global Types

Global types are encoded by their value type and a flag for their mutability.

globaltype::=t:valtype  m:mutm tmut::=0x00const|0x01var