[svn:parrot] r48034 - in branches/gsoc_past_optimization: runtime/parrot/library/PAST t/library
tcurtis at svn.parrot.org
tcurtis at svn.parrot.org
Wed Jul 7 17:17:20 UTC 2010
Author: tcurtis
Date: Wed Jul 7 17:17:20 2010
New Revision: 48034
URL: https://trac.parrot.org/parrot/changeset/48034
Log:
Walk .control and .loadinit attributes of PAST::Blocks in PAST::Walker.
Modified:
branches/gsoc_past_optimization/runtime/parrot/library/PAST/Walker.nqp
branches/gsoc_past_optimization/t/library/pastwalker.t
Modified: branches/gsoc_past_optimization/runtime/parrot/library/PAST/Walker.nqp
==============================================================================
--- branches/gsoc_past_optimization/runtime/parrot/library/PAST/Walker.nqp Wed Jul 7 16:53:00 2010 (r48033)
+++ branches/gsoc_past_optimization/runtime/parrot/library/PAST/Walker.nqp Wed Jul 7 17:17:20 2010 (r48034)
@@ -19,6 +19,18 @@
our multi sub walk (PAST::Walker $walker, Integer $i) { }
our multi sub walk (PAST::Walker $walker, String $s) { }
+ our multi sub walkChildren (PAST::Walker $walker, PAST::Block $block) {
+ my $index := 0;
+ my $max := pir::elements__IP($block);
+ until ($index == $max) {
+ walk($walker, $block[$index++]);
+ }
+ walk($walker, $block.control) if $walker.walkable($block.control);
+ walk($walker, $block.loadinit)
+ if pir::exists__IQS($block, 'loadinit')
+ && $walker.walkable($block.loadinit);
+ }
+
our multi sub walkChildren (PAST::Walker $walker, PAST::Var $var) {
my $index := 0;
my $max := pir::elements__IP($var);
Modified: branches/gsoc_past_optimization/t/library/pastwalker.t
==============================================================================
--- branches/gsoc_past_optimization/t/library/pastwalker.t Wed Jul 7 16:53:00 2010 (r48033)
+++ branches/gsoc_past_optimization/t/library/pastwalker.t Wed Jul 7 17:17:20 2010 (r48034)
@@ -49,7 +49,7 @@
$P2 = getattribute walker, 'counts'
$P3 = $P2['blocks']
- is($P3, 3, "PAST::Block")
+ is($P3, 4, "PAST::Block")
$P3 = $P2['ops']
is($P3, 4, "PAST::Op")
@@ -61,7 +61,7 @@
is($P3, 1, "PAST::Val")
$P3 = $P2['stmts']
- is($P3, 2, "PAST::Stmts")
+ is($P3, 3, "PAST::Stmts")
$P3 = $P2['varlists']
is($P3, 1, "PAST::VarList")
@@ -79,6 +79,8 @@
$P0.'pirop'("call")
$P1 = new ['PAST'; 'Var']
$P2 = new ['PAST'; 'Block']
+ $P3 = new ['PAST'; 'Block']
+ $P2.'control'($P3)
$P1.'viviself'($P2)
push $P0, $P1
$P1 = new ['PAST'; 'Val']
@@ -92,6 +94,8 @@
$P1 = new ['PAST'; 'VarList']
push $P0, $P1
$P1 = new ['PAST'; 'Block']
+ $P2 = new ['PAST'; 'Stmts']
+ $P1.'loadinit'($P2)
push $P0, $P1
push past, $P0
$P0 = new ['PAST'; 'Stmts']
More information about the parrot-commits
mailing list