From d90a1e3828856f4c790b3527299e17e42cf13552 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Mon, 20 Nov 2023 22:11:25 +0000 Subject: Extract WasmBackend.generateNativeRuntime() --- .../compiler/backends/wasm/WasmPatioCodeGenTests.java | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'src/test/java') 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", -- cgit v1.2.3