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:
parent
7e06e3fa36
commit
f78cc61bc8
@ -5241,7 +5241,7 @@ Yap_InitDBPreds(void)
|
|||||||
Yap_InitCPred("key_erased_statistics", 5, p_key_erased_statistics, SyncPredFlag);
|
Yap_InitCPred("key_erased_statistics", 5, p_key_erased_statistics, SyncPredFlag);
|
||||||
Yap_InitCPred("heap_space_info", 3, p_heap_space_info, SyncPredFlag);
|
Yap_InitCPred("heap_space_info", 3, p_heap_space_info, SyncPredFlag);
|
||||||
#endif
|
#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("$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("$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);
|
Yap_InitCPred("$install_thread_local", 2, p_install_thread_local, SafePredFlag|HiddenPredFlag);
|
||||||
|
13
C/index.c
13
C/index.c
@ -11,8 +11,11 @@
|
|||||||
* File: index.c *
|
* File: index.c *
|
||||||
* comments: Indexing a Prolog predicate *
|
* 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 $
|
* $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
|
* Revision 1.124 2005/04/27 20:09:25 vsc
|
||||||
* indexing code could get confused with suspension points
|
* indexing code could get confused with suspension points
|
||||||
* some further improvements on oveflow handling
|
* some further improvements on oveflow handling
|
||||||
@ -8145,7 +8148,7 @@ Yap_NthClause(PredEntry *ap, Int ncls)
|
|||||||
if (ncls == 1)
|
if (ncls == 1)
|
||||||
return to_clause(ipc->u.ld.d, ap);
|
return to_clause(ipc->u.ld.d, ap);
|
||||||
else if (alt == NULL) {
|
else if (alt == NULL) {
|
||||||
ncls -= 2;
|
ncls --;
|
||||||
/* get there in a fell swoop */
|
/* get there in a fell swoop */
|
||||||
if (ap->PredFlags & ProfiledPredFlag) {
|
if (ap->PredFlags & ProfiledPredFlag) {
|
||||||
if (ap->PredFlags & CountPredFlag) {
|
if (ap->PredFlags & CountPredFlag) {
|
||||||
@ -8158,7 +8161,7 @@ Yap_NthClause(PredEntry *ap, Int ncls)
|
|||||||
} else {
|
} else {
|
||||||
ipc = (yamop *)((char *)ipc+ncls*(UInt)NEXTOP((yamop *)NULL,ld));
|
ipc = (yamop *)((char *)ipc+ncls*(UInt)NEXTOP((yamop *)NULL,ld));
|
||||||
}
|
}
|
||||||
ncls = 1;
|
return to_clause(ipc->u.ld.d, ap);
|
||||||
} else {
|
} else {
|
||||||
ncls--;
|
ncls--;
|
||||||
}
|
}
|
||||||
@ -8173,7 +8176,7 @@ Yap_NthClause(PredEntry *ap, Int ncls)
|
|||||||
if (ncls == 1)
|
if (ncls == 1)
|
||||||
return to_clause(ipc->u.l.l, ap);
|
return to_clause(ipc->u.l.l, ap);
|
||||||
else if (alt == NULL) {
|
else if (alt == NULL) {
|
||||||
ncls -= 2;
|
ncls --;
|
||||||
/* get there in a fell swoop */
|
/* get there in a fell swoop */
|
||||||
if (ap->PredFlags & ProfiledPredFlag) {
|
if (ap->PredFlags & ProfiledPredFlag) {
|
||||||
if (ap->PredFlags & CountPredFlag) {
|
if (ap->PredFlags & CountPredFlag) {
|
||||||
@ -8186,7 +8189,7 @@ Yap_NthClause(PredEntry *ap, Int ncls)
|
|||||||
} else {
|
} else {
|
||||||
ipc = (yamop *)((char *)ipc+ncls*(UInt)NEXTOP((yamop *)NULL,l));
|
ipc = (yamop *)((char *)ipc+ncls*(UInt)NEXTOP((yamop *)NULL,l));
|
||||||
}
|
}
|
||||||
ncls = 1;
|
return to_clause(ipc->u.l.l, ap);
|
||||||
} else {
|
} else {
|
||||||
ncls--;
|
ncls--;
|
||||||
}
|
}
|
||||||
|
@ -721,3 +721,10 @@ halt :-
|
|||||||
halt(X) :-
|
halt(X) :-
|
||||||
'$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).
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user