aboutsummaryrefslogtreecommitdiff
path: root/src/boot
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2012-05-19 21:52:28 +0000
committerdos-reis <gdr@axiomatics.org>2012-05-19 21:52:28 +0000
commit2595149525297f87d09aba5deb2b93448b3f7411 (patch)
tree583507762bcc9ae9635465ab686644482f9e3354 /src/boot
parent5d8266cb4f98511dda707ebd08123c476bc361f3 (diff)
downloadopen-axiom-2595149525297f87d09aba5deb2b93448b3f7411.tar.gz
* boot/tokens.boot: symbolBinding is now builtin.
* boot/ast.boot (%Ast): Add %Dynamic variant. (bfColonColon): Use symbolBinding instead of FIND-SYMBOLS. (compFluid): Return a %Dynamic form. Adjust callers. (shoeCompTran): Tidy. * boot/translator.boot (BOOTLOOP): Tidy. (BOOTPO): Likewise.
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/ast.boot25
-rw-r--r--src/boot/strap/ast.clisp103
-rw-r--r--src/boot/strap/tokens.clisp2
-rw-r--r--src/boot/tokens.boot1
-rw-r--r--src/boot/translator.boot8
5 files changed, 66 insertions, 73 deletions
diff --git a/src/boot/ast.boot b/src/boot/ast.boot
index 945af4bc..3e484e29 100644
--- a/src/boot/ast.boot
+++ b/src/boot/ast.boot
@@ -66,6 +66,7 @@ structure %Ast ==
%Signature(%Symbol,%Mapping) -- op: S -> T
%Mapping(%Ast, %List) -- (S1, S2) -> T
%Forall(%List,%Ast) -- forall a . a -> a
+ %Dynamic %Ast -- x: local
%SuffixDot(%Ast) -- x .
%Quote(%Ast) -- 'x
%EqualPattern(%Ast) -- =x -- patterns
@@ -87,7 +88,7 @@ structure %Ast ==
%InfixExpr(%Symbol,%Ast,%Ast) -- x + y
%ConstantDefinition(%Symbol,%Ast) -- x == y
%Definition(%Symbol,%Ast,%Ast) -- f x == y
- %Macro(%Symbol,%List,%Ast) -- m x ==> y
+ %Macro(%Symbol,%List,%Ast) -- macro m x == y
%Lambda(%List,%Ast) -- x +-> x**2
%SuchThat(%Ast) -- | p
%Assignment(%Ast,%Ast) -- x := y
@@ -143,7 +144,7 @@ bfColon x==
bfColonColon: (%Symbol,%Symbol) -> %Symbol
bfColonColon(package, name) ==
%hasFeature KEYWORD::CLISP and package in '(EXT FFI) =>
- FIND_-SYMBOL(symbolName name,package)
+ symbolBinding(symbolName name,package)
makeSymbol(symbolName name, package)
bfSymbol: %Thing -> %Thing
@@ -203,7 +204,7 @@ bfBeginsDollar x ==
stringChar(symbolName x,0) = char "$"
compFluid id ==
- ["FLUID",id]
+ ["%Dynamic",id]
compFluidize x==
x = nil => nil
@@ -536,7 +537,6 @@ bfForin(lhs,U)==
bfFor(lhs,U,1)
bfLocal(a,b)==
- b is "FLUID" => compFluid a
b is "local" => compFluid a
a
@@ -600,7 +600,7 @@ bfLetForm(lhs,rhs) ==
bfLET1(lhs,rhs) ==
symbol? lhs => bfLetForm(lhs,rhs)
- lhs is ['FLUID,.] => bfLetForm(lhs,rhs)
+ lhs is ['%Dynamic,.] => bfLetForm(lhs,rhs)
symbol? rhs and not bfCONTAINED(rhs,lhs) =>
rhs1 := bfLET2(lhs,rhs)
rhs1 is ["L%T",:.] => bfMKPROGN [rhs1,rhs]
@@ -629,7 +629,7 @@ bfCONTAINED(x,y)==
bfLET2(lhs,rhs) ==
lhs = nil => nil
symbol? lhs => bfLetForm(lhs,rhs)
- lhs is ['FLUID,.] => bfLetForm(lhs,rhs)
+ lhs is ['%Dynamic,.] => bfLetForm(lhs,rhs)
lhs is ['L%T,a,b] =>
a := bfLET2(a,rhs)
(b := bfLET2(b,rhs)) = nil => a
@@ -1013,12 +1013,8 @@ shoeCompTran x==
body' := [fvars,:body']
lvars or needsPROG body => shoePROG(lvars,body')
body'
- fl := shoeFluids args
- body :=
- fl =>
- fvs:=["DECLARE",["SPECIAL",:fl]]
- [fvs,:body]
- body
+ if fl := shoeFluids args then
+ body := [["DECLARE",["SPECIAL",:fl]],:body]
[lamtype,args,:body]
needsPROG body ==
@@ -1050,7 +1046,7 @@ isDynamicVariable x ==
symbolMember?(x,$constantIdentifiers) => false
CONSTANTP x => false
BOUNDP x or $activeNamespace = nil => true
- y := FIND_-SYMBOL(symbolName x,$activeNamespace) => not CONSTANTP y
+ y := symbolBinding(symbolName x,$activeNamespace) => not CONSTANTP y
true
false
@@ -1078,7 +1074,7 @@ shoeCompTran1 x ==
if not symbolMember?(l,$locVars) then
$locVars := [l,:$locVars]
x
- l is ["FLUID",:.] =>
+ l is ['%Dynamic,:.] =>
if not symbolMember?(second l,$fluidVars) then
$fluidVars := [second l,:$fluidVars]
x.rest.first := second l
@@ -1119,7 +1115,6 @@ shoeCompTran1 x ==
bfTagged(a,b)==
$op = nil => %Signature(a,b) -- surely a toplevel decl
symbol? a =>
- b is "FLUID" => bfLET(compFluid a,nil)
b is "local" => bfLET(compFluid a,nil)
$typings := [["TYPE",b,a],:$typings]
a
diff --git a/src/boot/strap/ast.clisp b/src/boot/strap/ast.clisp
index 092da1dd..90b857fa 100644
--- a/src/boot/strap/ast.clisp
+++ b/src/boot/strap/ast.clisp
@@ -37,102 +37,104 @@
(DEFUN |%Forall| #1=(|bfVar#16| |bfVar#17|) (CONS '|%Forall| (LIST . #1#)))
-(DEFUN |%SuffixDot| #1=(|bfVar#18|) (CONS '|%SuffixDot| (LIST . #1#)))
+(DEFUN |%Dynamic| #1=(|bfVar#18|) (CONS '|%Dynamic| (LIST . #1#)))
-(DEFUN |%Quote| #1=(|bfVar#19|) (CONS '|%Quote| (LIST . #1#)))
+(DEFUN |%SuffixDot| #1=(|bfVar#19|) (CONS '|%SuffixDot| (LIST . #1#)))
-(DEFUN |%EqualPattern| #1=(|bfVar#20|) (CONS '|%EqualPattern| (LIST . #1#)))
+(DEFUN |%Quote| #1=(|bfVar#20|) (CONS '|%Quote| (LIST . #1#)))
-(DEFUN |%Colon| #1=(|bfVar#21|) (CONS '|%Colon| (LIST . #1#)))
+(DEFUN |%EqualPattern| #1=(|bfVar#21|) (CONS '|%EqualPattern| (LIST . #1#)))
-(DEFUN |%QualifiedName| #1=(|bfVar#22| |bfVar#23|)
+(DEFUN |%Colon| #1=(|bfVar#22|) (CONS '|%Colon| (LIST . #1#)))
+
+(DEFUN |%QualifiedName| #1=(|bfVar#23| |bfVar#24|)
(CONS '|%QualifiedName| (LIST . #1#)))
-(DEFUN |%DefaultValue| #1=(|bfVar#24| |bfVar#25|)
+(DEFUN |%DefaultValue| #1=(|bfVar#25| |bfVar#26|)
(CONS '|%DefaultValue| (LIST . #1#)))
-(DEFUN |%Key| #1=(|bfVar#26| |bfVar#27|) (CONS '|%Key| (LIST . #1#)))
+(DEFUN |%Key| #1=(|bfVar#27| |bfVar#28|) (CONS '|%Key| (LIST . #1#)))
-(DEFUN |%Bracket| #1=(|bfVar#28|) (CONS '|%Bracket| (LIST . #1#)))
+(DEFUN |%Bracket| #1=(|bfVar#29|) (CONS '|%Bracket| (LIST . #1#)))
-(DEFUN |%UnboundedSegment| #1=(|bfVar#29|)
+(DEFUN |%UnboundedSegment| #1=(|bfVar#30|)
(CONS '|%UnboundedSegment| (LIST . #1#)))
-(DEFUN |%BoundedSgement| #1=(|bfVar#30| |bfVar#31|)
+(DEFUN |%BoundedSgement| #1=(|bfVar#31| |bfVar#32|)
(CONS '|%BoundedSgement| (LIST . #1#)))
-(DEFUN |%Tuple| #1=(|bfVar#32|) (CONS '|%Tuple| (LIST . #1#)))
+(DEFUN |%Tuple| #1=(|bfVar#33|) (CONS '|%Tuple| (LIST . #1#)))
-(DEFUN |%ColonAppend| #1=(|bfVar#33| |bfVar#34|)
+(DEFUN |%ColonAppend| #1=(|bfVar#34| |bfVar#35|)
(CONS '|%ColonAppend| (LIST . #1#)))
-(DEFUN |%Pretend| #1=(|bfVar#35| |bfVar#36|) (CONS '|%Pretend| (LIST . #1#)))
+(DEFUN |%Pretend| #1=(|bfVar#36| |bfVar#37|) (CONS '|%Pretend| (LIST . #1#)))
-(DEFUN |%Is| #1=(|bfVar#37| |bfVar#38|) (CONS '|%Is| (LIST . #1#)))
+(DEFUN |%Is| #1=(|bfVar#38| |bfVar#39|) (CONS '|%Is| (LIST . #1#)))
-(DEFUN |%Isnt| #1=(|bfVar#39| |bfVar#40|) (CONS '|%Isnt| (LIST . #1#)))
+(DEFUN |%Isnt| #1=(|bfVar#40| |bfVar#41|) (CONS '|%Isnt| (LIST . #1#)))
-(DEFUN |%Reduce| #1=(|bfVar#41| |bfVar#42|) (CONS '|%Reduce| (LIST . #1#)))
+(DEFUN |%Reduce| #1=(|bfVar#42| |bfVar#43|) (CONS '|%Reduce| (LIST . #1#)))
-(DEFUN |%PrefixExpr| #1=(|bfVar#43| |bfVar#44|)
+(DEFUN |%PrefixExpr| #1=(|bfVar#44| |bfVar#45|)
(CONS '|%PrefixExpr| (LIST . #1#)))
-(DEFUN |%Call| #1=(|bfVar#45| |bfVar#46|) (CONS '|%Call| (LIST . #1#)))
+(DEFUN |%Call| #1=(|bfVar#46| |bfVar#47|) (CONS '|%Call| (LIST . #1#)))
-(DEFUN |%InfixExpr| #1=(|bfVar#47| |bfVar#48| |bfVar#49|)
+(DEFUN |%InfixExpr| #1=(|bfVar#48| |bfVar#49| |bfVar#50|)
(CONS '|%InfixExpr| (LIST . #1#)))
-(DEFUN |%ConstantDefinition| #1=(|bfVar#50| |bfVar#51|)
+(DEFUN |%ConstantDefinition| #1=(|bfVar#51| |bfVar#52|)
(CONS '|%ConstantDefinition| (LIST . #1#)))
-(DEFUN |%Definition| #1=(|bfVar#52| |bfVar#53| |bfVar#54|)
+(DEFUN |%Definition| #1=(|bfVar#53| |bfVar#54| |bfVar#55|)
(CONS '|%Definition| (LIST . #1#)))
-(DEFUN |%Macro| #1=(|bfVar#55| |bfVar#56| |bfVar#57|)
+(DEFUN |%Macro| #1=(|bfVar#56| |bfVar#57| |bfVar#58|)
(CONS '|%Macro| (LIST . #1#)))
-(DEFUN |%Lambda| #1=(|bfVar#58| |bfVar#59|) (CONS '|%Lambda| (LIST . #1#)))
+(DEFUN |%Lambda| #1=(|bfVar#59| |bfVar#60|) (CONS '|%Lambda| (LIST . #1#)))
-(DEFUN |%SuchThat| #1=(|bfVar#60|) (CONS '|%SuchThat| (LIST . #1#)))
+(DEFUN |%SuchThat| #1=(|bfVar#61|) (CONS '|%SuchThat| (LIST . #1#)))
-(DEFUN |%Assignment| #1=(|bfVar#61| |bfVar#62|)
+(DEFUN |%Assignment| #1=(|bfVar#62| |bfVar#63|)
(CONS '|%Assignment| (LIST . #1#)))
-(DEFUN |%While| #1=(|bfVar#63|) (CONS '|%While| (LIST . #1#)))
+(DEFUN |%While| #1=(|bfVar#64|) (CONS '|%While| (LIST . #1#)))
-(DEFUN |%Until| #1=(|bfVar#64|) (CONS '|%Until| (LIST . #1#)))
+(DEFUN |%Until| #1=(|bfVar#65|) (CONS '|%Until| (LIST . #1#)))
-(DEFUN |%For| #1=(|bfVar#65| |bfVar#66| |bfVar#67|) (CONS '|%For| (LIST . #1#)))
+(DEFUN |%For| #1=(|bfVar#66| |bfVar#67| |bfVar#68|) (CONS '|%For| (LIST . #1#)))
-(DEFUN |%Implies| #1=(|bfVar#68| |bfVar#69|) (CONS '|%Implies| (LIST . #1#)))
+(DEFUN |%Implies| #1=(|bfVar#69| |bfVar#70|) (CONS '|%Implies| (LIST . #1#)))
-(DEFUN |%Iterators| #1=(|bfVar#70|) (CONS '|%Iterators| (LIST . #1#)))
+(DEFUN |%Iterators| #1=(|bfVar#71|) (CONS '|%Iterators| (LIST . #1#)))
-(DEFUN |%Cross| #1=(|bfVar#71|) (CONS '|%Cross| (LIST . #1#)))
+(DEFUN |%Cross| #1=(|bfVar#72|) (CONS '|%Cross| (LIST . #1#)))
-(DEFUN |%Repeat| #1=(|bfVar#72| |bfVar#73|) (CONS '|%Repeat| (LIST . #1#)))
+(DEFUN |%Repeat| #1=(|bfVar#73| |bfVar#74|) (CONS '|%Repeat| (LIST . #1#)))
-(DEFUN |%Pile| #1=(|bfVar#74|) (CONS '|%Pile| (LIST . #1#)))
+(DEFUN |%Pile| #1=(|bfVar#75|) (CONS '|%Pile| (LIST . #1#)))
-(DEFUN |%Append| #1=(|bfVar#75|) (CONS '|%Append| (LIST . #1#)))
+(DEFUN |%Append| #1=(|bfVar#76|) (CONS '|%Append| (LIST . #1#)))
-(DEFUN |%Case| #1=(|bfVar#76| |bfVar#77|) (CONS '|%Case| (LIST . #1#)))
+(DEFUN |%Case| #1=(|bfVar#77| |bfVar#78|) (CONS '|%Case| (LIST . #1#)))
-(DEFUN |%Return| #1=(|bfVar#78|) (CONS '|%Return| (LIST . #1#)))
+(DEFUN |%Return| #1=(|bfVar#79|) (CONS '|%Return| (LIST . #1#)))
-(DEFUN |%Leave| #1=(|bfVar#79|) (CONS '|%Leave| (LIST . #1#)))
+(DEFUN |%Leave| #1=(|bfVar#80|) (CONS '|%Leave| (LIST . #1#)))
-(DEFUN |%Throw| #1=(|bfVar#80|) (CONS '|%Throw| (LIST . #1#)))
+(DEFUN |%Throw| #1=(|bfVar#81|) (CONS '|%Throw| (LIST . #1#)))
-(DEFUN |%Catch| #1=(|bfVar#81| |bfVar#82|) (CONS '|%Catch| (LIST . #1#)))
+(DEFUN |%Catch| #1=(|bfVar#82| |bfVar#83|) (CONS '|%Catch| (LIST . #1#)))
-(DEFUN |%Finally| #1=(|bfVar#83|) (CONS '|%Finally| (LIST . #1#)))
+(DEFUN |%Finally| #1=(|bfVar#84|) (CONS '|%Finally| (LIST . #1#)))
-(DEFUN |%Try| #1=(|bfVar#84| |bfVar#85|) (CONS '|%Try| (LIST . #1#)))
+(DEFUN |%Try| #1=(|bfVar#85| |bfVar#86|) (CONS '|%Try| (LIST . #1#)))
-(DEFUN |%Where| #1=(|bfVar#86| |bfVar#87|) (CONS '|%Where| (LIST . #1#)))
+(DEFUN |%Where| #1=(|bfVar#87| |bfVar#88|) (CONS '|%Where| (LIST . #1#)))
-(DEFUN |%Structure| #1=(|bfVar#88| |bfVar#89|)
+(DEFUN |%Structure| #1=(|bfVar#89| |bfVar#90|)
(CONS '|%Structure| (LIST . #1#)))
(DEFPARAMETER |$inDefIS| NIL)
@@ -244,7 +246,7 @@
(DEFUN |bfBeginsDollar| (|x|) (CHAR= (SCHAR (SYMBOL-NAME |x|) 0) (|char| '$)))
-(DEFUN |compFluid| (|id|) (LIST 'FLUID |id|))
+(DEFUN |compFluid| (|id|) (LIST '|%Dynamic| |id|))
(DEFUN |compFluidize| (|x|)
(COND ((NULL |x|) NIL)
@@ -776,9 +778,7 @@
(DEFUN |bfForin| (|lhs| U) (|bfFor| |lhs| U 1))
-(DEFUN |bfLocal| (|a| |b|)
- (COND ((EQ |b| 'FLUID) (|compFluid| |a|))
- ((EQ |b| '|local|) (|compFluid| |a|)) (T |a|)))
+(DEFUN |bfLocal| (|a| |b|) (COND ((EQ |b| '|local|) (|compFluid| |a|)) (T |a|)))
(DEFUN |bfTake| (|n| |x|)
(COND ((NULL |x|) |x|) ((EQL |n| 0) NIL)
@@ -849,7 +849,7 @@
(PROG (|let1| |g| |l2| |l1| |name| |rhs1| |ISTMP#1|)
(RETURN
(COND ((SYMBOLP |lhs|) (|bfLetForm| |lhs| |rhs|))
- ((AND (CONSP |lhs|) (EQ (CAR |lhs|) 'FLUID)
+ ((AND (CONSP |lhs|) (EQ (CAR |lhs|) '|%Dynamic|)
(PROGN
(SETQ |ISTMP#1| (CDR |lhs|))
(AND (CONSP |ISTMP#1|) (NULL (CDR |ISTMP#1|)))))
@@ -891,7 +891,7 @@
(DECLARE (SPECIAL |$inDefIS|))
(RETURN
(COND ((NULL |lhs|) NIL) ((SYMBOLP |lhs|) (|bfLetForm| |lhs| |rhs|))
- ((AND (CONSP |lhs|) (EQ (CAR |lhs|) 'FLUID)
+ ((AND (CONSP |lhs|) (EQ (CAR |lhs|) '|%Dynamic|)
(PROGN
(SETQ |ISTMP#1| (CDR |lhs|))
(AND (CONSP |ISTMP#1|) (NULL (CDR |ISTMP#1|)))))
@@ -1857,7 +1857,7 @@
((NOT (|symbolMember?| |l| |$locVars|))
(SETQ |$locVars| (CONS |l| |$locVars|))))
|x|)))
- ((AND (CONSP |l|) (EQ (CAR |l|) 'FLUID))
+ ((AND (CONSP |l|) (EQ (CAR |l|) '|%Dynamic|))
(COND
((NOT (|symbolMember?| (CADR |l|) |$fluidVars|))
(SETQ |$fluidVars| (CONS (CADR |l|) |$fluidVars|))))
@@ -1931,8 +1931,7 @@
(DECLARE (SPECIAL |$op| |$typings|))
(COND ((NULL |$op|) (|%Signature| |a| |b|))
((SYMBOLP |a|)
- (COND ((EQ |b| 'FLUID) (|bfLET| (|compFluid| |a|) NIL))
- ((EQ |b| '|local|) (|bfLET| (|compFluid| |a|) NIL))
+ (COND ((EQ |b| '|local|) (|bfLET| (|compFluid| |a|) NIL))
(T (SETQ |$typings| (CONS (LIST 'TYPE |b| |a|) |$typings|))
|a|)))
(T (LIST 'THE |b| |a|))))
diff --git a/src/boot/strap/tokens.clisp b/src/boot/strap/tokens.clisp
index 8dd98d44..6f2c0f71 100644
--- a/src/boot/strap/tokens.clisp
+++ b/src/boot/strap/tokens.clisp
@@ -226,7 +226,7 @@
(LIST '|stringDowncase| 'STRING-DOWNCASE)
(LIST '|string?| 'STRINGP) (LIST '|stringEq?| 'STRING=)
(LIST '|stringUpcase| 'STRING-UPCASE)
- (LIST '|subSequence| 'SUBSEQ)
+ (LIST '|subSequence| 'SUBSEQ) (LIST '|symbolBinding| 'FIND-SYMBOL)
(LIST '|symbolScope| 'SYMBOL-PACKAGE) (LIST '|symbolEq?| 'EQ)
(LIST '|symbolFunction| 'SYMBOL-FUNCTION)
(LIST '|symbolName| 'SYMBOL-NAME)
diff --git a/src/boot/tokens.boot b/src/boot/tokens.boot
index bcfa8e52..cb3491df 100644
--- a/src/boot/tokens.boot
+++ b/src/boot/tokens.boot
@@ -306,6 +306,7 @@ for i in [ _
["stringEq?","STRING="] , _
["stringUpcase", "STRING-UPCASE"] , _
["subSequence", "SUBSEQ"] , _
+ ["symbolBinding", "FIND-SYMBOL"] , _
["symbolScope", "SYMBOL-PACKAGE"] , _
["symbolEq?", "EQ"], _
["symbolFunction", "SYMBOL-FUNCTION"], _
diff --git a/src/boot/translator.boot b/src/boot/translator.boot
index ec035b43..430f3909 100644
--- a/src/boot/translator.boot
+++ b/src/boot/translator.boot
@@ -1,6 +1,6 @@
-- Copyright (c) 1991-2002, The Numerical Algorithms Group Ltd.
-- All rights reserved.
--- Copyright (C) 2007-2011, Gabriel Dos Reis.
+-- Copyright (C) 2007-2012, Gabriel Dos Reis.
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
@@ -695,8 +695,7 @@ BOOTLOOP() ==
#a=0=>
writeLine '"Boot Loop; to exit type ] "
BOOTLOOP()
- b:=shoePrefix? ('")console",a)
- b =>
+ shoePrefix? ('")console",a) =>
stream:= _*TERMINAL_-IO_*
PSTTOMC bRgen stream
BOOTLOOP()
@@ -709,8 +708,7 @@ BOOTPO() ==
#a=0=>
writeLine '"Boot Loop; to exit type ] "
BOOTPO()
- b:=shoePrefix? ('")console",a)
- b =>
+ shoePrefix? ('")console",a) =>
stream:= _*TERMINAL_-IO_*
PSTOUT bRgen stream
BOOTPO()