# HG changeset patch # User Paul Boddie # Date 1209169904 -7200 # Node ID 4b3cde1edd1994ad1e761fb9844ca338c5eaef4e # Parent 5a13e435dd0ed25c5b148b7d96a10d347a65a721 Make the last operation None if no operations have yet been generated. Made previous ImmediateInstruction subclasses employ AddressInstruction instead. Introduced ImmediateInstruction for *Index classes. Fixed exception handling for keyword arguments. diff -r 5a13e435dd0e -r 4b3cde1edd19 micropython/ast.py --- a/micropython/ast.py Mon Apr 21 00:35:18 2008 +0200 +++ b/micropython/ast.py Sat Apr 26 02:31:44 2008 +0200 @@ -194,7 +194,10 @@ "Return the last added instruction." - return self.code[-1] + try: + return self.code[-1] + except IndexError: + return None # Internal helper methods. @@ -340,7 +343,7 @@ # Add space for arguments appearing before this one. if frame_pos < pos: - self.new_op(ReserveFrame(pos - frame_pos) + self.new_op(ReserveFrame(pos - frame_pos)) # Generate code for the keyword and the positioning # operation. @@ -367,7 +370,7 @@ # Where no position is found, this could be an extra keyword # argument. - except ValueError: + except self.paramtable.TableError: extra_keywords.append(arg) continue diff -r 5a13e435dd0e -r 4b3cde1edd19 micropython/rsvp.py --- a/micropython/rsvp.py Mon Apr 21 00:35:18 2008 +0200 +++ b/micropython/rsvp.py Sat Apr 26 02:31:44 2008 +0200 @@ -67,18 +67,27 @@ AR = AddressRelativeInstruction -class ImmediateInstruction(Instruction): +class AddressInstruction(Instruction): "An instruction loading an address directly." def __repr__(self): return "%s(%r)" % (self.__class__.__name__, self.attr.location) +Address = AddressInstruction + +class ImmediateInstruction(Instruction): + + "An instruction employing a constant." + + def __repr__(self): + return "%s(%r)" % (self.__class__.__name__, self.attr) + Immediate = ImmediateInstruction # Instructions operating on the value stack. -class LoadConst(Immediate): "Load the constant from the specified location." +class LoadConst(Address): "Load the constant from the specified location." class Duplicate(Instruction): "Duplicate the top of stack." class Pop(Instruction): "Pop the top of stack."