aboutsummaryrefslogtreecommitdiffstats
path: root/src/c.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-12-08 19:07:09 +0000
committerDavid Robillard <d@drobilla.net>2010-12-08 19:07:09 +0000
commitd02fe43f0f6e50f8f22321aa0080283ee2ecc9fc (patch)
tree2a2007137d19221a541e97764dc3adef054f6581 /src/c.cpp
parent583a2d9d2397ff174b16d7df377f16c1df6fe875 (diff)
downloadresp-d02fe43f0f6e50f8f22321aa0080283ee2ecc9fc.tar.gz
resp-d02fe43f0f6e50f8f22321aa0080283ee2ecc9fc.tar.bz2
resp-d02fe43f0f6e50f8f22321aa0080283ee2ecc9fc.zip
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
Diffstat (limited to 'src/c.cpp')
-rw-r--r--src/c.cpp13
1 files changed, 7 insertions, 6 deletions
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<Value*> 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()));
}
}