1.1 --- a/micropython/syspython.py Fri Oct 25 00:59:37 2013 +0200
1.2 +++ b/micropython/syspython.py Fri Oct 25 01:02:10 2013 +0200
1.3 @@ -53,9 +53,11 @@
1.4 # observations are being made.
1.5
1.6 assattr_functions = ("storeattrcontext", "storeattrcontext",
1.7 - "storeattr", "storeattrindexcontextcond")
1.8 + "storeattr", "storeattrindexcontextcond",
1.9 + None)
1.10 getattr_functions = ("loadattrcontext", "loadattrcontextcond",
1.11 - "loadattr", "loadattrindexcontextcond")
1.12 + "loadattr", "loadattrindexcontextcond",
1.13 + "loadconstant")
1.14
1.15 # Source code classes.
1.16
1.17 @@ -518,7 +520,7 @@
1.18
1.19 # Choose the appropriate special functions.
1.20
1.21 - (opattrcontext, opattrcontextcond, opattr, opattrindexcontextcond) = \
1.22 + (opattrcontext, opattrcontextcond, opattr, opattrindexcontextcond, opconstant) = \
1.23 expr and assattr_functions or getattr_functions
1.24
1.25 accessor = self.dispatch(node.expr)
1.26 @@ -526,7 +528,15 @@
1.27 # Generate already-deduced accesses.
1.28
1.29 if node._access_type == "constant":
1.30 - return self._generateValue(node._value_deduced)
1.31 + value = self._generateValue(node._value_deduced)
1.32 +
1.33 + # Where constant attributes are accessed via instances, a special
1.34 + # operation setting the context is needed.
1.35 +
1.36 + if node._set_context == "set":
1.37 + return compiler.ast.CallFunc(special_name(opconstant), accessor)
1.38 + else:
1.39 + return value
1.40
1.41 # Generate accesses via static objects and instances.
1.42