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.Set_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)
def parse(cls, node: Iir) -> "Position": """Return the source code position of a IIR node.""" if node == nodes.Null_Iir: raise ValueError( "Position.parse(): Parameter 'node' must not be 'Null_iir'.") location = nodes.Get_Location(node) file = files_map.Location_To_File(location) fileNameId = files_map.Get_File_Name(file) fileName = name_table.Get_Name_Ptr(fileNameId) line = files_map.Location_File_To_Line(location, file) column = files_map.Location_File_Line_To_Offset(location, file, line) return cls(Path(fileName), line, column)
def location_to_position(fe, loc): assert loc != files_map.No_Location line = files_map.Location_File_To_Line(loc, fe) off = files_map.Location_File_Line_To_Offset(loc, fe, line) return {"line": line - 1, "character": off}