File Coverage

blib/lib/RPerl/Operation/Expression/Operator/Named/Sort.pm
Criterion Covered Total %
statement 34 81 41.9
branch 2 16 12.5
condition n/a
subroutine 9 11 81.8
pod n/a
total 45 108 41.6


line stmt bran cond sub pod time code
1             # [[[ DOCUMENTATION ]]]
2             # http://perldoc.perl.org/functions/sort.html
3             # NOT SUPPORTED: sort SUBNAME LIST
4             # NOT SUPPORTED: sort BLOCK LIST
5             # SUPPORTED: sort LIST
6              
7             # [[[ HEADER ]]]
8             package RPerl::Operation::Expression::Operator::Named::Sort;
9 4     4   23 use strict;
  4         9  
  4         95  
10 4     4   16 use warnings;
  4         8  
  4         77  
11 4     4   18 use RPerl::AfterSubclass;
  4         8  
  4         561  
12             our $VERSION = 0.001_000;
13              
14             # [[[ OO INHERITANCE ]]]
15 4     4   31 use parent qw(RPerl::Operation::Expression::Operator::Named);
  4         7  
  4         20  
16 4     4   243 use RPerl::Operation::Expression::Operator::Named;
  4         9  
  4         100  
17              
18             # [[[ CRITICS ]]]
19             ## no critic qw(ProhibitUselessNoCritic ProhibitMagicNumbers RequireCheckedSyscalls) # USER DEFAULT 1: allow numeric values & print operator
20             ## no critic qw(RequireInterpolationOfMetachars) # USER DEFAULT 2: allow single-quoted control characters & sigils
21              
22             # [[[ CONSTANTS ]]]
23 4     4   17 use constant NAME => my string $TYPED_NAME = 'sort';
  4         9  
  4         209  
24 4     4   23 use constant ARGUMENTS_MIN => my integer $TYPED_ARGUMENTS_MIN = 1;
  4         7  
  4         183  
25 4     4   21 use constant ARGUMENTS_MAX => my integer $TYPED_ARGUMENTS_MAX = 999;
  4         9  
  4         2496  
26              
27             # [[[ OO PROPERTIES ]]]
28             our hashref $properties = {};
29              
30             # [[[ SUBROUTINES & OO METHODS ]]]
31              
32             sub ast_to_rperl__generate {
33 13     13   28 { my string_hashref::method $RETURN_TYPE };
  13         30  
34 13         37 ( my object $self, my object $operator_named, my string_hashref $modes)
35             = @ARG;
36 13         62 my string_hashref $rperl_source_group = { PMC => q{} };
37              
38             # RPerl::diag( 'in Operator::Named::Sort->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
39             # RPerl::diag( 'in Operator::Named::Sort->ast_to_rperl__generate(), received $operator_named = ' . "\n" . RPerl::Parser::rperl_ast__dump($operator_named) . "\n" );
40              
41 13         41 my string $operator_named_class = ref $operator_named;
42 13 50       62 if ( $operator_named_class eq 'Operation_90' ) { # Operation -> OP01_NAMED_SCOLON
    50          
    0          
    0          
43             die RPerl::Parser::rperl_rule__replace(
44             'ERROR ECOGEASRP17, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Named operator '
45 0         0 . $operator_named->{children}->[0]
46             . ' requires one or more arguments, dying' )
47             . "\n";
48             }
49             elsif ( $operator_named_class eq 'Operator_94' ) # Operator -> OP01_NAMED SubExpression
50             {
51 13         54 $rperl_source_group->{PMC} .= $operator_named->{children}->[0] . q{ };
52             my string_hashref $rperl_source_subgroup
53 13         283 = $operator_named->{children}->[1]
54             ->ast_to_rperl__generate( $modes, $self );
55 13         289 RPerl::Generator::source_group_append( $rperl_source_group,
56             $rperl_source_subgroup );
57             }
58             elsif ( $operator_named_class eq 'Operator_95' ) { # Operator -> LPAREN OP01_NAMED ListElement OP21_LIST_COMMA ListElements ')'
59 0         0 my string $left_paren = $operator_named->{children}->[0];
60 0         0 my string $operator_name = $operator_named->{children}->[1];
61 0         0 my object $argument0 = $operator_named->{children}->[2];
62 0         0 my string $list_comma = $operator_named->{children}->[3];
63 0         0 my object $arguments = $operator_named->{children}->[4];
64 0         0 my string $right_paren = $operator_named->{children}->[5];
65              
66 0         0 my integer $argument_count = $arguments->length() + 1;
67 0 0       0 if ( $argument_count < ARGUMENTS_MIN() ) {
68 0         0 die
69             'ERROR ECOGEASRP02, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL:'
70             . "\n"
71             . 'Argument count '
72             . $argument_count
73             . ' falls below minimum argument limit '
74             . ARGUMENTS_MIN()
75             . ' for operation ' . q{'}
76             . NAME() . q{'}
77             . ', dying' . "\n";
78             }
79 0 0       0 if ( $argument_count > ARGUMENTS_MAX() ) {
80 0         0 die
81             'ERROR ECOGEASRP03, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL:'
82             . "\n"
83             . 'Argument count '
84             . $argument_count
85             . ' exceeds maximum argument limit '
86             . ARGUMENTS_MAX()
87             . ' for operation ' . q{'}
88             . NAME() . q{'}
89             . ', dying' . "\n";
90             }
91              
92 0         0 $rperl_source_group->{PMC} .= $left_paren . q{ } . $operator_name . q{ };
93 0         0 my string_hashref $rperl_source_subgroup = $argument0->ast_to_rperl__generate( $modes, $self );
94 0         0 RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup );
95 0         0 $rperl_source_group->{PMC} .= $list_comma . q{ };
96 0         0 $rperl_source_subgroup = $arguments->ast_to_rperl__generate( $modes, $self );
97 0         0 RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup );
98 0         0 $rperl_source_group->{PMC} .= q{ } . $right_paren;
99             }
100             elsif ( $operator_named_class eq 'OperatorVoid_134' ) { # OperatorVoid -> OP01_NAMED ListElement OP21_LIST_COMMA ListElements ';'
101 0         0 my string $operator_name = $operator_named->{children}->[0];
102 0         0 my object $argument0 = $operator_named->{children}->[1];
103 0         0 my string $list_comma = $operator_named->{children}->[2];
104 0         0 my object $arguments = $operator_named->{children}->[3];
105 0         0 my string $semicolon = $operator_named->{children}->[4];
106              
107 0         0 my integer $argument_count = $arguments->length() + 1;
108 0 0       0 if ( $argument_count < ARGUMENTS_MIN() ) {
109 0         0 die
110             'ERROR ECOGEASRP02, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL:'
111             . "\n"
112             . 'Argument count '
113             . $argument_count
114             . ' falls below minimum argument limit '
115             . ARGUMENTS_MIN()
116             . ' for operation ' . q{'}
117             . NAME() . q{'}
118             . ', dying' . "\n";
119             }
120 0 0       0 if ( $argument_count > ARGUMENTS_MAX() ) {
121 0         0 die
122             'ERROR ECOGEASRP03, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL:'
123             . "\n"
124             . 'Argument count '
125             . $argument_count
126             . ' exceeds maximum argument limit '
127             . ARGUMENTS_MAX()
128             . ' for operation ' . q{'}
129             . NAME() . q{'}
130             . ', dying' . "\n";
131             }
132              
133 0         0 $rperl_source_group->{PMC} .= $operator_name . q{ };
134 0         0 my string_hashref $rperl_source_subgroup = $argument0->ast_to_rperl__generate( $modes, $self );
135 0         0 RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup );
136 0         0 $rperl_source_group->{PMC} .= $list_comma . q{ };
137 0         0 $rperl_source_subgroup = $arguments->ast_to_rperl__generate( $modes, $self );
138 0         0 RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup );
139 0         0 $rperl_source_group->{PMC} .= $semicolon . "\n";
140             }
141             else {
142 0         0 die RPerl::Parser::rperl_rule__replace(
143             'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule '
144             . ($operator_named_class)
145             . ' found where Operation_90, Operator_94, Operator_95, or OperatorVoid_134 expected, dying'
146             ) . "\n";
147             }
148 13         40 return $rperl_source_group;
149             }
150              
151             sub ast_to_cpp__generate__CPPOPS_PERLTYPES {
152 0     0     { my string_hashref::method $RETURN_TYPE };
  0            
153 0           ( my object $self, my string_hashref $modes) = @ARG;
154 0           my string_hashref $cpp_source_group
155             = { CPP =>
156             q{// <<< RP::O::E::O::N::So __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>}
157             . "\n" };
158              
159             #...
160 0           return $cpp_source_group;
161             }
162              
163             sub ast_to_cpp__generate__CPPOPS_CPPTYPES {
164 0     0     { my string_hashref::method $RETURN_TYPE };
  0            
165 0           ( my object $self, my string_hashref $modes) = @ARG;
166 0           my string_hashref $cpp_source_group
167             = { CPP =>
168             q{// <<< RP::O::E::O::N::So __DUMMY_SOURCE_CODE CPPOPS_CPPTYPES >>>}
169             . "\n" };
170              
171             #...
172 0           return $cpp_source_group;
173             }
174              
175             1; # end of class