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 *
* 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,7 +465,8 @@ 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++;
}
}

View File

@ -106,10 +106,12 @@ 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; \
} \
} \
} \
@ -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;

View File

@ -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

View File

@ -5,7 +5,6 @@ set (PROGRAMS
dtproblog.yap
aproblog.yap
problog_learning.yap
problog_lbfgs.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_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).