From fced21bb27dd422cc488648bd112dad7bd67158f Mon Sep 17 00:00:00 2001 From: Virgil Date: Fri, 17 Jan 2025 20:34:47 +0200 Subject: [PATCH 1/7] Refactored Instruction parsing --- .github/workflows/test-pr.yml | 2 + Makefile | 15 +- pykwasm/pyproject.toml | 1 + .../wasm-semantics/binary-parser-test.md | 37 +- .../kdist/wasm-semantics/binary-parser.md | 29 + .../wasm-semantics/binary-parsing/block.md | 74 + .../wasm-semantics/binary-parsing/bytes.md | 34 + .../binary-parsing/code-section.md | 26 + .../wasm-semantics/binary-parsing/code.md | 43 + .../wasm-semantics/binary-parsing/defn.md | 9 +- .../wasm-semantics/binary-parsing/float.md | 34 + .../binary-parsing/func-section-entry.md | 30 + .../binary-parsing/func-section.md | 27 + .../wasm-semantics/binary-parsing/func.md | 24 + .../wasm-semantics/binary-parsing/functype.md | 22 +- .../wasm-semantics/binary-parsing/helpers.md | 130 + .../kdist/wasm-semantics/binary-parsing/if.md | 38 + .../binary-parsing/import-section.md | 17 +- .../wasm-semantics/binary-parsing/import.md | 29 +- .../binary-parsing/instr-list.md | 51 + .../wasm-semantics/binary-parsing/instr.md | 2664 +++++++++++++++++ .../wasm-semantics/binary-parsing/int.md | 91 +- .../wasm-semantics/binary-parsing/locals.md | 72 + .../wasm-semantics/binary-parsing/loop.md | 18 + .../wasm-semantics/binary-parsing/memarg.md | 30 + .../wasm-semantics/binary-parsing/module.md | 127 +- .../binary-parsing/resulttype.md | 12 +- .../wasm-semantics/binary-parsing/section.md | 43 +- .../binary-parsing/type-section.md | 17 +- .../wasm-semantics/binary-parsing/valtype.md | 48 +- .../src/pykwasm/kdist/wasm-semantics/data.md | 10 + .../src/pykwasm/scripts/binary-parser-gen.py | 978 ++++++ tests/binary-parsing/code-block.wast | 11 + tests/binary-parsing/code-block.wast.out | 65 + tests/binary-parsing/code-call-indirect.wast | 7 + .../code-call-parametric-drop.wast | 11 + .../code-call-parametric-drop.wast.out | 65 + .../code-control-instructions.wast | 15 + .../code-control-instructions.wast.out | 65 + tests/binary-parsing/code-empty-function.wast | 7 + .../code-empty-function.wast.out | 65 + tests/binary-parsing/code-loop-if.wast | 16 + tests/binary-parsing/code-loop-if.wast.out | 65 + tests/binary-parsing/code-loop.wast | 10 + tests/binary-parsing/code-loop.wast.out | 65 + tests/binary-parsing/code-memory.wast | 137 + .../code-numeric-convert-reinterpret.wast | 24 + .../binary-parsing/code-numeric-convert.wast | 124 + .../code-numeric-convert.wast.out | 65 + tests/binary-parsing/code-numeric-f32.wast | 132 + .../binary-parsing/code-numeric-f32.wast.out | 65 + tests/binary-parsing/code-numeric-f64.wast | 132 + .../binary-parsing/code-numeric-f64.wast.out | 65 + .../code-numeric-float-parsing.md | 14 + tests/binary-parsing/code-numeric-i32.wast | 149 + .../binary-parsing/code-numeric-i32.wast.out | 65 + tests/binary-parsing/code-numeric-i64.wast | 149 + .../binary-parsing/code-numeric-i64.wast.out | 65 + tests/binary-parsing/code-reference-func.wast | 14 + tests/binary-parsing/code-reference.wast | 14 + tests/binary-parsing/code-reference.wast.out | 65 + tests/binary-parsing/code-table.wast | 40 + .../binary-parsing/code-variable-global.wast | 9 + tests/binary-parsing/code-variable.wast | 13 + tests/binary-parsing/code-variable.wast.out | 65 + tests/binary-parsing/code.wast | 12 + tests/binary-parsing/code.wast.out | 65 + tests/binary-parsing/codes.wast | 12 + tests/binary-parsing/codes.wast.out | 65 + tests/binary-parsing/failing | 7 + 70 files changed, 6698 insertions(+), 118 deletions(-) create mode 100644 pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/block.md create mode 100644 pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/bytes.md create mode 100644 pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/code-section.md create mode 100644 pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/code.md create mode 100644 pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/float.md create mode 100644 pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/func-section-entry.md create mode 100644 pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/func-section.md create mode 100644 pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/func.md create mode 100644 pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/helpers.md create mode 100644 pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/if.md create mode 100644 pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/instr-list.md create mode 100644 pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/instr.md create mode 100644 pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/locals.md create mode 100644 pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/loop.md create mode 100644 pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/memarg.md create mode 100644 pykwasm/src/pykwasm/scripts/binary-parser-gen.py create mode 100644 tests/binary-parsing/code-block.wast create mode 100644 tests/binary-parsing/code-block.wast.out create mode 100644 tests/binary-parsing/code-call-indirect.wast create mode 100644 tests/binary-parsing/code-call-parametric-drop.wast create mode 100644 tests/binary-parsing/code-call-parametric-drop.wast.out create mode 100644 tests/binary-parsing/code-control-instructions.wast create mode 100644 tests/binary-parsing/code-control-instructions.wast.out create mode 100644 tests/binary-parsing/code-empty-function.wast create mode 100644 tests/binary-parsing/code-empty-function.wast.out create mode 100644 tests/binary-parsing/code-loop-if.wast create mode 100644 tests/binary-parsing/code-loop-if.wast.out create mode 100644 tests/binary-parsing/code-loop.wast create mode 100644 tests/binary-parsing/code-loop.wast.out create mode 100644 tests/binary-parsing/code-memory.wast create mode 100644 tests/binary-parsing/code-numeric-convert-reinterpret.wast create mode 100644 tests/binary-parsing/code-numeric-convert.wast create mode 100644 tests/binary-parsing/code-numeric-convert.wast.out create mode 100644 tests/binary-parsing/code-numeric-f32.wast create mode 100644 tests/binary-parsing/code-numeric-f32.wast.out create mode 100644 tests/binary-parsing/code-numeric-f64.wast create mode 100644 tests/binary-parsing/code-numeric-f64.wast.out create mode 100644 tests/binary-parsing/code-numeric-float-parsing.md create mode 100644 tests/binary-parsing/code-numeric-i32.wast create mode 100644 tests/binary-parsing/code-numeric-i32.wast.out create mode 100644 tests/binary-parsing/code-numeric-i64.wast create mode 100644 tests/binary-parsing/code-numeric-i64.wast.out create mode 100644 tests/binary-parsing/code-reference-func.wast create mode 100644 tests/binary-parsing/code-reference.wast create mode 100644 tests/binary-parsing/code-reference.wast.out create mode 100644 tests/binary-parsing/code-table.wast create mode 100644 tests/binary-parsing/code-variable-global.wast create mode 100644 tests/binary-parsing/code-variable.wast create mode 100644 tests/binary-parsing/code-variable.wast.out create mode 100644 tests/binary-parsing/code.wast create mode 100644 tests/binary-parsing/code.wast.out create mode 100644 tests/binary-parsing/codes.wast create mode 100644 tests/binary-parsing/codes.wast.out diff --git a/.github/workflows/test-pr.yml b/.github/workflows/test-pr.yml index 34412c17f..e444922dc 100644 --- a/.github/workflows/test-pr.yml +++ b/.github/workflows/test-pr.yml @@ -29,6 +29,8 @@ jobs: run: make -C pykwasm cov-unit - name: 'Run Rust unit-tests' run: make rust-tests + - name: 'Generated code did not change' + run: make generate-code && git status --porcelain=v1 2>/dev/null conformance-tests: name: 'Conformance Tests' diff --git a/Makefile b/Makefile index 60435f955..a9d6c4404 100644 --- a/Makefile +++ b/Makefile @@ -20,25 +20,30 @@ endif pykwasm: $(POETRY) install +.PHONY: generate-code +generate-code: pykwasm + $(POETRY_RUN) binary-parser-gen > pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/instr.md + .PHONY: build build-simple build-prove build-wrc20 build-binary-parser-test -build: pykwasm +build: pykwasm generate-code $(KDIST) -v build -j3 -build-simple: pykwasm +build-simple: pykwasm generate-code $(KDIST) -v build wasm-semantics.llvm -j3 -build-prove: pykwasm +build-prove: pykwasm generate-code $(KDIST) -v build wasm-semantics.kwasm-lemmas -j3 -build-wrc20: pykwasm +build-wrc20: pykwasm generate-code $(KDIST) -v build wasm-semantics.wrc20 -j3 -build-binary-parser-test: pykwasm +build-binary-parser-test: pykwasm generate-code $(KDIST) -v build wasm-semantics.binary-parser-test -j3 .PHONY: clean clean: pykwasm $(KDIST) clean + rm build -rf # Building ULM-integrated Definition diff --git a/pykwasm/pyproject.toml b/pykwasm/pyproject.toml index 47d044237..44b73652c 100644 --- a/pykwasm/pyproject.toml +++ b/pykwasm/pyproject.toml @@ -21,6 +21,7 @@ wasm2kast = "pykwasm.wasm2kast:main" kwasm = "pykwasm.scripts.kwasm:main" kwasm-convert = "pykwasm.scripts.convert:main" kwasm-preprocess = "pykwasm.scripts.preprocessor:main" +binary-parser-gen = "pykwasm.scripts.binary-parser-gen:main" [tool.poetry.plugins.kdist] wasm-semantics = "pykwasm.kdist.plugin" diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parser-test.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parser-test.md index 369fb800b..a8947a06f 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parser-test.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parser-test.md @@ -22,11 +22,46 @@ module BINARY-PARSER-TEST rule parseBinary(B:Bytes) => parseModule(B) + rule addDefnToModule + ( false => true + , _D:GlobalDefn + , #module(... metadata: _ => #meta (... id: , funcIds: .Map , filename: "error: test addDefnToModule(GlobalDefn) branch called." ))) + [owise] + rule addDefnToModule + ( false => true + , _D:TableDefn + , #module(... metadata: _ => #meta (... id: , funcIds: .Map , filename: "error: test addDefnToModule(TableDefn) branch called." ))) + [owise] + rule addDefnToModule + ( false => true + , _D:MemoryDefn + , #module(... metadata: _ => #meta (... id: , funcIds: .Map , filename: "error: test addDefnToModule(MemoryDefn) branch called." ))) + [owise] + rule addDefnToModule + ( false => true + , _D:ElemDefn + , #module(... metadata: _ => #meta (... id: , funcIds: .Map , filename: "error: test addDefnToModule(ElemDefn) branch called." ))) + [owise] + rule addDefnToModule + ( false => true + , _D:DataDefn + , #module(... metadata: _ => #meta (... id: , funcIds: .Map , filename: "error: test addDefnToModule(DataDefn) branch called." ))) + [owise] + rule addDefnToModule + ( false => true + , _D:StartDefn + , #module(... metadata: _ => #meta (... id: , funcIds: .Map , filename: "error: test addDefnToModule(StartDefn) branch called." ))) + [owise] + rule addDefnToModule + ( false => true + , _D:ExportDefn + , #module(... metadata: _ => #meta (... id: , funcIds: .Map , filename: "error: test addDefnToModule(ExportDefn) branch called." ))) + [owise] rule addDefnToModule ( false => true , _D:Defn , #module(... metadata: _ => #meta (... id: , funcIds: .Map , filename: "error: test addDefnToModule branch called." ))) - [owise] + [priority(250)] endmodule ``` diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parser.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parser.md index 1ab04bfd5..974d69d52 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parser.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parser.md @@ -6,14 +6,28 @@ This file defines a Wasm binary parser based on this ```k requires "binary-parsing/base.md" +requires "binary-parsing/block.md" +requires "binary-parsing/bytes.md" +requires "binary-parsing/code.md" +requires "binary-parsing/code-section.md" requires "binary-parsing/constant.md" requires "binary-parsing/defn.md" +requires "binary-parsing/float.md" +requires "binary-parsing/func-section.md" +requires "binary-parsing/func-section-entry.md" requires "binary-parsing/functype.md" requires "binary-parsing/globaltype.md" +requires "binary-parsing/helpers.md" +requires "binary-parsing/if.md" requires "binary-parsing/import.md" requires "binary-parsing/import-section.md" +requires "binary-parsing/instr.md" +requires "binary-parsing/instr-list.md" requires "binary-parsing/int.md" requires "binary-parsing/limits.md" +requires "binary-parsing/locals.md" +requires "binary-parsing/loop.md" +requires "binary-parsing/memarg.md" requires "binary-parsing/module.md" requires "binary-parsing/name.md" requires "binary-parsing/resulttype.md" @@ -22,6 +36,7 @@ requires "binary-parsing/tags.md" requires "binary-parsing/type-section.md" requires "binary-parsing/valtype.md" + module BINARY-PARSER-SYNTAX imports BINARY-PARSER-BASE-SYNTAX imports WASM @@ -33,13 +48,27 @@ endmodule module BINARY-PARSER [private] imports BINARY-PARSER-MODULE-SYNTAX + imports BINARY-PARSER-BLOCK + imports BINARY-PARSER-BYTES + imports BINARY-PARSER-CODE + imports BINARY-PARSER-CODE-SECTION imports BINARY-PARSER-CONSTANT + imports BINARY-PARSER-FLOAT + imports BINARY-PARSER-FUNC-SECTION + imports BINARY-PARSER-FUNC-SECTION-ENTRY imports BINARY-PARSER-FUNCTYPE imports BINARY-PARSER-GLOBALTYPE + imports BINARY-PARSER-HELPERS + imports BINARY-PARSER-IF imports BINARY-PARSER-IMPORT imports BINARY-PARSER-IMPORT-SECTION + imports BINARY-PARSER-INSTR-LIST + imports BINARY-PARSER-INSTR imports BINARY-PARSER-INT imports BINARY-PARSER-LIMITS + imports BINARY-PARSER-LOCALS + imports BINARY-PARSER-LOOP + imports BINARY-PARSER-MEMARG imports BINARY-PARSER-MODULE imports BINARY-PARSER-NAME imports BINARY-PARSER-RESULTTYPE diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/block.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/block.md new file mode 100644 index 000000000..616191e7b --- /dev/null +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/block.md @@ -0,0 +1,74 @@ +Parsing [blocks](https://webassembly.github.io/spec/core/binary/instructions.html#control-instructions), +i.e., a blocktype + instr list. + +```k + +module BINARY-PARSER-BLOCK-SYNTAX + imports BINARY-PARSER-BASE-SYNTAX + imports BINARY-PARSER-INSTR-LIST-SYNTAX + imports WASM-COMMON-SYNTAX + imports WASM-DATA-COMMON + + syntax BlockType ::= "epsilon" | ValType | Int + syntax Block ::= block(BlockType, BinaryInstrs) + syntax BinaryInstr ::= Block + syntax BlockResult ::= blockResult(Block, endsWithElse: Bool, BytesWithIndex) | ParseError + + syntax BlockResult ::= parseBlock(BytesWithIndex) [function, total] + + syntax VecTypeOrError ::= VecType | ParseError + syntax VecTypeOrError ::= blockTypeToVecType(BlockType, Defns) [function, total] +endmodule + +module BINARY-PARSER-BLOCK [private] + imports BINARY-PARSER-BLOCK-SYNTAX + imports BINARY-PARSER-CONSTANT-SYNTAX + imports BINARY-PARSER-INSTR-LIST-SYNTAX + imports BINARY-PARSER-INT-SYNTAX + imports BINARY-PARSER-TAGS + imports BINARY-PARSER-VALTYPE-SYNTAX + + syntax BlockResult ::= #parseBlock1(BlockTypeResult) [function, total] + | #parseBlock2(BlockType, InstrListResult) [function, total] + rule parseBlock(BWI:BytesWithIndex) => #parseBlock1(parseBlockType(BWI)) + rule #parseBlock1(blockTypeResult(BT:BlockType, BWI:BytesWithIndex)) + => #parseBlock2(BT, parseInstrList(BWI)) + rule #parseBlock1(E:ParseError) => E + rule #parseBlock2(BT:BlockType, instrListResult(Is:BinaryInstrs, EndsWithElse:Bool, BWI:BytesWithIndex)) + => blockResult(block(BT, Is), EndsWithElse, BWI) + rule #parseBlock2(_:BlockType, E:ParseError) => E + + syntax BlockTypeResult ::= blockTypeResult(BlockType, BytesWithIndex) | ParseError + + syntax BlockTypeResult ::= parseBlockType(BytesWithIndex) [function, total] + | #parseBlockType1(BytesWithIndex, BytesWithIndexOrError) [function, total] + | #parseBlockType2(BytesWithIndex, ValTypeResult) [function, total] + | #parseBlockType3(IntResult) [function, total] + rule parseBlockType(BWI:BytesWithIndex) + => #parseBlockType1(BWI, parseConstant(BWI, TYPE_EMPTY)) + rule #parseBlockType1(_:BytesWithIndex, BWI:BytesWithIndex) + => blockTypeResult(epsilon, BWI:BytesWithIndex) + rule #parseBlockType1(BWI:BytesWithIndex, _:ParseError) + => #parseBlockType2(BWI, parseValType(BWI)) + rule #parseBlockType2(_:BytesWithIndex, valTypeResult(VT:ValType, BWI:BytesWithIndex)) + => blockTypeResult(VT, BWI) + rule #parseBlockType2(BWI:BytesWithIndex, _:ParseError) + => #parseBlockType3(parseLeb128SInt(BWI)) + rule #parseBlockType3(intResult(Value:Int, BWI:BytesWithIndex)) + => blockTypeResult(Value, BWI) + rule #parseBlockType3(E:ParseError) => E + + rule blockTypeToVecType(epsilon, _:Defns) => [ .ValTypes ] + rule blockTypeToVecType(ValType, _:Defns) => [ ValType .ValTypes ] + rule blockTypeToVecType(Index:Int, Ds::Defns) => parseError("blockTypeToVecType: unimplemented", ListItem(Index) ListItem(Ds)) + // rule blockTypeToVecType(Index:Int, .Defns) => parseError("blockTypeToVecType: not found", ListItem(Index)) + // rule blockTypeToVecType(0, #type(FT:FuncType, _:OptionalId) Ds:Defns) => [FT] + // rule blockTypeToVecType(0, D:Defn Ds:Defns) => parseError("blockTypeToVecType", ListItem(D) ListItem(Ds)) + // [owise] + // rule blockTypeToVecType(Index:Int, D:Defn Ds:Defns) => blockTypeToVecType(Index -Int 1, Ds) + // requires Index >Int 0 + // rule blockTypeToVecType(Index:Int, Ds:Defns) => parseError("blockTypeToVecType", ListItem(I) ListItem(Ds)) + // requires Index bytesResult + ( substrBytes(Buffer, Index, Index +Int Count) + , bwi(Buffer, Index +Int Count) + ) + requires Index +Int Count <=Int lengthBytes(Buffer) + rule parseBytes(bwi(Buffer:Bytes, Index:Int), Count:Int) + => parseError("parseBytes", ListItem(lengthBytes(Buffer)) ListItem(Index) ListItem(Count) ListItem(Buffer)) + [owise] + + rule ignoreBytes(BWI:BytesWithIndex, Count:Int) + => #ignoreBytes(parseBytes(BWI, Count)) + + syntax BytesWithIndexOrError ::= #ignoreBytes(BytesResult) [function, total] + rule #ignoreBytes(bytesResult(_:Bytes, BWI:BytesWithIndex)) => BWI + rule #ignoreBytes(E:ParseError) => E +endmodule + +``` diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/code-section.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/code-section.md new file mode 100644 index 000000000..cd8e66477 --- /dev/null +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/code-section.md @@ -0,0 +1,26 @@ +// Parsing a [code section](https://webassembly.github.io/spec/core/binary/modules.html#code-section). + +```k +module BINARY-PARSER-CODE-SECTION-SYNTAX + imports BINARY-PARSER-BASE-SYNTAX + + syntax SectionResult ::= parseCodeSection(BytesWithIndex) [function, total] + +endmodule + +module BINARY-PARSER-CODE-SECTION [private] + imports BINARY-PARSER-CODE-SECTION-SYNTAX + imports BINARY-PARSER-CODE-SYNTAX + imports BINARY-PARSER-INT-SYNTAX + imports BINARY-PARSER-SECTION-SYNTAX + + syntax SectionResult ::= #parseCodeSection(IntResult) [function, total] + rule parseCodeSection(BWI:BytesWithIndex) => #parseCodeSection(parseLeb128UInt(BWI)) + rule #parseCodeSection(intResult(Count:Int, BWI:BytesWithIndex)) + => parseSectionVector(defnCode, Count, .BinaryDefns, BWI) + rule #parseCodeSection(E:ParseError) => E + + syntax DefnKind ::= "defnCode" + rule parseDefn(defnCode, BWI:BytesWithIndex) => parseDefnCode(BWI) +endmodule +``` diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/code.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/code.md new file mode 100644 index 000000000..e375761a4 --- /dev/null +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/code.md @@ -0,0 +1,43 @@ +// Parsing a [code object](https://webassembly.github.io/spec/core/binary/modules.html#code-section). + +```k +module BINARY-PARSER-CODE-SYNTAX + imports BINARY-PARSER-BASE-SYNTAX + imports BINARY-PARSER-INSTR-LIST-SYNTAX + imports WASM + + syntax BinaryDefn ::= BinaryDefnFunctionBody + syntax BinaryDefnFunctionBody ::= binaryDefnFunctionBody(VecType, BinaryInstrs) + + syntax BinaryDefnFunctionBodies ::= List{BinaryDefnFunctionBody, ""} + + syntax DefnResult ::= parseDefnCode(BytesWithIndex) [function, total] +endmodule + +module BINARY-PARSER-CODE [private] + imports BINARY-PARSER-CODE-SYNTAX + imports BINARY-PARSER-INSTR-LIST-SYNTAX + imports BINARY-PARSER-INT-SYNTAX + imports BINARY-PARSER-LOCALS-SYNTAX + imports BINARY-PARSER-SECTION-SYNTAX + imports BINARY-PARSER-VALTYPE-SYNTAX + imports BOOL + + syntax DefnResult ::= #parseDefnCode(sizeInBytes:IntResult) [function, total] + | #parseDefnCode1(sizeInBytes:Int, LocalsVecResult) [function, total] + | #parseDefnCode2(sizeInBytes:Int, ValTypes, InstrListResult) [function, total] + rule parseDefnCode(BWI:BytesWithIndex) => #parseDefnCode(parseLeb128UInt(BWI)) + rule #parseDefnCode(intResult(Size:Int, BWI:BytesWithIndex)) + => #parseDefnCode1(Size, parseLocalsVec(BWI)) + rule #parseDefnCode(E:ParseError) => E + rule #parseDefnCode1(Size:Int, localsVecResult(Locals:LocalsVec, BWI:BytesWithIndex)) + => #parseDefnCode2(Size, localsVecToValTypes(Locals), parseInstrList(BWI)) + rule #parseDefnCode1(_, E:ParseError) => E + rule #parseDefnCode2(_Size:Int, Locals:ValTypes, instrListResult(Is:BinaryInstrs, false, BWI:BytesWithIndex)) + => defnResult(binaryDefnFunctionBody([ Locals ], Is), BWI) + rule #parseDefnCode2(_Size:Int, Locals:ValTypes, instrListResult(Is:BinaryInstrs, true, BWI:BytesWithIndex)) + => parseError("#parseDefnCode2", ListItem(Locals) ListItem(Is) ListItem(BWI)) + rule #parseDefnCode2(_, _, E:ParseError) => E + +endmodule +``` diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/defn.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/defn.md index 2ee50643d..c54c498d2 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/defn.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/defn.md @@ -3,6 +3,13 @@ module BINARY-PARSER-DEFN-SYNTAX imports BINARY-PARSER-BASE-SYNTAX imports WASM-COMMON-SYNTAX - syntax DefnResult ::= defnResult(Defn, BytesWithIndex) | ParseError + syntax BinaryDefn ::= Defn + syntax DefnResult ::= defnResult(BinaryDefn, BytesWithIndex) | ParseError + + syntax BinaryDefns ::= List{BinaryDefn, ""} + + syntax DefnOrError ::= Defn | ParseError + syntax DefnsOrError ::= Defns | ParseError + endmodule ``` diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/float.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/float.md new file mode 100644 index 000000000..98ff67ce7 --- /dev/null +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/float.md @@ -0,0 +1,34 @@ +// Parsing a [float](https://webassembly.github.io/spec/core/binary/values.html#floating-point). + +```k +module BINARY-PARSER-FLOAT-SYNTAX + imports BINARY-PARSER-BASE-SYNTAX + + syntax FloatResult ::= floatResult(Float, BytesWithIndex) | ParseError + + syntax FloatResult ::= parseFloat64(BytesWithIndex) [function, total] + syntax FloatResult ::= parseFloat32(BytesWithIndex) [function, total] + +endmodule + +module BINARY-PARSER-FLOAT [private] + imports BINARY-PARSER-BYTES-SYNTAX + imports BINARY-PARSER-FLOAT-SYNTAX + + syntax FloatResult ::= #parseFloat64(BytesResult) [function, total] + rule parseFloat64(BWI:BytesWithIndex) => #parseFloat64(parseBytes(BWI, 8)) + rule #parseFloat64(bytesResult(Bytes:Bytes, BWI:BytesWithIndex)) + => parseError("#parseFloat64: bytesToFloat is not implemented", ListItem(Bytes) ListItem(BWI)) // float(bytesToFloat(Bytes), BWI) + rule #parseFloat64(E:ParseError) => E + + syntax FloatResult ::= #parseFloat32(BytesResult) [function, total] + rule parseFloat32(BWI:BytesWithIndex) => #parseFloat32(parseBytes(BWI, 4)) + rule #parseFloat32(bytesResult(Bytes:Bytes, BWI:BytesWithIndex)) + => parseError("#parseFloat32: bytesToFloat is not implemented", ListItem(Bytes) ListItem(BWI)) // float(bytesToFloat(Bytes), BWI) + rule #parseFloat32(E:ParseError) => E + + // syntax Float ::= bytesToFloat(Bytes) [function, total] + // TODO: implement. + +endmodule +``` diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/func-section-entry.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/func-section-entry.md new file mode 100644 index 000000000..c7757e85f --- /dev/null +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/func-section-entry.md @@ -0,0 +1,30 @@ +Parsing a [function type idx](https://webassembly.github.io/spec/core/binary/types.html#binary-functype). + +```k +module BINARY-PARSER-FUNC-SECTION-ENTRY-SYNTAX + imports BINARY-PARSER-BASE-SYNTAX + imports BINARY-PARSER-DEFN-SYNTAX + + syntax BinaryDefnFunctionTypes ::= List{BinaryDefnFunctionType, ""} + + syntax BinaryDefnFunctionType ::= binaryDefnFunctionType(typeIndex: Int) + syntax BinaryDefn ::= BinaryDefnFunctionType + + syntax DefnResult ::= parseFuncSectionEntry(BytesWithIndex) [function, total] + +endmodule + +module BINARY-PARSER-FUNC-SECTION-ENTRY [private] + imports BINARY-PARSER-FUNC-SECTION-ENTRY-SYNTAX + imports BINARY-PARSER-INT-SYNTAX + + syntax DefnResult ::= #parseFuncSectionEntry(IntResult) [function, total] + + rule parseFuncSectionEntry(BWI:BytesWithIndex) + => #parseFuncSectionEntry(parseLeb128UInt(BWI)) + rule #parseFuncSectionEntry(intResult(TypeIndex:Int, BWI:BytesWithIndex)) + => defnResult(binaryDefnFunctionType(TypeIndex), BWI) + rule #parseFuncSectionEntry(E:ParseError) => E + +endmodule +``` diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/func-section.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/func-section.md new file mode 100644 index 000000000..02e98900b --- /dev/null +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/func-section.md @@ -0,0 +1,27 @@ +// Parsing a [func section](https://webassembly.github.io/spec/core/binary/modules.html#function-section). + +```k +module BINARY-PARSER-FUNC-SECTION-SYNTAX + imports BINARY-PARSER-BASE-SYNTAX + + syntax SectionResult ::= parseFuncSection(BytesWithIndex) [function, total] + +endmodule + +module BINARY-PARSER-FUNC-SECTION [private] + imports BINARY-PARSER-FUNC-SECTION-ENTRY-SYNTAX + imports BINARY-PARSER-FUNC-SECTION-SYNTAX + imports BINARY-PARSER-INT-SYNTAX + imports BINARY-PARSER-SECTION-SYNTAX + + syntax SectionResult ::= #parseFuncSection(IntResult) [function, total] + rule parseFuncSection(BWI:BytesWithIndex) => #parseFuncSection(parseLeb128UInt(BWI)) + rule #parseFuncSection(intResult(Count:Int, BWI:BytesWithIndex)) + => parseSectionVector(defnFunc, Count, .BinaryDefns, BWI) + rule #parseFuncSection(E:ParseError) => E + + syntax DefnKind ::= "defnFunc" + rule parseDefn(defnFunc, BWI:BytesWithIndex) => parseFuncSectionEntry(BWI) + +endmodule +``` diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/func.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/func.md new file mode 100644 index 000000000..d29427a86 --- /dev/null +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/func.md @@ -0,0 +1,24 @@ +// Parsing a [func type id](https://webassembly.github.io/spec/core/binary/modules.html#function-section). + +```k +module BINARY-PARSER-FUNC-SYNTAX + imports BINARY-PARSER-BASE-SYNTAX + + syntax DefnResult ::= parseDefnFunc(BytesWithIndex) [function, total] + +endmodule + +module BINARY-PARSER-FUNC [private] + imports BINARY-PARSER-DEFN-SYNTAX + imports BINARY-PARSER-FUNC-SYNTAX + imports BINARY-PARSER-INT-SYNTAX + + syntax DefnResult ::= #parseDefnFunc(IntResult) [function, total] + + rule parseDefnFunc(BWI:BytesWithIndex) => #parseDefnFunc(parseLeb128UInt(BWI)) + rule #parseDefnFunc(intResult(TypeIndex:Int, BWI:BytesWithIndex)) + => defnResult(binaryDefnFunctionType(TypeIndex), BWI) + rule #parseDefnFunc(E:ParseError) => E + +endmodule +``` diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/functype.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/functype.md index 1486becaa..d286138b9 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/functype.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/functype.md @@ -4,8 +4,12 @@ Parsing a [function type](https://webassembly.github.io/spec/core/binary/types.h module BINARY-PARSER-FUNCTYPE-SYNTAX imports BINARY-PARSER-BASE-SYNTAX imports BINARY-PARSER-DEFN-SYNTAX + imports WASM-DATA-COMMON - syntax DefnResult ::= parseFuncType(BytesWithIndex) [function, total] + syntax DefnResult ::= parseDefnType(BytesWithIndex) [function, total] + + syntax FuncTypeResult ::= funcTypeResult(FuncType, BytesWithIndex) | ParseError + syntax FuncTypeResult ::= parseFuncType(BytesWithIndex) [function, total] endmodule module BINARY-PARSER-FUNCTYPE [private] @@ -15,9 +19,17 @@ module BINARY-PARSER-FUNCTYPE [private] imports BINARY-PARSER-TAGS imports WASM - syntax DefnResult ::= #parseFuncType(BytesWithIndexOrError) [function, total] - | #parseFuncType1(ResultTypeResult) [function, total] - | #parseFuncType2(VecType, ResultTypeResult) [function, total] + syntax DefnResult ::= #parseDefnType(FuncTypeResult) [function, total] + + rule parseDefnType(BWI:BytesWithIndex) => #parseDefnType(parseFuncType(BWI)) + + rule #parseDefnType(funcTypeResult(F:FuncType, BWI:BytesWithIndex)) + => defnResult(#type(F, ), BWI) + rule #parseDefnType(E:ParseError) => E + + syntax FuncTypeResult ::= #parseFuncType(BytesWithIndexOrError) [function, total] + | #parseFuncType1(ResultTypeResult) [function, total] + | #parseFuncType2(VecType, ResultTypeResult) [function, total] rule parseFuncType(BWI:BytesWithIndex) => #parseFuncType(parseConstant(BWI, TYPE_FUN)) rule #parseFuncType(BWI:BytesWithIndex) => #parseFuncType1(parseResultType(BWI)) @@ -26,7 +38,7 @@ module BINARY-PARSER-FUNCTYPE [private] => #parseFuncType2(V, parseResultType(BWI)) rule #parseFuncType1(E:ParseError) => E rule #parseFuncType2(V1:VecType, resultTypeResult(V2:VecType, BWI:BytesWithIndex)) - => defnResult(#type(V1 -> V2, ), BWI:BytesWithIndex) + => funcTypeResult(V1 -> V2, BWI:BytesWithIndex) rule #parseFuncType2(_:VecType, E:ParseError) => E endmodule diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/helpers.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/helpers.md new file mode 100644 index 000000000..6cba0b4be --- /dev/null +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/helpers.md @@ -0,0 +1,130 @@ +Random functionality that does not fit elsewhere. + +```k +module BINARY-PARSER-HELPERS-SYNTAX + imports BINARY-PARSER-BASE-SYNTAX + imports BINARY-PARSER-CODE-SYNTAX + imports BINARY-PARSER-DEFN-SYNTAX + imports BINARY-PARSER-FUNC-SECTION-ENTRY-SYNTAX + imports WASM-DATA-COMMON + + syntax Instr ::= buildCallIndirect(typeIdx:Int, tabeIdx:Int) [function, total] + syntax Instr ::= buildBrTable(targets:Ints, defaultTarget:Int) [function, total] + + syntax DefnsOrError ::= buildFunctionDefns(Defns, BinaryDefnFunctionTypes, BinaryDefnFunctionBodies) [function, total] + +endmodule + +module BINARY-PARSER-HELPERS [private] + imports BINARY-PARSER-BLOCK-SYNTAX + imports BINARY-PARSER-HELPERS-SYNTAX + imports BINARY-PARSER-IF-SYNTAX + imports BINARY-PARSER-LOOP-SYNTAX + imports BINARY-PARSER-INSTR-LIST-SYNTAX + imports WASM + + rule buildCallIndirect(TypeIdx:Int, TableIdx:Int) => #call_indirect(TableIdx, (type TypeIdx)) + + rule buildBrTable(Is:Ints, I:Int) => #br_table(#appendInts(Is, I)) + + syntax DefnsOrError ::= #buildFunctionDefns1 + ( DefnOrError + , Defns + , BinaryDefnFunctionTypes + , BinaryDefnFunctionBodies + ) [function, total] + | #buildFunctionDefns2(Defn, DefnsOrError) [function, total] + rule buildFunctionDefns(_:Defns, .BinaryDefnFunctionTypes, .BinaryDefnFunctionBodies) + => .Defns + rule buildFunctionDefns + ( Ds:Defns + , FT:BinaryDefnFunctionType FTs:BinaryDefnFunctionTypes + , FB:BinaryDefnFunctionBody FBs:BinaryDefnFunctionBodies + ) + => #buildFunctionDefns1(buildFunctionDefn(Ds, FT, FB), Ds, FTs, FBs) + rule buildFunctionDefns(Ds:Defns, FTs:BinaryDefnFunctionTypes, FBs:BinaryDefnFunctionBodies) + => parseError("buildFunctionDefns", ListItem(Ds) ListItem(FTs) ListItem(FBs)) + [owise] + rule #buildFunctionDefns1 + ( D:Defn + , Ds:Defns + , FTs:BinaryDefnFunctionTypes + , FBs:BinaryDefnFunctionBodies + ) + => #buildFunctionDefns2(D, buildFunctionDefns(Ds, FTs, FBs)) + rule #buildFunctionDefns1 + ( E:ParseError + , _:Defns + , _:BinaryDefnFunctionTypes + , _:BinaryDefnFunctionBodies + ) + => E + rule #buildFunctionDefns2(D:Defn, Ds:Defns) => D Ds + rule #buildFunctionDefns2(_:Defn, E:ParseError) => E + + syntax DefnOrError ::= buildFunctionDefn + ( Defns + , BinaryDefnFunctionType + , BinaryDefnFunctionBody + ) [function, total] + | #buildFunctionDefn1 + ( BinaryDefnFunctionType + , locals: VecType + , InstrsOrError + ) [function, total] + + rule buildFunctionDefn + ( Ds:Defns + , FT:BinaryDefnFunctionType + , binaryDefnFunctionBody(Locals:VecType, Is:BinaryInstrs) + ) + => #buildFunctionDefn1(FT, Locals, binaryInstrsToInstrs(Ds, Is)) + rule #buildFunctionDefn1(binaryDefnFunctionType(TypeIndex:Int), Locals:VecType, Is:Instrs) + => #func(TypeIndex, Locals, Is, #meta(, .Map)) + rule #buildFunctionDefn1(_:BinaryDefnFunctionType, _Locals:VecType, E:ParseError) => E + + syntax InstrsOrError ::= binaryInstrsToInstrs(Defns, BinaryInstrs) [function, total] + | #binaryInstrsToInstrs(InstrOrError, InstrsOrError) [function, total] + rule binaryInstrsToInstrs(_:Defns, .BinaryInstrs) => .Instrs + rule binaryInstrsToInstrs(Ds:Defns, I:BinaryInstr Is:BinaryInstrs) + => #binaryInstrsToInstrs(binaryInstrToInstr(Ds, I), binaryInstrsToInstrs(Ds, Is)) + rule #binaryInstrsToInstrs(I:Instr, Is:Instrs) => I Is + rule #binaryInstrsToInstrs(E:ParseError, _:InstrsOrError) => E + rule #binaryInstrsToInstrs(_:Instr, E:ParseError) => E + + syntax InstrOrError ::= binaryInstrToInstr(Defns, BinaryInstr) [function, total] + rule binaryInstrToInstr(_Ds:Defns, I:Instr) => I + rule binaryInstrToInstr(Ds:Defns, B:Block) + => resolvedBlockToInstr(resolveBlock(Ds, B)) + rule binaryInstrToInstr(Ds:Defns, loop(B:Block)) + => resolvedBlockToLoop(resolveBlock(Ds, B)) + rule binaryInstrToInstr(Ds:Defns, if(B:Block, Is:BinaryInstrs)) + => resolvedBlockInstrsToIf(resolveBlock(Ds, B), binaryInstrsToInstrs(Ds, Is)) + + syntax VecTypeOrError ::= VecType | ParseError + + syntax ResolvedBlockOrError ::= resolvedBlock(VecType, Instrs) | ParseError + + syntax ResolvedBlockOrError ::= resolveBlock(Defns, Block) [function, total] + | #resolveBlock(VecTypeOrError, InstrsOrError) [function, total] + rule resolveBlock(Ds:Defns, block(T:BlockType, Is:BinaryInstrs)) + => #resolveBlock(blockTypeToVecType(T, Ds), binaryInstrsToInstrs(Ds, Is)) + rule #resolveBlock(T:VecType, Is:Instrs) => resolvedBlock(T, Is) + rule #resolveBlock(E:ParseError, _:InstrsOrError) => E + rule #resolveBlock(_:VecType, E:ParseError) => E + + syntax InstrOrError ::= resolvedBlockToInstr(ResolvedBlockOrError) [function, total] + rule resolvedBlockToInstr(resolvedBlock(T:VecType, Is:Instrs)) => #block(T, Is, .Int) + rule resolvedBlockToInstr(E:ParseError) => E + + syntax InstrOrError ::= resolvedBlockToLoop(ResolvedBlockOrError) [function, total] + rule resolvedBlockToLoop(resolvedBlock(T:VecType, Is:Instrs)) => #loop(T, Is, .Int) + rule resolvedBlockToLoop(E:ParseError) => E + + syntax InstrOrError ::= resolvedBlockInstrsToIf(ResolvedBlockOrError, InstrsOrError) [function, total] + rule resolvedBlockInstrsToIf(resolvedBlock(T:VecType, Then:Instrs), Else:Instrs) => #if(T, Then, Else, .Int) + rule resolvedBlockInstrsToIf(E:ParseError, _:InstrsOrError) => E + rule resolvedBlockInstrsToIf(_:ResolvedBlockOrError, E:ParseError) => E + [owise] +endmodule +``` diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/if.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/if.md new file mode 100644 index 000000000..271e376e8 --- /dev/null +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/if.md @@ -0,0 +1,38 @@ +Parsing [loops](https://webassembly.github.io/spec/core/binary/instructions.html#control-instructions), +i.e., a blocktype + instr list. + +```k + +module BINARY-PARSER-IF-SYNTAX + imports BINARY-PARSER-BASE-SYNTAX + imports BINARY-PARSER-BLOCK-SYNTAX + + syntax BinaryInstr ::= if(Block, BinaryInstrs) + + syntax InstrResult ::= parseIf(BytesWithIndex) [function, total] + +endmodule + +module BINARY-PARSER-IF [private] + imports BINARY-PARSER-CONSTANT-SYNTAX + imports BINARY-PARSER-IF-SYNTAX + imports BINARY-PARSER-TAGS + imports BOOL + + syntax InstrResult ::= #parseIf1(BlockResult) [function, total] + | #parseIfElse1(Block, InstrListResult) [function, total] + rule parseIf(BWI:BytesWithIndex) => #parseIf1(parseBlock(BWI)) + rule #parseIf1(blockResult(B:Block, true, BWI:BytesWithIndex)) + => #parseIfElse1(B, parseInstrList(BWI)) + rule #parseIf1(blockResult(B:Block, false, BWI:BytesWithIndex)) + => instrResult(if(B, .BinaryInstrs), BWI) + rule #parseIf1(E:ParseError) => E + + rule #parseIfElse1(Then:Block, instrListResult(Else:BinaryInstrs, false, BWI:BytesWithIndex)) + => instrResult(if(Then, Else), BWI) + rule #parseIfElse1(Then:Block, instrListResult(Else:BinaryInstrs, true, BWI:BytesWithIndex)) + => parseError("#parseIfElse1", ListItem(Then) ListItem(Else) ListItem(BWI)) + rule #parseIfElse1(_:Block, E:ParseError) => E + +endmodule +``` diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/import-section.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/import-section.md index 20440ef7f..7ceca623e 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/import-section.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/import-section.md @@ -18,22 +18,11 @@ module BINARY-PARSER-IMPORT-SECTION [private] syntax SectionResult ::= #parseImportSection(IntResult) [function, total] rule parseImportSection(BWI:BytesWithIndex) => #parseImportSection(parseLeb128UInt(BWI)) rule #parseImportSection(intResult(Count:Int, BWI:BytesWithIndex)) - => parseImportSectionVector(Count, .Defns, BWI) + => parseSectionVector(defnImport, Count, .BinaryDefns, BWI) rule #parseImportSection(E:ParseError) => E - syntax SectionResult ::= parseImportSectionVector(remainingCount:Int, Defns, BytesWithIndex) [function, total] - | #parseImportSectionVector(remainingCount:Int, Defns, DefnResult) [function, total] - rule parseImportSectionVector(0, D:Defns, BWI:BytesWithIndex) => sectionResult(defnsSection(D), BWI) - rule parseImportSectionVector(Count:Int, D:Defns, BWI:BytesWithIndex) - => #parseImportSectionVector(Count, D, parseImport(BWI)) - requires Count >Int 0 - rule parseImportSectionVector(Count:Int, D:Defns, bwi(B:Bytes, I:Int)) - => parseError("parseImportSectionVector", ListItem(Count) ListItem(D) ListItem(I) ListItem(lengthBytes(B)) ListItem(B)) - [owise] - rule #parseImportSectionVector(Count:Int, Ds:Defns, defnResult(D:Defn, BWI:BytesWithIndex)) - => parseImportSectionVector(Count -Int 1, D Ds, BWI) - rule #parseImportSectionVector(_Count:Int, _:Defns, E:ParseError) => E - + syntax DefnKind ::= "defnImport" + rule parseDefn(defnImport, BWI:BytesWithIndex) => parseDefnImport(BWI) endmodule ``` diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/import.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/import.md index 15a3512df..4ee5e33e0 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/import.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/import.md @@ -4,7 +4,7 @@ module BINARY-PARSER-IMPORT-SYNTAX imports BINARY-PARSER-BASE-SYNTAX - syntax DefnResult ::= parseImport(BytesWithIndex) [function, total] + syntax DefnResult ::= parseDefnImport(BytesWithIndex) [function, total] endmodule @@ -21,20 +21,19 @@ module BINARY-PARSER-IMPORT [private] imports BINARY-PARSER-VALTYPE-SYNTAX imports WASM - syntax DefnResult ::= #parseImport1(NameResult) [function, total] - | #parseImport2(WasmString, NameResult) [function, total] - | #parseImport3(WasmString, WasmString, ImportDescResult) [function, total] - - rule parseImport(BWI:BytesWithIndex) => #parseImport1(parseName(BWI)) - rule #parseImport1(nameResult(Name:WasmString, BWI:BytesWithIndex)) - => #parseImport2(Name, parseName(BWI)) - rule #parseImport1(E:ParseError) => E - rule #parseImport2(ModuleName:WasmString, nameResult(ObjectName:WasmString, BWI:BytesWithIndex)) - => #parseImport3(ModuleName, ObjectName, parseImportDesc(BWI)) - rule #parseImport2(_, E:ParseError) => E - rule #parseImport3(ModuleName:WasmString, ObjectName:WasmString, importDescResult(Desc:ImportDesc, BWI:BytesWithIndex)) - => defnResult(#import(ModuleName, ObjectName, Desc), BWI) - rule #parseImport3(_, _, E:ParseError) => E + syntax DefnResult ::= #parseDefnImport1(NameResult) [function, total] + | #parseDefnImport2(WasmString, NameResult) [function, total] + | #parseDefnImport3(WasmString, WasmString, ImportDescResult) [function, total] + rule parseDefnImport(BWI:BytesWithIndex) => #parseDefnImport1(parseName(BWI)) + rule #parseDefnImport1(nameResult(Name:WasmString, BWI:BytesWithIndex)) + => #parseDefnImport2(Name, parseName(BWI)) + rule #parseDefnImport1(E:ParseError) => E + rule #parseDefnImport2(ModuleName:WasmString, nameResult(ObjectName:WasmString, BWI:BytesWithIndex)) + => #parseDefnImport3(ModuleName, ObjectName, parseImportDesc(BWI)) + rule #parseDefnImport2(_, E:ParseError) => E + rule #parseDefnImport3(ModuleName:WasmString, ObjectName:WasmString, importDescResult(Desc:ImportDesc, BWI:BytesWithIndex)) + => defnResult(#import(ModuleName, ObjectName, Desc), BWI) + rule #parseDefnImport3(_, _, E:ParseError) => E syntax ImportDescResult ::= importDescResult(ImportDesc, BytesWithIndex) | ParseError diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/instr-list.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/instr-list.md new file mode 100644 index 000000000..71c8622a2 --- /dev/null +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/instr-list.md @@ -0,0 +1,51 @@ +// Parsing an [expr/instr list](https://webassembly.github.io/spec/core/binary/instructions.html#binary-expr). + +```k +module BINARY-PARSER-INSTR-LIST-SYNTAX + imports BINARY-PARSER-BASE-SYNTAX + imports BINARY-PARSER-INSTR-SYNTAX + imports WASM-COMMON-SYNTAX + + syntax BinaryInstrs ::= List{BinaryInstr, ""} + + syntax InstrListResult ::= instrListResult(BinaryInstrs, endsWithElse: Bool, BytesWithIndex) | ParseError + syntax InstrListResult ::= parseInstrList(BytesWithIndex) [function, total] + + syntax InstrsOrError ::= Instrs | ParseError +endmodule + +module BINARY-PARSER-INSTR-LIST [private] + imports BINARY-PARSER-CONSTANT-SYNTAX + imports BINARY-PARSER-INSTR-LIST-SYNTAX + imports BINARY-PARSER-TAGS + imports BOOL + + syntax InstrListResult ::= #parseInstrList1(BytesWithIndex, BinaryInstrs) [function, total] + | #parseInstrList2(BytesWithIndex, BytesWithIndexOrError, BinaryInstrs) [function, total] + | #parseInstrList3(BytesWithIndex, BytesWithIndexOrError, BinaryInstrs) [function, total] + | #parseInstrList4(InstrResult, BinaryInstrs) [function, total] + + rule parseInstrList(BWI:BytesWithIndex) => #parseInstrList1(BWI, .BinaryInstrs) + rule #parseInstrList1(BWI:BytesWithIndex, Is:BinaryInstrs) + => #parseInstrList2(BWI, parseConstant(BWI, END), Is) + rule #parseInstrList2(_:BytesWithIndex, BWI:BytesWithIndex, Is:BinaryInstrs) + => instrListResult(reverse(Is), false, BWI) + rule #parseInstrList2(BWI:BytesWithIndex, _:ParseError, Is:BinaryInstrs) + => #parseInstrList3(BWI, parseConstant(BWI, ELSE), Is) + rule #parseInstrList3(_:BytesWithIndex, BWI:BytesWithIndex, Is:BinaryInstrs) + => instrListResult(reverse(Is), true, BWI) + rule #parseInstrList3(BWI:BytesWithIndex, _:ParseError, Is:BinaryInstrs) + => #parseInstrList4(parseInstr(BWI), Is) + rule #parseInstrList4(instrResult(I:BinaryInstr, BWI:BytesWithIndex), Is:BinaryInstrs) + => #parseInstrList1(BWI, I Is) + rule #parseInstrList4(E:ParseError, _) => E + + + syntax BinaryInstrs ::= reverse(BinaryInstrs) [function, total] + | #reverse(BinaryInstrs, BinaryInstrs) [function, total] + + rule reverse(I:BinaryInstrs) => #reverse(I, .BinaryInstrs) + rule #reverse(.BinaryInstrs, Is:BinaryInstrs) => Is + rule #reverse(I:BinaryInstr I1:BinaryInstrs, I2:BinaryInstrs) => #reverse(I1, I I2) +endmodule +``` diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/instr.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/instr.md new file mode 100644 index 000000000..c52b0f71c --- /dev/null +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/instr.md @@ -0,0 +1,2664 @@ +This was generated by `binary-parser-gen.py`. Do not edit this file directly. + +```k +module BINARY-PARSER-INSTR-SYNTAX + imports BINARY-PARSER-BASE-SYNTAX + imports WASM-COMMON-SYNTAX + + syntax BinaryInstr ::= Instr + + syntax InstrResult ::= instrResult(BinaryInstr, BytesWithIndex) | ParseError + syntax InstrResult ::= parseInstr(BytesWithIndex) [function, total] + + syntax InstrOrError ::= Instr | ParseError +endmodule + +module BINARY-PARSER-INSTR + imports BINARY-PARSER-BLOCK-SYNTAX + imports BINARY-PARSER-BYTES-SYNTAX + imports BINARY-PARSER-CONSTANT-SYNTAX + imports BINARY-PARSER-FLOAT-SYNTAX + imports BINARY-PARSER-HELPERS-SYNTAX + imports BINARY-PARSER-IF-SYNTAX + imports BINARY-PARSER-INSTR-SYNTAX + imports BINARY-PARSER-INT-SYNTAX + imports BINARY-PARSER-LOOP-SYNTAX + imports BINARY-PARSER-MEMARG-SYNTAX + imports BINARY-PARSER-VALTYPE-SYNTAX + imports WASM + + + syntax InstrResult ::= #parseInstrp1(IntResult) [function, total] + | #parseInstrp2(Int, BytesWithIndex) [function, total] + rule parseInstr(BWI:BytesWithIndex) => #parseInstrp1(parseByteAsInt(BWI)) + rule #parseInstrp1(intResult(I:Int, BWI:BytesWithIndex)) => #parseInstrp2(I, BWI) + rule #parseInstrp1(E:ParseError) => E + rule #parseInstrp2(0, BWI:BytesWithIndex) => parseInstrx0(BWI) + rule #parseInstrp2(1, BWI:BytesWithIndex) => parseInstrx1(BWI) + rule #parseInstrp2(2, BWI:BytesWithIndex) => parseInstrx2(BWI) + rule #parseInstrp2(3, BWI:BytesWithIndex) => parseInstrx3(BWI) + rule #parseInstrp2(4, BWI:BytesWithIndex) => parseInstrx4(BWI) + rule #parseInstrp2(12, BWI:BytesWithIndex) => parseInstrx12(BWI) + rule #parseInstrp2(13, BWI:BytesWithIndex) => parseInstrx13(BWI) + rule #parseInstrp2(14, BWI:BytesWithIndex) => parseInstrx14(BWI) + rule #parseInstrp2(15, BWI:BytesWithIndex) => parseInstrx15(BWI) + rule #parseInstrp2(16, BWI:BytesWithIndex) => parseInstrx16(BWI) + rule #parseInstrp2(17, BWI:BytesWithIndex) => parseInstrx17(BWI) + rule #parseInstrp2(26, BWI:BytesWithIndex) => parseInstrx26(BWI) + rule #parseInstrp2(27, BWI:BytesWithIndex) => parseInstrx27(BWI) + rule #parseInstrp2(28, BWI:BytesWithIndex) => parseInstrx28(BWI) + rule #parseInstrp2(32, BWI:BytesWithIndex) => parseInstrx32(BWI) + rule #parseInstrp2(33, BWI:BytesWithIndex) => parseInstrx33(BWI) + rule #parseInstrp2(34, BWI:BytesWithIndex) => parseInstrx34(BWI) + rule #parseInstrp2(35, BWI:BytesWithIndex) => parseInstrx35(BWI) + rule #parseInstrp2(36, BWI:BytesWithIndex) => parseInstrx36(BWI) + rule #parseInstrp2(37, BWI:BytesWithIndex) => parseInstrx37(BWI) + rule #parseInstrp2(38, BWI:BytesWithIndex) => parseInstrx38(BWI) + rule #parseInstrp2(40, BWI:BytesWithIndex) => parseInstrx40(BWI) + rule #parseInstrp2(41, BWI:BytesWithIndex) => parseInstrx41(BWI) + rule #parseInstrp2(42, BWI:BytesWithIndex) => parseInstrx42(BWI) + rule #parseInstrp2(43, BWI:BytesWithIndex) => parseInstrx43(BWI) + rule #parseInstrp2(44, BWI:BytesWithIndex) => parseInstrx44(BWI) + rule #parseInstrp2(45, BWI:BytesWithIndex) => parseInstrx45(BWI) + rule #parseInstrp2(46, BWI:BytesWithIndex) => parseInstrx46(BWI) + rule #parseInstrp2(47, BWI:BytesWithIndex) => parseInstrx47(BWI) + rule #parseInstrp2(48, BWI:BytesWithIndex) => parseInstrx48(BWI) + rule #parseInstrp2(49, BWI:BytesWithIndex) => parseInstrx49(BWI) + rule #parseInstrp2(50, BWI:BytesWithIndex) => parseInstrx50(BWI) + rule #parseInstrp2(51, BWI:BytesWithIndex) => parseInstrx51(BWI) + rule #parseInstrp2(52, BWI:BytesWithIndex) => parseInstrx52(BWI) + rule #parseInstrp2(53, BWI:BytesWithIndex) => parseInstrx53(BWI) + rule #parseInstrp2(54, BWI:BytesWithIndex) => parseInstrx54(BWI) + rule #parseInstrp2(55, BWI:BytesWithIndex) => parseInstrx55(BWI) + rule #parseInstrp2(56, BWI:BytesWithIndex) => parseInstrx56(BWI) + rule #parseInstrp2(57, BWI:BytesWithIndex) => parseInstrx57(BWI) + rule #parseInstrp2(58, BWI:BytesWithIndex) => parseInstrx58(BWI) + rule #parseInstrp2(59, BWI:BytesWithIndex) => parseInstrx59(BWI) + rule #parseInstrp2(60, BWI:BytesWithIndex) => parseInstrx60(BWI) + rule #parseInstrp2(61, BWI:BytesWithIndex) => parseInstrx61(BWI) + rule #parseInstrp2(62, BWI:BytesWithIndex) => parseInstrx62(BWI) + rule #parseInstrp2(63, BWI:BytesWithIndex) => parseInstrx63(BWI) + rule #parseInstrp2(64, BWI:BytesWithIndex) => parseInstrx64(BWI) + rule #parseInstrp2(65, BWI:BytesWithIndex) => parseInstrx65(BWI) + rule #parseInstrp2(66, BWI:BytesWithIndex) => parseInstrx66(BWI) + rule #parseInstrp2(67, BWI:BytesWithIndex) => parseInstrx67(BWI) + rule #parseInstrp2(68, BWI:BytesWithIndex) => parseInstrx68(BWI) + rule #parseInstrp2(69, BWI:BytesWithIndex) => parseInstrx69(BWI) + rule #parseInstrp2(70, BWI:BytesWithIndex) => parseInstrx70(BWI) + rule #parseInstrp2(71, BWI:BytesWithIndex) => parseInstrx71(BWI) + rule #parseInstrp2(72, BWI:BytesWithIndex) => parseInstrx72(BWI) + rule #parseInstrp2(73, BWI:BytesWithIndex) => parseInstrx73(BWI) + rule #parseInstrp2(74, BWI:BytesWithIndex) => parseInstrx74(BWI) + rule #parseInstrp2(75, BWI:BytesWithIndex) => parseInstrx75(BWI) + rule #parseInstrp2(76, BWI:BytesWithIndex) => parseInstrx76(BWI) + rule #parseInstrp2(77, BWI:BytesWithIndex) => parseInstrx77(BWI) + rule #parseInstrp2(78, BWI:BytesWithIndex) => parseInstrx78(BWI) + rule #parseInstrp2(79, BWI:BytesWithIndex) => parseInstrx79(BWI) + rule #parseInstrp2(80, BWI:BytesWithIndex) => parseInstrx80(BWI) + rule #parseInstrp2(81, BWI:BytesWithIndex) => parseInstrx81(BWI) + rule #parseInstrp2(82, BWI:BytesWithIndex) => parseInstrx82(BWI) + rule #parseInstrp2(83, BWI:BytesWithIndex) => parseInstrx83(BWI) + rule #parseInstrp2(84, BWI:BytesWithIndex) => parseInstrx84(BWI) + rule #parseInstrp2(85, BWI:BytesWithIndex) => parseInstrx85(BWI) + rule #parseInstrp2(86, BWI:BytesWithIndex) => parseInstrx86(BWI) + rule #parseInstrp2(87, BWI:BytesWithIndex) => parseInstrx87(BWI) + rule #parseInstrp2(88, BWI:BytesWithIndex) => parseInstrx88(BWI) + rule #parseInstrp2(89, BWI:BytesWithIndex) => parseInstrx89(BWI) + rule #parseInstrp2(90, BWI:BytesWithIndex) => parseInstrx90(BWI) + rule #parseInstrp2(91, BWI:BytesWithIndex) => parseInstrx91(BWI) + rule #parseInstrp2(92, BWI:BytesWithIndex) => parseInstrx92(BWI) + rule #parseInstrp2(93, BWI:BytesWithIndex) => parseInstrx93(BWI) + rule #parseInstrp2(94, BWI:BytesWithIndex) => parseInstrx94(BWI) + rule #parseInstrp2(95, BWI:BytesWithIndex) => parseInstrx95(BWI) + rule #parseInstrp2(96, BWI:BytesWithIndex) => parseInstrx96(BWI) + rule #parseInstrp2(97, BWI:BytesWithIndex) => parseInstrx97(BWI) + rule #parseInstrp2(98, BWI:BytesWithIndex) => parseInstrx98(BWI) + rule #parseInstrp2(99, BWI:BytesWithIndex) => parseInstrx99(BWI) + rule #parseInstrp2(100, BWI:BytesWithIndex) => parseInstrx100(BWI) + rule #parseInstrp2(101, BWI:BytesWithIndex) => parseInstrx101(BWI) + rule #parseInstrp2(102, BWI:BytesWithIndex) => parseInstrx102(BWI) + rule #parseInstrp2(103, BWI:BytesWithIndex) => parseInstrx103(BWI) + rule #parseInstrp2(104, BWI:BytesWithIndex) => parseInstrx104(BWI) + rule #parseInstrp2(105, BWI:BytesWithIndex) => parseInstrx105(BWI) + rule #parseInstrp2(106, BWI:BytesWithIndex) => parseInstrx106(BWI) + rule #parseInstrp2(107, BWI:BytesWithIndex) => parseInstrx107(BWI) + rule #parseInstrp2(108, BWI:BytesWithIndex) => parseInstrx108(BWI) + rule #parseInstrp2(109, BWI:BytesWithIndex) => parseInstrx109(BWI) + rule #parseInstrp2(110, BWI:BytesWithIndex) => parseInstrx110(BWI) + rule #parseInstrp2(111, BWI:BytesWithIndex) => parseInstrx111(BWI) + rule #parseInstrp2(112, BWI:BytesWithIndex) => parseInstrx112(BWI) + rule #parseInstrp2(113, BWI:BytesWithIndex) => parseInstrx113(BWI) + rule #parseInstrp2(114, BWI:BytesWithIndex) => parseInstrx114(BWI) + rule #parseInstrp2(115, BWI:BytesWithIndex) => parseInstrx115(BWI) + rule #parseInstrp2(116, BWI:BytesWithIndex) => parseInstrx116(BWI) + rule #parseInstrp2(117, BWI:BytesWithIndex) => parseInstrx117(BWI) + rule #parseInstrp2(118, BWI:BytesWithIndex) => parseInstrx118(BWI) + rule #parseInstrp2(119, BWI:BytesWithIndex) => parseInstrx119(BWI) + rule #parseInstrp2(120, BWI:BytesWithIndex) => parseInstrx120(BWI) + rule #parseInstrp2(121, BWI:BytesWithIndex) => parseInstrx121(BWI) + rule #parseInstrp2(122, BWI:BytesWithIndex) => parseInstrx122(BWI) + rule #parseInstrp2(123, BWI:BytesWithIndex) => parseInstrx123(BWI) + rule #parseInstrp2(124, BWI:BytesWithIndex) => parseInstrx124(BWI) + rule #parseInstrp2(125, BWI:BytesWithIndex) => parseInstrx125(BWI) + rule #parseInstrp2(126, BWI:BytesWithIndex) => parseInstrx126(BWI) + rule #parseInstrp2(127, BWI:BytesWithIndex) => parseInstrx127(BWI) + rule #parseInstrp2(128, BWI:BytesWithIndex) => parseInstrx128(BWI) + rule #parseInstrp2(129, BWI:BytesWithIndex) => parseInstrx129(BWI) + rule #parseInstrp2(130, BWI:BytesWithIndex) => parseInstrx130(BWI) + rule #parseInstrp2(131, BWI:BytesWithIndex) => parseInstrx131(BWI) + rule #parseInstrp2(132, BWI:BytesWithIndex) => parseInstrx132(BWI) + rule #parseInstrp2(133, BWI:BytesWithIndex) => parseInstrx133(BWI) + rule #parseInstrp2(134, BWI:BytesWithIndex) => parseInstrx134(BWI) + rule #parseInstrp2(135, BWI:BytesWithIndex) => parseInstrx135(BWI) + rule #parseInstrp2(136, BWI:BytesWithIndex) => parseInstrx136(BWI) + rule #parseInstrp2(137, BWI:BytesWithIndex) => parseInstrx137(BWI) + rule #parseInstrp2(138, BWI:BytesWithIndex) => parseInstrx138(BWI) + rule #parseInstrp2(139, BWI:BytesWithIndex) => parseInstrx139(BWI) + rule #parseInstrp2(140, BWI:BytesWithIndex) => parseInstrx140(BWI) + rule #parseInstrp2(141, BWI:BytesWithIndex) => parseInstrx141(BWI) + rule #parseInstrp2(142, BWI:BytesWithIndex) => parseInstrx142(BWI) + rule #parseInstrp2(143, BWI:BytesWithIndex) => parseInstrx143(BWI) + rule #parseInstrp2(144, BWI:BytesWithIndex) => parseInstrx144(BWI) + rule #parseInstrp2(145, BWI:BytesWithIndex) => parseInstrx145(BWI) + rule #parseInstrp2(146, BWI:BytesWithIndex) => parseInstrx146(BWI) + rule #parseInstrp2(147, BWI:BytesWithIndex) => parseInstrx147(BWI) + rule #parseInstrp2(148, BWI:BytesWithIndex) => parseInstrx148(BWI) + rule #parseInstrp2(149, BWI:BytesWithIndex) => parseInstrx149(BWI) + rule #parseInstrp2(150, BWI:BytesWithIndex) => parseInstrx150(BWI) + rule #parseInstrp2(151, BWI:BytesWithIndex) => parseInstrx151(BWI) + rule #parseInstrp2(152, BWI:BytesWithIndex) => parseInstrx152(BWI) + rule #parseInstrp2(153, BWI:BytesWithIndex) => parseInstrx153(BWI) + rule #parseInstrp2(154, BWI:BytesWithIndex) => parseInstrx154(BWI) + rule #parseInstrp2(155, BWI:BytesWithIndex) => parseInstrx155(BWI) + rule #parseInstrp2(156, BWI:BytesWithIndex) => parseInstrx156(BWI) + rule #parseInstrp2(157, BWI:BytesWithIndex) => parseInstrx157(BWI) + rule #parseInstrp2(158, BWI:BytesWithIndex) => parseInstrx158(BWI) + rule #parseInstrp2(159, BWI:BytesWithIndex) => parseInstrx159(BWI) + rule #parseInstrp2(160, BWI:BytesWithIndex) => parseInstrx160(BWI) + rule #parseInstrp2(161, BWI:BytesWithIndex) => parseInstrx161(BWI) + rule #parseInstrp2(162, BWI:BytesWithIndex) => parseInstrx162(BWI) + rule #parseInstrp2(163, BWI:BytesWithIndex) => parseInstrx163(BWI) + rule #parseInstrp2(164, BWI:BytesWithIndex) => parseInstrx164(BWI) + rule #parseInstrp2(165, BWI:BytesWithIndex) => parseInstrx165(BWI) + rule #parseInstrp2(166, BWI:BytesWithIndex) => parseInstrx166(BWI) + rule #parseInstrp2(167, BWI:BytesWithIndex) => parseInstrx167(BWI) + rule #parseInstrp2(168, BWI:BytesWithIndex) => parseInstrx168(BWI) + rule #parseInstrp2(169, BWI:BytesWithIndex) => parseInstrx169(BWI) + rule #parseInstrp2(170, BWI:BytesWithIndex) => parseInstrx170(BWI) + rule #parseInstrp2(171, BWI:BytesWithIndex) => parseInstrx171(BWI) + rule #parseInstrp2(172, BWI:BytesWithIndex) => parseInstrx172(BWI) + rule #parseInstrp2(173, BWI:BytesWithIndex) => parseInstrx173(BWI) + rule #parseInstrp2(174, BWI:BytesWithIndex) => parseInstrx174(BWI) + rule #parseInstrp2(175, BWI:BytesWithIndex) => parseInstrx175(BWI) + rule #parseInstrp2(176, BWI:BytesWithIndex) => parseInstrx176(BWI) + rule #parseInstrp2(177, BWI:BytesWithIndex) => parseInstrx177(BWI) + rule #parseInstrp2(178, BWI:BytesWithIndex) => parseInstrx178(BWI) + rule #parseInstrp2(179, BWI:BytesWithIndex) => parseInstrx179(BWI) + rule #parseInstrp2(180, BWI:BytesWithIndex) => parseInstrx180(BWI) + rule #parseInstrp2(181, BWI:BytesWithIndex) => parseInstrx181(BWI) + rule #parseInstrp2(182, BWI:BytesWithIndex) => parseInstrx182(BWI) + rule #parseInstrp2(183, BWI:BytesWithIndex) => parseInstrx183(BWI) + rule #parseInstrp2(184, BWI:BytesWithIndex) => parseInstrx184(BWI) + rule #parseInstrp2(185, BWI:BytesWithIndex) => parseInstrx185(BWI) + rule #parseInstrp2(186, BWI:BytesWithIndex) => parseInstrx186(BWI) + rule #parseInstrp2(187, BWI:BytesWithIndex) => parseInstrx187(BWI) + rule #parseInstrp2(188, BWI:BytesWithIndex) => parseInstrx188(BWI) + rule #parseInstrp2(189, BWI:BytesWithIndex) => parseInstrx189(BWI) + rule #parseInstrp2(190, BWI:BytesWithIndex) => parseInstrx190(BWI) + rule #parseInstrp2(191, BWI:BytesWithIndex) => parseInstrx191(BWI) + rule #parseInstrp2(192, BWI:BytesWithIndex) => parseInstrx192(BWI) + rule #parseInstrp2(193, BWI:BytesWithIndex) => parseInstrx193(BWI) + rule #parseInstrp2(194, BWI:BytesWithIndex) => parseInstrx194(BWI) + rule #parseInstrp2(195, BWI:BytesWithIndex) => parseInstrx195(BWI) + rule #parseInstrp2(196, BWI:BytesWithIndex) => parseInstrx196(BWI) + rule #parseInstrp2(208, BWI:BytesWithIndex) => parseInstrx208(BWI) + rule #parseInstrp2(209, BWI:BytesWithIndex) => parseInstrx209(BWI) + rule #parseInstrp2(210, BWI:BytesWithIndex) => parseInstrx210(BWI) + rule #parseInstrp2(252, BWI:BytesWithIndex) => parseInstrx252(BWI) + rule #parseInstrp2(253, BWI:BytesWithIndex) => parseInstrx253(BWI) + rule #parseInstrp2(I:Int, bwi(B:Bytes, Index:Int)) => parseError("#parseInstrp2", ListItem(I) ListItem(Index) ListItem(lengthBytes(B)) ListItem(B)) [owise] + + syntax InstrResult ::= parseInstrx0(BytesWithIndex) [function, total] + rule parseInstrx0(BWI:BytesWithIndex) => instrResult(unreachable, BWI) + syntax InstrResult ::= parseInstrx1(BytesWithIndex) [function, total] + rule parseInstrx1(BWI:BytesWithIndex) => instrResult(nop, BWI) + syntax InstrResult ::= parseInstrx2(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx2s1 + ( BlockResult + ) [function, total] + rule parseInstrx2(BWI) => #parseInstrx2s1(parseBlock(BWI)) + rule #parseInstrx2s1(blockResult(Block0:Block, _:Bool, BWI:BytesWithIndex)) => instrResult(Block0, BWI) + rule #parseInstrx2s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx3(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx3s1 + ( BlockResult + ) [function, total] + rule parseInstrx3(BWI) => #parseInstrx3s1(parseBlock(BWI)) + rule #parseInstrx3s1(blockResult(Block0:Block, _:Bool, BWI:BytesWithIndex)) => instrResult(loop(Block0), BWI) + rule #parseInstrx3s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx4(BytesWithIndex) [function, total] + rule parseInstrx4(BWI:BytesWithIndex) => parseIf(BWI) + syntax InstrResult ::= parseInstrx12(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx12s1 + ( IntResult + ) [function, total] + rule parseInstrx12(BWI) => #parseInstrx12s1(parseLeb128UInt(BWI)) + rule #parseInstrx12s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => instrResult(#br(UnsignedInt0), BWI) + rule #parseInstrx12s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx13(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx13s1 + ( IntResult + ) [function, total] + rule parseInstrx13(BWI) => #parseInstrx13s1(parseLeb128UInt(BWI)) + rule #parseInstrx13s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => instrResult(#br_if(UnsignedInt0), BWI) + rule #parseInstrx13s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx14(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx14s1 + ( IntsResult + ) [function, total] + rule parseInstrx14(BWI) => #parseInstrx14s1(parseUnsignedIntVec(BWI)) + syntax InstrResult ::= #parseInstrx14s2 + ( Ints + , IntResult + ) [function, total] + rule #parseInstrx14s1(intsResult(UnsignedIntVec0:Ints, BWI:BytesWithIndex)) => #parseInstrx14s2(UnsignedIntVec0, parseLeb128UInt(BWI)) + rule #parseInstrx14s1(E:ParseError) => E + rule #parseInstrx14s2(UnsignedIntVec0:Ints, intResult(UnsignedInt1:Int, BWI:BytesWithIndex)) => instrResult(buildBrTable(UnsignedIntVec0, UnsignedInt1), BWI) + rule #parseInstrx14s2(_UnsignedIntVec0:Ints, E:ParseError) => E + syntax InstrResult ::= parseInstrx15(BytesWithIndex) [function, total] + rule parseInstrx15(BWI:BytesWithIndex) => instrResult(return, BWI) + syntax InstrResult ::= parseInstrx16(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx16s1 + ( IntResult + ) [function, total] + rule parseInstrx16(BWI) => #parseInstrx16s1(parseLeb128UInt(BWI)) + rule #parseInstrx16s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => instrResult(#call(UnsignedInt0), BWI) + rule #parseInstrx16s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx17(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx17s1 + ( IntResult + ) [function, total] + rule parseInstrx17(BWI) => #parseInstrx17s1(parseLeb128UInt(BWI)) + syntax InstrResult ::= #parseInstrx17s2 + ( Int + , IntResult + ) [function, total] + rule #parseInstrx17s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => #parseInstrx17s2(UnsignedInt0, parseLeb128UInt(BWI)) + rule #parseInstrx17s1(E:ParseError) => E + rule #parseInstrx17s2(UnsignedInt0:Int, intResult(UnsignedInt1:Int, BWI:BytesWithIndex)) => instrResult(buildCallIndirect(UnsignedInt0, UnsignedInt1), BWI) + rule #parseInstrx17s2(_UnsignedInt0:Int, E:ParseError) => E + syntax InstrResult ::= parseInstrx26(BytesWithIndex) [function, total] + rule parseInstrx26(BWI:BytesWithIndex) => instrResult(drop, BWI) + syntax InstrResult ::= parseInstrx27(BytesWithIndex) [function, total] + rule parseInstrx27(BWI:BytesWithIndex) => instrResult(select, BWI) + syntax InstrResult ::= parseInstrx28(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx28s1 + ( ValTypesResult + ) [function, total] + rule parseInstrx28(BWI) => #parseInstrx28s1(parseValTypes(BWI)) + rule #parseInstrx28s1(valTypesResult(ValTypes0:ValTypes, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(ValTypes0) ListItem(BWI)) + rule #parseInstrx28s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx32(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx32s1 + ( IntResult + ) [function, total] + rule parseInstrx32(BWI) => #parseInstrx32s1(parseLeb128UInt(BWI)) + rule #parseInstrx32s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => instrResult(#local.get(UnsignedInt0), BWI) + rule #parseInstrx32s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx33(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx33s1 + ( IntResult + ) [function, total] + rule parseInstrx33(BWI) => #parseInstrx33s1(parseLeb128UInt(BWI)) + rule #parseInstrx33s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => instrResult(#local.set(UnsignedInt0), BWI) + rule #parseInstrx33s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx34(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx34s1 + ( IntResult + ) [function, total] + rule parseInstrx34(BWI) => #parseInstrx34s1(parseLeb128UInt(BWI)) + rule #parseInstrx34s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => instrResult(#local.tee(UnsignedInt0), BWI) + rule #parseInstrx34s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx35(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx35s1 + ( IntResult + ) [function, total] + rule parseInstrx35(BWI) => #parseInstrx35s1(parseLeb128UInt(BWI)) + rule #parseInstrx35s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => instrResult(#global.get(UnsignedInt0), BWI) + rule #parseInstrx35s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx36(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx36s1 + ( IntResult + ) [function, total] + rule parseInstrx36(BWI) => #parseInstrx36s1(parseLeb128UInt(BWI)) + rule #parseInstrx36s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => instrResult(#global.set(UnsignedInt0), BWI) + rule #parseInstrx36s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx37(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx37s1 + ( IntResult + ) [function, total] + rule parseInstrx37(BWI) => #parseInstrx37s1(parseLeb128UInt(BWI)) + rule #parseInstrx37s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => instrResult(#table.get(UnsignedInt0), BWI) + rule #parseInstrx37s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx38(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx38s1 + ( IntResult + ) [function, total] + rule parseInstrx38(BWI) => #parseInstrx38s1(parseLeb128UInt(BWI)) + rule #parseInstrx38s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => instrResult(#table.set(UnsignedInt0), BWI) + rule #parseInstrx38s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx40(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx40s1 + ( MemArgResult + ) [function, total] + rule parseInstrx40(BWI) => #parseInstrx40s1(parseMemArg(BWI)) + rule #parseInstrx40s1(memArgResult(MemArg2:MemArg, BWI:BytesWithIndex)) => instrResult(#load(i32, load, getMemArgOffset(MemArg2)), BWI) + rule #parseInstrx40s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx41(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx41s1 + ( MemArgResult + ) [function, total] + rule parseInstrx41(BWI) => #parseInstrx41s1(parseMemArg(BWI)) + rule #parseInstrx41s1(memArgResult(MemArg2:MemArg, BWI:BytesWithIndex)) => instrResult(#load(i64, load, getMemArgOffset(MemArg2)), BWI) + rule #parseInstrx41s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx42(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx42s1 + ( MemArgResult + ) [function, total] + rule parseInstrx42(BWI) => #parseInstrx42s1(parseMemArg(BWI)) + rule #parseInstrx42s1(memArgResult(MemArg2:MemArg, BWI:BytesWithIndex)) => instrResult(#load(f32, load, getMemArgOffset(MemArg2)), BWI) + rule #parseInstrx42s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx43(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx43s1 + ( MemArgResult + ) [function, total] + rule parseInstrx43(BWI) => #parseInstrx43s1(parseMemArg(BWI)) + rule #parseInstrx43s1(memArgResult(MemArg2:MemArg, BWI:BytesWithIndex)) => instrResult(#load(f64, load, getMemArgOffset(MemArg2)), BWI) + rule #parseInstrx43s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx44(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx44s1 + ( MemArgResult + ) [function, total] + rule parseInstrx44(BWI) => #parseInstrx44s1(parseMemArg(BWI)) + rule #parseInstrx44s1(memArgResult(MemArg2:MemArg, BWI:BytesWithIndex)) => instrResult(#load(i32, load8_s, getMemArgOffset(MemArg2)), BWI) + rule #parseInstrx44s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx45(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx45s1 + ( MemArgResult + ) [function, total] + rule parseInstrx45(BWI) => #parseInstrx45s1(parseMemArg(BWI)) + rule #parseInstrx45s1(memArgResult(MemArg2:MemArg, BWI:BytesWithIndex)) => instrResult(#load(i32, load8_u, getMemArgOffset(MemArg2)), BWI) + rule #parseInstrx45s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx46(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx46s1 + ( MemArgResult + ) [function, total] + rule parseInstrx46(BWI) => #parseInstrx46s1(parseMemArg(BWI)) + rule #parseInstrx46s1(memArgResult(MemArg2:MemArg, BWI:BytesWithIndex)) => instrResult(#load(i32, load16_s, getMemArgOffset(MemArg2)), BWI) + rule #parseInstrx46s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx47(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx47s1 + ( MemArgResult + ) [function, total] + rule parseInstrx47(BWI) => #parseInstrx47s1(parseMemArg(BWI)) + rule #parseInstrx47s1(memArgResult(MemArg2:MemArg, BWI:BytesWithIndex)) => instrResult(#load(i32, load16_u, getMemArgOffset(MemArg2)), BWI) + rule #parseInstrx47s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx48(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx48s1 + ( MemArgResult + ) [function, total] + rule parseInstrx48(BWI) => #parseInstrx48s1(parseMemArg(BWI)) + rule #parseInstrx48s1(memArgResult(MemArg2:MemArg, BWI:BytesWithIndex)) => instrResult(#load(i64, load8_s, getMemArgOffset(MemArg2)), BWI) + rule #parseInstrx48s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx49(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx49s1 + ( MemArgResult + ) [function, total] + rule parseInstrx49(BWI) => #parseInstrx49s1(parseMemArg(BWI)) + rule #parseInstrx49s1(memArgResult(MemArg2:MemArg, BWI:BytesWithIndex)) => instrResult(#load(i64, load8_u, getMemArgOffset(MemArg2)), BWI) + rule #parseInstrx49s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx50(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx50s1 + ( MemArgResult + ) [function, total] + rule parseInstrx50(BWI) => #parseInstrx50s1(parseMemArg(BWI)) + rule #parseInstrx50s1(memArgResult(MemArg2:MemArg, BWI:BytesWithIndex)) => instrResult(#load(i64, load16_s, getMemArgOffset(MemArg2)), BWI) + rule #parseInstrx50s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx51(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx51s1 + ( MemArgResult + ) [function, total] + rule parseInstrx51(BWI) => #parseInstrx51s1(parseMemArg(BWI)) + rule #parseInstrx51s1(memArgResult(MemArg2:MemArg, BWI:BytesWithIndex)) => instrResult(#load(i64, load16_u, getMemArgOffset(MemArg2)), BWI) + rule #parseInstrx51s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx52(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx52s1 + ( MemArgResult + ) [function, total] + rule parseInstrx52(BWI) => #parseInstrx52s1(parseMemArg(BWI)) + rule #parseInstrx52s1(memArgResult(MemArg2:MemArg, BWI:BytesWithIndex)) => instrResult(#load(i64, load32_s, getMemArgOffset(MemArg2)), BWI) + rule #parseInstrx52s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx53(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx53s1 + ( MemArgResult + ) [function, total] + rule parseInstrx53(BWI) => #parseInstrx53s1(parseMemArg(BWI)) + rule #parseInstrx53s1(memArgResult(MemArg2:MemArg, BWI:BytesWithIndex)) => instrResult(#load(i64, load32_u, getMemArgOffset(MemArg2)), BWI) + rule #parseInstrx53s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx54(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx54s1 + ( MemArgResult + ) [function, total] + rule parseInstrx54(BWI) => #parseInstrx54s1(parseMemArg(BWI)) + rule #parseInstrx54s1(memArgResult(MemArg2:MemArg, BWI:BytesWithIndex)) => instrResult(#store(i32, store, getMemArgOffset(MemArg2)), BWI) + rule #parseInstrx54s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx55(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx55s1 + ( MemArgResult + ) [function, total] + rule parseInstrx55(BWI) => #parseInstrx55s1(parseMemArg(BWI)) + rule #parseInstrx55s1(memArgResult(MemArg2:MemArg, BWI:BytesWithIndex)) => instrResult(#store(i64, store, getMemArgOffset(MemArg2)), BWI) + rule #parseInstrx55s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx56(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx56s1 + ( MemArgResult + ) [function, total] + rule parseInstrx56(BWI) => #parseInstrx56s1(parseMemArg(BWI)) + rule #parseInstrx56s1(memArgResult(MemArg2:MemArg, BWI:BytesWithIndex)) => instrResult(#store(f32, store, getMemArgOffset(MemArg2)), BWI) + rule #parseInstrx56s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx57(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx57s1 + ( MemArgResult + ) [function, total] + rule parseInstrx57(BWI) => #parseInstrx57s1(parseMemArg(BWI)) + rule #parseInstrx57s1(memArgResult(MemArg2:MemArg, BWI:BytesWithIndex)) => instrResult(#store(f64, store, getMemArgOffset(MemArg2)), BWI) + rule #parseInstrx57s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx58(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx58s1 + ( MemArgResult + ) [function, total] + rule parseInstrx58(BWI) => #parseInstrx58s1(parseMemArg(BWI)) + rule #parseInstrx58s1(memArgResult(MemArg2:MemArg, BWI:BytesWithIndex)) => instrResult(#store(i32, store8, getMemArgOffset(MemArg2)), BWI) + rule #parseInstrx58s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx59(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx59s1 + ( MemArgResult + ) [function, total] + rule parseInstrx59(BWI) => #parseInstrx59s1(parseMemArg(BWI)) + rule #parseInstrx59s1(memArgResult(MemArg2:MemArg, BWI:BytesWithIndex)) => instrResult(#store(i32, store16, getMemArgOffset(MemArg2)), BWI) + rule #parseInstrx59s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx60(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx60s1 + ( MemArgResult + ) [function, total] + rule parseInstrx60(BWI) => #parseInstrx60s1(parseMemArg(BWI)) + rule #parseInstrx60s1(memArgResult(MemArg2:MemArg, BWI:BytesWithIndex)) => instrResult(#store(i64, store8, getMemArgOffset(MemArg2)), BWI) + rule #parseInstrx60s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx61(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx61s1 + ( MemArgResult + ) [function, total] + rule parseInstrx61(BWI) => #parseInstrx61s1(parseMemArg(BWI)) + rule #parseInstrx61s1(memArgResult(MemArg2:MemArg, BWI:BytesWithIndex)) => instrResult(#store(i64, store16, getMemArgOffset(MemArg2)), BWI) + rule #parseInstrx61s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx62(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx62s1 + ( MemArgResult + ) [function, total] + rule parseInstrx62(BWI) => #parseInstrx62s1(parseMemArg(BWI)) + rule #parseInstrx62s1(memArgResult(MemArg2:MemArg, BWI:BytesWithIndex)) => instrResult(#store(i64, store32, getMemArgOffset(MemArg2)), BWI) + rule #parseInstrx62s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx63(BytesWithIndex) [function, total] + rule parseInstrx63(BWI:BytesWithIndex) => instrResult(memory.size, BWI) + syntax InstrResult ::= parseInstrx64(BytesWithIndex) [function, total] + rule parseInstrx64(BWI:BytesWithIndex) => instrResult(memory.grow, BWI) + syntax InstrResult ::= parseInstrx65(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx65s1 + ( IntResult + ) [function, total] + rule parseInstrx65(BWI) => #parseInstrx65s1(parseLeb128SInt(BWI)) + rule #parseInstrx65s1(intResult(SignedInt1:Int, BWI:BytesWithIndex)) => instrResult(`aIConst`(i32, SignedInt1), BWI) + rule #parseInstrx65s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx66(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx66s1 + ( IntResult + ) [function, total] + rule parseInstrx66(BWI) => #parseInstrx66s1(parseLeb128SInt(BWI)) + rule #parseInstrx66s1(intResult(SignedInt1:Int, BWI:BytesWithIndex)) => instrResult(`aIConst`(i64, SignedInt1), BWI) + rule #parseInstrx66s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx67(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx67s1 + ( FloatResult + ) [function, total] + rule parseInstrx67(BWI) => #parseInstrx67s1(parseFloat32(BWI)) + rule #parseInstrx67s1(floatResult(Float321:Float, BWI:BytesWithIndex)) => instrResult(`aFConst`(f32, Float321), BWI) + rule #parseInstrx67s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx68(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx68s1 + ( FloatResult + ) [function, total] + rule parseInstrx68(BWI) => #parseInstrx68s1(parseFloat64(BWI)) + rule #parseInstrx68s1(floatResult(Float641:Float, BWI:BytesWithIndex)) => instrResult(`aFConst`(f64, Float641), BWI) + rule #parseInstrx68s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx69(BytesWithIndex) [function, total] + rule parseInstrx69(BWI:BytesWithIndex) => instrResult(`aTestOp`(i32, eqz), BWI) + syntax InstrResult ::= parseInstrx70(BytesWithIndex) [function, total] + rule parseInstrx70(BWI:BytesWithIndex) => instrResult(`aIRelOp`(i32, eq), BWI) + syntax InstrResult ::= parseInstrx71(BytesWithIndex) [function, total] + rule parseInstrx71(BWI:BytesWithIndex) => instrResult(`aIRelOp`(i32, ne), BWI) + syntax InstrResult ::= parseInstrx72(BytesWithIndex) [function, total] + rule parseInstrx72(BWI:BytesWithIndex) => instrResult(`aIRelOp`(i32, lt_s), BWI) + syntax InstrResult ::= parseInstrx73(BytesWithIndex) [function, total] + rule parseInstrx73(BWI:BytesWithIndex) => instrResult(`aIRelOp`(i32, lt_u), BWI) + syntax InstrResult ::= parseInstrx74(BytesWithIndex) [function, total] + rule parseInstrx74(BWI:BytesWithIndex) => instrResult(`aIRelOp`(i32, gt_s), BWI) + syntax InstrResult ::= parseInstrx75(BytesWithIndex) [function, total] + rule parseInstrx75(BWI:BytesWithIndex) => instrResult(`aIRelOp`(i32, gt_u), BWI) + syntax InstrResult ::= parseInstrx76(BytesWithIndex) [function, total] + rule parseInstrx76(BWI:BytesWithIndex) => instrResult(`aIRelOp`(i32, le_s), BWI) + syntax InstrResult ::= parseInstrx77(BytesWithIndex) [function, total] + rule parseInstrx77(BWI:BytesWithIndex) => instrResult(`aIRelOp`(i32, le_u), BWI) + syntax InstrResult ::= parseInstrx78(BytesWithIndex) [function, total] + rule parseInstrx78(BWI:BytesWithIndex) => instrResult(`aIRelOp`(i32, ge_s), BWI) + syntax InstrResult ::= parseInstrx79(BytesWithIndex) [function, total] + rule parseInstrx79(BWI:BytesWithIndex) => instrResult(`aIRelOp`(i32, ge_u), BWI) + syntax InstrResult ::= parseInstrx80(BytesWithIndex) [function, total] + rule parseInstrx80(BWI:BytesWithIndex) => instrResult(`aTestOp`(i64, eqz), BWI) + syntax InstrResult ::= parseInstrx81(BytesWithIndex) [function, total] + rule parseInstrx81(BWI:BytesWithIndex) => instrResult(`aIRelOp`(i64, eq), BWI) + syntax InstrResult ::= parseInstrx82(BytesWithIndex) [function, total] + rule parseInstrx82(BWI:BytesWithIndex) => instrResult(`aIRelOp`(i64, ne), BWI) + syntax InstrResult ::= parseInstrx83(BytesWithIndex) [function, total] + rule parseInstrx83(BWI:BytesWithIndex) => instrResult(`aIRelOp`(i64, lt_s), BWI) + syntax InstrResult ::= parseInstrx84(BytesWithIndex) [function, total] + rule parseInstrx84(BWI:BytesWithIndex) => instrResult(`aIRelOp`(i64, lt_u), BWI) + syntax InstrResult ::= parseInstrx85(BytesWithIndex) [function, total] + rule parseInstrx85(BWI:BytesWithIndex) => instrResult(`aIRelOp`(i64, gt_s), BWI) + syntax InstrResult ::= parseInstrx86(BytesWithIndex) [function, total] + rule parseInstrx86(BWI:BytesWithIndex) => instrResult(`aIRelOp`(i64, gt_u), BWI) + syntax InstrResult ::= parseInstrx87(BytesWithIndex) [function, total] + rule parseInstrx87(BWI:BytesWithIndex) => instrResult(`aIRelOp`(i64, le_s), BWI) + syntax InstrResult ::= parseInstrx88(BytesWithIndex) [function, total] + rule parseInstrx88(BWI:BytesWithIndex) => instrResult(`aIRelOp`(i64, le_u), BWI) + syntax InstrResult ::= parseInstrx89(BytesWithIndex) [function, total] + rule parseInstrx89(BWI:BytesWithIndex) => instrResult(`aIRelOp`(i64, ge_s), BWI) + syntax InstrResult ::= parseInstrx90(BytesWithIndex) [function, total] + rule parseInstrx90(BWI:BytesWithIndex) => instrResult(`aIRelOp`(i64, ge_u), BWI) + syntax InstrResult ::= parseInstrx91(BytesWithIndex) [function, total] + rule parseInstrx91(BWI:BytesWithIndex) => instrResult(`aFRelOp`(f32, eq), BWI) + syntax InstrResult ::= parseInstrx92(BytesWithIndex) [function, total] + rule parseInstrx92(BWI:BytesWithIndex) => instrResult(`aFRelOp`(f32, ne), BWI) + syntax InstrResult ::= parseInstrx93(BytesWithIndex) [function, total] + rule parseInstrx93(BWI:BytesWithIndex) => instrResult(`aFRelOp`(f32, lt), BWI) + syntax InstrResult ::= parseInstrx94(BytesWithIndex) [function, total] + rule parseInstrx94(BWI:BytesWithIndex) => instrResult(`aFRelOp`(f32, gt), BWI) + syntax InstrResult ::= parseInstrx95(BytesWithIndex) [function, total] + rule parseInstrx95(BWI:BytesWithIndex) => instrResult(`aFRelOp`(f32, le), BWI) + syntax InstrResult ::= parseInstrx96(BytesWithIndex) [function, total] + rule parseInstrx96(BWI:BytesWithIndex) => instrResult(`aFRelOp`(f32, ge), BWI) + syntax InstrResult ::= parseInstrx97(BytesWithIndex) [function, total] + rule parseInstrx97(BWI:BytesWithIndex) => instrResult(`aFRelOp`(f64, eq), BWI) + syntax InstrResult ::= parseInstrx98(BytesWithIndex) [function, total] + rule parseInstrx98(BWI:BytesWithIndex) => instrResult(`aFRelOp`(f64, ne), BWI) + syntax InstrResult ::= parseInstrx99(BytesWithIndex) [function, total] + rule parseInstrx99(BWI:BytesWithIndex) => instrResult(`aFRelOp`(f64, lt), BWI) + syntax InstrResult ::= parseInstrx100(BytesWithIndex) [function, total] + rule parseInstrx100(BWI:BytesWithIndex) => instrResult(`aFRelOp`(f64, gt), BWI) + syntax InstrResult ::= parseInstrx101(BytesWithIndex) [function, total] + rule parseInstrx101(BWI:BytesWithIndex) => instrResult(`aFRelOp`(f64, le), BWI) + syntax InstrResult ::= parseInstrx102(BytesWithIndex) [function, total] + rule parseInstrx102(BWI:BytesWithIndex) => instrResult(`aFRelOp`(f64, ge), BWI) + syntax InstrResult ::= parseInstrx103(BytesWithIndex) [function, total] + rule parseInstrx103(BWI:BytesWithIndex) => instrResult(`aIUnOp`(i32, clz), BWI) + syntax InstrResult ::= parseInstrx104(BytesWithIndex) [function, total] + rule parseInstrx104(BWI:BytesWithIndex) => instrResult(`aIUnOp`(i32, ctz), BWI) + syntax InstrResult ::= parseInstrx105(BytesWithIndex) [function, total] + rule parseInstrx105(BWI:BytesWithIndex) => instrResult(`aIUnOp`(i32, popcnt), BWI) + syntax InstrResult ::= parseInstrx106(BytesWithIndex) [function, total] + rule parseInstrx106(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i32, add), BWI) + syntax InstrResult ::= parseInstrx107(BytesWithIndex) [function, total] + rule parseInstrx107(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i32, sub), BWI) + syntax InstrResult ::= parseInstrx108(BytesWithIndex) [function, total] + rule parseInstrx108(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i32, mul), BWI) + syntax InstrResult ::= parseInstrx109(BytesWithIndex) [function, total] + rule parseInstrx109(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i32, div_s), BWI) + syntax InstrResult ::= parseInstrx110(BytesWithIndex) [function, total] + rule parseInstrx110(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i32, div_u), BWI) + syntax InstrResult ::= parseInstrx111(BytesWithIndex) [function, total] + rule parseInstrx111(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i32, rem_s), BWI) + syntax InstrResult ::= parseInstrx112(BytesWithIndex) [function, total] + rule parseInstrx112(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i32, rem_u), BWI) + syntax InstrResult ::= parseInstrx113(BytesWithIndex) [function, total] + rule parseInstrx113(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i32, and), BWI) + syntax InstrResult ::= parseInstrx114(BytesWithIndex) [function, total] + rule parseInstrx114(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i32, or), BWI) + syntax InstrResult ::= parseInstrx115(BytesWithIndex) [function, total] + rule parseInstrx115(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i32, xor), BWI) + syntax InstrResult ::= parseInstrx116(BytesWithIndex) [function, total] + rule parseInstrx116(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i32, shl), BWI) + syntax InstrResult ::= parseInstrx117(BytesWithIndex) [function, total] + rule parseInstrx117(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i32, shr_s), BWI) + syntax InstrResult ::= parseInstrx118(BytesWithIndex) [function, total] + rule parseInstrx118(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i32, shr_u), BWI) + syntax InstrResult ::= parseInstrx119(BytesWithIndex) [function, total] + rule parseInstrx119(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i32, rotl), BWI) + syntax InstrResult ::= parseInstrx120(BytesWithIndex) [function, total] + rule parseInstrx120(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i32, rotr), BWI) + syntax InstrResult ::= parseInstrx121(BytesWithIndex) [function, total] + rule parseInstrx121(BWI:BytesWithIndex) => instrResult(`aIUnOp`(i32, clz), BWI) + syntax InstrResult ::= parseInstrx122(BytesWithIndex) [function, total] + rule parseInstrx122(BWI:BytesWithIndex) => instrResult(`aIUnOp`(i32, ctz), BWI) + syntax InstrResult ::= parseInstrx123(BytesWithIndex) [function, total] + rule parseInstrx123(BWI:BytesWithIndex) => instrResult(`aIUnOp`(i32, popcnt), BWI) + syntax InstrResult ::= parseInstrx124(BytesWithIndex) [function, total] + rule parseInstrx124(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i64, add), BWI) + syntax InstrResult ::= parseInstrx125(BytesWithIndex) [function, total] + rule parseInstrx125(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i64, sub), BWI) + syntax InstrResult ::= parseInstrx126(BytesWithIndex) [function, total] + rule parseInstrx126(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i64, mul), BWI) + syntax InstrResult ::= parseInstrx127(BytesWithIndex) [function, total] + rule parseInstrx127(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i64, div_s), BWI) + syntax InstrResult ::= parseInstrx128(BytesWithIndex) [function, total] + rule parseInstrx128(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i64, div_u), BWI) + syntax InstrResult ::= parseInstrx129(BytesWithIndex) [function, total] + rule parseInstrx129(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i64, rem_s), BWI) + syntax InstrResult ::= parseInstrx130(BytesWithIndex) [function, total] + rule parseInstrx130(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i64, rem_u), BWI) + syntax InstrResult ::= parseInstrx131(BytesWithIndex) [function, total] + rule parseInstrx131(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i64, and), BWI) + syntax InstrResult ::= parseInstrx132(BytesWithIndex) [function, total] + rule parseInstrx132(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i64, or), BWI) + syntax InstrResult ::= parseInstrx133(BytesWithIndex) [function, total] + rule parseInstrx133(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i64, xor), BWI) + syntax InstrResult ::= parseInstrx134(BytesWithIndex) [function, total] + rule parseInstrx134(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i64, shl), BWI) + syntax InstrResult ::= parseInstrx135(BytesWithIndex) [function, total] + rule parseInstrx135(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i64, shr_s), BWI) + syntax InstrResult ::= parseInstrx136(BytesWithIndex) [function, total] + rule parseInstrx136(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i64, shr_u), BWI) + syntax InstrResult ::= parseInstrx137(BytesWithIndex) [function, total] + rule parseInstrx137(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i64, rotl), BWI) + syntax InstrResult ::= parseInstrx138(BytesWithIndex) [function, total] + rule parseInstrx138(BWI:BytesWithIndex) => instrResult(`aIBinOp`(i64, rotr), BWI) + syntax InstrResult ::= parseInstrx139(BytesWithIndex) [function, total] + rule parseInstrx139(BWI:BytesWithIndex) => instrResult(`aFUnOp`(f32, abs), BWI) + syntax InstrResult ::= parseInstrx140(BytesWithIndex) [function, total] + rule parseInstrx140(BWI:BytesWithIndex) => instrResult(`aFUnOp`(f32, neg), BWI) + syntax InstrResult ::= parseInstrx141(BytesWithIndex) [function, total] + rule parseInstrx141(BWI:BytesWithIndex) => instrResult(`aFUnOp`(f32, ceil), BWI) + syntax InstrResult ::= parseInstrx142(BytesWithIndex) [function, total] + rule parseInstrx142(BWI:BytesWithIndex) => instrResult(`aFUnOp`(f32, floor), BWI) + syntax InstrResult ::= parseInstrx143(BytesWithIndex) [function, total] + rule parseInstrx143(BWI:BytesWithIndex) => instrResult(`aFUnOp`(f32, trunc), BWI) + syntax InstrResult ::= parseInstrx144(BytesWithIndex) [function, total] + rule parseInstrx144(BWI:BytesWithIndex) => instrResult(`aFUnOp`(f32, nearest), BWI) + syntax InstrResult ::= parseInstrx145(BytesWithIndex) [function, total] + rule parseInstrx145(BWI:BytesWithIndex) => instrResult(`aFUnOp`(f32, sqrt), BWI) + syntax InstrResult ::= parseInstrx146(BytesWithIndex) [function, total] + rule parseInstrx146(BWI:BytesWithIndex) => instrResult(`aFBinOp`(f32, add), BWI) + syntax InstrResult ::= parseInstrx147(BytesWithIndex) [function, total] + rule parseInstrx147(BWI:BytesWithIndex) => instrResult(`aFBinOp`(f32, sub), BWI) + syntax InstrResult ::= parseInstrx148(BytesWithIndex) [function, total] + rule parseInstrx148(BWI:BytesWithIndex) => instrResult(`aFBinOp`(f32, mul), BWI) + syntax InstrResult ::= parseInstrx149(BytesWithIndex) [function, total] + rule parseInstrx149(BWI:BytesWithIndex) => instrResult(`aFBinOp`(f32, div), BWI) + syntax InstrResult ::= parseInstrx150(BytesWithIndex) [function, total] + rule parseInstrx150(BWI:BytesWithIndex) => instrResult(`aFBinOp`(f32, min), BWI) + syntax InstrResult ::= parseInstrx151(BytesWithIndex) [function, total] + rule parseInstrx151(BWI:BytesWithIndex) => instrResult(`aFBinOp`(f32, max), BWI) + syntax InstrResult ::= parseInstrx152(BytesWithIndex) [function, total] + rule parseInstrx152(BWI:BytesWithIndex) => instrResult(`aFBinOp`(f32, copysign), BWI) + syntax InstrResult ::= parseInstrx153(BytesWithIndex) [function, total] + rule parseInstrx153(BWI:BytesWithIndex) => instrResult(`aFUnOp`(f64, abs), BWI) + syntax InstrResult ::= parseInstrx154(BytesWithIndex) [function, total] + rule parseInstrx154(BWI:BytesWithIndex) => instrResult(`aFUnOp`(f64, neg), BWI) + syntax InstrResult ::= parseInstrx155(BytesWithIndex) [function, total] + rule parseInstrx155(BWI:BytesWithIndex) => instrResult(`aFUnOp`(f64, ceil), BWI) + syntax InstrResult ::= parseInstrx156(BytesWithIndex) [function, total] + rule parseInstrx156(BWI:BytesWithIndex) => instrResult(`aFUnOp`(f64, floor), BWI) + syntax InstrResult ::= parseInstrx157(BytesWithIndex) [function, total] + rule parseInstrx157(BWI:BytesWithIndex) => instrResult(`aFUnOp`(f64, trunc), BWI) + syntax InstrResult ::= parseInstrx158(BytesWithIndex) [function, total] + rule parseInstrx158(BWI:BytesWithIndex) => instrResult(`aFUnOp`(f64, nearest), BWI) + syntax InstrResult ::= parseInstrx159(BytesWithIndex) [function, total] + rule parseInstrx159(BWI:BytesWithIndex) => instrResult(`aFUnOp`(f64, sqrt), BWI) + syntax InstrResult ::= parseInstrx160(BytesWithIndex) [function, total] + rule parseInstrx160(BWI:BytesWithIndex) => instrResult(`aFBinOp`(f32, add), BWI) + syntax InstrResult ::= parseInstrx161(BytesWithIndex) [function, total] + rule parseInstrx161(BWI:BytesWithIndex) => instrResult(`aFBinOp`(f32, sub), BWI) + syntax InstrResult ::= parseInstrx162(BytesWithIndex) [function, total] + rule parseInstrx162(BWI:BytesWithIndex) => instrResult(`aFBinOp`(f32, mul), BWI) + syntax InstrResult ::= parseInstrx163(BytesWithIndex) [function, total] + rule parseInstrx163(BWI:BytesWithIndex) => instrResult(`aFBinOp`(f32, div), BWI) + syntax InstrResult ::= parseInstrx164(BytesWithIndex) [function, total] + rule parseInstrx164(BWI:BytesWithIndex) => instrResult(`aFBinOp`(f32, min), BWI) + syntax InstrResult ::= parseInstrx165(BytesWithIndex) [function, total] + rule parseInstrx165(BWI:BytesWithIndex) => instrResult(`aFBinOp`(f32, max), BWI) + syntax InstrResult ::= parseInstrx166(BytesWithIndex) [function, total] + rule parseInstrx166(BWI:BytesWithIndex) => instrResult(`aFBinOp`(f32, copysign), BWI) + syntax InstrResult ::= parseInstrx167(BytesWithIndex) [function, total] + rule parseInstrx167(BWI:BytesWithIndex) => instrResult(`aCvtOp`(i32, wrap_i64), BWI) + syntax InstrResult ::= parseInstrx168(BytesWithIndex) [function, total] + rule parseInstrx168(BWI:BytesWithIndex) => instrResult(`aCvtOp`(i32, trunc_f32_s), BWI) + syntax InstrResult ::= parseInstrx169(BytesWithIndex) [function, total] + rule parseInstrx169(BWI:BytesWithIndex) => instrResult(`aCvtOp`(i32, trunc_f32_u), BWI) + syntax InstrResult ::= parseInstrx170(BytesWithIndex) [function, total] + rule parseInstrx170(BWI:BytesWithIndex) => instrResult(`aCvtOp`(i32, trunc_f64_s), BWI) + syntax InstrResult ::= parseInstrx171(BytesWithIndex) [function, total] + rule parseInstrx171(BWI:BytesWithIndex) => instrResult(`aCvtOp`(i32, trunc_f64_u), BWI) + syntax InstrResult ::= parseInstrx172(BytesWithIndex) [function, total] + rule parseInstrx172(BWI:BytesWithIndex) => instrResult(`aCvtOp`(i64, extend_i32_s), BWI) + syntax InstrResult ::= parseInstrx173(BytesWithIndex) [function, total] + rule parseInstrx173(BWI:BytesWithIndex) => instrResult(`aCvtOp`(i64, extend_i32_u), BWI) + syntax InstrResult ::= parseInstrx174(BytesWithIndex) [function, total] + rule parseInstrx174(BWI:BytesWithIndex) => instrResult(`aCvtOp`(i64, trunc_f32_s), BWI) + syntax InstrResult ::= parseInstrx175(BytesWithIndex) [function, total] + rule parseInstrx175(BWI:BytesWithIndex) => instrResult(`aCvtOp`(i64, trunc_f32_u), BWI) + syntax InstrResult ::= parseInstrx176(BytesWithIndex) [function, total] + rule parseInstrx176(BWI:BytesWithIndex) => instrResult(`aCvtOp`(i64, trunc_f64_s), BWI) + syntax InstrResult ::= parseInstrx177(BytesWithIndex) [function, total] + rule parseInstrx177(BWI:BytesWithIndex) => instrResult(`aCvtOp`(i64, trunc_f64_u), BWI) + syntax InstrResult ::= parseInstrx178(BytesWithIndex) [function, total] + rule parseInstrx178(BWI:BytesWithIndex) => instrResult(`aCvtOp`(f32, convert_i32_s), BWI) + syntax InstrResult ::= parseInstrx179(BytesWithIndex) [function, total] + rule parseInstrx179(BWI:BytesWithIndex) => instrResult(`aCvtOp`(f32, convert_i32_u), BWI) + syntax InstrResult ::= parseInstrx180(BytesWithIndex) [function, total] + rule parseInstrx180(BWI:BytesWithIndex) => instrResult(`aCvtOp`(f32, convert_i64_s), BWI) + syntax InstrResult ::= parseInstrx181(BytesWithIndex) [function, total] + rule parseInstrx181(BWI:BytesWithIndex) => instrResult(`aCvtOp`(f32, convert_i64_u), BWI) + syntax InstrResult ::= parseInstrx182(BytesWithIndex) [function, total] + rule parseInstrx182(BWI:BytesWithIndex) => instrResult(`aCvtOp`(f32, demote_f64), BWI) + syntax InstrResult ::= parseInstrx183(BytesWithIndex) [function, total] + rule parseInstrx183(BWI:BytesWithIndex) => instrResult(`aCvtOp`(f64, convert_i32_s), BWI) + syntax InstrResult ::= parseInstrx184(BytesWithIndex) [function, total] + rule parseInstrx184(BWI:BytesWithIndex) => instrResult(`aCvtOp`(f64, convert_i32_u), BWI) + syntax InstrResult ::= parseInstrx185(BytesWithIndex) [function, total] + rule parseInstrx185(BWI:BytesWithIndex) => instrResult(`aCvtOp`(f64, convert_i64_s), BWI) + syntax InstrResult ::= parseInstrx186(BytesWithIndex) [function, total] + rule parseInstrx186(BWI:BytesWithIndex) => instrResult(`aCvtOp`(f64, convert_i64_u), BWI) + syntax InstrResult ::= parseInstrx187(BytesWithIndex) [function, total] + rule parseInstrx187(BWI:BytesWithIndex) => instrResult(`aCvtOp`(f64, promote_f32), BWI) + syntax InstrResult ::= parseInstrx188(BytesWithIndex) [function, total] + rule parseInstrx188(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx189(BytesWithIndex) [function, total] + rule parseInstrx189(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx190(BytesWithIndex) [function, total] + rule parseInstrx190(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx191(BytesWithIndex) [function, total] + rule parseInstrx191(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx192(BytesWithIndex) [function, total] + rule parseInstrx192(BWI:BytesWithIndex) => instrResult(`aExtendS`(i32, extend8_s), BWI) + syntax InstrResult ::= parseInstrx193(BytesWithIndex) [function, total] + rule parseInstrx193(BWI:BytesWithIndex) => instrResult(`aExtendS`(i32, extend16_s), BWI) + syntax InstrResult ::= parseInstrx194(BytesWithIndex) [function, total] + rule parseInstrx194(BWI:BytesWithIndex) => instrResult(`aExtendS`(i64, extend8_s), BWI) + syntax InstrResult ::= parseInstrx195(BytesWithIndex) [function, total] + rule parseInstrx195(BWI:BytesWithIndex) => instrResult(`aExtendS`(i64, extend16_s), BWI) + syntax InstrResult ::= parseInstrx196(BytesWithIndex) [function, total] + rule parseInstrx196(BWI:BytesWithIndex) => instrResult(`aExtendS`(i64, extend32_s), BWI) + syntax InstrResult ::= parseInstrx208(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx208s1 + ( HeapTypeResult + ) [function, total] + rule parseInstrx208(BWI) => #parseInstrx208s1(parseHeapType(BWI)) + rule #parseInstrx208s1(heapTypeResult(HeapType0:HeapType, BWI:BytesWithIndex)) => instrResult(`aRef.null`(HeapType0), BWI) + rule #parseInstrx208s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx209(BytesWithIndex) [function, total] + rule parseInstrx209(BWI:BytesWithIndex) => instrResult(#ref.is_null, BWI) + syntax InstrResult ::= parseInstrx210(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx210s1 + ( IntResult + ) [function, total] + rule parseInstrx210(BWI) => #parseInstrx210s1(parseLeb128UInt(BWI)) + rule #parseInstrx210s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => instrResult(#ref.func(UnsignedInt0), BWI) + rule #parseInstrx210s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx252(BytesWithIndex) [function, total] + + syntax InstrResult ::= #parseInstrx252p1(IntResult) [function, total] + | #parseInstrx252p2(Int, BytesWithIndex) [function, total] + rule parseInstrx252(BWI:BytesWithIndex) => #parseInstrx252p1(parseByteAsInt(BWI)) + rule #parseInstrx252p1(intResult(I:Int, BWI:BytesWithIndex)) => #parseInstrx252p2(I, BWI) + rule #parseInstrx252p1(E:ParseError) => E + rule #parseInstrx252p2(0, BWI:BytesWithIndex) => parseInstrx252x0(BWI) + rule #parseInstrx252p2(1, BWI:BytesWithIndex) => parseInstrx252x1(BWI) + rule #parseInstrx252p2(2, BWI:BytesWithIndex) => parseInstrx252x2(BWI) + rule #parseInstrx252p2(3, BWI:BytesWithIndex) => parseInstrx252x3(BWI) + rule #parseInstrx252p2(4, BWI:BytesWithIndex) => parseInstrx252x4(BWI) + rule #parseInstrx252p2(5, BWI:BytesWithIndex) => parseInstrx252x5(BWI) + rule #parseInstrx252p2(6, BWI:BytesWithIndex) => parseInstrx252x6(BWI) + rule #parseInstrx252p2(7, BWI:BytesWithIndex) => parseInstrx252x7(BWI) + rule #parseInstrx252p2(8, BWI:BytesWithIndex) => parseInstrx252x8(BWI) + rule #parseInstrx252p2(9, BWI:BytesWithIndex) => parseInstrx252x9(BWI) + rule #parseInstrx252p2(10, BWI:BytesWithIndex) => parseInstrx252x10(BWI) + rule #parseInstrx252p2(11, BWI:BytesWithIndex) => parseInstrx252x11(BWI) + rule #parseInstrx252p2(12, BWI:BytesWithIndex) => parseInstrx252x12(BWI) + rule #parseInstrx252p2(13, BWI:BytesWithIndex) => parseInstrx252x13(BWI) + rule #parseInstrx252p2(14, BWI:BytesWithIndex) => parseInstrx252x14(BWI) + rule #parseInstrx252p2(15, BWI:BytesWithIndex) => parseInstrx252x15(BWI) + rule #parseInstrx252p2(16, BWI:BytesWithIndex) => parseInstrx252x16(BWI) + rule #parseInstrx252p2(17, BWI:BytesWithIndex) => parseInstrx252x17(BWI) + rule #parseInstrx252p2(I:Int, bwi(B:Bytes, Index:Int)) => parseError("#parseInstrx252p2", ListItem(I) ListItem(Index) ListItem(lengthBytes(B)) ListItem(B)) [owise] + + syntax InstrResult ::= parseInstrx252x0(BytesWithIndex) [function, total] + rule parseInstrx252x0(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx252x1(BytesWithIndex) [function, total] + rule parseInstrx252x1(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx252x2(BytesWithIndex) [function, total] + rule parseInstrx252x2(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx252x3(BytesWithIndex) [function, total] + rule parseInstrx252x3(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx252x4(BytesWithIndex) [function, total] + rule parseInstrx252x4(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx252x5(BytesWithIndex) [function, total] + rule parseInstrx252x5(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx252x6(BytesWithIndex) [function, total] + rule parseInstrx252x6(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx252x7(BytesWithIndex) [function, total] + rule parseInstrx252x7(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx252x8(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx252x8s1 + ( IntResult + ) [function, total] + rule parseInstrx252x8(BWI) => #parseInstrx252x8s1(parseLeb128UInt(BWI)) + syntax InstrResult ::= #parseInstrx252x8s2 + ( Int + , BytesWithIndexOrError + ) [function, total] + rule #parseInstrx252x8s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => #parseInstrx252x8s2(UnsignedInt0, parseConstant(BWI, b"\x00")) + rule #parseInstrx252x8s1(E:ParseError) => E + rule #parseInstrx252x8s2(UnsignedInt0:Int, BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(UnsignedInt0) ListItem(BWI)) + rule #parseInstrx252x8s2(_UnsignedInt0:Int, E:ParseError) => E + syntax InstrResult ::= parseInstrx252x9(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx252x9s1 + ( IntResult + ) [function, total] + rule parseInstrx252x9(BWI) => #parseInstrx252x9s1(parseLeb128UInt(BWI)) + rule #parseInstrx252x9s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(UnsignedInt0) ListItem(BWI)) + rule #parseInstrx252x9s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx252x10(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx252x10s1 + ( BytesWithIndexOrError + ) [function, total] + rule parseInstrx252x10(BWI) => #parseInstrx252x10s1(parseConstant(BWI, b"\x00")) + syntax InstrResult ::= #parseInstrx252x10s2 + ( BytesWithIndexOrError + ) [function, total] + rule #parseInstrx252x10s1(BWI) => #parseInstrx252x10s2(parseConstant(BWI, b"\x00")) + rule #parseInstrx252x10s1(E:ParseError) => E + rule #parseInstrx252x10s2(BWI:BytesWithIndex) => instrResult(memory.copy, BWI) + rule #parseInstrx252x10s2(E:ParseError) => E + syntax InstrResult ::= parseInstrx252x11(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx252x11s1 + ( BytesWithIndexOrError + ) [function, total] + rule parseInstrx252x11(BWI) => #parseInstrx252x11s1(parseConstant(BWI, b"\x00")) + rule #parseInstrx252x11s1(BWI:BytesWithIndex) => instrResult(memory.fill, BWI) + rule #parseInstrx252x11s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx252x12(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx252x12s1 + ( IntResult + ) [function, total] + rule parseInstrx252x12(BWI) => #parseInstrx252x12s1(parseLeb128UInt(BWI)) + syntax InstrResult ::= #parseInstrx252x12s2 + ( Int + , IntResult + ) [function, total] + rule #parseInstrx252x12s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => #parseInstrx252x12s2(UnsignedInt0, parseLeb128UInt(BWI)) + rule #parseInstrx252x12s1(E:ParseError) => E + rule #parseInstrx252x12s2(UnsignedInt0:Int, intResult(UnsignedInt1:Int, BWI:BytesWithIndex)) => instrResult(#table.init(UnsignedInt0, UnsignedInt1), BWI) + rule #parseInstrx252x12s2(_UnsignedInt0:Int, E:ParseError) => E + syntax InstrResult ::= parseInstrx252x13(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx252x13s1 + ( IntResult + ) [function, total] + rule parseInstrx252x13(BWI) => #parseInstrx252x13s1(parseLeb128UInt(BWI)) + rule #parseInstrx252x13s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => instrResult(#elem.drop(UnsignedInt0), BWI) + rule #parseInstrx252x13s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx252x14(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx252x14s1 + ( IntResult + ) [function, total] + rule parseInstrx252x14(BWI) => #parseInstrx252x14s1(parseLeb128UInt(BWI)) + syntax InstrResult ::= #parseInstrx252x14s2 + ( Int + , IntResult + ) [function, total] + rule #parseInstrx252x14s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => #parseInstrx252x14s2(UnsignedInt0, parseLeb128UInt(BWI)) + rule #parseInstrx252x14s1(E:ParseError) => E + rule #parseInstrx252x14s2(UnsignedInt0:Int, intResult(UnsignedInt1:Int, BWI:BytesWithIndex)) => instrResult(#table.copy(UnsignedInt0, UnsignedInt1), BWI) + rule #parseInstrx252x14s2(_UnsignedInt0:Int, E:ParseError) => E + syntax InstrResult ::= parseInstrx252x15(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx252x15s1 + ( IntResult + ) [function, total] + rule parseInstrx252x15(BWI) => #parseInstrx252x15s1(parseLeb128UInt(BWI)) + rule #parseInstrx252x15s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => instrResult(#table.grow(UnsignedInt0), BWI) + rule #parseInstrx252x15s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx252x16(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx252x16s1 + ( IntResult + ) [function, total] + rule parseInstrx252x16(BWI) => #parseInstrx252x16s1(parseLeb128UInt(BWI)) + rule #parseInstrx252x16s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => instrResult(#table.size(UnsignedInt0), BWI) + rule #parseInstrx252x16s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx252x17(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx252x17s1 + ( IntResult + ) [function, total] + rule parseInstrx252x17(BWI) => #parseInstrx252x17s1(parseLeb128UInt(BWI)) + rule #parseInstrx252x17s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => instrResult(#table.fill(UnsignedInt0), BWI) + rule #parseInstrx252x17s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253(BytesWithIndex) [function, total] + + syntax InstrResult ::= #parseInstrx253p1(IntResult) [function, total] + | #parseInstrx253p2(Int, BytesWithIndex) [function, total] + rule parseInstrx253(BWI:BytesWithIndex) => #parseInstrx253p1(parseByteAsInt(BWI)) + rule #parseInstrx253p1(intResult(I:Int, BWI:BytesWithIndex)) => #parseInstrx253p2(I, BWI) + rule #parseInstrx253p1(E:ParseError) => E + rule #parseInstrx253p2(0, BWI:BytesWithIndex) => parseInstrx253x0(BWI) + rule #parseInstrx253p2(1, BWI:BytesWithIndex) => parseInstrx253x1(BWI) + rule #parseInstrx253p2(2, BWI:BytesWithIndex) => parseInstrx253x2(BWI) + rule #parseInstrx253p2(3, BWI:BytesWithIndex) => parseInstrx253x3(BWI) + rule #parseInstrx253p2(4, BWI:BytesWithIndex) => parseInstrx253x4(BWI) + rule #parseInstrx253p2(5, BWI:BytesWithIndex) => parseInstrx253x5(BWI) + rule #parseInstrx253p2(6, BWI:BytesWithIndex) => parseInstrx253x6(BWI) + rule #parseInstrx253p2(7, BWI:BytesWithIndex) => parseInstrx253x7(BWI) + rule #parseInstrx253p2(8, BWI:BytesWithIndex) => parseInstrx253x8(BWI) + rule #parseInstrx253p2(9, BWI:BytesWithIndex) => parseInstrx253x9(BWI) + rule #parseInstrx253p2(10, BWI:BytesWithIndex) => parseInstrx253x10(BWI) + rule #parseInstrx253p2(11, BWI:BytesWithIndex) => parseInstrx253x11(BWI) + rule #parseInstrx253p2(12, BWI:BytesWithIndex) => parseInstrx253x12(BWI) + rule #parseInstrx253p2(13, BWI:BytesWithIndex) => parseInstrx253x13(BWI) + rule #parseInstrx253p2(14, BWI:BytesWithIndex) => parseInstrx253x14(BWI) + rule #parseInstrx253p2(15, BWI:BytesWithIndex) => parseInstrx253x15(BWI) + rule #parseInstrx253p2(16, BWI:BytesWithIndex) => parseInstrx253x16(BWI) + rule #parseInstrx253p2(17, BWI:BytesWithIndex) => parseInstrx253x17(BWI) + rule #parseInstrx253p2(18, BWI:BytesWithIndex) => parseInstrx253x18(BWI) + rule #parseInstrx253p2(19, BWI:BytesWithIndex) => parseInstrx253x19(BWI) + rule #parseInstrx253p2(20, BWI:BytesWithIndex) => parseInstrx253x20(BWI) + rule #parseInstrx253p2(21, BWI:BytesWithIndex) => parseInstrx253x21(BWI) + rule #parseInstrx253p2(22, BWI:BytesWithIndex) => parseInstrx253x22(BWI) + rule #parseInstrx253p2(23, BWI:BytesWithIndex) => parseInstrx253x23(BWI) + rule #parseInstrx253p2(24, BWI:BytesWithIndex) => parseInstrx253x24(BWI) + rule #parseInstrx253p2(25, BWI:BytesWithIndex) => parseInstrx253x25(BWI) + rule #parseInstrx253p2(26, BWI:BytesWithIndex) => parseInstrx253x26(BWI) + rule #parseInstrx253p2(27, BWI:BytesWithIndex) => parseInstrx253x27(BWI) + rule #parseInstrx253p2(28, BWI:BytesWithIndex) => parseInstrx253x28(BWI) + rule #parseInstrx253p2(29, BWI:BytesWithIndex) => parseInstrx253x29(BWI) + rule #parseInstrx253p2(30, BWI:BytesWithIndex) => parseInstrx253x30(BWI) + rule #parseInstrx253p2(31, BWI:BytesWithIndex) => parseInstrx253x31(BWI) + rule #parseInstrx253p2(32, BWI:BytesWithIndex) => parseInstrx253x32(BWI) + rule #parseInstrx253p2(33, BWI:BytesWithIndex) => parseInstrx253x33(BWI) + rule #parseInstrx253p2(34, BWI:BytesWithIndex) => parseInstrx253x34(BWI) + rule #parseInstrx253p2(35, BWI:BytesWithIndex) => parseInstrx253x35(BWI) + rule #parseInstrx253p2(36, BWI:BytesWithIndex) => parseInstrx253x36(BWI) + rule #parseInstrx253p2(37, BWI:BytesWithIndex) => parseInstrx253x37(BWI) + rule #parseInstrx253p2(38, BWI:BytesWithIndex) => parseInstrx253x38(BWI) + rule #parseInstrx253p2(39, BWI:BytesWithIndex) => parseInstrx253x39(BWI) + rule #parseInstrx253p2(40, BWI:BytesWithIndex) => parseInstrx253x40(BWI) + rule #parseInstrx253p2(41, BWI:BytesWithIndex) => parseInstrx253x41(BWI) + rule #parseInstrx253p2(42, BWI:BytesWithIndex) => parseInstrx253x42(BWI) + rule #parseInstrx253p2(43, BWI:BytesWithIndex) => parseInstrx253x43(BWI) + rule #parseInstrx253p2(44, BWI:BytesWithIndex) => parseInstrx253x44(BWI) + rule #parseInstrx253p2(45, BWI:BytesWithIndex) => parseInstrx253x45(BWI) + rule #parseInstrx253p2(46, BWI:BytesWithIndex) => parseInstrx253x46(BWI) + rule #parseInstrx253p2(47, BWI:BytesWithIndex) => parseInstrx253x47(BWI) + rule #parseInstrx253p2(48, BWI:BytesWithIndex) => parseInstrx253x48(BWI) + rule #parseInstrx253p2(49, BWI:BytesWithIndex) => parseInstrx253x49(BWI) + rule #parseInstrx253p2(50, BWI:BytesWithIndex) => parseInstrx253x50(BWI) + rule #parseInstrx253p2(51, BWI:BytesWithIndex) => parseInstrx253x51(BWI) + rule #parseInstrx253p2(52, BWI:BytesWithIndex) => parseInstrx253x52(BWI) + rule #parseInstrx253p2(53, BWI:BytesWithIndex) => parseInstrx253x53(BWI) + rule #parseInstrx253p2(54, BWI:BytesWithIndex) => parseInstrx253x54(BWI) + rule #parseInstrx253p2(55, BWI:BytesWithIndex) => parseInstrx253x55(BWI) + rule #parseInstrx253p2(56, BWI:BytesWithIndex) => parseInstrx253x56(BWI) + rule #parseInstrx253p2(57, BWI:BytesWithIndex) => parseInstrx253x57(BWI) + rule #parseInstrx253p2(58, BWI:BytesWithIndex) => parseInstrx253x58(BWI) + rule #parseInstrx253p2(59, BWI:BytesWithIndex) => parseInstrx253x59(BWI) + rule #parseInstrx253p2(60, BWI:BytesWithIndex) => parseInstrx253x60(BWI) + rule #parseInstrx253p2(61, BWI:BytesWithIndex) => parseInstrx253x61(BWI) + rule #parseInstrx253p2(62, BWI:BytesWithIndex) => parseInstrx253x62(BWI) + rule #parseInstrx253p2(63, BWI:BytesWithIndex) => parseInstrx253x63(BWI) + rule #parseInstrx253p2(64, BWI:BytesWithIndex) => parseInstrx253x64(BWI) + rule #parseInstrx253p2(65, BWI:BytesWithIndex) => parseInstrx253x65(BWI) + rule #parseInstrx253p2(66, BWI:BytesWithIndex) => parseInstrx253x66(BWI) + rule #parseInstrx253p2(67, BWI:BytesWithIndex) => parseInstrx253x67(BWI) + rule #parseInstrx253p2(68, BWI:BytesWithIndex) => parseInstrx253x68(BWI) + rule #parseInstrx253p2(69, BWI:BytesWithIndex) => parseInstrx253x69(BWI) + rule #parseInstrx253p2(70, BWI:BytesWithIndex) => parseInstrx253x70(BWI) + rule #parseInstrx253p2(71, BWI:BytesWithIndex) => parseInstrx253x71(BWI) + rule #parseInstrx253p2(72, BWI:BytesWithIndex) => parseInstrx253x72(BWI) + rule #parseInstrx253p2(73, BWI:BytesWithIndex) => parseInstrx253x73(BWI) + rule #parseInstrx253p2(74, BWI:BytesWithIndex) => parseInstrx253x74(BWI) + rule #parseInstrx253p2(75, BWI:BytesWithIndex) => parseInstrx253x75(BWI) + rule #parseInstrx253p2(76, BWI:BytesWithIndex) => parseInstrx253x76(BWI) + rule #parseInstrx253p2(77, BWI:BytesWithIndex) => parseInstrx253x77(BWI) + rule #parseInstrx253p2(78, BWI:BytesWithIndex) => parseInstrx253x78(BWI) + rule #parseInstrx253p2(79, BWI:BytesWithIndex) => parseInstrx253x79(BWI) + rule #parseInstrx253p2(80, BWI:BytesWithIndex) => parseInstrx253x80(BWI) + rule #parseInstrx253p2(81, BWI:BytesWithIndex) => parseInstrx253x81(BWI) + rule #parseInstrx253p2(82, BWI:BytesWithIndex) => parseInstrx253x82(BWI) + rule #parseInstrx253p2(83, BWI:BytesWithIndex) => parseInstrx253x83(BWI) + rule #parseInstrx253p2(84, BWI:BytesWithIndex) => parseInstrx253x84(BWI) + rule #parseInstrx253p2(85, BWI:BytesWithIndex) => parseInstrx253x85(BWI) + rule #parseInstrx253p2(86, BWI:BytesWithIndex) => parseInstrx253x86(BWI) + rule #parseInstrx253p2(87, BWI:BytesWithIndex) => parseInstrx253x87(BWI) + rule #parseInstrx253p2(88, BWI:BytesWithIndex) => parseInstrx253x88(BWI) + rule #parseInstrx253p2(89, BWI:BytesWithIndex) => parseInstrx253x89(BWI) + rule #parseInstrx253p2(90, BWI:BytesWithIndex) => parseInstrx253x90(BWI) + rule #parseInstrx253p2(91, BWI:BytesWithIndex) => parseInstrx253x91(BWI) + rule #parseInstrx253p2(92, BWI:BytesWithIndex) => parseInstrx253x92(BWI) + rule #parseInstrx253p2(93, BWI:BytesWithIndex) => parseInstrx253x93(BWI) + rule #parseInstrx253p2(94, BWI:BytesWithIndex) => parseInstrx253x94(BWI) + rule #parseInstrx253p2(95, BWI:BytesWithIndex) => parseInstrx253x95(BWI) + rule #parseInstrx253p2(96, BWI:BytesWithIndex) => parseInstrx253x96(BWI) + rule #parseInstrx253p2(97, BWI:BytesWithIndex) => parseInstrx253x97(BWI) + rule #parseInstrx253p2(98, BWI:BytesWithIndex) => parseInstrx253x98(BWI) + rule #parseInstrx253p2(99, BWI:BytesWithIndex) => parseInstrx253x99(BWI) + rule #parseInstrx253p2(100, BWI:BytesWithIndex) => parseInstrx253x100(BWI) + rule #parseInstrx253p2(101, BWI:BytesWithIndex) => parseInstrx253x101(BWI) + rule #parseInstrx253p2(102, BWI:BytesWithIndex) => parseInstrx253x102(BWI) + rule #parseInstrx253p2(103, BWI:BytesWithIndex) => parseInstrx253x103(BWI) + rule #parseInstrx253p2(104, BWI:BytesWithIndex) => parseInstrx253x104(BWI) + rule #parseInstrx253p2(105, BWI:BytesWithIndex) => parseInstrx253x105(BWI) + rule #parseInstrx253p2(106, BWI:BytesWithIndex) => parseInstrx253x106(BWI) + rule #parseInstrx253p2(107, BWI:BytesWithIndex) => parseInstrx253x107(BWI) + rule #parseInstrx253p2(108, BWI:BytesWithIndex) => parseInstrx253x108(BWI) + rule #parseInstrx253p2(109, BWI:BytesWithIndex) => parseInstrx253x109(BWI) + rule #parseInstrx253p2(110, BWI:BytesWithIndex) => parseInstrx253x110(BWI) + rule #parseInstrx253p2(111, BWI:BytesWithIndex) => parseInstrx253x111(BWI) + rule #parseInstrx253p2(112, BWI:BytesWithIndex) => parseInstrx253x112(BWI) + rule #parseInstrx253p2(113, BWI:BytesWithIndex) => parseInstrx253x113(BWI) + rule #parseInstrx253p2(114, BWI:BytesWithIndex) => parseInstrx253x114(BWI) + rule #parseInstrx253p2(115, BWI:BytesWithIndex) => parseInstrx253x115(BWI) + rule #parseInstrx253p2(116, BWI:BytesWithIndex) => parseInstrx253x116(BWI) + rule #parseInstrx253p2(117, BWI:BytesWithIndex) => parseInstrx253x117(BWI) + rule #parseInstrx253p2(118, BWI:BytesWithIndex) => parseInstrx253x118(BWI) + rule #parseInstrx253p2(119, BWI:BytesWithIndex) => parseInstrx253x119(BWI) + rule #parseInstrx253p2(120, BWI:BytesWithIndex) => parseInstrx253x120(BWI) + rule #parseInstrx253p2(121, BWI:BytesWithIndex) => parseInstrx253x121(BWI) + rule #parseInstrx253p2(122, BWI:BytesWithIndex) => parseInstrx253x122(BWI) + rule #parseInstrx253p2(123, BWI:BytesWithIndex) => parseInstrx253x123(BWI) + rule #parseInstrx253p2(124, BWI:BytesWithIndex) => parseInstrx253x124(BWI) + rule #parseInstrx253p2(125, BWI:BytesWithIndex) => parseInstrx253x125(BWI) + rule #parseInstrx253p2(126, BWI:BytesWithIndex) => parseInstrx253x126(BWI) + rule #parseInstrx253p2(127, BWI:BytesWithIndex) => parseInstrx253x127(BWI) + rule #parseInstrx253p2(128, BWI:BytesWithIndex) => parseInstrx253x128(BWI) + rule #parseInstrx253p2(129, BWI:BytesWithIndex) => parseInstrx253x129(BWI) + rule #parseInstrx253p2(130, BWI:BytesWithIndex) => parseInstrx253x130(BWI) + rule #parseInstrx253p2(131, BWI:BytesWithIndex) => parseInstrx253x131(BWI) + rule #parseInstrx253p2(132, BWI:BytesWithIndex) => parseInstrx253x132(BWI) + rule #parseInstrx253p2(133, BWI:BytesWithIndex) => parseInstrx253x133(BWI) + rule #parseInstrx253p2(134, BWI:BytesWithIndex) => parseInstrx253x134(BWI) + rule #parseInstrx253p2(135, BWI:BytesWithIndex) => parseInstrx253x135(BWI) + rule #parseInstrx253p2(136, BWI:BytesWithIndex) => parseInstrx253x136(BWI) + rule #parseInstrx253p2(137, BWI:BytesWithIndex) => parseInstrx253x137(BWI) + rule #parseInstrx253p2(138, BWI:BytesWithIndex) => parseInstrx253x138(BWI) + rule #parseInstrx253p2(139, BWI:BytesWithIndex) => parseInstrx253x139(BWI) + rule #parseInstrx253p2(140, BWI:BytesWithIndex) => parseInstrx253x140(BWI) + rule #parseInstrx253p2(141, BWI:BytesWithIndex) => parseInstrx253x141(BWI) + rule #parseInstrx253p2(142, BWI:BytesWithIndex) => parseInstrx253x142(BWI) + rule #parseInstrx253p2(143, BWI:BytesWithIndex) => parseInstrx253x143(BWI) + rule #parseInstrx253p2(144, BWI:BytesWithIndex) => parseInstrx253x144(BWI) + rule #parseInstrx253p2(145, BWI:BytesWithIndex) => parseInstrx253x145(BWI) + rule #parseInstrx253p2(146, BWI:BytesWithIndex) => parseInstrx253x146(BWI) + rule #parseInstrx253p2(147, BWI:BytesWithIndex) => parseInstrx253x147(BWI) + rule #parseInstrx253p2(148, BWI:BytesWithIndex) => parseInstrx253x148(BWI) + rule #parseInstrx253p2(149, BWI:BytesWithIndex) => parseInstrx253x149(BWI) + rule #parseInstrx253p2(150, BWI:BytesWithIndex) => parseInstrx253x150(BWI) + rule #parseInstrx253p2(151, BWI:BytesWithIndex) => parseInstrx253x151(BWI) + rule #parseInstrx253p2(152, BWI:BytesWithIndex) => parseInstrx253x152(BWI) + rule #parseInstrx253p2(153, BWI:BytesWithIndex) => parseInstrx253x153(BWI) + rule #parseInstrx253p2(155, BWI:BytesWithIndex) => parseInstrx253x155(BWI) + rule #parseInstrx253p2(156, BWI:BytesWithIndex) => parseInstrx253x156(BWI) + rule #parseInstrx253p2(157, BWI:BytesWithIndex) => parseInstrx253x157(BWI) + rule #parseInstrx253p2(158, BWI:BytesWithIndex) => parseInstrx253x158(BWI) + rule #parseInstrx253p2(159, BWI:BytesWithIndex) => parseInstrx253x159(BWI) + rule #parseInstrx253p2(160, BWI:BytesWithIndex) => parseInstrx253x160(BWI) + rule #parseInstrx253p2(161, BWI:BytesWithIndex) => parseInstrx253x161(BWI) + rule #parseInstrx253p2(163, BWI:BytesWithIndex) => parseInstrx253x163(BWI) + rule #parseInstrx253p2(164, BWI:BytesWithIndex) => parseInstrx253x164(BWI) + rule #parseInstrx253p2(167, BWI:BytesWithIndex) => parseInstrx253x167(BWI) + rule #parseInstrx253p2(168, BWI:BytesWithIndex) => parseInstrx253x168(BWI) + rule #parseInstrx253p2(169, BWI:BytesWithIndex) => parseInstrx253x169(BWI) + rule #parseInstrx253p2(170, BWI:BytesWithIndex) => parseInstrx253x170(BWI) + rule #parseInstrx253p2(171, BWI:BytesWithIndex) => parseInstrx253x171(BWI) + rule #parseInstrx253p2(172, BWI:BytesWithIndex) => parseInstrx253x172(BWI) + rule #parseInstrx253p2(173, BWI:BytesWithIndex) => parseInstrx253x173(BWI) + rule #parseInstrx253p2(174, BWI:BytesWithIndex) => parseInstrx253x174(BWI) + rule #parseInstrx253p2(177, BWI:BytesWithIndex) => parseInstrx253x177(BWI) + rule #parseInstrx253p2(181, BWI:BytesWithIndex) => parseInstrx253x181(BWI) + rule #parseInstrx253p2(182, BWI:BytesWithIndex) => parseInstrx253x182(BWI) + rule #parseInstrx253p2(183, BWI:BytesWithIndex) => parseInstrx253x183(BWI) + rule #parseInstrx253p2(184, BWI:BytesWithIndex) => parseInstrx253x184(BWI) + rule #parseInstrx253p2(185, BWI:BytesWithIndex) => parseInstrx253x185(BWI) + rule #parseInstrx253p2(186, BWI:BytesWithIndex) => parseInstrx253x186(BWI) + rule #parseInstrx253p2(188, BWI:BytesWithIndex) => parseInstrx253x188(BWI) + rule #parseInstrx253p2(189, BWI:BytesWithIndex) => parseInstrx253x189(BWI) + rule #parseInstrx253p2(190, BWI:BytesWithIndex) => parseInstrx253x190(BWI) + rule #parseInstrx253p2(191, BWI:BytesWithIndex) => parseInstrx253x191(BWI) + rule #parseInstrx253p2(192, BWI:BytesWithIndex) => parseInstrx253x192(BWI) + rule #parseInstrx253p2(193, BWI:BytesWithIndex) => parseInstrx253x193(BWI) + rule #parseInstrx253p2(195, BWI:BytesWithIndex) => parseInstrx253x195(BWI) + rule #parseInstrx253p2(196, BWI:BytesWithIndex) => parseInstrx253x196(BWI) + rule #parseInstrx253p2(199, BWI:BytesWithIndex) => parseInstrx253x199(BWI) + rule #parseInstrx253p2(200, BWI:BytesWithIndex) => parseInstrx253x200(BWI) + rule #parseInstrx253p2(201, BWI:BytesWithIndex) => parseInstrx253x201(BWI) + rule #parseInstrx253p2(202, BWI:BytesWithIndex) => parseInstrx253x202(BWI) + rule #parseInstrx253p2(203, BWI:BytesWithIndex) => parseInstrx253x203(BWI) + rule #parseInstrx253p2(204, BWI:BytesWithIndex) => parseInstrx253x204(BWI) + rule #parseInstrx253p2(205, BWI:BytesWithIndex) => parseInstrx253x205(BWI) + rule #parseInstrx253p2(206, BWI:BytesWithIndex) => parseInstrx253x206(BWI) + rule #parseInstrx253p2(209, BWI:BytesWithIndex) => parseInstrx253x209(BWI) + rule #parseInstrx253p2(213, BWI:BytesWithIndex) => parseInstrx253x213(BWI) + rule #parseInstrx253p2(214, BWI:BytesWithIndex) => parseInstrx253x214(BWI) + rule #parseInstrx253p2(215, BWI:BytesWithIndex) => parseInstrx253x215(BWI) + rule #parseInstrx253p2(216, BWI:BytesWithIndex) => parseInstrx253x216(BWI) + rule #parseInstrx253p2(217, BWI:BytesWithIndex) => parseInstrx253x217(BWI) + rule #parseInstrx253p2(218, BWI:BytesWithIndex) => parseInstrx253x218(BWI) + rule #parseInstrx253p2(219, BWI:BytesWithIndex) => parseInstrx253x219(BWI) + rule #parseInstrx253p2(220, BWI:BytesWithIndex) => parseInstrx253x220(BWI) + rule #parseInstrx253p2(221, BWI:BytesWithIndex) => parseInstrx253x221(BWI) + rule #parseInstrx253p2(222, BWI:BytesWithIndex) => parseInstrx253x222(BWI) + rule #parseInstrx253p2(223, BWI:BytesWithIndex) => parseInstrx253x223(BWI) + rule #parseInstrx253p2(224, BWI:BytesWithIndex) => parseInstrx253x224(BWI) + rule #parseInstrx253p2(225, BWI:BytesWithIndex) => parseInstrx253x225(BWI) + rule #parseInstrx253p2(227, BWI:BytesWithIndex) => parseInstrx253x227(BWI) + rule #parseInstrx253p2(228, BWI:BytesWithIndex) => parseInstrx253x228(BWI) + rule #parseInstrx253p2(229, BWI:BytesWithIndex) => parseInstrx253x229(BWI) + rule #parseInstrx253p2(230, BWI:BytesWithIndex) => parseInstrx253x230(BWI) + rule #parseInstrx253p2(231, BWI:BytesWithIndex) => parseInstrx253x231(BWI) + rule #parseInstrx253p2(232, BWI:BytesWithIndex) => parseInstrx253x232(BWI) + rule #parseInstrx253p2(233, BWI:BytesWithIndex) => parseInstrx253x233(BWI) + rule #parseInstrx253p2(234, BWI:BytesWithIndex) => parseInstrx253x234(BWI) + rule #parseInstrx253p2(235, BWI:BytesWithIndex) => parseInstrx253x235(BWI) + rule #parseInstrx253p2(236, BWI:BytesWithIndex) => parseInstrx253x236(BWI) + rule #parseInstrx253p2(237, BWI:BytesWithIndex) => parseInstrx253x237(BWI) + rule #parseInstrx253p2(239, BWI:BytesWithIndex) => parseInstrx253x239(BWI) + rule #parseInstrx253p2(240, BWI:BytesWithIndex) => parseInstrx253x240(BWI) + rule #parseInstrx253p2(241, BWI:BytesWithIndex) => parseInstrx253x241(BWI) + rule #parseInstrx253p2(242, BWI:BytesWithIndex) => parseInstrx253x242(BWI) + rule #parseInstrx253p2(243, BWI:BytesWithIndex) => parseInstrx253x243(BWI) + rule #parseInstrx253p2(244, BWI:BytesWithIndex) => parseInstrx253x244(BWI) + rule #parseInstrx253p2(245, BWI:BytesWithIndex) => parseInstrx253x245(BWI) + rule #parseInstrx253p2(246, BWI:BytesWithIndex) => parseInstrx253x246(BWI) + rule #parseInstrx253p2(247, BWI:BytesWithIndex) => parseInstrx253x247(BWI) + rule #parseInstrx253p2(248, BWI:BytesWithIndex) => parseInstrx253x248(BWI) + rule #parseInstrx253p2(249, BWI:BytesWithIndex) => parseInstrx253x249(BWI) + rule #parseInstrx253p2(250, BWI:BytesWithIndex) => parseInstrx253x250(BWI) + rule #parseInstrx253p2(251, BWI:BytesWithIndex) => parseInstrx253x251(BWI) + rule #parseInstrx253p2(252, BWI:BytesWithIndex) => parseInstrx253x252(BWI) + rule #parseInstrx253p2(253, BWI:BytesWithIndex) => parseInstrx253x253(BWI) + rule #parseInstrx253p2(254, BWI:BytesWithIndex) => parseInstrx253x254(BWI) + rule #parseInstrx253p2(255, BWI:BytesWithIndex) => parseInstrx253x255(BWI) + rule #parseInstrx253p2(I:Int, bwi(B:Bytes, Index:Int)) => parseError("#parseInstrx253p2", ListItem(I) ListItem(Index) ListItem(lengthBytes(B)) ListItem(B)) [owise] + + syntax InstrResult ::= parseInstrx253x0(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x0s1 + ( MemArgResult + ) [function, total] + rule parseInstrx253x0(BWI) => #parseInstrx253x0s1(parseMemArg(BWI)) + rule #parseInstrx253x0s1(memArgResult(MemArg0:MemArg, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(MemArg0) ListItem(BWI)) + rule #parseInstrx253x0s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x1(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x1s1 + ( MemArgResult + ) [function, total] + rule parseInstrx253x1(BWI) => #parseInstrx253x1s1(parseMemArg(BWI)) + rule #parseInstrx253x1s1(memArgResult(MemArg0:MemArg, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(MemArg0) ListItem(BWI)) + rule #parseInstrx253x1s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x2(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x2s1 + ( MemArgResult + ) [function, total] + rule parseInstrx253x2(BWI) => #parseInstrx253x2s1(parseMemArg(BWI)) + rule #parseInstrx253x2s1(memArgResult(MemArg0:MemArg, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(MemArg0) ListItem(BWI)) + rule #parseInstrx253x2s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x3(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x3s1 + ( MemArgResult + ) [function, total] + rule parseInstrx253x3(BWI) => #parseInstrx253x3s1(parseMemArg(BWI)) + rule #parseInstrx253x3s1(memArgResult(MemArg0:MemArg, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(MemArg0) ListItem(BWI)) + rule #parseInstrx253x3s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x4(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x4s1 + ( MemArgResult + ) [function, total] + rule parseInstrx253x4(BWI) => #parseInstrx253x4s1(parseMemArg(BWI)) + rule #parseInstrx253x4s1(memArgResult(MemArg0:MemArg, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(MemArg0) ListItem(BWI)) + rule #parseInstrx253x4s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x5(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x5s1 + ( MemArgResult + ) [function, total] + rule parseInstrx253x5(BWI) => #parseInstrx253x5s1(parseMemArg(BWI)) + rule #parseInstrx253x5s1(memArgResult(MemArg0:MemArg, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(MemArg0) ListItem(BWI)) + rule #parseInstrx253x5s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x6(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x6s1 + ( MemArgResult + ) [function, total] + rule parseInstrx253x6(BWI) => #parseInstrx253x6s1(parseMemArg(BWI)) + rule #parseInstrx253x6s1(memArgResult(MemArg0:MemArg, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(MemArg0) ListItem(BWI)) + rule #parseInstrx253x6s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x7(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x7s1 + ( MemArgResult + ) [function, total] + rule parseInstrx253x7(BWI) => #parseInstrx253x7s1(parseMemArg(BWI)) + rule #parseInstrx253x7s1(memArgResult(MemArg0:MemArg, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(MemArg0) ListItem(BWI)) + rule #parseInstrx253x7s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x8(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x8s1 + ( MemArgResult + ) [function, total] + rule parseInstrx253x8(BWI) => #parseInstrx253x8s1(parseMemArg(BWI)) + rule #parseInstrx253x8s1(memArgResult(MemArg0:MemArg, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(MemArg0) ListItem(BWI)) + rule #parseInstrx253x8s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x9(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x9s1 + ( MemArgResult + ) [function, total] + rule parseInstrx253x9(BWI) => #parseInstrx253x9s1(parseMemArg(BWI)) + rule #parseInstrx253x9s1(memArgResult(MemArg0:MemArg, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(MemArg0) ListItem(BWI)) + rule #parseInstrx253x9s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x10(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x10s1 + ( MemArgResult + ) [function, total] + rule parseInstrx253x10(BWI) => #parseInstrx253x10s1(parseMemArg(BWI)) + rule #parseInstrx253x10s1(memArgResult(MemArg0:MemArg, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(MemArg0) ListItem(BWI)) + rule #parseInstrx253x10s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x11(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x11s1 + ( MemArgResult + ) [function, total] + rule parseInstrx253x11(BWI) => #parseInstrx253x11s1(parseMemArg(BWI)) + rule #parseInstrx253x11s1(memArgResult(MemArg0:MemArg, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(MemArg0) ListItem(BWI)) + rule #parseInstrx253x11s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x12(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x12s1 + ( BytesWithIndexOrError + ) [function, total] + rule parseInstrx253x12(BWI) => #parseInstrx253x12s1(ignoreBytes(BWI, 16)) + rule #parseInstrx253x12s1(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + rule #parseInstrx253x12s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x13(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x13s1 + ( BytesWithIndexOrError + ) [function, total] + rule parseInstrx253x13(BWI) => #parseInstrx253x13s1(ignoreUnsignedInt(BWI, 16)) + rule #parseInstrx253x13s1(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + rule #parseInstrx253x13s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x14(BytesWithIndex) [function, total] + rule parseInstrx253x14(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x15(BytesWithIndex) [function, total] + rule parseInstrx253x15(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x16(BytesWithIndex) [function, total] + rule parseInstrx253x16(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x17(BytesWithIndex) [function, total] + rule parseInstrx253x17(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x18(BytesWithIndex) [function, total] + rule parseInstrx253x18(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x19(BytesWithIndex) [function, total] + rule parseInstrx253x19(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x20(BytesWithIndex) [function, total] + rule parseInstrx253x20(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x21(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x21s1 + ( IntResult + ) [function, total] + rule parseInstrx253x21(BWI) => #parseInstrx253x21s1(parseLeb128UInt(BWI)) + rule #parseInstrx253x21s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(UnsignedInt0) ListItem(BWI)) + rule #parseInstrx253x21s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x22(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x22s1 + ( IntResult + ) [function, total] + rule parseInstrx253x22(BWI) => #parseInstrx253x22s1(parseLeb128UInt(BWI)) + rule #parseInstrx253x22s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(UnsignedInt0) ListItem(BWI)) + rule #parseInstrx253x22s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x23(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x23s1 + ( IntResult + ) [function, total] + rule parseInstrx253x23(BWI) => #parseInstrx253x23s1(parseLeb128UInt(BWI)) + rule #parseInstrx253x23s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(UnsignedInt0) ListItem(BWI)) + rule #parseInstrx253x23s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x24(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x24s1 + ( IntResult + ) [function, total] + rule parseInstrx253x24(BWI) => #parseInstrx253x24s1(parseLeb128UInt(BWI)) + rule #parseInstrx253x24s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(UnsignedInt0) ListItem(BWI)) + rule #parseInstrx253x24s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x25(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x25s1 + ( IntResult + ) [function, total] + rule parseInstrx253x25(BWI) => #parseInstrx253x25s1(parseLeb128UInt(BWI)) + rule #parseInstrx253x25s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(UnsignedInt0) ListItem(BWI)) + rule #parseInstrx253x25s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x26(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x26s1 + ( IntResult + ) [function, total] + rule parseInstrx253x26(BWI) => #parseInstrx253x26s1(parseLeb128UInt(BWI)) + rule #parseInstrx253x26s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(UnsignedInt0) ListItem(BWI)) + rule #parseInstrx253x26s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x27(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x27s1 + ( IntResult + ) [function, total] + rule parseInstrx253x27(BWI) => #parseInstrx253x27s1(parseLeb128UInt(BWI)) + rule #parseInstrx253x27s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(UnsignedInt0) ListItem(BWI)) + rule #parseInstrx253x27s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x28(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x28s1 + ( IntResult + ) [function, total] + rule parseInstrx253x28(BWI) => #parseInstrx253x28s1(parseLeb128UInt(BWI)) + rule #parseInstrx253x28s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(UnsignedInt0) ListItem(BWI)) + rule #parseInstrx253x28s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x29(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x29s1 + ( IntResult + ) [function, total] + rule parseInstrx253x29(BWI) => #parseInstrx253x29s1(parseLeb128UInt(BWI)) + rule #parseInstrx253x29s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(UnsignedInt0) ListItem(BWI)) + rule #parseInstrx253x29s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x30(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x30s1 + ( IntResult + ) [function, total] + rule parseInstrx253x30(BWI) => #parseInstrx253x30s1(parseLeb128UInt(BWI)) + rule #parseInstrx253x30s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(UnsignedInt0) ListItem(BWI)) + rule #parseInstrx253x30s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x31(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x31s1 + ( IntResult + ) [function, total] + rule parseInstrx253x31(BWI) => #parseInstrx253x31s1(parseLeb128UInt(BWI)) + rule #parseInstrx253x31s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(UnsignedInt0) ListItem(BWI)) + rule #parseInstrx253x31s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x32(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x32s1 + ( IntResult + ) [function, total] + rule parseInstrx253x32(BWI) => #parseInstrx253x32s1(parseLeb128UInt(BWI)) + rule #parseInstrx253x32s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(UnsignedInt0) ListItem(BWI)) + rule #parseInstrx253x32s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x33(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x33s1 + ( IntResult + ) [function, total] + rule parseInstrx253x33(BWI) => #parseInstrx253x33s1(parseLeb128UInt(BWI)) + rule #parseInstrx253x33s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(UnsignedInt0) ListItem(BWI)) + rule #parseInstrx253x33s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x34(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x34s1 + ( IntResult + ) [function, total] + rule parseInstrx253x34(BWI) => #parseInstrx253x34s1(parseLeb128UInt(BWI)) + rule #parseInstrx253x34s1(intResult(UnsignedInt0:Int, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(UnsignedInt0) ListItem(BWI)) + rule #parseInstrx253x34s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x35(BytesWithIndex) [function, total] + rule parseInstrx253x35(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x36(BytesWithIndex) [function, total] + rule parseInstrx253x36(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x37(BytesWithIndex) [function, total] + rule parseInstrx253x37(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x38(BytesWithIndex) [function, total] + rule parseInstrx253x38(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x39(BytesWithIndex) [function, total] + rule parseInstrx253x39(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x40(BytesWithIndex) [function, total] + rule parseInstrx253x40(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x41(BytesWithIndex) [function, total] + rule parseInstrx253x41(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x42(BytesWithIndex) [function, total] + rule parseInstrx253x42(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x43(BytesWithIndex) [function, total] + rule parseInstrx253x43(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x44(BytesWithIndex) [function, total] + rule parseInstrx253x44(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x45(BytesWithIndex) [function, total] + rule parseInstrx253x45(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x46(BytesWithIndex) [function, total] + rule parseInstrx253x46(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x47(BytesWithIndex) [function, total] + rule parseInstrx253x47(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x48(BytesWithIndex) [function, total] + rule parseInstrx253x48(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x49(BytesWithIndex) [function, total] + rule parseInstrx253x49(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x50(BytesWithIndex) [function, total] + rule parseInstrx253x50(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x51(BytesWithIndex) [function, total] + rule parseInstrx253x51(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x52(BytesWithIndex) [function, total] + rule parseInstrx253x52(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x53(BytesWithIndex) [function, total] + rule parseInstrx253x53(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x54(BytesWithIndex) [function, total] + rule parseInstrx253x54(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x55(BytesWithIndex) [function, total] + rule parseInstrx253x55(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x56(BytesWithIndex) [function, total] + rule parseInstrx253x56(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x57(BytesWithIndex) [function, total] + rule parseInstrx253x57(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x58(BytesWithIndex) [function, total] + rule parseInstrx253x58(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x59(BytesWithIndex) [function, total] + rule parseInstrx253x59(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x60(BytesWithIndex) [function, total] + rule parseInstrx253x60(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x61(BytesWithIndex) [function, total] + rule parseInstrx253x61(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x62(BytesWithIndex) [function, total] + rule parseInstrx253x62(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x63(BytesWithIndex) [function, total] + rule parseInstrx253x63(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x64(BytesWithIndex) [function, total] + rule parseInstrx253x64(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x65(BytesWithIndex) [function, total] + rule parseInstrx253x65(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x66(BytesWithIndex) [function, total] + rule parseInstrx253x66(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x67(BytesWithIndex) [function, total] + rule parseInstrx253x67(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x68(BytesWithIndex) [function, total] + rule parseInstrx253x68(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x69(BytesWithIndex) [function, total] + rule parseInstrx253x69(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x70(BytesWithIndex) [function, total] + rule parseInstrx253x70(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x71(BytesWithIndex) [function, total] + rule parseInstrx253x71(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x72(BytesWithIndex) [function, total] + rule parseInstrx253x72(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x73(BytesWithIndex) [function, total] + rule parseInstrx253x73(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x74(BytesWithIndex) [function, total] + rule parseInstrx253x74(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x75(BytesWithIndex) [function, total] + rule parseInstrx253x75(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x76(BytesWithIndex) [function, total] + rule parseInstrx253x76(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x77(BytesWithIndex) [function, total] + rule parseInstrx253x77(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x78(BytesWithIndex) [function, total] + rule parseInstrx253x78(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x79(BytesWithIndex) [function, total] + rule parseInstrx253x79(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x80(BytesWithIndex) [function, total] + rule parseInstrx253x80(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x81(BytesWithIndex) [function, total] + rule parseInstrx253x81(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x82(BytesWithIndex) [function, total] + rule parseInstrx253x82(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x83(BytesWithIndex) [function, total] + rule parseInstrx253x83(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x84(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x84s1 + ( MemArgResult + ) [function, total] + rule parseInstrx253x84(BWI) => #parseInstrx253x84s1(parseMemArg(BWI)) + syntax InstrResult ::= #parseInstrx253x84s2 + ( MemArg + , IntResult + ) [function, total] + rule #parseInstrx253x84s1(memArgResult(MemArg0:MemArg, BWI:BytesWithIndex)) => #parseInstrx253x84s2(MemArg0, parseLeb128UInt(BWI)) + rule #parseInstrx253x84s1(E:ParseError) => E + rule #parseInstrx253x84s2(MemArg0:MemArg, intResult(UnsignedInt1:Int, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(MemArg0) ListItem(UnsignedInt1) ListItem(BWI)) + rule #parseInstrx253x84s2(_MemArg0:MemArg, E:ParseError) => E + syntax InstrResult ::= parseInstrx253x85(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x85s1 + ( MemArgResult + ) [function, total] + rule parseInstrx253x85(BWI) => #parseInstrx253x85s1(parseMemArg(BWI)) + syntax InstrResult ::= #parseInstrx253x85s2 + ( MemArg + , IntResult + ) [function, total] + rule #parseInstrx253x85s1(memArgResult(MemArg0:MemArg, BWI:BytesWithIndex)) => #parseInstrx253x85s2(MemArg0, parseLeb128UInt(BWI)) + rule #parseInstrx253x85s1(E:ParseError) => E + rule #parseInstrx253x85s2(MemArg0:MemArg, intResult(UnsignedInt1:Int, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(MemArg0) ListItem(UnsignedInt1) ListItem(BWI)) + rule #parseInstrx253x85s2(_MemArg0:MemArg, E:ParseError) => E + syntax InstrResult ::= parseInstrx253x86(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x86s1 + ( MemArgResult + ) [function, total] + rule parseInstrx253x86(BWI) => #parseInstrx253x86s1(parseMemArg(BWI)) + syntax InstrResult ::= #parseInstrx253x86s2 + ( MemArg + , IntResult + ) [function, total] + rule #parseInstrx253x86s1(memArgResult(MemArg0:MemArg, BWI:BytesWithIndex)) => #parseInstrx253x86s2(MemArg0, parseLeb128UInt(BWI)) + rule #parseInstrx253x86s1(E:ParseError) => E + rule #parseInstrx253x86s2(MemArg0:MemArg, intResult(UnsignedInt1:Int, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(MemArg0) ListItem(UnsignedInt1) ListItem(BWI)) + rule #parseInstrx253x86s2(_MemArg0:MemArg, E:ParseError) => E + syntax InstrResult ::= parseInstrx253x87(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x87s1 + ( MemArgResult + ) [function, total] + rule parseInstrx253x87(BWI) => #parseInstrx253x87s1(parseMemArg(BWI)) + syntax InstrResult ::= #parseInstrx253x87s2 + ( MemArg + , IntResult + ) [function, total] + rule #parseInstrx253x87s1(memArgResult(MemArg0:MemArg, BWI:BytesWithIndex)) => #parseInstrx253x87s2(MemArg0, parseLeb128UInt(BWI)) + rule #parseInstrx253x87s1(E:ParseError) => E + rule #parseInstrx253x87s2(MemArg0:MemArg, intResult(UnsignedInt1:Int, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(MemArg0) ListItem(UnsignedInt1) ListItem(BWI)) + rule #parseInstrx253x87s2(_MemArg0:MemArg, E:ParseError) => E + syntax InstrResult ::= parseInstrx253x88(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x88s1 + ( MemArgResult + ) [function, total] + rule parseInstrx253x88(BWI) => #parseInstrx253x88s1(parseMemArg(BWI)) + syntax InstrResult ::= #parseInstrx253x88s2 + ( MemArg + , IntResult + ) [function, total] + rule #parseInstrx253x88s1(memArgResult(MemArg0:MemArg, BWI:BytesWithIndex)) => #parseInstrx253x88s2(MemArg0, parseLeb128UInt(BWI)) + rule #parseInstrx253x88s1(E:ParseError) => E + rule #parseInstrx253x88s2(MemArg0:MemArg, intResult(UnsignedInt1:Int, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(MemArg0) ListItem(UnsignedInt1) ListItem(BWI)) + rule #parseInstrx253x88s2(_MemArg0:MemArg, E:ParseError) => E + syntax InstrResult ::= parseInstrx253x89(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x89s1 + ( MemArgResult + ) [function, total] + rule parseInstrx253x89(BWI) => #parseInstrx253x89s1(parseMemArg(BWI)) + syntax InstrResult ::= #parseInstrx253x89s2 + ( MemArg + , IntResult + ) [function, total] + rule #parseInstrx253x89s1(memArgResult(MemArg0:MemArg, BWI:BytesWithIndex)) => #parseInstrx253x89s2(MemArg0, parseLeb128UInt(BWI)) + rule #parseInstrx253x89s1(E:ParseError) => E + rule #parseInstrx253x89s2(MemArg0:MemArg, intResult(UnsignedInt1:Int, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(MemArg0) ListItem(UnsignedInt1) ListItem(BWI)) + rule #parseInstrx253x89s2(_MemArg0:MemArg, E:ParseError) => E + syntax InstrResult ::= parseInstrx253x90(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x90s1 + ( MemArgResult + ) [function, total] + rule parseInstrx253x90(BWI) => #parseInstrx253x90s1(parseMemArg(BWI)) + syntax InstrResult ::= #parseInstrx253x90s2 + ( MemArg + , IntResult + ) [function, total] + rule #parseInstrx253x90s1(memArgResult(MemArg0:MemArg, BWI:BytesWithIndex)) => #parseInstrx253x90s2(MemArg0, parseLeb128UInt(BWI)) + rule #parseInstrx253x90s1(E:ParseError) => E + rule #parseInstrx253x90s2(MemArg0:MemArg, intResult(UnsignedInt1:Int, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(MemArg0) ListItem(UnsignedInt1) ListItem(BWI)) + rule #parseInstrx253x90s2(_MemArg0:MemArg, E:ParseError) => E + syntax InstrResult ::= parseInstrx253x91(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x91s1 + ( MemArgResult + ) [function, total] + rule parseInstrx253x91(BWI) => #parseInstrx253x91s1(parseMemArg(BWI)) + syntax InstrResult ::= #parseInstrx253x91s2 + ( MemArg + , IntResult + ) [function, total] + rule #parseInstrx253x91s1(memArgResult(MemArg0:MemArg, BWI:BytesWithIndex)) => #parseInstrx253x91s2(MemArg0, parseLeb128UInt(BWI)) + rule #parseInstrx253x91s1(E:ParseError) => E + rule #parseInstrx253x91s2(MemArg0:MemArg, intResult(UnsignedInt1:Int, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(MemArg0) ListItem(UnsignedInt1) ListItem(BWI)) + rule #parseInstrx253x91s2(_MemArg0:MemArg, E:ParseError) => E + syntax InstrResult ::= parseInstrx253x92(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x92s1 + ( MemArgResult + ) [function, total] + rule parseInstrx253x92(BWI) => #parseInstrx253x92s1(parseMemArg(BWI)) + rule #parseInstrx253x92s1(memArgResult(MemArg0:MemArg, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(MemArg0) ListItem(BWI)) + rule #parseInstrx253x92s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x93(BytesWithIndex) [function, total] + syntax InstrResult ::= #parseInstrx253x93s1 + ( MemArgResult + ) [function, total] + rule parseInstrx253x93(BWI) => #parseInstrx253x93s1(parseMemArg(BWI)) + rule #parseInstrx253x93s1(memArgResult(MemArg0:MemArg, BWI:BytesWithIndex)) => parseError("instruction not implemented", ListItem(MemArg0) ListItem(BWI)) + rule #parseInstrx253x93s1(E:ParseError) => E + syntax InstrResult ::= parseInstrx253x94(BytesWithIndex) [function, total] + rule parseInstrx253x94(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x95(BytesWithIndex) [function, total] + rule parseInstrx253x95(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x96(BytesWithIndex) [function, total] + rule parseInstrx253x96(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x97(BytesWithIndex) [function, total] + rule parseInstrx253x97(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x98(BytesWithIndex) [function, total] + rule parseInstrx253x98(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x99(BytesWithIndex) [function, total] + rule parseInstrx253x99(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x100(BytesWithIndex) [function, total] + rule parseInstrx253x100(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x101(BytesWithIndex) [function, total] + rule parseInstrx253x101(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x102(BytesWithIndex) [function, total] + rule parseInstrx253x102(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x103(BytesWithIndex) [function, total] + rule parseInstrx253x103(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x104(BytesWithIndex) [function, total] + rule parseInstrx253x104(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x105(BytesWithIndex) [function, total] + rule parseInstrx253x105(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x106(BytesWithIndex) [function, total] + rule parseInstrx253x106(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x107(BytesWithIndex) [function, total] + rule parseInstrx253x107(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x108(BytesWithIndex) [function, total] + rule parseInstrx253x108(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x109(BytesWithIndex) [function, total] + rule parseInstrx253x109(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x110(BytesWithIndex) [function, total] + rule parseInstrx253x110(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x111(BytesWithIndex) [function, total] + rule parseInstrx253x111(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x112(BytesWithIndex) [function, total] + rule parseInstrx253x112(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x113(BytesWithIndex) [function, total] + rule parseInstrx253x113(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x114(BytesWithIndex) [function, total] + rule parseInstrx253x114(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x115(BytesWithIndex) [function, total] + rule parseInstrx253x115(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x116(BytesWithIndex) [function, total] + rule parseInstrx253x116(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x117(BytesWithIndex) [function, total] + rule parseInstrx253x117(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x118(BytesWithIndex) [function, total] + rule parseInstrx253x118(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x119(BytesWithIndex) [function, total] + rule parseInstrx253x119(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x120(BytesWithIndex) [function, total] + rule parseInstrx253x120(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x121(BytesWithIndex) [function, total] + rule parseInstrx253x121(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x122(BytesWithIndex) [function, total] + rule parseInstrx253x122(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x123(BytesWithIndex) [function, total] + rule parseInstrx253x123(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x124(BytesWithIndex) [function, total] + rule parseInstrx253x124(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x125(BytesWithIndex) [function, total] + rule parseInstrx253x125(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x126(BytesWithIndex) [function, total] + rule parseInstrx253x126(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + syntax InstrResult ::= parseInstrx253x127(BytesWithIndex) [function, total] + rule parseInstrx253x127(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x128(BytesWithIndex) [function, total] + | #parseInstrx253x128(BytesWithIndexOrError) [function, total] + rule parseInstrx253x128(BWI:BytesWithIndex) => #parseInstrx253x128(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x128(BWI:BytesWithIndex) => parseInstrx253x128xbytes(BWI) + rule #parseInstrx253x128(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x128xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x128xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x129(BytesWithIndex) [function, total] + | #parseInstrx253x129(BytesWithIndexOrError) [function, total] + rule parseInstrx253x129(BWI:BytesWithIndex) => #parseInstrx253x129(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x129(BWI:BytesWithIndex) => parseInstrx253x129xbytes(BWI) + rule #parseInstrx253x129(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x129xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x129xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x130(BytesWithIndex) [function, total] + | #parseInstrx253x130(BytesWithIndexOrError) [function, total] + rule parseInstrx253x130(BWI:BytesWithIndex) => #parseInstrx253x130(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x130(BWI:BytesWithIndex) => parseInstrx253x130xbytes(BWI) + rule #parseInstrx253x130(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x130xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x130xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x131(BytesWithIndex) [function, total] + | #parseInstrx253x131(BytesWithIndexOrError) [function, total] + rule parseInstrx253x131(BWI:BytesWithIndex) => #parseInstrx253x131(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x131(BWI:BytesWithIndex) => parseInstrx253x131xbytes(BWI) + rule #parseInstrx253x131(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x131xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x131xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x132(BytesWithIndex) [function, total] + | #parseInstrx253x132(BytesWithIndexOrError) [function, total] + rule parseInstrx253x132(BWI:BytesWithIndex) => #parseInstrx253x132(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x132(BWI:BytesWithIndex) => parseInstrx253x132xbytes(BWI) + rule #parseInstrx253x132(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x132xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x132xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x133(BytesWithIndex) [function, total] + | #parseInstrx253x133(BytesWithIndexOrError) [function, total] + rule parseInstrx253x133(BWI:BytesWithIndex) => #parseInstrx253x133(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x133(BWI:BytesWithIndex) => parseInstrx253x133xbytes(BWI) + rule #parseInstrx253x133(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x133xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x133xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x134(BytesWithIndex) [function, total] + | #parseInstrx253x134(BytesWithIndexOrError) [function, total] + rule parseInstrx253x134(BWI:BytesWithIndex) => #parseInstrx253x134(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x134(BWI:BytesWithIndex) => parseInstrx253x134xbytes(BWI) + rule #parseInstrx253x134(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x134xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x134xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x135(BytesWithIndex) [function, total] + | #parseInstrx253x135(BytesWithIndexOrError) [function, total] + rule parseInstrx253x135(BWI:BytesWithIndex) => #parseInstrx253x135(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x135(BWI:BytesWithIndex) => parseInstrx253x135xbytes(BWI) + rule #parseInstrx253x135(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x135xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x135xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x136(BytesWithIndex) [function, total] + | #parseInstrx253x136(BytesWithIndexOrError) [function, total] + rule parseInstrx253x136(BWI:BytesWithIndex) => #parseInstrx253x136(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x136(BWI:BytesWithIndex) => parseInstrx253x136xbytes(BWI) + rule #parseInstrx253x136(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x136xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x136xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x137(BytesWithIndex) [function, total] + | #parseInstrx253x137(BytesWithIndexOrError) [function, total] + rule parseInstrx253x137(BWI:BytesWithIndex) => #parseInstrx253x137(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x137(BWI:BytesWithIndex) => parseInstrx253x137xbytes(BWI) + rule #parseInstrx253x137(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x137xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x137xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x138(BytesWithIndex) [function, total] + | #parseInstrx253x138(BytesWithIndexOrError) [function, total] + rule parseInstrx253x138(BWI:BytesWithIndex) => #parseInstrx253x138(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x138(BWI:BytesWithIndex) => parseInstrx253x138xbytes(BWI) + rule #parseInstrx253x138(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x138xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x138xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x139(BytesWithIndex) [function, total] + | #parseInstrx253x139(BytesWithIndexOrError) [function, total] + rule parseInstrx253x139(BWI:BytesWithIndex) => #parseInstrx253x139(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x139(BWI:BytesWithIndex) => parseInstrx253x139xbytes(BWI) + rule #parseInstrx253x139(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x139xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x139xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x140(BytesWithIndex) [function, total] + | #parseInstrx253x140(BytesWithIndexOrError) [function, total] + rule parseInstrx253x140(BWI:BytesWithIndex) => #parseInstrx253x140(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x140(BWI:BytesWithIndex) => parseInstrx253x140xbytes(BWI) + rule #parseInstrx253x140(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x140xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x140xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x141(BytesWithIndex) [function, total] + | #parseInstrx253x141(BytesWithIndexOrError) [function, total] + rule parseInstrx253x141(BWI:BytesWithIndex) => #parseInstrx253x141(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x141(BWI:BytesWithIndex) => parseInstrx253x141xbytes(BWI) + rule #parseInstrx253x141(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x141xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x141xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x142(BytesWithIndex) [function, total] + | #parseInstrx253x142(BytesWithIndexOrError) [function, total] + rule parseInstrx253x142(BWI:BytesWithIndex) => #parseInstrx253x142(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x142(BWI:BytesWithIndex) => parseInstrx253x142xbytes(BWI) + rule #parseInstrx253x142(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x142xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x142xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x143(BytesWithIndex) [function, total] + | #parseInstrx253x143(BytesWithIndexOrError) [function, total] + rule parseInstrx253x143(BWI:BytesWithIndex) => #parseInstrx253x143(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x143(BWI:BytesWithIndex) => parseInstrx253x143xbytes(BWI) + rule #parseInstrx253x143(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x143xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x143xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x144(BytesWithIndex) [function, total] + | #parseInstrx253x144(BytesWithIndexOrError) [function, total] + rule parseInstrx253x144(BWI:BytesWithIndex) => #parseInstrx253x144(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x144(BWI:BytesWithIndex) => parseInstrx253x144xbytes(BWI) + rule #parseInstrx253x144(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x144xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x144xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x145(BytesWithIndex) [function, total] + | #parseInstrx253x145(BytesWithIndexOrError) [function, total] + rule parseInstrx253x145(BWI:BytesWithIndex) => #parseInstrx253x145(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x145(BWI:BytesWithIndex) => parseInstrx253x145xbytes(BWI) + rule #parseInstrx253x145(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x145xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x145xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x146(BytesWithIndex) [function, total] + | #parseInstrx253x146(BytesWithIndexOrError) [function, total] + rule parseInstrx253x146(BWI:BytesWithIndex) => #parseInstrx253x146(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x146(BWI:BytesWithIndex) => parseInstrx253x146xbytes(BWI) + rule #parseInstrx253x146(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x146xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x146xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x147(BytesWithIndex) [function, total] + | #parseInstrx253x147(BytesWithIndexOrError) [function, total] + rule parseInstrx253x147(BWI:BytesWithIndex) => #parseInstrx253x147(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x147(BWI:BytesWithIndex) => parseInstrx253x147xbytes(BWI) + rule #parseInstrx253x147(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x147xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x147xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x148(BytesWithIndex) [function, total] + | #parseInstrx253x148(BytesWithIndexOrError) [function, total] + rule parseInstrx253x148(BWI:BytesWithIndex) => #parseInstrx253x148(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x148(BWI:BytesWithIndex) => parseInstrx253x148xbytes(BWI) + rule #parseInstrx253x148(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x148xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x148xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x149(BytesWithIndex) [function, total] + | #parseInstrx253x149(BytesWithIndexOrError) [function, total] + rule parseInstrx253x149(BWI:BytesWithIndex) => #parseInstrx253x149(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x149(BWI:BytesWithIndex) => parseInstrx253x149xbytes(BWI) + rule #parseInstrx253x149(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x149xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x149xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x150(BytesWithIndex) [function, total] + | #parseInstrx253x150(BytesWithIndexOrError) [function, total] + rule parseInstrx253x150(BWI:BytesWithIndex) => #parseInstrx253x150(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x150(BWI:BytesWithIndex) => parseInstrx253x150xbytes(BWI) + rule #parseInstrx253x150(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x150xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x150xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x151(BytesWithIndex) [function, total] + | #parseInstrx253x151(BytesWithIndexOrError) [function, total] + rule parseInstrx253x151(BWI:BytesWithIndex) => #parseInstrx253x151(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x151(BWI:BytesWithIndex) => parseInstrx253x151xbytes(BWI) + rule #parseInstrx253x151(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x151xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x151xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x152(BytesWithIndex) [function, total] + | #parseInstrx253x152(BytesWithIndexOrError) [function, total] + rule parseInstrx253x152(BWI:BytesWithIndex) => #parseInstrx253x152(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x152(BWI:BytesWithIndex) => parseInstrx253x152xbytes(BWI) + rule #parseInstrx253x152(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x152xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x152xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x153(BytesWithIndex) [function, total] + | #parseInstrx253x153(BytesWithIndexOrError) [function, total] + rule parseInstrx253x153(BWI:BytesWithIndex) => #parseInstrx253x153(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x153(BWI:BytesWithIndex) => parseInstrx253x153xbytes(BWI) + rule #parseInstrx253x153(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x153xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x153xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x155(BytesWithIndex) [function, total] + | #parseInstrx253x155(BytesWithIndexOrError) [function, total] + rule parseInstrx253x155(BWI:BytesWithIndex) => #parseInstrx253x155(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x155(BWI:BytesWithIndex) => parseInstrx253x155xbytes(BWI) + rule #parseInstrx253x155(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x155xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x155xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x156(BytesWithIndex) [function, total] + | #parseInstrx253x156(BytesWithIndexOrError) [function, total] + rule parseInstrx253x156(BWI:BytesWithIndex) => #parseInstrx253x156(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x156(BWI:BytesWithIndex) => parseInstrx253x156xbytes(BWI) + rule #parseInstrx253x156(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x156xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x156xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x157(BytesWithIndex) [function, total] + | #parseInstrx253x157(BytesWithIndexOrError) [function, total] + rule parseInstrx253x157(BWI:BytesWithIndex) => #parseInstrx253x157(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x157(BWI:BytesWithIndex) => parseInstrx253x157xbytes(BWI) + rule #parseInstrx253x157(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x157xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x157xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x158(BytesWithIndex) [function, total] + | #parseInstrx253x158(BytesWithIndexOrError) [function, total] + rule parseInstrx253x158(BWI:BytesWithIndex) => #parseInstrx253x158(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x158(BWI:BytesWithIndex) => parseInstrx253x158xbytes(BWI) + rule #parseInstrx253x158(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x158xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x158xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x159(BytesWithIndex) [function, total] + | #parseInstrx253x159(BytesWithIndexOrError) [function, total] + rule parseInstrx253x159(BWI:BytesWithIndex) => #parseInstrx253x159(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x159(BWI:BytesWithIndex) => parseInstrx253x159xbytes(BWI) + rule #parseInstrx253x159(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x159xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x159xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x160(BytesWithIndex) [function, total] + | #parseInstrx253x160(BytesWithIndexOrError) [function, total] + rule parseInstrx253x160(BWI:BytesWithIndex) => #parseInstrx253x160(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x160(BWI:BytesWithIndex) => parseInstrx253x160xbytes(BWI) + rule #parseInstrx253x160(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x160xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x160xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x161(BytesWithIndex) [function, total] + | #parseInstrx253x161(BytesWithIndexOrError) [function, total] + rule parseInstrx253x161(BWI:BytesWithIndex) => #parseInstrx253x161(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x161(BWI:BytesWithIndex) => parseInstrx253x161xbytes(BWI) + rule #parseInstrx253x161(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x161xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x161xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x163(BytesWithIndex) [function, total] + | #parseInstrx253x163(BytesWithIndexOrError) [function, total] + rule parseInstrx253x163(BWI:BytesWithIndex) => #parseInstrx253x163(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x163(BWI:BytesWithIndex) => parseInstrx253x163xbytes(BWI) + rule #parseInstrx253x163(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x163xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x163xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x164(BytesWithIndex) [function, total] + | #parseInstrx253x164(BytesWithIndexOrError) [function, total] + rule parseInstrx253x164(BWI:BytesWithIndex) => #parseInstrx253x164(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x164(BWI:BytesWithIndex) => parseInstrx253x164xbytes(BWI) + rule #parseInstrx253x164(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x164xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x164xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x167(BytesWithIndex) [function, total] + | #parseInstrx253x167(BytesWithIndexOrError) [function, total] + rule parseInstrx253x167(BWI:BytesWithIndex) => #parseInstrx253x167(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x167(BWI:BytesWithIndex) => parseInstrx253x167xbytes(BWI) + rule #parseInstrx253x167(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x167xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x167xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x168(BytesWithIndex) [function, total] + | #parseInstrx253x168(BytesWithIndexOrError) [function, total] + rule parseInstrx253x168(BWI:BytesWithIndex) => #parseInstrx253x168(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x168(BWI:BytesWithIndex) => parseInstrx253x168xbytes(BWI) + rule #parseInstrx253x168(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x168xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x168xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x169(BytesWithIndex) [function, total] + | #parseInstrx253x169(BytesWithIndexOrError) [function, total] + rule parseInstrx253x169(BWI:BytesWithIndex) => #parseInstrx253x169(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x169(BWI:BytesWithIndex) => parseInstrx253x169xbytes(BWI) + rule #parseInstrx253x169(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x169xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x169xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x170(BytesWithIndex) [function, total] + | #parseInstrx253x170(BytesWithIndexOrError) [function, total] + rule parseInstrx253x170(BWI:BytesWithIndex) => #parseInstrx253x170(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x170(BWI:BytesWithIndex) => parseInstrx253x170xbytes(BWI) + rule #parseInstrx253x170(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x170xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x170xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x171(BytesWithIndex) [function, total] + | #parseInstrx253x171(BytesWithIndexOrError) [function, total] + rule parseInstrx253x171(BWI:BytesWithIndex) => #parseInstrx253x171(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x171(BWI:BytesWithIndex) => parseInstrx253x171xbytes(BWI) + rule #parseInstrx253x171(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x171xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x171xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x172(BytesWithIndex) [function, total] + | #parseInstrx253x172(BytesWithIndexOrError) [function, total] + rule parseInstrx253x172(BWI:BytesWithIndex) => #parseInstrx253x172(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x172(BWI:BytesWithIndex) => parseInstrx253x172xbytes(BWI) + rule #parseInstrx253x172(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x172xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x172xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x173(BytesWithIndex) [function, total] + | #parseInstrx253x173(BytesWithIndexOrError) [function, total] + rule parseInstrx253x173(BWI:BytesWithIndex) => #parseInstrx253x173(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x173(BWI:BytesWithIndex) => parseInstrx253x173xbytes(BWI) + rule #parseInstrx253x173(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x173xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x173xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x174(BytesWithIndex) [function, total] + | #parseInstrx253x174(BytesWithIndexOrError) [function, total] + rule parseInstrx253x174(BWI:BytesWithIndex) => #parseInstrx253x174(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x174(BWI:BytesWithIndex) => parseInstrx253x174xbytes(BWI) + rule #parseInstrx253x174(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x174xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x174xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x177(BytesWithIndex) [function, total] + | #parseInstrx253x177(BytesWithIndexOrError) [function, total] + rule parseInstrx253x177(BWI:BytesWithIndex) => #parseInstrx253x177(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x177(BWI:BytesWithIndex) => parseInstrx253x177xbytes(BWI) + rule #parseInstrx253x177(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x177xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x177xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x181(BytesWithIndex) [function, total] + | #parseInstrx253x181(BytesWithIndexOrError) [function, total] + rule parseInstrx253x181(BWI:BytesWithIndex) => #parseInstrx253x181(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x181(BWI:BytesWithIndex) => parseInstrx253x181xbytes(BWI) + rule #parseInstrx253x181(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x181xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x181xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x182(BytesWithIndex) [function, total] + | #parseInstrx253x182(BytesWithIndexOrError) [function, total] + rule parseInstrx253x182(BWI:BytesWithIndex) => #parseInstrx253x182(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x182(BWI:BytesWithIndex) => parseInstrx253x182xbytes(BWI) + rule #parseInstrx253x182(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x182xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x182xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x183(BytesWithIndex) [function, total] + | #parseInstrx253x183(BytesWithIndexOrError) [function, total] + rule parseInstrx253x183(BWI:BytesWithIndex) => #parseInstrx253x183(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x183(BWI:BytesWithIndex) => parseInstrx253x183xbytes(BWI) + rule #parseInstrx253x183(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x183xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x183xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x184(BytesWithIndex) [function, total] + | #parseInstrx253x184(BytesWithIndexOrError) [function, total] + rule parseInstrx253x184(BWI:BytesWithIndex) => #parseInstrx253x184(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x184(BWI:BytesWithIndex) => parseInstrx253x184xbytes(BWI) + rule #parseInstrx253x184(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x184xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x184xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x185(BytesWithIndex) [function, total] + | #parseInstrx253x185(BytesWithIndexOrError) [function, total] + rule parseInstrx253x185(BWI:BytesWithIndex) => #parseInstrx253x185(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x185(BWI:BytesWithIndex) => parseInstrx253x185xbytes(BWI) + rule #parseInstrx253x185(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x185xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x185xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x186(BytesWithIndex) [function, total] + | #parseInstrx253x186(BytesWithIndexOrError) [function, total] + rule parseInstrx253x186(BWI:BytesWithIndex) => #parseInstrx253x186(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x186(BWI:BytesWithIndex) => parseInstrx253x186xbytes(BWI) + rule #parseInstrx253x186(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x186xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x186xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x188(BytesWithIndex) [function, total] + | #parseInstrx253x188(BytesWithIndexOrError) [function, total] + rule parseInstrx253x188(BWI:BytesWithIndex) => #parseInstrx253x188(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x188(BWI:BytesWithIndex) => parseInstrx253x188xbytes(BWI) + rule #parseInstrx253x188(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x188xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x188xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x189(BytesWithIndex) [function, total] + | #parseInstrx253x189(BytesWithIndexOrError) [function, total] + rule parseInstrx253x189(BWI:BytesWithIndex) => #parseInstrx253x189(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x189(BWI:BytesWithIndex) => parseInstrx253x189xbytes(BWI) + rule #parseInstrx253x189(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x189xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x189xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x190(BytesWithIndex) [function, total] + | #parseInstrx253x190(BytesWithIndexOrError) [function, total] + rule parseInstrx253x190(BWI:BytesWithIndex) => #parseInstrx253x190(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x190(BWI:BytesWithIndex) => parseInstrx253x190xbytes(BWI) + rule #parseInstrx253x190(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x190xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x190xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x191(BytesWithIndex) [function, total] + | #parseInstrx253x191(BytesWithIndexOrError) [function, total] + rule parseInstrx253x191(BWI:BytesWithIndex) => #parseInstrx253x191(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x191(BWI:BytesWithIndex) => parseInstrx253x191xbytes(BWI) + rule #parseInstrx253x191(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x191xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x191xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x192(BytesWithIndex) [function, total] + | #parseInstrx253x192(BytesWithIndexOrError) [function, total] + rule parseInstrx253x192(BWI:BytesWithIndex) => #parseInstrx253x192(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x192(BWI:BytesWithIndex) => parseInstrx253x192xbytes(BWI) + rule #parseInstrx253x192(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x192xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x192xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x193(BytesWithIndex) [function, total] + | #parseInstrx253x193(BytesWithIndexOrError) [function, total] + rule parseInstrx253x193(BWI:BytesWithIndex) => #parseInstrx253x193(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x193(BWI:BytesWithIndex) => parseInstrx253x193xbytes(BWI) + rule #parseInstrx253x193(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x193xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x193xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x195(BytesWithIndex) [function, total] + | #parseInstrx253x195(BytesWithIndexOrError) [function, total] + rule parseInstrx253x195(BWI:BytesWithIndex) => #parseInstrx253x195(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x195(BWI:BytesWithIndex) => parseInstrx253x195xbytes(BWI) + rule #parseInstrx253x195(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x195xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x195xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x196(BytesWithIndex) [function, total] + | #parseInstrx253x196(BytesWithIndexOrError) [function, total] + rule parseInstrx253x196(BWI:BytesWithIndex) => #parseInstrx253x196(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x196(BWI:BytesWithIndex) => parseInstrx253x196xbytes(BWI) + rule #parseInstrx253x196(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x196xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x196xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x199(BytesWithIndex) [function, total] + | #parseInstrx253x199(BytesWithIndexOrError) [function, total] + rule parseInstrx253x199(BWI:BytesWithIndex) => #parseInstrx253x199(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x199(BWI:BytesWithIndex) => parseInstrx253x199xbytes(BWI) + rule #parseInstrx253x199(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x199xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x199xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x200(BytesWithIndex) [function, total] + | #parseInstrx253x200(BytesWithIndexOrError) [function, total] + rule parseInstrx253x200(BWI:BytesWithIndex) => #parseInstrx253x200(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x200(BWI:BytesWithIndex) => parseInstrx253x200xbytes(BWI) + rule #parseInstrx253x200(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x200xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x200xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x201(BytesWithIndex) [function, total] + | #parseInstrx253x201(BytesWithIndexOrError) [function, total] + rule parseInstrx253x201(BWI:BytesWithIndex) => #parseInstrx253x201(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x201(BWI:BytesWithIndex) => parseInstrx253x201xbytes(BWI) + rule #parseInstrx253x201(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x201xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x201xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x202(BytesWithIndex) [function, total] + | #parseInstrx253x202(BytesWithIndexOrError) [function, total] + rule parseInstrx253x202(BWI:BytesWithIndex) => #parseInstrx253x202(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x202(BWI:BytesWithIndex) => parseInstrx253x202xbytes(BWI) + rule #parseInstrx253x202(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x202xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x202xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x203(BytesWithIndex) [function, total] + | #parseInstrx253x203(BytesWithIndexOrError) [function, total] + rule parseInstrx253x203(BWI:BytesWithIndex) => #parseInstrx253x203(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x203(BWI:BytesWithIndex) => parseInstrx253x203xbytes(BWI) + rule #parseInstrx253x203(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x203xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x203xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x204(BytesWithIndex) [function, total] + | #parseInstrx253x204(BytesWithIndexOrError) [function, total] + rule parseInstrx253x204(BWI:BytesWithIndex) => #parseInstrx253x204(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x204(BWI:BytesWithIndex) => parseInstrx253x204xbytes(BWI) + rule #parseInstrx253x204(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x204xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x204xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x205(BytesWithIndex) [function, total] + | #parseInstrx253x205(BytesWithIndexOrError) [function, total] + rule parseInstrx253x205(BWI:BytesWithIndex) => #parseInstrx253x205(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x205(BWI:BytesWithIndex) => parseInstrx253x205xbytes(BWI) + rule #parseInstrx253x205(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x205xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x205xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x206(BytesWithIndex) [function, total] + | #parseInstrx253x206(BytesWithIndexOrError) [function, total] + rule parseInstrx253x206(BWI:BytesWithIndex) => #parseInstrx253x206(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x206(BWI:BytesWithIndex) => parseInstrx253x206xbytes(BWI) + rule #parseInstrx253x206(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x206xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x206xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x209(BytesWithIndex) [function, total] + | #parseInstrx253x209(BytesWithIndexOrError) [function, total] + rule parseInstrx253x209(BWI:BytesWithIndex) => #parseInstrx253x209(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x209(BWI:BytesWithIndex) => parseInstrx253x209xbytes(BWI) + rule #parseInstrx253x209(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x209xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x209xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x213(BytesWithIndex) [function, total] + | #parseInstrx253x213(BytesWithIndexOrError) [function, total] + rule parseInstrx253x213(BWI:BytesWithIndex) => #parseInstrx253x213(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x213(BWI:BytesWithIndex) => parseInstrx253x213xbytes(BWI) + rule #parseInstrx253x213(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x213xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x213xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x214(BytesWithIndex) [function, total] + | #parseInstrx253x214(BytesWithIndexOrError) [function, total] + rule parseInstrx253x214(BWI:BytesWithIndex) => #parseInstrx253x214(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x214(BWI:BytesWithIndex) => parseInstrx253x214xbytes(BWI) + rule #parseInstrx253x214(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x214xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x214xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x215(BytesWithIndex) [function, total] + | #parseInstrx253x215(BytesWithIndexOrError) [function, total] + rule parseInstrx253x215(BWI:BytesWithIndex) => #parseInstrx253x215(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x215(BWI:BytesWithIndex) => parseInstrx253x215xbytes(BWI) + rule #parseInstrx253x215(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x215xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x215xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x216(BytesWithIndex) [function, total] + | #parseInstrx253x216(BytesWithIndexOrError) [function, total] + rule parseInstrx253x216(BWI:BytesWithIndex) => #parseInstrx253x216(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x216(BWI:BytesWithIndex) => parseInstrx253x216xbytes(BWI) + rule #parseInstrx253x216(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x216xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x216xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x217(BytesWithIndex) [function, total] + | #parseInstrx253x217(BytesWithIndexOrError) [function, total] + rule parseInstrx253x217(BWI:BytesWithIndex) => #parseInstrx253x217(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x217(BWI:BytesWithIndex) => parseInstrx253x217xbytes(BWI) + rule #parseInstrx253x217(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x217xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x217xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x218(BytesWithIndex) [function, total] + | #parseInstrx253x218(BytesWithIndexOrError) [function, total] + rule parseInstrx253x218(BWI:BytesWithIndex) => #parseInstrx253x218(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x218(BWI:BytesWithIndex) => parseInstrx253x218xbytes(BWI) + rule #parseInstrx253x218(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x218xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x218xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x219(BytesWithIndex) [function, total] + | #parseInstrx253x219(BytesWithIndexOrError) [function, total] + rule parseInstrx253x219(BWI:BytesWithIndex) => #parseInstrx253x219(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x219(BWI:BytesWithIndex) => parseInstrx253x219xbytes(BWI) + rule #parseInstrx253x219(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x219xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x219xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x220(BytesWithIndex) [function, total] + | #parseInstrx253x220(BytesWithIndexOrError) [function, total] + rule parseInstrx253x220(BWI:BytesWithIndex) => #parseInstrx253x220(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x220(BWI:BytesWithIndex) => parseInstrx253x220xbytes(BWI) + rule #parseInstrx253x220(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x220xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x220xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x221(BytesWithIndex) [function, total] + | #parseInstrx253x221(BytesWithIndexOrError) [function, total] + rule parseInstrx253x221(BWI:BytesWithIndex) => #parseInstrx253x221(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x221(BWI:BytesWithIndex) => parseInstrx253x221xbytes(BWI) + rule #parseInstrx253x221(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x221xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x221xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x222(BytesWithIndex) [function, total] + | #parseInstrx253x222(BytesWithIndexOrError) [function, total] + rule parseInstrx253x222(BWI:BytesWithIndex) => #parseInstrx253x222(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x222(BWI:BytesWithIndex) => parseInstrx253x222xbytes(BWI) + rule #parseInstrx253x222(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x222xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x222xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x223(BytesWithIndex) [function, total] + | #parseInstrx253x223(BytesWithIndexOrError) [function, total] + rule parseInstrx253x223(BWI:BytesWithIndex) => #parseInstrx253x223(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x223(BWI:BytesWithIndex) => parseInstrx253x223xbytes(BWI) + rule #parseInstrx253x223(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x223xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x223xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x224(BytesWithIndex) [function, total] + | #parseInstrx253x224(BytesWithIndexOrError) [function, total] + rule parseInstrx253x224(BWI:BytesWithIndex) => #parseInstrx253x224(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x224(BWI:BytesWithIndex) => parseInstrx253x224xbytes(BWI) + rule #parseInstrx253x224(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x224xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x224xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x225(BytesWithIndex) [function, total] + | #parseInstrx253x225(BytesWithIndexOrError) [function, total] + rule parseInstrx253x225(BWI:BytesWithIndex) => #parseInstrx253x225(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x225(BWI:BytesWithIndex) => parseInstrx253x225xbytes(BWI) + rule #parseInstrx253x225(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x225xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x225xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x227(BytesWithIndex) [function, total] + | #parseInstrx253x227(BytesWithIndexOrError) [function, total] + rule parseInstrx253x227(BWI:BytesWithIndex) => #parseInstrx253x227(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x227(BWI:BytesWithIndex) => parseInstrx253x227xbytes(BWI) + rule #parseInstrx253x227(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x227xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x227xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x228(BytesWithIndex) [function, total] + | #parseInstrx253x228(BytesWithIndexOrError) [function, total] + rule parseInstrx253x228(BWI:BytesWithIndex) => #parseInstrx253x228(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x228(BWI:BytesWithIndex) => parseInstrx253x228xbytes(BWI) + rule #parseInstrx253x228(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x228xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x228xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x229(BytesWithIndex) [function, total] + | #parseInstrx253x229(BytesWithIndexOrError) [function, total] + rule parseInstrx253x229(BWI:BytesWithIndex) => #parseInstrx253x229(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x229(BWI:BytesWithIndex) => parseInstrx253x229xbytes(BWI) + rule #parseInstrx253x229(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x229xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x229xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x230(BytesWithIndex) [function, total] + | #parseInstrx253x230(BytesWithIndexOrError) [function, total] + rule parseInstrx253x230(BWI:BytesWithIndex) => #parseInstrx253x230(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x230(BWI:BytesWithIndex) => parseInstrx253x230xbytes(BWI) + rule #parseInstrx253x230(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x230xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x230xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x231(BytesWithIndex) [function, total] + | #parseInstrx253x231(BytesWithIndexOrError) [function, total] + rule parseInstrx253x231(BWI:BytesWithIndex) => #parseInstrx253x231(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x231(BWI:BytesWithIndex) => parseInstrx253x231xbytes(BWI) + rule #parseInstrx253x231(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x231xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x231xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x232(BytesWithIndex) [function, total] + | #parseInstrx253x232(BytesWithIndexOrError) [function, total] + rule parseInstrx253x232(BWI:BytesWithIndex) => #parseInstrx253x232(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x232(BWI:BytesWithIndex) => parseInstrx253x232xbytes(BWI) + rule #parseInstrx253x232(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x232xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x232xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x233(BytesWithIndex) [function, total] + | #parseInstrx253x233(BytesWithIndexOrError) [function, total] + rule parseInstrx253x233(BWI:BytesWithIndex) => #parseInstrx253x233(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x233(BWI:BytesWithIndex) => parseInstrx253x233xbytes(BWI) + rule #parseInstrx253x233(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x233xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x233xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x234(BytesWithIndex) [function, total] + | #parseInstrx253x234(BytesWithIndexOrError) [function, total] + rule parseInstrx253x234(BWI:BytesWithIndex) => #parseInstrx253x234(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x234(BWI:BytesWithIndex) => parseInstrx253x234xbytes(BWI) + rule #parseInstrx253x234(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x234xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x234xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x235(BytesWithIndex) [function, total] + | #parseInstrx253x235(BytesWithIndexOrError) [function, total] + rule parseInstrx253x235(BWI:BytesWithIndex) => #parseInstrx253x235(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x235(BWI:BytesWithIndex) => parseInstrx253x235xbytes(BWI) + rule #parseInstrx253x235(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x235xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x235xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x236(BytesWithIndex) [function, total] + | #parseInstrx253x236(BytesWithIndexOrError) [function, total] + rule parseInstrx253x236(BWI:BytesWithIndex) => #parseInstrx253x236(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x236(BWI:BytesWithIndex) => parseInstrx253x236xbytes(BWI) + rule #parseInstrx253x236(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x236xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x236xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x237(BytesWithIndex) [function, total] + | #parseInstrx253x237(BytesWithIndexOrError) [function, total] + rule parseInstrx253x237(BWI:BytesWithIndex) => #parseInstrx253x237(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x237(BWI:BytesWithIndex) => parseInstrx253x237xbytes(BWI) + rule #parseInstrx253x237(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x237xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x237xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x239(BytesWithIndex) [function, total] + | #parseInstrx253x239(BytesWithIndexOrError) [function, total] + rule parseInstrx253x239(BWI:BytesWithIndex) => #parseInstrx253x239(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x239(BWI:BytesWithIndex) => parseInstrx253x239xbytes(BWI) + rule #parseInstrx253x239(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x239xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x239xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x240(BytesWithIndex) [function, total] + | #parseInstrx253x240(BytesWithIndexOrError) [function, total] + rule parseInstrx253x240(BWI:BytesWithIndex) => #parseInstrx253x240(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x240(BWI:BytesWithIndex) => parseInstrx253x240xbytes(BWI) + rule #parseInstrx253x240(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x240xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x240xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x241(BytesWithIndex) [function, total] + | #parseInstrx253x241(BytesWithIndexOrError) [function, total] + rule parseInstrx253x241(BWI:BytesWithIndex) => #parseInstrx253x241(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x241(BWI:BytesWithIndex) => parseInstrx253x241xbytes(BWI) + rule #parseInstrx253x241(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x241xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x241xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x242(BytesWithIndex) [function, total] + | #parseInstrx253x242(BytesWithIndexOrError) [function, total] + rule parseInstrx253x242(BWI:BytesWithIndex) => #parseInstrx253x242(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x242(BWI:BytesWithIndex) => parseInstrx253x242xbytes(BWI) + rule #parseInstrx253x242(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x242xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x242xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x243(BytesWithIndex) [function, total] + | #parseInstrx253x243(BytesWithIndexOrError) [function, total] + rule parseInstrx253x243(BWI:BytesWithIndex) => #parseInstrx253x243(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x243(BWI:BytesWithIndex) => parseInstrx253x243xbytes(BWI) + rule #parseInstrx253x243(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x243xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x243xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x244(BytesWithIndex) [function, total] + | #parseInstrx253x244(BytesWithIndexOrError) [function, total] + rule parseInstrx253x244(BWI:BytesWithIndex) => #parseInstrx253x244(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x244(BWI:BytesWithIndex) => parseInstrx253x244xbytes(BWI) + rule #parseInstrx253x244(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x244xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x244xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x245(BytesWithIndex) [function, total] + | #parseInstrx253x245(BytesWithIndexOrError) [function, total] + rule parseInstrx253x245(BWI:BytesWithIndex) => #parseInstrx253x245(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x245(BWI:BytesWithIndex) => parseInstrx253x245xbytes(BWI) + rule #parseInstrx253x245(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x245xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x245xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x246(BytesWithIndex) [function, total] + | #parseInstrx253x246(BytesWithIndexOrError) [function, total] + rule parseInstrx253x246(BWI:BytesWithIndex) => #parseInstrx253x246(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x246(BWI:BytesWithIndex) => parseInstrx253x246xbytes(BWI) + rule #parseInstrx253x246(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x246xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x246xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x247(BytesWithIndex) [function, total] + | #parseInstrx253x247(BytesWithIndexOrError) [function, total] + rule parseInstrx253x247(BWI:BytesWithIndex) => #parseInstrx253x247(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x247(BWI:BytesWithIndex) => parseInstrx253x247xbytes(BWI) + rule #parseInstrx253x247(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x247xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x247xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x248(BytesWithIndex) [function, total] + | #parseInstrx253x248(BytesWithIndexOrError) [function, total] + rule parseInstrx253x248(BWI:BytesWithIndex) => #parseInstrx253x248(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x248(BWI:BytesWithIndex) => parseInstrx253x248xbytes(BWI) + rule #parseInstrx253x248(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x248xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x248xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x249(BytesWithIndex) [function, total] + | #parseInstrx253x249(BytesWithIndexOrError) [function, total] + rule parseInstrx253x249(BWI:BytesWithIndex) => #parseInstrx253x249(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x249(BWI:BytesWithIndex) => parseInstrx253x249xbytes(BWI) + rule #parseInstrx253x249(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x249xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x249xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x250(BytesWithIndex) [function, total] + | #parseInstrx253x250(BytesWithIndexOrError) [function, total] + rule parseInstrx253x250(BWI:BytesWithIndex) => #parseInstrx253x250(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x250(BWI:BytesWithIndex) => parseInstrx253x250xbytes(BWI) + rule #parseInstrx253x250(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x250xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x250xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x251(BytesWithIndex) [function, total] + | #parseInstrx253x251(BytesWithIndexOrError) [function, total] + rule parseInstrx253x251(BWI:BytesWithIndex) => #parseInstrx253x251(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x251(BWI:BytesWithIndex) => parseInstrx253x251xbytes(BWI) + rule #parseInstrx253x251(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x251xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x251xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x252(BytesWithIndex) [function, total] + | #parseInstrx253x252(BytesWithIndexOrError) [function, total] + rule parseInstrx253x252(BWI:BytesWithIndex) => #parseInstrx253x252(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x252(BWI:BytesWithIndex) => parseInstrx253x252xbytes(BWI) + rule #parseInstrx253x252(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x252xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x252xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x253(BytesWithIndex) [function, total] + | #parseInstrx253x253(BytesWithIndexOrError) [function, total] + rule parseInstrx253x253(BWI:BytesWithIndex) => #parseInstrx253x253(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x253(BWI:BytesWithIndex) => parseInstrx253x253xbytes(BWI) + rule #parseInstrx253x253(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x253xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x253xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x254(BytesWithIndex) [function, total] + | #parseInstrx253x254(BytesWithIndexOrError) [function, total] + rule parseInstrx253x254(BWI:BytesWithIndex) => #parseInstrx253x254(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x254(BWI:BytesWithIndex) => parseInstrx253x254xbytes(BWI) + rule #parseInstrx253x254(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x254xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x254xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) + + syntax InstrResult ::= parseInstrx253x255(BytesWithIndex) [function, total] + | #parseInstrx253x255(BytesWithIndexOrError) [function, total] + rule parseInstrx253x255(BWI:BytesWithIndex) => #parseInstrx253x255(parseConstant(BWI, b"\x01")) + rule #parseInstrx253x255(BWI:BytesWithIndex) => parseInstrx253x255xbytes(BWI) + rule #parseInstrx253x255(E:ParseError) => E + + syntax InstrResult ::= parseInstrx253x255xbytes(BytesWithIndex) [function, total] + rule parseInstrx253x255xbytes(BWI:BytesWithIndex) => parseError("instruction not implemented", ListItem(BWI)) +endmodule +``` + diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/int.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/int.md index 3f5213a0f..022586b1e 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/int.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/int.md @@ -3,13 +3,17 @@ ```k module BINARY-PARSER-INT-SYNTAX imports BINARY-PARSER-BASE-SYNTAX + imports WASM-DATA-COMMON syntax IntResult ::= intResult(value:Int, remainder:BytesWithIndex) | ParseError syntax IntResult ::= parseLeb128UInt(BytesWithIndex) [function, total] + syntax IntResult ::= parseLeb128SInt(BytesWithIndex) [function, total] + syntax IntResult ::= parseByteAsInt(BytesWithIndex) [function, total] - // TODO: Rename to IntVec - syntax IntList ::= List{Int, ":"} - syntax IntListResult ::= intListResult(IntList, BytesWithIndex) | ParseError + syntax IntsResult ::= intsResult(Ints, BytesWithIndex) | ParseError + syntax IntsResult ::= parseUnsignedIntVec(BytesWithIndex) [function, total] + + syntax BytesWithIndexOrError ::= ignoreUnsignedInt(BytesWithIndex, Int) [function, total] endmodule module BINARY-PARSER-INT [private] @@ -20,10 +24,11 @@ module BINARY-PARSER-INT [private] rule bit8IsSet(I:Int) => I &Int 128 =/=Int 0 syntax Int ::= clearBit8(Int) [function, total] - rule clearBit8(I:Int) => I ^Int (I &Int 128) + rule clearBit8(I:Int) => I -Int 128 requires 128 <=Int 128 + rule clearBit8(I:Int) => I requires I parseError("parseLeb128IntChunks", ListItem(lengthBytes(Buffer)) ListItem(I) ListItem(Buffer)) @@ -33,25 +38,81 @@ module BINARY-PARSER-INT [private] requires 0 <=Int I andBool I intListResult(Buffer[I] : .IntList, bwi(Buffer, I +Int 1)) + => intsResult(Buffer[I] .Ints, bwi(Buffer, I +Int 1)) requires 0 <=Int I andBool I intListResult(Value : L, BWI) + rule #parseLeb128IntChunks(Value:Int, intsResult(L:Ints, BWI:BytesWithIndex)) + => intsResult(Value L, BWI) rule #parseLeb128IntChunks(_Value:Int, E:ParseError) => E - syntax IntResult ::= #parseLeb128UInt(IntListResult) [function, total] + syntax IntResult ::= #parseLeb128UInt(IntsResult) [function, total] rule parseLeb128UInt(BWI:BytesWithIndex) => #parseLeb128UInt(parseLeb128IntChunks(BWI)) - rule #parseLeb128UInt(intListResult(L:IntList, BWI:BytesWithIndex)) + rule #parseLeb128UInt(intsResult(L:Ints, BWI:BytesWithIndex)) => intResult(buildLeb128UInt(L), BWI) rule #parseLeb128UInt(E:ParseError) => E - syntax Int ::= buildLeb128UInt(IntList) [function, total] - rule buildLeb128UInt(.IntList) => 0 - rule buildLeb128UInt(Value:Int : L:IntList) => Value +Int 128 *Int buildLeb128UInt(L) + syntax Int ::= buildLeb128UInt(Ints) [function, total] + rule buildLeb128UInt(.Ints) => 0 + rule buildLeb128UInt(Value:Int L:Ints) => Value +Int 128 *Int buildLeb128UInt(L) + + syntax IntResult ::= #parseLeb128SInt(IntsResult) [function, total] + + rule parseLeb128SInt(BWI:BytesWithIndex) => #parseLeb128SInt(parseLeb128IntChunks(BWI)) + rule #parseLeb128SInt(intsResult(L:Ints, BWI:BytesWithIndex)) + => intResult(leb128UnsignedToSigned(buildLeb128UInt(L), #lenInts(L) *Int 7), BWI) + rule #parseLeb128SInt(E:ParseError) => E + + syntax Int ::= buildLeb128UInt(Ints) [function, total] + rule buildLeb128UInt(.Ints) => 0 + rule buildLeb128UInt(Value:Int L:Ints) => Value +Int 128 *Int buildLeb128UInt(L) + + syntax Int ::= leb128UnsignedToSigned(unsigned: Int, bits: Int) [function, total] + rule leb128UnsignedToSigned(U:Int, Bits:Int) => U + requires U U -Int (1 < #ignoreUnsignedInt(Count -Int 1, parseLeb128UInt(BWI:BytesWithIndex)) + requires Count >Int 0 + rule ignoreUnsignedInt(BWI:BytesWithIndex, 0) => BWI + rule ignoreUnsignedInt(BWI:BytesWithIndex, Count:Int) + => parseError("ignoreUnsignedInt", ListItem(Count) ListItem(BWI)) + requires Count ignoreUnsignedInt(BWI, Count) + rule #ignoreUnsignedInt(_:Int, E:ParseError) => E + + rule parseByteAsInt(bwi(B:Bytes, Index:Int)) + => intResult(B[Index], bwi(B, Index +Int 1)) + requires 0 <=Int Index andBool Index <=Int lengthBytes(B) + rule parseByteAsInt(bwi(B:Bytes, Index:Int)) + => parseError("parseByteAsInt", ListItem(Index) ListItem(lengthBytes(B)) ListItem(B)) + [owise] + + syntax IntsResult ::= #parseUnsignedIntVec1(IntResult) [function, total] + | #parseUnsignedIntVec2(count: Int, Ints, BytesWithIndex) [function, total] + | #parseUnsignedIntVec3(count: Int, Ints, IntResult) [function, total] + + rule parseUnsignedIntVec(BWI:BytesWithIndex) => #parseUnsignedIntVec1(parseLeb128UInt(BWI)) + rule #parseUnsignedIntVec1(intResult(Count:Int, BWI:BytesWithIndex)) + => #parseUnsignedIntVec2(Count, .Ints, BWI) + rule #parseUnsignedIntVec1(E:ParseError) => E + rule #parseUnsignedIntVec2(0, L:Ints, BWI:BytesWithIndex) + => intsResult(#reverseInts(L), BWI) + rule #parseUnsignedIntVec2(Count:Int, L:Ints, BWI:BytesWithIndex) + => #parseUnsignedIntVec3(Count -Int 1, L, parseLeb128UInt(BWI)) + requires Count >Int 0 + rule #parseUnsignedIntVec2(Count:Int, L:Ints, BWI:BytesWithIndex) + => parseError("parseUnsignedIntVec2", ListItem(Count) ListItem(L) ListItem(BWI)) + rule #parseUnsignedIntVec3(Count:Int, L:Ints, intResult(Value:Int, BWI:BytesWithIndex)) + => #parseUnsignedIntVec2(Count, Value L, BWI) + rule #parseUnsignedIntVec3(_Count:Int, _:Ints, E:ParseError) => E endmodule -``` \ No newline at end of file +``` diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/locals.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/locals.md new file mode 100644 index 000000000..21fe52e49 --- /dev/null +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/locals.md @@ -0,0 +1,72 @@ +// Parsing a [locals object](https://webassembly.github.io/spec/core/binary/modules.html#binary-local). + +```k +module BINARY-PARSER-LOCALS-SYNTAX + imports BINARY-PARSER-BASE-SYNTAX + imports WASM-DATA-COMMON-SYNTAX + + syntax Locals ::= locals(Int, ValType) + syntax LocalsResult ::= localsResult(Locals, BytesWithIndex) | ParseError + syntax LocalsResult ::= parseLocals(BytesWithIndex) [function, total] + + syntax LocalsVec ::= List{Locals, ","} + syntax LocalsVecResult ::= localsVecResult(LocalsVec, BytesWithIndex) | ParseError + syntax LocalsVecResult ::= parseLocalsVec(BytesWithIndex) [function, total] + + syntax ValTypes ::= localsVecToValTypes(LocalsVec) [function, total] +endmodule + +module BINARY-PARSER-LOCALS [private] + imports BINARY-PARSER-INT-SYNTAX + imports BINARY-PARSER-LOCALS-SYNTAX + imports BINARY-PARSER-VALTYPE-SYNTAX + + syntax LocalsResult ::= #parseLocals1(IntResult) [function, total] + | #parseLocals2(Int, ValTypeResult) [function, total] + + rule parseLocals(BWI:BytesWithIndex) => #parseLocals1(parseLeb128UInt(BWI)) + rule #parseLocals1(intResult(Count:Int, BWI:BytesWithIndex)) + => #parseLocals2(Count, parseValType(BWI)) + rule #parseLocals1(E:ParseError) => E + rule #parseLocals2(I:Int, valTypeResult(T:ValType, BWI:BytesWithIndex)) + => localsResult(locals(I, T), BWI) + rule #parseLocals2(_, E:ParseError) => E + + syntax LocalsVecResult ::= #parseLocalsVec1(IntResult) [function, total] + | #parseLocalsVec2(LocalsVec, Int, BytesWithIndex) [function, total] + | #parseLocalsVec3(LocalsVec, Int, LocalsResult) [function, total] + + rule parseLocalsVec(BWI:BytesWithIndex) => #parseLocalsVec1(parseLeb128UInt(BWI)) + rule #parseLocalsVec1(intResult(Count:Int, BWI:BytesWithIndex)) + => #parseLocalsVec2(.LocalsVec, Count, BWI) + rule #parseLocalsVec1(E:ParseError) => E + + rule #parseLocalsVec2(L:LocalsVec, Count:Int, BWI:BytesWithIndex) + => parseError("#parseLocalsVec2", ListItem(Count) ListItem(L) ListItem(BWI)) + requires Count localsVecResult(reverse(L), BWI) + rule #parseLocalsVec2(L:LocalsVec, Count:Int, BWI:BytesWithIndex) + => #parseLocalsVec3(L, Count -Int 1, parseLocals(BWI)) + requires Count >Int 0 + + rule #parseLocalsVec3(Ls:LocalsVec, Count:Int, localsResult(L:Locals, BWI:BytesWithIndex)) + => #parseLocalsVec2((L , Ls), Count, BWI) + rule #parseLocalsVec3(_:LocalsVec, _:Int, E:ParseError) => E + + syntax LocalsVec ::= reverse(LocalsVec) [function, total] + | #reverse(LocalsVec, LocalsVec) [function, total] + + rule reverse(L:LocalsVec) => #reverse(L, .LocalsVec) + rule #reverse(.LocalsVec, L:LocalsVec) => L + rule #reverse((L:Locals , L1:LocalsVec), L2:LocalsVec) => #reverse(L1, (L , L2)) + + rule localsVecToValTypes(.LocalsVec) => .ValTypes + rule localsVecToValTypes(locals(Count:Int, _T:ValType) , Ls:LocalsVec) + => localsVecToValTypes(Ls) + requires Count <=Int 0 + rule localsVecToValTypes(locals(Count:Int, T:ValType) , Ls:LocalsVec) + => T localsVecToValTypes(locals(Count -Int 1, T) , Ls) + requires Count >Int 0 +endmodule +``` diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/loop.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/loop.md new file mode 100644 index 000000000..4e628b1eb --- /dev/null +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/loop.md @@ -0,0 +1,18 @@ +Parsing [loops](https://webassembly.github.io/spec/core/binary/instructions.html#control-instructions), +i.e., a blocktype + instr list. + +```k + +module BINARY-PARSER-LOOP-SYNTAX + imports BINARY-PARSER-BASE-SYNTAX + imports BINARY-PARSER-BLOCK-SYNTAX + + syntax BinaryInstr ::= loop(Block) + +endmodule + +module BINARY-PARSER-LOOP [private] + imports BINARY-PARSER-LOOP-SYNTAX + +endmodule +``` diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/memarg.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/memarg.md new file mode 100644 index 000000000..4d012de02 --- /dev/null +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/memarg.md @@ -0,0 +1,30 @@ +Parses a [memarg](https://webassembly.github.io/spec/core/binary/instructions.html#binary-memarg) + +```k +module BINARY-PARSER-MEMARG-SYNTAX + imports BINARY-PARSER-BASE-SYNTAX + + syntax MemArg ::= memArg(align:Int, offset:Int) + syntax MemArgResult ::= memArgResult(MemArg, BytesWithIndex) | ParseError + syntax MemArgResult ::= parseMemArg(BytesWithIndex) [function, total] + + syntax Int ::= getMemArgOffset(MemArg) [function, total] +endmodule + +module BINARY-PARSER-MEMARG [private] + imports BINARY-PARSER-INT-SYNTAX + imports BINARY-PARSER-MEMARG-SYNTAX + + syntax MemArgResult ::= #parseMemArg1(IntResult) [function, total] + | #parseMemArg2(Int, IntResult) [function, total] + rule parseMemArg(BWI:BytesWithIndex) => #parseMemArg1(parseLeb128UInt(BWI)) + rule #parseMemArg1(intResult(Value:Int, BWI:BytesWithIndex)) + => #parseMemArg2(Value, parseLeb128UInt(BWI)) + rule #parseMemArg1(E:ParseError) => E + rule #parseMemArg2(Align:Int, intResult(Offset:Int, BWI:BytesWithIndex)) + => memArgResult(memArg(Align, Offset), BWI) + rule #parseMemArg2(_:Int , E:ParseError) => E + + rule getMemArgOffset(memArg(_, Offset:Int)) => Offset +endmodule +``` diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/module.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/module.md index 8cce0db79..5cb0ab07d 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/module.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/module.md @@ -18,52 +18,113 @@ module BINARY-PARSER-MODULE-TEST-SYNTAX endmodule module BINARY-PARSER-MODULE [private] + imports BINARY-PARSER-CODE-SYNTAX imports BINARY-PARSER-CONSTANT-SYNTAX + imports BINARY-PARSER-FUNC-SECTION-ENTRY-SYNTAX + imports BINARY-PARSER-HELPERS-SYNTAX imports BINARY-PARSER-MODULE-SYNTAX imports BINARY-PARSER-MODULE-TEST-SYNTAX imports BINARY-PARSER-SECTION-SYNTAX + imports BINARY-PARSER-SYNTAX imports BINARY-PARSER-TAGS rule parseModule(BWI:BytesWithIndex) => parseModuleSections(reverseSections(splitSections(parseConstant(parseConstant(BWI, MAGIC), VERSION)))) - syntax ModuleResult ::= parseModuleSections(UnparsedSectionsResult) [function, total] - | #parseModuleSections(ParsedSectionsResult, BytesWithIndex) [function, total] + syntax ModuleResult ::= parseModuleSections(UnparsedSectionsResult) [function, total] + | #parseModuleSections1(ParsedSectionsResult, BytesWithIndex) [function, total] + | #parseModuleSections2(ModuleOrError, BytesWithIndex) [function, total] rule parseModuleSections(unparsedSectionsResult(S:UnparsedSections, BWI:BytesWithIndex)) - => #parseModuleSections(parseSections(S), BWI) + => #parseModuleSections1(parseSections(S), BWI) rule parseModuleSections(E:ParseError) => E - rule #parseModuleSections(S:Sections, BWI:BytesWithIndex) - => moduleResult + rule #parseModuleSections1(S:Sections, BWI:BytesWithIndex) + => #parseModuleSections2 ( addSectionsToModule ( S // Do not reverse, as required by addDefnToModule. - , #module - (... types: .Defns - , funcs: .Defns - , tables: .Defns - , mems: .Defns - , globals: .Defns - , elem: .Defns - , data: .Defns - , start: .Defns - , importDefns: .Defns - , exports: .Defns - , metadata: #meta(... id: , funcIds: .Map, filename: .String) + , moduleAndFunctions + ( #module + (... types: .Defns + , funcs: .Defns + , tables: .Defns + , mems: .Defns + , globals: .Defns + , elem: .Defns + , data: .Defns + , start: .Defns + , importDefns: .Defns + , exports: .Defns + , metadata: #meta(... id: , funcIds: .Map, filename: .String) + ) + , .BinaryDefnFunctionTypes + , .BinaryDefnFunctionBodies ) - ), BWI) - rule #parseModuleSections(E:ParseError, _:BytesWithIndex) => E - - syntax ModuleDecl ::= addSectionsToModule(Sections, ModuleDecl) [function, total] - rule addSectionsToModule(.Sections, M:ModuleDecl) => M - rule addSectionsToModule(S:Section : Ss:Sections, M:ModuleDecl) - => addSectionsToModule(Ss, addSectionToModule(S, M)) - syntax ModuleDecl ::= addSectionToModule(Section, ModuleDecl) [function, total] - rule addSectionToModule(customSection(_:Bytes), M:ModuleDecl) => M - rule addSectionToModule(defnsSection(D:Defns), M:ModuleDecl) => addDefnsToModule(D, M) + ) + , BWI + ) + rule #parseModuleSections1(E:ParseError, _:BytesWithIndex) => E + rule #parseModuleSections2(M:ModuleDecl, BWI:BytesWithIndex) + => moduleResult(M, BWI) + rule #parseModuleSections2(E:ParseError, _:BytesWithIndex) => E + + syntax ModuleOrError ::= addSectionsToModule(Sections, ModuleAndFunctions) [function, total] + syntax ModuleOrError ::= #addSectionsToModule(Sections, ModuleAndFunctions) [function, total] + // TODO: Combine the function types with the function definitions and add them to the module. + rule addSectionsToModule + ( .Sections + , moduleAndFunctions + ( #module(... types: Ds:Defns) #as M:ModuleDecl + , FT:BinaryDefnFunctionTypes + , FB:BinaryDefnFunctionBodies + ) + ) + => addOrderedDefnsOrErrorToModule(M, buildFunctionDefns(Ds, FT, FB)) + rule addSectionsToModule(S:Section : Ss:Sections, M:ModuleAndFunctions) + => #addSectionsToModule(Ss, addSectionToModule(S, M)) + rule #addSectionsToModule(Ss:Sections, M:ModuleAndFunctions) + => addSectionsToModule(Ss, M) + + syntax ModuleAndFunctions ::= addSectionToModule(Section, ModuleAndFunctions) [function, total] + rule addSectionToModule(customSection(_:Bytes), M:ModuleAndFunctions) => M + rule addSectionToModule(defnsSection(D:BinaryDefns), M:ModuleAndFunctions) + => addDefnsToModuleAndFunctions(D, M) + + syntax ModuleOrError ::= addOrderedDefnsOrErrorToModule(ModuleDecl, DefnsOrError) [function, total] + rule addOrderedDefnsOrErrorToModule(M:ModuleDecl, D:Defns) + // We need to reverse the defns because addDefnsToModule adds then in + // reverse order. + => addDefnsToModule(reverse(D), M) + rule addOrderedDefnsOrErrorToModule(_:ModuleDecl, E:ParseError) => E + + syntax ModuleAndFunctions ::= moduleAndFunctions + ( mod: ModuleDecl + , functionTypes: BinaryDefnFunctionTypes + , functionBodies: BinaryDefnFunctionBodies + ) + + syntax ModuleAndFunctions ::= addDefnsToModuleAndFunctions(BinaryDefns, ModuleAndFunctions) [function, total] + rule addDefnsToModuleAndFunctions(.BinaryDefns, M:ModuleAndFunctions) => M + rule addDefnsToModuleAndFunctions + ( D:Defn Ds:BinaryDefns => Ds + , moduleAndFunctions(... mod: M:ModuleDecl => addDefnToModule(false, D, M)) + ) + rule addDefnsToModuleAndFunctions + ( (binaryDefnFunctionType(_TypeIndex:Int) #as FT:BinaryDefnFunctionType) Ds:BinaryDefns + => Ds + , moduleAndFunctions(... functionTypes: FTs:BinaryDefnFunctionTypes => FT FTs) + ) + rule addDefnsToModuleAndFunctions + ( (binaryDefnFunctionBody(...) #as FB:BinaryDefnFunctionBody) Ds:BinaryDefns + => Ds + , moduleAndFunctions(... functionBodies: FBs:BinaryDefnFunctionBodies => FB FBs) + ) + syntax ModuleDecl ::= addDefnsToModule(Defns, ModuleDecl) [function, total] rule addDefnsToModule(.Defns, M:ModuleDecl) => M - rule addDefnsToModule(D:Defn Ds:Defns, M:ModuleDecl) - => addDefnsToModule(Ds, addDefnToModule(false, D, M)) + rule addDefnsToModule + ( D:Defn Ds:Defns => Ds + , M:ModuleDecl => addDefnToModule(false, D, M) + ) rule addDefnToModule(true, _, M) => M // The following add the defn at the top of the existing defns (e.g. T Ts), so @@ -71,6 +132,14 @@ module BINARY-PARSER-MODULE [private] // (the last defn should be processed in the first call). rule addDefnToModule(false => true, T:TypeDefn, #module(... types: Ts => T Ts)) rule addDefnToModule(false => true, I:ImportDefn, #module(... importDefns: Is => I Is)) + rule addDefnToModule(false => true, F:FuncDefn, #module(... funcs: Fs => F Fs)) + + // TODO: Merge with #reverseDefns in wasm-text.md + syntax Defns ::= reverse(Defns) [function, total] + rule reverse(D:Defns) => #reverse(D, .Defns) + syntax Defns ::= #reverse(Defns, Defns) [function, total] + rule #reverse(.Defns, Ds:Defns) => Ds + rule #reverse(D:Defn Ds1:Defns, Ds2:Defns) => #reverse(Ds1, D Ds2) endmodule ``` diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/resulttype.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/resulttype.md index b0ae70fff..39b359282 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/resulttype.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/resulttype.md @@ -14,15 +14,11 @@ module BINARY-PARSER-RESULTTYPE [private] imports BINARY-PARSER-RESULTTYPE-SYNTAX imports BINARY-PARSER-VALTYPE-SYNTAX - syntax ResultTypeResult ::= #parseResultType(IntResult) [function, total] - | #parseResultType1(ValTypesResult) [function, total] + syntax ResultTypeResult ::= #parseResultType(ValTypesResult) [function, total] - rule parseResultType(BWI:BytesWithIndex) => #parseResultType(parseLeb128UInt(BWI)) - rule #parseResultType(intResult(Count:Int, BWI:BytesWithIndex)) - => #parseResultType1(parseValTypes(Count, .ValTypes, BWI)) - rule #parseResultType(E:ParseError) => E - rule #parseResultType1(valTypesResult(V:ValTypes, BWI:BytesWithIndex)) + rule parseResultType(BWI:BytesWithIndex) => #parseResultType(parseValTypes(BWI)) + rule #parseResultType(valTypesResult(V:ValTypes, BWI:BytesWithIndex)) => resultTypeResult([V], BWI) - rule #parseResultType1(E:ParseError) => E + rule #parseResultType(E:ParseError) => E endmodule ``` diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/section.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/section.md index 39ff949f4..6468d19ba 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/section.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/section.md @@ -3,13 +3,23 @@ Splitting a module into [sections](https://webassembly.github.io/spec/core/binar ```k module BINARY-PARSER-SECTION-SYNTAX imports BINARY-PARSER-BASE-SYNTAX + imports BINARY-PARSER-DEFN-SYNTAX imports WASM-COMMON-SYNTAX syntax Section ::= customSection(Bytes) - | defnsSection(reverseDefns:Defns) + | defnsSection(reverseDefns:BinaryDefns) + + syntax DefnKind + syntax DefnResult ::= parseDefn(DefnKind, BytesWithIndex) [function, total] syntax SectionResult ::= sectionResult(Section, BytesWithIndex) | ParseError syntax SectionResult ::= parseSection(UnparsedSection) [function, total] + syntax SectionResult ::= parseSectionVector + ( type:DefnKind + , remainingCount:Int + , BinaryDefns + , BytesWithIndex + ) [function, total] syntax Sections ::= List{Section, ":"} syntax ParsedSectionsResult ::= Sections | ParseError @@ -26,6 +36,8 @@ endmodule module BINARY-PARSER-SECTION [private] imports BOOL + imports BINARY-PARSER-CODE-SECTION-SYNTAX + imports BINARY-PARSER-FUNC-SECTION-SYNTAX imports BINARY-PARSER-IMPORT-SECTION-SYNTAX imports BINARY-PARSER-INT-SYNTAX imports BINARY-PARSER-SECTION-SYNTAX @@ -39,6 +51,10 @@ module BINARY-PARSER-SECTION [private] => parseTypeSection(bwi(Data, 0)) rule parseSection(unparsedSection(IMPORT_SEC, Data:Bytes)) => parseImportSection(bwi(Data, 0)) + rule parseSection(unparsedSection(FUNC_SEC, Data:Bytes)) + => parseFuncSection(bwi(Data, 0)) + rule parseSection(unparsedSection(CODE_SEC, Data:Bytes)) + => parseCodeSection(bwi(Data, 0)) rule parseSection(A) => parseError("parseSection", ListItem(A)) [owise] @@ -54,6 +70,31 @@ module BINARY-PARSER-SECTION [private] rule #parseSections(_, E:ParseError) => E [owise] + syntax SectionResult ::= #parseSectionVector + ( type:DefnKind + , remainingCount:Int + , BinaryDefns + , DefnResult + ) [function, total] + rule parseSectionVector(_:DefnKind, 0, D:BinaryDefns, BWI:BytesWithIndex) + => sectionResult(defnsSection(D), BWI) + rule parseSectionVector(T:DefnKind, Count:Int, D:BinaryDefns, BWI:BytesWithIndex) + => #parseSectionVector(T, Count, D, parseDefn(T, BWI)) + requires Count >Int 0 + rule parseSectionVector(T:DefnKind, Count:Int, D:BinaryDefns, bwi(B:Bytes, I:Int)) + => parseError("parseSectionVector", ListItem(T) ListItem(Count) ListItem(D) ListItem(I) ListItem(lengthBytes(B)) ListItem(B)) + [owise] + rule #parseSectionVector + ( T:DefnKind + , RemainingCount:Int + , Ds:BinaryDefns + , defnResult(D:BinaryDefn, BWI:BytesWithIndex) + ) + => parseSectionVector(T, RemainingCount -Int 1, D Ds, BWI) + rule #parseSectionVector(_:DefnKind, _RemainingCount:Int, _Ds:BinaryDefns, E:ParseError) + => E + + syntax UnparsedSectionResult ::= unparsedSectionResult(UnparsedSection, BytesWithIndex) | ParseError syntax UnparsedSectionResult ::= splitSection(BytesWithIndex) [function, total] diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/type-section.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/type-section.md index 8f88bcec4..1728ad88a 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/type-section.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/type-section.md @@ -19,22 +19,11 @@ module BINARY-PARSER-TYPE-SECTION [private] syntax SectionResult ::= #parseTypeSection(IntResult) [function, total] rule parseTypeSection(BWI:BytesWithIndex) => #parseTypeSection(parseLeb128UInt(BWI)) rule #parseTypeSection(intResult(Count:Int, BWI:BytesWithIndex)) - => parseTypeSectionVector(Count, .Defns, BWI) + => parseSectionVector(defnType, Count, .BinaryDefns, BWI) rule #parseTypeSection(E:ParseError) => E - syntax SectionResult ::= parseTypeSectionVector(remainingCount:Int, Defns, BytesWithIndex) [function, total] - | #parseTypeSectionVector(remainingCount:Int, Defns, DefnResult) [function, total] - rule parseTypeSectionVector(0, D:Defns, BWI:BytesWithIndex) => sectionResult(defnsSection(D), BWI) - rule parseTypeSectionVector(Count:Int, D:Defns, BWI:BytesWithIndex) - => #parseTypeSectionVector(Count, D, parseFuncType(BWI)) - requires Count >Int 0 - rule parseTypeSectionVector(Count:Int, D:Defns, bwi(B:Bytes, I:Int)) - => parseError("parseTypeSectionVector", ListItem(Count) ListItem(D) ListItem(I) ListItem(lengthBytes(B)) ListItem(B)) - [owise] - rule #parseTypeSectionVector(RemainingCount:Int, Ds:Defns, defnResult(D:Defn, BWI:BytesWithIndex)) - => parseTypeSectionVector(RemainingCount -Int 1, D Ds, BWI) - rule #parseTypeSectionVector(_RemainingCount:Int, _Ds:Defns, E:ParseError) - => E + syntax DefnKind ::= "defnType" + rule parseDefn(defnType, BWI:BytesWithIndex) => parseDefnType(BWI) endmodule ``` diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/valtype.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/valtype.md index dbc82176a..b0247247c 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/valtype.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/valtype.md @@ -11,11 +11,20 @@ module BINARY-PARSER-VALTYPE-SYNTAX syntax ValTypeResult ::= parseValType(BytesWithIndex) [function, total] syntax ValTypesResult ::= valTypesResult(ValTypes, BytesWithIndex) | ParseError - syntax ValTypesResult ::= parseValTypes(remaining:Int, ValTypes, BytesWithIndex) [function, total] + syntax ValTypesResult ::= parseValTypes(BytesWithIndex) [function, total] + +``` + + Sometimes (see ref.null) we neef to parse a value type as a heap type. + +```k + syntax HeapTypeResult ::= heapTypeResult(HeapType, BytesWithIndex) | ParseError + syntax HeapTypeResult ::= parseHeapType(BytesWithIndex) [function, total] endmodule module BINARY-PARSER-VALTYPE [private] imports BINARY-PARSER-CONSTANT-SYNTAX + imports BINARY-PARSER-INT-SYNTAX imports BINARY-PARSER-TAGS imports BINARY-PARSER-VALTYPE-SYNTAX @@ -53,18 +62,26 @@ module BINARY-PARSER-VALTYPE [private] => E - syntax ValTypesResult ::= #parseValTypes(remaining:Int, ValTypes, ValTypeResult) [function, total] - rule parseValTypes(0, V:ValTypes, BWI:BytesWithIndex) + syntax ValTypesResult ::= #parseValTypes1(IntResult) [function, total] + syntax ValTypesResult ::= #parseValTypes2(remaining:Int, ValTypes, BytesWithIndex) [function, total] + syntax ValTypesResult ::= #parseValTypes3(remaining:Int, ValTypes, ValTypeResult) [function, total] + + rule parseValTypes(BWI:BytesWithIndex) + => #parseValTypes1(parseLeb128UInt(BWI)) + rule #parseValTypes1(intResult(Count:Int, BWI:BytesWithIndex)) + => #parseValTypes2(Count, .ValTypes, BWI) + rule #parseValTypes1(E:ParseError) => E + rule #parseValTypes2(0, V:ValTypes, BWI:BytesWithIndex) => valTypesResult(reverse(V), BWI) - rule parseValTypes(Count:Int, V:ValTypes, BWI:BytesWithIndex) - => #parseValTypes(Count -Int 1, V, parseValType(BWI)) + rule #parseValTypes2(Count:Int, V:ValTypes, BWI:BytesWithIndex) + => #parseValTypes3(Count -Int 1, V, parseValType(BWI)) requires Count >Int 0 - rule parseValTypes(Count:Int, V:ValTypes, bwi(B:Bytes, I:Int)) - => parseError("parseValTypes", ListItem(Count) ListItem(V) ListItem(I) ListItem(lengthBytes(B)) ListItem(B)) + rule #parseValTypes2(Count:Int, V:ValTypes, bwi(B:Bytes, I:Int)) + => parseError("#parseValTypes2", ListItem(Count) ListItem(V) ListItem(I) ListItem(lengthBytes(B)) ListItem(B)) [owise] - rule #parseValTypes(Count:Int, Vs:ValTypes, valTypeResult(V:ValType, BWI:BytesWithIndex)) - => parseValTypes(Count, V Vs, BWI) - rule #parseValTypes(_:Int, _:ValTypes, E:ParseError) => E + rule #parseValTypes3(Count:Int, Vs:ValTypes, valTypeResult(V:ValType, BWI:BytesWithIndex)) + => #parseValTypes2(Count, V Vs, BWI) + rule #parseValTypes3(_:Int, _:ValTypes, E:ParseError) => E syntax ValTypes ::= reverse(ValTypes) [function, total] | #reverse(ValTypes, ValTypes) [function, total] @@ -72,6 +89,17 @@ module BINARY-PARSER-VALTYPE [private] rule #reverse(.ValTypes, Vs:ValTypes) => Vs rule #reverse(V:ValType Vs1:ValTypes, Vs2:ValTypes) => #reverse(Vs1, V Vs2) + syntax HeapTypeResult ::= #parseHeapTypeFuncRef(BytesWithIndex, BytesWithIndexOrError) [function, total] + | #parseHeapTypeExtRef(BytesWithIndex, BytesWithIndexOrError) [function, total] + rule parseHeapType(BWI:BytesWithIndex) + => #parseHeapTypeFuncRef(BWI, parseConstant(BWI, TYPE_FUN_REF)) + rule #parseHeapTypeFuncRef(_, BWI:BytesWithIndex) => heapTypeResult(func, BWI) + rule #parseHeapTypeFuncRef(BWI:BytesWithIndex, _:ParseError) + => #parseHeapTypeExtRef(BWI, parseConstant(BWI, TYPE_EXT_REF)) + rule #parseHeapTypeExtRef(_, BWI:BytesWithIndex) => heapTypeResult(extern, BWI) + rule #parseHeapTypeExtRef(_:BytesWithIndex, E:ParseError) + => E + endmodule ``` \ No newline at end of file diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/data.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/data.md index 3c26e7013..99e4df442 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/data.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/data.md @@ -312,6 +312,8 @@ For `Int`, however, a the context is irrelevant and the index always just resolv syntax Index ::= #getElemSegment (ElemSegment, Int) [function] syntax Int ::= #lenInts (Ints) [function, total] syntax Int ::= #getInts (Ints, Int) [function] + syntax Ints ::= #appendInts (Ints, Int) [function, total] + syntax Ints ::= #reverseInts (Ints) [function, total] // -------------------------------------------------------------- rule #lenElemSegment(.ElemSegment) => 0 rule #lenElemSegment(_TFIDX ES) => 1 +Int #lenElemSegment(ES) @@ -325,6 +327,14 @@ For `Int`, however, a the context is irrelevant and the index always just resolv rule #getInts(E _ES, 0) => E rule #getInts(_E ES, I) => #getInts(ES, I -Int 1) requires I >Int 0 + rule #appendInts(.Ints, N:Int) => N .Ints + rule #appendInts(I:Int Is:Ints, N:Int) => I #appendInts(Is, N) + + rule #reverseInts(Is:Ints) => #reverseIntsHelper(Is, .Ints) + syntax Ints ::= #reverseIntsHelper(Ints, Ints) [function, total] + rule #reverseIntsHelper(.Ints, Is:Ints) => Is + rule #reverseIntsHelper(I:Int Is:Ints, Js:Ints) => #reverseIntsHelper(Is, I Js) + syntax Ints ::= elemSegment2Ints ( ElemSegment ) [function] // ----------------------------------------------------------- rule elemSegment2Ints(.ElemSegment) => .Ints diff --git a/pykwasm/src/pykwasm/scripts/binary-parser-gen.py b/pykwasm/src/pykwasm/scripts/binary-parser-gen.py new file mode 100644 index 000000000..b139f9cea --- /dev/null +++ b/pykwasm/src/pykwasm/scripts/binary-parser-gen.py @@ -0,0 +1,978 @@ +import os +from dataclasses import dataclass + +def bytes_to_k(b:bytes) -> str: + escaped_bytes = ''.join([f'\\x{b:02x}' for b in b]) + return 'b"' + escaped_bytes + '"' + +class Constructor: + def build(self, args: list[tuple['Argument', int]], bwi:str, output_pieces: list[str]) -> None: + raise NotImplementedError('Constructor.build') + def needs_bwi(self) -> bool: + raise NotImplementedError('Constructor.needs_bwi') + +@dataclass(frozen=True) +class Symbol(Constructor): + name: str + + def build(self, args: list['Argument'], bwi:str, output_pieces: list[str]) -> None: + output_pieces.append(f'instrResult(`{self.name}`(') + first = True + for i, arg in enumerate(args): + if not arg.is_used_in_constructor(): + continue + if not first: + output_pieces.append(', ') + first = False + output_pieces.append(arg.rhs_argument(i, True)) + if first: + output_pieces.append('.KList') + output_pieces.append(f'), {bwi})') + + def needs_bwi(self) -> bool: + return True + +def symbol(s:str) -> Symbol: + return Symbol(s) + +class Identity(Constructor): + def build(self, args: list['Argument'], bwi:str, output_pieces: list[str]) -> None: + first = True + output_pieces.append('instrResult(') + for i, arg in enumerate(args): + if not arg.is_used_in_constructor(): + continue + if not first: + raise ValueError(f'Identity constructor requires exactly one argument: {args}') + first = False + output_pieces.append(arg.rhs_argument(i, True)) + output_pieces.append(f', {bwi})') + + def needs_bwi(self) -> bool: + return True + +def identity() -> Identity: + return Identity() + +class NotImplemented(Constructor): + def build(self, args: list['Argument'], bwi:str, output_pieces: list[str]) -> None: + output_pieces.append('parseError("instruction not implemented",') + for i, arg in enumerate(args): + if not arg.is_used_in_constructor(): + continue + if not arg.is_parsing_arg(): + continue + output_pieces.append(f' ListItem({arg.rhs_argument(i, False)})') + output_pieces.append(f' ListItem({bwi}))') + + def needs_bwi(self) -> bool: + return True + +def not_implemented(): + return NotImplemented() + +@dataclass(frozen=True) +class Parser(Constructor): + parser_name: str + + def build(self, args: list['Argument'], bwi:str, output_pieces: list[str]) -> None: + output_pieces.append(f'{self.parser_name}(') + first = True + for i, arg in enumerate(args): + if not arg.is_used_in_constructor(): + continue + if not first: + output_pieces.append(', ') + first = False + output_pieces.append(arg.rhs_argument(i, True)) + if not first: + output_pieces.append(', ') + output_pieces.append(f'{bwi})') + + def needs_bwi(self) -> bool: + return True + +def parser(s:str): + return Parser(s) + +@dataclass(frozen=True) +class ConstructorResult(Constructor): + name: str + + def build(self, args: list['Argument'], bwi:str, output_pieces: list[str]) -> None: + output_pieces.append(f'instrResult({self.name}') + if args: + first = True + for i, arg in enumerate(args): + if not arg.is_used_in_constructor(): + continue + if first: + output_pieces.append('(') + first = False + else: + output_pieces.append(', ') + output_pieces.append(arg.rhs_argument(i, True)) + if not first: + output_pieces.append(')') + output_pieces.append(f', {bwi})') + + def needs_bwi(self) -> bool: + return True + +class Argument: + def parser(self, bwi: str) -> str: + raise NotImplementedError('Argument.parser') + def is_used_in_constructor(self) -> bool: + raise NotImplementedError('Argument.is_used_in_constructor') + def is_parsing_arg(self) -> bool: + raise NotImplementedError('Argument.is_parsing_arg') + def result_argument(self, index:int, bwi: str) -> str: + raise NotImplementedError('Argument.result_argument') + def result_type(self) -> str: + raise NotImplementedError('Argument.result_type') + def value_type(self) -> str: + raise NotImplementedError('Argument.value_type') + def lhs_argument(self, index: int, unused: bool) -> str: + raise NotImplementedError('Argument.lhs_argument') + def rhs_argument(self, index: int, cast_final_argument: int) -> str: + raise NotImplementedError('Argument.rhs_argument') + +@dataclass(frozen=True) +class TypedArg(Argument): + arg_type: str + + def parser(self, bwi: str) -> str: + if self.arg_type == 'UnsignedInt': + parse_fn = 'parseLeb128UInt' + elif self.arg_type == 'SignedInt': + parse_fn = 'parseLeb128SInt' + else: + parse_fn = f'parse{self.arg_type}' + + return f'{parse_fn}({bwi})' + + def is_used_in_constructor(self) -> bool: + return True + + def is_parsing_arg(self) -> bool: + return True + + def result_argument(self, index:int, bwi: str) -> str: + t = self.result_type() + it = self.inner_type() + mid = '' + if self.arg_type == "Block": + mid = ' _:Bool,' + return f'{t[0].lower()}{t[1:]}({self.arg_type}{index}:{it},{mid} {bwi}:BytesWithIndex)' + + def result_type(self) -> str: + t = self.inner_type() + return f'{t}Result' + + def inner_type(self) -> str: + if self.arg_type == 'UnsignedInt': + return 'Int' + if self.arg_type == 'SignedInt': + return 'Int' + if self.arg_type == 'UnsignedIntVec': + return 'Ints' + if self.arg_type == 'Float32': + return 'Float' + if self.arg_type == 'Float64': + return 'Float' + return self.arg_type + + def value_type(self) -> str: + return self.inner_type() + + def lhs_argument(self, index:int, unused: bool) -> str: + if unused: + prefix = '_' + else: + prefix = '' + return f'{prefix}{self.arg_type}{index}:{self.value_type()}' + + def rhs_argument(self, index:int, cast_final_argument: bool) -> str: + if self.arg_type == 'MemArg' and cast_final_argument: + return f'getMemArgOffset({self.arg_type}{index})' + return f'{self.arg_type}{index}' + +@dataclass(frozen=True) +class ConstructorArg(Argument): + name: str + + def is_used_in_constructor(self) -> bool: + return True + + def is_parsing_arg(self) -> bool: + return False + + def rhs_argument(self, index:int, cast_final_argument: bool) -> str: + return self.name + +def constructor_arg(name:str) -> ConstructorArg: + return ConstructorArg(name) + +@dataclass(frozen=True) +class ParseOnlyConstant(Argument): + value: bytes + + def parser(self, bwi: str) -> str: + return f'parseConstant({bwi}, {bytes_to_k(self.value)})' + + def is_used_in_constructor(self) -> bool: + return False + + def is_parsing_arg(self) -> bool: + return True + + def result_argument(self, index:int, bwi: str) -> str: + return f'{bwi}:BytesWithIndex' + + def result_type(self) -> str: + return 'BytesWithIndexOrError' + +def parse_constant(b:bytes): + return ParseOnlyConstant(b) + +@dataclass(frozen=True) +class RepeatedBytes(Argument): + count: int + + def parser(self, bwi: str) -> str: + return f'ignoreBytes({bwi}, {self.count})' + + def is_used_in_constructor(self) -> bool: + return False + + def is_parsing_arg(self) -> bool: + return True + + def result_argument(self, index:int, bwi: str) -> str: + return f'{bwi}:BytesWithIndex' + + def result_type(self) -> str: + return 'BytesWithIndexOrError' + +def repeated_bytes(count:int): + return RepeatedBytes(count) + +@dataclass(frozen=True) +class RepeatedType(Argument): + type_: str + count: int + + def parser(self, bwi: str) -> str: + return f'ignore{self.type_}({bwi}, {self.count})' + + def is_used_in_constructor(self) -> bool: + return False + + def is_parsing_arg(self) -> bool: + return True + + def result_argument(self, index:int, bwi: str) -> str: + return f'{bwi}:BytesWithIndex' + + def result_type(self) -> str: + return 'BytesWithIndexOrError' + +def repeated_type(value_type: str, count:int) -> RepeatedType: + return RepeatedType(value_type, count) + +@dataclass(frozen=True) +class InstrConfig: + name: str + prefix: bytes + args: list[Argument] + constructor: Constructor + + def __init__(self, name: str, prefix: bytes, args: list[str|Argument], constructor: str|Constructor) -> None: + object.__setattr__(self, 'name', name) + object.__setattr__(self, 'prefix', prefix) + object.__setattr__(self, 'args', [arg if isinstance(arg, Argument) else TypedArg(arg) for arg in args]) + object.__setattr__(self, 'constructor', constructor if isinstance(constructor, Constructor) else ConstructorResult(constructor)) + + def with_prefix(self, p: bytes) -> 'InstrConfig': + return InstrConfig(self.name, p, self.args, self.constructor) + +INSTRS_CONFIG:list[InstrConfig]=[ + # Wasm _control instructions_ are encoded with the follow tags. + # Note that `ELSE` instructions must appear in conjunction with `IF` instructions. + + # The tuple structure is: + # ('INSTRUCTION_NAME', b'instruction-prefix', ['Argument1Type', 'Argument2Type', ...], '#ConstructorName') + InstrConfig('UNREACHABLE', b'\x00', [], 'unreachable'), + InstrConfig('NOP', b'\x01', [], 'nop'), + InstrConfig('BLOCK', b'\x02', ['Block', ], identity()), # #block + InstrConfig('LOOP', b'\x03', ['Block', ], 'loop'), # #loop + InstrConfig('IF', b'\x04', [], parser('parseIf')), + # ('ELSE', b'\x05', [], ''), -- Parsed as part of 'If' + InstrConfig('BR', b'\x0C', ['UnsignedInt', ], '#br'), + InstrConfig('BR_IF', b'\x0D', ['UnsignedInt', ], '#br_if'), + InstrConfig('BR_TABLE', b'\x0E', ['UnsignedIntVec', 'UnsignedInt', ], 'buildBrTable'), + InstrConfig('RETURN', b'\x0F', [], 'return'), + InstrConfig('CALL', b'\x10', ['UnsignedInt', ], '#call'), + InstrConfig('CALL_INDIRECT', b'\x11', ['UnsignedInt', 'UnsignedInt', ], 'buildCallIndirect'), # #call_indirect + + # _Reference instructions_ are encoded with the following tags: + + InstrConfig('REF_NULL', b'\xD0', ['HeapType', ], symbol('aRef.null')), + InstrConfig('REF_ISNULL', b'\xD1', [], '#ref.is_null'), + InstrConfig('REF_FUNC', b'\xD2', ['UnsignedInt', ], '#ref.func'), + + InstrConfig('DROP', b'\x1A', [], 'drop'), + InstrConfig('SELECT', b'\x1B', [], 'select'), + InstrConfig('SELECT_GENERIC', b'\x1C', ['ValTypes', ], not_implemented()), + + # _Variable instructions_ are encoded with the following tags: + + InstrConfig('LOCAL_GET', b'\x20', ['UnsignedInt', ], '#local.get'), + InstrConfig('LOCAL_SET', b'\x21', ['UnsignedInt', ], '#local.set'), + InstrConfig('LOCAL_TEE', b'\x22', ['UnsignedInt', ], '#local.tee'), + InstrConfig('GLOBAL_GET', b'\x23', ['UnsignedInt', ], '#global.get'), + InstrConfig('GLOBAL_SET', b'\x24', ['UnsignedInt', ], '#global.set'), + + # _Table instructions_ are encoded with the following tags: + + InstrConfig('TABLE_GET', b'\x25', ['UnsignedInt', ], '#table.get'), + InstrConfig('TABLE_SET', b'\x26', ['UnsignedInt', ], '#table.set'), + InstrConfig('TABLE_INIT', b'\xFC\x0C', ['UnsignedInt', 'UnsignedInt', ], '#table.init'), + InstrConfig('ELEM_DROP', b'\xFC\x0D', ['UnsignedInt', ], '#elem.drop'), + InstrConfig('TABLE_COPY', b'\xFC\x0E', ['UnsignedInt', 'UnsignedInt', ], '#table.copy'), + InstrConfig('TABLE_GROW', b'\xFC\x0F', ['UnsignedInt', ], '#table.grow'), + InstrConfig('TABLE_SIZE', b'\xFC\x10', ['UnsignedInt', ], '#table.size'), + InstrConfig('TABLE_FILL', b'\xFC\x11', ['UnsignedInt', ], '#table.fill'), + + # _Memory instructions_ are encoded with the following tags: + + InstrConfig('I32_LOAD', b'\x28', [constructor_arg('i32'), constructor_arg('load'), 'MemArg', ], '#load'), + InstrConfig('I64_LOAD', b'\x29', [constructor_arg('i64'), constructor_arg('load'), 'MemArg', ], '#load'), + InstrConfig('F32_LOAD', b'\x2A', [constructor_arg('f32'), constructor_arg('load'), 'MemArg', ], '#load'), + InstrConfig('F64_LOAD', b'\x2B', [constructor_arg('f64'), constructor_arg('load'), 'MemArg', ], '#load'), + InstrConfig('I32_LOAD_8_S', b'\x2C', [constructor_arg('i32'), constructor_arg('load8_s'), 'MemArg', ], '#load'), + InstrConfig('I32_LOAD_8_U', b'\x2D', [constructor_arg('i32'), constructor_arg('load8_u'), 'MemArg', ], '#load'), + InstrConfig('I32_LOAD_16_S', b'\x2E', [constructor_arg('i32'), constructor_arg('load16_s'), 'MemArg', ], '#load'), + InstrConfig('I32_LOAD_16_U', b'\x2F', [constructor_arg('i32'), constructor_arg('load16_u'), 'MemArg', ], '#load'), + InstrConfig('I64_LOAD_8_S', b'\x30', [constructor_arg('i64'), constructor_arg('load8_s'), 'MemArg', ], '#load'), + InstrConfig('I64_LOAD_8_U', b'\x31', [constructor_arg('i64'), constructor_arg('load8_u'), 'MemArg', ], '#load'), + InstrConfig('I64_LOAD_16_S', b'\x32', [constructor_arg('i64'), constructor_arg('load16_s'), 'MemArg', ], '#load'), + InstrConfig('I64_LOAD_16_U', b'\x33', [constructor_arg('i64'), constructor_arg('load16_u'), 'MemArg', ], '#load'), + InstrConfig('I64_LOAD_32_S', b'\x34', [constructor_arg('i64'), constructor_arg('load32_s'), 'MemArg', ], '#load'), + InstrConfig('I64_LOAD_32_U', b'\x35', [constructor_arg('i64'), constructor_arg('load32_u'), 'MemArg', ], '#load'), + InstrConfig('I32_STORE', b'\x36', [constructor_arg('i32'), constructor_arg('store'), 'MemArg', ], '#store'), + InstrConfig('I64_STORE', b'\x37', [constructor_arg('i64'), constructor_arg('store'), 'MemArg', ], '#store'), + InstrConfig('F32_STORE', b'\x38', [constructor_arg('f32'), constructor_arg('store'), 'MemArg', ], '#store'), + InstrConfig('F64_STORE', b'\x39', [constructor_arg('f64'), constructor_arg('store'), 'MemArg', ], '#store'), + InstrConfig('I32_STORE_8', b'\x3A', [constructor_arg('i32'), constructor_arg('store8'), 'MemArg', ], '#store'), + InstrConfig('I32_STORE_16', b'\x3B', [constructor_arg('i32'), constructor_arg('store16'), 'MemArg', ], '#store'), + InstrConfig('I64_STORE_8', b'\x3C', [constructor_arg('i64'), constructor_arg('store8'), 'MemArg', ], '#store'), + InstrConfig('I64_STORE_16', b'\x3D', [constructor_arg('i64'), constructor_arg('store16'), 'MemArg', ], '#store'), + InstrConfig('I64_STORE_32', b'\x3E', [constructor_arg('i64'), constructor_arg('store32'), 'MemArg', ], '#store'), + InstrConfig('MEM_SIZE', b'\x3F', [], 'memory.size'), + InstrConfig('MEM_GROW', b'\x40', [], 'memory.grow'), + InstrConfig('MEM_INIT', b'\xFC\x08', ['UnsignedInt', parse_constant(b'\x00'), ], not_implemented()), + InstrConfig('DATA_DROP', b'\xFC\x09', ['UnsignedInt', ], not_implemented()), + InstrConfig('MEM_COPY', b'\xFC\x0A', [parse_constant(b'\x00'), parse_constant(b'\x00'), ], 'memory.copy'), + InstrConfig('MEM_FILL', b'\xFC\x0B', [parse_constant(b'\x00'), ], 'memory.fill'), + + # _Numeric instructions_ have the following tags: + + InstrConfig('I32_CONST', b'\x41', [constructor_arg('i32'), 'SignedInt', ], symbol('aIConst')), + InstrConfig('I64_CONST', b'\x42', [constructor_arg('i64'), 'SignedInt', ], symbol('aIConst')), + InstrConfig('F32_CONST', b'\x43', [constructor_arg('f32'), 'Float32', ], symbol('aFConst')), + InstrConfig('F64_CONST', b'\x44', [constructor_arg('f64'), 'Float64', ], symbol('aFConst')), + + InstrConfig('I32_EQZ', b'\x45', [constructor_arg('i32'), constructor_arg('eqz'), ], symbol('aTestOp')), + InstrConfig('I32_EQ', b'\x46', [constructor_arg('i32'), constructor_arg('eq'), ], symbol('aIRelOp')), + InstrConfig('I32_NE', b'\x47', [constructor_arg('i32'), constructor_arg('ne'), ], symbol('aIRelOp')), + InstrConfig('I32_LT_S', b'\x48', [constructor_arg('i32'), constructor_arg('lt_s'), ], symbol('aIRelOp')), + InstrConfig('I32_LT_U', b'\x49', [constructor_arg('i32'), constructor_arg('lt_u'), ], symbol('aIRelOp')), + InstrConfig('I32_GT_S', b'\x4A', [constructor_arg('i32'), constructor_arg('gt_s'), ], symbol('aIRelOp')), + InstrConfig('I32_GT_U', b'\x4B', [constructor_arg('i32'), constructor_arg('gt_u'), ], symbol('aIRelOp')), + InstrConfig('I32_LE_S', b'\x4C', [constructor_arg('i32'), constructor_arg('le_s'), ], symbol('aIRelOp')), + InstrConfig('I32_LE_U', b'\x4D', [constructor_arg('i32'), constructor_arg('le_u'), ], symbol('aIRelOp')), + InstrConfig('I32_GE_S', b'\x4E', [constructor_arg('i32'), constructor_arg('ge_s'), ], symbol('aIRelOp')), + InstrConfig('I32_GE_U', b'\x4F', [constructor_arg('i32'), constructor_arg('ge_u'), ], symbol('aIRelOp')), + + InstrConfig('I64_EQZ', b'\x50', [constructor_arg('i64'), constructor_arg('eqz'), ], symbol('aTestOp')), + InstrConfig('I64_EQ', b'\x51', [constructor_arg('i64'), constructor_arg('eq'), ], symbol('aIRelOp')), + InstrConfig('I64_NE', b'\x52', [constructor_arg('i64'), constructor_arg('ne'), ], symbol('aIRelOp')), + InstrConfig('I64_LT_S', b'\x53', [constructor_arg('i64'), constructor_arg('lt_s'), ], symbol('aIRelOp')), + InstrConfig('I64_LT_U', b'\x54', [constructor_arg('i64'), constructor_arg('lt_u'), ], symbol('aIRelOp')), + InstrConfig('I64_GT_S', b'\x55', [constructor_arg('i64'), constructor_arg('gt_s'), ], symbol('aIRelOp')), + InstrConfig('I64_GT_U', b'\x56', [constructor_arg('i64'), constructor_arg('gt_u'), ], symbol('aIRelOp')), + InstrConfig('I64_LE_S', b'\x57', [constructor_arg('i64'), constructor_arg('le_s'), ], symbol('aIRelOp')), + InstrConfig('I64_LE_U', b'\x58', [constructor_arg('i64'), constructor_arg('le_u'), ], symbol('aIRelOp')), + InstrConfig('I64_GE_S', b'\x59', [constructor_arg('i64'), constructor_arg('ge_s'), ], symbol('aIRelOp')), + InstrConfig('I64_GE_U', b'\x5A', [constructor_arg('i64'), constructor_arg('ge_u'), ], symbol('aIRelOp')), + + InstrConfig('F32_EQ', b'\x5B', [constructor_arg('f32'), constructor_arg('eq'), ], symbol('aFRelOp')), + InstrConfig('F32_NE', b'\x5C', [constructor_arg('f32'), constructor_arg('ne'), ], symbol('aFRelOp')), + InstrConfig('F32_LT', b'\x5D', [constructor_arg('f32'), constructor_arg('lt'), ], symbol('aFRelOp')), + InstrConfig('F32_GT', b'\x5E', [constructor_arg('f32'), constructor_arg('gt'), ], symbol('aFRelOp')), + InstrConfig('F32_LE', b'\x5F', [constructor_arg('f32'), constructor_arg('le'), ], symbol('aFRelOp')), + InstrConfig('F32_GE', b'\x60', [constructor_arg('f32'), constructor_arg('ge'), ], symbol('aFRelOp')), + + InstrConfig('F64_EQ', b'\x61', [constructor_arg('f64'), constructor_arg('eq'), ], symbol('aFRelOp')), + InstrConfig('F64_NE', b'\x62', [constructor_arg('f64'), constructor_arg('ne'), ], symbol('aFRelOp')), + InstrConfig('F64_LT', b'\x63', [constructor_arg('f64'), constructor_arg('lt'), ], symbol('aFRelOp')), + InstrConfig('F64_GT', b'\x64', [constructor_arg('f64'), constructor_arg('gt'), ], symbol('aFRelOp')), + InstrConfig('F64_LE', b'\x65', [constructor_arg('f64'), constructor_arg('le'), ], symbol('aFRelOp')), + InstrConfig('F64_GE', b'\x66', [constructor_arg('f64'), constructor_arg('ge'), ], symbol('aFRelOp')), + + InstrConfig('I32_CLZ', b'\x67', [constructor_arg('i32'), constructor_arg('clz'), ], symbol('aIUnOp')), + InstrConfig('I32_CTZ', b'\x68', [constructor_arg('i32'), constructor_arg('ctz'), ], symbol('aIUnOp')), + InstrConfig('I32_POPCNT', b'\x69', [constructor_arg('i32'), constructor_arg('popcnt'), ], symbol('aIUnOp')), + InstrConfig('I32_ADD', b'\x6A', [constructor_arg('i32'), constructor_arg('add'), ], symbol('aIBinOp')), + InstrConfig('I32_SUB', b'\x6B', [constructor_arg('i32'), constructor_arg('sub'), ], symbol('aIBinOp')), + InstrConfig('I32_MUL', b'\x6C', [constructor_arg('i32'), constructor_arg('mul'), ], symbol('aIBinOp')), + InstrConfig('I32_DIV_S', b'\x6D', [constructor_arg('i32'), constructor_arg('div_s'), ], symbol('aIBinOp')), + InstrConfig('I32_DIV_U', b'\x6E', [constructor_arg('i32'), constructor_arg('div_u'), ], symbol('aIBinOp')), + InstrConfig('I32_REM_S', b'\x6F', [constructor_arg('i32'), constructor_arg('rem_s'), ], symbol('aIBinOp')), + InstrConfig('I32_REM_U', b'\x70', [constructor_arg('i32'), constructor_arg('rem_u'), ], symbol('aIBinOp')), + InstrConfig('I32_AND', b'\x71', [constructor_arg('i32'), constructor_arg('and'), ], symbol('aIBinOp')), + InstrConfig('I32_OR', b'\x72', [constructor_arg('i32'), constructor_arg('or'), ], symbol('aIBinOp')), + InstrConfig('I32_XOR', b'\x73', [constructor_arg('i32'), constructor_arg('xor'), ], symbol('aIBinOp')), + InstrConfig('I32_SHL', b'\x74', [constructor_arg('i32'), constructor_arg('shl'), ], symbol('aIBinOp')), + InstrConfig('I32_SHR_S', b'\x75', [constructor_arg('i32'), constructor_arg('shr_s'), ], symbol('aIBinOp')), + InstrConfig('I32_SHR_U', b'\x76', [constructor_arg('i32'), constructor_arg('shr_u'), ], symbol('aIBinOp')), + InstrConfig('I32_ROTL', b'\x77', [constructor_arg('i32'), constructor_arg('rotl'), ], symbol('aIBinOp')), + InstrConfig('I32_ROTR', b'\x78', [constructor_arg('i32'), constructor_arg('rotr'), ], symbol('aIBinOp')), + + InstrConfig('I64_CLZ', b'\x79', [constructor_arg('i32'), constructor_arg('clz'), ], symbol('aIUnOp')), + InstrConfig('I64_CTZ', b'\x7A', [constructor_arg('i32'), constructor_arg('ctz'), ], symbol('aIUnOp')), + InstrConfig('I64_POPCNT', b'\x7B', [constructor_arg('i32'), constructor_arg('popcnt'), ], symbol('aIUnOp')), + InstrConfig('I64_ADD', b'\x7C', [constructor_arg('i64'), constructor_arg('add'), ], symbol('aIBinOp')), + InstrConfig('I64_SUB', b'\x7D', [constructor_arg('i64'), constructor_arg('sub'), ], symbol('aIBinOp')), + InstrConfig('I64_MUL', b'\x7E', [constructor_arg('i64'), constructor_arg('mul'), ], symbol('aIBinOp')), + InstrConfig('I64_DIV_S', b'\x7F', [constructor_arg('i64'), constructor_arg('div_s'), ], symbol('aIBinOp')), + InstrConfig('I64_DIV_U', b'\x80', [constructor_arg('i64'), constructor_arg('div_u'), ], symbol('aIBinOp')), + InstrConfig('I64_REM_S', b'\x81', [constructor_arg('i64'), constructor_arg('rem_s'), ], symbol('aIBinOp')), + InstrConfig('I64_REM_U', b'\x82', [constructor_arg('i64'), constructor_arg('rem_u'), ], symbol('aIBinOp')), + InstrConfig('I64_AND', b'\x83', [constructor_arg('i64'), constructor_arg('and'), ], symbol('aIBinOp')), + InstrConfig('I64_OR', b'\x84', [constructor_arg('i64'), constructor_arg('or'), ], symbol('aIBinOp')), + InstrConfig('I64_XOR', b'\x85', [constructor_arg('i64'), constructor_arg('xor'), ], symbol('aIBinOp')), + InstrConfig('I64_SHL', b'\x86', [constructor_arg('i64'), constructor_arg('shl'), ], symbol('aIBinOp')), + InstrConfig('I64_SHR_S', b'\x87', [constructor_arg('i64'), constructor_arg('shr_s'), ], symbol('aIBinOp')), + InstrConfig('I64_SHR_U', b'\x88', [constructor_arg('i64'), constructor_arg('shr_u'), ], symbol('aIBinOp')), + InstrConfig('I64_ROTL', b'\x89', [constructor_arg('i64'), constructor_arg('rotl'), ], symbol('aIBinOp')), + InstrConfig('I64_ROTR', b'\x8A', [constructor_arg('i64'), constructor_arg('rotr'), ], symbol('aIBinOp')), + + InstrConfig('F32_ABS', b'\x8B', [constructor_arg('f32'), constructor_arg('abs'), ], symbol('aFUnOp')), + InstrConfig('F32_NEG', b'\x8C', [constructor_arg('f32'), constructor_arg('neg'), ], symbol('aFUnOp')), + InstrConfig('F32_CEIL', b'\x8D', [constructor_arg('f32'), constructor_arg('ceil'), ], symbol('aFUnOp')), + InstrConfig('F32_FLOOR', b'\x8E', [constructor_arg('f32'), constructor_arg('floor'), ], symbol('aFUnOp')), + InstrConfig('F32_TRUNC', b'\x8F', [constructor_arg('f32'), constructor_arg('trunc'), ], symbol('aFUnOp')), + InstrConfig('F32_NEAREST', b'\x90', [constructor_arg('f32'), constructor_arg('nearest'), ], symbol('aFUnOp')), + InstrConfig('F32_SQRT', b'\x91', [constructor_arg('f32'), constructor_arg('sqrt'), ], symbol('aFUnOp')), + InstrConfig('F32_ADD', b'\x92', [constructor_arg('f32'), constructor_arg('add'), ], symbol('aFBinOp')), + InstrConfig('F32_SUB', b'\x93', [constructor_arg('f32'), constructor_arg('sub'), ], symbol('aFBinOp')), + InstrConfig('F32_MUL', b'\x94', [constructor_arg('f32'), constructor_arg('mul'), ], symbol('aFBinOp')), + InstrConfig('F32_DIV', b'\x95', [constructor_arg('f32'), constructor_arg('div'), ], symbol('aFBinOp')), + InstrConfig('F32_MIN', b'\x96', [constructor_arg('f32'), constructor_arg('min'), ], symbol('aFBinOp')), + InstrConfig('F32_MAX', b'\x97', [constructor_arg('f32'), constructor_arg('max'), ], symbol('aFBinOp')), + InstrConfig('F32_COPYSIGN', b'\x98', [constructor_arg('f32'), constructor_arg('copysign'), ], symbol('aFBinOp')), + + InstrConfig('F64_ABS', b'\x99', [constructor_arg('f64'), constructor_arg('abs'), ], symbol('aFUnOp')), + InstrConfig('F64_NEG', b'\x9A', [constructor_arg('f64'), constructor_arg('neg'), ], symbol('aFUnOp')), + InstrConfig('F64_CEIL', b'\x9B', [constructor_arg('f64'), constructor_arg('ceil'), ], symbol('aFUnOp')), + InstrConfig('F64_FLOOR', b'\x9C', [constructor_arg('f64'), constructor_arg('floor'), ], symbol('aFUnOp')), + InstrConfig('F64_TRUNC', b'\x9D', [constructor_arg('f64'), constructor_arg('trunc'), ], symbol('aFUnOp')), + InstrConfig('F64_NEAREST', b'\x9E', [constructor_arg('f64'), constructor_arg('nearest'), ], symbol('aFUnOp')), + InstrConfig('F64_SQRT', b'\x9F', [constructor_arg('f64'), constructor_arg('sqrt'), ], symbol('aFUnOp')), + InstrConfig('F64_ADD', b'\xA0', [constructor_arg('f32'), constructor_arg('add'), ], symbol('aFBinOp')), + InstrConfig('F64_SUB', b'\xA1', [constructor_arg('f32'), constructor_arg('sub'), ], symbol('aFBinOp')), + InstrConfig('F64_MUL', b'\xA2', [constructor_arg('f32'), constructor_arg('mul'), ], symbol('aFBinOp')), + InstrConfig('F64_DIV', b'\xA3', [constructor_arg('f32'), constructor_arg('div'), ], symbol('aFBinOp')), + InstrConfig('F64_MIN', b'\xA4', [constructor_arg('f32'), constructor_arg('min'), ], symbol('aFBinOp')), + InstrConfig('F64_MAX', b'\xA5', [constructor_arg('f32'), constructor_arg('max'), ], symbol('aFBinOp')), + InstrConfig('F64_COPYSIGN', b'\xA6', [constructor_arg('f32'), constructor_arg('copysign'), ], symbol('aFBinOp')), + + InstrConfig('I32_WRAP_I64', b'\xA7', [constructor_arg('i32'), constructor_arg('wrap_i64'), ], symbol('aCvtOp')), + InstrConfig('I32_TRUNC_F32_S', b'\xA8', [constructor_arg('i32'), constructor_arg('trunc_f32_s'), ], symbol('aCvtOp')), + InstrConfig('I32_TRUNC_F32_U', b'\xA9', [constructor_arg('i32'), constructor_arg('trunc_f32_u'), ], symbol('aCvtOp')), + InstrConfig('I32_TRUNC_F64_S', b'\xAA', [constructor_arg('i32'), constructor_arg('trunc_f64_s'), ], symbol('aCvtOp')), + InstrConfig('I32_TRUNC_F64_U', b'\xAB', [constructor_arg('i32'), constructor_arg('trunc_f64_u'), ], symbol('aCvtOp')), + + InstrConfig('I64_EXTEND_I32_S', b'\xAC', [constructor_arg('i64'), constructor_arg('extend_i32_s'), ], symbol('aCvtOp')), + InstrConfig('I64_EXTEND_I32_U', b'\xAD', [constructor_arg('i64'), constructor_arg('extend_i32_u'), ], symbol('aCvtOp')), + InstrConfig('I64_TRUNC_F32_S', b'\xAE', [constructor_arg('i64'), constructor_arg('trunc_f32_s'), ], symbol('aCvtOp')), + InstrConfig('I64_TRUNC_F32_U', b'\xAF', [constructor_arg('i64'), constructor_arg('trunc_f32_u'), ], symbol('aCvtOp')), + InstrConfig('I64_TRUNC_F64_S', b'\xB0', [constructor_arg('i64'), constructor_arg('trunc_f64_s'), ], symbol('aCvtOp')), + InstrConfig('I64_TRUNC_F64_U', b'\xB1', [constructor_arg('i64'), constructor_arg('trunc_f64_u'), ], symbol('aCvtOp')), + + InstrConfig('F32_CONVERT_I32_S', b'\xB2', [constructor_arg('f32'), constructor_arg('convert_i32_s'), ], symbol('aCvtOp')), + InstrConfig('F32_CONVERT_I32_U', b'\xB3', [constructor_arg('f32'), constructor_arg('convert_i32_u'), ], symbol('aCvtOp')), + InstrConfig('F32_CONVERT_I64_S', b'\xB4', [constructor_arg('f32'), constructor_arg('convert_i64_s'), ], symbol('aCvtOp')), + InstrConfig('F32_CONVERT_I64_U', b'\xB5', [constructor_arg('f32'), constructor_arg('convert_i64_u'), ], symbol('aCvtOp')), + InstrConfig('F32_DEMOTE_F64', b'\xB6', [constructor_arg('f32'), constructor_arg('demote_f64'), ], symbol('aCvtOp')), + + InstrConfig('F64_CONVERT_I32_S', b'\xB7', [constructor_arg('f64'), constructor_arg('convert_i32_s'), ], symbol('aCvtOp')), + InstrConfig('F64_CONVERT_I32_U', b'\xB8', [constructor_arg('f64'), constructor_arg('convert_i32_u'), ], symbol('aCvtOp')), + InstrConfig('F64_CONVERT_I64_S', b'\xB9', [constructor_arg('f64'), constructor_arg('convert_i64_s'), ], symbol('aCvtOp')), + InstrConfig('F64_CONVERT_I64_U', b'\xBA', [constructor_arg('f64'), constructor_arg('convert_i64_u'), ], symbol('aCvtOp')), + InstrConfig('F64_PROMOTE_F32', b'\xBB', [constructor_arg('f64'), constructor_arg('promote_f32'), ], symbol('aCvtOp')), + + InstrConfig('I32_REINTERPRET_F32', b'\xBC', [], not_implemented()), + InstrConfig('I64_REINTERPRET_F64', b'\xBD', [], not_implemented()), + InstrConfig('F32_REINTERPRET_I32', b'\xBE', [], not_implemented()), + InstrConfig('F64_REINTERPRET_I64', b'\xBF', [], not_implemented()), + + InstrConfig('I32_EXTEND_8_S', b'\xC0', [constructor_arg('i32'), constructor_arg('extend8_s'), ], symbol('aExtendS')), + InstrConfig('I32_EXTEND_16_S', b'\xC1', [constructor_arg('i32'), constructor_arg('extend16_s'), ], symbol('aExtendS')), + InstrConfig('I64_EXTEND_8_S', b'\xC2', [constructor_arg('i64'), constructor_arg('extend8_s'), ], symbol('aExtendS')), + InstrConfig('I64_EXTEND_16_S', b'\xC3', [constructor_arg('i64'), constructor_arg('extend16_s'), ], symbol('aExtendS')), + InstrConfig('I64_EXTEND_32_S', b'\xC4', [constructor_arg('i64'), constructor_arg('extend32_s'), ], symbol('aExtendS')), + + InstrConfig('I32_TRUNC_SAT_F32_S', b'\xFC\x00', [], not_implemented()), + InstrConfig('I32_TRUNC_SAT_F32_U', b'\xFC\x01', [], not_implemented()), + InstrConfig('I32_TRUNC_SAT_F64_S', b'\xFC\x02', [], not_implemented()), + InstrConfig('I32_TRUNC_SAT_F64_U', b'\xFC\x03', [], not_implemented()), + InstrConfig('I64_TRUNC_SAT_F32_S', b'\xFC\x04', [], not_implemented()), + InstrConfig('I64_TRUNC_SAT_F32_U', b'\xFC\x05', [], not_implemented()), + InstrConfig('I64_TRUNC_SAT_F64_S', b'\xFC\x06', [], not_implemented()), + InstrConfig('I64_TRUNC_SAT_F64_U', b'\xFC\x07', [], not_implemented()), + + # _Vector instructions_ have the following tags: + + InstrConfig('V128_LOAD', b'\xFD\x00', ['MemArg', ], not_implemented()), + InstrConfig('V128_LOAD_8X8_S', b'\xFD\x01', ['MemArg', ], not_implemented()), + InstrConfig('V128_LOAD_8X8_U', b'\xFD\x02', ['MemArg', ], not_implemented()), + InstrConfig('V128_LOAD_16X4_S', b'\xFD\x03', ['MemArg', ], not_implemented()), + InstrConfig('V128_LOAD_16X4_U', b'\xFD\x04', ['MemArg', ], not_implemented()), + InstrConfig('V128_LOAD_32X2_S', b'\xFD\x05', ['MemArg', ], not_implemented()), + InstrConfig('V128_LOAD_32X2_U', b'\xFD\x06', ['MemArg', ], not_implemented()), + InstrConfig('V128_LOAD_8_SPLAT', b'\xFD\x07', ['MemArg', ], not_implemented()), + InstrConfig('V128_LOAD_16_SPLAT', b'\xFD\x08', ['MemArg', ], not_implemented()), + InstrConfig('V128_LOAD_32_SPLAT', b'\xFD\x09', ['MemArg', ], not_implemented()), + InstrConfig('V128_LOAD_64_SPLAT', b'\xFD\x0A', ['MemArg', ], not_implemented()), + InstrConfig('V128_LOAD_32_ZERO', b'\xFD\x5C', ['MemArg', ], not_implemented()), + InstrConfig('V128_LOAD_64_ZERO', b'\xFD\x5D', ['MemArg', ], not_implemented()), + InstrConfig('V128_STORE', b'\xFD\x0B', ['MemArg', ], not_implemented()), + InstrConfig('V128_LOAD_8_LANE', b'\xFD\x54', ['MemArg', 'UnsignedInt', ], not_implemented()), + InstrConfig('V128_LOAD_16_LANE', b'\xFD\x55', ['MemArg', 'UnsignedInt', ], not_implemented()), + InstrConfig('V128_LOAD_32_LANE', b'\xFD\x56', ['MemArg', 'UnsignedInt', ], not_implemented()), + InstrConfig('V128_LOAD_64_LANE', b'\xFD\x57', ['MemArg', 'UnsignedInt', ], not_implemented()), + InstrConfig('V128_STORE_8_LANE', b'\xFD\x58', ['MemArg', 'UnsignedInt', ], not_implemented()), + InstrConfig('V128_STORE_16_LANE', b'\xFD\x59', ['MemArg', 'UnsignedInt', ], not_implemented()), + InstrConfig('V128_STORE_32_LANE', b'\xFD\x5A', ['MemArg', 'UnsignedInt', ], not_implemented()), + InstrConfig('V128_STORE_64_LANE', b'\xFD\x5B', ['MemArg', 'UnsignedInt', ], not_implemented()), + + InstrConfig('V128_CONST_BYTES', b'\xFD\x0C', [repeated_bytes(16), ], not_implemented()), + + InstrConfig('I8X16_SHUFFLE', b'\xFD\x0D', [repeated_type('UnsignedInt', 16), ], not_implemented()), + + InstrConfig('I8X16_EXTRACT_LANE_S', b'\xFD\x15', ['UnsignedInt', ], not_implemented()), + InstrConfig('I8X16_EXTRACT_LANE_U', b'\xFD\x16', ['UnsignedInt', ], not_implemented()), + InstrConfig('I8X16_REPLACE_LANE', b'\xFD\x17', ['UnsignedInt', ], not_implemented()), + InstrConfig('I16X8_EXTRACT_LANE_S', b'\xFD\x18', ['UnsignedInt', ], not_implemented()), + InstrConfig('I16X8_EXTRACT_LANE_U', b'\xFD\x19', ['UnsignedInt', ], not_implemented()), + InstrConfig('I16X8_REPLACE_LANE', b'\xFD\x1A', ['UnsignedInt', ], not_implemented()), + InstrConfig('I32X4_EXTRACT_LANE', b'\xFD\x1B', ['UnsignedInt', ], not_implemented()), + InstrConfig('I32X4_REPLACE_LANE', b'\xFD\x1C', ['UnsignedInt', ], not_implemented()), + InstrConfig('I64X2_EXTRACT_LANE', b'\xFD\x1D', ['UnsignedInt', ], not_implemented()), + InstrConfig('I64X2_REPLACE_LANE', b'\xFD\x1E', ['UnsignedInt', ], not_implemented()), + InstrConfig('F32X4_EXTRACT_LANE', b'\xFD\x1F', ['UnsignedInt', ], not_implemented()), + InstrConfig('F32X4_REPLACE_LANE', b'\xFD\x20', ['UnsignedInt', ], not_implemented()), + InstrConfig('F64X2_EXTRACT_LANE', b'\xFD\x21', ['UnsignedInt', ], not_implemented()), + InstrConfig('F64X2_REPLACE_LANE', b'\xFD\x22', ['UnsignedInt', ], not_implemented()), + + InstrConfig('I8X16_SWIZZLE', b'\xFD\x0E', [], not_implemented()), + InstrConfig('I8X16_SPLAT', b'\xFD\x0F', [], not_implemented()), + InstrConfig('I16X8_SPLAT', b'\xFD\x10', [], not_implemented()), + InstrConfig('I32X4_SPLAT', b'\xFD\x11', [], not_implemented()), + InstrConfig('I64X2_SPLAT', b'\xFD\x12', [], not_implemented()), + InstrConfig('F32X4_SPLAT', b'\xFD\x13', [], not_implemented()), + InstrConfig('F64X2_SPLAT', b'\xFD\x14', [], not_implemented()), + + InstrConfig('I8X16_EQ', b'\xFD\x23', [], not_implemented()), + InstrConfig('I8X16_NE', b'\xFD\x24', [], not_implemented()), + InstrConfig('I8X16_LT_S', b'\xFD\x25', [], not_implemented()), + InstrConfig('I8X16_LT_U', b'\xFD\x26', [], not_implemented()), + InstrConfig('I8X16_GT_S', b'\xFD\x27', [], not_implemented()), + InstrConfig('I8X16_GT_U', b'\xFD\x28', [], not_implemented()), + InstrConfig('I8X16_LE_S', b'\xFD\x29', [], not_implemented()), + InstrConfig('I8X16_LE_U', b'\xFD\x2A', [], not_implemented()), + InstrConfig('I8X16_GE_S', b'\xFD\x2B', [], not_implemented()), + InstrConfig('I8X16_GE_U', b'\xFD\x2C', [], not_implemented()), + + InstrConfig('I16X8_EQ', b'\xFD\x2D', [], not_implemented()), + InstrConfig('I16X8_NE', b'\xFD\x2E', [], not_implemented()), + InstrConfig('I16X8_LT_S', b'\xFD\x2F', [], not_implemented()), + InstrConfig('I16X8_LT_U', b'\xFD\x30', [], not_implemented()), + InstrConfig('I16X8_GT_S', b'\xFD\x31', [], not_implemented()), + InstrConfig('I16X8_GT_U', b'\xFD\x32', [], not_implemented()), + InstrConfig('I16X8_LE_S', b'\xFD\x33', [], not_implemented()), + InstrConfig('I16X8_LE_U', b'\xFD\x34', [], not_implemented()), + InstrConfig('I16X8_GE_S', b'\xFD\x35', [], not_implemented()), + InstrConfig('I16X8_GE_U', b'\xFD\x36', [], not_implemented()), + + InstrConfig('I32X4_EQ', b'\xFD\x37', [], not_implemented()), + InstrConfig('I32X4_NE', b'\xFD\x38', [], not_implemented()), + InstrConfig('I32X4_LT_S', b'\xFD\x39', [], not_implemented()), + InstrConfig('I32X4_LT_U', b'\xFD\x3A', [], not_implemented()), + InstrConfig('I32X4_GT_S', b'\xFD\x3B', [], not_implemented()), + InstrConfig('I32X4_GT_U', b'\xFD\x3C', [], not_implemented()), + InstrConfig('I32X4_LE_S', b'\xFD\x3D', [], not_implemented()), + InstrConfig('I32X4_LE_U', b'\xFD\x3E', [], not_implemented()), + InstrConfig('I32X4_GE_S', b'\xFD\x3F', [], not_implemented()), + InstrConfig('I32X4_GE_U', b'\xFD\x40', [], not_implemented()), + + InstrConfig('I64X2_EQ', b'\xFD\xD6\x01', [], not_implemented()), + InstrConfig('I64X2_NE', b'\xFD\xD7\x01', [], not_implemented()), + InstrConfig('I64X2_LT_S', b'\xFD\xD8\x01', [], not_implemented()), + InstrConfig('I64X2_GT_S', b'\xFD\xD9\x01', [], not_implemented()), + InstrConfig('I64X2_LE_S', b'\xFD\xDA\x01', [], not_implemented()), + InstrConfig('I64X2_GE_S', b'\xFD\xDB\x01', [], not_implemented()), + + InstrConfig('F32X4_EQ', b'\xFD\x41', [], not_implemented()), + InstrConfig('F32X4_NE', b'\xFD\x42', [], not_implemented()), + InstrConfig('F32X4_LT', b'\xFD\x43', [], not_implemented()), + InstrConfig('F32X4_GT', b'\xFD\x44', [], not_implemented()), + InstrConfig('F32X4_LE', b'\xFD\x45', [], not_implemented()), + InstrConfig('F32X4_GE', b'\xFD\x46', [], not_implemented()), + + InstrConfig('F64X2_EQ', b'\xFD\x47', [], not_implemented()), + InstrConfig('F64X2_NE', b'\xFD\x48', [], not_implemented()), + InstrConfig('F64X2_LT', b'\xFD\x49', [], not_implemented()), + InstrConfig('F64X2_GT', b'\xFD\x4A', [], not_implemented()), + InstrConfig('F64X2_LE', b'\xFD\x4B', [], not_implemented()), + InstrConfig('F64X2_GE', b'\xFD\x4C', [], not_implemented()), + + InstrConfig('V128_NOT', b'\xFD\x4D', [], not_implemented()), + InstrConfig('V128_AND', b'\xFD\x4E', [], not_implemented()), + InstrConfig('V128_ANDNOT', b'\xFD\x4F', [], not_implemented()), + InstrConfig('V128_OR', b'\xFD\x50', [], not_implemented()), + InstrConfig('V128_XOR', b'\xFD\x51', [], not_implemented()), + InstrConfig('V128_BITSELECT', b'\xFD\x52', [], not_implemented()), + InstrConfig('V128_ANY_TRUE', b'\xFD\x53', [], not_implemented()), + + InstrConfig('I8X16_ABS', b'\xFD\x60', [], not_implemented()), + InstrConfig('I8X16_NEG', b'\xFD\x61', [], not_implemented()), + InstrConfig('I8X16_POPCNT', b'\xFD\x62', [], not_implemented()), + InstrConfig('I8X16_ALL_TRUE', b'\xFD\x63', [], not_implemented()), + InstrConfig('I8X16_BITMASK', b'\xFD\x64', [], not_implemented()), + InstrConfig('I8X16_NARROW_I16X8_S', b'\xFD\x65', [], not_implemented()), + InstrConfig('I8X16_NARROW_I16X8_U', b'\xFD\x66', [], not_implemented()), + InstrConfig('I8X16_SHL', b'\xFD\x6B', [], not_implemented()), + InstrConfig('I8X16_SHR_S', b'\xFD\x6C', [], not_implemented()), + InstrConfig('I8X16_SHR_U', b'\xFD\x6D', [], not_implemented()), + InstrConfig('I8X16_ADD', b'\xFD\x6E', [], not_implemented()), + InstrConfig('I8X16_ADD_SAT_S', b'\xFD\x6F', [], not_implemented()), + InstrConfig('I8X16_ADD_SAT_U', b'\xFD\x70', [], not_implemented()), + InstrConfig('I8X16_SUB', b'\xFD\x71', [], not_implemented()), + InstrConfig('I8X16_SUB_SAT_S', b'\xFD\x72', [], not_implemented()), + InstrConfig('I8X16_SUB_SAT_U', b'\xFD\x73', [], not_implemented()), + InstrConfig('I8X16_MIN_S', b'\xFD\x76', [], not_implemented()), + InstrConfig('I8X16_MIN_U', b'\xFD\x77', [], not_implemented()), + InstrConfig('I8X16_MAX_S', b'\xFD\x78', [], not_implemented()), + InstrConfig('I8X16_MAX_U', b'\xFD\x79', [], not_implemented()), + InstrConfig('I8X16_AVGR_U', b'\xFD\x7B', [], not_implemented()), + + InstrConfig('I16X8_EXTADD_PAIRWISE_I8X16_S', b'\xFD\x7C', [], not_implemented()), + InstrConfig('I16X8_EXTADD_PAIRWISE_I8X16_U', b'\xFD\x7D', [], not_implemented()), + InstrConfig('I16X8_ABS', b'\xFD\x80\x01', [], not_implemented()), + InstrConfig('I16X8_NEG', b'\xFD\x81\x01', [], not_implemented()), + InstrConfig('I16X8_Q15MULR_SAT_S', b'\xFD\x82\x01', [], not_implemented()), + InstrConfig('I16X8_ALL_TRUE', b'\xFD\x83\x01', [], not_implemented()), + InstrConfig('I16X8_BITMASK', b'\xFD\x84\x01', [], not_implemented()), + InstrConfig('I16X8_NARROW_I32X4_S', b'\xFD\x85\x01', [], not_implemented()), + InstrConfig('I16X8_NARROW_I32X4_U', b'\xFD\x86\x01', [], not_implemented()), + InstrConfig('I16X8_EXTEND_LOW_I8X16_S', b'\xFD\x87\x01', [], not_implemented()), + InstrConfig('I16X8_EXTEND_HIGH_I8X16_S', b'\xFD\x88\x01', [], not_implemented()), + InstrConfig('I16X8_EXTEND_LOW_I8X16_U', b'\xFD\x89\x01', [], not_implemented()), + InstrConfig('I16X8_EXTEND_HIGH_I8X16_U', b'\xFD\x8A\x01', [], not_implemented()), + InstrConfig('I16X8_SHL', b'\xFD\x8B\x01', [], not_implemented()), + InstrConfig('I16X8_SHR_S', b'\xFD\x8C\x01', [], not_implemented()), + InstrConfig('I16X8_SHR_U', b'\xFD\x8D\x01', [], not_implemented()), + InstrConfig('I16X8_ADD', b'\xFD\x8E\x01', [], not_implemented()), + InstrConfig('I16X8_ADD_SAT_S', b'\xFD\x8F\x01', [], not_implemented()), + InstrConfig('I16X8_ADD_SAT_U', b'\xFD\x90\x01', [], not_implemented()), + InstrConfig('I16X8_SUB', b'\xFD\x91\x01', [], not_implemented()), + InstrConfig('I16X8_SUB_SAT_S', b'\xFD\x92\x01', [], not_implemented()), + InstrConfig('I16X8_SUB_SAT_U', b'\xFD\x93\x01', [], not_implemented()), + InstrConfig('I16X8_MUL', b'\xFD\x95\x01', [], not_implemented()), + InstrConfig('I16X8_MIN_S', b'\xFD\x96\x01', [], not_implemented()), + InstrConfig('I16X8_MIN_U', b'\xFD\x97\x01', [], not_implemented()), + InstrConfig('I16X8_MAX_S', b'\xFD\x98\x01', [], not_implemented()), + InstrConfig('I16X8_MAX_U', b'\xFD\x99\x01', [], not_implemented()), + InstrConfig('I16X8_AVGR_U', b'\xFD\x9B\x01', [], not_implemented()), + InstrConfig('I16X8_EXTMUL_LOW_I8X16_S', b'\xFD\x9C\x01', [], not_implemented()), + InstrConfig('I16X8_EXTMUL_HIGH_I8X16_S', b'\xFD\x9D\x01', [], not_implemented()), + InstrConfig('I16X8_EXTMUL_LOW_I8X16_U', b'\xFD\x9E\x01', [], not_implemented()), + InstrConfig('I16X8_EXTMUL_HIGH_I8X16_U', b'\xFD\x9F\x01', [], not_implemented()), + + InstrConfig('I32X4_EXTADD_PAIRWISE_I16X8_S', b'\xFD\x7E', [], not_implemented()), + InstrConfig('I32X4_EXTADD_PAIRWISE_I16X8_U', b'\xFD\x7F', [], not_implemented()), + InstrConfig('I32X4_ABS', b'\xFD\xA0\x01', [], not_implemented()), + InstrConfig('I32X4_NEG', b'\xFD\xA1\x01', [], not_implemented()), + InstrConfig('I32X4_ALL_TRUE', b'\xFD\xA3\x01', [], not_implemented()), + InstrConfig('I32X4_BITMASK', b'\xFD\xA4\x01', [], not_implemented()), + InstrConfig('I32X4_EXTEND_LOW_I16X8_S', b'\xFD\xA7\x01', [], not_implemented()), + InstrConfig('I32X4_EXTEND_HIGH_I16X8_S', b'\xFD\xA8\x01', [], not_implemented()), + InstrConfig('I32X4_EXTEND_LOW_I16X8_U', b'\xFD\xA9\x01', [], not_implemented()), + InstrConfig('I32X4_EXTEND_HIGH_I16X8_U', b'\xFD\xAA\x01', [], not_implemented()), + InstrConfig('I32X4_SHL', b'\xFD\xAB\x01', [], not_implemented()), + InstrConfig('I32X4_SHR_S', b'\xFD\xAC\x01', [], not_implemented()), + InstrConfig('I32X4_SHR_U', b'\xFD\xAD\x01', [], not_implemented()), + InstrConfig('I32X4_ADD', b'\xFD\xAE\x01', [], not_implemented()), + InstrConfig('I32X4_SUB', b'\xFD\xB1\x01', [], not_implemented()), + InstrConfig('I32X4_MUL', b'\xFD\xB5\x01', [], not_implemented()), + InstrConfig('I32X4_MIN_S', b'\xFD\xB6\x01', [], not_implemented()), + InstrConfig('I32X4_MIN_U', b'\xFD\xB7\x01', [], not_implemented()), + InstrConfig('I32X4_MAX_S', b'\xFD\xB8\x01', [], not_implemented()), + InstrConfig('I32X4_MAX_U', b'\xFD\xB9\x01', [], not_implemented()), + InstrConfig('I32X4_DOT_I16X8_S', b'\xFD\xBA\x01', [], not_implemented()), + InstrConfig('I32X4_EXTMUL_LOW_I16X8_S', b'\xFD\xBC\x01', [], not_implemented()), + InstrConfig('I32X4_EXTMUL_HIGH_I16X8_S', b'\xFD\xBD\x01', [], not_implemented()), + InstrConfig('I32X4_EXTMUL_LOW_I16X8_U', b'\xFD\xBE\x01', [], not_implemented()), + InstrConfig('I32X4_EXTMUL_HIGH_I16X8_U', b'\xFD\xBF\x01', [], not_implemented()), + + InstrConfig('I64X2_ABS', b'\xFD\xC0\x01', [], not_implemented()), + InstrConfig('I64X2_NEG', b'\xFD\xC1\x01', [], not_implemented()), + InstrConfig('I64X2_ALL_TRUE', b'\xFD\xC3\x01', [], not_implemented()), + InstrConfig('I64X2_BITMASK', b'\xFD\xC4\x01', [], not_implemented()), + InstrConfig('I64X2_EXTEND_LOW_I32X4_S', b'\xFD\xC7\x01', [], not_implemented()), + InstrConfig('I64X2_EXTEND_HIGH_I32X4_S', b'\xFD\xC8\x01', [], not_implemented()), + InstrConfig('I64X2_EXTEND_LOW_I32X4_U', b'\xFD\xC9\x01', [], not_implemented()), + InstrConfig('I64X2_EXTEND_HIGH_I32X4_U', b'\xFD\xCA\x01', [], not_implemented()), + InstrConfig('I64X2_SHL', b'\xFD\xCB\x01', [], not_implemented()), + InstrConfig('I64X2_SHR_S', b'\xFD\xCC\x01', [], not_implemented()), + InstrConfig('I64X2_SHR_U', b'\xFD\xCD\x01', [], not_implemented()), + InstrConfig('I64X2_ADD', b'\xFD\xCE\x01', [], not_implemented()), + InstrConfig('I64X2_SUB', b'\xFD\xD1\x01', [], not_implemented()), + InstrConfig('I64X2_MUL', b'\xFD\xD5\x01', [], not_implemented()), + InstrConfig('I64X2_EXTMUL_LOW_I32X4_S', b'\xFD\xDC\x01', [], not_implemented()), + InstrConfig('I64X2_EXTMUL_HIGH_I32X4_S', b'\xFD\xDD\x01', [], not_implemented()), + InstrConfig('I64X2_EXTMUL_LOW_I32X4_U', b'\xFD\xDE\x01', [], not_implemented()), + InstrConfig('I64X2_EXTMUL_HIGH_I32X4_U', b'\xFD\xDF\x01', [], not_implemented()), + + InstrConfig('F32X4_CEIL', b'\xFD\x67', [], not_implemented()), + InstrConfig('F32X4_FLOOR', b'\xFD\x68', [], not_implemented()), + InstrConfig('F32X4_TRUNC', b'\xFD\x69', [], not_implemented()), + InstrConfig('F32X4_NEAREST', b'\xFD\x6A', [], not_implemented()), + InstrConfig('F32X4_ABS', b'\xFD\xE0\x01', [], not_implemented()), + InstrConfig('F32X4_NEG', b'\xFD\xE1\x01', [], not_implemented()), + InstrConfig('F32X4_SQRT', b'\xFD\xE3\x01', [], not_implemented()), + InstrConfig('F32X4_ADD', b'\xFD\xE4\x01', [], not_implemented()), + InstrConfig('F32X4_SUB', b'\xFD\xE5\x01', [], not_implemented()), + InstrConfig('F32X4_MUL', b'\xFD\xE6\x01', [], not_implemented()), + InstrConfig('F32X4_DIV', b'\xFD\xE7\x01', [], not_implemented()), + InstrConfig('F32X4_MIN', b'\xFD\xE8\x01', [], not_implemented()), + InstrConfig('F32X4_MAX', b'\xFD\xE9\x01', [], not_implemented()), + InstrConfig('F32X4_PMIN', b'\xFD\xEA\x01', [], not_implemented()), + InstrConfig('F32X4_PMAX', b'\xFD\xEB\x01', [], not_implemented()), + + InstrConfig('F64X2_CEIL', b'\xFD\x74', [], not_implemented()), + InstrConfig('F64X2_FLOOR', b'\xFD\x75', [], not_implemented()), + InstrConfig('F64X2_TRUNC', b'\xFD\x7A', [], not_implemented()), + InstrConfig('F64X2_NEAREST', b'\xFD\x94\x01', [], not_implemented()), + InstrConfig('F64X2_ABS', b'\xFD\xEC\x01', [], not_implemented()), + InstrConfig('F64X2_NEG', b'\xFD\xED\x01', [], not_implemented()), + InstrConfig('F64X2_SQRT', b'\xFD\xEF\x01', [], not_implemented()), + InstrConfig('F64X2_ADD', b'\xFD\xF0\x01', [], not_implemented()), + InstrConfig('F64X2_SUB', b'\xFD\xF1\x01', [], not_implemented()), + InstrConfig('F64X2_MUL', b'\xFD\xF2\x01', [], not_implemented()), + InstrConfig('F64X2_DIV', b'\xFD\xF3\x01', [], not_implemented()), + InstrConfig('F64X2_MIN', b'\xFD\xF4\x01', [], not_implemented()), + InstrConfig('F64X2_MAX', b'\xFD\xF5\x01', [], not_implemented()), + InstrConfig('F64X2_PMIN', b'\xFD\xF6\x01', [], not_implemented()), + InstrConfig('F64X2_PMAX', b'\xFD\xF7\x01', [], not_implemented()), + + InstrConfig('I32X4_TRUNC_SAT_F32X4_S', b'\xFD\xF8\x01', [], not_implemented()), + InstrConfig('I32X4_TRUNC_SAT_F32X4_U', b'\xFD\xF9\x01', [], not_implemented()), + InstrConfig('F32X4_CONVERT_I32X4_S', b'\xFD\xFA\x01', [], not_implemented()), + InstrConfig('F32X4_CONVERT_I32X4_U', b'\xFD\xFB\x01', [], not_implemented()), + InstrConfig('I32X4_TRUNC_SAT_F64X2_S_ZERO', b'\xFD\xFC\x01', [], not_implemented()), + InstrConfig('I32X4_TRUNC_SAT_F64X2_U_ZERO', b'\xFD\xFD\x01', [], not_implemented()), + InstrConfig('F64X2_CONVERT_LOW_I32X4_S', b'\xFD\xFE\x01', [], not_implemented()), + InstrConfig('F64X2_CONVERT_LOW_I32X4_U', b'\xFD\xFF\x01', [], not_implemented()), + InstrConfig('F32X4_DEMOTE_F64X2_ZERO', b'\xFD\x5E', [], not_implemented()), + InstrConfig('F64X2_PROMOTE_LOW_F32X4', b'\xFD\x5F', [], not_implemented()), +] + +def parse_single_item(parser_prefix: str, item: InstrConfig, output_pieces: list[str]) -> None: + current_prefix = parser_prefix + if item.prefix: + current_prefix=parser_prefix + 'xbytes' + output_pieces.append(f""" + syntax InstrResult ::= {parser_prefix}(BytesWithIndex) [function, total] + | #{parser_prefix}(BytesWithIndexOrError) [function, total] + rule {parser_prefix}(BWI:BytesWithIndex) => #{parser_prefix}(parseConstant(BWI, {bytes_to_k(item.prefix)})) + rule #{parser_prefix}(BWI:BytesWithIndex) => {current_prefix}(BWI) + rule #{parser_prefix}(E:ParseError) => E + +""") + + output_pieces.append(f' syntax InstrResult ::= {current_prefix}(BytesWithIndex) [function, total]\n') + # Argument parsing + parsing_args = [arg for arg in item.args if arg.is_parsing_arg()] + suffix = 1 + lhs_function = current_prefix + prev_args = [] + last_parsed = None + for i, arg in enumerate(item.args): + if not arg.is_parsing_arg(): + continue + + rhs_function = f'#{current_prefix}s{suffix}' + suffix += 1 + + output_pieces.append(f""" syntax InstrResult ::= {rhs_function} + ( """) + newline_indented_comma = """ + , """ + newline_indented_declaration_end = """ + ) [function, total] +""" + first = True + for _, prev in prev_args: + if first: + first = False + else: + output_pieces.append(newline_indented_comma) + output_pieces.append(prev.value_type()) + if last_parsed: + parsed_arg, _ = last_parsed + if first: + first = False + else: + output_pieces.append(newline_indented_comma) + output_pieces.append(f'{parsed_arg.value_type()}') + if first: + first = False + else: + output_pieces.append(newline_indented_comma) + output_pieces.append(f'{arg.result_type()}') + output_pieces.append(newline_indented_declaration_end) + + # Success rewrite rule + lhs_args = [] + rhs_args = [] + for i, prev in prev_args: + lhs_args.append(prev.lhs_argument(i, unused=False)) + rhs_args.append(prev.rhs_argument(i, False)) + if last_parsed: + parsed_arg, parsed_arg_idx = last_parsed + lhs_args.append(f'{parsed_arg.result_argument(parsed_arg_idx, "BWI")}') + rhs_args.append(f'{parsed_arg.rhs_argument(parsed_arg_idx, False)}') + else: + lhs_args.append('BWI') + rhs_args.append(arg.parser('BWI')) + output_pieces.append(f' rule {lhs_function}({", ".join(lhs_args)}) => {rhs_function}({", ".join(rhs_args)})\n') + + if suffix > 2: + # Failure rewrite rule for every lhs_function except the first one. + failure_lhs_args = [] + for i, prev in prev_args: + failure_lhs_args.append(prev.lhs_argument(i, unused=True)) + failure_lhs_args.append('E:ParseError') + output_pieces.append(f' rule {lhs_function}({", ".join(failure_lhs_args)}) => E\n') + + # Update data + if last_parsed: + prev_args.append(last_parsed) + lhs_function = rhs_function + + if arg.is_used_in_constructor(): + last_parsed = (arg, i) + else: + last_parsed = None + + # Result construction + result_lhs_args = [] + for prev_arg, prev_index in prev_args: + result_lhs_args.append(prev_arg.lhs_argument(prev_index, unused=False)) + if last_parsed: + result_lhs_args.append(arg.result_argument(i, 'BWI' if item.constructor.needs_bwi() else '_BWI')) + else: + result_lhs_args.append('BWI:BytesWithIndex') + output_pieces.append(f' rule {lhs_function}({", ".join(result_lhs_args)}) => ') + item.constructor.build(item.args, 'BWI', output_pieces) + output_pieces.append('\n') + + if parsing_args: + # Error handling + error_lhs_args = [] + for prev_arg, prev_index in prev_args: + error_lhs_args.append(prev_arg.lhs_argument(prev_index, unused=True)) + error_lhs_args.append('E:ParseError') + output_pieces.append(f' rule {lhs_function}({", ".join(error_lhs_args)}) => E\n') + +def parse_group(parser_prefix: str, items: list[InstrConfig], output_pieces: list[str]) -> None: + assert items + if len(items) == 1: + parse_single_item(parser_prefix, items[0], output_pieces) + else: + output_pieces.append(f' syntax InstrResult ::= {parser_prefix}(BytesWithIndex) [function, total]\n') + parse_rules(parser_prefix, items, output_pieces) + + +def parse_rules(parser_prefix: str, items: list[InstrConfig], output_pieces: list[str]) -> None: + assert items + output_pieces.append(f""" + syntax InstrResult ::= #{parser_prefix}p1(IntResult) [function, total] + | #{parser_prefix}p2(Int, BytesWithIndex) [function, total] + rule {parser_prefix}(BWI:BytesWithIndex) => #{parser_prefix}p1(parseByteAsInt(BWI)) + rule #{parser_prefix}p1(intResult(I:Int, BWI:BytesWithIndex)) => #{parser_prefix}p2(I, BWI) + rule #{parser_prefix}p1(E:ParseError) => E +""") + + groups:list[list[InstrConfig]] = [[] for _ in range(256)] + for instr in items: + assert len(instr.prefix) > 0 + first_prefix = instr.prefix[0] + assert 0 <= first_prefix and first_prefix < 256 + groups[first_prefix].append(instr.with_prefix(instr.prefix[1:])) + for i in range(256): + if not groups[i]: + continue + output_pieces.append(f' rule #{parser_prefix}p2({i}, BWI:BytesWithIndex) => {parser_prefix}x{i}(BWI)\n') + output_pieces.append(f' rule #{parser_prefix}p2(I:Int, bwi(B:Bytes, Index:Int)) => parseError("#{parser_prefix}p2", ListItem(I) ListItem(Index) ListItem(lengthBytes(B)) ListItem(B)) [owise]\n') + output_pieces.append('\n') + for i in range(256): + if not groups[i]: + continue + parse_group(f'{parser_prefix}x{i}', groups[i], output_pieces) + +def main(): + output_pieces = [ + f"""This was generated by `{os.path.basename(__file__)}`. Do not edit this file directly. + +```k +module BINARY-PARSER-INSTR-SYNTAX + imports BINARY-PARSER-BASE-SYNTAX + imports WASM-COMMON-SYNTAX + + syntax BinaryInstr ::= Instr + + syntax InstrResult ::= instrResult(BinaryInstr, BytesWithIndex) | ParseError + syntax InstrResult ::= parseInstr(BytesWithIndex) [function, total] + + syntax InstrOrError ::= Instr | ParseError +endmodule + +module BINARY-PARSER-INSTR + imports BINARY-PARSER-BLOCK-SYNTAX + imports BINARY-PARSER-BYTES-SYNTAX + imports BINARY-PARSER-CONSTANT-SYNTAX + imports BINARY-PARSER-FLOAT-SYNTAX + imports BINARY-PARSER-HELPERS-SYNTAX + imports BINARY-PARSER-IF-SYNTAX + imports BINARY-PARSER-INSTR-SYNTAX + imports BINARY-PARSER-INT-SYNTAX + imports BINARY-PARSER-LOOP-SYNTAX + imports BINARY-PARSER-MEMARG-SYNTAX + imports BINARY-PARSER-VALTYPE-SYNTAX + imports WASM + +""", + ] + parse_rules('parseInstr', INSTRS_CONFIG, output_pieces) + output_pieces.append('endmodule\n') + output_pieces.append('```\n') + print(''.join(output_pieces)) + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/tests/binary-parsing/code-block.wast b/tests/binary-parsing/code-block.wast new file mode 100644 index 000000000..8b92f4874 --- /dev/null +++ b/tests/binary-parsing/code-block.wast @@ -0,0 +1,11 @@ +(module $mymodule + (func (param i32) (result i32) + (block (result i32) + nop + (i32.const 2) + ) + (return + (i32.const 1) + ) + ) +) diff --git a/tests/binary-parsing/code-block.wast.out b/tests/binary-parsing/code-block.wast.out new file mode 100644 index 000000000..6bf03ac3d --- /dev/null +++ b/tests/binary-parsing/code-block.wast.out @@ -0,0 +1,65 @@ + + + #module (... types: #type (... type: [ i32 .ValTypes ] -> [ i32 .ValTypes ] , metadata: ) .EmptyStmts , funcs: #func (... type: 0 , locals: [ .ValTypes ] , body: #block ( [ i32 .ValTypes ] , nop i32 . const 2 .EmptyStmts , .Int ) i32 . const 1 return .EmptyStmts , metadata: #meta (... id: , localIds: .Map ) ) .EmptyStmts , tables: .EmptyStmts , mems: .EmptyStmts , globals: .EmptyStmts , elem: .EmptyStmts , data: .EmptyStmts , start: .EmptyStmts , importDefns: .EmptyStmts , exports: .EmptyStmts , metadata: #meta (... id: , funcIds: .Map , filename: .String ) ) ~> .K + + + + .K + + + .ValStack + + + + .List + + + .Int + + + + .Map + + + .Map + + + .ModuleInstCellMap + + + 0 + + + + .FuncDefCellMap + + + 0 + + + .TabInstCellMap + + + 0 + + + .List + + + .GlobalInstCellMap + + + 0 + + + .ElemInstCellMap + + + 0 + + + + true + + + diff --git a/tests/binary-parsing/code-call-indirect.wast b/tests/binary-parsing/code-call-indirect.wast new file mode 100644 index 000000000..f70c7414b --- /dev/null +++ b/tests/binary-parsing/code-call-indirect.wast @@ -0,0 +1,7 @@ +(module $mymodule + (table 2 funcref) + (func (param i32) (result i32) + (call_indirect (result i32) (i32.const 1)) + (return (i32.const 1)) + ) +) diff --git a/tests/binary-parsing/code-call-parametric-drop.wast b/tests/binary-parsing/code-call-parametric-drop.wast new file mode 100644 index 000000000..15e8523c3 --- /dev/null +++ b/tests/binary-parsing/code-call-parametric-drop.wast @@ -0,0 +1,11 @@ +(module $mymodule + (func (param i32) (result i32) + (i32.const 1) + drop + (i32.const 7) + (i32.const 5) + (i32.const 1) + select + (return (i32.const 1)) + ) +) diff --git a/tests/binary-parsing/code-call-parametric-drop.wast.out b/tests/binary-parsing/code-call-parametric-drop.wast.out new file mode 100644 index 000000000..e4e681952 --- /dev/null +++ b/tests/binary-parsing/code-call-parametric-drop.wast.out @@ -0,0 +1,65 @@ + + + #module (... types: #type (... type: [ i32 .ValTypes ] -> [ i32 .ValTypes ] , metadata: ) .EmptyStmts , funcs: #func (... type: 0 , locals: [ .ValTypes ] , body: i32 . const 1 drop i32 . const 7 i32 . const 5 i32 . const 1 select i32 . const 1 return .EmptyStmts , metadata: #meta (... id: , localIds: .Map ) ) .EmptyStmts , tables: .EmptyStmts , mems: .EmptyStmts , globals: .EmptyStmts , elem: .EmptyStmts , data: .EmptyStmts , start: .EmptyStmts , importDefns: .EmptyStmts , exports: .EmptyStmts , metadata: #meta (... id: , funcIds: .Map , filename: .String ) ) ~> .K + + + + .K + + + .ValStack + + + + .List + + + .Int + + + + .Map + + + .Map + + + .ModuleInstCellMap + + + 0 + + + + .FuncDefCellMap + + + 0 + + + .TabInstCellMap + + + 0 + + + .List + + + .GlobalInstCellMap + + + 0 + + + .ElemInstCellMap + + + 0 + + + + true + + + diff --git a/tests/binary-parsing/code-control-instructions.wast b/tests/binary-parsing/code-control-instructions.wast new file mode 100644 index 000000000..c3f5e212b --- /dev/null +++ b/tests/binary-parsing/code-control-instructions.wast @@ -0,0 +1,15 @@ +(module $mymodule + (func (param i32) (result i32) + nop + (block + (br 0) + (br_if 0) + ) + (call 1 (i32.const 1)) + (return (i32.const 1)) + ) + (func (param i32) (result i32) + ( unreachable + ) + ) +) diff --git a/tests/binary-parsing/code-control-instructions.wast.out b/tests/binary-parsing/code-control-instructions.wast.out new file mode 100644 index 000000000..5b87ab508 --- /dev/null +++ b/tests/binary-parsing/code-control-instructions.wast.out @@ -0,0 +1,65 @@ + + + #module (... types: #type (... type: [ i32 .ValTypes ] -> [ i32 .ValTypes ] , metadata: ) .EmptyStmts , funcs: #func (... type: 0 , locals: [ .ValTypes ] , body: nop #block ( [ .ValTypes ] , #br ( 0 ) #br_if ( 0 ) .EmptyStmts , .Int ) i32 . const 1 #call ( 1 ) i32 . const 1 return .EmptyStmts , metadata: #meta (... id: , localIds: .Map ) ) #func (... type: 0 , locals: [ .ValTypes ] , body: unreachable .EmptyStmts , metadata: #meta (... id: , localIds: .Map ) ) .EmptyStmts , tables: .EmptyStmts , mems: .EmptyStmts , globals: .EmptyStmts , elem: .EmptyStmts , data: .EmptyStmts , start: .EmptyStmts , importDefns: .EmptyStmts , exports: .EmptyStmts , metadata: #meta (... id: , funcIds: .Map , filename: .String ) ) ~> .K + + + + .K + + + .ValStack + + + + .List + + + .Int + + + + .Map + + + .Map + + + .ModuleInstCellMap + + + 0 + + + + .FuncDefCellMap + + + 0 + + + .TabInstCellMap + + + 0 + + + .List + + + .GlobalInstCellMap + + + 0 + + + .ElemInstCellMap + + + 0 + + + + true + + + diff --git a/tests/binary-parsing/code-empty-function.wast b/tests/binary-parsing/code-empty-function.wast new file mode 100644 index 000000000..a1ac30ff2 --- /dev/null +++ b/tests/binary-parsing/code-empty-function.wast @@ -0,0 +1,7 @@ +(module $mymodule + (func (param i32) (result i32) + (return + (i32.const 1) + ) + ) +) diff --git a/tests/binary-parsing/code-empty-function.wast.out b/tests/binary-parsing/code-empty-function.wast.out new file mode 100644 index 000000000..8edc2df73 --- /dev/null +++ b/tests/binary-parsing/code-empty-function.wast.out @@ -0,0 +1,65 @@ + + + #module (... types: #type (... type: [ i32 .ValTypes ] -> [ i32 .ValTypes ] , metadata: ) .EmptyStmts , funcs: #func (... type: 0 , locals: [ .ValTypes ] , body: i32 . const 1 return .EmptyStmts , metadata: #meta (... id: , localIds: .Map ) ) .EmptyStmts , tables: .EmptyStmts , mems: .EmptyStmts , globals: .EmptyStmts , elem: .EmptyStmts , data: .EmptyStmts , start: .EmptyStmts , importDefns: .EmptyStmts , exports: .EmptyStmts , metadata: #meta (... id: , funcIds: .Map , filename: .String ) ) ~> .K + + + + .K + + + .ValStack + + + + .List + + + .Int + + + + .Map + + + .Map + + + .ModuleInstCellMap + + + 0 + + + + .FuncDefCellMap + + + 0 + + + .TabInstCellMap + + + 0 + + + .List + + + .GlobalInstCellMap + + + 0 + + + .ElemInstCellMap + + + 0 + + + + true + + + diff --git a/tests/binary-parsing/code-loop-if.wast b/tests/binary-parsing/code-loop-if.wast new file mode 100644 index 000000000..a8c0dac5f --- /dev/null +++ b/tests/binary-parsing/code-loop-if.wast @@ -0,0 +1,16 @@ +(module $mymodule + (func (param i32) (result i32) + (if + (br_if 0 (i32.const 1) (local.get 0)) + (then nop) + ) + (if (result i32) + (br_if 0 (i32.const 1) (local.get 0)) + (then (i32.const 2)) + (else (i32.const 3)) + ) + (return + (i32.const 1) + ) + ) +) diff --git a/tests/binary-parsing/code-loop-if.wast.out b/tests/binary-parsing/code-loop-if.wast.out new file mode 100644 index 000000000..ea70a43ae --- /dev/null +++ b/tests/binary-parsing/code-loop-if.wast.out @@ -0,0 +1,65 @@ + + + #module (... types: #type (... type: [ i32 .ValTypes ] -> [ i32 .ValTypes ] , metadata: ) .EmptyStmts , funcs: #func (... type: 0 , locals: [ .ValTypes ] , body: i32 . const 1 #local.get ( 0 ) #br_if ( 0 ) #if ( [ .ValTypes ] , nop .EmptyStmts , .EmptyStmts , .Int ) i32 . const 1 #local.get ( 0 ) #br_if ( 0 ) #if ( [ i32 .ValTypes ] , i32 . const 2 .EmptyStmts , i32 . const 3 .EmptyStmts , .Int ) i32 . const 1 return .EmptyStmts , metadata: #meta (... id: , localIds: .Map ) ) .EmptyStmts , tables: .EmptyStmts , mems: .EmptyStmts , globals: .EmptyStmts , elem: .EmptyStmts , data: .EmptyStmts , start: .EmptyStmts , importDefns: .EmptyStmts , exports: .EmptyStmts , metadata: #meta (... id: , funcIds: .Map , filename: .String ) ) ~> .K + + + + .K + + + .ValStack + + + + .List + + + .Int + + + + .Map + + + .Map + + + .ModuleInstCellMap + + + 0 + + + + .FuncDefCellMap + + + 0 + + + .TabInstCellMap + + + 0 + + + .List + + + .GlobalInstCellMap + + + 0 + + + .ElemInstCellMap + + + 0 + + + + true + + + diff --git a/tests/binary-parsing/code-loop.wast b/tests/binary-parsing/code-loop.wast new file mode 100644 index 000000000..c01c907dc --- /dev/null +++ b/tests/binary-parsing/code-loop.wast @@ -0,0 +1,10 @@ +(module $mymodule + (func (param i32) (result i32) + (loop + nop + ) + (return + (i32.const 1) + ) + ) +) diff --git a/tests/binary-parsing/code-loop.wast.out b/tests/binary-parsing/code-loop.wast.out new file mode 100644 index 000000000..a9d3747db --- /dev/null +++ b/tests/binary-parsing/code-loop.wast.out @@ -0,0 +1,65 @@ + + + #module (... types: #type (... type: [ i32 .ValTypes ] -> [ i32 .ValTypes ] , metadata: ) .EmptyStmts , funcs: #func (... type: 0 , locals: [ .ValTypes ] , body: #loop ( [ .ValTypes ] , nop .EmptyStmts , .Int ) i32 . const 1 return .EmptyStmts , metadata: #meta (... id: , localIds: .Map ) ) .EmptyStmts , tables: .EmptyStmts , mems: .EmptyStmts , globals: .EmptyStmts , elem: .EmptyStmts , data: .EmptyStmts , start: .EmptyStmts , importDefns: .EmptyStmts , exports: .EmptyStmts , metadata: #meta (... id: , funcIds: .Map , filename: .String ) ) ~> .K + + + + .K + + + .ValStack + + + + .List + + + .Int + + + + .Map + + + .Map + + + .ModuleInstCellMap + + + 0 + + + + .FuncDefCellMap + + + 0 + + + .TabInstCellMap + + + 0 + + + .List + + + .GlobalInstCellMap + + + 0 + + + .ElemInstCellMap + + + 0 + + + + true + + + diff --git a/tests/binary-parsing/code-memory.wast b/tests/binary-parsing/code-memory.wast new file mode 100644 index 000000000..63feabb95 --- /dev/null +++ b/tests/binary-parsing/code-memory.wast @@ -0,0 +1,137 @@ +(module $mymodule + (func (param i32) (result i32) + i32.const 0 + i32.load + drop + + i32.const 0 + i32.load offset=8 + drop + + i32.const 0 + i32.load align=4 + drop + + i32.const 0 + i32.load offset=8 align=4 + drop + + i32.const 0 + i64.load offset=8 + drop + + i32.const 0 + f32.load offset=8 + drop + + i32.const 0 + f64.load offset=8 + drop + + i32.const 0 + i32.load8_s offset=8 + drop + + i32.const 0 + i32.load8_u offset=8 + drop + + i32.const 0 + i32.load16_s offset=8 + drop + + i32.const 0 + i32.load16_u offset=8 + drop + + i32.const 0 + i64.load8_s offset=8 + drop + + i32.const 0 + i64.load8_u offset=8 + drop + + i32.const 0 + i64.load16_s offset=8 + drop + + i32.const 0 + i64.load16_u offset=8 + drop + + i32.const 0 + i64.load32_s offset=8 + drop + + i32.const 0 + i64.load32_u offset=8 + drop + + i32.const 0 + i32.const 0 + i32.store offset=8 + + i32.const 0 + i32.const 0 + i32.store8 offset=8 + + i32.const 0 + i32.const 0 + i32.store16 offset=8 + + i32.const 0 + i64.const 0 + i64.store offset=8 + + i32.const 0 + i64.const 0 + i64.store8 offset=8 + + i32.const 0 + i64.const 0 + i64.store16 offset=8 + + i32.const 0 + i64.const 0 + i64.store32 offset=8 + + i32.const 0 + i32.const 0 + f32.load offset=8 + f32.store offset=8 + + i32.const 0 + i32.const 0 + f64.load offset=8 + f64.store offset=8 + + memory.size + drop + + i32.const 0 + memory.grow + drop + + i32.const 0 + i32.const 0 + i32.const 0 + memory.fill + + i32.const 0 + i32.const 0 + i32.const 0 + memory.copy + + i32.const 0 + i32.const 0 + i32.const 0 + memory.init 0 + + data.drop 0 + (return (i32.const 1)) + ) + (memory (;0;) 17) + (global $g (mut i32) (i32.const 1048576)) + (data (i32.const 1048576) ";askdfja;skdjf") +) diff --git a/tests/binary-parsing/code-numeric-convert-reinterpret.wast b/tests/binary-parsing/code-numeric-convert-reinterpret.wast new file mode 100644 index 000000000..17a8819b2 --- /dev/null +++ b/tests/binary-parsing/code-numeric-convert-reinterpret.wast @@ -0,0 +1,24 @@ +(module $mymodule + (func (param i32) (result i32) + + i32.const 0 + f32.convert_i32_s + i32.reinterpret_f32 + drop + + i32.const 0 + f64.convert_i32_s + i64.reinterpret_f64 + drop + + i32.const 0 + f32.reinterpret_i32 + drop + + i64.const 0 + f64.reinterpret_i64 + drop + + (return (i32.const 1)) + ) +) diff --git a/tests/binary-parsing/code-numeric-convert.wast b/tests/binary-parsing/code-numeric-convert.wast new file mode 100644 index 000000000..e16878b71 --- /dev/null +++ b/tests/binary-parsing/code-numeric-convert.wast @@ -0,0 +1,124 @@ +(module $mymodule + (func (param i32) (result i32) + + i64.const 0 + i32.wrap_i64 + drop + + i32.const 0 + f32.convert_i32_s + i32.trunc_f32_s + drop + + i32.const 0 + f32.convert_i32_s + i32.trunc_f32_u + drop + + i32.const 0 + f64.convert_i32_s + drop + + i32.const 0 + f64.convert_i32_s + i32.trunc_f64_s + drop + + i32.const 0 + f64.convert_i32_s + i32.trunc_f64_u + drop + + i32.const 0 + i64.extend_i32_s + drop + + i32.const 0 + i64.extend_i32_u + drop + + i32.const 0 + f32.convert_i32_s + i64.trunc_f32_s + drop + + i32.const 0 + f32.convert_i32_s + i64.trunc_f32_u + drop + + i32.const 0 + f64.convert_i32_s + i64.trunc_f64_s + drop + + i32.const 0 + f64.convert_i32_s + i64.trunc_f64_u + drop + + i32.const 0 + f32.convert_i32_s + drop + + i32.const 0 + f32.convert_i32_u + drop + + i64.const 0 + f32.convert_i64_s + drop + + i64.const 0 + f32.convert_i64_u + drop + + i32.const 0 + f64.convert_i32_s + f32.demote_f64 + drop + + i32.const 0 + f64.convert_i32_s + drop + + i32.const 0 + f64.convert_i32_u + drop + + i64.const 0 + f64.convert_i64_s + drop + + i64.const 0 + f64.convert_i64_u + drop + + i32.const 0 + f32.convert_i32_s + f64.promote_f32 + drop + + i32.const 0 + i32.extend8_s + drop + + i32.const 0 + i32.extend16_s + drop + + i64.const 0 + i64.extend8_s + drop + + i64.const 0 + i64.extend16_s + drop + + i64.const 0 + i64.extend32_s + drop + + (return (i32.const 1)) + ) +) diff --git a/tests/binary-parsing/code-numeric-convert.wast.out b/tests/binary-parsing/code-numeric-convert.wast.out new file mode 100644 index 000000000..2bc8b8995 --- /dev/null +++ b/tests/binary-parsing/code-numeric-convert.wast.out @@ -0,0 +1,65 @@ + + + #module (... types: #type (... type: [ i32 .ValTypes ] -> [ i32 .ValTypes ] , metadata: ) .EmptyStmts , funcs: #func (... type: 0 , locals: [ .ValTypes ] , body: i64 . const 0 i32 . wrap_i64 drop i32 . const 0 f32 . convert_i32_s i32 . trunc_f32_s drop i32 . const 0 f32 . convert_i32_s i32 . trunc_f32_u drop i32 . const 0 f64 . convert_i32_s drop i32 . const 0 f64 . convert_i32_s i32 . trunc_f64_s drop i32 . const 0 f64 . convert_i32_s i32 . trunc_f64_u drop i32 . const 0 i64 . extend_i32_s drop i32 . const 0 i64 . extend_i32_u drop i32 . const 0 f32 . convert_i32_s i64 . trunc_f32_s drop i32 . const 0 f32 . convert_i32_s i64 . trunc_f32_u drop i32 . const 0 f64 . convert_i32_s i64 . trunc_f64_s drop i32 . const 0 f64 . convert_i32_s i64 . trunc_f64_u drop i32 . const 0 f32 . convert_i32_s drop i32 . const 0 f32 . convert_i32_u drop i64 . const 0 f32 . convert_i64_s drop i64 . const 0 f32 . convert_i64_u drop i32 . const 0 f64 . convert_i32_s f32 . demote_f64 drop i32 . const 0 f64 . convert_i32_s drop i32 . const 0 f64 . convert_i32_u drop i64 . const 0 f64 . convert_i64_s drop i64 . const 0 f64 . convert_i64_u drop i32 . const 0 f32 . convert_i32_s f64 . promote_f32 drop i32 . const 0 i32 . extend8_s drop i32 . const 0 i32 . extend16_s drop i64 . const 0 i64 . extend8_s drop i64 . const 0 i64 . extend16_s drop i64 . const 0 i64 . extend32_s drop i32 . const 1 return .EmptyStmts , metadata: #meta (... id: , localIds: .Map ) ) .EmptyStmts , tables: .EmptyStmts , mems: .EmptyStmts , globals: .EmptyStmts , elem: .EmptyStmts , data: .EmptyStmts , start: .EmptyStmts , importDefns: .EmptyStmts , exports: .EmptyStmts , metadata: #meta (... id: , funcIds: .Map , filename: .String ) ) ~> .K + + + + .K + + + .ValStack + + + + .List + + + .Int + + + + .Map + + + .Map + + + .ModuleInstCellMap + + + 0 + + + + .FuncDefCellMap + + + 0 + + + .TabInstCellMap + + + 0 + + + .List + + + .GlobalInstCellMap + + + 0 + + + .ElemInstCellMap + + + 0 + + + + true + + + diff --git a/tests/binary-parsing/code-numeric-f32.wast b/tests/binary-parsing/code-numeric-f32.wast new file mode 100644 index 000000000..1b51ce8ce --- /dev/null +++ b/tests/binary-parsing/code-numeric-f32.wast @@ -0,0 +1,132 @@ +(module $mymodule + (func (param i32) (result i32) + + i32.const 0 + f32.convert_i32_s + f32.abs + drop + + i32.const 0 + f32.convert_i32_s + f32.neg + drop + + i32.const 0 + f32.convert_i32_s + f32.ceil + drop + + i32.const 0 + f32.convert_i32_s + f32.floor + drop + + i32.const 0 + f32.convert_i32_s + f32.trunc + drop + + i32.const 0 + f32.convert_i32_s + f32.nearest + drop + + i32.const 0 + f32.convert_i32_s + f32.sqrt + drop + + i32.const 0 + f32.convert_i32_s + i32.const 0 + f32.convert_i32_s + f32.add + drop + + i32.const 0 + f32.convert_i32_s + i32.const 0 + f32.convert_i32_s + f32.sub + drop + + i32.const 0 + f32.convert_i32_s + i32.const 0 + f32.convert_i32_s + f32.mul + drop + + i32.const 0 + f32.convert_i32_s + i32.const 0 + f32.convert_i32_s + f32.div + drop + + i32.const 0 + f32.convert_i32_s + i32.const 0 + f32.convert_i32_s + f32.min + drop + + i32.const 0 + f32.convert_i32_s + i32.const 0 + f32.convert_i32_s + f32.max + drop + + i32.const 0 + f32.convert_i32_s + i32.const 0 + f32.convert_i32_s + f32.copysign + drop + + i32.const 0 + f32.convert_i32_s + i32.const 0 + f32.convert_i32_s + f32.eq + drop + + i32.const 0 + f32.convert_i32_s + i32.const 0 + f32.convert_i32_s + f32.ne + drop + + i32.const 0 + f32.convert_i32_s + i32.const 0 + f32.convert_i32_s + f32.lt + drop + + i32.const 0 + f32.convert_i32_s + i32.const 0 + f32.convert_i32_s + f32.gt + drop + + i32.const 0 + f32.convert_i32_s + i32.const 0 + f32.convert_i32_s + f32.le + drop + + i32.const 0 + f32.convert_i32_s + i32.const 0 + f32.convert_i32_s + f32.ge + drop + + (return (i32.const 1)) + ) +) diff --git a/tests/binary-parsing/code-numeric-f32.wast.out b/tests/binary-parsing/code-numeric-f32.wast.out new file mode 100644 index 000000000..96d9ba342 --- /dev/null +++ b/tests/binary-parsing/code-numeric-f32.wast.out @@ -0,0 +1,65 @@ + + + #module (... types: #type (... type: [ i32 .ValTypes ] -> [ i32 .ValTypes ] , metadata: ) .EmptyStmts , funcs: #func (... type: 0 , locals: [ .ValTypes ] , body: i32 . const 0 f32 . convert_i32_s f32 . abs drop i32 . const 0 f32 . convert_i32_s f32 . neg drop i32 . const 0 f32 . convert_i32_s f32 . ceil drop i32 . const 0 f32 . convert_i32_s f32 . floor drop i32 . const 0 f32 . convert_i32_s f32 . trunc drop i32 . const 0 f32 . convert_i32_s f32 . nearest drop i32 . const 0 f32 . convert_i32_s f32 . sqrt drop i32 . const 0 f32 . convert_i32_s i32 . const 0 f32 . convert_i32_s f32 . add drop i32 . const 0 f32 . convert_i32_s i32 . const 0 f32 . convert_i32_s f32 . sub drop i32 . const 0 f32 . convert_i32_s i32 . const 0 f32 . convert_i32_s f32 . mul drop i32 . const 0 f32 . convert_i32_s i32 . const 0 f32 . convert_i32_s f32 . div drop i32 . const 0 f32 . convert_i32_s i32 . const 0 f32 . convert_i32_s f32 . min drop i32 . const 0 f32 . convert_i32_s i32 . const 0 f32 . convert_i32_s f32 . max drop i32 . const 0 f32 . convert_i32_s i32 . const 0 f32 . convert_i32_s f32 . copysign drop i32 . const 0 f32 . convert_i32_s i32 . const 0 f32 . convert_i32_s f32 . eq drop i32 . const 0 f32 . convert_i32_s i32 . const 0 f32 . convert_i32_s f32 . ne drop i32 . const 0 f32 . convert_i32_s i32 . const 0 f32 . convert_i32_s f32 . lt drop i32 . const 0 f32 . convert_i32_s i32 . const 0 f32 . convert_i32_s f32 . gt drop i32 . const 0 f32 . convert_i32_s i32 . const 0 f32 . convert_i32_s f32 . le drop i32 . const 0 f32 . convert_i32_s i32 . const 0 f32 . convert_i32_s f32 . ge drop i32 . const 1 return .EmptyStmts , metadata: #meta (... id: , localIds: .Map ) ) .EmptyStmts , tables: .EmptyStmts , mems: .EmptyStmts , globals: .EmptyStmts , elem: .EmptyStmts , data: .EmptyStmts , start: .EmptyStmts , importDefns: .EmptyStmts , exports: .EmptyStmts , metadata: #meta (... id: , funcIds: .Map , filename: .String ) ) ~> .K + + + + .K + + + .ValStack + + + + .List + + + .Int + + + + .Map + + + .Map + + + .ModuleInstCellMap + + + 0 + + + + .FuncDefCellMap + + + 0 + + + .TabInstCellMap + + + 0 + + + .List + + + .GlobalInstCellMap + + + 0 + + + .ElemInstCellMap + + + 0 + + + + true + + + diff --git a/tests/binary-parsing/code-numeric-f64.wast b/tests/binary-parsing/code-numeric-f64.wast new file mode 100644 index 000000000..51a41edf8 --- /dev/null +++ b/tests/binary-parsing/code-numeric-f64.wast @@ -0,0 +1,132 @@ +(module $mymodule + (func (param i32) (result i32) + + i32.const 0 + f64.convert_i32_s + f64.abs + drop + + i32.const 0 + f64.convert_i32_s + f64.neg + drop + + i32.const 0 + f64.convert_i32_s + f64.ceil + drop + + i32.const 0 + f64.convert_i32_s + f64.floor + drop + + i32.const 0 + f64.convert_i32_s + f64.trunc + drop + + i32.const 0 + f64.convert_i32_s + f64.nearest + drop + + i32.const 0 + f64.convert_i32_s + f64.sqrt + drop + + i32.const 0 + f64.convert_i32_s + i32.const 0 + f64.convert_i32_s + f64.add + drop + + i32.const 0 + f64.convert_i32_s + i32.const 0 + f64.convert_i32_s + f64.sub + drop + + i32.const 0 + f64.convert_i32_s + i32.const 0 + f64.convert_i32_s + f64.mul + drop + + i32.const 1 + f64.convert_i32_s + i32.const 1 + f64.convert_i32_s + f64.div + drop + + i32.const 0 + f64.convert_i32_s + i32.const 0 + f64.convert_i32_s + f64.min + drop + + i32.const 0 + f64.convert_i32_s + i32.const 0 + f64.convert_i32_s + f64.max + drop + + i32.const 0 + f64.convert_i32_s + i32.const 0 + f64.convert_i32_s + f64.copysign + drop + + i32.const 0 + f64.convert_i32_s + i32.const 0 + f64.convert_i32_s + f64.eq + drop + + i32.const 0 + f64.convert_i32_s + i32.const 0 + f64.convert_i32_s + f64.ne + drop + + i32.const 0 + f64.convert_i32_s + i32.const 0 + f64.convert_i32_s + f64.lt + drop + + i32.const 0 + f64.convert_i32_s + i32.const 0 + f64.convert_i32_s + f64.gt + drop + + i32.const 0 + f64.convert_i32_s + i32.const 0 + f64.convert_i32_s + f64.le + drop + + i32.const 0 + f64.convert_i32_s + i32.const 0 + f64.convert_i32_s + f64.ge + drop + + (return (i32.const 1)) + ) +) diff --git a/tests/binary-parsing/code-numeric-f64.wast.out b/tests/binary-parsing/code-numeric-f64.wast.out new file mode 100644 index 000000000..d06e78cc9 --- /dev/null +++ b/tests/binary-parsing/code-numeric-f64.wast.out @@ -0,0 +1,65 @@ + + + #module (... types: #type (... type: [ i32 .ValTypes ] -> [ i32 .ValTypes ] , metadata: ) .EmptyStmts , funcs: #func (... type: 0 , locals: [ .ValTypes ] , body: i32 . const 0 f64 . convert_i32_s f64 . abs drop i32 . const 0 f64 . convert_i32_s f64 . neg drop i32 . const 0 f64 . convert_i32_s f64 . ceil drop i32 . const 0 f64 . convert_i32_s f64 . floor drop i32 . const 0 f64 . convert_i32_s f64 . trunc drop i32 . const 0 f64 . convert_i32_s f64 . nearest drop i32 . const 0 f64 . convert_i32_s f64 . sqrt drop i32 . const 0 f64 . convert_i32_s i32 . const 0 f64 . convert_i32_s f32 . add drop i32 . const 0 f64 . convert_i32_s i32 . const 0 f64 . convert_i32_s f32 . sub drop i32 . const 0 f64 . convert_i32_s i32 . const 0 f64 . convert_i32_s f32 . mul drop i32 . const 1 f64 . convert_i32_s i32 . const 1 f64 . convert_i32_s f32 . div drop i32 . const 0 f64 . convert_i32_s i32 . const 0 f64 . convert_i32_s f32 . min drop i32 . const 0 f64 . convert_i32_s i32 . const 0 f64 . convert_i32_s f32 . max drop i32 . const 0 f64 . convert_i32_s i32 . const 0 f64 . convert_i32_s f32 . copysign drop i32 . const 0 f64 . convert_i32_s i32 . const 0 f64 . convert_i32_s f64 . eq drop i32 . const 0 f64 . convert_i32_s i32 . const 0 f64 . convert_i32_s f64 . ne drop i32 . const 0 f64 . convert_i32_s i32 . const 0 f64 . convert_i32_s f64 . lt drop i32 . const 0 f64 . convert_i32_s i32 . const 0 f64 . convert_i32_s f64 . gt drop i32 . const 0 f64 . convert_i32_s i32 . const 0 f64 . convert_i32_s f64 . le drop i32 . const 0 f64 . convert_i32_s i32 . const 0 f64 . convert_i32_s f64 . ge drop i32 . const 1 return .EmptyStmts , metadata: #meta (... id: , localIds: .Map ) ) .EmptyStmts , tables: .EmptyStmts , mems: .EmptyStmts , globals: .EmptyStmts , elem: .EmptyStmts , data: .EmptyStmts , start: .EmptyStmts , importDefns: .EmptyStmts , exports: .EmptyStmts , metadata: #meta (... id: , funcIds: .Map , filename: .String ) ) ~> .K + + + + .K + + + .ValStack + + + + .List + + + .Int + + + + .Map + + + .Map + + + .ModuleInstCellMap + + + 0 + + + + .FuncDefCellMap + + + 0 + + + .TabInstCellMap + + + 0 + + + .List + + + .GlobalInstCellMap + + + 0 + + + .ElemInstCellMap + + + 0 + + + + true + + + diff --git a/tests/binary-parsing/code-numeric-float-parsing.md b/tests/binary-parsing/code-numeric-float-parsing.md new file mode 100644 index 000000000..cc93624db --- /dev/null +++ b/tests/binary-parsing/code-numeric-float-parsing.md @@ -0,0 +1,14 @@ +(module $mymodule + (func (param i32) (result i32) + f32.const 0.0 + drop + + f64.const 0.0 + drop + + (return (i32.const 1)) + ) + (memory (;0;) 17) + (global $g (mut i32) (i32.const 1048576)) + (data (i32.const 1048576) ";askdfja;skdjf") +) diff --git a/tests/binary-parsing/code-numeric-i32.wast b/tests/binary-parsing/code-numeric-i32.wast new file mode 100644 index 000000000..4e7adb387 --- /dev/null +++ b/tests/binary-parsing/code-numeric-i32.wast @@ -0,0 +1,149 @@ +(module $mymodule + (func (param i32) (result i32) + i32.const 0 + drop + + i32.const 0 + i32.clz + drop + + i32.const 0 + i32.ctz + drop + + i32.const 0 + i32.popcnt + drop + + i32.const 1 + i32.const 1 + i32.add + drop + + i32.const 1 + i32.const 1 + i32.sub + drop + + i32.const 1 + i32.const 1 + i32.mul + drop + + i32.const 1 + i32.const 1 + i32.div_s + drop + + i32.const 1 + i32.const 1 + i32.div_u + drop + + i32.const 1 + i32.const 1 + i32.rem_s + drop + + i32.const 1 + i32.const 1 + i32.rem_u + drop + + i32.const 1 + i32.const 1 + i32.and + drop + + i32.const 1 + i32.const 1 + i32.or + drop + + i32.const 1 + i32.const 1 + i32.xor + drop + + i32.const 1 + i32.const 1 + i32.shl + drop + + i32.const 1 + i32.const 1 + i32.shr_s + drop + + i32.const 1 + i32.const 1 + i32.shr_u + drop + + i32.const 1 + i32.const 1 + i32.rotl + drop + + i32.const 1 + i32.const 1 + i32.rotr + drop + + i32.const 1 + i32.eqz + drop + + i32.const 1 + i32.const 1 + i32.eq + drop + + i32.const 1 + i32.const 1 + i32.ne + drop + + i32.const 1 + i32.const 1 + i32.lt_s + drop + + i32.const 1 + i32.const 1 + i32.lt_u + drop + + i32.const 1 + i32.const 1 + i32.gt_s + drop + + i32.const 1 + i32.const 1 + i32.gt_u + drop + + i32.const 1 + i32.const 1 + i32.le_s + drop + + i32.const 1 + i32.const 1 + i32.le_u + drop + + i32.const 1 + i32.const 1 + i32.ge_s + drop + + i32.const 1 + i32.const 1 + i32.ge_u + drop + + (return (i32.const 1)) + ) +) diff --git a/tests/binary-parsing/code-numeric-i32.wast.out b/tests/binary-parsing/code-numeric-i32.wast.out new file mode 100644 index 000000000..d909cf722 --- /dev/null +++ b/tests/binary-parsing/code-numeric-i32.wast.out @@ -0,0 +1,65 @@ + + + #module (... types: #type (... type: [ i32 .ValTypes ] -> [ i32 .ValTypes ] , metadata: ) .EmptyStmts , funcs: #func (... type: 0 , locals: [ .ValTypes ] , body: i32 . const 0 drop i32 . const 0 i32 . clz drop i32 . const 0 i32 . ctz drop i32 . const 0 i32 . popcnt drop i32 . const 1 i32 . const 1 i32 . add drop i32 . const 1 i32 . const 1 i32 . sub drop i32 . const 1 i32 . const 1 i32 . mul drop i32 . const 1 i32 . const 1 i32 . div_s drop i32 . const 1 i32 . const 1 i32 . div_u drop i32 . const 1 i32 . const 1 i32 . rem_s drop i32 . const 1 i32 . const 1 i32 . rem_u drop i32 . const 1 i32 . const 1 i32 . and drop i32 . const 1 i32 . const 1 i32 . or drop i32 . const 1 i32 . const 1 i32 . xor drop i32 . const 1 i32 . const 1 i32 . shl drop i32 . const 1 i32 . const 1 i32 . shr_s drop i32 . const 1 i32 . const 1 i32 . shr_u drop i32 . const 1 i32 . const 1 i32 . rotl drop i32 . const 1 i32 . const 1 i32 . rotr drop i32 . const 1 i32 . eqz drop i32 . const 1 i32 . const 1 i32 . eq drop i32 . const 1 i32 . const 1 i32 . ne drop i32 . const 1 i32 . const 1 i32 . lt_s drop i32 . const 1 i32 . const 1 i32 . lt_u drop i32 . const 1 i32 . const 1 i32 . gt_s drop i32 . const 1 i32 . const 1 i32 . gt_u drop i32 . const 1 i32 . const 1 i32 . le_s drop i32 . const 1 i32 . const 1 i32 . le_u drop i32 . const 1 i32 . const 1 i32 . ge_s drop i32 . const 1 i32 . const 1 i32 . ge_u drop i32 . const 1 return .EmptyStmts , metadata: #meta (... id: , localIds: .Map ) ) .EmptyStmts , tables: .EmptyStmts , mems: .EmptyStmts , globals: .EmptyStmts , elem: .EmptyStmts , data: .EmptyStmts , start: .EmptyStmts , importDefns: .EmptyStmts , exports: .EmptyStmts , metadata: #meta (... id: , funcIds: .Map , filename: .String ) ) ~> .K + + + + .K + + + .ValStack + + + + .List + + + .Int + + + + .Map + + + .Map + + + .ModuleInstCellMap + + + 0 + + + + .FuncDefCellMap + + + 0 + + + .TabInstCellMap + + + 0 + + + .List + + + .GlobalInstCellMap + + + 0 + + + .ElemInstCellMap + + + 0 + + + + true + + + diff --git a/tests/binary-parsing/code-numeric-i64.wast b/tests/binary-parsing/code-numeric-i64.wast new file mode 100644 index 000000000..e5c159cc8 --- /dev/null +++ b/tests/binary-parsing/code-numeric-i64.wast @@ -0,0 +1,149 @@ +(module $mymodule + (func (param i32) (result i32) + i64.const 0 + drop + + i64.const 0 + i64.clz + drop + + i64.const 0 + i64.ctz + drop + + i64.const 0 + i64.popcnt + drop + + i64.const 1 + i64.const 1 + i64.add + drop + + i64.const 1 + i64.const 1 + i64.sub + drop + + i64.const 1 + i64.const 1 + i64.mul + drop + + i64.const 1 + i64.const 1 + i64.div_s + drop + + i64.const 1 + i64.const 1 + i64.div_u + drop + + i64.const 1 + i64.const 1 + i64.rem_s + drop + + i64.const 1 + i64.const 1 + i64.rem_u + drop + + i64.const 1 + i64.const 1 + i64.and + drop + + i64.const 1 + i64.const 1 + i64.or + drop + + i64.const 1 + i64.const 1 + i64.xor + drop + + i64.const 1 + i64.const 1 + i64.shl + drop + + i64.const 1 + i64.const 1 + i64.shr_s + drop + + i64.const 1 + i64.const 1 + i64.shr_u + drop + + i64.const 1 + i64.const 1 + i64.rotl + drop + + i64.const 1 + i64.const 1 + i64.rotr + drop + + i64.const 1 + i64.eqz + drop + + i64.const 1 + i64.const 1 + i64.eq + drop + + i64.const 1 + i64.const 1 + i64.ne + drop + + i64.const 1 + i64.const 1 + i64.lt_s + drop + + i64.const 1 + i64.const 1 + i64.lt_u + drop + + i64.const 1 + i64.const 1 + i64.gt_s + drop + + i64.const 1 + i64.const 1 + i64.gt_u + drop + + i64.const 1 + i64.const 1 + i64.le_s + drop + + i64.const 1 + i64.const 1 + i64.le_u + drop + + i64.const 1 + i64.const 1 + i64.ge_s + drop + + i64.const 1 + i64.const 1 + i64.ge_u + drop + + (return (i32.const 1)) + ) +) diff --git a/tests/binary-parsing/code-numeric-i64.wast.out b/tests/binary-parsing/code-numeric-i64.wast.out new file mode 100644 index 000000000..3608f04ac --- /dev/null +++ b/tests/binary-parsing/code-numeric-i64.wast.out @@ -0,0 +1,65 @@ + + + #module (... types: #type (... type: [ i32 .ValTypes ] -> [ i32 .ValTypes ] , metadata: ) .EmptyStmts , funcs: #func (... type: 0 , locals: [ .ValTypes ] , body: i64 . const 0 drop i64 . const 0 i32 . clz drop i64 . const 0 i32 . ctz drop i64 . const 0 i32 . popcnt drop i64 . const 1 i64 . const 1 i64 . add drop i64 . const 1 i64 . const 1 i64 . sub drop i64 . const 1 i64 . const 1 i64 . mul drop i64 . const 1 i64 . const 1 i64 . div_s drop i64 . const 1 i64 . const 1 i64 . div_u drop i64 . const 1 i64 . const 1 i64 . rem_s drop i64 . const 1 i64 . const 1 i64 . rem_u drop i64 . const 1 i64 . const 1 i64 . and drop i64 . const 1 i64 . const 1 i64 . or drop i64 . const 1 i64 . const 1 i64 . xor drop i64 . const 1 i64 . const 1 i64 . shl drop i64 . const 1 i64 . const 1 i64 . shr_s drop i64 . const 1 i64 . const 1 i64 . shr_u drop i64 . const 1 i64 . const 1 i64 . rotl drop i64 . const 1 i64 . const 1 i64 . rotr drop i64 . const 1 i64 . eqz drop i64 . const 1 i64 . const 1 i64 . eq drop i64 . const 1 i64 . const 1 i64 . ne drop i64 . const 1 i64 . const 1 i64 . lt_s drop i64 . const 1 i64 . const 1 i64 . lt_u drop i64 . const 1 i64 . const 1 i64 . gt_s drop i64 . const 1 i64 . const 1 i64 . gt_u drop i64 . const 1 i64 . const 1 i64 . le_s drop i64 . const 1 i64 . const 1 i64 . le_u drop i64 . const 1 i64 . const 1 i64 . ge_s drop i64 . const 1 i64 . const 1 i64 . ge_u drop i32 . const 1 return .EmptyStmts , metadata: #meta (... id: , localIds: .Map ) ) .EmptyStmts , tables: .EmptyStmts , mems: .EmptyStmts , globals: .EmptyStmts , elem: .EmptyStmts , data: .EmptyStmts , start: .EmptyStmts , importDefns: .EmptyStmts , exports: .EmptyStmts , metadata: #meta (... id: , funcIds: .Map , filename: .String ) ) ~> .K + + + + .K + + + .ValStack + + + + .List + + + .Int + + + + .Map + + + .Map + + + .ModuleInstCellMap + + + 0 + + + + .FuncDefCellMap + + + 0 + + + .TabInstCellMap + + + 0 + + + .List + + + .GlobalInstCellMap + + + 0 + + + .ElemInstCellMap + + + 0 + + + + true + + + diff --git a/tests/binary-parsing/code-reference-func.wast b/tests/binary-parsing/code-reference-func.wast new file mode 100644 index 000000000..8aa4fe2a3 --- /dev/null +++ b/tests/binary-parsing/code-reference-func.wast @@ -0,0 +1,14 @@ +(module $mymodule + (elem declare func $f) + (func $f (param i32) (result i32) + (return + (i32.const 0) + ) + ) + (func (param i32) (result i32) + (ref.func 0) + (return + (i32.const 1) + ) + ) +) diff --git a/tests/binary-parsing/code-reference.wast b/tests/binary-parsing/code-reference.wast new file mode 100644 index 000000000..737d2d2d2 --- /dev/null +++ b/tests/binary-parsing/code-reference.wast @@ -0,0 +1,14 @@ +(module $mymodule + (func $f (param i32) (result i32) + (return + (i32.const 0) + ) + ) + (func (param i32) (result i32) + (ref.null func) + (ref.is_null) + (return + (i32.const 1) + ) + ) +) diff --git a/tests/binary-parsing/code-reference.wast.out b/tests/binary-parsing/code-reference.wast.out new file mode 100644 index 000000000..9ba4c9a00 --- /dev/null +++ b/tests/binary-parsing/code-reference.wast.out @@ -0,0 +1,65 @@ + + + #module (... types: #type (... type: [ i32 .ValTypes ] -> [ i32 .ValTypes ] , metadata: ) .EmptyStmts , funcs: #func (... type: 0 , locals: [ .ValTypes ] , body: i32 . const 0 return .EmptyStmts , metadata: #meta (... id: , localIds: .Map ) ) #func (... type: 0 , locals: [ .ValTypes ] , body: ref.null func #ref.is_null i32 . const 1 return .EmptyStmts , metadata: #meta (... id: , localIds: .Map ) ) .EmptyStmts , tables: .EmptyStmts , mems: .EmptyStmts , globals: .EmptyStmts , elem: .EmptyStmts , data: .EmptyStmts , start: .EmptyStmts , importDefns: .EmptyStmts , exports: .EmptyStmts , metadata: #meta (... id: , funcIds: .Map , filename: .String ) ) ~> .K + + + + .K + + + .ValStack + + + + .List + + + .Int + + + + .Map + + + .Map + + + .ModuleInstCellMap + + + 0 + + + + .FuncDefCellMap + + + 0 + + + .TabInstCellMap + + + 0 + + + .List + + + .GlobalInstCellMap + + + 0 + + + .ElemInstCellMap + + + 0 + + + + true + + + diff --git a/tests/binary-parsing/code-table.wast b/tests/binary-parsing/code-table.wast new file mode 100644 index 000000000..f1bd1b06d --- /dev/null +++ b/tests/binary-parsing/code-table.wast @@ -0,0 +1,40 @@ +(module $mymodule + (table 2 funcref) + (table 2 funcref) + (elem (i32.const 0) 0) + (elem (i32.const 0) 0) + (func (param i32) (result i32) + (i32.const 1) + (i32.const 1) + (table.get 0) + (table.set 0) + + (table.size 0) + drop + + (i32.const 1) + (table.get 0) + (i32.const 10) + (table.grow 0) + drop + + (i32.const 10) + (i32.const 1) + (table.get 0) + (i32.const 10) + (table.fill 0) + + (i32.const 1) + (i32.const 1) + (i32.const 1) + (table.copy 0 1) + + (i32.const 1) + (i32.const 1) + (i32.const 1) + (table.init 0 1) + + (elem.drop 0) + (return (i32.const 1)) + ) +) diff --git a/tests/binary-parsing/code-variable-global.wast b/tests/binary-parsing/code-variable-global.wast new file mode 100644 index 000000000..d10b12451 --- /dev/null +++ b/tests/binary-parsing/code-variable-global.wast @@ -0,0 +1,9 @@ +(module $mymodule + (func (param i32) (result i32) + (local i32 i64) + global.get 0 + global.set 0 + (return (i32.const 1)) + ) + (global $g (mut i32) (i32.const 1048576)) +) diff --git a/tests/binary-parsing/code-variable.wast b/tests/binary-parsing/code-variable.wast new file mode 100644 index 000000000..51ac2b7d9 --- /dev/null +++ b/tests/binary-parsing/code-variable.wast @@ -0,0 +1,13 @@ +(module $mymodule + (func (param i32) (result i32) + (local i32 i64) + local.get 0 + local.set 0 + local.get 1 + local.set 1 + local.get 0 + local.tee 0 + drop + (return (i32.const 1)) + ) +) diff --git a/tests/binary-parsing/code-variable.wast.out b/tests/binary-parsing/code-variable.wast.out new file mode 100644 index 000000000..50ee805ee --- /dev/null +++ b/tests/binary-parsing/code-variable.wast.out @@ -0,0 +1,65 @@ + + + #module (... types: #type (... type: [ i32 .ValTypes ] -> [ i32 .ValTypes ] , metadata: ) .EmptyStmts , funcs: #func (... type: 0 , locals: [ i32 i64 .ValTypes ] , body: #local.get ( 0 ) #local.set ( 0 ) #local.get ( 1 ) #local.set ( 1 ) #local.get ( 0 ) #local.tee ( 0 ) drop i32 . const 1 return .EmptyStmts , metadata: #meta (... id: , localIds: .Map ) ) .EmptyStmts , tables: .EmptyStmts , mems: .EmptyStmts , globals: .EmptyStmts , elem: .EmptyStmts , data: .EmptyStmts , start: .EmptyStmts , importDefns: .EmptyStmts , exports: .EmptyStmts , metadata: #meta (... id: , funcIds: .Map , filename: .String ) ) ~> .K + + + + .K + + + .ValStack + + + + .List + + + .Int + + + + .Map + + + .Map + + + .ModuleInstCellMap + + + 0 + + + + .FuncDefCellMap + + + 0 + + + .TabInstCellMap + + + 0 + + + .List + + + .GlobalInstCellMap + + + 0 + + + .ElemInstCellMap + + + 0 + + + + true + + + diff --git a/tests/binary-parsing/code.wast b/tests/binary-parsing/code.wast new file mode 100644 index 000000000..719aec649 --- /dev/null +++ b/tests/binary-parsing/code.wast @@ -0,0 +1,12 @@ +(module $mymodule + (func (param i32) (result i32) + (local) + (return + (if (result i32) + (i32.eq (local.get 0) (i32.const 0)) + (i32.const 1) + (i32.mul (local.get 0) (call 0 (i32.sub (local.get 0) (i32.const 1)))) + ) + ) + ) +) diff --git a/tests/binary-parsing/code.wast.out b/tests/binary-parsing/code.wast.out new file mode 100644 index 000000000..a7e76b42e --- /dev/null +++ b/tests/binary-parsing/code.wast.out @@ -0,0 +1,65 @@ + + + #module (... types: #type (... type: [ i32 .ValTypes ] -> [ i32 .ValTypes ] , metadata: ) .EmptyStmts , funcs: #func (... type: 0 , locals: [ .ValTypes ] , body: #local.get ( 0 ) i32 . const 0 i32 . eq #if ( [ i32 .ValTypes ] , i32 . const 1 .EmptyStmts , #local.get ( 0 ) #local.get ( 0 ) i32 . const 1 i32 . sub #call ( 0 ) i32 . mul .EmptyStmts , .Int ) return .EmptyStmts , metadata: #meta (... id: , localIds: .Map ) ) .EmptyStmts , tables: .EmptyStmts , mems: .EmptyStmts , globals: .EmptyStmts , elem: .EmptyStmts , data: .EmptyStmts , start: .EmptyStmts , importDefns: .EmptyStmts , exports: .EmptyStmts , metadata: #meta (... id: , funcIds: .Map , filename: .String ) ) ~> .K + + + + .K + + + .ValStack + + + + .List + + + .Int + + + + .Map + + + .Map + + + .ModuleInstCellMap + + + 0 + + + + .FuncDefCellMap + + + 0 + + + .TabInstCellMap + + + 0 + + + .List + + + .GlobalInstCellMap + + + 0 + + + .ElemInstCellMap + + + 0 + + + + true + + + diff --git a/tests/binary-parsing/codes.wast b/tests/binary-parsing/codes.wast new file mode 100644 index 000000000..b98c1ead3 --- /dev/null +++ b/tests/binary-parsing/codes.wast @@ -0,0 +1,12 @@ +(module $mymodule + (func (param i32) (result i32) + (return + (i32.const 1) + ) + ) + (func (param i32) (result i32) + (return + (i32.const 2) + ) + ) +) diff --git a/tests/binary-parsing/codes.wast.out b/tests/binary-parsing/codes.wast.out new file mode 100644 index 000000000..01907571a --- /dev/null +++ b/tests/binary-parsing/codes.wast.out @@ -0,0 +1,65 @@ + + + #module (... types: #type (... type: [ i32 .ValTypes ] -> [ i32 .ValTypes ] , metadata: ) .EmptyStmts , funcs: #func (... type: 0 , locals: [ .ValTypes ] , body: i32 . const 1 return .EmptyStmts , metadata: #meta (... id: , localIds: .Map ) ) #func (... type: 0 , locals: [ .ValTypes ] , body: i32 . const 2 return .EmptyStmts , metadata: #meta (... id: , localIds: .Map ) ) .EmptyStmts , tables: .EmptyStmts , mems: .EmptyStmts , globals: .EmptyStmts , elem: .EmptyStmts , data: .EmptyStmts , start: .EmptyStmts , importDefns: .EmptyStmts , exports: .EmptyStmts , metadata: #meta (... id: , funcIds: .Map , filename: .String ) ) ~> .K + + + + .K + + + .ValStack + + + + .List + + + .Int + + + + .Map + + + .Map + + + .ModuleInstCellMap + + + 0 + + + + .FuncDefCellMap + + + 0 + + + .TabInstCellMap + + + 0 + + + .List + + + .GlobalInstCellMap + + + 0 + + + .ElemInstCellMap + + + 0 + + + + true + + + diff --git a/tests/binary-parsing/failing b/tests/binary-parsing/failing index f46364b41..dda4d54f0 100644 --- a/tests/binary-parsing/failing +++ b/tests/binary-parsing/failing @@ -1 +1,8 @@ tests/binary-parsing/type-param-v128.wast +tests/binary-parsing/code-call-indirect.wast +tests/binary-parsing/code-reference-func.wast +tests/binary-parsing/code-variable-global.wast +tests/binary-parsing/code-table.wast +tests/binary-parsing/code-memory.wast +tests/binary-parsing/code-numeric-float-parsing.md +tests/binary-parsing/code-numeric-convert-reinterpret.wast From 0dd416acc0ce6dcac36c5b4edef3c9cf17dd072f Mon Sep 17 00:00:00 2001 From: Virgil Date: Wed, 22 Jan 2025 16:46:28 +0200 Subject: [PATCH 2/7] Lint fixes for the code generator --- .../src/pykwasm/scripts/binary-parser-gen.py | 147 ++++++++++++------ 1 file changed, 97 insertions(+), 50 deletions(-) diff --git a/pykwasm/src/pykwasm/scripts/binary-parser-gen.py b/pykwasm/src/pykwasm/scripts/binary-parser-gen.py index b139f9cea..11928c033 100644 --- a/pykwasm/src/pykwasm/scripts/binary-parser-gen.py +++ b/pykwasm/src/pykwasm/scripts/binary-parser-gen.py @@ -1,21 +1,25 @@ import os from dataclasses import dataclass -def bytes_to_k(b:bytes) -> str: + +def bytes_to_k(b: bytes) -> str: escaped_bytes = ''.join([f'\\x{b:02x}' for b in b]) return 'b"' + escaped_bytes + '"' + class Constructor: - def build(self, args: list[tuple['Argument', int]], bwi:str, output_pieces: list[str]) -> None: + def build(self, args: list['Argument'], bwi: str, output_pieces: list[str]) -> None: raise NotImplementedError('Constructor.build') + def needs_bwi(self) -> bool: raise NotImplementedError('Constructor.needs_bwi') + @dataclass(frozen=True) class Symbol(Constructor): name: str - def build(self, args: list['Argument'], bwi:str, output_pieces: list[str]) -> None: + def build(self, args: list['Argument'], bwi: str, output_pieces: list[str]) -> None: output_pieces.append(f'instrResult(`{self.name}`(') first = True for i, arg in enumerate(args): @@ -32,11 +36,13 @@ def build(self, args: list['Argument'], bwi:str, output_pieces: list[str]) -> No def needs_bwi(self) -> bool: return True -def symbol(s:str) -> Symbol: + +def symbol(s: str) -> Symbol: return Symbol(s) + class Identity(Constructor): - def build(self, args: list['Argument'], bwi:str, output_pieces: list[str]) -> None: + def build(self, args: list['Argument'], bwi: str, output_pieces: list[str]) -> None: first = True output_pieces.append('instrResult(') for i, arg in enumerate(args): @@ -51,11 +57,13 @@ def build(self, args: list['Argument'], bwi:str, output_pieces: list[str]) -> No def needs_bwi(self) -> bool: return True + def identity() -> Identity: return Identity() + class NotImplemented(Constructor): - def build(self, args: list['Argument'], bwi:str, output_pieces: list[str]) -> None: + def build(self, args: list['Argument'], bwi: str, output_pieces: list[str]) -> None: output_pieces.append('parseError("instruction not implemented",') for i, arg in enumerate(args): if not arg.is_used_in_constructor(): @@ -68,14 +76,16 @@ def build(self, args: list['Argument'], bwi:str, output_pieces: list[str]) -> No def needs_bwi(self) -> bool: return True -def not_implemented(): + +def not_implemented() -> NotImplemented: return NotImplemented() + @dataclass(frozen=True) class Parser(Constructor): parser_name: str - def build(self, args: list['Argument'], bwi:str, output_pieces: list[str]) -> None: + def build(self, args: list['Argument'], bwi: str, output_pieces: list[str]) -> None: output_pieces.append(f'{self.parser_name}(') first = True for i, arg in enumerate(args): @@ -92,14 +102,16 @@ def build(self, args: list['Argument'], bwi:str, output_pieces: list[str]) -> No def needs_bwi(self) -> bool: return True -def parser(s:str): + +def parser(s: str) -> Parser: return Parser(s) + @dataclass(frozen=True) class ConstructorResult(Constructor): name: str - def build(self, args: list['Argument'], bwi:str, output_pieces: list[str]) -> None: + def build(self, args: list['Argument'], bwi: str, output_pieces: list[str]) -> None: output_pieces.append(f'instrResult({self.name}') if args: first = True @@ -119,24 +131,33 @@ def build(self, args: list['Argument'], bwi:str, output_pieces: list[str]) -> No def needs_bwi(self) -> bool: return True + class Argument: def parser(self, bwi: str) -> str: raise NotImplementedError('Argument.parser') + def is_used_in_constructor(self) -> bool: raise NotImplementedError('Argument.is_used_in_constructor') + def is_parsing_arg(self) -> bool: raise NotImplementedError('Argument.is_parsing_arg') - def result_argument(self, index:int, bwi: str) -> str: + + def result_argument(self, index: int, bwi: str) -> str: raise NotImplementedError('Argument.result_argument') + def result_type(self) -> str: raise NotImplementedError('Argument.result_type') + def value_type(self) -> str: raise NotImplementedError('Argument.value_type') + def lhs_argument(self, index: int, unused: bool) -> str: raise NotImplementedError('Argument.lhs_argument') - def rhs_argument(self, index: int, cast_final_argument: int) -> str: + + def rhs_argument(self, index: int, cast_final_argument: bool) -> str: raise NotImplementedError('Argument.rhs_argument') + @dataclass(frozen=True) class TypedArg(Argument): arg_type: str @@ -157,11 +178,11 @@ def is_used_in_constructor(self) -> bool: def is_parsing_arg(self) -> bool: return True - def result_argument(self, index:int, bwi: str) -> str: + def result_argument(self, index: int, bwi: str) -> str: t = self.result_type() it = self.inner_type() mid = '' - if self.arg_type == "Block": + if self.arg_type == 'Block': mid = ' _:Bool,' return f'{t[0].lower()}{t[1:]}({self.arg_type}{index}:{it},{mid} {bwi}:BytesWithIndex)' @@ -185,18 +206,19 @@ def inner_type(self) -> str: def value_type(self) -> str: return self.inner_type() - def lhs_argument(self, index:int, unused: bool) -> str: + def lhs_argument(self, index: int, unused: bool) -> str: if unused: prefix = '_' else: prefix = '' return f'{prefix}{self.arg_type}{index}:{self.value_type()}' - def rhs_argument(self, index:int, cast_final_argument: bool) -> str: + def rhs_argument(self, index: int, cast_final_argument: bool) -> str: if self.arg_type == 'MemArg' and cast_final_argument: return f'getMemArgOffset({self.arg_type}{index})' return f'{self.arg_type}{index}' + @dataclass(frozen=True) class ConstructorArg(Argument): name: str @@ -207,12 +229,14 @@ def is_used_in_constructor(self) -> bool: def is_parsing_arg(self) -> bool: return False - def rhs_argument(self, index:int, cast_final_argument: bool) -> str: + def rhs_argument(self, index: int, cast_final_argument: bool) -> str: return self.name -def constructor_arg(name:str) -> ConstructorArg: + +def constructor_arg(name: str) -> ConstructorArg: return ConstructorArg(name) + @dataclass(frozen=True) class ParseOnlyConstant(Argument): value: bytes @@ -226,15 +250,17 @@ def is_used_in_constructor(self) -> bool: def is_parsing_arg(self) -> bool: return True - def result_argument(self, index:int, bwi: str) -> str: + def result_argument(self, index: int, bwi: str) -> str: return f'{bwi}:BytesWithIndex' def result_type(self) -> str: return 'BytesWithIndexOrError' -def parse_constant(b:bytes): + +def parse_constant(b: bytes) -> ParseOnlyConstant: return ParseOnlyConstant(b) + @dataclass(frozen=True) class RepeatedBytes(Argument): count: int @@ -248,15 +274,17 @@ def is_used_in_constructor(self) -> bool: def is_parsing_arg(self) -> bool: return True - def result_argument(self, index:int, bwi: str) -> str: + def result_argument(self, index: int, bwi: str) -> str: return f'{bwi}:BytesWithIndex' def result_type(self) -> str: return 'BytesWithIndexOrError' -def repeated_bytes(count:int): + +def repeated_bytes(count: int) -> RepeatedBytes: return RepeatedBytes(count) + @dataclass(frozen=True) class RepeatedType(Argument): type_: str @@ -271,15 +299,17 @@ def is_used_in_constructor(self) -> bool: def is_parsing_arg(self) -> bool: return True - def result_argument(self, index:int, bwi: str) -> str: + def result_argument(self, index: int, bwi: str) -> str: return f'{bwi}:BytesWithIndex' def result_type(self) -> str: return 'BytesWithIndexOrError' -def repeated_type(value_type: str, count:int) -> RepeatedType: + +def repeated_type(value_type: str, count: int) -> RepeatedType: return RepeatedType(value_type, count) + @dataclass(frozen=True) class InstrConfig: name: str @@ -287,15 +317,19 @@ class InstrConfig: args: list[Argument] constructor: Constructor - def __init__(self, name: str, prefix: bytes, args: list[str|Argument], constructor: str|Constructor) -> None: + def __init__(self, name: str, prefix: bytes, args: list[str | Argument], constructor: str | Constructor) -> None: object.__setattr__(self, 'name', name) object.__setattr__(self, 'prefix', prefix) object.__setattr__(self, 'args', [arg if isinstance(arg, Argument) else TypedArg(arg) for arg in args]) - object.__setattr__(self, 'constructor', constructor if isinstance(constructor, Constructor) else ConstructorResult(constructor)) + object.__setattr__( + self, 'constructor', constructor if isinstance(constructor, Constructor) else ConstructorResult(constructor) + ) def with_prefix(self, p: bytes) -> 'InstrConfig': - return InstrConfig(self.name, p, self.args, self.constructor) + return InstrConfig(self.name, p, list(self.args), self.constructor) + +# fmt: off INSTRS_CONFIG:list[InstrConfig]=[ # Wasm _control instructions_ are encoded with the follow tags. # Note that `ELSE` instructions must appear in conjunction with `IF` instructions. @@ -791,26 +825,30 @@ def with_prefix(self, p: bytes) -> 'InstrConfig': InstrConfig('F32X4_DEMOTE_F64X2_ZERO', b'\xFD\x5E', [], not_implemented()), InstrConfig('F64X2_PROMOTE_LOW_F32X4', b'\xFD\x5F', [], not_implemented()), ] +# fmt: on + def parse_single_item(parser_prefix: str, item: InstrConfig, output_pieces: list[str]) -> None: current_prefix = parser_prefix if item.prefix: - current_prefix=parser_prefix + 'xbytes' - output_pieces.append(f""" + current_prefix = parser_prefix + 'xbytes' + output_pieces.append( + f""" syntax InstrResult ::= {parser_prefix}(BytesWithIndex) [function, total] | #{parser_prefix}(BytesWithIndexOrError) [function, total] rule {parser_prefix}(BWI:BytesWithIndex) => #{parser_prefix}(parseConstant(BWI, {bytes_to_k(item.prefix)})) rule #{parser_prefix}(BWI:BytesWithIndex) => {current_prefix}(BWI) rule #{parser_prefix}(E:ParseError) => E -""") +""" + ) output_pieces.append(f' syntax InstrResult ::= {current_prefix}(BytesWithIndex) [function, total]\n') # Argument parsing parsing_args = [arg for arg in item.args if arg.is_parsing_arg()] suffix = 1 lhs_function = current_prefix - prev_args = [] + prev_args: list[tuple[int, Argument]] = [] last_parsed = None for i, arg in enumerate(item.args): if not arg.is_parsing_arg(): @@ -819,8 +857,10 @@ def parse_single_item(parser_prefix: str, item: InstrConfig, output_pieces: list rhs_function = f'#{current_prefix}s{suffix}' suffix += 1 - output_pieces.append(f""" syntax InstrResult ::= {rhs_function} - ( """) + output_pieces.append( + f""" syntax InstrResult ::= {rhs_function} + ( """ + ) newline_indented_comma = """ , """ newline_indented_declaration_end = """ @@ -829,21 +869,21 @@ def parse_single_item(parser_prefix: str, item: InstrConfig, output_pieces: list first = True for _, prev in prev_args: if first: - first = False + first = False else: - output_pieces.append(newline_indented_comma) + output_pieces.append(newline_indented_comma) output_pieces.append(prev.value_type()) if last_parsed: - parsed_arg, _ = last_parsed + _, parsed_arg = last_parsed if first: - first = False + first = False else: - output_pieces.append(newline_indented_comma) + output_pieces.append(newline_indented_comma) output_pieces.append(f'{parsed_arg.value_type()}') if first: - first = False + first = False else: - output_pieces.append(newline_indented_comma) + output_pieces.append(newline_indented_comma) output_pieces.append(f'{arg.result_type()}') output_pieces.append(newline_indented_declaration_end) @@ -854,7 +894,7 @@ def parse_single_item(parser_prefix: str, item: InstrConfig, output_pieces: list lhs_args.append(prev.lhs_argument(i, unused=False)) rhs_args.append(prev.rhs_argument(i, False)) if last_parsed: - parsed_arg, parsed_arg_idx = last_parsed + parsed_arg_idx, parsed_arg = last_parsed lhs_args.append(f'{parsed_arg.result_argument(parsed_arg_idx, "BWI")}') rhs_args.append(f'{parsed_arg.rhs_argument(parsed_arg_idx, False)}') else: @@ -876,13 +916,13 @@ def parse_single_item(parser_prefix: str, item: InstrConfig, output_pieces: list lhs_function = rhs_function if arg.is_used_in_constructor(): - last_parsed = (arg, i) + last_parsed = (i, arg) else: last_parsed = None # Result construction result_lhs_args = [] - for prev_arg, prev_index in prev_args: + for prev_index, prev_arg in prev_args: result_lhs_args.append(prev_arg.lhs_argument(prev_index, unused=False)) if last_parsed: result_lhs_args.append(arg.result_argument(i, 'BWI' if item.constructor.needs_bwi() else '_BWI')) @@ -895,11 +935,12 @@ def parse_single_item(parser_prefix: str, item: InstrConfig, output_pieces: list if parsing_args: # Error handling error_lhs_args = [] - for prev_arg, prev_index in prev_args: + for prev_index, prev_arg in prev_args: error_lhs_args.append(prev_arg.lhs_argument(prev_index, unused=True)) error_lhs_args.append('E:ParseError') output_pieces.append(f' rule {lhs_function}({", ".join(error_lhs_args)}) => E\n') + def parse_group(parser_prefix: str, items: list[InstrConfig], output_pieces: list[str]) -> None: assert items if len(items) == 1: @@ -911,15 +952,17 @@ def parse_group(parser_prefix: str, items: list[InstrConfig], output_pieces: lis def parse_rules(parser_prefix: str, items: list[InstrConfig], output_pieces: list[str]) -> None: assert items - output_pieces.append(f""" + output_pieces.append( + f""" syntax InstrResult ::= #{parser_prefix}p1(IntResult) [function, total] | #{parser_prefix}p2(Int, BytesWithIndex) [function, total] rule {parser_prefix}(BWI:BytesWithIndex) => #{parser_prefix}p1(parseByteAsInt(BWI)) rule #{parser_prefix}p1(intResult(I:Int, BWI:BytesWithIndex)) => #{parser_prefix}p2(I, BWI) rule #{parser_prefix}p1(E:ParseError) => E -""") +""" + ) - groups:list[list[InstrConfig]] = [[] for _ in range(256)] + groups: list[list[InstrConfig]] = [[] for _ in range(256)] for instr in items: assert len(instr.prefix) > 0 first_prefix = instr.prefix[0] @@ -929,14 +972,17 @@ def parse_rules(parser_prefix: str, items: list[InstrConfig], output_pieces: lis if not groups[i]: continue output_pieces.append(f' rule #{parser_prefix}p2({i}, BWI:BytesWithIndex) => {parser_prefix}x{i}(BWI)\n') - output_pieces.append(f' rule #{parser_prefix}p2(I:Int, bwi(B:Bytes, Index:Int)) => parseError("#{parser_prefix}p2", ListItem(I) ListItem(Index) ListItem(lengthBytes(B)) ListItem(B)) [owise]\n') + output_pieces.append( + f' rule #{parser_prefix}p2(I:Int, bwi(B:Bytes, Index:Int)) => parseError("#{parser_prefix}p2", ListItem(I) ListItem(Index) ListItem(lengthBytes(B)) ListItem(B)) [owise]\n' + ) output_pieces.append('\n') for i in range(256): if not groups[i]: continue parse_group(f'{parser_prefix}x{i}', groups[i], output_pieces) -def main(): + +def main() -> None: output_pieces = [ f"""This was generated by `{os.path.basename(__file__)}`. Do not edit this file directly. @@ -974,5 +1020,6 @@ def main(): output_pieces.append('```\n') print(''.join(output_pieces)) + if __name__ == '__main__': - main() \ No newline at end of file + main() From 026cd6d1f4b921c709ae242f5268370fd358fcfe Mon Sep 17 00:00:00 2001 From: Virgil Date: Wed, 22 Jan 2025 18:14:12 +0200 Subject: [PATCH 3/7] Cleanup --- .../kdist/wasm-semantics/binary-parser.md | 2 + .../binary-parsing/binary-defn-convert.md | 123 ++++++++++++++++++ .../wasm-semantics/binary-parsing/block.md | 8 -- .../wasm-semantics/binary-parsing/defn.md | 2 +- .../wasm-semantics/binary-parsing/float.md | 2 +- .../binary-parsing/func-section.md | 2 +- .../wasm-semantics/binary-parsing/func.md | 2 +- .../wasm-semantics/binary-parsing/helpers.md | 108 --------------- .../kdist/wasm-semantics/binary-parsing/if.md | 4 +- .../binary-parsing/instr-list.md | 2 +- .../wasm-semantics/binary-parsing/locals.md | 2 +- .../wasm-semantics/binary-parsing/module.md | 3 +- 12 files changed, 134 insertions(+), 126 deletions(-) create mode 100644 pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/binary-defn-convert.md diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parser.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parser.md index 974d69d52..1c6fed6db 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parser.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parser.md @@ -6,6 +6,7 @@ This file defines a Wasm binary parser based on this ```k requires "binary-parsing/base.md" +requires "binary-parsing/binary-defn-convert.md" requires "binary-parsing/block.md" requires "binary-parsing/bytes.md" requires "binary-parsing/code.md" @@ -48,6 +49,7 @@ endmodule module BINARY-PARSER [private] imports BINARY-PARSER-MODULE-SYNTAX + imports BINARY-PARSER-BINARY-DEFN-CONVERT imports BINARY-PARSER-BLOCK imports BINARY-PARSER-BYTES imports BINARY-PARSER-CODE diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/binary-defn-convert.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/binary-defn-convert.md new file mode 100644 index 000000000..757b8fd09 --- /dev/null +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/binary-defn-convert.md @@ -0,0 +1,123 @@ +Convert BinaryDefn to Defn. + +```k +module BINARY-PARSER-BINARY-DEFN-CONVERT-SYNTAX + imports BINARY-PARSER-BASE-SYNTAX + imports BINARY-PARSER-CODE-SYNTAX + imports BINARY-PARSER-DEFN-SYNTAX + imports BINARY-PARSER-FUNC-SECTION-ENTRY-SYNTAX + imports WASM-DATA-COMMON + + syntax DefnsOrError ::= buildFunctionDefns(Defns, BinaryDefnFunctionTypes, BinaryDefnFunctionBodies) [function, total] + +endmodule + +module BINARY-PARSER-BINARY-DEFN-CONVERT [private] + imports BINARY-PARSER-BINARY-DEFN-CONVERT-SYNTAX + imports BINARY-PARSER-BLOCK-SYNTAX + imports BINARY-PARSER-IF-SYNTAX + imports BINARY-PARSER-LOOP-SYNTAX + imports BINARY-PARSER-INSTR-LIST-SYNTAX + imports WASM + + syntax DefnsOrError ::= #buildFunctionDefns1 + ( DefnOrError + , Defns + , BinaryDefnFunctionTypes + , BinaryDefnFunctionBodies + ) [function, total] + | #buildFunctionDefns2(Defn, DefnsOrError) [function, total] + rule buildFunctionDefns(_:Defns, .BinaryDefnFunctionTypes, .BinaryDefnFunctionBodies) + => .Defns + rule buildFunctionDefns + ( Ds:Defns + , FT:BinaryDefnFunctionType FTs:BinaryDefnFunctionTypes + , FB:BinaryDefnFunctionBody FBs:BinaryDefnFunctionBodies + ) + => #buildFunctionDefns1(buildFunctionDefn(Ds, FT, FB), Ds, FTs, FBs) + rule buildFunctionDefns(Ds:Defns, FTs:BinaryDefnFunctionTypes, FBs:BinaryDefnFunctionBodies) + => parseError("buildFunctionDefns", ListItem(Ds) ListItem(FTs) ListItem(FBs)) + [owise] + rule #buildFunctionDefns1 + ( D:Defn + , Ds:Defns + , FTs:BinaryDefnFunctionTypes + , FBs:BinaryDefnFunctionBodies + ) + => #buildFunctionDefns2(D, buildFunctionDefns(Ds, FTs, FBs)) + rule #buildFunctionDefns1 + ( E:ParseError + , _:Defns + , _:BinaryDefnFunctionTypes + , _:BinaryDefnFunctionBodies + ) + => E + rule #buildFunctionDefns2(D:Defn, Ds:Defns) => D Ds + rule #buildFunctionDefns2(_:Defn, E:ParseError) => E + + syntax DefnOrError ::= buildFunctionDefn + ( Defns + , BinaryDefnFunctionType + , BinaryDefnFunctionBody + ) [function, total] + | #buildFunctionDefn1 + ( BinaryDefnFunctionType + , locals: VecType + , InstrsOrError + ) [function, total] + + rule buildFunctionDefn + ( Ds:Defns + , FT:BinaryDefnFunctionType + , binaryDefnFunctionBody(Locals:VecType, Is:BinaryInstrs) + ) + => #buildFunctionDefn1(FT, Locals, binaryInstrsToInstrs(Ds, Is)) + rule #buildFunctionDefn1(binaryDefnFunctionType(TypeIndex:Int), Locals:VecType, Is:Instrs) + => #func(TypeIndex, Locals, Is, #meta(, .Map)) + rule #buildFunctionDefn1(_:BinaryDefnFunctionType, _Locals:VecType, E:ParseError) => E + + syntax InstrsOrError ::= binaryInstrsToInstrs(Defns, BinaryInstrs) [function, total] + | #binaryInstrsToInstrs(InstrOrError, InstrsOrError) [function, total] + rule binaryInstrsToInstrs(_:Defns, .BinaryInstrs) => .Instrs + rule binaryInstrsToInstrs(Ds:Defns, I:BinaryInstr Is:BinaryInstrs) + => #binaryInstrsToInstrs(binaryInstrToInstr(Ds, I), binaryInstrsToInstrs(Ds, Is)) + rule #binaryInstrsToInstrs(I:Instr, Is:Instrs) => I Is + rule #binaryInstrsToInstrs(E:ParseError, _:InstrsOrError) => E + rule #binaryInstrsToInstrs(_:Instr, E:ParseError) => E + + syntax InstrOrError ::= binaryInstrToInstr(Defns, BinaryInstr) [function, total] + rule binaryInstrToInstr(_Ds:Defns, I:Instr) => I + rule binaryInstrToInstr(Ds:Defns, B:Block) + => resolvedBlockToInstr(resolveBlock(Ds, B)) + rule binaryInstrToInstr(Ds:Defns, loop(B:Block)) + => resolvedBlockToLoop(resolveBlock(Ds, B)) + rule binaryInstrToInstr(Ds:Defns, if(B:Block, Is:BinaryInstrs)) + => resolvedBlockInstrsToIf(resolveBlock(Ds, B), binaryInstrsToInstrs(Ds, Is)) + + syntax VecTypeOrError ::= VecType | ParseError + + syntax ResolvedBlockOrError ::= resolvedBlock(VecType, Instrs) | ParseError + + syntax ResolvedBlockOrError ::= resolveBlock(Defns, Block) [function, total] + | #resolveBlock(VecTypeOrError, InstrsOrError) [function, total] + rule resolveBlock(Ds:Defns, block(T:BlockType, Is:BinaryInstrs)) + => #resolveBlock(blockTypeToVecType(T, Ds), binaryInstrsToInstrs(Ds, Is)) + rule #resolveBlock(T:VecType, Is:Instrs) => resolvedBlock(T, Is) + rule #resolveBlock(E:ParseError, _:InstrsOrError) => E + rule #resolveBlock(_:VecType, E:ParseError) => E + + syntax InstrOrError ::= resolvedBlockToInstr(ResolvedBlockOrError) [function, total] + rule resolvedBlockToInstr(resolvedBlock(T:VecType, Is:Instrs)) => #block(T, Is, .Int) + rule resolvedBlockToInstr(E:ParseError) => E + + syntax InstrOrError ::= resolvedBlockToLoop(ResolvedBlockOrError) [function, total] + rule resolvedBlockToLoop(resolvedBlock(T:VecType, Is:Instrs)) => #loop(T, Is, .Int) + rule resolvedBlockToLoop(E:ParseError) => E + + syntax InstrOrError ::= resolvedBlockInstrsToIf(ResolvedBlockOrError, InstrsOrError) [function, total] + rule resolvedBlockInstrsToIf(resolvedBlock(T:VecType, Then:Instrs), Else:Instrs) => #if(T, Then, Else, .Int) + rule resolvedBlockInstrsToIf(E:ParseError, _:InstrsOrError) => E + rule resolvedBlockInstrsToIf(_:ResolvedBlockOrError, E:ParseError) => E + [owise] +endmodule +``` diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/block.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/block.md index 616191e7b..1528942df 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/block.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/block.md @@ -61,14 +61,6 @@ module BINARY-PARSER-BLOCK [private] rule blockTypeToVecType(epsilon, _:Defns) => [ .ValTypes ] rule blockTypeToVecType(ValType, _:Defns) => [ ValType .ValTypes ] rule blockTypeToVecType(Index:Int, Ds::Defns) => parseError("blockTypeToVecType: unimplemented", ListItem(Index) ListItem(Ds)) - // rule blockTypeToVecType(Index:Int, .Defns) => parseError("blockTypeToVecType: not found", ListItem(Index)) - // rule blockTypeToVecType(0, #type(FT:FuncType, _:OptionalId) Ds:Defns) => [FT] - // rule blockTypeToVecType(0, D:Defn Ds:Defns) => parseError("blockTypeToVecType", ListItem(D) ListItem(Ds)) - // [owise] - // rule blockTypeToVecType(Index:Int, D:Defn Ds:Defns) => blockTypeToVecType(Index -Int 1, Ds) - // requires Index >Int 0 - // rule blockTypeToVecType(Index:Int, Ds:Defns) => parseError("blockTypeToVecType", ListItem(I) ListItem(Ds)) - // requires Index #call_indirect(TableIdx, (type TypeIdx)) rule buildBrTable(Is:Ints, I:Int) => #br_table(#appendInts(Is, I)) - syntax DefnsOrError ::= #buildFunctionDefns1 - ( DefnOrError - , Defns - , BinaryDefnFunctionTypes - , BinaryDefnFunctionBodies - ) [function, total] - | #buildFunctionDefns2(Defn, DefnsOrError) [function, total] - rule buildFunctionDefns(_:Defns, .BinaryDefnFunctionTypes, .BinaryDefnFunctionBodies) - => .Defns - rule buildFunctionDefns - ( Ds:Defns - , FT:BinaryDefnFunctionType FTs:BinaryDefnFunctionTypes - , FB:BinaryDefnFunctionBody FBs:BinaryDefnFunctionBodies - ) - => #buildFunctionDefns1(buildFunctionDefn(Ds, FT, FB), Ds, FTs, FBs) - rule buildFunctionDefns(Ds:Defns, FTs:BinaryDefnFunctionTypes, FBs:BinaryDefnFunctionBodies) - => parseError("buildFunctionDefns", ListItem(Ds) ListItem(FTs) ListItem(FBs)) - [owise] - rule #buildFunctionDefns1 - ( D:Defn - , Ds:Defns - , FTs:BinaryDefnFunctionTypes - , FBs:BinaryDefnFunctionBodies - ) - => #buildFunctionDefns2(D, buildFunctionDefns(Ds, FTs, FBs)) - rule #buildFunctionDefns1 - ( E:ParseError - , _:Defns - , _:BinaryDefnFunctionTypes - , _:BinaryDefnFunctionBodies - ) - => E - rule #buildFunctionDefns2(D:Defn, Ds:Defns) => D Ds - rule #buildFunctionDefns2(_:Defn, E:ParseError) => E - - syntax DefnOrError ::= buildFunctionDefn - ( Defns - , BinaryDefnFunctionType - , BinaryDefnFunctionBody - ) [function, total] - | #buildFunctionDefn1 - ( BinaryDefnFunctionType - , locals: VecType - , InstrsOrError - ) [function, total] - - rule buildFunctionDefn - ( Ds:Defns - , FT:BinaryDefnFunctionType - , binaryDefnFunctionBody(Locals:VecType, Is:BinaryInstrs) - ) - => #buildFunctionDefn1(FT, Locals, binaryInstrsToInstrs(Ds, Is)) - rule #buildFunctionDefn1(binaryDefnFunctionType(TypeIndex:Int), Locals:VecType, Is:Instrs) - => #func(TypeIndex, Locals, Is, #meta(, .Map)) - rule #buildFunctionDefn1(_:BinaryDefnFunctionType, _Locals:VecType, E:ParseError) => E - - syntax InstrsOrError ::= binaryInstrsToInstrs(Defns, BinaryInstrs) [function, total] - | #binaryInstrsToInstrs(InstrOrError, InstrsOrError) [function, total] - rule binaryInstrsToInstrs(_:Defns, .BinaryInstrs) => .Instrs - rule binaryInstrsToInstrs(Ds:Defns, I:BinaryInstr Is:BinaryInstrs) - => #binaryInstrsToInstrs(binaryInstrToInstr(Ds, I), binaryInstrsToInstrs(Ds, Is)) - rule #binaryInstrsToInstrs(I:Instr, Is:Instrs) => I Is - rule #binaryInstrsToInstrs(E:ParseError, _:InstrsOrError) => E - rule #binaryInstrsToInstrs(_:Instr, E:ParseError) => E - - syntax InstrOrError ::= binaryInstrToInstr(Defns, BinaryInstr) [function, total] - rule binaryInstrToInstr(_Ds:Defns, I:Instr) => I - rule binaryInstrToInstr(Ds:Defns, B:Block) - => resolvedBlockToInstr(resolveBlock(Ds, B)) - rule binaryInstrToInstr(Ds:Defns, loop(B:Block)) - => resolvedBlockToLoop(resolveBlock(Ds, B)) - rule binaryInstrToInstr(Ds:Defns, if(B:Block, Is:BinaryInstrs)) - => resolvedBlockInstrsToIf(resolveBlock(Ds, B), binaryInstrsToInstrs(Ds, Is)) - - syntax VecTypeOrError ::= VecType | ParseError - - syntax ResolvedBlockOrError ::= resolvedBlock(VecType, Instrs) | ParseError - - syntax ResolvedBlockOrError ::= resolveBlock(Defns, Block) [function, total] - | #resolveBlock(VecTypeOrError, InstrsOrError) [function, total] - rule resolveBlock(Ds:Defns, block(T:BlockType, Is:BinaryInstrs)) - => #resolveBlock(blockTypeToVecType(T, Ds), binaryInstrsToInstrs(Ds, Is)) - rule #resolveBlock(T:VecType, Is:Instrs) => resolvedBlock(T, Is) - rule #resolveBlock(E:ParseError, _:InstrsOrError) => E - rule #resolveBlock(_:VecType, E:ParseError) => E - - syntax InstrOrError ::= resolvedBlockToInstr(ResolvedBlockOrError) [function, total] - rule resolvedBlockToInstr(resolvedBlock(T:VecType, Is:Instrs)) => #block(T, Is, .Int) - rule resolvedBlockToInstr(E:ParseError) => E - - syntax InstrOrError ::= resolvedBlockToLoop(ResolvedBlockOrError) [function, total] - rule resolvedBlockToLoop(resolvedBlock(T:VecType, Is:Instrs)) => #loop(T, Is, .Int) - rule resolvedBlockToLoop(E:ParseError) => E - - syntax InstrOrError ::= resolvedBlockInstrsToIf(ResolvedBlockOrError, InstrsOrError) [function, total] - rule resolvedBlockInstrsToIf(resolvedBlock(T:VecType, Then:Instrs), Else:Instrs) => #if(T, Then, Else, .Int) - rule resolvedBlockInstrsToIf(E:ParseError, _:InstrsOrError) => E - rule resolvedBlockInstrsToIf(_:ResolvedBlockOrError, E:ParseError) => E - [owise] endmodule ``` diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/if.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/if.md index 271e376e8..aae65f9be 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/if.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/if.md @@ -1,5 +1,5 @@ -Parsing [loops](https://webassembly.github.io/spec/core/binary/instructions.html#control-instructions), -i.e., a blocktype + instr list. +Parsing [if](https://webassembly.github.io/spec/core/binary/instructions.html#control-instructions) +instructions. ```k diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/instr-list.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/instr-list.md index 71c8622a2..203b94bb2 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/instr-list.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/instr-list.md @@ -1,4 +1,4 @@ -// Parsing an [expr/instr list](https://webassembly.github.io/spec/core/binary/instructions.html#binary-expr). +Parsing an [expr/instr list](https://webassembly.github.io/spec/core/binary/instructions.html#binary-expr). ```k module BINARY-PARSER-INSTR-LIST-SYNTAX diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/locals.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/locals.md index 21fe52e49..55b8650a9 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/locals.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/locals.md @@ -1,4 +1,4 @@ -// Parsing a [locals object](https://webassembly.github.io/spec/core/binary/modules.html#binary-local). +Parsing a [locals object](https://webassembly.github.io/spec/core/binary/modules.html#binary-local). ```k module BINARY-PARSER-LOCALS-SYNTAX diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/module.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/module.md index 5cb0ab07d..437061041 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/module.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/module.md @@ -18,10 +18,10 @@ module BINARY-PARSER-MODULE-TEST-SYNTAX endmodule module BINARY-PARSER-MODULE [private] + imports BINARY-PARSER-BINARY-DEFN-CONVERT-SYNTAX imports BINARY-PARSER-CODE-SYNTAX imports BINARY-PARSER-CONSTANT-SYNTAX imports BINARY-PARSER-FUNC-SECTION-ENTRY-SYNTAX - imports BINARY-PARSER-HELPERS-SYNTAX imports BINARY-PARSER-MODULE-SYNTAX imports BINARY-PARSER-MODULE-TEST-SYNTAX imports BINARY-PARSER-SECTION-SYNTAX @@ -69,7 +69,6 @@ module BINARY-PARSER-MODULE [private] syntax ModuleOrError ::= addSectionsToModule(Sections, ModuleAndFunctions) [function, total] syntax ModuleOrError ::= #addSectionsToModule(Sections, ModuleAndFunctions) [function, total] - // TODO: Combine the function types with the function definitions and add them to the module. rule addSectionsToModule ( .Sections , moduleAndFunctions From c036994ab99614a54033f53359f7a68cae148e80 Mon Sep 17 00:00:00 2001 From: Virgil Date: Wed, 22 Jan 2025 18:50:09 +0200 Subject: [PATCH 4/7] Cleanup --- .../src/pykwasm/scripts/binary-parser-gen.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/pykwasm/src/pykwasm/scripts/binary-parser-gen.py b/pykwasm/src/pykwasm/scripts/binary-parser-gen.py index 11928c033..71b24832c 100644 --- a/pykwasm/src/pykwasm/scripts/binary-parser-gen.py +++ b/pykwasm/src/pykwasm/scripts/binary-parser-gen.py @@ -331,11 +331,12 @@ def with_prefix(self, p: bytes) -> 'InstrConfig': # fmt: off INSTRS_CONFIG:list[InstrConfig]=[ - # Wasm _control instructions_ are encoded with the follow tags. - # Note that `ELSE` instructions must appear in conjunction with `IF` instructions. - # The tuple structure is: # ('INSTRUCTION_NAME', b'instruction-prefix', ['Argument1Type', 'Argument2Type', ...], '#ConstructorName') + + # Wasm _control instructions_. + # Note that `ELSE` instructions must appear in conjunction with `IF` instructions. + InstrConfig('UNREACHABLE', b'\x00', [], 'unreachable'), InstrConfig('NOP', b'\x01', [], 'nop'), InstrConfig('BLOCK', b'\x02', ['Block', ], identity()), # #block @@ -349,7 +350,7 @@ def with_prefix(self, p: bytes) -> 'InstrConfig': InstrConfig('CALL', b'\x10', ['UnsignedInt', ], '#call'), InstrConfig('CALL_INDIRECT', b'\x11', ['UnsignedInt', 'UnsignedInt', ], 'buildCallIndirect'), # #call_indirect - # _Reference instructions_ are encoded with the following tags: + # _Reference instructions_:: InstrConfig('REF_NULL', b'\xD0', ['HeapType', ], symbol('aRef.null')), InstrConfig('REF_ISNULL', b'\xD1', [], '#ref.is_null'), @@ -359,7 +360,7 @@ def with_prefix(self, p: bytes) -> 'InstrConfig': InstrConfig('SELECT', b'\x1B', [], 'select'), InstrConfig('SELECT_GENERIC', b'\x1C', ['ValTypes', ], not_implemented()), - # _Variable instructions_ are encoded with the following tags: + # _Variable instructions_: InstrConfig('LOCAL_GET', b'\x20', ['UnsignedInt', ], '#local.get'), InstrConfig('LOCAL_SET', b'\x21', ['UnsignedInt', ], '#local.set'), @@ -367,7 +368,7 @@ def with_prefix(self, p: bytes) -> 'InstrConfig': InstrConfig('GLOBAL_GET', b'\x23', ['UnsignedInt', ], '#global.get'), InstrConfig('GLOBAL_SET', b'\x24', ['UnsignedInt', ], '#global.set'), - # _Table instructions_ are encoded with the following tags: + # _Table instructions_: InstrConfig('TABLE_GET', b'\x25', ['UnsignedInt', ], '#table.get'), InstrConfig('TABLE_SET', b'\x26', ['UnsignedInt', ], '#table.set'), @@ -378,7 +379,7 @@ def with_prefix(self, p: bytes) -> 'InstrConfig': InstrConfig('TABLE_SIZE', b'\xFC\x10', ['UnsignedInt', ], '#table.size'), InstrConfig('TABLE_FILL', b'\xFC\x11', ['UnsignedInt', ], '#table.fill'), - # _Memory instructions_ are encoded with the following tags: + # _Memory instructions_:: InstrConfig('I32_LOAD', b'\x28', [constructor_arg('i32'), constructor_arg('load'), 'MemArg', ], '#load'), InstrConfig('I64_LOAD', b'\x29', [constructor_arg('i64'), constructor_arg('load'), 'MemArg', ], '#load'), @@ -410,7 +411,7 @@ def with_prefix(self, p: bytes) -> 'InstrConfig': InstrConfig('MEM_COPY', b'\xFC\x0A', [parse_constant(b'\x00'), parse_constant(b'\x00'), ], 'memory.copy'), InstrConfig('MEM_FILL', b'\xFC\x0B', [parse_constant(b'\x00'), ], 'memory.fill'), - # _Numeric instructions_ have the following tags: + # _Numeric instructions_: InstrConfig('I32_CONST', b'\x41', [constructor_arg('i32'), 'SignedInt', ], symbol('aIConst')), InstrConfig('I64_CONST', b'\x42', [constructor_arg('i64'), 'SignedInt', ], symbol('aIConst')), @@ -568,7 +569,7 @@ def with_prefix(self, p: bytes) -> 'InstrConfig': InstrConfig('I64_TRUNC_SAT_F64_S', b'\xFC\x06', [], not_implemented()), InstrConfig('I64_TRUNC_SAT_F64_U', b'\xFC\x07', [], not_implemented()), - # _Vector instructions_ have the following tags: + # _Vector instructions_: InstrConfig('V128_LOAD', b'\xFD\x00', ['MemArg', ], not_implemented()), InstrConfig('V128_LOAD_8X8_S', b'\xFD\x01', ['MemArg', ], not_implemented()), From f7ae4cc8d114d738bb699a3664c01fb47b258b01 Mon Sep 17 00:00:00 2001 From: Virgil <25692529+virgil-serbanuta@users.noreply.github.com> Date: Mon, 27 Jan 2025 14:16:45 +0200 Subject: [PATCH 5/7] Update pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/int.md Co-authored-by: Stephen Skeirik --- pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/int.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/int.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/int.md index 022586b1e..43a13a628 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/int.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/int.md @@ -24,7 +24,7 @@ module BINARY-PARSER-INT [private] rule bit8IsSet(I:Int) => I &Int 128 =/=Int 0 syntax Int ::= clearBit8(Int) [function, total] - rule clearBit8(I:Int) => I -Int 128 requires 128 <=Int 128 + rule clearBit8(I:Int) => I -Int 128 requires 128 <=Int I rule clearBit8(I:Int) => I requires I Date: Mon, 27 Jan 2025 14:20:41 +0200 Subject: [PATCH 6/7] Fix review comments --- .../wasm-semantics/binary-parsing/func.md | 24 ------------------- .../wasm-semantics/binary-parsing/int.md | 4 ---- 2 files changed, 28 deletions(-) delete mode 100644 pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/func.md diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/func.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/func.md deleted file mode 100644 index 9e1e0ecc9..000000000 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/func.md +++ /dev/null @@ -1,24 +0,0 @@ -Parsing a [func type id](https://webassembly.github.io/spec/core/binary/modules.html#function-section). - -```k -module BINARY-PARSER-FUNC-SYNTAX - imports BINARY-PARSER-BASE-SYNTAX - - syntax DefnResult ::= parseDefnFunc(BytesWithIndex) [function, total] - -endmodule - -module BINARY-PARSER-FUNC [private] - imports BINARY-PARSER-DEFN-SYNTAX - imports BINARY-PARSER-FUNC-SYNTAX - imports BINARY-PARSER-INT-SYNTAX - - syntax DefnResult ::= #parseDefnFunc(IntResult) [function, total] - - rule parseDefnFunc(BWI:BytesWithIndex) => #parseDefnFunc(parseLeb128UInt(BWI)) - rule #parseDefnFunc(intResult(TypeIndex:Int, BWI:BytesWithIndex)) - => defnResult(binaryDefnFunctionType(TypeIndex), BWI) - rule #parseDefnFunc(E:ParseError) => E - -endmodule -``` diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/int.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/int.md index 43a13a628..793427cbd 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/int.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/int.md @@ -54,10 +54,6 @@ module BINARY-PARSER-INT [private] => intResult(buildLeb128UInt(L), BWI) rule #parseLeb128UInt(E:ParseError) => E - syntax Int ::= buildLeb128UInt(Ints) [function, total] - rule buildLeb128UInt(.Ints) => 0 - rule buildLeb128UInt(Value:Int L:Ints) => Value +Int 128 *Int buildLeb128UInt(L) - syntax IntResult ::= #parseLeb128SInt(IntsResult) [function, total] rule parseLeb128SInt(BWI:BytesWithIndex) => #parseLeb128SInt(parseLeb128IntChunks(BWI)) From d9a126dc3e77dce133463394c8da74884a0cf4c8 Mon Sep 17 00:00:00 2001 From: Virgil Date: Mon, 27 Jan 2025 16:01:23 +0200 Subject: [PATCH 7/7] Fix mem instruction parsing --- .../kdist/wasm-semantics/binary-parsing/instr.md | 14 ++++++++++++-- pykwasm/src/pykwasm/scripts/binary-parser-gen.py | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/instr.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/instr.md index c52b0f71c..ce6359772 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/instr.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/binary-parsing/instr.md @@ -509,9 +509,19 @@ module BINARY-PARSER-INSTR rule #parseInstrx62s1(memArgResult(MemArg2:MemArg, BWI:BytesWithIndex)) => instrResult(#store(i64, store32, getMemArgOffset(MemArg2)), BWI) rule #parseInstrx62s1(E:ParseError) => E syntax InstrResult ::= parseInstrx63(BytesWithIndex) [function, total] - rule parseInstrx63(BWI:BytesWithIndex) => instrResult(memory.size, BWI) + syntax InstrResult ::= #parseInstrx63s1 + ( BytesWithIndexOrError + ) [function, total] + rule parseInstrx63(BWI) => #parseInstrx63s1(parseConstant(BWI, b"\x00")) + rule #parseInstrx63s1(BWI:BytesWithIndex) => instrResult(memory.size, BWI) + rule #parseInstrx63s1(E:ParseError) => E syntax InstrResult ::= parseInstrx64(BytesWithIndex) [function, total] - rule parseInstrx64(BWI:BytesWithIndex) => instrResult(memory.grow, BWI) + syntax InstrResult ::= #parseInstrx64s1 + ( BytesWithIndexOrError + ) [function, total] + rule parseInstrx64(BWI) => #parseInstrx64s1(parseConstant(BWI, b"\x00")) + rule #parseInstrx64s1(BWI:BytesWithIndex) => instrResult(memory.grow, BWI) + rule #parseInstrx64s1(E:ParseError) => E syntax InstrResult ::= parseInstrx65(BytesWithIndex) [function, total] syntax InstrResult ::= #parseInstrx65s1 ( IntResult diff --git a/pykwasm/src/pykwasm/scripts/binary-parser-gen.py b/pykwasm/src/pykwasm/scripts/binary-parser-gen.py index 71b24832c..7e5fc92c5 100644 --- a/pykwasm/src/pykwasm/scripts/binary-parser-gen.py +++ b/pykwasm/src/pykwasm/scripts/binary-parser-gen.py @@ -404,8 +404,8 @@ def with_prefix(self, p: bytes) -> 'InstrConfig': InstrConfig('I64_STORE_8', b'\x3C', [constructor_arg('i64'), constructor_arg('store8'), 'MemArg', ], '#store'), InstrConfig('I64_STORE_16', b'\x3D', [constructor_arg('i64'), constructor_arg('store16'), 'MemArg', ], '#store'), InstrConfig('I64_STORE_32', b'\x3E', [constructor_arg('i64'), constructor_arg('store32'), 'MemArg', ], '#store'), - InstrConfig('MEM_SIZE', b'\x3F', [], 'memory.size'), - InstrConfig('MEM_GROW', b'\x40', [], 'memory.grow'), + InstrConfig('MEM_SIZE', b'\x3F', [parse_constant(b'\x00')], 'memory.size'), + InstrConfig('MEM_GROW', b'\x40', [parse_constant(b'\x00')], 'memory.grow'), InstrConfig('MEM_INIT', b'\xFC\x08', ['UnsignedInt', parse_constant(b'\x00'), ], not_implemented()), InstrConfig('DATA_DROP', b'\xFC\x09', ['UnsignedInt', ], not_implemented()), InstrConfig('MEM_COPY', b'\xFC\x0A', [parse_constant(b'\x00'), parse_constant(b'\x00'), ], 'memory.copy'),