X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FClass%2FMOP%2FMethod%2FGenerated.pm;h=3c6e08f4fba48843ec1b80200390e789bc710a24;hb=b45263ff64cb7105b40d21fef69b9c079136c4d3;hp=5af96b8776729d98b0de36f46eee14a13985875b;hpb=8e863a0a577e3f34c5bf67d06f066ec20000566f;p=gitmo%2FClass-MOP.git diff --git a/lib/Class/MOP/Method/Generated.pm b/lib/Class/MOP/Method/Generated.pm index 5af96b8..3c6e08f 100644 --- a/lib/Class/MOP/Method/Generated.pm +++ b/lib/Class/MOP/Method/Generated.pm @@ -6,12 +6,14 @@ use warnings; use Carp 'confess'; -our $VERSION = '0.86'; +our $VERSION = '1.07'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; use base 'Class::MOP::Method'; +use constant _PRINT_SOURCE => $ENV{MOP_PRINT_SOURCE} ? 1 : 0; + ## accessors sub new { @@ -29,22 +31,31 @@ sub _initialize_body { sub _eval_closure { # my ($self, $captures, $sub_body) = @_; my $__captures = $_[1]; - eval join( - "\n", - ( + + my $code; + + my $e = do { + local $@; + local $SIG{__DIE__}; + my $source = join + "\n", ( map { /^([\@\%\$])/ or die "capture key should start with \@, \% or \$: $_"; - q[my ] - . $_ . q[ = ] - . $1 - . q[{$__captures->{'] - . $_ - . q['}};]; - } keys %$__captures - ), - $_[2] - ); + q[my ] + . $_ . q[ = ] + . $1 + . q[{$__captures->{'] + . $_ . q['}};]; + } keys %$__captures + ), + $_[2]; + print STDERR "\n", $_[0]->name, ":\n", $source, "\n" if _PRINT_SOURCE; + $code = eval $source; + $@; + }; + + return ( $code, $e ); } sub _add_line_directive { @@ -77,7 +88,7 @@ sub _compile_code { my $code = $self->_add_line_directive(%args); - $self->_eval_closure($args{environment}, $code); + return $self->_eval_closure($args{environment}, $code); } 1; @@ -104,7 +115,7 @@ Stevan Little Estevan@iinteractive.comE =head1 COPYRIGHT AND LICENSE -Copyright 2006-2009 by Infinity Interactive, Inc. +Copyright 2006-2010 by Infinity Interactive, Inc. L