X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FScope-Context.git;a=blobdiff_plain;f=lib%2FScope%2FContext.pm;h=9f887b3442975f8097b7513aeaf6b87bbfc01e65;hp=4a45cbb540c61f2b7b60a2d0e2e0d587b07be42d;hb=4aa20fdf3f0a11fcd29276c295234da92f36176b;hpb=311423ea1bdbde2c8dde8ce3a772a1036365ec4f diff --git a/lib/Scope/Context.pm b/lib/Scope/Context.pm index 4a45cbb..9f887b3 100644 --- a/lib/Scope/Context.pm +++ b/lib/Scope/Context.pm @@ -236,15 +236,16 @@ If omitted, C<$frames> defaults to C<1>. sub up { my ($self, $frames) = @_; + my $cxt; if (Scalar::Util::blessed($self)) { $self->assert_valid; + $cxt = $self->cxt; } else { - $self = $self->new(Scope::Upper::UP(Scope::Upper::SUB())); + $cxt = Scope::Upper::UP(Scope::Upper::SUB()); } $frames = 1 unless defined $frames; - my $cxt = $self->cxt; $cxt = Scope::Upper::UP($cxt) for 1 .. $frames; $self->new($cxt); @@ -278,15 +279,17 @@ If omitted, C<$frames> defaults to C<0>, which results in the closest sub enclos sub sub { my ($self, $frames) = @_; + my $cxt; if (Scalar::Util::blessed($self)) { $self->assert_valid; + $cxt = $self->cxt; } else { - $self = $self->new(Scope::Upper::UP(Scope::Upper::SUB())); + $cxt = Scope::Upper::UP(Scope::Upper::SUB()); } $frames = 0 unless defined $frames; - my $cxt = Scope::Upper::SUB($self->cxt); + $cxt = Scope::Upper::SUB($cxt); $cxt = Scope::Upper::SUB(Scope::Upper::UP($cxt)) for 1 .. $frames; $self->new($cxt); @@ -316,15 +319,17 @@ If omitted, C<$frames> defaults to C<0>, which results in the closest eval enclo sub eval { my ($self, $frames) = @_; + my $cxt; if (Scalar::Util::blessed($self)) { $self->assert_valid; + $cxt = $self->cxt; } else { - $self = $self->new(Scope::Upper::UP(Scope::Upper::SUB())); + $cxt = Scope::Upper::UP(Scope::Upper::SUB()); } $frames = 0 unless defined $frames; - my $cxt = Scope::Upper::EVAL($self->cxt); + $cxt = Scope::Upper::EVAL($cxt); $cxt = Scope::Upper::EVAL(Scope::Upper::UP($cxt)) for 1 .. $frames; $self->new($cxt);