X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=Types.xs;h=0cff8fa6e90a930d94f37208b13c9859c4cd1742;hb=881d1aecb5e9948bbd7a384deffbab560eab4ef4;hp=752e3f43d27aab4f5b1de8a8c59d1e70ab91f220;hpb=b99a3bce46a7a325bfe18ce349df5cd80bdbc78f;p=perl%2Fmodules%2FLexical-Types.git diff --git a/Types.xs b/Types.xs index 752e3f4..0cff8fa 100644 --- a/Types.xs +++ b/Types.xs @@ -39,6 +39,10 @@ # define HvNAMELEN_get(H) strlen(HvNAME_get(H)) #endif +#ifndef OP_SIBLING +# define OP_SIBLING(O) ((O)->op_sibling) +#endif + #ifndef SvREFCNT_inc_simple_void_NN # define SvREFCNT_inc_simple_void_NN(S) ((void) SvREFCNT_inc(S)) #endif @@ -348,7 +352,13 @@ get_enclosing_cv: STATIC SV *lt_tag(pTHX_ SV *value) { #define lt_tag(V) lt_tag(aTHX_ (V)) lt_hint_t *h; - SV *code = NULL; + SV *code = NULL; +#if LT_THREADSAFE + dMY_CXT; + + if (!MY_CXT.tbl) + return newSViv(0); +#endif /* LT_THREADSAFE */ if (SvROK(value)) { value = SvRV(value); @@ -369,13 +379,10 @@ STATIC SV *lt_tag(pTHX_ SV *value) { #endif /* !LT_HINT_STRUCT */ #if LT_THREADSAFE - { - dMY_CXT; - /* We only need for the key to be an unique tag for looking up the value later - * Allocated memory provides convenient unique identifiers, so that's why we - * use the hint as the key itself. */ - ptable_hints_store(MY_CXT.tbl, h, h); - } + /* We only need for the key to be an unique tag for looking up the value later + * Allocated memory provides convenient unique identifiers, so that's why we + * use the hint as the key itself. */ + ptable_hints_store(MY_CXT.tbl, h, h); #endif /* LT_THREADSAFE */ return newSViv(PTR2IV(h)); @@ -386,7 +393,10 @@ STATIC SV *lt_detag(pTHX_ const SV *hint) { lt_hint_t *h; #if LT_THREADSAFE dMY_CXT; -#endif + + if (!MY_CXT.tbl) + return NULL; +#endif /* LT_THREADSAFE */ if (!(hint && SvIOK(hint))) return NULL; @@ -677,7 +687,9 @@ STATIC OP *lt_pp_padrange(pTHX) { base = PL_op->op_targ; count = PL_op->op_private & OPpPADRANGE_COUNTMASK; - for (i = 0, p = roi.padxv_start; i < count && p; ++i, p = p->op_sibling) { + for (i = 0, p = roi.padxv_start; i < count && p; ++i, p = p->op_next) { + while (p->op_type == OP_NULL) + p = p->op_next; lt_op_padxv_info oi; if (p->op_type == OP_PADSV && lt_padxv_map_fetch(p, &oi)) lt_op_padxv_info_call(&oi, PAD_SV(base + i)); @@ -710,7 +722,7 @@ STATIC OP *lt_ck_padany(pTHX_ OP *o) { if (stash && (code = lt_hint())) { dMY_CXT; SV *orig_pkg = newSVpvn(HvNAME_get(stash), HvNAMELEN_get(stash)); - SV *orig_meth = MY_CXT.default_meth; + SV *orig_meth = MY_CXT.default_meth; /* Guarded by lt_hint() */ SV *type_pkg = NULL; SV *type_meth = NULL; int items; @@ -796,7 +808,7 @@ STATIC int lt_maybe_padrange_setup(pTHX_ OP *o, const OP *start) { count = o->op_private & OPpPADRANGE_COUNTMASK; - for (i = 0, p = start; i < count && p; ++i, p = p->op_sibling) { + for (i = 0, p = start; i < count && p; ++i, p = p->op_next) { if (p->op_type == OP_PADSV) { /* In a padrange sequence, either all lexicals are typed, or none are. * Thus we can stop at the first padsv op. However, note that these @@ -848,8 +860,15 @@ STATIC void lt_peep_rec(pTHX_ OP *o, ptable *seen) { && !(o->op_flags & OPf_SPECIAL)) { /* A padrange op is guaranteed to have previously been a pushmark. * Moreover, for non-special padrange ops (i.e. that aren't for - * my (...) = @_), the original padxv ops are its siblings. */ - lt_maybe_padrange_setup(o, o->op_sibling); + * my (...) = @_), the first original padxv is its sibling or nephew. + */ + OP *kid = OP_SIBLING(o); + if (kid->op_type == OP_NULL && kid->op_flags & OPf_KIDS) { + kid = kUNOP->op_first; + if (kid->op_type == OP_NULL) + kid = OP_SIBLING(kid); + } + lt_maybe_padrange_setup(o, kid); } break; case OP_AASSIGN: { @@ -862,7 +881,7 @@ STATIC void lt_peep_rec(pTHX_ OP *o, ptable *seen) { && op->op_flags & OPf_SPECIAL) { const OP *start = cUNOPx(cBINOPo->op_last)->op_first; if (start->op_type == OP_PUSHMARK) - start = start->op_sibling; + start = OP_SIBLING(start); lt_maybe_padrange_setup(op, start); } break; @@ -914,9 +933,11 @@ STATIC void lt_peep(pTHX_ OP *o) { lt_old_peep(aTHX_ o); - ptable_seen_clear(seen); - lt_peep_rec(o); - ptable_seen_clear(seen); + if (seen) { + ptable_seen_clear(seen); + lt_peep_rec(o); + ptable_seen_clear(seen); + } } /* --- Interpreter setup/teardown ------------------------------------------ */