1 package Eval::WithLexicals::WithHintPersistence;
13 default => sub { {} },
20 local *Eval::WithLexicals::Cage::capture_hints;
21 local $Eval::WithLexicals::Cage::hints = { %{$self->hints} };
23 my @ret = $orig->(@_);
25 $self->hints({ Eval::WithLexicals::Cage::capture_hints() });
30 # XXX: Sub::Quote::capture_unroll without 'my'
32 sub _capture_unroll_global {
33 my ($from, $captures, $indent) = @_;
38 or die "capture key should start with \@, \% or \$: $_";
39 (' ' x $indent).qq{${_} = ${1}{${from}->{${\B::perlstring $_}}};\n};
44 around setup_code => sub {
45 shift; # we bypass orig, i.e. using role as normal inheritance.
47 # Only run the prelude on the first eval, hints will be set after
49 if($self->first_eval) {
51 return $self->prelude;
53 # Seems we can't use the technique of passing via @_ for code in a BEGIN
56 _capture_unroll_global('$Eval::WithLexicals::Cage::hints', $self->hints, 2),
61 around capture_code => sub {
65 ( q{ sub Eval::WithLexicals::Cage::capture_hints {
66 no warnings 'closure'; # XXX: can we limit the scope of this?
68 BEGIN { $hints = $^H; %hints = %^H; }
69 return q{$^H} => \$hints, q{%^H} => \%hints;