aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/BinaryFormat
diff options
context:
space:
mode:
Diffstat (limited to 'src/BinaryFormat')
-rw-r--r--src/BinaryFormat/Code.php5
-rw-r--r--src/BinaryFormat/Decoder.php16
2 files changed, 12 insertions, 9 deletions
diff --git a/src/BinaryFormat/Code.php b/src/BinaryFormat/Code.php
index cb0dbe6..6acf1e7 100644
--- a/src/BinaryFormat/Code.php
+++ b/src/BinaryFormat/Code.php
@@ -4,16 +4,17 @@ declare(strict_types=1);
namespace Nsfisis\Waddiwasi\BinaryFormat;
-use Nsfisis\Waddiwasi\Structure\Instructions\Expr;
+use Nsfisis\Waddiwasi\Structure\Instructions\Instr;
final readonly class Code
{
/**
* @param list<Locals> $compressedLocals
+ * @param list<Instr> $body
*/
public function __construct(
public array $compressedLocals,
- public Expr $body,
+ public array $body,
) {
}
}
diff --git a/src/BinaryFormat/Decoder.php b/src/BinaryFormat/Decoder.php
index 24089d0..30c5b56 100644
--- a/src/BinaryFormat/Decoder.php
+++ b/src/BinaryFormat/Decoder.php
@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace Nsfisis\Waddiwasi\BinaryFormat;
-use Nsfisis\Waddiwasi\Structure\Instructions\Expr;
use Nsfisis\Waddiwasi\Structure\Instructions\Instr;
use Nsfisis\Waddiwasi\Structure\Instructions\Instrs;
use Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Control\BlockType;
@@ -434,7 +433,7 @@ final class Decoder
return new Elem(
RefType::FuncRef,
array_map(
- fn ($funcRef) => new Expr([Instr::RefFunc($funcRef)]),
+ fn ($funcRef) => [Instr::RefFunc($funcRef)],
$initFuncRefs,
),
ElemMode::Active(0, $offset),
@@ -445,7 +444,7 @@ final class Decoder
return new Elem(
$refType,
array_map(
- fn ($funcRef) => new Expr([Instr::RefFunc($funcRef)]),
+ fn ($funcRef) => [Instr::RefFunc($funcRef)],
$initFuncRefs,
),
ElemMode::Passive(),
@@ -458,7 +457,7 @@ final class Decoder
return new Elem(
$refType,
array_map(
- fn ($funcRef) => new Expr([Instr::RefFunc($funcRef)]),
+ fn ($funcRef) => [Instr::RefFunc($funcRef)],
$initFuncRefs,
),
ElemMode::Active($table, $offset),
@@ -469,7 +468,7 @@ final class Decoder
return new Elem(
$refType,
array_map(
- fn ($funcRef) => new Expr([Instr::RefFunc($funcRef)]),
+ fn ($funcRef) => [Instr::RefFunc($funcRef)],
$initFuncRefs,
),
ElemMode::Declarative(),
@@ -650,9 +649,12 @@ final class Decoder
return $this->decodeU32();
}
- private function decodeExpr(): Expr
+ /**
+ * @return list<Instr>
+ */
+ private function decodeExpr(): array
{
- return new Expr($this->decodeInstrsUntil([Instrs\Control\End::class])[0]);
+ return $this->decodeInstrsUntil([Instrs\Control\End::class])[0];
}
private function decodeInstr(): Instr