aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-11-20 22:11:25 +0000
committerMichael Williamson <mike@zwobble.org>2023-11-20 22:11:25 +0000
commitd90a1e3828856f4c790b3527299e17e42cf13552 (patch)
tree6bced215d979ad995d6e3bebcd680538197c8547 /src/test/java
parent1748d528ba9886c663ca1d24c2eac848e89161c5 (diff)
Extract WasmBackend.generateNativeRuntime()
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/shedlang/compiler/backends/wasm/WasmPatioCodeGenTests.java19
1 files changed, 5 insertions, 14 deletions
diff --git a/src/test/java/org/shedlang/compiler/backends/wasm/WasmPatioCodeGenTests.java b/src/test/java/org/shedlang/compiler/backends/wasm/WasmPatioCodeGenTests.java
index 798f773f..b3c0960f 100644
--- a/src/test/java/org/shedlang/compiler/backends/wasm/WasmPatioCodeGenTests.java
+++ b/src/test/java/org/shedlang/compiler/backends/wasm/WasmPatioCodeGenTests.java
@@ -3,9 +3,10 @@ package org.shedlang.compiler.backends.wasm;
import org.shedlang.compiler.backends.wasm.structure.WasmBinaryFormat;
import org.shedlang.compiler.backends.wasm.structure.ast.instructions.WasmCall;
import org.shedlang.compiler.backends.wasm.structure.ast.instructions.WasmExpression;
-import org.shedlang.compiler.backends.wasm.structure.ast.instructions.WasmLocalGet;
-import org.shedlang.compiler.backends.wasm.structure.ast.instructions.WasmMemoryGrow;
-import org.shedlang.compiler.backends.wasm.structure.ast.modules.*;
+import org.shedlang.compiler.backends.wasm.structure.ast.modules.WasmFuncName;
+import org.shedlang.compiler.backends.wasm.structure.ast.modules.WasmFunction;
+import org.shedlang.compiler.backends.wasm.structure.ast.modules.WasmImport;
+import org.shedlang.compiler.backends.wasm.structure.ast.modules.WasmImportDescriptor;
import org.shedlang.compiler.backends.wasm.structure.ast.types.WasmFuncType;
import org.shedlang.compiler.backends.wasm.structure.ast.types.WasmValueType;
import org.shedlang.compiler.patio.PatioExampleTests;
@@ -24,17 +25,7 @@ public class WasmPatioCodeGenTests extends PatioExampleTests {
protected ExecutionResult run(PatioCompilationUnit patio) throws IOException, InterruptedException {
var wasmModule = WasmPatioCodeGen.generateCompilationUnit(patio);
- // TODO: put these in separate module, remove duplication
- wasmModule = wasmModule.addFunction(new WasmFunction(
- "wasm_memory_grow",
- List.of(new WasmLocal("pages", WasmValueType.I32)),
- List.of(),
- List.of(WasmValueType.I32),
- new WasmExpression(List.of(
- new WasmLocalGet(new WasmLocalIndex(0)),
- new WasmMemoryGrow()
- ))
- ));
+ wasmModule = WasmBackend.generateNativeRuntime(wasmModule);
wasmModule = wasmModule.addFunction(new WasmFunction(
"_start",