aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm.cpp10
-rw-r--r--tuplr.hpp3
-rw-r--r--typing.cpp20
3 files changed, 16 insertions, 17 deletions
diff --git a/llvm.cpp b/llvm.cpp
index ecfb735..78ab5cc 100644
--- a/llvm.cpp
+++ b/llvm.cpp
@@ -266,9 +266,9 @@ ASTCall::lift(CEnv& cenv)
// Extend environment with bound and typed parameters
cenv.push();
if (c->prot()->size() < size() - 1)
- throw Error((format("too many arguments to function `%1%'") % at(0)->str()).str(), exp.loc);
+ throw Error((format("too many arguments to function `%1%'") % at(0)->str()).str(), loc);
if (c->prot()->size() > size() - 1)
- throw Error((format("too few arguments to function `%1%'") % at(0)->str()).str(), exp.loc);
+ throw Error((format("too few arguments to function `%1%'") % at(0)->str()).str(), loc);
for (size_t i = 1; i < size(); ++i)
cenv.code.def(checked_cast<ASTSymbol*>(c->prot()->at(i-1)), at(i));
@@ -282,7 +282,7 @@ ASTCall::compile(CEnv& cenv)
{
AST* c = maybeLookup(cenv, at(0));
Function* f = dynamic_cast<Function*>(LLVal(cenv.compile(c)));
- if (!f) throw Error("callee failed to compile", exp.loc);
+ if (!f) throw Error("callee failed to compile", loc);
vector<Value*> params(size() - 1);
for (size_t i = 1; i < size(); ++i)
@@ -295,7 +295,7 @@ void
ASTDefinition::lift(CEnv& cenv)
{
if (cenv.code.ref(checked_cast<ASTSymbol*>(at(1))))
- throw Error(string("`") + at(1)->str() + "' redefined", exp.loc);
+ throw Error(string("`") + at(1)->str() + "' redefined", loc);
cenv.code.def((ASTSymbol*)at(1), at(2)); // Define first for recursion
at(2)->lift(cenv);
}
@@ -390,7 +390,7 @@ ASTPrimitive::compile(CEnv& cenv)
return cenv.engine.builder.CreateFCmp(pred, a, b);
}
- throw Error("Unknown primitive", exp.loc);
+ throw Error("unknown primitive", loc);
}
AType*
diff --git a/tuplr.hpp b/tuplr.hpp
index a931f8c..9a636b7 100644
--- a/tuplr.hpp
+++ b/tuplr.hpp
@@ -244,11 +244,10 @@ private:
/// Function call/application, e.g. "(func arg1 arg2)"
struct ASTCall : public ASTTuple {
- ASTCall(const SExp& e, const ASTTuple& t) : ASTTuple(t, e.loc), exp(e) {}
+ ASTCall(const SExp& e, const ASTTuple& t) : ASTTuple(t, e.loc) {}
void constrain(TEnv& tenv) const;
void lift(CEnv& cenv);
CValue compile(CEnv& cenv);
- const SExp& exp;
};
/// Definition special form, e.g. "(def x 2)"
diff --git a/typing.cpp b/typing.cpp
index 837b1c3..759a418 100644
--- a/typing.cpp
+++ b/typing.cpp
@@ -57,9 +57,9 @@ ASTCall::constrain(TEnv& tenv) const
void
ASTDefinition::constrain(TEnv& tenv) const
{
- if (size() != 3) throw Error("`def' requires exactly 2 arguments", exp.loc);
+ if (size() != 3) throw Error("`def' requires exactly 2 arguments", loc);
if (!dynamic_cast<const ASTSymbol*>(at(1)))
- throw Error("`def' name is not a symbol", exp.loc);
+ throw Error("`def' name is not a symbol", loc);
FOREACH(const_iterator, p, *this)
(*p)->constrain(tenv);
AType* tvar = tenv.type(this);
@@ -70,8 +70,8 @@ ASTDefinition::constrain(TEnv& tenv) const
void
ASTIf::constrain(TEnv& tenv) const
{
- if (size() < 3) throw Error("`if' requires exactly 3 arguments", exp.loc);
- if (size() % 2 != 0) throw Error("`if' missing final else clause", exp.loc);
+ if (size() < 3) throw Error("`if' requires exactly 3 arguments", loc);
+ if (size() % 2 != 0) throw Error("`if' missing final else clause", loc);
FOREACH(const_iterator, p, *this)
(*p)->constrain(tenv);
AType* retT = tenv.type(this);
@@ -99,7 +99,7 @@ ASTPrimitive::constrain(TEnv& tenv) const
else if (n == "=" || n == "!=" || n == ">" || n == ">=" || n == "<" || n == "<=")
type = COMPARISON;
else
- throw Error((format("unknown primitive `%1%'") % n).str(), exp.loc);
+ throw Error((format("unknown primitive `%1%'") % n).str(), loc);
FOREACH(const_iterator, p, *this)
(*p)->constrain(tenv);
@@ -107,31 +107,31 @@ ASTPrimitive::constrain(TEnv& tenv) const
switch (type) {
case ARITHMETIC:
if (size() < 3)
- throw Error((format("`%1%' requires at least 2 arguments") % n).str(), exp.loc);
+ throw Error((format("`%1%' requires at least 2 arguments") % n).str(), loc);
for (size_t i = 1; i < size(); ++i)
tenv.constrain(at(i), tenv.type(this));
break;
case BINARY:
if (size() != 3)
- throw Error((format("`%1%' requires exactly 2 arguments") % n).str(), exp.loc);
+ throw Error((format("`%1%' requires exactly 2 arguments") % n).str(), loc);
tenv.constrain(at(1), tenv.type(this));
tenv.constrain(at(2), tenv.type(this));
break;
case BITWISE:
if (size() != 3)
- throw Error((format("`%1%' requires exactly 2 arguments") % n).str(), exp.loc);
+ throw Error((format("`%1%' requires exactly 2 arguments") % n).str(), loc);
tenv.constrain(this, tenv.named("Bool"));
tenv.constrain(at(1), tenv.named("Bool"));
tenv.constrain(at(2), tenv.named("Bool"));
break;
case COMPARISON:
if (size() != 3)
- throw Error((format("`%1%' requires exactly 2 arguments") % n).str(), exp.loc);
+ throw Error((format("`%1%' requires exactly 2 arguments") % n).str(), loc);
tenv.constrain(this, tenv.named("Bool"));
tenv.constrain(at(1), tenv.type(at(2)));
break;
default:
- throw Error((format("unknown primitive `%1%'") % n).str(), exp.loc);
+ throw Error((format("unknown primitive `%1%'") % n).str(), loc);
}
}