| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# [[[ HEADER ]]] |
|
2
|
|
|
|
|
|
|
package RPerl::CompileUnit::Constant; |
|
3
|
3
|
|
|
3
|
|
17
|
use strict; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
70
|
|
|
4
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
59
|
|
|
5
|
3
|
|
|
3
|
|
13
|
use RPerl::AfterSubclass; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
347
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = 0.004_000; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# [[[ OO INHERITANCE ]]] |
|
9
|
3
|
|
|
3
|
|
17
|
use parent qw(RPerl::CompileUnit); |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
15
|
|
|
10
|
3
|
|
|
3
|
|
176
|
use RPerl::CompileUnit; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
55
|
|
|
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
|
|
|
|
|
|
|
# [[[ INCLUDES ]]] |
|
17
|
3
|
|
|
3
|
|
15
|
use perlapinames_generated; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
2028
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# [[[ OO PROPERTIES ]]] |
|
20
|
|
|
|
|
|
|
our hashref $properties = {}; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# [[[ SUBROUTINES & OO METHODS ]]] |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub ast_to_rperl__generate { |
|
25
|
14
|
|
|
14
|
|
35
|
{ my string_hashref::method $RETURN_TYPE }; |
|
|
14
|
|
|
|
|
29
|
|
|
26
|
14
|
|
|
|
|
41
|
( my object $self, my string_hashref $modes) = @ARG; |
|
27
|
14
|
|
|
|
|
50
|
my string_hashref $rperl_source_group = { PMC => q{} }; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# RPerl::diag( 'in CompileUnit::Constant->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" ); |
|
30
|
|
|
|
|
|
|
|
|
31
|
14
|
|
|
|
|
44
|
my string $use_constant = $self->{children}->[0]; |
|
32
|
14
|
|
|
|
|
55
|
my string $name = $self->{children}->[1]; |
|
33
|
14
|
|
|
|
|
35
|
my string $fat_arrow = $self->{children}->[2]; |
|
34
|
14
|
|
|
|
|
41
|
my object $type_inner_constant = $self->{children}->[3]; |
|
35
|
14
|
|
|
|
|
42
|
my string $type_inner_constant_my = $type_inner_constant->{children}->[0]; |
|
36
|
|
|
|
|
|
|
my string $type_inner_constant_type |
|
37
|
14
|
|
|
|
|
48
|
= $type_inner_constant->{children}->[1]->{children}->[0]; |
|
38
|
14
|
|
|
|
|
38
|
my string $type_inner_constant_TYPED = $type_inner_constant->{children}->[2]; |
|
39
|
14
|
|
|
|
|
41
|
my string $type_inner_constant_name = $type_inner_constant->{children}->[3]; |
|
40
|
14
|
|
|
|
|
41
|
my string $type_inner_constant_equal = $type_inner_constant->{children}->[4]; |
|
41
|
14
|
|
|
|
|
37
|
my object $subexpression = $self->{children}->[4]; |
|
42
|
14
|
|
|
|
|
34
|
my string $semicolon = $self->{children}->[5]; |
|
43
|
|
|
|
|
|
|
|
|
44
|
14
|
50
|
66
|
|
|
222
|
if ((exists $perlapinames_generated::FUNCTIONS_DOCUMENTED->{$name}) or |
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
45
|
|
|
|
|
|
|
(exists $perlapinames_generated::FUNCTIONS_UNDOCUMENTED->{$name}) or |
|
46
|
|
|
|
|
|
|
(exists $perlapinames_generated::VARIABLES_DOCUMENTED->{$name}) or |
|
47
|
|
|
|
|
|
|
(exists $perlapinames_generated::VARIABLES_UNDOCUMENTED->{$name})) { |
|
48
|
1
|
|
|
|
|
23
|
die 'ERROR ECOGEASRP42, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Perl API name conflict, constant name ' . q{'} |
|
49
|
|
|
|
|
|
|
. $name . q{'} |
|
50
|
|
|
|
|
|
|
. ' is the same as a protected function or variable name in the Perl API, please choose a different name, dying' . "\n"; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# CREATE SYMBOL TABLE ENTRY |
|
54
|
13
|
50
|
|
|
|
74
|
if ( exists $modes->{_symbol_table}->{ $modes->{_symbol_table}->{_namespace} }->{_global}->{$name} ) { |
|
55
|
|
|
|
|
|
|
die 'ERROR ECOGEASRP12, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: variable ' |
|
56
|
|
|
|
|
|
|
. $name |
|
57
|
|
|
|
|
|
|
. ' already declared in this scope, namespace ' |
|
58
|
|
|
|
|
|
|
. q{'} . $modes->{_symbol_table}->{_namespace} . q{'} |
|
59
|
|
|
|
|
|
|
. ', subroutine/method ' |
|
60
|
0
|
|
|
|
|
0
|
. q{'} . $modes->{_symbol_table}->{_subroutine} . q{()'} |
|
61
|
|
|
|
|
|
|
. ', dying' . "\n"; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
13
|
|
|
|
|
93
|
$modes->{_symbol_table}->{ $modes->{_symbol_table}->{_namespace} }->{_global}->{$name} |
|
64
|
|
|
|
|
|
|
= { isa => 'RPerl::CompileUnit::Constant', type => $type_inner_constant_type }; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
$rperl_source_group->{PMC} |
|
67
|
13
|
|
|
|
|
76
|
.= $use_constant . q{ } |
|
68
|
|
|
|
|
|
|
. $name . q{ } |
|
69
|
|
|
|
|
|
|
. $fat_arrow . q{ } |
|
70
|
|
|
|
|
|
|
. $type_inner_constant_my . q{ } |
|
71
|
|
|
|
|
|
|
. $type_inner_constant_type . q{ } |
|
72
|
|
|
|
|
|
|
. $type_inner_constant_TYPED |
|
73
|
|
|
|
|
|
|
. $type_inner_constant_name . q{ } |
|
74
|
|
|
|
|
|
|
. $type_inner_constant_equal . q{ }; |
|
75
|
|
|
|
|
|
|
|
|
76
|
13
|
|
|
|
|
379
|
my string_hashref $rperl_source_subgroup = $subexpression->ast_to_rperl__generate($modes); |
|
77
|
13
|
|
|
|
|
290
|
RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup ); |
|
78
|
|
|
|
|
|
|
|
|
79
|
13
|
|
|
|
|
42
|
$rperl_source_group->{PMC} .= $semicolon . "\n"; |
|
80
|
13
|
|
|
|
|
101
|
return $rperl_source_group; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub ast_to_cpp__generate__CPPOPS_PERLTYPES { |
|
84
|
0
|
|
|
0
|
|
0
|
{ my string_hashref::method $RETURN_TYPE }; |
|
|
0
|
|
|
|
|
0
|
|
|
85
|
0
|
|
|
|
|
0
|
( my object $self, my string_hashref $modes) = @ARG; |
|
86
|
0
|
|
|
|
|
0
|
my string_hashref $cpp_source_group = { H => q{// <<< RP::CU::Co __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>} . "\n" }; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
#... |
|
89
|
0
|
|
|
|
|
0
|
return $cpp_source_group; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub ast_to_cpp__generate__CPPOPS_CPPTYPES { |
|
93
|
2
|
|
|
2
|
|
3
|
{ my string_hashref::method $RETURN_TYPE }; |
|
|
2
|
|
|
|
|
3
|
|
|
94
|
2
|
|
|
|
|
4
|
( my object $self, my string $package_name_underscores, my string_hashref $modes ) = @ARG; |
|
95
|
2
|
|
|
|
|
7
|
my string_hashref $cpp_source_group = { H => q{} }; |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
#RPerl::diag( 'in CompileUnit::Constant->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" ); |
|
98
|
|
|
|
|
|
|
|
|
99
|
2
|
|
|
|
|
25
|
my string $name = $self->{children}->[1]; |
|
100
|
2
|
|
|
|
|
15
|
my string $type_inner_constant_type = $self->{children}->[3]->{children}->[1]->{children}->[0]; |
|
101
|
2
|
|
|
|
|
4
|
my object $subexpression = $self->{children}->[4]; |
|
102
|
|
|
|
|
|
|
|
|
103
|
2
|
50
|
33
|
|
|
28
|
if ((exists $perlapinames_generated::FUNCTIONS_DOCUMENTED->{$name}) or |
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
104
|
|
|
|
|
|
|
(exists $perlapinames_generated::FUNCTIONS_UNDOCUMENTED->{$name}) or |
|
105
|
|
|
|
|
|
|
(exists $perlapinames_generated::VARIABLES_DOCUMENTED->{$name}) or |
|
106
|
|
|
|
|
|
|
(exists $perlapinames_generated::VARIABLES_UNDOCUMENTED->{$name})) { |
|
107
|
0
|
|
|
|
|
0
|
die 'ERROR ECOGEASCP42, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Perl API name conflict, constant name ' . q{'} |
|
108
|
|
|
|
|
|
|
. $name . q{'} |
|
109
|
|
|
|
|
|
|
. ' is the same as a protected function or variable name in the Perl API, please choose a different name, dying' . "\n"; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# CREATE SYMBOL TABLE ENTRY |
|
113
|
2
|
50
|
|
|
|
10
|
if ( exists $modes->{_symbol_table}->{ $modes->{_symbol_table}->{_namespace} }->{_global}->{$name} ) { |
|
114
|
|
|
|
|
|
|
die 'ERROR ECOGEASCP12, CODE GENERATOR, ABSTRACT SYNTAX TO C++: variable ' |
|
115
|
|
|
|
|
|
|
. $name |
|
116
|
|
|
|
|
|
|
. ' already declared in this scope, namespace ' |
|
117
|
|
|
|
|
|
|
. q{'} . $modes->{_symbol_table}->{_namespace} . q{'} |
|
118
|
|
|
|
|
|
|
. ', subroutine/method ' |
|
119
|
0
|
|
|
|
|
0
|
. q{'} . $modes->{_symbol_table}->{_subroutine} . q{()'} |
|
120
|
|
|
|
|
|
|
. ', dying' . "\n"; |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# NEED FIX: possible 'const const' conflict?!? |
|
124
|
2
|
|
|
|
|
41
|
$type_inner_constant_type = RPerl::Generator::type_convert_perl_to_cpp($type_inner_constant_type, 1); # $pointerify_classes = 1 |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# add converted C++ type to symtab entry |
|
127
|
2
|
|
|
|
|
10
|
$modes->{_symbol_table}->{ $modes->{_symbol_table}->{_namespace} }->{_global}->{$name} |
|
128
|
|
|
|
|
|
|
= { isa => 'RPerl::CompileUnit::Constant', type => $type_inner_constant_type }; |
|
129
|
|
|
|
|
|
|
|
|
130
|
2
|
|
|
|
|
9
|
$cpp_source_group->{H} .= 'const ' . $type_inner_constant_type . q{ } . $package_name_underscores . '__' . $name . ' = '; |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# RPerl::diag( 'in CompileUnit::Constant->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $subexpression = ' . "\n" . RPerl::Parser::rperl_ast__dump($subexpression) . "\n" ); |
|
133
|
|
|
|
|
|
|
|
|
134
|
2
|
|
|
|
|
49
|
my string_hashref $cpp_source_subgroup = $subexpression->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes); |
|
135
|
2
|
|
|
|
|
7
|
$cpp_source_group->{H} .= $cpp_source_subgroup->{CPP}; |
|
136
|
2
|
|
|
|
|
7
|
$cpp_source_group->{H} .= ';' . "\n"; |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
# create shim |
|
139
|
2
|
50
|
33
|
|
|
10
|
if ( ( not exists $cpp_source_group->{_H_constants_shims} ) or ( not defined $cpp_source_group->{_H_constants_shims} ) ) { |
|
|
|
0
|
0
|
|
|
|
|
|
140
|
2
|
|
|
|
|
6
|
$cpp_source_group->{_H_constants_shims} = {}; |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
elsif (( not exists $cpp_source_group->{_H_constants_shims}->{$package_name_underscores} ) |
|
143
|
|
|
|
|
|
|
or ( not defined $cpp_source_group->{_H_constants_shims}->{$package_name_underscores} ) ) |
|
144
|
|
|
|
|
|
|
{ |
|
145
|
0
|
|
|
|
|
0
|
$cpp_source_group->{_H_constants_shims}->{$package_name_underscores} = q{}; |
|
146
|
|
|
|
|
|
|
} |
|
147
|
2
|
|
|
|
|
12
|
$cpp_source_group->{_H_constants_shims}->{$package_name_underscores} .= |
|
148
|
|
|
|
|
|
|
'const ' . $type_inner_constant_type . q{ } . $name . '() { return ' . $package_name_underscores . '__' . $name . '; }' . "\n"; |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
# RPerl::diag( 'in CompileUnit::Constant->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $cpp_source_group->{_H_constants_shims}->{$package_name_underscores} = ' . "\n" . $cpp_source_group->{_H_constants_shims}->{$package_name_underscores} . "\n" ); |
|
151
|
2
|
|
|
|
|
11
|
return $cpp_source_group; |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
1; # end of class |