summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2012-08-12 12:16:00 -0700
committerYukihiro "Matz" Matsumoto <[email protected]>2012-08-12 12:16:00 -0700
commit26a75d854b2b39469ed7b527ea646bca0b57a8f8 (patch)
treea3e1df38042eae7bfe52407516d58f5bd145aeb8
parent119b9f5bd5e03496af070c5dfeffa8c23e0a2c31 (diff)
parent686b6eb629d1694b620d9e36b7329efd7754b8c3 (diff)
downloadmruby-26a75d854b2b39469ed7b527ea646bca0b57a8f8.tar.gz
mruby-26a75d854b2b39469ed7b527ea646bca0b57a8f8.zip
Merge pull request #420 from masamitsu-murase/modify_exception_handling
Modify exception handling
-rw-r--r--src/vm.c6
-rw-r--r--test/t/exception.rb16
2 files changed, 22 insertions, 0 deletions
diff --git a/src/vm.c b/src/vm.c
index ac6dc9f1a..fa5a52d1f 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -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;
diff --git a/test/t/exception.rb b/test/t/exception.rb
index 0aed0e2e6..2ea319caa 100644
--- a/test/t/exception.rb
+++ b/test/t/exception.rb
@@ -253,3 +253,19 @@ assert('Exception 13') do
end
a == :ok
end
+
+def exception_test14
+ UnknownConstant
+end
+
+assert('Exception 14') do
+ a = :ng
+ begin
+ send(:exception_test14)
+ rescue
+ a = :ok
+ end
+
+ a == :ok
+end
+