3 * Copyright (c) 1996 Malcolm Beattie
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
10 #define PERL_NO_GET_CONTEXT
16 typedef PerlIO * InputStream;
18 typedef FILE * InputStream;
22 static const char* const svclassnames[] = {
29 #if PERL_VERSION <= 10
39 #if PERL_VERSION >= 11
71 static const char* const opclassnames[] = {
86 static const size_t opsizes[] = {
101 #define MY_CXT_KEY "B::_guts" XS_VERSION
104 int x_walkoptree_debug; /* Flag for walkoptree debug hook */
105 SV * x_specialsv_list[7];
110 #define walkoptree_debug (MY_CXT.x_walkoptree_debug)
111 #define specialsv_list (MY_CXT.x_specialsv_list)
114 cc_opclass(pTHX_ const OP *o)
120 return (o->op_flags & OPf_KIDS) ? OPc_UNOP : OPc_BASEOP;
122 if (o->op_type == OP_SASSIGN)
123 return ((o->op_private & OPpASSIGN_BACKWARDS) ? OPc_UNOP : OPc_BINOP);
125 if (o->op_type == OP_AELEMFAST) {
126 if (o->op_flags & OPf_SPECIAL)
137 if (o->op_type == OP_GV || o->op_type == OP_GVSV ||
138 o->op_type == OP_RCATLINE)
142 switch (PL_opargs[o->op_type] & OA_CLASS_MASK) {
167 case OA_PVOP_OR_SVOP:
169 * Character translations (tr///) are usually a PVOP, keeping a
170 * pointer to a table of shorts used to look up translations.
171 * Under utf8, however, a simple table isn't practical; instead,
172 * the OP is an SVOP (or, under threads, a PADOP),
173 * and the SV is a reference to a swash
174 * (i.e., an RV pointing to an HV).
176 return (o->op_private & (OPpTRANS_TO_UTF|OPpTRANS_FROM_UTF))
177 #if defined(USE_ITHREADS) \
178 && (PERL_VERSION > 8 || (PERL_VERSION == 8 && PERL_SUBVERSION >= 9))
179 ? OPc_PADOP : OPc_PVOP;
181 ? OPc_SVOP : OPc_PVOP;
190 case OA_BASEOP_OR_UNOP:
192 * UNI(OP_foo) in toke.c returns token UNI or FUNC1 depending on
193 * whether parens were seen. perly.y uses OPf_SPECIAL to
194 * signal whether a BASEOP had empty parens or none.
195 * Some other UNOPs are created later, though, so the best
196 * test is OPf_KIDS, which is set in newUNOP.
198 return (o->op_flags & OPf_KIDS) ? OPc_UNOP : OPc_BASEOP;
202 * The file stat OPs are created via UNI(OP_foo) in toke.c but use
203 * the OPf_REF flag to distinguish between OP types instead of the
204 * usual OPf_SPECIAL flag. As usual, if OPf_KIDS is set, then we
205 * return OPc_UNOP so that walkoptree can find our children. If
206 * OPf_KIDS is not set then we check OPf_REF. Without OPf_REF set
207 * (no argument to the operator) it's an OP; with OPf_REF set it's
208 * an SVOP (and op_sv is the GV for the filehandle argument).
210 return ((o->op_flags & OPf_KIDS) ? OPc_UNOP :
212 (o->op_flags & OPf_REF) ? OPc_PADOP : OPc_BASEOP);
214 (o->op_flags & OPf_REF) ? OPc_SVOP : OPc_BASEOP);
218 * next, last, redo, dump and goto use OPf_SPECIAL to indicate that a
219 * label was omitted (in which case it's a BASEOP) or else a term was
220 * seen. In this last case, all except goto are definitely PVOP but
221 * goto is either a PVOP (with an ordinary constant label), an UNOP
222 * with OPf_STACKED (with a non-constant non-sub) or an UNOP for
223 * OP_REFGEN (with goto &sub) in which case OPf_STACKED also seems to
226 if (o->op_flags & OPf_STACKED)
228 else if (o->op_flags & OPf_SPECIAL)
233 warn("can't determine class of operator %s, assuming BASEOP\n",
234 PL_op_name[o->op_type]);
239 make_op_object(pTHX_ const OP *o)
241 SV *opsv = sv_newmortal();
242 sv_setiv(newSVrv(opsv, opclassnames[cc_opclass(aTHX_ o)]), PTR2IV(o));
247 make_sv_object(pTHX_ SV *sv)
249 SV *const arg = sv_newmortal();
250 const char *type = 0;
254 for (iv = 0; iv < sizeof(specialsv_list)/sizeof(SV*); iv++) {
255 if (sv == specialsv_list[iv]) {
261 type = svclassnames[SvTYPE(sv)];
264 sv_setiv(newSVrv(arg, type), iv);
268 #if PERL_VERSION >= 9
270 make_temp_object(pTHX_ SV *temp)
273 SV *arg = sv_newmortal();
274 const char *const type = svclassnames[SvTYPE(temp)];
275 const IV iv = PTR2IV(temp);
277 target = newSVrv(arg, type);
278 sv_setiv(target, iv);
280 /* Need to keep our "temp" around as long as the target exists.
281 Simplest way seems to be to hang it from magic, and let that clear
282 it up. No vtable, so won't actually get in the way of anything. */
283 sv_magicext(target, temp, PERL_MAGIC_sv, NULL, NULL, 0);
284 /* magic object has had its reference count increased, so we must drop
291 make_warnings_object(pTHX_ const COP *const cop)
293 const STRLEN *const warnings = cop->cop_warnings;
294 const char *type = 0;
296 IV iv = sizeof(specialsv_list)/sizeof(SV*);
298 /* Counting down is deliberate. Before the split between make_sv_object
299 and make_warnings_obj there appeared to be a bug - Nullsv and pWARN_STD
300 were both 0, so you could never get a B::SPECIAL for pWARN_STD */
303 if ((SV*)warnings == specialsv_list[iv]) {
309 SV *arg = sv_newmortal();
310 sv_setiv(newSVrv(arg, type), iv);
313 /* B assumes that warnings are a regular SV. Seems easier to keep it
314 happy by making them into a regular SV. */
315 return make_temp_object(aTHX_ newSVpvn((char *)(warnings + 1), *warnings));
320 make_cop_io_object(pTHX_ COP *cop)
322 SV *const value = newSV(0);
324 Perl_emulate_cop_io(aTHX_ cop, value);
327 return make_sv_object(aTHX_ value);
330 return make_sv_object(aTHX_ NULL);
336 make_mg_object(pTHX_ MAGIC *mg)
338 SV *arg = sv_newmortal();
339 sv_setiv(newSVrv(arg, "B::MAGIC"), PTR2IV(mg));
344 cstring(pTHX_ SV *sv, bool perlstyle)
349 return newSVpvs_flags("0", SVs_TEMP);
351 sstr = newSVpvs_flags("\"", SVs_TEMP);
353 if (perlstyle && SvUTF8(sv)) {
354 SV *tmpsv = sv_newmortal(); /* Temporary SV to feed sv_uni_display */
355 const STRLEN len = SvCUR(sv);
356 const char *s = sv_uni_display(tmpsv, sv, 8*len, UNI_DISPLAY_QQ);
360 sv_catpvs(sstr, "\\\"");
362 sv_catpvs(sstr, "\\$");
364 sv_catpvs(sstr, "\\@");
367 if (strchr("nrftax\\",*(s+1)))
368 sv_catpvn(sstr, s++, 2);
370 sv_catpvs(sstr, "\\\\");
372 else /* should always be printable */
373 sv_catpvn(sstr, s, 1);
381 const char *s = SvPV(sv, len);
382 for (; len; len--, s++)
384 /* At least try a little for readability */
386 sv_catpvs(sstr, "\\\"");
388 sv_catpvs(sstr, "\\\\");
389 /* trigraphs - bleagh */
390 else if (!perlstyle && *s == '?' && len>=3 && s[1] == '?') {
391 Perl_sv_catpvf(aTHX_ sstr, "\\%03o", '?');
393 else if (perlstyle && *s == '$')
394 sv_catpvs(sstr, "\\$");
395 else if (perlstyle && *s == '@')
396 sv_catpvs(sstr, "\\@");
398 else if (isPRINT(*s))
400 else if (*s >= ' ' && *s < 127)
402 sv_catpvn(sstr, s, 1);
404 sv_catpvs(sstr, "\\n");
406 sv_catpvs(sstr, "\\r");
408 sv_catpvs(sstr, "\\t");
410 sv_catpvs(sstr, "\\a");
412 sv_catpvs(sstr, "\\b");
414 sv_catpvs(sstr, "\\f");
415 else if (!perlstyle && *s == '\v')
416 sv_catpvs(sstr, "\\v");
419 /* Don't want promotion of a signed -1 char in sprintf args */
420 const unsigned char c = (unsigned char) *s;
421 Perl_sv_catpvf(aTHX_ sstr, "\\%03o", c);
423 /* XXX Add line breaks if string is long */
426 sv_catpvs(sstr, "\"");
433 SV *sstr = newSVpvs_flags("'", SVs_TEMP);
434 const char *s = SvPV_nolen(sv);
435 /* Don't want promotion of a signed -1 char in sprintf args */
436 const unsigned char c = (unsigned char) *s;
439 sv_catpvs(sstr, "\\'");
441 sv_catpvs(sstr, "\\\\");
445 else if (c >= ' ' && c < 127)
447 sv_catpvn(sstr, s, 1);
449 sv_catpvs(sstr, "\\n");
451 sv_catpvs(sstr, "\\r");
453 sv_catpvs(sstr, "\\t");
455 sv_catpvs(sstr, "\\a");
457 sv_catpvs(sstr, "\\b");
459 sv_catpvs(sstr, "\\f");
461 sv_catpvs(sstr, "\\v");
463 Perl_sv_catpvf(aTHX_ sstr, "\\%03o", c);
464 sv_catpvs(sstr, "'");
468 #if PERL_VERSION >= 9
469 # define PMOP_pmreplstart(o) o->op_pmstashstartu.op_pmreplstart
470 # define PMOP_pmreplroot(o) o->op_pmreplrootu.op_pmreplroot
472 # define PMOP_pmreplstart(o) o->op_pmreplstart
473 # define PMOP_pmreplroot(o) o->op_pmreplroot
474 # define PMOP_pmpermflags(o) o->op_pmpermflags
475 # define PMOP_pmdynflags(o) o->op_pmdynflags
479 walkoptree(pTHX_ OP *o, const char *method, SV *ref)
484 const char *const classname = opclassnames[cc_opclass(aTHX_ o)];
487 /* Check that no-one has changed our reference, or is holding a reference
489 if (SvREFCNT(ref) == 1 && SvROK(ref) && SvTYPE(ref) == SVt_RV
490 && (object = SvRV(ref)) && SvREFCNT(object) == 1
491 && SvTYPE(object) == SVt_PVMG && SvIOK_only(object)
492 && !SvMAGICAL(object) && !SvMAGIC(object) && SvSTASH(object)) {
493 /* Looks good, so rebless it for the class we need: */
494 sv_bless(ref, gv_stashpv(classname, GV_ADD));
496 /* Need to make a new one. */
497 ref = sv_newmortal();
498 object = newSVrv(ref, classname);
500 sv_setiv(object, PTR2IV(o));
502 if (walkoptree_debug) {
506 perl_call_method("walkoptree_debug", G_DISCARD);
511 perl_call_method(method, G_DISCARD);
512 if (o && (o->op_flags & OPf_KIDS)) {
513 for (kid = ((UNOP*)o)->op_first; kid; kid = kid->op_sibling) {
514 ref = walkoptree(aTHX_ kid, method, ref);
517 if (o && (cc_opclass(aTHX_ o) == OPc_PMOP) && o->op_type != OP_PUSHRE
518 && (kid = PMOP_pmreplroot(cPMOPo)))
520 ref = walkoptree(aTHX_ kid, method, ref);
526 oplist(pTHX_ OP *o, SV **SP)
528 for(; o; o = o->op_next) {
529 #if PERL_VERSION >= 9
538 XPUSHs(make_op_object(aTHX_ o));
539 switch (o->op_type) {
541 SP = oplist(aTHX_ PMOP_pmreplstart(cPMOPo), SP);
544 if (o->op_flags & OPf_STACKED && o->op_flags & OPf_SPECIAL) {
545 OP *kid = cLISTOPo->op_first->op_sibling; /* pass pushmark */
546 kid = kUNOP->op_first; /* pass rv2gv */
547 kid = kUNOP->op_first; /* pass leave */
548 SP = oplist(aTHX_ kid->op_next, SP);
552 switch (PL_opargs[o->op_type] & OA_CLASS_MASK) {
554 SP = oplist(aTHX_ cLOGOPo->op_other, SP);
557 SP = oplist(aTHX_ cLOOPo->op_lastop, SP);
558 SP = oplist(aTHX_ cLOOPo->op_nextop, SP);
559 SP = oplist(aTHX_ cLOOPo->op_redoop, SP);
567 typedef UNOP *B__UNOP;
568 typedef BINOP *B__BINOP;
569 typedef LOGOP *B__LOGOP;
570 typedef LISTOP *B__LISTOP;
571 typedef PMOP *B__PMOP;
572 typedef SVOP *B__SVOP;
573 typedef PADOP *B__PADOP;
574 typedef PVOP *B__PVOP;
575 typedef LOOP *B__LOOP;
583 #if PERL_VERSION >= 11
584 typedef SV *B__REGEXP;
596 typedef MAGIC *B__MAGIC;
598 #if PERL_VERSION >= 9
599 typedef struct refcounted_he *B__RHE;
603 # define ASSIGN_COMMON_ALIAS(var) \
604 STMT_START { XSANY.any_i32 = offsetof(struct interpreter, var); } STMT_END
606 # define ASSIGN_COMMON_ALIAS(var) \
607 STMT_START { XSANY.any_ptr = (void *)&PL_##var; } STMT_END
610 /* This needs to be ALIASed in a custom way, hence can't easily be defined as
612 static XSPROTO(intrpvar_sv_common); /* prototype to pass -Wmissing-prototypes */
613 static XSPROTO(intrpvar_sv_common)
619 croak_xs_usage(cv, "");
621 ret = *(SV **)(XSANY.any_i32 + (char *)my_perl);
623 ret = *(SV **)(XSANY.any_ptr);
625 ST(0) = make_sv_object(aTHX_ ret);
629 #include "const-c.inc"
631 MODULE = B PACKAGE = B
633 INCLUDE: const-xs.inc
640 const char *file = __FILE__;
642 specialsv_list[0] = Nullsv;
643 specialsv_list[1] = &PL_sv_undef;
644 specialsv_list[2] = &PL_sv_yes;
645 specialsv_list[3] = &PL_sv_no;
646 specialsv_list[4] = (SV *) pWARN_ALL;
647 specialsv_list[5] = (SV *) pWARN_NONE;
648 specialsv_list[6] = (SV *) pWARN_STD;
650 cv = newXS("B::init_av", intrpvar_sv_common, file);
651 ASSIGN_COMMON_ALIAS(Iinitav);
652 cv = newXS("B::check_av", intrpvar_sv_common, file);
653 ASSIGN_COMMON_ALIAS(Icheckav_save);
654 #if PERL_VERSION >= 9
655 cv = newXS("B::unitcheck_av", intrpvar_sv_common, file);
656 ASSIGN_COMMON_ALIAS(Iunitcheckav_save);
658 cv = newXS("B::begin_av", intrpvar_sv_common, file);
659 ASSIGN_COMMON_ALIAS(Ibeginav_save);
660 cv = newXS("B::end_av", intrpvar_sv_common, file);
661 ASSIGN_COMMON_ALIAS(Iendav);
662 cv = newXS("B::main_cv", intrpvar_sv_common, file);
663 ASSIGN_COMMON_ALIAS(Imain_cv);
664 cv = newXS("B::inc_gv", intrpvar_sv_common, file);
665 ASSIGN_COMMON_ALIAS(Iincgv);
666 cv = newXS("B::defstash", intrpvar_sv_common, file);
667 ASSIGN_COMMON_ALIAS(Idefstash);
668 cv = newXS("B::curstash", intrpvar_sv_common, file);
669 ASSIGN_COMMON_ALIAS(Icurstash);
670 cv = newXS("B::formfeed", intrpvar_sv_common, file);
671 ASSIGN_COMMON_ALIAS(Iformfeed);
673 cv = newXS("B::regex_padav", intrpvar_sv_common, file);
674 ASSIGN_COMMON_ALIAS(Iregex_padav);
676 cv = newXS("B::warnhook", intrpvar_sv_common, file);
677 ASSIGN_COMMON_ALIAS(Iwarnhook);
678 cv = newXS("B::diehook", intrpvar_sv_common, file);
679 ASSIGN_COMMON_ALIAS(Idiehook);
685 RETVAL = PL_amagic_generation;
692 PUSHs(make_sv_object(aTHX_ (SV *)(PL_main_cv ? CvPADLIST(PL_main_cv)
693 : CvPADLIST(PL_compcv))));
701 PUSHs(make_sv_object(aTHX_ ix > 1 ? &PL_sv_yes
702 : ix < 1 ? &PL_sv_undef
710 PUSHs(make_op_object(aTHX_ ix ? PL_main_start : PL_main_root));
717 RETVAL = ix ? PL_dowarn : PL_sub_generation;
722 walkoptree(op, method)
726 (void) walkoptree(aTHX_ op, method, &PL_sv_undef);
729 walkoptree_debug(...)
732 RETVAL = walkoptree_debug;
733 if (items > 0 && SvTRUE(ST(1)))
734 walkoptree_debug = 1;
738 #define address(sv) PTR2IV(sv)
749 croak("argument is not a reference");
750 PUSHs(make_sv_object(aTHX_ SvRV(sv)));
759 ST(0) = sv_newmortal();
760 if (strncmp(name,"pp_",3) == 0)
762 for (i = 0; i < PL_maxo; i++)
764 if (strcmp(name, PL_op_name[i]) == 0)
770 sv_setiv(ST(0),result);
777 ST(0) = sv_newmortal();
778 if (opnum >= 0 && opnum < PL_maxo) {
779 sv_setpvs(ST(0), "pp_");
780 sv_catpv(ST(0), PL_op_name[opnum]);
789 const char *s = SvPVbyte(sv, len);
790 PERL_HASH(hash, s, len);
791 ST(0) = sv_2mortal(Perl_newSVpvf(aTHX_ "0x%"UVxf, (UV)hash));
793 #define cast_I32(foo) (I32)foo
815 PUSHs(ix == 2 ? cchar(aTHX_ sv) : cstring(aTHX_ sv, ix));
820 #if PERL_VERSION <= 8
821 # ifdef USE_5005THREADS
823 const STRLEN len = strlen(PL_threadsv_names);
826 for (i = 0; i < len; i++)
827 PUSHs(newSVpvn_flags(&PL_threadsv_names[i], 1, SVs_TEMP));
833 #define line_tp 0x20000
835 #define PADOFFSETp 0x40000
838 #define char_pp 0x70000
840 #define OP_next_ix OPp | offsetof(struct op, op_next)
841 #define OP_sibling_ix OPp | offsetof(struct op, op_sibling)
842 #define UNOP_first_ix OPp | offsetof(struct unop, op_first)
843 #define BINOP_last_ix OPp | offsetof(struct binop, op_last)
844 #define LOGOP_other_ix OPp | offsetof(struct logop, op_other)
845 #if PERL_VERSION >= 9
846 # define PMOP_pmreplstart_ix \
847 OPp | offsetof(struct pmop, op_pmstashstartu.op_pmreplstart)
849 # define PMOP_pmreplstart_ix OPp | offsetof(struct pmop, op_pmreplstart)
851 #define LOOP_redoop_ix OPp | offsetof(struct loop, op_redoop)
852 #define LOOP_nextop_ix OPp | offsetof(struct loop, op_nextop)
853 #define LOOP_lastop_ix OPp | offsetof(struct loop, op_lastop)
855 #define OP_targ_ix PADOFFSETp | offsetof(struct op, op_targ)
856 #define OP_flags_ix U8p | offsetof(struct op, op_flags)
857 #define OP_private_ix U8p | offsetof(struct op, op_private)
859 #define PMOP_pmflags_ix U32p | offsetof(struct pmop, op_pmflags)
862 #define PMOP_pmoffset_ix IVp | offsetof(struct pmop, op_pmoffset)
865 # Yes, B::SV::sv and B::SV::gv really do end up generating identical code.
866 #define SVOP_sv_ix SVp | offsetof(struct svop, op_sv)
867 #define SVOP_gv_ix SVp | offsetof(struct svop, op_sv)
869 #define PADOP_padix_ix PADOFFSETp | offsetof(struct padop, op_padix)
871 #define COP_seq_ix U32p | offsetof(struct cop, cop_seq)
872 #define COP_line_ix line_tp | offsetof(struct cop, cop_line)
873 #if PERL_VERSION >= 9
874 #define COP_hints_ix U32p | offsetof(struct cop, cop_hints)
876 #define COP_hints_ix U8p | offsetof(struct cop, op_private)
880 #define COP_stashpv_ix char_pp | offsetof(struct cop, cop_stashpv)
881 #define COP_file_ix char_pp | offsetof(struct cop, cop_file)
883 #define COP_stash_ix SVp | offsetof(struct cop, cop_stash)
884 #define COP_filegv_ix SVp | offsetof(struct cop, cop_filegv)
887 MODULE = B PACKAGE = B::OP
893 RETVAL = opsizes[cc_opclass(aTHX_ o)];
897 # The type checking code in B has always been identical for all OP types,
898 # irrespective of whether the action is actually defined on that OP.
904 B::OP::next = OP_next_ix
905 B::OP::sibling = OP_sibling_ix
906 B::OP::targ = OP_targ_ix
907 B::OP::flags = OP_flags_ix
908 B::OP::private = OP_private_ix
909 B::UNOP::first = UNOP_first_ix
910 B::BINOP::last = BINOP_last_ix
911 B::LOGOP::other = LOGOP_other_ix
912 B::PMOP::pmreplstart = PMOP_pmreplstart_ix
913 B::LOOP::redoop = LOOP_redoop_ix
914 B::LOOP::nextop = LOOP_nextop_ix
915 B::LOOP::lastop = LOOP_lastop_ix
916 B::PMOP::pmflags = PMOP_pmflags_ix
917 B::SVOP::sv = SVOP_sv_ix
918 B::SVOP::gv = SVOP_gv_ix
919 B::PADOP::padix = PADOP_padix_ix
920 B::COP::cop_seq = COP_seq_ix
921 B::COP::line = COP_line_ix
922 B::COP::hints = COP_hints_ix
927 ptr = (ix & 0xFFFF) + (char *)o;
928 switch ((U8)(ix >> 16)) {
929 case (U8)(OPp >> 16):
930 ret = make_op_object(aTHX_ *((OP **)ptr));
932 case (U8)(PADOFFSETp >> 16):
933 ret = sv_2mortal(newSVuv(*((PADOFFSET*)ptr)));
935 case (U8)(U8p >> 16):
936 ret = sv_2mortal(newSVuv(*((U8*)ptr)));
938 case (U8)(U32p >> 16):
939 ret = sv_2mortal(newSVuv(*((U32*)ptr)));
941 case (U8)(SVp >> 16):
942 ret = make_sv_object(aTHX_ *((SV **)ptr));
944 case (U8)(line_tp >> 16):
945 ret = sv_2mortal(newSVuv(*((line_t *)ptr)));
948 case (U8)(IVp >> 16):
949 ret = sv_2mortal(newSViv(*((IV*)ptr)));
951 case (U8)(char_pp >> 16):
952 ret = sv_2mortal(newSVpv(*((char **)ptr), 0));
965 RETVAL = (char *)(ix ? PL_op_desc : PL_op_name)[o->op_type];
974 SV *sv = newSVpvs_flags("PL_ppaddr[OP_", SVs_TEMP);
976 sv_catpv(sv, PL_op_name[o->op_type]);
977 for (i=13; (STRLEN)i < SvCUR(sv); ++i)
978 SvPVX(sv)[i] = toUPPER(SvPVX(sv)[i]);
982 #if PERL_VERSION >= 9
983 # These 3 are all bitfields, so we can't take their addresses.
996 RETVAL = o->op_spare;
1017 RETVAL = o->op_type;
1028 SP = oplist(aTHX_ o, SP);
1030 MODULE = B PACKAGE = B::LISTOP
1039 for (kid = o->op_first; kid; kid = kid->op_sibling)
1045 MODULE = B PACKAGE = B::PMOP PREFIX = PMOP_
1047 #if PERL_VERSION <= 8
1054 root = o->op_pmreplroot;
1055 /* OP_PUSHRE stores an SV* instead of an OP* in op_pmreplroot */
1056 if (o->op_type == OP_PUSHRE) {
1057 ST(0) = sv_newmortal();
1058 # ifdef USE_ITHREADS
1059 sv_setiv(ST(0), INT2PTR(PADOFFSET,root) );
1061 sv_setiv(newSVrv(ST(0), root ?
1062 svclassnames[SvTYPE((SV*)root)] : "B::SV"),
1067 ST(0) = make_op_object(aTHX_ root);
1076 if (o->op_type == OP_PUSHRE) {
1077 # ifdef USE_ITHREADS
1078 ST(0) = sv_newmortal();
1079 sv_setiv(ST(0), o->op_pmreplrootu.op_pmtargetoff);
1081 GV *const target = o->op_pmreplrootu.op_pmtargetgv;
1082 ST(0) = sv_newmortal();
1083 sv_setiv(newSVrv(ST(0), target ?
1084 svclassnames[SvTYPE((SV*)target)] : "B::SV"),
1089 OP *const root = o->op_pmreplrootu.op_pmreplroot;
1090 ST(0) = make_op_object(aTHX_ root);
1096 #define PMOP_pmstashpv(o) PmopSTASHPV(o);
1108 PUSHs(make_sv_object(aTHX_ (SV *) PmopSTASH(o)));
1112 #if PERL_VERSION < 9
1118 PUSHs(make_op_object(aTHX_ o->op_pmnext));
1138 ST(0) = sv_newmortal();
1140 #if PERL_VERSION >= 9
1142 sv_setuv(ST(0), RX_EXTFLAGS(rx));
1146 sv_setpvn(ST(0), RX_PRECOMP(rx), RX_PRELEN(rx));
1154 cv = newXS("B::PMOP::pmoffset", XS_B__OP_next, __FILE__);
1155 XSANY.any_i32 = PMOP_pmoffset_ix;
1156 cv = newXS("B::COP::stashpv", XS_B__OP_next, __FILE__);
1157 XSANY.any_i32 = COP_stashpv_ix;
1158 cv = newXS("B::COP::file", XS_B__OP_next, __FILE__);
1159 XSANY.any_i32 = COP_file_ix;
1161 cv = newXS("B::COP::stash", XS_B__OP_next, __FILE__);
1162 XSANY.any_i32 = COP_stash_ix;
1163 cv = newXS("B::COP::filegv", XS_B__OP_next, __FILE__);
1164 XSANY.any_i32 = COP_filegv_ix;
1166 #if PERL_VERSION >= 9
1167 cv = newXS("B::PMOP::reflags", XS_B__PMOP_precomp, __FILE__);
1172 MODULE = B PACKAGE = B::PADOP
1182 /* It happens that the output typemaps for B::SV and B::GV are
1183 identical. The "smarts" are in make_sv_object(), which determines
1184 which class to use based on SvTYPE(), rather than anything baked in
1187 ret = PAD_SVl(o->op_padix);
1188 if (ix && SvTYPE(ret) != SVt_PVGV)
1193 PUSHs(make_sv_object(aTHX_ ret));
1195 MODULE = B PACKAGE = B::PVOP
1202 * OP_TRANS uses op_pv to point to a table of 256 or >=258 shorts
1203 * whereas other PVOPs point to a null terminated string.
1205 if ((o->op_type == OP_TRANS || o->op_type == OP_TRANSR) &&
1206 (o->op_private & OPpTRANS_COMPLEMENT) &&
1207 !(o->op_private & OPpTRANS_DELETE))
1209 const short* const tbl = (short*)o->op_pv;
1210 const short entries = 257 + tbl[256];
1211 ST(0) = newSVpvn_flags(o->op_pv, entries * sizeof(short), SVs_TEMP);
1213 else if (o->op_type == OP_TRANS || o->op_type == OP_TRANSR) {
1214 ST(0) = newSVpvn_flags(o->op_pv, 256 * sizeof(short), SVs_TEMP);
1217 ST(0) = newSVpvn_flags(o->op_pv, strlen(o->op_pv), SVs_TEMP);
1219 #define COP_label(o) CopLABEL(o)
1220 #define COP_arybase(o) CopARYBASE_get(o)
1222 MODULE = B PACKAGE = B::COP PREFIX = COP_
1228 # Both pairs of accessors are provided for both ithreads and not, but for each,
1229 # one pair is direct structure access, and 1 pair "faked up" with a more complex
1230 # macro. We implement the direct structure access pair using the common code
1231 # above (B::OP::next)
1241 PUSHs(make_sv_object(aTHX_
1242 ix ? (SV *)CopFILEGV(o) : (SV *)CopSTASH(o)));
1252 RETVAL = ix ? CopFILE(o) : CopSTASHPV(o);
1268 #if PERL_VERSION >= 9
1269 ST(0) = ix ? make_cop_io_object(aTHX_ o) : make_warnings_object(aTHX_ o);
1271 ST(0) = make_sv_object(aTHX_ ix ? o->cop_io : o->cop_warnings);
1275 #if PERL_VERSION >= 9
1281 RETVAL = CopHINTHASH_get(o);
1287 MODULE = B PACKAGE = B::SV
1289 #define MAGICAL_FLAG_BITS (SVs_GMG|SVs_SMG|SVs_RMG)
1299 MAGICAL = MAGICAL_FLAG_BITS
1301 RETVAL = ix ? (SvFLAGS(sv) & (U32)ix) : SvREFCNT(sv);
1309 ST(0) = sv_2mortal(newRV(sv));
1312 MODULE = B PACKAGE = B::IV PREFIX = Sv
1318 MODULE = B PACKAGE = B::IV
1320 #define sv_SVp 0x00000
1321 #define sv_IVp 0x10000
1322 #define sv_UVp 0x20000
1323 #define sv_STRLENp 0x30000
1324 #define sv_U32p 0x40000
1325 #define sv_U8p 0x50000
1326 #define sv_char_pp 0x60000
1327 #define sv_NVp 0x70000
1328 #define sv_char_p 0x80000
1329 #define sv_SSize_tp 0x90000
1330 #define sv_I32p 0xA0000
1331 #define sv_U16p 0xB0000
1333 #define IV_ivx_ix sv_IVp | offsetof(struct xpviv, xiv_iv)
1334 #define IV_uvx_ix sv_UVp | offsetof(struct xpvuv, xuv_uv)
1335 #define NV_nvx_ix sv_NVp | offsetof(struct xpvnv, xnv_u.xnv_nv)
1337 #if PERL_VERSION >= 10
1338 #define NV_cop_seq_range_low_ix \
1339 sv_U32p | offsetof(struct xpvnv, xnv_u.xpad_cop_seq.xlow)
1340 #define NV_cop_seq_range_high_ix \
1341 sv_U32p | offsetof(struct xpvnv, xnv_u.xpad_cop_seq.xhigh)
1342 #define NV_parent_pad_index_ix \
1343 sv_U32p | offsetof(struct xpvnv, xnv_u.xpad_cop_seq.xlow)
1344 #define NV_parent_fakelex_flags_ix \
1345 sv_U32p | offsetof(struct xpvnv, xnv_u.xpad_cop_seq.xhigh)
1347 #define NV_cop_seq_range_low_ix \
1348 sv_NVp | offsetof(struct xpvnv, xnv_nv)
1349 #define NV_cop_seq_range_high_ix \
1350 sv_UVp | offsetof(struct xpvnv, xuv_uv)
1351 #define NV_parent_pad_index_ix \
1352 sv_NVp | offsetof(struct xpvnv, xnv_nv)
1353 #define NV_parent_fakelex_flags_ix \
1354 sv_UVp | offsetof(struct xpvnv, xuv_uv)
1357 #define PV_cur_ix sv_STRLENp | offsetof(struct xpv, xpv_cur)
1358 #define PV_len_ix sv_STRLENp | offsetof(struct xpv, xpv_len)
1360 #define PVMG_stash_ix sv_SVp | offsetof(struct xpvmg, xmg_stash)
1362 #if PERL_VERSION >= 10
1363 #define PVBM_useful_ix sv_I32p | offsetof(struct xpvgv, xiv_u.xivu_i32)
1364 #define PVBM_previous_ix sv_U32p | offsetof(struct xpvgv, xnv_u.xbm_s.xbm_previous)
1365 #define PVBM_rare_ix sv_U8p | offsetof(struct xpvgv, xnv_u.xbm_s.xbm_rare)
1367 #define PVBM_useful_ix sv_I32p | offsetof(struct xpvbm, xbm_useful)
1368 #define PVBM_previous_ix sv_U16p | offsetof(struct xpvbm, xbm_previous)
1369 #define PVBM_rare_ix sv_U8p | offsetof(struct xpvbm, xbm_rare)
1372 #define PVLV_targoff_ix sv_U32p | offsetof(struct xpvlv, xlv_targoff)
1373 #define PVLV_targlen_ix sv_U32p | offsetof(struct xpvlv, xlv_targlen)
1374 #define PVLV_targ_ix sv_SVp | offsetof(struct xpvlv, xlv_targ)
1375 #define PVLV_type_ix sv_char_p | offsetof(struct xpvlv, xlv_type)
1377 #if PERL_VERSION >= 10
1378 #define PVGV_stash_ix sv_SVp | offsetof(struct xpvgv, xnv_u.xgv_stash)
1379 #define PVGV_flags_ix sv_STRLENp | offsetof(struct xpvgv, xpv_cur)
1380 #define PVIO_lines_ix sv_IVp | offsetof(struct xpvio, xiv_iv)
1382 #define PVGV_stash_ix sv_SVp | offsetof(struct xpvgv, xgv_stash)
1383 #define PVGV_flags_ix sv_U8p | offsetof(struct xpvgv, xgv_flags)
1384 #define PVIO_lines_ix sv_IVp | offsetof(struct xpvio, xio_lines)
1387 #define PVIO_page_ix sv_IVp | offsetof(struct xpvio, xio_page)
1388 #define PVIO_page_len_ix sv_IVp | offsetof(struct xpvio, xio_page_len)
1389 #define PVIO_lines_left_ix sv_IVp | offsetof(struct xpvio, xio_lines_left)
1390 #define PVIO_top_name_ix sv_char_pp | offsetof(struct xpvio, xio_top_name)
1391 #define PVIO_top_gv_ix sv_SVp | offsetof(struct xpvio, xio_top_gv)
1392 #define PVIO_fmt_name_ix sv_char_pp | offsetof(struct xpvio, xio_fmt_name)
1393 #define PVIO_fmt_gv_ix sv_SVp | offsetof(struct xpvio, xio_fmt_gv)
1394 #define PVIO_bottom_name_ix sv_char_pp | offsetof(struct xpvio, xio_bottom_name)
1395 #define PVIO_bottom_gv_ix sv_SVp | offsetof(struct xpvio, xio_bottom_gv)
1396 #define PVIO_type_ix sv_char_p | offsetof(struct xpvio, xio_type)
1397 #define PVIO_flags_ix sv_U8p | offsetof(struct xpvio, xio_flags)
1399 #define PVAV_max_ix sv_SSize_tp | offsetof(struct xpvav, xav_max)
1401 #define PVFM_lines_ix sv_IVp | offsetof(struct xpvfm, xfm_lines)
1403 #define PVCV_stash_ix sv_SVp | offsetof(struct xpvcv, xcv_stash)
1404 #define PVCV_gv_ix sv_SVp | offsetof(struct xpvcv, xcv_gv)
1405 #define PVCV_file_ix sv_char_pp | offsetof(struct xpvcv, xcv_file)
1406 #define PVCV_depth_ix sv_I32p | offsetof(struct xpvcv, xcv_depth)
1407 #define PVCV_padlist_ix sv_SVp | offsetof(struct xpvcv, xcv_padlist)
1408 #define PVCV_outside_ix sv_SVp | offsetof(struct xpvcv, xcv_outside)
1409 #define PVCV_outside_seq_ix sv_U32p | offsetof(struct xpvcv, xcv_outside_seq)
1410 #define PVCV_flags_ix sv_U16p | offsetof(struct xpvcv, xcv_flags)
1412 #define PVHV_max_ix sv_STRLENp | offsetof(struct xpvhv, xhv_max)
1414 #if PERL_VERSION > 12
1415 #define PVHV_keys_ix sv_STRLENp | offsetof(struct xpvhv, xhv_keys)
1417 #define PVHV_keys_ix sv_IVp | offsetof(struct xpvhv, xhv_keys)
1420 # The type checking code in B has always been identical for all SV types,
1421 # irrespective of whether the action is actually defined on that SV.
1422 # We should fix this
1427 B::IV::IVX = IV_ivx_ix
1428 B::IV::UVX = IV_uvx_ix
1429 B::NV::NVX = NV_nvx_ix
1430 B::NV::COP_SEQ_RANGE_LOW = NV_cop_seq_range_low_ix
1431 B::NV::COP_SEQ_RANGE_HIGH = NV_cop_seq_range_high_ix
1432 B::NV::PARENT_PAD_INDEX = NV_parent_pad_index_ix
1433 B::NV::PARENT_FAKELEX_FLAGS = NV_parent_fakelex_flags_ix
1434 B::PV::CUR = PV_cur_ix
1435 B::PV::LEN = PV_len_ix
1436 B::PVMG::SvSTASH = PVMG_stash_ix
1437 B::PVLV::TARGOFF = PVLV_targoff_ix
1438 B::PVLV::TARGLEN = PVLV_targlen_ix
1439 B::PVLV::TARG = PVLV_targ_ix
1440 B::PVLV::TYPE = PVLV_type_ix
1441 B::GV::STASH = PVGV_stash_ix
1442 B::GV::GvFLAGS = PVGV_flags_ix
1443 B::BM::USEFUL = PVBM_useful_ix
1444 B::BM::PREVIOUS = PVBM_previous_ix
1445 B::BM::RARE = PVBM_rare_ix
1446 B::IO::LINES = PVIO_lines_ix
1447 B::IO::PAGE = PVIO_page_ix
1448 B::IO::PAGE_LEN = PVIO_page_len_ix
1449 B::IO::LINES_LEFT = PVIO_lines_left_ix
1450 B::IO::TOP_NAME = PVIO_top_name_ix
1451 B::IO::TOP_GV = PVIO_top_gv_ix
1452 B::IO::FMT_NAME = PVIO_fmt_name_ix
1453 B::IO::FMT_GV = PVIO_fmt_gv_ix
1454 B::IO::BOTTOM_NAME = PVIO_bottom_name_ix
1455 B::IO::BOTTOM_GV = PVIO_bottom_gv_ix
1456 B::IO::IoTYPE = PVIO_type_ix
1457 B::IO::IoFLAGS = PVIO_flags_ix
1458 B::AV::MAX = PVAV_max_ix
1459 B::FM::LINES = PVFM_lines_ix
1460 B::CV::STASH = PVCV_stash_ix
1461 B::CV::GV = PVCV_gv_ix
1462 B::CV::FILE = PVCV_file_ix
1463 B::CV::DEPTH = PVCV_depth_ix
1464 B::CV::PADLIST = PVCV_padlist_ix
1465 B::CV::OUTSIDE = PVCV_outside_ix
1466 B::CV::OUTSIDE_SEQ = PVCV_outside_seq_ix
1467 B::CV::CvFLAGS = PVCV_flags_ix
1468 B::HV::MAX = PVHV_max_ix
1469 B::HV::KEYS = PVHV_keys_ix
1474 ptr = (ix & 0xFFFF) + (char *)SvANY(sv);
1475 switch ((U8)(ix >> 16)) {
1476 case (U8)(sv_SVp >> 16):
1477 ret = make_sv_object(aTHX_ *((SV **)ptr));
1479 case (U8)(sv_IVp >> 16):
1480 ret = sv_2mortal(newSViv(*((IV *)ptr)));
1482 case (U8)(sv_UVp >> 16):
1483 ret = sv_2mortal(newSVuv(*((UV *)ptr)));
1485 case (U8)(sv_STRLENp >> 16):
1486 ret = sv_2mortal(newSVuv(*((STRLEN *)ptr)));
1488 case (U8)(sv_U32p >> 16):
1489 ret = sv_2mortal(newSVuv(*((U32 *)ptr)));
1491 case (U8)(sv_U8p >> 16):
1492 ret = sv_2mortal(newSVuv(*((U8 *)ptr)));
1494 case (U8)(sv_char_pp >> 16):
1495 ret = sv_2mortal(newSVpv(*((char **)ptr), 0));
1497 case (U8)(sv_NVp >> 16):
1498 ret = sv_2mortal(newSVnv(*((NV *)ptr)));
1500 case (U8)(sv_char_p >> 16):
1501 ret = newSVpvn_flags((char *)ptr, 1, SVs_TEMP);
1503 case (U8)(sv_SSize_tp >> 16):
1504 ret = sv_2mortal(newSViv(*((SSize_t *)ptr)));
1506 case (U8)(sv_I32p >> 16):
1507 ret = sv_2mortal(newSVuv(*((I32 *)ptr)));
1509 case (U8)(sv_U16p >> 16):
1510 ret = sv_2mortal(newSVuv(*((U16 *)ptr)));
1523 ST(0) = boolSV((I32)SvIVX(sv) != SvIVX(sv));
1524 } else if (sizeof(IV) == 8) {
1526 const IV iv = SvIVX(sv);
1528 * The following way of spelling 32 is to stop compilers on
1529 * 32-bit architectures from moaning about the shift count
1530 * being >= the width of the type. Such architectures don't
1531 * reach this code anyway (unless sizeof(IV) > 8 but then
1532 * everything else breaks too so I'm not fussed at the moment).
1535 wp[0] = htonl(((UV)iv) >> (sizeof(UV)*4));
1537 wp[0] = htonl(((U32)iv) >> (sizeof(UV)*4));
1539 wp[1] = htonl(iv & 0xffffffff);
1540 ST(0) = newSVpvn_flags((char *)wp, 8, SVs_TEMP);
1542 U32 w = htonl((U32)SvIVX(sv));
1543 ST(0) = newSVpvn_flags((char *)&w, 4, SVs_TEMP);
1546 MODULE = B PACKAGE = B::NV PREFIX = Sv
1552 #if PERL_VERSION < 11
1554 MODULE = B PACKAGE = B::RV PREFIX = Sv
1560 PUSHs(make_sv_object(aTHX_ SvRV(sv)));
1564 MODULE = B PACKAGE = B::REGEXP
1573 PUSHs(newSVpvn_flags(RX_PRECOMP(sv), RX_PRELEN(sv), SVs_TEMP));
1576 /* FIXME - can we code this method more efficiently? */
1582 MODULE = B PACKAGE = B::PV
1589 croak( "argument is not SvROK" );
1590 PUSHs(make_sv_object(aTHX_ SvRV(sv)));
1606 /* Boyer-Moore table is just after string and its safety-margin \0 */
1607 p += len + PERL_FBM_TABLE_OFFSET;
1609 } else if (ix == 2) {
1610 /* This used to read 257. I think that that was buggy - should have
1611 been 258. (The "\0", the flags byte, and 256 for the table. Not
1612 that anything anywhere calls this method. NWC. */
1613 /* Also, the start pointer has always been SvPVX(sv). Surely it
1614 should be SvPVX(sv) + SvCUR(sv)? The code has faithfully been
1615 refactored with this behaviour, since PVBM was added in
1616 651aa52ea1faa806. */
1617 p = SvPVX_const(sv);
1618 len = SvCUR(sv) + (SvVALID(sv) ? 256 + PERL_FBM_TABLE_OFFSET : 0);
1622 } else if (SvPOK(sv)) {
1624 p = SvPVX_const(sv);
1626 #if PERL_VERSION < 10
1627 /* Before 5.10 (well 931b58fb28fa5ca7), PAD_COMPNAME_GEN was stored
1628 in SvCUR(), which meant we had to attempt this special casing
1629 to avoid tripping up over variable names in the pads. */
1630 if((SvLEN(sv) && len >= SvLEN(sv))) {
1631 /* It claims to be longer than the space allocated for it -
1632 presuambly it's a variable name in the pad */
1638 /* XXX for backward compatibility, but should fail */
1639 /* croak( "argument is not SvPOK" ); */
1642 ST(0) = newSVpvn_flags(p, len, SVs_TEMP | utf8);
1644 MODULE = B PACKAGE = B::PVMG
1649 MAGIC * mg = NO_INIT
1651 for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic)
1652 XPUSHs(make_mg_object(aTHX_ mg));
1654 MODULE = B PACKAGE = B::MAGIC
1671 XPUSHs(mg->mg_moremagic ? make_mg_object(aTHX_ mg->mg_moremagic)
1675 mPUSHu(mg->mg_private);
1678 PUSHs(newSVpvn_flags(&(mg->mg_type), 1, SVs_TEMP));
1681 mPUSHu(mg->mg_flags);
1687 PUSHs(make_sv_object(aTHX_ mg->mg_obj));
1691 if (mg->mg_len >= 0) {
1692 PUSHs(newSVpvn_flags(mg->mg_ptr, mg->mg_len, SVs_TEMP));
1693 } else if (mg->mg_len == HEf_SVKEY) {
1694 PUSHs(make_sv_object(aTHX_ (SV*)mg->mg_ptr));
1696 PUSHs(sv_newmortal());
1698 PUSHs(sv_newmortal());
1701 if(mg->mg_type == PERL_MAGIC_qr) {
1702 mPUSHi(PTR2IV(mg->mg_obj));
1704 croak("REGEX is only meaningful on r-magic");
1708 if (mg->mg_type == PERL_MAGIC_qr) {
1709 REGEXP *rx = (REGEXP *)mg->mg_obj;
1710 PUSHs(newSVpvn_flags(rx ? RX_PRECOMP(rx) : NULL,
1711 rx ? RX_PRELEN(rx) : 0, SVs_TEMP));
1713 croak( "precomp is only meaningful on r-magic" );
1718 MODULE = B PACKAGE = B::GV PREFIX = Gv
1727 #if PERL_VERSION >= 10
1728 ST(0) = sv_2mortal(newSVhek(!ix ? GvNAME_HEK(gv)
1729 : (ix == 1 ? GvFILE_HEK(gv)
1730 : HvNAME_HEK((HV *)gv))));
1732 ST(0) = !ix ? newSVpvn_flags(GvNAME(gv), GvNAMELEN(gv), SVs_TEMP)
1733 : sv_2mortal(newSVpv(ix == 1 ? GvFILE(gv) : HvNAME((HV *)gv), 0))
1743 #if PERL_VERSION >= 9
1744 RETVAL = isGV_with_GP(gv) ? TRUE : FALSE;
1746 RETVAL = TRUE; /* In 5.8 and earlier they all are. */
1749 RETVAL = GvGP(gv) == Null(GP*);
1758 #define GP_sv_ix SVp | offsetof(struct gp, gp_sv)
1759 #define GP_io_ix SVp | offsetof(struct gp, gp_io)
1760 #define GP_cv_ix SVp | offsetof(struct gp, gp_cv)
1761 #define GP_cvgen_ix U32p | offsetof(struct gp, gp_cvgen)
1762 #define GP_refcnt_ix U32p | offsetof(struct gp, gp_refcnt)
1763 #define GP_hv_ix SVp | offsetof(struct gp, gp_hv)
1764 #define GP_av_ix SVp | offsetof(struct gp, gp_av)
1765 #define GP_form_ix SVp | offsetof(struct gp, gp_form)
1766 #define GP_egv_ix SVp | offsetof(struct gp, gp_egv)
1767 #define GP_line_ix line_tp | offsetof(struct gp, gp_line)
1777 GvREFCNT = GP_refcnt_ix
1790 const GV *const gv = CvGV(cv);
1791 Perl_croak(aTHX_ "NULL gp in B::GV::%s", gv ? GvNAME(gv) : "???");
1793 ptr = (ix & 0xFFFF) + (char *)gp;
1794 switch ((U8)(ix >> 16)) {
1795 case (U8)(SVp >> 16):
1796 ret = make_sv_object(aTHX_ *((SV **)ptr));
1798 case (U8)(U32p >> 16):
1799 ret = sv_2mortal(newSVuv(*((U32*)ptr)));
1801 case (U8)(line_tp >> 16):
1802 ret = sv_2mortal(newSVuv(*((line_t *)ptr)));
1812 PUSHs(make_sv_object(aTHX_ (SV *)GvFILEGV(gv)));
1814 MODULE = B PACKAGE = B::IO PREFIX = Io
1816 #if PERL_VERSION <= 8
1831 if( strEQ( name, "stdin" ) ) {
1832 handle = PerlIO_stdin();
1834 else if( strEQ( name, "stdout" ) ) {
1835 handle = PerlIO_stdout();
1837 else if( strEQ( name, "stderr" ) ) {
1838 handle = PerlIO_stderr();
1841 croak( "Invalid value '%s'", name );
1843 RETVAL = handle == IoIFP(io);
1847 MODULE = B PACKAGE = B::AV PREFIX = Av
1857 if (AvFILL(av) >= 0) {
1858 SV **svp = AvARRAY(av);
1860 for (i = 0; i <= AvFILL(av); i++)
1861 XPUSHs(make_sv_object(aTHX_ svp[i]));
1869 if (idx >= 0 && AvFILL(av) >= 0 && idx <= AvFILL(av))
1870 XPUSHs(make_sv_object(aTHX_ (AvARRAY(av)[idx])));
1872 XPUSHs(make_sv_object(aTHX_ NULL));
1874 #if PERL_VERSION < 9
1876 #define AvOFF(av) ((XPVAV*)SvANY(av))->xof_off
1882 MODULE = B PACKAGE = B::AV
1890 MODULE = B PACKAGE = B::CV PREFIX = Cv
1902 PUSHs(make_op_object(aTHX_ CvISXSUB(cv) ? NULL
1903 : ix ? CvROOT(cv) : CvSTART(cv)));
1911 ST(0) = ix && CvCONST(cv)
1912 ? make_sv_object(aTHX_ (SV *)CvXSUBANY(cv).any_ptr)
1913 : sv_2mortal(newSViv(CvISXSUB(cv)
1914 ? (ix ? CvXSUBANY(cv).any_iv
1915 : PTR2IV(CvXSUB(cv)))
1922 PUSHs(make_sv_object(aTHX_ (SV *)cv_const_sv(cv)));
1924 MODULE = B PACKAGE = B::HV PREFIX = Hv
1934 #if PERL_VERSION < 9
1940 PUSHs(make_op_object(aTHX_ HvPMROOT(hv)));
1948 if (HvKEYS(hv) > 0) {
1952 (void)hv_iterinit(hv);
1953 EXTEND(sp, HvKEYS(hv) * 2);
1954 while ((sv = hv_iternextsv(hv, &key, &len))) {
1956 PUSHs(make_sv_object(aTHX_ sv));
1960 MODULE = B PACKAGE = B::HE PREFIX = He
1968 PUSHs(make_sv_object(aTHX_ ix ? HeSVKEY_force(he) : HeVAL(he)));
1974 MODULE = B PACKAGE = B::RHE
1976 #if PERL_VERSION >= 9
1982 RETVAL = newRV( (SV*)cophh_2hv(h, 0) );