[Moose-commits] r7749 - Class-MOP/trunk/lib/Class/MOP/Method
autarch at code2.0beta.co.uk
autarch at code2.0beta.co.uk
Fri Feb 20 17:40:30 GMT 2009
Author: autarch
Date: 2009-02-20 09:40:29 -0800 (Fri, 20 Feb 2009)
New Revision: 7749
Modified:
Class-MOP/trunk/lib/Class/MOP/Method/Accessor.pm
Class-MOP/trunk/lib/Class/MOP/Method/Constructor.pm
Class-MOP/trunk/lib/Class/MOP/Method/Generated.pm
Log:
Revert back to checking for code compilation failure at the caller.
Fixed some error messages along the way.
Modified: Class-MOP/trunk/lib/Class/MOP/Method/Accessor.pm
===================================================================
--- Class-MOP/trunk/lib/Class/MOP/Method/Accessor.pm 2009-02-20 17:30:32 UTC (rev 7748)
+++ Class-MOP/trunk/lib/Class/MOP/Method/Accessor.pm 2009-02-20 17:40:29 UTC (rev 7749)
@@ -67,7 +67,8 @@
($self->is_inline ? 'inline' : ())
);
- $self->{'body'} = $self->$method_name();
+ eval { $self->{'body'} = $self->$method_name() };
+ die $@ if $@;
}
## generators
@@ -118,14 +119,17 @@
my $attr_name = $attr->name;
my $meta_instance = $attr->associated_class->instance_metaclass;
- return $self->_eval_closure(
+ my $code = $self->_eval_closure(
{},
'sub {'
- . $meta_instance->inline_set_slot_value('$_[0]', $attr_name, '$_[1]')
+ . $meta_instance->inline_set_slot_value('$_[0]', "'$attr_name'", '$_[1]')
. ' if scalar(@_) == 2; '
- . $meta_instance->inline_get_slot_value('$_[0]', $attr_name)
+ . $meta_instance->inline_get_slot_value('$_[0]', "'$attr_name'")
. '}'
);
+ confess "Could not generate inline accessor because : $@" if $@;
+
+ return $code;
}
sub generate_reader_method_inline {
@@ -134,13 +138,16 @@
my $attr_name = $attr->name;
my $meta_instance = $attr->associated_class->instance_metaclass;
- return $self->_eval_closure(
+ my $code = $self->_eval_closure(
{},
'sub {'
. 'confess "Cannot assign a value to a read-only accessor" if @_ > 1;'
. $meta_instance->inline_get_slot_value('$_[0]', $attr_name)
. '}'
);
+ confess "Could not generate inline reader because : $@" if $@;
+
+ return $code;
}
sub generate_writer_method_inline {
@@ -149,12 +156,15 @@
my $attr_name = $attr->name;
my $meta_instance = $attr->associated_class->instance_metaclass;
- return $self->_eval_closure(
+ my $code = $self->_eval_closure(
{},
'sub {'
. $meta_instance->inline_set_slot_value('$_[0]', $attr_name, '$_[1]')
. '}'
);
+ confess "Could not generate inline writer because : $@" if $@;
+
+ return $code;
}
@@ -164,12 +174,15 @@
my $attr_name = $attr->name;
my $meta_instance = $attr->associated_class->instance_metaclass;
- return $self->_eval_closure(
+ my $code = $self->_eval_closure(
{},
'sub {'
. $meta_instance->inline_is_slot_initialized('$_[0]', $attr_name)
. '}'
);
+ confess "Could not generate inline predicate because : $@" if $@;
+
+ return $code;
}
sub generate_clearer_method_inline {
@@ -178,12 +191,15 @@
my $attr_name = $attr->name;
my $meta_instance = $attr->associated_class->instance_metaclass;
- return $self->_eval_closure(
+ my $code = $self->_eval_closure(
{},
'sub {'
. $meta_instance->inline_deinitialize_slot('$_[0]', $attr_name)
. '}'
);
+ confess "Could not generate inline clearer because : $@" if $@;
+
+ return $code;
}
1;
Modified: Class-MOP/trunk/lib/Class/MOP/Method/Constructor.pm
===================================================================
--- Class-MOP/trunk/lib/Class/MOP/Method/Constructor.pm 2009-02-20 17:30:32 UTC (rev 7748)
+++ Class-MOP/trunk/lib/Class/MOP/Method/Constructor.pm 2009-02-20 17:40:29 UTC (rev 7749)
@@ -107,10 +107,13 @@
$source .= ";\n" . '}';
warn $source if $self->options->{debug};
- return $self->_eval_closure(
+ my $code = $self->_eval_closure(
$close_over,
$source
);
+ confess "Could not eval the constructor :\n\n$source\n\nbecause :\n\n$@" if $@;
+
+ return $code;
}
sub _generate_slot_initializer {
Modified: Class-MOP/trunk/lib/Class/MOP/Method/Generated.pm
===================================================================
--- Class-MOP/trunk/lib/Class/MOP/Method/Generated.pm 2009-02-20 17:30:32 UTC (rev 7748)
+++ Class-MOP/trunk/lib/Class/MOP/Method/Generated.pm 2009-02-20 17:40:29 UTC (rev 7749)
@@ -49,9 +49,7 @@
sub _eval_closure {
# my ($self, $captures, $sub_body) = @_;
my $__captures = $_[1];
-
- local $@;
- my $code = join(
+ eval join(
"\n",
(
map {
@@ -67,11 +65,6 @@
),
$_[2]
);
- my $sub = eval $code;
-
- die "$@\n$code" if $@;
-
- return $sub;
}
sub _add_line_directive {
More information about the Moose-commits
mailing list