From e2495878b872b341e6e04eed31dd255b1a6e256f Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 3 Jan 2024 01:35:32 +0900 Subject: feat: implement binary decoder --- src/Structure/Instructions/Instrs/Control/Block.php | 19 +++++++++++++++++++ .../Instructions/Instrs/Control/BlockType.php | 21 +++++++++++++++++++++ .../Instrs/Control/BlockTypes/TypeIdx.php | 15 +++++++++++++++ .../Instrs/Control/BlockTypes/ValType.php | 15 +++++++++++++++ src/Structure/Instructions/Instrs/Control/Br.php | 16 ++++++++++++++++ src/Structure/Instructions/Instrs/Control/BrIf.php | 16 ++++++++++++++++ .../Instructions/Instrs/Control/BrTable.php | 20 ++++++++++++++++++++ src/Structure/Instructions/Instrs/Control/Call.php | 16 ++++++++++++++++ .../Instructions/Instrs/Control/CallIndirect.php | 18 ++++++++++++++++++ src/Structure/Instructions/Instrs/Control/Else_.php | 11 +++++++++++ src/Structure/Instructions/Instrs/Control/End.php | 11 +++++++++++ src/Structure/Instructions/Instrs/Control/If_.php | 21 +++++++++++++++++++++ src/Structure/Instructions/Instrs/Control/Loop.php | 19 +++++++++++++++++++ src/Structure/Instructions/Instrs/Control/Nop.php | 11 +++++++++++ .../Instructions/Instrs/Control/Return_.php | 11 +++++++++++ .../Instructions/Instrs/Control/Unreachable.php | 11 +++++++++++ 16 files changed, 251 insertions(+) create mode 100644 src/Structure/Instructions/Instrs/Control/Block.php create mode 100644 src/Structure/Instructions/Instrs/Control/BlockType.php create mode 100644 src/Structure/Instructions/Instrs/Control/BlockTypes/TypeIdx.php create mode 100644 src/Structure/Instructions/Instrs/Control/BlockTypes/ValType.php create mode 100644 src/Structure/Instructions/Instrs/Control/Br.php create mode 100644 src/Structure/Instructions/Instrs/Control/BrIf.php create mode 100644 src/Structure/Instructions/Instrs/Control/BrTable.php create mode 100644 src/Structure/Instructions/Instrs/Control/Call.php create mode 100644 src/Structure/Instructions/Instrs/Control/CallIndirect.php create mode 100644 src/Structure/Instructions/Instrs/Control/Else_.php create mode 100644 src/Structure/Instructions/Instrs/Control/End.php create mode 100644 src/Structure/Instructions/Instrs/Control/If_.php create mode 100644 src/Structure/Instructions/Instrs/Control/Loop.php create mode 100644 src/Structure/Instructions/Instrs/Control/Nop.php create mode 100644 src/Structure/Instructions/Instrs/Control/Return_.php create mode 100644 src/Structure/Instructions/Instrs/Control/Unreachable.php (limited to 'src/Structure/Instructions/Instrs/Control') diff --git a/src/Structure/Instructions/Instrs/Control/Block.php b/src/Structure/Instructions/Instrs/Control/Block.php new file mode 100644 index 0000000..2be7a1f --- /dev/null +++ b/src/Structure/Instructions/Instrs/Control/Block.php @@ -0,0 +1,19 @@ + $body + */ + public function __construct( + public BlockType $type, + public array $body, + ) { + } +} diff --git a/src/Structure/Instructions/Instrs/Control/BlockType.php b/src/Structure/Instructions/Instrs/Control/BlockType.php new file mode 100644 index 0000000..68c6bd4 --- /dev/null +++ b/src/Structure/Instructions/Instrs/Control/BlockType.php @@ -0,0 +1,21 @@ + $labelTable + */ + public 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 new file mode 100644 index 0000000..c8702d3 --- /dev/null +++ b/src/Structure/Instructions/Instrs/Control/Call.php @@ -0,0 +1,16 @@ + $thenBody + * @param list $elseBody + */ + public 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 new file mode 100644 index 0000000..30c85ef --- /dev/null +++ b/src/Structure/Instructions/Instrs/Control/Loop.php @@ -0,0 +1,19 @@ + $body + */ + public function __construct( + public BlockType $type, + public array $body, + ) { + } +} diff --git a/src/Structure/Instructions/Instrs/Control/Nop.php b/src/Structure/Instructions/Instrs/Control/Nop.php new file mode 100644 index 0000000..dbb1b6c --- /dev/null +++ b/src/Structure/Instructions/Instrs/Control/Nop.php @@ -0,0 +1,11 @@ +