[svn:parrot] r40574 - branches/tt795_kill_parrot_sub_structure/lib/Parrot/Pmc2c
bacek at svn.parrot.org
bacek at svn.parrot.org
Sun Aug 16 03:13:33 UTC 2009
Author: bacek
Date: Sun Aug 16 03:13:25 2009
New Revision: 40574
URL: https://trac.parrot.org/parrot/changeset/40574
Log:
[pmc2c] Support arrays as ATTRibutes
Modified:
branches/tt795_kill_parrot_sub_structure/lib/Parrot/Pmc2c/Attribute.pm
branches/tt795_kill_parrot_sub_structure/lib/Parrot/Pmc2c/Parser.pm
Modified: branches/tt795_kill_parrot_sub_structure/lib/Parrot/Pmc2c/Attribute.pm
==============================================================================
--- branches/tt795_kill_parrot_sub_structure/lib/Parrot/Pmc2c/Attribute.pm Sat Aug 15 23:18:14 2009 (r40573)
+++ branches/tt795_kill_parrot_sub_structure/lib/Parrot/Pmc2c/Attribute.pm Sun Aug 16 03:13:25 2009 (r40574)
@@ -10,9 +10,10 @@
my ( $class, $self_hash ) = @_;
my $self = {
(
- name => "",
- type => "",
- modifiers => [],
+ name => "",
+ type => "",
+ array_size => "",
+ modifiers => [],
%{ $self_hash || {} }
)
};
@@ -36,7 +37,7 @@
sub generate_declaration {
my ( $self, $pmc ) = @_;
my $h = $pmc->{emitter};
- my $decl = ' ' . $self->{type} . ' ' . $self->{name} . ";\n";
+ my $decl = ' ' . $self->{type} . ' ' . $self->{name} . $self->{array_size} . ";\n";
$h->emit($decl);
Modified: branches/tt795_kill_parrot_sub_structure/lib/Parrot/Pmc2c/Parser.pm
==============================================================================
--- branches/tt795_kill_parrot_sub_structure/lib/Parrot/Pmc2c/Parser.pm Sat Aug 15 23:18:14 2009 (r40573)
+++ branches/tt795_kill_parrot_sub_structure/lib/Parrot/Pmc2c/Parser.pm Sun Aug 16 03:13:25 2009 (r40574)
@@ -146,6 +146,9 @@
| \(\*\w*\)\(.*?\)
)
+ # Array size
+ (\[\d+\])?
+
# modifiers
\s*
((?::\w+\s*)*)
@@ -159,19 +162,21 @@
}sx;
while ($pmcbody =~ s/($attr_re)//o) {
- my ($type, $name, @modifiers, $comment);
+ my ($type, $name, $array_size, @modifiers, $comment);
$type = $2;
$name = $3;
- @modifiers = split /\s/, $4;
- $comment = $5;
+ $array_size = $4 || '';
+ @modifiers = split /\s/, $5;
+ $comment = $6;
$lineno += count_newlines($1);
$pmc->add_attribute(Parrot::Pmc2c::Attribute->new(
{
- name => $name,
- type => $type,
- modifiers => \@modifiers,
+ name => $name,
+ type => $type,
+ array_size => $array_size,
+ modifiers => \@modifiers,
}
));
}
More information about the parrot-commits
mailing list