From 33888c1bac8a1e58fae55f275a0d0eafd16144c5 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Mon, 20 Nov 2023 19:55:13 +0000 Subject: Introduce explicit notion of a BoundVariable --- .../org/shedlang/compiler/stackir/StackCompiler.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 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 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(); 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 shedVariableNames) { + public Context enterBlock(List 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; -- cgit v1.2.3