diff options
author | dos-reis <gdr@axiomatics.org> | 2011-12-28 01:46:50 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2011-12-28 01:46:50 +0000 |
commit | 8165b0668e5116e9ed43b9de15bf961792598d72 (patch) | |
tree | e07e367794f3f3c908629af866e32b42681ec6b0 /src | |
parent | e9328a463a93cf65c222587ea1465b65e9d12d0f (diff) | |
download | open-axiom-8165b0668e5116e9ed43b9de15bf961792598d72.tar.gz |
* interp/g-opt.boot (coagulateWhenSeries): Simplify.
(packWhen!): Likewise.
(unnestWhen!): Tidy.
(removeScope!): Handle %when forms.
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 7 | ||||
-rw-r--r-- | src/interp/g-opt.boot | 29 |
2 files changed, 16 insertions, 20 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 39ec289b..e60a0264 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,12 @@ 2011-12-27 Gabriel Dos Reis <gdr@cs.tamu.edu> + * interp/g-opt.boot (coagulateWhenSeries): Simplify. + (packWhen!): Likewise. + (unnestWhen!): Tidy. + (removeScope!): Handle %when forms. + +2011-12-27 Gabriel Dos Reis <gdr@cs.tamu.edu> + * interp/g-opt.boot (exitScope?): Now return an expression or nil. (cancelScopeLeave!): Tidy. diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot index a4b4f549..880d088b 100644 --- a/src/interp/g-opt.boot +++ b/src/interp/g-opt.boot @@ -269,8 +269,8 @@ mkDefault(g,l) == l = nil => ['CONDERR] mkScope(g,mkSeq l) -coagulateWhenSeries(x,tag) == - x is ['%seq,:.] => f(x.args,tag) where +coagulateWhenSeries(l,tag) == + f(l,tag) where f(l,tag) == cl := nil while l is [s,:.] and (cl' := g(s,tag)) repeat @@ -280,14 +280,8 @@ coagulateWhenSeries(x,tag) == [cl,l] g(s,tag) == -- return list of reduced clauses if they all exit from same scope. - s is ['%when,:.] => - [u for x in s.args while (u := h(x,tag) or leave nil)] - where h(x,tag) == - x is [p,['%leave,=tag,y]] => [p,y] - x is [p,['%return,:.]] => x - nil + s is ['%when,:.] => exitClauses(s.args,tag) nil - nil ++ Return non-nil if the expression `x' exist the scope with tag `g' ++ by normal local transfer or by exiting the enclosing function @@ -302,9 +296,8 @@ 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 + while stmts is [s,:.] repeat + s := f s s is ['%when,[p,u],['%otherwise,v]] and exitScope?(u,tag) => stmts.first := ['%when,[p,u]] stmts.rest := spliceSeqArgs [f v,:rest stmts] @@ -335,14 +328,8 @@ packWhen! x == walkWith!(x,function f) where resetTo(x,f ['%when,:cl,:y.args]) 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] => - 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]] => - resetTo(x,f ['%when,[p,u],['%otherwise,f mkScope(g,v)]]) - coagulateWhenSeries(y,g) is [u,v] => + x is ['%scope,g,['%seq,:w]] and coagulateWhenSeries(w,g) is [u,v] => resetTo(x,f ['%when,:u,['%otherwise,f mkDefault(g,v)]]) - x x spliceSeq! x == walkWith!(x,function f) where @@ -362,7 +349,7 @@ cancelScopeLeave! x == walkWith!(x,function f) where f x == x is ['%scope,g,u] => u is ['%when,:.] and (v := exitClauses(u.args,g)) => - resetTo(x,['%when,:v]) + resetTo(x,[u.op,:v]) y := exitScope?(u,g) => resetTo(x,f y) x x @@ -402,6 +389,8 @@ cleanLoop! x == prefixWalk!(x,function f) where removeScope! x == prefixWalk!(x,function f) where f x == x is ['%scope,g,y] => + y is ['%when,[p,['%leave,=g,u]],['%leave,=g,v]] => + resetTo(x,['%when,[p,u],['%otherwise,v]]) hasNoLeave?(y,g) => resetTo(x,f y) x x |