[pypy-svn] r61746 - in pypy/trunk/pypy/interpreter: astcompiler test

arigo at codespeak.net arigo at codespeak.net
Wed Feb 11 19:04:25 CET 2009


Author: arigo
Date: Wed Feb 11 19:04:24 2009
New Revision: 61746

Modified:
   pypy/trunk/pypy/interpreter/astcompiler/pyassem.py
   pypy/trunk/pypy/interpreter/test/test_compiler.py
Log:
(getxsick, arigo)
Fix the handling of self.deadcode in pyassem.
Fixes a failing test showing nonsense in dead parts of bytecodes.


Modified: pypy/trunk/pypy/interpreter/astcompiler/pyassem.py
==============================================================================
--- pypy/trunk/pypy/interpreter/astcompiler/pyassem.py	(original)
+++ pypy/trunk/pypy/interpreter/astcompiler/pyassem.py	Wed Feb 11 19:04:24 2009
@@ -84,9 +84,10 @@
 
     def emitop_extended_arg(self, intval):
         assert intval <= 0x7FFFFFFF
-        self.emit('EXTENDED_ARG')
-        self.co_code.append(chr((intval >> 16) & 0xFF))
-        self.co_code.append(chr((intval >> 24) & 0xFF))
+        if not self.deadcode:
+            self.emit('EXTENDED_ARG')
+            self.co_code.append(chr((intval >> 16) & 0xFF))
+            self.co_code.append(chr((intval >> 24) & 0xFF))
         return intval & 0xFFFF
     emitop_extended_arg._dont_inline_ = True
 
@@ -102,11 +103,12 @@
         if opname == "SET_LINENO":
             self.emitop_setlineno(intval)
             return
-        if intval > 0xFFFF:
-            intval = self.emitop_extended_arg(intval)
-        self.emit(opname)
-        self.co_code.append(chr(intval & 0xFF))
-        self.co_code.append(chr(intval >> 8))
+        if not self.deadcode:
+            if intval > 0xFFFF:
+                intval = self.emitop_extended_arg(intval)
+            self.emit(opname)
+            self.co_code.append(chr(intval & 0xFF))
+            self.co_code.append(chr(intval >> 8))
 
     # ____________________________________________________________
     # Instructions with an object argument (LOAD_CONST)

Modified: pypy/trunk/pypy/interpreter/test/test_compiler.py
==============================================================================
--- pypy/trunk/pypy/interpreter/test/test_compiler.py	(original)
+++ pypy/trunk/pypy/interpreter/test/test_compiler.py	Wed Feb 11 19:04:24 2009
@@ -820,7 +820,6 @@
         assert '(1000)' in asm
 
     def test_dis_stopcode(self):
-        skip("not fixed yet")
         source = """def _f(a):
                 print a
                 return 1



More information about the Pypy-commit mailing list