summaryrefslogtreecommitdiffstats
path: root/lib/Reply/Plugin/Hints.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Reply/Plugin/Hints.pm')
-rw-r--r--lib/Reply/Plugin/Hints.pm71
1 files changed, 30 insertions, 41 deletions
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<no strict> 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 <<LINE;
+ method mangle_line ($line) {
+ my $package = __PACKAGE__;
+ return <<LINE;
BEGIN {
- \$^H = \$${package}::hints;
- \%^H = \%\$${package}::hinthash;
- \${^WARNING_BITS} = \$${package}::warning_bits;
+ \$^H = \$${package}::HINTS;
+ \%^H = \%\$${package}::HINTHASH;
+ \${^WARNING_BITS} = \$${package}::WARNING_BITS;
}
$line
;
BEGIN {
- \$${package}::hints = \$^H;
- \$${package}::hinthash = \\\%^H;
- \$${package}::warning_bits = \${^WARNING_BITS};
+ \$${package}::HINTS = \$^H;
+ \$${package}::HINTHASH = \\\%^H;
+ \$${package}::WARNING_BITS = \${^WARNING_BITS};
}
LINE
-}
-
-sub compile {
- my $self = shift;
- my ($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 = $self->{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;