fixes for copy_term
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1041 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
572690acd8
commit
ea52ce8b26
@ -115,7 +115,6 @@ CopyAttVar(CELL *orig, CELL ***to_visit_ptr, CELL *res)
|
|||||||
} else if (IsAtomicTerm(t)) {
|
} else if (IsAtomicTerm(t)) {
|
||||||
newv->Atts[2*j+1] = t;
|
newv->Atts[2*j+1] = t;
|
||||||
} else {
|
} else {
|
||||||
#ifdef RATIONAL_TREES
|
|
||||||
to_visit[0] = attv->Atts+2*j;
|
to_visit[0] = attv->Atts+2*j;
|
||||||
to_visit[1] = attv->Atts+2*j+1;
|
to_visit[1] = attv->Atts+2*j+1;
|
||||||
to_visit[2] = newv->Atts+2*j+1;
|
to_visit[2] = newv->Atts+2*j+1;
|
||||||
@ -123,12 +122,6 @@ CopyAttVar(CELL *orig, CELL ***to_visit_ptr, CELL *res)
|
|||||||
/* fool the system into thinking we had a variable there */
|
/* fool the system into thinking we had a variable there */
|
||||||
attv->Atts[2*j+1] = AbsAppl(H);
|
attv->Atts[2*j+1] = AbsAppl(H);
|
||||||
to_visit += 4;
|
to_visit += 4;
|
||||||
#else
|
|
||||||
to_visit[0] = attv->Atts+2*j;
|
|
||||||
to_visit[1] = attv->Atts+2*j+1;
|
|
||||||
to_visit[2] = newv->Atts+2*j+1;
|
|
||||||
to_visit += 3;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*to_visit_ptr = to_visit;
|
*to_visit_ptr = to_visit;
|
||||||
|
@ -315,7 +315,8 @@ copy_suspended_goals(sus_record *pt, CELL ***to_visit_ptr)
|
|||||||
to_visit[0] = &(pt->SG)-1;
|
to_visit[0] = &(pt->SG)-1;
|
||||||
to_visit[1] = &(pt->SG);
|
to_visit[1] = &(pt->SG);
|
||||||
to_visit[2] = &(gf->SG);
|
to_visit[2] = &(gf->SG);
|
||||||
*to_visit_ptr = to_visit+3;
|
to_visit[3] = (CELL *)(*to_visit[0]);
|
||||||
|
*to_visit_ptr = to_visit+4;
|
||||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||||
gf->NS = UpdateSVarList(gf);
|
gf->NS = UpdateSVarList(gf);
|
||||||
#endif
|
#endif
|
||||||
|
@ -59,8 +59,8 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *H
|
|||||||
{
|
{
|
||||||
|
|
||||||
CELL **to_visit0, **to_visit = (CELL **)Yap_PreAllocCodeSpace();
|
CELL **to_visit0, **to_visit = (CELL **)Yap_PreAllocCodeSpace();
|
||||||
tr_fr_ptr TR0 = TR;
|
|
||||||
CELL *HB0 = HB;
|
CELL *HB0 = HB;
|
||||||
|
tr_fr_ptr TR0 = TR;
|
||||||
#ifdef COROUTINING
|
#ifdef COROUTINING
|
||||||
CELL *dvars = NULL;
|
CELL *dvars = NULL;
|
||||||
#endif
|
#endif
|
||||||
@ -185,41 +185,20 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *H
|
|||||||
if (IsAttachedTerm((CELL)ptd0)) {
|
if (IsAttachedTerm((CELL)ptd0)) {
|
||||||
/* if unbound, call the standard copy term routine */
|
/* if unbound, call the standard copy term routine */
|
||||||
CELL **bp[1];
|
CELL **bp[1];
|
||||||
tr_fr_ptr CurTR;
|
|
||||||
if (ptd0 >= dvars) {
|
|
||||||
*ptf++ = (CELL) ptd0;
|
|
||||||
} else {
|
|
||||||
if (dvars == NULL) {
|
if (dvars == NULL) {
|
||||||
dvars = (CELL *)Yap_ReadTimedVar(DelayedVars);
|
dvars = (CELL *)Yap_ReadTimedVar(DelayedVars);
|
||||||
}
|
}
|
||||||
|
if (ptd0 >= dvars) {
|
||||||
|
*ptf++ = (CELL) ptd0;
|
||||||
|
} else {
|
||||||
bp[0] = to_visit;
|
bp[0] = to_visit;
|
||||||
CurTR = TR;
|
|
||||||
HB = HB0;
|
HB = HB0;
|
||||||
if (!attas[ExtFromCell(ptd0)].copy_term_op(ptd0, bp, ptf)) {
|
if (!attas[ExtFromCell(ptd0)].copy_term_op(ptd0, bp, ptf)) {
|
||||||
goto overflow;
|
goto overflow;
|
||||||
}
|
}
|
||||||
to_visit = bp[0];
|
to_visit = bp[0];
|
||||||
HB = HLow;
|
HB = HLow;
|
||||||
if (CurTR != TR) {
|
|
||||||
/* Problem here is that the attached routine might
|
|
||||||
* have changed the list of suspended goals and stored
|
|
||||||
* new entries in the trail. This should be quite
|
|
||||||
* rare, so for simplicity we just swap cells from
|
|
||||||
* bottom and top of Trail, not nice but not worth
|
|
||||||
* complicating everything else.
|
|
||||||
*/
|
|
||||||
CELL *pt1 = (CELL *)TR0;
|
|
||||||
CELL *pt2 = (CELL *)CurTR;
|
|
||||||
|
|
||||||
while (pt2 < (CELL *)TR) {
|
|
||||||
CELL o = *pt1;
|
|
||||||
pt1++;
|
|
||||||
pt2++;
|
|
||||||
pt1[-1] = pt2[-1];
|
|
||||||
pt2[-1] = o;
|
|
||||||
}
|
|
||||||
TR0 = (tr_fr_ptr)pt1;
|
|
||||||
}
|
|
||||||
ptf++;
|
ptf++;
|
||||||
Bind_Global(ptd0, ptf[-1]);
|
Bind_Global(ptd0, ptf[-1]);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user