diff options
-rw-r--r-- | dump.c | 4 | ||||
-rw-r--r-- | ext/B/B/Concise.pm | 1 | ||||
-rw-r--r-- | op.c | 5 | ||||
-rw-r--r-- | op.h | 3 | ||||
-rw-r--r-- | pp.c | 3 | ||||
-rw-r--r-- | pp_hot.c | 3 |
6 files changed, 19 insertions, 0 deletions
@@ -943,6 +943,10 @@ Perl_do_op_dump(pTHX_ I32 level, PerlIO *file, const OP *o) if (o->op_private & OPpLVAL_DEFER) sv_catpv(tmpsv, ",LVAL_DEFER"); } + else if ((optype == OP_RV2HV || optype == OP_PADHV) + && o->op_private & OpMAYBE_TRUEBOOL) { + sv_catpvs(tmpsv, ",OpMAYBE_TRUEBOOL"); + } else { if (o->op_private & HINT_STRICT_REFS) sv_catpv(tmpsv, ",STRICT_REFS"); diff --git a/ext/B/B/Concise.pm b/ext/B/B/Concise.pm index f0a1b44e20..3f2a93d126 100644 --- a/ext/B/B/Concise.pm +++ b/ext/B/B/Concise.pm @@ -629,6 +629,7 @@ $priv{$_}{16} = "OURINTR" for ("gvsv", "rv2sv", "rv2av", "rv2hv", "r2gv", "enteriter"); $priv{$_}{8} = 'LVSUB' for qw(rv2av rv2gv rv2hv padav padhv aelem helem aslice hslice av2arylen keys rkeys substr pos vec); +$priv{$_}{64} = 'BOOL' for 'rv2hv', 'padhv'; $priv{substr}{16} = 'REPL1ST'; $priv{$_}{16} = "TARGMY" for (map(($_,"s$_"),"chop", "chomp"), @@ -10580,6 +10580,11 @@ Perl_rpeep(pTHX_ register OP *o) || o->op_type == OP_AND ) && fopishv) cLOGOP->op_first = opt_scalarhv(fop); + else if (!(lop->op_flags & OPf_WANT)) { + if (fop->op_type == OP_SCALAR) + fop = cUNOPx(fop)->op_first; + fop->op_private |= OpMAYBE_TRUEBOOL; + } if ( (lop->op_flags & OPf_WANT) == OPf_WANT_VOID && sopishv) cLOGOP->op_first->op_sibling = opt_scalarhv(sop); @@ -221,6 +221,9 @@ Deprecated. Use C<GIMME_V> instead. /* OP_RV2[AGH]V, OP_PAD[AH]V, OP_[AH]ELEM, OP_[AH]SLICE OP_AV2ARYLEN, OP_R?KEYS, OP_SUBSTR, OP_POS, OP_VEC */ #define OPpMAYBE_LVSUB 8 /* We might be an lvalue to return */ + /* OP_RV2HV and OP_PADHV */ +#define OpMAYBE_TRUEBOOL 64 /* %hash in (%hash || $foo) where + cx is not known till run time */ /* OP_SUBSTR only */ #define OPpSUBSTR_REPL_FIRST 16 /* 1st arg is replacement string */ @@ -131,6 +131,9 @@ PP(pp_padhv) if (gimme == G_ARRAY) { RETURNOP(Perl_do_kv(aTHX)); } + else if (PL_op->op_private & OpMAYBE_TRUEBOOL + && block_gimme() == G_VOID) + SETs(boolSV(HvUSEDKEYS(TARG))); else if (gimme == G_SCALAR) { SV* const sv = Perl_hv_scalar(aTHX_ MUTABLE_HV(TARG)); SETs(sv); @@ -873,6 +873,9 @@ PP(pp_rv2av) *PL_stack_sp = sv; return Perl_do_kv(aTHX); } + else if (PL_op->op_private & OpMAYBE_TRUEBOOL + && block_gimme() == G_VOID) + SETs(boolSV(HvUSEDKEYS(sv))); else if (gimme == G_SCALAR) { dTARGET; TARG = Perl_hv_scalar(aTHX_ MUTABLE_HV(sv)); |