Skip to content

Commit

Permalink
Fix issues in .clone(); now all of clone.t passes again.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Jan 6, 2012
1 parent 43b615d commit b86c667
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/core/Mu.pm
Expand Up @@ -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
}

Expand Down

0 comments on commit b86c667

Please sign in to comment.