1.1 --- a/micropython/rsvp.py Mon May 05 00:46:38 2008 +0200
1.2 +++ b/micropython/rsvp.py Sat May 10 02:32:20 2008 +0200
1.3 @@ -19,7 +19,7 @@
1.4 this program. If not, see <http://www.gnu.org/licenses/>.
1.5 """
1.6
1.7 -from micropython.inspect import Const, Instance
1.8 +from micropython.inspect import Attr, Const, Instance
1.9
1.10 class Instruction:
1.11
1.12 @@ -51,10 +51,19 @@
1.13
1.14 def __repr__(self):
1.15 position = self.attr.position
1.16 - if isinstance(self.attr.parent, Instance):
1.17 - location = "instance"
1.18 - result = position
1.19 - else:
1.20 + location = "instance"
1.21 + result = position
1.22 + return "%s(%r, %r -> %r)" % (self.__class__.__name__, location, position, result)
1.23 +
1.24 +AR = AddressRelativeInstruction
1.25 +
1.26 +class AddressInstruction(Instruction):
1.27 +
1.28 + "An instruction loading an address directly."
1.29 +
1.30 + def __repr__(self):
1.31 + if isinstance(self.attr, Attr):
1.32 + position = self.attr.position
1.33 location = self.attr.parent.location
1.34
1.35 # NOTE: Unpositioned attributes are handled here.
1.36 @@ -65,16 +74,9 @@
1.37 location = self.attr.parent.name
1.38 position = self.attr.name
1.39 result = None
1.40 - return "%s(%r, %r -> %r)" % (self.__class__.__name__, location, position, result)
1.41 -
1.42 -AR = AddressRelativeInstruction
1.43 -
1.44 -class AddressInstruction(Instruction):
1.45 -
1.46 - "An instruction loading an address directly."
1.47 -
1.48 - def __repr__(self):
1.49 - return "%s(%r)" % (self.__class__.__name__, self.attr.location)
1.50 + return "%s(%r, %r -> %r)" % (self.__class__.__name__, location, position, result)
1.51 + else:
1.52 + return "%s(%r)" % (self.__class__.__name__, self.attr.location)
1.53
1.54 Address = AddressInstruction
1.55
1.56 @@ -112,7 +114,7 @@
1.57
1.58 # Instructions operating on the value stack.
1.59
1.60 -class LoadConst(StackAdd, Address): "Load the constant from the specified location."
1.61 +class LoadConst(StackAdd, Address): "Load the constant, class, function, module from the specified location."
1.62 class Duplicate(StackAdd, Instruction): "Duplicate the top of the stack."
1.63 class Pop(StackRemove, Immediate): "Pop entries from the top of the stack."
1.64
1.65 @@ -131,8 +133,8 @@
1.66 class StoreAttr(StackRemove2, AR): "Store an object in the given attribute."
1.67 class LoadAttrIndex(Immediate): "Load the object for the attribute with the given index."
1.68 class StoreAttrIndex(StackRemove2, Immediate): "Store an object in the attribute with the given index."
1.69 -class LoadAddress(StackAdd, AR): "Load the object from the given fixed attribute address."
1.70 -class StoreAddress(StackRemove, AR): "Store an object in the given fixed attribute address."
1.71 +class LoadAddress(StackAdd, Address): "Load the object from the given fixed attribute address."
1.72 +class StoreAddress(StackRemove, Address): "Store an object in the given fixed attribute address."
1.73
1.74 # Access to invocation frames in preparation.
1.75