From fd332f979c4216a560925639ae99f2155ab56044 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 10 Dec 2010 18:28:49 +0000 Subject: Simplify if into nested 2-branch (scheme style) ifs at simplify stage. git-svn-id: http://svn.drobilla.net/resp/resp@346 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- src/compile.cpp | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'src/compile.cpp') diff --git a/src/compile.cpp b/src/compile.cpp index 123b403..4c7980e 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -109,22 +109,11 @@ compile_fn(CEnv& cenv, const ATuple* fn) throw() static CVal compile_if(CEnv& cenv, const ATuple* aif) throw() { - IfState state = cenv.engine()->compileIfStart(cenv); - for (ATuple::const_iterator i = aif->iter_at(1); ; ++i) { - ATuple::const_iterator next = i; - if (++next == aif->end()) - break; - - cenv.engine()->compileIfBranch(cenv, state, resp_compile(cenv, *i), *next); - - i = next; // jump 2 each iteration (to the next predicate) - } - - CVal elseV = NULL; + const AST* aelse = NULL; if (*aif->list_last() != *cenv.penv.sym("__unreachable")) - elseV = resp_compile(cenv, aif->list_last()); + aelse = aif->list_ref(3); - return cenv.engine()->compileIfEnd(cenv, state, elseV, cenv.type(aif)); + return cenv.engine()->compileIf(cenv, aif->list_ref(1), aif->list_ref(2), aelse); } static CVal -- cgit v1.2.1