| 1 | |||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||
| 3 | # Interface Definition Language (OMG IDL CORBA v3.0) | ||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||
| 5 | # C++ Language Mapping Specification, New Edition June 1999 | ||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | package CORBA::Cplusplus::LiteralVisitor; | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | our $VERSION = '0.40'; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use CORBA::C::LiteralVisitor; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use base qw(CORBA::C::LiteralVisitor); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | # needs $node->{cpp_name} (CplusplusNameVisitor) for Enum | ||||||||||||||||||||||||||||
| 19 | # builds $node->{cpp_literal} | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 22 | 0 | my $proto = shift; | |||||||||||||||||||||||||||
| 23 | 0 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||||||||||
|
Condition0%0/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||
| 24 | 0 | my $self = {}; | |||||||||||||||||||||||||||
| 25 | 0 | bless $self, $class; | |||||||||||||||||||||||||||
| 26 | 0 | my ($parser) = @_; | |||||||||||||||||||||||||||
| 27 | 0 | $self->{key} = 'cpp_literal'; | |||||||||||||||||||||||||||
| 28 | 0 | $self->{symbtab} = $parser->YYData->{symbtab}; | |||||||||||||||||||||||||||
| 29 | 0 | return $self; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub _Eval { | ||||||||||||||||||||||||||
|
Subroutine
_Eval: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||
| 33 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 34 | 0 | my ($list_expr, $type) = @_; | |||||||||||||||||||||||||||
| 35 | 0 | my $elt = pop @{$list_expr}; | |||||||||||||||||||||||||||
| 36 | 0 | ▶ | unless (ref $elt) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | $elt = $self->{symbtab}->Lookup($elt); | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | 0 | ▶ | if ( $elt->isa('BinaryOp') ) { | ||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||
| 40 | 0 | my $right = $self->_Eval($list_expr, $type); | |||||||||||||||||||||||||||
| 41 | 0 | ▶ | if ( $elt->{op} eq '>>' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$elt->{"op"} eq ">>" or $elt->{"op"} eq "<<"
MC/DC0%0/2
$elt->{"op"} eq ">>" or $elt->{"op"} eq "<<"
$elt->{"op"} eq ">>"
$elt->{"op"} eq "<<"
Truth table0%0/3
A or B
A= $elt->{"op"} eq ">>"B= $elt->{"op"} eq "<<"
| |||||||||||||||||||||||||||||
| 42 | or $elt->{op} eq '<<' ) { | ||||||||||||||||||||||||||||
| 43 | 0 | $right =~ s/[LU]+$//; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | 0 | my $left = $self->_Eval($list_expr, $type); | |||||||||||||||||||||||||||
| 46 | 0 | return '(' . $left . q{ } . $elt->{op} . q{ } . $right . ')'; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | elsif ( $elt->isa('UnaryOp') ) { | ||||||||||||||||||||||||||||
| 49 | 0 | my $right = $self->_Eval($list_expr, $type); | |||||||||||||||||||||||||||
| 50 | 0 | return $elt->{op} . $right; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | elsif ( $elt->isa('Constant') ) { | ||||||||||||||||||||||||||||
| 53 | 0 | return $elt->{cpp_name}; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | elsif ( $elt->isa('Enum') ) { | ||||||||||||||||||||||||||||
| 56 | 0 | return $elt->{cpp_name}; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | elsif ( $elt->isa('Literal') ) { | ||||||||||||||||||||||||||||
| 59 | 0 | $elt->visit($self, $type); | |||||||||||||||||||||||||||
| 60 | 0 | return $elt->{$self->{key}}; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | else { | ||||||||||||||||||||||||||||
| 63 | 0 | warn __PACKAGE__," _Eval: INTERNAL ERROR ",ref $elt,".\n"; | |||||||||||||||||||||||||||
| 64 | 0 | return undef; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | sub visitBooleanLiteral { | ||||||||||||||||||||||||||
|
Subroutine
visitBooleanLiteral: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 69 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 70 | 0 | my ($node) = @_; | |||||||||||||||||||||||||||
| 71 | 0 | ▶ | if ($node->{value} eq 'TRUE') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 0 | $node->{$self->{key}} = 'true'; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | else { | ||||||||||||||||||||||||||||
| 75 | 0 | $node->{$self->{key}} = 'false'; | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 1 | 1; | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||