[pypy-svn] r7232 - in pypy/trunk/src/pypy/interpreter: . test

hpk at codespeak.net hpk at codespeak.net
Mon Nov 15 11:32:18 CET 2004


Author: hpk
Date: Mon Nov 15 11:32:18 2004
New Revision: 7232

Modified:
   pypy/trunk/src/pypy/interpreter/pycode.py
   pypy/trunk/src/pypy/interpreter/test/test_code.py
Log:
add a 'keys()' method to enhanceclass in order
to list all possible arguments for enhanceclass 
(for the translator to substitute the too-dynamic
enhanceclass with a static dict lookup) 



Modified: pypy/trunk/src/pypy/interpreter/pycode.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/pycode.py	(original)
+++ pypy/trunk/src/pypy/interpreter/pycode.py	Mon Nov 15 11:32:18 2004
@@ -130,7 +130,6 @@
             code.co_cellvars = space.unwrap(w_cellvars)
         return space.wrap(code)
 
-
 def enhanceclass(baseclass, newclass, cache={}):
     # this is a bit too dynamic for RPython, but it looks nice
     # and I assume that we can easily change it into a static
@@ -145,3 +144,16 @@
                 pass
             cache[baseclass, newclass] = Mixed
             return Mixed
+
+def keys():
+    from pypy.interpreter.pyopcode import PyInterpFrame as Frame
+    from pypy.interpreter.nestedscope import PyNestedScopeFrame
+    from pypy.interpreter.generator import GeneratorFrame 
+
+    return [
+         (Frame, PyNestedScopeFrame), 
+         (Frame, GeneratorFrame), 
+         (enhanceclass(Frame, PyNestedScopeFrame), GeneratorFrame), 
+        ]
+
+enhanceclass.keys = keys 

Modified: pypy/trunk/src/pypy/interpreter/test/test_code.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/test/test_code.py	(original)
+++ pypy/trunk/src/pypy/interpreter/test/test_code.py	Mon Nov 15 11:32:18 2004
@@ -92,5 +92,15 @@
         exec co in d
         self.assertEquals(d['c'], 3)
 
+class TestCodeEnhanceClass(testit.IntTestCase):
+    def test_enhanceclass_for_translator(self):
+        from pypy.interpreter.pycode import enhanceclass
+        assert hasattr(enhanceclass, 'keys')
+        arglist = enhanceclass.keys() 
+        for args in arglist: 
+            enhanceclass(*args)
+        
+        
+
 if __name__ == '__main__':
     testit.main()



More information about the Pypy-commit mailing list