diff options
author | dos-reis <gdr@axiomatics.org> | 2011-12-18 20:11:04 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2011-12-18 20:11:04 +0000 |
commit | d6ff41eb503996363dd676485e138a2f322de601 (patch) | |
tree | 82d1ce6d046f9b39aa1e31ef6c096d4c287b609b /src | |
parent | d286893196d08cbe61ff2c80f470d8c0a7f606cf (diff) | |
download | open-axiom-d6ff41eb503996363dd676485e138a2f322de601.tar.gz |
* interp/g-opt.boot (unnestWhen!): New.
(packWhen!): Simplify.
(optimize!): Run before changeVariableDefinitionToStore.
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 6 | ||||
-rw-r--r-- | src/interp/g-opt.boot | 31 |
2 files changed, 29 insertions, 8 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 0a8c4aaa..f5638379 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2011-12-18 Gabriel Dos Reis <gdr@cs.tamu.edu> + + * interp/g-opt.boot (unnestWhen!): New. + (packWhen!): Simplify. + (optimize!): Run before changeVariableDefinitionToStore. + 2011-12-17 Gabriel Dos Reis <gdr@cs.tamu.edu> * interp/g-opt.boot (removeScope!): New. diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot index 75d358da..089e2718 100644 --- a/src/interp/g-opt.boot +++ b/src/interp/g-opt.boot @@ -299,6 +299,28 @@ coagulateWhenSeries(x,tag) == exitScope?(x,g) == x is ['%leave,=g,:.] or x is ['%return,:.] +unnestWhen! x == f x where + f x == + x is ['%scope,tag,y] => + y is ['%seq,:stmts] => + repeat + stmts = nil => leave nil + s := f first stmts + s is ['%when,[p,u],['%otherwise,v]] and exitScope?(u,tag) => + stmts.first := ['%when,[p,u]] + stmts.rest := spliceSeqArgs [f v,:rest stmts] + stmts.first := s + stmts := rest stmts + x + y is ['%when,[p,u:=['%leave,=tag,.]],['%otherwise,v]] => + reset(x,f mkScope(tag,mkSeq [['%when,[p,u]],f v])) + second(x.args) := f y + x + do + abstraction? x => x.absBody := f x.absBody + x is ['%leave,.,y] => second(x.args) := f y + x + ++ Transform nested-to-tower. packWhen! x == walkWith!(x,function f) where f x == @@ -309,13 +331,6 @@ packWhen! x == walkWith!(x,function f) where x is ['%leave,g,['%when,[p,['%leave,=g,s]]]] => resetTo(x,['%leave,g,['%when,[p,s]]]) x is ['%scope,g,y] and y is ['%seq,:stmts] => - repeat - stmts = nil => leave nil - s := first stmts - s is ['%when,[p,u],['%otherwise,v]] and exitScope?(u,g) => - 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)]]) y.args is [['%when,[p,u:=['%return,:.]]],['%leave,=g,v]] => @@ -382,7 +397,7 @@ removeScope! x == prefixWalk!(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! cleanLoop! x + x := unnestWhen! spliceSeq! packWhen! transformIF! removeLeave! cleanLoop! x changeVariableDefinitionToStore(x,nil) simplifyVMForm removeScope! cancelScopeLeave! spliceSeq! packWhen! inlineLocals! groupTranscients! cancelScopeLeave! |