summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2017-07-17 13:47:12 +0100
committerDavid Mitchell <davem@iabyn.com>2017-07-27 11:30:24 +0100
commite855b461ca460cbac6d017d10587057f51474a68 (patch)
treebdb1b2f9c4961152fe7817cb96bc065b24d1ad47 /pp.c
parente3ad3bbc29184edf8de9c3acf6b85e79e632b069 (diff)
downloadperl-e855b461ca460cbac6d017d10587057f51474a68.tar.gz
move pp_padav(), pp_padhv() from pp.c to pp_hot.c
Just a cut+paste; no code or functional changes. As well as being hot code, pp_padav() and pp_padhv() also have a lot of code in common with pp_rv2av() (which also implements pp_rv2hv()). Having all three functions in the same file will allow the next few commits to move some of that common code into static inline functions.
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c120
1 files changed, 0 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)
{