[svn:parrot] r38358 - in branches/pmc_pct/compilers/pmc/src: . parser

bacek at svn.parrot.org bacek at svn.parrot.org
Sat Apr 25 23:58:19 UTC 2009


Author: bacek
Date: Sat Apr 25 23:58:17 2009
New Revision: 38358
URL: https://trac.parrot.org/parrot/changeset/38358

Log:
Handle METHODs in body_part

Modified:
   branches/pmc_pct/compilers/pmc/src/nodes.pir
   branches/pmc_pct/compilers/pmc/src/parser/actions.pm

Modified: branches/pmc_pct/compilers/pmc/src/nodes.pir
==============================================================================
--- branches/pmc_pct/compilers/pmc/src/nodes.pir	Sat Apr 25 22:46:22 2009	(r38357)
+++ branches/pmc_pct/compilers/pmc/src/nodes.pir	Sat Apr 25 23:58:17 2009	(r38358)
@@ -121,6 +121,31 @@
     .param pmc method
 
     $P0 = self.'attr'('vtables', 0, 0)
+    $I0 = exists $P0[name]
+    unless $I0 goto add_method
+    $S0 = concat "Duplicate VTABLE method: ", name
+    die $S0
+  add_method:
+    $P0[name] = method
+    .return ()
+.end
+
+=item C<add_method>
+
+Add METHOD to PMC.
+
+=cut
+
+.sub 'add_method' :method
+    .param string name
+    .param pmc method
+
+    $P0 = self.'attr'('methods', 0, 0)
+    $I0 = exists $P0[name]
+    unless $I0 goto add_method
+    $S0 = concat "Duplicate METHOD: ", name
+    die $S0
+  add_method:
     $P0[name] = method
     .return ()
 .end

Modified: branches/pmc_pct/compilers/pmc/src/parser/actions.pm
==============================================================================
--- branches/pmc_pct/compilers/pmc/src/parser/actions.pm	Sat Apr 25 22:46:22 2009	(r38357)
+++ branches/pmc_pct/compilers/pmc/src/parser/actions.pm	Sat Apr 25 23:58:17 2009	(r38358)
@@ -13,10 +13,12 @@
 
     if $key eq 'begin' {
         $?PMC := PMC::Class.new(
-            :name(~$<identifier>)
+            :name(~$<identifier>),
+            :node($/)
         );
     }
     else {
+        # Set c_header and c_coda
         make $?PMC;
     }
 }
@@ -49,11 +51,13 @@
 method body_part($/, $key) {
     our $?PMC;
 
+    #say("body_part: " ~$key);
     my $m := $/{$key}.ast;
     if $key eq 'vtable' {
         $?PMC.add_vtable($m.name, $m);
     }
     elsif $key eq 'method' {
+        $?PMC.add_method($m.name, $m);
     }
 }
 
@@ -72,7 +76,14 @@
 
 method method($/) {
     #say('METHOD ' ~$<identifier>);
-    my $past := PAST::Block.new( :blocktype('declaration'), :node($/) );
+    my $past := PAST::Block.new(
+        :name(~$<identifier>),
+        :blocktype('declaration'),
+        :node($/),
+        PAST::Op.new(
+            :inline(~$<c_body>)
+        )
+    );
     make $past;
 }
 


More information about the parrot-commits mailing list