Commit 26a75d85 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #420 from masamitsu-murase/modify_exception_handling

Modify exception handling
parents 119b9f5b 686b6eb6
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <setjmp.h> #include <setjmp.h>
#include <stddef.h>
#define STACK_INIT_SIZE 128 #define STACK_INIT_SIZE 128
#define CALLINFO_INIT_SIZE 32 #define CALLINFO_INIT_SIZE 32
...@@ -402,6 +403,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self) ...@@ -402,6 +403,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
int ai = mrb->arena_idx; int ai = mrb->arena_idx;
jmp_buf *prev_jmp = (jmp_buf *)mrb->jmp; jmp_buf *prev_jmp = (jmp_buf *)mrb->jmp;
jmp_buf c_jmp; jmp_buf c_jmp;
ptrdiff_t ciidx = mrb->ci - mrb->cibase;
#ifdef DIRECT_THREADED #ifdef DIRECT_THREADED
static void *optable[] = { static void *optable[] = {
...@@ -1028,6 +1030,10 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self) ...@@ -1028,6 +1030,10 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
ci = mrb->ci; ci = mrb->ci;
eidx = mrb->ci->eidx; eidx = mrb->ci->eidx;
if (ci == mrb->cibase) goto L_STOP; 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) { while (ci[0].ridx == ci[-1].ridx) {
cipop(mrb); cipop(mrb);
ci = mrb->ci; ci = mrb->ci;
......
...@@ -253,3 +253,19 @@ assert('Exception 13') do ...@@ -253,3 +253,19 @@ assert('Exception 13') do
end end
a == :ok a == :ok
end end
def exception_test14
UnknownConstant
end
assert('Exception 14') do
a = :ng
begin
send(:exception_test14)
rescue
a = :ok
end
a == :ok
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment