1.1 --- a/micropython/basicdata.py Thu Oct 24 13:54:07 2013 +0200
1.2 +++ b/micropython/basicdata.py Thu Oct 24 16:48:23 2013 +0200
1.3 @@ -91,9 +91,31 @@
1.4 def make_instance():
1.5 return common_instance
1.6
1.7 +class TypedInstance(Instance):
1.8 +
1.9 + "A placeholder indicating the involvement of an instance of a known type."
1.10 +
1.11 + def __init__(self, cls):
1.12 + Instance.__init__(self)
1.13 + self.cls = cls
1.14 +
1.15 + def __repr__(self):
1.16 + return "<instance of %s>" % shortrepr(self.cls)
1.17 +
1.18 + def __eq__(self, other):
1.19 + return other.__class__ is TypedInstance and other.cls is self.cls
1.20 +
1.21 + def __ne__(self, other):
1.22 + return not self.__eq__(other)
1.23 +
1.24 + def __hash__(self):
1.25 + return 0
1.26 +
1.27 + __shortrepr__ = __repr__
1.28 +
1.29 # Data objects appearing in programs before run-time.
1.30
1.31 -class Const(Constant, Instance):
1.32 +class Const(Constant, TypedInstance):
1.33
1.34 "A constant object with no context."
1.35