1.1 --- a/annotate.py Thu Jan 25 00:28:56 2007 +0100
1.2 +++ b/annotate.py Thu Jan 25 00:30:10 2007 +0100
1.3 @@ -1230,6 +1230,7 @@
1.4 # NOTE: Constant not added to table.
1.5
1.6 constant = Constant(name=repr(arg), value=arg, namespace=Namespace())
1.7 + #constant.namespace.store("__class__", self.get_builtin_instances(invocation, constant.typename))
1.8 code += [
1.9 StoreTemp(
1.10 expr=LoadRef(
2.1 --- a/simplified.py Thu Jan 25 00:28:56 2007 +0100
2.2 +++ b/simplified.py Thu Jan 25 00:30:10 2007 +0100
2.3 @@ -472,13 +472,6 @@
2.4
2.5 # Program structure nodes.
2.6
2.7 -class Module(Node):
2.8 -
2.9 - "A Python module."
2.10 -
2.11 - def full_name(self):
2.12 - return "module %s" % self.name
2.13 -
2.14 class Subprogram(Node, WithName):
2.15
2.16 "A subprogram: functions, methods and loops."
2.17 @@ -487,9 +480,28 @@
2.18 Node.__init__(self, *args, **kw)
2.19 WithName.__init__(self)
2.20
2.21 +class Comparable(Node):
2.22 +
2.23 + "Comparable nodes implementing the 'full_name' method."
2.24 +
2.25 + def __eq__(self, other):
2.26 + # NOTE: Single instance: all instances are the same
2.27 + # NOTE: Multiple instances: all instances are different
2.28 + return self.full_name() == other.full_name()
2.29 +
2.30 + def __hash__(self):
2.31 + return id(self)
2.32 +
2.33 +class Module(Comparable):
2.34 +
2.35 + "A Python module."
2.36 +
2.37 + def full_name(self):
2.38 + return "module %s" % self.name
2.39 +
2.40 # Special non-program nodes.
2.41
2.42 -class Structure(Node): "A non-program node containing some kind of namespace."
2.43 +class Structure(Comparable): "A non-program node containing some kind of namespace."
2.44
2.45 class _Class(Structure, WithName):
2.46
2.47 @@ -537,7 +549,7 @@
2.48 self.attributes_for_instances = {}
2.49
2.50 def _get_key(self, node):
2.51 - return getattr(node, "original_def", node)
2.52 + return getattr(node, "original_def", None) # self.module.original
2.53
2.54 def has_instance(self, node):
2.55 return self.instances.has_key(self._get_key(node))
2.56 @@ -592,6 +604,12 @@
2.57 Instance.__init__(self, *args, **kw)
2.58 self.typename = self.value.__class__.__name__
2.59
2.60 + # NOTE: Hacked full_name avoiding instantiation ordering issues:
2.61 + # NOTE: initialise built-in types, initialise built-in constants.
2.62 +
2.63 + #def full_name(self):
2.64 + # return self.typename + "-c"
2.65 +
2.66 class Attribute:
2.67
2.68 """