diff options
author | David Robillard <d@drobilla.net> | 2009-06-27 00:09:30 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-06-27 00:09:30 +0000 |
commit | 9ba1ca23fb217c747117c5bbff3fcaac98f5f261 (patch) | |
tree | 6109fd74688af3c35fc6007bbcb19fde7bbb1c51 /cps.cpp | |
parent | 91d2737207d328647e1eb6c66ffca2dcc9277a46 (diff) | |
download | resp-9ba1ca23fb217c747117c5bbff3fcaac98f5f261.tar.gz resp-9ba1ca23fb217c747117c5bbff3fcaac98f5f261.tar.bz2 resp-9ba1ca23fb217c747117c5bbff3fcaac98f5f261.zip |
More CPS conversion work.
git-svn-id: http://svn.drobilla.net/resp/tuplr@151 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'cps.cpp')
-rw-r--r-- | cps.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -59,6 +59,9 @@ ACall::cps(TEnv& tenv, AST* cont) ASymbol* arg = NULL; // Make a continuation for each element (operator and arguments) + // Argument evaluation continuations are not themselves in CPS. + // Each makes a tail call to the next, and the last makes a tail + // call to the continuation of this call ssize_t firstFn = -1; ssize_t lastFn = -1; for (size_t i = 0; i < size(); ++i) { @@ -71,7 +74,7 @@ ACall::cps(TEnv& tenv, AST* cont) firstFn = i; AFn* thisFn = tup<AFn>(loc, tenv.penv.sym("fn"), - tup<ATuple>(at(i)->loc, arg, tenv.penv.gensym("_k"), 0), + tup<ATuple>(at(i)->loc, arg, 0), 0); if (lastFn != -1) @@ -84,18 +87,14 @@ ACall::cps(TEnv& tenv, AST* cont) } if (firstFn != -1) { - // Call our callee in the last argument's evaluation function + // Call this call's callee in the last argument evaluator ACall* call = tup<ACall>(loc, 0); assert(funcs.size() == size()); for (size_t i = 0; i < funcs.size(); ++i) call->push_back(funcs[i].second); - if (!to<APrimitive*>()) - call->push_back(cont); - else - call = tup<ACall>(loc, cont, call, 0); assert(fn); - fn->push_back(call); + fn->push_back(call->cps(tenv, cont)); return at(firstFn)->cps(tenv, funcs[firstFn].first); } else { assert(at(0)->value()); |