[svn:parrot] r38657 - branches/pmc_pct/compilers/pmcc/src/emitter

cotto at svn.parrot.org cotto at svn.parrot.org
Sat May 9 22:11:14 UTC 2009


Author: cotto
Date: Sat May  9 22:11:14 2009
New Revision: 38657
URL: https://trac.parrot.org/parrot/changeset/38657

Log:
[pmcc] only generate ATTR-related code when there are ATTRs

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	Sat May  9 21:58:21 2009	(r38656)
+++ branches/pmc_pct/compilers/pmcc/src/emitter/pmc.pm	Sat May  9 22:11:14 2009	(r38657)
@@ -74,13 +74,17 @@
     my $struct_body;
     my $struct_end;
 
+    my @attrs := self.attrs;
+    my @struct_members;
+
+    if + at attrs == 0 {
+        return "";
+    }
+
     $struct_start :=
         "\n/* " ~ self.name ~ " PMC's underlying struct. */\n" ~
         "typedef struct Parrot_" ~ self.name ~ "_attributes {\n";
 
-    my @attrs := self.attrs;
-    my @struct_members;
-
     for @attrs {
         if $_<is_fp> {
             @struct_members.push("    " ~ $_<type> ~";\n");
@@ -103,6 +107,12 @@
 
 method generate_casting_macro() {
 
+    my @attrs := self.attrs;
+
+    if + at attrs == 0 {
+        return "";
+    }
+
     return
         "#define PARROT_" ~ self.ucname ~ "(o) ((Parrot_" ~ self.name ~ "_attributes *) PMC_data(o))\n";
 }
@@ -119,6 +129,10 @@
     my @attrs := self.attrs;
     my @accessors;
 
+    if + at attrs == 0 {
+        return "";
+    }
+
     for @attrs {
         @accessors.push( self.generate_accessor_comment(self.name, $_<name>) );
         @accessors.push( self.generate_get_accessor($_<type>, $_<name>) );


More information about the parrot-commits mailing list