[pypy-svn] r32653 - pypy/dist/pypy/objspace/cclp

auc at codespeak.net auc at codespeak.net
Tue Sep 26 16:08:50 CEST 2006


Author: auc
Date: Tue Sep 26 16:08:46 2006
New Revision: 32653

Modified:
   pypy/dist/pypy/objspace/cclp/interp_var.py
   pypy/dist/pypy/objspace/cclp/thunk.py
   pypy/dist/pypy/objspace/cclp/types.py
   pypy/dist/pypy/objspace/cclp/variable.py
Log:
type declarations, small fixes


Modified: pypy/dist/pypy/objspace/cclp/interp_var.py
==============================================================================
--- pypy/dist/pypy/objspace/cclp/interp_var.py	(original)
+++ pypy/dist/pypy/objspace/cclp/interp_var.py	Tue Sep 26 16:08:46 2006
@@ -1,10 +1,11 @@
 from pypy.objspace.cclp.variable import wait__Var, _assign_aliases, _entail
-from pypy.objspace.cclp.types import W_Var, W_CVar
+from pypy.objspace.cclp.types import W_Root, W_Var, W_CVar
 from pypy.objspace.cclp.global_state import scheduler
 from pypy.objspace.cclp.misc import w
 
 
 def interp_free(w_var):
+    assert isinstance(w_var, W_Var)
     return isinstance(w_var.w_bound_to, W_Var)
 
 def interp_wait(space, obj):
@@ -13,16 +14,19 @@
 
 class RebindingError(Exception): pass
 
-def interp_bind(w_var, obj):
+def interp_bind(w_var, w_obj):
+    # w_obj is NOT a W_Var
     if interp_free(w_var):
-        return interp_assign_aliases(w_var, obj)
-    if w_var.w_bound_to == obj:
+        return interp_assign_aliases(w_var, w_obj)
+    if w_var.w_bound_to == w_obj:
         return
     raise RebindingError
 
 class EntailmentError(Exception): pass
 
 def interp_entail(w_v1, w_v2):
+    assert isinstance(w_v1, W_Var)
+    assert isinstance(w_v2, W_Var)
     w_v1val = w_v1.w_bound_to
     w_v2val = w_v2.w_bound_to
     if not interp_free(w_v1):
@@ -41,6 +45,7 @@
     w_curr = w_var
     while 1:
         w_next = w_curr.w_bound_to
+        assert isinstance(w_next, W_Var)
         _assign(w_curr, w_val)
         # notify the blocked threads
         scheduler[0].unblock_on(w_curr)
@@ -54,6 +59,7 @@
 def _assign_entailed(w_var, w_val):
     w("   :assign entailed")
     for var in w_var.entails:
+        assert isinstance(var, W_Var)
         if interp_free(var):
             interp_assign_aliases(var, w_val)
         else:
@@ -63,7 +69,7 @@
 def _assign(w_var, w_val):
     assert isinstance(w_var, W_Var)
     if isinstance(w_var, W_CVar):
-        if not w_val in w_var.w_dom._values.content:
+        if not w_var.w_dom.contains(w_val):
             raise ValueError, "assignment out of domain"
     w_var.w_bound_to = w_val
 

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 16:08:46 2006
@@ -150,8 +150,8 @@
 
     def call(self):
         coro = self.coro
+        cspace = coro._cspace
         try:
-            cspace = coro._cspace
             cspace.distributor = coro
             dist = self.dist
             try:

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 16:08:46 2006
@@ -117,6 +117,7 @@
     w_curr = w_var
     while 1:
         w_next = w_curr.w_bound_to
+        assert isinstance(w_next, W_Var)
         al.append(w_curr)
         if space.is_true(space.is_nb_(w_next, w_var)):
             break

Modified: pypy/dist/pypy/objspace/cclp/variable.py
==============================================================================
--- pypy/dist/pypy/objspace/cclp/variable.py	(original)
+++ pypy/dist/pypy/objspace/cclp/variable.py	Tue Sep 26 16:08:46 2006
@@ -122,6 +122,7 @@
     w_curr = w_var1
     while 1:
         w_next = w_curr.w_bound_to
+        assert isinstance(w_next, W_Var)
         if w_next is w_var2:
             return space.newbool(True)
         if w_next is w_var1:
@@ -138,6 +139,7 @@
     w_curr = w_start
     while 1:
         w_next = w_curr.w_bound_to
+        assert isinstance(w_next, W_Var)
         if space.is_true(space.is_nb_(w_next, w_start)):
             return w_curr
         w_curr = w_next
@@ -260,6 +262,7 @@
     w_curr = w_var
     while 1:
         w_next = w_curr.w_bound_to
+        assert isinstance(w_next, W_Var)
         _assign(space, w_curr, w_val)
         # notify the blocked threads
         scheduler[0].unblock_on(w_curr)



More information about the Pypy-commit mailing list