diff options
author | David Robillard <d@drobilla.net> | 2010-12-10 18:28:49 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-12-10 18:28:49 +0000 |
commit | fd332f979c4216a560925639ae99f2155ab56044 (patch) | |
tree | 1cc23036bd1c99e60e35cd1e9ab6c1b085999886 /src/compile.cpp | |
parent | c0d05f679266f419f47b2636bd6f8b085ff23f1a (diff) | |
download | resp-fd332f979c4216a560925639ae99f2155ab56044.tar.gz resp-fd332f979c4216a560925639ae99f2155ab56044.tar.bz2 resp-fd332f979c4216a560925639ae99f2155ab56044.zip |
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
Diffstat (limited to 'src/compile.cpp')
-rw-r--r-- | src/compile.cpp | 17 |
1 files changed, 3 insertions, 14 deletions
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 |