File Coverage

hax/compilerun_sv.c.inc
Criterion Covered Total %
statement 14 15 93.3
branch 6 12 50.0
condition n/a
subroutine n/a
pod n/a
total 20 27 74.0


line stmt bran cond sub pod time code
1             /* vi: set ft=c : */
2              
3             #ifdef G_USEHINTS
4             # define compilerun_sv(sv, flags) eval_sv(sv, flags|G_USEHINTS|G_RETHROW)
5             #else
6             # define compilerun_sv(sv, flags) S_compilerun_sv(aTHX_ sv, flags)
7 9           static void S_compilerun_sv(pTHX_ SV *sv, U32 flags)
8             {
9             /* We can't call eval_sv() because it doesn't preserve the caller's hints
10             * or features. We'll have to emulate it and do different things
11             * https://github.com/Perl/perl5/issues/21415
12             */
13 9           OP *o = newUNOP(OP_ENTEREVAL, G_SCALAR,
14             newSVOP(OP_CONST, 0, SvREFCNT_inc(sv)));
15 9 50         OP *start = LINKLIST(o);
16 9           o->op_next = NULL;
17             #ifdef OPpEVAL_EVALSV
18             o->op_private |= OPpEVAL_EVALSV;
19             #endif
20              
21 9           SAVEFREEOP(o);
22              
23             // Now just execute the ops in the list until the end
24 9           SAVEVPTR(PL_op);
25 9           PL_op = start;
26              
27             #ifndef OPpEVAL_EVALSV
28             /* Without OPpEVAL_EVALSV we can only detect compiler errors by
29             * pp_entereval() returning NULL. We'll have to manually run the optree
30             * until we see that to know
31             */
32 27 50         while(PL_op && PL_op->op_type != OP_ENTEREVAL)
    100          
33 18           PL_op = (*PL_op->op_ppaddr)(aTHX);
34 9 50         if(PL_op)
35 9           PL_op = (*PL_op->op_ppaddr)(aTHX); // run the OP_ENTEREVAL
36 9 50         if(!PL_op)
37 0 0         croak_sv(ERRSV);
38             #endif
39 9           CALLRUNOPS(aTHX);
40              
41             #ifdef OPpEVAL_EVALSV
42             dSP;
43             if(!TOPs)
44             croak_sv(ERRSV);
45             #endif
46 9           }
47             #endif