5.3 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.

5.3.1 Number Types

Number types are encoded by a single byte.

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

5.3.2 Vector Types

Vector types are also encoded by a single byte.

vectype::=0x7Bv128

5.3.3 Reference Types

Reference types are also encoded by a single byte.

reftype::=0x70funcref|0x6Fexternref

5.3.4 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.

5.3.5 Result Types

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

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

5.3.6 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

5.3.7 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}

5.3.8 Memory Types

Memory types are encoded with their limits.

memtype::=lim:limitslim

5.3.9 Table Types

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

tabletype::=et:reftype  lim:limitslim et

5.3.10 Global Types

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

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