[svn:parrot] r46905 - in branches/gsoc_past_optimization: examples/library runtime/parrot/library/PAST

tcurtis at svn.parrot.org tcurtis at svn.parrot.org
Sun May 23 03:12:09 UTC 2010


Author: tcurtis
Date: Sun May 23 03:12:08 2010
New Revision: 46905
URL: https://trac.parrot.org/parrot/changeset/46905

Log:
Fix PAST::Transformer to correctly handle deleted nodes
and update the example to demonstrate it.

Modified:
   branches/gsoc_past_optimization/examples/library/pastwalker.pir
   branches/gsoc_past_optimization/runtime/parrot/library/PAST/Transformer.pir

Modified: branches/gsoc_past_optimization/examples/library/pastwalker.pir
==============================================================================
--- branches/gsoc_past_optimization/examples/library/pastwalker.pir	Sun May 23 02:56:01 2010	(r46904)
+++ branches/gsoc_past_optimization/examples/library/pastwalker.pir	Sun May 23 03:12:08 2010	(r46905)
@@ -33,11 +33,16 @@
 .sub 'walk' :multi(['PAST';'Transformer';'Changer'], ['PAST';'Val'])
     .param pmc walker
     .param pmc node
+    $I0 = node.'value'()
+    if $I0 == 1 goto is_one
     .local pmc result
     result = clone node
     result.'value'(5)
     $P0 = result.'value'()
     .return (result)
+is_one:
+    $P0 = null
+    .return ($P0)
 .end
 
 .namespace []
@@ -48,6 +53,9 @@
     $P0 = new ['PAST';'Val']
     $P0.'value'(0)
     push past, $P0
+    $P0 = new ['PAST';'Val']
+    $P0.'value'(1)
+    push past, $P0
     $P0 = new ['PAST';'Var']
     push past, $P0
 

Modified: branches/gsoc_past_optimization/runtime/parrot/library/PAST/Transformer.pir
==============================================================================
--- branches/gsoc_past_optimization/runtime/parrot/library/PAST/Transformer.pir	Sun May 23 02:56:01 2010	(r46904)
+++ branches/gsoc_past_optimization/runtime/parrot/library/PAST/Transformer.pir	Sun May 23 03:12:08 2010	(r46905)
@@ -40,17 +40,19 @@
 .sub 'replaceChildren'
     .param pmc node
     .param pmc newChildren
-    .local int index, max
-    max = elements node
-    index = 0
-    ge index, max, end
+    .local int childIndex, resultIndex, max
+    max = elements newChildren
+    childIndex = 0
+    resultIndex = 0
+    ge childIndex, max, end
 loop:
-    $P0 = newChildren[index]
+    $P0 = newChildren[childIndex]
     if null $P0 goto reloop
-    node[index] = $P0
+    node[resultIndex] = $P0
+    inc resultIndex
 reloop:
-    inc index
-    lt index, max, loop
+    inc childIndex
+    lt childIndex, max, loop
 end:
     .return ()
 .end


More information about the parrot-commits mailing list