File Coverage

blib/lib/RPerl/CompileUnit/Include.pm
Criterion Covered Total %
statement 30 51 58.8
branch 3 14 21.4
condition 0 12 0.0
subroutine 6 8 75.0
pod n/a
total 39 85 45.8


line stmt bran cond sub pod time code
1             # [[[ HEADER ]]]
2             package RPerl::CompileUnit::Include;
3 3     3   18 use strict;
  3         7  
  3         72  
4 3     3   15 use warnings;
  3         6  
  3         65  
5 3     3   14 use RPerl::AfterSubclass;
  3         21  
  3         407  
6             our $VERSION = 0.002_300;
7              
8             # [[[ OO INHERITANCE ]]]
9 3     3   20 use parent qw(RPerl::GrammarRule);
  3         6  
  3         14  
10 3     3   170 use RPerl::GrammarRule;
  3         9  
  3         1778  
11              
12             # [[[ CRITICS ]]]
13             ## no critic qw(ProhibitUselessNoInclude 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             sub ast_to_rperl__generate {
22 163     163   424 { my string_hashref::method $RETURN_TYPE };
  163         422  
23 163         596 ( my object $self, my string_hashref $modes) = @ARG;
24 163         754 my string_hashref $rperl_source_group = { PMC => q{} };
25              
26             # RPerl::diag( 'in Include->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
27             # RPerl::diag( 'in Include->ast_to_rperl__generate(), have ::class($self) = ' . ::class($self) . "\n" );
28 163 100       924 if ( ref $self eq 'Include_50' ) {
    50          
29             # Include -> USE_OR_REQUIRE WordScoped ';'
30 142         578 my string $use_or_require_keyword = $self->{children}->[0];
31             my string $module_name
32 142         517 = $self->{children}->[1]->{children}->[0];
33 142         528 my string $semicolon = $self->{children}->[2];
34             $rperl_source_group->{PMC}
35 142         734 .= $use_or_require_keyword . q{ } . $module_name . $semicolon . "\n";
36              
37             # RPerl::diag( 'in Include->ast_to_rperl__generate(), have $module_name = ' . $module_name . "\n" );
38             }
39             elsif ( ref $self eq 'Include_51' ) {
40             # Include -> USE_OR_REQUIRE WordScoped OP01_QW ';'
41 21         139 my string $use_or_require_keyword = $self->{children}->[0];
42             my string $module_name
43 21         98 = $self->{children}->[1]->{children}->[0];
44 21         113 my string $qw = $self->{children}->[2];
45 21         78 my string $semicolon = $self->{children}->[3];
46             $rperl_source_group->{PMC}
47 21         163 .= $use_or_require_keyword . q{ }
48             . $module_name . q{ }
49             . $qw
50             . $semicolon . "\n";
51             }
52             else {
53 0         0 die RPerl::Parser::rperl_rule__replace(
54             'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule '
55             . ( ref $self )
56             . ' found where Include_50 or Include_51 expected, dying' )
57             . "\n";
58             }
59 163         927 return $rperl_source_group;
60             }
61              
62             sub ast_to_cpp__generate__CPPOPS_PERLTYPES {
63 0     0     { my string_hashref::method $RETURN_TYPE };
  0            
64 0           ( my object $self, my string_hashref $modes) = @ARG;
65 0           my string_hashref $cpp_source_group
66             = { CPP => q{// <<< RP::CU::I __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>}
67             . "\n" };
68              
69             #...
70 0           return $cpp_source_group;
71             }
72              
73             sub ast_to_cpp__generate__CPPOPS_CPPTYPES {
74 0     0     { my string_hashref::method $RETURN_TYPE };
  0            
75 0           ( my object $self, my string $package_name_underscores, my string_hashref $modes) = @ARG;
76             # RPerl::diag( 'in Include->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
77 0           my string_hashref $cpp_source_group = { H => q{} };
78              
79             # NEED ANSWER: no difference between wholesale includes and selective includes in C++?
80 0 0 0       if (( ref $self eq 'Include_50' ) or ( ref $self eq 'Include_51' )) {
81             # Include -> USE_OR_REQUIRE WordScoped ...
82             # DEV NOTE: ignore manually included RPerl* and rperl* modules, presumably they will all be automatically included
83 0           my string $module_name = $self->{children}->[1]->{children}->[0];
84 0 0 0       if ( $module_name =~ /^\w+Perl::Config$/ ) { # DEV NOTE, CORRELATION #rp027: MathPerl::Config, PhysicsPerl::Config, etc
    0          
85             # RPerl::diag('in CompileUnit::Include->ast_to_cpp__generate__CPPOPS_CPPTYPES(), skipping system config file $module_name = ' . $module_name . "\n");
86             }
87             elsif (((substr $module_name, 0, 5) ne 'RPerl') and ((substr $module_name, 0, 5) ne 'rperl')) {
88 0 0 0       if ((not exists $cpp_source_group->{_PMC_includes}) or (not defined $cpp_source_group->{_PMC_includes})) {
    0 0        
89 0           $cpp_source_group->{_PMC_includes} = {};
90             }
91             elsif ((not exists $cpp_source_group->{_PMC_includes}->{$package_name_underscores})
92             or (not defined $cpp_source_group->{_PMC_includes}->{$package_name_underscores})) {
93 0           $cpp_source_group->{_PMC_includes}->{$package_name_underscores} = q{};
94             }
95 0           $cpp_source_group->{_PMC_includes}->{$package_name_underscores} .= 'require ' . $module_name . ';' . "\n";
96 0           $module_name =~ s/::/\//gxms;
97 0           $cpp_source_group->{H} .= q{#include "} . $module_name . q{.cpp"} . "\n";
98             # RPerl::diag( 'in Include->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $module_name = ' . $module_name . "\n" );
99             }
100             }
101             else {
102 0           die RPerl::Parser::rperl_rule__replace(
103             'ERROR ECOGEASCP00, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule '
104             . ( ref $self )
105             . ' found where Include_50 or Include_51 expected, dying' )
106             . "\n";
107             }
108            
109             # RPerl::diag( 'in Include->ast_to_cpp__generate__CPPOPS_CPPTYPES(), about to return $cpp_source_group = ' . "\n" . RPerl::Parser::rperl_ast__dump($cpp_source_group) . "\n" );
110 0           return $cpp_source_group;
111             }
112              
113             1; # end of class