From d1c268b76f65e69ea708096d5023c4d731cff594 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 11 Jul 2024 20:02:34 +0900 Subject: fix: various spectests --- src/WebAssembly/Execution/Allocator.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/WebAssembly/Execution/Allocator.php') diff --git a/src/WebAssembly/Execution/Allocator.php b/src/WebAssembly/Execution/Allocator.php index 4e2adbf..79f8679 100644 --- a/src/WebAssembly/Execution/Allocator.php +++ b/src/WebAssembly/Execution/Allocator.php @@ -12,6 +12,7 @@ use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\MemType; use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\TableType; use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\ValType; use RuntimeException; +use function assert; use function count; final readonly class Allocator @@ -61,7 +62,7 @@ final readonly class Allocator foreach ($externVals as $externVal) { match ($externVal::class) { - ExternVals\Func::class => null, // handled below. + 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, @@ -72,14 +73,13 @@ final readonly class Allocator foreach ($preAllocatedFuncs as $funcAddr) { $m->funcAddrs[] = $funcAddr; $funcInst = $this->store->funcs[$funcAddr]; - if ($funcInst instanceof FuncInsts\Wasm) { - // @phpstan-ignore-next-line - $this->store->funcs[$funcAddr] = FuncInst::Wasm( - $funcInst->type, - $m, - $funcInst->code, - ); - } + assert($funcInst instanceof FuncInsts\Wasm); + // @phpstan-ignore-next-line + $this->store->funcs[$funcAddr] = FuncInst::Wasm( + $funcInst->type, + $m, + $funcInst->code, + ); } foreach ($module->tables as $table) { $m->tableAddrs[] = $this->allocTable($table->type, Ref::RefNull($table->type->refType)); -- cgit v1.2.3-70-g09d2