« blib/lib/WWW/Shopify/Liquid/Tag/Capture.pm
↑ Summary
blib/lib/WWW/Shopify/Liquid/Operator/Concatenate.pm »
| 1 | #!/usr/bin/perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 30 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 30 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | package WWW::Shopify::Liquid::Tag::For; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 30 | ▶ | use base 'WWW::Shopify::Liquid::Tag::Enclosing'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 0 | ▶ | sub min_arguments { return 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
min_arguments: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 0 | ▶ | sub max_arguments { return 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
max_arguments: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | sub verify { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verify: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | die new WWW::Shopify::Liquid::Exception::Parser::Arguments($self, "Requires in operator to be part of loop.") unless | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | $self->{arguments}->[0]->isa('WWW::Shopify::Liquid::Operator::In'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | die new WWW::Shopify::Liquid::Exception::Parser::Arguments($self, "Requires the opening variable of a loop to be a simple variable.") unless | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | $self->{arguments}->[0]->{operands}->[0] && $self->{arguments}->[0]->{operands}->[0]->isa('WWW::Shopify::Liquid::Token::Variable') && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | sub inner_tags { return qw(else) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inner_tags: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 30 | ▶ | use List::Util qw(min); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 30 | ▶ | use Scalar::Util qw(looks_like_number blessed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 30 | ▶ | use Clone qw(clone); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | my $package = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | my $self = bless { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | line => shift, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | core => shift, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | arguments => shift, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | contents => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | false_path => undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | }, $package; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | $self->interpret_inner_tokens(@{$_[0]}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | sub interpret_inner_tokens { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | my ($self, @tokens) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
interpret_inner_tokens: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # Comes in [for_path], [tag, other_path]... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my $token = shift(@tokens); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | return undef unless $token; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | $self->{contents} = $token->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | if (int(@tokens) > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $self->{false_path} = $tokens[0]->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | sub render_loop { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | my ($self, $renderer, $hash, $op1, $op2, $start, $end, @array) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render_loop: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my @texts = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my $all_processed = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my $var = $op1->{core}->[0]->{core}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my $content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | for ($start..$end) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | $hash->{$var} = $array[$_]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | $hash->{forloop} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | index => ($_+1), index0 => $_, first => $_ == 0, last => $_ == $#array, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | length => int(@array), rindex0 => (($#array - $_) + 1), rindex => (($#array - $_)), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | $content = $self->{contents}->render($renderer, $hash); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | if (my $exp = $@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if ($exp->isa('WWW::Shopify::Liquid::Exception::Control::Break')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } elsif ($exp->isa('WWW::Shopify::Liquid::Exception::Control::Continue')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | die $exp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | $all_processed = 0 if !$self->is_processed($content); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | push(@texts, $content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | return join('', grep { defined $_ } @texts) if $all_processed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | sub expand_concatenations { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | my ($self, $result) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expand_concatenations: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | sub optimize_loop { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | my ($self, $optimizer, $hash, $op1, $op2, $start, $end, @array) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
optimize_loop: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | # First step, we replace everything by a big concatenate. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my @texts = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my $var = $op1->{core}->[0]->{core}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | return '' if $start > $end; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | my @parts = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | $hash->{$var} = $array[$_]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | $hash->{forloop} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | index => ($_+1), index0 => $_, first => $_ == 0, last => $_ == $#array, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | length => int(@array), rindex0 => (($#array - $_) + 1), rindex => (($#array - $_)), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | $result = $self->is_processed($self->{contents}) ? $self->{contents} : clone($self->{contents})->optimize($optimizer, $hash); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | if (my $exp = $@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if ($exp->isa('WWW::Shopify::Liquid::Exception::Control::Break')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } elsif ($exp->isa('WWW::Shopify::Liquid::Exception::Control::Continue')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | die $exp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $self->expand_concatenations($result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } ($start..$end); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | return $parts[0] if int(@parts) == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | return WWW::Shopify::Liquid::Operator::Concatenate->new($self->{line}, "", @parts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # Should eventually support loop unrolling. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | sub process { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | my ($self, $hash, $action, $pipeline) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process: not called CC=26 SCAR=65.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my @args = @{$self->{arguments}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my ($op1, $op2) = @{$args[0]->{operands}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | $op2 = $op2->$action($pipeline, $hash) if !$self->is_processed($op2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | $op2 = [keys(%$op2)] if ref($op2) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | die new WWW::Shopify::Liquid::Exception::Renderer::Arguments($self, "Requires an array in for loop.") unless ref($op2) eq "ARRAY"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | my @array = @$op2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | my $limit = int(@array); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | my $offset = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | my ($limit_arg) = grep { $_->isa('WWW::Shopify::Liquid::Token::Variable::Named') && $_->{name} eq "limit" } @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | my $limit_result = $limit_arg->$action($pipeline, $hash) if $limit_arg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | return $self if !$self->is_processed($limit_result); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 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"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | my ($offset_arg) = grep { $_->isa('WWW::Shopify::Liquid::Token::Variable::Named') && $_->{name} eq "offset" } @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | my $offset_result = $offset_arg->$action($pipeline, $hash) if $offset_arg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 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"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | my $dispatch = $action . "_loop"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | return $self->$dispatch($pipeline, $hash, $op1, $op2, $offset, min($#array, $limit+$offset-1), @array); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 30 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||