| 1 |
|
| #include "EXTERN.h" |
| 2 |
|
| #include "perl.h" |
| 3 |
|
| #include "perlapi.h" |
| 4 |
|
| #include "XSUB.h" |
| 5 |
|
| |
| 6 |
|
| /* LOTS OF CRIBBING FROM B::Generate; just avoiding its static variables */ |
| 7 |
|
| static inline I32 |
| 8 |
0 |
| op_name_to_num(SV * name) |
| 9 |
|
| { |
| 10 |
|
| char const *s; |
| 11 |
0 |
| char *wanted = SvPV_nolen(name); |
| 12 |
0 |
| int i =0; |
| 13 |
0 |
| int topop = OP_max; |
| 14 |
|
| |
| 15 |
|
| #ifdef PERL_CUSTOM_OPS |
| 16 |
|
| topop--; |
| 17 |
|
| #endif |
| 18 |
|
| |
| 19 |
0 |
▶ | if (SvIOK(name) && SvIV(name) >= 0 && SvIV(name) < topop) |
Branch: 3 branches
| Branch | True | False | Total |
| if (SvIOK(name) && SvIV(name) >= 0 && SvIV(name) < topop) |
0 |
0 |
0 |
| if (SvIOK(name) && SvIV(name) >= 0 && SvIV(name) < topop) |
0 |
0 |
0 |
| if (SvIOK(name) && SvIV(name) >= 0 && SvIV(name) < topop) |
0 |
0 |
0 |
|
| 20 |
0 |
| return SvIV(name); /* XXX coverage 0 */ |
| 21 |
|
| |
| 22 |
0 |
▶ | for (s = PL_op_name[i]; s; s = PL_op_name[++i]) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (s = PL_op_name[i]; s; s = PL_op_name[++i]) { |
0 |
0 |
0 |
|
| 23 |
0 |
▶ | if (strEQ(s, wanted)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (strEQ(s, wanted)) |
0 |
0 |
0 |
|
| 24 |
0 |
| return i; |
| 25 |
|
| } |
| 26 |
|
| #ifdef PERL_CUSTOM_OPS |
| 27 |
|
| if (PL_custom_op_names) { |
| 28 |
|
| HE* ent; |
| 29 |
|
| SV* value; |
| 30 |
|
| |
| 31 |
|
| /* This is sort of a hv_exists, backwards - since custom-ops |
| 32 |
|
| are stored using their pp-addr as key, we must scan the |
| 33 |
|
| values */ |
| 34 |
|
| (void)hv_iterinit(PL_custom_op_names); |
| 35 |
|
| while ((ent = hv_iternext(PL_custom_op_names))) { |
| 36 |
|
| if (strEQ(SvPV_nolen(hv_iterval(PL_custom_op_names,ent)),wanted)) |
| 37 |
|
| return OP_CUSTOM; |
| 38 |
|
| } |
| 39 |
|
| } |
| 40 |
|
| #endif |
| 41 |
|
| |
| 42 |
0 |
| croak("No such op \"%s\"", SvPV_nolen(name)); /* XXX coverage 0 */ |
| 43 |
|
| |
| 44 |
|
| return -1; |
| 45 |
|
| } |
| 46 |
|
| |
| 47 |
|
| |
| 48 |
|
| #define NEW_SVOP(_newOPgen, B_class) \ |
| 49 |
|
| { \ |
| 50 |
|
| OP *o; \ |
| 51 |
|
| SV* param; \ |
| 52 |
|
| I32 typenum; \ |
| 53 |
|
| typenum = op_name_to_num(type); /* XXX More classes here! */ \ |
| 54 |
|
| if (typenum == OP_GVSV) { \ |
| 55 |
|
| if (*(SvPV_nolen(sv)) == '$') \ |
| 56 |
|
| param = (SV*)gv_fetchpv(SvPVX(sv)+1, TRUE, SVt_PV); \ |
| 57 |
|
| else \ |
| 58 |
|
| croak("First character to GVSV was not dollar"); \ |
| 59 |
|
| } else \ |
| 60 |
|
| param = newSVsv(sv); \ |
| 61 |
|
| o = _newOPgen(typenum, flags, param); \ |
| 62 |
|
| if (strEQ(B_class,"B::PADOP")) { \ |
| 63 |
|
| PADOP* p = (PADOP *)o; \ |
| 64 |
|
| PADNAME **names = PadnamelistARRAY((PADNAMELIST *)PadlistARRAY(padlist)[0]); \ |
| 65 |
|
| names[p->op_padix] = newPADNAMEpvn("&", 1); \ |
| 66 |
|
| } \ |
| 67 |
|
| ST(0) = sv_newmortal(); \ |
| 68 |
|
| sv_setiv(newSVrv(ST(0), B_class), PTR2IV(o)); \ |
| 69 |
|
| } |
| 70 |
|
| |
| 71 |
|
| #define PRE_OP \ |
| 72 |
|
| I32 old_padix = PL_padix; \ |
| 73 |
|
| I32 old_comppad_name_fill = PL_comppad_name_fill; \ |
| 74 |
|
| I32 old_min_intro_pending = PL_min_intro_pending; \ |
| 75 |
|
| I32 old_max_intro_pending = PL_max_intro_pending; \ |
| 76 |
|
| int old_cv_has_eval = PL_cv_has_eval; \ |
| 77 |
|
| I32 old_pad_reset_pending = PL_pad_reset_pending; \ |
| 78 |
|
| SV **old_curpad = PL_curpad; \ |
| 79 |
|
| AV *old_comppad = PL_comppad; \ |
| 80 |
|
| OP* old_op = PL_op; \ |
| 81 |
|
| PADNAMELIST *old_comppad_name = PL_comppad_name; \ |
| 82 |
|
| PL_comppad_name = PadlistNAMES(padlist); \ |
| 83 |
|
| PL_comppad = PadlistARRAY(padlist)[1]; \ |
| 84 |
|
| PL_curpad = AvARRAY(PL_comppad); \ |
| 85 |
|
| PL_comppad_name_fill = 0; \ |
| 86 |
|
| PL_min_intro_pending = 0; \ |
| 87 |
|
| PL_cv_has_eval = 0; \ |
| 88 |
|
| PL_pad_reset_pending = 0; \ |
| 89 |
|
| PL_padix = PadnamelistMAX(PL_comppad_name); |
| 90 |
|
| |
| 91 |
|
| |
| 92 |
|
| #define POST_OP \ |
| 93 |
|
| PL_padix = old_padix; \ |
| 94 |
|
| PL_comppad_name_fill = old_comppad_name_fill; \ |
| 95 |
|
| PL_min_intro_pending = old_min_intro_pending; \ |
| 96 |
|
| PL_max_intro_pending = old_max_intro_pending; \ |
| 97 |
|
| PL_pad_reset_pending = old_pad_reset_pending; \ |
| 98 |
|
| PL_curpad = old_curpad; \ |
| 99 |
|
| PL_comppad = old_comppad; \ |
| 100 |
|
| PL_comppad_name = old_comppad_name; \ |
| 101 |
|
| PL_cv_has_eval = old_cv_has_eval; \ |
| 102 |
|
| PL_op = old_op; |
| 103 |
|
| |
| 104 |
|
| MODULE = sealed PACKAGE = sealed PREFIX = GVOP_ |
| 105 |
|
| |
| 106 |
|
| SV *GVOP_new(SV *type, I32 flags, SV *sv, PADLIST* padlist) |
| 107 |
|
| |
| 108 |
|
| CODE: |
| 109 |
0 |
| PRE_OP; |
| 110 |
|
| #ifdef USE_ITHREADS |
| 111 |
|
| NEW_SVOP(newPADOP, "B::PADOP"); |
| 112 |
|
| #else |
| 113 |
0 |
▶ | NEW_SVOP(newSVOP, "B::SVOP"); |
Branch: 2 branches
| Branch | True | False | Total |
| NEW_SVOP(newSVOP, "B::SVOP"); |
0 |
0 |
0 |
| NEW_SVOP(newSVOP, "B::SVOP"); |
0 |
0 |
0 |
|
| 114 |
|
| #endif |
| 115 |
0 |
| POST_OP; |