line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# [[[ HEADER ]]] |
2
|
|
|
|
|
|
|
package RPerl::CompileUnit::Module; |
3
|
4
|
|
|
4
|
|
37
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
127
|
|
4
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
108
|
|
5
|
4
|
|
|
4
|
|
23
|
use RPerl::AfterSubclass; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
611
|
|
6
|
|
|
|
|
|
|
our $VERSION = 0.002_400; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# [[[ OO INHERITANCE ]]] |
9
|
|
|
|
|
|
|
# <<< CHANGE_ME: leave as base class for no inheritance, or replace with real parent package name >>> |
10
|
4
|
|
|
4
|
|
31
|
use parent qw(RPerl::CompileUnit); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
28
|
|
11
|
4
|
|
|
4
|
|
243
|
use RPerl::CompileUnit; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
363
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# [[[ CRITICS ]]] |
14
|
|
|
|
|
|
|
## no critic qw(ProhibitUselessNoCritic ProhibitMagicNumbers RequireCheckedSyscalls) # USER DEFAULT 1: allow numeric values & print operator |
15
|
|
|
|
|
|
|
## no critic qw(RequireInterpolationOfMetachars) # USER DEFAULT 2: allow single-quoted control characters & sigils |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# [[[ INCLUDES ]]] |
18
|
|
|
|
|
|
|
#use RPerl::Parser; |
19
|
|
|
|
|
|
|
#eval 'require RPerl::Parser;'; |
20
|
|
|
|
|
|
|
eval {require RPerl::Parser;}; |
21
|
|
|
|
|
|
|
if ($EVAL_ERROR and ($EVAL_ERROR =~ /attempt to reload/i)){ |
22
|
|
|
|
|
|
|
delete $INC{'RPerl::Parser'}; |
23
|
|
|
|
|
|
|
require RPerl::Parser; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
elsif ($EVAL_ERROR ne q{}) { die $EVAL_ERROR; } |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
4
|
|
1762
|
use RPerl::Generator; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
2429
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# [[[ OO PROPERTIES ]]] |
30
|
|
|
|
|
|
|
our hashref $properties = {}; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# [[[ SUBROUTINES & OO METHODS ]]] |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
our string_hashref::method $ast_to_rperl__generate = sub { |
35
|
|
|
|
|
|
|
( my object $self, my string_hashref $modes) = @_; |
36
|
|
|
|
|
|
|
my string_hashref $rperl_source_group = {}; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# RPerl::diag('in Module->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n"); |
39
|
|
|
|
|
|
|
# RPerl::diag('in Module->ast_to_rperl__generate(), received $modes = ' . "\n" . Dumper($modes) . "\n"); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my object_arrayref $modules_and_headers = $self->{children}->[0]->{children}; |
42
|
|
|
|
|
|
|
my string_hashref $rperl_source_subgroup; |
43
|
|
|
|
|
|
|
my string $package_name_underscores; # get from Header to Class or Package |
44
|
|
|
|
|
|
|
my boolean $header_started = 0; |
45
|
|
|
|
|
|
|
my boolean $current_package_count = 0; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# disable unused symbol table testing |
48
|
|
|
|
|
|
|
# RPerl::diag('in Module->ast_to_rperl__generate(), have %RPerl::Generator:: symbol table = ' . "\n" . Dumper(\%RPerl::Generator::) . "\n"); |
49
|
|
|
|
|
|
|
# RPerl::diag('in Module->ast_to_rperl__generate(), have %RPerl::CompileUnit::Module::Header:: symbol table dumped = ' . "\n" . Dumper(\%RPerl::CompileUnit::Module::Header::) . "\n"); |
50
|
|
|
|
|
|
|
# RPerl::diag('in Module->ast_to_rperl__generate(), have %ModuleHeader_23:: symbol table dumped = ' . "\n" . Dumper(\%ModuleHeader_23::) . "\n"); |
51
|
|
|
|
|
|
|
# my $class = 'RPerl::CompileUnit::Module::Header'; |
52
|
|
|
|
|
|
|
# RPerl::diag('in Module->ast_to_rperl__generate(), have symtab entries for ' . $class . "\n" . RPerl::analyze_class_symtab_entries($class) . "\n\n"); |
53
|
|
|
|
|
|
|
# $class = 'ModuleHeader_23'; |
54
|
|
|
|
|
|
|
# RPerl::diag('in Module->ast_to_rperl__generate(), have symtab entries for ' . $class . "\n" . RPerl::analyze_class_symtab_entries($class) . "\n\n"); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
foreach my object $header_or_module (@{$modules_and_headers}) { |
57
|
|
|
|
|
|
|
# RPerl::diag('in Module->ast_to_rperl__generate(), have $header_or_module = ' . "\n" . RPerl::Parser::rperl_ast__dump($header_or_module) . "\n\n"); |
58
|
|
|
|
|
|
|
if ((ref $header_or_module) eq 'ModuleHeader_23') { |
59
|
|
|
|
|
|
|
if ($header_started) { |
60
|
|
|
|
|
|
|
die 'ERROR ECOGEASRP34, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: ModuleHeader found without first finding Module for previous ModuleHeader, dying' . "\n"; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
else { |
63
|
|
|
|
|
|
|
# if ($current_package_count >= 1) { $rperl_source_group->{PMC} .= "\n\n"; } # DEV NOTE: extra spaces removed by perltidy??? |
64
|
|
|
|
|
|
|
if (($current_package_count == 1) and ( $modes->{label} eq 'ON' )) { |
65
|
|
|
|
|
|
|
$rperl_source_group->{PMC} .= '# [[[ ADDITIONAL CLASSES ]]]' . "\n\n"; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
$header_started = 1; |
68
|
|
|
|
|
|
|
$rperl_source_subgroup = $header_or_module->ast_to_rperl__generate($modes); |
69
|
|
|
|
|
|
|
$package_name_underscores = $rperl_source_subgroup->{_package_name_underscores}; |
70
|
|
|
|
|
|
|
RPerl::Generator::source_group_append($rperl_source_group, $rperl_source_subgroup); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
elsif (((ref $header_or_module) eq 'Module_24') or ((ref $header_or_module) eq 'Module_25')) { |
74
|
|
|
|
|
|
|
if ($header_started) { |
75
|
|
|
|
|
|
|
$rperl_source_subgroup = $header_or_module->ast_to_rperl__generate($package_name_underscores, $modes); |
76
|
|
|
|
|
|
|
RPerl::Generator::source_group_append($rperl_source_group, $rperl_source_subgroup); |
77
|
|
|
|
|
|
|
$header_started = 0; |
78
|
|
|
|
|
|
|
$current_package_count++; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
else { |
81
|
|
|
|
|
|
|
die 'ERROR ECOGEASRP35, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Module found without first finding ModuleHeader, dying' . "\n"; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
else { |
85
|
|
|
|
|
|
|
die RPerl::Parser::rperl_rule__replace( |
86
|
|
|
|
|
|
|
'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule ' |
87
|
|
|
|
|
|
|
. ( ref $header_or_module ) |
88
|
|
|
|
|
|
|
. ' found where ModuleHeader_23, Module_24, or Module_25 expected, dying' ) |
89
|
|
|
|
|
|
|
. "\n"; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
return $rperl_source_group; |
94
|
|
|
|
|
|
|
}; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
our string_hashref::method $ast_to_cpp__generate__CPPOPS_PERLTYPES = sub { |
97
|
|
|
|
|
|
|
( my object $self, my string_hashref $modes ) = @_; |
98
|
|
|
|
|
|
|
my string_hashref $cpp_source_group = { |
99
|
|
|
|
|
|
|
CPP => |
100
|
|
|
|
|
|
|
q{// <<< RP::CU::M __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>} |
101
|
|
|
|
|
|
|
. "\n", |
102
|
|
|
|
|
|
|
H => |
103
|
|
|
|
|
|
|
q{// <<< RP::CU::M __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>} |
104
|
|
|
|
|
|
|
. "\n", |
105
|
|
|
|
|
|
|
PMC => |
106
|
|
|
|
|
|
|
q{# <<< RP::CU::M __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>} |
107
|
|
|
|
|
|
|
. "\n" |
108
|
|
|
|
|
|
|
}; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
#... |
111
|
|
|
|
|
|
|
return $cpp_source_group; |
112
|
|
|
|
|
|
|
}; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
our string_hashref::method $ast_to_cpp__generate__CPPOPS_CPPTYPES = sub { |
115
|
|
|
|
|
|
|
( my object $self, my string_hashref $modes ) = @_; |
116
|
|
|
|
|
|
|
my string_hashref $cpp_source_group = { CPP => q{}, H => q{} }; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# RPerl::diag('in Module->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n"); |
119
|
|
|
|
|
|
|
# RPerl::diag('in Module->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $modes = ' . "\n" . Dumper($modes) . "\n"); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
my object_arrayref $modules_and_headers = $self->{children}->[0]->{children}; |
122
|
|
|
|
|
|
|
my string_hashref $cpp_source_subgroup; |
123
|
|
|
|
|
|
|
my string_hashref $cpp_source_subgroup_saved; |
124
|
|
|
|
|
|
|
my string $package_name_underscores; # get from Header to Class or Package |
125
|
|
|
|
|
|
|
my boolean $header_started = 0; |
126
|
|
|
|
|
|
|
my boolean $current_package_count = 0; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
foreach my object $header_or_module (@{$modules_and_headers}) { |
129
|
|
|
|
|
|
|
# RPerl::diag('in Module->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $header_or_module = ' . "\n" . RPerl::Parser::rperl_ast__dump($header_or_module) . "\n\n"); |
130
|
|
|
|
|
|
|
# C++ Module::Header wraps around Module, must call both *generate_begin*() and *generate_end*() |
131
|
|
|
|
|
|
|
if ((ref $header_or_module) eq 'ModuleHeader_23') { |
132
|
|
|
|
|
|
|
if ($header_started) { |
133
|
|
|
|
|
|
|
die 'ERROR ECOGEASCP34, CODE GENERATOR, ABSTRACT SYNTAX TO C++, CPPOPS_CPPTYPES: ModuleHeader found without first finding Module for previous ModuleHeader, dying' . "\n"; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
else { |
136
|
|
|
|
|
|
|
if ($current_package_count >= 1) { |
137
|
|
|
|
|
|
|
$cpp_source_group->{CPP} .= "\n\n"; |
138
|
|
|
|
|
|
|
$cpp_source_group->{H} .= "\n\n"; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
if (($current_package_count == 1) and ( $modes->{label} eq 'ON' )) { |
141
|
|
|
|
|
|
|
$cpp_source_group->{CPP} .= '// [[[ ADDITIONAL CLASSES ]]]' . "\n\n"; |
142
|
|
|
|
|
|
|
$cpp_source_group->{H} .= '// [[[ ADDITIONAL CLASSES ]]]' . "\n\n"; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
$header_started = 1; |
145
|
|
|
|
|
|
|
$cpp_source_subgroup = $header_or_module->ast_to_cpp__generate_begin__CPPOPS_CPPTYPES($modes); |
146
|
|
|
|
|
|
|
$package_name_underscores = $cpp_source_subgroup->{_package_name_underscores}; |
147
|
|
|
|
|
|
|
RPerl::Generator::source_group_append($cpp_source_group, $cpp_source_subgroup); |
148
|
|
|
|
|
|
|
$cpp_source_subgroup_saved = $header_or_module->ast_to_cpp__generate_end__CPPOPS_CPPTYPES($modes); |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
elsif (((ref $header_or_module) eq 'Module_24') or ((ref $header_or_module) eq 'Module_25')) { |
152
|
|
|
|
|
|
|
if ($header_started) { |
153
|
|
|
|
|
|
|
$cpp_source_subgroup = $header_or_module->ast_to_cpp__generate__CPPOPS_CPPTYPES($package_name_underscores, $modes); |
154
|
|
|
|
|
|
|
RPerl::Generator::source_group_append($cpp_source_group, $cpp_source_subgroup); |
155
|
|
|
|
|
|
|
RPerl::Generator::source_group_append($cpp_source_group, $cpp_source_subgroup_saved); |
156
|
|
|
|
|
|
|
$header_started = 0; |
157
|
|
|
|
|
|
|
$cpp_source_group->{CPP} .= "\n" . '// end of class' . "\n"; |
158
|
|
|
|
|
|
|
$cpp_source_group->{H} .= "\n" . '// end of class' . "\n"; |
159
|
|
|
|
|
|
|
$current_package_count++; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
else { |
162
|
|
|
|
|
|
|
die 'ERROR ECOGEASCP35, CODE GENERATOR, ABSTRACT SYNTAX TO C++, CPPOPS_CPPTYPES: Module found without first finding ModuleHeader, dying' . "\n"; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
else { |
166
|
|
|
|
|
|
|
die RPerl::Parser::rperl_rule__replace( |
167
|
|
|
|
|
|
|
'ERROR ECOGEASCP00, CODE GENERATOR, ABSTRACT SYNTAX TO C++, CPPOPS_CPPTYPES: Grammar rule ' |
168
|
|
|
|
|
|
|
. ( ref $header_or_module ) |
169
|
|
|
|
|
|
|
. ' found where ModuleHeader_23, Module_24, or Module_25 expected, dying' ) |
170
|
|
|
|
|
|
|
. "\n"; |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
return $cpp_source_group; |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
}; |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
1; # end of class |