diff options
author | David Robillard <d@drobilla.net> | 2012-12-14 06:17:55 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-12-14 06:17:55 +0000 |
commit | 7bfe9965f7b3bd980bd0dd788ca7ec50a2d5f6e1 (patch) | |
tree | 53c847025f11c951541723c195dd0310bdd14724 /src/simplify.cpp | |
parent | 32c1b78fc9bdadd1dd40ed390941b2a6fea39435 (diff) | |
download | resp-7bfe9965f7b3bd980bd0dd788ca7ec50a2d5f6e1.tar.gz resp-7bfe9965f7b3bd980bd0dd788ca7ec50a2d5f6e1.tar.bz2 resp-7bfe9965f7b3bd980bd0dd788ca7ec50a2d5f6e1.zip |
More flexible and unified code pass design.
git-svn-id: http://svn.drobilla.net/resp/trunk@435 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/simplify.cpp')
-rw-r--r-- | src/simplify.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/simplify.cpp b/src/simplify.cpp index e081bf7..921c6e6 100644 --- a/src/simplify.cpp +++ b/src/simplify.cpp @@ -26,7 +26,7 @@ using namespace std; static const AST* -simplify_if(CEnv& cenv, const ATuple* aif) throw() +simplify_if(CEnv& cenv, Code& code, const ATuple* aif) throw() { List copy(aif->loc, cenv.penv.sym("if"), NULL); copy.push_back(aif->list_ref(1)); @@ -54,9 +54,9 @@ simplify_if(CEnv& cenv, const ATuple* aif) throw() } static const AST* -simplify_match(CEnv& cenv, const ATuple* match) throw() +simplify_match(CEnv& cenv, Code& code, const ATuple* match) throw() { - const AST* const obj = resp_simplify(cenv, match->list_ref(1)); + const AST* const obj = resp_simplify(cenv, code, match->list_ref(1)); // Dot expression to get tag. Note index is -1 to compensate for the lift phase // which adds 1 to skip the RTTI, which we don't want here (FIXME: ick...) @@ -108,7 +108,7 @@ simplify_match(CEnv& cenv, const ATuple* match) throw() fn.push_back(def); } - fn.push_back(resp_simplify(cenv, body)); + fn.push_back(resp_simplify(cenv, code, body)); List fnT(Cursor(), cenv.tenv.Fn, protT, cenv.type(match), 0); assert(fnT.head->list_ref(1)); @@ -121,18 +121,18 @@ simplify_match(CEnv& cenv, const ATuple* match) throw() copyIf.push_back(cenv.penv.sym("__unreachable")); cenv.setTypeSameAs(copyIf, match); - List copy(match->loc, cenv.penv.sym("do"), def.head, simplify_if(cenv, copyIf), 0); + List copy(match->loc, cenv.penv.sym("do"), def.head, simplify_if(cenv, code, copyIf), 0); cenv.setTypeSameAs(copy, match); return copy; } static const AST* -simplify_list(CEnv& cenv, const ATuple* call) throw() +simplify_list(CEnv& cenv, Code& code, const ATuple* call) throw() { List copy; for (ATuple::const_iterator i = call->begin(); i != call->end(); ++i) - copy.push_back(resp_simplify(cenv, *i)); + copy.push_back(resp_simplify(cenv, code, *i)); cenv.setTypeSameAs(copy.head, call); @@ -140,7 +140,7 @@ simplify_list(CEnv& cenv, const ATuple* call) throw() } static const AST* -simplify_let(CEnv& cenv, const ATuple* call) throw() +simplify_let(CEnv& cenv, Code& code, const ATuple* call) throw() { const ATuple* vars = call->list_ref(1)->to_tuple(); @@ -153,12 +153,12 @@ simplify_let(CEnv& cenv, const ATuple* call) throw() const ASymbol* sym = (*i++)->to_symbol(); const AST* val = (*i++); fnProt.push_back(sym); - fnArgs.push_back(resp_simplify(cenv, val)); + fnArgs.push_back(resp_simplify(cenv, code, val)); fnProtT.push_back(cenv.type(val)); } fn.push_back(fnProt.head); - fn.push_back(resp_simplify(cenv, call->list_ref(2))); + fn.push_back(resp_simplify(cenv, code, call->list_ref(2))); List fnT; fnT.push_back(cenv.tenv.Fn); @@ -194,7 +194,7 @@ simplify_list_elem(CEnv& cenv, const ATuple* node, const AST* type) } static const AST* -simplify_quote(CEnv& cenv, const ATuple* call) throw() +simplify_quote(CEnv& cenv, Code& code, const ATuple* call) throw() { switch (call->frst()->tag()) { case T_SYMBOL: @@ -214,7 +214,7 @@ simplify_quote(CEnv& cenv, const ATuple* call) throw() } const AST* -resp_simplify(CEnv& cenv, const AST* ast) throw() +resp_simplify(CEnv& cenv, Code& code, const AST* ast) throw() { const ATuple* const list = ast->to_tuple(); if (!list) @@ -224,13 +224,13 @@ resp_simplify(CEnv& cenv, const AST* ast) throw() const std::string form = sym ? sym->sym() : ""; if (form == "match") - return simplify_match(cenv, list); + return simplify_match(cenv, code, list); else if (form == "if") - return simplify_if(cenv, list); + return simplify_if(cenv, code, list); else if (form == "let") - return simplify_let(cenv, list); + return simplify_let(cenv, code, list); else if (form == "quote") - return simplify_quote(cenv, list); + return simplify_quote(cenv, code, list); else - return simplify_list(cenv, list); + return simplify_list(cenv, code, list); } |