From 48560d9b326a9edb73231e816791edc1b196b1b1 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Tue, 7 Nov 2023 17:21:06 +0000 Subject: Generate stack IR for resume statements --- src/main/java/org/shedlang/compiler/stackir/StackCompiler.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/org/shedlang/compiler/stackir/StackCompiler.java b/src/main/java/org/shedlang/compiler/stackir/StackCompiler.java index 0d467c0d..bad4f72c 100644 --- a/src/main/java/org/shedlang/compiler/stackir/StackCompiler.java +++ b/src/main/java/org/shedlang/compiler/stackir/StackCompiler.java @@ -315,7 +315,7 @@ public class StackCompiler { compileFunctionReturn(functionReturn, context); case TypedResumeNode resume -> - throw new UnsupportedOperationException("TODO"); + compileResume(resume, context); case TypedWhileNode while_ -> compileWhile(while_, context); @@ -479,6 +479,12 @@ public class StackCompiler { } } + private static Context compileResume(TypedResumeNode node, Context context) { + context = compileExpression(node.expression(), context); + context = context.addInstruction(new ReturnInstruction(node.source())); + return context; + } + private static Context compileStringLiteral( TypedStringLiteralNode node, Context context -- cgit v1.2.3