[pypy-svn] r44108 - pypy/branch/prolog-bytecode/pypy/lang/prolog/interpreter
cfbolz at codespeak.net
cfbolz at codespeak.net
Thu Jun 7 23:10:53 CEST 2007
Author: cfbolz
Date: Thu Jun 7 23:10:52 2007
New Revision: 44108
Modified:
pypy/branch/prolog-bytecode/pypy/lang/prolog/interpreter/engine.py
pypy/branch/prolog-bytecode/pypy/lang/prolog/interpreter/interpreter.py
pypy/branch/prolog-bytecode/pypy/lang/prolog/interpreter/term.py
Log:
more dead code
Modified: pypy/branch/prolog-bytecode/pypy/lang/prolog/interpreter/engine.py
==============================================================================
--- pypy/branch/prolog-bytecode/pypy/lang/prolog/interpreter/engine.py (original)
+++ pypy/branch/prolog-bytecode/pypy/lang/prolog/interpreter/engine.py Thu Jun 7 23:10:52 2007
@@ -52,9 +52,6 @@
var.binding = val
del self.trail[trails:]
- def discard(self, state):
- pass #XXX for now
-
def newvar(self):
result = Var(self)
return result
@@ -76,25 +73,6 @@
curr = curr.next
return first, copy
- def find_applicable_rule(self, uh2):
- #import pdb;pdb.set_trace()
- while self:
- uh = self.rule.unify_hash
- hint(uh, concrete=True)
- uh = hint(uh, deepfreeze=True)
- j = 0
- while j < len(uh):
- hint(j, concrete=True)
- hash1 = uh[j]
- hash2 = uh2[j]
- if hash1 != 0 and hash2 * (hash2 - hash1) != 0:
- break
- j += 1
- else:
- return self
- self = self.next
- return None
-
def __repr__(self):
return "LinkedRules(%r, %r)" % (self.rule, self.next)
Modified: pypy/branch/prolog-bytecode/pypy/lang/prolog/interpreter/interpreter.py
==============================================================================
--- pypy/branch/prolog-bytecode/pypy/lang/prolog/interpreter/interpreter.py (original)
+++ pypy/branch/prolog-bytecode/pypy/lang/prolog/interpreter/interpreter.py Thu Jun 7 23:10:52 2007
@@ -215,4 +215,3 @@
self.engine.heap.revert(oldstate)
rulechain = rulechain.next
raise error.UnificationFailed
-
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 23:10:52 2007
@@ -9,13 +9,6 @@
DEBUG = False
-TAGBITS = 3
-CURR_TAG = 1
-def tag():
- global CURR_TAG
- CURR_TAG += 1
- assert CURR_TAG <= 2 ** TAGBITS
- return CURR_TAG
def debug_print(*args):
if DEBUG and not we_are_translated():
@@ -39,11 +32,6 @@
def copy(self, 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
- raise NotImplementedError("abstract base class")
-
@specialize.arg(3)
def unify(self, other, heap, occurs_check=False):
raise NotImplementedError("abstract base class")
@@ -68,7 +56,6 @@
error.throw_type_error("evaluable", self)
class Var(PrologObject):
- TAG = 0
STANDARD_ORDER = 0
__slots__ = ('binding', )
@@ -119,14 +106,6 @@
newvar = memo[self] = heap.newvar()
return newvar
- def get_unify_hash(self, heap):
- if heap is not None:
- self = self.dereference(heap)
- if isinstance(self, Var):
- return 0
- return self.get_unify_hash(heap)
- return 0
-
def contains_var(self, var, heap):
self = self.dereference(heap)
if self is var:
@@ -195,12 +174,8 @@
def get_prolog_signature(self):
raise NotImplementedError("abstract base")
- def unify_hash_of_children(self, heap):
- raise NotImplementedError("abstract base")
-
class Atom(Callable):
- TAG = tag()
STANDARD_ORDER = 1
cache = {}
@@ -226,13 +201,6 @@
def copy(self, heap, memo):
return self
- def get_unify_hash(self, heap):
- name = hint(self.name, promote=True)
- return intmask(hash(name) << TAGBITS | self.TAG)
-
- def unify_hash_of_children(self, heap):
- return []
-
def get_prolog_signature(self):
return Term("/", [self, NUMBER_0])
@@ -255,7 +223,6 @@
class Number(NonVar):
- TAG = tag()
STANDARD_ORDER = 2
_immutable_ = True
def __init__(self, num):
@@ -276,16 +243,12 @@
def __repr__(self):
return "Number(%r)" % (self.num, )
- def get_unify_hash(self, heap):
- return intmask(self.num << TAGBITS | self.TAG)
-
def eval_arithmetic(self, engine):
return self
NUMBER_0 = Number(0)
class Float(NonVar):
- TAG = tag()
STANDARD_ORDER = 2
_immutable_ = True
def __init__(self, floatval):
@@ -300,12 +263,6 @@
def copy(self, heap, memo):
return self
- def get_unify_hash(self, heap):
- #XXX no clue whether this is a good idea...
- m, e = math.frexp(self.floatval)
- m = intmask(int(m / 2 * 2 ** (32 - TAGBITS)))
- return intmask(m << TAGBITS | self.TAG)
-
def __str__(self):
return repr(self.floatval)
@@ -322,7 +279,6 @@
class BlackBox(NonVar):
# meant to be subclassed
- TAG = tag()
STANDARD_ORDER = 4
def __init__(self):
pass
@@ -336,10 +292,6 @@
def copy(self, heap, memo):
return self
- def get_unify_hash(self, heap):
- return intmask(id(self) << TAGBITS | self.TAG)
-
-
# helper functions for various Term methods
@@ -347,7 +299,6 @@
return obj.getvalue(heap)
class Term(Callable):
- TAG = tag()
STANDARD_ORDER = 3
_immutable_ = True
def __init__(self, name, args, signature=None):
@@ -403,18 +354,6 @@
else:
return self
- def get_unify_hash(self, heap):
- signature = hint(self.signature, promote=True)
- return intmask(hash(signature) << TAGBITS | self.TAG)
-
- def unify_hash_of_children(self, heap):
- unify_hash = []
- i = 0
- while i < len(self.args):
- unify_hash.append(self.args[i].get_unify_hash(heap))
- i += 1
- return unify_hash
-
def get_prolog_signature(self):
return Term("/", [Atom.newatom(self.name), Number(len(self.args))])
More information about the pypy-svn
mailing list