Skip to content

Commit

Permalink
Revise setting imports to use Perl6::Compiler.import .
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed May 28, 2009
1 parent 1d8c5bf commit 84b4e1c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 34 deletions.
25 changes: 14 additions & 11 deletions build/gen_setting_pm.pl
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,24 @@

print <<"END_SETTING";
# Need to use all built-in classes, to import their exports.
sub SETTING_INIT() {
END_SETTING
s/\\/\//g for @classes;
print join('', map {
my $colon_form = $_;
$colon_form =~ s/[\/\\]/::/g;
"BEGIN { \%*INC<$_> = 1 };\nuse $colon_form;\n" } @classes);
my $colon_form = $_;
$colon_form =~ s/[\/\\]/::/g;
" Perl6::Compiler.import('$colon_form', ':DEFAULT', ':MANDATORY');\n"
} @classes);
print "}\n";

# Why yes, "OMFG" is a correct response to this hack. We need to make sure
# that we set up %*INC properly for the pre-compiled case, and can't use
# BEGIN blocks to preserve those changes for now.
print <<"END_SETTING";
Q:PIR {
.return (1)
.end
.sub '' :load :init
};
END_SETTING
print join('', map { "\%*INC<$_> = 1;\n" } @classes);
#print <<"END_SETTING";
#Q:PIR {
# .return (1)
#.end
#.sub '' :load :init
#};
#END_SETTING
#print join('', map { "\%*INC<$_> = 1;\n" } @classes);
27 changes: 4 additions & 23 deletions perl6.pir
Original file line number Diff line number Diff line change
Expand Up @@ -445,30 +445,11 @@ Currently this does the equivalent of EXPORTALL on the core namespaces.
=cut

.namespace []

.sub '' :anon :load :init
.local pmc perl6, nslist, nsiter
perl6 = get_hll_global ['Perl6'], 'Compiler'
nslist = split ' ', 'Any'
nsiter = iter nslist
ns_loop:
unless nsiter goto ns_done
$S0 = shift nsiter
$S0 .= '::EXPORT::ALL'
$P0 = perl6.'parse_name'($S0)
.local pmc ns, symiter
ns = get_hll_namespace $P0
if null ns goto ns_loop
symiter = iter ns
sym_loop:
unless symiter goto sym_done
$S0 = shift symiter
$P0 = ns[$S0]
set_global $S0, $P0
goto sym_loop
sym_done:
goto ns_loop
ns_done:
$P0 = get_global 'SETTING_INIT'
if null $P0 goto done
$P0()
done:
.end

## This goes at the bottom because the methods end up in the 'parrot'
Expand Down

0 comments on commit 84b4e1c

Please sign in to comment.