From 247b1706013397a4c7f41c354cb3d9d3257dfbfb Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 31 Dec 2010 06:09:42 +0000 Subject: Saner type unification. git-svn-id: http://svn.drobilla.net/resp/resp@391 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- src/repl.cpp | 16 +++------------- 1 file 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); -- cgit v1.2.1