aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-01-27 13:22:56 +0900
committernsfisis <nsfisis@gmail.com>2024-02-26 11:07:06 +0900
commit900377463a8264871ee42e488112b076b7973b6a (patch)
treebf727d3484ca7c8d35f18ef29ea8d9305d4b57da
parente2495878b872b341e6e04eed31dd255b1a6e256f (diff)
downloadphp-waddiwasi-900377463a8264871ee42e488112b076b7973b6a.tar.gz
php-waddiwasi-900377463a8264871ee42e488112b076b7973b6a.tar.zst
php-waddiwasi-900377463a8264871ee42e488112b076b7973b6a.zip
feat: partially implement execution
-rw-r--r--composer.json2
-rw-r--r--index.php10
-rw-r--r--src/BinaryFormat/Decoder.php15
-rw-r--r--src/Execution/Allocator.php162
-rw-r--r--src/Execution/DataAddr.php13
-rw-r--r--src/Execution/DataInst.php16
-rw-r--r--src/Execution/ElemAddr.php13
-rw-r--r--src/Execution/ElemInst.php19
-rw-r--r--src/Execution/ExportInst.php17
-rw-r--r--src/Execution/ExternAddr.php13
-rw-r--r--src/Execution/ExternVal.php28
-rw-r--r--src/Execution/ExternVals/Func.php16
-rw-r--r--src/Execution/ExternVals/Global_.php16
-rw-r--r--src/Execution/ExternVals/Mem.php16
-rw-r--r--src/Execution/ExternVals/Table.php16
-rw-r--r--src/Execution/FuncAddr.php13
-rw-r--r--src/Execution/FuncInst.php21
-rw-r--r--src/Execution/FuncInsts/Host.php20
-rw-r--r--src/Execution/FuncInsts/Wasm.php20
-rw-r--r--src/Execution/GlobalAddr.php13
-rw-r--r--src/Execution/GlobalInst.php16
-rw-r--r--src/Execution/MemAddr.php13
-rw-r--r--src/Execution/MemInst.php19
-rw-r--r--src/Execution/ModuleInst.php32
-rw-r--r--src/Execution/Num.php40
-rw-r--r--src/Execution/Nums/F32_.php18
-rw-r--r--src/Execution/Nums/F64_.php18
-rw-r--r--src/Execution/Nums/I32.php18
-rw-r--r--src/Execution/Nums/I64.php18
-rw-r--r--src/Execution/Ref.php25
-rw-r--r--src/Execution/Refs/RefExtern.php16
-rw-r--r--src/Execution/Refs/RefFunc.php16
-rw-r--r--src/Execution/Refs/RefNull.php16
-rw-r--r--src/Execution/Result.php21
-rw-r--r--src/Execution/Results/Trap.php11
-rw-r--r--src/Execution/Results/Values.php19
-rw-r--r--src/Execution/Runtime.php561
-rw-r--r--src/Execution/Stack.php42
-rw-r--r--src/Execution/StackEntries/Frame.php23
-rw-r--r--src/Execution/StackEntries/Label.php21
-rw-r--r--src/Execution/StackEntries/Value.php16
-rw-r--r--src/Execution/StackEntry.php38
-rw-r--r--src/Execution/Store.php31
-rw-r--r--src/Execution/TableAddr.php13
-rw-r--r--src/Execution/TableInst.php19
-rw-r--r--src/Execution/Val.php18
-rw-r--r--src/Execution/Vals/Num.php16
-rw-r--r--src/Execution/Vals/Ref.php16
-rw-r--r--src/Structure/Instructions/Instrs/Control/Block.php2
-rw-r--r--src/Structure/Instructions/Instrs/Control/Br.php2
-rw-r--r--src/Structure/Instructions/Instrs/Control/BrIf.php2
-rw-r--r--src/Structure/Instructions/Instrs/Control/BrTable.php2
-rw-r--r--src/Structure/Instructions/Instrs/Control/Call.php2
-rw-r--r--src/Structure/Instructions/Instrs/Control/CallIndirect.php2
-rw-r--r--src/Structure/Instructions/Instrs/Control/If_.php2
-rw-r--r--src/Structure/Instructions/Instrs/Control/Loop.php2
-rw-r--r--src/Structure/Instructions/Instrs/Memory/DataDrop.php2
-rw-r--r--src/Structure/Instructions/Instrs/Memory/F32Load.php2
-rw-r--r--src/Structure/Instructions/Instrs/Memory/F32Store.php2
-rw-r--r--src/Structure/Instructions/Instrs/Memory/F64Load.php2
-rw-r--r--src/Structure/Instructions/Instrs/Memory/F64Store.php2
-rw-r--r--src/Structure/Instructions/Instrs/Memory/I32Load.php2
-rw-r--r--src/Structure/Instructions/Instrs/Memory/I32Load16S.php2
-rw-r--r--src/Structure/Instructions/Instrs/Memory/I32Load16U.php2
-rw-r--r--src/Structure/Instructions/Instrs/Memory/I32Load8S.php2
-rw-r--r--src/Structure/Instructions/Instrs/Memory/I32Load8U.php2
-rw-r--r--src/Structure/Instructions/Instrs/Memory/I32Store.php2
-rw-r--r--src/Structure/Instructions/Instrs/Memory/I32Store16.php2
-rw-r--r--src/Structure/Instructions/Instrs/Memory/I32Store8.php2
-rw-r--r--src/Structure/Instructions/Instrs/Memory/I64Load.php2
-rw-r--r--src/Structure/Instructions/Instrs/Memory/I64Load16S.php2
-rw-r--r--src/Structure/Instructions/Instrs/Memory/I64Load16U.php2
-rw-r--r--src/Structure/Instructions/Instrs/Memory/I64Load32S.php2
-rw-r--r--src/Structure/Instructions/Instrs/Memory/I64Load32U.php2
-rw-r--r--src/Structure/Instructions/Instrs/Memory/I64Load8S.php2
-rw-r--r--src/Structure/Instructions/Instrs/Memory/I64Load8U.php2
-rw-r--r--src/Structure/Instructions/Instrs/Memory/I64Store.php2
-rw-r--r--src/Structure/Instructions/Instrs/Memory/I64Store16.php2
-rw-r--r--src/Structure/Instructions/Instrs/Memory/I64Store32.php2
-rw-r--r--src/Structure/Instructions/Instrs/Memory/I64Store8.php2
-rw-r--r--src/Structure/Instructions/Instrs/Memory/MemoryInit.php2
-rw-r--r--src/Structure/Instructions/Instrs/Numeric/F32Const.php2
-rw-r--r--src/Structure/Instructions/Instrs/Numeric/F64Const.php2
-rw-r--r--src/Structure/Instructions/Instrs/Numeric/I32Const.php2
-rw-r--r--src/Structure/Instructions/Instrs/Numeric/I64Const.php2
-rw-r--r--src/Structure/Instructions/Instrs/Parametric/Select.php2
-rw-r--r--src/Structure/Instructions/Instrs/Reference/RefFunc.php2
-rw-r--r--src/Structure/Instructions/Instrs/Reference/RefNull.php2
-rw-r--r--src/Structure/Instructions/Instrs/Table/ElemDrop.php2
-rw-r--r--src/Structure/Instructions/Instrs/Table/TableCopy.php2
-rw-r--r--src/Structure/Instructions/Instrs/Table/TableFill.php2
-rw-r--r--src/Structure/Instructions/Instrs/Table/TableGet.php2
-rw-r--r--src/Structure/Instructions/Instrs/Table/TableGrow.php2
-rw-r--r--src/Structure/Instructions/Instrs/Table/TableInit.php2
-rw-r--r--src/Structure/Instructions/Instrs/Table/TableSet.php2
-rw-r--r--src/Structure/Instructions/Instrs/Table/TableSize.php2
-rw-r--r--src/Structure/Instructions/Instrs/Variable/GlobalGet.php2
-rw-r--r--src/Structure/Instructions/Instrs/Variable/GlobalSet.php2
-rw-r--r--src/Structure/Instructions/Instrs/Variable/LocalGet.php2
-rw-r--r--src/Structure/Instructions/Instrs/Variable/LocalSet.php2
-rw-r--r--src/Structure/Instructions/Instrs/Variable/LocalTee.php2
101 files changed, 1626 insertions, 69 deletions
diff --git a/composer.json b/composer.json
index 455d17b..e7a82e4 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "nsfisis/waddiwasi",
"type": "project",
- "description": "WebAssembly interpreter written in pure PHP",
+ "description": "WebAssembly runtime written in pure PHP",
"license": "MIT",
"authors": [
{
diff --git a/index.php b/index.php
index 7b076e2..158a8bb 100644
--- a/index.php
+++ b/index.php
@@ -2,12 +2,4 @@
declare(strict_types=1);
-
-
-
-
-
-
-
-
-
+require_once __DIR__ . '/vendor/autoload.php';
diff --git a/src/BinaryFormat/Decoder.php b/src/BinaryFormat/Decoder.php
index f95c26e..be1b44d 100644
--- a/src/BinaryFormat/Decoder.php
+++ b/src/BinaryFormat/Decoder.php
@@ -132,12 +132,12 @@ final class Decoder
{
assert($this->pos === 4);
$this->ensureNBytesRemains(4);
- $b1 = ord($this->input[0]);
- $b2 = ord($this->input[1]);
- $b3 = ord($this->input[2]);
- $b4 = ord($this->input[3]);
+ $b1 = ord($this->input[4]);
+ $b2 = ord($this->input[5]);
+ $b3 = ord($this->input[6]);
+ $b4 = ord($this->input[7]);
if ([$b1, $b2, $b3, $b4] !== [0x01, 0x00, 0x00, 0x00]) {
- throw new InvalidBinaryFormatException("version");
+ throw new InvalidBinaryFormatException(sprintf("version: [%x, %x, %x, %x]", $b1, $b2, $b3, $b4));
}
$this->pos += 4;
}
@@ -150,6 +150,9 @@ final class Decoder
private function decodeSection(SectionId $sectionId, callable $decoder): mixed
{
$this->skipCustomSections();
+ if ($this->eof()) {
+ return null;
+ }
$idValue = $this->peekByte();
$id = SectionId::tryFrom($idValue);
@@ -983,7 +986,7 @@ final class Decoder
private function ensureNBytesRemains(int $n): void
{
if ($this->inputSize < $this->pos + $n) {
- throw new InvalidBinaryFormatException("ensureNBytesRemains");
+ throw new InvalidBinaryFormatException("ensureNBytesRemains: $this->inputSize < $this->pos + $n");
}
}
diff --git a/src/Execution/Allocator.php b/src/Execution/Allocator.php
new file mode 100644
index 0000000..ad62fc7
--- /dev/null
+++ b/src/Execution/Allocator.php
@@ -0,0 +1,162 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution;
+
+use Nsfisis\Waddiwasi\Structure\Modules\ExportDescs;
+use Nsfisis\Waddiwasi\Structure\Modules\Func;
+use Nsfisis\Waddiwasi\Structure\Modules\Module;
+use Nsfisis\Waddiwasi\Structure\Types\GlobalType;
+use Nsfisis\Waddiwasi\Structure\Types\MemType;
+use Nsfisis\Waddiwasi\Structure\Types\RefType;
+use Nsfisis\Waddiwasi\Structure\Types\TableType;
+
+final readonly class Allocator
+{
+ public function __construct(
+ private readonly Store $store,
+ ) {
+ }
+
+ /**
+ * @param list<ExternVal> $externVals
+ */
+ public function allocPreInitModule(
+ Module $module,
+ array $externVals,
+ ): ModuleInst {
+ $m = new ModuleInst($module->types, [], [], [], [], [], [], []);
+
+ foreach ($externVals as $externVal) {
+ if ($externVal instanceof ExternVals\Global_) {
+ $m->globalAddrs[] = $externVal->addr;
+ }
+ }
+ foreach ($module->funcs as $func) {
+ $m->funcAddrs[] = $this->allocFunc($func, $m);
+ }
+
+ return $m;
+ }
+
+ /**
+ * @param list<ExternVal> $externVals
+ * @param list<Val> $vals
+ * @param list<list<Ref>> $refsList
+ * @param list<FuncAddr> $preAllocatedFuncs
+ */
+ public function allocModule(
+ Module $module,
+ array $externVals,
+ array $vals,
+ array $refsList,
+ array $preAllocatedFuncs,
+ ): ModuleInst {
+ $m = new ModuleInst($module->types, [], [], [], [], [], [], []);
+
+ foreach ($externVals as $externVal) {
+ match ($externVal::class) {
+ ExternVals\Func::class => $m->funcAddrs[] = $externVal->addr,
+ ExternVals\Table::class => $m->tableAddrs[] = $externVal->addr,
+ ExternVals\Mem::class => $m->memAddrs[] = $externVal->addr,
+ ExternVals\Global_::class => $m->globalAddrs[] = $externVal->addr,
+ default => throw new \RuntimeException("unreachable"),
+ };
+ }
+
+ foreach ($preAllocatedFuncs as $funcAddr) {
+ $m->funcAddrs[] = $funcAddr;
+ $funcInst = $this->store->funcs[$funcAddr->value];
+ assert($funcInst instanceof FuncInsts\Wasm);
+ // @phpstan-ignore-next-line
+ $this->store->funcs[$funcAddr->value] = FuncInst::Wasm(
+ $funcInst->type,
+ $m,
+ $funcInst->code,
+ );
+ }
+ foreach ($module->tables as $table) {
+ $m->tableAddrs[] = $this->allocTable($table->type, Ref::RefNull($table->type->refType));
+ }
+ foreach ($module->mems as $mem) {
+ $m->memAddrs[] = $this->allocMem($mem->type);
+ }
+ foreach ($module->datas as $data) {
+ $m->dataAddrs[] = $this->allocData($data->init);
+ }
+
+ foreach ($module->globals as $i => $global) {
+ $m->globalAddrs[] = $this->allocGlobal($global->type, $vals[$i]);
+ }
+ foreach ($module->elems as $i => $elem) {
+ $m->elemAddrs[] = $this->allocElem($elem->type, $refsList[$i]);
+ }
+
+ foreach ($module->exports as $export) {
+ $value = match ($export->desc::class) {
+ ExportDescs\Func::class => ExternVal::Func($m->funcAddrs[$export->desc->func->value]),
+ ExportDescs\Table::class => ExternVal::Table($m->tableAddrs[$export->desc->table->value]),
+ ExportDescs\Mem::class => ExternVal::Mem($m->memAddrs[$export->desc->mem->value]),
+ ExportDescs\Global_::class => ExternVal::Global_($m->globalAddrs[$export->desc->global->value]),
+ default => throw new \RuntimeException("unreachable"),
+ };
+ $m->exports[] = new ExportInst($export->name, $value);
+ }
+
+ return $m;
+ }
+
+ private function allocFunc(Func $func, ModuleInst $moduleInst): FuncAddr
+ {
+ $funcType = $moduleInst->types[$func->type->value];
+ $funcInst = FuncInst::Wasm($funcType, $moduleInst, $func);
+ $this->store->funcs[] = $funcInst;
+ return new FuncAddr(count($this->store->funcs) - 1);
+ }
+
+ private function allocTable(TableType $tableType, Ref $ref): TableAddr
+ {
+ $minSize = $tableType->limits->min;
+ $elem = array_fill(0, $minSize, $ref);
+ $tableInst = new TableInst($tableType, $elem);
+ $this->store->tables[] = $tableInst;
+ return new TableAddr(count($this->store->tables) - 1);
+ }
+
+ private function allocMem(MemType $memType): MemAddr
+ {
+ $minSize = $memType->limits->min;
+ $data = array_fill(0, $minSize * 64 * 1024, 0);
+ $memInst = new MemInst($memType, $data);
+ $this->store->mems[] = $memInst;
+ return new MemAddr(count($this->store->mems) - 1);
+ }
+
+ private function allocGlobal(GlobalType $globalType, Val $val): GlobalAddr
+ {
+ $globalInst = new GlobalInst($globalType, $val);
+ $this->store->globals[] = $globalInst;
+ return new GlobalAddr(count($this->store->globals) - 1);
+ }
+
+ /**
+ * @param list<Ref> $elem
+ */
+ private function allocElem(RefType $refType, array $elem): ElemAddr
+ {
+ $elemInst = new ElemInst($refType, $elem);
+ $this->store->elems[] = $elemInst;
+ return new ElemAddr(count($this->store->elems) - 1);
+ }
+
+ /**
+ * @param list<Byte> $data
+ */
+ private function allocData(array $data): DataAddr
+ {
+ $dataInst = new DataInst($data);
+ $this->store->datas[] = $dataInst;
+ return new DataAddr(count($this->store->datas) - 1);
+ }
+}
diff --git a/src/Execution/DataAddr.php b/src/Execution/DataAddr.php
new file mode 100644
index 0000000..b3c4516
--- /dev/null
+++ b/src/Execution/DataAddr.php
@@ -0,0 +1,13 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution;
+
+final readonly class DataAddr
+{
+ public function __construct(
+ public int $value,
+ ) {
+ }
+}
diff --git a/src/Execution/DataInst.php b/src/Execution/DataInst.php
new file mode 100644
index 0000000..0db1da5
--- /dev/null
+++ b/src/Execution/DataInst.php
@@ -0,0 +1,16 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution;
+
+final readonly class DataInst
+{
+ /**
+ * @param list<Byte> $data
+ */
+ public function __construct(
+ public array $data,
+ ) {
+ }
+}
diff --git a/src/Execution/ElemAddr.php b/src/Execution/ElemAddr.php
new file mode 100644
index 0000000..e46b54f
--- /dev/null
+++ b/src/Execution/ElemAddr.php
@@ -0,0 +1,13 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution;
+
+final readonly class ElemAddr
+{
+ public function __construct(
+ public int $value,
+ ) {
+ }
+}
diff --git a/src/Execution/ElemInst.php b/src/Execution/ElemInst.php
new file mode 100644
index 0000000..24e655c
--- /dev/null
+++ b/src/Execution/ElemInst.php
@@ -0,0 +1,19 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution;
+
+use Nsfisis\Waddiwasi\Structure\Types\RefType;
+
+final readonly class ElemInst
+{
+ /**
+ * @param list<Ref> $elem
+ */
+ public function __construct(
+ public RefType $type,
+ public array $elem,
+ ) {
+ }
+}
diff --git a/src/Execution/ExportInst.php b/src/Execution/ExportInst.php
new file mode 100644
index 0000000..e4521b4
--- /dev/null
+++ b/src/Execution/ExportInst.php
@@ -0,0 +1,17 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution;
+
+final readonly class ExportInst
+{
+ /**
+ * @param Name $name
+ */
+ public function __construct(
+ public string $name,
+ public ExternVal $value,
+ ) {
+ }
+}
diff --git a/src/Execution/ExternAddr.php b/src/Execution/ExternAddr.php
new file mode 100644
index 0000000..954127c
--- /dev/null
+++ b/src/Execution/ExternAddr.php
@@ -0,0 +1,13 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution;
+
+final readonly class ExternAddr
+{
+ public function __construct(
+ public int $value,
+ ) {
+ }
+}
diff --git a/src/Execution/ExternVal.php b/src/Execution/ExternVal.php
new file mode 100644
index 0000000..f095225
--- /dev/null
+++ b/src/Execution/ExternVal.php
@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution;
+
+abstract readonly class ExternVal
+{
+ final public static function Func(FuncAddr $addr): ExternVals\Func
+ {
+ return new ExternVals\Func($addr);
+ }
+
+ final public static function Table(TableAddr $addr): ExternVals\Table
+ {
+ return new ExternVals\Table($addr);
+ }
+
+ final public static function Mem(MemAddr $addr): ExternVals\Mem
+ {
+ return new ExternVals\Mem($addr);
+ }
+
+ final public static function Global_(GlobalAddr $addr): ExternVals\Global_
+ {
+ return new ExternVals\Global_($addr);
+ }
+}
diff --git a/src/Execution/ExternVals/Func.php b/src/Execution/ExternVals/Func.php
new file mode 100644
index 0000000..314d44d
--- /dev/null
+++ b/src/Execution/ExternVals/Func.php
@@ -0,0 +1,16 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution\ExternVals;
+
+use Nsfisis\Waddiwasi\Execution\ExternVal;
+use Nsfisis\Waddiwasi\Execution\FuncAddr;
+
+final readonly class Func extends ExternVal
+{
+ protected function __construct(
+ public FuncAddr $addr,
+ ) {
+ }
+}
diff --git a/src/Execution/ExternVals/Global_.php b/src/Execution/ExternVals/Global_.php
new file mode 100644
index 0000000..ae38c78
--- /dev/null
+++ b/src/Execution/ExternVals/Global_.php
@@ -0,0 +1,16 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution\ExternVals;
+
+use Nsfisis\Waddiwasi\Execution\ExternVal;
+use Nsfisis\Waddiwasi\Execution\GlobalAddr;
+
+final readonly class Global_ extends ExternVal
+{
+ protected function __construct(
+ public GlobalAddr $addr,
+ ) {
+ }
+}
diff --git a/src/Execution/ExternVals/Mem.php b/src/Execution/ExternVals/Mem.php
new file mode 100644
index 0000000..7bded5a
--- /dev/null
+++ b/src/Execution/ExternVals/Mem.php
@@ -0,0 +1,16 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution\ExternVals;
+
+use Nsfisis\Waddiwasi\Execution\ExternVal;
+use Nsfisis\Waddiwasi\Execution\MemAddr;
+
+final readonly class Mem extends ExternVal
+{
+ protected function __construct(
+ public MemAddr $addr,
+ ) {
+ }
+}
diff --git a/src/Execution/ExternVals/Table.php b/src/Execution/ExternVals/Table.php
new file mode 100644
index 0000000..cd36bb2
--- /dev/null
+++ b/src/Execution/ExternVals/Table.php
@@ -0,0 +1,16 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution\ExternVals;
+
+use Nsfisis\Waddiwasi\Execution\ExternVal;
+use Nsfisis\Waddiwasi\Execution\TableAddr;
+
+final readonly class Table extends ExternVal
+{
+ protected function __construct(
+ public TableAddr $addr,
+ ) {
+ }
+}
diff --git a/src/Execution/FuncAddr.php b/src/Execution/FuncAddr.php
new file mode 100644
index 0000000..101c7c9
--- /dev/null
+++ b/src/Execution/FuncAddr.php
@@ -0,0 +1,13 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution;
+
+final readonly class FuncAddr
+{
+ public function __construct(
+ public int $value,
+ ) {
+ }
+}
diff --git a/src/Execution/FuncInst.php b/src/Execution/FuncInst.php
new file mode 100644
index 0000000..c69eb80
--- /dev/null
+++ b/src/Execution/FuncInst.php
@@ -0,0 +1,21 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution;
+
+use Nsfisis\Waddiwasi\Structure\Modules\Func;
+use Nsfisis\Waddiwasi\Structure\Types\FuncType;
+
+abstract readonly class FuncInst
+{
+ final public static function Wasm(FuncType $type, ModuleInst $module, Func $code): FuncInsts\Wasm
+ {
+ return new FuncInsts\Wasm($type, $module, $code);
+ }
+
+ final public static function Host(FuncType $type, callable $code): FuncInsts\Host
+ {
+ return new FuncInsts\Host($type, $code);
+ }
+}
diff --git a/src/Execution/FuncInsts/Host.php b/src/Execution/FuncInsts/Host.php
new file mode 100644
index 0000000..e3cba4a
--- /dev/null
+++ b/src/Execution/FuncInsts/Host.php
@@ -0,0 +1,20 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution\FuncInsts;
+
+use Nsfisis\Waddiwasi\Execution\FuncInst;
+use Nsfisis\Waddiwasi\Structure\Types\FuncType;
+
+final readonly class Host extends FuncInst
+{
+ /**
+ * @param callable $code
+ */
+ public function __construct(
+ public FuncType $type,
+ public mixed $code,
+ ) {
+ }
+}
diff --git a/src/Execution/FuncInsts/Wasm.php b/src/Execution/FuncInsts/Wasm.php
new file mode 100644
index 0000000..88eea61
--- /dev/null
+++ b/src/Execution/FuncInsts/Wasm.php
@@ -0,0 +1,20 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution\FuncInsts;
+
+use Nsfisis\Waddiwasi\Execution\FuncInst;
+use Nsfisis\Waddiwasi\Execution\ModuleInst;
+use Nsfisis\Waddiwasi\Structure\Modules\Func;
+use Nsfisis\Waddiwasi\Structure\Types\FuncType;
+
+final readonly class Wasm extends FuncInst
+{
+ public function __construct(
+ public FuncType $type,
+ public ModuleInst $module,
+ public Func $code,
+ ) {
+ }
+}
diff --git a/src/Execution/GlobalAddr.php b/src/Execution/GlobalAddr.php
new file mode 100644
index 0000000..f9a08ff
--- /dev/null
+++ b/src/Execution/GlobalAddr.php
@@ -0,0 +1,13 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution;
+
+final readonly class GlobalAddr
+{
+ public function __construct(
+ public int $value,
+ ) {
+ }
+}
diff --git a/src/Execution/GlobalInst.php b/src/Execution/GlobalInst.php
new file mode 100644
index 0000000..47bd9a0
--- /dev/null
+++ b/src/Execution/GlobalInst.php
@@ -0,0 +1,16 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution;
+
+use Nsfisis\Waddiwasi\Structure\Types\GlobalType;
+
+final readonly class GlobalInst
+{
+ public function __construct(
+ public GlobalType $type,
+ public Val $value,
+ ) {
+ }
+}
diff --git a/src/Execution/MemAddr.php b/src/Execution/MemAddr.php
new file mode 100644
index 0000000..5c141cc
--- /dev/null
+++ b/src/Execution/MemAddr.php
@@ -0,0 +1,13 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution;
+
+final readonly class MemAddr
+{
+ public function __construct(
+ public int $value,
+ ) {
+ }
+}
diff --git a/src/Execution/MemInst.php b/src/Execution/MemInst.php
new file mode 100644
index 0000000..3999052
--- /dev/null
+++ b/src/Execution/MemInst.php
@@ -0,0 +1,19 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution;
+
+use Nsfisis\Waddiwasi\Structure\Types\MemType;
+
+final readonly class MemInst
+{
+ /**
+ * @param list<Byte> $data
+ */
+ public function __construct(
+ public MemType $type,
+ public array $data,
+ ) {
+ }
+}
diff --git a/src/Execution/ModuleInst.php b/src/Execution/ModuleInst.php
new file mode 100644
index 0000000..2cd7f08
--- /dev/null
+++ b/src/Execution/ModuleInst.php
@@ -0,0 +1,32 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution;
+
+use Nsfisis\Waddiwasi\Structure\Types\FuncType;
+
+final class ModuleInst
+{
+ /**
+ * @param list<FuncType> $types
+ * @param list<FuncAddr> $funcAddrs
+ * @param list<TableAddr> $tableAddrs
+ * @param list<MemAddr> $memAddrs
+ * @param list<GlobalAddr> $globalAddrs
+ * @param list<ElemAddr> $elemAddrs
+ * @param list<DataAddr> $dataAddrs
+ * @param list<ExportInst> $exports
+ */
+ public function __construct(
+ public array $types,
+ public array $funcAddrs,
+ public array $tableAddrs,
+ public array $memAddrs,
+ public array $globalAddrs,
+ public array $elemAddrs,
+ public array $dataAddrs,
+ public array $exports,
+ ) {
+ }
+}
diff --git a/src/Execution/Num.php b/src/Execution/Num.php
new file mode 100644
index 0000000..03fec4f
--- /dev/null
+++ b/src/Execution/Num.php
@@ -0,0 +1,40 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution;
+
+abstract readonly class Num
+{
+ /**
+ * @param S32 $value
+ */
+ final public static function I32(int $value): Nums\I32
+ {
+ return new Nums\I32($value);
+ }
+
+ /**
+ * @param S64 $value
+ */
+ final public static function I64(int $value): Nums\I64
+ {
+ return new Nums\I64($value);
+ }
+
+ /**
+ * @param F32 $value
+ */
+ final public static function F32(float $value): Nums\F32_
+ {
+ return new Nums\F32_($value);
+ }
+
+ /**
+ * @param F64 $value
+ */
+ final public static function F64(float $value): Nums\F64_
+ {
+ return new Nums\F64_($value);
+ }
+}
diff --git a/src/Execution/Nums/F32_.php b/src/Execution/Nums/F32_.php
new file mode 100644
index 0000000..5c7b749
--- /dev/null
+++ b/src/Execution/Nums/F32_.php
@@ -0,0 +1,18 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution\Nums;
+
+use Nsfisis\Waddiwasi\Execution\Num;
+
+final readonly class F32_ extends Num
+{
+ /**
+ * @param F32 $value
+ */
+ public function __construct(
+ public float $value,
+ ) {
+ }
+}
diff --git a/src/Execution/Nums/F64_.php b/src/Execution/Nums/F64_.php
new file mode 100644
index 0000000..c24709e
--- /dev/null
+++ b/src/Execution/Nums/F64_.php
@@ -0,0 +1,18 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution\Nums;
+
+use Nsfisis\Waddiwasi\Execution\Num;
+
+final readonly class F64_ extends Num
+{
+ /**
+ * @param F64 $value
+ */
+ public function __construct(
+ public float $value,
+ ) {
+ }
+}
diff --git a/src/Execution/Nums/I32.php b/src/Execution/Nums/I32.php
new file mode 100644
index 0000000..fbc6fab
--- /dev/null
+++ b/src/Execution/Nums/I32.php
@@ -0,0 +1,18 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution\Nums;
+
+use Nsfisis\Waddiwasi\Execution\Num;
+
+final readonly class I32 extends Num
+{
+ /**
+ * @param S32 $value
+ */
+ public function __construct(
+ public int $value,
+ ) {
+ }
+}
diff --git a/src/Execution/Nums/I64.php b/src/Execution/Nums/I64.php
new file mode 100644
index 0000000..889b863
--- /dev/null
+++ b/src/Execution/Nums/I64.php
@@ -0,0 +1,18 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution\Nums;
+
+use Nsfisis\Waddiwasi\Execution\Num;
+
+final readonly class I64 extends Num
+{
+ /**
+ * @param S64 $value
+ */
+ public function __construct(
+ public int $value,
+ ) {
+ }
+}
diff --git a/src/Execution/Ref.php b/src/Execution/Ref.php
new file mode 100644
index 0000000..4f0c3c1
--- /dev/null
+++ b/src/Execution/Ref.php
@@ -0,0 +1,25 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution;
+
+use Nsfisis\Waddiwasi\Structure\Types\RefType;
+
+abstract readonly class Ref
+{
+ final public static function RefNull(RefType $type): Refs\RefNull
+ {
+ return new Refs\RefNull($type);
+ }
+
+ final public static function RefFunc(FuncAddr $addr): Refs\RefFunc
+ {
+ return new Refs\RefFunc($addr);
+ }
+
+ final public static function RefExtern(ExternAddr $addr): Refs\RefExtern
+ {
+ return new Refs\RefExtern($addr);
+ }
+}
diff --git a/src/Execution/Refs/RefExtern.php b/src/Execution/Refs/RefExtern.php
new file mode 100644
index 0000000..4beccb4
--- /dev/null
+++ b/src/Execution/Refs/RefExtern.php
@@ -0,0 +1,16 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution\Refs;
+
+use Nsfisis\Waddiwasi\Execution\ExternAddr;
+use Nsfisis\Waddiwasi\Execution\Ref;
+
+final readonly class RefExtern extends Ref
+{
+ public function __construct(
+ public ExternAddr $addr,
+ ) {
+ }
+}
diff --git a/src/Execution/Refs/RefFunc.php b/src/Execution/Refs/RefFunc.php
new file mode 100644
index 0000000..449b780
--- /dev/null
+++ b/src/Execution/Refs/RefFunc.php
@@ -0,0 +1,16 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution\Refs;
+
+use Nsfisis\Waddiwasi\Execution\FuncAddr;
+use Nsfisis\Waddiwasi\Execution\Ref;
+
+final readonly class RefFunc extends Ref
+{
+ public function __construct(
+ public FuncAddr $addr,
+ ) {
+ }
+}
diff --git a/src/Execution/Refs/RefNull.php b/src/Execution/Refs/RefNull.php
new file mode 100644
index 0000000..b4323d7
--- /dev/null
+++ b/src/Execution/Refs/RefNull.php
@@ -0,0 +1,16 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution\Refs;
+
+use Nsfisis\Waddiwasi\Execution\Ref;
+use Nsfisis\Waddiwasi\Structure\Types\RefType;
+
+final readonly class RefNull extends Ref
+{
+ public function __construct(
+ public RefType $type,
+ ) {
+ }
+}
diff --git a/src/Execution/Result.php b/src/Execution/Result.php
new file mode 100644
index 0000000..e07752c
--- /dev/null
+++ b/src/Execution/Result.php
@@ -0,0 +1,21 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution;
+
+abstract readonly class Result
+{
+ /**
+ * @param list<Val> $values
+ */
+ final public static function Values(array $values): Results\Values
+ {
+ return new Results\Values($values);
+ }
+
+ final public static function Trap(): Results\Trap
+ {
+ return new Results\Trap();
+ }
+}
diff --git a/src/Execution/Results/Trap.php b/src/Execution/Results/Trap.php
new file mode 100644
index 0000000..eb676b2
--- /dev/null
+++ b/src/Execution/Results/Trap.php
@@ -0,0 +1,11 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution\Results;
+
+use Nsfisis\Waddiwasi\Execution\Result;
+
+final readonly class Trap extends Result
+{
+}
diff --git a/src/Execution/Results/Values.php b/src/Execution/Results/Values.php
new file mode 100644
index 0000000..c3a9e36
--- /dev/null
+++ b/src/Execution/Results/Values.php
@@ -0,0 +1,19 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution\Results;
+
+use Nsfisis\Waddiwasi\Execution\Result;
+use Nsfisis\Waddiwasi\Execution\Val;
+
+final readonly class Values extends Result
+{
+ /**
+ * @param list<Val> $values
+ */
+ protected function __construct(
+ public array $values,
+ ) {
+ }
+}
diff --git a/src/Execution/Runtime.php b/src/Execution/Runtime.php
new file mode 100644
index 0000000..030c46e
--- /dev/null
+++ b/src/Execution/Runtime.php
@@ -0,0 +1,561 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution;
+
+use Nsfisis\Waddiwasi\Structure\Instructions\Instr;
+use Nsfisis\Waddiwasi\Structure\Instructions\Instrs;
+use Nsfisis\Waddiwasi\Structure\Modules\DataModes;
+use Nsfisis\Waddiwasi\Structure\Modules\ElemModes;
+use Nsfisis\Waddiwasi\Structure\Modules\Module;
+use Nsfisis\Waddiwasi\Structure\Types\DataIdx;
+use Nsfisis\Waddiwasi\Structure\Types\ElemIdx;
+
+// @todo split this class into multiple classes
+final readonly class Runtime
+{
+ private function __construct(
+ private readonly Store $store,
+ private readonly Stack $stack,
+ private readonly ModuleInst $module,
+ ) {
+ }
+
+ /**
+ * @param list<ExternVal> $externVals
+ */
+ public static function instantiate(
+ Store $store,
+ Module $module,
+ array $externVals,
+ ): self {
+ $allocator = new Allocator($store);
+
+ $moduleInstInit = $allocator->allocPreInitModule($module, $externVals);
+
+ $stack = new Stack([]);
+ $frameInit = StackEntry::Frame(0, [], $moduleInstInit);
+ $stack->push($frameInit);
+
+ $runtimeInit = new self($store, $stack, $moduleInstInit);
+
+ $vals = [];
+ foreach ($module->globals as $global) {
+ $instrs = $global->init->instrs;
+ array_pop($instrs); // drop "end"
+ $vals[] = $runtimeInit->evalInstrs($instrs);
+ assert($stack->top() === $frameInit);
+ }
+
+ $refsList = [];
+ foreach ($module->elems as $elem) {
+ $refs = [];
+ foreach ($elem->init as $expr) {
+ $instrs = $expr->instrs;
+ array_pop($instrs); // drop "end"
+ $result = $runtimeInit->evalInstrs($instrs);
+ assert($result instanceof Vals\Ref);
+ $refs[] = $result->inner;
+ }
+ $refsList[] = $refs;
+ }
+
+ assert($stack->top() === $frameInit);
+ $stack->pop();
+
+ $moduleInst = $allocator->allocModule(
+ $module,
+ $externVals,
+ $vals,
+ $refsList,
+ $moduleInstInit->funcAddrs,
+ );
+
+ $runtime = new self($store, $stack, $moduleInst);
+
+ $frame = StackEntry::Frame(0, [], $moduleInst);
+ $stack->push($frame);
+
+ foreach ($module->elems as $i => $elem) {
+ if ($elem->mode instanceof ElemModes\Active) {
+ $n = count($elem->init);
+ $instrs = $elem->mode->offset->instrs;
+ array_pop($instrs); // drop "end"
+ $instrs[] = Instr::I32Const(0);
+ $instrs[] = Instr::I32Const($n);
+ $instrs[] = Instr::TableInit($elem->mode->table, new ElemIdx($i));
+ $instrs[] = Instr::ElemDrop(new ElemIdx($i));
+ $runtime->execInstrs($instrs);
+ } elseif ($elem->mode instanceof ElemModes\Declarative) {
+ $runtime->execInstrs([Instr::ElemDrop(new ElemIdx($i))]);
+ }
+ }
+ foreach ($module->datas as $i => $data) {
+ if ($data->mode instanceof DataModes\Active) {
+ assert($data->mode->memory->value === 0);
+ $n = count($data->init);
+ $instrs = $data->mode->offset->instrs;
+ array_pop($instrs); // drop "end"
+ $instrs[] = Instr::I32Const(0);
+ $instrs[] = Instr::I32Const($n);
+ $instrs[] = Instr::MemoryInit(new DataIdx($i));
+ $instrs[] = Instr::DataDrop(new DataIdx($i));
+ $runtime->execInstrs($instrs);
+ }
+ }
+
+ if ($module->start !== null) {
+ $runtime->execInstrs([Instr::Call($module->start->func)]);
+ }
+
+ assert($stack->top() === $frame);
+ $stack->pop();
+
+ return new self($store, $stack, $moduleInst);
+ }
+
+ public function invoke(): void
+ {
+ }
+
+ /**
+ * @param list<Instr> $instrs
+ */
+ private function execInstrs(array $instrs): void
+ {
+ foreach ($instrs as $i) {
+ $this->interpret($i);
+ }
+ }
+
+ /**
+ * @param list<Instr> $instrs
+ */
+ private function evalInstrs(array $instrs): Val
+ {
+ $this->execInstrs($instrs);
+ $result = $this->stack->pop();
+ assert($result instanceof StackEntries\Value);
+ return $result->inner;
+ }
+
+ private function interpret(Instr $instr): void
+ {
+ if ($instr instanceof Instrs\Numeric\F32Abs) {
+ $v = $this->stack->pop();
+ assert($v instanceof StackEntries\Value);
+ assert($v->inner instanceof Vals\Num);
+ assert($v->inner->inner instanceof Nums\F32_);
+ $this->stack->push(StackEntry::Value(Val::Num(Num::F32($v->inner->inner))));
+ } elseif ($instr instanceof Instrs\Numeric\F32Add) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F32Ceil) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F32Const) {
+ $this->stack->push(StackEntry::Value(Val::Num(Num::F32($instr->value))));
+ } elseif ($instr instanceof Instrs\Numeric\F32ConvertI32S) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F32ConvertI32U) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F32ConvertI64S) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F32ConvertI64U) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F32CopySign) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F32DemoteF64) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F32Div) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F32Eq) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F32Floor) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F32Ge) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F32Gt) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F32Le) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F32Lt) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F32Max) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F32Min) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F32Mul) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F32Ne) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F32Nearest) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F32Neg) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F32ReinterpretI32) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F32ReinterpretI64) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F32Sqrt) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F32Sub) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F32Trunc) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64Abs) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64Add) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64Ceil) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64Const) {
+ $this->stack->push(StackEntry::Value(Val::Num(Num::F64($instr->value))));
+ } elseif ($instr instanceof Instrs\Numeric\F64ConvertI32S) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64ConvertI32U) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64ConvertI64S) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64ConvertI64U) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64CopySign) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64Div) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64Eq) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64Floor) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64Ge) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64Gt) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64Le) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64Lt) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64Max) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64Min) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64Mul) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64Ne) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64Nearest) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64Neg) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64PromoteF32) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64ReinterpretI32) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64ReinterpretI64) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64Sqrt) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64Sub) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\F64Trunc) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32Add) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32And) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32Clz) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32Const) {
+ $this->stack->push(StackEntry::Value(Val::Num(Num::I32($instr->value))));
+ } elseif ($instr instanceof Instrs\Numeric\I32Ctz) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32DivS) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32DivU) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32Eq) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32Eqz) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32Extend16S) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32Extend8S) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32GeS) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32GeU) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32GtS) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32GtU) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32LeS) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32LeU) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32LtS) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32LtU) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32Mul) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32Ne) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32Or) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32Popcnt) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32ReinterpretF32) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32ReinterpretF64) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32RemS) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32RemU) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32RotL) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32RotR) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32Shl) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32ShrS) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32ShrU) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32Sub) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32TruncF32S) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32TruncF32U) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32TruncF64S) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32TruncF64U) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32TruncSatF32S) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32TruncSatF32U) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32TruncSatF64S) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32TruncSatF64U) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32WrapI64) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I32Xor) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64Add) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64And) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64Clz) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64Const) {
+ $this->stack->push(StackEntry::Value(Val::Num(Num::I64($instr->value))));
+ } elseif ($instr instanceof Instrs\Numeric\I64Ctz) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64DivS) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64DivU) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64Eq) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64Eqz) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64Extend16S) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64Extend32S) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64Extend8S) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64ExtendI32S) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64ExtendI32U) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64GeS) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64GeU) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64GtS) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64GtU) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64LeS) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64LeU) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64LtS) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64LtU) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64Mul) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64Ne) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64Or) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64Popcnt) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64ReinterpretF32) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64ReinterpretF64) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64RemS) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64RemU) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64RotL) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64RotR) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64Shl) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64ShrS) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64ShrU) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64Sub) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64TruncF32S) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64TruncF32U) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64TruncF64S) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64TruncF64U) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64TruncSatF32S) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64TruncSatF32U) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64TruncSatF64S) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64TruncSatF64U) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Numeric\I64Xor) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Reference\RefFunc) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Reference\RefIsNull) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Reference\RefNull) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Parametric\Drop) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Parametric\Select) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Variable\GlobalGet) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Variable\GlobalSet) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Variable\LocalGet) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Variable\LocalSet) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Variable\LocalTee) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Table\ElemDrop) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Table\TableCopy) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Table\TableFill) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Table\TableGet) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Table\TableGrow) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Table\TableInit) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Table\TableSet) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Table\TableSize) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\DataDrop) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\F32Load) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\F32Store) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\F64Load) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\F64Store) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\I32Load) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\I32Load16S) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\I32Load16U) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\I32Load8S) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\I32Load8U) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\I32Store) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\I32Store16) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\I32Store8) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\I64Load) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\I64Load16S) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\I64Load16U) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\I64Load32S) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\I64Load32U) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\I64Load8S) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\I64Load8U) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\I64Store) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\I64Store16) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\I64Store32) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\I64Store8) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\MemoryCopy) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\MemoryFill) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\MemoryGrow) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\MemoryInit) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Memory\MemorySize) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Control\Block) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Control\Br) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Control\BrIf) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Control\BrTable) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Control\Call) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Control\CallIndirect) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Control\Else_) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Control\End) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Control\If_) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Control\Loop) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Control\Nop) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Control\Return_) {
+ assert(false, "not implemented " . $instr::class);
+ } elseif ($instr instanceof Instrs\Control\Unreachable) {
+ assert(false, "not implemented " . $instr::class);
+ } else {
+ assert(false);
+ }
+ }
+}
diff --git a/src/Execution/Stack.php b/src/Execution/Stack.php
new file mode 100644
index 0000000..1fa2dae
--- /dev/null
+++ b/src/Execution/Stack.php
@@ -0,0 +1,42 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution;
+
+final class Stack
+{
+ /**
+ * @param list<StackEntry> $entries
+ */
+ public function __construct(
+ private array $entries,
+ ) {
+ }
+
+ public function push(StackEntry $entry): void
+ {
+ $this->entries[] = $entry;
+ }
+
+ public function pop(): ?StackEntry
+ {
+ return array_pop($this->entries);
+ }
+
+ public function top(): ?StackEntry
+ {
+ $n = array_key_last($this->entries);
+ return $n === null ? null : $this->entries[$n];
+ }
+
+ public function count(): int
+ {
+ return count($this->entries);
+ }
+
+ public function isEmpty(): bool
+ {
+ return $this->count() === 0;
+ }
+}
diff --git a/src/Execution/StackEntries/Frame.php b/src/Execution/StackEntries/Frame.php
new file mode 100644
index 0000000..f8bd68e
--- /dev/null
+++ b/src/Execution/StackEntries/Frame.php
@@ -0,0 +1,23 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution\StackEntries;
+
+use Nsfisis\Waddiwasi\Execution\ModuleInst;
+use Nsfisis\Waddiwasi\Execution\StackEntry;
+use Nsfisis\Waddiwasi\Execution\Val;
+
+final readonly class Frame extends StackEntry
+{
+ /**
+ * @param int<0, max> $arity
+ * @param list<Val> $locals
+ */
+ public function __construct(
+ public int $arity,
+ public array $locals,
+ public ModuleInst $module,
+ ) {
+ }
+}
diff --git a/src/Execution/StackEntries/Label.php b/src/Execution/StackEntries/Label.php
new file mode 100644
index 0000000..b83fb0f
--- /dev/null
+++ b/src/Execution/StackEntries/Label.php
@@ -0,0 +1,21 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution\StackEntries;
+
+use Nsfisis\Waddiwasi\Execution\StackEntry;
+use Nsfisis\Waddiwasi\Structure\Instructions\Instr;
+
+final readonly class Label extends StackEntry
+{
+ /**
+ * @param int<0, max> $arity
+ * @param list<Instr> $target
+ */
+ public function __construct(
+ public int $arity,
+ public array $target,
+ ) {
+ }
+}
diff --git a/src/Execution/StackEntries/Value.php b/src/Execution/StackEntries/Value.php
new file mode 100644
index 0000000..1cd1146
--- /dev/null
+++ b/src/Execution/StackEntries/Value.php
@@ -0,0 +1,16 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution\StackEntries;
+
+use Nsfisis\Waddiwasi\Execution\StackEntry;
+use Nsfisis\Waddiwasi\Execution\Val;
+
+final readonly class Value extends StackEntry
+{
+ public function __construct(
+ public Val $inner,
+ ) {
+ }
+}
diff --git a/src/Execution/StackEntry.php b/src/Execution/StackEntry.php
new file mode 100644
index 0000000..8a9d7dd
--- /dev/null
+++ b/src/Execution/StackEntry.php
@@ -0,0 +1,38 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution;
+
+use Nsfisis\Waddiwasi\Structure\Instructions\Instr;
+
+abstract readonly class StackEntry
+{
+ final public static function Value(Val $inner): StackEntries\Value
+ {
+ return new StackEntries\Value($inner);
+ }
+
+ /**
+ * @param int<0, max> $arity
+ * @param list<Instr> $target
+ */
+ final public static function Label(
+ int $arity,
+ array $target,
+ ): StackEntries\Label {
+ return new StackEntries\Label($arity, $target);
+ }
+
+ /**
+ * @param int<0, max> $arity
+ * @param list<Val> $locals
+ */
+ final public static function Frame(
+ int $arity,
+ array $locals,
+ ModuleInst $module,
+ ): StackEntries\Frame {
+ return new StackEntries\Frame($arity, $locals, $module);
+ }
+}
diff --git a/src/Execution/Store.php b/src/Execution/Store.php
new file mode 100644
index 0000000..b7b0dfc
--- /dev/null
+++ b/src/Execution/Store.php
@@ -0,0 +1,31 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution;
+
+final class Store
+{
+ /**
+ * @param list<FuncInst> $funcs
+ * @param list<TableInst> $tables
+ * @param list<MemInst> $mems
+ * @param list<GlobalInst> $globals
+ * @param list<ElemInst> $elems
+ * @param list<DataInst> $datas
+ */
+ public function __construct(
+ public array $funcs,
+ public array $tables,
+ public array $mems,
+ public array $globals,
+ public array $elems,
+ public array $datas,
+ ) {
+ }
+
+ public static function empty(): self
+ {
+ return new self([], [], [], [], [], []);
+ }
+}
diff --git a/src/Execution/TableAddr.php b/src/Execution/TableAddr.php
new file mode 100644
index 0000000..e41eef1
--- /dev/null
+++ b/src/Execution/TableAddr.php
@@ -0,0 +1,13 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution;
+
+final readonly class TableAddr
+{
+ public function __construct(
+ public int $value,
+ ) {
+ }
+}
diff --git a/src/Execution/TableInst.php b/src/Execution/TableInst.php
new file mode 100644
index 0000000..5a6766d
--- /dev/null
+++ b/src/Execution/TableInst.php
@@ -0,0 +1,19 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution;
+
+use Nsfisis\Waddiwasi\Structure\Types\TableType;
+
+final readonly class TableInst
+{
+ /**
+ * @param list<Ref> $elem
+ */
+ public function __construct(
+ public TableType $type,
+ public array $elem,
+ ) {
+ }
+}
diff --git a/src/Execution/Val.php b/src/Execution/Val.php
new file mode 100644
index 0000000..287f441
--- /dev/null
+++ b/src/Execution/Val.php
@@ -0,0 +1,18 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution;
+
+abstract readonly class Val
+{
+ final public static function Num(Num $inner): Vals\Num
+ {
+ return new Vals\Num($inner);
+ }
+
+ final public static function Ref(Ref $inner): Vals\Ref
+ {
+ return new Vals\Ref($inner);
+ }
+}
diff --git a/src/Execution/Vals/Num.php b/src/Execution/Vals/Num.php
new file mode 100644
index 0000000..15b4433
--- /dev/null
+++ b/src/Execution/Vals/Num.php
@@ -0,0 +1,16 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution\Vals;
+
+use Nsfisis\Waddiwasi\Execution\Num as OrigNum;
+use Nsfisis\Waddiwasi\Execution\Val;
+
+final readonly class Num extends Val
+{
+ public function __construct(
+ public OrigNum $inner,
+ ) {
+ }
+}
diff --git a/src/Execution/Vals/Ref.php b/src/Execution/Vals/Ref.php
new file mode 100644
index 0000000..8ea8a94
--- /dev/null
+++ b/src/Execution/Vals/Ref.php
@@ -0,0 +1,16 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Nsfisis\Waddiwasi\Execution\Vals;
+
+use Nsfisis\Waddiwasi\Execution\Ref as OrigRef;
+use Nsfisis\Waddiwasi\Execution\Val;
+
+final readonly class Ref extends Val
+{
+ public function __construct(
+ public OrigRef $inner,
+ ) {
+ }
+}
diff --git a/src/Structure/Instructions/Instrs/Control/Block.php b/src/Structure/Instructions/Instrs/Control/Block.php
index 2be7a1f..a4842c0 100644
--- a/src/Structure/Instructions/Instrs/Control/Block.php
+++ b/src/Structure/Instructions/Instrs/Control/Block.php
@@ -11,7 +11,7 @@ final readonly class Block extends Instr
/**
* @param list<Instr> $body
*/
- public function __construct(
+ protected function __construct(
public BlockType $type,
public array $body,
) {
diff --git a/src/Structure/Instructions/Instrs/Control/Br.php b/src/Structure/Instructions/Instrs/Control/Br.php
index 836f3f1..b8564a0 100644
--- a/src/Structure/Instructions/Instrs/Control/Br.php
+++ b/src/Structure/Instructions/Instrs/Control/Br.php
@@ -9,7 +9,7 @@ use Nsfisis\Waddiwasi\Structure\Types\LabelIdx;
final readonly class Br extends Instr
{
- public function __construct(
+ protected function __construct(
public LabelIdx $label,
) {
}
diff --git a/src/Structure/Instructions/Instrs/Control/BrIf.php b/src/Structure/Instructions/Instrs/Control/BrIf.php
index a15a716..980c76e 100644
--- a/src/Structure/Instructions/Instrs/Control/BrIf.php
+++ b/src/Structure/Instructions/Instrs/Control/BrIf.php
@@ -9,7 +9,7 @@ use Nsfisis\Waddiwasi\Structure\Types\LabelIdx;
final readonly class BrIf extends Instr
{
- public function __construct(
+ protected function __construct(
public LabelIdx $label,
) {
}
diff --git a/src/Structure/Instructions/Instrs/Control/BrTable.php b/src/Structure/Instructions/Instrs/Control/BrTable.php
index 57a08f3..37f61ed 100644
--- a/src/Structure/Instructions/Instrs/Control/BrTable.php
+++ b/src/Structure/Instructions/Instrs/Control/BrTable.php
@@ -12,7 +12,7 @@ final readonly class BrTable extends Instr
/**
* @param list<LabelIdx> $labelTable
*/
- public function __construct(
+ protected function __construct(
public array $labelTable,
public LabelIdx $defaultLabel,
) {
diff --git a/src/Structure/Instructions/Instrs/Control/Call.php b/src/Structure/Instructions/Instrs/Control/Call.php
index c8702d3..472752b 100644
--- a/src/Structure/Instructions/Instrs/Control/Call.php
+++ b/src/Structure/Instructions/Instrs/Control/Call.php
@@ -9,7 +9,7 @@ use Nsfisis\Waddiwasi\Structure\Types\FuncIdx;
final readonly class Call extends Instr
{
- public function __construct(
+ protected function __construct(
public FuncIdx $func,
) {
}
diff --git a/src/Structure/Instructions/Instrs/Control/CallIndirect.php b/src/Structure/Instructions/Instrs/Control/CallIndirect.php
index 2cf28a5..6f43e06 100644
--- a/src/Structure/Instructions/Instrs/Control/CallIndirect.php
+++ b/src/Structure/Instructions/Instrs/Control/CallIndirect.php
@@ -10,7 +10,7 @@ use Nsfisis\Waddiwasi\Structure\Types\TypeIdx;
final readonly class CallIndirect extends Instr
{
- public function __construct(
+ protected function __construct(
public TableIdx $funcTable,
public TypeIdx $type,
) {
diff --git a/src/Structure/Instructions/Instrs/Control/If_.php b/src/Structure/Instructions/Instrs/Control/If_.php
index 0536be0..1eeee47 100644
--- a/src/Structure/Instructions/Instrs/Control/If_.php
+++ b/src/Structure/Instructions/Instrs/Control/If_.php
@@ -12,7 +12,7 @@ final readonly class If_ extends Instr
* @param list<Instr> $thenBody
* @param list<Instr> $elseBody
*/
- public function __construct(
+ protected function __construct(
public BlockType $type,
public array $thenBody,
public array $elseBody,
diff --git a/src/Structure/Instructions/Instrs/Control/Loop.php b/src/Structure/Instructions/Instrs/Control/Loop.php
index 30c85ef..839f75d 100644
--- a/src/Structure/Instructions/Instrs/Control/Loop.php
+++ b/src/Structure/Instructions/Instrs/Control/Loop.php
@@ -11,7 +11,7 @@ final readonly class Loop extends Instr
/**
* @param list<Instr> $body
*/
- public function __construct(
+ protected function __construct(
public BlockType $type,
public array $body,
) {
diff --git a/src/Structure/Instructions/Instrs/Memory/DataDrop.php b/src/Structure/Instructions/Instrs/Memory/DataDrop.php
index 4d08ef8..1764ce9 100644
--- a/src/Structure/Instructions/Instrs/Memory/DataDrop.php
+++ b/src/Structure/Instructions/Instrs/Memory/DataDrop.php
@@ -9,7 +9,7 @@ use Nsfisis\Waddiwasi\Structure\Types\DataIdx;
final readonly class DataDrop extends Instr
{
- public function __construct(
+ protected function __construct(
public DataIdx $data,
) {
}
diff --git a/src/Structure/Instructions/Instrs/Memory/F32Load.php b/src/Structure/Instructions/Instrs/Memory/F32Load.php
index d315ffc..4b06021 100644
--- a/src/Structure/Instructions/Instrs/Memory/F32Load.php
+++ b/src/Structure/Instructions/Instrs/Memory/F32Load.php
@@ -12,7 +12,7 @@ final readonly class F32Load extends Instr
* @param U32 $offset
* @param U32 $align
*/
- public function __construct(
+ protected function __construct(
public int $offset,
public int $align,
) {
diff --git a/src/Structure/Instructions/Instrs/Memory/F32Store.php b/src/Structure/Instructions/Instrs/Memory/F32Store.php
index 702698d..7c1c212 100644
--- a/src/Structure/Instructions/Instrs/Memory/F32Store.php
+++ b/src/Structure/Instructions/Instrs/Memory/F32Store.php
@@ -12,7 +12,7 @@ final readonly class F32Store extends Instr
* @param U32 $offset
* @param U32 $align
*/
- public function __construct(
+ protected function __construct(
public int $offset,
public int $align,
) {
diff --git a/src/Structure/Instructions/Instrs/Memory/F64Load.php b/src/Structure/Instructions/Instrs/Memory/F64Load.php
index 8ea4742..55778a6 100644
--- a/src/Structure/Instructions/Instrs/Memory/F64Load.php
+++ b/src/Structure/Instructions/Instrs/Memory/F64Load.php
@@ -12,7 +12,7 @@ final readonly class F64Load extends Instr
* @param U32 $offset
* @param U32 $align
*/
- public function __construct(
+ protected function __construct(
public int $offset,
public int $align,
) {
diff --git a/src/Structure/Instructions/Instrs/Memory/F64Store.php b/src/Structure/Instructions/Instrs/Memory/F64Store.php
index 3cda981..d324365 100644
--- a/src/Structure/Instructions/Instrs/Memory/F64Store.php
+++ b/src/Structure/Instructions/Instrs/Memory/F64Store.php
@@ -12,7 +12,7 @@ final readonly class F64Store extends Instr
* @param U32 $offset
* @param U32 $align
*/
- public function __construct(
+ protected function __construct(
public int $offset,
public int $align,
) {
diff --git a/src/Structure/Instructions/Instrs/Memory/I32Load.php b/src/Structure/Instructions/Instrs/Memory/I32Load.php
index 98e5e35..a5925bc 100644
--- a/src/Structure/Instructions/Instrs/Memory/I32Load.php
+++ b/src/Structure/Instructions/Instrs/Memory/I32Load.php
@@ -12,7 +12,7 @@ final readonly class I32Load extends Instr
* @param U32 $offset
* @param U32 $align
*/
- public function __construct(
+ protected function __construct(
public int $offset,
public int $align,
) {
diff --git a/src/Structure/Instructions/Instrs/Memory/I32Load16S.php b/src/Structure/Instructions/Instrs/Memory/I32Load16S.php
index f4fa975..78a15fc 100644
--- a/src/Structure/Instructions/Instrs/Memory/I32Load16S.php
+++ b/src/Structure/Instructions/Instrs/Memory/I32Load16S.php
@@ -12,7 +12,7 @@ final readonly class I32Load16S extends Instr
* @param U32 $offset
* @param U32 $align
*/
- public function __construct(
+ protected function __construct(
public int $offset,
public int $align,
) {
diff --git a/src/Structure/Instructions/Instrs/Memory/I32Load16U.php b/src/Structure/Instructions/Instrs/Memory/I32Load16U.php
index 8d6d772..475dff8 100644
--- a/src/Structure/Instructions/Instrs/Memory/I32Load16U.php
+++ b/src/Structure/Instructions/Instrs/Memory/I32Load16U.php
@@ -12,7 +12,7 @@ final readonly class I32Load16U extends Instr
* @param U32 $offset
* @param U32 $align
*/
- public function __construct(
+ protected function __construct(
public int $offset,
public int $align,
) {
diff --git a/src/Structure/Instructions/Instrs/Memory/I32Load8S.php b/src/Structure/Instructions/Instrs/Memory/I32Load8S.php
index 3d93375..ef8912a 100644
--- a/src/Structure/Instructions/Instrs/Memory/I32Load8S.php
+++ b/src/Structure/Instructions/Instrs/Memory/I32Load8S.php
@@ -12,7 +12,7 @@ final readonly class I32Load8S extends Instr
* @param U32 $offset
* @param U32 $align
*/
- public function __construct(
+ protected function __construct(
public int $offset,
public int $align,
) {
diff --git a/src/Structure/Instructions/Instrs/Memory/I32Load8U.php b/src/Structure/Instructions/Instrs/Memory/I32Load8U.php
index dcc94bc..0c05360 100644
--- a/src/Structure/Instructions/Instrs/Memory/I32Load8U.php
+++ b/src/Structure/Instructions/Instrs/Memory/I32Load8U.php
@@ -12,7 +12,7 @@ final readonly class I32Load8U extends Instr
* @param U32 $offset
* @param U32 $align
*/
- public function __construct(
+ protected function __construct(
public int $offset,
public int $align,
) {
diff --git a/src/Structure/Instructions/Instrs/Memory/I32Store.php b/src/Structure/Instructions/Instrs/Memory/I32Store.php
index c65e9c1..e104861 100644
--- a/src/Structure/Instructions/Instrs/Memory/I32Store.php
+++ b/src/Structure/Instructions/Instrs/Memory/I32Store.php
@@ -12,7 +12,7 @@ final readonly class I32Store extends Instr
* @param U32 $offset
* @param U32 $align
*/
- public function __construct(
+ protected function __construct(
public int $offset,
public int $align,
) {
diff --git a/src/Structure/Instructions/Instrs/Memory/I32Store16.php b/src/Structure/Instructions/Instrs/Memory/I32Store16.php
index 01401df..8deb592 100644
--- a/src/Structure/Instructions/Instrs/Memory/I32Store16.php
+++ b/src/Structure/Instructions/Instrs/Memory/I32Store16.php
@@ -12,7 +12,7 @@ final readonly class I32Store16 extends Instr
* @param U32 $offset
* @param U32 $align
*/
- public function __construct(
+ protected function __construct(
public int $offset,
public int $align,
) {
diff --git a/src/Structure/Instructions/Instrs/Memory/I32Store8.php b/src/Structure/Instructions/Instrs/Memory/I32Store8.php
index 07f0f90..349f78f 100644
--- a/src/Structure/Instructions/Instrs/Memory/I32Store8.php
+++ b/src/Structure/Instructions/Instrs/Memory/I32Store8.php
@@ -12,7 +12,7 @@ final readonly class I32Store8 extends Instr
* @param U32 $offset
* @param U32 $align
*/
- public function __construct(
+ protected function __construct(
public int $offset,
public int $align,
) {
diff --git a/src/Structure/Instructions/Instrs/Memory/I64Load.php b/src/Structure/Instructions/Instrs/Memory/I64Load.php
index ccb8069..89bc32a 100644
--- a/src/Structure/Instructions/Instrs/Memory/I64Load.php
+++ b/src/Structure/Instructions/Instrs/Memory/I64Load.php
@@ -12,7 +12,7 @@ final readonly class I64Load extends Instr
* @param U32 $offset
* @param U32 $align
*/
- public function __construct(
+ protected function __construct(
public int $offset,
public int $align,
) {
diff --git a/src/Structure/Instructions/Instrs/Memory/I64Load16S.php b/src/Structure/Instructions/Instrs/Memory/I64Load16S.php
index 34f9a9d..f8202a7 100644
--- a/src/Structure/Instructions/Instrs/Memory/I64Load16S.php
+++ b/src/Structure/Instructions/Instrs/Memory/I64Load16S.php
@@ -12,7 +12,7 @@ final readonly class I64Load16S extends Instr
* @param U32 $offset
* @param U32 $align
*/
- public function __construct(
+ protected function __construct(
public int $offset,
public int $align,
) {
diff --git a/src/Structure/Instructions/Instrs/Memory/I64Load16U.php b/src/Structure/Instructions/Instrs/Memory/I64Load16U.php
index 171ed96..f93b42b 100644
--- a/src/Structure/Instructions/Instrs/Memory/I64Load16U.php
+++ b/src/Structure/Instructions/Instrs/Memory/I64Load16U.php
@@ -12,7 +12,7 @@ final readonly class I64Load16U extends Instr
* @param U32 $offset
* @param U32 $align
*/
- public function __construct(
+ protected function __construct(
public int $offset,
public int $align,
) {
diff --git a/src/Structure/Instructions/Instrs/Memory/I64Load32S.php b/src/Structure/Instructions/Instrs/Memory/I64Load32S.php
index e26fbc8..6aaa5e3 100644
--- a/src/Structure/Instructions/Instrs/Memory/I64Load32S.php
+++ b/src/Structure/Instructions/Instrs/Memory/I64Load32S.php
@@ -12,7 +12,7 @@ final readonly class I64Load32S extends Instr
* @param U32 $offset
* @param U32 $align
*/
- public function __construct(
+ protected function __construct(
public int $offset,
public int $align,
) {
diff --git a/src/Structure/Instructions/Instrs/Memory/I64Load32U.php b/src/Structure/Instructions/Instrs/Memory/I64Load32U.php
index 6568d25..8561919 100644
--- a/src/Structure/Instructions/Instrs/Memory/I64Load32U.php
+++ b/src/Structure/Instructions/Instrs/Memory/I64Load32U.php
@@ -12,7 +12,7 @@ final readonly class I64Load32U extends Instr
* @param U32 $offset
* @param U32 $align
*/
- public function __construct(
+ protected function __construct(
public int $offset,
public int $align,
) {
diff --git a/src/Structure/Instructions/Instrs/Memory/I64Load8S.php b/src/Structure/Instructions/Instrs/Memory/I64Load8S.php
index 7f4a8ef..3fff762 100644
--- a/src/Structure/Instructions/Instrs/Memory/I64Load8S.php
+++ b/src/Structure/Instructions/Instrs/Memory/I64Load8S.php
@@ -12,7 +12,7 @@ final readonly class I64Load8S extends Instr
* @param U32 $offset
* @param U32 $align
*/
- public function __construct(
+ protected function __construct(
public int $offset,
public int $align,
) {
diff --git a/src/Structure/Instructions/Instrs/Memory/I64Load8U.php b/src/Structure/Instructions/Instrs/Memory/I64Load8U.php
index 1982714..1d12c24 100644
--- a/src/Structure/Instructions/Instrs/Memory/I64Load8U.php
+++ b/src/Structure/Instructions/Instrs/Memory/I64Load8U.php
@@ -12,7 +12,7 @@ final readonly class I64Load8U extends Instr
* @param U32 $offset
* @param U32 $align
*/
- public function __construct(
+ protected function __construct(
public int $offset,
public int $align,
) {
diff --git a/src/Structure/Instructions/Instrs/Memory/I64Store.php b/src/Structure/Instructions/Instrs/Memory/I64Store.php
index 75e0303..db974db 100644
--- a/src/Structure/Instructions/Instrs/Memory/I64Store.php
+++ b/src/Structure/Instructions/Instrs/Memory/I64Store.php
@@ -12,7 +12,7 @@ final readonly class I64Store extends Instr
* @param U32 $offset
* @param U32 $align
*/
- public function __construct(
+ protected function __construct(
public int $offset,
public int $align,
) {
diff --git a/src/Structure/Instructions/Instrs/Memory/I64Store16.php b/src/Structure/Instructions/Instrs/Memory/I64Store16.php
index 66ecec6..4cb48a2 100644
--- a/src/Structure/Instructions/Instrs/Memory/I64Store16.php
+++ b/src/Structure/Instructions/Instrs/Memory/I64Store16.php
@@ -12,7 +12,7 @@ final readonly class I64Store16 extends Instr
* @param U32 $offset
* @param U32 $align
*/
- public function __construct(
+ protected function __construct(
public int $offset,
public int $align,
) {
diff --git a/src/Structure/Instructions/Instrs/Memory/I64Store32.php b/src/Structure/Instructions/Instrs/Memory/I64Store32.php
index 8307efd..4d3e894 100644
--- a/src/Structure/Instructions/Instrs/Memory/I64Store32.php
+++ b/src/Structure/Instructions/Instrs/Memory/I64Store32.php
@@ -12,7 +12,7 @@ final readonly class I64Store32 extends Instr
* @param U32 $offset
* @param U32 $align
*/
- public function __construct(
+ protected function __construct(
public int $offset,
public int $align,
) {
diff --git a/src/Structure/Instructions/Instrs/Memory/I64Store8.php b/src/Structure/Instructions/Instrs/Memory/I64Store8.php
index dd52475..aaac79b 100644
--- a/src/Structure/Instructions/Instrs/Memory/I64Store8.php
+++ b/src/Structure/Instructions/Instrs/Memory/I64Store8.php
@@ -12,7 +12,7 @@ final readonly class I64Store8 extends Instr
* @param U32 $offset
* @param U32 $align
*/
- public function __construct(
+ protected function __construct(
public int $offset,
public int $align,
) {
diff --git a/src/Structure/Instructions/Instrs/Memory/MemoryInit.php b/src/Structure/Instructions/Instrs/Memory/MemoryInit.php
index 72f7ee9..cce52c2 100644
--- a/src/Structure/Instructions/Instrs/Memory/MemoryInit.php
+++ b/src/Structure/Instructions/Instrs/Memory/MemoryInit.php
@@ -9,7 +9,7 @@ use Nsfisis\Waddiwasi\Structure\Types\DataIdx;
final readonly class MemoryInit extends Instr
{
- public function __construct(
+ protected function __construct(
public DataIdx $data,
) {
}
diff --git a/src/Structure/Instructions/Instrs/Numeric/F32Const.php b/src/Structure/Instructions/Instrs/Numeric/F32Const.php
index d9ce335..0b69861 100644
--- a/src/Structure/Instructions/Instrs/Numeric/F32Const.php
+++ b/src/Structure/Instructions/Instrs/Numeric/F32Const.php
@@ -11,7 +11,7 @@ final readonly class F32Const extends Instr
/**
* @param F32 $value
*/
- public function __construct(
+ protected function __construct(
public float $value,
) {
}
diff --git a/src/Structure/Instructions/Instrs/Numeric/F64Const.php b/src/Structure/Instructions/Instrs/Numeric/F64Const.php
index dcfa9e8..540e6f4 100644
--- a/src/Structure/Instructions/Instrs/Numeric/F64Const.php
+++ b/src/Structure/Instructions/Instrs/Numeric/F64Const.php
@@ -11,7 +11,7 @@ final readonly class F64Const extends Instr
/**
* @param F64 $value
*/
- public function __construct(
+ protected function __construct(
public float $value,
) {
}
diff --git a/src/Structure/Instructions/Instrs/Numeric/I32Const.php b/src/Structure/Instructions/Instrs/Numeric/I32Const.php
index 7beaae0..d9f1aea 100644
--- a/src/Structure/Instructions/Instrs/Numeric/I32Const.php
+++ b/src/Structure/Instructions/Instrs/Numeric/I32Const.php
@@ -11,7 +11,7 @@ final readonly class I32Const extends Instr
/**
* @param U32 $value
*/
- public function __construct(
+ protected function __construct(
public int $value,
) {
}
diff --git a/src/Structure/Instructions/Instrs/Numeric/I64Const.php b/src/Structure/Instructions/Instrs/Numeric/I64Const.php
index 59f34f3..59ca0f8 100644
--- a/src/Structure/Instructions/Instrs/Numeric/I64Const.php
+++ b/src/Structure/Instructions/Instrs/Numeric/I64Const.php
@@ -11,7 +11,7 @@ final readonly class I64Const extends Instr
/**
* @param U64 $value
*/
- public function __construct(
+ protected function __construct(
public int $value,
) {
}
diff --git a/src/Structure/Instructions/Instrs/Parametric/Select.php b/src/Structure/Instructions/Instrs/Parametric/Select.php
index 5e5b5ad..dd09ef3 100644
--- a/src/Structure/Instructions/Instrs/Parametric/Select.php
+++ b/src/Structure/Instructions/Instrs/Parametric/Select.php
@@ -12,7 +12,7 @@ final readonly class Select extends Instr
/**
* @param list<ValType> $types
*/
- public function __construct(
+ protected function __construct(
public array $types,
) {
}
diff --git a/src/Structure/Instructions/Instrs/Reference/RefFunc.php b/src/Structure/Instructions/Instrs/Reference/RefFunc.php
index 2849f5f..9924de1 100644
--- a/src/Structure/Instructions/Instrs/Reference/RefFunc.php
+++ b/src/Structure/Instructions/Instrs/Reference/RefFunc.php
@@ -9,7 +9,7 @@ use Nsfisis\Waddiwasi\Structure\Types\FuncIdx;
final readonly class RefFunc extends Instr
{
- public function __construct(
+ protected function __construct(
public FuncIdx $func,
) {
}
diff --git a/src/Structure/Instructions/Instrs/Reference/RefNull.php b/src/Structure/Instructions/Instrs/Reference/RefNull.php
index b3727c6..06e339c 100644
--- a/src/Structure/Instructions/Instrs/Reference/RefNull.php
+++ b/src/Structure/Instructions/Instrs/Reference/RefNull.php
@@ -9,7 +9,7 @@ use Nsfisis\Waddiwasi\Structure\Types\RefType;
final readonly class RefNull extends Instr
{
- public function __construct(
+ protected function __construct(
public RefType $type,
) {
}
diff --git a/src/Structure/Instructions/Instrs/Table/ElemDrop.php b/src/Structure/Instructions/Instrs/Table/ElemDrop.php
index fcaf9ea..5b96fcd 100644
--- a/src/Structure/Instructions/Instrs/Table/ElemDrop.php
+++ b/src/Structure/Instructions/Instrs/Table/ElemDrop.php
@@ -9,7 +9,7 @@ use Nsfisis\Waddiwasi\Structure\Types\ElemIdx;
final readonly class ElemDrop extends Instr
{
- public function __construct(
+ protected function __construct(
public ElemIdx $elem,
) {
}
diff --git a/src/Structure/Instructions/Instrs/Table/TableCopy.php b/src/Structure/Instructions/Instrs/Table/TableCopy.php
index 04a50c8..4c5d008 100644
--- a/src/Structure/Instructions/Instrs/Table/TableCopy.php
+++ b/src/Structure/Instructions/Instrs/Table/TableCopy.php
@@ -9,7 +9,7 @@ use Nsfisis\Waddiwasi\Structure\Types\TableIdx;
final readonly class TableCopy extends Instr
{
- public function __construct(
+ protected function __construct(
public TableIdx $to,
public TableIdx $from,
) {
diff --git a/src/Structure/Instructions/Instrs/Table/TableFill.php b/src/Structure/Instructions/Instrs/Table/TableFill.php
index 4128657..43d1f57 100644
--- a/src/Structure/Instructions/Instrs/Table/TableFill.php
+++ b/src/Structure/Instructions/Instrs/Table/TableFill.php
@@ -9,7 +9,7 @@ use Nsfisis\Waddiwasi\Structure\Types\TableIdx;
final readonly class TableFill extends Instr
{
- public function __construct(
+ protected function __construct(
public TableIdx $table,
) {
}
diff --git a/src/Structure/Instructions/Instrs/Table/TableGet.php b/src/Structure/Instructions/Instrs/Table/TableGet.php
index bc1b35f..77ebf4a 100644
--- a/src/Structure/Instructions/Instrs/Table/TableGet.php
+++ b/src/Structure/Instructions/Instrs/Table/TableGet.php
@@ -9,7 +9,7 @@ use Nsfisis\Waddiwasi\Structure\Types\TableIdx;
final readonly class TableGet extends Instr
{
- public function __construct(
+ protected function __construct(
public TableIdx $table,
) {
}
diff --git a/src/Structure/Instructions/Instrs/Table/TableGrow.php b/src/Structure/Instructions/Instrs/Table/TableGrow.php
index ddd9b2a..2ac222d 100644
--- a/src/Structure/Instructions/Instrs/Table/TableGrow.php
+++ b/src/Structure/Instructions/Instrs/Table/TableGrow.php
@@ -9,7 +9,7 @@ use Nsfisis\Waddiwasi\Structure\Types\TableIdx;
final readonly class TableGrow extends Instr
{
- public function __construct(
+ protected function __construct(
public TableIdx $table,
) {
}
diff --git a/src/Structure/Instructions/Instrs/Table/TableInit.php b/src/Structure/Instructions/Instrs/Table/TableInit.php
index d4666ae..7617809 100644
--- a/src/Structure/Instructions/Instrs/Table/TableInit.php
+++ b/src/Structure/Instructions/Instrs/Table/TableInit.php
@@ -10,7 +10,7 @@ use Nsfisis\Waddiwasi\Structure\Types\TableIdx;
final readonly class TableInit extends Instr
{
- public function __construct(
+ protected function __construct(
public TableIdx $to,
public ElemIdx $from,
) {
diff --git a/src/Structure/Instructions/Instrs/Table/TableSet.php b/src/Structure/Instructions/Instrs/Table/TableSet.php
index 8aaf11e..7ac7c8e 100644
--- a/src/Structure/Instructions/Instrs/Table/TableSet.php
+++ b/src/Structure/Instructions/Instrs/Table/TableSet.php
@@ -9,7 +9,7 @@ use Nsfisis\Waddiwasi\Structure\Types\TableIdx;
final readonly class TableSet extends Instr
{
- public function __construct(
+ protected function __construct(
public TableIdx $table,
) {
}
diff --git a/src/Structure/Instructions/Instrs/Table/TableSize.php b/src/Structure/Instructions/Instrs/Table/TableSize.php
index 00200a6..1c63e34 100644
--- a/src/Structure/Instructions/Instrs/Table/TableSize.php
+++ b/src/Structure/Instructions/Instrs/Table/TableSize.php
@@ -9,7 +9,7 @@ use Nsfisis\Waddiwasi\Structure\Types\TableIdx;
final readonly class TableSize extends Instr
{
- public function __construct(
+ protected function __construct(
public TableIdx $table,
) {
}
diff --git a/src/Structure/Instructions/Instrs/Variable/GlobalGet.php b/src/Structure/Instructions/Instrs/Variable/GlobalGet.php
index 7d25650..a3bd2c6 100644
--- a/src/Structure/Instructions/Instrs/Variable/GlobalGet.php
+++ b/src/Structure/Instructions/Instrs/Variable/GlobalGet.php
@@ -9,7 +9,7 @@ use Nsfisis\Waddiwasi\Structure\Types\GlobalIdx;
final readonly class GlobalGet extends Instr
{
- public function __construct(
+ protected function __construct(
public GlobalIdx $var,
) {
}
diff --git a/src/Structure/Instructions/Instrs/Variable/GlobalSet.php b/src/Structure/Instructions/Instrs/Variable/GlobalSet.php
index 2f32855..080e15a 100644
--- a/src/Structure/Instructions/Instrs/Variable/GlobalSet.php
+++ b/src/Structure/Instructions/Instrs/Variable/GlobalSet.php
@@ -9,7 +9,7 @@ use Nsfisis\Waddiwasi\Structure\Types\GlobalIdx;
final readonly class GlobalSet extends Instr
{
- public function __construct(
+ protected function __construct(
public GlobalIdx $var,
) {
}
diff --git a/src/Structure/Instructions/Instrs/Variable/LocalGet.php b/src/Structure/Instructions/Instrs/Variable/LocalGet.php
index 4c4f794..bc764c2 100644
--- a/src/Structure/Instructions/Instrs/Variable/LocalGet.php
+++ b/src/Structure/Instructions/Instrs/Variable/LocalGet.php
@@ -9,7 +9,7 @@ use Nsfisis\Waddiwasi\Structure\Types\LocalIdx;
final readonly class LocalGet extends Instr
{
- public function __construct(
+ protected function __construct(
public LocalIdx $var,
) {
}
diff --git a/src/Structure/Instructions/Instrs/Variable/LocalSet.php b/src/Structure/Instructions/Instrs/Variable/LocalSet.php
index d103c22..9b107e8 100644
--- a/src/Structure/Instructions/Instrs/Variable/LocalSet.php
+++ b/src/Structure/Instructions/Instrs/Variable/LocalSet.php
@@ -9,7 +9,7 @@ use Nsfisis\Waddiwasi\Structure\Types\LocalIdx;
final readonly class LocalSet extends Instr
{
- public function __construct(
+ protected function __construct(
public LocalIdx $var,
) {
}
diff --git a/src/Structure/Instructions/Instrs/Variable/LocalTee.php b/src/Structure/Instructions/Instrs/Variable/LocalTee.php
index 89e253b..3e48e8e 100644
--- a/src/Structure/Instructions/Instrs/Variable/LocalTee.php
+++ b/src/Structure/Instructions/Instrs/Variable/LocalTee.php
@@ -9,7 +9,7 @@ use Nsfisis\Waddiwasi\Structure\Types\LocalIdx;
final readonly class LocalTee extends Instr
{
- public function __construct(
+ protected function __construct(
public LocalIdx $var,
) {
}