line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
109
|
|
|
109
|
|
2549
|
use 5.010001; |
|
109
|
|
|
|
|
12252
|
|
2
|
109
|
|
|
109
|
|
598
|
use strict; |
|
109
|
|
|
|
|
230
|
|
|
109
|
|
|
|
|
2582
|
|
3
|
109
|
|
|
109
|
|
886
|
use warnings; |
|
109
|
|
|
|
|
230
|
|
|
109
|
|
|
|
|
6414
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use Mite::Miteception -all; |
6
|
109
|
|
|
109
|
|
637
|
|
|
109
|
|
|
|
|
253
|
|
|
109
|
|
|
|
|
862
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
8
|
|
|
|
|
|
|
our $VERSION = '0.011000'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has name => |
11
|
|
|
|
|
|
|
is => ro, |
12
|
|
|
|
|
|
|
isa => ValidClassName, |
13
|
|
|
|
|
|
|
required => true; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has shim_name => |
16
|
|
|
|
|
|
|
is => rw, |
17
|
|
|
|
|
|
|
isa => ValidClassName, |
18
|
|
|
|
|
|
|
lazy => true, |
19
|
|
|
|
|
|
|
builder => sub { |
20
|
|
|
|
|
|
|
my $self = shift; |
21
|
6
|
|
|
6
|
|
17
|
eval { $self->project->config->data->{shim} } // 'Mite::Shim' |
22
|
6
|
|
50
|
|
|
17
|
}; |
|
6
|
|
|
|
|
33
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has source => |
25
|
|
|
|
|
|
|
is => rw, |
26
|
|
|
|
|
|
|
isa => MiteSource, |
27
|
|
|
|
|
|
|
# avoid a circular dep with Mite::Source |
28
|
|
|
|
|
|
|
weak_ref => true; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has imported_functions => |
31
|
|
|
|
|
|
|
is => ro, |
32
|
|
|
|
|
|
|
isa => Map[ MethodName, Str ], |
33
|
|
|
|
|
|
|
builder => sub { {} }; |
34
|
154
|
|
|
154
|
|
517
|
|
35
|
|
|
|
|
|
|
has imported_keywords => |
36
|
|
|
|
|
|
|
is => ro, |
37
|
|
|
|
|
|
|
isa => Map[ MethodName, Str ], |
38
|
|
|
|
|
|
|
builder => sub { {} }; |
39
|
154
|
|
|
154
|
|
659
|
|
40
|
|
|
|
|
|
|
has arg => |
41
|
|
|
|
|
|
|
is => rw, |
42
|
|
|
|
|
|
|
default => {}; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
require Type::Registry; |
48
|
154
|
|
|
154
|
0
|
396
|
my $reg = 'Type::Registry'->for_class( $self->name ); |
49
|
|
|
|
|
|
|
$reg->add_types( 'Types::Standard' ); |
50
|
154
|
|
|
|
|
45449
|
$reg->add_types( 'Types::Common::Numeric' ); |
51
|
154
|
|
|
|
|
1767028
|
$reg->add_types( 'Types::Common::String' ); |
52
|
154
|
|
|
|
|
2719
|
|
53
|
154
|
|
|
|
|
1264480
|
my $library = eval { $self->project->config->data->{types} }; |
54
|
154
|
|
|
|
|
2739102
|
$reg->add_types( $library ) if $library; |
55
|
|
|
|
|
|
|
} |
56
|
154
|
|
|
|
|
431650
|
|
|
154
|
|
|
|
|
1892
|
|
57
|
154
|
50
|
|
|
|
5918
|
my $self = shift; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
return $self->source->project; |
60
|
|
|
|
|
|
|
} |
61
|
1112
|
|
|
1112
|
0
|
1992
|
|
62
|
|
|
|
|
|
|
my ( $self, $file, $arg ) = ( shift, @_ ); |
63
|
1112
|
|
|
|
|
3317
|
|
64
|
|
|
|
|
|
|
my $requested = sub { $arg->{$_[0]} ? 1 : $arg->{'!'.$_[0]} ? 0 : $arg->{'-all'} ? 1 : $_[1]; }; |
65
|
|
|
|
|
|
|
my $shim = $self->shim_name; |
66
|
|
|
|
|
|
|
my $package = $self->name; |
67
|
117
|
|
|
117
|
0
|
387
|
my $ctxt = $shim->can( '_definition_context' ); |
68
|
|
|
|
|
|
|
|
69
|
117
|
100
|
|
1989
|
|
630
|
no strict 'refs'; |
|
1989
|
50
|
|
|
|
7630
|
|
|
|
100
|
|
|
|
|
|
70
|
117
|
|
|
|
|
471
|
${ $package .'::USES_MITE' } = ref( $self ); |
71
|
117
|
|
|
|
|
496
|
${ $package .'::MITE_SHIM' } = $shim; |
72
|
117
|
|
|
|
|
790
|
|
73
|
|
|
|
|
|
|
my $want_bool = $requested->( '-bool', 0 ); |
74
|
109
|
|
|
109
|
|
12561
|
my $want_is = $requested->( '-is', 0 ); |
|
109
|
|
|
|
|
308
|
|
|
109
|
|
|
|
|
65289
|
|
75
|
117
|
|
|
|
|
347
|
for my $f ( qw/ true false / ) { |
|
117
|
|
|
|
|
663
|
|
76
|
117
|
|
|
|
|
268
|
next unless $requested->( $f, $want_bool ); |
|
117
|
|
|
|
|
474
|
|
77
|
|
|
|
|
|
|
*{"$package\::$f"} = \&{"$shim\::$f"}; |
78
|
117
|
|
|
|
|
408
|
$self->imported_functions->{$f} = "$shim\::$f"; |
79
|
117
|
|
|
|
|
393
|
} |
80
|
117
|
|
|
|
|
391
|
for my $f ( qw/ ro rw rwp lazy bare / ) { |
81
|
234
|
100
|
|
|
|
597
|
next unless $requested->( $f, $want_is ); |
82
|
24
|
|
|
|
|
74
|
*{"$package\::$f"} = \&{"$shim\::$f"}; |
|
24
|
|
|
|
|
102
|
|
|
24
|
|
|
|
|
123
|
|
83
|
24
|
|
|
|
|
151
|
$self->imported_functions->{$f} = "$shim\::$f"; |
84
|
|
|
|
|
|
|
} |
85
|
117
|
|
|
|
|
410
|
for my $f ( qw/ carp croak confess guard STRICT lock unlock / ) { |
86
|
585
|
100
|
|
|
|
974
|
next unless $requested->( $f, false ); |
87
|
55
|
|
|
|
|
82
|
*{"$package\::$f"} = \&{"$shim\::$f"}; |
|
55
|
|
|
|
|
178
|
|
|
55
|
|
|
|
|
146
|
|
88
|
55
|
|
|
|
|
183
|
$self->imported_functions->{$f} = "$shim\::$f"; |
89
|
|
|
|
|
|
|
} |
90
|
117
|
|
|
|
|
452
|
if ( $requested->( blessed => false ) ) { |
91
|
819
|
100
|
|
|
|
1469
|
require Scalar::Util; |
92
|
71
|
|
|
|
|
115
|
*{"$package\::blessed"} = \&Scalar::Util::blessed; |
|
71
|
|
|
|
|
216
|
|
|
71
|
|
|
|
|
189
|
|
93
|
71
|
|
|
|
|
218
|
$self->imported_functions->{blessed} = "Scalar::Util::blessed"; |
94
|
|
|
|
|
|
|
} |
95
|
117
|
100
|
|
|
|
420
|
} |
96
|
10
|
|
|
|
|
63
|
|
97
|
10
|
|
|
|
|
30
|
my $self = shift; |
|
10
|
|
|
|
|
43
|
|
98
|
10
|
|
|
|
|
107
|
|
99
|
|
|
|
|
|
|
return undef |
100
|
|
|
|
|
|
|
if not eval { $self->project->config->data->{autolax} }; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
return $self->imported_functions->{STRICT} |
103
|
211
|
|
|
211
|
0
|
483
|
? 'STRICT' |
104
|
|
|
|
|
|
|
: sprintf( '%s::STRICT', $self->project->config->data->{shim} ); |
105
|
|
|
|
|
|
|
} |
106
|
211
|
50
|
|
|
|
419
|
|
|
211
|
|
|
|
|
637
|
|
107
|
|
|
|
|
|
|
for my $function ( qw/ carp croak confess / ) { |
108
|
|
|
|
|
|
|
no strict 'refs'; |
109
|
|
|
|
|
|
|
*{"_function_for_$function"} = sub { |
110
|
0
|
0
|
|
|
|
0
|
my $self = shift; |
111
|
|
|
|
|
|
|
return $function |
112
|
|
|
|
|
|
|
if $self->imported_functions->{$function}; |
113
|
|
|
|
|
|
|
return sprintf '%s::%s', $self->shim_name, $function |
114
|
109
|
|
|
109
|
|
966
|
if $self->shim_name; |
|
109
|
|
|
|
|
285
|
|
|
109
|
|
|
|
|
109611
|
|
115
|
|
|
|
|
|
|
$function eq 'carp' ? 'warn sprintf' : 'die sprintf'; |
116
|
296
|
|
|
296
|
|
656
|
}; |
117
|
|
|
|
|
|
|
} |
118
|
296
|
100
|
|
|
|
1597
|
|
119
|
234
|
50
|
|
|
|
865
|
my $self = shift; |
120
|
|
|
|
|
|
|
|
121
|
0
|
0
|
|
|
|
0
|
my $code = join "\n", |
122
|
|
|
|
|
|
|
'{', |
123
|
|
|
|
|
|
|
map( $self->$_, $self->compilation_stages ), |
124
|
|
|
|
|
|
|
'1;', |
125
|
|
|
|
|
|
|
'}'; |
126
|
123
|
|
|
123
|
0
|
356
|
|
127
|
|
|
|
|
|
|
#::diag $code if main->can('diag'); |
128
|
123
|
|
|
|
|
3766
|
return $code; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
my ( $self, $classvar, $selfvar, $argvar, $metavar ) = @_; |
132
|
|
|
|
|
|
|
return sprintf '( $Mite::META{%s} ||= %s->__META__ )', |
133
|
|
|
|
|
|
|
$classvar, $classvar; |
134
|
|
|
|
|
|
|
} |
135
|
123
|
|
|
|
|
2341
|
|
136
|
|
|
|
|
|
|
return qw( |
137
|
|
|
|
|
|
|
_compile_package |
138
|
|
|
|
|
|
|
_compile_pragmas |
139
|
284
|
|
|
284
|
|
947
|
_compile_uses_mite |
140
|
284
|
|
|
|
|
2604
|
_compile_imported_keywords |
141
|
|
|
|
|
|
|
_compile_imported_functions |
142
|
|
|
|
|
|
|
_compile_meta_method |
143
|
|
|
|
|
|
|
); |
144
|
|
|
|
|
|
|
} |
145
|
123
|
|
|
123
|
0
|
690
|
|
146
|
|
|
|
|
|
|
my $self = shift; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
return "package @{[ $self->name ]};"; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
my $self = shift; |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
return <<'CODE'; |
154
|
|
|
|
|
|
|
use strict; |
155
|
|
|
|
|
|
|
use warnings; |
156
|
123
|
|
|
123
|
|
316
|
no warnings qw( once void ); |
157
|
|
|
|
|
|
|
CODE |
158
|
123
|
|
|
|
|
303
|
} |
|
123
|
|
|
|
|
3645
|
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
my $self = shift; |
161
|
|
|
|
|
|
|
|
162
|
123
|
|
|
123
|
|
296
|
my @code = sprintf 'our $USES_MITE = %s;', B::perlstring( ref($self) ); |
163
|
|
|
|
|
|
|
if ( $self->shim_name ) { |
164
|
123
|
|
|
|
|
419
|
push @code, sprintf 'our $MITE_SHIM = %s;', B::perlstring( $self->shim_name ); |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
push @code, sprintf 'our $MITE_VERSION = %s;', B::perlstring( $self->VERSION ); |
167
|
|
|
|
|
|
|
join "\n", @code; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
my $self = shift; |
171
|
|
|
|
|
|
|
|
172
|
123
|
|
|
123
|
|
359
|
my %func = %{ $self->imported_keywords or {} } or return; |
173
|
|
|
|
|
|
|
my @keywords = sort keys %func; |
174
|
123
|
|
|
|
|
1056
|
my $keyword_slots = join q{, }, map "*$_", @keywords; |
175
|
123
|
50
|
|
|
|
786
|
my $coderefs = join "\n", map " $func{$_},", @keywords; |
176
|
123
|
|
|
|
|
530
|
|
177
|
|
|
|
|
|
|
return sprintf <<'CODE', B::perlstring( $self->shim_name ), B::perlstring( $self->name ), $keyword_slots, $self->shim_name, $coderefs; |
178
|
123
|
|
|
|
|
2015
|
# Mite keywords |
179
|
123
|
|
|
|
|
1353
|
BEGIN { |
180
|
|
|
|
|
|
|
my ( $SHIM, $CALLER ) = ( %s, %s ); |
181
|
|
|
|
|
|
|
( %s ) = do { |
182
|
|
|
|
|
|
|
package %s; |
183
|
123
|
|
|
123
|
|
346
|
no warnings 'redefine'; |
184
|
|
|
|
|
|
|
( |
185
|
123
|
50
|
|
|
|
233
|
%s |
|
123
|
100
|
|
|
|
1883
|
|
186
|
117
|
|
|
|
|
978
|
); |
187
|
117
|
|
|
|
|
1052
|
}; |
188
|
117
|
|
|
|
|
1353
|
}; |
189
|
|
|
|
|
|
|
CODE |
190
|
117
|
|
|
|
|
622
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
my $self = shift; |
193
|
|
|
|
|
|
|
my %func = %{ $self->imported_functions } or return; |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
return join "\n", |
196
|
|
|
|
|
|
|
'# Mite imports', |
197
|
|
|
|
|
|
|
'BEGIN {', |
198
|
|
|
|
|
|
|
( $func{blessed} ? ' require Scalar::Util;' : () ), |
199
|
|
|
|
|
|
|
map( |
200
|
|
|
|
|
|
|
sprintf( ' *%s = \&%s;', $_, $func{$_} ), |
201
|
|
|
|
|
|
|
sort keys %func |
202
|
|
|
|
|
|
|
), |
203
|
|
|
|
|
|
|
'};', |
204
|
|
|
|
|
|
|
''; |
205
|
|
|
|
|
|
|
} |
206
|
123
|
|
|
123
|
|
347
|
|
207
|
123
|
100
|
|
|
|
257
|
my $self = shift; |
|
123
|
|
|
|
|
3822
|
|
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
my $code = <<'CODE'; |
210
|
|
|
|
|
|
|
# Gather metadata for constructor and destructor |
211
|
|
|
|
|
|
|
sub __META__ { |
212
|
|
|
|
|
|
|
no strict 'refs'; |
213
|
|
|
|
|
|
|
my $class = shift; $class = ref($class) || $class; |
214
|
13
|
100
|
|
|
|
767
|
my $linear_isa = mro::get_linear_isa( $class ); |
215
|
|
|
|
|
|
|
return { |
216
|
|
|
|
|
|
|
BUILD => [ |
217
|
|
|
|
|
|
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
218
|
|
|
|
|
|
|
map { "$_\::BUILD" } reverse @$linear_isa |
219
|
|
|
|
|
|
|
], |
220
|
|
|
|
|
|
|
DEMOLISH => [ |
221
|
|
|
|
|
|
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
222
|
100
|
|
|
100
|
|
311
|
map { "$_\::DEMOLISH" } @$linear_isa |
223
|
|
|
|
|
|
|
], |
224
|
100
|
|
|
|
|
330
|
HAS_BUILDARGS => $class->can('BUILDARGS'), |
225
|
|
|
|
|
|
|
HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'), |
226
|
|
|
|
|
|
|
}; |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
CODE |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
if ( eval { $self->project->config->data->{mop} } ) { |
231
|
|
|
|
|
|
|
$code .= sprintf <<'CODE', $self->project->config->data->{mop}; |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
# Moose-compatibility method |
234
|
|
|
|
|
|
|
sub meta { |
235
|
|
|
|
|
|
|
require %s; |
236
|
|
|
|
|
|
|
Moose::Util::find_meta( ref $_[0] or $_[0] ); |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
CODE |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
return $code; |
242
|
|
|
|
|
|
|
} |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
1; |