From 634a91a27700a139d714501a27021a1db732c966 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Wed, 8 Apr 2026 18:52:26 +0100 Subject: Allow multiple destinations in Patio calls --- .../compiler/patio/PatioSerializerTests.java | 6 +++--- .../shedlang/compiler/patio/instructions/Patio.java | 21 +++++++++++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) (limited to 'src/test/java/org') diff --git a/src/test/java/org/shedlang/compiler/patio/PatioSerializerTests.java b/src/test/java/org/shedlang/compiler/patio/PatioSerializerTests.java index 76b336ea..1f8aba71 100644 --- a/src/test/java/org/shedlang/compiler/patio/PatioSerializerTests.java +++ b/src/test/java/org/shedlang/compiler/patio/PatioSerializerTests.java @@ -197,7 +197,7 @@ public class PatioSerializerTests { var string = PatioTesting.serializeInstruction(instruction); assertThat(string, equalTo(""" - (call _ "f" ((local "a") (local "b") (local "c")))""" + (call () "f" ((local "a") (local "b") (local "c")))""" )); } @@ -212,7 +212,7 @@ public class PatioSerializerTests { var string = PatioTesting.serializeInstruction(instruction); assertThat(string, equalTo(""" - (call (local "destination") "f" ((local "a") (local "b") (local "c")))""" + (call ((local "destination")) "f" ((local "a") (local "b") (local "c")))""" )); } @@ -227,7 +227,7 @@ public class PatioSerializerTests { var string = PatioTesting.serializeInstruction(instruction); assertThat(string, equalTo(""" - (call-pointer (local "destination") (local "f") ((local "a") (local "b") (local "c")))""" + (call-pointer ((local "destination")) (local "f") ((local "a") (local "b") (local "c")))""" )); } 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 0c0de429..ec332d94 100644 --- a/src/test/java/org/shedlang/compiler/patio/instructions/Patio.java +++ b/src/test/java/org/shedlang/compiler/patio/instructions/Patio.java @@ -33,13 +33,26 @@ public class Patio { return new PatioByteConst(value); } + public static PatioInstruction call( + List destinations, + String name, + List args + ) { + return new PatioCall( + destinations, + name, + args, + Sources.NULL + ); + } + public static PatioInstruction call( Optional destination, String name, List args ) { return new PatioCall( - destination, + destination.stream().toList(), name, args, Sources.NULL @@ -52,7 +65,7 @@ public class Patio { List args ) { return new PatioCallPointer( - destination, + List.of(destination), functionPointer, args, Sources.NULL @@ -298,6 +311,10 @@ public class Patio { return new PatioLocal(name, type, PatioLocalType.PARAM); } + public static PatioInstruction return_(List values) { + return new PatioReturn(values, Sources.NULL); + } + public static PatioInstruction return_(PatioOperand value) { return new PatioReturn(List.of(value), Sources.NULL); } -- cgit v1.2.3