diff options
author | David Robillard <d@drobilla.net> | 2010-12-26 20:25:57 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-12-26 20:25:57 +0000 |
commit | 28e3727290335ee85793795f7ec6d48e050db922 (patch) | |
tree | b3a20c1f7c2efb1794d4e80b61e5048b1cfbeac2 /src/unify.cpp | |
parent | aa6a0b6a6553e854be6731e8ebd4306605b00e6e (diff) | |
download | resp-28e3727290335ee85793795f7ec6d48e050db922.tar.gz resp-28e3727290335ee85793795f7ec6d48e050db922.tar.bz2 resp-28e3727290335ee85793795f7ec6d48e050db922.zip |
Remove AType::DOTS.
git-svn-id: http://svn.drobilla.net/resp/resp@358 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/unify.cpp')
-rw-r--r-- | src/unify.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/unify.cpp b/src/unify.cpp index 48818e9..52a3265 100644 --- a/src/unify.cpp +++ b/src/unify.cpp @@ -119,6 +119,13 @@ Constraints::replace(const AType* s, const AType* t) return *this; } +static inline bool +is_dots(const AST* ast) +{ + const AType* type = ast->as_type(); + return (type->kind == AType::NAME && type->head()->str() == "..."); +} + /// Unify a type constraint set (TAPL 22.4) Subst unify(const Constraints& constraints) @@ -143,13 +150,14 @@ unify(const Constraints& constraints) for (; si != s->end() && ti != t->end(); ++si, ++ti) { const AType* st = (*si)->as_type(); const AType* tt = (*ti)->as_type(); - if (st->kind == AType::DOTS || tt->kind == AType::DOTS) + if (is_dots(st) || is_dots(tt)) return unify(cp); else cp.push_back(Constraint(st, tt)); } - if ( (si == s->end() && (ti == t->end() || (*ti)->as_type()->kind == AType::DOTS)) - || (ti == t->end() && (*si)->as_type()->kind == AType::DOTS)) + if ((si == s->end() && ti == t->end()) + || (si != s->end() && is_dots(*si)) + || (ti != t->end() && is_dots(*ti))) return unify(cp); } throw Error(s->loc, |