From: Dave Rolsky Date: Sun, 21 Jun 2009 16:22:35 +0000 (-0500) Subject: work with Inlined changes in CMOP X-Git-Tag: 0.82~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=34aab661b22bed0df039dfab3aa4a84747abea06;p=gitmo%2FMoose.git work with Inlined changes in CMOP --- diff --git a/lib/Moose/Meta/Method/Accessor.pm b/lib/Moose/Meta/Method/Accessor.pm index 48ada67..be89843 100644 --- a/lib/Moose/Meta/Method/Accessor.pm +++ b/lib/Moose/Meta/Method/Accessor.pm @@ -17,7 +17,7 @@ sub _error_thrower { } sub _eval_code { - my ( $self, $code ) = @_; + my ( $self, $source ) = @_; # NOTE: # set up the environment @@ -34,9 +34,15 @@ sub _eval_code { : undef), }; - #warn "code for $attr_name =>\n" . $code . "\n"; - $self->_compile_code( environment => $environment, code => $code ) - or $self->throw_error("Could not create writer for '${\$self->associated_attribute->name}' because $@ \n code: $code", error => $@, data => $code ); + #warn "code for $attr_name =>\n" . $source . "\n"; + my ( $code, $e ) = $self->_compile_code( environment => $environment, code => $source ); + + $self->throw_error( + "Could not create writer for '${\$self->associated_attribute->name}' because $e \n code: $source", + error => $e, data => $source ) + if $e; + + return $code; } sub _generate_accessor_method_inline { diff --git a/lib/Moose/Meta/Method/Constructor.pm b/lib/Moose/Meta/Method/Constructor.pm index 7eb6606..98a99e6 100644 --- a/lib/Moose/Meta/Method/Constructor.pm +++ b/lib/Moose/Meta/Method/Constructor.pm @@ -96,7 +96,7 @@ sub _initialize_body { defined $_ ? $_->_compiled_type_constraint : undef; } @type_constraints; - my $code = $self->_compile_code( + my ( $code, $e ) = $self->_compile_code( code => $source, environment => { '$meta' => \$self, @@ -104,7 +104,12 @@ sub _initialize_body { '@type_constraints' => \@type_constraints, '@type_constraint_bodies' => \@type_constraint_bodies, }, - ) or $self->throw_error("Could not eval the constructor :\n\n$source\n\nbecause :\n\n$@", error => $@, data => $source ); + ); + + $self->throw_error( + "Could not eval the constructor :\n\n$source\n\nbecause :\n\n$e", + error => $e, data => $source ) + if $e; $self->{'body'} = $code; } diff --git a/lib/Moose/Meta/Method/Destructor.pm b/lib/Moose/Meta/Method/Destructor.pm index ae9a7e0..7700b23 100644 --- a/lib/Moose/Meta/Method/Destructor.pm +++ b/lib/Moose/Meta/Method/Destructor.pm @@ -96,10 +96,15 @@ sub _initialize_body { warn $source if $self->options->{debug}; - my $code = $self->_compile_code( + my ( $code, $e ) = $self->_compile_code( environment => {}, code => $source, - ) or $self->throw_error("Could not eval the destructor :\n\n$source\n\nbecause :\n\n$@", error => $@, data => $source); + ); + + $self->throw_error( + "Could not eval the destructor :\n\n$source\n\nbecause :\n\n$e", + error => $e, data => $source ) + if $e; $self->{'body'} = $code; }