aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/WebAssembly/Execution
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-04-06 02:31:47 +0900
committernsfisis <nsfisis@gmail.com>2025-04-06 02:31:47 +0900
commitd33b1cc0416b8f0b05efcd2fad5200fd1db998a1 (patch)
tree844a9d4cf1052c8a80f63320909c890a2228a14f /src/WebAssembly/Execution
parentfa9ad79209d85b0677b00ca1d41d070105fec09f (diff)
downloadphp-waddiwasi-d33b1cc0416b8f0b05efcd2fad5200fd1db998a1.tar.gz
php-waddiwasi-d33b1cc0416b8f0b05efcd2fad5200fd1db998a1.tar.zst
php-waddiwasi-d33b1cc0416b8f0b05efcd2fad5200fd1db998a1.zip
refactor: add Runtime::instantiateFromStream()
Diffstat (limited to 'src/WebAssembly/Execution')
-rw-r--r--src/WebAssembly/Execution/Runtime.php12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/WebAssembly/Execution/Runtime.php b/src/WebAssembly/Execution/Runtime.php
index 1bb440b..a120d7d 100644
--- a/src/WebAssembly/Execution/Runtime.php
+++ b/src/WebAssembly/Execution/Runtime.php
@@ -4,6 +4,8 @@ declare(strict_types=1);
namespace Nsfisis\Waddiwasi\WebAssembly\Execution;
+use Nsfisis\Waddiwasi\Stream\StreamInterface;
+use Nsfisis\Waddiwasi\WebAssembly\BinaryFormat\Decoder;
use Nsfisis\Waddiwasi\WebAssembly\Structure\Instructions\Instr;
use Nsfisis\Waddiwasi\WebAssembly\Structure\Instructions\Instrs;
use Nsfisis\Waddiwasi\WebAssembly\Structure\Instructions\Instrs\Control\BlockType;
@@ -125,6 +127,16 @@ final class Runtime implements ExporterInterface
return new self($store, $stack, $moduleInst);
}
+ public static function instantiateFromStream(
+ StreamInterface $stream,
+ Linker $linker,
+ ): self {
+ return self::instantiate(
+ (new Decoder($stream))->decode(),
+ $linker,
+ );
+ }
+
public function exports(): array
{
return $this->module->exports;