Skip to content

Commit

Permalink
Switch to PDD-31 style load_module
Browse files Browse the repository at this point in the history
We're only implementing the string form; namespace considerations
seem to imply parse_name is unimplementable for Perl 5.  It will
probably be gone in my PDD-31 replacement draft.
  • Loading branch information
sorear committed Apr 2, 2010
1 parent 929684b commit 5145ceb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 29 deletions.
2 changes: 1 addition & 1 deletion nt/load_xs.t
Expand Up @@ -3,7 +3,7 @@
plan(1);

pir::load_bytecode('perl5.pbc');
my $ns := pir::compreg__ps('perl5').load_library(['Scalar','Util'])<namespace>;
my $ns := pir::compreg__ps('perl5').load_module('Scalar::Util');

ok(1, "Scalar::Util loaded OK");

Expand Down
41 changes: 13 additions & 28 deletions perl5.pir
Expand Up @@ -105,44 +105,29 @@ to the blizkost compiler.
.tailcall $P0()
.end

=item load_library
=item load_module(name)

Implements the HLLCompiler library loading interface.
=item get_module(name)

Implements the PDD-31 library loading interface.

=cut

.sub 'load_library' :method
.param pmc name
.sub 'load_module' :method
.param pmc name_str
.param pmc extra :named :slurpy

# Construct a use into some dummy package.
# XXX Add a number to make it unique per use.
.local string package_name, name_str
package_name = 'BLIZKOST::TEMP::IMPORT'
name_str = join '::', name

self.'!force'()
$P0 = getattribute self, '$!requirer'
$P0(name_str)

# Make namespace wrapper PMC.
.local pmc ns_wrapper, p5i
p5i = getattribute self, "$!interp"
ns_wrapper = new ['P5Namespace'], p5i
ns_wrapper = name_str

# Set up imports. XXX No import symbols yet, todo.
.local pmc imports
imports = new ['Hash']
$P0 = new ['Hash']
imports['DEFAULT'] = $P0

# Construct library info hash.
.local pmc result
result = new ['Hash']
result['namespace'] = ns_wrapper
result['symbols'] = imports
.return (result)
.return (name_str)
.end

.sub 'get_module' :method
.param pmc name_str

.return (name_str)
.end

=back
Expand Down

0 comments on commit 5145ceb

Please sign in to comment.