From 22e329617866a6580ccff5636f148d72603fa8fc Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 10 Dec 2010 04:24:20 +0000 Subject: Move simplification from lift stage to a new (post-typing) simplify stage. git-svn-id: http://svn.drobilla.net/resp/resp@344 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- src/lift.cpp | 46 ++-------------------------------------------- 1 file changed, 2 insertions(+), 44 deletions(-) (limited to 'src/lift.cpp') diff --git a/src/lift.cpp b/src/lift.cpp index 239b02e..5791e41 100644 --- a/src/lift.cpp +++ b/src/lift.cpp @@ -212,48 +212,6 @@ lift_let(CEnv& cenv, Code& code, const ATuple* let) throw() return copy; } -static const AST* -lift_match(CEnv& cenv, Code& code, const ATuple* match) throw() -{ - List copy(match->loc, cenv.penv.sym("let"), NULL); - List copyVars; - - const ASymbol* tsym = cenv.penv.gensym("_matchT"); - - List tval; - tval.push_back(cenv.penv.sym(".")); - tval.push_back(resp_lift(cenv, code, match->list_ref(1))); - tval.push_back(new ALiteral(T_INT32, 0, Cursor())); - - copyVars.push_back(tsym); - copyVars.push_back(tval); - copy.push_back(copyVars); - - List copyIf; - copyIf.push_back(cenv.penv.sym("if")); - for (ATuple::const_iterator i = match->iter_at(2); i != match->end();) { - const ATuple* pat = (*i++)->as_tuple(); - const AST* body = *i++; - - List cond; - cond.push_back(cenv.penv.sym("__tag_is")); - cond.push_back(tsym); - cond.push_back(pat->head()); - - copyIf.push_back(cond); - const AST* liftedBody = resp_lift(cenv, code, body); - assert(liftedBody); - copyIf.push_back(liftedBody); - } - copyIf.push_back(cenv.penv.sym("__unreachable")); - copy.push_back(copyIf); - - cenv.setTypeSameAs(copyIf, match); - cenv.setTypeSameAs(copy, match); - - return copy; -} - static const AST* lift_call(CEnv& cenv, Code& code, const ATuple* call) throw() { @@ -345,8 +303,8 @@ resp_lift(CEnv& cenv, Code& code, const AST* ast) throw() return lift_args(cenv, code, call); else if (form == "let") return lift_let(cenv, code, call); - else if (form == "match") - return lift_match(cenv, code, call); + else if (form == "__tag_is") + return call; else return lift_call(cenv, code, call); } -- cgit v1.2.1