table.copy
Copy elements from one table to another. You can copy elements from and to the same table.

Syntax

table.copy $destinationTable $sourceTable

Parameters

$destinationTable Optional
If there is no source and destination tables given then the default table is used. If used then this points to a (table...) object to copy the elements to.
$sourceTable Optional
This points to a (table...) object to copy the elements from. If the destination is given then this is required too.

Stack In

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

Stack Out

NONE

Example

;; Create tables of function references
(table $tableFrom 10 funcref)
(table $tableTo 10 funcref)

;; Create function
(func $copyTable
  ;; Set the offset within the destination table to copy the elements to
  i32.const 4

  ;; Set the offset within the source table to copy the elements from
  i32.const 2

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

  ;; Copy the elements from one to another
  table.copy $tableTo $tableFrom

  ;; The 6 elements from tableFrom (at offset 2) were copied
  ;; into tableTo (at offset 4)
)