From a0367d144bb30ac0eb422b05a962b694602fc601 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 14 May 2011 02:20:53 +0000 Subject: More granular if compilation API (towards assembly-like IR stage and simpler backends) git-svn-id: http://svn.drobilla.net/resp/trunk@412 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- src/compile.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/compile.cpp') diff --git a/src/compile.cpp b/src/compile.cpp index 44017ec..ba8cc5e 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -167,11 +167,18 @@ compile_fn(CEnv& cenv, const ATuple* fn) throw() static CVal compile_if(CEnv& cenv, const ATuple* aif) throw() { + const AST* cond = aif->list_ref(1); + const AST* then = aif->list_ref(2); const AST* aelse = NULL; if (*aif->list_last() != *cenv.penv.sym("__unreachable")) aelse = aif->list_ref(3); - return cenv.engine()->compileIf(cenv, aif->list_ref(1), aif->list_ref(2), aelse); + const AST* type = cenv.type(then); + + cenv.engine()->compileIfStart(cenv, cond, type); + cenv.engine()->compileIfThen(cenv, resp_compile(cenv, then)); + cenv.engine()->compileIfElse(cenv, resp_compile(cenv, aelse)); + return cenv.engine()->compileIfEnd(cenv); } static CVal @@ -214,6 +221,9 @@ compile_call(CEnv& cenv, const ATuple* call) throw() CVal resp_compile(CEnv& cenv, const AST* ast) throw() { + if (!ast) + return NULL; + switch (ast->tag()) { case T_UNKNOWN: return NULL; -- cgit v1.2.1