File Coverage

blib/lib/RPerl/Operation/Expression/Operator/String/Concatenate.pm
Criterion Covered Total %
statement 50 58 86.2
branch 7 12 58.3
condition 7 11 63.6
subroutine 7 8 87.5
pod n/a
total 71 89 79.7


line stmt bran cond sub pod time code
1             # [[[ HEADER ]]]
2             package RPerl::Operation::Expression::Operator::String::Concatenate;
3 4     4   23 use strict;
  4         8  
  4         99  
4 4     4   20 use warnings;
  4         7  
  4         80  
5 4     4   18 use RPerl::AfterSubclass;
  4         8  
  4         532  
6             our $VERSION = 0.002_100;
7              
8             # [[[ OO INHERITANCE ]]]
9 4     4   25 use parent qw(RPerl::Operation::Expression::Operator::String);
  4         7  
  4         20  
10 4     4   199 use RPerl::Operation::Expression::Operator::String;
  4         9  
  4         1711  
11              
12             # [[[ CRITICS ]]]
13             ## no critic qw(ProhibitUselessNoCritic ProhibitMagicNumbers RequireCheckedSyscalls) # USER DEFAULT 1: allow numeric values & print operator
14             ## no critic qw(RequireInterpolationOfMetachars) # USER DEFAULT 2: allow single-quoted control characters & sigils
15              
16             # [[[ OO PROPERTIES ]]]
17             our hashref $properties = {};
18              
19             # [[[ SUBROUTINES & OO METHODS ]]]
20              
21             sub ast_to_rperl__generate {
22 170     170   371 { my string_hashref::method $RETURN_TYPE };
  170         371  
23 170         558 ( my object $self, my string_hashref $modes) = @ARG;
24 170         577 my string_hashref $rperl_source_group = { PMC => q{} };
25              
26             # RPerl::diag( 'in Operator::String::Concatenate->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
27              
28 170         410 my string $self_class = ref $self;
29 170 50       555 if ( $self_class eq 'Operator_108' ) { # Operator -> SubExpression OP08_STRING_CAT SubExpression
30 170         3558 my string_hashref $rperl_source_subgroup = $self->{children}->[0]->ast_to_rperl__generate($modes);
31 170         3723 RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup );
32 170         619 $rperl_source_group->{PMC} .= q{ } . $self->{children}->[1] . q{ };
33 170         3628 $rperl_source_subgroup = $self->{children}->[2]->ast_to_rperl__generate($modes);
34 170         3200 RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup );
35             }
36             else {
37 0         0 die RPerl::Parser::rperl_rule__replace(
38             'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule '
39             . $self_class
40             . ' found where Operator_108 expected, dying' )
41             . "\n";
42             }
43 170         782 return $rperl_source_group;
44             }
45              
46             sub ast_to_cpp__generate__CPPOPS_PERLTYPES {
47 0     0   0 { my string_hashref::method $RETURN_TYPE };
  0         0  
48 0         0 ( my object $self, my string_hashref $modes) = @ARG;
49 0         0 my string_hashref $cpp_source_group
50             = {
51             CPP => q{// <<< RP::O::E::O::S::C __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>}
52             . "\n"
53             };
54              
55             #...
56 0         0 return $cpp_source_group;
57             }
58              
59             sub ast_to_cpp__generate__CPPOPS_CPPTYPES {
60 22     22   46 { my string_hashref::method $RETURN_TYPE };
  22         43  
61 22         58 ( my object $self, my string_hashref $modes) = @ARG;
62 22         74 my string_hashref $cpp_source_group = { CPP => q{} };
63              
64             # RPerl::diag( 'in Operator::String::Concatenate->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
65              
66             # save to stack of saved flags, when needed
67 22 100 66     128 if ((exists $modes->{_inside_cat_operator}) and (defined $modes->{_inside_cat_operator})) {
68 1 50 33     8 if ((not exists $modes->{_inside_cat_operator_saved}) or (not defined $modes->{_inside_cat_operator_saved})) {
69 1         21 $modes->{_inside_cat_operator_saved} = [];
70             }
71 1         3 push @{$modes->{_inside_cat_operator_saved}}, $modes->{_inside_cat_operator};
  1         5  
72             }
73 22         95 $modes->{_inside_cat_operator} = 1;
74              
75 22         49 my string $self_class = ref $self;
76 22 50       73 if ( $self_class eq 'Operator_108' ) { # Operator -> SubExpression OP08_STRING_CAT SubExpression
77 22         603 my string_hashref $cpp_source_subgroup = $self->{children}->[0]->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes);
78 22         509 RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup );
79 22         51 $cpp_source_group->{CPP} .= ' + ';
80 22         549 $cpp_source_subgroup = $self->{children}->[2]->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes);
81 22         530 RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup );
82             }
83             else {
84 0         0 die RPerl::Parser::rperl_rule__replace(
85             'ERROR ECOGEASCP00, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule '
86             . $self_class
87             . ' found where Operator_108 expected, dying' )
88             . "\n";
89             }
90              
91             # restore from stack of saved flags, when needed
92 22         68 delete $modes->{_inside_cat_operator};
93 22 50 66     101 if ((exists $modes->{_inside_cat_operator_saved}) and (defined $modes->{_inside_cat_operator_saved}) and (scalar $modes->{_inside_cat_operator_saved})) {
      100        
94 2         4 $modes->{_inside_cat_operator} = pop @{$modes->{_inside_cat_operator_saved}};
  2         6  
95 2 50       6 if (not scalar $modes->{_inside_cat_operator_saved}) { delete $modes->{_inside_cat_operator_saved}; }
  0         0  
96             }
97 22         132 return $cpp_source_group;
98             }
99              
100             1; # end of class