summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pp.c120
-rw-r--r--pp_hot.c124
2 files changed, 124 insertions, 120 deletions
diff --git a/pp.c b/pp.c
index 798c6247d3..8e27eac244 100644
--- a/pp.c
+++ b/pp.c
@@ -62,127 +62,7 @@ PP(pp_stub)
/* Pushy stuff. */
-/* This is also called directly by pp_lvavref. */
-PP(pp_padav)
-{
- dSP; dTARGET;
- U8 gimme;
- assert(SvTYPE(TARG) == SVt_PVAV);
- if (UNLIKELY( PL_op->op_private & OPpLVAL_INTRO ))
- if (LIKELY( !(PL_op->op_private & OPpPAD_STATE) ))
- SAVECLEARSV(PAD_SVl(PL_op->op_targ));
- EXTEND(SP, 1);
-
- if (PL_op->op_flags & OPf_REF) {
- PUSHs(TARG);
- RETURN;
- }
- else if (PL_op->op_private & OPpMAYBE_LVSUB) {
- const I32 flags = is_lvalue_sub();
- if (flags && !(flags & OPpENTERSUB_INARGS)) {
- if (GIMME_V == G_SCALAR)
- /* diag_listed_as: Can't return %s to lvalue scalar context */
- Perl_croak(aTHX_ "Can't return array to lvalue scalar context");
- PUSHs(TARG);
- RETURN;
- }
- }
- gimme = GIMME_V;
- if (gimme == G_ARRAY) {
- /* XXX see also S_pushav in pp_hot.c */
- const SSize_t maxarg = AvFILL(MUTABLE_AV(TARG)) + 1;
- EXTEND(SP, maxarg);
- if (SvMAGICAL(TARG)) {
- SSize_t i;
- for (i=0; i < maxarg; i++) {
- SV * const * const svp = av_fetch(MUTABLE_AV(TARG), i, FALSE);
- SP[i+1] = (svp) ? *svp : &PL_sv_undef;
- }
- }
- else {
- SSize_t i;
- for (i=0; i < maxarg; i++) {
- SV * const sv = AvARRAY((const AV *)TARG)[i];
- SP[i+1] = sv ? sv : &PL_sv_undef;
- }
- }
- SP += maxarg;
- }
- else if (gimme == G_SCALAR) {
- const SSize_t maxarg = AvFILL(MUTABLE_AV(TARG)) + 1;
- if (!maxarg)
- PUSHs(&PL_sv_zero);
- else if (PL_op->op_private & OPpTRUEBOOL)
- PUSHs(&PL_sv_yes);
- else
- mPUSHi(maxarg);
- }
- RETURN;
-}
-
-PP(pp_padhv)
-{
- dSP; dTARGET;
- U8 gimme;
- bool tied;
-
- assert(SvTYPE(TARG) == SVt_PVHV);
- XPUSHs(TARG);
- if (UNLIKELY( PL_op->op_private & OPpLVAL_INTRO ))
- if (LIKELY( !(PL_op->op_private & OPpPAD_STATE) ))
- SAVECLEARSV(PAD_SVl(PL_op->op_targ));
-
- if (PL_op->op_flags & OPf_REF)
- RETURN;
- else if (PL_op->op_private & OPpMAYBE_LVSUB) {
- const I32 flags = is_lvalue_sub();
- if (flags && !(flags & OPpENTERSUB_INARGS)) {
- if (GIMME_V == G_SCALAR)
- /* diag_listed_as: Can't return %s to lvalue scalar context */
- Perl_croak(aTHX_ "Can't return hash to lvalue scalar context");
- RETURN;
- }
- }
-
- gimme = GIMME_V;
- if (gimme == G_ARRAY) {
- RETURNOP(Perl_do_kv(aTHX));
- }
-
- if (PL_op->op_private & OPpPADHV_ISKEYS)
- /* 'keys %h' masquerading as '%h': reset iterator */
- (void)hv_iterinit(MUTABLE_HV(TARG));
-
- tied = SvRMAGICAL(TARG) && mg_find(TARG, PERL_MAGIC_tied);
-
- if ( ( PL_op->op_private & OPpTRUEBOOL
- || ( PL_op->op_private & OPpMAYBE_TRUEBOOL
- && block_gimme() == G_VOID )
- )
- && !tied
- )
- SETs(HvUSEDKEYS(TARG) ? &PL_sv_yes : &PL_sv_zero);
- else if (gimme == G_SCALAR) {
- if (PL_op->op_private & OPpPADHV_ISKEYS) {
- IV i;
- if (tied) {
- i = 0;
- while (hv_iternext(MUTABLE_HV(TARG)))
- i++;
- }
- else
- i = HvUSEDKEYS(MUTABLE_HV(TARG));
- (void)POPs;
- mPUSHi(i);
- }
- else {
- SV* const sv = Perl_hv_scalar(aTHX_ MUTABLE_HV(TARG));
- SETs(sv);
- }
- }
- RETURN;
-}
PP(pp_padcv)
{
diff --git a/pp_hot.c b/pp_hot.c
index 4c391f7552..7a93604276 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -966,6 +966,130 @@ PP(pp_print)
}
+/* This is also called directly by pp_lvavref. */
+PP(pp_padav)
+{
+ dSP; dTARGET;
+ U8 gimme;
+ assert(SvTYPE(TARG) == SVt_PVAV);
+ if (UNLIKELY( PL_op->op_private & OPpLVAL_INTRO ))
+ if (LIKELY( !(PL_op->op_private & OPpPAD_STATE) ))
+ SAVECLEARSV(PAD_SVl(PL_op->op_targ));
+ EXTEND(SP, 1);
+
+ if (PL_op->op_flags & OPf_REF) {
+ PUSHs(TARG);
+ RETURN;
+ }
+ else if (PL_op->op_private & OPpMAYBE_LVSUB) {
+ const I32 flags = is_lvalue_sub();
+ if (flags && !(flags & OPpENTERSUB_INARGS)) {
+ if (GIMME_V == G_SCALAR)
+ /* diag_listed_as: Can't return %s to lvalue scalar context */
+ Perl_croak(aTHX_ "Can't return array to lvalue scalar context");
+ PUSHs(TARG);
+ RETURN;
+ }
+ }
+
+ gimme = GIMME_V;
+ if (gimme == G_ARRAY) {
+ /* XXX see also S_pushav in pp_hot.c */
+ const SSize_t maxarg = AvFILL(MUTABLE_AV(TARG)) + 1;
+ EXTEND(SP, maxarg);
+ if (SvMAGICAL(TARG)) {
+ SSize_t i;
+ for (i=0; i < maxarg; i++) {
+ SV * const * const svp = av_fetch(MUTABLE_AV(TARG), i, FALSE);
+ SP[i+1] = (svp) ? *svp : &PL_sv_undef;
+ }
+ }
+ else {
+ SSize_t i;
+ for (i=0; i < maxarg; i++) {
+ SV * const sv = AvARRAY((const AV *)TARG)[i];
+ SP[i+1] = sv ? sv : &PL_sv_undef;
+ }
+ }
+ SP += maxarg;
+ }
+ else if (gimme == G_SCALAR) {
+ const SSize_t maxarg = AvFILL(MUTABLE_AV(TARG)) + 1;
+ if (!maxarg)
+ PUSHs(&PL_sv_zero);
+ else if (PL_op->op_private & OPpTRUEBOOL)
+ PUSHs(&PL_sv_yes);
+ else
+ mPUSHi(maxarg);
+ }
+ RETURN;
+}
+
+
+PP(pp_padhv)
+{
+ dSP; dTARGET;
+ U8 gimme;
+ bool tied;
+
+ assert(SvTYPE(TARG) == SVt_PVHV);
+ XPUSHs(TARG);
+ if (UNLIKELY( PL_op->op_private & OPpLVAL_INTRO ))
+ if (LIKELY( !(PL_op->op_private & OPpPAD_STATE) ))
+ SAVECLEARSV(PAD_SVl(PL_op->op_targ));
+
+ if (PL_op->op_flags & OPf_REF)
+ RETURN;
+ else if (PL_op->op_private & OPpMAYBE_LVSUB) {
+ const I32 flags = is_lvalue_sub();
+ if (flags && !(flags & OPpENTERSUB_INARGS)) {
+ if (GIMME_V == G_SCALAR)
+ /* diag_listed_as: Can't return %s to lvalue scalar context */
+ Perl_croak(aTHX_ "Can't return hash to lvalue scalar context");
+ RETURN;
+ }
+ }
+
+ gimme = GIMME_V;
+ if (gimme == G_ARRAY) {
+ RETURNOP(Perl_do_kv(aTHX));
+ }
+
+ if (PL_op->op_private & OPpPADHV_ISKEYS)
+ /* 'keys %h' masquerading as '%h': reset iterator */
+ (void)hv_iterinit(MUTABLE_HV(TARG));
+
+ tied = SvRMAGICAL(TARG) && mg_find(TARG, PERL_MAGIC_tied);
+
+ if ( ( PL_op->op_private & OPpTRUEBOOL
+ || ( PL_op->op_private & OPpMAYBE_TRUEBOOL
+ && block_gimme() == G_VOID )
+ )
+ && !tied
+ )
+ SETs(HvUSEDKEYS(TARG) ? &PL_sv_yes : &PL_sv_zero);
+ else if (gimme == G_SCALAR) {
+ if (PL_op->op_private & OPpPADHV_ISKEYS) {
+ IV i;
+ if (tied) {
+ i = 0;
+ while (hv_iternext(MUTABLE_HV(TARG)))
+ i++;
+ }
+ else
+ i = HvUSEDKEYS(MUTABLE_HV(TARG));
+ (void)POPs;
+ mPUSHi(i);
+ }
+ else {
+ SV* const sv = Perl_hv_scalar(aTHX_ MUTABLE_HV(TARG));
+ SETs(sv);
+ }
+ }
+ RETURN;
+}
+
+
/* also used for: pp_rv2hv() */
/* also called directly by pp_lvavref */