aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/llvm.cpp b/llvm.cpp
index ef52b88..7786bf5 100644
--- a/llvm.cpp
+++ b/llvm.cpp
@@ -255,8 +255,9 @@ AClosure::liftCall(CEnv& cenv, const vector<AType*>& argsT)
// Define value first for recursion
cenv.precompile(this, f);
funcs.push_back(make_pair(thisType, f));
-
- CValue retVal = cenv.compile(at(2));
+ CValue retVal = NULL;
+ for (size_t i = 2; i < size(); ++i)
+ retVal = cenv.compile(at(i));
llengine(cenv)->builder.CreateRet(LLVal(retVal)); // Finish function
cenv.optimise(LLFunc(f));
} catch (Error& e) {
@@ -310,7 +311,7 @@ ACall::compile(CEnv& cenv)
TEnv::GenericTypes::const_iterator gt = cenv.tenv.genericTypes.find(c);
assert(gt != cenv.tenv.genericTypes.end());
const AType* polyT = gt->second;
- AType* fnT = new AType(loc, cenv.penv.sym("Fn"), protT, polyT->at(2), 0);
+ AType* fnT = new AType(loc, cenv.penv.sym("Fn"), protT, polyT->at(polyT->size()-1), 0);
Function* f = (Function*)c->funcs.find(fnT);
if (!f) throw Error("callee failed to compile", loc);
@@ -326,10 +327,10 @@ void
ADefinition::lift(CEnv& cenv)
{
// Define stub first for recursion
- cenv.def(at(1)->as<ASymbol*>(), at(2), cenv.type(at(2)), NULL);
+ cenv.def(sym(), at(2), cenv.type(at(2)), NULL);
AClosure* c = at(2)->to<AClosure*>();
if (c)
- c->name = at(1)->str();
+ c->name = sym()->str();
at(2)->lift(cenv);
}
@@ -337,9 +338,9 @@ CValue
ADefinition::compile(CEnv& cenv)
{
// Define stub first for recursion
- cenv.def(at(1)->as<ASymbol*>(), at(2), cenv.type(at(2)), NULL);
- CValue val = cenv.compile(at(2));
- cenv.vals.def(at(1)->as<ASymbol*>(), val);
+ cenv.def(sym(), at(2), cenv.type(at(2)), NULL);
+ CValue val = cenv.compile(at(size() - 1));
+ cenv.vals.def(sym(), val);
return val;
}