diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-12-13 21:22:40 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-12-13 21:24:56 +0000 |
| commit | d00493a763a368825f17f2525c3f1c2cb23ad9de (patch) | |
| tree | 393448dcaf8c66947628f91725bfe2521baf998f /src/main/java | |
| parent | 13ff1f831986f18d01e00d15c884458e46188ed3 (diff) | |
Add Shid local-drop instruction
Diffstat (limited to 'src/main/java')
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 { +} |
