| 1 | package Text::Handlebars::Compiler; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 13 | our $AUTHORITY = 'cpan:DOY'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 13 | $Text::Handlebars::Compiler::VERSION = '0.05'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 13 | ▶ | use Mouse; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 13 | extends 'Text::Xslate::Compiler'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 13 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 13 | has '+syntax' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | default => 'Handlebars', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 162 | ▶ | sub define_helper { shift->parser->define_helper(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
define_helper: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 70 | ▶ | sub _generate_block_body { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_block_body: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 70 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 70 | my ($node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 70 | my @compiled = map { $self->compile_ast($_) } @{ $node->second }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 70 | ▶ | unshift @compiled, $self->_localize_vars($node->first) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | if $node->first; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 70 | return @compiled; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 685 | ▶ | sub _generate_key { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_key: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 685 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 685 | my ($node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 685 | my $var = $node->clone(arity => 'variable'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 685 | return $self->compile_ast($self->check_lambda($var)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 66 | ▶ | sub _generate_key_field { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_key_field: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 66 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 66 | my ($node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 66 | my $field = $node->clone(arity => 'field'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 66 | return $self->compile_ast($self->check_lambda($field)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1683 | ▶ | sub _generate_call { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_call: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 1683 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 1683 | my ($node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 1683 | ▶ | if ($node->is_helper) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 42 | my @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | my @hash; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 42 | for my $arg (@{ $node->second }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 43 | ▶ | if ($arg->arity eq 'pair') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 4 | push @hash, $arg->first, $arg->second; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 39 | push @args, $arg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 42 | my $hash = $self->make_hash(@hash); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 42 | unshift @args, $self->vars; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 42 | ▶ | if ($node->is_block_helper) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 34 | push @{ $node->first->second }, $hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 34 | $node->second(\@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 8 | $node->second([ @args, $hash ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 1683 | return $self->SUPER::_generate_call($node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 3 | ▶ | sub _generate_partial { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_partial: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 3 | my ($node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 3 | my $file = $node->first; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 3 | ▶ | if (ref($file) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 3 | $file = $node->clone( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | arity => 'binary', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | id => '~', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | first => $file->[0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | second => $node->clone(arity => 'suffix'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 3 | my $args = $node->second; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 3 | ▶ | if ($args) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | $args = [ $self->new_vars($args) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 3 | $self->compile_ast( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | $self->make_ternary( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | $self->find_file($file->clone), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | $node->clone( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | arity => 'include', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | id => 'include', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | first => $file->clone, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | second => $args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | $self->literal(''), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 6 | ▶ | sub _generate_suffix { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_suffix: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 6 | my ($node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 6 | $self->opcode('suffix'), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 3 | ▶ | sub find_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_file: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 3 | my ($filename) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 3 | return $filename->clone( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | arity => 'unary', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | id => 'find_file', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | first => $filename, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 35 | ▶ | sub _generate_for { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_for: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 35 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 35 | my ($node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 35 | my @opcodes = $self->SUPER::_generate_for(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 35 | @opcodes, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | $self->opcode('nil'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 69 | ▶ | sub _generate_block { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_block: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 69 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 69 | my ($node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 69 | my $name = $node->first; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 69 | my %block = %{ $node->second }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 69 | ▶ | if ($name->arity eq 'call') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | return $self->compile_ast( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | $name->clone( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | first => $self->call( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | $node, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | '(make_block_helper)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | $self->vars, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | $name->first, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | $block{if}{raw_text}->clone, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | ($block{else} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | ? $block{else}{raw_text}->clone | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 34 | ▶ | : $self->literal('')), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | is_block_helper => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 35 | my $iterations = $self->make_ternary( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | $self->is_falsy($name->clone), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | $self->make_array($self->literal(1)), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | $self->make_ternary( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | $self->is_array_ref($name->clone), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | $name->clone, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | $self->make_array($self->literal(1)), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 35 | my $loop_var = $self->parser->symbol('(loop_var)')->clone(arity => 'variable'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | my $body_block = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | $self->make_ternary( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | $self->is_falsy($name->clone), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | $name->clone( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | arity => 'block_body', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | first => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | second => [ $block{else}{body} ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | $name->clone( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | arity => 'block_body', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | first => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | $self->new_vars($name->clone, $self->iterator_index), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 35 | second => [ $block{if}{body} ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 35 | my $var = $name->clone(arity => 'variable'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | return $self->compile_ast( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | $self->make_ternary( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | $self->is_code_ref($var->clone), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | $self->run_code( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | $var->clone, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | $block{if}{raw_text}->clone, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | $block{if}{open_tag}->clone, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | $block{if}{close_tag}->clone, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 35 | ), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | $self->parser->symbol('(for)')->clone( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | arity => 'for', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | first => $iterations, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | second => [$loop_var], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | third => $body_block, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 1071 | ▶ | sub _generate_unary { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_unary: called CC=6 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 1071 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 1071 | my ($node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | # XXX copied from Text::Xslate::Compiler because it uses a hardcoded list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | # of unary ops | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 1071 | ▶ | if ($self->is_unary($node->id)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 1001 | my @code = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | $self->compile_ast($node->first), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | $self->opcode($node->id) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | # render_string can't be constant folded, because it depends on the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | # current vars | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 1001 | ▶ | if ($Text::Xslate::Compiler::OPTIMIZE and $self->_code_is_literal(@code) && $node->id ne 'render_string' && $node->id ne 'find_file') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
$Text::Xslate::Compiler::OPTIMIZE and ($self->_code_is_literal(@code) and $node->id ne "render_string" and $node->id ne "find_file")
$self->_code_is_literal(@code) and $node->id ne "render_string" and $node->id ne "find_file"
$self->_code_is_literal(@code) and $node->id ne "render_string"
MC/DC0%0/4
$Text::Xslate::Compiler::OPTIMIZE and ($self->_code_is_literal(@code) and $node->id ne "render_string" and $node->id ne "find_file")
$Text::Xslate::Compiler::OPTIMIZE
$self->_code_is_literal(@code)
$node->id ne "render_string"
$node->id ne "find_file"
Truth table20%1/5
A and B and C and D
A= $Text::Xslate::Compiler::OPTIMIZEB= $self->_code_is_literal(@code)C= $node->id ne "render_string"D= $node->id ne "find_file"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | $self->_fold_constants(\@code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 1001 | return @code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 70 | return $self->SUPER::_generate_unary(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 1071 | ▶ | sub is_unary { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_unary: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 1071 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 1071 | my ($id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | my %unary = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 1071 | map { $_ => 1 } qw(builtin_is_array_ref builtin_is_hash_ref is_code_ref | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | find_file) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 1071 | return $unary{$id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 70 | ▶ | sub _generate_array_length { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_array_length: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 70 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 70 | my ($node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 70 | my $max_index = $self->parser->symbol('(max_index)')->clone( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | id => 'max_index', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | arity => 'unary', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | first => $node->first, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 70 | $self->compile_ast($max_index), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | $self->opcode('move_to_sb'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | $self->opcode('literal', 1), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | $self->opcode('add'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 786 | ▶ | sub _generate_run_code { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_run_code: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 786 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 786 | my ($node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 786 | my $to_render = $node->clone(arity => 'call'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 786 | ▶ | if ($node->third) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 35 | my ($open_tag, $close_tag) = @{ $node->third }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 35 | $to_render = $self->make_ternary( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | $self->parser->symbol('==')->clone( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | arity => 'binary', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | first => $close_tag->clone, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | second => $self->literal('}}'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | $to_render, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | $self->join('{{= ', $open_tag, ' ', $close_tag, ' =}}', $to_render) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | # XXX turn this into an opcode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 786 | my $render_string = $self->call( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | $node, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | '(render_string)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | $to_render, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | $self->vars, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 786 | return $self->compile_ast($render_string); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 36 | ▶ | sub _generate_new_vars { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_new_vars: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 36 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 36 | my ($node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 36 | my ($vars, $value, $i) = ($node->first, $node->second, $node->third); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 36 | my $lvar_id = $self->lvar_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 36 | local $self->{lvar_id} = $self->lvar_use(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 36 | my @code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 36 | push @code, $self->compile_ast($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 36 | push @code, $self->opcode('save_to_lvar', $lvar_id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 36 | my $lvar_value = $value->clone(arity => 'lvar', id => $lvar_id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 36 | ▶ | if ($i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 35 | my $value_at_index = $value->clone( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | arity => 'field', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | first => $value->clone, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | second => $i->clone, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 35 | push @code, $self->compile_ast( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | $self->make_ternary( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | $self->is_array_ref($lvar_value->clone), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | $self->save_lvar( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | $lvar_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | $self->make_ternary( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | $self->is_hash_ref($value_at_index->clone), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | $self->merge_hash( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | $self->make_hash( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | $self->literal('.'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | $value_at_index->clone, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | $value_at_index->clone, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | $self->make_hash( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | $self->literal('.'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | $value_at_index->clone, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 1 | push @code, $self->compile_ast( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | $self->make_ternary( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | $self->is_array_ref($lvar_value->clone), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | $self->save_lvar( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | $lvar_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | $self->make_hash( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | $self->literal('.'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | $value->clone, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 36 | ▶ | push @code, $self->compile_ast( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | $self->save_lvar( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | $lvar_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | $self->make_ternary( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | $self->is_hash_ref($lvar_value->clone), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | $self->merge_hash( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | ($i | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | ? ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | $self->make_hash( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | $self->literal('@index'), $i->clone | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | $vars->clone, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | $lvar_value->clone, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | $self->make_hash( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | $self->literal('..'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | $vars->clone, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | $vars->clone, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 36 | push @code, $self->opcode('load_lvar', $lvar_id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 36 | return @code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 108 | ▶ | sub _generate_lvar { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_lvar: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 108 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 108 | my ($node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 108 | $self->opcode('load_lvar', $node->id), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 72 | ▶ | sub _generate_save_lvar { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_save_lvar: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 72 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 72 | my ($node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 72 | $self->compile_ast($node->first), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | $self->opcode('save_to_lvar', $node->id), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 142 | ▶ | sub _generate_merge_hash { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_merge_hash: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 142 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 142 | my ($node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 142 | my $lvar_id = $self->lvar_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 142 | local $self->{lvar_id} = $self->lvar_use(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 142 | $self->compile_ast($node->first), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | $self->opcode('save_to_lvar', $lvar_id), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | $self->compile_ast($node->second), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | $self->opcode('move_to_sb'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | $self->opcode('load_lvar', $lvar_id), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | $self->opcode('merge_hash'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 35 | ▶ | sub join { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
join: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 35 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 35 | my (@args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 35 | @args = map { $self->literalize($_) } @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 35 | my $joined = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 35 | for my $arg (@args) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 175 | $joined = $self->parser->symbol('~')->clone( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | arity => 'binary', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | first => $joined, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | second => $arg, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 35 | return $joined; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 210 | ▶ | sub literalize { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
literalize: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 210 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 210 | my ($val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 210 | ▶ | return $val->clone if blessed($val); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 105 | return $self->literal($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 820 | ▶ | sub call { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
call: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 820 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 820 | my ($node, $name, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 820 | my $code = $self->parser->symbol('(name)')->clone( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | arity => 'name', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | id => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | line => $node->line, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 820 | return $self->parser->call($code, @args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 1106 | ▶ | sub make_ternary { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_ternary: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 1106 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 1106 | my ($if, $then, $else) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 1106 | return $self->parser->symbol('?:')->clone( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | arity => 'if', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | first => $if, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | second => $then, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | third => $else, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 898 | ▶ | sub vars { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vars: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 898 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 898 | return $self->parser->symbol('(vars)')->clone(arity => 'vars'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 35 | ▶ | sub iterator_index { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
iterator_index: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 35 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 35 | return $self->parser->symbol('(iterator)')->clone( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | arity => 'iterator', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | id => '$~(loop_var)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | first => $self->parser->symbol('(loop_var)')->clone, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 751 | ▶ | sub check_lambda { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_lambda: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 751 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 751 | my ($var) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 751 | return $self->make_ternary( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | $self->is_code_ref($var->clone), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | $self->run_code($var->clone), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | $var, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 141 | ▶ | sub is_array_ref { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_array_ref: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 141 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 141 | my ($var) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 141 | return $self->parser->symbol('(is_array_ref)')->clone( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | id => 'builtin_is_array_ref', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | arity => 'unary', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | first => $var, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 71 | ▶ | sub is_hash_ref { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_hash_ref: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 71 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 71 | my ($var) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 71 | return $self->parser->symbol('(is_hash_ref)')->clone( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | id => 'builtin_is_hash_ref', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | arity => 'unary', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | first => $var, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 786 | ▶ | sub is_code_ref { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_code_ref: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 786 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 786 | my ($var) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 786 | return $self->parser->symbol('(is_code_ref)')->clone( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | id => 'is_code_ref', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | arity => 'unary', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | first => $var, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 70 | ▶ | sub make_array { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_array: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 70 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 70 | my (@contents) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 70 | return $self->parser->symbol('[')->clone( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | arity => 'composer', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | first => \@contents, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 184 | ▶ | sub make_hash { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_hash: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 184 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 184 | my (@contents) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 184 | return $self->parser->symbol('{')->clone( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | arity => 'composer', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | first => \@contents, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 70 | ▶ | sub is_falsy { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_falsy: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 70 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 70 | my ($node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 70 | return $self->not( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | $self->make_ternary( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | $self->is_array_ref($node->clone), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | $self->array_length($node->clone), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | $node | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 70 | ▶ | sub not { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
not: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 70 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 70 | my ($node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 70 | return $self->parser->symbol('!')->clone( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | arity => 'unary', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | first => $node, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 70 | ▶ | sub array_length { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
array_length: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 70 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 70 | my ($node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 70 | return $self->parser->symbol('(array_length)')->clone( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | arity => 'array_length', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | first => $node, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 786 | ▶ | sub run_code { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_code: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 786 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 786 | my ($code, $raw_text, $open_tag, $close_tag) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 786 | ▶ | return $self->parser->symbol('(run_code)')->clone( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | arity => 'run_code', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | first => $code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | (@_ > 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | ? (second => [ $raw_text ], third => [ $open_tag, $close_tag ]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | : (second => [])), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 36 | ▶ | sub new_vars { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_vars: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 36 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 36 | my ($value, $i) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 36 | return $value->clone( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | arity => 'new_vars', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | first => $self->vars, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | second => $value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | third => $i, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 72 | ▶ | sub save_lvar { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
save_lvar: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 72 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 72 | my ($id, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 72 | return $value->clone( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | arity => 'save_lvar', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | id => $id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | first => $value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 71 | ▶ | sub merge_hash { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge_hash: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 71 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 71 | my (@hashes) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 71 | my $merged = shift @hashes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 71 | for my $hash (@hashes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 142 | $merged = $self->merge_single_hash($merged, $hash); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 71 | return $merged; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 142 | ▶ | sub merge_single_hash { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge_single_hash: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 142 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 142 | my ($left, $right) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 142 | return $left->clone( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | arity => 'merge_hash', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | first => $left, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | second => $right, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 382 | ▶ | sub literal { shift->parser->literal(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
literal: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 13 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 13 | ▶ | no Mouse; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | =for Pod::Coverage | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | define_helper | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | find_file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | is_unary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | join | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | literalize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | make_ternary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | vars | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | iterator_index | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | check_lambda | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | is_array_ref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | is_hash_ref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | is_code_ref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | make_array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | make_hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | is_falsy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | array_length | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | run_code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | new_vars | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | save_lvar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | merge_hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | merge_single_hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | literal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 13 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||