From 311e3b43b68209648fe9561d1aaff93d9a4d4f0f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 7 Mar 2009 03:52:55 +0000 Subject: Make out and error streams fields of CEnv instead of static globals. git-svn-id: http://svn.drobilla.net/resp/tuplr@73 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- llvm.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'llvm.cpp') diff --git a/llvm.cpp b/llvm.cpp index e94a806..8eeab42 100644 --- a/llvm.cpp +++ b/llvm.cpp @@ -92,8 +92,8 @@ struct CEnvPimpl { Function* alloc; }; -CEnv::CEnv(PEnv& p, TEnv& t, CEngine& eng) - : engine(eng), penv(p), tenv(t), symID(0), _pimpl(new CEnvPimpl(eng)) +CEnv::CEnv(PEnv& p, TEnv& t, CEngine& e, ostream& os, ostream& es) + : engine(e), penv(p), tenv(t), symID(0), alloc(0), log(os, es), _pimpl(new CEnvPimpl(e)) { } @@ -539,10 +539,10 @@ eval(CEnv& cenv, const string& name, istream& is) cenv.engine.builder.CreateRet(val); cenv.optimise(f); - out << call(resultType, cenv.engine.engine->getPointerToFunction(f)) + cenv.log.out << call(resultType, cenv.engine.engine->getPointerToFunction(f)) << " : " << resultType->str() << endl; } catch (Error& e) { - err << e.what() << endl; + cenv.log.err << e.what() << endl; return 1; } return 0; @@ -552,8 +552,8 @@ int repl(CEnv& cenv) { while (1) { - out << "() "; - out.flush(); + cenv.log.out << "() "; + cenv.log.out.flush(); Cursor cursor("(stdin)"); try { SExp exp = readExpression(cursor, std::cin); @@ -580,13 +580,13 @@ repl(CEnv& cenv) f->eraseFromParent(); // Error reading body, remove function throw e; } - out << call(bodyT, cenv.engine.engine->getPointerToFunction(f)); + cenv.log.out << call(bodyT, cenv.engine.engine->getPointerToFunction(f)); } else { - out << "; " << cenv.compile(body); + cenv.log.out << "; " << cenv.compile(body); } - out << " : " << cenv.tenv.type(body)->str() << endl; + cenv.log.out << " : " << cenv.tenv.type(body)->str() << endl; } catch (Error& e) { - err << e.what() << endl; + cenv.log.err << e.what() << endl; } } return 0; -- cgit v1.2.1