Skip to content
Permalink
Browse files

Explicitly identify types used for mixins

So that we'll be able to better optimize access to the rest of them.
  • Loading branch information...
jnthn committed Feb 13, 2019
1 parent ee2238f commit f09156240a52b34bc356ef715bd955c8f4378cb4
Showing with 12 additions and 5 deletions.
  1. +9 −2 src/Perl6/Metamodel/ClassHOW.nqp
  2. +2 −2 src/Perl6/Metamodel/EnumHOW.nqp
  3. +1 −1 src/Perl6/Metamodel/Mixins.nqp
@@ -40,9 +40,16 @@ class Perl6::Metamodel::ClassHOW
}

my $anon_id := 1;
method new_type(:$name, :$repr = 'P6opaque', :$ver, :$auth, :$api) {
method new_type(:$name, :$repr = 'P6opaque', :$ver, :$auth, :$api, :$is_mixin) {
my $metaclass := self.new();
my $obj := nqp::settypehll(nqp::newtype($metaclass, $repr), 'perl6');
my $new_type;
if $is_mixin {
$new_type := nqp::newmixintype($metaclass, $repr);
}
else {
$new_type := nqp::newtype($metaclass, $repr);
}
my $obj := nqp::settypehll($new_type, 'perl6');
$metaclass.set_name($obj, $name // "<anon|{$anon_id++}>");
self.add_stash($obj);
$metaclass.set_ver($obj, $ver) if $ver;
@@ -52,9 +52,9 @@ class Perl6::Metamodel::EnumHOW
nqp::findmethod(NQPMu, 'BUILDALL')(nqp::create(self), |%named)
}

method new_type(:$name!, :$base_type?, :$repr = 'P6opaque') {
method new_type(:$name!, :$base_type?, :$repr = 'P6opaque', :$is_mixin) {
my $meta := self.new();
my $obj := nqp::settypehll(nqp::newtype($meta, $repr), 'perl6');
my $obj := nqp::settypehll(nqp::newmixintype($meta, $repr), 'perl6');
$meta.set_name($obj, $name);
$meta.set_base_type($meta, $base_type) unless $base_type =:= NQPMu;
$meta.setup_mixin_cache($obj);
@@ -81,7 +81,7 @@ role Perl6::Metamodel::Mixins {

# Create new type, derive it from ourself and then add
# all the roles we're mixing it.
my $new_type := self.new_type(:name($new_name), :repr($obj.REPR));
my $new_type := self.new_type(:name($new_name), :repr($obj.REPR), :is_mixin);
$new_type.HOW.set_is_mixin($new_type);
$new_type.HOW.add_parent($new_type, $obj.WHAT);
for @roles {

0 comments on commit f091562

Please sign in to comment.
You can’t perform that action at this time.