| 1 |
|
| #include "EXTERN.h" |
| 2 |
|
| #include "perl.h" |
| 3 |
|
| #include "XSUB.h" |
| 4 |
|
| #define NEED_sv_2pv_flags |
| 5 |
|
| #include "ppport.h" |
| 6 |
|
| |
| 7 |
58 |
| int is_global() { |
| 8 |
58 |
| return SvTRUE(get_sv("overload::eval::GLOBAL", 1)); |
| 9 |
|
| } |
| 10 |
|
| |
| 11 |
|
| OP* (*real_pp_eval)(pTHX); |
| 12 |
58 |
| PP(pp_overload_eval) { |
| 13 |
58 |
| dSP; dTARG; |
| 14 |
|
| SV* hook; |
| 15 |
|
| SV* sv; |
| 16 |
58 |
| HV* saved_hh = NULL; |
| 17 |
|
| I32 count, c, ax; |
| 18 |
|
| |
| 19 |
|
| #if ((PERL_VERSION == 13) && (PERL_SUBVERSION >= 7) || (PERL_VERSION > 13)) |
| 20 |
58 |
| hook = cophh_fetch_pvn(PL_curcop->cop_hints_hash, "overload::eval", 14, 0, 0); |
| 21 |
|
| #else |
| 22 |
|
| hook = Perl_refcounted_he_fetch( aTHX_ PL_curcop->cop_hints_hash, Nullsv, "overload::eval", 14 /* strlen */, 0, 0); |
| 23 |
|
| #endif |
| 24 |
|
| |
| 25 |
58 |
▶ | if ( !( is_global() || SvPOK( hook ) ) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( !( is_global() || SvPOK( hook ) ) ) { |
54 |
4 |
58 |
| if ( !( is_global() || SvPOK( hook ) ) ) { |
49 |
5 |
54 |
|
| 26 |
49 |
| return real_pp_eval(aTHX); |
| 27 |
|
| } |
| 28 |
|
| |
| 29 |
|
| /* Take the source off the argument stack. */ |
| 30 |
9 |
▶ | if (PL_op->op_private & OPpEVAL_HAS_HH) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PL_op->op_private & OPpEVAL_HAS_HH) { |
9 |
0 |
9 |
|
| 31 |
9 |
| saved_hh = (HV*) SvREFCNT_inc(POPs); |
| 32 |
|
| } |
| 33 |
9 |
| sv = POPs; |
| 34 |
|
| |
| 35 |
|
| /* I'm sure I'm doing this stack stuff the hard way. I'm just not |
| 36 |
|
| confident enough to directly pass the output from the hook |
| 37 |
|
| directly to my caller. |
| 38 |
|
| |
| 39 |
|
| I may also need to set TARG. |
| 40 |
|
| */ |
| 41 |
|
| |
| 42 |
9 |
| ENTER; |
| 43 |
9 |
| SAVETMPS; |
| 44 |
9 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
9 |
9 |
|
| 45 |
9 |
▶ | XPUSHs(sv); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv); |
0 |
9 |
9 |
|
| 46 |
9 |
| PUTBACK; |
| 47 |
|
| |
| 48 |
9 |
| count = call_sv( hook, GIMME_V ); |
| 49 |
5 |
| SPAGAIN; |
| 50 |
5 |
| SP -= count; |
| 51 |
5 |
| ax = (SP - PL_stack_base) + 1; |
| 52 |
12 |
▶ | for ( c = 0; c < count; ++c ) { |
Branch: 1 branch
| Branch | True | False | Total |
| for ( c = 0; c < count; ++c ) { |
7 |
5 |
12 |
|
| 53 |
7 |
| SvREFCNT_inc( ST(c) ); |
| 54 |
|
| } |
| 55 |
|
| |
| 56 |
5 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
5 |
0 |
5 |
|
| 57 |
5 |
| LEAVE; |
| 58 |
|
| |
| 59 |
5 |
▶ | EXTEND(SP,count); |
Branch: 2 branches
| Branch | True | False | Total |
| EXTEND(SP,count); |
5 |
0 |
5 |
| EXTEND(SP,count); |
0 |
5 |
5 |
|
| 60 |
12 |
▶ | for ( c = 0; c < count; ++c ) { |
Branch: 1 branch
| Branch | True | False | Total |
| for ( c = 0; c < count; ++c ) { |
7 |
5 |
12 |
|
| 61 |
7 |
| PUSHs(sv_2mortal(ST(c))); |
| 62 |
|
| } |
| 63 |
|
| |
| 64 |
5 |
| RETURN; |
| 65 |
|
| } |
| 66 |
|
| |
| 67 |
|
| MODULE = overload::eval PACKAGE = overload::eval PREFIX = overload_eval_ |
| 68 |
|
| |
| 69 |
|
| PROTOTYPES: ENABLE |
| 70 |
|
| |
| 71 |
|
| void |
| 72 |
|
| _install_eval() |
| 73 |
|
| CODE: |
| 74 |
|
| /* Is this a race in threaded perl? */ |
| 75 |
5 |
| real_pp_eval = PL_ppaddr[OP_ENTEREVAL]; |
| 76 |
5 |
| PL_ppaddr[OP_ENTEREVAL] = Perl_pp_overload_eval; |