Skip to content

Commit da7760a

Browse files
committed
Add a --module-path option so we can make sure we load the correct module during the bootstrap.
1 parent c15d820 commit da7760a

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/HLL/SerializationContextBuilder.pm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ class HLL::Compiler::SerializationContextBuilder {
174174
# during the deserialization.
175175
method load_module($module_name, $cur_GLOBALish) {
176176
# Immediate loading.
177-
ModuleLoader.load_module($module_name, $cur_GLOBALish);
177+
ModuleLoader.load_module($module_name, $cur_GLOBALish,
178+
:prefix(%*COMPILING<%?OPTIONS><module-path>));
178179

179180
# Make sure we do the loading during deserialization.
180181
self.add_event(:deserialize_past(PAST::Stmts.new(

src/ModuleLoader.pm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ knowhow ModuleLoader {
1111
$*CTXSAVE := 0;
1212
}
1313

14-
method load_module($module_name, $cur_GLOBALish) {
14+
method load_module($module_name, $cur_GLOBALish, :$prefix) {
1515
# If we didn't already do so, load the module and capture
1616
# its mainline. Otherwise, we already loaded it so go on
1717
# with what we already have.
1818
my $module_ctx;
1919
my $path := pir::join('/', pir::split('::', $module_name)) ~ '.pbc';
20+
if $prefix {
21+
$path := "$prefix/$path";
22+
}
2023
if pir::defined(%modules_loaded{$path}) {
2124
$module_ctx := %modules_loaded{$path};
2225
}

src/NQP/Compiler.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ sub MAIN(@ARGS) {
1313
@clo.push('parsetrace');
1414
@clo.push('setting=s');
1515
@clo.push('setting-path=s');
16+
@clo.push('module-path=s');
1617

1718
# Enter the compiler.
1819
$nqpcomp.command_line(@ARGS, :encoding('utf8'), :transcode('ascii iso-8859-1'));

0 commit comments

Comments
 (0)