diff options
| author | Michael Williamson <mike@zwobble.org> | 2024-01-21 19:31:31 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2024-01-21 19:31:56 +0000 |
| commit | 8462c0ecc99be62339fe1829363c15beb8c5c0f1 (patch) | |
| tree | 4dced037b32cdcf463480e00e03b69556ba5175b /src/test/java | |
| parent | d6d1411a6f836a5d72bb3ef3c27619569f8b5131 (diff) | |
Remove alloc-heap from Patio
Diffstat (limited to 'src/test/java')
3 files changed, 1 insertions, 74 deletions
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java b/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java index ddc9c386..3b894f3a 100644 --- a/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java +++ b/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java @@ -1,11 +1,10 @@ package org.shedlang.compiler.patio; import org.junit.jupiter.api.Test; +import org.shedlang.compiler.patio.instructions.Patio; import org.shedlang.compiler.patio.types.PatioDataLayouts; import org.shedlang.compiler.patio.types.PatioDataValues; import org.shedlang.compiler.patio.types.PatioTypes; -import org.shedlang.compiler.patio.instructions.Patio; -import org.shedlang.compiler.shidtopatio.ShidToPatioGc; import org.shedlang.compiler.sources.Sources; import org.shedlang.compiler.testing.ExecutionResult; import org.zwobble.precisely.Matcher; @@ -90,62 +89,6 @@ public abstract class PatioExampleTests { } @Test - public void allocHeap() throws IOException, InterruptedException { - var patioFunction = PatioFunctionDefinition.builder() - .withName(FUNCTION_NAME) - .withReturnType(PatioTypes.INT) - .addLocal(Patio.val("x", PatioTypes.DATA_POINTER)) - .addLocal(Patio.val("y", PatioTypes.INT)) - .addLocal(Patio.val("z", PatioTypes.INT)) - .addLocal(Patio.val("r", PatioTypes.INT)) - .addBodyInstruction(Patio.allocHeap( - Patio.localRef("x"), - // TODO: move/rename ShidToPatioGc to be shid-agnostic? - // TODO: find a way to ensure we only alloc objects with the GC header? - // (Probably just remove the GC from Patio?) - ShidToPatioGc.gcObjectDataLayout(PatioDataLayouts.INT) - )) - .addBodyInstruction(Patio.memoryStore( - Patio.localRef("x"), - ShidToPatioGc.gcObjectDataLayout(PatioDataLayouts.INT), - ShidToPatioGc.gcObjectOffset(List.of()), - Patio.int_(42) - )) - .addBodyInstruction(Patio.memoryLoad( - Patio.localRef("y"), - Patio.localRef("x"), - ShidToPatioGc.gcObjectDataLayout(PatioDataLayouts.INT), - ShidToPatioGc.gcObjectOffset(List.of()) - )) - .addBodyInstruction(Patio.intAdd( - Patio.localRef("z"), - Patio.localRef("y"), - Patio.int_(5) - )) - .addBodyInstruction(Patio.memoryStore( - Patio.localRef("x"), - ShidToPatioGc.gcObjectDataLayout(PatioDataLayouts.INT), - ShidToPatioGc.gcObjectOffset(List.of()), - Patio.localRef("z") - )) - .addBodyInstruction(Patio.memoryLoad( - Patio.localRef("r"), - Patio.localRef("x"), - ShidToPatioGc.gcObjectDataLayout(PatioDataLayouts.INT), - ShidToPatioGc.gcObjectOffset(List.of()) - )) - .addBodyInstruction(Patio.return_( - Patio.localRef("r") - )) - .build(); - var patio = Patio.compilationUnit(List.of(patioFunction)); - - var result = run(patio); - - assertThat(result, isSilentExit(47)); - } - - @Test public void allocStack() throws IOException, InterruptedException { var patioFunction = PatioFunctionDefinition.builder() .withName(FUNCTION_NAME) diff --git a/src/test/java/org/shedlang/compiler/patio/PatioSerializerTests.java b/src/test/java/org/shedlang/compiler/patio/PatioSerializerTests.java index 404b072f..071007f9 100644 --- a/src/test/java/org/shedlang/compiler/patio/PatioSerializerTests.java +++ b/src/test/java/org/shedlang/compiler/patio/PatioSerializerTests.java @@ -134,18 +134,6 @@ public class PatioSerializerTests { // == Instructions == @Test - public void canSerializeAllocHeap() { - var instruction = Patio.allocHeap( - Patio.localRef("x"), - PatioDataLayouts.struct(List.of(PatioDataLayouts.INT, PatioDataLayouts.INT, PatioDataLayouts.BYTE)) - ); - - var string = PatioTesting.serializeInstruction(instruction); - - assertThat(string, equalTo("(alloc-heap (local \"x\") (struct (int int byte)))")); - } - - @Test public void canSerializeAllocStack() { var instruction = Patio.allocStack( Patio.localRef("x"), 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 a1dbd84e..49f35768 100644 --- a/src/test/java/org/shedlang/compiler/patio/instructions/Patio.java +++ b/src/test/java/org/shedlang/compiler/patio/instructions/Patio.java @@ -13,10 +13,6 @@ import java.util.Optional; public class Patio { private Patio() {} - public static PatioInstruction allocHeap(PatioLocalRef destination, PatioDataLayout layout) { - return new PatioAllocHeap(destination, layout, List.of(), 0, Sources.NULL); - } - public static PatioInstruction allocStack(PatioLocalRef destination, PatioDataLayout layout) { return new PatioAllocStack(destination, layout, Sources.NULL); } |
