[pypy-svn] r44093 - in pypy/branch/prolog-bytecode/pypy/lang/prolog/interpreter: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Thu Jun 7 16:10:10 CEST 2007
Author: cfbolz
Date: Thu Jun 7 16:10:09 2007
New Revision: 44093
Modified:
pypy/branch/prolog-bytecode/pypy/lang/prolog/interpreter/interpreter.py
pypy/branch/prolog-bytecode/pypy/lang/prolog/interpreter/test/test_engine.py
pypy/branch/prolog-bytecode/pypy/lang/prolog/interpreter/translatedmain.py
Log:
some small fixes for actually stopping the computation - now all tests pass
again
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 16:10:09 2007
@@ -2,7 +2,7 @@
from pypy.lang.prolog.interpreter import error
from pypy.lang.prolog.interpreter.term import Term, Atom, Var, Callable
from pypy.lang.prolog.interpreter.engine import Continuation, \
- LimitedScopeContinuation
+ LimitedScopeContinuation, DONOTHING
from pypy.lang.prolog.interpreter.prologopcode import unrolling_opcode_descs, \
HAVE_ARGUMENT
@@ -77,8 +77,9 @@
continuation = self.run(self.code.opcode, 0, continuation)
if not choice_point:
return continuation
- while continuation is not None:
+ while continuation is not DONOTHING:
continuation = continuation._call(self.engine)
+ return DONOTHING
def run(self, bytecode, pc, continuation):
stack = []
@@ -109,8 +110,8 @@
else:
res = meth(stack)
if res is not None:
- while 1:
- continuation = res
+ continuation = res
+ while continuation is not DONOTHING:
if isinstance(continuation, FrameContinuation):
self = continuation.frame
pc = continuation.pc
@@ -119,7 +120,8 @@
stack = []
break
else:
- res = continuation._call(self.engine)
+ print continuation
+ continuation = continuation._call(self.engine)
break
else:
assert 0, "missing opcode"
@@ -187,8 +189,7 @@
continuation = LimitedScopeContinuation(continuation)
try:
frame = rule.make_frame(query)
- frame.run_directly(continuation)
- return
+ return frame.run_directly(continuation)
except error.UnificationFailed:
self.engine.heap.revert(oldstate)
except error.CutException, e:
@@ -199,8 +200,7 @@
else:
try:
frame = rule.make_frame(query)
- frame.run_directly(continuation)
- return
+ return frame.run_directly(continuation)
except error.UnificationFailed:
self.engine.heap.revert(oldstate)
rulechain = rulechain.next
Modified: pypy/branch/prolog-bytecode/pypy/lang/prolog/interpreter/test/test_engine.py
==============================================================================
--- pypy/branch/prolog-bytecode/pypy/lang/prolog/interpreter/test/test_engine.py (original)
+++ pypy/branch/prolog-bytecode/pypy/lang/prolog/interpreter/test/test_engine.py Thu Jun 7 16:10:09 2007
@@ -206,7 +206,6 @@
e.run(parse_query_term("g(2, 2)."))
def test_lists():
- py.test.skip("hangs (or takes very long) right now")
e = get_engine("""
nrev([],[]).
nrev([X|Y],Z) :- nrev(Y,Z1),
Modified: pypy/branch/prolog-bytecode/pypy/lang/prolog/interpreter/translatedmain.py
==============================================================================
--- pypy/branch/prolog-bytecode/pypy/lang/prolog/interpreter/translatedmain.py (original)
+++ pypy/branch/prolog-bytecode/pypy/lang/prolog/interpreter/translatedmain.py Thu Jun 7 16:10:09 2007
@@ -1,3 +1,4 @@
+import autopath
import os, sys
from pypy.rlib.parsing.parsing import ParseError
from pypy.rlib.parsing.deterministic import LexerError
@@ -143,5 +144,12 @@
e.run(term.Term("consult", [term.Atom(filename)]))
if __name__ == '__main__':
+ argv = sys.argv
e = Engine()
- repl(e)
+ if len(argv) == 2:
+ execute(e, argv[1])
+ try:
+ repl(e)
+ except SystemExit:
+ sys.exit(1)
+ sys.exit(0)
More information about the Pypy-commit
mailing list