aboutsummaryrefslogtreecommitdiffstats
path: root/src/unify.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-10-15 19:24:00 +0000
committerDavid Robillard <d@drobilla.net>2009-10-15 19:24:00 +0000
commitc139e62f1fa1341eaa9c6f7b7d8e54601721a329 (patch)
treea20204e68f4ed3128973cd32f443cb9a8f91a9c4 /src/unify.cpp
parent7743d332e41c7795dcbaa49511293f22597e4db7 (diff)
downloadresp-c139e62f1fa1341eaa9c6f7b7d8e54601721a329.tar.gz
resp-c139e62f1fa1341eaa9c6f7b7d8e54601721a329.tar.bz2
resp-c139e62f1fa1341eaa9c6f7b7d8e54601721a329.zip
Remove all use of ATuple::at().
git-svn-id: http://svn.drobilla.net/resp/tuplr@229 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/unify.cpp')
-rw-r--r--src/unify.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/unify.cpp b/src/unify.cpp
index 38f2583..5284bea 100644
--- a/src/unify.cpp
+++ b/src/unify.cpp
@@ -31,7 +31,7 @@ TEnv::buildSubst(AType* genericT, const AType& argsT)
Subst subst;
// Build substitution to apply to generic type
- const ATuple* genericProtT = genericT->at(1)->as<const ATuple*>();
+ const ATuple* genericProtT = (*(genericT->begin() + 1))->as<const ATuple*>();
assert(argsT.size() == genericProtT->size());
ATuple::const_iterator g = genericProtT->begin();
AType::const_iterator a = argsT.begin();
@@ -41,9 +41,11 @@ TEnv::buildSubst(AType* genericT, const AType& argsT)
if (callArgT->kind == AType::EXPR) {
assert(genericArgT->kind == AType::EXPR);
assert(callArgT->size() == genericArgT->size());
- for (size_t i = 0; i < callArgT->size(); ++i) {
- const AType* gT = genericArgT->at(i)->to<const AType*>();
- AType* aT = callArgT->at(i)->to<AType*>();
+ ATuple::const_iterator gi = genericArgT->begin();
+ ATuple::const_iterator ci = callArgT->begin();
+ for (; gi != genericArgT->end(); ++gi, ++ci) {
+ const AType* gT = (*gi)->to<const AType*>();
+ AType* aT = (*ci)->to<AType*>();
if (gT && aT)
subst.add(gT, aT);
}
@@ -68,11 +70,11 @@ static void
substitute(ATuple* tup, const AST* from, AST* to)
{
if (!tup) return;
- for (size_t i = 0; i < tup->size(); ++i)
- if (*tup->at(i) == *from)
- tup->at(i) = to;
- else if (tup->at(i) != to)
- substitute(tup->at(i)->to<ATuple*>(), from, to);
+ FOREACHP(ATuple::iterator, i, tup)
+ if (**i == *from)
+ *i = to;
+ else if (*i != to)
+ substitute((*i)->to<ATuple*>(), from, to);
}
/// Compose two substitutions (TAPL 22.1.1)
@@ -124,11 +126,13 @@ unify(const Constraints& constraints)
cp.replace(t, s);
return Subst::compose(unify(cp), Subst(t, s));
} else if (s->kind == AType::EXPR && s->kind == t->kind && s->size() == t->size()) {
- for (size_t i = 1; i < s->size(); ++i) {
- AType* si = s->at(i)->to<AType*>();
- AType* ti = t->at(i)->to<AType*>();
- assert(si && ti);
- cp.push_back(Constraint(si, ti, si->loc));
+ AType::iterator si = s->begin() + 1;
+ AType::iterator ti = t->begin() + 1;
+ for (; si != s->end(); ++si, ++ti) {
+ AType* st = (*si)->to<AType*>();
+ AType* tt = (*ti)->to<AType*>();
+ assert(st && tt);
+ cp.push_back(Constraint(st, tt, st->loc));
}
return unify(cp);
} else {