[pypy-svn] r32657 - in pypy/dist/pypy/objspace/cclp: . constraint

auc at codespeak.net auc at codespeak.net
Tue Sep 26 19:09:17 CEST 2006


Author: auc
Date: Tue Sep 26 19:09:04 2006
New Revision: 32657

Modified:
   pypy/dist/pypy/objspace/cclp/constraint/constraint.py
   pypy/dist/pypy/objspace/cclp/scheduler.py
   pypy/dist/pypy/objspace/cclp/space.py
   pypy/dist/pypy/objspace/cclp/thunk.py
   pypy/dist/pypy/objspace/cclp/types.py
Log:
more tweaklets to help the annotator


Modified: pypy/dist/pypy/objspace/cclp/constraint/constraint.py
==============================================================================
--- pypy/dist/pypy/objspace/cclp/constraint/constraint.py	(original)
+++ pypy/dist/pypy/objspace/cclp/constraint/constraint.py	Tue Sep 26 19:09:04 2006
@@ -101,7 +101,8 @@
             assert isinstance(domain, W_AbstractDomain)
             values = domain.get_values()
             assert isinstance(values, list)
-            variables.append((domain.size(), [variable.w_name(), values, 0, len(values)]))
+            variables.append((domain.size(),
+                              [variable.w_name(), values, 0, len(values)]))
             first_value = values[0]
             assert isinstance(first_value, W_Root)
             kwargs.content[variable.w_name()] = first_value

Modified: pypy/dist/pypy/objspace/cclp/scheduler.py
==============================================================================
--- pypy/dist/pypy/objspace/cclp/scheduler.py	(original)
+++ pypy/dist/pypy/objspace/cclp/scheduler.py	Tue Sep 26 19:09:04 2006
@@ -14,6 +14,7 @@
     def __init__(self, space):
         self.space = space
         self._main = ClonableCoroutine.w_getcurrent(space)
+        assert isinstance(self._main, ClonableCoroutine)
         self._init_head(self._main)
         self._init_blocked()
         self._switch_count = 0
@@ -86,6 +87,7 @@
         if self.is_stable(cspace):
             return
         curr = ClonableCoroutine.w_getcurrent(self.space)
+        assert isinstance(curr, ClonableCoroutine)
         self._asking[curr] = cspace
         self._blocked[curr] = True
         # either we choose() from inside
@@ -136,6 +138,7 @@
         to_be_run = self._head
         sentinel = to_be_run
         current = ClonableCoroutine.w_getcurrent(self.space)
+        assert isinstance(current, ClonableCoroutine)
         while (to_be_run in self._blocked) \
                   or to_be_run.is_dead() \
                   or (to_be_run == current):
@@ -150,7 +153,7 @@
                     break
             if to_be_run == sentinel:
                 if not dont_pass:
-                    return ClonableCoroutine.w_getcurrent(self.space)
+                    return current
                 w(str(sched_all(self.space)))
                 ## we RESET sched state so as to keep being usable beyond that
                 self._init_head(self._main)

Modified: pypy/dist/pypy/objspace/cclp/space.py
==============================================================================
--- pypy/dist/pypy/objspace/cclp/space.py	(original)
+++ pypy/dist/pypy/objspace/cclp/space.py	Tue Sep 26 19:09:04 2006
@@ -81,7 +81,8 @@
         self.space.wait(self._choice)
         choice = self._choice.w_bound_to
         self._choice = newvar(self.space)
-        self._last_choice = choice.intval
+        assert isinstance(choice, W_IntObject)
+        self._last_choice = self.space.int_w(choice)
         return choice
 
     def choose(self, n):

Modified: pypy/dist/pypy/objspace/cclp/thunk.py
==============================================================================
--- pypy/dist/pypy/objspace/cclp/thunk.py	(original)
+++ pypy/dist/pypy/objspace/cclp/thunk.py	Tue Sep 26 19:09:04 2006
@@ -141,7 +141,7 @@
                         break
             except ConsistencyError:
                 cspace.fail()
-            except:
+            except Exception: # rpython doesn't like just except:\n ...
                 if not we_are_translated():
                     import traceback
                     traceback.print_exc()
@@ -174,8 +174,11 @@
                 varset = sol.w_bound_to
                 assert isinstance(varset, W_ListObject)
                 for var in varset.wrappeditems:
-                    assert var.w_dom.size() == 1
-                    interp_bind(var, var.w_dom.get_values()[0])
+                    assert isinstance(var, W_CVar)
+                    dom = var.w_dom
+                    assert isinstance(dom, W_AbstractDomain)
+                    assert dom.size() == 1
+                    interp_bind(var, dom.get_values()[0])
                 assert interp_free(cspace._choice)
                 interp_bind(cspace._choice, self.space.newint(1))
             except ConsistencyError, e:

Modified: pypy/dist/pypy/objspace/cclp/types.py
==============================================================================
--- pypy/dist/pypy/objspace/cclp/types.py	(original)
+++ pypy/dist/pypy/objspace/cclp/types.py	Tue Sep 26 19:09:04 2006
@@ -94,6 +94,9 @@
     def get_values(self):
         pass
 
+    def size(self):
+        pass
+
 W_AbstractDomain.typedef = typedef.TypeDef("W_AbstractDomain")
 
 class W_AbstractDistributor(baseobjspace.Wrappable):



More information about the Pypy-commit mailing list