[Python-checkins] CVS: python/dist/src/Tools/compiler/compiler pycodegen.py,1.42,1.43

Jeremy Hylton jhylton@users.sourceforge.net
Tue, 28 Aug 2001 09:35:20 -0700


Update of /cvsroot/python/python/dist/src/Tools/compiler/compiler
In directory usw-pr-cvs1:/tmp/cvs-serv16049

Modified Files:
	pycodegen.py 
Log Message:
Generate FOR_ITER-based loops instead of old FOR_LOOP-based loops


Index: pycodegen.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/compiler/compiler/pycodegen.py,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -d -r1.42 -r1.43
*** pycodegen.py	2001/08/27 22:56:16	1.42
--- pycodegen.py	2001/08/28 16:35:18	1.43
***************
*** 356,364 ****
          self.emit('SETUP_LOOP', after)
          self.visit(node.list)
!         self.visit(ast.Const(0))
          self.nextBlock(start)
          self.set_lineno(node, force=1)
!         self.emit('FOR_LOOP', anchor)
!         self.nextBlock()
          self.visit(node.assign)
          self.visit(node.body)
--- 356,364 ----
          self.emit('SETUP_LOOP', after)
          self.visit(node.list)
!         self.emit('GET_ITER')
! 
          self.nextBlock(start)
          self.set_lineno(node, force=1)
!         self.emit('FOR_ITER', anchor)
          self.visit(node.assign)
          self.visit(node.body)
***************
*** 568,572 ****
              else:
                  self.nextBlock()
!             self.emit('POP_TOP')
          self.emit('END_FINALLY')
          if node.else_:
--- 568,573 ----
              else:
                  self.nextBlock()
!             if expr: # XXX
!                 self.emit('POP_TOP')
          self.emit('END_FINALLY')
          if node.else_:
***************
*** 1002,1006 ****
                  self.emit(prefix + '_FAST', name)
          elif scope == SC_GLOBAL:
!             self.emit(prefix + '_GLOBAL', name)
          elif scope == SC_FREE or scope == SC_CELL:
              self.emit(prefix + '_DEREF', name)
--- 1003,1010 ----
                  self.emit(prefix + '_FAST', name)
          elif scope == SC_GLOBAL:
!             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)