ifix some wierd cases in indexing code:
would not look at next argument problem with pvar as last clause (R Camacho). git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1337 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
d62a9e2ffa
commit
f6da8078ae
42
C/index.c
42
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-06-04 07:27:34 $,$Author: ricroc $ *
|
* Last rev: $Date: 2005-07-05 18:32:32 $,$Author: vsc $ *
|
||||||
* $Log: not supported by cvs2svn $
|
* $Log: not supported by cvs2svn $
|
||||||
|
* Revision 1.137 2005/06/04 07:27:34 ricroc
|
||||||
|
* long int support for tabling
|
||||||
|
*
|
||||||
* Revision 1.136 2005/06/03 08:26:32 ricroc
|
* Revision 1.136 2005/06/03 08:26:32 ricroc
|
||||||
* float support for tabling
|
* float support for tabling
|
||||||
*
|
*
|
||||||
@ -462,12 +465,12 @@ insort(ClauseDef base[], CELL *p, CELL *q, int my_p)
|
|||||||
|
|
||||||
/* copy to a new list of terms */
|
/* copy to a new list of terms */
|
||||||
static
|
static
|
||||||
void msort(ClauseDef *base, Int *pt, Int size, int my_p)
|
void msort(ClauseDef *base, CELL *pt, Int size, int my_p)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (size > 2) {
|
if (size > 2) {
|
||||||
Int half_size = size / 2;
|
Int half_size = size / 2;
|
||||||
Int *pt_left, *pt_right, *end_pt, *end_pt_left;
|
CELL *pt_left, *pt_right, *end_pt, *end_pt_left;
|
||||||
int left_p, right_p;
|
int left_p, right_p;
|
||||||
|
|
||||||
if (size < 50) {
|
if (size < 50) {
|
||||||
@ -881,6 +884,9 @@ has_cut(yamop *pc)
|
|||||||
case _put_x_val:
|
case _put_x_val:
|
||||||
pc = NEXTOP(pc,xx);
|
pc = NEXTOP(pc,xx);
|
||||||
break;
|
break;
|
||||||
|
case _put_xx_val:
|
||||||
|
pc = NEXTOP(pc,xxxx);
|
||||||
|
break;
|
||||||
/* instructions type yx */
|
/* instructions type yx */
|
||||||
case _get_y_var:
|
case _get_y_var:
|
||||||
case _get_y_val:
|
case _get_y_val:
|
||||||
@ -1528,6 +1534,25 @@ add_info(ClauseDef *clause, UInt regno)
|
|||||||
}
|
}
|
||||||
cl = NEXTOP(cl,xx);
|
cl = NEXTOP(cl,xx);
|
||||||
break;
|
break;
|
||||||
|
case _put_xx_val:
|
||||||
|
if (regcopy_in(myregs, nofregs, cl->u.xxxx.xl1)) {
|
||||||
|
nofregs = add_regcopy(myregs, nofregs, cl->u.xxxx.xr1);
|
||||||
|
} else if (regcopy_in(myregs, nofregs, cl->u.xxxx.xr1) &&
|
||||||
|
(nofregs = delete_regcopy(myregs, nofregs, cl->u.xxxx.xr1)) == 0 &&
|
||||||
|
!ycopy) {
|
||||||
|
clause->Tag = (CELL)NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (regcopy_in(myregs, nofregs, cl->u.xxxx.xl2)) {
|
||||||
|
nofregs = add_regcopy(myregs, nofregs, cl->u.xxxx.xr2);
|
||||||
|
} else if (regcopy_in(myregs, nofregs, cl->u.xxxx.xr2) &&
|
||||||
|
(nofregs = delete_regcopy(myregs, nofregs, cl->u.xxxx.xr2)) == 0 &&
|
||||||
|
!ycopy) {
|
||||||
|
clause->Tag = (CELL)NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cl = NEXTOP(cl,xxxx);
|
||||||
|
break;
|
||||||
case _glist_valx:
|
case _glist_valx:
|
||||||
case _gl_void_varx:
|
case _gl_void_varx:
|
||||||
case _gl_void_valx:
|
case _gl_void_valx:
|
||||||
@ -3025,6 +3050,7 @@ groups_in(ClauseDef *min, ClauseDef *max, GroupDef *grp)
|
|||||||
(!IsVarTerm(min->Tag)));
|
(!IsVarTerm(min->Tag)));
|
||||||
if (min <= max && min->Tag == (_var+1)*sizeof(CELL)) {
|
if (min <= max && min->Tag == (_var+1)*sizeof(CELL)) {
|
||||||
min++;
|
min++;
|
||||||
|
if (min < max)
|
||||||
goto restart_loop;
|
goto restart_loop;
|
||||||
}
|
}
|
||||||
grp->LastClause = min-1;
|
grp->LastClause = min-1;
|
||||||
@ -3578,7 +3604,7 @@ do_consts(GroupDef *grp, Term t, struct intermediates *cint, int compound_term,
|
|||||||
if (ap->PredFlags & LogUpdatePredFlag && max > min)
|
if (ap->PredFlags & LogUpdatePredFlag && max > min)
|
||||||
ics->Label = suspend_indexing(min, max, ap, cint);
|
ics->Label = suspend_indexing(min, max, ap, cint);
|
||||||
else
|
else
|
||||||
ics->Label = do_compound_index(min, max, sreg, cint, compound_term, arity, argno+1, nxtlbl, first, last_arg, clleft, top, TRUE);
|
ics->Label = do_compound_index(min, max, sreg, cint, compound_term, arity, argno, nxtlbl, first, last_arg, clleft, top, TRUE);
|
||||||
} else if (ap->PredFlags & LogUpdatePredFlag) {
|
} else if (ap->PredFlags & LogUpdatePredFlag) {
|
||||||
ics->Label = suspend_indexing(min, max, cint->CurrentPred, cint);
|
ics->Label = suspend_indexing(min, max, cint->CurrentPred, cint);
|
||||||
} else {
|
} else {
|
||||||
@ -3668,7 +3694,7 @@ do_funcs(GroupDef *grp, Term t, struct intermediates *cint, UInt argno, int firs
|
|||||||
} else {
|
} else {
|
||||||
sreg = NULL;
|
sreg = NULL;
|
||||||
}
|
}
|
||||||
ifs->Label = do_compound_index(min, max, sreg, cint, 0, ArityOfFunctor(f), argno+1, nxtlbl, first, last_arg, clleft, top, TRUE);
|
ifs->Label = do_compound_index(min, max, sreg, cint, 0, ArityOfFunctor(f), argno, nxtlbl, first, last_arg, clleft, top, TRUE);
|
||||||
}
|
}
|
||||||
grp->FirstClause = min = max+1;
|
grp->FirstClause = min = max+1;
|
||||||
}
|
}
|
||||||
@ -3699,7 +3725,7 @@ do_pair(GroupDef *grp, Term t, struct intermediates *cint, UInt argno, int first
|
|||||||
if (min != max && !IsPairTerm(t)) {
|
if (min != max && !IsPairTerm(t)) {
|
||||||
return suspend_indexing(min, max, cint->CurrentPred, cint);
|
return suspend_indexing(min, max, cint->CurrentPred, cint);
|
||||||
}
|
}
|
||||||
return do_compound_index(min, max, (IsPairTerm(t) ? RepPair(t) : NULL), cint, 0, 2, argno+1, nxtlbl, first, last_arg, clleft, top, TRUE);
|
return do_compound_index(min, max, (IsPairTerm(t) ? RepPair(t) : NULL), cint, 0, 2, argno, nxtlbl, first, last_arg, clleft, top, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -5520,7 +5546,7 @@ replace_index_block(ClauseUnion *parent_block, yamop *cod, yamop *ncod, PredEntr
|
|||||||
c->u.ParentIndex = ncl;
|
c->u.ParentIndex = ncl;
|
||||||
c = c->SiblingIndex;
|
c = c->SiblingIndex;
|
||||||
}
|
}
|
||||||
Yap_FreeCodeSpace((CODEADDR)cl);
|
Yap_FreeCodeSpace((char *)cl);
|
||||||
} else {
|
} else {
|
||||||
StaticIndex
|
StaticIndex
|
||||||
*cl = ClauseCodeToStaticIndex(cod),
|
*cl = ClauseCodeToStaticIndex(cod),
|
||||||
@ -5535,7 +5561,7 @@ replace_index_block(ClauseUnion *parent_block, yamop *cod, yamop *ncod, PredEntr
|
|||||||
}
|
}
|
||||||
c->SiblingIndex = ncl;
|
c->SiblingIndex = ncl;
|
||||||
}
|
}
|
||||||
Yap_FreeCodeSpace((CODEADDR)cl);
|
Yap_FreeCodeSpace((char *)cl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user