Ticket #1635: handler.pir

File handler.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  $I0 = set_addr after
25
26  # Use exception handler
27  #eh.'rewind'($I0)
28  # Use exception
29  ex.'rewind'($I0)
30
31  say 'Never'
32after:
33  say 'Bye'
34  .return()
35.end
36
37.namespace [ 'Foo' ]
38
39.sub th :method
40  die 'From method'
41.end
42
43.sub increment :vtable
44  die 'From vtable'
45.end