table.init
Copy functions references from data into a table. You can store a collection of function references in a passive data object and copy them into a table before they need to be used.

Syntax

table.init $tableLabel $elementLabel

Parameters

$tableLabel Optional
If there is no label then the default table is used. If used then this points to a (table...) object.
$elementLabel
This points to a passive data (element...) object to copy the elements from.

Stack In

i32 The offset within the destination table to copy to.
i32 The offset within the source element to copy from.
i32 The number of elements to copy.

Stack Out

NONE

Example

;; Create table of function references
(table $table 10 funcref)

;; Create element listing function references
(elem $passiveElement func $add $sub $mul)

;; Create function
(func $setupTable
  ;; Set the offset in destination table to copy the elements to
  i32.const 0

  ;; Set the offset in source element data to copy the elements from
  i32.const 0

  ;; Set the number of elements to copy
  i32.const 3

  ;; Initialize the table with the data elements
  table.init $table $passiveElement

  ;; The 3 elements from data are also now in the table
)