diff options
author | dos-reis <gdr@axiomatics.org> | 2010-06-26 20:21:15 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2010-06-26 20:21:15 +0000 |
commit | 7eabcc6358795f6a44b3771cb0cb1b659a5d08f3 (patch) | |
tree | 45c4302ea936e8045fcd15ff18ad53a3bc15946f /src | |
parent | 1a500aa511c69c769afc27e0c0f786db54167f19 (diff) | |
download | open-axiom-7eabcc6358795f6a44b3771cb0cb1b659a5d08f3.tar.gz |
* interp/g-opt.boot ($VMsideEffectFreeOperators): Include %vref
and %vlength.
* interp/g-util.boot: Expand them.
* algebra/array1.spad.pamphlet (PrimitiveArray): Use them.
(IndexedOneDimensionalArray): Likewise.
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 8 | ||||
-rw-r--r-- | src/algebra/array1.spad.pamphlet | 38 | ||||
-rw-r--r-- | src/interp/g-opt.boot | 3 | ||||
-rw-r--r-- | src/interp/g-util.boot | 5 |
4 files changed, 34 insertions, 20 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 61418877..0a6758d4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,13 @@ 2010-06-26 Gabriel Dos Reis <gdr@cs.tamu.edu> + * interp/g-opt.boot ($VMsideEffectFreeOperators): Include %vref + and %vlength. + * interp/g-util.boot: Expand them. + * algebra/array1.spad.pamphlet (PrimitiveArray): Use them. + (IndexedOneDimensionalArray): Likewise. + +2010-06-26 Gabriel Dos Reis <gdr@cs.tamu.edu> + * algebra/aggcat.spad.pamphlet (HomogeneousAggregate): Satisfy BasicType if element type satisfies it. diff --git a/src/algebra/array1.spad.pamphlet b/src/algebra/array1.spad.pamphlet index 3f93b26f..0d4257e8 100644 --- a/src/algebra/array1.spad.pamphlet +++ b/src/algebra/array1.spad.pamphlet @@ -15,8 +15,10 @@ ++ This provides a fast array type with no bound checking on elt's. ++ Minimum index is 0 in this type, cannot be changed PrimitiveArray(S:Type): OneDimensionalArrayAggregate S == add - #x == - sizeOfSimpleArray(x)$Lisp + import %vlength: % -> NonNegativeInteger from Foreign Builtin + import %vref: (%,Integer) -> S from Foreign Builtin + + #x == %vlength x minIndex x == 0 @@ -30,11 +32,8 @@ PrimitiveArray(S:Type): OneDimensionalArrayAggregate S == add new(n, x) == makeFilledSimpleArray(getVMType(S)$Lisp,n,x)$Lisp - qelt(x, i) == - getSimpleArrayEntry(x,i)$Lisp - - elt(x:%, i:Integer) == - getSimpleArrayEntry(x,i)$Lisp + qelt(x, i) == %vref(x,i) + elt(x:%, i:Integer) == %vref(x,i) qsetelt!(x, i, s) == setSimpleArrayEntry(x,i,s)$Lisp @@ -371,9 +370,10 @@ FlexibleArray(S: Type) == Implementation where IndexedOneDimensionalArray(S:Type, mn:Integer): OneDimensionalArrayAggregate S == add + import %vlength: % -> NonNegativeInteger from Foreign Builtin + import %vref: (%,Integer) -> S from Foreign Builtin + macro Qmax == maxIndexOfSimpleArray$Foreign(Builtin) - macro Qsize == sizeOfSimpleArray$Foreign(Builtin) - macro Qelt == getSimpleArrayEntry$Foreign(Builtin) macro Qsetelt == setSimpleArrayEntry$Foreign(Builtin) macro I == Integer Rep == PrimitiveArray S @@ -393,14 +393,14 @@ IndexedOneDimensionalArray(S:Type, mn:Integer): map!(f, s1) == n: Integer := Qmax(s1) n < 0 => s1 - for i in 0..n repeat Qsetelt(s1, i, f(Qelt(s1,i))) + for i in 0..n repeat Qsetelt(s1, i, f(%vref(s1,i))) s1 map(f, s1) == n:Integer := Qmax(s1) n < 0 => s1 ss2:% := newArray(n+1) - for i in 0..n repeat Qsetelt(ss2, i, f(Qelt(s1,i))) + for i in 0..n repeat Qsetelt(ss2, i, f(%vref(s1,i))) ss2 map(f, a, b) == @@ -408,11 +408,11 @@ IndexedOneDimensionalArray(S:Type, mn:Integer): maxind < 0 => empty() c:% := newArray(maxind+1) for i in 0..maxind repeat - Qsetelt(c, i, f(Qelt(a,i),Qelt(b,i))) + Qsetelt(c, i, f(%vref(a,i),%vref(b,i))) c if zero? mn then - qelt(x, i) == Qelt(x, i) + qelt(x, i) == %vref(x, i) qsetelt!(x, i, s) == Qsetelt(x, i, s) elt(x:%, i:I) == @@ -424,22 +424,22 @@ IndexedOneDimensionalArray(S:Type, mn:Integer): qsetelt!(x, i, s) else if one? mn then - maxIndex x == Qsize x - qelt(x, i) == Qelt(x, i-1) + maxIndex x == %vlength x + qelt(x, i) == %vref(x, i-1) qsetelt!(x, i, s) == Qsetelt(x, i-1, s) elt(x:%, i:I) == - QSLESSP(i,1$Lisp)$Lisp or QSLESSP(Qsize x,i)$Lisp => + QSLESSP(i,1$Lisp)$Lisp or QSLESSP(%vlength x,i)$Lisp => error "index out of range" - Qelt(x, i-1) + %vref(x, i-1) setelt(x:%, i:I, s:S) == - QSLESSP(i,1$Lisp)$Lisp or QSLESSP(Qsize x,i)$Lisp => + QSLESSP(i,1$Lisp)$Lisp or QSLESSP(%vlength x,i)$Lisp => error "index out of range" Qsetelt(x, i-1, s) else - qelt(x, i) == Qelt(x, i - mn) + qelt(x, i) == %vref(x, i - mn) qsetelt!(x, i, s) == Qsetelt(x, i - mn, s) elt(x:%, i:I) == diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot index d526f439..8c7c4a10 100644 --- a/src/interp/g-opt.boot +++ b/src/interp/g-opt.boot @@ -478,7 +478,8 @@ $VMsideEffectFreeOperators == %fpow %fdiv %fneg %i2f %fminval %fmaxval %fbase %fprec %ftrunc %nil %pair? %lconcat %llength %lfirst %lsecond %lthird %lreverse %lempty? %hash %ismall? %string? %f2s - %ceq %clt %cle %cgt %cge %c2i %i2c) + %ceq %clt %cle %cgt %cge %c2i %i2c + %vref %vlength) ++ List of simple VM operators $simpleVMoperators == diff --git a/src/interp/g-util.boot b/src/interp/g-util.boot index b718e253..97519045 100644 --- a/src/interp/g-util.boot +++ b/src/interp/g-util.boot @@ -372,6 +372,11 @@ for x in [ -- binary list operations ['%lconcat, :'APPEND], + -- simple vector operations + ['%vfill, :'FILL], + ['%vlength, :'sizeOfSimpleArray], + ['%vref, :'getSimpleArrayEntry], + -- symbol unary functions ['%gensym, :'GENSYM], |