* lib/Parrot/Pmc2c/MethodEmitter.pm:
[parrot.git] / languages / forth / variablestack.pir
blob170ba497626c0b4ca4883e3cc7b1cbab435a6cfa
2 .HLL 'Forth', ''
3 .namespace ['VariableStack']
5 .sub init :anon :load
6     .local pmc class
7     class = newclass 'VariableStack'
9     addattribute class, '@stack'
10     addattribute class, '$next'
11 .end
13 .sub init :vtable :method
14     .local pmc stack, cell
15     stack = new .ResizableIntegerArray
16     cell  = new 'Integer'
17     cell  = 0
19     setattribute self, '@stack', stack
20     setattribute self, '$next',  cell
21 .end
23 .sub get_integer :vtable :method
24     .local pmc next
25     next = getattribute self, '$next'
26     $I0  = next
27     inc next
28     .return($I0)
29 .end
31 .sub get_pmc_keyed_int :vtable :method
32     .param int key
33     .local pmc stack
34     stack = getattribute self, '@stack'
36     $P0 = stack[key]
37     .return($P0)
38 .end
40 .sub set_pmc_keyed_int :vtable :method
41     .param int key
42     .param pmc value
44     .local pmc stack
45     stack = getattribute self, '@stack'
46     stack[key] = value
47 .end
49 # Local Variables:
50 #   mode: pir
51 #   fill-column: 100
52 # End:
53 # vim: expandtab shiftwidth=4 ft=pir: