Skip to content

Commit

Permalink
Streamline Metamodel::PackageHOW
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Feb 25, 2024
1 parent 1ce9b4c commit 3c9f07a
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/Perl6/Metamodel/PackageHOW.nqp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#- Metamodel::PackageHOW -------------------------------------------------------
class Perl6::Metamodel::PackageHOW
does Perl6::Metamodel::Naming
does Perl6::Metamodel::Documenting
Expand All @@ -7,21 +8,24 @@ class Perl6::Metamodel::PackageHOW
does Perl6::Metamodel::MethodDelegation
{

my $archetypes := Perl6::Metamodel::Archetypes.new();
method archetypes($obj?) {
$archetypes
}
my $archetypes := Perl6::Metamodel::Archetypes.new;
method archetypes($XXX?) { $archetypes }

method new(*%named) {
nqp::findmethod(NQPMu, 'BUILDALL')(nqp::create(self), %named)
method new(*%_) {
nqp::findmethod(NQPMu, 'BUILDALL')(nqp::create(self), %_)
}

method new_type(:$name = '<anon>', :$repr, :$ver, :$auth) {
if $repr { nqp::die("'package' does not support custom representations") }
my $metaclass := nqp::create(self);
my $obj := nqp::settypehll(nqp::newtype($metaclass, 'Uninstantiable'), 'Raku');
$metaclass.set_name($obj, $name);
self.add_stash($obj);
method new_type(:$name = '<anon>', :$repr, *%_) {
nqp::die("'package' does not support custom representations")
if $repr;

my $HOW := nqp::create(self);
my $target := nqp::settypehll(
nqp::newtype($HOW, 'Uninstantiable'), 'Raku'
);

$HOW.set_name($target, $name);
$HOW.add_stash($target)
}
}

Expand Down

0 comments on commit 3c9f07a

Please sign in to comment.