1 # Copyright (C) 2007-2008, The Perl Foundation.
6 examples/past/blocktype_immediate.pir - Evaluating a PAST::Block immediately
10 % ./parrot examples/past/blocktype_immediate.pir
14 Create and evaluate a PAST::Block with blocktype 'immediate'.
15 'immediate' means the the block is evaluated end the last value
18 Beware that this doesn't work yet as expected:
20 '_block10' isn't a closure (no :outer)
21 current instr.: 'anon' pc 3 (EVAL_1:5)
22 called from Sub 'parrot;PCT::HLLCompiler;eval' pc 609 (src/HLLCompiler.pir:368)
23 called from Sub 'main' pc 70 (examples/past/blocktype_immediate.pir:52)
27 F<docs/pdds/pdd26_ast.pod>
34 load_bytecode 'PGE.pbc'
35 load_bytecode 'PGE/Text.pbc'
36 load_bytecode 'PGE/Util.pbc'
37 load_bytecode 'PGE/Dumper.pbc'
38 load_bytecode 'PCT.pbc'
43 # content of the block
45 val_x = new 'PAST::Val'
46 val_x.init( 'value' => '-536870912', 'returns' => 'Integer' )
48 # wrap the content in a block
50 var_block = new 'PAST::Block'
51 var_block.init( val_x, 'blocktype' => 'immediate' )
54 .local pmc astcompiler
55 astcompiler = new [ 'PCT::HLLCompiler' ]
56 astcompiler.'removestage'('parse')
57 astcompiler.'removestage'('past')
61 ( result ) = astcompiler.'eval'(var_block)
62 _dumper( result, 'result' )
70 # vim: expandtab shiftwidth=4 ft=pir: