line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mic; |
2
|
|
|
|
|
|
|
|
3
|
33
|
|
|
33
|
|
347620
|
use strict; |
|
33
|
|
|
|
|
97
|
|
|
33
|
|
|
|
|
862
|
|
4
|
33
|
|
|
33
|
|
839
|
use 5.008_005; |
|
33
|
|
|
|
|
112
|
|
5
|
33
|
|
|
33
|
|
174
|
use Carp; |
|
33
|
|
|
|
|
65
|
|
|
33
|
|
|
|
|
2022
|
|
6
|
33
|
|
|
33
|
|
11130
|
use Params::Validate qw(:all); |
|
33
|
|
|
|
|
245123
|
|
|
33
|
|
|
|
|
6191
|
|
7
|
33
|
|
|
33
|
|
10851
|
use Mic::Assembler; |
|
33
|
|
|
|
|
125
|
|
|
33
|
|
|
|
|
13373
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.000006'; |
10
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $Class_count = 0; |
13
|
|
|
|
|
|
|
our %Bound_implementation_of; |
14
|
|
|
|
|
|
|
our %Contracts_for; |
15
|
|
|
|
|
|
|
our %Spec_for; |
16
|
|
|
|
|
|
|
our %Util_class; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub load_class { |
19
|
2
|
|
|
2
|
1
|
108
|
my ($class, $spec) = @_; |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
66
|
|
|
9
|
$spec->{name} ||= "Mic::Class_${\ ++$Class_count }"; |
|
1
|
|
|
|
|
7
|
|
22
|
2
|
|
|
|
|
6
|
$class->assemble($spec); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub assemble { |
26
|
49
|
|
|
49
|
0
|
370
|
my (undef, $spec) = @_; |
27
|
|
|
|
|
|
|
|
28
|
49
|
|
|
|
|
257
|
my $assembler = Mic::Assembler->new(-spec => $spec); |
29
|
49
|
|
|
|
|
99
|
my $cls_stash; |
30
|
49
|
100
|
|
|
|
185
|
if ( ! $spec->{name} ) { |
31
|
47
|
|
|
|
|
91
|
my $depth = 0; |
32
|
47
|
|
|
|
|
97
|
my $caller_pkg = ''; |
33
|
47
|
|
|
|
|
92
|
my $pkg = __PACKAGE__; |
34
|
|
|
|
|
|
|
|
35
|
47
|
|
|
|
|
72
|
do { |
36
|
89
|
|
|
|
|
1474
|
$caller_pkg = (caller $depth++)[0]; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
while $caller_pkg =~ /^$pkg\b/; |
39
|
47
|
|
|
|
|
557
|
$spec = $assembler->load_spec_from($caller_pkg); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
49
|
|
|
|
|
161
|
_check_imp_aliases($spec); |
43
|
49
|
|
|
|
|
162
|
my @args = %$spec; |
44
|
49
|
|
|
|
|
1643
|
validate(@args, { |
45
|
|
|
|
|
|
|
interface => { type => HASHREF | SCALAR }, |
46
|
|
|
|
|
|
|
implementation => { type => SCALAR }, |
47
|
|
|
|
|
|
|
name => { type => SCALAR, optional => 1 }, |
48
|
|
|
|
|
|
|
}); |
49
|
49
|
|
|
|
|
380
|
return $assembler->assemble; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _check_imp_aliases { |
53
|
49
|
|
|
49
|
|
100
|
my ($spec) = @_; |
54
|
|
|
|
|
|
|
|
55
|
49
|
|
|
|
|
134
|
my @imp_aliases = qw[via impl]; |
56
|
49
|
|
|
|
|
111
|
foreach my $k (@imp_aliases) { |
57
|
97
|
50
|
66
|
|
|
288
|
if (! exists $spec->{implementation} && exists $spec->{$k}) { |
58
|
1
|
|
|
|
|
4
|
$spec->{implementation} = $spec->{$k}; |
59
|
1
|
|
|
|
|
2
|
delete @{$spec}{ @imp_aliases }; |
|
1
|
|
|
|
|
5
|
|
60
|
1
|
|
|
|
|
4
|
last; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
*setup_class = \&assemble; |
66
|
|
|
|
|
|
|
*define_class = \&assemble; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub builder_for { |
69
|
52
|
|
|
52
|
0
|
215
|
my ($class) = @_; |
70
|
|
|
|
|
|
|
|
71
|
52
|
0
|
|
|
|
199
|
return $Util_class{ $class } |
72
|
|
|
|
|
|
|
or confess "Unknown class: $class"; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
__END__ |