line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
108
|
|
|
108
|
|
2093
|
use 5.010001; |
|
108
|
|
|
|
|
351
|
|
2
|
108
|
|
|
108
|
|
4246
|
use strict; |
|
108
|
|
|
|
|
226
|
|
|
108
|
|
|
|
|
2611
|
|
3
|
108
|
|
|
108
|
|
465
|
use warnings; |
|
108
|
|
|
|
|
203
|
|
|
108
|
|
|
|
|
14866
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use Mite::Miteception -all; |
6
|
108
|
|
|
108
|
|
593
|
|
|
108
|
|
|
|
|
9975
|
|
|
108
|
|
|
|
|
11586
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
8
|
|
|
|
|
|
|
our $VERSION = '0.010008'; |
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
|
15
|
|
|
15
|
|
23
|
eval { $self->project->config->data->{shim} } // 'Mite::Shim' |
22
|
15
|
|
50
|
|
|
24
|
}; |
|
15
|
|
|
|
|
31
|
|
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
|
162
|
|
|
162
|
|
484
|
|
35
|
|
|
|
|
|
|
has imported_keywords => |
36
|
|
|
|
|
|
|
is => ro, |
37
|
|
|
|
|
|
|
isa => Map[ MethodName, Str ], |
38
|
|
|
|
|
|
|
builder => sub { {} }; |
39
|
162
|
|
|
162
|
|
419
|
|
40
|
|
|
|
|
|
|
has arg => |
41
|
|
|
|
|
|
|
is => rw, |
42
|
|
|
|
|
|
|
default => {}; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
require Type::Registry; |
48
|
162
|
|
|
162
|
0
|
509
|
my $reg = 'Type::Registry'->for_class( $self->name ); |
49
|
|
|
|
|
|
|
$reg->add_types( 'Types::Standard' ); |
50
|
162
|
|
|
|
|
41604
|
$reg->add_types( 'Types::Common::Numeric' ); |
51
|
162
|
|
|
|
|
1318117
|
$reg->add_types( 'Types::Common::String' ); |
52
|
162
|
|
|
|
|
2485
|
|
53
|
162
|
|
|
|
|
736947
|
my $library = eval { $self->project->config->data->{types} }; |
54
|
162
|
|
|
|
|
1983715
|
$reg->add_types( $library ) if $library; |
55
|
|
|
|
|
|
|
} |
56
|
162
|
|
|
|
|
239393
|
|
|
162
|
|
|
|
|
1592
|
|
57
|
162
|
50
|
|
|
|
5222
|
my $self = shift; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
return $self->source->project; |
60
|
|
|
|
|
|
|
} |
61
|
1161
|
|
|
1161
|
0
|
1829
|
|
62
|
|
|
|
|
|
|
my ( $self, $file, $arg ) = ( shift, @_ ); |
63
|
1161
|
|
|
|
|
2869
|
|
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
|
116
|
|
|
116
|
0
|
380
|
my $ctxt = $shim->can( '_definition_context' ); |
68
|
|
|
|
|
|
|
|
69
|
116
|
100
|
|
1740
|
|
1189
|
no strict 'refs'; |
|
1740
|
50
|
|
|
|
6557
|
|
|
|
100
|
|
|
|
|
|
70
|
116
|
|
|
|
|
454
|
${ $package .'::USES_MITE' } = ref( $self ); |
71
|
116
|
|
|
|
|
500
|
${ $package .'::MITE_SHIM' } = $shim; |
72
|
116
|
|
|
|
|
892
|
|
73
|
|
|
|
|
|
|
my $want_bool = $requested->( '-bool', 0 ); |
74
|
108
|
|
|
108
|
|
818
|
my $want_is = $requested->( '-is', 0 ); |
|
108
|
|
|
|
|
219
|
|
|
108
|
|
|
|
|
43140
|
|
75
|
116
|
|
|
|
|
495
|
for my $f ( qw/ true false / ) { |
|
116
|
|
|
|
|
1121
|
|
76
|
116
|
|
|
|
|
460
|
next unless $requested->( $f, $want_bool ); |
|
116
|
|
|
|
|
5036
|
|
77
|
|
|
|
|
|
|
*{"$package\::$f"} = \&{"$shim\::$f"}; |
78
|
116
|
|
|
|
|
449
|
$self->imported_functions->{$f} = "$shim\::$f"; |
79
|
116
|
|
|
|
|
336
|
} |
80
|
116
|
|
|
|
|
473
|
for my $f ( qw/ ro rw rwp lazy bare / ) { |
81
|
232
|
100
|
|
|
|
3596
|
next unless $requested->( $f, $want_is ); |
82
|
24
|
|
|
|
|
47
|
*{"$package\::$f"} = \&{"$shim\::$f"}; |
|
24
|
|
|
|
|
101
|
|
|
24
|
|
|
|
|
80
|
|
83
|
24
|
|
|
|
|
138
|
$self->imported_functions->{$f} = "$shim\::$f"; |
84
|
|
|
|
|
|
|
} |
85
|
116
|
|
|
|
|
387
|
for my $f ( qw/ carp croak confess guard STRICT / ) { |
86
|
580
|
100
|
|
|
|
815
|
next unless $requested->( $f, false ); |
87
|
55
|
|
|
|
|
68
|
*{"$package\::$f"} = \&{"$shim\::$f"}; |
|
55
|
|
|
|
|
194
|
|
|
55
|
|
|
|
|
133
|
|
88
|
55
|
|
|
|
|
166
|
$self->imported_functions->{$f} = "$shim\::$f"; |
89
|
|
|
|
|
|
|
} |
90
|
116
|
|
|
|
|
376
|
if ( $requested->( blessed => false ) ) { |
91
|
580
|
100
|
|
|
|
978
|
require Scalar::Util; |
92
|
51
|
|
|
|
|
76
|
*{"$package\::blessed"} = \&Scalar::Util::blessed; |
|
51
|
|
|
|
|
200
|
|
|
51
|
|
|
|
|
121
|
|
93
|
51
|
|
|
|
|
167
|
$self->imported_functions->{blessed} = "Scalar::Util::blessed"; |
94
|
|
|
|
|
|
|
} |
95
|
116
|
100
|
|
|
|
410
|
} |
96
|
10
|
|
|
|
|
52
|
|
97
|
10
|
|
|
|
|
29
|
my $self = shift; |
|
10
|
|
|
|
|
35
|
|
98
|
10
|
|
|
|
|
108
|
|
99
|
|
|
|
|
|
|
return undef |
100
|
|
|
|
|
|
|
if not eval { $self->project->config->data->{autolax} }; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
return $self->imported_functions->{STRICT} |
103
|
214
|
|
|
214
|
0
|
450
|
? 'STRICT' |
104
|
|
|
|
|
|
|
: sprintf( '%s::STRICT', $self->project->config->data->{shim} ); |
105
|
|
|
|
|
|
|
} |
106
|
214
|
50
|
|
|
|
361
|
|
|
214
|
|
|
|
|
577
|
|
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
|
108
|
|
|
108
|
|
766
|
if $self->shim_name; |
|
108
|
|
|
|
|
274
|
|
|
108
|
|
|
|
|
86783
|
|
115
|
|
|
|
|
|
|
$function eq 'carp' ? 'warn sprintf' : 'die sprintf'; |
116
|
297
|
|
|
297
|
|
537
|
}; |
117
|
|
|
|
|
|
|
} |
118
|
297
|
100
|
|
|
|
1327
|
|
119
|
235
|
50
|
|
|
|
725
|
my $self = shift; |
120
|
|
|
|
|
|
|
|
121
|
0
|
0
|
|
|
|
0
|
my $code = join "\n", |
122
|
|
|
|
|
|
|
'{', |
123
|
|
|
|
|
|
|
map( $self->$_, $self->compilation_stages ), |
124
|
|
|
|
|
|
|
'1;', |
125
|
|
|
|
|
|
|
'}'; |
126
|
131
|
|
|
131
|
0
|
318
|
|
127
|
|
|
|
|
|
|
#::diag $code if main->can('diag'); |
128
|
131
|
|
|
|
|
3460
|
return $code; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
my ( $self, $classvar, $selfvar, $argvar, $metavar ) = @_; |
132
|
|
|
|
|
|
|
return sprintf '( $Mite::META{%s} ||= %s->__META__ )', |
133
|
|
|
|
|
|
|
$classvar, $classvar; |
134
|
|
|
|
|
|
|
} |
135
|
131
|
|
|
|
|
2338
|
|
136
|
|
|
|
|
|
|
return qw( |
137
|
|
|
|
|
|
|
_compile_package |
138
|
|
|
|
|
|
|
_compile_pragmas |
139
|
294
|
|
|
294
|
|
885
|
_compile_uses_mite |
140
|
294
|
|
|
|
|
2377
|
_compile_imported_keywords |
141
|
|
|
|
|
|
|
_compile_imported_functions |
142
|
|
|
|
|
|
|
_compile_meta_method |
143
|
|
|
|
|
|
|
); |
144
|
|
|
|
|
|
|
} |
145
|
131
|
|
|
131
|
0
|
679
|
|
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
|
131
|
|
|
131
|
|
280
|
no warnings qw( once void ); |
157
|
|
|
|
|
|
|
CODE |
158
|
131
|
|
|
|
|
255
|
} |
|
131
|
|
|
|
|
3425
|
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
my $self = shift; |
161
|
|
|
|
|
|
|
|
162
|
131
|
|
|
131
|
|
323
|
my @code = sprintf 'our $USES_MITE = %s;', B::perlstring( ref($self) ); |
163
|
|
|
|
|
|
|
if ( $self->shim_name ) { |
164
|
131
|
|
|
|
|
354
|
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
|
131
|
|
|
131
|
|
320
|
my %func = %{ $self->imported_keywords or {} } or return; |
173
|
|
|
|
|
|
|
my @keywords = sort keys %func; |
174
|
131
|
|
|
|
|
1126
|
my $keyword_slots = join q{, }, map "*$_", @keywords; |
175
|
131
|
50
|
|
|
|
692
|
my $coderefs = join "\n", map " $func{$_},", @keywords; |
176
|
131
|
|
|
|
|
498
|
|
177
|
|
|
|
|
|
|
return sprintf <<'CODE', B::perlstring( $self->shim_name ), B::perlstring( $self->name ), $keyword_slots, $self->shim_name, $coderefs; |
178
|
131
|
|
|
|
|
1943
|
# Mite keywords |
179
|
131
|
|
|
|
|
1246
|
BEGIN { |
180
|
|
|
|
|
|
|
my ( $SHIM, $CALLER ) = ( %s, %s ); |
181
|
|
|
|
|
|
|
( %s ) = do { |
182
|
|
|
|
|
|
|
package %s; |
183
|
131
|
|
|
131
|
|
444
|
no warnings 'redefine'; |
184
|
|
|
|
|
|
|
( |
185
|
131
|
50
|
|
|
|
249
|
%s |
|
131
|
100
|
|
|
|
1734
|
|
186
|
116
|
|
|
|
|
900
|
); |
187
|
116
|
|
|
|
|
972
|
}; |
188
|
116
|
|
|
|
|
1213
|
}; |
189
|
|
|
|
|
|
|
CODE |
190
|
116
|
|
|
|
|
563
|
} |
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
|
131
|
|
|
131
|
|
375
|
|
207
|
131
|
100
|
|
|
|
225
|
my $self = shift; |
|
131
|
|
|
|
|
3506
|
|
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
|
|
|
|
618
|
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
|
103
|
|
|
103
|
|
280
|
map { "$_\::DEMOLISH" } @$linear_isa |
223
|
|
|
|
|
|
|
], |
224
|
103
|
|
|
|
|
281
|
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; |