ref.func
Pushes a reference to a function onto the stack. This can then be placed inside a (table...) and then called indirectly.

Syntax

ref.func $function

Parameters

$function
The function you want the reference to.

Stack In

NONE

Stack Out

funcref A reference to a function.

Example

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

;; Create set table function
(func $setTable
  ;; Set the function at index 0
  i32.const 1

  ;; Set the function reference value to $add1
  ref.func $add1

  ;; Set the table with the $add1 function reference
  table.set

  ;; The table index 0 has a function reference to $add1
)