diff options
Diffstat (limited to 'llvm.cpp')
-rw-r--r-- | llvm.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -61,7 +61,7 @@ lltype(const AType* t) if (t->at(0)->str() == "Pair") { vector<const Type*> types; for (size_t i = 1; i < t->size(); ++i) - types.push_back(lltype(dynamic_cast<AType*>(t->at(i)))); + types.push_back(lltype(t->at(i)->to<AType*>())); return PointerType::get(StructType::get(types, false), 0); } } @@ -218,10 +218,10 @@ AClosure::liftCall(CEnv& cenv, const vector<AType*>& argsT) if (!genericType->concrete()) { // Find type and build substitution assert(argsT.size() == prot()->size()); - ATuple* genericProtT = dynamic_cast<ATuple*>(genericType->at(1)); + ATuple* genericProtT = genericType->at(1)->to<ATuple*>(); assert(genericProtT); for (size_t i = 0; i < argsT.size(); ++i) - argsSubst[dynamic_cast<AType*>(genericProtT->at(i))] = dynamic_cast<AType*>(argsT.at(i)); + argsSubst[genericProtT->at(i)->to<AType*>()] = argsT.at(i)->to<AType*>(); thisType = argsSubst.apply(genericType)->as<AType*>(); @@ -239,7 +239,7 @@ AClosure::liftCall(CEnv& cenv, const vector<AType*>& argsT) // Write function declaration string name = this->name == "" ? cenv.gensym("_fn") : this->name; Function* f = compileFunction(cenv, name, - lltype(dynamic_cast<AType*>(thisType->at(thisType->size() - 1))), + lltype(thisType->at(thisType->size()-1)->to<AType*>()), *protT); cenv.push(); @@ -281,7 +281,7 @@ static AST* maybeLookup(CEnv& cenv, AST* ast) { - ASymbol* s = dynamic_cast<ASymbol*>(ast); + ASymbol* s = ast->to<ASymbol*>(); if (s && s->addr) return cenv.tenv.deref(s->addr).first; return ast; @@ -290,8 +290,7 @@ maybeLookup(CEnv& cenv, AST* ast) void ACall::lift(CEnv& cenv) { - AClosure* c = dynamic_cast<AClosure*>(maybeLookup(cenv, at(0))); - + AClosure* c = maybeLookup(cenv, at(0))->to<AClosure*>(); vector<AType*> argsT; // Lift arguments @@ -313,7 +312,7 @@ ACall::lift(CEnv& cenv) CValue ACall::compile(CEnv& cenv) { - AClosure* c = dynamic_cast<AClosure*>(maybeLookup(cenv, at(0))); + AClosure* c = maybeLookup(cenv, at(0))->to<AClosure*>(); if (!c) return NULL; // Primitive @@ -341,7 +340,7 @@ ADefinition::lift(CEnv& cenv) { // Define first for recursion cenv.def(at(1)->as<ASymbol*>(), at(2), cenv.type(at(2)), NULL); - AClosure* c = dynamic_cast<AClosure*>(at(2)); + AClosure* c = at(2)->to<AClosure*>(); if (c) c->name = at(1)->str(); at(2)->lift(cenv); @@ -405,7 +404,7 @@ APrimitive::compile(CEnv& cenv) Value* a = LLVal(cenv.compile(at(1))); Value* b = LLVal(cenv.compile(at(2))); bool isFloat = cenv.type(at(1))->str() == "Float"; - const string n = dynamic_cast<ASymbol*>(at(0))->str(); + const string n = at(0)->to<ASymbol*>()->str(); // Binary arithmetic operations Instruction::BinaryOps op = (Instruction::BinaryOps)0; |