File Coverage

blib/lib/RPerl/Operation/Expression.pm
Criterion Covered Total %
statement 39 46 84.7
branch 6 8 75.0
condition n/a
subroutine 7 8 87.5
pod n/a
total 52 62 83.8


line stmt bran cond sub pod time code
1             # [[[ HEADER ]]]
2             package RPerl::Operation::Expression;
3 4     4   1027 use strict;
  4         9  
  4         90  
4 4     4   17 use warnings;
  4         7  
  4         85  
5 4     4   19 use RPerl::AfterSubclass;
  4         8  
  4         459  
6             our $VERSION = 0.002_010;
7              
8             # [[[ OO INHERITANCE ]]]
9 4     4   23 use parent qw(RPerl::Operation);
  4         8  
  4         21  
10 4     4   224 use RPerl::Operation;
  4         9  
  4         1487  
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 1443     1443   2818 { my string_hashref::method $RETURN_TYPE };
  1443         2606  
23 1443         3260 ( my object $self, my string_hashref $modes) = @ARG;
24 1443         4253 my string_hashref $rperl_source_group
25             = { PMC => q{} };
26 1443         3137 my string_hashref $rperl_source_subgroup;
27              
28             # RPerl::diag( 'in Expression->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
29              
30 1443 100       6797 if ( ( ref $self ) eq 'Operation_89' ) { # Operation -> Expression ';'
    50          
31             $rperl_source_subgroup
32 303         6619 = $self->{children}->[0]->ast_to_rperl__generate($modes);
33 303         6439 RPerl::Generator::source_group_append( $rperl_source_group,
34             $rperl_source_subgroup );
35 303         972 $rperl_source_group->{PMC} .= $self->{children}->[1] . "\n"; # semicolon
36             }
37             elsif ( ( ref $self ) eq 'SubExpression_149' ) { # SubExpression -> Expression
38             $rperl_source_subgroup
39 1140         26014 = $self->{children}->[0]->ast_to_rperl__generate($modes);
40 1140         24949 RPerl::Generator::source_group_append( $rperl_source_group,
41             $rperl_source_subgroup );
42             }
43             else {
44 0         0 die RPerl::Parser::rperl_rule__replace(
45             'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule '
46             . ( ref $self )
47             . ' found where Operation_89 or SubExpression_149 expected, dying'
48             ) . "\n";
49             }
50 1443         81210 return $rperl_source_group;
51             }
52              
53             sub ast_to_cpp__generate__CPPOPS_PERLTYPES {
54 0     0   0 { my string_hashref::method $RETURN_TYPE };
  0         0  
55 0         0 ( my object $self, my string_hashref $modes) = @ARG;
56 0         0 my string_hashref $cpp_source_group
57             = { CPP => q{// <<< RP::O::E __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>}
58             . "\n" };
59              
60             #...
61 0         0 return $cpp_source_group;
62             }
63              
64             sub ast_to_cpp__generate__CPPOPS_CPPTYPES {
65 112     112   210 { my string_hashref::method $RETURN_TYPE };
  112         172  
66 112         227 ( my object $self, my string_hashref $modes) = @ARG;
67 112         325 my string_hashref $cpp_source_group
68             = { CPP => q{} };
69 112         190 my string_hashref $cpp_source_subgroup;
70              
71             # RPerl::diag( 'in Expression->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
72              
73 112 100       439 if ( ( ref $self ) eq 'Operation_89' ) { # Operation -> Expression ';'
    50          
74             $cpp_source_subgroup
75 5         149 = $self->{children}->[0]->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes);
76             # RPerl::diag( 'in Expression->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $cpp_source_subgroup = ' . "\n" . RPerl::Parser::rperl_ast__dump($cpp_source_subgroup) . "\n" );
77 5         117 RPerl::Generator::source_group_append( $cpp_source_group,
78             $cpp_source_subgroup );
79 5         16 $cpp_source_group->{CPP} .= $self->{children}->[1] . "\n"; # semicolon
80             }
81             elsif ( ( ref $self ) eq 'SubExpression_149' ) { # SubExpression -> Expression
82             $cpp_source_subgroup
83 107         2404 = $self->{children}->[0]->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes);
84             # RPerl::diag( 'in Expression->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $cpp_source_subgroup = ' . "\n" . RPerl::Parser::rperl_ast__dump($cpp_source_subgroup) . "\n" );
85 107         2388 RPerl::Generator::source_group_append( $cpp_source_group,
86             $cpp_source_subgroup );
87             }
88             else {
89 0         0 die RPerl::Parser::rperl_rule__replace(
90             'ERROR ECOGEASCP00, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule '
91             . ( ref $self )
92             . ' found where Operation_89 or SubExpression_149 expected, dying'
93             ) . "\n";
94             }
95 112         6424 return $cpp_source_group;
96             }
97              
98             1; # end of class