Types

Number Types

numtypeI::=i32i32|i64i64|f32f32|f64f64

Vector Types

vectypeI::=v128v128

Heap Types

absheaptype::=anyany|eqeq|i31i31|structstruct|arrayarray|nonenone|funcfunc|nofuncnofunc|externextern|noexnnoexn|exnexn|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 )exnref( ref  null  exn )nullexnref( ref  null  noexn )externref( ref  null  extern )nullexternref( ref  null  noextern )

Value Types

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

Composite Types

comptypeI::=( struct  ft:list(fieldI) )struct ft|( array  ft:fieldtypeI )array ft|( func  t1:list(paramI)  t2:list(resultI) )func [t1][t2]paramI::=( param  id?  t:valtypeI )tresultI::=( result  t:valtypeI )tfieldI::=( field  id?  ft:fieldtypeI )ftfieldtypeI::=st:storagetypest|( mut  st:storagetype )mut ststoragetypeI::=t:valtypeIt|t:packtypetpacktype::=i8i8|i16i16

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  ))

Similarly, multiple anonymous structure fields may be combined into a single declaration:

(  field  fieldtype  )((  field  fieldtype  ))

Recursive Types

rectypeI::=( rec  st:list(typedefI) )rec sttypedefI::=( type  id?  st:subtypeI )stsubtypeI::=( sub  final?  x:list(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  )

Address Types

addrtype::=i32i32|i64i64

Abbreviations

The address type can be omitted, in which case it defaults i32:

i32

Limits

limitsN::=n:u64[n..2N]|n:u64  m:u64[n..m]

Tag Types

tagtypeI::=x,I:typeuseIx

Global Types

globaltypeI::=t:valtypeIt|( mut  t:valtypeI )mut t

Memory Types

memtypeI::=at:addrtype  lim:limits|at|/64Kiat lim page

Table Types

tabletypeI::=at:addrtype  lim:limits|at|  et:reftypeIat lim et

External Types

externtypeI::=( tag  id?  tt:tagtype )tag tt|( global  id?  gt:globaltypeI )global gt|( memory  id?  mt:memtypeI )mem  mt|( table  id?  tt:tabletypeI )table tt|( func  id?  x,I:typeuseI )func x