cvsuser     04/11/25 03:15:37

  Modified:    ops      core.ops
               t/pmc    exception.t
  Log:
  new push_eh opcode
  
  Revision  Changes    Path
  1.377     +14 -1     parrot/ops/core.ops
  
  Index: core.ops
  ===================================================================
  RCS file: /cvs/public/parrot/ops/core.ops,v
  retrieving revision 1.376
  retrieving revision 1.377
  diff -u -r1.376 -r1.377
  --- core.ops  25 Nov 2004 09:28:01 -0000      1.376
  +++ core.ops  25 Nov 2004 11:15:20 -0000      1.377
  @@ -571,7 +571,13 @@
   
   =item B<set_eh>(in PMC)
   
  -Push the exception handler in $1 on the control stack.
  +Push the exception handler in $1 on the control stack. This opcode is
  +deprecrated. Please use B<push_eh>.
  +
  +=item B<push_eh>(labelconst INT)
  +
  +Create an exception handler for the given catch label and push it onto
  +the control stack.
   
   =item B<clear_eh>()
   
  @@ -602,6 +608,13 @@
     goto NEXT();
   }
   
  +inline op push_eh(labelconst INT) {
  +  PMC *eh = pmc_new(interpreter, enum_class_Exception_Handler);
  +  VTABLE_set_pointer(interpreter, eh, CUR_OPCODE + $1);
  +  push_exception(interpreter, eh);
  +  goto NEXT();
  +}
  +
   inline op clear_eh() {
     pop_exception(interpreter);
     goto NEXT();
  
  
  
  1.14      +18 -2     parrot/t/pmc/exception.t
  
  Index: exception.t
  ===================================================================
  RCS file: /cvs/public/parrot/t/pmc/exception.t,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- exception.t       15 Nov 2004 10:31:04 -0000      1.13
  +++ exception.t       25 Nov 2004 11:15:37 -0000      1.14
  @@ -1,6 +1,6 @@
   #! perl -w
   # Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -# $Id: exception.t,v 1.13 2004/11/15 10:31:04 leo Exp $
  +# $Id: exception.t,v 1.14 2004/11/25 11:15:37 leo Exp $
   
   =head1 NAME
   
  @@ -16,7 +16,7 @@
   
   =cut
   
  -use Parrot::Test tests => 23;
  +use Parrot::Test tests => 24;
   use Test::More;
   
   output_is(<<'CODE', <<'OUTPUT', "set_eh - clear_eh");
  @@ -566,5 +566,21 @@
   99
   OUTPUT
   
  +output_is(<<'CODE', <<'OUTPUT', "push_eh - throw");
  +    print "main\n"
  +    push_eh handler
  +    print "ok\n"
  +    new P30, .Exception
  +    throw P30
  +    print "not reached\n"
  +    end
  +handler:
  +    print "catched it\n"
  +    end
  +CODE
  +main
  +ok
  +catched it
  +OUTPUT
   1;
   
  
  
  

Reply via email to