def set_supertypes(type_list): typename_to_type = {} child_types = [] for type in type_list: type.supertype_names = [] typename_to_type[type.name] = type if type.basetype_name: child_types.append((type.name, type.basetype_name)) for (desc_name, anc_name) in graph.transitive_closure(child_types): typename_to_type[desc_name].supertype_names.append(anc_name)
def set_supertypes(type_list): # TODO: This is a two-stage construction, which is perhaps # not a great idea. Might need more thought in the future. type_name_to_type = {} child_types = [] for type in type_list: type.supertype_names = [] type_name_to_type[type.name] = type if type.basetype_name: child_types.append((type.name, type.basetype_name)) for (desc_name, anc_name) in graph.transitive_closure(child_types): type_name_to_type[desc_name].supertype_names.append(anc_name)