aboutsummaryrefslogtreecommitdiff
path: root/src/interp
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2011-03-10 07:23:13 +0000
committerdos-reis <gdr@axiomatics.org>2011-03-10 07:23:13 +0000
commit6e3562819cbfa286d4ac03ec3e9c07c5003ea0d9 (patch)
tree97148cb6046c833f8474684ceb589a84dfa3ea56 /src/interp
parent8c47810df65c610513d4be825bd6ee9a56f97f9f (diff)
downloadopen-axiom-6e3562819cbfa286d4ac03ec3e9c07c5003ea0d9.tar.gz
* interp/c-util.boot (resolveConstantForm): New. Split out of
replaceSimpleFunctions. (foldSpadcall): Use it too.
Diffstat (limited to 'src/interp')
-rw-r--r--src/interp/c-util.boot21
1 files changed, 13 insertions, 8 deletions
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