aboutsummaryrefslogtreecommitdiff
path: root/src/algebra/array1.spad.pamphlet
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2008-04-21 15:16:32 +0000
committerdos-reis <gdr@axiomatics.org>2008-04-21 15:16:32 +0000
commita04a446805a1108cd19f633878ca367629c23f4b (patch)
treed7b057f8b144184299ae72c0f91ad12e320a6157 /src/algebra/array1.spad.pamphlet
parentb136bc01f60d2baa53148919ee04828dbe9e53b1 (diff)
downloadopen-axiom-a04a446805a1108cd19f633878ca367629c23f4b.tar.gz
Add support for byte values, and byte buffers.
Diffstat (limited to 'src/algebra/array1.spad.pamphlet')
-rw-r--r--src/algebra/array1.spad.pamphlet100
1 files changed, 58 insertions, 42 deletions
diff --git a/src/algebra/array1.spad.pamphlet b/src/algebra/array1.spad.pamphlet
index 86fe6cb6..87ba8034 100644
--- a/src/algebra/array1.spad.pamphlet
+++ b/src/algebra/array1.spad.pamphlet
@@ -2,7 +2,7 @@
\usepackage{axiom}
\begin{document}
\title{\$SPAD/src/algebra array1.spad}
-\author{Michael Monagan, Stephen Watt}
+\author{Gabriel Dos Reis, Michael Monagan, Stephen Watt}
\maketitle
\begin{abstract}
\end{abstract}
@@ -15,25 +15,37 @@
++ 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
- Qmax ==> QVMAXINDEX$Lisp
- Qsize ==> QVSIZE$Lisp
--- Qelt ==> QVELT$Lisp
--- Qsetelt ==> QSETVELT$Lisp
- Qelt ==> ELT$Lisp
- Qsetelt ==> SETELT$Lisp
- Qnew ==> GETREFV$Lisp
+ #x ==
+ sizeOfSimpleArray(x)$Lisp
+
+ minIndex x ==
+ 0
- #x == Qsize x
- minIndex x == 0
- empty() == Qnew(0$Lisp)
- new(n, x) == fill_!(Qnew n, x)
- qelt(x, i) == Qelt(x, i)
- elt(x:%, i:Integer) == Qelt(x, i)
- qsetelt_!(x, i, s) == Qsetelt(x, i, s)
- setelt(x:%, i:Integer, s:S) == Qsetelt(x, i, s)
- fill_!(x, s) == (for i in 0..Qmax x repeat Qsetelt(x, i, s); x)
+ empty() ==
+ makeSimpleArray(getVMType(S)$Lisp,0$Lisp)$Lisp
+
+ 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
+
+ qsetelt!(x, i, s) ==
+ setSimpleArrayEntry(x,i,s)$Lisp
+
+ setelt(x:%, i:Integer, s:S) ==
+ setSimpleArrayEntry(x,i,s)$Lisp
+
+ fill!(x, s) ==
+ for i in 0..maxIndexOfSimpleArray(x)$Lisp repeat
+ setSimpleArrayEntry(x, i, s)$Lisp
+ x
@
+
\section{PRIMARR.lsp BOOTSTRAP}
{\bf PRIMARR} depends on itself.
We need to break this cycle to build the algebra. So we keep a
@@ -48,44 +60,48 @@ Note that this code is not included in the generated catdef.spad file.
(/VERSIONCHECK 2)
-(PUT '|PRIMARR;#;$Nni;1| '|SPADreplace| 'QVSIZE)
+(PUT '|PRIMARR;#;$Nni;1| '|SPADreplace| '|sizeOfSimpleArray|)
-(DEFUN |PRIMARR;#;$Nni;1| (|x| $) (QVSIZE |x|))
+(DEFUN |PRIMARR;#;$Nni;1| (|x| $) (|sizeOfSimpleArray| |x|))
(PUT '|PRIMARR;minIndex;$I;2| '|SPADreplace| '(XLAM (|x|) 0))
(DEFUN |PRIMARR;minIndex;$I;2| (|x| $) 0)
-(PUT '|PRIMARR;empty;$;3| '|SPADreplace| '(XLAM NIL (GETREFV 0)))
-
-(DEFUN |PRIMARR;empty;$;3| ($) (GETREFV 0))
+(DEFUN |PRIMARR;empty;$;3| ($)
+ (|makeSimpleArray| (|getVMType| (|getShellEntry| $ 6)) 0))
(DEFUN |PRIMARR;new;NniS$;4| (|n| |x| $)
- (SPADCALL (GETREFV |n|) |x| (|getShellEntry| $ 12)))
+ (|makeFilledSimpleArray| (|getVMType| (|getShellEntry| $ 6)) |n| |x|))
-(PUT '|PRIMARR;qelt;$IS;5| '|SPADreplace| 'ELT)
+(PUT '|PRIMARR;qelt;$IS;5| '|SPADreplace| '|getSimpleArrayEntry|)
-(DEFUN |PRIMARR;qelt;$IS;5| (|x| |i| $) (ELT |x| |i|))
+(DEFUN |PRIMARR;qelt;$IS;5| (|x| |i| $)
+ (|getSimpleArrayEntry| |x| |i|))
-(PUT '|PRIMARR;elt;$IS;6| '|SPADreplace| 'ELT)
+(PUT '|PRIMARR;elt;$IS;6| '|SPADreplace| '|getSimpleArrayEntry|)
-(DEFUN |PRIMARR;elt;$IS;6| (|x| |i| $) (ELT |x| |i|))
+(DEFUN |PRIMARR;elt;$IS;6| (|x| |i| $)
+ (|getSimpleArrayEntry| |x| |i|))
-(PUT '|PRIMARR;qsetelt!;$I2S;7| '|SPADreplace| 'SETELT)
+(PUT '|PRIMARR;qsetelt!;$I2S;7| '|SPADreplace| '|setSimpleArrayEntry|)
-(DEFUN |PRIMARR;qsetelt!;$I2S;7| (|x| |i| |s| $) (SETELT |x| |i| |s|))
+(DEFUN |PRIMARR;qsetelt!;$I2S;7| (|x| |i| |s| $)
+ (|setSimpleArrayEntry| |x| |i| |s|))
-(PUT '|PRIMARR;setelt;$I2S;8| '|SPADreplace| 'SETELT)
+(PUT '|PRIMARR;setelt;$I2S;8| '|SPADreplace| '|setSimpleArrayEntry|)
-(DEFUN |PRIMARR;setelt;$I2S;8| (|x| |i| |s| $) (SETELT |x| |i| |s|))
+(DEFUN |PRIMARR;setelt;$I2S;8| (|x| |i| |s| $)
+ (|setSimpleArrayEntry| |x| |i| |s|))
(DEFUN |PRIMARR;fill!;$S$;9| (|x| |s| $)
(PROG (|i| #0=#:G1403)
(RETURN
(SEQ (SEQ (LETT |i| 0 |PRIMARR;fill!;$S$;9|)
- (LETT #0# (QVMAXINDEX |x|) |PRIMARR;fill!;$S$;9|) G190
- (COND ((QSGREATERP |i| #0#) (GO G191)))
- (SEQ (EXIT (SETELT |x| |i| |s|)))
+ (LETT #0# (|maxIndexOfSimpleArray| |x|)
+ |PRIMARR;fill!;$S$;9|)
+ G190 (COND ((QSGREATERP |i| #0#) (GO G191)))
+ (SEQ (EXIT (|setSimpleArrayEntry| |x| |i| |s|)))
(LETT |i| (QSADD1 |i|) |PRIMARR;fill!;$S$;9|) (GO G190)
G191 (EXIT NIL))
(EXIT |x|)))))
@@ -161,9 +177,9 @@ Note that this code is not included in the generated catdef.spad file.
(LIST '#(NIL NIL NIL NIL NIL NIL (|local| |#1|)
(|NonNegativeInteger|) |PRIMARR;#;$Nni;1| (|Integer|)
|PRIMARR;minIndex;$I;2| |PRIMARR;empty;$;3|
- |PRIMARR;fill!;$S$;9| |PRIMARR;new;NniS$;4|
- |PRIMARR;qelt;$IS;5| |PRIMARR;elt;$IS;6|
- |PRIMARR;qsetelt!;$I2S;7| |PRIMARR;setelt;$I2S;8|
+ |PRIMARR;new;NniS$;4| |PRIMARR;qelt;$IS;5|
+ |PRIMARR;elt;$IS;6| |PRIMARR;qsetelt!;$I2S;7|
+ |PRIMARR;setelt;$I2S;8| |PRIMARR;fill!;$S$;9|
(|Mapping| 6 6 6) (|Boolean|) (|List| 6) (|Equation| 6)
(|List| 21) (|Mapping| 19 6) (|Mapping| 19 6 6)
(|UniversalSegment| 9) (|Void|) (|Mapping| 6 6)
@@ -207,25 +223,25 @@ Note that this code is not included in the generated catdef.spad file.
'(2 7 19 0 0 1 3 0 26 0 9 9 1 1 5 19 0
1 2 0 19 24 0 1 1 5 0 0 1 2 0 0 24 0
1 1 5 0 0 1 2 0 0 24 0 1 2 0 19 0 7 1
- 3 0 6 0 25 6 1 3 0 6 0 9 6 17 2 0 0
+ 3 0 6 0 25 6 1 3 0 6 0 9 6 16 2 0 0
23 0 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1
7 0 0 1 2 7 0 6 0 1 2 0 0 23 0 1 4 7
6 18 0 6 6 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