1.1 --- a/micropython/rsvp.py Mon May 19 00:22:00 2008 +0200
1.2 +++ b/micropython/rsvp.py Sat Jun 07 21:55:24 2008 +0200
1.3 @@ -31,6 +31,12 @@
1.4 new_code.append(item)
1.5 return new_code
1.6
1.7 +def name(attr):
1.8 + if isinstance(attr, Attr):
1.9 + return attr.name
1.10 + else:
1.11 + return attr
1.12 +
1.13 class Instruction:
1.14
1.15 "A generic instruction."
1.16 @@ -63,7 +69,11 @@
1.17 "An instruction accessing an object's attribute."
1.18
1.19 def __repr__(self):
1.20 - return "%s(%r)" % (self.__class__.__name__, self.get_operand())
1.21 + position = self.get_operand()
1.22 + if position is not None:
1.23 + return "%s(%r) # %s" % (self.__class__.__name__, position, name(self.attr))
1.24 + else:
1.25 + return "%s(%r)" % (self.__class__.__name__, name(self.attr))
1.26
1.27 def get_operand(self):
1.28 return self.attr.position
1.29 @@ -77,9 +87,11 @@
1.30 def __repr__(self):
1.31 location, position, result = self.get_operands()
1.32 if location is not None:
1.33 - return "%s(%r, %r -> %r)" % (self.__class__.__name__, location, position, result)
1.34 + return "%s(%r) # %r, %r (%s)" % (self.__class__.__name__, result, location, position, name(self.attr))
1.35 + elif result is not None:
1.36 + return "%s(%r) # %s" % (self.__class__.__name__, result, name(self.attr))
1.37 else:
1.38 - return "%s(%r)" % (self.__class__.__name__, result)
1.39 + return "%s(...) # %s" % (self.__class__.__name__, name(self.attr))
1.40
1.41 def get_operands(self):
1.42 if isinstance(self.attr, Attr):