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/Hints.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/Hints.pm')
-rw-r--r-- | lib/App/REPL/Plugin/Hints.pm | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/App/REPL/Plugin/Hints.pm b/lib/App/REPL/Plugin/Hints.pm index 9d198e2..a09f117 100644 --- a/lib/App/REPL/Plugin/Hints.pm +++ b/lib/App/REPL/Plugin/Hints.pm @@ -25,7 +25,14 @@ sub new { return $self; } -sub evaluate { +sub mangle_line { + my $self = shift; + my ($line) = @_; + + return "BEGIN { \$^H = \$" . __PACKAGE__ . "::hints; \%^H = \%\$" . __PACKAGE__ . "::hinthash; \${^WARNING_BITS} = \$" . __PACKAGE__ . "::warning_bits } $line; BEGIN { \$" . __PACKAGE__ . "::hints = \$^H; \$" . __PACKAGE__ . "::hinthash = \\\%^H; \$" . __PACKAGE__ . "::warning_bits = \${^WARNING_BITS} }"; +} + +sub compile { my $self = shift; my ($next, $line, %args) = @_; @@ -36,8 +43,6 @@ sub evaluate { our $hinthash = $self->{hinthash}; our $warning_bits = $self->{warning_bits}; - $line = "BEGIN { \$^H = \$" . __PACKAGE__ . "::hints; \%^H = \%\$" . __PACKAGE__ . "::hinthash; \${^WARNING_BITS} = \$" . __PACKAGE__ . "::warning_bits } $line; BEGIN { \$" . __PACKAGE__ . "::hints = \$^H; \$" . __PACKAGE__ . "::hinthash = \\\%^H; \$" . __PACKAGE__ . "::warning_bits = \${^WARNING_BITS} }"; - my @result = $next->($line, %args); $self->{hints} = $hints; |