Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix loading foreign libraries.
Import the proper namespace for foreign libraries.
  • Loading branch information
tene committed Jun 3, 2009
1 parent 7cfa196 commit 77db80c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
11 changes: 8 additions & 3 deletions src/builtins/eval.pir
Expand Up @@ -153,13 +153,13 @@ itself can be found in src/builtins/control.pir.
$P0 = ver['lang']
if null $P0 goto no_hll
lang = $P0
.local pmc compiler, library, imports, callerns
.local pmc name, compiler, library, imports, callerns, foreignlibns
$P0 = getinterp
callerns = $P0['namespace';1]
'load-language'(lang)
compiler = compreg lang
$P0 = compiler_obj.'parse_name'(module)
library = compiler.'load_library'($P0)
name = compiler_obj.'parse_name'(module)
library = compiler.'load_library'(name)
imports = library['symbols']
imports = imports['DEFAULT']
.local pmc ns_iter, item
Expand All @@ -171,6 +171,11 @@ itself can be found in src/builtins/control.pir.
callerns[$S0] = $P0
goto import_loop
import_loop_end:
foreignlibns = library['namespace']
if null foreignlibns goto no_foreign_ns
$S0 = pop name
set_hll_global name, $S0, foreignlibns
no_foreign_ns:
.return (library)
no_hll:
# Require module.
Expand Down
9 changes: 6 additions & 3 deletions src/parser/actions.pm
Expand Up @@ -415,8 +415,9 @@ method use_statement($/) {
}

## Handle versioning
my $ver;
if $<colonpair> {
my $ver := PAST::Op.new( :pasttype('call'), :name('hash') );
$ver := PAST::Op.new( :pasttype('call'), :name('hash') );
for $<colonpair> {
$ver.push( $_.ast );
}
Expand All @@ -430,12 +431,14 @@ method use_statement($/) {
## XXX Need to handle tags here too, and creating needed lexical
## slots.
our @?NS;
my %ver_hash;
for @($ver) { if $_ { %ver_hash{$_[0].value()} := $_[1].value() } }
if $tags {
my %tag_hash;
for @($tags) { %tag_hash{$_[0].value()} := 1 }
use($name, :import_to(@?NS ?? @?NS[0] !! ''), :tags(%tag_hash));
use($name, :import_to(@?NS ?? @?NS[0] !! ''), :ver(%ver_hash), :tags(%tag_hash));
} else {
use($name, :import_to(@?NS ?? @?NS[0] !! ''));
use($name, :import_to(@?NS ?? @?NS[0] !! ''), :ver(%ver_hash),);
}
}
$past := PAST::Stmts.new( :node($/) );
Expand Down

0 comments on commit 77db80c

Please sign in to comment.