diff options
author | dos-reis <gdr@axiomatics.org> | 2011-02-28 09:47:25 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2011-02-28 09:47:25 +0000 |
commit | 59ee694e2266b29dff595286647998eb448537ac (patch) | |
tree | d34a231bea90607eb7198191bd1c05469a4f06bc | |
parent | 26253eebb30fc5f6074836e387547d6353779049 (diff) | |
download | open-axiom-59ee694e2266b29dff595286647998eb448537ac.tar.gz |
* interp/i-code.boot: Move content to i-coerce.boot. Delete.
-rw-r--r-- | src/ChangeLog | 4 | ||||
-rw-r--r-- | src/interp/Makefile.in | 3 | ||||
-rw-r--r-- | src/interp/i-code.boot | 147 | ||||
-rw-r--r-- | src/interp/i-coerce.boot | 111 |
4 files changed, 116 insertions, 149 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index ed975515..f9082fe8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2011-02-28 Gabriel Dos Reis <gdr@cs.tamu.edu> + * interp/i-code.boot: Move content to i-coerce.boot. Delete. + +2011-02-28 Gabriel Dos Reis <gdr@cs.tamu.edu> + * algebra/boolean.spad.pamphlet (PropositionalFormula): Implement true and false. Fix thinko in notFormula. diff --git a/src/interp/Makefile.in b/src/interp/Makefile.in index 00a0a2ad..93d1cd65 100644 --- a/src/interp/Makefile.in +++ b/src/interp/Makefile.in @@ -88,7 +88,7 @@ OBJS= boot-pkg.$(FASLEXT) types.$(FASLEXT) \ ggreater.$(FASLEXT) \ hypertex.$(FASLEXT) \ i-object.$(FASLEXT) i-analy.$(FASLEXT) \ - i-code.$(FASLEXT) i-resolv.$(FASLEXT) \ + i-resolv.$(FASLEXT) \ i-coerce.$(FASLEXT) \ i-coerfn.$(FASLEXT) i-eval.$(FASLEXT) \ i-funsel.$(FASLEXT) \ @@ -337,7 +337,6 @@ i-coerce.$(FASLEXT): i-analy.$(FASLEXT) i-resolv.$(FASLEXT) i-resolv.$(FASLEXT): i-object.$(FASLEXT) i-analy.$(FASLEXT): i-object.$(FASLEXT) i-intern.$(FASLEXT): i-object.$(FASLEXT) ptrees.$(FASLEXT) -i-code.$(FASLEXT): i-object.$(FASLEXT) i-object.$(FASLEXT): g-util.$(FASLEXT) i-util.$(FASLEXT): g-util.$(FASLEXT) format.$(FASLEXT): macros.$(FASLEXT) diff --git a/src/interp/i-code.boot b/src/interp/i-code.boot deleted file mode 100644 index 6db15fe9..00000000 --- a/src/interp/i-code.boot +++ /dev/null @@ -1,147 +0,0 @@ --- Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. --- All rights reserved. --- Copyright (C) 2007-2011, Gabriel Dos Reis. --- All rights reserved. --- --- Redistribution and use in source and binary forms, with or without --- modification, are permitted provided that the following conditions are --- met: --- --- - Redistributions of source code must retain the above copyright --- notice, this list of conditions and the following disclaimer. --- --- - Redistributions in binary form must reproduce the above copyright --- notice, this list of conditions and the following disclaimer in --- the documentation and/or other materials provided with the --- distribution. --- --- - Neither the name of The Numerical ALgorithms Group Ltd. nor the --- names of its contributors may be used to endorse or promote products --- derived from this software without specific prior written permission. --- --- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS --- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED --- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER --- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, --- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, --- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -import i_-object -namespace BOOT - ---% Interpreter Code Generation Routines - ---Modified by JHD 9/9/93 to fix a problem with coerces inside ---interpreter functions being used as mappings. They were being ---handled with $useCoerceOrCroak being NIL, and therefore internal ---coercions were not correctly handled. Fix: remove dependence ---on $useCoerceOrCroak, and test explicitly for Mapping types. - ---% COERCE - -intCodeGenCOERCE(triple,t2) == - -- NOTE: returns a triple - t1 := objMode triple - t1 = $EmptyMode => NIL - t1 = t2 => triple - val := objVal triple - - -- if request is for a coerce to t2 from a coerce from - -- to to t1, and t1 = Void or canCoerce(t0,t2), then optimize - - (val is ['coerceOrCroak,trip,t1', .]) and - (t0 := objCodeMode trip) and ([.,val0] := objCodeVal trip) and - ( (t1 = $Void) or canCoerceFrom(removeQuote t0,t2) ) => - -- just generate code for coercion, don't coerce constants - -- might be too big - intCodeGenCOERCE(objNew(val0, removeQuote t0), t2) - - val is ['THROW,label,code] => - if label is ['QUOTE, l] then label := l - null($compilingMap) or (label ~= mapCatchName($mapName)) => - objNew(['THROW,label,getValueNormalForm - intCodeGenCOERCE(objNew(code,t1),t2)],t2) - -- we have a return statement. just send it back as is - objNew(val,t2) - - val is ['PROGN,:code,lastCode] => - objNew(['PROGN,:code,getValueNormalForm - intCodeGenCOERCE(objNew(lastCode,t1),t2)],t2) - - val is ['%when,:conds] => - objNew(['%when, - :[[p,getValueNormalForm intCodeGenCOERCE(objNew(v,t1),t2)] - for [p,v] in conds]],t2) - - -- specially handle subdomain - absolutelyCanCoerceByCheating(t1,t2) => objNew(val,t2) - - -- specially handle coerce to Any - t2 = $Any => objNew(['CONS,MKQ t1,val],t2) - - -- optimize coerces from Any - (t1 = $Any) and (val is ['CONS,t1',val']) => - intCodeGenCOERCE(objNew(val',removeQuote t1'),t2) - - -- specially handle coerce from Equation to Boolean - (t1 is ['Equation,:.]) and (t2 = $Boolean) => - coerceByFunction(triple,t2) - - -- next is hack for if-then-elses - (t1 = '$NoValueMode) and (val is ['%when,pred]) => - code := - ['%when,pred, - ['%otherwise,['throwKeyedMsg,MKQ "S2IM0016",MKQ $mapName]]] - objNew(code,t2) - - -- optimize coerces to Expression - t2 = $OutputForm => - coerceByFunction(triple,t2) - - isSubDomain(t1, $Integer) => - intCodeGenCOERCE(objNew(val, $Integer), t2) - - -- generate code - -- 1. See if the coercion will go through (absolutely) - -- Must be careful about variables or else things like - -- P I --> P[x] P I might not have the x in the original polynomial - -- put in the correct place - - (not containsVariables(t2)) and canCoerceByFunction(t1,t2) => - -- try coerceByFunction - (not canCoerceByMap(t1,t2)) and - (code := coerceByFunction(triple,t2)) => code - intCodeGenCoerce1(val,t1,t2) - - -- 2. Set up a failure point otherwise - - intCodeGenCoerce1(val,t1,t2) - -intCodeGenCoerce1(val,t1,t2) == - -- Internal function to previous one - -- designed to ensure that we don't use coerceOrCroak on mappings ---(t2 is ['Mapping,:.]) => THROW('coerceOrCroaker, 'croaked) - objNew(['coerceOrCroak,objNewCode(['wrap,val],t1), - MKQ t2, MKQ $mapName],t2) - ---% Map components - -wrapMapBodyWithCatch body == - -- places a CATCH around the map body - -- note that we will someday have to fix up the catch identifier - -- to use the generated internal map name - $mapThrowCount = 0 => body - if body is ['failCheck,['coerceOrFail,trip,targ,mapn]] - then - trip is ['LIST,v,m,e] => - ['failCheck,['coerceOrFail, - ['LIST,['CATCH,MKQ mapCatchName $mapName, v],m,e],targ,mapn]] - keyedSystemError("S2GE0016",['"wrapMapBodyWithCatch", - '"bad CATCH for in function form"]) - else ['CATCH,MKQ mapCatchName $mapName,body] diff --git a/src/interp/i-coerce.boot b/src/interp/i-coerce.boot index 89e1699b..a56ae5d1 100644 --- a/src/interp/i-coerce.boot +++ b/src/interp/i-coerce.boot @@ -1361,3 +1361,114 @@ hasCorrectTarget(m,sig is [dc,tar,:.]) == tar is ['Union,t,'failed] => t=m tar is ['Union,'failed,t] and t=m + +--% Interpreter Code Generation Routines + +--Modified by JHD 9/9/93 to fix a problem with coerces inside +--interpreter functions being used as mappings. They were being +--handled with $useCoerceOrCroak being NIL, and therefore internal +--coercions were not correctly handled. Fix: remove dependence +--on $useCoerceOrCroak, and test explicitly for Mapping types. + +--% COERCE + +intCodeGenCOERCE(triple,t2) == + -- NOTE: returns a triple + t1 := objMode triple + t1 = $EmptyMode => NIL + t1 = t2 => triple + val := objVal triple + + -- if request is for a coerce to t2 from a coerce from + -- to to t1, and t1 = Void or canCoerce(t0,t2), then optimize + + (val is ['coerceOrCroak,trip,t1', .]) and + (t0 := objCodeMode trip) and ([.,val0] := objCodeVal trip) and + ( (t1 = $Void) or canCoerceFrom(removeQuote t0,t2) ) => + -- just generate code for coercion, don't coerce constants + -- might be too big + intCodeGenCOERCE(objNew(val0, removeQuote t0), t2) + + val is ['THROW,label,code] => + if label is ['QUOTE, l] then label := l + null($compilingMap) or (label ~= mapCatchName($mapName)) => + objNew(['THROW,label,getValueNormalForm + intCodeGenCOERCE(objNew(code,t1),t2)],t2) + -- we have a return statement. just send it back as is + objNew(val,t2) + + val is ['PROGN,:code,lastCode] => + objNew(['PROGN,:code,getValueNormalForm + intCodeGenCOERCE(objNew(lastCode,t1),t2)],t2) + + val is ['%when,:conds] => + objNew(['%when, + :[[p,getValueNormalForm intCodeGenCOERCE(objNew(v,t1),t2)] + for [p,v] in conds]],t2) + + -- specially handle subdomain + absolutelyCanCoerceByCheating(t1,t2) => objNew(val,t2) + + -- specially handle coerce to Any + t2 = $Any => objNew(['CONS,MKQ t1,val],t2) + + -- optimize coerces from Any + (t1 = $Any) and (val is ['CONS,t1',val']) => + intCodeGenCOERCE(objNew(val',removeQuote t1'),t2) + + -- specially handle coerce from Equation to Boolean + (t1 is ['Equation,:.]) and (t2 = $Boolean) => + coerceByFunction(triple,t2) + + -- next is hack for if-then-elses + (t1 = '$NoValueMode) and (val is ['%when,pred]) => + code := + ['%when,pred, + ['%otherwise,['throwKeyedMsg,MKQ "S2IM0016",MKQ $mapName]]] + objNew(code,t2) + + -- optimize coerces to Expression + t2 = $OutputForm => + coerceByFunction(triple,t2) + + isSubDomain(t1, $Integer) => + intCodeGenCOERCE(objNew(val, $Integer), t2) + + -- generate code + -- 1. See if the coercion will go through (absolutely) + -- Must be careful about variables or else things like + -- P I --> P[x] P I might not have the x in the original polynomial + -- put in the correct place + + (not containsVariables(t2)) and canCoerceByFunction(t1,t2) => + -- try coerceByFunction + (not canCoerceByMap(t1,t2)) and + (code := coerceByFunction(triple,t2)) => code + intCodeGenCoerce1(val,t1,t2) + + -- 2. Set up a failure point otherwise + + intCodeGenCoerce1(val,t1,t2) + +intCodeGenCoerce1(val,t1,t2) == + -- Internal function to previous one + -- designed to ensure that we don't use coerceOrCroak on mappings +--(t2 is ['Mapping,:.]) => THROW('coerceOrCroaker, 'croaked) + objNew(['coerceOrCroak,objNewCode(['wrap,val],t1), + MKQ t2, MKQ $mapName],t2) + +--% Map components + +wrapMapBodyWithCatch body == + -- places a CATCH around the map body + -- note that we will someday have to fix up the catch identifier + -- to use the generated internal map name + $mapThrowCount = 0 => body + if body is ['failCheck,['coerceOrFail,trip,targ,mapn]] + then + trip is ['LIST,v,m,e] => + ['failCheck,['coerceOrFail, + ['LIST,['CATCH,MKQ mapCatchName $mapName, v],m,e],targ,mapn]] + keyedSystemError("S2GE0016",['"wrapMapBodyWithCatch", + '"bad CATCH for in function form"]) + else ['CATCH,MKQ mapCatchName $mapName,body] |