fix high arity and nth clause

This commit is contained in:
Vítor Santos Costa 2013-11-25 18:31:33 +01:00
parent 7a3a4ab32b
commit fae3da8659

View File

@ -5203,6 +5203,7 @@ p_nth_clause( USES_REGS1 )
LogUpdClause *cl; LogUpdClause *cl;
Int ncls; Int ncls;
Int CurSlot, sl;
if (!IsIntegerTerm(tn)) if (!IsIntegerTerm(tn))
return FALSE; return FALSE;
ncls = IntegerOfTerm(tn); ncls = IntegerOfTerm(tn);
@ -5211,8 +5212,11 @@ p_nth_clause( USES_REGS1 )
return FALSE; return FALSE;
PELOCK(47,pe); PELOCK(47,pe);
if (!(pe->PredFlags & (SourcePredFlag|LogUpdatePredFlag))) { if (!(pe->PredFlags & (SourcePredFlag|LogUpdatePredFlag))) {
UNLOCK(pe->PELock);
return FALSE; return FALSE;
} }
CurSlot = Yap_StartSlots( PASS_REGS1 );
sl = Yap_InitSlot( ARG4 PASS_REGS );
/* in case we have to index or to expand code */ /* in case we have to index or to expand code */
if (pe->ModuleOfPred != IDB_MODULE) { if (pe->ModuleOfPred != IDB_MODULE) {
UInt i; UInt i;
@ -5227,6 +5231,8 @@ p_nth_clause( USES_REGS1 )
IPred(pe, 0, CP); IPred(pe, 0, CP);
} }
cl = Yap_NthClause(pe, ncls); cl = Yap_NthClause(pe, ncls);
ARG4 = Yap_GetFromSlot( sl PASS_REGS );
LOCAL_CurSlot = CurSlot;
if (cl == NULL) { if (cl == NULL) {
UNLOCK(pe->PELock); UNLOCK(pe->PELock);
return FALSE; return FALSE;