mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
Adding sexp_apply_no_err_handler utility and using in simplifier.
This commit is contained in:
parent
4d0daf5df4
commit
c0b9a213c9
3 changed files with 23 additions and 1 deletions
|
@ -1420,6 +1420,7 @@ SEXP_API sexp sexp_stack_trace_op (sexp ctx, sexp self, sexp_sint_t n, sexp out)
|
||||||
SEXP_API sexp sexp_apply (sexp context, sexp proc, sexp args);
|
SEXP_API sexp sexp_apply (sexp context, sexp proc, sexp args);
|
||||||
SEXP_API sexp sexp_apply1 (sexp ctx, sexp f, sexp x);
|
SEXP_API sexp sexp_apply1 (sexp ctx, sexp f, sexp x);
|
||||||
SEXP_API sexp sexp_apply2 (sexp ctx, sexp f, sexp x, sexp y);
|
SEXP_API sexp sexp_apply2 (sexp ctx, sexp f, sexp x, sexp y);
|
||||||
|
SEXP_API sexp sexp_apply_no_err_handler (sexp ctx, sexp proc, sexp args);
|
||||||
SEXP_API sexp sexp_make_trampoline (sexp ctx, sexp proc, sexp args);
|
SEXP_API sexp sexp_make_trampoline (sexp ctx, sexp proc, sexp args);
|
||||||
SEXP_API sexp sexp_make_foreign (sexp ctx, const char *name, int num_args, int flags, sexp_proc1 f, sexp data);
|
SEXP_API sexp sexp_make_foreign (sexp ctx, const char *name, int num_args, int flags, sexp_proc1 f, sexp data);
|
||||||
SEXP_API void sexp_init(void);
|
SEXP_API void sexp_init(void);
|
||||||
|
|
|
@ -51,7 +51,7 @@ static sexp simplify (sexp ctx, sexp ast, sexp init_substs, sexp lambda) {
|
||||||
tmp = sexp_make_vector(ctx2, 0, SEXP_VOID);
|
tmp = sexp_make_vector(ctx2, 0, SEXP_VOID);
|
||||||
tmp = sexp_make_procedure(ctx2, SEXP_ZERO, SEXP_ZERO, res, tmp);
|
tmp = sexp_make_procedure(ctx2, SEXP_ZERO, SEXP_ZERO, res, tmp);
|
||||||
if (! sexp_exceptionp(tmp)) {
|
if (! sexp_exceptionp(tmp)) {
|
||||||
tmp = sexp_apply(ctx2, tmp, SEXP_NULL);
|
tmp = sexp_apply_no_err_handler(ctx2, tmp, SEXP_NULL);
|
||||||
if (! sexp_exceptionp(tmp))
|
if (! sexp_exceptionp(tmp))
|
||||||
app = sexp_make_lit(ctx2, tmp);
|
app = sexp_make_lit(ctx2, tmp);
|
||||||
}
|
}
|
||||||
|
|
21
vm.c
21
vm.c
|
@ -2136,4 +2136,25 @@ sexp sexp_apply2 (sexp ctx, sexp f, sexp x, sexp y) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sexp sexp_apply_no_err_handler (sexp ctx, sexp proc, sexp args) {
|
||||||
|
sexp res, err_cell;
|
||||||
|
sexp_gc_var2(handler, params);
|
||||||
|
sexp_gc_preserve2(ctx, handler, params);
|
||||||
|
#if SEXP_USE_GREEN_THREADS
|
||||||
|
params = sexp_context_params(ctx);
|
||||||
|
sexp_context_params(ctx) = SEXP_NULL;
|
||||||
|
#endif
|
||||||
|
err_cell = sexp_global(ctx, SEXP_G_ERR_HANDLER);
|
||||||
|
err_cell = sexp_opcodep(err_cell) ? sexp_opcode_data(err_cell) : SEXP_FALSE;
|
||||||
|
handler = sexp_pairp(err_cell) ? sexp_cdr(err_cell) : SEXP_FALSE;
|
||||||
|
if (sexp_pairp(err_cell)) sexp_cdr(err_cell) = SEXP_FALSE;
|
||||||
|
res = sexp_apply(ctx, proc, args);
|
||||||
|
if (sexp_pairp(err_cell)) sexp_cdr(err_cell) = handler;
|
||||||
|
#if SEXP_USE_GREEN_THREADS
|
||||||
|
sexp_context_params(ctx) = params;
|
||||||
|
#endif
|
||||||
|
sexp_gc_release2(ctx);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue