aboutsummaryrefslogtreecommitdiff
path: root/src/interp
diff options
context:
space:
mode:
Diffstat (limited to 'src/interp')
-rw-r--r--src/interp/i-map.boot18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/interp/i-map.boot b/src/interp/i-map.boot
index a6a26ac9..ed313aca 100644
--- a/src/interp/i-map.boot
+++ b/src/interp/i-map.boot
@@ -1033,11 +1033,14 @@ findLocalVars1(op,form) ==
mkLocalVar(op,a)
form is ['is,l,pattern] =>
findLocalVars1(op,l)
- for var in listOfVariables rest pattern repeat mkLocalVar(op,var)
+ for var in listOfVariables rest pattern repeat
+ mkLocalVar(op,var)
form is [oper,:itrl,body] and oper in '(REPEAT COLLECT %collect) =>
findLocalsInLoop(op,itrl,body)
form is ['%loop,:itrl,val,body] =>
findLocalsInLoop(op,itrl,[body,val])
+ form is ['%bind,bindings,:body] =>
+ findExternalVarsInBindExpr(op,bindings,body)
form is [y,:argl] =>
y is "Record" or (y is "Union" and argl is [[":",.,.],:.]) =>
-- don't pick field tags, their are not variables.
@@ -1067,6 +1070,19 @@ findLocalsInLoop(op,itrl,body) ==
findLocalVars1(op,b)
$localVars := setUnion(savedLocalVars,setDifference($localVars,iterVars))
+++ Subroutine of findLocalVars1.
+++ Find variables in a bind-expressions that are external to that block.
+findExternalVarsInBindExpr(op,bindings,stmts) ==
+ savedLocalVars := $localVars
+ boundVars := nil
+ for [var,init] in bindings repeat
+ findLocalVars1(op,init)
+ boundVars := [var,:boundVars]
+ mkLocalVar(op,var)
+ for stmt in stmts repeat
+ findLocalVars1(op,stmt)
+ $localVars := setUnion(savedLocalVars,setDifference($localVars,boundVars))
+
isFreeVar(var) ==
member(var,$freeVars)