"Fossies" - the Fresh Open Source Software Archive

Member "RPerl-5.002000/lib/RPerl/Operation/Expression/SubExpression/ArrayDereference.pm" (30 Aug 2019, 4143 Bytes) of package /linux/misc/RPerl-5.002000.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ArrayDereference.pm" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 3.601000_vs_4.000000.

    1 # [[[ HEADER ]]]
    2 package RPerl::Operation::Expression::SubExpression::ArrayDereference;
    3 use strict;
    4 use warnings;
    5 use RPerl::AfterSubclass;
    6 our $VERSION = 0.002_200;
    7 
    8 # [[[ OO INHERITANCE ]]]
    9 use parent qw(RPerl::Operation::Expression::SubExpression);
   10 use RPerl::Operation::Expression::SubExpression;
   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 sub ast_to_rperl__generate {
   22     { my string_hashref::method $RETURN_TYPE };
   23     ( my object $self, my string_hashref $modes) = @ARG;
   24     my string_hashref $rperl_source_group = { PMC => q{} };
   25     my object $rperl_source_subgroup;
   26 
   27 #    RPerl::diag( 'in ArrayDereference->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
   28 
   29     my string $self_class = ref $self;
   30     # unwrap ArrayDereference_221 and ArrayDereference_222 from SubExpression_160
   31     if ( $self_class eq 'SubExpression_160' ) {  # SubExpression -> ArrayDereference
   32         $self = $self->{children}->[0];
   33     }
   34 
   35     $self_class = ref $self;
   36     if ( $self_class eq 'ArrayDereference_221' ) {  # ArrayDereference -> '@{' Variable '}'
   37         my string $at_left_brace = $self->{children}->[0];
   38         my object $variable = $self->{children}->[1];
   39         my string $right_brace = $self->{children}->[2];
   40  
   41         $rperl_source_group->{PMC} .= $at_left_brace . q{ };
   42         $rperl_source_subgroup = $variable->ast_to_rperl__generate($modes);
   43         RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup );
   44         $rperl_source_group->{PMC} .= q{ } . $right_brace;
   45     }
   46     elsif ( $self_class eq 'ArrayDereference_222' ) {  # ArrayDereference -> '@{' OPTIONAL-47 ArrayReference '}'
   47         my string $at_left_brace = $self->{children}->[0];
   48         my object $type_inner_optional = $self->{children}->[1];
   49         my object $array_reference = $self->{children}->[2];
   50         my string $right_brace = $self->{children}->[3];
   51  
   52         $rperl_source_group->{PMC} .= $at_left_brace . q{ };
   53         if (exists $type_inner_optional->{children}->[0]) {
   54             $rperl_source_subgroup = $type_inner_optional->{children}->[0]->ast_to_rperl__generate($modes);
   55             RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup );
   56             $rperl_source_group->{PMC} .= q{ };
   57         }
   58         $rperl_source_subgroup = $array_reference->ast_to_rperl__generate($modes);
   59         RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup );
   60         $rperl_source_group->{PMC} .= q{ } . $right_brace;
   61     }
   62     else {
   63         die RPerl::Parser::rperl_rule__replace(
   64             'ERROR ECOGEASRP000, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule '
   65                 . $self_class
   66                 . ' found where ArrayDereference_221 or ArrayDereference_222 expected, dying'
   67         ) . "\n";
   68     }
   69     return $rperl_source_group;
   70 }
   71 
   72 sub ast_to_cpp__generate__CPPOPS_PERLTYPES {
   73     { my string_hashref::method $RETURN_TYPE };
   74     ( my object $self, my string_hashref $modes) = @ARG;
   75     my string_hashref $cpp_source_group = { CPP => q{// <<< RP::O::E::SE::AD __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>} . "\n" };
   76 
   77     #...
   78     return $cpp_source_group;
   79 }
   80 
   81 sub ast_to_cpp__generate__CPPOPS_CPPTYPES {
   82     { my string_hashref::method $RETURN_TYPE };
   83     ( my object $self, my string_hashref $modes) = @ARG;
   84     my string_hashref $cpp_source_group = { CPP => q{// <<< RP::O::E::SE::AD __DUMMY_SOURCE_CODE CPPOPS_CPPTYPES >>>} . "\n" };
   85 
   86 #    RPerl::diag( 'in ArrayDereference->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
   87     # DEV NOTE, CORRELATION #rp031: NEED UPGRADE: implement proper @array vs $arrayref, %hash vs $hashref, dereferencing, etc.
   88 
   89     return $cpp_source_group;
   90 }
   91 
   92 1;    # end of class