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 --- .../org/shedlang/compiler/stackir/InstructionSerializerTests.java | 4 ++-- .../java/org/shedlang/compiler/stackir/instructions/Instructions.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/test/java/org/shedlang/compiler/stackir') 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