line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
107
|
|
|
107
|
|
2908
|
use 5.010001; |
|
107
|
|
|
|
|
457
|
|
2
|
107
|
|
|
107
|
|
883
|
use strict; |
|
107
|
|
|
|
|
547
|
|
|
107
|
|
|
|
|
2785
|
|
3
|
107
|
|
|
107
|
|
1010
|
use warnings; |
|
107
|
|
|
|
|
412
|
|
|
107
|
|
|
|
|
5745
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Mite::Source; |
6
|
107
|
|
|
107
|
|
926
|
use Mite::Miteception -all; |
|
107
|
|
|
|
|
407
|
|
|
107
|
|
|
|
|
1346
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
9
|
|
|
|
|
|
|
our $VERSION = '0.012000'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has file => |
12
|
|
|
|
|
|
|
is => ro, |
13
|
|
|
|
|
|
|
isa => Path, |
14
|
|
|
|
|
|
|
coerce => true, |
15
|
|
|
|
|
|
|
required => true; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has classes => |
18
|
|
|
|
|
|
|
is => ro, |
19
|
|
|
|
|
|
|
isa => HashRef[MiteClass], |
20
|
|
|
|
|
|
|
default => sub { {} }; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has class_order => |
23
|
|
|
|
|
|
|
is => ro, |
24
|
|
|
|
|
|
|
isa => ArrayRef[NonEmptyStr], |
25
|
|
|
|
|
|
|
default => sub { [] }; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has compiled => |
28
|
|
|
|
|
|
|
is => ro, |
29
|
|
|
|
|
|
|
isa => MiteCompiled, |
30
|
|
|
|
|
|
|
lazy => true, |
31
|
|
|
|
|
|
|
default => sub { |
32
|
|
|
|
|
|
|
my $self = shift; |
33
|
|
|
|
|
|
|
return Mite::Compiled->new( source => $self ); |
34
|
|
|
|
|
|
|
}; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has project => |
37
|
|
|
|
|
|
|
is => rw, |
38
|
|
|
|
|
|
|
isa => MiteProject, |
39
|
|
|
|
|
|
|
# avoid a circular dep with Mite::Project |
40
|
|
|
|
|
|
|
weak_ref => true; |
41
|
|
|
|
|
|
|
|
42
|
107
|
|
|
107
|
|
47924
|
use Mite::Compiled; |
|
107
|
|
|
|
|
353
|
|
|
107
|
|
|
|
|
17093
|
|
43
|
107
|
|
|
107
|
|
61361
|
use Mite::Class; |
|
107
|
|
|
|
|
1495
|
|
|
107
|
|
|
|
|
57103
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub has_class { |
46
|
44
|
|
|
44
|
0
|
825
|
my ( $self, $name ) = ( shift, @_ ); |
47
|
|
|
|
|
|
|
|
48
|
44
|
|
|
|
|
473
|
return defined $self->classes->{$name}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub compile { |
52
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
0
|
return $self->compiled->compile(); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# Add an existing class instance to this source |
58
|
|
|
|
|
|
|
sub add_classes { |
59
|
1
|
|
|
1
|
0
|
33
|
my ( $self, @classes ) = ( shift, @_ ); |
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
4
|
for my $class (@classes) { |
62
|
2
|
|
|
|
|
10
|
$class->source($self); |
63
|
|
|
|
|
|
|
|
64
|
2
|
50
|
|
|
|
12
|
next if $self->classes->{$class->name}; |
65
|
2
|
|
|
|
|
8
|
$self->classes->{$class->name} = $class; |
66
|
2
|
|
|
|
|
3
|
push @{ $self->class_order }, $class->name; |
|
2
|
|
|
|
|
10
|
|
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
1
|
|
|
|
|
8
|
return; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# Create or reuse a class instance for this source give a name |
73
|
|
|
|
|
|
|
sub class_for { |
74
|
151
|
|
|
151
|
0
|
935
|
my ( $self, $name, $metaclass ) = ( shift, @_ ); |
75
|
151
|
|
100
|
|
|
713
|
$metaclass ||= 'Mite::Class'; |
76
|
|
|
|
|
|
|
|
77
|
151
|
100
|
|
|
|
1162
|
if ( not $self->classes->{$name} ) { |
78
|
148
|
|
|
|
|
10072
|
eval "require $metaclass"; |
79
|
148
|
|
|
|
|
1798
|
$self->classes->{$name} = $metaclass->new( |
80
|
|
|
|
|
|
|
name => $name, |
81
|
|
|
|
|
|
|
source => $self, |
82
|
|
|
|
|
|
|
); |
83
|
148
|
|
|
|
|
371
|
push @{ $self->class_order }, $name; |
|
148
|
|
|
|
|
805
|
|
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
151
|
|
|
|
|
1290
|
return $self->classes->{$name}; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub _compile_mop { |
90
|
0
|
|
|
0
|
|
|
my ( $self, $name ) = @_; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
my $joined = join "\n", |
93
|
0
|
|
|
|
|
|
map { $self->classes->{$_}->_compile_mop } |
94
|
0
|
|
|
|
|
|
@{ $self->class_order }; |
|
0
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
while ( $joined =~ /\n\n/ ) { |
97
|
0
|
|
|
|
|
|
$joined =~ s/\n\n/\n/g; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
return sprintf <<'CODE', B::perlstring( "$name" ), $joined; |
101
|
|
|
|
|
|
|
require %s; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
%s |
104
|
|
|
|
|
|
|
CODE |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1; |