diff options
author | David Robillard <d@drobilla.net> | 2009-10-13 21:05:29 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-10-13 21:05:29 +0000 |
commit | 2759e14c66c62e3b66cdd5af3e9914f72b32b5ee (patch) | |
tree | 10e610ec01316f52edde682abf2a6effb8da9afe /src/c.cpp | |
parent | 3bed7f70fb2793cf7ba82473526ac1ac97de1973 (diff) | |
download | resp-2759e14c66c62e3b66cdd5af3e9914f72b32b5ee.tar.gz resp-2759e14c66c62e3b66cdd5af3e9914f72b32b5ee.tar.bz2 resp-2759e14c66c62e3b66cdd5af3e9914f72b32b5ee.zip |
Cleanup, shrink.
git-svn-id: http://svn.drobilla.net/resp/tuplr@209 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/c.cpp')
-rw-r--r-- | src/c.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
@@ -36,8 +36,8 @@ struct Function { string text; }; -static inline Value* llVal(CValue v) { return static_cast<Value*>(v); } -static inline Function* llFunc(CFunction f) { return static_cast<Function*>(f); } +static inline Value* llVal(CVal v) { return static_cast<Value*>(v); } +static inline Function* llFunc(CFunc f) { return static_cast<Function*>(f); } static const Type* llType(const AType* t) @@ -83,7 +83,7 @@ struct CEngine : public Engine { { } - CFunction startFunction(CEnv& cenv, + CFunc startFunction(CEnv& cenv, const std::string& name, const AType* retT, const ATuple& argsT, const vector<string> argNames) { @@ -112,35 +112,35 @@ struct CEngine : public Engine { return f; } - void finishFunction(CEnv& cenv, CFunction f, const AType* retT, CValue ret) { + void finishFunction(CEnv& cenv, CFunc f, const AType* retT, CVal ret) { out += "return " + *(Value*)ret + ";\n}\n\n"; } - void eraseFunction(CEnv& cenv, CFunction f) { + void eraseFunction(CEnv& cenv, CFunc f) { cenv.err << "C backend does not support JIT (eraseFunction)" << endl; } - CValue compileCall(CEnv& cenv, CFunction func, const vector<CValue>& args) { + CVal compileCall(CEnv& cenv, CFunc func, const vector<CVal>& args) { Value* varname = new string(cenv.penv.gensymstr("x")); Function* f = llFunc(func); out += (format("const %s %s = %s(") % f->returnType % *varname % f->name).str(); - FOREACH(vector<CValue>::const_iterator, i, args) + FOREACH(vector<CVal>::const_iterator, i, args) out += *llVal(*i); out += ");\n"; return varname; } - CFunction compileFunction(CEnv& cenv, AFn* fn, const AType& argsT); + CFunc compileFunction(CEnv& cenv, AFn* fn, const AType& argsT); - CValue compileLiteral(CEnv& cenv, AST* lit); - CValue compilePrimitive(CEnv& cenv, APrimitive* prim); - CValue compileIf(CEnv& cenv, AIf* aif); + CVal compileLiteral(CEnv& cenv, AST* lit); + CVal compilePrimitive(CEnv& cenv, APrimitive* prim); + CVal compileIf(CEnv& cenv, AIf* aif); void writeModule(CEnv& cenv, std::ostream& os) { os << out; } - const string call(CEnv& cenv, CFunction f, AType* retT) { + const string call(CEnv& cenv, CFunc f, AType* retT) { cenv.err << "C backend does not support JIT (call)" << endl; return ""; } @@ -158,13 +158,13 @@ tuplr_new_c_engine() * Code Generation * ***************************************************************************/ -CValue +CVal CEngine::compileLiteral(CEnv& cenv, AST* lit) { return new Value(lit->str()); } -CFunction +CFunc CEngine::compileFunction(CEnv& cenv, AFn* fn, const AType& argsT) { TEnv::GenericTypes::const_iterator gt = cenv.tenv.genericTypes.find(fn); @@ -184,7 +184,7 @@ CEngine::compileFunction(CEnv& cenv, AFn* fn, const AType& argsT) string("call has non-concrete type %1%\n") + thisType->str()); Object::pool.addRoot(thisType); - CFunction f = fn->impls.find(thisType); + CFunc f = fn->impls.find(thisType); if (f) return f; @@ -220,7 +220,7 @@ CEngine::compileFunction(CEnv& cenv, AFn* fn, const AType& argsT) // Define value first for recursion cenv.precompile(fn, f); fn->impls.push_back(make_pair(thisType, f)); - CValue retVal = NULL; + CVal retVal = NULL; for (size_t i = 2; i < fn->size(); ++i) retVal = cenv.compile(fn->at(i)); cenv.engine()->finishFunction(cenv, f, cenv.type(fn->at(fn->size() - 1)), retVal); @@ -233,7 +233,7 @@ CEngine::compileFunction(CEnv& cenv, AFn* fn, const AType& argsT) return f; } -CValue +CVal CEngine::compileIf(CEnv& cenv, AIf* aif) { CEngine* engine = reinterpret_cast<CEngine*>(cenv.engine()); @@ -261,7 +261,7 @@ CEngine::compileIf(CEnv& cenv, AIf* aif) return varname; } -CValue +CVal CEngine::compilePrimitive(CEnv& cenv, APrimitive* prim) { CEngine* engine = reinterpret_cast<CEngine*>(cenv.engine()); |