# HG changeset patch # User paulb@localhost.localdomain # Date 1169681410 -3600 # Node ID 3a0b84b2da0bbbf1741ed0f1c4639207d904b3f6 # Parent ee619a045fa10c790dc266b68054e812fcea9583 Changed default absent original_def in instance lookup to None. Added commentary about certain behavioural issues. diff -r ee619a045fa1 -r 3a0b84b2da0b annotate.py --- a/annotate.py Thu Jan 25 00:28:56 2007 +0100 +++ b/annotate.py Thu Jan 25 00:30:10 2007 +0100 @@ -1230,6 +1230,7 @@ # NOTE: Constant not added to table. constant = Constant(name=repr(arg), value=arg, namespace=Namespace()) + #constant.namespace.store("__class__", self.get_builtin_instances(invocation, constant.typename)) code += [ StoreTemp( expr=LoadRef( diff -r ee619a045fa1 -r 3a0b84b2da0b simplified.py --- a/simplified.py Thu Jan 25 00:28:56 2007 +0100 +++ b/simplified.py Thu Jan 25 00:30:10 2007 +0100 @@ -472,13 +472,6 @@ # Program structure nodes. -class Module(Node): - - "A Python module." - - def full_name(self): - return "module %s" % self.name - class Subprogram(Node, WithName): "A subprogram: functions, methods and loops." @@ -487,9 +480,28 @@ Node.__init__(self, *args, **kw) WithName.__init__(self) +class Comparable(Node): + + "Comparable nodes implementing the 'full_name' method." + + def __eq__(self, other): + # NOTE: Single instance: all instances are the same + # NOTE: Multiple instances: all instances are different + return self.full_name() == other.full_name() + + def __hash__(self): + return id(self) + +class Module(Comparable): + + "A Python module." + + def full_name(self): + return "module %s" % self.name + # Special non-program nodes. -class Structure(Node): "A non-program node containing some kind of namespace." +class Structure(Comparable): "A non-program node containing some kind of namespace." class _Class(Structure, WithName): @@ -537,7 +549,7 @@ self.attributes_for_instances = {} def _get_key(self, node): - return getattr(node, "original_def", node) + return getattr(node, "original_def", None) # self.module.original def has_instance(self, node): return self.instances.has_key(self._get_key(node)) @@ -592,6 +604,12 @@ Instance.__init__(self, *args, **kw) self.typename = self.value.__class__.__name__ + # NOTE: Hacked full_name avoiding instantiation ordering issues: + # NOTE: initialise built-in types, initialise built-in constants. + + #def full_name(self): + # return self.typename + "-c" + class Attribute: """