[pypy-svn] r44102 - pypy/branch/prolog-bytecode/pypy/lang/prolog/interpreter

cfbolz at codespeak.net cfbolz at codespeak.net
Thu Jun 7 19:12:17 CEST 2007


Author: cfbolz
Date: Thu Jun  7 19:12:17 2007
New Revision: 44102

Modified:
   pypy/branch/prolog-bytecode/pypy/lang/prolog/interpreter/term.py
Log:
the copy_and_unify methods are no longer needed


Modified: pypy/branch/prolog-bytecode/pypy/lang/prolog/interpreter/term.py
==============================================================================
--- pypy/branch/prolog-bytecode/pypy/lang/prolog/interpreter/term.py	(original)
+++ pypy/branch/prolog-bytecode/pypy/lang/prolog/interpreter/term.py	Thu Jun  7 19:12:17 2007
@@ -39,9 +39,6 @@
     def copy(self, heap, memo):
         raise NotImplementedError("abstract base class")
 
-    def copy_and_unify(self, other, heap, memo):
-        raise NotImplementedError("abstract base class")
-
     def get_unify_hash(self, heap):
         # if two non-var objects return two different numbers
         # they must not be unifiable
@@ -122,18 +119,6 @@
             newvar = memo[self] = heap.newvar()
             return newvar
 
-    def copy_and_unify(self, other, heap, memo):
-        hint(self, concrete=True)
-        self = hint(self, deepfreeze=True)
-        try:
-            seen_value = memo[self]
-        except KeyError:
-            memo[self] = other
-            return other
-        else:
-            seen_value.unify(other, heap)
-            return seen_value
-
     def get_unify_hash(self, heap):
         if heap is not None:
             self = self.dereference(heap)
@@ -201,18 +186,6 @@
         else:
             self.basic_unify(other, heap, occurs_check)
 
-    def copy_and_unify(self, other, heap, memo):
-        other = other.dereference(heap)
-        if isinstance(other, Var):
-            copy = self.copy(heap, memo)
-            other._unify(copy, heap)
-            return copy
-        else:
-            return self.copy_and_basic_unify(other, heap, memo)
-
-    def copy_and_basic_unify(self, other, heap, memo):
-        raise NotImplementedError("abstract base class")
-
 
 class Callable(NonVar):
     __slots__ = ("name", "signature")
@@ -253,14 +226,6 @@
     def copy(self, heap, memo):
         return self
 
-    def copy_and_basic_unify(self, other, heap, memo):
-        hint(self, concrete=True)
-        if isinstance(other, Atom) and (self is other or
-                                        other.name == self.name):
-            return self
-        else:
-            raise UnificationFailed
-
     def get_unify_hash(self, heap):
         name = hint(self.name, promote=True)
         return intmask(hash(name) << TAGBITS | self.TAG)
@@ -305,13 +270,6 @@
     def copy(self, heap, memo):
         return self
 
-    def copy_and_basic_unify(self, other, heap, memo):
-        hint(self, concrete=True)
-        if isinstance(other, Number) and other.num == self.num:
-            return self
-        else:
-            raise UnificationFailed
-
     def __str__(self):
         return repr(self.num)
 
@@ -342,13 +300,6 @@
     def copy(self, heap, memo):
         return self
 
-    def copy_and_basic_unify(self, other, heap, memo):
-        hint(self, concrete=True)
-        if isinstance(other, Float) and other.floatval == self.floatval:
-            return self
-        else:
-            raise UnificationFailed
-
     def get_unify_hash(self, heap):
         #XXX no clue whether this is a good idea...
         m, e = math.frexp(self.floatval)
@@ -385,13 +336,6 @@
     def copy(self, heap, memo):
         return self
 
-    def copy_and_basic_unify(self, other, heap, memo):
-        hint(self, concrete=True)
-        if self is other:
-            return self
-        else:
-            raise UnificationFailed
-
     def get_unify_hash(self, heap):
         return intmask(id(self) << TAGBITS | self.TAG)
 
@@ -445,22 +389,6 @@
             i += 1
         return Term(self.name, newargs, self.signature)
 
-    def copy_and_basic_unify(self, other, heap, memo):
-        hint(self, concrete=True)
-        self = hint(self, deepfreeze=True)
-        if (isinstance(other, Term) and
-            self.signature == other.signature):
-            newargs = [None] * len(self.args)
-            i = 0
-            while i < len(self.args):
-                hint(i, concrete=True)
-                arg = self.args[i].copy_and_unify(other.args[i], heap, memo)
-                newargs[i] = arg
-                i += 1
-            return Term(self.name, newargs, self.signature)
-        else:
-            raise UnificationFailed
-
     def getvalue(self, heap):
         return self._copy_term(_getvalue, heap)
 


More information about the pypy-svn mailing list