copy_term
This commit is contained in:
parent
a3dd1a1520
commit
93bb39d5f7
@ -8,10 +8,8 @@
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: utilpreds.c *
|
||||
* Last rev: 4/03/88 *
|
||||
* mods: *
|
||||
* comments: new utility predicates for YAP *
|
||||
* File: utilpreds.c * Last rev: 4/03/88
|
||||
** mods: * comments: new utility predicates for YAP *
|
||||
* *
|
||||
*************************************************************************/
|
||||
#ifdef SCCS
|
||||
@ -265,11 +263,11 @@ int Yap_copy_complex_term(register CELL *pt0, register CELL *pt0_end,
|
||||
*ptf++ = AbsPair(RepAppl(*headp));
|
||||
continue;
|
||||
}
|
||||
*ptf = AbsPair(HR);
|
||||
ptf++;
|
||||
if (to_visit >= to_visit_max-32) {
|
||||
expand_stack(to_visit0, to_visit, to_visit_max, struct cp_frame);
|
||||
}
|
||||
*ptf = AbsPair(HR);
|
||||
ptf++;
|
||||
to_visit->start_cp = pt0;
|
||||
to_visit->end_cp = pt0_end;
|
||||
to_visit->to = ptf;
|
||||
@ -298,8 +296,8 @@ int Yap_copy_complex_term(register CELL *pt0, register CELL *pt0_end,
|
||||
ptd0 = pt0;
|
||||
goto deref;
|
||||
} else if (IsApplTerm(d0)) {
|
||||
register Functor f;
|
||||
register CELL *headp, head;
|
||||
Functor f;
|
||||
CELL *headp, head;
|
||||
/* store the terms to visit */
|
||||
headp = RepAppl(d0);
|
||||
head = *headp;
|
||||
@ -323,12 +321,25 @@ int Yap_copy_complex_term(register CELL *pt0, register CELL *pt0_end,
|
||||
continue;
|
||||
}
|
||||
f = (Functor)(head);
|
||||
|
||||
if (IsExtensionFunctor(f)) {
|
||||
if (share) {
|
||||
if (share && (ground || IsExtensionFunctor(f))) {
|
||||
*ptf++ = d0;
|
||||
continue;
|
||||
}
|
||||
/* store the terms to visit */
|
||||
to_visit->start_cp = pt0;
|
||||
to_visit->end_cp = pt0_end;
|
||||
to_visit->to = ptf;
|
||||
to_visit->curp = headp;
|
||||
to_visit->oldv = head;
|
||||
to_visit->ground = ground;
|
||||
if (++to_visit >= to_visit_max-32) {
|
||||
expand_stack(to_visit0, to_visit, to_visit_max, struct cp_frame);
|
||||
}
|
||||
*ptf = AbsAppl(HR);
|
||||
ptf++;
|
||||
ptf = HR;
|
||||
|
||||
if (IsExtensionFunctor(f)) {
|
||||
switch ((CELL)f) {
|
||||
case (CELL) FunctorDBRef:
|
||||
case (CELL) FunctorAttVar:
|
||||
@ -393,19 +404,6 @@ int Yap_copy_complex_term(register CELL *pt0, register CELL *pt0_end,
|
||||
}
|
||||
continue;
|
||||
}
|
||||
*ptf = AbsAppl(HR);
|
||||
ptf++;
|
||||
/* store the terms to visit */
|
||||
to_visit->start_cp = pt0;
|
||||
to_visit->end_cp = pt0_end;
|
||||
to_visit->to = ptf;
|
||||
to_visit->curp = headp;
|
||||
d0 = *headp;
|
||||
to_visit->oldv = d0;
|
||||
to_visit->ground = ground;
|
||||
if (++to_visit >= to_visit_max-32) {
|
||||
expand_stack(to_visit0, to_visit, to_visit_max, struct cp_frame);
|
||||
}
|
||||
if (share) {
|
||||
TrailedMaBind(headp,AbsPair(HR));
|
||||
} else {
|
||||
@ -467,14 +465,15 @@ int Yap_copy_complex_term(register CELL *pt0, register CELL *pt0_end,
|
||||
RESET_VARIABLE(ptf);
|
||||
if ((ADDR)TR > LOCAL_TrailTop - MIN_ARENA_SIZE)
|
||||
goto trail_overflow;
|
||||
TrailedMaBind(ptd0, (CELL)ptf);
|
||||
DO_TRAIL(ptd0, (CELL)ptf);
|
||||
*ptd0 = (CELL)ptf;
|
||||
ptf++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Do we still have compound terms to visit */
|
||||
if (to_visit > to_visit0) {
|
||||
/* Do we still have compound terms to visit */
|
||||
if (to_visit > to_visit0) {
|
||||
to_visit--;
|
||||
if (!share)
|
||||
*to_visit->curp = to_visit->oldv;
|
||||
@ -485,44 +484,44 @@ if (to_visit > to_visit0) {
|
||||
goto loop;
|
||||
}
|
||||
|
||||
/* restore our nice, friendly, term to its original state */
|
||||
/* restore our nice, friendly, term to its original state */
|
||||
clean_complex_tr(TR0 PASS_REGS);
|
||||
/* follow chain of multi-assigned variables */
|
||||
pop_text_stack(lvl);
|
||||
return 0;
|
||||
|
||||
|
||||
overflow:
|
||||
/* oops, we're in trouble */
|
||||
HR = HLow;
|
||||
/* we've done it */
|
||||
/* restore our nice, friendly, term to its original state */
|
||||
HB = HB0;
|
||||
while (to_visit > to_visit0) {
|
||||
overflow:
|
||||
/* oops, we're in trouble */
|
||||
HR = HLow;
|
||||
/* we've done it */
|
||||
/* restore our nice, friendly, term to its original state */
|
||||
HB = HB0;
|
||||
while (to_visit > to_visit0) {
|
||||
to_visit--;
|
||||
pt0 = to_visit->start_cp;
|
||||
pt0_end = to_visit->end_cp;
|
||||
ptf = to_visit->to;
|
||||
}
|
||||
reset_trail(TR0);
|
||||
pop_text_stack(lvl);
|
||||
return -1;
|
||||
reset_trail(TR0);
|
||||
pop_text_stack(lvl);
|
||||
return -1;
|
||||
|
||||
trail_overflow:
|
||||
/* oops, we're in trouble */
|
||||
HR = HLow;
|
||||
/* we've done it */
|
||||
/* restore our nice, friendly, term to its original state */
|
||||
HB = HB0;
|
||||
while (to_visit > to_visit0) {
|
||||
trail_overflow:
|
||||
/* oops, we're in trouble */
|
||||
HR = HLow;
|
||||
/* we've done it */
|
||||
/* restore our nice, friendly, term to its original state */
|
||||
HB = HB0;
|
||||
while (to_visit > to_visit0) {
|
||||
to_visit--;
|
||||
pt0 = to_visit->start_cp;
|
||||
pt0_end = to_visit->end_cp;
|
||||
ptf = to_visit->to;
|
||||
}
|
||||
reset_trail(TR0);
|
||||
pop_text_stack(lvl);
|
||||
return -4;
|
||||
reset_trail(TR0);
|
||||
pop_text_stack(lvl);
|
||||
return -4;
|
||||
}
|
||||
|
||||
|
||||
|
14
C/write.c
14
C/write.c
@ -106,15 +106,17 @@ static bool callPortray(Term t, int sno USES_REGS) {
|
||||
yhandle_t yt = Yap_InitHandle(t); \
|
||||
if (wglb->Write_Loops) { \
|
||||
yhandle_t i; \
|
||||
for (i=wglb->sl0;i<yt;i++) { \
|
||||
for (i = yt - 1; i >= wglb->sl0; i--) { \
|
||||
if (Yap_GetFromHandle(i) == t) { \
|
||||
char buf[63]; snprintf(buf, 63, " @( ^^^%ld^^^ ) ",yt-i); \
|
||||
wrputs(buf,wglb->stream ); return; \
|
||||
char buf[63]; \
|
||||
snprintf(buf, 63, " @{ ^^%ld } ", yt - i); \
|
||||
wrputs(buf, wglb->stream); \
|
||||
return; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
F; \
|
||||
t = Yap_PopHandle(yt);\
|
||||
t = Yap_PopHandle(yt); \
|
||||
}
|
||||
static void wrputn(Int, struct write_globs *);
|
||||
static void wrputf(Float, struct write_globs *);
|
||||
@ -711,11 +713,11 @@ static void write_var(CELL *t, struct write_globs *wglb,
|
||||
wrputs("$AT(", wglb->stream);
|
||||
write_var(t, wglb, rwt);
|
||||
wrputc(',', wglb->stream);
|
||||
PROTECT(t, writeTerm(*l, 999, 1, FALSE, wglb, &nrwt));
|
||||
PROTECT(*l, writeTerm(*l, 999, 1, FALSE, wglb, &nrwt));
|
||||
attv = RepAttVar(t);
|
||||
wrputc(',', wglb->stream);
|
||||
l++;
|
||||
PROTECT(t, writeTerm(*l, 999, 1, FALSE, wglb, &nrwt));
|
||||
PROTECT(*l, writeTerm(*l, 999, 1, FALSE, wglb, &nrwt));
|
||||
wrclose_bracket(wglb, TRUE);
|
||||
}
|
||||
wglb->Portray_delays = TRUE;
|
||||
|
@ -400,27 +400,23 @@ if (GMP_INCLUDE_DIRS)
|
||||
)
|
||||
endif ()
|
||||
|
||||
include_directories(H
|
||||
H/generated
|
||||
include os OPTYap utf8proc JIT/HPP)
|
||||
include_directories(BEFORE ${CMAKE_BINARY_DIR})
|
||||
|
||||
add_subdirectory( H )
|
||||
|
||||
set_directory_properties( PROPERTIES INCLUDE_DIRECTORIES
|
||||
H
|
||||
H/generated
|
||||
include
|
||||
os
|
||||
OPTYap
|
||||
utf8proc
|
||||
JIT/HPP
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}/H
|
||||
${CMAKE_SOURCE_DIR}/H/generated
|
||||
${CMAKE_SOURCE_DIR}/include
|
||||
${CMAKE_SOURCE_DIR}/os
|
||||
${CMAKE_SOURCE_DIR}/OPTYap
|
||||
${CMAKE_SOURCE_DIR}/utf8proc
|
||||
${CMAKE_SOURCE_DIR}/JIT/HPP
|
||||
${GMP_INCLUDE_DIRS}
|
||||
${READLINE_LIBRARIES}
|
||||
${SQLITE_LIBRARIES}
|
||||
${ANDROID_LIBRARIES}
|
||||
${CMAKE_BINARY_DIR}
|
||||
)
|
||||
|
||||
add_subdirectory( H )
|
||||
|
||||
#MPI STUFF
|
||||
# library/mpi/mpi.c library/mpi/mpe.c
|
||||
# library/lammpi/yap_mpi.c library/lammpi/hash.c library/lammpi/prologterms2c.c
|
||||
|
@ -5,7 +5,6 @@ set (PROGRAMS
|
||||
dtproblog.yap
|
||||
aproblog.yap
|
||||
problog_learning.yap
|
||||
problog_lbfgs.yap
|
||||
problog_learning_lbdd.yap
|
||||
)
|
||||
|
||||
|
@ -2453,8 +2453,8 @@ uses local dynamic predicates max_probability/1 and max_proof/1
|
||||
problog_max(Goal, Prob, Facts) :-
|
||||
problog_flag(first_threshold,InitT),
|
||||
init_problog_max(InitT),
|
||||
problog_control(off,up),
|
||||
problog_max_id(Goal, Prob, FactIDs),theo todo
|
||||
problog_control(off,up), %
|
||||
problog_max_id(Goal, Prob, FactIDs), %theo todo
|
||||
( FactIDs = [_|_] -> get_fact_list(FactIDs, Facts);
|
||||
Facts = FactIDs).
|
||||
|
||||
|
Reference in New Issue
Block a user