def build_representation(self):
    """
      Builds the internal representation of declarations and how they relate to
      each other. It works by creating a map of type/method declaration indices,
      and then associate the bytecode for each of them.

      When all declarations are created, the parenting process runs and creates
      the tree structure of the decalrations, such as::

         ModuleDeclaration()
           - TypeDeclaration(name='SomeClass')
              - MethodDeclaration#lineno(name='methodOfSomeClass')
              - MethodDeclaration#lineno(name='otherMethodOfSomeClass')

      This representation is required to run the visitors.
    """
    if not self.bytecode:
      return

    decl_counter = 0
    self.all_decls = set()
    decl_map = {}

    # logger.debug("Bytecode:\n%s", show_bytecode(self.bytecode))

    class_decl_indices, method_decl_indices = BytecodeObject.find_classes_methods(self.bytecode)
    interest_indices = class_decl_indices.union(method_decl_indices)

    current_co = self.bytecode[0][5]
    self.main_module = ModuleDeclaration(self.pyc_file, current_co)
    self.main_module.bytecode = self.bytecode
    self.main_module.bytecode_object = self

    module_lines = (1, max([self.bytecode[i][1] for i in xrange(len(self.bytecode))]), decl_counter)
    self.main_module.lines = module_lines
    BytecodeObject.parse_imports(self.main_module, self.bytecode)
    decl_map[module_lines] = self.main_module
    decl_counter += 1

    self.all_decls.add(self.main_module)

    for tpl_indices in interest_indices:
      decl = None
      start_index, end_index = tpl_indices
      index, lineno, op, arg, _, co = self.bytecode[start_index]
      end_lineno = max([self.bytecode[i][1] for i in xrange(start_index, min(end_index + 1, len(self.bytecode)))])
      decl_co = BytecodeObject.next_code_object(self.bytecode, start_index)

      lines_tuple = (lineno, end_lineno, decl_counter)

      i = start_index
      if class_decl_indices in tpl_indices:
        # Class specific information
        decl = TypeDeclaration(decl_co.co_name, decl_co)
      else:
        # Method specific information
        decl = MethodDeclaration(decl_co.co_name, decl_co)
        decl.formal_params = BytecodeObject.get_formal_params(decl_co)

      decl.bytecode = self.bytecode[start_index:end_index]
      decl.lines = lines_tuple[:2]

      self.all_decls.add(decl)
      decl_map[lines_tuple] = decl
      decl_counter += 1


    co_deps_graph = {
      self.main_module.code_object : {}
    }

    i, length = 0, len(self.bytecode)
    while i < length:
      op, arg, co = self.bytecode[i][2], self.bytecode[i][3], self.bytecode[i][5]
      if op == LOAD_CONST and isinstance(arg, types.CodeType):
        if co not in co_deps_graph:
          co_deps_graph[co] = dict()
        if arg not in co_deps_graph[co]:
          co_deps_graph[co][arg] = dict()

          decl_parent = self.get_decl(code_object=co)
          decl_child = self.get_decl(code_object=arg)
          decl_child.parent = decl_parent
      i += 1

    logger.debug('\n' + BytecodeObject.build_tree(self.main_module))
dataset/ETHPy150Open neuroo/equip/equip/bytecode/code.py/BytecodeObject.build_representation/swapped operands of `in`