diff options
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; |