Mildew/AST/Call.pm

filter: Statementstmt 34.2% 37 / 108 Branchbran 0.0% 0 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 15 / 20 Podpod n/a totaltotal 35.1% 52 / 148 CC 11 SCAR 23.8
CC
11
Cov
29%
__ANON__
38.3
__ANON__
11.0
__ANON__
11.0
CRAP 10.8
« Mildew/AST/If.pm ↑ Summary Mildew/Frontend/STD.pm »
1 4 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 4 ▶use MooseX::Declare;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶class Mildew::AST::Call extends Mildew::AST::Base {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=3.6
4 4 ▶ use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶ use Mildew::AST::Helpers qw(YYY);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 has 'capture' => (is=>'ro');
7 4 has 'identifier' => (is=>'ro');
8 #TODO delete
9 0 ▶ method arguments {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=2 SCAR=16.1
10 0 my @args = @{$self->capture->positional};
11 0 my @named = @{$self->capture->named};
12 0 ▶ while (@named) {
Branch: 1 branch
BranchTrueFalseTotal
if (@named) 0 0 0
13 0 push (@args,Mildew::AST::Named->new(key=>shift @named,value=>shift @named));
14 }
15 0 @args;
16 4 }
17 0 ▶ method m0ld($ret) {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=3 SCAR=23.9
18 0 ▶ if ($self->capture->isa("Mildew::AST::Capture")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->capture->isa('Mildew::AST::Capture')) { } 0 0 0
19 0 my $invocant = Mildew::AST::unique_id;
20 0 my $identifier = Mildew::AST::unique_id;
21
22 0 my $args = "";
23
24 my @args = map {
25 0 my $id = Mildew::AST::unique_id;
26 0 $args .= $_->m0ld($id);
27 0 $id
28 0 } @{$self->capture->positional};
29
30 0 my @named = @{$self->capture->named};
31 0 ▶ while (@named) {
Branch: 1 branch
BranchTrueFalseTotal
if (@named) 0 0 0
32 0 my $key = Mildew::AST::unique_id;
33 0 my $value = Mildew::AST::unique_id;
34 0 $args .= (shift @named)->m0ld($key);
35 0 $args .= (shift @named)->m0ld($value);
36 0 push(@args,":".$key."(".$value.")");
37 }
38
39 0 $self->capture->invocant->m0ld($invocant)
40 . $self->identifier->m0ld($identifier)
41 . $args
42 . "my $ret = "
43 . $invocant . "." . $identifier
44 . "(" . join(',',@args) . ")" . ";\n";
45 } else {
46 0 die 'unimplemented';
47 }
48 4 }
49 0 ▶ method simplified {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=3 SCAR=24.0
50 0 ▶ if ($self->capture->isa("Mildew::AST::Capture")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->capture->isa('Mildew::AST::Capture')) { } 0 0 0
51  
52 0 my @setup_args;
53 my @simplified_pos = map {
54 0 my ($pos,@pos_setup) = $_->simplified;
55 0 push(@setup_args,@pos_setup);
56 0 $pos;
57 0 } @{$self->capture->positional};
58
59 0 my @simplified_named;
60 0 my @named = @{$self->capture->named};
61 0 ▶ while (@named) {
Branch: 1 branch
BranchTrueFalseTotal
if (@named) 0 0 0
62 0 my ($key,@setup_key) = (shift @named)->simplified;
63 0 my ($value,@setup_value) = (shift @named)->simplified;
64 0 push(@setup_args,@setup_key,@setup_value);
65 0 push(@simplified_named,$key,$value);
66 }
67  
68 0 my ($invocant,@invocant_setup) = $self->capture->invocant->simplified;
69 0 my ($identifier,@identifier_setup) = $self->identifier->simplified;
70 0 my $reg = Mildew::AST::unique_reg;
71 0 ($reg,@invocant_setup,@identifier_setup,@setup_args,Mildew::AST::Assign->new(lvalue=>$reg,rvalue=>
72 Mildew::AST::Call->new(identifier=>$identifier,capture=>Mildew::AST::Capture->new(
73 invocant=>$invocant,
74 positional=>[@simplified_pos],
75 named=>[@simplified_named]
76 )),
77 ));
78 } else {
79 0 die 'unimplemented';
80 }
81 4 }
82 0 ▶ method pretty {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=6 SCAR=36.4
83
84 0 my $identifier;
85 0 ▶ if ($self->identifier->isa("Mildew::AST::StringConstant")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->identifier->isa('Mildew::AST::StringConstant')) { } 0 0 0
86 0 $identifier = $self->identifier->value;
87 } else {
88 0 $identifier = $self->identifier->pretty;
89 }
90
91 0 my $args = '';
92 0 my @args = map {$_->pretty} @{$self->capture->positional};
93 0 my @named = @{$self->capture->named};
94 0 ▶ while (@named) {
Branch: 1 branch
BranchTrueFalseTotal
if (@named) 0 0 0
95 0 push(@args,":".(shift @named)->pretty." => ".(shift @named)->pretty);
96 }
97
98 0 ▶ if ($self->capture->isa("Mildew::AST::Capture")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->capture->isa('Mildew::AST::Capture')) { } 0 0 0
99 0 ▶ YYY($self) unless $self->capture->invocant;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->capture->invocant 0 0 0
100 0 ▶ $self->capture->invocant->pretty . "." . $identifier . (@args ? '(' . join(',',@args) . ')' : '');
Branch: 1 branch
BranchTrueFalseTotal
@args ? : 0 0 0
101 } else {
102 0 $self->SUPER::pretty;
103 }
104 4 }
105 0 ▶ method forest {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=1 SCAR=4.6
106 0 Forest::Tree->new(node=>$self->pretty,children=>[map {$_->forest} ($self->capture->invocant,$self->identifier,@{$self->capture->positional},@{$self->capture->named})]);
107 4 }
108 4 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
« Mildew/AST/If.pm ↑ Summary Mildew/Frontend/STD.pm »