table.get
Gets a function reference from a table and pushes it onto the stack.

Syntax

table.get $label

Parameters

$label Optional
If there is no label then the default table is used. If used then this points to a (table...) object.

Stack In

i32 The index of the function reference in the table.

Stack Out

funcref The reference to a function.

Examples

;; Create default table of function references
(table 4 funcref)

;; Create table test function
(func $test
  ;; Create local function reference
  (local $function funcref)

  ;; Get function at index 0
  i32.const 0
  table.get
  local.set $function

  ;; Set the function at index 1
  i32.const 1
  local.get $function
  table.set

  ;; The table index 0 and 1 both point to the same function
)
;; Create labelled table of function references
(table $testTable 6 funcref)

;; Create table test function
(func $test
  ;; Create local function reference
  (local $function funcref)

  ;; Get function at index 0
  i32.const 0
  table.get $testTable
  local.set $function

  ;; Set the function at index 1
  i32.const 1
  local.get $function
  table.set $testTable

  ;; The $testTable table index 0 and 1 both point to the same function
)