def veval_ast_aug_assign(astc: 'AstContext', local_field: 'values.Field', graph: 'Graph'): assert (isinstance(astc.nast, gast.gast.AugAssign)) lineprop = utils.LineProperty(astc.lineno) target = veval_ast(astc.c(astc.nast.target), local_field, graph) value = veval_ast(astc.c(astc.nast.value), local_field, graph) target_value = try_get_value(target, 'aug_assign', lineprop) value_value = try_get_value(value, 'aug_assign', lineprop) binop = nodes.BinOpType.Unknown if isinstance(astc.nast.op, gast.Add): binop = nodes.BinOpType.Add if isinstance(astc.nast.op, gast.Sub): binop = nodes.BinOpType.Sub node_aug_assign = nodes.NodeAugAssign(target_value, value_value, binop, astc.lineno) graph.add_node(node_aug_assign) # TODO : estimate type new_value = functions.generate_value_with_same_type(target_value) node_aug_assign.set_outputs([new_value]) target.get_ref().revise(new_value)
def veval_ast_aug_assign(astc : 'AstContext', local_field : 'values.Field', graph : 'Graph'): assert(isinstance(astc.nast, gast.gast.AugAssign)) target = veval_ast(astc.c(astc.nast.target), local_field, graph) value = veval_ast(astc.c(astc.nast.value), local_field, graph) binop = nodes.BinOpType.Unknown if isinstance(astc.nast.op, gast.Add): binop = nodes.BinOpType.Add if isinstance(astc.nast.op, gast.Sub): binop = nodes.BinOpType.Sub target_value = target.get_value() if isinstance(target_value, values.NumberValue): node_aug_assign = nodes.NodeValueAugAssign(target_value, value.get_value(), binop, astc.lineno) new_value = functions.generate_value_with_same_type(target_value) target.revise(new_value) node_aug_assign.set_outputs([new_value]) graph.add_node(node_aug_assign) return values.NoneValue() else: node_aug_assign = nodes.NodeAugAssign(target_value, value.get_value(), binop, astc.lineno) target_value.modify(node_aug_assign, None) graph.add_node(node_aug_assign) return values.NoneValue()