File Coverage

blib/lib/RPerl/DataStructure/Array/Reference.pm
Criterion Covered Total %
statement 67 74 90.5
branch 9 12 75.0
condition n/a
subroutine 13 14 92.8
pod n/a
total 89 100 89.0


line stmt bran cond sub pod time code
1             # [[[ HEADER ]]]
2             package RPerl::DataStructure::Array::Reference;
3 7     7   44 use strict;
  7         14  
  7         270  
4 7     7   34 use warnings;
  7         16  
  7         223  
5 7     7   36 use RPerl::AfterSubclass;
  7         14  
  7         1649  
6             our $VERSION = 0.004_000;
7              
8             # [[[ OO INHERITANCE ]]]
9 7     7   44 use parent qw(RPerl::DataType::Modifier::Reference);
  7         16  
  7         51  
10 7     7   1229 use RPerl::DataType::Modifier::Reference;
  7         14  
  7         198  
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   30 use strict;
  7         14  
  7         123  
23 7     7   29 use warnings;
  7         12  
  7         217  
24              
25             #require RPerl::Object;
26             package # hide from PAUSE indexing
27             object;
28 7     7   29 use strict;
  7         12  
  7         116  
29 7     7   27 use warnings;
  7         14  
  7         184  
30              
31             package RPerl::DataStructure::Array::Reference;
32 7     7   37 use strict;
  7         13  
  7         128  
33 7     7   26 use warnings;
  7         14  
  7         3281  
34              
35             # [[[ OO PROPERTIES ]]]
36             # NEED FIX: type 'hashref' not yet defined here,
37             # makes it impossible to 'use RPerl::DataStructure::Array;' or 'use RPerl::DataStructure::Hash;',
38             # followed by more cascading errors
39             our hashref $properties = {};
40              
41             #our $properties = {};
42              
43             # [[[ SUBROUTINES & OO METHODS ]]]
44              
45             sub ast_to_rperl__generate {
46 308     308   721 { my string_hashref::method $RETURN_TYPE };
  308         579  
47 308         862 ( my object $self, my string_hashref $modes) = @ARG;
48 308         1048 my string_hashref $rperl_source_group = { PMC => q{} };
49              
50             # RPerl::diag( 'in Array::Reference->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
51              
52 308         894 my string $self_class = ref $self;
53              
54             # unwrap ArrayReference_211 from SubExpression_153
55 308 100       1084 if ( $self_class eq 'SubExpression_153' ) {
56 284         881 $self = $self->{children}->[0];
57 284         717 $self_class = ref $self;
58             }
59              
60 308 50       1133 if ( ($self_class) ne 'ArrayReference_211' ) {
61 0         0 die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule '
62             . ($self_class)
63             . ' found where ArrayReference_211 or SubExpression_153 expected, dying' )
64             . "\n";
65             }
66              
67             # ArrayReference -> LBRACKET OPTIONAL-45 ']'
68 308         1022 my string $left_bracket = $self->{children}->[0];
69 308         708 my object $list_elements_optional = $self->{children}->[1];
70 308         797 my string $right_bracket = $self->{children}->[2];
71              
72 308         882 $rperl_source_group->{PMC} .= $left_bracket;
73              
74 308 100       1130 if ( exists $list_elements_optional->{children}->[0] ) {
75 278         6602 my string_hashref $rperl_source_subgroup = $list_elements_optional->{children}->[0]->ast_to_rperl__generate($modes);
76 278         5874 RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup );
77             }
78              
79 308         782 $rperl_source_group->{PMC} .= $right_bracket;
80 308         8246 return $rperl_source_group;
81             }
82              
83             sub ast_to_cpp__generate__CPPOPS_PERLTYPES {
84 0     0   0 { my string_hashref::method $RETURN_TYPE };
  0         0  
85 0         0 ( my object $self, my string_hashref $modes) = @ARG;
86 0         0 my string_hashref $cpp_source_group = { CPP => q{// <<< RP::DS::A::R __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>} . "\n" };
87              
88             #...
89 0         0 return $cpp_source_group;
90             }
91              
92             sub ast_to_cpp__generate__CPPOPS_CPPTYPES {
93 7     7   20 { my string_hashref::method $RETURN_TYPE };
  7         14  
94 7         18 ( my object $self, my string_hashref $modes) = @ARG;
95 7         22 my string_hashref $cpp_source_group = { CPP => q{} };
96              
97             # RPerl::diag( 'in Array::Reference->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
98              
99 7         18 my string $self_class = ref $self;
100              
101             # unwrap ArrayReference_211 from SubExpression_153
102 7 100       24 if ( $self_class eq 'SubExpression_153' ) {
103 6         28 $self = $self->{children}->[0];
104 6         14 $self_class = ref $self;
105             }
106              
107 7 50       25 if ( ($self_class) ne 'ArrayReference_211' ) {
108 0         0 die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASCP00, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule '
109             . ($self_class)
110             . ' found where ArrayReference_211 or SubExpression_153 expected, dying' )
111             . "\n";
112             }
113              
114             # ArrayReference -> LBRACKET OPTIONAL-45 ']'
115 7         17 my object $list_elements_optional = $self->{children}->[1];
116              
117 7         18 $cpp_source_group->{CPP} .= '{';
118              
119 7 50       22 if ( exists $list_elements_optional->{children}->[0] ) {
120 7         144 my string_hashref $cpp_source_subgroup = $list_elements_optional->{children}->[0]->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes);
121 7         131 RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup );
122             }
123              
124 7         22 $cpp_source_group->{CPP} .= '}';
125 7         94 return $cpp_source_group;
126             }
127              
128             1; # end of class