aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java6
-rw-r--r--src/main/java/org/shedlang/compiler/shid/ShidSerializer.java6
-rw-r--r--src/main/java/org/shedlang/compiler/shid/instructions/ShidInstruction.java2
-rw-r--r--src/main/java/org/shedlang/compiler/shid/instructions/ShidLocalDrop.java10
4 files changed, 23 insertions, 1 deletions
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java b/src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java
index a555d181..582d3959 100644
--- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java
+++ b/src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java
@@ -467,6 +467,10 @@ public class PatioCodeGen {
context
);
+ case ShidLocalDrop localDrop -> {
+ yield context;
+ }
+
case ShidLocalLoad localLoad -> {
var local = context.shidLocalNameToLocal(localLoad.name());
@@ -989,6 +993,8 @@ public class PatioCodeGen {
}
case ShidIntSub intSubInstruction -> {
}
+ case ShidLocalDrop localDropInstruction -> {
+ }
case ShidLocalLoad localLoadInstruction -> {
}
case ShidLocalStore localStoreInstruction -> {
diff --git a/src/main/java/org/shedlang/compiler/shid/ShidSerializer.java b/src/main/java/org/shedlang/compiler/shid/ShidSerializer.java
index 58f49ed0..bd6971fd 100644
--- a/src/main/java/org/shedlang/compiler/shid/ShidSerializer.java
+++ b/src/main/java/org/shedlang/compiler/shid/ShidSerializer.java
@@ -155,6 +155,12 @@ public class ShidSerializer {
case ShidIntSub intSub ->
treeList(treeIdentifier("int-sub"));
+ case ShidLocalDrop localDrop ->
+ treeList(
+ treeIdentifier("local-drop"),
+ treeString(localDrop.name())
+ );
+
case ShidLocalLoad localLoadInstruction ->
treeList(
treeIdentifier("local-load"),
diff --git a/src/main/java/org/shedlang/compiler/shid/instructions/ShidInstruction.java b/src/main/java/org/shedlang/compiler/shid/instructions/ShidInstruction.java
index 082c3de5..1c1afc3c 100644
--- a/src/main/java/org/shedlang/compiler/shid/instructions/ShidInstruction.java
+++ b/src/main/java/org/shedlang/compiler/shid/instructions/ShidInstruction.java
@@ -3,7 +3,7 @@ package org.shedlang.compiler.shid.instructions;
import org.shedlang.compiler.sources.Source;
public sealed interface ShidInstruction
- permits ShidCall, ShidDefineEffect, ShidDefineFunction, ShidDefineStruct, ShidDiscard, ShidDuplicate, ShedEffectHandlerBreak, ShidFieldLoad, ShidIf, ShidIntAdd, ShidIntEquals, ShidIntNotEqual, ShidIntSub, ShidLocalLoad, ShidLocalStore, ShidLoop, ShidLoopBreak, ShidLoopContinue, ShidNamespaceFieldStore, ShidNamespaceImport, ShidPushBool, ShidPushInt, ShidPushString, ShidPushUnit, ShidResume, ShidReturn, ShidStringAdd, ShidSwitch, ShidTry, ShidTupleCreate, ShidTupleGet, ShidVarLoad, ShidVarStore {
+ permits ShedEffectHandlerBreak, ShidCall, ShidDefineEffect, ShidDefineFunction, ShidDefineStruct, ShidDiscard, ShidDuplicate, ShidFieldLoad, ShidIf, ShidIntAdd, ShidIntEquals, ShidIntNotEqual, ShidIntSub, ShidLocalDrop, ShidLocalLoad, ShidLocalStore, ShidLoop, ShidLoopBreak, ShidLoopContinue, ShidNamespaceFieldStore, ShidNamespaceImport, ShidPushBool, ShidPushInt, ShidPushString, ShidPushUnit, ShidResume, ShidReturn, ShidStringAdd, ShidSwitch, ShidTry, ShidTupleCreate, ShidTupleGet, ShidVarLoad, ShidVarStore {
Source source();
}
diff --git a/src/main/java/org/shedlang/compiler/shid/instructions/ShidLocalDrop.java b/src/main/java/org/shedlang/compiler/shid/instructions/ShidLocalDrop.java
new file mode 100644
index 00000000..582de263
--- /dev/null
+++ b/src/main/java/org/shedlang/compiler/shid/instructions/ShidLocalDrop.java
@@ -0,0 +1,10 @@
+package org.shedlang.compiler.shid.instructions;
+
+import org.shedlang.compiler.sources.Source;
+
+/**
+ * Assert that the local with the given name will not be loaded until a store
+ * into that local.
+ */
+public record ShidLocalDrop(String name, Source source) implements ShidInstruction {
+}