Permalink
Browse files

fixing more exceptions bugs

  • Loading branch information...
1 parent 213079a commit 7c968bd07d5ecdc0cd864ffdeb900142898287b2 @lrz lrz committed May 12, 2009
Showing with 39 additions and 13 deletions.
  1. +18 −6 roxor.cpp
  2. +1 −0 roxor.h
  3. +19 −6 test_vm/exception.rb
  4. +1 −1 vm_eval.c
View
@@ -8720,17 +8720,29 @@ rb_iseq_new(NODE *node, VALUE filename)
return Qnil;
}
+static inline void
+__vm_raise(void)
+{
+ void *exc = __cxa_allocate_exception(0);
+ __cxa_throw(exc, NULL, NULL);
+}
+
+extern "C"
+void
+rb_vm_raise_current_exception(void)
+{
+ assert(GET_VM()->current_exception() != Qnil);
+ __vm_raise();
+}
+
extern "C"
void
rb_vm_raise(VALUE exception)
{
rb_iv_set(exception, "bt", rb_vm_backtrace(100));
- if (exception != GET_VM()->current_exception()) {
- rb_objc_retain((void *)exception);
- GET_VM()->push_current_exception(exception);
- }
- void *exc = __cxa_allocate_exception(0);
- __cxa_throw(exc, NULL, NULL);
+ rb_objc_retain((void *)exception);
+ GET_VM()->push_current_exception(exception);
+ __vm_raise();
}
extern "C"
View
@@ -178,6 +178,7 @@ rb_robject_allocate_instance(VALUE klass)
}
void rb_vm_raise(VALUE exception);
+void rb_vm_raise_current_exception(void);
VALUE rb_vm_current_exception(void);
void rb_vm_set_current_exception(VALUE exception);
VALUE rb_vm_backtrace(int level);
View
@@ -167,15 +167,15 @@ def foo
begin
raise e
rescue
- p :ok if $! == e
+ p :ok if $!.eql?(e)
end
}
assert ':ok', %{
begin
raise 'foo'
rescue => e
- p :ok if $! == e
+ p :ok if $!.eql?(e)
end
}
@@ -192,11 +192,11 @@ def foo
begin
raise e3
rescue
- p :ok if $! == e3
+ p :ok if $!.eql?(e3)
end
- p :ok if $! == e2
+ p :ok if $!.eql?(e2)
end
- p :ok if $! == e1
+ p :ok if $!.eql?(e1)
end
}
@@ -208,7 +208,7 @@ def foo
x += 1
raise e
rescue
- p :ok if $! == e
+ p :ok if $!.eql?(e)
retry if x < 2
end
}
@@ -220,3 +220,16 @@ def foo
end
p :ok if $!.nil?
}
+
+assert ":ok", %{
+ e = RuntimeError.new('foo')
+ begin
+ raise e
+ rescue
+ begin
+ raise
+ rescue => e2
+ p :ok if e.eql?(e2)
+ end
+ end
+}
View
@@ -343,7 +343,7 @@ eval_string(VALUE self, VALUE klass, VALUE src, VALUE scope, const char *file,
if (node == NULL) {
VALUE exc = rb_vm_current_exception();
if (exc != Qnil) {
- rb_exc_raise(exc);
+ rb_vm_raise_current_exception();
}
else {
rb_raise(rb_eSyntaxError, "compile error");

0 comments on commit 7c968bd

Please sign in to comment.