aboutsummaryrefslogtreecommitdiff
path: root/src/interp
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2008-05-11 19:14:29 +0000
committerdos-reis <gdr@axiomatics.org>2008-05-11 19:14:29 +0000
commit20e1bed66399cce629d08a71ca0552ed24fef1d1 (patch)
tree000ab5b98e479d1c077fc4f6fd4a9f46c4a9451c /src/interp
parent51422a0c6bc0128cd5635a01c402ef56ad4ed770 (diff)
downloadopen-axiom-20e1bed66399cce629d08a71ca0552ed24fef1d1.tar.gz
Restrict loop variable scopes, take 2.
* interp/iterator.boot (compReduce1): Maintain proper scope for loop variables. (compRepeatOrCollect): Really maintain proper scope for loop variables. * interp/compiler.boot (eltModemapFilter): Highlight faulty selector. (seteltModemapFilter): Likewise. * interp/c-util.boot (stackMessage): Don't build message if there is no argument for substitution. * algebra/aggcat.spad.pamphlet (#$UnaryRecursiveAggregate): Declare free loop variable. (cycleEntry$UnaryRecursiveAggregate): Likewise. (cycleLength): Likewise. (merge$OneDimensionalArrayAggregate): Likewise. (delete$OneDimensionalArrayAggregate): Likewise. (position$ListAggregate): Likewise. * algebra/array1.spad.pamphlet (merge!$IndexedFlexibleArray): Likewise. * algebra/combfunc.spad.pamphlet (K2fact$CombinatorialFunction): Likewise. * algebra/curve.spad.pamphlet (nonSingularModel$FunctionFieldCategory): Likewise. * algebra/dpolcat.spad.pamphlet (differentiate$DifferentialPolynomialCategory): Likewise. * algebra/efstruc.spad.pamphlet (validExponential$ElementaryFunctionStructurePackage): Likewise. (ker2explogs$InnerTrigonometricManipulations): Likewise. (complexNormalize$TrigonometricManipulations): Likewise.
Diffstat (limited to 'src/interp')
-rw-r--r--src/interp/c-util.boot4
-rw-r--r--src/interp/compiler.boot8
-rw-r--r--src/interp/iterator.boot16
3 files changed, 16 insertions, 12 deletions
diff --git a/src/interp/c-util.boot b/src/interp/c-util.boot
index a8475327..a2691741 100644
--- a/src/interp/c-util.boot
+++ b/src/interp/c-util.boot
@@ -512,7 +512,9 @@ unStackWarning(msg,args) ==
nil
stackMessage(msg,args == nil) ==
- $compErrorMessageStack:= [buildMessage(msg,args),:$compErrorMessageStack]
+ if args ^= nil then
+ msg := buildMessage(msg,args)
+ $compErrorMessageStack:= [msg,:$compErrorMessageStack]
nil
stackMessageIfNone msg ==
diff --git a/src/interp/compiler.boot b/src/interp/compiler.boot
index b120fc9d..397e6b9a 100644
--- a/src/interp/compiler.boot
+++ b/src/interp/compiler.boot
@@ -563,7 +563,7 @@ eltModemapFilter(name,mmList,e) ==
isConstantId(name,e) =>
l:= [mm for mm in mmList | mm is [[.,.,.,sel,:.],:.] and sel=name] => l
--there are elts with extra parameters
- stackMessage('"selector variable: %1 is undeclared and unbound",[name])
+ stackMessage('"selector variable: %1b is undeclared and unbound",[name])
nil
mmList
@@ -571,7 +571,7 @@ seteltModemapFilter(name,mmList,e) ==
isConstantId(name,e) =>
l:= [mm for (mm:= [[.,.,.,sel,:.],:.]) in mmList | sel=name] => l
--there are setelts with extra parameters
- stackMessage('"selector variable: %1 is undeclared and unbound",[name])
+ stackMessage('"selector variable: %1b is undeclared and unbound",[name])
nil
mmList
@@ -727,7 +727,7 @@ setqMultiple(nameList,val,m,e) ==
[[name,:mode] for [":",name,mode] in l]
stackMessage('"no multiple assigns to mode: %1p",[t])
#nameList^=#selectorModePairs =>
- stackMessage('"%1 must decompose into %2 components",[val,#nameList])
+ stackMessage('"%1b must decompose into %2 components",[val,#nameList])
3 --generate code; return
assignList:=
[([.,.,e]:= compSetq1(x,["elt",g,y],z,e) or return "failed").expr
@@ -737,7 +737,7 @@ setqMultiple(nameList,val,m,e) ==
setqMultipleExplicit(nameList,valList,m,e) ==
#nameList^=#valList =>
- stackMessage('"Multiple assignment error; # of items in: %1 must = # in: %2",[nameList,valList])
+ stackMessage('"Multiple assignment error; # of items in: %1b must = # in: %2",[nameList,valList])
gensymList:= [genVariable() for name in nameList]
assignList:=
--should be fixed to declare genVar when possible
diff --git a/src/interp/iterator.boot b/src/interp/iterator.boot
index d62f4939..19ead302 100644
--- a/src/interp/iterator.boot
+++ b/src/interp/iterator.boot
@@ -45,10 +45,11 @@ compReduce1(form is ["REDUCE",op,.,collectForm],m,e,$formalArgList) ==
if STRINGP op then op:= INTERN op
^MEMQ(collectOp,'(COLLECT COLLECTV COLLECTVEC)) =>
systemError ["illegal reduction form:",form]
- $sideEffectsList: local
- $until: local
- $initList: local
- $endTestList: local
+ $sideEffectsList: local := nil
+ $until: local := nil
+ $initList: local := nil
+ $endTestList: local := nil
+ oldEnv := e
$e:= e
itl:= [([.,$e]:= compIterator(x,$e) or return "failed").(0) for x in itl]
itl="failed" => return nil
@@ -73,7 +74,7 @@ compReduce1(form is ["REDUCE",op,.,collectForm],m,e,$formalArgList) ==
if $until then
[untilCode,.,e]:= comp($until,$Boolean,e)
finalCode:= substitute(["UNTIL",untilCode],'$until,finalCode)
- [finalCode,m,e]
+ [finalCode,m,oldEnv]
++ returns the identity element of the `reduction' operation `x'
++ over a list -- a monoid homomorphism.
@@ -93,6 +94,7 @@ compRepeatOrCollect(form,m,e) ==
,e) where
fn(form,$exitModeStack,$leaveLevelStack,$formalArgList,e) ==
$until: local
+ oldEnv := e
[repeatOrCollect,:itl,body]:= form
itl':=
[([x',e]:= compIterator(x,e) or return "failed"; x') for x in itl]
@@ -135,7 +137,7 @@ compRepeatOrCollect(form,m,e) ==
T := coerceExit([form',m'',e'],targetMode) or return nil
-- iterator variables and other variables declared in
-- in a loop are local to the loop.
- [T.expr,T.mode,e]
+ [T.expr,T.mode,oldEnv]
--constructByModemap([x,source,e],target) ==
-- u:=
@@ -213,7 +215,7 @@ compIterator(it,e) ==
it is ["WHILE",p] =>
[p',m,e]:=
comp(p,$Boolean,e) or return
- stackMessage('"WHILE operand: %1 is not Boolean valued",[p])
+ stackMessage('"WHILE operand: %1b is not Boolean valued",[p])
[["WHILE",p'],e]
it is ["UNTIL",p] => ($until:= p; ['$until,e])
it is ["|",x] =>