diff options
author | David Robillard <d@drobilla.net> | 2010-12-31 06:09:42 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-12-31 06:09:42 +0000 |
commit | 247b1706013397a4c7f41c354cb3d9d3257dfbfb (patch) | |
tree | 7a339f90e86a743ecb1eae35b5e17008df8fbae6 | |
parent | ef8ec5f9d0a8def665cb31c6ee84e0afbc80c1bc (diff) | |
download | resp-247b1706013397a4c7f41c354cb3d9d3257dfbfb.tar.gz resp-247b1706013397a4c7f41c354cb3d9d3257dfbfb.tar.bz2 resp-247b1706013397a4c7f41c354cb3d9d3257dfbfb.zip |
Saner type unification.
git-svn-id: http://svn.drobilla.net/resp/resp@391 ad02d1e2-f140-0410-9f75-f8b11f17cedd
-rw-r--r-- | src/repl.cpp | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/src/repl.cpp b/src/repl.cpp index 204e2ab..50064f8 100644 --- a/src/repl.cpp +++ b/src/repl.cpp @@ -46,21 +46,9 @@ readParseType(CEnv& cenv, Cursor& cursor, istream& is, const AST*& exp, const AS Constraints c(cenv.tsubst); resp_constrain(cenv.tenv, c, ast); // Constrain types + cenv.tsubst = unify(c); - //cout << "(CONSTRAINTS " << endl << c << ")" << endl; - - const Subst subst = unify(c); // Solve type constraints - for (Subst::const_iterator i = subst.begin(); i != subst.end(); ++i) { - if (!cenv.tsubst.contains(i->first)) { // Substitution's LHS is a new variable - cenv.tsubst.push_back(*i); // Add substitution to global type substitution - Object::pool.addRoot(i->first); - Object::pool.addRoot(i->second); - } - } - - //cout << "(SUBST " << endl << subst << ")" << endl; //cout << "(TSUBST " << endl << cenv.tsubst << ")" << endl; - cenv.tsubst = Subst::compose(cenv.tsubst, subst); // FIXME: breaks polymorphism + repl Object::pool.addRoot(ast); // Make parsed expression a GC root so it is not deleted @@ -70,6 +58,8 @@ readParseType(CEnv& cenv, Cursor& cursor, istream& is, const AST*& exp, const AS static void callPrintCollect(CEnv& cenv, CFunc f, const AST* result, const AST* resultT, bool execute) { + Object::pool.collect(Object::pool.roots()); + if (execute) cenv.out << cenv.engine()->call(cenv, f, resultT); |