[pypy-svn] r28521 - pypy/dist/pypy/translator/cli

antocuni at codespeak.net antocuni at codespeak.net
Thu Jun 8 15:37:26 CEST 2006


Author: antocuni
Date: Thu Jun  8 15:37:26 2006
New Revision: 28521

Modified:
   pypy/dist/pypy/translator/cli/cts.py
   pypy/dist/pypy/translator/cli/function.py
Log:
bugfix.



Modified: pypy/dist/pypy/translator/cli/cts.py
==============================================================================
--- pypy/dist/pypy/translator/cli/cts.py	(original)
+++ pypy/dist/pypy/translator/cli/cts.py	Thu Jun  8 15:37:26 2006
@@ -60,6 +60,8 @@
             assert False, error
 
 class CTS(object):
+    ILASM_KEYWORDS = ['call']
+    
     def __init__(self, db):
         self.db = db
 
@@ -69,6 +71,13 @@
         else:
             return result
 
+    def escape_name(self, name):
+        """Mangle then name if it's a ilasm reserved word"""
+        if name in self.ILASM_KEYWORDS:
+            return name + '__MANGLED' # XXX: it could not be unique
+        else:
+            return name
+
     def lltype_to_cts(self, t, include_class=True):
         if isinstance(t, ootype.Instance):
             self.db.pending_class(t)
@@ -106,6 +115,7 @@
     def graph_to_signature(self, graph, is_method = False, func_name = None):
         ret_type, ret_var = self.llvar_to_cts(graph.getreturnvar())
         func_name = func_name or graph.name
+        func_name = self.escape_name(func_name)
 
         args = [arg for arg in graph.getargs() if arg.concretetype is not ootype.Void]
         if is_method:

Modified: pypy/dist/pypy/translator/cli/function.py
==============================================================================
--- pypy/dist/pypy/translator/cli/function.py	(original)
+++ pypy/dist/pypy/translator/cli/function.py	Thu Jun  8 15:37:26 2006
@@ -24,7 +24,7 @@
         self.db = db
         self.cts = CTS(db)
         self.graph = graph
-        self.name = name or graph.name
+        self.name = self.cts.escape_name(name or graph.name)
         self.is_method = is_method
         self.is_entrypoint = is_entrypoint
         self.blocknum = {}



More information about the Pypy-commit mailing list