[pypy-svn] r14729 - in pypy/dist/pypy: rpython rpython/test translator/goal

pedronis at codespeak.net pedronis at codespeak.net
Mon Jul 18 15:45:01 CEST 2005


Author: pedronis
Date: Mon Jul 18 15:44:56 2005
New Revision: 14729

Modified:
   pypy/dist/pypy/rpython/llinterp.py
   pypy/dist/pypy/rpython/rbuiltin.py
   pypy/dist/pypy/rpython/test/test_rbuiltin.py
   pypy/dist/pypy/translator/goal/ISSUES.txt
Log:
* isinstance(SomeObject...)

* support for simple_call in llinterp




Modified: pypy/dist/pypy/rpython/llinterp.py
==============================================================================
--- pypy/dist/pypy/rpython/llinterp.py	(original)
+++ pypy/dist/pypy/rpython/llinterp.py	Mon Jul 18 15:44:56 2005
@@ -306,6 +306,13 @@
         """ % locals()).compile()
     del opname
 
+    def op_simple_call(self, f, *args):
+        assert typeOf(f) == Ptr(PyObject)
+        for pyo in args:
+            assert typeOf(pyo) == Ptr(PyObject)
+        res = f._obj.value(*[pyo._obj.value for pyo in args])
+        return pyobjectptr(res)
+        
 
 
 # __________________________________________________________

Modified: pypy/dist/pypy/rpython/rbuiltin.py
==============================================================================
--- pypy/dist/pypy/rpython/rbuiltin.py	(original)
+++ pypy/dist/pypy/rpython/rbuiltin.py	Mon Jul 18 15:44:56 2005
@@ -8,6 +8,7 @@
 from pypy.rpython import rptr
 from pypy.rpython.robject import pyobj_repr
 from pypy.rpython.rfloat import float_repr, FloatRepr
+from pypy.rpython.rbool import bool_repr
 from pypy.rpython import rclass
 from pypy.tool import sourcetools
 
@@ -112,6 +113,12 @@
     return hop.args_r[0].rtype_bltn_list(hop)
 
 def rtype_builtin_isinstance(hop):
+    if hop.args_r[0] == pyobj_repr or hop.args_r[1] == pyobj_repr:
+        v_obj, v_typ = hop.inputargs(pyobj_repr, pyobj_repr)
+        c = hop.inputconst(pyobj_repr, isinstance)
+        v = hop.genop('simple_call', [c, v_obj, v_typ], resulttype = pyobj_repr)
+        return hop.llops.convertvar(v, pyobj_repr, bool_repr)        
+    
     instance_repr = rclass.getinstancerepr(hop.rtyper, None)
     class_repr = rclass.get_type_repr(hop.rtyper)
     

Modified: pypy/dist/pypy/rpython/test/test_rbuiltin.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rbuiltin.py	(original)
+++ pypy/dist/pypy/rpython/test/test_rbuiltin.py	Mon Jul 18 15:44:56 2005
@@ -1,6 +1,7 @@
 from pypy.rpython.test.test_llinterp import interpret
 from pypy.rpython.test import test_llinterp
 from pypy.rpython.objectmodel import instantiate
+from pypy.rpython import lltype
 from pypy.objspace.flow import model as flowmodel
 from pypy.tool import udir
 
@@ -157,3 +158,16 @@
     assert res.super.typeptr.name[0] == 'A'
     res = interpret(f, [2])
     assert res.super.typeptr.name[0] == 'B'
+
+
+def test_isinstance_obj():
+    _1 = lltype.pyobjectptr(1)
+    def f(x):
+        return isinstance(x, int)
+    res = interpret(f, [_1], someobjects=True)
+    assert res is True
+    _1_0 = lltype.pyobjectptr(1.0)
+    res = interpret(f, [_1_0], someobjects=True)
+    assert res is False
+    
+    

Modified: pypy/dist/pypy/translator/goal/ISSUES.txt
==============================================================================
--- pypy/dist/pypy/translator/goal/ISSUES.txt	(original)
+++ pypy/dist/pypy/translator/goal/ISSUES.txt	Mon Jul 18 15:44:56 2005
@@ -13,8 +13,6 @@
   * we need a call_args similar to simple_call (doing redispatching)
     on MethodOfFrozenPBCRepr
 
-  * isinstance(SomeObject, _), needed by wrap__object
-
   * the PBCReprs generally lack a convert_from_to() to convert from a small PBC
     set to a larger one.
 



More information about the Pypy-commit mailing list