aboutsummaryrefslogtreecommitdiff
path: root/src/interp
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2009-07-06 08:49:58 +0000
committerdos-reis <gdr@axiomatics.org>2009-07-06 08:49:58 +0000
commit2c34c1a268d3eb28f39bf9f431a49b09c5a1339f (patch)
treea3dcb70c23a29eae6e3179b0eb09235b09500810 /src/interp
parent40af74e42fffdffe075310520d00b0e0d97d4a8c (diff)
downloadopen-axiom-2c34c1a268d3eb28f39bf9f431a49b09c5a1339f.tar.gz
* interp/compiler.boot (localReferenceIfThere): Tidy.
* interp/g-util.boot (homogeneousListToVector): New. * interp/g-opt.boot (optCollectVector): Use it.
Diffstat (limited to 'src/interp')
-rw-r--r--src/interp/compiler.boot5
-rw-r--r--src/interp/g-opt.boot35
-rw-r--r--src/interp/g-util.boot3
3 files changed, 24 insertions, 19 deletions
diff --git a/src/interp/compiler.boot b/src/interp/compiler.boot
index 386b0014..2eb63a11 100644
--- a/src/interp/compiler.boot
+++ b/src/interp/compiler.boot
@@ -2261,12 +2261,11 @@ numberize x ==
atom x => x
[numberize first x,:numberize rest x]
-++ If there is a local reference to mode `m', return it. Otherwise
-++ return `m' itself.
+++ If there is a local reference to mode `m', return it.
localReferenceIfThere m ==
m = "$" => m
idx := NRTassocIndex m => ["getShellEntry","$",idx]
- m
+ quoteForm m
compRepeatOrCollect(form,m,e) ==
fn(form,[m,:$exitModeStack],[#$exitModeStack,:$leaveLevelStack],$formalArgList
diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot
index 1104d4ec..f3a29f81 100644
--- a/src/interp/g-opt.boot
+++ b/src/interp/g-opt.boot
@@ -501,6 +501,7 @@ optLET_* form ==
rplac(first form,"LET")
optLET form
+
optCollectVector form ==
[.,eltType,:iters,body] := form
fromList := false -- are we drawing from a list?
@@ -511,22 +512,24 @@ optCollectVector form ==
MEMQ(op,'(SUCHTHAT WHILE UNTIL)) => fromList := true
MEMQ(op,'(IN ON)) => vecSize := [["SIZE",third iter],:vecSize]
MEMQ(op,'(STEP ISTEP)) =>
- -- pick a loop variable that we can use as the loop index.
- [.,var,lo,inc,:etc] := iter
- if lo = 0 and inc = 1 then
- index := var
- if [hi] := etc then
- sz :=
- inc = 1 =>
- lo = 1 => hi
- lo = 0 => MKQSADD1 hi
- MKQSADD1 ["-",hi,lo]
- lo = 1 => ["/",hi,inc]
- lo = 0 => ["/",MKQSADD1 hi,inc]
- ["/",["-",MKQSADD1 hi, lo],inc]
- vecSize := [sz, :vecSize]
+ -- pick a loop variable that we can use as the loop index.
+ [.,var,lo,inc,:etc] := iter
+ if lo = 0 and inc = 1 then
+ index := var
+ if [hi] := etc then
+ sz :=
+ inc = 1 =>
+ lo = 1 => hi
+ lo = 0 => MKQSADD1 hi
+ MKQSADD1 ["-",hi,lo]
+ lo = 1 => ["/",hi,inc]
+ lo = 0 => ["/",MKQSADD1 hi,inc]
+ ["/",["-",MKQSADD1 hi, lo],inc]
+ vecSize := [sz, :vecSize]
+ systemErrorHere ["optCollectVector", iter]
-- if we draw from a list, then just build a list and convert to vector.
- fromList => ["LIST2VEC",["COLLECT",:iters,body]]
+ fromList =>
+ ["homogeneousListToVector",["getVMType",eltType], ["COLLECT",:iters,body]]
vecSize = nil => systemErrorHere ["optCollectVector",form]
-- get the actual size of the vector.
vecSize :=
@@ -537,7 +540,7 @@ optCollectVector form ==
index := GENSYM()
iters := [:iters,["ISTEP",index,0,1]]
vec := GENSYM()
- ["LET",[[vec,["GETREFV",vecSize]]],
+ ["LET",[[vec,["makeSimpleArray",["getVMType",eltType],vecSize]]],
["REPEAT",:iters,["setSimpleArrayEntry",vec,index,body]],
vec]
diff --git a/src/interp/g-util.boot b/src/interp/g-util.boot
index d51b72cc..18e08c65 100644
--- a/src/interp/g-util.boot
+++ b/src/interp/g-util.boot
@@ -48,6 +48,9 @@ $interpOnly := false
--% Utility Functions of General Use
+homogeneousListToVector(t,l) ==
+ makeSimpleArrayFromList(t,l)
+
++ tests if x is an identifier beginning with #
isSharpVar x ==