line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mic::Implementation; |
2
|
|
|
|
|
|
|
|
3
|
34
|
|
|
34
|
|
18938
|
use strict; |
|
34
|
|
|
|
|
81
|
|
|
34
|
|
|
|
|
1419
|
|
4
|
34
|
|
|
34
|
|
201
|
use Package::Stash; |
|
34
|
|
|
|
|
69
|
|
|
34
|
|
|
|
|
870
|
|
5
|
34
|
|
|
34
|
|
181
|
use Params::Validate qw(:all); |
|
34
|
|
|
|
|
84
|
|
|
34
|
|
|
|
|
20225
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub import { |
8
|
51
|
|
|
51
|
|
2462
|
my $class = shift; |
9
|
|
|
|
|
|
|
|
10
|
51
|
|
|
|
|
1226
|
my %arg = validate(@_, { |
11
|
|
|
|
|
|
|
has => { type => HASHREF }, |
12
|
|
|
|
|
|
|
classmethod => { type => ARRAYREF, optional => 1 }, |
13
|
|
|
|
|
|
|
}); |
14
|
|
|
|
|
|
|
|
15
|
51
|
|
|
|
|
515
|
strict->import(); |
16
|
|
|
|
|
|
|
|
17
|
51
|
|
|
|
|
224
|
$arg{-caller} = (caller)[0]; |
18
|
51
|
|
|
|
|
801
|
$class->define(%arg); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub define { |
22
|
51
|
|
|
51
|
0
|
215
|
my ($class, %arg) = @_; |
23
|
|
|
|
|
|
|
|
24
|
51
|
|
33
|
|
|
233
|
my $caller_pkg = delete $arg{-caller} || (caller)[0]; |
25
|
51
|
|
|
|
|
623
|
my $stash = Package::Stash->new($caller_pkg); |
26
|
|
|
|
|
|
|
|
27
|
51
|
|
|
|
|
240
|
$class->add_attribute_syms(\%arg, $stash); |
28
|
|
|
|
|
|
|
|
29
|
51
|
|
|
|
|
11251
|
$stash->add_symbol('%__meta__', \%arg); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub add_attribute_syms { |
33
|
51
|
|
|
51
|
0
|
131
|
my ($class, $arg, $stash) = @_; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my @slots = ( |
36
|
51
|
|
|
|
|
92
|
keys %{ $arg->{has} }, |
|
51
|
|
|
|
|
185
|
|
37
|
|
|
|
|
|
|
); |
38
|
51
|
|
|
|
|
100
|
my %seen_attr; |
39
|
51
|
|
|
|
|
204
|
foreach my $i ( 0 .. $#slots ) { |
40
|
67
|
50
|
|
|
|
237
|
next if exists $seen_attr{ $slots[$i] }; |
41
|
|
|
|
|
|
|
|
42
|
67
|
|
|
|
|
146
|
$seen_attr{ $slots[$i] }++; |
43
|
67
|
|
|
|
|
255
|
$class->add_sym($arg, $stash, $slots[$i], $i); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub add_sym { |
48
|
67
|
|
|
67
|
0
|
154
|
my ($class, $arg, $stash, $slot, $sym_val) = @_; |
49
|
|
|
|
|
|
|
|
50
|
67
|
|
|
|
|
166
|
$arg->{slot_offset}{$slot} = $sym_val; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
$stash->add_symbol( |
53
|
|
|
|
|
|
|
sprintf('&%s', $slot), |
54
|
0
|
|
|
0
|
|
|
sub () { $sym_val } |
55
|
67
|
|
|
|
|
1592
|
); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |