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