From 8a611731641d07f5aa91b1f0bee080afe8e6af94 Mon Sep 17 00:00:00 2001 From: dos-reis Date: Fri, 9 Dec 2011 13:15:21 +0000 Subject: * interp/g-opt.boot (packWehn!): New. (optimize!): Use it. --- src/interp/g-opt.boot | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/interp') diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot index 0b972171..9b09860a 100644 --- a/src/interp/g-opt.boot +++ b/src/interp/g-opt.boot @@ -263,11 +263,23 @@ transformIF! x == walkWith!(x,function f) where resetTo(x,['%when,[p,s1],['%otherwise,s2]]) x +++ Transform nested-to-tower. +packWhen! x == walkWith!(x,function f) where + f x == + x is ['%when,[p1,['%when,[p2,s]]]] => + resetTo(x,f ['%when,[['%and,p1,p2],s]]) + x is ['%when,:cl,['%otherwise,y]] and y is ['%when,:.] => + resetTo(x,f ['%when,:cl,:y.args]) + x is ['%scope,g,['%seq,['%when,[p,['%leave,=g,y]]],['%leave,=g,z]]] + and hasNoLeave?(p,g) => + resetTo(x,f ['%when,[p,y],['%otherwise,mkScope(g,z)]]) + 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 == - simplifyVMForm transformIF! removeSeq! inlineLocals! + simplifyVMForm packWhen! transformIF! removeSeq! inlineLocals! groupTranscients! reduceXLAM! x ++ A non-mutating version of `optimize!'. -- cgit v1.2.3