aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2012-01-08 14:55:53 +0000
committerdos-reis <gdr@axiomatics.org>2012-01-08 14:55:53 +0000
commitc95f1b3efced12df21e9e99369cdb1a0a7d8ec2d (patch)
treebb14c435c048163f87a83ae27366415fd753372f /src
parent041f2e9f7c59fd11a182760e31dd3bdb75d3ea79 (diff)
downloadopen-axiom-c95f1b3efced12df21e9e99369cdb1a0a7d8ec2d.tar.gz
* boot/ast.boot (bfEnum): New.
* boot/translator.boot (translateToplevel): Use it to translate enumeration definitions. * interp/types.boot (%ConstructorKind): Use new syntax.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/boot/ast.boot3
-rw-r--r--src/boot/strap/ast.clisp3
-rw-r--r--src/boot/strap/translator.clisp41
-rw-r--r--src/boot/translator.boot4
-rw-r--r--src/interp/types.boot4
6 files changed, 43 insertions, 19 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 9a089bd6..5f30c52b 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
+2012-01-08 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * boot/ast.boot (bfEnum): New.
+ * boot/translator.boot (translateToplevel): Use it to translate
+ enumeration definitions.
+ * interp/types.boot (%ConstructorKind): Use new syntax.
+
2012-01-01 Gabriel Dos Reis <gdr@cs.tamu.edu>
* interp/define.boot (evalCategoryForm): New.
diff --git a/src/boot/ast.boot b/src/boot/ast.boot
index 656fdceb..23bd1425 100644
--- a/src/boot/ast.boot
+++ b/src/boot/ast.boot
@@ -1312,6 +1312,9 @@ bfDs n ==
n = 0 => '""
strconc('"D",bfDs(n-1))
+bfEnum(t,csts) ==
+ ['DEFTYPE,t,nil,backquote(['MEMBER,:csts],nil)]
+
bfHandlers(n,e,hs) == main(n,e,hs,nil) where
main(n,e,hs,xs) ==
hs = nil =>
diff --git a/src/boot/strap/ast.clisp b/src/boot/strap/ast.clisp
index b0c40086..e90f8223 100644
--- a/src/boot/strap/ast.clisp
+++ b/src/boot/strap/ast.clisp
@@ -2329,6 +2329,9 @@
(DEFUN |bfDs| (|n|) (COND ((EQL |n| 0) "") (T (CONCAT "D" (|bfDs| (- |n| 1))))))
+(DEFUN |bfEnum| (|t| |csts|)
+ (LIST 'DEFTYPE |t| NIL (|backquote| (CONS 'MEMBER |csts|) NIL)))
+
(DEFUN |bfHandlers| (|n| |e| |hs|) (|bfHandlers,main| |n| |e| |hs| NIL))
(DEFUN |bfHandlers,main| (|n| |e| |hs| |xs|)
diff --git a/src/boot/strap/translator.clisp b/src/boot/strap/translator.clisp
index 4294b1ba..eec8f45e 100644
--- a/src/boot/strap/translator.clisp
+++ b/src/boot/strap/translator.clisp
@@ -609,7 +609,7 @@
(T |x|)))))
(DEFUN |translateToplevel| (|b| |export?|)
- (PROG (|lhs| |t| |ISTMP#2| |sig| |ns| |n| |ISTMP#1| |xs|)
+ (PROG (|csts| |lhs| |t| |ISTMP#2| |sig| |ns| |n| |ISTMP#1| |xs|)
(DECLARE
(SPECIAL |$currentModuleName| |$foreignsDefsForCLisp|
|$constantIdentifiers| |$InteractiveMode| |$activeNamespace|))
@@ -725,21 +725,30 @@
(|bfMDef| |op| |args| |body|)))
(|%Structure|
(LET ((|t| (CADR |b|)) (|alts| (CADDR |b|)))
- (LET ((|bfVar#5| NIL)
- (|bfVar#6| NIL)
- (|bfVar#4| |alts|)
- (|alt| NIL))
- (LOOP
- (COND
- ((OR (NOT (CONSP |bfVar#4|))
- (PROGN (SETQ |alt| (CAR |bfVar#4|)) NIL))
- (RETURN |bfVar#5|))
- ((NULL |bfVar#5|)
- (SETQ |bfVar#5| #2=(CONS (|bfCreateDef| |alt|) NIL))
- (SETQ |bfVar#6| |bfVar#5|))
- (T (RPLACD |bfVar#6| #2#)
- (SETQ |bfVar#6| (CDR |bfVar#6|))))
- (SETQ |bfVar#4| (CDR |bfVar#4|))))))
+ (COND
+ ((AND (CONSP |alts|) (NULL (CDR |alts|))
+ (PROGN
+ (SETQ |ISTMP#1| (CAR |alts|))
+ (AND (CONSP |ISTMP#1|)
+ (EQ (CAR |ISTMP#1|) '|Enumeration|)
+ (PROGN (SETQ |csts| (CDR |ISTMP#1|)) T))))
+ (LIST (|bfEnum| |t| |csts|)))
+ (T
+ (LET ((|bfVar#5| NIL)
+ (|bfVar#6| NIL)
+ (|bfVar#4| |alts|)
+ (|alt| NIL))
+ (LOOP
+ (COND
+ ((OR (NOT (CONSP |bfVar#4|))
+ (PROGN (SETQ |alt| (CAR |bfVar#4|)) NIL))
+ (RETURN |bfVar#5|))
+ ((NULL |bfVar#5|)
+ (SETQ |bfVar#5| #2=(CONS (|bfCreateDef| |alt|) NIL))
+ (SETQ |bfVar#6| |bfVar#5|))
+ (T (RPLACD |bfVar#6| #2#)
+ (SETQ |bfVar#6| (CDR |bfVar#6|))))
+ (SETQ |bfVar#4| (CDR |bfVar#4|))))))))
(|%Namespace|
(LET ((|n| (CADR |b|)))
(PROGN
diff --git a/src/boot/translator.boot b/src/boot/translator.boot
index a58f55eb..ec035b43 100644
--- a/src/boot/translator.boot
+++ b/src/boot/translator.boot
@@ -479,7 +479,9 @@ translateToplevel(b,export?) ==
%Macro(op,args,body) => bfMDef(op,args,body)
- %Structure(t,alts) => [bfCreateDef alt for alt in alts]
+ %Structure(t,alts) =>
+ alts is [['Enumeration,:csts]] => [bfEnum(t,csts)]
+ [bfCreateDef alt for alt in alts]
%Namespace n =>
$activeNamespace := symbolName n
diff --git a/src/interp/types.boot b/src/interp/types.boot
index 915279ee..592c70e5 100644
--- a/src/interp/types.boot
+++ b/src/interp/types.boot
@@ -43,5 +43,5 @@ namespace BOOT
%Modemap <=> %List(%Form) -- modemap
-%ConstructorKind <=> -- kind of ctor instances
- MEMBER(category,domain,package)
+structure %ConstructorKind == -- kind of ctor instances
+ Enumeration(category,domain,package)