File Coverage

blib/lib/RPerl/Operation/Statement/OperatorVoid/LoopControl.pm
Criterion Covered Total %
statement 30 59 50.8
branch 5 22 22.7
condition 7 9 77.7
subroutine 6 8 75.0
pod n/a
total 48 98 48.9


line stmt bran cond sub pod time code
1             # [[[ HEADER ]]]
2             package RPerl::Operation::Statement::OperatorVoid::LoopControl;
3 4     4   22 use strict;
  4         8  
  4         94  
4 4     4   20 use warnings;
  4         8  
  4         81  
5 4     4   18 use RPerl::AfterSubclass;
  4         8  
  4         521  
6             our $VERSION = 0.002_000;
7              
8             # [[[ OO INHERITANCE ]]]
9 4     4   30 use parent qw(RPerl::Operation::Statement::OperatorVoid);
  4         10  
  4         24  
10 4     4   168 use RPerl::Operation::Statement::OperatorVoid;
  4         12  
  4         2346  
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 26     26   79 { my string_hashref::method $RETURN_TYPE };
  26         70  
23 26         97 ( my object $self, my string_hashref $modes) = @ARG;
24 26         143 my string_hashref $rperl_source_group = { PMC => q{} };
25 26         109 my string_hashref $rperl_source_subgroup;
26              
27             # RPerl::diag( 'in OperatorVoid::LoopControl->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
28              
29 26         106 my string $self_class = ref $self;
30 26 100       179 if ( $self_class eq 'OperatorVoid_135' ) { # OperatorVoid -> OP19_LOOP_CONTROL_SCOLON
    50          
31 6 50 66     79 if (($self->{children}->[0] ne 'next;') and ($self->{children}->[0] ne 'last;')) {
32             die RPerl::Parser::rperl_rule__replace(
33             'ERROR ECOGEASRP26, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: loop control operator '
34 0         0 . $self->{children}->[0]
35             . ' found where next; or last; expected, dying'
36             ) . "\n";
37             }
38 6         35 $rperl_source_group->{PMC} .= $self->{children}->[0] . "\n";
39             }
40             elsif ( $self_class eq 'OperatorVoid_136' ) { # OperatorVoid -> OP19_LOOP_CONTROL LoopLabel ';'
41 20         90 my string $loop_control = $self->{children}->[0];
42 20         96 my string $loop_label = $self->{children}->[1]->{children}->[0];
43 20         86 my string $semicolon = $self->{children}->[2];
44 20         113 $rperl_source_group->{PMC} .= $loop_control . q{ } . $loop_label . $semicolon . "\n";
45            
46            
47            
48 20 50 100     374 if (($loop_control !~ /^next/xms) and ($loop_control !~ /^last/xms) and ($loop_control !~ /^redo/xms)) {
      66        
49 0         0 die RPerl::Parser::rperl_rule__replace(
50             'ERROR ECOGEASCP27, CODE GENERATOR, ABSTRACT SYNTAX TO C++: loop control operator '
51             . $loop_control
52             . ' found where next, last, or redo expected, dying'
53             ) . "\n";
54             }
55             }
56             else {
57 0         0 die RPerl::Parser::rperl_rule__replace(
58             'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule '
59             . $self_class
60             . ' found where OperatorVoid_135 or OperatorVoid_136 expected, dying'
61             ) . "\n";
62             }
63 26         156 return $rperl_source_group;
64             }
65              
66             sub ast_to_cpp__generate__CPPOPS_PERLTYPES {
67 0     0     { my string_hashref::method $RETURN_TYPE };
  0            
68 0           ( my object $self, my string_hashref $modes) = @ARG;
69 0           my string_hashref $cpp_source_group
70             = { CPP =>
71             q{// <<< RP::O::S::OV::LC __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>}
72             . "\n" };
73              
74             #...
75 0           return $cpp_source_group;
76             }
77              
78             sub ast_to_cpp__generate__CPPOPS_CPPTYPES {
79 0     0     { my string_hashref::method $RETURN_TYPE };
  0            
80 0           ( my object $self, my string_hashref $modes) = @ARG;
81 0           my string_hashref $cpp_source_group = { CPP => q{} };
82 0           my string_hashref $cpp_source_subgroup;
83              
84             # RPerl::diag( 'in OperatorVoid::LoopControl->$ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
85              
86 0           my string $self_class = ref $self;
87 0 0         if ( $self_class eq 'OperatorVoid_135' ) { # OperatorVoid -> OP19_LOOP_CONTROL_SCOLON
    0          
88 0 0         if ($self->{children}->[0] eq 'next;') {
    0          
89 0           $cpp_source_group->{CPP} .= 'continue;' . "\n";
90             }
91             elsif ($self->{children}->[0] eq 'last;') {
92 0           $cpp_source_group->{CPP} .= 'break;' . "\n";
93             }
94             else {
95             die RPerl::Parser::rperl_rule__replace(
96             'ERROR ECOGEASCP26, CODE GENERATOR, ABSTRACT SYNTAX TO C++: loop control operator '
97 0           . $self->{children}->[0]
98             . ' found where next; or last; expected, dying'
99             ) . "\n";
100             }
101             }
102             elsif ( $self_class eq 'OperatorVoid_136' ) { # OperatorVoid -> OP19_LOOP_CONTROL LoopLabel ';'
103 0           my string $loop_control = $self->{children}->[0];
104 0           my string $loop_label = $self->{children}->[1]->{children}->[0];
105 0           my string $semicolon = $self->{children}->[2];
106 0 0         if ($loop_control =~ /^next/xms) {
    0          
    0          
107 0           $cpp_source_group->{CPP} .= 'goto ' . $loop_label . '_NEXT' . $semicolon . "\n";
108             }
109             elsif ($loop_control =~ /^last/xms) {
110 0           $cpp_source_group->{CPP} .= 'goto ' . $loop_label . '_LAST' . $semicolon . "\n";
111             }
112             elsif ($loop_control =~ /^redo/xms) {
113 0           $cpp_source_group->{CPP} .= 'goto ' . $loop_label . '_REDO' . $semicolon . "\n";
114             }
115             else {
116 0           die RPerl::Parser::rperl_rule__replace(
117             'ERROR ECOGEASCP27, CODE GENERATOR, ABSTRACT SYNTAX TO C++: loop control operator '
118             . $loop_control
119             . ' found where next, last, or redo expected, dying'
120             ) . "\n";
121             }
122             }
123             else {
124 0           die RPerl::Parser::rperl_rule__replace(
125             'ERROR ECOGEASCP00, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule '
126             . $self_class
127             . ' found where OperatorVoid_135 or OperatorVoid_136 expected, dying'
128             ) . "\n";
129             }
130 0           return $cpp_source_group;
131             }
132              
133             1; # end of class