File Coverage

blib/lib/RPerl/Operation/Statement/Loop/ForEach.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 20 20 100.0


line stmt bran cond sub pod time code
1             # [[[ HEADER ]]]
2             package RPerl::Operation::Statement::Loop::ForEach;
3 5     5   39 use strict;
  5         15  
  5         150  
4 5     5   25 use warnings;
  5         13  
  5         129  
5 5     5   26 use RPerl::AfterSubclass;
  5         12  
  5         729  
6             our $VERSION = 0.001_000;
7              
8             # [[[ OO INHERITANCE ]]]
9 5     5   39 use parent qw(RPerl::Operation::Statement::Loop);
  5         13  
  5         37  
10 5     5   328 use RPerl::Operation::Statement::Loop;
  5         13  
  5         1740  
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             our string_hashref::method $ast_to_rperl__generate = sub {
22             ( my object $self, my string_hashref $modes) = @_;
23             my string_hashref $rperl_source_group = { PMC => q{} };
24              
25             # RPerl::diag( 'in Loop::ForEach->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
26              
27             my string $self_class = ref $self;
28              
29             # unwrap LoopForEach_169 from Loop_165
30             if ( $self_class eq 'Loop_165' ) { # Loop -> LoopForEach
31             $self = $self->{children}->[0];
32             $self_class = ref $self;
33             }
34              
35             # LoopForEach -> 'foreach' MY Type VARIABLE_SYMBOL LPAREN ListElements ')' CodeBlock
36             if ( $self_class eq 'LoopForEach_169' ) {
37             my string $foreach = $self->{children}->[0];
38             my string $my = $self->{children}->[1];
39             my string $type = $self->{children}->[2]->{children}->[0];
40             my string $variable_symbol = $self->{children}->[3];
41             my string $left_paren = $self->{children}->[4];
42             my object $list_elements = $self->{children}->[5];
43             my string $right_paren = $self->{children}->[6];
44             my object $codeblock = $self->{children}->[7];
45              
46             # START HERE: add error checking for PERLOPS_PERLTYPES, then utilize for CPPOPS_CPPTYPES
47             # START HERE: add error checking for PERLOPS_PERLTYPES, then utilize for CPPOPS_CPPTYPES
48             # START HERE: add error checking for PERLOPS_PERLTYPES, then utilize for CPPOPS_CPPTYPES
49            
50             # RPerl::diag( 'in Loop::ForEach->ast_to_rperl__generate(), have $list_elements = ' . "\n" . RPerl::Parser::rperl_ast__dump($list_elements) . "\n" );
51             # die 'TMP DEBUG';
52             # if ((scalar @{$list_elements->{children}->[1]->{children}}) > 0) { # non-empty _STAR_LIST, meaning 2 or more total elements in ListElements
53             # }
54              
55             $rperl_source_group->{PMC} .= $foreach . q{ } . $my . q{ } . $type . q{ } . $variable_symbol . q{ } . $left_paren . q{ };
56             my object $rperl_source_subgroup = $list_elements->ast_to_rperl__generate($modes);
57             RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup );
58             $rperl_source_group->{PMC} .= q{ } . $right_paren . q{ };
59             $rperl_source_subgroup = $codeblock->ast_to_rperl__generate($modes);
60             RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup );
61             }
62             else {
63             die RPerl::Parser::rperl_rule__replace(
64             'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule ' . $self_class . ' found where LoopForEach_169 expected, dying' )
65             . "\n";
66             }
67             return $rperl_source_group;
68             };
69              
70             our string_hashref::method $ast_to_cpp__generate__CPPOPS_PERLTYPES = sub {
71             ( my object $self, my string_hashref $modes) = @_;
72             my string_hashref $cpp_source_group = { CPP => q{// <<< RP::O::S::L::FE __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>} . "\n" };
73              
74             #...
75             return $cpp_source_group;
76             };
77              
78             our string_hashref::method $ast_to_cpp__generate__CPPOPS_CPPTYPES = sub {
79             ( my object $self, my string_hashref $modes) = @_;
80              
81             # START HERE: implement CPPOPS_CPPTYPES
82             # START HERE: implement CPPOPS_CPPTYPES
83             # START HERE: implement CPPOPS_CPPTYPES
84              
85             my string_hashref $cpp_source_group = { CPP => q{// <<< RP::O::S::L::FE __DUMMY_SOURCE_CODE CPPOPS_CPPTYPES >>>} . "\n" };
86              
87             #...
88             return $cpp_source_group;
89             };
90              
91             1; # end of class