optimise Visitor.ScopeTrackingTransform
authorStefan Behnel <scoder@users.berlios.de>
Fri, 12 Nov 2010 11:18:56 +0000 (12:18 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Fri, 12 Nov 2010 11:18:56 +0000 (12:18 +0100)
Cython/Compiler/Visitor.pxd
Cython/Compiler/Visitor.py

index 495cece4cc0947a30399c4c135b89410d47bf200..8c88a3dc9c71fa627e84e7111e7d943d731ba655 100644 (file)
@@ -21,6 +21,11 @@ cdef class CythonTransform(VisitorTransform):
     cdef public context
     cdef public current_directives
 
+cdef class ScopeTrackingTransform(CythonTransform):
+    cdef public scope_type
+    cdef public scope_node
+    cdef visit_scope(self, node, scope_type)
+
 cdef class EnvTransform(CythonTransform):
     cdef public list env_stack
 
index 6ff36034d8ca196d70aed42f076581dc69b76c52..a9cd264c9df814270d0711b67aa976fc57a3237a 100644 (file)
@@ -291,8 +291,8 @@ class CythonTransform(VisitorTransform):
 
 class ScopeTrackingTransform(CythonTransform):
     # Keeps track of type of scopes
-    scope_type = None # can be either of 'module', 'function', 'cclass', 'pyclass'
-    scope_node = None
+    #scope_type: can be either of 'module', 'function', 'cclass', 'pyclass', 'struct'
+    #scope_node: the node that owns the current scope
     
     def visit_ModuleNode(self, node):
         self.scope_type = 'module'