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

auc at codespeak.net auc at codespeak.net
Tue Sep 26 10:48:22 CEST 2006


Author: auc
Date: Tue Sep 26 10:48:18 2006
New Revision: 32643

Modified:
   pypy/dist/pypy/objspace/cclp/constraint/distributor.py
   pypy/dist/pypy/objspace/cclp/misc.py
   pypy/dist/pypy/objspace/cclp/space.py
   pypy/dist/pypy/objspace/cclp/thread.py
   pypy/dist/pypy/objspace/cclp/types.py
Log:
helper func. to help the annotation


Modified: pypy/dist/pypy/objspace/cclp/constraint/distributor.py
==============================================================================
--- pypy/dist/pypy/objspace/cclp/constraint/distributor.py	(original)
+++ pypy/dist/pypy/objspace/cclp/constraint/distributor.py	Tue Sep 26 10:48:18 2006
@@ -12,15 +12,13 @@
 
 from pypy.objspace.cclp.types import W_AbstractDistributor, Solution
 from pypy.objspace.cclp.thunk import DistributorThunk
-from pypy.objspace.cclp.misc import w, ClonableCoroutine
+from pypy.objspace.cclp.misc import w, ClonableCoroutine, get_current_cspace
 from pypy.objspace.cclp.global_state import scheduler
 from pypy.objspace.cclp.interp_var import interp_free
 
 def spawn_distributor(space, distributor):
     thread = ClonableCoroutine(space)
-    current = ClonableCoroutine.w_getcurrent(space)
-    assert hasattr(current, '_cspace')
-    thread._cspace = current._cspace
+    thread._cspace = get_current_cspace(space)
     thunk = DistributorThunk(space, distributor, thread)
     thread.bind(thunk)
     if not we_are_translated():

Modified: pypy/dist/pypy/objspace/cclp/misc.py
==============================================================================
--- pypy/dist/pypy/objspace/cclp/misc.py	(original)
+++ pypy/dist/pypy/objspace/cclp/misc.py	Tue Sep 26 10:48:18 2006
@@ -19,6 +19,13 @@
         os.write(1, msg)
         os.write(1, ' ')
 
+def get_current_cspace(space):
+    curr = ClonableCoroutine.w_getcurrent(space)
+    assert isinstance(curr, ClonableCoroutine)
+    assert hasattr(curr, '_cspace')
+    return curr._cspace
+
+
 def interp_id(space, w_obj):
     "debugging purposes only"
     assert isinstance(w_obj, baseobjspace.W_Root) 

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 10:48:18 2006
@@ -4,7 +4,7 @@
 
 from pypy.objspace.std.intobject import W_IntObject
 
-from pypy.objspace.cclp.misc import ClonableCoroutine, w
+from pypy.objspace.cclp.misc import ClonableCoroutine, get_current_cspace, w
 from pypy.objspace.cclp.thunk import CSpaceThunk, PropagatorThunk
 from pypy.objspace.cclp.global_state import scheduler
 from pypy.objspace.cclp.variable import newvar
@@ -34,7 +34,7 @@
 def choose(space, w_n):
     assert isinstance(w_n, W_IntObject)
     n = space.int_w(w_n)
-    cspace = ClonableCoroutine.w_getcurrent(space)._cspace
+    cspace = get_current_cspace(space)
     if cspace != None:
         assert isinstance(cspace, W_CSpace)
         try:
@@ -51,7 +51,7 @@
 
 def tell(space, w_constraint):
     assert isinstance(w_constraint, constraint.W_AbstractConstraint)
-    ClonableCoroutine.w_getcurrent(space)._cspace.tell(w_constraint)
+    get_current_cspace(space).tell(w_constraint)
 app_tell = gateway.interp2app(tell)
 
 

Modified: pypy/dist/pypy/objspace/cclp/thread.py
==============================================================================
--- pypy/dist/pypy/objspace/cclp/thread.py	(original)
+++ pypy/dist/pypy/objspace/cclp/thread.py	Tue Sep 26 10:48:18 2006
@@ -2,7 +2,7 @@
 from pypy.rpython.objectmodel import we_are_translated
 
 from pypy.objspace.cclp.types import W_Var, W_Future, W_FailedValue
-from pypy.objspace.cclp.misc import w, v, ClonableCoroutine
+from pypy.objspace.cclp.misc import w, v, ClonableCoroutine, get_current_cspace
 from pypy.objspace.cclp.thunk import FutureThunk, ProcedureThunk
 from pypy.objspace.cclp.global_state import scheduler
 
@@ -21,7 +21,7 @@
     w_Future = W_Future(space)
     thunk = FutureThunk(space, w_callable, args, w_Future, coro)
     coro.bind(thunk)
-    coro._cspace = ClonableCoroutine.w_getcurrent(space)._cspace
+    coro._cspace = get_current_cspace(space)
     if not we_are_translated():
         w("FUTURE", str(id(coro)), "for", str(w_callable.name))
     scheduler[0].add_new_thread(coro)
@@ -41,7 +41,7 @@
     #coro.cspace = ClonableCoroutine.w_getcurrent(space).cspace
     thunk = ProcedureThunk(space, w_callable, args, coro)
     coro.bind(thunk)
-    coro._cspace = ClonableCoroutine.w_getcurrent(space)._cspace
+    coro._cspace = get_current_cspace(space)
     if not we_are_translated():
         w("STACKLET", str(id(coro)), "for", str(w_callable.name))
     scheduler[0].add_new_thread(coro)

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 10:48:18 2006
@@ -1,7 +1,7 @@
 from pypy.interpreter import baseobjspace, gateway, typedef
 from pypy.interpreter.error import OperationError
 
-from pypy.objspace.cclp.misc import w, ClonableCoroutine
+from pypy.objspace.cclp.misc import w, ClonableCoroutine, get_current_cspace
 
 W_Root = baseobjspace.W_Root
 
@@ -42,9 +42,7 @@
         self.w_dom = w_dom
         self.name = space.str_w(w_name)
         self.w_nam = w_name
-        current = ClonableCoroutine.w_getcurrent(space)
-        assert hasattr(current, '_cspace')
-        cspace = current._cspace
+        cspace = get_current_cspace(space)
         if cspace is None:
             w("-- WARNING : you are instanciating a constraint var in the top-level space")
         else:
@@ -99,7 +97,7 @@
         assert isinstance(fanout, int)
         self._space = space
         self._fanout = fanout
-        self._cspace = ClonableCoroutine.w_getcurrent(space)._cspace
+        self._cspace = get_current_cspace(space)
 
 W_AbstractDistributor.typedef = typedef.TypeDef("W_AbstractDistributor")
 



More information about the Pypy-commit mailing list