aboutsummaryrefslogtreecommitdiffstats
path: root/llvm.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-06-18 20:45:40 +0000
committerDavid Robillard <d@drobilla.net>2009-06-18 20:45:40 +0000
commit936f996c4091266e9404f346e2939e613121f74c (patch)
tree737f02b112cd6d98a0abdc11b2a84591b1493b8e /llvm.cpp
parentd8c876402bb348abc7d1fb539f245e7ba8c4ce27 (diff)
downloadresp-936f996c4091266e9404f346e2939e613121f74c.tar.gz
resp-936f996c4091266e9404f346e2939e613121f74c.tar.bz2
resp-936f996c4091266e9404f346e2939e613121f74c.zip
Make source location mandatory parameter for Error.
git-svn-id: http://svn.drobilla.net/resp/tuplr@121 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'llvm.cpp')
-rw-r--r--llvm.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/llvm.cpp b/llvm.cpp
index dcf8365..d04bd1b 100644
--- a/llvm.cpp
+++ b/llvm.cpp
@@ -56,7 +56,7 @@ lltype(const AType* t)
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() + "'");
+ throw Error(string("Unknown primitive type `") + t->str() + "'", t->loc);
case AType::EXPR:
if (t->at(0)->str() == "Pair") {
vector<const Type*> types;
@@ -148,24 +148,24 @@ LITERAL(bool, "Bool", ConstantInt::get(Type::Int1Ty, val, false))
static Function*
compileFunction(CEnv& cenv, const std::string& name, const Type* retT, const ATuple& protT,
- const vector<string> argNames=vector<string>())
+ Cursor loc, const vector<string> argNames=vector<string>())
{
Function::LinkageTypes linkage = Function::ExternalLinkage;
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")
+ THROW_IF(!lltype(at), "function parameter is untyped", protT.at(i)->loc)
cprot.push_back(lltype(at));
}
- THROW_IF(!retT, "function return is untyped")
+ THROW_IF(!retT, "function return is untyped", loc);
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");
+ throw Error("function redefined", loc);
}
// Set argument names in generated code
@@ -237,7 +237,7 @@ AClosure::liftCall(CEnv& cenv, const vector<AType*>& argsT)
string name = this->name == "" ? cenv.gensym("_fn") : this->name;
Function* f = compileFunction(cenv, name,
lltype(thisType->at(thisType->size()-1)->to<AType*>()),
- *protT);
+ *protT, loc);
cenv.push();
Subst oldSubst = cenv.tsubst;
@@ -467,7 +467,7 @@ AConsCall::lift(CEnv& cenv)
vector<string> argNames;
argNames.push_back("car");
argNames.push_back("cdr");
- Function* func = compileFunction(cenv, cenv.gensym("cons"), pT, *protT, argNames);
+ Function* func = compileFunction(cenv, cenv.gensym("cons"), pT, *protT, loc, argNames);
Value* mem = builder.CreateCall(LLVal(cenv.alloc), ConstantInt::get(Type::Int32Ty, sz), "mem");
Value* cell = builder.CreateBitCast(mem, pT, "cell");
@@ -563,7 +563,7 @@ eval(CEnv& cenv, const string& name, istream& is)
THROW_IF(!ctype, "body has non-compilable type", cursor)
// Create function for top-level of program
- Function* f = compileFunction(cenv, "main", ctype, ATuple(cursor));
+ Function* f = compileFunction(cenv, "main", ctype, ATuple(cursor), cursor);
// Compile all expressions into it
Value* val = NULL;
@@ -610,7 +610,7 @@ repl(CEnv& cenv)
if (lltype(bodyT)) {
// Create anonymous function to insert code into
- Function* f = compileFunction(cenv, cenv.gensym("_repl"), lltype(bodyT), ATuple(cursor));
+ Function* f = compileFunction(cenv, cenv.gensym("_repl"), lltype(bodyT), ATuple(cursor), cursor);
try {
Value* retVal = LLVal(cenv.compile(body));
llengine(cenv)->builder.CreateRet(retVal); // Finish function