blib/lib/CORBA/IDLtree.pm

filter: Statementstmt 46.2% 1166 / 2519 Branchbran 41.2% 627 / 1520 Conditioncond 28.5% 142 / 498 MC/DCmcdc 13.5% 38 / 280 Subroutinesub 62.1% 59 / 95 Podpod 25.9% 21 / 81 totaltotal 41.1% 2053 / 4993 CC 978 SCAR 81.4
CC
978
Cov
43%
Parse_File_i
12300.7
get_numeric
1190.0
find_node
992.0
CRAP 3426.9
↑ Summary
1 # CORBA/IDLtree.pm IDL to symbol tree translator
2 # This module is distributed under the same terms as Perl itself.
3 # Copyright (C) 1998-2025, O. Kellogg <olivermkellogg@gail.com>
4 # Main Authors: Oliver Kellogg, Heiko Schroeder
5 #
6 # -----------------------------------------------------------------------------
7 # Ver. | Date | Recent changes (for complete history see file Changes)
8 # -----+----------+------------------------------------------------------------
9 # 2.06 2025-04-20 * In the SUBORDINATES of ENUM, when $enable_comments is set
10 # change the layout for a comment to conform to the REMARK
11 # node layout.
12 # * Change sub info to only print if $verbose is set.
13 # * Fix handling of annotations applied on members of
14 # constructed types.
15 # * On encountering unknown annotation, downgrade severity
16 # from error to warning.
17 # 2.05 2021/06/13 * Increase minimum required perl version to 5.8 due to
18 # addition of "use utf8".
19 # * Add handling of Windows CP-1252 character encoding in
20 # input file:
21 # - Add `use utf8`.
22 # - Require module Encode::Guess.
23 # - In sub get_items:
24 # - On encountering a non printable character call
25 # Encode::Guess->guess.
26 # - If the call returns a ref then a decoder was found
27 # and no special action is required.
28 # - If the call returns "No appropriate encodings found"
29 # then assign $l from Encode::decode("cp-1252", $l).
30 # - If the call returns none of the above then print a
31 # warning "Unsupported character encoding" and replace
32 # the non printable characters in $l by space.
33 # - In sub Parse_File_i case $file case $emucpp call to
34 # `open $in`, the encoding directive for UTF-8 is no
35 # longer needed due to use of Encode::Guess (see above).
36 # * In sub skip_input fix handling of preprocessor directives
37 # where the "#" is not placed in column 1 but is preceded by
38 # whitespace.
39 # * Fix sub scoped_name in case of chained module reopenings.
40 #
41 # 2.04 2020/06/20 * In sub Parse_File_i case $file case $emucpp open $in
42 # with encoding(UTF-8) to ensure that IDL files are parsed
43 # as utf8.
44 # * New sub discard_bom discards a possible Unicode or UTF-8
45 # BOM (Byte Order Mark) at the start of the given line.
46 # In sub get_items add optional argument $firstline.
47 # If $firstline is given and true then discard_bom will be
48 # called on the first line read from file.
49 # In sub Parse_File_i outer while-loop add local
50 # $firstline for call to sub get_items.
51 # * New sub has_default_branch checks whether the given union
52 # subordinates contain a DEFAULT branch. This fixes a bug
53 # related to checking that a union has an enum type as its
54 # switch and does not have a default branch.
55 # A false warning was generated in case the default branch
56 # was preceded by a comment.
57 # * Improvements to preprocessor emulation:
58 # - Support "#if defined XYZ" without parentheses around
59 # the symbol. Fix evaluation of the symbol.
60 # - Do not attempt evaluating preprocessor directives when
61 # inside multi line comments.
62 # - Fix handling of #endif in nested #if/#ifdef/#ifndef.
63 # * In @annoDefs add java_mapping annotations defined by the
64 # IDL4 to Java mapping proposal.
65 # 2.03 2019/04/27 * Fixed a bug related to Dump_Symbols whereby when using
66 # a string array ref as the optional argument, repeated
67 # calls to the sub would accumulate the text.
68 # * In sub parse_members, optional argument $comment fixes
69 # processing of trailing comment at members of struct,
70 # exception, and valuetype.
71 # 2.02 2018/08/15 * Fixed a few typos in documentation.
72 # * Added support for IDL4 struct inheritance defined by the
73 # Building Block Extended Data-Types:
74 # In case of STRUCT, the first SUBORDINATES element of may
75 # be a reference to a further STRUCT node instead of the
76 # reference to quintuplet. In this case, the first element
77 # indicates the IDL4 parent struct type of the current
78 # struct. The function isnode() can be used for detecting
79 # this case. The support for IDL4 struct inheritance is
80 # implemented in sub Parse_File_i case $kw eq 'struct'.
81 # * In sub is_elementary_type return early on undefined
82 # $tdesc.
83 # * In sub info check for valid $currfile and @infilename
84 # before accessing $infilename[$currfile].
85 # * In sub error avoid code duplication by reusing the
86 # implementation of sub info.
87 # * In sub dump_symbols_internal handling of METHOD, pop
88 # @arg only if @arg is non empty and $arg[-1] contains
89 # the exception list. We need these extra tests because
90 # METHODs in VALUETYPEs do not have an exception list as
91 # the last element of the SUBORDINATES.
92 # * In sub dump_symbols_internal handling of REMARK nodes,
93 # on calling sub dump_comment swap elements of anonymous
94 # constructed array: $name comes first, then $subord.
95 # (COMMENT nodes use the same layout.)
96 # 2.01 2018/01/23 * Fixed parsing of named argument values in sub
97 # parse_annotation_app: At case
98 # @$argref && $argref->[0] eq '('
99 # while-loop over @$argref case
100 # $val =~ /^[a-z]/i and $argref->[0] eq '='
101 # for-loop of $ai case
102 # $adef[$ai]->[1] eq $parname,
103 # after assigning $param_index execute `last' instead of
104 # `return'.
105 # * Declared globals %annoEnum and @annoDefs as `our' to
106 # make them accessible from outside.
107 # * Added 'port' to global %keywords.
108 # * Fixed calls to sub annotation so that more than one
109 # annotation may accumulate on a given IDL item.
110 # * Fixed changelog entry for v. 1.6 modification of REMARK
111 # NAME/SUBORDINATES.
112 # 2.00 2018/01/05 * Fixed parsing of parameterless annotation with empty
113 # @$argref in sub parse_annotation_app.
114 # * Changed version numbering to conform to CPAN format.
115 # * Based distro on skeleton generated by module-starter.
116 # * Started converting inline documentation to POD format.
117 # 1.6 2018/01/01 * Fixed parsing of inheritance from an absolute qualified
118 # superclass such as e.g.
119 # valuetype vt : ::absolute::qualified::superclass {...};
120 # * Added variable $global_idlfile, a copy of the file name
121 # passed into the most recent call to Parse_File.
122 # * Simplified the REMARK node as follows:
123 # - Its NAME contains the starting line number of the
124 # comment lines.
125 # - Its SUBORDINATES points to a simple array of lines.
126 # The file name and line number elements are no longer
127 # part of the lines array.
128 # * The COMMENT element now points to a tuple of (starting)
129 # line number and reference to simple array of lines.
130 # I.e. the file name and line number elements are no
131 # longer part of the lines array.
132 # * Added support for IDL4 standard annotations and user
133 # defined @annotation. See below for documentation on
134 # the new node element ANNOTATIONS.
135 # IDL4 annotations are currently supported in the
136 # following locations:
137 # - Type declarations
138 # - Member declarations of structured types
139 # - Enum literal value declarations
140 # Modified the node structure of these constructs
141 # accordingly.
142 # * New sub enum_literals returns the net literals of an
143 # ENUM. It is intended to shield against the node
144 # structure change at enum literals. Direct usages of
145 # enum SUBORDINATES should be replaced by calls to this
146 # sub when possible.
147 # * Removed support for non standard enum value repre-
148 # sentation as in: enum MyEnum { zero=0, one=1 };
149 # This is superseded by the @value annotation.
150 # 1.5 2017/07/23 The SCOPEREF of a MODULE now points to the previous
151 # opening of the module.
152 # Changed the COMMENT node element and the NAME element of
153 # the REMARK node as follows: Each element in the comment
154 # array is a ref to an array that contains the name of the
155 # file, the line number, and the comment text in that order.
156  
157 package CORBA::IDLtree;
158  
159 2 require Carp;
160 2 require Encode::Guess;
161  
162 2 ▶use 5.008_003;
Subroutine BEGIN: called CC=1 SCAR=0.0
163 2 ▶use strict 'vars';
Subroutine BEGIN: called CC=1 SCAR=0.0
164 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
165 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
166 2 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
167 2 ▶use Math::BigInt;
Subroutine BEGIN: called CC=1 SCAR=0.0
168 2 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
169  
170 # @EXPORT = ();
171 # @EXPORT_OK = (); # &Parse_File, &Dump_Symbols, and all the constants subs
172  
173 2 ▶use vars qw(@include_path %defines $cache_trees $global_idlfile
Subroutine BEGIN: called CC=1 SCAR=0.0
174 $n_errors $enable_comments $struct2vt $vt2struct
175 $cache_statistics $string_bound $permissive
176 $long_double_supported $union_default_null_allowed
177 2 $leading_underscore_allowed);
178  
179 =head1 NAME
180  
181 CORBA::IDLtree - OMG IDL to symbol tree translator
182  
183 =head1 VERSION
184  
185 Version 2.05
186  
187 =cut
188  
189 2 our $VERSION = '2.06';
190  
191 =head1 SYNOPSIS
192  
193 Subroutine Parse_File is the universal entry point (to be called by the
194 main program.)
195 It takes an IDL file name as the input parameter and parses that file,
196 constructing one or more symbol trees for the outermost declarations
197 encountered. It returns a reference to an array containing references
198 to those trees.
199 In case of errors during parsing, Parse_File returns 0.
200  
201 Usage:
202  
203 use CORBA::IDLtree;
204  
205 my $ref_to_array_of_outermost_declarations = CORBA::IDLtree::Parse_File("myfile.idl");
206  
207 $ref_to_array_of_outermost_declarations or die "File had syntax errors\n";
208 foreach my $node (@$ref_to_array_of_outermost_declarations) {
209 # Query $node->[TYPE] to find out what each node is;
210 # use $node->[SUBORDINATES] according to the $node->[TYPE].
211 # For example:
212 if ($node->[CORBA::IDLtree::TYPE] == CORBA::IDLtree::MODULE) {
213 foreach my $subnode @{$node->[CORBA::IDLtree::SUBORDINATES]}) {
214 # Assuming your "sub process" codes your business logic:
215 &process($subnode);
216 }
217 } elsif ($node->[CORBA::IDLtree::TYPE] == CORBA::IDLtree::...) {
218 # And so on, decode and process all the types you need ...
219 # For further details see the demo application in subdir demoapp.
220 }
221 }
222  
223 =head1 STRUCTURE OF THE SYMBOL TREE
224  
225 A "thing" in the symbol tree can be either a reference to a node, or a
226 reference to an array of references to nodes.
227  
228 Each node is a six element array with the elements
229  
230 [0] => TYPE (MODULE|INTERFACE|STRUCT|UNION|ENUM|TYPEDEF|CHAR|...)
231 [1] => NAME
232 [2] => SUBORDINATES
233 [3] => ANNOTATIONS
234 [4] => COMMENT
235 [5] => SCOPEREF
236  
237 The C<TYPE> element, instead of holding a type ID number (see the following
238 list under C<SUBORDINATES>), can also be a reference to the node defining the
239 type. When the C<TYPE> element can contain either a type ID or a reference to
240 the defining node, we will call it a I<type descriptor>.
241 Which of the two alternatives is in effect can be determined via the
242 C<isnode> function.
243  
244 The C<NAME> element, unless specified otherwise, simply holds the name string
245 of the respective IDL syntactic item.
246  
247 The C<SUBORDINATES> element depends on the type ID:
248  
249 =over
250  
251 =item MODULE or INTERFACE
252  
253 Reference to an array of nodes (symbols) which are defined
254 within the module or interface. In the case of C<INTERFACE>,
255 element [0] in this array will contain a reference to a
256 further array which in turn contains references to the
257 parent interfaceZ<>(s) if inheritance is used, or the null
258 value if the current interface is not derived by
259 inheritance. Element [1] is the "local/abstract" flag
260 which is C<ABSTRACT> for abstract interfaces, or C<LOCAL> for
261 interfaces declared local.
262  
263 =item INTERFACE_FWD
264  
265 Reference to the node of the full interface declaration.
266  
267 =item STRUCT or EXCEPTION
268  
269 Reference to an array of node references representing the
270 member components of the struct or exception.
271 Each member representative node is a quintuplet consisting
272 of (C<TYPE>, C<NAME>, <dimref>, C<ANNOTATIONS>, C<COMMENT>).
273 The <dimref> is a reference to a list of dimension numbers,
274 or is 0 if no dimensions were given.
275 In case of STRUCT, the first element may be a reference to a
276 further STRUCT node instead of the reference to quintuplet.
277 In this case, the first element indicates the IDL4 parent
278 struct type of the current struct. The function isnode() can
279 be used for detecting this case.
280  
281 =item UNION
282  
283 Similar to C<STRUCT>/C<EXCEPTION>, reference to an array of
284 nodes. For union members, the member node has the same
285 structure as for STRUCT/EXCEPTION.
286 However, the first node contains a type descriptor for
287 the discriminant type. The switch node does not follow the
288 usual quadruplet structure of members; it is a single item.
289 The C<TYPE> of a member node may also be C<CASE> or C<DEFAULT>.
290 When the TYPE is CASE or DEFAULT, this means that the
291 following member node will be the union branch controlled
292 by the CASE or DEFAULT.
293 For C<CASE>, the C<NAME> is unused, and the C<SUBORDINATES> contains
294 a reference to a list of the case values for the following
295 member node.
296 For C<DEFAULT>, both the C<NAME> and the C<SUBORDINATES> are unused.
297  
298 =item ENUM
299  
300 Reference to an array where each element is a further reference to
301 an array.
302 In this array,
303  
304 =over
305  
306 =item * if C<$enable_comments> is set then the first element may be
307 numeric. In that case the element represents a comment using the same
308 layout as the REMARK node. The number is the starting line number of
309 the comment; the second element is unused, and the third element is a
310 reference to array containing the comment lines.
311  
312 =item * otherwise the element describes an enum value. It then consists
313 of three elements: The first element is the enum literal value. The
314 second element is a reference to an array of annotations as described
315 in the C<ANNOTATIONS> documentation (see below). The third element is
316 a reference to the trailing comment list.
317  
318 =back
319  
320 =item TYPEDEF
321  
322 Reference to a two-element array: element 0 contains a
323 reference to the type descriptor of the original type;
324 element 1 contains a reference to an array of dimension
325 expressions, or the null value if no dimensions are given.
326 When given, the dimension expressions are plain strings.
327  
328 =item SEQUENCE
329  
330 As a special case, the C<NAME> element of a C<SEQUENCE> node
331 does not contain a name (as sequences are anonymous
332 types), but instead is used to hold the bound number.
333 If the bound number is 0 then it is an unbounded
334 sequence. The C<SUBORDINATES> element contains the type
335 descriptor of the base type of the sequence. This
336 descriptor could itself be a reference to a C<SEQUENCE>
337 defining node (that is, a nested sequence definition.)
338  
339 =item BOUNDED_STRING
340  
341 Bounded strings are treated as a special case of sequence.
342 They are represented as references to a node that has
343 C<BOUNDED_STRING> or C<BOUNDED_WSTRING> as the type ID, the bound
344 number in the C<NAME>, and the C<SUBORDINATES> element is unused.
345  
346 =item CONST
347  
348 Reference to a two-element array. Element 0 is a type
349 descriptor of the const's type; element 1 is a reference
350 to an array containing the RHS expression symbols.
351  
352 =item FIXED
353  
354 Reference to a two-element array. Element 0 contains the
355 digit number and element 1 contains the scale factor.
356 The C<NAME> component in a C<FIXED> node is unused.
357  
358 =item VALUETYPE
359  
360 Uses the following structure:
361  
362 [0] => $is_abstract (boolean)
363 [1] => reference to a tuple (two-element list) containing
364 inheritance related information:
365 [0] => $is_truncatable (boolean)
366 [1] => \@ancestors (reference to array containing
367 references to ancestor nodes)
368 [2] => \@members: reference to array containing references
369 to tuples (two-element lists) of the form:
370 [0] => 0|PRIVATE|PUBLIC
371 A zero for this value means the element [1]
372 contains a reference to a declaration, such
373 as a METHOD or ATTRIBUTE.
374 In case of METHOD, the first element in the
375 method node subordinates (i.e., the return
376 type) may be FACTORY.
377 However, unlike interface methods, the last
378 element is _not_ a reference to the 'raises'
379 list. Support for 'raises' of valuetype
380 methods may be added in a future version.
381 [1] => reference to the defining node.
382 In case of PRIVATE or PUBLIC state member,
383 the SUBORDINATES of the defining node
384 contains a dimref (reference to dimensions
385 list, see STRUCT.)
386  
387 =item VALUETYPE_BOX
388  
389 Reference to the defining type node.
390  
391 =item VALUETYPE_FWD
392  
393 Reference to the node of the full valuetype declaration.
394  
395 =item NATIVE
396  
397 Subordinates unused.
398  
399 =item ATTRIBUTE
400  
401 Reference to a two-element array; element 0 is the read-
402 only flag (0 for read/write attributes), element 1 is a
403 type descriptor of the attribute's type.
404  
405 =item METHOD
406  
407 Reference to a variable length array; element 0 is a type
408 descriptor for the return type. Elements 1 and following
409 are references to parameter descriptor nodes with the
410 following structure:
411  
412 elem. 0 => parameter type descriptor
413 elem. 1 => parameter name
414 elem. 2 => parameter mode (IN, OUT, or INOUT)
415  
416 The last element in the variable-length array is a
417 reference to the "raises" list. This list contains
418 references to the declaration nodes of exceptions raised,
419 or is empty if there is no "raises" clause.
420  
421 =item INCFILE
422  
423 Reference to an array of nodes (symbols) which are defined
424 within the include file. The Name element of this node
425 contains the include file name.
426  
427 =item PRAGMA_PREFIX
428  
429 Subordinates unused.
430  
431 =item PRAGMA_VERSION
432  
433 Version string.
434  
435 =item PRAGMA_ID
436  
437 ID string.
438  
439 =item PRAGMA
440  
441 This is for the general case of pragmas that are none
442 of the above, i.e. pragmas unknown to IDLtree.
443 The C<NAME> holds the pragma name, and C<SUBORDINATES>
444 holds all further text appearing after the pragma name.
445  
446 =item REMARK
447  
448 The C<NAME> of the node contains the starting line number
449 of the comment text.
450 The C<SUBORDINATES> component contains a reference to a list
451 of comment lines. The comment lines are not newline
452 terminated.
453 The source line number of each comment line can be
454 computed by adding the starting line number and the
455 array index of the comment line.
456 By default, C<REMARK> nodes will not be generated;
457 generation of C<REMARK> nodes can be enabled by setting the
458 $enable_comments global variable to non zero.
459  
460 =back
461  
462 The C<ANNOTATIONS> element holds the reference to an array of annotation nodes
463 if IDL4 style annotations are present (if no annotations are present then
464 the ANNOTATIONS element holds 0).
465 Each entry in this array is an array reference. The first element in the
466 array referenced is the index to an entry in @annoDefs (see comments at
467 declaration of @annoDefs). The following elements contain the concrete
468 values for the parameters, in the order as defined by the entry in
469 @annoDefs. If the user omitted the value of the parameter then the
470 default as specified by the entry in @annoDefs is filled in.
471  
472 The C<COMMENT> element holds the comment text that follows the IDL declaration
473 on the same line. Usually this is just a single line. However, if a multi-
474 line comment is started on the same line after a declaration, the multi-line
475 comment may extend to further lines - therefore we use a list of lines.
476 The lines in this list are not newline terminated. The C<COMMENT> field is a
477 reference to a tuple of starting line number and reference to the line list,
478 or contains 0 if no trailing comment is present at the IDL item.
479  
480 The C<SCOPEREF> element is a reference back to the node of the module or
481 interface enclosing the current node. If the current node is already
482 at the global scope level then the C<SCOPEREF> is 0.
483 Special case: For a reopened module, the C<SCOPEREF> points to the previous
484 opening of the same module. In case of multiple reopenings, each reopening
485 points to the previous opening. The C<SCOPEREF> of the initial module finally
486 points to the enclosing scope.
487 All nodes have this element except for the parameter nodes of methods and
488 the component nodes of structs/unions/exceptions.
489  
490 =head1 CLASS VARIABLES
491  
492 =head2 Variables that can be set by client code
493  
494 =over
495  
496 =item @CORBA::IDLtree::include_path
497  
498 Paths where to look for included IDL files.
499  
500 =item %CORBA::IDLtree::defines
501  
502 Symbol definitions for preprocessor.
503  
504 =item $CORBA::IDLtree::cache_trees
505  
506 Values 0 or 1, default 0.
507 By default, do not cache trees of C<#include>d files.
508  
509 =item $CORBA::IDLtree::enable_comments
510  
511 Values 0 or 1, default 0.
512 By default, do not generate C<REMARK> nodes.
513  
514 =item $CORBA::IDLtree::struct2vt
515  
516 Values 0 or 1, default 0.
517 Change struct into equivalent valuetype
518  
519 =item $CORBA::IDLtree::vt2struct
520  
521 Values 0 or 1, default 0.
522 Change valuetype into equivalent struct
523  
524 =item $CORBA::IDLtree::cache_statistics
525  
526 Values 0 or 1, default 0.
527 Print cache statistics
528  
529 =item $CORBA::IDLtree::long_double_supported
530  
531 Values 0 or 1, default 0.
532 Switch on support for IDL C<long double>.
533  
534 =item $CORBA::IDLtree::union_default_null_allowed
535  
536 Values 0 or 1, default 1.
537 Switch off permission that a C<union>'s C<default> branch may be empty.
538  
539 =item $CORBA::IDLtree::leading_underscore_allowed
540  
541 Value 1 will remove the leading underscore.
542 Value 2 will preserve the leading underscore.
543  
544 =item $CORBA::IDLtree::permissive
545  
546 Values 0 or 1, default 0.
547 By default, misuse of IDL keywords as identifiers is a hard error.
548  
549 =back
550  
551 =head2 Variables written by CORBA::IDLtree
552  
553 These are to be considered read-only from outside:
554  
555 =over
556  
557 =item $CORBA::IDLtree::n_errors
558  
559 Cumulative number of errors for a C<Parse_File> call.
560  
561 =item $CORBA::IDLtree::global_idlfile
562  
563 Copy of filename passed into most recent call of sub Parse_File
564  
565 =back
566  
567 =cut
568  
569 # User definable auxiliary data for Parse_File:
570 2 @include_path = (); # Paths where to look for included IDL files
571 2 %defines = (); # Symbol definitions for preprocessor
572 2 $cache_trees = 0; # By default, do not cache trees of #included files
573 2 $enable_comments = 0; # By default, do not generate REMARK nodes.
574 2 $struct2vt = 0; # change struct into equivalent valuetype
575 2 $vt2struct = 0; # change valuetype into equivalent struct
576 2 $cache_statistics = 0; # print cache statistics
577  
578 2 $long_double_supported = 0;
579 2 $union_default_null_allowed = 1;
580 2 $leading_underscore_allowed = 0; # value 1 will remove the leading underscore
581 # value 2 will preserve the leading underscore
582 2 $permissive = 0; # By default, misuse of IDL keywords is a hard error
583  
584 # Variables written by CORBA::IDLtree (to be considered read-only from outside)
585  
586 2 $n_errors = 0; # Cumulative number of errors for a Parse_File call.
587 2 $global_idlfile = ""; # Copy of filename passed into most recent call of
588 # sub Parse_File
589  
590 # Internal variables (should not be visible)
591  
592 2 my $is64bit = $Config{ivsize} >= 8;
593  
594 2 our $verbose = 0; # report progress to stdout, set via sub set_verbose
595  
596 2 my $comment_directives = undef; # may be set to an IDLtree::Comment_Directives
597 # object or derivative via set_directive_object
598  
599 2 my %active_defines = (); # used by #ifdef / #ifndef / #define / #undef processing
600  
601 =head1 CONSTANTS
602  
603 =head2 Constants for accessing the elements of a node
604  
605 =over 2
606  
607 =item Constants for indexing the elements of a node
608  
609 As explained in STRUCTURE OF THE SYMBOL TREE, each node is represented as a
610 six element array. These constants are intended for indexing the array:
611  
612 sub TYPE () { 0 }
613 sub NAME () { 1 }
614 sub SUBORDINATES () { 2 }
615 sub MODE () { 2 }
616 sub ANNOTATIONS () { 3 }
617 sub COMMENT () { 4 }
618 sub SCOPEREF () { 5 }
619  
620 The constant C<MODE> is an alias of C<SUBORDINATES> for method parameter nodes.
621  
622 =cut
623  
624 sub TYPE () { 0 }
625 sub NAME () { 1 }
626 sub SUBORDINATES () { 2 }
627 sub MODE () { 2 } # alias of SUBORDINATES (for method parameter nodes)
628 sub ANNOTATIONS () { 3 }
629 sub COMMENT () { 4 }
630 sub SCOPEREF () { 5 }
631  
632 =item Method parameter modes
633  
634 sub IN () { 1 }
635 sub OUT () { 2 }
636 sub INOUT () { 3 }
637  
638 =cut
639  
640 sub IN () { 1 }
641 sub OUT () { 2 }
642 sub INOUT () { 3 }
643  
644 =item Meanings of the TYPE entry in the symbol node
645  
646 sub NONE () { 0 } # error/illegality value
647 sub BOOLEAN () { 1 }
648 sub OCTET () { 2 }
649 sub CHAR () { 3 }
650 sub WCHAR () { 4 }
651 sub SHORT () { 5 }
652 sub LONG () { 6 }
653 sub LONGLONG () { 7 }
654 sub USHORT () { 8 }
655 sub ULONG () { 9 }
656 sub ULONGLONG () { 10 }
657 sub FLOAT () { 11 }
658 sub DOUBLE () { 12 }
659 sub LONGDOUBLE () { 13 }
660 sub STRING () { 14 }
661 sub WSTRING () { 15 }
662 sub OBJECT () { 16 }
663 sub TYPECODE () { 17 }
664 sub ANY () { 18 }
665 sub FIXED () { 19 } # node
666 sub BOUNDED_STRING () { 20 } # node
667 sub BOUNDED_WSTRING () { 21 } # node
668 sub SEQUENCE () { 22 } # node
669 sub ENUM () { 23 } # node
670 sub TYPEDEF () { 24 } # node
671 sub NATIVE () { 25 } # node
672 sub STRUCT () { 26 } # node
673 sub UNION () { 27 } # node
674 sub CASE () { 28 }
675 sub DEFAULT () { 29 }
676 sub EXCEPTION () { 30 } # node
677 sub CONST () { 31 } # node
678 sub MODULE () { 32 } # node
679 sub INTERFACE () { 33 } # node
680 sub INTERFACE_FWD () { 34 } # node
681 sub VALUETYPE () { 35 } # node
682 sub VALUETYPE_FWD () { 36 } # node
683 sub VALUETYPE_BOX () { 37 } # node
684 sub ATTRIBUTE () { 38 } # node
685 sub ONEWAY () { 39 } # implies "void" as the return type
686 sub VOID () { 40 }
687 sub FACTORY () { 41 }
688 sub METHOD () { 42 } # node
689 sub INCFILE () { 43 } # node
690 sub PRAGMA_PREFIX () { 44 } # node
691 sub PRAGMA_VERSION () { 45 } # node
692 sub PRAGMA_ID () { 46 } # node
693 sub PRAGMA () { 47 } # node
694 sub REMARK () { 48 } # node
695 sub NUMBER_OF_TYPES () { 49 }
696  
697 The constant C<FACTORY> can only occur as the return type of a method in a valuetype.
698  
699 =cut
700  
701 # If these codes are changed then @predef_types must be changed accordingly.
702 sub NONE () { 0 } # error/illegality value
703 sub BOOLEAN () { 1 }
704 sub OCTET () { 2 }
705 sub CHAR () { 3 }
706 sub WCHAR () { 4 }
707 sub SHORT () { 5 }
708 sub LONG () { 6 }
709 sub LONGLONG () { 7 }
710 sub USHORT () { 8 }
711 sub ULONG () { 9 }
712 sub ULONGLONG () { 10 }
713 sub FLOAT () { 11 }
714 sub DOUBLE () { 12 }
715 sub LONGDOUBLE () { 13 }
716 sub STRING () { 14 }
717 sub WSTRING () { 15 }
718 sub OBJECT () { 16 }
719 sub TYPECODE () { 17 }
720 sub ANY () { 18 }
721 sub FIXED () { 19 } # node
722 sub BOUNDED_STRING () { 20 } # node
723 sub BOUNDED_WSTRING () { 21 } # node
724 sub SEQUENCE () { 22 } # node
725 sub ENUM () { 23 } # node
726 sub TYPEDEF () { 24 } # node
727 sub NATIVE () { 25 } # node
728 sub STRUCT () { 26 } # node
729 sub UNION () { 27 } # node
730 sub CASE () { 28 }
731 sub DEFAULT () { 29 }
732 sub EXCEPTION () { 30 } # node
733 sub CONST () { 31 } # node
734 sub MODULE () { 32 } # node
735 sub INTERFACE () { 33 } # node
736 sub INTERFACE_FWD () { 34 } # node
737 sub VALUETYPE () { 35 } # node
738 sub VALUETYPE_FWD () { 36 } # node
739 sub VALUETYPE_BOX () { 37 } # node
740 sub ATTRIBUTE () { 38 } # node
741 sub ONEWAY () { 39 } # implies "void" as the return type
742 sub VOID () { 40 }
743 sub FACTORY () { 41 } # treated as return type of METHOD;
744 # can only occur inside valuetype
745 sub METHOD () { 42 } # node
746 sub INCFILE () { 43 } # node
747 sub PRAGMA_PREFIX () { 44 } # node
748 sub PRAGMA_VERSION () { 45 } # node
749 sub PRAGMA_ID () { 46 } # node
750 sub PRAGMA () { 47 } # node
751 sub REMARK () { 48 } # node
752 sub NUMBER_OF_TYPES () { 49 }
753  
754 # special type code used for filling @typestack
755 59 ▶sub ANNOTATION { &NUMBER_OF_TYPES }
Subroutine ANNOTATION: called CC=1 SCAR=0.0
Pod undocumented
756  
757 =item Interface/valuetype flag values
758  
759 sub ABSTRACT { 1 }
760 sub LOCAL { 2 }
761 sub TRUNCATABLE { 2 }
762 sub CUSTOM { 3 }
763  
764 =cut
765  
766 16 ▶sub ABSTRACT { 1 }
Subroutine ABSTRACT: called CC=1 SCAR=0.0
Pod undocumented
767 16 ▶sub LOCAL { 2 }
Subroutine LOCAL: called CC=1 SCAR=0.0
Pod undocumented
768 0 ▶sub TRUNCATABLE { 2 }
Subroutine TRUNCATABLE: not called CC=1 SCAR=6.9
Pod undocumented
769 0 ▶sub CUSTOM { 3 }
Subroutine CUSTOM: not called CC=1 SCAR=6.9
Pod undocumented
770  
771 =item Valuetype member flags
772  
773 sub PRIVATE { 1 }
774 sub PUBLIC { 2 }
775  
776 =back
777  
778 =cut
779  
780 0 ▶sub PRIVATE { 1 }
Subroutine PRIVATE: not called CC=1 SCAR=6.9
Pod undocumented
781 0 ▶sub PUBLIC { 2 }
Subroutine PUBLIC: not called CC=1 SCAR=6.9
Pod undocumented
782  
783 =head1 SUBROUTINES
784  
785 =head2 Parse_File
786  
787 Parses the file name given as argument.
788 Returns reference to array of nodes representing the top level (global)
789 declarations in the file.
790 Returns 0 if the file had syntax errors.
791 C<Parse_File> writes the error messages to C<STDERR>.
792  
793 =cut
794  
795 sub Parse_File;
796  
797 0 ▶sub set_directive_object {
Subroutine set_directive_object: not called CC=1 SCAR=6.9
Pod undocumented
798 0 $comment_directives = shift;
799 }
800  
801 =head2 Dump_Symbols
802  
803 Symbol tree dumper (for debugging etc.) reconstructs the IDL source notation
804 from the parsed symbol tree.
805 Parameters:
806  
807 =over
808  
809 =item 1.
810  
811 Reference to a symbol array (return value from a previous call to Parse_File).
812  
813 =item 2.
814  
815 Optional parameter controlling the output:
816  
817 =over
818  
819 =item *
820  
821 If given as string then it is the name of a file into which to dump the IDL source.
822  
823 =item *
824  
825 If given as array reference then the IDL source will be placed in the
826 referenced array, one line per element, where each line is not newline
827 terminated.
828  
829 =item *
830  
831 If the optional parameter is not given or is given as C<undef> then the IDL
832 source will be dumped to C<STDOUT>.
833  
834 =back
835  
836 =back
837  
838 =cut
839  
840 sub Dump_Symbols;
841  
842 sub Version ()
843 0 ▶{
Subroutine Version: not called CC=3 SCAR=24.8
Pod undocumented
844 0 for ('$Revision: 30679 $') { #'){
845 0 ▶ /: *(\S+)/ and return $VERSION . "_" . $1;
Branch: 1 branch
BranchTrueFalseTotal
/: *(\S+)/ and return $CORBA::IDLtree::VERSION . '_' . $1 0 0 0
846 }
847 0 return $VERSION;
848 }
849  
850 =head2 is_elementary_type
851  
852 Given a node reference, returns the type constant if the node prepresents
853 an elementary type. Returns 0 if the type is not elementary.
854  
855 =head2 predef_type
856  
857 Given a type name (as string), returns the type constant if the type name
858 is that of an elementary type. Returns 0 if the type is not elementary.
859  
860 =head2 isnode
861  
862 Given a "thing", returns 1 if it is a reference to a node, 0 otherwise.
863  
864 =head2 is_scope
865  
866 Given a "thing", returns 1 if it's a ref to a C<MODULE>, C<INTERFACE>, or
867 C<INCFILE> node.
868  
869 =head2 find_node
870  
871 Looks up a name in the symbol treeZ<>(s) constructed so far.
872 Returns the node ref if found, else 0.
873  
874 =head2 typeof
875  
876 Given a type descriptor, returns the type as a string in IDL syntax.
877  
878 =head2 set_verbose
879  
880 Call this to make the parser tell us what it's doing.
881  
882 =head2 is_a
883  
884 Determine if typeid is of given type, recursing through C<TYPEDEF>s.
885  
886 =head2 root_type
887  
888 Get the original type of a C<TYPEDEF>, i.e. recurse through all non array
889 C<TYPEDEF>s until the original type is reached.
890  
891 =head2 is_pragma
892  
893 Return 1 if the given type constant or node is a pragma.
894  
895 =head2 files_included
896  
897 Returns an array with the names of files #included.
898  
899 =head2 get_scalar_default
900  
901 Get default value for type.
902 Uses comment directives object if available.
903  
904 =head2 idlsplit
905  
906 Splits a given IDL expression into its individual
907 tokens. Returns the tokens as a list.
908 Example: The call
909  
910 idlsplit("(m_a::myconst+1.0) / scale")
911  
912 returns the list
913  
914 "(", "m_a::myconst", "+", "1.0", ")", "/", "scale"
915  
916 =head2 is_valid_identifier
917  
918 Returns 1 if the argument is a valid IDL identifier.
919  
920 =head2 scoped_name
921  
922 Expects a symbol node as the input argument and
923 returns its fully qualified name in IDL syntax.
924  
925 =head2 collect_includes
926  
927 Utility for collecting C<#include>d files.
928 Parameters:
929  
930 =over
931  
932 =item 1.
933  
934 Reference to node list to analyze.
935  
936 =item 2.
937  
938 Reference to hash in which to add the includefile names encountered.
939 The includefile names are added as key fields of the hash.
940 The value fields are not used.
941  
942 =back
943  
944 =head2 get_numeric
945  
946 Computes numeric value of expression.
947  
948 =head2 enum_literals
949  
950 The C<SUBORDINATES> of C<ENUM> contains more than just the actual enum literal
951 values (the additional data are: annotations, trailing comments).
952 This is a convenience subroutine which returns the net literals of the given
953 C<$enumnode[SUBORDINATES]>.
954  
955 =cut
956  
957 sub is_elementary_type;
958 sub predef_type;
959 sub isnode;
960 sub is_scope;
961 sub find_node;
962 sub typeof;
963 sub set_verbose;
964 sub is_a;
965 sub root_type;
966 sub is_pragma;
967 sub files_included;
968 sub get_scalar_default;
969 sub idlsplit;
970 sub is_valid_identifier;
971 sub scoped_name;
972 sub collect_includes;
973 sub get_numeric;
974 sub enum_literals;
975  
976 # Internal subroutines (should not be visible)
977  
978 sub use_system_preprocessor; # Attempt to use the system preprocessor if
979 # one is found.
980 # Takes no arguments.
981 # NOTE: Due to variations in preprocessor
982 # options and behavior, this might not work
983 # on your system.
984 # If use_system_preprocessor is not called
985 # then the IDLtree parser attempts to do the
986 # preprocessing itself.
987 sub in_annotation_def; # Returns true while parsing an @annotation.
988 sub get_items;
989 sub unget_items;
990 sub check_name;
991 sub curr_scope;
992 sub scope_names;
993 sub find_node_i;
994 sub parse_sequence;
995 sub parse_type;
996 sub parse_members;
997 sub error;
998 sub info;
999 sub abort;
1000 sub require_end_of_stmt;
1001 sub get_files_included;
1002 sub dump_symbols_internal;
1003  
1004 # Start of implementation
1005  
1006 # Auxiliary (non-visible) global stuff ########################################
1007  
1008 # Annotation enumeration types (auxiliary to declaring @annoDefs).
1009 # User defined annotation enumeration types are added here when they arise.
1010 2 our %annoEnum = (
1011 "AutoidKind" => [ "SEQUENTIAL", "HASH" ],
1012 "ExtensibilityKind" => [ "FINAL", "APPENDABLE", "MUTABLE" ],
1013 "PlacementKind" => [ "BEGIN_FILE",
1014 "BEFORE_DECLARATION",
1015 "BEGIN_DECLARATION",
1016 "END_DECLARATION",
1017 "AFTER_DECLARATION",
1018 "END_FILE" ],
1019 # IDL4 to Java mapping
1020 "NamingConvention" => [ "IDL_NAMING_CONVENTION",
1021 "JAVA_NAMING_CONVENTION" ]
1022 );
1023  
1024 # Predefined annotation definitions.
1025 # User defined annotation definitions are appended here when they arise.
1026 # Each element in @annoDefs is a reference to an array:
1027 # The first element in the array is the annotation name.
1028 # The following elements in the array represent the parameters of the
1029 # annotation (if the annotation has no parameters then there will be no
1030 # further elements). Each parameter is represented as a reference to a
1031 # triplet (three element array). The first element in the triplet is
1032 # either a type number (one of the values BOOLEAN, OCTET, CHAR, SHORT,
1033 # LONG, LONGLONG, USHORT, ULONG, ULONGLONG, FLOAT, STRING, ANY) or a
1034 # reference to an entry in %annoEnum. The second element in the triplet
1035 # is the parameter name. The third element in the triplet is the default
1036 # value if a default is given, or is undef if no default is given.
1037  
1038 2 our @annoDefs = (
1039 [ "id", [ ULONG, "value", undef ] ],
1040 [ "autoid", [ "AutoidKind", "value", "HASH" ] ],
1041 [ "optional", [ BOOLEAN, "value", "TRUE" ] ],
1042 [ "position", [ USHORT, "value", undef ] ],
1043 [ "value", [ ANY, "value", undef ] ],
1044 [ "extensibility", [ "ExtensibilityKind", "value", undef ] ],
1045 [ "final" ],
1046 [ "appendable" ],
1047 [ "mutable" ],
1048 [ "key", [ BOOLEAN, "value", "TRUE" ] ],
1049 [ "must_understand", [ BOOLEAN, "value", "TRUE" ] ],
1050 [ "default_literal" ],
1051 [ "default", [ ANY, "value", undef ] ],
1052 [ "range", [ ANY, "min", undef ], [ ANY, "max", undef ] ],
1053 [ "min", [ ANY, "value", undef ] ],
1054 [ "max", [ ANY, "value", undef ] ],
1055 [ "unit", [ STRING, "value", undef ] ],
1056 [ "bit_bound", [ USHORT, "value", undef ] ],
1057 [ "external", [ BOOLEAN, "value", "TRUE" ] ],
1058 [ "nested", [ BOOLEAN, "value", "TRUE" ] ],
1059 [ "verbatim", [ STRING, "language", "*" ],
1060 [ "PlacementKind", "placement", "BEFORE_DECLARATION" ],
1061 [ STRING, "text", undef ] ],
1062 [ "service", [ STRING, "platform", "*" ] ],
1063 [ "oneway", [ BOOLEAN, "value", "TRUE" ] ],
1064 [ "ami", [ BOOLEAN, "value", "TRUE" ] ],
1065 # IDL4 to Java mapping
1066 [ "java_mapping", [ STRING, "constants_container", "Constants" ],
1067 [ BOOLEAN, "promote_integer_width", "FALSE" ],
1068 [ "NamingConvention", "apply_naming_convention",
1069 "IDL_NAMING_CONVENTION" ],
1070 [ STRING, "string_type", "String" ] ]
1071 );
1072  
1073 # Temporary store collecting annotations will be flushed when the construct
1074 # to annotate is seen.
1075 # The structure of @annotations is that of the ANNOTATIONS element in tree
1076 # nodes (see documentation at beginning of file):
1077 # Each entry in this array is an array reference. The first element in the
1078 # array referenced is a reference to an entry in @annoDefs. The following
1079 # elements contain the concrete values for the parameters, in the order as
1080 # defined by the entry in @annoDefs. If the user omitted the value of the
1081 # parameter then the default as specified by the entry in @annoDefs is
1082 # filled in.
1083 2 my @annotations = ();
1084  
1085 {
1086 # general symbol cache class, used for include file cache and
1087 # node cache
1088 package CORBA::IDLtree::Cache;
1089  
1090 4 ▶ sub new {
Subroutine new: called CC=2 SCAR=7.2
1091 4 my $class = shift;
1092 4 ▶ $class = ref($class) || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
040
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
1093  
1094 4 my $this = bless {}, $class;
1095 4 $this->clear();
1096 4 return $this;
1097 }
1098  
1099 8 ▶ sub clear {
Subroutine clear: called CC=1 SCAR=0.0
1100 8 my $this = shift;
1101  
1102 8 %{$this->{_cache}} = ();
1103 8 $this->{_hits} = 0;
1104 8 $this->{_queries} = 0;
1105 8 return $this;
1106 }
1107  
1108 # if $value is true add under the name $name
1109 # to the cache
1110 43 ▶ sub add {
Subroutine add: called CC=4 SCAR=14.0
1111 43 my $this = shift;
1112 43 my ($name, $value) = @_;
1113  
1114 43 ▶ if ($value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value) 43 0 43
1115 43 ▶ if (exists $this->{_cache}{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $this->{"_cache"}{$name}) 1 42 43
1116 1 my $existing = $this->{_cache}{$name};
1117 1 ▶ if ($existing != $value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($existing != $value) 1 0 1
1118 # This happens when adding the reopening of a known module.
1119 # The cache only holds the last reopening.
1120 1 CORBA::IDLtree::info("CORBA::IDLtree::Cache::add($name): replacing "
1121 . "$existing (" . CORBA::IDLtree::typeof($existing)
1122 . ") by $value (" . CORBA::IDLtree::typeof($value) . ")");
1123 }
1124 }
1125 43 $this->{_cache}{$name} = $value;
1126 }
1127 43 return $this;
1128 }
1129  
1130 # get entry for $name or undef if $name is not known
1131 377 ▶ sub get {
Subroutine get: called CC=2 SCAR=6.9
1132 377 my $this = shift;
1133 377 my ($name) = @_;
1134  
1135 377 $this->{_queries}++;
1136 377 ▶ if (exists $this->{_cache}{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $this->{"_cache"}{$name}) 66 311 377
1137 66 $this->{_hits}++;
1138 66 return $this->{_cache}{$name};
1139 }
1140 311 return undef;
1141 }
1142  
1143 # return hits / queries ratio
1144 0 ▶ sub ratio {
Subroutine ratio: not called CC=1 SCAR=6.9
1145 0 my $this = shift;
1146 0 return $this->{_hits}." / ".$this->{_queries};
1147 }
1148  
1149 # return known names
1150 0 ▶ sub symbols {
Subroutine symbols: not called CC=1 SCAR=6.9
1151 0 my $this = shift;
1152 0 return keys %{$this->{_cache}};
1153 }
1154 }
1155  
1156 # The @predef_types array must have the types in the same order as
1157 # the numeric order of type identifying constants defined above.
1158 2 my @predef_types = qw/ none boolean octet char wchar short long long_long
1159 unsigned_short unsigned_long unsigned_long_long
1160 float double long_double string wstring Object
1161 TypeCode any fixed bounded_string bounded_wstring
1162 sequence enum typedef native struct union case default
1163 exception const module interface interface_fwd
1164 valuetype valuetype_fwd valuetype_box
1165 attribute oneway void factory method
1166 include pragma_prefix pragma_version pragma_id pragma /;
1167  
1168 # list of all IDL keywords (as of CORBA 3.0) in lower case
1169 # used to check for name conflicts
1170 2 my %keywords = map { $_ => undef } qw/
1171 abstract any attribute boolean case char component const
1172 consumes context custom default double emits enum exception
1173 eventtype factory false finder fixed float getraises home
1174 import in inout interface local long module multiple native
1175 object octet oneway out port primarykey private provides public
1176 publishes raises readonly setraises sequence short string
1177 struct supports switch true truncatable typedef typeid
1178 typeprefix unsigned union uses valuebase valuetype void
1179 wchar wstring/;
1180  
1181 2 my @infilename = (); # infilename and line_number move in parallel.
1182 2 my @line_number = ();
1183 2 my @remark = (); # Auxiliary to comment processing
1184 2 my @post_comment = (); # Auxiliary to comment processing
1185 2 my @global_items = (); # Auxiliary to sub unget_items
1186 2 my $findnode_cache = new CORBA::IDLtree::Cache();
1187 # Auxiliary to find_node_i(): cache for lookups
1188 2 my $abstract = 0; # can also contain LOCAL (for interfaces)
1189 2 my $currfile = -1;
1190 2 my $starting_line_number_of_remark = 0; # 0 = there is no pre comment
1191 2 my $line_number_of_post_comment = 0; # 0 = there is no post comment
1192 2 my $emucpp = 1; # use C preprocessor emulation
1193 2 my $locale_was_determined = 0;
1194 2 my $locale = undef;
1195  
1196 0 ▶sub locate_executable {
Subroutine locate_executable: not called CC=3 SCAR=24.8
Pod undocumented
1197 # FIXME: this is probably another reinvention of the wheel.
1198 # Should look for builtin Perl solution or CPAN module that does this.
1199 0 my $executable = shift;
1200 # my $pathsep = $Config{'path_sep'};
1201 0 my $pathsep = ':';
1202 0 my $fully_qualified_name = "";
1203 0 my @dirs = split(/$pathsep/, $ENV{'PATH'});
1204 0 foreach (@dirs) {
1205 0 my $fqn = "$_/$executable";
1206 0 ▶ if (-e $fqn) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $fqn) 0 0 0
1207 0 $fully_qualified_name = $fqn;
1208 0 last;
1209 }
1210 }
1211 0 $fully_qualified_name;
1212 }
1213  
1214  
1215 224 ▶sub idlsplit {
Subroutine idlsplit: called CC=49 SCAR=57.5
Pod documented
1216 224 my $str = shift;
1217 224 my $in_preprocessor = $str =~ /^\s*#/;
1218 224 my $in_string = 0;
1219 224 my $in_lit = 0;
1220 224 my $in_space = 0;
1221 224 my $i;
1222 224 my @out = ();
1223 224 my $ondx = -1;
1224 224 ▶ for ($i = 0; $i < length($str); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < length $str) 6134 224 6358
1225 6134 my $ch = substr($str, $i, 1);
1226 6134 ▶ if ($in_string) {
Branch: 6 branches
BranchTrueFalseTotal
if ($in_string) { } 34 6100 6134
elsif ($ch eq '"') { } 3 6097 6100
elsif ($ch eq q[']) { } 6 6091 6097
elsif ($ch =~ /[a-z_0-9\.]/i) { } 4921 1170 6091
elsif ($in_lit) { } 694 476 1170
elsif (not $ch =~ /\s/) { } 247 229 476
1227 34 $out[$ondx] .= $ch;
1228 34 ▶ if ($ch eq '"' and substr($str, $i-1, 1) ne "\\") {
Branch: 1 branch
BranchTrueFalseTotal
if ($ch eq "\"" and substr($str, $i - 1, 1) ne "\\") 3 31 34
Condition66%2/3
$ch eq "\"" and substr($str, $i - 1, 1) ne "\\"
!ll&&!rl&&r
3103
MC/DC50%1/2
$ch eq "\"" and substr($str, $i - 1, 1) ne "\\"
$ch eq "\"" substr($str, $i - 1, 1) ne "\\"
Truth table66%2/3
A and B
A= $ch eq "\""B= substr($str, $i - 1, 1) ne "\\"
ABresult
0X0
100
111
1229 3 $in_string = 0;
1230 }
1231 } elsif ($ch eq '"') {
1232 3 $in_string = 1;
1233 3 $out[++$ondx] = $ch;
1234 } elsif ($ch eq "'") {
1235 6 my $endx = index $str, "'", $i + 2;
1236 6 ▶ if ($endx < $i + 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($endx < $i + 2) 0 6 6
1237 0 error "cannot find closing apostrophe of char literal";
1238 0 return @out;
1239 }
1240 6 $out[++$ondx] = substr($str, $i, $endx - $i + 1);
1241 # print "idlsplit: $out[$ondx]\n";
1242 6 $i = $endx;
1243 } elsif ($ch =~ /[a-z_0-9\.]/i) {
1244 4921 ▶ if (! $in_lit) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($in_lit) 694 4227 4921
1245 694 $in_lit = 1;
1246 694 $ondx++;
1247 }
1248 4921 $out[$ondx] .= $ch;
1249 } elsif ($in_lit) {
1250 694 $in_lit = 0;
1251 # do preprocessor substitution
1252 694 ▶ if (exists $active_defines{$out[$ondx]}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $active_defines{$out[$ondx]}) 0 694 694
1253 0 my $value = $active_defines{$out[$ondx]};
1254 0 ▶ if ("$value" ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if ("$value" ne "") 0 0 0
1255 0 my @addl = idlsplit($value);
1256 0 pop @out; # remove original symbol
1257 0 push @out, @addl; # add replacement text
1258 0 $ondx = $#out;
1259 }
1260 }
1261 694 ▶ if ($ch !~ /\s/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ch =~ /\s/) 236 458 694
1262 236 $out[++$ondx] = $ch;
1263 }
1264 } elsif ($ch !~ /\s/) {
1265 247 $out[++$ondx] = $ch;
1266 }
1267 }
1268 224 ▶ if ($in_lit) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_lit) 0 224 224
1269 # do preprocessor substitution
1270 0 ▶ if (exists $active_defines{$out[$ondx]}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $active_defines{$out[$ondx]}) 0 0 0
1271 0 my $value = $active_defines{$out[$ondx]};
1272 0 ▶ if ("$value" ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if ("$value" ne "") 0 0 0
1273 0 my @addl = idlsplit($value);
1274 0 pop @out; # remove original symbol
1275 0 push @out, @addl; # add replacement text
1276 0 $ondx = $#out;
1277 }
1278 }
1279 }
1280 # For simplification of further processing:
1281 # 1. Turn extra-long and unsigned types into single keyword
1282 # long double => long_double
1283 # unsigned short => unsigned_short
1284 # 2. Put scoped names back together, e.g. 'A' ':' ':' 'B' => 'A::B'
1285 # Also, discard global-scope designators. (leading ::)
1286 # 3. Put the sign and value of negative numbers back together
1287 # 4. Put bounded string type (string<bound>) into one element
1288 224 ▶ for ($i = 0; $i < $#out; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $#out) 951 224 1175
1289 951 ▶ if ($out[$i] eq 'long') {
Branch: 4 branches
BranchTrueFalseTotal
if ($out[$i] eq 'long') { } 30 921 951
elsif ($out[$i] eq 'unsigned') { } 1 920 921
elsif ($out[$i] eq ':' and $out[$i + 1] eq ':') { } 0 920 920
elsif ($out[$i] eq '-' and $out[$i + 1] =~ /^\d/) { } 0 1840 1840
1290 30 ▶ if ($out[$i+1] eq 'double' && !$long_double_supported) {
Branch: 1 branch
BranchTrueFalseTotal
if ($out[$i + 1] eq "double" and not $CORBA::IDLtree::long_double_supported) 0 30 30
Condition66%2/3
$out[$i + 1] eq "double" and not $CORBA::IDLtree::long_double_supported
!ll&&!rl&&r
2550
MC/DC0%0/2
$out[$i + 1] eq "double" and not $CORBA::IDLtree::long_double_supported
$out[$i + 1] eq "double" not $CORBA::IDLtree::long_double_supported
Truth table66%2/3
A and not(B)
A= $out[$i + 1] eq "double"B= not $CORBA::IDLtree::long_double_supported
ABresult
0X0
100
111
1291 0 error("ERROR: long double not supported");
1292 }
1293 30 ▶ if ($out[$i+1] eq 'long' or $out[$i+1] eq 'double') {
Branch: 1 branch
BranchTrueFalseTotal
if ($out[$i + 1] eq "long" or $out[$i + 1] eq "double") 10 20 30
Condition100%3/3
$out[$i + 1] eq "long" or $out[$i + 1] eq "double"
l!l&&r!l&&!r
5520
MC/DC100%2/2
$out[$i + 1] eq "long" or $out[$i + 1] eq "double"
$out[$i + 1] eq "long" $out[$i + 1] eq "double"
Truth table100%3/3
A or B
A= $out[$i + 1] eq "long"B= $out[$i + 1] eq "double"
ABresult
1X1
011
000
1294 10 $out[$i] .= '_' . $out[$i + 1];
1295 10 splice @out, $i + 1, 1;
1296 }
1297 } elsif ($out[$i] eq 'unsigned') {
1298 1 ▶ if ($out[$i+1] eq 'short' or $out[$i+1] eq 'long') {
Branch: 1 branch
BranchTrueFalseTotal
if ($out[$i + 1] eq "short" or $out[$i + 1] eq "long") 1 0 1
Condition33%1/3
$out[$i + 1] eq "short" or $out[$i + 1] eq "long"
l!l&&r!l&&!r
100
MC/DC0%0/2
$out[$i + 1] eq "short" or $out[$i + 1] eq "long"
$out[$i + 1] eq "short" $out[$i + 1] eq "long"
Truth table33%1/3
A or B
A= $out[$i + 1] eq "short"B= $out[$i + 1] eq "long"
ABresult
1X1
011
000
1299 1 $out[$i] .= '_' . $out[$i + 1];
1300 1 splice @out, $i + 1, 1;
1301 1 ▶ if ($out[$i+1] eq 'long') {
Branch: 1 branch
BranchTrueFalseTotal
if ($out[$i + 1] eq "long") 0 1 1
1302 0 $out[$i] .= '_long';
1303 0 splice @out, $i + 1, 1;
1304 }
1305 }
1306 ▶ } elsif ($out[$i] eq ':' and $out[$i+1] eq ':') {
Condition66%2/3
$out[$i] eq ":" and $out[$i + 1] eq ":"
!ll&&!rl&&r
900200
MC/DC0%0/2
$out[$i] eq ":" and $out[$i + 1] eq ":"
$out[$i] eq ":" $out[$i + 1] eq ":"
Truth table66%2/3
A and B
A= $out[$i] eq ":"B= $out[$i + 1] eq ":"
ABresult
0X0
100
111
1307 # remove "::"
1308 # except when inheriting from an absolute qualified superclass
1309 # such as: valuetype vt : ::absolute::qualified::superclass {
1310 # ...
1311 # };
1312 # here, we need to preserve the first ':' as inheritance intro
1313 0 ▶ unless ($i < $#out - 1 && $out[$i+2] eq ':') {
Branch: 1 branch
BranchTrueFalseTotal
unless ($i < $#out - 1 and $out[$i + 2] eq ":") 0 0 0
Condition0%0/3
$i < $#out - 1 and $out[$i + 2] eq ":"
!ll&&!rl&&r
000
MC/DC0%0/2
$i < $#out - 1 and $out[$i + 2] eq ":"
$i < $#out - 1 $out[$i + 2] eq ":"
Truth table0%0/3
A and B
A= $i < $#out - 1B= $out[$i + 2] eq ":"
ABresult
0X0
100
111
1314 0 splice @out, $i, 2;
1315 0 ▶ if ($i > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i > 0) 0 0 0
1316 0 my $prev = $out[$i - 1];
1317 0 ▶ if ($prev =~ /\w$/ and !exists($keywords{$prev})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($prev =~ /\w$/ and not exists $keywords{$prev}) 0 0 0
Condition0%0/3
$prev =~ /\w$/ and not exists $keywords{$prev}
!ll&&!rl&&r
000
MC/DC0%0/2
$prev =~ /\w$/ and not exists $keywords{$prev}
$prev =~ /\w$/ not exists $keywords{$prev}
Truth table0%0/3
A and not(B)
A= $prev =~ /\w$/B= not exists $keywords{$prev}
ABresult
0X0
100
111
1318 0 ▶ if ($out[$i - 1] eq 'CORBA') {
Branch: 1 branch
BranchTrueFalseTotal
if ($out[$i - 1] eq 'CORBA') { } 0 0 0
1319 0 $out[$i - 1] = $out[$i]; # discard CORBA namespace
1320 } else {
1321 0 $out[$i - 1] .= '::' . $out[$i];
1322 }
1323 0 splice @out, $i--, 1;
1324 }
1325 }
1326 }
1327 # } elsif ($out[$i] eq '@' and $out[$i+1] =~ /^\w/) {
1328 # # Put annotation '@' together with its identifier
1329 # $out[$i] .= $out[$i + 1];
1330 # splice @out, $i + 1, 1;
1331 ▶ } elsif ($out[$i] eq '-' and $out[$i+1] =~ /^\d/) {
Condition33%1/3
$out[$i] eq "-" and $out[$i + 1] =~ /^\d/
!ll&&!rl&&r
92000
MC/DC0%0/2
$out[$i] eq "-" and $out[$i + 1] =~ /^\d/
$out[$i] eq "-" $out[$i + 1] =~ /^\d/
Truth table33%1/3
A and B
A= $out[$i] eq "-"B= $out[$i + 1] =~ /^\d/
ABresult
0X0
100
111
1332 0 ▶ if ($i == 0 || $out[$i-1] eq '(' || $out[$i-1] eq '='
Branch: 1 branch
BranchTrueFalseTotal
if ($i == 0 or $out[$i - 1] eq "(" or $out[$i - 1] eq "=" or $in_preprocessor) 0 0 0
Condition0%0/9
$i == 0 or $out[$i - 1] eq "(" or $out[$i - 1] eq "=" or $in_preprocessor
l!l&&r!l&&!r
000
$i == 0 or $out[$i - 1] eq "(" or $out[$i - 1] eq "="
l!l&&r!l&&!r
000
$i == 0 or $out[$i - 1] eq "("
l!l&&r!l&&!r
000
MC/DC0%0/4
$i == 0 or $out[$i - 1] eq "(" or $out[$i - 1] eq "=" or $in_preprocessor
$i == 0 $out[$i - 1] eq "(" $out[$i - 1] eq "=" $in_preprocessor
Truth table0%0/5
A or B or C or D
A= $i == 0B= $out[$i - 1] eq "("C= $out[$i - 1] eq "="D= $in_preprocessor
ABCDresult
1XXX1
01XX1
001X1
00011
00000
1333 || $in_preprocessor) {
1334 0 $out[$i] .= $out[$i + 1];
1335 0 splice @out, $i + 1, 1;
1336 }
1337 }
1338 # Restore floating point scientific notation (e.g. 10.0e-3)
1339 951 ▶ if ($out[$i] =~ /^[\-\d][\d\.]*e$/i and
Branch: 1 branch
BranchTrueFalseTotal
if ($out[$i] =~ /^[\-\d][\d\.]*e$/i and $out[$i + 1] eq "+" || $out[$i + 1] eq "-") 0 951 951
Condition16%1/6
$out[$i] =~ /^[\-\d][\d\.]*e$/i and $out[$i + 1] eq "+" || $out[$i + 1] eq "-"
!ll&&!rl&&r
95100
$out[$i + 1] eq "+" or $out[$i + 1] eq "-"
l!l&&r!l&&!r
000
MC/DC0%0/3
$out[$i] =~ /^[\-\d][\d\.]*e$/i and $out[$i + 1] eq "+" || $out[$i + 1] eq "-"
$out[$i] =~ /^[\-\d][\d\.]*e$/i $out[$i + 1] eq "+" $out[$i + 1] eq "-"
Truth table25%1/4
A and B or C
A= $out[$i] =~ /^[\-\d][\d\.]*e$/iB= $out[$i + 1] eq "+"C= $out[$i + 1] eq "-"
ABCresult
0XX0
1000
11X1
1011
1340 $out[$i+1] eq '+' || $out[$i+1] eq '-') {
1341 0 $out[$i] .= $out[$i + 1] . $out[$i + 2];
1342 0 splice @out, $i + 1, 2;
1343 }
1344 }
1345 # Bounded strings are special-cased:
1346 # compress the notation "string<bound>" into one element
1347 224 ▶ for ($i = 0; $i < $#out - 1; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $#out - 1) 727 224 951
1348 727 ▶ if ($out[$i] =~ /^w?string$/
Branch: 1 branch
BranchTrueFalseTotal
if ($out[$i] =~ /^w?string$/ and ($out[$i + 1] eq "<" and $out[$i + 3] eq ">")) 0 727 727
Condition50%3/6
$out[$i] =~ /^w?string$/ and ($out[$i + 1] eq "<" and $out[$i + 3] eq ">")
!ll&&!rl&&r
703240
$out[$i + 1] eq "<" and $out[$i + 3] eq ">"
!ll&&!rl&&r
2400
MC/DC0%0/3
$out[$i] =~ /^w?string$/ and ($out[$i + 1] eq "<" and $out[$i + 3] eq ">")
$out[$i] =~ /^w?string$/ $out[$i + 1] eq "<" $out[$i + 3] eq ">"
Truth table50%2/4
A and B and C
A= $out[$i] =~ /^w?string$/B= $out[$i + 1] eq "<"C= $out[$i + 3] eq ">"
ABCresult
0XX0
10X0
1100
1111
1349 and $out[$i+1] eq '<' && $out[$i+3] eq '>') {
1350 0 my $bound = $out[$i+2];
1351 0 $out[$i] .= '<' . $bound . '>';
1352 0 splice @out, $i + 1, 3;
1353 }
1354 }
1355 224 @out;
1356 }
1357  
1358  
1359 17 ▶sub is_elementary_type {
Subroutine is_elementary_type: called CC=10 SCAR=37.7
Pod documented
1360 # Returns the type index of an elementary type,
1361 # or 0 if the type is not elementary.
1362 17 my $tdesc = shift; # argument: a type descriptor
1363 17 ▶ unless (defined $tdesc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $tdesc) 0 17 17
1364 0 error("CORBA::IDLtree::is_elementary_type called on undefined tdesc"
1365 . Carp::longmess());
1366 0 return 0;
1367 }
1368 17 my $recurse_into_typedef = 0; # optional argument
1369 17 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 17 17
1370 0 $recurse_into_typedef = shift;
1371 }
1372 17 my $rv = 0;
1373 17 ▶ if ($tdesc >= BOOLEAN && $tdesc <= ANY) {
Branch: 2 branches
BranchTrueFalseTotal
if ($tdesc >= 1 and $tdesc <= 18) { } 17 0 17
elsif ($recurse_into_typedef and isnode($tdesc) and $tdesc->[0] == 24) { } 0 0 0
Condition33%1/3
$tdesc >= 1 and $tdesc <= 18
!ll&&!rl&&r
0017
MC/DC0%0/2
$tdesc >= 1 and $tdesc <= 18
$tdesc >= 1 $tdesc <= 18
Truth table33%1/3
A and B
A= $tdesc >= 1B= $tdesc <= 18
ABresult
0X0
100
111
1374 # For our purposes, sequences, bounded strings, enums, structs, and
1375 # unions do not count as elementary types. They are represented as a
1376 # further node, i.e. the argument to is_elementary_type is not a
1377 # numeric constant but instead contains a reference to the defining
1378 # node.
1379 17 $rv = $tdesc;
1380 ▶ } elsif ($recurse_into_typedef && isnode($tdesc) &&
Condition0%0/6
$recurse_into_typedef and isnode($tdesc) and $tdesc->[0] == 24
!ll&&!rl&&r
000
$recurse_into_typedef and isnode($tdesc)
!ll&&!rl&&r
000
MC/DC0%0/3
$recurse_into_typedef and isnode($tdesc) and $tdesc->[0] == 24
$recurse_into_typedef isnode($tdesc) $tdesc->[0] == 24
Truth table0%0/4
A and B and C
A= $recurse_into_typedefB= isnode($tdesc)C= $tdesc->[0] == 24
ABCresult
0XX0
10X0
1100
1111
1381 $$tdesc[TYPE] == TYPEDEF) {
1382 0 my @origtype_and_dim = @{$$tdesc[SUBORDINATES]};
1383 0 my $dimref = $origtype_and_dim[1];
1384 0 ▶ unless ($dimref && @{$dimref}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dimref and @{$dimref;}) 0 0 0
Condition0%0/3
$dimref and @{$dimref;}
!ll&&!rl&&r
000
MC/DC0%0/2
$dimref and @{$dimref;}
$dimref @{$dimref;}
Truth table0%0/3
A and B
A= $dimrefB= @{$dimref;}
ABresult
0X0
100
111
1385 0 $rv = is_elementary_type($origtype_and_dim[0], 1);
1386 }
1387 }
1388 17 $rv;
1389 }
1390  
1391  
1392 221 ▶sub predef_type {
Subroutine predef_type: called CC=7 SCAR=24.2
Pod documented
1393 221 my $idltype = shift;
1394 221 my $i;
1395 221 ▶ for ($i = 1; $i <= $#predef_types; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#predef_types) 6515 110 6625
1396 6515 ▶ if ($idltype eq $predef_types[$i]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($idltype eq $predef_types[$i]) 111 6404 6515
1397 111 ▶ if ($string_bound and $idltype =~ /^w?string$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CORBA::IDLtree::string_bound and $idltype =~ /^w?string$/) { } 0 111 111
Condition33%1/3
$CORBA::IDLtree::string_bound and $idltype =~ /^w?string$/
!ll&&!rl&&r
11100
MC/DC0%0/2
$CORBA::IDLtree::string_bound and $idltype =~ /^w?string$/
$CORBA::IDLtree::string_bound $idltype =~ /^w?string$/
Truth table33%1/3
A and B
A= $CORBA::IDLtree::string_boundB= $idltype =~ /^w?string$/
ABresult
0X0
100
111
1398 0 info("bounding $idltype to $string_bound");
1399 0 $idltype .= "<$string_bound>";
1400 } else {
1401 111 return $i;
1402 }
1403 }
1404 }
1405 110 ▶ if ($idltype =~ /^(w?string)\s*<(\d+)\s*>/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($idltype =~ /^(w?string)\s*<(\d+)\s*>/) 0 110 110
1406 0 my $type;
1407 0 ▶ $type = ($1 eq "wstring" ? BOUNDED_WSTRING : BOUNDED_STRING);
Branch: 1 branch
BranchTrueFalseTotal
$1 eq 'wstring' ? : 0 0 0
1408 0 my $bound = $2;
1409 0 return [ $type, $bound, 0, 0, 0, curr_scope ];
1410 }
1411 110 0;
1412 }
1413  
1414  
1415 185 ▶sub is_valid_identifier {
Subroutine is_valid_identifier: called CC=4 SCAR=17.9
Pod documented
1416 185 my $name = shift;
1417 185 ▶ if ($name !~ /^[a-z_:]/i || ($name =~ /^_/ && !$leading_underscore_allowed)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $name =~ /^[a-z_:]/i or $name =~ /^_/ and not $CORBA::IDLtree::leading_underscore_allowed) 0 185 185
Condition33%2/6
not $name =~ /^[a-z_:]/i or $name =~ /^_/ and not $CORBA::IDLtree::leading_underscore_allowed
l!l&&r!l&&!r
00185
$name =~ /^_/ and not $CORBA::IDLtree::leading_underscore_allowed
!ll&&!rl&&r
18500
MC/DC0%0/3
not $name =~ /^[a-z_:]/i or $name =~ /^_/ and not $CORBA::IDLtree::leading_underscore_allowed
not $name =~ /^[a-z_:]/i $name =~ /^_/ not $CORBA::IDLtree::leading_underscore_allowed
Truth table25%1/4
not(A) or B and not(C)
A= not $name =~ /^[a-z_:]/iB= $name =~ /^_/C= not $CORBA::IDLtree::leading_underscore_allowed
ABCresult
1XX1
0111
00X0
0100
1418 0 return 0; # illegal first character
1419 }
1420 185 $name !~ /[^a-z0-9_:\.]/i
1421 }
1422  
1423 169 ▶sub check_name {
Subroutine check_name: called CC=7 SCAR=24.7
Pod undocumented
1424 169 my $name = shift;
1425 169 my $msg = "name";
1426 169 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 81 88 169
1427 81 $msg = shift;
1428 }
1429 169 ▶ unless (is_valid_identifier($name)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (is_valid_identifier($name)) 0 169 169
1430 0 ▶ unless ($name =~ /^w?string<.*>$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($name =~ /^w?string<.*>$/) 0 0 0
1431 0 error "illegal $msg: $name";
1432 }
1433 }
1434 169 ▶ if (exists $keywords{lc($name)}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $keywords{lc $name}) 0 169 169
1435 0 ▶ if ($permissive) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CORBA::IDLtree::permissive) { } 0 0 0
1436 0 info "WARNING: illegal $msg: '$name' is an IDL keyword";
1437 } else {
1438 0 error "illegal $msg: '$name' is an IDL keyword";
1439 }
1440 }
1441 # according to spec, a leading underscore disables keyword check but
1442 # is not part of the identifier
1443 169 ▶ unless ($leading_underscore_allowed > 1) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($CORBA::IDLtree::leading_underscore_allowed > 1) 169 0 169
1444 169 $name =~ s/^_//;
1445 }
1446 169 return $name;
1447 }
1448  
1449 13 ▶sub check_typename {
Subroutine check_typename: called CC=8 SCAR=30.8
Pod undocumented
1450 13 my $name = shift;
1451 13 my $msg = "name";
1452 13 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 13 0 13
1453 13 $msg = shift;
1454 }
1455 13 ▶ unless (is_valid_identifier($name)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (is_valid_identifier($name)) 0 13 13
1456 0 ▶ unless ($name =~ /^w?string<.*>$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($name =~ /^w?string<.*>$/) 0 0 0
1457 0 error "illegal $msg: $name";
1458 }
1459 }
1460 13 my $pt = predef_type($name);
1461 13 ▶ if ((ref($pt) ? $pt->[0] : $pt) < TYPEDEF) {
Branch: 2 branches
BranchTrueFalseTotal
if ((ref $pt ? $pt->[0] : $pt) < 24) 13 0 13
ref $pt ? : 0 13 13
1462 # elementary type => OK
1463 13 return $name;
1464 }
1465 0 ▶ if (exists $keywords{lc($name)}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $keywords{lc $name}) 0 0 0
1466 0 ▶ if ($permissive) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CORBA::IDLtree::permissive) { } 0 0 0
1467 0 info "WARNING: illegal $msg: '$name' is an IDL keyword";
1468 } else {
1469 0 error "illegal $msg: '$name' is an IDL keyword";
1470 }
1471 }
1472 # according to spec, a leading underscore disables keyword check but
1473 # is not part of the identifier
1474 0 $name =~ s/^_//;
1475 0 return $name;
1476 }
1477  
1478 2 my @scopestack = ();
1479 # The scope stack. Elements in this stack are references to
1480 # MODULE or INTERFACE nodes.
1481  
1482 145 ▶sub curr_scope {
Subroutine curr_scope: called CC=2 SCAR=6.9
Pod undocumented
1483 145 ▶ ($#scopestack < 0 ? 0 : $scopestack[$#scopestack]);
Branch: 1 branch
BranchTrueFalseTotal
$#scopestack < 0 ? : 5 140 145
1484 }
1485  
1486 183 ▶sub annotation {
Subroutine annotation: called CC=2 SCAR=8.4
Pod undocumented
1487 183 my $retval = 0;
1488 183 ▶ if (@annotations) {
Branch: 1 branch
BranchTrueFalseTotal
if (@annotations) 0 183 183
1489 0 $retval = [ @annotations ];
1490 0 @annotations = ();
1491 }
1492 183 return $retval;
1493 }
1494  
1495 236 ▶sub comment {
Subroutine comment: called CC=2 SCAR=9.2
Pod documented
1496 236 my $cmnt = 0;
1497 236 ▶ if (@post_comment) {
Branch: 1 branch
BranchTrueFalseTotal
if (@post_comment) 0 236 236
1498 0 $cmnt = [ $line_number_of_post_comment, [ @post_comment ] ];
1499 0 @post_comment = ();
1500 0 $line_number_of_post_comment = 0;
1501 }
1502 236 return $cmnt;
1503 }
1504  
1505  
1506 8 ▶sub parse_sequence {
Subroutine parse_sequence: called CC=7 SCAR=21.0
Pod undocumented
1507 8 my ($argref, $symroot) = @_;
1508 8 ▶ if (shift @{$argref} ne '<') {
Branch: 1 branch
BranchTrueFalseTotal
if (shift @{$argref;} ne "<") 0 8 8
1509 0 error "expecting '<'";
1510 0 return 0;
1511 }
1512 8 my $nxtarg = shift @{$argref};
1513 8 my $type = predef_type $nxtarg;
1514 8 ▶ if (! $type) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $type) { } 3 5 8
elsif ($type == 22) { } 0 5 5
1515 3 $type = find_node_i($nxtarg, $symroot);
1516 3 ▶ if (! $type) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($type) 0 3 3
1517 0 error "unknown sequence type";
1518 0 return 0;
1519 }
1520 } elsif ($type == SEQUENCE) {
1521 0 $type = parse_sequence($argref, $symroot);
1522 }
1523 8 my $bound = 0;
1524 8 $nxtarg = shift @{$argref};
1525 8 ▶ if ($nxtarg eq ',') {
Branch: 1 branch
BranchTrueFalseTotal
if ($nxtarg eq ",") 2 6 8
1526 2 $bound = shift @{$argref};
1527 2 $nxtarg = shift @{$argref};
1528 }
1529 8 ▶ if ($nxtarg ne '>') {
Branch: 1 branch
BranchTrueFalseTotal
if ($nxtarg ne ">") 0 8 8
1530 0 error "expecting '<'";
1531 0 return 0;
1532 }
1533 8 return [SEQUENCE, $bound, $type, annotation, comment, curr_scope];
1534 }
1535  
1536  
1537 88 ▶sub parse_type {
Subroutine parse_type: called CC=15 SCAR=51.0
Pod undocumented
1538 88 my ($typename, $argref, $symtreeref) = @_;
1539 88 my $type;
1540 88 ▶ if ($typename eq 'fixed') {
Branch: 3 branches
BranchTrueFalseTotal
if ($typename eq 'fixed') { } 0 88 88
elsif ($typename =~ /^(w?string)<([\w:]+)>$/) { } 0 88 88
elsif ($typename eq 'sequence') { } 8 80 88
1541 0 ▶ if (shift @{$argref} ne '<') {
Branch: 1 branch
BranchTrueFalseTotal
if (shift @{$argref;} ne "<") 0 0 0
1542 0 error "expecting '<' after 'fixed'";
1543 0 return 0;
1544 }
1545 0 my $digits = shift @{$argref};
1546 0 ▶ if ($digits =~ /\D/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digits =~ /\D/) 0 0 0
1547 0 error "digit number in 'fixed' must be constant";
1548 0 return 0;
1549 }
1550 0 ▶ if (shift @{$argref} ne ',') {
Branch: 1 branch
BranchTrueFalseTotal
if (shift @{$argref;} ne ",") 0 0 0
1551 0 error "expecting comma in 'fixed'";
1552 0 return 0;
1553 }
1554 0 my $scale = shift @{$argref};
1555 0 ▶ if ($scale =~ /\D/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($scale =~ /\D/) 0 0 0
1556 0 error "scale number in 'fixed' must be constant";
1557 0 return 0;
1558 }
1559 0 ▶ if (shift @{$argref} ne '>') {
Branch: 1 branch
BranchTrueFalseTotal
if (shift @{$argref;} ne ">") 0 0 0
1560 0 error "expecting '>' at end of 'fixed'";
1561 0 return 0;
1562 }
1563 0 my @digits_and_scale = ($digits, $scale);
1564 0 $type = [ FIXED, "", \@digits_and_scale, annotation, comment, curr_scope ];
1565 } elsif ($typename =~ /^(w?string)<([\w:]+)>$/) { # bounded string
1566 0 my $t;
1567 0 ▶ $t = ($1 eq "wstring" ? BOUNDED_WSTRING : BOUNDED_STRING);
Branch: 1 branch
BranchTrueFalseTotal
$1 eq 'wstring' ? : 0 0 0
1568 0 my $bound = $2;
1569 0 ▶ if ($bound !~ /^\d/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($bound =~ /^\d/) 0 0 0
1570 0 my $boundtype = find_node_i($bound, $symtreeref);
1571 0 ▶ if (isnode $boundtype) {
Branch: 1 branch
BranchTrueFalseTotal
if (isnode($boundtype)) { } 0 0 0
1572 0 my @node = @{$boundtype};
1573 0 ▶ if ($node[TYPE] == CONST) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node[0] == 31) { } 0 0 0
1574 0 my($basetype, $expr_ref) = @{$node[SUBORDINATES]};
1575 0 my @expr = @{$expr_ref};
1576 0 ▶ if (scalar(@expr) > 1 or $expr[0] !~ /^\d/) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @expr > 1 or not $expr[0] =~ /^\d/) 0 0 0
Condition0%0/3
scalar @expr > 1 or not $expr[0] =~ /^\d/
l!l&&r!l&&!r
000
MC/DC0%0/2
scalar @expr > 1 or not $expr[0] =~ /^\d/
scalar @expr > 1 not $expr[0] =~ /^\d/
Truth table0%0/3
A or not(B)
A= scalar @expr > 1B= not $expr[0] =~ /^\d/
ABresult
1X1
011
000
1577 0 error("string bound expressions"
1578 . " are not yet implemented");
1579 }
1580 0 $bound = $expr[0];
1581 } else {
1582 0 error "illegal type for string bound";
1583 }
1584 } else {
1585 0 error "Cannot resolve string bound";
1586 }
1587 }
1588 0 $type = [ $t, $bound, 0, annotation, comment, curr_scope ];
1589 } elsif ($typename eq 'sequence') {
1590 8 $type = parse_sequence($argref, $symtreeref);
1591 } else {
1592 80 $type = find_node_i($typename, $symtreeref);
1593 }
1594 88 $type;
1595 }
1596  
1597  
1598 30 ▶sub parse_members {
Subroutine parse_members: called CC=36 SCAR=55.4
Pod undocumented
1599 # params: \@symbols, \@arg, $structref_or_vt_access
1600 # If the structref_or_vt_access is a reference then we
1601 # assume to be parsing a struct and the member data are stored
1602 # in the list referenced by $structref.
1603 # If the structref_or_vt_access is not a reference then we
1604 # assume to be parsing a valuetype state member. In that case
1605 # $structref_or_vt_access contains the value &PRIVATE or
1606 # &PUBLIC indicating the access of the state member.
1607 # The valuetype member is directly added to @$symtreeref.
1608 # returns: -1 for error;
1609 # 0 for success with enclosing scope still open;
1610 # 1 for success with enclosing scope closed (i.e. seen '};')
1611 30 my($symtreeref, $argref, $structref_or_vt_access, $comment) = @_;
1612 30 my $structref = 0;
1613 30 my $value_member_flag = 0;
1614 30 ▶ if (ref $structref_or_vt_access) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $structref_or_vt_access) { } 30 0 30
1615 30 $structref = $structref_or_vt_access;
1616 } else {
1617 0 $value_member_flag = $structref_or_vt_access;
1618 }
1619 30 ▶ while (@{$argref}) { # We're up here for a TYPE name
Branch: 1 branch
BranchTrueFalseTotal
if (@{$argref;}) 30 30 60
1620 30 my $first_thing = shift @{$argref}; # but it could also be '}'
1621 30 ▶ while ($first_thing eq '@') {
Branch: 1 branch
BranchTrueFalseTotal
if ($first_thing eq "\@") 0 30 30
1622 0 my $ann = shift @{$argref};
1623 0 parse_annotation_app($ann, $argref);
1624 0 $first_thing = shift @{$argref};
1625 }
1626 30 ▶ if ($first_thing eq '}') {
Branch: 1 branch
BranchTrueFalseTotal
if ($first_thing eq "}") 0 30 30
1627 0 unshift @{$argref}, '}';
1628 0 return 1; # return value signals closing of scope.
1629 }
1630 30 my $component_type = parse_type($first_thing, $argref, $symtreeref);
1631 30 ▶ if (! $component_type) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($component_type) 0 30 30
1632 0 error "unknown type $first_thing";
1633 0 return -1; # return value signals error.
1634 }
1635 30 ▶ if (in_annotation_def()) {
Branch: 1 branch
BranchTrueFalseTotal
if (&in_annotation_def()) 0 30 30
1636 0 my $component_name = shift @{$argref};
1637 0 my $default;
1638 0 ▶ if (@{$argref}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$argref;}) 0 0 0
1639 0 my $next = shift @{$argref};
1640 0 ▶ if ($next eq 'default') {
Branch: 1 branch
BranchTrueFalseTotal
if ($next eq "default") 0 0 0
1641 0 $default = shift @{$argref};
1642 }
1643 }
1644 0 push @{$structref}, [ $component_type, $component_name, $default ];
1645 0 ▶ if (@{$argref}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$argref;}) 0 0 0
1646 0 my $next = shift @{$argref};
1647 0 ▶ unless ($next eq ';') {
Branch: 1 branch
BranchTrueFalseTotal
unless ($next eq ";") 0 0 0
1648 0 error("parse_members($first_thing) : found '$next' (expecting ';')");
1649 0 return -1;
1650 }
1651 }
1652 0 next;
1653 }
1654 30 ▶ if (! is_type($component_type)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (is_type($component_type)) 0 30 30
1655 0 error "$first_thing is not a type";
1656 0 return -1;
1657 }
1658 30 ▶ while (@{$argref}) { # We're here for VARIABLE name(s)
Branch: 1 branch
BranchTrueFalseTotal
if (@{$argref;}) 30 17 47
1659 30 $first_thing = shift @{$argref};
1660 30 ▶ while ($first_thing eq '@') {
Branch: 1 branch
BranchTrueFalseTotal
if ($first_thing eq "\@") 0 30 30
1661 0 my $ann = shift @{$argref};
1662 0 parse_annotation_app($ann, $argref);
1663 0 $first_thing = shift @{$argref};
1664 }
1665 30 ▶ if ($first_thing eq '}') {
Branch: 1 branch
BranchTrueFalseTotal
if ($first_thing eq "}") 0 30 30
1666 0 unshift @{$argref}, '}';
1667 0 error "parse_members: unexpected '}'";
1668 0 return 1; # return value signals closing of scope.
1669 }
1670 30 my $component_name = $first_thing;
1671 30 $component_name = check_name($component_name);
1672 30 my @dimensions = ();
1673 30 my $nxtarg = "";
1674 30 ▶ while (@{$argref}) { # We're here for a variable's DIMENSIONS
Branch: 1 branch
BranchTrueFalseTotal
if (@{$argref;}) 13 17 30
1675 13 $nxtarg = shift @{$argref};
1676 13 ▶ if ($nxtarg eq '[') {
Branch: 2 branches
BranchTrueFalseTotal
if ($nxtarg eq '[') { } 0 13 13
elsif ($nxtarg eq ',' or $nxtarg eq ';') { } 13 0 13
1677 0 my $dim = shift @{$argref};
1678 0 ▶ if (shift @{$argref} ne ']') {
Branch: 1 branch
BranchTrueFalseTotal
if (shift @{$argref;} ne "]") 0 0 0
1679 0 error "expecting ']'";
1680 0 return -1;
1681 }
1682 0 push @dimensions, $dim;
1683 ▶ } elsif ($nxtarg eq ',' || $nxtarg eq ';') {
Condition33%1/3
$nxtarg eq "," or $nxtarg eq ";"
l!l&&r!l&&!r
0130
MC/DC0%0/2
$nxtarg eq "," or $nxtarg eq ";"
$nxtarg eq "," $nxtarg eq ";"
Truth table33%1/3
A or B
A= $nxtarg eq ","B= $nxtarg eq ";"
ABresult
1X1
011
000
1684 13 last;
1685 } else {
1686 0 error "component declaration syntax error";
1687 0 return -1;
1688 }
1689 }
1690 30 my $dimref = 0;
1691 30 ▶ if (@dimensions) {
Branch: 1 branch
BranchTrueFalseTotal
if (@dimensions) 0 30 30
1692 0 $dimref = [ @dimensions ];
1693 0 ▶ unless ($permissive) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($CORBA::IDLtree::permissive) 0 0 0
1694 0 info "$component_name : array members are DEPRECATED";
1695 }
1696 }
1697 # check for duplicate component names
1698 30 my $name_found = "";
1699 30 ▶ if ($value_member_flag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value_member_flag) { } 0 30 30
1700 0 for (@$symtreeref) {
1701 0 my $type = $_->[TYPE];
1702 0 ▶ if (isnode($type) && $type->[NAME] eq $component_name) {
Branch: 1 branch
BranchTrueFalseTotal
if (isnode($type) and $type->[1] eq $component_name) 0 0 0
Condition0%0/3
isnode($type) and $type->[1] eq $component_name
!ll&&!rl&&r
000
MC/DC0%0/2
isnode($type) and $type->[1] eq $component_name
isnode($type) $type->[1] eq $component_name
Truth table0%0/3
A and B
A= isnode($type)B= $type->[1] eq $component_name
ABresult
0X0
100
111
1703 0 $name_found = $component_name;
1704 0 last;
1705 }
1706 }
1707 } else {
1708 30 for (@$structref) {
1709 113 ▶ next unless ref $_;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $_ 15 98 113
1710 98 ▶ next if $_->[TYPE] == CASE || $_->[TYPE] == DEFAULT;
Branch: 1 branch
BranchTrueFalseTotal
if $_->[0] == 28 or $_->[0] == 29 53 45 98
Condition100%3/3
$_->[0] == 28 or $_->[0] == 29
l!l&&r!l&&!r
46745
MC/DC100%2/2
$_->[0] == 28 or $_->[0] == 29
$_->[0] == 28 $_->[0] == 29
Truth table100%3/3
A or B
A= $_->[0] == 28B= $_->[0] == 29
ABresult
1X1
011
000
1711 45 ▶ if ($_->[TYPE] != REMARK && $_->[NAME] eq $component_name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->[0] != 48 and $_->[1] eq $component_name) 0 45 45
Condition33%1/3
$_->[0] != 48 and $_->[1] eq $component_name
!ll&&!rl&&r
0450
MC/DC0%0/2
$_->[0] != 48 and $_->[1] eq $component_name
$_->[0] != 48 $_->[1] eq $component_name
Truth table33%1/3
A and B
A= $_->[0] != 48B= $_->[1] eq $component_name
ABresult
0X0
100
111
1712 0 $name_found = $component_name;
1713 0 last;
1714 }
1715 }
1716 }
1717 30 ▶ if ($name_found) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name_found) 0 30 30
1718 0 error "duplicate component name $name_found";
1719 0 return -1;
1720 }
1721 30 ▶ unless (defined $comment) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $comment) 15 15 30
1722 15 $comment = comment();
1723 }
1724 30 my $member_node = [ $component_type, $component_name, $dimref,
1725 annotation(), $comment ];
1726 30 ▶ if ($value_member_flag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value_member_flag) { } 0 30 30
1727 0 push @{$symtreeref}, [ $value_member_flag, $member_node ];
1728 } else {
1729 30 push @{$structref}, $member_node;
1730 }
1731 30 ▶ last if ($nxtarg eq ';');
Branch: 1 branch
BranchTrueFalseTotal
if $nxtarg eq ";" 13 17 30
1732 }
1733 }
1734 0 # return value signals success with scope still open.
1735 30 }
1736  
1737  
1738 2 my @prev_symroots = ();
1739 # Stack of the roots of previously constructed symtrees.
1740 # Used by find_node_i() for identifying symbols.
1741 # Elements are added to/removed from the front of this,
1742 # i.e. using unshift/shift (as opposed to push/pop.)
1743  
1744 2 my @fh = qw/ IN0 IN1 IN2 IN3 IN4 IN5 IN6 IN7 IN8 IN9/;
1745 # Input file handles (constants)
1746  
1747 # Cache of previously parsed includefiles
1748 2 my $includecache = new CORBA::IDLtree::Cache();
1749 2 my $did_emucppmsg = 0; # auxiliary to sub emucppmsg
1750  
1751 2 my @struct = (); # Temporary storage for struct/union/exception/
1752 # @annotation definition members.
1753 2 my @typestack = (); # For struct/union/exception, typestack, namestack, and
1754 2 my @namestack = (); # cmntstack move in parallel.
1755 # For valuetypes, only typestack is used.
1756 # For annotation definitions, @struct is flushed to
1757 # @annoDefs.
1758  
1759 2 my @annostack = (); # The annotation stack stores the concrete annotations
1760 # given on a struct/union/exception/valuetype declaration, e.g.
1761 # @external
1762 # struct mystruct {
1763 # ...
1764 # };
1765 # It is needed because the node is not constructed until the end of the
1766 # structure declaration, and members may have own annotations which would
1767 # overwrite the annotations of the type.
1768  
1769 2 my @cmntstack = (); # The comment stack stores a trailing comment on the
1770 # struct/union/exception declaration line, e.g.
1771 # struct mystruct { // This comment is stored in @cmntstack.
1772 # ...
1773 # };
1774 # It is needed because the node is not constructed until the end of the
1775 # structure declaration, and members may have trailing comments which
1776 # would overwrite the single post_comment buffer.
1777  
1778 166 ▶sub in_annotation_def() {
Subroutine in_annotation_def: called CC=2 SCAR=7.2
Pod undocumented
1779 166 ▶ return (@typestack && $typestack[$#typestack] == ANNOTATION);
Condition66%2/3
@typestack && $typestack[$#typestack] == ANNOTATION()
!ll&&!rl&&r
107590
MC/DC0%0/2
@typestack && $typestack[$#typestack] == ANNOTATION()
@typestack $typestack[$#typestack] == ANNOTATION()
Truth table66%2/3
A && B
A= @typestackB= $typestack[$#typestack] == ANNOTATION()
ABresult
0X0
100
111
1780 }
1781  
1782 0 ▶sub set_verbose {
Subroutine set_verbose: not called CC=2 SCAR=17.9
Pod documented
1783 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
1784 0 $verbose = shift;
1785 } else {
1786 0 $verbose = 1;
1787 }
1788 }
1789  
1790 1 ▶sub emucppmsg {
Subroutine emucppmsg: called CC=2 SCAR=7.1
Pod undocumented
1791 1 ▶ if (! $did_emucppmsg) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $did_emucppmsg) 1 0 1
1792 1 info("// using preprocessor emulation");
1793 1 $did_emucppmsg = 1;
1794 }
1795 }
1796  
1797 0 ▶sub use_system_preprocessor {
Subroutine use_system_preprocessor: not called CC=1 SCAR=6.9
Pod undocumented
1798 0 $emucpp = 0;
1799 }
1800  
1801 0 ▶sub eval_preproc_expr {
Subroutine eval_preproc_expr: not called CC=8 SCAR=42.8
Pod undocumented
1802 0 my @arg = @_;
1803 0 my $symbol = shift @arg;
1804 0 ▶ if ($symbol eq 'defined') {
Branch: 3 branches
BranchTrueFalseTotal
if ($symbol eq 'defined') { } 0 0 0
elsif ($symbol =~ /^[A-z]/) { } 0 0 0
elsif (not $symbol =~ /^\d+$/) { } 0 0 0
1805 0 ▶ $arg[0] eq '(' and shift @arg; # discard open-paren
Branch: 1 branch
BranchTrueFalseTotal
$arg[0] eq "(" and shift @arg 0 0 0
1806 0 $symbol = shift @arg;
1807 0 ▶ $arg[0] eq ')' and shift @arg; # discard close-paren
Branch: 1 branch
BranchTrueFalseTotal
$arg[0] eq ")" and shift @arg 0 0 0
1808 0 ▶ if (@arg or $symbol !~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (@arg or not $symbol =~ /^\d+$/) 0 0 0
Condition0%0/3
@arg or not $symbol =~ /^\d+$/
l!l&&r!l&&!r
000
MC/DC0%0/2
@arg or not $symbol =~ /^\d+$/
@arg not $symbol =~ /^\d+$/
Truth table0%0/3
A or not(B)
A= @argB= not $symbol =~ /^\d+$/
ABresult
1X1
011
000
1809 # There is more than the closing paren or
1810 # $symbol has an unimplemented (non numeric) value
1811 0 error "warning: #if not fully implemented\n";
1812 }
1813 0 return $symbol;
1814 } elsif ($symbol =~ /^[A-z]/) {
1815 # NB: sub idlsplit has already done symbol substitution
1816 0 error "built-in preprocessor does not know how to interpret $symbol";
1817 0 return 0;
1818 } elsif ($symbol !~ /^\d+$/) {
1819 0 error "warning: #if expressions not yet implemented\n";
1820 }
1821 $symbol
1822 0 }
1823  
1824 0 ▶sub skip_input {
Subroutine skip_input: not called CC=18 SCAR=58.3
Pod undocumented
1825 0 my $count = 0;
1826 0 my $in = $fh[$#infilename];
1827 0 my $in_comment = 0;
1828 0 ▶ while (<$in>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $in)) 0 0 0
1829 0 $line_number[$currfile]++;
1830 0 chomp;
1831 0 my $l = $_;
1832 0 ▶ if ($in_comment) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_comment) 0 0 0
1833 0 ▶ if ($l =~ /\*\//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($l =~ m[\*/]) 0 0 0
1834 0 $in_comment = 0;
1835 }
1836 0 next;
1837 }
1838 0 my $cstart = index($l, "/*");
1839 0 ▶ if ($cstart >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cstart >= 0) 0 0 0
1840 0 my $cstop = index($l, "*/");
1841 0 ▶ if ($cstop > $cstart) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cstop > $cstart) { } 0 0 0
1842 0 my $pre = "";
1843 0 ▶ if ($cstart > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cstart > 0) 0 0 0
1844 0 $pre = substr($l, 0, $cstart);
1845 }
1846 0 $cstop += 2;
1847 0 my $post = "";
1848 0 ▶ if ($cstop < length($l)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cstop < length $l) 0 0 0
1849 0 $post = substr($l, $cstop);
1850 }
1851 0 $l = $pre . $post;
1852 } else {
1853 0 $in_comment = 1;
1854 0 next;
1855 }
1856 }
1857 0 ▶ next unless ($l =~ /^\s*#/);
Branch: 1 branch
BranchTrueFalseTotal
unless $l =~ /^\s*#/ 0 0 0
1858 0 my @arg = idlsplit($l);
1859 0 my $kw = shift @arg;
1860 # print (join ('|', @arg) . "\n");
1861 0 my $directive = shift @arg;
1862 0 ▶ if ($count == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count == 0) 0 0 0
1863 0 ▶ if ($directive eq 'else' || $directive eq 'endif') {
Branch: 1 branch
BranchTrueFalseTotal
if ($directive eq "else" or $directive eq "endif") 0 0 0
Condition0%0/3
$directive eq "else" or $directive eq "endif"
l!l&&r!l&&!r
000
MC/DC0%0/2
$directive eq "else" or $directive eq "endif"
$directive eq "else" $directive eq "endif"
Truth table0%0/3
A or B
A= $directive eq "else"B= $directive eq "endif"
ABresult
1X1
011
000
1864 0 return;
1865 }
1866 0 ▶ if ($directive eq 'elif') {
Branch: 1 branch
BranchTrueFalseTotal
if ($directive eq "elif") 0 0 0
1867 0 ▶ if (eval_preproc_expr @arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval_preproc_expr(@arg)) 0 0 0
1868 0 return;
1869 }
1870 0 next;
1871 }
1872 }
1873 0 ▶ if ($directive eq 'if' ||
Branch: 2 branches
BranchTrueFalseTotal
if ($directive eq 'if' or $directive eq 'ifdef' or $directive eq 'ifndef') { } 0 0 0
elsif ($directive eq 'endif') { } 0 0 0
Condition0%0/6
$directive eq "if" or $directive eq "ifdef" or $directive eq "ifndef"
l!l&&r!l&&!r
000
$directive eq "if" or $directive eq "ifdef"
l!l&&r!l&&!r
000
MC/DC0%0/3
$directive eq "if" or $directive eq "ifdef" or $directive eq "ifndef"
$directive eq "if" $directive eq "ifdef" $directive eq "ifndef"
Truth table0%0/4
A or B or C
A= $directive eq "if"B= $directive eq "ifdef"C= $directive eq "ifndef"
ABCresult
1XX1
01X1
0011
0000
1874 $directive eq 'ifdef' ||
1875 $directive eq 'ifndef') {
1876 0 $count++;
1877 } elsif ($directive eq 'endif') {
1878 0 $count--;
1879 }
1880 # For #elif, the count remains the same.
1881 }
1882 0 error "skip_input: fell off end of file";
1883 }
1884  
1885 # If the given line begins with the Unicode or UTF-8 BOM (Byte Order Mark) then
1886 # discard the BOM in the returned line.
1887 22 ▶sub discard_bom {
Subroutine discard_bom: called CC=6 SCAR=25.4
Pod undocumented
1888 22 my $line = shift;
1889 22 ▶ if (length($line) > 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $line > 2) 21 1 22
1890 # Check for UTF-8 BOM (Byte Order Mark) 0xEF,0xBB,0xBF
1891 21 my $ord0 = ord(substr($line, 0, 1));
1892 21 ▶ if ($ord0 == 0xFEFF) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ord0 == 65279) { } 0 21 21
elsif ($ord0 == 239) { } 0 21 21
1893 0 $line = substr($line, 1); # Unicode
1894 } elsif ($ord0 == 0xEF) {
1895 0 my $ord1 = ord(substr($line, 1, 1));
1896 0 my $ord2 = ord(substr($line, 2, 1));
1897 0 ▶ if ($ord1 == 0xBB && $ord2 == 0xBF) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ord1 == 187 and $ord2 == 191) 0 0 0
Condition0%0/3
$ord1 == 187 and $ord2 == 191
!ll&&!rl&&r
000
MC/DC0%0/2
$ord1 == 187 and $ord2 == 191
$ord1 == 187 $ord2 == 191
Truth table0%0/3
A and B
A= $ord1 == 187B= $ord2 == 191
ABresult
0X0
100
111
1898 0 $line = substr($line, 3); # UTF-8
1899 }
1900 }
1901 }
1902 22 return $line;
1903 }
1904  
1905 229 ▶sub get_items { # returns empty list for end-of-file or fatal error
Subroutine get_items: called CC=54 SCAR=58.1
Pod undocumented
1906 229 my $in = shift;
1907 229 my $firstline;
1908 229 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 204 25 229
1909 204 $firstline = shift;
1910 }
1911 229 my @items = ();
1912 229 ▶ if (@global_items) {
Branch: 1 branch
BranchTrueFalseTotal
if (@global_items) 2 227 229
1913 2 @items = @global_items;
1914 2 @global_items = ();
1915 2 return @items;
1916 }
1917 227 my $first = 1;
1918 227 my $in_comment = 0;
1919 227 my $seen_token = 0;
1920 227 my $line = "";
1921 227 $starting_line_number_of_remark = 0;
1922 227 $line_number_of_post_comment = 0;
1923 227 my $l;
1924 227 @remark = ();
1925 227 @post_comment = ();
1926 line:
1927 227 ▶ while (($l = <$in>)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($l = readline $in)) 303 3 306
1928 303 $line_number[$currfile]++;
1929 303 chomp $l;
1930 303 $l =~ s/\r//g; # zap DOS line ending
1931 303 ▶ if ($firstline) {
Branch: 1 branch
BranchTrueFalseTotal
if ($firstline) 22 281 303
1932 22 $l = discard_bom($l);
1933 22 $firstline = 0;
1934 }
1935 303 ▶ if ($l =~ /[^\t\f[:print:]]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($l =~ /[^\t\f[:print:]]/) 0 303 303
1936 0 my $decoder = Encode::Guess->guess($l);
1937 0 ▶ unless (ref $decoder) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $decoder) 0 0 0
1938 # info($decoder);
1939 0 ▶ if ($decoder =~ /No appropriate encodings found/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($decoder =~ /No appropriate encodings found/) { } 0 0 0
1940 0 $l = Encode::decode("cp-1252", $l);
1941 } else {
1942 0 info "Unsupported character encoding - $decoder";
1943 0 $l =~ s/[^\t\f[:print:]]/ /g;
1944 }
1945 }
1946 }
1947 303 ▶ if ($l =~ /^\s*$/) { # empty
Branch: 1 branch
BranchTrueFalseTotal
if ($l =~ /^\s*$/) 43 260 303
1948 43 ▶ if ($in_comment) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_comment) 0 43 43
1949 0 ▶ if ($seen_token) {
Branch: 1 branch
BranchTrueFalseTotal
if ($seen_token) { } 0 0 0
1950 0 push @post_comment, "";
1951 } else {
1952 0 push @remark, "";
1953 }
1954 }
1955 43 next;
1956 }
1957 260 ▶ if ($in_comment) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_comment) 21 239 260
1958 21 ▶ if ($l =~ /\/\*/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($l =~ m[/\*]) 0 21 21
1959 0 info "warning: nested comments not supported!";
1960 }
1961 21 ▶ if ($l =~ /\*\//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($l =~ m[\*/]) { } 1 20 21
1962 1 my $cpos = index($l, "*/");
1963 1 my $cmnt = substr($l, 0, $cpos);
1964 1 $cmnt =~ s/\s*$//;
1965 1 $l = substr($l, $cpos+2);
1966 #my $cmnt = $l;
1967 #$cmnt =~ s/\s*\*\/.*$//;
1968 1 ▶ if ($seen_token) {
Branch: 1 branch
BranchTrueFalseTotal
if ($seen_token) { } 0 1 1
1969 0 push @post_comment, $cmnt;
1970 } else {
1971 1 push @remark, $cmnt;
1972 }
1973 1 $in_comment = 0; # end of multi-line comment
1974 #$l =~ s/^.*\*\///;
1975 1 ▶ if ($seen_token) {
Branch: 1 branch
BranchTrueFalseTotal
if ($seen_token) 0 1 1
1976 0 ▶ if ($l !~ /^\s*$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($l =~ /^\s*$/) 0 0 0
1977 0 error "unsupported comment/token combination";
1978 }
1979 0 last;
1980 }
1981 1 ▶ next if ($l =~ /^\s*$/);
Branch: 1 branch
BranchTrueFalseTotal
if $l =~ /^\s*$/ 1 0 1
1982 } else {
1983 20 ▶ if ($seen_token) {
Branch: 1 branch
BranchTrueFalseTotal
if ($seen_token) { } 0 20 20
1984 0 push @post_comment, $l;
1985 } else {
1986 20 push @remark, $l;
1987 }
1988 20 next;
1989 }
1990 }
1991 239 ▶ if ($l =~ /^\s*\/\/(.*)/) { # single-line comment by itself
Branch: 1 branch
BranchTrueFalseTotal
if ($l =~ m[^\s*//(.*)]) 10 229 239
1992 10 my $cmnt = $1;
1993 10 ▶ unless (@remark) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@remark) 6 4 10
1994 6 $starting_line_number_of_remark = $line_number[$currfile];
1995 }
1996 10 push @remark, $cmnt;
1997 10 next;
1998 }
1999 229 ▶ while ($l =~ /\/\*/) { # start of multi-line comment
Branch: 1 branch
BranchTrueFalseTotal
if ($l =~ m[/\*]) 1 228 229
2000 1 my $cpos = index($l, "/*");
2001 1 my $cend = index($l, "*/", $cpos+2);
2002 1 my $cmnt = "";
2003 1 ▶ if ($cend > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cend > 0) { } 0 1 1
2004 # start and end on the same line
2005 # extract comment block
2006 0 $cmnt = substr($l, $cpos+2, $cend-$cpos-2);
2007 0 substr($l, $cpos, $cend-$cpos+2) = "";
2008 } else {
2009 # only start found, extract comment part
2010 1 $cmnt = substr($l, $cpos+2);
2011 1 $l = substr($l, 0, $cpos);
2012 # comment continues on next line
2013 1 $in_comment = 1;
2014 }
2015 1 $cmnt =~ s/\s*$//;
2016 #my $cmnt = $l;
2017 #$cmnt =~ s/^.*\/\*//; # remove comment start and stuff before
2018 #$cmnt =~ s/\*\/.*$//; # remove comment end and stuff after (if any)
2019 #if ($l =~ /\*\//) {
2020 # # remove comment
2021 # $l =~ s/\/\*.*\*\///;
2022 #} else {
2023 # $in_comment = 1;
2024 # # remove start of comment
2025 # $l =~ s/\/\*.*$//;
2026 #}
2027 1 ▶ unless (defined($line_number[$currfile])) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $line_number[$currfile]) 0 1 1
2028 0 die("CORBA::IDLtree::get_items line_number of $currfile undefined (1)\n");
2029 }
2030 1 ▶ if ($l =~ /^\s*$/) { # If there is nothing else on the line
Branch: 1 branch
BranchTrueFalseTotal
if ($l =~ /^\s*$/) { } 1 0 1
2031 1 push @remark, $cmnt; # then declare it a prefixed comment;
2032 1 $starting_line_number_of_remark = $line_number[$currfile];
2033 1 next line;
2034 } else {
2035 0 push @post_comment, $cmnt; # else declare it a trailing comment.
2036 0 $line_number_of_post_comment = $line_number[$currfile];
2037 }
2038 }
2039 228 ▶ if ($l =~ /\/\/(.*)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($l =~ m[//(.*)$]) 0 228 228
2040 0 my $cmnt = $1;
2041 0 ▶ unless ($cmnt =~ /^\s*$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($cmnt =~ /^\s*$/) 0 0 0
2042 0 ▶ unless (defined($line_number[$currfile])) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $line_number[$currfile]) 0 0 0
2043 0 die("CORBA::IDLtree::get_items line_number of $currfile undefined (2)\n");
2044 }
2045 0 $line_number_of_post_comment = $line_number[$currfile];
2046 0 push @post_comment, $cmnt;
2047 }
2048 0 $l =~ s/\/\/.*$//; # discard trailing comment
2049 }
2050 228 $l =~ s/^\s+//; # discard leading whitespace
2051 228 $l =~ s/\s+$//; # discard trailing whitespace
2052 228 ▶ if ($first) {
Branch: 1 branch
BranchTrueFalseTotal
if ($first) { } 224 4 228
2053 224 $first = 0;
2054 } else {
2055 4 $l = " $l";
2056 }
2057 228 $line .= $l;
2058 228 ▶ if (($line =~ /^#/) # preprocessor directive
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^#/ or $line =~ /\@/ and not $line =~ /\@annotation\b/ or $line =~ /[;,":{]$/) 224 4 228
Condition66%6/9
$line =~ /^#/ or $line =~ /\@/ and not $line =~ /\@annotation\b/ or $line =~ /[;,":{]$/
l!l&&r!l&&!r
22224
$line =~ /^#/ or $line =~ /\@/ and not $line =~ /\@annotation\b/
l!l&&r!l&&!r
20226
$line =~ /\@/ and not $line =~ /\@annotation\b/
!ll&&!rl&&r
22600
MC/DC50%2/4
$line =~ /^#/ or $line =~ /\@/ and not $line =~ /\@annotation\b/ or $line =~ /[;,":{]$/
$line =~ /^#/ $line =~ /\@/ not $line =~ /\@annotation\b/ $line =~ /[;,":{]$/
Truth table50%3/6
A or B and not(C) or D
A= $line =~ /^#/B= $line =~ /\@/C= not $line =~ /\@annotation\b/D= $line =~ /[;,":{]$/
ABCDresult
1XXX1
011X1
00X11
01011
00X00
01000
2059 or ($line =~ /\@/ and $line !~ /\@annotation\b/) # annotation
2060 or ($line =~ /[;,":{]$/)) { #" characters declared to denote eol.
2061 224 $seen_token = 1;
2062 224 ▶ last unless $in_comment;
Branch: 1 branch
BranchTrueFalseTotal
unless $in_comment 224 0 224
2063 }
2064 }
2065 227 ▶ if ($in_comment) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_comment) 0 227 227
2066 0 error "end of file reached while comment still open";
2067 0 $in_comment = 0;
2068 }
2069 227 ▶ if (! $line) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($line) 3 224 227
2070 3 return ();
2071 }
2072 # sub idlsplit also does preprocessor symbol substitution.
2073 224 my @arg = idlsplit($line);
2074 224 my @tmp = @arg;
2075 224 ▶ if ($tmp[0] ne '#') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tmp[0] ne "#") 222 2 224
2076 222 return @arg;
2077 }
2078 2 shift @tmp; # discard '#'
2079 2 my $directive = shift @tmp;
2080 2 ▶ if ($directive eq 'if' || $directive eq 'elif') {
Branch: 7 branches
BranchTrueFalseTotal
if ($directive eq 'if' or $directive eq 'elif') { } 0 2 2
elsif ($directive eq 'ifdef') { } 0 2 2
elsif ($directive eq 'ifndef') { } 0 2 2
elsif ($directive eq 'define') { } 0 2 2
elsif ($directive eq 'undef') { } 0 2 2
elsif ($directive eq 'else') { } 0 2 2
elsif ($directive eq 'endif') { } 0 2 2
Condition33%1/3
$directive eq "if" or $directive eq "elif"
l!l&&r!l&&!r
002
MC/DC0%0/2
$directive eq "if" or $directive eq "elif"
$directive eq "if" $directive eq "elif"
Truth table33%1/3
A or B
A= $directive eq "if"B= $directive eq "elif"
ABresult
1X1
011
000
2081 0 emucppmsg;
2082 0 ▶ skip_input unless (eval_preproc_expr @tmp);
Branch: 1 branch
BranchTrueFalseTotal
unless eval_preproc_expr(@tmp) 0 0 0
2083 0 @arg = get_items($in);
2084 } elsif ($directive eq 'ifdef') {
2085 0 my $symbol = shift @tmp;
2086 0 emucppmsg;
2087 0 ▶ skip_input unless ($symbol =~ /^\d/);
Branch: 1 branch
BranchTrueFalseTotal
unless $symbol =~ /^\d/ 0 0 0
2088 0 @arg = get_items($in);
2089 } elsif ($directive eq 'ifndef') {
2090 0 my $symbol = shift @tmp;
2091 0 emucppmsg;
2092 0 ▶ skip_input if ($symbol =~ /^\d/);
Branch: 1 branch
BranchTrueFalseTotal
if $symbol =~ /^\d/ 0 0 0
2093 0 @arg = get_items($in);
2094 } elsif ($directive eq 'define') {
2095 0 my $symbol = shift @tmp;
2096 0 my $value = 1;
2097 0 emucppmsg;
2098 0 ▶ if (@tmp) {
Branch: 1 branch
BranchTrueFalseTotal
if (@tmp) 0 0 0
2099 0 $value = join(' ', @tmp);
2100 0 info("// defining $symbol as $value");
2101 }
2102 0 ▶ if (exists $active_defines{$symbol} and
Branch: 1 branch
BranchTrueFalseTotal
if (exists $active_defines{$symbol} and $value ne $active_defines{$symbol}) 0 0 0
Condition0%0/3
exists $active_defines{$symbol} and $value ne $active_defines{$symbol}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $active_defines{$symbol} and $value ne $active_defines{$symbol}
exists $active_defines{$symbol} $value ne $active_defines{$symbol}
Truth table0%0/3
A and B
A= exists $active_defines{$symbol}B= $value ne $active_defines{$symbol}
ABresult
0X0
100
111
2103 $value ne $active_defines{$symbol}) {
2104 0 ▶ if ($cache_trees) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CORBA::IDLtree::cache_trees) { } 0 0 0
2105 0 error("Redefinition of $symbol may lead to " .
2106 "erroneous trees when cache_trees is used");
2107 } else {
2108 0 info "info: redefining $symbol";
2109 }
2110 }
2111 0 $active_defines{$symbol} = $value;
2112 0 @arg = get_items($in);
2113 } elsif ($directive eq 'undef') {
2114 0 my $symbol = shift @tmp;
2115 0 emucppmsg;
2116 0 ▶ if (exists $active_defines{$symbol}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $active_defines{$symbol}) 0 0 0
2117 0 ▶ if ($cache_trees) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CORBA::IDLtree::cache_trees) 0 0 0
2118 0 error("#undef of $symbol may lead to " .
2119 "erroneous trees when cache_trees is used");
2120 }
2121 0 delete $active_defines{$symbol};
2122 }
2123 0 @arg = get_items($in);
2124 } elsif ($directive eq 'else') {
2125 # We only get to see the #else here if we were not skipping
2126 # the preceding #if or #elif.
2127 0 skip_input;
2128 0 @arg = get_items($in);
2129 } elsif ($directive eq 'endif') {
2130 0 @arg = get_items($in);
2131 }
2132 2 @arg;
2133 }
2134  
2135 2 ▶sub unget_items {
Subroutine unget_items: called CC=1 SCAR=0.0
Pod undocumented
2136 2 @global_items = @_;
2137 }
2138  
2139  
2140 0 ▶sub isname {
Subroutine isname: not called CC=1 SCAR=6.9
Pod undocumented
2141 0 my $txt = shift;
2142 0 $txt =~ /^[A-Za-z]/
2143 }
2144  
2145 # check if the path given by the strings in @parts leads to
2146 # the given $scope starting at the referring scope $refscope.
2147 # return the absolute path if the path is OK, undef otherwise
2148 2 ▶sub check_scope {
Subroutine check_scope: called CC=11 SCAR=39.4
Pod undocumented
2149 2 my ($scope, $refscope, @parts) = @_;
2150 2 my $p = join("::", get_scope($scope));
2151  
2152 2 ▶ if (@parts == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@parts == 0) 2 0 2
2153 # special case: both elements are in top-level scope
2154 2 ▶ if (! $refscope && $p eq "") {
Branch: 1 branch
BranchTrueFalseTotal
if (not $refscope and $p eq "") 0 2 2
Condition33%1/3
not $refscope and $p eq ""
!ll&&!rl&&r
200
MC/DC0%0/2
not $refscope and $p eq ""
not $refscope $p eq ""
Truth table33%1/3
not(A) and B
A= not $refscopeB= $p eq ""
ABresult
0X0
100
111
2155 0 return $p;
2156 }
2157 # no scope given, must be in the referring scope or
2158 # its ancestors
2159 2 ▶ for (my $s = $refscope; $s; $s = $s->[SCOPEREF]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s) 2 0 2
2160 2 ▶ return $p if $scope == $s;
Branch: 1 branch
BranchTrueFalseTotal
if $scope == $s 2 0 2
2161 }
2162 0 return undef;
2163 }
2164  
2165 # the specified parts must either be an absolute
2166 # path to $scope or start at the referring scope
2167 # or one of its ancestors
2168 # (a path starting with "::" is always absolute,
2169 # though the parser can't handle this right now!)
2170 0 my $is_abs = $parts[0] eq "";
2171 0 ▶ shift @parts if $is_abs;
Branch: 1 branch
BranchTrueFalseTotal
if $is_abs 0 0 0
2172  
2173 # check absolute path first
2174 0 ▶ return $p if join("::", @parts) eq $p;
Branch: 1 branch
BranchTrueFalseTotal
if join("::", @parts) eq $p 0 0 0
2175  
2176 0 ▶ unless ($is_abs) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($is_abs) 0 0 0
2177 # try possible "relative" paths
2178 0 ▶ for (my @anc = get_scope($refscope); @anc; pop @anc) {
Branch: 1 branch
BranchTrueFalseTotal
if (@anc) 0 0 0
2179 0 ▶ return $p if join("::", (@anc, @parts)) eq $p;
Branch: 1 branch
BranchTrueFalseTotal
if join("::", (@anc, @parts)) eq $p 0 0 0
2180 }
2181 }
2182  
2183 # wrong scope given
2184 0 return undef;
2185 }
2186  
2187 # In the SUBORDINATES of ENUM there may be remark nodes or trailing comment
2188 # nodes. Function enum_literals returns the net literals stripped of any
2189 # remark nodes or trailing comment info.
2190 # It expects the SUBORDINATES of the enum node as the argument and
2191 # returns the extracted list.
2192 6 ▶sub enum_literals {
Subroutine enum_literals: called CC=5 SCAR=17.8
Pod documented
2193 6 my ($enum_subordinate) = @_;
2194 6 ▶ unless (ref $enum_subordinate) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $enum_subordinate) 0 6 6
2195 # Possible misuse - generate warning?
2196 0 return ();
2197 }
2198 6 my @values = ();
2199 6 foreach my $elem (@{$enum_subordinate}) {
2200 21 ▶ unless (ref($elem) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $elem eq "ARRAY") 0 21 21
2201 0 Carp::cluck("enum_literals: IDLtree internal error" .
2202 "- enum subordinates should be ARRAY\n");
2203 0 last;
2204 }
2205 21 ▶ $elem->[0] =~ /^\d/ and next; # remark node
Branch: 1 branch
BranchTrueFalseTotal
$elem->[0] =~ /^\d/ and next 0 21 21
2206 21 push @values, $elem->[0];
2207 }
2208 6 return @values;
2209 }
2210  
2211 # check if the given literal correctly identifies
2212 # an enumeration member of the enumeration type $type
2213 # as referenced from the referring scope $refscope
2214 # if $refscope is not specified, curr_scope() is used.
2215 2 ▶sub check_enum_literal {
Subroutine check_enum_literal: called CC=5 SCAR=16.2
Pod undocumented
2216 2 my ($type, $literal, $refscope) = @_;
2217  
2218 2 ▶ $refscope = curr_scope() unless defined $refscope;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $refscope 2 0 2
2219  
2220 2 my $found = 0;
2221 2 my @p = (split "::", $literal);
2222 2 my $e = pop @p;
2223 2 my $s = check_scope($type->[SCOPEREF], $refscope, @p);
2224 2 ▶ if (defined $s) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $s) 2 0 2
2225 2 foreach (enum_literals($type->[SUBORDINATES])) {
2226 4 ▶ $found = 1, last if $_ eq $e;
Branch: 1 branch
BranchTrueFalseTotal
if $_ eq $e 2 2 4
2227 }
2228 }
2229 2 return $found;
2230 }
2231  
2232 17 ▶sub check_union_case {
Subroutine check_union_case: called CC=25 SCAR=38.2
Pod undocumented
2233 17 my ($symroot, $known_cases, $case) = @_;
2234  
2235 17 my $i = 0;
2236 17 ▶ if ($case->[TYPE] == DEFAULT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($case->[0] == 29) { } 1 16 17
2237 1 foreach (@$known_cases) {
2238 3 ▶ next if $i++ == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $i++ == 0 1 2 3
2239 2 ▶ if ($_->[TYPE] == DEFAULT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->[0] == 29) 0 2 2
2240 0 error "duplicate default label";
2241 0 return undef;
2242 }
2243 }
2244 } else {
2245 16 my $type = root_type($known_cases->[TYPE]);
2246 16 my $c;
2247 16 ▶ if (is_a($type, ENUM)) {
Branch: 3 branches
BranchTrueFalseTotal
if (is_a($type, 23)) { } 2 14 16
elsif (is_a($type, 1)) { } 2 12 14
elsif (is_a($type, 3)) { } 4 8 12
2248 # check if value is part of enumeration
2249 2 foreach $c (@{$case->[SUBORDINATES]}) {
2250 2 ▶ unless (check_enum_literal($type, $c)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (check_enum_literal($type, $c)) 0 2 2
2251 0 error "invalid case value $c";
2252 0 return undef;
2253 }
2254 }
2255 } elsif (is_a($type, BOOLEAN)) {
2256 2 foreach $c (@{$case->[SUBORDINATES]}) {
2257 2 ▶ unless ($c eq "TRUE" || $c eq "FALSE") {
Branch: 1 branch
BranchTrueFalseTotal
unless ($c eq "TRUE" or $c eq "FALSE") 0 2 2
Condition66%2/3
$c eq "TRUE" or $c eq "FALSE"
l!l&&r!l&&!r
110
MC/DC0%0/2
$c eq "TRUE" or $c eq "FALSE"
$c eq "TRUE" $c eq "FALSE"
Truth table66%2/3
A or B
A= $c eq "TRUE"B= $c eq "FALSE"
ABresult
1X1
011
000
2258 0 error "invalid case value $c";
2259 0 return undef;
2260 }
2261 }
2262 } elsif (is_a($type, CHAR)) {
2263 4 foreach $c (@{$case->[SUBORDINATES]}) {
2264 5 ▶ unless ($c =~ /^'.*'$/ || $c =~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($c =~ /^'.*'$/ or $c =~ /^\d+$/) 0 5 5
Condition33%1/3
$c =~ /^'.*'$/ or $c =~ /^\d+$/
l!l&&r!l&&!r
500
MC/DC0%0/2
$c =~ /^'.*'$/ or $c =~ /^\d+$/
$c =~ /^'.*'$/ $c =~ /^\d+$/
Truth table33%1/3
A or B
A= $c =~ /^'.*'$/B= $c =~ /^\d+$/
ABresult
1X1
011
000
2265 0 error "invalid case value $c";
2266 0 return undef;
2267 }
2268 }
2269 } else {
2270 # must be integer
2271 8 foreach $c (@{$case->[SUBORDINATES]}) {
2272 9 ▶ unless ($c =~ /^[-+]?\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($c =~ /^[-+]?\d+$/) 0 9 9
2273 0 my $resolved_const = get_numeric($symroot, $c, curr_scope);
2274 0 ▶ unless ($resolved_const =~ /^[-+]?\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($resolved_const =~ /^[-+]?\d+$/) 0 0 0
2275 0 error "invalid case value $c";
2276 0 return undef;
2277 }
2278 }
2279 }
2280 }
2281 16 foreach (@$known_cases) {
2282 86 ▶ next if $i++ == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $i++ == 0 16 70 86
2283 70 ▶ next unless $_->[TYPE] == CASE;
Branch: 1 branch
BranchTrueFalseTotal
unless $_->[0] == 28 41 29 70
2284 29 foreach (@{$_->[SUBORDINATES]}) {
2285 34 foreach $c (@{$case->[SUBORDINATES]}) {
2286 38 ▶ if ($c eq $_) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq $_) 0 38 38
2287 0 error "duplicate case label $c";
2288 0 return undef;
2289 }
2290 }
2291 }
2292 }
2293 }
2294 17 return 1;
2295 }
2296  
2297  
2298 2 ▶sub Parse_File {
Subroutine Parse_File: called CC=12 SCAR=32.5
Pod documented
2299 2 my $filename = shift;
2300 2 ▶ if ($cache_trees) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CORBA::IDLtree::cache_trees) { } 0 2 2
2301 0 my $incfile_contents_ref = $includecache->get($filename);
2302 0 ▶ if ($incfile_contents_ref) {
Branch: 1 branch
BranchTrueFalseTotal
if ($incfile_contents_ref) 0 0 0
2303 0 bless($incfile_contents_ref, "CORBA::IDLtree");
2304 0 return $incfile_contents_ref;
2305 }
2306 } else {
2307 2 $includecache->clear(); # Roots of previously parsed includefiles
2308 2 $findnode_cache->clear(); # Flush the find_node_i() cache
2309 }
2310 2 $global_idlfile = $filename;
2311 2 @infilename = (); # infilename and line_number move in parallel.
2312 2 @line_number = ();
2313 2 $n_errors = 0; # auxiliary to sub error
2314 2 @remark = (); # Auxiliary to comment processing
2315 2 @post_comment = (); # Auxiliary to comment processing
2316 2 $abstract = 0;
2317 2 $currfile = -1;
2318 2 $did_emucppmsg = 0; # auxiliary to sub emucppmsg
2319 2 @scopestack = ();
2320 2 @prev_symroots = ();
2321 2 %active_defines = %defines;
2322 2 ▶ unless ($locale_was_determined) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($locale_was_determined) 1 1 2
2323 1 foreach my $env ('LANG', 'LOCALE', 'LC_ALL') {
2324 3 ▶ if (exists $ENV{$env}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ENV{$env}) 0 3 3
2325 0 my $lang = $ENV{$env};
2326 0 ▶ if ($lang && $lang ne "C") {
Branch: 1 branch
BranchTrueFalseTotal
if ($lang and $lang ne "C") 0 0 0
Condition0%0/3
$lang and $lang ne "C"
!ll&&!rl&&r
000
MC/DC0%0/2
$lang and $lang ne "C"
$lang $lang ne "C"
Truth table0%0/3
A and B
A= $langB= $lang ne "C"
ABresult
0X0
100
111
2327 0 $locale = $lang;
2328 0 last;
2329 }
2330 }
2331 }
2332 1 $locale_was_determined = 1;
2333 }
2334 2 my $res = Parse_File_i($filename);
2335 2 ▶ if ($cache_statistics) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CORBA::IDLtree::cache_statistics) 0 2 2
2336 0 print "Node cache: " . $findnode_cache->ratio()."\n";
2337 0 print "Include cache: " . $includecache->ratio()."\n";
2338 }
2339 2 ▶ if ($res && !@$res) {
Branch: 2 branches
BranchTrueFalseTotal
if ($res and not @$res) { } 0 2 2
elsif ($CORBA::IDLtree::cache_trees) { } 0 2 2
Condition33%1/3
$res and not @$res
!ll&&!rl&&r
020
MC/DC0%0/2
$res and not @$res
$res not @$res
Truth table33%1/3
A and not(B)
A= $resB= not @$res
ABresult
0X0
100
111
2340 0 warn "Warning: CORBA::IDLtree::Parse_File: $filename is empty\n";
2341 0 $res = 0;
2342 } elsif ($cache_trees) {
2343 # Put the main unit in the include cache, too
2344 # (it may be #included by a subsequent main file.)
2345 0 $includecache->add($filename, $res);
2346 }
2347 2 return $res;
2348 }
2349  
2350 # the function changes the passed in struct node
2351 # into an "equivalent" valuetype
2352 0 ▶sub convert_to_valuetype {
Subroutine convert_to_valuetype: not called CC=7 SCAR=40.3
Pod undocumented
2353 0 my ($node) = @_;
2354  
2355 # just in case...
2356 0 ▶ return unless $node->[TYPE] == STRUCT;
Branch: 1 branch
BranchTrueFalseTotal
unless $node->[0] == 26 0 0 0
2357  
2358 # first, convert the members to public state members
2359 0 foreach (@{$node->[SUBORDINATES]}) {
2360 0 my $membertype = $_->[TYPE];
2361 0 ▶ if ($membertype == REMARK) {
Branch: 1 branch
BranchTrueFalseTotal
if ($membertype == 48) { } 0 0 0
2362 0 $_ = [ 0, $_ ];
2363 } else {
2364 0 ▶ if (isnode($membertype) &&
Branch: 1 branch
BranchTrueFalseTotal
if (isnode($membertype) and $membertype->[0] == 20 || $membertype->[0] == 21) 0 0 0
Condition0%0/6
isnode($membertype) and $membertype->[0] == 20 || $membertype->[0] == 21
!ll&&!rl&&r
000
$membertype->[0] == 20 or $membertype->[0] == 21
l!l&&r!l&&!r
000
MC/DC0%0/3
isnode($membertype) and $membertype->[0] == 20 || $membertype->[0] == 21
isnode($membertype) $membertype->[0] == 20 $membertype->[0] == 21
Truth table0%0/4
A and B or C
A= isnode($membertype)B= $membertype->[0] == 20C= $membertype->[0] == 21
ABCresult
0XX0
1000
11X1
1011
2365 ($membertype->[TYPE] == CORBA::IDLtree::BOUNDED_STRING ||
2366 $membertype->[TYPE] == CORBA::IDLtree::BOUNDED_WSTRING)) {
2367 # Ad hoc member type declaration shall have its own
2368 # enclosing valuetype as the SCOPEREF
2369 0 $membertype->[SCOPEREF] = $node;
2370 }
2371 0 $_ = [ PUBLIC, $_ ];
2372 }
2373 }
2374 # now, change the subordinates:
2375 0 $node->[SUBORDINATES] = [
2376 0, # abstract
2377 [ 0, # is_truncatable
2378 0 # ancestors
2379 ],
2380 $node->[SUBORDINATES], # members
2381 ];
2382 # change the type into VALUETYPE
2383 0 $node->[TYPE] = VALUETYPE;
2384 }
2385  
2386 # Parses an annotation application.
2387 # Parsing of an @annotation definition is not done here.
2388 # Expects the annotation name as the first parameter and possible
2389 # annotation arguments by an array reference in the second parameter.
2390 # Is expected to be called not too long after get_items (the sub may find
2391 # that too many args were returned by get_items and may therefore call
2392 # unget_items).
2393 # Returns 1 on success, 2 on unknown annotation, 0 on error.
2394 0 ▶sub parse_annotation_app {
Subroutine parse_annotation_app: not called CC=30 SCAR=68.4
Pod undocumented
2395 0 my ($ann, $argref) = @_;
2396 0 my ($index) = grep { $annoDefs[$_]->[0] eq $ann } 0..$#annoDefs;
2397 0 ▶ unless (defined $index) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $index) 0 0 0
2398 0 warn "Unknown annotation \@$ann\n";
2399 0 ▶ if ($argref->[0] eq '(') {
Branch: 1 branch
BranchTrueFalseTotal
if ($argref->[0] eq "(") 0 0 0
2400 0 my $seen_closing_parenth = 0;
2401 0 ▶ while (@$argref) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$argref) 0 0 0
2402 0 ▶ if ($argref->[0] eq ')') {
Branch: 1 branch
BranchTrueFalseTotal
if ($argref->[0] eq ")") 0 0 0
2403 0 $seen_closing_parenth = 1;
2404 0 last;
2405 }
2406 0 shift @$argref;
2407 }
2408 0 ▶ unless ($seen_closing_parenth) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($seen_closing_parenth) 0 0 0
2409 0 error "Missing closing parenthesis for annotation arguments";
2410 0 return 0;
2411 }
2412 }
2413 0 return 2;
2414 }
2415 0 my @adef = @{$annoDefs[$index]};
2416 0 shift @adef; # discard name
2417 0 my @anode = ($index);
2418 0 my @anargs;
2419 0 ▶ if (@adef) {
Branch: 1 branch
BranchTrueFalseTotal
if (@adef) 0 0 0
2420 0 @anargs = map { undef } @adef;
2421 0 ▶ unless ($argref && @$argref) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($argref and @$argref) 0 0 0
Condition0%0/3
$argref and @$argref
!ll&&!rl&&r
000
MC/DC0%0/2
$argref and @$argref
$argref @$argref
Truth table0%0/3
A and B
A= $argrefB= @$argref
ABresult
0X0
100
111
2422 0 error("parse_annotation_app: internal error"
2423 . " (get_items returned insufficient args)\n"
2424 . Carp::longmess());
2425 0 return 0;
2426 }
2427 }
2428 0 ▶ if (@$argref && $argref->[0] eq '(') {
Branch: 1 branch
BranchTrueFalseTotal
if (@$argref and $argref->[0] eq "(") 0 0 0
Condition0%0/3
@$argref and $argref->[0] eq "("
!ll&&!rl&&r
000
MC/DC0%0/2
@$argref and $argref->[0] eq "("
@$argref $argref->[0] eq "("
Truth table0%0/3
A and B
A= @$argrefB= $argref->[0] eq "("
ABresult
0X0
100
111
2429 0 ▶ unless (@adef) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@adef) 0 0 0
2430 0 error "Annotation \@$ann does not require arguments";
2431 0 return 0;
2432 }
2433 0 shift @$argref;
2434 0 my $closing_parenth_seen = 0;
2435 0 my $upcounter = 0;
2436 0 ▶ while (@$argref) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$argref) 0 0 0
2437 0 my $val = shift @$argref;
2438 0 ▶ if ($val eq ')') {
Branch: 1 branch
BranchTrueFalseTotal
if ($val eq ")") 0 0 0
2439 0 $closing_parenth_seen = 1;
2440 0 last;
2441 }
2442 0 ▶ $val eq ',' and next;
Branch: 1 branch
BranchTrueFalseTotal
$val eq "," and next 0 0 0
2443 0 ▶ if ($val =~ /^[a-z]/i and $argref->[0] eq '=') {
Branch: 1 branch
BranchTrueFalseTotal
if ($val =~ /^[a-z]/i and $argref->[0] eq '=') { } 0 0 0
Condition0%0/3
$val =~ /^[a-z]/i and $argref->[0] eq "="
!ll&&!rl&&r
000
MC/DC0%0/2
$val =~ /^[a-z]/i and $argref->[0] eq "="
$val =~ /^[a-z]/i $argref->[0] eq "="
Truth table0%0/3
A and B
A= $val =~ /^[a-z]/iB= $argref->[0] eq "="
ABresult
0X0
100
111
2444 0 my $parname = $val;
2445 0 shift @$argref;
2446 0 ▶ unless (@$argref) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$argref) 0 0 0
2447 0 error "Annotation \@$ann no value given for $parname";
2448 0 return 0;
2449 }
2450 0 my $param_index = undef;
2451 0 ▶ for (my $ai = 0; $ai < scalar(@adef); ++$ai) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ai < scalar @adef) 0 0 0
2452 0 ▶ if ($adef[$ai]->[1] eq $parname) {
Branch: 1 branch
BranchTrueFalseTotal
if ($adef[$ai][1] eq $parname) 0 0 0
2453 0 $param_index = $ai;
2454 0 last;
2455 }
2456 }
2457 0 ▶ unless (defined $param_index) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $param_index) 0 0 0
2458 0 error "Annotation \@$ann unknown parameter given: $parname";
2459 0 return 0;
2460 }
2461 0 $val = shift @$argref;
2462 0 my $type = $adef[$param_index]->[0];
2463 0 ▶ if (exists $annoEnum{$type}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $CORBA::IDLtree::annoEnum{$type}) 0 0 0
2464 0 my $enumvalues = $annoEnum{$type};
2465 0 ▶ unless (grep { $_ eq $val } @{$enumvalues}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$_ eq $val;} @{$enumvalues;}) 0 0 0
2466 0 error "Annotation \@$ann parameter $parname illegal value: $val";
2467 0 return 0;
2468 }
2469 }
2470 0 $anargs[$param_index] = $val;
2471 } else {
2472 0 my $type = $adef[$upcounter]->[0];
2473 0 ▶ if (exists $annoEnum{$type}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $CORBA::IDLtree::annoEnum{$type}) 0 0 0
2474 0 my $enumvalues = $annoEnum{$type};
2475 0 ▶ unless (grep { $_ eq $val } @{$enumvalues}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$_ eq $val;} @{$enumvalues;}) 0 0 0
2476 0 error("Annotation \@$ann parameter " . $adef[$upcounter]->[1]
2477 . " illegal value: $val");
2478 0 return 0;
2479 }
2480 }
2481 0 $anargs[$upcounter] = $val;
2482 0 ++$upcounter;
2483 }
2484 }
2485 0 ▶ unless ($closing_parenth_seen) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($closing_parenth_seen) 0 0 0
2486 0 error "Annotation \@$ann syntax error: require closing parenthesis";
2487 0 return 0;
2488 }
2489 }
2490 0 ▶ if (@adef) {
Branch: 1 branch
BranchTrueFalseTotal
if (@adef) 0 0 0
2491 0 ▶ for (my $i = 0; $i < scalar(@adef); ++$i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @adef) 0 0 0
2492 0 ▶ unless (defined $anargs[$i]) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $anargs[$i]) 0 0 0
2493 0 my $parname = $adef[$i]->[1];
2494 0 my $default = $adef[$i]->[2];
2495 0 ▶ if (defined $default) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $default) { } 0 0 0
2496 0 $anargs[$i] = $default;
2497 0 info("Annotation \@$ann using default value for parameter $parname");
2498 } else {
2499 0 error("Annotation \@$ann no value given for parameter $parname");
2500 0 return 0;
2501 }
2502 }
2503 }
2504 0 push @anode, @anargs;
2505 }
2506 0 push @annotations, [ @anode ];
2507 }
2508  
2509 # Check whether the given union subordinates contain a DEFAULT branch.
2510 1 ▶sub has_default_branch {
Subroutine has_default_branch: called CC=3 SCAR=11.2
Pod undocumented
2511 1 my $union_subord = shift;
2512 1 my @members = @{$union_subord};
2513 1 ▶ for (my $i = $#members; $i > 0; --$i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i > 0) 4 1 5
2514 4 ▶ if ($members[$i]->[TYPE] == DEFAULT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($members[$i][0] == 29) 0 4 4
2515 0 return 1;
2516 }
2517 }
2518 1 return 0;
2519 }
2520  
2521 # Push subordinate - just like perl push() but hides
2522 # different structure of valuetype subordinates.
2523 97 ▶sub pushsub {
Subroutine pushsub: called CC=3 SCAR=13.3
Pod undocumented
2524 97 my($symbols, $noderef, $in_valuetype) = @_;
2525 97 ▶ if ($in_valuetype && !$vt2struct) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_valuetype and not $CORBA::IDLtree::vt2struct) { } 0 97 97
Condition33%1/3
$in_valuetype and not $CORBA::IDLtree::vt2struct
!ll&&!rl&&r
9700
MC/DC0%0/2
$in_valuetype and not $CORBA::IDLtree::vt2struct
$in_valuetype not $CORBA::IDLtree::vt2struct
Truth table33%1/3
A and not(B)
A= $in_valuetypeB= not $CORBA::IDLtree::vt2struct
ABresult
0X0
100
111
2526 0 push @$symbols, [ 0, $noderef ];
2527 } else {
2528 97 push @$symbols, $noderef;
2529 }
2530 }
2531  
2532 22 ▶sub Parse_File_i {
Subroutine Parse_File_i: called CC=283 SCAR=94.2
Pod undocumented
2533 22 my ($file, $input_filehandle, $symb, $in_valuetype) = @_;
2534  
2535 22 my @vt_inheritance = (0, 0);
2536 22 my $in;
2537 22 my $custom = 0;
2538 22 $abstract = 0;
2539 22 ▶ if ($file) { # Process a new file (or includefile if cpp emulated)
Branch: 2 branches
BranchTrueFalseTotal
if ($file) { } 3 19 22
elsif ("$input_filehandle") { } 19 0 19
2540 3 ▶ -e "$file" or abort("Cannot find file $file");
Branch: 1 branch
BranchTrueFalseTotal
-e "$file" or abort("Cannot find file $file") 3 0 3
2541 # remove "//" from filename to ensure correct filename match
2542 3 $file =~ s:/+:/:g;
2543 3 push @infilename, $file;
2544 3 push @line_number, 0;
2545 3 $currfile = $#infilename;
2546 3 $in = $fh[$currfile];
2547 3 my $cppcmd = "";
2548 3 ▶ unless ($emucpp) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($emucpp) 0 3 3
2549 # Try to find and run the C preprocessor.
2550 # Use `cpp' in preference of `cc -E' if the former can be found.
2551 # If no preprocessor can be found, we will try to emulate it.
2552 0 ▶ if (locate_executable 'cpp') {
Branch: 2 branches
BranchTrueFalseTotal
if (locate_executable('cpp')) { } 0 0 0
elsif (locate_executable('gcc')) { } 0 0 0
2553 0 $cppcmd = 'cpp';
2554 } elsif (locate_executable 'gcc') {
2555 0 $cppcmd = 'gcc -E -x c++';
2556 } else {
2557 0 $emucpp = 1;
2558 }
2559 }
2560 3 ▶ if ($emucpp) {
Branch: 1 branch
BranchTrueFalseTotal
if ($emucpp) { } 3 0 3
2561 3 ▶ open($in, , '<', $file) or abort("Cannot open file $file");
Branch: 1 branch
BranchTrueFalseTotal
open $in, "<", $file or abort("Cannot open file $file") 3 0 3
2562 } else {
2563 0 my $cpp_args = "";
2564 0 foreach (keys %defines) {
2565 0 $cpp_args .= " -D$_=" . $defines{$_};
2566 }
2567 0 foreach (@include_path) {
2568 0 $cpp_args .= " -I$_";
2569 }
2570 0 ▶ open($in, "$cppcmd $cpp_args $file |")
Branch: 1 branch
BranchTrueFalseTotal
open $in, "$cppcmd $cpp_args $file |" or abort("Cannot open file $file") 0 0 0
2571 or abort("Cannot open file $file");
2572 }
2573 3 info("// processing: $file");
2574 } elsif ("$input_filehandle") {
2575 19 $in = $input_filehandle; # Process a module or interface within file.
2576 }
2577  
2578 # symbol tree that will be constructed here
2579 22 my $symbols;
2580 22 ▶ if ($symb) {
Branch: 1 branch
BranchTrueFalseTotal
if ($symb) { } 20 2 22
2581 20 $symbols = $symb;
2582 } else {
2583 2 $symbols = [ ];
2584 }
2585 # @struct, @typestack, @namestack, @cmntstack used to be my() vars here.
2586 # They were moved to the global scope in order to support #include
2587 # statements at arbitrary locations.
2588 22 my @arg;
2589 22 my $firstline = 1;
2590 22 ▶ while ((@arg = get_items($in, $firstline))) {
Branch: 1 branch
BranchTrueFalseTotal
if (@arg = get_items($in, $firstline)) 201 3 204
2591 201 $firstline = 0;
2592 201 ▶ if ($verbose > 1) { # "super verbose mode"
Branch: 1 branch
BranchTrueFalseTotal
if ($CORBA::IDLtree::verbose > 1) 0 201 201
2593 0 my $line = join(' ', @arg);
2594 0 info("IDLtree: parsing $line");
2595 }
2596 201 ▶ if ($enable_comments && @remark) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CORBA::IDLtree::enable_comments and @remark) 0 201 201
Condition33%1/3
$CORBA::IDLtree::enable_comments and @remark
!ll&&!rl&&r
20100
MC/DC0%0/2
$CORBA::IDLtree::enable_comments and @remark
$CORBA::IDLtree::enable_comments @remark
Truth table33%1/3
A and B
A= $CORBA::IDLtree::enable_commentsB= @remark
ABresult
0X0
100
111
2597 0 my $remnode_ref = [ REMARK, $starting_line_number_of_remark, [ @remark ], 0, 0, curr_scope ];
2598 0 ▶ if (@typestack) {
Branch: 1 branch
BranchTrueFalseTotal
if (@typestack) { } 0 0 0
2599 0 push @struct, $remnode_ref;
2600 } else {
2601 0 pushsub($symbols, $remnode_ref, $in_valuetype);
2602 }
2603 0 @remark = ();
2604 0 $starting_line_number_of_remark = 0;
2605 }
2606 201 my $cmnt = comment;
2607 201 KEYWORD:
2608 my $kw = shift @arg;
2609 201 ▶ if ($kw eq '#') {
Branch: 14 branches
BranchTrueFalseTotal
if ($kw eq '#') { } 2 199 201
elsif ($kw eq '@') { } 0 199 199
elsif ($kw eq '}') { } 34 165 199
elsif ($kw eq 'module') { } 3 162 165
elsif ($kw eq 'interface') { } 30 132 162
elsif ($kw eq 'local') { } 0 132 132
elsif ($kw eq 'abstract') { } 0 132 132
elsif ($kw eq 'custom') { } 0 132 132
elsif ($kw eq 'valuetype') { } 0 132 132
elsif ($kw eq 'public' or $kw eq 'private') { } 0 132 132
elsif ($kw eq 'struct' or $kw eq 'exception') { } 10 122 132
elsif ($kw eq 'union') { } 5 117 122
elsif ($kw eq 'case' or $kw eq 'default') { } 17 100 117
elsif ($kw eq 'enum') { } 3 97 100
2610 2 my $directive = shift @arg;
2611 2 ▶ if ($directive eq 'pragma') {
Branch: 4 branches
BranchTrueFalseTotal
if ($directive eq 'pragma') { } 1 1 2
elsif ($directive eq 'include') { } 1 0 1
elsif ($directive =~ /^\d/) { } 0 0 0
elsif ($directive eq 'if' or $directive eq 'ifdef' or $directive eq 'ifndef' or $directive eq 'elif' or $directive eq 'else' or $directive eq 'endif' or $directive eq 'define' or $directive eq 'undef') { } 0 0 0
2612 1 my @pragma_node;
2613 1 $directive = shift @arg;
2614 1 ▶ if ($directive eq 'prefix') {
Branch: 3 branches
BranchTrueFalseTotal
if ($directive eq 'prefix') { } 1 0 1
elsif ($directive eq 'version') { } 0 0 0
elsif (uc $directive eq 'ID') { } 0 0 0
2615 1 my $prefix = shift @arg;
2616 1 ▶ if (substr($prefix, 0, 1) ne '"') {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($prefix, 0, 1) ne '"') { } 0 1 1
2617 0 error "prefix should be given in double quotes";
2618 } else {
2619 1 $prefix = substr($prefix, 1);
2620 1 ▶ if (substr($prefix, length($prefix) - 1) ne '"') {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($prefix, length($prefix) - 1) ne '"') { } 0 1 1
2621 0 error "missing closing quote";
2622 } else {
2623 1 $prefix = substr($prefix, 0, length($prefix) - 1);
2624 }
2625 }
2626 1 @pragma_node = (PRAGMA_PREFIX, $prefix, 0, 0, $cmnt,
2627 curr_scope);
2628 } elsif ($directive eq 'version') {
2629 0 my $unitname = shift @arg;
2630 0 my $vstring = shift @arg;
2631 0 @pragma_node = (PRAGMA_VERSION, $unitname, $vstring, 0, $cmnt,
2632 curr_scope);
2633 } elsif (uc($directive) eq 'ID') {
2634 0 my $unitname = shift @arg;
2635 0 my $idstring = shift @arg;
2636 0 @pragma_node = (PRAGMA_ID, $unitname, $idstring, 0, $cmnt,
2637 curr_scope);
2638 } else {
2639 0 my $rest_of_line = join ' ', @arg;
2640 0 @pragma_node = (PRAGMA, $directive, $rest_of_line, 0, $cmnt,
2641 curr_scope);
2642 }
2643 1 push @$symbols, \@pragma_node;
2644 } elsif ($directive eq 'include') {
2645 1 my $filename = shift @arg;
2646 1 emucppmsg;
2647 1 ▶ if ($filename eq '<') {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename eq "<") 0 1 1
2648 # try to convert filename in '<...>' to "normal" string
2649 0 $filename = '"';
2650 0 my $t;
2651 0 ▶ while (@arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (@arg) 0 0 0
2652 0 $t = shift @arg;
2653 0 ▶ if ($t eq '>') {
Branch: 1 branch
BranchTrueFalseTotal
if ($t eq ">") 0 0 0
2654 0 $filename .= '"';
2655 0 last;
2656 }
2657 0 $filename .= $t;
2658 }
2659 }
2660 1 ▶ if (substr($filename, 0, 1) ne '"') {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($filename, 0, 1) ne '"') { } 0 1 1
2661 0 error "include file name should be given in double quotes or < >";
2662 } else {
2663 1 $filename = substr($filename, 1);
2664 1 ▶ if (substr($filename, length($filename) - 1) ne '"') {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($filename, length($filename) - 1) ne '"') { } 0 1 1
2665 0 error "missing closing quote";
2666 } else {
2667 1 $filename = substr($filename, 0, length($filename) - 1);
2668 }
2669 }
2670 1 $filename =~ s/\\/\//g; # convert DOS path to Unix
2671 1 my $found = 1;
2672 1 ▶ if (not -e "$filename") {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e "$filename") 1 0 1
2673 1 $found = 0;
2674 1 foreach (@include_path) {
2675 1 ▶ if (-e "$_/$filename") {
Branch: 1 branch
BranchTrueFalseTotal
if (-e "$_/$filename") 1 0 1
2676 1 $filename = "$_/$filename";
2677 1 $found = 1;
2678 1 last;
2679 }
2680 }
2681 }
2682 1 ▶ $found or abort ("Cannot find file $filename");
Branch: 1 branch
BranchTrueFalseTotal
$found or abort("Cannot find file $filename") 1 0 1
2683 1 my $in_global_scope = 1;
2684 1 ▶ if (@typestack || @scopestack) {
Branch: 1 branch
BranchTrueFalseTotal
if (@typestack or @scopestack) 0 1 1
Condition33%1/3
@typestack or @scopestack
l!l&&r!l&&!r
001
MC/DC0%0/2
@typestack or @scopestack
@typestack @scopestack
Truth table33%1/3
A or B
A= @typestackB= @scopestack
ABresult
1X1
011
000
2685 0 $in_global_scope = 0;
2686 }
2687 1 my $include_node = [ INCFILE, $filename, 0, 0, $cmnt, curr_scope ];
2688 1 my $incfile_contents_ref = $includecache->get($filename);
2689 1 ▶ if ($incfile_contents_ref) {
Branch: 1 branch
BranchTrueFalseTotal
if ($incfile_contents_ref) { } 0 1 1
2690 0 $include_node->[SUBORDINATES] = $incfile_contents_ref;
2691 0 push @$symbols, $include_node;
2692 } else {
2693 1 unshift @prev_symroots, $symbols;
2694 1 $incfile_contents_ref = [];
2695 1 $include_node->[SUBORDINATES] = $incfile_contents_ref;
2696 # add include file node early so that find_node_i
2697 # can use it
2698 # @todo THIS CANNOT WORK - $symbols is local in this sub
2699 # and is not passed into the Parse_file_i call.
2700 1 push @$symbols, $include_node;
2701 1 ▶ Parse_File_i($filename, undef, $incfile_contents_ref)
Branch: 1 branch
BranchTrueFalseTotal
Parse_File_i($filename, undef, $incfile_contents_ref) or abort("can't go on, sorry") 1 0 1
2702 or abort("can't go on, sorry");
2703 1 $includecache->add($filename, $incfile_contents_ref);
2704 1 shift @prev_symroots;
2705 1 ▶ pop @scopestack if $in_global_scope;
Branch: 1 branch
BranchTrueFalseTotal
if $in_global_scope 1 0 1
2706 }
2707 1 ▶ unless ($in_global_scope) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($in_global_scope) 0 1 1
2708 # Quick fix for Ada code generator:
2709 # replace the INCFILE node by the symbols if not
2710 # in global scope
2711 0 pop @$symbols;
2712 0 foreach (@$incfile_contents_ref) {
2713 0 push @$symbols, $_
2714 }
2715 }
2716 } elsif ($directive =~ /^\d/) {
2717 # It's an output from the C preprocessor generated for
2718 # a "#include"
2719 0 my $linenum = $directive;
2720 0 $linenum =~ s/^(\d+)/$1/;
2721 0 my $filename = shift @arg;
2722 0 $filename = substr($filename, 1, length($filename) - 2);
2723 0 $filename =~ s@^./@@;
2724 0 $filename =~ s:/+:/:g;
2725 0 ▶ if ($filename eq $infilename[$currfile]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename eq $infilename[$currfile]) 0 0 0
2726 0 $line_number[$currfile] = $linenum;
2727 0 next;
2728 }
2729 0 my $seen_file = 0;
2730 0 my $i;
2731 0 ▶ for ($i = 0; $i <= $#infilename; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#infilename) 0 0 0
2732 0 ▶ if ($filename eq $infilename[$i]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename eq $infilename[$i]) 0 0 0
2733 0 $currfile = $i;
2734 0 $line_number[$currfile] = $linenum;
2735 0 $seen_file = 1;
2736 0 last;
2737 }
2738 }
2739 0 ▶ last if ($seen_file);
Branch: 1 branch
BranchTrueFalseTotal
if $seen_file 0 0 0
2740 0 push @infilename, $filename;
2741 0 $currfile = $#infilename;
2742 0 $line_number[$currfile] = $linenum;
2743 0 unshift @prev_symroots, $symbols;
2744 0 my $incfile_contents_ref = Parse_File_i("", $in, []);
2745 0 ▶ $incfile_contents_ref or abort("can't go on, sorry");
Branch: 1 branch
BranchTrueFalseTotal
$incfile_contents_ref or abort("can't go on, sorry") 0 0 0
2746 0 shift @prev_symroots;
2747 0 my @include_node = (INCFILE, $filename,
2748 $incfile_contents_ref, 0, $cmnt, curr_scope);
2749 0 push @$symbols, \@include_node;
2750 ▶ } elsif ($directive eq 'if' ||
Condition0%0/21
$directive eq "if" or $directive eq "ifdef" or $directive eq "ifndef" or $directive eq "elif" or $directive eq "else" or $directive eq "endif" or $directive eq "define" or $directive eq "undef"
l!l&&r!l&&!r
000
$directive eq "if" or $directive eq "ifdef" or $directive eq "ifndef" or $directive eq "elif" or $directive eq "else" or $directive eq "endif" or $directive eq "define"
l!l&&r!l&&!r
000
$directive eq "if" or $directive eq "ifdef" or $directive eq "ifndef" or $directive eq "elif" or $directive eq "else" or $directive eq "endif"
l!l&&r!l&&!r
000
$directive eq "if" or $directive eq "ifdef" or $directive eq "ifndef" or $directive eq "elif" or $directive eq "else"
l!l&&r!l&&!r
000
$directive eq "if" or $directive eq "ifdef" or $directive eq "ifndef" or $directive eq "elif"
l!l&&r!l&&!r
000
$directive eq "if" or $directive eq "ifdef" or $directive eq "ifndef"
l!l&&r!l&&!r
000
$directive eq "if" or $directive eq "ifdef"
l!l&&r!l&&!r
000
MC/DC0%0/8
$directive eq "if" or $directive eq "ifdef" or $directive eq "ifndef" or $directive eq "elif" or $directive eq "else" or $directive eq "endif" or $directive eq "define" or $directive eq "undef"
$directive eq "if" $directive eq "ifdef" $directive eq "ifndef" $directive eq "elif" $directive eq "else" $directive eq "endif" $directive eq "define" $directive eq "undef"
Truth table0%0/9
A or B or C or D or E or F or G or H
A= $directive eq "if"B= $directive eq "ifdef"C= $directive eq "ifndef"D= $directive eq "elif"E= $directive eq "else"F= $directive eq "endif"G= $directive eq "define"H= $directive eq "undef"
ABCDEFGHresult
1XXXXXXX1
01XXXXXX1
001XXXXX1
0001XXXX1
00001XXX1
000001XX1
0000001X1
000000011
000000000
2751 $directive eq 'ifdef' ||
2752 $directive eq 'ifndef' ||
2753 $directive eq 'elif' ||
2754 $directive eq 'else' ||
2755 $directive eq 'endif' ||
2756 $directive eq 'define' ||
2757 $directive eq 'undef') {
2758 # Sanity check only -
2759 # preprocessor conditions and definitions were already handled
2760 # in sub get_items and do not appear here.
2761 0 error "internal error - seen #$directive in Parse_File_i\n";
2762 } else {
2763 0 info "ignoring preprocessor directive \#$directive\n";
2764 }
2765 2 next;
2766  
2767 } elsif ($kw eq '@') {
2768 0 my $ann = shift @arg;
2769 0 ▶ if ($ann eq "annotation") {
Branch: 1 branch
BranchTrueFalseTotal
if ($ann eq 'annotation') { } 0 0 0
2770 0 my $name = check_name(shift @arg);
2771 0 push @typestack, ANNOTATION;
2772 0 push @namestack, $name;
2773 0 ▶ if (shift @arg ne '{') {
Branch: 1 branch
BranchTrueFalseTotal
if (shift @arg ne "{") 0 0 0
2774 0 error "expecting '{'";
2775 0 next;
2776 }
2777 0 @struct = ();
2778 0 ▶ if (@arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (@arg) 0 0 0
2779 0 ▶ if ($arg[0] eq '}' or
Branch: 1 branch
BranchTrueFalseTotal
if ($arg[0] eq "}" or parse_members($symbols, \@arg, \@struct) == 1) 0 0 0
Condition0%0/3
$arg[0] eq "}" or parse_members($symbols, \@arg, \@struct) == 1
l!l&&r!l&&!r
000
MC/DC0%0/2
$arg[0] eq "}" or parse_members($symbols, \@arg, \@struct) == 1
$arg[0] eq "}" parse_members($symbols, \@arg, \@struct) == 1
Truth table0%0/3
A or B
A= $arg[0] eq "}"B= parse_members($symbols, \@arg, \@struct) == 1
ABresult
1X1
011
000
2780 parse_members($symbols, \@arg, \@struct) == 1) {
2781 # end of type declaration was encountered
2782 0 push @annoDefs, [ $name, @struct ];
2783 0 pop @namestack;
2784 0 pop @typestack;
2785 0 @struct = ();
2786 }
2787 }
2788 } else {
2789 0 parse_annotation_app($ann, \@arg);
2790 0 ▶ if (@arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (@arg) 0 0 0
2791 0 unget_items(@arg);
2792 }
2793 }
2794 0 next;
2795  
2796 } elsif ($kw eq "\}") {
2797 34 ▶ if (shift @arg ne ';') {
Branch: 1 branch
BranchTrueFalseTotal
if (shift @arg ne ";") 0 34 34
2798 0 error "missing ';'";
2799 }
2800 34 ▶ unless (@typestack) { # must be closing of module, interface, or valuetype
Branch: 1 branch
BranchTrueFalseTotal
unless (@typestack) 19 15 34
2801 19 ▶ if (@scopestack) {
Branch: 1 branch
BranchTrueFalseTotal
if (@scopestack) { } 19 0 19
2802 19 pop @scopestack;
2803 } else {
2804 # did not see a '{'
2805 0 error("unexpected \};");
2806 }
2807 19 return $symbols;
2808 }
2809 15 ▶ if ($in_valuetype) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_valuetype) 0 15 15
2810 0 error "Parse_File_i internal: in_valuetype true on non empty typestack";
2811 0 return $symbols;
2812 }
2813 15 ▶ if (in_annotation_def()) {
Branch: 1 branch
BranchTrueFalseTotal
if (&in_annotation_def()) 0 15 15
2814 0 pop @typestack;
2815 0 my $anno = pop @namestack;
2816 0 push @annoDefs, [ $anno, @struct ];
2817 0 @struct = ();
2818 0 next;
2819 }
2820 15 my $type = pop @typestack;
2821 15 my $name = pop @namestack;
2822 15 my $anno = pop @annostack;
2823 15 my $cmnt = pop @cmntstack;
2824 15 ▶ if ($type == UNION && is_a($struct[0], ENUM)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 27 and is_a($struct[0], 23)) 1 14 15
Condition100%3/3
$type == 27 and is_a($struct[0], 23)
!ll&&!rl&&r
1041
MC/DC100%2/2
$type == 27 and is_a($struct[0], 23)
$type == 27 is_a($struct[0], 23)
Truth table100%3/3
A and B
A= $type == 27B= is_a($struct[0], 23)
ABresult
0X0
100
111
2825 # For the case of ENUM, check that all enum values
2826 # are covered by CASEs.
2827 # No check possible if DEFAULT given.
2828 1 ▶ unless (has_default_branch(\@struct)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (has_default_branch(\@struct)) 1 0 1
2829 1 my $enumtype = root_type($struct[0]);
2830 1 my %lits_given = ();
2831 1 my $umember;
2832 1 foreach $umember (@struct) {
2833 5 ▶ if ($umember->[TYPE] == CASE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($umember->[0] == 28) 2 3 5
2834 2 foreach (@{$umember->[SUBORDINATES]}) {
2835 2 my $stripped_lit = $_;
2836 2 $stripped_lit =~ s/^.*:://;
2837 2 $lits_given{$stripped_lit} = 1;
2838 }
2839 }
2840 }
2841 1 foreach (enum_literals($enumtype->[SUBORDINATES])) {
2842 3 ▶ my $lit = ref($_) ? $_->[0] : $_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_ ? : 0 3 3
2843 3 ▶ if (defined($lit) && !defined($lits_given{$lit})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $lit and not defined $lits_given{$lit}) 1 2 3
Condition66%2/3
defined $lit and not defined $lits_given{$lit}
!ll&&!rl&&r
021
MC/DC50%1/2
defined $lit and not defined $lits_given{$lit}
defined $lit not defined $lits_given{$lit}
Truth table66%2/3
A and not(B)
A= defined $litB= not defined $lits_given{$lit}
ABresult
0X0
100
111
2844 1 info("$name info: no case for enum value "
2845 . $lit . " given");
2846 }
2847 }
2848 }
2849 }
2850 15 my @structnode = ($type, $name, [ @struct ], $anno, $cmnt, curr_scope);
2851 15 ▶ if ($struct2vt && $type == STRUCT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CORBA::IDLtree::struct2vt and $type == 26) 0 15 15
Condition33%1/3
$CORBA::IDLtree::struct2vt and $type == 26
!ll&&!rl&&r
1500
MC/DC0%0/2
$CORBA::IDLtree::struct2vt and $type == 26
$CORBA::IDLtree::struct2vt $type == 26
Truth table33%1/3
A and B
A= $CORBA::IDLtree::struct2vtB= $type == 26
ABresult
0X0
100
111
2852 0 convert_to_valuetype(\@structnode);
2853 }
2854 15 pushsub($symbols, [ @structnode ]);
2855 15 @struct = ();
2856 15 next;
2857  
2858 } elsif ($kw eq 'module') {
2859 3 my $name = check_name(shift @arg);
2860 3 ▶ error("expecting '{'") if (shift(@arg) ne '{');
Branch: 1 branch
BranchTrueFalseTotal
if shift @arg ne "{" 0 3 3
2861 3 my $subord;
2862 3 my $fullname = join('::', scope_names(), $name);
2863 3 my $scope = curr_scope();
2864 # See if the full name is in the findnode_cache already.
2865 # This can happen in the case of reopened modules.
2866 # The findnode_cache always contains the most recently seen
2867 # reopening of a module.
2868 3 my $module = $findnode_cache->get($fullname);
2869 3 ▶ if ($module) {
Branch: 1 branch
BranchTrueFalseTotal
if ($module) 1 2 3
2870 # If this is a reopening then our SCOPEREF shall point to
2871 # the previous opening of the module.
2872 1 $scope = $module;
2873 }
2874 3 $subord = [ ];
2875 3 $module = [ MODULE, $name, $subord, annotation, $cmnt, $scope ];
2876 3 $findnode_cache->add($fullname, $module);
2877 3 push @$symbols, $module;
2878 3 unshift @prev_symroots, $symbols;
2879 3 push @scopestack, $module;
2880 3 ▶ Parse_File_i("", $in, $subord) or abort("can't go on, sorry");
Branch: 1 branch
BranchTrueFalseTotal
Parse_File_i("", $in, $subord) or abort("can't go on, sorry") 3 0 3
2881 3 ▶ unless ($module) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($module) 0 3 3
2882 0 shift @prev_symroots;
2883 }
2884 3 next;
2885  
2886 } elsif ($kw eq 'interface') {
2887 30 my $name = check_name(shift @arg);
2888 30 my $symnode = [ INTERFACE, $name, undef, annotation, $cmnt, curr_scope ];
2889 30 my $lasttok = pop(@arg);
2890 30 ▶ if ($lasttok eq ';') {
Branch: 2 branches
BranchTrueFalseTotal
if ($lasttok eq ';') { } 14 16 30
elsif ($lasttok ne '{') { } 0 16 16
2891 14 $symnode->[TYPE] = INTERFACE_FWD;
2892 14 push @$symbols, $symnode;
2893 14 next;
2894 } elsif ($lasttok ne '{') {
2895 0 push @arg, $lasttok;
2896 0 ▶ if (! require_end_of_stmt(\@arg, $in, '{')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (require_end_of_stmt(\@arg, $in, "{")) 0 0 0
2897 0 error "expecting '{'";
2898 0 next;
2899 }
2900 }
2901 16 my $fwd = find_node_i($name, $symbols);
2902 16 ▶ if ($fwd) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fwd) 14 2 16
2903 14 ▶ if ($$fwd[TYPE] != INTERFACE_FWD) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fwd->[0] != 34) 0 14 14
2904 0 error "type of interface fwd decl is not INTERFACE_FWD";
2905 0 next;
2906 }
2907 14 $$fwd[SUBORDINATES] = $symnode;
2908 }
2909 16 my @ancestor = ();
2910 16 ▶ if (@arg) { # we have ancestors
Branch: 1 branch
BranchTrueFalseTotal
if (@arg) 5 11 16
2911 5 ▶ if (shift @arg ne ':') {
Branch: 2 branches
BranchTrueFalseTotal
if (shift @arg ne ':') { } 0 5 5
elsif (not @arg) { } 0 5 5
2912 0 error "syntax error";
2913 0 next;
2914 } elsif (! @arg) {
2915 0 error "expecting ancestor(s)";
2916 0 next;
2917 }
2918 5 my $i; # "use strict" wants it.
2919 5 ▶ for ($i = 0; $i < @arg; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @arg) 6 5 11
2920 6 my $name = check_name($arg[$i], "ancestor name");
2921 6 my $ancestor_node = find_node_i($name, $symbols);
2922 6 ▶ if (! $ancestor_node) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ancestor_node) 0 6 6
2923 0 error "could not find ancestor $name";
2924 0 next;
2925 }
2926 6 push @ancestor, $ancestor_node;
2927 6 ▶ if ($i < $#arg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $#arg) 1 5 6
2928 1 ▶ if ($arg[++$i] ne ',') {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg[++$i] ne ",") 0 1 1
2929 0 error "expecting comma separated list of ancestors";
2930 0 last;
2931 }
2932 }
2933 }
2934 }
2935 16 my $subord = [ \@ancestor, $abstract ];
2936 16 $symnode->[SUBORDINATES] = $subord;
2937 16 push @$symbols, $symnode;
2938 16 unshift @prev_symroots, $symbols;
2939 16 push @scopestack, $symnode;
2940 16 ▶ Parse_File_i("", $in, $subord)
Branch: 1 branch
BranchTrueFalseTotal
Parse_File_i("", $in, $subord) or abort("can't go on, sorry") 16 0 16
2941 or abort("can't go on, sorry");
2942 16 shift @prev_symroots;
2943 16 $abstract = 0;
2944 16 next;
2945  
2946 } elsif ($kw eq 'local') {
2947 0 $abstract = LOCAL;
2948 0 goto KEYWORD;
2949  
2950 } elsif ($kw eq 'abstract') {
2951 0 $abstract = ABSTRACT;
2952 0 goto KEYWORD;
2953  
2954 } elsif ($kw eq 'custom') {
2955 0 $custom = 1;
2956 0 goto KEYWORD;
2957  
2958 } elsif ($kw eq 'valuetype') {
2959 0 my $name = check_name(shift @arg);
2960 0 my $anno = annotation;
2961 0 my $symnode = [ VALUETYPE, $name, 0, $anno, $cmnt, curr_scope ];
2962 0 ▶ if ($vt2struct) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CORBA::IDLtree::vt2struct) { } 0 0 0
2963 0 push @typestack, STRUCT;
2964 0 push @namestack, $name;
2965 0 push @annostack, $anno;
2966 0 push @cmntstack, $cmnt;
2967 0 @struct = ();
2968 } else {
2969 0 push @$symbols, $symnode;
2970 }
2971 0 my $nxttok = shift @arg;
2972 0 ▶ if ($nxttok eq ';') {
Branch: 1 branch
BranchTrueFalseTotal
if ($nxttok eq ";") 0 0 0
2973 0 $symnode->[TYPE] = VALUETYPE_FWD;
2974 # Aliased to $symbols[$#symbols]
2975 0 next;
2976 }
2977 0 my @ancestors = (); # do the inheritance jive
2978 0 my $seen_ancestors = 0;
2979 0 ▶ if ($nxttok eq ':') {
Branch: 1 branch
BranchTrueFalseTotal
if ($nxttok eq ":") 0 0 0
2980 0 ▶ if (($nxttok = shift @arg) eq 'truncatable') {
Branch: 1 branch
BranchTrueFalseTotal
if (($nxttok = shift @arg) eq "truncatable") 0 0 0
2981 0 $vt_inheritance[0] = 1;
2982 0 $nxttok = shift @arg;
2983 }
2984 0 ▶ while (isname($nxttok) and $nxttok ne 'supports') {
Branch: 1 branch
BranchTrueFalseTotal
if (isname($nxttok) and $nxttok ne "supports") 0 0 0
Condition0%0/3
isname($nxttok) and $nxttok ne "supports"
!ll&&!rl&&r
000
MC/DC0%0/2
isname($nxttok) and $nxttok ne "supports"
isname($nxttok) $nxttok ne "supports"
Truth table0%0/3
A and B
A= isname($nxttok)B= $nxttok ne "supports"
ABresult
0X0
100
111
2985 0 my $anc_type = find_node_i($nxttok, $symbols);
2986 0 ▶ if (! isnode($anc_type)
Branch: 1 branch
BranchTrueFalseTotal
if (not isnode($anc_type) or $anc_type->[0] != 35 and $anc_type->[0] != 37 and $anc_type->[0] != 36) { } 0 0 0
Condition0%0/9
not isnode($anc_type) or $anc_type->[0] != 35 and $anc_type->[0] != 37 and $anc_type->[0] != 36
l!l&&r!l&&!r
000
$anc_type->[0] != 35 and $anc_type->[0] != 37 and $anc_type->[0] != 36
!ll&&!rl&&r
000
$anc_type->[0] != 35 and $anc_type->[0] != 37
!ll&&!rl&&r
000
MC/DC0%0/4
not isnode($anc_type) or $anc_type->[0] != 35 and $anc_type->[0] != 37 and $anc_type->[0] != 36
not isnode($anc_type) $anc_type->[0] != 35 $anc_type->[0] != 37 $anc_type->[0] != 36
Truth table0%0/5
not(A) or B and C and D
A= not isnode($anc_type)B= $anc_type->[0] != 35C= $anc_type->[0] != 37D= $anc_type->[0] != 36
ABCDresult
1XXX1
01111
00XX0
010X0
01100
2987 || ($$anc_type[TYPE] != VALUETYPE &&
2988 $$anc_type[TYPE] != VALUETYPE_BOX &&
2989 $$anc_type[TYPE] != VALUETYPE_FWD)) {
2990 0 error "ancestor $nxttok must be valuetype";
2991 } else {
2992 0 push @ancestors, $anc_type;
2993 }
2994 0 ▶ last unless (($nxttok = shift @arg) eq ',');
Branch: 1 branch
BranchTrueFalseTotal
unless ($nxttok = shift @arg) eq "," 0 0 0
2995 0 $nxttok = shift @arg;
2996 }
2997 0 $seen_ancestors = 1;
2998 }
2999 0 ▶ if ($nxttok eq 'supports') {
Branch: 1 branch
BranchTrueFalseTotal
if ($nxttok eq "supports") 0 0 0
3000 0 ▶ while (isname($nxttok = shift @arg)) {
Branch: 1 branch
BranchTrueFalseTotal
if (isname($nxttok = shift @arg)) 0 0 0
3001 0 my $anc_type = find_node_i($nxttok, $symbols);
3002 0 ▶ if (! $anc_type) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $anc_type) { } 0 0 0
elsif (not isnode($anc_type) or $anc_type->[0] != 33 or $anc_type->[0] != 34) { } 0 0 0
3003 0 error "unknown ancestor $nxttok";
3004 ▶ } elsif (! isnode($anc_type)
Condition0%0/6
not isnode($anc_type) or $anc_type->[0] != 33 or $anc_type->[0] != 34
l!l&&r!l&&!r
000
not isnode($anc_type) or $anc_type->[0] != 33
l!l&&r!l&&!r
000
MC/DC0%0/3
not isnode($anc_type) or $anc_type->[0] != 33 or $anc_type->[0] != 34
not isnode($anc_type) $anc_type->[0] != 33 $anc_type->[0] != 34
Truth table0%0/4
not(A) or B or C
A= not isnode($anc_type)B= $anc_type->[0] != 33C= $anc_type->[0] != 34
ABCresult
1XX1
01X1
0011
0000
3005 || $$anc_type[TYPE] != INTERFACE
3006 || $$anc_type[TYPE] != INTERFACE_FWD) {
3007 0 error "ancestor $nxttok must be interface";
3008 } else {
3009 0 push @ancestors, $anc_type;
3010 }
3011 0 ▶ last unless (($nxttok = shift @arg) eq ',');
Branch: 1 branch
BranchTrueFalseTotal
unless ($nxttok = shift @arg) eq "," 0 0 0
3012 }
3013 0 $seen_ancestors = 1;
3014 }
3015 0 ▶ if ($seen_ancestors) {
Branch: 3 branches
BranchTrueFalseTotal
if ($seen_ancestors) { } 0 0 0
elsif (isname($nxttok)) { } 0 0 0
elsif ($nxttok ne '{') { } 0 0 0
3016 0 ▶ if ($nxttok ne '{') {
Branch: 1 branch
BranchTrueFalseTotal
if ($nxttok ne "{") 0 0 0
3017 0 error "expecting '{' at valuetype declaration";
3018 }
3019 0 $vt_inheritance[1] = [ @ancestors ];
3020 } elsif (isname $nxttok) {
3021 # suspect a value box
3022 0 my $type = parse_type($nxttok, \@arg, $symbols);
3023 0 ▶ if ($type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type) { } 0 0 0
3024 0 $symnode->[TYPE] = VALUETYPE_BOX;
3025 0 $symnode->[SUBORDINATES] = $type;
3026 # Aliased to $symbols[$#symbols]
3027 } else {
3028 0 error "value box: unknown type $nxttok";
3029 }
3030 0 next;
3031 } elsif ($nxttok ne '{') {
3032 0 error "expecting '{' at valuetype declaration";
3033 }
3034 0 my $fwd = find_node_i($name, $symbols);
3035 0 ▶ if (ref($fwd) && $$fwd[TYPE] == VALUETYPE_FWD) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $fwd and $fwd->[0] == 36) 0 0 0
Condition0%0/3
ref $fwd and $fwd->[0] == 36
!ll&&!rl&&r
000
MC/DC0%0/2
ref $fwd and $fwd->[0] == 36
ref $fwd $fwd->[0] == 36
Truth table0%0/3
A and B
A= ref $fwdB= $fwd->[0] == 36
ABresult
0X0
100
111
3036 0 $$fwd[SUBORDINATES] = $symnode;
3037 }
3038  
3039 0 ▶ unless ($vt2struct) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($CORBA::IDLtree::vt2struct) 0 0 0
3040 0 my $declarations = [ ];
3041 0 my $obvsub = [ $abstract, [ @vt_inheritance ], $declarations ];
3042 0 $symnode->[SUBORDINATES] = $obvsub;
3043 0 unshift @prev_symroots, $symbols;
3044 0 push @scopestack, $symnode;
3045 0 ▶ Parse_File_i("", $in, $declarations, 1) or abort("can't go on, sorry");
Branch: 1 branch
BranchTrueFalseTotal
Parse_File_i("", $in, $declarations, 1) or abort("can't go on, sorry") 0 0 0
3046 # The closing brace and ";" was seen in Parse_File_i and @scopestack
3047 # was popped there.
3048 0 shift @prev_symroots;
3049 }
3050 0 $abstract = 0;
3051 0 @vt_inheritance = (0, 0);
3052 0 next;
3053  
3054 ▶ } elsif ($kw eq 'public' or $kw eq 'private') {
Condition33%1/3
$kw eq "public" or $kw eq "private"
l!l&&r!l&&!r
00132
MC/DC0%0/2
$kw eq "public" or $kw eq "private"
$kw eq "public" $kw eq "private"
Truth table33%1/3
A or B
A= $kw eq "public"B= $kw eq "private"
ABresult
1X1
011
000
3055 0 ▶ unless ($in_valuetype) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($in_valuetype) 0 0 0
3056 0 error "'$kw' is only permitted in valuetypes";
3057 0 next;
3058 }
3059 0 ▶ if ($abstract) {
Branch: 1 branch
BranchTrueFalseTotal
if ($abstract) 0 0 0
3060 0 error "state members not permitted in abstract valuetype";
3061 0 next;
3062 }
3063 0 ▶ if ($vt2struct) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CORBA::IDLtree::vt2struct) { } 0 0 0
3064 0 ▶ if (parse_members($symbols, \@arg, \@struct) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (parse_members($symbols, \@arg, \@struct) == 1) 0 0 0
3065 # end of type declaration was encountered
3066 0 my $type = pop @typestack;
3067 0 my $name = pop @namestack;
3068 0 my $initial_cmnt = pop @cmntstack;
3069 0 my @node = ($type, $name, [ @struct ], 0, $initial_cmnt, curr_scope);
3070 0 push @$symbols, [ @node ];
3071 0 @struct = ();
3072 }
3073 } else {
3074 0 my $vt_access;
3075 0 ▶ if ($kw eq 'public') {
Branch: 1 branch
BranchTrueFalseTotal
if ($kw eq 'public') { } 0 0 0
3076 0 $vt_access = PUBLIC;
3077 } else {
3078 0 $vt_access = PRIVATE;
3079 }
3080 0 ▶ if (parse_members($symbols, \@arg, $vt_access, $cmnt) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (parse_members($symbols, \@arg, $vt_access, $cmnt) == 1) 0 0 0
3081 # end of type declaration was encountered
3082 0 ▶ if (@scopestack) {
Branch: 1 branch
BranchTrueFalseTotal
if (@scopestack) { } 0 0 0
3083 0 pop @scopestack;
3084 } else {
3085 0 error "internal error - scopestack is empty";
3086 }
3087 0 return $symbols;
3088 }
3089 }
3090 0 next;
3091  
3092 ▶ } elsif ($kw eq 'struct' or $kw eq 'exception') {
Condition100%3/3
$kw eq "struct" or $kw eq "exception"
l!l&&r!l&&!r
82122
MC/DC100%2/2
$kw eq "struct" or $kw eq "exception"
$kw eq "struct" $kw eq "exception"
Truth table100%3/3
A or B
A= $kw eq "struct"B= $kw eq "exception"
ABresult
1X1
011
000
3093 10 my $type;
3094 10 ▶ $type = ($kw eq 'struct' ? STRUCT : EXCEPTION);
Branch: 1 branch
BranchTrueFalseTotal
$kw eq 'struct' ? : 8 2 10
3095 10 my $name = check_name(shift @arg);
3096 10 my $anno = annotation;
3097 10 push @typestack, $type;
3098 10 push @namestack, $name;
3099 10 push @annostack, $anno;
3100 10 push @cmntstack, $cmnt;
3101 10 @struct = ();
3102 10 my $nxt = shift @arg;
3103 10 ▶ if ($type == STRUCT && $nxt eq ':') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 26 and $nxt eq ":") 0 10 10
Condition66%2/3
$type == 26 and $nxt eq ":"
!ll&&!rl&&r
280
MC/DC0%0/2
$type == 26 and $nxt eq ":"
$type == 26 $nxt eq ":"
Truth table66%2/3
A and B
A= $type == 26B= $nxt eq ":"
ABresult
0X0
100
111
3104 0 my $parent_type = shift @arg;
3105 0 my $parent = parse_type($parent_type, \@arg, $symbols);
3106 0 ▶ if (isnode($parent) && $parent->[TYPE] == STRUCT) {
Branch: 1 branch
BranchTrueFalseTotal
if (isnode($parent) and $parent->[0] == 26) { } 0 0 0
Condition0%0/3
isnode($parent) and $parent->[0] == 26
!ll&&!rl&&r
000
MC/DC0%0/2
isnode($parent) and $parent->[0] == 26
isnode($parent) $parent->[0] == 26
Truth table0%0/3
A and B
A= isnode($parent)B= $parent->[0] == 26
ABresult
0X0
100
111
3107 0 push @struct, $parent;
3108 } else {
3109 0 error "expecting a struct type as parent of $name";
3110 }
3111 0 $nxt = shift @arg;
3112 }
3113 10 ▶ if ($nxt ne '{') {
Branch: 1 branch
BranchTrueFalseTotal
if ($nxt ne "{") 0 10 10
3114 0 error "expecting '{'";
3115 0 next;
3116 }
3117 10 ▶ if (@arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (@arg) 0 10 10
3118 0 ▶ if ($arg[0] eq '}' or
Branch: 1 branch
BranchTrueFalseTotal
if ($arg[0] eq "}" or parse_members($symbols, \@arg, \@struct, $cmnt) == 1) 0 0 0
Condition0%0/3
$arg[0] eq "}" or parse_members($symbols, \@arg, \@struct, $cmnt) == 1
l!l&&r!l&&!r
000
MC/DC0%0/2
$arg[0] eq "}" or parse_members($symbols, \@arg, \@struct, $cmnt) == 1
$arg[0] eq "}" parse_members($symbols, \@arg, \@struct, $cmnt) == 1
Truth table0%0/3
A or B
A= $arg[0] eq "}"B= parse_members($symbols, \@arg, \@struct, $cmnt) == 1
ABresult
1X1
011
000
3119 parse_members($symbols, \@arg, \@struct, $cmnt) == 1) {
3120 # end of type declaration was encountered
3121 0 my $node = [ $type, $name, [ @struct ], $anno, $cmnt, curr_scope ];
3122 0 ▶ if ($struct2vt && $type == STRUCT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CORBA::IDLtree::struct2vt and $type == 26) 0 0 0
Condition0%0/3
$CORBA::IDLtree::struct2vt and $type == 26
!ll&&!rl&&r
000
MC/DC0%0/2
$CORBA::IDLtree::struct2vt and $type == 26
$CORBA::IDLtree::struct2vt $type == 26
Truth table0%0/3
A and B
A= $CORBA::IDLtree::struct2vtB= $type == 26
ABresult
0X0
100
111
3123 0 convert_to_valuetype($node);
3124 }
3125 0 push @$symbols, $node;
3126 0 pop @cmntstack;
3127 0 pop @annostack;
3128 0 pop @namestack;
3129 0 pop @typestack;
3130 0 @struct = ();
3131 }
3132 }
3133 10 next;
3134  
3135 } elsif ($kw eq 'union') {
3136 5 my $name = check_name(shift @arg, "type name");
3137 5 my $anno = annotation;
3138 5 push @typestack, UNION;
3139 5 push @namestack, $name;
3140 5 push @annostack, $anno;
3141 5 push @cmntstack, $cmnt;
3142 5 ▶ if (shift(@arg) ne 'switch') {
Branch: 1 branch
BranchTrueFalseTotal
if (shift @arg ne "switch") 0 5 5
3143 0 error "union: expecting keyword 'switch'";
3144 0 next;
3145 }
3146 5 my $nxt = shift @arg;
3147 5 ▶ if ($nxt ne '(') {
Branch: 1 branch
BranchTrueFalseTotal
if ($nxt ne "(") 0 5 5
3148 0 error "expecting '('";
3149 0 next;
3150 }
3151 5 $nxt = shift @arg;
3152 5 ▶ while ($nxt eq '@') {
Branch: 1 branch
BranchTrueFalseTotal
if ($nxt eq "\@") 0 5 5
3153 0 my $annoName = shift @arg;
3154 0 parse_annotation_app($annoName, \@arg);
3155 0 $nxt = shift @arg;
3156 }
3157 5 my $switchtypename = $nxt;
3158 5 my $switchtype = find_node_i($switchtypename, $symbols);
3159 5 ▶ if (! $switchtype) {
Branch: 3 branches
BranchTrueFalseTotal
if (not $switchtype) { } 0 5 5
elsif (isnode($switchtype)) { } 1 4 5
elsif ($switchtype < 1 or $switchtype > 10) { } 0 4 4
3160 0 error "unknown type of switch variable";
3161 0 next;
3162 } elsif (isnode $switchtype) {
3163 1 my $typ = ${$switchtype}[TYPE];
3164 1 ▶ if ($typ < BOOLEAN ||
Branch: 1 branch
BranchTrueFalseTotal
if ($typ < 1 or $typ > 9 and $typ != 23 and $typ != 24) 0 1 1
Condition33%3/9
$typ < 1 or $typ > 9 and $typ != 23 and $typ != 24
l!l&&r!l&&!r
001
$typ > 9 and $typ != 23 and $typ != 24
!ll&&!rl&&r
100
$typ > 9 and $typ != 23
!ll&&!rl&&r
010
MC/DC0%0/4
$typ < 1 or $typ > 9 and $typ != 23 and $typ != 24
$typ < 1 $typ > 9 $typ != 23 $typ != 24
Truth table20%1/5
A or B and C and D
A= $typ < 1B= $typ > 9C= $typ != 23D= $typ != 24
ABCDresult
1XXX1
01111
00XX0
010X0
01100
3165 ($typ > ULONG && $typ != ENUM && $typ != TYPEDEF)) {
3166 0 error "illegal switch variable type (node; $typ)";
3167 0 next;
3168 }
3169 ▶ } elsif ($switchtype < BOOLEAN || $switchtype > ULONGLONG) {
Condition33%1/3
$switchtype < 1 or $switchtype > 10
l!l&&r!l&&!r
004
MC/DC0%0/2
$switchtype < 1 or $switchtype > 10
$switchtype < 1 $switchtype > 10
Truth table33%1/3
A or B
A= $switchtype < 1B= $switchtype > 10
ABresult
1X1
011
000
3170 0 error "illegal switch variable type ($switchtype)";
3171 0 next;
3172 }
3173 5 ▶ error("expecting ')'") if (shift @arg ne ')');
Branch: 1 branch
BranchTrueFalseTotal
if shift @arg ne ")" 0 5 5
3174 5 ▶ error("expecting '{'") if (shift @arg ne '{');
Branch: 1 branch
BranchTrueFalseTotal
if shift @arg ne "{" 0 5 5
3175 5 ▶ error("ignoring excess characters") if (@arg);
Branch: 1 branch
BranchTrueFalseTotal
if @arg 0 5 5
3176 5 @struct = ($switchtype);
3177 5 next;
3178  
3179 ▶ } elsif ($kw eq 'case' or $kw eq 'default') {
Condition100%3/3
$kw eq "case" or $kw eq "default"
l!l&&r!l&&!r
161100
MC/DC100%2/2
$kw eq "case" or $kw eq "default"
$kw eq "case" $kw eq "default"
Truth table100%3/3
A or B
A= $kw eq "case"B= $kw eq "default"
ABresult
1X1
011
000
3180 17 my @node;
3181 17 my @casevals = ();
3182 17 ▶ if ($kw eq 'case') {
Branch: 1 branch
BranchTrueFalseTotal
if ($kw eq 'case') { } 16 1 17
3183 16 ▶ while (@arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (@arg) 16 0 16
3184 16 push @casevals, shift @arg;
3185 16 ▶ if (shift @arg ne ':') {
Branch: 1 branch
BranchTrueFalseTotal
if (shift @arg ne ":") 0 16 16
3186 0 error "expecting ':'";
3187 0 last;
3188 }
3189 16 ▶ last unless (@arg);
Branch: 1 branch
BranchTrueFalseTotal
unless @arg 4 12 16
3190 12 ▶ last unless ($arg[0] eq 'case');
Branch: 1 branch
BranchTrueFalseTotal
unless $arg[0] eq "case" 12 0 12
3191 0 shift @arg;
3192 }
3193 16 ▶ if (! @arg) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@arg) 4 12 16
3194 # Peek ahead at following lines. If they contain further
3195 # CASEs then append them to @casevals.
3196 4 ▶ while ((@arg = get_items($in))) {
Branch: 1 branch
BranchTrueFalseTotal
if (@arg = get_items($in)) 4 0 4
3197 4 $kw = shift @arg;
3198 4 ▶ unless ($kw eq 'case') {
Branch: 1 branch
BranchTrueFalseTotal
unless ($kw eq "case") 2 2 4
3199 2 unshift @arg, $kw;
3200 2 unget_items(@arg);
3201 2 @arg = ();
3202 2 last;
3203 }
3204 2 ▶ if ($arg[$#arg] eq ';') {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg[$#arg] eq ";") 2 0 2
3205 2 pop @arg;
3206 }
3207 2 ▶ while (@arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (@arg) 2 0 2
3208 2 push @casevals, shift @arg;
3209 2 ▶ if (shift @arg ne ':') {
Branch: 1 branch
BranchTrueFalseTotal
if (shift @arg ne ":") 0 2 2
3210 0 error "expecting ':'";
3211 0 last;
3212 }
3213 2 ▶ last unless (@arg);
Branch: 1 branch
BranchTrueFalseTotal
unless @arg 0 2 2
3214 2 ▶ last unless ($arg[0] eq 'case');
Branch: 1 branch
BranchTrueFalseTotal
unless $arg[0] eq "case" 2 0 2
3215 0 shift @arg;
3216 }
3217 2 ▶ last if (@arg);
Branch: 1 branch
BranchTrueFalseTotal
if @arg 2 0 2
3218 }
3219 }
3220 16 @node = (CASE, "", \@casevals);
3221 } else {
3222 1 ▶ if (shift @arg ne ':') {
Branch: 1 branch
BranchTrueFalseTotal
if (shift @arg ne ":") 0 1 1
3223 0 error "expecting ':'";
3224 0 next;
3225 }
3226 1 @node = (DEFAULT, "", 0);
3227 }
3228 17 check_union_case($symbols, \@struct, \@node);
3229 17 push @struct, \@node;
3230 17 ▶ if (@arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (@arg) 15 2 17
3231 15 ▶ if (parse_members($symbols, \@arg, \@struct) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (parse_members($symbols, \@arg, \@struct) == 1) 0 15 15
3232 # end of type declaration was encountered
3233 0 ▶ if ($#typestack < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#typestack < 0) 0 0 0
3234 0 error "internal error 1";
3235 0 next;
3236 }
3237 0 my $type = pop @typestack;
3238 0 my $name = pop @namestack;
3239 0 my $anno = pop @annostack;
3240 0 my $initial_cmnt = pop @cmntstack;
3241 0 ▶ if ($initial_cmnt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($initial_cmnt) 0 0 0
3242 0 ▶ if ($cmnt && $cmnt != $initial_cmnt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmnt and $cmnt != $initial_cmnt) 0 0 0
Condition0%0/3
$cmnt and $cmnt != $initial_cmnt
!ll&&!rl&&r
000
MC/DC0%0/2
$cmnt and $cmnt != $initial_cmnt
$cmnt $cmnt != $initial_cmnt
Truth table0%0/3
A and B
A= $cmntB= $cmnt != $initial_cmnt
ABresult
0X0
100
111
3243 0 push @{$initial_cmnt->[1]}, @{$cmnt->[1]};
3244 }
3245 0 $cmnt = $initial_cmnt;
3246 }
3247 0 ▶ if ($type != UNION) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type != 27) 0 0 0
3248 0 error "internal error 2";
3249 0 next;
3250 }
3251 0 my @unionnode = ($type, $name, [ @struct ], $anno, $cmnt,
3252 curr_scope);
3253 0 push @$symbols, [ @unionnode ];
3254 0 @struct = ();
3255 }
3256 }
3257 17 next;
3258  
3259 } elsif ($kw eq 'enum') {
3260 3 my $typename = check_name(shift @arg, "type name");
3261 3 ▶ if (shift @arg ne '{') {
Branch: 1 branch
BranchTrueFalseTotal
if (shift @arg ne "{") 0 3 3
3262 0 error("expecting '{'");
3263 0 next;
3264 }
3265 3 my $anno = annotation;
3266 3 my @values = ();
3267 3 ▶ @arg = get_items($in) unless @arg;
Branch: 1 branch
BranchTrueFalseTotal
unless @arg 1 2 3
3268 3 while (1) {
3269 12 my $lit = shift @arg;
3270 12 ▶ if (in_annotation_def()) {
Branch: 1 branch
BranchTrueFalseTotal
if (&in_annotation_def()) { } 0 12 12
3271 0 ▶ unless ($lit =~ /^\w+$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($lit =~ /^\w+$/) 0 0 0
3272 0 error("illegal enum value at $lit");
3273 0 $lit = check_name($lit);
3274 }
3275 0 push @values, $lit;
3276 } else {
3277 12 ▶ if ($enable_comments && @remark) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CORBA::IDLtree::enable_comments and @remark) 0 12 12
Condition33%1/3
$CORBA::IDLtree::enable_comments and @remark
!ll&&!rl&&r
1200
MC/DC0%0/2
$CORBA::IDLtree::enable_comments and @remark
$CORBA::IDLtree::enable_comments @remark
Truth table33%1/3
A and B
A= $CORBA::IDLtree::enable_commentsB= @remark
ABresult
0X0
100
111
3278 0 push @values, [ $starting_line_number_of_remark, "", [ @remark ]];
3279 0 $starting_line_number_of_remark = 0;
3280 0 @remark = ();
3281 }
3282 12 ▶ while ($lit eq '@') {
Branch: 1 branch
BranchTrueFalseTotal
if ($lit eq "\@") 0 12 12
3283 0 my $annoName = shift @arg;
3284 0 parse_annotation_app($annoName, \@arg);
3285 0 $lit = shift @arg;
3286 }
3287 12 $lit = check_name($lit); # must be a literal
3288 12 ▶ unless ($lit =~ /^\w+$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($lit =~ /^\w+$/) 0 12 12
3289 0 last; # error message was already produced by sub check_name
3290 }
3291 12 push @values, [ $lit, annotation, comment ];
3292 }
3293 12 ▶ if (@arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (@arg) 12 0 12
3294 12 my $nxt = shift @arg;
3295 12 ▶ $nxt eq '}' and last;
Branch: 1 branch
BranchTrueFalseTotal
$nxt eq "}" and last 3 9 12
3296 9 ▶ unless ($nxt eq ',') {
Branch: 1 branch
BranchTrueFalseTotal
unless ($nxt eq ",") 0 9 9
3297 0 error "syntax error at $nxt (expecting ',')";
3298 0 last;
3299 }
3300 }
3301 } continue {
3302 9 ▶ @arg = get_items($in) unless @arg;
Branch: 1 branch
BranchTrueFalseTotal
unless @arg 4 5 9
3303 }
3304 3 ▶ if (in_annotation_def()) {
Branch: 1 branch
BranchTrueFalseTotal
if (&in_annotation_def()) { } 0 3 3
3305 0 $annoEnum{$typename} = [ @values ];
3306 } else {
3307 3 my $node = [ ENUM, $typename, [ @values ], $anno, $cmnt, curr_scope ];
3308 3 push @$symbols, $node;
3309 }
3310 3 next;
3311 }
3312  
3313 97 ▶ if (! require_end_of_stmt(\@arg, $in)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (require_end_of_stmt(\@arg, $in)) 0 97 97
3314 0 error "statement not terminated";
3315 0 next;
3316 }
3317  
3318 97 ▶ if ($kw eq 'native') {
Branch: 5 branches
BranchTrueFalseTotal
if ($kw eq 'native') { } 0 97 97
elsif ($kw eq 'const') { } 12 85 97
elsif ($kw eq 'typedef') { } 13 72 85
elsif ($kw eq 'readonly' or $kw eq 'attribute') { } 3 69 72
elsif (grep /\(/, @arg) { } 54 15 69
3319 0 my $name = check_name(shift @arg, "type name");
3320 0 my $node = [ NATIVE, $name, 0, annotation, $cmnt, curr_scope ];
3321 0 pushsub($symbols, $node, $in_valuetype);
3322  
3323 } elsif ($kw eq 'const') {
3324 12 my $type = shift @arg;
3325 12 my $name = shift @arg;
3326 12 ▶ if (shift(@arg) ne '=') {
Branch: 1 branch
BranchTrueFalseTotal
if (shift @arg ne "=") 0 12 12
3327 0 error "expecting '='";
3328 0 next;
3329 }
3330 12 my $typething = find_node_i($type, $symbols);
3331 12 ▶ unless ($typething) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($typething) 0 12 12
3332 0 error "unknown const type $type";
3333 0 next;
3334 }
3335 # Check basic validity of the RHS expression.
3336 12 foreach (@arg) {
3337 12 ▶ next if (/^\d/ or /^\.\d/ or /^-\d/); # numeric constant
Branch: 1 branch
BranchTrueFalseTotal
if /^\d/ or /^\.\d/ or /^-\d/ 7 5 12
Condition66%4/6
/^\d/ or /^\.\d/ or /^-\d/
l!l&&r!l&&!r
705
/^\d/ or /^\.\d/
l!l&&r!l&&!r
705
MC/DC33%1/3
/^\d/ or /^\.\d/ or /^-\d/
/^\d/ /^\.\d/ /^-\d/
Truth table50%2/4
A or B or C
A= /^\d/B= /^\.\d/C= /^-\d/
ABCresult
1XX1
01X1
0011
0000
3338 5 ▶ next if (/^'.*'$/ or /^".*"$/); # character or string
Branch: 1 branch
BranchTrueFalseTotal
if /^'.*'$/ or /^".*"$/ 2 3 5
Condition100%3/3
/^'.*'$/ or /^".*"$/
l!l&&r!l&&!r
113
MC/DC100%2/2
/^'.*'$/ or /^".*"$/
/^'.*'$/ /^".*"$/
Truth table100%3/3
A or B
A= /^'.*'$/B= /^".*"$/
ABresult
1X1
011
000
3339 3 ▶ next if is_valid_identifier $_; # identifier
Branch: 1 branch
BranchTrueFalseTotal
if is_valid_identifier($_) 3 0 3
3340 # Check against predefined operands.
3341 0 my $arg = $_;
3342 0 my @operands = ( '+', '-', '*', '/', '%', '<<', '>>', '~',
3343 '^', '|', '&', '!', '||', '&&', '==', '!=',
3344 '<', '>', '<=', '>=' );
3345 0 my $is_operand = 0;
3346 0 foreach (@operands) {
3347 0 ▶ if ($arg eq $_) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg eq $_) 0 0 0
3348 0 $is_operand = 1;
3349 0 last;
3350 }
3351 }
3352 0 ▶ next if $is_operand;
Branch: 1 branch
BranchTrueFalseTotal
if $is_operand 0 0 0
3353 0 error "unknown token in CONST: $arg";
3354 }
3355 12 my @tuple = ($typething, [ @arg ]);
3356 12 ▶ if (isnode $typething) {
Branch: 1 branch
BranchTrueFalseTotal
if (isnode($typething)) 2 10 12
3357 2 my $id = ${$typething}[TYPE];
3358 2 ▶ if ($id < ENUM || $id > TYPEDEF) {
Branch: 1 branch
BranchTrueFalseTotal
if ($id < 23 or $id > 24) 0 2 2
Condition33%1/3
$id < 23 or $id > 24
l!l&&r!l&&!r
002
MC/DC0%0/2
$id < 23 or $id > 24
$id < 23 $id > 24
Truth table33%1/3
A or B
A= $id < 23B= $id > 24
ABresult
1X1
011
000
3359 0 error "expecting type";
3360 0 next;
3361 }
3362 }
3363 12 my $node = [ CONST, $name, \@tuple, annotation, $cmnt, curr_scope ];
3364 12 pushsub($symbols, $node, $in_valuetype);
3365  
3366 } elsif ($kw eq 'typedef') {
3367 13 my $oldtype = check_typename(shift @arg, "name of original type");
3368 # TO BE DONE: oldtype is STRUCT or UNION
3369 13 my $existing_typenode = parse_type($oldtype, \@arg, $symbols);
3370 13 ▶ if (! $existing_typenode) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($existing_typenode) 0 13 13
3371 0 error "typedef: unknown type $oldtype";
3372 0 next;
3373 }
3374 13 my $newtype = check_name(shift @arg, "name of newly defined type");
3375 13 my @dimensions = ();
3376 13 ▶ while (@arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (@arg) 7 13 20
3377 7 ▶ if (shift(@arg) ne '[') {
Branch: 1 branch
BranchTrueFalseTotal
if (shift @arg ne "[") 0 7 7
3378 0 error "expecting '['";
3379 0 last;
3380 }
3381 7 my $dim;
3382 my $token;
3383 7 ▶ while (@arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (@arg) 14 0 14
3384 14 $token = shift(@arg);
3385 14 ▶ last if ($token eq ']');
Branch: 1 branch
BranchTrueFalseTotal
if $token eq "]" 7 7 14
3386 7 ▶ if ($dim) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dim) 0 7 7
3387 0 $dim .= ' ';
3388 }
3389 7 $dim .= $token;
3390 }
3391 7 ▶ unless ($dim) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dim) 0 7 7
3392 0 error "expecting dimension";
3393 0 last;
3394 }
3395 7 ▶ unless ($token eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
unless ($token eq "]") 0 7 7
3396 0 error "expecting ']'";
3397 0 last;
3398 }
3399 7 push @dimensions, $dim;
3400 }
3401 13 my @subord = ($existing_typenode, [ @dimensions ]);
3402 13 my $node = [ TYPEDEF, $newtype, \@subord, annotation, $cmnt, curr_scope ];
3403 13 pushsub($symbols, $node, $in_valuetype);
3404  
3405 ▶ } elsif ($kw eq 'readonly' or $kw eq 'attribute') {
Condition100%3/3
$kw eq "readonly" or $kw eq "attribute"
l!l&&r!l&&!r
1269
MC/DC100%2/2
$kw eq "readonly" or $kw eq "attribute"
$kw eq "readonly" $kw eq "attribute"
Truth table100%3/3
A or B
A= $kw eq "readonly"B= $kw eq "attribute"
ABresult
1X1
011
000
3406 3 my $readonly = 0;
3407 3 ▶ if ($kw eq 'readonly') {
Branch: 1 branch
BranchTrueFalseTotal
if ($kw eq "readonly") 1 2 3
3408 1 ▶ if (shift(@arg) ne 'attribute') {
Branch: 1 branch
BranchTrueFalseTotal
if (shift @arg ne "attribute") 0 1 1
3409 0 error "expecting keyword 'attribute'";
3410 0 next;
3411 }
3412 1 $readonly = 1;
3413 }
3414 3 my $typename = shift @arg;
3415 3 my $type = parse_type($typename, \@arg, $symbols);
3416 3 ▶ if (! $type) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($type) 0 3 3
3417 0 error "unknown type $typename";
3418 0 next;
3419 }
3420 3 my @subord = ($readonly, $type);
3421 3 my $name = check_name(shift @arg);
3422 3 my $node = [ ATTRIBUTE, $name, \@subord, annotation, $cmnt, curr_scope ];
3423 3 pushsub($symbols, $node, $in_valuetype);
3424  
3425 } elsif (grep /\(/, @arg) { # Method declaration
3426 54 my $rettype;
3427 my @subord;
3428 54 ▶ if ($kw eq 'oneway') {
Branch: 3 branches
BranchTrueFalseTotal
if ($kw eq 'oneway') { } 5 49 54
elsif ($kw eq 'void') { } 7 42 49
elsif ($in_valuetype and $kw eq 'factory') { } 0 42 42
3429 5 ▶ if (shift(@arg) ne 'void') {
Branch: 1 branch
BranchTrueFalseTotal
if (shift @arg ne "void") 0 5 5
3430 0 error "expecting keyword 'void' after oneway";
3431 0 next;
3432 }
3433 5 $rettype = ONEWAY;
3434 } elsif ($kw eq 'void') {
3435 7 $rettype = VOID;
3436 ▶ } elsif ($in_valuetype and $kw eq 'factory') {
Condition33%1/3
$in_valuetype and $kw eq "factory"
!ll&&!rl&&r
4200
MC/DC0%0/2
$in_valuetype and $kw eq "factory"
$in_valuetype $kw eq "factory"
Truth table33%1/3
A and B
A= $in_valuetypeB= $kw eq "factory"
ABresult
0X0
100
111
3437 0 $rettype = FACTORY;
3438 } else {
3439 42 $rettype = parse_type($kw, \@arg, $symbols);
3440 42 ▶ if (! $rettype) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($rettype) 0 42 42
3441 0 error "unknown return type $kw";
3442 0 next;
3443 }
3444 }
3445 54 @subord = ($rettype);
3446 54 my $name = check_name(shift @arg, "method name");
3447 54 ▶ if (shift(@arg) ne '(') {
Branch: 2 branches
BranchTrueFalseTotal
if (shift @arg ne '(') { } 0 54 54
elsif (pop @arg ne ')') { } 0 54 54
3448 0 error "expecting opening parenthesis";
3449 0 next;
3450 } elsif (pop(@arg) ne ')') {
3451 0 error "expecting closing parenthesis";
3452 0 next;
3453 }
3454 54 my @exception_list = ();
3455 54 my $expecting_exception_list = 0;
3456 54 ▶ while (@arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (@arg) 78 53 131
3457 78 my $m = shift @arg;
3458 78 my $typename = shift @arg;
3459 78 my $pname = shift @arg;
3460 78 ▶ if ($m eq ')') {
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq ")") 1 77 78
3461 1 ▶ if ($typename ne 'raises') {
Branch: 2 branches
BranchTrueFalseTotal
if ($typename ne 'raises') { } 0 1 1
elsif ($pname ne '(') { } 0 1 1
3462 0 error "expecting keyword 'raises'";
3463 } elsif ($pname ne '(') {
3464 0 error "expecting '(' after 'raises'";
3465 } else {
3466 1 $expecting_exception_list = 1;
3467 }
3468 1 last;
3469 }
3470 77 ▶ my $pmode = ($m eq 'in' ? &IN :
Branch: 3 branches
BranchTrueFalseTotal
$m eq 'in' ? : 34 43 77
$m eq 'out' ? : 22 21 43
$m eq 'inout' ? : 21 0 21
3471 $m eq 'out' ? &OUT :
3472 $m eq 'inout' ? &INOUT : 0);
3473 77 ▶ unless ($pmode) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pmode) 0 77 77
3474 0 error("$name parameter $pname : bad mode $m (expecting 'in', 'out', or 'inout')");
3475 0 last;
3476 }
3477 77 ▶ if ($rettype == FACTORY && $pmode != IN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rettype == 41 and $pmode != 1) 0 77 77
Condition33%1/3
$rettype == 41 and $pmode != 1
!ll&&!rl&&r
7700
MC/DC0%0/2
$rettype == 41 and $pmode != 1
$rettype == 41 $pmode != 1
Truth table33%1/3
A and B
A= $rettype == 41B= $pmode != 1
ABresult
0X0
100
111
3478 0 error("$name: FACTORY parameter $pname must have mode 'in'");
3479 0 last;
3480 }
3481 77 my $ptype = find_node_i($typename, $symbols);
3482 77 ▶ if (! $ptype) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ptype) 0 77 77
3483 0 error "unknown type of parameter $pname";
3484 0 last;
3485 }
3486 77 my @param_node = ($ptype, $pname);
3487 77 push @param_node, $pmode;
3488 77 push @subord, [ @param_node ];
3489 77 ▶ if (@arg and $arg[0] eq ',') {
Branch: 1 branch
BranchTrueFalseTotal
if (@arg and $arg[0] eq ",") 46 31 77
Condition66%2/3
@arg and $arg[0] eq ","
!ll&&!rl&&r
31046
MC/DC50%1/2
@arg and $arg[0] eq ","
@arg $arg[0] eq ","
Truth table66%2/3
A and B
A= @argB= $arg[0] eq ","
ABresult
0X0
100
111
3490 46 shift @arg;
3491 }
3492 }
3493 54 my @node = (METHOD, $name, [ @subord ], annotation, $cmnt, curr_scope);
3494 54 ▶ if ($expecting_exception_list) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expecting_exception_list) 1 53 54
3495 1 ▶ while (@arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (@arg) 1 1 2
3496 1 my $exc_name = shift @arg;
3497 1 my $exc_type = find_node_i($exc_name, $symbols);
3498 1 ▶ if (! $exc_type) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $exc_type) { } 0 1 1
elsif (do { $exc_type }->[0] != 30) { } 0 1 1
3499 0 error "unknown exception $exc_name";
3500 0 last;
3501 1 } elsif (${$exc_type}[TYPE] != EXCEPTION) {
3502 0 error "cannot raise $exc_name (not an exception)";
3503 0 last;
3504 }
3505 1 push @exception_list, $exc_type;
3506 1 ▶ if (@arg and shift @arg ne ',') {
Branch: 1 branch
BranchTrueFalseTotal
if (@arg and shift @arg ne ",") 0 1 1
Condition33%1/3
@arg and shift @arg ne ","
!ll&&!rl&&r
100
MC/DC0%0/2
@arg and shift @arg ne ","
@arg shift @arg ne ","
Truth table33%1/3
A and B
A= @argB= shift @arg ne ","
ABresult
0X0
100
111
3507 0 error "expecting ',' in exception list";
3508 0 last;
3509 }
3510 }
3511 }
3512 54 ▶ if ($in_valuetype) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_valuetype) { } 0 54 54
3513 0 ▶ if (@exception_list) {
Branch: 1 branch
BranchTrueFalseTotal
if (@exception_list) 0 0 0
3514 0 error "'raises' not yet supported in valuetype methods";
3515 }
3516 } else {
3517 54 push @{$node[SUBORDINATES]}, [ @exception_list ];
3518 }
3519 54 pushsub($symbols, [ @node ], $in_valuetype);
3520  
3521 } else { # Data
3522 15 unshift @arg, $kw; # put type back into @arg
3523 15 ▶ if ($#typestack < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#typestack < 0) 0 15 15
3524 0 error "unexpected declaration";
3525 0 next;
3526 }
3527 15 ▶ if ($typestack[-1] == UNION) {
Branch: 1 branch
BranchTrueFalseTotal
if ($typestack[-1] == 27) 2 13 15
3528 # a union case may be followed by only one declaration,
3529 # i.e. each declaration must come after CASE or DEFAULT
3530 2 my $i = $#struct;
3531 2 ▶ while ($i > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i > 0) 2 0 2
3532 2 ▶ last unless $struct[$i]->[TYPE] == REMARK;
Branch: 1 branch
BranchTrueFalseTotal
unless $struct[$i][0] == 48 2 0 2
3533 0 --$i;
3534 }
3535 2 ▶ if ($i < 0 || $struct[$i]->[TYPE] != CASE && $struct[$i]->[TYPE] != DEFAULT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < 0 or $struct[$i][0] != 28 and $struct[$i][0] != 29) 0 2 2
Condition33%2/6
$i < 0 or $struct[$i][0] != 28 and $struct[$i][0] != 29
l!l&&r!l&&!r
002
$struct[$i][0] != 28 and $struct[$i][0] != 29
!ll&&!rl&&r
200
MC/DC0%0/3
$i < 0 or $struct[$i][0] != 28 and $struct[$i][0] != 29
$i < 0 $struct[$i][0] != 28 $struct[$i][0] != 29
Truth table25%1/4
A or B and C
A= $i < 0B= $struct[$i][0] != 28C= $struct[$i][0] != 29
ABCresult
1XX1
0111
00X0
0100
3536 0 error "unexpected declaration, case missing?";
3537 0 next;
3538 }
3539 }
3540 15 ▶ if (parse_members($symbols, \@arg, \@struct, $cmnt) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (parse_members($symbols, \@arg, \@struct, $cmnt) == 1) 0 15 15
3541 # end of type declaration was encountered
3542 0 my $type = pop @typestack;
3543 0 my $name = pop @namestack;
3544 0 ▶ if ($type == ANNOTATION) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == ANNOTATION()) { } 0 0 0
3545 0 push @annoDefs, [ $name, @struct ];
3546 } else {
3547 0 my $anno = pop @annostack;
3548 0 my $initial_cmnt = pop @cmntstack;
3549 0 ▶ if ($initial_cmnt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($initial_cmnt) 0 0 0
3550 0 ▶ if ($cmnt && $cmnt != $initial_cmnt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmnt and $cmnt != $initial_cmnt) 0 0 0
Condition0%0/3
$cmnt and $cmnt != $initial_cmnt
!ll&&!rl&&r
000
MC/DC0%0/2
$cmnt and $cmnt != $initial_cmnt
$cmnt $cmnt != $initial_cmnt
Truth table0%0/3
A and B
A= $cmntB= $cmnt != $initial_cmnt
ABresult
0X0
100
111
3551 0 push @{$initial_cmnt->[1]}, @{$cmnt->[1]};
3552 }
3553 0 $cmnt = $initial_cmnt;
3554 }
3555 0 my @node = ($type, $name, [ @struct ], $anno, $cmnt, curr_scope);
3556 0 push @$symbols, [ @node ];
3557 }
3558 0 @struct = ();
3559 }
3560 }
3561 }
3562 3 info("IDLtree: done with parsing $file\n");
3563 3 ▶ if ($file) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file) 3 0 3
3564 3 close $in;
3565 3 pop @infilename;
3566 3 pop @line_number;
3567 3 $currfile--;
3568 }
3569 3 ▶ if ($n_errors) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CORBA::IDLtree::n_errors) 0 3 3
3570 0 return 0;
3571 }
3572 3 ▶ bless($symbols, "CORBA::IDLtree") unless $symb;
Branch: 1 branch
BranchTrueFalseTotal
unless $symb 2 1 3
3573 3 return $symbols;
3574 }
3575  
3576 # If @{$argref} ends with ';' right off the bat then pop @{$argref} and
3577 # return success.
3578 # Otherwise read items from file and push them onto @{$argref} until ';'
3579 # is seen.
3580 # If end of file is encountered before seeing a ';' then return error,
3581 # else pop the ';' off end of @{$argref} and return success.
3582 97 ▶sub require_end_of_stmt {
Subroutine require_end_of_stmt: called CC=6 SCAR=18.2
Pod undocumented
3583 97 my $argref = shift;
3584 97 my $file = shift;
3585 97 my $stmt_terminator = ';';
3586 97 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 97 97
3587 0 $stmt_terminator = shift;
3588 }
3589 97 ▶ if ($argref->[$#$argref] eq $stmt_terminator) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$argref[$argref->$#*] eq $stmt_terminator) 88 9 97
3590 88 pop @{$argref};
3591 88 return 1;
3592 }
3593 9 my @new_items;
3594 9 ▶ while ($argref->[$#$argref] ne $stmt_terminator) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$argref[$argref->$#*] ne $stmt_terminator) 16 9 25
3595 16 ▶ last if (! (@new_items = get_items($file)));
Branch: 1 branch
BranchTrueFalseTotal
unless @new_items = get_items($file) 0 16 16
3596 16 push @{$argref}, @new_items;
3597 }
3598 9 ▶ if ($argref->[$#$argref] eq $stmt_terminator) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$argref[$argref->$#*] eq $stmt_terminator) 9 0 9
3599 9 pop @{$argref};
3600 9 return 1;
3601 }
3602 0 0;
3603 }
3604  
3605  
3606 7634 ▶sub isnode {
Subroutine isnode: called CC=7 SCAR=19.6
Pod documented
3607 7634 my $node_ref = shift;
3608  
3609 7634 ▶ ref($node_ref) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
ref $node_ref or return 0 7339 295 7634
3610 7339 ▶ ref($node_ref) eq "ARRAY" && defined($node_ref->[TYPE]) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
ref $node_ref eq "ARRAY" and defined $node_ref->[0] or return 0 7184 155 7339
Condition100%3/3
ref $node_ref eq "ARRAY" and defined $node_ref->[0]
!ll&&!rl&&r
21537184
MC/DC100%2/2
ref $node_ref eq "ARRAY" and defined $node_ref->[0]
ref $node_ref eq "ARRAY" defined $node_ref->[0]
Truth table100%3/3
A and B
A= ref $node_ref eq "ARRAY"B= defined $node_ref->[0]
ABresult
0X0
100
111
3611 7184 ▶ if ($node_ref->[TYPE] >= BOOLEAN
Branch: 1 branch
BranchTrueFalseTotal
if ($node_ref->[0] >= 1 and $node_ref->[0] < 49) 6836 348 7184
Condition66%2/3
$node_ref->[0] >= 1 and $node_ref->[0] < 49
!ll&&!rl&&r
03486836
MC/DC50%1/2
$node_ref->[0] >= 1 and $node_ref->[0] < 49
$node_ref->[0] >= 1 $node_ref->[0] < 49
Truth table66%2/3
A and B
A= $node_ref->[0] >= 1B= $node_ref->[0] < 49
ABresult
0X0
100
111
3612 && $node_ref->[TYPE] < NUMBER_OF_TYPES) {
3613 6836 ▶ if (scalar(@$node_ref) == 5) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$node_ref == 5) 0 6836 6836
3614 # We give a warning here because element count 5 could indicate
3615 # that isnode() is called on a structured member (may indicate
3616 # misuse or latent bug).
3617 0 info("isnode(" . $node_ref->[NAME] . ") : element count is 5\n"
3618 . Carp::longmess());
3619 }
3620 6836 return (scalar(@$node_ref) == 6);
3621 }
3622 # NB: The (@$node_ref == 6) means that component descriptors of
3623 # structs/unions/exceptions and parameter descriptors of methods
3624 # do not qualify as nodes.
3625 348 return 0;
3626 }
3627  
3628  
3629 0 ▶sub is_scope {
Subroutine is_scope: not called CC=5 SCAR=34.0
Pod documented
3630 0 my $thing = shift;
3631 0 my $rv = 0;
3632 0 ▶ if (isnode $thing) {
Branch: 1 branch
BranchTrueFalseTotal
if (isnode($thing)) 0 0 0
3633 0 my $type = $$thing[TYPE];
3634 0 ▶ $rv = ($type == MODULE || $type == INTERFACE || $type == VALUETYPE ||
Condition0%0/9
$type == 32 || $type == 33 || $type == 35 || $type == 43
l!l&&r!l&&!r
000
$type == 32 or $type == 33 or $type == 35
l!l&&r!l&&!r
000
$type == 32 or $type == 33
l!l&&r!l&&!r
000
MC/DC0%0/4
$type == 32 || $type == 33 || $type == 35 || $type == 43
$type == 32 $type == 33 $type == 35 $type == 43
Truth table0%0/5
A or B or C || D
A= $type == 32B= $type == 33C= $type == 35D= $type == 43
ABCDresult
1XXX1
01XX1
001X1
00011
00000
3635 $type == INCFILE);
3636 }
3637 0 $rv;
3638 }
3639  
3640  
3641 30 ▶sub is_type {
Subroutine is_type: called CC=15 SCAR=32.7
Pod undocumented
3642 30 my $thing = shift;
3643 30 ▶ if (isnode($thing)) {
Branch: 1 branch
BranchTrueFalseTotal
if (isnode($thing)) { } 13 17 30
3644 13 my $type = $thing->[TYPE];
3645 13 ▶ return $type == FIXED
Condition56%22/39
$type == 19 || $type == 20 || $type == 21 || $type == 22 || $type == 23 || $type == 24 || $type == 25 || $type == 26 || $type == 27 || $type == 33 || $type == 34 || $type == 35 || $type == 36 || $type == 37
l!l&&r!l&&!r
1300
$type == 19 or $type == 20 or $type == 21 or $type == 22 or $type == 23 or $type == 24 or $type == 25 or $type == 26 or $type == 27 or $type == 33 or $type == 34 or $type == 35 or $type == 36
l!l&&r!l&&!r
1300
$type == 19 or $type == 20 or $type == 21 or $type == 22 or $type == 23 or $type == 24 or $type == 25 or $type == 26 or $type == 27 or $type == 33 or $type == 34 or $type == 35
l!l&&r!l&&!r
1300
$type == 19 or $type == 20 or $type == 21 or $type == 22 or $type == 23 or $type == 24 or $type == 25 or $type == 26 or $type == 27 or $type == 33 or $type == 34
l!l&&r!l&&!r
1210
$type == 19 or $type == 20 or $type == 21 or $type == 22 or $type == 23 or $type == 24 or $type == 25 or $type == 26 or $type == 27 or $type == 33
l!l&&r!l&&!r
1111
$type == 19 or $type == 20 or $type == 21 or $type == 22 or $type == 23 or $type == 24 or $type == 25 or $type == 26 or $type == 27
l!l&&r!l&&!r
1012
$type == 19 or $type == 20 or $type == 21 or $type == 22 or $type == 23 or $type == 24 or $type == 25 or $type == 26
l!l&&r!l&&!r
553
$type == 19 or $type == 20 or $type == 21 or $type == 22 or $type == 23 or $type == 24 or $type == 25
l!l&&r!l&&!r
508
$type == 19 or $type == 20 or $type == 21 or $type == 22 or $type == 23 or $type == 24
l!l&&r!l&&!r
058
$type == 19 or $type == 20 or $type == 21 or $type == 22 or $type == 23
l!l&&r!l&&!r
0013
$type == 19 or $type == 20 or $type == 21 or $type == 22
l!l&&r!l&&!r
0013
$type == 19 or $type == 20 or $type == 21
l!l&&r!l&&!r
0013
$type == 19 or $type == 20
l!l&&r!l&&!r
0013
MC/DC0%0/14
$type == 19 || $type == 20 || $type == 21 || $type == 22 || $type == 23 || $type == 24 || $type == 25 || $type == 26 || $type == 27 || $type == 33 || $type == 34 || $type == 35 || $type == 36 || $type == 37
$type == 19 $type == 20 $type == 21 $type == 22 $type == 23 $type == 24 $type == 25 $type == 26 $type == 27 $type == 33 $type == 34 $type == 35 $type == 36 $type == 37
Truth table33%5/15
A or B or C or D or E or F or G or H or I or J or K or L or M || N
A= $type == 19B= $type == 20C= $type == 21D= $type == 22E= $type == 23F= $type == 24G= $type == 25H= $type == 26I= $type == 27J= $type == 33K= $type == 34L= $type == 35M= $type == 36N= $type == 37
ABCDEFGHIJKLMNresult
1XXXXXXXXXXXXX1
01XXXXXXXXXXXX1
001XXXXXXXXXXX1
0001XXXXXXXXXX1
00001XXXXXXXXX1
000001XXXXXXXX1
0000001XXXXXXX1
00000001XXXXXX1
000000001XXXXX1
0000000001XXXX1
00000000001XXX1
000000000001XX1
0000000000001X1
000000000000011
000000000000000
3646 || $type == BOUNDED_STRING
3647 || $type == BOUNDED_WSTRING
3648 || $type == SEQUENCE
3649 || $type == ENUM
3650 || $type == TYPEDEF
3651 || $type == NATIVE
3652 || $type == STRUCT
3653 || $type == UNION
3654 || $type == INTERFACE
3655 || $type == INTERFACE_FWD
3656 || $type == VALUETYPE
3657 || $type == VALUETYPE_FWD
3658 || $type == VALUETYPE_BOX;
3659 } else {
3660 17 return is_elementary_type($thing);
3661 }
3662 }
3663  
3664 # Return the names of the nodes in @scopestack as a list.
3665 243 ▶sub scope_names {
Subroutine scope_names: called CC=3 SCAR=11.1
Pod undocumented
3666 243 my @names = ();
3667 243 foreach my $noderef (@scopestack) {
3668 432 ▶ unless ($$noderef[TYPE] == INCFILE) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($noderef->[0] == 43) 432 0 432
3669 432 push @names, $$noderef[NAME];
3670 }
3671 }
3672 243 @names;
3673 }
3674  
3675  
3676 # Only push those elements which are not already in targetlist.
3677 247 ▶sub push_uniq {
Subroutine push_uniq: called CC=3 SCAR=11.0
Pod undocumented
3678 247 my ($targetlistref, @elements) = @_;
3679 247 my $element;
3680 247 foreach $element (@elements) {
3681 247 ▶ unless (grep { $_ eq $element } @$targetlistref) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$_ eq $element;} @$targetlistref) 197 50 247
3682 197 push @$targetlistref, $element;
3683 }
3684 }
3685 }
3686  
3687 # Auxiliary to find_node_i:
3688 # Find symbol named by @parts in (or below) scope $root
3689 # Return list of matching node refs (empty list if no match)
3690 # Does not check enclosing scopes!
3691 479 ▶sub find_node_i_sc {
Subroutine find_node_i_sc: called CC=27 SCAR=36.1
Pod undocumented
3692 479 my ($root, @parts) = @_;
3693  
3694 479 my ($decls, $start, $end);
3695 479 my $anc = undef;
3696 479 my $type = 0;
3697 479 $start = 0;
3698 479 ▶ if (isnode($root)) {
Branch: 1 branch
BranchTrueFalseTotal
if (isnode($root)) { } 170 309 479
3699 170 $decls = $root->[SUBORDINATES];
3700 170 $type = $root->[TYPE];
3701 170 ▶ if ($type == INTERFACE) {
Branch: 3 branches
BranchTrueFalseTotal
if ($type == 33) { } 64 106 170
elsif ($type == 35) { } 0 106 106
elsif ($type == 34) { } 14 92 106
3702 64 $anc = $decls->[0];
3703 64 $start = 2;
3704 } elsif ($type == VALUETYPE) {
3705 0 $decls = $decls->[2];
3706 } elsif ($type == INTERFACE_FWD) {
3707 14 my $full_interface = $decls;
3708 14 ▶ unless (isnode($full_interface)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (isnode($full_interface)) 0 14 14
3709 # Return the INTERFACE_FWD node only if the full interface
3710 # is not known.
3711 0 my @r = ();
3712 0 my $first = $parts[0];
3713 0 ▶ if (defined($root->[NAME]) && $root->[NAME] eq $first) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $root->[1] and $root->[1] eq $first) 0 0 0
Condition0%0/3
defined $root->[1] and $root->[1] eq $first
!ll&&!rl&&r
000
MC/DC0%0/2
defined $root->[1] and $root->[1] eq $first
defined $root->[1] $root->[1] eq $first
Truth table0%0/3
A and B
A= defined $root->[1]B= $root->[1] eq $first
ABresult
0X0
100
111
3714 0 info("find_node_i_sc($first) : Unresolved INTERFACE_FWD");
3715 0 @r = ($root);
3716 }
3717 0 return @r;
3718 }
3719 14 $decls = $full_interface->[SUBORDINATES];
3720 14 $anc = $decls->[0];
3721 14 $start = 2;
3722 }
3723 } else {
3724 309 $decls = $root;
3725 }
3726 479 $end = $#$decls;
3727 479 my $first = shift @parts;
3728 479 my @result = ();
3729 479 my $i;
3730 479 ▶ for ($i = $start; $i <= $end; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $end) 6738 479 7217
3731 6738 my $node = $decls->[$i];
3732 # !isnode($node) on the first 2 elements of INTERFACE subordinates
3733 6738 ▶ next unless (isnode $node);
Branch: 1 branch
BranchTrueFalseTotal
unless isnode($node) 384 6354 6738
3734 6354 ▶ if ($type == VALUETYPE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 35) 0 6354 6354
3735 0 ▶ next if $node->[0]; # ignore state members
Branch: 1 branch
BranchTrueFalseTotal
if $node->[0] 0 0 0
3736 0 $node = $node->[1];
3737 }
3738 6354 my $nt = $node->[TYPE];
3739 6354 ▶ unless (defined $nt) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $nt) 0 6354 6354
3740 0 error("Undefined TYPE on node: " . join(',', @$node) . Carp::longmess());
3741 0 next;
3742 }
3743 6354 ▶ next if ($nt == REMARK || $nt == METHOD || $nt == ATTRIBUTE);
Branch: 1 branch
BranchTrueFalseTotal
if $nt == 48 or $nt == 42 or $nt == 38 1010 5344 6354
Condition83%5/6
$nt == 48 or $nt == 42 or $nt == 38
l!l&&r!l&&!r
934765344
$nt == 48 or $nt == 42
l!l&&r!l&&!r
09345420
MC/DC66%2/3
$nt == 48 or $nt == 42 or $nt == 38
$nt == 48 $nt == 42 $nt == 38
Truth table75%3/4
A or B or C
A= $nt == 48B= $nt == 42C= $nt == 38
ABCresult
1XX1
01X1
0011
0000
3744 5344 my @r;
3745 5344 ▶ if ($nt == INCFILE) {
Branch: 2 branches
BranchTrueFalseTotal
if ($nt == 43) { } 1 5343 5344
elsif (defined $node->[1] and $node->[1] eq $first) { } 246 5097 5343
3746 1 @r = find_node_i_sc($node->[SUBORDINATES], $first, @parts);
3747 ▶ } elsif (defined($node->[NAME]) && $node->[NAME] eq $first) {
Condition66%2/3
defined $node->[1] and $node->[1] eq $first
!ll&&!rl&&r
05097246
MC/DC50%1/2
defined $node->[1] and $node->[1] eq $first
defined $node->[1] $node->[1] eq $first
Truth table66%2/3
A and B
A= defined $node->[1]B= $node->[1] eq $first
ABresult
0X0
100
111
3748 246 ▶ if (@parts == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@parts == 0) { } 182 64 246
3749 182 @r = ($node);
3750 182 ▶ if ($nt == INTERFACE_FWD) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nt == 34) 64 118 182
3751 # Return the full interface if it is already known.
3752 64 my $full_interface = $node->[SUBORDINATES];
3753 64 ▶ if (isnode($full_interface)) {
Branch: 1 branch
BranchTrueFalseTotal
if (isnode($full_interface)) 50 14 64
3754 50 @r = ($full_interface);
3755 }
3756 }
3757 } else {
3758 64 @r = find_node_i_sc($node, @parts);
3759 }
3760 }
3761 5344 ▶ if (@r) {
Branch: 1 branch
BranchTrueFalseTotal
if (@r) 247 5097 5344
3762 247 push_uniq(\@result, @r);
3763 }
3764 }
3765  
3766 # interfaces may inherit symbols from their ancestors
3767 479 ▶ if (defined($anc) && @parts == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $anc and @parts == 0) 78 401 479
Condition66%2/3
defined $anc and @parts == 0
!ll&&!rl&&r
401078
MC/DC50%1/2
defined $anc and @parts == 0
defined $anc @parts == 0
Truth table66%2/3
A and B
A= defined $ancB= @parts == 0
ABresult
0X0
100
111
3768 78 my @r;
3769 78 foreach (@$anc) {
3770 14 @r = find_node_i_sc($_, $first);
3771 14 ▶ if (@r) {
Branch: 1 branch
BranchTrueFalseTotal
if (@r) 0 14 14
3772 0 push_uniq(\@result, @r);
3773 }
3774 }
3775 }
3776 479 return @result;
3777 }
3778  
3779 200 ▶sub find_node_i {
Subroutine find_node_i: called CC=28 SCAR=42.9
Pod undocumented
3780 # Returns a reference to the defining node, or a type id value
3781 # if the name given is a CORBA predefined type name.
3782 # Returns 0 if the name could not be identified.
3783 200 my $name = shift;
3784 200 ▶ if ("$name" eq "") {
Branch: 1 branch
BranchTrueFalseTotal
if ("$name" eq "") 0 200 200
3785 0 Carp::cluck("IDLtree::find_node_i() called on empty name\n");
3786 0 return 0;
3787 }
3788 200 my $current_symtree_ref = shift;
3789 200 my $is_abs = 0;
3790 200 ▶ if ($name =~ /^::/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /^::/) 0 200 200
3791 0 $name =~ s/^:://;
3792 0 $is_abs = 1;
3793 }
3794 200 ▶ if ($name =~ /^CORBA::/ || $name !~ /::/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /^CORBA::/ or not $name =~ /::/) 200 0 200
Condition33%1/3
$name =~ /^CORBA::/ or not $name =~ /::/
l!l&&r!l&&!r
02000
MC/DC0%0/2
$name =~ /^CORBA::/ or not $name =~ /::/
$name =~ /^CORBA::/ not $name =~ /::/
Truth table33%1/3
A or not(B)
A= $name =~ /^CORBA::/B= not $name =~ /::/
ABresult
1X1
011
000
3795 200 my $n = $name;
3796 # this is not absolutely correct: according to the CORBA
3797 # specification IDL predefined names must not be scoped
3798 200 $n =~ s/^CORBA:://;
3799 200 my $predef_type_id = predef_type($n);
3800 200 ▶ if ($predef_type_id) {
Branch: 1 branch
BranchTrueFalseTotal
if ($predef_type_id) 94 106 200
3801 94 return $predef_type_id;
3802 }
3803 }
3804  
3805 106 ▶ if (in_annotation_def()) {
Branch: 1 branch
BranchTrueFalseTotal
if (&in_annotation_def()) 0 106 106
3806 0 ▶ if (exists $annoEnum{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $CORBA::IDLtree::annoEnum{$name}) 0 0 0
3807 0 return $name;
3808 }
3809 0 error("\@annotation " . $namestack[$#namestack] . ": unknown type $name");
3810 0 return 0;
3811 }
3812  
3813 106 my $res = undef;
3814 106 my @namecomponents = split(/::/, $name);
3815  
3816 106 ▶ unless ($is_abs) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($is_abs) 106 0 106
3817 # check "local" scope first
3818 106 my $scn = join("::", scope_names(), @namecomponents);
3819 106 $res = $findnode_cache->get($scn);
3820 106 ▶ return $res if defined $res;
Branch: 1 branch
BranchTrueFalseTotal
if defined $res 26 80 106
3821 80 my @r = find_node_i_sc($current_symtree_ref, @namecomponents);
3822 80 ▶ if (@r == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@r == 1) 13 67 80
3823 13 $res = $r[0];
3824 13 $findnode_cache->add($scn, $res);
3825 13 return $res;
3826 }
3827 }
3828  
3829 67 my @roots = ($current_symtree_ref);
3830 67 ▶ if (@prev_symroots && $prev_symroots[-1] != $current_symtree_ref) {
Branch: 1 branch
BranchTrueFalseTotal
if (@prev_symroots and $prev_symroots[-1] != $current_symtree_ref) 67 0 67
Condition33%1/3
@prev_symroots and $prev_symroots[-1] != $current_symtree_ref
!ll&&!rl&&r
0067
MC/DC0%0/2
@prev_symroots and $prev_symroots[-1] != $current_symtree_ref
@prev_symroots $prev_symroots[-1] != $current_symtree_ref
Truth table33%1/3
A and B
A= @prev_symrootsB= $prev_symroots[-1] != $current_symtree_ref
ABresult
0X0
100
111
3831 67 push @roots, $prev_symroots[-1];
3832 }
3833 67 my $root;
3834 67 foreach $root (@roots) {
3835 134 ▶ unless ($is_abs) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($is_abs) 134 0 134
3836 134 my @scopes = scope_names;
3837 134 ▶ while (@scopes) {
Branch: 1 branch
BranchTrueFalseTotal
if (@scopes) 198 2 200
3838 198 my $scn = join("::", @scopes);
3839 # try the node cache for the full name first
3840 198 my $n = join("::", $scn, $name);
3841 198 $res = $findnode_cache->get($n);
3842 198 ▶ if ($res) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res) 39 159 198
3843 39 return $res;
3844 }
3845 # find the scope
3846 159 my @sc = find_node_i_sc($root, @scopes);
3847 159 ▶ last unless @sc;
Branch: 1 branch
BranchTrueFalseTotal
unless @sc 67 92 159
3848 92 foreach (@sc) {
3849 92 my $s = $_;
3850 92 my @r = find_node_i_sc($s, @namecomponents);
3851 92 ▶ if (@r) {
Branch: 1 branch
BranchTrueFalseTotal
if (@r) 26 66 92
3852 26 ▶ if (scalar(@r) > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @r > 1) 0 26 26
3853 # remove pragmas from node list for now
3854 0 @r = grep(!is_pragma($_), @r);
3855 0 ▶ if (@r > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@r > 1) { } 0 0 0
3856 0 warn("find_node_i: find_node_i_sc(" . typeof($s)
3857 . ", $name) returns multiple matches:\n");
3858 0 foreach (@r) {
3859 0 warn "\t$_\n";
3860 }
3861 0 Carp::cluck();
3862 } else {
3863 0 warn("find_node_i($name): pragmas ignored\n");
3864 }
3865 }
3866
3867 26 $res = $r[0];
3868 26 $findnode_cache->add($n, $res);
3869 26 return $res;
3870 }
3871 }
3872 66 pop @scopes;
3873 }
3874 }
3875 # check global scope
3876 #info "find_node_i($name): checking global scope...\n";
3877 69 $res = $findnode_cache->get($name);
3878 69 ▶ last if defined $res;
Branch: 1 branch
BranchTrueFalseTotal
if defined $res 0 69 69
3879 69 my @r = find_node_i_sc($root, @namecomponents);
3880 69 ▶ if (@r) {
Branch: 1 branch
BranchTrueFalseTotal
if (@r) 0 69 69
3881 0 ▶ if (scalar(@r) > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @r > 1) 0 0 0
3882 # remove pragmas from node list for now
3883 0 @r = grep(!is_pragma($_), @r);
3884 0 ▶ if (@r > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@r > 1) { } 0 0 0
3885 0 warn("find_node_i: global find_node_i_sc("
3886 . $name . ") returns multiple matches:\n");
3887 0 foreach (@r) {
3888 0 warn("\t" . typeof($_) . "\n");
3889 }
3890 0 Carp::cluck();
3891 } else {
3892 0 warn("find_node_i($name): pragmas ignored\n");
3893 }
3894 }
3895 0 $res = $r[0];
3896 0 my $n = typeof($res, 1);
3897 0 $findnode_cache->add($n, $res);
3898 0 last;
3899 }
3900 }
3901 2 return $res;
3902 }
3903  
3904  
3905 9 ▶sub info {
Subroutine info: called CC=4 SCAR=25.8
Pod undocumented
3906 9 ▶ $verbose or return;
Branch: 1 branch
BranchTrueFalseTotal
$CORBA::IDLtree::verbose or return 0 9 9
3907 0 my $message = shift;
3908 0 ▶ if ($currfile >= 0 && $currfile < scalar(@infilename)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($currfile >= 0 and $currfile < scalar @infilename) { } 0 0 0
Condition0%0/3
$currfile >= 0 and $currfile < scalar @infilename
!ll&&!rl&&r
000
MC/DC0%0/2
$currfile >= 0 and $currfile < scalar @infilename
$currfile >= 0 $currfile < scalar @infilename
Truth table0%0/3
A and B
A= $currfile >= 0B= $currfile < scalar @infilename
ABresult
0X0
100
111
3909 0 print($infilename[$currfile] . " line " . $line_number[$currfile]
3910 . ": $message\n");
3911 } else {
3912 0 print($message . "\n");
3913 }
3914 }
3915  
3916 0 ▶sub error {
Subroutine error: not called CC=3 SCAR=24.8
Pod undocumented
3917 0 my $message = shift;
3918 0 ▶ if ($currfile >= 0 && $currfile < scalar(@infilename)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($currfile >= 0 and $currfile < scalar @infilename) { } 0 0 0
Condition0%0/3
$currfile >= 0 and $currfile < scalar @infilename
!ll&&!rl&&r
000
MC/DC0%0/2
$currfile >= 0 and $currfile < scalar @infilename
$currfile >= 0 $currfile < scalar @infilename
Truth table0%0/3
A and B
A= $currfile >= 0B= $currfile < scalar @infilename
ABresult
0X0
100
111
3919 0 warn($infilename[$currfile] . " line " . $line_number[$currfile]
3920 . ": $message\n");
3921 } else {
3922 0 warn($message . "\n");
3923 }
3924 0 $n_errors++;
3925 }
3926  
3927 0 ▶sub abort {
Subroutine abort: not called CC=2 SCAR=17.9
Pod undocumented
3928 0 my $message = shift;
3929 0 my $f = "";
3930 0 ▶ if ($currfile >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($currfile >= 0) 0 0 0
3931 0 $f = $infilename[$currfile] . " line " . $line_number[$currfile]
3932 . ": ";
3933 }
3934 0 die ($f . $message . "\n");
3935 }
3936  
3937  
3938 # From here on, it's only Useful User Utilities
3939 # (not required for IDLtree internal purposes)
3940  
3941 191 ▶sub typeof { # Returns the string of a "type descriptor" in IDL syntax
Subroutine typeof: called CC=19 SCAR=33.1
Pod documented
3942 191 my $type = shift;
3943 191 my $gen_scope = 0; # generate scope-qualified name
3944 191 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 189 2 191
3945 189 $gen_scope = shift;
3946 }
3947 191 my $rv = "";
3948 191 ▶ if (!ref($type) && ($type >= BOOLEAN && $type < NUMBER_OF_TYPES)) {
Branch: 2 branches
BranchTrueFalseTotal
if (not ref $type and ($type >= 1 and $type < 49)) { } 98 93 191
elsif (not isnode($type)) { } 0 93 93
Condition50%3/6
not ref $type and ($type >= 1 and $type < 49)
!ll&&!rl&&r
93098
$type >= 1 and $type < 49
!ll&&!rl&&r
0098
MC/DC33%1/3
not ref $type and ($type >= 1 and $type < 49)
not ref $type $type >= 1 $type < 49
Truth table50%2/4
not(A) and B and C
A= not ref $typeB= $type >= 1C= $type < 49
ABCresult
0XX0
10X0
1100
1111
3949 98 $rv = $predef_types[$type];
3950 98 ▶ if ($type <= ANY) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type <= 18) 98 0 98
3951 98 $rv =~ s/_/ /g;
3952 }
3953 98 return $rv;
3954 } elsif (! isnode($type)) {
3955 0 Carp::cluck("CORBA::IDLtree::typeof error: parameter is not a node ($type)\n");
3956 0 return "";
3957 }
3958 93 my @node = @{$type};
3959 93 my $name = $node[NAME];
3960 93 my $prefix = "";
3961 93 ▶ if ($gen_scope) {
Branch: 1 branch
BranchTrueFalseTotal
if ($gen_scope) 91 2 93
3962 91 my @tmpnode = @node;
3963 91 my @scope;
3964 91 ▶ while ((@scope = @{$tmpnode[SCOPEREF]})) {
Branch: 1 branch
BranchTrueFalseTotal
if (@scope = @{$tmpnode[5];}) 91 91 182
3965 91 ▶ last if ($scope[TYPE] == INCFILE);
Branch: 1 branch
BranchTrueFalseTotal
if $scope[0] == 43 0 91 91
3966 91 my $new_prefix = $scope[NAME] . "::";
3967 91 ▶ unless ($prefix =~ /\b$new_prefix/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($prefix =~ /\b$new_prefix/) 91 0 91
3968 91 $prefix = $new_prefix . $prefix;
3969 }
3970 91 @tmpnode = @scope;
3971 }
3972 91 ▶ if (ref $gen_scope) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $gen_scope) 91 0 91
3973 # @gen_scope contains the scope strings.
3974 # Now we can decide whether the scope prefix is needed.
3975 91 my $curr_scope = join("::", @{$gen_scope});
3976 91 ▶ if ($prefix eq "${curr_scope}::") {
Branch: 1 branch
BranchTrueFalseTotal
if ($prefix eq "${curr_scope}::") 28 63 91
3977 28 $prefix = "";
3978 }
3979 }
3980 }
3981 93 $rv = "$prefix$name";
3982 93 ▶ if ($node[TYPE] == FIXED) {
Branch: 3 branches
BranchTrueFalseTotal
if ($node[0] == 19) { } 0 93 93
elsif ($node[0] == 20 or $node[0] == 21) { } 0 93 93
elsif ($node[0] == 22) { } 8 85 93
3983 0 my @digits_and_scale = @{$node[SUBORDINATES]};
3984 0 my $digits = $digits_and_scale[0];
3985 0 my $scale = $digits_and_scale[1];
3986 0 $rv = "fixed<$digits,$scale>";
3987 ▶ } elsif ($node[TYPE] == BOUNDED_STRING ||
Condition33%1/3
$node[0] == 20 or $node[0] == 21
l!l&&r!l&&!r
0093
MC/DC0%0/2
$node[0] == 20 or $node[0] == 21
$node[0] == 20 $node[0] == 21
Truth table33%1/3
A or B
A= $node[0] == 20B= $node[0] == 21
ABresult
1X1
011
000
3988 $node[TYPE] == BOUNDED_WSTRING) {
3989 0 my $wide = "";
3990 0 ▶ if ($node[TYPE] == BOUNDED_WSTRING) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node[0] == 21) 0 0 0
3991 0 $wide = "w";
3992 }
3993 0 $rv = "${wide}string<" . $name . ">";
3994 } elsif ($node[TYPE] == SEQUENCE) {
3995 8 my $bound = $name; # NAME holds the bound
3996 8 my $eltype = typeof($node[SUBORDINATES], $gen_scope);
3997 8 $rv = 'sequence<' . $eltype;
3998 8 ▶ if ($bound) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bound) 2 6 8
3999 2 $rv .= ", $bound";
4000 }
4001 8 $rv .= '>';
4002 }
4003 93 $rv;
4004 }
4005  
4006  
4007 47 ▶sub is_a {
Subroutine is_a: called CC=10 SCAR=35.9
Pod documented
4008 # Determines whether node is of given type. Recurses through TYPEDEFs.
4009 47 my ($type, $typeid) = @_;
4010  
4011 47 ▶ unless ($type) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($type) 0 47 47
4012 0 Carp::cluck("CORBA::IDLtree::is_a: invalid input (comparing to "
4013 . typeof($typeid) . ")\n");
4014 0 return 0;
4015 }
4016 47 ▶ if (! isnode $type) {
Branch: 1 branch
BranchTrueFalseTotal
unless (isnode($type)) 44 3 47
4017 44 ▶ if ($typeid > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($typeid > 0) { } 44 0 44
4018 44 return $type == $typeid;
4019 } else {
4020 0 return typeof($type) eq $typeid;
4021 }
4022 }
4023  
4024 # check the node
4025 3 ▶ if ($typeid > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($typeid > 0) { } 3 0 3
4026 3 ▶ return 1 if $type->[TYPE] == $typeid;
Branch: 1 branch
BranchTrueFalseTotal
if $type->[0] == $typeid 3 0 3
4027 } else {
4028 0 ▶ return 1 if scoped_name($type) eq $typeid;
Branch: 1 branch
BranchTrueFalseTotal
if scoped_name($type) eq $typeid 0 0 0
4029 }
4030 0 ▶ return 0 unless $type->[TYPE] == TYPEDEF;
Branch: 1 branch
BranchTrueFalseTotal
unless $type->[0] == 24 0 0 0
4031  
4032 # we have a typedef
4033  
4034 0 my $origtype_and_dim = $type->[SUBORDINATES];
4035  
4036 # array ?
4037 0 my $dimref = $$origtype_and_dim[1];
4038 0 ▶ return 0 if $dimref && @{$dimref};
Branch: 1 branch
BranchTrueFalseTotal
if $dimref and @{$dimref;} 0 0 0
Condition0%0/3
$dimref and @{$dimref;}
!ll&&!rl&&r
000
MC/DC0%0/2
$dimref and @{$dimref;}
$dimref @{$dimref;}
Truth table0%0/3
A and B
A= $dimrefB= @{$dimref;}
ABresult
0X0
100
111
4039  
4040 # no, recursively check basetype
4041 0 return is_a($$origtype_and_dim[0], $typeid);
4042 }
4043  
4044 17 ▶sub root_type {
Subroutine root_type: called CC=5 SCAR=25.2
Pod documented
4045 # Returns the original type of a TYPEDEF, i.e. recurses through
4046 # all non-array TYPEDEFs until the original type is reached.
4047 17 my $type = shift;
4048 17 ▶ if (isnode $type and $$type[TYPE] == TYPEDEF) {
Branch: 1 branch
BranchTrueFalseTotal
if (isnode($type) and $type->[0] == 24) 0 17 17
Condition66%2/3
isnode($type) and $type->[0] == 24
!ll&&!rl&&r
1430
MC/DC0%0/2
isnode($type) and $type->[0] == 24
isnode($type) $type->[0] == 24
Truth table66%2/3
A and B
A= isnode($type)B= $type->[0] == 24
ABresult
0X0
100
111
4049 0 my($origtype, $dimref) = @{$$type[SUBORDINATES]};
4050 0 ▶ unless ($dimref && @{$dimref}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dimref and @{$dimref;}) 0 0 0
Condition0%0/3
$dimref and @{$dimref;}
!ll&&!rl&&r
000
MC/DC0%0/2
$dimref and @{$dimref;}
$dimref @{$dimref;}
Truth table0%0/3
A and B
A= $dimrefB= @{$dimref;}
ABresult
0X0
100
111
4051 0 return root_type($origtype);
4052 }
4053 }
4054 $type
4055 17 }
4056  
4057 0 ▶sub root_elem_type {
Subroutine root_elem_type: not called CC=3 SCAR=24.8
Pod undocumented
4058 # Returns the original type of a TYPEDEF, i.e. recurses through
4059 # all TYPEDEFs until the original type is reached.
4060 # Also recurses through array types taking the element type of
4061 # an array type.
4062 0 my $type = shift;
4063 0 ▶ if (isnode $type and $$type[TYPE] == TYPEDEF) {
Branch: 1 branch
BranchTrueFalseTotal
if (isnode($type) and $type->[0] == 24) 0 0 0
Condition0%0/3
isnode($type) and $type->[0] == 24
!ll&&!rl&&r
000
MC/DC0%0/2
isnode($type) and $type->[0] == 24
isnode($type) $type->[0] == 24
Truth table0%0/3
A and B
A= isnode($type)B= $type->[0] == 24
ABresult
0X0
100
111
4064 0 return root_elem_type($type->[SUBORDINATES][0]);
4065 }
4066 0 return $type;
4067 }
4068  
4069  
4070 0 ▶sub is_pragma {
Subroutine is_pragma: not called CC=5 SCAR=34.0
Pod documented
4071 0 my $type = shift;
4072 0 ▶ if (isnode $type) {
Branch: 1 branch
BranchTrueFalseTotal
if (isnode($type)) 0 0 0
4073 0 $type = $type->[TYPE];
4074 }
4075 0 ▶ return ($type == PRAGMA_PREFIX ||
Condition0%0/9
$type == 44 || $type == 45 || $type == 46 || $type == 47
l!l&&r!l&&!r
000
$type == 44 or $type == 45 or $type == 46
l!l&&r!l&&!r
000
$type == 44 or $type == 45
l!l&&r!l&&!r
000
MC/DC0%0/4
$type == 44 || $type == 45 || $type == 46 || $type == 47
$type == 44 $type == 45 $type == 46 $type == 47
Truth table0%0/5
A or B or C || D
A= $type == 44B= $type == 45C= $type == 46D= $type == 47
ABCDresult
1XXX1
01XX1
001X1
00011
00000
4076 $type == PRAGMA_VERSION ||
4077 $type == PRAGMA_ID ||
4078 $type == PRAGMA);
4079 }
4080  
4081 0 ▶sub files_included {
Subroutine files_included: not called CC=1 SCAR=6.9
Pod documented
4082 0 return $includecache->symbols()
4083 }
4084  
4085 0 ▶sub collect_includes {
Subroutine collect_includes: not called CC=6 SCAR=37.4
Pod documented
4086 0 my($symroot, $dependency_hash_ref) = @_;
4087 0 my $myname = "CORBA::IDLtree::collect_includes";
4088  
4089 0 ▶ if (! $symroot) {
Branch: 3 branches
BranchTrueFalseTotal
if (not $symroot) { } 0 0 0
elsif (not ref $symroot) { } 0 0 0
elsif (isnode($symroot)) { } 0 0 0
4090 0 warn "\n$myname: encountered empty elem (returning)\n";
4091 0 return;
4092 } elsif (not ref $symroot) {
4093 0 warn "\n$myname: incoming symroot is $symroot (returning)\n";
4094 0 return;
4095 } elsif (isnode $symroot) {
4096 0 warn "\n$myname: usage error: invoked on node (returning)\n";
4097 0 return;
4098 }
4099 0 foreach my $noderef (@{$symroot}) {
4100 0 my @node = @{$noderef};
4101 0 my $type = $node[TYPE];
4102 0 my $name = $node[NAME];
4103 0 ▶ if ($type == INCFILE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 43) 0 0 0
4104 0 $dependency_hash_ref->{$name} = 1;
4105 0 collect_includes($noderef->[SUBORDINATES], $dependency_hash_ref);
4106 }
4107 }
4108 }
4109  
4110 # For floating point notation, FORTRAN and C inspired languages support
4111 # omitting the trailing dot-zero but Ada does not.
4112 0 ▶sub append_dot_zero {
Subroutine append_dot_zero: not called CC=3 SCAR=24.8
Pod undocumented
4113 0 my $res = shift;
4114 0 my $epos = index($res, 'e');
4115 0 ▶ if ($epos < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($epos < 0) 0 0 0
4116 0 $epos = index($res, 'E');
4117 }
4118 0 ▶ if ($epos > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($epos > 0) { } 0 0 0
4119 0 $res = substr($res, 0, $epos) . ".0" . substr($res, $epos);
4120 } else {
4121 0 $res .= ".0";
4122 }
4123 0 return $res;
4124 }
4125  
4126 0 ▶sub get_numeric {
Subroutine get_numeric: not called CC=34 SCAR=70.8
Pod documented
4127 0 my $tree = shift;
4128 0 my ($value, $scoperef, $wantfloat) = @_;
4129  
4130 0 ▶ if ($value =~ /^[-+]?(?:0x)?[0-9a-f]*$/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^[-+]?(?:0x)?[0-9a-f]*$/i) 0 0 0
4131 # integer literal, convert to decimal
4132 0 ▶ if ($is64bit) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is64bit) { } 0 0 0
4133 0 my $res = eval($value);
4134 0 ▶ if ($wantfloat) {
Branch: 1 branch
BranchTrueFalseTotal
if ($wantfloat) 0 0 0
4135 0 $res = append_dot_zero($res);
4136 }
4137 0 return $res;
4138 } else {
4139 # use BigInt so that Perl won't switch to
4140 # floating point for large values
4141 0 my $v;
4142 0 ▶ if ($value =~ /^[-+]?0[0-7]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^[-+]?0[0-7]/) { } 0 0 0
4143 # Math::BigInt->new won't convert octal numbers
4144 # (and from_oct produces NaN for '0')...
4145 0 ▶ if (Math::BigInt->can('from_oct')) {
Branch: 1 branch
BranchTrueFalseTotal
if ('Math::BigInt'->can('from_oct')) { } 0 0 0
4146 0 $v = Math::BigInt->from_oct($value);
4147 } else {
4148 # older Math::BigInt versions don't have from_oct
4149 0 my @dg = (split //, $value);
4150 0 my $sg = '';
4151 0 ▶ if ($dg[0] eq '-' || $dg[0] eq '+' || $dg[0] eq '0') {
Branch: 1 branch
BranchTrueFalseTotal
if ($dg[0] eq "-" or $dg[0] eq "+" or $dg[0] eq 0) 0 0 0
Condition0%0/6
$dg[0] eq "-" or $dg[0] eq "+" or $dg[0] eq 0
l!l&&r!l&&!r
000
$dg[0] eq "-" or $dg[0] eq "+"
l!l&&r!l&&!r
000
MC/DC0%0/3
$dg[0] eq "-" or $dg[0] eq "+" or $dg[0] eq 0
$dg[0] eq "-" $dg[0] eq "+" $dg[0] eq 0
Truth table0%0/4
A or B or C
A= $dg[0] eq "-"B= $dg[0] eq "+"C= $dg[0] eq 0
ABCresult
1XX1
01X1
0011
0000
4152 0 my $c = shift @dg;
4153 0 ▶ $sg = $c if $c eq '-';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "-" 0 0 0
4154 }
4155 0 $v = Math::BigInt->new(shift @dg);
4156 0 ▶ while (@dg > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@dg > 0) 0 0 0
4157 0 my $c = shift(@dg);
4158 0 ▶ if ($c lt '0' || $c gt '7') {
Branch: 1 branch
BranchTrueFalseTotal
if ($c lt 0 or $c gt 7) 0 0 0
Condition0%0/3
$c lt 0 or $c gt 7
l!l&&r!l&&!r
000
MC/DC0%0/2
$c lt 0 or $c gt 7
$c lt 0 $c gt 7
Truth table0%0/3
A or B
A= $c lt 0B= $c gt 7
ABresult
1X1
011
000
4159 0 $v->bnan();
4160 0 last;
4161 }
4162 0 $v = $v * 8 + $c;
4163 }
4164 0 ▶ $v->bneg() if $sg eq '-';
Branch: 1 branch
BranchTrueFalseTotal
if $sg eq "-" 0 0 0
4165 }
4166 0 ▶ if ($v->is_nan()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v->is_nan) 0 0 0
4167 0 return undef;
4168 }
4169 } else {
4170 0 $v = Math::BigInt->new($value);
4171 0 ▶ if ($v->is_nan()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v->is_nan) 0 0 0
4172 0 return undef;
4173 }
4174 0 ▶ if ($wantfloat && $v !~ /\./) {
Branch: 1 branch
BranchTrueFalseTotal
if ($wantfloat and not $v =~ /\./) 0 0 0
Condition0%0/3
$wantfloat and not $v =~ /\./
!ll&&!rl&&r
000
MC/DC0%0/2
$wantfloat and not $v =~ /\./
$wantfloat not $v =~ /\./
Truth table0%0/3
A and not(B)
A= $wantfloatB= not $v =~ /\./
ABresult
0X0
100
111
4175 0 $v = append_dot_zero($v);
4176 }
4177 }
4178 0 return $v;
4179 }
4180 }
4181 0 ▶ if ($value =~ /^[-+]?(?:\d+.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^[-+]?(?:\d+.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/) 0 0 0
4182 # floating point literal
4183 0 my $res = eval($value);
4184 0 ▶ if ($wantfloat && $res !~ /\./) {
Branch: 1 branch
BranchTrueFalseTotal
if ($wantfloat and not $res =~ /\./) 0 0 0
Condition0%0/3
$wantfloat and not $res =~ /\./
!ll&&!rl&&r
000
MC/DC0%0/2
$wantfloat and not $res =~ /\./
$wantfloat not $res =~ /\./
Truth table0%0/3
A and not(B)
A= $wantfloatB= not $res =~ /\./
ABresult
0X0
100
111
4185 0 $res = append_dot_zero($res);
4186 }
4187 0 return $res;
4188 }
4189  
4190 0 ▶ if (isnode($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (isnode($value)) 0 0 0
4191 # only const node allowed here
4192 0 ▶ return undef unless $value->[TYPE] == CONST;
Branch: 1 branch
BranchTrueFalseTotal
unless $value->[0] == 31 0 0 0
4193 # constants may contain an expression which
4194 # max contain other constants
4195 0 my $t = root_type($value->[SUBORDINATES][0]);
4196 0 ▶ $wantfloat = ($t >= FLOAT && $t <= LONGDOUBLE);
Condition0%0/3
$t >= 11 && $t <= 13
!ll&&!rl&&r
000
MC/DC0%0/2
$t >= 11 && $t <= 13
$t >= 11 $t <= 13
Truth table0%0/3
A && B
A= $t >= 11B= $t <= 13
ABresult
0X0
100
111
4197 0 my $rhs_ref = $value->[SUBORDINATES][1];
4198  
4199 0 my $expr = "";
4200 0 foreach my $token (@$rhs_ref) {
4201 0 ▶ if ($token =~ /^[a-z]/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token =~ /^[a-z]/i) { } 0 0 0
4202 # hex value or constant
4203 0 my $v = get_numeric($tree, $token, $value->[SCOPEREF], $wantfloat);
4204 0 ▶ if (defined $v) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $v) { } 0 0 0
4205 0 $expr .= $v;
4206 } else {
4207 0 $expr .= " $token";
4208 }
4209 } else {
4210 0 $expr .= " $token";
4211 }
4212 }
4213 0 my $res = eval($expr);
4214 0 ▶ if ($wantfloat && $res !~ /\./) {
Branch: 1 branch
BranchTrueFalseTotal
if ($wantfloat and not $res =~ /\./) 0 0 0
Condition0%0/3
$wantfloat and not $res =~ /\./
!ll&&!rl&&r
000
MC/DC0%0/2
$wantfloat and not $res =~ /\./
$wantfloat not $res =~ /\./
Truth table0%0/3
A and not(B)
A= $wantfloatB= not $res =~ /\./
ABresult
0X0
100
111
4215 0 $res = append_dot_zero($res);
4216 }
4217 0 return $res;
4218 }
4219  
4220 0 my @expr = idlsplit($value);
4221 0 ▶ if (@expr > 1) {
Branch: 3 branches
BranchTrueFalseTotal
if (@expr > 1) { } 0 0 0
elsif ($expr[0] eq 'FALSE') { } 0 0 0
elsif ($expr[0] eq 'TRUE') { } 0 0 0
4222 # expression, construct a "pseudo const node" from it
4223 0 ▶ my $t = ($wantfloat ? &FLOAT : &LONG);
Branch: 1 branch
BranchTrueFalseTotal
$wantfloat ? : 0 0 0
4224 # &LONG in the above is probably wrong - but we get away with it.
4225 # We just need to distinguish float from non float type here.
4226 0 return get_numeric($tree, [ CONST, "expr", [$t, [ @expr ] ], 0, "", $scoperef ], $wantfloat);
4227 } elsif ($expr[0] eq 'FALSE') {
4228 0 info "CORBA::IDLtree::get_numeric returns 'false' for boolean FALSE";
4229 0 return 'false';
4230 } elsif ($expr[0] eq 'TRUE') {
4231 0 info "CORBA::IDLtree::get_numeric returns 'true' for boolean TRUE";
4232 0 return 'true';
4233 }
4234 0 my $node = find_node($tree, $value, $scoperef);
4235 0 ▶ if (isnode($node)) {
Branch: 1 branch
BranchTrueFalseTotal
if (isnode($node)) 0 0 0
4236 0 return get_numeric($tree, $node, $wantfloat);
4237 }
4238 0 Carp::cluck ("unknown symbol in expression: $value\n");
4239 0 return undef;
4240 }
4241  
4242  
4243 # Subs for finding stuff
4244  
4245 0 ▶sub find_in_current_scope { # Auxiliary to find_scope() / find_node().
Subroutine find_in_current_scope: not called CC=12 SCAR=50.5
Pod undocumented
4246 0 my $name = shift;
4247 0 my $scoperef = shift; # Expects node (of MODULE or INTERFACE)
4248 0 my $must_be_scope_node = 0;
4249 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
4250 0 $must_be_scope_node = shift;
4251 }
4252 0 ▶ return undef unless defined $scoperef->[SUBORDINATES];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $scoperef->[2] 0 0 0
4253  
4254 0 my $decls = $scoperef->[SUBORDINATES];
4255 0 my $start = 0;
4256 0 my $scopetype = $scoperef->[TYPE];
4257 0 ▶ if ($scopetype == INTERFACE) {
Branch: 2 branches
BranchTrueFalseTotal
if ($scopetype == 33) { } 0 0 0
elsif ($scopetype == 35) { } 0 0 0
4258 0 $start = 2;
4259 } elsif ($scopetype == VALUETYPE) {
4260 0 $decls = $decls->[2];
4261 }
4262 0 my $end = $#$decls;
4263 0 ▶ for (my $i = $start; $i <= $end; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $end) 0 0 0
4264 0 my $node = $decls->[$i];
4265 0 ▶ if ($scopetype == VALUETYPE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($scopetype == 35) 0 0 0
4266 0 ▶ next if $node->[0]; # ignore state members
Branch: 1 branch
BranchTrueFalseTotal
if $node->[0] 0 0 0
4267 0 $node = $node->[1];
4268 }
4269 0 ▶ if (@$node > 1 && $node->[NAME] eq $name) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$node > 1 and $node->[1] eq $name) 0 0 0
Condition0%0/3
@$node > 1 and $node->[1] eq $name
!ll&&!rl&&r
000
MC/DC0%0/2
@$node > 1 and $node->[1] eq $name
@$node > 1 $node->[1] eq $name
Truth table0%0/3
A and B
A= @$node > 1B= $node->[1] eq $name
ABresult
0X0
100
111
4270 0 ▶ if ($must_be_scope_node and not is_scope $node) {
Branch: 1 branch
BranchTrueFalseTotal
if ($must_be_scope_node and not is_scope($node)) { } 0 0 0
Condition0%0/3
$must_be_scope_node and not is_scope($node)
!ll&&!rl&&r
000
MC/DC0%0/2
$must_be_scope_node and not is_scope($node)
$must_be_scope_node not is_scope($node)
Truth table0%0/3
A and not(B)
A= $must_be_scope_nodeB= not is_scope($node)
ABresult
0X0
100
111
4271 0 warn("warning: $name also used in " .
4272 scoped_name($node) . "\n");
4273 } else {
4274 0 return $node;
4275 }
4276 }
4277 }
4278 0 undef;
4279 }
4280  
4281 sub find_scope_i; # Auxiliary to find_scope().
4282  
4283 0 ▶sub find_scope_i {
Subroutine find_scope_i: not called CC=18 SCAR=58.3
Pod undocumented
4284 0 my ($scopelist_ref, $currscope, $global_symroot) = @_;
4285 0 my @scopes = @{$scopelist_ref};
4286 # $currscope sometimes is 0 instead of undef...
4287  
4288 0 ▶ $currscope = undef unless $currscope;
Branch: 1 branch
BranchTrueFalseTotal
unless $currscope 0 0 0
4289 0 ▶ unless (defined $currscope) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $currscope) 0 0 0
4290 0 ▶ return undef unless defined $global_symroot;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $global_symroot 0 0 0
4291  
4292 # Try find it somewhere in $global_symroot.
4293 GLOBAL_SCOPES:
4294 0 foreach my $node (@$global_symroot) {
4295 0 ▶ if ($node->[TYPE] == INCFILE) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[0] == 43) { } 0 0 0
elsif (is_scope($node) and $scopes[0] eq $node->[1]) { } 0 0 0
4296 0 my $subord = $node->[SUBORDINATES];
4297 0 $currscope = find_scope_i(\@scopes, undef, $subord);
4298 0 ▶ last GLOBAL_SCOPES if $currscope;
Branch: 1 branch
BranchTrueFalseTotal
if $currscope 0 0 0
4299 ▶ } elsif (is_scope($node) && $scopes[0] eq $node->[NAME]) {
Condition0%0/3
is_scope($node) and $scopes[0] eq $node->[1]
!ll&&!rl&&r
000
MC/DC0%0/2
is_scope($node) and $scopes[0] eq $node->[1]
is_scope($node) $scopes[0] eq $node->[1]
Truth table0%0/3
A and B
A= is_scope($node)B= $scopes[0] eq $node->[1]
ABresult
0X0
100
111
4300 # It's in this scope.
4301 0 $currscope = $node;
4302 0 ▶ if (scalar(@scopes) > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @scopes > 1) { } 0 0 0
4303 # See if the further scopes match, too.
4304 0 my $subord = $node->[SUBORDINATES];
4305 0 my @sc = @scopes;
4306 0 shift @sc;
4307 0 $currscope = find_scope_i(\@sc, undef, $subord);
4308 0 ▶ if ($currscope) {
Branch: 1 branch
BranchTrueFalseTotal
if ($currscope) 0 0 0
4309 0 return $currscope;
4310 }
4311 } else {
4312 0 last;
4313 }
4314 }
4315 }
4316 0 ▶ return undef unless defined $currscope;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $currscope 0 0 0
4317 }
4318  
4319 0 ▶ if ($scopes[0] eq $$currscope[NAME]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($scopes[0] eq $currscope->[1]) 0 0 0
4320 # It's in the current scope.
4321 0 shift @scopes;
4322 0 ▶ while (@scopes) {
Branch: 1 branch
BranchTrueFalseTotal
if (@scopes) 0 0 0
4323 0 my $sought_name = shift @scopes;
4324 0 $currscope = find_in_current_scope($sought_name, $currscope, 1);
4325 0 ▶ last unless $currscope;
Branch: 1 branch
BranchTrueFalseTotal
unless $currscope 0 0 0
4326 }
4327 0 return $currscope;
4328 }
4329 # Not a direct match with current scope.
4330 # Try the scopes nested in the current scope.
4331 0 my $scope = find_in_current_scope($scopes[0], $currscope, 1);
4332 0 ▶ if ($scope) {
Branch: 1 branch
BranchTrueFalseTotal
if ($scope) 0 0 0
4333 0 shift @scopes;
4334 0 ▶ while (@scopes) {
Branch: 1 branch
BranchTrueFalseTotal
if (@scopes) 0 0 0
4335 0 my $sought_name = shift @scopes;
4336 0 $scope = find_in_current_scope($sought_name, $scope, 1);
4337 0 ▶ last unless $scope;
Branch: 1 branch
BranchTrueFalseTotal
unless $scope 0 0 0
4338 }
4339 0 return $scope;
4340 }
4341 # Still no match. Step outside and try again.
4342 0 find_scope_i($scopelist_ref, $$currscope[SCOPEREF], $global_symroot);
4343 }
4344  
4345 0 ▶sub find_scope {
Subroutine find_scope: not called CC=3 SCAR=24.8
Pod undocumented
4346 0 my $global_symroot = shift;
4347 0 my ($scopelist_ref, $currscope) = @_;
4348  
4349 0 my $scoperef = undef;
4350 0 ▶ $scoperef = find_scope_i($scopelist_ref, $currscope)
Branch: 1 branch
BranchTrueFalseTotal
if defined $currscope 0 0 0
4351 if defined $currscope;
4352  
4353 # undef as the second arg to find_scope_i means
4354 # try to find it anywhere in $global_symroot.
4355 0 ▶ $scoperef = find_scope_i($scopelist_ref, undef, $global_symroot)
Branch: 1 branch
BranchTrueFalseTotal
unless defined $scoperef 0 0 0
4356 unless defined $scoperef;
4357  
4358 0 $scoperef;
4359 }
4360  
4361 # Auxiliary to get_scope()
4362 sub get_scope_1;
4363  
4364 4 ▶sub get_scope_1 {
Subroutine get_scope_1: called CC=3 SCAR=11.0
Pod undocumented
4365 4 my ($scoperef) = @_;
4366 4 ▶ return () unless ref($scoperef);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $scoperef 2 2 4
4367 2 ▶ return () if ($scoperef->[TYPE] == INCFILE);
Branch: 1 branch
BranchTrueFalseTotal
if $scoperef->[0] == 43 0 2 2
4368 2 return (get_scope_1($scoperef->[SCOPEREF]), $scoperef->[NAME]);
4369 }
4370  
4371 # return a list of scope names leading to the given scope
4372 # (including the scope itself)
4373 2 ▶sub get_scope {
Subroutine get_scope: called CC=3 SCAR=14.2
Pod undocumented
4374 2 my $scoperef = shift;
4375 2 my @scopes = get_scope_1($scoperef);
4376 # Remove multiple consecutive mentions of the same scope.
4377 # This happens for reopened modules (the SCOPEREF of a reopening
4378 # points to the previous opening of the same module.)
4379 2 my $i;
4380 2 ▶ for ($i = 1; $i < scalar(@scopes); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @scopes) 0 2 2
4381 0 ▶ if ($scopes[$i] eq $scopes[$i - 1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($scopes[$i] eq $scopes[$i - 1]) 0 0 0
4382 0 splice(@scopes, $i, 1);
4383 0 $i--;
4384 }
4385 }
4386 2 return @scopes;
4387 }
4388  
4389 0 ▶sub find_node {
Subroutine find_node: not called CC=31 SCAR=69.0
Pod documented
4390 0 my $global_symroot = shift;
4391 0 my ($name, $scoperef, $recurse) = @_;
4392
4393 #Carp::cluck("find_node: scoperef == 0") if $scoperef==0;
4394
4395 # $scoperef is expected to be a MODULE or INTERFACE node reference
4396  
4397 0 my @components = split(/::/, $name);
4398 0 ▶ shift @components if $components[0] eq "";
Branch: 1 branch
BranchTrueFalseTotal
if $components[0] eq "" 0 0 0
4399 0 my $noderef = undef;
4400 0 ▶ if (scalar(@components) > 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @components > 1) { } 0 0 0
elsif (defined $scoperef and $scoperef != 0) { } 0 0 0
4401 0 $name = pop @components;
4402 0 $scoperef = $global_symroot->find_scope(\@components, $scoperef);
4403 0 ▶ if (defined $scoperef) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $scoperef) 0 0 0
4404 0 $noderef = find_in_current_scope($name, $scoperef);
4405 }
4406 ▶ } elsif (defined($scoperef) && $scoperef != 0) {
Condition0%0/3
defined $scoperef and $scoperef != 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $scoperef and $scoperef != 0
defined $scoperef $scoperef != 0
Truth table0%0/3
A and B
A= defined $scoperefB= $scoperef != 0
ABresult
0X0
100
111
4407 0 my $scope = $scoperef;
4408 0 ▶ while ($scope) {
Branch: 1 branch
BranchTrueFalseTotal
if ($scope) 0 0 0
4409 0 $noderef = find_in_current_scope($name, $scope);
4410 0 ▶ last if $noderef;
Branch: 1 branch
BranchTrueFalseTotal
if $noderef 0 0 0
4411 0 $scope = $$scope[SCOPEREF];
4412 }
4413 0 ▶ if ($recurse && !$noderef) {
Branch: 1 branch
BranchTrueFalseTotal
if ($recurse and not $noderef) 0 0 0
Condition0%0/3
$recurse and not $noderef
!ll&&!rl&&r
000
MC/DC0%0/2
$recurse and not $noderef
$recurse not $noderef
Truth table0%0/3
A and not(B)
A= $recurseB= not $noderef
ABresult
0X0
100
111
4414 0 my $nodetype = $scoperef->[TYPE];
4415 0 my $innernodes = $scoperef->[SUBORDINATES];
4416 0 ▶ if ($nodetype == VALUETYPE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nodetype == 35) 0 0 0
4417 0 $innernodes = $innernodes->[2];
4418 }
4419 0 foreach (@{$innernodes}) {
4420 0 my $n = $_;
4421 0 ▶ if ($nodetype == VALUETYPE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nodetype == 35) 0 0 0
4422 0 ▶ next if $n->[0]; # ignore state members
Branch: 1 branch
BranchTrueFalseTotal
if $n->[0] 0 0 0
4423 0 $n = $n->[1];
4424 }
4425 0 my $nt = $n->[TYPE];
4426 0 ▶ next unless ($nt == INCFILE || $nt == MODULE ||
Branch: 1 branch
BranchTrueFalseTotal
unless $nt == 43 or $nt == 32 or $nt == 33 or $nt == 35 0 0 0
Condition0%0/9
$nt == 43 or $nt == 32 or $nt == 33 or $nt == 35
l!l&&r!l&&!r
000
$nt == 43 or $nt == 32 or $nt == 33
l!l&&r!l&&!r
000
$nt == 43 or $nt == 32
l!l&&r!l&&!r
000
MC/DC0%0/4
$nt == 43 or $nt == 32 or $nt == 33 or $nt == 35
$nt == 43 $nt == 32 $nt == 33 $nt == 35
Truth table0%0/5
A or B or C or D
A= $nt == 43B= $nt == 32C= $nt == 33D= $nt == 35
ABCDresult
1XXX1
01XX1
001X1
00011
00000
4427 $nt == INTERFACE || $nt == VALUETYPE);
4428 0 $noderef = $global_symroot->find_node($name, $n, 1);
4429 0 ▶ last if $noderef;
Branch: 1 branch
BranchTrueFalseTotal
if $noderef 0 0 0
4430 }
4431 }
4432 } else {
4433 0 foreach (@$global_symroot) {
4434 0 ▶ next if $_->[TYPE] == REMARK;
Branch: 1 branch
BranchTrueFalseTotal
if $_->[0] == 48 0 0 0
4435 0 ▶ if ($_->[NAME] eq $name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->[1] eq $name) 0 0 0
4436 0 ▶ if ($_->[TYPE] == INTERFACE_FWD) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->[0] == 34) 0 0 0
4437 0 my $full_interface = $_->[SUBORDINATES];
4438 # Return the INTERFACE_FWD node only if the full interface
4439 # is not known.
4440 0 ▶ next if (defined($full_interface) && @{$full_interface});
Branch: 1 branch
BranchTrueFalseTotal
if defined $full_interface and @{$full_interface;} 0 0 0
Condition0%0/3
defined $full_interface and @{$full_interface;}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $full_interface and @{$full_interface;}
defined $full_interface @{$full_interface;}
Truth table0%0/3
A and B
A= defined $full_interfaceB= @{$full_interface;}
ABresult
0X0
100
111
4441 }
4442 0 return $_;
4443 }
4444 }
4445 # FIXME: This is not really correct:
4446 # If no scope is given, search in all scopes, recursively
4447 0 foreach (@$global_symroot) {
4448 0 my $nt = $_->[TYPE];
4449 0 ▶ if ($nt == INCFILE || $nt == MODULE ||
Branch: 1 branch
BranchTrueFalseTotal
if ($nt == 43 or $nt == 32 or $nt == 33 or $nt == 35) 0 0 0
Condition0%0/9
$nt == 43 or $nt == 32 or $nt == 33 or $nt == 35
l!l&&r!l&&!r
000
$nt == 43 or $nt == 32 or $nt == 33
l!l&&r!l&&!r
000
$nt == 43 or $nt == 32
l!l&&r!l&&!r
000
MC/DC0%0/4
$nt == 43 or $nt == 32 or $nt == 33 or $nt == 35
$nt == 43 $nt == 32 $nt == 33 $nt == 35
Truth table0%0/5
A or B or C or D
A= $nt == 43B= $nt == 32C= $nt == 33D= $nt == 35
ABCDresult
1XXX1
01XX1
001X1
00011
00000
4450 $nt == INTERFACE || $nt == VALUETYPE) {
4451 0 $noderef = $global_symroot->find_node($name, $_, 1);
4452 0 ▶ last if $noderef;
Branch: 1 branch
BranchTrueFalseTotal
if $noderef 0 0 0
4453 }
4454 }
4455 }
4456 0 return $noderef;
4457 }
4458  
4459 0 ▶sub scoped_name {
Subroutine scoped_name: not called CC=3 SCAR=24.8
Pod documented
4460 0 my $node = shift;
4461 0 my $scope_sep = "::";
4462 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
4463 0 $scope_sep = shift;
4464 }
4465  
4466 0 ▶ unless (isnode($node)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (isnode($node)) 0 0 0
4467 0 return "";
4468 }
4469 0 my @scopes = get_scope($node->[SCOPEREF]);
4470 0 push @scopes, $node->[NAME];
4471 0 return join($scope_sep, @scopes);
4472 }
4473  
4474  
4475 # Dump_Symbols and auxiliary subroutines
4476  
4477 # Meaning of $dsoptarg:
4478 # undef => print to stdout
4479 # not ref => print to file
4480 # ref => print to $dstext
4481 2 my $dsoptarg = undef; # by default, print to stdout
4482 2 my $dstext;
4483 2 my $dsindentlevel = 0;
4484  
4485 944 ▶sub dsemit {
Subroutine dsemit: called CC=3 SCAR=16.0
Pod undocumented
4486 944 my $str = shift;
4487 944 ▶ if (defined $dsoptarg) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $dsoptarg) { } 0 944 944
4488 0 ▶ if (ref $dsoptarg) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $dsoptarg) { } 0 0 0
4489 0 $dstext .= $str;
4490 } else {
4491 0 print DS $str;
4492 }
4493 } else {
4494 944 print $str;
4495 }
4496 }
4497  
4498 282 ▶sub dsdent {
Subroutine dsdent: called CC=2 SCAR=6.9
Pod undocumented
4499 282 dsemit(' ' x ($dsindentlevel * 3));
4500 282 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 191 91 282
4501 191 dsemit shift;
4502 }
4503 }
4504  
4505 46 ▶sub dump_comment {
Subroutine dump_comment: called CC=5 SCAR=29.9
Pod undocumented
4506 46 my $cmnt_ref = shift;
4507 46 ▶ $cmnt_ref or return;
Branch: 1 branch
BranchTrueFalseTotal
$cmnt_ref or return 0 46 46
4508 0 my @cmnt = @{$cmnt_ref->[1]};
4509 0 ▶ @cmnt or return;
Branch: 1 branch
BranchTrueFalseTotal
@cmnt or return 0 0 0
4510 0 ▶ if (scalar(@cmnt) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @cmnt == 1) 0 0 0
4511 0 my $comment = $cmnt[0];
4512 0 dsdent "// $comment\n";
4513 0 return;
4514 }
4515 # multi line comment
4516 0 dsdent "/*\n";
4517 0 foreach (@cmnt) {
4518 0 dsdent " $_\n";
4519 }
4520 0 dsdent " */\n";
4521 }
4522  
4523 2 my @dscopes; # List of scope strings; auxiliary to sub dstypeof
4524  
4525 181 ▶sub dstypeof {
Subroutine dstypeof: called CC=1 SCAR=0.0
Pod undocumented
4526 181 typeof(shift, \@dscopes);
4527 }
4528  
4529 135 ▶sub dump_symbols_internal {
Subroutine dump_symbols_internal: called CC=78 SCAR=53.4
Pod undocumented
4530 135 my $sym_array_ref = shift;
4531 135 ▶ if (! $sym_array_ref) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($sym_array_ref) 0 135 135
4532 0 warn "dump_symbols_internal: empty elem (returning)\n";
4533 0 return 0;
4534 }
4535 135 my $status = 1;
4536 135 ▶ if (not isnode $sym_array_ref) {
Branch: 1 branch
BranchTrueFalseTotal
unless (isnode($sym_array_ref)) 2 133 135
4537 2 foreach (@{$sym_array_ref}) {
4538 4 ▶ unless (dump_symbols_internal $_) {
Branch: 1 branch
BranchTrueFalseTotal
unless (dump_symbols_internal($_)) 0 4 4
4539 0 $status = 0;
4540 }
4541 }
4542 2 return $status;
4543 }
4544 133 my @node = @{$sym_array_ref};
4545 133 my $type = $node[TYPE];
4546 133 my $name = $node[NAME];
4547 133 my $subord = $node[SUBORDINATES];
4548 133 my @arg = @{$subord};
4549 133 my $i;
4550 133 ▶ if ($type == INCFILE || $type == PRAGMA_PREFIX) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 43 or $type == 44) 2 131 133
Condition100%3/3
$type == 43 or $type == 44
l!l&&r!l&&!r
11131
MC/DC100%2/2
$type == 43 or $type == 44
$type == 43 $type == 44
Truth table100%3/3
A or B
A= $type == 43B= $type == 44
ABresult
1X1
011
000
4551 2 ▶ if ($type == INCFILE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 43) { } 1 1 2
4552 1 dsemit "\#include ";
4553 1 $name =~ s@^.*/@@;
4554 } else {
4555 1 dsemit "\#pragma prefix ";
4556 }
4557 2 dsemit "\"$name\"\n\n";
4558 2 return $status;
4559 }
4560 131 ▶ if ($type == ATTRIBUTE) {
Branch: 10 branches
BranchTrueFalseTotal
if ($type == 38) { } 3 128 131
elsif ($type == 42) { } 54 74 128
elsif ($type == 35) { } 0 74 74
elsif ($type == 32 or $type == 33) { } 18 56 74
elsif ($type == 24) { } 13 43 56
elsif ($type == 31) { } 12 31 43
elsif ($type == 23) { } 3 28 31
elsif ($type == 26 or $type == 27 or $type == 30) { } 14 14 28
elsif ($type == 34) { } 14 0 14
elsif ($type == 48) { } 0 0 0
4561 3 dsdent;
4562 3 ▶ dsemit("readonly ") if ($arg[0]);
Branch: 1 branch
BranchTrueFalseTotal
if $arg[0] 1 2 3
4563 3 dsemit("attribute " . dstypeof($arg[1]) . " $name");
4564 } elsif ($type == METHOD) {
4565 54 my $t = shift @arg;
4566 54 my $rettype;
4567 54 ▶ if ($t == ONEWAY) {
Branch: 2 branches
BranchTrueFalseTotal
if ($t == 39) { } 5 49 54
elsif ($t == 40) { } 7 42 49
4568 5 $rettype = 'oneway void';
4569 } elsif ($t == VOID) {
4570 7 $rettype = 'void';
4571 } else {
4572 42 $rettype = dstypeof($t);
4573 }
4574 54 my @exc_list;
4575 54 ▶ if (@arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (@arg) 54 0 54
4576 54 my $lastarg = $arg[$#arg];
4577 54 ▶ unless (ref($lastarg) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $lastarg eq "ARRAY") 0 54 54
4578 0 die("CORBA::IDLtree::dump_symbols_internal error at METHOD "
4579 . $name . " last arg ($global_idlfile)\n");
4580 }
4581 54 my @last = @{$lastarg};
4582 54 ▶ if (scalar(@last) != 3 || ref($last[NAME])) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @last != 3 or ref $last[1]) 54 0 54
Condition33%1/3
scalar @last != 3 or ref $last[1]
l!l&&r!l&&!r
5400
MC/DC0%0/2
scalar @last != 3 or ref $last[1]
scalar @last != 3 ref $last[1]
Truth table33%1/3
A or B
A= scalar @last != 3B= ref $last[1]
ABresult
1X1
011
000
4583 54 @exc_list = @{pop @arg};
4584 }
4585 }
4586 54 dsdent($rettype . " $name (");
4587 54 ▶ if (@arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (@arg) 31 23 54
4588 31 ▶ unless ($#arg == 0) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($#arg == 0) 24 7 31
4589 24 dsemit "\n";
4590 24 $dsindentlevel += 5;
4591 }
4592 31 ▶ for ($i = 0; $i <= $#arg; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#arg) 77 31 108
4593 77 my $pnode = $arg[$i];
4594 77 my $ptype = dstypeof($$pnode[TYPE]);
4595 77 my $pname = $$pnode[NAME];
4596 77 my $m = $$pnode[SUBORDINATES];
4597 77 ▶ my $pmode = ($m == &IN ? 'in' : $m == &OUT ? 'out' : 'inout');
Branch: 2 branches
BranchTrueFalseTotal
$m == &IN ? : 34 43 77
$m == &OUT ? : 22 21 43
4598 77 ▶ dsdent unless ($#arg == 0);
Branch: 1 branch
BranchTrueFalseTotal
unless $#arg == 0 70 7 77
4599 77 dsemit "$pmode $ptype $pname";
4600 77 ▶ dsemit(",\n") if ($i < $#arg);
Branch: 1 branch
BranchTrueFalseTotal
if $i < $#arg 46 31 77
4601 }
4602 31 ▶ unless ($#arg == 0) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($#arg == 0) 24 7 31
4603 24 $dsindentlevel -= 5;
4604 }
4605 }
4606 54 dsemit ")";
4607 54 ▶ if (@exc_list) {
Branch: 1 branch
BranchTrueFalseTotal
if (@exc_list) 1 53 54
4608 1 dsemit "\n";
4609 1 $dsindentlevel++;
4610 1 dsdent " raises (";
4611 1 ▶ for ($i = 0; $i <= $#exc_list; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#exc_list) 1 1 2
4612 1 dsemit(${$exc_list[$i]}[NAME]);
4613 1 ▶ dsemit(", ") if ($i < $#exc_list);
Branch: 1 branch
BranchTrueFalseTotal
if $i < $#exc_list 0 1 1
4614 }
4615 1 dsemit ")";
4616 1 $dsindentlevel--;
4617 }
4618 } elsif ($type == VALUETYPE) {
4619 0 dsdent;
4620 0 ▶ if ($arg[0]) { # `abstract' flag
Branch: 1 branch
BranchTrueFalseTotal
if ($arg[0]) 0 0 0
4621 0 dsemit "abstract ";
4622 }
4623 0 dsemit "valuetype $name ";
4624 0 ▶ if ($arg[1]) { # ancestor info
Branch: 1 branch
BranchTrueFalseTotal
if ($arg[1]) 0 0 0
4625 0 my($truncatable, $ancestors_ref) = @{$arg[1]};
4626 0 ▶ if ($truncatable) {
Branch: 1 branch
BranchTrueFalseTotal
if ($truncatable) 0 0 0
4627 0 dsemit "truncatable ";
4628 }
4629 0 ▶ if (@{$ancestors_ref}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$ancestors_ref;}) 0 0 0
4630 0 dsemit ": ";
4631 0 my $first = 1;
4632 0 foreach (@{$ancestors_ref}) {
4633 0 ▶ if ($first) {
Branch: 1 branch
BranchTrueFalseTotal
if ($first) { } 0 0 0
4634 0 $first = 0;
4635 } else {
4636 0 dsemit ", ";
4637 }
4638 0 dsemit(dstypeof $_);
4639 }
4640 0 dsemit ' ';
4641 }
4642 }
4643 0 dsemit "{\n";
4644 0 $dsindentlevel++;
4645 0 foreach (@{$arg[2]}) {
4646 0 my ($memberkind, $member) = @$_;
4647 0 ▶ if ($memberkind) {
Branch: 1 branch
BranchTrueFalseTotal
if ($memberkind) { } 0 0 0
4648 0 my $mtype = dstypeof($member->[TYPE]);
4649 0 my $mname = $member->[NAME];
4650 0 dump_comment $member->[COMMENT];
4651 0 ▶ dsdent($memberkind == &PUBLIC ? "public" : "private");
Branch: 1 branch
BranchTrueFalseTotal
$memberkind == &PUBLIC ? : 0 0 0
4652 0 dsemit " $mtype $mname;\n";
4653 } else {
4654 0 ▶ unless (dump_symbols_internal $member) {
Branch: 1 branch
BranchTrueFalseTotal
unless (dump_symbols_internal($member)) 0 0 0
4655 0 $status = 0;
4656 }
4657 }
4658 }
4659 0 $dsindentlevel--;
4660 0 dsdent "}";
4661 ▶ } elsif ($type == MODULE || $type == INTERFACE) {
Condition100%3/3
$type == 32 or $type == 33
l!l&&r!l&&!r
21656
MC/DC100%2/2
$type == 32 or $type == 33
$type == 32 $type == 33
Truth table100%3/3
A or B
A= $type == 32B= $type == 33
ABresult
1X1
011
000
4662 18 push @dscopes, $name;
4663 18 dsdent;
4664 18 ▶ if ($type == INTERFACE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 33) 16 2 18
4665 16 ▶ if ($arg[1] == ABSTRACT) {
Branch: 2 branches
BranchTrueFalseTotal
if ($arg[1] == ABSTRACT()) { } 0 16 16
elsif ($arg[1] == LOCAL()) { } 0 16 16
4666 0 dsemit "abstract ";
4667 } elsif ($arg[1] == LOCAL) {
4668 0 dsemit "local ";
4669 }
4670 }
4671 18 dsemit($predef_types[$type] . " ");
4672 18 dsemit "$name ";
4673 18 ▶ if ($type == INTERFACE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 33) 16 2 18
4674 16 my $ancref = shift @arg;
4675 16 my @ancestors = @{$ancref};
4676 16 shift @arg; # discard the "abstract" flag
4677 16 ▶ if (@ancestors) {
Branch: 1 branch
BranchTrueFalseTotal
if (@ancestors) 5 11 16
4678 5 dsemit ": ";
4679 5 ▶ for ($i = 0; $i <= $#ancestors; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#ancestors) 6 5 11
4680 6 my @ancnode = @{$ancestors[$i]};
4681 6 dsemit $ancnode[NAME];
4682 6 ▶ dsemit(", ") if ($i < $#ancestors);
Branch: 1 branch
BranchTrueFalseTotal
if $i < $#ancestors 1 5 6
4683 }
4684 }
4685 }
4686 18 dsemit " {\n\n";
4687 18 $dsindentlevel++;
4688 18 foreach (@arg) {
4689 129 ▶ unless (dump_symbols_internal $_) {
Branch: 1 branch
BranchTrueFalseTotal
unless (dump_symbols_internal($_)) 0 129 129
4690 0 $status = 0;
4691 }
4692 }
4693 18 $dsindentlevel--;
4694 18 dsdent "}";
4695 18 pop @dscopes;
4696 } elsif ($type == TYPEDEF) {
4697 13 my $origtype = $arg[0];
4698 13 my $dimref = $arg[1];
4699 13 dsdent("typedef " . dstypeof($origtype) . " $name");
4700 13 ▶ if ($dimref and @{$dimref}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dimref and @{$dimref;}) 5 8 13
Condition66%2/3
$dimref and @{$dimref;}
!ll&&!rl&&r
085
MC/DC50%1/2
$dimref and @{$dimref;}
$dimref @{$dimref;}
Truth table66%2/3
A and B
A= $dimrefB= @{$dimref;}
ABresult
0X0
100
111
4701 5 foreach (@{$dimref}) {
4702 7 dsemit "[$_]";
4703 }
4704 }
4705 } elsif ($type == CONST) {
4706 12 dsdent("const " . dstypeof($arg[0]) . " $name = ");
4707 12 dsemit join(' ', @{$arg[1]});
4708 } elsif ($type == ENUM) {
4709 3 dsdent "enum $name { ";
4710 3 @arg = enum_literals($subord);
4711 3 ▶ if ($#arg > 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#arg > 4) 0 3 3
4712 0 $dsindentlevel += 5;
4713 0 dsemit "\n";
4714 }
4715 3 ▶ for ($i = 0; $i <= $#arg; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#arg) 12 3 15
4716 12 ▶ dsdent if ($#arg > 4);
Branch: 1 branch
BranchTrueFalseTotal
if $#arg > 4 0 12 12
4717 12 dsemit $arg[$i];
4718 12 ▶ if ($i < $#arg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $#arg) 9 3 12
4719 9 dsemit(", ");
4720 9 ▶ dsemit("\n") if ($#arg > 4);
Branch: 1 branch
BranchTrueFalseTotal
if $#arg > 4 0 9 9
4721 }
4722 }
4723 3 ▶ if ($#arg > 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#arg > 4) { } 0 3 3
4724 0 $dsindentlevel -= 5;
4725 0 dsemit "\n";
4726 0 dsdent "}";
4727 } else {
4728 3 dsemit " }";
4729 }
4730 ▶ } elsif ($type == STRUCT || $type == UNION || $type == EXCEPTION) {
Condition100%6/6
$type == 26 or $type == 27 or $type == 30
l!l&&r!l&&!r
12214
$type == 26 or $type == 27
l!l&&r!l&&!r
7516
MC/DC100%3/3
$type == 26 or $type == 27 or $type == 30
$type == 26 $type == 27 $type == 30
Truth table100%4/4
A or B or C
A= $type == 26B= $type == 27C= $type == 30
ABCresult
1XX1
01X1
0011
0000
4731 14 dsdent($predef_types[$type] . " $name");
4732 14 ▶ if ($type == UNION) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 27) 5 9 14
4733 5 dsemit(" switch (" . dstypeof(shift @arg) . ")");
4734 }
4735 14 dsemit " {\n";
4736 14 $dsindentlevel++;
4737 14 my $had_case = 0;
4738 14 ▶ while (@arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (@arg) 46 14 60
4739 46 my $node = shift @arg;
4740 46 my $type = $$node[TYPE];
4741 46 my $name = $$node[NAME];
4742 46 my $suboref = $$node[SUBORDINATES];
4743 46 dump_comment $$node[COMMENT];
4744 46 ▶ if ($type == CASE || $type == DEFAULT) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type == 28 or $type == 29) { } 17 29 46
elsif ($type == 48) { } 0 29 29
Condition100%3/3
$type == 28 or $type == 29
l!l&&r!l&&!r
16129
MC/DC100%2/2
$type == 28 or $type == 29
$type == 28 $type == 29
Truth table100%3/3
A or B
A= $type == 28B= $type == 29
ABresult
1X1
011
000
4745 17 ▶ if ($had_case) {
Branch: 1 branch
BranchTrueFalseTotal
if ($had_case) { } 12 5 17
4746 12 $dsindentlevel--;
4747 } else {
4748 5 $had_case = 1;
4749 }
4750 17 ▶ if ($type == CASE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 28) { } 16 1 17
4751 16 foreach (@{$suboref}) {
4752 18 dsdent "case $_:\n";
4753 }
4754 } else {
4755 1 dsdent "default:\n";
4756 }
4757 17 $dsindentlevel++;
4758 } elsif ($type == REMARK) {
4759 0 dump_comment [ $name, $suboref ];
4760 } else {
4761 29 foreach (@{$suboref}) {
4762 0 $name .= '[' . $_ . ']';
4763 }
4764 29 dsdent(dstypeof($type) . " $name;\n");
4765 }
4766 }
4767 14 $dsindentlevel -= $had_case + 1;
4768 14 dsdent "}";
4769 } elsif ($type == INTERFACE_FWD) {
4770 14 dsdent "interface $name";
4771 } elsif ($type == REMARK) {
4772 0 dump_comment [ $name, $subord ];
4773 0 return $status;
4774 } else {
4775 0 my $ttext;
4776 0 ▶ if (ref $type) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $type) { } 0 0 0
4777 0 $ttext = dstypeof($type);
4778 } else {
4779 0 $ttext = $type;
4780 }
4781 0 warn("Dump_Symbols: unimplemented type $ttext\n");
4782 0 $status = 0;
4783 }
4784 131 ▶ if ($status) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status) { } 131 0 131
4785 131 dsemit ";\n\n";
4786 } else {
4787 0 dsemit "\n"; # just to get a clean line ending on error
4788 }
4789 131 $status
4790 }
4791  
4792  
4793 2 ▶sub Dump_Symbols {
Subroutine Dump_Symbols: called CC=6 SCAR=28.4
Pod documented
4794 2 my $sym_array_ref = shift;
4795 2 my $output_file_name;
4796 2 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 2 2
4797 # Meaning of optional argument:
4798 # when string => filename to open and write to
4799 # when array reference => dump into dereferenced array
4800 0 $dsoptarg = shift;
4801 0 ▶ unless (ref $dsoptarg) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $dsoptarg) 0 0 0
4802 0 $output_file_name = $dsoptarg;
4803 0 ▶ unless (open(DS, ">$output_file_name")) {
Branch: 1 branch
BranchTrueFalseTotal
unless (open DS, ">$output_file_name") 0 0 0
4804 0 warn "CORBA::IDLtree::Dump_Symbols: cannot create $output_file_name\n";
4805 0 $dsoptarg = undef;
4806 0 return undef;
4807 }
4808 0 my $hfence = $output_file_name;
4809 0 $hfence =~ s/\W+/_/g;
4810 0 $hfence = "_" . uc($hfence) . "_";
4811 0 dsemit "#ifndef $hfence\n";
4812 0 dsemit "#define $hfence\n\n";
4813 }
4814 } else {
4815 2 $dsoptarg = undef;
4816 }
4817 2 $dstext = "";
4818 2 my $res = dump_symbols_internal($sym_array_ref);
4819 2 ▶ if ($output_file_name) {
Branch: 2 branches
BranchTrueFalseTotal
if ($output_file_name) { } 0 2 2
elsif ($dsoptarg) { } 0 2 2
4820 0 dsemit "#endif\n";
4821 0 close DS;
4822 } elsif ($dsoptarg) {
4823 0 @{$dsoptarg} = split(/\n/, $dstext);
4824 }
4825 2 return $res;
4826 }
4827  
4828 # End of Dump_Symbols stuff.
4829  
4830  
4831 # traverse_tree stuff.
4832  
4833 2 my $user_sub_ref = 0;
4834 2 my $traverse_includefiles = 0;
4835  
4836 sub traverse;
4837  
4838 0 ▶sub traverse {
Subroutine traverse: not called CC=11 SCAR=48.8
Pod undocumented
4839 0 my ($symroot, $scope, $inside_includefile) = @_;
4840 0 ▶ if (! $symroot) {
Branch: 3 branches
BranchTrueFalseTotal
if (not $symroot) { } 0 0 0
elsif (is_elementary_type($symroot)) { } 0 0 0
elsif (not isnode($symroot)) { } 0 0 0
4841 0 warn "\nCORBA::IDLtree::traverse: encountered empty elem (returning)\n";
4842 0 return;
4843 } elsif (is_elementary_type $symroot) {
4844 0 &{$user_sub_ref}($symroot, $scope, $inside_includefile);
4845 0 return;
4846 } elsif (not isnode $symroot) {
4847 0 foreach (@{$symroot}) {
4848 0 traverse($_, $scope, $inside_includefile);
4849 }
4850 0 return;
4851 }
4852 0 &{$user_sub_ref}($symroot, $scope, $inside_includefile);
4853 0 my @node = @{$symroot};
4854 0 my $type = $node[TYPE];
4855 0 my $name = $node[NAME];
4856 0 my $subord = $node[SUBORDINATES];
4857 0 my @arg = @{$subord};
4858 0 ▶ if ($type == &INCFILE) {
Branch: 3 branches
BranchTrueFalseTotal
if ($type == &INCFILE) { } 0 0 0
elsif ($type == 32) { } 0 0 0
elsif ($type == 33) { } 0 0 0
4859 0 ▶ traverse($subord, $scope, 1) if ($traverse_includefiles);
Branch: 1 branch
BranchTrueFalseTotal
if $traverse_includefiles 0 0 0
4860 } elsif ($type == MODULE) {
4861 0 foreach (@arg) {
4862 0 traverse($_, scoped_name($symroot), $inside_includefile);
4863 }
4864 } elsif ($type == INTERFACE) {
4865 # my @ancestors = @{$arg[0]};
4866 # if (@ancestors) {
4867 # foreach $elder (@ancestors) {
4868 # &{$user_sub_ref}($elder, $scope, $inside_includefile);
4869 # }
4870 # }
4871 0 shift @arg; # discard ancestors
4872 0 shift @arg; # discard abstract flag
4873 0 foreach (@arg) {
4874 0 traverse($_, scoped_name($symroot), $inside_includefile);
4875 }
4876 }
4877 }
4878  
4879 0 ▶sub traverse_tree {
Subroutine traverse_tree: not called CC=2 SCAR=17.9
Pod undocumented
4880 0 my $sym_array_ref = shift;
4881 0 $user_sub_ref = shift;
4882 0 $traverse_includefiles = 0;
4883 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
4884 0 $traverse_includefiles = shift;
4885 }
4886 0 traverse($sym_array_ref, "", 0);
4887 }
4888  
4889 # End of traverse_tree stuff.
4890  
4891 0 ▶sub get_scalar_default {
Subroutine get_scalar_default: not called CC=6 SCAR=37.4
Pod documented
4892 0 my ($node, $scoped) = @_;
4893  
4894 0 ▶ if (defined($comment_directives)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $comment_directives) { } 0 0 0
4895 0 return $comment_directives->get_default($node, $scoped);
4896 } else {
4897 0 my $t = root_type($node);
4898 0 ▶ if ($t == BOOLEAN) {
Branch: 3 branches
BranchTrueFalseTotal
if ($t == 1) { } 0 0 0
elsif (is_elementary_type($t)) { } 0 0 0
elsif ($t->[0] == 23) { } 0 0 0
4899 0 return "FALSE";
4900 } elsif (is_elementary_type($t)) {
4901 0 return 0;
4902 } elsif ($t->[TYPE] == ENUM) {
4903 0 my @literals = enum_literals($t->[SUBORDINATES]);
4904 0 my $v = $literals[0];
4905 0 ▶ if ($scoped) {
Branch: 1 branch
BranchTrueFalseTotal
if ($scoped) 0 0 0
4906 0 my @sc = get_scope($t);
4907 0 pop @sc;
4908 0 $v = join("::", @sc, $v);
4909 }
4910 0 return $v;
4911 } else {
4912 0 return undef;
4913 }
4914 }
4915 }
4916  
4917 0 ▶sub is_integer {
Subroutine is_integer: not called CC=7 SCAR=40.3
Pod undocumented
4918 0 my ($type) = @_;
4919 0 my $e = is_elementary_type($type, 1);
4920 0 ▶ return $e == OCTET
Condition0%0/18
$e == 2 || $e == 5 || $e == 6 || $e == 7 || $e == 8 || $e == 9 || $e == 10
l!l&&r!l&&!r
000
$e == 2 or $e == 5 or $e == 6 or $e == 7 or $e == 8 or $e == 9
l!l&&r!l&&!r
000
$e == 2 or $e == 5 or $e == 6 or $e == 7 or $e == 8
l!l&&r!l&&!r
000
$e == 2 or $e == 5 or $e == 6 or $e == 7
l!l&&r!l&&!r
000
$e == 2 or $e == 5 or $e == 6
l!l&&r!l&&!r
000
$e == 2 or $e == 5
l!l&&r!l&&!r
000
MC/DC0%0/7
$e == 2 || $e == 5 || $e == 6 || $e == 7 || $e == 8 || $e == 9 || $e == 10
$e == 2 $e == 5 $e == 6 $e == 7 $e == 8 $e == 9 $e == 10
Truth table0%0/8
A or B or C or D or E or F || G
A= $e == 2B= $e == 5C= $e == 6D= $e == 7E= $e == 8F= $e == 9G= $e == 10
ABCDEFGresult
1XXXXXX1
01XXXXX1
001XXXX1
0001XXX1
00001XX1
000001X1
00000011
00000000
4921 || $e == SHORT
4922 || $e == LONG
4923 || $e == LONGLONG
4924 || $e == USHORT
4925 || $e == ULONG
4926 || $e == ULONGLONG;
4927 }
4928  
4929 0 ▶sub find_union_case {
Subroutine find_union_case: not called CC=12 SCAR=50.5
Pod undocumented
4930 0 my ($tree, $node, $caseval) = @_;
4931  
4932 0 my $case = $caseval;
4933 0 ▶ if ($caseval =~ /::/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($caseval =~ /::/) 0 0 0
4934 0 $caseval =~ s/^.*:://;
4935 }
4936 0 ▶ return undef unless $node->[TYPE] == UNION;
Branch: 1 branch
BranchTrueFalseTotal
unless $node->[0] == 27 0 0 0
4937 0 my $int = is_integer($node->[SUBORDINATES][0]);
4938 0 my $found = 0;
4939 0 my $thecase = undef;
4940 0 my $thecase_memb = undef;
4941 0 ▶ for (my $n = 1; $n <= $#{$node->[SUBORDINATES]}; ++$n) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n <= $#{$$node[2];}) 0 0 0
4942 0 my $memb = $node->[SUBORDINATES][$n];
4943 0 ▶ next if $memb->[TYPE] == REMARK;
Branch: 1 branch
BranchTrueFalseTotal
if $memb->[0] == 48 0 0 0
4944 0 ▶ if ($memb->[TYPE] == CASE) {
Branch: 3 branches
BranchTrueFalseTotal
if ($memb->[0] == 28) { } 0 0 0
elsif ($memb->[0] == 29) { } 0 0 0
elsif ($found) { } 0 0 0
4945 0 for my $c (@{$memb->[SUBORDINATES]}) {
4946 0 ▶ my $cv = $int ? $tree->get_numeric($c) : $c;
Branch: 1 branch
BranchTrueFalseTotal
$int ? : 0 0 0
4947 0 ▶ if ($cv =~ /::/) { $cv =~ s/^.*:://; }
Branch: 1 branch
BranchTrueFalseTotal
if ($cv =~ /::/) 0 0 0
4948 0 ▶ if ($cv eq $caseval) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cv eq $caseval) 0 0 0
4949 0 $found = 1;
4950 0 $thecase = $c;
4951 0 last;
4952 }
4953 }
4954 0 $thecase_memb = $memb;
4955 } elsif ($memb->[TYPE] == DEFAULT) {
4956 # note: this assumes "default" is always the last branch
4957 0 $found = 1;
4958 0 $thecase = $case;
4959 0 $thecase_memb = $memb;
4960 } elsif ($found) {
4961 0 return ($thecase, $memb, $thecase_memb);
4962 }
4963 }
4964 0 return ($case, undef, undef);
4965 }
4966  
4967 0 ▶sub get_union_default {
Subroutine get_union_default: not called CC=16 SCAR=56.1
Pod undocumented
4968 0 my ($tree, $node) = @_;
4969  
4970 0 ▶ return undef unless $node->[TYPE] == UNION;
Branch: 1 branch
BranchTrueFalseTotal
unless $node->[0] == 27 0 0 0
4971  
4972 0 my $switcht = $node->[SUBORDINATES][0];
4973  
4974 # first try: default of discriminant type
4975 0 my $case = get_scalar_default($switcht, 1);
4976  
4977 0 my ($memb, $casememb);
4978 0 ($case, $memb, $casememb) = find_union_case($tree, $node, $case);
4979 0 ▶ if (defined($memb) || $union_default_null_allowed) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $memb or $CORBA::IDLtree::union_default_null_allowed) 0 0 0
Condition0%0/3
defined $memb or $CORBA::IDLtree::union_default_null_allowed
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $memb or $CORBA::IDLtree::union_default_null_allowed
defined $memb $CORBA::IDLtree::union_default_null_allowed
Truth table0%0/3
A or B
A= defined $membB= $CORBA::IDLtree::union_default_null_allowed
ABresult
1X1
011
000
4980 0 return ($case, $memb, $casememb);
4981 }
4982 # else...
4983 0 my $st = root_type($switcht);
4984 0 ▶ if (isnode($st) && $st->[TYPE] == ENUM) {
Branch: 1 branch
BranchTrueFalseTotal
if (isnode($st) and $st->[0] == 23) 0 0 0
Condition0%0/3
isnode($st) and $st->[0] == 23
!ll&&!rl&&r
000
MC/DC0%0/2
isnode($st) and $st->[0] == 23
isnode($st) $st->[0] == 23
Truth table0%0/3
A and B
A= isnode($st)B= $st->[0] == 23
ABresult
0X0
100
111
4985 # try each enum label until a match is found
4986 0 for my $e (enum_literals($st->[SUBORDINATES])) {
4987 0 ▶ my $el = ref($e) ? $e->[0] : $e;
Branch: 1 branch
BranchTrueFalseTotal
ref $e ? : 0 0 0
4988 0 ($el, $memb, $casememb) = find_union_case($tree, $node, $el);
4989 0 ▶ if (defined $memb) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $memb) 0 0 0
4990 0 ▶ unless ($el =~ /::/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($el =~ /::/) 0 0 0
4991 0 my @sc = CORBA::IDLtree::get_scope($st);
4992 0 pop @sc;
4993 0 $el = join("::", @sc, $el);
4994 }
4995 0 return ($el, $memb, $casememb);
4996 }
4997 }
4998 }
4999 # use the first case as fallback
5000 0 $case = undef;
5001 0 $casememb = undef;
5002 0 ▶ for (my $n = 1; $n <= $#{$node->[SUBORDINATES]}; ++$n) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n <= $#{$$node[2];}) 0 0 0
5003 0 my $memb = $node->[SUBORDINATES][$n];
5004 0 ▶ next if $memb->[TYPE] == REMARK;
Branch: 1 branch
BranchTrueFalseTotal
if $memb->[0] == 48 0 0 0
5005 0 ▶ if ($memb->[TYPE] == CASE) {
Branch: 3 branches
BranchTrueFalseTotal
if ($memb->[0] == 28) { } 0 0 0
elsif ($memb->[0] == 29) { } 0 0 0
elsif (defined $case) { } 0 0 0
5006 0 $case = $memb->[SUBORDINATES][0];
5007 0 ▶ $case = $tree->get_numeric($case) if is_integer($switcht);
Branch: 1 branch
BranchTrueFalseTotal
if is_integer($switcht) 0 0 0
5008 0 $casememb = $memb;
5009 } elsif ($memb->[TYPE] == DEFAULT) {
5010 0 $case = undef;
5011 0 $casememb = undef;
5012 0 next;
5013 } elsif (defined $case) {
5014 0 return ($case, $memb, $casememb);
5015 }
5016 }
5017 0 return undef;
5018 }
5019  
5020 =head1 AUTHOR
5021  
5022 Oliver M. Kellogg, C<< <okellogg at users.sourceforge.net> >>
5023  
5024 =head1 BUGS
5025  
5026 Please report any bugs or feature requests to C<bug-corba-idltree at rt.cpan.org>,
5027 or through the web interface at
5028 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CORBA-IDLtree>.
5029 I will be notified, and then you'll automatically be notified of progress on your
5030 bug as I make changes.
5031  
5032  
5033 =head1 SUPPORT
5034  
5035 You can find documentation for this module with the perldoc command.
5036  
5037 perldoc CORBA::IDLtree
5038  
5039  
5040 You can also look for information at:
5041  
5042 =over 4
5043  
5044 =item * RT: CPAN's request tracker (report bugs here)
5045  
5046 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=CORBA-IDLtree>
5047  
5048 =item * AnnoCPAN: Annotated CPAN documentation
5049  
5050 L<http://annocpan.org/dist/CORBA-IDLtree>
5051  
5052 =item * CPAN Ratings
5053  
5054 L<http://cpanratings.perl.org/d/CORBA-IDLtree>
5055  
5056 =item * Search CPAN
5057  
5058 L<http://search.cpan.org/dist/CORBA-IDLtree/>
5059  
5060 =back
5061  
5062  
5063 =head1 ACKNOWLEDGEMENTS
5064  
5065 Thanks to Heiko Schroeder for contributing.
5066  
5067 =head1 LICENSE AND COPYRIGHT
5068  
5069 Copyright (C) 1998-2020, Oliver M. Kellogg
5070  
5071 This program is free software; you can redistribute it and/or modify it
5072 under the same terms as Perl itself.
5073  
5074 =cut
5075  
5076 2 1;
5077  
5078 # Local Variables:
5079 # cperl-indent-level: 4
5080 # indent-tabs-mode: nil
5081 # End:
↑ Summary