[pypy-svn] r35362 - in pypy/branch/jit-real-world/pypy: annotation annotation/test rlib rpython rpython/test

pedronis at codespeak.net pedronis at codespeak.net
Wed Dec 6 03:30:19 CET 2006


Author: pedronis
Date: Wed Dec  6 03:29:18 2006
New Revision: 35362

Modified:
   pypy/branch/jit-real-world/pypy/annotation/annrpython.py
   pypy/branch/jit-real-world/pypy/annotation/binaryop.py
   pypy/branch/jit-real-world/pypy/annotation/description.py
   pypy/branch/jit-real-world/pypy/annotation/test/test_annrpython.py
   pypy/branch/jit-real-world/pypy/rlib/rarithmetic.py
   pypy/branch/jit-real-world/pypy/rlib/ros.py
   pypy/branch/jit-real-world/pypy/rpython/raddress.py
   pypy/branch/jit-real-world/pypy/rpython/robject.py
   pypy/branch/jit-real-world/pypy/rpython/rptr.py
   pypy/branch/jit-real-world/pypy/rpython/rtyper.py
   pypy/branch/jit-real-world/pypy/rpython/test/test_rpbc.py
Log:
svn merge -r 35338:35361 http://codespeak.net/svn/pypy/dist/pypy/annotation annotation
svn merge -r 35338:35361 http://codespeak.net/svn/pypy/dist/pypy/rpython rpython    U    rpython/raddress.py
svn merge -r 35338:35361 http://codespeak.net/svn/pypy/dist/pypy/rlib rlib



Modified: pypy/branch/jit-real-world/pypy/annotation/annrpython.py
==============================================================================
--- pypy/branch/jit-real-world/pypy/annotation/annrpython.py	(original)
+++ pypy/branch/jit-real-world/pypy/annotation/annrpython.py	Wed Dec  6 03:29:18 2006
@@ -645,6 +645,7 @@
                 last_exc_value_vars = []
                 in_except_block = True
 
+            ignore_link = False
             cells = []
             renaming = {}
             for a,v in zip(link.args,link.target.inputargs):
@@ -662,6 +663,9 @@
                     if (link.exitcase, a) in knowntypedata:
                         knownvarvalue = knowntypedata[(link.exitcase, a)]
                         cell = pair(cell, knownvarvalue).improve()
+                        # ignore links that try to pass impossible values
+                        if cell == annmodel.s_ImpossibleValue:
+                            ignore_link = True
 
                     if hasattr(cell,'is_type_of'):
                         renamed_is_type_of = []
@@ -691,12 +695,12 @@
 
                     cells.append(cell)
 
+            if ignore_link:
+                continue
+
             if in_except_block:
                 last_exception_object.is_type_of = last_exc_value_vars
 
-            if annmodel.s_ImpossibleValue in cells:
-                continue    # ignore links that try to pass impossible values
-
             self.links_followed[link] = True
             self.addpendingblock(graph, link.target, cells)
 

Modified: pypy/branch/jit-real-world/pypy/annotation/binaryop.py
==============================================================================
--- pypy/branch/jit-real-world/pypy/annotation/binaryop.py	(original)
+++ pypy/branch/jit-real-world/pypy/annotation/binaryop.py	Wed Dec  6 03:29:18 2006
@@ -630,11 +630,23 @@
         return SomeBuiltin(bltn1.analyser, s_self, methodname=bltn1.methodname)
 
 class __extend__(pairtype(SomePBC, SomePBC)):
+
     def union((pbc1, pbc2)):       
         d = pbc1.descriptions.copy()
         d.update(pbc2.descriptions)
         return SomePBC(d, can_be_None = pbc1.can_be_None or pbc2.can_be_None)
 
+    def is_((obj1, obj2)):
+        thistype = pairtype(SomePBC, SomePBC)
+        s = super(thistype, pair(obj1, obj2)).is_()
+        if not s.is_constant():
+            for desc in obj1.descriptions:
+                if desc in obj2.descriptions:
+                    break
+            else:
+                s.const = False    # no common desc in the two sets
+        return s
+
 class __extend__(pairtype(SomeImpossibleValue, SomeObject)):
     def union((imp1, obj2)):
         return obj2

Modified: pypy/branch/jit-real-world/pypy/annotation/description.py
==============================================================================
--- pypy/branch/jit-real-world/pypy/annotation/description.py	(original)
+++ pypy/branch/jit-real-world/pypy/annotation/description.py	Wed Dec  6 03:29:18 2006
@@ -254,6 +254,10 @@
             self.specializer = policy.get_specializer(tag)
         enforceargs = getattr(self.pyobj, '_annenforceargs_', None)
         if enforceargs:
+            if not callable(enforceargs):
+                from pypy.annotation.policy import Sig
+                enforceargs = Sig(*enforceargs)
+                self.pyobj._annenforceargs_ = enforceargs
             enforceargs(self, inputcells) # can modify inputcells in-place
         return self.specializer(self, inputcells)
 

Modified: pypy/branch/jit-real-world/pypy/annotation/test/test_annrpython.py
==============================================================================
--- pypy/branch/jit-real-world/pypy/annotation/test/test_annrpython.py	(original)
+++ pypy/branch/jit-real-world/pypy/annotation/test/test_annrpython.py	Wed Dec  6 03:29:18 2006
@@ -2363,6 +2363,18 @@
         assert not s.nonneg
         py.test.raises(Exception, a.build_types, fun, [int, int])
 
+    def test_sig_simpler(self):
+        def fun(x, y):
+            return x+y
+        s_nonneg = annmodel.SomeInteger(nonneg=True)
+        fun._annenforceargs_ = (int, s_nonneg)
+
+        a = self.RPythonAnnotator()
+        s = a.build_types(fun, [s_nonneg, s_nonneg])
+        assert isinstance(s, annmodel.SomeInteger)
+        assert not s.nonneg
+        py.test.raises(Exception, a.build_types, fun, [int, int])
+
     def test_sig_lambda(self):
         def fun(x, y):
             return y

Modified: pypy/branch/jit-real-world/pypy/rlib/rarithmetic.py
==============================================================================
--- pypy/branch/jit-real-world/pypy/rlib/rarithmetic.py	(original)
+++ pypy/branch/jit-real-world/pypy/rlib/rarithmetic.py	Wed Dec  6 03:29:18 2006
@@ -313,6 +313,7 @@
 
         def specialize_call(self, hop):
             v_result, = hop.inputargs(hop.r_result.lowleveltype)
+            hop.exception_cannot_occur()
             return v_result
             
     return int_type

Modified: pypy/branch/jit-real-world/pypy/rlib/ros.py
==============================================================================
--- pypy/branch/jit-real-world/pypy/rlib/ros.py	(original)
+++ pypy/branch/jit-real-world/pypy/rlib/ros.py	Wed Dec  6 03:29:18 2006
@@ -8,6 +8,7 @@
     # we fake it with the real one
     name, value = name_eq_value.split('=', 1)
     os.putenv(name, value)
+putenv._annenforceargs_ = (str,)
 
 _initial_items = os.environ.items()
 
@@ -29,6 +30,7 @@
             return value
         idx += 1
     return None
+getenv._annenforceargs_ = (str,)
 
 
 class DIR(object):
@@ -49,3 +51,4 @@
 
 def opendir(dirname):
     return DIR(dirname)
+opendir._annenforceargs_ = (str,)

Modified: pypy/branch/jit-real-world/pypy/rpython/raddress.py
==============================================================================
--- pypy/branch/jit-real-world/pypy/rpython/raddress.py	(original)
+++ pypy/branch/jit-real-world/pypy/rpython/raddress.py	Wed Dec  6 03:29:18 2006
@@ -7,6 +7,7 @@
 from pypy.rpython.rmodel import Repr, IntegerRepr
 from pypy.rpython.rptr import PtrRepr
 from pypy.rpython.lltypesystem import lltype
+from pypy.rlib.rarithmetic import r_uint
 
 class __extend__(annmodel.SomeAddress):
     def rtyper_makerepr(self, rtyper):
@@ -36,6 +37,11 @@
         assert not isinstance(value, _address)
         return value
 
+    def ll_str(self, a):
+        from pypy.rpython.lltypesystem.rstr import ll_str
+        id = cast_adr_to_int(a)
+        return ll_str.ll_int2hex(r_uint(id), True)
+
     def rtype_getattr(self, hop):
         v_access = hop.inputarg(address_repr, 0)
         return v_access

Modified: pypy/branch/jit-real-world/pypy/rpython/robject.py
==============================================================================
--- pypy/branch/jit-real-world/pypy/rpython/robject.py	(original)
+++ pypy/branch/jit-real-world/pypy/rpython/robject.py	Wed Dec  6 03:29:18 2006
@@ -9,19 +9,25 @@
 
 class __extend__(annmodel.SomeObject):
     def rtyper_makerepr(self, rtyper):
-        if self.knowntype is type:
+        kind = getkind(self)
+        if kind == "type":
             return rclass.get_type_repr(rtyper)
-        elif self.is_constant():
+        elif kind == "const":
             return constpyobj_repr
         else:
             return pyobj_repr
     def rtyper_makekey(self):
-        if self.is_constant():
-            return self.__class__, "const"
-        if self.knowntype is type:
-            return self.__class__, "type"
-        else:
-            return self.__class__, "pyobj"
+        return self.__class__, getkind(self)
+
+def getkind(s_obj):
+    if s_obj.is_constant():
+        if getattr(s_obj.const, '__module__', None) == '__builtin__':
+            return "const"
+    if s_obj.knowntype is type:
+        return "type"
+    if s_obj.is_constant():
+        return "const"
+    return "pyobj"
 
 
 class PyObjRepr(Repr):

Modified: pypy/branch/jit-real-world/pypy/rpython/rptr.py
==============================================================================
--- pypy/branch/jit-real-world/pypy/rpython/rptr.py	(original)
+++ pypy/branch/jit-real-world/pypy/rpython/rptr.py	Wed Dec  6 03:29:18 2006
@@ -27,7 +27,7 @@
         self.lowleveltype = ptrtype
 
     def ll_str(self, p):
-        from pypy.rpython.lltypesystem.rstr import LLHelpers, ll_str
+        from pypy.rpython.lltypesystem.rstr import ll_str
         id = lltype.cast_ptr_to_int(p)
         return ll_str.ll_int2hex(r_uint(id), True)
 

Modified: pypy/branch/jit-real-world/pypy/rpython/rtyper.py
==============================================================================
--- pypy/branch/jit-real-world/pypy/rpython/rtyper.py	(original)
+++ pypy/branch/jit-real-world/pypy/rpython/rtyper.py	Wed Dec  6 03:29:18 2006
@@ -244,12 +244,8 @@
                 bc += 1
                 continue
             block, position = err.where
-            func = self.annotator.annotated.get(block, None)
-            if func:
-                func = "(%s:%s)" %(func.__module__ or '?', func.__name__)
-            else:
-                func = "(?:?)"
-            errmsg = ("TyperError-%d: %s" % (c, func) +
+            graph = self.annotator.annotated.get(block, None)
+            errmsg = ("TyperError-%d: %s\n" % (c, graph) +
                       str(err) +
                       "\n")
             if to_log:

Modified: pypy/branch/jit-real-world/pypy/rpython/test/test_rpbc.py
==============================================================================
--- pypy/branch/jit-real-world/pypy/rpython/test/test_rpbc.py	(original)
+++ pypy/branch/jit-real-world/pypy/rpython/test/test_rpbc.py	Wed Dec  6 03:29:18 2006
@@ -1477,6 +1477,20 @@
         res = self.interpret(f, [5])
         assert res == 123
 
+    def test_is_among_functions(self):
+        def g1(): pass
+        def g2(): pass
+        def g3(): pass
+        def f(n):
+            if n > 5:
+                g = g2
+            else:
+                g = g1
+            g()
+            g3()
+            return g is g3
+        res = self.interpret(f, [2])
+        assert res == False
 
 # We don't care about the following test_hlinvoke tests working on
 # ootype. Maybe later. This kind of thing is only used in rdict



More information about the Pypy-commit mailing list