# HG changeset patch # User Paul Boddie # Date 1373223961 -7200 # Node ID ed96a883b4b14a127795c87eaffc163c2253811f # Parent 0402f18ff296dbfd8fa3627b5b6bdc37ab7adabb Simplified the selection of special functions used in generated syspython code. Added some notes about low-level syspython special functions. Added a reminder to the assignment documentation. diff -r 0402f18ff296 -r ed96a883b4b1 docs/assignment.txt --- a/docs/assignment.txt Fri Jul 05 23:13:22 2013 +0200 +++ b/docs/assignment.txt Sun Jul 07 21:06:01 2013 +0200 @@ -43,6 +43,9 @@ unless attribute usage observations are employed to detect possible attribute assignments + Remember that once a function is assigned to a class, it will have that class + as context (as an unbound method) + Access types: Access to stored value from... Effect on context Optimised instruction Unoptimised instruction diff -r 0402f18ff296 -r ed96a883b4b1 docs/syspython.txt --- a/docs/syspython.txt Fri Jul 05 23:13:22 2013 +0200 +++ b/docs/syspython.txt Sun Jul 07 21:06:01 2013 +0200 @@ -23,6 +23,27 @@ or method. Note that the apply function resembles the Python function of the same name but is not actually that particular function. +Low-Level Code +-------------- + +Most Python-level program code should be wrapped in special function +invocations, and as a result other syntax features might be used to express +low-level concepts. Low-level operations may also be expressed using other +special functions. For example: + + storelocal(element, loadobjtable(loadattr(obj, classcode), attrcode)) + +Here, element holds the raw data provided by the table access involving a base +defined by the classcode of an object and an offset defined by the supplied +attrcode. + +Note that all low-level functions deal only with addresses and offsets, not +symbols. In the above example, loadattr combines the address of obj with the +symbol classcode whose actual value must be substituted by the compiler. +However, the loadobjtable function requires a genuine offset value for the +classcode (which is why loadattr is being used to obtain it), and a genuine +offset for the attrcode (which is provided directly). + Program Data and Data Structure Definition ------------------------------------------ diff -r 0402f18ff296 -r ed96a883b4b1 micropython/syspython.py --- a/micropython/syspython.py Fri Jul 05 23:13:22 2013 +0200 +++ b/micropython/syspython.py Sun Jul 07 21:06:01 2013 +0200 @@ -52,10 +52,10 @@ # Some of the assignment operations cannot be supported unless attribute usage # observations are being made. -assattr_functions = ("storeaddress", "storeaddresscontext", "storeaddresscontext", - "storeattr", "storeattrindex", None) -getattr_functions = ("loadaddress", "loadaddresscontext", "loadaddresscontextcond", - "loadattr", "loadattrindex", "loadattrindexcontextcond") +assattr_functions = ("storeattrcontext", "storeattrcontext", + "storeattr", "storeattrindexcontextcond") +getattr_functions = ("loadattrcontext", "loadattrcontextcond", + "loadattr", "loadattrindexcontextcond") # Source code classes. @@ -518,8 +518,8 @@ # Choose the appropriate special functions. - (opaddress, opaddresscontext, opaddresscontextcond, - opattr, opattrindex, opattrindexcontextcond) = expr and assattr_functions or getattr_functions + (opattrcontext, opattrcontextcond, opattr, opattrindexcontextcond) = \ + expr and assattr_functions or getattr_functions accessor = self.dispatch(node.expr) @@ -536,11 +536,11 @@ if node._access_type == "static": if node._set_context == "set": - op = opaddresscontext + op = opattrcontext elif node._set_context == "cond": - op = opaddresscontextcond + op = opattrcontextcond else: - op = opaddress + op = opattr parent = self._generateValue(node._attr_deduced.parent)