develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34548 - branches/rvar/compilers/pct/src/PAST

From:
pmichaud
Date:
December 28, 2008 21:51
Subject:
[svn:parrot] r34548 - branches/rvar/compilers/pct/src/PAST
Message ID:
20081229055125.758F2CB9FA@x12.develooper.com
Author: pmichaud
Date: Sun Dec 28 21:51:24 2008
New Revision: 34548

Modified:
   branches/rvar/compilers/pct/src/PAST/Node.pir

Log:
[pct]:  Make PAST::Block.symbol smart about adding attributes to existing entry.


Modified: branches/rvar/compilers/pct/src/PAST/Node.pir
==============================================================================
--- branches/rvar/compilers/pct/src/PAST/Node.pir	(original)
+++ branches/rvar/compilers/pct/src/PAST/Node.pir	Sun Dec 28 21:51:24 2008
@@ -551,7 +551,7 @@
 .end
 
 
-=item symbol(name, [attr1 => val1, attr2 => val2, ...])
+=item symbol(name [, attr1 => val1, attr2 => val2, ...])
 
 If called with named arguments, sets the symbol hash corresponding
 to C<name> in the current block.  The HLL is free to select
@@ -573,14 +573,24 @@
     symtable = new 'Hash'
     self['symtable'] = symtable
   have_symtable:
-    if attr goto set_symbol
-  get_symbol:
-    $P0 = symtable[name]
-    if null $P0 goto end
-    .return ($P0)
-  set_symbol:
+    .local pmc symbol
+    symbol = symtable[name]
+    if null symbol goto symbol_empty
+    unless attr goto attr_done
+    .local pmc it
+    it = iter attr
+  attr_loop:
+    unless it goto attr_done
+    $S0 = shift it
+    $P0 = attr[$S0]
+    symbol[$S0] = $P0
+    goto attr_loop
+  attr_done:
+    .return (symbol)
+  symbol_empty:
+    unless attr goto symbol_done
     symtable[name] = attr
-  end:
+  symbol_done:
     .return (attr)
 .end
 



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