aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2011-12-12 17:58:32 +0000
committerdos-reis <gdr@axiomatics.org>2011-12-12 17:58:32 +0000
commit5f863b1ca407b898fd3bf788cb3aaffdb2701d2b (patch)
tree171bb926c431a235a5fb3866a66f7424f5ff7017
parentc81c34e8a92f6982d761a48cc2b103ce736fbf95 (diff)
downloadopen-axiom-5f863b1ca407b898fd3bf788cb3aaffdb2701d2b.tar.gz
* interp/g-opt.boot (packWhen!): Tidy.
(spliceSeq!): New. (optimize!): Run splice! packWhen! twice.
-rw-r--r--src/ChangeLog6
-rw-r--r--src/interp/g-opt.boot27
2 files changed, 27 insertions, 6 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index e611f359..e8f198e6 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2011-12-12 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * interp/g-opt.boot (packWhen!): Tidy.
+ (spliceSeq!): New.
+ (optimize!): Run splice! packWhen! twice.
+
2011-12-11 Gabriel Dos Reis <gdr@cs.tamu.edu>
* interp/g-util.boot (liftAassignments!): New.
diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot
index 1e2703d7..bdca2d74 100644
--- a/src/interp/g-opt.boot
+++ b/src/interp/g-opt.boot
@@ -289,22 +289,37 @@ coagulateWhenSeries(x,tag) ==
++ Transform nested-to-tower.
packWhen! x == walkWith!(x,function f) where
f x ==
+ x is ['%scope,g,y] and y is ['%seq,:stmts] =>
+ repeat
+ stmts = nil => leave nil
+ s := first stmts
+ s is ['%when,[p,u:=['%leave,=g,.]],['%otherwise,v]] =>
+ stmts.first := ['%when,[p,u]]
+ stmts.rest := [v,:rest stmts]
+ stmts := rest stmts
+ y.args is [['%when,[p,['%leave,=g,u]]],['%leave,=g,v]] =>
+ resetTo(x,f ['%when,[p,u],['%otherwise,f mkScope(g,v)]])
+ coagulateWhenSeries(y,g) is [u,v] =>
+ resetTo(x,f ['%when,:u,['%otherwise,f mkDefault(g,v)]])
+ 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]]] =>
- resetTo(x,f ['%when,[p,y],['%otherwise,f mkScope(g,z)]])
- x is ['%scope,g,y] and coagulateWhenSeries(y,g) is [u,v] =>
- resetTo(x,f ['%when,:u,['%otherwise,f mkDefault(g,v)]])
+ x
+
+spliceSeq! x == walkWith!(x,function f) where
+ f x ==
+ if x is ['%seq,:.] then
+ x.args := spliceSeqArgs x.args
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 packWhen! transformIF! removeSeq! inlineLocals!
- groupTranscients! reduceXLAM! x
+ simplifyVMForm spliceSeq! packWhen! spliceSeq! packWhen! transformIF!
+ removeSeq! inlineLocals! groupTranscients! reduceXLAM! x
++ A non-mutating version of `optimize!'.
optimize x ==