diff options
-rw-r--r-- | src/ChangeLog | 11 | ||||
-rw-r--r-- | src/interp/buildom.boot | 35 | ||||
-rw-r--r-- | src/interp/g-opt.boot | 25 | ||||
-rw-r--r-- | src/interp/i-eval.boot | 4 | ||||
-rw-r--r-- | src/interp/lisp-backend.boot | 1 | ||||
-rw-r--r-- | src/interp/lisplib.boot | 1 |
6 files changed, 47 insertions, 30 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 96f5842b..c4881406 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2011-05-19 Gabriel Dos Reis <gdr@cs.tamu.edu> + + * interp/i-eval.boot (evalForm): Adjust. + * interp/buildom.boot (mkRecordFun): New. + (eltRecordFun): Likewise. + (copyRecordFun): Likewise. + (mkRecordFunList): Use them. + * interp/g-opt.boot (optMkRecord): Remove. + (optRECORDELT): Likewise. + * interp/lisp-backend.boot: Translate %vcopy. + 2011-05-18 Gabriel Dos Reis <gdr@cs.tamu.edu> * interp/buildom.boot (lookupInDomainVector): Establish a new diff --git a/src/interp/buildom.boot b/src/interp/buildom.boot index d16f5d73..2db25403 100644 --- a/src/interp/buildom.boot +++ b/src/interp/buildom.boot @@ -585,22 +585,49 @@ mkMappingFunList(nam,mapForm,e) == ["ELT",dc,$FirstParamSlot + nargs + 1]]] [substitute(nam,dc,substituteDollarIfRepHack sigFunAlist),e] + +++ Build an inline function for constructing records of length `n'. +mkRecordFun n == + args := take(n,$FormalMapVariableList) + op := + n < 2 => '%list + n = 2 => '%pair + '%vector + ["XLAM",args,[op,:args]] + +++ Build an inline function for selecting field `i' or a +++ record of length `n'. +eltRecordFun(n,i) == + body := + n < 2 => ['%head,"#1"] + n = 2 => + i = 0 => ['%head,"#1"] + ['%tail,"#1"] + ['%vref,"#1",i] + ["XLAM",["#1","#2"],body] + +copyRecordFun n == + body := + n < 2 => ['%list,['%head,"#1"]] + n = 2 => ['%pair,['%head,"#1"],['%tail,"#1"]] + ['%vcopy,"#1"] + ["XLAM",["#1"],body] + mkRecordFunList(nam,["Record",:Alist],e) == len:= #Alist dc := gensym() sigFunAlist:= - [["construct",[nam,:[A for [.,a,A] in Alist]],"mkRecord"], + [["construct",[nam,:[A for [.,a,A] in Alist]],mkRecordFun len], ["=",[$Boolean,nam ,nam],["ELT",dc,$FirstParamSlot + len]], ["~=",[$Boolean,nam,nam],["ELT",dc,0]], ["hash",[$SingleInteger,nam],["ELT",dc,0]], ["coerce",[$OutputForm,nam],["ELT",dc,$FirstParamSlot+len+1]],: - [["elt",[A,nam,PNAME a],["XLAM",["$1","$2"],["RECORDELT","$1",i,len]]] + [["elt",[A,nam,PNAME a],eltRecordFun(len,i)] for i in 0.. for [.,a,A] in Alist],: [["setelt",[A,nam,PNAME a,A],["XLAM",["$1","$2","$3"], ["SETRECORDELT","$1",i, len,"$3"]]] for i in 0.. for [.,a,A] in Alist],: - [["copy",[nam,nam],["XLAM",["$1"],["RECORDCOPY", - "$1",len]]]]] + [["copy",[nam,nam],copyRecordFun len]]] [substitute(nam,dc,substituteDollarIfRepHack sigFunAlist),e] mkNewUnionFunList(name,form is ["Union",:listOfEntries],e) == diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot index 1171c72c..b37b942c 100644 --- a/src/interp/g-opt.boot +++ b/src/interp/g-opt.boot @@ -286,11 +286,6 @@ optCons (x is ["CONS",a,b]) == x x -optMkRecord ["mkRecord",:u] == - u is [x] => ['%list,x] - #u=2 => ['%pair,:u] - ['%vector,:u] - optCond (x is ['%when,:l]) == if l is [a,[aa,b]] and aa is '%otherwise and b is ['%when,:c] then x.rest.rest := c @@ -397,16 +392,6 @@ optSEQ ["SEQ",:l] == l is ["SEQ",[op,a]] and op in '(EXIT RETURN THROW) => a l -optRECORDELT ["RECORDELT",name,ind,len] == - len=1 => - ind=0 => ['%head,name] - keyedSystemError("S2OO0002",[ind]) - len=2 => - ind=0 => ['%head,name] - ind=1 => ['%tail,name] - keyedSystemError("S2OO0002",[ind]) - ['%vref,name,ind] - optSETRECORDELT ["SETRECORDELT",name,ind,len,expr] == len=1 => ind = 0 => ['SEQ,['%store,['%head,name],expr],['EXIT,['%head,name]]] @@ -447,8 +432,9 @@ $VMsideEffectFreeOperators == %lreverse %lempty? %hash %ismall? %string? %f2s %ccst %ccstmax %ceq %clt %cle %cgt %cge %c2i %i2c %s2c %c2s %cup %cdown %sname - %strlength %streq %i2s %schar %strlt %strconc %strcopy - %vector %aref %vref %vlength %bytevec2str %str2bytevec + %strlength %streq %i2s %schar %strlt %strconc + %strcopy %bytevec2str %str2bytevec + %vector %aref %vref %vlength %vcopy %bitvector %bitvecnot %bitvecand %bitvecnand %bivecor %bitvecnor %bitvecxor %bitveccopy %bitvecconc %bitveclength %bitvecref %bitveceq %bitveclt @@ -828,10 +814,7 @@ for x in '( (%call optCall) _ (%when optCond)_ (%retract optRetract)_ (%CollectV optCollectVector)_ - (mkRecord optMkRecord)_ - (RECORDELT optRECORDELT)_ - (SETRECORDELT optSETRECORDELT)_ - (RECORDCOPY optRECORDCOPY)) _ + (SETRECORDELT optSETRECORDELT)) _ repeat property(first x,'OPTIMIZE) := second x --much quicker to call functions if they have an SBC diff --git a/src/interp/i-eval.boot b/src/interp/i-eval.boot index a4fc8e3b..faf20da6 100644 --- a/src/interp/i-eval.boot +++ b/src/interp/i-eval.boot @@ -239,12 +239,8 @@ evalForm(op,opName,argl,mmS) == ['SPADCALL,:form,freeFun] fun is ['XLAM,xargs,:xbody] => rec := first form - xbody is [['RECORDELT,.,ind,len]] => - optRECORDELT([CAAR xbody,rec,ind,len]) xbody is [['SETRECORDELT,.,ind,len,.]] => optSETRECORDELT([CAAR xbody,rec,ind,len,third form]) - xbody is [['RECORDCOPY,.,len]] => - optRECORDCOPY([CAAR xbody,rec,len]) ['FUNCALL,['function , ['LAMBDA,xargs,:xbody]],:TAKE(#xargs, form)] dcVector := evalDomain dc fun0 := diff --git a/src/interp/lisp-backend.boot b/src/interp/lisp-backend.boot index 961cf3fd..3b254c78 100644 --- a/src/interp/lisp-backend.boot +++ b/src/interp/lisp-backend.boot @@ -578,6 +578,7 @@ for x in [ ['%vref, :'SVREF], ['%aref, :'getSimpleArrayEntry], ['%makevector,:'MAKE_-ARRAY], + ['%vcopy, :'COPY_-SEQ], -- symbol unary functions ['%gensym, :'GENSYM], diff --git a/src/interp/lisplib.boot b/src/interp/lisplib.boot index cc4b1a14..8e6aa7a3 100644 --- a/src/interp/lisplib.boot +++ b/src/interp/lisplib.boot @@ -695,7 +695,6 @@ transformOperationAlist operationAlist == impOp is 'XLAM => implementation impOp in '(CONST Subsumed) => impOp keyedSystemError("S2IL0025",[impOp]) - implementation is 'mkRecord => 'mkRecord keyedSystemError("S2IL0025",[implementation]) signatureItem:= if u:= assoc([op,sig],$functionLocations) then n := [n,:rest u] |