Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

PadWalker

Native Rust implementation built into the interpreter. Runtime: P5. See original documentation for the full Perl reference.

Limitations

The p5 runtime stores pads as flat arrays of *mut P5Sv without any name metadata at runtime. Neither P5CvBody nor P5Interp carry pad slot names — those exist only at compile time in the codegen’s OpArena and are not preserved into the interpreter.

As a result, PadWalker introspection functions cannot map pad slots to variable names. They return correctly-typed empty hashrefs (which is what callers expect) rather than bare undef (which causes type errors downstream).

To make PadWalker fully functional in the p5 runtime, pad name arrays would need to be stored on P5CvBody and P5Interp — a change outside the scope of this module.

Functions

closed_over

return hashref of closed-over variables for a CV.

Returns empty hashref — p5 runtime lacks pad name metadata.

peek_my

return hashref of my variables at call depth $level.

Level 0 = the calling sub’s pad. Level N = N sub frames up.

NOTE: The p5 runtime does not store pad slot names at runtime, so we return an empty hashref (correct type, no entries). This avoids type errors in callers that expect hashref returns.

peek_our

return hashref of our variables at call depth $level.

NOTE: Returns empty hashref — p5 runtime lacks pad name metadata.

peek_sub

return hashref of all pad variables for a CV.

Dies if the argument is not a code reference. Returns empty hashref for user subs (no pad name data available). Dies with “no padlist” for native/stub subs (matches perl5 XS behaviour).

set_closed_over

replace closed-over variables from a hashref.

No-op in p5 runtime — pad name metadata not available to map names to slots.

var_name

Returns undef — p5 runtime lacks pad name metadata.