aboutsummaryrefslogtreecommitdiffstats
path: root/typing.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-06-18 20:40:31 +0000
committerDavid Robillard <d@drobilla.net>2009-06-18 20:40:31 +0000
commitd8c876402bb348abc7d1fb539f245e7ba8c4ce27 (patch)
tree2b104ffa8d054e524f7fdfbf27052700b2e19cbe /typing.cpp
parent545b524bda45f2087ac92cf58f6eaa78499332cf (diff)
downloadresp-d8c876402bb348abc7d1fb539f245e7ba8c4ce27.tar.gz
resp-d8c876402bb348abc7d1fb539f245e7ba8c4ce27.tar.bz2
resp-d8c876402bb348abc7d1fb539f245e7ba8c4ce27.zip
THROW_IF macro.
git-svn-id: http://svn.drobilla.net/resp/tuplr@120 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'typing.cpp')
-rw-r--r--typing.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/typing.cpp b/typing.cpp
index aba4449..3f2f8e0 100644
--- a/typing.cpp
+++ b/typing.cpp
@@ -149,9 +149,9 @@ ACall::constrain(TEnv& tenv, Constraints& c) const
void
ADefinition::constrain(TEnv& tenv, Constraints& c) const
{
- if (size() != 3) throw Error("`def' requires exactly 2 arguments", loc);
+ THROW_IF(size() != 3, "`def' requires exactly 2 arguments", loc);
const ASymbol* sym = this->sym();
- if (!sym) throw Error("`def' has no symbol", loc);
+ THROW_IF(!sym, "`def' has no symbol", loc)
AType* tvar = tenv.var(at(2));
tenv.def(sym, make_pair(at(2), tvar));
@@ -162,8 +162,8 @@ ADefinition::constrain(TEnv& tenv, Constraints& c) const
void
AIf::constrain(TEnv& tenv, Constraints& c) const
{
- if (size() < 3) throw Error("`if' requires exactly 3 arguments", loc);
- if (size() % 2 != 0) throw Error("`if' missing final else clause", loc);
+ THROW_IF(size() < 4, "`if' requires at least 3 argumentsz", loc);
+ THROW_IF(size() % 2 != 0, "`if' missing final else clause", loc)
for (size_t i = 1; i < size(); ++i)
at(i)->constrain(tenv, c);
AType* retT = tenv.var(this);
@@ -230,7 +230,7 @@ APrimitive::constrain(TEnv& tenv, Constraints& c) const
void
AConsCall::constrain(TEnv& tenv, Constraints& c) const
{
- if (size() != 3) throw Error("`cons' requires exactly 2 arguments", loc);
+ THROW_IF(size() != 3, "`cons' requires exactly 2 arguments", loc)
AType* t = new AType(loc, tenv.penv.sym("Pair"), 0);
for (size_t i = 1; i < size(); ++i) {
at(i)->constrain(tenv, c);
@@ -242,7 +242,7 @@ AConsCall::constrain(TEnv& tenv, Constraints& c) const
void
ACarCall::constrain(TEnv& tenv, Constraints& c) const
{
- if (size() != 2) throw Error("`car' requires exactly 1 argument", loc);
+ THROW_IF(size() != 2, "`car' requires exactly 1 argument", loc)
at(1)->constrain(tenv, c);
AType* carT = tenv.var(this);
AType* pairT = new AType(at(1)->loc, tenv.penv.sym("Pair"), carT, tenv.var(), 0);
@@ -253,7 +253,7 @@ ACarCall::constrain(TEnv& tenv, Constraints& c) const
void
ACdrCall::constrain(TEnv& tenv, Constraints& c) const
{
- if (size() != 2) throw Error("`cdr' requires exactly 1 argument", loc);
+ THROW_IF(size() != 2, "`cdr' requires exactly 1 argument", loc)
at(1)->constrain(tenv, c);
AType* cdrT = tenv.var(this);
AType* pairT = new AType(at(1)->loc, tenv.penv.sym("Pair"), tenv.var(), cdrT, 0);