From 8462c0ecc99be62339fe1829363c15beb8c5c0f1 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 21 Jan 2024 19:31:31 +0000 Subject: Remove alloc-heap from Patio --- .../shedlang/compiler/patio/PatioExampleTests.java | 59 +--------------------- .../compiler/patio/PatioSerializerTests.java | 12 ----- .../compiler/patio/instructions/Patio.java | 4 -- 3 files changed, 1 insertion(+), 74 deletions(-) (limited to 'src/test/java') 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; @@ -89,62 +88,6 @@ public abstract class PatioExampleTests { assertThat(result, isSilentExit(42)); } - @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() 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 @@ -133,18 +133,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( 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); } -- cgit v1.2.3