Changeset 21546 for perl5

Show
Ignore:
Timestamp:
07/25/08 23:52:06 (4 months ago)
Author:
fglock
Message:

[v6.pm] emitter fixes

Location:
perl5/Pugs-Compiler-Perl6/lib/Pugs
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • perl5/Pugs-Compiler-Perl6/lib/Pugs/Emitter/Perl6/Perl5.pm

    r21543 r21546  
    408408} 
    409409 
     410sub _emit_array_index { 
     411    my $n = shift; 
     412    if (   ref($n) eq 'HASH'  
     413        && exists $n->{op1} 
     414        && $n->{op1} eq '*' 
     415        && $n->{fixity} eq 'prefix' 
     416        )  
     417    { 
     418        return _emit( $n->{exp1} ); 
     419    } 
     420    return _emit( $n ); 
     421} 
     422 
    410423sub _emit_parameter_signature { 
    411424    my $n = $_[0] or return ''; 
     
    653666        ) 
    654667    { 
    655         if (    $n->{sub}{bareword} eq 'push' 
    656              && $n->{op1} eq 'call' 
    657              && (  _is_paren_containing($n->{param}, \&_is_empty_exp) 
    658                 || _is_paren_containing($n->{param}, \&_is_exp_containing, \&_is_empty_braces ) 
    659                 ) 
    660             )  
    661         { 
    662             return _not_implemented( "push without parameters", "call" ); 
     668        if ( $n->{sub}{bareword} eq 'push' && $n->{op1} eq 'call' ) { 
     669            if ( _is_paren_containing($n->{param}, \&_is_empty_exp) ) { 
     670                return _not_implemented( "push without parameters", "call" ); 
     671            } 
     672            if ( _is_paren_containing($n->{param}, \&_is_exp_containing, \&_is_empty_braces ) ) { 
     673                return " # push( [] ) ??? \n";   # See: push.t 
     674            } 
    663675        } 
    664676 
     
    771783            } 
    772784 
    773             if ($subname eq 'substr' || $subname eq 'split' || $subname eq 'die' || $subname eq 'return' || $subname eq 'push' || $subname eq 'shift' || $subname eq 'join' || $subname eq 'index' || $subname eq 'undef' || $subname eq 'rand' || $subname eq 'int' || $subname eq 'splice' || $subname eq 'keys' || $subname eq 'values' || $subname eq 'sort' || $subname eq 'chomp' || $subname eq 'lc' || $subname eq 'abs' ) { 
     785            if ($subname eq 'substr' || $subname eq 'split' || $subname eq 'die' || $subname eq 'return' || $subname eq 'push' || $subname eq 'pop' || $subname eq 'shift' || $subname eq 'join' || $subname eq 'index' || $subname eq 'undef' || $subname eq 'rand' || $subname eq 'int' || $subname eq 'splice' || $subname eq 'keys' || $subname eq 'values' || $subname eq 'sort' || $subname eq 'chomp' || $subname eq 'lc' || $subname eq 'abs' ) { 
    774786                return $subname . emit_parenthesis( $n->{param} ); 
    775787            } 
     
    16441656                       ) 
    16451657                       ; 
    1646             return $name . '[' . _emit( $n->{exp2} ) . ']'; 
    1647         } 
    1648  
    1649         return _emit( $n->{exp1} ) . '->[' . _emit( $n->{exp2} ) . ']'; 
     1658            return $name . '[' . _emit_array_index( $n->{exp2} ) . ']'; 
     1659        } 
     1660 
     1661        return _emit( $n->{exp1} ) . '->[' . _emit_array_index( $n->{exp2} ) . ']'; 
    16501662    } 
    16511663 
  • perl5/Pugs-Compiler-Perl6/lib/Pugs/Runtime/Perl6.pm

    r21419 r21546  
    246246    use Scalar::Util qw(looks_like_number); 
    247247     
     248    sub elems { 
     249        return scalar @{$_[0]} if ref($_[0]) eq 'ARRAY'; 
     250        return 1; 
     251    } 
     252     
    248253    sub perl { 
    249254        local $Data::Dumper::Terse    = 1;