From 336648e6c68fb0d24d12e67e37c9398c01d09c34 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 14 Oct 2009 00:43:14 +0000 Subject: Remove cruft. git-svn-id: http://svn.drobilla.net/resp/tuplr@216 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- src/constrain.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/constrain.cpp') diff --git a/src/constrain.cpp b/src/constrain.cpp index 7106ec8..e5349d9 100644 --- a/src/constrain.cpp +++ b/src/constrain.cpp @@ -66,17 +66,15 @@ AFn::constrain(TEnv& tenv, Constraints& c) const if (gt != tenv.genericTypes.end()) { genericType = gt->second; } else { - set defined; + set defs; TEnv::Frame frame; // Add parameters to environment frame for (size_t i = 0; i < prot()->size(); ++i) { const ASymbol* sym = prot()->at(i)->to(); - if (!sym) - throw Error(prot()->at(i)->loc, "parameter name is not a symbol"); - if (defined.find(sym) != defined.end()) - throw Error(sym->loc, (format("duplicate parameter `%1%'") % sym->str()).str()); - defined.insert(sym); + THROW_IF(!sym, prot()->at(i)->loc, "parameter name is not a symbol"); + THROW_IF(defs.count(sym) != 0, sym->loc, string("duplicate parameter `") + sym->str() + "'"); + defs.insert(sym); frame.push_back(make_pair(sym, make_pair((AST*)NULL, (AType*)NULL))); } @@ -87,9 +85,8 @@ AFn::constrain(TEnv& tenv, Constraints& c) const const ADef* def = exp->to(); if (def) { const ASymbol* sym = def->sym(); - if (defined.find(sym) != defined.end()) - throw Error(def->loc, (format("`%1%' defined twice") % sym->str()).str()); - defined.insert(def->sym()); + THROW_IF(defs.count(sym) != 0, def->loc, (format("`%1%' defined twice") % sym->str()).str()); + defs.insert(def->sym()); frame.push_back(make_pair(def->sym(), make_pair(const_cast(def->at(2)), (AType*)NULL))); } @@ -138,8 +135,7 @@ ACall::constrain(TEnv& tenv, Constraints& c) const const AST* callee = tenv.resolve(at(0)); const AFn* closure = callee->to(); if (closure) { - if (size() - 1 != closure->prot()->size()) - throw Error(loc, "incorrect number of arguments"); + THROW_IF(size() - 1 != closure->prot()->size(), loc, "incorrect number of arguments"); TEnv::GenericTypes::iterator gt = tenv.genericTypes.find(closure); if (gt != tenv.genericTypes.end()) { const ATuple* prot = gt->second->at(1)->to(); -- cgit v1.2.1