(element...)
Declares the function references that goes into a (table...)
object.
This is used to initialize the table when the module is created. It is used
to declare functions that will later be inserted into a table.
You can also declare a passive list of function reference that are not automatically added to a table
but can be copied into one manually.
Syntax
(elem $table (i32.const offset) $function1 $functionN)
(elem declare func $function1 $functionN)
(elem $passiveData func $function1 $functionN)
Parameters
$table Optional
The table where the function references are to be set. If not given then the default table is used.
If used then this points to the (table...)
object.
offset
The index offset within the table that the function references will be stored.
$passiveData
The label for the passive data. This will be used when copying the function references into a table.
$function1
The label of the function that will be placed into the table. Its reference, the pointer to the function, will be placed
into the table, not the whole function itself.
$functionN Optional
You can have any number of function references in the element.
Examples
(table 10 funcref)
(elem (i32.const 0) $add1 $add2)
(table $table 10 funcref)
(elem $passiveElement func $add $sub $mul)
(func $setupTable
i32.const 0
i32.const 0
i32.const 3
table.init $table $passiveElement
)