The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Wasm::Wasm3::Module

SYNOPSIS

See Wasm::Wasm3.

DESCRIPTION

This module exposes wasm3’s module object to Perl.

METHODS

This class is not directly instantiated; see Wasm::Wasm3 for details.

$value = OBJ->get_global( $NAME )

Returns the value of the $NAMEd export global.

$type = OBJ->get_global_type( $NAME )

Returns the type (e.g., Wasm::Wasm3::TYPE_I32) of the $NAMEd export global.

Sets $CODEREF as $MODULE_NAME.$FUNCTION_NAME’s implementation inside the WebAssembly module. See below for "$SIGNATURE".

$CODEREF will always be called in list context. $CODEREF MUST return the number of arguments that $SIGNATURE indicates, or you’ll get an error (possibly an unhelpful one).

If $CODEREF throws, the exception is warn()ed, and a generic callback-failed error is thrown to the link_function() caller.

$SIGNATURE

$SIGNATURE is wasm3’s own convention to describe a function’s inputs & outputs. As of this writing wasm3’s documentation doesn’t describe it very well, so we’ll describe it here.

The format is $RETURNS($ARGS), where $RETURNS and $ARGS are both either:

  • v, to indicate empty (v meaning “void”)

  • … a sequence of one or more of: i (i32), I (i64), f (f32), F, (f64)

Space characters are ignored.

For example: v(if) indicates a function that takes i32 and f32 as arguments and returns nothing.