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, 7 insertions, 7 deletions
diff --git a/src/llvm.cpp b/src/llvm.cpp
index 810a7d3..34f23ca 100644
--- a/src/llvm.cpp
+++ b/src/llvm.cpp
@@ -317,7 +317,7 @@ LLVMEngine::compileFunction(CEnv& cenv, AFn* fn, const AType& argsT)
fn->impls.push_back(make_pair(thisType, f));
CVal retVal = NULL;
for (size_t i = 2; i < fn->size(); ++i)
- retVal = cenv.compile(fn->at(i));
+ retVal = fn->at(i)->compile(cenv);
cenv.engine()->finishFunction(cenv, f, cenv.type(fn->at(fn->size() - 1)), retVal);
} catch (Error& e) {
f->eraseFromParent(); // Error reading body, remove function
@@ -339,7 +339,7 @@ LLVMEngine::compileIf(CEnv& cenv, AIf* aif)
BasicBlock* nextBB = NULL;
Branches branches;
for (size_t i = 1; i < aif->size() - 1; i += 2) {
- Value* condV = llVal(cenv.compile(aif->at(i)));
+ Value* condV = llVal(aif->at(i)->compile(cenv));
BasicBlock* thenBB = BasicBlock::Create((format("then%1%") % ((i+1)/2)).str());
nextBB = BasicBlock::Create((format("else%1%") % ((i+1)/2)).str());
@@ -349,7 +349,7 @@ LLVMEngine::compileIf(CEnv& cenv, AIf* aif)
// Emit then block for this condition
parent->getBasicBlockList().push_back(thenBB);
engine->builder.SetInsertPoint(thenBB);
- Value* thenV = llVal(cenv.compile(aif->at(i + 1)));
+ Value* thenV = llVal(aif->at(i + 1)->compile(cenv));
engine->builder.CreateBr(mergeBB);
branches.push_back(make_pair(thenV, engine->builder.GetInsertBlock()));
@@ -359,7 +359,7 @@ LLVMEngine::compileIf(CEnv& cenv, AIf* aif)
// Emit final else block
engine->builder.SetInsertPoint(nextBB);
- Value* elseV = llVal(cenv.compile(aif->at(aif->size() - 1)));
+ Value* elseV = llVal(aif->at(aif->size() - 1)->compile(cenv));
engine->builder.CreateBr(mergeBB);
branches.push_back(make_pair(elseV, engine->builder.GetInsertBlock()));
@@ -378,8 +378,8 @@ CVal
LLVMEngine::compilePrimitive(CEnv& cenv, APrimitive* prim)
{
LLVMEngine* engine = reinterpret_cast<LLVMEngine*>(cenv.engine());
- Value* a = llVal(cenv.compile(prim->at(1)));
- Value* b = llVal(cenv.compile(prim->at(2)));
+ Value* a = llVal(prim->at(1)->compile(cenv));
+ Value* b = llVal(prim->at(2)->compile(cenv));
bool isFloat = cenv.type(prim->at(1))->str() == "Float";
const string n = prim->at(0)->to<ASymbol*>()->str();
@@ -396,7 +396,7 @@ LLVMEngine::compilePrimitive(CEnv& cenv, APrimitive* prim)
if (op != 0) {
Value* val = engine->builder.CreateBinOp(op, a, b);
for (size_t i = 3; i < prim->size(); ++i)
- val = engine->builder.CreateBinOp(op, val, llVal(cenv.compile(prim->at(i))));
+ val = engine->builder.CreateBinOp(op, val, llVal(prim->at(i)->compile(cenv)));
return val;
}