Types

Number Types

numtypeI::=i32i32|i64i64|f32f32|f64f64

Vector Types

vectypeI::=v128v128

Heap Types

absheaptype::=anyany|eqeq|i31i31|structstruct|arrayarray|nonenone|funcfunc|nofuncnofunc|externextern|noexternnoexternheaptypeI::=t:absheaptypey|x:typeidxIx

Reference Types

reftypeI::=( ref  ht:heaptype )ref ht|( ref  null  ht:heaptype )ref null ht

Abbreviations

There are shorthands for references to abstract heap types.

anyref( ref  null  any )eqref( ref  null  eq )i31ref( ref  null  i31 )structref( ref  null  struct )arrayref( ref  null  array )nullref( ref  null  none )funcref( ref  null  func )nullfuncref( ref  null  nofunc )externref( ref  null  extern )nullexternref( ref  null  noextern )

Value Types

valtypeI::=t:numtypeIt|t:vectypeIt|t:reftypeIt

Function Types

functypeI::=( func  t1:vec(paramI)  t2:vec(resultI) )[t1][t2]paramI::=( param  id?  t:valtypeI )tresultI::=( result  t:valtypeI )t

Note

The optional identifier names for parameters in a function type only have documentation purpose. They cannot be referenced from anywhere.

Abbreviations

Multiple anonymous parameters or results may be combined into a single declaration:

(  param  valtype  )((  param  valtype  ))(  result  valtype  )((  result  valtype  ))

Aggregate Types

arraytypeI::=( array  ft:fieldtypeI )ftstructtypeI::=( struct  ft:vec(fieldI) )ftfieldI::=( field  id?  ft:fieldtypeI )ftfieldtypeI::=st:storagetypeconst st|( mut  st:storagetype )var ststoragetypeI::=t:valtypeIt|t:packedtypetpackedtype::=i8i8|i16i16

Abbreviations

Multiple anonymous structure fields may be combined into a single declaration:

(  field  fieldtype  )((  field  fieldtype  ))

Composite Types

comptypeI::=at:arraytypeIarray at|st:structtypeIstruct at|ft:functypeIfunc ft

Recursive Types

rectypeI::=( rec  st:vec(typedefI) )rec sttypedefI::=( type  id?  st:subtypeI )stsubtypeI::=( sub  final?  x:vec(typeidxI)  ct:comptypeI )sub final? x ct

Abbreviations

Singular recursive types can omit the rec keyword:

typedef(  rec  typedef  )

Similarly, final sub types with no super-types can omit the sub keyword and arguments:

comptype(  sub  final  ϵ  comptype  )

Limits

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

Memory Types

memtypeI::=lim:limitslim

Table Types

tabletypeI::=lim:limits  et:reftypeIlim et

Global Types

globaltypeI::=t:valtypeconst t|( mut  t:valtypeI )var t