| 1 | #!/usr/bin/perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 38 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 38 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # The special-ist tag in the world. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | package WWW::Shopify::Liquid::Tag::For; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 38 | ▶ | use base 'WWW::Shopify::Liquid::Tag::Enclosing'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 0 | ▶ | sub min_arguments { return 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
min_arguments: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 0 | ▶ | sub max_arguments { return 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
max_arguments: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | sub verify { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verify: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | die new WWW::Shopify::Liquid::Exception::Parser::Arguments($self, "Requires in operator to be part of loop.") unless | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | $self->{arguments}->[0]->isa('WWW::Shopify::Liquid::Operator::In'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | die new WWW::Shopify::Liquid::Exception::Parser::Arguments($self, "Requires the opening variable of a loop to be a simple variable.") unless | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | $self->{arguments}->[0]->{operands}->[0] && $self->{arguments}->[0]->{operands}->[0]->isa('WWW::Shopify::Liquid::Token::Variable') && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | int(@{$self->{arguments}->[0]->{operands}->[0]->{core}}) == 1 && $self->{arguments}->[0]->{operands}->[0]->{core}->[0]->isa('WWW::Shopify::Liquid::Token::String'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$self->{"arguments"}[0]{"operands"}[0] and $self->{"arguments"}[0]{"operands"}[0]->isa("WWW::Shopify::Liquid::Token::Variable") and int @{$self->{"arguments"}[0]{"operands"}[0]{"core"};} == 1 and $self->{"arguments"}[0]{"operands"}[0]{"core"}[0]->isa("WWW::Shopify::Liquid::Token::String")
$self->{"arguments"}[0]{"operands"}[0] and $self->{"arguments"}[0]{"operands"}[0]->isa("WWW::Shopify::Liquid::Token::Variable") and int @{$self->{"arguments"}[0]{"operands"}[0]{"core"};} == 1
$self->{"arguments"}[0]{"operands"}[0] and $self->{"arguments"}[0]{"operands"}[0]->isa("WWW::Shopify::Liquid::Token::Variable")
MC/DC0%0/4
$self->{"arguments"}[0]{"operands"}[0] and $self->{"arguments"}[0]{"operands"}[0]->isa("WWW::Shopify::Liquid::Token::Variable") and int @{$self->{"arguments"}[0]{"operands"}[0]{"core"};} == 1 and $self->{"arguments"}[0]{"operands"}[0]{"core"}[0]->isa("WWW::Shopify::Liquid::Token::String")
$self->{"arguments"}[0]{"operands"}[0]
$self->{"arguments"}[0]{"operands"}[0]->isa("WWW::Shopify::Liquid::Token::Variable")
int @{$self->{"arguments"}[0]{"operands"}[0]{"core"};} == 1
$self->{"arguments"}[0]{"operands"}[0]{"core"}[0]->isa("WWW::Shopify::Liquid::Token::String")
Truth table0%0/5
A and B and C and D
A= $self->{"arguments"}[0]{"operands"}[0]B= $self->{"arguments"}[0]{"operands"}[0]->isa("WWW::Shopify::Liquid::Token::Variable")C= int @{$self->{"arguments"}[0]{"operands"}[0]{"core"};} == 1D= $self->{"arguments"}[0]{"operands"}[0]{"core"}[0]->isa("WWW::Shopify::Liquid::Token::String")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | sub inner_tags { return qw(else) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inner_tags: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 38 | ▶ | use List::Util qw(min); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 38 | ▶ | use Scalar::Util qw(looks_like_number blessed reftype); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 38 | ▶ | use Clone qw(clone); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | my $package = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | my $self = bless { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | line => shift, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | core => shift, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | arguments => shift, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | contents => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | false_path => undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | }, $package; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | $self->interpret_inner_tokens(@{$_[0]}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub interpret_inner_tokens { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
interpret_inner_tokens: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my ($self, @tokens) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # Comes in [for_path], [tag, other_path]... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my $token = shift(@tokens); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | return undef unless $token; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $self->{contents} = $token->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | if (int(@tokens) > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | die new WWW::Shopify::Liquid::Exception::Parser($self, "else cannot be anywhere, except the end tag of the for statement.") if int(@tokens) > 1 || $tokens[0]->[0]->tag ne "else"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
int @tokens > 1 or $tokens[0][0]->tag ne "else"
MC/DC0%0/2
int @tokens > 1 or $tokens[0][0]->tag ne "else"
int @tokens > 1
$tokens[0][0]->tag ne "else"
Truth table0%0/3
A or B
A= int @tokens > 1B= $tokens[0][0]->tag ne "else"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | $self->{false_path} = $tokens[0]->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub render_loop { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render_loop: not called CC=16 SCAR=56.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my ($self, $renderer, $hash, $op1, $op2, $start, $end, $arrayRef) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my @array = @$arrayRef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my @texts = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my $all_processed = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my $var = $op1->{core}->[0]->{core}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my $content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | if ($renderer->state && exists $renderer->state->{values}->{$self . "-1"}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$renderer->state and exists $renderer->state->{"values"}{$self . '-1'}
MC/DC0%0/2
$renderer->state and exists $renderer->state->{"values"}{$self . '-1'}
$renderer->state
exists $renderer->state->{"values"}{$self . '-1'}
Truth table0%0/3
A and B
A= $renderer->stateB= exists $renderer->state->{"values"}{$self . '-1'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $start = $renderer->state->{values}->{$self . "-1"}->{index}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | @texts = @{$renderer->state->{values}->{$self . "-1"}->{texts}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | delete $renderer->state->{values}->{$self . "-1"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | for ($start..$end) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $hash->{$var} = $array[$_]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | $hash->{forloop} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | index => ($_+1), index0 => $_, first => $_ == 0, last => $_ == $#array, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | length => int(@array), rindex0 => (($#array - $_)), rindex => (($#array - $_) + 1), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | $content = $self->is_processed($self->{contents}) ? $self->{contents} : $self->{contents}->render($renderer, $hash); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | if (my $exp = $@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | if (defined $exp && blessed($exp) && $exp->isa('WWW::Shopify::Liquid::Exception::Control')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $exp and builtin::blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control")
defined $exp and builtin::blessed($exp)
MC/DC0%0/3
defined $exp and builtin::blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control")
defined $exp
builtin::blessed($exp)
$exp->isa("WWW::Shopify::Liquid::Exception::Control")
Truth table0%0/4
A and B and C
A= defined $expB= builtin::blessed($exp)C= $exp->isa("WWW::Shopify::Liquid::Exception::Control")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if ($exp->isa('WWW::Shopify::Liquid::Exception::Control::Pause')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | $exp->register_value($self . "-1", { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | index => $_, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | texts => \@texts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | die $exp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | push(@texts, @{$exp->initial_render}) if $exp->initial_render && int(@{$exp->initial_render}) > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$exp->initial_render and int @{$exp->initial_render;} > 0
MC/DC0%0/2
$exp->initial_render and int @{$exp->initial_render;} > 0
$exp->initial_render
int @{$exp->initial_render;} > 0
Truth table0%0/3
A and B
A= $exp->initial_renderB= int @{$exp->initial_render;} > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | if ($exp->isa('WWW::Shopify::Liquid::Exception::Control::Break')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } elsif ($exp->isa('WWW::Shopify::Liquid::Exception::Control::Continue')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | die $exp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | $all_processed = 0 if !$self->is_processed($content); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | push(@texts, $content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | return join('', grep { defined $_ } @texts) if $all_processed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub expand_concatenations { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expand_concatenations: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | my ($self, $result) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | return blessed($result) && $result->isa('WWW::Shopify::Liquid::Operator::Concatenate') ? (map { $self->expand_concatenations($_) } @{$result->{operands}}) : ($result); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($result) and $result->isa("WWW::Shopify::Liquid::Operator::Concatenate")
MC/DC0%0/2
builtin::blessed($result) and $result->isa("WWW::Shopify::Liquid::Operator::Concatenate")
builtin::blessed($result)
$result->isa("WWW::Shopify::Liquid::Operator::Concatenate")
Truth table0%0/3
A and B
A= builtin::blessed($result)B= $result->isa("WWW::Shopify::Liquid::Operator::Concatenate")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | sub optimize_loop { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
optimize_loop: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my ($self, $optimizer, $hash, $op1, $op2, $start, $end, $arrayRef) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my @array = @$arrayRef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | # First step, we replace everything by a big concatenate. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my @texts = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | my $var = $op1->{core}->[0]->{core}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | return '' if $start > $end; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | my @parts = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | $hash->{$var} = $array[$_]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | $hash->{forloop} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | index => ($_+1), index0 => $_, first => $_ == 0, last => $_ == $#array, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | length => int(@array), rindex0 => (($#array - $_) + 1), rindex => (($#array - $_)), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | my $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | $result = $self->is_processed($self->{contents}) ? $self->{contents} : clone($self->{contents})->optimize($optimizer, $hash); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | if (my $exp = $@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | if (defined $exp && blessed($exp) && $exp->isa('WWW::Shopify::Liquid::Exception::Control')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $exp and builtin::blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control")
defined $exp and builtin::blessed($exp)
MC/DC0%0/3
defined $exp and builtin::blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control")
defined $exp
builtin::blessed($exp)
$exp->isa("WWW::Shopify::Liquid::Exception::Control")
Truth table0%0/4
A and B and C
A= defined $expB= builtin::blessed($exp)C= $exp->isa("WWW::Shopify::Liquid::Exception::Control")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | push(@texts, @{$exp->initial_render}) if $exp->initial_render && int(@{$exp->initial_render}) > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$exp->initial_render and int @{$exp->initial_render;} > 0
MC/DC0%0/2
$exp->initial_render and int @{$exp->initial_render;} > 0
$exp->initial_render
int @{$exp->initial_render;} > 0
Truth table0%0/3
A and B
A= $exp->initial_renderB= int @{$exp->initial_render;} > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | if ($exp->isa('WWW::Shopify::Liquid::Exception::Control::Break')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } elsif ($exp->isa('WWW::Shopify::Liquid::Exception::Control::Continue')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | die $exp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | $self->expand_concatenations($result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } ($start..$end); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | return $parts[0] if int(@parts) == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | return $optimizer->optimize($hash, WWW::Shopify::Liquid::Operator::Concatenate->new($self->{line}, "", @parts)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | # Called to expand the second operand in "in" argument list. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | sub apply { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my ($self, $hash, $operand) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | return [keys(%$operand)] if ref($operand) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | return $operand; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # Should eventually support loop unrolling. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | sub process { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process: not called CC=31 SCAR=69.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | my ($self, $hash, $action, $pipeline) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my @args = @{$self->{arguments}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my ($op1, $op2) = @{$args[0]->{operands}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | $op2 = $op2->$action($pipeline, $hash) if !$self->is_processed($op2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | $self->{arguments}->[0]->{operands}->[1] = $op2 if $self->is_processed($op2) && $action eq 'optimize'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->is_processed($op2) and $action eq "optimize"
MC/DC0%0/2
$self->is_processed($op2) and $action eq "optimize"
$self->is_processed($op2)
$action eq "optimize"
Truth table0%0/3
A and B
A= $self->is_processed($op2)B= $action eq "optimize"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | if ($action eq "optimize" && !$self->is_processed($self->{contents})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$action eq "optimize" and not $self->is_processed($self->{"contents"})
MC/DC0%0/2
$action eq "optimize" and not $self->is_processed($self->{"contents"})
$action eq "optimize"
not $self->is_processed($self->{"contents"})
Truth table0%0/3
A and not(B)
A= $action eq "optimize"B= not $self->is_processed($self->{"contents"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | # Ensure that the loop variable is unset for at least the duration of the loop while we do an initial optimization. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my $var = $op1->{core}->[0]->{core}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | delete $hash->{$var}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | # And, in fact, make sure that ALL variables that get set in the loop get unset here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | for (grep { ref($_) eq 'WWW::Shopify::Liquid::Tag::Assign' } $self->{contents}->tokens) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | next if int(@{$_->{arguments}->[0]->{operands}->[0]->{core}}) == 1 && | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | blessed($_->{arguments}->[0]->{operands}->[0]->{core}->[0]->{core}) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | $_->{arguments}->[0]->{operands}->[0]->{core}->[0]->{core}->isa('WWW::Shopify::Liquid::Token::String'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
int @{$_->{"arguments"}[0]{"operands"}[0]{"core"};} == 1 and builtin::blessed($_->{"arguments"}[0]{"operands"}[0]{"core"}[0]{"core"}) and $_->{"arguments"}[0]{"operands"}[0]{"core"}[0]{"core"}->isa("WWW::Shopify::Liquid::Token::String")
int @{$_->{"arguments"}[0]{"operands"}[0]{"core"};} == 1 and builtin::blessed($_->{"arguments"}[0]{"operands"}[0]{"core"}[0]{"core"})
MC/DC0%0/3
int @{$_->{"arguments"}[0]{"operands"}[0]{"core"};} == 1 and builtin::blessed($_->{"arguments"}[0]{"operands"}[0]{"core"}[0]{"core"}) and $_->{"arguments"}[0]{"operands"}[0]{"core"}[0]{"core"}->isa("WWW::Shopify::Liquid::Token::String")
int @{$_->{"arguments"}[0]{"operands"}[0]{"core"};} == 1
builtin::blessed($_->{"arguments"}[0]{"operands"}[0]{"core"}[0]{"core"})
$_->{"arguments"}[0]{"operands"}[0]{"core"}[0]{"core"}->isa("WWW::Shopify::Liquid::Token::String")
Truth table0%0/4
A and B and C
A= int @{$_->{"arguments"}[0]{"operands"}[0]{"core"};} == 1B= builtin::blessed($_->{"arguments"}[0]{"operands"}[0]{"core"}[0]{"core"})C= $_->{"arguments"}[0]{"operands"}[0]{"core"}[0]{"core"}->isa("WWW::Shopify::Liquid::Token::String")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | delete $hash->{$_->{arguments}->[0]->{operands}->[0]->{core}->[0]->{core}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $pipeline->push_conditional_state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $self->{contents} = $self->{contents}->optimize($pipeline, $hash); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | $pipeline->pop_conditional_state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $op2 = $self->apply($hash, $op2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | return $self if (!$self->is_processed($op2) && $action eq "optimize"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $self->is_processed($op2) and $action eq "optimize"
MC/DC0%0/2
not $self->is_processed($op2) and $action eq "optimize"
not $self->is_processed($op2)
$action eq "optimize"
Truth table0%0/3
not(A) and B
A= not $self->is_processed($op2)B= $action eq "optimize"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | return '' if (!$self->is_processed($op2) && $action eq "render"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $self->is_processed($op2) and $action eq "render"
MC/DC0%0/2
not $self->is_processed($op2) and $action eq "render"
not $self->is_processed($op2)
$action eq "render"
Truth table0%0/3
not(A) and B
A= not $self->is_processed($op2)B= $action eq "render"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | return (defined $self->{false_path} ? $self->{false_path}->$action($pipeline, $hash) : '') if ref($op2) ne "ARRAY" || int(@$op2) == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
ref $op2 ne "ARRAY" or int @$op2 == 0
MC/DC0%0/2
ref $op2 ne "ARRAY" or int @$op2 == 0
ref $op2 ne "ARRAY"
int @$op2 == 0
Truth table0%0/3
A or B
A= ref $op2 ne "ARRAY"B= int @$op2 == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | die new WWW::Shopify::Liquid::Exception::Renderer::Arguments($self, "Requires an array in for loop.") unless ref($op2) eq "ARRAY"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | my @array = @$op2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | my $limit = int(@array); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | my $offset = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | my ($limit_arg) = grep { $_->isa('WWW::Shopify::Liquid::Token::Variable::Named') && $_->{name} eq "limit" } @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$_->isa('WWW::Shopify::Liquid::Token::Variable::Named') && $_->{'name'} eq 'limit'
MC/DC0%0/2
$_->isa('WWW::Shopify::Liquid::Token::Variable::Named') && $_->{'name'} eq 'limit'
$_->isa('WWW::Shopify::Liquid::Token::Variable::Named')
$_->{'name'} eq 'limit'
Truth table0%0/3
A && B
A= $_->isa('WWW::Shopify::Liquid::Token::Variable::Named')B= $_->{'name'} eq 'limit'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | my $limit_result = $limit_arg->$action($pipeline, $hash) if $limit_arg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | return $self if !$self->is_processed($limit_result); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | $limit = $limit_result->{limit} if $limit_result && ref($limit_result) && ref($limit_result) eq 'HASH' && looks_like_number($limit_result->{limit}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$limit_result and ref $limit_result and ref $limit_result eq "HASH" and &looks_like_number($limit_result->{"limit"})
$limit_result and ref $limit_result and ref $limit_result eq "HASH"
$limit_result and ref $limit_result
MC/DC0%0/4
$limit_result and ref $limit_result and ref $limit_result eq "HASH" and &looks_like_number($limit_result->{"limit"})
$limit_result
ref $limit_result
ref $limit_result eq "HASH"
&looks_like_number($limit_result->{"limit"})
Truth table0%0/5
A and B and C and D
A= $limit_resultB= ref $limit_resultC= ref $limit_result eq "HASH"D= &looks_like_number($limit_result->{"limit"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | my ($offset_arg) = grep { $_->isa('WWW::Shopify::Liquid::Token::Variable::Named') && $_->{name} eq "offset" } @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$_->isa('WWW::Shopify::Liquid::Token::Variable::Named') && $_->{'name'} eq 'offset'
MC/DC0%0/2
$_->isa('WWW::Shopify::Liquid::Token::Variable::Named') && $_->{'name'} eq 'offset'
$_->isa('WWW::Shopify::Liquid::Token::Variable::Named')
$_->{'name'} eq 'offset'
Truth table0%0/3
A && B
A= $_->isa('WWW::Shopify::Liquid::Token::Variable::Named')B= $_->{'name'} eq 'offset'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | my $offset_result = $offset_arg->$action($pipeline, $hash) if $offset_arg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | $offset = $offset_result->{offset} if $offset_result && ref($offset_result) && ref($offset_result) eq 'HASH' && looks_like_number($offset_result->{offset}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$offset_result and ref $offset_result and ref $offset_result eq "HASH" and &looks_like_number($offset_result->{"offset"})
$offset_result and ref $offset_result and ref $offset_result eq "HASH"
$offset_result and ref $offset_result
MC/DC0%0/4
$offset_result and ref $offset_result and ref $offset_result eq "HASH" and &looks_like_number($offset_result->{"offset"})
$offset_result
ref $offset_result
ref $offset_result eq "HASH"
&looks_like_number($offset_result->{"offset"})
Truth table0%0/5
A and B and C and D
A= $offset_resultB= ref $offset_resultC= ref $offset_result eq "HASH"D= &looks_like_number($offset_result->{"offset"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my $dispatch = $action . "_loop"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | return $self->$dispatch($pipeline, $hash, $op1, $op2, $offset, min($#array, $limit+$offset-1), \@array); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 38 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||