diff options
author | David Robillard <d@drobilla.net> | 2010-04-13 17:37:01 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-04-13 17:37:01 +0000 |
commit | 58170e475a1a35685ccb180767c4f86489be5733 (patch) | |
tree | f119bfb983202d4a50ab74d5dccf0af950390511 /src/repl.cpp | |
parent | d15593d1cda3e7c56cccc4958d6e07f8f15c90f3 (diff) | |
download | resp-58170e475a1a35685ccb180767c4f86489be5733.tar.gz resp-58170e475a1a35685ccb180767c4f86489be5733.tar.bz2 resp-58170e475a1a35685ccb180767c4f86489be5733.zip |
Better error reporting when unification fails (report both locations, and preserve locations during substitution).
git-svn-id: http://svn.drobilla.net/resp/resp@256 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/repl.cpp')
-rw-r--r-- | src/repl.cpp | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/src/repl.cpp b/src/repl.cpp index 92fb621..472d1a5 100644 --- a/src/repl.cpp +++ b/src/repl.cpp @@ -38,7 +38,17 @@ readParseType(CEnv& cenv, Cursor& cursor, istream& is, AST*& exp, AST*& ast) Constraints c(cenv.tsubst); ast->constrain(cenv.tenv, c); // Constrain types - cenv.tsubst = unify(c); // Solve type constraints + 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)) { + //cout << "New variable " << i->first << " = " << i->second << endl; + cenv.tsubst.push_back(*i); + } + } + + //cout << "**** SUBST\n" << subst << "********" << endl; + //cout << "**** CENV.SUBST\n" << cenv.tsubst << "********" << endl; + //cenv.tsubst = Subst::compose(cenv.tsubst, subst); // Add types in type substition as GC roots for (Subst::iterator i = cenv.tsubst.begin(); i != cenv.tsubst.end(); ++i) { @@ -74,8 +84,8 @@ eval(CEnv& cenv, const string& name, istream& is, bool execute) while (readParseType(cenv, cursor, is, exp, ast)) parsed.push_back(ast); - //for (list< pair<SExp, AST*> >::const_iterator i = parsed.begin(); i != parsed.end(); ++i) - // pprint(cout, i->second->cps(cenv.tenv, cenv.penv.sym("cont"))); + /*for (list<AST*>::const_iterator i = parsed.begin(); i != parsed.end(); ++i) + pprint(cout, (*i)->cps(cenv.tenv, cenv.penv.sym("halt")));*/ CVal val = NULL; CFunc f = NULL; @@ -89,10 +99,18 @@ eval(CEnv& cenv, const string& name, istream& is, bool execute) concrete.push_back(c); } - cout << endl << ";;;; CONCRETE {" << endl << endl; - for (Code::iterator i = concrete.begin(); i != concrete.end(); ++i) - cout << *i << endl << endl; - cout << ";;;; } CONCRETE" << endl << endl;*/ + if (cenv.args.find("-d") != cenv.args.end()) { + cout << endl << ";;;; CONCRETE {" << endl << endl; + for (Code::iterator i = concrete.begin(); i != concrete.end(); ++i) { + cout << *i << endl; + ADef* def = (*i)->to<ADef*>(); + if (def) + std::cout << " :: " << cenv.type(def->body()) << std::endl; + cout << endl; + } + cout << ";;;; } CONCRETE" << endl << endl; + } + */ // Lift all expressions Code lifted; |