From 84807c9365168b8b5c0ce277a341d78a222cef33 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Wed, 12 Jul 2023 19:36:25 +0100 Subject: Extract TypedBlockNode::behaviour() --- src/main/java/org/shedlang/compiler/stackir/StackCompiler.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'src/main/java/org/shedlang/compiler/stackir') diff --git a/src/main/java/org/shedlang/compiler/stackir/StackCompiler.java b/src/main/java/org/shedlang/compiler/stackir/StackCompiler.java index b4c8f9f0..70f38cf6 100644 --- a/src/main/java/org/shedlang/compiler/stackir/StackCompiler.java +++ b/src/main/java/org/shedlang/compiler/stackir/StackCompiler.java @@ -4,7 +4,6 @@ import org.pcollections.PVector; import org.shedlang.compiler.ShedBuiltins; import org.shedlang.compiler.ast.typed.*; import org.shedlang.compiler.stackir.instructions.*; -import org.shedlang.compiler.util.Lists; import org.shedlang.compiler.util.P; import java.util.stream.Collectors; @@ -101,14 +100,7 @@ public class StackCompiler { .flatMap(statement -> compileFunctionStatement(statement).stream()) .collect(Collectors.toList()); - var lastStatement = Lists.last(node.body().statements()); - // TODO: remove duplication with type checker (default to none behaviour). - // Extract block node? - var lastStatementBehaviour = lastStatement - .map(statement -> statement.behaviour()) - .orElse(TypedFunctionStatementBehaviour.CONTINUE); - - switch (lastStatementBehaviour) { + switch (node.body().behaviour()) { case TypedFunctionStatementBehaviour.BlockReturn blockReturn -> { body.add(new ReturnInstruction(node.source())); } -- cgit v1.2.3