diff options
author | David Robillard <d@drobilla.net> | 2011-05-14 07:07:49 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-05-14 07:07:49 +0000 |
commit | 5ca391c314ccef39597a5c412a27772f86e11889 (patch) | |
tree | f8bef0f1192ebbf97f38c6949ad4d7bae12a2e72 /src/compile.cpp | |
parent | 6cbeccf2ca0df91e5b71ccdbfcf412535f0c1179 (diff) | |
download | resp-5ca391c314ccef39597a5c412a27772f86e11889.tar.gz resp-5ca391c314ccef39597a5c412a27772f86e11889.tar.bz2 resp-5ca391c314ccef39597a5c412a27772f86e11889.zip |
Make currentFn private to the backend.
git-svn-id: http://svn.drobilla.net/resp/trunk@421 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/compile.cpp')
-rw-r--r-- | src/compile.cpp | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/src/compile.cpp b/src/compile.cpp index 1f82a47..1534263 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -53,14 +53,6 @@ compile_literal_symbol(CEnv& cenv, const ASymbol* sym) throw() } static CVal -compile_cast(CEnv& cenv, const ATuple* cast) throw() -{ - return cenv.engine()->compileCast(cenv, - resp_compile(cenv, cast->frst()), - cenv.type(cast)); -} - -static CVal compile_type(CEnv& cenv, const AST* type) throw() { return compile_literal_symbol(cenv, type->as_tuple()->fst()->as_symbol()); @@ -137,22 +129,18 @@ static CVal compile_call(CEnv& cenv, const ATuple* call) throw() { const ATuple* protT = cenv.type(call->fst())->as_tuple()->prot(); - CFunc f = resp_compile(cenv, call->fst()); - - if (!f) - f = cenv.currentFn; // Recursive call (callee defined as a stub) + CFunc f = resp_compile(cenv, call->fst()); vector<CVal> args; ATuple::const_iterator t = protT->iter_at(0); for (ATuple::const_iterator e = call->iter_at(1); e != call->end(); ++e, ++t) { CVal arg = resp_compile(cenv, *e); - if ((*e)->to_symbol()) { - if (cenv.type(*e) != cenv.type(*t)) { - args.push_back(cenv.engine()->compileCast(cenv, arg, *t)); - continue; - } + if ((*e)->to_symbol() && (cenv.type(*e) != cenv.type(*t))) { + + args.push_back(cenv.engine()->compileCast(cenv, arg, *t)); + } else { + args.push_back(arg); } - args.push_back(arg); } return cenv.engine()->compileCall(cenv, f, cenv.type(call->fst())->as_tuple(), args); @@ -169,7 +157,6 @@ compile_fn_start(CEnv& cenv, const ATuple* call) throw() cenv.def(name, NULL, type, func); cenv.engine()->pushFnArgs(cenv, args, type, func); - cenv.currentFn = func; return NULL; } @@ -178,11 +165,8 @@ static CVal compile_fn_end(CEnv& cenv, const ATuple* call) throw() { const AST* retT = cenv.type(call->frst())->as_tuple()->frrst(); - cenv.engine()->finishFn(cenv, cenv.currentFn, - resp_compile(cenv, call->frrst()), - retT); + cenv.engine()->finishFn(cenv, resp_compile(cenv, call->frrst()), retT); cenv.pop(); - cenv.currentFn = NULL; return NULL; } @@ -214,7 +198,9 @@ resp_compile(CEnv& cenv, const AST* ast) throw() if (is_primitive(cenv.penv, call)) return cenv.engine()->compilePrimitive(cenv, ast->as_tuple()); else if (form == "cast") - return compile_cast(cenv, call); + return cenv.engine()->compileCast(cenv, + resp_compile(cenv, call->frst()), + cenv.type(call)); else if (form == "cons" || isupper(form[0])) return compile_cons(cenv, call); else if (form == ".") |