diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-03-15 19:02:22 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-03-15 19:02:22 +0900 |
| commit | 9b45796547c8022b98a9254320323d72aecd81cb (patch) | |
| tree | 5aaf49a070859ff4c226c4efef5de0174d51d36d /src/BinaryFormat/Decoder.php | |
| parent | b2f2bbf72d7c5009f56f15fa972957ea399ad221 (diff) | |
| download | php-waddiwasi-9b45796547c8022b98a9254320323d72aecd81cb.tar.gz php-waddiwasi-9b45796547c8022b98a9254320323d72aecd81cb.tar.zst php-waddiwasi-9b45796547c8022b98a9254320323d72aecd81cb.zip | |
refactor: remove Expr class
Diffstat (limited to 'src/BinaryFormat/Decoder.php')
| -rw-r--r-- | src/BinaryFormat/Decoder.php | 16 |
1 files changed, 9 insertions, 7 deletions
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 |
