diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-07-14 22:10:03 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-07-14 22:10:14 +0100 |
| commit | 3dfd0c6534584206d2f0bb6a88b56f7201d18197 (patch) | |
| tree | e311694d0796f56ff88265f263eca9a6af405bea /src/test/java | |
| parent | 2e9b821350221fc2defa89e9c4ecefc1c273855b (diff) | |
Handle params when defining functions in WASM backend
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenDefineFunctionTests.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenDefineFunctionTests.java b/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenDefineFunctionTests.java index 87a6dee6..d32f716a 100644 --- a/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenDefineFunctionTests.java +++ b/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenDefineFunctionTests.java @@ -58,4 +58,31 @@ public class WasmCodeGenDefineFunctionTests { snapshotter.assertSnapshot(objdumpContext(result)); } + + @Test + public void positionalAndNamedParamsAreDefined(Snapshotter snapshotter) throws IOException, InterruptedException { + var instruction = new DefineFunctionInstruction( + "f", + List.of(Instructions.param("param1"), Instructions.param("param2")), + List.of(Instructions.param("paramA"), Instructions.param("paramB")), + FreeVariables.of("a", "b"), + List.of( + Instructions.localLoad("a"), + Instructions.localLoad("param1"), + Instructions.intAdd(), + Instructions.localLoad("paramA"), + Instructions.intAdd(), + Instructions.return_() + ), + Sources.NULL + ); + var context = WasmCodeGenContext.EMPTY + .addShedLocal("b").context() + .addShedLocal("c").context() + .addShedLocal("a").context(); + + var result = WasmCodeGen.generateInstruction(instruction, context); + + snapshotter.assertSnapshot(objdumpContext(result)); + } } |
