[svn:parrot] r38590 - branches/pmc_pct/compilers/pmcc/src/emitter
cotto at svn.parrot.org
cotto at svn.parrot.org
Fri May 8 07:25:42 UTC 2009
Author: cotto
Date: Fri May 8 07:25:40 2009
New Revision: 38590
URL: https://trac.parrot.org/parrot/changeset/38590
Log:
[pmcc] add incomplete code to create ATTR accessors
Modified:
branches/pmc_pct/compilers/pmcc/src/emitter/pmc.pm
Modified: branches/pmc_pct/compilers/pmcc/src/emitter/pmc.pm
==============================================================================
--- branches/pmc_pct/compilers/pmcc/src/emitter/pmc.pm Fri May 8 06:00:47 2009 (r38589)
+++ branches/pmc_pct/compilers/pmcc/src/emitter/pmc.pm Fri May 8 07:25:40 2009 (r38590)
@@ -29,6 +29,8 @@
self.generate_casting_macro(), "\n",
+ self.generate_attr_accessors(), "\n",
+
'#endif /* ', $guard, " */ \n"
)
);
@@ -100,6 +102,46 @@
"#define PARROT_" ~ self.ucname ~ "(o) ((Parrot_" ~ self.name ~ "_attributes *) PMC_data(o))\n";
}
+
+#=item C<generate_attr_accessors>
+#
+#Generate a macros to manipulate ATTRs
+#
+#=cut
+
+method generate_attr_accessors() {
+
+ my @attrs := self.attrs;
+ my @accessors;
+
+ for @attrs {
+ @accessors.push( self.generate_get_accessor($_<type>,$_<name>) );
+ #@accessors.push( self.generate_set_accessor($_<type>,$_<name>);
+ }
+
+ return join("\n", @accessors);
+}
+
+
+method generate_get_accessor($type, $attr_name) {
+
+ my $macro_start :=
+"#define GETATTR_" ~ self.name ~ "_" ~ $attr_name ~ "(interp, pmc, dest) \\
+do { \\
+ if (PObj_is_object_TEST(pmc)) { \\\n";
+
+ #XXX: Put code to generate the accessor body here.
+
+ my $macro_end :=
+" } \\
+ else \\
+ (dest) = ((Parrot_" ~ self.name ~ "_attributes *)PMC_data(pmc))->" ~ $attr_name ~ "; \\
+} while (0);\n";
+
+ return $macro_start ~ $macro_end;
+}
+
+
#=item C<generate_c_file>
#
#Generate C file for PMC.
@@ -158,6 +200,13 @@
join('', @res);
}
+method dumper($x) {
+ PIR q<
+ load_bytecode "dumper.pbc"
+ >;
+ _dumper($x);
+}
+
method attrs() {
self.past.attrs;
}
More information about the parrot-commits
mailing list