Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

dragonchild's scratchpad

by dragonchild (Archbishop)
on Jun 01, 2004 at 17:21 UTC ( #358276=scratchpad: print w/ replies, xml ) Need Help??

The idea I had was to:
  1. Clone the subrefs
  2. Remove the ops which create the callframe and set @_ to the params passed in (except for the first one).
  3. Add in an op for a label at the end of the tree corresponding to SUB_N: (where N is the sub #.
  4. Replace the ops for "return (...)" with ops for "@_ = (...);goto SUB_N;" (except for the last one).
  5. String the converted subrefs together.

I'm figuring that the lexical pads don't need to be messed with because the ops should be referring to them by memory address. And, I do want the addresses to remain the same when cloning. The reason being:

{ my $counter; sub inc_counter { $counter++ } }

If I chain inc_counter(), I want it to keep incrementing $counter. Maybe it is an option to clone_subref()?

I figured that B::Generate should be able to do this very easily, except I haven't the foggiest where to start. :-)

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2014-08-20 13:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (113 votes), past polls