diff options
author | David Robillard <d@drobilla.net> | 2010-12-04 23:48:39 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-12-04 23:48:39 +0000 |
commit | 5ca01630edc38087b722e1c22b20edc82d871dd7 (patch) | |
tree | cc58b13832fba3161f952bdfd9f2a7db5c90ade6 /src | |
parent | 8905a0e25858a047e0844c55ed8a025153ab25d9 (diff) | |
download | resp-5ca01630edc38087b722e1c22b20edc82d871dd7.tar.gz resp-5ca01630edc38087b722e1c22b20edc82d871dd7.tar.bz2 resp-5ca01630edc38087b722e1c22b20edc82d871dd7.zip |
Tidy up unify.cpp
git-svn-id: http://svn.drobilla.net/resp/resp@298 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src')
-rw-r--r-- | src/resp.hpp | 5 | ||||
-rw-r--r-- | src/unify.cpp | 11 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/resp.hpp b/src/resp.hpp index 6a40729..35edf31 100644 --- a/src/resp.hpp +++ b/src/resp.hpp @@ -438,6 +438,10 @@ struct AType : public ATuple { AType(Cursor c, AST* ast, va_list args) : ATuple(c, ast, args), kind(EXPR), id(0) { tag(T_TYPE); } AType(const AST* first, const AST* rest, Cursor c) : ATuple(first, rest, c), kind(EXPR), id(0) { tag(T_TYPE); } AType(const AType& copy) : ATuple(copy), kind(copy.kind), id(copy.id) { tag(T_TYPE); } + AType(const AType& copy, Cursor cur) : ATuple(copy), kind(copy.kind), id(copy.id) { + tag(T_TYPE); + loc = cur; + } bool concrete() const { switch (kind) { @@ -703,6 +707,7 @@ struct TEnv : public Env<const ASymbol*, const AType*> { if (!ast) return new AType(Cursor(), varID++); + assert(!ast->to_type()); Vars::iterator v = vars.find(ast); if (v != vars.end()) return v->second; diff --git a/src/unify.cpp b/src/unify.cpp index 0c9dea2..9f3a521 100644 --- a/src/unify.cpp +++ b/src/unify.cpp @@ -33,7 +33,7 @@ TEnv::buildSubst(const AType* genericT, const AType& argsT) // Build substitution to apply to generic type const ATuple* genericProtT = genericT->list_ref(1)->as_tuple(); ATuple::const_iterator g = genericProtT->begin(); - AType::const_iterator a = argsT.begin(); + ATuple::const_iterator a = argsT.begin(); for (; a != argsT.end(); ++a, ++g) { const AType* genericArgT = (*g)->to_type(); const AType* callArgT = (*a)->to_type(); @@ -60,7 +60,6 @@ Constraints::constrain(TEnv& tenv, const AST* o, const AType* t) { assert(o); assert(t); - assert(!o->to_type()); push_back(Constraint(tenv.var(o), t)); } @@ -109,16 +108,12 @@ Constraints::replace(const AType* s, const AType* t) { for (Constraints::iterator c = begin(); c != end(); ++c) { if (*c->first == *s) { - AType* type = new AType(*t); - type->loc = c->first->loc; - c->first = type; + c->first = new AType(*t, c->first->loc); } else if (c->first->kind == AType::EXPR) { c->first = substitute(c->first, s, t); } if (*c->second == *s) { - AType* type = new AType(*t); - type->loc = c->second->loc; - c->second = type; + c->second = new AType(*t, c->second->loc); } else if (c->second->kind == AType::EXPR) { c->second = substitute(c->second, s, t); } |