[pypy-svn] r27167 - in pypy/dist/pypy/rpython: . ootypesystem test

antocuni at codespeak.net antocuni at codespeak.net
Sat May 13 14:34:07 CEST 2006


Author: antocuni
Date: Sat May 13 14:33:49 2006
New Revision: 27167

Modified:
   pypy/dist/pypy/rpython/llinterp.py
   pypy/dist/pypy/rpython/ootypesystem/ootype.py
   pypy/dist/pypy/rpython/ootypesystem/rbuiltin.py
   pypy/dist/pypy/rpython/ootypesystem/rstr.py
   pypy/dist/pypy/rpython/test/test_rstr.py
Log:
Added a new operation 'oostring'



Modified: pypy/dist/pypy/rpython/llinterp.py
==============================================================================
--- pypy/dist/pypy/rpython/llinterp.py	(original)
+++ pypy/dist/pypy/rpython/llinterp.py	Sat May 13 14:33:49 2006
@@ -1001,6 +1001,8 @@
     def op_ooidentityhash(self, inst):
         return ootype.ooidentityhash(inst)
 
+    def op_oostring(self, obj):
+        return ootype.oostring(obj)
 
 class Tracer(object):
     Counter = 0

Modified: pypy/dist/pypy/rpython/ootypesystem/ootype.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/ootype.py	(original)
+++ pypy/dist/pypy/rpython/ootypesystem/ootype.py	Sat May 13 14:33:49 2006
@@ -1056,6 +1056,10 @@
     assert isinstance(typeOf(inst), (Instance, Record))
     return inst._identityhash()
 
+def oostring(obj):
+    "Convert char, int and str to str"
+    return make_string(str(obj))
+
 def setItemType(LIST, ITEMTYPE):
     return LIST._set_itemtype(ITEMTYPE)
 

Modified: pypy/dist/pypy/rpython/ootypesystem/rbuiltin.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/rbuiltin.py	(original)
+++ pypy/dist/pypy/rpython/ootypesystem/rbuiltin.py	Sat May 13 14:33:49 2006
@@ -57,6 +57,12 @@
     else:
         raise TyperError("XXX missing impl of isinstance(x, variable)")
 
+def rtype_oostring(hop):
+    assert isinstance(hop.args_s[0],(annmodel.SomeInteger,
+                                     annmodel.SomeChar,
+                                     annmodel.SomeString))
+    return hop.genop('oostring', hop.args_v, resulttype = ootype.String)
+
 
 BUILTIN_TYPER = {}
 BUILTIN_TYPER[ootype.new] = rtype_new
@@ -66,3 +72,4 @@
 BUILTIN_TYPER[ootype.runtimenew] = rtype_runtimenew
 BUILTIN_TYPER[ootype.ooidentityhash] = rtype_ooidentityhash
 BUILTIN_TYPER[isinstance] = rtype_builtin_isinstance
+BUILTIN_TYPER[ootype.oostring] = rtype_oostring

Modified: pypy/dist/pypy/rpython/ootypesystem/rstr.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/rstr.py	(original)
+++ pypy/dist/pypy/rpython/ootypesystem/rstr.py	Sat May 13 14:33:49 2006
@@ -60,6 +60,8 @@
     def ll_strconcat(s1, s2):
         return s1.ll_strconcat(s2)
 
+    def ll_chr2str(ch):
+        return ootype.oostring(ch)
 
 string_repr = StringRepr()
 char_repr = CharRepr()

Modified: pypy/dist/pypy/rpython/test/test_rstr.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rstr.py	(original)
+++ pypy/dist/pypy/rpython/test/test_rstr.py	Sat May 13 14:33:49 2006
@@ -101,7 +101,6 @@
             assert res is True
         
     def test_char_constant(self):
-        self._skip_oo('conversion char-->string')
         def fn(s):
             return s + '.'
         res = self.interpret(fn, ['x'])



More information about the Pypy-commit mailing list