HTML/NameVisitor.pm

filter: Statementstmt 3.3% 8 / 241 Branchbran 0.0% 0 / 62 Conditioncond 0.0% 0 / 30 MC/DCmcdc 0.0% 0 / 17 Subroutinesub 4.5% 2 / 44 Podpod 0.0% 0 / 38 totaltotal 2.3% 10 / 432 CC 44 SCAR 35.2
CC
44
Cov
2%
visitWideStringLiteral
90.0
visitWideCharacterLiteral
72.0
_get_name
56.0
CRAP 33.8
« HTML/CommentVisitor.pm ↑ Summary HTML.pm »
1
2 #
3 # Interface Definition Language (OMG IDL CORBA v3.0)
4 #
5
6 package CORBA::HTML::NameVisitor;
7
8 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10
11 1 our $VERSION = '2.60';
12
13 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
14 0 my $proto = shift;
15 0 ▶ my $class = ref($proto) || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
16 0 my $self = {};
17 0 bless $self, $class;
18 0 my ($parser) = @_;
19 0 $self->{symbtab} = $parser->YYData->{symbtab};
20 0 return $self;
21 }
22
23 0 ▶sub _get_name {
Subroutine _get_name: not called CC=7 SCAR=40.3
24 0 my $self = shift;
25 0 my ($node, $scope) = @_;
26 0 my $full = $node->{full};
27 0 $full =~ s/^:://;
28 0 my @list_name = split /::/, $full;
29 0 my @list_scope = split /::/, $scope;
30 0 ▶ while (@list_scope) {
Branch: 1 branch
BranchTrueFalseTotal
if (@list_scope) 0 0 0
31 0 ▶ last if ($list_scope[0] ne $list_name[0]);
Branch: 1 branch
BranchTrueFalseTotal
if $list_scope[0] ne $list_name[0] 0 0 0
32 0 shift @list_name;
33 0 shift @list_scope;
34 }
35 0 my $name = join '::', @list_name;
36 0 my $fragment = $node->{idf};
37 0 ▶ $fragment = $node->{html_name} if (exists $node->{html_name});
Branch: 1 branch
BranchTrueFalseTotal
if exists $node->{"html_name"} 0 0 0
38 0 ▶ if (exists $node->{file_html}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $node->{'file_html'}) { } 0 0 0
elsif ($node->isa('BaseInterface') or $node->isa('ForwardBaseInterface')) { } 0 0 0
39 0 my $a = '<a href="' . $node->{file_html} . '#' . $fragment . '">' . $name . '</a>';
40 0 return $a;
41 }
42 ▶ elsif ( $node->isa('BaseInterface') or $node->isa('ForwardBaseInterface') ) {
Condition0%0/3
$node->isa("BaseInterface") or $node->isa("ForwardBaseInterface")
l!l&&r!l&&!r
000
MC/DC0%0/2
$node->isa("BaseInterface") or $node->isa("ForwardBaseInterface")
$node->isa("BaseInterface") $node->isa("ForwardBaseInterface")
Truth table0%0/3
A or B
A= $node->isa("BaseInterface")B= $node->isa("ForwardBaseInterface")
ABresult
1X1
011
000
43 0 my $filename = $node->{full};
44 0 $filename =~ s/::/_/g;
45 0 $filename .= '.html';
46 0 my $a = '<a href="' . $filename . '#' . $fragment . '">' . $name . '</a>';
47 0 return $a;
48 }
49 else {
50 0 return $name;
51 }
52 }
53
54 0 ▶sub _get_lexeme {
Subroutine _get_lexeme: not called CC=1 SCAR=6.9
55 0 my $self = shift;
56 0 my ($node) = @_;
57 0 my $value = $node->{lexeme};
58 0 $value =~ s/&/"&amp;"/g;
59 0 $value =~ s/</"&lt;"/g;
60 0 $value =~ s/>/"&gt;"/g;
61 0 return $value;
62 }
63
64 0 ▶sub _get_defn {
Subroutine _get_defn: not called CC=2 SCAR=17.9
65 0 my $self = shift;
66 0 my ($defn) = @_;
67 0 ▶ if (ref $defn) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $defn) { } 0 0 0
68 0 return $defn;
69 }
70 else {
71 0 return $self->{symbtab}->Lookup($defn);
72 }
73 }
74
75 #
76 # 3.8 Interface Declaration
77 #
78
79 0 ▶sub visitBaseInterface {
Subroutine visitBaseInterface: not called CC=1 SCAR=6.9
Pod undocumented
80 0 my $self = shift;
81 0 my ($node, $scope) = @_;
82 0 return $self->_get_name($node, $scope);
83 }
84
85 0 ▶sub visitForwardBaseInterface {
Subroutine visitForwardBaseInterface: not called CC=1 SCAR=6.9
Pod undocumented
86 0 my $self = shift;
87 0 my ($node, $scope) = @_;
88 0 return $self->_get_name($node, $scope);
89 }
90
91 #
92 # 3.10 Constant Declaration
93 #
94
95 0 ▶sub visitConstant {
Subroutine visitConstant: not called CC=1 SCAR=6.9
Pod undocumented
96 0 my $self = shift;
97 0 my ($node, $scope) = @_;
98 0 return $self->_get_name($node, $scope);
99 }
100
101 0 ▶sub _Eval {
Subroutine _Eval: not called CC=7 SCAR=40.3
102 0 my $self = shift;
103 0 my ($list_expr, $scope, $type) = @_;
104 0 my $elt = pop @{$list_expr};
105 0 ▶ unless (ref $elt) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $elt) 0 0 0
106 0 $elt = $self->{symbtab}->Lookup($elt);
107 }
108 0 ▶ if ( $elt->isa('BinaryOp') ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($elt->isa('BinaryOp')) { } 0 0 0
elsif ($elt->isa('UnaryOp')) { } 0 0 0
elsif ($elt->isa('Constant') or $elt->isa('Enum') or $elt->isa('Literal')) { } 0 0 0
109 0 my $right = $self->_Eval($list_expr, $scope, $type);
110 0 my $left = $self->_Eval($list_expr, $scope, $type);
111 0 return q{(} . $left . q{ } . $elt->{op} . q{ } . $right . q{)};
112 }
113 elsif ( $elt->isa('UnaryOp') ) {
114 0 my $right = $self->_Eval($list_expr, $scope, $type);
115 0 return $elt->{op} . $right;
116 }
117 ▶ elsif ( $elt->isa('Constant')
Condition0%0/6
$elt->isa("Constant") or $elt->isa("Enum") or $elt->isa("Literal")
l!l&&r!l&&!r
000
$elt->isa("Constant") or $elt->isa("Enum")
l!l&&r!l&&!r
000
MC/DC0%0/3
$elt->isa("Constant") or $elt->isa("Enum") or $elt->isa("Literal")
$elt->isa("Constant") $elt->isa("Enum") $elt->isa("Literal")
Truth table0%0/4
A or B or C
A= $elt->isa("Constant")B= $elt->isa("Enum")C= $elt->isa("Literal")
ABCresult
1XX1
01X1
0011
0000
118 or $elt->isa('Enum')
119 or $elt->isa('Literal') ) {
120 0 return $elt->visit($self, $scope, $type);
121 }
122 else {
123 0 warn __PACKAGE__," _Eval: INTERNAL ERROR ",ref $elt,".\n";
124 0 return undef;
125 }
126 }
127
128 0 ▶sub visitExpression {
Subroutine visitExpression: not called CC=1 SCAR=6.9
Pod undocumented
129 0 my $self = shift;
130 0 my ($node, $scope) = @_;
131 0 my @list_expr = @{$node->{list_expr}}; # create a copy
132 0 return $self->_Eval(\@list_expr, $scope, $node->{type});
133 }
134
135 0 ▶sub visitEnum {
Subroutine visitEnum: not called CC=1 SCAR=6.9
Pod undocumented
136 0 my $self = shift;
137 0 my ($node, $attr) = @_;
138 0 return $node->{idf};
139 }
140
141 0 ▶sub visitIntegerLiteral {
Subroutine visitIntegerLiteral: not called CC=1 SCAR=6.9
Pod undocumented
142 0 my $self = shift;
143 0 my ($node) = @_;
144 0 return $self->_get_lexeme($node);
145 }
146
147 0 ▶sub visitStringLiteral {
Subroutine visitStringLiteral: not called CC=7 SCAR=40.3
Pod undocumented
148 0 my $self = shift;
149 0 my ($node) = @_;
150 0 my @list = unpack 'C*', $node->{value};
151 0 my $str = q{"};
152 0 foreach (@list) {
153 0 ▶ if ($_ < 32 or $_ >= 127) {
Branch: 4 branches
BranchTrueFalseTotal
if ($_ < 32 or $_ >= 127) { } 0 0 0
elsif ($_ == 38) { } 0 0 0
elsif ($_ == 60) { } 0 0 0
elsif ($_ == 62) { } 0 0 0
Condition0%0/3
$_ < 32 or $_ >= 127
l!l&&r!l&&!r
000
MC/DC0%0/2
$_ < 32 or $_ >= 127
$_ < 32 $_ >= 127
Truth table0%0/3
A or B
A= $_ < 32B= $_ >= 127
ABresult
1X1
011
000
154 0 $str .= sprintf "\\x%02x", $_;
155 }
156 elsif ($_ == ord '&') {
157 0 $str .= '&amp;';
158 }
159 elsif ($_ == ord '<') {
160 0 $str .= '&lt;';
161 }
162 elsif ($_ == ord '>') {
163 0 $str .= '&gt;';
164 }
165 else {
166 0 $str .= chr $_;
167 }
168 }
169 0 $str .= q{"};
170 0 return $str;
171 }
172
173 0 ▶sub visitWideStringLiteral {
Subroutine visitWideStringLiteral: not called CC=9 SCAR=45.0
Pod undocumented
174 0 my $self = shift;
175 0 my ($node) = @_;
176 0 my @list = unpack 'C*', $node->{value};
177 0 my $str = q{L"};
178 0 foreach (@list) {
179 0 ▶ if ($_ < 32 or ($_ >= 128 and $_ < 256)) {
Branch: 5 branches
BranchTrueFalseTotal
if ($_ < 32 or $_ >= 128 and $_ < 256) { } 0 0 0
elsif ($_ >= 256) { } 0 0 0
elsif ($_ == 38) { } 0 0 0
elsif ($_ == 60) { } 0 0 0
elsif ($_ == 62) { } 0 0 0
Condition0%0/6
$_ < 32 or $_ >= 128 and $_ < 256
l!l&&r!l&&!r
000
$_ >= 128 and $_ < 256
!ll&&!rl&&r
000
MC/DC0%0/3
$_ < 32 or $_ >= 128 and $_ < 256
$_ < 32 $_ >= 128 $_ < 256
Truth table0%0/4
A or B and C
A= $_ < 32B= $_ >= 128C= $_ < 256
ABCresult
1XX1
0111
00X0
0100
180 0 $str .= sprintf "\\x%02x", $_;
181 }
182 elsif ($_ >= 256) {
183 0 $str .= sprintf "\\u%04x", $_;
184 }
185 elsif ($_ == ord '&') {
186 0 $str .= '&amp;';
187 }
188 elsif ($_ == ord '<') {
189 0 $str .= '&lt;';
190 }
191 elsif ($_ == ord '>') {
192 0 $str .= '&gt;';
193 }
194 else {
195 0 $str .= chr $_;
196 }
197 }
198 0 $str .= q{"};
199 0 return $str;
200 }
201
202 0 ▶sub visitCharacterLiteral {
Subroutine visitCharacterLiteral: not called CC=6 SCAR=37.4
Pod undocumented
203 0 my $self = shift;
204 0 my ($node) = @_;
205 0 my @list = unpack 'C', $node->{value};
206 0 my $c = $list[0];
207 0 my $str = q{'};
208 0 ▶ if ($c < 32 or $c >= 128) {
Branch: 4 branches
BranchTrueFalseTotal
if ($c < 32 or $c >= 128) { } 0 0 0
elsif ($c == 38) { } 0 0 0
elsif ($c == 60) { } 0 0 0
elsif ($c == 62) { } 0 0 0
Condition0%0/3
$c < 32 or $c >= 128
l!l&&r!l&&!r
000
MC/DC0%0/2
$c < 32 or $c >= 128
$c < 32 $c >= 128
Truth table0%0/3
A or B
A= $c < 32B= $c >= 128
ABresult
1X1
011
000
209 0 $str .= sprintf "\\x%02x", $c;
210 }
211 elsif ($c == ord '&') {
212 0 $str .= '&amp;';
213 }
214 elsif ($c == ord '<') {
215 0 $str .= '&lt;';
216 }
217 elsif ($c == ord '>') {
218 0 $str .= '&gt;';
219 }
220 else {
221 0 $str .= chr $c;
222 }
223 0 $str .= q{'};
224 0 return $str;
225 }
226
227 0 ▶sub visitWideCharacterLiteral {
Subroutine visitWideCharacterLiteral: not called CC=8 SCAR=42.8
Pod undocumented
228 0 my $self = shift;
229 0 my ($node) = @_;
230 0 my @list = unpack 'C', $node->{value};
231 0 my $c = $list[0];
232 0 my $str = q{L'};
233 0 ▶ if ($c < 32 or ($c >= 128 and $c < 256)) {
Branch: 5 branches
BranchTrueFalseTotal
if ($c < 32 or $c >= 128 and $c < 256) { } 0 0 0
elsif ($c >= 256) { } 0 0 0
elsif ($c == 38) { } 0 0 0
elsif ($c == 60) { } 0 0 0
elsif ($c == 62) { } 0 0 0
Condition0%0/6
$c < 32 or $c >= 128 and $c < 256
l!l&&r!l&&!r
000
$c >= 128 and $c < 256
!ll&&!rl&&r
000
MC/DC0%0/3
$c < 32 or $c >= 128 and $c < 256
$c < 32 $c >= 128 $c < 256
Truth table0%0/4
A or B and C
A= $c < 32B= $c >= 128C= $c < 256
ABCresult
1XX1
0111
00X0
0100
234 0 $str .= sprintf "\\x%02x", $c;
235 }
236 elsif ($c >= 256) {
237 0 $str .= sprintf "\\u%04x", $c;
238 }
239 elsif ($c == ord '&') {
240 0 $str .= '&amp;';
241 }
242 elsif ($c == ord '<') {
243 0 $str .= '&lt;';
244 }
245 elsif ($c == ord '>') {
246 0 $str .= '&gt;';
247 }
248 else {
249 0 $str .= chr $c;
250 }
251 0 $str .= q{'};
252 0 return $str;
253 }
254
255 0 ▶sub visitFixedPtLiteral {
Subroutine visitFixedPtLiteral: not called CC=1 SCAR=6.9
Pod undocumented
256 0 my $self = shift;
257 0 my ($node) = @_;
258 0 return $self->_get_lexeme($node);
259 }
260
261 0 ▶sub visitFloatingPtLiteral {
Subroutine visitFloatingPtLiteral: not called CC=1 SCAR=6.9
Pod undocumented
262 0 my $self = shift;
263 0 my ($node) = @_;
264 0 return $self->_get_lexeme($node);
265 }
266
267 0 ▶sub visitBooleanLiteral {
Subroutine visitBooleanLiteral: not called CC=1 SCAR=6.9
Pod undocumented
268 0 my $self = shift;
269 0 my ($node) = @_;
270 0 return $node->{value};
271 }
272
273 #
274 # 3.11 Type Declaration
275 #
276
277 0 ▶sub visitTypeDeclarator {
Subroutine visitTypeDeclarator: not called CC=1 SCAR=6.9
Pod undocumented
278 0 my $self = shift;
279 0 my ($node, $scope) = @_;
280 0 return $self->_get_name($node, $scope);
281 }
282
283 0 ▶sub visitNativeType {
Subroutine visitNativeType: not called CC=1 SCAR=6.9
Pod undocumented
284 0 my $self = shift;
285 0 my ($node, $scope) = @_;
286 0 return $self->_get_name($node, $scope);
287 }
288
289 0 ▶sub visitBasicType {
Subroutine visitBasicType: not called CC=1 SCAR=6.9
Pod undocumented
290 0 my $self = shift;
291 0 my ($node) = @_;
292 0 return $node->{value};
293 }
294
295 0 ▶sub visitAnyType {
Subroutine visitAnyType: not called CC=1 SCAR=6.9
Pod undocumented
296 0 my $self = shift;
297 0 my ($node) = @_;
298 0 return $node->{value};
299 }
300
301 0 ▶sub visitStructType {
Subroutine visitStructType: not called CC=1 SCAR=6.9
Pod undocumented
302 0 my $self = shift;
303 0 my ($node, $scope) = @_;
304 0 return $self->_get_name($node, $scope);
305 }
306
307 0 ▶sub visitUnionType {
Subroutine visitUnionType: not called CC=1 SCAR=6.9
Pod undocumented
308 0 my $self = shift;
309 0 my ($node, $scope) = @_;
310 0 return $self->_get_name($node, $scope);
311 }
312
313 0 ▶sub visitEnumType {
Subroutine visitEnumType: not called CC=1 SCAR=6.9
Pod undocumented
314 0 my $self = shift;
315 0 my ($node, $scope) = @_;
316 0 return $self->_get_name($node, $scope);
317 }
318
319 0 ▶sub visitSequenceType {
Subroutine visitSequenceType: not called CC=2 SCAR=17.9
Pod undocumented
320 0 my $self = shift;
321 0 my ($node, $scope) = @_;
322 0 my $type = $self->_get_defn($node->{type});
323 0 my $name = $node->{value} . '&lt;';
324 0 $name .= $type->visit($self, $scope);
325 0 ▶ if (exists $node->{max}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $node->{"max"}) 0 0 0
326 0 $name .= q{,};
327 0 $name .= $node->{max}->visit($self, $scope);
328 }
329 0 $name .= '&gt;';
330 0 return $name;
331 }
332
333 0 ▶sub visitStringType {
Subroutine visitStringType: not called CC=2 SCAR=17.9
Pod undocumented
334 0 my $self = shift;
335 0 my ($node, $scope) = @_;
336 0 ▶ if (exists $node->{max}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $node->{'max'}) { } 0 0 0
337 0 my $name = $node->{value} . '&lt;';
338 0 $name .= $node->{max}->visit($self, $scope);
339 0 $name .= '&gt;';
340 0 return $name;
341 }
342 else {
343 0 return $node->{value};
344 }
345 }
346
347 0 ▶sub visitWideStringType {
Subroutine visitWideStringType: not called CC=2 SCAR=17.9
Pod undocumented
348 0 my $self = shift;
349 0 my ($node, $scope) = @_;
350 0 ▶ if (exists $node->{max}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $node->{'max'}) { } 0 0 0
351 0 my $name = $node->{value} . '&lt;';
352 0 $name .= $node->{max}->visit($self, $scope);
353 0 $name .= '&gt;';
354 0 return $name;
355 }
356 else {
357 0 return $node->{value};
358 }
359 }
360
361 0 ▶sub visitFixedPtType {
Subroutine visitFixedPtType: not called CC=1 SCAR=6.9
Pod undocumented
362 0 my $self = shift;
363 0 my ($node, $scope) = @_;
364 0 my $name = $node->{value} . '&lt;';
365 0 $name .= $node->{d}->visit($self, $scope);
366 0 $name .= q{,};
367 0 $name .= $node->{s}->visit($self, $scope);
368 0 $name .= '&gt;';
369 0 return $name;
370 }
371
372 0 ▶sub visitFixedPtConstType {
Subroutine visitFixedPtConstType: not called CC=1 SCAR=6.9
Pod undocumented
373 0 my $self = shift;
374 0 my ($node, $scope) = @_;
375 0 return $node->{value};
376 }
377
378 0 ▶sub visitVoidType {
Subroutine visitVoidType: not called CC=1 SCAR=6.9
Pod undocumented
379 0 my $self = shift;
380 0 my ($node) = @_;
381 0 return $node->{value};
382 }
383
384 0 ▶sub visitValueBaseType {
Subroutine visitValueBaseType: not called CC=1 SCAR=6.9
Pod undocumented
385 0 my $self = shift;
386 0 my ($node) = @_;
387 0 return $node->{value};
388 }
389
390 #
391 # 3.12 Exception Declaration
392 #
393
394 0 ▶sub visitException {
Subroutine visitException: not called CC=1 SCAR=6.9
Pod undocumented
395 0 my $self = shift;
396 0 my ($node, $scope) = @_;
397 0 return $self->_get_name($node, $scope);
398 }
399
400 #
401 # 3.13 Operation Declaration
402 #
403
404 0 ▶sub visitOperation {
Subroutine visitOperation: not called CC=1 SCAR=6.9
Pod undocumented
405 0 my $self = shift;
406 0 my ($node, $scope) = @_;
407 0 return $self->_get_name($node, $scope);
408 }
409
410 #
411 # 3.14 Attribute Declaration
412 #
413
414 0 ▶sub visitAttribute {
Subroutine visitAttribute: not called CC=1 SCAR=6.9
Pod undocumented
415 0 my $self = shift;
416 0 my ($node, $scope) = @_;
417 0 return $self->_get_name($node, $scope);
418 }
419
420 #
421 # 3.17 Component Declaration
422 #
423
424 0 ▶sub visitProvides {
Subroutine visitProvides: not called CC=1 SCAR=6.9
Pod undocumented
425 0 my $self = shift;
426 0 my ($node, $scope) = @_;
427 0 return $self->_get_name($node, $scope);
428 }
429
430 0 ▶sub visitUses {
Subroutine visitUses: not called CC=1 SCAR=6.9
Pod undocumented
431 0 my $self = shift;
432 0 my ($node, $scope) = @_;
433 0 return $self->_get_name($node, $scope);
434 }
435
436 0 ▶sub visitPublishes {
Subroutine visitPublishes: not called CC=1 SCAR=6.9
Pod undocumented
437 0 my $self = shift;
438 0 my ($node, $scope) = @_;
439 0 return $self->_get_name($node, $scope);
440 }
441
442 0 ▶sub visitEmits {
Subroutine visitEmits: not called CC=1 SCAR=6.9
Pod undocumented
443 0 my $self = shift;
444 0 my ($node, $scope) = @_;
445 0 return $self->_get_name($node, $scope);
446 }
447
448 0 ▶sub visitConsumes {
Subroutine visitConsumes: not called CC=1 SCAR=6.9
Pod undocumented
449 0 my $self = shift;
450 0 my ($node, $scope) = @_;
451 0 return $self->_get_name($node, $scope);
452 }
453
454 #
455 # 3.18 Home Declaration
456 #
457
458 0 ▶sub visitFactory {
Subroutine visitFactory: not called CC=1 SCAR=6.9
Pod undocumented
459 0 my $self = shift;
460 0 my ($node, $scope) = @_;
461 0 return $self->_get_name($node, $scope);
462 }
463
464 0 ▶sub visitFinder {
Subroutine visitFinder: not called CC=1 SCAR=6.9
Pod undocumented
465 0 my $self = shift;
466 0 my ($node, $scope) = @_;
467 0 return $self->_get_name($node, $scope);
468 }
469
470 1 1;
471
« HTML/CommentVisitor.pm ↑ Summary HTML.pm »