1.1 --- a/micropython/ast.py Sun Jul 20 23:16:26 2008 +0200
1.2 +++ b/micropython/ast.py Mon Jul 21 00:24:00 2008 +0200
1.3 @@ -34,7 +34,9 @@
1.4 supported_optimisations = ["constant_storage", "known_target", "self_access", "temp_storage", "load_operations", "unused_results"]
1.5
1.6 attribute_load_instructions = (LoadAddress, LoadAddressContext, LoadAttr, LoadAttrIndex)
1.7 - attribute_store_instructions = (StoreAddress, None, StoreAttr, StoreAttrIndex)
1.8 + attribute_store_instructions = (None, None, StoreAttr, StoreAttrIndex)
1.9 + name_load_instructions = (LoadName, LoadAddress)
1.10 + name_store_instructions = (StoreName, StoreAddress)
1.11
1.12 def __init__(self, module, importer, optimisations=None):
1.13
1.14 @@ -568,7 +570,12 @@
1.15
1.16 # Produce a suitable instruction.
1.17
1.18 - self.replace_op(AddressInstruction(pos))
1.19 + if AddressInstruction is not None:
1.20 + self.replace_op(AddressInstruction(pos))
1.21 + else:
1.22 + raise TranslateError(self.module.full_name(), node,
1.23 + "Storing of class or module attribute %r via an object is not permitted." % attrname)
1.24 +
1.25 return
1.26
1.27 # Where the last operation involves the special 'self' name, check to
1.28 @@ -1118,7 +1125,7 @@
1.29 def visitAssList(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "AssList")
1.30
1.31 def visitAssName(self, node):
1.32 - self._visitName(node, (StoreName, StoreAddress))
1.33 + self._visitName(node, self.name_store_instructions)
1.34 self.set_source()
1.35
1.36 visitAssTuple = visitAssList
1.37 @@ -1161,7 +1168,7 @@
1.38
1.39 self.new_op(LoadConst(node.unit))
1.40 self.record_value()
1.41 - self._visitName(node, (StoreName, StoreAddress))
1.42 + self._visitName(node, self.name_store_instructions)
1.43 self.set_source()
1.44 self.discard_value()
1.45
1.46 @@ -1290,7 +1297,7 @@
1.47 self.new_op(LoadConst(node.unit))
1.48
1.49 self.record_value()
1.50 - self._visitName(node, (StoreName, StoreAddress))
1.51 + self._visitName(node, self.name_store_instructions)
1.52 self.set_source()
1.53 self.discard_value()
1.54
1.55 @@ -1380,7 +1387,7 @@
1.56 const = self.module.constant_values[None]
1.57 self.new_op(LoadConst(const))
1.58 else:
1.59 - self._visitName(node, (LoadName, LoadAddress))
1.60 + self._visitName(node, self.name_load_instructions)
1.61
1.62 def visitNot(self, node):
1.63 next_label = self.new_label()