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[] = {
27 #if PERL_VERSION <= 10
34 #if PERL_VERSION >= 11
61 static const char* const opclassnames[] = {
76 static const size_t opsizes[] = {
91 #define MY_CXT_KEY "B::_guts" XS_VERSION
94 int x_walkoptree_debug; /* Flag for walkoptree debug hook */
95 SV * x_specialsv_list[7];
100 #define walkoptree_debug (MY_CXT.x_walkoptree_debug)
101 #define specialsv_list (MY_CXT.x_specialsv_list)
104 cc_opclass(pTHX_ const OP *o)
112 return (o->op_flags & OPf_KIDS) ? OPc_UNOP : OPc_BASEOP;
114 if (o->op_type == OP_SASSIGN)
115 return ((o->op_private & OPpASSIGN_BACKWARDS) ? OPc_UNOP : OPc_BINOP);
117 if (o->op_type == OP_AELEMFAST) {
118 #if PERL_VERSION <= 14
119 if (o->op_flags & OPf_SPECIAL)
131 if (o->op_type == OP_GV || o->op_type == OP_GVSV ||
132 o->op_type == OP_RCATLINE)
136 if (o->op_type == OP_CUSTOM)
139 switch (OP_CLASS(o)) {
164 case OA_PVOP_OR_SVOP:
166 * Character translations (tr///) are usually a PVOP, keeping a
167 * pointer to a table of shorts used to look up translations.
168 * Under utf8, however, a simple table isn't practical; instead,
169 * the OP is an SVOP (or, under threads, a PADOP),
170 * and the SV is a reference to a swash
171 * (i.e., an RV pointing to an HV).
174 (o->op_private & (OPpTRANS_TO_UTF|OPpTRANS_FROM_UTF))
176 #if defined(USE_ITHREADS)
177 ? OPc_PADOP : OPc_PVOP;
179 ? OPc_SVOP : OPc_PVOP;
188 case OA_BASEOP_OR_UNOP:
190 * UNI(OP_foo) in toke.c returns token UNI or FUNC1 depending on
191 * whether parens were seen. perly.y uses OPf_SPECIAL to
192 * signal whether a BASEOP had empty parens or none.
193 * Some other UNOPs are created later, though, so the best
194 * test is OPf_KIDS, which is set in newUNOP.
196 return (o->op_flags & OPf_KIDS) ? OPc_UNOP : OPc_BASEOP;
200 * The file stat OPs are created via UNI(OP_foo) in toke.c but use
201 * the OPf_REF flag to distinguish between OP types instead of the
202 * usual OPf_SPECIAL flag. As usual, if OPf_KIDS is set, then we
203 * return OPc_UNOP so that walkoptree can find our children. If
204 * OPf_KIDS is not set then we check OPf_REF. Without OPf_REF set
205 * (no argument to the operator) it's an OP; with OPf_REF set it's
206 * an SVOP (and op_sv is the GV for the filehandle argument).
208 return ((o->op_flags & OPf_KIDS) ? OPc_UNOP :
210 (o->op_flags & OPf_REF) ? OPc_PADOP : OPc_BASEOP);
212 (o->op_flags & OPf_REF) ? OPc_SVOP : OPc_BASEOP);
216 * next, last, redo, dump and goto use OPf_SPECIAL to indicate that a
217 * label was omitted (in which case it's a BASEOP) or else a term was
218 * seen. In this last case, all except goto are definitely PVOP but
219 * goto is either a PVOP (with an ordinary constant label), an UNOP
220 * with OPf_STACKED (with a non-constant non-sub) or an UNOP for
221 * OP_REFGEN (with goto &sub) in which case OPf_STACKED also seems to
224 if (o->op_flags & OPf_STACKED)
226 else if (o->op_flags & OPf_SPECIAL)
231 warn("can't determine class of operator %s, assuming BASEOP\n",
237 make_op_object(pTHX_ const OP *o)
239 SV *opsv = sv_newmortal();
240 sv_setiv(newSVrv(opsv, opclassnames[cc_opclass(aTHX_ o)]), PTR2IV(o));
246 get_overlay_object(pTHX_ const OP *o, const char * const name, U32 namelen)
251 SV *sv =get_sv("B::overlay", 0);
252 if (!sv || !SvROK(sv))
255 if (SvTYPE(sv) != SVt_PVHV)
257 key = newSViv(PTR2IV(o));
258 he = hv_fetch_ent((HV*)sv, key, 0, 0);
263 if (!sv || !SvROK(sv))
266 if (SvTYPE(sv) != SVt_PVHV)
268 svp = hv_fetch((HV*)sv, name, namelen, 0);
277 make_sv_object(pTHX_ SV *sv)
279 SV *const arg = sv_newmortal();
280 const char *type = 0;
284 for (iv = 0; iv < (IV)(sizeof(specialsv_list)/sizeof(SV*)); iv++) {
285 if (sv == specialsv_list[iv]) {
291 type = svclassnames[SvTYPE(sv)];
294 sv_setiv(newSVrv(arg, type), iv);
299 make_hek_object(pTHX_ HEK *hek)
301 SV *ret = sv_setref_pvn(sv_newmortal(), "B::HEK", HEK_KEY(hek), HEK_LEN(hek));
304 SvIV_set(rv, PTR2IV(hek));
310 make_temp_object(pTHX_ SV *temp)
313 SV *arg = sv_newmortal();
314 const char *const type = svclassnames[SvTYPE(temp)];
315 const IV iv = PTR2IV(temp);
317 target = newSVrv(arg, type);
318 sv_setiv(target, iv);
320 /* Need to keep our "temp" around as long as the target exists.
321 Simplest way seems to be to hang it from magic, and let that clear
322 it up. No vtable, so won't actually get in the way of anything. */
323 sv_magicext(target, temp, PERL_MAGIC_sv, NULL, NULL, 0);
324 /* magic object has had its reference count increased, so we must drop
331 make_warnings_object(pTHX_ const COP *const cop)
333 const STRLEN *const warnings = cop->cop_warnings;
334 const char *type = 0;
336 IV iv = sizeof(specialsv_list)/sizeof(SV*);
338 /* Counting down is deliberate. Before the split between make_sv_object
339 and make_warnings_obj there appeared to be a bug - Nullsv and pWARN_STD
340 were both 0, so you could never get a B::SPECIAL for pWARN_STD */
343 if ((SV*)warnings == specialsv_list[iv]) {
349 SV *arg = sv_newmortal();
350 sv_setiv(newSVrv(arg, type), iv);
353 /* B assumes that warnings are a regular SV. Seems easier to keep it
354 happy by making them into a regular SV. */
355 return make_temp_object(aTHX_ newSVpvn((char *)(warnings + 1), *warnings));
360 make_cop_io_object(pTHX_ COP *cop)
362 SV *const value = newSV(0);
364 Perl_emulate_cop_io(aTHX_ cop, value);
367 return make_sv_object(aTHX_ value);
370 return make_sv_object(aTHX_ NULL);
375 make_mg_object(pTHX_ MAGIC *mg)
377 SV *arg = sv_newmortal();
378 sv_setiv(newSVrv(arg, "B::MAGIC"), PTR2IV(mg));
383 cstring(pTHX_ SV *sv, bool perlstyle)
388 return newSVpvs_flags("0", SVs_TEMP);
390 sstr = newSVpvs_flags("\"", SVs_TEMP);
392 if (perlstyle && SvUTF8(sv)) {
393 SV *tmpsv = sv_newmortal(); /* Temporary SV to feed sv_uni_display */
394 const STRLEN len = SvCUR(sv);
395 const char *s = sv_uni_display(tmpsv, sv, 8*len, UNI_DISPLAY_QQ);
399 sv_catpvs(sstr, "\\\"");
401 sv_catpvs(sstr, "\\$");
403 sv_catpvs(sstr, "\\@");
406 if (strchr("nrftax\\",*(s+1)))
407 sv_catpvn(sstr, s++, 2);
409 sv_catpvs(sstr, "\\\\");
411 else /* should always be printable */
412 sv_catpvn(sstr, s, 1);
420 const char *s = SvPV(sv, len);
421 for (; len; len--, s++)
423 /* At least try a little for readability */
425 sv_catpvs(sstr, "\\\"");
427 sv_catpvs(sstr, "\\\\");
428 /* trigraphs - bleagh */
429 else if (!perlstyle && *s == '?' && len>=3 && s[1] == '?') {
430 Perl_sv_catpvf(aTHX_ sstr, "\\%03o", '?');
432 else if (perlstyle && *s == '$')
433 sv_catpvs(sstr, "\\$");
434 else if (perlstyle && *s == '@')
435 sv_catpvs(sstr, "\\@");
436 else if (isPRINT(*s))
437 sv_catpvn(sstr, s, 1);
439 sv_catpvs(sstr, "\\n");
441 sv_catpvs(sstr, "\\r");
443 sv_catpvs(sstr, "\\t");
445 sv_catpvs(sstr, "\\a");
447 sv_catpvs(sstr, "\\b");
449 sv_catpvs(sstr, "\\f");
450 else if (!perlstyle && *s == '\v')
451 sv_catpvs(sstr, "\\v");
454 /* Don't want promotion of a signed -1 char in sprintf args */
455 const unsigned char c = (unsigned char) *s;
456 Perl_sv_catpvf(aTHX_ sstr, "\\%03o", c);
458 /* XXX Add line breaks if string is long */
461 sv_catpvs(sstr, "\"");
468 SV *sstr = newSVpvs_flags("'", SVs_TEMP);
469 const char *s = SvPV_nolen(sv);
470 /* Don't want promotion of a signed -1 char in sprintf args */
471 const unsigned char c = (unsigned char) *s;
474 sv_catpvs(sstr, "\\'");
476 sv_catpvs(sstr, "\\\\");
478 sv_catpvn(sstr, s, 1);
480 sv_catpvs(sstr, "\\n");
482 sv_catpvs(sstr, "\\r");
484 sv_catpvs(sstr, "\\t");
486 sv_catpvs(sstr, "\\a");
488 sv_catpvs(sstr, "\\b");
490 sv_catpvs(sstr, "\\f");
492 sv_catpvs(sstr, "\\v");
494 Perl_sv_catpvf(aTHX_ sstr, "\\%03o", c);
495 sv_catpvs(sstr, "'");
499 #define PMOP_pmreplstart(o) o->op_pmstashstartu.op_pmreplstart
500 #define PMOP_pmreplroot(o) o->op_pmreplrootu.op_pmreplroot
503 walkoptree(pTHX_ OP *o, const char *method, SV *ref)
508 const char *const classname = opclassnames[cc_opclass(aTHX_ o)];
511 /* Check that no-one has changed our reference, or is holding a reference
513 if (SvREFCNT(ref) == 1 && SvROK(ref) && SvTYPE(ref) == SVt_RV
514 && (object = SvRV(ref)) && SvREFCNT(object) == 1
515 && SvTYPE(object) == SVt_PVMG && SvIOK_only(object)
516 && !SvMAGICAL(object) && !SvMAGIC(object) && SvSTASH(object)) {
517 /* Looks good, so rebless it for the class we need: */
518 sv_bless(ref, gv_stashpv(classname, GV_ADD));
520 /* Need to make a new one. */
521 ref = sv_newmortal();
522 object = newSVrv(ref, classname);
524 sv_setiv(object, PTR2IV(o));
526 if (walkoptree_debug) {
530 perl_call_method("walkoptree_debug", G_DISCARD);
535 perl_call_method(method, G_DISCARD);
536 if (o && (o->op_flags & OPf_KIDS)) {
537 for (kid = ((UNOP*)o)->op_first; kid; kid = kid->op_sibling) {
538 ref = walkoptree(aTHX_ kid, method, ref);
541 if (o && (cc_opclass(aTHX_ o) == OPc_PMOP) && o->op_type != OP_PUSHRE
542 && (kid = PMOP_pmreplroot(cPMOPo)))
544 ref = walkoptree(aTHX_ kid, method, ref);
550 oplist(pTHX_ OP *o, SV **SP)
552 for(; o; o = o->op_next) {
556 XPUSHs(make_op_object(aTHX_ o));
557 switch (o->op_type) {
559 SP = oplist(aTHX_ PMOP_pmreplstart(cPMOPo), SP);
562 if (o->op_flags & OPf_STACKED && o->op_flags & OPf_SPECIAL) {
563 OP *kid = cLISTOPo->op_first->op_sibling; /* pass pushmark */
564 kid = kUNOP->op_first; /* pass rv2gv */
565 kid = kUNOP->op_first; /* pass leave */
566 SP = oplist(aTHX_ kid->op_next, SP);
570 switch (PL_opargs[o->op_type] & OA_CLASS_MASK) {
572 SP = oplist(aTHX_ cLOGOPo->op_other, SP);
575 SP = oplist(aTHX_ cLOOPo->op_lastop, SP);
576 SP = oplist(aTHX_ cLOOPo->op_nextop, SP);
577 SP = oplist(aTHX_ cLOOPo->op_redoop, SP);
585 typedef UNOP *B__UNOP;
586 typedef BINOP *B__BINOP;
587 typedef LOGOP *B__LOGOP;
588 typedef LISTOP *B__LISTOP;
589 typedef PMOP *B__PMOP;
590 typedef SVOP *B__SVOP;
591 typedef PADOP *B__PADOP;
592 typedef PVOP *B__PVOP;
593 typedef LOOP *B__LOOP;
601 #if PERL_VERSION >= 11
602 typedef SV *B__REGEXP;
614 typedef MAGIC *B__MAGIC;
617 typedef struct refcounted_he *B__RHE;
619 typedef PADLIST *B__PADLIST;
623 # define ASSIGN_COMMON_ALIAS(prefix, var) \
624 STMT_START { XSANY.any_i32 = offsetof(struct interpreter, prefix##var); } STMT_END
626 # define ASSIGN_COMMON_ALIAS(prefix, var) \
627 STMT_START { XSANY.any_ptr = (void *)&PL_##var; } STMT_END
630 /* This needs to be ALIASed in a custom way, hence can't easily be defined as
632 static XSPROTO(intrpvar_sv_common); /* prototype to pass -Wmissing-prototypes */
633 static XSPROTO(intrpvar_sv_common)
639 croak_xs_usage(cv, "");
641 ret = *(SV **)(XSANY.any_i32 + (char *)my_perl);
643 ret = *(SV **)(XSANY.any_ptr);
645 ST(0) = make_sv_object(aTHX_ ret);
653 #define line_tp 0x20000
655 #define PADOFFSETp 0x40000
658 #define char_pp 0x70000
660 /* table that drives most of the B::*OP methods */
666 size_t offset; /* if -1, access is handled on a case-by-case basis */
668 STR_WITH_LEN("next"), OPp, offsetof(struct op, op_next), /* 0*/
669 STR_WITH_LEN("sibling"), OPp, offsetof(struct op, op_sibling), /* 1*/
670 STR_WITH_LEN("targ"), PADOFFSETp, offsetof(struct op, op_targ), /* 2*/
671 STR_WITH_LEN("flags"), U8p, offsetof(struct op, op_flags), /* 3*/
672 STR_WITH_LEN("private"), U8p, offsetof(struct op, op_private), /* 4*/
673 STR_WITH_LEN("first"), OPp, offsetof(struct unop, op_first), /* 5*/
674 STR_WITH_LEN("last"), OPp, offsetof(struct binop, op_last), /* 6*/
675 STR_WITH_LEN("other"), OPp, offsetof(struct logop, op_other), /* 7*/
676 STR_WITH_LEN("pmreplstart"), 0, -1, /* 8*/
677 STR_WITH_LEN("redoop"), OPp, offsetof(struct loop, op_redoop), /* 9*/
678 STR_WITH_LEN("nextop"), OPp, offsetof(struct loop, op_nextop), /*10*/
679 STR_WITH_LEN("lastop"), OPp, offsetof(struct loop, op_lastop), /*11*/
680 STR_WITH_LEN("pmflags"), U32p, offsetof(struct pmop, op_pmflags), /*12*/
681 #if PERL_VERSION >= 17
682 STR_WITH_LEN("code_list"),OPp, offsetof(struct pmop, op_code_list),/*13*/
684 STR_WITH_LEN("code_list"),0, -1,
686 STR_WITH_LEN("sv"), SVp, offsetof(struct svop, op_sv), /*14*/
687 STR_WITH_LEN("gv"), SVp, offsetof(struct svop, op_sv), /*15*/
688 STR_WITH_LEN("padix"), PADOFFSETp,offsetof(struct padop, op_padix),/*16*/
689 STR_WITH_LEN("cop_seq"), U32p, offsetof(struct cop, cop_seq), /*17*/
690 STR_WITH_LEN("line"), line_tp, offsetof(struct cop, cop_line), /*18*/
691 STR_WITH_LEN("hints"), U32p, offsetof(struct cop, cop_hints), /*19*/
693 STR_WITH_LEN("pmoffset"),IVp, offsetof(struct pmop, op_pmoffset),/*20*/
694 STR_WITH_LEN("filegv"), 0, -1, /*21*/
695 STR_WITH_LEN("file"), char_pp, offsetof(struct cop, cop_file), /*22*/
696 STR_WITH_LEN("stash"), 0, -1, /*23*/
697 # if PERL_VERSION < 17
698 STR_WITH_LEN("stashpv"), char_pp, offsetof(struct cop, cop_stashpv), /*24*/
699 STR_WITH_LEN("stashoff"),0, -1, /*25*/
701 STR_WITH_LEN("stashpv"), 0, -1, /*24*/
702 STR_WITH_LEN("stashoff"),PADOFFSETp,offsetof(struct cop, cop_stashoff),/*25*/
705 STR_WITH_LEN("pmoffset"),0, -1, /*20*/
706 STR_WITH_LEN("filegv"), SVp, offsetof(struct cop, cop_filegv), /*21*/
707 STR_WITH_LEN("file"), 0, -1, /*22*/
708 STR_WITH_LEN("stash"), SVp, offsetof(struct cop, cop_stash), /*23*/
709 STR_WITH_LEN("stashpv"), 0, -1, /*24*/
710 STR_WITH_LEN("stashoff"),0, -1, /*25*/
712 STR_WITH_LEN("size"), 0, -1, /*26*/
713 STR_WITH_LEN("name"), 0, -1, /*27*/
714 STR_WITH_LEN("desc"), 0, -1, /*28*/
715 STR_WITH_LEN("ppaddr"), 0, -1, /*29*/
716 STR_WITH_LEN("type"), 0, -1, /*30*/
717 STR_WITH_LEN("opt"), 0, -1, /*31*/
718 STR_WITH_LEN("spare"), 0, -1, /*32*/
719 STR_WITH_LEN("children"),0, -1, /*33*/
720 STR_WITH_LEN("pmreplroot"), 0, -1, /*34*/
721 STR_WITH_LEN("pmstashpv"), 0, -1, /*35*/
722 STR_WITH_LEN("pmstash"), 0, -1, /*36*/
723 STR_WITH_LEN("precomp"), 0, -1, /*37*/
724 STR_WITH_LEN("reflags"), 0, -1, /*38*/
725 STR_WITH_LEN("sv"), 0, -1, /*39*/
726 STR_WITH_LEN("gv"), 0, -1, /*40*/
727 STR_WITH_LEN("pv"), 0, -1, /*41*/
728 STR_WITH_LEN("label"), 0, -1, /*42*/
729 STR_WITH_LEN("arybase"), 0, -1, /*43*/
730 STR_WITH_LEN("warnings"),0, -1, /*44*/
731 STR_WITH_LEN("io"), 0, -1, /*45*/
732 STR_WITH_LEN("hints_hash"),0, -1, /*46*/
735 #include "const-c.inc"
737 MODULE = B PACKAGE = B
739 INCLUDE: const-xs.inc
746 const char *file = __FILE__;
748 specialsv_list[0] = Nullsv;
749 specialsv_list[1] = &PL_sv_undef;
750 specialsv_list[2] = &PL_sv_yes;
751 specialsv_list[3] = &PL_sv_no;
752 specialsv_list[4] = (SV *) pWARN_ALL;
753 specialsv_list[5] = (SV *) pWARN_NONE;
754 specialsv_list[6] = (SV *) pWARN_STD;
756 cv = newXS("B::init_av", intrpvar_sv_common, file);
757 ASSIGN_COMMON_ALIAS(I, initav);
758 cv = newXS("B::check_av", intrpvar_sv_common, file);
759 ASSIGN_COMMON_ALIAS(I, checkav_save);
760 cv = newXS("B::unitcheck_av", intrpvar_sv_common, file);
761 ASSIGN_COMMON_ALIAS(I, unitcheckav_save);
762 cv = newXS("B::begin_av", intrpvar_sv_common, file);
763 ASSIGN_COMMON_ALIAS(I, beginav_save);
764 cv = newXS("B::end_av", intrpvar_sv_common, file);
765 ASSIGN_COMMON_ALIAS(I, endav);
766 cv = newXS("B::main_cv", intrpvar_sv_common, file);
767 ASSIGN_COMMON_ALIAS(I, main_cv);
768 cv = newXS("B::inc_gv", intrpvar_sv_common, file);
769 ASSIGN_COMMON_ALIAS(I, incgv);
770 cv = newXS("B::defstash", intrpvar_sv_common, file);
771 ASSIGN_COMMON_ALIAS(I, defstash);
772 cv = newXS("B::curstash", intrpvar_sv_common, file);
773 ASSIGN_COMMON_ALIAS(I, curstash);
775 cv = newXS("B::formfeed", intrpvar_sv_common, file);
776 ASSIGN_COMMON_ALIAS(I, formfeed);
779 cv = newXS("B::regex_padav", intrpvar_sv_common, file);
780 ASSIGN_COMMON_ALIAS(I, regex_padav);
782 cv = newXS("B::warnhook", intrpvar_sv_common, file);
783 ASSIGN_COMMON_ALIAS(I, warnhook);
784 cv = newXS("B::diehook", intrpvar_sv_common, file);
785 ASSIGN_COMMON_ALIAS(I, diehook);
793 PUSHs(make_sv_object(aTHX_ GvSV(gv_fetchpvs("\f", GV_ADD, SVt_PV))));
800 RETVAL = PL_amagic_generation;
807 PADLIST *padlist = CvPADLIST(PL_main_cv ? PL_main_cv : PL_compcv);
811 SV * const rv = sv_newmortal();
812 sv_setiv(newSVrv(rv, padlist ? "B::PADLIST" : "B::NULL"),
817 PUSHs(make_sv_object(aTHX_ (SV *)padlist));
826 PUSHs(make_sv_object(aTHX_ ix > 1 ? &PL_sv_yes
827 : ix < 1 ? &PL_sv_undef
835 PUSHs(make_op_object(aTHX_ ix ? PL_main_start : PL_main_root));
842 RETVAL = ix ? PL_dowarn : PL_sub_generation;
847 walkoptree(op, method)
851 (void) walkoptree(aTHX_ op, method, &PL_sv_undef);
854 walkoptree_debug(...)
857 RETVAL = walkoptree_debug;
858 if (items > 0 && SvTRUE(ST(1)))
859 walkoptree_debug = 1;
863 #define address(sv) PTR2IV(sv)
874 croak("argument is not a reference");
875 PUSHs(make_sv_object(aTHX_ SvRV(sv)));
884 ST(0) = sv_newmortal();
885 if (strncmp(name,"pp_",3) == 0)
887 for (i = 0; i < PL_maxo; i++)
889 if (strcmp(name, PL_op_name[i]) == 0)
895 sv_setiv(ST(0),result);
902 ST(0) = sv_newmortal();
903 if (opnum >= 0 && opnum < PL_maxo)
904 Perl_sv_setpvf(aTHX_ ST(0), "pp_%s", PL_op_name[opnum]);
912 const char *s = SvPVbyte(sv, len);
913 PERL_HASH(hash, s, len);
914 ST(0) = sv_2mortal(Perl_newSVpvf(aTHX_ "0x%"UVxf, (UV)hash));
916 #define cast_I32(foo) (I32)foo
938 PUSHs(ix == 2 ? cchar(aTHX_ sv) : cstring(aTHX_ sv, (bool)ix));
947 MODULE = B PACKAGE = B::OP
950 # The type checking code in B has always been identical for all OP types,
951 # irrespective of whether the action is actually defined on that OP.
965 B::PMOP::pmreplstart = 8
969 B::PMOP::pmflags = 12
970 B::PMOP::code_list = 13
977 B::PMOP::pmoffset = 20
982 B::COP::stashoff = 25
990 B::LISTOP::children = 33
991 B::PMOP::pmreplroot = 34
992 B::PMOP::pmstashpv = 35
993 B::PMOP::pmstash = 36
994 B::PMOP::precomp = 37
995 B::PMOP::reflags = 38
1000 B::COP::arybase = 43
1001 B::COP::warnings = 44
1003 B::COP::hints_hash = 46
1011 if (ix < 0 || ix > 46)
1012 croak("Illegal alias %d for B::*OP::next", (int)ix);
1013 ret = get_overlay_object(aTHX_ o,
1014 op_methods[ix].name, op_methods[ix].namelen);
1020 /* handle non-direct field access */
1022 offset = op_methods[ix].offset;
1025 case 8: /* pmreplstart */
1026 ret = make_op_object(aTHX_
1027 cPMOPo->op_type == OP_SUBST
1028 ? cPMOPo->op_pmstashstartu.op_pmreplstart
1033 case 21: /* filegv */
1034 ret = make_sv_object(aTHX_ (SV *)CopFILEGV((COP*)o));
1037 #ifndef USE_ITHREADS
1039 ret = sv_2mortal(newSVpv(CopFILE((COP*)o), 0));
1043 case 23: /* stash */
1044 ret = make_sv_object(aTHX_ (SV *)CopSTASH((COP*)o));
1047 #if PERL_VERSION >= 17 || !defined USE_ITHREADS
1048 case 24: /* stashpv */
1049 # if PERL_VERSION >= 17
1050 ret = sv_2mortal(CopSTASH((COP*)o)
1051 && SvTYPE(CopSTASH((COP*)o)) == SVt_PVHV
1052 ? newSVhek(HvNAME_HEK(CopSTASH((COP*)o)))
1055 ret = sv_2mortal(newSVpv(CopSTASHPV((COP*)o), 0));
1060 ret = sv_2mortal(newSVuv((UV)(opsizes[cc_opclass(aTHX_ o)])));
1064 ret = sv_2mortal(newSVpv(
1065 (char *)(ix == 28 ? OP_DESC(o) : OP_NAME(o)), 0));
1067 case 29: /* ppaddr */
1070 ret = sv_2mortal(Perl_newSVpvf(aTHX_ "PL_ppaddr[OP_%s]",
1071 PL_op_name[o->op_type]));
1072 for (i=13; (STRLEN)i < SvCUR(ret); ++i)
1073 SvPVX(ret)[i] = toUPPER(SvPVX(ret)[i]);
1078 case 32: /* spare */
1079 /* These 3 are all bitfields, so we can't take their addresses */
1080 ret = sv_2mortal(newSVuv((UV)(
1081 ix == 30 ? o->op_type
1082 : ix == 31 ? o->op_opt
1085 case 33: /* children */
1089 for (kid = ((LISTOP*)o)->op_first; kid; kid = kid->op_sibling)
1091 ret = sv_2mortal(newSVuv(i));
1094 case 34: /* pmreplroot */
1095 if (cPMOPo->op_type == OP_PUSHRE) {
1097 ret = sv_newmortal();
1098 sv_setiv(ret, cPMOPo->op_pmreplrootu.op_pmtargetoff);
1100 GV *const target = cPMOPo->op_pmreplrootu.op_pmtargetgv;
1101 ret = sv_newmortal();
1102 sv_setiv(newSVrv(ret, target ?
1103 svclassnames[SvTYPE((SV*)target)] : "B::SV"),
1108 OP *const root = cPMOPo->op_pmreplrootu.op_pmreplroot;
1109 ret = make_op_object(aTHX_ root);
1113 case 35: /* pmstashpv */
1114 ret = sv_2mortal(newSVpv(PmopSTASHPV(cPMOPo),0));
1117 case 36: /* pmstash */
1118 ret = make_sv_object(aTHX_ (SV *) PmopSTASH(cPMOPo));
1121 case 37: /* precomp */
1122 case 38: /* reflags */
1124 REGEXP *rx = PM_GETRE(cPMOPo);
1125 ret = sv_newmortal();
1128 sv_setuv(ret, RX_EXTFLAGS(rx));
1131 sv_setpvn(ret, RX_PRECOMP(rx), RX_PRELEN(rx));
1138 /* It happens that the output typemaps for B::SV and B::GV
1139 * are identical. The "smarts" are in make_sv_object(),
1140 * which determines which class to use based on SvTYPE(),
1141 * rather than anything baked in at compile time. */
1142 if (cPADOPo->op_padix) {
1143 ret = PAD_SVl(cPADOPo->op_padix);
1144 if (ix == 40 && SvTYPE(ret) != SVt_PVGV)
1149 ret = make_sv_object(aTHX_ ret);
1152 /* OP_TRANS uses op_pv to point to a table of 256 or >=258
1153 * shorts whereas other PVOPs point to a null terminated
1155 if ( (cPVOPo->op_type == OP_TRANS
1156 || cPVOPo->op_type == OP_TRANSR) &&
1157 (cPVOPo->op_private & OPpTRANS_COMPLEMENT) &&
1158 !(cPVOPo->op_private & OPpTRANS_DELETE))
1160 const short* const tbl = (short*)cPVOPo->op_pv;
1161 const short entries = 257 + tbl[256];
1162 ret = newSVpvn_flags(cPVOPo->op_pv, entries * sizeof(short), SVs_TEMP);
1164 else if (cPVOPo->op_type == OP_TRANS || cPVOPo->op_type == OP_TRANSR) {
1165 ret = newSVpvn_flags(cPVOPo->op_pv, 256 * sizeof(short), SVs_TEMP);
1168 ret = newSVpvn_flags(cPVOPo->op_pv, strlen(cPVOPo->op_pv), SVs_TEMP);
1170 case 42: /* label */
1171 ret = sv_2mortal(newSVpv(CopLABEL(cCOPo),0));
1173 case 43: /* arybase */
1174 ret = sv_2mortal(newSVuv(0));
1176 case 44: /* warnings */
1177 ret = make_warnings_object(aTHX_ cCOPo);
1180 ret = make_cop_io_object(aTHX_ cCOPo);
1182 case 46: /* hints_hash */
1183 ret = sv_newmortal();
1184 sv_setiv(newSVrv(ret, "B::RHE"),
1185 PTR2IV(CopHINTHASH_get(cCOPo)));
1188 croak("method %s not implemented", op_methods[ix].name);
1194 /* do a direct structure offset lookup */
1196 ptr = (char *)o + offset;
1197 type = op_methods[ix].type;
1198 switch ((U8)(type >> 16)) {
1199 case (U8)(OPp >> 16):
1200 ret = make_op_object(aTHX_ *((OP **)ptr));
1202 case (U8)(PADOFFSETp >> 16):
1203 ret = sv_2mortal(newSVuv(*((PADOFFSET*)ptr)));
1205 case (U8)(U8p >> 16):
1206 ret = sv_2mortal(newSVuv(*((U8*)ptr)));
1208 case (U8)(U32p >> 16):
1209 ret = sv_2mortal(newSVuv(*((U32*)ptr)));
1211 case (U8)(SVp >> 16):
1212 ret = make_sv_object(aTHX_ *((SV **)ptr));
1214 case (U8)(line_tp >> 16):
1215 ret = sv_2mortal(newSVuv(*((line_t *)ptr)));
1217 case (U8)(IVp >> 16):
1218 ret = sv_2mortal(newSViv(*((IV*)ptr)));
1220 case (U8)(char_pp >> 16):
1221 ret = sv_2mortal(newSVpv(*((char **)ptr), 0));
1224 croak("Illegal type 0x%08x for B::*OP::%s",
1225 (unsigned)type, op_methods[ix].name);
1236 SP = oplist(aTHX_ o, SP);
1239 MODULE = B PACKAGE = B::SV
1241 #define MAGICAL_FLAG_BITS (SVs_GMG|SVs_SMG|SVs_RMG)
1251 MAGICAL = MAGICAL_FLAG_BITS
1253 RETVAL = ix ? (SvFLAGS(sv) & (U32)ix) : SvREFCNT(sv);
1261 ST(0) = sv_2mortal(newRV(sv));
1264 MODULE = B PACKAGE = B::IV PREFIX = Sv
1270 MODULE = B PACKAGE = B::IV
1272 #define sv_SVp 0x00000
1273 #define sv_IVp 0x10000
1274 #define sv_UVp 0x20000
1275 #define sv_STRLENp 0x30000
1276 #define sv_U32p 0x40000
1277 #define sv_U8p 0x50000
1278 #define sv_char_pp 0x60000
1279 #define sv_NVp 0x70000
1280 #define sv_char_p 0x80000
1281 #define sv_SSize_tp 0x90000
1282 #define sv_I32p 0xA0000
1283 #define sv_U16p 0xB0000
1285 #define IV_ivx_ix sv_IVp | offsetof(struct xpviv, xiv_iv)
1286 #define IV_uvx_ix sv_UVp | offsetof(struct xpvuv, xuv_uv)
1287 #define NV_nvx_ix sv_NVp | offsetof(struct xpvnv, xnv_u.xnv_nv)
1289 #define NV_cop_seq_range_low_ix \
1290 sv_U32p | offsetof(struct xpvnv, xnv_u.xpad_cop_seq.xlow)
1291 #define NV_cop_seq_range_high_ix \
1292 sv_U32p | offsetof(struct xpvnv, xnv_u.xpad_cop_seq.xhigh)
1293 #define NV_parent_pad_index_ix \
1294 sv_U32p | offsetof(struct xpvnv, xnv_u.xpad_cop_seq.xlow)
1295 #define NV_parent_fakelex_flags_ix \
1296 sv_U32p | offsetof(struct xpvnv, xnv_u.xpad_cop_seq.xhigh)
1298 #define PV_cur_ix sv_STRLENp | offsetof(struct xpv, xpv_cur)
1299 #define PV_len_ix sv_STRLENp | offsetof(struct xpv, xpv_len)
1301 #define PVMG_stash_ix sv_SVp | offsetof(struct xpvmg, xmg_stash)
1303 #if PERL_VERSION > 18
1304 # define PVBM_useful_ix sv_I32p | offsetof(struct xpvgv, xnv_u.xbm_useful)
1305 #elif PERL_VERSION > 14
1306 # define PVBM_useful_ix sv_I32p | offsetof(struct xpvgv, xnv_u.xbm_s.xbm_useful)
1308 #define PVBM_useful_ix sv_I32p | offsetof(struct xpvgv, xiv_u.xivu_i32)
1311 #define PVLV_targoff_ix sv_U32p | offsetof(struct xpvlv, xlv_targoff)
1312 #define PVLV_targlen_ix sv_U32p | offsetof(struct xpvlv, xlv_targlen)
1313 #define PVLV_targ_ix sv_SVp | offsetof(struct xpvlv, xlv_targ)
1314 #define PVLV_type_ix sv_char_p | offsetof(struct xpvlv, xlv_type)
1316 #define PVGV_stash_ix sv_SVp | offsetof(struct xpvgv, xnv_u.xgv_stash)
1317 #define PVGV_flags_ix sv_STRLENp | offsetof(struct xpvgv, xpv_cur)
1318 #define PVIO_lines_ix sv_IVp | offsetof(struct xpvio, xiv_iv)
1320 #define PVIO_page_ix sv_IVp | offsetof(struct xpvio, xio_page)
1321 #define PVIO_page_len_ix sv_IVp | offsetof(struct xpvio, xio_page_len)
1322 #define PVIO_lines_left_ix sv_IVp | offsetof(struct xpvio, xio_lines_left)
1323 #define PVIO_top_name_ix sv_char_pp | offsetof(struct xpvio, xio_top_name)
1324 #define PVIO_top_gv_ix sv_SVp | offsetof(struct xpvio, xio_top_gv)
1325 #define PVIO_fmt_name_ix sv_char_pp | offsetof(struct xpvio, xio_fmt_name)
1326 #define PVIO_fmt_gv_ix sv_SVp | offsetof(struct xpvio, xio_fmt_gv)
1327 #define PVIO_bottom_name_ix sv_char_pp | offsetof(struct xpvio, xio_bottom_name)
1328 #define PVIO_bottom_gv_ix sv_SVp | offsetof(struct xpvio, xio_bottom_gv)
1329 #define PVIO_type_ix sv_char_p | offsetof(struct xpvio, xio_type)
1330 #define PVIO_flags_ix sv_U8p | offsetof(struct xpvio, xio_flags)
1332 #define PVAV_max_ix sv_SSize_tp | offsetof(struct xpvav, xav_max)
1334 #define PVCV_stash_ix sv_SVp | offsetof(struct xpvcv, xcv_stash)
1335 #if PERL_VERSION > 17 || (PERL_VERSION == 17 && PERL_SUBVERSION >= 3)
1336 # define PVCV_gv_ix sv_SVp | offsetof(struct xpvcv, xcv_gv_u.xcv_gv)
1338 # define PVCV_gv_ix sv_SVp | offsetof(struct xpvcv, xcv_gv)
1340 #define PVCV_file_ix sv_char_pp | offsetof(struct xpvcv, xcv_file)
1341 #define PVCV_outside_ix sv_SVp | offsetof(struct xpvcv, xcv_outside)
1342 #define PVCV_outside_seq_ix sv_U32p | offsetof(struct xpvcv, xcv_outside_seq)
1343 #define PVCV_flags_ix sv_U32p | offsetof(struct xpvcv, xcv_flags)
1345 #define PVHV_max_ix sv_STRLENp | offsetof(struct xpvhv, xhv_max)
1347 #if PERL_VERSION > 12
1348 #define PVHV_keys_ix sv_STRLENp | offsetof(struct xpvhv, xhv_keys)
1350 #define PVHV_keys_ix sv_IVp | offsetof(struct xpvhv, xhv_keys)
1353 # The type checking code in B has always been identical for all SV types,
1354 # irrespective of whether the action is actually defined on that SV.
1355 # We should fix this
1360 B::IV::IVX = IV_ivx_ix
1361 B::IV::UVX = IV_uvx_ix
1362 B::NV::NVX = NV_nvx_ix
1363 B::NV::COP_SEQ_RANGE_LOW = NV_cop_seq_range_low_ix
1364 B::NV::COP_SEQ_RANGE_HIGH = NV_cop_seq_range_high_ix
1365 B::NV::PARENT_PAD_INDEX = NV_parent_pad_index_ix
1366 B::NV::PARENT_FAKELEX_FLAGS = NV_parent_fakelex_flags_ix
1367 B::PV::CUR = PV_cur_ix
1368 B::PV::LEN = PV_len_ix
1369 B::PVMG::SvSTASH = PVMG_stash_ix
1370 B::PVLV::TARGOFF = PVLV_targoff_ix
1371 B::PVLV::TARGLEN = PVLV_targlen_ix
1372 B::PVLV::TARG = PVLV_targ_ix
1373 B::PVLV::TYPE = PVLV_type_ix
1374 B::GV::STASH = PVGV_stash_ix
1375 B::GV::GvFLAGS = PVGV_flags_ix
1376 B::BM::USEFUL = PVBM_useful_ix
1377 B::IO::LINES = PVIO_lines_ix
1378 B::IO::PAGE = PVIO_page_ix
1379 B::IO::PAGE_LEN = PVIO_page_len_ix
1380 B::IO::LINES_LEFT = PVIO_lines_left_ix
1381 B::IO::TOP_NAME = PVIO_top_name_ix
1382 B::IO::TOP_GV = PVIO_top_gv_ix
1383 B::IO::FMT_NAME = PVIO_fmt_name_ix
1384 B::IO::FMT_GV = PVIO_fmt_gv_ix
1385 B::IO::BOTTOM_NAME = PVIO_bottom_name_ix
1386 B::IO::BOTTOM_GV = PVIO_bottom_gv_ix
1387 B::IO::IoTYPE = PVIO_type_ix
1388 B::IO::IoFLAGS = PVIO_flags_ix
1389 B::AV::MAX = PVAV_max_ix
1390 B::CV::STASH = PVCV_stash_ix
1391 B::CV::GV = PVCV_gv_ix
1392 B::CV::FILE = PVCV_file_ix
1393 B::CV::OUTSIDE = PVCV_outside_ix
1394 B::CV::OUTSIDE_SEQ = PVCV_outside_seq_ix
1395 B::CV::CvFLAGS = PVCV_flags_ix
1396 B::HV::MAX = PVHV_max_ix
1397 B::HV::KEYS = PVHV_keys_ix
1402 ptr = (ix & 0xFFFF) + (char *)SvANY(sv);
1403 switch ((U8)(ix >> 16)) {
1404 case (U8)(sv_SVp >> 16):
1405 if ((ix == (PVCV_gv_ix)) && CvNAMED(sv))
1406 ret = make_hek_object(aTHX_ CvNAME_HEK((CV*)sv));
1408 ret = make_sv_object(aTHX_ *((SV **)ptr));
1410 case (U8)(sv_IVp >> 16):
1411 ret = sv_2mortal(newSViv(*((IV *)ptr)));
1413 case (U8)(sv_UVp >> 16):
1414 ret = sv_2mortal(newSVuv(*((UV *)ptr)));
1416 case (U8)(sv_STRLENp >> 16):
1417 ret = sv_2mortal(newSVuv(*((STRLEN *)ptr)));
1419 case (U8)(sv_U32p >> 16):
1420 ret = sv_2mortal(newSVuv(*((U32 *)ptr)));
1422 case (U8)(sv_U8p >> 16):
1423 ret = sv_2mortal(newSVuv(*((U8 *)ptr)));
1425 case (U8)(sv_char_pp >> 16):
1426 ret = sv_2mortal(newSVpv(*((char **)ptr), 0));
1428 case (U8)(sv_NVp >> 16):
1429 ret = sv_2mortal(newSVnv(*((NV *)ptr)));
1431 case (U8)(sv_char_p >> 16):
1432 ret = newSVpvn_flags((char *)ptr, 1, SVs_TEMP);
1434 case (U8)(sv_SSize_tp >> 16):
1435 ret = sv_2mortal(newSViv(*((SSize_t *)ptr)));
1437 case (U8)(sv_I32p >> 16):
1438 ret = sv_2mortal(newSVuv(*((I32 *)ptr)));
1440 case (U8)(sv_U16p >> 16):
1441 ret = sv_2mortal(newSVuv(*((U16 *)ptr)));
1444 croak("Illegal alias 0x%08x for B::*IVX", (unsigned)ix);
1456 ST(0) = boolSV((I32)SvIVX(sv) != SvIVX(sv));
1457 } else if (sizeof(IV) == 8) {
1459 const IV iv = SvIVX(sv);
1461 * The following way of spelling 32 is to stop compilers on
1462 * 32-bit architectures from moaning about the shift count
1463 * being >= the width of the type. Such architectures don't
1464 * reach this code anyway (unless sizeof(IV) > 8 but then
1465 * everything else breaks too so I'm not fussed at the moment).
1468 wp[0] = htonl(((UV)iv) >> (sizeof(UV)*4));
1470 wp[0] = htonl(((U32)iv) >> (sizeof(UV)*4));
1472 wp[1] = htonl(iv & 0xffffffff);
1473 ST(0) = newSVpvn_flags((char *)wp, 8, SVs_TEMP);
1475 U32 w = htonl((U32)SvIVX(sv));
1476 ST(0) = newSVpvn_flags((char *)&w, 4, SVs_TEMP);
1479 MODULE = B PACKAGE = B::NV PREFIX = Sv
1485 #if PERL_VERSION < 11
1487 MODULE = B PACKAGE = B::RV PREFIX = Sv
1493 PUSHs(make_sv_object(aTHX_ SvRV(sv)));
1497 MODULE = B PACKAGE = B::REGEXP
1506 PUSHs(newSVpvn_flags(RX_PRECOMP(sv), RX_PRELEN(sv), SVs_TEMP));
1509 /* FIXME - can we code this method more efficiently? */
1515 MODULE = B PACKAGE = B::PV
1522 croak( "argument is not SvROK" );
1523 PUSHs(make_sv_object(aTHX_ SvRV(sv)));
1538 #ifndef PERL_FBM_TABLE_OFFSET
1539 const MAGIC *const mg = mg_find(sv, PERL_MAGIC_bm);
1542 croak("argument to B::BM::TABLE is not a PVBM");
1547 /* Boyer-Moore table is just after string and its safety-margin \0 */
1548 p += len + PERL_FBM_TABLE_OFFSET;
1551 } else if (ix == 2) {
1552 /* This used to read 257. I think that that was buggy - should have
1553 been 258. (The "\0", the flags byte, and 256 for the table.)
1554 The only user of this method is B::Bytecode in B::PV::bsave.
1555 I'm guessing that nothing tested the runtime correctness of
1556 output of bytecompiled string constant arguments to index (etc).
1558 Note the start pointer is and has always been SvPVX(sv), not
1559 SvPVX(sv) + SvCUR(sv) PVBM was added in 651aa52ea1faa806, and
1560 first used by the compiler in 651aa52ea1faa806. It's used to
1561 get a "complete" dump of the buffer at SvPVX(), not just the
1562 PVBM table. This permits the generated bytecode to "load"
1565 5.15 and later store the BM table via MAGIC, so the compiler
1566 should handle this just fine without changes if PVBM now
1567 always returns the SvPVX() buffer. */
1570 ? RX_WRAPPED_const((REGEXP*)sv)
1573 p = SvPVX_const(sv);
1575 #ifdef PERL_FBM_TABLE_OFFSET
1576 len = SvCUR(sv) + (SvVALID(sv) ? 256 + PERL_FBM_TABLE_OFFSET : 0);
1582 p = isREGEXP(sv) ? RX_WRAPPED((REGEXP*)sv) : SvPVX(sv);
1587 } else if (SvPOK(sv)) {
1589 p = SvPVX_const(sv);
1593 else if (isREGEXP(sv)) {
1595 p = RX_WRAPPED_const((REGEXP*)sv);
1600 /* XXX for backward compatibility, but should fail */
1601 /* croak( "argument is not SvPOK" ); */
1604 ST(0) = newSVpvn_flags(p, len, SVs_TEMP | utf8);
1606 MODULE = B PACKAGE = B::HEK
1618 pv = newSVpvn(HEK_KEY(hek), HEK_LEN(hek));
1619 if (HEK_UTF8(hek)) SvUTF8_on(pv);
1624 mPUSHu(HEK_LEN(hek));
1627 mPUSHu(HEK_FLAGS(hek));
1631 MODULE = B PACKAGE = B::PVMG
1636 MAGIC * mg = NO_INIT
1638 for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic)
1639 XPUSHs(make_mg_object(aTHX_ mg));
1641 MODULE = B PACKAGE = B::MAGIC
1658 XPUSHs(mg->mg_moremagic ? make_mg_object(aTHX_ mg->mg_moremagic)
1662 mPUSHu(mg->mg_private);
1665 PUSHs(newSVpvn_flags(&(mg->mg_type), 1, SVs_TEMP));
1668 mPUSHu(mg->mg_flags);
1674 PUSHs(make_sv_object(aTHX_ mg->mg_obj));
1678 if (mg->mg_len >= 0) {
1679 PUSHs(newSVpvn_flags(mg->mg_ptr, mg->mg_len, SVs_TEMP));
1680 } else if (mg->mg_len == HEf_SVKEY) {
1681 PUSHs(make_sv_object(aTHX_ (SV*)mg->mg_ptr));
1683 PUSHs(sv_newmortal());
1685 PUSHs(sv_newmortal());
1688 if(mg->mg_type == PERL_MAGIC_qr) {
1689 mPUSHi(PTR2IV(mg->mg_obj));
1691 croak("REGEX is only meaningful on r-magic");
1695 if (mg->mg_type == PERL_MAGIC_qr) {
1696 REGEXP *rx = (REGEXP *)mg->mg_obj;
1697 PUSHs(newSVpvn_flags(rx ? RX_PRECOMP(rx) : NULL,
1698 rx ? RX_PRELEN(rx) : 0, SVs_TEMP));
1700 croak( "precomp is only meaningful on r-magic" );
1705 MODULE = B PACKAGE = B::BM PREFIX = Bm
1715 MODULE = B PACKAGE = B::GV PREFIX = Gv
1724 ST(0) = sv_2mortal(newSVhek(!ix ? GvNAME_HEK(gv)
1725 : (ix == 1 ? GvFILE_HEK(gv)
1726 : HvNAME_HEK((HV *)gv))));
1735 RETVAL = isGV_with_GP(gv) ? TRUE : FALSE;
1737 RETVAL = GvGP(gv) == Null(GP*);
1746 #define GP_sv_ix SVp | offsetof(struct gp, gp_sv)
1747 #define GP_io_ix SVp | offsetof(struct gp, gp_io)
1748 #define GP_cv_ix SVp | offsetof(struct gp, gp_cv)
1749 #define GP_cvgen_ix U32p | offsetof(struct gp, gp_cvgen)
1750 #define GP_refcnt_ix U32p | offsetof(struct gp, gp_refcnt)
1751 #define GP_hv_ix SVp | offsetof(struct gp, gp_hv)
1752 #define GP_av_ix SVp | offsetof(struct gp, gp_av)
1753 #define GP_form_ix SVp | offsetof(struct gp, gp_form)
1754 #define GP_egv_ix SVp | offsetof(struct gp, gp_egv)
1755 #define GP_line_ix line_tp | offsetof(struct gp, gp_line)
1765 GvREFCNT = GP_refcnt_ix
1778 const GV *const gv = CvGV(cv);
1779 Perl_croak(aTHX_ "NULL gp in B::GV::%s", gv ? GvNAME(gv) : "???");
1781 ptr = (ix & 0xFFFF) + (char *)gp;
1782 switch ((U8)(ix >> 16)) {
1783 case (U8)(SVp >> 16):
1784 ret = make_sv_object(aTHX_ *((SV **)ptr));
1786 case (U8)(U32p >> 16):
1787 ret = sv_2mortal(newSVuv(*((U32*)ptr)));
1789 case (U8)(line_tp >> 16):
1790 ret = sv_2mortal(newSVuv(*((line_t *)ptr)));
1793 croak("Illegal alias 0x%08x for B::*SV", (unsigned)ix);
1802 PUSHs(make_sv_object(aTHX_ (SV *)GvFILEGV(gv)));
1804 MODULE = B PACKAGE = B::IO PREFIX = Io
1814 if( strEQ( name, "stdin" ) ) {
1815 handle = PerlIO_stdin();
1817 else if( strEQ( name, "stdout" ) ) {
1818 handle = PerlIO_stdout();
1820 else if( strEQ( name, "stderr" ) ) {
1821 handle = PerlIO_stderr();
1824 croak( "Invalid value '%s'", name );
1826 RETVAL = handle == IoIFP(io);
1830 MODULE = B PACKAGE = B::AV PREFIX = Av
1840 if (AvFILL(av) >= 0) {
1841 SV **svp = AvARRAY(av);
1843 for (i = 0; i <= AvFILL(av); i++)
1844 XPUSHs(make_sv_object(aTHX_ svp[i]));
1852 if (idx >= 0 && AvFILL(av) >= 0 && idx <= AvFILL(av))
1853 XPUSHs(make_sv_object(aTHX_ (AvARRAY(av)[idx])));
1855 XPUSHs(make_sv_object(aTHX_ NULL));
1858 MODULE = B PACKAGE = B::FM PREFIX = Fm
1861 #define FmLINES(sv) 0
1867 MODULE = B PACKAGE = B::CV PREFIX = Cv
1879 PUSHs(make_op_object(aTHX_ CvISXSUB(cv) ? NULL
1880 : ix ? CvROOT(cv) : CvSTART(cv)));
1898 PUSHs(make_sv_object(aTHX_ (SV *)CvPADLIST(cv)));
1909 ST(0) = ix && CvCONST(cv)
1910 ? make_sv_object(aTHX_ (SV *)CvXSUBANY(cv).any_ptr)
1911 : sv_2mortal(newSViv(CvISXSUB(cv)
1912 ? (ix ? CvXSUBANY(cv).any_iv
1913 : PTR2IV(CvXSUB(cv)))
1920 PUSHs(make_sv_object(aTHX_ (SV *)cv_const_sv(cv)));
1922 MODULE = B PACKAGE = B::HV PREFIX = Hv
1936 if (HvUSEDKEYS(hv) > 0) {
1940 (void)hv_iterinit(hv);
1941 EXTEND(sp, HvUSEDKEYS(hv) * 2);
1942 while ((sv = hv_iternextsv(hv, &key, &len))) {
1944 PUSHs(make_sv_object(aTHX_ sv));
1948 MODULE = B PACKAGE = B::HE PREFIX = He
1956 PUSHs(make_sv_object(aTHX_ ix ? HeSVKEY_force(he) : HeVAL(he)));
1962 MODULE = B PACKAGE = B::RHE
1968 RETVAL = newRV( (SV*)cophh_2hv(h, 0) );
1975 MODULE = B PACKAGE = B::PADLIST PREFIX = Padlist
1982 PadlistARRAY(padlist)
1985 if (PadlistMAX(padlist) >= 0) {
1986 PAD **padp = PadlistARRAY(padlist);
1988 for (i = 0; i <= PadlistMAX(padlist); i++)
1989 XPUSHs(make_sv_object(aTHX_ (SV *)padp[i]));
1993 PadlistARRAYelt(padlist, idx)
1997 if (PadlistMAX(padlist) >= 0
1998 && idx <= PadlistMAX(padlist))
1999 XPUSHs(make_sv_object(aTHX_
2000 (SV *)PadlistARRAY(padlist)[idx]));
2002 XPUSHs(make_sv_object(aTHX_ NULL));
2005 PadlistREFCNT(padlist)
2008 RETVAL = PadlistREFCNT(padlist);