Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def visit_For(self, node):
self.expr_parent = node
self.result[node] = self.locals.copy()
md.visit(self, node)
self.visit(node.iter)
self.locals.add(node.target.id)
for stmt in node.body:
self.visit(stmt)
for stmt in node.orelse:
self.visit(stmt)
def visit(self, node):
metadata.visit(self, node)
return super(CxxFunction, self).visit(node)
def visit_Assign(self, node):
md.visit(self, node)
self.visit(node.value)
ids = self.gather(Identifiers, node.value)
for target in node.targets:
if isinstance(target, ast.Name):
self.assign_to(target, ids)
if node.value not in self.pure_expressions:
self.result[target.id] = LazynessAnalysis.INF
elif isinstance(target, (ast.Subscript)) or isattr(target):
# if we modify just a part of a variable, it can't be lazy
var_name = get_variable(target)
if isinstance(var_name, ast.Name):
# variable is modified so other variables that use it dies
self.modify(var_name.id)
# and this variable can't be lazy
self.result[var_name.id] = LazynessAnalysis.INF
else:
def visit_While(self, node):
md.visit(self, node)
self.visit(node.test)
self.visit_loop(node.body)
for stmt in node.orelse:
self.visit(stmt)
def visit_AugAssign(self, node):
md.visit(self, node)
# augassigned variable can't be lazy
self.visit(node.value)
if isinstance(node.target, ast.Name):
# variable is modified so other variables that use it dies
self.modify(node.target.id)
# and this variable can't be lazy
self.result[node.target.id] = LazynessAnalysis.INF
elif isinstance(node.target, ast.Subscript) or isattr(node.target):
var_name = get_variable(node.target)
# variable is modified so other variables that use it dies
self.modify(var_name.id)
# and this variable can't be lazy
self.result[var_name.id] = LazynessAnalysis.INF
else:
raise PythranSyntaxError("AugAssign to unknown node", node)
def visit_For(self, node):
md.visit(self, node)
ids = self.gather(Identifiers, node.iter)
if isinstance(node.target, ast.Name):
self.assign_to(node.target, ids)
self.result[node.target.id] = LazynessAnalysis.INF
else:
err = "Assignation in for loop not to a Name"
raise PythranSyntaxError(err, node)
self.visit_loop(node.body)
for stmt in node.orelse:
self.visit(stmt)
def visit_Assign(self, node):
self.expr_parent = node
self.result[node] = self.locals.copy()
md.visit(self, node)
self.visit(node.value)
self.locals.update(t.id for t in node.targets
if isinstance(t, ast.Name))
for target in node.targets:
self.visit(target)