From 2d6ca67c0a0ca4e72ab409e5503a112f30e1f0a7 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 20 Jul 2023 15:24:44 +0100 Subject: Add int-add instruction --- .../java/org/shedlang/compiler/patio/PatioSerializerTests.java | 9 +++++++++ .../java/org/shedlang/compiler/patio/instructions/Patio.java | 9 +++++++++ 2 files changed, 18 insertions(+) (limited to 'src/test/java') diff --git a/src/test/java/org/shedlang/compiler/patio/PatioSerializerTests.java b/src/test/java/org/shedlang/compiler/patio/PatioSerializerTests.java index b354d534..73d4c613 100644 --- a/src/test/java/org/shedlang/compiler/patio/PatioSerializerTests.java +++ b/src/test/java/org/shedlang/compiler/patio/PatioSerializerTests.java @@ -86,6 +86,15 @@ public class PatioSerializerTests { assertThat(string, equalTo("(function-pointer-get \"target\" \"f\")")); } + @Test + public void canSerializeIntAdd() { + var instruction = Patio.intAdd("target", "left", "right"); + + var string = PatioTesting.serializeInstruction(instruction); + + assertThat(string, equalTo("(int-add \"target\" \"left\" \"right\")")); + } + @Test public void canSerializeIntGet() { var instruction = Patio.intGet("target", 42); diff --git a/src/test/java/org/shedlang/compiler/patio/instructions/Patio.java b/src/test/java/org/shedlang/compiler/patio/instructions/Patio.java index d8445de9..c0de6abc 100644 --- a/src/test/java/org/shedlang/compiler/patio/instructions/Patio.java +++ b/src/test/java/org/shedlang/compiler/patio/instructions/Patio.java @@ -43,6 +43,15 @@ public class Patio { return new PatioFunctionPointerGet(new PatioLocalRef(target), name, Sources.NULL); } + public static PatioInstruction intAdd(String target, String left, String right) { + return new PatioIntAdd( + new PatioLocalRef(target), + new PatioLocalRef(left), + new PatioLocalRef(right), + Sources.NULL + ); + } + public static PatioInstruction intGet(String target, int value) { return new PatioIntGet(new PatioLocalRef(target), value, Sources.NULL); } -- cgit v1.2.3