line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
############################################################################# |
2
|
|
|
|
|
|
|
# A node in the graph (includes a type field) |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# (c) by Tels 2004-2005. |
5
|
|
|
|
|
|
|
############################################################################# |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Graph::Flowchart::Node; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
@ISA = qw/Graph::Easy::Node Exporter/; |
10
|
|
|
|
|
|
|
$VERSION = '0.06'; |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
25320
|
use Graph::Easy::Node; |
|
2
|
|
|
|
|
73045
|
|
|
2
|
|
|
|
|
82
|
|
13
|
2
|
|
|
2
|
|
18
|
use Exporter; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
140
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
@EXPORT_OK = qw/ |
16
|
|
|
|
|
|
|
N_START N_END N_BLOCK N_IF N_THEN N_ELSE N_JOINT N_END N_FOR N_BODY |
17
|
|
|
|
|
|
|
N_USE |
18
|
|
|
|
|
|
|
N_SUB |
19
|
|
|
|
|
|
|
N_CONTINUE N_GOTO N_BREAK N_RETURN N_NEXT N_LAST N_WHILE N_UNTIL |
20
|
|
|
|
|
|
|
/; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
############################################################################# |
23
|
|
|
|
|
|
|
############################################################################# |
24
|
|
|
|
|
|
|
|
25
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
107
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use constant { |
28
|
2
|
|
|
|
|
979
|
N_START => 1, |
29
|
|
|
|
|
|
|
N_END => 2, |
30
|
|
|
|
|
|
|
N_BLOCK => 3, |
31
|
|
|
|
|
|
|
N_IF => 4, |
32
|
|
|
|
|
|
|
N_THEN => 5, |
33
|
|
|
|
|
|
|
N_ELSE => 6, |
34
|
|
|
|
|
|
|
N_JOINT => 7, |
35
|
|
|
|
|
|
|
N_FOR => 8, |
36
|
|
|
|
|
|
|
N_BODY => 9, |
37
|
|
|
|
|
|
|
N_CONTINUE => 10, |
38
|
|
|
|
|
|
|
N_GOTO => 11, |
39
|
|
|
|
|
|
|
N_RETURN => 12, |
40
|
|
|
|
|
|
|
N_BREAK => 13, |
41
|
|
|
|
|
|
|
N_NEXT => 14, |
42
|
|
|
|
|
|
|
N_LAST => 15, |
43
|
|
|
|
|
|
|
N_SUB => 16, |
44
|
|
|
|
|
|
|
N_USE => 17, |
45
|
|
|
|
|
|
|
N_WHILE => 18, |
46
|
|
|
|
|
|
|
N_UNTIL => 19, |
47
|
2
|
|
|
2
|
|
10
|
}; |
|
2
|
|
|
|
|
3
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $subclass = { |
50
|
|
|
|
|
|
|
N_START() => 'start', |
51
|
|
|
|
|
|
|
N_END() => 'end', |
52
|
|
|
|
|
|
|
N_BLOCK() => 'block', |
53
|
|
|
|
|
|
|
N_BODY() => 'block', |
54
|
|
|
|
|
|
|
N_CONTINUE() => 'block', |
55
|
|
|
|
|
|
|
N_THEN() => 'block', |
56
|
|
|
|
|
|
|
N_IF() => 'if', |
57
|
|
|
|
|
|
|
N_ELSE() => 'else', |
58
|
|
|
|
|
|
|
N_JOINT() => 'joint', |
59
|
|
|
|
|
|
|
N_FOR() => 'for', |
60
|
|
|
|
|
|
|
N_GOTO() => 'goto', |
61
|
|
|
|
|
|
|
N_RETURN() => 'return', |
62
|
|
|
|
|
|
|
N_NEXT() => 'next', |
63
|
|
|
|
|
|
|
N_BREAK() => 'break', |
64
|
|
|
|
|
|
|
N_LAST() => 'last', |
65
|
|
|
|
|
|
|
N_SUB() => 'sub', |
66
|
|
|
|
|
|
|
N_USE() => 'use', |
67
|
|
|
|
|
|
|
N_WHILE() => 'while', |
68
|
|
|
|
|
|
|
N_UNTIL() => 'until', |
69
|
|
|
|
|
|
|
}; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
############################################################################# |
72
|
|
|
|
|
|
|
############################################################################# |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub new |
75
|
|
|
|
|
|
|
{ |
76
|
10
|
|
|
10
|
1
|
5077
|
my ($class, $label, $type, $labelname, $group) = @_; |
77
|
|
|
|
|
|
|
|
78
|
10
|
|
|
|
|
34
|
my $self = bless {}, $class; |
79
|
|
|
|
|
|
|
|
80
|
10
|
100
|
|
|
|
33
|
$type = N_START() unless defined $type; |
81
|
|
|
|
|
|
|
|
82
|
10
|
|
|
|
|
49
|
$self->{_type} = $type; |
83
|
10
|
100
|
|
|
|
25
|
$self->{_label} = $labelname if defined $labelname; |
84
|
10
|
|
|
|
|
36
|
$self->{id} = Graph::Easy::Base::_new_id(); |
85
|
|
|
|
|
|
|
|
86
|
10
|
50
|
|
|
|
54
|
$label = '' unless defined $label; |
87
|
|
|
|
|
|
|
# convert newlines into '\n' |
88
|
10
|
|
|
|
|
22
|
$label =~ s/\n/\\n/g; |
89
|
|
|
|
|
|
|
|
90
|
10
|
|
|
|
|
75
|
$self->_init( { label => $label, name => $self->{id} } ); |
91
|
|
|
|
|
|
|
|
92
|
10
|
|
50
|
|
|
347
|
$self->sub_class($subclass->{$type} || 'unknown'); |
93
|
|
|
|
|
|
|
|
94
|
10
|
50
|
|
|
|
138
|
if (ref $group) |
95
|
|
|
|
|
|
|
{ |
96
|
0
|
|
|
|
|
0
|
$group->add_node($self); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
10
|
|
|
|
|
32
|
$self; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub _set_type |
103
|
|
|
|
|
|
|
{ |
104
|
0
|
|
|
0
|
|
|
my $self = shift; |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
$self->{_type} = shift; |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
$self; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |
112
|
|
|
|
|
|
|
__END__ |