File Coverage

blib/lib/RPerl/Operation/Expression/Operator/Compare/EqualNotEqual.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::Expression::Operator::Compare::EqualNotEqual;
3 5     5   73 use strict;
  5         12  
  5         136  
4 5     5   28 use warnings;
  5         12  
  5         153  
5 5     5   32 use RPerl::AfterSubclass;
  5         17  
  5         662  
6             our $VERSION = 0.003_000;
7              
8             # [[[ OO INHERITANCE ]]]
9 5     5   36 use parent qw(RPerl::Operation::Expression::Operator::Compare);
  5         15  
  5         30  
10 5     5   194 use RPerl::Operation::Expression::Operator::Compare;
  5         16  
  5         2401  
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 Operator::Compare::EqualNotEqual->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
26              
27             my string $self_class = ref $self;
28             if ( $self_class eq 'Operator_102' ) { # Operator -> SubExpression OP12_COMPARE_EQ_NE SubExpression
29             if ( ( $self->{children}->[1] ne '==' )
30             and ( $self->{children}->[1] ne '!=' )
31             and ( $self->{children}->[1] ne '<=>' )
32             and ( $self->{children}->[1] ne 'eq' )
33             and ( $self->{children}->[1] ne 'ne' )
34             and ( $self->{children}->[1] ne 'cmp' ) )
35             {
36             die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASRP29, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: comparison operator '
37             . $self->{children}->[1]
38             . ' found where ==, !=, <=>, eq, ne, or cmp expected, dying' )
39             . "\n";
40             }
41              
42             my string_hashref $rperl_source_subgroup = $self->{children}->[0]->ast_to_rperl__generate($modes);
43             RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup );
44             $rperl_source_group->{PMC} .= q{ } . $self->{children}->[1] . q{ };
45             $rperl_source_subgroup = $self->{children}->[2]->ast_to_rperl__generate($modes);
46             RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup );
47             }
48             else {
49             die RPerl::Parser::rperl_rule__replace(
50             'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule ' . $self_class . ' found where Operator_102 expected, dying' )
51             . "\n";
52             }
53              
54             return $rperl_source_group;
55             };
56              
57             our string_hashref::method $ast_to_cpp__generate__CPPOPS_PERLTYPES = sub {
58             ( my object $self, my string_hashref $modes) = @_;
59             my string_hashref $cpp_source_group = { CPP => q{// <<< RP::O::E::O::C::ENE __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>} . "\n" };
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_hashref $modes) = @_;
67             my string_hashref $cpp_source_group = { CPP => q{} };
68              
69             # RPerl::diag( 'in Operator::Compare::EqualNotEqual->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
70              
71             my string $self_class = ref $self;
72             if ( $self_class eq 'Operator_102' ) { # Operator -> SubExpression OP12_COMPARE_EQ_NE SubExpression
73             my string_hashref $cpp_source_subgroup = $self->{children}->[0]->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes);
74             RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup );
75             if ( ( $self->{children}->[1] eq '==' ) or ( $self->{children}->[1] eq '!=' ) ) {
76             $cpp_source_group->{CPP} .= q{ } . $self->{children}->[1] . q{ };
77             }
78             elsif ( $self->{children}->[1] eq '<=>' ) {
79             $cpp_source_group->{CPP} .= ' DUMMY_THREE_WAY_COMPARISON_NUMERIC ';
80             }
81             elsif ( $self->{children}->[1] eq 'eq' ) {
82             $cpp_source_group->{CPP} .= ' == '; # DEV NOTE: '==' is an overload for std::string::compare()
83             }
84             elsif ( $self->{children}->[1] eq 'ne' ) {
85             $cpp_source_group->{CPP} .= ' != '; # DEV NOTE: '!=' is an overload for not(std::string::compare())
86             }
87             elsif ( $self->{children}->[1] eq 'cmp' ) {
88             $cpp_source_group->{CPP} .= ' DUMMY_THREE_WAY_COMPARISON_STRING ';
89             }
90             else {
91             die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASCP29, CODE GENERATOR, ABSTRACT SYNTAX TO C++: comparison operator '
92             . $self->{children}->[1]
93             . ' found where ==, !=, <=>, eq, ne, or cmp expected, dying' )
94             . "\n";
95             }
96             $cpp_source_subgroup = $self->{children}->[2]->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes);
97             RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup );
98             }
99             else {
100             die RPerl::Parser::rperl_rule__replace(
101             'ERROR ECOGEASCP00, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule ' . $self_class . ' found where Operator_102 expected, dying' )
102             . "\n";
103             }
104              
105             return $cpp_source_group;
106             };
107              
108             1; # end of class