summaryrefslogtreecommitdiffstats
path: root/Tools/compiler
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-08-28 16:35:18 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-08-28 16:35:18 (GMT)
commitf354575328becbdd21a92f0386db6568dcdd8d45 (patch)
tree8c90a7d87f5c1cd416391ea77c2cb716993a0664 /Tools/compiler
parent318e167e98a0f01f1093e3dbf71c6f6ded49f707 (diff)
downloadcpython-f354575328becbdd21a92f0386db6568dcdd8d45.zip
cpython-f354575328becbdd21a92f0386db6568dcdd8d45.tar.gz
cpython-f354575328becbdd21a92f0386db6568dcdd8d45.tar.bz2
Generate FOR_ITER-based loops instead of old FOR_LOOP-based loops
Diffstat (limited to 'Tools/compiler')
-rw-r--r--Tools/compiler/compiler/pycodegen.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/Tools/compiler/compiler/pycodegen.py b/Tools/compiler/compiler/pycodegen.py
index ced0f07..37dbcfd 100644
--- a/Tools/compiler/compiler/pycodegen.py
+++ b/Tools/compiler/compiler/pycodegen.py
@@ -355,11 +355,11 @@ class CodeGenerator:
self.set_lineno(node)
self.emit('SETUP_LOOP', after)
self.visit(node.list)
- self.visit(ast.Const(0))
+ self.emit('GET_ITER')
+
self.nextBlock(start)
self.set_lineno(node, force=1)
- self.emit('FOR_LOOP', anchor)
- self.nextBlock()
+ self.emit('FOR_ITER', anchor)
self.visit(node.assign)
self.visit(node.body)
self.emit('JUMP_ABSOLUTE', start)
@@ -567,7 +567,8 @@ class CodeGenerator:
self.nextBlock(next)
else:
self.nextBlock()
- self.emit('POP_TOP')
+ if expr: # XXX
+ self.emit('POP_TOP')
self.emit('END_FINALLY')
if node.else_:
self.nextBlock(lElse)
@@ -1001,7 +1002,10 @@ class NestedScopeCodeGenerator(CodeGenerator):
else:
self.emit(prefix + '_FAST', name)
elif scope == SC_GLOBAL:
- self.emit(prefix + '_GLOBAL', name)
+ if not self.optimized:
+ self.emit(prefix + '_NAME', name)
+ else:
+ self.emit(prefix + '_GLOBAL', name)
elif scope == SC_FREE or scope == SC_CELL:
self.emit(prefix + '_DEREF', name)
else: