aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-07-20 23:34:29 +0100
committerMichael Williamson <mike@zwobble.org>2023-07-20 23:36:01 +0100
commit88f7aecdecf5a4e2d4f4f243aa2517129a191b25 (patch)
treef32d369114f99e80834e406e7dcabd435b3d6667
parentfceeffe7558fc4cbab8d2d5062ad6cf2930ce850 (diff)
Change local-copy to more general local-store
-rw-r--r--snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenCallTests]/[method:canCallFunctionWithArgs(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected10
-rw-r--r--snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenCallTests]/[method:canCallFunctionWithNoArgs(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected2
-rw-r--r--snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenLocalStoreTests]/[method:localStorePopsTemporaryIntoLocal(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected2
-rw-r--r--src/main/java/org/shedlang/compiler/patio/PatioCodeGenContext.java4
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java8
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioInstruction.java2
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioLocalStore.java (renamed from src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioLocalCopy.java)7
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioSerializerTests.java6
-rw-r--r--src/test/java/org/shedlang/compiler/patio/instructions/Patio.java7
9 files changed, 25 insertions, 23 deletions
diff --git a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenCallTests]/[method:canCallFunctionWithArgs(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenCallTests]/[method:canCallFunctionWithArgs(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected
index c32eee46..301a4bad 100644
--- a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenCallTests]/[method:canCallFunctionWithArgs(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected
+++ b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenCallTests]/[method:canCallFunctionWithArgs(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected
@@ -16,11 +16,11 @@ Args:
Instructions:
(
- (local-copy (local "callArgNamed__a__0") (local "namedA"))
- (local-copy (local "callArgNamed__b__0") (local "namedB"))
- (local-copy (local "callArgPositional__1__0") (local "pos2"))
- (local-copy (local "callArgPositional__0__0") (local "pos1"))
- (local-copy (local "receiver__0") (local "receiver"))
+ (local-store (local "callArgNamed__a__0") (local "namedA"))
+ (local-store (local "callArgNamed__b__0") (local "namedB"))
+ (local-store (local "callArgPositional__1__0") (local "pos2"))
+ (local-store (local "callArgPositional__0__0") (local "pos1"))
+ (local-store (local "receiver__0") (local "receiver"))
(int-to-data-ptr (local "closurePointer__0") (local "receiver__0"))
(
memory-load
diff --git a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenCallTests]/[method:canCallFunctionWithNoArgs(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenCallTests]/[method:canCallFunctionWithNoArgs(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected
index 8e6b929b..a8abe69a 100644
--- a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenCallTests]/[method:canCallFunctionWithNoArgs(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected
+++ b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenCallTests]/[method:canCallFunctionWithNoArgs(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected
@@ -12,7 +12,7 @@ Args:
Instructions:
(
- (local-copy (local "receiver__0") (local "receiver"))
+ (local-store (local "receiver__0") (local "receiver"))
(int-to-data-ptr (local "closurePointer__0") (local "receiver__0"))
(
memory-load
diff --git a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenLocalStoreTests]/[method:localStorePopsTemporaryIntoLocal(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenLocalStoreTests]/[method:localStorePopsTemporaryIntoLocal(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected
index 7f35774f..46e0a220 100644
--- a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenLocalStoreTests]/[method:localStorePopsTemporaryIntoLocal(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected
+++ b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenLocalStoreTests]/[method:localStorePopsTemporaryIntoLocal(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected
@@ -9,7 +9,7 @@ Args:
Instructions:
(
- (local-copy (local "local__x") (local "b"))
+ (local-store (local "local__x") (local "b"))
)
Temporary stack:
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenContext.java b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenContext.java
index f85d97a1..aca3f71c 100644
--- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenContext.java
+++ b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenContext.java
@@ -7,7 +7,7 @@ import org.pcollections.PVector;
import org.shedlang.compiler.backends.llvm.NameAllocator;
import org.shedlang.compiler.patio.ast.*;
import org.shedlang.compiler.patio.ast.instructions.PatioInstruction;
-import org.shedlang.compiler.patio.ast.instructions.PatioLocalCopy;
+import org.shedlang.compiler.patio.ast.instructions.PatioLocalStore;
import org.shedlang.compiler.patio.ast.operands.PatioLocalRef;
import org.shedlang.compiler.patio.ast.types.PatioDataLayout;
import org.shedlang.compiler.patio.ast.types.PatioType;
@@ -244,7 +244,7 @@ public record PatioCodeGenContext(
var result = this.functionContext.temporaryPop();
return new PatioCodeGenContext(this.compilationUnitContext, result.context)
- .addInstruction(new PatioLocalCopy(target, result.value, source));
+ .addInstruction(new PatioLocalStore(target, result.value, source));
}
public PatioCodeGenContext temporaryPush(PatioLocalRef value) {
diff --git a/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java b/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java
index 8edf1464..bfdbac89 100644
--- a/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java
+++ b/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java
@@ -174,11 +174,11 @@ public class PatioSerializer {
operandToTree(intToDataPtr.value())
);
- case PatioLocalCopy localCopy ->
+ case PatioLocalStore localStore ->
treeList(
- treeIdentifier("local-copy"),
- operandToTree(localCopy.target()),
- operandToTree(localCopy.value())
+ treeIdentifier("local-store"),
+ operandToTree(localStore.target()),
+ operandToTree(localStore.value())
);
case PatioMemoryLoad memoryLoad ->
diff --git a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioInstruction.java b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioInstruction.java
index 88b47962..c18afbd1 100644
--- a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioInstruction.java
+++ b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioInstruction.java
@@ -2,6 +2,6 @@ package org.shedlang.compiler.patio.ast.instructions;
import org.shedlang.compiler.sources.Source;
-public sealed interface PatioInstruction permits PatioAlloc, PatioCallPointer, PatioDataPtrGet, PatioDataPtrToInt, PatioFunctionPointerGet, PatioIf, PatioIntAdd, PatioIntGet, PatioIntToDataPtr, PatioLocalCopy, PatioMemoryLoad, PatioMemoryStore, PatioReturn {
+public sealed interface PatioInstruction permits PatioAlloc, PatioCallPointer, PatioDataPtrGet, PatioDataPtrToInt, PatioFunctionPointerGet, PatioIf, PatioIntAdd, PatioIntGet, PatioIntToDataPtr, PatioLocalStore, PatioMemoryLoad, PatioMemoryStore, PatioReturn {
Source source();
}
diff --git a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioLocalCopy.java b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioLocalStore.java
index 34d5bbaa..22939cd5 100644
--- a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioLocalCopy.java
+++ b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioLocalStore.java
@@ -1,14 +1,15 @@
package org.shedlang.compiler.patio.ast.instructions;
import org.shedlang.compiler.patio.ast.operands.PatioLocalRef;
+import org.shedlang.compiler.patio.ast.operands.PatioOperand;
import org.shedlang.compiler.sources.Source;
/**
- * Copy the given value into the target local.
+ * Store the given value in the target local.
*/
-public record PatioLocalCopy(
+public record PatioLocalStore(
PatioLocalRef target,
- PatioLocalRef value,
+ PatioOperand value,
Source source
) implements PatioInstruction {
}
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioSerializerTests.java b/src/test/java/org/shedlang/compiler/patio/PatioSerializerTests.java
index e7c21285..880c7001 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioSerializerTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioSerializerTests.java
@@ -199,12 +199,12 @@ public class PatioSerializerTests {
}
@Test
- public void canSerializeLocalCopy() {
- var instruction = Patio.localCopy("target", "x");
+ public void canSerializeLocalStore() {
+ var instruction = Patio.localStore("target", Patio.localRef("x"));
var string = PatioTesting.serializeInstruction(instruction);
- assertThat(string, equalTo("(local-copy (local \"target\") (local \"x\"))"));
+ assertThat(string, equalTo("(local-store (local \"target\") (local \"x\"))"));
}
@Test
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 50aa38ab..be897477 100644
--- a/src/test/java/org/shedlang/compiler/patio/instructions/Patio.java
+++ b/src/test/java/org/shedlang/compiler/patio/instructions/Patio.java
@@ -3,6 +3,7 @@ package org.shedlang.compiler.patio.instructions;
import org.shedlang.compiler.patio.ast.*;
import org.shedlang.compiler.patio.ast.instructions.*;
import org.shedlang.compiler.patio.ast.operands.PatioLocalRef;
+import org.shedlang.compiler.patio.ast.operands.PatioOperand;
import org.shedlang.compiler.patio.ast.types.PatioDataLayout;
import org.shedlang.compiler.patio.ast.types.PatioType;
import org.shedlang.compiler.sources.Sources;
@@ -99,10 +100,10 @@ public class Patio {
return new PatioLocal(name, type);
}
- public static PatioInstruction localCopy(String target, String value) {
- return new PatioLocalCopy(
+ public static PatioInstruction localStore(String target, PatioOperand value) {
+ return new PatioLocalStore(
new PatioLocalRef(target),
- new PatioLocalRef(value),
+ value,
Sources.NULL
);
}