Legend:
- Unmodified
- Added
- Removed
-
v6/mildew/mildew
r22859 r22860 323 323 AST::Label->new(label=>label($m->{label}),stmt=>statement($m->{statement})); 324 324 } elsif ($m->{statement_control}) { 325 XXX('statement_control') 325 my $stm = $m->{statement_control}; 326 if ($stm->{sym} eq 'if') { 327 AST::If->new( 328 cond => $stm->{xblock}{EXPR}->emit_m0ld, 329 then => $stm->{xblock}{pblock}{block}->emit_m0ld 330 ); 331 } else { 332 XXX('unkown sym in statement_control') 333 } 326 334 } elsif ($m->{EXPR}) { 327 335 $m->{EXPR}->emit_m0ld; -
v6/mildew/src/AST.pm
r22621 r22860 4 4 sub unique_id { 5 5 '$id'.$id++; 6 } 7 my $lab = 0; 8 sub unique_label { 9 'lab'.$lab++; 6 10 } 7 11 sub indent { … … 33 37 $yaml; 34 38 } 39 40 package AST::If; 41 use Moose; 42 extends 'AST::Base'; 43 has 'cond' => (is => 'ro'); 44 has 'then' => (is => 'ro'); 45 sub m0ld { 46 my ($self) = @_; 47 my $id_cond = AST::unique_id; 48 my $id_then = AST::unique_id; 49 my $label_then = AST::unique_label; 50 my $label_else = AST::unique_label; 51 my $cond = $self->cond->m0ld($id_cond); 52 my $then = $self->then->m0ld($id_then); 53 54 $cond.$/. 55 'my '.$id_cond.'_val = '.$id_cond.'."FETCH"();'.$/. 56 'my '.$id_cond.'_bool = '.$id_cond.'_val."bool"();'.$/. 57 'if '.$id_cond.'_bool { goto '.$label_then.'; } else { goto '.$label_else.'; };'.$/. 58 $label_then.':'.$/. 59 $then.$/. 60 $label_else.':'.$/; 61 } 62 35 63 package AST::Block; 36 64 use Moose; -
v6/mildew/t/if.t
r22808 r22860 2 2 if True { 3 3 $OUT.print("ok 1\n"); 4 } else {5 $OUT.print("not ok 1\n");6 4 }
