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 --- dist.ini | 2 -- lib/Eval/Closure.pm | 29 ++++------------------------- t/close-over.t | 6 ++---- 3 files changed, 6 insertions(+), 31 deletions(-) diff --git a/dist.ini b/dist.ini index ba39718..0c17480 100644 --- a/dist.ini +++ b/dist.ini @@ -13,10 +13,8 @@ bugtracker_mailto = [AutoPrereqs] skip = ^Perl::Tidy$ skip = ^perl$ -skip = ^Devel::LexAlias$ [Prereqs / RuntimeRecommends] Perl::Tidy = 0 -Devel::LexAlias = 0.05 [ContributorsFromGit] 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 { diff --git a/t/close-over.t b/t/close-over.t index 6aa0f25..254ec40 100644 --- a/t/close-over.t +++ b/t/close-over.t @@ -9,8 +9,7 @@ use Eval::Closure; use Test::Requires 'PadWalker'; -SKIP: { - skip "Devel::LexAlias not available", 1 unless Eval::Closure::HAS_DEVEL_LEXALIAS; +{ my $foo = []; my $env = { '$foo' => \$foo }; @@ -22,8 +21,7 @@ SKIP: { "closed over the right things"); } -SKIP: { - skip "Devel::LexAlias not available", 1 unless Eval::Closure::HAS_DEVEL_LEXALIAS; +{ my $foo = {}; my $bar = []; my $env = { '$foo' => \$bar, '$bar' => \$foo }; -- cgit v1.2.3-54-g00ecf