From 08422c967ac645b5087763972951ae0ac452b401 Mon Sep 17 00:00:00 2001 From: vsc Date: Wed, 4 Jun 2008 13:58:42 +0000 Subject: [PATCH] more fixes to C-interface git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2257 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/c_interface.c | 52 +++++++++++++++++++++++++++++++++++------- C/heapgc.c | 6 ++--- LGPL/Makefile.in | 1 + changes-5.1.html | 2 ++ console/yap.c | 10 ++++---- docs/yap.tex | 32 ++++++++++++++------------ include/YapInterface.h | 3 +++ 7 files changed, 75 insertions(+), 31 deletions(-) diff --git a/C/c_interface.c b/C/c_interface.c index 668972484..903986744 100644 --- a/C/c_interface.c +++ b/C/c_interface.c @@ -10,8 +10,12 @@ * File: c_interface.c * * comments: c_interface primitives definition * * * -* Last rev: $Date: 2008-04-28 23:02:32 $,$Author: vsc $ * +* Last rev: $Date: 2008-06-04 13:58:36 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.116 2008/04/28 23:02:32 vsc +* fix bug in current_predicate/2 +* fix bug in c_interface. +* * Revision 1.115 2008/04/11 16:30:27 ricroc * *** empty log message *** * @@ -399,6 +403,7 @@ X_API Term STD_PROTO(YAP_BufferToString, (char *)); X_API Term STD_PROTO(YAP_BufferToAtomList, (char *)); X_API void STD_PROTO(YAP_Error,(int, Term, char *, ...)); X_API Term STD_PROTO(YAP_RunGoal,(Term)); +X_API Term STD_PROTO(YAP_RunGoalOnce,(Term)); X_API int STD_PROTO(YAP_RestartGoal,(void)); X_API int STD_PROTO(YAP_ShutdownGoal,(int)); X_API int STD_PROTO(YAP_EnterGoal,(PredEntry *, Term *, YAP_dogoalinfo *)); @@ -1429,8 +1434,8 @@ YAP_RunGoal(Term t) CP = old_CP; Yap_AllowRestart = TRUE; } else { - if (B != NULL) /* restore might have destroyed B */ - B = B->cp_b; + ASP = B->cp_env; + B = B->cp_b; Yap_AllowRestart = FALSE; } @@ -1438,6 +1443,41 @@ YAP_RunGoal(Term t) return(out); } +X_API Term +YAP_RunGoalOnce(Term t) +{ + Term out; + yamop *old_CP = CP; + BACKUP_MACHINE_REGS(); + + Yap_PrologMode = UserMode; + out = Yap_RunTopGoal(t); + Yap_PrologMode = UserCCallMode; + if (out) { + choiceptr cut_pt; + + cut_pt = B; + while (cut_pt-> cp_ap != NOCODE) { + cut_pt = cut_pt->cp_b; + } +#ifdef YAPOR + CUT_prune_to(cut_pt); +#endif + B = cut_pt; + } + ASP = B->cp_env; + ENV = (CELL *)ASP[E_E]; + B = (choiceptr)ASP[E_CB]; +#ifdef DEPTH_LIMIT + DEPTH = ASP[E_DEPTH]; +#endif + P = (yamop *)ASP[E_CP]; + CP = old_CP; + Yap_AllowRestart = FALSE; + RECOVER_MACHINE_REGS(); + return(out); +} + X_API int YAP_RestartGoal(void) { @@ -1469,7 +1509,6 @@ YAP_ShutdownGoal(int backtrack) if (Yap_AllowRestart) { choiceptr cut_pt; - yamop *my_p = P; cut_pt = B; while (cut_pt-> cp_ap != NOCODE) { @@ -1488,10 +1527,7 @@ YAP_ShutdownGoal(int backtrack) TR = cut_pt->cp_tr; } /* we can always recover the stack */ - ENV = cut_pt->cp_env; - ASP = (CELL *)(cut_pt+1); - ASP += EnvSizeInCells; - P = my_p; + ASP = cut_pt->cp_env; ENV = (CELL *)ASP[E_E]; B = (choiceptr)ASP[E_CB]; #ifdef DEPTH_LIMIT diff --git a/C/heapgc.c b/C/heapgc.c index 21cc58573..0244eb8aa 100644 --- a/C/heapgc.c +++ b/C/heapgc.c @@ -3456,15 +3456,15 @@ marking_phase(tr_fr_ptr old_TR, CELL *current_env, yamop *curp, CELL *max) cont_top0 = (cont *)db_vec; #endif cont_top = (cont *)db_vec; -#ifdef COROUTINING - mark_delays(max); -#endif /* These two must be marked first so that our trail optimisation won't lose values */ mark_regs(old_TR); /* active registers & trail */ /* active environments */ mark_environments(current_env, EnvSize(curp), EnvBMap((CELL *)curp)); mark_choicepoints(B, old_TR, is_gc_very_verbose()); /* choicepoints, and environs */ +#ifdef COROUTINING + mark_delays(max); +#endif #ifdef EASY_SHUNTING set_conditionals(sTR); #endif diff --git a/LGPL/Makefile.in b/LGPL/Makefile.in index 333df6ae4..ea96f59cb 100644 --- a/LGPL/Makefile.in +++ b/LGPL/Makefile.in @@ -26,6 +26,7 @@ YAP_EXTRAS=@YAP_EXTRAS@ PROGRAMS= $(srcdir)/debug.pl \ $(srcdir)/maplist.pl \ + $(srcdir)/nb_rbtrees.yap \ $(srcdir)/operators.pl \ $(srcdir)/option.pl \ $(srcdir)/prolog_source.pl \ diff --git a/changes-5.1.html b/changes-5.1.html index 1f90714da..a7f30b58e 100644 --- a/changes-5.1.html +++ b/changes-5.1.html @@ -17,6 +17,8 @@

Yap-5.1.3: