line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# [[[ HEADER ]]] |
2
|
|
|
|
|
|
|
package RPerl::Operation::Expression::Operator::Logical::OrXor; |
3
|
5
|
|
|
5
|
|
30
|
use strict; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
131
|
|
4
|
5
|
|
|
5
|
|
22
|
use warnings; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
113
|
|
5
|
5
|
|
|
5
|
|
26
|
use RPerl::AfterSubclass; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
654
|
|
6
|
|
|
|
|
|
|
our $VERSION = 0.002_000; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# [[[ OO INHERITANCE ]]] |
9
|
5
|
|
|
5
|
|
34
|
use parent qw(RPerl::Operation::Expression::Operator::Logical); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
30
|
|
10
|
5
|
|
|
5
|
|
329
|
use RPerl::Operation::Expression::Operator::Logical; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
1661
|
|
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::Logical::OrXor->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_106' ) # Operator -> SubExpression OP16_LOGICAL_OR SubExpression |
29
|
|
|
|
|
|
|
or ( $self_class eq 'Operator_111' ) # Operator -> SubExpression OP24_LOGICAL_OR_XOR SubExpression |
30
|
|
|
|
|
|
|
) |
31
|
|
|
|
|
|
|
{ |
32
|
|
|
|
|
|
|
my string_hashref $rperl_source_subgroup |
33
|
|
|
|
|
|
|
= $self->{children}->[0]->ast_to_rperl__generate($modes); |
34
|
|
|
|
|
|
|
RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup ); |
35
|
|
|
|
|
|
|
$rperl_source_group->{PMC} .= q{ } . $self->{children}->[1] . q{ }; |
36
|
|
|
|
|
|
|
$rperl_source_subgroup |
37
|
|
|
|
|
|
|
= $self->{children}->[2]->ast_to_rperl__generate($modes); |
38
|
|
|
|
|
|
|
RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else { |
41
|
|
|
|
|
|
|
die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule ' |
42
|
|
|
|
|
|
|
. $self_class |
43
|
|
|
|
|
|
|
. ' found where Operator_106 or Operator_111 expected, dying' ) |
44
|
|
|
|
|
|
|
. "\n"; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
return $rperl_source_group; |
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
our string_hashref::method $ast_to_cpp__generate__CPPOPS_PERLTYPES = sub { |
51
|
|
|
|
|
|
|
( my object $self, my string_hashref $modes) = @_; |
52
|
|
|
|
|
|
|
my string_hashref $cpp_source_group = { CPP => q{// <<< RP::O::E::O::L::OX __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>} . "\n" }; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
#... |
55
|
|
|
|
|
|
|
return $cpp_source_group; |
56
|
|
|
|
|
|
|
}; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
our string_hashref::method $ast_to_cpp__generate__CPPOPS_CPPTYPES = sub { |
59
|
|
|
|
|
|
|
( my object $self, my string_hashref $modes) = @_; |
60
|
|
|
|
|
|
|
my string_hashref $cpp_source_group = { CPP => q{} }; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# RPerl::diag( 'in Operator::Logical::OrXor->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" ); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# NEED FIX: in Perl, '||' and 'or' are equivalent except 'or' has a lower precedence; in C++, '||' and 'or' are exactly equivalent; |
65
|
|
|
|
|
|
|
# therefore I assume we need to add parenthesis around the operands to the left and right of Perl's 'or' when it is compiled to C++, |
66
|
|
|
|
|
|
|
# in order to replicate the precedence behavior? |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my string $self_class = ref $self; |
69
|
|
|
|
|
|
|
if (( $self_class eq 'Operator_106' ) # Operator -> SubExpression OP16_LOGICAL_OR SubExpression |
70
|
|
|
|
|
|
|
or ( $self_class eq 'Operator_111' ) # Operator -> SubExpression OP24_LOGICAL_OR_XOR SubExpression |
71
|
|
|
|
|
|
|
) |
72
|
|
|
|
|
|
|
{ |
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
|
|
|
|
|
|
|
$cpp_source_group->{CPP} .= q{ } . $self->{children}->[1] . q{ }; |
76
|
|
|
|
|
|
|
$cpp_source_subgroup = $self->{children}->[2]->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes); |
77
|
|
|
|
|
|
|
RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup ); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
else { |
80
|
|
|
|
|
|
|
die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASCP00, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule ' |
81
|
|
|
|
|
|
|
. $self_class |
82
|
|
|
|
|
|
|
. ' found where Operator_106 or Operator_111 expected, dying' ) |
83
|
|
|
|
|
|
|
. "\n"; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
return $cpp_source_group; |
87
|
|
|
|
|
|
|
}; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; # end of class |