Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Get package decls with :: in the name working for new-style packages.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Oct 2, 2010
1 parent 3c25cb5 commit 3514c77
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/NQP/Actions.pm
Expand Up @@ -379,7 +379,8 @@ method package_declarator:sym<grammar>($/) { make old_package($/) }
method package_declarator:sym<role>($/) { make package($/); }

sub package($/) {
my $name := ~$<package_def><name>;
my @ns := pir::clone__PP($<package_def><name><identifier>);
my $name := ~@ns.pop;

# Prefix the class initialization with initial setup. Also install it
# in the symbol table right away.
Expand All @@ -392,7 +393,7 @@ sub package($/) {
)
),
PAST::Op.new( :pasttype('bind'),
PAST::Var.new( :name($name), :namespace(''), :scope('package') ),
PAST::Var.new( :name($name), :namespace(@ns), :scope('package') ),
PAST::Var.new( :name('type_obj'), :scope('register') )
),
PAST::Op.new( :pasttype('bind'),
Expand All @@ -410,8 +411,8 @@ sub package($/) {
# Add call to add_parent if we have one.
# XXX Doesn't handle lexical classes yet.
if $<package_def><parent> {
my @ns := pir::clone__PP($<package_def><parent>);
my $name := @ns.pop;
my @ns := pir::clone__PP($<package_def><parent><identifier>);
my $name := ~@ns.pop;
$*PACKAGE-SETUP.push(PAST::Op.new(
:pasttype('callmethod'), :name('add_parent'),
PAST::Op.new(
Expand All @@ -436,8 +437,7 @@ sub package($/) {
));

# Set up slot for the type object to live in.
@BLOCK[0][0].unshift(PAST::Var.new( :name($name), :scope('package'), :isdecl(1) ));
@BLOCK[0].symbol($name, :scope('package'));
@BLOCK[0][0].unshift(PAST::Var.new( :name($name), :namespace(@ns), :scope('package'), :isdecl(1) ));

# Evaluate anything else in the package in-line; also give it a $?CLASS
# lexical. XXX Due to Parrot static lexpad fail, it's currently package scoped.
Expand Down

0 comments on commit 3514c77

Please sign in to comment.