blib/lib/Text/Xslate/PP/Opcode.pm

filter: Statementstmt 99.7% 333 / 334 Branchbran 93.1% 41 / 44 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 87 / 87 Podpod 0.0% 0 / 75 totaltotal 85.4% 464 / 543 CC 25 SCAR 5.9
CC
25
Cov
99%
tx_macro_enter
7.0
tx_funcall
4.0
op_for_iter
4.0
CRAP 1.8
« blib/lib/Text/Xslate/HashWithDefault.pm ↑ Summary blib/lib/Text/Xslate/Symbol.pm »
1 package Text::Xslate::PP::Opcode;
2 190 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 190 extends qw(Text::Xslate::PP::State);
4  
5 190 ▶use version; our $VERSION = version->declare('v3.5.9');
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 190 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 190 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 190 ▶use Text::Xslate::PP;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 190 ▶use Text::Xslate::PP::Const;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 190 ▶use Text::Xslate::PP::Method;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 190 ▶use Text::Xslate::Util qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
14 p neat
15 mark_raw unmark_raw html_escape uri_escape
16 $DEBUG
17 190 );
18  
19 190 ▶use constant _DUMP_PP => scalar($DEBUG =~ /\b dump=pp \b/xms);
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 190 ▶no warnings 'recursion';
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 190 if(!Text::Xslate::PP::_PP_ERROR_VERBOSE()) {
24 190 our @CARP_NOT = qw(
25 Text::Xslate
26 );
27 }
28 190 our $_current_frame;
29  
30  
31 #
32 #
33 #
34  
35 8538 ▶sub op_noop {
Subroutine op_noop: called CC=1 SCAR=0.0
Pod undocumented
36 8538 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
37 }
38  
39  
40 1802 ▶sub op_move_to_sb {
Subroutine op_move_to_sb: called CC=1 SCAR=0.0
Pod undocumented
41 1802 $_[0]->{sb} = $_[0]->{sa};
42 1802 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
43 }
44  
45 66 ▶sub op_move_from_sb {
Subroutine op_move_from_sb: called CC=1 SCAR=0.0
Pod undocumented
46 66 $_[0]->{sa} = $_[0]->{sb};
47 66 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
48 }
49  
50 557 ▶sub op_save_to_lvar {
Subroutine op_save_to_lvar: called CC=1 SCAR=0.0
Pod undocumented
51 557 tx_access_lvar( $_[0], $_[0]->op_arg, $_[0]->{sa} );
52 557 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
53 }
54  
55 2311 ▶sub op_load_lvar {
Subroutine op_load_lvar: called CC=1 SCAR=0.0
Pod undocumented
56 2311 $_[0]->{sa} = tx_access_lvar( $_[0], $_[0]->op_arg );
57 2311 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
58 }
59  
60 272 ▶sub op_load_lvar_to_sb {
Subroutine op_load_lvar_to_sb: called CC=1 SCAR=0.0
Pod undocumented
61 272 $_[0]->{sb} = tx_access_lvar( $_[0], $_[0]->op_arg );
62 272 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
63 }
64  
65 39 ▶sub op_localize_s {
Subroutine op_localize_s: called CC=1 SCAR=0.0
Pod undocumented
66 39 my($st) = @_;
67 39 my $key = $st->op_arg;
68 39 my $newval = $st->{sa};
69 39 $st->localize($key, $newval);
70  
71 39 goto $st->{ code }->[ ++$st->{ pc } ]->{ exec_code };
72 }
73  
74 9 ▶sub op_localize_vars {
Subroutine op_localize_vars: called CC=2 SCAR=6.9
Pod undocumented
75 9 my($st) = @_;
76 9 my $new_vars = $st->{sa};
77 9 my $old_vars = $st->vars;
78  
79 9 ▶ if(ref($new_vars) ne 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $new_vars ne "HASH") 1 8 9
80 1 $st->warn(undef, "Variable map must be a HASH reference");
81 }
82  
83 8 ▶ push @{ $st->{local_stack} }, bless sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
84 8 $st->vars($old_vars);
85 8 return;
86 8 }, 'Text::Xslate::PP::Guard';
87  
88 8 $st->vars($new_vars);
89  
90 8 goto $st->{ code }->[ ++$st->{ pc } ]->{ exec_code };
91 }
92  
93 6082 ▶sub op_push {
Subroutine op_push: called CC=1 SCAR=0.0
Pod undocumented
94 6082 push @{ $_[0]->{ SP }->[ -1 ] }, $_[0]->{sa};
95 6082 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
96 }
97  
98  
99 1313 ▶sub op_pushmark {
Subroutine op_pushmark: called CC=1 SCAR=0.0
Pod undocumented
100 1313 push @{ $_[0]->{ SP } }, [];
101 1313 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
102 }
103  
104  
105 173 ▶sub op_nil {
Subroutine op_nil: called CC=1 SCAR=0.0
Pod undocumented
106 173 $_[0]->{sa} = undef;
107 173 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
108 }
109  
110 6 ▶sub op_vars {
Subroutine op_vars: called CC=1 SCAR=0.0
Pod undocumented
111 6 $_[0]->{sa} = $_[0]->{vars};
112  
113 6 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
114 }
115  
116 6489 ▶sub op_literal {
Subroutine op_literal: called CC=1 SCAR=0.0
Pod undocumented
117 6489 $_[0]->{sa} = $_[0]->op_arg;
118 6489 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
119 }
120  
121  
122 299784 ▶sub op_literal_i {
Subroutine op_literal_i: called CC=1 SCAR=0.0
Pod undocumented
123 299784 $_[0]->{sa} = $_[0]->op_arg;
124 299784 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
125 }
126  
127  
128 3420 ▶sub op_fetch_s {
Subroutine op_fetch_s: called CC=1 SCAR=0.0
Pod undocumented
129 3420 $_[0]->{sa} = $_[0]->{vars}->{ $_[0]->op_arg };
130 3420 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
131 }
132  
133 75 ▶sub op_fetch_field {
Subroutine op_fetch_field: called CC=1 SCAR=0.0
Pod undocumented
134 75 my($st) = @_;
135 75 my $var = $st->{sb};
136 75 my $key = $st->{sa};
137 75 $st->{sa} = $st->fetch($var, $key);
138 75 goto $st->{ code }->[ ++$st->{ pc } ]->{ exec_code };
139 }
140  
141  
142 1094 ▶sub op_fetch_field_s {
Subroutine op_fetch_field_s: called CC=1 SCAR=0.0
Pod undocumented
143 1094 my($st) = @_;
144 1094 my $var = $st->{sa};
145 1094 my $key = $st->op_arg;
146 1094 $st->{sa} = $st->fetch($var, $key);
147 1094 goto $st->{ code }->[ ++$st->{ pc } ]->{ exec_code };
148 }
149  
150  
151 4131 ▶sub op_print {
Subroutine op_print: called CC=1 SCAR=0.0
Pod undocumented
152 4131 my($st) = @_;
153 4131 $st->print($st->{sa});
154 4130 goto $st->{ code }->[ ++$st->{ pc } ]->{ exec_code };
155 }
156  
157  
158 181 ▶sub op_print_raw {
Subroutine op_print_raw: called CC=2 SCAR=6.9
Pod undocumented
159 181 my($st) = @_;
160 181 ▶ if(defined $st->{sa}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $st->{'sa'}) { } 179 2 181
161 179 $st->{ output } .= $st->{sa};
162 }
163 else {
164 2 $st->warn( undef, "Use of nil to print" );
165 }
166 181 goto $st->{ code }->[ ++$st->{ pc } ]->{ exec_code };
167 }
168  
169  
170 7420 ▶sub op_print_raw_s {
Subroutine op_print_raw_s: called CC=1 SCAR=0.0
Pod undocumented
171 7420 $_[0]->{ output } .= $_[0]->op_arg;
172 7420 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
173 }
174  
175  
176 1246 ▶sub op_include {
Subroutine op_include: called CC=1 SCAR=0.0
Pod undocumented
177 1246 my($st) = @_;
178 1246 my $child = Text::Xslate::PP::tx_load_template( $st->engine, $st->{sa}, 1 );
179 1242 $st->push_frame('include', undef);
180 1242 my $output = Text::Xslate::PP::tx_execute( $child, $st->{vars} );
181 837 $st->pop_frame(0);
182 837 $st->{output} .= $output;
183 837 goto $st->{ code }->[ ++$st->{ pc } ]->{ exec_code };
184 }
185  
186 2 ▶sub op_find_file {
Subroutine op_find_file: called CC=1 SCAR=0.0
Pod undocumented
187 2 $_[0]->{sa} = eval { $_[0]->engine->find_file($_[0]->{sa}); 1 };
188 2 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
189 }
190  
191 1 ▶sub op_suffix {
Subroutine op_suffix: called CC=1 SCAR=0.0
Pod undocumented
192 1 $_[0]->{sa} = $_[0]->engine->{suffix};
193 1 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
194 }
195  
196 202 ▶sub op_for_start {
Subroutine op_for_start: called CC=1 SCAR=0.0
Pod undocumented
197 202 my($st) = @_;
198 202 my $id = $st->op_arg;
199 202 my $ar = Text::Xslate::PP::tx_check_itr_ar($st, $st->{sa});
200  
201 #tx_access_lvar( $st, $id + TXfor_ITEM, undef );
202 202 tx_access_lvar( $st, $id + TXfor_ITER, -1 );
203 202 tx_access_lvar( $st, $id + TXfor_ARRAY, $ar );
204  
205 202 goto $st->{ code }->[ ++$st->{ pc } ]->{ exec_code };
206 }
207  
208  
209 981 ▶sub op_for_iter {
Subroutine op_for_iter: called CC=4 SCAR=13.9
Pod undocumented
210 981 my($st) = @_;
211 981 my $id = $st->{sa};
212 981 my $av = tx_access_lvar( $st, $id + TXfor_ARRAY );
213  
214 981 ▶ if(defined $av) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $av) 980 1 981
215 980 my $i = tx_access_lvar( $st, $id + TXfor_ITER );
216 980 ▶ $av = [ $av ] unless ref $av;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $av 0 980 980
217 980 ▶ if ( ++$i < scalar(@{ $av }) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i < scalar @{$av;}) { } 782 198 980
218 782 tx_access_lvar( $st, $id + TXfor_ITEM, $av->[ $i ] );
219 782 tx_access_lvar( $st, $id + TXfor_ITER, $i );
220 782 goto $st->{ code }->[ ++$st->{ pc } ]->{ exec_code };
221 }
222 else {
223 # finish the loop
224 198 $st->{sa} = ( $i > 0 ); # for 'for-else' block
225 198 tx_access_lvar( $st, $id + TXfor_ITEM, undef );
226 198 tx_access_lvar( $st, $id + TXfor_ITER, undef );
227 198 tx_access_lvar( $st, $id + TXfor_ARRAY, undef );
228 }
229 }
230  
231 # finish
232 199 $st->{ pc } = $st->op_arg;
233 199 goto $st->{ code }->[ $st->{ pc } ]->{ exec_code };
234 }
235  
236  
237 513 ▶sub op_add {
Subroutine op_add: called CC=1 SCAR=0.0
Pod undocumented
238 513 $_[0]->{sa} = $_[0]->{sb} + $_[0]->{sa};
239 513 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
240 }
241  
242  
243 28 ▶sub op_sub {
Subroutine op_sub: called CC=1 SCAR=0.0
Pod undocumented
244 28 $_[0]->{sa} = $_[0]->{sb} - $_[0]->{sa};
245 28 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
246 }
247  
248  
249 26 ▶sub op_mul {
Subroutine op_mul: called CC=1 SCAR=0.0
Pod undocumented
250 26 $_[0]->{sa} = $_[0]->{sb} * $_[0]->{sa};
251 26 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
252 }
253  
254  
255 9 ▶sub op_div {
Subroutine op_div: called CC=1 SCAR=0.0
Pod undocumented
256 9 $_[0]->{sa} = $_[0]->{sb} / $_[0]->{sa};
257 9 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
258 }
259  
260  
261 50 ▶sub op_mod {
Subroutine op_mod: called CC=2 SCAR=6.9
Pod undocumented
262 50 my($st) = @_;
263 50 my $lhs = int $st->{sb};
264 50 my $rhs = int $st->{sa};
265 50 ▶ if($rhs == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rhs == 0) { } 1 49 50
266 1 $st->error(undef, "Illegal modulus zero");
267 1 $st->{sa} = 'NaN';
268 }
269 else {
270 49 $st->{sa} = $lhs % $rhs;
271 }
272 50 goto $st->{ code }->[ ++$st->{ pc } ]->{ exec_code };
273 }
274  
275  
276 94 ▶sub op_concat {
Subroutine op_concat: called CC=1 SCAR=0.0
Pod undocumented
277 94 my($st) = @_;
278 94 $st->{sa} = Text::Xslate::PP::tx_concat($st->{sb}, $st->{sa});
279 94 goto $st->{ code }->[ ++$st->{ pc } ]->{ exec_code };
280 }
281  
282 8 ▶sub op_repeat {
Subroutine op_repeat: called CC=1 SCAR=0.0
Pod undocumented
283 8 my($st) = @_;
284 8 $st->{sa} = Text::Xslate::PP::tx_repeat($st->{sb}, $st->{sa});
285 8 goto $st->{ code }->[ ++$st->{ pc } ]->{ exec_code };
286 }
287  
288 4 ▶sub op_bitor {
Subroutine op_bitor: called CC=1 SCAR=0.0
Pod undocumented
289 4 $_[0]->{sa} = int($_[0]->{sb}) | int($_[0]->{sa});
290 4 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
291 }
292  
293 4 ▶sub op_bitand {
Subroutine op_bitand: called CC=1 SCAR=0.0
Pod undocumented
294 4 $_[0]->{sa} = int($_[0]->{sb}) & int($_[0]->{sa});
295 4 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
296 }
297  
298 5 ▶sub op_bitxor {
Subroutine op_bitxor: called CC=1 SCAR=0.0
Pod undocumented
299 5 $_[0]->{sa} = int($_[0]->{sb}) ^ int($_[0]->{sa});
300 5 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
301 }
302  
303 6 ▶sub op_bitneg {
Subroutine op_bitneg: called CC=1 SCAR=0.0
Pod undocumented
304 6 $_[0]->{sa} = ~int($_[0]->{sa});
305 6 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
306 }
307  
308  
309  
310 297762 ▶sub op_and {
Subroutine op_and: called CC=2 SCAR=6.9
Pod undocumented
311 297762 ▶ if ( $_[0]->{sa} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0]{'sa'}) { } 297557 205 297762
312 297557 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
313 }
314 else {
315 205 $_[0]->{ pc } = $_[0]->op_arg;
316 205 goto $_[0]->{ code }->[ $_[0]->{ pc } ]->{ exec_code };
317 }
318 }
319  
320  
321 41 ▶sub op_dand {
Subroutine op_dand: called CC=2 SCAR=6.9
Pod undocumented
322 41 ▶ if ( defined $_[0]->{sa} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]{'sa'}) { } 31 10 41
323 31 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
324 }
325 else {
326 10 $_[0]->{ pc } = $_[0]->op_arg;
327 10 goto $_[0]->{ code }->[ $_[0]->{ pc } ]->{ exec_code };
328 }
329 }
330  
331  
332 218 ▶sub op_or {
Subroutine op_or: called CC=2 SCAR=6.9
Pod undocumented
333 218 ▶ if ( ! $_[0]->{sa} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $_[0]{'sa'}) { } 103 115 218
334 103 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
335 }
336 else {
337 115 $_[0]->{ pc } = $_[0]->op_arg;
338 115 goto $_[0]->{ code }->[ $_[0]->{ pc } ]->{ exec_code };
339 }
340 }
341  
342  
343 48 ▶sub op_dor {
Subroutine op_dor: called CC=2 SCAR=6.9
Pod undocumented
344 48 my $sv = $_[0]->{sa};
345 48 ▶ if ( defined $sv ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sv) { } 22 26 48
346 22 $_[0]->{ pc } = $_[0]->op_arg;
347 22 goto $_[0]->{ code }->[ $_[0]->{ pc } ]->{ exec_code };
348 }
349 else {
350 26 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
351 }
352  
353 }
354  
355 5 ▶sub op_not {
Subroutine op_not: called CC=1 SCAR=0.0
Pod undocumented
356 5 $_[0]->{sa} = ! $_[0]->{sa};
357 5 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
358 }
359  
360 9 ▶sub op_minus {
Subroutine op_minus: called CC=1 SCAR=0.0
Pod undocumented
361 9 $_[0]->{sa} = -$_[0]->{sa};
362 9 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
363 }
364  
365 21 ▶sub op_max_index {
Subroutine op_max_index: called CC=1 SCAR=0.0
Pod undocumented
366 21 $_[0]->{sa} = scalar(@{ $_[0]->{sa} }) - 1;
367 21 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
368 }
369  
370 9 ▶sub op_builtin_mark_raw {
Subroutine op_builtin_mark_raw: called CC=1 SCAR=0.0
Pod undocumented
371 9 $_[0]->{sa} = mark_raw($_[0]->{sa});
372 9 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
373 }
374  
375 10 ▶sub op_builtin_unmark_raw {
Subroutine op_builtin_unmark_raw: called CC=1 SCAR=0.0
Pod undocumented
376 10 $_[0]->{sa} = unmark_raw($_[0]->{sa});
377 10 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
378 }
379  
380 10 ▶sub op_builtin_html_escape {
Subroutine op_builtin_html_escape: called CC=1 SCAR=0.0
Pod undocumented
381 10 $_[0]->{sa} = html_escape($_[0]->{sa});
382 10 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
383 }
384  
385 6 ▶sub op_builtin_uri_escape {
Subroutine op_builtin_uri_escape: called CC=1 SCAR=0.0
Pod undocumented
386 6 $_[0]->{sa} = uri_escape($_[0]->{sa});
387 6 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
388 }
389  
390 4 ▶sub op_builtin_is_array_ref {
Subroutine op_builtin_is_array_ref: called CC=1 SCAR=0.0
Pod undocumented
391 4 $_[0]->{sa} = Text::Xslate::Util::is_array_ref($_[0]->{sa});
392 4 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
393 }
394  
395 4 ▶sub op_builtin_is_hash_ref {
Subroutine op_builtin_is_hash_ref: called CC=1 SCAR=0.0
Pod undocumented
396 4 $_[0]->{sa} = Text::Xslate::Util::is_hash_ref($_[0]->{sa});
397 4 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
398 }
399  
400 2 ▶sub op_is_code_ref {
Subroutine op_is_code_ref: called CC=1 SCAR=0.0
Pod undocumented
401 2 $_[0]->{sa} = Text::Xslate::Util::is_code_ref($_[0]->{sa});
402 2 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
403 }
404  
405 32 ▶sub op_match {
Subroutine op_match: called CC=1 SCAR=0.0
Pod undocumented
406 32 $_[0]->{sa} = Text::Xslate::PP::tx_match($_[0]->{sb}, $_[0]->{sa});
407 32 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
408 }
409  
410 500 ▶sub op_eq {
Subroutine op_eq: called CC=1 SCAR=0.0
Pod undocumented
411 500 $_[0]->{sa} = Text::Xslate::PP::tx_sv_eq($_[0]->{sb}, $_[0]->{sa});
412 500 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
413 }
414  
415  
416 85 ▶sub op_ne {
Subroutine op_ne: called CC=1 SCAR=0.0
Pod undocumented
417 85 $_[0]->{sa} = !Text::Xslate::PP::tx_sv_eq($_[0]->{sb}, $_[0]->{sa});
418 85 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
419 }
420  
421  
422 58 ▶sub op_lt {
Subroutine op_lt: called CC=1 SCAR=0.0
Pod undocumented
423 58 $_[0]->{sa} = $_[0]->{sb} < $_[0]->{sa};
424 58 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
425 }
426  
427 10 ▶sub op_le {
Subroutine op_le: called CC=1 SCAR=0.0
Pod undocumented
428 10 $_[0]->{sa} = $_[0]->{sb} <= $_[0]->{sa};
429 10 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
430 }
431  
432 41 ▶sub op_gt {
Subroutine op_gt: called CC=1 SCAR=0.0
Pod undocumented
433 41 $_[0]->{sa} = $_[0]->{sb} > $_[0]->{sa};
434 41 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
435 }
436  
437 419 ▶sub op_ge {
Subroutine op_ge: called CC=1 SCAR=0.0
Pod undocumented
438 419 $_[0]->{sa} = $_[0]->{sb} >= $_[0]->{sa};
439 419 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
440 }
441  
442 54 ▶sub op_ncmp {
Subroutine op_ncmp: called CC=1 SCAR=0.0
Pod undocumented
443 54 $_[0]->{sa} = $_[0]->{sb} <=> $_[0]->{sa};
444 54 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
445 }
446 13 ▶sub op_scmp {
Subroutine op_scmp: called CC=1 SCAR=0.0
Pod undocumented
447 13 $_[0]->{sa} = $_[0]->{sb} cmp $_[0]->{sa};
448 13 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
449 }
450  
451 7 ▶sub op_range {
Subroutine op_range: called CC=1 SCAR=0.0
Pod undocumented
452 7 my($self) = @_;
453 7 push @{ $self->{ SP }->[ -1 ] }, ($self->{sb} .. $self->{sa});
454 7 goto $self->{ code }->[ ++$self->{ pc } ]->{ exec_code };
455 }
456  
457 880 ▶sub op_fetch_symbol {
Subroutine op_fetch_symbol: called CC=1 SCAR=0.0
Pod undocumented
458 880 my($st) = @_;
459 880 my $name = $st->op_arg;
460 880 $st->{sa} = $st->fetch_symbol($name);
461  
462 873 goto $st->{ code }->[ ++$st->{ pc } ]->{ exec_code };
463 }
464  
465 1440 ▶sub tx_macro_enter {
Subroutine tx_macro_enter: called CC=7 SCAR=19.5
Pod undocumented
466 1440 my($st, $macro, $retaddr) = @_;
467 1440 my $name = $macro->name;
468 1440 my $addr = $macro->addr;
469 1440 my $nargs = $macro->nargs;
470 1440 my $outer = $macro->outer;
471 1440 my $args = pop @{ $st->{SP} };
472  
473 1440 print STDERR " " x $st->current_frame, "tx_macro_enter($name) to $retaddr\n" if _DUMP_PP;
474  
475 1440 ▶ if(@{$args} != $nargs) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$args;} != $nargs) 2 1438 1440
476 $st->error(undef, "Wrong number of arguments for %s (%d %s %d)",
477 2 ▶ $name, scalar(@{$args}), scalar(@{$args}) > $nargs ? '>' : '<', $nargs);
Branch: 1 branch
BranchTrueFalseTotal
scalar @{$args;} > $nargs ? : 1 1 2
478 2 $st->{ sa } = undef;
479 2 $st->{ pc }++;
480 2 return;
481 }
482  
483 1438 my $cframe = $st->push_frame($name, $retaddr);
484  
485 1436 $cframe->[ TXframe_OUTPUT ] = $st->{ output };
486  
487 1436 $st->{ output } = '';
488  
489 1436 my $i = 0;
490 1436 ▶ if($outer > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($outer > 0) 11 1425 1436
491 # copies lexical variables from the old frame to the new one
492 11 my $oframe = $st->frame->[ $st->current_frame - 1 ];
493 11 ▶ for(; $i < $outer; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $outer) 21 11 32
494 21 my $real_ix = $i + TXframe_START_LVAR;
495 21 $cframe->[$real_ix] = $oframe->[$real_ix];
496 }
497 }
498  
499 1436 for my $val (@{$args}) {
500 1013 tx_access_lvar( $st, $i++, $val );
501 }
502  
503 1436 $st->{ pc } = $addr;
504 1436 ▶ if($st->{code}->[$addr]->{opname} ne 'macro_begin') {
Branch: 1 branch
BranchTrueFalseTotal
if ($st->{"code"}[$addr]{"opname"} ne "macro_begin") 0 1436 1436
505 0 Carp::croak("Oops: entering non-macros: ", p($st->{code}->[$addr]));
506 }
507 1436 return;
508 }
509  
510 1233 ▶sub op_macro_end {
Subroutine op_macro_end: called CC=1 SCAR=0.0
Pod undocumented
511 1233 my($st) = @_;
512  
513 1233 my $top = $st->frame->[ $st->current_frame ];
514 1233 printf STDERR "%stx_macro_end(%s)]\n", ' ' x $st->current_frame - 1, $top->[ TXframe_NAME ] if _DUMP_PP;
515  
516 1233 $st->{sa} = mark_raw( $st->{ output } );
517 1233 $st->pop_frame(1);
518  
519 1233 $st->{ pc } = $top->[ TXframe_RETADDR ];
520 1233 goto $st->{ code }->[ $st->{ pc } ]->{ exec_code };
521 }
522  
523 862 ▶sub op_funcall {
Subroutine op_funcall: called CC=2 SCAR=6.9
Pod undocumented
524 862 my($st) = @_;
525 862 my $func = $st->{sa};
526 862 ▶ if(ref $func eq TXt_MACRO) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $func eq 'Text::Xslate::PP::Type::Macro') { } 658 204 862
527 658 tx_macro_enter($st, $func, $st->{ pc } + 1);
528 656 goto $st->{ code }->[ $st->{ pc } ]->{ exec_code };
529 }
530 else {
531 204 $st->{sa} = tx_funcall( $st, $func );
532 201 goto $st->{ code }->[ ++$st->{ pc } ]->{ exec_code };
533 }
534 }
535  
536 290 ▶sub op_methodcall_s {
Subroutine op_methodcall_s: called CC=1 SCAR=0.0
Pod undocumented
537 290 my($st) = @_;
538 $st->{sa} = Text::Xslate::PP::Method::tx_methodcall(
539 290 $st, undef, $st->op_arg, @{ pop @{ $st->{SP} } });
540 289 goto $st->{ code }->[ ++$st->{ pc } ]->{ exec_code };
541 }
542  
543 101 ▶sub op_make_array {
Subroutine op_make_array: called CC=1 SCAR=0.0
Pod undocumented
544 101 my $args = pop @{ $_[0]->{SP} };
545 101 $_[0]->{sa} = $args;
546 101 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
547 }
548  
549 58 ▶sub op_make_hash {
Subroutine op_make_hash: called CC=1 SCAR=0.0
Pod undocumented
550 58 my $args = pop @{ $_[0]->{SP} };
551 58 $_[0]->{sa} = { @{$args} };
552 58 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
553 }
554  
555 6 ▶sub op_merge_hash {
Subroutine op_merge_hash: called CC=1 SCAR=0.0
Pod undocumented
556 6 $_[0]->{sa} = Text::Xslate::Util::merge_hash($_[0]->{sa}, $_[0]->{sb});
557 6 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
558 }
559  
560  
561 72 ▶sub op_enter {
Subroutine op_enter: called CC=2 SCAR=6.9
Pod undocumented
562 72 ▶ push @{$_[0]->{save_local_stack} ||= []}, delete $_[0]->{local_stack};
Condition100%2/2
$_[0]{"save_local_stack"} ||= []
l!l
3141
MC/DC100%1/1
$_[0]{"save_local_stack"} ||= []
$_[0]{"save_local_stack"}
Truth table100%2/2
A
A= $_[0]{"save_local_stack"}
Aresult
11
00
563  
564 72 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
565 }
566  
567 70 ▶sub op_leave {
Subroutine op_leave: called CC=1 SCAR=0.0
Pod undocumented
568 70 $_[0]->{local_stack} = pop @{$_[0]->{save_local_stack}};
569  
570 70 goto $_[0]->{ code }->[ ++$_[0]->{ pc } ]->{ exec_code };
571 }
572  
573 297993 ▶sub op_goto {
Subroutine op_goto: called CC=1 SCAR=0.0
Pod undocumented
574 297993 $_[0]->{ pc } = $_[0]->op_arg;
575 297993 goto $_[0]->{ code }->[ $_[0]->{ pc } ]->{ exec_code };
576 }
577  
578 3924 ▶sub op_end {
Subroutine op_end: called CC=2 SCAR=6.9
Pod undocumented
579 3924 my($st) = @_;
580 3924 printf STDERR "op_end at %d\n", $st->{pc} if _DUMP_PP;
581 3924 $st->{ pc } = $st->code_len;
582  
583 3924 ▶ if($st->current_frame != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($st->current_frame != 0) 4 3920 3924
584 #Carp::croak("Oops: broken stack frame:" . p($st->frame));
585 }
586 3924 return;
587 }
588  
589 190 sub op_depend; *op_depend = \&op_noop;
590 190 sub op_macro_begin; *op_macro_begin = \&op_noop;
591 190 sub op_macro_nargs; *op_macro_nargs = \&op_noop;
592 190 sub op_macro_outer; *op_macro_outer = \&op_noop;
593 190 sub op_set_opinfo; *op_set_opinfo = \&op_noop;
594 190 sub op_super; *op_super = \&op_noop;
595  
596 #
597 # INTERNAL COMMON FUNCTIONS
598 #
599  
600 8676 ▶sub tx_access_lvar {
Subroutine tx_access_lvar: called CC=2 SCAR=6.9
Pod undocumented
601 8676 ▶ return $_[0]->pad->[ $_[1] + TXframe_START_LVAR ] if @_ == 2;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 2 4544 4132 8676
602 4132 $_[0]->pad->[ $_[1] + TXframe_START_LVAR ] = $_[2];
603 }
604  
605  
606 477 ▶sub tx_funcall {
Subroutine tx_funcall: called CC=4 SCAR=13.9
Pod undocumented
607 477 my ( $st, $proc ) = @_;
608 477 my ( @args ) = @{ pop @{ $st->{ SP } } };
609 477 my $ret;
610  
611 477 ▶ if(!defined $proc) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $proc) { } 2 475 477
612 2 my $c = $st->{code}->[ $st->{pc} - 1 ];
613 $st->error( undef, "Undefined function%s is called",
614 2 ▶ $c->{ opname } eq 'fetch_s' ? " $c->{arg}()" : ""
Branch: 1 branch
BranchTrueFalseTotal
$c->{'opname'} eq 'fetch_s' ? : 2 0 2
615 );
616 }
617 else {
618 475 $ret = eval { $proc->( @args ) };
619 475 ▶ $st->error( undef, "%s", $@) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 8 467 475
620 }
621  
622 474 return $ret;
623 }
624  
625 1055 ▶sub proccall {
Subroutine proccall: called CC=2 SCAR=6.9
Pod undocumented
626 1055 my($st, $proc) = @_;
627 1055 ▶ if(ref $proc eq TXt_MACRO) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $proc eq 'Text::Xslate::PP::Type::Macro') { } 782 273 1055
628 782 local $st->{pc} = $st->{pc};
629 782 tx_macro_enter($st, $proc, $st->{code_len});
630 782 $st->{code}->[ $st->{pc} ]->{ exec_code }->( $st );
631 782 return $st->{sa};
632 }
633 else {
634 273 return tx_funcall($st, $proc);
635 }
636 }
637  
638 190 ▶no Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
639 190 __PACKAGE__->meta->make_immutable();
640 __END__
« blib/lib/Text/Xslate/HashWithDefault.pm ↑ Summary blib/lib/Text/Xslate/Symbol.pm »