summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorToby Inkster <mail@tobyinkster.co.uk>2013-07-25 16:46:46 +0100
committerJesse Luehrs <doy@tozt.net>2013-07-30 15:44:47 -0400
commita52d611f30176d32061d5f9386589f2404957d67 (patch)
treedfee269986866cd37c840becc3c4cf8222baf680 /lib
parent07bc152aec2d30461166e92420ccdd75db2baf3d (diff)
downloadeval-closure-a52d611f30176d32061d5f9386589f2404957d67.tar.gz
eval-closure-a52d611f30176d32061d5f9386589f2404957d67.zip
remove fallback option
Diffstat (limited to 'lib')
-rw-r--r--lib/Eval/Closure.pm29
1 files changed, 4 insertions, 25 deletions
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 {