/
CompUnit.pm6
59 lines (49 loc) · 1.62 KB
/
CompUnit.pm6
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
class CompUnit {
has Str $.from;
has Str $.short-name;
has Version $.version;
has Str $.auth;
has Str $!WHICH;
# The CompUnit::Repository that loaded this CompUnit.
has CompUnit::Repository $.repo is required;
# That repository's identifier for the compilation unit. This is not globally unique.
has Str:D $.repo-id is required;
# The low-level handle.
has CompUnit::Handle $.handle is required;
# Whether the module was loaded from a precompilation or not.
has Bool $.precompiled = False;
# The distribution that this compilation unit was installed as part of
# (if known).
has Distribution $.distribution;
my $default-from = 'Perl6';
method new(CompUnit:U:
Str :$short-name is copy,
Version :$version,
Str :$auth,
Str :$from = $default-from,
CompUnit::Handle :$handle = CompUnit::Handle,
CompUnit::Repository :$repo,
Str :$repo-id,
Bool :$precompiled = False,
Distribution :$distribution,
) {
self.bless(
:$short-name,
:$version,
:$auth,
:$from,
:$handle,
:$repo,
:$repo-id,
:$precompiled,
:$distribution,
);
}
multi method WHICH(CompUnit:D:) { $!WHICH //= self.^name }
multi method Str(CompUnit:D: --> Str:D) { $!short-name }
multi method gist(CompUnit:D: --> Str:D) { self.short-name }
method unit() {
$.handle.unit
}
}
# vim: ft=perl6 expandtab sw=4