fix handling of multiassignment variables with tabling;
fix bad overflow handling when copying terms from tries.
This commit is contained in:
parent
04f3b32a9a
commit
8275f2232c
@ -2169,8 +2169,8 @@ Yap_absmi(int inp)
|
|||||||
/* multi-assignment variable */
|
/* multi-assignment variable */
|
||||||
/* so the next cell is the old value */
|
/* so the next cell is the old value */
|
||||||
#ifdef FROZEN_STACKS
|
#ifdef FROZEN_STACKS
|
||||||
pt[0] = TrailVal(pt0-1);
|
--pt0;
|
||||||
pt0 -= 1;
|
pt[0] = TrailVal(pt0);
|
||||||
#else
|
#else
|
||||||
pt[0] = TrailTerm(pt0-1);
|
pt[0] = TrailTerm(pt0-1);
|
||||||
pt0 -= 2;
|
pt0 -= 2;
|
||||||
|
@ -86,12 +86,13 @@ STD_PROTO(static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames, (tg_sol_fr_p
|
|||||||
CELL *NEW_STACK; \
|
CELL *NEW_STACK; \
|
||||||
INFORMATION_MESSAGE("Expanding trail in 64 Kbytes"); \
|
INFORMATION_MESSAGE("Expanding trail in 64 Kbytes"); \
|
||||||
old_top = Yap_TrailTop; \
|
old_top = Yap_TrailTop; \
|
||||||
Yap_growtrail(64 * 1024L, TRUE); \
|
if (!Yap_growtrail(64 * 1024L, TRUE)) {Yap_Error(OUT_OF_TRAIL_ERROR,TermNil,"trie loading"); P=FAILCODE; } else { \
|
||||||
diff = (void *)Yap_TrailTop - old_top; \
|
diff = (void *)Yap_TrailTop - old_top; \
|
||||||
NEW_STACK = (CELL *)((void *)STACK + diff); \
|
NEW_STACK = (CELL *)((void *)STACK + diff); \
|
||||||
memmove((void *)NEW_STACK, (void *)STACK, old_top - (void *)STACK); \
|
memmove((void *)NEW_STACK, (void *)STACK, old_top - (void *)STACK); \
|
||||||
STACK = NEW_STACK; \
|
STACK = NEW_STACK; \
|
||||||
STACK_BASE = (CELL *)((void *)STACK_BASE + diff); \
|
STACK_BASE = (CELL *)((void *)STACK_BASE + diff); \
|
||||||
|
}\
|
||||||
}
|
}
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
|
|
||||||
@ -398,8 +399,9 @@ void unbind_variables(tr_fr_ptr unbind_tr, tr_fr_ptr end_tr) {
|
|||||||
}
|
}
|
||||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||||
} else {
|
} else {
|
||||||
Term aux_val = TrailTerm(--unbind_tr);
|
|
||||||
CELL *aux_ptr = RepAppl(ref);
|
CELL *aux_ptr = RepAppl(ref);
|
||||||
|
--unbind_tr;
|
||||||
|
Term aux_val = TrailVal(unbind_tr);
|
||||||
*aux_ptr = aux_val;
|
*aux_ptr = aux_val;
|
||||||
#endif /* MULTI_ASSIGNMENT_VARIABLES */
|
#endif /* MULTI_ASSIGNMENT_VARIABLES */
|
||||||
}
|
}
|
||||||
@ -441,8 +443,7 @@ void rebind_variables(tr_fr_ptr rebind_tr, tr_fr_ptr end_tr) {
|
|||||||
/* first time we found the variable, let's put the new value */
|
/* first time we found the variable, let's put the new value */
|
||||||
*cell_ptr = TrailVal(rebind_tr);
|
*cell_ptr = TrailVal(rebind_tr);
|
||||||
}
|
}
|
||||||
/* skip the old value */
|
--rebind_tr;
|
||||||
rebind_tr--;
|
|
||||||
#endif /* MULTI_ASSIGNMENT_VARIABLES */
|
#endif /* MULTI_ASSIGNMENT_VARIABLES */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -475,6 +476,16 @@ void restore_bindings(tr_fr_ptr unbind_tr, tr_fr_ptr rebind_tr) {
|
|||||||
TABLING_ERROR_MESSAGE("unbind_tr > Yap_TrailTop (function restore_bindings)");
|
TABLING_ERROR_MESSAGE("unbind_tr > Yap_TrailTop (function restore_bindings)");
|
||||||
#endif /* TABLING_ERRORS */
|
#endif /* TABLING_ERRORS */
|
||||||
}
|
}
|
||||||
|
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||||
|
} else if (IsApplTerm(ref)) {
|
||||||
|
CELL *pt = RepAppl(ref);
|
||||||
|
|
||||||
|
/* AbsAppl means */
|
||||||
|
/* multi-assignment variable */
|
||||||
|
/* so the next cell is the old value */
|
||||||
|
--unbind_tr;
|
||||||
|
pt[0] = TrailVal(unbind_tr);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* look for end */
|
/* look for end */
|
||||||
@ -492,7 +503,9 @@ void restore_bindings(tr_fr_ptr unbind_tr, tr_fr_ptr rebind_tr) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* rebind loop */
|
/* rebind loop */
|
||||||
|
Yap_NEW_MAHASH((ma_h_inner_struct *)H);
|
||||||
while (rebind_tr != end_tr) {
|
while (rebind_tr != end_tr) {
|
||||||
ref = (CELL) TrailTerm(--rebind_tr);
|
ref = (CELL) TrailTerm(--rebind_tr);
|
||||||
if (IsVarTerm(ref)) {
|
if (IsVarTerm(ref)) {
|
||||||
@ -508,6 +521,15 @@ void restore_bindings(tr_fr_ptr unbind_tr, tr_fr_ptr rebind_tr) {
|
|||||||
TABLING_ERROR_MESSAGE("rebind_tr < end_tr (function restore_bindings)");
|
TABLING_ERROR_MESSAGE("rebind_tr < end_tr (function restore_bindings)");
|
||||||
#endif /* TABLING_ERRORS */
|
#endif /* TABLING_ERRORS */
|
||||||
}
|
}
|
||||||
|
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||||
|
} else {
|
||||||
|
CELL *cell_ptr = RepAppl(ref);
|
||||||
|
if (!Yap_lookup_ma_var(cell_ptr)) {
|
||||||
|
/* first time we found the variable, let's put the new value */
|
||||||
|
*cell_ptr = TrailVal(rebind_tr);
|
||||||
|
}
|
||||||
|
--rebind_tr;
|
||||||
|
#endif /* MULTI_ASSIGNMENT_VARIABLES */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user