diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 6 | ||||
-rw-r--r-- | src/interp/c-util.boot | 21 |
2 files changed, 19 insertions, 8 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 35635104..f99eb8b8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2011-03-10 Gabriel Dos Reis <gdr@cs.tamu.edu> + + * interp/c-util.boot (resolveConstantForm): New. Split out of + replaceSimpleFunctions. + (foldSpadcall): Use it too. + 2011-03-09 Gabriel Dos Reis <gdr@cs.tamu.edu> * algebra/catdef.spad.pamphlet (StepThrough) [nextItem]: Now diff --git a/src/interp/c-util.boot b/src/interp/c-util.boot index 8c1fe71b..c493f31f 100644 --- a/src/interp/c-util.boot +++ b/src/interp/c-util.boot @@ -1137,6 +1137,17 @@ eqSubst(args,parms,body) == NSUBLIS(pairList(parms,args),body,KEYWORD::TEST,function EQ) +++ Attempt to resolve the indirect reference to a constant form +++ `[spadConstant,$,n]' to a simpler expression +resolveConstantForm form == + fun := getCapsuleDirectoryEntry third form or return form + -- Conservatively preserve object identity and storage + -- consumption by not folding non-atomic constant forms. + getFunctionReplacement fun isnt ['XLAM,=nil,body] => form + atomic? body or isVMConstantForm body => body + form + + ++ Walk `form' and replace simple functions as appropriate. replaceSimpleFunctions form == atomic? form => form @@ -1144,14 +1155,7 @@ replaceSimpleFunctions form == mutateConditionalFormWithUnaryFunction(form,function replaceSimpleFunctions) form.op is "LET" => optLET mutateBindingFormWithUnaryFunction(form,function replaceSimpleFunctions) - form is ["spadConstant","$",n] => - op := getCapsuleDirectoryEntry n - op = nil => form - -- Conservatively preserve object identity and storage - -- consumption by not folding non-atomic constant forms. - getFunctionReplacement op isnt ['XLAM,=nil,body] => form - atomic? body or isVMConstantForm body => body - form + form is ['spadConstant,'$,.] => resolveConstantForm form -- 1. process argument first. for args in tails rest form repeat arg := first args @@ -1243,6 +1247,7 @@ foldSpadcall form == mutateConditionalFormWithUnaryFunction(form,function foldSpadcall) for x in form repeat foldSpadcall x + form is ['spadConstant,'$,.] => resolveConstantForm form form.op isnt 'SPADCALL => form fun := lastNode form fun isnt [['%tref,'$,slot]] => form |