

def visit_Assign(self, node):

    def flatten_targets(tgt, lst):
        if isinstance(tgt, list):
            for x in tgt:
                flatten_targets(x, lst)
        elif isinstance(tgt, (ast.Tuple, ast.List)):
            for x in tgt.elts:
                flatten_targets(x, lst)
        elif isinstance(tgt, (ast.Attribute, ast.Name, ast.Subscript)):
            lst.append(tgt)
        else:
            from ..ast_helpers import print_simple_ast
            print_simple_ast(tgt)
            raise Exception('Unsupported assignment type ({kind})!\nPlease notify the PyMTL developers!\n\n {lineno} {srccode}\n File: {filename}\n Function: {funcname}\n Line: {lineno}\n'.format(attr=self.attr[0], kind=tgt.__class__, srccode=self.src[(node.lineno - 1)], filename=inspect.getfile(self.func), funcname=self.func.func_name, lineno=((self.funclineno + node.lineno) - 1)))
    targets = []
    flatten_targets(node.targets, targets)
    for lhs in targets:
        if ((not isinstance(lhs, ast.Attribute)) or (lhs.attr not in self.attr)):
            try:
                lhs = ReplaceIndexesWithZero().visit(lhs)
                lhs.ctx = ast.Load()
                _code = compile(ast.Expression(lhs), '<ast>', 'eval')
                _temp = eval(_code, self.dict_)
            except (NameError, AttributeError) as e:
                _temp = None
            except IndexError as e:
                _temp = None
            if isinstance(_temp, Signal):
                raise PyMTLError('Attempting to write a(n) {kind} without .{attr}!\n\n {lineno} {srccode}\n File: {filename}\n Function: {funcname}\n Line: {lineno}\n'.format(attr=self.attr[0], kind=_temp.__class__.__name__, srccode=self.src[(node.lineno - 1)], filename=inspect.getfile(self.func), funcname=self.func.func_name, lineno=((self.funclineno + node.lineno) - 1)))

dataset/ETHPy150Open cornell-brg/pymtl/pymtl/tools/simulation/ast_visitor.py DetectMissingValueNext.visit_Assign/original