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)
122 return (o->op_flags & OPf_KIDS) ? OPc_UNOP : OPc_BASEOP;
124 if (o->op_type == OP_SASSIGN)
125 return ((o->op_private & OPpASSIGN_BACKWARDS) ? OPc_UNOP : OPc_BINOP);
127 if (o->op_type == OP_AELEMFAST) {
128 #if PERL_VERSION <= 14
129 if (o->op_flags & OPf_SPECIAL)
141 if (o->op_type == OP_GV || o->op_type == OP_GVSV ||
142 o->op_type == OP_RCATLINE)
146 if (o->op_type == OP_CUSTOM)
149 switch (OP_CLASS(o)) {
174 case OA_PVOP_OR_SVOP:
176 * Character translations (tr///) are usually a PVOP, keeping a
177 * pointer to a table of shorts used to look up translations.
178 * Under utf8, however, a simple table isn't practical; instead,
179 * the OP is an SVOP (or, under threads, a PADOP),
180 * and the SV is a reference to a swash
181 * (i.e., an RV pointing to an HV).
184 (o->op_private & (OPpTRANS_TO_UTF|OPpTRANS_FROM_UTF))
186 #if defined(USE_ITHREADS) \
187 && (PERL_VERSION > 8 || (PERL_VERSION == 8 && PERL_SUBVERSION >= 9))
188 ? OPc_PADOP : OPc_PVOP;
190 ? OPc_SVOP : OPc_PVOP;
199 case OA_BASEOP_OR_UNOP:
201 * UNI(OP_foo) in toke.c returns token UNI or FUNC1 depending on
202 * whether parens were seen. perly.y uses OPf_SPECIAL to
203 * signal whether a BASEOP had empty parens or none.
204 * Some other UNOPs are created later, though, so the best
205 * test is OPf_KIDS, which is set in newUNOP.
207 return (o->op_flags & OPf_KIDS) ? OPc_UNOP : OPc_BASEOP;
211 * The file stat OPs are created via UNI(OP_foo) in toke.c but use
212 * the OPf_REF flag to distinguish between OP types instead of the
213 * usual OPf_SPECIAL flag. As usual, if OPf_KIDS is set, then we
214 * return OPc_UNOP so that walkoptree can find our children. If
215 * OPf_KIDS is not set then we check OPf_REF. Without OPf_REF set
216 * (no argument to the operator) it's an OP; with OPf_REF set it's
217 * an SVOP (and op_sv is the GV for the filehandle argument).
219 return ((o->op_flags & OPf_KIDS) ? OPc_UNOP :
221 (o->op_flags & OPf_REF) ? OPc_PADOP : OPc_BASEOP);
223 (o->op_flags & OPf_REF) ? OPc_SVOP : OPc_BASEOP);
227 * next, last, redo, dump and goto use OPf_SPECIAL to indicate that a
228 * label was omitted (in which case it's a BASEOP) or else a term was
229 * seen. In this last case, all except goto are definitely PVOP but
230 * goto is either a PVOP (with an ordinary constant label), an UNOP
231 * with OPf_STACKED (with a non-constant non-sub) or an UNOP for
232 * OP_REFGEN (with goto &sub) in which case OPf_STACKED also seems to
235 if (o->op_flags & OPf_STACKED)
237 else if (o->op_flags & OPf_SPECIAL)
242 warn("can't determine class of operator %s, assuming BASEOP\n",
248 make_op_object(pTHX_ const OP *o)
250 SV *opsv = sv_newmortal();
251 sv_setiv(newSVrv(opsv, opclassnames[cc_opclass(aTHX_ o)]), PTR2IV(o));
256 make_sv_object(pTHX_ SV *sv)
258 SV *const arg = sv_newmortal();
259 const char *type = 0;
263 for (iv = 0; iv < (IV)(sizeof(specialsv_list)/sizeof(SV*)); iv++) {
264 if (sv == specialsv_list[iv]) {
270 type = svclassnames[SvTYPE(sv)];
273 sv_setiv(newSVrv(arg, type), iv);
277 #if PERL_VERSION >= 9
279 make_temp_object(pTHX_ SV *temp)
282 SV *arg = sv_newmortal();
283 const char *const type = svclassnames[SvTYPE(temp)];
284 const IV iv = PTR2IV(temp);
286 target = newSVrv(arg, type);
287 sv_setiv(target, iv);
289 /* Need to keep our "temp" around as long as the target exists.
290 Simplest way seems to be to hang it from magic, and let that clear
291 it up. No vtable, so won't actually get in the way of anything. */
292 sv_magicext(target, temp, PERL_MAGIC_sv, NULL, NULL, 0);
293 /* magic object has had its reference count increased, so we must drop
300 make_warnings_object(pTHX_ const COP *const cop)
302 const STRLEN *const warnings = cop->cop_warnings;
303 const char *type = 0;
305 IV iv = sizeof(specialsv_list)/sizeof(SV*);
307 /* Counting down is deliberate. Before the split between make_sv_object
308 and make_warnings_obj there appeared to be a bug - Nullsv and pWARN_STD
309 were both 0, so you could never get a B::SPECIAL for pWARN_STD */
312 if ((SV*)warnings == specialsv_list[iv]) {
318 SV *arg = sv_newmortal();
319 sv_setiv(newSVrv(arg, type), iv);
322 /* B assumes that warnings are a regular SV. Seems easier to keep it
323 happy by making them into a regular SV. */
324 return make_temp_object(aTHX_ newSVpvn((char *)(warnings + 1), *warnings));
329 make_cop_io_object(pTHX_ COP *cop)
331 SV *const value = newSV(0);
333 Perl_emulate_cop_io(aTHX_ cop, value);
336 return make_sv_object(aTHX_ value);
339 return make_sv_object(aTHX_ NULL);
345 make_mg_object(pTHX_ MAGIC *mg)
347 SV *arg = sv_newmortal();
348 sv_setiv(newSVrv(arg, "B::MAGIC"), PTR2IV(mg));
353 cstring(pTHX_ SV *sv, bool perlstyle)
358 return newSVpvs_flags("0", SVs_TEMP);
360 sstr = newSVpvs_flags("\"", SVs_TEMP);
362 if (perlstyle && SvUTF8(sv)) {
363 SV *tmpsv = sv_newmortal(); /* Temporary SV to feed sv_uni_display */
364 const STRLEN len = SvCUR(sv);
365 const char *s = sv_uni_display(tmpsv, sv, 8*len, UNI_DISPLAY_QQ);
369 sv_catpvs(sstr, "\\\"");
371 sv_catpvs(sstr, "\\$");
373 sv_catpvs(sstr, "\\@");
376 if (strchr("nrftax\\",*(s+1)))
377 sv_catpvn(sstr, s++, 2);
379 sv_catpvs(sstr, "\\\\");
381 else /* should always be printable */
382 sv_catpvn(sstr, s, 1);
390 const char *s = SvPV(sv, len);
391 for (; len; len--, s++)
393 /* At least try a little for readability */
395 sv_catpvs(sstr, "\\\"");
397 sv_catpvs(sstr, "\\\\");
398 /* trigraphs - bleagh */
399 else if (!perlstyle && *s == '?' && len>=3 && s[1] == '?') {
400 Perl_sv_catpvf(aTHX_ sstr, "\\%03o", '?');
402 else if (perlstyle && *s == '$')
403 sv_catpvs(sstr, "\\$");
404 else if (perlstyle && *s == '@')
405 sv_catpvs(sstr, "\\@");
407 else if (isPRINT(*s))
409 else if (*s >= ' ' && *s < 127)
411 sv_catpvn(sstr, s, 1);
413 sv_catpvs(sstr, "\\n");
415 sv_catpvs(sstr, "\\r");
417 sv_catpvs(sstr, "\\t");
419 sv_catpvs(sstr, "\\a");
421 sv_catpvs(sstr, "\\b");
423 sv_catpvs(sstr, "\\f");
424 else if (!perlstyle && *s == '\v')
425 sv_catpvs(sstr, "\\v");
428 /* Don't want promotion of a signed -1 char in sprintf args */
429 const unsigned char c = (unsigned char) *s;
430 Perl_sv_catpvf(aTHX_ sstr, "\\%03o", c);
432 /* XXX Add line breaks if string is long */
435 sv_catpvs(sstr, "\"");
442 SV *sstr = newSVpvs_flags("'", SVs_TEMP);
443 const char *s = SvPV_nolen(sv);
444 /* Don't want promotion of a signed -1 char in sprintf args */
445 const unsigned char c = (unsigned char) *s;
448 sv_catpvs(sstr, "\\'");
450 sv_catpvs(sstr, "\\\\");
454 else if (c >= ' ' && c < 127)
456 sv_catpvn(sstr, s, 1);
458 sv_catpvs(sstr, "\\n");
460 sv_catpvs(sstr, "\\r");
462 sv_catpvs(sstr, "\\t");
464 sv_catpvs(sstr, "\\a");
466 sv_catpvs(sstr, "\\b");
468 sv_catpvs(sstr, "\\f");
470 sv_catpvs(sstr, "\\v");
472 Perl_sv_catpvf(aTHX_ sstr, "\\%03o", c);
473 sv_catpvs(sstr, "'");
477 #if PERL_VERSION >= 9
478 # define PMOP_pmreplstart(o) o->op_pmstashstartu.op_pmreplstart
479 # define PMOP_pmreplroot(o) o->op_pmreplrootu.op_pmreplroot
481 # define PMOP_pmreplstart(o) o->op_pmreplstart
482 # define PMOP_pmreplroot(o) o->op_pmreplroot
483 # define PMOP_pmpermflags(o) o->op_pmpermflags
484 # define PMOP_pmdynflags(o) o->op_pmdynflags
488 walkoptree(pTHX_ OP *o, const char *method, SV *ref)
493 const char *const classname = opclassnames[cc_opclass(aTHX_ o)];
496 /* Check that no-one has changed our reference, or is holding a reference
498 if (SvREFCNT(ref) == 1 && SvROK(ref) && SvTYPE(ref) == SVt_RV
499 && (object = SvRV(ref)) && SvREFCNT(object) == 1
500 && SvTYPE(object) == SVt_PVMG && SvIOK_only(object)
501 && !SvMAGICAL(object) && !SvMAGIC(object) && SvSTASH(object)) {
502 /* Looks good, so rebless it for the class we need: */
503 sv_bless(ref, gv_stashpv(classname, GV_ADD));
505 /* Need to make a new one. */
506 ref = sv_newmortal();
507 object = newSVrv(ref, classname);
509 sv_setiv(object, PTR2IV(o));
511 if (walkoptree_debug) {
515 perl_call_method("walkoptree_debug", G_DISCARD);
520 perl_call_method(method, G_DISCARD);
521 if (o && (o->op_flags & OPf_KIDS)) {
522 for (kid = ((UNOP*)o)->op_first; kid; kid = kid->op_sibling) {
523 ref = walkoptree(aTHX_ kid, method, ref);
526 if (o && (cc_opclass(aTHX_ o) == OPc_PMOP) && o->op_type != OP_PUSHRE
527 && (kid = PMOP_pmreplroot(cPMOPo)))
529 ref = walkoptree(aTHX_ kid, method, ref);
535 oplist(pTHX_ OP *o, SV **SP)
537 for(; o; o = o->op_next) {
538 #if PERL_VERSION >= 9
547 XPUSHs(make_op_object(aTHX_ o));
548 switch (o->op_type) {
550 SP = oplist(aTHX_ PMOP_pmreplstart(cPMOPo), SP);
553 if (o->op_flags & OPf_STACKED && o->op_flags & OPf_SPECIAL) {
554 OP *kid = cLISTOPo->op_first->op_sibling; /* pass pushmark */
555 kid = kUNOP->op_first; /* pass rv2gv */
556 kid = kUNOP->op_first; /* pass leave */
557 SP = oplist(aTHX_ kid->op_next, SP);
561 switch (PL_opargs[o->op_type] & OA_CLASS_MASK) {
563 SP = oplist(aTHX_ cLOGOPo->op_other, SP);
566 SP = oplist(aTHX_ cLOOPo->op_lastop, SP);
567 SP = oplist(aTHX_ cLOOPo->op_nextop, SP);
568 SP = oplist(aTHX_ cLOOPo->op_redoop, SP);
576 typedef UNOP *B__UNOP;
577 typedef BINOP *B__BINOP;
578 typedef LOGOP *B__LOGOP;
579 typedef LISTOP *B__LISTOP;
580 typedef PMOP *B__PMOP;
581 typedef SVOP *B__SVOP;
582 typedef PADOP *B__PADOP;
583 typedef PVOP *B__PVOP;
584 typedef LOOP *B__LOOP;
592 #if PERL_VERSION >= 11
593 typedef SV *B__REGEXP;
605 typedef MAGIC *B__MAGIC;
607 #if PERL_VERSION >= 9
608 typedef struct refcounted_he *B__RHE;
612 # define ASSIGN_COMMON_ALIAS(prefix, var) \
613 STMT_START { XSANY.any_i32 = offsetof(struct interpreter, prefix##var); } STMT_END
615 # define ASSIGN_COMMON_ALIAS(prefix, var) \
616 STMT_START { XSANY.any_ptr = (void *)&PL_##var; } STMT_END
619 /* This needs to be ALIASed in a custom way, hence can't easily be defined as
621 static XSPROTO(intrpvar_sv_common); /* prototype to pass -Wmissing-prototypes */
622 static XSPROTO(intrpvar_sv_common)
628 croak_xs_usage(cv, "");
630 ret = *(SV **)(XSANY.any_i32 + (char *)my_perl);
632 ret = *(SV **)(XSANY.any_ptr);
634 ST(0) = make_sv_object(aTHX_ ret);
638 #include "const-c.inc"
640 MODULE = B PACKAGE = B
642 INCLUDE: const-xs.inc
649 const char *file = __FILE__;
651 specialsv_list[0] = Nullsv;
652 specialsv_list[1] = &PL_sv_undef;
653 specialsv_list[2] = &PL_sv_yes;
654 specialsv_list[3] = &PL_sv_no;
655 specialsv_list[4] = (SV *) pWARN_ALL;
656 specialsv_list[5] = (SV *) pWARN_NONE;
657 specialsv_list[6] = (SV *) pWARN_STD;
659 cv = newXS("B::init_av", intrpvar_sv_common, file);
660 ASSIGN_COMMON_ALIAS(I, initav);
661 cv = newXS("B::check_av", intrpvar_sv_common, file);
662 ASSIGN_COMMON_ALIAS(I, checkav_save);
663 #if PERL_VERSION >= 9
664 cv = newXS("B::unitcheck_av", intrpvar_sv_common, file);
665 ASSIGN_COMMON_ALIAS(I, unitcheckav_save);
667 cv = newXS("B::begin_av", intrpvar_sv_common, file);
668 ASSIGN_COMMON_ALIAS(I, beginav_save);
669 cv = newXS("B::end_av", intrpvar_sv_common, file);
670 ASSIGN_COMMON_ALIAS(I, endav);
671 cv = newXS("B::main_cv", intrpvar_sv_common, file);
672 ASSIGN_COMMON_ALIAS(I, main_cv);
673 cv = newXS("B::inc_gv", intrpvar_sv_common, file);
674 ASSIGN_COMMON_ALIAS(I, incgv);
675 cv = newXS("B::defstash", intrpvar_sv_common, file);
676 ASSIGN_COMMON_ALIAS(I, defstash);
677 cv = newXS("B::curstash", intrpvar_sv_common, file);
678 ASSIGN_COMMON_ALIAS(I, curstash);
679 cv = newXS("B::formfeed", intrpvar_sv_common, file);
680 ASSIGN_COMMON_ALIAS(I, formfeed);
682 cv = newXS("B::regex_padav", intrpvar_sv_common, file);
683 ASSIGN_COMMON_ALIAS(I, regex_padav);
685 cv = newXS("B::warnhook", intrpvar_sv_common, file);
686 ASSIGN_COMMON_ALIAS(I, warnhook);
687 cv = newXS("B::diehook", intrpvar_sv_common, file);
688 ASSIGN_COMMON_ALIAS(I, diehook);
694 RETVAL = PL_amagic_generation;
701 PUSHs(make_sv_object(aTHX_ (SV *)(PL_main_cv ? CvPADLIST(PL_main_cv)
702 : CvPADLIST(PL_compcv))));
710 PUSHs(make_sv_object(aTHX_ ix > 1 ? &PL_sv_yes
711 : ix < 1 ? &PL_sv_undef
719 PUSHs(make_op_object(aTHX_ ix ? PL_main_start : PL_main_root));
726 RETVAL = ix ? PL_dowarn : PL_sub_generation;
731 walkoptree(op, method)
735 (void) walkoptree(aTHX_ op, method, &PL_sv_undef);
738 walkoptree_debug(...)
741 RETVAL = walkoptree_debug;
742 if (items > 0 && SvTRUE(ST(1)))
743 walkoptree_debug = 1;
747 #define address(sv) PTR2IV(sv)
758 croak("argument is not a reference");
759 PUSHs(make_sv_object(aTHX_ SvRV(sv)));
768 ST(0) = sv_newmortal();
769 if (strncmp(name,"pp_",3) == 0)
771 for (i = 0; i < PL_maxo; i++)
773 if (strcmp(name, PL_op_name[i]) == 0)
779 sv_setiv(ST(0),result);
786 ST(0) = sv_newmortal();
787 if (opnum >= 0 && opnum < PL_maxo)
788 Perl_sv_setpvf(aTHX_ ST(0), "pp_%s", PL_op_name[opnum]);
796 const char *s = SvPVbyte(sv, len);
797 PERL_HASH(hash, s, len);
798 ST(0) = sv_2mortal(Perl_newSVpvf(aTHX_ "0x%"UVxf, (UV)hash));
800 #define cast_I32(foo) (I32)foo
822 PUSHs(ix == 2 ? cchar(aTHX_ sv) : cstring(aTHX_ sv, (bool)ix));
827 #if PERL_VERSION <= 8
828 # ifdef USE_5005THREADS
830 const STRLEN len = strlen(PL_threadsv_names);
833 for (i = 0; i < len; i++)
834 PUSHs(newSVpvn_flags(&PL_threadsv_names[i], 1, SVs_TEMP));
840 #define line_tp 0x20000
842 #define PADOFFSETp 0x40000
845 #define char_pp 0x70000
847 #define OP_next_ix OPp | offsetof(struct op, op_next)
848 #define OP_sibling_ix OPp | offsetof(struct op, op_sibling)
849 #define UNOP_first_ix OPp | offsetof(struct unop, op_first)
850 #define BINOP_last_ix OPp | offsetof(struct binop, op_last)
851 #define LOGOP_other_ix OPp | offsetof(struct logop, op_other)
852 #if PERL_VERSION >= 9
853 # define PMOP_pmreplstart_ix \
854 OPp | offsetof(struct pmop, op_pmstashstartu.op_pmreplstart)
856 # define PMOP_pmreplstart_ix OPp | offsetof(struct pmop, op_pmreplstart)
858 #define LOOP_redoop_ix OPp | offsetof(struct loop, op_redoop)
859 #define LOOP_nextop_ix OPp | offsetof(struct loop, op_nextop)
860 #define LOOP_lastop_ix OPp | offsetof(struct loop, op_lastop)
862 #define OP_targ_ix PADOFFSETp | offsetof(struct op, op_targ)
863 #define OP_flags_ix U8p | offsetof(struct op, op_flags)
864 #define OP_private_ix U8p | offsetof(struct op, op_private)
866 #define PMOP_pmflags_ix U32p | offsetof(struct pmop, op_pmflags)
869 #define PMOP_pmoffset_ix IVp | offsetof(struct pmop, op_pmoffset)
872 # Yes, B::SV::sv and B::SV::gv really do end up generating identical code.
873 #define SVOP_sv_ix SVp | offsetof(struct svop, op_sv)
874 #define SVOP_gv_ix SVp | offsetof(struct svop, op_sv)
876 #define PADOP_padix_ix PADOFFSETp | offsetof(struct padop, op_padix)
878 #define COP_seq_ix U32p | offsetof(struct cop, cop_seq)
879 #define COP_line_ix line_tp | offsetof(struct cop, cop_line)
880 #if PERL_VERSION >= 9
881 #define COP_hints_ix U32p | offsetof(struct cop, cop_hints)
883 #define COP_hints_ix U8p | offsetof(struct cop, op_private)
887 #define COP_stashpv_ix char_pp | offsetof(struct cop, cop_stashpv)
888 #define COP_file_ix char_pp | offsetof(struct cop, cop_file)
890 #define COP_stash_ix SVp | offsetof(struct cop, cop_stash)
891 #define COP_filegv_ix SVp | offsetof(struct cop, cop_filegv)
894 MODULE = B PACKAGE = B::OP
900 RETVAL = opsizes[cc_opclass(aTHX_ o)];
904 # The type checking code in B has always been identical for all OP types,
905 # irrespective of whether the action is actually defined on that OP.
911 B::OP::next = OP_next_ix
912 B::OP::sibling = OP_sibling_ix
913 B::OP::targ = OP_targ_ix
914 B::OP::flags = OP_flags_ix
915 B::OP::private = OP_private_ix
916 B::UNOP::first = UNOP_first_ix
917 B::BINOP::last = BINOP_last_ix
918 B::LOGOP::other = LOGOP_other_ix
919 B::PMOP::pmreplstart = PMOP_pmreplstart_ix
920 B::LOOP::redoop = LOOP_redoop_ix
921 B::LOOP::nextop = LOOP_nextop_ix
922 B::LOOP::lastop = LOOP_lastop_ix
923 B::PMOP::pmflags = PMOP_pmflags_ix
924 B::SVOP::sv = SVOP_sv_ix
925 B::SVOP::gv = SVOP_gv_ix
926 B::PADOP::padix = PADOP_padix_ix
927 B::COP::cop_seq = COP_seq_ix
928 B::COP::line = COP_line_ix
929 B::COP::hints = COP_hints_ix
934 ptr = (ix & 0xFFFF) + (char *)o;
935 switch ((U8)(ix >> 16)) {
936 case (U8)(OPp >> 16):
937 ret = make_op_object(aTHX_ *((OP **)ptr));
939 case (U8)(PADOFFSETp >> 16):
940 ret = sv_2mortal(newSVuv(*((PADOFFSET*)ptr)));
942 case (U8)(U8p >> 16):
943 ret = sv_2mortal(newSVuv(*((U8*)ptr)));
945 case (U8)(U32p >> 16):
946 ret = sv_2mortal(newSVuv(*((U32*)ptr)));
948 case (U8)(SVp >> 16):
949 ret = make_sv_object(aTHX_ *((SV **)ptr));
951 case (U8)(line_tp >> 16):
952 ret = sv_2mortal(newSVuv(*((line_t *)ptr)));
955 case (U8)(IVp >> 16):
956 ret = sv_2mortal(newSViv(*((IV*)ptr)));
958 case (U8)(char_pp >> 16):
959 ret = sv_2mortal(newSVpv(*((char **)ptr), 0));
963 croak("Illegal alias 0x%08x for B::*next", (unsigned)ix);
975 RETVAL = (char *)(ix ? OP_DESC(o) : OP_NAME(o));
986 sv = sv_2mortal(Perl_newSVpvf(aTHX_ "PL_ppaddr[OP_%s]",
987 PL_op_name[o->op_type]));
988 for (i=13; (STRLEN)i < SvCUR(sv); ++i)
989 SvPVX(sv)[i] = toUPPER(SvPVX(sv)[i]);
992 #if PERL_VERSION >= 9
993 # These 3 are all bitfields, so we can't take their addresses.
1006 RETVAL = o->op_spare;
1009 RETVAL = o->op_type;
1027 RETVAL = o->op_type;
1038 SP = oplist(aTHX_ o, SP);
1040 MODULE = B PACKAGE = B::LISTOP
1049 for (kid = o->op_first; kid; kid = kid->op_sibling)
1055 MODULE = B PACKAGE = B::PMOP PREFIX = PMOP_
1057 #if PERL_VERSION <= 8
1064 root = o->op_pmreplroot;
1065 /* OP_PUSHRE stores an SV* instead of an OP* in op_pmreplroot */
1066 if (o->op_type == OP_PUSHRE) {
1067 ST(0) = sv_newmortal();
1068 # ifdef USE_ITHREADS
1069 sv_setiv(ST(0), INT2PTR(PADOFFSET,root) );
1071 sv_setiv(newSVrv(ST(0), root ?
1072 svclassnames[SvTYPE((SV*)root)] : "B::SV"),
1077 ST(0) = make_op_object(aTHX_ root);
1086 if (o->op_type == OP_PUSHRE) {
1087 # ifdef USE_ITHREADS
1088 ST(0) = sv_newmortal();
1089 sv_setiv(ST(0), o->op_pmreplrootu.op_pmtargetoff);
1091 GV *const target = o->op_pmreplrootu.op_pmtargetgv;
1092 ST(0) = sv_newmortal();
1093 sv_setiv(newSVrv(ST(0), target ?
1094 svclassnames[SvTYPE((SV*)target)] : "B::SV"),
1099 OP *const root = o->op_pmreplrootu.op_pmreplroot;
1100 ST(0) = make_op_object(aTHX_ root);
1106 #define PMOP_pmstashpv(o) PmopSTASHPV(o);
1118 PUSHs(make_sv_object(aTHX_ (SV *) PmopSTASH(o)));
1122 #if PERL_VERSION < 9
1128 PUSHs(make_op_object(aTHX_ o->op_pmnext));
1148 ST(0) = sv_newmortal();
1150 #if PERL_VERSION >= 9
1152 sv_setuv(ST(0), RX_EXTFLAGS(rx));
1156 sv_setpvn(ST(0), RX_PRECOMP(rx), RX_PRELEN(rx));
1164 cv = newXS("B::PMOP::pmoffset", XS_B__OP_next, __FILE__);
1165 XSANY.any_i32 = PMOP_pmoffset_ix;
1166 cv = newXS("B::COP::stashpv", XS_B__OP_next, __FILE__);
1167 XSANY.any_i32 = COP_stashpv_ix;
1168 cv = newXS("B::COP::file", XS_B__OP_next, __FILE__);
1169 XSANY.any_i32 = COP_file_ix;
1171 cv = newXS("B::COP::stash", XS_B__OP_next, __FILE__);
1172 XSANY.any_i32 = COP_stash_ix;
1173 cv = newXS("B::COP::filegv", XS_B__OP_next, __FILE__);
1174 XSANY.any_i32 = COP_filegv_ix;
1176 #if PERL_VERSION >= 9
1177 cv = newXS("B::PMOP::reflags", XS_B__PMOP_precomp, __FILE__);
1182 MODULE = B PACKAGE = B::PADOP
1192 /* It happens that the output typemaps for B::SV and B::GV are
1193 identical. The "smarts" are in make_sv_object(), which determines
1194 which class to use based on SvTYPE(), rather than anything baked in
1197 ret = PAD_SVl(o->op_padix);
1198 if (ix && SvTYPE(ret) != SVt_PVGV)
1203 PUSHs(make_sv_object(aTHX_ ret));
1205 MODULE = B PACKAGE = B::PVOP
1212 * OP_TRANS uses op_pv to point to a table of 256 or >=258 shorts
1213 * whereas other PVOPs point to a null terminated string.
1215 if ((o->op_type == OP_TRANS || o->op_type == OP_TRANSR) &&
1216 (o->op_private & OPpTRANS_COMPLEMENT) &&
1217 !(o->op_private & OPpTRANS_DELETE))
1219 const short* const tbl = (short*)o->op_pv;
1220 const short entries = 257 + tbl[256];
1221 ST(0) = newSVpvn_flags(o->op_pv, entries * sizeof(short), SVs_TEMP);
1223 else if (o->op_type == OP_TRANS || o->op_type == OP_TRANSR) {
1224 ST(0) = newSVpvn_flags(o->op_pv, 256 * sizeof(short), SVs_TEMP);
1227 ST(0) = newSVpvn_flags(o->op_pv, strlen(o->op_pv), SVs_TEMP);
1229 #define COP_label(o) CopLABEL(o)
1231 #define COP_stashlen(o) CopSTASH_len(o)
1234 MODULE = B PACKAGE = B::COP PREFIX = COP_
1240 # Both pairs of accessors are provided for both ithreads and not, but for each,
1241 # one pair is direct structure access, and 1 pair "faked up" with a more complex
1242 # macro. We implement the direct structure access pair using the common code
1243 # above (B::OP::next)
1253 PUSHs(make_sv_object(aTHX_
1254 ix ? (SV *)CopFILEGV(o) : (SV *)CopSTASH(o)));
1272 RETVAL = ix ? CopFILE(o) : CopSTASHPV(o);
1292 #if PERL_VERSION >= 9
1293 ST(0) = ix ? make_cop_io_object(aTHX_ o) : make_warnings_object(aTHX_ o);
1295 ST(0) = make_sv_object(aTHX_ ix ? o->cop_io : o->cop_warnings);
1299 #if PERL_VERSION >= 9
1305 RETVAL = CopHINTHASH_get(o);
1311 MODULE = B PACKAGE = B::SV
1313 #define MAGICAL_FLAG_BITS (SVs_GMG|SVs_SMG|SVs_RMG)
1323 MAGICAL = MAGICAL_FLAG_BITS
1325 RETVAL = ix ? (SvFLAGS(sv) & (U32)ix) : SvREFCNT(sv);
1333 ST(0) = sv_2mortal(newRV(sv));
1336 MODULE = B PACKAGE = B::IV PREFIX = Sv
1342 MODULE = B PACKAGE = B::IV
1344 #define sv_SVp 0x00000
1345 #define sv_IVp 0x10000
1346 #define sv_UVp 0x20000
1347 #define sv_STRLENp 0x30000
1348 #define sv_U32p 0x40000
1349 #define sv_U8p 0x50000
1350 #define sv_char_pp 0x60000
1351 #define sv_NVp 0x70000
1352 #define sv_char_p 0x80000
1353 #define sv_SSize_tp 0x90000
1354 #define sv_I32p 0xA0000
1355 #define sv_U16p 0xB0000
1357 #define IV_ivx_ix sv_IVp | offsetof(struct xpviv, xiv_iv)
1358 #define IV_uvx_ix sv_UVp | offsetof(struct xpvuv, xuv_uv)
1359 #define NV_nvx_ix sv_NVp | offsetof(struct xpvnv, xnv_u.xnv_nv)
1361 #if PERL_VERSION >= 10
1362 #define NV_cop_seq_range_low_ix \
1363 sv_U32p | offsetof(struct xpvnv, xnv_u.xpad_cop_seq.xlow)
1364 #define NV_cop_seq_range_high_ix \
1365 sv_U32p | offsetof(struct xpvnv, xnv_u.xpad_cop_seq.xhigh)
1366 #define NV_parent_pad_index_ix \
1367 sv_U32p | offsetof(struct xpvnv, xnv_u.xpad_cop_seq.xlow)
1368 #define NV_parent_fakelex_flags_ix \
1369 sv_U32p | offsetof(struct xpvnv, xnv_u.xpad_cop_seq.xhigh)
1371 #define NV_cop_seq_range_low_ix \
1372 sv_NVp | offsetof(struct xpvnv, xnv_nv)
1373 #define NV_cop_seq_range_high_ix \
1374 sv_UVp | offsetof(struct xpvnv, xuv_uv)
1375 #define NV_parent_pad_index_ix \
1376 sv_NVp | offsetof(struct xpvnv, xnv_nv)
1377 #define NV_parent_fakelex_flags_ix \
1378 sv_UVp | offsetof(struct xpvnv, xuv_uv)
1381 #define PV_cur_ix sv_STRLENp | offsetof(struct xpv, xpv_cur)
1382 #define PV_len_ix sv_STRLENp | offsetof(struct xpv, xpv_len)
1384 #define PVMG_stash_ix sv_SVp | offsetof(struct xpvmg, xmg_stash)
1386 #if PERL_VERSION >= 10
1387 # if PERL_VERSION > 14
1388 # define PVBM_useful_ix sv_I32p | offsetof(struct xpvgv, xnv_u.xbm_s.xbm_useful)
1389 # define PVBM_previous_ix sv_UVp | offsetof(struct xpvuv, xuv_uv)
1391 #define PVBM_useful_ix sv_I32p | offsetof(struct xpvgv, xiv_u.xivu_i32)
1392 #define PVBM_previous_ix sv_U32p | offsetof(struct xpvgv, xnv_u.xbm_s.xbm_previous)
1394 #define PVBM_rare_ix sv_U8p | offsetof(struct xpvgv, xnv_u.xbm_s.xbm_rare)
1396 #define PVBM_useful_ix sv_I32p | offsetof(struct xpvbm, xbm_useful)
1397 #define PVBM_previous_ix sv_U16p | offsetof(struct xpvbm, xbm_previous)
1398 #define PVBM_rare_ix sv_U8p | offsetof(struct xpvbm, xbm_rare)
1401 #define PVLV_targoff_ix sv_U32p | offsetof(struct xpvlv, xlv_targoff)
1402 #define PVLV_targlen_ix sv_U32p | offsetof(struct xpvlv, xlv_targlen)
1403 #define PVLV_targ_ix sv_SVp | offsetof(struct xpvlv, xlv_targ)
1404 #define PVLV_type_ix sv_char_p | offsetof(struct xpvlv, xlv_type)
1406 #if PERL_VERSION >= 10
1407 #define PVGV_stash_ix sv_SVp | offsetof(struct xpvgv, xnv_u.xgv_stash)
1408 #define PVGV_flags_ix sv_STRLENp | offsetof(struct xpvgv, xpv_cur)
1409 #define PVIO_lines_ix sv_IVp | offsetof(struct xpvio, xiv_iv)
1411 #define PVGV_stash_ix sv_SVp | offsetof(struct xpvgv, xgv_stash)
1412 #define PVGV_flags_ix sv_U8p | offsetof(struct xpvgv, xgv_flags)
1413 #define PVIO_lines_ix sv_IVp | offsetof(struct xpvio, xio_lines)
1416 #define PVIO_page_ix sv_IVp | offsetof(struct xpvio, xio_page)
1417 #define PVIO_page_len_ix sv_IVp | offsetof(struct xpvio, xio_page_len)
1418 #define PVIO_lines_left_ix sv_IVp | offsetof(struct xpvio, xio_lines_left)
1419 #define PVIO_top_name_ix sv_char_pp | offsetof(struct xpvio, xio_top_name)
1420 #define PVIO_top_gv_ix sv_SVp | offsetof(struct xpvio, xio_top_gv)
1421 #define PVIO_fmt_name_ix sv_char_pp | offsetof(struct xpvio, xio_fmt_name)
1422 #define PVIO_fmt_gv_ix sv_SVp | offsetof(struct xpvio, xio_fmt_gv)
1423 #define PVIO_bottom_name_ix sv_char_pp | offsetof(struct xpvio, xio_bottom_name)
1424 #define PVIO_bottom_gv_ix sv_SVp | offsetof(struct xpvio, xio_bottom_gv)
1425 #define PVIO_type_ix sv_char_p | offsetof(struct xpvio, xio_type)
1426 #define PVIO_flags_ix sv_U8p | offsetof(struct xpvio, xio_flags)
1428 #define PVAV_max_ix sv_SSize_tp | offsetof(struct xpvav, xav_max)
1430 #define PVFM_lines_ix sv_IVp | offsetof(struct xpvfm, xfm_lines)
1432 #define PVCV_stash_ix sv_SVp | offsetof(struct xpvcv, xcv_stash)
1433 #define PVCV_gv_ix sv_SVp | offsetof(struct xpvcv, xcv_gv)
1434 #define PVCV_file_ix sv_char_pp | offsetof(struct xpvcv, xcv_file)
1435 #define PVCV_depth_ix sv_I32p | offsetof(struct xpvcv, xcv_depth)
1436 #define PVCV_padlist_ix sv_SVp | offsetof(struct xpvcv, xcv_padlist)
1437 #define PVCV_outside_ix sv_SVp | offsetof(struct xpvcv, xcv_outside)
1438 #define PVCV_outside_seq_ix sv_U32p | offsetof(struct xpvcv, xcv_outside_seq)
1439 #define PVCV_flags_ix sv_U16p | offsetof(struct xpvcv, xcv_flags)
1441 #define PVHV_max_ix sv_STRLENp | offsetof(struct xpvhv, xhv_max)
1443 #if PERL_VERSION > 12
1444 #define PVHV_keys_ix sv_STRLENp | offsetof(struct xpvhv, xhv_keys)
1446 #define PVHV_keys_ix sv_IVp | offsetof(struct xpvhv, xhv_keys)
1449 # The type checking code in B has always been identical for all SV types,
1450 # irrespective of whether the action is actually defined on that SV.
1451 # We should fix this
1456 B::IV::IVX = IV_ivx_ix
1457 B::IV::UVX = IV_uvx_ix
1458 B::NV::NVX = NV_nvx_ix
1459 B::NV::COP_SEQ_RANGE_LOW = NV_cop_seq_range_low_ix
1460 B::NV::COP_SEQ_RANGE_HIGH = NV_cop_seq_range_high_ix
1461 B::NV::PARENT_PAD_INDEX = NV_parent_pad_index_ix
1462 B::NV::PARENT_FAKELEX_FLAGS = NV_parent_fakelex_flags_ix
1463 B::PV::CUR = PV_cur_ix
1464 B::PV::LEN = PV_len_ix
1465 B::PVMG::SvSTASH = PVMG_stash_ix
1466 B::PVLV::TARGOFF = PVLV_targoff_ix
1467 B::PVLV::TARGLEN = PVLV_targlen_ix
1468 B::PVLV::TARG = PVLV_targ_ix
1469 B::PVLV::TYPE = PVLV_type_ix
1470 B::GV::STASH = PVGV_stash_ix
1471 B::GV::GvFLAGS = PVGV_flags_ix
1472 B::BM::USEFUL = PVBM_useful_ix
1473 B::BM::PREVIOUS = PVBM_previous_ix
1474 B::BM::RARE = PVBM_rare_ix
1475 B::IO::LINES = PVIO_lines_ix
1476 B::IO::PAGE = PVIO_page_ix
1477 B::IO::PAGE_LEN = PVIO_page_len_ix
1478 B::IO::LINES_LEFT = PVIO_lines_left_ix
1479 B::IO::TOP_NAME = PVIO_top_name_ix
1480 B::IO::TOP_GV = PVIO_top_gv_ix
1481 B::IO::FMT_NAME = PVIO_fmt_name_ix
1482 B::IO::FMT_GV = PVIO_fmt_gv_ix
1483 B::IO::BOTTOM_NAME = PVIO_bottom_name_ix
1484 B::IO::BOTTOM_GV = PVIO_bottom_gv_ix
1485 B::IO::IoTYPE = PVIO_type_ix
1486 B::IO::IoFLAGS = PVIO_flags_ix
1487 B::AV::MAX = PVAV_max_ix
1488 B::FM::LINES = PVFM_lines_ix
1489 B::CV::STASH = PVCV_stash_ix
1490 B::CV::GV = PVCV_gv_ix
1491 B::CV::FILE = PVCV_file_ix
1492 B::CV::DEPTH = PVCV_depth_ix
1493 B::CV::PADLIST = PVCV_padlist_ix
1494 B::CV::OUTSIDE = PVCV_outside_ix
1495 B::CV::OUTSIDE_SEQ = PVCV_outside_seq_ix
1496 B::CV::CvFLAGS = PVCV_flags_ix
1497 B::HV::MAX = PVHV_max_ix
1498 B::HV::KEYS = PVHV_keys_ix
1503 ptr = (ix & 0xFFFF) + (char *)SvANY(sv);
1504 switch ((U8)(ix >> 16)) {
1505 case (U8)(sv_SVp >> 16):
1506 ret = make_sv_object(aTHX_ *((SV **)ptr));
1508 case (U8)(sv_IVp >> 16):
1509 ret = sv_2mortal(newSViv(*((IV *)ptr)));
1511 case (U8)(sv_UVp >> 16):
1512 ret = sv_2mortal(newSVuv(*((UV *)ptr)));
1514 case (U8)(sv_STRLENp >> 16):
1515 ret = sv_2mortal(newSVuv(*((STRLEN *)ptr)));
1517 case (U8)(sv_U32p >> 16):
1518 ret = sv_2mortal(newSVuv(*((U32 *)ptr)));
1520 case (U8)(sv_U8p >> 16):
1521 ret = sv_2mortal(newSVuv(*((U8 *)ptr)));
1523 case (U8)(sv_char_pp >> 16):
1524 ret = sv_2mortal(newSVpv(*((char **)ptr), 0));
1526 case (U8)(sv_NVp >> 16):
1527 ret = sv_2mortal(newSVnv(*((NV *)ptr)));
1529 case (U8)(sv_char_p >> 16):
1530 ret = newSVpvn_flags((char *)ptr, 1, SVs_TEMP);
1532 case (U8)(sv_SSize_tp >> 16):
1533 ret = sv_2mortal(newSViv(*((SSize_t *)ptr)));
1535 case (U8)(sv_I32p >> 16):
1536 ret = sv_2mortal(newSVuv(*((I32 *)ptr)));
1538 case (U8)(sv_U16p >> 16):
1539 ret = sv_2mortal(newSVuv(*((U16 *)ptr)));
1542 croak("Illegal alias 0x%08x for B::*IVX", (unsigned)ix);
1554 ST(0) = boolSV((I32)SvIVX(sv) != SvIVX(sv));
1555 } else if (sizeof(IV) == 8) {
1557 const IV iv = SvIVX(sv);
1559 * The following way of spelling 32 is to stop compilers on
1560 * 32-bit architectures from moaning about the shift count
1561 * being >= the width of the type. Such architectures don't
1562 * reach this code anyway (unless sizeof(IV) > 8 but then
1563 * everything else breaks too so I'm not fussed at the moment).
1566 wp[0] = htonl(((UV)iv) >> (sizeof(UV)*4));
1568 wp[0] = htonl(((U32)iv) >> (sizeof(UV)*4));
1570 wp[1] = htonl(iv & 0xffffffff);
1571 ST(0) = newSVpvn_flags((char *)wp, 8, SVs_TEMP);
1573 U32 w = htonl((U32)SvIVX(sv));
1574 ST(0) = newSVpvn_flags((char *)&w, 4, SVs_TEMP);
1577 MODULE = B PACKAGE = B::NV PREFIX = Sv
1583 #if PERL_VERSION < 11
1585 MODULE = B PACKAGE = B::RV PREFIX = Sv
1591 PUSHs(make_sv_object(aTHX_ SvRV(sv)));
1595 MODULE = B PACKAGE = B::REGEXP
1604 PUSHs(newSVpvn_flags(RX_PRECOMP(sv), RX_PRELEN(sv), SVs_TEMP));
1607 /* FIXME - can we code this method more efficiently? */
1613 MODULE = B PACKAGE = B::PV
1620 croak( "argument is not SvROK" );
1621 PUSHs(make_sv_object(aTHX_ SvRV(sv)));
1636 #ifndef PERL_FBM_TABLE_OFFSET
1637 const MAGIC *const mg = mg_find(sv, PERL_MAGIC_bm);
1640 croak("argument to B::BM::TABLE is not a PVBM");
1645 /* Boyer-Moore table is just after string and its safety-margin \0 */
1646 p += len + PERL_FBM_TABLE_OFFSET;
1649 } else if (ix == 2) {
1650 /* This used to read 257. I think that that was buggy - should have
1651 been 258. (The "\0", the flags byte, and 256 for the table.)
1652 The only user of this method is B::Bytecode in B::PV::bsave.
1653 I'm guessing that nothing tested the runtime correctness of
1654 output of bytecompiled string constant arguments to index (etc).
1656 Note the start pointer is and has always been SvPVX(sv), not
1657 SvPVX(sv) + SvCUR(sv) PVBM was added in 651aa52ea1faa806, and
1658 first used by the compiler in 651aa52ea1faa806. It's used to
1659 get a "complete" dump of the buffer at SvPVX(), not just the
1660 PVBM table. This permits the generated bytecode to "load"
1663 5.15 and later store the BM table via MAGIC, so the compiler
1664 should handle this just fine without changes if PVBM now
1665 always returns the SvPVX() buffer. */
1666 p = SvPVX_const(sv);
1667 #ifdef PERL_FBM_TABLE_OFFSET
1668 len = SvCUR(sv) + (SvVALID(sv) ? 256 + PERL_FBM_TABLE_OFFSET : 0);
1675 } else if (SvPOK(sv)) {
1677 p = SvPVX_const(sv);
1679 #if PERL_VERSION < 10
1680 /* Before 5.10 (well 931b58fb28fa5ca7), PAD_COMPNAME_GEN was stored
1681 in SvCUR(), which meant we had to attempt this special casing
1682 to avoid tripping up over variable names in the pads. */
1683 if((SvLEN(sv) && len >= SvLEN(sv))) {
1684 /* It claims to be longer than the space allocated for it -
1685 presumably it's a variable name in the pad */
1691 /* XXX for backward compatibility, but should fail */
1692 /* croak( "argument is not SvPOK" ); */
1695 ST(0) = newSVpvn_flags(p, len, SVs_TEMP | utf8);
1697 MODULE = B PACKAGE = B::PVMG
1702 MAGIC * mg = NO_INIT
1704 for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic)
1705 XPUSHs(make_mg_object(aTHX_ mg));
1707 MODULE = B PACKAGE = B::MAGIC
1724 XPUSHs(mg->mg_moremagic ? make_mg_object(aTHX_ mg->mg_moremagic)
1728 mPUSHu(mg->mg_private);
1731 PUSHs(newSVpvn_flags(&(mg->mg_type), 1, SVs_TEMP));
1734 mPUSHu(mg->mg_flags);
1740 PUSHs(make_sv_object(aTHX_ mg->mg_obj));
1744 if (mg->mg_len >= 0) {
1745 PUSHs(newSVpvn_flags(mg->mg_ptr, mg->mg_len, SVs_TEMP));
1746 } else if (mg->mg_len == HEf_SVKEY) {
1747 PUSHs(make_sv_object(aTHX_ (SV*)mg->mg_ptr));
1749 PUSHs(sv_newmortal());
1751 PUSHs(sv_newmortal());
1754 if(mg->mg_type == PERL_MAGIC_qr) {
1755 mPUSHi(PTR2IV(mg->mg_obj));
1757 croak("REGEX is only meaningful on r-magic");
1761 if (mg->mg_type == PERL_MAGIC_qr) {
1762 REGEXP *rx = (REGEXP *)mg->mg_obj;
1763 PUSHs(newSVpvn_flags(rx ? RX_PRECOMP(rx) : NULL,
1764 rx ? RX_PRELEN(rx) : 0, SVs_TEMP));
1766 croak( "precomp is only meaningful on r-magic" );
1771 MODULE = B PACKAGE = B::GV PREFIX = Gv
1780 #if PERL_VERSION >= 10
1781 ST(0) = sv_2mortal(newSVhek(!ix ? GvNAME_HEK(gv)
1782 : (ix == 1 ? GvFILE_HEK(gv)
1783 : HvNAME_HEK((HV *)gv))));
1785 ST(0) = !ix ? newSVpvn_flags(GvNAME(gv), GvNAMELEN(gv), SVs_TEMP)
1786 : sv_2mortal(newSVpv(ix == 1 ? GvFILE(gv) : HvNAME((HV *)gv), 0))
1796 #if PERL_VERSION >= 9
1797 RETVAL = isGV_with_GP(gv) ? TRUE : FALSE;
1799 RETVAL = TRUE; /* In 5.8 and earlier they all are. */
1802 RETVAL = GvGP(gv) == Null(GP*);
1811 #define GP_sv_ix SVp | offsetof(struct gp, gp_sv)
1812 #define GP_io_ix SVp | offsetof(struct gp, gp_io)
1813 #define GP_cv_ix SVp | offsetof(struct gp, gp_cv)
1814 #define GP_cvgen_ix U32p | offsetof(struct gp, gp_cvgen)
1815 #define GP_refcnt_ix U32p | offsetof(struct gp, gp_refcnt)
1816 #define GP_hv_ix SVp | offsetof(struct gp, gp_hv)
1817 #define GP_av_ix SVp | offsetof(struct gp, gp_av)
1818 #define GP_form_ix SVp | offsetof(struct gp, gp_form)
1819 #define GP_egv_ix SVp | offsetof(struct gp, gp_egv)
1820 #define GP_line_ix line_tp | offsetof(struct gp, gp_line)
1830 GvREFCNT = GP_refcnt_ix
1843 const GV *const gv = CvGV(cv);
1844 Perl_croak(aTHX_ "NULL gp in B::GV::%s", gv ? GvNAME(gv) : "???");
1846 ptr = (ix & 0xFFFF) + (char *)gp;
1847 switch ((U8)(ix >> 16)) {
1848 case (U8)(SVp >> 16):
1849 ret = make_sv_object(aTHX_ *((SV **)ptr));
1851 case (U8)(U32p >> 16):
1852 ret = sv_2mortal(newSVuv(*((U32*)ptr)));
1854 case (U8)(line_tp >> 16):
1855 ret = sv_2mortal(newSVuv(*((line_t *)ptr)));
1858 croak("Illegal alias 0x%08x for B::*SV", (unsigned)ix);
1867 PUSHs(make_sv_object(aTHX_ (SV *)GvFILEGV(gv)));
1869 MODULE = B PACKAGE = B::IO PREFIX = Io
1871 #if PERL_VERSION <= 8
1886 if( strEQ( name, "stdin" ) ) {
1887 handle = PerlIO_stdin();
1889 else if( strEQ( name, "stdout" ) ) {
1890 handle = PerlIO_stdout();
1892 else if( strEQ( name, "stderr" ) ) {
1893 handle = PerlIO_stderr();
1896 croak( "Invalid value '%s'", name );
1898 RETVAL = handle == IoIFP(io);
1902 MODULE = B PACKAGE = B::AV PREFIX = Av
1912 if (AvFILL(av) >= 0) {
1913 SV **svp = AvARRAY(av);
1915 for (i = 0; i <= AvFILL(av); i++)
1916 XPUSHs(make_sv_object(aTHX_ svp[i]));
1924 if (idx >= 0 && AvFILL(av) >= 0 && idx <= AvFILL(av))
1925 XPUSHs(make_sv_object(aTHX_ (AvARRAY(av)[idx])));
1927 XPUSHs(make_sv_object(aTHX_ NULL));
1929 #if PERL_VERSION < 9
1931 #define AvOFF(av) ((XPVAV*)SvANY(av))->xof_off
1937 MODULE = B PACKAGE = B::AV
1945 MODULE = B PACKAGE = B::CV PREFIX = Cv
1957 PUSHs(make_op_object(aTHX_ CvISXSUB(cv) ? NULL
1958 : ix ? CvROOT(cv) : CvSTART(cv)));
1966 ST(0) = ix && CvCONST(cv)
1967 ? make_sv_object(aTHX_ (SV *)CvXSUBANY(cv).any_ptr)
1968 : sv_2mortal(newSViv(CvISXSUB(cv)
1969 ? (ix ? CvXSUBANY(cv).any_iv
1970 : PTR2IV(CvXSUB(cv)))
1977 PUSHs(make_sv_object(aTHX_ (SV *)cv_const_sv(cv)));
1979 MODULE = B PACKAGE = B::HV PREFIX = Hv
1989 #if PERL_VERSION < 9
1995 PUSHs(make_op_object(aTHX_ HvPMROOT(hv)));
2003 if (HvUSEDKEYS(hv) > 0) {
2007 (void)hv_iterinit(hv);
2008 EXTEND(sp, HvUSEDKEYS(hv) * 2);
2009 while ((sv = hv_iternextsv(hv, &key, &len))) {
2011 PUSHs(make_sv_object(aTHX_ sv));
2015 MODULE = B PACKAGE = B::HE PREFIX = He
2023 PUSHs(make_sv_object(aTHX_ ix ? HeSVKEY_force(he) : HeVAL(he)));
2029 MODULE = B PACKAGE = B::RHE
2031 #if PERL_VERSION >= 9
2037 RETVAL = newRV( (SV*)cophh_2hv(h, 0) );