Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I assign an CV to a package with a list of opcodes?
    primarykey
    data
    text
    <p>I have been playing with the new parse_block feature in bleadperl,</p> <p>I can parse several statements into a listop, which would generate the tree below:</p> <pre><code>LISTOP (0x1002a00c0) leave [1] OP (0x1002d6220) enter COP (0x1002a0b80) nextstate OP (0x10028c0f0) null LISTOP (0x1002a0170) print OP (0x1002b1a90) pushmark SVOP (0x100327ee0) const PV (0x100826ec0) "hello\n" COP (0x1002a0c50) nextstate LISTOP (0x100324ee0) print OP (0x100327880) pushmark SVOP (0x100324eb0) const PV (0x100897688) "world\n" </code></pre> <p>I need to return a pointer to an optree structure from my keyword plugin, which at the moment just contains the bare list of ops. I want to wrap these ops inside a subroutine and assign it to a symbol within a stash.</p> <p>So I guess I want to do something like this:</p> <pre><code>$ perl -MO=Terse -e "*foo = sub { print 'my listops here' }" LISTOP (0x10022b5e0) leave [1] OP (0x10022b620) enter COP (0x10022b590) nextstate BINOP (0x100202090) sassign UNOP (0x1002083d0) refgen UNOP (0x100208360) null [146] OP (0x1002083a0) pushmark SVOP (0x100208330) anoncode [1] CV (0x100826d40) UNOP (0x1002085a0) rv2gv SVOP (0x100208550) gv GV (0x100826d28) *foo </code></pre> <p>Presumably I need to add entersub, leavesub at the beginning and end of my listops but I am not sure how I would go about constructing this in XS? Nor do I know how to turn the resulting optree in to a CV?</p> <p>I can find examples of generating a CV for xsubs but not from optrees. </p> <p>Thanks for your help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload