1.1 --- a/simplify/viewer.py Sat Jun 16 01:57:38 2007 +0200
1.2 +++ b/simplify/viewer.py Sun Jun 17 22:05:04 2007 +0200
1.3 @@ -197,7 +197,7 @@
1.4
1.5 def _write_classes(self, module):
1.6 self.stream.write("<table cellspacing='5' cellpadding='5'>\n")
1.7 - for structure in self.structures:
1.8 + for structure in self.module.simplifier.structures:
1.9 self._write_class(structure)
1.10 self.stream.write("</table>\n")
1.11
1.12 @@ -214,7 +214,8 @@
1.13
1.14 # ...and all known attribute names.
1.15
1.16 - structure_attributes = self.structure_attributes[structure]
1.17 + structure_attributes = structure.get_instance_attribute_names()
1.18 +
1.19 for name in self.attribute_names:
1.20 if name in structure_attributes:
1.21 self.stream.write("<th class='summary-attr'>%s</th>\n" % self._text(name))
1.22 @@ -224,9 +225,12 @@
1.23
1.24 # Write instances for the class, along with type details for each attribute.
1.25
1.26 - for instance in self.structures_to_instances[structure]:
1.27 + names_to_instances, instance_names = structure.get_names_to_instances()
1.28 +
1.29 + for instance_name in instance_names:
1.30 + instance = names_to_instances[instance_name]
1.31 self.stream.write("<tr>\n")
1.32 - self.stream.write("<th class='summary-instance'>%s</th>\n" % self._text(instance.full_name()))
1.33 + self.stream.write("<th class='summary-instance'>%s</th>\n" % self._text(instance_name))
1.34 for name in self.attribute_names:
1.35 self.stream.write("<td>\n")
1.36 values = instance.namespace.get(name, [])
1.37 @@ -240,50 +244,15 @@
1.38
1.39 def _init_details(self):
1.40 names = set()
1.41 - self.structures_to_instances = {}
1.42 - self.structure_attributes = {}
1.43 - names_to_structures = {}
1.44
1.45 # Visit all structures.
1.46
1.47 for structure in self.module.simplifier.structures:
1.48 -
1.49 - # Map all instance names to instances.
1.50 -
1.51 - names_to_instances = {}
1.52 - attribute_names = set()
1.53 -
1.54 - for instance in structure.instances.values():
1.55 - for name, values in instance.namespace.items():
1.56 - if not name in attribute_names:
1.57 - attribute_names.add(name)
1.58 - if not name in names:
1.59 - names.add(name)
1.60 - names_to_instances[instance.full_name()] = instance
1.61 -
1.62 - # Record the instances in name order for the structure.
1.63 -
1.64 - instance_names = names_to_instances.keys()
1.65 - instance_names.sort()
1.66 - sorted_instances = [names_to_instances[name] for name in instance_names]
1.67 - self.structures_to_instances[structure] = sorted_instances
1.68 -
1.69 - # Record the attributes used in all instances of the structure.
1.70 -
1.71 - self.structure_attributes[structure] = attribute_names
1.72 -
1.73 - # Record the name to structure mapping.
1.74 -
1.75 - names_to_structures[structure.full_name()] = structure
1.76 + names.update(structure.get_instance_attribute_names())
1.77
1.78 self.attribute_names = list(names)
1.79 self.attribute_names.sort()
1.80
1.81 - structure_names = names_to_structures.keys()
1.82 - structure_names.sort()
1.83 -
1.84 - self.structures = [names_to_structures[name] for name in structure_names]
1.85 -
1.86 # Browser classes.
1.87
1.88 class Browser(ASTVisitor, Writer):