diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-04-06 02:31:47 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-04-06 02:31:47 +0900 |
| commit | d33b1cc0416b8f0b05efcd2fad5200fd1db998a1 (patch) | |
| tree | 844a9d4cf1052c8a80f63320909c890a2228a14f /examples/hello-world/index.php | |
| parent | fa9ad79209d85b0677b00ca1d41d070105fec09f (diff) | |
| download | php-waddiwasi-d33b1cc0416b8f0b05efcd2fad5200fd1db998a1.tar.gz php-waddiwasi-d33b1cc0416b8f0b05efcd2fad5200fd1db998a1.tar.zst php-waddiwasi-d33b1cc0416b8f0b05efcd2fad5200fd1db998a1.zip | |
refactor: add Runtime::instantiateFromStream()
Diffstat (limited to 'examples/hello-world/index.php')
| -rw-r--r-- | examples/hello-world/index.php | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/examples/hello-world/index.php b/examples/hello-world/index.php index 6129a07..74989a3 100644 --- a/examples/hello-world/index.php +++ b/examples/hello-world/index.php @@ -5,7 +5,6 @@ declare(strict_types=1); require_once __DIR__ . '/../../vendor/autoload.php'; use Nsfisis\Waddiwasi\Stream\BlobStream; -use Nsfisis\Waddiwasi\WebAssembly\BinaryFormat\Decoder; use Nsfisis\Waddiwasi\WebAssembly\Execution\Extern; use Nsfisis\Waddiwasi\WebAssembly\Execution\FuncInst; use Nsfisis\Waddiwasi\WebAssembly\Execution\Linker; @@ -23,13 +22,13 @@ $wasmBinary = ("" . "\x00\x41\xd7\x00\x10\x00\x41\xef\x00\x10\x00\x41\xf2\x00\x10\x00" . "\x41\xec\x00\x10\x00\x41\xe4\x00\x10\x00\x41\x21\x10\x00\x41\x0a" . "\x10\x00\x0b"); -$module = (new Decoder(new BlobStream($wasmBinary)))->decode(); +$wasmBinaryStream = new BlobStream($wasmBinary); $store = Store::empty(); $linker = new Linker($store); $linker->register('', 'putc', Extern::Func(FuncInst::Host(new FuncType([ValType::I32], []), function (Runtime $runtime, int $c) { printf('%c', $c); }))); -$runtime = Runtime::instantiate($module, $linker); +$runtime = Runtime::instantiateFromStream($wasmBinaryStream, $linker); $runtime->invoke('main', []); |
