[svn:parrot] r47923 - branches/gsoc_past_optimization/runtime/parrot/library/Tree/Pattern

tcurtis at svn.parrot.org tcurtis at svn.parrot.org
Wed Jun 30 00:54:54 UTC 2010


Author: tcurtis
Date: Wed Jun 30 00:54:54 2010
New Revision: 47923
URL: https://trac.parrot.org/parrot/changeset/47923

Log:
Add .depth;

Modified:
   branches/gsoc_past_optimization/runtime/parrot/library/Tree/Pattern/Transformer.nqp

Modified: branches/gsoc_past_optimization/runtime/parrot/library/Tree/Pattern/Transformer.nqp
==============================================================================
--- branches/gsoc_past_optimization/runtime/parrot/library/Tree/Pattern/Transformer.nqp	Wed Jun 30 00:48:56 2010	(r47922)
+++ branches/gsoc_past_optimization/runtime/parrot/library/Tree/Pattern/Transformer.nqp	Wed Jun 30 00:54:54 2010	(r47923)
@@ -10,15 +10,29 @@
     has $pattern;
     has $transform;
 
+    has $depth;
+
     method new ($pattern, $transform, *%adverbs) {
         my $class := pir::getattribute__PPS(self.HOW(),
                                            'parrotclass');
         my $self := pir::new__PP($class);
+        $self.depth(0);
         $self.pattern($pattern);
         $self.transform($transform);
         $self;
     }
 
+    method depth ($depth?) {
+        my $result;
+        if pir::defined__IP($depth) {
+            pir::setattribute(self, '$depth', $depth);
+        }
+        else {
+            $result := pir::getattribute__PPS(self, '$depth');
+        }
+        $result;
+    }
+
     method pattern ($pattern?) {
         my $result;
         if pir::defined__iP($pattern) {
@@ -61,8 +75,10 @@
         else {
             $result := $node;
         }
+        $walker.depth($walker.depth + 1);
         my $newChildren := walkChildren($walker, $result);
         replaceChildren($result, $newChildren);
+        $walker.depth($walker.depth - 1);
         $result;
     }
 


More information about the parrot-commits mailing list