[macruby-changes] [1567] MacRuby/branches/experimental

source_changes at macosforge.org source_changes at macosforge.org
Mon May 11 18:27:24 PDT 2009


Revision: 1567
          http://trac.macosforge.org/projects/ruby/changeset/1567
Author:   lsansonetti at apple.com
Date:     2009-05-11 18:27:24 -0700 (Mon, 11 May 2009)
Log Message:
-----------
fixing more exceptions bugs

Modified Paths:
--------------
    MacRuby/branches/experimental/roxor.cpp
    MacRuby/branches/experimental/roxor.h
    MacRuby/branches/experimental/test_vm/exception.rb
    MacRuby/branches/experimental/vm_eval.c

Modified: MacRuby/branches/experimental/roxor.cpp
===================================================================
--- MacRuby/branches/experimental/roxor.cpp	2009-05-12 00:47:06 UTC (rev 1566)
+++ MacRuby/branches/experimental/roxor.cpp	2009-05-12 01:27:24 UTC (rev 1567)
@@ -8720,17 +8720,29 @@
     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"

Modified: MacRuby/branches/experimental/roxor.h
===================================================================
--- MacRuby/branches/experimental/roxor.h	2009-05-12 00:47:06 UTC (rev 1566)
+++ MacRuby/branches/experimental/roxor.h	2009-05-12 01:27:24 UTC (rev 1567)
@@ -178,6 +178,7 @@
 }
 
 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);

Modified: MacRuby/branches/experimental/test_vm/exception.rb
===================================================================
--- MacRuby/branches/experimental/test_vm/exception.rb	2009-05-12 00:47:06 UTC (rev 1566)
+++ MacRuby/branches/experimental/test_vm/exception.rb	2009-05-12 01:27:24 UTC (rev 1567)
@@ -167,7 +167,7 @@
   begin
     raise e
   rescue
-    p :ok if $! == e
+    p :ok if $!.eql?(e)
   end
 }
 
@@ -175,7 +175,7 @@
   begin
     raise 'foo'
   rescue => e
-    p :ok if $! == e
+    p :ok if $!.eql?(e)
   end
 }
 
@@ -192,11 +192,11 @@
       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 @@
     x += 1
     raise e
   rescue
-    p :ok if $! == e
+    p :ok if $!.eql?(e)
     retry if x < 2
   end
 }
@@ -220,3 +220,16 @@
   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
+}

Modified: MacRuby/branches/experimental/vm_eval.c
===================================================================
--- MacRuby/branches/experimental/vm_eval.c	2009-05-12 00:47:06 UTC (rev 1566)
+++ MacRuby/branches/experimental/vm_eval.c	2009-05-12 01:27:24 UTC (rev 1567)
@@ -343,7 +343,7 @@
     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");
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090511/2efbc0bc/attachment-0001.html>


More information about the macruby-changes mailing list