diff options
Diffstat (limited to 'lib/App/REPL/Plugin/Packages.pm')
-rw-r--r-- | lib/App/REPL/Plugin/Packages.pm | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/App/REPL/Plugin/Packages.pm b/lib/App/REPL/Plugin/Packages.pm index d35d3f0..c1c02d0 100644 --- a/lib/App/REPL/Plugin/Packages.pm +++ b/lib/App/REPL/Plugin/Packages.pm @@ -13,18 +13,23 @@ sub new { return $self; } -sub evaluate { +sub mangle_line { my $self = shift; - my ($next, $line, %args) = @_; + my ($line) = @_; + + return "package $self->{package}; $line; BEGIN { \$" . __PACKAGE__ . "::package = __PACKAGE__ }"; +} + +sub compile { + my $self = shift; + my ($next, @args) = @_; # XXX it'd be nice to avoid using globals here, but we can't use # eval_closure's environment parameter since we need to access the # information in a BEGIN block our $package = $self->{package}; - $line = "package $package; $line; BEGIN { \$" . __PACKAGE__ . "::package = __PACKAGE__ }"; - - my @result = $next->($line, %args); + my @result = $next->(@args); $self->{package} = $package; |