line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::YADV::Structure::Base; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
71
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
49
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
12
|
use Data::YADV::Structure; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1292
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
70
|
|
|
70
|
0
|
104
|
my ($class, $structure, $path, $parent) = @_; |
10
|
|
|
|
|
|
|
|
11
|
70
|
|
100
|
|
|
693
|
bless { |
12
|
|
|
|
|
|
|
structure => $structure, |
13
|
|
|
|
|
|
|
path => $path || [], |
14
|
|
|
|
|
|
|
parent => $parent |
15
|
|
|
|
|
|
|
}, $class; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
78
|
|
|
78
|
0
|
316
|
sub get_structure { $_[0]->{structure} } |
19
|
11
|
|
|
11
|
0
|
29
|
sub get_parent { $_[0]->{parent} } |
20
|
1
|
|
|
1
|
0
|
11
|
sub get_path { $_[0]->{path} } |
21
|
4
|
|
|
4
|
0
|
165
|
sub get_type { lc((split /::/, (ref $_[0]))[-1]) } |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub get_child { |
24
|
103
|
|
|
103
|
0
|
1231
|
my ($self, @path) = @_; |
25
|
|
|
|
|
|
|
|
26
|
103
|
100
|
|
|
|
527
|
return $self unless @path; |
27
|
|
|
|
|
|
|
|
28
|
57
|
|
|
|
|
88
|
my $entry = shift @path; |
29
|
|
|
|
|
|
|
|
30
|
57
|
|
|
|
|
67
|
my $node; |
31
|
57
|
100
|
|
|
|
115
|
if ($entry eq '..') { |
32
|
4
|
|
|
|
|
15
|
$node = $self->get_parent; |
33
|
|
|
|
|
|
|
} else { |
34
|
53
|
|
|
|
|
155
|
$node = $self->_get_child_node($entry); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
57
|
100
|
|
|
|
304
|
$node && $node->get_child(@path); |
38
|
|
|
|
|
|
|
}; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub get_root { |
41
|
5
|
|
|
5
|
0
|
6
|
my $self = shift; |
42
|
|
|
|
|
|
|
|
43
|
5
|
|
|
|
|
14
|
my $parent = $self->get_parent; |
44
|
5
|
100
|
|
|
|
15
|
return $self unless $parent; |
45
|
4
|
|
|
|
|
22
|
$parent->get_root; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub get_path_string { |
49
|
13
|
|
|
13
|
0
|
27
|
my ($self, @path) = @_; |
50
|
13
|
|
|
|
|
14
|
_stringify_path(@{$self->{path}}, @path); |
|
13
|
|
|
|
|
37
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _build_node { |
54
|
49
|
|
|
49
|
|
73
|
my ($self, $path, $value) = @_; |
55
|
|
|
|
|
|
|
|
56
|
49
|
|
|
|
|
67
|
Data::YADV::Structure->new($value, [@{$self->{path}}, $path], $self); |
|
49
|
|
|
|
|
209
|
|
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _stringify_path { |
60
|
13
|
|
|
13
|
|
54
|
join '->', @_; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub die { |
64
|
0
|
|
|
0
|
0
|
|
my ($self, $message, $path) = @_; |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my @path = @{$self->{path}}; |
|
0
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
push @path, $path if defined $path; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
die _stringify_path('$structure', @path) . ': ' .$message; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |