aboutsummaryrefslogtreecommitdiffstats
path: root/src/repl.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-10-15 16:08:46 +0000
committerDavid Robillard <d@drobilla.net>2009-10-15 16:08:46 +0000
commitd388d0a98042ede74a0240f3eebb9e6b2ef854b1 (patch)
tree968a8ad27ab90d8668642dbb7f66ecb018380714 /src/repl.cpp
parent6942e2f4c1fec87a152eeefa0ed85e169760fa77 (diff)
downloadresp-d388d0a98042ede74a0240f3eebb9e6b2ef854b1.tar.gz
resp-d388d0a98042ede74a0240f3eebb9e6b2ef854b1.tar.bz2
resp-d388d0a98042ede74a0240f3eebb9e6b2ef854b1.zip
Tidy.
git-svn-id: http://svn.drobilla.net/resp/tuplr@223 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/repl.cpp')
-rw-r--r--src/repl.cpp54
1 files 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<ATuple*>() && (*exp)->to<ATuple*>()->empty())
+ exp = readExpression(cursor, is);
+ if (exp->to<ATuple*>() && exp->to<ATuple*>()->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<ADef*>())
- cenv.lock(*result);
+ if (ast->to<ADef*>())
+ 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<AST*, AST*> > 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<SExp, AST*> >::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<AST*, AST*> >::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);