diff options
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/org/shedlang/compiler/stackir/StackCompiler.java | 11 |
1 files changed, 10 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 61932ada..12a32125 100644 --- a/src/main/java/org/shedlang/compiler/stackir/StackCompiler.java +++ b/src/main/java/org/shedlang/compiler/stackir/StackCompiler.java @@ -134,7 +134,7 @@ public class StackCompiler { compileStringLiteral(typedStringLiteralNode, context); case TypedTupleNode typedTupleNode -> - throw new UnsupportedOperationException("TODO"); + compileTuple(typedTupleNode, context); }; } @@ -414,6 +414,15 @@ public class StackCompiler { }; } + private static Context compileTuple(TypedTupleNode node, Context context) { + for (var elementNode : node.elements()) { + context = compileExpression(elementNode, context); + } + + var instruction = new TupleCreateInstruction(node.elements().size(), node.source()); + return context.addInstruction(instruction); + } + private static Context compileWhile(TypedWhileNode node, Context context) { context = context.enterBlock(node.body().boundVariableNames()); context = compileBlockWithoutYield(node.body(), context); |
