File Coverage

blib/lib/RPerl/Operation/Expression/SubExpression/Variable/Retrieval.pm
Criterion Covered Total %
statement 64 114 56.1
branch 19 60 31.6
condition n/a
subroutine 7 8 87.5
pod n/a
total 90 182 49.4


line stmt bran cond sub pod time code
1             # [[[ HEADER ]]]
2             package RPerl::Operation::Expression::SubExpression::Variable::Retrieval;
3 3     3   21 use strict;
  3         8  
  3         78  
4 3     3   15 use warnings;
  3         7  
  3         69  
5 3     3   14 use RPerl::AfterSubclass;
  3         9  
  3         448  
6             our $VERSION = 0.004_000;
7              
8             # [[[ OO INHERITANCE ]]]
9 3     3   21 use parent qw(RPerl::Operation::Expression::SubExpression);
  3         7  
  3         15  
10 3     3   184 use RPerl::Operation::Expression::SubExpression;
  3         8  
  3         3271  
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 158     158   349 { my string_hashref::method $RETURN_TYPE };
  158         305  
23 158         369 ( my object $self, my string_hashref $modes) = @ARG;
24 158         447 my string_hashref $rperl_source_group = { PMC => q{} };
25              
26             # RPerl::diag( 'in Variable::Retrieval->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
27              
28 158         366 my string $self_class = ref $self;
29 158 100       587 if ( $self_class eq 'VariableRetrieval_192' ) { # VariableRetrieval -> OP02_ARRAY_THINARROW SubExpression ']'
    100          
    50          
30 77         259 my string $arrow_left_bracket = $self->{children}->[0];
31 77         181 my object $subexpression = $self->{children}->[1];
32 77         177 my string $right_bracket = $self->{children}->[2];
33              
34 77         218 $rperl_source_group->{PMC} .= $arrow_left_bracket . q{ };
35 77         1531 my string_hashref $rperl_source_subgroup = $subexpression->ast_to_rperl__generate($modes);
36 77         1680 RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup );
37 77         251 $rperl_source_group->{PMC} .= q{ } . $right_bracket;
38             }
39             elsif ( $self_class eq 'VariableRetrieval_193' ) { # VariableRetrieval -> OP02_HASH_THINARROW SubExpression '}'
40 3         38 my string $arrow_left_brace = $self->{children}->[0];
41 3         13 my object $subexpression = $self->{children}->[1];
42 3         10 my string $right_brace = $self->{children}->[2];
43              
44 3         13 $rperl_source_group->{PMC} .= $arrow_left_brace . q{ };
45 3         72 my string_hashref $rperl_source_subgroup = $subexpression->ast_to_rperl__generate($modes);
46 3         69 RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup );
47 3         12 $rperl_source_group->{PMC} .= q{ } . $right_brace;
48             }
49             elsif ( $self_class eq 'VariableRetrieval_194' ) { # VariableRetrieval -> OP02_HASH_THINARROW WORD '}'
50 78         234 my string $arrow_left_brace = $self->{children}->[0];
51 78         162 my string $word = $self->{children}->[1];
52 78         184 my string $right_brace = $self->{children}->[2];
53              
54 78         241 $rperl_source_group->{PMC} .= $arrow_left_brace . q{ } . $word . q{ } . $right_brace;
55             }
56             else {
57 0         0 die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule '
58             . ($self_class)
59             . ' found where VariableRetrieval_192, VariableRetrieval_192, or VariableRetrieval_192 expected, dying' )
60             . "\n";
61             }
62 158         753 return $rperl_source_group;
63             }
64              
65             sub ast_to_cpp__generate__CPPOPS_PERLTYPES {
66 0     0   0 { my string_hashref::method $RETURN_TYPE };
  0         0  
67 0         0 ( my object $self, my string_hashref $modes) = @ARG;
68 0         0 my string_hashref $cpp_source_group = { CPP => q{// <<< RP::O::E::SE::V::R __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>} . "\n" };
69              
70             #...
71 0         0 return $cpp_source_group;
72             }
73              
74             sub ast_to_cpp__generate__CPPOPS_CPPTYPES {
75 32     32   56 { my string_hashref::method $RETURN_TYPE };
  32         51  
76 32         73 ( my object $self, my string $variable_symbol, my string $base_type, my string_hashref $modes) = @ARG;
77 32         80 my string_hashref $cpp_source_group = { CPP => q{} };
78              
79             # RPerl::diag( 'in Variable::Retrieval->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
80              
81 32         59 my string $self_class = ref $self;
82 32         57 my string $subtype;
83 32 100       124 if ( $self_class eq 'VariableRetrieval_192' ) { # VariableRetrieval -> OP02_ARRAY_THINARROW SubExpression ']'
    50          
    50          
84 9         38 my object $subexpression = $self->{children}->[1];
85 9 50       42 if ( $base_type =~ /_arrayref$/ ) { # array
    0          
    0          
    0          
86 9         26 $subtype = substr $base_type, 0, ( ( length $base_type ) - 9 ); # strip trailing '_arrayref'
87 9 100       50 if ( exists $rperlnamespaces_generated::RPERL->{ $subtype . '::' } ) {
88 3 50       13 if ( $subtype eq 'arrayref' ) { # arrayref of arrayrefs
    50          
    50          
89 0         0 die 'NEED TEST & IMPLEMENT!!!';
90             }
91             elsif ( $subtype eq 'hashref' ) { # arrayref of hashrefs
92 0         0 die 'NEED TEST & IMPLEMENT!!!';
93             }
94             elsif ( $subtype =~ /sse_number_pair$/xms ) { # arrayref of SSE number pairs
95 0         0 die 'NEED TEST & IMPLEMENT!!!';
96             }
97             else { # arrayref of scalars
98 3         7 $cpp_source_group->{CPP} .= '[';
99 3         60 my string_hashref $cpp_source_subgroup = $subexpression->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes);
100 3         55 RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup );
101 3         11 $cpp_source_group->{CPP} .= ']';
102             }
103             }
104             else { # arrayref of user-defined data types (objects)
105 6         15 $cpp_source_group->{CPP} .= '[';
106 6         127 my string_hashref $cpp_source_subgroup = $subexpression->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes);
107 6         121 RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup );
108 6         21 $cpp_source_group->{CPP} .= ']';
109             }
110             }
111             elsif ( $base_type eq 'sse_number_pair' ) { # SSE 2-element array
112 0         0 $cpp_source_group->{CPP} .= '[';
113 0         0 my string_hashref $cpp_source_subgroup = $subexpression->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes);
114 0         0 RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup );
115 0         0 $cpp_source_group->{CPP} .= ']';
116             }
117             elsif ( $base_type =~ /_hashref$/ ) { # hash
118 0         0 die 'ERROR ECOGEASCPxd, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Variable retrieval, can not use arrayref retrieval on hashref type ' . $base_type . ', dying' . "\n";
119             }
120             elsif ( exists $rperlnamespaces_generated::RPERL->{ $base_type . '::' } ) { # scalar
121 0         0 die 'ERROR ECOGEASCPxd, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Variable retrieval, can not use arrayref retrieval on scalar type ' . $base_type . ', dying' . "\n";
122             }
123             else { # user-defined type AKA class
124 0         0 die 'ERROR ECOGEASCPxd, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Variable retrieval, can not use arrayref retrieval on object of user-defined class ' . $base_type . ', dying' . "\n";
125             }
126             }
127             elsif ( $self_class eq 'VariableRetrieval_193' ) { # VariableRetrieval -> OP02_HASH_THINARROW SubExpression '}'
128 0         0 my object $subexpression = $self->{children}->[1];
129 0 0       0 if ( $base_type =~ /_arrayref$/ ) { # array
    0          
    0          
    0          
130 0         0 die 'ERROR ECOGEASCPxd, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Variable retrieval, can not use hashref retrieval on arrayref type ' . $base_type . ', dying' . "\n";
131             }
132             elsif ( $base_type eq 'sse_number_pair' ) {
133 0         0 die 'ERROR ECOGEASCPxd, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Variable retrieval, can not use hashref retrieval on SSE type ' . $base_type . ', dying' . "\n";
134             }
135             elsif ( $base_type =~ /_hashref$/ ) { # hash
136 0         0 $subtype = substr $base_type, 0, ( ( length $base_type ) - 8 ); # strip trailing '_hashref'
137 0 0       0 if ( exists $rperlnamespaces_generated::RPERL->{ $subtype . '::' } ) {
138 0 0       0 if ( $subtype eq 'arrayref' ) { # hashrefs of arrayrefs
    0          
    0          
139 0         0 die 'NEED TEST & IMPLEMENT!!!';
140             }
141             elsif ( $subtype eq 'hashref' ) { # hashrefs of hashrefs
142 0         0 die 'NEED TEST & IMPLEMENT!!!';
143             }
144             elsif ( $subtype =~ /sse_number_pair$/xms ) { # hashref of SSE number pairs
145 0         0 die 'NEED TEST & IMPLEMENT!!!';
146             }
147             else { # hashrefs of scalars
148 0         0 $cpp_source_group->{CPP} .= '[';
149 0         0 my string_hashref $cpp_source_subgroup = $subexpression->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes);
150 0         0 RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup );
151 0         0 $cpp_source_group->{CPP} .= ']';
152             }
153             }
154             else { # hashref of user-defined data types (objects)
155 0         0 $cpp_source_group->{CPP} .= '[';
156 0         0 my string_hashref $cpp_source_subgroup = $subexpression->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes);
157 0         0 RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup );
158 0         0 $cpp_source_group->{CPP} .= ']';
159             }
160             }
161             elsif ( exists $rperlnamespaces_generated::RPERL->{ $base_type . '::' } ) { # scalar
162 0         0 die 'ERROR ECOGEASCPxd, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Variable retrieval, can not use hashref retrieval on scalar type ' . $base_type . ', dying' . "\n";
163             }
164             else { # user-defined type AKA class
165 0         0 $cpp_source_group->{CPP} .= '->';
166 0         0 my string_hashref $cpp_source_subgroup = $subexpression->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes);
167 0         0 RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup );
168             }
169             }
170             elsif ( $self_class eq 'VariableRetrieval_194' ) { # VariableRetrieval -> OP02_HASH_THINARROW WORD '}'
171 23         77 my string $word = $self->{children}->[1];
172              
173 23 50       124 if ( $base_type =~ /_arrayref$/ ) { # array
    50          
    50          
    50          
174 0         0 die 'ERROR ECOGEASCPxd, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Variable retrieval, can not use hashref retrieval on arrayref type ' . $base_type . ', dying' . "\n";
175             }
176             elsif ( $base_type eq 'sse_number_pair' ) {
177 0         0 die 'ERROR ECOGEASCPxd, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Variable retrieval, can not use hashref retrieval on SSE type ' . $base_type . ', dying' . "\n";
178             }
179             elsif ( $base_type =~ /_hashref$/ ) { # hash
180 0         0 $subtype = substr $base_type, 0, ( ( length $base_type ) - 8 ); # strip trailing '_hashref'
181 0 0       0 if ( exists $rperlnamespaces_generated::RPERL->{ $subtype . '::' } ) {
182 0 0       0 if ( $subtype eq 'arrayref' ) { # hashrefs of arrayrefs
    0          
    0          
183 0         0 die 'NEED TEST & IMPLEMENT!!!';
184             }
185             elsif ( $subtype eq 'hashref' ) { # hashrefs of hashrefs
186 0         0 die 'NEED TEST & IMPLEMENT!!!';
187             }
188             elsif ( $subtype =~ /sse_number_pair$/xms ) { # hashref of SSE number pairs
189 0         0 die 'NEED TEST & IMPLEMENT!!!';
190             }
191             else { # hashrefs of scalars
192 0         0 $cpp_source_group->{CPP} .= '[' . $word . ']';
193             }
194             }
195             else { # hashref of user-defined data types (objects)
196 0         0 $cpp_source_group->{CPP} .= '[' . $word . ']';
197             }
198             }
199             elsif ( exists $rperlnamespaces_generated::RPERL->{ $base_type . '::' } ) { # scalar
200 0         0 die 'ERROR ECOGEASCPxd, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Variable retrieval, can not use hashref retrieval on scalar type ' . $base_type . ', dying' . "\n";
201             }
202             else { # user-defined type AKA class
203 23         54 $cpp_source_group->{CPP} .= '->' . $word;
204             }
205              
206             }
207             else {
208 0         0 die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASCP00, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule '
209             . ($self_class)
210             . ' found where VariableRetrieval_192, VariableRetrieval_192, or VariableRetrieval_192 expected, dying' )
211             . "\n";
212             }
213 32         145 return $cpp_source_group;
214             }
215              
216             1; # end of class