Ticket #1378: interp_iglobals.pir

File interp_iglobals.pir, 443 bytes (added by cotto, 5 years ago)

example of how to use (and misuse) the above patch

Line 
1.sub main :main
2    .local pmc interp
3
4    interp = getinterp
5    $P0 = interp['iglobals']
6    $P1 = $P0['classname_hash']
7    $I0 = $P1
8    say $I0
9
10    .local pmc it
11
12    it = iter $P1
13  iter_start:
14    unless it goto iter_end
15    $S0 = shift it
16    print "key is "
17    print $S0
18    $S1 = $P1[$S0]
19    print ", value is "
20    say $S1
21    goto iter_start
22  iter_end:
23    noop
24
25    #try to modify the read-only hash
26    $P1['foo'] = 234
27.end