aboutsummaryrefslogtreecommitdiffstats
path: root/src/compile.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/compile.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/compile.cpp')
-rw-r--r--src/compile.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/compile.cpp b/src/compile.cpp
index 282a7f0..647c7d5 100644
--- a/src/compile.cpp
+++ b/src/compile.cpp
@@ -36,17 +36,16 @@ compile_symbol(CEnv& cenv, const ASymbol* sym) throw()
static CVal
compile_fn(CEnv& cenv, const ATuple* fn) throw()
{
+ assert(!cenv.currentFn);
+
const AType* type = cenv.type(fn);
CFunc f = cenv.findImpl(fn, type);
if (f)
return f;
-
- // Write function declaration
- f = cenv.engine()->startFunction(cenv, cenv.name(fn), fn->prot(), type);
- // Create a new environment frame and bind argument values
- cenv.engine()->pushFunctionArgs(cenv, fn, type, f);
- assert(!cenv.currentFn);
+ // Write function declaration and push stack frame
+ f = cenv.engine()->startFunction(cenv, cenv.name(fn), fn->prot(), type);
+ cenv.engine()->pushFunctionArgs(cenv, fn->prot(), type, f);
cenv.currentFn = f;
// Write function body
@@ -54,11 +53,9 @@ compile_fn(CEnv& cenv, const ATuple* fn) throw()
for (ATuple::const_iterator i = fn->iter_at(2); i != fn->end(); ++i)
retVal = resp_compile(cenv, *i);
- // Write function conclusion
+ // Write function conclusion and pop stack frame
cenv.engine()->finishFunction(cenv, f, retVal);
-
- // Pop environment frame
- cenv.pop();
+ cenv.pop();
cenv.currentFn = NULL;
cenv.vals.def(cenv.penv.sym(cenv.name(fn)), f);
@@ -84,7 +81,7 @@ compile_type(CEnv& cenv, const AType* type) throw()
static CVal
compile_call(CEnv& cenv, const ATuple* call) throw()
{
- CFunc f = resp_compile(cenv, *call->begin());
+ CFunc f = resp_compile(cenv, call->head());
if (!f)
f = cenv.currentFn; // Recursive call (callee defined as a stub)