line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YATT::Lite::Util::AsBase; |
2
|
14
|
|
|
14
|
|
94
|
use strict; |
|
14
|
|
|
|
|
30
|
|
|
14
|
|
|
|
|
466
|
|
3
|
14
|
|
|
14
|
|
70
|
use warnings qw(FATAL all NONFATAL misc); |
|
14
|
|
|
|
|
30
|
|
|
14
|
|
|
|
|
483
|
|
4
|
14
|
|
|
14
|
|
69
|
use Carp; |
|
14
|
|
|
|
|
25
|
|
|
14
|
|
|
|
|
1269
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
require Exporter; |
7
|
|
|
|
|
|
|
our @EXPORT = qw/import _import_as_base/; |
8
|
|
|
|
|
|
|
our @EXPORT_OK = @EXPORT; |
9
|
|
|
|
|
|
|
|
10
|
14
|
|
|
14
|
|
88
|
use YATT::Lite::Util qw/ckeval globref/; |
|
14
|
|
|
|
|
29
|
|
|
14
|
|
|
|
|
5060
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
require mro; |
13
|
|
|
|
|
|
|
require YATT::Lite::MFields; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub import { |
16
|
30
|
|
|
30
|
|
508
|
parse_args(\@_, scalar caller); |
17
|
30
|
|
|
|
|
129732
|
goto &Exporter::import; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# |
21
|
|
|
|
|
|
|
# Scan -zzz flag and call $pack->_import_zzz($callpack) |
22
|
|
|
|
|
|
|
# |
23
|
|
|
|
|
|
|
sub parse_args ($$) { |
24
|
34
|
|
|
34
|
0
|
97
|
my ($arglist, $callpack) = @_; |
25
|
34
|
50
|
33
|
|
|
369
|
return unless $arglist and @$arglist and defined (my $target = $arglist->[0]); |
|
|
|
33
|
|
|
|
|
26
|
34
|
|
33
|
|
|
111
|
$callpack //= caller(1); |
27
|
|
|
|
|
|
|
|
28
|
34
|
|
66
|
|
|
375
|
while ($arglist and @$arglist >= 2 |
|
|
|
66
|
|
|
|
|
|
|
|
100
|
|
|
|
|
29
|
|
|
|
|
|
|
and defined $arglist->[1] |
30
|
|
|
|
|
|
|
and $arglist->[1] =~ /^-(.+)/) { |
31
|
2
|
|
|
|
|
8
|
splice @$arglist, 1, 1; |
32
|
2
|
50
|
|
|
|
54
|
my $sub = $target->can('_import_' . $1) |
33
|
|
|
|
|
|
|
or carp "Unknown flag $1 for target class $target"; |
34
|
2
|
|
|
|
|
10
|
$sub->($target, $callpack); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Called like: use Foo -as_base; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _import_as_base { |
41
|
2
|
|
|
2
|
|
6
|
my ($myPack, $callpack) = @_; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
{ |
44
|
2
|
|
|
|
|
5
|
my $sym = globref($callpack, 'ISA'); |
|
2
|
|
|
|
|
12
|
|
45
|
2
|
|
|
|
|
7
|
my $isa; |
46
|
2
|
50
|
|
|
|
5
|
unless ($isa = *{$sym}{ARRAY}) { |
|
2
|
|
|
|
|
12
|
|
47
|
0
|
|
|
|
|
0
|
*$sym = $isa = []; |
48
|
|
|
|
|
|
|
} |
49
|
2
|
|
|
|
|
13
|
my $using_c3 = mro::get_mro($callpack) eq 'c3'; |
50
|
2
|
50
|
|
|
|
8
|
unless (grep {$_ eq $myPack} @$isa) { |
|
0
|
|
|
|
|
0
|
|
51
|
2
|
50
|
|
|
|
9
|
if ($using_c3) { |
52
|
0
|
|
|
|
|
0
|
unshift @$isa, $myPack; |
53
|
|
|
|
|
|
|
} else { |
54
|
2
|
|
|
|
|
44
|
push @$isa, $myPack; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# Fill $callpack's %FIELDS, by current ISA. |
60
|
2
|
|
|
|
|
14
|
YATT::Lite::MFields->define_fields($callpack); |
61
|
|
|
|
|
|
|
|
62
|
2
|
|
|
|
|
11
|
my $sym = globref($callpack, 'MY'); |
63
|
2
|
50
|
|
|
|
7
|
YATT::Lite::Util::define_const($sym, $callpack) unless *{$sym}{CODE}; |
|
2
|
|
|
|
|
14
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |