Skip to content

Conversation

@veewee
Copy link
Owner

@veewee veewee commented Aug 3, 2023

See #5

This PR introduces support for function reference value types.

For example:

$builder = InstanceBuilder::fromWat(
    <<<'EOWAT'
    (module
        (import "env" "greet" (func $greet))
        (func
            call $greet
        )
        (start 1) ;; run the first function automatically
    )
    EOWAT
);

$imports = Imports::create();
$imports->define('env', 'greet', Type\Global::immutable(
    function () use ($result) {
        echo 'Hello!';
    }
));


$builder->import($imports);
$instance = $builder->build();

Hello!

@veewee veewee marked this pull request as draft August 3, 2023 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants