aboutsummaryrefslogtreecommitdiffstats
path: root/llvm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm.cpp')
-rw-r--r--llvm.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm.cpp b/llvm.cpp
index e2b5992..dcf8365 100644
--- a/llvm.cpp
+++ b/llvm.cpp
@@ -155,11 +155,11 @@ 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*>();
- if (!lltype(at)) throw Error("function parameter is untyped");
+ THROW_IF(!lltype(at), "function parameter is untyped")
cprot.push_back(lltype(at));
}
- if (!retT) throw Error("function return is untyped");
+ THROW_IF(!retT, "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);
@@ -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);
- if (!f) throw Error((format("callee failed to compile for type %1%") % fnT->str()).str(), loc);
+ THROW_IF(!f, (format("callee failed to compile for type %1%") % fnT->str()).str(), loc)
vector<Value*> params(size() - 1);
for (size_t i = 1; i < size(); ++i)
@@ -560,7 +560,7 @@ eval(CEnv& cenv, const string& name, istream& is)
}
const Type* ctype = lltype(resultType);
- if (!ctype) throw Error("body has non-compilable type", cursor);
+ THROW_IF(!ctype, "body has non-compilable type", cursor)
// Create function for top-level of program
Function* f = compileFunction(cenv, "main", ctype, ATuple(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);
- if (!bodyT) throw Error("call to untyped body", cursor);
+ THROW_IF(!bodyT, "call to untyped body", cursor)
body->lift(cenv);