File Coverage

blib/lib/RPerl/Operation/Statement.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;
3 5     5   1858 use strict;
  5         607  
  5         133  
4 5     5   28 use warnings;
  5         11  
  5         131  
5 5     5   314 use RPerl::AfterSubclass;
  5         15  
  5         723  
6             our $VERSION = 0.002_010;
7              
8             # [[[ OO INHERITANCE ]]]
9 5     5   39 use parent qw(RPerl::Operation);
  5         13  
  5         33  
10 5     5   326 use RPerl::Operation;
  5         13  
  5         2600  
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             my object $child0 = $self->{children}->[0];
25             my string $child0_class = ref $child0;
26             my string_hashref $rperl_source_subgroup;
27              
28             # RPerl::diag( 'in Statement->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
29              
30             # Conditional, OperatorVoid, VariableDeclaration, or VariableModification
31             if ( ( $child0_class eq 'Statement_152' )
32             or ( $child0_class eq 'Statement_154' )
33             or ( $child0_class eq 'Statement_155' )
34             or ( $child0_class eq 'Statement_156' ) )
35             {
36             $rperl_source_subgroup
37             = $child0->ast_to_rperl__generate($modes);
38             RPerl::Generator::source_group_append( $rperl_source_group,
39             $rperl_source_subgroup );
40             }
41              
42             # Loop
43             elsif ( $child0_class eq 'Statement_153' ) {
44             my $optional_loop_label = $child0->{children}->[0];
45             my $loop = $child0->{children}->[1];
46             # RPerl::diag( 'in Statement->ast_to_rperl__generate(), have $optional_loop_label = ' . "\n" . RPerl::Parser::rperl_ast__dump($optional_loop_label) . "\n" );
47             if ( exists $optional_loop_label->{children}->[0] ) { # LoopLabel COLON
48             $rperl_source_group->{PMC} .= "\n" . $optional_loop_label->{children}->[0]->{children}->[0] . $optional_loop_label->{children}->[1]->{attr} . "\n";
49             }
50             $rperl_source_subgroup = $loop->ast_to_rperl__generate($modes);
51             RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup );
52             }
53             else {
54             die RPerl::Parser::rperl_rule__replace(
55             'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule '
56             . $child0_class
57             . ' found where Statement_152, Statement_153, Statement_154, Statement_155, or Statement_156 expected, dying'
58             ) . "\n";
59             }
60              
61             return $rperl_source_group;
62             };
63              
64             our string_hashref::method $ast_to_cpp__generate__CPPOPS_PERLTYPES = sub {
65             ( my object $self, my string_hashref $modes) = @_;
66             my string_hashref $cpp_source_group
67             = { CPP => q{// <<< RP::O::S __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>}
68             . "\n" };
69              
70             #...
71             return $cpp_source_group;
72             };
73              
74             our string_hashref::method $ast_to_cpp__generate__CPPOPS_CPPTYPES = sub {
75             ( my object $self, my string_hashref $modes) = @_;
76             # RPerl::diag( 'in Statement->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $modes->{_symbol_table} = ' . "\n" . Dumper($modes->{_symbol_table}) . "\n");
77              
78             my string_hashref $cpp_source_group = { CPP => q{} };
79             my object $child0 = $self->{children}->[0];
80             my string $child0_class = ref $child0;
81             my string_hashref $cpp_source_subgroup;
82              
83             # RPerl::diag( 'in Statement->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
84              
85             # Conditional, OperatorVoid, VariableDeclaration, or VariableModification
86             if ( ( $child0_class eq 'Statement_152' )
87             or ( $child0_class eq 'Statement_154' )
88             or ( $child0_class eq 'Statement_155' )
89             or ( $child0_class eq 'Statement_156' ) )
90             {
91             $cpp_source_subgroup = $child0->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes);
92             # RPerl::diag( 'in Statement->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $cpp_source_subgroup = ' . "\n" . RPerl::Parser::rperl_ast__dump($cpp_source_subgroup) . "\n" );
93             RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup );
94             }
95              
96             # Loop
97             elsif ( $child0_class eq 'Statement_153' ) {
98             my object $optional_loop_label = $child0->{children}->[0];
99             my object $loop = $child0->{children}->[1];
100             my string $loop_label = undef;
101             # RPerl::diag( 'in Statement->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $loop = ' . "\n" . RPerl::Parser::rperl_ast__dump($loop) . "\n" );
102             # RPerl::diag( 'in Statement->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $optional_loop_label = ' . "\n" . RPerl::Parser::rperl_ast__dump($optional_loop_label) . "\n" );
103              
104             if ( exists $optional_loop_label->{children}->[0] ) { # LoopLabel COLON
105             $loop_label = $optional_loop_label->{children}->[0]->{children}->[0];
106             }
107             # RPerl::diag( 'in Statement->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $loop_label = ' . "\n" . RPerl::Parser::rperl_ast__dump($loop_label) . "\n" );
108             $cpp_source_subgroup = $loop->ast_to_cpp__generate__CPPOPS_CPPTYPES($loop_label, $modes);
109             RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup );
110             }
111             else {
112             die RPerl::Parser::rperl_rule__replace(
113             'ERROR ECOGEASCP00, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule '
114             . $child0_class
115             . ' found where Statement_152, Statement_153, Statement_154, Statement_155, or Statement_156 expected, dying'
116             ) . "\n";
117             }
118              
119             return $cpp_source_group;
120             };
121              
122             1; # end of class