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

Commit

Permalink
Copy/port code from JnthnNQP to make the attribute initialization calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Sep 26, 2010
1 parent c51bdac commit 57ae6b3
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src/NQP/Actions.pm
Original file line number Diff line number Diff line change
Expand Up @@ -492,11 +492,31 @@ method variable_declarator($/) {
}
if $*SCOPE eq 'has' {
$BLOCK.symbol($name, :scope('attribute') );
unless $BLOCK<attributes> {
$BLOCK<attributes> :=
PAST::Op.new( :pasttype('list'), :named('attr') );
if $*PACKAGE-SETUP {
# Create and add a meta-attribute.
my $meta-attr-type := %*HOW-METAATTR{$*PKGDECL} || $*DEFAULT-METAATTR;
$*PACKAGE-SETUP.push(PAST::Op.new(
:pasttype('callmethod'), :name('add_attribute'),
PAST::Op.new(
:pirop('get_how PP'),
PAST::Var.new( :name('type_obj'), :scope('register') )
),
PAST::Var.new( :name('type_obj'), :scope('register') ),
PAST::Op.new(
:pasttype('callmethod'), :name('new'),
PAST::Var.new( :name($meta-attr-type), :namespace(''), :scope('package') ),
PAST::Val.new( :value($name), :named('name') )
)
));
}
else {
# XXX Old way, will go away once all package types are ported.
unless $BLOCK<attributes> {
$BLOCK<attributes> :=
PAST::Op.new( :pasttype('list'), :named('attr') );
}
$BLOCK<attributes>.push( $name );
}
$BLOCK<attributes>.push( $name );
$past := PAST::Stmts.new();
}
else {
Expand Down

0 comments on commit 57ae6b3

Please sign in to comment.