[svn:parrot] r38634 - in branches/pmc_pct/compilers/pmcc/src: . emitter parser
cotto at svn.parrot.org
cotto at svn.parrot.org
Sat May 9 12:04:19 UTC 2009
Author: cotto
Date: Sat May 9 12:04:18 2009
New Revision: 38634
URL: https://trac.parrot.org/parrot/changeset/38634
Log:
[pmcc] add support for (simple) function pointer ATTRs
Modified:
branches/pmc_pct/compilers/pmcc/src/emitter/pmc.pm
branches/pmc_pct/compilers/pmcc/src/nodes.pir
branches/pmc_pct/compilers/pmcc/src/parser/actions.pm
branches/pmc_pct/compilers/pmcc/src/parser/grammar.pg
Modified: branches/pmc_pct/compilers/pmcc/src/emitter/pmc.pm
==============================================================================
--- branches/pmc_pct/compilers/pmcc/src/emitter/pmc.pm Sat May 9 12:04:01 2009 (r38633)
+++ branches/pmc_pct/compilers/pmcc/src/emitter/pmc.pm Sat May 9 12:04:18 2009 (r38634)
@@ -82,7 +82,12 @@
my @struct_members;
for @attrs {
- @struct_members.push(" " ~ $_<type> ~ " " ~ $_<name> ~ ";\n");
+ if $_<is_fp> {
+ @struct_members.push(" " ~ $_<type> ~";\n");
+ }
+ else {
+ @struct_members.push(" " ~ $_<type> ~ " " ~ $_<name> ~ ";\n");
+ }
}
$struct_end := "} Parrot_" ~ self.name ~ "_attributes;\n";
@@ -116,8 +121,8 @@
for @attrs {
@accessors.push( self.generate_accessor_comment(self.name, $_<name>) );
- @accessors.push( self.generate_get_accessor($_<type>,$_<name>) );
- @accessors.push( self.generate_set_accessor($_<type>,$_<name>) );
+ @accessors.push( self.generate_get_accessor($_<type>, $_<name>) );
+ @accessors.push( self.generate_set_accessor($_<type>, $_<name>) );
}
return join("\n", @accessors);
Modified: branches/pmc_pct/compilers/pmcc/src/nodes.pir
==============================================================================
--- branches/pmc_pct/compilers/pmcc/src/nodes.pir Sat May 9 12:04:01 2009 (r38633)
+++ branches/pmc_pct/compilers/pmcc/src/nodes.pir Sat May 9 12:04:18 2009 (r38634)
@@ -278,6 +278,7 @@
.sub 'add_attr' :method
.param string name
.param string type
+ .param int is_fp
.local pmc it, attrs, attr
@@ -297,6 +298,7 @@
attr = new 'Hash'
attr['type'] = type
attr['name'] = name
+ attr['is_fp'] = is_fp
push attrs, attr
.return ()
.end
Modified: branches/pmc_pct/compilers/pmcc/src/parser/actions.pm
==============================================================================
--- branches/pmc_pct/compilers/pmcc/src/parser/actions.pm Sat May 9 12:04:01 2009 (r38633)
+++ branches/pmc_pct/compilers/pmcc/src/parser/actions.pm Sat May 9 12:04:18 2009 (r38634)
@@ -54,17 +54,25 @@
our $?PMC;
my $name;
my $type;
+ my $is_fp;
my $accessor_type;
if $key eq 'simple_attr' {
- $type := ~$/<simple_attr><simple_attr_type>;
- $name := ~$/<simple_attr><identifier>;
+ $type := ~$/<simple_attr><simple_attr_type>;
+ $name := ~$/<simple_attr><identifier>;
+ $is_fp := 0;
}
elsif $key eq 'pointer_attr' {
- $type := ~$/<pointer_attr><pointer_attr_type>;
- $name := ~$/<pointer_attr><identifier>;
+ $type := ~$/<pointer_attr><pointer_attr_type>;
+ $name := ~$/<pointer_attr><identifier>;
+ $is_fp := 0;
+ }
+ elsif $key eq 'func_pointer_attr' {
+ $type := ~$/<func_pointer_attr>;
+ $name := ~$/<func_pointer_attr><identifier>;
+ $is_fp := 1;
}
- $?PMC.add_attr($name, $type);
+ $?PMC.add_attr($name, $type, $is_fp);
}
Modified: branches/pmc_pct/compilers/pmcc/src/parser/grammar.pg
==============================================================================
--- branches/pmc_pct/compilers/pmcc/src/parser/grammar.pg Sat May 9 12:04:01 2009 (r38633)
+++ branches/pmc_pct/compilers/pmcc/src/parser/grammar.pg Sat May 9 12:04:18 2009 (r38634)
@@ -56,17 +56,18 @@
}
rule attribute {
- 'ATTR' <attribute_type> <c_comment>?
+ 'ATTR' <attribute_type> ';' <c_comment>?
}
rule attribute_type {
- [ <simple_attr> {*} #= simple_attr
- | <pointer_attr> {*} #= pointer_attr
+ [ <simple_attr> {*} #= simple_attr
+ | <pointer_attr> {*} #= pointer_attr
+ | <func_pointer_attr> {*} #= func_pointer_attr
]
}
rule simple_attr {
- <simple_attr_type> <identifier> ';'
+ <simple_attr_type> <identifier>
}
rule simple_attr_type {
@@ -79,13 +80,20 @@
}
rule pointer_attr {
- <pointer_attr_type> <identifier> ';'
+ <pointer_attr_type> <identifier>
}
rule pointer_attr_type {
<simple_attr_type> '*'+
}
+rule func_pointer_attr {
+ [ <pointer_attr_type> | <simple_attr_type> ]
+ '(' '*' <identifier> ')'
+ '(' .*? ')'
+}
+
+
# Body of PMC class.
rule body {
<body_part>*
More information about the parrot-commits
mailing list