line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2003-2021 by [Mark Overmeer]. |
2
|
|
|
|
|
|
|
# For other contributors see ChangeLog. |
3
|
|
|
|
|
|
|
# See the manual pages for details on the licensing terms. |
4
|
|
|
|
|
|
|
# Pod stripped from pm file by OODoc 2.02. |
5
|
|
|
|
|
|
|
# This code is part of perl distribution OODoc. It is licensed under the |
6
|
|
|
|
|
|
|
# same terms as Perl itself: https://spdx.org/licenses/Artistic-2.0.html |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package OODoc::Text::Subroutine; |
9
|
1
|
|
|
1
|
|
914
|
use vars '$VERSION'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
58
|
|
10
|
|
|
|
|
|
|
$VERSION = '2.02'; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
6
|
use base 'OODoc::Text'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
89
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
31
|
|
15
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
28
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
5
|
use Log::Report 'oodoc'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub init($) |
21
|
0
|
|
|
0
|
0
|
|
{ my ($self, $args) = @_; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
exists $args->{name} |
24
|
0
|
0
|
|
|
|
|
or error __x"no name for subroutine"; |
25
|
|
|
|
|
|
|
|
26
|
0
|
0
|
|
|
|
|
$self->SUPER::init($args) |
27
|
|
|
|
|
|
|
or return; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
$self->{OTS_param} = delete $args->{parameters}; |
30
|
0
|
|
|
|
|
|
$self->{OTS_options} = {}; |
31
|
0
|
|
|
|
|
|
$self->{OTS_defaults} = {}; |
32
|
0
|
|
|
|
|
|
$self->{OTS_diags} = []; |
33
|
0
|
|
|
|
|
|
$self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
#------------------------------------------- |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub extends($) |
40
|
0
|
|
|
0
|
1
|
|
{ my $self = shift; |
41
|
0
|
0
|
|
|
|
|
@_ or return $self->SUPER::extends; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my $super = shift; |
44
|
0
|
0
|
|
|
|
|
if($self->type ne $super->type) |
45
|
0
|
|
|
|
|
|
{ my ($fn1, $ln1) = $self->where; |
46
|
0
|
|
|
|
|
|
my ($fn2, $ln2) = $super->where; |
47
|
0
|
|
|
|
|
|
my ($t1, $t2 ) = ($self->type, $super->type); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
warning __x"subroutine {name}() extended by different type:\n {type1} in {file1} line {line1}\n {type2} in {file2} line {line2}" |
50
|
|
|
|
|
|
|
, name => "$self" |
51
|
|
|
|
|
|
|
, type1 => $t1, file1 => $fn1, line1 => $ln1 |
52
|
|
|
|
|
|
|
, type2 => $t2, file2 => $fn2, line2 => $ln2; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
$self->SUPER::extends($super); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
#------------------------------------------- |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
0
|
1
|
|
sub parameters() {shift->{OTS_param}} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#------------------------------------------- |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub location($) |
67
|
0
|
|
|
0
|
1
|
|
{ my ($self, $manual) = @_; |
68
|
0
|
|
|
|
|
|
my $container = $self->container; |
69
|
0
|
0
|
|
|
|
|
my $super = $self->extends |
70
|
|
|
|
|
|
|
or return $container; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my $superloc = $super->location; |
73
|
0
|
|
|
|
|
|
my $superpath = $superloc->path; |
74
|
0
|
|
|
|
|
|
my $mypath = $container->path; |
75
|
|
|
|
|
|
|
|
76
|
0
|
0
|
|
|
|
|
return $container if $superpath eq $mypath; |
77
|
|
|
|
|
|
|
|
78
|
0
|
0
|
|
|
|
|
if(length $superpath < length $mypath) |
|
|
0
|
|
|
|
|
|
79
|
0
|
0
|
|
|
|
|
{ return $container |
80
|
|
|
|
|
|
|
if substr($mypath, 0, length($superpath)+1) eq "$superpath/"; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
elsif(substr($superpath, 0, length($mypath)+1) eq "$mypath/") |
83
|
0
|
0
|
|
|
|
|
{ if($superloc->isa("OODoc::Text::Chapter")) |
|
|
0
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
{ return $self->manual |
85
|
|
|
|
|
|
|
->chapter($superloc->name); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
elsif($superloc->isa("OODoc::Text::Section")) |
88
|
0
|
|
|
|
|
|
{ return $self->manual |
89
|
|
|
|
|
|
|
->chapter($superloc->chapter->name) |
90
|
|
|
|
|
|
|
->section($superloc->name); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
else |
93
|
0
|
|
|
|
|
|
{ return $self->manual |
94
|
|
|
|
|
|
|
->chapter($superloc->chapter->name) |
95
|
|
|
|
|
|
|
->section($superloc->section->name) |
96
|
|
|
|
|
|
|
->subsection($superloc->name); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
0
|
0
|
|
|
|
|
unless($manual->inherited($self)) |
101
|
0
|
|
|
|
|
|
{ my ($myfn, $myln) = $self->where; |
102
|
0
|
|
|
|
|
|
my ($superfn, $superln) = $super->where; |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
warning __x"subroutine {name}() location conflict:\n {path1} in {file1} line {line1}\n {path2} in {file2} line {line2}" |
105
|
|
|
|
|
|
|
, name => "$self" |
106
|
|
|
|
|
|
|
, path1 => $mypath, file1 => $myfn, line1 => $myln |
107
|
|
|
|
|
|
|
, path2 => $superpath, file2 => $superfn, line2 => $superln; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
$container; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
0
|
1
|
|
sub path() { shift->container->path } |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
#------------------------------------------- |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub default($) |
120
|
0
|
|
|
0
|
1
|
|
{ my ($self, $it) = @_; |
121
|
|
|
|
|
|
|
ref $it |
122
|
0
|
0
|
|
|
|
|
or return $self->{OTS_defaults}{$it}; |
123
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
|
my $name = $it->name; |
125
|
0
|
|
|
|
|
|
$self->{OTS_defaults}{$name} = $it; |
126
|
0
|
|
|
|
|
|
$it; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
#------------------------------------------- |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
0
|
|
|
0
|
1
|
|
sub defaults() { values %{shift->{OTS_defaults}} } |
|
0
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub option($) |
136
|
0
|
|
|
0
|
1
|
|
{ my ($self, $it) = @_; |
137
|
|
|
|
|
|
|
ref $it |
138
|
0
|
0
|
|
|
|
|
or return $self->{OTS_options}{$it}; |
139
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
|
my $name = $it->name; |
141
|
0
|
|
|
|
|
|
$self->{OTS_options}{$name} = $it; |
142
|
0
|
|
|
|
|
|
$it; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub findOption($) |
148
|
0
|
|
|
0
|
1
|
|
{ my ($self, $name) = @_; |
149
|
0
|
|
|
|
|
|
my $option = $self->option($name); |
150
|
0
|
0
|
|
|
|
|
return $option if $option; |
151
|
|
|
|
|
|
|
|
152
|
0
|
0
|
|
|
|
|
my $extends = $self->extends or return; |
153
|
0
|
|
|
|
|
|
$extends->findOption($name); |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
157
|
0
|
|
|
0
|
1
|
|
sub options() { values %{shift->{OTS_options}} } |
|
0
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub diagnostic($) |
161
|
0
|
|
|
0
|
1
|
|
{ my ($self, $diag) = @_; |
162
|
0
|
|
|
|
|
|
push @{$self->{OTS_diags}}, $diag; |
|
0
|
|
|
|
|
|
|
163
|
0
|
|
|
|
|
|
$diag; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
|
167
|
0
|
|
|
0
|
1
|
|
sub diagnostics() { @{shift->{OTS_diags}} } |
|
0
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub collectedOptions(@) |
171
|
0
|
|
|
0
|
1
|
|
{ my ($self, %args) = @_; |
172
|
0
|
|
|
|
|
|
my @extends = $self->extends; |
173
|
0
|
|
|
|
|
|
my %options; |
174
|
0
|
|
|
|
|
|
foreach ($self->extends) |
175
|
0
|
|
|
|
|
|
{ my $options = $_->collectedOptions; |
176
|
0
|
|
|
|
|
|
@options{ keys %$options } = values %$options; |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
0
|
|
|
|
|
|
$options{$_->name}[0] = $_ for $self->options; |
180
|
|
|
|
|
|
|
|
181
|
0
|
|
|
|
|
|
foreach my $default ($self->defaults) |
182
|
0
|
|
|
|
|
|
{ my $name = $default->name; |
183
|
|
|
|
|
|
|
|
184
|
0
|
0
|
|
|
|
|
unless(exists $options{$name}) |
185
|
0
|
|
|
|
|
|
{ my ($fn, $ln) = $default->where; |
186
|
0
|
|
|
|
|
|
warning __x"no option {name} for default in {file} line {line}" |
187
|
|
|
|
|
|
|
, name => $name, file => $fn, line => $ln; |
188
|
0
|
|
|
|
|
|
next; |
189
|
|
|
|
|
|
|
} |
190
|
0
|
|
|
|
|
|
$options{$name}[1] = $default; |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
0
|
|
|
|
|
|
foreach my $option ($self->options) |
194
|
0
|
|
|
|
|
|
{ my $name = $option->name; |
195
|
0
|
0
|
|
|
|
|
next if defined $options{$name}[1]; |
196
|
|
|
|
|
|
|
|
197
|
0
|
|
|
|
|
|
my ($fn, $ln) = $option->where; |
198
|
0
|
|
|
|
|
|
warning __x"no default for option {name} defined in {file} line {line}" |
199
|
|
|
|
|
|
|
, name => $name, file => $fn, line => $ln; |
200
|
|
|
|
|
|
|
|
201
|
0
|
|
|
|
|
|
my $default = $options{$name}[1] = |
202
|
|
|
|
|
|
|
OODoc::Text::Default->new |
203
|
|
|
|
|
|
|
( name => $name, value => 'undef' |
204
|
|
|
|
|
|
|
, subroutine => $self, linenr => $ln |
205
|
|
|
|
|
|
|
); |
206
|
|
|
|
|
|
|
|
207
|
0
|
|
|
|
|
|
$self->default($default); |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
0
|
|
|
|
|
|
\%options; |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
1; |