line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mic; |
2
|
|
|
|
|
|
|
|
3
|
33
|
|
|
33
|
|
270118
|
use strict; |
|
33
|
|
|
|
|
63
|
|
|
33
|
|
|
|
|
777
|
|
4
|
33
|
|
|
33
|
|
724
|
use 5.008_005; |
|
33
|
|
|
|
|
101
|
|
5
|
33
|
|
|
33
|
|
215
|
use Carp; |
|
33
|
|
|
|
|
61
|
|
|
33
|
|
|
|
|
1755
|
|
6
|
33
|
|
|
33
|
|
10100
|
use Params::Validate qw(:all); |
|
33
|
|
|
|
|
218097
|
|
|
33
|
|
|
|
|
5352
|
|
7
|
33
|
|
|
33
|
|
9885
|
use Mic::Assembler; |
|
33
|
|
|
|
|
101
|
|
|
33
|
|
|
|
|
9524
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.000005'; |
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
|
90
|
my ($class, $spec) = @_; |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
66
|
|
|
9
|
$spec->{name} ||= "Mic::Class_${\ ++$Class_count }"; |
|
1
|
|
|
|
|
6
|
|
22
|
2
|
|
|
|
|
7
|
$class->assemble($spec); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub assemble { |
26
|
49
|
|
|
49
|
0
|
346
|
my (undef, $spec) = @_; |
27
|
|
|
|
|
|
|
|
28
|
49
|
|
|
|
|
253
|
my $assembler = Mic::Assembler->new(-spec => $spec); |
29
|
49
|
|
|
|
|
88
|
my $cls_stash; |
30
|
49
|
100
|
|
|
|
157
|
if ( ! $spec->{name} ) { |
31
|
47
|
|
|
|
|
73
|
my $depth = 0; |
32
|
47
|
|
|
|
|
71
|
my $caller_pkg = ''; |
33
|
47
|
|
|
|
|
195
|
my $pkg = __PACKAGE__; |
34
|
|
|
|
|
|
|
|
35
|
47
|
|
|
|
|
64
|
do { |
36
|
89
|
|
|
|
|
1219
|
$caller_pkg = (caller $depth++)[0]; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
while $caller_pkg =~ /^$pkg\b/; |
39
|
47
|
|
|
|
|
527
|
$spec = $assembler->load_spec_from($caller_pkg); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
49
|
|
|
|
|
163
|
my @args = %$spec; |
43
|
49
|
|
|
|
|
1467
|
validate(@args, { |
44
|
|
|
|
|
|
|
interface => { type => HASHREF | SCALAR }, |
45
|
|
|
|
|
|
|
implementation => { type => SCALAR }, |
46
|
|
|
|
|
|
|
name => { type => SCALAR, optional => 1 }, |
47
|
|
|
|
|
|
|
}); |
48
|
49
|
|
|
|
|
326
|
return $assembler->assemble; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
*setup_class = \&assemble; |
52
|
|
|
|
|
|
|
*define_class = \&assemble; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub builder_for { |
55
|
52
|
|
|
52
|
0
|
206
|
my ($class) = @_; |
56
|
|
|
|
|
|
|
|
57
|
52
|
0
|
|
|
|
184
|
return $Util_class{ $class } |
58
|
|
|
|
|
|
|
or confess "Unknown class: $class"; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
__END__ |