From b44683eb40df4920e51d927088823d29d44faee6 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 25 Jun 2023 15:46:25 +0100 Subject: Add WASM code gen for push-int instruction --- .../backends/wasm/WasmCodeGenPushIntTests.java | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenPushIntTests.java (limited to 'src/test/java') diff --git a/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenPushIntTests.java b/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenPushIntTests.java new file mode 100644 index 00000000..e461f5f6 --- /dev/null +++ b/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenPushIntTests.java @@ -0,0 +1,27 @@ +package org.shedlang.compiler.backends.wasm; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.shedlang.compiler.stackir.instructions.Instructions; +import org.shedlang.compiler.testing.snapshots.SnapshotResolver; +import org.shedlang.compiler.testing.snapshots.Snapshotter; + +import java.io.IOException; + +import static org.shedlang.compiler.backends.wasm.structure.WasmObjdump.objdump; + +@ExtendWith({SnapshotResolver.class}) +public class WasmCodeGenPushIntTests { + // TODO: handle larger ints + + @Test + public void pushIntIsCompiledToOperandInStack(Snapshotter snapshotter) throws IOException, InterruptedException { + var instruction = Instructions.pushInt(42); + var context = WasmCodeGenContext.EMPTY; + + var result = WasmCodeGen.generateInstruction(instruction, context); + + var module = result.toFunction().toModule(); + snapshotter.assertSnapshot(objdump(module)); + } +} -- cgit v1.2.3