diff options
Diffstat (limited to 'src/interp/g-opt.boot')
-rw-r--r-- | src/interp/g-opt.boot | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot index 7816eafb..75d358da 100644 --- a/src/interp/g-opt.boot +++ b/src/interp/g-opt.boot @@ -371,14 +371,22 @@ cleanLoop! x == prefixWalk!(x,function f) where xs.first := g(first xs,tag) x +removeScope! x == prefixWalk!(x,function f) where + f x == + x is ['%scope,g,y] => + hasNoLeave?(y,g) => resetTo(x,f y) + x + x + ++ Transform an intermediate form (output of the elaborator) to ++ a lower intermediate form, applying several transformations ++ generaly intended to improve quality and efficiency. optimize! x == x := spliceSeq! packWhen! transformIF! removeLeave! cleanLoop! x changeVariableDefinitionToStore(x,nil) - simplifyVMForm cancelScopeLeave! spliceSeq! packWhen! inlineLocals! - groupTranscients! cancelScopeLeave! removeJunk! reduceXLAM! x + simplifyVMForm removeScope! cancelScopeLeave! spliceSeq! packWhen! + inlineLocals! groupTranscients! cancelScopeLeave! + removeJunk! reduceXLAM! x ++ A non-mutating version of `optimize!'. optimize x == @@ -395,22 +403,6 @@ optimizeFunctionDef(def) == sayBrightlyI bright '"Intermediate VM code:" pp expr - expr.absBody := - removeTopLevelLabel expr.absBody where - removeTopLevelLabel body == - body is ['%scope,g,u] => - removeTopLevelLabel replaceLeaveByReturn(u,g) - body - replaceLeaveByReturn(x,g) == - fn(x,g) - x - fn(x,g) == - x is ['%leave,=g,:u] => - x.first := "RETURN" - x.rest := replaceLeaveByReturn(u,g) - x isnt [.,:.] => nil - replaceLeaveByReturn(first x,g) - replaceLeaveByReturn(rest x,g) [first def,expr] resetTo(x,y) == |