This commit is contained in:
Vitor Santos Costa 2019-02-10 00:18:08 +00:00
parent 24b6908225
commit 3fdc260ee6
3 changed files with 38 additions and 40 deletions

View File

@ -88,26 +88,12 @@ static inline void clean_tr(tr_fr_ptr TR0 USES_REGS) {
TR = TR0;
}
//#define CELL *pt0, *pt0_end, *ptf;
//} non_singletons_t;
#define IS_VISIT_MARKER \
(IsPairTerm(d0) && RepPair(d0)>=(CELL*)to_visit0 && RepPair(d0) <= (CELL*)to_visit)
static inline bool IS_VISIT_MARKER(Term d0, void *to_visit, void *to_visit0) {
return IsPairTerm(d0) && RepPair(d0)>=(CELL*)to_visit0 && RepPair(d0) <= (CELL*)to_visit;
}
#define VISIT_MARKER AbsPair((CELL*)to_visit)
#define CYC_MARK_LIST \
if (IsPairTerm(d0) && RepPair(d0)>=(CELL*)to_visit0 && RepPair(d0) <= (CELL*)to_visit) { \
/*fprintf(stderr,"+%ld at %s\n", to_visit-to_visit0, __FUNCTION__);*/ \
MaBind(ptd0, BREAK_LOOP(*RepPair(d0))); \
} \
#define CYC_MARK_APPL \
if (IsApplTerm(d0) && RepAppl(d0)>=(Term*)to_visit0 && RepAppl(d0) <= (Term*)to_visit) { \
/*fprintf(stderr,"+%ld at %s\n", to_visit-to_visit0, __FUNCTION__);*/ \
MaBind(ptd0, BREAK_LOOP(*RepAppl(d0))); \
} \
typedef struct {
Term old_var;
@ -127,6 +113,7 @@ typedef struct non_single_struct_t {
*to_visit0 = to_visit, \
*to_visit_max = to_visit + 1024; \
\
/*fprintf(stderr, "%ld at %s\n", to_visit - to_visit0, __FUNCTION__);*/ \
while (to_visit >= to_visit0) { \
CELL d0; \
CELL *ptd0; \
@ -136,7 +123,6 @@ while (pt0 < pt0_end) { \
ptd0 = pt0; \
d0 = *ptd0; \
list_loop: \
/*fprintf(stderr, "%ld at %s\n", to_visit - to_visit0, __FUNCTION__);*/ \
deref_head(d0, var_in_term_unk); \
var_in_term_nvar : { \
if (IsPairTerm(d0)) { \
@ -146,7 +132,7 @@ list_loop: \
ptd0 = RepPair(d0); \
d0 = ptd0[0]; \
LIST0; \
if (IS_VISIT_MARKER) \
if (IS_VISIT_MARKER(d0,to_visit,to_visit0)) \
goto restart; \
to_visit->pt0 = pt0; \
to_visit->pt0_end = pt0_end; \
@ -158,16 +144,16 @@ list_loop: \
pt0_end = pt0 + 1; \
goto list_loop; \
} else if (IsApplTerm(d0)) { \
register Functor f; \
Functor f; \
/* store the terms to visit */ \
ptd0 = RepAppl(d0); \
f = (Functor)(d0 = *ptd0); \
\
if (to_visit + 32 >= to_visit_max) { \
if (IsExtensionFunctor(f)) continue; \
if (to_visit + 32 >= to_visit_max) { \
goto aux_overflow; \
} \
STRUCT0; \
if (IS_VISIT_MARKER) { \
if ( IS_VISIT_MARKER(d0,to_visit,to_visit0)) { \
\
continue; \
} \
@ -241,7 +227,7 @@ list_loop: \
}
#define CYC_LIST \
if (d0 == TermFreeTerm) { \
if (IS_VISIT_MARKER(d0,to_visit,to_visit0)) { \
/*fprintf(stderr,"+%ld at %s\n", to_visit-to_visit0, __FUNCTION__);*/ \
while (to_visit > to_visit0) { \
to_visit--; \
@ -253,7 +239,7 @@ while (to_visit > to_visit0) { \
}
#define CYC_APPL \
if (IsAtomTerm((CELL)f)) { \
if (IS_VISIT_MARKER(d0,to_visit,to_visit0)) { \
while (to_visit > to_visit0) { \
to_visit--; \
to_visit->ptd0[0] = \
@ -281,11 +267,11 @@ cyclic_complex_term( CELL *pt0, CELL *pt0_end USES_REGS) {
bool Yap_IsCyclicTerm(Term t USES_REGS) {
if (IsVarTerm(t)) {
return false;
return t;
} else if (IsPrimitiveTerm(t)) {
return false;
return t;
} else {
return cyclic_complex_term(&(t)-1, &(t)PASS_REGS);
return cyclic_complex_term(&(t)-1, &(t) PASS_REGS);
}
}
@ -314,11 +300,24 @@ static Term BREAK_LOOP(Int ddep) {
/**
@brief routine to locate all variables in a term, and its applications */
#define CYC_MARK_LIST(d0) \
if (IS_VISIT_MARKER(d0,to_visit,to_visit0)) { \
/*fprintf(stderr,"+%ld at %s\n", to_visit-to_visit0, __FUNCTION__);*/ \
MaBind(ptd0, BREAK_LOOP(d0)); \
} \
#define CYC_MARK_APPL(d0) \
if (IS_VISIT_MARKER(d0,to_visit,to_visit0)) { \
/*fprintf(stderr,"+%ld at %s\n", to_visit-to_visit0, __FUNCTION__);*/ \
MaBind(ptd0, BREAK_LOOP(d0)); \
} \
static Term cycles_in_complex_term(register CELL *pt0,
register CELL *pt0_end USES_REGS) {
int lvl = push_text_stack(); \
WALK_COMPLEX_TERM__(CYC_MARK_LIST, CYC_MARK_APPL, {});
WALK_COMPLEX_TERM__(CYC_MARK_LIST(d0), CYC_MARK_APPL(d0), {});
/* leave an empty slot to fill in later */
END_WALK();
@ -331,9 +330,9 @@ static Term cycles_in_complex_term(register CELL *pt0,
bool Yap_CyclesInTerm(Term t USES_REGS) {
if (IsVarTerm(t)) {
return false;
return t;
} else if (IsPrimitiveTerm(t)) {
return false;
return t;
} else {
return cycles_in_complex_term(&(t)-1, &(t) PASS_REGS);
}
@ -1324,7 +1323,6 @@ Int cp_link(Term t,Int i, Int j, cl_connector *q, Int max, CELL *tailp)
{
Int me;
printf("%lx i=%ld,max=%ld,H=%p\n", t, i, max, HR),
t = Deref(t);
if (IsVarTerm(t) || IsPrimitiveTerm(t)) {
if (IsIntegerTerm(t) && dataid(t,q)) {

View File

@ -581,12 +581,14 @@ static void putAtom(Atom atom, int Quote_illegal, struct write_globs *wglb) {
unsigned char *s;
wtype atom_or_symbol;
wrf stream = wglb->stream;
if (atom == NULL) return;
s = RepAtom(atom)->UStrOfAE;
if (s[0] == '\0')
return;
if (IsBlob(atom)) {
wrputblob(RepAtom(atom), Quote_illegal, wglb);
return;
}
s = RepAtom(atom)->UStrOfAE;
/* #define CRYPT_FOR_STEVE 1*/
#ifdef CRYPT_FOR_STEVE
if (Yap_GetValue(AtomCryptAtoms) != TermNil &&
@ -1103,7 +1105,7 @@ void Yap_plwrite(Term t, StreamDesc *mywrite, int max_depth, int flags,
wglb.lw = separator;
if ((flags & Handle_cyclics_f) ){
t = Yap_CyclesInTerm(t, 3, NULL PASS_REGS);
Yap_CyclesInTerm(t, 3, NULL PASS_REGS);
}
/* protect slots for portray */
@ -1123,3 +1125,4 @@ void Yap_plwrite(Term t, StreamDesc *mywrite, int max_depth, int flags,
}
pop_text_stack(lvl);
}

View File

@ -378,11 +378,8 @@ live :-
current_prolog_flag(break_level, BL ),
( BL \= 0 -> format(user_error, '[~p] ',[BL]) ;
true ),
( current_prolog_flag(toplevel_print_options, Opts) ->
write_term(user_error,Answ,Opts) ;
format(user_error,'~w',[Answ])
),
format(user_error,'.~n', []).
current_prolog_flag(toplevel_print_options, Opts),
write_term(user_error,Answ,Opts).
'$another' :-
format(user_error,' ? ',[]),