[svn:parrot] r47848 - in branches/gsoc_past_optimization: . runtime/parrot/library/PAST
tcurtis at svn.parrot.org
tcurtis at svn.parrot.org
Sat Jun 26 00:49:01 UTC 2010
Author: tcurtis
Date: Sat Jun 26 00:49:01 2010
New Revision: 47848
URL: https://trac.parrot.org/parrot/changeset/47848
Log:
PAST::Transformer is Tree::Transformer
Modified:
branches/gsoc_past_optimization/MANIFEST.generated
branches/gsoc_past_optimization/runtime/parrot/library/PAST/Transformer.nqp
Modified: branches/gsoc_past_optimization/MANIFEST.generated
==============================================================================
--- branches/gsoc_past_optimization/MANIFEST.generated Sat Jun 26 00:18:02 2010 (r47847)
+++ branches/gsoc_past_optimization/MANIFEST.generated Sat Jun 26 00:49:01 2010 (r47848)
@@ -319,6 +319,7 @@
runtime/parrot/library/Tree/Pattern/Constant.pbc [main]
runtime/parrot/library/Tree/Pattern/Match.pbc [main]
runtime/parrot/library/Tree/Pattern/Transformer.pbc [main]
+runtime/parrot/library/Tree/Transformer.pbc [main]
runtime/parrot/library/Tree/Walker.pbc [main]
runtime/parrot/library/URI.pbc [main]
runtime/parrot/library/YAML/Dumper.pbc [main]
Modified: branches/gsoc_past_optimization/runtime/parrot/library/PAST/Transformer.nqp
==============================================================================
--- branches/gsoc_past_optimization/runtime/parrot/library/PAST/Transformer.nqp Sat Jun 26 00:18:02 2010 (r47847)
+++ branches/gsoc_past_optimization/runtime/parrot/library/PAST/Transformer.nqp Sat Jun 26 00:49:01 2010 (r47848)
@@ -3,49 +3,14 @@
# $Id$
INIT {
- pir::load_bytecode('PAST/Walker.pbc');
+ pir::load_bytecode('Tree/Transformer.pbc');
}
-class PAST::Transformer is PAST::Walker { }
-
-module Tree::Walker {
- our multi sub walk (PAST::Transformer $walker, PAST::Node $node) {
- my $result := $node;
- replaceChildren($result, walkChildren($walker, $node));
- $result;
- }
-
- our multi sub walk (PAST::Transformer $walker, $node) {
- $node; # Don't touch things that we don't know what to do with.
- }
-
- our multi sub walkChildren (PAST::Transformer $walker,
- PAST::Node $node) {
- my @results;
- my $index := 0;
- my $max := pir::elements__IP($node);
- while ($index < $max) {
- @results[$index] := walk($walker, $node[$index]);
- $index++;
- }
- @results;
- }
-
- our sub replaceChildren ($node, $newChildren) {
- my $index := pir::elements__IP($node);
- while ($index > 0) {
- pir::pop__PP($node);
- $index--;
- }
- my $max := pir::elements__IP($newChildren);
- while ($index < $max) {
- pir::push($node, $newChildren[$index])
- if pir::defined__IP($newChildren[$index]);
- $index++;
- }
- null;
- }
-}
+# This class doesn't differ in behavior from Tree::Transformer, but having
+# it provides both a specification of what you expect to be transforming
+# and a way to easily change its behavior if that becomes necessary in the
+# future.
+class PAST::Transformer is Tree::Transformer { }
# Local Variables:
# mode: cperl
More information about the parrot-commits
mailing list