diff options
Diffstat (limited to 'dump.c')
-rw-r--r-- | dump.c | 773 |
1 files changed, 9 insertions, 764 deletions
@@ -884,7 +884,7 @@ S_op_private_to_names(pTHX_ SV *tmpsv, U32 optype, U32 op_private) { return FALSE; } -#define DUMP_OP_FLAGS(o,xml,level,file) \ +#define DUMP_OP_FLAGS(o,level,file) \ if (o->op_flags || o->op_slabbed || o->op_savefree || o->op_static) { \ SV * const tmpsv = newSVpvs(""); \ switch (o->op_flags & OPf_WANT) { \ @@ -906,22 +906,11 @@ S_op_private_to_names(pTHX_ SV *tmpsv, U32 optype, U32 op_private) { if (o->op_savefree) sv_catpvs(tmpsv, ",SAVEFREE"); \ if (o->op_static) sv_catpvs(tmpsv, ",STATIC"); \ if (o->op_folded) sv_catpvs(tmpsv, ",FOLDED"); \ - if (!xml) \ - Perl_dump_indent(aTHX_ level, file, "FLAGS = (%s)\n", \ - SvCUR(tmpsv) ? SvPVX_const(tmpsv) + 1 : "");\ - else \ - PerlIO_printf(file, " flags=\"%s\"", \ - SvCUR(tmpsv) ? SvPVX(tmpsv) + 1 : ""); \ + Perl_dump_indent(aTHX_ level, file, "FLAGS = (%s)\n", \ + SvCUR(tmpsv) ? SvPVX_const(tmpsv) + 1 : ""); \ } -#if !defined(PERL_MAD) -# define xmldump_attr1(level, file, pat, arg) -#else -# define xmldump_attr1(level, file, pat, arg) \ - S_xmldump_attr(aTHX_ level, file, pat, arg) -#endif - -#define DUMP_OP_PRIVATE(o,xml,level,file) \ +#define DUMP_OP_PRIVATE(o,level,file) \ if (o->op_private) { \ U32 optype = o->op_type; \ U32 oppriv = o->op_private; \ @@ -1003,11 +992,8 @@ S_op_private_to_names(pTHX_ SV *tmpsv, U32 optype, U32 op_private) { && oppriv & OPpSLICEWARNING ) \ sv_catpvs(tmpsv, ",SLICEWARNING"); \ if (SvCUR(tmpsv)) { \ - if (xml) \ - xmldump_attr1(level+1, file, "private=\"%s\"", SvPVX(tmpsv)+1); \ - else \ - Perl_dump_indent(aTHX_ level, file, "PRIVATE = (%s)\n", SvPVX_const(tmpsv) + 1); \ - } else if (!xml) \ + Perl_dump_indent(aTHX_ level, file, "PRIVATE = (%s)\n", SvPVX_const(tmpsv) + 1); \ + } else \ Perl_dump_indent(aTHX_ level, file, "PRIVATE = (0x%"UVxf")\n", \ (UV)oppriv); \ } @@ -1073,49 +1059,9 @@ Perl_do_op_dump(pTHX_ I32 level, PerlIO *file, const OP *o) Perl_dump_indent(aTHX_ level, file, "ADDR = 0x%"UVxf" => 0x%"UVxf"\n", (UV)o, (UV)o->op_next); #endif - DUMP_OP_FLAGS(o,0,level,file); - DUMP_OP_PRIVATE(o,0,level,file); - -#ifdef PERL_MAD - if (PL_madskills && o->op_madprop) { - SV * const tmpsv = newSVpvs(""); - MADPROP* mp = o->op_madprop; - Perl_dump_indent(aTHX_ level, file, "MADPROPS = {\n"); - level++; - while (mp) { - const char tmp = mp->mad_key; - sv_setpvs(tmpsv,"'"); - if (tmp) - sv_catpvn(tmpsv, &tmp, 1); - sv_catpv(tmpsv, "'="); - switch (mp->mad_type) { - case MAD_NULL: - sv_catpv(tmpsv, "NULL"); - Perl_dump_indent(aTHX_ level, file, "%s\n", SvPVX(tmpsv)); - break; - case MAD_PV: - sv_catpv(tmpsv, "<"); - sv_catpvn(tmpsv, (char*)mp->mad_val, mp->mad_vlen); - sv_catpv(tmpsv, ">"); - Perl_dump_indent(aTHX_ level, file, "%s\n", SvPVX(tmpsv)); - break; - case MAD_OP: - if ((OP*)mp->mad_val) { - Perl_dump_indent(aTHX_ level, file, "%s\n", SvPVX(tmpsv)); - do_op_dump(level, file, (OP*)mp->mad_val); - } - break; - default: - sv_catpv(tmpsv, "(UNK)"); - Perl_dump_indent(aTHX_ level, file, "%s\n", SvPVX(tmpsv)); - break; - } - mp = mp->mad_next; - } - level--; - Perl_dump_indent(aTHX_ level, file, "}\n"); - } -#endif + DUMP_OP_FLAGS(o,level,file); + DUMP_OP_PRIVATE(o,level,file); + switch (optype) { case OP_AELEMFAST: @@ -1130,11 +1076,6 @@ Perl_do_op_dump(pTHX_ I32 level, PerlIO *file, const OP *o) const char * name; SV * const tmpsv = newSVpvs_flags("", SVs_TEMP); SV * const tmpsv2 = newSVpvs_flags("", SVs_TEMP); -#ifdef PERL_MAD - /* FIXME - is this making unwarranted assumptions about the - UTF-8 cleanliness of the dump file handle? */ - SvUTF8_on(tmpsv); -#endif gv_fullname3(tmpsv, MUTABLE_GV(cSVOPo->op_sv), NULL); name = SvPV_const(tmpsv, len); Perl_dump_indent(aTHX_ level, file, "GV = %s\n", @@ -2461,11 +2402,6 @@ Perl_debop(pTHX_ const OP *o) case OP_GV: if (cGVOPo_gv) { SV * const sv = newSV(0); -#ifdef PERL_MAD - /* FIXME - is this making unwarranted assumptions about the - UTF-8 cleanliness of the dump file handle? */ - SvUTF8_on(sv); -#endif gv_fullname3(sv, cGVOPo_gv, NULL); PerlIO_printf(Perl_debug_log, "(%s)", SvPV_nolen_const(sv)); SvREFCNT_dec_NN(sv); @@ -2578,697 +2514,6 @@ Perl_debprofdump(pTHX) } } -#ifdef PERL_MAD -/* - * XML variants of most of the above routines - */ - -STATIC void -S_xmldump_attr(pTHX_ I32 level, PerlIO *file, const char* pat, ...) -{ - va_list args; - - PERL_ARGS_ASSERT_XMLDUMP_ATTR; - - PerlIO_printf(file, "\n "); - va_start(args, pat); - xmldump_vindent(level, file, pat, &args); - va_end(args); -} - - -void -Perl_xmldump_indent(pTHX_ I32 level, PerlIO *file, const char* pat, ...) -{ - va_list args; - PERL_ARGS_ASSERT_XMLDUMP_INDENT; - va_start(args, pat); - xmldump_vindent(level, file, pat, &args); - va_end(args); -} - -void -Perl_xmldump_vindent(pTHX_ I32 level, PerlIO *file, const char* pat, va_list *args) -{ - PERL_ARGS_ASSERT_XMLDUMP_VINDENT; - - PerlIO_printf(file, "%*s", (int)(level*PL_dumpindent), ""); - PerlIO_vprintf(file, pat, *args); -} - -void -Perl_xmldump_all(pTHX) -{ - xmldump_all_perl(FALSE); -} - -void -Perl_xmldump_all_perl(pTHX_ bool justperl PERL_UNUSED_DECL) -{ - PerlIO_setlinebuf(PL_xmlfp); - if (PL_main_root) - op_xmldump(PL_main_root); - /* someday we might call this, when it outputs XML: */ - /* xmldump_packsubs_perl(PL_defstash, justperl); */ - if (PL_xmlfp != (PerlIO*)PerlIO_stdout()) - PerlIO_close(PL_xmlfp); - PL_xmlfp = 0; -} - -void -Perl_xmldump_packsubs(pTHX_ const HV *stash) -{ - PERL_ARGS_ASSERT_XMLDUMP_PACKSUBS; - xmldump_packsubs_perl(stash, FALSE); -} - -void -Perl_xmldump_packsubs_perl(pTHX_ const HV *stash, bool justperl) -{ - I32 i; - HE *entry; - - PERL_ARGS_ASSERT_XMLDUMP_PACKSUBS_PERL; - - if (!HvARRAY(stash)) - return; - for (i = 0; i <= (I32) HvMAX(stash); i++) { - for (entry = HvARRAY(stash)[i]; entry; entry = HeNEXT(entry)) { - GV *gv = MUTABLE_GV(HeVAL(entry)); - HV *hv; - if (SvTYPE(gv) != SVt_PVGV || !GvGP(gv)) - continue; - if (GvCVu(gv)) - xmldump_sub_perl(gv, justperl); - if (GvFORM(gv)) - xmldump_form(gv); - if (HeKEY(entry)[HeKLEN(entry)-1] == ':' - && (hv = GvHV(gv)) && hv != PL_defstash) - xmldump_packsubs_perl(hv, justperl); /* nested package */ - } - } -} - -void -Perl_xmldump_sub(pTHX_ const GV *gv) -{ - PERL_ARGS_ASSERT_XMLDUMP_SUB; - xmldump_sub_perl(gv, FALSE); -} - -void -Perl_xmldump_sub_perl(pTHX_ const GV *gv, bool justperl) -{ - SV * sv; - - PERL_ARGS_ASSERT_XMLDUMP_SUB_PERL; - - if (justperl && (CvISXSUB(GvCV(gv)) || !CvROOT(GvCV(gv)))) - return; - - sv = sv_newmortal(); - gv_fullname3(sv, gv, NULL); - Perl_xmldump_indent(aTHX_ 0, PL_xmlfp, "\nSUB %s = ", SvPVX(sv)); - if (CvXSUB(GvCV(gv))) - Perl_xmldump_indent(aTHX_ 0, PL_xmlfp, "(xsub 0x%"UVxf" %d)\n", - PTR2UV(CvXSUB(GvCV(gv))), - (int)CvXSUBANY(GvCV(gv)).any_i32); - else if (CvROOT(GvCV(gv))) - op_xmldump(CvROOT(GvCV(gv))); - else - Perl_xmldump_indent(aTHX_ 0, PL_xmlfp, "<undef>\n"); -} - -void -Perl_xmldump_form(pTHX_ const GV *gv) -{ - SV * const sv = sv_newmortal(); - - PERL_ARGS_ASSERT_XMLDUMP_FORM; - - gv_fullname3(sv, gv, NULL); - Perl_xmldump_indent(aTHX_ 0, PL_xmlfp, "\nFORMAT %s = ", SvPVX(sv)); - if (CvROOT(GvFORM(gv))) - op_xmldump(CvROOT(GvFORM(gv))); - else - Perl_xmldump_indent(aTHX_ 0, PL_xmlfp, "<undef>\n"); -} - -void -Perl_xmldump_eval(pTHX) -{ - op_xmldump(PL_eval_root); -} - -char * -Perl_sv_catxmlsv(pTHX_ SV *dsv, SV *ssv) -{ - PERL_ARGS_ASSERT_SV_CATXMLSV; - return sv_catxmlpvn(dsv, SvPVX(ssv), SvCUR(ssv), SvUTF8(ssv)); -} - -char * -Perl_sv_catxmlpv(pTHX_ SV *dsv, const char *pv, int utf8) -{ - PERL_ARGS_ASSERT_SV_CATXMLPV; - return sv_catxmlpvn(dsv, pv, strlen(pv), utf8); -} - -char * -Perl_sv_catxmlpvn(pTHX_ SV *dsv, const char *pv, STRLEN len, int utf8) -{ - unsigned int c; - const char * const e = pv + len; - const char * const start = pv; - STRLEN dsvcur; - STRLEN cl; - - PERL_ARGS_ASSERT_SV_CATXMLPVN; - - sv_catpvs(dsv,""); - dsvcur = SvCUR(dsv); /* in case we have to restart */ - - retry: - while (pv < e) { - if (utf8) { - c = utf8_to_uvchr_buf((U8*)pv, (U8*)e, &cl); - if (cl == 0) { - SvCUR(dsv) = dsvcur; - pv = start; - utf8 = 0; - goto retry; - } - } - else - c = (*pv & 255); - - if (isCNTRL_L1(c) - && c != '\t' - && c != '\n' - && c != '\r' - && c != LATIN1_TO_NATIVE(0x85)) - { - Perl_sv_catpvf(aTHX_ dsv, "STUPIDXML(#x%X)", c); - } - else switch (c) { - case '<': - sv_catpvs(dsv, "<"); - break; - case '>': - sv_catpvs(dsv, ">"); - break; - case '&': - sv_catpvs(dsv, "&"); - break; - case '"': - sv_catpvs(dsv, """); - break; - default: - if (c < 0xD800) { - if (! isPRINT(c)) { - Perl_sv_catpvf(aTHX_ dsv, "&#x%X;", c); - } - else { - const char string = (char) c; - sv_catpvn(dsv, &string, 1); - } - break; - } - if ((c >= 0xD800 && c <= 0xDB7F) || - (c >= 0xDC00 && c <= 0xDFFF) || - (c >= 0xFFF0 && c <= 0xFFFF) || - c > 0x10ffff) - Perl_sv_catpvf(aTHX_ dsv, "STUPIDXML(#x%X)", c); - else - Perl_sv_catpvf(aTHX_ dsv, "&#x%X;", c); - } - - if (utf8) - pv += UTF8SKIP(pv); - else - pv++; - } - - return SvPVX(dsv); -} - -char * -Perl_sv_xmlpeek(pTHX_ SV *sv) -{ - SV * const t = sv_newmortal(); - STRLEN n_a; - int unref = 0; - - PERL_ARGS_ASSERT_SV_XMLPEEK; - - sv_utf8_upgrade(t); - sv_setpvs(t, ""); - /* retry: */ - if (!sv) { - sv_catpv(t, "VOID=\"\""); - goto finish; - } - else if (sv == (const SV *)0x55555555 || ((char)SvTYPE(sv)) == 'U') { - sv_catpv(t, "WILD=\"\""); - goto finish; - } - else if (sv == &PL_sv_undef || sv == &PL_sv_no || sv == &PL_sv_yes || sv == &PL_sv_placeholder) { - if (sv == &PL_sv_undef) { - sv_catpv(t, "SV_UNDEF=\"1\""); - if (!(SvFLAGS(sv) & (SVf_OK|SVf_OOK|SVs_OBJECT| - SVs_GMG|SVs_SMG|SVs_RMG)) && - SvREADONLY(sv)) - goto finish; - } - else if (sv == &PL_sv_no) { - sv_catpv(t, "SV_NO=\"1\""); - if (!(SvFLAGS(sv) & (SVf_ROK|SVf_OOK|SVs_OBJECT| - SVs_GMG|SVs_SMG|SVs_RMG)) && - !(~SvFLAGS(sv) & (SVf_POK|SVf_NOK|SVf_READONLY| - SVp_POK|SVp_NOK)) && - SvCUR(sv) == 0 && - SvNVX(sv) == 0.0) - goto finish; - } - else if (sv == &PL_sv_yes) { - sv_catpv(t, "SV_YES=\"1\""); - if (!(SvFLAGS(sv) & (SVf_ROK|SVf_OOK|SVs_OBJECT| - SVs_GMG|SVs_SMG|SVs_RMG)) && - !(~SvFLAGS(sv) & (SVf_POK|SVf_NOK|SVf_READONLY| - SVp_POK|SVp_NOK)) && - SvCUR(sv) == 1 && - SvPVX(sv) && *SvPVX(sv) == '1' && - SvNVX(sv) == 1.0) - goto finish; - } - else { - sv_catpv(t, "SV_PLACEHOLDER=\"1\""); - if (!(SvFLAGS(sv) & (SVf_OK|SVf_OOK|SVs_OBJECT| - SVs_GMG|SVs_SMG|SVs_RMG)) && - SvREADONLY(sv)) - goto finish; - } - sv_catpv(t, " XXX=\"\" "); - } - else if (SvREFCNT(sv) == 0) { - sv_catpv(t, " refcnt=\"0\""); - unref++; - } - else if (DEBUG_R_TEST_) { - int is_tmp = 0; - SSize_t ix; - /* is this SV on the tmps stack? */ - for (ix=PL_tmps_ix; ix>=0; ix--) { - if (PL_tmps_stack[ix] == sv) { - is_tmp = 1; - break; - } - } - if (SvREFCNT(sv) > 1) - Perl_sv_catpvf(aTHX_ t, " DRT=\"<%"UVuf"%s>\"", (UV)SvREFCNT(sv), - is_tmp ? "T" : ""); - else if (is_tmp) - sv_catpv(t, " DRT=\"<T>\""); - } - - if (SvROK(sv)) { - sv_catpv(t, " ROK=\"\""); - } - switch (SvTYPE(sv)) { - default: - sv_catpv(t, " FREED=\"1\""); - goto finish; - - case SVt_NULL: - sv_catpv(t, " UNDEF=\"1\""); - goto finish; - case SVt_IV: - sv_catpv(t, " IV=\""); - break; - case SVt_NV: - sv_catpv(t, " NV=\""); - break; - case SVt_PV: - sv_catpv(t, " PV=\""); - break; - case SVt_PVIV: - sv_catpv(t, " PVIV=\""); - break; - case SVt_PVNV: - sv_catpv(t, " PVNV=\""); - break; - case SVt_PVMG: - sv_catpv(t, " PVMG=\""); - break; - case SVt_PVLV: - sv_catpv(t, " PVLV=\""); - break; - case SVt_PVAV: - sv_catpv(t, " AV=\""); - break; - case SVt_PVHV: - sv_catpv(t, " HV=\""); - break; - case SVt_PVCV: - if (CvGV(sv)) - Perl_sv_catpvf(aTHX_ t, " CV=\"(%s)\"", GvNAME(CvGV(sv))); - else - sv_catpv(t, " CV=\"()\""); - goto finish; - case SVt_PVGV: - sv_catpv(t, " GV=\""); - break; - case SVt_INVLIST: - sv_catpv(t, " DUMMY=\""); - break; - case SVt_REGEXP: - sv_catpv(t, " REGEXP=\""); - break; - case SVt_PVFM: - sv_catpv(t, " FM=\""); - break; - case SVt_PVIO: - sv_catpv(t, " IO=\""); - break; - } - - if (SvPOKp(sv)) { - if (SvPVX(sv)) { - sv_catxmlsv(t, sv); - } - } - else if (SvNOKp(sv)) { - STORE_NUMERIC_LOCAL_SET_STANDARD(); - Perl_sv_catpvf(aTHX_ t, "%"NVgf"",SvNVX(sv)); - RESTORE_NUMERIC_LOCAL(); - } - else if (SvIOKp(sv)) { - if (SvIsUV(sv)) - Perl_sv_catpvf(aTHX_ t, "%"UVuf"", (UV)SvUVX(sv)); - else - Perl_sv_catpvf(aTHX_ t, "%"IVdf"", (IV)SvIVX(sv)); - } - else - sv_catpv(t, ""); - sv_catpv(t, "\""); - - finish: - while (unref--) - sv_catpv(t, ")"); - return SvPV(t, n_a); -} - -void -Perl_do_pmop_xmldump(pTHX_ I32 level, PerlIO *file, const PMOP *pm) -{ - PERL_ARGS_ASSERT_DO_PMOP_XMLDUMP; - - if (!pm) { - Perl_xmldump_indent(aTHX_ level, file, "<pmop/>\n"); - return; - } - Perl_xmldump_indent(aTHX_ level, file, "<pmop \n"); - level++; - if (PM_GETRE(pm)) { - REGEXP *const r = PM_GETRE(pm); - SV * const tmpsv = newSVpvn_utf8("", 0, TRUE); - sv_catxmlsv(tmpsv, MUTABLE_SV(r)); - Perl_xmldump_indent(aTHX_ level, file, "pre=\"%s\"\n", - SvPVX(tmpsv)); - SvREFCNT_dec_NN(tmpsv); - Perl_xmldump_indent(aTHX_ level, file, "when=\"%s\"\n", - (pm->op_private & OPpRUNTIME) ? "RUN" : "COMP"); - } - else - Perl_xmldump_indent(aTHX_ level, file, "pre=\"\" when=\"RUN\"\n"); - if (pm->op_pmflags || (PM_GETRE(pm) && RX_CHECK_SUBSTR(PM_GETRE(pm)))) { - SV * const tmpsv = pm_description(pm); - Perl_xmldump_indent(aTHX_ level, file, "pmflags=\"%s\"\n", SvCUR(tmpsv) ? SvPVX(tmpsv) + 1 : ""); - SvREFCNT_dec_NN(tmpsv); - } - - level--; - if (pm->op_type != OP_PUSHRE && pm->op_pmreplrootu.op_pmreplroot) { - Perl_xmldump_indent(aTHX_ level, file, ">\n"); - Perl_xmldump_indent(aTHX_ level+1, file, "<pm_repl>\n"); - do_op_xmldump(level+2, file, pm->op_pmreplrootu.op_pmreplroot); - Perl_xmldump_indent(aTHX_ level+1, file, "</pm_repl>\n"); - Perl_xmldump_indent(aTHX_ level, file, "</pmop>\n"); - } - else - Perl_xmldump_indent(aTHX_ level, file, "/>\n"); -} - -void -Perl_pmop_xmldump(pTHX_ const PMOP *pm) -{ - do_pmop_xmldump(0, PL_xmlfp, pm); -} - -void -Perl_do_op_xmldump(pTHX_ I32 level, PerlIO *file, const OP *o) -{ - UV seq; - int contents = 0; - const OPCODE optype = o->op_type; - - PERL_ARGS_ASSERT_DO_OP_XMLDUMP; - - if (!o) - return; - seq = sequence_num(o); - Perl_xmldump_indent(aTHX_ level, file, - "<op_%s seq=\"%"UVuf" -> ", - OP_NAME(o), - seq); - level++; - if (o->op_next) - PerlIO_printf(file, seq ? "%"UVuf"\"" : "(%"UVuf")\"", - sequence_num(o->op_next)); - else - PerlIO_printf(file, "DONE\""); - - if (o->op_targ) { - if (optype == OP_NULL) - { - PerlIO_printf(file, " was=\"%s\"", PL_op_name[o->op_targ]); - if (o->op_targ == OP_NEXTSTATE) - { - if (CopLINE(cCOPo)) - PerlIO_printf(file, " line=\"%"UVuf"\"", - (UV)CopLINE(cCOPo)); - if (CopSTASHPV(cCOPo)) - PerlIO_printf(file, " package=\"%s\"", - CopSTASHPV(cCOPo)); - if (CopLABEL(cCOPo)) - PerlIO_printf(file, " label=\"%s\"", - CopLABEL(cCOPo)); - } - } - else - PerlIO_printf(file, " targ=\"%ld\"", (long)o->op_targ); - } -#ifdef DUMPADDR - PerlIO_printf(file, " addr=\"0x%"UVxf" => 0x%"UVxf"\"", (UV)o, (UV)o->op_next); -#endif - - DUMP_OP_FLAGS(o,1,0,file); - DUMP_OP_PRIVATE(o,1,0,file); - - switch (optype) { - case OP_AELEMFAST: - if (o->op_flags & OPf_SPECIAL) { - break; - } - case OP_GVSV: - case OP_GV: -#ifdef USE_ITHREADS - S_xmldump_attr(aTHX_ level, file, "padix=\"%" IVdf "\"", (IV)cPADOPo->op_padix); -#else - if (cSVOPo->op_sv) { - SV * const tmpsv1 = newSVpvn_utf8(NULL, 0, TRUE); - SV * const tmpsv2 = newSVpvn_utf8("", 0, TRUE); - char *s; - STRLEN len; - ENTER; - SAVEFREESV(tmpsv1); - SAVEFREESV(tmpsv2); - gv_fullname3(tmpsv1, MUTABLE_GV(cSVOPo->op_sv), NULL); - s = SvPV(tmpsv1,len); - sv_catxmlpvn(tmpsv2, s, len, 1); - S_xmldump_attr(aTHX_ level, file, "gv=\"%s\"", SvPV(tmpsv2, len)); - LEAVE; - } - else - S_xmldump_attr(aTHX_ level, file, "gv=\"NULL\""); -#endif - break; - case OP_CONST: - case OP_HINTSEVAL: - case OP_METHOD_NAMED: -#ifndef USE_ITHREADS - /* with ITHREADS, consts are stored in the pad, and the right pad - * may not be active here, so skip */ - S_xmldump_attr(aTHX_ level, file, "%s", sv_xmlpeek(cSVOPo_sv)); -#endif - break; - case OP_ANONCODE: - if (!contents) { - contents = 1; - PerlIO_printf(file, ">\n"); - } - do_op_xmldump(level+1, file, CvROOT(cSVOPo_sv)); - break; - case OP_NEXTSTATE: - case OP_DBSTATE: - if (CopLINE(cCOPo)) - S_xmldump_attr(aTHX_ level, file, "line=\"%"UVuf"\"", - (UV)CopLINE(cCOPo)); - if (CopSTASHPV(cCOPo)) - S_xmldump_attr(aTHX_ level, file, "package=\"%s\"", - CopSTASHPV(cCOPo)); - if (CopLABEL(cCOPo)) - S_xmldump_attr(aTHX_ level, file, "label=\"%s\"", - CopLABEL(cCOPo)); - break; - case OP_ENTERLOOP: - S_xmldump_attr(aTHX_ level, file, "redo=\""); - if (cLOOPo->op_redoop) - PerlIO_printf(file, "%"UVuf"\"", sequence_num(cLOOPo->op_redoop)); - else - PerlIO_printf(file, "DONE\""); - S_xmldump_attr(aTHX_ level, file, "next=\""); - if (cLOOPo->op_nextop) - PerlIO_printf(file, "%"UVuf"\"", sequence_num(cLOOPo->op_nextop)); - else - PerlIO_printf(file, "DONE\""); - S_xmldump_attr(aTHX_ level, file, "last=\""); - if (cLOOPo->op_lastop) - PerlIO_printf(file, "%"UVuf"\"", sequence_num(cLOOPo->op_lastop)); - else - PerlIO_printf(file, "DONE\""); - break; - case OP_COND_EXPR: - case OP_RANGE: - case OP_MAPWHILE: - case OP_GREPWHILE: - case OP_OR: - case OP_AND: - S_xmldump_attr(aTHX_ level, file, "other=\""); - if (cLOGOPo->op_other) - PerlIO_printf(file, "%"UVuf"\"", sequence_num(cLOGOPo->op_other)); - else - PerlIO_printf(file, "DONE\""); - break; - case OP_LEAVE: - case OP_LEAVEEVAL: - case OP_LEAVESUB: - case OP_LEAVESUBLV: - case OP_LEAVEWRITE: - case OP_SCOPE: - if (o->op_private & OPpREFCOUNTED) - S_xmldump_attr(aTHX_ level, file, "refcnt=\"%"UVuf"\"", (UV)o->op_targ); - break; - default: - break; - } - - if (PL_madskills && o->op_madprop) { - char prevkey = '\0'; - SV * const tmpsv = newSVpvn_utf8("", 0, TRUE); - const MADPROP* mp = o->op_madprop; - - if (!contents) { - contents = 1; - PerlIO_printf(file, ">\n"); - } - Perl_xmldump_indent(aTHX_ level, file, "<madprops>\n"); - level++; - while (mp) { - char tmp = mp->mad_key; - sv_setpvs(tmpsv,"\""); - if (tmp) - sv_catxmlpvn(tmpsv, &tmp, 1, 0); - if ((tmp == '_') || (tmp == '#')) /* '_' '#' whitespace belong to the previous token. */ - sv_catxmlpvn(tmpsv, &prevkey, 1, 0); - else - prevkey = tmp; - sv_catpv(tmpsv, "\""); - switch (mp->mad_type) { - case MAD_NULL: - sv_catpv(tmpsv, "NULL"); - Perl_xmldump_indent(aTHX_ level, file, "<mad_null key=%s/>\n", SvPVX(tmpsv)); - break; - case MAD_PV: - sv_catpv(tmpsv, " val=\""); - sv_catxmlpvn(tmpsv, (char*)mp->mad_val, mp->mad_vlen,1); - sv_catpv(tmpsv, "\""); - Perl_xmldump_indent(aTHX_ level, file, "<mad_pv key=%s/>\n", SvPVX(tmpsv)); - break; - case MAD_SV: - sv_catpv(tmpsv, " val=\""); - sv_catxmlsv(tmpsv, MUTABLE_SV(mp->mad_val)); - sv_catpv(tmpsv, "\""); - Perl_xmldump_indent(aTHX_ level, file, "<mad_sv key=%s/>\n", SvPVX(tmpsv)); - break; - case MAD_OP: - if ((OP*)mp->mad_val) { - Perl_xmldump_indent(aTHX_ level, file, "<mad_op key=%s>\n", SvPVX(tmpsv)); - do_op_xmldump(level+1, file, (OP*)mp->mad_val); - Perl_xmldump_indent(aTHX_ level, file, "</mad_op>\n"); - } - break; - default: - Perl_xmldump_indent(aTHX_ level, file, "<mad_unk key=%s/>\n", SvPVX(tmpsv)); - break; - } - mp = mp->mad_next; - } - level--; - Perl_xmldump_indent(aTHX_ level, file, "</madprops>\n"); - - SvREFCNT_dec_NN(tmpsv); - } - - switch (optype) { - case OP_PUSHRE: - case OP_MATCH: - case OP_QR: - case OP_SUBST: - if (!contents) { - contents = 1; - PerlIO_printf(file, ">\n"); - } - do_pmop_xmldump(level, file, cPMOPo); - break; - default: - break; - } - - if (o->op_flags & OPf_KIDS) { - OP *kid; - if (!contents) { - contents = 1; - PerlIO_printf(file, ">\n"); - } - for (kid = cUNOPo->op_first; kid; kid = kid->op_sibling) - do_op_xmldump(level, file, kid); - } - - if (contents) - Perl_xmldump_indent(aTHX_ level-1, file, "</op_%s>\n", OP_NAME(o)); - else - PerlIO_printf(file, " />\n"); -} - -void -Perl_op_xmldump(pTHX_ const OP *o) -{ - PERL_ARGS_ASSERT_OP_XMLDUMP; - - do_op_xmldump(0, PL_xmlfp, o); -} -#endif /* * Local variables: |