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

auc at codespeak.net auc at codespeak.net
Tue Sep 26 17:21:01 CEST 2006


Author: auc
Date: Tue Sep 26 17:20:56 2006
New Revision: 32655

Modified:
   pypy/dist/pypy/objspace/cclp/constraint/constraint.py
   pypy/dist/pypy/objspace/cclp/thunk.py
   pypy/dist/pypy/objspace/cclp/types.py
Log:
more type info ...


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 17:20:56 2006
@@ -9,7 +9,8 @@
 
 from pypy.objspace.constraint.computationspace import W_ComputationSpace
 
-from pypy.objspace.cclp.types import W_Constraint, W_CVar as W_Variable
+from pypy.objspace.cclp.types import W_Constraint, W_AbstractDomain, W_Root, \
+     W_CVar as W_Variable
 
 from pypy.objspace.std.model import StdObjSpaceMultiMethod
 
@@ -97,9 +98,13 @@
         for variable in self._variables:
             assert isinstance(variable, W_Variable)
             domain = variable.w_dom
+            assert isinstance(domain, W_AbstractDomain)
             values = domain.get_values()
+            assert isinstance(values, list)
             variables.append((domain.size(), [variable.w_name(), values, 0, len(values)]))
-            kwargs.content[variable.w_name()] = values[0]
+            first_value = values[0]
+            assert isinstance(first_value, W_Root)
+            kwargs.content[variable.w_name()] = first_value
         # sort variables to instanciate those with fewer possible values first
         sort(variables)
         self._assign_values_state = variables

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 17:20:56 2006
@@ -3,9 +3,12 @@
 
 from pypy.objspace.cclp.misc import w
 from pypy.objspace.cclp.global_state import scheduler
-from pypy.objspace.cclp.types import W_Var, W_Future, W_FailedValue, ConsistencyError, Solution
-from pypy.objspace.cclp.interp_var import interp_wait, interp_entail, interp_bind, interp_free, interp_wait_or
+from pypy.objspace.cclp.types import W_Var, W_CVar, W_Future, W_FailedValue, \
+     ConsistencyError, Solution, W_AbstractDomain
+from pypy.objspace.cclp.interp_var import interp_wait, interp_entail, \
+     interp_bind, interp_free, interp_wait_or
 
+from pypy.objspace.std.listobject import W_ListObject
 from pypy.rpython.objectmodel import we_are_translated
 
 def logic_args(args):
@@ -123,8 +126,14 @@
                     if entailed:
                         break
                     # we will block on domains being pruned
-                    wait_list = [var.w_dom.give_synchronizer()
-                                 for var in self.const._variables]
+                    wait_list = []
+                    _vars = self.const._variables
+                    assert isinstance(_vars, list)
+                    for var in _vars:
+                        assert isinstance(var, W_CVar)
+                        dom = var.w_dom
+                        assert isinstance(dom, W_AbstractDomain)
+                        wait_list.append(dom.give_synchronizer())
                     #or the cspace being dead
                     wait_list.append(cspace._finished)
                     interp_wait_or(self.space, wait_list)
@@ -160,7 +169,11 @@
                     dist.w_distribute(choice)
                 w("-- DISTRIBUTOR thunk exited because a solution was found")
                 #XXX assert that all propagators are entailed
-                for var in cspace._solution.w_bound_to.wrappeditems:
+                sol = cspace._solution
+                assert isinstance(sol, W_Var)
+                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 interp_free(cspace._choice)

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 17:20:56 2006
@@ -88,6 +88,11 @@
         self._space = space
         self._changed = W_Var(self._space)
 
+    def give_synchronizer(self):
+        pass
+
+    def get_values(self):
+        pass
 
 W_AbstractDomain.typedef = typedef.TypeDef("W_AbstractDomain")
 



More information about the Pypy-commit mailing list