develooper Front page | perl.cvs.parrot | Postings from January 2009

[svn:parrot] r35934 - in trunk: languages/pipp/src/pmc lib/Parrot/Pmc2c src/pmc

From:
cotto
Date:
January 23, 2009 17:19
Subject:
[svn:parrot] r35934 - in trunk: languages/pipp/src/pmc lib/Parrot/Pmc2c src/pmc
Message ID:
20090124011844.5B043CB9AE@x12.develooper.com
Author: cotto
Date: Fri Jan 23 17:18:43 2009
New Revision: 35934

Modified:
   trunk/languages/pipp/src/pmc/phpfloat.pmc
   trunk/lib/Parrot/Pmc2c/Parser.pm
   trunk/src/pmc/callsignature.pmc
   trunk/src/pmc/timer.pmc

Log:
[pmc] make ATTRs implicitly be passed down the inheritance chain


Modified: trunk/languages/pipp/src/pmc/phpfloat.pmc
==============================================================================
--- trunk/languages/pipp/src/pmc/phpfloat.pmc	(original)
+++ trunk/languages/pipp/src/pmc/phpfloat.pmc	Fri Jan 23 17:18:43 2009
@@ -26,7 +26,6 @@
     group    php_group
     hll      PHP
     maps     Float {
-    ATTR FLOATVAL fv;
 
 /*
 

Modified: trunk/lib/Parrot/Pmc2c/Parser.pm
==============================================================================
--- trunk/lib/Parrot/Pmc2c/Parser.pm	(original)
+++ trunk/lib/Parrot/Pmc2c/Parser.pm	Fri Jan 23 17:18:43 2009
@@ -76,7 +76,7 @@
     my $lineno = count_newlines($preamble) + $chewed_lines + 1;
     my $class_init;
 
-    ($lineno, $pmcbody)    = find_attrs(  $pmc, $pmcbody, $lineno, $filename);
+    ($lineno, $pmcbody)    = find_attrs(  $pmc, $pmcbody, $lineno, $filename, $pmc2cMain);
     ($lineno, $class_init) = find_methods($pmc, $pmcbody, $lineno, $filename);
 
     $pmc->postamble( Parrot::Pmc2c::Emitter->text( $post, $filename, $lineno ) );
@@ -90,7 +90,26 @@
 }
 
 sub find_attrs {
-    my ($pmc, $pmcbody, $lineno, $filename) = @_;
+    my ($pmc, $pmcbody, $lineno, $filename, $pmc2cMain) = @_;
+
+    #prepend parent ATTRs to this PMC's ATTR list, if possible
+    my $got_attrs_from = '';
+    foreach my $parent ( @{ $pmc->{parents} } ) {
+
+        my $parent_dump = $pmc2cMain->read_dump( lc($parent) . '.dump' );
+
+        if ( $got_attrs_from ne '' && $parent_dump->{has_attribute} ) {
+            die "$filename is trying to extend $got_attrs_from and $parent, ".
+                "but both these PMCs have ATTRs.";
+        }
+
+        if ( $parent_dump->{has_attribute} ) {
+            $got_attrs_from = $parent;
+            foreach my $parent_attrs ( @{ $parent_dump->{attributes} } ) {
+                $pmc->add_attribute($parent_attrs);
+            }
+        }
+    }
 
     # backreferences here are all +1 because below the qr is wrapped in quotes
     my $attr_re = qr{

Modified: trunk/src/pmc/callsignature.pmc
==============================================================================
--- trunk/src/pmc/callsignature.pmc	(original)
+++ trunk/src/pmc/callsignature.pmc	Fri Jan 23 17:18:43 2009
@@ -30,8 +30,6 @@
         PARROT_CAPTURE(obj)->hash = pmc_new((i), enum_class_Hash);
 
 pmclass CallSignature extends Capture need_ext provides array provides hash {
-    ATTR PMC    *array;      /* Positional arguments */
-    ATTR PMC    *hash;       /* Named arguments */
     ATTR PMC    *returns;    /* Result PMCs, if they were passed with the call */
     ATTR PMC    *type_tuple; /* Cached argument types for multiple dispatch */
     ATTR STRING *short_sig;  /* Simple string signature args & returns */

Modified: trunk/src/pmc/timer.pmc
==============================================================================
--- trunk/src/pmc/timer.pmc	(original)
+++ trunk/src/pmc/timer.pmc	Fri Jan 23 17:18:43 2009
@@ -59,16 +59,6 @@
 #include "parrot/scheduler_private.h"
 
 pmclass Timer extends Task provides event need_ext {
-    ATTR INTVAL        id;        /* The task ID. */
-    ATTR INTVAL        priority;  /* The priority of the task. */
-    ATTR FLOATVAL      birthtime; /* The creation time stamp of the task. */
-    ATTR STRING       *type;      /* The type of the task. */
-    ATTR STRING       *subtype;   /* The subtype of the task. */
-    ATTR STRING       *status;    /* The status of the task. */
-    ATTR Parrot_Interp interp;    /* The interpreter that created the task. */
-    ATTR PMC          *codeblock; /* An (optional) codeblock for the task. */
-    ATTR PMC          *data;      /* Additional data for the task. */
-    ATTR char         *cb_data;   /* Additional data for a callback event. */
     ATTR FLOATVAL      duration;  /* The duration of the timer pause */
     ATTR FLOATVAL      interval;  /* How often to repeat */
     ATTR INTVAL        repeat;    /* Whether to repeat:



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About