line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# [[[ DOCUMENTATION ]]] |
2
|
|
|
|
|
|
|
# http://perldoc.perl.org/functions/scalar.html |
3
|
|
|
|
|
|
|
# SUPPORTED: scalar EXPR |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# [[[ HEADER ]]] |
6
|
|
|
|
|
|
|
package RPerl::Operation::Expression::Operator::NamedUnary::Scalar; |
7
|
4
|
|
|
4
|
|
23
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
101
|
|
8
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
94
|
|
9
|
4
|
|
|
4
|
|
19
|
use RPerl::AfterSubclass; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
488
|
|
10
|
|
|
|
|
|
|
our $VERSION = 0.003_100; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# [[[ OO INHERITANCE ]]] |
13
|
4
|
|
|
4
|
|
24
|
use parent qw(RPerl::Operation::Expression::Operator::NamedUnary); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
21
|
|
14
|
4
|
|
|
4
|
|
218
|
use RPerl::Operation::Expression::Operator::NamedUnary; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
101
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# [[[ CRITICS ]]] |
17
|
|
|
|
|
|
|
## no critic qw(ProhibitUselessNoCritic ProhibitMagicNumbers RequireCheckedSyscalls) # USER DEFAULT 1: allow numeric values & print operator |
18
|
|
|
|
|
|
|
## no critic qw(RequireInterpolationOfMetachars) # USER DEFAULT 2: allow single-quoted control characters & sigils |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# [[[ CONSTANTS ]]] |
21
|
4
|
|
|
4
|
|
19
|
use constant NAME => my string $TYPED_NAME = 'scalar'; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
203
|
|
22
|
4
|
|
|
4
|
|
22
|
use constant NAME_CPPOPS_PERLTYPES => my string $TYPED_NAME_CPPOPS_PERLTYPES = 'DUMMY_OP_SCALAR'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
181
|
|
23
|
4
|
|
|
4
|
|
21
|
use constant NAME_CPPOPS_CPPTYPES => my string $TYPED_NAME_CPPOPS_CPPTYPES = 'size'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
173
|
|
24
|
4
|
|
|
4
|
|
21
|
use constant ARGUMENTS_MIN => my integer $TYPED_ARGUMENTS_MIN = 1; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
176
|
|
25
|
4
|
|
|
4
|
|
20
|
use constant ARGUMENTS_MAX => my integer $TYPED_ARGUMENTS_MAX = 1; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
2529
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# [[[ OO PROPERTIES ]]] |
28
|
|
|
|
|
|
|
our hashref $properties = {}; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# [[[ SUBROUTINES & OO METHODS ]]] |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub ast_to_rperl__generate { |
33
|
18
|
|
|
18
|
|
56
|
{ my string_hashref::method $RETURN_TYPE }; |
|
18
|
|
|
|
|
61
|
|
34
|
18
|
|
|
|
|
67
|
( my object $self, my object $operator_named, my string_hashref $modes) = @ARG; |
35
|
18
|
|
|
|
|
100
|
my string_hashref $rperl_source_group = { PMC => q{} }; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# RPerl::diag( 'in Operator::NamedUnary::Scalar->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" ); |
38
|
|
|
|
|
|
|
# RPerl::diag( 'in Operator::NamedUnary::Scalar->ast_to_rperl__generate(), received $operator_named = ' . "\n" . RPerl::Parser::rperl_ast__dump($operator_named) . "\n" ); |
39
|
|
|
|
|
|
|
|
40
|
18
|
|
|
|
|
78
|
my string $operator_named_class = ref $operator_named; |
41
|
18
|
50
|
|
|
|
128
|
if ( $operator_named_class eq 'Operation_91' ) { # Operation -> OP10_NAMED_UNARY_SCOLON |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
42
|
|
|
|
|
|
|
die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASRP16, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Named operator ' |
43
|
0
|
|
|
|
|
0
|
. q{'} . $operator_named->{children}->[0] . q{'} |
44
|
|
|
|
|
|
|
. ' requires exactly one argument, dying' ) |
45
|
|
|
|
|
|
|
. "\n"; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
elsif ( $operator_named_class eq 'Operator_110' ) { # Operator -> OP10_NAMED_UNARY SubExpression |
48
|
18
|
|
|
|
|
101
|
$rperl_source_group->{PMC} .= $operator_named->{children}->[0] . q{ }; |
49
|
18
|
|
|
|
|
529
|
my string_hashref $rperl_source_subgroup = $operator_named->{children}->[1]->ast_to_rperl__generate( $modes, $self ); |
50
|
18
|
|
|
|
|
544
|
RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup ); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
elsif ( $operator_named_class eq 'Operator_111' ) { # Operator -> OP10_NAMED_UNARY |
53
|
|
|
|
|
|
|
die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASRP16, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Named operator ' |
54
|
0
|
|
|
|
|
0
|
. q{'} . $operator_named->{children}->[0] . q{'} |
55
|
|
|
|
|
|
|
. ' requires exactly one argument, dying' ) |
56
|
|
|
|
|
|
|
. "\n"; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
else { |
59
|
0
|
|
|
|
|
0
|
die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule ' |
60
|
|
|
|
|
|
|
. ($operator_named_class) |
61
|
|
|
|
|
|
|
. ' found where Operation_91, Operator_110, or Operator_111 expected, dying' ) |
62
|
|
|
|
|
|
|
. "\n"; |
63
|
|
|
|
|
|
|
} |
64
|
18
|
|
|
|
|
214
|
return $rperl_source_group; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub ast_to_cpp__generate__CPPOPS_PERLTYPES { |
68
|
0
|
|
|
0
|
|
0
|
{ my string_hashref::method $RETURN_TYPE }; |
|
0
|
|
|
|
|
0
|
|
69
|
0
|
|
|
|
|
0
|
( my object $self, my string_hashref $modes) = @ARG; |
70
|
0
|
|
|
|
|
0
|
my string_hashref $cpp_source_group = { CPP => q{// <<< RP::O::E::O::NU::Sca __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>} . "\n" }; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
#... |
73
|
0
|
|
|
|
|
0
|
return $cpp_source_group; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub ast_to_cpp__generate__CPPOPS_CPPTYPES { |
77
|
2
|
|
|
2
|
|
6
|
{ my string_hashref::method $RETURN_TYPE }; |
|
2
|
|
|
|
|
4
|
|
78
|
2
|
|
|
|
|
5
|
( my object $self, my object $operator_named, my string_hashref $modes) = @ARG; |
79
|
2
|
|
|
|
|
13
|
my string_hashref $cpp_source_group = { CPP => q{} }; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# RPerl::diag( 'in NamedUnary::Scalar->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" ); |
82
|
|
|
|
|
|
|
# RPerl::diag( 'in NamedUnary::Scalar->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $operator_named = ' . "\n" . RPerl::Parser::rperl_ast__dump($operator_named) . "\n" ); |
83
|
|
|
|
|
|
|
|
84
|
2
|
|
|
|
|
9
|
my string $operator_named_class = ref $operator_named; |
85
|
2
|
50
|
|
|
|
12
|
if ( $operator_named_class eq 'Operation_91' ) { # Operation -> OP10_NAMED_UNARY_SCOLON |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
86
|
|
|
|
|
|
|
die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASCP16, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Named operator ' |
87
|
0
|
|
|
|
|
0
|
. q{'} . $operator_named->{children}->[0] . q{'} |
88
|
|
|
|
|
|
|
. ' requires exactly one argument, dying' ) |
89
|
|
|
|
|
|
|
. "\n"; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
elsif ( $operator_named_class eq 'Operator_110' ) { # Operator -> OP10_NAMED_UNARY SubExpression |
92
|
|
|
|
|
|
|
# must have ArrayDereference as only argument |
93
|
2
|
|
|
|
|
6
|
my object $subexpression = $operator_named->{children}->[1]; |
94
|
2
|
|
|
|
|
7
|
my string $subexpression_class = ref $subexpression; |
95
|
2
|
0
|
33
|
|
|
10
|
if ( ( $subexpression_class ne 'SubExpression_154' ) |
|
|
|
33
|
|
|
|
|
96
|
|
|
|
|
|
|
and ( $subexpression_class ne 'ArrayDereference_214' ) |
97
|
|
|
|
|
|
|
and ( $subexpression_class ne 'ArrayDereference_215' ) ) |
98
|
|
|
|
|
|
|
{ |
99
|
|
|
|
|
|
|
die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASCP70, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Named operator ' |
100
|
0
|
|
|
|
|
0
|
. q{'} . $operator_named->{children}->[0] . q{'} |
101
|
|
|
|
|
|
|
. ' requires ArrayDereference argument, received ' |
102
|
|
|
|
|
|
|
. $subexpression_class |
103
|
|
|
|
|
|
|
. ' instead, dying' ) |
104
|
|
|
|
|
|
|
. "\n"; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# unwrap ArrayDereference_214 and ArrayDereference_215 from SubExpression_154 |
108
|
2
|
50
|
|
|
|
8
|
if ( $subexpression_class eq 'SubExpression_154' ) { # SubExpression -> ArrayDereference |
109
|
2
|
|
|
|
|
16
|
$subexpression = $subexpression->{children}->[0]; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
2
|
|
|
|
|
5
|
$subexpression_class = ref $subexpression; |
113
|
2
|
|
|
|
|
4
|
my string_hashref $cpp_source_subgroup; |
114
|
2
|
100
|
|
|
|
8
|
if ( $subexpression_class eq 'ArrayDereference_214' ) { # ArrayDereference -> '@{' Variable '}' |
|
|
50
|
|
|
|
|
|
115
|
1
|
|
|
|
|
32
|
$cpp_source_subgroup = $subexpression->{children}->[1]->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes); |
116
|
1
|
|
|
|
|
24
|
RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup ); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
elsif ( $subexpression_class eq 'ArrayDereference_215' ) { # ArrayDereference -> '@{' OPTIONAL-47 ArrayReference '}' |
119
|
1
|
|
|
|
|
9
|
my object $type_inner_optional = $subexpression->{children}->[1]; |
120
|
1
|
|
|
|
|
3
|
my object $array_reference = $subexpression->{children}->[2]; |
121
|
|
|
|
|
|
|
|
122
|
1
|
50
|
|
|
|
4
|
if ( exists $type_inner_optional->{children}->[0] ) { |
123
|
1
|
|
|
|
|
3
|
$cpp_source_group->{CPP} .= '(('; |
124
|
1
|
|
|
|
|
28
|
$cpp_source_subgroup = $type_inner_optional->{children}->[0]->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes); |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# RPerl::diag( 'in NamedUnary::Scalar->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $cpp_source_subgroup = ' . "\n" . RPerl::Parser::rperl_ast__dump($cpp_source_subgroup) . "\n" ); |
127
|
1
|
|
|
|
|
20
|
RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup ); |
128
|
1
|
|
|
|
|
3
|
$cpp_source_group->{CPP} .= ') '; |
129
|
1
|
|
|
|
|
27
|
$cpp_source_subgroup = $array_reference->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes); |
130
|
1
|
|
|
|
|
21
|
RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup ); |
131
|
1
|
|
|
|
|
4
|
$cpp_source_group->{CPP} .= ')'; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# DEV NOTE: I think we don't have to die here in CPPOPS_PERLTYPES mode??? |
135
|
|
|
|
|
|
|
# DEV NOTE, CORRELATION #rp031: NEED ANSWER: are array dereferences allowed in CPPOPS or not??? |
136
|
|
|
|
|
|
|
else { |
137
|
0
|
|
|
|
|
0
|
die RPerl::Parser::rperl_rule__replace( |
138
|
|
|
|
|
|
|
'ERROR ECOGEASCP13, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Array dereference of array reference must provide data type for array reference in CPPOPS_CPPTYPES mode, but no data type provided, dying' |
139
|
|
|
|
|
|
|
) . "\n"; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
else { |
143
|
0
|
|
|
|
|
0
|
die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASCP00, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule ' |
144
|
|
|
|
|
|
|
. $subexpression_class |
145
|
|
|
|
|
|
|
. ' found where ArrayDereference_214 or ArrayDereference_215 expected, dying' ) |
146
|
|
|
|
|
|
|
. "\n"; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
2
|
|
|
|
|
9
|
$cpp_source_group->{CPP} .= '.' . NAME_CPPOPS_CPPTYPES() . '()'; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
elsif ( $operator_named_class eq 'Operator_111' ) { # Operator -> OP10_NAMED_UNARY |
152
|
|
|
|
|
|
|
die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASCP16, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Named operator ' |
153
|
0
|
|
|
|
|
0
|
. $operator_named->{children}->[0] |
154
|
|
|
|
|
|
|
. ' requires exactly one argument, dying' ) |
155
|
|
|
|
|
|
|
. "\n"; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
else { |
158
|
0
|
|
|
|
|
0
|
die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASCP00, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule ' |
159
|
|
|
|
|
|
|
. ($operator_named_class) |
160
|
|
|
|
|
|
|
. ' found where Operation_91, Operator_110, or Operator_111 expected, dying' ) |
161
|
|
|
|
|
|
|
. "\n"; |
162
|
|
|
|
|
|
|
} |
163
|
2
|
|
|
|
|
9
|
return $cpp_source_group; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
1; # end of class |