From 64ae63e69b6a5f180b869bd49fa92aaed7407021 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Fri, 15 Dec 2023 11:55:41 +0000 Subject: Fix name of instruction --- .../java/org/shedlang/compiler/patio/PatioCodeGen.java | 2 +- .../java/org/shedlang/compiler/shid/ShidCodeGen.java | 2 +- .../org/shedlang/compiler/shid/ShidSerializer.java | 2 +- .../shid/instructions/ShedEffectHandlerBreak.java | 18 ------------------ .../shid/instructions/ShidEffectHandlerBreak.java | 18 ++++++++++++++++++ .../compiler/shid/instructions/ShidInstruction.java | 6 +++--- 6 files changed, 24 insertions(+), 24 deletions(-) delete mode 100644 src/main/java/org/shedlang/compiler/shid/instructions/ShedEffectHandlerBreak.java create mode 100644 src/main/java/org/shedlang/compiler/shid/instructions/ShidEffectHandlerBreak.java (limited to 'src/main/java') diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java b/src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java index 2107991d..925b540a 100644 --- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java +++ b/src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java @@ -304,7 +304,7 @@ public class PatioCodeGen { yield context.temporaryPush(value).temporaryPush(value); } - case ShedEffectHandlerBreak effectHandlerBreak -> { + case ShidEffectHandlerBreak effectHandlerBreak -> { var valueResult = context.temporaryPop(); var value = valueResult.value(); context = valueResult.context(); diff --git a/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java b/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java index fee218db..cf14766c 100644 --- a/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java +++ b/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java @@ -93,7 +93,7 @@ public class ShidCodeGen { private static Context compileBreak(TypedBreakNode node, Context context) { context = compileExpression(node.expression(), context); - context = context.addInstruction(new ShedEffectHandlerBreak(node.handledEffect(), node.source())); + context = context.addInstruction(new ShidEffectHandlerBreak(node.handledEffect(), node.source())); return context; } diff --git a/src/main/java/org/shedlang/compiler/shid/ShidSerializer.java b/src/main/java/org/shedlang/compiler/shid/ShidSerializer.java index 66f6e049..09501abe 100644 --- a/src/main/java/org/shedlang/compiler/shid/ShidSerializer.java +++ b/src/main/java/org/shedlang/compiler/shid/ShidSerializer.java @@ -126,7 +126,7 @@ public class ShidSerializer { treeIdentifier("duplicate") ); - case ShedEffectHandlerBreak effectHandlerBreak -> + case ShidEffectHandlerBreak effectHandlerBreak -> treeList( treeIdentifier("effect-handler-break"), userDefinedEffectToTree(effectHandlerBreak.effect()) diff --git a/src/main/java/org/shedlang/compiler/shid/instructions/ShedEffectHandlerBreak.java b/src/main/java/org/shedlang/compiler/shid/instructions/ShedEffectHandlerBreak.java deleted file mode 100644 index 156352b8..00000000 --- a/src/main/java/org/shedlang/compiler/shid/instructions/ShedEffectHandlerBreak.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.shedlang.compiler.shid.instructions; - -import org.shedlang.compiler.sources.Source; -import org.shedlang.compiler.types.UserDefinedEffect; - -/** - * Pop a value from the temporary value stack and exit with that value from - * the closest try expression in the call stack that handles the given effect. - */ -public record ShedEffectHandlerBreak( - UserDefinedEffect effect, - Source source -) implements ShidInstruction { - @Override - public boolean isTerminator() { - return true; - } -} diff --git a/src/main/java/org/shedlang/compiler/shid/instructions/ShidEffectHandlerBreak.java b/src/main/java/org/shedlang/compiler/shid/instructions/ShidEffectHandlerBreak.java new file mode 100644 index 00000000..b19edcd5 --- /dev/null +++ b/src/main/java/org/shedlang/compiler/shid/instructions/ShidEffectHandlerBreak.java @@ -0,0 +1,18 @@ +package org.shedlang.compiler.shid.instructions; + +import org.shedlang.compiler.sources.Source; +import org.shedlang.compiler.types.UserDefinedEffect; + +/** + * Pop a value from the temporary value stack and exit with that value from + * the closest try expression in the call stack that handles the given effect. + */ +public record ShidEffectHandlerBreak( + UserDefinedEffect effect, + Source source +) implements ShidInstruction { + @Override + public boolean isTerminator() { + return true; + } +} 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 2b559d9d..8eb2b3a0 100644 --- a/src/main/java/org/shedlang/compiler/shid/instructions/ShidInstruction.java +++ b/src/main/java/org/shedlang/compiler/shid/instructions/ShidInstruction.java @@ -3,11 +3,11 @@ package org.shedlang.compiler.shid.instructions; import org.shedlang.compiler.sources.Source; public sealed interface ShidInstruction - permits ShedEffectHandlerBreak, ShidBlock, 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 { + permits ShidEffectHandlerBreak, ShidBlock, 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 { /** - * If an instruction is a terminator, any following instructions in the - * current block are guaranteed to be unreachable. + * If an instruction is a terminator, execution is guaranteed to leave the + * current block. */ boolean isTerminator(); -- cgit v1.2.3