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/stackir/StackCompiler.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/main/java/org/shedlang/compiler/stackir/StackCompiler.java b/src/main/java/org/shedlang/compiler/stackir/StackCompiler.java
index bad4f72c..da20c770 100644
--- a/src/main/java/org/shedlang/compiler/stackir/StackCompiler.java
+++ b/src/main/java/org/shedlang/compiler/stackir/StackCompiler.java
@@ -114,6 +114,17 @@ public class StackCompiler {
return context;
}
+ private static Context compileEffectDefinition(
+ TypedEffectDefinitionNode node,
+ Context context
+ ) {
+ var localName = context.shedVariableToLocal(node.effect().name());
+
+ return context
+ .addInstruction(new DefineEffectInstruction(node.effect(), node.source()))
+ .addInstruction(new LocalStoreInstruction(localName, node.source()));
+ }
+
public static Context compileExpression(TypedExpressionNode node, Context context) {
return switch (node) {
case TypedBinaryOperationNode typedBinaryOperationNode ->
@@ -450,7 +461,7 @@ public class StackCompiler {
compileAssign(assign, context);
case TypedEffectDefinitionNode effectDefinition ->
- throw new UnsupportedOperationException("TODO");
+ compileEffectDefinition(effectDefinition, context);
case TypedFunctionDefinitionNode functionDefinition ->
compileFunctionDefinition(functionDefinition, context);