aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/hello-world/index.php5
-rw-r--r--examples/php-on-wasm/php-wasm.php4
-rw-r--r--examples/rubyvm-on-php-on-wasm/php-wasm.php4
3 files changed, 4 insertions, 9 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', []);
diff --git a/examples/php-on-wasm/php-wasm.php b/examples/php-on-wasm/php-wasm.php
index 90a5c1a..c66b79c 100644
--- a/examples/php-on-wasm/php-wasm.php
+++ b/examples/php-on-wasm/php-wasm.php
@@ -5,7 +5,6 @@ declare(strict_types=1);
require_once __DIR__ . '/../../vendor/autoload.php';
use Nsfisis\Waddiwasi\Stream\FileStream;
-use Nsfisis\Waddiwasi\WebAssembly\BinaryFormat\Decoder;
use Nsfisis\Waddiwasi\WebAssembly\Execution\Runtime;
const PHP_HELLO_WORLD = <<<'EOS'
@@ -15,9 +14,8 @@ EOS;
$linker = (require_once __DIR__ . '/emscripten_bridge.php');
$wasmBinaryStream = new FileStream(__DIR__ . '/php-wasm.wasm');
-$module = (new Decoder($wasmBinaryStream))->decode();
-$runtime = Runtime::instantiate($module, $linker);
+$runtime = Runtime::instantiateFromStream($wasmBinaryStream, $linker);
$codePtr = allocateStringOnWasmMemory($runtime, PHP_HELLO_WORLD);
$results = $runtime->invoke("php_wasm_run", [$codePtr]);
diff --git a/examples/rubyvm-on-php-on-wasm/php-wasm.php b/examples/rubyvm-on-php-on-wasm/php-wasm.php
index 148b98a..c89c8c4 100644
--- a/examples/rubyvm-on-php-on-wasm/php-wasm.php
+++ b/examples/rubyvm-on-php-on-wasm/php-wasm.php
@@ -5,7 +5,6 @@ declare(strict_types=1);
require_once __DIR__ . '/../../vendor/autoload.php';
use Nsfisis\Waddiwasi\Stream\FileStream;
-use Nsfisis\Waddiwasi\WebAssembly\BinaryFormat\Decoder;
use Nsfisis\Waddiwasi\WebAssembly\Execution\Runtime;
const PHP_HELLO_WORLD = <<<'EOS'
@@ -13,11 +12,10 @@ require_once '%DIR%/HelloWorld.php';
EOS;
$wasmBinaryStream = new FileStream(__DIR__ . '/php-wasm.wasm');
-$module = (new Decoder($wasmBinaryStream))->decode();
$linker = require_once __DIR__ . '/emscripten_bridge.php';
-$runtime = Runtime::instantiate($module, $linker);
+$runtime = Runtime::instantiateFromStream($wasmBinaryStream, $linker);
$codePtr = allocateStringOnWasmMemory($runtime, strtr(PHP_HELLO_WORLD, ['%DIR%' => __DIR__]));
$results = $runtime->invoke("php_wasm_run", [$codePtr]);