Ticket #1635: unroll.pir

File unroll.pir, 0.6 KB (added by NotFound, 5 years ago)
Line 
1.sub main :main
2  .local pmc eh, ex
3  eh = new 'ExceptionHandler'
4  set_addr eh, here
5  push_eh eh
6
7  $P0 = newclass ['Foo']
8  $P1 = new $P0
9  say 'Before'
10
11  # Throw from vtable override
12  inc $P1
13  # Throw from pir method
14  #$P1.'th'()
15
16  say 'Never'
17  .return()
18here:
19  .get_results(ex)
20  $S0 = ex['message']
21  print '"'
22  print $S0
23  say '" caught!'
24
25  # Use exception handler
26  # unroll eh
27  # Use exception
28  unroll ex
29  say 'Bye'
30  .return()
31.end
32
33.namespace [ 'Foo' ]
34
35.sub th :method
36  die 'From method'
37.end
38
39.sub increment :vtable
40  die 'From vtable'
41.end