[pypy-svn] r6233 - pypy/branch/pypy-genc/translator

arigo at codespeak.net arigo at codespeak.net
Mon Aug 30 17:36:14 CEST 2004


Author: arigo
Date: Mon Aug 30 17:36:14 2004
New Revision: 6233

Modified:
   pypy/branch/pypy-genc/translator/genc.py
Log:
Cosmetics.


Modified: pypy/branch/pypy-genc/translator/genc.py
==============================================================================
--- pypy/branch/pypy-genc/translator/genc.py	(original)
+++ pypy/branch/pypy-genc/translator/genc.py	Mon Aug 30 17:36:14 2004
@@ -19,9 +19,9 @@
 
     def __repr__(self):
         if hasattr(self, 'const'):
-            return '<C const %s>' % (self.const,)
+            return '<C:= %r>' % (self.const,)
         else:
-            return '<C: %s>' % ' '.join(self.impl)
+            return '<C: %s>' % ' + '.join(self.impl)
 
 
 class TypingError(Exception):
@@ -97,6 +97,7 @@
         except KeyError:
             # a constant doesn't need any C variable to be encoded
             r = self.r_constants[key] = CRepr([])
+            r.const = value
             # returning a constant
             def writer():
                 return 'return 0;'
@@ -111,13 +112,12 @@
             conv = self.lloperations['convert']
             if isinstance(value, int):
                 # can convert the constant to a C int
-                r.const = str(int(value))
                 def writer(z):
-                    return '%s = %s;' % (z, r.const)
+                    return '%s = %d;' % (z, value)
                 conv[r, self.R_INT] = writer, False
                 # can convert the constant to a PyObject*
                 def writer(z, err):
-                    return 'convert_io(%s, %s, %s)' % (r.const, z, err)
+                    return 'convert_io(%d, %s, %s)' % (value, z, err)
                 conv[r, self.R_OBJECT] = writer, True
             elif isinstance(value, str):
                 # can convert the constant to a PyObject*
@@ -127,7 +127,6 @@
                 conv[r, self.R_OBJECT] = writer, True
             elif value is None:
                 # can convert the constant to Py_None
-                r.const = 'Py_None'
                 def writer(z):
                     return 'convert_vo(%s)' % (z,)
                 conv[r, self.R_OBJECT] = writer, False



More information about the Pypy-commit mailing list