File Coverage

blib/lib/RPerl/Operation/Expression/SubroutineCall.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::Expression::SubroutineCall;
3 5     5   36 use strict;
  5         15  
  5         132  
4 5     5   24 use warnings;
  5         11  
  5         103  
5 5     5   25 use RPerl::AfterSubclass;
  5         11  
  5         638  
6             our $VERSION = 0.002_100;
7              
8             # [[[ OO INHERITANCE ]]]
9 5     5   36 use parent qw(RPerl::Operation::Expression);
  5         12  
  5         29  
10 5     5   348 use RPerl::Operation::Expression;
  5         14  
  5         2448  
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             my string_hashref $rperl_source_subgroup;
25              
26             # RPerl::diag( 'in SubroutineCall->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
27              
28             if ( ( ref $self ) ne 'Expression_132' ) {
29             die RPerl::Parser::rperl_rule__replace(
30             'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule '
31             . ( ref $self )
32             . ' found where Expression_132 expected, dying' )
33             . "\n";
34             }
35              
36             # Expression -> WordScoped LPAREN OPTIONAL-33 ')'
37             my object $name = $self->{children}->[0];
38             my string $left_paren = $self->{children}->[1];
39             my object $arguments_optional = $self->{children}->[2];
40             my string $right_paren = $self->{children}->[3];
41             $rperl_source_group->{PMC}
42             .= $name->{children}->[0] . $left_paren;
43              
44             if ( exists $arguments_optional->{children}->[0] ) {
45             $rperl_source_subgroup = $arguments_optional->{children}->[0]
46             ->ast_to_rperl__generate($modes);
47             RPerl::Generator::source_group_append( $rperl_source_group,
48             $rperl_source_subgroup );
49             }
50              
51             $rperl_source_group->{PMC} .= $right_paren;
52             return $rperl_source_group;
53             };
54              
55             our string_hashref::method $ast_to_cpp__generate__CPPOPS_PERLTYPES = sub {
56             ( my object $self, my string_hashref $modes) = @_;
57             my string_hashref $cpp_source_group
58             = {
59             CPP => q{// <<< RP::O::E::SC __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>}
60             . "\n"
61             };
62              
63             #...
64             return $cpp_source_group;
65             };
66              
67             our string_hashref::method $ast_to_cpp__generate__CPPOPS_CPPTYPES = sub {
68             ( my object $self, my string_hashref $modes) = @_;
69             my string_hashref $cpp_source_group = { CPP => q{} };
70             my string_hashref $cpp_source_subgroup;
71              
72             # RPerl::diag( 'in SubroutineCall->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
73              
74             if ( ( ref $self ) ne 'Expression_132' ) {
75             die RPerl::Parser::rperl_rule__replace(
76             'ERROR ECOGEASCP00, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule '
77             . ( ref $self )
78             . ' found where Expression_132 expected, dying' )
79             . "\n";
80             }
81              
82             # Expression -> WordScoped LPAREN OPTIONAL-33 ')'
83             my object $name = $self->{children}->[0];
84             my string $left_paren = $self->{children}->[1];
85             my object $arguments_optional = $self->{children}->[2];
86             my string $right_paren = $self->{children}->[3];
87            
88             # remove leading double-colon scope operator '::'
89             my string $name_string = $name->{children}->[0];
90             if ((substr $name_string, 0, 2) eq '::') {
91             substr $name_string, 0, 2, '';
92             }
93            
94             # replace RPerl system builtin functions with proper C++ name alternatives
95             if (exists $rperloperations::BUILTINS->{$name_string}) {
96             $name_string = $rperloperations::BUILTINS->{$name_string};
97             }
98              
99             # replace all semicolons with underscores
100             $name_string =~ s/:/_/gxms;
101              
102             $cpp_source_group->{CPP} .= $name_string . $left_paren;
103              
104             if ( exists $arguments_optional->{children}->[0] ) {
105             $cpp_source_subgroup = $arguments_optional->{children}->[0]
106             ->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes);
107             RPerl::Generator::source_group_append( $cpp_source_group,
108             $cpp_source_subgroup );
109             }
110              
111             $cpp_source_group->{CPP} .= $right_paren;
112             return $cpp_source_group;
113             };
114              
115             1; # end of class