c->protolen = 0;
c->pp = 0;
c->check = 0;
+ c->ref = 0;
c->ud = NULL;
return;
dupe->pp = orig->pp;
dupe->check = orig->check;
+ dupe->ref = orig->ref;
dupe->ud = orig->ud;
return dupe;
return (SvOK(hint) && SvIOK(hint)) ? SvIVX(hint) : 0;
}
+STATIC OP *so_find_gvop(OP *o, OP **last_arg_p, OP **rv2cv_p) {
+ OP *ex_list, *last_arg, *rv2cv, *gvop;
+
+ ex_list = cUNOPo->op_first;
+ /* pushmark when a method call */
+ if (!ex_list || ex_list->op_type != OP_NULL)
+ goto skip;
+
+ rv2cv = cUNOPx(ex_list)->op_first;
+ if (!rv2cv)
+ goto skip;
+
+ while (1) {
+ OP *next = rv2cv->op_sibling;
+ if (!next)
+ break;
+ last_arg = rv2cv;
+ rv2cv = next;
+ }
+
+ if (!(rv2cv->op_flags & OPf_KIDS))
+ goto skip;
+
+ gvop = cUNOPx(rv2cv)->op_first;
+
+ if (gvop && gvop->op_type == OP_GV)
+ goto done;
+
+skip:
+ last_arg = NULL;
+ rv2cv = NULL;
+ gvop = NULL;
+
+done:
+ if (last_arg_p)
+ *last_arg_p = last_arg;
+ if (rv2cv_p)
+ *rv2cv_p = rv2cv;
+
+ return gvop;
+}
+
STATIC OP *(*so_old_ck_entersub)(pTHX_ OP *) = 0;
STATIC OP *so_ck_entersub(pTHX_ OP *o) {
o = CALL_FPTR(so_old_ck_entersub)(aTHX_ o);
if (so_hint()) {
- OP *ex_list, *rv2cv, *gvop, *last_arg = NULL;
+ OP *ex_list, *last_arg, *rv2cv, *gvop;
GV *gv;
if (o->op_type != OP_ENTERSUB)
if (o->op_private & OPpENTERSUB_AMPER) /* hopefully \&foo */
goto skip;
- ex_list = cUNOPo->op_first;
- /* pushmark when a method call */
- if (!ex_list || ex_list->op_type != OP_NULL)
- goto skip;
-
- rv2cv = cUNOPx(ex_list)->op_first;
- if (!rv2cv)
- goto skip;
-
- while (1) {
- OP *next = rv2cv->op_sibling;
- if (!next)
- break;
- last_arg = rv2cv;
- rv2cv = next;
- }
-
- if (!(rv2cv->op_flags & OPf_KIDS))
- goto skip;
-
- gvop = cUNOPx(rv2cv)->op_first;
- if (!gvop || gvop->op_type != OP_GV)
+ gvop = so_find_gvop(o, &last_arg, &rv2cv);
+ if (!gvop)
goto skip;
gv = cGVOPx_gv(gvop);
return o;
}
+STATIC OP *(*so_old_ck_refgen)(pTHX_ OP *) = 0;
+
+STATIC OP *so_ck_refgen(pTHX_ OP *o) {
+ o = CALL_FPTR(so_old_ck_refgen)(aTHX_ o);
+
+ if (so_hint()) {
+ OP *kid = o;
+ OP *prev = NULL;
+ OP *parent = NULL;
+
+ while (kid->op_flags & OPf_KIDS) {
+ parent = kid;
+ kid = cUNOPx(kid)->op_first;
+ }
+
+ if (!parent)
+ goto skip;
+
+ for (kid; kid; prev = kid, kid = kid->op_sibling) {
+ OP *gvop;
+ GV *gv;
+ const sub_op_config_t *c;
+
+ if (kid->op_type != OP_RV2CV)
+ continue;
+
+ gvop = so_find_gvop(kid, NULL, NULL);
+ if (!gvop)
+ continue;
+
+ gv = cGVOPx_gv(gvop);
+
+ {
+ SV **svp;
+ const char *name = GvNAME(gv);
+ I32 len = GvNAMELEN(gv);
+ dMY_CXT;
+
+ svp = hv_fetch(MY_CXT.map, name, len, 0);
+ if (!svp)
+ continue;
+
+ c = INT2PTR(const sub_op_config_t *, SvIVX(*svp));
+ }
+
+ if (c->ref) {
+ OP *new_kid = CALL_FPTR(c->ref)(aTHX_ kid, c->ud);
+
+ if (new_kid != kid) {
+ new_kid->op_sibling = kid->op_sibling;
+ new_kid->op_next = new_kid;
+ if (prev)
+ prev->op_sibling = new_kid;
+ else
+ cUNOPx(parent)->op_first = new_kid;
+ op_null(kid);
+ kid = new_kid;
+ }
+ }
+ }
+ }
+
+skip:
+ return o;
+}
+
STATIC OP *(*so_old_ck_gelem)(pTHX_ OP *) = 0;
STATIC OP *so_ck_gelem(pTHX_ OP *o) {
so_old_ck_entersub = PL_check[OP_ENTERSUB];
PL_check[OP_ENTERSUB] = so_ck_entersub;
+ so_old_ck_refgen = PL_check[OP_REFGEN];
+ PL_check[OP_REFGEN] = so_ck_refgen;
so_old_ck_gelem = PL_check[OP_GELEM];
PL_check[OP_GELEM] = so_ck_gelem;
}