[pypy-svn] r50061 - pypy/branch/llvmgcroot/pypy/translator/llvm

arigo at codespeak.net arigo at codespeak.net
Mon Dec 24 16:46:34 CET 2007


Author: arigo
Date: Mon Dec 24 16:46:33 2007
New Revision: 50061

Modified:
   pypy/branch/llvmgcroot/pypy/translator/llvm/node.py
Log:
Use the NameManager to build names that are valid C identifiers.
Helps a lot for debugging with gdb...


Modified: pypy/branch/llvmgcroot/pypy/translator/llvm/node.py
==============================================================================
--- pypy/branch/llvmgcroot/pypy/translator/llvm/node.py	(original)
+++ pypy/branch/llvmgcroot/pypy/translator/llvm/node.py	Mon Dec 24 16:46:33 2007
@@ -1,29 +1,16 @@
 from pypy.rpython.lltypesystem import lltype
+from pypy.translator.gensupp import NameManager
+
+NODE_NAMES = NameManager()
 
 
 class Node(object):
     __slots__ = "name".split()
     prefix = '%'
 
-    nodename_count = {}
-    def mangle(self, name):
-        if name not in self.nodename_count:
-            self.nodename_count[name] = 1
-            return name
-        else:
-            result = '%s_%d' % (name, self.nodename_count[name])
-            self.nodename_count[name] += 1
-            # this ensures (a) doesn exist yet, and (b) adds it to the
-            # dictionary just to prevent some function called xxx_42() and clashing
-            return self.mangle(result)
-
     def make_name(self, name=''):
         " helper for creating names"
-        name = self.prefix + name
-        name = self.mangle(name)
-        if " " in name or "<" in name: 
-            name = '"%s"' % name
-
+        name = self.prefix + NODE_NAMES.uniquename(name)
         self.name = name
 
     def setup(self):



More information about the Pypy-commit mailing list