line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# [[[ HEADER ]]] |
2
|
|
|
|
|
|
|
package RPerl::CompileUnit::Module::Package; |
3
|
3
|
|
|
3
|
|
19
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
75
|
|
4
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
61
|
|
5
|
3
|
|
|
3
|
|
13
|
use RPerl::AfterSubclass; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
375
|
|
6
|
|
|
|
|
|
|
our $VERSION = 0.002_000; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# [[[ OO INHERITANCE ]]] |
9
|
3
|
|
|
3
|
|
19
|
use parent qw(RPerl::CompileUnit::Module); |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
17
|
|
10
|
3
|
|
|
3
|
|
158
|
use RPerl::CompileUnit::Module; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
122
|
|
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
|
|
16
|
use RPerl::Parser; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
52
|
|
18
|
3
|
|
|
3
|
|
13
|
use RPerl::Generator; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
1921
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# [[[ OO PROPERTIES ]]] |
21
|
|
|
|
|
|
|
our hashref $properties = {}; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# [[[ SUBROUTINES & OO METHODS ]]] |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub ast_to_rperl__generate { |
26
|
133
|
|
|
133
|
|
417
|
{ my string_hashref::method $RETURN_TYPE }; |
|
133
|
|
|
|
|
409
|
|
27
|
133
|
|
|
|
|
518
|
( my object $self, my string $package_name_underscores, my string_hashref $modes ) = @ARG; |
28
|
133
|
|
|
|
|
494
|
my string_hashref $rperl_source_group = {}; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# RPerl::diag( 'in Package->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" ); |
31
|
|
|
|
|
|
|
|
32
|
133
|
|
|
|
|
576
|
my string $self_class = ref $self; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# unwrap Package_36 from Module_24 |
35
|
133
|
50
|
|
|
|
1037
|
if ( ($self_class) eq 'Module_24' ) { |
36
|
133
|
|
|
|
|
626
|
$self = $self->{children}->[0]; |
37
|
133
|
|
|
|
|
372
|
$self_class = ref $self; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
133
|
50
|
|
|
|
905
|
if ( ($self_class) ne 'Package_36' ) { |
41
|
0
|
|
|
|
|
0
|
die RPerl::Parser::rperl_rule__replace( |
42
|
|
|
|
|
|
|
'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule ' |
43
|
|
|
|
|
|
|
. ($self_class) |
44
|
|
|
|
|
|
|
. ' found where Module_24 or Package_36 expected, dying' ) |
45
|
|
|
|
|
|
|
. "\n"; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Package: Critic* Exports? Include* Constant* Subroutine+ LITERAL_NUMBER ';' ; |
49
|
133
|
|
|
|
|
492
|
my object $critic_star = $self->{children}->[0]; |
50
|
133
|
|
|
|
|
354
|
my object $exports_optional = $self->{children}->[1]; |
51
|
133
|
|
|
|
|
518
|
my object $include_star = $self->{children}->[2]; |
52
|
133
|
|
|
|
|
429
|
my object $constant_star = $self->{children}->[3]; |
53
|
133
|
|
|
|
|
597
|
my object $subroutine_plus = $self->{children}->[4]; |
54
|
133
|
|
|
|
|
469
|
my string $retval_literal_number = $self->{children}->[5]; |
55
|
133
|
|
|
|
|
598
|
my string $retval_semicolon = $self->{children}->[6]; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# RPerl::diag( 'in Package->ast_to_rperl__generate(), have $exports_optional = ' . "\n" . RPerl::Parser::rperl_ast__dump($exports_optional) . "\n" ); |
58
|
|
|
|
|
|
|
|
59
|
133
|
|
|
|
|
453
|
my string_hashref $rperl_source_subgroup; |
60
|
|
|
|
|
|
|
|
61
|
133
|
100
|
|
|
|
735
|
if ( exists $critic_star->{children}->[0] ) { |
62
|
87
|
50
|
|
|
|
571
|
if ( $modes->{label} eq 'ON' ) { |
63
|
0
|
|
|
|
|
0
|
$rperl_source_group->{PMC} .= '# [[[ CRITICS ]]]' . "\n"; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
133
|
|
|
|
|
413
|
foreach my object $critic ( @{ $critic_star->{children} } ) { |
|
133
|
|
|
|
|
516
|
|
67
|
105
|
|
|
|
|
2880
|
$rperl_source_subgroup = $critic->ast_to_rperl__generate($modes); |
68
|
105
|
|
|
|
|
2361
|
RPerl::Generator::source_group_append( $rperl_source_group, |
69
|
|
|
|
|
|
|
$rperl_source_subgroup ); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
133
|
100
|
|
|
|
826
|
if ( exists $exports_optional->{children}->[0] ) { |
73
|
|
|
|
|
|
|
# RPerl::diag( 'in Package->ast_to_rperl__generate(), have YES EXPORTS ' . "\n" ); |
74
|
9
|
50
|
|
|
|
50
|
if ( $modes->{label} eq 'ON' ) { |
75
|
0
|
|
|
|
|
0
|
$rperl_source_group->{PMC} .= "\n" . '# [[[ EXPORTS ]]]' . "\n"; |
76
|
|
|
|
|
|
|
} |
77
|
9
|
|
|
|
|
25
|
my object $exports = $exports_optional->{children}->[0]; |
78
|
9
|
|
|
|
|
32
|
my string $use_exporter = $exports->{children}->[0]; |
79
|
9
|
|
|
|
|
27
|
my string $export = $exports->{children}->[1]; |
80
|
9
|
|
|
|
|
24
|
my string $export_ok = $exports->{children}->[2]; |
81
|
|
|
|
|
|
|
|
82
|
9
|
|
|
|
|
24
|
$rperl_source_group->{PMC} .= $use_exporter; # already has a newline |
83
|
9
|
100
|
|
|
|
39
|
if ( exists $export->{children}->[0] ) { |
84
|
5
|
|
|
|
|
24
|
$rperl_source_group->{PMC} .= $export->{children}->[0]->{attr} . $export->{children}->[1]->{attr} . ';' . "\n"; # DEV NOTE: does not capture semicolon in AST for some reason, must hard-code here |
85
|
|
|
|
|
|
|
} |
86
|
9
|
100
|
|
|
|
39
|
if ( exists $export_ok->{children}->[0] ) { |
87
|
5
|
|
|
|
|
33
|
$rperl_source_group->{PMC} .= $export_ok->{children}->[0]->{attr} . $export_ok->{children}->[1]->{attr} . ';' . "\n"; # DEV NOTE: does not capture semicolon in AST for some reason, must hard-code here |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
# RPerl::diag( 'in Package->ast_to_rperl__generate(), AFTER EXPORTS, have $rperl_source_group->{PMC} = ' . "\n" . RPerl::Parser::rperl_ast__dump($rperl_source_group->{PMC}) . "\n" ); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
133
|
100
|
|
|
|
851
|
if ( exists $include_star->{children}->[0] ) { |
93
|
9
|
50
|
|
|
|
49
|
if ( $modes->{label} eq 'ON' ) { |
94
|
0
|
|
|
|
|
0
|
$rperl_source_group->{PMC} .= "\n" . '# [[[ INCLUDES ]]]' . "\n"; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
133
|
|
|
|
|
508
|
foreach my object $include ( @{ $include_star->{children} } ) { ## no critic qw(ProhibitPostfixControls) # SYSTEM SPECIAL 6: PERL CRITIC FILED ISSUE #639, not postfix foreach or if |
|
133
|
|
|
|
|
558
|
|
98
|
10
|
|
|
|
|
271
|
$rperl_source_subgroup = $include->ast_to_rperl__generate($modes); |
99
|
10
|
|
|
|
|
222
|
RPerl::Generator::source_group_append( $rperl_source_group, |
100
|
|
|
|
|
|
|
$rperl_source_subgroup ); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
133
|
100
|
|
|
|
898
|
if ( exists $constant_star->{children}->[0] ) { |
104
|
1
|
50
|
|
|
|
6
|
if ( $modes->{label} eq 'ON' ) { |
105
|
0
|
|
|
|
|
0
|
$rperl_source_group->{PMC} .= "\n" . '# [[[ CONSTANTS ]]]' . "\n"; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
} |
108
|
133
|
|
|
|
|
420
|
foreach my object $constant ( @{ $constant_star->{children} } ) { ## no critic qw(ProhibitPostfixControls) # SYSTEM SPECIAL 6: PERL CRITIC FILED ISSUE #639, not postfix foreach or if |
|
133
|
|
|
|
|
619
|
|
109
|
2
|
|
|
|
|
43
|
$rperl_source_subgroup = $constant->ast_to_rperl__generate($modes); |
110
|
2
|
|
|
|
|
39
|
RPerl::Generator::source_group_append( $rperl_source_group, |
111
|
|
|
|
|
|
|
$rperl_source_subgroup ); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# always have at least one subroutine, don't need to check if they exist to label |
115
|
133
|
50
|
|
|
|
838
|
if ( $modes->{label} eq 'ON' ) { |
116
|
0
|
|
|
|
|
0
|
$rperl_source_group->{PMC} .= "\n" . '# [[[ SUBROUTINES ]]]' . "\n"; |
117
|
|
|
|
|
|
|
} |
118
|
133
|
|
|
|
|
386
|
foreach my object $subroutine ( ## no critic qw(ProhibitPostfixControls) # SYSTEM SPECIAL 6: PERL CRITIC FILED ISSUE #639, not postfix foreach or if |
119
|
133
|
|
|
|
|
579
|
@{ $subroutine_plus->{children} } |
120
|
|
|
|
|
|
|
) |
121
|
|
|
|
|
|
|
{ |
122
|
146
|
|
|
|
|
4136
|
$rperl_source_subgroup |
123
|
|
|
|
|
|
|
= $subroutine->ast_to_rperl__generate($modes); |
124
|
146
|
|
|
|
|
3456
|
RPerl::Generator::source_group_append( $rperl_source_group, |
125
|
|
|
|
|
|
|
$rperl_source_subgroup ); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
133
|
50
|
|
|
|
616
|
if ( $modes->{label} eq 'ON' ) { |
129
|
|
|
|
|
|
|
$rperl_source_group->{PMC} |
130
|
0
|
|
|
|
|
0
|
.= "\n" |
131
|
|
|
|
|
|
|
. $retval_literal_number |
132
|
|
|
|
|
|
|
. $retval_semicolon |
133
|
|
|
|
|
|
|
. ' # end of package' . "\n"; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
else { |
136
|
|
|
|
|
|
|
$rperl_source_group->{PMC} |
137
|
133
|
|
|
|
|
894
|
.= $retval_literal_number . $retval_semicolon . "\n"; |
138
|
|
|
|
|
|
|
} |
139
|
133
|
|
|
|
|
1259
|
return $rperl_source_group; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub ast_to_cpp__generate__CPPOPS_PERLTYPES { |
143
|
0
|
|
|
0
|
|
|
{ my string_hashref::method $RETURN_TYPE }; |
|
0
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
( my object $self, my string $package_name_underscores, my string_hashref $modes ) = @ARG; |
145
|
0
|
|
|
|
|
|
my string_hashref $cpp_source_group = { |
146
|
|
|
|
|
|
|
CPP => |
147
|
|
|
|
|
|
|
q{// <<< RP::CU::M::P __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>} |
148
|
|
|
|
|
|
|
. "\n", |
149
|
|
|
|
|
|
|
H => q{// <<< RP::CU::M::P __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>} |
150
|
|
|
|
|
|
|
. "\n", |
151
|
|
|
|
|
|
|
# PMC => q{# <<< RP::CU::M::P __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>} . "\n" |
152
|
|
|
|
|
|
|
}; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
#... |
155
|
0
|
|
|
|
|
|
return $cpp_source_group; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub ast_to_cpp__generate__CPPOPS_CPPTYPES { |
159
|
0
|
|
|
0
|
|
|
{ my string_hashref::method $RETURN_TYPE }; |
|
0
|
|
|
|
|
|
|
160
|
0
|
|
|
|
|
|
( my object $self, my string $package_name_underscores, my string_hashref $modes ) = @ARG; |
161
|
0
|
|
|
|
|
|
my string_hashref $cpp_source_group = { |
162
|
|
|
|
|
|
|
CPP => q{// <<< RP::CU::M::P __DUMMY_SOURCE_CODE CPPOPS_CPPTYPES >>>} |
163
|
|
|
|
|
|
|
. "\n", |
164
|
|
|
|
|
|
|
H => q{// <<< RP::CU::M::P __DUMMY_SOURCE_CODE CPPOPS_CPPTYPES >>>} |
165
|
|
|
|
|
|
|
. "\n", |
166
|
|
|
|
|
|
|
# PMC => q{# <<< RP::CU::M::P __DUMMY_SOURCE_CODE CPPOPS_CPPTYPES >>>} . "\n" |
167
|
|
|
|
|
|
|
}; |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
#... |
170
|
0
|
|
|
|
|
|
return $cpp_source_group; |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
1; # end of class |