# HG changeset patch # User Paul Boddie # Date 1259439505 -3600 # Node ID 8bf88acd0963c8eac40217fde539526c8265da1e # Parent 4eda9d4892b0fbfe1aaf7ea1412d524e4d638f38 Added a test of attribute access optimisation relevance where non-class, non-instance targets are involved. diff -r 4eda9d4892b0 -r 8bf88acd0963 micropython/trans.py --- a/micropython/trans.py Sat Nov 28 21:14:44 2009 +0100 +++ b/micropython/trans.py Sat Nov 28 21:18:25 2009 +0100 @@ -506,20 +506,24 @@ try: attr = self.objtable.access(target_name, attrname) + + # Disallow non-class/instance optimisations. + except TableError, exc: - raise TranslateError(self.module.full_name(), node, exc.args[0]) + print "Possible optimisation for", target_name, "not permissable." # Produce a suitable instruction. - if AddressContextCondInstruction is not None and attr.is_static_attribute(): - self.new_op(AddressContextCondInstruction(attr)) - elif AttrInstruction is not None and not attr.is_static_attribute(): - self.new_op(AttrInstruction(attr)) else: - raise TranslateError(self.module.full_name(), node, - "Storing of class or module attribute %r via an object is not permitted." % attrname) + if AddressContextCondInstruction is not None and attr.is_static_attribute(): + self.new_op(AddressContextCondInstruction(attr)) + elif AttrInstruction is not None and not attr.is_static_attribute(): + self.new_op(AttrInstruction(attr)) + else: + raise TranslateError(self.module.full_name(), node, + "Storing of class or module attribute %r via an object is not permitted." % attrname) - return + return # Otherwise, perform a normal operation.