From d388d0a98042ede74a0240f3eebb9e6b2ef854b1 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 15 Oct 2009 16:08:46 +0000 Subject: Tidy. git-svn-id: http://svn.drobilla.net/resp/tuplr@223 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- src/repl.cpp | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/repl.cpp b/src/repl.cpp index 88885ea..96f30c3 100644 --- a/src/repl.cpp +++ b/src/repl.cpp @@ -27,15 +27,15 @@ using namespace std; static bool -readParseTypeCompile(CEnv& cenv, Cursor& cursor, istream& is, AST** exp, AST** result, AType** resultT) +readParseTypeCompile(CEnv& cenv, Cursor& cursor, istream& is, AST*& exp, AST*& ast, AType*& type) { - *exp = readExpression(cursor, is); - if ((*exp)->to() && (*exp)->to()->empty()) + exp = readExpression(cursor, is); + if (exp->to() && exp->to()->empty()) return false; - *result = cenv.penv.parse(*exp); // Parse input + ast = cenv.penv.parse(exp); // Parse input Constraints c; - (*result)->constrain(cenv.tenv, c); // Constrain types + ast->constrain(cenv.tenv, c); // Constrain types cenv.tsubst = Subst::compose(cenv.tsubst, unify(c)); // Solve type constraints @@ -45,14 +45,14 @@ readParseTypeCompile(CEnv& cenv, Cursor& cursor, istream& is, AST** exp, AST** r Object::pool.addRoot(i->second); } - (*resultT) = cenv.type(*result); - THROW_IF(!*resultT, cursor, "call to untyped body"); + type = cenv.type(ast); + THROW_IF(!type, cursor, "call to untyped body"); - (*result)->lift(cenv); // Lift functions + ast->lift(cenv); // Lift functions // Add definitions as GC roots - if ((*result)->to()) - cenv.lock(*result); + if (ast->to()) + cenv.lock(ast); return true; } @@ -77,34 +77,34 @@ callPrintCollect(CEnv& cenv, CFunc f, AST* result, AType* resultT, bool execute) int eval(CEnv& cenv, const string& name, istream& is, bool execute) { - AST* exp = NULL; - AST* result = NULL; - AType* resultT = NULL; + AST* exp = NULL; + AST* ast = NULL; + AType* type = NULL; list< pair > exprs; Cursor cursor(name); try { - while (readParseTypeCompile(cenv, cursor, is, &exp, &result, &resultT)) - exprs.push_back(make_pair(exp, result)); + while (readParseTypeCompile(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) // pprint(cout, i->second->cps(cenv.tenv, cenv.penv.sym("cont"))); CVal val = NULL; CFunc f = NULL; - if (resultT->concrete()) { + if (type->concrete()) { // Create function for top-level of program - f = cenv.engine()->startFunction(cenv, "main", resultT, ATuple(cursor)); + f = cenv.engine()->startFunction(cenv, "main", type, ATuple(cursor)); // Compile all expressions into it for (list< pair >::const_iterator i = exprs.begin(); i != exprs.end(); ++i) val = i->second->compile(cenv); // Finish compilation - cenv.engine()->finishFunction(cenv, f, resultT, val); + cenv.engine()->finishFunction(cenv, f, type, val); } - // Call and print result - callPrintCollect(cenv, f, result, resultT, execute); + // Call and print ast + callPrintCollect(cenv, f, ast, type, execute); } catch (Error& e) { cenv.err << e.what() << endl; @@ -117,9 +117,9 @@ eval(CEnv& cenv, const string& name, istream& is, bool execute) int repl(CEnv& cenv) { - AST* exp = NULL; - AST* result = NULL; - AType* resultT = NULL; + AST* exp = NULL; + AST* ast = NULL; + AType* type = NULL; const string replFnName = cenv.penv.gensymstr("_repl"); while (1) { cenv.out << "() "; @@ -128,15 +128,15 @@ repl(CEnv& cenv) try { Subst oldSubst = cenv.tsubst; - if (!readParseTypeCompile(cenv, cursor, std::cin, &exp, &result, &resultT)) + if (!readParseTypeCompile(cenv, cursor, std::cin, exp, ast, type)) break; CFunc f = NULL; try { // Create function for this repl loop - f = cenv.engine()->startFunction(cenv, replFnName, resultT, ATuple(cursor)); - cenv.engine()->finishFunction(cenv, f, resultT, result->compile(cenv)); - callPrintCollect(cenv, f, result, resultT, true); + f = cenv.engine()->startFunction(cenv, replFnName, type, ATuple(cursor)); + cenv.engine()->finishFunction(cenv, f, type, ast->compile(cenv)); + callPrintCollect(cenv, f, ast, type, true); } catch (Error& e) { cenv.out << e.msg << endl; cenv.engine()->eraseFunction(cenv, f); -- cgit v1.2.1