diff options
Diffstat (limited to 'src/WebAssembly/Structure/Modules')
28 files changed, 528 insertions, 0 deletions
diff --git a/src/WebAssembly/Structure/Modules/Data.php b/src/WebAssembly/Structure/Modules/Data.php new file mode 100644 index 0000000..3994a01 --- /dev/null +++ b/src/WebAssembly/Structure/Modules/Data.php @@ -0,0 +1,17 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules; + +final readonly class Data +{ + /** + * @param list<Byte> $init + */ + public function __construct( + public array $init, + public DataMode $mode, + ) { + } +} diff --git a/src/WebAssembly/Structure/Modules/DataMode.php b/src/WebAssembly/Structure/Modules/DataMode.php new file mode 100644 index 0000000..37205bc --- /dev/null +++ b/src/WebAssembly/Structure/Modules/DataMode.php @@ -0,0 +1,25 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules; + +use Nsfisis\Waddiwasi\WebAssembly\Structure\Instructions\Instr; + +abstract readonly class DataMode +{ + final public static function Passive(): DataModes\Passive + { + return new DataModes\Passive(); + } + + /** + * @param list<Instr> $offset + */ + final public static function Active( + int $memory, + array $offset, + ): DataModes\Active { + return new DataModes\Active($memory, $offset); + } +} diff --git a/src/WebAssembly/Structure/Modules/DataModes/Active.php b/src/WebAssembly/Structure/Modules/DataModes/Active.php new file mode 100644 index 0000000..41cc9c7 --- /dev/null +++ b/src/WebAssembly/Structure/Modules/DataModes/Active.php @@ -0,0 +1,20 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\DataModes; + +use Nsfisis\Waddiwasi\WebAssembly\Structure\Instructions\Instr; +use Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\DataMode; + +final readonly class Active extends DataMode +{ + /** + * @param list<Instr> $offset + */ + protected function __construct( + public int $memory, + public array $offset, + ) { + } +} diff --git a/src/WebAssembly/Structure/Modules/DataModes/Passive.php b/src/WebAssembly/Structure/Modules/DataModes/Passive.php new file mode 100644 index 0000000..6ef6ba9 --- /dev/null +++ b/src/WebAssembly/Structure/Modules/DataModes/Passive.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\DataModes; + +use Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\DataMode; + +final readonly class Passive extends DataMode +{ + protected function __construct() + { + } +} diff --git a/src/WebAssembly/Structure/Modules/Elem.php b/src/WebAssembly/Structure/Modules/Elem.php new file mode 100644 index 0000000..1b9831f --- /dev/null +++ b/src/WebAssembly/Structure/Modules/Elem.php @@ -0,0 +1,21 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules; + +use Nsfisis\Waddiwasi\WebAssembly\Structure\Instructions\Instr; +use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\RefType; + +final readonly class Elem +{ + /** + * @param list<list<Instr>> $init + */ + public function __construct( + public RefType $type, + public array $init, + public ElemMode $mode, + ) { + } +} diff --git a/src/WebAssembly/Structure/Modules/ElemMode.php b/src/WebAssembly/Structure/Modules/ElemMode.php new file mode 100644 index 0000000..0777bd4 --- /dev/null +++ b/src/WebAssembly/Structure/Modules/ElemMode.php @@ -0,0 +1,30 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules; + +use Nsfisis\Waddiwasi\WebAssembly\Structure\Instructions\Instr; + +abstract readonly class ElemMode +{ + final public static function Passive(): ElemModes\Passive + { + return new ElemModes\Passive(); + } + + /** + * @param list<Instr> $offset + */ + final public static function Active( + int $table, + array $offset, + ): ElemModes\Active { + return new ElemModes\Active($table, $offset); + } + + final public static function Declarative(): ElemModes\Declarative + { + return new ElemModes\Declarative(); + } +} diff --git a/src/WebAssembly/Structure/Modules/ElemModes/Active.php b/src/WebAssembly/Structure/Modules/ElemModes/Active.php new file mode 100644 index 0000000..e66e080 --- /dev/null +++ b/src/WebAssembly/Structure/Modules/ElemModes/Active.php @@ -0,0 +1,20 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\ElemModes; + +use Nsfisis\Waddiwasi\WebAssembly\Structure\Instructions\Instr; +use Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\ElemMode; + +final readonly class Active extends ElemMode +{ + /** + * @param list<Instr> $offset + */ + protected function __construct( + public int $table, + public array $offset, + ) { + } +} diff --git a/src/WebAssembly/Structure/Modules/ElemModes/Declarative.php b/src/WebAssembly/Structure/Modules/ElemModes/Declarative.php new file mode 100644 index 0000000..28f917a --- /dev/null +++ b/src/WebAssembly/Structure/Modules/ElemModes/Declarative.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\ElemModes; + +use Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\ElemMode; + +final readonly class Declarative extends ElemMode +{ + protected function __construct() + { + } +} diff --git a/src/WebAssembly/Structure/Modules/ElemModes/Passive.php b/src/WebAssembly/Structure/Modules/ElemModes/Passive.php new file mode 100644 index 0000000..5fb323e --- /dev/null +++ b/src/WebAssembly/Structure/Modules/ElemModes/Passive.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\ElemModes; + +use Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\ElemMode; + +final readonly class Passive extends ElemMode +{ + protected function __construct() + { + } +} diff --git a/src/WebAssembly/Structure/Modules/Export.php b/src/WebAssembly/Structure/Modules/Export.php new file mode 100644 index 0000000..fea3f04 --- /dev/null +++ b/src/WebAssembly/Structure/Modules/Export.php @@ -0,0 +1,17 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules; + +final readonly class Export +{ + /** + * @param Name $name + */ + public function __construct( + public string $name, + public ExportDesc $desc, + ) { + } +} diff --git a/src/WebAssembly/Structure/Modules/ExportDesc.php b/src/WebAssembly/Structure/Modules/ExportDesc.php new file mode 100644 index 0000000..3462569 --- /dev/null +++ b/src/WebAssembly/Structure/Modules/ExportDesc.php @@ -0,0 +1,28 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules; + +abstract readonly class ExportDesc +{ + final public static function Func(int $func): ExportDescs\Func + { + return new ExportDescs\Func($func); + } + + final public static function Table(int $table): ExportDescs\Table + { + return new ExportDescs\Table($table); + } + + final public static function Mem(int $mem): ExportDescs\Mem + { + return new ExportDescs\Mem($mem); + } + + final public static function Global(int $global): ExportDescs\Global_ + { + return new ExportDescs\Global_($global); + } +} diff --git a/src/WebAssembly/Structure/Modules/ExportDescs/Func.php b/src/WebAssembly/Structure/Modules/ExportDescs/Func.php new file mode 100644 index 0000000..85926c6 --- /dev/null +++ b/src/WebAssembly/Structure/Modules/ExportDescs/Func.php @@ -0,0 +1,15 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\ExportDescs; + +use Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\ExportDesc; + +final readonly class Func extends ExportDesc +{ + protected function __construct( + public int $func, + ) { + } +} diff --git a/src/WebAssembly/Structure/Modules/ExportDescs/Global_.php b/src/WebAssembly/Structure/Modules/ExportDescs/Global_.php new file mode 100644 index 0000000..9e1d481 --- /dev/null +++ b/src/WebAssembly/Structure/Modules/ExportDescs/Global_.php @@ -0,0 +1,15 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\ExportDescs; + +use Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\ExportDesc; + +final readonly class Global_ extends ExportDesc +{ + protected function __construct( + public int $global, + ) { + } +} diff --git a/src/WebAssembly/Structure/Modules/ExportDescs/Mem.php b/src/WebAssembly/Structure/Modules/ExportDescs/Mem.php new file mode 100644 index 0000000..9212f45 --- /dev/null +++ b/src/WebAssembly/Structure/Modules/ExportDescs/Mem.php @@ -0,0 +1,15 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\ExportDescs; + +use Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\ExportDesc; + +final readonly class Mem extends ExportDesc +{ + protected function __construct( + public int $mem, + ) { + } +} diff --git a/src/WebAssembly/Structure/Modules/ExportDescs/Table.php b/src/WebAssembly/Structure/Modules/ExportDescs/Table.php new file mode 100644 index 0000000..e89f2d8 --- /dev/null +++ b/src/WebAssembly/Structure/Modules/ExportDescs/Table.php @@ -0,0 +1,15 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\ExportDescs; + +use Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\ExportDesc; + +final readonly class Table extends ExportDesc +{ + protected function __construct( + public int $table, + ) { + } +} diff --git a/src/WebAssembly/Structure/Modules/Func.php b/src/WebAssembly/Structure/Modules/Func.php new file mode 100644 index 0000000..f1c305e --- /dev/null +++ b/src/WebAssembly/Structure/Modules/Func.php @@ -0,0 +1,21 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules; + +use Nsfisis\Waddiwasi\WebAssembly\Structure\Instructions\Instr; + +final readonly class Func +{ + /** + * @param list<Local> $locals + * @param list<Instr> $body + */ + public function __construct( + public int $type, + public array $locals, + public array $body, + ) { + } +} diff --git a/src/WebAssembly/Structure/Modules/Global_.php b/src/WebAssembly/Structure/Modules/Global_.php new file mode 100644 index 0000000..04ffbc6 --- /dev/null +++ b/src/WebAssembly/Structure/Modules/Global_.php @@ -0,0 +1,20 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules; + +use Nsfisis\Waddiwasi\WebAssembly\Structure\Instructions\Instr; +use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\GlobalType; + +final readonly class Global_ +{ + /** + * @param list<Instr> $init + */ + public function __construct( + public GlobalType $type, + public array $init, + ) { + } +} diff --git a/src/WebAssembly/Structure/Modules/Import.php b/src/WebAssembly/Structure/Modules/Import.php new file mode 100644 index 0000000..e764fcb --- /dev/null +++ b/src/WebAssembly/Structure/Modules/Import.php @@ -0,0 +1,19 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules; + +final readonly class Import +{ + /** + * @param Name $module + * @param Name $name + */ + public function __construct( + public string $module, + public string $name, + public ImportDesc $desc, + ) { + } +} diff --git a/src/WebAssembly/Structure/Modules/ImportDesc.php b/src/WebAssembly/Structure/Modules/ImportDesc.php new file mode 100644 index 0000000..240ad2b --- /dev/null +++ b/src/WebAssembly/Structure/Modules/ImportDesc.php @@ -0,0 +1,32 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules; + +use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\GlobalType; +use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\MemType; +use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\TableType; + +abstract readonly class ImportDesc +{ + final public static function Func(int $func): ImportDescs\Func + { + return new ImportDescs\Func($func); + } + + final public static function Table(TableType $table): ImportDescs\Table + { + return new ImportDescs\Table($table); + } + + final public static function Mem(MemType $mem): ImportDescs\Mem + { + return new ImportDescs\Mem($mem); + } + + final public static function Global(GlobalType $global): ImportDescs\Global_ + { + return new ImportDescs\Global_($global); + } +} diff --git a/src/WebAssembly/Structure/Modules/ImportDescs/Func.php b/src/WebAssembly/Structure/Modules/ImportDescs/Func.php new file mode 100644 index 0000000..4b5da18 --- /dev/null +++ b/src/WebAssembly/Structure/Modules/ImportDescs/Func.php @@ -0,0 +1,15 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\ImportDescs; + +use Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\ImportDesc; + +final readonly class Func extends ImportDesc +{ + protected function __construct( + public int $func, + ) { + } +} diff --git a/src/WebAssembly/Structure/Modules/ImportDescs/Global_.php b/src/WebAssembly/Structure/Modules/ImportDescs/Global_.php new file mode 100644 index 0000000..bab51b9 --- /dev/null +++ b/src/WebAssembly/Structure/Modules/ImportDescs/Global_.php @@ -0,0 +1,16 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\ImportDescs; + +use Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\ImportDesc; +use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\GlobalType; + +final readonly class Global_ extends ImportDesc +{ + protected function __construct( + public GlobalType $global, + ) { + } +} diff --git a/src/WebAssembly/Structure/Modules/ImportDescs/Mem.php b/src/WebAssembly/Structure/Modules/ImportDescs/Mem.php new file mode 100644 index 0000000..934d1c9 --- /dev/null +++ b/src/WebAssembly/Structure/Modules/ImportDescs/Mem.php @@ -0,0 +1,16 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\ImportDescs; + +use Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\ImportDesc; +use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\MemType; + +final readonly class Mem extends ImportDesc +{ + protected function __construct( + public MemType $mem, + ) { + } +} diff --git a/src/WebAssembly/Structure/Modules/ImportDescs/Table.php b/src/WebAssembly/Structure/Modules/ImportDescs/Table.php new file mode 100644 index 0000000..f8b2fa3 --- /dev/null +++ b/src/WebAssembly/Structure/Modules/ImportDescs/Table.php @@ -0,0 +1,16 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\ImportDescs; + +use Nsfisis\Waddiwasi\WebAssembly\Structure\Modules\ImportDesc; +use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\TableType; + +final readonly class Table extends ImportDesc +{ + protected function __construct( + public TableType $table, + ) { + } +} diff --git a/src/WebAssembly/Structure/Modules/Local.php b/src/WebAssembly/Structure/Modules/Local.php new file mode 100644 index 0000000..699d7a3 --- /dev/null +++ b/src/WebAssembly/Structure/Modules/Local.php @@ -0,0 +1,15 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules; + +use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\ValType; + +final readonly class Local +{ + public function __construct( + public ValType $type, + ) { + } +} diff --git a/src/WebAssembly/Structure/Modules/Mem.php b/src/WebAssembly/Structure/Modules/Mem.php new file mode 100644 index 0000000..45f0066 --- /dev/null +++ b/src/WebAssembly/Structure/Modules/Mem.php @@ -0,0 +1,15 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules; + +use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\MemType; + +final readonly class Mem +{ + public function __construct( + public MemType $type, + ) { + } +} diff --git a/src/WebAssembly/Structure/Modules/Module.php b/src/WebAssembly/Structure/Modules/Module.php new file mode 100644 index 0000000..a6ce2c8 --- /dev/null +++ b/src/WebAssembly/Structure/Modules/Module.php @@ -0,0 +1,35 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules; + +use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\FuncType; + +final readonly class Module +{ + /** + * @param list<FuncType> $types + * @param list<Func> $funcs + * @param list<Table> $tables + * @param list<Mem> $mems + * @param list<Global_> $globals + * @param list<Elem> $elems + * @param list<Data> $datas + * @param list<Import> $imports + * @param list<Export> $exports + */ + public function __construct( + public array $types, + public array $funcs, + public array $tables, + public array $mems, + public array $globals, + public array $elems, + public array $datas, + public ?Start $start, + public array $imports, + public array $exports, + ) { + } +} diff --git a/src/WebAssembly/Structure/Modules/Start.php b/src/WebAssembly/Structure/Modules/Start.php new file mode 100644 index 0000000..6659929 --- /dev/null +++ b/src/WebAssembly/Structure/Modules/Start.php @@ -0,0 +1,13 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules; + +final readonly class Start +{ + public function __construct( + public int $func, + ) { + } +} diff --git a/src/WebAssembly/Structure/Modules/Table.php b/src/WebAssembly/Structure/Modules/Table.php new file mode 100644 index 0000000..f0125a2 --- /dev/null +++ b/src/WebAssembly/Structure/Modules/Table.php @@ -0,0 +1,15 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Waddiwasi\WebAssembly\Structure\Modules; + +use Nsfisis\Waddiwasi\WebAssembly\Structure\Types\TableType; + +final readonly class Table +{ + public function __construct( + public TableType $type, + ) { + } +} |
