line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# [[[ HEADER ]]] |
2
|
|
|
|
|
|
|
package RPerl::Operation::Statement::Loop::While; |
3
|
5
|
|
|
5
|
|
32
|
use strict; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
129
|
|
4
|
5
|
|
|
5
|
|
23
|
use warnings; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
109
|
|
5
|
5
|
|
|
5
|
|
27
|
use RPerl::AfterSubclass; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
617
|
|
6
|
|
|
|
|
|
|
our $VERSION = 0.003_000; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# [[[ OO INHERITANCE ]]] |
9
|
5
|
|
|
5
|
|
37
|
use parent qw(RPerl::Operation::Statement::Loop); |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
36
|
|
10
|
5
|
|
|
5
|
|
415
|
use RPerl::Operation::Statement::Loop; |
|
5
|
|
|
|
|
19
|
|
|
5
|
|
|
|
|
2835
|
|
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
|
|
|
|
|
|
|
# [[[ OO PROPERTIES ]]] |
17
|
|
|
|
|
|
|
our hashref $properties = {}; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# [[[ SUBROUTINES & OO METHODS ]]] |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our string_hashref::method $ast_to_rperl__generate = sub { |
22
|
|
|
|
|
|
|
( my object $self, my string_hashref $modes) = @_; |
23
|
|
|
|
|
|
|
my string_hashref $rperl_source_group = { PMC => q{} }; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# RPerl::diag( 'in Loop::While->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my string $self_class = ref $self; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# unwrap LoopWhile_170 and LoopWhile_171 from Loop_166 |
30
|
|
|
|
|
|
|
if ( $self_class eq 'Loop_166' ) { # Loop -> LoopWhile |
31
|
|
|
|
|
|
|
$self = $self->{children}->[0]; |
32
|
|
|
|
|
|
|
$self_class = ref $self; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
if ( $self_class eq 'LoopWhile_170' ) { # LoopWhile -> 'while' LPAREN SubExpression ')' CodeBlock |
36
|
|
|
|
|
|
|
my string $while = $self->{children}->[0]; |
37
|
|
|
|
|
|
|
my string $left_paren = $self->{children}->[1]; |
38
|
|
|
|
|
|
|
my object $subexpression = $self->{children}->[2]; |
39
|
|
|
|
|
|
|
my string $right_paren = $self->{children}->[3]; |
40
|
|
|
|
|
|
|
my object $codeblock = $self->{children}->[4]; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$rperl_source_group->{PMC} .= $while . q{ } . $left_paren . q{ }; |
43
|
|
|
|
|
|
|
my object $rperl_source_subgroup = $subexpression->ast_to_rperl__generate($modes); |
44
|
|
|
|
|
|
|
RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup ); |
45
|
|
|
|
|
|
|
$rperl_source_group->{PMC} .= q{ } . $right_paren . q{ }; |
46
|
|
|
|
|
|
|
$rperl_source_subgroup = $codeblock->ast_to_rperl__generate($modes); |
47
|
|
|
|
|
|
|
RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup ); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
elsif ( $self_class eq 'LoopWhile_171' ) { # LoopWhile -> 'while' LPAREN_MY Type VARIABLE_SYMBOL OP19_VARIABLE_ASSIGN SubExpressionOrInput ')' CodeBlock |
50
|
|
|
|
|
|
|
my string $while = $self->{children}->[0]; |
51
|
|
|
|
|
|
|
my string $left_paren_my = $self->{children}->[1]; |
52
|
|
|
|
|
|
|
my string $type = $self->{children}->[2]->{children}->[0]; |
53
|
|
|
|
|
|
|
my string $variable_symbol = $self->{children}->[3]; |
54
|
|
|
|
|
|
|
my string $assign = $self->{children}->[4]; |
55
|
|
|
|
|
|
|
my object $subexpression_or_stdin = $self->{children}->[5]; |
56
|
|
|
|
|
|
|
my string $right_paren = $self->{children}->[6]; |
57
|
|
|
|
|
|
|
my object $codeblock = $self->{children}->[7]; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# RPerl::diag( 'in Loop::While->ast_to_rperl__generate(), have $type = ' . "\n" . RPerl::Parser::rperl_ast__dump($type) . "\n" ); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$rperl_source_group->{PMC} .= $while . q{ } . $left_paren_my . q{ } . $type . q{ } . $variable_symbol . q{ } . $assign . q{ }; |
62
|
|
|
|
|
|
|
my object $rperl_source_subgroup = $subexpression_or_stdin->ast_to_rperl__generate($modes); |
63
|
|
|
|
|
|
|
RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup ); |
64
|
|
|
|
|
|
|
$rperl_source_group->{PMC} .= q{ } . $right_paren . q{ }; |
65
|
|
|
|
|
|
|
$rperl_source_subgroup = $codeblock->ast_to_rperl__generate($modes); |
66
|
|
|
|
|
|
|
RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup ); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
else { |
69
|
|
|
|
|
|
|
die RPerl::Parser::rperl_rule__replace( |
70
|
|
|
|
|
|
|
'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule ' |
71
|
|
|
|
|
|
|
. $self_class |
72
|
|
|
|
|
|
|
. ' found where LoopWhile_170 or LoopWhile_171 expected, dying' ) |
73
|
|
|
|
|
|
|
. "\n"; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
return $rperl_source_group; |
76
|
|
|
|
|
|
|
}; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
our string_hashref::method $ast_to_cpp__generate__CPPOPS_PERLTYPES = sub { |
79
|
|
|
|
|
|
|
( my object $self, my string_hashref $modes) = @_; |
80
|
|
|
|
|
|
|
my string_hashref $cpp_source_group |
81
|
|
|
|
|
|
|
= { CPP => |
82
|
|
|
|
|
|
|
q{// <<< RP::O::S::L::W __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>} |
83
|
|
|
|
|
|
|
. "\n" }; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
#... |
86
|
|
|
|
|
|
|
return $cpp_source_group; |
87
|
|
|
|
|
|
|
}; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
our string_hashref::method $ast_to_cpp__generate__CPPOPS_CPPTYPES = sub { |
90
|
|
|
|
|
|
|
( my object $self, my string $loop_label, my string_hashref $modes) = @_; |
91
|
|
|
|
|
|
|
my string_hashref $cpp_source_group = { CPP => q{} }; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# RPerl::diag( 'in Loop::While->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" ); |
94
|
|
|
|
|
|
|
# RPerl::diag( 'in Loop::While->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $loop_label = ' . $loop_label . "\n" ); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my string $self_class = ref $self; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# unwrap LoopWhile_170 from Loop_166 |
99
|
|
|
|
|
|
|
if ( $self_class eq 'Loop_166' ) { # Loop -> LoopWhile |
100
|
|
|
|
|
|
|
$self = $self->{children}->[0]; |
101
|
|
|
|
|
|
|
$self_class = ref $self; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
if ( $self_class eq 'LoopWhile_170' ) { # LoopWhile -> 'while' LPAREN SubExpression ')' CodeBlock |
105
|
|
|
|
|
|
|
my string $while = $self->{children}->[0]; |
106
|
|
|
|
|
|
|
my string $left_paren = $self->{children}->[1]; |
107
|
|
|
|
|
|
|
my object $subexpression = $self->{children}->[2]; |
108
|
|
|
|
|
|
|
my string $right_paren = $self->{children}->[3]; |
109
|
|
|
|
|
|
|
my object $codeblock = $self->{children}->[4]; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
$cpp_source_group->{CPP} .= $while . q{ } . $left_paren . q{ }; |
112
|
|
|
|
|
|
|
my object $cpp_source_subgroup = $subexpression->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes); |
113
|
|
|
|
|
|
|
RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup ); |
114
|
|
|
|
|
|
|
$cpp_source_group->{CPP} .= q{ } . $right_paren . q{ }; |
115
|
|
|
|
|
|
|
$cpp_source_subgroup = $codeblock->ast_to_cpp__generate__CPPOPS_CPPTYPES($loop_label, $modes); |
116
|
|
|
|
|
|
|
RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup ); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
elsif ( $self_class eq 'LoopWhile_171' ) { # LoopWhile -> 'while' LPAREN_MY Type VARIABLE_SYMBOL OP19_VARIABLE_ASSIGN SubExpressionOrInput ')' CodeBlock |
119
|
|
|
|
|
|
|
$cpp_source_group = { CPP => q{// <<< RP::O::S::L::W __DUMMY_SOURCE_CODE CPPOPS_CPPTYPES >>>} . "\n" }; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
else { |
122
|
|
|
|
|
|
|
die RPerl::Parser::rperl_rule__replace( |
123
|
|
|
|
|
|
|
'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule ' |
124
|
|
|
|
|
|
|
. $self_class |
125
|
|
|
|
|
|
|
. ' found where LoopWhile_170 or LoopWhile_171 expected, dying' ) |
126
|
|
|
|
|
|
|
. "\n"; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
return $cpp_source_group; |
129
|
|
|
|
|
|
|
}; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; # end of class |