Skip to content

Commit

Permalink
Implement foreign namespace protocol
Browse files Browse the repository at this point in the history
I beleive this to be the last critical piece for Rakudo work.
  • Loading branch information
sorear committed Apr 25, 2010
1 parent 5fa07ce commit c389906
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
20 changes: 20 additions & 0 deletions nt/namespace.t
@@ -0,0 +1,20 @@
# vim: ft=perl6

plan(2);

pir::load_bytecode("perl5.pir");
my $p5 := pir::compreg__ps("perl5");

$p5.make_interp('
package Foo::Bar;
sub Method {
my ($self, $x, $y) = @_;
return $x + $y;
}
')();

my $ns := $p5.get_namespace('Foo::Bar');

ok(pir::defined($ns), "can get namespaces for packages");

ok($ns.Method(1,3,7) == 4, "can call package methods");
11 changes: 11 additions & 0 deletions perl5.pir
Expand Up @@ -189,6 +189,17 @@ Implements the PDD-31 library loading interface.
.return (name_str)
.end

.sub 'get_namespace' :method
.param pmc name

self.'!force'()

$P0 = getattribute self, '$!interp'
$P0 = $P0.'get_namespace'(name)

.return($P0)
.end

.sub 'get_exports' :method
.param pmc module_name
.param pmc imports :slurpy
Expand Down

0 comments on commit c389906

Please sign in to comment.