diff --git a/books/bookvol9.pamphlet b/books/bookvol9.pamphlet index 18098f8..00027d1 100644 --- a/books/bookvol9.pamphlet +++ b/books/bookvol9.pamphlet @@ -1495,6 +1495,42 @@ Symbolics read-line returns embedded newlines in a c-m-Y.") (t (|postForm| x))))))) @ + +\defun{postAtom}{postAtom} +\usesdollar{postAtom}{boot} +<>= +(defun |postAtom| (x) + (declare (special $boot)) + (cond + ($boot x) + ((eql x 0) '(|Zero|)) + ((eql x 1) '(|One|)) + ((eq x t) 't$) + ((and (identp x) (getdatabase x 'niladic)) (list x)) + (t x))) + +@ + +\defun{postTranList}{postTranList} +\calls{postTranList}{postTran} +<>= +(defun |postTranList| (x) + (loop for y in x collect (|postTran| y))) + +@ + +\defun{postScriptsForm}{postScriptsForm} +\calls{postScriptsForm}{getScriptName} +\calls{postScriptsForm}{length} +\calls{postScriptsForm}{postTranScripts} +<>= +(defun |postScriptsForm| (arg0 argl) + (let ((op (second arg0)) (a (third arg0))) + (cons (|getScriptName| op a (|#| argl)) + (append (|postTranScripts| a) argl)))) + +@ + \chapter{The Compiler} \section{Compiling EQ.spad} @@ -1876,7 +1912,7 @@ Again we find a lot of redundant work. We finally end up calling (let (|$newComp| |$scanIfTrue| |$compileOnlyCertainItems| |$f| |$m| |$QuickLet| |$QuickCode| |$sourceFileTypes| |$InteractiveMode| path optlist fun optname - optargs fullopt translateoldtonew constructor) + optargs fullopt constructor) (declare (special |$newComp| |$scanIfTrue| |$compileOnlyCertainItems| |$f| |$m| |$QuickLet| |$QuickCode| |$sourceFileTypes| |$InteractiveMode| /editfile |$options| @@ -2681,7 +2717,7 @@ And the {\bf s-process} function which returns a parsed version of the input. (and (pairp t2) (eq (qcar t2) 'def))))))) (setq t3 (|compOrCroak| x m e)) (setq val (car t3)) - (setq mode (cadr t3)) + (setq mode (second t3)) (cons val (cons mode (cons e nil)))) (t (|compOrCroak| x m e))))) @@ -2830,8 +2866,8 @@ preferred to the underlying representation -- RDJ 9/12/83 (let (td) (declare (special |$compStack| |$Representation| |$EmptyMode|)) (if (setq td (|comp2| x m e)) - (if (and (equal m |$EmptyMode|) (equal (cadr td) |$Representation|)) - (list (car td) '$ (caddr td)) + (if (and (equal m |$EmptyMode|) (equal (second td) |$Representation|)) + (list (car td) '$ (third td)) td) (|compNoStacking1| x m e |$compStack|)))) @@ -2847,7 +2883,7 @@ preferred to the underlying representation -- RDJ 9/12/83 (let (u td) (if (setq u (|get| (if (eq m '$) '|Rep| m) '|value| e)) (if (setq td (|comp2| x (car u) e)) - (list (car td) m (caddr td)) + (list (car td) m (third td)) nil) nil))) @@ -3074,13 +3110,13 @@ preferred to the underlying representation -- RDJ 9/12/83 \usesdollar{compColon}{insideExpressionIfTrue} <>= (defun |compColon| (arg0 m e) - (let (|$lhsOfColon| argf argt tprime mprime r l tmp1 td op argl newTarget a + (let (|$lhsOfColon| argf argt tprime mprime r td op argl newTarget a signature tmp2 catform tmp3 g2 g5) (declare (special |$lhsOfColon| |$noEnv| |$insideFunctorIfTrue| |$bootStrapMode| |$FormalMapVariableList| |$insideCategoryIfTrue| |$insideExpressionIfTrue|)) - (setq argf (cadr arg0)) - (setq argt (caddr arg0)) + (setq argf (second arg0)) + (setq argt (third arg0)) (if |$insideExpressionIfTrue| (|compColonInside| argf m e argt) (progn @@ -3112,7 +3148,7 @@ preferred to the underlying representation -- RDJ 9/12/83 ((eq (car argf) 'listof) (dolist (x (cdr argf) td) (setq td (|compColon| (list '|:| x argt) m e)) - (setq e (caddr td)))) + (setq e (third td)))) (t (setq e (cond @@ -3201,15 +3237,15 @@ preferred to the underlying representation -- RDJ 9/12/83 \usesdollar{compColonInside}{EmptyMode} <>= (defun |compColonInside| (x m e mprime) - (let (mpp warningMessage td tprime failed) + (let (mpp warningMessage td tprime) (declare (special |$newCompilerUnionFlag| |$EmptyMode|)) (setq e (|addDomain| mprime e)) (when (setq td (|comp| x |$EmptyMode| e)) (cond - ((equal (setq mpp (CADR td)) mprime) + ((equal (setq mpp (second td)) mprime) (setq warningMessage (list '|:| mprime '| -- should replace by @|)))) - (setq td (list (car td) mprime (caddr td))) + (setq td (list (car td) mprime (third td))) (when (setq tprime (|coerce| td m)) (cond (warningMessage (|stackWarning| warningMessage)) @@ -3300,7 +3336,7 @@ preferred to the underlying representation -- RDJ 9/12/83 <>= (defun |convert| (td m) (let (res) - (when (setq res (|resolve| (cadr td) m)) + (when (setq res (|resolve| (second td) m)) (|coerce| td res)))) @ @@ -3346,7 +3382,7 @@ preferred to the underlying representation -- RDJ 9/12/83 \usesdollar{compSymbol}{NoValue} <>= (defun |compSymbol| (s m e) - (let (v mprime) + (let (v mprime mode) (declare (special |$Symbol| |$Expression| |$FormalMapVariableList| |$compForModeIfTrue| |$formalArgList| |$NoValueMode| |$functorLocalParameters| |$Boolean| |$NoValue|)) @@ -3363,10 +3399,10 @@ preferred to the underlying representation -- RDJ 9/12/83 ((member s |$functorLocalParameters|) ; s will be replaced by an ELT form in beforeCompile (|NRTgetLocalIndex| s) - (list s (cadr v) e)) + (list s (second v) e)) (t ; s has been SETQd - (list s (cadr v) e)))) + (list s (second v) e)))) ((setq mprime (|getmode| s e)) (cond ((and (null (|member| s |$formalArgList|)) @@ -3394,7 +3430,7 @@ preferred to the underlying representation -- RDJ 9/12/83 \calls{compList}{comp} <>= (defun |compList| (l m e) - (let (tmp1 tmp2 t0 failed (mUnder (cadr m))) + (let (tmp1 tmp2 t0 failed (mUnder (second m))) (if (null l) (list nil m e) (progn @@ -3404,8 +3440,8 @@ preferred to the underlying representation -- RDJ 9/12/83 (setq x (car t3)) (if (setq tmp1 (|comp| x mUnder e)) (progn - (setq mUnder (cadr tmp1)) - (setq e (caddr tmp1)) + (setq mUnder (second tmp1)) + (setq e (third tmp1)) (push tmp1 tmp2)) (setq failed t)))) (unless failed @@ -3426,7 +3462,7 @@ preferred to the underlying representation -- RDJ 9/12/83 \usesdollar{compVector}{EmptyVector} <>= (defun |compVector| (l m e) - (let (tmp1 tmp2 t0 failed (mUnder (cadr m))) + (let (tmp1 tmp2 t0 failed (mUnder (second m))) (declare (special |$EmptyVector|)) (if (null l) (list |$EmptyVector| m e) @@ -3437,8 +3473,8 @@ preferred to the underlying representation -- RDJ 9/12/83 (setq x (car t3)) (if (setq tmp1 (|comp| x mUnder e)) (progn - (setq mUnder (cadr tmp1)) - (setq e (caddr tmp1)) + (setq mUnder (second tmp1)) + (setq e (third tmp1)) (push tmp1 tmp2)) (setq failed t)))) (unless failed @@ -3585,7 +3621,7 @@ preferred to the underlying representation -- RDJ 9/12/83 <>= (defun |compForm2| (form m e modemapList) (let (op argl sargl aList dc cond nsig v ncond deleteList newList td tl - partialModeList tmp1 tmp2 tmp3 tmp4 tmp5 tmp6 tmp7 tmp8 tmp9 tmpb tmpc) + partialModeList tmp1 tmp2 tmp3 tmp4 tmp5 tmp6 tmp7) (declare (special |$EmptyMode| |$TriangleVariableList|)) (setq op (car form)) (setq argl (cdr form)) @@ -3676,13 +3712,13 @@ preferred to the underlying representation -- RDJ 9/12/83 (setq tmp2 (qcdr tmp1)) (and (pairp tmp2) (eq (qcdr tmp2) nil)))))) (when (setq tmp3 (|comp| a |$EmptyMode| e)) - (setq e (caddr tmp3)) + (setq e (third tmp3)) (|compForm1| form m e))) (t (setq u (dolist (x argl) (setq tmp3 (or (|comp| x |$EmptyMode| e) (return '|failed|))) - (setq e (caddr tmp3)) + (setq e (third tmp3)) tmp3)) (unless (eq u '|failed|) (|compForm1| form m e)))))) @@ -3832,6 +3868,7 @@ preferred to the underlying representation -- RDJ 9/12/83 \usesdollar{compWithMappingMode1}{EmptyMode} \usesdollar{compWithMappingMode1}{FormalMapVariableList} \usesdollar{compWithMappingMode1}{CategoryFrame} +\usesdollar{compWithMappingMode1}{formatArgList} <>= (defun |compWithMappingMode1| (x m oldE |$formalArgList|) (declare (special |$formalArgList|)) @@ -3840,11 +3877,11 @@ preferred to the underlying representation -- RDJ 9/12/83 u frees i scode locals body vec expandedFunction fname uu) (declare (special |$killOptimizeIfTrue| $funname $funnameTail |$QuickCode| |$EmptyMode| |$FormalMapVariableList| - |$CategoryFrame|)) + |$CategoryFrame| |$formatArgList|)) (return (seq (progn - (setq mprime (cadr m)) + (setq mprime (second m)) (setq sl (cddr m)) (setq |$killOptimizeIfTrue| t) (setq e oldE) @@ -3952,7 +3989,7 @@ preferred to the underlying representation -- RDJ 9/12/83 (seq (exit (progn (setq tmp6 (|compMakeDeclaration| (list '|:| v m ) |$EmptyMode| e)) - (setq e (caddr tmp6)) + (setq e (third tmp6)) tmp6)))) (cond ((and oldstyle @@ -3978,7 +4015,7 @@ preferred to the underlying representation -- RDJ 9/12/83 ; -- pass this as the environment to our inner function. (setq $funname nil) (setq $funnameTail (list nil)) - (setq expandedFunction (comp-tran (cadr uu))) + (setq expandedFunction (comp-tran (second uu))) (setq frees (freelist expandedFunction vl nil e)) (setq expandedFunction (cond @@ -4105,9 +4142,9 @@ preferred to the underlying representation -- RDJ 9/12/83 \calls{compLambda}{stackAndThrow} <>= (defun |compLambda| (x m e) - (let (vl body tmp1 tmp2 tmp3 target a1 args arg1 sig1 ress) - (setq vl (cadr x)) - (setq body (caddr x)) + (let (vl body tmp1 tmp2 tmp3 target args arg1 sig1 ress) + (setq vl (second x)) + (setq body (third x)) (cond ((and (pairp vl) (eq (qcar vl) '|:|) (progn @@ -4127,7 +4164,7 @@ preferred to the underlying representation -- RDJ 9/12/83 ((listp args) (setq tmp3 (|argsToSig| args)) (setq arg1 (CAR tmp3)) - (setq sig1 (CADR tmp3)) + (setq sig1 (second tmp3)) (cond (sig1 (setq ress @@ -4164,7 +4201,7 @@ preferred to the underlying representation -- RDJ 9/12/83 \usesdollar{compWhere}{EmptyMode} <>= (defun |compWhere| (arg0 m eInit) - (let (|$insideExpressionIfTrue| |$insideWhereIfTrue| form exprList e u + (let (|$insideExpressionIfTrue| |$insideWhereIfTrue| form exprList e eBefore tmp1 x eAfter del eFinal) (declare (special |$insideExpressionIfTrue| |$insideWhereIfTrue| |$EmptyMode|)) @@ -4371,11 +4408,11 @@ symbol in the free list are represented by the alist (symbol . count) (cond ((member op '(quote go |function|)) free) ((eq op 'lambda) ; lambdas bind symbols - (setq bound (unionq bound (cadr u))) + (setq bound (unionq bound (second u))) (dolist (v (cddr u)) (setq free (freelist v bound free e)))) ((eq op 'prog) ; progs bind symbols - (setq bound (unionq bound (cadr u))) + (setq bound (unionq bound (second u))) (dolist (v (cddr u)) (unless (atom v) (setq free (freelist v bound free e))))) @@ -4612,7 +4649,10 @@ if \verb|$InteractiveMode| then use a null outputstream <> <> +<> +<> <> +<> <> <> <> diff --git a/changelog b/changelog index 9db7f4d..2529949 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,6 @@ +20101004 tpd src/axiom-website/patches.html 20101004.01.tpd.patch +20101004 tpd src/interp/parsing.lisp treeshake compiler +20101004 tpd books/bookvol9 treeshake compiler 20101003 tpd src/axiom-website/patches.html 20101003.03.tpd.patch 20101003 tpd src/interp/parsing.lisp treeshake compiler 20101003 tpd books/bookvol9 treeshake compiler diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html index 90cf08f..4dee3a7 100644 --- a/src/axiom-website/patches.html +++ b/src/axiom-website/patches.html @@ -3184,5 +3184,7 @@ books/bookvol9 treeshake compiler
books/bookvol9 treeshake compiler
20101003.03.tpd.patch books/bookvol9 treeshake compiler
+20101004.01.tpd.patch +books/bookvol9 treeshake compiler
diff --git a/src/interp/parsing.lisp.pamphlet b/src/interp/parsing.lisp.pamphlet index 9190aee..5266f7a 100644 --- a/src/interp/parsing.lisp.pamphlet +++ b/src/interp/parsing.lisp.pamphlet @@ -4051,11 +4051,6 @@ parse (DEFUN |displayPreCompilationErrors| NIL (PROG (|n| |errors| |heading|) (RETURN (SEQ (PROGN (SPADLET |n| (|#| (SPADLET |$postStack| (REMDUP (NREVERSE |$postStack|))))) (COND ((EQL |n| 0) NIL) ((QUOTE T) (SPADLET |errors| (COND ((> |n| 1) "errors") ((QUOTE T) "error"))) (COND (|$InteractiveMode| (|sayBrightly| (CONS " Semantic " (CONS |errors| (CONS " detected: " NIL))))) ((QUOTE T) (SPADLET |heading| (COND ((NEQUAL |$topOp| (QUOTE |$topOp|)) (CONS " " (CONS |$topOp| (CONS " has" NIL)))) ((QUOTE T) (CONS " You have" NIL)))) (|sayBrightly| (APPEND |heading| (CONS (QUOTE |%b|) (CONS |n| (CONS (QUOTE |%d|) (CONS "precompilation " (CONS |errors| (CONS ":" NIL)))))))))) (COND ((> |n| 1) (DO ((#0=#:G166154 |$postStack| (CDR #0#)) (|x| NIL) (|i| 1 (QSADD1 |i|))) ((OR (ATOM #0#) (PROGN (SETQ |x| (CAR #0#)) NIL)) NIL) (SEQ (EXIT (|sayMath| (CONS " " (CONS |i| (CONS ") " |x|)))))))) ((QUOTE T) (|sayMath| (CONS " " (CAR |$postStack|))))) (TERPRI)))))))) -;postTranList x == [postTran y for y in x] - -;;; *** |postTranList| REDEFINED - -(DEFUN |postTranList| (|x|) (PROG NIL (RETURN (SEQ (PROG (#0=#:G166212) (SPADLET #0# NIL) (RETURN (DO ((#1=#:G166217 |x| (CDR #1#)) (|y| NIL)) ((OR (ATOM #1#) (PROGN (SETQ |y| (CAR #1#)) NIL)) (NREVERSE0 #0#)) (SEQ (EXIT (SETQ #0# (CONS (|postTran| |y|) #0#))))))))))) ;postBigFloat x == ; [.,mant,:expon] := x ; $BOOT => INT2RNUM(mant) * INT2RNUM(10) ** expon @@ -4161,17 +4156,7 @@ parse ;;; *** |postMakeCons| REDEFINED (DEFUN |postMakeCons| (|l|) (PROG (|ISTMP#1| |ISTMP#2| |a| |l'|) (RETURN (COND ((NULL |l|) (QUOTE |nil|)) ((AND (PAIRP |l|) (PROGN (SPADLET |ISTMP#1| (QCAR |l|)) (AND (PAIRP |ISTMP#1|) (EQ (QCAR |ISTMP#1|) (QUOTE |:|)) (PROGN (SPADLET |ISTMP#2| (QCDR |ISTMP#1|)) (AND (PAIRP |ISTMP#2|) (EQ (QCDR |ISTMP#2|) NIL) (PROGN (SPADLET |a| (QCAR |ISTMP#2|)) (QUOTE T)))))) (PROGN (SPADLET |l'| (QCDR |l|)) (QUOTE T))) (COND (|l'| (CONS (QUOTE |append|) (CONS (|postTran| |a|) (CONS (|postMakeCons| |l'|) NIL)))) ((QUOTE T) (|postTran| |a|)))) ((QUOTE T) (CONS (QUOTE |cons|) (CONS (|postTran| (CAR |l|)) (CONS (|postMakeCons| (CDR |l|)) NIL)))))))) -;postAtom x == -; $BOOT => x -; x=0 => '(Zero) -; x=1 => '(One) -; EQ(x,'T) => 'T_$ -- rename T in spad code to T$ -; IDENTP x and GETDATABASE(x,'NILADIC) => LIST x -; x -;;; *** |postAtom| REDEFINED - -(DEFUN |postAtom| (|x|) (COND ($BOOT |x|) ((EQL |x| 0) (QUOTE (|Zero|))) ((EQL |x| 1) (QUOTE (|One|))) ((EQ |x| (QUOTE T)) (QUOTE T$)) ((AND (IDENTP |x|) (GETDATABASE |x| (QUOTE NILADIC))) (LIST |x|)) ((QUOTE T) |x|))) ;postBlock ['Block,:l,x] == ; ['SEQ,:postBlockItemList l,['exit,postTran x]] @@ -4329,12 +4314,6 @@ parse ;;; *** |postQuote| REDEFINED (DEFUN |postQuote| (#0=#:G167035) (PROG (|a|) (RETURN (PROGN (SPADLET |a| (CADR #0#)) (CONS (QUOTE QUOTE) (CONS |a| NIL)))))) -;postScriptsForm(['Scripts,op,a],argl) == -; [getScriptName(op,a,#argl),:postTranScripts a,:argl] - -;;; *** |postScriptsForm| REDEFINED - -(DEFUN |postScriptsForm| (#0=#:G167046 |argl|) (PROG (|op| |a|) (RETURN (PROGN (SPADLET |op| (CADR #0#)) (SPADLET |a| (CADDR #0#)) (CONS (|getScriptName| |op| |a| (|#| |argl|)) (APPEND (|postTranScripts| |a|) |argl|)))))) ;postScripts ['Scripts,op,a] == ; [getScriptName(op,a,0),:postTranScripts a]