diff options
author | dos-reis <gdr@axiomatics.org> | 2008-04-21 15:16:32 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2008-04-21 15:16:32 +0000 |
commit | a04a446805a1108cd19f633878ca367629c23f4b (patch) | |
tree | d7b057f8b144184299ae72c0f91ad12e320a6157 /src/algebra | |
parent | b136bc01f60d2baa53148919ee04828dbe9e53b1 (diff) | |
download | open-axiom-a04a446805a1108cd19f633878ca367629c23f4b.tar.gz |
Add support for byte values, and byte buffers.
Diffstat (limited to 'src/algebra')
-rw-r--r-- | src/algebra/Makefile.in | 6 | ||||
-rw-r--r-- | src/algebra/Makefile.pamphlet | 6 | ||||
-rw-r--r-- | src/algebra/array1.spad.pamphlet | 100 | ||||
-rw-r--r-- | src/algebra/data.spad.pamphlet | 102 | ||||
-rw-r--r-- | src/algebra/exposed.lsp.pamphlet | 2 |
5 files changed, 168 insertions, 48 deletions
diff --git a/src/algebra/Makefile.in b/src/algebra/Makefile.in index ea22eb05..168617e9 100644 --- a/src/algebra/Makefile.in +++ b/src/algebra/Makefile.in @@ -378,7 +378,7 @@ axiom_algebra_layer_1 = \ AGG AGG- IEVALAB IEVALAB- FORTCAT ITUPLE \ PATAB PPCURVE PSCURVE REAL RESLATC RETRACT \ RETRACT- SEGCAT BINDING SYNTAX BMODULE LOGIC \ - LOGIC- EVALAB EVALAB- FEVALAB FEVALAB- + LOGIC- EVALAB EVALAB- FEVALAB FEVALAB- BYTE axiom_algebra_layer_1_nrlibs = \ $(addsuffix .NRLIB/code.$(FASLEXT),$(axiom_algebra_layer_1)) @@ -389,7 +389,7 @@ axiom_algebra_layer_1_objects = \ axiom_algebra_layer_2 = \ ELTAGG ELTAGG- FMC FMFUN FORTFN FVC \ CTORCALL FVFUN INTRET IXAGG IXAGG- SEGXCAT \ - CONTOUR LIST3 MKFUNC OASGP + CONTOUR LIST3 MKFUNC OASGP axiom_algebra_layer_2_nrlibs = \ $(addsuffix .NRLIB/code.$(FASLEXT),$(axiom_algebra_layer_2)) @@ -552,7 +552,7 @@ axiom_algebra_layer_11_objects = \ axiom_algebra_layer_12 = \ DIOPS DIOPS- DIAGG DIAGG- BITS DIRPROD2 IMATRIX \ IVECTOR LPOLY LSMP LSMP1 MATCAT2 PTCAT TRIMAT \ - FSAGG FSAGG- SYSTEM + FSAGG FSAGG- SYSTEM BYTEARY axiom_algebra_layer_12_nrlibs = \ $(addsuffix .NRLIB/code.$(FASLEXT),$(axiom_algebra_layer_12)) diff --git a/src/algebra/Makefile.pamphlet b/src/algebra/Makefile.pamphlet index 91499e2f..129123b8 100644 --- a/src/algebra/Makefile.pamphlet +++ b/src/algebra/Makefile.pamphlet @@ -218,7 +218,7 @@ axiom_algebra_layer_1 = \ AGG AGG- IEVALAB IEVALAB- FORTCAT ITUPLE \ PATAB PPCURVE PSCURVE REAL RESLATC RETRACT \ RETRACT- SEGCAT BINDING SYNTAX BMODULE LOGIC \ - LOGIC- EVALAB EVALAB- FEVALAB FEVALAB- + LOGIC- EVALAB EVALAB- FEVALAB FEVALAB- BYTE axiom_algebra_layer_1_nrlibs = \ $(addsuffix .NRLIB/code.$(FASLEXT),$(axiom_algebra_layer_1)) @@ -236,7 +236,7 @@ axiom_algebra_layer_1_objects = \ axiom_algebra_layer_2 = \ ELTAGG ELTAGG- FMC FMFUN FORTFN FVC \ CTORCALL FVFUN INTRET IXAGG IXAGG- SEGXCAT \ - CONTOUR LIST3 MKFUNC OASGP + CONTOUR LIST3 MKFUNC OASGP axiom_algebra_layer_2_nrlibs = \ $(addsuffix .NRLIB/code.$(FASLEXT),$(axiom_algebra_layer_2)) @@ -544,7 +544,7 @@ axiom_algebra_layer_11_objects = \ axiom_algebra_layer_12 = \ DIOPS DIOPS- DIAGG DIAGG- BITS DIRPROD2 IMATRIX \ IVECTOR LPOLY LSMP LSMP1 MATCAT2 PTCAT TRIMAT \ - FSAGG FSAGG- SYSTEM + FSAGG FSAGG- SYSTEM BYTEARY axiom_algebra_layer_12_nrlibs = \ $(addsuffix .NRLIB/code.$(FASLEXT),$(axiom_algebra_layer_12)) 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 1 3 0 6 18 0 6 1 2 0 6 18 - 0 1 3 0 6 0 9 6 16 2 0 6 0 9 14 2 7 9 + 0 1 3 0 6 0 9 6 15 2 0 6 0 9 13 2 7 9 6 0 1 3 7 9 6 0 9 1 2 0 9 23 0 1 1 0 - 20 0 1 2 0 0 7 6 13 2 0 19 0 7 1 1 6 + 20 0 1 2 0 0 7 6 12 2 0 19 0 7 1 1 6 9 0 10 2 5 0 0 0 1 2 5 0 0 0 1 3 0 0 24 0 0 1 1 0 20 0 1 2 7 19 6 0 1 1 6 9 0 1 2 5 0 0 0 1 2 0 0 27 0 1 3 0 0 18 0 0 1 2 0 0 27 0 1 2 0 19 0 7 1 1 7 30 0 1 3 0 0 0 0 9 1 3 0 0 6 0 9 1 1 0 34 0 1 2 0 19 9 0 1 1 7 31 0 1 1 - 6 6 0 1 2 0 33 23 0 1 2 0 0 0 6 12 2 + 6 6 0 1 2 0 33 23 0 1 2 0 0 0 6 17 2 0 19 23 0 1 3 8 0 0 20 20 1 2 8 0 0 21 1 3 8 0 0 6 6 1 2 8 0 0 22 1 2 0 19 0 0 1 2 7 19 6 0 1 1 0 20 0 1 1 0 19 0 1 0 0 0 11 2 0 0 0 25 1 2 0 6 0 - 9 15 3 0 6 0 9 6 1 2 0 0 0 9 1 2 0 0 + 9 14 3 0 6 0 9 6 1 2 0 0 0 9 1 2 0 0 0 25 1 2 7 7 6 0 1 2 0 7 23 0 1 3 0 0 0 0 9 1 1 0 0 0 1 1 3 29 0 1 1 0 0 20 1 1 0 0 32 1 2 0 0 6 0 1 2 0 0 0 0 1 diff --git a/src/algebra/data.spad.pamphlet b/src/algebra/data.spad.pamphlet new file mode 100644 index 00000000..b67fca76 --- /dev/null +++ b/src/algebra/data.spad.pamphlet @@ -0,0 +1,102 @@ +\documentclass{article} +\usepackage{axiom} + +\author{Gabriel Dos~Reis} + +\begin{document} + +\begin{abstract} +\end{abstract} + +\tableofcontents +\eject + +\section{The Byte domain} + +<<domain BYTE Byte>>= +import NonNegativeInteger +import OutputForm +)abbrev domain BYTE Byte +++ Author: Gabriel Dos Reis +++ Date Created: April 19, 2008 +++ Related Constructor: +++ Description: +++ Byte is the datatype of 8-bit sized unsigned integer values. +Byte(): Public == Private where + Public ==> Join(OrderedSet, CoercibleTo NonNegativeInteger) with + coerce: NonNegativeInteger -> % + ++ coerce(x) injects the unsigned integer value `v' into + ++ the Byte algebra. `v' must be non-negative and less than 256. + + Private ==> add + coerce(x: NonNegativeInteger): % == + byteGreaterEqual(x,256$Lisp)$Lisp => + userError "integer value cannot be represented by a byte" + x : % + + coerce(x: %): NonNegativeInteger == + x : NonNegativeInteger + + coerce(x: %): OutputForm == + x::NonNegativeInteger::OutputForm + + x < y == + byteLessThan(x,y)$Lisp +@ + + +\section{The ByteArray domain} + +<<domain BYTEARY ByteArray>>= +import PrimitiveArray +import Byte +)abbrev domain BYTEARY ByteArray +++ Author: Gabriel Dos Reis +++ Date Created: April 19, 2008 +++ Related Constructor: +++ Description: +++ ByteArray provides datatype for fix-sized buffer of bytes. +ByteArray() == PrimitiveArray Byte +@ + + +\section{License} +<<license>>= +--Copyright (C) 2007-2008, Gabriel Dos Reis. +--All rights reserved. +-- +--Redistribution and use in source and binary forms, with or without +--modification, are permitted provided that the following conditions are +--met: +-- +-- - Redistributions of source code must retain the above copyright +-- notice, this list of conditions and the following disclaimer. +-- +-- - Redistributions in binary form must reproduce the above copyright +-- notice, this list of conditions and the following disclaimer in +-- the documentation and/or other materials provided with the +-- distribution. +-- +-- - Neither the name of The Numerical Algorithms Group Ltd. nor the +-- names of its contributors may be used to endorse or promote products +-- derived from this software without specific prior written permission. +-- +--THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +--IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +--TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +--PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER +--OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +--EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +--PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +--PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +--LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +--NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +--SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +@ + + +<<*>>= +<<license>> +<<domain BYTE Byte>> +<<domain BYTEARY ByteArray>> +@ diff --git a/src/algebra/exposed.lsp.pamphlet b/src/algebra/exposed.lsp.pamphlet index 2492f004..ed69e324 100644 --- a/src/algebra/exposed.lsp.pamphlet +++ b/src/algebra/exposed.lsp.pamphlet @@ -74,6 +74,8 @@ (|Binding| . BINDING) (|Bits| . BITS) (|Boolean| . BOOLEAN) + (|Byte| . BYTE) + (|ByteArray| . BYTEARY) (|CardinalNumber| . CARD) (|CartesianTensor| . CARTEN) (|CartesianTensorFunctions2| . CARTEN2) |