From a52d611f30176d32061d5f9386589f2404957d67 Mon Sep 17 00:00:00 2001 From: Toby Inkster Date: Thu, 25 Jul 2013 16:46:46 +0100 Subject: remove fallback option --- lib/Eval/Closure.pm | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) (limited to 'lib') diff --git a/lib/Eval/Closure.pm b/lib/Eval/Closure.pm index 600e890..cd6a030 100644 --- a/lib/Eval/Closure.pm +++ b/lib/Eval/Closure.pm @@ -8,11 +8,11 @@ use Exporter 'import'; use Carp; use overload (); +use Devel::LexAlias (); use Scalar::Util qw(reftype); use Try::Tiny; -use constant HAS_LEXICAL_SUBS => $] >= 5.018; -use constant HAS_DEVEL_LEXALIAS => eval { require Devel::LexAlias }; +use constant HAS_LEXICAL_SUBS => $] >= 5.018; =head1 SYNOPSIS @@ -200,7 +200,7 @@ sub _clean_eval_closure { undef $code; } - _inject_captures($code, $captures); + Devel::LexAlias::lexalias($code, $_, $captures->{$_}) for keys %$captures; return ($code, $e); } @@ -245,28 +245,7 @@ sub _make_lexical_stub { . 'my ' . $tmpname . ' = $_[' . $index . ']; ' . 'my sub ' . $name . ' { goto ' . $tmpname . ' }'; } - elsif (HAS_DEVEL_LEXALIAS) { - return 'my ' . $key . ';'; - } - else { - return 'our ' . $key . ';'; - } -} - -sub _inject_captures -{ - my ($code, $captures) = @_; - - if (HAS_DEVEL_LEXALIAS) { - Devel::LexAlias::lexalias($code, $_, $captures->{$_}) for keys %$captures; - } - else { - no strict "refs"; - for (keys %$captures) { - my $slot = "Eval::Closure::Sandbox_${Eval::Closure::SANDBOX_ID}::" . substr($_, 1); - *{$slot} = $captures->{$_}; - } - } + return 'my ' . $key . ';'; } sub _dump_source { -- cgit v1.2.3-54-g00ecf