[Python-checkins] CVS: /python/nondist/src/Compiler pyassem.py,1.4,1.5

Jeremy Hylton jhylton@cnri.reston.va.us
Thu, 17 Feb 2000 17:58:56 -0500


Update of /projects/cvsroot//python/nondist/src/Compiler
In directory goon.cnri.reston.va.us:/home/jhylton/python/nondist/src/Compiler

Modified Files:
	pyassem.py 
Log Message:
changes to _lookupName
- removed now (happily) unused second arg
- need to verify results of [].index are correct; for building consts,
  need to have same value and same type, e.g. 2 not the same as 2L




Index: pyassem.py
===================================================================
RCS file: /projects/cvsroot//python/nondist/src/Compiler/pyassem.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** pyassem.py	2000/02/17 22:09:35	1.4
--- pyassem.py	2000/02/17 22:58:54	1.5
***************
*** 64,68 ****
          # used by makeCodeObject
          self._getArgCount(args)
-         print name, args, self.argcount
          self.code = ''
          self.consts = [docstring]
--- 64,67 ----
***************
*** 261,278 ****
      globalOps = ('LOAD_GLOBAL', 'STORE_GLOBAL', 'DELETE_GLOBAL')
  
!     def _lookupName(self, name, list, list2=None):
!         """Return index of name in list, appending if necessary
! 
!         Yicky hack: Second list can be used for lookup of local names
!         where the name needs to be added to varnames and names.
!         """
          if name in list:
!             return list.index(name)
!         else:
!             end = len(list)
!             list.append(name)
!             if list2 is not None:
!                 list2.append(name)
!             return end
  
      # Convert some stuff from the dis module for local use
--- 260,277 ----
      globalOps = ('LOAD_GLOBAL', 'STORE_GLOBAL', 'DELETE_GLOBAL')
  
!     def _lookupName(self, name, list):
!         """Return index of name in list, appending if necessary"""
          if name in list:
!             i = list.index(name)
!             # this is cheap, but incorrect in some cases, e.g 2 vs. 2L
!             if type(name) == type(list[i]):
!                 return i
!             for i in range(len(list)):
!                 elt = list[i]
!                 if type(elt) == type(name) and elt == name:
!                     return i
!         end = len(list)
!         list.append(name)
!         return end
  
      # Convert some stuff from the dis module for local use