table.fill
Fill part of a table with a value.

Syntax

table.fill $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 offset within the table to start filling in.
funcref A reference to a function to fill the elements with.
i32 The number of elements in the table to fill.

Stack Out

NONE

Examples

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

;; Create function
(func $fillDefaultTable
  ;; Set the offset within the table to start filling in elements
  i32.const 2

  ;; Set what to fill the elements in the table with
  ref.null func

  ;; Set the number of elements to fill
  i32.const 4

  ;; Fill the default table
  table.fill

  ;; The table from index 2 for 4 elements now contain
  ;; null function references.
)
;; Create labelled table of function references
(table $testTable 6 funcref)

;; Create function
(func $fillTestTable
  ;; Set the offset within the table to start filling in elements
  i32.const 0

  ;; Set what to fill the elements in the table with
  ref.null func

  ;; Set the number of elements to fill
  i32.const 6

  ;; Fill the test table
  table.fill $testTable

  ;; All the table elements are set to null function references.
)