[pypy-svn] r53243 - in pypy/branch/jit-hotpath/pypy/lang/prolog: builtin interpreter interpreter/test
cfbolz at codespeak.net
cfbolz at codespeak.net
Wed Apr 2 02:28:39 CEST 2008
Author: cfbolz
Date: Wed Apr 2 02:28:39 2008
New Revision: 53243
Modified:
pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/allsolution.py
pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/arithmeticbuiltin.py
pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/atomconstruction.py
pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/control.py
pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/database.py
pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/exception.py
pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/formatting.py
pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/parseraccess.py
pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/register.py
pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/source.py
pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/termconstruction.py
pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/unify.py
pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/arithmetic.py
pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/choice.py
pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/engine.py
pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/helper.py
pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/interactive.py
pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/portal.py
pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/term.py
pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/test/dont_test_translate.py
pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/test/test_engine.py
pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/test/test_jit.py
pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/test/test_parsing.py
pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/test/test_unification.py
pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/test/tool.py
pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/translatedmain.py
Log:
whack a bit at the prolog interpreter, trying to make it jittable
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/allsolution.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/allsolution.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/allsolution.py Wed Apr 2 02:28:39 2008
@@ -11,22 +11,23 @@
self.template = template
def _call(self, engine):
- clone = self.template.getvalue(engine.heap)
+ clone = self.template.getvalue(engine)
self.found.append(clone)
raise error.UnificationFailed()
def impl_findall(engine, template, goal, bag):
- oldstate = engine.heap.branch()
+ oldstate = engine.branch()
collector = FindallContinuation(template)
try:
engine.call(goal, collector)
except error.UnificationFailed:
- engine.heap.revert(oldstate)
+ engine.revert(oldstate)
result = term.Atom.newatom("[]")
for i in range(len(collector.found) - 1, -1, -1):
copy = collector.found[i]
d = {}
- copy = copy.copy(engine.heap, d)
+ copy = copy.copy(engine, d)
result = term.Term(".", [copy, result])
- bag.unify(result, engine.heap)
+ bag.unify(result, engine)
+impl_findall._look_inside_me_ = False
expose_builtin(impl_findall, "findall", unwrap_spec=['raw', 'callable', 'raw'])
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/arithmeticbuiltin.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/arithmeticbuiltin.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/arithmeticbuiltin.py Wed Apr 2 02:28:39 2008
@@ -9,13 +9,13 @@
def impl_between(engine, lower, upper, varorint, continuation):
if isinstance(varorint, term.Var):
for i in range(lower, upper):
- oldstate = engine.heap.branch()
+ oldstate = engine.branch()
try:
- varorint.unify(term.Number(i), engine.heap)
+ varorint.unify(term.Number(i), engine)
return continuation.call(engine, choice_point=True)
except error.UnificationFailed:
- engine.heap.revert(oldstate)
- varorint.unify(term.Number(upper), engine.heap)
+ engine.revert(oldstate)
+ varorint.unify(term.Number(upper), engine)
return continuation.call(engine, choice_point=False)
else:
integer = helper.unwrap_int(varorint)
@@ -26,8 +26,7 @@
handles_continuation=True)
def impl_is(engine, var, num):
- var.unify(num, engine.heap)
-impl_is._look_inside_me_ = True
+ var.unify(num, engine)
expose_builtin(impl_is, "is", unwrap_spec=["raw", "arithmetic"])
for ext, prolog, python in [("eq", "=:=", "=="),
@@ -57,6 +56,7 @@
eq = n1 %s n2
if not eq:
raise error.UnificationFailed()""" % (ext, python, python)).compile()
- expose_builtin(globals()["impl_arith_%s" % (ext, )], prolog,
+ func = globals()["impl_arith_%s" % (ext, )]
+ expose_builtin(func, prolog,
unwrap_spec=["arithmetic", "arithmetic"])
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/atomconstruction.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/atomconstruction.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/atomconstruction.py Wed Apr 2 02:28:39 2008
@@ -11,13 +11,13 @@
# nondeterministic splitting of result
r = helper.convert_to_str(result)
for i in range(len(r) + 1):
- oldstate = engine.heap.branch()
+ oldstate = engine.branch()
try:
- a1.unify(term.Atom(r[:i]), engine.heap)
- a2.unify(term.Atom(r[i:]), engine.heap)
+ a1.unify(term.Atom(r[:i]), engine)
+ a2.unify(term.Atom(r[i:]), engine)
return continuation.call(engine, choice_point=True)
except error.UnificationFailed:
- engine.heap.revert(oldstate)
+ engine.revert(oldstate)
raise error.UnificationFailed()
else:
s2 = helper.convert_to_str(a2)
@@ -25,7 +25,7 @@
if r.endswith(s2):
stop = len(r) - len(s2)
assert stop > 0
- a1.unify(term.Atom(r[:stop]), engine.heap)
+ a1.unify(term.Atom(r[:stop]), engine)
else:
raise error.UnificationFailed()
else:
@@ -33,12 +33,12 @@
if isinstance(a2, term.Var):
r = helper.convert_to_str(result)
if r.startswith(s1):
- a2.unify(term.Atom(r[len(s1):]), engine.heap)
+ a2.unify(term.Atom(r[len(s1):]), engine)
else:
raise error.UnificationFailed()
else:
s2 = helper.convert_to_str(a2)
- result.unify(term.Atom(s1 + s2), engine.heap)
+ result.unify(term.Atom(s1 + s2), engine)
return continuation.call(engine, choice_point=False)
expose_builtin(impl_atom_concat, "atom_concat",
unwrap_spec=["obj", "obj", "obj"],
@@ -47,7 +47,7 @@
def impl_atom_length(engine, s, length):
if not (isinstance(length, term.Var) or isinstance(length, term.Number)):
error.throw_type_error("integer", length)
- term.Number(len(s)).unify(length, engine.heap)
+ term.Number(len(s)).unify(length, engine)
expose_builtin(impl_atom_length, "atom_length", unwrap_spec = ["atom", "obj"])
def impl_sub_atom(engine, s, before, length, after, sub, continuation):
@@ -70,7 +70,7 @@
if startbefore < 0:
startbefore = 0
stopbefore = len(s) + 1
- oldstate = engine.heap.branch()
+ oldstate = engine.branch()
if not isinstance(sub, term.Var):
s1 = helper.unwrap_atom(sub)
if len(s1) >= stoplength or len(s1) < startlength:
@@ -83,12 +83,12 @@
if b < 0:
break
start = b + 1
- before.unify(term.Number(b), engine.heap)
- after.unify(term.Number(len(s) - len(s1) - b), engine.heap)
- length.unify(term.Number(len(s1)), engine.heap)
+ before.unify(term.Number(b), engine)
+ after.unify(term.Number(len(s) - len(s1) - b), engine)
+ length.unify(term.Number(len(s1)), engine)
return continuation.call(engine, choice_point=True)
except:
- engine.heap.revert(oldstate)
+ engine.revert(oldstate)
raise
except error.UnificationFailed:
pass
@@ -100,13 +100,13 @@
continue
try:
try:
- before.unify(term.Number(b), engine.heap)
- after.unify(term.Number(len(s) - l - b), engine.heap)
- length.unify(term.Number(l), engine.heap)
- sub.unify(term.Atom(s[b:b + l]), engine.heap)
+ before.unify(term.Number(b), engine)
+ after.unify(term.Number(len(s) - l - b), engine)
+ length.unify(term.Number(l), engine)
+ sub.unify(term.Atom(s[b:b + l]), engine)
return continuation.call(engine, choice_point=True)
except:
- engine.heap.revert(oldstate)
+ engine.revert(oldstate)
raise
except error.UnificationFailed:
pass
@@ -119,14 +119,14 @@
continue
try:
try:
- before.unify(term.Number(b), engine.heap)
- after.unify(term.Number(a), engine.heap)
- length.unify(term.Number(l), engine.heap)
- sub.unify(term.Atom(s[b:b + l]), engine.heap)
+ before.unify(term.Number(b), engine)
+ after.unify(term.Number(a), engine)
+ length.unify(term.Number(l), engine)
+ sub.unify(term.Atom(s[b:b + l]), engine)
return continuation.call(engine, choice_point=True)
return None
except:
- engine.heap.revert(oldstate)
+ engine.revert(oldstate)
raise
except error.UnificationFailed:
pass
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/control.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/control.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/control.py Wed Apr 2 02:28:39 2008
@@ -33,7 +33,7 @@
self.continuation = continuation
def _call(self, engine):
- next_call = self.next_call.dereference(engine.heap)
+ next_call = self.next_call.dereference(engine)
next_call = helper.ensure_callable(next_call)
return engine.call(next_call, self.continuation, choice_point=False)
@@ -46,11 +46,11 @@
handles_continuation=True)
def impl_or(engine, call1, call2, continuation):
- oldstate = engine.heap.branch()
+ oldstate = engine.branch()
try:
return engine.call(call1, continuation)
except error.UnificationFailed:
- engine.heap.revert(oldstate)
+ engine.revert(oldstate)
return engine.call(call2, continuation, choice_point=False)
expose_builtin(impl_or, ";", unwrap_spec=["callable", "callable"],
@@ -68,11 +68,11 @@
expose_builtin(impl_not, ["not", "\\+"], unwrap_spec=["callable"])
def impl_if(engine, if_clause, then_clause, continuation):
- oldstate = engine.heap.branch()
+ oldstate = engine.branch()
try:
engine.call(if_clause)
except error.UnificationFailed:
- engine.heap.revert(oldstate)
+ engine.revert(oldstate)
raise
return engine.call(helper.ensure_callable(then_clause), continuation,
choice_point=False)
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/database.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/database.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/database.py Wed Apr 2 02:28:39 2008
@@ -19,11 +19,11 @@
expose_builtin(impl_abolish, "abolish", unwrap_spec=["obj"])
def impl_assert(engine, rule):
- engine.add_rule(rule.getvalue(engine.heap))
+ engine.add_rule(rule.getvalue(engine))
expose_builtin(impl_assert, ["assert", "assertz"], unwrap_spec=["callable"])
def impl_asserta(engine, rule):
- engine.add_rule(rule.getvalue(engine.heap), end=False)
+ engine.add_rule(rule.getvalue(engine), end=False)
expose_builtin(impl_asserta, "asserta", unwrap_spec=["callable"])
@@ -46,14 +46,14 @@
rulechain = function.rulechain
while rulechain:
rule = rulechain.rule
- oldstate = engine.heap.branch()
+ oldstate = engine.branch()
# standardizing apart
try:
- deleted_body = rule.clone_and_unify_head(engine.heap, head)
+ deleted_body = rule.clone_and_unify_head(engine, head)
if body is not None:
- body.unify(deleted_body, engine.heap)
+ body.unify(deleted_body, engine)
except error.UnificationFailed:
- engine.heap.revert(oldstate)
+ engine.revert(oldstate)
else:
if function.rulechain is rulechain:
if rulechain.next is None:
@@ -66,6 +66,7 @@
rulechain = rulechain.next
else:
raise error.UnificationFailed()
+impl_retract._look_inside_me_ = False
expose_builtin(impl_retract, "retract", unwrap_spec=["callable"])
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/exception.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/exception.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/exception.py Wed Apr 2 02:28:39 2008
@@ -8,29 +8,30 @@
def impl_catch(engine, goal, catcher, recover, continuation):
catching_continuation = enginemod.LimitedScopeContinuation(continuation)
- old_state = engine.heap.branch()
+ old_state = engine.branch()
try:
return engine.call(goal, catching_continuation)
except error.CatchableError, e:
if not catching_continuation.scope_active:
raise
- exc_term = e.term.getvalue(engine.heap)
- engine.heap.revert(old_state)
+ exc_term = e.term.getvalue(engine)
+ engine.revert(old_state)
d = {}
- exc_term = exc_term.copy(engine.heap, d)
+ exc_term = exc_term.copy(engine, d)
try:
impl_ground(engine, exc_term)
except error.UnificationFailed:
raise error.UncatchableError(
"not implemented: catching of non-ground terms")
try:
- catcher.unify(exc_term, engine.heap)
+ catcher.unify(exc_term, engine)
except error.UnificationFailed:
if isinstance(e, error.UserError):
raise error.UserError(exc_term)
if isinstance(e, error.CatchableError):
raise error.CatchableError(exc_term)
return engine.call(recover, continuation, choice_point=False)
+impl_catch._look_inside_me_ = False
expose_builtin(impl_catch, "catch", unwrap_spec=["callable", "obj", "callable"],
handles_continuation=True)
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/formatting.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/formatting.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/formatting.py Wed Apr 2 02:28:39 2008
@@ -147,10 +147,12 @@
def impl_write_term(engine, term, options):
f = TermFormatter.from_option_list(engine, options)
os.write(1, f.format(term)) # XXX use streams
+impl_write_term._look_inside_me_ = False
expose_builtin(impl_write_term, "write_term", unwrap_spec=["concrete", "list"])
def impl_nl(engine):
os.write(1, "\n") # XXX use streams
+impl_nl._look_inside_me_ = False
expose_builtin(impl_nl, "nl", unwrap_spec=[])
def impl_write(engine, term):
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/parseraccess.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/parseraccess.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/parseraccess.py Wed Apr 2 02:28:39 2008
@@ -9,14 +9,14 @@
for prec, allops in engine.getoperations():
for form, ops in allops:
for op in ops:
- oldstate = engine.heap.branch()
+ oldstate = engine.branch()
try:
- precedence.unify(term.Number(prec), engine.heap)
- typ.unify(term.Atom.newatom(form), engine.heap)
- name.unify(term.Atom(op), engine.heap)
+ precedence.unify(term.Number(prec), engine)
+ typ.unify(term.Atom.newatom(form), engine)
+ name.unify(term.Atom(op), engine)
return continuation.call(engine, choice_point=True)
except error.UnificationFailed:
- engine.heap.revert(oldstate)
+ engine.revert(oldstate)
raise error.UnificationFailed()
expose_builtin(impl_current_op, "current_op", unwrap_spec=["obj", "obj", "obj"],
handles_continuation=True)
@@ -53,6 +53,7 @@
else:
operations.append((precedence, [(typ, [name])]))
engine.parser = parsing.make_parser_at_runtime(engine.operations)
+impl_op._look_inside_me_ = False
expose_builtin(impl_op, "op", unwrap_spec=["int", "atom", "atom"])
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/register.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/register.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/register.py Wed Apr 2 02:28:39 2008
@@ -42,10 +42,10 @@
varname = "var%s" % (i, )
subargs.append(varname)
if spec in ("obj", "callable", "int", "atom", "arithmetic"):
- code.append(" %s = query.args[%s].dereference(engine.heap)" %
+ code.append(" %s = query.args[%s].dereference(engine)" %
(varname, i))
elif spec in ("concrete", "list"):
- code.append(" %s = query.args[%s].getvalue(engine.heap)" %
+ code.append(" %s = query.args[%s].getvalue(engine)" %
(varname, i))
if spec in ("int", "atom", "arithmetic", "list"):
code.append(
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/source.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/source.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/source.py Wed Apr 2 02:28:39 2008
@@ -28,6 +28,7 @@
finally:
os.close(fd)
engine.runstring(file_content)
+impl_consult._look_inside_me_ = False
expose_builtin(impl_consult, "consult", unwrap_spec=["obj"])
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/termconstruction.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/termconstruction.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/termconstruction.py Wed Apr 2 02:28:39 2008
@@ -7,11 +7,11 @@
def impl_functor(engine, t, functor, arity):
if helper.is_atomic(t):
- functor.unify(t, engine.heap)
- arity.unify(term.Number(0), engine.heap)
+ functor.unify(t, engine)
+ arity.unify(term.Number(0), engine)
elif isinstance(t, term.Term):
- functor.unify(term.Atom(t.name), engine.heap)
- arity.unify(term.Number(len(t.args)), engine.heap)
+ functor.unify(term.Atom(t.name), engine)
+ arity.unify(term.Number(len(t.args)), engine)
elif isinstance(t, term.Var):
if isinstance(functor, term.Var):
error.throw_instantiation_error()
@@ -21,12 +21,12 @@
else:
functor = helper.ensure_atomic(functor)
if a == 0:
- t.unify(helper.ensure_atomic(functor), engine.heap)
+ t.unify(helper.ensure_atomic(functor), engine)
else:
name = helper.unwrap_atom(functor)
t.unify(
term.Term(name, [term.Var() for i in range(a)]),
- engine.heap)
+ engine)
expose_builtin(impl_functor, "functor", unwrap_spec=["obj", "obj", "obj"])
def impl_arg(engine, first, second, third, continuation):
@@ -39,13 +39,13 @@
if isinstance(first, term.Var):
for i in range(len(second.args)):
arg = second.args[i]
- oldstate = engine.heap.branch()
+ oldstate = engine.branch()
try:
- third.unify(arg, engine.heap)
- first.unify(term.Number(i + 1), engine.heap)
+ third.unify(arg, engine)
+ first.unify(term.Number(i + 1), engine)
return continuation.call(engine, choice_point=True)
except error.UnificationFailed:
- engine.heap.revert(oldstate)
+ engine.revert(oldstate)
raise error.UnificationFailed()
elif isinstance(first, term.Number):
num = first.num
@@ -56,7 +56,7 @@
if num > len(second.args):
raise error.UnificationFailed()
arg = second.args[num - 1]
- third.unify(arg, engine.heap)
+ third.unify(arg, engine)
else:
error.throw_type_error("integer", first)
return continuation.call(engine, choice_point=False)
@@ -71,9 +71,9 @@
l = [first]
u1 = helper.wrap_list(l)
if not isinstance(second, term.Var):
- u1.unify(second, engine.heap)
+ u1.unify(second, engine)
else:
- u1.unify(second, engine.heap)
+ u1.unify(second, engine)
else:
if isinstance(second, term.Var):
error.throw_instantiation_error()
@@ -82,13 +82,15 @@
head = l[0]
if not isinstance(head, term.Atom):
error.throw_type_error("atom", head)
- term.Term(head.name, l[1:]).unify(first, engine.heap)
+ term.Term(head.name, l[1:]).unify(first, engine)
expose_builtin(impl_univ, "=..", unwrap_spec=["obj", "obj"])
def impl_copy_term(engine, interm, outterm):
d = {}
- copy = interm.copy(engine.heap, d)
- outterm.unify(copy, engine.heap)
+ copy = interm.copy(engine, d)
+ outterm.unify(copy, engine)
+impl_copy_term._look_inside_me_ = False
expose_builtin(impl_copy_term, "copy_term", unwrap_spec=["obj", "obj"])
+
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/unify.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/unify.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/builtin/unify.py Wed Apr 2 02:28:39 2008
@@ -8,21 +8,21 @@
# comparison and unification of terms
def impl_unify(engine, obj1, obj2):
- obj1.unify(obj2, engine.heap)
+ obj1.unify(obj2, engine)
expose_builtin(impl_unify, "=", unwrap_spec=["raw", "raw"])
def impl_unify_with_occurs_check(engine, obj1, obj2):
- obj1.unify(obj2, engine.heap, occurs_check=True)
+ obj1.unify(obj2, engine, occurs_check=True)
expose_builtin(impl_unify_with_occurs_check, "unify_with_occurs_check",
unwrap_spec=["raw", "raw"])
def impl_does_not_unify(engine, obj1, obj2):
try:
- branch = engine.heap.branch()
+ branch = engine.branch()
try:
- obj1.unify(obj2, engine.heap)
+ obj1.unify(obj2, engine)
finally:
- engine.heap.revert(branch)
+ engine.revert(branch)
except error.UnificationFailed:
return
raise error.UnificationFailed()
@@ -37,7 +37,7 @@
("ge", "@>=", "!= -1")]:
exec py.code.Source("""
def impl_standard_comparison_%s(engine, obj1, obj2):
- c = term.cmp_standard_order(obj1, obj2, engine.heap)
+ c = term.cmp_standard_order(obj1, obj2, engine)
if not c %s:
raise error.UnificationFailed()""" % (ext, python)).compile()
expose_builtin(globals()["impl_standard_comparison_%s" % (ext, )], prolog,
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/arithmetic.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/arithmetic.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/arithmetic.py Wed Apr 2 02:28:39 2008
@@ -85,6 +85,7 @@
code.end_block("else")
code.emit("return norm_float(term.Float(%s))" % pattern)
code.end_block("def")
+ code.emit("general_%s._look_inside_me_ = False" % (name, ))
miniglobals = globals().copy()
exec py.code.Source(code.tostring()).compile() in miniglobals
result = miniglobals["prolog_" + name]
@@ -95,7 +96,6 @@
def eval_arithmetic(engine, query):
return query.eval_arithmetic(engine)
-eval_arithmetic._look_inside_me_ = True
def norm_float(obj):
v = obj.floatval
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/choice.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/choice.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/choice.py Wed Apr 2 02:28:39 2008
@@ -29,7 +29,7 @@
def __init__(self, engine, continuation, stop_cut=False):
self._init_current()
self.engine = engine
- self.oldstate = engine.heap.branch()
+ self.oldstate = engine.branch()
self.continuation = continuation
self.stop_cut = stop_cut
self.any_choice = True
@@ -50,7 +50,7 @@
else:
self.exception = e
except UnificationFailed:
- self.engine.heap.revert(self.oldstate)
+ self.engine.revert(self.oldstate)
if last:
raise
return
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/engine.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/engine.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/engine.py Wed Apr 2 02:28:39 2008
@@ -38,38 +38,39 @@
self.scope_active = False
return self.continuation.call(engine, choice_point=False)
-class Heap(object):
- def __init__(self):
+class TrailChunk(object):
+ def __init__(self, prev=None):
self.trail = []
+ self.prev = prev
+
+class Heap(object):
+ _mixin_ = True
+
def reset(self):
- self.trail = []
- self.last_branch = 0
+ self.current_chunk = TrailChunk()
+ __init__ = reset
def add_trail(self, var):
- self.trail.append((var, var.binding))
+ self.current_chunk.trail.append((var, var.binding))
def branch(self):
- return len(self.trail)
+ result = self.current_chunk
+ self.current_chunk = TrailChunk(self.current_chunk)
+ return result
def revert(self, state):
- trails = state
- for i in range(len(self.trail) - 1, trails - 1, -1):
- var, val = self.trail[i]
- var.binding = val
- del self.trail[trails:]
+ curr = self.current_chunk
+ while curr is not state:
+ for i in range(len(curr.trail) - 1, -1, -1):
+ var, val = curr.trail[i]
+ var.binding = val
+ curr = curr.prev
+ self.current_chunk = TrailChunk(curr)
def discard(self, state):
pass #XXX for now
- def maxvar(self):
- XXX
- return self.needed_vars
-
- def newvar(self):
- result = Var(self)
- return result
-
class LinkedRules(object):
_immutable_ = True
def __init__(self, rule, next=None):
@@ -134,15 +135,14 @@
last.next = rulechain.next
-class Engine(object):
+class Engine(Heap):
+ _virtualizable_ = True
+
def __init__(self):
- self.heap = Heap()
+ self.reset()
self.signature2function = {}
self.parser = None
self.operations = None
- #XXX circular imports hack
- from pypy.lang.prolog.builtin import builtins_list
- globals()['unrolling_builtins'] = unrolling_iterable(builtins_list)
def add_rule(self, rule, end=True):
from pypy.lang.prolog import builtin
@@ -199,30 +199,39 @@
def _call(self, query, continuation):
signature = query.signature
- from pypy.lang.prolog.builtin import builtins
- builtins = hint(builtins, deepfreeze=True)
signature = hint(signature, promote=True)
- for bsig, builtin in unrolling_builtins:
- if signature == bsig:
- return builtin.call(self, query, continuation)
+ builtin = _jit_builtin_lookup(signature)
+ if builtin is not None:
+ return builtin.call(self, query, continuation)
return self.user_call(query, continuation, choice_point=False)
- def main_loop(self, where, query, continuation, rule=None):
+ def jit_main_loop(self, where, query, continuation, rule=None):
next = (DONE, None, None, None)
- hint(where, concrete=True)
- hint(rule, concrete=True)
while 1:
+ myjitdriver.jit_merge_point(where=where, continuation=continuation,
+ query=query, rule=rule, _self=self,
+ next=next)
+ hint(where, concrete=True)
+ hint(rule, concrete=True)
if where == DONE:
return next
- next = self.dispatch_bytecode(where, query, continuation, rule)
+ next = self.dispatch_bytecode(next, where, query, continuation, rule)
where, query, continuation, rule = next
where = hint(where, promote=True)
+ rule = hint(rule, promote=True)
- def dispatch_bytecode(self, where, query, continuation, rule):
+ def main_loop(self, where, query, continuation, rule=None):
+ return self.jit_main_loop(where, query, continuation, rule)
+ main_loop._look_inside_me_ = False
+
+ def dispatch_bytecode(self, next, where, query, continuation, rule):
if where == CALL:
next = self._call(query, continuation)
elif where == TRY_RULE:
- rule = hint(rule, promote=True)
+ # XXX seems a slightly strange place to put it
+ myjitdriver.can_enter_jit(where=where, continuation=continuation,
+ query=query, rule=rule, _self=self,
+ next=next)
next = self._try_rule(rule, query, continuation)
elif where == USER_CALL:
next = self._user_call(query, continuation)
@@ -233,13 +242,10 @@
raise Exception("unknown bytecode")
return next
- @purefunction
- def _jit_lookup(self, signature):
+ def _lookup(self, signature):
signature2function = self.signature2function
- function = signature2function.get(signature, None)
- if function is None:
- signature2function[signature] = function = Function()
- return function
+ signature2function = hint(signature2function, promote=True)
+ return _jit_lookup(signature2function, signature)
def user_call(self, query, continuation, choice_point=True):
if not choice_point:
@@ -248,21 +254,21 @@
def _user_call(self, query, continuation):
signature = hint(query.signature, promote=True)
- function = self._jit_lookup(signature)
+ function = self._lookup(signature)
startrulechain = function.rulechain
startrulechain = hint(startrulechain, promote=True)
if startrulechain is None:
error.throw_existence_error(
"procedure", query.get_prolog_signature())
- unify_hash = query.unify_hash_of_children(self.heap)
+ unify_hash = query.unify_hash_of_children(self)
rulechain = startrulechain.find_applicable_rule(unify_hash)
if rulechain is None:
# none of the rules apply
raise UnificationFailed()
rule = rulechain.rule
rulechain = rulechain.next
- oldstate = self.heap.branch()
+ oldstate = self.branch()
while 1:
if rulechain is not None:
rulechain = rulechain.find_applicable_rule(unify_hash)
@@ -274,10 +280,10 @@
continuation = LimitedScopeContinuation(continuation)
try:
result = self.try_rule(rule, query, continuation)
- self.heap.discard(oldstate)
+ self.discard(oldstate)
return result
except UnificationFailed:
- self.heap.revert(oldstate)
+ self.revert(oldstate)
except CutException, e:
if continuation.scope_active:
return self.continue_after_cut(e.continuation,
@@ -291,11 +297,11 @@
result = self.try_rule(rule, query, continuation,
choice_point=choice_point,
inline=inline)
- self.heap.discard(oldstate)
+ self.discard(oldstate)
return result
except UnificationFailed:
assert choice_point
- self.heap.revert(oldstate)
+ self.revert(oldstate)
rule = rulechain.rule
rulechain = rulechain.next
@@ -307,9 +313,8 @@
def _try_rule(self, rule, query, continuation):
rule = hint(rule, deepfreeze=True)
- hint(self, concrete=True)
# standardizing apart
- nextcall = rule.clone_and_unify_head(self.heap, query)
+ nextcall = rule.clone_and_unify_head(self, query)
if nextcall is not None:
return self.call(nextcall, continuation, choice_point=False)
else:
@@ -338,5 +343,24 @@
return self.operations
+ at purefunction
+def _jit_builtin_lookup(signature):
+ from pypy.lang.prolog.builtin import builtins
+ return builtins.get(signature, None)
+
+
+ at purefunction
+def _jit_lookup(signature2function, signature):
+ function = signature2function.get(signature, None)
+ if function is None:
+ signature2function[signature] = function = Function()
+ return function
+
+class MyJitDriver(JitDriver):
+ reds = ['continuation', 'query', 'next', '_self']
+ greens = ['where', 'rule']
+
+ def on_enter_jit(self, invariant, reds, where, rule):
+ reds._self.branch()
-
+myjitdriver = MyJitDriver()
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/helper.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/helper.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/helper.py Wed Apr 2 02:28:39 2008
@@ -25,7 +25,6 @@
def is_callable(var, engine):
return isinstance(var, term.Callable)
-is_callable._look_inside_me_ = True
def ensure_callable(var):
if isinstance(var, term.Var):
@@ -34,7 +33,6 @@
return var
else:
error.throw_type_error("callable", var)
-ensure_callable._look_inside_me_ = True
def unwrap_int(obj):
if isinstance(obj, term.Number):
@@ -49,7 +47,6 @@
if isinstance(obj, term.Atom):
return obj.name
error.throw_type_error('atom', obj)
-unwrap_atom._look_inside_me_ = True
def unwrap_predicate_indicator(predicate):
if not isinstance(predicate, term.Term):
@@ -79,6 +76,10 @@
elif isinstance(obj, term.Number):
return str(obj.num)
elif isinstance(obj, term.Float):
- return str(obj.floatval)
+ return convert_float_to_str(obj)
error.throw_type_error("atomic", obj)
+
+def convert_float_to_str(obj):
+ return str(obj.floatval)
+convert_float_to_str._look_inside_me_ = False
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/interactive.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/interactive.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/interactive.py Wed Apr 2 02:28:39 2008
@@ -59,7 +59,7 @@
f = TermFormatter(engine, quoted=True, max_depth=10)
vars = var_to_pos.items()
vars.sort()
- heap = engine.heap
+ heap = engine
for var, real_var in vars:
if var.startswith("_"):
continue
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/portal.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/portal.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/portal.py Wed Apr 2 02:28:39 2008
@@ -1,66 +1,20 @@
from pypy.jit.hintannotator.policy import ManualGraphPolicy
from pypy.lang.prolog.interpreter import term, engine, helper
from pypy.translator.translator import graphof
-from pypy.annotation.specialize import getuniquenondirectgraph
forbidden_modules = {'pypy.lang.prolog.interpreter.parser': True,
}
-good_modules = {'pypy.lang.prolog.builtin.control': True,
- 'pypy.lang.prolog.builtin.register': True
- }
-
-
-PORTAL = engine.Engine.portal_try_rule.im_func
class PyrologHintAnnotatorPolicy(ManualGraphPolicy):
- PORTAL = PORTAL
+ hotpath = True
+
def look_inside_graph_of_module(self, graph, func, mod):
if mod in forbidden_modules:
return False
- if mod in good_modules:
- return True
- if mod.startswith("pypy.lang.prolog"):
- return False
return True
- def fill_timeshift_graphs(self):
- import pypy
- for cls in [term.Var, term.Term, term.Number, term.Atom]:
- self.seegraph(cls.copy)
- self.seegraph(cls.__init__)
- self.seegraph(cls.copy_and_unify)
- for cls in [term.Term, term.Number, term.Atom]:
- self.seegraph(cls.copy_and_basic_unify)
- self.seegraph(cls.dereference)
- self.seegraph(cls.copy_and_basic_unify)
- for cls in [term.Var, term.Term, term.Number, term.Atom]:
- self.seegraph(cls.get_unify_hash)
- self.seegraph(cls.eval_arithmetic)
- for cls in [term.Callable, term.Atom, term.Term]:
- self.seegraph(cls.get_prolog_signature)
- self.seegraph(cls.unify_hash_of_children)
- self.seegraph(PORTAL)
- self.seegraph(engine.Heap.newvar)
- self.seegraph(term.Rule.clone_and_unify_head)
- self.seegraph(engine.Engine.call)
- self.seegraph(engine.Engine._call)
- self.seegraph(engine.Engine.user_call)
- self.seegraph(engine.Engine._user_call)
- self.seegraph(engine.Engine.try_rule)
- self.seegraph(engine.Engine._try_rule)
- self.seegraph(engine.Engine.main_loop)
- self.seegraph(engine.Engine.dispatch_bytecode)
- self.seegraph(engine.LinkedRules.find_applicable_rule)
- for method in "branch revert discard newvar extend maxvar".split():
- self.seegraph(getattr(engine.Heap, method))
- self.seegraph(engine.Continuation.call)
- for cls in [engine.Continuation, engine.LimitedScopeContinuation,
- pypy.lang.prolog.builtin.control.AndContinuation]:
- self.seegraph(cls._call)
- for function in "".split():
- self.seegraph(getattr(helper, function))
def get_portal(drv):
t = drv.translator
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/term.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/term.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/term.py Wed Apr 2 02:28:39 2008
@@ -78,7 +78,7 @@
__slots__ = ('binding', )
cache = {}
- def __init__(self, heap=None):
+ def __init__(self):
self.binding = None
@specialize.arg(3)
@@ -120,7 +120,7 @@
try:
return memo[self]
except KeyError:
- newvar = memo[self] = heap.newvar()
+ newvar = memo[self] = Var()
return newvar
def copy_and_unify(self, other, heap, memo):
@@ -160,7 +160,7 @@
return self is other
def eval_arithmetic(self, engine):
- self = self.dereference(engine.heap)
+ self = self.dereference(engine)
if isinstance(self, Var):
error.throw_instantiation_error()
return self.eval_arithmetic(engine)
@@ -318,6 +318,8 @@
TAG = tag()
STANDARD_ORDER = 2
_immutable_ = True
+
+ floatval = 0.0
def __init__(self, floatval):
self.floatval = floatval
@@ -342,6 +344,7 @@
m, e = math.frexp(self.floatval)
m = intmask(int(m / 2 * 2 ** (32 - TAGBITS)))
return intmask(m << TAGBITS | self.TAG)
+ get_unify_hash._look_inside_me_ = False
def __str__(self):
return repr(self.floatval)
@@ -387,9 +390,6 @@
# helper functions for various Term methods
-def _clone(obj, offset):
- return obj.clone(offset)
-
def _getvalue(obj, heap):
return obj.getvalue(heap)
@@ -538,6 +538,7 @@
memo = {}
h2 = self.head
hint(h2, concrete=True)
+ h2 = hint(h2, deepfreeze=True)
if isinstance(h2, Term):
assert isinstance(head, Term)
i = 0
@@ -604,3 +605,4 @@
elif isinstance(obj2, Float):
return rcmp(obj1.floatval, obj2.floatval)
assert 0
+cmp_standard_order._look_inside_me_ = False
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/test/dont_test_translate.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/test/dont_test_translate.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/test/dont_test_translate.py Wed Apr 2 02:28:39 2008
@@ -39,7 +39,7 @@
def run():
e.run(t1)
e.run(t2)
- v0 = e.heap.getvar(0)
+ v0 = e.getvar(0)
if isinstance(v0, Atom):
return v0.name
return "no!"
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/test/test_engine.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/test/test_engine.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/test/test_engine.py Wed Apr 2 02:28:39 2008
@@ -12,7 +12,7 @@
""")
t, vars = get_query_and_vars("f(X).")
e.run(t)
- assert vars['X'].dereference(e.heap).name == "a"
+ assert vars['X'].dereference(e).name == "a"
def test_and():
e = get_engine("""
@@ -24,7 +24,7 @@
e.run(parse_query_term("f(a, c)."))
t, vars = get_query_and_vars("f(X, c).")
e.run(t)
- assert vars['X'].dereference(e.heap).name == "a"
+ assert vars['X'].dereference(e).name == "a"
def test_and_long():
e = get_engine("""
@@ -56,7 +56,7 @@
e.run(parse_query_term("num(succ(0))."))
t, vars = get_query_and_vars("num(X).")
e.run(t)
- assert vars['X'].dereference(e.heap).num == 0
+ assert vars['X'].dereference(e).num == 0
e.run(parse_query_term("add(0, 0, 0)."))
py.test.raises(UnificationFailed, e.run, parse_query_term("""
add(0, 0, succ(0))."""))
@@ -93,7 +93,7 @@
""")
t, vars = get_query_and_vars("f(a, b, Z).")
e.run(t)
- assert vars['Z'].dereference(e.heap).name == "a"
+ assert vars['Z'].dereference(e).name == "a"
f = collect_all(e, "X = 1; X = 2.")
assert len(f) == 2
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/test/test_jit.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/test/test_jit.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/test/test_jit.py Wed Apr 2 02:28:39 2008
@@ -1,34 +1,42 @@
import py
-py.test.skip("port me")
-from pypy.jit.timeshifter.test.test_portal import PortalTest, P_NOVIRTUAL
+from pypy.rlib.debug import ll_assert
+from pypy.jit.rainbow.test import test_hotpath
from pypy.lang.prolog.interpreter import portal
from pypy.lang.prolog.interpreter import engine, term
from pypy.lang.prolog.interpreter.parsing import parse_query_term, get_engine
+py.test.skip("fix me")
POLICY = portal.PyrologHintAnnotatorPolicy()
-
-class TestPortal(PortalTest):
+class TestPortal(test_hotpath.HotPathTest):
small = False
def test_simple(self):
- e = get_engine("""
- f(x, y).
- f(a(X), b(b(Y))) :- f(X, Y).
- """)
- X = e.heap.newvar()
- Y = e.heap.newvar()
+ X = term.Var()
+ Y = term.Var()
larger = term.Term(
- "f", [term.Term("a", [X]), term.Term("b", [term.Term("b", [Y])])])
+ "h", [term.Number(100), X])
+ e = get_engine("""
+ f(X) :- h(X, _).
+ h(0, foo).
+ h(X, Y) :- Z is X - 1, h(Z, Y).
+ """)
+ signature2function = e.signature2function
+ parser = e.parser
+ operations = e.operations
def main(n):
- e.heap.reset()
+ # XXX workaround for problems with prebuilt virtualizables
+ e = engine.Engine()
+ e.signature2function = signature2function
+ e.parser = parser
+ e.operations = operations
if n == 0:
- e.call(term.Term("f", [X, Y]))
- return isinstance(X.dereference(e.heap), term.Atom)
+ e.call(term.Term("h", [term.Number(2), Y]))
+ return isinstance(Y.dereference(e), term.Atom)
if n == 1:
e.call(larger)
- return isinstance(X.dereference(e.heap), term.Atom)
+ return isinstance(Y.dereference(e), term.Atom)
else:
return False
@@ -38,16 +46,10 @@
assert res == True
- res = self.timeshift_from_portal(main, portal.PORTAL,
- [1], policy=POLICY,
- backendoptimize=True,
- inline=0.0)
+ res = self.run(main, [1], threshold=2, policy=POLICY)
assert res == True
- res = self.timeshift_from_portal(main, portal.PORTAL,
- [0], policy=POLICY,
- backendoptimize=True,
- inline=0.0)
+ res = self.run(main, [0], threshold=2, policy=POLICY)
assert res == True
def test_and(self):
@@ -59,13 +61,13 @@
f(X) :- b(X), a(X).
f(X) :- fail.
""")
- X = e.heap.newvar()
+ X = term.Var()
def main(n):
- e.heap.reset()
+ e.reset()
if n == 0:
e.call(term.Term("h", [X]))
- return isinstance(X.dereference(e.heap), term.Atom)
+ return isinstance(X.dereference(e), term.Atom)
else:
return False
@@ -84,19 +86,19 @@
append([X|Y], L, [X|Z]) :- append(Y, L, Z).
""")
t = parse_query_term("append([a, b, c], [d, f, g], X).")
- X = e.heap.newvar()
+ X = term.Var()
def main(n):
if n == 0:
e.call(t)
- return isinstance(X.dereference(e.heap), term.Term)
+ return isinstance(X.dereference(e), term.Term)
else:
return False
res = main(0)
assert res == True
- e.heap.reset()
+ e.reset()
res = self.timeshift_from_portal(main, portal.PORTAL,
[0], policy=POLICY,
backendoptimize=True,
@@ -111,13 +113,13 @@
f(X, b) :- g(X).
g(b).
""")
- X = e.heap.newvar()
+ X = term.Var()
def main(n):
- e.heap.reset()
+ e.reset()
if n == 0:
e.call(term.Term("h", [X]))
- return isinstance(X.dereference(e.heap), term.Atom)
+ return isinstance(X.dereference(e), term.Atom)
else:
return False
@@ -132,16 +134,10 @@
assert res == True
def test_loop(self):
- e = get_engine("""
- f(X) :- h(X, _).
- f(50).
- h(0, _).
- h(X, Y) :- Y is X - 1, h(Y, _).
- """)
num = term.Number(50)
def main(n):
- e.heap.reset()
+ e.reset()
if n == 0:
e.call(term.Term("f", [num]))
return True
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/test/test_parsing.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/test/test_parsing.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/test/test_parsing.py Wed Apr 2 02:28:39 2008
@@ -37,10 +37,10 @@
term = parse_query_term(
"""add_numeral(succ(succ(null)), succ(succ(null)), X).""")
e.run(term)
- var = Var(0).getvalue(e.heap)
- print var, e.heap
+ var = Var().getvalue(e)
+ print var, e
# does not raise
- var.unify(four, e.heap)
+ var.unify(four, e)
term = parse_query_term(
"""greater_than(succ(succ(succ(null))), succ(succ(null))).""")
e.run(term)
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/test/test_unification.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/test/test_unification.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/test/test_unification.py Wed Apr 2 02:28:39 2008
@@ -60,9 +60,9 @@
e.add_rule(Term("f", [X, X]))
e.add_rule(Term(":-", [Term("f", [X, Y]),
Term("f", [Y, X])]))
- X = e.heap.newvar()
+ X = Var()
e.run(Term("f", [Atom.newatom("b"), X]))
- assert X.dereference(e.heap).name == "b"
+ assert X.dereference(e).name == "b"
e.run(Term("f", [Atom.newatom("b"), Atom.newatom("a")]))
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/test/tool.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/test/tool.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/test/tool.py Wed Apr 2 02:28:39 2008
@@ -9,7 +9,7 @@
terms, vars = e.parse(query)
term, = terms
e.run(term)
- return dict([(name, var.dereference(e.heap))
+ return dict([(name, var.dereference(e))
for name, var in vars.iteritems()])
def assert_false(query, e=None):
if e is None:
@@ -27,7 +27,7 @@
self.vars = vars
def _call(self, engine):
- self.heaps.append(dict([(name, var.dereference(engine.heap))
+ self.heaps.append(dict([(name, var.dereference(engine))
for name, var in self.vars.iteritems()]))
print "restarting computation"
raise UnificationFailed
Modified: pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/translatedmain.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/translatedmain.py (original)
+++ pypy/branch/jit-hotpath/pypy/lang/prolog/interpreter/translatedmain.py Wed Apr 2 02:28:39 2008
@@ -43,7 +43,7 @@
for var, real_var in var_to_pos.iteritems():
if var.startswith("_"):
continue
- val = f.format(real_var.getvalue(engine.heap))
+ val = f.format(real_var.getvalue(engine))
write("%s = %s\n" % (var, val))
def getch():
More information about the Pypy-commit
mailing list