diff options
Diffstat (limited to 'src/llvm.cpp')
-rw-r--r-- | src/llvm.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/llvm.cpp b/src/llvm.cpp index 6aedd93..7039a97 100644 --- a/src/llvm.cpp +++ b/src/llvm.cpp @@ -186,14 +186,14 @@ struct LLVMEngine : public Engine { return builder.CreateCall(llFunc(f), llArgs.begin(), llArgs.end()); } - CFunc compileFunction(CEnv& cenv, AFn* fn, const AType* type); + CFunc compileFunction(CEnv& cenv, const AFn* fn, const AType* type); CVal compileTup(CEnv& cenv, const AType* type, const vector<CVal>& fields); CVal compileDot(CEnv& cenv, CVal tup, int32_t index); - CVal compileLiteral(CEnv& cenv, AST* lit); + CVal compileLiteral(CEnv& cenv, const AST* lit); CVal compileString(CEnv& cenv, const char* str); - CVal compilePrimitive(CEnv& cenv, APrimitive* prim); - CVal compileIf(CEnv& cenv, AIf* aif); + CVal compilePrimitive(CEnv& cenv, const APrimitive* prim); + CVal compileIf(CEnv& cenv, const AIf* aif); CVal compileGlobal(CEnv& cenv, const AType* type, const string& sym, CVal val); CVal getGlobal(CEnv& cenv, const string& sym, CVal val); @@ -299,17 +299,17 @@ LLVMEngine::compileDot(CEnv& cenv, CVal tup, int32_t index) } CVal -LLVMEngine::compileLiteral(CEnv& cenv, AST* lit) +LLVMEngine::compileLiteral(CEnv& cenv, const AST* lit) { - ALiteral<int32_t>* ilit = dynamic_cast<ALiteral<int32_t>*>(lit); + const ALiteral<int32_t>* ilit = dynamic_cast<const ALiteral<int32_t>*>(lit); if (ilit) return ConstantInt::get(Type::getInt32Ty(context), ilit->val, true); - ALiteral<float>* flit = dynamic_cast<ALiteral<float>*>(lit); + const ALiteral<float>* flit = dynamic_cast<const ALiteral<float>*>(lit); if (flit) return ConstantFP::get(Type::getFloatTy(context), flit->val); - ALiteral<bool>* blit = dynamic_cast<ALiteral<bool>*>(lit); + const ALiteral<bool>* blit = dynamic_cast<const ALiteral<bool>*>(lit); if (blit) return ConstantFP::get(Type::getFloatTy(context), blit->val); @@ -323,7 +323,7 @@ LLVMEngine::compileString(CEnv& cenv, const char* str) } CFunc -LLVMEngine::compileFunction(CEnv& cenv, AFn* fn, const AType* type) +LLVMEngine::compileFunction(CEnv& cenv, const AFn* fn, const AType* type) { assert(type->concrete()); @@ -359,7 +359,7 @@ LLVMEngine::compileFunction(CEnv& cenv, AFn* fn, const AType* type) try { cenv.currentFn = f; CVal retVal = NULL; - for (AFn::iterator i = fn->begin() + 2; i != fn->end(); ++i) + for (AFn::const_iterator i = fn->begin() + 2; i != fn->end(); ++i) retVal = (*i)->compile(cenv); cenv.engine()->finishFunction(cenv, f, retVal); } catch (Error& e) { @@ -374,7 +374,7 @@ LLVMEngine::compileFunction(CEnv& cenv, AFn* fn, const AType* type) } CVal -LLVMEngine::compileIf(CEnv& cenv, AIf* aif) +LLVMEngine::compileIf(CEnv& cenv, const AIf* aif) { typedef vector< pair<Value*, BasicBlock*> > Branches; LLVMEngine* engine = reinterpret_cast<LLVMEngine*>(cenv.engine()); @@ -383,8 +383,8 @@ LLVMEngine::compileIf(CEnv& cenv, AIf* aif) BasicBlock* nextBB = NULL; Branches branches; size_t idx = 1; - for (AIf::iterator i = aif->begin() + 1; ; ++i, idx += 2) { - AIf::iterator next = i; + for (AIf::const_iterator i = aif->begin() + 1; ; ++i, idx += 2) { + AIf::const_iterator next = i; if (++next == aif->end()) break; @@ -426,15 +426,15 @@ LLVMEngine::compileIf(CEnv& cenv, AIf* aif) } CVal -LLVMEngine::compilePrimitive(CEnv& cenv, APrimitive* prim) +LLVMEngine::compilePrimitive(CEnv& cenv, const APrimitive* prim) { - APrimitive::iterator i = prim->begin(); + APrimitive::const_iterator i = prim->begin(); LLVMEngine* engine = reinterpret_cast<LLVMEngine*>(cenv.engine()); bool isFloat = cenv.type(*++i)->str() == "Float"; Value* a = llVal((*i++)->compile(cenv)); Value* b = llVal((*i++)->compile(cenv)); - const string n = prim->head()->to<ASymbol*>()->str(); + const string n = prim->head()->to<const ASymbol*>()->str(); // Binary arithmetic operations Instruction::BinaryOps op = (Instruction::BinaryOps)0; |