def visit_AugAssign(self, node): """ AugAssigned value depend on r-value type dependencies. It is valid for subscript, `a[i] += foo()` means `a` type depend on `foo` return type and previous a types too. """ args = (self.naming[get_variable(node.target).id], self.visit(node.value)) merge_dep = list({frozenset.union(*x) for x in itertools.product(*args)}) self.naming[get_variable(node.target).id] = merge_dep
def visit_Assign(self, node): """ In case of assignment assign value depend on r-value type dependencies. It is valid for subscript, `a[i] = foo()` means `a` type depend on `foo` return type. """ value_deps = self.visit(node.value) for target in node.targets: self.naming[get_variable(target).id] = value_deps
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_Assign(self, node): md.visit(self, node) self.visit(node.value) ids = self.passmanager.gather(Identifiers, node.value, self.ctx) for target in node.targets: if isinstance(target, ast.Name): self.assign_to(target, ids, node.value) if node.value not in self.pure_expressions: self.result[target.id] = LazynessAnalysis.INF elif isinstance(target, ast.Subscript): # 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, node.value) # and this variable can't be lazy self.result[var_name.id] = LazynessAnalysis.INF else: raise PythranSyntaxError("Assign to unknown node", node)