[pypy-svn] r25482 - in pypy/dist/pypy/objspace: . constraint constraint/test

auc at codespeak.net auc at codespeak.net
Fri Apr 7 11:14:27 CEST 2006


Author: auc
Date: Fri Apr  7 11:14:26 2006
New Revision: 25482

Modified:
   pypy/dist/pypy/objspace/constraint/computationspace.py
   pypy/dist/pypy/objspace/constraint/test/test_computationspace.py
   pypy/dist/pypy/objspace/logic.py
Log:
instanciation, variable creation


Modified: pypy/dist/pypy/objspace/constraint/computationspace.py
==============================================================================
--- pypy/dist/pypy/objspace/constraint/computationspace.py	(original)
+++ pypy/dist/pypy/objspace/constraint/computationspace.py	Fri Apr  7 11:14:26 2006
@@ -1,3 +1,4 @@
+from pypy.interpreter.error import OperationError
 from pypy.interpreter.baseobjspace import Wrappable
 from pypy.interpreter import baseobjspace, typedef, gateway
 from pypy.interpreter.gateway import interp2app
@@ -14,13 +15,15 @@
     def w_var(self, w_name, w_domain):
         name = self._space.str_w(w_name)
         assert isinstance(w_domain, W_AbstractDomain)
-        assert name not in self.domains
-        self.domains[name] = w_domain
+        if w_name in self.domains.content:
+            raise OperationError(self._space.w_RuntimeError,
+                                 self._space.wrap("Name already used"))
+        self.domains.content[w_name] = w_domain
 
 
 W_ComputationSpace.typedef = typedef.TypeDef("W_ComputationSpace",
-    var = interp2app(W_ComputationSpace.w_var),
-                                             )
+    var = interp2app(W_ComputationSpace.w_var))
+
 
 def newspace(space):
     return W_ComputationSpace(space)

Modified: pypy/dist/pypy/objspace/constraint/test/test_computationspace.py
==============================================================================
--- pypy/dist/pypy/objspace/constraint/test/test_computationspace.py	(original)
+++ pypy/dist/pypy/objspace/constraint/test/test_computationspace.py	Fri Apr  7 11:14:26 2006
@@ -13,6 +13,8 @@
     def test_var(self):
         cspace = newspace()
         cspace.var("foo", FiniteDomain([1,2,3]))
+        #FIXME: raise the good exc. type
+        raises(Exception, cspace.var, "foo", FiniteDomain([1,2,3]))
 
     
 

Modified: pypy/dist/pypy/objspace/logic.py
==============================================================================
--- pypy/dist/pypy/objspace/logic.py	(original)
+++ pypy/dist/pypy/objspace/logic.py	Fri Apr  7 11:14:26 2006
@@ -760,6 +760,13 @@
 
 W_FiniteDomain = domain.W_FiniteDomain
 
+#------ computation space -------
+
+from pypy.objspace.constraint import computationspace
+all_mms.update(computationspace.all_mms)
+
+W_ComputationSpace = computationspace.W_ComputationSpace
+
 #-- THE SPACE ---------------------------------------
 
 #class UnificationError(w_RuntimeError):
@@ -814,7 +821,10 @@
                  space.wrap(app_bind))
     space.setitem(space.builtin.w_dict, space.wrap('unify'),
                  space.wrap(app_unify))
-    #-- domain -----
+    #-- comp space ---
+    space.setitem(space.builtin.w_dict, space.wrap('newspace'),
+                 space.wrap(computationspace.app_newspace))
+    #-- domain -------
     space.setitem(space.builtin.w_dict, space.wrap('FiniteDomain'),
                  space.wrap(domain.app_make_fd))
     space.setitem(space.builtin.w_dict, space.wrap('intersection'),



More information about the Pypy-commit mailing list