From d02fe43f0f6e50f8f22321aa0080283ee2ecc9fc Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 8 Dec 2010 19:07:09 +0000 Subject: Clean up function compilation stuff. Add some utilities to for using named types. git-svn-id: http://svn.drobilla.net/resp/resp@313 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- src/c.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/c.cpp') diff --git a/src/c.cpp b/src/c.cpp index 51455e3..2373846 100644 --- a/src/c.cpp +++ b/src/c.cpp @@ -100,7 +100,7 @@ struct CEngine : public Engine { } CFunc startFunction(CEnv& cenv, - const std::string& name, const ATuple* args, const AType* type) + const std::string& name, const ATuple* args, const AType* type) { const AType* argsT = type->prot()->as_type(); const AType* retT = type->list_ref(2)->as_type(); @@ -130,10 +130,11 @@ struct CEngine : public Engine { f->text += ")\n{\n"; out += f->text; + return f; } - void pushFunctionArgs(CEnv& cenv, const ATuple* fn, const AType* type, CFunc f); + void pushFunctionArgs(CEnv& cenv, const ATuple* prot, const AType* type, CFunc f); void finishFunction(CEnv& cenv, CFunc f, CVal ret) { out += "return " + *(Value*)ret + ";\n}\n\n"; @@ -210,7 +211,7 @@ CEngine::compileString(CEnv& cenv, const char* str) } void -CEngine::pushFunctionArgs(CEnv& cenv, const ATuple* fn, const AType* type, CFunc f) +CEngine::pushFunctionArgs(CEnv& cenv, const ATuple* prot, const AType* type, CFunc f) { cenv.push(); @@ -218,12 +219,12 @@ CEngine::pushFunctionArgs(CEnv& cenv, const ATuple* fn, const AType* type, CFunc // Bind argument values in CEnv vector args; - ATuple::const_iterator p = fn->prot()->begin(); + ATuple::const_iterator p = prot->begin(); ATuple::const_iterator pT = argsT->begin(); - for (; p != fn->prot()->end(); ++p, ++pT) { + for (; p != prot->end(); ++p, ++pT) { const AType* t = (*pT)->as_type(); const Type* lt = llType(t); - THROW_IF(!lt, fn->loc, "untyped parameter\n"); + THROW_IF(!lt, (*p)->loc, "untyped parameter\n"); cenv.def((*p)->as_symbol(), *p, t, new string((*p)->str())); } } -- cgit v1.2.1