[svn:parrot] r44555 - in branches/exceptions_refactor/src: . pmc

tene at svn.parrot.org tene at svn.parrot.org
Mon Mar 1 05:15:05 UTC 2010


Author: tene
Date: Mon Mar  1 05:15:02 2010
New Revision: 44555
URL: https://trac.parrot.org/parrot/changeset/44555

Log:
Allow rethrown subclassed exceptions to find the next handler.
Add infrastructure to filter based on exception types.

Modified:
   branches/exceptions_refactor/src/pmc/exceptionhandler.pmc
   branches/exceptions_refactor/src/scheduler.c

Modified: branches/exceptions_refactor/src/pmc/exceptionhandler.pmc
==============================================================================
--- branches/exceptions_refactor/src/pmc/exceptionhandler.pmc	Mon Mar  1 04:01:34 2010	(r44554)
+++ branches/exceptions_refactor/src/pmc/exceptionhandler.pmc	Mon Mar  1 05:15:02 2010	(r44555)
@@ -26,6 +26,8 @@
 
     ATTR PMC    *handled_types;
     ATTR PMC    *handled_types_except;
+    ATTR PMC    *handled_classes;
+    ATTR PMC    *handled_classes_except;
     ATTR INTVAL min_severity;
     ATTR INTVAL max_severity;
 
@@ -47,6 +49,8 @@
         attrs->max_severity         = 0;
         attrs->handled_types        = PMCNULL;
         attrs->handled_types_except = PMCNULL;
+        attrs->handled_classes        = PMCNULL;
+        attrs->handled_classes_except = PMCNULL;
 
         /* an exception handler has no separate context; it's only a snapshot
          * of an "earlier" context, which is contained in the interpreter's
@@ -70,6 +74,8 @@
             PARROT_EXCEPTIONHANDLER(SELF);
         Parrot_gc_mark_PMC_alive(interp, attrs->handled_types);
         Parrot_gc_mark_PMC_alive(interp, attrs->handled_types_except);
+        Parrot_gc_mark_PMC_alive(interp, attrs->handled_classes);
+        Parrot_gc_mark_PMC_alive(interp, attrs->handled_classes_except);
         SUPER();
     }
 
@@ -296,6 +302,44 @@
                 : PMCNULL;
     }
 
+/*
+
+=item C<METHOD handle_classes(PMC *classes :slurpy)>
+
+Set the exception classes that the ExceptionHandler will handle.
+
+=cut
+
+*/
+
+    METHOD handle_classes(PMC *classes :slurpy) {
+        Parrot_ExceptionHandler_attributes * const attrs =
+                    PARROT_EXCEPTIONHANDLER(SELF);
+        attrs->handled_classes =
+            VTABLE_elements(interp, classes) > 0
+                ? classes
+                : PMCNULL;
+    }
+
+/*
+
+=item C<METHOD handle_classes_except(PMC *classes :slurpy)>
+
+Set the exception classes that the ExceptionHandler will not handle.
+
+=cut
+
+*/
+
+    METHOD handle_classes_except(PMC *classes :slurpy) {
+        Parrot_ExceptionHandler_attributes * const attrs =
+                    PARROT_EXCEPTIONHANDLER(SELF);
+        attrs->handled_classes_except =
+            VTABLE_elements(interp, classes) > 0
+                ? classes
+                : PMCNULL;
+    }
+
 }
 
 /*

Modified: branches/exceptions_refactor/src/scheduler.c
==============================================================================
--- branches/exceptions_refactor/src/scheduler.c	Mon Mar  1 04:01:34 2010	(r44554)
+++ branches/exceptions_refactor/src/scheduler.c	Mon Mar  1 05:15:02 2010	(r44555)
@@ -856,6 +856,7 @@
     PMC            *iter        = PMCNULL;
     STRING * const  handled_str = CONST_STRING(interp, "handled");
     STRING * const  iter_str    = CONST_STRING(interp, "handler_iter");
+    STRING * const  ex_str      = CONST_STRING(interp, "Exception");
 
     if (already_doing) {
         Parrot_io_eprintf(interp,
@@ -878,7 +879,7 @@
 
         /* Exceptions store the handler iterator for rethrow, other kinds of
          * tasks don't (though they could). */
-        if (task->vtable->base_type == enum_class_Exception
+        if (VTABLE_isa(interp, task, ex_str)
         && VTABLE_get_integer_keyed_str(interp, task, handled_str) == -1) {
             iter    = VTABLE_get_attr_str(interp, task, iter_str);
             context = (PMC *)VTABLE_get_pointer(interp, task);


More information about the parrot-commits mailing list