fix another bug in nth_instance, thanks to Pat Caldon

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1290 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2005-05-25 18:58:38 +00:00
parent 7e06e3fa36
commit f78cc61bc8
3 changed files with 16 additions and 6 deletions

View File

@ -5241,7 +5241,7 @@ Yap_InitDBPreds(void)
Yap_InitCPred("key_erased_statistics", 5, p_key_erased_statistics, SyncPredFlag);
Yap_InitCPred("heap_space_info", 3, p_heap_space_info, SyncPredFlag);
#endif
Yap_InitCPred("nth_instance", 3, p_nth_instance, SyncPredFlag);
Yap_InitCPred("$nth_instance", 3, p_nth_instance, SyncPredFlag);
Yap_InitCPred("$nth_instancep", 3, p_nth_instancep, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$jump_to_next_dynamic_clause", 0, p_jump_to_next_dynamic_clause, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$install_thread_local", 2, p_install_thread_local, SafePredFlag|HiddenPredFlag);

View File

@ -11,8 +11,11 @@
* File: index.c *
* comments: Indexing a Prolog predicate *
* *
* Last rev: $Date: 2005-04-28 14:50:45 $,$Author: vsc $ *
* Last rev: $Date: 2005-05-25 18:58:37 $,$Author: vsc $ *
* $Log: not supported by cvs2svn $
* Revision 1.125 2005/04/28 14:50:45 vsc
* clause should always deref before testing type
*
* Revision 1.124 2005/04/27 20:09:25 vsc
* indexing code could get confused with suspension points
* some further improvements on oveflow handling
@ -8145,7 +8148,7 @@ Yap_NthClause(PredEntry *ap, Int ncls)
if (ncls == 1)
return to_clause(ipc->u.ld.d, ap);
else if (alt == NULL) {
ncls -= 2;
ncls --;
/* get there in a fell swoop */
if (ap->PredFlags & ProfiledPredFlag) {
if (ap->PredFlags & CountPredFlag) {
@ -8158,7 +8161,7 @@ Yap_NthClause(PredEntry *ap, Int ncls)
} else {
ipc = (yamop *)((char *)ipc+ncls*(UInt)NEXTOP((yamop *)NULL,ld));
}
ncls = 1;
return to_clause(ipc->u.ld.d, ap);
} else {
ncls--;
}
@ -8173,7 +8176,7 @@ Yap_NthClause(PredEntry *ap, Int ncls)
if (ncls == 1)
return to_clause(ipc->u.l.l, ap);
else if (alt == NULL) {
ncls -= 2;
ncls --;
/* get there in a fell swoop */
if (ap->PredFlags & ProfiledPredFlag) {
if (ap->PredFlags & CountPredFlag) {
@ -8186,7 +8189,7 @@ Yap_NthClause(PredEntry *ap, Int ncls)
} else {
ipc = (yamop *)((char *)ipc+ncls*(UInt)NEXTOP((yamop *)NULL,l));
}
ncls = 1;
return to_clause(ipc->u.l.l, ap);
} else {
ncls--;
}

View File

@ -721,3 +721,10 @@ halt :-
halt(X) :-
'$halt'(X).
nth_instance(X,Y,Z) :-
nonvar(X), var(Y), var(Z), !,
recorded(X,_,Z),
'$nth_instance'(_,Y,Z).
nth_instance(X,Y,Z) :-
'$nth_instance'(X,Y,Z).