diff options
author | David Robillard <d@drobilla.net> | 2010-12-02 18:08:44 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-12-02 18:08:44 +0000 |
commit | a2021fceed6810a5c9f2f14632fc40a5c122cf0e (patch) | |
tree | 754eb47a734135d68a05fa25d494ccf51e418b19 /src | |
parent | a6b1581f08477456e6d128124693c456ad27f4e0 (diff) | |
download | resp-a2021fceed6810a5c9f2f14632fc40a5c122cf0e.tar.gz resp-a2021fceed6810a5c9f2f14632fc40a5c122cf0e.tar.bz2 resp-a2021fceed6810a5c9f2f14632fc40a5c122cf0e.zip |
Remove use of ACall type hierarchy from lift phase.
git-svn-id: http://svn.drobilla.net/resp/resp@280 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src')
-rw-r--r-- | src/lift.cpp | 52 |
1 files changed, 20 insertions, 32 deletions
diff --git a/src/lift.cpp b/src/lift.cpp index 29a25fe..aea8b0d 100644 --- a/src/lift.cpp +++ b/src/lift.cpp @@ -178,7 +178,7 @@ lift_call(CEnv& cenv, Code& code, ACall* call) throw() } static AST* -lift_def(CEnv& cenv, Code& code, ADef* def) throw() +lift_def(CEnv& cenv, Code& code, ACall* def) throw() { // Define stub first for recursion const ASymbol* const sym = def->list_ref(1)->as<const ASymbol*>(); @@ -229,45 +229,33 @@ resp_lift(CEnv& cenv, Code& code, AST* ast) throw() if (sym) return lift_symbol(cenv, code, sym); - ADef* const def = ast->to<ADef*>(); - if (def) - return lift_def(cenv, code, def); - AFn* const fn = ast->to<AFn*>(); if (fn) return lift_fn(cenv, code, fn); - AIf* const aif = ast->to<AIf*>(); - if (aif) - return lift_builtin_call<AIf>(cenv, code, aif); - - ACons* const cons = ast->to<ACons*>(); - if (cons) - return lift_builtin_call<ACons>(cenv, code, cons); - - ADot* const dot = ast->to<ADot*>(); - if (dot) - return lift_builtin_call<ADot>(cenv, code, dot); - - AQuote* const quote = ast->to<AQuote*>(); - if (quote) - return lift_builtin_call<AQuote>(cenv, code, quote); - - AMatch* const match = ast->to<AMatch*>(); - if (match) - return match; // FIXME - APrimitive* const prim = ast->to<APrimitive*>(); if (prim) return lift_builtin_call<APrimitive>(cenv, code, prim); - ADefType* const defType = ast->to<ADefType*>(); - if (defType) - return defType; - ACall* const call = ast->to<ACall*>(); - if (call) - return lift_call(cenv, code, call); - + if (call) { + const ASymbol* const sym = call->head()->to<const ASymbol*>(); + const std::string form = sym ? sym->cppstr : ""; + if (form == "def") + return lift_def(cenv, code, call); + else if (form == "if") + return lift_builtin_call<AIf>(cenv, code, call); + else if (form == "cons" || isupper(form[0])) + return lift_builtin_call<ACons>(cenv, code, call); + else if (form == ".") + return lift_builtin_call<ADot>(cenv, code, call); + else if (form == "quote") + return lift_builtin_call<AQuote>(cenv, code, call); + else if (form == "match" || form == "def-type") + return call; // FIXME + else + return lift_call(cenv, code, call); + } + return ast; } |