From 3e19fb26f62ce9fa02e417c015f6668989d1eaad Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 7 Aug 2013 22:28:04 -0400 Subject: convert all of the plugins --- lib/Reply/Plugin/Hints.pm | 71 ++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 41 deletions(-) (limited to 'lib/Reply/Plugin/Hints.pm') diff --git a/lib/Reply/Plugin/Hints.pm b/lib/Reply/Plugin/Hints.pm index d36d14a..a944e40 100644 --- a/lib/Reply/Plugin/Hints.pm +++ b/lib/Reply/Plugin/Hints.pm @@ -1,11 +1,11 @@ -package Reply::Plugin::Hints; +package main; my $default_hints; my $default_hinthash; my $default_warning_bits; BEGIN { $default_hints = $^H; - $default_hinthash = \%^H; + $default_hinthash = { %^H }; $default_warning_bits = ${^WARNING_BITS}; } @@ -13,7 +13,7 @@ use strict; use warnings; # ABSTRACT: persists lexical hints across input lines -use base 'Reply::Plugin'; +use mop; =head1 SYNOPSIS @@ -29,56 +29,45 @@ lines (at least until C is given). =cut -sub new { - my $class = shift; +class Reply::Plugin::Hints extends Reply::Plugin { + has $hints = $default_hints; + has $hinthash = $default_hinthash; + has $warning_bits = $default_warning_bits; - my $self = $class->SUPER::new(@_); - $self->{hints} = $default_hints; - $self->{hinthash} = $default_hinthash; - $self->{warning_bits} = $default_warning_bits; - - return $self; -} - -sub mangle_line { - my $self = shift; - my ($line) = @_; - - my $package = __PACKAGE__; - return <{hints}; - our $hinthash = $self->{hinthash}; - our $warning_bits = $self->{warning_bits}; + method compile ($next, $line, %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 $HINTS = $hints; + our $HINTHASH = $hinthash; + our $WARNING_BITS = $warning_bits; - my @result = $next->($line, %args); + my @result = $next->($line, %args); - $self->{hints} = $hints; - $self->{hinthash} = $hinthash; - $self->{warning_bits} = $warning_bits; + $hints = $HINTS; + $hinthash = $HINTHASH; + $warning_bits = $WARNING_BITS; - return @result; + return @result; + } } 1; -- cgit v1.2.3-54-g00ecf