Changeset 22929 for v6

Show
Ignore:
Timestamp:
11/08/08 12:42:28 (2 months ago)
Author:
pmurias
Message:

[mildew] reverted 22887 and 22888 as they output broken m0ld, 22888 likely needs to be reapplied once things works again

Location:
v6/mildew
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • v6/mildew/mildew

    r22888 r22929  
    1515use Getopt::Long; 
    1616use Carp 'confess'; 
    17 use Scalar::Util qw(blessed); 
    1817 
    1918my ($desugar,$debug,$file,$exec); 
     
    4241} 
    4342 
    44 sub 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 } 
     43sub VAST::ws::emit_m0ld {} 
    5544 
    5645sub VAST::longname::canonical { 
     
    8978                    ), 
    9079                ); 
    91             } else { 
    92                 XXX; 
    9380            } 
    94         } else { 
    95             XXX; 
    9681        } 
    9782    } else { 
     
    136121        if ($name->{morename} and !$name->{identifier}) { 
    137122            lookup join '',map {$_->{identifier}[0]{TEXT}} @{$name->{morename}}; 
    138         } else { 
    139             XXX; 
    140         } 
    141     } else { 
    142         XXX; 
     123             
     124        } 
    143125    } 
    144126} 
     
    223205sub VAST::sublongname::canonical { 
    224206    my $m = shift; 
    225     XXX; 
    226207} 
    227208sub varname { 
     
    246227sub VAST::Comma::emit_m0ld { 
    247228    my $m = shift; 
    248     AST::List->new( 
    249         elements => [ map {$_->emit_m0ld} @{$m->{list}} ] 
    250     ); 
     229    map {$_->emit_m0ld} @{$m->{list}}; 
    251230} 
    252231sub VAST::nulltermish::emit_m0ld { 
     
    259238    if (my $methodop = $m->{dottyop}{methodop}) { 
    260239        if ($methodop->{longname}) { 
    261             my $positional = [ map { map { $_->emit_m0ld } @{$_->{statement}} } @{$methodop->{semilist}} ]; 
     240            my $positional = $methodop->{semilist}[0]{statement}[0]; 
     241            my @positional = $positional ? $positional->emit_m0ld : (); 
    262242            my $ident = $methodop->{longname}->canonical; 
    263243            if ($m->{sym} eq '^!') { 
     
    266246            AST::Call->new( 
    267247                identifier=>string $ident, 
    268                 capture=>AST::Capture->new(invocant=>FETCH($noun),positional=>$positional), 
     248                capture=>AST::Capture->new(invocant=>FETCH($noun),positional=>[@positional]), 
    269249            ); 
    270250        } else { 
     
    273253    } elsif (my $postop = $m->{dottyop}{postop}) { 
    274254        if (my $postcircumfix = $postop->{postcircumfix}) { 
    275             my $positional = [ map { map { $_->emit_m0ld } @{$_->{statement}} } @{$methodop->{semilist}} ]; 
     255            my $positional = $methodop->{semilist}[0]{statement}[0]; 
     256            my @positional = $positional ? $positional->emit_m0ld : (); 
    276257            AST::Call->new( 
    277258                identifier => string 'postcircumfix:'.$postcircumfix->{FIRST}.' '.$postcircumfix->{LAST}, 
    278                 capture => AST::Capture->new(invocant=>FETCH($noun),positional=>$positional), 
     259                capture => AST::Capture->new(invocant=>FETCH($noun),positional=>[@positional]), 
    279260            ); 
    280261        } else { 
     
    313294sub VAST::Methodcall::emit_m0ld { 
    314295    my $m = shift; 
    315     $m->{dotty}->emit_m0ld($m->{arg}{noun}->emit_m0ld); 
     296    $m->{arg}->emit_m0ld; 
    316297} 
    317298sub VAST::List_assignment::emit_m0ld { 
     
    381362print $mold->pretty,"\n" if $desugar; 
    382363exit if $desugar; 
    383 my $m0ld = <<'BOILERPLATE'.$mold->m0ld('$main').<<'CALL_MAIN'; 
     364my $m0ld = <<'BOILERPLATE'.$mold->emit_('$main').<<'CALL_MAIN'; 
    384365my $void; 
    385366BOILERPLATE 
  • v6/mildew/src/AST.pm

    r22888 r22929  
    11{ 
    22package AST; 
    3 use utf8; 
    43my $id=0; 
    54sub unique_id { 
     
    2322    my $self = shift; 
    2423    my $id = AST::unique_id; 
    25     return $self->m0ld($id); 
    26  
     24    $AST::CODE .= do {local $AST::CODE='';$AST::CODE . $self->m0ld($id)}; 
     25    return $id; 
     26 
     27} 
     28sub emit_ { 
     29    local $AST::CODE = ''; 
     30    my ($self,$ret) = @_; 
     31    my $mold = $self->m0ld($ret); 
     32    $AST::CODE . $mold; 
    2733} 
    2834sub pretty { 
     
    4652    my $then = $self->then->m0ld($id_then); 
    4753 
    48     $cond. 
     54    $cond.$/. 
    4955    'my '.$id_cond.'_val = '.$id_cond.'."FETCH"();'.$/. 
    5056    'my '.$id_cond.'_bool = '.$id_cond.'_val."bool"();'.$/. 
     
    6470    "my $ret = mold {\n" 
    6571        . join('',map {'my $'.$_.";\n"} @{$self->regs}) 
    66         . join("",map { $_->m0ld('$void') } @{$self->stmts}) 
     72        . join("",map { $_->emit_('$void') } @{$self->stmts}) 
    6773    . "};\n"; 
    6874} 
     
    96102has 'stmt'; 
    97103 
    98 package AST::List; 
    99 use Moose; 
    100 extends 'AST::Base'; 
    101 has 'elements' => (is=>'ro'); 
    102  
    103 sub 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 } 
    114  
    115104package AST::Named; 
    116105use Moose; 
     
    149138    my ($self,$ret) = @_; 
    150139    if ($self->capture->isa("AST::Capture")) { 
    151         my @args; 
    152         my $code = ''; 
    153         for ($self->arguments) { 
    154             my $id = AST::unique_id(); 
    155             $code .= $_->m0ld($id); 
    156             push @args, $id; 
    157         } 
    158         my $invocant = AST::unique_id(); 
    159         $code .= $self->capture->invocant->m0ld($invocant); 
    160         my $identifier = AST::unique_id(); 
    161         $code .= $self->identifier->m0ld($identifier); 
    162         $code .= "my $ret = " 
    163           . $invocant 
    164           . "." . $identifier 
    165           . "(" . join(',', @args) . ")" . ";\n"; 
     140        "my $ret = " 
     141        . $self->capture->invocant->emit 
     142        . "." . $self->identifier->emit 
     143        . "(" . join(',', map {$_->emit} $self->arguments) . ")" . ";\n"; 
    166144    } else { 
    167145        die 'unimplemented'; 
     
    228206} 
    229207sub m0ld { 
    230     my ($self,$ret) = @_; 
    231     "my $ret = ".$self->name."\n"; 
     208    die "method m0ld is not supported on AST::Reg, m0ld doesn't support register aliasing\n" 
    232209} 
    233210sub pretty {