-
-
Notifications
You must be signed in to change notification settings - Fork 373
/
terms.pm
99 lines (86 loc) · 3.66 KB
/
terms.pm
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
91
92
93
94
95
96
97
98
99
sub term:<time>() { nqp::p6box_i(pir::time__I()) }
{
my @ARGS;
my Mu $argiter := pir::get_hll_global__Ps('$!ARGITER');
@ARGS.push(nqp::p6box_s(nqp::shift($argiter))) while $argiter;
nqp::bindkey(pir::get_who__PP(PROCESS), '@ARGS', @ARGS);
$PROCESS::ARGFILES = IO::ArgFiles.new(:args(@ARGS));
my %ENV;
my Mu $env := pir::new__Ps('Env');
my Mu $enviter := nqp::iterator($env);
my $key;
while $enviter {
$key = nqp::p6box_s(pir::shift__SP($enviter));
%ENV{$key} = nqp::p6box_s(nqp::atkey($env, nqp::unbox_s($key)));
}
%ENV does role {
method at_key($k) {
Proxy.new(
FETCH => {
if nqp::p6bool(nqp::existskey($env, nqp::unbox_s($k))) {
nqp::p6box_s(nqp::atkey($env, nqp::unbox_s($k)))
}
else {
Any
}
},
STORE => -> $, $v {
nqp::bindkey($env, nqp::unbox_s($k), nqp::unbox_s($v))
}
)
}
method delete($k) {
my $ret = self.at_key($k);
pir::delete($env, nqp::unbox_s($k));
return $ret;
}
}
nqp::bindkey(pir::get_who__PP(PROCESS), '%ENV', %ENV);
my $VM = {
name => 'parrot', # XXX: should be made dynamical
config => pir::perl6ize_type__PP(
nqp::atpos(pir::getinterp, pir::const::IGLOBALS_CONFIG_HASH))
}
nqp::bindkey(pir::get_who__PP(PROCESS), '$VM', $VM);
my Mu $compiler := pir::find_caller_lex__PS('$COMPILER_CONFIG');
my $PERL = {
name => 'rakudo',
compiler => {
name => 'rakudo',
ver => nqp::p6box_s(nqp::atkey($compiler, 'version')),
release-number => nqp::p6box_s(nqp::atkey($compiler, 'release-number')),
build-date => nqp::p6box_s(nqp::atkey($compiler, 'build-date')),
codename => nqp::p6box_s(nqp::atkey($compiler, 'codename')),
}
};
nqp::bindkey(pir::get_who__PP(PROCESS), '$PERL', $PERL);
my $CWD = nqp::p6box_s(pir::new__PS('OS').cwd);
nqp::bindkey(pir::get_who__PP(PROCESS), '$CWD', $CWD);
my @INC;
@INC.push(%ENV<RAKUDOLIB>.split($VM<config><osname> eq 'MSWin32' ?? ';' !! ':')) if %ENV<RAKUDOLIB>;
@INC.push(%ENV<PERL6LIB>.split($VM<config><osname> eq 'MSWin32' ?? ';' !! ':')) if %ENV<PERL6LIB>;
try {
@INC.push((%ENV<HOME> // %ENV<HOMEDRIVE> ~ %ENV<HOMEPATH>) ~ '/.perl6/lib');
}
@INC.push($VM<config><libdir> ~ $VM<config><versiondir> ~ '/languages/perl6/lib');
@INC.push('.'); # XXX: remove this when 'use lib' works fine
nqp::bindkey(pir::get_who__PP(PROCESS), '@INC', @INC);
my $PID = nqp::p6box_i(pir::getinterp.getpid());
nqp::bindkey(pir::get_who__PP(PROCESS), '$PID', $PID);
my $OS = $VM<config><osname>; # XXX: master gets this information with the sysinfo dynop
nqp::bindkey(pir::get_who__PP(PROCESS), '$OS', $OS);
my $OSVER = $VM<config><osvers>; # XXX: master gets this information with the sysinfo dynop
nqp::bindkey(pir::get_who__PP(PROCESS), '$OSVER', $OSVER);
my $EXECUTABLE_NAME =
nqp::p6box_s(pir::interpinfo__Si(pir::const::INTERPINFO_EXECUTABLE_FULLNAME));
nqp::bindkey(pir::get_who__PP(PROCESS), '$EXECUTABLE_NAME', $EXECUTABLE_NAME);
my $PROGRAM_NAME =
nqp::p6box_s(
nqp::atpos(
nqp::atpos(
pir::getinterp, pir::const::IGLOBALS_ARGV_LIST
), 0
)
) || 'interactive';
nqp::bindkey(pir::get_who__PP(PROCESS), '$PROGRAM_NAME', $PROGRAM_NAME);
}