summaryrefslogtreecommitdiffstats
path: root/Lib/compiler/pycodegen.py
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-08-30 20:25:55 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-08-30 20:25:55 (GMT)
commit71ebc3359bb1a5106ba3c282746817d5d44e735b (patch)
tree545b890ab51c541d5043172fc45d4ba2a8ce7844 /Lib/compiler/pycodegen.py
parent017cb2c7d85fa4a07365a9a205aca21bc29d01a8 (diff)
downloadcpython-71ebc3359bb1a5106ba3c282746817d5d44e735b.zip
cpython-71ebc3359bb1a5106ba3c282746817d5d44e735b.tar.gz
cpython-71ebc3359bb1a5106ba3c282746817d5d44e735b.tar.bz2
Fix _convert_NAME() so that it doesn't store locals for class bodies.
Fix list comp code generation -- emit GET_ITER instead of Const(0) after the list. Add CO_GENERATOR flag to generators. Get CO_xxx flags from the new module
Diffstat (limited to 'Lib/compiler/pycodegen.py')
-rw-r--r--Lib/compiler/pycodegen.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/compiler/pycodegen.py b/Lib/compiler/pycodegen.py
index 7a089f0..4f7603d 100644
--- a/Lib/compiler/pycodegen.py
+++ b/Lib/compiler/pycodegen.py
@@ -11,8 +11,9 @@ from cStringIO import StringIO
from compiler import ast, parse, walk
from compiler import pyassem, misc, future, symbols
from compiler.consts import SC_LOCAL, SC_GLOBAL, SC_FREE, SC_CELL
-from compiler.pyassem import CO_VARARGS, CO_VARKEYWORDS, CO_NEWLOCALS,\
- CO_NESTED, TupleArg
+from compiler.consts import CO_VARARGS, CO_VARKEYWORDS, CO_NEWLOCALS,\
+ CO_NESTED, CO_GENERATOR
+from compiler.pyassem import TupleArg
# Do we have Python 1.x or Python 2.x?
try:
@@ -495,10 +496,10 @@ class CodeGenerator:
anchor = self.newBlock()
self.visit(node.list)
- self.visit(ast.Const(0))
+ self.emit('GET_ITER')
self.nextBlock(start)
self.emit('SET_LINENO', node.lineno)
- self.emit('FOR_LOOP', anchor)
+ self.emit('FOR_ITER', anchor)
self.nextBlock()
self.visit(node.assign)
return start, anchor
@@ -1199,6 +1200,8 @@ class NestedFunctionCodeGenerator(AbstractFunctionCode,
self.__super_init(func, filename, scopes, isLambda, class_name)
self.graph.setFreeVars(self.scope.get_free_vars())
self.graph.setCellVars(self.scope.get_cell_vars())
+ if self.scope.generator is not None:
+ self.graph.setFlag(CO_GENERATOR)
## self.graph.setFlag(CO_NESTED)
class AbstractClassCode: