[pypy-svn] r13836 - pypy/dist/pypy/rpython
ale at codespeak.net
ale at codespeak.net
Sat Jun 25 11:42:19 CEST 2005
Author: ale
Date: Sat Jun 25 11:42:16 2005
New Revision: 13836
Modified:
pypy/dist/pypy/rpython/llinterp.py
pypy/dist/pypy/rpython/rbuiltin.py
pypy/dist/pypy/rpython/rint.py
Log:
Added support for unichr builtin and ord for unichars
Modified: pypy/dist/pypy/rpython/llinterp.py
==============================================================================
--- pypy/dist/pypy/rpython/llinterp.py (original)
+++ pypy/dist/pypy/rpython/llinterp.py Sat Jun 25 11:42:16 2005
@@ -256,6 +256,14 @@
assert type(b) is str and len(b) == 1
return ord(b)
+ def op_cast_unichar_to_int(self, b):
+ assert type(b) is unicode and len(b) == 1
+ return ord(b)
+
+ def op_cast_int_to_unichar(self, b):
+ assert type(b) is int
+ return unichr(b)
+
def op_cast_int_to_uint(self, b):
assert type(b) is int
return r_uint(b)
Modified: pypy/dist/pypy/rpython/rbuiltin.py
==============================================================================
--- pypy/dist/pypy/rpython/rbuiltin.py (original)
+++ pypy/dist/pypy/rpython/rbuiltin.py Sat Jun 25 11:42:16 2005
@@ -99,6 +99,10 @@
assert hop.nb_args == 1
return hop.args_r[0].rtype_chr(hop)
+def rtype_builtin_unichr(hop):
+ assert hop.nb_args == 1
+ return hop.args_r[0].rtype_unichr(hop)
+
def rtype_builtin_list(hop):
return hop.args_r[0].rtype_bltn_list(hop)
Modified: pypy/dist/pypy/rpython/rint.py
==============================================================================
--- pypy/dist/pypy/rpython/rint.py (original)
+++ pypy/dist/pypy/rpython/rint.py Sat Jun 25 11:42:16 2005
@@ -2,7 +2,7 @@
from pypy.annotation import model as annmodel
from pypy.objspace.flow.objspace import op_appendices
from pypy.rpython.lltype import Signed, Unsigned, Bool, Float, Void, Char, \
- GcArray, malloc, Array
+ UniChar, GcArray, malloc, Array
from pypy.rpython.rmodel import Repr, TyperError, IntegerRepr, CharRepr, \
inputconst
from pypy.rpython.robject import PyObjRepr, pyobj_repr
@@ -206,6 +206,10 @@
vlist = hop.inputargs(Signed)
return hop.genop('cast_int_to_char', vlist, resulttype=Char)
+ def rtype_unichr(_, hop):
+ vlist = hop.inputargs(Signed)
+ return hop.genop('cast_int_to_unichar', vlist, resulttype=UniChar)
+
def rtype_is_true(self, hop):
if self.lowleveltype == Unsigned:
vlist = hop.inputargs(Unsigned)
More information about the Pypy-commit
mailing list