From 48656ef560302c9e9864b84b2f95f266799d88e3 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 4 Jul 2013 14:21:11 -0400 Subject: just give up on the whole 'name' thing here --- lib/Reply/Plugin/Autocomplete/Lexicals.pm | 8 ++++---- lib/Reply/Plugin/Autocomplete/Methods.pm | 9 ++++----- lib/Reply/Plugin/Defaults.pm | 12 ++++-------- lib/Reply/Plugin/LexicalPersistence.pm | 2 +- lib/Reply/Plugin/ResultCache.pm | 2 +- 5 files changed, 14 insertions(+), 19 deletions(-) (limited to 'lib') diff --git a/lib/Reply/Plugin/Autocomplete/Lexicals.pm b/lib/Reply/Plugin/Autocomplete/Lexicals.pm index dd953bf..204778a 100644 --- a/lib/Reply/Plugin/Autocomplete/Lexicals.pm +++ b/lib/Reply/Plugin/Autocomplete/Lexicals.pm @@ -24,16 +24,16 @@ sub new { my $class = shift; my $self = $class->SUPER::new(@_); - $self->{env} = {}; + $self->{env} = []; return $self; } sub lexical_environment { my $self = shift; - my ($name, $env) = @_; + my ($env) = @_; - $self->{env}{$name} = $env; + push @{ $self->{env} }, $env; } sub tab_handler { @@ -48,7 +48,7 @@ sub tab_handler { # these can't be lexicals return if $sigil eq '&' || $sigil eq '*'; - my $env = { map { %$_ } values %{ $self->{env} } }; + my $env = { map { %$_ } @{ $self->{env} } }; my @env = keys %$env; my @results; diff --git a/lib/Reply/Plugin/Autocomplete/Methods.pm b/lib/Reply/Plugin/Autocomplete/Methods.pm index 151caa0..d4319b2 100644 --- a/lib/Reply/Plugin/Autocomplete/Methods.pm +++ b/lib/Reply/Plugin/Autocomplete/Methods.pm @@ -28,7 +28,7 @@ sub new { my $class = shift; my $self = $class->SUPER::new(@_); - $self->{env} = {}; + $self->{env} = []; $self->{package} = 'main'; return $self; @@ -36,9 +36,9 @@ sub new { sub lexical_environment { my $self = shift; - my ($name, $env) = @_; + my ($env) = @_; - $self->{env}{$name} = $env; + push @{ $self->{env} }, $env; } sub package { @@ -63,8 +63,7 @@ sub tab_handler { if ($invocant =~ /^\$/) { # XXX should support globals here my $env = { - (map { %$_ } values %{ $self->{env} }), - (%{ $self->{env}{defaults} || {} }), + map { %$_ } @{ $self->{env} }, }; my $var = $env->{$invocant}; return unless $var && ref($var) eq 'REF' && blessed($$var); diff --git a/lib/Reply/Plugin/Defaults.pm b/lib/Reply/Plugin/Defaults.pm index ca3c047..991b807 100644 --- a/lib/Reply/Plugin/Defaults.pm +++ b/lib/Reply/Plugin/Defaults.pm @@ -20,7 +20,7 @@ sub new { my $self = $class->SUPER::new(@_); $self->{quit} = 0; - $self->{env} = {}; + $self->{env} = []; $self->{package} = 'main'; return $self; @@ -48,11 +48,7 @@ sub compile { my $self = shift; my ($next, $line, %args) = @_; - my $default_env = delete $self->{env}{default} || {}; - my $env = { - (map { %$_ } values %{ $self->{env} }), - %$default_env, - }; + my $env = { map { %$_ } @{ $self->{env} } }; my $prefix = "package $self->{package};\n$PREFIX"; @@ -66,8 +62,8 @@ sub compile { sub lexical_environment { my $self = shift; - my ($name, $env) = @_; - $self->{env}{$name} = $env; + my ($env) = @_; + push @{ $self->{env} }, $env; } sub package { diff --git a/lib/Reply/Plugin/LexicalPersistence.pm b/lib/Reply/Plugin/LexicalPersistence.pm index e3bbb9a..8437cbe 100644 --- a/lib/Reply/Plugin/LexicalPersistence.pm +++ b/lib/Reply/Plugin/LexicalPersistence.pm @@ -41,7 +41,7 @@ sub compile { %{ peek_sub($code) }, }; - $self->publish('lexical_environment', default => $self->{env}); + $self->publish('lexical_environment', $self->{env}); return $code; } diff --git a/lib/Reply/Plugin/ResultCache.pm b/lib/Reply/Plugin/ResultCache.pm index beb884b..5a241e3 100644 --- a/lib/Reply/Plugin/ResultCache.pm +++ b/lib/Reply/Plugin/ResultCache.pm @@ -46,7 +46,7 @@ sub execute { $self->publish( 'lexical_environment', - result_cache => { + { "\@$self->{result_name}" => $self->{results}, }, ); -- cgit v1.2.3-54-g00ecf