def visit_AugAssign(self, node): """ Update range value for augassigned variables. >>> import ast >>> from pythran import passmanager, backend >>> node = ast.parse("def foo(): a = 2; a -= 1") >>> pm = passmanager.PassManager("test") >>> res = pm.gather(RangeValues, node) >>> res['a'] Range(low=1, high=2) """ if isinstance(node.target, ast.Name): self.result[node.target.id].update(combine(self.result[node.target.id], self.visit(node.value), node.op))
def visit_AugAssign(self, node): """ Update range value for augassigned variables. >>> import ast >>> from pythran import passmanager, backend >>> node = ast.parse("def foo(): a = 2; a -= 1") >>> pm = passmanager.PassManager("test") >>> res = pm.gather(RangeValues, node) >>> res['a'] Range(low=1, high=2) """ if isinstance(node.target, ast.Name): self.result[node.target.id].update( combine(self.result[node.target.id], self.visit(node.value), node.op))
def visit_BinOp(self, node): """ Combine operands ranges for given operator. >>> import ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = 2 ... c = 3 ... d = a - c''') >>> pm = passmanager.PassManager("test") >>> res = pm.gather(RangeValues, node) >>> res['d'] Range(low=-1, high=-1) """ return combine(self.visit(node.left), self.visit(node.right), node.op)