scratchpad
dragonchild
The idea I had was to:
<ol>
<li>Clone the subrefs
<li>Remove the ops which create the callframe and set @_ to the params
passed in (except for the first one).
<li>Add in an op for a label at the end of the tree corresponding to
SUB_N: (where N is the sub #.
<li>Replace the ops for "return (...)" with ops for "@_ = (...);goto
SUB_N;" (except for the last one).
<li>String the converted subrefs together.
</ol>
<p>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:
<code>
{
my $counter;
sub inc_counter { $counter++ }
}
</code>
<p>If I chain inc_counter(), I want it to keep incrementing $counter.
Maybe it is an option to clone_subref()?
<p>I figured that B::Generate should be able to do this very easily,
except I haven't the foggiest where to start. :-)