X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=Magic.xs;h=69ad981a726d862427de4e88d96de34b3a689432;hb=670e590caf3db942b5e7feddc1e86669f9f46294;hp=33fc60e70e295a065e1a990fa0f878c0621ca3a3;hpb=9686f4e3e41ef4f12e2aa812c5f6301e2a169e40;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/Magic.xs b/Magic.xs index 33fc60e..69ad981 100644 --- a/Magic.xs +++ b/Magic.xs @@ -133,6 +133,14 @@ # define IN_PERL_COMPILETIME (PL_curcop == &PL_compiling) #endif +#ifndef OP_NAME +# define OP_NAME(O) (PL_op_name[(O)->op_type]) +#endif + +#ifndef OP_CLASS +# define OP_CLASS(O) (PL_opargs[(O)->op_type] & OA_CLASS_MASK) +#endif + #ifdef DEBUGGING # define VMG_ASSERT(C) assert(C) #else @@ -391,6 +399,9 @@ typedef enum { OPc_COP, #if VMG_HAS_PERL(5, 21, 5) OPc_METHOP, +#endif +#if VMG_HAS_PERL(5, 21, 7) + OPc_UNOP_AUX, #endif OPc_MAX } opclass; @@ -410,18 +421,27 @@ static const char *const vmg_opclassnames[] = { "B::COP", #if VMG_HAS_PERL(5, 21, 5) "B::METHOP", +#endif +#if VMG_HAS_PERL(5, 21, 7) + "B::UNOP_AUX", #endif NULL }; -static opclass vmg_opclass(const OP *o) { +static opclass vmg_opclass(pTHX_ const OP *o) { +#define vmg_opclass(O) vmg_opclass(aTHX_ (O)) #if 0 if (!o) return OPc_NULL; #endif - if (o->op_type == 0) + if (o->op_type == 0) { +#if VMG_HAS_PERL(5, 21, 7) + if (o->op_targ == OP_NEXTSTATE || o->op_targ == OP_DBSTATE) + return OPc_COP; +#endif return (o->op_flags & OPf_KIDS) ? OPc_UNOP : OPc_BASEOP; + } if (o->op_type == OP_SASSIGN) return ((o->op_private & OPpASSIGN_BACKWARDS) ? OPc_UNOP : OPc_BINOP); @@ -444,7 +464,7 @@ static opclass vmg_opclass(const OP *o) { return OPc_PADOP; #endif - switch (PL_opargs[o->op_type] & OA_CLASS_MASK) { + switch (OP_CLASS(o)) { case OA_BASEOP: return OPc_BASEOP; case OA_UNOP: @@ -462,7 +482,16 @@ static opclass vmg_opclass(const OP *o) { case OA_PADOP: return OPc_PADOP; case OA_PVOP_OR_SVOP: - return (o->op_private & (OPpTRANS_TO_UTF|OPpTRANS_FROM_UTF)) ? OPc_SVOP : OPc_PVOP; + return ( +#if VMG_HAS_PERL(5, 13, 7) + (o->op_type != OP_CUSTOM) && +#endif + (o->op_private & (OPpTRANS_TO_UTF|OPpTRANS_FROM_UTF))) +#if defined(USE_ITHREADS) && VMG_HAS_PERL(5, 8, 9) + ? OPc_PADOP : OPc_PVOP; +#else + ? OPc_SVOP : OPc_PVOP; +#endif case OA_LOOP: return OPc_LOOP; case OA_COP: @@ -486,6 +515,10 @@ static opclass vmg_opclass(const OP *o) { #if VMG_HAS_PERL(5, 21, 5) case OA_METHOP: return OPc_METHOP; +#endif +#if VMG_HAS_PERL(5, 21, 7) + case OA_UNOP_AUX: + return OPc_UNOP_AUX; #endif } @@ -1123,8 +1156,12 @@ static SV *vmg_op_info(pTHX_ unsigned int opinfo) { switch (opinfo) { case VMG_OP_INFO_NAME: { - OPCODE t = PL_op->op_type; - return sv_2mortal(newSVpvn(PL_op_name[t], vmg_op_name_len[t])); + const char *name; + STRLEN name_len; + OPCODE t = PL_op->op_type; + name = OP_NAME(PL_op); + name_len = (t == OP_CUSTOM) ? strlen(name) : vmg_op_name_len[t]; + return sv_2mortal(newSVpvn(name, name_len)); } case VMG_OP_INFO_OBJECT: { dMY_CXT;