[pypy-svn] r48012 - pypy/dist/pypy/lang/smalltalk

cfbolz at codespeak.net cfbolz at codespeak.net
Fri Oct 26 01:00:08 CEST 2007


Author: cfbolz
Date: Fri Oct 26 01:00:07 2007
New Revision: 48012

Modified:
   pypy/dist/pypy/lang/smalltalk/primitives.py
Log:
small heuristic to assign nicer names to functions to make it easier to debug


Modified: pypy/dist/pypy/lang/smalltalk/primitives.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/primitives.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/primitives.py	Fri Oct 26 01:00:07 2007
@@ -50,8 +50,19 @@
 def expose_primitive(code, unwrap_spec=None):
     # some serious magic, don't look
     from pypy.rlib.unroll import unrolling_iterable
+    # heuristics to give it a nice name
+    name = None
+    for key, value in globals().iteritems():
+        if isinstance(value, int) and value == code and key == key.upper():
+            if name is not None:
+                # refusing to guess
+                name = "unknown"
+            else:
+                name = key
+
     def decorator(func):
         assert code not in prim_table
+        func.func_name = "prim_" + name
         if unwrap_spec is None:
             prim_table[code] = func
             return func
@@ -82,7 +93,7 @@
             frame.pop_n(len_unwrap_spec)   # only if no exception occurs!
             return res
 
-        wrapped.func_name = func.func_name
+        wrapped.func_name = "wrap_prim_" + name
         prim_table[code] = wrapped
         return func
     return decorator



More information about the Pypy-commit mailing list