diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-03-13 22:42:58 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-03-13 22:42:58 +0900 |
| commit | 814e5197439fbf2b404e8e66f3c6dd6e5ed39776 (patch) | |
| tree | 72901a7e2f1641366d2cfd57b883929989c68328 /src/Structure/Instructions | |
| parent | 7348999caf3ce1e0be64697319581d52f1d7f8ea (diff) | |
| download | php-waddiwasi-814e5197439fbf2b404e8e66f3c6dd6e5ed39776.tar.gz php-waddiwasi-814e5197439fbf2b404e8e66f3c6dd6e5ed39776.tar.zst php-waddiwasi-814e5197439fbf2b404e8e66f3c6dd6e5ed39776.zip | |
perf: make *Addr/*Idx to primitive int
Diffstat (limited to 'src/Structure/Instructions')
24 files changed, 49 insertions, 87 deletions
diff --git a/src/Structure/Instructions/Instr.php b/src/Structure/Instructions/Instr.php index 2014e04..cb4b3b8 100644 --- a/src/Structure/Instructions/Instr.php +++ b/src/Structure/Instructions/Instr.php @@ -12,15 +12,7 @@ use Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Parametric; use Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Reference; use Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Table; use Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Variable; -use Nsfisis\Waddiwasi\Structure\Types\DataIdx; -use Nsfisis\Waddiwasi\Structure\Types\ElemIdx; -use Nsfisis\Waddiwasi\Structure\Types\FuncIdx; -use Nsfisis\Waddiwasi\Structure\Types\GlobalIdx; -use Nsfisis\Waddiwasi\Structure\Types\LabelIdx; -use Nsfisis\Waddiwasi\Structure\Types\LocalIdx; use Nsfisis\Waddiwasi\Structure\Types\RefType; -use Nsfisis\Waddiwasi\Structure\Types\TableIdx; -use Nsfisis\Waddiwasi\Structure\Types\TypeIdx; use Nsfisis\Waddiwasi\Structure\Types\ValType; abstract readonly class Instr @@ -616,7 +608,7 @@ abstract readonly class Instr } // Reference instructions - final public static function RefFunc(FuncIdx $func): Reference\RefFunc + final public static function RefFunc(int $func): Reference\RefFunc { return new Reference\RefFunc($func); } @@ -643,63 +635,63 @@ abstract readonly class Instr } // Variable instructions - final public static function GlobalGet(GlobalIdx $var): Variable\GlobalGet + final public static function GlobalGet(int $var): Variable\GlobalGet { return new Variable\GlobalGet($var); } - final public static function GlobalSet(GlobalIdx $var): Variable\GlobalSet + final public static function GlobalSet(int $var): Variable\GlobalSet { return new Variable\GlobalSet($var); } - final public static function LocalGet(LocalIdx $var): Variable\LocalGet + final public static function LocalGet(int $var): Variable\LocalGet { return new Variable\LocalGet($var); } - final public static function LocalSet(LocalIdx $var): Variable\LocalSet + final public static function LocalSet(int $var): Variable\LocalSet { return new Variable\LocalSet($var); } - final public static function LocalTee(LocalIdx $var): Variable\LocalTee + final public static function LocalTee(int $var): Variable\LocalTee { return new Variable\LocalTee($var); } // Table instructions - final public static function ElemDrop(ElemIdx $elem): Table\ElemDrop + final public static function ElemDrop(int $elem): Table\ElemDrop { return new Table\ElemDrop($elem); } - final public static function TableCopy(TableIdx $to, TableIdx $from): Table\TableCopy + final public static function TableCopy(int $to, int $from): Table\TableCopy { return new Table\TableCopy($to, $from); } - final public static function TableFill(TableIdx $table): Table\TableFill + final public static function TableFill(int $table): Table\TableFill { return new Table\TableFill($table); } - final public static function TableGet(TableIdx $table): Table\TableGet + final public static function TableGet(int $table): Table\TableGet { return new Table\TableGet($table); } - final public static function TableGrow(TableIdx $table): Table\TableGrow + final public static function TableGrow(int $table): Table\TableGrow { return new Table\TableGrow($table); } - final public static function TableInit(TableIdx $to, ElemIdx $from): Table\TableInit + final public static function TableInit(int $to, int $from): Table\TableInit { return new Table\TableInit($to, $from); } - final public static function TableSet(TableIdx $table): Table\TableSet + final public static function TableSet(int $table): Table\TableSet { return new Table\TableSet($table); } - final public static function TableSize(TableIdx $table): Table\TableSize + final public static function TableSize(int $table): Table\TableSize { return new Table\TableSize($table); } // Memory instructions - final public static function DataDrop(DataIdx $data): Memory\DataDrop + final public static function DataDrop(int $data): Memory\DataDrop { return new Memory\DataDrop($data); } @@ -899,7 +891,7 @@ abstract readonly class Instr { return new Memory\MemoryGrow(); } - final public static function MemoryInit(DataIdx $data): Memory\MemoryInit + final public static function MemoryInit(int $data): Memory\MemoryInit { return new Memory\MemoryInit($data); } @@ -916,26 +908,26 @@ abstract readonly class Instr { return new Control\Block($type, $body); } - final public static function Br(LabelIdx $label): Control\Br + final public static function Br(int $label): Control\Br { return new Control\Br($label); } - final public static function BrIf(LabelIdx $label): Control\BrIf + final public static function BrIf(int $label): Control\BrIf { return new Control\BrIf($label); } /** - * @param list<LabelIdx> $labelTable + * @param list<int> $labelTable */ - final public static function BrTable(array $labelTable, LabelIdx $defaultLabel): Control\BrTable + final public static function BrTable(array $labelTable, int $defaultLabel): Control\BrTable { return new Control\BrTable($labelTable, $defaultLabel); } - final public static function Call(FuncIdx $func): Control\Call + final public static function Call(int $func): Control\Call { return new Control\Call($func); } - final public static function CallIndirect(TableIdx $funcTable, TypeIdx $type): Control\CallIndirect + final public static function CallIndirect(int $funcTable, int $type): Control\CallIndirect { return new Control\CallIndirect($funcTable, $type); } diff --git a/src/Structure/Instructions/Instrs/Control/BlockType.php b/src/Structure/Instructions/Instrs/Control/BlockType.php index c2fe106..a90389b 100644 --- a/src/Structure/Instructions/Instrs/Control/BlockType.php +++ b/src/Structure/Instructions/Instrs/Control/BlockType.php @@ -4,12 +4,11 @@ declare(strict_types=1); namespace Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Control; -use Nsfisis\Waddiwasi\Structure\Types\TypeIdx; use Nsfisis\Waddiwasi\Structure\Types\ValType; abstract readonly class BlockType { - final public static function TypeIdx(TypeIdx $type): BlockTypes\TypeIdx + final public static function TypeIdx(int $type): BlockTypes\TypeIdx { return new BlockTypes\TypeIdx($type); } diff --git a/src/Structure/Instructions/Instrs/Control/BlockTypes/TypeIdx.php b/src/Structure/Instructions/Instrs/Control/BlockTypes/TypeIdx.php index bb798e4..564eaf4 100644 --- a/src/Structure/Instructions/Instrs/Control/BlockTypes/TypeIdx.php +++ b/src/Structure/Instructions/Instrs/Control/BlockTypes/TypeIdx.php @@ -5,16 +5,10 @@ declare(strict_types=1); namespace Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Control\BlockTypes; use Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Control\BlockType; -use Nsfisis\Waddiwasi\Structure\Types\TypeIdx as OrigTypeIdx; final readonly class TypeIdx extends BlockType { - protected function __construct(public OrigTypeIdx $inner) + protected function __construct(public int $inner) { } - - public static function opName(): string - { - return "hoge"; - } } diff --git a/src/Structure/Instructions/Instrs/Control/Br.php b/src/Structure/Instructions/Instrs/Control/Br.php index 26af157..7fe3415 100644 --- a/src/Structure/Instructions/Instrs/Control/Br.php +++ b/src/Structure/Instructions/Instrs/Control/Br.php @@ -5,12 +5,11 @@ declare(strict_types=1); namespace Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Control; use Nsfisis\Waddiwasi\Structure\Instructions\Instr; -use Nsfisis\Waddiwasi\Structure\Types\LabelIdx; final readonly class Br extends Instr { protected function __construct( - public LabelIdx $label, + public int $label, ) { } diff --git a/src/Structure/Instructions/Instrs/Control/BrIf.php b/src/Structure/Instructions/Instrs/Control/BrIf.php index c6a4b3c..5fb622e 100644 --- a/src/Structure/Instructions/Instrs/Control/BrIf.php +++ b/src/Structure/Instructions/Instrs/Control/BrIf.php @@ -5,12 +5,11 @@ declare(strict_types=1); namespace Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Control; use Nsfisis\Waddiwasi\Structure\Instructions\Instr; -use Nsfisis\Waddiwasi\Structure\Types\LabelIdx; final readonly class BrIf extends Instr { protected function __construct( - public LabelIdx $label, + public int $label, ) { } diff --git a/src/Structure/Instructions/Instrs/Control/BrTable.php b/src/Structure/Instructions/Instrs/Control/BrTable.php index c7685f6..a9c37e8 100644 --- a/src/Structure/Instructions/Instrs/Control/BrTable.php +++ b/src/Structure/Instructions/Instrs/Control/BrTable.php @@ -5,16 +5,15 @@ declare(strict_types=1); namespace Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Control; use Nsfisis\Waddiwasi\Structure\Instructions\Instr; -use Nsfisis\Waddiwasi\Structure\Types\LabelIdx; final readonly class BrTable extends Instr { /** - * @param list<LabelIdx> $labelTable + * @param list<int> $labelTable */ protected function __construct( public array $labelTable, - public LabelIdx $defaultLabel, + public int $defaultLabel, ) { } diff --git a/src/Structure/Instructions/Instrs/Control/Call.php b/src/Structure/Instructions/Instrs/Control/Call.php index ba73037..9ee14be 100644 --- a/src/Structure/Instructions/Instrs/Control/Call.php +++ b/src/Structure/Instructions/Instrs/Control/Call.php @@ -5,12 +5,11 @@ declare(strict_types=1); namespace Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Control; use Nsfisis\Waddiwasi\Structure\Instructions\Instr; -use Nsfisis\Waddiwasi\Structure\Types\FuncIdx; final readonly class Call extends Instr { protected function __construct( - public FuncIdx $func, + public int $func, ) { } diff --git a/src/Structure/Instructions/Instrs/Control/CallIndirect.php b/src/Structure/Instructions/Instrs/Control/CallIndirect.php index d6fcea4..11617ce 100644 --- a/src/Structure/Instructions/Instrs/Control/CallIndirect.php +++ b/src/Structure/Instructions/Instrs/Control/CallIndirect.php @@ -5,14 +5,12 @@ declare(strict_types=1); namespace Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Control; use Nsfisis\Waddiwasi\Structure\Instructions\Instr; -use Nsfisis\Waddiwasi\Structure\Types\TableIdx; -use Nsfisis\Waddiwasi\Structure\Types\TypeIdx; final readonly class CallIndirect extends Instr { protected function __construct( - public TableIdx $funcTable, - public TypeIdx $type, + public int $funcTable, + public int $type, ) { } diff --git a/src/Structure/Instructions/Instrs/Memory/DataDrop.php b/src/Structure/Instructions/Instrs/Memory/DataDrop.php index 90cea96..acf337b 100644 --- a/src/Structure/Instructions/Instrs/Memory/DataDrop.php +++ b/src/Structure/Instructions/Instrs/Memory/DataDrop.php @@ -5,12 +5,11 @@ declare(strict_types=1); namespace Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Memory; use Nsfisis\Waddiwasi\Structure\Instructions\Instr; -use Nsfisis\Waddiwasi\Structure\Types\DataIdx; final readonly class DataDrop extends Instr { protected function __construct( - public DataIdx $data, + public int $data, ) { } diff --git a/src/Structure/Instructions/Instrs/Memory/MemoryInit.php b/src/Structure/Instructions/Instrs/Memory/MemoryInit.php index 5538234..8bf762b 100644 --- a/src/Structure/Instructions/Instrs/Memory/MemoryInit.php +++ b/src/Structure/Instructions/Instrs/Memory/MemoryInit.php @@ -5,12 +5,11 @@ declare(strict_types=1); namespace Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Memory; use Nsfisis\Waddiwasi\Structure\Instructions\Instr; -use Nsfisis\Waddiwasi\Structure\Types\DataIdx; final readonly class MemoryInit extends Instr { protected function __construct( - public DataIdx $data, + public int $data, ) { } diff --git a/src/Structure/Instructions/Instrs/Reference/RefFunc.php b/src/Structure/Instructions/Instrs/Reference/RefFunc.php index 0ccbc36..97f11b5 100644 --- a/src/Structure/Instructions/Instrs/Reference/RefFunc.php +++ b/src/Structure/Instructions/Instrs/Reference/RefFunc.php @@ -5,12 +5,11 @@ declare(strict_types=1); namespace Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Reference; use Nsfisis\Waddiwasi\Structure\Instructions\Instr; -use Nsfisis\Waddiwasi\Structure\Types\FuncIdx; final readonly class RefFunc extends Instr { protected function __construct( - public FuncIdx $func, + public int $func, ) { } diff --git a/src/Structure/Instructions/Instrs/Table/ElemDrop.php b/src/Structure/Instructions/Instrs/Table/ElemDrop.php index bbf4586..65ea56a 100644 --- a/src/Structure/Instructions/Instrs/Table/ElemDrop.php +++ b/src/Structure/Instructions/Instrs/Table/ElemDrop.php @@ -5,12 +5,11 @@ declare(strict_types=1); namespace Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Table; use Nsfisis\Waddiwasi\Structure\Instructions\Instr; -use Nsfisis\Waddiwasi\Structure\Types\ElemIdx; final readonly class ElemDrop extends Instr { protected function __construct( - public ElemIdx $elem, + public int $elem, ) { } diff --git a/src/Structure/Instructions/Instrs/Table/TableCopy.php b/src/Structure/Instructions/Instrs/Table/TableCopy.php index 85aa9fc..b756d28 100644 --- a/src/Structure/Instructions/Instrs/Table/TableCopy.php +++ b/src/Structure/Instructions/Instrs/Table/TableCopy.php @@ -5,13 +5,12 @@ declare(strict_types=1); namespace Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Table; use Nsfisis\Waddiwasi\Structure\Instructions\Instr; -use Nsfisis\Waddiwasi\Structure\Types\TableIdx; final readonly class TableCopy extends Instr { protected function __construct( - public TableIdx $to, - public TableIdx $from, + public int $to, + public int $from, ) { } diff --git a/src/Structure/Instructions/Instrs/Table/TableFill.php b/src/Structure/Instructions/Instrs/Table/TableFill.php index 84c6e13..fea7bb9 100644 --- a/src/Structure/Instructions/Instrs/Table/TableFill.php +++ b/src/Structure/Instructions/Instrs/Table/TableFill.php @@ -5,12 +5,11 @@ declare(strict_types=1); namespace Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Table; use Nsfisis\Waddiwasi\Structure\Instructions\Instr; -use Nsfisis\Waddiwasi\Structure\Types\TableIdx; final readonly class TableFill extends Instr { protected function __construct( - public TableIdx $table, + public int $table, ) { } diff --git a/src/Structure/Instructions/Instrs/Table/TableGet.php b/src/Structure/Instructions/Instrs/Table/TableGet.php index e10dd5a..bb7b58f 100644 --- a/src/Structure/Instructions/Instrs/Table/TableGet.php +++ b/src/Structure/Instructions/Instrs/Table/TableGet.php @@ -5,12 +5,11 @@ declare(strict_types=1); namespace Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Table; use Nsfisis\Waddiwasi\Structure\Instructions\Instr; -use Nsfisis\Waddiwasi\Structure\Types\TableIdx; final readonly class TableGet extends Instr { protected function __construct( - public TableIdx $table, + public int $table, ) { } diff --git a/src/Structure/Instructions/Instrs/Table/TableGrow.php b/src/Structure/Instructions/Instrs/Table/TableGrow.php index 4f224fc..026a09b 100644 --- a/src/Structure/Instructions/Instrs/Table/TableGrow.php +++ b/src/Structure/Instructions/Instrs/Table/TableGrow.php @@ -5,12 +5,11 @@ declare(strict_types=1); namespace Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Table; use Nsfisis\Waddiwasi\Structure\Instructions\Instr; -use Nsfisis\Waddiwasi\Structure\Types\TableIdx; final readonly class TableGrow extends Instr { protected function __construct( - public TableIdx $table, + public int $table, ) { } diff --git a/src/Structure/Instructions/Instrs/Table/TableInit.php b/src/Structure/Instructions/Instrs/Table/TableInit.php index 2c834c0..b728de3 100644 --- a/src/Structure/Instructions/Instrs/Table/TableInit.php +++ b/src/Structure/Instructions/Instrs/Table/TableInit.php @@ -5,14 +5,12 @@ declare(strict_types=1); namespace Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Table; use Nsfisis\Waddiwasi\Structure\Instructions\Instr; -use Nsfisis\Waddiwasi\Structure\Types\ElemIdx; -use Nsfisis\Waddiwasi\Structure\Types\TableIdx; final readonly class TableInit extends Instr { protected function __construct( - public TableIdx $to, - public ElemIdx $from, + public int $to, + public int $from, ) { } diff --git a/src/Structure/Instructions/Instrs/Table/TableSet.php b/src/Structure/Instructions/Instrs/Table/TableSet.php index f02c375..5e5bb1b 100644 --- a/src/Structure/Instructions/Instrs/Table/TableSet.php +++ b/src/Structure/Instructions/Instrs/Table/TableSet.php @@ -5,12 +5,11 @@ declare(strict_types=1); namespace Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Table; use Nsfisis\Waddiwasi\Structure\Instructions\Instr; -use Nsfisis\Waddiwasi\Structure\Types\TableIdx; final readonly class TableSet extends Instr { protected function __construct( - public TableIdx $table, + public int $table, ) { } diff --git a/src/Structure/Instructions/Instrs/Table/TableSize.php b/src/Structure/Instructions/Instrs/Table/TableSize.php index 321c8f7..3357f48 100644 --- a/src/Structure/Instructions/Instrs/Table/TableSize.php +++ b/src/Structure/Instructions/Instrs/Table/TableSize.php @@ -5,12 +5,11 @@ declare(strict_types=1); namespace Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Table; use Nsfisis\Waddiwasi\Structure\Instructions\Instr; -use Nsfisis\Waddiwasi\Structure\Types\TableIdx; final readonly class TableSize extends Instr { protected function __construct( - public TableIdx $table, + public int $table, ) { } diff --git a/src/Structure/Instructions/Instrs/Variable/GlobalGet.php b/src/Structure/Instructions/Instrs/Variable/GlobalGet.php index 542a805..8ee9f09 100644 --- a/src/Structure/Instructions/Instrs/Variable/GlobalGet.php +++ b/src/Structure/Instructions/Instrs/Variable/GlobalGet.php @@ -5,12 +5,11 @@ declare(strict_types=1); namespace Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Variable; use Nsfisis\Waddiwasi\Structure\Instructions\Instr; -use Nsfisis\Waddiwasi\Structure\Types\GlobalIdx; final readonly class GlobalGet extends Instr { protected function __construct( - public GlobalIdx $var, + public int $var, ) { } diff --git a/src/Structure/Instructions/Instrs/Variable/GlobalSet.php b/src/Structure/Instructions/Instrs/Variable/GlobalSet.php index 1540dd3..3dbc5ec 100644 --- a/src/Structure/Instructions/Instrs/Variable/GlobalSet.php +++ b/src/Structure/Instructions/Instrs/Variable/GlobalSet.php @@ -5,12 +5,11 @@ declare(strict_types=1); namespace Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Variable; use Nsfisis\Waddiwasi\Structure\Instructions\Instr; -use Nsfisis\Waddiwasi\Structure\Types\GlobalIdx; final readonly class GlobalSet extends Instr { protected function __construct( - public GlobalIdx $var, + public int $var, ) { } diff --git a/src/Structure/Instructions/Instrs/Variable/LocalGet.php b/src/Structure/Instructions/Instrs/Variable/LocalGet.php index 4fc0ced..c9ba7e7 100644 --- a/src/Structure/Instructions/Instrs/Variable/LocalGet.php +++ b/src/Structure/Instructions/Instrs/Variable/LocalGet.php @@ -5,12 +5,11 @@ declare(strict_types=1); namespace Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Variable; use Nsfisis\Waddiwasi\Structure\Instructions\Instr; -use Nsfisis\Waddiwasi\Structure\Types\LocalIdx; final readonly class LocalGet extends Instr { protected function __construct( - public LocalIdx $var, + public int $var, ) { } diff --git a/src/Structure/Instructions/Instrs/Variable/LocalSet.php b/src/Structure/Instructions/Instrs/Variable/LocalSet.php index 4a21ca3..eb79baa 100644 --- a/src/Structure/Instructions/Instrs/Variable/LocalSet.php +++ b/src/Structure/Instructions/Instrs/Variable/LocalSet.php @@ -5,12 +5,11 @@ declare(strict_types=1); namespace Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Variable; use Nsfisis\Waddiwasi\Structure\Instructions\Instr; -use Nsfisis\Waddiwasi\Structure\Types\LocalIdx; final readonly class LocalSet extends Instr { protected function __construct( - public LocalIdx $var, + public int $var, ) { } diff --git a/src/Structure/Instructions/Instrs/Variable/LocalTee.php b/src/Structure/Instructions/Instrs/Variable/LocalTee.php index 97fb46a..862b4d2 100644 --- a/src/Structure/Instructions/Instrs/Variable/LocalTee.php +++ b/src/Structure/Instructions/Instrs/Variable/LocalTee.php @@ -5,12 +5,11 @@ declare(strict_types=1); namespace Nsfisis\Waddiwasi\Structure\Instructions\Instrs\Variable; use Nsfisis\Waddiwasi\Structure\Instructions\Instr; -use Nsfisis\Waddiwasi\Structure\Types\LocalIdx; final readonly class LocalTee extends Instr { protected function __construct( - public LocalIdx $var, + public int $var, ) { } |
