diff options
author | Teddy <ted.sybil@gmail.com> | 2013-08-15 11:04:57 +0800 |
---|---|---|
committer | Teddy <ted.sybil@gmail.com> | 2013-08-15 11:04:57 +0800 |
commit | 9f9bd0ee34422aceb9725276292a66b0e7934c6a (patch) | |
tree | 4e9044237f3b7004b3b8598fe2c53546ab29dc25 /types.cpp | |
parent | 06d014cb0e95f92945ea01610fd1c52a1b087502 (diff) |
tail-rec for `if` and `and`
Diffstat (limited to 'types.cpp')
-rw-r--r-- | types.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -88,17 +88,16 @@ Pair *ProcObj::call(Pair *_args, Environment * &lenvt, { gc.expose(*top_ptr); *top_ptr++ = gc.attach(TO_PAIR(_args->cdr)->car); - EXIT_CURRENT_EXEC(lenvt, cont); // exit cont and envt - gc.expose(_args); + EXIT_CURRENT_EXEC(lenvt, cont, _args); // exit cont and envt return ret_addr->next; } else { if (nexp->cdr == empty_list && !nexp->car->is_simple_obj()) // tail recursion opt { - cont->tail = true; - cont->state = NULL; - top_ptr++; // revert the cont + cont->tail = true; + cont->state = NULL; + top_ptr++; // revert the cont } else { @@ -311,8 +310,7 @@ BuiltinProcObj::BuiltinProcObj(BuiltinProc f, string _name) : Pair *ret_addr = cont->pc; gc.expose(*top_ptr); *top_ptr++ = gc.attach(handler(TO_PAIR(args->cdr), name)); - EXIT_CURRENT_EXEC(lenvt, cont); - gc.expose(args); + EXIT_CURRENT_EXEC(lenvt, cont, args); return ret_addr->next; // Move to the next instruction } |