Changeset 21550 for perl5

Show
Ignore:
Timestamp:
07/26/08 18:40:23 (6 months ago)
Author:
fglock
Message:

[v6.pm] array fixes; more tests

Location:
perl5/Pugs-Compiler-Perl6
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • perl5/Pugs-Compiler-Perl6/MANIFEST

    r21456 r21550  
    160160t/spec/S16-io/say.t 
    161161t/spec/S29-any/cmp.t 
     162t/spec/S29-array/delete.t 
    162163t/spec/S29-array/exists.t 
    163164t/spec/S29-context/exit-in-if.t 
  • perl5/Pugs-Compiler-Perl6/lib/Pugs/Emitter/Perl6/Perl5.pm

    r21546 r21550  
    666666        ) 
    667667    { 
    668         if ( $n->{sub}{bareword} eq 'push' && $n->{op1} eq 'call' ) { 
     668        if ( (  $n->{sub}{bareword} eq 'push'  
     669             || $n->{sub}{bareword} eq 'pop'  
     670             ) 
     671            && $n->{op1} eq 'call' )  
     672        { 
    669673            if ( _is_paren_containing($n->{param}, \&_is_empty_exp) ) { 
    670                 return _not_implemented( "push without parameters", "call" ); 
     674                return _not_implemented( $n->{sub}{bareword} . " without parameters", "call" ); 
    671675            } 
    672676            if ( _is_paren_containing($n->{param}, \&_is_exp_containing, \&_is_empty_braces ) ) { 
     
    944948                return 'Pugs::Runtime::Perl6::Array::map([\('.$code.', '. _emit( $n->{self} ).')], {})'; 
    945949            } 
    946             if (  $n->{method}{dot_bareword} eq 'delete' 
    947                || $n->{method}{dot_bareword} eq 'exists' 
    948                ) { 
     950            if (  $n->{method}{dot_bareword} eq 'delete' ) { 
     951                my $self = _emit($n->{self}); 
     952                return '( bless [' 
     953                    . _emit( $n->{method} ).' '.$self.'['._emit($n->{param}).']' 
     954                    . "], 'Pugs::Runtime::Perl6::Array' )"; 
     955            } 
     956            if ( $n->{method}{dot_bareword} eq 'exists' ) { 
    949957                my $self = _emit($n->{self}); 
    950958                $self =~ s{\@}{\$}; 
  • perl5/Pugs-Compiler-Perl6/lib/Pugs/Runtime/Perl6.pm

    r21546 r21550  
    355355     
    356356package Pugs::Runtime::Perl6::Array; 
     357    use overload ( 
     358        '""'     => \&str, 
     359        '0+'     => sub { scalar @{$_[0]} }, 
     360        'bool'   => sub { scalar @{$_[0]} ? 1 : 0 }, 
     361        fallback => 1, 
     362    ); 
     363    sub str { 
     364        join( " ", @{$_[0]} ) 
     365    } 
    357366 
    358367    sub map {