File Coverage

blib/lib/RPerl/Operation/Statement/OperatorVoid/Named.pm
Criterion Covered Total %
statement 43 52 82.6
branch 6 8 75.0
condition 5 6 83.3
subroutine 7 8 87.5
pod n/a
total 61 74 82.4


line stmt bran cond sub pod time code
1             # [[[ HEADER ]]]
2             package RPerl::Operation::Statement::OperatorVoid::Named;
3 4     4   1122 use strict;
  4         8  
  4         100  
4 4     4   21 use warnings;
  4         10  
  4         88  
5 4     4   20 use RPerl::AfterSubclass;
  4         9  
  4         520  
6             our $VERSION = 0.002_000;
7              
8             # [[[ OO INHERITANCE ]]]
9 4     4   25 use parent qw(RPerl::Operation::Statement::OperatorVoid);
  4         8  
  4         21  
10 4     4   220 use RPerl::Operation::Statement::OperatorVoid;
  4         9  
  4         2004  
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             # [[[ OO PROPERTIES, CLASS PROPERTY AKA PACKAGE VARIABLE ]]]
20             our string_hashref $NAMES = {
21             'return' => 'RPerl::Operation::Statement::OperatorVoid::Named::Return',
22             'exit' => 'RPerl::Operation::Statement::OperatorVoid::Named::Exit',
23             'die' => 'RPerl::Operation::Statement::OperatorVoid::Named::Die',
24             'croak' => 'RPerl::Operation::Statement::OperatorVoid::Named::Croak'
25             };
26              
27             # [[[ SUBROUTINES & OO METHODS ]]]
28              
29             sub ast_to_rperl__generate {
30 428     428   1489 { my string_hashref::method $RETURN_TYPE };
  428         1409  
31 428         1712 ( my object $self, my string_hashref $modes) = @ARG;
32 428         1831 my string_hashref $rperl_source_group = { PMC => q{} };
33 428         1355 my string_hashref $rperl_source_subgroup;
34              
35             # RPerl::diag( 'in OperatorVoid::Named->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
36              
37 428         2166 my string $operator_void_name = $self->{children}->[0];
38 428 100 100     5746 if ( ( ( substr $operator_void_name, -1, 1 ) eq q{;} ) or ( ( substr $operator_void_name, -1, 1 ) eq q{(} )) {
39 72         298 chop $operator_void_name;
40             }
41 428 50       2679 if ( not exists $NAMES->{$operator_void_name} ) {
42             die
43             q{ERROR ECOGEASRP01, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: unsupported or unrecognized named void operator '}
44             . $operator_void_name
45             . q{' found where }
46 0         0 . ( join ', ', ( sort keys %{$NAMES} ) )
  0         0  
47             . ' expected, dying' . "\n";
48             }
49 428         1880 my string $operator_void_class = $NAMES->{$operator_void_name};
50 428         8000 my object $operator_void_object = $operator_void_class->new();
51              
52 428         12429 $rperl_source_subgroup
53             = $operator_void_object->ast_to_rperl__generate( $modes, $self );
54 407         8774 RPerl::Generator::source_group_append( $rperl_source_group,
55             $rperl_source_subgroup );
56 407         6126 return $rperl_source_group;
57             }
58              
59             sub ast_to_cpp__generate__CPPOPS_PERLTYPES {
60 0     0   0 { my string_hashref::method $RETURN_TYPE };
  0         0  
61 0         0 ( my object $self, my string_hashref $modes) = @ARG;
62 0         0 my string_hashref $cpp_source_group
63             = { CPP =>
64             q{// <<< RP::O::S::OV::N __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>}
65             . "\n" };
66              
67             #...
68 0         0 return $cpp_source_group;
69             }
70              
71             # DEV NOTE: PERLOPS_PERLTYPES & CPPOPS_CPPTYPES code generation are exactly equivalent
72             sub ast_to_cpp__generate__CPPOPS_CPPTYPES {
73 39     39   95 { my string_hashref::method $RETURN_TYPE };
  39         69  
74 39         93 ( my object $self, my string_hashref $modes) = @ARG;
75 39         149 my string_hashref $cpp_source_group = { CPP => q{} };
76 39         65 my string_hashref $cpp_source_subgroup;
77              
78             # RPerl::diag( 'in OperatorVoid::Named->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
79              
80 39         169 my string $operator_void_name = $self->{children}->[0];
81 39 100 66     212 if ( ( ( substr $operator_void_name, -1, 1 ) eq q{;} ) or ( ( substr $operator_void_name, -1, 1 ) eq q{(} )) {
82 21         63 chop $operator_void_name;
83             }
84 39 50       120 if ( not exists $NAMES->{$operator_void_name} ) {
85             die
86             q{ERROR ECOGEASCP01, CODE GENERATOR, ABSTRACT SYNTAX TO C++: unsupported or unrecognized named void operator '}
87             . $operator_void_name
88             . q{' found where }
89 0         0 . ( join ', ', ( sort keys %{$NAMES} ) )
  0         0  
90             . ' expected, dying' . "\n";
91             }
92 39         110 my string $operator_void_class = $NAMES->{$operator_void_name};
93 39         533 my object $operator_void_object = $operator_void_class->new();
94              
95 39         1029 $cpp_source_subgroup
96             = $operator_void_object->ast_to_cpp__generate__CPPOPS_CPPTYPES( $modes, $self );
97 39         785 RPerl::Generator::source_group_append( $cpp_source_group,
98             $cpp_source_subgroup );
99 39         494 return $cpp_source_group;
100             }
101              
102             1; # end of class