Permalink
Browse files

Fix issues in .clone(); now all of clone.t passes again.

  • Loading branch information...
jnthn committed Jan 6, 2012
1 parent 43b615d commit b86c6672132acad9365be5169c68a6e29e2d9826
Showing with 14 additions and 2 deletions.
  1. +14 −2 src/core/Mu.pm
View
@@ -215,9 +215,21 @@ my class Mu {
$self.HOW.can($self, $name)
}
- method clone() {
+ method clone(*%twiddles) {
my $cloned := pir::repr_clone__PP(nqp::p6decont(self));
- # XXX Probably need to clone containery things a level deeper.
+ for self.^attributes() -> $attr {
+ my $name := $attr.name;
+ my $package := $attr.package;
+ unless pir::repr_get_primitive_type_spec__IP($attr.type) {
+ my $attr_val := nqp::getattr($cloned, $package, $name);
+ nqp::bindattr($cloned, $package, $name, pir::repr_clone__PP($attr_val.VAR))
+ if nqp::iscont($attr_val);
+ }
+ my $acc_name := $name.substr(2);
+ if $attr.has-accessor && %twiddles.exists($acc_name) {
+ nqp::getattr($cloned, $package, $name) = %twiddles{$acc_name};
+ }
+ }
$cloned
}

0 comments on commit b86c667

Please sign in to comment.