line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
107
|
|
|
107
|
|
2206
|
use 5.010001; |
|
107
|
|
|
|
|
513
|
|
2
|
107
|
|
|
107
|
|
703
|
use strict; |
|
107
|
|
|
|
|
376
|
|
|
107
|
|
|
|
|
2758
|
|
3
|
107
|
|
|
107
|
|
666
|
use warnings; |
|
107
|
|
|
|
|
877
|
|
|
107
|
|
|
|
|
5480
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Mite::Compiled; |
6
|
107
|
|
|
107
|
|
847
|
use Mite::Miteception -all; |
|
107
|
|
|
|
|
392
|
|
|
107
|
|
|
|
|
994
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
9
|
|
|
|
|
|
|
our $VERSION = '0.012000'; |
10
|
|
|
|
|
|
|
|
11
|
107
|
|
|
107
|
|
861
|
use Path::Tiny; |
|
107
|
|
|
|
|
275
|
|
|
107
|
|
|
|
|
73478
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Don't load Mite::Source else it will go circular |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has file => |
16
|
|
|
|
|
|
|
is => rw, |
17
|
|
|
|
|
|
|
isa => Path, |
18
|
|
|
|
|
|
|
coerce => true, |
19
|
|
|
|
|
|
|
lazy => true, |
20
|
|
|
|
|
|
|
default => sub { |
21
|
|
|
|
|
|
|
my $self = shift; |
22
|
|
|
|
|
|
|
return $self->_source_file2compiled_file( $self->source->file ); |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has source => |
26
|
|
|
|
|
|
|
is => ro, |
27
|
|
|
|
|
|
|
isa => MiteSource, |
28
|
|
|
|
|
|
|
# avoid a circular dep with Mite::Source |
29
|
|
|
|
|
|
|
weak_ref => true, |
30
|
|
|
|
|
|
|
required => true, |
31
|
|
|
|
|
|
|
handles => [ qw( classes class_order ) ]; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub compile { |
34
|
88
|
|
|
88
|
0
|
272
|
my $self = shift; |
35
|
|
|
|
|
|
|
|
36
|
88
|
|
|
|
|
203
|
my $code; |
37
|
88
|
|
|
|
|
220
|
for my $class_name ( @{ $self->class_order } ) { |
|
88
|
|
|
|
|
540
|
|
38
|
122
|
|
|
|
|
703
|
my $class = $self->classes->{$class_name}; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Only supported by Type::Tiny 1.013_001 but no harm |
41
|
|
|
|
|
|
|
# in doing this anyway. |
42
|
|
|
|
|
|
|
local $Type::Tiny::SafePackage = sprintf 'package %s;', |
43
|
122
|
|
|
|
|
750
|
eval { $self->source->project->config->data->{shim} } |
44
|
122
|
|
66
|
|
|
376
|
// do { $class_name . '::__SAFE_NAMESPACE__' }; |
|
116
|
|
|
|
|
4973
|
|
45
|
|
|
|
|
|
|
|
46
|
122
|
|
|
|
|
1413
|
$code .= $class->compile; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
88
|
|
|
|
|
364
|
my $tidied; |
50
|
88
|
50
|
66
|
|
|
290
|
eval { |
|
|
|
33
|
|
|
|
|
51
|
88
|
|
|
|
|
231
|
my $flag; |
52
|
88
|
50
|
|
|
|
715
|
if ( $self->source->project->config->should_tidy ) { |
53
|
0
|
|
|
|
|
0
|
$flag = Perl::Tidy::perltidy( |
54
|
|
|
|
|
|
|
source => \$code, |
55
|
|
|
|
|
|
|
destination => \$tidied, |
56
|
|
|
|
|
|
|
argv => [], |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
} |
59
|
6
|
|
|
|
|
60
|
!$flag; |
60
|
|
|
|
|
|
|
} and defined($tidied) and length($tidied) and ($code = $tidied); |
61
|
|
|
|
|
|
|
|
62
|
88
|
|
|
|
|
2976
|
return $code; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub write { |
66
|
88
|
|
|
88
|
0
|
530
|
my ( $self, %opts ) = @_; |
67
|
|
|
|
|
|
|
|
68
|
88
|
|
|
|
|
499
|
my $code = $self->compile; |
69
|
88
|
50
|
|
|
|
539
|
if ( defined $opts{module_fakeout_namespace} ) { |
70
|
0
|
|
|
|
|
0
|
my $ns = $opts{module_fakeout_namespace}; |
71
|
0
|
|
|
|
|
0
|
$code =~ s/$ns\:://g; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
88
|
|
|
|
|
652
|
return $self->file->spew_utf8($code); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub remove { |
78
|
1
|
|
|
1
|
0
|
7
|
my $self = shift; |
79
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
4
|
return $self->file->remove; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
signature_for _source_file2compiled_file => ( |
84
|
|
|
|
|
|
|
pos => [ Defined ], |
85
|
|
|
|
|
|
|
); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub _source_file2compiled_file { |
88
|
|
|
|
|
|
|
my ( $self, $source_file ) = @_; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# Changes here must be coordinated with Mite.pm |
91
|
|
|
|
|
|
|
return $source_file . '.mite.pm'; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |