Changeset 22888 for v6

Show
Ignore:
Timestamp:
11/05/08 20:49:14 (2 months ago)
Author:
ruoso
Message:

[mildew] allow multiple arguments in method calls to preserve the information for those using the capture in slice context...

Location:
v6/mildew
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • v6/mildew/mildew

    r22887 r22888  
    1515use Getopt::Long; 
    1616use Carp 'confess'; 
     17use Scalar::Util qw(blessed); 
    1718 
    1819my ($desugar,$debug,$file,$exec); 
     
    4142} 
    4243 
    43 sub VAST::ws::emit_m0ld {} 
     44sub VAST::ws::emit_m0ld { 
     45    my $m = shift; 
     46    ( map { 
     47        warn ' extracting '.$_.' from ws '; 
     48        $m->{$_}->emit_m0ld 
     49      } grep { blessed $m->{$_} } keys %{$m} ), 
     50    ( map { 
     51        warn ' extracting '.ref($_).' from ws '; 
     52        $_->emit_m0ld 
     53      } map { @{$m->{$_}} } grep { ref $m->{$_} eq 'ARRAY' } keys %{$m} ), 
     54} 
    4455 
    4556sub VAST::longname::canonical { 
     
    7889                    ), 
    7990                ); 
     91            } else { 
     92                XXX; 
    8093            } 
     94        } else { 
     95            XXX; 
    8196        } 
    8297    } else { 
     
    121136        if ($name->{morename} and !$name->{identifier}) { 
    122137            lookup join '',map {$_->{identifier}[0]{TEXT}} @{$name->{morename}}; 
    123              
    124         } 
     138        } else { 
     139            XXX; 
     140        } 
     141    } else { 
     142        XXX; 
    125143    } 
    126144} 
     
    205223sub VAST::sublongname::canonical { 
    206224    my $m = shift; 
     225    XXX; 
    207226} 
    208227sub varname { 
     
    227246sub VAST::Comma::emit_m0ld { 
    228247    my $m = shift; 
    229     map {$_->emit_m0ld} @{$m->{list}}; 
     248    AST::List->new( 
     249        elements => [ map {$_->emit_m0ld} @{$m->{list}} ] 
     250    ); 
    230251} 
    231252sub VAST::nulltermish::emit_m0ld { 
     
    238259    if (my $methodop = $m->{dottyop}{methodop}) { 
    239260        if ($methodop->{longname}) { 
    240             my $positional = $methodop->{semilist}[0]{statement}[0]; 
    241             my @positional = $positional ? $positional->emit_m0ld : (); 
     261            my $positional = [ map { map { $_->emit_m0ld } @{$_->{statement}} } @{$methodop->{semilist}} ]; 
    242262            my $ident = $methodop->{longname}->canonical; 
    243263            if ($m->{sym} eq '^!') { 
     
    246266            AST::Call->new( 
    247267                identifier=>string $ident, 
    248                 capture=>AST::Capture->new(invocant=>FETCH($noun),positional=>[@positional]), 
     268                capture=>AST::Capture->new(invocant=>FETCH($noun),positional=>$positional), 
    249269            ); 
    250270        } else { 
     
    253273    } elsif (my $postop = $m->{dottyop}{postop}) { 
    254274        if (my $postcircumfix = $postop->{postcircumfix}) { 
    255             my $positional = $methodop->{semilist}[0]{statement}[0]; 
    256             my @positional = $positional ? $positional->emit_m0ld : (); 
     275            my $positional = [ map { map { $_->emit_m0ld } @{$_->{statement}} } @{$methodop->{semilist}} ]; 
    257276            AST::Call->new( 
    258277                identifier => string 'postcircumfix:'.$postcircumfix->{FIRST}.' '.$postcircumfix->{LAST}, 
    259                 capture => AST::Capture->new(invocant=>FETCH($noun),positional=>[@positional]), 
     278                capture => AST::Capture->new(invocant=>FETCH($noun),positional=>$positional), 
    260279            ); 
    261280        } else { 
     
    294313sub VAST::Methodcall::emit_m0ld { 
    295314    my $m = shift; 
    296     $m->{arg}->emit_m0ld; 
     315    $m->{dotty}->emit_m0ld($m->{arg}{noun}->emit_m0ld); 
    297316} 
    298317sub VAST::List_assignment::emit_m0ld { 
  • v6/mildew/src/AST.pm

    r22887 r22888  
    11{ 
    22package AST; 
     3use utf8; 
    34my $id=0; 
    45sub unique_id { 
     
    9495has 'identifier'; 
    9596has 'stmt'; 
     97 
     98package AST::List; 
     99use Moose; 
     100extends 'AST::Base'; 
     101has 'elements' => (is=>'ro'); 
     102 
     103sub m0ld { 
     104    my ($self, $ret) = @_; 
     105    my @args; 
     106    my $code; 
     107    for (@{$self->elements}) { 
     108        my $id = AST::unique_id(); 
     109        $code .= $_->m0ld($id); 
     110        push @args, $id; 
     111    } 
     112    $code .= 'my '.$ret.' = ?SMOP__S1P__List."new"('.join(',',@args).');'.$/; 
     113} 
    96114 
    97115package AST::Named;