aboutsummaryrefslogtreecommitdiffstats
path: root/src/lift.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lift.cpp')
-rw-r--r--src/lift.cpp52
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;
}