Commit 5215b5b2 authored by Stefan Behnel's avatar Stefan Behnel

optimise Visitor.ScopeTrackingTransform

parent 356808fe
...@@ -21,6 +21,11 @@ cdef class CythonTransform(VisitorTransform): ...@@ -21,6 +21,11 @@ cdef class CythonTransform(VisitorTransform):
cdef public context cdef public context
cdef public current_directives 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 class EnvTransform(CythonTransform):
cdef public list env_stack cdef public list env_stack
......
...@@ -291,8 +291,8 @@ class CythonTransform(VisitorTransform): ...@@ -291,8 +291,8 @@ class CythonTransform(VisitorTransform):
class ScopeTrackingTransform(CythonTransform): class ScopeTrackingTransform(CythonTransform):
# Keeps track of type of scopes # Keeps track of type of scopes
scope_type = None # can be either of 'module', 'function', 'cclass', 'pyclass' #scope_type: can be either of 'module', 'function', 'cclass', 'pyclass', 'struct'
scope_node = None #scope_node: the node that owns the current scope
def visit_ModuleNode(self, node): def visit_ModuleNode(self, node):
self.scope_type = 'module' self.scope_type = 'module'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment