aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2008-12-21 02:20:35 +0000
committerdos-reis <gdr@axiomatics.org>2008-12-21 02:20:35 +0000
commit2f4a173a01acbc47bbe855a01ea79b18d0a0c4a0 (patch)
tree4f15c7ade2b48e69c25bdf8ce7d721a5a016a6c1 /src
parent93853a12aba78b695405d9275f9ab56b01ec4269 (diff)
downloadopen-axiom-2f4a173a01acbc47bbe855a01ea79b18d0a0c4a0.tar.gz
* interp/define.boot (checkRepresentation): Take a third
argument. Provide view morphisms for domain extensions. (compCapsule): Adjust call. * algebra/alql.spad.pamphlet (DataList): Use per and rep. * algebra/fortmac.spad.pamphlet (MachineInteger): Likewise. * algebra/fortran.spad.pamphlet (FortranExpression): Likewise. * algebra/integer.spad.pamphlet (NonNegativeInteger): Likewise. (PositiveInteger): Likewise. * algebra/ituple.spad.pamphlet (InfiniteTuple): Likewise. * algebra/matrix.spad.pamphlet (RectangularMatrix): Likewise. * algebra/pf.spad.pamphlet (InnerPrimeField): Likewise. * algebra/radix.spad.pamphlet (BinaryExpansion): Likewise. (DecimalExpansion): Likewise. (HexadecimalExpansion): Likewise.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog17
-rw-r--r--src/algebra/alql.spad.pamphlet4
-rw-r--r--src/algebra/fortmac.spad.pamphlet6
-rw-r--r--src/algebra/fortran.spad.pamphlet16
-rw-r--r--src/algebra/integer.spad.pamphlet8
-rw-r--r--src/algebra/ituple.spad.pamphlet12
-rw-r--r--src/algebra/matrix.spad.pamphlet22
-rw-r--r--src/algebra/pf.spad.pamphlet2
-rw-r--r--src/algebra/radix.spad.pamphlet6
-rw-r--r--src/interp/define.boot27
10 files changed, 72 insertions, 48 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index cfbfbc30..f3b6d473 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,22 @@
2008-12-20 Gabriel Dos Reis <gdr@cs.tamu.edu>
+ * interp/define.boot (checkRepresentation): Take a third
+ argument. Provide view morphisms for domain extensions.
+ (compCapsule): Adjust call.
+ * algebra/alql.spad.pamphlet (DataList): Use per and rep.
+ * algebra/fortmac.spad.pamphlet (MachineInteger): Likewise.
+ * algebra/fortran.spad.pamphlet (FortranExpression): Likewise.
+ * algebra/integer.spad.pamphlet (NonNegativeInteger): Likewise.
+ (PositiveInteger): Likewise.
+ * algebra/ituple.spad.pamphlet (InfiniteTuple): Likewise.
+ * algebra/matrix.spad.pamphlet (RectangularMatrix): Likewise.
+ * algebra/pf.spad.pamphlet (InnerPrimeField): Likewise.
+ * algebra/radix.spad.pamphlet (BinaryExpansion): Likewise.
+ (DecimalExpansion): Likewise.
+ (HexadecimalExpansion): Likewise.
+
+2008-12-20 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
* interp/i-analy.boot (elaborateForm): New.
* interp/i-spec2.boot (uphas): Use it. Evaluate first operand.
diff --git a/src/algebra/alql.spad.pamphlet b/src/algebra/alql.spad.pamphlet
index a7f895a1..edcae0c5 100644
--- a/src/algebra/alql.spad.pamphlet
+++ b/src/algebra/alql.spad.pamphlet
@@ -29,8 +29,8 @@ DataList(S:OrderedSet) : Exports == Implementation where
elt(x,"unique") == removeDuplicates(x)
elt(x,"sort") == sort(x)
elt(x,"count") == #x
- coerce(x:List S) == x pretend %
- coerce(x:%):List S == x pretend (List S)
+ coerce(x:List S) == per x
+ coerce(x:%):List S == rep x
coerce(x:%): OutputForm == (x :: List S) :: OutputForm
datalist(x:List S) == x::%
diff --git a/src/algebra/fortmac.spad.pamphlet b/src/algebra/fortmac.spad.pamphlet
index 657d8da1..07016a41 100644
--- a/src/algebra/fortmac.spad.pamphlet
+++ b/src/algebra/fortmac.spad.pamphlet
@@ -56,11 +56,11 @@ MachineInteger(): Exports == Implementation where
abs(u) > MAXINT =>
message: S := concat [convert(u)@S," > MAXINT(",convert(MAXINT)@S,")"]
error message
- u pretend $
+ per u
- retract(u:$):Integer == u pretend Integer
+ retract(u:$):Integer == rep u
- retractIfCan(u:$):Union(Integer,"failed") == u pretend Integer
+ retractIfCan(u:$):Union(Integer,"failed") == rep u
@
\section{domain MFLOAT MachineFloat}
diff --git a/src/algebra/fortran.spad.pamphlet b/src/algebra/fortran.spad.pamphlet
index 2507beda..4c6f9cc0 100644
--- a/src/algebra/fortran.spad.pamphlet
+++ b/src/algebra/fortran.spad.pamphlet
@@ -1622,7 +1622,7 @@ FortranExpression(basicSymbols,subscriptedSymbols,R):
not empty? extras =>
m := fixUpSymbols(u)
m case EXPR(R) => m::EXPR(R)
- error("Extra symbols detected:",[string(v) for v in extras]$L(String))
+ error ["Extra symbols detected:",[string(v) for v in extras]$L(String)]
u
notSymbol?(v:BO):Boolean ==
@@ -1648,7 +1648,7 @@ FortranExpression(basicSymbols,subscriptedSymbols,R):
fortranFunctions : L S := f77Functions
extras : L S := setDifference(ops,fortranFunctions)
not empty? extras =>
- error("Non FORTRAN-77 functions detected:",[string(v) for v in extras])
+ error ["Non FORTRAN-77 functions detected:",[string(v) for v in extras]]
void()
checkForNagOperators(u:EXPR R):$ ==
@@ -1658,8 +1658,8 @@ FortranExpression(basicSymbols,subscriptedSymbols,R):
piOp : BasicOperator := operator X01AAF
piSub : Equation EXPR R :=
equation(pi()$Pi::EXPR(R),kernel(piOp,0::EXPR(R))$EXPR(R))
- subst(u,piSub) pretend $
- u pretend $
+ per subst(u,piSub)
+ per u
-- Conditional retractions:
@@ -1720,7 +1720,7 @@ FortranExpression(basicSymbols,subscriptedSymbols,R):
pi():$ == kernel(operator X01AAF,0)
- coerce(u:$):EXPR R == u pretend EXPR(R)
+ coerce(u:$):EXPR R == rep u
retractIfCan(u:EXPR R):Union($,"failed") ==
if (extraSymbols? u) then
@@ -1738,12 +1738,12 @@ FortranExpression(basicSymbols,subscriptedSymbols,R):
retractIfCan(u:Symbol):Union($,"failed") ==
not (member?(u,basicSymbols) or
scripted?(u) and member?(name u,subscriptedSymbols)) => "failed"
- (((u::EXPR(R))$(EXPR R))pretend Rep)::$
+ per (u::EXPR(R))
retract(u:Symbol):$ ==
res : Union($,"failed") := retractIfCan(u)
- res case "failed" => error("Illegal Symbol Detected:",u::String)
- res::$
+ res case "failed" => error ["Illegal Symbol Detected:",u::String]
+ res
@
\section{License}
diff --git a/src/algebra/integer.spad.pamphlet b/src/algebra/integer.spad.pamphlet
index ad958900..1d0009a0 100644
--- a/src/algebra/integer.spad.pamphlet
+++ b/src/algebra/integer.spad.pamphlet
@@ -281,9 +281,9 @@ NonNegativeInteger: Join(OrderedAbelianMonoidSup,Monoid) with
sup(x,y) == MAX(x,y)$Lisp
shift(x:%, n:Integer):% == ASH(x,n)$Lisp
subtractIfCan(x, y) ==
- c:Integer := (x pretend Integer) - (y pretend Integer)
+ c:Integer := rep x - rep y
c < 0 => "failed"
- c pretend %
+ per c
@
@@ -304,9 +304,7 @@ PositiveInteger: Join(OrderedAbelianSemiGroup,Monoid) with
++ positive integers \spad{a} and b.
commutative("*")
++ commutative("*") means multiplication is commutative : x*y = y*x
- == SubDomain(NonNegativeInteger,#1 > 0) add
- x:%
- y:%
+ == SubDomain(NonNegativeInteger,#1 > 0)
@
diff --git a/src/algebra/ituple.spad.pamphlet b/src/algebra/ituple.spad.pamphlet
index c47f99be..190ae035 100644
--- a/src/algebra/ituple.spad.pamphlet
+++ b/src/algebra/ituple.spad.pamphlet
@@ -45,13 +45,11 @@ InfiniteTuple(S:Type): Exports == Implementation where
++ construct(t) converts an infinite tuple to a stream.
Implementation ==> Stream S add
- generate(f,x) == generate(f,x)$Stream(S) pretend %
- filterWhile(f, x) == filterWhile(f,x pretend Stream(S))$Stream(S) pretend %
- filterUntil(f, x) == filterUntil(f,x pretend Stream(S))$Stream(S) pretend %
- select(f, x) == select(f,x pretend Stream(S))$Stream(S) pretend %
- construct x == x pretend Stream(S)
--- coerce x ==
--- coerce(x)$Stream(S)
+ generate(f,x) == per generate(f,x)$Stream(S)
+ filterWhile(f, x) == per filterWhile(f,rep x)$Stream(S)
+ filterUntil(f, x) == per filterUntil(f,rep x)$Stream(S)
+ select(f, x) == per select(f,rep x)$Stream(S)
+ construct x == rep x
@
diff --git a/src/algebra/matrix.spad.pamphlet b/src/algebra/matrix.spad.pamphlet
index 660a5de4..d017dc19 100644
--- a/src/algebra/matrix.spad.pamphlet
+++ b/src/algebra/matrix.spad.pamphlet
@@ -293,10 +293,10 @@ RectangularMatrix(m,n,R): Exports == Implementation where
mini ==> minIndex
maxi ==> maxIndex
- ZERO := new(m,n,0)$Matrix(R) pretend $
+ ZERO := per new(m,n,0)$Matrix(R)
0 == ZERO
- coerce(x:$):OutputForm == coerce(x pretend Matrix R)$Matrix(R)
+ coerce(x:$):OutputForm == rep(x)::OutputForm
matrix(l: List List R) ==
-- error check: this is a top level function
@@ -307,28 +307,28 @@ RectangularMatrix(m,n,R): Exports == Implementation where
for i in minr(ans)..maxr(ans) for ll in l repeat
for j in minc(ans)..maxc(ans) for r in ll repeat
qsetelt_!(ans,i,j,r)
- ans pretend $
+ per ans
- row(x,i) == directProduct row(x pretend Matrix(R),i)
- column(x,j) == directProduct column(x pretend Matrix(R),j)
+ row(x,i) == directProduct row(rep x,i)
+ column(x,j) == directProduct column(rep x,j)
- coerce(x:$):Matrix(R) == copy(x pretend Matrix(R))
+ coerce(x:$):Matrix(R) == copy rep x
rectangularMatrix x ==
(nrows(x) ~= m) or (ncols(x) ~= n) =>
error "rectangularMatrix: matrix of bad dimensions"
- copy(x) pretend $
+ per copy(x)
if R has EuclideanDomain then
- rowEchelon x == rowEchelon(x pretend Matrix(R)) pretend $
+ rowEchelon x == per rowEchelon(rep x)
if R has IntegralDomain then
- rank x == rank(x pretend Matrix(R))
- nullity x == nullity(x pretend Matrix(R))
+ rank x == rank rep x
+ nullity x == nullity rep x
nullSpace x ==
- [directProduct c for c in nullSpace(x pretend Matrix(R))]
+ [directProduct c for c in nullSpace rep x]
if R has Field then
diff --git a/src/algebra/pf.spad.pamphlet b/src/algebra/pf.spad.pamphlet
index 4eaf3fbf..21b8979a 100644
--- a/src/algebra/pf.spad.pamphlet
+++ b/src/algebra/pf.spad.pamphlet
@@ -84,7 +84,7 @@ InnerPrimeField(p:PositiveInteger): Exports == Implementation where
zero?(n) => 1
zero?(x) => 0
r := positiveRemainder(n,p-1)::NNI
- ((x pretend IntegerMod p) **$IntegerMod(p) r) pretend $
+ per (rep(x) **$IntegerMod(p) r)
if p <= convert(max()$SingleInteger)@Integer then
q := p::SingleInteger
diff --git a/src/algebra/radix.spad.pamphlet b/src/algebra/radix.spad.pamphlet
index 80b12c4c..f5ed227e 100644
--- a/src/algebra/radix.spad.pamphlet
+++ b/src/algebra/radix.spad.pamphlet
@@ -288,7 +288,7 @@ BinaryExpansion(): Exports == Implementation where
Implementation ==> RadixExpansion(2) add
binary r == r :: %
- coerce(x:%): RadixExpansion(2) == x pretend RadixExpansion(2)
+ coerce(x:%): RadixExpansion(2) == rep x
@
\section{domain DECIMAL DecimalExpansion}
@@ -317,7 +317,7 @@ DecimalExpansion(): Exports == Implementation where
Implementation ==> RadixExpansion(10) add
decimal r == r :: %
- coerce(x:%): RadixExpansion(10) == x pretend RadixExpansion(10)
+ coerce(x:%): RadixExpansion(10) == rep x
@
\section{domain HEXADEC HexadecimalExpansion}
@@ -348,7 +348,7 @@ HexadecimalExpansion(): Exports == Implementation where
Implementation ==> RadixExpansion(16) add
hex r == r :: %
- coerce(x:%): RadixExpansion(16) == x pretend RadixExpansion(16)
+ coerce(x:%): RadixExpansion(16) == rep x
@
\section{package RADUTIL RadixUtilities}
diff --git a/src/interp/define.boot b/src/interp/define.boot
index ab46b80c..75e33ecc 100644
--- a/src/interp/define.boot
+++ b/src/interp/define.boot
@@ -182,13 +182,13 @@ insertViewMorphisms(t,e) ==
++ per: Rep -> %
++ rep: % -> Rep
++ as local inline functions.
-checkRepresentation: (%Form,%List) -> %Form
-checkRepresentation(addForm,body) ==
+checkRepresentation: (%Form,%List,%Env) -> %Env
+checkRepresentation(addForm,body,env) ==
domainRep := nil
hasAssignRep := false -- assume code does not assign to Rep.
viewFuns := nil
- null body => body -- Don't be too hard on nothing.
+ null body => env -- Don't be too hard on nothing.
-- Locate possible Rep definition
for [stmt,:.] in tails body repeat
@@ -204,8 +204,7 @@ checkRepresentation(addForm,body) ==
stackWarning('"Consider using == definition for %1b",["Rep"])
return hasAssignRep := true
stmt is ["IF",.,:l] or stmt is ["SEQ",:l] or stmt is ["exit",:l] =>
- checkRepresentation(addForm,l)
- $useRepresentationHack => return hasAssignRep := true
+ checkRepresentation(nil,l,env)
stmt isnt ["DEF",[op,:args],sig,.,val] => nil -- skip for now.
op in '(rep per) =>
domainRep ^= nil =>
@@ -234,7 +233,19 @@ checkRepresentation(addForm,body) ==
-- Shall we perform the dirty tricks?
if hasAssignRep then
$useRepresentationHack := true
- body
+ -- Domain extensions with no explicit Rep definition have the
+ -- the base domain as representation (at least operationally).
+ else if null domainRep and addForm ^= nil then
+ if $functorKind = "domain" and addForm isnt ["%Comma",:.] then
+ domainRep :=
+ addForm is ["SubDomain",dom,.] => dom
+ addForm
+ base := compForMode(domainRep,$EmptyMode,env) or
+ stackAndThrow('"1b is not a domain",[domainRep])
+ $useRepresentationHack := false
+ env := insertViewMorphisms(base.expr,env)
+ -- ??? Maybe we should also make Rep available as macro.
+ env
compDefine1: (%Form,%Mode,%Env) -> %Maybe %Triple
@@ -1424,8 +1435,8 @@ compCapsule(['CAPSULE,:itemList],m,e) ==
$insideExpressionIfTrue: local:= false
$useRepresentationHack := true
clearCapsuleFunctionTable()
- compCapsuleInner(checkRepresentation($addFormLhs,itemList),m,
- addDomain('_$,e))
+ e := checkRepresentation($addFormLhs,itemList,e)
+ compCapsuleInner(itemList,m,addDomain('_$,e))
compSubDomain(["SubDomain",domainForm,predicate],m,e) ==
$addFormLhs: local:= domainForm