Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
A variety of circularity-sawing MOP updates.
  • Loading branch information
jnthn committed Jan 16, 2013
1 parent 3b7e5a3 commit ce967e9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/how/NQPClassHOW.pm
Expand Up @@ -342,7 +342,7 @@ knowhow NQPClassHOW {
unless $_ =:= @cand_list {
# Is current candidate in the tail? If so, reject.
my $cur_pos := 1;
while $cur_pos <= +$_ {
while $cur_pos <= nqp::elems($_) {
if $_[$cur_pos] =:= $cand_class {
$rejected := 1;
}
Expand Down Expand Up @@ -410,7 +410,7 @@ knowhow NQPClassHOW {
my @mro_reversed := reverse(@!mro);
for @mro_reversed {
for $_.HOW.method_table($_) {
%cache{$_.key} := $_.value;
%cache{nqp::iterkey_s($_)} := nqp::iterval($_);
}
}
nqp::setmethcache($obj, %cache);
Expand Down Expand Up @@ -580,7 +580,7 @@ knowhow NQPClassHOW {
my @attrs;
if $local {
for %!attributes {
nqp::push(@attrs, $_.value);
nqp::push(@attrs, nqp::iterval($_));
}
}
else {
Expand Down
4 changes: 2 additions & 2 deletions src/how/NQPConcreteRoleHOW.pm
Expand Up @@ -121,7 +121,7 @@ knowhow NQPConcreteRoleHOW {
method methods($obj, :$local) {
my @meths;
for %!methods {
nqp::push(@meths, $_.value);
nqp::push(@meths, nqp::iterval($_));
}
@meths
}
Expand All @@ -141,7 +141,7 @@ knowhow NQPConcreteRoleHOW {
method attributes($obj, :$local) {
my @attrs;
for %!attributes {
nqp::push(@attrs, $_.value);
nqp::push(@attrs, nqp::iterval($_));
}
@attrs
}
Expand Down
14 changes: 7 additions & 7 deletions src/how/NQPParametricRoleHOW.pm
Expand Up @@ -127,15 +127,15 @@ knowhow NQPParametricRoleHOW {
# Copy attributes. (Nothing to reify in NQP as we don't currently
# have parametric types that may end up in the signature.)
for %!attributes {
$irole.HOW.add_attribute($irole, $_.value);
$irole.HOW.add_attribute($irole, nqp::iterval($_));
}

# Capture methods in the correct lexical context.
for %!methods {
my $name := $_.key;
my $meth := nqp::can($_.value, 'instantiate_generic')
?? $_.value.instantiate_generic($pad)
!! $_.value.clone();
my $name := nqp::iterkey_s($_);
my $meth := nqp::can(nqp::iterval($_), 'instantiate_generic')
?? nqp::iterval($_).instantiate_generic($pad)
!! nqp::iterval($_).clone();
if nqp::substr($name, 0, 12) eq '!!LATENAME!!' {
$name := nqp::atkey($pad, nqp::substr($name, 12));
$meth.'!set_name'($name);
Expand Down Expand Up @@ -164,7 +164,7 @@ knowhow NQPParametricRoleHOW {
method methods($obj, :$local) {
my @meths;
for %!methods {
nqp::push(@meths, $_.value);
nqp::push(@meths, nqp::iterval($_));
}
@meths
}
Expand All @@ -180,7 +180,7 @@ knowhow NQPParametricRoleHOW {
method attributes($obj, :$local) {
my @attrs;
for %!attributes {
nqp::push(@attrs, $_.value);
nqp::push(@attrs, nqp::iterval($_));
}
@attrs
}
Expand Down
10 changes: 6 additions & 4 deletions src/how/RoleToClassApplier.pm
Expand Up @@ -34,17 +34,19 @@ knowhow RoleToClassApplier {
# Collisions?
my @collisions := $to_compose_meta.collisions($to_compose);
for @collisions {
unless has_method($target, ~$_, 1) {
nqp::die("Method '$_' collides and a resolution must be provided by the class '" ~
my $name := nqp::can($_, 'name') ?? $_.name !! nqp::getcodename($_);
unless has_method($target, $name, 1) {
nqp::die("Method '$name' collides and a resolution must be provided by the class '" ~
$target.HOW.name($target) ~ "'");
}
}

# Compose in any methods.
my @methods := $to_compose_meta.methods($to_compose);
for @methods {
unless has_method($target, ~$_, 0) {
$target.HOW.add_method($target, ~$_, $_);
my $name := nqp::can($_, 'name') ?? $_.name !! nqp::getcodename($_);
unless has_method($target, $name, 0) {
$target.HOW.add_method($target, $name, $_);
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/how/RoleToRoleApplier.pm
Expand Up @@ -5,7 +5,7 @@ knowhow RoleToRoleApplier {
for @roles {
my @methods := $_.HOW.methods($_);
for @methods {
my $name := ~$_;
my $name := nqp::can($_, 'name') ?? $_.name !! nqp::getcodename($_);
my $meth := $_;
my @meth_list;
if nqp::defined(%meth_info{$name}) {
Expand All @@ -30,12 +30,13 @@ knowhow RoleToRoleApplier {
my %target_meth_info;
my @target_meths := $target.HOW.methods($target);
for @target_meths {
%target_meth_info{~$_} := $_;
my $name := nqp::can($_, 'name') ?? $_.name !! nqp::getcodename($_);
%target_meth_info{$name} := $_;
}

# Process method list.
for %meth_info {
my $name := ~$_;
my $name := nqp::iterkey_s($_);
my @add_meths := %meth_info{$name};

# Do we already have a method of this name? If so, ignore all of the
Expand Down

0 comments on commit ce967e9

Please sign in to comment.