[svn:parrot] r47425 - in trunk: include/parrot src/ops t/op

pmichaud at svn.parrot.org pmichaud at svn.parrot.org
Sun Jun 6 07:57:55 UTC 2010


Author: pmichaud
Date: Sun Jun  6 07:57:55 2010
New Revision: 47425
URL: https://trac.parrot.org/parrot/changeset/47425

Log:
[core]: The argument to the 'exit' opcode shouldn't be the exception type.
This patch adds a new CONTROL_EXIT exception type for exit exceptions and uses
that for the 'exit' opcode.

Modified:
   trunk/include/parrot/exceptions.h
   trunk/src/ops/core.ops
   trunk/src/ops/core_ops.c
   trunk/t/op/exit.t

Modified: trunk/include/parrot/exceptions.h
==============================================================================
--- trunk/include/parrot/exceptions.h	Sun Jun  6 07:57:48 2010	(r47424)
+++ trunk/include/parrot/exceptions.h	Sun Jun  6 07:57:55 2010	(r47425)
@@ -90,6 +90,7 @@
     CONTROL_ERROR,
     CONTROL_TAKE,
     CONTROL_LEAVE,
+    CONTROL_EXIT,
 
     CONTROL_LOOP_NEXT,
     CONTROL_LOOP_LAST,

Modified: trunk/src/ops/core.ops
==============================================================================
--- trunk/src/ops/core.ops	Sun Jun  6 07:57:48 2010	(r47424)
+++ trunk/src/ops/core.ops	Sun Jun  6 07:57:55 2010	(r47425)
@@ -823,7 +823,8 @@
     opcode_t        *dest;
     opcode_t * const ret       = expr NEXT();
     PMC      * const resume    = pmc_new(interp, enum_class_Continuation);
-    PMC      * const exception = Parrot_ex_build_exception(interp, EXCEPT_exit, $1, NULL);
+    PMC      * const exception = Parrot_ex_build_exception(interp, EXCEPT_exit, 
+                                                           CONTROL_EXIT, NULL);
 
     VTABLE_set_pointer(interp, resume, ret);
 

Modified: trunk/src/ops/core_ops.c
==============================================================================
--- trunk/src/ops/core_ops.c	Sun Jun  6 07:57:48 2010	(r47424)
+++ trunk/src/ops/core_ops.c	Sun Jun  6 07:57:55 2010	(r47425)
@@ -14796,7 +14796,8 @@
     opcode_t        *dest;
     opcode_t * const ret       =cur_opcode + 2;
     PMC      * const resume    = pmc_new(interp, enum_class_Continuation);
-    PMC      * const exception = Parrot_ex_build_exception(interp, EXCEPT_exit, IREG(1), NULL);
+    PMC      * const exception = Parrot_ex_build_exception(interp, EXCEPT_exit, 
+                                                           CONTROL_EXIT, NULL);
 
     VTABLE_set_pointer(interp, resume, ret);
 
@@ -14813,7 +14814,8 @@
     opcode_t        *dest;
     opcode_t * const ret       =cur_opcode + 2;
     PMC      * const resume    = pmc_new(interp, enum_class_Continuation);
-    PMC      * const exception = Parrot_ex_build_exception(interp, EXCEPT_exit, cur_opcode[1], NULL);
+    PMC      * const exception = Parrot_ex_build_exception(interp, EXCEPT_exit, 
+                                                           CONTROL_EXIT, NULL);
 
     VTABLE_set_pointer(interp, resume, ret);
 

Modified: trunk/t/op/exit.t
==============================================================================
--- trunk/t/op/exit.t	Sun Jun  6 07:57:48 2010	(r47424)
+++ trunk/t/op/exit.t	Sun Jun  6 07:57:55 2010	(r47425)
@@ -7,7 +7,7 @@
 use lib qw( . lib ../lib ../../lib );
 
 use Test::More;
-use Parrot::Test tests => 7;
+use Parrot::Test tests => 8;
 
 =head1 NAME
 
@@ -65,6 +65,20 @@
     pbc_exit_code_is($pbc, 0, 'pbc exits with 0 by default');
 }
 
+pir_exit_code_is( <<'CODE', 2, "pir exit code isn't exception type" );
+.sub main
+    $P0 = new ['ExceptionHandler']
+    set_addr $P0, catcher
+    $P0.'handle_types'(2)
+    push_eh $P0
+    exit 2
+  catcher:
+    # we shouldn't arrive here
+    pop_eh
+    exit 10
+.end
+CODE
+
 # Local Variables:
 #   mode: cperl
 #   cperl-indent-level: 4


More information about the parrot-commits mailing list