diff options
Diffstat (limited to 'llvm.cpp')
-rw-r--r-- | llvm.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -50,13 +50,13 @@ lltype(const AType* t) { switch (t->kind) { case AType::VAR: - throw Error((format("non-compilable type `%1%'") % t->str()).str(), t->loc); + throw Error(t->loc, (format("non-compilable type `%1%'") % t->str()).str()); return NULL; case AType::PRIM: if (t->at(0)->str() == "Bool") return Type::Int1Ty; if (t->at(0)->str() == "Int") return Type::Int32Ty; if (t->at(0)->str() == "Float") return Type::FloatTy; - throw Error(string("Unknown primitive type `") + t->str() + "'", t->loc); + throw Error(t->loc, string("Unknown primitive type `") + t->str() + "'"); case AType::EXPR: if (t->at(0)->str() == "Pair") { vector<const Type*> types; @@ -155,17 +155,17 @@ compileFunction(CEnv& cenv, const std::string& name, const Type* retT, const ATu vector<const Type*> cprot; for (size_t i = 0; i < protT.size(); ++i) { AType* at = protT.at(i)->as<AType*>(); - THROW_IF(!lltype(at), "function parameter is untyped", protT.at(i)->loc) + THROW_IF(!lltype(at), protT.at(i)->loc, "function parameter is untyped") cprot.push_back(lltype(at)); } - THROW_IF(!retT, "function return is untyped", loc); + THROW_IF(!retT, loc, "function return is untyped"); FunctionType* fT = FunctionType::get(static_cast<const Type*>(retT), cprot, false); Function* f = Function::Create(fT, linkage, name, llengine(cenv)->module); if (f->getName() != name) { f->eraseFromParent(); - throw Error("function redefined", loc); + throw Error(loc, "function redefined"); } // Set argument names in generated code @@ -223,7 +223,7 @@ AClosure::liftCall(CEnv& cenv, const vector<AType*>& argsT) argsSubst[*genericProtT->at(i)->to<AType*>()] = argsT.at(i)->to<AType*>(); thisType = argsSubst.apply(genericType)->as<AType*>(); if (!thisType->concrete()) - throw Error("unable to resolve concrete type for function", loc); + throw Error(loc, "unable to resolve concrete type for function"); } else { thisType = genericType; } @@ -290,9 +290,9 @@ ACall::lift(CEnv& cenv) if (!c) return; // Primitive if (c->prot()->size() < size() - 1) - throw Error((format("too many arguments to function `%1%'") % at(0)->str()).str(), loc); + throw Error(loc, (format("too many arguments to function `%1%'") % at(0)->str()).str()); if (c->prot()->size() > size() - 1) - throw Error((format("too few arguments to function `%1%'") % at(0)->str()).str(), loc); + throw Error(loc, (format("too few arguments to function `%1%'") % at(0)->str()).str()); c->liftCall(cenv, argsT); // Lift called closure } @@ -312,7 +312,7 @@ ACall::compile(CEnv& cenv) assert(gt != cenv.tenv.genericTypes.end()); AType* fnT = new AType(loc, cenv.penv.sym("Fn"), protT, cenv.type(this), 0); Function* f = (Function*)c->funcs.find(fnT); - THROW_IF(!f, (format("callee failed to compile for type %1%") % fnT->str()).str(), loc) + THROW_IF(!f, loc, (format("callee failed to compile for type %1%") % fnT->str()).str()) vector<Value*> params(size() - 1); for (size_t i = 1; i < size(); ++i) @@ -426,7 +426,7 @@ APrimitive::compile(CEnv& cenv) return llengine(cenv)->builder.CreateICmp(pred, a, b); } - throw Error("unknown primitive", loc); + throw Error(loc, "unknown primitive"); } AType* @@ -560,7 +560,7 @@ eval(CEnv& cenv, const string& name, istream& is) } const Type* ctype = lltype(resultType); - THROW_IF(!ctype, "body has non-compilable type", cursor) + THROW_IF(!ctype, cursor, "body has non-compilable type") // Create function for top-level of program Function* f = compileFunction(cenv, "main", ctype, ATuple(cursor), cursor); @@ -604,7 +604,7 @@ repl(CEnv& cenv) cenv.tsubst = Subst::compose(cenv.tsubst, TEnv::unify(c)); // Solve type constraints AType* bodyT = cenv.type(body); - THROW_IF(!bodyT, "call to untyped body", cursor) + THROW_IF(!bodyT, cursor, "call to untyped body") body->lift(cenv); |