Python support
This commit is contained in:
parent
7ca285eb40
commit
8d64753c54
@ -2258,7 +2258,7 @@ X_API bool YAP_DelayInit(YAP_ModInit_t f, const char s[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void start_modules(void) {
|
static void start_modules(void) {
|
||||||
Term cm = CurrentModule;
|
Term cm = CurrentModule;
|
||||||
for (size_t i = 0; i < n_mdelays; i++) {
|
for (size_t i = 0; i < n_mdelays; i++) {
|
||||||
CurrentModule = MkAtomTerm(YAP_LookupAtom(m_delays[i].s));
|
CurrentModule = MkAtomTerm(YAP_LookupAtom(m_delays[i].s));
|
||||||
m_delays[i].f();
|
m_delays[i].f();
|
||||||
|
@ -392,7 +392,6 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
|||||||
where = TermNil;
|
where = TermNil;
|
||||||
LOCAL_PrologMode &= ~AbortMode;
|
LOCAL_PrologMode &= ~AbortMode;
|
||||||
LOCAL_CurrentError = type;
|
LOCAL_CurrentError = type;
|
||||||
LOCAL_PrologMode |= InErrorMode;
|
|
||||||
/* make sure failure will be seen at next port */
|
/* make sure failure will be seen at next port */
|
||||||
// no need to lock & unlock
|
// no need to lock & unlock
|
||||||
if (LOCAL_PrologMode & AsyncIntMode)
|
if (LOCAL_PrologMode & AsyncIntMode)
|
||||||
|
@ -463,7 +463,7 @@ p_cyclic( USES_REGS1 )
|
|||||||
return rational_tree(t);
|
return rational_tree(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Yap_IsAcyclicTerm(Term t)
|
bool Yap_IsAcyclicTerm(Term t)
|
||||||
{
|
{
|
||||||
return !rational_tree(t);
|
return !rational_tree(t);
|
||||||
}
|
}
|
||||||
|
@ -2950,7 +2950,7 @@ static Int ground_complex_term(register CELL *pt0, register CELL *pt0_end USES_R
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Yap_IsGroundTerm(Term t)
|
bool Yap_IsGroundTerm(Term t)
|
||||||
{
|
{
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
@ -2963,7 +2963,7 @@ int Yap_IsGroundTerm(Term t)
|
|||||||
} else if (IsPairTerm(t)) {
|
} else if (IsPairTerm(t)) {
|
||||||
if ((out =ground_complex_term(RepPair(t)-1,
|
if ((out =ground_complex_term(RepPair(t)-1,
|
||||||
RepPair(t)+1 PASS_REGS)) >= 0) {
|
RepPair(t)+1 PASS_REGS)) >= 0) {
|
||||||
return out;
|
return out != 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Functor fun = FunctorOfTerm(t);
|
Functor fun = FunctorOfTerm(t);
|
||||||
@ -2973,14 +2973,14 @@ int Yap_IsGroundTerm(Term t)
|
|||||||
else if ((out = ground_complex_term(RepAppl(t),
|
else if ((out = ground_complex_term(RepAppl(t),
|
||||||
RepAppl(t)+
|
RepAppl(t)+
|
||||||
ArityOfFunctor(fun) PASS_REGS)) >= 0) {
|
ArityOfFunctor(fun) PASS_REGS)) >= 0) {
|
||||||
return out;
|
return out != 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (out < 0) {
|
if (out < 0) {
|
||||||
*HR++ = t;
|
*HR++ = t;
|
||||||
if (!Yap_ExpandPreAllocCodeSpace(0, NULL, TRUE)) {
|
if (!Yap_ExpandPreAllocCodeSpace(0, NULL, TRUE)) {
|
||||||
Yap_Error(RESOURCE_ERROR_AUXILIARY_STACK, ARG1, "overflow in ground");
|
Yap_Error(RESOURCE_ERROR_AUXILIARY_STACK, ARG1, "overflow in ground");
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
t = *--HR;
|
t = *--HR;
|
||||||
}
|
}
|
||||||
@ -3916,19 +3916,19 @@ static int variant_complex(register CELL *pt0, register CELL *pt0_end, register
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static bool
|
||||||
is_variant(Term t1, Term t2, int parity USES_REGS)
|
is_variant(Term t1, Term t2, int parity USES_REGS)
|
||||||
{
|
{
|
||||||
int out;
|
int out;
|
||||||
|
|
||||||
if (t1 == t2)
|
if (t1 == t2)
|
||||||
return (TRUE);
|
return true;
|
||||||
if (IsVarTerm(t1)) {
|
if (IsVarTerm(t1)) {
|
||||||
if (IsVarTerm(t2))
|
if (IsVarTerm(t2))
|
||||||
return(TRUE);
|
return true;
|
||||||
return(FALSE);
|
return false;
|
||||||
} else if (IsVarTerm(t2))
|
} else if (IsVarTerm(t2))
|
||||||
return(FALSE);
|
return false;
|
||||||
if (IsAtomOrIntTerm(t1)) {
|
if (IsAtomOrIntTerm(t1)) {
|
||||||
return(t1 == t2);
|
return(t1 == t2);
|
||||||
}
|
}
|
||||||
@ -3938,12 +3938,12 @@ is_variant(Term t1, Term t2, int parity USES_REGS)
|
|||||||
RepPair(t1)+1,
|
RepPair(t1)+1,
|
||||||
RepPair(t2)-1 PASS_REGS);
|
RepPair(t2)-1 PASS_REGS);
|
||||||
if (out < 0) goto error;
|
if (out < 0) goto error;
|
||||||
return out;
|
return out != 0;
|
||||||
}
|
}
|
||||||
else return (FALSE);
|
else return false;
|
||||||
}
|
}
|
||||||
if (!IsApplTerm(t2)) {
|
if (!IsApplTerm(t2)) {
|
||||||
return FALSE;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
Functor f1 = FunctorOfTerm(t1);
|
Functor f1 = FunctorOfTerm(t1);
|
||||||
|
|
||||||
@ -3955,7 +3955,7 @@ is_variant(Term t1, Term t2, int parity USES_REGS)
|
|||||||
RepAppl(t1)+ArityOfFunctor(f1),
|
RepAppl(t1)+ArityOfFunctor(f1),
|
||||||
RepAppl(t2) PASS_REGS);
|
RepAppl(t2) PASS_REGS);
|
||||||
if (out < 0) goto error;
|
if (out < 0) goto error;
|
||||||
return out;
|
return out != 0;
|
||||||
}
|
}
|
||||||
error:
|
error:
|
||||||
if (out == -1) {
|
if (out == -1) {
|
||||||
@ -3965,10 +3965,10 @@ is_variant(Term t1, Term t2, int parity USES_REGS)
|
|||||||
}
|
}
|
||||||
return is_variant(t1, t2, parity PASS_REGS);
|
return is_variant(t1, t2, parity PASS_REGS);
|
||||||
}
|
}
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
bool
|
||||||
Yap_Variant(Term t1, Term t2)
|
Yap_Variant(Term t1, Term t2)
|
||||||
{
|
{
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
@ -4558,7 +4558,7 @@ camacho_dum( USES_REGS1 )
|
|||||||
|
|
||||||
#endif /* DEBUG */
|
#endif /* DEBUG */
|
||||||
|
|
||||||
int
|
bool
|
||||||
Yap_IsListTerm(Term t)
|
Yap_IsListTerm(Term t)
|
||||||
{
|
{
|
||||||
Term *tailp;
|
Term *tailp;
|
||||||
@ -4776,7 +4776,8 @@ static Int numbervars_in_complex_term(register CELL *pt0, register CELL *pt0_end
|
|||||||
}
|
}
|
||||||
|
|
||||||
Int
|
Int
|
||||||
Yap_NumberVars( Term inp, Int numbv, int handle_singles ) /* numbervariables in term t */
|
Yap_NumberVars( Term inp, Int numbv, bool handle_singles ) /*
|
||||||
|
* numbervariables in term t */
|
||||||
{
|
{
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
Int out;
|
Int out;
|
||||||
|
50
CXX/yapdb.hh
50
CXX/yapdb.hh
@ -1,4 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#ifndef _YAPDB_H
|
||||||
|
#define _YAPDB_H
|
||||||
|
|
||||||
#define YAP_CPP_DB_INTERFACE 1
|
#define YAP_CPP_DB_INTERFACE 1
|
||||||
|
|
||||||
//! @{
|
//! @{
|
||||||
@ -16,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
class YAPTerm;
|
class YAPTerm;
|
||||||
|
class YAPAtomTerm;
|
||||||
|
|
||||||
class YAPError;
|
class YAPError;
|
||||||
|
|
||||||
@ -66,23 +71,32 @@ public:
|
|||||||
/// Constructor: receives Prolog functor and casts it to YAPFunctor
|
/// Constructor: receives Prolog functor and casts it to YAPFunctor
|
||||||
///
|
///
|
||||||
/// Notice that this is designed for internal use only.
|
/// Notice that this is designed for internal use only.
|
||||||
YAPFunctor( Functor ff) { f = ff; }
|
inline YAPFunctor( Functor ff) { f = ff; }
|
||||||
public:
|
public:
|
||||||
~YAPFunctor( ) { };
|
/// Constructor: receives name as an atom, plus arity
|
||||||
|
///
|
||||||
|
/// This is the default method, and the most popular
|
||||||
|
YAPFunctor( YAPAtom at, uintptr_t arity) { f = Yap_MkFunctor( at.a, arity ); }
|
||||||
|
|
||||||
/// Constructor: receives name as a string plus arity
|
/// Constructor: receives name as a string plus arity
|
||||||
///
|
///
|
||||||
/// Notice that this is designed for ISO-LATIN-1 right now
|
/// Notice that this is designed for ISO-LATIN-1 right now
|
||||||
YAPFunctor( char * s, arity_t arity) { f = Yap_MkFunctor( Yap_LookupAtom( s ), arity ); }
|
/// Note: Python confuses the 3 constructors,
|
||||||
|
/// use YAPFunctorFromString
|
||||||
|
inline YAPFunctor( const char * s, uintptr_t arity, bool isutf8=true)
|
||||||
|
{ f = Yap_MkFunctor(
|
||||||
|
Yap_LookupAtom( s ), arity ); }
|
||||||
/// Constructor: receives name as a wide string plus arity
|
/// Constructor: receives name as a wide string plus arity
|
||||||
///
|
///
|
||||||
/// Notice that this is designed for UNICODE right now
|
/// Notice that this is designed for UNICODE right now
|
||||||
YAPFunctor( wchar_t * s, arity_t arity) { f = Yap_MkFunctor( Yap_LookupWideAtom( s ), arity ) ; }
|
|
||||||
/// Constructor: receives name as an atom, plus arity
|
|
||||||
///
|
///
|
||||||
/// This is the default method, and the most popi;at
|
/// Note: Python confuses the 3 constructors,
|
||||||
YAPFunctor( YAPAtom at, arity_t arity) { f = Yap_MkFunctor( at.a, arity ); }
|
/// use YAPFunctorFromWideString
|
||||||
|
inline YAPFunctor( const wchar_t * s, uintptr_t arity) {
|
||||||
/// Getter: extract name of functor as an atom
|
f = Yap_MkFunctor(
|
||||||
|
Yap_LookupWideAtom( s ), arity ) ; }
|
||||||
|
~YAPFunctor( ) { };
|
||||||
|
/// Getter: extract name of functor as an atom
|
||||||
///
|
///
|
||||||
/// this is for external usage.
|
/// this is for external usage.
|
||||||
YAPAtom name(void) {
|
YAPAtom name(void) {
|
||||||
@ -92,7 +106,7 @@ public:
|
|||||||
/// Getter: extract arity of functor as an unsigned integer
|
/// Getter: extract arity of functor as an unsigned integer
|
||||||
///
|
///
|
||||||
/// this is for external usage.
|
/// this is for external usage.
|
||||||
arity_t arity(void) {
|
uintptr_t arity(void) {
|
||||||
return ArityOfFunctor( f );
|
return ArityOfFunctor( f );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +193,7 @@ public:
|
|||||||
|
|
||||||
/// Mod:Name/Arity constructor for predicates.
|
/// Mod:Name/Arity constructor for predicates.
|
||||||
///
|
///
|
||||||
inline YAPPredicate(YAPAtom at, arity_t arity, YAPModule mod) {
|
inline YAPPredicate(YAPAtom at, uintptr_t arity, YAPModule mod) {
|
||||||
if (arity) {
|
if (arity) {
|
||||||
Functor f = Yap_MkFunctor(at.a, arity);
|
Functor f = Yap_MkFunctor(at.a, arity);
|
||||||
ap = RepPredProp(PredPropByFunc(f,mod.t()));
|
ap = RepPredProp(PredPropByFunc(f,mod.t()));
|
||||||
@ -190,7 +204,7 @@ public:
|
|||||||
|
|
||||||
/// Atom/Arity constructor for predicates.
|
/// Atom/Arity constructor for predicates.
|
||||||
///
|
///
|
||||||
YAPPredicate(YAPAtom at, arity_t arity);
|
YAPPredicate(YAPAtom at, uintptr_t arity);
|
||||||
|
|
||||||
|
|
||||||
/// module of a predicate
|
/// module of a predicate
|
||||||
@ -215,7 +229,7 @@ public:
|
|||||||
/// arity of predicate
|
/// arity of predicate
|
||||||
///
|
///
|
||||||
/// we return a positive number.
|
/// we return a positive number.
|
||||||
arity_t getArity() { return ap->ArityOfPE; }
|
uintptr_t getArity() { return ap->ArityOfPE; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -226,7 +240,7 @@ public:
|
|||||||
class YAPPrologPredicate: public YAPPredicate {
|
class YAPPrologPredicate: public YAPPredicate {
|
||||||
public:
|
public:
|
||||||
YAPPrologPredicate(YAPAtom name,
|
YAPPrologPredicate(YAPAtom name,
|
||||||
arity_t arity,
|
uintptr_t arity,
|
||||||
YAPModule module = YAPModule(),
|
YAPModule module = YAPModule(),
|
||||||
bool tabled = false,
|
bool tabled = false,
|
||||||
bool logical_updates = false,
|
bool logical_updates = false,
|
||||||
@ -256,7 +270,7 @@ class YAPFLIP: public YAPPredicate {
|
|||||||
public:
|
public:
|
||||||
YAPFLIP(CPredicate call,
|
YAPFLIP(CPredicate call,
|
||||||
YAPAtom name,
|
YAPAtom name,
|
||||||
arity_t arity,
|
uintptr_t arity,
|
||||||
YAPModule module = YAPModule(),
|
YAPModule module = YAPModule(),
|
||||||
CPredicate retry = 0,
|
CPredicate retry = 0,
|
||||||
CPredicate cut = 0,
|
CPredicate cut = 0,
|
||||||
@ -277,7 +291,7 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
YAPFLIP(const char *name,
|
YAPFLIP(const char *name,
|
||||||
arity_t arity,
|
uintptr_t arity,
|
||||||
YAPModule module = YAPModule(),
|
YAPModule module = YAPModule(),
|
||||||
bool backtrackable = false
|
bool backtrackable = false
|
||||||
) : YAPPredicate( YAPAtom(name), arity, module) {
|
) : YAPPredicate( YAPAtom(name), arity, module) {
|
||||||
@ -299,3 +313,5 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
214
CXX/yapi.cpp
214
CXX/yapi.cpp
@ -15,11 +15,11 @@ extern "C" {
|
|||||||
X_API char *Yap_TermToString(Term t, size_t *length, encoding_t encodingp,
|
X_API char *Yap_TermToString(Term t, size_t *length, encoding_t encodingp,
|
||||||
int flags);
|
int flags);
|
||||||
|
|
||||||
X_API void YAP_UserCPredicate(const char *, YAP_UserCPred, YAP_Arity arity);
|
X_API void YAP_UserCPredicate(const char *, YAP_UserCPred, arity_t arity);
|
||||||
X_API void YAP_UserCPredicateWithArgs(const char *, YAP_UserCPred, YAP_Arity,
|
X_API void YAP_UserCPredicateWithArgs(const char *, YAP_UserCPred, arity_t,
|
||||||
YAP_Term);
|
YAP_Term);
|
||||||
X_API void YAP_UserBackCPredicate(const char *, YAP_UserCPred, YAP_UserCPred,
|
X_API void YAP_UserBackCPredicate(const char *, YAP_UserCPred, YAP_UserCPred,
|
||||||
YAP_Arity, YAP_Arity);
|
arity_t, arity_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
YAPAtomTerm::YAPAtomTerm(char *s) { // build string
|
YAPAtomTerm::YAPAtomTerm(char *s) { // build string
|
||||||
@ -156,26 +156,61 @@ YAPStringTerm::YAPStringTerm(wchar_t *s, size_t len)
|
|||||||
|
|
||||||
YAPApplTerm::YAPApplTerm(YAPFunctor f, YAPTerm ts[]) : YAPTerm() {
|
YAPApplTerm::YAPApplTerm(YAPFunctor f, YAPTerm ts[]) : YAPTerm() {
|
||||||
BACKUP_H();
|
BACKUP_H();
|
||||||
UInt arity = ArityOfFunctor(f.f);
|
arity_t arity = ArityOfFunctor(f.f);
|
||||||
mk(Yap_MkApplTerm(f.f, arity, (Term *)ts));
|
Term *tt = new Term[arity];
|
||||||
|
for (int i = 0; i < arity; i++)
|
||||||
|
tt[i] = ts[i].term();
|
||||||
|
mk(Yap_MkApplTerm(f.f, arity, tt));
|
||||||
|
delete[] tt;
|
||||||
RECOVER_H();
|
RECOVER_H();
|
||||||
}
|
}
|
||||||
|
|
||||||
YAPApplTerm::YAPApplTerm(YAPFunctor f) : YAPTerm() {
|
YAPApplTerm::YAPApplTerm(YAPFunctor f) : YAPTerm() {
|
||||||
BACKUP_H();
|
BACKUP_H();
|
||||||
UInt arity = ArityOfFunctor(f.f);
|
arity_t arity = ArityOfFunctor(f.f);
|
||||||
mk(Yap_MkNewApplTerm(f.f, arity));
|
mk(Yap_MkNewApplTerm(f.f, arity));
|
||||||
RECOVER_H();
|
RECOVER_H();
|
||||||
}
|
}
|
||||||
|
|
||||||
YAPTerm YAPApplTerm::getArg(int arg) {
|
YAPFunctor YAPApplTerm::getFunctor() { return YAPFunctor(FunctorOfTerm(gt())); }
|
||||||
BACKUP_H();
|
|
||||||
YAPTerm to = YAPTerm(ArgOfTerm(arg, gt()));
|
static YAPTerm tmp;
|
||||||
RECOVER_H();
|
|
||||||
return to;
|
YAPTerm &YAPTerm::operator[](arity_t i) {
|
||||||
|
BACKUP_MACHINE_REGS();
|
||||||
|
Term t0 = gt();
|
||||||
|
Term tf = 0;
|
||||||
|
if (IsApplTerm(t0)) {
|
||||||
|
Functor f = FunctorOfTerm(t0);
|
||||||
|
if (IsExtensionFunctor(f))
|
||||||
|
return *new YAPTerm();
|
||||||
|
tf = ArgOfTerm(i + 1, t0);
|
||||||
|
} else if (IsPairTerm(t0)) {
|
||||||
|
if (i==0)
|
||||||
|
tf = HeadOfTerm(t0);
|
||||||
|
else if (i==1)
|
||||||
|
tf = TailOfTerm(t0);
|
||||||
|
}
|
||||||
|
RECOVER_MACHINE_REGS();
|
||||||
|
return * new YAPTerm(tf);
|
||||||
}
|
}
|
||||||
|
|
||||||
YAPFunctor YAPApplTerm::getFunctor() { return YAPFunctor(FunctorOfTerm(gt())); }
|
YAPTerm &YAPListTerm::operator[](arity_t i) {
|
||||||
|
BACKUP_MACHINE_REGS();
|
||||||
|
Term t0 = gt();
|
||||||
|
Term tf = 0;
|
||||||
|
while (IsPairTerm(t0)) {
|
||||||
|
if (i==0) {
|
||||||
|
tf = HeadOfTerm(t0);
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
t0 = TailOfTerm(t0);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RECOVER_MACHINE_REGS();
|
||||||
|
return * new YAPTerm(tf);
|
||||||
|
}
|
||||||
|
|
||||||
YAPPairTerm::YAPPairTerm(YAPTerm th, YAPTerm tl) : YAPTerm() {
|
YAPPairTerm::YAPPairTerm(YAPTerm th, YAPTerm tl) : YAPTerm() {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
@ -239,17 +274,36 @@ YAP_tag_t YAPTerm::tag() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
YAPTerm YAPTerm::deepCopy() {
|
YAPTerm YAPTerm::deepCopy() {
|
||||||
Term tn;
|
yhandle_t tn;
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
|
|
||||||
tn = Yap_CopyTerm(gt());
|
tn = Yap_CopyTerm(gt());
|
||||||
|
|
||||||
RECOVER_MACHINE_REGS();
|
RECOVER_MACHINE_REGS();
|
||||||
return new YAPTerm(tn);
|
return *new YAPTerm(tn);
|
||||||
|
}
|
||||||
|
|
||||||
|
YAPListTerm YAPListTerm::dup() {
|
||||||
|
yhandle_t tn;
|
||||||
|
BACKUP_MACHINE_REGS();
|
||||||
|
|
||||||
|
tn = Yap_CopyTerm(gt());
|
||||||
|
|
||||||
|
RECOVER_MACHINE_REGS();
|
||||||
|
return *new YAPListTerm(tn);
|
||||||
|
}
|
||||||
|
|
||||||
|
intptr_t YAPTerm::numberVars(intptr_t i0, bool skip_singletons) {
|
||||||
|
BACKUP_MACHINE_REGS();
|
||||||
|
|
||||||
|
intptr_t i = Yap_NumberVars(gt(), i0, skip_singletons);
|
||||||
|
|
||||||
|
RECOVER_MACHINE_REGS();
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool YAPTerm::exactlyEqual(YAPTerm t1) {
|
bool YAPTerm::exactlyEqual(YAPTerm t1) {
|
||||||
int out;
|
bool out;
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
|
|
||||||
out = Yap_eq(gt(), t1.term());
|
out = Yap_eq(gt(), t1.term());
|
||||||
@ -259,7 +313,7 @@ bool YAPTerm::exactlyEqual(YAPTerm t1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool YAPTerm::unify(YAPTerm t1) {
|
bool YAPTerm::unify(YAPTerm t1) {
|
||||||
int out;
|
intptr_t out;
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
|
|
||||||
out = Yap_unify(gt(), t1.term());
|
out = Yap_unify(gt(), t1.term());
|
||||||
@ -269,7 +323,7 @@ bool YAPTerm::unify(YAPTerm t1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool YAPTerm::unifiable(YAPTerm t1) {
|
bool YAPTerm::unifiable(YAPTerm t1) {
|
||||||
int out;
|
intptr_t out;
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
|
|
||||||
out = Yap_Unifiable(gt(), t1.term());
|
out = Yap_Unifiable(gt(), t1.term());
|
||||||
@ -279,7 +333,7 @@ bool YAPTerm::unifiable(YAPTerm t1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool YAPTerm::variant(YAPTerm t1) {
|
bool YAPTerm::variant(YAPTerm t1) {
|
||||||
int out;
|
intptr_t out;
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
|
|
||||||
out = Yap_Variant(gt(), t1.term());
|
out = Yap_Variant(gt(), t1.term());
|
||||||
@ -306,7 +360,7 @@ const char *YAPTerm::text() {
|
|||||||
char *os;
|
char *os;
|
||||||
|
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
if (!(os = Yap_TermToString(Yap_GetFromSlot(t), &length, enc, 0))) {
|
if (!(os = Yap_TermToString(Yap_GetFromSlot(t), &length, enc, Handle_vars_f))) {
|
||||||
RECOVER_MACHINE_REGS();
|
RECOVER_MACHINE_REGS();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -349,13 +403,14 @@ YAPTerm YAPListTerm::car() {
|
|||||||
else
|
else
|
||||||
throw YAPError(TYPE_ERROR_LIST);
|
throw YAPError(TYPE_ERROR_LIST);
|
||||||
}
|
}
|
||||||
YAPListTerm::YAPListTerm(YAPTerm ts[], size_t n) {
|
|
||||||
|
YAPListTerm::YAPListTerm(YAPTerm ts[], arity_t n) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
Term t;
|
Term t;
|
||||||
BACKUP_H();
|
BACKUP_H();
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
t = TermNil;
|
t = TermNil;
|
||||||
while (HR+n*2 > ASP-1024) {
|
while (HR + n * 2 > ASP - 1024) {
|
||||||
RECOVER_H();
|
RECOVER_H();
|
||||||
if (!Yap_dogc(0, NULL PASS_REGS)) {
|
if (!Yap_dogc(0, NULL PASS_REGS)) {
|
||||||
t = TermNil;
|
t = TermNil;
|
||||||
@ -363,12 +418,10 @@ YAPListTerm::YAPListTerm(YAPTerm ts[], size_t n) {
|
|||||||
BACKUP_H();
|
BACKUP_H();
|
||||||
}
|
}
|
||||||
t = AbsPair(HR);
|
t = AbsPair(HR);
|
||||||
for (int i = 0; i < n; i ++ ) {
|
for (intptr_t i = 0; i < n; i++) {
|
||||||
HR[2*i] = ts[i].gt();
|
HR[2 * i] = ts[i].gt();
|
||||||
HR[2*i+1] = AbsPair(HR+(2*i+2));
|
HR[2 * i + 1] = AbsPair(HR + (2 * i + 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
YAPVarTerm::YAPVarTerm() {
|
YAPVarTerm::YAPVarTerm() {
|
||||||
@ -403,7 +456,7 @@ const char *YAPAtom::getName(void) {
|
|||||||
|
|
||||||
void YAPQuery::initOpenQ() {
|
void YAPQuery::initOpenQ() {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
//oq = LOCAL_execution;
|
// oq = LOCAL_execution;
|
||||||
// LOCAL_execution = this;
|
// LOCAL_execution = this;
|
||||||
q_open = true;
|
q_open = true;
|
||||||
q_state = 0;
|
q_state = 0;
|
||||||
@ -412,7 +465,7 @@ void YAPQuery::initOpenQ() {
|
|||||||
q_p = P;
|
q_p = P;
|
||||||
q_cp = CP;
|
q_cp = CP;
|
||||||
// make sure this is safe
|
// make sure this is safe
|
||||||
q_handles = Yap_StartSlots();
|
q_handles = Yap_StartSlots();
|
||||||
}
|
}
|
||||||
|
|
||||||
int YAPError::get() { return errNo; }
|
int YAPError::get() { return errNo; }
|
||||||
@ -482,42 +535,53 @@ YAPQuery::YAPQuery(YAPPredicate p, YAPTerm ts[]) : YAPPredicate(p.ap) {
|
|||||||
|
|
||||||
YAPListTerm YAPQuery::namedVars() {
|
YAPListTerm YAPQuery::namedVars() {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "vnames %s %d", vnames.text(), LOCAL_CurSlot);
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "vnames %s %d",
|
||||||
|
vnames.text(), LOCAL_CurSlot);
|
||||||
return vnames; // should be o
|
return vnames; // should be o
|
||||||
}
|
}
|
||||||
|
|
||||||
|
YAPListTerm YAPQuery::namedVarsCopy() {
|
||||||
|
CACHE_REGS
|
||||||
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "vnames %s %d",
|
||||||
|
vnames.text(), LOCAL_CurSlot);
|
||||||
|
return YAPListTerm(YAP_CopyTerm(vnames.term())); // should be o
|
||||||
|
}
|
||||||
|
|
||||||
bool YAPQuery::next() {
|
bool YAPQuery::next() {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
int result;
|
bool result;
|
||||||
|
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
if (!q_open )
|
if (!q_open)
|
||||||
return false;
|
return false;
|
||||||
if (setjmp(q_env))
|
if (setjmp(q_env))
|
||||||
return false;
|
return false;
|
||||||
// don't forget, on success these guys must create slots
|
// don't forget, on success these guys may create slots
|
||||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "exec ");
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "exec ");
|
||||||
|
|
||||||
if (this->q_state == 0) {
|
if (q_state == 0) {
|
||||||
result = (bool)YAP_EnterGoal((YAP_PredEntryPtr)ap, q_g, &q_h);
|
result = (bool)YAP_EnterGoal((YAP_PredEntryPtr)ap, q_g, &q_h);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
LOCAL_AllowRestart = q_open;
|
LOCAL_AllowRestart = q_open;
|
||||||
result = (bool)YAP_RetryGoal(&q_h);
|
result = (bool)YAP_RetryGoal(&q_h);
|
||||||
}
|
}
|
||||||
if (result)
|
{
|
||||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "vnames %d %s %d", q_state, vnames.text(), LOCAL_CurSlot);
|
if (result)
|
||||||
else
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "vnames %d %s %d",
|
||||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "fail");
|
q_state, vnames.text(), LOCAL_CurSlot);
|
||||||
|
else
|
||||||
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "fail");
|
||||||
|
}
|
||||||
q_state = 1;
|
q_state = 1;
|
||||||
if (Yap_GetException()) {
|
if (Yap_GetException()) {
|
||||||
throw(YAPError(SYSTEM_ERROR_INTERNAL));
|
throw(YAPError(SYSTEM_ERROR_INTERNAL));
|
||||||
}
|
}
|
||||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "out %d", result);
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "out %d", result);
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
YAP_LeaveGoal(FALSE, &q_h);
|
YAP_LeaveGoal(FALSE, &q_h);
|
||||||
q_open = 0;
|
q_open = false;
|
||||||
} else {
|
} else {
|
||||||
q_handles = Yap_StartSlots();
|
q_handles = Yap_StartSlots();
|
||||||
}
|
}
|
||||||
@ -529,7 +593,7 @@ void YAPQuery::cut() {
|
|||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
|
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
if (!q_open || q_state == 0)
|
if (!q_open || q_state == 0)
|
||||||
return;
|
return;
|
||||||
YAP_LeaveGoal(FALSE, &q_h);
|
YAP_LeaveGoal(FALSE, &q_h);
|
||||||
q_open = 0;
|
q_open = 0;
|
||||||
@ -541,13 +605,17 @@ bool YAPQuery::deterministic() {
|
|||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
|
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
if (!q_open || q_state == 0)
|
if (!q_open || q_state == 0)
|
||||||
return false;
|
return false;
|
||||||
choiceptr myB = (choiceptr)(LCL0 - q_h.b);
|
choiceptr myB = (choiceptr)(LCL0 - q_h.b);
|
||||||
return (B >= myB);
|
return (B >= myB);
|
||||||
RECOVER_MACHINE_REGS();
|
RECOVER_MACHINE_REGS();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
YAPTerm YAPQuery::getTerm(yhandle_t t) { return YAPTerm(t); }
|
||||||
|
|
||||||
|
YAPTerm YAPQuery::getTerm(int t) { return YAPTerm((yhandle_t)t); }
|
||||||
|
|
||||||
void YAPQuery::close() {
|
void YAPQuery::close() {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
|
|
||||||
@ -560,7 +628,7 @@ void YAPQuery::close() {
|
|||||||
}
|
}
|
||||||
YAP_LeaveGoal(FALSE, &q_h);
|
YAP_LeaveGoal(FALSE, &q_h);
|
||||||
q_open = 0;
|
q_open = 0;
|
||||||
//LOCAL_execution = this;
|
// LOCAL_execution = this;
|
||||||
RECOVER_MACHINE_REGS();
|
RECOVER_MACHINE_REGS();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -614,54 +682,52 @@ void Yap_displayWithJava(int c) {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void YAPEngine::doInit(YAP_file_type_t BootMode)
|
void YAPEngine::doInit(YAP_file_type_t BootMode) {
|
||||||
{
|
if ((BootMode = YAP_Init(&init_args)) == YAP_FOUND_BOOT_ERROR) {
|
||||||
if ((BootMode = YAP_Init(&init_args)) == YAP_FOUND_BOOT_ERROR) {
|
|
||||||
throw(YAPError(SYSTEM_ERROR_INTERNAL));
|
throw(YAPError(SYSTEM_ERROR_INTERNAL));
|
||||||
}
|
}
|
||||||
/* Begin preprocessor code */
|
/* Begin preprocessor code */
|
||||||
/* live */
|
/* live */
|
||||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "$init_system");
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "$init_system");
|
||||||
#if __ANDROID__
|
#if __ANDROID__
|
||||||
Yap_AndroidBufp = (char *)malloc(Yap_AndroidMax = 4096);
|
Yap_AndroidBufp = (char *)malloc(Yap_AndroidMax = 4096);
|
||||||
Yap_AndroidBufp[0] = '\0';
|
Yap_AndroidBufp[0] = '\0';
|
||||||
Yap_AndroidSz = 0;
|
Yap_AndroidSz = 0;
|
||||||
#endif
|
#endif
|
||||||
yerror = YAPError();
|
yerror = YAPError();
|
||||||
|
|
||||||
YAPQuery initq = YAPQuery( YAPAtom( "$init_system" ) );
|
YAPQuery initq = YAPQuery(YAPAtom("$init_system"));
|
||||||
if (initq.next()) {
|
if (initq.next()) {
|
||||||
initq.cut();
|
initq.cut();
|
||||||
} else {
|
} else {
|
||||||
// should throw exception
|
// should throw exception
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
YAPEngine::YAPEngine(char *savedState, char *bootFile,
|
YAPEngine::YAPEngine(char *savedState, char *bootFile, size_t stackSize,
|
||||||
size_t stackSize, size_t trailSize,
|
size_t trailSize, size_t maxStackSize, size_t maxTrailSize,
|
||||||
size_t maxStackSize, size_t maxTrailSize, char *libDir,
|
char *libDir, char *goal, char *topLevel, bool script,
|
||||||
char *goal, char *topLevel, bool script,
|
|
||||||
bool fastBoot,
|
bool fastBoot,
|
||||||
YAPCallback *cb)
|
YAPCallback *cb)
|
||||||
: _callback(0) { // a single engine can be active
|
: _callback(0) { // a single engine can be active
|
||||||
|
|
||||||
YAP_file_type_t BootMode;
|
YAP_file_type_t BootMode;
|
||||||
int Argc = 1;
|
int Argc = 1;
|
||||||
char **Argv;
|
char **Argv;
|
||||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "YAP %s ", bootFile);
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "YAP %s ", bootFile);
|
||||||
|
|
||||||
//delYAPCallback()b
|
// delYAPCallback()b
|
||||||
//if (cb)
|
// if (cb)
|
||||||
// setYAPCallback(cb);
|
// setYAPCallback(cb);
|
||||||
curren = this;
|
curren = this;
|
||||||
{
|
{
|
||||||
size_t l1 = 2 * sizeof(char *);
|
size_t l1 = 2 * sizeof(char *);
|
||||||
if (!(Argv = (char **)malloc(l1)))
|
if (!(Argv = (char **)malloc(l1)))
|
||||||
return;
|
return;
|
||||||
Argv[0] = "yap";
|
Argv[0] = "yap";
|
||||||
Argv[1] = NULL;
|
Argv[1] = NULL;
|
||||||
}
|
}
|
||||||
BootMode = Yap_InitDefaults( &init_args, NULL, Argc, Argv);
|
BootMode = Yap_InitDefaults(&init_args, NULL, Argc, Argv);
|
||||||
init_args.SavedState = savedState;
|
init_args.SavedState = savedState;
|
||||||
init_args.StackSize = stackSize;
|
init_args.StackSize = stackSize;
|
||||||
init_args.TrailSize = trailSize;
|
init_args.TrailSize = trailSize;
|
||||||
@ -676,19 +742,17 @@ YAPEngine::YAPEngine(char *savedState, char *bootFile,
|
|||||||
doInit(BootMode);
|
doInit(BootMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
YAPEngine::YAPEngine(int argc, char *argv[],
|
YAPEngine::YAPEngine(int argc, char *argv[],
|
||||||
YAPCallback *cb)
|
YAPCallback *cb)
|
||||||
: _callback(0){ // a single engine can be active
|
: _callback(0) { // a single engine can be active
|
||||||
|
|
||||||
YAP_file_type_t BootMode;
|
YAP_file_type_t BootMode;
|
||||||
BootMode = YAP_parse_yap_arguments(argc, argv, &init_args);
|
BootMode = YAP_parse_yap_arguments(argc, argv, &init_args);
|
||||||
//delYAPCallback()b
|
// delYAPCallback()b
|
||||||
//if (cb)
|
// if (cb)
|
||||||
// setYAPCallback(cb);
|
// setYAPCallback(cb);
|
||||||
curren = this;
|
curren = this;
|
||||||
doInit( BootMode );
|
doInit(BootMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
YAPPredicate::YAPPredicate(YAPAtom at) {
|
YAPPredicate::YAPPredicate(YAPAtom at) {
|
||||||
@ -723,7 +787,7 @@ PredEntry *YAPPredicate::getPred(Term &t, Term *&outp) {
|
|||||||
ts[0] = t;
|
ts[0] = t;
|
||||||
ts[1] = m;
|
ts[1] = m;
|
||||||
t = Yap_MkApplTerm(FunctorCsult, 2, ts);
|
t = Yap_MkApplTerm(FunctorCsult, 2, ts);
|
||||||
outp = RepAppl(t)+1;
|
outp = RepAppl(t) + 1;
|
||||||
}
|
}
|
||||||
Functor f = FunctorOfTerm(t);
|
Functor f = FunctorOfTerm(t);
|
||||||
if (IsExtensionFunctor(f)) {
|
if (IsExtensionFunctor(f)) {
|
||||||
|
27
CXX/yapi.hh
27
CXX/yapi.hh
@ -67,7 +67,31 @@ extern "C" {
|
|||||||
#include "iopreds.h"
|
#include "iopreds.h"
|
||||||
|
|
||||||
#ifdef SWIGPYTHON
|
#ifdef SWIGPYTHON
|
||||||
extern PyObject *term_to_python(yhandle_t t);
|
extern PyObject *term_to_python(yhandle_t t, bool eval);
|
||||||
|
extern PyObject *deref_term_to_python(yhandle_t t);
|
||||||
|
X_API bool init_python(void);
|
||||||
|
|
||||||
|
extern PyObject *py_Main;
|
||||||
|
|
||||||
|
extern inline PyObject *AtomToPy( const char *s)
|
||||||
|
{
|
||||||
|
if (strcmp(s, "true") == 0)
|
||||||
|
return Py_True;
|
||||||
|
if (strcmp(s, "false") == 0)
|
||||||
|
return Py_False;
|
||||||
|
if (strcmp(s, "none") == 0)
|
||||||
|
return Py_None;
|
||||||
|
if (strcmp(s, "[]") == 0)
|
||||||
|
return PyList_New(0);
|
||||||
|
else if (strcmp(s, "{}") == 0)
|
||||||
|
return PyDict_New();
|
||||||
|
/* return __main__,s */
|
||||||
|
else if (PyObject_HasAttrString(py_Main, s)) {
|
||||||
|
return PyObject_GetAttrString(py_Main, s);
|
||||||
|
}
|
||||||
|
// no way to translate
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -83,6 +107,7 @@ X_API void YAP_UserCPredicateWithArgs(const char *, YAP_UserCPred, YAP_Arity, YA
|
|||||||
X_API Term Yap_StringToTerm(const char *s, size_t len, encoding_t *encp, int prio, Term *bindings_p);
|
X_API Term Yap_StringToTerm(const char *s, size_t len, encoding_t *encp, int prio, Term *bindings_p);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class YAPEngine;
|
class YAPEngine;
|
||||||
|
19
CXX/yapq.hh
19
CXX/yapq.hh
@ -90,7 +90,13 @@ public:
|
|||||||
void close();
|
void close();
|
||||||
/// query variables.
|
/// query variables.
|
||||||
YAPListTerm namedVars();
|
YAPListTerm namedVars();
|
||||||
///simple YAP Query;
|
/// query variables, but copied out
|
||||||
|
YAPListTerm namedVarsCopy();
|
||||||
|
/// convert a ref to a binding.
|
||||||
|
YAPTerm getTerm(yhandle_t t);
|
||||||
|
/// convert a ref to a binding.
|
||||||
|
YAPTerm getTerm(int t);
|
||||||
|
///simple YAP Query;
|
||||||
/// just calls YAP and reports success or failure, Useful when we just
|
/// just calls YAP and reports success or failure, Useful when we just
|
||||||
/// want things done, eg YAPCommand("load_files(library(lists), )")
|
/// want things done, eg YAPCommand("load_files(library(lists), )")
|
||||||
inline bool command()
|
inline bool command()
|
||||||
@ -158,19 +164,22 @@ public:
|
|||||||
YAPQuery *query( const char *s ) {
|
YAPQuery *query( const char *s ) {
|
||||||
return new YAPQuery( s );
|
return new YAPQuery( s );
|
||||||
};
|
};
|
||||||
/// current module for the engine
|
/// current module for the engine
|
||||||
YAPModule currentModule( ) { return YAPModule( ) ; }
|
YAPModule currentModule( ) { return YAPModule( ) ; }
|
||||||
|
/// given a handle, fetch a term from the engine
|
||||||
|
inline YAPTerm getTerm( yhandle_t h) { return YAPTerm( h ) ; }
|
||||||
/// current directory for the engine
|
/// current directory for the engine
|
||||||
const char *currentDir( ) {
|
const char *currentDir( ) {
|
||||||
char dir[1024];
|
char dir[1024];
|
||||||
std::string s = Yap_getcwd(dir, 1024-1);
|
std::string s = Yap_getcwd(dir, 1024-1);
|
||||||
return s.c_str();
|
return s.c_str();
|
||||||
}
|
};
|
||||||
/// report YAP version as a string
|
/// report YAP version as a string
|
||||||
const char *version( ) {
|
const char *version( ) {
|
||||||
std::string s = Yap_version();
|
std::string s = Yap_version();
|
||||||
return s.c_str();
|
return s.c_str();
|
||||||
}
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* YAPQ_HH */
|
#endif /* YAPQ_HH */
|
||||||
|
177
CXX/yapt.hh
177
CXX/yapt.hh
@ -23,8 +23,9 @@ public:
|
|||||||
virtual ~YAPTerm() {};
|
virtual ~YAPTerm() {};
|
||||||
YAPTerm(Term tn) { mk( tn ); } /// private method to convert from Term (internal YAP representation) to YAPTerm
|
YAPTerm(Term tn) { mk( tn ); } /// private method to convert from Term (internal YAP representation) to YAPTerm
|
||||||
// do nothing constructor
|
// do nothing constructor
|
||||||
YAPTerm() { mk(TermNil); }
|
YAPTerm() {
|
||||||
/// integer to term
|
t = 0;
|
||||||
|
}
|
||||||
YAPTerm(intptr_t i);
|
YAPTerm(intptr_t i);
|
||||||
/// pointer to term
|
/// pointer to term
|
||||||
YAPTerm(void *ptr);
|
YAPTerm(void *ptr);
|
||||||
@ -32,17 +33,21 @@ public:
|
|||||||
YAPTerm(char *s) { Term tp ; mk( YAP_ReadBuffer(s,&tp) ); }
|
YAPTerm(char *s) { Term tp ; mk( YAP_ReadBuffer(s,&tp) ); }
|
||||||
/// extract the tag of a term, after dereferencing.
|
/// extract the tag of a term, after dereferencing.
|
||||||
YAP_tag_t tag();
|
YAP_tag_t tag();
|
||||||
/// copy the term ( term copy )
|
/// copy the term ( term copy )
|
||||||
YAPTerm deepCopy();
|
YAPTerm deepCopy();
|
||||||
|
/// numbervars ( int start, bool process=false )
|
||||||
|
intptr_t numberVars(intptr_t start, bool skip_singletons=false );
|
||||||
inline Term term() { return gt(); } /// from YAPTerm to Term (internal YAP representation)
|
inline Term term() { return gt(); } /// from YAPTerm to Term (internal YAP representation)
|
||||||
//const YAPTerm *vars();
|
/// fetch a sub-term
|
||||||
|
YAPTerm &operator[](size_t n);
|
||||||
|
//const YAPTerm *vars();
|
||||||
/// this term is == to t1
|
/// this term is == to t1
|
||||||
bool exactlyEqual(YAPTerm t1);
|
virtual bool exactlyEqual(YAPTerm t1);
|
||||||
bool unify(YAPTerm t1); /// t = t1
|
virtual bool unify(YAPTerm t1); /// t = t1
|
||||||
bool unifiable(YAPTerm t1); /// we can unify t and t1
|
virtual bool unifiable(YAPTerm t1); /// we can unify t and t1
|
||||||
bool variant(YAPTerm t1); /// t =@= t1, the two terms are equal up to variable renaming
|
virtual bool variant(YAPTerm t1); /// t =@= t1, the two terms are equal up to variable renaming
|
||||||
intptr_t hashTerm(size_t sz, size_t depth, bool variant); /// term hash,
|
virtual intptr_t hashTerm(size_t sz, size_t depth, bool variant); /// term hash,
|
||||||
virtual bool isVar() { return IsVarTerm( gt() ); } /// type check for unbound
|
virtual bool isVar() { return IsVarTerm( gt() ); } /// type check for unound
|
||||||
virtual bool isAtom() { return IsAtomTerm( gt() ); } /// type check for atom
|
virtual bool isAtom() { return IsAtomTerm( gt() ); } /// type check for atom
|
||||||
virtual bool isInteger() { return IsIntegerTerm( gt() ); } /// type check for integer
|
virtual bool isInteger() { return IsIntegerTerm( gt() ); } /// type check for integer
|
||||||
virtual bool isFloat() { return IsFloatTerm( gt() ); } /// type check for floating-point
|
virtual bool isFloat() { return IsFloatTerm( gt() ); } /// type check for floating-point
|
||||||
@ -53,27 +58,42 @@ public:
|
|||||||
virtual bool isGround() { return Yap_IsGroundTerm( gt() ); } /// term is ground
|
virtual bool isGround() { return Yap_IsGroundTerm( gt() ); } /// term is ground
|
||||||
virtual bool isList() { return Yap_IsListTerm( gt() ); } /// term is a list
|
virtual bool isList() { return Yap_IsListTerm( gt() ); } /// term is a list
|
||||||
|
|
||||||
/// extract the argument i of the term, where i in 1...arity
|
/// extract the argument i of the term, where i in 1...arity
|
||||||
inline YAPTerm getArg(int i) {
|
inline YAPTerm getArg(arity_t i) {
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
Term t0 = gt();
|
Term t0 = gt();
|
||||||
YAPTerm tf;
|
YAPTerm tf;
|
||||||
if (IsApplTerm(t0))
|
if (IsApplTerm(t0))
|
||||||
tf = YAPTerm(ArgOfTerm(i, t0));
|
tf = YAPTerm(ArgOfTerm(i, t0));
|
||||||
else if (IsPairTerm(t0)) {
|
else if (IsPairTerm(t0)) {
|
||||||
if (i==1)
|
if (i==1)
|
||||||
tf = YAPTerm(HeadOfTerm(t0));
|
tf = YAPTerm(HeadOfTerm(t0));
|
||||||
else if (i==2)
|
else if (i==2)
|
||||||
tf = YAPTerm(TailOfTerm(t0));
|
tf = YAPTerm(TailOfTerm(t0));
|
||||||
} else {
|
} else {
|
||||||
tf = YAPTerm((Term)0);
|
tf = YAPTerm((Term)0);
|
||||||
|
}
|
||||||
|
RECOVER_MACHINE_REGS();
|
||||||
|
return tf;
|
||||||
}
|
}
|
||||||
RECOVER_MACHINE_REGS();
|
|
||||||
REGS_LOG( "after getArg H= %p, i=%d", HR, tf.gt()) ;
|
|
||||||
return tf;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// return a string with a textual representation of the term
|
/// extract the arity of the term
|
||||||
|
/// variables have arity 0
|
||||||
|
virtual inline arity_t arity() {
|
||||||
|
Term t0 = gt();
|
||||||
|
|
||||||
|
if (IsApplTerm(t0)) {
|
||||||
|
Functor f = FunctorOfTerm(t0);
|
||||||
|
if (IsExtensionFunctor(f))
|
||||||
|
return 0;
|
||||||
|
return ArityOfFunctor(f);
|
||||||
|
} else if (IsPairTerm(t0)) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// return a string with a textual representation of the term
|
||||||
virtual const char *text();
|
virtual const char *text();
|
||||||
|
|
||||||
/// return a handle to the term
|
/// return a handle to the term
|
||||||
@ -104,43 +124,6 @@ public:
|
|||||||
virtual bool isList() { return false; } /// term is a list
|
virtual bool isList() { return false; } /// term is a list
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Atom Term
|
|
||||||
* Term Representation of an Atom
|
|
||||||
*/
|
|
||||||
class YAPAtomTerm: public YAPTerm {
|
|
||||||
friend class YAPModule;
|
|
||||||
// Constructor: receives a C-atom;
|
|
||||||
YAPAtomTerm(Atom a) { mk( MkAtomTerm(a) ); }
|
|
||||||
YAPAtomTerm(Term t): YAPTerm(t) { IsAtomTerm(t); }
|
|
||||||
// Getter for Prolog atom
|
|
||||||
Term getTerm() { return t; }
|
|
||||||
public:
|
|
||||||
// Constructor: receives an atom;
|
|
||||||
YAPAtomTerm(YAPAtom a): YAPTerm() { mk( MkAtomTerm(a.a) ); }
|
|
||||||
// Constructor: receives a sequence of ISO-LATIN1 codes;
|
|
||||||
YAPAtomTerm(char *s) ;
|
|
||||||
// Constructor: receives a sequence of up to n ISO-LATIN1 codes;
|
|
||||||
YAPAtomTerm(char *s, size_t len);
|
|
||||||
// Constructor: receives a sequence of wchar_ts, whatever they may be;
|
|
||||||
YAPAtomTerm(wchar_t *s) ;
|
|
||||||
// Constructor: receives a sequence of n wchar_ts, whatever they may be;
|
|
||||||
YAPAtomTerm(wchar_t *s, size_t len);
|
|
||||||
virtual bool isVar() { return false; } /// type check for unbound
|
|
||||||
virtual bool isAtom() { return true; } /// type check for atom
|
|
||||||
virtual bool isInteger() { return false; } /// type check for integer
|
|
||||||
virtual bool isFloat() { return false; } /// type check for floating-point
|
|
||||||
virtual bool isString() { return false; } /// type check for a string " ... "
|
|
||||||
virtual bool isCompound() { return false; } /// is a primitive term
|
|
||||||
virtual bool isAppl() { return false; } /// is a structured term
|
|
||||||
virtual bool isPair() { return false; } /// is a pair term
|
|
||||||
virtual bool isGround() { return true; } /// term is ground
|
|
||||||
virtual bool isList() { return gt() == TermNil; } /// [] is a list
|
|
||||||
// Getter: outputs the atom;
|
|
||||||
YAPAtom getAtom() { return YAPAtom(AtomOfTerm( gt() )); }
|
|
||||||
// Getter: outputs the name as a sequence of ISO-LATIN1 codes;
|
|
||||||
const char *text() { return (const char *)AtomOfTerm( gt() )->StrOfAE; }
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Compound Term
|
* @brief Compound Term
|
||||||
@ -153,7 +136,15 @@ public:
|
|||||||
YAPApplTerm(YAPFunctor f, YAPTerm ts[]);
|
YAPApplTerm(YAPFunctor f, YAPTerm ts[]);
|
||||||
YAPApplTerm(YAPFunctor f);
|
YAPApplTerm(YAPFunctor f);
|
||||||
YAPFunctor getFunctor();
|
YAPFunctor getFunctor();
|
||||||
YAPTerm getArg(int i);
|
inline YAPTerm getArg(arity_t i) {
|
||||||
|
BACKUP_MACHINE_REGS();
|
||||||
|
Term t0 = gt();
|
||||||
|
YAPTerm tf;
|
||||||
|
tf = YAPTerm(ArgOfTerm(i, t0));
|
||||||
|
RECOVER_MACHINE_REGS();
|
||||||
|
return tf;
|
||||||
|
}
|
||||||
|
;
|
||||||
virtual bool isVar() { return false; } /// type check for unbound
|
virtual bool isVar() { return false; } /// type check for unbound
|
||||||
virtual bool isAtom() { return false; } /// type check for atom
|
virtual bool isAtom() { return false; } /// type check for atom
|
||||||
virtual bool isInteger() { return false; } /// type check for integer
|
virtual bool isInteger() { return false; } /// type check for integer
|
||||||
@ -215,8 +206,10 @@ public:
|
|||||||
/// @param[in] the length of the array
|
/// @param[in] the length of the array
|
||||||
YAPListTerm(YAPTerm ts[], size_t n);
|
YAPListTerm(YAPTerm ts[], size_t n);
|
||||||
// YAPListTerm( vector<YAPTerm> v );
|
// YAPListTerm( vector<YAPTerm> v );
|
||||||
/// Return the number of elements in a list term.
|
/// Return the number of elements in a list term.
|
||||||
size_t length() { Term *tailp; Term t1 = gt(); return Yap_SkipList(&t1, &tailp); }
|
size_t length() { Term *tailp; Term t1 = gt(); return Yap_SkipList(&t1, &tailp); }
|
||||||
|
/// Extract the nth element.
|
||||||
|
YAPTerm &operator[](size_t n);
|
||||||
/// Extract the first element of a list.
|
/// Extract the first element of a list.
|
||||||
///
|
///
|
||||||
/// @param[in] the list
|
/// @param[in] the list
|
||||||
@ -234,6 +227,10 @@ public:
|
|||||||
/* error */
|
/* error */
|
||||||
throw YAPError(TYPE_ERROR_LIST);
|
throw YAPError(TYPE_ERROR_LIST);
|
||||||
}
|
}
|
||||||
|
/// copy a list.
|
||||||
|
///
|
||||||
|
/// @param[in] the list
|
||||||
|
YAPListTerm dup();
|
||||||
|
|
||||||
/// Check if the list is empty.
|
/// Check if the list is empty.
|
||||||
///
|
///
|
||||||
@ -262,4 +259,44 @@ public:
|
|||||||
const char *getString() { return StringOfTerm( gt() ); }
|
const char *getString() { return StringOfTerm( gt() ); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Atom Term
|
||||||
|
* Term Representation of an Atom
|
||||||
|
*/
|
||||||
|
class YAPAtomTerm: public YAPTerm {
|
||||||
|
friend class YAPModule;
|
||||||
|
// Constructor: receives a C-atom;
|
||||||
|
YAPAtomTerm(Atom a) { mk( MkAtomTerm(a) ); }
|
||||||
|
YAPAtomTerm(Term t): YAPTerm(t) { IsAtomTerm(t); }
|
||||||
|
// Getter for Prolog atom
|
||||||
|
Term getTerm() { return t; }
|
||||||
|
public:
|
||||||
|
// Constructor: receives an atom;
|
||||||
|
YAPAtomTerm(YAPAtom a): YAPTerm() { mk( MkAtomTerm(a.a) ); }
|
||||||
|
// Constructor: receives a sequence of ISO-LATIN1 codes;
|
||||||
|
YAPAtomTerm(char *s) ;
|
||||||
|
// Constructor: receives a sequence of up to n ISO-LATIN1 codes;
|
||||||
|
YAPAtomTerm(char *s, size_t len);
|
||||||
|
// Constructor: receives a sequence of wchar_ts, whatever they may be;
|
||||||
|
YAPAtomTerm(wchar_t *s) ;
|
||||||
|
// Constructor: receives a sequence of n wchar_ts, whatever they may be;
|
||||||
|
YAPAtomTerm(wchar_t *s, size_t len);
|
||||||
|
virtual bool isVar() { return false; } /// type check for unbound
|
||||||
|
virtual bool isAtom() { return true; } /// type check for atom
|
||||||
|
virtual bool isInteger() { return false; } /// type check for integer
|
||||||
|
virtual bool isFloat() { return false; } /// type check for floating-point
|
||||||
|
virtual bool isString() { return false; } /// type check for a string " ... "
|
||||||
|
virtual bool isCompound() { return false; } /// is a primitive term
|
||||||
|
virtual bool isAppl() { return false; } /// is a structured term
|
||||||
|
virtual bool isPair() { return false; } /// is a pair term
|
||||||
|
virtual bool isGround() { return true; } /// term is ground
|
||||||
|
virtual bool isList() { return gt() == TermNil; } /// [] is a list
|
||||||
|
// Getter: outputs the atom;
|
||||||
|
YAPAtom getAtom() { return YAPAtom(AtomOfTerm( gt() )); }
|
||||||
|
// Getter: outputs the name as a sequence of ISO-LATIN1 codes;
|
||||||
|
const char *text() { return (const char *)AtomOfTerm( gt() )->StrOfAE; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* YAPT_HH */
|
#endif /* YAPT_HH */
|
||||||
|
84
H/Atoms.h
84
H/Atoms.h
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#ifndef EXTERN
|
#ifndef EXTERN
|
||||||
#ifndef ADTDEFS_C
|
#ifndef ADTDEFS_C
|
||||||
#define EXTERN static
|
#define EXTERN static
|
||||||
#else
|
#else
|
||||||
#define EXTERN
|
#define EXTERN
|
||||||
#endif
|
#endif
|
||||||
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
typedef struct atom_blob {
|
typedef struct atom_blob {
|
||||||
size_t length;
|
size_t length;
|
||||||
char data[MIN_ARRAY];
|
char data[MIN_ARRAY];
|
||||||
} atom_blob_t;
|
} atom_blob_t;
|
||||||
@ -38,66 +38,59 @@ typedef struct atom_blob {
|
|||||||
/* Atoms are assumed to be uniquely represented by an OFFSET and to have
|
/* Atoms are assumed to be uniquely represented by an OFFSET and to have
|
||||||
associated with them a struct of type AtomEntry
|
associated with them a struct of type AtomEntry
|
||||||
The two functions
|
The two functions
|
||||||
RepAtom : Atom -> *AtomEntry
|
RepAtom : Atom -> *AtomEntry
|
||||||
AbsAtom : *AtomEntry -> Atom
|
AbsAtom : *AtomEntry -> Atom
|
||||||
are used to encapsulate the implementation of atoms
|
are used to encapsulate the implementation of atoms
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct AtomEntryStruct *Atom;
|
typedef struct AtomEntryStruct *Atom;
|
||||||
typedef struct PropEntryStruct *Prop;
|
typedef struct PropEntryStruct *Prop;
|
||||||
|
|
||||||
|
|
||||||
/* I can only define the structure after I define the actual atoms */
|
/* I can only define the structure after I define the actual atoms */
|
||||||
|
|
||||||
/* atom structure */
|
/* atom structure */
|
||||||
typedef struct AtomEntryStruct
|
typedef struct AtomEntryStruct {
|
||||||
{
|
Atom NextOfAE; /* used to build hash chains */
|
||||||
Atom NextOfAE; /* used to build hash chains */
|
Prop PropsOfAE; /* property list for this atom */
|
||||||
Prop PropsOfAE; /* property list for this atom */
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
rwlock_t ARWLock;
|
rwlock_t ARWLock;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
union {
|
union {
|
||||||
unsigned char uUStrOfAE[MIN_ARRAY]; /* representation of atom as a string */
|
unsigned char uUStrOfAE[MIN_ARRAY]; /* representation of atom as a string */
|
||||||
char uStrOfAE[MIN_ARRAY]; /* representation of atom as a string */
|
char uStrOfAE[MIN_ARRAY]; /* representation of atom as a string */
|
||||||
wchar_t uWStrOfAE[MIN_ARRAY]; /* representation of atom as a string */
|
wchar_t uWStrOfAE[MIN_ARRAY]; /* representation of atom as a string */
|
||||||
struct atom_blob blob[MIN_ARRAY];
|
struct atom_blob blob[MIN_ARRAY];
|
||||||
} rep;
|
} rep;
|
||||||
}
|
} AtomEntry;
|
||||||
AtomEntry;
|
|
||||||
|
|
||||||
// compatible with C and C++;
|
// compatible with C and C++;
|
||||||
typedef struct ExtraAtomEntryStruct
|
typedef struct ExtraAtomEntryStruct {
|
||||||
{
|
Atom NextOfAE; /* used to build hash chains */
|
||||||
Atom NextOfAE; /* used to build hash chains */
|
Prop PropsOfAE; /* property list for this atom */
|
||||||
Prop PropsOfAE; /* property list for this atom */
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
rwlock_t ARWLock;
|
rwlock_t ARWLock;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
union {
|
union {
|
||||||
unsigned char uUStrOfAE[4]; /* representation of atom as a string */
|
unsigned char uUStrOfAE[4]; /* representation of atom as a string */
|
||||||
char uStrOfAE[4]; /* representation of atom as a string */
|
char uStrOfAE[4]; /* representation of atom as a string */
|
||||||
wchar_t uWStrOfAE[2]; /* representation of atom as a string */
|
wchar_t uWStrOfAE[2]; /* representation of atom as a string */
|
||||||
struct atom_blob blob[2];
|
struct atom_blob blob[2];
|
||||||
} rep;
|
} rep;
|
||||||
}
|
} ExtraAtomEntry;
|
||||||
ExtraAtomEntry;
|
|
||||||
|
|
||||||
#define UStrOfAE rep.uUStrOfAE
|
#define UStrOfAE rep.uUStrOfAE
|
||||||
#define StrOfAE rep.uStrOfAE
|
#define StrOfAE rep.uStrOfAE
|
||||||
#define WStrOfAE rep.uWStrOfAE
|
#define WStrOfAE rep.uWStrOfAE
|
||||||
|
|
||||||
|
|
||||||
/* Props and Atoms are stored in chains, ending with a NIL */
|
/* Props and Atoms are stored in chains, ending with a NIL */
|
||||||
#ifdef USE_OFFSETS
|
#ifdef USE_OFFSETS
|
||||||
# define EndOfPAEntr(P) ( Addr(P) == AtomBase)
|
#define EndOfPAEntr(P) (Addr(P) == AtomBase)
|
||||||
#else
|
#else
|
||||||
# define EndOfPAEntr(P) ( Addr(P) == NIL )
|
#define EndOfPAEntr(P) (Addr(P) == NIL)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* ********************** Properties **********************************/
|
/* ********************** Properties **********************************/
|
||||||
|
|
||||||
#if defined(USE_OFFSETS)
|
#if defined(USE_OFFSETS)
|
||||||
@ -109,34 +102,32 @@ typedef struct ExtraAtomEntryStruct
|
|||||||
typedef SFLAGS PropFlags;
|
typedef SFLAGS PropFlags;
|
||||||
|
|
||||||
/* basic property entry structure */
|
/* basic property entry structure */
|
||||||
typedef struct PropEntryStruct
|
typedef struct PropEntryStruct {
|
||||||
{
|
Prop NextOfPE; /* used to chain properties */
|
||||||
Prop NextOfPE; /* used to chain properties */
|
PropFlags KindOfPE; /* kind of property */
|
||||||
PropFlags KindOfPE; /* kind of property */
|
|
||||||
} PropEntry;
|
} PropEntry;
|
||||||
|
|
||||||
/* ************************* Functors **********************************/
|
/* ************************* Functors **********************************/
|
||||||
|
|
||||||
/* Functor data type
|
/* Functor data type
|
||||||
abstype Functor = atom # int
|
abstype Functor = atom # int
|
||||||
with MkFunctor(a,n) = ...
|
with MkFunctor(a,n) = ...
|
||||||
and NameOfFunctor(f) = ...
|
and NameOfFunctor(f) = ...
|
||||||
and ArityOfFunctor(f) = ... */
|
and ArityOfFunctor(f) = ... */
|
||||||
|
|
||||||
#define MaxArity 255
|
#define MaxArity 255
|
||||||
|
|
||||||
typedef CELL arity_t;
|
typedef size_t arity_t;
|
||||||
|
|
||||||
#define FunctorProperty ((PropFlags)(0xbb00))
|
#define FunctorProperty ((PropFlags)(0xbb00))
|
||||||
|
|
||||||
/* functor property */
|
/* functor property */
|
||||||
typedef struct FunctorEntryStruct
|
typedef struct FunctorEntryStruct {
|
||||||
{
|
Prop NextOfPE; /* used to chain properties */
|
||||||
Prop NextOfPE; /* used to chain properties */
|
PropFlags KindOfPE; /* kind of property */
|
||||||
PropFlags KindOfPE; /* kind of property */
|
arity_t ArityOfFE; /* arity of functor */
|
||||||
arity_t ArityOfFE; /* arity of functor */
|
Atom NameOfFE; /* back pointer to owner atom */
|
||||||
Atom NameOfFE; /* back pointer to owner atom */
|
Prop PropsOfFE; /* pointer to list of properties for this functor */
|
||||||
Prop PropsOfFE; /* pointer to list of properties for this functor */
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
rwlock_t FRWLock;
|
rwlock_t FRWLock;
|
||||||
#endif
|
#endif
|
||||||
@ -144,5 +135,4 @@ typedef struct FunctorEntryStruct
|
|||||||
|
|
||||||
typedef FunctorEntry *Functor;
|
typedef FunctorEntry *Functor;
|
||||||
|
|
||||||
|
|
||||||
#endif /* ATOMS_H */
|
#endif /* ATOMS_H */
|
||||||
|
@ -67,22 +67,22 @@
|
|||||||
|
|
||||||
#include "inline-only.h"
|
#include "inline-only.h"
|
||||||
|
|
||||||
INLINE_ONLY int IsVarTerm (Term);
|
INLINE_ONLY bool IsVarTerm (Term);
|
||||||
|
|
||||||
INLINE_ONLY int
|
INLINE_ONLY bool
|
||||||
IsVarTerm (Term t)
|
IsVarTerm (Term t)
|
||||||
{
|
{
|
||||||
return (int) (Signed (t) >= 0);
|
return Signed (t) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
INLINE_ONLY int IsNonVarTerm (Term);
|
INLINE_ONLY bool IsNonVarTerm (Term);
|
||||||
|
|
||||||
INLINE_ONLY int
|
INLINE_ONLY bool
|
||||||
IsNonVarTerm (Term t)
|
IsNonVarTerm (Term t)
|
||||||
{
|
{
|
||||||
return (int) (Signed (t) < 0);
|
return Signed (t) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -107,12 +107,12 @@ AbsPair (Term * p)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
INLINE_ONLY Int IsPairTerm (Term);
|
INLINE_ONLY bool IsPairTerm (Term);
|
||||||
|
|
||||||
INLINE_ONLY Int
|
INLINE_ONLY bool
|
||||||
IsPairTerm (Term t)
|
IsPairTerm (Term t)
|
||||||
{
|
{
|
||||||
return (Int) (BitOn (PairBit, (t)));
|
return BitOn (PairBit, (t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -137,22 +137,22 @@ AbsAppl (Term * p)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
INLINE_ONLY Int IsApplTerm (Term);
|
INLINE_ONLY bool IsApplTerm (Term);
|
||||||
|
|
||||||
INLINE_ONLY Int
|
INLINE_ONLY bool
|
||||||
IsApplTerm (Term t)
|
IsApplTerm (Term t)
|
||||||
{
|
{
|
||||||
return (Int) (BitOn (ApplBit, (t)));
|
return BitOn (ApplBit, (t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
INLINE_ONLY Int IsAtomOrIntTerm (Term);
|
INLINE_ONLY bool IsAtomOrIntTerm (Term);
|
||||||
|
|
||||||
INLINE_ONLY Int
|
INLINE_ONLY bool
|
||||||
IsAtomOrIntTerm (Term t)
|
IsAtomOrIntTerm (Term t)
|
||||||
{
|
{
|
||||||
return (Int) (!(Unsigned (t) & CompBits));
|
return !(Unsigned (t) & CompBits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
120
H/TermExt.h
120
H/TermExt.h
@ -243,9 +243,9 @@ OOPS
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsFloatTerm(Term);
|
INLINE_ONLY inline EXTERN bool IsFloatTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsFloatTerm(Term t) {
|
INLINE_ONLY inline EXTERN bool IsFloatTerm(Term t) {
|
||||||
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorDouble);
|
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorDouble);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,10 +269,11 @@ INLINE_ONLY inline EXTERN Int LongIntOfTerm(Term t) {
|
|||||||
return (Int)(RepAppl(t)[1]);
|
return (Int)(RepAppl(t)[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsLongIntTerm(Term);
|
INLINE_ONLY inline EXTERN bool IsLongIntTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsLongIntTerm(Term t) {
|
INLINE_ONLY inline EXTERN bool IsLongIntTerm(Term t) {
|
||||||
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorLongInt);
|
return IsApplTerm(t) &&
|
||||||
|
FunctorOfTerm(t) == FunctorLongInt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************/
|
/****************************************************/
|
||||||
@ -325,10 +326,11 @@ INLINE_ONLY inline EXTERN const char *StringOfTerm(Term t) {
|
|||||||
return (const char *)(RepAppl(t) + 2);
|
return (const char *)(RepAppl(t) + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsStringTerm(Term);
|
INLINE_ONLY inline EXTERN bool IsStringTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsStringTerm(Term t) {
|
INLINE_ONLY inline EXTERN bool IsStringTerm(Term t) {
|
||||||
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorString);
|
return IsApplTerm(t) &&
|
||||||
|
FunctorOfTerm(t) == FunctorString;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************/
|
/****************************************************/
|
||||||
@ -357,10 +359,11 @@ typedef struct {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsBigIntTerm(Term);
|
INLINE_ONLY inline EXTERN bool IsBigIntTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsBigIntTerm(Term t) {
|
INLINE_ONLY inline EXTERN bool IsBigIntTerm(Term t) {
|
||||||
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorBigInt);
|
return IsApplTerm(t) &&
|
||||||
|
FunctorOfTerm(t) == FunctorBigInt;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_GMP
|
#ifdef USE_GMP
|
||||||
@ -379,11 +382,12 @@ INLINE_ONLY inline EXTERN void MPZ_SET(mpz_t dest, MP_INT *src) {
|
|||||||
dest->_mp_d = src->_mp_d;
|
dest->_mp_d = src->_mp_d;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsLargeIntTerm(Term);
|
INLINE_ONLY inline EXTERN bool IsLargeIntTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsLargeIntTerm(Term t) {
|
INLINE_ONLY inline EXTERN bool IsLargeIntTerm(Term t) {
|
||||||
return (int)(IsApplTerm(t) && ((FunctorOfTerm(t) <= FunctorBigInt) &&
|
return IsApplTerm(t) &&
|
||||||
(FunctorOfTerm(t) >= FunctorLongInt)));
|
((FunctorOfTerm(t) <= FunctorBigInt) &&
|
||||||
|
(FunctorOfTerm(t) >= FunctorLongInt));
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN UInt Yap_SizeOfBigInt(Term);
|
INLINE_ONLY inline EXTERN UInt Yap_SizeOfBigInt(Term);
|
||||||
@ -407,18 +411,20 @@ INLINE_ONLY inline EXTERN int IsLargeIntTerm(Term t) {
|
|||||||
|
|
||||||
/* extern Functor FunctorLongInt; */
|
/* extern Functor FunctorLongInt; */
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsLargeNumTerm(Term);
|
INLINE_ONLY inline EXTERN bool IsLargeNumTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsLargeNumTerm(Term t) {
|
INLINE_ONLY inline EXTERN bool IsLargeNumTerm(Term t) {
|
||||||
return (int)(IsApplTerm(t) && ((FunctorOfTerm(t) <= FunctorBigInt) &&
|
return IsApplTerm(t) &&
|
||||||
(FunctorOfTerm(t) >= FunctorDouble)));
|
((FunctorOfTerm(t) <= FunctorBigInt) &&
|
||||||
|
(FunctorOfTerm(t) >= FunctorDouble));
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsExternalBlobTerm(Term, CELL);
|
INLINE_ONLY inline EXTERN bool IsExternalBlobTerm(Term, CELL);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsExternalBlobTerm(Term t, CELL tag) {
|
INLINE_ONLY inline EXTERN bool IsExternalBlobTerm(Term t, CELL tag) {
|
||||||
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorBigInt &&
|
return IsApplTerm(t) &&
|
||||||
RepAppl(t)[1] == tag);
|
FunctorOfTerm(t) == FunctorBigInt &&
|
||||||
|
RepAppl(t)[1] == tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN void *ExternalBlobFromTerm(Term);
|
INLINE_ONLY inline EXTERN void *ExternalBlobFromTerm(Term);
|
||||||
@ -428,63 +434,69 @@ INLINE_ONLY inline EXTERN void *ExternalBlobFromTerm(Term t) {
|
|||||||
return (void *)(base + 1);
|
return (void *)(base + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsNumTerm(Term);
|
INLINE_ONLY inline EXTERN bool IsNumTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsNumTerm(Term t) {
|
INLINE_ONLY inline EXTERN bool IsNumTerm(Term t) {
|
||||||
return (int)((IsIntTerm(t) || IsLargeNumTerm(t)));
|
return (IsIntTerm(t) || IsLargeNumTerm(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int IsAtomicTerm(Term);
|
INLINE_ONLY inline EXTERN bool IsAtomicTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int IsAtomicTerm(Term t) {
|
INLINE_ONLY inline EXTERN bool IsAtomicTerm(Term t) {
|
||||||
return (Int)(IsAtomOrIntTerm(t) || IsLargeNumTerm(t) || IsStringTerm(t));
|
return IsAtomOrIntTerm(t) ||
|
||||||
|
IsLargeNumTerm(t) ||
|
||||||
|
IsStringTerm(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int IsExtensionFunctor(Functor);
|
INLINE_ONLY inline EXTERN bool IsExtensionFunctor(Functor);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int IsExtensionFunctor(Functor f) {
|
INLINE_ONLY inline EXTERN bool IsExtensionFunctor(Functor f) {
|
||||||
return (Int)(f <= FunctorString);
|
return f <= FunctorString;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int IsBlobFunctor(Functor);
|
INLINE_ONLY inline EXTERN bool IsBlobFunctor(Functor);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int IsBlobFunctor(Functor f) {
|
INLINE_ONLY inline EXTERN bool IsBlobFunctor(Functor f) {
|
||||||
return (Int)((f <= FunctorString && f >= FunctorDBRef));
|
return (f <= FunctorString &&
|
||||||
|
f >= FunctorDBRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int IsPrimitiveTerm(Term);
|
INLINE_ONLY inline EXTERN bool IsPrimitiveTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int IsPrimitiveTerm(Term t) {
|
INLINE_ONLY inline EXTERN bool IsPrimitiveTerm(Term t) {
|
||||||
return (Int)((IsAtomOrIntTerm(t) ||
|
return (IsAtomOrIntTerm(t) ||
|
||||||
(IsApplTerm(t) && IsBlobFunctor(FunctorOfTerm(t)))));
|
(IsApplTerm(t) &&
|
||||||
|
IsBlobFunctor(FunctorOfTerm(t))));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TERM_EXTENSIONS
|
#ifdef TERM_EXTENSIONS
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int IsAttachFunc(Functor);
|
INLINE_ONLY inline EXTERN bool IsAttachFunc(Functor);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int IsAttachFunc(Functor f) { return (Int)(FALSE); }
|
INLINE_ONLY inline EXTERN bool IsAttachFunc(Functor f) { return (Int)(FALSE); }
|
||||||
|
|
||||||
#define IsAttachedTerm(t) __IsAttachedTerm(t PASS_REGS)
|
#define IsAttachedTerm(t) __IsAttachedTerm(t PASS_REGS)
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int __IsAttachedTerm(Term USES_REGS);
|
INLINE_ONLY inline EXTERN bool __IsAttachedTerm(Term USES_REGS);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int __IsAttachedTerm(Term t USES_REGS) {
|
INLINE_ONLY inline EXTERN bool __IsAttachedTerm(Term t USES_REGS) {
|
||||||
return (Int)((IsVarTerm(t) && IsAttVar(VarOfTerm(t))));
|
return (IsVarTerm(t) &&
|
||||||
|
IsAttVar(VarOfTerm(t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int GlobalIsAttachedTerm(Term);
|
INLINE_ONLY inline EXTERN bool GlobalIsAttachedTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int GlobalIsAttachedTerm(Term t) {
|
INLINE_ONLY inline EXTERN bool GlobalIsAttachedTerm(Term t) {
|
||||||
return (Int)((IsVarTerm(t) && GlobalIsAttVar(VarOfTerm(t))));
|
return (IsVarTerm(t) &&
|
||||||
|
GlobalIsAttVar(VarOfTerm(t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SafeIsAttachedTerm(t) __SafeIsAttachedTerm((t)PASS_REGS)
|
#define SafeIsAttachedTerm(t) __SafeIsAttachedTerm((t)PASS_REGS)
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int __SafeIsAttachedTerm(Term USES_REGS);
|
INLINE_ONLY inline EXTERN bool __SafeIsAttachedTerm(Term USES_REGS);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int __SafeIsAttachedTerm(Term t USES_REGS) {
|
INLINE_ONLY inline EXTERN bool __SafeIsAttachedTerm(Term t USES_REGS) {
|
||||||
return (Int)(IsVarTerm(t) && IsAttVar(VarOfTerm(t)));
|
return IsVarTerm(t) && IsAttVar(VarOfTerm(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN exts ExtFromCell(CELL *);
|
INLINE_ONLY inline EXTERN exts ExtFromCell(CELL *);
|
||||||
@ -523,13 +535,13 @@ INLINE_ONLY inline EXTERN void *Yap_BlobInfo(Term t) {
|
|||||||
|
|
||||||
#ifdef YAP_H
|
#ifdef YAP_H
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int unify_extension(Functor, CELL, CELL *, CELL);
|
INLINE_ONLY inline EXTERN bool unify_extension(Functor, CELL, CELL *, CELL);
|
||||||
|
|
||||||
EXTERN int unify_extension(Functor, CELL, CELL *, CELL);
|
EXTERN bool unify_extension(Functor, CELL, CELL *, CELL);
|
||||||
|
|
||||||
int Yap_gmp_tcmp_big_big(Term, Term);
|
int Yap_gmp_tcmp_big_big(Term, Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int unify_extension(Functor f, CELL d0, CELL *pt0,
|
INLINE_ONLY inline EXTERN bool unify_extension(Functor f, CELL d0, CELL *pt0,
|
||||||
CELL d1) {
|
CELL d1) {
|
||||||
switch (BlobOfFunctor(f)) {
|
switch (BlobOfFunctor(f)) {
|
||||||
case db_ref_e:
|
case db_ref_e:
|
||||||
@ -555,7 +567,7 @@ INLINE_ONLY inline EXTERN int unify_extension(Functor f, CELL d0, CELL *pt0,
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (FALSE);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline CELL Yap_IntP_key(CELL *pt) {
|
static inline CELL Yap_IntP_key(CELL *pt) {
|
||||||
|
27
H/YapTags.h
27
H/YapTags.h
@ -170,9 +170,10 @@ INLINE_ONLY inline EXTERN Term MkVarTerm__(USES_REGS1) {
|
|||||||
return (Term)((*HR = 0, HR++));
|
return (Term)((*HR = 0, HR++));
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsUnboundVar(Term *);
|
INLINE_ONLY inline EXTERN bool IsUnboundVar(Term *);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsUnboundVar(Term *t) { return (int)(*(t) == 0); }
|
INLINE_ONLY inline EXTERN bool IsUnboundVar(Term *t) { return (int)(*(t) ==
|
||||||
|
0); }
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@ -184,10 +185,10 @@ INLINE_ONLY inline EXTERN Term MkVarTerm__(USES_REGS1) {
|
|||||||
return (Term)((*HR = (CELL)HR, HR++));
|
return (Term)((*HR = (CELL)HR, HR++));
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsUnboundVar(Term *);
|
INLINE_ONLY inline EXTERN bool IsUnboundVar(Term *);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsUnboundVar(Term *t) {
|
INLINE_ONLY inline EXTERN bool IsUnboundVar(Term *t) {
|
||||||
return (int)(*(t) == (Term)(t));
|
return *(t) == (Term)(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -234,10 +235,10 @@ INLINE_ONLY inline EXTERN Atom AtomOfTerm(Term t) {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsAtomTerm(Term);
|
INLINE_ONLY inline EXTERN bool IsAtomTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsAtomTerm(Term t) {
|
INLINE_ONLY inline EXTERN bool IsAtomTerm(Term t) {
|
||||||
return (int)(CHKTAG((t), AtomTag));
|
return CHKTAG((t), AtomTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Term MkIntTerm(Int);
|
INLINE_ONLY inline EXTERN Term MkIntTerm(Int);
|
||||||
@ -257,10 +258,10 @@ INLINE_ONLY inline EXTERN Term MkIntConstant(Int n) {
|
|||||||
return (Term)(NONTAGGED(NumberTag, (n)));
|
return (Term)(NONTAGGED(NumberTag, (n)));
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsIntTerm(Term);
|
INLINE_ONLY inline EXTERN bool IsIntTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsIntTerm(Term t) {
|
INLINE_ONLY inline EXTERN bool IsIntTerm(Term t) {
|
||||||
return (int)(CHKTAG((t), NumberTag));
|
return CHKTAG((t), NumberTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY EXTERN inline Term MkPairTerm__(Term head, Term tail USES_REGS);
|
INLINE_ONLY EXTERN inline Term MkPairTerm__(Term head, Term tail USES_REGS);
|
||||||
@ -312,9 +313,9 @@ INLINE_ONLY inline EXTERN Term __MkIntegerTerm(Int n USES_REGS) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsIntegerTerm(Term);
|
INLINE_ONLY inline EXTERN bool IsIntegerTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsIntegerTerm(Term t) {
|
INLINE_ONLY inline EXTERN bool IsIntegerTerm(Term t) {
|
||||||
return (int)(IsIntTerm(t) || IsLongIntTerm(t));
|
return (int)(IsIntTerm(t) || IsLongIntTerm(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -773,6 +773,7 @@ static inline Term Yap_WCharsToDiffListOfCodes(const wchar_t *s,
|
|||||||
out.dif = tail;
|
out.dif = tail;
|
||||||
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
||||||
return 0L;
|
return 0L;
|
||||||
|
|
||||||
return out.val.t;
|
return out.val.t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
H/Yapproto.h
10
H/Yapproto.h
@ -465,19 +465,19 @@ void Yap_InitUserBacks(void);
|
|||||||
|
|
||||||
/* utilpreds.c */
|
/* utilpreds.c */
|
||||||
Term Yap_CopyTerm(Term);
|
Term Yap_CopyTerm(Term);
|
||||||
int Yap_Variant(Term, Term);
|
bool Yap_Variant(Term, Term);
|
||||||
size_t Yap_ExportTerm(Term, char *, size_t, UInt);
|
size_t Yap_ExportTerm(Term, char *, size_t, UInt);
|
||||||
size_t Yap_SizeOfExportedTerm(char *);
|
size_t Yap_SizeOfExportedTerm(char *);
|
||||||
Term Yap_ImportTerm(char *);
|
Term Yap_ImportTerm(char *);
|
||||||
int Yap_IsListTerm(Term);
|
bool Yap_IsListTerm(Term);
|
||||||
bool Yap_IsListOrPartialListTerm(Term);
|
bool Yap_IsListOrPartialListTerm(Term);
|
||||||
Term Yap_CopyTermNoShare(Term);
|
Term Yap_CopyTermNoShare(Term);
|
||||||
int Yap_SizeGroundTerm(Term, int);
|
int Yap_SizeGroundTerm(Term, int);
|
||||||
int Yap_IsGroundTerm(Term);
|
bool Yap_IsGroundTerm(Term);
|
||||||
int Yap_IsAcyclicTerm(Term);
|
bool Yap_IsAcyclicTerm(Term);
|
||||||
void Yap_InitUtilCPreds(void);
|
void Yap_InitUtilCPreds(void);
|
||||||
Int Yap_TermHash(Term, Int, Int, int);
|
Int Yap_TermHash(Term, Int, Int, int);
|
||||||
Int Yap_NumberVars(Term, Int, int);
|
Int Yap_NumberVars(Term, Int, bool);
|
||||||
Term Yap_TermVariables(Term t, UInt arity USES_REGS);
|
Term Yap_TermVariables(Term t, UInt arity USES_REGS);
|
||||||
Term Yap_UnNumberTerm(Term, int);
|
Term Yap_UnNumberTerm(Term, int);
|
||||||
Int Yap_SkipList(Term *, Term **);
|
Int Yap_SkipList(Term *, Term **);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*************************************************************************
|
vv/*************************************************************************
|
||||||
* *
|
* *
|
||||||
* YAP Prolog *
|
* YAP Prolog *
|
||||||
* *
|
* *
|
||||||
@ -697,6 +697,7 @@ db_files(Fs) :-
|
|||||||
StartMsg = consulting,
|
StartMsg = consulting,
|
||||||
EndMsg = consulted
|
EndMsg = consulted
|
||||||
),
|
),
|
||||||
|
current_prolog_flag(verbose_load, VerboseLoad),
|
||||||
'$early_print'(informational, loading(StartMsg, UserFile)),
|
'$early_print'(informational, loading(StartMsg, UserFile)),
|
||||||
'$lf_opt'(skip_unix_header , TOpts, SkipUnixHeader),
|
'$lf_opt'(skip_unix_header , TOpts, SkipUnixHeader),
|
||||||
( SkipUnixHeader == true
|
( SkipUnixHeader == true
|
||||||
@ -709,6 +710,7 @@ db_files(Fs) :-
|
|||||||
'$lf_opt'(imports, TOpts, Imports),
|
'$lf_opt'(imports, TOpts, Imports),
|
||||||
'$import_to_current_module'(File, ContextModule, Imports, _, TOpts),
|
'$import_to_current_module'(File, ContextModule, Imports, _, TOpts),
|
||||||
'$current_module'(Mod, SourceModule),
|
'$current_module'(Mod, SourceModule),
|
||||||
|
set_prolog_flag(verbose_load, VerboseLoad),
|
||||||
H is heapused-H0, '$cputime'(TF,_), T is TF-T0,
|
H is heapused-H0, '$cputime'(TF,_), T is TF-T0,
|
||||||
'$early_print'(informational, loaded(EndMsg, File, Mod, T, H)),
|
'$early_print'(informational, loaded(EndMsg, File, Mod, T, H)),
|
||||||
'$end_consult',
|
'$end_consult',
|
||||||
|
@ -372,8 +372,8 @@ be lost.
|
|||||||
'$loop_spy'(GoalNumber, G, Module, CalledFromDebugger) :-
|
'$loop_spy'(GoalNumber, G, Module, CalledFromDebugger) :-
|
||||||
'$current_choice_point'(CP),
|
'$current_choice_point'(CP),
|
||||||
'$system_catch'('$loop_spy2'(GoalNumber, G, Module, CalledFromDebugger, CP),
|
'$system_catch'('$loop_spy2'(GoalNumber, G, Module, CalledFromDebugger, CP),
|
||||||
Module, error(Event,Context),
|
Module, Error,
|
||||||
'$loop_spy_event'(error(Event,Context), GoalNumber, G, Module, CalledFromDebugger)).
|
'$loop_spy_event'(Error, GoalNumber, G, Module, CalledFromDebugger)).
|
||||||
|
|
||||||
% handle weird things happening in the debugger.
|
% handle weird things happening in the debugger.
|
||||||
'$loop_spy_event'('$pass'(Event), _, _, _, _) :- !,
|
'$loop_spy_event'('$pass'(Event), _, _, _, _) :- !,
|
||||||
@ -736,7 +736,7 @@ be lost.
|
|||||||
fail.
|
fail.
|
||||||
'$action'(0'A,_,_,_,_,_) :- !, % 'b break
|
'$action'(0'A,_,_,_,_,_) :- !, % 'b break
|
||||||
'$skipeol'(0'A),
|
'$skipeol'(0'A),
|
||||||
'$hacks':'$stack_dump',
|
'$stack_dump',
|
||||||
fail.
|
fail.
|
||||||
'$action'(0'c,_,_,_,_,on) :- !, % 'c creep
|
'$action'(0'c,_,_,_,_,on) :- !, % 'c creep
|
||||||
'$skipeol'(0'c),
|
'$skipeol'(0'c),
|
||||||
|
Reference in New Issue
Block a user