File Coverage

blib/lib/RPerl/Operation/Statement/OperatorVoid/Named.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 20 20 100.0


line stmt bran cond sub pod time code
1             # [[[ HEADER ]]]
2             package RPerl::Operation::Statement::OperatorVoid::Named;
3 5     5   1991 use strict;
  5         17  
  5         144  
4 5     5   30 use warnings;
  5         11  
  5         126  
5 5     5   28 use RPerl::AfterSubclass;
  5         14  
  5         708  
6             our $VERSION = 0.002_000;
7              
8             # [[[ OO INHERITANCE ]]]
9 5     5   41 use parent qw(RPerl::Operation::Statement::OperatorVoid);
  5         13  
  5         33  
10 5     5   333 use RPerl::Operation::Statement::OperatorVoid;
  5         14  
  5         2284  
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             our string_hashref::method $ast_to_rperl__generate = sub {
30             ( my object $self, my string_hashref $modes) = @_;
31             my string_hashref $rperl_source_group = { PMC => q{} };
32             my string_hashref $rperl_source_subgroup;
33              
34             # RPerl::diag( 'in OperatorVoid::Named->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
35              
36             my string $operator_void_name = $self->{children}->[0];
37             if ( ( ( substr $operator_void_name, -1, 1 ) eq q{;} ) or ( ( substr $operator_void_name, -1, 1 ) eq q{(} )) {
38             chop $operator_void_name;
39             }
40             if ( not exists $NAMES->{$operator_void_name} ) {
41             die
42             q{ERROR ECOGEASRP01, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: unsupported or unrecognized named void operator '}
43             . $operator_void_name
44             . q{' found where }
45             . ( join ', ', ( sort keys %{$NAMES} ) )
46             . ' expected, dying' . "\n";
47             }
48             my string $operator_void_class = $NAMES->{$operator_void_name};
49             my object $operator_void_object = $operator_void_class->new();
50              
51             $rperl_source_subgroup
52             = $operator_void_object->ast_to_rperl__generate( $modes, $self );
53             RPerl::Generator::source_group_append( $rperl_source_group,
54             $rperl_source_subgroup );
55              
56             return $rperl_source_group;
57             };
58              
59             our string_hashref::method $ast_to_cpp__generate__CPPOPS_PERLTYPES = sub {
60             ( my object $self, my string_hashref $modes) = @_;
61             my string_hashref $cpp_source_group
62             = { CPP =>
63             q{// <<< RP::O::S::OV::N __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>}
64             . "\n" };
65              
66             #...
67             return $cpp_source_group;
68             };
69              
70             # DEV NOTE: PERLOPS_PERLTYPES & CPPOPS_CPPTYPES code generation are exactly equivalent
71             our string_hashref::method $ast_to_cpp__generate__CPPOPS_CPPTYPES = sub {
72             ( my object $self, my string_hashref $modes) = @_;
73             my string_hashref $cpp_source_group = { CPP => q{} };
74             my string_hashref $cpp_source_subgroup;
75              
76             # RPerl::diag( 'in OperatorVoid::Named->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
77              
78             my string $operator_void_name = $self->{children}->[0];
79             if ( ( ( substr $operator_void_name, -1, 1 ) eq q{;} ) or ( ( substr $operator_void_name, -1, 1 ) eq q{(} )) {
80             chop $operator_void_name;
81             }
82             if ( not exists $NAMES->{$operator_void_name} ) {
83             die
84             q{ERROR ECOGEASCP01, CODE GENERATOR, ABSTRACT SYNTAX TO C++: unsupported or unrecognized named void operator '}
85             . $operator_void_name
86             . q{' found where }
87             . ( join ', ', ( sort keys %{$NAMES} ) )
88             . ' expected, dying' . "\n";
89             }
90             my string $operator_void_class = $NAMES->{$operator_void_name};
91             my object $operator_void_object = $operator_void_class->new();
92              
93             $cpp_source_subgroup
94             = $operator_void_object->ast_to_cpp__generate__CPPOPS_CPPTYPES( $modes, $self );
95             RPerl::Generator::source_group_append( $cpp_source_group,
96             $cpp_source_subgroup );
97              
98             return $cpp_source_group;
99             };
100              
101             1; # end of class