| 1 | #!/usr/bin/perl | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 38 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 38 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | # Used in our AST to keep things simple; represents the concatenation of text and other stuff. | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # Making this a many-dimensional operator, so that we avoid going too far down the callstack rabbithole. | ||||||||||||||||||||||||||||||||||||||||||
| 8 | package WWW::Shopify::Liquid::Operator::Concatenate; | ||||||||||||||||||||||||||||||||||||||||||
| 9 | 38 | ▶ | use base 'WWW::Shopify::Liquid::Operator'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 38 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 0 | ▶ | sub symbol { return ('~'); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
symbol: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | ▶ | sub arity { return "nary"; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
arity: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | sub priority { return 9; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
priority: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | sub operate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
operate: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | my ($self, $hash, $action, @ops) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | $ops[$_] = '' for (grep { !defined $ops[$_] } 0..$#ops); | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | return join("", grep { defined $_ } @ops); | |||||||||||||||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | sub process { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process: not called CC=19 SCAR=59.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | my ($self, $hash, $action, $pipeline) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my @ops = @{$self->{operands}}; | |||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | for my $idx (0..$#ops) { | |||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | $ops[$idx] = $ops[$idx]->$action($pipeline, $hash) unless $self->is_processed($ops[$idx]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | $self->{operands}->[$idx] = $ops[$idx] if $action eq "optimize"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | if (my $exp = $@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | $exp->initial_render(@ops[0..($idx-1)]) if $idx > 0 && blessed($exp) && $exp->isa('WWW::Shopify::Liquid::Exception::Control'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$idx > 0 and builtin::blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control")
$idx > 0 and builtin::blessed($exp)
MC/DC0%0/3
$idx > 0 and builtin::blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control")
$idx > 0
builtin::blessed($exp)
$exp->isa("WWW::Shopify::Liquid::Exception::Control")
Truth table0%0/4
A and B and C
A= $idx > 0B= builtin::blessed($exp)C= $exp->isa("WWW::Shopify::Liquid::Exception::Control")
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | if (blessed($exp) && $exp->isa('WWW::Shopify::Liquid::Exception::Control::Pause')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control::Pause")
MC/DC0%0/2
builtin::blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control::Pause")
builtin::blessed($exp)
$exp->isa("WWW::Shopify::Liquid::Exception::Control::Pause")
Truth table0%0/3
A and B
A= builtin::blessed($exp)B= $exp->isa("WWW::Shopify::Liquid::Exception::Control::Pause")
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | $exp->register_value($self->{operands}->[$_], $ops[$_]) for (0..($idx-1)); | |||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | die $exp; | |||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | if (int(grep { !$self->is_processed($_) } @ops) > 0 && $action eq "optimize") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
int grep({not $self->is_processed($_);} @ops) > 0 and $action eq "optimize"
MC/DC0%0/2
int grep({not $self->is_processed($_);} @ops) > 0 and $action eq "optimize"
int grep({not $self->is_processed($_);} @ops) > 0
$action eq "optimize"
Truth table0%0/3
A and B
A= int grep({not $self->is_processed($_);} @ops) > 0B= $action eq "optimize"
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my $result; | |||||||||||||||||||||||||||||||||||||||||
| 40 | my @new_ops; | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | for (map { blessed($_) && $_->isa('WWW::Shopify::Liquid::Operator::Concatenate') ? (@{$_->{operands}}) : ($_) } @ops) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($_) and $_->isa("WWW::Shopify::Liquid::Operator::Concatenate")
MC/DC0%0/2
builtin::blessed($_) and $_->isa("WWW::Shopify::Liquid::Operator::Concatenate")
builtin::blessed($_)
$_->isa("WWW::Shopify::Liquid::Operator::Concatenate")
Truth table0%0/3
A and B
A= builtin::blessed($_)B= $_->isa("WWW::Shopify::Liquid::Operator::Concatenate")
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | if ($self->is_processed($_)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | $result .= $_ if defined $_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | push(@new_ops, $result); | |||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $result = ''; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | push(@new_ops, $_); | |||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | push(@new_ops, $result) if $result ne ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $self->{operands} = \@new_ops; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | return $self->operate($hash, $action, @ops); | |||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub optimize { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
optimize: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my ($self, $optimizer, $hash) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my $result = $self->SUPER::optimize($optimizer, $hash); | |||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | $self->{operands} = [grep { !$self->is_processed($_) || (defined $_ && $_ ne '') } @{$self->{operands}}]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
!$self->is_processed($_) || defined $_ && $_ ne ''
defined $_ and $_ ne ""
MC/DC0%0/3
!$self->is_processed($_) || defined $_ && $_ ne ''
!$self->is_processed($_)
defined $_
$_ ne ""
Truth table0%0/4
not(A) || B and C
A= !$self->is_processed($_)B= defined $_C= $_ ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | return $self->{operands}->[0] if int(@{$self->{operands}}) == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | my $package = shift; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my $line = shift; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | my $core = shift; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my $self = bless { line => $line, core => $core, operands => undef }, $package; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | $self->{operands} = [@_] if int(@_) >= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 38 | 1; | |||||||||||||||||||||||||||||||||||||||||