aboutsummaryrefslogtreecommitdiffstats
path: root/src/lift.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-12-10 04:24:20 +0000
committerDavid Robillard <d@drobilla.net>2010-12-10 04:24:20 +0000
commit22e329617866a6580ccff5636f148d72603fa8fc (patch)
tree4038bdc902a7726da493850e71e81b1b01102622 /src/lift.cpp
parent4b2af37d24d864db463d004930f924b5adfebc28 (diff)
downloadresp-22e329617866a6580ccff5636f148d72603fa8fc.tar.gz
resp-22e329617866a6580ccff5636f148d72603fa8fc.tar.bz2
resp-22e329617866a6580ccff5636f148d72603fa8fc.zip
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
Diffstat (limited to 'src/lift.cpp')
-rw-r--r--src/lift.cpp46
1 files changed, 2 insertions, 44 deletions
diff --git a/src/lift.cpp b/src/lift.cpp
index 239b02e..5791e41 100644
--- a/src/lift.cpp
+++ b/src/lift.cpp
@@ -213,48 +213,6 @@ lift_let(CEnv& cenv, Code& code, const ATuple* let) throw()
}
static const AST*
-lift_match(CEnv& cenv, Code& code, const ATuple* match) throw()
-{
- List<ATuple, const AST> copy(match->loc, cenv.penv.sym("let"), NULL);
- List<ATuple, const AST> copyVars;
-
- const ASymbol* tsym = cenv.penv.gensym("_matchT");
-
- List<ATuple, const AST> tval;
- tval.push_back(cenv.penv.sym("."));
- tval.push_back(resp_lift(cenv, code, match->list_ref(1)));
- tval.push_back(new ALiteral<int32_t>(T_INT32, 0, Cursor()));
-
- copyVars.push_back(tsym);
- copyVars.push_back(tval);
- copy.push_back(copyVars);
-
- List<ATuple, const AST> 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<ATuple, const AST> 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()
{
List<ATuple, const AST> copy;
@@ -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);
}