extend C-interface to support b-prolog like stuff
This commit is contained in:
parent
fc2a50b67e
commit
9f2b0c7e70
@ -384,12 +384,14 @@ X_API Bool STD_PROTO(YAP_IsNonVarTerm,(Term));
|
||||
X_API Bool STD_PROTO(YAP_IsIntTerm,(Term));
|
||||
X_API Bool STD_PROTO(YAP_IsLongIntTerm,(Term));
|
||||
X_API Bool STD_PROTO(YAP_IsBigNumTerm,(Term));
|
||||
X_API Bool STD_PROTO(YAP_IsNumberTerm,(Term));
|
||||
X_API Bool STD_PROTO(YAP_IsRationalTerm,(Term));
|
||||
X_API Bool STD_PROTO(YAP_IsFloatTerm,(Term));
|
||||
X_API Bool STD_PROTO(YAP_IsDbRefTerm,(Term));
|
||||
X_API Bool STD_PROTO(YAP_IsAtomTerm,(Term));
|
||||
X_API Bool STD_PROTO(YAP_IsPairTerm,(Term));
|
||||
X_API Bool STD_PROTO(YAP_IsApplTerm,(Term));
|
||||
X_API Bool STD_PROTO(YAP_IsCompoundTerm,(Term));
|
||||
X_API Bool STD_PROTO(YAP_IsExternalDataInStackTerm,(Term));
|
||||
X_API Bool STD_PROTO(YAP_IsOpaqueObjectTerm,(Term, int));
|
||||
X_API Term STD_PROTO(YAP_MkIntTerm,(Int));
|
||||
@ -427,6 +429,7 @@ X_API void STD_PROTO(YAP_cut_up,(void));
|
||||
X_API Int STD_PROTO(YAP_Unify,(Term,Term));
|
||||
X_API int STD_PROTO(YAP_Unifiable,(Term,Term));
|
||||
X_API int STD_PROTO(YAP_Reset,(void));
|
||||
X_API Int STD_PROTO(YAP_ListLength,(Term));
|
||||
X_API Int STD_PROTO(YAP_Init,(YAP_init_args *));
|
||||
X_API Int STD_PROTO(YAP_FastInit,(char *));
|
||||
X_API PredEntry *STD_PROTO(YAP_FunctorToPred,(Functor));
|
||||
@ -531,6 +534,9 @@ X_API void *STD_PROTO(YAP_Record,(Term));
|
||||
X_API Term STD_PROTO(YAP_Recorded,(void *));
|
||||
X_API int STD_PROTO(YAP_Erase,(void *));
|
||||
X_API int STD_PROTO(YAP_Variant,(Term, Term));
|
||||
X_API Int STD_PROTO(YAP_NumberVars,(Term, Int));
|
||||
X_API Term STD_PROTO(YAP_UnNumberVars,(Term));
|
||||
X_API int STD_PROTO(YAP_IsNumberedVariable,(Term));
|
||||
X_API int STD_PROTO(YAP_ExactlyEqual,(Term, Term));
|
||||
X_API Int STD_PROTO(YAP_TermHash,(Term, Int, Int, int));
|
||||
X_API void STD_PROTO(YAP_signal,(int));
|
||||
@ -603,6 +609,12 @@ YAP_IsIntTerm(Term t)
|
||||
return IsIntegerTerm(t);
|
||||
}
|
||||
|
||||
X_API Bool
|
||||
YAP_IsNumberTerm(Term t)
|
||||
{
|
||||
return IsIntegerTerm(t) || IsIntTerm(t) || IsFloatTerm(t) || IsBigIntTerm(t);
|
||||
}
|
||||
|
||||
X_API Bool
|
||||
YAP_IsLongIntTerm(Term t)
|
||||
{
|
||||
@ -683,6 +695,13 @@ YAP_IsApplTerm(Term t)
|
||||
return (IsApplTerm(t) && !IsExtensionFunctor(FunctorOfTerm(t)));
|
||||
}
|
||||
|
||||
X_API Bool
|
||||
YAP_IsCompoundTerm(Term t)
|
||||
{
|
||||
return (IsApplTerm(t) && !IsExtensionFunctor(FunctorOfTerm(t))) ||
|
||||
IsPairTerm(t);
|
||||
}
|
||||
|
||||
|
||||
X_API Term
|
||||
YAP_MkIntTerm(Int n)
|
||||
@ -1188,7 +1207,7 @@ YAP_Unifiable(Term t1, Term t2)
|
||||
int out;
|
||||
BACKUP_MACHINE_REGS();
|
||||
|
||||
out = Yap_unifiable(t1, t2);
|
||||
out = Yap_Unifiable(t1, t2);
|
||||
|
||||
RECOVER_MACHINE_REGS();
|
||||
return out;
|
||||
@ -3854,3 +3873,38 @@ YAP_TagOfTerm(Term t)
|
||||
return YAP_TAG_APPL;
|
||||
}
|
||||
}
|
||||
|
||||
int YAP_BPROLOG_exception;
|
||||
Term YAP_BPROLOG_curr_toam_status;
|
||||
|
||||
Int
|
||||
YAP_ListLength(Term t) {
|
||||
Int l = 0;
|
||||
while (TRUE) {
|
||||
if (IsVarTerm(t)) return -1;
|
||||
if (t == TermNil)
|
||||
return l;
|
||||
if (!IsPairTerm(t))
|
||||
return -1;
|
||||
l++;
|
||||
t = TailOfTerm(t);
|
||||
}
|
||||
}
|
||||
|
||||
Int
|
||||
YAP_NumberVars(Term t, Int nbv) {
|
||||
return Yap_NumberVars(t, nbv);
|
||||
}
|
||||
|
||||
Term
|
||||
YAP_UnNumberVars(Term t) {
|
||||
return Yap_UnNumberTerm(t);
|
||||
}
|
||||
|
||||
int
|
||||
YAP_IsNumberedVariable(Term t) {
|
||||
return IsApplTerm(t) &&
|
||||
FunctorOfTerm(t) == FunctorVar &&
|
||||
IsIntegerTerm(ArgOfTerm(1,t));
|
||||
}
|
||||
|
||||
|
@ -109,6 +109,9 @@ extern X_API YAP_Bool PROTO(YAP_IsRationalTerm,(YAP_Term));
|
||||
/* YAP_Bool IsFloatTerm(YAP_Term) */
|
||||
extern X_API YAP_Bool PROTO(YAP_IsFloatTerm,(YAP_Term));
|
||||
|
||||
/* YAP_Bool IsNumberTerm(YAP_Term) */
|
||||
extern X_API YAP_Bool PROTO(YAP_IsNumberTerm,(YAP_Term));
|
||||
|
||||
/* YAP_Bool IsDbRefTerm(YAP_Term) */
|
||||
extern X_API YAP_Bool PROTO(YAP_IsDbRefTerm,(YAP_Term));
|
||||
|
||||
@ -121,6 +124,9 @@ extern X_API YAP_Bool PROTO(YAP_IsPairTerm,(YAP_Term));
|
||||
/* YAP_Bool IsApplTerm(YAP_Term) */
|
||||
extern X_API YAP_Bool PROTO(YAP_IsApplTerm,(YAP_Term));
|
||||
|
||||
/* YAP_Bool IsCompoundTerm(YAP_Term) */
|
||||
extern X_API YAP_Bool PROTO(YAP_IsCompoundTerm,(YAP_Term));
|
||||
|
||||
/* Term MkIntTerm(YAP_Int) */
|
||||
extern X_API YAP_Term PROTO(YAP_MkIntTerm,(YAP_Int));
|
||||
|
||||
@ -237,6 +243,9 @@ extern X_API void PROTO(YAP_UserCPredicateWithArgs,(CONST char *, YAP_Bool (*)(v
|
||||
arity, int extra) */
|
||||
extern X_API void PROTO(YAP_UserBackCPredicate,(CONST char *, YAP_Bool (*)(void), YAP_Bool (*)(void), YAP_Arity, unsigned int));
|
||||
|
||||
/* YAP_Int YAP_ListLength(YAP_Term t) */
|
||||
extern X_API YAP_Int PROTO(YAP_ListLength,(YAP_Term));
|
||||
|
||||
/* void UserBackCPredicate(char *name, int *init(), int *cont(), int *cut(), int
|
||||
arity, int extra) */
|
||||
extern X_API void PROTO(YAP_UserBackCutCPredicate,(CONST char *, YAP_Bool (*)(void), YAP_Bool (*)(void), YAP_Bool (*)(void), YAP_Arity, unsigned int));
|
||||
@ -310,7 +319,7 @@ extern X_API void PROTO(YAP_Error,(int, YAP_Term, CONST char *, ...));
|
||||
extern X_API YAP_Term PROTO(YAP_Read,(void *));
|
||||
|
||||
/* void YAP_Write(YAP_Term,void (*)(int),int) */
|
||||
extern X_API void PROTO(YAP_Write,(YAP_Term,void (*)(int),int));
|
||||
extern X_API void PROTO(YAP_Write,(YAP_Term,void *,int));
|
||||
|
||||
/* void YAP_WriteBufffer(YAP_Term,char *,unsgined int,int) */
|
||||
extern X_API void PROTO(YAP_WriteBuffer,(YAP_Term,char *,unsigned int,int));
|
||||
@ -534,6 +543,9 @@ extern X_API int PROTO(YAP_Erase,(void *));
|
||||
|
||||
/* term utilities */
|
||||
extern X_API int PROTO(YAP_Variant,(YAP_Term,YAP_Term));
|
||||
extern X_API YAP_Int PROTO(YAP_NumberVars,(YAP_Term,YAP_Int));
|
||||
extern X_API YAP_Term PROTO(YAP_UnNumberVars,(YAP_Term));
|
||||
extern X_API int PROTO(YAP_IsNumberedVariable,(YAP_Term));
|
||||
extern X_API int PROTO(YAP_Unifiable,(YAP_Term,YAP_Term));
|
||||
extern X_API int PROTO(YAP_ExactlyEqual,(YAP_Term,YAP_Term));
|
||||
extern X_API YAP_Int PROTO(YAP_TermHash,(YAP_Term, YAP_Int, YAP_Int, int));
|
||||
|
Reference in New Issue
Block a user