aboutsummaryrefslogtreecommitdiffstats
path: root/src/llvm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/llvm.cpp')
-rw-r--r--src/llvm.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/llvm.cpp b/src/llvm.cpp
index 9e519a7..c798d24 100644
--- a/src/llvm.cpp
+++ b/src/llvm.cpp
@@ -154,7 +154,7 @@ struct LLVMEngine : public Engine {
return builder.CreateCall(llFunc(f), llArgs.begin(), llArgs.end());
}
- void liftCall(CEnv& cenv, AFn* fn, const AType& argsT);
+ CFunction compileFunction(CEnv& cenv, AFn* fn, const AType& argsT);
CValue compileLiteral(CEnv& cenv, AST* lit);
CValue compilePrimitive(CEnv& cenv, APrimitive* prim);
@@ -219,8 +219,8 @@ LLVMEngine::compileLiteral(CEnv& cenv, AST* lit)
throw Error(lit->loc, "Unknown literal type");
}
-void
-LLVMEngine::liftCall(CEnv& cenv, AFn* fn, const AType& argsT)
+CFunction
+LLVMEngine::compileFunction(CEnv& cenv, AFn* fn, const AType& argsT)
{
TEnv::GenericTypes::const_iterator gt = cenv.tenv.genericTypes.find(fn);
assert(gt != cenv.tenv.genericTypes.end());
@@ -239,8 +239,9 @@ LLVMEngine::liftCall(CEnv& cenv, AFn* fn, const AType& argsT)
string("call has non-concrete type %1%\n") + thisType->str());
Object::pool.addRoot(thisType);
- if (fn->impls.find(thisType))
- return;
+ Function* f = (Function*)fn->impls.find(thisType);
+ if (f)
+ return f;
ATuple* protT = thisType->at(1)->as<ATuple*>();
@@ -250,7 +251,7 @@ LLVMEngine::liftCall(CEnv& cenv, AFn* fn, const AType& argsT)
// Write function declaration
const string name = (fn->name == "") ? cenv.penv.gensymstr("_fn") : fn->name;
- Function* f = llFunc(cenv.engine()->startFunction(cenv, name,
+ f = llFunc(cenv.engine()->startFunction(cenv, name,
thisType->at(thisType->size()-1)->to<AType*>(),
*protT, argNames));
@@ -327,6 +328,7 @@ LLVMEngine::liftCall(CEnv& cenv, AFn* fn, const AType& argsT)
}
cenv.tsubst = oldSubst;
cenv.pop();
+ return f;
}
CValue