aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Dos Reis <gdr@axiomatics.org>2015-12-31 17:41:40 -0800
committerGabriel Dos Reis <gdr@axiomatics.org>2015-12-31 17:41:40 -0800
commit50617665789d393c74ddbb779129fba0edd201f5 (patch)
treecdd7e4674157b52106e7bf6816afd89c71c4fa30 /src
parentf51aee83708673ef9941174951bec9aee80cb03c (diff)
downloadopen-axiom-50617665789d393c74ddbb779129fba0edd201f5.tar.gz
Don't unconditionally reference primitive types if they are being defined.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog6
-rw-r--r--src/algebra/integer.spad.pamphlet4
-rw-r--r--src/interp/compiler.boot20
3 files changed, 21 insertions, 9 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 913696d1..bb6d981b 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2015-12-31 Gabriel Dos Reis <gdr@axiomatics.org>
+
+ * interp/compiler.boot (modeIfTypeBeingDefined): New.
+ (primitiveType): Add DB parameter as first. Don't unconditionally
+ reference primitive types if they are being defined.
+
2015-12-30 Gabriel Dos Reis <gdr@axiomatics.org>
* interp/functor.boot (compCategories): Use the DB parameter is
diff --git a/src/algebra/integer.spad.pamphlet b/src/algebra/integer.spad.pamphlet
index 6838a053..6474ec28 100644
--- a/src/algebra/integer.spad.pamphlet
+++ b/src/algebra/integer.spad.pamphlet
@@ -113,7 +113,7 @@ Integer: IntegerNumberSystem with
1 == %icst1
zero? x == x = 0$%
one? x == x = 1$%
- base() == 2 pretend %
+ base() == 2@%
copy x == x
inc x == %iinc x
dec x == %idec x
@@ -133,7 +133,7 @@ Integer: IntegerNumberSystem with
latex(x:%):String ==
s := %i2s x
- -1$% < x and x < 10 => s
+ -1$% < x and x < 10@% => s
%strconc("{", %strconc(s, "}"))
positiveRemainder(a, b) ==
diff --git a/src/interp/compiler.boot b/src/interp/compiler.boot
index dbecf2ac..6bfb47fc 100644
--- a/src/interp/compiler.boot
+++ b/src/interp/compiler.boot
@@ -67,7 +67,7 @@ compFormWithModemap: (%Maybe %Database,%Form,%Mode,%Env,%Modemap) -> %Maybe %Tri
compToApply: (%Form,%List %Form,%Mode,%Env) -> %Maybe %Triple
compApplication: (%Form,%List %Form,%Mode,%Triple) -> %Maybe %Triple
-primitiveType: %Form -> %Mode
+primitiveType: (%Maybe %Database,%Form,%Mode) -> %Mode
modeEqual: (%Form,%Form) -> %Boolean
hasUniqueCaseView: (%Form,%Mode,%Env) -> %Boolean
convertOrCroak: (%Triple,%Mode) -> %Maybe %Triple
@@ -414,17 +414,23 @@ compAtom(db,x,m,e) ==
T := integer? x and x > 1 and compIntegerLiteral(db,x,m,e) => T
t :=
ident? x => compSymbol(x,m,e) or return nil
- listMember?(m,$IOFormDomains) and primitiveType x => [x,m,e]
+ listMember?(m,$IOFormDomains) and primitiveType(db,x,m) => [x,m,e]
string? x => [x,x,e]
- [x,primitiveType x or return nil,e]
+ [x,primitiveType(db,x,m) or return nil,e]
convert(t,m)
-primitiveType x ==
+modeIfTypeBeingDefined(db,t,m) ==
+ db = nil or m = $EmptyMode => t
+ substitute(dbConstructorForm db,'$,m) = t => m
+ t
+
+primitiveType(db,x,m) ==
x is nil => $EmptyMode
- string? x => $String
+ string? x => modeIfTypeBeingDefined(db,$String,m)
integer? x =>
- x = 0 => $NonNegativeInteger
- x > 0 => $PositiveInteger
+ db ~= nil and substitute(dbConstructorForm db,'$,m) = $Integer => m
+ x = 0 => modeIfTypeBeingDefined(db,$NonNegativeInteger,m)
+ x > 0 => modeIfTypeBeingDefined(db,$PositiveInteger,m)
$Integer
float? x => $DoubleFloat
nil