/
ModuleHOW.nqp
38 lines (33 loc) · 1.11 KB
/
ModuleHOW.nqp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class Perl6::Metamodel::ModuleHOW
does Perl6::Metamodel::Naming
does Perl6::Metamodel::Documenting
does Perl6::Metamodel::Versioning
does Perl6::Metamodel::Stashing
does Perl6::Metamodel::TypePretense
does Perl6::Metamodel::MethodDelegation
{
has $!composed;
my $archetypes := Perl6::Metamodel::Archetypes.new( );
method archetypes() {
$archetypes
}
method new(*%named) {
nqp::findmethod(NQPMu, 'BUILDALL')(nqp::create(self), |%named)
}
method new_type(:$name = '<anon>', :$repr, :$ver, :$auth, :$api) {
if $repr { nqp::die("'module' does not support custom representations") }
my $metaclass := self.new();
my $obj := nqp::settypehll(nqp::newtype($metaclass, 'Uninstantiable'), 'perl6');
$metaclass.set_name($obj, $name);
$metaclass.set_ver($obj, $ver);
$metaclass.set_auth($obj, $auth) if $auth;
$metaclass.set_api($obj, $api) if $api;
self.add_stash($obj);
}
method compose($obj, :$compiler_services) {
$!composed := 1;
}
method is_composed($obj) {
$!composed
}
}