Created
August 2, 2011 16:54
-
-
Save anonymous/1120645 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pmichaud@kiwi:~/nom$ cat z.pir | |
.include 'except_types.pasm' | |
.include 'except_severity.pasm' | |
.sub 'main' :main | |
$P0 = new ['ExceptionHandler'] | |
set_label $P0, handler1 | |
$P0.'handle_types_except'(.CONTROL_LOOP_NEXT) | |
push_eh $P0 | |
$P0 = new ['ExceptionHandler'] | |
set_label $P0, handler2 | |
$P0.'handle_types_except'(.CONTROL_ERROR) | |
push_eh $P0 | |
'a'() | |
'a'() | |
.return (0) | |
handler1: | |
.local pmc exception | |
.get_results (exception) | |
say 'handler1 caught exception' | |
pop_eh | |
$P0 = getattribute exception, 'resume' | |
say 'resuming after exception' | |
$P0() | |
handler2: | |
.get_results (exception) | |
say 'handler2 caught exception' | |
pop_eh | |
$P0 = getattribute exception, 'resume' | |
say 'resuming after exception' | |
$P0() | |
.end | |
.sub 'a' | |
say "In subroutine 'a'" | |
die "first exception" | |
say "resumed 'a' after first exception" | |
die .EXCEPT_NORMAL, .CONTROL_LOOP_NEXT | |
say "resumed 'a' after second exception" | |
say "leaving 'a'" | |
.end | |
pmichaud@kiwi:~/nom$ install/bin/parrot z.pir | |
In subroutine 'a' | |
handler1 caught exception | |
resuming after exception | |
resumed 'a' after first exception | |
Warning | |
No exception handler and no message | |
current instr.: 'a' pc 101 (z.pir:42) | |
called from Sub 'main' pc 72 (z.pir:26) | |
pmichaud@kiwi:~/nom$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment