Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Only run MAIN in the mainline. Closes RT #114354
Includes a small refactoring of @*MODULES handling, which avoids
leaving traces in @*MODULES after the first module load (which
is always the setting)
  • Loading branch information
moritz committed Aug 1, 2012
1 parent 85b7789 commit 2cdf1c6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/Perl6/Actions.pm
Expand Up @@ -242,8 +242,9 @@ class Perl6::Actions is HLL::Actions {
# Load the needed libraries.
$*W.add_libs($unit);

# If the unit defines &MAIN, add a &MAIN_HELPER.
if $unit.symbol('&MAIN') {
# If the unit defines &MAIN, and this is in the mainline,
# add a &MAIN_HELPER.
if !$*W.is_precompilation_mode && +@*MODULES == 0 && $unit.symbol('&MAIN') {
$mainline := QAST::Op.new(
:op('call'),
:name('&MAIN_HELPER'),
Expand Down
4 changes: 2 additions & 2 deletions src/Perl6/ModuleLoader.pm
Expand Up @@ -110,6 +110,7 @@ class Perl6::ModuleLoader {
}
my %chosen := @candidates[0];

my @MODULES := nqp::clone(@*MODULES);
# If we didn't already do so, load the module and capture
# its mainline. Otherwise, we already loaded it so go on
# with what we already have.
Expand All @@ -118,6 +119,7 @@ class Perl6::ModuleLoader {
$module_ctx := %modules_loaded{%chosen<key>};
}
else {
my @*MODULES := @MODULES;
if +@*MODULES == 0 {
my %prev := nqp::hash();
%prev<line> := $line;
Expand Down Expand Up @@ -161,11 +163,9 @@ class Perl6::ModuleLoader {
DEBUG("done loading ", %chosen<pm>) if $DEBUG;

}
nqp::pop(@*MODULES);
pir::set_hll_global__vsP('GLOBAL', $preserve_global);
CATCH {
pir::set_hll_global__vsP('GLOBAL', $preserve_global);
nqp::pop(@*MODULES);
nqp::rethrow($_);
}
}
Expand Down

0 comments on commit 2cdf1c6

Please sign in to comment.