beetlebug▾
/

ztcl::wasm imports

Gives the module, the name, the kind, and the type of each import.

ztcl::wasm imports MODULE

Description

Gives a flat list of four items for each import of MODULE: the import module, the name, the kind, and the type, as exports gives them.

Arguments

ArgumentTypeDefaultDescription
MODULEhandlerequiredA module handle.

Returns

A list of module, name, kind, and type for each import.

Examples

Each example of this page runs after package require ztcl::wasm # (func (export "add") (param i32 i32) (result i32)) set m [ztcl::wasm new [binary decode hex 0061736d0100000001070160027f7f017f030201000707010361646400000a09010700200020016a0b]] set w [ztcl::wasm instantiate $m] # (memory (export "memory") 1 2), the bytes "hi" at 16, the globals "g" (mut i32 5) and "k" (i64 7), and (func (export "div") (param i32 i32) (result i32)) of i32.div_s set mem [ztcl::wasm new [binary decode hex 0061736d0100000001070160027f7f017f03020100050401010102060b027f0141050b7e0042070b071804066d656d6f7279020001670300016b03010364697600000a09010700200020016d0b0b09010041100b03686900]] .

% set lm [ztcl::wasm new [binary decode hex 0061736d0100000001080260017f00600000020b0103656e76036c6f670000030201010707010372756e00010a08010600410710000b]]
> ztcl::wasm imports $lm
env log func {i32 {}}

% ztcl::wasm imports $m

Errors

% ztcl::wasm imports $w
can not find wasm module "wasm0"
-errorcode ZTCL WASM HANDLE

% ztcl::wasm imports
wrong # args: should be "ztcl::wasm imports module"
-errorcode TCL WRONGARGS

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.1
Compute cost
One compute unit for each call and each loop pass of the wasm code.

See also