Skip to content

Commit 1aa0ec3

Browse files
committed
First cut of loading NQPCORE.setting by default, overridable at the command line with --setting=NULL or --setting=OTHER. Seems to work, including how it intersects with interactive mode (uses the same outer-setting mechanism...yay). Big missing piece: setting loading not handled in pre-compiled code yet.
1 parent 3a5e136 commit 1aa0ec3

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/NQP/Actions.pm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ method newpad($/) {
158158

159159
method outerctx($/) {
160160
our @BLOCK;
161+
unless pir::defined(%*COMPILING<%?OPTIONS><outer_ctx>) {
162+
# We haven't got a specified outer context already, so load a
163+
# setting. XXX Won't work for pre-compiled case yet.
164+
pir::compreg__Ps('NQP-rx').load_setting(%*COMPILING<%?OPTIONS><setting> // 'NQPCORE');
165+
}
161166
self.SET_BLOCK_OUTER_CTX(@BLOCK[0]);
162167
}
163168

src/NQP/Compiler.pm

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
11
class NQP::Compiler is HLL::Compiler {
2+
method load_setting($setting_name) {
3+
if $setting_name ne 'NULL' {
4+
# Try to load setting and get context.
5+
my $*CTXSAVE := self;
6+
my $*MAIN_CTX;
7+
pir::load_bytecode("$setting_name.setting.pbc");
8+
unless pir::defined($*MAIN_CTX) {
9+
pir::die("Unable to load setting $setting_name; maybe it is missing a YOU_ARE_HERE?");
10+
}
11+
12+
# Now it's loaded, set it as the outer context of the code
13+
# being compiled.
14+
%*COMPILING<%?OPTIONS><outer_ctx> := $*MAIN_CTX;
15+
}
16+
}
217
}

0 commit comments

Comments
 (0)