Mildew/AST/Seq.pm untested

filter: Statementstmt 0.0% 0 / 43 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 69 SCAR -
1 class Mildew::AST::Seq extends Mildew::AST::Base {
2 has 'stmts' => (is=>'ro');
3 has 'id' => (is=>'ro');
4 has 'next' => (is=>'rw');
5 method pretty {
6 (defined($self->id) ? $self->id . ": " : '')
7 . join("",map {Mildew::AST::terminate_stmt $_->pretty} @{$self->stmts});
8 }
9 method m0ld($ret) {
10 my @stmts = @{$self->stmts};
11 my $last = pop @stmts;
12 my $m0ld = join('',map {$_->m0ld(Mildew::AST::unique_id)} @stmts);
13 $m0ld = $m0ld . $last->m0ld($ret) if $last;
14 (defined($self->id) ? $self->id . ": " : '') . $m0ld ;
15 }
16 method simplified {
17 die "can't call simplified on a block with id" if $self->id;
18 my @stmts;
19 my $value;
20 for (@{$self->stmts}) {
21 my @side_effects;
22 ($value,@side_effects) = $_->simplified;
23 push (@stmts,@side_effects);
24 }
25 ($value,@stmts);
26 }
27 method jumps {
28 my $last = $self->stmts->[-1];
29 if (defined $last && $last->isa('Mildew::AST::Goto')) {
30 $self->stmts->[-1]->block;
31 } elsif (defined $last && $last->isa('Mildew::AST::Branch')) {
32 ($last->else,$last->then),;
33 } elsif ($self->next) {
34 $self->next;
35 } else {
36 ();
37 }
38 }
39 method forest {
40 Forest::Tree->new(node=>$self->id.':',children=>[map {$_->forest} @{$self->stmts}]);
41 }
42 method took {
43 my $took = 0;
44 for (@{$self->stmts}) {
45 $took += $_->took;
46 }
47 $took;
48 }
49 method forest {
50 Forest::Tree->new(node=> $self->id.':' . ($Mildew::took ? ' - ' . sprintf("%.4f",$self->took) : ''),children=>[map {$_->forest } @{$self->stmts}]);
51 }
52 }