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/algebra | |
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/algebra')
-rw-r--r-- | src/algebra/array1.spad.pamphlet | 38 |
1 files changed, 19 insertions, 19 deletions
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) == |