aboutsummaryrefslogtreecommitdiffstats
path: root/src/repl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/repl.cpp')
-rw-r--r--src/repl.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/repl.cpp b/src/repl.cpp
index 0264c18..c2a50f5 100644
--- a/src/repl.cpp
+++ b/src/repl.cpp
@@ -44,6 +44,8 @@ readParseType(CEnv& cenv, Cursor& cursor, istream& is, AST*& exp, AST*& ast)
Constraints c(cenv.tsubst);
ast->constrain(cenv.tenv, c); // Constrain types
+ //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
@@ -53,8 +55,8 @@ readParseType(CEnv& cenv, Cursor& cursor, istream& is, AST*& exp, AST*& ast)
}
}
- //cout << "**** SUBST\n" << subst << "********" << endl;
- //cout << "**** CENV.SUBST\n" << cenv.tsubst << "********" << endl;
+ //cout << "(SUBST " << endl << subst << ")" << endl;
+ //cout << "(TSUBST " << endl << cenv.tsubst << ")" << endl;
//cenv.tsubst = Subst::compose(cenv.tsubst, subst);
Object::pool.addRoot(ast); // Make parsed expression a GC root so it is not deleted
@@ -77,18 +79,21 @@ callPrintCollect(CEnv& cenv, CFunc f, AST* result, const AType* resultT, bool ex
/// Compile and evaluate code from @a is
int
-eval(CEnv& cenv, const string& name, istream& is, bool execute)
+eval(CEnv& cenv, Cursor& cursor, istream& is, bool execute)
{
- AST* exp = NULL;
- AST* ast = NULL;
+ AST* exp = NULL;
+ AST* ast = NULL;
list<AST*> parsed;
- Cursor cursor(name);
try {
while (readParseType(cenv, cursor, is, exp, ast))
parsed.push_back(ast);
- /*for (list<AST*>::const_iterator i = parsed.begin(); i != parsed.end(); ++i)
- pprint(cout, (*i)->cps(cenv.tenv, cenv.penv.sym("halt")));*/
+
+ if (cenv.args.find("-T") != cenv.args.end()) {
+ for (list<AST*>::const_iterator i = parsed.begin(); i != parsed.end(); ++i)
+ pprint(cout, (*i), &cenv, true);
+ return 0;
+ }
CVal val = NULL;
CFunc f = NULL;