aboutsummaryrefslogtreecommitdiffstats
path: root/src/constrain.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-10-14 00:43:14 +0000
committerDavid Robillard <d@drobilla.net>2009-10-14 00:43:14 +0000
commit336648e6c68fb0d24d12e67e37c9398c01d09c34 (patch)
tree291b28073091b65d41a82e36853130ce3b7adfda /src/constrain.cpp
parentba3406f78e20f2e6a7fd6dbe28eb8de553cec9ae (diff)
downloadresp-336648e6c68fb0d24d12e67e37c9398c01d09c34.tar.gz
resp-336648e6c68fb0d24d12e67e37c9398c01d09c34.tar.bz2
resp-336648e6c68fb0d24d12e67e37c9398c01d09c34.zip
Remove cruft.
git-svn-id: http://svn.drobilla.net/resp/tuplr@216 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/constrain.cpp')
-rw-r--r--src/constrain.cpp18
1 files changed, 7 insertions, 11 deletions
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<const ASymbol*> defined;
+ set<const ASymbol*> 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<const ASymbol*>();
- 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<const ADef*>();
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<AST*>(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<const AFn*>();
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<const ATuple*>();