diff --git a/C/c_interface.c b/C/c_interface.c index c49de58d9..ae7593bb9 100755 --- a/C/c_interface.c +++ b/C/c_interface.c @@ -1744,6 +1744,7 @@ X_API bool YAP_EnterGoal(YAP_PredEntryPtr ape, CELL *ptr, YAP_dogoalinfo *dgi) { // HR-H0,LCL0-ENV,LCL0-(CELL*)B,(CELL*)TR-LCL0, P, CP, LOCAL_CurSlot); out = Yap_exec_absmi(true, false); fprintf(stderr,"EnterGoal success=%d: H=%d ENV=%p B=%d TR=%d P=%p CP=%p Slots=%d\n", out,HR-H0,LCL0-ENV,LCL0-(CELL*)B,(CELL*)TR-LCL0, P, CP, LOCAL_CurSlot); + dgi->b = LCL0 - (CELL *)B; if (out) { dgi->EndSlot = LOCAL_CurSlot; Yap_StartSlots(); diff --git a/packages/python/swig/prolog/yapi.yap b/packages/python/swig/prolog/yapi.yap index 2d2080cd9..6c58ae1ab 100644 --- a/packages/python/swig/prolog/yapi.yap +++ b/packages/python/swig/prolog/yapi.yap @@ -72,11 +72,13 @@ python_query( Caller, String ) :- atomic_to_term( String, Goal, VarNames ), query_to_answer( Goal, VarNames, Status, Bindings), atom_to_string( Status, SStatus ), - Caller.q.port := SStatus, + Caller.port := SStatus, + start_low_level_trace, write_query_answer( Bindings ), nl(user_error), - Caller.q.answer := {}, - maplist(in_dict(Caller.q.answer), Bindings). + Caller.answer := {}, + maplist(in_dict(Caller.answer), Bindings). + in_dict(Dict, var([V0,V|Vs])) :- !, Dict[V] := V0, @@ -84,6 +86,6 @@ in_dict(Dict, var([V0,V|Vs])) :- !, in_dict(_Dict, var([_],_G)) :- !. in_dict(Dict, nonvar([V0|Vs],G)) :- !, Dict[V0] := G, - in_dict( Dict, nonvar(Vs, Gs)). + in_dict( Dict, nonvar(Vs, G) ). in_dict(_Dict, nonvar([],_G)) :- !. in_dict(_, _). diff --git a/packages/python/swig/yap4py/yapi.py b/packages/python/swig/yap4py/yapi.py index 0a825be90..80553cc9b 100644 --- a/packages/python/swig/yap4py/yapi.py +++ b/packages/python/swig/yap4py/yapi.py @@ -53,37 +53,29 @@ class Predicate( YAPPredicate ): def __init__(self, t, module=None): super().__init__(t) -class Query: +class Query (YAPQuery): """Goal is a predicate instantiated under a specific environment """ def __init__(self, engine, g): - engine.reSet() + super().__init__(g) self.engine = engine - self.q = engine.query(g) - if self.q: - self.port = "call" - self.bindings = None - self.engine = engine - self.answer = {} + self.port = "call" + self.bindings = None + self.answer = {} def __iter__(self): return self def __next__(self): - if not self.q: - raise RuntimeError() - if self.port == "exit": + if self.port == "exit" or self.port == "fail": return else: - if self.q.next(): + if self.next(): return self.port,self.answer else: self.close() def close( self ): - if self.q: - self.q.close() - self.q = None - + self.engine.reSet() def name( name, arity): try: