1.1 --- a/micropython/ast.py Sat Jun 12 23:09:30 2010 +0200
1.2 +++ b/micropython/ast.py Sun Jun 13 02:24:35 2010 +0200
1.3 @@ -429,7 +429,25 @@
1.4 else:
1.5 self._visitName(node, self.name_load_instructions)
1.6
1.7 - def visitSlice(self, node): raise TranslationNotImplementedError("Slice")
1.8 + def visitSlice(self, node):
1.9 + if node.lower is None:
1.10 + if node.upper is None:
1.11 + args = []
1.12 + else:
1.13 + args = [compiler.ast.Name("None"), node.upper]
1.14 + else:
1.15 + args = [node.lower]
1.16 +
1.17 + # NOTE: Need to guarantee reliable access to the slice built-in.
1.18 +
1.19 + slice = compiler.ast.CallFunc(compiler.ast.Name("slice"), args)
1.20 +
1.21 + self.dispatch(node.expr)
1.22 + self._startCallFunc()
1.23 + self._generateAttr(node, "__getitem__", self.attribute_load_instructions)
1.24 + temp_target, target, temp_context = self._generateCallFunc([slice], node)
1.25 + self._doCallFunc(temp_target, target)
1.26 + self._endCallFunc(temp_target, target, temp_context)
1.27
1.28 def visitSubscript(self, node):
1.29 self.dispatch(node.expr)