From b0a5e24bb43e06fe99e9c4d6cddebce08c379af7 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 16 Oct 2009 15:25:00 +0000 Subject: Fix globals. Don't add always empty top level environment frames (screws up Env::topLevel). git-svn-id: http://svn.drobilla.net/resp/tuplr@242 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- src/repl.cpp | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) (limited to 'src/repl.cpp') 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() && exp->to()->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()) - cenv.lock(ast); - return true; } @@ -83,7 +79,7 @@ eval(CEnv& cenv, const string& name, istream& is, bool execute) list< pair > 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 >::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* def = ast->to(); - 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; -- cgit v1.2.1