summaryrefslogtreecommitdiffstats
path: root/lib/App/REPL/Plugin/LexicalPersistence.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/App/REPL/Plugin/LexicalPersistence.pm')
-rw-r--r--lib/App/REPL/Plugin/LexicalPersistence.pm12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/App/REPL/Plugin/LexicalPersistence.pm b/lib/App/REPL/Plugin/LexicalPersistence.pm
index 6c9b1d3..986fa03 100644
--- a/lib/App/REPL/Plugin/LexicalPersistence.pm
+++ b/lib/App/REPL/Plugin/LexicalPersistence.pm
@@ -13,13 +13,19 @@ sub new {
return $self;
}
-sub evaluate {
+sub compile {
my $self = shift;
my ($next, $line, %args) = @_;
- $line = $self->{env}->prepare($line);
+ my %c = %{ $self->{env}->get_context('_') };
+
+ $args{environment} ||= {};
+ $args{environment} = {
+ %{ $args{environment} },
+ (map { $_ => ref($c{$_}) ? $c{$_} : \$c{$_} } keys %c),
+ };
my ($code) = $next->($line, %args);
- return $self->{env}->call($code);
+ return $self->{env}->wrap($code);
}
1;