Ticket #556: test.pir

File test.pir, 0.6 KB (added by bsdz, 5 years ago)

Example pir code demonstrating bug.

Line 
1.include 'library/dumper.pir'
2
3.namespace [ 'MyRPA' ]
4.sub '__dump' :method
5    .param pmc dumper
6    .param pmc label
7    dumper.'genericArray'(label, self)
8.end
9
10.namespace []
11.sub '' :main
12
13    $P0 = subclass 'ResizablePMCArray', 'MyRPA'
14
15    $P1 = new 'ResizablePMCArray'
16    'pass_by_ref'($P1)
17    _dumper($P1, 'RPA after')
18   
19    $P2 = new 'MyRPA'
20    'pass_by_ref'($P2)
21    _dumper($P2, 'MyRPA after')
22   
23.end
24
25.sub 'pass_by_ref'
26    .param pmc p
27    p[0] = 'hello'
28    _dumper(p, 'before setref')
29    setref p, p   
30.end