| 1 | 6 | ▶ | use strict; use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | package assign::Struct; | ||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use XXX; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 26 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 26 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 8 | 26 | bless { | |||||||||||||||||||||||||||||||||||||||||
| 9 | elems => [], | ||||||||||||||||||||||||||||||||||||||||||
| 10 | @_, | ||||||||||||||||||||||||||||||||||||||||||
| 11 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||
| 12 | } | ||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 26 | ▶ | sub parse { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=8 SCAR=21.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 26 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 26 | my $node = $self->{node}; | |||||||||||||||||||||||||||||||||||||||||
| 18 | 26 | my $statement; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 26 | for my $child ($node->children) { | |||||||||||||||||||||||||||||||||||||||||
| 20 | 59 | my $type = ref($child); | |||||||||||||||||||||||||||||||||||||||||
| 21 | 59 | ▶ | if ($type eq 'PPI::Token::Whitespace') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 33 | next; | |||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 26 | ▶ | if ($type eq 'PPI::Statement') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 26 | ▶ | XXX $node, "more than one statement" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | if $statement; | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 26 | $statement = $child; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 26 | next; | |||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | XXX $node, "unexpected node"; | |||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 26 | ▶ | XXX $node, "no statement in array" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | unless $statement; | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 26 | $self->{in} = [ $statement->children ]; | |||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 26 | while (1) { | |||||||||||||||||||||||||||||||||||||||||
| 39 | 80 | ▶ | $self->parse_elem or last; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 77 | ▶ | $self->parse_comma or last; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 26 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 77 | ▶ | sub parse_comma { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_comma: called CC=5 SCAR=17.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 77 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 77 | my $in = $self->{in}; | |||||||||||||||||||||||||||||||||||||||||
| 49 | 77 | ▶ | while (@$in) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 54 | my $tok = shift(@$in); | |||||||||||||||||||||||||||||||||||||||||
| 51 | 54 | my $type = ref($tok); | |||||||||||||||||||||||||||||||||||||||||
| 52 | 54 | ▶ | next if $type eq 'PPI::Token::Whitespace'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 54 | ▶ | if ($type eq 'PPI::Token::Operator' and | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$type eq "PPI::Token::Operator" and $tok->content eq ","
MC/DC0%0/2
$type eq "PPI::Token::Operator" and $tok->content eq ","
$type eq "PPI::Token::Operator"
$tok->content eq ","
Truth table33%1/3
A and B
A= $type eq "PPI::Token::Operator"B= $tok->content eq ","
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | $tok->content eq ',' | ||||||||||||||||||||||||||||||||||||||||||
| 56 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 54 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | XXX $tok, $in, "comma expected"; | |||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 23 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 63 | ▶ | sub get_var { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_var: called CC=7 SCAR=19.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 63 | my ($self, $var) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 63 | my $def; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 63 | my $in = $self->{in}; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 63 | ▶ | if (@$in > 1 and | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
@$in > 1 and ref $in->[0] eq "PPI::Token::Operator" and $in->[0]->content eq "="
@$in > 1 and ref $in->[0] eq "PPI::Token::Operator"
MC/DC66%2/3
@$in > 1 and ref $in->[0] eq "PPI::Token::Operator" and $in->[0]->content eq "="
@$in > 1
ref $in->[0] eq "PPI::Token::Operator"
$in->[0]->content eq "="
Truth table75%3/4
A and B and C
A= @$in > 1B= ref $in->[0] eq "PPI::Token::Operator"C= $in->[0]->content eq "="
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | ref($in->[0]) eq 'PPI::Token::Operator' and | ||||||||||||||||||||||||||||||||||||||||||
| 72 | $in->[0]->content eq '=' | ||||||||||||||||||||||||||||||||||||||||||
| 73 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 4 | shift @$in; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 4 | my $d = shift @$in; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 4 | ▶ | XXX $d, "Invalid token for variable default" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | unless ref($d) =~ | ||||||||||||||||||||||||||||||||||||||||||
| 78 | /^PPI::Token::(Number|Symbol|Quote::(Single|Double))$/; | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 4 | $def = $d->content; | |||||||||||||||||||||||||||||||||||||||||
| 80 | 4 | ▶ | XXX $d, "Invalid token for variable default" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $d eq "PPI::Token::Symbol" and not $def =~ /^\$\w+$/
MC/DC0%0/2
ref $d eq "PPI::Token::Symbol" and not $def =~ /^\$\w+$/
ref $d eq "PPI::Token::Symbol"
not $def =~ /^\$\w+$/
Truth table66%2/3
A and not(B)
A= ref $d eq "PPI::Token::Symbol"B= not $def =~ /^\$\w+$/
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | if ref($d) eq 'PPI::Token::Symbol' and | ||||||||||||||||||||||||||||||||||||||||||
| 82 | $def !~ /^\$\w+$/; | ||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 63 | assign::var->new($var, $def); | |||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||