src/xslate_opcode.inc

filter: Statementstmt 97.9% 432 / 441 Branchbran 71.6% 129 / 180 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 90.3% 561 / 621 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« lib/Text/Xslate.xs ↑ Summary src/xslate_methods.xs »
1 /*********************
2  
3 Xslate opcode definitions
4  
5 *********************/
6  
7 8521 TXC(noop) {
8 8521 TX_RETURN_NEXT();
9 }
10  
11 1803 TXC(move_to_sb) {
12 1803 TX_st_sb = TX_st_sa;
13 1803 TX_RETURN_NEXT();
14 }
15  
16 66 TXC(move_from_sb) {
17 66 TX_st_sa = TX_st_sb;
18 66 TX_RETURN_NEXT();
19 }
20  
21 557 TXC_w_var(save_to_lvar) {
22 557 SV* const sv = TX_lvar(TX_op_arg_iv);
23 557 sv_setsv(sv, TX_st_sa);
24 557 TX_st_sa = sv;
25  
26 557 TX_RETURN_NEXT();
27 }
28  
29 2309 TXC_w_var(load_lvar) {
30 2309 TX_st_sa = TX_lvar_get(TX_op_arg_iv);
31 2309 TX_RETURN_NEXT();
32 }
33  
34 272 TXC_w_var(load_lvar_to_sb) {
35 272 TX_st_sb = TX_lvar_get(TX_op_arg_iv);
36 272 TX_RETURN_NEXT();
37 }
38  
39 /* local $vars->{$key} = $val */
40 /* see pp_helem() in pp_hot.c */
41 39 TXC_w_key(localize_s) {
42 39 HV* const vars = TX_st->vars;
43 39 ▶ const bool tied = SvRMAGICAL(vars) && mg_find((const SV *)vars, PERL_MAGIC_tied);
Branch: 2 branches
BranchTrueFalseTotal
const bool tied = SvRMAGICAL(vars) && mg_find((const SV *)vars, PERL_MAGIC_tied); 1 38 39
const bool tied = SvRMAGICAL(vars) && mg_find((const SV *)vars, PERL_MAGIC_tied); 1 0 1
44 39 SV* const key = TX_op_arg_sv;
45 39 bool const preeminent
46 39 = hv_exists_ent(vars, key, 0U);
47 39 HE* const he = hv_fetch_ent(vars, key, TRUE, 0U);
48 39 SV* const newval = TX_st_sa;
49 39 SV** const svp = &HeVAL(he);
50  
51 39 ▶ if(!preeminent) {
Branch: 1 branch
BranchTrueFalseTotal
if(!preeminent) { 18 21 39
52 STRLEN keylen;
53 18 const char* const keypv = SvPV_const(key, keylen);
54 18 ▶ SAVEDELETE(vars, savepvn(keypv, keylen),
Branch: 1 branch
BranchTrueFalseTotal
SAVEDELETE(vars, savepvn(keypv, keylen), 0 18 18
55 SvUTF8(key) ? -(I32)keylen : (I32)keylen);
56 }
57 else {
58 21 ▶ if (tied) {
Branch: 1 branch
BranchTrueFalseTotal
if (tied) { 1 20 21
59 #ifdef SAVEf_KEEPOLDELEM /* 5.12.0 or higher versions */
60 1 save_helem_flags(vars, key, svp, SAVEf_KEEPOLDELEM);
61 #else
62 SV *tmp = newSVsv(*svp);
63 save_helem(vars, key, &tmp);
64 #endif
65 }
66 else {
67 20 save_helem(vars, key, svp);
68 }
69 }
70 39 sv_setsv_mg(*svp, newval);
71  
72 39 TX_RETURN_NEXT();
73 }
74  
75 /* local $engine->{vars} = expr; */
76 9 TXC(localize_vars) {
77 9 SV* vars = sv_mortalcopy(TX_st_sa);
78  
79 9 ▶ if(!( SvROK(vars) && SvTYPE(SvRV(vars)) == SVt_PVHV
Branch: 2 branches
BranchTrueFalseTotal
if(!( SvROK(vars) && SvTYPE(SvRV(vars)) == SVt_PVHV 8 1 9
if(!( SvROK(vars) && SvTYPE(SvRV(vars)) == SVt_PVHV 8 0 8
80 8 ▶ && !SvOBJECT(SvRV(vars)) )) {
Branch: 1 branch
BranchTrueFalseTotal
&& !SvOBJECT(SvRV(vars)) )) { 0 8 8
81 1 tx_warn(aTHX_ TX_st, "Variable map must be a HASH reference, not %s",
82 tx_neat(aTHX_ vars));
83 0 vars = sv_2mortal(newRV_noinc((SV*)newHV()));
84 }
85  
86 8 save_hptr(&(TX_st->vars));
87 8 TX_st->vars = (HV*)SvRV(vars);
88  
89 8 TX_RETURN_NEXT();
90 }
91  
92 6059 TXC(push) {
93 6059 dSP;
94 6059 ▶ XPUSHs(sv_mortalcopy(TX_st_sa));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_mortalcopy(TX_st_sa)); 0 6059 6059
95 6059 PUTBACK;
96  
97 6059 TX_RETURN_NEXT();
98 }
99  
100 1298 TXC(pushmark) {
101 1298 dSP;
102 1298 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 1298 1298
103  
104 1298 TX_RETURN_NEXT();
105 }
106  
107 173 TXC(nil) {
108 173 TX_st_sa = &PL_sv_undef;
109  
110 173 TX_RETURN_NEXT();
111 }
112  
113 39845465 TXC_w_sv(literal) {
114 39845465 TX_st_sa = TX_op_arg_sv;
115  
116 39845465 TX_RETURN_NEXT();
117 }
118  
119 /* the same as literal, but make sure its argument is an integer */
120 TXC_w_sviv(literal_i);
121  
122 3417 TXC_w_key(fetch_s) { /* fetch a field from the top */
123 3417 HV* const vars = TX_st->vars;
124 3417 HE* const he = hv_fetch_ent(vars, TX_op_arg_sv, FALSE, 0U);
125  
126 3417 ▶ TX_st_sa = he ? hv_iterval(vars, he) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
TX_st_sa = he ? hv_iterval(vars, he) : &PL_sv_undef; 3372 45 3417
127  
128 3417 TX_RETURN_NEXT();
129 }
130  
131 75 TXC(fetch_field) { /* fetch a field from a variable (bin operator) */
132 75 SV* const var = TX_st_sb;
133 75 SV* const key = TX_st_sa;
134  
135 75 TX_st_sa = tx_fetch(aTHX_ TX_st, var, key);
136 75 TX_RETURN_NEXT();
137 }
138  
139 1090 TXC_w_key(fetch_field_s) { /* fetch a field from a variable (for literal) */
140 1090 SV* const var = TX_st_sa;
141 1090 SV* const key = TX_op_arg_sv;
142  
143 1090 TX_st_sa = tx_fetch(aTHX_ TX_st, var, key);
144 1090 TX_RETURN_NEXT();
145 }
146  
147 4119 TXC(print) {
148 4119 tx_print(aTHX_ TX_st, TX_st_sa);
149 4118 TX_RETURN_NEXT();
150 }
151  
152 181 TXC(print_raw) {
153 181 SV* const arg = tx_unmark_raw(aTHX_ TX_st_sa);
154 181 ▶ if(SvOK(arg)) {
Branch: 1 branch
BranchTrueFalseTotal
if(SvOK(arg)) { 179 2 181
155 179 tx_sv_cat(aTHX_ TX_st->output, arg);
156 }
157 else {
158 2 tx_warn(aTHX_ TX_st, "Use of nil to print");
159 }
160 181 TX_RETURN_NEXT();
161 }
162  
163 7398 TXC_w_sv(print_raw_s) {
164 7398 tx_sv_cat(aTHX_ TX_st->output, TX_op_arg_sv);
165  
166 7398 TX_RETURN_NEXT();
167 }
168  
169 1246 TXC(include) {
170 dMY_CXT;
171 1246 tx_state_t* const st = tx_load_template(aTHX_ TX_st->engine, TX_st_sa, TRUE);
172  
173 1242 ENTER;
174 1242 SAVETMPS;
175 1242 tx_push_frame(aTHX_ st);
176 1242 tx_execute(aTHX_ aMY_CXT_ st, TX_st->output, TX_st->vars);
177 837 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 207 630 837
178 837 LEAVE;
179  
180 837 TX_RETURN_NEXT();
181 }
182  
183 2 TXC(find_file) {
184 2 dSP;
185  
186 2 ENTER;
187 2 SAVETMPS;
188  
189 2 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 2 2
190 2 ▶ XPUSHs(TX_st->engine);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(TX_st->engine); 0 2 2
191 2 ▶ XPUSHs(TX_st_sa);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(TX_st_sa); 0 2 2
192 2 PUTBACK;
193  
194 2 call_method("find_file", G_SCALAR|G_EVAL);
195  
196 2 SPAGAIN;
197 2 ▶ if (SvTRUE(ERRSV)) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvTRUE(ERRSV)) { 2 0 2
if (SvTRUE(ERRSV)) { 1 1 2
198 1 sv_setsv(TX_st_sa, &PL_sv_no);
199 }
200 else {
201 1 sv_setsv(TX_st_sa, &PL_sv_yes);
202 }
203 2 (void)POPs;
204 2 PUTBACK;
205  
206 2 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 2 0 2
207 2 LEAVE;
208  
209 2 TX_RETURN_NEXT();
210 }
211  
212 1 TXC(suffix) {
213 1 TX_st_sa = *hv_fetchs((HV*)SvRV(TX_st->engine), "suffix", 0);
214 1 TX_RETURN_NEXT();
215 }
216  
217 202 TXC_w_var(for_start) {
218 202 SV* avref = TX_st_sa;
219 202 IV const id = TX_op_arg_iv;
220 SV* tmpsv;
221  
222 202 ▶ SvGETMAGIC(avref);
Branch: 2 branches
BranchTrueFalseTotal
SvGETMAGIC(avref); 2 200 202
SvGETMAGIC(avref); 0 2 2
223 202 ▶ if((tmpsv = tx_sv_to_ref(aTHX_ avref, SVt_PVAV, to_av_amg))) {
Branch: 1 branch
BranchTrueFalseTotal
if((tmpsv = tx_sv_to_ref(aTHX_ avref, SVt_PVAV, to_av_amg))) { 191 10 201
224 191 avref = tmpsv;
225 }
226 else {
227 10 ▶ if(SvOK(avref)) {
Branch: 1 branch
BranchTrueFalseTotal
if(SvOK(avref)) { 3 7 10
228 3 tx_error(aTHX_ TX_st,
229 "Iterating data must be an ARRAY reference, not %s",
230 tx_neat(aTHX_ avref));
231 }
232 10 avref = sv_2mortal(newRV_noinc((SV*)newAV()));
233 }
234  
235 201 (void) TX_lvar(id+TXfor_ITEM); /* allocate the space */
236 201 sv_setiv(TX_lvar(id+TXfor_ITER), -1); /* (re)set iterator */
237 201 sv_setsv(TX_lvar(id+TXfor_ARRAY), avref);
238  
239 201 TX_RETURN_NEXT();
240 }
241  
242 980 TXC_goto(for_iter) {
243 980 SV* const idsv = TX_st_sa;
244 980 IV const id = SvIVX(idsv); /* by literal_i */
245 980 SV* const item = TX_lvar_get(id+TXfor_ITEM);
246 980 SV* const i = TX_lvar_get(id+TXfor_ITER);
247 980 SV* const avref = TX_lvar_get(id+TXfor_ARRAY);
248 980 AV* const av = (AV*)SvRV(avref);
249  
250 assert(SvROK(avref));
251 assert(SvTYPE(av) == SVt_PVAV);
252 assert(SvIOK(i));
253  
254 980 ▶ SvIOK_only(i); /* for $^item */
Branch: 4 branches
BranchTrueFalseTotal
SvIOK_only(i); /* for $^item */ 0 980 980
SvIOK_only(i); /* for $^item */ 0 0 0
SvIOK_only(i); /* for $^item */ 0 0 0
SvIOK_only(i); /* for $^item */ 0 980 980
255 980 SvIVX(i)++;
256 //warn("for_next[%d %d]", (int)SvIV(i), (int)AvFILLp(av));
257 980 ▶ if(LIKELY(!SvRMAGICAL(av))) {
Branch: 1 branch
BranchTrueFalseTotal
if(LIKELY(!SvRMAGICAL(av))) { 972 8 980
258 972 ▶ if(SvIVX(i) <= AvFILLp(av)) {
Branch: 1 branch
BranchTrueFalseTotal
if(SvIVX(i) <= AvFILLp(av)) { 777 195 972
259 777 sv_setsv(item, AvARRAY(av)[SvIVX(i)]);
260 777 TX_RETURN_NEXT();
261 }
262 }
263 else { /* magical variables */
264 8 ▶ if(SvIVX(i) <= av_len(av)) {
Branch: 1 branch
BranchTrueFalseTotal
if(SvIVX(i) <= av_len(av)) { 5 3 8
265 5 SV** const itemp = av_fetch(av, SvIVX(i), FALSE);
266 5 ▶ sv_setsv(item, itemp ? *itemp : NULL);
Branch: 1 branch
BranchTrueFalseTotal
sv_setsv(item, itemp ? *itemp : NULL); 5 0 5
267 5 TX_RETURN_NEXT();
268 }
269 }
270  
271 /* the loop finished */
272 198 ▶ TX_st_sa = boolSV( SvIVX(i) > 0 ); /* for foreach-else */
Branch: 1 branch
BranchTrueFalseTotal
TX_st_sa = boolSV( SvIVX(i) > 0 ); /* for foreach-else */ 181 17 198
273 198 tx_sv_clear(aTHX_ item);
274 198 tx_sv_clear(aTHX_ i);
275 198 tx_sv_clear(aTHX_ avref);
276  
277 198 TX_RETURN_PC( TX_op_arg_pc );
278 }
279  
280  
281 /* sv_2iv(the guts of SvIV_please()) can make stringification faster,
282 although I don't know why it is :)
283 */
284 513 TXC(add) {
285 513 sv_setnv(TX_st->targ, SvNVx(TX_st_sb) + SvNVx(TX_st_sa));
286 513 sv_2iv(TX_st->targ); /* IV please */
287 513 TX_st_sa = TX_st->targ;
288 513 TX_RETURN_NEXT();
289 }
290 28 TXC(sub) {
291 28 sv_setnv(TX_st->targ, SvNVx(TX_st_sb) - SvNVx(TX_st_sa));
292 28 sv_2iv(TX_st->targ); /* IV please */
293 28 TX_st_sa = TX_st->targ;
294 28 TX_RETURN_NEXT();
295 }
296 26 TXC(mul) {
297 26 sv_setnv(TX_st->targ, SvNVx(TX_st_sb) * SvNVx(TX_st_sa));
298 26 sv_2iv(TX_st->targ); /* IV please */
299 26 TX_st_sa = TX_st->targ;
300 26 TX_RETURN_NEXT();
301 }
302 9 TXC(div) {
303 9 sv_setnv(TX_st->targ, SvNVx(TX_st_sb) / SvNVx(TX_st_sa));
304 9 sv_2iv(TX_st->targ); /* IV please */
305 9 TX_st_sa = TX_st->targ;
306 9 TX_RETURN_NEXT();
307 }
308 50 TXC(mod) {
309 50 IV const lhs = SvIVx(TX_st_sb);
310 50 IV const rhs = SvIVx(TX_st_sa);
311 50 ▶ if(rhs == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if(rhs == 0) { 1 49 50
312 1 tx_error(aTHX_ TX_st, "Illegal modulus zero");
313 1 sv_setpvs(TX_st->targ, "NaN");
314 }
315 else {
316 49 sv_setiv(TX_st->targ, lhs % rhs);
317 }
318 50 TX_st_sa = TX_st->targ;
319 50 TX_RETURN_NEXT();
320 }
321  
322 94 TXC_w_sv(concat) {
323 dMY_CXT;
324 94 SV* sv = TX_op_arg_sv;
325 94 SV* const lhs = TX_st_sb;
326 94 SV* const rhs = TX_st_sa;
327  
328 94 ▶ SvGETMAGIC(lhs);
Branch: 2 branches
BranchTrueFalseTotal
SvGETMAGIC(lhs); 1 93 94
SvGETMAGIC(lhs); 0 1 1
329 94 ▶ SvGETMAGIC(rhs);
Branch: 2 branches
BranchTrueFalseTotal
SvGETMAGIC(rhs); 0 94 94
SvGETMAGIC(rhs); 0 0 0
330  
331 94 ▶ if(!SvOK(lhs)){
Branch: 1 branch
BranchTrueFalseTotal
if(!SvOK(lhs)){ 5 89 94
332 5 sv_setsv_nomg(sv, rhs);
333 5 TX_st_sa = sv;
334 5 TX_RETURN_NEXT();
335 }
336 89 ▶ if(!SvOK(rhs)){
Branch: 1 branch
BranchTrueFalseTotal
if(!SvOK(rhs)){ 4 85 89
337 4 sv_setsv_nomg(sv, lhs);
338 4 TX_st_sa = sv;
339 4 TX_RETURN_NEXT();
340 }
341  
342 85 ▶ if(tx_str_is_raw(aTHX_ aMY_CXT_ lhs)) {
Branch: 1 branch
BranchTrueFalseTotal
if(tx_str_is_raw(aTHX_ aMY_CXT_ lhs)) { 10 75 85
343 10 sv_setsv_nomg(sv, TX_UNMARK_RAW(lhs));
344  
345 10 ▶ if(tx_str_is_raw(aTHX_ aMY_CXT_ rhs)) {
Branch: 1 branch
BranchTrueFalseTotal
if(tx_str_is_raw(aTHX_ aMY_CXT_ rhs)) { 5 5 10
346 5 sv_catsv_nomg(sv, TX_UNMARK_RAW(rhs));
347 }
348 else {
349 5 tx_sv_cat_with_html_escape_force(aTHX_ sv, rhs);
350 }
351 10 sv = tx_mark_raw(aTHX_ sv);
352 }
353 else {
354 75 ▶ if(tx_str_is_raw(aTHX_ aMY_CXT_ rhs)) {
Branch: 1 branch
BranchTrueFalseTotal
if(tx_str_is_raw(aTHX_ aMY_CXT_ rhs)) { 7 68 75
355 7 sv_setpvs(sv, "");
356 7 tx_sv_cat_with_html_escape_force(aTHX_ sv, lhs);
357 7 sv_catsv_nomg(sv, TX_UNMARK_RAW(rhs));
358 7 sv = tx_mark_raw(aTHX_ sv);
359 }
360 else {
361 68 sv_setsv_nomg(sv, lhs);
362 68 sv_catsv_nomg(sv, rhs);
363 }
364 }
365  
366 85 TX_st_sa = sv;
367  
368 85 TX_RETURN_NEXT();
369 }
370  
371 8 TXC_w_sv(repeat) {
372 dMY_CXT;
373 8 IV const lhs_is_raw = tx_str_is_raw(aTHX_ aMY_CXT_ TX_st_sb);
374 8 ▶ SV* const lhs = lhs_is_raw ? TX_UNMARK_RAW(TX_st_sb) : TX_st_sb;
Branch: 1 branch
BranchTrueFalseTotal
SV* const lhs = lhs_is_raw ? TX_UNMARK_RAW(TX_st_sb) : TX_st_sb; 2 6 8
375 8 SV* const rhs = TX_st_sa;
376  
377 8 ▶ SvGETMAGIC(lhs);
Branch: 2 branches
BranchTrueFalseTotal
SvGETMAGIC(lhs); 0 8 8
SvGETMAGIC(lhs); 0 0 0
378 8 ▶ if(!SvOK(lhs)) {
Branch: 1 branch
BranchTrueFalseTotal
if(!SvOK(lhs)) { 2 6 8
379 2 tx_warn(aTHX_ TX_st, "Use of nil for repeat operator");
380 2 TX_st_sa = &PL_sv_undef;
381 }
382 6 ▶ else if(!looks_like_number(rhs)) {
Branch: 1 branch
BranchTrueFalseTotal
else if(!looks_like_number(rhs)) { 0 6 6
383 0 tx_error(aTHX_ TX_st, "Repeat count must be a number, not %s",
384 tx_neat(aTHX_ TX_st_sa));
385 0 TX_st_sa = &PL_sv_undef;
386 }
387 else {
388 6 STRLEN const len = sv_len(lhs);
389 6 UV const count = SvUV(rhs);
390 6 SV* const sv = TX_op_arg_sv;
391 UV i;
392  
393 6 sv_setpvs(sv, "");
394 6 ▶ SvGROW(sv, len * count + 1);
Branch: 2 branches
BranchTrueFalseTotal
SvGROW(sv, len * count + 1); 6 0 6
SvGROW(sv, len * count + 1); 3 3 6
395 122 ▶ for(i = 0; i < count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = 0; i < count; i++) { 116 6 122
396 116 tx_sv_cat(aTHX_ sv, lhs);
397 }
398 6 ▶ TX_st_sa = lhs_is_raw ? tx_mark_raw(aTHX_ sv) : sv;
Branch: 1 branch
BranchTrueFalseTotal
TX_st_sa = lhs_is_raw ? tx_mark_raw(aTHX_ sv) : sv; 2 4 6
399 }
400  
401 8 TX_RETURN_NEXT();
402 }
403  
404 4 TXC(bitor) {
405 4 sv_setuv(TX_st->targ, SvUVx(TX_st_sb) | SvUVx(TX_st_sa));
406 4 TX_st_sa = TX_st->targ;
407 4 TX_RETURN_NEXT();
408 }
409  
410 4 TXC(bitand) {
411 4 sv_setuv(TX_st->targ, SvUVx(TX_st_sb) & SvUVx(TX_st_sa));
412 4 TX_st_sa = TX_st->targ;
413 4 TX_RETURN_NEXT();
414 }
415  
416 5 TXC(bitxor) {
417 5 sv_setuv(TX_st->targ, SvUVx(TX_st_sb) ^ SvUVx(TX_st_sa));
418 5 TX_st_sa = TX_st->targ;
419 5 TX_RETURN_NEXT();
420 }
421  
422 6 TXC(bitneg) {
423 6 sv_setuv(TX_st->targ, ~SvUVx(TX_st_sa));
424 6 TX_st_sa = TX_st->targ;
425 6 TX_RETURN_NEXT();
426 }
427  
428  
429  
430 39836967 TXC_goto(and) {
431 39836967 ▶ if(sv_true(TX_st_sa)) {
Branch: 1 branch
BranchTrueFalseTotal
if(sv_true(TX_st_sa)) { 39836761 206 39836967
432 39836761 TX_RETURN_NEXT();
433 }
434 else {
435 206 TX_RETURN_PC( TX_op_arg_pc );
436 }
437 }
438  
439 41 TXC_goto(dand) {
440 41 SV* const sv = TX_st_sa;
441 41 ▶ SvGETMAGIC(sv);
Branch: 2 branches
BranchTrueFalseTotal
SvGETMAGIC(sv); 0 41 41
SvGETMAGIC(sv); 0 0 0
442 41 ▶ if(SvOK(sv)) {
Branch: 1 branch
BranchTrueFalseTotal
if(SvOK(sv)) { 31 10 41
443 31 TX_RETURN_NEXT();
444 }
445 else {
446 10 TX_RETURN_PC( TX_op_arg_pc );
447 }
448 }
449  
450 218 TXC_goto(or) {
451 218 ▶ if(!sv_true(TX_st_sa)) {
Branch: 1 branch
BranchTrueFalseTotal
if(!sv_true(TX_st_sa)) { 103 115 218
452 103 TX_RETURN_NEXT();
453 }
454 else {
455 115 TX_RETURN_PC( TX_op_arg_pc );
456 }
457 }
458  
459 48 TXC_goto(dor) {
460 48 SV* const sv = TX_st_sa;
461 48 ▶ SvGETMAGIC(sv);
Branch: 2 branches
BranchTrueFalseTotal
SvGETMAGIC(sv); 0 48 48
SvGETMAGIC(sv); 0 0 0
462 48 ▶ if(!SvOK(sv)) {
Branch: 1 branch
BranchTrueFalseTotal
if(!SvOK(sv)) { 26 22 48
463 26 TX_RETURN_NEXT();
464 }
465 else {
466 22 TX_RETURN_PC( TX_op_arg_pc );
467 }
468 }
469  
470 5 TXC(not) {
471 5 ▶ TX_st_sa = boolSV( !sv_true(TX_st_sa) );
Branch: 1 branch
BranchTrueFalseTotal
TX_st_sa = boolSV( !sv_true(TX_st_sa) ); 1 4 5
472  
473 5 TX_RETURN_NEXT();
474 }
475  
476 9 TXC(minus) { /* unary minus */
477 9 sv_setnv(TX_st->targ, -SvNVx(TX_st_sa));
478 9 sv_2iv(TX_st->targ); /* IV please */
479 9 TX_st_sa = TX_st->targ;
480 9 TX_RETURN_NEXT();
481 }
482  
483 21 TXC(max_index) {
484 21 SV* const avref = TX_st_sa;
485  
486 21 ▶ if(!(SvROK(avref) && SvTYPE(SvRV(avref)) == SVt_PVAV)) {
Branch: 2 branches
BranchTrueFalseTotal
if(!(SvROK(avref) && SvTYPE(SvRV(avref)) == SVt_PVAV)) { 21 0 21
if(!(SvROK(avref) && SvTYPE(SvRV(avref)) == SVt_PVAV)) { 0 21 21
487 0 croak("Oops: Not an ARRAY reference for builtin max_index: %s",
488 tx_neat(aTHX_ avref));
489 }
490  
491 21 sv_setiv(TX_st->targ, av_len((AV*)SvRV(avref)));
492 21 TX_st_sa = TX_st->targ;
493 21 TX_RETURN_NEXT();
494 }
495  
496 9 TXC(builtin_mark_raw) {
497 9 TX_st_sa = tx_mark_raw(aTHX_ TX_st_sa);
498 9 TX_RETURN_NEXT();
499 }
500  
501 10 TXC(builtin_unmark_raw) {
502 10 TX_st_sa = tx_unmark_raw(aTHX_ TX_st_sa);
503 10 TX_RETURN_NEXT();
504 }
505  
506 6 TXC(builtin_uri_escape) {
507 6 TX_st_sa = tx_uri_escape(aTHX_ TX_st_sa);
508 6 TX_RETURN_NEXT();
509 }
510  
511 4 TXC(builtin_is_array_ref) {
512 4 SV* const sv = TX_st_sa;
513 4 ▶ SvGETMAGIC(sv);
Branch: 2 branches
BranchTrueFalseTotal
SvGETMAGIC(sv); 0 4 4
SvGETMAGIC(sv); 0 0 0
514 4 ▶ TX_st_sa = boolSV( tx_sv_is_array_ref(aTHX_ sv) );
Branch: 1 branch
BranchTrueFalseTotal
TX_st_sa = boolSV( tx_sv_is_array_ref(aTHX_ sv) ); 1 3 4
515 4 TX_RETURN_NEXT();
516 }
517  
518 4 TXC(builtin_is_hash_ref) {
519 4 SV* const sv = TX_st_sa;
520 4 ▶ SvGETMAGIC(sv);
Branch: 2 branches
BranchTrueFalseTotal
SvGETMAGIC(sv); 0 4 4
SvGETMAGIC(sv); 0 0 0
521 4 ▶ TX_st_sa = boolSV( tx_sv_is_hash_ref(aTHX_ sv) );
Branch: 1 branch
BranchTrueFalseTotal
TX_st_sa = boolSV( tx_sv_is_hash_ref(aTHX_ sv) ); 1 3 4
522 4 TX_RETURN_NEXT();
523 }
524  
525 10 TXC(builtin_html_escape) {
526 10 TX_st_sa = tx_html_escape(aTHX_ TX_st_sa);
527 10 TX_RETURN_NEXT();
528 }
529  
530 2 TXC(is_code_ref) {
531 2 SV* const sv = TX_st_sa;
532 2 ▶ SvGETMAGIC(sv);
Branch: 2 branches
BranchTrueFalseTotal
SvGETMAGIC(sv); 0 2 2
SvGETMAGIC(sv); 0 0 0
533 2 ▶ TX_st_sa = boolSV( tx_sv_is_code_ref(aTHX_ sv) );
Branch: 1 branch
BranchTrueFalseTotal
TX_st_sa = boolSV( tx_sv_is_code_ref(aTHX_ sv) ); 1 1 2
534 2 TX_RETURN_NEXT();
535 }
536  
537 6 TXC(merge_hash) {
538 6 SV* const base = TX_st_sa;
539 6 SV* const value = TX_st_sb;
540 6 TX_st_sa = tx_merge_hash(aTHX_ TX_st, base, value);
541 6 TX_RETURN_NEXT();
542 }
543  
544 32 TXC(match) {
545 32 ▶ TX_st_sa = boolSV( tx_sv_match(aTHX_ TX_st_sb, TX_st_sa) );
Branch: 1 branch
BranchTrueFalseTotal
TX_st_sa = boolSV( tx_sv_match(aTHX_ TX_st_sb, TX_st_sa) ); 16 16 32
546 32 TX_RETURN_NEXT();
547 }
548  
549 500 TXC(eq) {
550 500 ▶ TX_st_sa = boolSV( tx_sv_eq(aTHX_ TX_st_sb, TX_st_sa) );
Branch: 1 branch
BranchTrueFalseTotal
TX_st_sa = boolSV( tx_sv_eq(aTHX_ TX_st_sb, TX_st_sa) ); 189 311 500
551 500 TX_RETURN_NEXT();
552 }
553  
554 85 TXC(ne) {
555 85 ▶ TX_st_sa = boolSV( !tx_sv_eq(aTHX_ TX_st_sb, TX_st_sa) );
Branch: 1 branch
BranchTrueFalseTotal
TX_st_sa = boolSV( !tx_sv_eq(aTHX_ TX_st_sb, TX_st_sa) ); 19 66 85
556 85 TX_RETURN_NEXT();
557 }
558  
559 58 TXC(lt) {
560 58 ▶ TX_st_sa = boolSV( SvNVx(TX_st_sb) < SvNVx(TX_st_sa) );
Branch: 1 branch
BranchTrueFalseTotal
TX_st_sa = boolSV( SvNVx(TX_st_sb) < SvNVx(TX_st_sa) ); 36 22 58
561 58 TX_RETURN_NEXT();
562 }
563 10 TXC(le) {
564 10 ▶ TX_st_sa = boolSV(
Branch: 1 branch
BranchTrueFalseTotal
TX_st_sa = boolSV( 6 4 10
565 SvNVx(TX_ckuuv_lhs(TX_st_sb)) <= SvNVx(TX_ckuuv_rhs(TX_st_sa))
566 );
567 10 TX_RETURN_NEXT();
568 }
569 42 TXC(gt) {
570 42 ▶ TX_st_sa = boolSV(
Branch: 1 branch
BranchTrueFalseTotal
TX_st_sa = boolSV( 18 24 42
571 SvNVx(TX_ckuuv_lhs(TX_st_sb)) > SvNVx(TX_ckuuv_rhs(TX_st_sa))
572 );
573 42 TX_RETURN_NEXT();
574 }
575 419 TXC(ge) {
576 419 ▶ TX_st_sa = boolSV(
Branch: 1 branch
BranchTrueFalseTotal
TX_st_sa = boolSV( 215 204 419
577 SvNVx(TX_ckuuv_lhs(TX_st_sb)) >= SvNVx(TX_ckuuv_rhs(TX_st_sa))
578 );
579 419 TX_RETURN_NEXT();
580 }
581  
582 54 TXC(ncmp) {
583 54 NV const lhs = SvNVx(TX_ckuuv_lhs(TX_st_sb));
584 54 NV const rhs = SvNVx(TX_ckuuv_rhs(TX_st_sa));
585 IV value;
586 54 ▶ if(lhs == rhs) {
Branch: 1 branch
BranchTrueFalseTotal
if(lhs == rhs) { 0 54 54
587 0 value = 0;
588 }
589 54 ▶ else if(lhs < rhs) {
Branch: 1 branch
BranchTrueFalseTotal
else if(lhs < rhs) { 1 53 54
590 1 value = -1;
591 }
592 53 ▶ else if(lhs > rhs) {
Branch: 1 branch
BranchTrueFalseTotal
else if(lhs > rhs) { 53 0 53
593 53 value = 1;
594 }
595 else {
596 /* compares NaN with something */
597 0 TX_st_sa = &PL_sv_undef;
598 0 TX_RETURN_NEXT();
599 }
600  
601 54 sv_setiv(TX_st->targ, value);
602 54 TX_st_sa = TX_st->targ;
603 54 TX_RETURN_NEXT();
604 }
605  
606 13 TXC(scmp) {
607 13 sv_setiv(TX_st->targ,
608 sv_cmp(TX_ckuuv_lhs(TX_st_sb), TX_ckuuv_rhs(TX_st_sa))
609 );
610 13 TX_st_sa = TX_st->targ;
611 13 TX_RETURN_NEXT();
612 }
613  
614 7 TXC(range) {
615 7 dSP;
616 7 SV* const lhs = TX_st_sb;
617 7 SV* const rhs = TX_st_sa;
618 OP myop;
619 7 Zero(&myop, 1, OP);
620 7 myop.op_ppaddr = PL_ppaddr[OP_FLOP];
621 7 myop.op_type = OP_FLOP;
622  
623 /* call pp_flop() */
624 7 ENTER;
625 7 SAVEOP();
626 7 PL_op = &myop;
627 /* set GIMME to G_ARRAY (see op.h) */
628 7 PL_op->op_flags |= OPf_WANT_LIST;
629 7 ▶ EXTEND(SP, 2);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 2); 0 7 7
630 7 PUSHs(TX_ckuuv_lhs(lhs));
631 7 PUSHs(TX_ckuuv_rhs(rhs));
632 7 PUTBACK;
633 7 myop.op_ppaddr(aTHX);
634  
635 7 LEAVE;
636 7 TX_RETURN_NEXT();
637 }
638  
639 876 TXC_w_key(fetch_symbol) { /* functions, macros, constants */
640 876 SV* const name = TX_op_arg_sv;
641 HE* he;
642  
643 876 ▶ if((he = hv_fetch_ent(TX_st->symbol, name, FALSE, 0U))) {
Branch: 1 branch
BranchTrueFalseTotal
if((he = hv_fetch_ent(TX_st->symbol, name, FALSE, 0U))) { 869 7 876
644 869 TX_st_sa = HeVAL(he);
645 }
646 else {
647 7 croak("Undefined symbol %s", tx_neat(aTHX_ name));
648 }
649  
650 869 TX_RETURN_NEXT();
651 }
652  
653 860 TXC(funcall) { /* call a function or a macro */
654 /* PUSHMARK must be done */
655 860 SV* const proc = TX_st_sa;
656  
657 860 ▶ if(tx_sv_is_macro(aTHX_ proc)) {
Branch: 1 branch
BranchTrueFalseTotal
if(tx_sv_is_macro(aTHX_ proc)) { 656 204 860
658 656 tx_macro_enter(aTHX_ TX_st, (AV*)SvRV(proc), TX_st->pc + 1 /* retaddr */);
659 }
660 else {
661 204 TX_st_sa = tx_funcall(aTHX_ TX_st, proc, "function call");
662 201 TX_RETURN_NEXT();
663 }
664 }
665  
666 1229 TXC(macro_end) {
667 1229 SV* const retaddr = AvARRAY(TX_current_frame())[TXframe_RETADDR];
668  
669 1229 TX_st_sa = tx_mark_raw(aTHX_ TX_st->output);
670  
671 1229 tx_pop_frame(aTHX_ TX_st, TRUE);
672  
673 1229 TX_RETURN_PC( INT2PTR(tx_pc_t, SvUVX(retaddr)) );
674 }
675  
676 281 TXC_w_key(methodcall_s) {
677 281 TX_st_sa = tx_methodcall(aTHX_ TX_st, TX_op_arg_sv);
678  
679 280 TX_RETURN_NEXT();
680 }
681  
682 101 TXC(make_array) {
683 /* PUSHMARK must be done */
684 101 dSP;
685 101 dMARK;
686 101 dORIGMARK;
687 101 I32 const items = SP - MARK;
688 101 AV* const av = newAV();
689 101 SV* const avref = sv_2mortal(newRV_noinc((SV*)av));
690  
691 101 av_extend(av, items - 1);
692 5307 ▶ while(++MARK <= SP) {
Branch: 1 branch
BranchTrueFalseTotal
while(++MARK <= SP) { 5206 101 5307
693 5206 SV* const val = *MARK;
694 /* the SV is a mortal copy */
695 /* see 'push' */
696 5206 av_push(av, val);
697 5206 SvREFCNT_inc_simple_void_NN(val);
698 }
699  
700 101 SP = ORIGMARK;
701 101 PUTBACK;
702  
703 101 TX_st_sa = avref;
704  
705 101 TX_RETURN_NEXT();
706 }
707  
708 54 TXC(make_hash) {
709 /* PUSHMARK must be done */
710 54 dSP;
711 54 dMARK;
712 54 dORIGMARK;
713 54 I32 const items = SP - MARK;
714 54 HV* const hv = newHV();
715 54 SV* const hvref = sv_2mortal(newRV_noinc((SV*)hv));
716  
717 54 ▶ if((items % 2) != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if((items % 2) != 0) { 0 54 54
718 0 tx_error(aTHX_ TX_st, "Odd number of elements for hash literals");
719 0 ▶ XPUSHs(sv_newmortal());
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_newmortal()); 0 0 0
720 }
721  
722 118 ▶ while(MARK < SP) {
Branch: 1 branch
BranchTrueFalseTotal
while(MARK < SP) { 64 54 118
723 64 SV* const key = *(++MARK);
724 64 SV* const val = *(++MARK);
725  
726 /* the SVs are a mortal copy */
727 /* see 'push' */
728 64 (void)hv_store_ent(hv, key, val, 0U);
729 64 SvREFCNT_inc_simple_void_NN(val);
730 }
731  
732 54 SP = ORIGMARK;
733 54 PUTBACK;
734  
735 54 TX_st_sa = hvref;
736  
737 54 TX_RETURN_NEXT();
738 }
739  
740 72 TXC(enter) {
741 72 ENTER;
742 72 SAVETMPS;
743  
744 72 TX_RETURN_NEXT();
745 }
746  
747 70 TXC(leave) {
748 70 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 46 24 70
749 70 LEAVE;
750  
751 70 TX_RETURN_NEXT();
752 }
753  
754 39837198 TXC_goto(goto) {
755 /* To catch SIGALRM and SIGXCPU */
756 39837198 ▶ PERL_ASYNC_CHECK();
Branch: 1 branch
BranchTrueFalseTotal
PERL_ASYNC_CHECK(); 1 39837197 39837198
757 39837197 TX_RETURN_PC( TX_op_arg_pc );
758 }
759  
760 6 TXC(vars) {
761 6 TX_st_sa = sv_2mortal(newRV_inc((SV*)TX_st->vars));
762 6 TX_RETURN_NEXT();
763 }
764  
765 /* opcode markers (noop) */
766 TXC_w_sv(depend); /* tell the vm to dependent template files */
767 TXC_w_key(macro_begin);
768 TXC_w_sviv(macro_nargs);
769 TXC_w_sviv(macro_outer);
770 TXC(set_opinfo);
771 TXC(super);
772  
773 /* "end" must be here (the last opcode) */
774 3914 TXC(end) {
775 //assert(TX_st->current_frame == 0);
776 3914 }
777  
778 /* vim: set filetype=xs: */
« lib/Text/Xslate.xs ↑ Summary src/xslate_methods.xs »