diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-07-12 19:36:25 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-07-12 19:36:25 +0100 |
| commit | 84807c9365168b8b5c0ce277a341d78a222cef33 (patch) | |
| tree | 22cfb6bc26bbb1dd60381ac0efcc06bc472e71b3 /src/main/java/org/shedlang/compiler/stackir | |
| parent | c459a11534c60eec13e28f2823d751d6c68b698f (diff) | |
Extract TypedBlockNode::behaviour()
Diffstat (limited to 'src/main/java/org/shedlang/compiler/stackir')
| -rw-r--r-- | src/main/java/org/shedlang/compiler/stackir/StackCompiler.java | 10 |
1 files changed, 1 insertions, 9 deletions
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())); } |
