diff --git a/books/bookvol9.pamphlet b/books/bookvol9.pamphlet index 401343d..915c1f9 100644 --- a/books/bookvol9.pamphlet +++ b/books/bookvol9.pamphlet @@ -4124,6 +4124,51 @@ An angry JHD - August 15th., 1984 @ +\defplist{return}{compReturn} +<>= +(eval-when (eval load) + (setf (get '|return| 'special) '|compReturn|)) + +@ + +\defun{compReturn}{compReturn} +\calls{compReturn}{stackSemanticError} +\calls{compReturn}{nequal} +\calls{compReturn}{userError} +\calls{compReturn}{resolve} +\calls{compReturn}{comp} +\calls{compReturn}{modifyModeStack} +\usesdollar{compReturn}{exitModeStack} +\usesdollar{compReturn}{returnMode} +<>= +(defun |compReturn| (arg m e) + (let (level x index u xp mp ep) + (declare (special |$returnMode| |$exitModeStack|)) + (setq level (second arg)) + (setq x (third arg)) + (cond + ((null |$exitModeStack|) + (|stackSemanticError| + (list '|the return before| '|%b| x '|%d| '|is unneccessary|) nil) + nil) + ((nequal level 1) + (|userError| "multi-level returns not supported")) + (t + (setq index (max 0 (1- (|#| |$exitModeStack|)))) + (when (>= index 0) + (setq |$returnMode| + (|resolve| (elt |$exitModeStack| index) |$returnMode|))) + (when (setq u (|comp| x |$returnMode| e)) + (setq xp (first u)) + (setq mp (second u)) + (setq ep (third u)) + (when (>= index 0) + (setq |$returnMode| (|resolve| mp |$returnMode|)) + (|modifyModeStack| mp index)) + (list (list '|TAGGEDreturn| 0 u) m ep)))))) + +@ + \defplist{seq}{compSeq} <>= (eval-when (eval load) @@ -4181,6 +4226,148 @@ An angry JHD - August 15th., 1984 @ +\defplist{let}{compSetq} +<>= +(eval-when (eval load) + (setf (get 'let 'special) '|compSetq|)) + +@ + +\defplist{setq}{compSetq} +<>= +(eval-when (eval load) + (setf (get 'setq 'special) '|compSetq|)) + +@ + +\defun{compSetq}{compSetq} +\calls{compSetq}{compSetq1} +<>= +(defun |compSetq| (arg m e) + (|compSetq1| (second arg) (third arg) m e)) + +@ + +\defun{compSetq1}{compSetq1} +\calls{compSetq1}{setqSingle} +\calls{compSetq1}{identp} +\calls{compSetq1}{compMakeDeclaration} +\calls{compSetq1}{compSetq} +\calls{compSetq1}{qcar} +\calls{compSetq1}{qcdr} +\calls{compSetq1}{setqMultiple} +\calls{compSetq1}{setqSetelt} +\usesdollar{compSetq1}{EmptyMode} +<>= +(defun |compSetq1| (form val m e) + (let (x y ep op z) + (declare (special |$EmptyMode|)) + (cond + ((identp form) (|setqSingle| form val m e)) + ((and (pairp form) (eq (qcar form) '|:|) (pairp (qcdr form)) + (pairp (qcdr (qcdr form))) (eq (qcdr (qcdr (qcdr form))) nil)) + (setq x (second form)) + (setq y (third form)) + (setq ep (third (|compMakeDeclaration| form |$EmptyMode| e))) + (|compSetq| (list 'let x val) m ep)) + ((pairp form) + (setq op (qcar form)) + (setq z (qcdr form)) + (cond + ((eq op 'cons) (|setqMultiple| (|uncons| form) val m e)) + ((eq op '|@Tuple|) (|setqMultiple| z val m e)) + (t (|setqSetelt| form val m e))))))) + +@ + +\defun{setqSetelt}{setqSetelt} +\calls{setqSetelt}{comp} +<>= +(defun |setqSetelt| (arg val m e) + (|comp| (cons '|setelt| (cons (car arg) (append (cdr arg) (list val)))) m e)) + +@ + +\defun{setqSingle}{setqSingle} +\calls{setqSingle}{getProplist} +\calls{setqSingle}{getmode} +\calls{setqSingle}{get} +\calls{setqSingle}{nequal} +\calls{setqSingle}{maxSuperType} +\calls{setqSingle}{comp} +\calls{setqSingle}{getmode} +\calls{setqSingle}{assignError} +\calls{setqSingle}{convert} +\calls{setqSingle}{identp} +\calls{setqSingle}{profileRecord} +\calls{setqSingle}{consProplistOf} +\calls{setqSingle}{removeEnv} +\calls{setqSingle}{addBinding} +\calls{setqSingle}{isDomainForm} +\calls{setqSingle}{isDomainInScope} +\calls{setqSingle}{stackWarning} +\calls{setqSingle}{augModemapsFromDomain1} +\calls{setqSingle}{NRTassocIndex} +\calls{setqSingle}{isDomainForm} +\calls{setqSingle}{outputComp} +\usesdollar{setqSingle}{insideSetqSingleIfTrue} +\usesdollar{setqSingle}{QuickLet} +\usesdollar{setqSingle}{form} +\usesdollar{setqSingle}{profileCompiler} +\usesdollar{setqSingle}{EmptyMode} +\usesdollar{setqSingle}{NoValueMode} +<>= +(defun |setqSingle| (id val m e) + (let (|$insideSetqSingleIfTrue| currentProplist mpp maxmpp td x mp tp key + newProplist ep k form) + (declare (special |$insideSetqSingleIfTrue| |$QuickLet| |$form| + |$profileCompiler| |$EmptyMode| |$NoValueMode|)) + (setq |$insideSetqSingleIfTrue| t) + (setq currentProplist (|getProplist| id e)) + (setq mpp + (or (|get| id '|mode| e) (|getmode| id e) + (if (equal m |$NoValueMode|) |$EmptyMode| m))) + (when (setq td + (cond + ((setq td (|comp| val mpp e)) + td) + ((and (null (|get| id '|mode| e)) + (nequal mpp (setq maxmpp (|maxSuperType| mpp e))) + (setq td (|comp| val maxmpp e))) + td) + ((and (setq td (|comp| val |$EmptyMode| e)) + (|getmode| (second td) e)) + (|assignError| val (second td) id mpp)))) + (when (setq tp (|convert| td m)) + (setq x (first tp)) + (setq mp (second tp)) + (setq ep (third tp)) + (when (and |$profileCompiler| (identp id)) + (setq key (if (member id (cdr |$form|)) '|arguments| '|locals|)) + (|profileRecord| key id (second td))) + (setq newProplist + (|consProplistOf| id currentProplist '|value| + (|removeEnv| (cons val (cdr td))))) + (setq ep (if (pairp id) ep (|addBinding| id newProplist ep))) + (when (|isDomainForm| val ep) + (when (|isDomainInScope| id ep) + (|stackWarning| + (list '|domain valued variable| '|%b| id '|%d| + '|has been reassigned within its scope| ))) + (setq ep (|augModemapsFromDomain1| id val ep))) + (if (setq k (|NRTassocIndex| id)) + (setq form (list 'setelt '$ k x)) + (setq form + (if |$QuickLet| + (list 'let id x) + (list 'let id x + (if (|isDomainForm| x ep) + (list 'elt id 0) + (car (|outputComp| id ep))))))) + (list form mp ep))))) + +@ + \defplist{vector}{compVector} <>= (eval-when (eval load) @@ -11430,9 +11617,14 @@ if \verb|$InteractiveMode| then use a null outputstream <> <> <> +<> <> <> <> +<> +<> +<> +<> <> <> <> diff --git a/changelog b/changelog index e9d5ba1..91e6e99 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,7 @@ +20101206 tpd src/axiom-website/patches.html 20101206.01.tpd.patch +20101206 tpd src/interp/postprop.lisp treeshake comiler +20101206 tpd src/interp/compiler.lisp treeshake compiler +20101206 tpd books/bookvol9 treeshake compiler 20101205 tpd src/axiom-website/patches.html 20101205.02.tpd.patch 20101205 tpd src/interp/postprop.lisp treeshake compiler 20101205 tpd src/interp/iterator.lisp treeshake compiler diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html index eb218c2..96d1ffb 100644 --- a/src/axiom-website/patches.html +++ b/src/axiom-website/patches.html @@ -3295,5 +3295,7 @@ In process, not yet released

src/axiom-website/download.html add ubuntu
20101205.02.tpd.patch books/bookvol9 treeshake compiler
+20101206.01.tpd.patch +books/bookvol9 treeshake compiler
diff --git a/src/interp/compiler.lisp.pamphlet b/src/interp/compiler.lisp.pamphlet index 5bab77d..d1ed42f 100644 --- a/src/interp/compiler.lisp.pamphlet +++ b/src/interp/compiler.lisp.pamphlet @@ -924,215 +924,6 @@ Compile SubsetCategory @ -\subsection{compSetq} -Compile setq -<<*>>= -;compSetq(["LET",form,val],m,E) == compSetq1(form,val,m,E) - -(DEFUN |compSetq| (G168129 |m| E) - (PROG (|form| |val|) - (RETURN - (PROGN - (COND ((EQ (CAR G168129) 'LET) (CAR G168129))) - (SPADLET |form| (CADR G168129)) - (SPADLET |val| (CADDR G168129)) - (|compSetq1| |form| |val| |m| E))))) - -@ -\subsection{compSetq1} -<<*>>= -;compSetq1(form,val,m,E) == -; IDENTP form => setqSingle(form,val,m,E) -; form is [":",x,y] => -; [.,.,E']:= compMakeDeclaration(form,$EmptyMode,E) -; compSetq(["LET",x,val],m,E') -; form is [op,:l] => -; op="CONS" => setqMultiple(uncons form,val,m,E) -; op="Tuple" => setqMultiple(l,val,m,E) -; setqSetelt(form,val,m,E) - -(DEFUN |compSetq1| (|form| |val| |m| E) - (PROG (|ISTMP#1| |x| |ISTMP#2| |y| |LETTMP#1| |E'| |op| |l|) - (declare (special |$EmptyMode|)) - (RETURN - (COND - ((IDENTP |form|) (|setqSingle| |form| |val| |m| E)) - ((AND (PAIRP |form|) (EQ (QCAR |form|) '|:|) - (PROGN - (SPADLET |ISTMP#1| (QCDR |form|)) - (AND (PAIRP |ISTMP#1|) - (PROGN - (SPADLET |x| (QCAR |ISTMP#1|)) - (SPADLET |ISTMP#2| (QCDR |ISTMP#1|)) - (AND (PAIRP |ISTMP#2|) (EQ (QCDR |ISTMP#2|) NIL) - (PROGN (SPADLET |y| (QCAR |ISTMP#2|)) 'T)))))) - (SPADLET |LETTMP#1| - (|compMakeDeclaration| |form| |$EmptyMode| E)) - (SPADLET |E'| (CADDR |LETTMP#1|)) - (|compSetq| (CONS 'LET (CONS |x| (CONS |val| NIL))) |m| |E'|)) - ((AND (PAIRP |form|) - (PROGN - (SPADLET |op| (QCAR |form|)) - (SPADLET |l| (QCDR |form|)) - 'T)) - (COND - ((BOOT-EQUAL |op| 'CONS) - (|setqMultiple| (|uncons| |form|) |val| |m| E)) - ((BOOT-EQUAL |op| '|@Tuple|) - (|setqMultiple| |l| |val| |m| E)) - ('T (|setqSetelt| |form| |val| |m| E)))))))) - -@ -\subsection{setqSetelt} -Compile setelt -<<*>>= -;setqSetelt([v,:s],val,m,E) == -; comp(["setelt",v,:s,val],m,E) - -(DEFUN |setqSetelt| (G168190 |val| |m| E) - (PROG (|v| |s|) - (RETURN - (PROGN - (SPADLET |v| (CAR G168190)) - (SPADLET |s| (CDR G168190)) - (|comp| (CONS '|setelt| - (CONS |v| (APPEND |s| (CONS |val| NIL)))) - |m| E))))) - -@ -\subsection{setqSingle} -<<*>>= -;setqSingle(id,val,m,E) == -; $insideSetqSingleIfTrue: local:= true -; --used for comping domain forms within functions -; currentProplist:= getProplist(id,E) -; m'':= -; get(id,'mode,E) or getmode(id,E) or -; (if m=$NoValueMode then $EmptyMode else m) -;-- m'':= LASSOC("mode",currentProplist) or $EmptyMode -; --for above line to work, line 3 of compNoStackingis required -; T:= -; eval or return nil where -; eval() == -; T:= comp(val,m'',E) => T -; not get(id,"mode",E) and m'' ^= (maxm'':=maxSuperType(m'',E)) and -; (T:=comp(val,maxm'',E)) => T -; (T:= comp(val,$EmptyMode,E)) and getmode(T.mode,E) => -; assignError(val,T.mode,id,m'') -; T':= [x,m',e']:= convert(T,m) or return nil -; if $profileCompiler = true then -; null IDENTP id => nil -; key := -; MEMQ(id,rest $form) => 'arguments -; 'locals -; profileRecord(key,id,T.mode) -; newProplist:= consProplistOf(id,currentProplist,"value",removeEnv [val,:rest T]) -; e':= (PAIRP id => e'; addBinding(id,newProplist,e')) -; if isDomainForm(val,e') then -; if isDomainInScope(id,e') then -; stackWarning ["domain valued variable","%b",id,"%d", -; "has been reassigned within its scope"] -; e':= augModemapsFromDomain1(id,val,e') -; --all we do now is to allocate a slot number for lhs -; --e.g. the LET form below will be changed by putInLocalDomainReferences -;--+ -; if (k:=NRTassocIndex(id)) -; then form:=['SETELT,"$",k,x] -; else form:= -; $QuickLet => ["LET",id,x] -; ["LET",id,x, -; (isDomainForm(x,e') => ['ELT,id,0];CAR outputComp(id,e'))] -; [form,m',e'] - -(DEFUN |setqSingle| (|id| |val| |m| E) - (PROG (|$insideSetqSingleIfTrue| |currentProplist| |m''| |maxm''| T$ - |LETTMP#1| |x| |m'| |T'| |key| |newProplist| |e'| |k| |form|) - (DECLARE (SPECIAL |$insideSetqSingleIfTrue| |$QuickLet| |$form| - |$profileCompiler| |$EmptyMode| |$NoValueMode|)) - (RETURN - (PROGN - (SPADLET |$insideSetqSingleIfTrue| 'T) - (SPADLET |currentProplist| (|getProplist| |id| E)) - (SPADLET |m''| - (OR (|get| |id| '|mode| E) (|getmode| |id| E) - (COND - ((BOOT-EQUAL |m| |$NoValueMode|) |$EmptyMode|) - ('T |m|)))) - (SPADLET T$ - (OR (COND - ((SPADLET T$ (|comp| |val| |m''| E)) T$) - ((AND (NULL (|get| |id| '|mode| E)) - (NEQUAL |m''| - (SPADLET |maxm''| - (|maxSuperType| |m''| E))) - (SPADLET T$ (|comp| |val| |maxm''| E))) - T$) - ((AND (SPADLET T$ (|comp| |val| |$EmptyMode| E)) - (|getmode| (CADR T$) E)) - (|assignError| |val| (CADR T$) |id| |m''|))) - (RETURN NIL))) - (SPADLET |T'| - (PROGN - (SPADLET |LETTMP#1| - (OR (|convert| T$ |m|) (RETURN NIL))) - (SPADLET |x| (CAR |LETTMP#1|)) - (SPADLET |m'| (CADR |LETTMP#1|)) - (SPADLET |e'| (CADDR |LETTMP#1|)) - |LETTMP#1|)) - (COND - ((BOOT-EQUAL |$profileCompiler| 'T) - (COND - ((NULL (IDENTP |id|)) NIL) - ('T - (SPADLET |key| - (COND - ((member |id| (CDR |$form|)) '|arguments|) - ('T '|locals|))) - (|profileRecord| |key| |id| (CADR T$)))))) - (SPADLET |newProplist| - (|consProplistOf| |id| |currentProplist| '|value| - (|removeEnv| (CONS |val| (CDR T$))))) - (SPADLET |e'| - (COND - ((PAIRP |id|) |e'|) - ('T (|addBinding| |id| |newProplist| |e'|)))) - (COND - ((|isDomainForm| |val| |e'|) - (COND - ((|isDomainInScope| |id| |e'|) - (|stackWarning| - (CONS '|domain valued variable| - (CONS '|%b| - (CONS |id| - (CONS '|%d| - (CONS - '|has been reassigned within its scope| - NIL)))))))) - (SPADLET |e'| (|augModemapsFromDomain1| |id| |val| |e'|)))) - (COND - ((SPADLET |k| (|NRTassocIndex| |id|)) - (SPADLET |form| - (CONS 'SETELT (CONS '$ (CONS |k| (CONS |x| NIL)))))) - ('T - (SPADLET |form| - (COND - (|$QuickLet| - (CONS 'LET (CONS |id| (CONS |x| NIL)))) - ('T - (CONS 'LET - (CONS |id| - (CONS |x| - (CONS - (COND - ((|isDomainForm| |x| |e'|) - (CONS 'ELT - (CONS |id| (CONS 0 NIL)))) - ('T - (CAR (|outputComp| |id| |e'|)))) - NIL))))))))) - (CONS |form| (CONS |m'| (CONS |e'| NIL))))))) - -@ \subsection{assignError} <<*>>= ;assignError(val,m',form,m) == @@ -1670,63 +1461,6 @@ Compile suchthat (CONS |x'| (CONS |m'| (CONS |e| NIL))))))) @ -\subsection{compReturn} -Compile return -<<*>>= -;compReturn(["return",level,x],m,e) == -; null $exitModeStack => -; stackSemanticError(["the return before","%b",x,"%d","is unneccessary"],nil) -; nil -; level^=1 => userError '"multi-level returns not supported" -; index:= MAX(0,#$exitModeStack-1) -; if index>=0 then $returnMode:= resolve($exitModeStack.index,$returnMode) -; [x',m',e']:= u:= comp(x,$returnMode,e) or return nil -; if index>=0 then -; $returnMode:= resolve(m',$returnMode) -; modifyModeStack(m',index) -; [["TAGGEDreturn",0,u],m,e'] - -(DEFUN |compReturn| (G169083 |m| |e|) - (PROG (|level| |x| |index| |u| |x'| |m'| |e'|) - (declare (special |$returnMode| |$exitModeStack|)) - (RETURN - (PROGN - (COND ((EQ (CAR G169083) '|return|) (CAR G169083))) - (SPADLET |level| (CADR G169083)) - (SPADLET |x| (CADDR G169083)) - (COND - ((NULL |$exitModeStack|) - (|stackSemanticError| - (CONS '|the return before| - (CONS '|%b| - (CONS |x| - (CONS '|%d| - (CONS '|is unneccessary| NIL))))) - NIL) - NIL) - ((NEQUAL |level| 1) - (|userError| - "multi-level returns not supported")) - ('T - (SPADLET |index| - (MAX 0 (SPADDIFFERENCE (|#| |$exitModeStack|) 1))) - (COND - ((>= |index| 0) - (SPADLET |$returnMode| - (|resolve| (ELT |$exitModeStack| |index|) - |$returnMode|)))) - (SPADLET |u| - (OR (|comp| |x| |$returnMode| |e|) (RETURN NIL))) - (SPADLET |x'| (CAR |u|)) (SPADLET |m'| (CADR |u|)) - (SPADLET |e'| (CADDR |u|)) - (COND - ((>= |index| 0) - (SPADLET |$returnMode| (|resolve| |m'| |$returnMode|)) - (|modifyModeStack| |m'| |index|))) - (CONS (CONS '|TAGGEDreturn| (CONS 0 (CONS |u| NIL))) - (CONS |m| (CONS |e'| NIL))))))))) - -@ \subsection{compHasFormat} <<*>>= ;compHasFormat (pred is ["has",olda,b]) == diff --git a/src/interp/postprop.lisp.pamphlet b/src/interp/postprop.lisp.pamphlet index 44ab3a0..3302fcb 100644 --- a/src/interp/postprop.lisp.pamphlet +++ b/src/interp/postprop.lisp.pamphlet @@ -83,9 +83,9 @@ ; (REDUCE |compReduce|) ; (COLLECT |compRepeatOrCollect|) ; (REPEAT |compRepeatOrCollect|) - (|return| |compReturn|) - (LET |compSetq|) - (SETQ |compSetq|) +; (|return| |compReturn|) +; (LET |compSetq|) +; (SETQ |compSetq|) ; (SEQ |compSeq|) (|String| |compString|) (|SubDomain| |compSubDomain|)