예제 #1
0
 def compute_anti_dependences(self):
     """Return a dictionnary of anti dependencies for design unit"""
     res = {}
     lib = libraries.Get_Libraries_Chain()
     while lib != nodes.Null_Iir:
         files = nodes.Get_Design_File_Chain(lib)
         while files != nodes.Null_Iir:
             units = nodes.Get_First_Design_Unit(files)
             while units != nodes.Null_Iir:
                 if nodes.Get_Date_State(units) == nodes.Date_State.Analyze:
                     # The unit has been analyzed, so the dependencies are know.
                     deps = nodes.Get_Dependence_List(units)
                     assert deps != nodes.Null_Iir_List
                     deps_it = lists.Iterate(deps)
                     while lists.Is_Valid(byref(deps_it)):
                         el = lists.Get_Element(byref(deps_it))
                         if nodes.Get_Kind(
                                 el) == nodes.Iir_Kind.Design_Unit:
                             if res.get(el, None):
                                 res[el].append(units)
                             else:
                                 res[el] = [units]
                         else:
                             assert False
                         lists.Next(byref(deps_it))
                 units = nodes.Get_Chain(units)
             files = nodes.Get_Chain(files)
         lib = nodes.Get_Chain(lib)
     return res
예제 #2
0
 def obsolete_dependent_units(self, unit, antideps):
     """Obsolete units that depends of :param unit:"""
     udeps = antideps.get(unit, None)
     if udeps is None:
         # There are no units.
         return
     # Avoid infinite recursion
     antideps[unit] = None
     for un in udeps:
         log.debug("obsolete %d %s", un,
                   pyutils.name_image(nodes.Get_Identifier(un)))
         # Recurse
         self.obsolete_dependent_units(un, antideps)
         if nodes.Get_Date_State(un) == nodes.Date_State.Disk:
             # Already obsolete!
             continue
         # FIXME: just de-analyze ?
         nodes.Set_Date_State(un, nodes.Date_State.Disk)
         sem_lib.Free_Dependence_List(un)
         loc = nodes.Get_Location(un)
         fil = files_map.Location_To_File(loc)
         pos = files_map.Location_File_To_Pos(loc, fil)
         line = files_map.Location_File_To_Line(loc, fil)
         col = files_map.Location_File_Line_To_Offset(loc, fil, line)
         nodes.Set_Design_Unit_Source_Pos(un, pos)
         nodes.Set_Design_Unit_Source_Line(un, line)
         nodes.Set_Design_Unit_Source_Col(un, col)