File Coverage

blib/lib/RPerl/Operation/Expression/SubroutineCall/MethodCall/ConstructorCall.pm
Criterion Covered Total %
statement 43 77 55.8
branch 5 16 31.2
condition n/a
subroutine 7 9 77.7
pod n/a
total 55 102 53.9


line stmt bran cond sub pod time code
1             # [[[ HEADER ]]]
2             package RPerl::Operation::Expression::SubroutineCall::MethodCall::ConstructorCall;
3 4     4   22 use strict;
  4         7  
  4         98  
4 4     4   18 use warnings;
  4         9  
  4         79  
5 4     4   18 use RPerl::AfterSubclass;
  4         9  
  4         530  
6             our $VERSION = 0.003_000;
7              
8             # [[[ OO INHERITANCE ]]]
9 4     4   24 use parent qw(RPerl::Operation::Expression::SubroutineCall::MethodCall);
  4         8  
  4         21  
10 4     4   234 use RPerl::Operation::Expression::SubroutineCall::MethodCall;
  4         8  
  4         2344  
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 106     106   193 { my string_hashref::method $RETURN_TYPE };
  106         195  
23 106         237 ( my object $self, my string_hashref $modes) = @ARG;
24 106         297 my string_hashref $rperl_source_group = { PMC => q{} };
25 106         177 my string_hashref $rperl_source_subgroup;
26              
27             # RPerl::diag( 'in ConstructorCall->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
28              
29 106 50       331 if ( ( ref $self ) ne 'Expression_148' ) {
30 0         0 die RPerl::Parser::rperl_rule__replace(
31             'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule '
32             . ( ref $self )
33             . ' found where Expression_148 expected, dying' )
34             . "\n";
35             }
36              
37             # Expression -> WordScoped OP02_METHOD_THINARROW_NEW OPTIONAL-36 ')'
38 106         279 my object $type = $self->{children}->[0];
39 106         221 my string $thin_arrow_new_left_paren = $self->{children}->[1];
40 106         225 my object $properties_init_optional = $self->{children}->[2];
41 106         245 my string $right_paren = $self->{children}->[3];
42              
43 106         423 $rperl_source_group->{PMC} .= $type->{children}->[0] . $thin_arrow_new_left_paren;
44              
45 106 100       317 if ( exists $properties_init_optional->{children}->[0] ) {
46 3         91 $rperl_source_subgroup = $properties_init_optional->{children}->[0]->ast_to_rperl__generate($modes);
47 3         65 RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup );
48             }
49              
50 106         202 $rperl_source_group->{PMC} .= $right_paren;
51 106         391 return $rperl_source_group;
52             }
53              
54             sub ast_to_cpp__generate__CPPOPS_PERLTYPES {
55 0     0   0 { my string_hashref::method $RETURN_TYPE };
  0         0  
56 0         0 ( my object $self, my string_hashref $modes) = @ARG;
57 0         0 my string_hashref $cpp_source_group
58             = { CPP =>
59             q{// <<< RP::O::E::SC::MC::CC __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>}
60             . "\n" };
61              
62             #...
63 0         0 return $cpp_source_group;
64             }
65              
66             sub ast_to_cpp__generate__CPPOPS_CPPTYPES {
67 25     25   46 { my string_hashref::method $RETURN_TYPE };
  25         42  
68 25         55 ( my object $self, my string_hashref $modes) = @ARG;
69             # RPerl::diag( 'in ConstructorCall->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
70            
71 25         66 my string_hashref $cpp_source_group = { CPP => q{} };
72 25         46 my string_hashref $cpp_source_subgroup;
73              
74 25 50       80 if ( ( ref $self ) ne 'Expression_148' ) {
75 0         0 die RPerl::Parser::rperl_rule__replace(
76             'ERROR ECOGEASCP00, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule ' . ( ref $self ) . ' found where Expression_148 expected, dying' ) . "\n";
77             }
78              
79             # Expression -> WordScoped OP02_METHOD_THINARROW_NEW OPTIONAL-36 ')'
80 25         102 my object $type = $self->{children}->[0]->{children}->[0];
81 25         457 $type = RPerl::Generator::type_convert_perl_to_cpp($type, 0); # $pointerify_classes = 0
82 25         57 my object $properties_init_optional = $self->{children}->[2];
83              
84 25         59 $cpp_source_group->{CPP} .= 'new ' . $type;
85              
86 25 50       72 if ( exists $properties_init_optional->{children}->[0] ) {
87 0         0 $properties_init_optional = $properties_init_optional->{children}->[0]; # unwrap hashref object
88             # RPerl::diag( 'in ConstructorCall->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have unwrapped $properties_init_optional = ' . "\n" . RPerl::Parser::rperl_ast__dump($properties_init_optional) . "\n" );
89              
90 0         0 my object $property_0 = $properties_init_optional->{children}->[1];
91             # RPerl::diag( 'in ConstructorCall->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $property_0 = ' . "\n" . RPerl::Parser::rperl_ast__dump($property_0) . "\n" );
92              
93 0 0       0 if ( ( ref $property_0 ) ne 'HashEntry_218' ) {
94 0         0 die RPerl::Parser::rperl_rule__replace(
95             'ERROR ECOGEASCP36, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule ' . ( ref $property_0 ) . ' found where HashEntry_218 expected, object property value initialization hashref must contain normal key/value pairs only, dying' ) . "\n";
96             }
97              
98 0         0 $cpp_source_subgroup = $self->ast_to_cpp__generate__CPPOPS_CPPTYPES__property_init($modes, $property_0);
99 0         0 RPerl::diag( 'in ConstructorCall->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $cpp_source_subgroup from $property_0 = ' . "\n" . RPerl::Parser::rperl_ast__dump($cpp_source_subgroup) . "\n" );
100 0         0 die 'TMP DEBUG';
101              
102             # START HERE: generate C++ for property 0, add foreach loop to handle remaining properties, copy CPPOPS_CPPTYPES property init semantics to PERLOPS_PERLTYPES mode above, create passing & failing tests
103             # START HERE: generate C++ for property 0, add foreach loop to handle remaining properties, copy CPPOPS_CPPTYPES property init semantics to PERLOPS_PERLTYPES mode above, create passing & failing tests
104             # START HERE: generate C++ for property 0, add foreach loop to handle remaining properties, copy CPPOPS_CPPTYPES property init semantics to PERLOPS_PERLTYPES mode above, create passing & failing tests
105             }
106 25         98 return $cpp_source_group;
107             }
108              
109              
110             sub ast_to_cpp__generate__CPPOPS_CPPTYPES__property_init {
111 0     0     { my string_hashref::method $RETURN_TYPE };
  0            
112 0           ( my object $self, my string_hashref $modes, my object $property ) = @ARG;
113             # RPerl::diag( 'in ConstructorCall->ast_to_cpp__generate__CPPOPS_CPPTYPES__property_init(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
114             # RPerl::diag( 'in ConstructorCall->ast_to_cpp__generate__CPPOPS_CPPTYPES__property_init(), received $property = ' . "\n" . RPerl::Parser::rperl_ast__dump($property) . "\n" );
115            
116 0           my string_hashref $cpp_source_group = { CPP_name => q{}, CPP_value => q{} };
117 0           my string_hashref $cpp_source_subgroup;
118              
119 0           my object $property_name = $property->{children}->[0];
120 0           my object $property_type_inner_optional = $property->{children}->[2];
121 0           my object $property_value = $property->{children}->[3];
122              
123 0 0         if ( ( ref $property_name ) ne 'VarOrLitOrOpStrOrWord_245' ) {
124 0           die RPerl::Parser::rperl_rule__replace(
125             'ERROR ECOGEASCP36, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule ' . ( ref $property_name ) . ' found where VarOrLitOrOpStrOrWord_245 expected, object property value initialization hashref must contain normal key/value pairs only, dying' ) . "\n";
126             }
127              
128 0           $property_name = $property_name->{children}->[0]; # unwrap OpStringOrWord_272 from VarOrLitOrOpStrOrWord_245
129 0 0         if ( ( ref $property_name ) ne 'OpStringOrWord_272' ) {
130 0           die RPerl::Parser::rperl_rule__replace(
131             'ERROR ECOGEASCP37, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule ' . ( ref $property_name ) . ' found where OpStringOrWord_272 expected, object property value initialization hashref must contain bareword keys only, dying' ) . "\n";
132             }
133              
134 0           $property_name = $property_name->{children}->[0]; # unwrap bareword from OpStringOrWord_272
135              
136 0 0         if ( exists $property_type_inner_optional->{children}->[0] ) {
137 0           die RPerl::Parser::rperl_rule__replace(
138             'ERROR ECOGEASCP38, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Object property initialization, hashref entry for property name ' . q{'} . $property_name . q{'} . ' has inner type when it should have no inner type, dying' ) . "\n";
139             }
140              
141 0           $cpp_source_group->{CPP_name} = $property_name;
142              
143 0           $cpp_source_subgroup = $property_value->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes);
144 0           $cpp_source_group->{CPP_value} = $cpp_source_subgroup->{CPP};
145 0           return $cpp_source_group;
146             }
147              
148             1; # end of class