| 1 | package Template::Alloy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # See the perldoc in Template/Alloy.pod # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # Copyright 2007 - 2013 - Paul Seamons # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # Distributed under the Perl Artistic License without warranty # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 10 | ▶ | use Template::Alloy::Exception; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 10 | ▶ | use Template::Alloy::Operator qw(play_operator define_operator); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 10 | ▶ | use Template::Alloy::VMethod qw(define_vmethod $SCALAR_OPS $ITEM_OPS $ITEM_METHODS $FILTER_OPS $LIST_OPS $HASH_OPS $VOBJS); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 10 | our $VERSION = '1.022'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 10 | our $QR_PRIVATE = qr/^[_.]/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 10 | our $WHILE_MAX = 1000; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 10 | our $MAX_EVAL_RECURSE = 50; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 10 | our $MAX_MACRO_RECURSE = 50; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 10 | our $STAT_TTL = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 10 | our $QR_INDEX = '(?:\d*\.\d+ | \d+)'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 10 | our @CONFIG_COMPILETIME = qw(SYNTAX CACHE_STR_REFS ANYCASE INTERPOLATE PRE_CHOMP POST_CHOMP ENCODING | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | SEMICOLONS V1DOLLAR V2PIPE V2EQUALS AUTO_EVAL SHOW_UNDEFINED_INTERP AUTO_FILTER); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 10 | our @CONFIG_RUNTIME = qw(ADD_LOCAL_PATH CALL_CONTEXT DUMP VMETHOD_FUNCTIONS STRICT); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 10 | our $EVAL_CONFIG = {map {$_ => 1} @CONFIG_COMPILETIME, @CONFIG_RUNTIME}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 10 | our $EXTRA_COMPILE_EXT = '.sto'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 10 | our $PERL_COMPILE_EXT = '.pl'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 10 | our $JS_COMPILE_EXT = '.js'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 10 | our $GLOBAL_CACHE = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 10 | our $AUTOROLE = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | Compile => [qw(load_perl compile_template compile_tree compile_expr)], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | HTE => [qw(parse_tree_hte param output register_function clear_param query new_file new_scalar_ref new_array_ref new_filehandle)], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | Parse => [qw(parse_tree parse_expr apply_precedence parse_args dump_parse_tree dump_parse_expr define_directive define_syntax)], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | Play => [qw(play_tree _macro_sub)], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | Stream => [qw(stream_tree)], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | JS => [qw(load_js compile_template_js compile_tree_js play_js js_context process_js parse_tree_js process_jsr parse_tree_jsr)], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | TT => [qw(parse_tree_tt3 process)], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | Tmpl => [qw(parse_tree_tmpl set_delimiters set_strip set_value set_values parse_string set_dir parse_file loop_iteration fetch_loop_iteration)], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | Velocity => [qw(parse_tree_velocity merge)], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 10 | my $ROLEMAP = { map { my $type = $_; map { ($_ => $type) } @{ $AUTOROLE->{$type} } } keys %$AUTOROLE }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 10 | my %STANDIN = ('Template' => 'TT', 'Template::Toolkit' => 'TT', 'HTML::Template' => 'HTE', 'HTML::Template::Expr' => 'HTE', 'Text::Tmpl' => 'Tmpl'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 10 | our $AUTOLOAD; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 39 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 39 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 39 | ▶ | my $meth = ($AUTOLOAD && $AUTOLOAD =~ /::(\w+)$/) ? $1 : $self->throw('autoload', "Invalid method $AUTOLOAD"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$Template::Alloy::AUTOLOAD and $Template::Alloy::AUTOLOAD =~ /::(\w+)$/
MC/DC50%1/2
$Template::Alloy::AUTOLOAD and $Template::Alloy::AUTOLOAD =~ /::(\w+)$/
$Template::Alloy::AUTOLOAD
$Template::Alloy::AUTOLOAD =~ /::(\w+)$/
Truth table66%2/3
A and B
A= $Template::Alloy::AUTOLOADB= $Template::Alloy::AUTOLOAD =~ /::(\w+)$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 37 | ▶ | if (! $self->can($meth)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | require Carp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 1 | Carp::croak("Can't locate object method \"$meth\" via package ".ref($self)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 36 | return $self->$meth(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 38 | ▶ | sub can { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
can: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 38 | my ($self, $meth) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 38 | ▶ | __PACKAGE__->import($ROLEMAP->{$meth}) if $ROLEMAP->{$meth}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 38 | return $self->SUPER::can($meth); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub DESTROY {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 117 | ▶ | sub import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=13 SCAR=25.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 117 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 117 | foreach my $item (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 74 | ▶ | next if $item =~ /^(load|1)$/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 68 | ▶ | if (lc $item eq 'all') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 2 | local $AUTOROLE->{'JS'}; delete $AUTOROLE->{'JS'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | return $class->import(keys %$AUTOROLE); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 66 | my $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 66 | ▶ | if ($type = $STANDIN{$item}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 7 | (my $file = "$item.pm") =~ s|::|/|g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 7 | ▶ | if (! $INC{$file} || ! $item->isa(__PACKAGE__)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$INC{$file} and $item->isa(__PACKAGE__)
MC/DC100%2/2
$INC{$file} and $item->isa(__PACKAGE__)
$INC{$file}
$item->isa(__PACKAGE__)
Truth table100%3/3
A and B
A= $INC{$file}B= $item->isa(__PACKAGE__)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 4 | ▶ | if ($INC{$file}) { require Carp; Carp::croak("Class $item is already loaded - can't override") } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 3 | eval "{package $item; our \@ISA = qw(".__PACKAGE__.");}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 3 | $INC{$file} = __FILE__; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 3 | ▶ | next if ! $AUTOROLE->{$type}; # already imported | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 65 | ▶ | $type ||= $AUTOROLE->{$item} ? $item : $ROLEMAP->{$item} || do { require Carp; Carp::croak("Invalid import option \"$item\"") }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$type ||= $Template::Alloy::AUTOROLE->{$item} ? $item : $ROLEMAP->{$item} || do {
require Carp;
Carp::croak(qq[Invalid import option "$item"])
}
$ROLEMAP->{$item} or do {
require Carp;
Carp::croak(qq[Invalid import option "$item"])
}
MC/DC0%0/2
$type ||= $Template::Alloy::AUTOROLE->{$item} ? $item : $ROLEMAP->{$item} || do {
require Carp;
Carp::croak(qq[Invalid import option "$item"])
}
$type
$Template::Alloy::AUTOROLE->{$item} ? $item : $ROLEMAP->{$item} || do {
require Carp;
Carp::croak(qq[Invalid import option "$item"])
}
MC/DC0%0/2
$ROLEMAP->{$item} or do {
require Carp;
Carp::croak(qq[Invalid import option "$item"])
}
$ROLEMAP->{$item}
do {
require Carp;
Carp::croak(qq[Invalid import option "$item"])
}
Truth table66%2/3
A ||= B
A= $typeB= $Template::Alloy::AUTOROLE->{$item} ? $item : $ROLEMAP->{$item} || do {
require Carp;
Carp::croak(qq[Invalid import option "$item"])
}
Truth table66%2/3
A or B
A= $ROLEMAP->{$item}B= do {
require Carp;
Carp::croak(qq[Invalid import option "$item"])
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 64 | my $pkg = __PACKAGE__."::$type"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 64 | (my $file = "$pkg.pm") =~ s|::|/|g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 64 | require $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 10 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 64 | *{__PACKAGE__."::$_"} = \&{"$pkg\::$_"} for @{ $AUTOROLE->{$type} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 64 | $AUTOROLE->{$type} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 113 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 4197 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 4197 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 4197 | ▶ | my $args = ref($_[0]) ? { %{ shift() } } : {@_}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | ### allow for lowercase args | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 4197 | ▶ | if (my @keys = grep {/^[a-z][a-z_]+$/} keys %$args) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 253 | @{ $args }{ map { uc $_ } @keys } = delete @{ $args }{ @keys }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 4197 | return bless $args, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | sub run { shift->process_simple(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 773 | ▶ | sub process_simple { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process_simple: called CC=10 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 773 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 773 | ▶ | my $in = shift || die "Missing input"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || die('Missing input')
MC/DC100%1/1
shift() || die('Missing input')
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 772 | ▶ | my $swap = shift || die "Missing variable hash"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || die('Missing variable hash')
MC/DC100%1/1
shift() || die('Missing variable hash')
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 771 | ▶ | my $out = shift || ($self->{'STREAM'} ? \ "" : die "Missing output string ref"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
shift() || ($self->{'STREAM'} ? \'' : die('Missing output string ref'))
MC/DC0%0/2
shift() || ($self->{'STREAM'} ? \'' : die('Missing output string ref'))
shift()
($self->{'STREAM'} ? \'' : die('Missing output string ref'))
Truth table33%1/3
A || B
A= shift()B= ($self->{'STREAM'} ? \'' : die('Missing output string ref'))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 770 | delete $self->{'error'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 770 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 770 | delete $self->{'_debug_off'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 770 | delete $self->{'_debug_format'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 770 | local $self->{'_start_top_level'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 770 | $self->_process($in, $swap, $out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 770 | ▶ | if (my $err = $@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 40 | ▶ | if ($err->type !~ /stop|return|next|last|break/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 40 | $self->{'error'} = $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 40 | ▶ | die $err if $self->{'RAISE_ERROR'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 40 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | ▶ | } elsif ($err->type eq 'return' && UNIVERSAL::isa($err->info, 'HASH')) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$err->type eq "return" and UNIVERSAL::isa($err->info, "HASH")
MC/DC0%0/2
$err->type eq "return" and UNIVERSAL::isa($err->info, "HASH")
$err->type eq "return"
UNIVERSAL::isa($err->info, "HASH")
Truth table0%0/3
A and B
A= $err->type eq "return"B= UNIVERSAL::isa($err->info, "HASH")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | return $err->info->{'return_val'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 730 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 5094 | ▶ | sub _process { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process: called CC=23 SCAR=31.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 5094 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 5094 | my $file = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 5094 | ▶ | local $self->{'_vars'} = shift || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || {}
MC/DC100%1/1
shift() || {}
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 5094 | ▶ | my $out_ref = shift || $self->throw('undef', "Missing output ref"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
shift() || $self->throw('undef', 'Missing output ref')
MC/DC0%0/2
shift() || $self->throw('undef', 'Missing output ref')
shift()
$self->throw('undef', 'Missing output ref')
Truth table33%1/3
A || B
A= shift()B= $self->throw('undef', 'Missing output ref')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 5093 | local $self->{'_top_level'} = delete $self->{'_start_top_level'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 5093 | my $i = length $$out_ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | ### parse and execute | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 5093 | my $doc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 5093 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 5093 | ▶ | $doc = (ref($file) eq 'HASH') ? $file : $self->load_template($file); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | ### prevent recursion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | $self->throw('file', "recursion into '$doc->{name}'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 4919 | ▶ | if ! $self->{'RECURSION'} && $self->{'_in'}->{$doc->{'name'}} && $doc->{'name'} ne 'input text'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
not $self->{"RECURSION"} and $self->{"_in"}{$doc->{"name"}} and $doc->{"name"} ne "input text"
not $self->{"RECURSION"} and $self->{"_in"}{$doc->{"name"}}
MC/DC100%3/3
not $self->{"RECURSION"} and $self->{"_in"}{$doc->{"name"}} and $doc->{"name"} ne "input text"
not $self->{"RECURSION"}
$self->{"_in"}{$doc->{"name"}}
$doc->{"name"} ne "input text"
Truth table100%4/4
not(A) and B and C
A= not $self->{"RECURSION"}B= $self->{"_in"}{$doc->{"name"}}C= $doc->{"name"} ne "input text"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 4913 | local $self->{'_in'}->{$doc->{'name'}} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 4913 | local $self->{'_component'} = $doc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 4913 | ▶ | local $self->{'_template'} = $self->{'_top_level'} ? $doc : $self->{'_template'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 4913 | local @{ $self }{@CONFIG_RUNTIME} = @{ $self }{@CONFIG_RUNTIME}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | ### run the document however we can | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 4913 | ▶ | if ($self->{'STREAM'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 1356 | ▶ | $self->throw('process', 'No _tree found') if ! $doc->{'_tree'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 1356 | $self->stream_tree($doc->{'_tree'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } elsif ($self->{'COMPILE_JS'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | $self->play_js($doc, $out_ref); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } elsif ($doc->{'_perl'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 1742 | $doc->{'_perl'}->{'code'}->($self, $out_ref); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } elsif ($doc->{'_tree'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 1814 | $self->play_tree($doc->{'_tree'}, $out_ref); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 1 | $self->throw('process', 'No _perl and no _tree found'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | ### trim whitespace from the beginning and the end of a block or template | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 4718 | ▶ | if ($self->{'TRIM'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 27 | substr($$out_ref, $i, length($$out_ref) - $i) =~ s{ \s+ $ }{}x; # tail first | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 27 | substr($$out_ref, $i, length($$out_ref) - $i) =~ s{ ^ \s+ }{}x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | ### handle exceptions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 5093 | ▶ | if (my $err = $@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 375 | ▶ | $err = $self->exception('undef', $err) if ! UNIVERSAL::can($err, 'type'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 375 | ▶ | $err->doc($doc) if $doc && $err->can('doc') && ! $err->doc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$doc and $err->can("doc") and not $err->doc
$doc and $err->can("doc")
MC/DC66%2/3
$doc and $err->can("doc") and not $err->doc
$doc
$err->can("doc")
not $err->doc
Truth table75%3/4
A and B and not(C)
A= $docB= $err->can("doc")C= not $err->doc
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 375 | ▶ | die $err if ! $self->{'_top_level'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 273 | ▶ | die $err if $err->type ne 'stop' && ($err->type ne 'return' || $err->info); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$err->type ne "stop" and $err->type ne "return" || $err->info
$err->type ne "return" or $err->info
MC/DC66%2/3
$err->type ne "stop" and $err->type ne "return" || $err->info
$err->type ne "stop"
$err->type ne "return"
$err->info
Truth table75%3/4
A and B or C
A= $err->type ne "stop"B= $err->type ne "return"C= $err->info
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 4756 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 5245 | ▶ | sub load_template { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_template: called CC=71 SCAR=46.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 5245 | my ($self, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 5245 | ▶ | $self->throw('undef', 'Undefined file passed to load_template') if ! defined $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 5244 | ▶ | my $docs = $self->{'GLOBAL_CACHE'} || ($self->{'_documents'} ||= {}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition80%4/5
$self->{'GLOBAL_CACHE'} || ($self->{'_documents'} ||= {})
$self->{"_documents"} ||= {}
MC/DC0%0/2
$self->{'GLOBAL_CACHE'} || ($self->{'_documents'} ||= {})
$self->{'GLOBAL_CACHE'}
($self->{'_documents'} ||= {})
MC/DC100%1/1
$self->{"_documents"} ||= {}
$self->{"_documents"}
Truth table66%2/3
A || B
A= $self->{'GLOBAL_CACHE'}B= ($self->{'_documents'} ||= {})
Truth table100%2/2
A
A= $self->{"_documents"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 5244 | ▶ | $docs = $GLOBAL_CACHE if ! ref $docs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | ### looks like a scalar ref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 5244 | my $doc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 5244 | ▶ | if (ref $file) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 4477 | ▶ | return $file if ref $file eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 4476 | ▶ | if (! defined($self->{'CACHE_STR_REFS'}) || $self->{'CACHE_STR_REFS'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $self->{"CACHE_STR_REFS"} or $self->{"CACHE_STR_REFS"}
MC/DC50%1/2
not defined $self->{"CACHE_STR_REFS"} or $self->{"CACHE_STR_REFS"}
not defined $self->{"CACHE_STR_REFS"}
$self->{"CACHE_STR_REFS"}
Truth table66%2/3
not(A) or B
A= not defined $self->{"CACHE_STR_REFS"}B= $self->{"CACHE_STR_REFS"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 4473 | my $_file = $self->string_id($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 4473 | ▶ | if ($docs->{$_file}) { # no-ttl necessary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 193 | $doc = $docs->{$_file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 193 | ▶ | $doc->{'_perl'} = $self->load_perl($doc) if ! $doc->{'_perl'} && $self->{'COMPILE_PERL'}; # second hit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $doc->{"_perl"} and $self->{"COMPILE_PERL"}
MC/DC100%2/2
not $doc->{"_perl"} and $self->{"COMPILE_PERL"}
not $doc->{"_perl"}
$self->{"COMPILE_PERL"}
Truth table100%3/3
not(A) and B
A= not $doc->{"_perl"}B= $self->{"COMPILE_PERL"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 193 | return $doc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 4280 | $doc->{'_filename'} = $_file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 3 | ▶ | $doc->{'_no_perl'} = $self->{'FORCE_STR_REF_PERL'} ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 4283 | $doc->{'_is_str_ref'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 4283 | $doc->{'_content'} = $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 4283 | $doc->{'name'} = 'input text'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 4283 | $doc->{'modtime'} = time; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | ### looks like a previously cached document | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } elsif ($docs->{$file}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 19 | $doc = $docs->{$file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 19 | ▶ | if (time - $doc->{'cache_time'} < ($self->{'STAT_TTL'} || $STAT_TTL) # don't stat more than once a second | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
time - $doc->{"cache_time"} < ($self->{"STAT_TTL"} || $Template::Alloy::STAT_TTL) or $doc->{"modtime"} == (stat $doc->{"_filename"})[9]
$self->{'STAT_TTL'} || $Template::Alloy::STAT_TTL
MC/DC0%0/2
time - $doc->{"cache_time"} < ($self->{"STAT_TTL"} || $Template::Alloy::STAT_TTL) or $doc->{"modtime"} == (stat $doc->{"_filename"})[9]
time - $doc->{"cache_time"} < ($self->{"STAT_TTL"} || $Template::Alloy::STAT_TTL)
$doc->{"modtime"} == (stat $doc->{"_filename"})[9]
MC/DC0%0/2
$self->{'STAT_TTL'} || $Template::Alloy::STAT_TTL
$self->{'STAT_TTL'}
$Template::Alloy::STAT_TTL
Truth table33%1/3
A or B
A= time - $doc->{"cache_time"} < ($self->{"STAT_TTL"} || $Template::Alloy::STAT_TTL)B= $doc->{"modtime"} == (stat $doc->{"_filename"})[9]
Truth table33%1/3
A || B
A= $self->{'STAT_TTL'}B= $Template::Alloy::STAT_TTL
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | || $doc->{'modtime'} == (stat $doc->{'_filename'})[9]) { # otherwise see if the file was modified | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 19 | ▶ | $doc->{'_perl'} = $self->load_perl($doc) if ! $doc->{'_perl'} && $self->{'COMPILE_PERL'}; # second hit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $doc->{"_perl"} and $self->{"COMPILE_PERL"}
MC/DC100%2/2
not $doc->{"_perl"} and $self->{"COMPILE_PERL"}
not $doc->{"_perl"}
$self->{"COMPILE_PERL"}
Truth table100%3/3
not(A) and B
A= not $doc->{"_perl"}B= $self->{"COMPILE_PERL"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 19 | return $doc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | delete @$doc{qw(_tree modtime _content _line_offsets _perl _js)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | ### looks like a previously cached not-found | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } elsif ($self->{'_not_found'}->{$file}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 9 | $doc = $self->{'_not_found'}->{$file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 9 | ▶ | if (time - $doc->{'cache_time'} < ($self->{'NEGATIVE_STAT_TTL'} || $self->{'STAT_TTL'} || $STAT_TTL)) { # negative cache for a second | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$self->{'NEGATIVE_STAT_TTL'} || $self->{'STAT_TTL'} || $Template::Alloy::STAT_TTL
$self->{"NEGATIVE_STAT_TTL"} or $self->{"STAT_TTL"}
MC/DC0%0/3
$self->{'NEGATIVE_STAT_TTL'} || $self->{'STAT_TTL'} || $Template::Alloy::STAT_TTL
$self->{"NEGATIVE_STAT_TTL"}
$self->{"STAT_TTL"}
$Template::Alloy::STAT_TTL
Truth table50%2/4
A or B || C
A= $self->{"NEGATIVE_STAT_TTL"}B= $self->{"STAT_TTL"}C= $Template::Alloy::STAT_TTL
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 3 | die $doc->{'exception'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 6 | delete $self->{'_not_found'}->{$file}; # clear cache on failure | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | ### looks like a block passed in at runtime | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } elsif ($self->{'BLOCKS'}->{$file}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 227 | my $block = $self->{'BLOCKS'}->{$file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 227 | ▶ | $block = $block->() if UNIVERSAL::isa($block, 'CODE'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 227 | ▶ | if (! UNIVERSAL::isa($block, 'HASH')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 4 | ▶ | $self->throw('block', "Unsupported BLOCK type \"$block\"") if ref $block; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 3 | ▶ | $block = eval { $self->load_template(\$block) } || $self->throw('block', 'Parse error on predefined block'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
eval {
do {
$self->load_template(\$block)
}
} || $self->throw('block', 'Parse error on predefined block')
MC/DC0%0/2
eval {
do {
$self->load_template(\$block)
}
} || $self->throw('block', 'Parse error on predefined block')
eval {
do {
$self->load_template(\$block)
}
}
$self->throw('block', 'Parse error on predefined block')
Truth table33%1/3
A || B
A= eval {
do {
$self->load_template(\$block)
}
}B= $self->throw('block', 'Parse error on predefined block')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 225 | ▶ | $doc->{'name'} = ($block->{'name'} && $block->{'name'} ne 'input text') ? $block->{'name'} : $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$block->{"name"} and $block->{"name"} ne "input text"
MC/DC100%2/2
$block->{"name"} and $block->{"name"} ne "input text"
$block->{"name"}
$block->{"name"} ne "input text"
Truth table100%3/3
A and B
A= $block->{"name"}B= $block->{"name"} ne "input text"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 225 | ▶ | $doc->{'_filename'} = $block->{'_filename'} if $block->{'_filename'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 225 | ▶ | if ($block->{'_perl'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 77 | $doc->{'_perl'} = $block->{'_perl'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } elsif ($block->{'_tree'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 147 | $doc->{'_tree'} = $block->{'_tree'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 1 | $self->throw('block', "Invalid block definition (missing tree)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 224 | return $doc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | ### lookup the filename | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 4801 | ▶ | if (! $doc->{'_filename'} && ! ref $file) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$doc->{"_filename"} or ref $file
MC/DC100%2/2
$doc->{"_filename"} or ref $file
$doc->{"_filename"}
ref $file
Truth table100%3/3
A or B
A= $doc->{"_filename"}B= ref $file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 518 | $doc->{'name'} = $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 518 | $doc->{'_filename'} = eval { $self->include_filename($file) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 518 | ▶ | if (my $err = $@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | ### allow for blocks in other files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 51 | ▶ | if ($self->{'EXPOSE_BLOCKS'} && ! $self->{'_looking_in_block_file'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$self->{"EXPOSE_BLOCKS"} and not $self->{"_looking_in_block_file"}
MC/DC50%1/2
$self->{"EXPOSE_BLOCKS"} and not $self->{"_looking_in_block_file"}
$self->{"EXPOSE_BLOCKS"}
not $self->{"_looking_in_block_file"}
Truth table66%2/3
A and not(B)
A= $self->{"EXPOSE_BLOCKS"}B= not $self->{"_looking_in_block_file"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 18 | local $self->{'_looking_in_block_file'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 18 | my $block_name = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 18 | ▶ | OUTER: while ($file =~ s|/([^/.]+)$||) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 12 | ▶ | $block_name = length($block_name) ? "$1/$block_name" : $1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 12 | ▶ | my $ref = eval { $self->load_template($file) } || next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
eval {
do {
$self->load_template($file)
}
} || (next)
MC/DC0%0/1
eval {
do {
$self->load_template($file)
}
} || (next)
eval {
do {
$self->load_template($file)
}
}
Truth table50%1/2
A
A= eval {
do {
$self->load_template($file)
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 12 | my $_tree = $ref->{'_tree'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 12 | foreach my $node (@$_tree) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 30 | ▶ | last if ! ref $node; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 30 | ▶ | next if $node->[0] eq 'META'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 18 | ▶ | last if $node->[0] ne 'BLOCK'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 18 | ▶ | next if $block_name ne $node->[3]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 12 | $doc->{'_tree'} = $node->[4]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 12 | @{$doc}{qw(modtime _content)} = @{$ref}{qw(modtime _content)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | $doc->{'_perl'} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | meta => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | blocks => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | code => $ref->{'_perl'}->{'blocks'}->{$block_name}->{'_perl'}->{'code'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 12 | ▶ | } if $ref->{'_perl'} && $ref->{'_perl'}->{'blocks'} && $ref->{'_perl'}->{'blocks'}->{$block_name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$ref->{"_perl"} and $ref->{"_perl"}{"blocks"} and $ref->{"_perl"}{"blocks"}{$block_name}
$ref->{"_perl"} and $ref->{"_perl"}{"blocks"}
MC/DC33%1/3
$ref->{"_perl"} and $ref->{"_perl"}{"blocks"} and $ref->{"_perl"}{"blocks"}{$block_name}
$ref->{"_perl"}
$ref->{"_perl"}{"blocks"}
$ref->{"_perl"}{"blocks"}{$block_name}
Truth table50%2/4
A and B and C
A= $ref->{"_perl"}B= $ref->{"_perl"}{"blocks"}C= $ref->{"_perl"}{"blocks"}{$block_name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 12 | ▶ | $doc->{'_js'} = $self->load_js($doc) if $self->{'COMPILE_JS'} && $ref->{'_js'}; # have to regenerate because block is buried in js | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"COMPILE_JS"} and $ref->{"_js"}
MC/DC0%0/2
$self->{"COMPILE_JS"} and $ref->{"_js"}
$self->{"COMPILE_JS"}
$ref->{"_js"}
Truth table33%1/3
A and B
A= $self->{"COMPILE_JS"}B= $ref->{"_js"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 12 | return $doc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } elsif ($self->{'DEFAULT'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | $err = '' if ($doc->{'_filename'} = eval { $self->include_filename($self->{'DEFAULT'}) }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 39 | ▶ | if ($err) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | ### cache the negative error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 39 | ▶ | if (! defined($self->{'NEGATIVE_STAT_TTL'}) || $self->{'NEGATIVE_STAT_TTL'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $self->{"NEGATIVE_STAT_TTL"} or $self->{"NEGATIVE_STAT_TTL"}
MC/DC0%0/2
not defined $self->{"NEGATIVE_STAT_TTL"} or $self->{"NEGATIVE_STAT_TTL"}
not defined $self->{"NEGATIVE_STAT_TTL"}
$self->{"NEGATIVE_STAT_TTL"}
Truth table66%2/3
not(A) or B
A= not defined $self->{"NEGATIVE_STAT_TTL"}B= $self->{"NEGATIVE_STAT_TTL"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 39 | ▶ | $err = $self->exception('undef', $err) if ! UNIVERSAL::can($err, 'type'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 39 | $self->{'_not_found'}->{$file} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | cache_time => time, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | exception => $self->exception($err->type, $err->info." (cached)"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 39 | die $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | ### return perl - if they want perl - otherwise - the ast | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 4750 | ▶ | if (! $doc->{'_no_perl'} && $self->{'COMPILE_PERL'} && ($self->{'COMPILE_PERL'} ne '2' || $self->{'_tree'})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition88%8/9
not $doc->{"_no_perl"} and $self->{"COMPILE_PERL"} and $self->{"COMPILE_PERL"} ne 2 || $self->{"_tree"}
not $doc->{"_no_perl"} and $self->{"COMPILE_PERL"}
$self->{"COMPILE_PERL"} ne 2 or $self->{"_tree"}
MC/DC75%3/4
not $doc->{"_no_perl"} and $self->{"COMPILE_PERL"} and $self->{"COMPILE_PERL"} ne 2 || $self->{"_tree"}
not $doc->{"_no_perl"}
$self->{"COMPILE_PERL"}
$self->{"COMPILE_PERL"} ne 2
$self->{"_tree"}
Truth table80%4/5
not(A) and B and C or D
A= not $doc->{"_no_perl"}B= $self->{"COMPILE_PERL"}C= $self->{"COMPILE_PERL"} ne 2D= $self->{"_tree"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 1690 | $doc->{'_perl'} = $self->load_perl($doc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } elsif ($self->{'COMPILE_JS'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | $self->load_js($doc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 3060 | $doc->{'_tree'} = $self->load_tree($doc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | ### cache parsed_tree in memory unless asked not to do so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 4617 | ▶ | if (! defined($self->{'CACHE_SIZE'}) || $self->{'CACHE_SIZE'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $self->{"CACHE_SIZE"} or $self->{"CACHE_SIZE"}
MC/DC50%1/2
not defined $self->{"CACHE_SIZE"} or $self->{"CACHE_SIZE"}
not defined $self->{"CACHE_SIZE"}
$self->{"CACHE_SIZE"}
Truth table66%2/3
not(A) or B
A= not defined $self->{"CACHE_SIZE"}B= $self->{"CACHE_SIZE"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 4365 | $doc->{'cache_time'} = time; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 4365 | ▶ | if (ref $file) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 3920 | ▶ | $docs->{$doc->{'_filename'}} = $doc if $doc->{'_filename'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 445 | ▶ | $docs->{$file} ||= $doc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$docs->{$file} ||= $doc
MC/DC0%0/2
$docs->{$file} ||= $doc
$docs->{$file}
$doc
Truth table33%1/3
A ||= B
A= $docs->{$file}B= $doc
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | ### allow for config option to keep the cache size down | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 4365 | ▶ | if ($self->{'CACHE_SIZE'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | if (scalar(keys %$docs) > $self->{'CACHE_SIZE'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | my $n = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | foreach my $file (sort {$docs->{$b}->{'cache_time'} <=> $docs->{$a}->{'cache_time'}} keys %$docs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | delete($docs->{$file}) if ++$n > $self->{'CACHE_SIZE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 4617 | return $doc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 4474 | ▶ | sub string_id { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
string_id: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 4474 | my ($self, $ref) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 4474 | require Digest::MD5; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | my $str = ref($self) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | && $self->{'ENCODING'} # ENCODING is defined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 1 | && eval { require Encode } # Encode.pm is available | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | && defined &Encode::encode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 4474 | ▶ | ? Encode::encode($self->{'ENCODING'}, $$ref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
ref $self and $self->{"ENCODING"} and eval {
do {
require Encode
}
} and defined &Encode::encode
ref $self and $self->{"ENCODING"} and eval {
do {
require Encode
}
}
ref $self and $self->{"ENCODING"}
MC/DC50%2/4
ref $self and $self->{"ENCODING"} and eval {
do {
require Encode
}
} and defined &Encode::encode
ref $self
$self->{"ENCODING"}
eval {
do {
require Encode
}
}
defined &Encode::encode
Truth table60%3/5
A and B and C and D
A= ref $selfB= $self->{"ENCODING"}C= eval {
do {
require Encode
}
}D= defined &Encode::encode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | : $$ref; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 4474 | my $sum = Digest::MD5::md5_hex($str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 4474 | return 'Alloy_str_ref_cache/'.substr($sum,0,3).'/'.$sum; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 4749 | ▶ | sub load_tree { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_tree: called CC=23 SCAR=32.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 4749 | my ($self, $doc) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | ### first look for a compiled optree | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 4749 | ▶ | if ($doc->{'_filename'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 4746 | ▶ | $doc->{'modtime'} ||= (stat $doc->{'_filename'})[9]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$doc->{"modtime"} ||= (stat $doc->{"_filename"})[9]
MC/DC0%0/2
$doc->{"modtime"} ||= (stat $doc->{"_filename"})[9]
$doc->{"modtime"}
(stat $doc->{"_filename"})[9]
Truth table66%2/3
A ||= B
A= $doc->{"modtime"}B= (stat $doc->{"_filename"})[9]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 4746 | ▶ | if ($self->{'COMPILE_DIR'} || $self->{'COMPILE_EXT'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"COMPILE_DIR"} or $self->{"COMPILE_EXT"}
MC/DC100%2/2
$self->{"COMPILE_DIR"} or $self->{"COMPILE_EXT"}
$self->{"COMPILE_DIR"}
$self->{"COMPILE_EXT"}
Truth table100%3/3
A or B
A= $self->{"COMPILE_DIR"}B= $self->{"COMPILE_EXT"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 16 | my $file = $doc->{'_filename'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 16 | ▶ | if ($self->{'COMPILE_DIR'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 8 | ▶ | $file =~ y|:|/| if $^O eq 'MSWin32'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 8 | $file = $self->{'COMPILE_DIR'} .'/'. $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } elsif ($doc->{'_is_str_ref'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 2 | ▶ | $file = ($self->include_paths->[0] || '.') .'/'. $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->include_paths->[0] || '.'
MC/DC0%0/1
$self->include_paths->[0] || '.'
$self->include_paths->[0]
Truth table50%1/2
A
A= $self->include_paths->[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 16 | ▶ | $file .= $self->{'COMPILE_EXT'} if defined($self->{'COMPILE_EXT'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 16 | ▶ | $file .= $EXTRA_COMPILE_EXT if defined $EXTRA_COMPILE_EXT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 16 | ▶ | if (-e $file && ($doc->{'_is_str_ref'} || (stat $file)[9] == $doc->{'modtime'})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
-e $file and $doc->{"_is_str_ref"} || (stat $file)[9] == $doc->{"modtime"}
$doc->{"_is_str_ref"} or (stat $file)[9] == $doc->{"modtime"}
MC/DC33%1/3
-e $file and $doc->{"_is_str_ref"} || (stat $file)[9] == $doc->{"modtime"}
-e $file
$doc->{"_is_str_ref"}
(stat $file)[9] == $doc->{"modtime"}
Truth table50%2/4
A and B or C
A= -e $fileB= $doc->{"_is_str_ref"}C= (stat $file)[9] == $doc->{"modtime"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 1 | require Storable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 1 | return Storable::retrieve($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 15 | $doc->{'_storable_filename'} = $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | ### no cached tree - we will need to load our own | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 4748 | ▶ | $doc->{'_content'} ||= $self->slurp($doc->{'_filename'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$doc->{"_content"} ||= $self->slurp($doc->{"_filename"})
MC/DC0%0/2
$doc->{"_content"} ||= $self->slurp($doc->{"_filename"})
$doc->{"_content"}
$self->slurp($doc->{"_filename"})
Truth table66%2/3
A ||= B
A= $doc->{"_content"}B= $self->slurp($doc->{"_filename"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 4748 | ▶ | if ($self->{'CONSTANTS'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 33 | ▶ | my $key = $self->{'CONSTANT_NAMESPACE'} || 'constants'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'CONSTANT_NAMESPACE'} || 'constants'
MC/DC0%0/1
$self->{'CONSTANT_NAMESPACE'} || 'constants'
$self->{'CONSTANT_NAMESPACE'}
Truth table50%1/2
A
A= $self->{'CONSTANT_NAMESPACE'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 33 | ▶ | $self->{'NAMESPACE'}->{$key} ||= $self->{'CONSTANTS'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"NAMESPACE"}{$key} ||= $self->{"CONSTANTS"}
MC/DC0%0/2
$self->{"NAMESPACE"}{$key} ||= $self->{"CONSTANTS"}
$self->{"NAMESPACE"}{$key}
$self->{"CONSTANTS"}
Truth table33%1/3
A ||= B
A= $self->{"NAMESPACE"}{$key}B= $self->{"CONSTANTS"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 4748 | local $self->{'_component'} = $doc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 4748 | my $tree = eval { $self->parse_tree($doc->{'_content'}) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 4748 | ▶ | || do { my $e = $@; $e->doc($doc) if UNIVERSAL::can($e, 'doc') && ! $e->doc; die $e }; # errors die | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
eval {
do {
$self->parse_tree($doc->{'_content'})
}
} || do {
my $e = $@;
$e->doc($doc) if UNIVERSAL::can($e, 'doc') and not $e->doc;
die $e
}
UNIVERSAL::can($e, "doc") and not $e->doc
MC/DC0%0/2
eval {
do {
$self->parse_tree($doc->{'_content'})
}
} || do {
my $e = $@;
$e->doc($doc) if UNIVERSAL::can($e, 'doc') and not $e->doc;
die $e
}
eval {
do {
$self->parse_tree($doc->{'_content'})
}
}
do {
my $e = $@;
$e->doc($doc) if UNIVERSAL::can($e, 'doc') and not $e->doc;
die $e
}
MC/DC0%0/2
UNIVERSAL::can($e, "doc") and not $e->doc
UNIVERSAL::can($e, "doc")
not $e->doc
Truth table33%1/3
A || B
A= eval {
do {
$self->parse_tree($doc->{'_content'})
}
}B= do {
my $e = $@;
$e->doc($doc) if UNIVERSAL::can($e, 'doc') and not $e->doc;
die $e
}
Truth table33%1/3
A and not(B)
A= UNIVERSAL::can($e, "doc")B= not $e->doc
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | ### save a cache on the fileside as asked | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 4615 | ▶ | if ($doc->{'_storable_filename'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 15 | my $dir = $doc->{'_storable_filename'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 15 | $dir =~ s|/[^/]+$||; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 15 | ▶ | if (! -d $dir) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 10 | require File::Path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 10 | File::Path::mkpath($dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 15 | require Storable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 15 | Storable::store($tree, $doc->{'_storable_filename'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 15 | utime $doc->{'modtime'}, $doc->{'modtime'}, $doc->{'_storable_filename'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 4615 | return $tree; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | ### allow for resolving full expression ASTs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 27283 | ▶ | sub play_expr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
play_expr: called CC=118 SCAR=53.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 27283 | ▶ | return $_[1] if ! ref $_[1]; # allow for the parse tree to store literals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 18246 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 18246 | my $var = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 18246 | ▶ | my $ARGS = shift || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || {}
MC/DC100%1/1
shift() || {}
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 18246 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | ### determine the top level of this particular variable access | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 18246 | my $ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 18246 | my $name = $var->[$i++]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 18246 | my $args = $var->[$i++]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 18246 | ▶ | if (ref $name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 9142 | ▶ | if (! defined $name->[0]) { # operator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 8968 | ▶ | return $self->play_operator($name) if wantarray && $name->[1] eq '..'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
wantarray and $name->[1] eq ".."
MC/DC100%2/2
wantarray and $name->[1] eq ".."
wantarray
$name->[1] eq ".."
Truth table100%3/3
A and B
A= wantarrayB= $name->[1] eq ".."
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 8776 | ▶ | $ref = ($name->[1] eq '-temp-') ? $name->[2] : $self->play_operator($name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | } else { # a named variable access (ie via $name.foo) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 174 | $name = $self->play_expr($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 174 | ▶ | if (defined $name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 174 | ▶ | return if $QR_PRIVATE && $name =~ $QR_PRIVATE; # don't allow vars that begin with _ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$Template::Alloy::QR_PRIVATE and $name =~ /$Template::Alloy::QR_PRIVATE/
MC/DC50%1/2
$Template::Alloy::QR_PRIVATE and $name =~ /$Template::Alloy::QR_PRIVATE/
$Template::Alloy::QR_PRIVATE
$name =~ /$Template::Alloy::QR_PRIVATE/
Truth table66%2/3
A and B
A= $Template::Alloy::QR_PRIVATEB= $name =~ /$Template::Alloy::QR_PRIVATE/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 171 | ▶ | return \$self->{'_vars'}->{$name} if $i >= $#$var && $ARGS->{'return_ref'} && ! ref $self->{'_vars'}->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$i >= $var->$#* and $ARGS->{"return_ref"} and not ref $self->{"_vars"}{$name}
$i >= $var->$#* and $ARGS->{"return_ref"}
MC/DC0%0/3
$i >= $var->$#* and $ARGS->{"return_ref"} and not ref $self->{"_vars"}{$name}
$i >= $var->$#*
$ARGS->{"return_ref"}
not ref $self->{"_vars"}{$name}
Truth table50%2/4
A and B and not(C)
A= $i >= $var->$#*B= $ARGS->{"return_ref"}C= not ref $self->{"_vars"}{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 171 | $ref = $self->{'_vars'}->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } elsif (defined $name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 9104 | ▶ | return if $QR_PRIVATE && $name =~ $QR_PRIVATE; # don't allow vars that begin with _ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$Template::Alloy::QR_PRIVATE and $name =~ /$Template::Alloy::QR_PRIVATE/
MC/DC100%2/2
$Template::Alloy::QR_PRIVATE and $name =~ /$Template::Alloy::QR_PRIVATE/
$Template::Alloy::QR_PRIVATE
$name =~ /$Template::Alloy::QR_PRIVATE/
Truth table100%3/3
A and B
A= $Template::Alloy::QR_PRIVATEB= $name =~ /$Template::Alloy::QR_PRIVATE/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 9089 | ▶ | return \$self->{'_vars'}->{$name} if $i >= $#$var && $ARGS->{'return_ref'} && ! ref $self->{'_vars'}->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$i >= $var->$#* and $ARGS->{"return_ref"} and not ref $self->{"_vars"}{$name}
$i >= $var->$#* and $ARGS->{"return_ref"}
MC/DC100%3/3
$i >= $var->$#* and $ARGS->{"return_ref"} and not ref $self->{"_vars"}{$name}
$i >= $var->$#*
$ARGS->{"return_ref"}
not ref $self->{"_vars"}{$name}
Truth table100%4/4
A and B and not(C)
A= $i >= $var->$#*B= $ARGS->{"return_ref"}C= not ref $self->{"_vars"}{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 9083 | $ref = $self->{'_vars'}->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 9083 | ▶ | if (! defined $ref) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 811 | ▶ | $ref = ($name eq 'template' || $name eq 'component') ? $self->{"_$name"} : $VOBJS->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$name eq "template" or $name eq "component"
MC/DC100%2/2
$name eq "template" or $name eq "component"
$name eq "template"
$name eq "component"
Truth table100%3/3
A or B
A= $name eq "template"B= $name eq "component"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 811 | ▶ | $ref = $ITEM_METHODS->{$name} || $ITEM_OPS->{$name} if ! $ref && (! defined($self->{'VMETHOD_FUNCTIONS'}) || $self->{'VMETHOD_FUNCTIONS'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
not $ref and !defined($self->{"VMETHOD_FUNCTIONS"}) || $self->{"VMETHOD_FUNCTIONS"}
not defined $self->{"VMETHOD_FUNCTIONS"} or $self->{"VMETHOD_FUNCTIONS"}
$Template::Alloy::ITEM_METHODS->{$name} || $Template::Alloy::ITEM_OPS->{$name}
MC/DC0%0/3
not $ref and !defined($self->{"VMETHOD_FUNCTIONS"}) || $self->{"VMETHOD_FUNCTIONS"}
not $ref
not defined $self->{"VMETHOD_FUNCTIONS"}
$self->{"VMETHOD_FUNCTIONS"}
MC/DC50%1/2
$Template::Alloy::ITEM_METHODS->{$name} || $Template::Alloy::ITEM_OPS->{$name}
$Template::Alloy::ITEM_METHODS->{$name}
$Template::Alloy::ITEM_OPS->{$name}
Truth table0%0/4
not(A) and not(B) or C
A= not $refB= not defined $self->{"VMETHOD_FUNCTIONS"}C= $self->{"VMETHOD_FUNCTIONS"}
Truth table66%2/3
A || B
A= $Template::Alloy::ITEM_METHODS->{$name}B= $Template::Alloy::ITEM_OPS->{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 811 | ▶ | $ref = $self->{'_vars'}->{lc $name} if ! defined $ref && $self->{'LOWER_CASE_VAR_FALLBACK'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $ref and $self->{"LOWER_CASE_VAR_FALLBACK"}
MC/DC100%2/2
not defined $ref and $self->{"LOWER_CASE_VAR_FALLBACK"}
not defined $ref
$self->{"LOWER_CASE_VAR_FALLBACK"}
Truth table100%3/3
not(A) and B
A= not defined $refB= $self->{"LOWER_CASE_VAR_FALLBACK"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 18030 | my %seen_filters; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 18030 | ▶ | while (defined $ref) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | ### check at each point if the returned thing was a code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 20225 | ▶ | if (UNIVERSAL::isa($ref, 'CODE')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 547 | ▶ | return $ref if $i >= $#$var && $ARGS->{'return_ref'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$i >= $var->$#* and $ARGS->{"return_ref"}
MC/DC100%2/2
$i >= $var->$#* and $ARGS->{"return_ref"}
$i >= $var->$#*
$ARGS->{"return_ref"}
Truth table100%3/3
A and B
A= $i >= $var->$#*B= $ARGS->{"return_ref"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 532 | ▶ | my @args = $args ? map { $self->play_expr($_) } @$args : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 532 | ▶ | my $type = $self->{'CALL_CONTEXT'} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'CALL_CONTEXT'} || ''
MC/DC100%1/1
$self->{'CALL_CONTEXT'} || ''
$self->{'CALL_CONTEXT'}
Truth table100%2/2
A
A= $self->{'CALL_CONTEXT'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 532 | ▶ | if ($type eq 'item') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 39 | $ref = $ref->(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 493 | my @results = $ref->(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 490 | ▶ | if ($type eq 'list') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 33 | $ref = \@results; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | } elsif (defined $results[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 453 | ▶ | $ref = ($#results > 0) ? \@results : $results[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | } elsif (defined $results[1]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | die $results[1]; # TT behavior - why not just throw ? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 4 | $ref = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 4 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | ### descend one chained level | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 20203 | ▶ | last if $i >= $#$var; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 3031 | ▶ | my $was_dot_call = $ARGS->{'no_dots'} ? 1 : $var->[$i++] eq '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 3031 | $name = $var->[$i++]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 3031 | $args = $var->[$i++]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | ### allow for named portions of a variable name (foo.$name.bar) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 3031 | ▶ | if (ref $name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 48 | ▶ | if (ref($name) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 48 | $name = $self->play_expr($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 48 | ▶ | if (! defined($name) || ($QR_PRIVATE && $name =~ $QR_PRIVATE) || $name =~ /^\./) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
not defined $name or $Template::Alloy::QR_PRIVATE and $name =~ /$Template::Alloy::QR_PRIVATE/ or $name =~ /^\./
not defined $name or $Template::Alloy::QR_PRIVATE and $name =~ /$Template::Alloy::QR_PRIVATE/
$Template::Alloy::QR_PRIVATE and $name =~ /$Template::Alloy::QR_PRIVATE/
MC/DC0%0/4
not defined $name or $Template::Alloy::QR_PRIVATE and $name =~ /$Template::Alloy::QR_PRIVATE/ or $name =~ /^\./
not defined $name
$Template::Alloy::QR_PRIVATE
$name =~ /$Template::Alloy::QR_PRIVATE/
$name =~ /^\./
Truth table16%1/6
not(A) or B and C or D
A= not defined $nameB= $Template::Alloy::QR_PRIVATEC= $name =~ /$Template::Alloy::QR_PRIVATE/D= $name =~ /^\./
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | $ref = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | die "Shouldn't get a ". ref($name) ." during a vivify on chain"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 3031 | ▶ | if (! defined $name || ($QR_PRIVATE && $name =~ $QR_PRIVATE)) { # don't allow vars that begin with _ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not defined $name or $Template::Alloy::QR_PRIVATE and $name =~ /$Template::Alloy::QR_PRIVATE/
$Template::Alloy::QR_PRIVATE and $name =~ /$Template::Alloy::QR_PRIVATE/
MC/DC66%2/3
not defined $name or $Template::Alloy::QR_PRIVATE and $name =~ /$Template::Alloy::QR_PRIVATE/
not defined $name
$Template::Alloy::QR_PRIVATE
$name =~ /$Template::Alloy::QR_PRIVATE/
Truth table75%3/4
not(A) or B and C
A= not defined $nameB= $Template::Alloy::QR_PRIVATEC= $name =~ /$Template::Alloy::QR_PRIVATE/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 3 | $ref = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 3 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | ### allow for scalar and filter access (this happens for every non virtual method call) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 3028 | ▶ | if (! ref $ref) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 935 | ▶ | if ($ITEM_METHODS->{$name}) { # normal scalar op | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 223 | ▶ | $ref = $ITEM_METHODS->{$name}->($self, $ref, $args ? map { $self->play_expr($_) } @$args : ()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | } elsif ($ITEM_OPS->{$name}) { # normal scalar op | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 661 | ▶ | $ref = $ITEM_OPS->{$name}->($ref, $args ? map { $self->play_expr($_) } @$args : ()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | } elsif ($LIST_OPS->{$name}) { # auto-promote to list and use list op | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | $ref = $LIST_OPS->{$name}->([$ref], $args ? map { $self->play_expr($_) } @$args : ()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | ▶ | } elsif (my $filter = $self->{'FILTERS'}->{$name} # filter configured in Template args | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition83%10/12
$self->{'FILTERS'}{$name} || $Template::Alloy::FILTER_OPS->{$name} || UNIVERSAL::isa($name, 'CODE') && $name || $self->list_filters->{$name}
$self->{"FILTERS"}{$name} or $Template::Alloy::FILTER_OPS->{$name} or UNIVERSAL::isa($name, "CODE") and $name
$self->{"FILTERS"}{$name} or $Template::Alloy::FILTER_OPS->{$name}
UNIVERSAL::isa($name, "CODE") and $name
MC/DC60%3/5
$self->{'FILTERS'}{$name} || $Template::Alloy::FILTER_OPS->{$name} || UNIVERSAL::isa($name, 'CODE') && $name || $self->list_filters->{$name}
$self->{"FILTERS"}{$name}
$Template::Alloy::FILTER_OPS->{$name}
UNIVERSAL::isa($name, "CODE")
$name
$self->list_filters->{$name}
Truth table57%4/7
A or B or C and D || E
A= $self->{"FILTERS"}{$name}B= $Template::Alloy::FILTER_OPS->{$name}C= UNIVERSAL::isa($name, "CODE")D= $nameE= $self->list_filters->{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | || $FILTER_OPS->{$name} # predefined filters in Alloy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | || (UNIVERSAL::isa($name, 'CODE') && $name) # looks like a filter sub passed in the stash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | || $self->list_filters->{$name}) { # filter defined in Template::Filters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 36 | ▶ | if (UNIVERSAL::isa($filter, 'CODE')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 9 | $ref = eval { $filter->($ref) }; # non-dynamic filter - no args | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 9 | ▶ | if (my $err = $@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | ▶ | $self->throw('filter', $err) if ! UNIVERSAL::can($err, 'type'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | die $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | } elsif (! UNIVERSAL::isa($filter, 'ARRAY')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | $self->throw('filter', "invalid FILTER entry for '$name' (not a CODE ref)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | ▶ | } elsif (@$filter == 2 && UNIVERSAL::isa($filter->[0], 'CODE')) { # these are the TT style filters | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
@$filter == 2 and UNIVERSAL::isa($filter->[0], "CODE")
MC/DC50%1/2
@$filter == 2 and UNIVERSAL::isa($filter->[0], "CODE")
@$filter == 2
UNIVERSAL::isa($filter->[0], "CODE")
Truth table66%2/3
A and B
A= @$filter == 2B= UNIVERSAL::isa($filter->[0], "CODE")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 9 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 9 | my $sub = $filter->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 9 | ▶ | if ($filter->[1]) { # it is a "dynamic filter" that will return a sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 6 | ▶ | ($sub, my $err) = $sub->($self->context, $args ? map { $self->play_expr($_) } @$args : ()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 6 | ▶ | if (! $sub && $err) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
not $sub and $err
MC/DC0%0/2
not $sub and $err
not $sub
$err
Truth table33%1/3
not(A) and B
A= not $subB= $err
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | $self->throw('filter', $err) if ! UNIVERSAL::can($err, 'type'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | die $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | } elsif (! UNIVERSAL::isa($sub, 'CODE')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | ▶ | $self->throw('filter', "invalid FILTER for '$name' (not a CODE ref)") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | if ! UNIVERSAL::can($sub, 'type'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | die $sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 9 | $ref = $sub->($ref); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 9 | ▶ | if (my $err = $@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | $self->throw('filter', $err) if ! UNIVERSAL::can($err, 'type'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | die $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | } else { # this looks like our vmethods turned into "filters" (a filter stored under a name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 18 | ▶ | $self->throw('filter', 'Recursive filter alias \"$name\"') if $seen_filters{$name} ++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 18 | $var = [$name, 0, '|', @$filter, @{$var}[$i..$#$var]]; # splice the filter into our current tree | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 18 | $i = 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 36 | ▶ | if (scalar keys %seen_filters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
scalar keys %seen_filters and $seen_filters{$$var[$i - 5] or ""}
$$var[$i - 5] || ''
MC/DC0%0/2
scalar keys %seen_filters and $seen_filters{$$var[$i - 5] or ""}
scalar keys %seen_filters
$seen_filters{$$var[$i - 5] or ""}
MC/DC0%0/1
$$var[$i - 5] || ''
$$var[$i - 5]
Truth table66%2/3
A and B
A= scalar keys %seen_filtersB= $seen_filters{$$var[$i - 5] or ""}
Truth table50%1/2
A
A= $$var[$i - 5]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | && $seen_filters{$var->[$i - 5] || ''}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | $self->throw('filter', "invalid FILTER entry for '".$var->[$i - 5]."' (not a CODE ref)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 6 | $ref = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | ### method calls on objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 2093 | ▶ | if ($was_dot_call && UNIVERSAL::can($ref, 'can')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$was_dot_call and UNIVERSAL::can($ref, "can")
MC/DC100%2/2
$was_dot_call and UNIVERSAL::can($ref, "can")
$was_dot_call
UNIVERSAL::can($ref, "can")
Truth table100%3/3
A and B
A= $was_dot_callB= UNIVERSAL::can($ref, "can")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 535 | ▶ | return $ref if $i >= $#$var && $ARGS->{'return_ref'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$i >= $var->$#* and $ARGS->{"return_ref"}
MC/DC0%0/2
$i >= $var->$#* and $ARGS->{"return_ref"}
$i >= $var->$#*
$ARGS->{"return_ref"}
Truth table66%2/3
A and B
A= $i >= $var->$#*B= $ARGS->{"return_ref"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 535 | ▶ | my $type = $self->{'CALL_CONTEXT'} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'CALL_CONTEXT'} || ''
MC/DC100%1/1
$self->{'CALL_CONTEXT'} || ''
$self->{'CALL_CONTEXT'}
Truth table100%2/2
A
A= $self->{'CALL_CONTEXT'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 535 | ▶ | my @args = $args ? map { $self->play_expr($_) } @$args : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 535 | ▶ | if ($type eq 'item') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 21 | $ref = $ref->$name(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 21 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | } elsif ($type eq 'list') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 21 | $ref = [$ref->$name(@args)]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 21 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 493 | my @results = eval { $ref->$name(@args) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 493 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 9 | my $class = ref $ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 9 | ▶ | die $@ if ref $@ || $@ !~ /Can\'t locate object method "\Q$name\E" via package "\Q$class\E"/ || $type eq 'list'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
ref $@ or not $@ =~ /Can\'t locate object method "\Q$name\E" via package "\Q$class\E"/ or $type eq "list"
ref $@ or not $@ =~ /Can\'t locate object method "\Q$name\E" via package "\Q$class\E"/
MC/DC0%0/3
ref $@ or not $@ =~ /Can\'t locate object method "\Q$name\E" via package "\Q$class\E"/ or $type eq "list"
ref $@
not $@ =~ /Can\'t locate object method "\Q$name\E" via package "\Q$class\E"/
$type eq "list"
Truth table25%1/4
A or not(B) or C
A= ref $@B= not $@ =~ /Can\'t locate object method "\Q$name\E" via package "\Q$class\E"/C= $type eq "list"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | } elsif (defined $results[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 484 | ▶ | $ref = ($#results > 0) ? \@results : $results[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 484 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | } elsif (defined $results[1]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | die $results[1]; # TT behavior - why not just throw ? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | $ref = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | # didn't find a method by that name - so fail down to hash and array access | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 1567 | ▶ | if (UNIVERSAL::isa($ref, 'HASH')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 980 | ▶ | if ($was_dot_call && exists($ref->{$name}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
$was_dot_call and exists $ref->{$name}
MC/DC100%2/2
$was_dot_call and exists $ref->{$name}
$was_dot_call
exists $ref->{$name}
Truth table100%3/3
A and B
A= $was_dot_callB= exists $ref->{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 692 | ▶ | return \ $ref->{$name} if $i >= $#$var && $ARGS->{'return_ref'} && ! ref $ref->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$i >= $var->$#* and $ARGS->{"return_ref"} and not ref $ref->{$name}
$i >= $var->$#* and $ARGS->{"return_ref"}
MC/DC66%2/3
$i >= $var->$#* and $ARGS->{"return_ref"} and not ref $ref->{$name}
$i >= $var->$#*
$ARGS->{"return_ref"}
not ref $ref->{$name}
Truth table75%3/4
A and B and not(C)
A= $i >= $var->$#*B= $ARGS->{"return_ref"}C= not ref $ref->{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 680 | $ref = $ref->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } elsif ($HASH_OPS->{$name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 159 | ▶ | $ref = $HASH_OPS->{$name}->($ref, $args ? map { $self->play_expr($_) } @$args : ()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | } elsif ($ARGS->{'is_namespace_during_compile'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 6 | return $var; # abort - can't fold namespace variable | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 123 | ▶ | return \ $ref->{$name} if $i >= $#$var && $ARGS->{'return_ref'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$i >= $var->$#* and $ARGS->{"return_ref"}
MC/DC100%2/2
$i >= $var->$#* and $ARGS->{"return_ref"}
$i >= $var->$#*
$ARGS->{"return_ref"}
Truth table100%3/3
A and B
A= $i >= $var->$#*B= $ARGS->{"return_ref"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 120 | $ref = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | } elsif (UNIVERSAL::isa($ref, 'ARRAY')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 587 | ▶ | if ($name =~ m{ ^ -? $QR_INDEX $ }ox) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 155 | ▶ | return \ $ref->[$name] if $i >= $#$var && $ARGS->{'return_ref'} && ! ref $ref->[$name]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$i >= $var->$#* and $ARGS->{"return_ref"} and not ref $ref->[$name]
$i >= $var->$#* and $ARGS->{"return_ref"}
MC/DC66%2/3
$i >= $var->$#* and $ARGS->{"return_ref"} and not ref $ref->[$name]
$i >= $var->$#*
$ARGS->{"return_ref"}
not ref $ref->[$name]
Truth table75%3/4
A and B and not(C)
A= $i >= $var->$#*B= $ARGS->{"return_ref"}C= not ref $ref->[$name]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 149 | $ref = $ref->[$name]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | } elsif ($LIST_OPS->{$name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 432 | ▶ | $ref = $LIST_OPS->{$name}->($ref, $args ? map { $self->play_expr($_) } @$args : ()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | $ref = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | $ref = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | } # end of while | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 17941 | ▶ | if (! defined $ref) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 769 | ▶ | $self->strict_throw($var) if $self->{'STRICT'}; # will die | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 745 | ▶ | die $self->tt_var_string($var)." is undefined\n" if $self->{'_debug_undef'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 739 | $ref = $self->undefined_any($var); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 17911 | return $ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 5533 | ▶ | sub set_variable { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_variable: called CC=58 SCAR=49.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 5533 | my ($self, $var, $val, $ARGS) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 5533 | ▶ | $ARGS ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$ARGS ||= {}
MC/DC100%1/1
$ARGS ||= {}
$ARGS
Truth table100%2/2
A
A= $ARGS
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 5533 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | ### allow for the parse tree to store literals - the literal is used as a name (like [% 'a' = 'A' %]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 5533 | ▶ | $var = [$var, 0] if ! ref $var; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | ### determine the top level of this particular variable access | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 5533 | my $ref = $var->[$i++]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 5533 | my $args = $var->[$i++]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 5533 | ▶ | if (ref $ref) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | ### non-named types can't be set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 18 | ▶ | return if ref($ref) ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 18 | ▶ | if (! defined $ref->[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 6 | ▶ | return if ! $ref->[1] || $ref->[1] !~ /^[\$\@]\(\)$/; # do allow @( ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ref->[1] and $ref->[1] =~ /^[\$\@]\(\)$/
MC/DC0%0/2
$ref->[1] and $ref->[1] =~ /^[\$\@]\(\)$/
$ref->[1]
$ref->[1] =~ /^[\$\@]\(\)$/
Truth table33%1/3
A and B
A= $ref->[1]B= $ref->[1] =~ /^[\$\@]\(\)$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 6 | $ref = $self->play_operator($ref); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | # named access (ie via $name.foo) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 12 | $ref = $self->play_expr($ref); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 12 | ▶ | if (defined $ref && (! $QR_PRIVATE || $ref !~ $QR_PRIVATE)) { # don't allow vars that begin with _ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $ref and not $Template::Alloy::QR_PRIVATE && $ref =~ /$Template::Alloy::QR_PRIVATE/
$Template::Alloy::QR_PRIVATE && $ref =~ /$Template::Alloy::QR_PRIVATE/
MC/DC0%0/3
defined $ref and not $Template::Alloy::QR_PRIVATE && $ref =~ /$Template::Alloy::QR_PRIVATE/
defined $ref
$Template::Alloy::QR_PRIVATE
$ref =~ /$Template::Alloy::QR_PRIVATE/
Truth table25%1/4
A and not(B && C)
A= defined $refB= $Template::Alloy::QR_PRIVATEC= $ref =~ /$Template::Alloy::QR_PRIVATE/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 12 | ▶ | if ($#$var <= $i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 6 | return $self->{'_vars'}->{$ref} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 6 | ▶ | $ref = $self->{'_vars'}->{$ref} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"_vars"}{$ref} ||= {}
MC/DC0%0/1
$self->{"_vars"}{$ref} ||= {}
$self->{"_vars"}{$ref}
Truth table50%1/2
A
A= $self->{"_vars"}{$ref}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | } elsif (defined $ref) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 5515 | ▶ | return if $QR_PRIVATE && $ref =~ $QR_PRIVATE; # don't allow vars that begin with _ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$Template::Alloy::QR_PRIVATE and $ref =~ /$Template::Alloy::QR_PRIVATE/
MC/DC100%2/2
$Template::Alloy::QR_PRIVATE and $ref =~ /$Template::Alloy::QR_PRIVATE/
$Template::Alloy::QR_PRIVATE
$ref =~ /$Template::Alloy::QR_PRIVATE/
Truth table100%3/3
A and B
A= $Template::Alloy::QR_PRIVATEB= $ref =~ /$Template::Alloy::QR_PRIVATE/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 5512 | ▶ | if ($#$var <= $i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 5374 | return $self->{'_vars'}->{$ref} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 138 | ▶ | $ref = $self->{'_vars'}->{$ref} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"_vars"}{$ref} ||= {}
MC/DC100%1/1
$self->{"_vars"}{$ref} ||= {}
$self->{"_vars"}{$ref}
Truth table100%2/2
A
A= $self->{"_vars"}{$ref}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 150 | ▶ | while (defined $ref) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | ### check at each point if the returned thing was a code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 198 | ▶ | if (UNIVERSAL::isa($ref, 'CODE')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 6 | ▶ | my $type = $self->{'CALL_CONTEXT'} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'CALL_CONTEXT'} || ''
MC/DC100%1/1
$self->{'CALL_CONTEXT'} || ''
$self->{'CALL_CONTEXT'}
Truth table100%2/2
A
A= $self->{'CALL_CONTEXT'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | ▶ | my @args = $args ? map { $self->play_expr($_) } @$args : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 6 | ▶ | if ($type eq 'item') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | $ref = $ref->(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 6 | my @results = $ref->(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 6 | ▶ | if ($type eq 'list') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 3 | $ref = \@results; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | } elsif (defined $results[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 3 | ▶ | $ref = ($#results > 0) ? \@results : $results[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | } elsif (defined $results[1]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | die $results[1]; # TT behavior - why not just throw ? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | ### descend one chained level | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 198 | ▶ | last if $i >= $#$var; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 198 | ▶ | my $was_dot_call = $ARGS->{'no_dots'} ? 1 : $var->[$i++] eq '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 198 | my $name = $var->[$i++]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 198 | my $args = $var->[$i++]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | ### allow for named portions of a variable name (foo.$name.bar) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 198 | ▶ | if (ref $name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 18 | ▶ | if (ref($name) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 18 | $name = $self->play_expr($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 18 | ▶ | if (! defined($name) || $name =~ /^[_.]/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $name or $name =~ /^[_.]/
MC/DC0%0/2
not defined $name or $name =~ /^[_.]/
not defined $name
$name =~ /^[_.]/
Truth table33%1/3
not(A) or B
A= not defined $nameB= $name =~ /^[_.]/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | die "Shouldn't get a ".ref($name)." during a vivify on chain"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 198 | ▶ | if ($QR_PRIVATE && $name =~ $QR_PRIVATE) { # don't allow vars that begin with _ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$Template::Alloy::QR_PRIVATE and $name =~ /$Template::Alloy::QR_PRIVATE/
MC/DC0%0/2
$Template::Alloy::QR_PRIVATE and $name =~ /$Template::Alloy::QR_PRIVATE/
$Template::Alloy::QR_PRIVATE
$name =~ /$Template::Alloy::QR_PRIVATE/
Truth table33%1/3
A and B
A= $Template::Alloy::QR_PRIVATEB= $name =~ /$Template::Alloy::QR_PRIVATE/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | ### scalar access | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 198 | ▶ | if (! ref $ref) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | ### method calls on objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | } elsif (UNIVERSAL::can($ref, 'can')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 15 | my $lvalueish; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 15 | ▶ | my $type = $self->{'CALL_CONTEXT'} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'CALL_CONTEXT'} || ''
MC/DC100%1/1
$self->{'CALL_CONTEXT'} || ''
$self->{'CALL_CONTEXT'}
Truth table100%2/2
A
A= $self->{'CALL_CONTEXT'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | ▶ | my @args = $args ? map { $self->play_expr($_) } @$args : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 15 | ▶ | if ($i >= $#$var) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 12 | $lvalueish = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 12 | push @args, $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 15 | ▶ | if ($type eq 'item') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 3 | $ref = $ref->$name(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 3 | ▶ | return if $lvalueish; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | } elsif ($type eq 'list') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 3 | $ref = [$ref->$name(@args)]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 3 | ▶ | return if $lvalueish; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 9 | my @results = eval { $ref->$name(@args) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 9 | ▶ | if (! $@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 9 | ▶ | if (defined $results[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 9 | ▶ | $ref = ($#results > 0) ? \@results : $results[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | } elsif (defined $results[1]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | die $results[1]; # TT behavior - why not just throw ? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 9 | ▶ | return if $lvalueish; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 3 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | my $class = ref $ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | ▶ | die $@ if ref $@ || $@ !~ /Can\'t locate object method "\Q$name\E" via package "\Q$class\E"/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $@ or not $@ =~ /Can\'t locate object method "\Q$name\E" via package "\Q$class\E"/
MC/DC0%0/2
ref $@ or not $@ =~ /Can\'t locate object method "\Q$name\E" via package "\Q$class\E"/
ref $@
not $@ =~ /Can\'t locate object method "\Q$name\E" via package "\Q$class\E"/
Truth table0%0/3
A or not(B)
A= ref $@B= not $@ =~ /Can\'t locate object method "\Q$name\E" via package "\Q$class\E"/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | # fall on down to "normal" accessors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 183 | ▶ | if (UNIVERSAL::isa($ref, 'HASH')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 165 | ▶ | if ($#$var <= $i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 126 | return $ref->{$name} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 39 | ▶ | $ref = $ref->{$name} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$ref->{$name} ||= {}
MC/DC100%1/1
$ref->{$name} ||= {}
$ref->{$name}
Truth table100%2/2
A
A= $ref->{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 39 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | } elsif (UNIVERSAL::isa($ref, 'ARRAY')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 18 | ▶ | if ($name =~ m{ ^ -? $QR_INDEX $ }ox) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 18 | ▶ | if ($#$var <= $i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 12 | return $ref->[$name] = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 6 | ▶ | $ref = $ref->[$name] ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ref->[$name] ||= {}
MC/DC0%0/1
$ref->[$name] ||= {}
$ref->[$name]
Truth table50%1/2
A
A= $ref->[$name]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 6 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 190 | ▶ | sub _vars { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_vars: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 190 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 190 | ▶ | $self->{'_vars'} = shift if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 190 | ▶ | return $self->{'_vars'} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"_vars"} ||= {}
MC/DC0%0/1
$self->{"_vars"} ||= {}
$self->{"_vars"}
Truth table50%1/2
A
A= $self->{"_vars"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 539 | ▶ | sub include_filename { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
include_filename: called CC=14 SCAR=33.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 539 | my ($self, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 539 | ▶ | if ($file =~ m|^/|) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | ▶ | $self->throw('file', "$file absolute paths are not allowed (set ABSOLUTE option)") if ! $self->{'ABSOLUTE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | ▶ | return $file if -e $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | } elsif ($file =~ m{(^|/)\.\./}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | ▶ | $self->throw('file', "$file relative paths are not allowed (set RELATIVE option)") if ! $self->{'RELATIVE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | ▶ | return $file if -e $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 539 | my @paths = @{ $self->include_paths }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 539 | ▶ | if ($self->{'ADD_LOCAL_PATH'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
$self->{"ADD_LOCAL_PATH"} and $self->{"_component"} and $self->{"_component"}{"_filename"} and $self->{"_component"}{"_filename"} =~ m[^(.+)/[^/]+$]
$self->{"ADD_LOCAL_PATH"} and $self->{"_component"} and $self->{"_component"}{"_filename"}
$self->{"ADD_LOCAL_PATH"} and $self->{"_component"}
MC/DC25%1/4
$self->{"ADD_LOCAL_PATH"} and $self->{"_component"} and $self->{"_component"}{"_filename"} and $self->{"_component"}{"_filename"} =~ m[^(.+)/[^/]+$]
$self->{"ADD_LOCAL_PATH"}
$self->{"_component"}
$self->{"_component"}{"_filename"}
$self->{"_component"}{"_filename"} =~ m[^(.+)/[^/]+$]
Truth table40%2/5
A and B and C and D
A= $self->{"ADD_LOCAL_PATH"}B= $self->{"_component"}C= $self->{"_component"}{"_filename"}D= $self->{"_component"}{"_filename"} =~ m[^(.+)/[^/]+$]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | && $self->{'_component'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | && $self->{'_component'}->{'_filename'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | && $self->{'_component'}->{'_filename'} =~ m|^(.+)/[^/]+$|) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 60 | ▶ | ($self->{'ADD_LOCAL_PATH'} < 0) ? push(@paths, $1) : unshift(@paths, $1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 539 | foreach my $path (@paths) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 580 | ▶ | return "$path/$file" if -e "$path/$file"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 51 | $self->throw('file', "$file: not found"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 542 | ▶ | sub include_paths { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
include_paths: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 542 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 542 | ▶ | return $self->{'INCLUDE_PATHS'} ||= do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"INCLUDE_PATHS"} ||= do {
my $paths = $self->{"INCLUDE_PATH"} || ["."];
$paths = &$paths() if UNIVERSAL::isa($paths, "CODE");
$paths = $self->split_paths($paths) unless UNIVERSAL::isa($paths, "ARRAY");
$paths
}
MC/DC0%0/2
$self->{"INCLUDE_PATHS"} ||= do {
my $paths = $self->{"INCLUDE_PATH"} || ["."];
$paths = &$paths() if UNIVERSAL::isa($paths, "CODE");
$paths = $self->split_paths($paths) unless UNIVERSAL::isa($paths, "ARRAY");
$paths
}
$self->{"INCLUDE_PATHS"}
do {
my $paths = $self->{"INCLUDE_PATH"} || ["."];
$paths = &$paths() if UNIVERSAL::isa($paths, "CODE");
$paths = $self->split_paths($paths) unless UNIVERSAL::isa($paths, "ARRAY");
$paths
}
Truth table66%2/3
A ||= B
A= $self->{"INCLUDE_PATHS"}B= do {
my $paths = $self->{"INCLUDE_PATH"} || ["."];
$paths = &$paths() if UNIVERSAL::isa($paths, "CODE");
$paths = $self->split_paths($paths) unless UNIVERSAL::isa($paths, "ARRAY");
$paths
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | # TT does this everytime a file is looked up - we are going to do it just in time - the first time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 410 | ▶ | my $paths = $self->{'INCLUDE_PATH'} || ['.']; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'INCLUDE_PATH'} || ['.']
MC/DC100%1/1
$self->{'INCLUDE_PATH'} || ['.']
$self->{'INCLUDE_PATH'}
Truth table100%2/2
A
A= $self->{'INCLUDE_PATH'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 410 | ▶ | $paths = $paths->() if UNIVERSAL::isa($paths, 'CODE'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 410 | ▶ | $paths = $self->split_paths($paths) if ! UNIVERSAL::isa($paths, 'ARRAY'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 410 | $paths; # return of the do | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 548 | ▶ | sub split_paths { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
split_paths: called CC=5 SCAR=17.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 548 | my ($self, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 548 | ▶ | return $path if UNIVERSAL::isa($path, 'ARRAY'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 521 | ▶ | my $delim = $self->{'DELIMITER'} || ':'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'DELIMITER'} || ':'
MC/DC0%0/1
$self->{'DELIMITER'} || ':'
$self->{'DELIMITER'}
Truth table50%1/2
A
A= $self->{'DELIMITER'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 521 | ▶ | $delim = ($delim eq ':' && $^O eq 'MSWin32') ? qr|:(?!/)| : qr|\Q$delim\E|; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$delim eq ":" and $^O eq "MSWin32"
MC/DC0%0/2
$delim eq ":" and $^O eq "MSWin32"
$delim eq ":"
$^O eq "MSWin32"
Truth table33%1/3
A and B
A= $delim eq ":"B= $^O eq "MSWin32"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 521 | return [split $delim, "$path"]; # allow objects to stringify as necessary | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 490 | ▶ | sub slurp { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
slurp: called CC=5 SCAR=17.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 490 | my ($self, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 490 | ▶ | open(my $fh, '<', $file) || $self->throw('file', "$file couldn't be opened: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 490 | read $fh, my $txt, -s $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 490 | ▶ | if ($self->{'ENCODING'}) { # thanks to Carl Franks for this addition | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 3 | eval { require Encode }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 3 | ▶ | if ($@ || ! defined &Encode::decode) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$@ or not defined &Encode::decode
MC/DC0%0/2
$@ or not defined &Encode::decode
$@
not defined &Encode::decode
Truth table33%1/3
A or not(B)
A= $@B= not defined &Encode::decode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | warn "Encode module not found, 'ENCODING' config only available on perl >= 5.7.3\n$@"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 3 | $txt = Encode::decode($self->{'ENCODING'}, $txt); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 490 | return \$txt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 38 | ▶ | sub error { shift->{'error'} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 487 | ▶ | sub exception { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exception: called CC=8 SCAR=22.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 487 | my $self_or_class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 487 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 487 | my $info = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 487 | ▶ | return $type if UNIVERSAL::can($type, 'type'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 474 | ▶ | if (ref($info) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 100 | ▶ | my $hash = ref($info->[-1]) eq 'HASH' ? pop(@$info) : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 100 | ▶ | if (@$info >= 2 || scalar keys %$hash) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%1/2
@$info >= 2 or scalar keys %$hash
MC/DC0%0/1
@$info >= 2 or scalar keys %$hash
@$info >= 2
Truth table50%1/2
A
A= @$info >= 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | $hash->{$_} = $info->[$_] for 0 .. $#$info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | $hash->{'args'} = $info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | $info = $hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | } elsif (@$info == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 87 | $info = $info->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 13 | $info = $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 13 | $type = 'undef'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 474 | return Template::Alloy::Exception->new($type, $info, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 440 | ▶ | sub throw { die shift->exception(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
throw: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 45 | ▶ | sub context { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
context: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 45 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 45 | require Template::Alloy::Context; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 45 | return Template::Alloy::Context->new({_template => $self}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 257 | ▶ | sub iterator { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
iterator: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 257 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 257 | require Template::Alloy::Iterator; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 257 | Template::Alloy::Iterator->new(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 614 | ▶ | sub undefined_get { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
undefined_get: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 614 | my ($self, $ident, $node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 614 | ▶ | return $self->{'UNDEFINED_GET'}->($self, $ident, $node) if $self->{'UNDEFINED_GET'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 614 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 739 | ▶ | sub undefined_any { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
undefined_any: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 739 | my ($self, $ident) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 739 | ▶ | return $self->{'UNDEFINED_ANY'}->($self, $ident) if $self->{'UNDEFINED_ANY'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 739 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 27 | ▶ | sub strict_throw { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
strict_throw: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 27 | my ($self, $ident) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 27 | my $v = $self->tt_var_string($ident); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 27 | my $temp = $self->{'_template'}->{'name'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 27 | my $comp = $self->{'_component'}->{'name'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 27 | ▶ | my $msg = "undefined variable: $v in $comp".($comp ne $temp ? " while processing $temp" : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 27 | ▶ | return $self->{'STRICT_THROW'}->($self, 'var.undef', $msg, {name => $v, component => $comp, template => $temp, ident => $ident}) if $self->{'STRICT_THROW'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 21 | $self->throw('var.undef', $msg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 9 | ▶ | sub list_filters { shift->{'_filters'} ||= eval { require Template::Filters; $Template::Filters::FILTERS } || {} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_filters: called CC=3 SCAR=12.5
Pod
documented
Condition40%2/5
+(shift())->{"_filters"} ||= eval {
do {
require Template::Filters;
$Template::Filters::FILTERS
}
} || {}
eval {
do {
require Template::Filters;
$Template::Filters::FILTERS
}
} || {}
MC/DC0%0/2
+(shift())->{"_filters"} ||= eval {
do {
require Template::Filters;
$Template::Filters::FILTERS
}
} || {}
+(shift())->{"_filters"}
eval {
do {
require Template::Filters;
$Template::Filters::FILTERS
}
}
Truth table33%1/3
A ||= B
A= +(shift())->{"_filters"}B= eval {
do {
require Template::Filters;
$Template::Filters::FILTERS
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 16 | ▶ | sub debug_node { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug_node: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 16 | my ($self, $node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 16 | my $info = $self->node_info($node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 16 | ▶ | my $format = $self->{'_debug_format'} || $self->{'DEBUG_FORMAT'} || "\n## \$file line \$line : [% \$text %] ##\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%5/5
$self->{'_debug_format'} || $self->{'DEBUG_FORMAT'} || "\n## \$file line \$line : [% \$text %] ##\n"
$self->{"_debug_format"} or $self->{"DEBUG_FORMAT"}
MC/DC100%2/2
$self->{'_debug_format'} || $self->{'DEBUG_FORMAT'} || "\n## \$file line \$line : [% \$text %] ##\n"
$self->{"_debug_format"}
$self->{"DEBUG_FORMAT"}
Truth table100%3/3
A or B
A= $self->{"_debug_format"}B= $self->{"DEBUG_FORMAT"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 16 | $format =~ s{\$(file|line|text)}{$info->{$1}}g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 16 | return $format; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 102 | ▶ | sub node_info { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
node_info: called CC=5 SCAR=16.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 102 | my ($self, $node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 102 | my $doc = $self->{'_component'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 102 | my $i = $node->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 102 | ▶ | my $j = $node->[2] || return ''; # META can be 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$node->[2] || (return '')
MC/DC0%0/1
$node->[2] || (return '')
$node->[2]
Truth table50%1/2
A
A= $node->[2]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | file => $doc->{'name'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | line => 'unknown', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | text => 'unknown', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 102 | ▶ | } if !$doc->{'_filename'} && !$doc->{'_content'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$doc->{"_filename"} or $doc->{"_content"}
MC/DC0%0/2
$doc->{"_filename"} or $doc->{"_content"}
$doc->{"_filename"}
$doc->{"_content"}
Truth table33%1/3
A or B
A= $doc->{"_filename"}B= $doc->{"_content"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 102 | ▶ | $doc->{'_content'} ||= $self->slurp($doc->{'_filename'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$doc->{"_content"} ||= $self->slurp($doc->{"_filename"})
MC/DC0%0/2
$doc->{"_content"} ||= $self->slurp($doc->{"_filename"})
$doc->{"_content"}
$self->slurp($doc->{"_filename"})
Truth table66%2/3
A ||= B
A= $doc->{"_content"}B= $self->slurp($doc->{"_filename"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 102 | my $s = substr(${ $doc->{'_content'} }, $i, $j - $i); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 102 | $s =~ s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 102 | $s =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 102 | file => $doc->{'name'}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | line => $self->get_line_number_by_index($doc, $i), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | text => $s, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 3500 | ▶ | sub get_line_number_by_index { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_line_number_by_index: called CC=12 SCAR=25.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 3500 | my ($self, $doc, $index, $include_char) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 3500 | ▶ | if (! $index || $index <= 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $index or $index <= 0
MC/DC0%0/2
not $index or $index <= 0
not $index
$index <= 0
Truth table33%1/3
not(A) or B
A= not $indexB= $index <= 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | ▶ | return $include_char ? (1, 1) : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 3500 | ▶ | my $lines = $doc->{'_line_offsets'} ||= do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$doc->{"_line_offsets"} ||= do {
$doc->{"_content"} ||= $self->slurp($doc->{"_filename"});
my $i = 0;
my(@lines) = 0;
while (1) {
$i = index(${$doc->{"_content"};}, "\n", $i) + 1;
last if $i == 0;
push @lines, $i;
};
\@lines
}
MC/DC0%0/2
$doc->{"_line_offsets"} ||= do {
$doc->{"_content"} ||= $self->slurp($doc->{"_filename"});
my $i = 0;
my(@lines) = 0;
while (1) {
$i = index(${$doc->{"_content"};}, "\n", $i) + 1;
last if $i == 0;
push @lines, $i;
};
\@lines
}
$doc->{"_line_offsets"}
do {
$doc->{"_content"} ||= $self->slurp($doc->{"_filename"});
my $i = 0;
my(@lines) = 0;
while (1) {
$i = index(${$doc->{"_content"};}, "\n", $i) + 1;
last if $i == 0;
push @lines, $i;
};
\@lines
}
Truth table66%2/3
A ||= B
A= $doc->{"_line_offsets"}B= do {
$doc->{"_content"} ||= $self->slurp($doc->{"_filename"});
my $i = 0;
my(@lines) = 0;
while (1) {
$i = index(${$doc->{"_content"};}, "\n", $i) + 1;
last if $i == 0;
push @lines, $i;
};
\@lines
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 1628 | ▶ | $doc->{'_content'} ||= $self->slurp($doc->{'_filename'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$doc->{"_content"} ||= $self->slurp($doc->{"_filename"})
MC/DC0%0/2
$doc->{"_content"} ||= $self->slurp($doc->{"_filename"})
$doc->{"_content"}
$self->slurp($doc->{"_filename"})
Truth table33%1/3
A ||= B
A= $doc->{"_content"}B= $self->slurp($doc->{"_filename"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 1628 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 1628 | my @lines = (0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 1628 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 1780 | $i = index(${ $doc->{'_content'} }, "\n", $i) + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 1780 | ▶ | last if $i == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 152 | push @lines, $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 1628 | \@lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | ### binary search them (this is fast even on big docs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 3500 | my ($i, $j) = (0, $#$lines); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 3500 | ▶ | if ($index > $lines->[-1]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 3282 | $i = $j; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 218 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 620 | ▶ | last if abs($i - $j) <= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 402 | my $k = int(($i + $j) / 2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 402 | ▶ | $j = $k if $lines->[$k] >= $index; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 402 | ▶ | $i = $k if $lines->[$k] <= $index; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 3500 | ▶ | return $include_char ? ($i + 1, $index - $lines->[$i]) : $i + 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 31014 | ▶ | sub ast_string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ast_string: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 31014 | my ($self, $var) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 31014 | ▶ | return 'undef' if ! defined $var; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 29157 | ▶ | return '['.join(', ', map { $self->ast_string($_) } @$var).']' if ref $var; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 20265 | ▶ | return $var if $var =~ /^(-?[1-9]\d{0,13}|0)$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 11098 | $var =~ s/([\'\\])/\\$1/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 11098 | return "'$var'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 36 | ▶ | sub tt_var_string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tt_var_string: called CC=7 SCAR=19.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 36 | my ($self, $ident) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 36 | ▶ | if (! ref $ident) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 3 | ▶ | return $ident if $ident eq '0' || $ident =~ /^[1-9]\d{0,12}$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ident eq 0 or $ident =~ /^[1-9]\d{0,12}$/
MC/DC0%0/2
$ident eq 0 or $ident =~ /^[1-9]\d{0,12}$/
$ident eq 0
$ident =~ /^[1-9]\d{0,12}$/
Truth table33%1/3
A or B
A= $ident eq 0B= $ident =~ /^[1-9]\d{0,12}$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 0 | $ident =~ s/\'/\\\'/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 0 | return "'$ident'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 33 | my $v = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 33 | ▶ | for (my $i = 0; $i < @$ident; ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 51 | $v .= $ident->[$i++]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 51 | ▶ | $v .= '('.join(',',map{$self->tt_var_string($_)} @{$ident->[$i-1]}).')' if $ident->[$i++]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 51 | ▶ | $v .= $ident->[$i++] if $i < @$ident; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 33 | return $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 223 | ▶ | sub item_method_eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
item_method_eval: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 223 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 223 | ▶ | my $text = shift; return '' if ! defined $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 223 | ▶ | my $args = shift || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || {}
MC/DC100%1/1
shift() || {}
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 223 | ▶ | local $self->{'_eval_recurse'} = $self->{'_eval_recurse'} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'_eval_recurse'} || 0
MC/DC100%1/1
$self->{'_eval_recurse'} || 0
$self->{'_eval_recurse'}
Truth table100%2/2
A
A= $self->{'_eval_recurse'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | $self->throw('eval_recurse', "MAX_EVAL_RECURSE $Template::Alloy::MAX_EVAL_RECURSE reached") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 223 | ▶ | if ++$self->{'_eval_recurse'} > ($self->{'MAX_EVAL_RECURSE'} || $MAX_EVAL_RECURSE); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{'MAX_EVAL_RECURSE'} || $Template::Alloy::MAX_EVAL_RECURSE
MC/DC0%0/2
$self->{'MAX_EVAL_RECURSE'} || $Template::Alloy::MAX_EVAL_RECURSE
$self->{'MAX_EVAL_RECURSE'}
$Template::Alloy::MAX_EVAL_RECURSE
Truth table66%2/3
A || B
A= $self->{'MAX_EVAL_RECURSE'}B= $Template::Alloy::MAX_EVAL_RECURSE
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 193 | my %ARGS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 193 | @ARGS{ map {uc} keys %$args } = values %$args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 193 | delete @ARGS{ grep {! $Template::Alloy::EVAL_CONFIG->{$_}} keys %ARGS }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 193 | ▶ | $self->throw("eval_strict", "Cannot disable STRICT once it is enabled") if exists $ARGS{'STRICT'} && ! $ARGS{'STRICT'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $ARGS{"STRICT"} and not $ARGS{"STRICT"}
MC/DC100%2/2
exists $ARGS{"STRICT"} and not $ARGS{"STRICT"}
exists $ARGS{"STRICT"}
not $ARGS{"STRICT"}
Truth table100%3/3
A and not(B)
A= exists $ARGS{"STRICT"}B= not $ARGS{"STRICT"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 190 | local @$self{ keys %ARGS } = values %ARGS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 190 | my $out = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 190 | ▶ | $self->process_simple(\$text, $self->_vars, \$out) || $self->throw($self->error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 179 | return $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 10 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | ### See the perldoc in Template/Alloy.pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||