ztcl::wasm exports
Gives the name, the kind, and the type of each export.
ztcl::wasm exports MODULE|INSTANCE
Description
Gives a flat list of three items for each export: its name; its kind, func, table, mem, or global; and its type. The type of a function is the list of its parameter types and its result types, the type of a table or a memory is its minimum and its maximum, empty for no maximum, and the type of a global is its value type.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| MODULE|INSTANCE | handle | required | A module handle or an instance handle. |
Returns
A list of name, kind, and type for each export.
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]]
.
% list [ztcl::wasm exports $m] [ztcl::wasm exports $w]
{add func {{i32 i32} i32}} {add func {{i32 i32} i32}}
% ztcl::wasm exports $mem
memory mem {1 2} g global i32 k global i64 div func {{i32 i32} i32}
% # (table (export "t") 2 funcref)
> ztcl::wasm exports [ztcl::wasm new [binary decode hex 0061736d0100000004040170000207050101740100]]
t table {2 {}}
Errors
% ztcl::wasm exports nope
can not find wasm instance "nope"
-errorcode ZTCL WASM HANDLE
% ztcl::wasm exports
wrong # args: should be "ztcl::wasm exports module|instance"
-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.