aboutsummaryrefslogtreecommitdiffstats
path: root/src/compile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/compile.cpp')
-rw-r--r--src/compile.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/compile.cpp b/src/compile.cpp
index cf777f8..14cd562 100644
--- a/src/compile.cpp
+++ b/src/compile.cpp
@@ -34,7 +34,7 @@ compile_symbol(CEnv& cenv, const ASymbol* sym) throw()
}
static CVal
-compile_fn(CEnv& cenv, const AFn* fn) throw()
+compile_fn(CEnv& cenv, const ACall* fn) throw()
{
const AType* type = cenv.type(fn);
CFunc f = cenv.findImpl(fn, type);
@@ -42,7 +42,7 @@ compile_fn(CEnv& cenv, const AFn* fn) throw()
return f;
// Write function declaration
- f = cenv.engine()->startFunction(cenv, fn->name, fn->prot(), type);
+ f = cenv.engine()->startFunction(cenv, cenv.name(fn), fn->prot(), type);
// Create a new environment frame and bind argument values
cenv.engine()->pushFunctionArgs(cenv, fn, type, f);
@@ -51,7 +51,7 @@ compile_fn(CEnv& cenv, const AFn* fn) throw()
// Write function body
CVal retVal = NULL;
- for (AFn::const_iterator i = fn->iter_at(2); i != fn->end(); ++i)
+ for (ATuple::const_iterator i = fn->iter_at(2); i != fn->end(); ++i)
retVal = resp_compile(cenv, *i);
// Write function conclusion
@@ -61,7 +61,7 @@ compile_fn(CEnv& cenv, const AFn* fn) throw()
cenv.pop();
cenv.currentFn = NULL;
- cenv.vals.def(cenv.penv.sym(fn->name), f);
+ cenv.vals.def(cenv.penv.sym(cenv.name(fn)), f);
cenv.addImpl(fn, f);
return f;
}
@@ -155,10 +155,6 @@ resp_compile(CEnv& cenv, const AST* ast) throw()
if (sym)
return compile_symbol(cenv, sym);
- const AFn* fn = ast->to<const AFn*>();
- if (fn)
- return compile_fn(cenv, fn);
-
const AType* type = ast->to<const AType*>();
if (type)
return compile_type(cenv, type);
@@ -169,6 +165,8 @@ resp_compile(CEnv& cenv, const AST* ast) throw()
const std::string form = sym ? sym->cppstr : "";
if (is_primitive(cenv.penv, call))
return cenv.engine()->compilePrimitive(cenv, ast->as<const ACall*>());
+ else if (form == "fn")
+ return compile_fn(cenv, call);
else if (form == "def")
return compile_def(cenv, call);
else if (form == "if")