fixes from Stasinos

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@870 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2003-09-15 19:06:55 +00:00
parent ac19e411a2
commit 0d441d069d
2 changed files with 52 additions and 48 deletions

View File

@ -4232,9 +4232,9 @@ static DBTerm *
StoreTermInDB(Term t, int nargs) StoreTermInDB(Term t, int nargs)
{ {
DBTerm *x; DBTerm *x;
Yap_Error_Size = 0;
int needs_vars; int needs_vars;
Yap_Error_Size = 0;
while ((x = (DBTerm *)CreateDBStruct(t, (DBProp)NULL, while ((x = (DBTerm *)CreateDBStruct(t, (DBProp)NULL,
InQueue, &needs_vars)) == NULL) { InQueue, &needs_vars)) == NULL) {
switch(DBErrorFlag) { switch(DBErrorFlag) {

View File

@ -57,7 +57,7 @@ static char SccsId[] = "%W% %G%";
#endif #endif
UInt STATIC_PROTO(do_index, (ClauseDef *,ClauseDef *,PredEntry *,UInt,UInt,int,int,CELL *)); UInt STATIC_PROTO(do_index, (ClauseDef *,ClauseDef *,PredEntry *,UInt,UInt,int,int,CELL *));
UInt STATIC_PROTO(do_compound_index, (ClauseDef *,ClauseDef *,Term *t,PredEntry *,UInt,UInt,UInt,UInt,int,int,int,int,CELL *)); UInt STATIC_PROTO(do_compound_index, (ClauseDef *,ClauseDef *,Term *t,PredEntry *,UInt,UInt,UInt,UInt,int,int,int,CELL *));
UInt STATIC_PROTO(do_dbref_index, (ClauseDef *,ClauseDef *,Term,PredEntry *,UInt,UInt,int,int,CELL *)); UInt STATIC_PROTO(do_dbref_index, (ClauseDef *,ClauseDef *,Term,PredEntry *,UInt,UInt,int,int,CELL *));
UInt STATIC_PROTO(do_blob_index, (ClauseDef *,ClauseDef *,Term,PredEntry *,UInt,UInt,int,int,CELL *)); UInt STATIC_PROTO(do_blob_index, (ClauseDef *,ClauseDef *,Term,PredEntry *,UInt,UInt,int,int,CELL *));
@ -2808,7 +2808,7 @@ do_consts(GroupDef *grp, Term t, PredEntry *ap, int compound_term, CELL *sreg, U
max != grp->LastClause) max++; max != grp->LastClause) max++;
if (min != max) { if (min != max) {
if (sreg != NULL) { if (sreg != NULL) {
ics->Label = do_compound_index(min, max, sreg, ap, compound_term, arity, argno+1, nxtlbl, first, last_arg, clleft, !(ap->PredFlags & LogUpdatePredFlag), top); ics->Label = do_compound_index(min, max, sreg, ap, compound_term, arity, argno+1, nxtlbl, first, last_arg, clleft, top);
} else if (ap->PredFlags & LogUpdatePredFlag) { } else if (ap->PredFlags & LogUpdatePredFlag) {
ics->Label = suspend_indexing(min, max, ap); ics->Label = suspend_indexing(min, max, ap);
} else { } else {
@ -2896,7 +2896,7 @@ do_funcs(GroupDef *grp, Term t, PredEntry *ap, UInt argno, int first, int last_a
} else { } else {
sreg = NULL; sreg = NULL;
} }
ifs->Label = do_compound_index(min, max, sreg, ap, 0, ArityOfFunctor(f), argno+1, nxtlbl, first, last_arg, clleft, !(ap->PredFlags & LogUpdatePredFlag), top); ifs->Label = do_compound_index(min, max, sreg, ap, 0, ArityOfFunctor(f), argno+1, nxtlbl, first, last_arg, clleft, top);
} }
grp->FirstClause = min = max+1; grp->FirstClause = min = max+1;
} }
@ -2924,7 +2924,7 @@ do_pair(GroupDef *grp, Term t, PredEntry *ap, UInt argno, int first, int last_ar
if (min != max && !IsPairTerm(t)) { if (min != max && !IsPairTerm(t)) {
return suspend_indexing(min, max, ap); return suspend_indexing(min, max, ap);
} }
return do_compound_index(min, max, (IsPairTerm(t) ? RepPair(t) : NULL), ap, 0, 2, argno+1, nxtlbl, first, last_arg, clleft, !(ap->PredFlags & LogUpdatePredFlag), top); return do_compound_index(min, max, (IsPairTerm(t) ? RepPair(t) : NULL), ap, 0, 2, argno+1, nxtlbl, first, last_arg, clleft, top);
} }
static void static void
@ -3238,7 +3238,7 @@ copy_clauses(ClauseDef *max0, ClauseDef *min0, CELL *top)
/* execute an index inside a structure */ /* execute an index inside a structure */
static UInt static UInt
do_compound_index(ClauseDef *min0, ClauseDef* max0, Term* sreg, PredEntry *ap, UInt i, UInt arity, UInt argno, UInt fail_l, int first, int last_arg, int clleft, int do_retry, CELL *top) do_compound_index(ClauseDef *min0, ClauseDef* max0, Term* sreg, PredEntry *ap, UInt i, UInt arity, UInt argno, UInt fail_l, int first, int last_arg, int clleft, CELL *top)
{ {
int ret_lab = 0, *newlabp; int ret_lab = 0, *newlabp;
CELL *top0 = top; CELL *top0 = top;
@ -3295,7 +3295,7 @@ do_compound_index(ClauseDef *min0, ClauseDef* max0, Term* sreg, PredEntry *ap, U
i++; i++;
} }
if (!found_index) { if (!found_index) {
if (do_retry && (!lu_pred || !done_work)) if (!lu_pred || !done_work)
*newlabp = do_index(min0, max0, ap, argno+1, fail_l, first, clleft, top); *newlabp = do_index(min0, max0, ap, argno+1, fail_l, first, clleft, top);
else else
*newlabp = suspend_indexing(min0, max0, ap); *newlabp = suspend_indexing(min0, max0, ap);
@ -3732,9 +3732,9 @@ expand_index(PredEntry *ap) {
/* this is will be used as a new PC */ /* this is will be used as a new PC */
CELL *top = (CELL *) TR; CELL *top = (CELL *) TR;
UInt arity = 0; UInt arity = 0;
sp = stack = (istack_entry *)top;
UInt lab, fail_l, clleft, arg0 = 0; UInt lab, fail_l, clleft, arg0 = 0;
sp = stack = (istack_entry *)top;
labelno = 1; labelno = 1;
stack[0].pos = 0; stack[0].pos = 0;
/* try to refine the interval using the indexing code */ /* try to refine the interval using the indexing code */
@ -3902,9 +3902,10 @@ expand_index(PredEntry *ap) {
} }
break; break;
case _switch_on_sub_arg_type: case _switch_on_sub_arg_type:
t = Deref(s_reg[ipc->u.sllll.s]); {
int argno = ipc->u.sllll.s; COUNT argno = ipc->u.sllll.s;
t = Deref(s_reg[ipc->u.sllll.s]);
if (argno != arity-1) is_last_arg = FALSE; if (argno != arity-1) is_last_arg = FALSE;
t = Deref(s_reg[argno]); t = Deref(s_reg[argno]);
if (IsVarTerm(t)) { if (IsVarTerm(t)) {
@ -3923,6 +3924,7 @@ expand_index(PredEntry *ap) {
arg0 = argno+1; arg0 = argno+1;
ipc = ipc->u.sllll.l2; ipc = ipc->u.sllll.l2;
} }
}
break; break;
case _if_not_then: case _if_not_then:
labp = NULL; labp = NULL;
@ -4067,7 +4069,7 @@ expand_index(PredEntry *ap) {
CodeStart = cpc = NULL; CodeStart = cpc = NULL;
if (!IsVarTerm(sp[-1].val) && IsPairTerm(sp[-1].val) && sp > stack) { if (!IsVarTerm(sp[-1].val) && IsPairTerm(sp[-1].val) && sp > stack) {
lab = do_compound_index(cls, max, s_reg, ap, arg0, 2, argno+1, fail_l, isfirstcl, is_last_arg, clleft, TRUE, top); lab = do_compound_index(cls, max, s_reg, ap, arg0, 2, argno+1, fail_l, isfirstcl, is_last_arg, clleft, top);
} else if (!IsVarTerm(sp[-1].val) && IsApplTerm(sp[-1].val) && sp > stack) { } else if (!IsVarTerm(sp[-1].val) && IsApplTerm(sp[-1].val) && sp > stack) {
/* we are continuing within a compound term */ /* we are continuing within a compound term */
Functor f = (Functor)RepAppl(sp[-1].val); Functor f = (Functor)RepAppl(sp[-1].val);
@ -4077,7 +4079,7 @@ expand_index(PredEntry *ap) {
else else
lab = do_blob_index(cls, max, t, ap, argno, fail_l, isfirstcl, clleft, top); lab = do_blob_index(cls, max, t, ap, argno, fail_l, isfirstcl, clleft, top);
} else { } else {
lab = do_compound_index(cls, max, s_reg, ap, arg0, ArityOfFunctor(f), argno, fail_l, isfirstcl, is_last_arg, clleft, TRUE, top); lab = do_compound_index(cls, max, s_reg, ap, arg0, ArityOfFunctor(f), argno, fail_l, isfirstcl, is_last_arg, clleft, top);
} }
} else { } else {
if (argno == ap->ArityOfPE) { if (argno == ap->ArityOfPE) {
@ -4993,10 +4995,10 @@ static void
add_to_index(PredEntry *ap, int first, path_stack_entry *sp, ClauseDef *cls) { add_to_index(PredEntry *ap, int first, path_stack_entry *sp, ClauseDef *cls) {
/* last clause to experiment with */ /* last clause to experiment with */
yamop *ipc = ap->cs.p_code.TrueCodeOfPred; yamop *ipc = ap->cs.p_code.TrueCodeOfPred;
sp = init_block_stack(sp, ipc, ap);
int group1 = TRUE; int group1 = TRUE;
yamop *alt = NULL; yamop *alt = NULL;
sp = init_block_stack(sp, ipc, ap);
/* try to refine the interval using the indexing code */ /* try to refine the interval using the indexing code */
while (ipc != NULL) { while (ipc != NULL) {
op_numbers op = Yap_op_from_opcode(ipc->opc); op_numbers op = Yap_op_from_opcode(ipc->opc);
@ -6451,9 +6453,10 @@ find_caller(PredEntry *ap, yamop *code) {
} }
break; break;
case _switch_on_sub_arg_type: case _switch_on_sub_arg_type:
t = Deref(s_reg[ipc->u.sllll.s]); {
int argno = ipc->u.sllll.s; COUNT argno = ipc->u.sllll.s;
t = Deref(s_reg[ipc->u.sllll.s]);
if (argno != arity-1) is_last_arg = FALSE; if (argno != arity-1) is_last_arg = FALSE;
t = Deref(s_reg[argno]); t = Deref(s_reg[argno]);
if (IsVarTerm(t)) { if (IsVarTerm(t)) {
@ -6471,6 +6474,7 @@ find_caller(PredEntry *ap, yamop *code) {
sp = push_stack(sp, -argno-1, t); sp = push_stack(sp, -argno-1, t);
ipc = ipc->u.sllll.l2; ipc = ipc->u.sllll.l2;
} }
}
break; break;
case _if_not_then: case _if_not_then:
ipc = NULL; ipc = NULL;