[pypy-commit] pypy default: Progress.

arigo noreply at buildbot.pypy.org
Wed Dec 7 17:40:06 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r50262:6e9276536c74
Date: 2011-12-07 15:17 +0100
http://bitbucket.org/pypy/pypy/changeset/6e9276536c74/

Log:	Progress.

diff --git a/pypy/objspace/fake/objspace.py b/pypy/objspace/fake/objspace.py
--- a/pypy/objspace/fake/objspace.py
+++ b/pypy/objspace/fake/objspace.py
@@ -7,6 +7,7 @@
 from pypy.rlib.unroll import unrolling_iterable
 from pypy.rlib.objectmodel import we_are_translated
 from pypy.rlib.nonconst import NonConstant
+from pypy.rlib.rarithmetic import r_uint
 from pypy.translator.translator import TranslationContext
 
 
@@ -41,14 +42,61 @@
         self._seen_extras = []
         ObjSpace.__init__(self)
 
+    def str_w(self, w_obj):
+        is_root(w_obj)
+        return NonConstant("foobar")
+
+    def int_w(self, w_obj):
+        is_root(w_obj)
+        return NonConstant(-42)
+
+    def float_w(self, w_obj):
+        is_root(w_obj)
+        return NonConstant(42.5)
+
+    def uint_w(self, w_obj):
+        is_root(w_obj)
+        return r_uint(NonConstant(42))
+
+    def bigint_w(self, w_obj):
+        from pypy.rlib.rbigint import rbigint
+        is_root(w_obj)
+        return rbigint.fromint(NonConstant(42))
+
+    def unicode_w(self, w_obj):
+        is_root(w_obj)
+        return NonConstant(u"foobar")
+
     def is_true(self, w_obj):
         is_root(w_obj)
         return NonConstant(False)
 
+    def unwrap(self, w_obj):
+        "NOT_RPYTHON"
+        raise NotImplementedError
+
     def newdict(self, module=False, instance=False, classofinstance=None,
                 strdict=False):
         return W_Root()
 
+    def newtuple(self, list_w):
+        is_root(list_w[NonConstant(0)])
+        return W_Root()
+
+    def newlist(self, list_w):
+        is_root(list_w[NonConstant(0)])
+        return W_Root()
+
+    def newslice(self, w_start, w_end, w_step):
+        is_root(w_start)
+        is_root(w_end)
+        is_root(w_step)
+        return W_Root()
+
+    def marshal_w(self, w_obj):
+        "NOT_RPYTHON"
+        raise NotImplementedError
+
     def wrap(self, x):
         if isinstance(x, gateway.interp2app):
             self._see_interp2app(x)
@@ -94,6 +142,7 @@
             ann.build_types(func, argtypes)
         for check in self._seen_extras:
             ann.build_types(check, [])
+        #t.viewcg()
         t.buildrtyper().specialize()
         t.checkgraphs()
 
@@ -116,5 +165,8 @@
                '; '.join(['is_root(%s)' % arg for arg in args]))) in d
         meth = func_with_new_name(d['meth'], name)
         setattr(FakeObjSpace, name, meth)
+    #
+    for name in ObjSpace.IrregularOpTable:
+        assert hasattr(FakeObjSpace, name)    # missing?
 
 setup()
diff --git a/pypy/objspace/fake/test/test_checkmodule.py b/pypy/objspace/fake/test/test_checkmodule.py
--- a/pypy/objspace/fake/test/test_checkmodule.py
+++ b/pypy/objspace/fake/test/test_checkmodule.py
@@ -1,5 +1,9 @@
-from pypy.objspace.fake.checkmodule import checkmodule, FakeObjSpace
-from pypy.interpreter.gateway import interp2app
+import py
+from pypy.objspace.fake.checkmodule import checkmodule
+from pypy.objspace.fake.objspace import FakeObjSpace, is_root
+from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.typedef import TypeDef
+from pypy.interpreter.gateway import interp2app, W_Root, ObjSpace
 
 
 def make_checker():
@@ -9,7 +13,6 @@
     see._annspecialcase_ = 'specialize:memo'
     return see, check
 
-
 def test_wrap_interp2app():
     see, check = make_checker()
     space = FakeObjSpace()
@@ -18,8 +21,31 @@
     space.wrap(interp2app(lambda space: see()))
     assert len(space._seen_extras) == 1
     assert len(check) == 0
-    space.translates(lambda: None)
+    space.translates()
     assert len(check) == 1
 
+def test_wrap_interp2app_int():
+    see, check = make_checker()
+    def foobar(space, x, w_y, z):
+        is_root(w_y)
+        see()
+        return space.wrap(x - z)
+    space = FakeObjSpace()
+    space.wrap(interp2app(foobar, unwrap_spec=[ObjSpace, int, W_Root, int]))
+    space.translates()
+    assert check
+
+
+def test_gettypefor_untranslated():
+    py.test.skip("in-progress")
+    class W_Foo(Wrappable):
+        pass
+    W_Foo.typedef = TypeDef('foo',
+                            __module__ = 'barmod',
+                            do_it = interp2app(W_Foo.do_it))
+    see, check = make_checker()
+    space = FakeObjSpace()
+    space.gettypefor(W_Foo)
+
 def test_itertools_module():
     checkmodule('itertools')


More information about the pypy-commit mailing list