aboutsummaryrefslogtreecommitdiffstats
path: root/src/repl.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-10-16 15:25:00 +0000
committerDavid Robillard <d@drobilla.net>2009-10-16 15:25:00 +0000
commitb0a5e24bb43e06fe99e9c4d6cddebce08c379af7 (patch)
treec1a171b32186b4c2415d7e461cdacb554b6a5deb /src/repl.cpp
parentb7f85538771817b5ff7f2573bd1c5d64c9849e1e (diff)
downloadresp-b0a5e24bb43e06fe99e9c4d6cddebce08c379af7.tar.gz
resp-b0a5e24bb43e06fe99e9c4d6cddebce08c379af7.tar.bz2
resp-b0a5e24bb43e06fe99e9c4d6cddebce08c379af7.zip
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
Diffstat (limited to 'src/repl.cpp')
-rw-r--r--src/repl.cpp21
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;