support PL_skip_list and PL_unify_bool.
This commit is contained in:
parent
91cada2661
commit
d3c7800ab4
@ -416,7 +416,7 @@ X_API Term STD_PROTO(YAP_MkListFromTerms,(Term *,Int));
|
||||
X_API Term STD_PROTO(YAP_MkNewPairTerm,(void));
|
||||
X_API Term STD_PROTO(YAP_HeadOfTerm,(Term));
|
||||
X_API Term STD_PROTO(YAP_TailOfTerm,(Term));
|
||||
X_API int STD_PROTO(YAP_SkipList,(Term *, Term **));
|
||||
X_API Int STD_PROTO(YAP_SkipList,(Term *, Term **));
|
||||
X_API Term STD_PROTO(YAP_MkApplTerm,(Functor,UInt,Term *));
|
||||
X_API Term STD_PROTO(YAP_MkNewApplTerm,(Functor,UInt));
|
||||
X_API Functor STD_PROTO(YAP_FunctorOfTerm,(Term));
|
||||
@ -1050,14 +1050,15 @@ YAP_TailOfTerm(Term t)
|
||||
return (TailOfTerm(t));
|
||||
}
|
||||
|
||||
X_API int
|
||||
X_API Int
|
||||
YAP_SkipList(Term *l, Term **tailp)
|
||||
{
|
||||
return Yap_SkipList(l, tailp);
|
||||
Int length = 0;
|
||||
Term *s; /* slow */
|
||||
Term v; /* temporary */
|
||||
|
||||
v = Derefa(l);
|
||||
do_derefa(v,l,derefa_unk,derefa_nonvar);
|
||||
s = l;
|
||||
|
||||
if ( IsPairTerm(*l) )
|
||||
@ -1070,7 +1071,8 @@ YAP_SkipList(Term *l, Term **tailp)
|
||||
}
|
||||
lam++;
|
||||
length++;
|
||||
l = RepPair(*l)+1; v = Derefa(l);
|
||||
l = RepPair(*l)+1;
|
||||
do_derefa(v,l,derefa2_unk,derefa2_nonvar);
|
||||
} while ( *l != *s && IsPairTerm(*l) );
|
||||
}
|
||||
*tailp = l;
|
||||
@ -3550,15 +3552,15 @@ YAP_FloatsToList(double *dblp, size_t sz)
|
||||
if (!sz)
|
||||
return TermNil;
|
||||
while (ASP-1024 < H + sz*(2+2+SIZEOF_DOUBLE/SIZEOF_LONG_INT)) {
|
||||
if (dblp > H0 && dblp < H) {
|
||||
if ((CELL *)dblp > H0 && (CELL *)dblp < H) {
|
||||
/* we are in trouble */
|
||||
LOCAL_OpenArray = dblp;
|
||||
LOCAL_OpenArray = (CELL *)dblp;
|
||||
}
|
||||
if (!dogc( PASS_REGS1 )) {
|
||||
RECOVER_H();
|
||||
return 0L;
|
||||
}
|
||||
dblp = LOCAL_OpenArray;
|
||||
dblp = (double *)LOCAL_OpenArray;
|
||||
LOCAL_OpenArray = NULL;
|
||||
}
|
||||
t = AbsPair(H);
|
||||
|
@ -215,6 +215,10 @@ typedef void *PL_engine_t;
|
||||
#define PL_CHAR (38) /* int */
|
||||
#define PL_CODE (39) /* int */
|
||||
#define PL_BYTE (40) /* int */
|
||||
/* PL_skip_list() */
|
||||
#define PL_PARTIAL_LIST (41) /* a partial list */
|
||||
#define PL_CYCLIC_TERM (42) /* a cyclic list/term */
|
||||
#define PL_NOT_A_LIST (43) /* Object is not a list */
|
||||
|
||||
#define CVT_ATOM 0x0001
|
||||
#define CVT_STRING 0x0002
|
||||
@ -502,11 +506,19 @@ extern X_API int PL_unify_list_chars(term_t, const char *);
|
||||
extern X_API int PL_unify_list_ncodes(term_t, size_t, const char *);
|
||||
extern X_API int PL_unify_nil(term_t);
|
||||
extern X_API int PL_unify_pointer(term_t, void *);
|
||||
extern X_API int PL_unify_bool(term_t, int);
|
||||
extern X_API int PL_unify_string_chars(term_t, const char *);
|
||||
extern X_API int PL_unify_string_nchars(term_t, size_t, const char *);
|
||||
extern X_API int PL_unify_term(term_t,...);
|
||||
extern X_API int PL_unify_chars(term_t, int, size_t, const char *);
|
||||
extern X_API int PL_unify_chars_diff(term_t, term_t, int, size_t, const char *);
|
||||
/*******************************
|
||||
* LISTS *
|
||||
*******************************/
|
||||
|
||||
PL_EXPORT(int) PL_skip_list(term_t list, term_t tail, size_t *len);
|
||||
|
||||
|
||||
extern X_API int PL_unify_wchars(term_t, int, size_t, const pl_wchar_t *);
|
||||
extern X_API int PL_unify_wchars_diff(term_t, term_t, int, size_t, const pl_wchar_t *);
|
||||
extern X_API int PL_chars_to_term(const char *,term_t);
|
||||
|
@ -193,7 +193,7 @@ extern X_API YAP_Term PROTO(YAP_HeadOfTerm,(YAP_Term));
|
||||
extern X_API YAP_Term PROTO(YAP_TailOfTerm,(YAP_Term));
|
||||
|
||||
/* Int AddressOfTailOfTerm(Term *, Term **) */
|
||||
extern X_API int PROTO(YAP_SkipList,(YAP_Term *, YAP_Term **));
|
||||
extern X_API YAP_Int PROTO(YAP_SkipList,(YAP_Term *, YAP_Term **));
|
||||
|
||||
/* Term TailOfTerm(Term) */
|
||||
extern X_API YAP_Term PROTO(YAP_TermNil,(void));
|
||||
|
@ -460,6 +460,13 @@ X_API int PL_get_int64(term_t ts, int64_t *i)
|
||||
#endif
|
||||
}
|
||||
|
||||
X_API int PL_unify_bool(term_t t, int a)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term iterm = (a ? MkAtomTerm(AtomTrue) : MkAtomTerm(AtomFalse) );
|
||||
return Yap_unify(Yap_GetFromSlot(t PASS_REGS),iterm);
|
||||
}
|
||||
|
||||
|
||||
#if USE_GMP
|
||||
|
||||
@ -1766,6 +1773,34 @@ X_API int PL_is_list(term_t ts)
|
||||
return Yap_IsListTerm(t);
|
||||
}
|
||||
|
||||
X_API int
|
||||
PL_skip_list(term_t list, term_t tail, size_t *len)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term *l = Yap_AddressFromSlot(list PASS_REGS);
|
||||
Term *t;
|
||||
intptr_t length;
|
||||
|
||||
length = Yap_SkipList(l, &t);
|
||||
if ( len )
|
||||
*len = length;
|
||||
if ( tail )
|
||||
{ Term t2 = Yap_GetFromSlot(tail);
|
||||
|
||||
Yap_unify(t2, *t);
|
||||
}
|
||||
|
||||
if ( *t == TermNil )
|
||||
return PL_LIST;
|
||||
else if ( IsVarTerm(*t) )
|
||||
return PL_PARTIAL_LIST;
|
||||
else if ( IsPairTerm(*t) )
|
||||
return PL_CYCLIC_TERM;
|
||||
else
|
||||
return PL_NOT_A_LIST;
|
||||
}
|
||||
|
||||
|
||||
X_API int PL_is_number(term_t ts)
|
||||
{
|
||||
CACHE_REGS
|
||||
|
Reference in New Issue
Block a user