1.1 --- a/docs/syspython.txt Fri Jul 05 17:16:07 2013 +0200
1.2 +++ b/docs/syspython.txt Fri Jul 05 18:03:54 2013 +0200
1.3 @@ -35,6 +35,11 @@
1.4
1.5 constants(...)
1.6
1.7 +Each module may feature keyword arguments, and a list of such names is
1.8 +provided as follows:
1.9 +
1.10 + keywords(...)
1.11 +
1.12 Explicit structure declaration is still performed using class statements,
1.13 but base classes are omitted and attributes are declared explicitly as
1.14 follows:
1.15 @@ -183,11 +188,12 @@
1.16 In general, attribute access must use an explicit function indicating the
1.17 kind of access operation being performed. For example:
1.18
1.19 - # context effect
1.20 - # --------------
1.21 + # context effect
1.22 +
1.23 loadattr(obj, attrname) # preserve context
1.24 loadattrcontext(parent, attrname, obj) # replace context with obj
1.25 loadattrcontextcond(parent, attrname, obj) # run-time context decision
1.26 +
1.27 loadattrindex(obj, attrname) # preserve context
1.28 loadattrindexcontextcond(obj, attrname) # run-time context decision
1.29
1.30 @@ -195,6 +201,10 @@
1.31 storeattrcontext(parent, attrname, value, obj) # replace context with obj
1.32 storeattrindex(obj, attrname, value)
1.33
1.34 +Recall that for loadattrindex family functions, the location of the attribute
1.35 +is obtained from the object table and the nature of the attribute is
1.36 +determined from the stored context value.
1.37 +
1.38 Temporary variables could employ similar functions:
1.39
1.40 loadtemp(0)
2.1 --- a/micropython/syspython.py Fri Jul 05 17:16:07 2013 +0200
2.2 +++ b/micropython/syspython.py Fri Jul 05 18:03:54 2013 +0200
2.3 @@ -91,6 +91,15 @@
2.4
2.5 definitions = self.process_definitions(node)
2.6
2.7 + # keywords(name, ...)
2.8 +
2.9 + keywords = module.keyword_names and [
2.10 + compiler.ast.CallFunc(
2.11 + special_name("keywords"),
2.12 + [special_name(name) for name in module.keyword_names]
2.13 + )
2.14 + ] or []
2.15 +
2.16 # globalnames(name, ...)
2.17
2.18 globalnames = module.module_attribute_names() and [
2.19 @@ -113,7 +122,7 @@
2.20 self.in_main = False
2.21 self.units.pop()
2.22
2.23 - return compiler.ast.Module(node.doc, compiler.ast.Stmt(definitions + [main]))
2.24 + return compiler.ast.Module(node.doc, compiler.ast.Stmt(keywords + definitions + [main]))
2.25
2.26 # Statements.
2.27
2.28 @@ -1026,7 +1035,11 @@
2.29 )
2.30
2.31 def visitSliceobj(self, node):
2.32 - return compiler.ast.Sliceobj([self.dispatch(n) for n in node.nodes])
2.33 + return compiler.ast.CallFunc(
2.34 + special_name("apply"),
2.35 + [module_attribute("__builtins__", "slice")]
2.36 + + [self.dispatch(n) for n in node.nodes]
2.37 + )
2.38
2.39 def visitSub(self, node):
2.40 return self._visitBinary(node)