| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# [[[ HEADER ]]] |
|
2
|
|
|
|
|
|
|
package RPerl::Operation::Statement::VariableDeclaration; |
|
3
|
3
|
|
|
3
|
|
19
|
use strict; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
72
|
|
|
4
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
74
|
|
|
5
|
3
|
|
|
3
|
|
16
|
use RPerl::AfterSubclass; |
|
|
3
|
|
|
|
|
12
|
|
|
|
3
|
|
|
|
|
387
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = 0.009_000; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# [[[ OO INHERITANCE ]]] |
|
9
|
3
|
|
|
3
|
|
18
|
use parent qw(RPerl::Operation::Statement); |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
15
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# [[[ CRITICS ]]] |
|
12
|
|
|
|
|
|
|
## no critic qw(ProhibitUselessNoCritic ProhibitMagicNumbers RequireCheckedSyscalls) # USER DEFAULT 1: allow numeric values & print operator |
|
13
|
|
|
|
|
|
|
## no critic qw(RequireInterpolationOfMetachars) # USER DEFAULT 2: allow single-quoted control characters & sigils |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# [[[ INCLUDES ]]] |
|
16
|
3
|
|
|
3
|
|
178
|
use Scalar::Util 'blessed'; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
190
|
|
|
17
|
3
|
|
|
3
|
|
19
|
use perlapinames_generated; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
10745
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# [[[ OO PROPERTIES ]]] |
|
20
|
|
|
|
|
|
|
our hashref $properties = {}; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# [[[ SUBROUTINES & OO METHODS ]]] |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub ast_to_rperl__generate { |
|
25
|
598
|
|
|
598
|
|
1454
|
{ my string_hashref::method $RETURN_TYPE }; |
|
|
598
|
|
|
|
|
1409
|
|
|
26
|
598
|
|
|
|
|
1740
|
( my object $self, my string_hashref $modes) = @ARG; |
|
27
|
598
|
|
|
|
|
2401
|
my string_hashref $rperl_source_group = { PMC => q{} }; |
|
28
|
598
|
|
|
|
|
1520
|
my string_hashref $rperl_source_subgroup; |
|
29
|
598
|
|
|
|
|
1629
|
my string $self_class = ref $self; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" ); |
|
32
|
|
|
|
|
|
|
# die 'TMP DEBUG, dying'; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# unwrap VariableDeclaration_195, VariableDeclaration_196, VariableDeclaration_197, and VariableDeclaration_198 from Statement_169 |
|
35
|
598
|
50
|
|
|
|
2769
|
if ( $self_class eq 'Statement_169' ) { # Statement -> VariableDeclaration |
|
36
|
598
|
|
|
|
|
2404
|
$self = $self->{children}->[0]; |
|
37
|
598
|
|
|
|
|
1651
|
$self_class = ref $self; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
598
|
100
|
|
|
|
3155
|
if ( $self_class eq 'VariableDeclaration_195' ) { # VariableDeclaration -> MY Type VARIABLE_SYMBOL ';' |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
41
|
34
|
|
|
|
|
152
|
my string $my = $self->{children}->[0]; |
|
42
|
34
|
|
|
|
|
128
|
my string $type = $self->{children}->[1]->{children}->[0]; |
|
43
|
34
|
|
|
|
|
104
|
my string $symbol = $self->{children}->[2]; |
|
44
|
34
|
|
|
|
|
134
|
my string $semicolon = $self->{children}->[3]; |
|
45
|
|
|
|
|
|
|
|
|
46
|
34
|
|
|
|
|
162
|
my string $symbol_no_sigil = substr $symbol, 1; |
|
47
|
34
|
100
|
100
|
|
|
632
|
if ((exists $perlapinames_generated::FUNCTIONS_DOCUMENTED->{$symbol_no_sigil}) or |
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
48
|
|
|
|
|
|
|
(exists $perlapinames_generated::FUNCTIONS_UNDOCUMENTED->{$symbol_no_sigil}) or |
|
49
|
|
|
|
|
|
|
(exists $perlapinames_generated::VARIABLES_DOCUMENTED->{$symbol_no_sigil}) or |
|
50
|
|
|
|
|
|
|
(exists $perlapinames_generated::VARIABLES_UNDOCUMENTED->{$symbol_no_sigil})) { |
|
51
|
4
|
|
|
|
|
116
|
die 'ERROR ECOGEASRP43, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Perl API name conflict, variable name ' . q{'} |
|
52
|
|
|
|
|
|
|
. $symbol_no_sigil . q{'} |
|
53
|
|
|
|
|
|
|
. ' is the same as a protected function or variable name in the Perl API, please choose a different name, dying' . "\n"; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
30
|
|
|
|
|
216
|
$rperl_source_group->{PMC} .= $my . q{ } . $type . q{ } . $symbol . $semicolon . "\n"; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_rperl__generate(), have $modes->{_symbol_table} = ' . "\n" . Dumper($modes->{_symbol_table}) . "\n" ); |
|
59
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_rperl__generate(), have $modes->{_symbol_table}->{_namespace} = ' . "\n" . Dumper($modes->{_symbol_table}->{_namespace}) . "\n" ); |
|
60
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_rperl__generate(), have $modes->{_symbol_table}->{_subroutine} = ' . "\n" . Dumper($modes->{_symbol_table}->{_subroutine}) . "\n" ); |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# CREATE SYMBOL TABLE ENTRY |
|
63
|
30
|
50
|
|
|
|
208
|
if ( exists $modes->{_symbol_table}->{ $modes->{_symbol_table}->{_namespace} }->{ $modes->{_symbol_table}->{_subroutine} }->{$symbol} ) { |
|
64
|
|
|
|
|
|
|
die 'ERROR ECOGEASRP12, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: variable ' |
|
65
|
|
|
|
|
|
|
. $symbol |
|
66
|
|
|
|
|
|
|
. ' already declared in this scope, namespace ' |
|
67
|
|
|
|
|
|
|
. q{'} . $modes->{_symbol_table}->{_namespace} . q{'} |
|
68
|
|
|
|
|
|
|
. ', subroutine/method ' |
|
69
|
0
|
|
|
|
|
0
|
. q{'} . $modes->{_symbol_table}->{_subroutine} . q{()'} |
|
70
|
|
|
|
|
|
|
. ', dying' . "\n"; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
30
|
|
|
|
|
276
|
$modes->{_symbol_table}->{ $modes->{_symbol_table}->{_namespace} }->{ $modes->{_symbol_table}->{_subroutine} }->{$symbol} |
|
73
|
|
|
|
|
|
|
= { isa => 'RPerl::Operation::Expression::SubExpression::Variable', type => $type }; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
elsif ( $self_class eq 'VariableDeclaration_196' ) { # VariableDeclaration -> MY Type VARIABLE_SYMBOL OP19_VARIABLE_ASSIGN OpNamedScolonOrSubExpIn |
|
76
|
559
|
|
|
|
|
2126
|
my string $my = $self->{children}->[0]; |
|
77
|
559
|
|
|
|
|
1915
|
my string $type = $self->{children}->[1]->{children}->[0]; |
|
78
|
559
|
|
|
|
|
1856
|
my string $symbol = $self->{children}->[2]; |
|
79
|
559
|
|
|
|
|
1690
|
my string $assign = $self->{children}->[3]; |
|
80
|
559
|
|
|
|
|
1408
|
my object $opnamed_or_subexp_or_input_scolon = $self->{children}->[4]; |
|
81
|
|
|
|
|
|
|
|
|
82
|
559
|
|
|
|
|
1830
|
my string $symbol_no_sigil = substr $symbol, 1; |
|
83
|
559
|
50
|
33
|
|
|
8750
|
if ((exists $perlapinames_generated::FUNCTIONS_DOCUMENTED->{$symbol_no_sigil}) or |
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
84
|
|
|
|
|
|
|
(exists $perlapinames_generated::FUNCTIONS_UNDOCUMENTED->{$symbol_no_sigil}) or |
|
85
|
|
|
|
|
|
|
(exists $perlapinames_generated::VARIABLES_DOCUMENTED->{$symbol_no_sigil}) or |
|
86
|
|
|
|
|
|
|
(exists $perlapinames_generated::VARIABLES_UNDOCUMENTED->{$symbol_no_sigil})) { |
|
87
|
0
|
|
|
|
|
0
|
die 'ERROR ECOGEASRP43, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Perl API name conflict, variable name ' . q{'} |
|
88
|
|
|
|
|
|
|
. $symbol_no_sigil . q{'} |
|
89
|
|
|
|
|
|
|
. ' is the same as a protected function or variable name in the Perl API, please choose a different name, dying' . "\n"; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_rperl__generate(), have $opnamed_or_subexp_or_input_scolon = ' . "\n" . RPerl::Parser::rperl_ast__dump($opnamed_or_subexp_or_input_scolon) . "\n" ); |
|
93
|
|
|
|
|
|
|
|
|
94
|
559
|
|
|
|
|
2651
|
$rperl_source_group->{PMC} .= $my . q{ } . $type . q{ } . $symbol . q{ } . $assign . q{ }; |
|
95
|
|
|
|
|
|
|
|
|
96
|
559
|
|
|
|
|
1724
|
my string $opnamed_or_subexp_or_input_scolon_type = ref $opnamed_or_subexp_or_input_scolon; |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_rperl__generate(), have $opnamed_or_subexp_or_input_scolon_type = ' . "\n" . RPerl::Parser::rperl_ast__dump($opnamed_or_subexp_or_input_scolon_type) . "\n" ); |
|
99
|
|
|
|
|
|
|
|
|
100
|
559
|
100
|
100
|
|
|
4421
|
if ( ( $opnamed_or_subexp_or_input_scolon_type eq 'OpNamedScolonOrSubExpIn_253' ) |
|
|
|
50
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
or ( $opnamed_or_subexp_or_input_scolon_type eq 'OpNamedScolonOrSubExpIn_254' ) ) |
|
102
|
|
|
|
|
|
|
{ |
|
103
|
|
|
|
|
|
|
# OpNamedScolonOrSubExpIn -> OP01_NAMED_SCOLON |
|
104
|
|
|
|
|
|
|
# OpNamedScolonOrSubExpIn -> OP10_NAMED_UNARY_SCOLON |
|
105
|
3
|
|
|
|
|
54
|
$rperl_source_group->{PMC} .= $opnamed_or_subexp_or_input_scolon->{children}->[0]; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
elsif ( $opnamed_or_subexp_or_input_scolon_type eq 'OpNamedScolonOrSubExpIn_255' ) { # OpNamedScolonOrSubExpIn -> SubExpressionOrInput ';' |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_rperl__generate(), have (ref $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children}->[0]) = ' . "\n" . RPerl::Parser::rperl_ast__dump((ref $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children}->[0])) . "\n" ); |
|
110
|
|
|
|
|
|
|
|
|
111
|
556
|
100
|
33
|
|
|
45866
|
if ( ( exists $opnamed_or_subexp_or_input_scolon->{children} ) |
|
|
|
100
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
112
|
|
|
|
|
|
|
and ( exists $opnamed_or_subexp_or_input_scolon->{children}->[0] ) |
|
113
|
|
|
|
|
|
|
and ( blessed( $opnamed_or_subexp_or_input_scolon->{children}->[0] ) ) |
|
114
|
|
|
|
|
|
|
and ( exists $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children} ) |
|
115
|
|
|
|
|
|
|
and ( exists $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0] ) |
|
116
|
|
|
|
|
|
|
and ( blessed( $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0] ) ) |
|
117
|
|
|
|
|
|
|
and ( exists $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children} ) |
|
118
|
|
|
|
|
|
|
and ( exists $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children}->[0] ) |
|
119
|
|
|
|
|
|
|
and ( blessed( $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children}->[0] ) ) |
|
120
|
|
|
|
|
|
|
and ( $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children}->[0] |
|
121
|
|
|
|
|
|
|
->isa('RPerl::Operation::Expression::SubroutineCall::MethodCall::ConstructorCall') ) |
|
122
|
|
|
|
|
|
|
) |
|
123
|
|
|
|
|
|
|
{ |
|
124
|
|
|
|
|
|
|
my string $constructor_type |
|
125
|
24
|
|
|
|
|
124
|
= $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children}->[0]->{children}->[0]->{children}->[0]; |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_rperl__generate(), have $constructor_type = ' . "\n" . RPerl::Parser::rperl_ast__dump($constructor_type) . "\n" ); |
|
128
|
|
|
|
|
|
|
|
|
129
|
24
|
100
|
|
|
|
110
|
if ( $type ne $constructor_type ) { |
|
130
|
2
|
|
|
|
|
62
|
die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASRP20, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: data type mismatch, ' . q{'} |
|
131
|
|
|
|
|
|
|
. $type . q{'} |
|
132
|
|
|
|
|
|
|
. ' type is different than ' . q{'} |
|
133
|
|
|
|
|
|
|
. $constructor_type . q{'} |
|
134
|
|
|
|
|
|
|
. ' constructor type, dying' ) |
|
135
|
|
|
|
|
|
|
. "\n"; |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
elsif ( |
|
139
|
|
|
|
|
|
|
( exists $opnamed_or_subexp_or_input_scolon->{children} ) |
|
140
|
|
|
|
|
|
|
and ( exists $opnamed_or_subexp_or_input_scolon->{children}->[0] ) |
|
141
|
|
|
|
|
|
|
and ( blessed( $opnamed_or_subexp_or_input_scolon->{children}->[0] ) ) |
|
142
|
|
|
|
|
|
|
and ( exists $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children} ) |
|
143
|
|
|
|
|
|
|
and ( exists $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0] ) |
|
144
|
|
|
|
|
|
|
and ( blessed( $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0] ) ) |
|
145
|
|
|
|
|
|
|
and ( exists $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children} ) |
|
146
|
|
|
|
|
|
|
and ( exists $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children}->[0] ) |
|
147
|
|
|
|
|
|
|
and ( blessed( $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children}->[0] ) ) |
|
148
|
|
|
|
|
|
|
and ( $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children}->[0]->isa('RPerl::Operation::Expression::SubroutineCall') ) ) |
|
149
|
|
|
|
|
|
|
{ |
|
150
|
|
|
|
|
|
|
my string $constructor_name |
|
151
|
59
|
|
|
|
|
321
|
= $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children}->[0]->{children}->[0]->{children}->[0]; |
|
152
|
59
|
50
|
|
|
|
365
|
if ( $constructor_name =~ m/::new$/xms ) { |
|
153
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $constructor_name = ' . $constructor_name . "\n" ); |
|
154
|
0
|
|
|
|
|
0
|
my string $constructor_type = substr $constructor_name, 0, ( ( length $constructor_name ) - 5 ); |
|
155
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $constructor_type = ' . $constructor_type . "\n" ); |
|
156
|
|
|
|
|
|
|
|
|
157
|
0
|
0
|
|
|
|
0
|
if ( $type ne $constructor_type ) { |
|
158
|
0
|
|
|
|
|
0
|
die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASRP20, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: data type mismatch, ' . q{'} |
|
159
|
|
|
|
|
|
|
. $type . q{'} |
|
160
|
|
|
|
|
|
|
. ' type is different than ' . q{'} |
|
161
|
|
|
|
|
|
|
. $constructor_type . q{'} |
|
162
|
|
|
|
|
|
|
. ' constructor type, dying' ) |
|
163
|
|
|
|
|
|
|
. "\n"; |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
} |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
# CREATE SYMBOL TABLE ENTRY |
|
169
|
|
|
|
|
|
|
# in a *.pl program, you can have variables declared outside of any namespace, which means they are in the default 'main::' namespace AKA '::' using Perl rules |
|
170
|
554
|
50
|
33
|
|
|
5349
|
if ((not exists $modes->{_symbol_table}->{_namespace}) or (not defined $modes->{_symbol_table}->{_namespace})) { |
|
171
|
0
|
|
|
|
|
0
|
$modes->{_symbol_table}->{_namespace} = 'main::'; |
|
172
|
|
|
|
|
|
|
} |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
# in a *.pl program, you can have variables declared outside of any subroutine, which means they are in the default 'main()' subroutine using C++ rules |
|
175
|
554
|
50
|
33
|
|
|
3819
|
if ((not exists $modes->{_symbol_table}->{_subroutine}) or (not defined $modes->{_symbol_table}->{_subroutine})) { |
|
176
|
0
|
|
|
|
|
0
|
$modes->{_symbol_table}->{_subroutine} = 'main'; |
|
177
|
|
|
|
|
|
|
} |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
# RPerl::diag('in VariableDeclaration->ast_to_rperl__generate(), have $symbol = ' . $symbol . "\n"); |
|
180
|
|
|
|
|
|
|
# RPerl::diag('in VariableDeclaration->ast_to_rperl__generate(), have $modes->{_symbol_table} = ' . Dumper($modes->{_symbol_table}) . "\n"); |
|
181
|
|
|
|
|
|
|
# RPerl::diag('in VariableDeclaration->ast_to_rperl__generate(), have $modes->{_symbol_table}->{_namespace} = ' . $modes->{_symbol_table}->{_namespace} . "\n"); |
|
182
|
|
|
|
|
|
|
# RPerl::diag('in VariableDeclaration->ast_to_rperl__generate(), have $modes->{_symbol_table}->{_subroutine} = ' . $modes->{_symbol_table}->{_subroutine} . "\n"); |
|
183
|
|
|
|
|
|
|
|
|
184
|
554
|
50
|
|
|
|
2913
|
if ( exists $modes->{_symbol_table}->{ $modes->{_symbol_table}->{_namespace} }->{ $modes->{_symbol_table}->{_subroutine} }->{$symbol} ) { |
|
185
|
|
|
|
|
|
|
die 'ERROR ECOGEASRP12, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: variable ' |
|
186
|
|
|
|
|
|
|
. $symbol |
|
187
|
|
|
|
|
|
|
. ' already declared in this scope, namespace ' |
|
188
|
|
|
|
|
|
|
. q{'} . $modes->{_symbol_table}->{_namespace} . q{'} |
|
189
|
|
|
|
|
|
|
. ', subroutine/method ' |
|
190
|
0
|
|
|
|
|
0
|
. q{'} . $modes->{_symbol_table}->{_subroutine} . q{()'} |
|
191
|
|
|
|
|
|
|
. ', dying' . "\n"; |
|
192
|
|
|
|
|
|
|
} |
|
193
|
554
|
|
|
|
|
3667
|
$modes->{_symbol_table}->{ $modes->{_symbol_table}->{_namespace} }->{ $modes->{_symbol_table}->{_subroutine} }->{$symbol} |
|
194
|
|
|
|
|
|
|
= { isa => 'RPerl::Operation::Expression::SubExpression::Variable', type => $type }; |
|
195
|
|
|
|
|
|
|
|
|
196
|
554
|
|
|
|
|
15352
|
$rperl_source_subgroup = $opnamed_or_subexp_or_input_scolon->{children}->[0]->ast_to_rperl__generate($modes); # subexpression |
|
197
|
554
|
|
|
|
|
12337
|
RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup ); |
|
198
|
554
|
|
|
|
|
2208
|
$rperl_source_group->{PMC} .= $opnamed_or_subexp_or_input_scolon->{children}->[1]; # semicolon |
|
199
|
|
|
|
|
|
|
} |
|
200
|
|
|
|
|
|
|
else { |
|
201
|
0
|
|
|
|
|
0
|
die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule ' |
|
202
|
|
|
|
|
|
|
. $opnamed_or_subexp_or_input_scolon_type |
|
203
|
|
|
|
|
|
|
. ' found where OpNamedScolonOrSubExpIn_253, OpNamedScolonOrSubExpIn_254, or OpNamedScolonOrSubExpIn_255 expected, dying' ) |
|
204
|
|
|
|
|
|
|
. "\n"; |
|
205
|
|
|
|
|
|
|
} |
|
206
|
|
|
|
|
|
|
|
|
207
|
557
|
|
|
|
|
1853
|
$rperl_source_group->{PMC} .= "\n"; |
|
208
|
|
|
|
|
|
|
} |
|
209
|
|
|
|
|
|
|
elsif ( $self_class eq 'VariableDeclaration_197' ) { # VariableDeclaration -> MY Type VARIABLE_SYMBOL OP02_ARRAY_THINARROW SubExpression ']' OP19_VARIABLE_ASSIGN 'undef' ';' |
|
210
|
4
|
|
|
|
|
45
|
my string $my = $self->{children}->[0]; |
|
211
|
4
|
|
|
|
|
16
|
my string $type = $self->{children}->[1]->{children}->[0]; |
|
212
|
4
|
|
|
|
|
10
|
my string $symbol = $self->{children}->[2]; |
|
213
|
4
|
|
|
|
|
14
|
my string $arrow_left_bracket = $self->{children}->[3]; |
|
214
|
4
|
|
|
|
|
11
|
my object $subexpression = $self->{children}->[4]; |
|
215
|
4
|
|
|
|
|
17
|
my string $right_bracket = $self->{children}->[5]; |
|
216
|
4
|
|
|
|
|
13
|
my string $assign = $self->{children}->[6]; |
|
217
|
4
|
|
|
|
|
16
|
my string $undef = $self->{children}->[7]; |
|
218
|
4
|
|
|
|
|
12
|
my string $semicolon = $self->{children}->[8]; |
|
219
|
|
|
|
|
|
|
|
|
220
|
4
|
|
|
|
|
13
|
my string $symbol_no_sigil = substr $symbol, 1; |
|
221
|
4
|
50
|
33
|
|
|
60
|
if ((exists $perlapinames_generated::FUNCTIONS_DOCUMENTED->{$symbol_no_sigil}) or |
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
222
|
|
|
|
|
|
|
(exists $perlapinames_generated::FUNCTIONS_UNDOCUMENTED->{$symbol_no_sigil}) or |
|
223
|
|
|
|
|
|
|
(exists $perlapinames_generated::VARIABLES_DOCUMENTED->{$symbol_no_sigil}) or |
|
224
|
|
|
|
|
|
|
(exists $perlapinames_generated::VARIABLES_UNDOCUMENTED->{$symbol_no_sigil})) { |
|
225
|
0
|
|
|
|
|
0
|
die 'ERROR ECOGEASRP43, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Perl API name conflict, variable name ' . q{'} |
|
226
|
|
|
|
|
|
|
. $symbol_no_sigil . q{'} |
|
227
|
|
|
|
|
|
|
. ' is the same as a protected function or variable name in the Perl API, please choose a different name, dying' . "\n"; |
|
228
|
|
|
|
|
|
|
} |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
# CREATE SYMBOL TABLE ENTRY |
|
231
|
4
|
50
|
|
|
|
22
|
if ( exists $modes->{_symbol_table}->{ $modes->{_symbol_table}->{_namespace} }->{ $modes->{_symbol_table}->{_subroutine} }->{$symbol} ) { |
|
232
|
|
|
|
|
|
|
die 'ERROR ECOGEASRP12, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: variable ' |
|
233
|
|
|
|
|
|
|
. $symbol |
|
234
|
|
|
|
|
|
|
. ' already declared in this scope, namespace ' |
|
235
|
|
|
|
|
|
|
. q{'} . $modes->{_symbol_table}->{_namespace} . q{'} |
|
236
|
|
|
|
|
|
|
. ', subroutine/method ' |
|
237
|
0
|
|
|
|
|
0
|
. q{'} . $modes->{_symbol_table}->{_subroutine} . q{()'} |
|
238
|
|
|
|
|
|
|
. ', dying' . "\n"; |
|
239
|
|
|
|
|
|
|
} |
|
240
|
4
|
|
|
|
|
28
|
$modes->{_symbol_table}->{ $modes->{_symbol_table}->{_namespace} }->{ $modes->{_symbol_table}->{_subroutine} }->{$symbol} |
|
241
|
|
|
|
|
|
|
= { isa => 'RPerl::Operation::Expression::SubExpression::Variable', type => $type }; |
|
242
|
|
|
|
|
|
|
|
|
243
|
4
|
|
|
|
|
21
|
$rperl_source_group->{PMC} .= $my . q{ } . $type . q{ } . $symbol . $arrow_left_bracket . q{ }; |
|
244
|
4
|
|
|
|
|
105
|
$rperl_source_subgroup = $subexpression->ast_to_rperl__generate($modes); |
|
245
|
4
|
|
|
|
|
91
|
RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup ); |
|
246
|
4
|
|
|
|
|
24
|
$rperl_source_group->{PMC} .= q{ } . $right_bracket . q{ } . $assign . q{ } . $undef . $semicolon . "\n"; |
|
247
|
|
|
|
|
|
|
} |
|
248
|
|
|
|
|
|
|
elsif ( $self_class eq 'VariableDeclaration_198' ) { # VariableDeclaration -> MY TYPE_FHREF FHREF_SYMBOL ';' |
|
249
|
1
|
|
|
|
|
26
|
my string $my = $self->{children}->[0]; |
|
250
|
1
|
|
|
|
|
4
|
my string $type_fhref = $self->{children}->[1]; |
|
251
|
1
|
|
|
|
|
3
|
my string $symbol_fhref = $self->{children}->[2]; |
|
252
|
1
|
|
|
|
|
6
|
my string $semicolon = $self->{children}->[3]; |
|
253
|
|
|
|
|
|
|
|
|
254
|
1
|
|
|
|
|
5
|
my string $symbol_no_sigil = substr $symbol_fhref, 1; |
|
255
|
1
|
50
|
33
|
|
|
22
|
if ((exists $perlapinames_generated::FUNCTIONS_DOCUMENTED->{$symbol_no_sigil}) or |
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
256
|
|
|
|
|
|
|
(exists $perlapinames_generated::FUNCTIONS_UNDOCUMENTED->{$symbol_no_sigil}) or |
|
257
|
|
|
|
|
|
|
(exists $perlapinames_generated::VARIABLES_DOCUMENTED->{$symbol_no_sigil}) or |
|
258
|
|
|
|
|
|
|
(exists $perlapinames_generated::VARIABLES_UNDOCUMENTED->{$symbol_no_sigil})) { |
|
259
|
0
|
|
|
|
|
0
|
die 'ERROR ECOGEASRP43, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Perl API name conflict, variable name ' . q{'} |
|
260
|
|
|
|
|
|
|
. $symbol_no_sigil . q{'} |
|
261
|
|
|
|
|
|
|
. ' is the same as a protected function or variable name in the Perl API, please choose a different name, dying' . "\n"; |
|
262
|
|
|
|
|
|
|
} |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
# CREATE SYMBOL TABLE ENTRY |
|
265
|
1
|
50
|
|
|
|
8
|
if ( exists $modes->{_symbol_table}->{ $modes->{_symbol_table}->{_namespace} }->{ $modes->{_symbol_table}->{_subroutine} }->{$symbol_fhref} ) { |
|
266
|
|
|
|
|
|
|
die 'ERROR ECOGEASRP12, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: variable ' |
|
267
|
|
|
|
|
|
|
. $symbol_fhref |
|
268
|
|
|
|
|
|
|
. ' already declared in this scope, namespace ' |
|
269
|
|
|
|
|
|
|
. q{'} . $modes->{_symbol_table}->{_namespace} . q{'} |
|
270
|
|
|
|
|
|
|
. ', subroutine/method ' |
|
271
|
0
|
|
|
|
|
0
|
. q{'} . $modes->{_symbol_table}->{_subroutine} . q{()'} |
|
272
|
|
|
|
|
|
|
. ', dying' . "\n"; |
|
273
|
|
|
|
|
|
|
} |
|
274
|
1
|
|
|
|
|
11
|
$modes->{_symbol_table}->{ $modes->{_symbol_table}->{_namespace} }->{ $modes->{_symbol_table}->{_subroutine} }->{$symbol_fhref} |
|
275
|
|
|
|
|
|
|
= { isa => 'RPerl::Operation::Expression::SubExpression::Variable', type => $type_fhref }; |
|
276
|
|
|
|
|
|
|
|
|
277
|
1
|
|
|
|
|
8
|
$rperl_source_group->{PMC} .= $my . q{ } . $type_fhref . q{ } . $symbol_fhref . $semicolon . "\n"; |
|
278
|
|
|
|
|
|
|
} |
|
279
|
|
|
|
|
|
|
else { |
|
280
|
0
|
|
|
|
|
0
|
die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule ' |
|
281
|
|
|
|
|
|
|
. $self_class |
|
282
|
|
|
|
|
|
|
. ' found where VariableDeclaration_195, VariableDeclaration_196, VariableDeclaration_197, or VariableDeclaration_198 expected, dying' ) |
|
283
|
|
|
|
|
|
|
. "\n"; |
|
284
|
|
|
|
|
|
|
} |
|
285
|
592
|
|
|
|
|
4590
|
return $rperl_source_group; |
|
286
|
|
|
|
|
|
|
} |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
sub ast_to_cpp__generate__CPPOPS_PERLTYPES { |
|
289
|
0
|
|
|
0
|
|
0
|
{ my string_hashref::method $RETURN_TYPE }; |
|
|
0
|
|
|
|
|
0
|
|
|
290
|
0
|
|
|
|
|
0
|
( my object $self, my string_hashref $modes) = @ARG; |
|
291
|
0
|
|
|
|
|
0
|
my string_hashref $cpp_source_group = { CPP => q{// <<< RP::O::S::VD __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>} . "\n" }; |
|
292
|
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
#... |
|
294
|
0
|
|
|
|
|
0
|
return $cpp_source_group; |
|
295
|
|
|
|
|
|
|
} |
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
sub ast_to_cpp__generate__CPPOPS_CPPTYPES { |
|
298
|
47
|
|
|
47
|
|
87
|
{ my string_hashref::method $RETURN_TYPE }; |
|
|
47
|
|
|
|
|
122
|
|
|
299
|
47
|
|
|
|
|
115
|
( my object $self, my string_hashref $modes) = @ARG; |
|
300
|
47
|
|
|
|
|
154
|
my string_hashref $cpp_source_group = { CPP => q{} }; |
|
301
|
47
|
|
|
|
|
94
|
my string_hashref $cpp_source_subgroup; |
|
302
|
47
|
|
|
|
|
120
|
my string $self_class = ref $self; |
|
303
|
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" ); |
|
305
|
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
# unwrap VariableDeclaration_195, VariableDeclaration_196, VariableDeclaration_197, and VariableDeclaration_198 from Statement_169 |
|
307
|
47
|
50
|
|
|
|
147
|
if ( $self_class eq 'Statement_169' ) { # Statement -> VariableDeclaration |
|
308
|
47
|
|
|
|
|
154
|
$self = $self->{children}->[0]; |
|
309
|
47
|
|
|
|
|
112
|
$self_class = ref $self; |
|
310
|
|
|
|
|
|
|
} |
|
311
|
|
|
|
|
|
|
|
|
312
|
47
|
50
|
|
|
|
182
|
if ( $self_class eq 'VariableDeclaration_195' ) { # VariableDeclaration -> MY Type VARIABLE_SYMBOL ';' |
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
313
|
0
|
|
|
|
|
0
|
my string $type = $self->{children}->[1]->{children}->[0]; |
|
314
|
0
|
|
|
|
|
0
|
my string $symbol = $self->{children}->[2]; |
|
315
|
|
|
|
|
|
|
|
|
316
|
0
|
|
|
|
|
0
|
my string $symbol_no_sigil = substr $symbol, 1; |
|
317
|
0
|
0
|
0
|
|
|
0
|
if ((exists $perlapinames_generated::FUNCTIONS_DOCUMENTED->{$symbol_no_sigil}) or |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
318
|
|
|
|
|
|
|
(exists $perlapinames_generated::FUNCTIONS_UNDOCUMENTED->{$symbol_no_sigil}) or |
|
319
|
|
|
|
|
|
|
(exists $perlapinames_generated::VARIABLES_DOCUMENTED->{$symbol_no_sigil}) or |
|
320
|
|
|
|
|
|
|
(exists $perlapinames_generated::VARIABLES_UNDOCUMENTED->{$symbol_no_sigil})) { |
|
321
|
0
|
|
|
|
|
0
|
die 'ERROR ECOGEASCP43, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Perl API name conflict, variable name ' . q{'} |
|
322
|
|
|
|
|
|
|
. $symbol_no_sigil . q{'} |
|
323
|
|
|
|
|
|
|
. ' is the same as a protected function or variable name in the Perl API, please choose a different name, dying' . "\n"; |
|
324
|
|
|
|
|
|
|
} |
|
325
|
|
|
|
|
|
|
|
|
326
|
0
|
|
|
|
|
0
|
substr $symbol, 0, 1, q{}; # remove leading $ sigil |
|
327
|
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
# CREATE SYMBOL TABLE ENTRY |
|
329
|
0
|
0
|
|
|
|
0
|
if ( exists $modes->{_symbol_table}->{ $modes->{_symbol_table}->{_namespace} }->{ $modes->{_symbol_table}->{_subroutine} }->{$symbol} ) { |
|
330
|
|
|
|
|
|
|
die 'ERROR ECOGEASCP12, CODE GENERATOR, ABSTRACT SYNTAX TO C++: variable ' |
|
331
|
|
|
|
|
|
|
. $symbol |
|
332
|
|
|
|
|
|
|
. ' already declared in this scope, namespace ' |
|
333
|
|
|
|
|
|
|
. q{'} . $modes->{_symbol_table}->{_namespace} . q{'} |
|
334
|
|
|
|
|
|
|
. ', subroutine/method ' |
|
335
|
0
|
|
|
|
|
0
|
. q{'} . $modes->{_symbol_table}->{_subroutine} . q{()'} |
|
336
|
|
|
|
|
|
|
. ', dying' . "\n"; |
|
337
|
|
|
|
|
|
|
} |
|
338
|
0
|
|
|
|
|
0
|
$modes->{_symbol_table}->{ $modes->{_symbol_table}->{_namespace} }->{ $modes->{_symbol_table}->{_subroutine} }->{$symbol} |
|
339
|
|
|
|
|
|
|
= { isa => 'RPerl::Operation::Expression::SubExpression::Variable', type => $type }; |
|
340
|
|
|
|
|
|
|
|
|
341
|
0
|
|
|
|
|
0
|
$type = RPerl::Generator::type_convert_perl_to_cpp( $type, 1 ); # $pointerify_classes = 1 |
|
342
|
0
|
|
|
|
|
0
|
$modes->{_symbol_table}->{ $modes->{_symbol_table}->{_namespace} }->{ $modes->{_symbol_table}->{_subroutine} }->{$symbol}->{type_cpp} = $type; # add converted C++ type to symtab entry |
|
343
|
|
|
|
|
|
|
|
|
344
|
0
|
|
|
|
|
0
|
$cpp_source_group->{CPP} .= $type . q{ } . $symbol . ';' . "\n"; |
|
345
|
|
|
|
|
|
|
} |
|
346
|
|
|
|
|
|
|
elsif ( $self_class eq 'VariableDeclaration_196' ) { # VariableDeclaration -> MY Type VARIABLE_SYMBOL OP19_VARIABLE_ASSIGN OpNamedScolonOrSubExpIn |
|
347
|
47
|
|
|
|
|
213
|
my string $type = $self->{children}->[1]->{children}->[0]; |
|
348
|
47
|
|
|
|
|
130
|
my string $symbol = $self->{children}->[2]; |
|
349
|
47
|
|
|
|
|
115
|
my string $assign = $self->{children}->[3]; |
|
350
|
47
|
|
|
|
|
123
|
my object $opnamed_or_subexp_or_input_scolon = $self->{children}->[4]; |
|
351
|
|
|
|
|
|
|
|
|
352
|
47
|
|
|
|
|
129
|
my string $symbol_no_sigil = substr $symbol, 1; |
|
353
|
47
|
50
|
33
|
|
|
583
|
if ((exists $perlapinames_generated::FUNCTIONS_DOCUMENTED->{$symbol_no_sigil}) or |
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
354
|
|
|
|
|
|
|
(exists $perlapinames_generated::FUNCTIONS_UNDOCUMENTED->{$symbol_no_sigil}) or |
|
355
|
|
|
|
|
|
|
(exists $perlapinames_generated::VARIABLES_DOCUMENTED->{$symbol_no_sigil}) or |
|
356
|
|
|
|
|
|
|
(exists $perlapinames_generated::VARIABLES_UNDOCUMENTED->{$symbol_no_sigil})) { |
|
357
|
0
|
|
|
|
|
0
|
die 'ERROR ECOGEASCP43, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Perl API name conflict, variable name ' . q{'} |
|
358
|
|
|
|
|
|
|
. $symbol_no_sigil . q{'} |
|
359
|
|
|
|
|
|
|
. ' is the same as a protected function or variable name in the Perl API, please choose a different name, dying' . "\n"; |
|
360
|
|
|
|
|
|
|
} |
|
361
|
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $opnamed_or_subexp_or_input_scolon = ' . "\n" . RPerl::Parser::rperl_ast__dump($opnamed_or_subexp_or_input_scolon) . "\n" ); |
|
363
|
|
|
|
|
|
|
|
|
364
|
47
|
|
|
|
|
109
|
substr $symbol, 0, 1, q{}; # remove leading $ sigil |
|
365
|
47
|
|
|
|
|
86
|
my boolean $is_constructor_call_normal = 0; |
|
366
|
47
|
|
|
|
|
80
|
my boolean $is_constructor_call_special = 0; |
|
367
|
|
|
|
|
|
|
|
|
368
|
47
|
|
|
|
|
101
|
my string $opnamed_or_subexp_or_input_scolon_type = ref $opnamed_or_subexp_or_input_scolon; |
|
369
|
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $opnamed_or_subexp_or_input_scolon_type = ' . "\n" . RPerl::Parser::rperl_ast__dump($opnamed_or_subexp_or_input_scolon_type) . "\n" ); |
|
371
|
|
|
|
|
|
|
|
|
372
|
47
|
50
|
33
|
|
|
312
|
if ( ( $opnamed_or_subexp_or_input_scolon_type eq 'OpNamedScolonOrSubExpIn_253' ) |
|
|
|
50
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
or ( $opnamed_or_subexp_or_input_scolon_type eq 'OpNamedScolonOrSubExpIn_254' ) ) |
|
374
|
|
|
|
|
|
|
{ |
|
375
|
|
|
|
|
|
|
# OpNamedScolonOrSubExpIn -> OP01_NAMED_SCOLON |
|
376
|
|
|
|
|
|
|
# OpNamedScolonOrSubExpIn -> OP10_NAMED_UNARY_SCOLON |
|
377
|
0
|
|
|
|
|
0
|
$cpp_source_group->{CPP} .= $opnamed_or_subexp_or_input_scolon->{children}->[0]; |
|
378
|
|
|
|
|
|
|
} |
|
379
|
|
|
|
|
|
|
elsif ( $opnamed_or_subexp_or_input_scolon_type eq 'OpNamedScolonOrSubExpIn_255' ) { # OpNamedScolonOrSubExpIn -> SubExpressionOrInput ';' |
|
380
|
47
|
100
|
33
|
|
|
3883
|
if ( ( exists $opnamed_or_subexp_or_input_scolon->{children} ) |
|
|
|
100
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
381
|
|
|
|
|
|
|
and ( exists $opnamed_or_subexp_or_input_scolon->{children}->[0] ) |
|
382
|
|
|
|
|
|
|
and ( blessed( $opnamed_or_subexp_or_input_scolon->{children}->[0] ) ) |
|
383
|
|
|
|
|
|
|
and ( exists $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children} ) |
|
384
|
|
|
|
|
|
|
and ( exists $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0] ) |
|
385
|
|
|
|
|
|
|
and ( blessed( $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0] ) ) |
|
386
|
|
|
|
|
|
|
and ( exists $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children} ) |
|
387
|
|
|
|
|
|
|
and ( exists $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children}->[0] ) |
|
388
|
|
|
|
|
|
|
and ( blessed( $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children}->[0] ) ) |
|
389
|
|
|
|
|
|
|
and ( $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children}->[0] |
|
390
|
|
|
|
|
|
|
->isa('RPerl::Operation::Expression::SubroutineCall::MethodCall::ConstructorCall') ) |
|
391
|
|
|
|
|
|
|
) |
|
392
|
|
|
|
|
|
|
{ |
|
393
|
2
|
|
|
|
|
6
|
$is_constructor_call_normal = 1; |
|
394
|
|
|
|
|
|
|
my string $constructor_type |
|
395
|
2
|
|
|
|
|
8
|
= $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children}->[0]->{children}->[0]->{children}->[0]; |
|
396
|
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $constructor_type = ' . "\n" . RPerl::Parser::rperl_ast__dump($constructor_type) . "\n" ); |
|
398
|
|
|
|
|
|
|
|
|
399
|
2
|
50
|
|
|
|
9
|
if ( $type ne $constructor_type ) { |
|
400
|
0
|
|
|
|
|
0
|
die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASCP20, CODE GENERATOR, ABSTRACT SYNTAX TO C++: data type mismatch, ' . q{'} |
|
401
|
|
|
|
|
|
|
. $type . q{'} |
|
402
|
|
|
|
|
|
|
. ' type is different than ' . q{'} |
|
403
|
|
|
|
|
|
|
. $constructor_type . q{'} |
|
404
|
|
|
|
|
|
|
. ' constructor type, dying' ) |
|
405
|
|
|
|
|
|
|
. "\n"; |
|
406
|
|
|
|
|
|
|
} |
|
407
|
|
|
|
|
|
|
} |
|
408
|
|
|
|
|
|
|
elsif ( |
|
409
|
|
|
|
|
|
|
( exists $opnamed_or_subexp_or_input_scolon->{children} ) |
|
410
|
|
|
|
|
|
|
and ( exists $opnamed_or_subexp_or_input_scolon->{children}->[0] ) |
|
411
|
|
|
|
|
|
|
and ( blessed( $opnamed_or_subexp_or_input_scolon->{children}->[0] ) ) |
|
412
|
|
|
|
|
|
|
and ( exists $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children} ) |
|
413
|
|
|
|
|
|
|
and ( exists $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0] ) |
|
414
|
|
|
|
|
|
|
and ( blessed( $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0] ) ) |
|
415
|
|
|
|
|
|
|
and ( exists $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children} ) |
|
416
|
|
|
|
|
|
|
and ( exists $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children}->[0] ) |
|
417
|
|
|
|
|
|
|
and ( blessed( $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children}->[0] ) ) |
|
418
|
|
|
|
|
|
|
and ( $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children}->[0]->isa('RPerl::Operation::Expression::SubroutineCall') ) ) |
|
419
|
|
|
|
|
|
|
{ |
|
420
|
|
|
|
|
|
|
my string $constructor_name |
|
421
|
1
|
|
|
|
|
8
|
= $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children}->[0]->{children}->[0]->{children}->[0]; |
|
422
|
1
|
50
|
|
|
|
7
|
if ( $constructor_name =~ m/::new$/xms ) { |
|
423
|
0
|
|
|
|
|
0
|
$is_constructor_call_special = 1; |
|
424
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $constructor_name = ' . $constructor_name . "\n" ); |
|
425
|
0
|
|
|
|
|
0
|
my string $constructor_type = substr $constructor_name, 0, ( ( length $constructor_name ) - 5 ); |
|
426
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $constructor_type = ' . $constructor_type . "\n" ); |
|
427
|
|
|
|
|
|
|
|
|
428
|
0
|
0
|
|
|
|
0
|
if ( $type ne $constructor_type ) { |
|
429
|
0
|
|
|
|
|
0
|
die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASCP20, CODE GENERATOR, ABSTRACT SYNTAX TO C++: data type mismatch, ' . q{'} |
|
430
|
|
|
|
|
|
|
. $type . q{'} |
|
431
|
|
|
|
|
|
|
. ' type is different than ' . q{'} |
|
432
|
|
|
|
|
|
|
. $constructor_type . q{'} |
|
433
|
|
|
|
|
|
|
. ' constructor type, dying' ) |
|
434
|
|
|
|
|
|
|
. "\n"; |
|
435
|
|
|
|
|
|
|
} |
|
436
|
|
|
|
|
|
|
} |
|
437
|
|
|
|
|
|
|
} |
|
438
|
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
# CREATE SYMBOL TABLE ENTRY |
|
440
|
|
|
|
|
|
|
# in a *.pl program, you can have variables declared outside of any namespace, which means they are in the default 'main::' namespace AKA '::' using Perl rules |
|
441
|
47
|
50
|
33
|
|
|
340
|
if ((not exists $modes->{_symbol_table}->{_namespace}) or (not defined $modes->{_symbol_table}->{_namespace})) { |
|
442
|
0
|
|
|
|
|
0
|
$modes->{_symbol_table}->{_namespace} = 'main::'; |
|
443
|
|
|
|
|
|
|
} |
|
444
|
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
# in a *.pl program, you can have variables declared outside of any subroutine, which means they are in the default 'main()' subroutine using C++ rules |
|
446
|
47
|
50
|
33
|
|
|
284
|
if ((not exists $modes->{_symbol_table}->{_subroutine}) or (not defined $modes->{_symbol_table}->{_subroutine})) { |
|
447
|
0
|
|
|
|
|
0
|
$modes->{_symbol_table}->{_subroutine} = 'main'; |
|
448
|
|
|
|
|
|
|
} |
|
449
|
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
# RPerl::diag('in VariableDeclaration->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $symbol = ' . $symbol . "\n"); |
|
451
|
|
|
|
|
|
|
# RPerl::diag('in VariableDeclaration->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $modes->{_symbol_table} = ' . Dumper($modes->{_symbol_table}) . "\n"); |
|
452
|
|
|
|
|
|
|
# RPerl::diag('in VariableDeclaration->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $modes->{_symbol_table}->{_namespace} = ' . $modes->{_symbol_table}->{_namespace} . "\n"); |
|
453
|
|
|
|
|
|
|
# RPerl::diag('in VariableDeclaration->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $modes->{_symbol_table}->{_subroutine} = ' . $modes->{_symbol_table}->{_subroutine} . "\n"); |
|
454
|
|
|
|
|
|
|
|
|
455
|
47
|
50
|
|
|
|
203
|
if ( exists $modes->{_symbol_table}->{ $modes->{_symbol_table}->{_namespace} }->{ $modes->{_symbol_table}->{_subroutine} }->{$symbol} ) { |
|
456
|
|
|
|
|
|
|
die 'ERROR ECOGEASCP12, CODE GENERATOR, ABSTRACT SYNTAX TO C++: variable ' |
|
457
|
|
|
|
|
|
|
. $symbol |
|
458
|
|
|
|
|
|
|
. ' already declared in this scope, namespace ' |
|
459
|
|
|
|
|
|
|
. q{'} . $modes->{_symbol_table}->{_namespace} . q{'} |
|
460
|
|
|
|
|
|
|
. ', subroutine/method ' |
|
461
|
0
|
|
|
|
|
0
|
. q{'} . $modes->{_symbol_table}->{_subroutine} . q{()'} |
|
462
|
|
|
|
|
|
|
. ', dying' . "\n"; |
|
463
|
|
|
|
|
|
|
} |
|
464
|
47
|
|
|
|
|
267
|
$modes->{_symbol_table}->{ $modes->{_symbol_table}->{_namespace} }->{ $modes->{_symbol_table}->{_subroutine} }->{$symbol} |
|
465
|
|
|
|
|
|
|
= { isa => 'RPerl::Operation::Expression::SubExpression::Variable', type => $type }; |
|
466
|
|
|
|
|
|
|
|
|
467
|
47
|
|
|
|
|
1125
|
$type = RPerl::Generator::type_convert_perl_to_cpp( $type, 1 ); # $pointerify_classes = 1 |
|
468
|
47
|
|
|
|
|
189
|
$modes->{_symbol_table}->{ $modes->{_symbol_table}->{_namespace} }->{ $modes->{_symbol_table}->{_subroutine} }->{$symbol}->{type_cpp} = $type; # add converted C++ type to symtab entry |
|
469
|
|
|
|
|
|
|
|
|
470
|
47
|
|
|
|
|
154
|
$cpp_source_group->{CPP} .= $type . q{ } . $symbol; |
|
471
|
|
|
|
|
|
|
|
|
472
|
47
|
100
|
|
|
|
171
|
if ($is_constructor_call_normal) { |
|
|
|
50
|
|
|
|
|
|
|
473
|
2
|
50
|
|
|
|
12
|
if ( not exists $rperlnamespaces_generated::RPERL->{ $type . '::' } ) { # not scalar or SSE number pair |
|
474
|
2
|
|
|
|
|
5
|
$cpp_source_group->{CPP} .= '('; |
|
475
|
2
|
|
|
|
|
67
|
$cpp_source_subgroup = $opnamed_or_subexp_or_input_scolon->{children}->[0]->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes); # subexpression |
|
476
|
2
|
|
|
|
|
45
|
RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup ); |
|
477
|
2
|
|
|
|
|
6
|
$cpp_source_group->{CPP} .= ')'; |
|
478
|
|
|
|
|
|
|
} |
|
479
|
|
|
|
|
|
|
# purposefully do nothing here, no code needed |
|
480
|
|
|
|
|
|
|
} |
|
481
|
|
|
|
|
|
|
elsif ($is_constructor_call_special) { |
|
482
|
0
|
0
|
|
|
|
0
|
if ( exists $rperlnamespaces_generated::RPERL->{ $type . '::' } ) { |
|
483
|
0
|
0
|
0
|
|
|
0
|
if (($type eq 'integer_arrayref_arrayref') or ($type eq 'number_arrayref_arrayref') or ($type eq 'string_arrayref_arrayref')) { |
|
|
|
|
0
|
|
|
|
|
|
484
|
0
|
|
|
|
|
0
|
my string $base_type = (split /_/, $type)[0]; |
|
485
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $base_type = ' . $base_type . "\n" ); |
|
486
|
0
|
|
|
|
|
0
|
$cpp_source_group->{CPP} .= '('; |
|
487
|
0
|
0
|
|
|
|
0
|
if (not exists $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children}->[0]->{children}->[2]->{children}->[0]->{children}->[0]->{children}->[0]->{children}->[0]->{children}->[0]->{children}->[0]) { |
|
|
|
0
|
|
|
|
|
|
|
488
|
0
|
|
|
|
|
0
|
die 'ERROR ECOGEASCP60, CODE GENERATOR, ABSTRACT SYNTAX TO C++: first argument missing, constructor for type ' . $type . ', dying' . "\n"; |
|
489
|
|
|
|
|
|
|
} |
|
490
|
|
|
|
|
|
|
elsif (not exists $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children}->[0]->{children}->[2]->{children}->[0]->{children}->[1]->{children}->[1]->{children}->[0]->{children}->[0]->{children}->[0]->{children}->[0]) { |
|
491
|
0
|
|
|
|
|
0
|
die 'ERROR ECOGEASCP61, CODE GENERATOR, ABSTRACT SYNTAX TO C++: second argument missing, constructor for type ' . $type . ', dying' . "\n"; |
|
492
|
|
|
|
|
|
|
} |
|
493
|
0
|
|
|
|
|
0
|
my string $row_count_argument = $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children}->[0]->{children}->[2]->{children}->[0]->{children}->[0]->{children}->[0]->{children}->[0]->{children}->[0]->{children}->[0]; |
|
494
|
0
|
|
|
|
|
0
|
substr $row_count_argument, 0, 1, q{}; # remove leading '$' sigil |
|
495
|
0
|
|
|
|
|
0
|
$cpp_source_group->{CPP} .= $row_count_argument . ', ' . $base_type . '_arrayref('; |
|
496
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $opnamed_or_subexp_or_input_scolon->... = ' . "\n" . RPerl::Parser::rperl_ast__dump($opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children}->[0]->{children}->[2]->{children}->[0]->{children}->[1]->{children}->[1]->{children}->[0]->{children}->[0]->{children}->[0]->{children}->[0]) . "\n" ); |
|
497
|
0
|
|
|
|
|
0
|
my string $column_count_argument = $opnamed_or_subexp_or_input_scolon->{children}->[0]->{children}->[0]->{children}->[0]->{children}->[2]->{children}->[0]->{children}->[1]->{children}->[1]->{children}->[0]->{children}->[0]->{children}->[0]->{children}->[0]; |
|
498
|
0
|
|
|
|
|
0
|
substr $column_count_argument, 0, 1, q{}; # remove leading '$' sigil |
|
499
|
0
|
|
|
|
|
0
|
$cpp_source_group->{CPP} .= $column_count_argument . '))'; |
|
500
|
|
|
|
|
|
|
} |
|
501
|
|
|
|
|
|
|
else { |
|
502
|
0
|
|
|
|
|
0
|
die 'ERROR ECOGEASCP62, CODE GENERATOR, ABSTRACT SYNTAX TO C++: constructor called for recognized but currently unsupported type ' . $type . ', dying' . "\n"; |
|
503
|
|
|
|
|
|
|
} |
|
504
|
|
|
|
|
|
|
} |
|
505
|
|
|
|
|
|
|
else { |
|
506
|
0
|
|
|
|
|
0
|
die 'ERROR ECOGEASCP63, CODE GENERATOR, ABSTRACT SYNTAX TO C++: constructor called for unrecognized type ' . $type . ', dying' . "\n"; |
|
507
|
|
|
|
|
|
|
} |
|
508
|
|
|
|
|
|
|
} |
|
509
|
|
|
|
|
|
|
else { |
|
510
|
|
|
|
|
|
|
|
|
511
|
45
|
|
|
|
|
134
|
my $subexpression = $opnamed_or_subexp_or_input_scolon->{children}->[0]; |
|
512
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $subexpression = ' . "\n" . RPerl::Parser::rperl_ast__dump($subexpression) . "\n" ); |
|
513
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have (ref $subexpression) = ' . (ref $subexpression) . "\n" ); |
|
514
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have (ref $subexpression->{children}->[0]) = ' . (ref $subexpression->{children}->[0]) . "\n" ); |
|
515
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have (ref $subexpression->{children}->[0]->{children}->[0]) = ' . (ref $subexpression->{children}->[0]->{children}->[0]) . "\n" ); |
|
516
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have (ref $subexpression->{children}->[0]->{children}->[0]->{children}->[1]) = ' . (ref $subexpression->{children}->[0]->{children}->[0]->{children}->[1]) . "\n" ); |
|
517
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $subexpression->{children}->[0]->{children}->[0]->{children}->[1]->{children} = ' . "\n" . $subexpression->{children}->[0]->{children}->[0]->{children}->[1]->{children} . "\n" ); |
|
518
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $subexpression->{children}->[0]->{children}->[0]->{children}->[1]->{children} = ' . "\n" . Dumper($subexpression->{children}->[0]->{children}->[0]->{children}->[1]->{children}) . "\n" ); |
|
519
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have scalar @{$subexpression->{children}->[0]->{children}->[0]->{children}->[1]->{children}} = ' . "\n" . (scalar @{$subexpression->{children}->[0]->{children}->[0]->{children}->[1]->{children}}) . "\n" ); |
|
520
|
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
# test for empty array ref as value for variable initialization, discard in C++ |
|
522
|
45
|
100
|
33
|
|
|
1206
|
if ( |
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
523
|
|
|
|
|
|
|
(blessed $subexpression) and |
|
524
|
|
|
|
|
|
|
((ref $subexpression) eq 'SubExpressionOrInput_158') and |
|
525
|
|
|
|
|
|
|
(exists $subexpression->{children}) and |
|
526
|
|
|
|
|
|
|
(defined $subexpression->{children}) and |
|
527
|
|
|
|
|
|
|
(defined $subexpression->{children}->[0]) and |
|
528
|
|
|
|
|
|
|
(blessed $subexpression->{children}->[0]) and |
|
529
|
|
|
|
|
|
|
((ref $subexpression->{children}->[0]) eq 'SubExpression_153') and |
|
530
|
|
|
|
|
|
|
(exists $subexpression->{children}->[0]->{children}) and |
|
531
|
|
|
|
|
|
|
(defined $subexpression->{children}->[0]->{children}) and |
|
532
|
|
|
|
|
|
|
(defined $subexpression->{children}->[0]->{children}->[0]) and |
|
533
|
|
|
|
|
|
|
(blessed $subexpression->{children}->[0]->{children}->[0]) and |
|
534
|
|
|
|
|
|
|
((ref $subexpression->{children}->[0]->{children}->[0]) eq 'ArrayReference_211') and |
|
535
|
|
|
|
|
|
|
(exists $subexpression->{children}->[0]->{children}->[0]->{children}) and |
|
536
|
|
|
|
|
|
|
(defined $subexpression->{children}->[0]->{children}->[0]->{children}) and |
|
537
|
|
|
|
|
|
|
(defined $subexpression->{children}->[0]->{children}->[0]->{children}->[0]) and |
|
538
|
|
|
|
|
|
|
( $subexpression->{children}->[0]->{children}->[0]->{children}->[0] eq '[') and |
|
539
|
|
|
|
|
|
|
(defined $subexpression->{children}->[0]->{children}->[0]->{children}->[1]) and |
|
540
|
|
|
|
|
|
|
(blessed $subexpression->{children}->[0]->{children}->[0]->{children}->[1]) and |
|
541
|
|
|
|
|
|
|
((ref $subexpression->{children}->[0]->{children}->[0]->{children}->[1]) eq '_OPTIONAL') and |
|
542
|
|
|
|
|
|
|
(exists $subexpression->{children}->[0]->{children}->[0]->{children}->[1]->{children}) and |
|
543
|
|
|
|
|
|
|
(defined $subexpression->{children}->[0]->{children}->[0]->{children}->[1]->{children}) and |
|
544
|
6
|
|
|
|
|
238
|
((scalar @{$subexpression->{children}->[0]->{children}->[0]->{children}->[1]->{children}}) == 0) and |
|
545
|
|
|
|
|
|
|
(defined $subexpression->{children}->[0]->{children}->[0]->{children}->[2]) and |
|
546
|
|
|
|
|
|
|
( $subexpression->{children}->[0]->{children}->[0]->{children}->[2] eq ']') |
|
547
|
|
|
|
|
|
|
) { |
|
548
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have empty array ref' . "\n"); |
|
549
|
1
|
|
|
|
|
4
|
1; # do nothing |
|
550
|
|
|
|
|
|
|
} |
|
551
|
|
|
|
|
|
|
else { |
|
552
|
44
|
|
|
|
|
147
|
$cpp_source_group->{CPP} .= q{ } . $assign . q{ }; |
|
553
|
44
|
|
|
|
|
1082
|
$cpp_source_subgroup = $opnamed_or_subexp_or_input_scolon->{children}->[0]->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes); # subexpression |
|
554
|
44
|
|
|
|
|
932
|
RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup ); |
|
555
|
|
|
|
|
|
|
} |
|
556
|
|
|
|
|
|
|
} |
|
557
|
47
|
|
|
|
|
167
|
$cpp_source_group->{CPP} .= $opnamed_or_subexp_or_input_scolon->{children}->[1]; # semicolon |
|
558
|
|
|
|
|
|
|
} |
|
559
|
|
|
|
|
|
|
else { |
|
560
|
0
|
|
|
|
|
0
|
die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASCP00, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule ' |
|
561
|
|
|
|
|
|
|
. $opnamed_or_subexp_or_input_scolon_type |
|
562
|
|
|
|
|
|
|
. ' found where OpNamedScolonOrSubExpIn_253, OpNamedScolonOrSubExpIn_254, or OpNamedScolonOrSubExpIn_255 expected, dying' ) |
|
563
|
|
|
|
|
|
|
. "\n"; |
|
564
|
|
|
|
|
|
|
} |
|
565
|
|
|
|
|
|
|
|
|
566
|
47
|
|
|
|
|
154
|
$cpp_source_group->{CPP} .= "\n"; |
|
567
|
|
|
|
|
|
|
} |
|
568
|
|
|
|
|
|
|
elsif ( $self_class eq 'VariableDeclaration_197' ) { # VariableDeclaration -> MY Type VARIABLE_SYMBOL OP02_ARRAY_THINARROW SubExpression ']' OP19_VARIABLE_ASSIGN 'undef' ';' |
|
569
|
0
|
|
|
|
|
0
|
my string $type = $self->{children}->[1]->{children}->[0]; |
|
570
|
0
|
|
|
|
|
0
|
my string $symbol = $self->{children}->[2]; |
|
571
|
0
|
|
|
|
|
0
|
my object $subexpression = $self->{children}->[4]; |
|
572
|
0
|
|
|
|
|
0
|
my string $semicolon = $self->{children}->[8]; |
|
573
|
|
|
|
|
|
|
|
|
574
|
0
|
|
|
|
|
0
|
my string $symbol_no_sigil = substr $symbol, 1; |
|
575
|
0
|
0
|
0
|
|
|
0
|
if ((exists $perlapinames_generated::FUNCTIONS_DOCUMENTED->{$symbol_no_sigil}) or |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
576
|
|
|
|
|
|
|
(exists $perlapinames_generated::FUNCTIONS_UNDOCUMENTED->{$symbol_no_sigil}) or |
|
577
|
|
|
|
|
|
|
(exists $perlapinames_generated::VARIABLES_DOCUMENTED->{$symbol_no_sigil}) or |
|
578
|
|
|
|
|
|
|
(exists $perlapinames_generated::VARIABLES_UNDOCUMENTED->{$symbol_no_sigil})) { |
|
579
|
0
|
|
|
|
|
0
|
die 'ERROR ECOGEASCP43, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Perl API name conflict, variable name ' . q{'} |
|
580
|
|
|
|
|
|
|
. $symbol_no_sigil . q{'} |
|
581
|
|
|
|
|
|
|
. ' is the same as a protected function or variable name in the Perl API, please choose a different name, dying' . "\n"; |
|
582
|
|
|
|
|
|
|
} |
|
583
|
|
|
|
|
|
|
|
|
584
|
0
|
|
|
|
|
0
|
substr $symbol, 0, 1, q{}; # remove leading $ sigil |
|
585
|
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
# RPerl::diag( 'in VariableDeclaration->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $subexpression = ' . RPerl::Parser::rperl_ast__dump($subexpression) . "\n" ); |
|
587
|
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
# CREATE SYMBOL TABLE ENTRY |
|
589
|
0
|
0
|
|
|
|
0
|
if ( exists $modes->{_symbol_table}->{ $modes->{_symbol_table}->{_namespace} }->{ $modes->{_symbol_table}->{_subroutine} }->{$symbol} ) { |
|
590
|
|
|
|
|
|
|
die 'ERROR ECOGEASCP12, CODE GENERATOR, ABSTRACT SYNTAX TO C++: variable ' |
|
591
|
|
|
|
|
|
|
. $symbol |
|
592
|
|
|
|
|
|
|
. ' already declared in this scope, namespace ' |
|
593
|
|
|
|
|
|
|
. q{'} . $modes->{_symbol_table}->{_namespace} . q{'} |
|
594
|
|
|
|
|
|
|
. ', subroutine/method ' |
|
595
|
0
|
|
|
|
|
0
|
. q{'} . $modes->{_symbol_table}->{_subroutine} . q{()'} |
|
596
|
|
|
|
|
|
|
. ', dying' . "\n"; |
|
597
|
|
|
|
|
|
|
} |
|
598
|
0
|
|
|
|
|
0
|
$modes->{_symbol_table}->{ $modes->{_symbol_table}->{_namespace} }->{ $modes->{_symbol_table}->{_subroutine} }->{$symbol} |
|
599
|
|
|
|
|
|
|
= { isa => 'RPerl::Operation::Expression::SubExpression::Variable', type => $type }; |
|
600
|
|
|
|
|
|
|
|
|
601
|
0
|
|
|
|
|
0
|
$type = RPerl::Generator::type_convert_perl_to_cpp( $type, 1 ); # $pointerify_classes = 1 |
|
602
|
0
|
|
|
|
|
0
|
$modes->{_symbol_table}->{ $modes->{_symbol_table}->{_namespace} }->{ $modes->{_symbol_table}->{_subroutine} }->{$symbol}->{type_cpp} = $type; # add converted C++ type to symtab entry |
|
603
|
|
|
|
|
|
|
|
|
604
|
0
|
|
|
|
|
0
|
my string $subexpression_address = "$subexpression"; |
|
605
|
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
# POSSIBLE COMPILE-TIME OPTIMIZATION #01: avoids compensation addition below |
|
607
|
0
|
|
|
|
|
0
|
$subexpression = RPerl::Generator::arrayref_convert_index_max_to_size($subexpression); |
|
608
|
|
|
|
|
|
|
|
|
609
|
0
|
|
|
|
|
0
|
$cpp_source_group->{CPP} .= $type . q{ } . $symbol . $semicolon . "\n"; |
|
610
|
0
|
|
|
|
|
0
|
$cpp_source_group->{CPP} .= $symbol . q{.resize(}; |
|
611
|
0
|
|
|
|
|
0
|
$cpp_source_subgroup = $subexpression->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes); |
|
612
|
0
|
0
|
|
|
|
0
|
if ( $subexpression_address eq "$subexpression" ) { # not compensated automatically, must compensate manually |
|
613
|
|
|
|
|
|
|
# 'foo() * $bar' becomes '(foo() * $bar) + 1' |
|
614
|
0
|
|
|
|
|
0
|
$cpp_source_subgroup->{CPP} = q{(} . $cpp_source_subgroup->{CPP} . q{) + 1}; |
|
615
|
|
|
|
|
|
|
} |
|
616
|
0
|
|
|
|
|
0
|
RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup ); |
|
617
|
0
|
|
|
|
|
0
|
$cpp_source_group->{CPP} .= q{)} . $semicolon . "\n"; |
|
618
|
|
|
|
|
|
|
} |
|
619
|
|
|
|
|
|
|
elsif ( $self_class eq 'VariableDeclaration_198' ) { # VariableDeclaration -> MY TYPE_FHREF FHREF_SYMBOL ';' |
|
620
|
0
|
|
|
|
|
0
|
my string $type_fhref = $self->{children}->[1]; |
|
621
|
0
|
|
|
|
|
0
|
my string $symbol_fhref = $self->{children}->[2]; |
|
622
|
|
|
|
|
|
|
|
|
623
|
0
|
|
|
|
|
0
|
my string $symbol_no_sigil = substr $symbol_fhref, 1; |
|
624
|
0
|
0
|
0
|
|
|
0
|
if ((exists $perlapinames_generated::FUNCTIONS_DOCUMENTED->{$symbol_no_sigil}) or |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
625
|
|
|
|
|
|
|
(exists $perlapinames_generated::FUNCTIONS_UNDOCUMENTED->{$symbol_no_sigil}) or |
|
626
|
|
|
|
|
|
|
(exists $perlapinames_generated::VARIABLES_DOCUMENTED->{$symbol_no_sigil}) or |
|
627
|
|
|
|
|
|
|
(exists $perlapinames_generated::VARIABLES_UNDOCUMENTED->{$symbol_no_sigil})) { |
|
628
|
0
|
|
|
|
|
0
|
die 'ERROR ECOGEASCP43, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Perl API name conflict, variable name ' . q{'} |
|
629
|
|
|
|
|
|
|
. $symbol_no_sigil . q{'} |
|
630
|
|
|
|
|
|
|
. ' is the same as a protected function or variable name in the Perl API, please choose a different name, dying' . "\n"; |
|
631
|
|
|
|
|
|
|
} |
|
632
|
|
|
|
|
|
|
|
|
633
|
0
|
|
|
|
|
0
|
substr $symbol_fhref, 0, 1, q{}; # remove leading $ sigil |
|
634
|
|
|
|
|
|
|
|
|
635
|
|
|
|
|
|
|
# CREATE SYMBOL TABLE ENTRY |
|
636
|
0
|
0
|
|
|
|
0
|
if ( exists $modes->{_symbol_table}->{ $modes->{_symbol_table}->{_namespace} }->{ $modes->{_symbol_table}->{_subroutine} }->{$symbol_fhref} ) { |
|
637
|
|
|
|
|
|
|
die 'ERROR ECOGEASCP12, CODE GENERATOR, ABSTRACT SYNTAX TO C++: variable ' |
|
638
|
|
|
|
|
|
|
. $symbol_fhref |
|
639
|
|
|
|
|
|
|
. ' already declared in this scope, namespace ' |
|
640
|
|
|
|
|
|
|
. q{'} . $modes->{_symbol_table}->{_namespace} . q{'} |
|
641
|
|
|
|
|
|
|
. ', subroutine/method ' |
|
642
|
0
|
|
|
|
|
0
|
. q{'} . $modes->{_symbol_table}->{_subroutine} . q{()'} |
|
643
|
|
|
|
|
|
|
. ', dying' . "\n"; |
|
644
|
|
|
|
|
|
|
} |
|
645
|
0
|
|
|
|
|
0
|
$modes->{_symbol_table}->{ $modes->{_symbol_table}->{_namespace} }->{ $modes->{_symbol_table}->{_subroutine} }->{$symbol_fhref} |
|
646
|
|
|
|
|
|
|
= { isa => 'RPerl::Operation::Expression::SubExpression::Variable', type => $type_fhref }; |
|
647
|
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
# NEED ANSWER: should we enable type_convert_perl_to_cpp() for future use of constant_filehandleref type? |
|
649
|
|
|
|
|
|
|
# $type_fhref = RPerl::Generator::type_convert_perl_to_cpp($type_fhref, 1); # $pointerify_classes = 1 |
|
650
|
|
|
|
|
|
|
$modes->{_symbol_table}->{ $modes->{_symbol_table}->{_namespace} }->{ $modes->{_symbol_table}->{_subroutine} }->{$symbol_fhref}->{type_cpp} |
|
651
|
0
|
|
|
|
|
0
|
= $type_fhref; # add converted C++ type to symtab entry |
|
652
|
|
|
|
|
|
|
|
|
653
|
0
|
|
|
|
|
0
|
$cpp_source_group->{CPP} .= $type_fhref . q{ } . $symbol_fhref . ';' . "\n"; |
|
654
|
|
|
|
|
|
|
} |
|
655
|
|
|
|
|
|
|
else { |
|
656
|
0
|
|
|
|
|
0
|
die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASCP00, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule ' |
|
657
|
|
|
|
|
|
|
. $self_class |
|
658
|
|
|
|
|
|
|
. ' found where VariableDeclaration_195, VariableDeclaration_196, VariableDeclaration_197, or VariableDeclaration_198 expected, dying' ) |
|
659
|
|
|
|
|
|
|
. "\n"; |
|
660
|
|
|
|
|
|
|
} |
|
661
|
47
|
|
|
|
|
328
|
return $cpp_source_group; |
|
662
|
|
|
|
|
|
|
} |
|
663
|
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
1; # end of class |