From d33b1cc0416b8f0b05efcd2fad5200fd1db998a1 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 6 Apr 2025 02:31:47 +0900 Subject: refactor: add Runtime::instantiateFromStream() --- examples/hello-world/index.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'examples/hello-world/index.php') 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', []); -- cgit v1.2.3-70-g09d2