1 | |
---|
2 | .include 'library/dumper.pir' |
---|
3 | |
---|
4 | .sub 'main' :main |
---|
5 | |
---|
6 | load_bytecode 'PGE.pbc' |
---|
7 | load_bytecode 'PCT.pbc' |
---|
8 | |
---|
9 | .local pmc block |
---|
10 | block = new ['PAST';'Block'] |
---|
11 | block.'init'( 'name' => 'foo' ) |
---|
12 | |
---|
13 | .local pmc stmts |
---|
14 | stmts = new ['PAST';'Stmts'] |
---|
15 | stmts.'init'() |
---|
16 | block.'push'(stmts) |
---|
17 | |
---|
18 | $P0 = new ['PAST';'Block'] |
---|
19 | |
---|
20 | $P1 = new ['PAST';'Op'] |
---|
21 | $P1.'init'( 'name' => 'push', 'pasttype' => 'callmethod') |
---|
22 | |
---|
23 | $P2 = new ['PAST';'Var'] |
---|
24 | $P2.'init'( 'scope' => 'package') |
---|
25 | push $P1, $P2 |
---|
26 | |
---|
27 | $I0 = 1 |
---|
28 | loop: |
---|
29 | if $I0 == 8 goto more |
---|
30 | |
---|
31 | $P3 = new ['PAST';'Val'] |
---|
32 | $P3.'init'( 'value' => $I0) |
---|
33 | push $P1, $P3 |
---|
34 | inc $I0 |
---|
35 | goto loop |
---|
36 | |
---|
37 | more: |
---|
38 | push $P0, $P1 |
---|
39 | |
---|
40 | stmts.'push'($P0) |
---|
41 | |
---|
42 | .local pmc astcompiler |
---|
43 | astcompiler = new [ 'PCT';'HLLCompiler' ] |
---|
44 | astcompiler.'removestage'('parse') |
---|
45 | astcompiler.'removestage'('past') |
---|
46 | |
---|
47 | _dumper(block, 'block') |
---|
48 | |
---|
49 | # compile to PIR and display |
---|
50 | $S99 = astcompiler.'compile'(block, 'target' => 'pir') |
---|
51 | print $S99 |
---|
52 | .end |
---|