aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/shedlang/compiler/stackir
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-11-20 19:55:13 +0000
committerMichael Williamson <mike@zwobble.org>2023-11-20 19:55:13 +0000
commit33888c1bac8a1e58fae55f275a0d0eafd16144c5 (patch)
treedb148f62366b4b84fab50f4f6b19ffa5f2e09f05 /src/main/java/org/shedlang/compiler/stackir
parent992336f41a4f6881f2a43e61e479f66e062609fd (diff)
Introduce explicit notion of a BoundVariable
Diffstat (limited to 'src/main/java/org/shedlang/compiler/stackir')
-rw-r--r--src/main/java/org/shedlang/compiler/stackir/StackCompiler.java18
1 files changed, 9 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 8110e6da..885e26e4 100644
--- a/src/main/java/org/shedlang/compiler/stackir/StackCompiler.java
+++ b/src/main/java/org/shedlang/compiler/stackir/StackCompiler.java
@@ -217,7 +217,7 @@ public class StackCompiler {
Source source,
Context context
) {
- context = context.enterBlock(body.boundVariableNames());
+ context = context.enterBlock(body.boundVariables());
var c = context;
@@ -355,7 +355,7 @@ public class StackCompiler {
Context context
) {
if (conditionalBranches.isEmpty()) {
- context = context.enterBlock(elseBody.boundVariableNames());
+ context = context.enterBlock(elseBody.boundVariables());
context = compileBlockWithYield(elseBody, context);
var elseInstructions = context.instructions;
context = context.exitBlock();
@@ -366,7 +366,7 @@ public class StackCompiler {
var conditionalBranch = conditionalBranches.get(0);
context = compileExpression(conditionalBranch.condition(), context);
- context = context.enterBlock(conditionalBranch.body().boundVariableNames());
+ context = context.enterBlock(conditionalBranch.body().boundVariables());
context = compileBlockWithYield(conditionalBranch.body(), context);
var ifTrueInstructions = context.instructions;
context = context.exitBlock();
@@ -622,7 +622,7 @@ public class StackCompiler {
context = compileTryHandlerMethod(handlerMethod, context);
}
- context = context.enterBlock(node.body().boundVariableNames());
+ context = context.enterBlock(node.body().boundVariables());
context = compileBlockWithYield(node.body(), context);
var bodyInstructions = context.instructions;
context = context.exitBlock();
@@ -674,7 +674,7 @@ public class StackCompiler {
var switchCases = new ArrayList<SwitchInstruction.Case>();
for (var whenCase : node.cases()) {
- context = context.enterBlock(whenCase.body().boundVariableNames());
+ context = context.enterBlock(whenCase.body().boundVariables());
context = compileBlockWithYield(whenCase.body(), context);
var caseBodyInstructions = context.instructions;
context = context.exitBlock();
@@ -696,7 +696,7 @@ public class StackCompiler {
}
private static Context compileWhile(TypedWhileNode node, Context context) {
- context = context.enterBlock(node.body().boundVariableNames());
+ context = context.enterBlock(node.body().boundVariables());
context = compileBlockWithoutYield(node.body(), context);
var ifTrueInstructions = context.instructions;
context = context.exitBlock();
@@ -754,7 +754,7 @@ public class StackCompiler {
this.shedVariablesByName = shedVariablesByName;
}
- public Context enterBlock(List<String> shedVariableNames) {
+ public Context enterBlock(List<BoundVariable> shedVariables) {
var context = new Context(
this.instructionsStack.plus(this.instructions),
P.vector(),
@@ -763,8 +763,8 @@ public class StackCompiler {
this.shedVariablesByName
);
- for (var shedVariableName : shedVariableNames) {
- context = context.addShedVariable(shedVariableName);
+ for (var shedVariable : shedVariables) {
+ context = context.addShedVariable(shedVariable.name());
}
return context;