diff options
Diffstat (limited to 'src/repl.cpp')
-rw-r--r-- | src/repl.cpp | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/src/repl.cpp b/src/repl.cpp index 85b2821..a5c6adf 100644 --- a/src/repl.cpp +++ b/src/repl.cpp @@ -27,7 +27,7 @@ using namespace std; static bool -readParseTypeCompile(CEnv& cenv, Cursor& cursor, istream& is, AST*& exp, AST*& ast, AType*& type) +readParseTypeLift(CEnv& cenv, Cursor& cursor, istream& is, AST*& exp, AST*& ast, AType*& type) { exp = readExpression(cursor, is); if (exp->to<ATuple*>() && exp->to<ATuple*>()->empty()) @@ -50,10 +50,6 @@ readParseTypeCompile(CEnv& cenv, Cursor& cursor, istream& is, AST*& exp, AST*& a ast->lift(cenv); // Lift functions - // Add definitions as GC roots - if (ast->to<ADef*>()) - cenv.lock(ast); - return true; } @@ -83,7 +79,7 @@ eval(CEnv& cenv, const string& name, istream& is, bool execute) list< pair<AST*, AST*> > exprs; Cursor cursor(name); try { - while (readParseTypeCompile(cenv, cursor, is, exp, ast, type)) + while (readParseTypeLift(cenv, cursor, is, exp, ast, type)) exprs.push_back(make_pair(exp, ast)); //for (list< pair<SExp, AST*> >::const_iterator i = exprs.begin(); i != exprs.end(); ++i) @@ -127,23 +123,14 @@ repl(CEnv& cenv) Cursor cursor("(stdin)"); try { - if (!readParseTypeCompile(cenv, cursor, std::cin, exp, ast, type)) + if (!readParseTypeLift(cenv, cursor, std::cin, exp, ast, type)) break; CFunc f = NULL; try { // Create function for this repl loop f = cenv.engine()->startFunction(cenv, replFnName, type, ATuple(cursor)); - - CVal val = ast->compile(cenv); - - // Set global if expression is a top level define - if (ast->to<ADef*>()) { - ADef* def = ast->to<ADef*>(); - cenv.vals.def(def->sym(), cenv.engine()->compileGlobal( - cenv, cenv.type(def->body()), def->sym()->str(), val)); - } - cenv.engine()->finishFunction(cenv, f, type, val); + cenv.engine()->finishFunction(cenv, f, type, ast->compile(cenv)); callPrintCollect(cenv, f, ast, type, true); } catch (Error& e) { cenv.out << e.msg << endl; |