line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tree::Template::Declare::DAG_Node; |
2
|
3
|
|
|
3
|
|
12
|
use strict; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
103
|
|
3
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
72
|
|
4
|
3
|
|
|
3
|
|
10
|
use Carp; |
|
3
|
|
|
|
|
2
|
|
|
3
|
|
|
|
|
1021
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION='0.6'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
3
|
|
|
3
|
0
|
7
|
my ($class,$node_class)=@_; |
10
|
3
|
|
50
|
|
|
745
|
$node_class||='Tree::DAG_Node'; |
11
|
|
|
|
|
|
|
|
12
|
3
|
50
|
|
|
|
186
|
eval "require $node_class" or ## no critic (ProhibitStringyEval) |
13
|
|
|
|
|
|
|
croak "Can't load $node_class: $@"; ## no critic (ProhibitPunctuationVars) |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
return bless {nc=>$node_class},$class; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new_tree { |
19
|
0
|
|
|
0
|
0
|
|
my ($self)=@_; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
return bless [],'Tree::Template::Declare::DAG_Node::Tree'; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub finalize_tree { |
25
|
0
|
|
|
0
|
0
|
|
my ($self,$tree)=@_; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
return $tree->[0]; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub new_node { |
31
|
0
|
|
|
0
|
0
|
|
my ($self)=@_; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
return $self->{nc}->new(); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub add_child_node { |
37
|
0
|
|
|
0
|
0
|
|
my ($self,$parent,$child)=@_; |
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
if ($parent->isa('Tree::Template::Declare::DAG_Node::Tree')) { |
40
|
0
|
|
|
|
|
|
push @{$parent},$child; |
|
0
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
return $parent; |
42
|
|
|
|
|
|
|
} |
43
|
0
|
|
|
|
|
|
return $parent->add_daughter($child); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub set_node_name { |
47
|
0
|
|
|
0
|
0
|
|
my ($self,$node,$name)=@_; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
return $node->name($name); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub set_node_attributes { |
53
|
0
|
|
|
0
|
0
|
|
my ($self,$node,$attrs)=@_; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my %all_attributes=( |
56
|
0
|
|
|
|
|
|
%{$node->attributes}, |
57
|
0
|
|
|
|
|
|
%{$attrs}, |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
return $node->attributes(\%all_attributes); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
__END__ |