diff options
| author | Masamitsu MURASE <[email protected]> | 2012-08-13 01:49:50 +0900 |
|---|---|---|
| committer | Masamitsu MURASE <[email protected]> | 2012-08-13 01:49:50 +0900 |
| commit | 87ba67f42d36ca001298644c2e4f2f3a26d5c40b (patch) | |
| tree | 1b1dba47ee08a7b6048a9aaeb415637535c4337f | |
| parent | 119b9f5bd5e03496af070c5dfeffa8c23e0a2c31 (diff) | |
| download | mruby-87ba67f42d36ca001298644c2e4f2f3a26d5c40b.tar.gz mruby-87ba67f42d36ca001298644c2e4f2f3a26d5c40b.zip | |
Modify exception handling.
If an exception is raised before cipush is called in mrb_run,
it should be handled in the outer mrb_run.
| -rw-r--r-- | src/vm.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -20,6 +20,7 @@ #include <stdio.h> #include <string.h> #include <setjmp.h> +#include <stddef.h> #define STACK_INIT_SIZE 128 #define CALLINFO_INIT_SIZE 32 @@ -402,6 +403,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self) int ai = mrb->arena_idx; jmp_buf *prev_jmp = (jmp_buf *)mrb->jmp; jmp_buf c_jmp; + ptrdiff_t ciidx = mrb->ci - mrb->cibase; #ifdef DIRECT_THREADED static void *optable[] = { @@ -1028,6 +1030,10 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self) ci = mrb->ci; eidx = mrb->ci->eidx; if (ci == mrb->cibase) goto L_STOP; + if (ciidx == ci - mrb->cibase){ + mrb->jmp = prev_jmp; + longjmp(*(jmp_buf*)mrb->jmp, 1); + } while (ci[0].ridx == ci[-1].ridx) { cipop(mrb); ci = mrb->ci; |
