v6.pm

filter: Statementstmt 88.2% 15 / 17 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 91.3% 21 / 23 CC 1 SCAR 0.5
CC
1
Cov
88%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Pugs/Runtime/Perl6.pm ↑ Summary
1 package v6;
2 $v6::VERSION = '0.006';
3  
4 # Documentation in the __END__
5 21 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 21 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 21 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 21 ▶use Module::Compile-base;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 21 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 0 ▶use Pugs::Runtime::Perl6;
Subroutine BEGIN: called CC=1 SCAR=2.6
11  
12 my $bin;
13 BEGIN { $bin = ((dirname(__FILE__) || '.') . "/..") };
14  
15 sub pmc_can_output { 1 }
16  
17 sub pmc_parse_blocks {
18 my $class = shift;
19 my $text = shift;
20 return [$text, {$class => { use => 'dummy' }}, [$class]]
21 }
22  
23 sub pmc_filter {
24 my ($class, $module, $line_number, $post_process) = @_;
25 $class->SUPER::pmc_filter($module, 0, $post_process);
26 }
27  
28 sub pmc_compile {
29 my ($class, $source) = @_;
30  
31 require Pugs::Compiler::Perl6;
32  
33 my $p6 = Pugs::Compiler::Perl6->compile( $source );
34 my $perl5 = $p6->{perl5};
35  
36 # Don't write when we failed to compile, otherwise it never recompiles!
37 die unless length $perl5;
38  
39 # $perl5 =~ s/do\{(.*)\}/$1/s;
40 my ($package, $file) = caller(4);
41 $perl5 =
42 ( $package ? "package $package;\n" : "# no package name\n" ).
43 ((!$package or ($package eq 'main')) ? (
44 "use Config;\n".
45 "use lib split(/\\Q\$Config{path_sep}/, \$ENV{PERL6LIB} || '');\n"
46 ) : '').
47 "use Scalar::Util;\n" .
48 "use Pugs::Runtime::Perl6;\n" .
49 "use strict;\n" .
50 "no warnings 'void';\n" . # t/07-try.t, t/07-ref.t
51 $perl5 . "\n" .
52 "; 1;\n";
53  
54 {
55 # Perl::Tidy is used if available
56 local $@; # don't care if there are errors here
57 local @ARGV = (); # "You may not specify any filenames ... - Perl::Tidy.pm
58 eval {
59 require Perl::Tidy;
60 my $perl5_tidy;
61 Perl::Tidy::perltidy( source => \$perl5, destination => \$perl5_tidy );
62 $perl5 = $perl5_tidy;
63 }
64 }
65  
66 return $perl5;
67 }
68  
69 if (@ARGV and !caller) {
70 # We are the main program here
71 my ($compile_only, $code);
72  
73 if ($ARGV[0] eq '--compile-only') {
74 shift(@ARGV);
75 $compile_only++;
76 }
77  
78 shift(@ARGV) if $ARGV[0] =~ /^--pugs/;
79 shift(@ARGV) if $ARGV[0] =~ /^-Bperl5$/i;
80 splice(@ARGV, 0, 2) if $ARGV[0] =~ /^-B$/;
81  
82 if (@ARGV and $ARGV[0] =~ s/^-e//) {
83 $code = (length($ARGV[0]) ? $ARGV[0] : $ARGV[1]);
84 }
85 else {
86 local $/;
87 $code = <>;
88 }
89  
90 if ($compile_only) {
91 print __PACKAGE__->pmc_compile($code);
92 }
93 else {
94 local $@;
95 eval __PACKAGE__->pmc_compile($code);
96 die $@ if $@;
97 exit 0;
98 }
99 }
100  
101 1;
102  
103 __END__
« Pugs/Runtime/Perl6.pm ↑ Summary