Overriding qx//

Dave Evans mkpm-20051014 at djce.org.uk
Thu Apr 13 12:13:04 PDT 2006

On Thu, Apr 13, 2006 at 02:03:32AM -0700, Nik Clayton wrote:
> Anyone got any insights as to how this might be achieved (short of
> grubbing around with XS)?

The answer that immediately came to mind was to modify the syntax tree after
compilation: i.e. turn the code "qx('stuff')":

LISTOP (0x81703a0) leave [1]
    OP (0x81702b0) enter
    COP (0x8170340) nextstate
    LISTOP (0x81704a8) print
        OP (0x8170300) pushmark
        UNOP (0x8170620) backtick [1]
            OP (0x81705c8) null [3]
            SVOP (0x81704e0) const [2] PV (0x81526b4) "stuff"

into "do_qx('stuff')":

LISTOP (0x81703a0) leave [1]
    OP (0x8170320) enter
    COP (0x8170340) nextstate
    LISTOP (0x81704a8) print
        OP (0x81702d0) pushmark
        UNOP (0x815a138) entersub [2]
            UNOP (0x8170620) null [141]
                OP (0x815a0e0) pushmark
                SVOP (0x81702b0) const [3] PV (0x8152630) "stuff"
                UNOP (0x81705c8) null [17]
                    PADOP (0x81704e0) gv  GV (0x81526b4) *do_qx

(and then implement the "do_qx" sub, of course).

Furthermore, the obvious point of reference for this was an article I read a
while back, by Damien Conway I suspect, about how to modify Acme::Don't so
that "don't { ... } unless ..." does The Right Thing.

However, I can't find the article :-(  I suspect it used B::Utils and/or
B::Generate, and I can't get B::Generate to compile.  So this post may or may not
be any help to you.


Dave Evans

PGP key: http://rudolf.org.uk/pgpkey
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: Digital signature
Url : http://mail.pm.org/pipermail/miltonkeynes-pm/attachments/20060413/0498c9e5/attachment.bin 

More information about the MiltonKeynes-pm mailing list