root/ext/Perl-Compiler/testy.pl

Revision 11280, 1.7 kB (checked in by Darren_Duncan, 3 years ago)

more .p6 to .pl renaming

  • Property svn:mime-type set to text/plain; charset=UTF-8
  • Property svn:eol-style set to native
Line 
1use Perl::Compiler::PIL;
2use Perl::Compiler::PIL::Util;
3use Perl::Compiler::CodeGen::NameGen;
4use Perl::Compiler::CodeGen::Perl5_Str;
5
6# push @array, 4;
7
8my $pad = ::Perl::Compiler::PIL::Util::Pad.new(
9            names => [ '@array', '&push' ],
10);
11
12my $stmt = ::Perl::Compiler::PIL::PILStmt.new(
13            value => ::Perl::Compiler::PIL::PILApp.new(
14                code => ::Perl::Compiler::PIL::PILExp.new(
15                    value => ::Perl::Compiler::PIL::PILVar.new(
16                        value => '&push',
17                        pad => $pad,
18                    ),
19                ),
20                args => [
21                    ::Perl::Compiler::PIL::PILExp.new(
22                        value => ::Perl::Compiler::PIL::PILVar.new(
23                            value => '@array',
24                            pad => $pad,
25                        ),
26                    ),
27                    ::Perl::Compiler::PIL::PILLit.new(
28                        value => ::Perl::Compiler::PIL::PILVal.new(
29                            value => 4,
30                        ),
31                    ),
32                ],
33            ),
34           );
35
36my $block = ::Perl::Compiler::PIL::PILCode.new(
37                codetype => ::Perl::Compiler::PIL::Util::ConcreteType.new(
38                    name => 'Block',
39                ),
40                signature => ::Perl::Compiler::PIL::Util::Signature.new(
41                    params => [],
42                ),
43                pads => [ $pad ],
44                statements => ::Perl::Compiler::PIL::PILStmts.new(
45                    head => $stmt,
46                    tail => ::Perl::Compiler::PIL::PILNil.new(),
47                ),
48            );
49
50my $gen = ::Perl::Compiler::CodeGen::Perl5_Str.new;
51say $gen.generate($block);
Note: See TracBrowser for help on using the browser.