File Coverage

blib/lib/RPerl/DataStructure/Hash/Reference.pm
Criterion Covered Total %
statement 84 94 89.3
branch 13 20 65.0
condition n/a
subroutine 13 14 92.8
pod n/a
total 110 128 85.9


line stmt bran cond sub pod time code
1             # [[[ HEADER ]]]
2             package RPerl::DataStructure::Hash::Reference;
3 7     7   44 use strict;
  7         17  
  7         238  
4 7     7   32 use warnings;
  7         15  
  7         193  
5 7     7   40 use RPerl::AfterSubclass;
  7         13  
  7         1094  
6             our $VERSION = 0.003_000;
7              
8             # [[[ OO INHERITANCE ]]]
9 7     7   49 use parent qw(RPerl::DataType::Modifier::Reference);
  7         13  
  7         40  
10 7     7   946 use RPerl::DataType::Modifier::Reference;
  7         15  
  7         197  
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             ## no critic qw(Capitalization ProhibitMultiplePackages ProhibitReusedNames) # SYSTEM DEFAULT 3: allow multiple & lower case package names
16              
17             # [[[ INCLUDES ]]]
18             # DEV NOTE: must pre-declare string_hashref::method and object types here, because this file appears on a lower line number in rperltypes.pm
19             #require RPerl::CodeBlock::Subroutine::Method;
20             package # hide from PAUSE indexing
21             string_hashref::method;
22 7     7   60 use strict;
  7         12  
  7         123  
23 7     7   29 use warnings;
  7         14  
  7         248  
24              
25             #require RPerl::Object;
26             package # hide from PAUSE indexing
27             object;
28 7     7   34 use strict;
  7         11  
  7         125  
29 7     7   28 use warnings;
  7         11  
  7         189  
30              
31             package RPerl::DataStructure::Hash::Reference;
32 7     7   29 use strict;
  7         28  
  7         128  
33 7     7   29 use warnings;
  7         14  
  7         4333  
34              
35             # [[[ OO PROPERTIES ]]]
36             our hashref $properties = {};
37              
38             # [[[ SUBROUTINES & OO METHODS ]]]
39              
40             sub ast_to_rperl__generate {
41 216     216   457 { my string_hashref::method $RETURN_TYPE };
  216         470  
42 216         511 ( my object $self, my string_hashref $modes) = @ARG;
43 216         698 my string_hashref $rperl_source_group = { PMC => q{} };
44              
45             # RPerl::diag( 'in Hash::Reference->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
46              
47 216         631 my string $self_class = ref $self;
48              
49             # unwrap HashReference_225 & HashReference_226 from SubExpression_155
50 216 100       729 if ( $self_class eq 'SubExpression_155' ) {
51 197         562 $self = $self->{children}->[0];
52 197         511 $self_class = ref $self;
53             }
54              
55 216 100       704 if ( $self_class eq 'HashReference_225' ) { # HashReference -> LBRACE HashEntry STAR-50 '}'
    50          
56 197         599 my string $left_brace = $self->{children}->[0];
57 197         430 my object $hash_entry = $self->{children}->[1];
58 197         484 my object $hash_entries_star = $self->{children}->[2];
59 197         526 my string $right_brace = $self->{children}->[3];
60              
61 197         552 $rperl_source_group->{PMC} .= $left_brace;
62 197         4467 my string_hashref $rperl_source_subgroup
63             = $hash_entry->ast_to_rperl__generate($modes);
64 197         4120 RPerl::Generator::source_group_append( $rperl_source_group,
65             $rperl_source_subgroup );
66              
67 197         435 foreach my $hash_entry_star ( @{ $hash_entries_star->{children} } ) {
  197         690  
68 764 100       1815 if ( ref $hash_entry_star eq 'TERMINAL' ) {
69 382 50       1269 if ( $hash_entry_star->{attr} ne q{,} ) {
70             die RPerl::Parser::rperl_rule__replace(
71             q{ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule '}
72             . $hash_entry_star->{attr}
73 0         0 . q{' found where OP21_LIST_COMMA ',' expected, dying}
74             ) . "\n";
75             }
76             $rperl_source_group->{PMC}
77 382         946 .= $hash_entry_star->{attr} . q{ }; # OP21_LIST_COMMA
78             }
79             else {
80 382         7801 $rperl_source_subgroup
81             = $hash_entry_star->ast_to_rperl__generate($modes);
82 382         7707 RPerl::Generator::source_group_append( $rperl_source_group,
83             $rperl_source_subgroup );
84             }
85             }
86              
87 197         645 $rperl_source_group->{PMC} .= $right_brace;
88             }
89             elsif ( $self_class eq 'HashReference_226' ) { # HashReference -> LBRACE '}'
90 19         89 my string $left_brace = $self->{children}->[0];
91 19         56 my string $right_brace = $self->{children}->[1];
92 19         71 $rperl_source_group->{PMC} .= $left_brace . $right_brace;
93             }
94             else {
95 0         0 die RPerl::Parser::rperl_rule__replace(
96             'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule '
97             . ($self_class)
98             . ' found where HashReference_225, HashReference_226, or SubExpression_155 expected, dying'
99             ) . "\n";
100             }
101 216         5722 return $rperl_source_group;
102             }
103              
104             sub ast_to_cpp__generate__CPPOPS_PERLTYPES {
105 0     0   0 { my string_hashref::method $RETURN_TYPE };
  0         0  
106 0         0 ( my object $self, my string_hashref $modes) = @ARG;
107 0         0 my string_hashref $cpp_source_group
108             = {
109             CPP => q{// <<< RP::DS::H::R __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>}
110             . "\n"
111             };
112              
113             #...
114 0         0 return $cpp_source_group;
115             }
116              
117             sub ast_to_cpp__generate__CPPOPS_CPPTYPES {
118 7     7   17 { my string_hashref::method $RETURN_TYPE };
  7         12  
119 7         18 ( my object $self, my string_hashref $modes) = @ARG;
120 7         21 my string_hashref $cpp_source_group = { CPP => q{} };
121              
122             # RPerl::diag( 'in Hash::Reference->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
123              
124 7         19 my string $self_class = ref $self;
125              
126             # unwrap HashReference_225 & HashReference_226 from SubExpression_155
127 7 50       26 if ( $self_class eq 'SubExpression_155' ) {
128 7         36 $self = $self->{children}->[0];
129 7         15 $self_class = ref $self;
130             }
131              
132 7 50       21 if ( $self_class eq 'HashReference_225' ) { # HashReference -> LBRACE HashEntry STAR-50 '}'
    0          
133 7         24 my object $hash_entry = $self->{children}->[1];
134 7         15 my object $hash_entries_star = $self->{children}->[2];
135              
136 7         24 $cpp_source_group->{CPP} .= '{ ';
137 7         149 my string_hashref $cpp_source_subgroup
138             = $hash_entry->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes);
139 7         163 RPerl::Generator::source_group_append( $cpp_source_group,
140             $cpp_source_subgroup );
141              
142 7         15 foreach my $hash_entry_star ( @{ $hash_entries_star->{children} } ) {
  7         24  
143 26 100       67 if ( ref $hash_entry_star eq 'TERMINAL' ) {
144 13 50       44 if ( $hash_entry_star->{attr} ne q{,} ) {
145             die RPerl::Parser::rperl_rule__replace(
146             q{ERROR ECOGEASCP00, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule '}
147             . $hash_entry_star->{attr}
148 0         0 . q{' found where OP21_LIST_COMMA ',' expected, dying}
149             ) . "\n";
150             }
151             $cpp_source_group->{CPP}
152 13         39 .= $hash_entry_star->{attr} . q{ }; # OP21_LIST_COMMA
153             }
154             else {
155 13         248 $cpp_source_subgroup
156             = $hash_entry_star->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes);
157 13         234 RPerl::Generator::source_group_append( $cpp_source_group,
158             $cpp_source_subgroup );
159             }
160             }
161              
162 7         27 $cpp_source_group->{CPP} .= ' }';
163             }
164             elsif ( $self_class eq 'HashReference_226' ) { # HashReference -> LBRACE '}'
165 0         0 $cpp_source_group->{CPP} .= '{}';
166             }
167             else {
168 0         0 die RPerl::Parser::rperl_rule__replace(
169             'ERROR ECOGEASCP00, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule '
170             . ($self_class)
171             . ' found where HashReference_225, HashReference_226, or SubExpression_155 expected, dying'
172             ) . "\n";
173             }
174 7         80 return $cpp_source_group;
175             }
176              
177             1; # end of class