-
-
Notifications
You must be signed in to change notification settings - Fork 372
/
Compiler.pm6
90 lines (72 loc) · 2.86 KB
/
Compiler.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
class Compiler does Systemic {
my constant $id = nqp::p6box_s(nqp::sha1(
$*W.handle.Str
~ nqp::atkey(nqp::gethllsym(
'default', 'SysConfig').rakudo-build-config(), 'source-digest')
));
my Mu $compiler := nqp::gethllsym('default', 'SysConfig')
.rakudo-build-config();
# XXX Various issues with this stuff on JVM
has $.id is built(:bind) = nqp::ifnull(nqp::atkey($compiler,'id'),$id);
has $.release is built(:bind) = nqp::atkey($compiler,'release-number');
has $.codename is built(:bind) = nqp::atkey($compiler, 'codename');
submethod TWEAK(--> Nil) {
# https://github.com/rakudo/rakudo/issues/3436
nqp::bind($!name,'rakudo');
nqp::bind($!auth,'The Perl Foundation');
# looks like: 2018.01-50-g8afd791c1
nqp::bind($!version,Version.new(nqp::p6box_s(nqp::atkey($compiler,'version'))))
unless $!version;
}
method backend() {
nqp::getcomp("Raku").backend.name
}
proto method id(|) {*}
multi method id(Compiler:U:) { nqp::ifnull(nqp::atkey($compiler,'id'),$id) }
multi method id(Compiler:D:) { $!id }
method verbose-config(:$say) {
my $compiler := nqp::getcomp("Raku");
my $backend := $compiler.backend;
my $name := $backend.name;
my $items := nqp::list_s;
nqp::push_s($items,$name ~ '::' ~ .key ~ '=' ~ .value)
for $backend.config;
my $language := $compiler.language;
nqp::push_s($items,$language ~ '::' ~ .key ~ '=' ~ .value)
for $compiler.config;
nqp::push_s(
$items,
'repo::chain=' ~ (try $*REPO.repo-chain.map( *.gist ).join(" ")) // ''
);
nqp::push_s($items,"distro::$_={ $*DISTRO."$_"() // '' }")
for <auth desc is-win name path-sep release signature version>;
nqp::push_s($items,"kernel::$_={ $*KERNEL."$_"() // '' }")
for <arch archname auth bits desc
hardware name release signature version>;
try {
require System::Info;
my $sysinfo := System::Info.new;
nqp::push_s($items,"sysinfo::{ .name }={ $sysinfo.$_ // '' }")
for $sysinfo.^methods.grep: { .count == 1 && .name ne 'new' };
}
my $string := nqp::join("\n",Rakudo::Sorting.MERGESORT-str($items));
if $say {
nqp::say($string);
Nil
}
else {
my %config;
my $clone := nqp::clone($items);
while $clone {
my ($main,$key,$value) = nqp::shift_s($clone).split(<:: =>);
%config.AT-KEY($main).AT-KEY($key) = $value
}
%config but role {
has $!string = $string;
proto method Str() { $!string }
proto method gist() { $!string }
}
}
}
}
# vim: expandtab shiftwidth=4