line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Language::Homespring::Visualise::GraphViz; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = 0.04; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
923
|
use warnings; |
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
34
|
|
6
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
7
|
1
|
|
|
1
|
|
768
|
use GraphViz; |
|
1
|
|
|
1
|
|
4
|
|
|
1
|
|
|
|
|
781
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
499
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
11
|
0
|
|
|
|
|
|
my $self = bless {}, $class; |
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
|
|
|
my $options = shift; |
14
|
0
|
|
|
|
|
|
$self->{interp} = $options->{interp}; |
15
|
0
|
|
0
|
|
|
|
$self->{spring_col} = $options->{spring_col} || '#C0C0FF'; |
16
|
0
|
|
0
|
|
|
|
$self->{node_col} = $options->{node_col} || 'white'; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
0
|
|
|
|
$self->{fontname} = $options->{fontname} || 'Times'; |
19
|
0
|
|
0
|
|
|
|
$self->{fontsize} = $options->{fontsize} || '12'; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
return $self; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub do { |
25
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
$self->{graph} = GraphViz->new( |
28
|
|
|
|
|
|
|
directed => 0, |
29
|
|
|
|
|
|
|
layout => 'dot', |
30
|
|
|
|
|
|
|
rankdir => 1, |
31
|
|
|
|
|
|
|
epsilon => 1, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
$self->add_node($self->{interp}->{root_node}, 1); |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
return $self->{graph}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub add_node { |
40
|
0
|
|
|
0
|
0
|
|
my ($self, $node, $rank) = @_; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
for(@{$node->{child_nodes}}){ |
|
0
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my $label = $_->{node_name_safe}; |
44
|
0
|
|
|
|
|
|
$label =~ s/\\/\\\\/g; |
45
|
|
|
|
|
|
|
|
46
|
0
|
0
|
|
|
|
|
my $fillcolor = $_->{spring}?$self->{spring_col}:$self->{node_col}; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
$self->{graph}->add_node( |
49
|
|
|
|
|
|
|
$_->{uid}, |
50
|
|
|
|
|
|
|
label => $label, |
51
|
|
|
|
|
|
|
rank => $rank, |
52
|
|
|
|
|
|
|
fillcolor => $fillcolor, |
53
|
|
|
|
|
|
|
style => 'filled', |
54
|
|
|
|
|
|
|
fontname => $self->{fontname}, |
55
|
|
|
|
|
|
|
fontsize => $self->{fontsize}, |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
0
|
0
|
|
|
|
|
$self->{graph}->add_edge( |
59
|
|
|
|
|
|
|
$node->{uid} => $_->{uid}, |
60
|
|
|
|
|
|
|
arrowtail => 'normal', |
61
|
|
|
|
|
|
|
) if ($node->{uid} != $self->{interp}->{root_node}->{uid}); |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
$self->add_node($_, $rank+1); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |