1.1 --- a/simplified.py Sat Oct 21 02:54:39 2006 +0200
1.2 +++ b/simplified.py Sat Oct 21 02:56:25 2006 +0200
1.3 @@ -335,13 +335,12 @@
1.4 def full_name(self):
1.5 return self._full_name
1.6
1.7 -class Module(Node, WithName):
1.8 +class Module(Node):
1.9
1.10 "A Python module."
1.11
1.12 - def __init__(self, *args, **kw):
1.13 - Node.__init__(self, *args, **kw)
1.14 - WithName.__init__(self)
1.15 + def full_name(self):
1.16 + return self.name
1.17
1.18 class Subprogram(Node, WithName):
1.19
1.20 @@ -362,17 +361,27 @@
1.21 def __init__(self, *args, **kw):
1.22 Structure.__init__(self, *args, **kw)
1.23 WithName.__init__(self)
1.24 + self.instances = []
1.25
1.26 class Instance(Structure):
1.27
1.28 "An instance."
1.29
1.30 def full_name(self):
1.31 + # NOTE: Wrap the result in a call to name(self, ...) where multiple
1.32 + # NOTE: instances per class can occur.
1.33 return self.namespace.load("__class__")[0].type.full_name()
1.34
1.35 def __repr__(self):
1.36 return "Instance of type '%s'" % self.full_name()
1.37
1.38 + def __eq__(self, other):
1.39 + # NOTE: Assuming that multiple instances of the same class are equal.
1.40 + return self.full_name() == other.full_name()
1.41 +
1.42 + def __hash__(self):
1.43 + return id(self)
1.44 +
1.45 class Constant(Instance):
1.46
1.47 "A constant initialised with a type name for future processing."