+cimport cython
+
from Cython.Compiler.Visitor cimport (
CythonTransform, VisitorTransform, TreeVisitor,
ScopeTrackingTransform, EnvTransform)
cdef class NormalizeTree(CythonTransform):
cdef bint is_in_statlist
cdef bint is_in_expr
+ cpdef visit_StatNode(self, node, is_listcontainer=*)
cdef class PostParse(ScopeTrackingTransform):
cdef dict specialattribute_handlers
#def eliminate_rhs_duplicates(list expr_list_list, list ref_node_sequence)
#def sort_common_subsequences(list items)
+@cython.locals(starred_targets=Py_ssize_t, lhs_size=Py_ssize_t, rhs_size=Py_ssize_t)
cdef flatten_parallel_assignments(list input, list output)
cdef map_starred_assignment(list lhs_targets, list starred_assignments, list lhs_args, list rhs_args)
import cython
-from cython import set
cython.declare(copy=object, ModuleNode=object, TreeFragment=object, TemplateTransform=object,
EncodedString=object, error=object, warning=object, PyrexTypes=object, Naming=object)
and appends them to ref_node_sequence. The input list is modified
in-place.
"""
- seen_nodes = set()
+ seen_nodes = cython.set()
ref_nodes = {}
def find_duplicates(node):
if node.is_literal or node.is_name:
'operator.comma' : c_binop_constructor(','),
}
- special_methods = set(['declare', 'union', 'struct', 'typedef', 'sizeof',
- 'cast', 'pointer', 'compiled', 'NULL']
- + list(unop_method_nodes.keys()))
+ special_methods = cython.set(['declare', 'union', 'struct', 'typedef', 'sizeof',
+ 'cast', 'pointer', 'compiled', 'NULL'])
+ special_methods.update(unop_method_nodes.keys())
def __init__(self, context, compilation_directive_defaults):
super(InterpretCompilerDirectives, self).__init__(context)
self.compilation_directive_defaults = {}
for key, value in compilation_directive_defaults.items():
self.compilation_directive_defaults[unicode(key)] = value
- self.cython_module_names = set()
+ self.cython_module_names = cython.set()
self.directive_names = {}
def check_directive_scope(self, pos, directive, scope):
return node
def visit_ModuleNode(self, node):
- self.seen_vars_stack.append(set())
+ self.seen_vars_stack.append(cython.set())
node.analyse_declarations(self.env_stack[-1])
self.visitchildren(node)
self.seen_vars_stack.pop()
return node
def visit_FuncDefNode(self, node):
- self.seen_vars_stack.append(set())
+ self.seen_vars_stack.append(cython.set())
lenv = node.local_scope
node.body.analyse_control_flow(lenv) # this will be totally refactored
node.declare_arguments(lenv)
node.analyse_declarations(self.env_stack[-1])
# the node may or may not have a local scope
if node.expr_scope:
- self.seen_vars_stack.append(set(self.seen_vars_stack[-1]))
+ self.seen_vars_stack.append(cython.set(self.seen_vars_stack[-1]))
self.env_stack.append(node.expr_scope)
self.visitchildren(node)
self.env_stack.pop()