aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2010-06-28 11:55:57 +0000
committerdos-reis <gdr@axiomatics.org>2010-06-28 11:55:57 +0000
commit3d42ed01a18486fb8390503753fe31bbb75c9551 (patch)
tree6c484ca594c9ddfcab6c447c4ee446bf5d929d17
parentea69320b242425d110f3cdfdf716f1826dcd806a (diff)
downloadopen-axiom-3d42ed01a18486fb8390503753fe31bbb75c9551.tar.gz
* interp/i-map.boot (findExternalVarsInBindExpr): New.
(findLocalVars1): Use it for %bind-expressions.
-rw-r--r--src/ChangeLog5
-rw-r--r--src/interp/i-map.boot18
2 files changed, 22 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 7cfdc4e1..3ff117da 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2010-06-28 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * interp/i-map.boot (findExternalVarsInBindExpr): New.
+ (findLocalVars1): Use it for %bind-expressions.
+
2010-06-27 Gabriel Dos Reis <gdr@cs.tamu.edu>
* interp/g-util.boot: Add new opcode %before?.
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)