Welcome to the Monastery | |
PerlMonks |
Re^2: RFC: Is there more to alias?by xmath (Hermit) |
on Aug 24, 2004 at 22:24 UTC ( [id://385530]=note: print w/replies, xml ) | Need Help?? |
The hard part was getting any sort of "trigger" on the occurrence of alias (which is just a declared but undefined sub). The breakthrough was the discovery of PL_check and the fact it's editable. This array contains a list of "check functions" which are invoked whenever a node is created in the op-tree. I used it to trigger on OP_RV2CV (the occurrence of "alias" or "copy") and OP_ENTERSUB (the completion of the op-subtree that invokes it). I do some initial modifications of the op-tree, and in particular mark is so I can find it later. When alias/copy has been seen I also temporarily override PL_peepp. There I scan the optree for markings and do the actual work, which consists mostly of setting the op_ppaddr of various ops inside alias to aliasing equivalents. A final piece of the puzzle is supporting alias BLOCK which involves a lexer hack, but is mostly unrelated to the rest. It may indeed be applicable in other situations. I was already thinking about how I could make this mechanism more reusable. Any further details you want?
In Section
Meditations
|
|