File Coverage

blib/lib/RPerl/Operation/Statement/Loop.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;
3 5     5   32 use strict;
  5         16  
  5         142  
4 5     5   28 use warnings;
  5         11  
  5         113  
5 5     5   26 use RPerl::AfterSubclass;
  5         9  
  5         649  
6             our $VERSION = 0.002_010;
7              
8             # [[[ OO INHERITANCE ]]]
9 5     5   35 use parent qw(RPerl::Operation::Statement);
  5         14  
  5         32  
10 5     5   324 use RPerl::Operation::Statement;
  5         18  
  5         1769  
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->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 Loop_164, Loop_165, and Loop_166 from Statement_153
30             if ( $self_class eq 'Statement_153' ) {
31             $self = $self->{children}->[0];
32             $self_class = ref $self;
33             }
34              
35             if ( ( $self_class eq 'Loop_164' ) # Loop -> LoopFor
36             or ( $self_class eq 'Loop_165' ) # Loop -> LoopForEach
37             or ( $self_class eq 'Loop_166' ) ) # Loop -> LoopWhile
38             {
39             my object $rperl_source_subgroup = $self->ast_to_rperl__generate($modes);
40             RPerl::Generator::source_group_append( $rperl_source_group,
41             $rperl_source_subgroup );
42             }
43             else {
44             die RPerl::Parser::rperl_rule__replace(
45             'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule '
46             . $self_class
47             . ' found where Loop_164, Loop_165, or Loop_166 expected, dying'
48             ) . "\n";
49             }
50             return $rperl_source_group;
51             };
52              
53             our string_hashref::method $ast_to_cpp__generate__CPPOPS_PERLTYPES = sub {
54             ( my object $self, my string $loop_label, my string_hashref $modes) = @_;
55             my string_hashref $cpp_source_group
56             = {
57             CPP => q{// <<< RP::O::S::L __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>}
58             . "\n"
59             };
60              
61             #...
62             return $cpp_source_group;
63             };
64              
65             our string_hashref::method $ast_to_cpp__generate__CPPOPS_CPPTYPES = sub {
66             ( my object $self, my string $loop_label, my string_hashref $modes) = @_;
67             my string_hashref $cpp_source_group = { CPP => q{} };
68              
69             # RPerl::diag( 'in Loop->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
70             # RPerl::diag( 'in Loop->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $loop_label = ' . $loop_label . "\n" );
71              
72             my string $self_class = ref $self;
73              
74             # unwrap Loop_164, Loop_165, and Loop_166 from Statement_153
75             if ( $self_class eq 'Statement_153' ) {
76             $self = $self->{children}->[0];
77             $self_class = ref $self;
78             }
79              
80             if ( ( $self_class eq 'Loop_164' ) # Loop -> LoopFor
81             or ( $self_class eq 'Loop_165' ) # Loop -> LoopForEach
82             or ( $self_class eq 'Loop_166' ) ) # Loop -> LoopWhile
83             {
84             my object $cpp_source_subgroup = $self->ast_to_cpp__generate__CPPOPS_CPPTYPES($loop_label, $modes);
85             RPerl::Generator::source_group_append( $cpp_source_group,
86             $cpp_source_subgroup );
87             }
88             else {
89             die RPerl::Parser::rperl_rule__replace(
90             'ERROR ECOGEASCP00, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule '
91             . $self_class
92             . ' found where Loop_164, Loop_165, or Loop_166 expected, dying'
93             ) . "\n";
94             }
95             # RPerl::diag( 'in Loop->ast_to_cpp__generate__CPPOPS_CPPTYPES(), bottom of subroutine, have $modes->{_loop_iterators} = ' . "\n" . Dumper($modes->{_loop_iterators}) . "\n" );
96              
97             return $cpp_source_group;
98             };
99              
100             1; # end of class