diff --git a/books/bookvol9.pamphlet b/books/bookvol9.pamphlet index 2842ac6..9274680 100644 --- a/books/bookvol9.pamphlet +++ b/books/bookvol9.pamphlet @@ -2641,6 +2641,56 @@ preferred to the underlying representation -- RDJ 9/12/83 @ +\defun{compSeq}{compSeq} +\calls{compSeq}{compSeq1} +\usesdollar{compSeq}{exitModeStack} +<>= +(defun |compSeq| (arg0 m e) + (declare (special |$exitModeStack|)) + (|compSeq1| (cdr arg0) (cons m |$exitModeStack|) e)) + +@ + +\defun{compSeq1}{compSeq1} +\calls{compSeq1}{nreverse0} +\calls{compSeq1}{compSeqItem} +\calls{compSeq1}{mkq} +\calls{compSeq1}{replaceExitEtc} +\usesdollar{compSeq1}{exitModeStack} +\usesdollar{compSeq1}{insideExpressionIfTrue} +\usesdollar{compSeq1}{finalEnv} +\usesdollar{compSeq1}{NoValueMode} +<>= +(defun |compSeq1| (l |$exitModeStack| e) + (declare (special |$exitModeStack|)) + (let (|$insideExpressionIfTrue| |$finalEnv| tmp1 tmp2 c catchTag form) + (declare (special |$insideExpressionIfTrue| |$finalEnv| |$NoValueMode|)) + (setq |$insideExpressionIfTrue| nil) + (setq |$finalEnv| nil) + (when + (setq c (dolist (x l (nreverse0 tmp2)) + (setq |$insideExpressionIfTrue| nil) + (setq tmp1 (|compSeqItem| x |$NoValueMode| e)) + (unless tmp1 (return nil)) + (setq e (third tmp1)) + (push (first tmp1) tmp2))) + (setq catchTag (mkq (gensym))) + (setq form + (cons 'seq + (|replaceExitEtc| c catchTag '|TAGGEDexit| (elt |$exitModeStack| 0)))) + (list (list 'catch catchTag form) (elt |$exitModeStack| 0) |$finalEnv|)))) + +@ + +\defun{compSeqItem}{compSeqItem} +\calls{compSeqItem}{comp} +\calls{compSeqItem}{macroExpand} +<>= +(defun |compSeqItem| (x m e) + (|comp| (|macroExpand| x e) m e)) + +@ + \defun{argsToSig}{argsToSig} <>= (defun |argsToSig| (args) @@ -2697,6 +2747,54 @@ preferred to the underlying representation -- RDJ 9/12/83 @ +\defun{compExit}{compExit} +\calls{compExit}{comp} +\calls{compExit}{modifyModeStack} +\calls{compExit}{stackMessageIfNone} +\usesdollar{compExit}{exitModeStack} +<>= +(defun |compExit| (arg0 m e) + (let (x index m1 u) + (declare (special |$exitModeStack|)) + (setq index (1- (second arg0))) + (setq x (third arg0)) + (cond + ((null |$exitModeStack|) + (|comp| x m e)) + (t + (setq m1 (elt |$exitModeStack| index)) + (setq u (|comp| x m1 e)) + (cond + (u + (|modifyModeStack| (second u) index) + (list (list '|TAGGEDexit| index u) m e)) + (t + (|stackMessageIfNone| + (list '|cannot compile exit expression| x '|in mode| m1)))))))) + +@ +\defun{modifyModeStack}{modifyModeStack} +\calls{modifyModeStack}{say} +\calls{modifyModeStack}{copy} +\calls{modifyModeStack}{setelt} +\calls{modifyModeStack}{resolve} +\usesdollar{modifyModeStack}{reportExitModeStack} +\usesdollar{modifyModeStack}{exitModeStack} +<>= +(defun |modifyModeStack| (|m| |index|) + (declare (special |$exitModeStack| |$reportExitModeStack|)) + (if |$reportExitModeStack| + (say "exitModeStack: " (copy |$exitModeStack|) + " ====> " + (progn + (setelt |$exitModeStack| |index| + (|resolve| |m| (elt |$exitModeStack| |index|))) + |$exitModeStack|)) + (setelt |$exitModeStack| |index| + (|resolve| |m| (elt |$exitModeStack| |index|))))) + +@ + \defun{freelist}{Create a list of unbound symbols} We walk argument u looking for symbols that are unbound. If we find a symbol we add it to the free list. If it occurs in a prog then it is @@ -2962,6 +3060,7 @@ if \verb|$InteractiveMode| then use a null outputstream <> <> <> +<> <> <> <> @@ -2984,6 +3083,9 @@ if \verb|$InteractiveMode| then use a null outputstream <> <> <> +<> +<> +<> <> <> <> @@ -2999,6 +3101,8 @@ if \verb|$InteractiveMode| then use a null outputstream <> +<> + <> <> diff --git a/changelog b/changelog index 463ee25..cc264b8 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,6 @@ +20100928 tpd src/axiom-website/patches.html 20100928.02.tpd.patch +20100928 tpd src/interp/compiler.lisp treeshake compiler +20100928 tpd books/bookvol9.pamphlet treeshake compiler 20100928 tpd src/axiom-website/patches.html 20100928.01.tpd.patch 20100928 tpd src/interp/compiler.lisp treeshake compiler 20100928 tpd books/bookvol9.pamphlet treeshake compiler diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html index a9ab314..848de49 100644 --- a/src/axiom-website/patches.html +++ b/src/axiom-website/patches.html @@ -3164,5 +3164,7 @@ books/bookvolbib add Eric Weisstein [Wein]
src/axiom-website/download.html add fedora, debian
20100928.01.tpd.patch books/bookvol9.pamphlet treeshake compiler
+20100928.02.tpd.patch +books/bookvol9.pamphlet treeshake compiler
diff --git a/src/interp/compiler.lisp.pamphlet b/src/interp/compiler.lisp.pamphlet index dd02c39..506a3eb 100644 --- a/src/interp/compiler.lisp.pamphlet +++ b/src/interp/compiler.lisp.pamphlet @@ -1836,93 +1836,6 @@ the left hand side of the macro. NIL))))))))) @ -\subsection{compSeq} -Compile seq -<<*>>= -;compSeq(["SEQ",:l],m,e) == compSeq1(l,[m,:$exitModeStack],e) - -(DEFUN |compSeq| (G168818 |m| |e|) - (PROG (|l|) - (declare (special |$exitModeStack|)) - (RETURN - (PROGN - (COND ((EQ (CAR G168818) 'SEQ) (CAR G168818))) - (SPADLET |l| (CDR G168818)) - (|compSeq1| |l| (CONS |m| |$exitModeStack|) |e|))))) - -@ -\subsection{compSeq1} -<<*>>= -;compSeq1(l,$exitModeStack,e) == -; $insideExpressionIfTrue: local -; $finalEnv: local -; --used in replaceExitEtc. -; c:= -; [([.,.,e]:= -; --this used to be compOrCroak-- but changed so we can back out -; ($insideExpressionIfTrue:= NIL; compSeqItem(x,$NoValueMode,e) or return -; "failed")).expr for x in l] -; if c="failed" then return nil -; catchTag:= MKQ GENSYM() -; form:= ["SEQ",:replaceExitEtc(c,catchTag,"TAGGEDexit",$exitModeStack.(0))] -; [["CATCH",catchTag,form],$exitModeStack.(0),$finalEnv] - -(DEFUN |compSeq1| (|l| |$exitModeStack| |e|) - (DECLARE (SPECIAL |$exitModeStack|)) - (PROG (|$insideExpressionIfTrue| |$finalEnv| |LETTMP#1| |c| - |catchTag| |form|) - (DECLARE (SPECIAL |$insideExpressionIfTrue| |$finalEnv| |$NoValueMode|)) - (RETURN - (SEQ (PROGN - (SPADLET |$insideExpressionIfTrue| NIL) - (SPADLET |$finalEnv| NIL) - (SPADLET |c| - (PROG (G168847) - (SPADLET G168847 NIL) - (RETURN - (DO ((G168857 |l| (CDR G168857)) - (|x| NIL)) - ((OR (ATOM G168857) - (PROGN - (SETQ |x| (CAR G168857)) - NIL)) - (NREVERSE0 G168847)) - (SEQ (EXIT (SETQ G168847 - (CONS - (CAR - (PROGN - (SPADLET |LETTMP#1| - (PROGN - (SPADLET - |$insideExpressionIfTrue| - NIL) - (OR - (|compSeqItem| |x| - |$NoValueMode| |e|) - (RETURN '|failed|)))) - (SPADLET |e| - (CADDR |LETTMP#1|)) - |LETTMP#1|)) - G168847)))))))) - (COND ((BOOT-EQUAL |c| '|failed|) (RETURN NIL))) - (SPADLET |catchTag| (MKQ (GENSYM))) - (SPADLET |form| - (CONS 'SEQ - (|replaceExitEtc| |c| |catchTag| - '|TAGGEDexit| (ELT |$exitModeStack| 0)))) - (CONS (CONS 'CATCH (CONS |catchTag| (CONS |form| NIL))) - (CONS (ELT |$exitModeStack| 0) - (CONS |$finalEnv| NIL)))))))) - -@ -\subsection{compSeqItem} -<<*>>= -;compSeqItem(x,m,e) == comp(macroExpand(x,e),m,e) - -(DEFUN |compSeqItem| (|x| |m| |e|) - (|comp| (|macroExpand| |x| |e|) |m| |e|)) - -@ \subsection{replaceExitEtc} <<*>>= ;replaceExitEtc(x,tag,opFlag,opMode) == @@ -2039,68 +1952,6 @@ Compile suchthat (CONS |x'| (CONS |m'| (CONS |e| NIL))))))) @ -\subsection{compExit} -Compile exit -<<*>>= -;compExit(["exit",level,x],m,e) == -; index:= level-1 -; $exitModeStack = [] => comp(x,m,e) -; m1:= $exitModeStack.index -; [x',m',e']:= -; u:= -; comp(x,m1,e) or return -; stackMessageIfNone ["cannot compile exit expression",x,"in mode",m1] -; modifyModeStack(m',index) -; [["TAGGEDexit",index,u],m,e] - -(DEFUN |compExit| (G169003 |m| |e|) - (PROG (|level| |x| |index| |m1| |u| |x'| |m'| |e'|) - (declare (special |$exitModeStack|)) - (RETURN - (PROGN - (COND ((EQ (CAR G169003) '|exit|) (CAR G169003))) - (SPADLET |level| (CADR G169003)) - (SPADLET |x| (CADDR G169003)) - (SPADLET |index| (SPADDIFFERENCE |level| 1)) - (COND - ((NULL |$exitModeStack|) (|comp| |x| |m| |e|)) - ('T (SPADLET |m1| (ELT |$exitModeStack| |index|)) - (SPADLET |u| - (OR (|comp| |x| |m1| |e|) - (RETURN - (|stackMessageIfNone| - (CONS '|cannot compile exit expression| - (CONS |x| - (CONS '|in mode| (CONS |m1| NIL)))))))) - (SPADLET |x'| (CAR |u|)) (SPADLET |m'| (CADR |u|)) - (SPADLET |e'| (CADDR |u|)) (|modifyModeStack| |m'| |index|) - (CONS (CONS '|TAGGEDexit| (CONS |index| (CONS |u| NIL))) - (CONS |m| (CONS |e| NIL))))))))) - -@ -\subsection{modifyModeStack} -<<*>>= -;modifyModeStack(m,index) == -; $reportExitModeStack => -; SAY("exitModeStack: ",COPY $exitModeStack," ====> ", -; ($exitModeStack.index:= resolve(m,$exitModeStack.index); $exitModeStack)) -; $exitModeStack.index:= resolve(m,$exitModeStack.index) - -(DEFUN |modifyModeStack| (|m| |index|) - (declare (special |$exitModeStack| |$reportExitModeStack|)) - (COND - (|$reportExitModeStack| - (SAY "exitModeStack: " (COPY |$exitModeStack|) - " ====> " - (PROGN - (SETELT |$exitModeStack| |index| - (|resolve| |m| (ELT |$exitModeStack| |index|))) - |$exitModeStack|))) - ('T - (SETELT |$exitModeStack| |index| - (|resolve| |m| (ELT |$exitModeStack| |index|)))))) - -@ \subsection{compLeave} Compile leave <<*>>=