copy_term

This commit is contained in:
Vítor Santos Costa 2019-01-24 19:03:18 +00:00
parent a3dd1a1520
commit 93bb39d5f7
5 changed files with 238 additions and 242 deletions

View File

@ -8,10 +8,8 @@
* * * *
************************************************************************** **************************************************************************
* * * *
* File: utilpreds.c * * File: utilpreds.c * Last rev: 4/03/88
* Last rev: 4/03/88 * ** mods: * comments: new utility predicates for YAP *
* mods: *
* comments: new utility predicates for YAP *
* * * *
*************************************************************************/ *************************************************************************/
#ifdef SCCS #ifdef SCCS
@ -265,11 +263,11 @@ int Yap_copy_complex_term(register CELL *pt0, register CELL *pt0_end,
*ptf++ = AbsPair(RepAppl(*headp)); *ptf++ = AbsPair(RepAppl(*headp));
continue; continue;
} }
*ptf = AbsPair(HR);
ptf++;
if (to_visit >= to_visit_max-32) { if (to_visit >= to_visit_max-32) {
expand_stack(to_visit0, to_visit, to_visit_max, struct cp_frame); expand_stack(to_visit0, to_visit, to_visit_max, struct cp_frame);
} }
*ptf = AbsPair(HR);
ptf++;
to_visit->start_cp = pt0; to_visit->start_cp = pt0;
to_visit->end_cp = pt0_end; to_visit->end_cp = pt0_end;
to_visit->to = ptf; to_visit->to = ptf;
@ -298,8 +296,8 @@ int Yap_copy_complex_term(register CELL *pt0, register CELL *pt0_end,
ptd0 = pt0; ptd0 = pt0;
goto deref; goto deref;
} else if (IsApplTerm(d0)) { } else if (IsApplTerm(d0)) {
register Functor f; Functor f;
register CELL *headp, head; CELL *headp, head;
/* store the terms to visit */ /* store the terms to visit */
headp = RepAppl(d0); headp = RepAppl(d0);
head = *headp; head = *headp;
@ -323,12 +321,25 @@ int Yap_copy_complex_term(register CELL *pt0, register CELL *pt0_end,
continue; continue;
} }
f = (Functor)(head); f = (Functor)(head);
if (share && (ground || IsExtensionFunctor(f))) {
if (IsExtensionFunctor(f)) {
if (share) {
*ptf++ = d0; *ptf++ = d0;
continue; 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) { switch ((CELL)f) {
case (CELL) FunctorDBRef: case (CELL) FunctorDBRef:
case (CELL) FunctorAttVar: case (CELL) FunctorAttVar:
@ -393,19 +404,6 @@ int Yap_copy_complex_term(register CELL *pt0, register CELL *pt0_end,
} }
continue; 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) { if (share) {
TrailedMaBind(headp,AbsPair(HR)); TrailedMaBind(headp,AbsPair(HR));
} else { } else {
@ -467,7 +465,8 @@ int Yap_copy_complex_term(register CELL *pt0, register CELL *pt0_end,
RESET_VARIABLE(ptf); RESET_VARIABLE(ptf);
if ((ADDR)TR > LOCAL_TrailTop - MIN_ARENA_SIZE) if ((ADDR)TR > LOCAL_TrailTop - MIN_ARENA_SIZE)
goto trail_overflow; goto trail_overflow;
TrailedMaBind(ptd0, (CELL)ptf); DO_TRAIL(ptd0, (CELL)ptf);
*ptd0 = (CELL)ptf;
ptf++; ptf++;
} }
} }

View File

@ -106,10 +106,12 @@ static bool callPortray(Term t, int sno USES_REGS) {
yhandle_t yt = Yap_InitHandle(t); \ yhandle_t yt = Yap_InitHandle(t); \
if (wglb->Write_Loops) { \ if (wglb->Write_Loops) { \
yhandle_t i; \ yhandle_t i; \
for (i=wglb->sl0;i<yt;i++) { \ for (i = yt - 1; i >= wglb->sl0; i--) { \
if (Yap_GetFromHandle(i) == t) { \ if (Yap_GetFromHandle(i) == t) { \
char buf[63]; snprintf(buf, 63, " @( ^^^%ld^^^ ) ",yt-i); \ char buf[63]; \
wrputs(buf,wglb->stream ); return; \ snprintf(buf, 63, " @{ ^^%ld } ", yt - i); \
wrputs(buf, wglb->stream); \
return; \
} \ } \
} \ } \
} \ } \
@ -711,11 +713,11 @@ static void write_var(CELL *t, struct write_globs *wglb,
wrputs("$AT(", wglb->stream); wrputs("$AT(", wglb->stream);
write_var(t, wglb, rwt); write_var(t, wglb, rwt);
wrputc(',', wglb->stream); wrputc(',', wglb->stream);
PROTECT(t, writeTerm(*l, 999, 1, FALSE, wglb, &nrwt)); PROTECT(*l, writeTerm(*l, 999, 1, FALSE, wglb, &nrwt));
attv = RepAttVar(t); attv = RepAttVar(t);
wrputc(',', wglb->stream); wrputc(',', wglb->stream);
l++; l++;
PROTECT(t, writeTerm(*l, 999, 1, FALSE, wglb, &nrwt)); PROTECT(*l, writeTerm(*l, 999, 1, FALSE, wglb, &nrwt));
wrclose_bracket(wglb, TRUE); wrclose_bracket(wglb, TRUE);
} }
wglb->Portray_delays = TRUE; wglb->Portray_delays = TRUE;

View File

@ -400,27 +400,23 @@ if (GMP_INCLUDE_DIRS)
) )
endif () endif ()
include_directories(H include_directories(
H/generated ${CMAKE_SOURCE_DIR}/H
include os OPTYap utf8proc JIT/HPP) ${CMAKE_SOURCE_DIR}/H/generated
include_directories(BEFORE ${CMAKE_BINARY_DIR}) ${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/os
add_subdirectory( H ) ${CMAKE_SOURCE_DIR}/OPTYap
${CMAKE_SOURCE_DIR}/utf8proc
set_directory_properties( PROPERTIES INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/JIT/HPP
H
H/generated
include
os
OPTYap
utf8proc
JIT/HPP
${GMP_INCLUDE_DIRS} ${GMP_INCLUDE_DIRS}
${READLINE_LIBRARIES} ${READLINE_LIBRARIES}
${SQLITE_LIBRARIES} ${SQLITE_LIBRARIES}
${ANDROID_LIBRARIES} ${ANDROID_LIBRARIES}
${CMAKE_BINARY_DIR}
) )
add_subdirectory( H )
#MPI STUFF #MPI STUFF
# library/mpi/mpi.c library/mpi/mpe.c # library/mpi/mpi.c library/mpi/mpe.c
# library/lammpi/yap_mpi.c library/lammpi/hash.c library/lammpi/prologterms2c.c # library/lammpi/yap_mpi.c library/lammpi/hash.c library/lammpi/prologterms2c.c

View File

@ -5,7 +5,6 @@ set (PROGRAMS
dtproblog.yap dtproblog.yap
aproblog.yap aproblog.yap
problog_learning.yap problog_learning.yap
problog_lbfgs.yap
problog_learning_lbdd.yap problog_learning_lbdd.yap
) )

View File

@ -2453,8 +2453,8 @@ uses local dynamic predicates max_probability/1 and max_proof/1
problog_max(Goal, Prob, Facts) :- problog_max(Goal, Prob, Facts) :-
problog_flag(first_threshold,InitT), problog_flag(first_threshold,InitT),
init_problog_max(InitT), init_problog_max(InitT),
problog_control(off,up), problog_control(off,up), %
problog_max_id(Goal, Prob, FactIDs),theo todo problog_max_id(Goal, Prob, FactIDs), %theo todo
( FactIDs = [_|_] -> get_fact_list(FactIDs, Facts); ( FactIDs = [_|_] -> get_fact_list(FactIDs, Facts);
Facts = FactIDs). Facts = FactIDs).