Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'mop-cleanup'
  • Loading branch information
jnthn committed Jan 18, 2013
2 parents 8ac18c6 + ce967e9 commit e29532a
Show file tree
Hide file tree
Showing 15 changed files with 24,769 additions and 24,787 deletions.
10 changes: 9 additions & 1 deletion src/QAST/Operations.nqp
Expand Up @@ -1529,7 +1529,6 @@ QAST::Operations.add_core_pirop_mapping('deletepos', 'delete', '0Qi', :inlinable
QAST::Operations.add_core_pirop_mapping('existskey', 'exists', 'IQs', :inlinable(1));
QAST::Operations.add_core_pirop_mapping('existspos', 'exists', 'IQi', :inlinable(1));
QAST::Operations.add_core_pirop_mapping('elems', 'elements', 'IP', :inlinable(1));
QAST::Operations.add_core_pirop_mapping('iterator', 'iter', 'PP', :inlinable(1));
QAST::Operations.add_core_pirop_mapping('push', 'push', '0PP', :inlinable(1));
QAST::Operations.add_core_pirop_mapping('push_s', 'push', '0Ps', :inlinable(1));
QAST::Operations.add_core_pirop_mapping('push_i', 'push', '0Pi', :inlinable(1));
Expand All @@ -1550,6 +1549,13 @@ QAST::Operations.add_core_pirop_mapping('splice', 'splice', '0PPii', :inlinable(
QAST::Operations.add_core_pirop_mapping('islist', 'nqp_islist', 'IP', :inlinable(1));
QAST::Operations.add_core_pirop_mapping('ishash', 'nqp_ishash', 'IP', :inlinable(1));
QAST::Operations.add_core_pirop_mapping('isinvokable', 'is_invokable', 'IP', :inlinable(1));
QAST::Operations.add_core_pirop_mapping('iterator', 'iter', 'PP', :inlinable(1));
QAST::Operations.add_core_op('iterkey_s', -> $qastcomp, $op {
$qastcomp.as_post(QAST::Op.new( :op('callmethod'), :name('key'), $op[0] ))
});
QAST::Operations.add_core_op('iterval', -> $qastcomp, $op {
$qastcomp.as_post(QAST::Op.new( :op('callmethod'), :name('value'), $op[0] ))
});

# repr-level aggregate operations
QAST::Operations.add_core_pirop_mapping('r_atpos', 'repr_at_pos_obj', 'PPi', :inlinable(1));
Expand Down Expand Up @@ -1620,6 +1626,8 @@ QAST::Operations.add_core_pirop_mapping('bindlexdyn', 'store_dynamic_lex', '1sP'
QAST::Operations.add_core_pirop_mapping('takeclosure', 'newclosure', 'PP');
QAST::Operations.add_core_pirop_mapping('getcodeobj', 'get_sub_code_object', 'PP');
QAST::Operations.add_core_pirop_mapping('setcodeobj', 'set_sub_code_object', '1PP');
QAST::Operations.add_core_pirop_mapping('getcodename', 'set', 'SP');
QAST::Operations.add_core_pirop_mapping('setcodename', 'assign', '1Ps');

# serialization context related opcodes
QAST::Operations.add_core_pirop_mapping('sha1', 'nqp_sha1', 'Ss');
Expand Down
11 changes: 3 additions & 8 deletions src/how/NQPClassHOW.pm
Expand Up @@ -33,11 +33,6 @@ knowhow NQPClassHOW {
has @!done;

# Cached values, which are thrown away if the class changes.
# XXX Should be an attribute later, but we get into some trouble with
# the bootstrap for now since we end up with SC references back to the
# previous build due to a parse altering the cache, and the SC WB getting
# hit.
#my %caches;
has %!caches;

# Parrot-specific vtable mapping hash. Maps vtable name to method.
Expand Down Expand Up @@ -347,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 @@ -415,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 @@ -585,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 e29532a

Please sign in to comment.