[pypy-svn] pypy ootype-virtualrefs: implement force_cast for the cli backend

antocuni commits-noreply at bitbucket.org
Wed Apr 6 18:35:21 CEST 2011


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: ootype-virtualrefs
Changeset: r43176:c7bd951a8df1
Date: 2011-04-06 18:34 +0200
http://bitbucket.org/pypy/pypy/changeset/c7bd951a8df1/

Log:	implement force_cast for the cli backend

diff --git a/pypy/rpython/test/test_rbuiltin.py b/pypy/rpython/test/test_rbuiltin.py
--- a/pypy/rpython/test/test_rbuiltin.py
+++ b/pypy/rpython/test/test_rbuiltin.py
@@ -496,6 +496,13 @@
         res = self.interpret(llf, [rffi.r_short(123)], policy=LowLevelAnnotatorPolicy())
         assert res == 123
 
+    def test_force_cast(self):
+        def llfn(v):
+            return rffi.cast(rffi.SHORT, v)
+        res = self.interpret(llfn, [0x12345678])
+        assert res == 0x5678
+
+
 class TestLLtype(BaseTestRbuiltin, LLRtypeMixin):
 
     def test_isinstance_obj(self):

diff --git a/pypy/translator/cli/opcodes.py b/pypy/translator/cli/opcodes.py
--- a/pypy/translator/cli/opcodes.py
+++ b/pypy/translator/cli/opcodes.py
@@ -148,6 +148,7 @@
     'cast_longlong_to_float':   'conv.r8',
     'cast_float_to_longlong':   'conv.i8',
     'cast_primitive':           [PushAllArgs, CastPrimitive],
+    'force_cast':               [PushAllArgs, CastPrimitive],
     'truncate_longlong_to_int': 'conv.i4',
     }
 


More information about the Pypy-commit mailing list