[pypy-svn] r56932 - pypy/branch/2.5-features/pypy/interpreter/astcompiler

bgola at codespeak.net bgola at codespeak.net
Sat Aug 2 16:55:24 CEST 2008


Author: bgola
Date: Sat Aug  2 16:55:23 2008
New Revision: 56932

Modified:
   pypy/branch/2.5-features/pypy/interpreter/astcompiler/pyassem.py
Log:
fixing the computeStackDepth method to work with new (2.5) MAKE_CLOSURE semantics

Modified: pypy/branch/2.5-features/pypy/interpreter/astcompiler/pyassem.py
==============================================================================
--- pypy/branch/2.5-features/pypy/interpreter/astcompiler/pyassem.py	(original)
+++ pypy/branch/2.5-features/pypy/interpreter/astcompiler/pyassem.py	Sat Aug  2 16:55:23 2008
@@ -311,26 +311,12 @@
             except KeyError:
                 pass
             else:
-                if opcode == pythonopcode.opmap['MAKE_CLOSURE']:
-                    # only supports "LOAD_CONST co / MAKE_CLOSURE n"
-                    if just_loaded_const is None:
-                        raise InternalCompilerError("MAKE_CLOSURE not "
-                                                    "following LOAD_CONST")
-                    codeobj = self.space.interp_w(PyCode, just_loaded_const)
-                    nfreevars = len(codeobj.co_freevars)
-                    effect = - nfreevars - oparg
-                else:
-                    effect = tracker(oparg)
+                effect = tracker(oparg)
                 curstackdepth += effect
                 if i in finally_targets:
                     curstackdepth += 2  # see pyopcode.FinallyBlock.cleanup()
                 self._setdepth(i, curstackdepth)
 
-            if opcode == pythonopcode.opmap['LOAD_CONST']:
-                just_loaded_const = consts_w[oparg]
-            else:
-                just_loaded_const = None
-
         self.stacksize = largestsize
 
     def fixLabelTargets(self):
@@ -481,8 +467,7 @@
 def depth_MAKE_FUNCTION(argc):
     return -argc
 def depth_MAKE_CLOSURE(argc):
-    raise InternalCompilerError("must special-case this in order to account"
-                                " for the free variables")
+    return -argc
 def depth_BUILD_SLICE(argc):
     if argc == 2:
         return -1



More information about the Pypy-commit mailing list