diff options
author | dos-reis <gdr@axiomatics.org> | 2012-01-08 14:55:53 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2012-01-08 14:55:53 +0000 |
commit | c95f1b3efced12df21e9e99369cdb1a0a7d8ec2d (patch) | |
tree | bb14c435c048163f87a83ae27366415fd753372f /src/boot | |
parent | 041f2e9f7c59fd11a182760e31dd3bdb75d3ea79 (diff) | |
download | open-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/boot')
-rw-r--r-- | src/boot/ast.boot | 3 | ||||
-rw-r--r-- | src/boot/strap/ast.clisp | 3 | ||||
-rw-r--r-- | src/boot/strap/translator.clisp | 41 | ||||
-rw-r--r-- | src/boot/translator.boot | 4 |
4 files changed, 34 insertions, 17 deletions
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 |