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

cotto at svn.parrot.org cotto at svn.parrot.org
Sat May 16 23:55:18 UTC 2009


Author: cotto
Date: Sat May 16 23:55:18 2009
New Revision: 38854
URL: https://trac.parrot.org/parrot/changeset/38854

Log:
[pmcc] emit an attribute_def string similar to what pmc2c does

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 16 23:28:14 2009	(r38853)
+++ branches/pmc_pct/compilers/pmcc/src/emitter/pmc.pm	Sat May 16 23:55:18 2009	(r38854)
@@ -396,6 +396,40 @@
 
 =cut
 
+method generate_attr_defs() {
+
+    my @attrs := self.attrs;
+    
+    my $attr_defs := "";
+    for @attrs {
+
+        my $type := $_<type>;
+        my $name := $_<name>;
+
+        $type.replace(' ','');
+
+        if $type eq 'INTVAL' {
+            $attr_defs := $attr_defs ~ 'I' ~ $name ~ " ";
+        }
+        elsif $type eq 'FLOATVAL' {
+            $attr_defs := $attr_defs ~ 'F' ~ $name ~ " ";
+        }
+        #XXX: using the same thing for FLOATVAL and PMC* smells like a bug, but
+        #it's what pmc2c did.
+        elsif $type eq 'PMC*' {
+            $attr_defs := $attr_defs ~ 'F' ~ $name ~ " ";
+        }
+        elsif $type eq 'STRING*' {
+            $attr_defs := $attr_defs ~ 'S' ~ $name ~ " ";
+        }
+        else {
+            $attr_defs := $attr_defs ~ ':' ~ $name ~ " ";
+        }
+    }
+
+    '    static const char attr_defs [] = "' ~ $attr_defs ~ "\";\n";
+}
+
 
 =item C<get_vtable_func>
 


More information about the parrot-commits mailing list