Changeset 21543 for perl5

Show
Ignore:
Timestamp:
07/25/08 21:28:49 (6 months ago)
Author:
fglock
Message:

[v6.pm] emitter hacks

Files:
1 modified

Legend:

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

    r21535 r21543  
    581581} 
    582582 
     583sub _is_empty_braces { 
     584    return 1 if 
     585           ref($_[0]) eq 'HASH' 
     586        && exists $_[0]{fixity} 
     587        && !exists $_[0]{exp1} 
     588        && $_[0]{fixity} eq 'circumfix' 
     589        && $_[0]{op1} eq '[' 
     590        && $_[0]{op2} eq ']' 
     591} 
     592 
     593sub _is_empty_exp { 
     594    return 1 if 
     595           ref($_[0]) eq 'HASH' 
     596        && !exists $_[0]{exp1} 
     597} 
     598 
     599sub _is_exp_containing { 
     600    return 1 if 
     601           ref($_[0]) eq 'HASH' 
     602        && exists $_[0]{exp1} 
     603        && $_[1]->( $_[0]{exp1}, @_[2..$#_] ) 
     604} 
     605 
     606sub _is_paren_containing { 
     607    return 1 if 
     608           ref($_[0]) eq 'HASH' 
     609        && exists $_[0]{fixity} 
     610        && $_[0]{fixity} eq 'circumfix' 
     611        && $_[0]{op1} eq '(' 
     612        && $_[0]{op2} eq ')' 
     613        && $_[1]->($_[0], @_[2..$#_] ) 
     614} 
     615 
    583616sub _emit_closure { 
    584617    my ($signature, $block) = @_; 
     
    620653        ) 
    621654    { 
     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" ); 
     663        } 
     664 
    622665        if ( $n->{sub}{bareword} eq 'call' ) { 
    623666            # call; 
     
    786829        no warnings 'uninitialized'; 
    787830        #warn "method_call: ", Dumper( $n ); 
     831        if ( $n->{method}{dot_bareword} eq 'nextwith' ) { 
     832            if ( exists $n->{self}{code} ) { 
     833                my ($sub_name) = $n->{self}{code} =~ /^&(.*)$/; 
     834                return 'return ' . _emit( { 
     835                        op1   => 'call', 
     836                        param => $n->{param}, 
     837                        sub   => { bareword => $sub_name }, 
     838                    } ); 
     839            } 
     840        } 
    788841        if ( $n->{method}{dot_bareword} eq 'print' || 
    789842             $n->{method}{dot_bareword} eq 'warn' ) {