From b32f6a05c34234a5f90d292e3b646810ffd2064b Mon Sep 17 00:00:00 2001 From: dos-reis Date: Thu, 15 Dec 2011 22:59:18 +0000 Subject: * interp/g-util.boot (prefixWalk!): New. * interp/g-opt.boot (cleanLoop!): Rename from removeLoopExitTag!. Adjust caller. Rewrite as a prefix walk. --- src/ChangeLog | 6 ++++++ src/interp/g-opt.boot | 6 +++--- src/interp/g-util.boot | 8 ++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index b82acad7..fd8f184a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2011-12-15 Gabriel Dos Reis + + * interp/g-util.boot (prefixWalk!): New. + * interp/g-opt.boot (cleanLoop!): Rename from removeLoopExitTag!. + Adjust caller. Rewrite as a prefix walk. + 2011-12-15 Gabriel Dos Reis * interp/g-opt.boot (removeLoopExitTag!): New. diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot index 37087c9b..2dc0dd72 100644 --- a/src/interp/g-opt.boot +++ b/src/interp/g-opt.boot @@ -345,10 +345,10 @@ removeLeave! x == walkWith!(x,function f) where x is ['%leave,.,y] and y is ['%return,:.] => resetTo(x,y) x -removeLoopExitTag! x == walkWith!(x,function f) where +cleanLoop! x == prefixWalk!(x,function f) where f x == x is ['%scope,tag,['%repeat,:itl,body,val]] => - resetTo(x,['%repeat,:itl,g(body,tag),g(val,tag)]) + resetTo(x,f ['%repeat,:itl,g(body,tag),g(val,tag)]) x g(x,tag) == atomic? x => x @@ -364,7 +364,7 @@ removeLoopExitTag! x == walkWith!(x,function f) where ++ a lower intermediate form, applying several transformations ++ generaly intended to improve quality and efficiency. optimize! x == - x := spliceSeq! packWhen! transformIF! removeLeave! removeLoopExitTag! x + x := spliceSeq! packWhen! transformIF! removeLeave! cleanLoop! x changeVariableDefinitionToStore(x,nil) simplifyVMForm cancelScopeLeave! spliceSeq! packWhen! inlineLocals! groupTranscients! cancelScopeLeave! removeJunk! reduceXLAM! x diff --git a/src/interp/g-util.boot b/src/interp/g-util.boot index 8c741420..4404d105 100644 --- a/src/interp/g-util.boot +++ b/src/interp/g-util.boot @@ -137,6 +137,14 @@ walkWith!(x,f) == ys.first := walkWith!(first ys,f) apply(f,x,nil) +prefixWalk!(x,f) == + atomic? x => x + x := apply(f,x,nil) + atomic? x => x + for xs in tails x | not atomic? first xs repeat + xs.first := prefixWalk!(first xs,f) + x + listify x == x is [.,:.] => x [x] -- cgit v1.2.3