Skip to content

Commit

Permalink
Tweak stubbed packages again to work when lexical
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Jun 10, 2011
1 parent 6e8c8fc commit e7fb127
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/niecza
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ method open_package_def($, $/ = $*cursor) {
$sub.signature = $<signature>.ast;
$type = ::Metamodel::ParametricRole;
}
my @ns;
if $<longname> {
my $r = self.mangle_longname($<longname>[0], True);
$name = $r<name>;
Expand All @@ -287,18 +288,16 @@ method open_package_def($, $/ = $*cursor) {
if $scope eq 'our' {
$ourpkg = ($r<path>:exists) ?? $r<path> !! ['OUR'];
}
try @ns = $*CURLEX<!sub>.outer.find_pkg(
[ @( $r<path> // ['MY'] ), $r<name> ]);
$*CURLEX<!sub>.outervar = ($scope eq 'anon' || ($r<path>:exists))
?? self.gensym !! $name;
} else {
$*CURLEX<!sub>.outervar = self.gensym;
$name = 'ANON';
}

my @ns = $ourpkg ?? (@( $sub.outer.find_pkg($ourpkg) ), $name) !!
$*unit.anon_stash;

$*unit.create_stash([@ns]);
my $old = $*unit.get_item([@ns]);
my $old = @ns ?? $*unit.get_item([@ns]) !! Any;

if $old && ($old.[0] ne $*unit.name || $*unit.deref($old).closed) {
$/.CURSOR.panic("Redefinition of class [@ns]");
Expand All @@ -307,6 +306,11 @@ method open_package_def($, $/ = $*cursor) {
if $old {
$obj = $*unit.deref($old);
} else {
@ns = $ourpkg ?? (@( $sub.outer.find_pkg($ourpkg) ), $name) !!
$*unit.anon_stash;

$*unit.create_stash([@ns]);

$sub.outer.add_my_stash($*CURLEX<!sub>.outervar, [@ns]);
$obj = $type.new(:$name);
$obj.exports = [ [@ns] ];
Expand Down

0 comments on commit e7fb127

Please sign in to comment.