fixing a small bug that missed some tail-recursion cases

This commit is contained in:
Alex Shinn 2009-11-22 18:14:46 +09:00
parent 3a47a903e8
commit bb251082f6
2 changed files with 4 additions and 1 deletions

1
eval.c
View file

@ -960,6 +960,7 @@ static void generate_general_app (sexp ctx, sexp app) {
emit(ctx, (tailp ? OP_TAIL_CALL : OP_CALL)); emit(ctx, (tailp ? OP_TAIL_CALL : OP_CALL));
emit_word(ctx, (sexp_uint_t)sexp_make_fixnum(len)); emit_word(ctx, (sexp_uint_t)sexp_make_fixnum(len));
sexp_context_tailp(ctx) = tailp;
sexp_context_depth(ctx) -= len; sexp_context_depth(ctx) -= len;
sexp_gc_release1(ctx); sexp_gc_release1(ctx);
} }

View file

@ -122,7 +122,9 @@
#f #f
((lambda (cl) ((lambda (cl)
(if (compare 'else (car cl)) (if (compare 'else (car cl))
(cons (rename 'begin) (cdr cl)) (if (pair? (cddr expr))
(error "non-final else in cond" expr)
(cons (rename 'begin) (cdr cl)))
(if (if (null? (cdr cl)) #t (compare '=> (cadr cl))) (if (if (null? (cdr cl)) #t (compare '=> (cadr cl)))
(list (list (rename 'lambda) (list (rename 'tmp)) (list (list (rename 'lambda) (list (rename 'tmp))
(list (rename 'if) (rename 'tmp) (list (rename 'if) (rename 'tmp)