diff options
author | dos-reis <gdr@axiomatics.org> | 2008-01-28 21:13:46 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2008-01-28 21:13:46 +0000 |
commit | 1eac6c122d6a62d8ce3eeced8c3b1b6b97108498 (patch) | |
tree | 82aa9a05557e7fc955c32c164eee167045de9917 /src/boot | |
parent | a27cc2ac7bf6a0ad60cc6c9f949a988d0444bb4e (diff) | |
download | open-axiom-1eac6c122d6a62d8ce3eeced8c3b1b6b97108498.tar.gz |
Support signature declaration in Boot.
* boot/ast.boot (bfUntuple): New.
(bfTagged): Toplevel tags are signatures.
* boot/parser.boot (bpTyping): New.
(bpTagged): Use it.
* boot/translator.boot (genDeclaration): New.
(bpOutItem): Use it.
* interp/compiler.boot: Add type annotations for compiler routines.
* lisp/Makefile.in ($(OUT)/lisp$(EXEEXT)): Don't turn on emit-fn.
Diffstat (limited to 'src/boot')
-rw-r--r-- | src/boot/ast.boot | 20 | ||||
-rw-r--r-- | src/boot/parser.boot | 12 | ||||
-rw-r--r-- | src/boot/translator.boot | 13 |
3 files changed, 37 insertions, 8 deletions
diff --git a/src/boot/ast.boot b/src/boot/ast.boot index 4c0c02d4..958ad11c 100644 --- a/src/boot/ast.boot +++ b/src/boot/ast.boot @@ -175,6 +175,11 @@ compFluidize x== bfTuple x== ["TUPLE",:x] bfTupleP x==EQCAR(x,"TUPLE") + +++ If `bf' is a tuple return its elements; otherwise `bf'. +bfUntuple bf == + bfTupleP bf => cdr bf + bf bfTupleIf x== if bfTupleP x @@ -914,13 +919,14 @@ shoeCompTran1 x== shoeCompTran1 cdr x bfTagged(a,b)== - IDENTP a => - EQ(b,"FLUID") => bfLET(compFluid a,NIL) - EQ(b,"fluid") => bfLET(compFluid a,NIL) - EQ(b,"local") => bfLET(compFluid a,NIL) - $typings:=cons(["TYPE",b,a],$typings) - a - ["THE",b,a] + null $op => Signature(a,b) -- surely a toplevel decl + IDENTP a => + EQ(b,"FLUID") => bfLET(compFluid a,NIL) + EQ(b,"fluid") => bfLET(compFluid a,NIL) + EQ(b,"local") => bfLET(compFluid a,NIL) + $typings:=cons(["TYPE",b,a],$typings) + a + ["THE",b,a] bfAssign(l,r)== if bfTupleP l then bfSetelt(CADR l,CDDR l ,r) else bfLET(l,r) diff --git a/src/boot/parser.boot b/src/boot/parser.boot index 9908a68a..9c41a07b 100644 --- a/src/boot/parser.boot +++ b/src/boot/parser.boot @@ -553,9 +553,19 @@ bpApplication()== (bpApplication() and bpPush(bfApplication(bpPop2(),bpPop1())) or true) +++ Typing: +++ SimpleType +++ Mapping +bpTyping() == + bpApplication() and + (bpEqKey "ARROW" and (bpApplication() or bpTrap()) and + bpPush Mapping(bpPop1(), bfUntuple bpPop1()) or true) or bpMapping() + +++ Tagged: +++ Name : Typing bpTagged()== bpApplication() and - (bpEqKey "COLON" and (bpApplication() or bpTrap()) and + (bpEqKey "COLON" and (bpTyping() or bpTrap()) and bpPush bfTagged(bpPop2(),bpPop1()) or true) bpExpt()== bpRightAssoc('(POWER),function bpTagged) diff --git a/src/boot/translator.boot b/src/boot/translator.boot index 0fc79fa0..8d866052 100644 --- a/src/boot/translator.boot +++ b/src/boot/translator.boot @@ -351,7 +351,17 @@ shoeOutParse stream == nil else CAR $stack +++ Generate a global signature declaration for symbol `n'. +genDeclaration(n,t) == + t is ["Mapping",valType,argTypes] => + if bfTupleP argTypes then argTypes := cdr argTypes + if not null argTypes and SYMBOLP argTypes + then argTypes := [argTypes] + ["DECLAIM",["FTYPE",["FUNCTION",argTypes,valType],n]] + ["DECLAIM",["TYPE",t,n]] + bpOutItem()== + $op := nil bpComma() or bpTrap() b:=bpPop1() EQCAR(b,"TUPLE")=> bpPush cdr b @@ -359,6 +369,9 @@ bpOutItem()== b is ["L%T",l,r] and IDENTP l => bpPush [["DEFPARAMETER",l,r]] case b of + Signature(op,t) => + bpPush [genDeclaration(op,t)] + Module(m) => bpPush [shoeCompileTimeEvaluation ["PROVIDE", m]] |