diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-05-30 03:12:25 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-05-30 03:12:25 -0500 |
commit | 071e98547d4dda83c29ea87cd4cff9115667bf24 (patch) | |
tree | 5b20f0019eb42b385f7a452c973991a1149ef625 /lib/App/REPL/Plugin/LexicalPersistence.pm | |
parent | 34218fd2af78b254dd424de2289981621ee85f94 (diff) | |
download | reply-071e98547d4dda83c29ea87cd4cff9115667bf24.tar.gz reply-071e98547d4dda83c29ea87cd4cff9115667bf24.zip |
split evaluate into compile and execute
Diffstat (limited to 'lib/App/REPL/Plugin/LexicalPersistence.pm')
-rw-r--r-- | lib/App/REPL/Plugin/LexicalPersistence.pm | 12 |
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; |