diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-07-11 00:27:55 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-07-11 00:27:55 +0900 |
| commit | 2e3505bea41552ba28978399cddead52d64d7e85 (patch) | |
| tree | fe963ad219582f6b1decc9fc5ca99bc07302971c /examples/php-on-wasm | |
| parent | ba5a17008cb153512e484f144e35e28cff8b7640 (diff) | |
| download | php-waddiwasi-2e3505bea41552ba28978399cddead52d64d7e85.tar.gz php-waddiwasi-2e3505bea41552ba28978399cddead52d64d7e85.tar.zst php-waddiwasi-2e3505bea41552ba28978399cddead52d64d7e85.zip | |
feat: support streaming decoding
Diffstat (limited to 'examples/php-on-wasm')
| -rw-r--r-- | examples/php-on-wasm/php-wasm.php | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/examples/php-on-wasm/php-wasm.php b/examples/php-on-wasm/php-wasm.php index 92871cd..697b5b3 100644 --- a/examples/php-on-wasm/php-wasm.php +++ b/examples/php-on-wasm/php-wasm.php @@ -5,33 +5,24 @@ declare(strict_types=1); require_once __DIR__ . '/../../vendor/autoload.php'; use Nsfisis\Waddiwasi\BinaryFormat\Decoder; -use Nsfisis\Waddiwasi\BinaryFormat\InvalidBinaryFormatException; use Nsfisis\Waddiwasi\Execution\Extern; use Nsfisis\Waddiwasi\Execution\Externs; use Nsfisis\Waddiwasi\Execution\FuncInst; use Nsfisis\Waddiwasi\Execution\Refs; use Nsfisis\Waddiwasi\Execution\Runtime; use Nsfisis\Waddiwasi\Execution\Store; +use Nsfisis\Waddiwasi\Stream\FileStream; use Nsfisis\Waddiwasi\Structure\Types\FuncType; use Nsfisis\Waddiwasi\Structure\Types\NumType; use Nsfisis\Waddiwasi\Structure\Types\ResultType; use Nsfisis\Waddiwasi\Structure\Types\ValType; -const PHP_EMPTY = ''; - const PHP_HELLO_WORLD = <<<'EOS' echo "Hello, World!\n"; EOS; -$wasmBinary = file_get_contents(__DIR__ . '/php-wasm.wasm'); -\assert($wasmBinary !== false); - -try { - $module = (new Decoder($wasmBinary))->decode(); -} catch (InvalidBinaryFormatException $e) { - fprintf(STDERR, $e->getMessage() . "\n"); - exit(1); -} +$wasmBinaryStream = new FileStream(__DIR__ . '/php-wasm.wasm'); +$module = (new Decoder($wasmBinaryStream))->decode(); $imports = [ 'env' => [ |
