From 121bb5c7e3d141d6baade166e42b58fef7c59c1c Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 23 Sep 2023 16:17:11 +0100 Subject: Store total element count in tuple-get instruction --- .../java/org/shedlang/compiler/patio/PatioCodeGenTupleGetTests.java | 2 +- .../org/shedlang/compiler/stackir/InstructionSerializerTests.java | 4 ++-- .../java/org/shedlang/compiler/stackir/instructions/Instructions.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/test/java') diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenTupleGetTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenTupleGetTests.java index d50b8022..fc1cf272 100644 --- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenTupleGetTests.java +++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenTupleGetTests.java @@ -15,7 +15,7 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize; public class PatioCodeGenTupleGetTests { @Test public void canGenerateCodeForTupleGet(Snapshotter snapshotter) throws IOException { - var stackIr = Instructions.tupleGet(2); + var stackIr = Instructions.tupleGet(2, 3); var context = PatioCodeGenContext.EMPTY .temporaryPush(new PatioLocalRef("a")) .temporaryPush(new PatioLocalRef("b")); diff --git a/src/test/java/org/shedlang/compiler/stackir/InstructionSerializerTests.java b/src/test/java/org/shedlang/compiler/stackir/InstructionSerializerTests.java index d6f4b830..b9166fac 100644 --- a/src/test/java/org/shedlang/compiler/stackir/InstructionSerializerTests.java +++ b/src/test/java/org/shedlang/compiler/stackir/InstructionSerializerTests.java @@ -305,11 +305,11 @@ public class InstructionSerializerTests { @Test public void canSerializeTupleGet() { - var instruction = Instructions.tupleGet(2); + var instruction = Instructions.tupleGet(2, 3); var string = serialize(instruction); - assertThat(string, equalTo("(tuple-get 2)")); + assertThat(string, equalTo("(tuple-get 2 3)")); } @Test diff --git a/src/test/java/org/shedlang/compiler/stackir/instructions/Instructions.java b/src/test/java/org/shedlang/compiler/stackir/instructions/Instructions.java index 126ad1fa..ae1e0a4c 100644 --- a/src/test/java/org/shedlang/compiler/stackir/instructions/Instructions.java +++ b/src/test/java/org/shedlang/compiler/stackir/instructions/Instructions.java @@ -110,8 +110,8 @@ public class Instructions { return new TupleCreateInstruction(elementCount, Sources.NULL); } - public static Instruction tupleGet(int elementIndex) { - return new TupleGetInstruction(elementIndex, Sources.NULL); + public static Instruction tupleGet(int elementIndex, int elementCount) { + return new TupleGetInstruction(elementIndex, elementCount, Sources.NULL); } public static Instruction varLoad(String name) { -- cgit v1.2.3