File Coverage

blib/lib/RPerl/Operation/Expression/Operator/Arithmetic/Power.pm
Criterion Covered Total %
statement 41 48 85.4
branch 2 4 50.0
condition n/a
subroutine 7 8 87.5
pod n/a
total 50 60 83.3


line stmt bran cond sub pod time code
1             # [[[ HEADER ]]]
2             package RPerl::Operation::Expression::Operator::Arithmetic::Power;
3 4     4   24 use strict;
  4         8  
  4         148  
4 4     4   21 use warnings;
  4         7  
  4         83  
5 4     4   20 use RPerl::AfterSubclass;
  4         6  
  4         491  
6             our $VERSION = 0.002_000;
7              
8             # [[[ OO INHERITANCE ]]]
9 4     4   27 use parent qw(RPerl::Operation::Expression::Operator::Arithmetic);
  4         10  
  4         23  
10 4     4   227 use RPerl::Operation::Expression::Operator::Arithmetic;
  4         19  
  4         1315  
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 12     12   27 { my string_hashref::method $RETURN_TYPE };
  12         25  
23 12         29 ( my object $self, my string_hashref $modes) = @ARG;
24 12         36 my string_hashref $rperl_source_group = { PMC => q{} };
25              
26             # RPerl::diag( 'in Operator::Arithmetic::Power->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
27              
28 12         25 my string $self_class = ref $self;
29 12 50       31 if ( $self_class eq 'Operator_100' ) { # Operator -> SubExpression OP04_MATH_POW SubExpression
30 12         258 my string_hashref $rperl_source_subgroup = $self->{children}->[0]->ast_to_rperl__generate($modes);
31 12         233 RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup );
32 12         35 $rperl_source_group->{PMC} .= q{ } . $self->{children}->[1] . q{ };
33 12         231 $rperl_source_subgroup = $self->{children}->[2]->ast_to_rperl__generate($modes);
34 12         240 RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup );
35             }
36             else {
37 0         0 die RPerl::Parser::rperl_rule__replace(
38             'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule '
39             . $self_class
40             . ' found where Operator_100 expected, dying' )
41             . "\n";
42             }
43 12         55 return $rperl_source_group;
44             }
45              
46             sub ast_to_cpp__generate__CPPOPS_PERLTYPES {
47 0     0   0 { my string_hashref::method $RETURN_TYPE };
  0         0  
48 0         0 ( my object $self, my string_hashref $modes) = @ARG;
49 0         0 my string_hashref $cpp_source_group
50             = {
51             CPP => q{// <<< RP::O::E::O::M::P __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>}
52             . "\n"
53             };
54              
55             #...
56 0         0 return $cpp_source_group;
57             }
58              
59              
60             sub ast_to_cpp__generate__CPPOPS_CPPTYPES {
61 2     2   5 { my string_hashref::method $RETURN_TYPE };
  2         3  
62 2         5 ( my object $self, my string_hashref $modes) = @ARG;
63 2         8 my string_hashref $cpp_source_group = { H_INCLUDES => q{}, CPP => q{} };
64              
65             # RPerl::diag( 'in Operator::Arithmetic::Power->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
66              
67 2         5 my string $self_class = ref $self;
68 2 50       6 if ( $self_class eq 'Operator_100' ) { # Operator -> SubExpression OP04_MATH_POW SubExpression
69             # DEV NOTE: including math.h here causes compiler errors, instead it is always included via RPerl/Inline.pm
70             # $cpp_source_group->{H_INCLUDES} .= '#include <math.h>' . "\n";
71              
72 2         6 $cpp_source_group->{CPP} .= 'pow(';
73 2         49 my string_hashref $cpp_source_subgroup = $self->{children}->[0]->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes);
74 2         50 RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup );
75 2         5 $cpp_source_group->{CPP} .= ', ';
76 2         45 $cpp_source_subgroup = $self->{children}->[2]->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes);
77 2         43 RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup );
78 2         6 $cpp_source_group->{CPP} .= ')';
79             }
80             else {
81 0         0 die RPerl::Parser::rperl_rule__replace(
82             'ERROR ECOGEASCP00, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule '
83             . $self_class
84             . ' found where Operator_100 expected, dying' )
85             . "\n";
86             }
87 2         10 return $cpp_source_group;
88             }
89              
90             1; # end of class