Actually, I thought so at first, but perhaps not. op_class[] is not available on Perl 5.24.4 and earlier. But leaving that aside, although the "name" method seems to return the right thing, other fields don't

When I try with:

sub testing { my $site = sub { callsite() }; my $addr = $site->(); printf "Op address is 0x%x\n", $addr; my $op = make_op_object($addr); printf("op %s, name: %s, parent: %s\n", $op, $op->name, $op->paren +t); # I can get OPs by walking and looking for $op_addr, # but I don't want to do that. my $walker = B::Concise::compile('-terse', '-src', \&testing); B::Concise::walk_output(\my $buf); $walker->(); # walks and renders into $buf; print $buf; } testing();
I get:
Op address is 0x55eddbdfba80 op B::OP=SCALAR(0x55eddba2c578), name: padsv, parent: B::BINOP=SCALAR( +0x55eddba422d0) B::Concise::compile(CODE(0x55eddbe20a80)) UNOP (0x55eddbe1ab10) leavesub [1] LISTOP (0x55eddbdfb9a0) lineseq # 37: my $site = sub { callsite() }; COP (0x55eddbab2048) nextstate BINOP (0x55eddbdfb9f8) sassign UNOP (0x55eddbdfba40) srefgen UNOP (0x55eddbdfbab8) null [157] SVOP (0x55eddbdfbb00) anoncode [2] CV (0x55eddba4d +0f8) OP (0x55eddbdfbb40) padsv [1] # 38: my $addr = $site->(); COP (0x55eddbab1e68) nextstate BINOP (0x55eddbab1ec8) sassign UNOP (0x55eddbab1f10) entersub [4] UNOP (0x55eddbab1f88) null [157] OP (0x55eddbab1f50) pushmark UNOP (0x55eddbab1fd0) null [16] OP (0x55eddbab2010) padsv [1] OP (0x55eddbdfba80) padsv [3]
Note that the address is different as is the parent.


In reply to Re^2: How can I turn an op address into the right kind of B::OP? by rockyb
in thread How can I turn an op address into the right kind of B::OP? by rockyb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.