Conflicts:
	CXX/yapi.hh
This commit is contained in:
Vitor Santos Costa 2014-08-11 00:28:25 +01:00
commit 7f3dc7e5ab
404 changed files with 312612 additions and 11707 deletions

6
.gitmodules vendored
View File

@ -31,9 +31,6 @@
[submodule "packages/R"]
path = packages/R
url = git://git.code.sf.net/p/yap/R
[submodule "packages/pldoc"]
path = packages/pldoc
url = git://git.code.sf.net/p/yap/pldoc
[submodule "packages/real"]
path = packages/real
url = git://git.code.sf.net/p/yap/real
@ -46,9 +43,6 @@
[submodule "packages/udi"]
path = packages/udi
url = https://github.com/davidvaz/yap-udi-indexers.git
[submodule "packages/ltx2htm"]
path = packages/ltx2htm
url = git://git.code.sf.net/p/yap/ltx2htm
[submodule "packages/raptor"]
path = packages/raptor
url = git://git.code.sf.net/p/yap/raptor

2385
C/absmi.c

File diff suppressed because it is too large Load Diff

View File

@ -109,7 +109,7 @@ Yap_MkFunctorWithAddress(Atom ap, unsigned int arity, FunctorEntry *p)
}
inline static Atom
SearchInInvisible(char *atom)
SearchInInvisible(const char *atom)
{
AtomEntry *chain;
@ -141,7 +141,7 @@ SearchAtom(unsigned char *p, Atom a) {
}
static inline Atom
SearchWideAtom(wchar_t *p, Atom a) {
SearchWideAtom(const wchar_t *p, Atom a) {
AtomEntry *ae;
/* search atom in chain */
@ -156,7 +156,7 @@ SearchWideAtom(wchar_t *p, Atom a) {
}
static Atom
LookupAtom(char *atom)
LookupAtom(const char *atom)
{ /* lookup atom in atom table */
UInt hash;
unsigned char *p;
@ -216,7 +216,7 @@ LookupAtom(char *atom)
static Atom
LookupWideAtom(wchar_t *atom)
LookupWideAtom(const wchar_t *atom)
{ /* lookup atom in atom table */
CELL hash;
wchar_t *p;
@ -226,7 +226,7 @@ LookupWideAtom(wchar_t *atom)
WideAtomEntry *wae;
/* compute hash */
p = atom;
p = (wchar_t *)atom;
hash = WideHashFunction(p) % WideAtomHashTableSize;
/* we'll start by holding a read lock in order to avoid contention */
READ_LOCK(WideHashChain[hash].AERWLock);
@ -285,9 +285,9 @@ LookupWideAtom(wchar_t *atom)
}
Atom
Yap_LookupMaybeWideAtom(wchar_t *atom)
Yap_LookupMaybeWideAtom(const wchar_t *atom)
{ /* lookup atom in atom table */
wchar_t *p = atom, c;
wchar_t *p = (wchar_t *)atom, c;
size_t len = 0;
char *ptr, *ptr0;
Atom at;
@ -297,7 +297,7 @@ Yap_LookupMaybeWideAtom(wchar_t *atom)
len++;
}
/* not really a wide atom */
p = atom;
p = (wchar_t *)atom;
ptr0 = ptr = Yap_AllocCodeSpace(len+1);
if (!ptr)
return NIL;
@ -308,7 +308,7 @@ Yap_LookupMaybeWideAtom(wchar_t *atom)
}
Atom
Yap_LookupMaybeWideAtomWithLength(wchar_t *atom, size_t len0)
Yap_LookupMaybeWideAtomWithLength(const wchar_t *atom, size_t len0)
{ /* lookup atom in atom table */
Atom at;
int wide = FALSE;
@ -354,7 +354,7 @@ Yap_LookupMaybeWideAtomWithLength(wchar_t *atom, size_t len0)
}
Atom
Yap_LookupAtomWithLength(char *atom, size_t len0)
Yap_LookupAtomWithLength(const char *atom, size_t len0)
{ /* lookup atom in atom table */
Atom at;
char *ptr;
@ -371,19 +371,19 @@ Yap_LookupAtomWithLength(char *atom, size_t len0)
}
Atom
Yap_LookupAtom(char *atom)
Yap_LookupAtom(const char *atom)
{ /* lookup atom in atom table */
return LookupAtom(atom);
}
Atom
Yap_LookupWideAtom(wchar_t *atom)
Yap_LookupWideAtom(const wchar_t *atom)
{ /* lookup atom in atom table */
return LookupWideAtom(atom);
}
Atom
Yap_FullLookupAtom(char *atom)
Yap_FullLookupAtom(const char *atom)
{ /* lookup atom in atom table */
Atom t;
@ -394,7 +394,7 @@ Yap_FullLookupAtom(char *atom)
}
void
Yap_LookupAtomWithAddress(char *atom, AtomEntry *ae)
Yap_LookupAtomWithAddress(const char *atom, AtomEntry *ae)
{ /* lookup atom in atom table */
register CELL hash;
register unsigned char *p;
@ -699,10 +699,10 @@ Yap_GetPredPropByFunc(Functor f, Term cur_mod)
{
Prop p0;
READ_LOCK(f->FRWLock);
FUNC_READ_LOCK(f);
p0 = GetPredPropByFuncHavingLock(f, cur_mod);
READ_UNLOCK(f->FRWLock);
FUNC_READ_UNLOCK(f);
return (p0);
}
@ -712,9 +712,9 @@ Yap_GetPredPropByFuncInThisModule(Functor f, Term cur_mod)
{
Prop p0;
READ_LOCK(f->FRWLock);
FUNC_READ_LOCK(f);
p0 = GetPredPropByFuncHavingLock(f, cur_mod);
READ_UNLOCK(f->FRWLock);
FUNC_READ_UNLOCK(f);
return (p0);
}
@ -730,9 +730,9 @@ Yap_GetPredPropHavingLock(Atom ap, unsigned int arity, Term mod)
GetPredPropByAtomHavingLock(ae, mod);
}
f = InlinedUnlockedMkFunctor(ae, arity);
READ_LOCK(f->FRWLock);
FUNC_READ_LOCK(f);
p0 = GetPredPropByFuncHavingLock(f, mod);
READ_UNLOCK(f->FRWLock);
FUNC_READ_UNLOCK(f);
return (p0);
}
@ -811,40 +811,11 @@ Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod)
p->ModuleOfPred = 0L;
else
p->ModuleOfPred = cur_mod;
if (fe->PropsOfFE) {
UInt hsh = PRED_HASH(fe, cur_mod, PredHashTableSize);
WRITE_LOCK(PredHashRWLock);
if (10*(PredsInHashTable+1) > 6*PredHashTableSize) {
if (!ExpandPredHash()) {
Yap_FreeCodeSpace((ADDR)p);
WRITE_UNLOCK(PredHashRWLock);
WRITE_UNLOCK(fe->FRWLock);
return NULL;
}
/* retry hashing */
hsh = PRED_HASH(fe, cur_mod, PredHashTableSize);
}
PredsInHashTable++;
if (p->ModuleOfPred == 0L) {
PredEntry *pe = RepPredProp(fe->PropsOfFE);
hsh = PRED_HASH(fe, pe->ModuleOfPred, PredHashTableSize);
/* should be the first one */
pe->NextOfPE = AbsPredProp(PredHash[hsh]);
PredHash[hsh] = pe;
fe->PropsOfFE = AbsPredProp(p);
} else {
p->NextOfPE = AbsPredProp(PredHash[hsh]);
PredHash[hsh] = p;
}
WRITE_UNLOCK(PredHashRWLock);
/* make sure that we have something here: note that this is not a valid pointer!! */
RepPredProp(fe->PropsOfFE)->NextOfPE = fe->PropsOfFE;
} else {
fe->PropsOfFE = AbsPredProp(p);
p->NextOfPE = NIL;
}
//TRUE_FUNC_WRITE_LOCK(fe);
#if DEBUG_NEW_FUNCTOR
if (!strcmp(fe->NameOfFE->StrOfAE, "library_directory"))
jmp_deb(1);
#endif
INIT_LOCK(p->PELock);
p->KindOfPE = PEProp;
p->ArityOfPE = fe->ArityOfFE;
@ -883,10 +854,44 @@ Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod)
}
}
if (LOCAL_PL_local_data_p== NULL || !truePrologFlag(PLFLAG_DEBUGINFO)) {
p->ExtraPredFlags |= NoDebugPredFlag;
p->ExtraPredFlags |= NoTracePredFlag;
}
p->FunctorOfPred = fe;
WRITE_UNLOCK(fe->FRWLock);
if (fe->PropsOfFE) {
UInt hsh = PRED_HASH(fe, cur_mod, PredHashTableSize);
WRITE_LOCK(PredHashRWLock);
if (10*(PredsInHashTable+1) > 6*PredHashTableSize) {
if (!ExpandPredHash()) {
Yap_FreeCodeSpace((ADDR)p);
WRITE_UNLOCK(PredHashRWLock);
FUNC_WRITE_UNLOCK(fe);
return NULL;
}
/* retry hashing */
hsh = PRED_HASH(fe, cur_mod, PredHashTableSize);
}
PredsInHashTable++;
if (p->ModuleOfPred == 0L) {
PredEntry *pe = RepPredProp(fe->PropsOfFE);
hsh = PRED_HASH(fe, pe->ModuleOfPred, PredHashTableSize);
/* should be the first one */
pe->NextOfPE = AbsPredProp(PredHash[hsh]);
PredHash[hsh] = pe;
fe->PropsOfFE = AbsPredProp(p);
} else {
p->NextOfPE = AbsPredProp(PredHash[hsh]);
PredHash[hsh] = p;
}
WRITE_UNLOCK(PredHashRWLock);
/* make sure that we have something here: note that this is not a valid pointer!! */
RepPredProp(fe->PropsOfFE)->NextOfPE = fe->PropsOfFE;
} else {
fe->PropsOfFE = AbsPredProp(p);
p->NextOfPE = NIL;
}
FUNC_WRITE_UNLOCK(fe);
{
Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred)+1, p, GPROF_NEW_PRED_FUNC);
if (!(p->PredFlags & (CPredFlag|AsmPredFlag))) {
@ -938,7 +943,7 @@ Yap_NewThreadPred(PredEntry *ap USES_REGS)
p->FunctorOfPred = ap->FunctorOfPred;
Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred)+1, p, GPROF_NEW_PRED_THREAD);
if (LOCAL_PL_local_data_p== NULL || !truePrologFlag(PLFLAG_DEBUGINFO)) {
p->ExtraPredFlags |= NoDebugPredFlag;
p->ExtraPredFlags |= (NoSpyPredFlag|NoTracePredFlag);
}
if (!(p->PredFlags & (CPredFlag|AsmPredFlag))) {
Yap_inform_profiler_of_clause(&(p->cs.p_code.ExpandCode), &(p->cs.p_code.ExpandCode)+1, p, GPROF_NEW_PRED_THREAD);
@ -1009,7 +1014,7 @@ Yap_NewPredPropByAtom(AtomEntry *ae, Term cur_mod)
p0 = AbsPredProp(p);
p->FunctorOfPred = (Functor)AbsAtom(ae);
if (LOCAL_PL_local_data_p== NULL || !truePrologFlag(PLFLAG_DEBUGINFO)) {
p->ExtraPredFlags |= NoDebugPredFlag;
p->ExtraPredFlags |= (NoTracePredFlag|NoSpyPredFlag);
}
WRITE_UNLOCK(ae->ARWLock);
{
@ -1027,7 +1032,7 @@ Yap_PredPropByFunctorNonThreadLocal(Functor f, Term cur_mod)
{
PredEntry *p;
WRITE_LOCK(f->FRWLock);
FUNC_WRITE_LOCK(f);
if (!(p = RepPredProp(f->PropsOfFE)))
return Yap_NewPredPropByFunctor(f,cur_mod);
@ -1037,7 +1042,7 @@ Yap_PredPropByFunctorNonThreadLocal(Functor f, Term cur_mod)
p->ModuleOfPred ||
!cur_mod ||
cur_mod == TermProlog) {
WRITE_UNLOCK(f->FRWLock);
FUNC_WRITE_UNLOCK(f);
return AbsPredProp(p);
}
}
@ -1051,7 +1056,7 @@ Yap_PredPropByFunctorNonThreadLocal(Functor f, Term cur_mod)
p->ModuleOfPred == cur_mod)
{
READ_UNLOCK(PredHashRWLock);
WRITE_UNLOCK(f->FRWLock);
FUNC_WRITE_UNLOCK(f);
return AbsPredProp(p);
}
p = RepPredProp(p->NextOfPE);

594
C/amasm.c

File diff suppressed because it is too large Load Diff

View File

@ -290,7 +290,7 @@ GetNBTerm(live_term *ar, Int indx USES_REGS)
return TermNil;
}
}
Bind(&(ar[indx].tlive), livet);
YapBind(&(ar[indx].tlive), livet);
return livet;
}
}
@ -2002,7 +2002,7 @@ p_assign_dynamic( USES_REGS1 )
Term tn = Yap_NewTimedVar(t3);
CELL *sp = RepAppl(tn);
*sp = (CELL)FunctorAtFoundOne;
Bind(&(ptr->ValueOfVE.lterms[indx].tlive),tn);
YapBind(&(ptr->ValueOfVE.lterms[indx].tlive),tn);
} else {
Yap_UpdateTimedVar(t, t3);
}

View File

@ -55,6 +55,139 @@ static Int p_number_chars( USES_REGS1 );
static Int p_number_codes( USES_REGS1 );
static Int init_current_atom( USES_REGS1 );
static Int cont_current_atom( USES_REGS1 );
static int AlreadyHidden(char *);
static Int p_hide( USES_REGS1 );
static Int p_hidden( USES_REGS1 );
static Int p_unhide( USES_REGS1 );
static int
AlreadyHidden(char *name)
{
AtomEntry *chain;
READ_LOCK(INVISIBLECHAIN.AERWLock);
chain = RepAtom(INVISIBLECHAIN.Entry);
READ_UNLOCK(INVISIBLECHAIN.AERWLock);
while (!EndOfPAEntr(chain) && strcmp(chain->StrOfAE, name) != 0)
chain = RepAtom(chain->NextOfAE);
if (EndOfPAEntr(chain))
return (FALSE);
return (TRUE);
}
/** @pred hide(+ _Atom_)
Make atom _Atom_ invisible.
Notice that defining a new atom with the same characters will
result in a different atom.xs
**/
static Int
p_hide( USES_REGS1 )
{ /* hide(+Atom) */
Atom atomToInclude;
Term t1 = Deref(ARG1);
if (IsVarTerm(t1)) {
Yap_Error(INSTANTIATION_ERROR,t1,"hide/1");
return(FALSE);
}
if (!IsAtomTerm(t1)) {
Yap_Error(TYPE_ERROR_ATOM,t1,"hide/1");
return(FALSE);
}
atomToInclude = AtomOfTerm(t1);
if (AlreadyHidden(RepAtom(atomToInclude)->StrOfAE)) {
Yap_Error(SYSTEM_ERROR,t1,"an atom of name %s was already hidden",
RepAtom(atomToInclude)->StrOfAE);
return(FALSE);
}
Yap_ReleaseAtom(atomToInclude);
WRITE_LOCK(INVISIBLECHAIN.AERWLock);
WRITE_LOCK(RepAtom(atomToInclude)->ARWLock);
RepAtom(atomToInclude)->NextOfAE = INVISIBLECHAIN.Entry;
WRITE_UNLOCK(RepAtom(atomToInclude)->ARWLock);
INVISIBLECHAIN.Entry = atomToInclude;
WRITE_UNLOCK(INVISIBLECHAIN.AERWLock);
return (TRUE);
}
/** @pred hidden( +Atom )
Is the atom _Ãtom_ visible to Prolog?
**/
static Int
p_hidden( USES_REGS1 )
{ /* '$hidden'(+F) */
Atom at;
AtomEntry *chain;
Term t1 = Deref(ARG1);
if (IsVarTerm(t1))
return (FALSE);
if (IsAtomTerm(t1))
at = AtomOfTerm(t1);
else if (IsApplTerm(t1))
at = NameOfFunctor(FunctorOfTerm(t1));
else
return (FALSE);
READ_LOCK(INVISIBLECHAIN.AERWLock);
chain = RepAtom(INVISIBLECHAIN.Entry);
while (!EndOfPAEntr(chain) && AbsAtom(chain) != at)
chain = RepAtom(chain->NextOfAE);
READ_UNLOCK(INVISIBLECHAIN.AERWLock);
if (EndOfPAEntr(chain))
return (FALSE);
return (TRUE);
}
/** @pred unhide(+ _Atom_)
Make hidden atom _Atom_ visible
Note that the operation fails if another atom with name _Atom_ was defined since.
**/
static Int
p_unhide( USES_REGS1 )
{ /* unhide(+Atom) */
AtomEntry *atom, *old, *chain;
Term t1 = Deref(ARG1);
if (IsVarTerm(t1)) {
Yap_Error(INSTANTIATION_ERROR,t1,"unhide/1");
return(FALSE);
}
if (!IsAtomTerm(t1)) {
Yap_Error(TYPE_ERROR_ATOM,t1,"unhide/1");
return(FALSE);
}
atom = RepAtom(AtomOfTerm(t1));
WRITE_LOCK(atom->ARWLock);
if (atom->PropsOfAE != NIL) {
Yap_Error(SYSTEM_ERROR,t1,"cannot unhide an atom in use");
return(FALSE);
}
WRITE_LOCK(INVISIBLECHAIN.AERWLock);
chain = RepAtom(INVISIBLECHAIN.Entry);
old = NIL;
while (!EndOfPAEntr(chain) && strcmp(chain->StrOfAE, atom->StrOfAE) != 0) {
old = chain;
chain = RepAtom(chain->NextOfAE);
}
if (EndOfPAEntr(chain))
return (FALSE);
atom->PropsOfAE = chain->PropsOfAE;
if (old == NIL)
INVISIBLECHAIN.Entry = chain->NextOfAE;
else
old->NextOfAE = chain->NextOfAE;
WRITE_UNLOCK(INVISIBLECHAIN.AERWLock);
WRITE_UNLOCK(atom->ARWLock);
return (TRUE);
}
static Int
p_char_code( USES_REGS1 )
@ -1939,11 +2072,8 @@ init_current_wide_atom( USES_REGS1 )
void
Yap_InitBackAtoms(void)
{
Yap_InitCPredBack("$current_atom", 1, 2, init_current_atom, cont_current_atom,
SafePredFlag|SyncPredFlag);
Yap_InitCPredBack("$current_wide_atom", 1, 2, init_current_wide_atom,
cont_current_wide_atom,
SafePredFlag|SyncPredFlag);
Yap_InitCPredBack("$current_atom", 1, 2, init_current_atom, cont_current_atom,SafePredFlag|SyncPredFlag);
Yap_InitCPredBack("$current_wide_atom", 1, 2, init_current_wide_atom,cont_current_wide_atom,SafePredFlag|SyncPredFlag);
Yap_InitCPredBack("atom_concat", 3, 2, init_atom_concat3, cont_atom_concat3, 0);
Yap_InitCPredBack("string_concat", 3, 2, init_string_concat3, cont_string_concat3, 0);
Yap_InitCPredBack("sub_atom", 5, 5, init_sub_atom, cont_sub_atomic, 0);
@ -1982,4 +2112,8 @@ Yap_InitAtomPreds(void)
Yap_InitCPred("atomics_to_string", 2, p_atomics_to_string2, 0);
Yap_InitCPred("atomics_to_string", 3, p_atomics_to_string3, 0);
Yap_InitCPred("get_string_code", 3, p_get_string_code3, 0);
/* hiding and unhiding some predicates */
Yap_InitCPred("hide", 1, p_hide, SafePredFlag|SyncPredFlag);
Yap_InitCPred("unhide", 1, p_unhide, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$hidden", 1, p_hidden, SafePredFlag|SyncPredFlag);
}

View File

@ -325,6 +325,11 @@
* *
*************************************************************************/
/**
@file c_interface.c
*/
#define Bool int
#define flt double
#define C_INTERFACE
@ -351,7 +356,7 @@
#include "iopreds.h"
// we cannot consult YapInterface.h, that conflicts with what we declare, though
// it shouldn't
#include "yap_structs.h"
#include "YapInterface.h"
#define _yap_c_interface_h 1
#include "pl-shared.h"
#include "YapText.h"
@ -379,124 +384,8 @@
#define X_API __declspec(dllexport)
#endif
X_API Term YAP_A(int);
X_API Term YAP_Deref(Term);
X_API Term YAP_MkVarTerm(void);
X_API Bool YAP_IsVarTerm(Term);
X_API Bool YAP_IsNonVarTerm(Term);
X_API Bool YAP_IsIntTerm(Term);
X_API Bool YAP_IsLongIntTerm(Term);
X_API Bool YAP_IsBigNumTerm(Term);
X_API Bool YAP_IsNumberTerm(Term);
X_API Bool YAP_IsRationalTerm(Term);
X_API Bool YAP_IsFloatTerm(Term);
X_API Bool YAP_IsDbRefTerm(Term);
X_API Bool YAP_IsAtomTerm(Term);
X_API Bool YAP_IsPairTerm(Term);
X_API Bool YAP_IsApplTerm(Term);
X_API Bool YAP_IsCompoundTerm(Term);
X_API Bool YAP_IsExternalDataInStackTerm(Term);
X_API Bool YAP_IsOpaqueObjectTerm(Term, int);
X_API Term YAP_MkIntTerm(Int);
X_API Term YAP_MkBigNumTerm(void *);
X_API Term YAP_MkRationalTerm(void *);
X_API Int YAP_IntOfTerm(Term);
X_API void YAP_BigNumOfTerm(Term, void *);
X_API void YAP_RationalOfTerm(Term, void *);
X_API Term YAP_MkFloatTerm(flt);
X_API flt YAP_FloatOfTerm(Term);
X_API Term YAP_MkAtomTerm(Atom);
X_API Atom YAP_AtomOfTerm(Term);
X_API Atom YAP_LookupAtom(char *);
X_API Atom YAP_LookupWideAtom(wchar_t *);
X_API size_t YAP_AtomNameLength(Atom);
X_API Atom YAP_FullLookupAtom(char *);
X_API int YAP_IsWideAtom(Atom);
X_API char *YAP_AtomName(Atom);
X_API wchar_t *YAP_WideAtomName(Atom);
X_API Term YAP_MkPairTerm(Term,Term);
X_API Term YAP_MkListFromTerms(Term *,Int);
X_API Term YAP_MkNewPairTerm(void);
X_API Term YAP_HeadOfTerm(Term);
X_API Term YAP_TailOfTerm(Term);
X_API Int YAP_SkipList(Term *, Term **);
X_API Term YAP_MkApplTerm(Functor,UInt,Term *);
X_API Term YAP_MkNewApplTerm(Functor,UInt);
X_API Functor YAP_FunctorOfTerm(Term);
X_API Term YAP_ArgOfTerm(Int,Term);
X_API Term *YAP_ArgsOfTerm(Term);
X_API Functor YAP_MkFunctor(Atom,Int);
X_API Atom YAP_NameOfFunctor(Functor);
X_API Int YAP_ArityOfFunctor(Functor);
X_API void *YAP_ExtraSpace(void);
X_API void YAP_cut_up(void);
X_API Int YAP_Unify(Term,Term);
X_API int YAP_Unifiable(Term,Term);
X_API int YAP_Reset(void);
X_API Int YAP_ListLength(Term);
X_API Int YAP_Init(YAP_init_args *);
X_API Int YAP_FastInit(char *);
X_API PredEntry *YAP_FunctorToPred(Functor);
X_API PredEntry *YAP_AtomToPred(Atom);
X_API PredEntry *YAP_FunctorToPredInModule(Functor, Term);
X_API PredEntry *YAP_AtomToPredInModule(Atom, Term);
X_API Int YAP_CallProlog(Term);
X_API void *YAP_AllocSpaceFromYap(size_t);
X_API void *YAP_ReallocSpaceFromYap(void*,size_t);
X_API void YAP_FreeSpaceFromYap(void *);
X_API int YAP_StringToBuffer(Term, char *, unsigned int);
X_API Term YAP_ReadBuffer(char *,Term *);
X_API Term YAP_FloatsToList(double *, size_t);
X_API Int YAP_ListToFloats(Term, double *, size_t);
X_API Term YAP_IntsToList(Int *, size_t);
X_API Int YAP_ListToInts(Term, Int *, size_t);
X_API Term YAP_BufferToString(char *);
X_API Term YAP_NBufferToString(char *, size_t);
X_API Term YAP_WideBufferToString(wchar_t *);
X_API Term YAP_NWideBufferToString(wchar_t *, size_t);
X_API Term YAP_BufferToAtomList(char *);
X_API Term YAP_NBufferToAtomList(char *,size_t);
X_API Term YAP_WideBufferToAtomList(wchar_t *);
X_API Term YAP_NWideBufferToAtomList(wchar_t *, size_t);
X_API Term YAP_NWideBufferToAtomDiffList(wchar_t *, Term, size_t);
X_API Term YAP_BufferToDiffList(char *, Term);
X_API Term YAP_NBufferToDiffList(char *, Term, size_t);
X_API Term YAP_WideBufferToDiffList(wchar_t *, Term);
X_API Term YAP_NWideBufferToDiffList(wchar_t *, Term, size_t);
X_API void YAP_Error(int, Term, char *, ...);
X_API Int YAP_RunPredicate(PredEntry *, Term *);
X_API Int YAP_RunGoal(Term);
X_API Int YAP_RunGoalOnce(Term);
X_API int YAP_RestartGoal(void);
X_API int YAP_ShutdownGoal(int);
X_API int YAP_EnterGoal(PredEntry *, Term *, YAP_dogoalinfo *);
X_API int YAP_RetryGoal(YAP_dogoalinfo *);
X_API int YAP_LeaveGoal(int, YAP_dogoalinfo *);
X_API int YAP_GoalHasException(Term *);
X_API void YAP_ClearExceptions(void);
X_API int YAP_ContinueGoal(void);
X_API void YAP_PruneGoal(YAP_dogoalinfo *);
X_API IOSTREAM *YAP_TermToStream(Term);
X_API IOSTREAM *YAP_InitConsult(int, char *);
X_API void YAP_EndConsult(IOSTREAM *);
X_API Term YAP_Read(IOSTREAM *);
X_API void YAP_Write(Term, IOSTREAM *, int);
X_API Term YAP_CopyTerm(Term);
X_API int YAP_WriteBuffer(Term, char *, size_t, int);
X_API char *YAP_WriteDynamicBuffer(Term, char *, size_t, size_t *, int *, int);
X_API char *YAP_CompileClause(Term);
X_API void YAP_PutValue(Atom,Term);
X_API Term YAP_GetValue(Atom);
X_API int YAP_CompareTerms(Term,Term);
X_API void YAP_Exit(int);
X_API void YAP_InitSocks(char *, long);
X_API void YAP_SetOutputMessage(void);
X_API int YAP_StreamToFileNo(Term);
X_API void YAP_CloseAllOpenStreams(void);
X_API void YAP_FlushAllStreams(void);
/**
@group slotInterface Term Handles or Slots
@defgroup slotInterface Term Handles or Slots
@{
Term handles correspond to SWI-Prolog's term_t datatype: they are a safe representation
@ -518,130 +407,63 @@ For implementation details and more information, please check term_t_slots in th
/// @brief report the current position of the slots, assuming that they occupy the top of the stack.
///
///
X_API Int YAP_CurrentSlot(void);
X_API yhandle_t YAP_CurrentSlot(void);
/// @brief allocate n empty new slots
///
/// Return a handle to the system's default slot.
X_API Int YAP_NewSlots(int NumberOfSlots);
X_API yhandle_t YAP_NewSlots(int NumberOfSlots);
/// @brief allocate n empty new slots
///
/// Allocate _NumberOfSlots_ from the stack and return an handle to the
/// last one. The other handle can be obtained by decrementing the handle.
X_API Int YAP_InitSlot(YAP_Term t);
X_API yhandle_t YAP_InitSlot(YAP_Term t);
/// @brief read from a slot.
///
///
X_API YAP_Term YAP_GetFromSlot(YAP_Int slot);
X_API YAP_Term YAP_GetFromSlot(YAP_handle_t slot);
/// @brief get the memory address of a slot
///
/// Return the address of slot _slot_: please use with care.
X_API YAP_Term *YAP_AddressFromSlot(YAP_Int);
X_API YAP_Term *YAP_AddressFromSlot(YAP_handle_t);
/// @brief get the memory address of the term actually stored in a slot
///
///
X_API YAP_Term *YAP_AddressOfTermInSlot(YAP_Int);
X_API YAP_Term *YAP_AddressOfTermInSlot(YAP_handle_t);
/// @brief store term in a slot
///
///
X_API void YAP_PutInSlot(YAP_Int slot, YAP_Term t);
X_API void YAP_PutInSlot(YAP_handle_t slot, YAP_Term t);
/// @brief Succeeds if it recovers the space allocated for $n$ contiguous slots starting at topSlot.
///
/// Set the contents of slot _slot_ to _t_.
X_API int YAP_RecoverSlots(int, YAP_Int topSlot);
X_API int YAP_RecoverSlots(int, YAP_handle_t topSlot);
/// @brief copies the first new n YAAM registers to slots
///
/// Store the current first _HowMany_ arguments in new slots.
X_API YAP_Int YAP_ArgsToSlots(int HowMany);
X_API YAP_handle_t YAP_ArgsToSlots(int HowMany);
/// @brief copies n slots such that sl is copied to the last abstract ,achine register.
///
/// Set the first _HowMany_ arguments to the _HowMany_ slots
// starting at _slot_.
X_API void YAP_SlotsToArgs(int HowMany, YAP_Int slot);
X_API void YAP_SlotsToArgs(int HowMany, YAP_handle_t slot);
/// @}
X_API void YAP_Throw(Term);
X_API void YAP_AsyncThrow(Term);
X_API void YAP_Halt(int);
X_API Term *YAP_TopOfLocalStack(void);
X_API void *YAP_Predicate(Atom,UInt,Term);
X_API void YAP_PredicateInfo(void *,Atom *,UInt *,Term *);
X_API void YAP_UserCPredicate(char *,CPredicate,UInt);
X_API void YAP_UserBackCPredicate(char *,CPredicate,CPredicate,UInt,unsigned int);
X_API void YAP_UserCPredicateWithArgs(char *,CPredicate,UInt,Term);
X_API void YAP_UserBackCutCPredicate(char *,CPredicate,CPredicate,CPredicate,UInt,unsigned int);
X_API void *YAP_ExtraSpaceCut(void);
X_API Term YAP_SetCurrentModule(Term);
X_API Term YAP_CurrentModule(void);
X_API Term YAP_CreateModule(Atom);
X_API Term YAP_StripModule(Term, Term *);
X_API int YAP_ThreadSelf(void);
X_API int YAP_ThreadCreateEngine(struct thread_attr_struct *);
X_API int YAP_ThreadAttachEngine(int);
X_API int YAP_ThreadDetachEngine(int);
X_API int YAP_ThreadDestroyEngine(int);
X_API Term YAP_MkBlobTerm(unsigned int);
X_API void *YAP_BlobOfTerm(Term);
X_API Term YAP_TermNil(void);
X_API int YAP_IsTermNil(Term);
X_API int YAP_AtomGetHold(Atom);
X_API int YAP_AtomReleaseHold(Atom);
X_API Agc_hook YAP_AGCRegisterHook(Agc_hook);
X_API int YAP_HaltRegisterHook(HaltHookFunc, void *);
X_API char *YAP_cwd(void);
X_API Term YAP_OpenList(int);
X_API Term YAP_ExtendList(Term, Term);
X_API int YAP_CloseList(Term, Term);
X_API int YAP_IsAttVar(Term);
X_API Term YAP_AttsOfVar(Term);
X_API int YAP_FileNoFromStream(Term);
X_API void *YAP_FileDescriptorFromStream(Term);
X_API void *YAP_Record(Term);
X_API Term YAP_Recorded(void *);
X_API int YAP_Erase(void *);
X_API int YAP_Variant(Term, Term);
X_API Int YAP_NumberVars(Term, Int);
X_API Term YAP_UnNumberVars(Term);
X_API int YAP_IsNumberedVariable(Term);
X_API int YAP_ExactlyEqual(Term, Term);
X_API Int YAP_TermHash(Term, Int, Int, int);
X_API void YAP_signal(int);
X_API int YAP_SetYAPFlag(yap_flag_t, int);
X_API Int YAP_VarSlotToNumber(Int);
X_API Term YAP_ModuleUser(void);
X_API Int YAP_NumberOfClausesForPredicate(PredEntry *);
X_API int YAP_MaxOpPriority(Atom, Term);
X_API int YAP_OpInfo(Atom, Term, int, int *, int *);
X_API Term YAP_AllocExternalDataInStack(size_t);
X_API void *YAP_ExternalDataInStackFromTerm(Term);
X_API int YAP_NewOpaqueType(void *);
X_API Term YAP_NewOpaqueObject(int, size_t);
X_API void *YAP_OpaqueObjectFromTerm(Term);
X_API CELL *YAP_HeapStoreOpaqueTerm(Term t);
X_API int YAP_Argv(char *** argvp);
X_API YAP_tag_t YAP_TagOfTerm(Term);
X_API size_t YAP_ExportTerm(Term, char *, size_t);
X_API size_t YAP_SizeOfExportedTerm(char *);
X_API Term YAP_ImportTerm(char *);
X_API int YAP_RequiresExtraStack(size_t);
X_API Int YAP_AtomToInt(Atom At);
X_API Atom YAP_IntToAtom(Int i);
static UInt
static arity_t
current_arity(void)
{
CACHE_REGS
if (P && PREVOP(P,Osbpp)->opc == Yap_opcode(_call_usercpred)) {
return PREVOP(P,Osbpp)->u.Osbpp.p->ArityOfPE;
return PREVOP(P,Osbpp)->y_u.Osbpp.p->ArityOfPE;
} else {
return 0;
}
@ -654,7 +476,7 @@ doexpand(UInt sz)
UInt arity;
if (P && PREVOP(P,Osbpp)->opc == Yap_opcode(_call_usercpred)) {
arity = PREVOP(P,Osbpp)->u.Osbpp.p->ArityOfPE;
arity = PREVOP(P,Osbpp)->y_u.Osbpp.p->ArityOfPE;
} else {
arity = 0;
}
@ -671,12 +493,6 @@ YAP_A(int i)
return(Deref(XREGS[i]));
}
X_API Term
YAP_Deref(Term t)
{
return(Deref(t));
}
X_API Bool
YAP_IsIntTerm(Term t)
{
@ -813,16 +629,19 @@ YAP_MkBigNumTerm(void *big)
#endif /* USE_GMP */
}
X_API void
X_API int
YAP_BigNumOfTerm(Term t, void *b)
{
#if USE_GMP
MP_INT *bz = (MP_INT *)b;
if (IsVarTerm(t))
return;
return FALSE;
if (!IsBigIntTerm(t))
return;
return FALSE;
mpz_set(bz,Yap_BigIntOfTerm(t));
return TRUE;
#else
return FALSE;
#endif /* USE_GMP */
}
@ -840,16 +659,19 @@ YAP_MkRationalTerm(void *big)
#endif /* USE_GMP */
}
X_API void
X_API int
YAP_RationalOfTerm(Term t, void *b)
{
#if USE_GMP
MP_RAT *br = (MP_RAT *)b;
if (IsVarTerm(t))
return;
return FALSE;
if (!IsBigIntTerm(t))
return;
return FALSE;
mpq_set(br,Yap_BigRatOfTerm(t));
return TRUE;
#else
return FALSE;
#endif /* USE_GMP */
}
@ -935,29 +757,29 @@ YAP_IsWideAtom(Atom a)
return IsWideAtom(a);
}
X_API char *
X_API const char *
YAP_AtomName(Atom a)
{
char *o;
const char *o;
o = AtomName(a);
return(o);
}
X_API wchar_t *
X_API const wchar_t *
YAP_WideAtomName(Atom a)
{
return RepAtom(a)->WStrOfAE;
}
X_API Atom
YAP_LookupAtom(char *c)
YAP_LookupAtom(const char *c)
{
CACHE_REGS
Atom a;
while (TRUE) {
a = Yap_LookupAtom(c);
a = Yap_LookupAtom((char *)c);
LOCK(LOCAL_SignalLock);
if (a == NIL || Yap_has_signal(YAP_CDOVF_SIGNAL)) {
if (!Yap_locked_growheap(FALSE, 0, NULL)) {
@ -969,16 +791,17 @@ YAP_LookupAtom(char *c)
return a;
}
}
return NULL;
}
X_API Atom
YAP_LookupWideAtom(wchar_t *c)
YAP_LookupWideAtom(const wchar_t *c)
{
CACHE_REGS
Atom a;
while (TRUE) {
a = Yap_LookupWideAtom(c);
a = Yap_LookupWideAtom((wchar_t *)c);
LOCK(LOCAL_SignalLock);
if (a == NIL || Yap_has_signal(YAP_CDOVF_SIGNAL)) {
if (!Yap_locked_growheap(FALSE, 0, NULL)) {
@ -990,16 +813,17 @@ YAP_LookupWideAtom(wchar_t *c)
return a;
}
}
return NULL;
}
X_API Atom
YAP_FullLookupAtom(char *c)
YAP_FullLookupAtom(const char *c)
{
CACHE_REGS
Atom at;
while (TRUE) {
at = Yap_FullLookupAtom(c);
at = Yap_FullLookupAtom((char *)c);
LOCK(LOCAL_SignalLock);
if (at == NIL || Yap_has_signal(YAP_CDOVF_SIGNAL)) {
if (!Yap_locked_growheap(FALSE, 0, NULL)) {
@ -1011,6 +835,7 @@ YAP_FullLookupAtom(char *c)
return at;
}
}
return NULL;
}
X_API size_t
@ -1164,7 +989,7 @@ YAP_SkipList(Term *l, Term **tailp)
}
X_API Term
YAP_MkApplTerm(Functor f,UInt arity, Term args[])
YAP_MkApplTerm(Functor f, UInt arity, Term args[])
{
CACHE_REGS
Term t;
@ -1180,7 +1005,7 @@ YAP_MkApplTerm(Functor f,UInt arity, Term args[])
}
X_API Term
YAP_MkNewApplTerm(Functor f,UInt arity)
YAP_MkNewApplTerm(Functor f, UInt arity)
{
CACHE_REGS
Term t;
@ -1203,7 +1028,7 @@ YAP_FunctorOfTerm(Term t)
X_API Term
YAP_ArgOfTerm(Int n, Term t)
YAP_ArgOfTerm(UInt n, Term t)
{
return (ArgOfTerm(n, t));
}
@ -1219,7 +1044,7 @@ YAP_ArgsOfTerm(Term t)
}
X_API Functor
YAP_MkFunctor(Atom a, Int n)
YAP_MkFunctor(Atom a, UInt n)
{
return (Yap_MkFunctor(a, n));
}
@ -1230,7 +1055,7 @@ YAP_NameOfFunctor(Functor f)
return (NameOfFunctor(f));
}
X_API Int
X_API UInt
YAP_ArityOfFunctor(Functor f)
{
return (ArityOfFunctor(f));
@ -1243,7 +1068,7 @@ YAP_ExtraSpaceCut(void)
void *ptr;
BACKUP_B();
ptr = (void *)(((CELL *)(Yap_REGS.CUT_C_TOP))-(((yamop *)Yap_REGS.CUT_C_TOP->try_userc_cut_yamop)->u.OtapFs.extra));
ptr = (void *)(((CELL *)(Yap_REGS.CUT_C_TOP))-(((yamop *)Yap_REGS.CUT_C_TOP->try_userc_cut_yamop)->y_u.OtapFs.extra));
RECOVER_B();
return(ptr);
@ -1258,7 +1083,7 @@ YAP_ExtraSpace(void)
BACKUP_H();
/* find a pointer to extra space allocable */
ptr = (void *)((CELL *)(B+1)+P->u.OtapFs.s);
ptr = (void *)((CELL *)(B+1)+P->y_u.OtapFs.s);
B->cp_h = HR;
RECOVER_H();
@ -1309,7 +1134,7 @@ YAP_cut_up(void)
RECOVER_B();
}
X_API Int
X_API int
YAP_Unify(Term t1, Term t2)
{
Int out;
@ -1395,10 +1220,10 @@ YAP_InitSlot(Term t)
}
X_API int
YAP_RecoverSlots(int n, Int sl)
YAP_RecoverSlots(int n, Int top_slot)
{
CACHE_REGS
return Yap_RecoverSlots(n, sl PASS_REGS);
return Yap_RecoverSlots(n, top_slot PASS_REGS);
}
X_API Term
@ -1454,7 +1279,7 @@ typedef Int (*CPredicate9)(Int,Int,Int,Int,Int,Int,Int,Int,Int);
typedef Int (*CPredicate10)(Int,Int,Int,Int,Int,Int,Int,Int,Int,Int);
typedef Int (*CPredicateV)(Int,Int,struct foreign_context *);
static Int
static
execute_cargs(PredEntry *pe, CPredicate exec_code USES_REGS)
{
switch (pe->ArityOfPE) {
@ -1563,19 +1388,19 @@ execute_cargs(PredEntry *pe, CPredicate exec_code USES_REGS)
}
}
typedef Int (*CBPredicate)(struct foreign_context *);
typedef Int (*CBPredicate1)(Int,struct foreign_context *);
typedef Int (*CBPredicate2)(Int,Int,struct foreign_context *);
typedef Int (*CBPredicate3)(Int,Int,Int,struct foreign_context *);
typedef Int (*CBPredicate4)(Int,Int,Int,Int,struct foreign_context *);
typedef Int (*CBPredicate5)(Int,Int,Int,Int,Int,struct foreign_context *);
typedef Int (*CBPredicate6)(Int,Int,Int,Int,Int,Int,struct foreign_context *);
typedef Int (*CBPredicate7)(Int,Int,Int,Int,Int,Int,Int,struct foreign_context *);
typedef Int (*CBPredicate8)(Int,Int,Int,Int,Int,Int,Int,Int,struct foreign_context *);
typedef Int (*CBPredicate9)(Int,Int,Int,Int,Int,Int,Int,Int,Int,struct foreign_context *);
typedef Int (*CBPredicate10)(Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,struct foreign_context *);
typedef uintptr_t (*CBPredicate)(struct foreign_context *);
typedef uintptr_t (*CBPredicate1)(Int,struct foreign_context *);
typedef uintptr_t (*CBPredicate2)(Int,Int,struct foreign_context *);
typedef uintptr_t (*CBPredicate3)(Int,Int,Int,struct foreign_context *);
typedef uintptr_t (*CBPredicate4)(Int,Int,Int,Int,struct foreign_context *);
typedef uintptr_t (*CBPredicate5)(Int,Int,Int,Int,Int,struct foreign_context *);
typedef uintptr_t (*CBPredicate6)(Int,Int,Int,Int,Int,Int,struct foreign_context *);
typedef uintptr_t (*CBPredicate7)(Int,Int,Int,Int,Int,Int,Int,struct foreign_context *);
typedef uintptr_t (*CBPredicate8)(Int,Int,Int,Int,Int,Int,Int,Int,struct foreign_context *);
typedef uintptr_t (*CBPredicate9)(Int,Int,Int,Int,Int,Int,Int,Int,Int,struct foreign_context *);
typedef uintptr_t (*CBPredicate10)(Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,struct foreign_context *);
static Int
static uintptr_t
execute_cargs_back(PredEntry *pe, CPredicate exec_code, struct foreign_context *ctx USES_REGS)
{
switch (pe->ArityOfPE) {
@ -1593,9 +1418,10 @@ execute_cargs_back(PredEntry *pe, CPredicate exec_code, struct foreign_context *
case 2:
{
CBPredicate2 code2 = (CBPredicate2)exec_code;
return ((code2)(&B->cp_a1-LCL0,
uintptr_t val = ((code2)(&B->cp_a1-LCL0,
&B->cp_a2-LCL0,
ctx));
return val;
}
case 3:
{
@ -1694,7 +1520,7 @@ execute_cargs_back(PredEntry *pe, CPredicate exec_code, struct foreign_context *
}
}
static Int
static uintptr_t
complete_fail(choiceptr ptr, int has_cp USES_REGS)
{
// this case is easy, jut be sure to throw everything
@ -1707,7 +1533,7 @@ complete_fail(choiceptr ptr, int has_cp USES_REGS)
return FALSE;
}
static int
static uintptr_t
complete_exit(choiceptr ptr, int has_cp, int cut_all USES_REGS)
{
// the user often leaves open frames, especially in forward execution
@ -1807,8 +1633,8 @@ YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code)
CELL ocp = LCL0-(CELL *)B;
/* for slots to work */
Int CurSlot = Yap_StartSlots( PASS_REGS1 );
if (pe->PredFlags & (SWIEnvPredFlag|CArgsPredFlag)) {
Int val;
if (pe->PredFlags & (SWIEnvPredFlag|CArgsPredFlag|ModuleTransparentPredFlag)) {
uintptr_t val;
CPredicateV codev = (CPredicateV)exec_code;
struct foreign_context *ctx = (struct foreign_context *)(&EXTRA_CBACK_ARG(pe->ArityOfPE,1));
@ -1842,7 +1668,8 @@ YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code)
ctx->context = (uintptr_t)(val & ~REDO_PTR);
else
ctx->context = (uintptr_t)((val & ~REDO_PTR)>>FRG_REDO_BITS);
return TRUE;
/* fix dropped cps */
return complete_exit(((choiceptr)(LCL0-ocp)), FALSE, FALSE PASS_REGS);
}
} else {
Int ret = (exec_code)( PASS_REGS1 );
@ -1971,7 +1798,8 @@ YAP_ExecuteNext(PredEntry *pe, CPredicate exec_code)
else
ctx->context = (uintptr_t)((val & ~REDO_PTR)>>FRG_REDO_BITS);
}
return TRUE;
/* fix dropped cps */
return complete_exit(((choiceptr)(LCL0-ocp)), FALSE, FALSE PASS_REGS);
} else {
Int ret = (exec_code)( PASS_REGS1 );
LOCAL_CurSlot = CurSlot;
@ -2067,7 +1895,7 @@ YAP_StringToBuffer(Term t, char *buf, unsigned int bufsize)
/* copy a string to a buffer */
X_API Term
YAP_BufferToString(char *s)
YAP_BufferToString(const char *s)
{
Term t;
BACKUP_H();
@ -2087,7 +1915,7 @@ YAP_BufferToString(char *s)
/* copy a string to a buffer */
X_API Term
YAP_NBufferToString(char *s, size_t len)
YAP_NBufferToString(const char *s, size_t len)
{
Term t;
BACKUP_H();
@ -2109,7 +1937,7 @@ YAP_NBufferToString(char *s, size_t len)
/* copy a string to a buffer */
X_API Term
YAP_WideBufferToString(wchar_t *s)
YAP_WideBufferToString(const wchar_t *s)
{
Term t;
BACKUP_H();
@ -2129,7 +1957,7 @@ YAP_WideBufferToString(wchar_t *s)
/* copy a string to a buffer */
X_API Term
YAP_NWideBufferToString(wchar_t *s, size_t len)
YAP_NWideBufferToString(const wchar_t *s, size_t len)
{
Term t;
BACKUP_H();
@ -2151,7 +1979,7 @@ YAP_NWideBufferToString(wchar_t *s, size_t len)
/* copy a string to a buffer */
X_API Term
YAP_ReadBuffer(char *s, Term *tp)
YAP_ReadBuffer(const char *s, Term *tp)
{
CACHE_REGS
Int sl;
@ -2199,8 +2027,8 @@ YAP_ReadBuffer(char *s, Term *tp)
}
/* copy a string to a buffer */
X_API Term
YAP_BufferToAtomList(char *s)
X_API YAP_Term
YAP_BufferToAtomList(const char *s)
{
Term t;
BACKUP_H();
@ -2220,7 +2048,7 @@ YAP_BufferToAtomList(char *s)
/* copy a string of size len to a buffer */
X_API Term
YAP_NBufferToAtomList(char *s, size_t len)
YAP_NBufferToAtomList(const char *s, size_t len)
{
Term t;
BACKUP_H();
@ -2242,7 +2070,7 @@ YAP_NBufferToAtomList(char *s, size_t len)
/* copy a string to a buffer */
X_API Term
YAP_WideBufferToAtomList(wchar_t *s)
YAP_WideBufferToAtomList(const wchar_t *s)
{
Term t;
BACKUP_H();
@ -2262,7 +2090,7 @@ YAP_WideBufferToAtomList(wchar_t *s)
/* copy a string of size len to a buffer */
X_API Term
YAP_NWideBufferToAtomList(wchar_t *s, size_t len)
YAP_NWideBufferToAtomList(const wchar_t *s, size_t len)
{
Term t;
BACKUP_H();
@ -2284,7 +2112,7 @@ YAP_NWideBufferToAtomList(wchar_t *s, size_t len)
/* copy a string of size len to a buffer */
X_API Term
YAP_NWideBufferToAtomDiffList(wchar_t *s, Term t0, size_t len)
YAP_NWideBufferToAtomDiffList(const wchar_t *s, Term t0, size_t len)
{
Term t;
BACKUP_H();
@ -2307,7 +2135,7 @@ YAP_NWideBufferToAtomDiffList(wchar_t *s, Term t0, size_t len)
/* copy a string to a buffer */
X_API Term
YAP_BufferToDiffList(char *s, Term t0)
YAP_BufferToDiffList(const char *s, Term t0)
{
Term t;
BACKUP_H();
@ -2328,7 +2156,7 @@ YAP_BufferToDiffList(char *s, Term t0)
/* copy a string of size len to a buffer */
X_API Term
YAP_NBufferToDiffList(char *s, Term t0, size_t len)
YAP_NBufferToDiffList(const char *s, Term t0, size_t len)
{
Term t;
BACKUP_H();
@ -2351,7 +2179,7 @@ YAP_NBufferToDiffList(char *s, Term t0, size_t len)
/* copy a string to a buffer */
X_API Term
YAP_WideBufferToDiffList(wchar_t *s, Term t0)
YAP_WideBufferToDiffList(const wchar_t *s, Term t0)
{
Term t;
BACKUP_H();
@ -2372,7 +2200,7 @@ YAP_WideBufferToDiffList(wchar_t *s, Term t0)
/* copy a string of size len to a buffer */
X_API Term
YAP_NWideBufferToDiffList(wchar_t *s, Term t0, size_t len)
YAP_NWideBufferToDiffList(const wchar_t *s, Term t0, size_t len)
{
Term t;
BACKUP_H();
@ -2395,7 +2223,7 @@ YAP_NWideBufferToDiffList(wchar_t *s, Term t0, size_t len)
X_API void
YAP_Error(int myerrno, Term t, char *buf,...)
YAP_Error(int myerrno, Term t, const char *buf,...)
{
#define YAP_BUF_SIZE 512
va_list ap;
@ -2469,14 +2297,17 @@ YAP_EnterGoal(PredEntry *pe, Term *ptr, YAP_dogoalinfo *dgi)
dgi->cp = CP;
dgi->CurSlot = LOCAL_CurSlot;
// ensure our current ENV receives current P.
Yap_PrepGoal(pe->ArityOfPE, ptr, B PASS_REGS);
P = pe->CodeOfPred;
dgi->b = LCL0-(CELL*)B;
out = run_emulator(dgi PASS_REGS);
RECOVER_MACHINE_REGS();
if (out) {
LOCAL_CurSlot = dgi->CurSlot; // ignore any slots created within the called goal
dgi->EndSlot = LOCAL_CurSlot;
Yap_StartSlots( PASS_REGS1 );
} else {
LOCAL_CurSlot = dgi->CurSlot; // ignore any slots created within the called goal
}
return out;
}
@ -2498,7 +2329,7 @@ YAP_RetryGoal(YAP_dogoalinfo *dgi)
P = FAILCODE;
/* make sure we didn't leave live slots when we backtrack */
ASP = (CELL *)B;
LOCAL_CurSlot = dgi->CurSlot;
LOCAL_CurSlot = dgi->EndSlot;
out = run_emulator(dgi PASS_REGS);
RECOVER_MACHINE_REGS();
if (out) {
@ -2624,7 +2455,8 @@ YAP_ExternalDataInStackFromTerm(Term t)
return ExternalBlobFromTerm (t);
}
int YAP_NewOpaqueType(void *f)
X_API YAP_opaque_tag_t
YAP_NewOpaqueType(struct YAP_opaque_handler_struct *f)
{
int i;
if (!GLOBAL_OpaqueHandlers) {
@ -2642,7 +2474,7 @@ int YAP_NewOpaqueType(void *f)
return i+USER_BLOB_START;
}
Term YAP_NewOpaqueObject(int tag, size_t bytes)
Term YAP_NewOpaqueObject(YAP_opaque_tag_t tag, size_t bytes)
{
Term t = Yap_AllocExternalDataInStack((CELL)tag, bytes);
if (t == TermNil)
@ -2651,7 +2483,7 @@ Term YAP_NewOpaqueObject(int tag, size_t bytes)
}
X_API Bool
YAP_IsOpaqueObjectTerm(Term t, int tag)
YAP_IsOpaqueObjectTerm(Term t, YAP_opaque_tag_t tag)
{
return IsExternalBlobTerm(t, (CELL)tag);
}
@ -2875,7 +2707,7 @@ YAP_ClearExceptions(void)
}
X_API IOSTREAM *
YAP_InitConsult(int mode, char *filename)
YAP_InitConsult(int mode, const char *filename)
{
IOSTREAM *st;
BACKUP_MACHINE_REGS();
@ -3291,7 +3123,7 @@ YAP_Init(YAP_init_args *yap_init)
} else {
GLOBAL_AllowTrailExpansion = TRUE;
}
if (yap_init->YapPrologRCFile) {
if (yap_init->YapPrologRCFile) {
Yap_PutValue(AtomConsultOnBoot, MkAtomTerm(Yap_LookupAtom(yap_init->YapPrologRCFile)));
/*
This must be done again after restore, as yap_flags
@ -3326,7 +3158,7 @@ YAP_Init(YAP_init_args *yap_init)
if (restore_result == DO_ONLY_CODE) {
/* first, initialise the saved state */
Term t_goal = MkAtomTerm(AtomInitProlog);
YAP_RunGoalOnce(t_goal);
YAP_RunGoalOnce(t_goal);
Yap_InitYaamRegs( 0 );
return YAP_BOOT_FROM_SAVED_CODE;
} else {
@ -3475,9 +3307,10 @@ YAP_Exit(int retval)
Yap_exit(retval);
}
X_API void
YAP_InitSocks(char *host, long port)
X_API int
YAP_InitSocks(const char *host, long port)
{
return 0;
}
X_API void
@ -3575,13 +3408,13 @@ YAP_PredicateInfo(void *p, Atom* a, UInt* arity, Term* m)
}
X_API void
YAP_UserCPredicate(char *name, CPredicate def, UInt arity)
YAP_UserCPredicate(const char *name, CPredicate def, UInt arity)
{
Yap_InitCPred(name, arity, def, UserCPredFlag);
}
X_API void
YAP_UserBackCPredicate(char *name, CPredicate init, CPredicate cont,
YAP_UserBackCPredicate(const char *name, CPredicate init, CPredicate cont,
UInt arity, unsigned int extra)
{
Yap_InitCPredBackCut(name, arity, extra, init, cont, NULL ,UserCPredFlag);
@ -3589,14 +3422,14 @@ YAP_UserBackCPredicate(char *name, CPredicate init, CPredicate cont,
}
X_API void
YAP_UserBackCutCPredicate(char *name, CPredicate init, CPredicate cont, CPredicate cut,
YAP_UserBackCutCPredicate(const char *name, CPredicate init, CPredicate cont, CPredicate cut,
UInt arity, unsigned int extra)
{
Yap_InitCPredBackCut(name, arity, extra, init, cont, cut, UserCPredFlag);
}
X_API void
YAP_UserCPredicateWithArgs(char *a, CPredicate f, UInt arity, Term mod)
YAP_UserCPredicateWithArgs(const char *a, CPredicate f, UInt arity, Term mod)
{
CACHE_REGS
PredEntry *pe;
@ -3658,7 +3491,7 @@ YAP_ThreadSelf(void)
}
X_API int
YAP_ThreadCreateEngine(struct thread_attr_struct * attr)
YAP_ThreadCreateEngine(struct YAP_thread_attr_struct * attr)
{
#if THREADS
return Yap_thread_create_engine(attr);
@ -3739,7 +3572,7 @@ X_API char *
YAP_cwd(void)
{
CACHE_REGS
char *buf;
char *buf = NULL;
int len;
if (!Yap_getcwd(LOCAL_FileNameBuf, YAP_FILENAME_MAX))
return FALSE;
@ -4053,11 +3886,11 @@ YAP_Erase(void *handle)
return 1;
}
X_API Int
X_API yhandle_t
YAP_ArgsToSlots(int n)
{
CACHE_REGS
Int slot = Yap_NewSlots(n PASS_REGS);
yhandle_t slot = Yap_NewSlots(n PASS_REGS);
CELL *ptr0 = LCL0+slot, *ptr1=&ARG1;
while (n--) {
*ptr0++ = *ptr1++;
@ -4066,7 +3899,7 @@ YAP_ArgsToSlots(int n)
}
X_API void
YAP_SlotsToArgs(int n, Int slot)
YAP_SlotsToArgs(int n, yhandle_t slot)
{
CACHE_REGS
CELL *ptr0 = LCL0+slot, *ptr1=&ARG1;
@ -4108,8 +3941,8 @@ YAP_SetYAPFlag(yap_flag_t flag, int val)
}
/* Int YAP_VarSlotToNumber(Int) */
Int YAP_VarSlotToNumber(Int s) {
/* yhandle_t YAP_VarSlotToNumber(yhandle_t) */
yhandle_t YAP_VarSlotToNumber(yhandle_t s) {
CACHE_REGS
Term *t = (CELL *)Deref(Yap_GetFromSlot(s PASS_REGS));
if (t < HR)
@ -4123,7 +3956,7 @@ Term YAP_ModuleUser(void) {
}
/* int YAP_PredicateHasClauses() */
Int YAP_NumberOfClausesForPredicate(PredEntry *pe) {
yhandle_t YAP_NumberOfClausesForPredicate(PredEntry *pe) {
return pe->cs.p_code.NOfClauses;
}

274
C/cdmgr.c
View File

@ -537,14 +537,14 @@ PredForChoicePt(yamop *p_code) {
case _Nstop:
return NULL;
case _jump:
p_code = p_code->u.l.l;
p_code = p_code->y_u.l.l;
break;
case _retry_me:
case _trust_me:
return p_code->u.Otapl.p;
return p_code->y_u.Otapl.p;
case _retry_exo:
case _retry_all_exo:
return p_code->u.lp.p;
return p_code->y_u.lp.p;
case _try_logical:
case _retry_logical:
case _trust_logical:
@ -552,7 +552,7 @@ PredForChoicePt(yamop *p_code) {
case _count_trust_logical:
case _profiled_retry_logical:
case _profiled_trust_logical:
return p_code->u.OtaLl.d->ClPred;
return p_code->y_u.OtaLl.d->ClPred;
#ifdef TABLING
case _trie_trust_var:
case _trie_retry_var:
@ -596,19 +596,19 @@ PredForChoicePt(yamop *p_code) {
/* compile error --> return ENV_ToP(gc_B->cp_cp); */
#endif /* TABLING */
case _or_else:
if (p_code == p_code->u.Osblp.l) {
if (p_code == p_code->y_u.Osblp.l) {
/* repeat */
Atom at = AtomRepeatSpace;
return RepPredProp(PredPropByAtom(at, PROLOG_MODULE));
} else {
return p_code->u.Osblp.p0;
return p_code->y_u.Osblp.p0;
}
break;
case _or_last:
#ifdef YAPOR
return p_code->u.Osblp.p0;
return p_code->y_u.Osblp.p0;
#else
return p_code->u.p.p;
return p_code->y_u.p.p;
#endif /* YAPOR */
break;
case _count_retry_me:
@ -619,7 +619,7 @@ PredForChoicePt(yamop *p_code) {
p_code = NEXTOP(p_code,l);
break;
default:
return p_code->u.Otapl.p;
return p_code->y_u.Otapl.p;
}
}
return NULL;
@ -1040,7 +1040,7 @@ Yap_IPred(PredEntry *p, UInt NSlots, yamop *next_pc)
IPred(p, NSlots, next_pc);
}
#define GONEXT(TYPE) code_p = ((yamop *)(&(code_p->u.TYPE.next)))
#define GONEXT(TYPE) code_p = ((yamop *)(&(code_p->y_u.TYPE.next)))
static void
RemoveMainIndex(PredEntry *ap)
@ -1097,29 +1097,29 @@ static yamop *
release_wcls(yamop *cop, OPCODE ecs)
{
if (cop->opc == ecs) {
cop->u.sssllp.s3--;
if (!cop->u.sssllp.s3) {
UInt sz = (UInt)NEXTOP((yamop *)NULL,sssllp)+cop->u.sssllp.s1*sizeof(yamop *);
cop->y_u.sssllp.s3--;
if (!cop->y_u.sssllp.s3) {
UInt sz = (UInt)NEXTOP((yamop *)NULL,sssllp)+cop->y_u.sssllp.s1*sizeof(yamop *);
LOCK(ExpandClausesListLock);
#ifdef DEBUG
Yap_expand_clauses_sz -= sz;
Yap_ExpandClauses--;
#endif
if (cop->u.sssllp.p->PredFlags & LogUpdatePredFlag) {
if (cop->y_u.sssllp.p->PredFlags & LogUpdatePredFlag) {
Yap_LUIndexSpace_EXT -= sz;
} else {
Yap_IndexSpace_EXT -= sz;
}
if (ExpandClausesFirst == cop)
ExpandClausesFirst = cop->u.sssllp.snext;
ExpandClausesFirst = cop->y_u.sssllp.snext;
if (ExpandClausesLast == cop) {
ExpandClausesLast = cop->u.sssllp.sprev;
ExpandClausesLast = cop->y_u.sssllp.sprev;
}
if (cop->u.sssllp.sprev) {
cop->u.sssllp.sprev->u.sssllp.snext = cop->u.sssllp.snext;
if (cop->y_u.sssllp.sprev) {
cop->y_u.sssllp.sprev->y_u.sssllp.snext = cop->y_u.sssllp.snext;
}
if (cop->u.sssllp.snext) {
cop->u.sssllp.snext->u.sssllp.sprev = cop->u.sssllp.sprev;
if (cop->y_u.sssllp.snext) {
cop->y_u.sssllp.snext->y_u.sssllp.sprev = cop->y_u.sssllp.sprev;
}
UNLOCK(ExpandClausesListLock);
Yap_InformOfRemoval(cop);
@ -1163,12 +1163,12 @@ cleanup_dangling_indices(yamop *ipc, yamop *beg, yamop *end, yamop *suspend_code
case _retry2:
case _retry3:
case _retry4:
decrease_ref_counter(ipc->u.l.l, beg, end, suspend_code);
decrease_ref_counter(ipc->y_u.l.l, beg, end, suspend_code);
ipc = NEXTOP(ipc,l);
break;
case _retry:
case _trust:
decrease_ref_counter(ipc->u.Otapl.d, beg, end, suspend_code);
decrease_ref_counter(ipc->y_u.Otapl.d, beg, end, suspend_code);
ipc = NEXTOP(ipc,Otapl);
break;
case _try_clause:
@ -1185,8 +1185,8 @@ cleanup_dangling_indices(yamop *ipc, yamop *beg, yamop *end, yamop *suspend_code
case _profiled_retry_logical:
{
yamop *oipc = ipc;
decrease_ref_counter(ipc->u.OtaLl.d->ClCode, beg, end, suspend_code);
ipc = ipc->u.OtaLl.n;
decrease_ref_counter(ipc->y_u.OtaLl.d->ClCode, beg, end, suspend_code);
ipc = ipc->y_u.OtaLl.n;
Yap_LUIndexSpace_CP -= (UInt)NEXTOP((yamop *)NULL,OtaLl);
Yap_FreeCodeSpace((ADDR)oipc);
#ifdef DEBUG
@ -1202,35 +1202,35 @@ cleanup_dangling_indices(yamop *ipc, yamop *beg, yamop *end, yamop *suspend_code
Yap_DirtyCps--;
Yap_FreedCps++;
#endif
decrease_ref_counter(ipc->u.OtILl.d->ClCode, beg, end, suspend_code);
decrease_ref_counter(ipc->y_u.OtILl.d->ClCode, beg, end, suspend_code);
Yap_LUIndexSpace_CP -= (UInt)NEXTOP((yamop *)NULL,OtILl);
Yap_FreeCodeSpace((ADDR)ipc);
return;
case _enter_lu_pred:
{
yamop *oipc = ipc;
if (ipc->u.Illss.I->ClFlags & InUseMask || ipc->u.Illss.I->ClRefCount)
if (ipc->y_u.Illss.I->ClFlags & InUseMask || ipc->y_u.Illss.I->ClRefCount)
return;
#ifdef DEBUG
Yap_DirtyCps+=ipc->u.Illss.s;
Yap_LiveCps-=ipc->u.Illss.s;
Yap_DirtyCps+=ipc->y_u.Illss.s;
Yap_LiveCps-=ipc->y_u.Illss.s;
#endif
ipc = ipc->u.Illss.l1;
ipc = ipc->y_u.Illss.l1;
/* in case we visit again */
oipc->u.Illss.l1 = FAILCODE;
oipc->u.Illss.s = 0;
oipc->u.Illss.e = 0;
oipc->y_u.Illss.l1 = FAILCODE;
oipc->y_u.Illss.s = 0;
oipc->y_u.Illss.e = 0;
}
break;
case _try_in:
case _jump:
case _jump_if_var:
ipc->u.l.l = release_wcls(ipc->u.l.l, ecs);
ipc->y_u.l.l = release_wcls(ipc->y_u.l.l, ecs);
ipc = NEXTOP(ipc,l);
break;
/* instructions type xl */
case _jump_if_nonvar:
ipc->u.xll.l1 = release_wcls(ipc->u.xll.l1, ecs);
ipc->y_u.xll.l1 = release_wcls(ipc->y_u.xll.l1, ecs);
ipc = NEXTOP(ipc,xll);
break;
/* instructions type p */
@ -1239,31 +1239,31 @@ cleanup_dangling_indices(yamop *ipc, yamop *beg, yamop *end, yamop *suspend_code
break;
/* instructions type e */
case _switch_on_type:
ipc->u.llll.l1 = release_wcls(ipc->u.llll.l1, ecs);
ipc->u.llll.l2 = release_wcls(ipc->u.llll.l2, ecs);
ipc->u.llll.l3 = release_wcls(ipc->u.llll.l3, ecs);
ipc->u.llll.l4 = release_wcls(ipc->u.llll.l4, ecs);
ipc->y_u.llll.l1 = release_wcls(ipc->y_u.llll.l1, ecs);
ipc->y_u.llll.l2 = release_wcls(ipc->y_u.llll.l2, ecs);
ipc->y_u.llll.l3 = release_wcls(ipc->y_u.llll.l3, ecs);
ipc->y_u.llll.l4 = release_wcls(ipc->y_u.llll.l4, ecs);
ipc = NEXTOP(ipc,llll);
break;
case _switch_list_nl:
ipc->u.ollll.l1 = release_wcls(ipc->u.ollll.l1, ecs);
ipc->u.ollll.l2 = release_wcls(ipc->u.ollll.l2, ecs);
ipc->u.ollll.l3 = release_wcls(ipc->u.ollll.l3, ecs);
ipc->u.ollll.l4 = release_wcls(ipc->u.ollll.l4, ecs);
ipc->y_u.ollll.l1 = release_wcls(ipc->y_u.ollll.l1, ecs);
ipc->y_u.ollll.l2 = release_wcls(ipc->y_u.ollll.l2, ecs);
ipc->y_u.ollll.l3 = release_wcls(ipc->y_u.ollll.l3, ecs);
ipc->y_u.ollll.l4 = release_wcls(ipc->y_u.ollll.l4, ecs);
ipc = NEXTOP(ipc,ollll);
break;
case _switch_on_arg_type:
ipc->u.xllll.l1 = release_wcls(ipc->u.xllll.l1, ecs);
ipc->u.xllll.l2 = release_wcls(ipc->u.xllll.l2, ecs);
ipc->u.xllll.l3 = release_wcls(ipc->u.xllll.l3, ecs);
ipc->u.xllll.l4 = release_wcls(ipc->u.xllll.l4, ecs);
ipc->y_u.xllll.l1 = release_wcls(ipc->y_u.xllll.l1, ecs);
ipc->y_u.xllll.l2 = release_wcls(ipc->y_u.xllll.l2, ecs);
ipc->y_u.xllll.l3 = release_wcls(ipc->y_u.xllll.l3, ecs);
ipc->y_u.xllll.l4 = release_wcls(ipc->y_u.xllll.l4, ecs);
ipc = NEXTOP(ipc,xllll);
break;
case _switch_on_sub_arg_type:
ipc->u.sllll.l1 = release_wcls(ipc->u.sllll.l1, ecs);
ipc->u.sllll.l2 = release_wcls(ipc->u.sllll.l2, ecs);
ipc->u.sllll.l3 = release_wcls(ipc->u.sllll.l3, ecs);
ipc->u.sllll.l4 = release_wcls(ipc->u.sllll.l4, ecs);
ipc->y_u.sllll.l1 = release_wcls(ipc->y_u.sllll.l1, ecs);
ipc->y_u.sllll.l2 = release_wcls(ipc->y_u.sllll.l2, ecs);
ipc->y_u.sllll.l3 = release_wcls(ipc->y_u.sllll.l3, ecs);
ipc->y_u.sllll.l4 = release_wcls(ipc->y_u.sllll.l4, ecs);
ipc = NEXTOP(ipc,sllll);
break;
case _if_not_then:
@ -1276,7 +1276,7 @@ cleanup_dangling_indices(yamop *ipc, yamop *beg, yamop *end, yamop *suspend_code
case _if_cons:
case _go_on_cons:
/* make sure we don't leave dangling references to memory that is going to be removed */
ipc->u.sssl.l = NULL;
ipc->y_u.sssl.l = NULL;
ipc = NEXTOP(ipc,sssl);
break;
case _op_fail:
@ -1755,9 +1755,9 @@ add_first_dynamic(PredEntry *p, yamop *cp, int spy_flag)
p->OpcodeOfPred = ncp->opc = Yap_opcode(_spy_or_trymark);
else
p->OpcodeOfPred = ncp->opc = Yap_opcode(_try_and_mark);
ncp->u.Otapl.s = p->ArityOfPE;
ncp->u.Otapl.p = p;
ncp->u.Otapl.d = cp;
ncp->y_u.Otapl.s = p->ArityOfPE;
ncp->y_u.Otapl.p = p;
ncp->y_u.Otapl.d = cp;
/* This is the point we enter the code */
p->cs.p_code.TrueCodeOfPred = p->CodeOfPred = ncp;
p->cs.p_code.NOfClauses = 1;
@ -1777,9 +1777,9 @@ add_first_dynamic(PredEntry *p, yamop *cp, int spy_flag)
cp->opc = Yap_opcode(_count_retry_and_mark);
else
cp->opc = Yap_opcode(_retry_and_mark);
cp->u.Otapl.s = p->ArityOfPE;
cp->u.Otapl.p = p;
cp->u.Otapl.d = ncp;
cp->y_u.Otapl.s = p->ArityOfPE;
cp->y_u.Otapl.p = p;
cp->y_u.Otapl.d = ncp;
/* also, keep a backpointer for the days you delete the clause */
ClauseCodeToDynamicClause(cp)->ClPrevious = ncp;
/* Don't forget to say who is the only clause for the predicate so
@ -1796,7 +1796,7 @@ add_first_dynamic(PredEntry *p, yamop *cp, int spy_flag)
/* and close the code */
ncp = NEXTOP(ncp,e);
ncp->opc = Yap_opcode(_Ystop);
ncp->u.l.l = cl->ClCode;
ncp->y_u.l.l = cl->ClCode;
}
/* p is already locked */
@ -1840,7 +1840,7 @@ asserta_stat_clause(PredEntry *p, yamop *q, int spy_flag)
p->OpcodeOfPred = INDEX_OPCODE;
p->CodeOfPred = (yamop *)(&(p->OpcodeOfPred));
}
p->cs.p_code.LastClause->u.Otapl.d = q;
p->cs.p_code.LastClause->y_u.Otapl.d = q;
}
/* p is already locked */
@ -1856,22 +1856,22 @@ asserta_dynam_clause(PredEntry *p, yamop *cp)
cl->ClPrevious = (yamop *)(p->CodeOfPred);
cl->ClFlags |= DynamicMask;
UNLOCK(ClauseCodeToDynamicClause(p->cs.p_code.FirstClause)->ClLock);
q->u.Otapl.d = p->cs.p_code.FirstClause;
q->u.Otapl.s = p->ArityOfPE;
q->u.Otapl.p = p;
q->y_u.Otapl.d = p->cs.p_code.FirstClause;
q->y_u.Otapl.s = p->ArityOfPE;
q->y_u.Otapl.p = p;
if (p->PredFlags & ProfiledPredFlag)
cp->opc = Yap_opcode(_profiled_retry_and_mark);
else if (p->PredFlags & CountPredFlag)
cp->opc = Yap_opcode(_count_retry_and_mark);
else
cp->opc = Yap_opcode(_retry_and_mark);
cp->u.Otapl.s = p->ArityOfPE;
cp->u.Otapl.p = p;
cp->y_u.Otapl.s = p->ArityOfPE;
cp->y_u.Otapl.p = p;
p->cs.p_code.FirstClause = cp;
q = p->CodeOfPred;
q->u.Otapl.d = cp;
q->u.Otapl.s = p->ArityOfPE;
q->u.Otapl.p = p;
q->y_u.Otapl.d = cp;
q->y_u.Otapl.s = p->ArityOfPE;
q->y_u.Otapl.p = p;
}
@ -1931,7 +1931,7 @@ assertz_dynam_clause(PredEntry *p, yamop *cp)
q = p->cs.p_code.LastClause;
LOCK(ClauseCodeToDynamicClause(q)->ClLock);
q->u.Otapl.d = cp;
q->y_u.Otapl.d = cp;
p->cs.p_code.LastClause = cp;
/* also, keep backpointers for the days we'll delete all the clause */
cl->ClPrevious = q;
@ -1944,9 +1944,9 @@ assertz_dynam_clause(PredEntry *p, yamop *cp)
q->opc = Yap_opcode(_count_retry_and_mark);
else
q->opc = Yap_opcode(_retry_and_mark);
q->u.Otapl.d = p->CodeOfPred;
q->u.Otapl.s = p->ArityOfPE;
q->u.Otapl.p = p;
q->y_u.Otapl.d = p->CodeOfPred;
q->y_u.Otapl.s = p->ArityOfPE;
q->y_u.Otapl.p = p;
p->cs.p_code.NOfClauses++;
}
@ -2335,7 +2335,7 @@ addclause(Term t, yamop *cp, int mode, Term mod, Term *t4ref)
mod != TermProlog && mod)
)
) {
printf("p=%p p->PredFlags=%lx %lx p->cs.p_code.NOfClauses=%ld\n", p, p->PredFlags,SysExportPredFlag , p->cs.p_code.NOfClauses);
//printf("p=%p p->PredFlags=%lx %lx p->cs.p_code.NOfClauses=%ld\n", p, p->PredFlags,SysExportPredFlag , p->cs.p_code.NOfClauses);
addcl_permission_error(RepAtom(at), Arity, FALSE);
UNLOCKPE(30,p);
return TermNil;
@ -2671,7 +2671,7 @@ Yap_ConsultingFile ( USES_REGS1 )
/* consult file *file*, *mode* may be one of either consult or reconsult */
static void
init_consult(int mode, char *file)
init_consult(int mode, const char *file)
{
CACHE_REGS
if (!LOCAL_ConsultSp) {
@ -2693,7 +2693,7 @@ init_consult(int mode, char *file)
}
void
Yap_init_consult(int mode, char *file)
Yap_init_consult(int mode, const char *file)
{
init_consult(mode,file);
}
@ -3174,6 +3174,21 @@ p_is_discontiguous( USES_REGS1 )
return(out);
}
static Int
p_is_thread_local( USES_REGS1 )
{ /* '$is_dynamic'(+P) */
PredEntry *pe;
Int out;
pe = get_pred(Deref(ARG1), Deref(ARG2), "$is_log_updatable");
if (EndOfPAEntr(pe))
return FALSE;
PELOCK(27,pe);
out = (pe->PredFlags & ThreadLocalPredFlag);
UNLOCKPE(45,pe);
return(out);
}
static Int
p_is_log_updatable( USES_REGS1 )
{ /* '$is_dynamic'(+P) */
@ -3553,16 +3568,16 @@ search_for_static_predicate_in_use(PredEntry *p, int check_everything)
if (p->PredFlags & LogUpdatePredFlag) {
LogUpdIndex *cl = ClauseCodeToLogUpdIndex(code_beg);
if (find_owner_log_index(cl, code_p))
b_ptr->cp_ap = cur_log_upd_clause(pe, b_ptr->cp_ap->u.Otapl.d);
b_ptr->cp_ap = cur_log_upd_clause(pe, b_ptr->cp_ap->y_u.Otapl.d);
} else if (p->PredFlags & MegaClausePredFlag) {
StaticIndex *cl = ClauseCodeToStaticIndex(code_beg);
if (find_owner_static_index(cl, code_p))
b_ptr->cp_ap = cur_clause(pe, b_ptr->cp_ap->u.Otapl.d);
b_ptr->cp_ap = cur_clause(pe, b_ptr->cp_ap->y_u.Otapl.d);
} else {
/* static clause */
StaticIndex *cl = ClauseCodeToStaticIndex(code_beg);
if (find_owner_static_index(cl, code_p)) {
b_ptr->cp_ap = cur_clause(pe, b_ptr->cp_ap->u.Otapl.d);
b_ptr->cp_ap = cur_clause(pe, b_ptr->cp_ap->y_u.Otapl.d);
}
}
}
@ -4151,7 +4166,7 @@ found_idb_clause(yamop *pc, CODEADDR *startp, CODEADDR *endp)
static PredEntry *
found_expand_index(yamop *pc, CODEADDR *startp, CODEADDR *endp, yamop *codeptr USES_REGS)
{
PredEntry *pp = codeptr->u.sssllp.p;
PredEntry *pp = codeptr->y_u.sssllp.p;
if (pc == codeptr) {
*startp = (CODEADDR)codeptr;
*endp = (CODEADDR)NEXTOP(codeptr,sssllp);
@ -4199,30 +4214,30 @@ found_ystop(yamop *pc, int clause_code, CODEADDR *startp, CODEADDR *endp, PredEn
}
if (!pp) {
/* must be an index */
PredEntry **pep = (PredEntry **)pc->u.l.l;
PredEntry **pep = (PredEntry **)pc->y_u.l.l;
pp = pep[-1];
}
if (pp->PredFlags & LogUpdatePredFlag) {
if (clause_code) {
LogUpdClause *cl = ClauseCodeToLogUpdClause(pc->u.l.l);
LogUpdClause *cl = ClauseCodeToLogUpdClause(pc->y_u.l.l);
*startp = (CODEADDR)cl;
*endp = (CODEADDR)cl+cl->ClSize;
} else {
LogUpdIndex *cl = ClauseCodeToLogUpdIndex(pc->u.l.l);
LogUpdIndex *cl = ClauseCodeToLogUpdIndex(pc->y_u.l.l);
*startp = (CODEADDR)cl;
*endp = (CODEADDR)cl+cl->ClSize;
}
} else if (pp->PredFlags & DynamicPredFlag) {
DynamicClause *cl = ClauseCodeToDynamicClause(pc->u.l.l);
DynamicClause *cl = ClauseCodeToDynamicClause(pc->y_u.l.l);
*startp = (CODEADDR)cl;
*endp = (CODEADDR)cl+cl->ClSize;
} else {
if (clause_code) {
StaticClause *cl = ClauseCodeToStaticClause(pc->u.l.l);
StaticClause *cl = ClauseCodeToStaticClause(pc->y_u.l.l);
*startp = (CODEADDR)cl;
*endp = (CODEADDR)cl+cl->ClSize;
} else {
StaticIndex *cl = ClauseCodeToStaticIndex(pc->u.l.l);
StaticIndex *cl = ClauseCodeToStaticIndex(pc->y_u.l.l);
*startp = (CODEADDR)cl;
*endp = (CODEADDR)cl+cl->ClSize;
}
@ -4311,7 +4326,7 @@ p_is_profiled( USES_REGS1 )
if (PROFILING) ta = MkAtomTerm(AtomOn);
else ta = MkAtomTerm(AtomOff);
Bind((CELL *)t,ta);
YapBind((CELL *)t,ta);
return(TRUE);
} else if (!IsAtomTerm(t)) return(FALSE);
s = RepAtom(AtomOfTerm(t))->StrOfAE;
@ -4409,7 +4424,7 @@ p_is_call_counted( USES_REGS1 )
if (CALL_COUNTING) ta = MkAtomTerm(AtomOn);
else ta = MkAtomTerm(AtomOff);
Bind((CELL *)t,ta);
YapBind((CELL *)t,ta);
return(TRUE);
} else if (!IsAtomTerm(t)) return(FALSE);
s = RepAtom(AtomOfTerm(t))->StrOfAE;
@ -5150,7 +5165,7 @@ Yap_UpdateTimestamps(PredEntry *ap)
case _trust_logical:
case _count_trust_logical:
case _profiled_trust_logical:
if (bptr->cp_ap->u.OtaLl.d->ClPred == ap) {
if (bptr->cp_ap->y_u.OtaLl.d->ClPred == ap) {
UInt ts = IntegerOfTerm(bptr->cp_args[ar]);
if (ts != arp[0]) {
if (arp-HR < 1024) {
@ -5214,7 +5229,7 @@ Yap_UpdateTimestamps(PredEntry *ap)
case _trust_logical:
case _count_trust_logical:
case _profiled_trust_logical:
if (bptr->cp_ap->u.OtaLl.d->ClPred == ap) {
if (bptr->cp_ap->y_u.OtaLl.d->ClPred == ap) {
UInt ts = IntegerOfTerm(bptr->cp_args[ar]);
while (ts != arp[0])
arp--;
@ -5579,9 +5594,9 @@ index_ssz(StaticIndex *x, PredEntry *pe)
}
/* expand clause blocks */
while (ep) {
if (ep->u.sssllp.p == pe)
sz += (UInt)NEXTOP((yamop *)NULL,sssllp)+ep->u.sssllp.s1*sizeof(yamop *);
ep = ep->u.sssllp.snext;
if (ep->y_u.sssllp.p == pe)
sz += (UInt)NEXTOP((yamop *)NULL,sssllp)+ep->y_u.sssllp.s1*sizeof(yamop *);
ep = ep->y_u.sssllp.snext;
}
/* main indexing tree */
sz += tree_index_ssz(x);
@ -5787,7 +5802,7 @@ p_env_info( USES_REGS1 )
env_b = MkIntegerTerm((Int)(LCL0-(CELL *)env[E_CB]));
env_cp = (yamop *)env[E_CP];
/* pe = PREVOP(env_cp,Osbpp)->u.Osbpp.p0; */
/* pe = PREVOP(env_cp,Osbpp)->y_u.Osbpp.p0; */
taddr = MkIntegerTerm((Int)env);
return Yap_unify(ARG3,MkIntegerTerm((Int)env_cp)) &&
Yap_unify(ARG2, taddr) &&
@ -5800,7 +5815,7 @@ p_cpc_info( USES_REGS1 )
PredEntry *pe;
yamop *ipc = (yamop *)IntegerOfTerm(Deref(ARG1));
pe = PREVOP(ipc,Osbpp)->u.Osbpp.p0;
pe = PREVOP(ipc,Osbpp)->y_u.Osbpp.p0;
return UnifyPredInfo(pe, 2 PASS_REGS) &&
Yap_unify(ARG5,MkIntegerTerm(ClauseId(ipc,pe)));
}
@ -5903,21 +5918,21 @@ p_choicepoint_info( USES_REGS1 )
case _count_trust_logical:
case _profiled_retry_logical:
case _profiled_trust_logical:
ncl = ipc->u.OtaLl.d->ClCode;
pe = ipc->u.OtaLl.d->ClPred;
ncl = ipc->y_u.OtaLl.d->ClCode;
pe = ipc->y_u.OtaLl.d->ClPred;
t = BuildActivePred(pe, cptr->cp_args);
break;
case _or_else:
pe = ipc->u.Osblp.p0;
pe = ipc->y_u.Osblp.p0;
ncl = ipc;
t = Yap_MkNewApplTerm(FunctorOr, 2);
break;
case _or_last:
#ifdef YAPOR
pe = ipc->u.Osblp.p0;
pe = ipc->y_u.Osblp.p0;
#else
pe = ipc->u.p.p;
pe = ipc->y_u.p.p;
#endif
ncl = ipc;
t = Yap_MkNewApplTerm(FunctorOr, 2);
@ -5929,26 +5944,26 @@ p_choicepoint_info( USES_REGS1 )
t = TermNil;
ipc = NEXTOP(ipc,l);
if (!ncl)
ncl = ipc->u.Otapl.d;
ncl = ipc->y_u.Otapl.d;
go_on = TRUE;
break;
case _jump:
pe = NULL;
t = TermNil;
ipc = ipc->u.l.l;
ipc = ipc->y_u.l.l;
go_on = TRUE;
break;
case _retry_c:
case _retry_userc:
ncl = NEXTOP(ipc,OtapFs);
pe = ipc->u.OtapFs.p;
pe = ipc->y_u.OtapFs.p;
t = BuildActivePred(pe, cptr->cp_args);
break;
case _retry_profiled:
case _count_retry:
pe = NULL;
t = TermNil;
ncl = ipc->u.Otapl.d;
ncl = ipc->y_u.Otapl.d;
ipc = NEXTOP(ipc,p);
go_on = TRUE;
break;
@ -5963,14 +5978,14 @@ p_choicepoint_info( USES_REGS1 )
case _retry:
case _trust:
if (!ncl)
ncl = ipc->u.Otapl.d;
pe = ipc->u.Otapl.p;
ncl = ipc->y_u.Otapl.d;
pe = ipc->y_u.Otapl.p;
t = BuildActivePred(pe, cptr->cp_args);
break;
case _retry_exo:
case _retry_all_exo:
ncl = NULL;
pe = ipc->u.lp.p;
pe = ipc->y_u.lp.p;
t = BuildActivePred(pe, cptr->cp_args);
break;
case _Nstop:
@ -6031,61 +6046,61 @@ store_dbcl_size(yamop *pc, UInt arity, Term t0, PredEntry *pe)
case 2:
pc->opc = Yap_opcode(_get_2atoms);
DerefAndCheck(t, tp[0]);
pc->u.cc.c1 = t;
pc->y_u.cc.c1 = t;
DerefAndCheck(t, tp[1]);
pc->u.cc.c2 = t;
pc->y_u.cc.c2 = t;
pc = NEXTOP(pc,cc);
break;
case 3:
pc->opc = Yap_opcode(_get_3atoms);
DerefAndCheck(t, tp[0]);
pc->u.ccc.c1 = t;
pc->y_u.ccc.c1 = t;
DerefAndCheck(t, tp[1]);
pc->u.ccc.c2 = t;
pc->y_u.ccc.c2 = t;
DerefAndCheck(t, tp[2]);
pc->u.ccc.c3 = t;
pc->y_u.ccc.c3 = t;
pc = NEXTOP(pc,ccc);
break;
case 4:
pc->opc = Yap_opcode(_get_4atoms);
DerefAndCheck(t, tp[0]);
pc->u.cccc.c1 = t;
pc->y_u.cccc.c1 = t;
DerefAndCheck(t, tp[1]);
pc->u.cccc.c2 = t;
pc->y_u.cccc.c2 = t;
DerefAndCheck(t, tp[2]);
pc->u.cccc.c3 = t;
pc->y_u.cccc.c3 = t;
DerefAndCheck(t, tp[3]);
pc->u.cccc.c4 = t;
pc->y_u.cccc.c4 = t;
pc = NEXTOP(pc,cccc);
break;
case 5:
pc->opc = Yap_opcode(_get_5atoms);
DerefAndCheck(t, tp[0]);
pc->u.ccccc.c1 = t;
pc->y_u.ccccc.c1 = t;
DerefAndCheck(t, tp[1]);
pc->u.ccccc.c2 = t;
pc->y_u.ccccc.c2 = t;
DerefAndCheck(t, tp[2]);
pc->u.ccccc.c3 = t;
pc->y_u.ccccc.c3 = t;
DerefAndCheck(t, tp[3]);
pc->u.ccccc.c4 = t;
pc->y_u.ccccc.c4 = t;
DerefAndCheck(t, tp[4]);
pc->u.ccccc.c5 = t;
pc->y_u.ccccc.c5 = t;
pc = NEXTOP(pc,ccccc);
break;
case 6:
pc->opc = Yap_opcode(_get_6atoms);
DerefAndCheck(t, tp[0]);
pc->u.cccccc.c1 = t;
pc->y_u.cccccc.c1 = t;
DerefAndCheck(t, tp[1]);
pc->u.cccccc.c2 = t;
pc->y_u.cccccc.c2 = t;
DerefAndCheck(t, tp[2]);
pc->u.cccccc.c3 = t;
pc->y_u.cccccc.c3 = t;
DerefAndCheck(t, tp[3]);
pc->u.cccccc.c4 = t;
pc->y_u.cccccc.c4 = t;
DerefAndCheck(t, tp[4]);
pc->u.cccccc.c5 = t;
pc->y_u.cccccc.c5 = t;
DerefAndCheck(t, tp[5]);
pc->u.cccccc.c6 = t;
pc->y_u.cccccc.c6 = t;
pc = NEXTOP(pc,cccccc);
break;
default:
@ -6094,12 +6109,12 @@ store_dbcl_size(yamop *pc, UInt arity, Term t0, PredEntry *pe)
for (i = 0; i< arity; i++) {
pc->opc = Yap_opcode(_get_atom);
#if PRECOMPUTE_REGADDRESS
pc->u.xc.x = (CELL) (XREGS + (i+1));
pc->y_u.xc.x = (CELL) (XREGS + (i+1));
#else
pc->u.xc.x = i+1;
pc->y_u.xc.x = i+1;
#endif
DerefAndCheck(t, tp[0]);
pc->u.xc.c = t;
pc->y_u.xc.c = t;
tp++;
pc = NEXTOP(pc,xc);
}
@ -6107,7 +6122,7 @@ store_dbcl_size(yamop *pc, UInt arity, Term t0, PredEntry *pe)
break;
}
pc->opc = Yap_opcode(_procceed);
pc->u.p.p = pe;
pc->y_u.p.p = pe;
return TRUE;
}
@ -6617,6 +6632,7 @@ Yap_InitCdMgr(void)
Yap_InitCPred("$is_metapredicate", 2, p_is_metapredicate, TestPredFlag | SafePredFlag);
Yap_InitCPred("$is_expand_goal_or_meta_predicate", 2, p_is_expandgoalormetapredicate, TestPredFlag | SafePredFlag);
Yap_InitCPred("$is_log_updatable", 2, p_is_log_updatable, TestPredFlag | SafePredFlag);
Yap_InitCPred("$is_thread_local", 2, p_is_thread_local, TestPredFlag | SafePredFlag);
Yap_InitCPred("$is_source", 2, p_is_source, TestPredFlag | SafePredFlag);
Yap_InitCPred("$is_exo", 2, p_is_exo, TestPredFlag | SafePredFlag);
Yap_InitCPred("$owner_file", 3, p_owner_file, SafePredFlag);

View File

@ -75,22 +75,22 @@ Yap_ClauseListExtend(clause_list_t cl, void * clause, void *pred)
fclause = ptr[-1];
code_p = (yamop *)(ptr-1);
code_p->opc = Yap_opcode(_try_clause);
code_p->u.Otapl.d = fclause;
code_p->u.Otapl.s = ap->ArityOfPE;
code_p->u.Otapl.p = ap;
code_p->y_u.Otapl.d = fclause;
code_p->y_u.Otapl.s = ap->ArityOfPE;
code_p->y_u.Otapl.p = ap;
#ifdef TABLING
code_p->u.Otapl.te = ap->TableOfPred;
code_p->y_u.Otapl.te = ap->TableOfPred;
#endif
#ifdef YAPOR
INIT_YAMOP_LTT(code_p, 0);
#endif /* YAPOR */
code_p = NEXTOP(code_p,Otapl);
code_p->opc = Yap_opcode(_trust);
code_p->u.Otapl.d = clause;
code_p->u.Otapl.s = ap->ArityOfPE;
code_p->u.Otapl.p = ap;
code_p->y_u.Otapl.d = clause;
code_p->y_u.Otapl.s = ap->ArityOfPE;
code_p->y_u.Otapl.p = ap;
#ifdef TABLING
code_p->u.Otapl.te = ap->TableOfPred;
code_p->y_u.Otapl.te = ap->TableOfPred;
#endif
#ifdef YAPOR
INIT_YAMOP_LTT(code_p, 0);
@ -100,11 +100,11 @@ Yap_ClauseListExtend(clause_list_t cl, void * clause, void *pred)
if (!(code_p = (yamop *)extend_blob(cl->start,((CELL)NEXTOP((yamop *)NULL,Otapl))/sizeof(CELL) PASS_REGS))) return FALSE;
code_p->opc = Yap_opcode(_trust);
code_p->u.Otapl.d = clause;
code_p->u.Otapl.s = ap->ArityOfPE;
code_p->u.Otapl.p = ap;
code_p->y_u.Otapl.d = clause;
code_p->y_u.Otapl.s = ap->ArityOfPE;
code_p->y_u.Otapl.p = ap;
#ifdef TABLING
code_p->u.Otapl.te = ap->TableOfPred;
code_p->y_u.Otapl.te = ap->TableOfPred;
#endif
#ifdef YAPOR
INIT_YAMOP_LTT(code_p, 0);

View File

@ -447,7 +447,7 @@ c_var(Term t, Int argno, unsigned int arity, unsigned int level, compiler_struct
}
break;
case bt1_flag:
Yap_emit(fetch_args_for_bccall, t, 0, &cglobs->cint);
Yap_emit(fetch_args_for_bccall_op, t, 0, &cglobs->cint);
break;
case bt2_flag:
Yap_emit(bccall_op, t, (CELL)cglobs->current_p0, &cglobs->cint);
@ -2196,7 +2196,7 @@ usesvar(compiler_vm_op ic)
case save_pair_op:
case f_val_op:
case f_var_op:
case fetch_args_for_bccall:
case fetch_args_for_bccall_op:
case bccall_op:
return TRUE;
default:
@ -2963,7 +2963,7 @@ c_layout(compiler_struct *cglobs)
case unify_s_var_op:
case unify_s_val_op:
#endif
case fetch_args_for_bccall:
case fetch_args_for_bccall_op:
case bccall_op:
checktemp(arg, rn, ic, cglobs);
break;

View File

@ -67,7 +67,7 @@ static char SccsId[] = "%W% %G%";
#endif
#ifdef DEBUG
static void ShowOp(char *, struct PSEUDO *);
static void ShowOp(const char *, struct PSEUDO *);
#endif /* DEBUG */
/*
@ -446,7 +446,7 @@ write_functor(Functor f)
}
static void
ShowOp (char *f, struct PSEUDO *cpc)
ShowOp (const char *f, struct PSEUDO *cpc)
{
char ch;
Int arg = cpc->rnd1;
@ -468,6 +468,7 @@ ShowOp (char *f, struct PSEUDO *cpc)
#endif
case 'a':
case 'n':
case 'S':
Yap_DebugPlWrite ((Term) arg);
break;
case 'b':
@ -666,143 +667,286 @@ ShowOp (char *f, struct PSEUDO *cpc)
Yap_DebugErrorPutc ('\n');
}
static char *opformat[] =
{
"nop",
"get_var\t\t%v,%r",
"put_var\t\t%v,%r",
"get_val\t\t%v,%r",
"put_val\t\t%v,%r",
"get_atom\t%a,%r",
"put_atom\t%a,%r",
"get_num\t\t%n,%r",
"put_num\t\t%n,%r",
"get_float\t\t%w,%r",
"put_float\t\t%w,%r",
"get_dbterm\t%w,%r",
"put_dbterm\t%w,%r",
"get_longint\t\t%w,%r",
"put_longint\t\t%w,%r",
"get_bigint\t\t%l,%r",
"put_bigint\t\t%l,%r",
"get_list\t%r",
"put_list\t%r",
"get_struct\t%f,%r",
"put_struct\t%f,%r",
"put_unsafe\t%v,%r",
"unify_var\t%v",
"write_var\t%v",
"unify_val\t%v",
"write_val\t%v",
"unify_atom\t%a",
"write_atom\t%a",
"unify_num\t%n",
"write_num\t%n",
"unify_float\t%w",
"write_float\t%w",
"unify_dbterm\t%w",
"write_dbterm\t%w",
"unify_longint\t%w",
"write_longint\t%w",
"unify_bigint\t%l",
"write_bigint\t%l",
"unify_list",
"write_list",
"unify_struct\t%f",
"write_struct\t%f",
"write_unsafe\t%v",
"unify_local\t%v",
"write local\t%v",
"unify_last_list",
"write_last_list",
"unify_last_struct\t%f",
"write_last_struct\t%f",
"unify_last_var\t%v",
"unify_last_val\t%v",
"unify_last_local\t%v",
"unify_last_atom\t%a",
"unify_last_num\t%n",
"unify_last_float\t%w",
"unify_last_dbterm\t%w",
"unify_last_longint\t%w",
"unify_last_bigint\t%l",
"ensure_space",
"native_code",
"function_to_var\t%v,%B",
"function_to_val\t%v,%B",
"function_to_0\t%B",
"align_float",
"fail",
"cut",
"cutexit",
"allocate",
"deallocate",
"try_me_else\t\t%l\t%x",
"jump\t\t%l",
"jump\t\t%l",
"proceed",
"call\t\t%p,%d,%z",
"execute\t\t%p",
"sys\t\t%p",
"%l:",
"name\t\t%m,%d",
"pop\t\t%l",
"retry_me_else\t\t%l\t%x",
"trust_me_else_fail\t%x",
"either_me\t\t%l,%d,%z",
"or_else\t\t%l,%z",
"or_last",
"push_or",
"pushpop_or",
"pop_or",
"save_by\t\t%v",
"commit_by\t\t%v",
"patch_by\t\t%v",
"try\t\t%g\t%x",
"retry\t\t%g\t%x",
"trust\t\t%g\t%x",
"try_in\t\t%g\t%x",
"jump_if_var\t\t%g",
"jump_if_nonvar\t\t%g",
"cache_arg\t%r",
"cache_sub_arg\t%d",
"user_index",
"switch_on_type\t%h\t%h\t%h\t%h",
"switch_on_constant\t%i\n%c",
"if_constant\t%i\n%c",
"switch_on_functor\t%i\n%e",
"if_functor\t%i\n%e",
"if_not_then\t%i\t%h\t%h\t%h",
"index_on_dbref",
"index_on_blob",
"index_on_long",
"check_var\t %r",
"save_pair\t%v",
"save_appl\t%v",
"pvar_bitmap\t%l,%b",
"pvar_live_regs\t%l,%b",
"fetch_reg1_reg2\t%N,%N",
"fetch_constant_reg\t%l,%N",
"fetch_reg_constant\t%l,%N",
"fetch_integer_reg\t%d,%N",
"fetch_reg_integer\t%d,%N",
"enter_profiling\t\t%g",
"retry_profiled\t\t%g",
"count_call_op\t\t%g",
"count_retry_op\t\t%g",
"restore_temps\t\t%l",
"restore_temps_and_skip\t\t%l",
"enter_lu",
"empty_call\t\t%l,%d",
static const char *
getFormat(compiler_vm_op ic) {
switch( ic ) {
case nop_op:
return "nop";
case get_var_op:
return "get_var\t\t%v,%r";
case put_var_op:
return "put_var\t\t%v,%r";
case get_val_op:
return "get_val\t\t%v,%r";
case put_val_op:
return "put_val\t\t%v,%r";
case get_atom_op:
return "get_atom\t%a,%r";
case put_atom_op:
return "put_atom\t%a,%r";
case get_num_op:
return "get_num\t\t%n,%r";
case put_num_op:
return "put_num\t\t%n,%r";
case get_float_op:
return "get_float\t\t%w,%r";
case put_float_op:
return "put_float\t\t%w,%r";
case get_string_op:
return "get_string\t\t%w,%S";
case put_string_op:
return "put_string\t\t%w,%S";
case get_dbterm_op:
return "get_dbterm\t%w,%r";
case put_dbterm_op:
return "put_dbterm\t%w,%r";
case get_longint_op:
return "get_longint\t\t%w,%r";
case put_longint_op:
return "put_longint\t\t%w,%r";
case get_bigint_op:
return "get_bigint\t\t%l,%r";
case put_bigint_op:
return "put_bigint\t\t%l,%r";
case get_list_op:
return "get_list\t%r";
case put_list_op:
return "put_list\t%r";
case get_struct_op:
return "get_struct\t%f,%r";
case put_struct_op:
return "put_struct\t%f,%r";
case put_unsafe_op:
return "put_unsafe\t%v,%r";
case unify_var_op:
return "unify_var\t%v";
case write_var_op:
return "write_var\t%v";
case unify_val_op:
return "unify_val\t%v";
case write_val_op:
return "write_val\t%v";
case unify_atom_op:
return "unify_atom\t%a";
case write_atom_op:
return "write_atom\t%a";
case unify_num_op:
return "unify_num\t%n";
case write_num_op:
return "write_num\t%n";
case unify_float_op:
return "unify_float\t%w";
case write_float_op:
return "write_float\t%w";
case unify_string_op:
return "unify_string\t%S";
case write_string_op:
return "write_string\t%S";
case unify_dbterm_op:
return "unify_dbterm\t%w";
case write_dbterm_op:
return "write_dbterm\t%w";
case unify_longint_op:
return "unify_longint\t%w";
case write_longint_op:
return "write_longint\t%w";
case unify_bigint_op:
return "unify_bigint\t%l";
case write_bigint_op:
return "write_bigint\t%l";
case unify_list_op:
return "unify_list";
case write_list_op:
return "write_list";
case unify_struct_op:
return "unify_struct\t%f";
case write_struct_op:
return "write_struct\t%f";
case write_unsafe_op:
return "write_unsafe\t%v";
case unify_local_op:
return "unify_local\t%v";
case write_local_op:
return "write local\t%v";
case unify_last_list_op:
return "unify_last_list";
case write_last_list_op:
return "write_last_list";
case unify_last_struct_op:
return "unify_last_struct\t%f";
case write_last_struct_op:
return "write_last_struct\t%f";
case unify_last_var_op:
return "unify_last_var\t%v";
case unify_last_val_op:
return "unify_last_val\t%v";
case unify_last_local_op:
return "unify_last_local\t%v";
case unify_last_atom_op:
return "unify_last_atom\t%a";
case unify_last_num_op:
return "unify_last_num\t%n";
case unify_last_float_op:
return "unify_last_float\t%w";
case unify_last_string_op:
return "unify_last_string\t%S";
case unify_last_dbterm_op:
return "unify_last_dbterm\t%w";
case unify_last_longint_op:
return "unify_last_longint\t%w";
case unify_last_bigint_op:
return "unify_last_bigint\t%l";
case ensure_space_op:
return "ensure_space";
case native_op:
return "native_code";
case f_var_op:
return "function_to_var\t%v,%B";
case f_val_op:
return "function_to_val\t%v,%B";
case f_0_op:
return "function_to_0\t%B";
case align_float_op:
return "align_float";
case fail_op:
return "fail";
case cut_op:
return "cut";
case cutexit_op:
return "cutexit";
case allocate_op:
return "allocate";
case deallocate_op:
return "deallocate";
case tryme_op:
return "try_me_else\t\t%l\t%x";
case jump_op:
return "jump\t\t%l";
case jumpi_op:
return "jump_in_indexing\t\t%i";
case procceed_op:
return "proceed";
case call_op:
return "call\t\t%p,%d,%z";
case execute_op:
return "execute\t\t%p";
case safe_call_op:
return "sys\t\t%p";
case label_op:
return "%l:";
case name_op:
return "name\t\t%m,%d";
case pop_op:
return "pop\t\t%l";
case retryme_op:
return "retry_me_else\t\t%l\t%x";
case trustme_op:
return "trust_me_else_fail\t%x";
case either_op:
return "either_me\t\t%l,%d,%z";
case orelse_op:
return "or_else\t\t%l,%z";
case orlast_op:
return "or_last";
case push_or_op:
return "push_or";
case pop_or_op:
return "pop_or";
case pushpop_or_op:
return "pushpop_or";
case save_b_op:
return "save_by\t\t%v";
case commit_b_op:
return "commit_by\t\t%v";
case patch_b_op:
return "patch_by\t\t%v";
case try_op:
return "try\t\t%g\t%x";
case retry_op:
return "retry\t\t%g\t%x";
case trust_op:
return "trust\t\t%g\t%x";
case try_in_op:
return "try_in\t\t%g\t%x";
case jump_v_op:
return "jump_if_var\t\t%g";
case jump_nv_op:
return "jump_if_nonvar\t\t%g";
case cache_arg_op:
return "cache_arg\t%r";
case cache_sub_arg_op:
return "cache_sub_arg\t%d";
case user_switch_op:
return "user_switch";
case switch_on_type_op:
return "switch_on_type\t%h\t%h\t%h\t%h";
case switch_c_op:
return "switch_on_constant\t%i\n%c";
case if_c_op:
return "if_constant\t%i\n%c";
case switch_f_op:
return "switch_on_functor\t%i\n%e";
case if_f_op:
return "if_functor\t%i\n%e";
case if_not_op:
return "if_not_then\t%i\t%h\t%h\t%h";
case index_dbref_op:
return "index_on_dbref";
case index_blob_op:
return "index_on_blob";
case index_long_op:
return "index_on_blob";
case index_string_op:
return "index_on_string";
case if_nonvar_op:
return "check_var\t %r";
case save_pair_op:
return "save_pair\t%v";
case save_appl_op:
return "save_appl\t%v";
case mark_initialised_pvars_op:
return "pvar_bitmap\t%l,%b";
case mark_live_regs_op:
return "pvar_live_regs\t%l,%b";
case fetch_args_vv_op:
return "fetch_reg1_reg2\t%N,%N";
case fetch_args_cv_op:
return "fetch_constant_reg\t%l,%N";
case fetch_args_vc_op:
return "fetch_reg_constant\t%l,%N";
case fetch_args_iv_op:
return "fetch_integer_reg\t%d,%N";
case fetch_args_vi_op:
return "fetch_reg_integer\t%d,%N";
case enter_profiling_op:
return "enter_profiling\t\t%g";
case retry_profiled_op:
return "retry_profiled\t\t%g";
case count_call_op:
return "count_call_op\t\t%g";
case count_retry_op:
return "count_retry_op\t\t%g";
case restore_tmps_op:
return "restore_temps\t\t%l";
case restore_tmps_and_skip_op:
return "restore_temps_and_skip\t\t%l";
case enter_lu_op:
return "enter_lu";
case empty_call_op:
return "empty_call\t\t%l,%d";
#ifdef YAPOR
"sync",
case sync_op:
return "sync";
#endif /* YAPOR */
#ifdef TABLING
"table_new_answer",
"table_try_single\t%g\t%x",
case table_new_answer_op:
return "table_new_answer";
case table_try_single_op:
return "table_try_single\t%g\t%x";
#endif /* TABLING */
#ifdef TABLING_INNER_CUTS
"clause_with_cut",
case "clause_with_cut":
return clause_with_cut_op;
#endif /* TABLING_INNER_CUTS */
#ifdef BEAM
"run_op %1,%4",
@ -828,10 +972,16 @@ static char *opformat[] =
"equal_op",
"exit",
#endif
"fetch_args_for_bccall\t%v",
"binary_cfunc\t\t%v,%P",
"blob\t%O",
"label_control\t"
case fetch_args_for_bccall_op:
return "fetch_args_for_bccall\t%v";
case bccall_op:
return "binary_cfunc\t\t%v,%P";
case blob_op:
return "blob\t%O";
case string_op:
return "string\t%O";
case label_ctl_op:
return "label_control\t";
#ifdef SFUNC
,
"get_s_f_op\t%f,%r",
@ -849,14 +999,14 @@ static char *opformat[] =
"unify_s_end",
"write_s_end"
#endif
};
}
return NULL;
}
void
Yap_ShowCode (struct intermediates *cint)
{
CACHE_REGS
CELL *oldH = HR;
struct PSEUDO *cpc;
cpc = cint->CodeStart;
@ -865,12 +1015,11 @@ Yap_ShowCode (struct intermediates *cint)
while (cpc) {
compiler_vm_op ic = cpc->op;
if (ic != nop_op) {
ShowOp (opformat[ic], cpc);
}
}
ShowOp (getFormat(ic), cpc);
cpc = cpc->nextInst;
}
Yap_DebugErrorPutc ('\n');
HR = oldH;
}
#endif /* DEBUG */

View File

@ -2718,7 +2718,7 @@ new_lu_entry(Term t)
if (IsApplTerm(t)) {
Functor f = FunctorOfTerm(t);
WRITE_LOCK(f->FRWLock);
FUNC_WRITE_LOCK(f);
p0 = Yap_NewPredPropByFunctor(f,IDB_MODULE);
} else if (IsAtomTerm(t)) {
Atom at = AtomOfTerm(t);
@ -2726,7 +2726,7 @@ new_lu_entry(Term t)
WRITE_LOCK(RepAtom(at)->ARWLock);
p0 = Yap_NewPredPropByAtom(at,IDB_MODULE);
} else {
WRITE_LOCK(FunctorList->FRWLock);
FUNC_WRITE_LOCK(FunctorList);
p0 = Yap_NewPredPropByFunctor(FunctorList,IDB_MODULE);
}
pe = RepPredProp(p0);
@ -3614,14 +3614,14 @@ index_sz(LogUpdIndex *x)
endop = Yap_opcode(_profiled_trust_logical);
else
endop = Yap_opcode(_trust_logical);
start = start->u.Illss.l1;
if (start->u.Illss.s) do {
start = start->y_u.Illss.l1;
if (start->y_u.Illss.s) do {
sz += (UInt)NEXTOP((yamop*)NULL,OtaLl);
op1 = start->opc;
count++;
if (start->u.OtaLl.d->ClFlags & ErasedMask)
if (start->y_u.OtaLl.d->ClFlags & ErasedMask)
dead++;
start = start->u.OtaLl.n;
start = start->y_u.OtaLl.n;
} while (op1 != endop);
}
x = x->ChildIndex;
@ -3656,9 +3656,9 @@ lu_statistics(PredEntry *pe USES_REGS)
/* expand clause blocks */
yamop *ep = ExpandClausesFirst;
while (ep) {
if (ep->u.sssllp.p == pe)
isz += (UInt)NEXTOP((yamop *)NULL,sssllp)+ep->u.sssllp.s1*sizeof(yamop *);
ep = ep->u.sssllp.snext;
if (ep->y_u.sssllp.p == pe)
isz += (UInt)NEXTOP((yamop *)NULL,sssllp)+ep->y_u.sssllp.s1*sizeof(yamop *);
ep = ep->y_u.sssllp.snext;
}
isz += index_sz(ClauseCodeToLogUpdIndex(pe->cs.p_code.TrueCodeOfPred));
}
@ -3915,7 +3915,7 @@ find_next_clause(DBRef ref0 USES_REGS)
static Int
p_jump_to_next_dynamic_clause( USES_REGS1 )
{
DBRef ref = (DBRef)(((yamop *)((CODEADDR)P-(CELL)NEXTOP((yamop *)NULL,Osbpp)))->u.Osbpp.bmap);
DBRef ref = (DBRef)(((yamop *)((CODEADDR)P-(CELL)NEXTOP((yamop *)NULL,Osbpp)))->y_u.Osbpp.bmap);
yamop *newp = find_next_clause(ref PASS_REGS);
if (newp == NULL) {
@ -4070,20 +4070,20 @@ MyEraseClause(DynamicClause *clau USES_REGS)
I don't need to lock the clause at this point because
I am the last one using it anyway.
*/
ref = (DBRef) NEXTOP(clau->ClCode,Otapl)->u.Osbpp.bmap;
ref = (DBRef) NEXTOP(clau->ClCode,Otapl)->y_u.Osbpp.bmap;
/* don't do nothing if the reference is still in use */
if (DBREF_IN_USE(ref))
return;
if ( P == clau->ClCode ) {
yamop *np = RTRYCODE;
/* make it the next alternative */
np->u.Otapl.d = find_next_clause((DBRef)(NEXTOP(P,Otapl)->u.Osbpp.bmap) PASS_REGS);
if (np->u.Otapl.d == NULL)
np->y_u.Otapl.d = find_next_clause((DBRef)(NEXTOP(P,Otapl)->y_u.Osbpp.bmap) PASS_REGS);
if (np->y_u.Otapl.d == NULL)
P = (yamop *)FAILCODE;
else {
/* with same arity as before */
np->u.Otapl.s = P->u.Otapl.s;
np->u.Otapl.p = P->u.Otapl.p;
np->y_u.Otapl.s = P->y_u.Otapl.s;
np->y_u.Otapl.p = P->y_u.Otapl.p;
/* go ahead and try this code */
P = np;
}
@ -4134,7 +4134,7 @@ PrepareToEraseLogUpdClause(LogUpdClause *clau, DBRef dbr)
if (p->cs.p_code.FirstClause != cl) {
/* we are not the first clause... */
yamop *prev_code_p = (yamop *)(dbr->Prev->Code);
prev_code_p->u.Otapl.d = code_p->u.Otapl.d;
prev_code_p->y_u.Otapl.d = code_p->y_u.Otapl.d;
/* are we the last? */
if (p->cs.p_code.LastClause == cl)
p->cs.p_code.LastClause = prev_code_p;
@ -4143,7 +4143,7 @@ PrepareToEraseLogUpdClause(LogUpdClause *clau, DBRef dbr)
if (p->cs.p_code.LastClause == p->cs.p_code.FirstClause) {
p->cs.p_code.LastClause = p->cs.p_code.FirstClause = NULL;
} else {
p->cs.p_code.FirstClause = code_p->u.Otapl.d;
p->cs.p_code.FirstClause = code_p->y_u.Otapl.d;
p->cs.p_code.FirstClause->opc =
Yap_opcode(_try_me);
}
@ -4158,7 +4158,7 @@ PrepareToEraseLogUpdClause(LogUpdClause *clau, DBRef dbr)
if (p->cs.p_code.FirstClause == p->cs.p_code.LastClause) {
if (p->cs.p_code.FirstClause != NULL) {
code_p = p->cs.p_code.FirstClause;
code_p->u.Otapl.d = p->cs.p_code.FirstClause;
code_p->y_u.Otapl.d = p->cs.p_code.FirstClause;
p->cs.p_code.TrueCodeOfPred = NEXTOP(code_p, Otapl);
if (p->PredFlags & (SpiedPredFlag|CountPredFlag|ProfiledPredFlag)) {
p->OpcodeOfPred = Yap_opcode(_spy_pred);

View File

@ -242,6 +242,8 @@ DumpActiveGoals ( USES_REGS1 )
if (!ONLOCAL (b_ptr) || b_ptr->cp_b == NULL)
break;
pe = Yap_PredForChoicePt(b_ptr);
if (!pe)
break;
PELOCK(72,pe);
{
Functor f;
@ -251,10 +253,13 @@ DumpActiveGoals ( USES_REGS1 )
if (pe->ModuleOfPred)
mod = pe->ModuleOfPred;
else mod = TermProlog;
YapPlWrite (mod);
YapPutc (LOCAL_c_error_stream,':');
if (mod != TermProlog &&
mod != MkAtomTerm(AtomUser) ) {
YapPlWrite (mod);
YapPutc (LOCAL_c_error_stream,':');
}
if (pe->ArityOfPE == 0) {
YapPlWrite (MkAtomTerm (NameOfFunctor(f)));
YapPlWrite (MkAtomTerm ((Atom)f));
} else {
Int i = 0, arity = pe->ArityOfPE;
Term *args = &(b_ptr->cp_a1);
@ -1990,6 +1995,9 @@ E);
Yap_RestartYap( 1 );
}
UNLOCK(LOCAL_SignalLock);
#if DEBUG
DumpActiveGoals( PASS_REGS1 );
#endif
/* wait if we we are in user code,
it's up to her to decide */

View File

@ -542,12 +542,6 @@ init_between( USES_REGS1 )
return cont_between( PASS_REGS1 );
}
/**
*
* @}
*
* @}
*/
void
Yap_InitEval(void)
{
@ -562,3 +556,7 @@ Yap_InitEval(void)
Yap_InitCPredBack("between", 3, 2, init_between, cont_between, 0);
}
/**
*
* @}
*/

View File

@ -30,7 +30,6 @@ static Int EnterCreepMode(Term, Term CACHE_TYPE);
static Int p_save_cp( USES_REGS1 );
static Int p_execute( USES_REGS1 );
static Int p_execute0( USES_REGS1 );
static int execute_pred(PredEntry *ppe, CELL *pt USES_REGS);
static Term
cp_as_integer(choiceptr cp USES_REGS)
@ -125,7 +124,7 @@ p_save_cp( USES_REGS1 )
#endif
if (!IsVarTerm(t)) return(FALSE);
td = cp_as_integer(B PASS_REGS);
Bind((CELL *)t,td);
YapBind((CELL *)t,td);
return(TRUE);
}
@ -139,7 +138,7 @@ p_save_env_b( USES_REGS1 )
#endif
if (!IsVarTerm(t)) return(FALSE);
td = cp_as_integer((choiceptr)YENV[E_CB] PASS_REGS);
Bind((CELL *)t,td);
YapBind((CELL *)t,td);
return(TRUE);
}
@ -676,7 +675,7 @@ p_do_goal_expansion( USES_REGS1 )
if ( (pe = RepPredProp(Yap_GetPredPropByFunc(FunctorGoalExpansion2, cmod) ) ) &&
pe->OpcodeOfPred != FAIL_OPCODE &&
pe->OpcodeOfPred != UNDEF_OPCODE &&
execute_pred(pe, NULL PASS_REGS) ) {
Yap_execute_pred(pe, NULL PASS_REGS) ) {
out = TRUE;
ARG3 = ARG2;
goto complete;
@ -685,7 +684,7 @@ p_do_goal_expansion( USES_REGS1 )
if ( (pe = RepPredProp(Yap_GetPredPropByFunc(FunctorGoalExpansion2, SYSTEM_MODULE ) ) ) &&
pe->OpcodeOfPred != FAIL_OPCODE &&
pe->OpcodeOfPred != UNDEF_OPCODE &&
execute_pred(pe, NULL PASS_REGS) ) {
Yap_execute_pred(pe, NULL PASS_REGS) ) {
out = TRUE;
ARG3 = ARG2;
goto complete;
@ -696,7 +695,7 @@ p_do_goal_expansion( USES_REGS1 )
if ( (pe = RepPredProp(Yap_GetPredPropByFunc(FunctorGoalExpansion, USER_MODULE ) ) ) &&
pe->OpcodeOfPred != FAIL_OPCODE &&
pe->OpcodeOfPred != UNDEF_OPCODE &&
execute_pred(pe, NULL PASS_REGS) ) {
Yap_execute_pred(pe, NULL PASS_REGS) ) {
out = TRUE;
goto complete;
}
@ -706,7 +705,7 @@ p_do_goal_expansion( USES_REGS1 )
(pe = RepPredProp(Yap_GetPredPropByFunc(FunctorGoalExpansion2, USER_MODULE ) ) ) &&
pe->OpcodeOfPred != FAIL_OPCODE &&
pe->OpcodeOfPred != UNDEF_OPCODE &&
execute_pred(pe, NULL PASS_REGS) ) {
Yap_execute_pred(pe, NULL PASS_REGS) ) {
ARG3 = ARG2;
out = TRUE;
}
@ -738,7 +737,7 @@ p_do_term_expansion( USES_REGS1 )
if ( (pe = RepPredProp(Yap_GetPredPropByFunc(FunctorTermExpansion, cmod) ) ) &&
pe->OpcodeOfPred != FAIL_OPCODE &&
pe->OpcodeOfPred != UNDEF_OPCODE &&
execute_pred(pe, NULL PASS_REGS) ) {
Yap_execute_pred(pe, NULL PASS_REGS) ) {
out = TRUE;
goto complete;
}
@ -746,7 +745,7 @@ p_do_term_expansion( USES_REGS1 )
if ( (pe = RepPredProp(Yap_GetPredPropByFunc(FunctorTermExpansion, SYSTEM_MODULE ) ) ) &&
pe->OpcodeOfPred != FAIL_OPCODE &&
pe->OpcodeOfPred != UNDEF_OPCODE &&
execute_pred(pe, NULL PASS_REGS) ) {
Yap_execute_pred(pe, NULL PASS_REGS) ) {
out = TRUE;
goto complete;
}
@ -755,7 +754,7 @@ p_do_term_expansion( USES_REGS1 )
(pe = RepPredProp(Yap_GetPredPropByFunc(FunctorTermExpansion, USER_MODULE ) ) ) &&
pe->OpcodeOfPred != FAIL_OPCODE &&
pe->OpcodeOfPred != UNDEF_OPCODE &&
execute_pred(pe, NULL PASS_REGS) ) {
Yap_execute_pred(pe, NULL PASS_REGS) ) {
out = TRUE;
}
complete:
@ -1215,8 +1214,8 @@ Yap_exec_absmi(int top)
}
static int
execute_pred(PredEntry *ppe, CELL *pt USES_REGS)
int
Yap_execute_pred(PredEntry *ppe, CELL *pt USES_REGS)
{
yamop *saved_p, *saved_cp;
yamop *CodeAdr;
@ -1226,15 +1225,9 @@ execute_pred(PredEntry *ppe, CELL *pt USES_REGS)
saved_cp = CP;
PELOCK(81,ppe);
if (ppe->ArityOfPE == 0) {
CodeAdr = ppe->CodeOfPred;
UNLOCK(ppe->PELock);
out = do_goal(CodeAdr, 0, pt, FALSE PASS_REGS);
} else {
CodeAdr = ppe->CodeOfPred;
UNLOCK(ppe->PELock);
out = do_goal(CodeAdr, ppe->ArityOfPE, pt, FALSE PASS_REGS);
}
CodeAdr = ppe->CodeOfPred;
UNLOCK(ppe->PELock);
out = do_goal(CodeAdr, ppe->ArityOfPE, pt, FALSE PASS_REGS);
if (out == 1) {
choiceptr cut_B;
@ -1335,7 +1328,7 @@ Yap_execute_goal(Term t, int nargs, Term mod)
if (pe == NIL) {
return CallMetaCall(t, mod PASS_REGS);
}
return execute_pred(ppe, pt PASS_REGS);
return Yap_execute_pred(ppe, pt PASS_REGS);
}
@ -1430,13 +1423,17 @@ Yap_RunTopGoal(Term t)
}
static void
restore_regs(Term t USES_REGS)
restore_regs(Term t, int restore_all USES_REGS)
{
if (IsApplTerm(t)) {
Int i;
Int max = ArityOfFunctor(FunctorOfTerm(t));
CELL *ptr = RepAppl(t)+1;
Int max = ArityOfFunctor(FunctorOfTerm(t))-4;
CELL *ptr = RepAppl(t)+5;
P = (yamop *)IntegerOfTerm(ptr[-4]);
CP = (yamop *)IntegerOfTerm(ptr[-3]);
ENV = (CELL *)(LCL0-IntegerOfTerm(ptr[-2]));
YENV = (CELL *)(LCL0-IntegerOfTerm(ptr[-1]));
for (i = 0; i < max; i += 2) {
Int j = IntOfTerm(ptr[0]);
XREGS[j] = ptr[1];
@ -1455,7 +1452,7 @@ p_restore_regs( USES_REGS1 )
return(FALSE);
}
if (IsAtomTerm(t)) return(TRUE);
restore_regs(t PASS_REGS);
restore_regs(t, FALSE PASS_REGS);
return(TRUE);
}
@ -1466,13 +1463,15 @@ p_restore_regs2( USES_REGS1 )
Term t = Deref(ARG1), d0;
choiceptr pt0;
Int d;
if (IsVarTerm(t)) {
Yap_Error(INSTANTIATION_ERROR,t,"support for coroutining");
return(FALSE);
}
d0 = Deref(ARG2);
if (!IsAtomTerm(t)) {
restore_regs(t PASS_REGS);
restore_regs(t, TRUE PASS_REGS);
}
if (IsVarTerm(d0)) {
Yap_Error(INSTANTIATION_ERROR,d0,"support for coroutining");
@ -1481,13 +1480,16 @@ p_restore_regs2( USES_REGS1 )
if (!IsIntegerTerm(d0)) {
return(FALSE);
}
d = IntegerOfTerm(d0);
if (!d)
return TRUE;
#if YAPOR_SBA
pt0 = (choiceptr)IntegerOfTerm(d0);
pt0 = (choiceptr)d;
#else
pt0 = (choiceptr)(LCL0-IntOfTerm(d0));
pt0 = (choiceptr)(LCL0-d);
#endif
/* find where to cut to */
if (pt0 > B) {
if ((CELL *)pt0 != LCL0 && pt0 > B) {
/* Wow, we're gonna cut!!! */
while (B->cp_b < pt0) {
while (POP_CHOICE_POINT(B->cp_b))
@ -1585,9 +1587,9 @@ static int is_cleanup_cp(choiceptr cp_b)
if (cp_b->cp_ap->opc != ORLAST_OPCODE)
return FALSE;
#ifdef YAPOR
pe = cp_b->cp_ap->u.Osblp.p0;
pe = cp_b->cp_ap->y_u.Osblp.p0;
#else
pe = cp_b->cp_ap->u.p.p;
pe = cp_b->cp_ap->y_u.p.p;
#endif /* YAPOR */
/*
it has to be a cleanup and it has to be a completed goal,
@ -1900,7 +1902,7 @@ Yap_dogc( int extra_args, Term *tp USES_REGS )
int i;
if (P && PREVOP(P,Osbpp)->opc == Yap_opcode(_call_usercpred)) {
arity = PREVOP(P,Osbpp)->u.Osbpp.p->ArityOfPE;
arity = PREVOP(P,Osbpp)->y_u.Osbpp.p->ArityOfPE;
nextpc = P;
} else {
arity = 0;

20
C/exo.c
View File

@ -41,7 +41,7 @@
#define FNV32_PRIME ((UInt)16777619)
#define FNV64_PRIME ((UInt)1099511628211)
#define FNV32_OFFSET ((UInt)2166136261)
#define FNV32_OFFSET ((UInt)0x811c9dc5)
#define FNV64_OFFSET ((UInt)14695981039346656037)
/*MurmurHash3 from: https://code.google.com/p/smhasher/wiki/MurmurHash3*/
@ -435,7 +435,7 @@ add_index(struct index_t **ip, UInt bmap, PredEntry *ap, UInt count)
continue;
}
#if DEBUG
fprintf(stderr, "entries=%ld collisions=%ld (max=%ld) trys=%ld\n", i->nentries, i->ncollisions, i->max_col_count, i->ntrys);
fprintf(stderr, "entries=" UInt_FORMAT " collisions=" UInt_FORMAT" (max=" UInt_FORMAT ") trys=" UInt_FORMAT "\n", i->nentries, i->ncollisions, i->max_col_count, i->ntrys);
#endif
if (!i->ntrys && !i->is_key) {
i->is_key = TRUE;
@ -467,30 +467,30 @@ add_index(struct index_t **ip, UInt bmap, PredEntry *ap, UInt count)
ptr->opc = Yap_opcode(_try_exo);
else
ptr->opc = Yap_opcode(_try_all_exo);
ptr->u.lp.l = (yamop *)i;
ptr->u.lp.p = ap;
ptr->y_u.lp.l = (yamop *)i;
ptr->y_u.lp.p = ap;
ptr = NEXTOP(ptr, lp);
if (count)
ptr->opc = Yap_opcode(_retry_exo);
else
ptr->opc = Yap_opcode(_retry_all_exo);
ptr->u.lp.p = ap;
ptr->u.lp.l = (yamop *)i;
ptr->y_u.lp.p = ap;
ptr->y_u.lp.l = (yamop *)i;
ptr = NEXTOP(ptr, lp);
for (j = 0; j < i->arity; j++) {
ptr->opc = Yap_opcode(_get_atom_exo);
#if PRECOMPUTE_REGADDRESS
ptr->u.x.x = (CELL) (XREGS + (j+1));
ptr->y_u.x.x = (CELL) (XREGS + (j+1));
#else
ptr->u.x.x = j+1;
ptr->y_u.x.x = j+1;
#endif
ptr = NEXTOP(ptr, x);
}
ptr->opc = Yap_opcode(_procceed);
ptr->u.p.p = ap;
ptr->y_u.p.p = ap;
ptr = NEXTOP(ptr, p);
ptr->opc = Yap_opcode(_Ystop);
ptr->u.l.l = i->code;
ptr->y_u.l.l = i->code;
Yap_inform_profiler_of_clause((char *)(i->code), (char *)NEXTOP(ptr,l), ap, GPROF_INDEX);
if (ap->PredFlags & UDIPredFlag) {
Yap_new_udi_clause( ap, NULL, (Term)ip);

View File

@ -1289,7 +1289,7 @@ p_nb_getval( USES_REGS1 )
to = ge->global;
if (IsVarTerm(to) && IsUnboundVar(VarOfTerm(to))) {
Term t = MkVarTerm();
Bind(VarOfTerm(to), t);
YapBind(VarOfTerm(to), t);
to = t;
}
READ_UNLOCK(ge->GRWLock);

View File

@ -934,10 +934,10 @@ prof_alrm(int signo, siginfo_t *si, void *scv)
if (oop == _call_cpred || oop == _call_usercpred) {
/* doing C-code */
current_p = PREVOP(P,Osbpp)->u.Osbpp.p->CodeOfPred;
current_p = PREVOP(P,Osbpp)->y_u.Osbpp.p->CodeOfPred;
} else if ((oop = Yap_op_from_opcode(P->opc)) == _execute_cpred) {
/* doing C-code */
current_p = P->u.pp.p->CodeOfPred;
current_p = P->y_u.pp.p->CodeOfPred;
} else {
current_p = P;
}

View File

@ -1073,7 +1073,7 @@ fix_compiler_instructions(PInstr *pcpc USES_REGS)
case write_local_op:
case f_var_op:
case f_val_op:
case fetch_args_for_bccall:
case fetch_args_for_bccall_op:
case bccall_op:
case save_pair_op:
case save_appl_op:
@ -1419,13 +1419,22 @@ Yap_locked_growheap(int fix_code, size_t in_size, void *cip)
int res;
int blob_overflow = (NOfBlobs > NOfBlobsMax);
#if (THREADS) || YAPOR
res = FALSE;
if (NOfAtoms > 2*AtomHashTableSize || blob_overflow) {
Yap_undo_signal( YAP_CDOVF_SIGNAL );
return TRUE;
#ifdef THREADS
LOCK(GLOBAL_ThreadHandlesLock);
#endif
// make sure that we cannot have more than a thread life
if (Yap_NOfThreads() > 1) {
#ifdef THREADS
UNLOCK(GLOBAL_ThreadHandlesLock);
#endif
res = FALSE;
if (NOfAtoms > 2*AtomHashTableSize || blob_overflow) {
Yap_undo_signal( YAP_CDOVF_SIGNAL );
UNLOCK(LOCAL_SignalLock);
return TRUE;
}
}
#else
// don't release the MTHREAD lock in case we're running from the C-interface.
if (NOfAtoms > 2*AtomHashTableSize || blob_overflow) {
UInt n = NOfAtoms;
if (GLOBAL_AGcThreshold)
@ -1438,11 +1447,18 @@ Yap_locked_growheap(int fix_code, size_t in_size, void *cip)
res = growatomtable( PASS_REGS1 );
} else {
Yap_undo_signal( YAP_CDOVF_SIGNAL );
#ifdef THREADS
UNLOCK(GLOBAL_ThreadHandlesLock);
#endif
return TRUE;
}
LeaveGrowMode(GrowHeapMode);
if (res)
if (res) {
#ifdef THREADS
UNLOCK(GLOBAL_ThreadHandlesLock);
#endif
return res;
}
}
#if USE_SYSTEM_MALLOC
P = Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"malloc failed");
@ -1451,6 +1467,8 @@ Yap_locked_growheap(int fix_code, size_t in_size, void *cip)
res=do_growheap(fix_code, in_size, (struct intermediates *)cip, NULL, NULL, NULL PASS_REGS);
#endif
LeaveGrowMode(GrowHeapMode);
#ifdef THREADS
UNLOCK(GLOBAL_ThreadHandlesLock);
#endif
return res;
}

View File

@ -111,7 +111,7 @@ gc_growtrail(int committed, tr_fr_ptr begsTR, cont *old_cont_top0 USES_REGS)
/* ask for double the size */
sz = 2*sz;
if (!Yap_growtrail(sz, TRUE)) {
if (!Yap_locked_growtrail(sz, TRUE)) {
#ifdef EASY_SHUNTING
if (begsTR) {
LOCAL_sTR = (tr_fr_ptr)old_cont_top0;
@ -169,11 +169,13 @@ PUSH_POINTER(CELL *v USES_REGS) {
*LOCAL_iptop++ = v;
}
#ifdef EASY_SHUNTING
inline static void
POP_POINTER( USES_REGS1 ) {
if (LOCAL_iptop >= (CELL_PTR *)ASP) return;
--LOCAL_iptop;
}
#endif
inline static void
POPSWAP_POINTER(CELL_PTR *vp, CELL_PTR v USES_REGS) {
@ -384,7 +386,7 @@ static void
check_pr_trail(tr_fr_ptr trp USES_REGS)
{
if ((tr_fr_ptr)LOCAL_TrailTop-TR < 1024) {
if (!Yap_growtrail(0, TRUE) || TRUE) {
if (!Yap_locked_growtrail(0, TRUE) || TRUE) {
/* could not find more trail */
save_machine_regs();
siglongjmp(LOCAL_gc_restore, 2);
@ -451,7 +453,7 @@ push_registers(Int num_regs, yamop *nextop USES_REGS)
/* push any live registers we might have hanging around */
if (nextop->opc == Yap_opcode(_move_back) ||
nextop->opc == Yap_opcode(_skip)) {
CELL *lab = (CELL *)(nextop->u.l.l);
CELL *lab = (CELL *)(nextop->y_u.l.l);
CELL max = lab[0];
Int curr = lab[1];
lab += 2;
@ -547,7 +549,7 @@ pop_registers(Int num_regs, yamop *nextop USES_REGS)
/* pop any live registers we might have hanging around */
if (nextop->opc == Yap_opcode(_move_back) ||
nextop->opc == Yap_opcode(_skip)) {
CELL *lab = (CELL *)(nextop->u.l.l);
CELL *lab = (CELL *)(nextop->y_u.l.l);
CELL max = lab[0];
Int curr = lab[1];
lab += 2;
@ -1524,21 +1526,6 @@ mark_external_reference(CELL *ptr USES_REGS) {
}
}
static void inline
mark_external_reference2(CELL *ptr USES_REGS) {
CELL *next = GET_NEXT(*ptr);
if (ONHEAP(next)) {
#ifdef HYBRID_SCHEME
CELL_PTR *old = LOCAL_iptop;
#endif
mark_variable(ptr PASS_REGS);
POPSWAP_POINTER(old, ptr PASS_REGS);
} else {
mark_code(ptr,next PASS_REGS);
}
}
/*
* mark all heap objects accessible from the trail (which includes the active
* general purpose registers)
@ -2055,8 +2042,8 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose
if (opnum == _or_else || opnum == _or_last) {
/* ; choice point */
mark_environments((CELL_PTR) (gc_B->cp_a1),
-gc_B->cp_cp->u.Osblp.s / ((OPREG)sizeof(CELL)),
gc_B->cp_cp->u.Osblp.bmap
-gc_B->cp_cp->y_u.Osblp.s / ((OPREG)sizeof(CELL)),
gc_B->cp_cp->y_u.Osblp.bmap
PASS_REGS);
} else {
/* choicepoint with arguments */
@ -2107,10 +2094,10 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose
}
B = old_b;
}
nargs = rtp->u.OtapFs.s+rtp->u.OtapFs.extra;
nargs = rtp->y_u.OtapFs.s+rtp->y_u.OtapFs.extra;
break;
case _jump:
rtp = rtp->u.l.l;
rtp = rtp->y_u.l.l;
op = rtp->opc;
opnum = Yap_op_from_opcode(op);
goto restart_cp;
@ -2144,7 +2131,7 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose
{
CELL *vars_ptr, vars;
vars_ptr = (CELL *)(GEN_CP(gc_B) + 1);
nargs = rtp->u.Otapl.s;
nargs = rtp->y_u.Otapl.s;
while (nargs--) {
mark_external_reference(vars_ptr PASS_REGS);
vars_ptr++;
@ -2307,15 +2294,15 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose
on the other hand it's the only way we can be sure we can reclaim
space
*/
yamop *end = rtp->u.OtaLl.n;
yamop *end = rtp->y_u.OtaLl.n;
while (end->opc != trust_lu &&
end->opc != count_trust_lu &&
end->opc != profiled_trust_lu )
end = end->u.OtaLl.n;
mark_ref_in_use((DBRef)end->u.OtILl.block PASS_REGS);
end = end->y_u.OtaLl.n;
mark_ref_in_use((DBRef)end->y_u.OtILl.block PASS_REGS);
}
/* mark timestamp */
nargs = rtp->u.OtaLl.s+1;
nargs = rtp->y_u.OtaLl.s+1;
break;
case _count_retry_logical:
{
@ -2324,13 +2311,13 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose
on the other hand it's the only way we can be sure we can reclaim
space
*/
yamop *end = rtp->u.OtaLl.n;
yamop *end = rtp->y_u.OtaLl.n;
while (Yap_op_from_opcode(end->opc) != _count_trust_logical)
end = end->u.OtaLl.n;
mark_ref_in_use((DBRef)end->u.OtILl.block PASS_REGS);
end = end->y_u.OtaLl.n;
mark_ref_in_use((DBRef)end->y_u.OtILl.block PASS_REGS);
}
/* mark timestamp */
nargs = rtp->u.OtaLl.s+1;
nargs = rtp->y_u.OtaLl.s+1;
break;
case _profiled_retry_logical:
{
@ -2339,28 +2326,28 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose
on the other hand it's the only way we can be sure we can reclaim
space
*/
yamop *end = rtp->u.OtaLl.n;
yamop *end = rtp->y_u.OtaLl.n;
while (Yap_op_from_opcode(end->opc) != _profiled_trust_logical)
end = end->u.OtaLl.n;
mark_ref_in_use((DBRef)end->u.OtILl.block PASS_REGS);
end = end->y_u.OtaLl.n;
mark_ref_in_use((DBRef)end->y_u.OtILl.block PASS_REGS);
}
/* mark timestamp */
nargs = rtp->u.OtaLl.s+1;
nargs = rtp->y_u.OtaLl.s+1;
break;
case _trust_logical:
case _count_trust_logical:
case _profiled_trust_logical:
/* mark timestamp */
mark_ref_in_use((DBRef)rtp->u.OtILl.block PASS_REGS);
nargs = rtp->u.OtILl.d->ClPred->ArityOfPE+1;
mark_ref_in_use((DBRef)rtp->y_u.OtILl.block PASS_REGS);
nargs = rtp->y_u.OtILl.d->ClPred->ArityOfPE+1;
break;
case _retry_exo:
case _retry_exo_udi:
case _retry_all_exo:
nargs = rtp->u.lp.p->ArityOfPE;
nargs = rtp->y_u.lp.p->ArityOfPE;
break;
case _retry_udi:
nargs = rtp->u.p.p->ArityOfPE;
nargs = rtp->y_u.p.p->ArityOfPE;
break;
#ifdef DEBUG
case _retry_me:
@ -2375,14 +2362,14 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose
fprintf(stderr,"OOPS in GC: gc not supported in this case!!!\n");
exit(1);
}
nargs = rtp->u.Otapl.s;
nargs = rtp->y_u.Otapl.s;
break;
default:
fprintf(stderr, "OOPS in GC: Unexpected opcode: %d\n", opnum);
nargs = 0;
#else
default:
nargs = rtp->u.Otapl.s;
nargs = rtp->y_u.Otapl.s;
#endif
}
@ -2399,8 +2386,8 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose
pt->opc != count_trust_lu &&
pt->opc != profiled_trust_lu
)
pt = pt->u.OtaLl.n;
mark_ref_in_use((DBRef)pt->u.OtILl.block PASS_REGS);
pt = pt->y_u.OtaLl.n;
mark_ref_in_use((DBRef)pt->y_u.OtILl.block PASS_REGS);
}
}
/* for each saved register */
@ -3050,8 +3037,8 @@ sweep_choicepoints(choiceptr gc_B USES_REGS)
case _or_last:
sweep_environments((CELL_PTR)(gc_B->cp_a1),
-gc_B->cp_cp->u.Osblp.s / ((OPREG)sizeof(CELL)),
gc_B->cp_cp->u.Osblp.bmap
-gc_B->cp_cp->y_u.Osblp.s / ((OPREG)sizeof(CELL)),
gc_B->cp_cp->y_u.Osblp.bmap
PASS_REGS);
break;
case _retry_profiled:
@ -3061,7 +3048,7 @@ sweep_choicepoints(choiceptr gc_B USES_REGS)
opnum = Yap_op_from_opcode(op);
goto restart_cp;
case _jump:
rtp = rtp->u.l.l;
rtp = rtp->y_u.l.l;
op = rtp->opc;
opnum = Yap_op_from_opcode(op);
goto restart_cp;
@ -3094,7 +3081,7 @@ sweep_choicepoints(choiceptr gc_B USES_REGS)
CELL *vars_ptr, vars;
sweep_environments(gc_B->cp_env, EnvSize(gc_B->cp_cp), EnvBMap(gc_B->cp_cp) PASS_REGS);
vars_ptr = (CELL *)(GEN_CP(gc_B) + 1);
nargs = rtp->u.Otapl.s;
nargs = rtp->y_u.Otapl.s;
while(nargs--) {
CELL cp_cell = *vars_ptr;
if (MARKED_PTR(vars_ptr)) {
@ -3288,12 +3275,12 @@ sweep_choicepoints(choiceptr gc_B USES_REGS)
case _count_retry_logical:
case _profiled_retry_logical:
/* sweep timestamp */
sweep_b(gc_B, rtp->u.OtaLl.s+1 PASS_REGS);
sweep_b(gc_B, rtp->y_u.OtaLl.s+1 PASS_REGS);
break;
case _trust_logical:
case _count_trust_logical:
case _profiled_trust_logical:
sweep_b(gc_B, rtp->u.OtILl.d->ClPred->ArityOfPE+1 PASS_REGS);
sweep_b(gc_B, rtp->y_u.OtILl.d->ClPred->ArityOfPE+1 PASS_REGS);
break;
case _retry2:
sweep_b(gc_B, 2 PASS_REGS);
@ -3305,12 +3292,12 @@ sweep_choicepoints(choiceptr gc_B USES_REGS)
sweep_b(gc_B, 4 PASS_REGS);
break;
case _retry_udi:
sweep_b(gc_B, rtp->u.p.p->ArityOfPE PASS_REGS);
sweep_b(gc_B, rtp->y_u.p.p->ArityOfPE PASS_REGS);
break;
case _retry_exo:
case _retry_exo_udi:
case _retry_all_exo:
sweep_b(gc_B, rtp->u.lp.p->ArityOfPE PASS_REGS);
sweep_b(gc_B, rtp->y_u.lp.p->ArityOfPE PASS_REGS);
break;
case _retry_c:
case _retry_userc:
@ -3318,8 +3305,8 @@ sweep_choicepoints(choiceptr gc_B USES_REGS)
register CELL_PTR saved_reg;
/* for each extra saved register */
for (saved_reg = &(gc_B->cp_a1)+rtp->u.OtapFs.s;
saved_reg < &(gc_B->cp_a1)+rtp->u.OtapFs.s+rtp->u.OtapFs.extra;
for (saved_reg = &(gc_B->cp_a1)+rtp->y_u.OtapFs.s;
saved_reg < &(gc_B->cp_a1)+rtp->y_u.OtapFs.s+rtp->y_u.OtapFs.extra;
saved_reg++) {
CELL cp_cell = *saved_reg;
if (MARKED_PTR(saved_reg)) {
@ -3332,7 +3319,7 @@ sweep_choicepoints(choiceptr gc_B USES_REGS)
}
/* continue to clean environments and arguments */
default:
sweep_b(gc_B,rtp->u.Otapl.s PASS_REGS);
sweep_b(gc_B,rtp->y_u.Otapl.s PASS_REGS);
}
/* link to prev choicepoint */

812
C/index.c

File diff suppressed because it is too large Load Diff

115
C/init.c
View File

@ -121,7 +121,7 @@ Yap_IsOpType(char *type)
}
static int
OpDec(int p, char *type, Atom a, Term m)
OpDec(int p, const char *type, Atom a, Term m)
{
int i;
AtomEntry *ae = RepAtom(a);
@ -399,7 +399,7 @@ update_flags_from_prolog(UInt flags, PredEntry *pe)
}
void
Yap_InitCPred(char *Name, unsigned long int Arity, CPredicate code, UInt flags)
Yap_InitCPred(const char *Name, UInt Arity, CPredicate code, UInt flags)
{
CACHE_REGS
Atom atom = NIL;
@ -483,27 +483,27 @@ Yap_InitCPred(char *Name, unsigned long int Arity, CPredicate code, UInt flags)
p_code->opc = Yap_opcode(_call_usercpred);
else
p_code->opc = Yap_opcode(_call_cpred);
p_code->u.Osbpp.bmap = NULL;
p_code->u.Osbpp.s = -Signed(RealEnvSize);
p_code->u.Osbpp.p =
p_code->u.Osbpp.p0 =
p_code->y_u.Osbpp.bmap = NULL;
p_code->y_u.Osbpp.s = -Signed(RealEnvSize);
p_code->y_u.Osbpp.p =
p_code->y_u.Osbpp.p0 =
pe;
p_code = NEXTOP(p_code,Osbpp);
if (!(flags & SafePredFlag)) {
p_code->opc = Yap_opcode(_deallocate);
p_code->u.p.p = pe;
p_code->y_u.p.p = pe;
p_code = NEXTOP(p_code,p);
}
p_code->opc = Yap_opcode(_procceed);
p_code->u.p.p = pe;
p_code->y_u.p.p = pe;
p_code = NEXTOP(p_code,p);
p_code->opc = Yap_opcode(_Ystop);
p_code->u.l.l = cl->ClCode;
p_code->y_u.l.l = cl->ClCode;
pe->OpcodeOfPred = pe->CodeOfPred->opc;
}
void
Yap_InitCmpPred(char *Name, unsigned long int Arity, CmpPredicate cmp_code, UInt flags)
Yap_InitCmpPred(const char *Name, UInt Arity, CmpPredicate cmp_code, UInt flags)
{
CACHE_REGS
Atom atom = NIL;
@ -567,21 +567,21 @@ Yap_InitCmpPred(char *Name, unsigned long int Arity, CmpPredicate cmp_code, UInt
pe->cs.d_code = cmp_code;
pe->ModuleOfPred = CurrentModule;
p_code->opc = pe->OpcodeOfPred = Yap_opcode(_call_bfunc_xx);
p_code->u.plxxs.p = pe;
p_code->u.plxxs.f = FAILCODE;
p_code->u.plxxs.x1 = Yap_emit_x(1);
p_code->u.plxxs.x2 = Yap_emit_x(2);
p_code->u.plxxs.flags = Yap_compile_cmp_flags(pe);
p_code->y_u.plxxs.p = pe;
p_code->y_u.plxxs.f = FAILCODE;
p_code->y_u.plxxs.x1 = Yap_emit_x(1);
p_code->y_u.plxxs.x2 = Yap_emit_x(2);
p_code->y_u.plxxs.flags = Yap_compile_cmp_flags(pe);
p_code = NEXTOP(p_code,plxxs);
p_code->opc = Yap_opcode(_procceed);
p_code->u.p.p = pe;
p_code->y_u.p.p = pe;
p_code = NEXTOP(p_code,p);
p_code->opc = Yap_opcode(_Ystop);
p_code->u.l.l = cl->ClCode;
p_code->y_u.l.l = cl->ClCode;
}
void
Yap_InitAsmPred(char *Name, unsigned long int Arity, int code, CPredicate def, UInt flags)
Yap_InitAsmPred(const char *Name, UInt Arity, int code, CPredicate def, UInt flags)
{
CACHE_REGS
Atom atom = NIL;
@ -655,20 +655,20 @@ Yap_InitAsmPred(char *Name, unsigned long int Arity, int code, CPredicate def,
p_code = NEXTOP(p_code,e);
}
p_code->opc = Yap_opcode(_call_cpred);
p_code->u.Osbpp.bmap = NULL;
p_code->u.Osbpp.s = -Signed(RealEnvSize);
p_code->u.Osbpp.p = p_code->u.Osbpp.p0 = pe;
p_code->y_u.Osbpp.bmap = NULL;
p_code->y_u.Osbpp.s = -Signed(RealEnvSize);
p_code->y_u.Osbpp.p = p_code->y_u.Osbpp.p0 = pe;
p_code = NEXTOP(p_code,Osbpp);
if (!(flags & SafePredFlag)) {
p_code->opc = Yap_opcode(_deallocate);
p_code->u.p.p = pe;
p_code->y_u.p.p = pe;
p_code = NEXTOP(p_code,p);
}
p_code->opc = Yap_opcode(_procceed);
p_code->u.p.p = pe;
p_code->y_u.p.p = pe;
p_code = NEXTOP(p_code,p);
p_code->opc = Yap_opcode(_Ystop);
p_code->u.l.l = cl->ClCode;
p_code->y_u.l.l = cl->ClCode;
pe->OpcodeOfPred = pe->CodeOfPred->opc;
} else {
pe->OpcodeOfPred = Yap_opcode(_undef_p);
@ -689,7 +689,7 @@ CleanBack(PredEntry *pe, CPredicate Start, CPredicate Cont, CPredicate Cut)
return;
}
code = (yamop *)(pe->cs.p_code.FirstClause);
code->u.OtapFs.p = pe;
code->y_u.OtapFs.p = pe;
if (pe->PredFlags & UserCPredFlag)
code->opc = Yap_opcode(_try_userc);
else
@ -698,7 +698,7 @@ CleanBack(PredEntry *pe, CPredicate Start, CPredicate Cont, CPredicate Cut)
INIT_YAMOP_LTT(code, 2);
PUT_YAMOP_SEQ(code);
#endif /* YAPOR */
code->u.OtapFs.f = Start;
code->y_u.OtapFs.f = Start;
code = NEXTOP(code,OtapFs);
if (pe->PredFlags & UserCPredFlag)
code->opc = Yap_opcode(_retry_userc);
@ -708,32 +708,32 @@ CleanBack(PredEntry *pe, CPredicate Start, CPredicate Cont, CPredicate Cut)
INIT_YAMOP_LTT(code, 1);
PUT_YAMOP_SEQ(code);
#endif /* YAPOR */
code->u.OtapFs.f = Cont;
code->y_u.OtapFs.f = Cont;
code = NEXTOP(code,OtapFs);
if (pe->PredFlags & UserCPredFlag)
code->opc = Yap_opcode(_cut_c);
else
code->opc = Yap_opcode(_cut_userc);
code->u.OtapFs.p = pe;
code->u.OtapFs.f = Cut;
code->y_u.OtapFs.p = pe;
code->y_u.OtapFs.f = Cut;
}
void
Yap_InitCPredBack(char *Name, unsigned long int Arity,
Yap_InitCPredBack(const char *Name, UInt Arity,
unsigned int Extra, CPredicate Start,
CPredicate Cont, UInt flags){
Yap_InitCPredBack_(Name,Arity,Extra,Start,Cont,NULL,flags);
}
void
Yap_InitCPredBackCut(char *Name, unsigned long int Arity,
Yap_InitCPredBackCut(const char *Name, UInt Arity,
unsigned int Extra, CPredicate Start,
CPredicate Cont,CPredicate Cut, UInt flags){
Yap_InitCPredBack_(Name,Arity,Extra,Start,Cont,Cut,flags);
}
void
Yap_InitCPredBack_(char *Name, unsigned long int Arity,
Yap_InitCPredBack_(const char *Name, UInt Arity,
unsigned int Extra, CPredicate Start,
CPredicate Cont, CPredicate Cut, UInt flags)
{
@ -776,6 +776,7 @@ Yap_InitCPredBack_(char *Name, unsigned long int Arity,
else {
StaticClause *cl;
yamop *code = ((StaticClause *)NULL)->ClCode;
UInt sz = (CELL)NEXTOP(NEXTOP(NEXTOP(NEXTOP(code,OtapFs),OtapFs),OtapFs),l);
if (flags & UserCPredFlag)
pe->PredFlags = UserCPredFlag | BackCPredFlag| CompiledPredFlag | StandardPredFlag | flags;
else
@ -785,7 +786,7 @@ Yap_InitCPredBack_(char *Name, unsigned long int Arity,
pe->PredFlags |= SequentialPredFlag;
#endif /* YAPOR */
cl = (StaticClause *)Yap_AllocCodeSpace((CELL)NEXTOP(NEXTOP(NEXTOP(NEXTOP(code,OtapFs),OtapFs),OtapFs),l));
cl = (StaticClause *)Yap_AllocCodeSpace(sz);
if (cl == NULL) {
Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"No Heap Space in InitCPredBack");
@ -793,7 +794,7 @@ Yap_InitCPredBack_(char *Name, unsigned long int Arity,
}
cl->ClFlags = StaticMask;
cl->ClNext = NULL;
Yap_ClauseSpace += (CELL)NEXTOP(NEXTOP(NEXTOP(NEXTOP(code,OtapFs),OtapFs),OtapFs),l);
Yap_ClauseSpace += sz;
cl->ClSize =
(CELL)NEXTOP(NEXTOP(NEXTOP(NEXTOP(code,OtapFs),OtapFs),OtapFs),e);
cl->usc.ClLine = Yap_source_line_no();
@ -805,10 +806,10 @@ Yap_InitCPredBack_(char *Name, unsigned long int Arity,
pe->OpcodeOfPred = code->opc = Yap_opcode(_try_userc);
else
pe->OpcodeOfPred = code->opc = Yap_opcode(_try_c);
code->u.OtapFs.f = Start;
code->u.OtapFs.p = pe;
code->u.OtapFs.s = Arity;
code->u.OtapFs.extra = Extra;
code->y_u.OtapFs.f = Start;
code->y_u.OtapFs.p = pe;
code->y_u.OtapFs.s = Arity;
code->y_u.OtapFs.extra = Extra;
#ifdef YAPOR
INIT_YAMOP_LTT(code, 2);
PUT_YAMOP_SEQ(code);
@ -818,10 +819,10 @@ Yap_InitCPredBack_(char *Name, unsigned long int Arity,
code->opc = Yap_opcode(_retry_userc);
else
code->opc = Yap_opcode(_retry_c);
code->u.OtapFs.f = Cont;
code->u.OtapFs.p = pe;
code->u.OtapFs.s = Arity;
code->u.OtapFs.extra = Extra;
code->y_u.OtapFs.f = Cont;
code->y_u.OtapFs.p = pe;
code->y_u.OtapFs.s = Arity;
code->y_u.OtapFs.extra = Extra;
#ifdef YAPOR
INIT_YAMOP_LTT(code, 1);
PUT_YAMOP_SEQ(code);
@ -831,13 +832,13 @@ Yap_InitCPredBack_(char *Name, unsigned long int Arity,
code->opc = Yap_opcode(_cut_userc);
else
code->opc = Yap_opcode(_cut_c);
code->u.OtapFs.f = Cut;
code->u.OtapFs.p = pe;
code->u.OtapFs.s = Arity;
code->u.OtapFs.extra = Extra;
code->y_u.OtapFs.f = Cut;
code->y_u.OtapFs.p = pe;
code->y_u.OtapFs.s = Arity;
code->y_u.OtapFs.extra = Extra;
code = NEXTOP(code,OtapFs);
code->opc = Yap_opcode(_Ystop);
code->u.l.l = cl->ClCode;
code->y_u.l.l = cl->ClCode;
}
}
@ -898,10 +899,10 @@ InitEnvInst(yamop start[2], yamop **instp, op_numbers opc, PredEntry *pred)
/* make it look like the instruction is preceeded by a call instruction */
ipc->opc = Yap_opcode(_call);
ipc->u.Osbpp.s = -Signed(RealEnvSize);
ipc->u.Osbpp.bmap = NULL;
ipc->u.Osbpp.p = pred;
ipc->u.Osbpp.p0 = pred;
ipc->y_u.Osbpp.s = -Signed(RealEnvSize);
ipc->y_u.Osbpp.bmap = NULL;
ipc->y_u.Osbpp.p = pred;
ipc->y_u.Osbpp.p0 = pred;
ipc = NEXTOP(ipc, Osbpp);
ipc->opc = Yap_opcode(opc);
*instp = ipc;
@ -914,14 +915,14 @@ InitOtaplInst(yamop start[1], OPCODE opc, PredEntry *pe)
/* this is a place holder, it should not really be used */
ipc->opc = Yap_opcode(opc);
ipc->u.Otapl.s = 0;
ipc->u.Otapl.p = pe;
ipc->u.Otapl.d = NULL;
ipc->y_u.Otapl.s = 0;
ipc->y_u.Otapl.p = pe;
ipc->y_u.Otapl.d = NULL;
#ifdef YAPOR
INIT_YAMOP_LTT(ipc, 1);
#endif /* YAPOR */
#ifdef TABLING
ipc->u.Otapl.te = NULL;
ipc->y_u.Otapl.te = NULL;
#endif /* TABLING */
}
@ -1182,8 +1183,8 @@ InitCodes(void)
modp->PredFlags |= MetaPredFlag;
}
#ifdef YAPOR
Yap_heap_regs->getwork_code->u.Otapl.p = RepPredProp(PredPropByAtom(AtomGetwork, PROLOG_MODULE));
Yap_heap_regs->getwork_seq_code->u.Otapl.p = RepPredProp(PredPropByAtom(AtomGetworkSeq, PROLOG_MODULE));
Yap_heap_regs->getwork_code->y_u.Otapl.p = RepPredProp(PredPropByAtom(AtomGetwork, PROLOG_MODULE));
Yap_heap_regs->getwork_seq_code->y_u.Otapl.p = RepPredProp(PredPropByAtom(AtomGetworkSeq, PROLOG_MODULE));
#endif /* YAPOR */
}

View File

@ -649,7 +649,7 @@ p_functor( USES_REGS1 ) /* functor(?,?,?) */
BEGP(pt0);
deref_body(d1, pt0, func_nvar_unk, func_nvar_nvar);
/* A2 is a variable, go and bind it */
Bind(pt0, d0);
YapBind(pt0, d0);
/* have to buffer ENDP and label */
d0 = arity;
ENDP(pt0);
@ -670,7 +670,7 @@ p_functor( USES_REGS1 ) /* functor(?,?,?) */
BEGP(pt0);
deref_body(d1, pt0, func_nvar3_unk, func_nvar3_nvar);
/* A3 is a variable, go and bind it */
Bind(pt0, d0);
YapBind(pt0, d0);
return(TRUE);
ENDP(pt0);
@ -748,7 +748,7 @@ p_functor( USES_REGS1 ) /* functor(?,?,?) */
}
/* else if arity is 0 just pass d0 through */
/* Ding, ding, we made it */
Bind(pt0, d0);
YapBind(pt0, d0);
return(TRUE);
@ -923,7 +923,7 @@ p_save_cp( USES_REGS1 )
#endif
if (!IsVarTerm(t)) return(FALSE);
td = cp_as_integer(B PASS_REGS);
Bind((CELL *)t,td);
YapBind((CELL *)t,td);
return(TRUE);
}

View File

@ -484,14 +484,13 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
{
CACHE_REGS
TokEntry *tokstart;
Term t, v;
Term t;
Term OCurrentModule = CurrentModule, tmod, tpos;
int store_comments = rd->comments;
if (inp_stream == NULL) {
return FALSE;
}
CurrentModule = tmod = MkAtomTerm(rd->module->AtomOfME);
LOCAL_Error_TYPE = YAP_NO_ERROR;
while (TRUE) {
CELL *old_H;
@ -558,7 +557,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
}
}
repeat_cycle:
CurrentModule = tmod;
CurrentModule = tmod = MkAtomTerm(rd->module->AtomOfME);
if (LOCAL_ErrorMessage || (t = Yap_Parse(rd)) == 0) {
CurrentModule = OCurrentModule;
if (LOCAL_ErrorMessage) {
@ -601,6 +600,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
rd->has_exception = TRUE;
rd->exception = Yap_InitSlot(terror PASS_REGS);
CurrentModule = OCurrentModule;
return FALSE;
}
} else {
@ -614,6 +614,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
if (store_comments && !Yap_unify(LOCAL_Comments, Yap_GetFromSlot( rd->comments PASS_REGS)))
return FALSE;
if (rd->varnames) {
Term v;
while (TRUE) {
CELL *old_H = HR;
@ -633,11 +634,14 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
TR = old_TR;
}
}
if (!Yap_unify(v, Yap_GetFromSlot( rd->varnames PASS_REGS)))
if (!Yap_unify(v, Yap_GetFromSlot( rd->varnames PASS_REGS))) {
CurrentModule = OCurrentModule;
return FALSE;
}
}
if (rd->variables) {
Term v;
while (TRUE) {
CELL *old_H = HR;
@ -657,10 +661,13 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
TR = old_TR;
}
}
if (!Yap_unify(v, Yap_GetFromSlot( rd->variables PASS_REGS)))
if (!Yap_unify(v, Yap_GetFromSlot( rd->variables PASS_REGS))) {
CurrentModule = OCurrentModule;
return FALSE;
}
}
if (rd->singles) {
Term v;
while (TRUE) {
CELL *old_H = HR;
@ -686,11 +693,14 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
else
rd->singles = FALSE;
} else if (rd->singles) {
if (!Yap_unify( rd->singles, Yap_GetFromSlot( v PASS_REGS )))
return FALSE;
if (!Yap_unify( v, Yap_GetFromSlot( rd->singles PASS_REGS ))) {
CurrentModule = OCurrentModule;
return FALSE;
}
}
}
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
CurrentModule = OCurrentModule;
return TRUE;
}
@ -955,10 +965,8 @@ p_write_string( USES_REGS1 )
int encoding;
char buf[256];
if ((s = Yap_TermToString( in, NULL, 0, &length, &encoding, 0)))
fprintf(stderr,"%ld %s\n",length, s);
if ((s = Yap_TermToString( in, buf, 256, &length, &encoding, 0)))
fprintf(stderr,"%ld %s\n",length, s);
fprintf(stderr,"%s\n", s);
return TRUE;
}
#endif

View File

@ -121,7 +121,7 @@ LookupModule(Term a )
/* prolog module */
if (a == 0) {
return GetModuleEntry(AtomProlog);
return GetModuleEntry(AtomUser);
}
at = AtomOfTerm(a);
me = GetModuleEntry(at);
@ -263,6 +263,62 @@ p_strip_module( USES_REGS1 )
Yap_unify(ARG2, tmod);
}
static Term
Yap_YapStripModule(Term t, Term *modp)
{
CACHE_REGS
Term tmod;
if (modp)
tmod = *modp;
else {
tmod = CurrentModule;
if (tmod == PROLOG_MODULE) {
tmod = TermProlog;
}
}
restart:
if (IsVarTerm(t) || !IsApplTerm(t)) {
if (modp)
*modp = tmod;
return t;
} else {
Functor fun = FunctorOfTerm(t);
if (fun == FunctorModule) {
Term t1 = ArgOfTerm(1, t);
tmod = t1;
if (!IsVarTerm(tmod) && !IsAtomTerm(tmod) ) {
return 0L;
}
t = ArgOfTerm(2, t);
goto restart;
}
if (modp)
*modp = tmod;
return t;
}
return 0L;
}
static Int
p_yap_strip_module( USES_REGS1 )
{
Term t1 = Deref(ARG1), tmod = CurrentModule;
if (tmod == PROLOG_MODULE) {
tmod = TermProlog;
}
t1 = Yap_YapStripModule( t1, &tmod );
if (!t1) {
Yap_Error(TYPE_ERROR_CALLABLE,ARG1,"trying to obtain module");
return FALSE;
}
return Yap_unify(ARG3, t1) &&
Yap_unify(ARG2, tmod);
}
static Int
p_context_module( USES_REGS1 )
{
@ -335,6 +391,7 @@ Yap_InitModulesC(void)
Yap_InitCPred("$current_module", 1, p_current_module1, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$change_module", 1, p_change_module, SafePredFlag|SyncPredFlag);
Yap_InitCPred("strip_module", 3, p_strip_module, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$yap_strip_module", 3, p_yap_strip_module, SafePredFlag|SyncPredFlag);
Yap_InitCPred("context_module", 1, p_context_module, 0);
Yap_InitCPredBack("$all_current_modules", 1, 1, init_current_module, cont_current_module,
SafePredFlag|SyncPredFlag);

View File

@ -8,23 +8,17 @@
#include "Yatom.h"
#include "pl-incl.h"
#include "YapText.h"
#include "yapio.h"
#if HAVE_MATH_H
#include <math.h>
#endif
#define Quote_illegal_f 1
#define Ignore_ops_f 2
#define Handle_vars_f 4
#define Use_portray_f 8
#define To_heap_f 16
#define Unfold_cyclics_f 32
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#define LOCK() PL_LOCK(L_PLFLAG)
#define UNLOCK() PL_UNLOCK(L_PLFLAG)
//#define LOCK() PL_LOCK(L_PLFLAG)
//#define UNLOCK() PL_UNLOCK(L_PLFLAG)
int fileerrors;
@ -649,7 +643,7 @@ numberVars(term_t t, nv_options *opts, int n ARG_LD) {
* PROMOTION *
*******************************/
static int
int
check_float(double f)
{
#ifdef HAVE_FPCLASSIFY
@ -795,7 +789,6 @@ PL_unify_wchars_diff(term_t t, term_t tail, int flags,
if ( len == (size_t)-1 )
len = wcslen(s);
text.text.w = (pl_wchar_t *)s;
text.encoding = ENC_WCHAR;
text.storage = PL_CHARS_HEAP;
@ -856,8 +849,6 @@ PL_get_chars(term_t t, char **s, unsigned flags)
{ return PL_get_nchars(t, NULL, s, flags);
}
char *Yap_TermToString(Term t, char *s, size_t sz, size_t *length, int *encoding, int flags);
char *
Yap_TermToString(Term t, char *s, size_t sz, size_t *length, int *encoding, int flags)
{
@ -921,6 +912,39 @@ Yap_TermToString(Term t, char *s, size_t sz, size_t *length, int *encoding, int
return NULL;
}
char *
Yap_HandleToString(term_t l, size_t sz, size_t *length, int *encoding, int flags)
{
char *r, buf[4096];
int64_t size;
IOSTREAM *fd;
r = buf;
fd = Sopenmem(&r, &sz, "w");
fd->encoding = ENC_UTF8;
if ( PL_write_term(fd, l, 1200, flags) &&
Sputcode(EOS, fd) >= 0 &&
Sflush(fd) >= 0 )
{
size = Stell64(fd);
*length = size-1;
char *bf = malloc(*length+1);
if (!bf)
return NULL;
strncpy(bf,buf,*length+1);
Sclose(fd);
r = bf;
return r;
}
/* failed */
if ( r != buf ) {
Sfree(r);
}
return NULL;
}
X_API int
PL_ttymode(IOSTREAM *s)
@ -1185,12 +1209,13 @@ static int thread_highest_id = 0;
X_API int
PL_w32thread_raise(DWORD id, int sig)
{ int i;
CACHE_REGS
if ( sig < 0 || sig > MAXSIGNAL )
return FALSE; /* illegal signal */
LOCK();
LOCK(LOCAL_SignalLock);
PL_LOCK(L_PLFLAG);
// LOCK(LOCAL_SignalLock);
for(i = 0; i <= thread_highest_id; i++)
{ PL_thread_info_t *info = GD->thread.threads[i];
@ -1200,14 +1225,14 @@ PL_w32thread_raise(DWORD id, int sig)
Yap_external_signal(i, sig); //raiseSignal(info->thread_data, sig);
if ( info->w32id )
PostThreadMessage(info->w32id, WM_SIGNALLED, 0, 0L);
UNLOCK(LOCAL_SignalLock);
UNLOCK();
//UNLOCK(LOCAL_SignalLock);
PL_UNLOCK(L_PLFLAG);
DEBUG(1, Sdprintf("Signalled %d to thread %d\n", sig, i));
return TRUE;
}
}
UNLOCK(LOCAL_SignalLock);
UNLOCK();
// UNLOCK(LOCAL_SignalLock);
PL_UNLOCK(L_PLFLAG);
return FALSE; /* can't find thread */
}

View File

@ -16,8 +16,8 @@
* *
*************************************************************************/
#include <SWI-Stream.h>
#include "absmi.h"
#include <SWI-Stream.h>
#include "Foreign.h"
#include "alloc.h"
#include "yapio.h"
@ -968,8 +968,9 @@ read_pred(IOSTREAM *stream, Term mod) {
}
ap->TimeStampOfPred = read_uint(stream);
/* multifile predicates cannot reside in module 0 */
if (flags & MultiFileFlag && ap->ModuleOfPred == PROLOG_MODULE)
if (flags & MultiFileFlag && ap->ModuleOfPred == PROLOG_MODULE) {
ap->ModuleOfPred = TermProlog;
}
read_clauses(stream, ap, nclauses, flags);
if (flags & HiddenPredFlag) {
Yap_HidePred(ap);
@ -1005,7 +1006,6 @@ read_module(IOSTREAM *stream) {
ReadHash(stream);
while ((x = read_tag(stream)) == QLY_START_MODULE) {
Term mod = (Term)read_uint(stream);
mod = MkAtomTerm(AtomAdjust(AtomOfTerm(mod)));
if (mod)
while ((x = read_tag(stream)) == QLY_START_PREDICATE) {
@ -1054,7 +1054,6 @@ static Int
p_read_program( USES_REGS1 )
{
IOSTREAM *stream;
void YAP_Reset(void);
Term t1 = Deref(ARG1);
if (IsVarTerm(t1)) {

View File

@ -16,8 +16,8 @@
* *
*************************************************************************/
#include <SWI-Stream.h>
#include "absmi.h"
#include <SWI-Stream.h>
#include "Foreign.h"
#include "alloc.h"
#include "yapio.h"
@ -335,7 +335,7 @@ InitHash(void)
LOCAL_ExportFunctorHashChain = (export_functor_hash_entry_t *)calloc(LOCAL_ExportFunctorHashTableSize, sizeof(export_functor_hash_entry_t ));
LOCAL_ExportAtomHashTableNum = 0;
LOCAL_ExportAtomHashTableSize = EXPORT_ATOM_TABLE_SIZE;
LOCAL_ExportAtomHashChain = (export_atom_hash_entry_t *)calloc( LOCAL_ExportAtomHashTableSize, sizeof(export_atom_hash_entry_t *));
LOCAL_ExportAtomHashChain = (export_atom_hash_entry_t *)calloc( LOCAL_ExportAtomHashTableSize, sizeof(export_atom_hash_entry_t));
LOCAL_ExportPredEntryHashTableNum = 0;
LOCAL_ExportPredEntryHashTableSize = EXPORT_PRED_ENTRY_TABLE_SIZE;
LOCAL_ExportPredEntryHashChain = (export_pred_entry_hash_entry_t *)calloc(LOCAL_ExportPredEntryHashTableSize, sizeof(export_pred_entry_hash_entry_t));

View File

@ -19,6 +19,7 @@ static char SccsId[] = "@(#)save.c 1.3 3/15/90";
#endif
#include "config.h"
#include "absmi.h"
#include "SWI-Stream.h"
#if _MSC_VER || defined(__MINGW32__)
#if HAVE_WINSOCK2_H
@ -27,7 +28,6 @@ static char SccsId[] = "@(#)save.c 1.3 3/15/90";
#include <windows.h>
#include <psapi.h>
#endif
#include "absmi.h"
#include "alloc.h"
#if USE_DL_MALLOC
#include "dlmalloc.h"
@ -247,6 +247,19 @@ open_file(char *my_file, int flag)
{
int splfild;
#if __ANDROID__
if (strstr(my_file, "/assets/") == my_file) {
if (flag == O_RDONLY) {
my_file += strlen("/assets/");
AAsset* asset = AAssetManager_open(GLOBAL_assetManager, my_file, AASSET_MODE_UNKNOWN);
if (!asset)
return -1;
AAsset_close( asset );
return 0; // usually the file will be compressed, so there is no point in actually trying to open it.
}
return -1;
}
#endif
#ifdef M_WILLIAMS
if (flag & O_CREAT)
splfild = creat(my_file, flag);
@ -1291,9 +1304,9 @@ RestoreHashPreds( USES_REGS1 )
UInt i;
PredEntry **oldp = PredHash;
np = (PredEntry **) Yap_AllocAtomSpace(sizeof(PredEntry **)*size);
np = (PredEntry **) Yap_AllocAtomSpace(sizeof(PredEntry *)*size);
if (!np) {
if (!(np = (PredEntry **) malloc(sizeof(PredEntry **)*size))) {
if (!(np = (PredEntry **) malloc(sizeof(PredEntry *)*size))) {
Yap_Error(FATAL_ERROR,TermNil,"Could not allocate space for pred table");
return;
}
@ -1453,6 +1466,10 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac
int mode = FAIL_RESTORE;
char save_buffer[YAP_FILENAME_MAX+1];
#if __ANDROID__
if (!inpf)
inpf = YAPSTARTUP;
#endif
save_buffer[0] = '\0';
// LOCAL_ErrorMessage = NULL;
if (inpf == NULL) {
@ -1473,9 +1490,11 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac
strncat(LOCAL_FileNameBuf, "/", YAP_FILENAME_MAX-1);
strncat(LOCAL_FileNameBuf, inpf, YAP_FILENAME_MAX-1);
} else {
strncat(LOCAL_FileNameBuf, inpf, YAP_FILENAME_MAX-1);
strncpy(LOCAL_FileNameBuf, inpf, YAP_FILENAME_MAX-1);
}
if (inpf != NULL && !((splfild = open_file(inpf, O_RDONLY)) < 0)) {
if (inpf != NULL &&
!((splfild = open_file(inpf, O_RDONLY)) < 0))
{
if ((mode = try_open(inpf,Astate,ATrail,AStack,AHeap,save_buffer,streamp)) != FAIL_RESTORE) {
return mode;
}
@ -1517,7 +1536,7 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac
}
#if _MSC_VER || defined(__MINGW32__)
if ((inpf = Yap_RegistryGetString("startup"))) {
if (!((splfild = open_file(inpf, O_RDONLY)) < 0)) {
if (!((splfild = Sopen_file(inpf, "r")) < 0)) {
if ((mode = try_open(inpf,Astate,ATrail,AStack,AHeap,save_buffer,streamp)) != FAIL_RESTORE) {
return mode;
}

View File

@ -294,8 +294,8 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
int ch;
/* escape sequence */
ch = getchrq(inp_stream);
do_switch:
ch = getchrq(inp_stream);
switch (ch) {
case 10:
return 0;
@ -307,7 +307,12 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
return '\b';
case 'c':
while (chtype((ch = getchrq(inp_stream))) == BS);
goto do_switch;
{
if (ch == '\\') {
goto do_switch;
}
return ch;
}
case 'd':
return 127;
case 'e':

View File

@ -310,10 +310,6 @@ static Int cont_current_op( USES_REGS1 );
static Int init_current_atom_op( USES_REGS1 );
static Int cont_current_atom_op( USES_REGS1 );
static Int p_flags( USES_REGS1 );
static int AlreadyHidden(char *);
static Int p_hide( USES_REGS1 );
static Int p_hidden( USES_REGS1 );
static Int p_unhide( USES_REGS1 );
static Int TrailMax(void);
static Int GlobalMax(void);
static Int LocalMax(void);
@ -840,7 +836,7 @@ cont_current_predicate_for_atom( USES_REGS1 )
FunctorEntry *pp = RepFunctorProp(pf);
if (IsFunctorProperty(pp->KindOfPE)) {
Prop p0;
READ_LOCK(pp->FRWLock);
FUNC_READ_LOCK(pp);
p0 = pp->PropsOfFE;
if (p0) {
PredEntry *p = RepPredProp(p0);
@ -849,7 +845,7 @@ cont_current_predicate_for_atom( USES_REGS1 )
UInt ar = p->ArityOfPE;
/* we found the predicate */
EXTRA_CBACK_ARG(3,1) = MkIntegerTerm((Int)(pp->NextOfPE));
READ_UNLOCK(pp->FRWLock);
FUNC_READ_UNLOCK(pp);
return
Yap_unify(ARG3,MkIntegerTerm(ar));
} else if (p->NextOfPE) {
@ -862,7 +858,7 @@ cont_current_predicate_for_atom( USES_REGS1 )
p->ModuleOfPred == mod)
{
READ_UNLOCK(PredHashRWLock);
READ_UNLOCK(pp->FRWLock);
FUNC_READ_UNLOCK(pp);
/* we found the predicate */
EXTRA_CBACK_ARG(3,1) = MkIntegerTerm((Int)(p->NextOfPE));
return Yap_unify(ARG3,MkIntegerTerm(p->ArityOfPE));
@ -871,7 +867,7 @@ cont_current_predicate_for_atom( USES_REGS1 )
}
}
}
READ_UNLOCK(pp->FRWLock);
FUNC_READ_UNLOCK(pp);
} else if (pp->KindOfPE == PEProp) {
PredEntry *pe = RepPredProp(pf);
PELOCK(31,pe);
@ -1170,117 +1166,6 @@ p_set_flag( USES_REGS1 )
return TRUE;
}
static int
AlreadyHidden(char *name)
{
AtomEntry *chain;
READ_LOCK(INVISIBLECHAIN.AERWLock);
chain = RepAtom(INVISIBLECHAIN.Entry);
READ_UNLOCK(INVISIBLECHAIN.AERWLock);
while (!EndOfPAEntr(chain) && strcmp(chain->StrOfAE, name) != 0)
chain = RepAtom(chain->NextOfAE);
if (EndOfPAEntr(chain))
return (FALSE);
return (TRUE);
}
static Int
p_hide( USES_REGS1 )
{ /* hide(+Atom) */
Atom atomToInclude;
Term t1 = Deref(ARG1);
if (IsVarTerm(t1)) {
Yap_Error(INSTANTIATION_ERROR,t1,"hide/1");
return(FALSE);
}
if (!IsAtomTerm(t1)) {
Yap_Error(TYPE_ERROR_ATOM,t1,"hide/1");
return(FALSE);
}
atomToInclude = AtomOfTerm(t1);
if (AlreadyHidden(RepAtom(atomToInclude)->StrOfAE)) {
Yap_Error(SYSTEM_ERROR,t1,"an atom of name %s was already hidden",
RepAtom(atomToInclude)->StrOfAE);
return(FALSE);
}
Yap_ReleaseAtom(atomToInclude);
WRITE_LOCK(INVISIBLECHAIN.AERWLock);
WRITE_LOCK(RepAtom(atomToInclude)->ARWLock);
RepAtom(atomToInclude)->NextOfAE = INVISIBLECHAIN.Entry;
WRITE_UNLOCK(RepAtom(atomToInclude)->ARWLock);
INVISIBLECHAIN.Entry = atomToInclude;
WRITE_UNLOCK(INVISIBLECHAIN.AERWLock);
return (TRUE);
}
static Int
p_hidden( USES_REGS1 )
{ /* '$hidden'(+F) */
Atom at;
AtomEntry *chain;
Term t1 = Deref(ARG1);
if (IsVarTerm(t1))
return (FALSE);
if (IsAtomTerm(t1))
at = AtomOfTerm(t1);
else if (IsApplTerm(t1))
at = NameOfFunctor(FunctorOfTerm(t1));
else
return (FALSE);
READ_LOCK(INVISIBLECHAIN.AERWLock);
chain = RepAtom(INVISIBLECHAIN.Entry);
while (!EndOfPAEntr(chain) && AbsAtom(chain) != at)
chain = RepAtom(chain->NextOfAE);
READ_UNLOCK(INVISIBLECHAIN.AERWLock);
if (EndOfPAEntr(chain))
return (FALSE);
return (TRUE);
}
static Int
p_unhide( USES_REGS1 )
{ /* unhide(+Atom) */
AtomEntry *atom, *old, *chain;
Term t1 = Deref(ARG1);
if (IsVarTerm(t1)) {
Yap_Error(INSTANTIATION_ERROR,t1,"unhide/1");
return(FALSE);
}
if (!IsAtomTerm(t1)) {
Yap_Error(TYPE_ERROR_ATOM,t1,"unhide/1");
return(FALSE);
}
atom = RepAtom(AtomOfTerm(t1));
WRITE_LOCK(atom->ARWLock);
if (atom->PropsOfAE != NIL) {
Yap_Error(SYSTEM_ERROR,t1,"cannot unhide an atom in use");
return(FALSE);
}
WRITE_LOCK(INVISIBLECHAIN.AERWLock);
chain = RepAtom(INVISIBLECHAIN.Entry);
old = NIL;
while (!EndOfPAEntr(chain) && strcmp(chain->StrOfAE, atom->StrOfAE) != 0) {
old = chain;
chain = RepAtom(chain->NextOfAE);
}
if (EndOfPAEntr(chain))
return (FALSE);
atom->PropsOfAE = chain->PropsOfAE;
if (old == NIL)
INVISIBLECHAIN.Entry = chain->NextOfAE;
else
old->NextOfAE = chain->NextOfAE;
WRITE_UNLOCK(INVISIBLECHAIN.AERWLock);
WRITE_UNLOCK(atom->ARWLock);
return (TRUE);
}
void
Yap_show_statistics(void)
{
@ -2035,10 +1920,6 @@ Yap_InitCPreds(void)
/* Accessing and changing the flags for a predicate */
Yap_InitCPred("$flags", 4, p_flags, SyncPredFlag);
Yap_InitCPred("$set_flag", 4, p_set_flag, SyncPredFlag);
/* hiding and unhiding some predicates */
Yap_InitCPred("hide", 1, p_hide, SafePredFlag|SyncPredFlag);
Yap_InitCPred("unhide", 1, p_unhide, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$hidden", 1, p_hidden, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$has_yap_or", 0, p_has_yap_or, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$has_eam", 0, p_has_eam, SafePredFlag|SyncPredFlag);
#ifndef YAPOR

View File

@ -1110,6 +1110,66 @@ Yap_random (void)
#endif
}
#if HAVE_RANDOM
static Int
p_init_random_state ( USES_REGS1 )
{
register Term t0 = Deref (ARG1);
char *old, *new;
if (IsVarTerm (t0)) {
return(Yap_unify(ARG1,MkIntegerTerm((Int)current_seed)));
}
if(!IsNumTerm (t0))
return (FALSE);
if (IsIntTerm (t0))
current_seed = (unsigned int) IntOfTerm (t0);
else if (IsFloatTerm (t0))
current_seed = (unsigned int) FloatOfTerm (t0);
else
current_seed = (unsigned int) LongIntOfTerm (t0);
new = (char *) malloc(256);
old = initstate(random(), new, 256);
return Yap_unify(ARG2, MkIntegerTerm((Int)old)) &&
Yap_unify(ARG3, MkIntegerTerm((Int)new));
}
static Int
p_set_random_state ( USES_REGS1 )
{
register Term t0 = Deref (ARG1);
char *old, * new;
if (IsVarTerm (t0)) {
return FALSE;
}
if (IsIntegerTerm (t0))
new = (char *) IntegerOfTerm (t0);
else
return FALSE;
old = setstate( new );
return Yap_unify(ARG2, MkIntegerTerm((Int)old));
}
static Int
p_release_random_state ( USES_REGS1 )
{
register Term t0 = Deref (ARG1);
char *old;
if (IsVarTerm (t0)) {
return FALSE;
}
if (IsIntegerTerm (t0))
old = (char *) IntegerOfTerm (t0);
else
return FALSE;
free( old );
return TRUE;
}
#endif
static Int
p_srandom ( USES_REGS1 )
{
@ -1657,15 +1717,23 @@ ReceiveSignal (int s, void *x, void *y)
#if (_MSC_VER || defined(__MINGW32__))
static BOOL WINAPI
MSCHandleSignal(DWORD dwCtrlType) {
CACHE_REGS
#if THREADS
if (REMOTE_InterruptsDisabled(0)) {
#else
if (LOCAL_InterruptsDisabled) {
#endif
return FALSE;
}
switch(dwCtrlType) {
case CTRL_C_EVENT:
case CTRL_BREAK_EVENT:
#if THREADS
Yap_external_signal(0, YAP_WINTIMER_SIGNAL);
REMOTE_PrologMode(0) |= InterruptMode;
#else
Yap_signal(YAP_WINTIMER_SIGNAL);
LOCAL_PrologMode |= InterruptMode;
LOCAL_PrologMode |= InterruptMode;
#endif
return(TRUE);
default:
return(FALSE);
@ -1739,32 +1807,9 @@ Yap_volume_header(char *file)
}
int Yap_getcwd(const char *buf, int len)
char * Yap_getcwd(const char *cwd, size_t cwdlen)
{
CACHE_REGS
#if __simplescalar__
/* does not implement getcwd */
strncpy(Yap_buf,GLOBAL_pwd,len);
#elif HAVE_GETCWD
if (getcwd ((char *)buf, len) == NULL) {
#if HAVE_STRERROR
Yap_Error(OPERATING_SYSTEM_ERROR, ARG1, "%s in getcwd/1", strerror(errno));
#else
Yap_Error(OPERATING_SYSTEM_ERROR, ARG1, "error %d in getcwd/1", errno);
#endif
return FALSE;
}
#else
if (getwd (buf) == NULL) {
#if HAVE_STRERROR
Yap_Error(OPERATING_SYSTEM_ERROR, ARG1, "%s in getcwd/1", strerror(errno));
#else
Yap_Error(OPERATING_SYSTEM_ERROR, ARG1, "in getcwd/1");
#endif
return FALSE;
}
#endif
return TRUE;
return PL_cwd((char *)cwd, cwdlen);
}
/******
@ -1778,6 +1823,9 @@ TrueFileName (char *source, char *root, char *result, int in_lib, int expand_roo
char ares1[YAP_FILENAME_MAX];
result[0] = '\0';
if (strlen(source) >= YAP_FILENAME_MAX) {
Yap_Error(OPERATING_SYSTEM_ERROR, TermNil, "%s in true_file-name is larger than the buffer size (%d bytes)", source, strlen(source));
}
#if defined(__MINGW32__) || _MSC_VER
/* step 0: replace / by \ */
strncpy(ares1, source, YAP_FILENAME_MAX);
@ -2677,7 +2725,11 @@ p_yap_paths( USES_REGS1 ) {
out3 = MkAtomTerm(Yap_LookupAtom(DESTDIR "/" YAP_BINDIR));
} else {
out1 = MkAtomTerm(Yap_LookupAtom(YAP_LIBDIR));
#if __ANDROID__
out2 = MkAtomTerm(Yap_LookupAtom("/assets/share"));
#else
out2 = MkAtomTerm(Yap_LookupAtom(YAP_SHAREDIR));
#endif
out3 = MkAtomTerm(Yap_LookupAtom(YAP_BINDIR));
}
return(Yap_unify(out1,ARG1) &&
@ -2685,6 +2737,34 @@ p_yap_paths( USES_REGS1 ) {
Yap_unify(out3,ARG3));
}
static Int
p_log_event( USES_REGS1 ) {
Term in = Deref(ARG1);
Atom at;
if (IsVarTerm(in))
return FALSE;
if (!IsAtomTerm(in))
return FALSE;
at = AtomOfTerm( in );
#if DEBUG
if (IsWideAtom(at) )
fprintf(stderr, "LOG %S\n", RepAtom(at)->WStrOfAE);
else if (IsBlob(at))
return FALSE;
else
fprintf(stderr, "LOG %s\n", RepAtom(at)->StrOfAE);
#endif
if (IsWideAtom(at) || IsBlob(at))
return FALSE;
#if __ANDROID__
__android_log_print(ANDROID_LOG_INFO, "YAP", " %s ",RepAtom(at)->StrOfAE);
#endif
return TRUE;
}
static Int
p_env_separator( USES_REGS1 ) {
#if defined(_WIN32)
@ -3010,6 +3090,12 @@ Yap_InitSysPreds(void)
/* can only do after heap is initialised */
InitLastWtime();
Yap_InitCPred ("srandom", 1, p_srandom, SafePredFlag);
#if HAVE_RANDOM
Yap_InitCPred ("init_random_state", 3, p_init_random_state, SafePredFlag);
Yap_InitCPred ("set_random_state", 2, p_set_random_state, SafePredFlag);
Yap_InitCPred ("release_random_state", 1, p_release_random_state, SafePredFlag);
#endif
Yap_InitCPred ("log_event", 1, p_log_event, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("sh", 0, p_sh, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("$shell", 1, p_shell, SafePredFlag|SyncPredFlag|UserCPredFlag);
Yap_InitCPred ("system", 1, p_system, SafePredFlag|SyncPredFlag|UserCPredFlag);

View File

@ -24,6 +24,7 @@
#include "YapText.h"
#include <string.h>
#include <wchar.h>
#ifndef HAVE_WCSNLEN
inline static size_t
@ -1275,7 +1276,7 @@ concat( int n, seq_tv_t *out, void *sv[], encoding_t encv[], size_t lengv[] USES
while ( (chr = *ptr++) != '\0' ) *buf++ = chr;
}
*buf++ = '\0';
at = out->val.a = Yap_LookupAtom((char *)HR);
at = out->val.a = Yap_LookupAtom((const char *)HR);
return at;
}
}
@ -1358,7 +1359,7 @@ void *
Yap_Concat_Text( int n, seq_tv_t inp[], seq_tv_t *out USES_REGS)
{
encoding_t * encv;
void **bufv;
void **bufv;
int minimal = FALSE;
void *buf;
size_t leng, *lengv;
@ -1368,8 +1369,6 @@ Yap_Concat_Text( int n, seq_tv_t inp[], seq_tv_t *out USES_REGS)
HEAP_TERM_ERROR(bufv, void *);
encv = (encoding_t *)malloc(n*sizeof(encoding_t));
HEAP_ERROR(encv, encoding_t);
lengv = (size_t *)malloc(n*sizeof(size_t));
HEAP_ERROR(lengv, size_t);
buf = NULL;
for (i = 0 ; i < n ; i++) {
void *nbuf = read_Text( buf, inp+i, encv+i, &minimal, &leng PASS_REGS );
@ -1381,6 +1380,8 @@ Yap_Concat_Text( int n, seq_tv_t inp[], seq_tv_t *out USES_REGS)
buf = compute_end( nbuf, encv[i] );
}
}
lengv = (size_t *)malloc(n*sizeof(size_t));
HEAP_ERROR(lengv, size_t);
buf = concat(n, out, bufv, encv, lengv PASS_REGS);
return buf;
}

View File

@ -90,6 +90,12 @@ Yap_ThreadID( void )
return -1;
}
int
Yap_NOfThreads(void) {
// GLOBAL_ThreadHandlesLock is held
return GLOBAL_NOfThreads;
}
static int
allocate_new_tid(void)
{
@ -509,9 +515,9 @@ Yap_thread_self(void)
}
CELL
Yap_thread_create_engine(thread_attr *ops)
Yap_thread_create_engine(YAP_thread_attr *ops)
{
thread_attr opsv;
YAP_thread_attr opsv;
int new_id = allocate_new_tid();
Term t = TermNil;
@ -684,7 +690,11 @@ static Int
p_thread_set_concurrency( USES_REGS1 )
{
Term tnew = Deref(ARG2);
int newc, cur;
int newc;
#if HAVE_PTHREAD_GETCONCURRENCY
int cur;
#endif
if (IsVarTerm(tnew)) {
newc = 0;
@ -694,11 +704,15 @@ p_thread_set_concurrency( USES_REGS1 )
Yap_Error(TYPE_ERROR_INTEGER,tnew,"thread_set_concurrency/2");
return(FALSE);
}
#if HAVE_PTHREAD_GETCONCURRENCY
cur = MkIntegerTerm(pthread_getconcurrency());
if (pthread_setconcurrency(newc) != 0) {
return FALSE;
}
return Yap_unify(ARG1, MkIntegerTerm(cur));
#else
return FALSE;
#endif
}
static Int
@ -1090,6 +1104,17 @@ void Yap_InitThreadPreds(void)
#else
int
Yap_NOfThreads(void) {
// GLOBAL_ThreadHandlesLock is held
#ifdef YAPOR
return 2;
#else
return 1;
#endif
}
static Int
p_no_threads(void)
{ /* '$thread_signal'(+P) */

View File

@ -146,7 +146,7 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
// if (!worker_id) return;
LOCK(Yap_heap_regs->low_level_trace_lock);
sc = Yap_heap_regs;
if (vsc_count == 161862) jmp_deb(1);
//if (vsc_count == 161862) jmp_deb(1);
// Sfprintf(stderr,"B=%p ", B);
#ifdef THREADS
LOCAL_ThreadHandle.thread_inst_count++;

View File

@ -395,7 +395,7 @@ oc_unify_nvar_nvar:
deref_body(d1, pt1, oc_unify_nvar_unk, oc_unify_nvar_nvar);
/* d0 is bound and d1 is unbound */
Bind(pt1, d0);
YapBind(pt1, d0);
/* local variables cannot be in a term */
if (pt1 > HR && pt1 < LCL0)
return TRUE;
@ -408,7 +408,7 @@ oc_unify_nvar_nvar:
deref_head(d1, oc_unify_var_unk);
oc_unify_var_nvar:
/* pt0 is unbound and d1 is bound */
Bind(pt0, d1);
YapBind(pt0, d1);
/* local variables cannot be in a term */
if (pt0 > HR && pt0 < LCL0)
return TRUE;
@ -528,7 +528,7 @@ unify_nvar_nvar:
deref_body(d1, pt1, unify_nvar_unk, unify_nvar_nvar);
/* d0 is bound and d1 is unbound */
Bind(pt1, d0);
YapBind(pt1, d0);
return (TRUE);
deref_body(d0, pt0, unify_unk, unify_nvar);
@ -536,7 +536,7 @@ unify_nvar_nvar:
deref_head(d1, unify_var_unk);
unify_var_nvar:
/* pt0 is unbound and d1 is bound */
Bind(pt0, d1);
YapBind(pt0, d1);
return TRUE;
#if TRAILING_REQUIRES_BRANCH

View File

@ -1618,6 +1618,40 @@ p_term_variables( USES_REGS1 ) /* variables in term t */
return Yap_unify(ARG2,out);
}
/**
* Exports a nil-terminated list with all the variables in a term.
* @param[in] the term
* @param[in] the arity of the calling predicate (required for exact garbage collection).
*/
Term
Yap_TermVariables( Term t, UInt arity USES_REGS ) /* variables in term t */
{
Term out;
do {
t = Deref(t);
if (IsVarTerm(t)) {
return MkPairTerm(t, TermNil);
} else if (IsPrimitiveTerm(t)) {
return TermNil;
} else if (IsPairTerm(t)) {
out = vars_in_complex_term(RepPair(t)-1,
RepPair(t)+1, TermNil PASS_REGS);
}
else {
Functor f = FunctorOfTerm(t);
out = vars_in_complex_term(RepAppl(t),
RepAppl(t)+
ArityOfFunctor(f), TermNil PASS_REGS);
}
if (out == 0L) {
if (!expand_vts( arity PASS_REGS ))
return FALSE;
}
} while (out == 0L);
return out;
}
static Term attvars_in_complex_term(register CELL *pt0, register CELL *pt0_end, Term inp USES_REGS)
{
@ -4150,7 +4184,7 @@ p_subsumes( USES_REGS1 ) /* subsumes terms t1 and t2 */
if (t1 == t2)
return (TRUE);
if (IsVarTerm(t1)) {
Bind(VarOfTerm(t1), t2);
YapBind(VarOfTerm(t1), t2);
if (Yap_rational_tree_loop(VarOfTerm(t1)-1,VarOfTerm(t1),(CELL **)AuxSp,(CELL **)AuxBase))
return FALSE;
return TRUE;
@ -4238,7 +4272,7 @@ static int term_subsumer_complex(register CELL *pt0, register CELL *pt0_end, reg
HR[1] = d1;
HR[2] = (CELL)npt;
HR[3] = d0;
Bind(VarOfTerm(d0), (CELL)HR);
YapBind(VarOfTerm(d0), (CELL)HR);
HR+=4;
RESET_VARIABLE(npt);
npt++;

View File

@ -317,7 +317,7 @@ wrputf(Float f, struct write_globs *wglb) /* writes a float */
size_t l1 = strlen((const char *)decimalpoint+1);
#else
const unsigned char *decimalpoint = ".";
l1 = 0;
size_t l1 = 0;
#endif
if (lastw == symbol || lastw == alphanum) {
@ -578,7 +578,7 @@ putAtom(Atom atom, int Quote_illegal, struct write_globs *wglb)
wrputblob(RepAtom(atom),Quote_illegal,wglb);
return;
}
if (IsWideAtom(atom)) {
if (IsWideAtom(atom) ) {
wchar_t *ws = RepAtom(atom)->WStrOfAE;
if (Quote_illegal) {
@ -889,11 +889,12 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
if (IsVarTerm(t)) {
write_var((CELL *)t, wglb, &nrwt);
} else if (IsIntTerm(t)) {
wrputn((Int) IntOfTerm(t),wglb);
} else if (IsAtomTerm(t)) {
putAtom(AtomOfTerm(t), wglb->Quote_illegal, wglb);
} else if (IsPairTerm(t)) {
if (wglb->Ignore_ops) {
if (wglb->Ignore_ops) {
wrputs("'.'(",wglb->stream);
lastw = separator;
writeTerm(from_pointer(RepPair(t), &nrwt, wglb), 999, depth + 1, FALSE, wglb, &nrwt);
@ -909,15 +910,15 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
struct DB_TERM *old_EX = NULL;
Int sl = 0;
targs[0] = t;
targs[0] = t;
Yap_PutValue(AtomPortray, MkAtomTerm(AtomNil));
if (EX) old_EX = EX;
sl = Yap_InitSlot(t PASS_REGS);
Yap_execute_goal(Yap_MkApplTerm(FunctorPortray, 1, targs), 0, 1);
Yap_execute_goal(Yap_MkApplTerm(FunctorPortray, 1, targs), 0, 1);
t = Yap_GetFromSlot(sl PASS_REGS);
Yap_RecoverSlots(1, sl PASS_REGS);
if (old_EX != NULL) EX = old_EX;
if (Yap_GetValue(AtomPortray) == MkAtomTerm(AtomTrue))
if (Yap_GetValue(AtomPortray) == MkAtomTerm(AtomTrue))
return;
}
if (yap_flags[WRITE_QUOTED_STRING_FLAG] && IsCodesTerm(t)) {
@ -926,12 +927,12 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
wrputc('[', wglb->stream);
lastw = separator;
/* we assume t was already saved in the stack */
write_list(t, 0, depth, wglb, rwt);
write_list(t, 0, depth, wglb, rwt);
wrputc(']', wglb->stream);
lastw = separator;
lastw = separator;
}
} else { /* compound term */
Functor functor = FunctorOfTerm(t);
Functor functor = FunctorOfTerm(t);
int Arity;
Atom atom;
int op, lp, rp;
@ -1087,7 +1088,7 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
} else if (!wglb->Ignore_ops &&
Arity == 2 && Yap_IsInfixOp(atom, &op, &lp,
&rp) ) {
Term tleft = ArgOfTerm(1, t);
Term tleft = ArgOfTerm(1, t);
Term tright = ArgOfTerm(2, t);
int bracket_left =
!IsVarTerm(tleft) && IsAtomTerm(tleft) &&

View File

@ -2,413 +2,628 @@
#define YAP_CPP_INTERFACE 1
#include "yapi.hh"
#include "SWI-Stream.h"
YAPAtomTerm::YAPAtomTerm(char *s) { // build string
BACKUP_H();
CACHE_REGS
seq_tv_t inp, out;
inp.val.c = s;
inp.type = YAP_STRING_CHARS;
out.type = YAP_STRING_ATOM;
if (Yap_CVT_Text(&inp, &out PASS_REGS))
t = MkAtomTerm(out.val.a);
else t = 0L;
RECOVER_H();
YAPAtomTerm::YAPAtomTerm(char *s) { // build string
BACKUP_H();
CACHE_REGS
seq_tv_t inp, out;
inp.val.c = s;
inp.type = YAP_STRING_CHARS;
out.type = YAP_STRING_ATOM;
if (Yap_CVT_Text(&inp, &out PASS_REGS))
mk ( MkAtomTerm(out.val.a) );
else t = 0L;
RECOVER_H();
}
YAPAtomTerm::YAPAtomTerm(char *s, size_t len) { // build string
BACKUP_H();
YAPAtomTerm::YAPAtomTerm(char *s, size_t len) { // build string
BACKUP_H();
CACHE_REGS
seq_tv_t inp, out;
inp.val.c = s;
inp.type = YAP_STRING_CHARS;
out.type = YAP_STRING_ATOM|YAP_STRING_NCHARS|YAP_STRING_TRUNC;
out.sz = len;
out.max = len;
if (Yap_CVT_Text(&inp, &out PASS_REGS))
t = MkAtomTerm(out.val.a);
else t = 0L;
RECOVER_H();
CACHE_REGS
seq_tv_t inp, out;
inp.val.c = s;
inp.type = YAP_STRING_CHARS;
out.type = YAP_STRING_ATOM|YAP_STRING_NCHARS|YAP_STRING_TRUNC;
out.sz = len;
out.max = len;
if (Yap_CVT_Text(&inp, &out PASS_REGS))
mk ( MkAtomTerm(out.val.a) );
else t = 0L;
RECOVER_H();
}
YAPAtomTerm::YAPAtomTerm(wchar_t *s): YAPTerm() { // build string
BACKUP_H();
YAPAtomTerm::YAPAtomTerm(wchar_t *s): YAPTerm() { // build string
BACKUP_H();
CACHE_REGS
seq_tv_t inp, out;
inp.val.w = s;
inp.type = YAP_STRING_WCHARS;
out.type = YAP_STRING_ATOM;
if (Yap_CVT_Text(&inp, &out PASS_REGS))
t = MkAtomTerm(out.val.a);
else t = 0L;
RECOVER_H();
CACHE_REGS
seq_tv_t inp, out;
inp.val.w = s;
inp.type = YAP_STRING_WCHARS;
out.type = YAP_STRING_ATOM;
if (Yap_CVT_Text(&inp, &out PASS_REGS))
mk ( MkAtomTerm(out.val.a) );
else t = 0L;
RECOVER_H();
}
YAPAtomTerm::YAPAtomTerm(wchar_t *s, size_t len) : YAPTerm() { // build string
BACKUP_H();
YAPAtomTerm::YAPAtomTerm(wchar_t *s, size_t len) : YAPTerm() { // build string
BACKUP_H();
CACHE_REGS
seq_tv_t inp, out;
inp.val.w = s;
inp.type = YAP_STRING_WCHARS;
out.type = YAP_STRING_ATOM|YAP_STRING_NCHARS|YAP_STRING_TRUNC;
out.sz = len;
out.max = len;
if (Yap_CVT_Text(&inp, &out PASS_REGS))
t = MkAtomTerm(out.val.a);
else t = 0L;
RECOVER_H();
CACHE_REGS
seq_tv_t inp, out;
inp.val.w = s;
inp.type = YAP_STRING_WCHARS;
out.type = YAP_STRING_ATOM|YAP_STRING_NCHARS|YAP_STRING_TRUNC;
out.sz = len;
out.max = len;
if (Yap_CVT_Text(&inp, &out PASS_REGS))
mk ( MkAtomTerm(out.val.a) );
else t = 0L;
RECOVER_H();
}
YAPStringTerm::YAPStringTerm(char *s) { // build string
BACKUP_H();
YAPStringTerm::YAPStringTerm(char *s) { // build string
BACKUP_H();
CACHE_REGS
seq_tv_t inp, out;
inp.val.c = s;
inp.type = YAP_STRING_CHARS;
out.type = YAP_STRING_STRING;
if (Yap_CVT_Text(&inp, &out PASS_REGS))
t = out.val.t;
else t = 0L;
RECOVER_H();
CACHE_REGS
seq_tv_t inp, out;
inp.val.c = s;
inp.type = YAP_STRING_CHARS;
out.type = YAP_STRING_STRING;
if (Yap_CVT_Text(&inp, &out PASS_REGS))
mk ( out.val.t );
else t = 0L;
RECOVER_H();
}
YAPStringTerm::YAPStringTerm(char *s, size_t len) { // build string
BACKUP_H();
YAPStringTerm::YAPStringTerm(char *s, size_t len) { // build string
BACKUP_H();
CACHE_REGS
seq_tv_t inp, out;
inp.val.c = s;
inp.type = YAP_STRING_CHARS;
out.type = YAP_STRING_STRING|YAP_STRING_NCHARS|YAP_STRING_TRUNC;
out.sz = len;
out.max = len;
if (Yap_CVT_Text(&inp, &out PASS_REGS))
t = out.val.t;
else t = 0L;
RECOVER_H();
CACHE_REGS
seq_tv_t inp, out;
inp.val.c = s;
inp.type = YAP_STRING_CHARS;
out.type = YAP_STRING_STRING|YAP_STRING_NCHARS|YAP_STRING_TRUNC;
out.sz = len;
out.max = len;
if (Yap_CVT_Text(&inp, &out PASS_REGS))
mk ( out.val.t );
else t = 0L;
RECOVER_H();
}
YAPStringTerm::YAPStringTerm(wchar_t *s): YAPTerm() { // build string
BACKUP_H();
YAPStringTerm::YAPStringTerm(wchar_t *s): YAPTerm() { // build string
BACKUP_H();
CACHE_REGS
seq_tv_t inp, out;
inp.val.w = s;
inp.type = YAP_STRING_WCHARS;
out.type = YAP_STRING_STRING;
if (Yap_CVT_Text(&inp, &out PASS_REGS))
t = out.val.t;
else t = 0L;
RECOVER_H();
CACHE_REGS
seq_tv_t inp, out;
inp.val.w = s;
inp.type = YAP_STRING_WCHARS;
out.type = YAP_STRING_STRING;
if (Yap_CVT_Text(&inp, &out PASS_REGS))
mk ( out.val.t );
else t = 0L;
RECOVER_H();
}
YAPStringTerm::YAPStringTerm(wchar_t *s, size_t len) : YAPTerm() { // build string
BACKUP_H();
YAPStringTerm::YAPStringTerm(wchar_t *s, size_t len) : YAPTerm() { // build string
BACKUP_H();
CACHE_REGS
seq_tv_t inp, out;
inp.val.w = s;
inp.type = YAP_STRING_WCHARS;
out.type = YAP_STRING_STRING|YAP_STRING_NCHARS|YAP_STRING_TRUNC;
out.sz = len;
out.max = len;
if (Yap_CVT_Text(&inp, &out PASS_REGS))
t = out.val.t;
else t = 0L;
RECOVER_H();
CACHE_REGS
seq_tv_t inp, out;
inp.val.w = s;
inp.type = YAP_STRING_WCHARS;
out.type = YAP_STRING_STRING|YAP_STRING_NCHARS|YAP_STRING_TRUNC;
out.sz = len;
out.max = len;
if (Yap_CVT_Text(&inp, &out PASS_REGS))
mk ( out.val.t );
else t = 0L;
RECOVER_H();
}
YAPApplTerm::YAPApplTerm(YAPFunctor f, YAPTerm ts[]) : YAPTerm() {
UInt arity = ArityOfFunctor(f.f);
t = Yap_MkApplTerm( f.f, arity, (Term *)ts);
UInt arity = ArityOfFunctor(f.f);
mk ( Yap_MkApplTerm( f.f, arity, (Term *)ts) );
}
YAPApplTerm::YAPApplTerm(YAPFunctor f) : YAPTerm() {
UInt arity = ArityOfFunctor(f.f);
t = Yap_MkNewApplTerm( f.f, arity);
UInt arity = ArityOfFunctor(f.f);
mk ( Yap_MkNewApplTerm( f.f, arity) );
}
YAPTerm YAPApplTerm::getArg(unsigned int arg) {
return YAPTerm( ArgOfTerm(arg, t) );
YAPTerm YAPApplTerm::getArg(int arg) {
return YAPTerm( ArgOfTerm(arg, gt() ) );
}
YAPFunctor YAPApplTerm::getFunctor() {
return YAPFunctor( FunctorOfTerm(t) );
return YAPFunctor( FunctorOfTerm( gt( )) );
}
YAPPairTerm::YAPPairTerm(YAPTerm th, YAPTerm tl) : YAPTerm() {
CACHE_REGS
t = MkPairTerm( th.t, tl.t);
CACHE_REGS
mk ( MkPairTerm( th.term(), tl.term() ) );
}
YAPPairTerm::YAPPairTerm() : YAPTerm() {
t = Yap_MkNewPairTerm( );
t = Yap_MkNewPairTerm( );
}
YAP_tag_t YAPTerm::tag() {
if (IsVarTerm(t)) {
CELL *pt = VarOfTerm(t);
if (IsUnboundVar(pt)) {
CACHE_REGS
if (IsAttVar(pt))
return YAP_TAG_ATT;
return YAP_TAG_UNBOUND;
}
return YAP_TAG_REF;
}
if (IsPairTerm(t))
return YAP_TAG_PAIR;
if (IsAtomOrIntTerm(t)) {
if (IsAtomTerm(t))
return YAP_TAG_ATOM;
return YAP_TAG_INT;
} else {
Functor f = FunctorOfTerm(t);
void YAPTerm::mk(Term t0) { CACHE_REGS t = Yap_InitSlot( t0 PASS_REGS); }
if (IsExtensionFunctor(f)) {
if (f == FunctorDBRef) {
return YAP_TAG_DBREF;
}
if (f == FunctorLongInt) {
return YAP_TAG_LONG_INT;
}
if (f == FunctorBigInt) {
big_blob_type bt = (big_blob_type)RepAppl(t)[1];
switch (bt) {
case BIG_INT:
return YAP_TAG_BIG_INT;
case BIG_RATIONAL:
return YAP_TAG_RATIONAL;
default:
return YAP_TAG_OPAQUE;
}
}
}
return YAP_TAG_APPL;
}
Term YAPTerm::gt() { CACHE_REGS return Yap_GetFromSlot( t PASS_REGS); }
YAP_tag_t YAPTerm::tag() {
Term tt = gt( );
if (IsVarTerm(tt)) {
CELL *pt = VarOfTerm(tt);
if (IsUnboundVar(pt)) {
CACHE_REGS
if (IsAttVar(pt))
return YAP_TAG_ATT;
return YAP_TAG_UNBOUND;
}
return YAP_TAG_REF;
}
if (IsPairTerm(tt))
return YAP_TAG_PAIR;
if (IsAtomOrIntTerm(tt)) {
if (IsAtomTerm(tt))
return YAP_TAG_ATOM;
return YAP_TAG_INT;
} else {
Functor f = FunctorOfTerm(tt);
if (IsExtensionFunctor(f)) {
if (f == FunctorDBRef) {
return YAP_TAG_DBREF;
}
if (f == FunctorLongInt) {
return YAP_TAG_LONG_INT;
}
if (f == FunctorBigInt) {
big_blob_type bt = (big_blob_type)RepAppl(tt)[1];
switch (bt) {
case BIG_INT:
return YAP_TAG_BIG_INT;
case BIG_RATIONAL:
return YAP_TAG_RATIONAL;
default:
return YAP_TAG_OPAQUE;
}
}
}
return YAP_TAG_APPL;
}
}
YAPTerm YAPTerm::deepCopy() {
Term tn;
BACKUP_MACHINE_REGS();
Term tn;
BACKUP_MACHINE_REGS();
tn = Yap_CopyTerm(t);
tn = Yap_CopyTerm( gt() );
RECOVER_MACHINE_REGS();
return new YAPTerm( tn );
RECOVER_MACHINE_REGS();
return new YAPTerm( tn );
}
bool YAPTerm::exactlyEqual(YAPTerm t1) {
int out;
BACKUP_MACHINE_REGS();
int out;
BACKUP_MACHINE_REGS();
out = Yap_eq(Deref(t), Deref(t1.t));
out = Yap_eq(gt(), t1.term());
RECOVER_MACHINE_REGS();
return out;
RECOVER_MACHINE_REGS();
return out;
}
bool YAPTerm::unify(YAPTerm t1) {
int out;
BACKUP_MACHINE_REGS();
int out;
BACKUP_MACHINE_REGS();
out = Yap_unify(Deref(t), Deref(t1.t));
out = Yap_unify(gt(), t1.term());
RECOVER_MACHINE_REGS();
return out;
RECOVER_MACHINE_REGS();
return out;
}
bool YAPTerm::unifiable(YAPTerm t1) {
int out;
BACKUP_MACHINE_REGS();
int out;
BACKUP_MACHINE_REGS();
out = Yap_Unifiable(Deref(t), Deref(t1.t));
out = Yap_Unifiable(gt(), t1.term());
RECOVER_MACHINE_REGS();
return out;
RECOVER_MACHINE_REGS();
return out;
}
bool YAPTerm::variant(YAPTerm t1) {
int out;
BACKUP_MACHINE_REGS();
int out;
BACKUP_MACHINE_REGS();
out = Yap_Variant(Deref(t), Deref(t1.t));
out = Yap_Variant(gt(), t1.term());
RECOVER_MACHINE_REGS();
return out;
RECOVER_MACHINE_REGS();
return out;
}
intptr_t YAPTerm::hash(size_t sz, size_t depth, bool variant) {
Int out;
intptr_t YAPTerm::hashTerm(size_t sz, size_t depth, bool variant) {
intptr_t out;
BACKUP_MACHINE_REGS();
BACKUP_MACHINE_REGS();
out = Yap_TermHash(t, sz, depth, variant);
out = Yap_TermHash(gt(), sz, depth, variant) ;
RECOVER_MACHINE_REGS();
return out;
RECOVER_MACHINE_REGS();
return out;
}
char *YAPTerm::text(void) {
size_t sze = 4096, length;
char *os;
int enc;
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "I LCL0+%p/t=(%d) %x", LCL0, t, LCL0[-15]) ; }
BACKUP_MACHINE_REGS();
if (!(os = Yap_HandleToString(t, sze, &length, &enc, 0))) {
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "IIa LCL0+t=(%p) %x", LCL0, LCL0[-15]) ; }
RECOVER_MACHINE_REGS();
return (char *)NULL;
}
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "II LCL0+t=(%p) %x", LCL0, LCL0[-15]) ; }
RECOVER_MACHINE_REGS();
return os;
}
bool YAPListTerm::nil() {
CACHE_REGS
__android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "t=%d LCL0+t=(%p)", t, LCL0+t) ;
return gt() == TermNil;
}
char *YAPAtom::name(void) {
if (IsWideAtom(a)) {
// return an UTF-8 version
size_t sz = 512;
wchar_t * ptr = a->WStrOfAE;
int ch = -1;
char *s = new char[sz], *op = s;
while (ch) {
ch = *ptr++;
utf8_put_char( op, ch );
}
sz = strlen(s)+1;
char *os = new char[sz];
memcpy(os, s, sz);
delete s;
return os;
} else if (IsBlob(a)) {
PL_blob_t *type = RepBlobProp(a->PropsOfAE)->blob_t;
size_t sz = 512;
YAPIntegerTerm::YAPIntegerTerm(intptr_t i) { CACHE_REGS Term tn = MkIntegerTerm( i ); mk( tn ); }
if (type->write) {
char *s = new char[sz];
IOSTREAM *stream = Sopenmem(&s, &sz, "w");
stream->encoding = ENC_UTF8;
atom_t at = YAP_SWIAtomFromAtom(AbsAtom(a));
type->write(stream, at, 0);
Sclose(stream);
popOutputContext();
sz = strlen(s)+1;
char *os = new char[sz];
memcpy(os, s, sz);
delete s;
return os;
} else {
char *s = new char[sz];
/*
YAPTerm *YAPTerm::vars()
{
BACKUP_MACHINE_REGS();
CACHE_REGS
YAPPairTerm lv = YAPPairTerm(Yap_TermVariables(gt(), 0 PASS_REGS));
RECOVER_MACHINE_REGS();
return lv;
}
*/
YAPTerm::YAPTerm(void *ptr) { CACHE_REGS mk( MkIntegerTerm( (Int)ptr ) );}
YAPTerm::YAPTerm(intptr_t i) { CACHE_REGS Term tn = MkIntegerTerm( i ); mk( tn ); }
YAPTerm YAPListTerm::car()
{
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "t=%d LCL0+t=(%p)", t, LCL0+t) ; }
Term to = gt();
if (IsPairTerm(to))
return YAPTerm(HeadOfTerm(to));
else
return MkIntTerm(-1);
}
YAPVarTerm::YAPVarTerm() { CACHE_REGS mk( MkVarTerm( ) ); }
char *YAPAtom::getName(void) {
if (IsWideAtom(a)) {
// return an UTF-8 version
size_t sz = 512;
wchar_t * ptr = a->WStrOfAE;
int ch = -1;
char *s = new char[sz], *op = s;
while (ch) {
ch = *ptr++;
utf8_put_char( op, ch );
}
sz = strlen(s)+1;
char *os = new char[sz];
memcpy(os, s, sz);
delete[] s;
return os;
} else if (IsBlob(a)) {
PL_blob_t *type = RepBlobProp(a->PropsOfAE)->blob_t;
size_t sz = 512;
if (type->write) {
char *s = new char[sz];
IOSTREAM *stream = Sopenmem(&s, &sz, "w");
stream->encoding = ENC_UTF8;
atom_t at = YAP_SWIAtomFromAtom(AbsAtom(a));
type->write(stream, at, 0);
Sclose(stream);
popOutputContext();
sz = strlen(s)+1;
char *os = new char[sz];
memcpy(os, s, sz);
delete s;
return os;
} else {
char *s = new char[sz];
#if defined(__linux__) || defined(__APPLE__)
snprintf(s, sz, "'%s'(%p)", AtomSWIStream->StrOfAE, a);
snprintf(s, sz, "'%s'(%p)", AtomSWIStream->StrOfAE, a);
#else
snprintf(s, sz, "'%s'(0x%p)", AtomSWIStream->StrOfAE, a);
snprintf(s, sz, "'%s'(0x%p)", AtomSWIStream->StrOfAE, a);
#endif
char *os = new char[sz];
memcpy(os, s, sz);
delete s;
return os;
}
} else {
return a->StrOfAE;
}
char *os = new char[sz];
memcpy(os, s, sz);
delete[] s;
return os;
}
} else {
return a->StrOfAE;
}
}
YAPPredicate::YAPPredicate(const char *s, Term **outp, YAPTerm &vnames) throw (int) {
CACHE_REGS
vnames = Yap_NewSlots(1 PASS_REGS);
Term t = Yap_StringToTerm(s, strlen(s)+1, Yap_GetFromSlot( vnames.t PASS_REGS));
if (t == 0L)
throw YAPError::YAP_SYNTAX_ERROR;
ap = getPred( t, outp );
//{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "OUT vnames=%d ap=%p LCL0=%p", vnames, ap, LCL0) ; }
}
YAPPredicate::YAPPredicate(YAPAtom at) {
CACHE_REGS
ap = RepPredProp(PredPropByAtom(at.a,CurrentModule));
}
YAPPredicate::YAPPredicate(YAPAtom at, arity_t arity) {
CACHE_REGS
if (arity) {
Functor f = Yap_MkFunctor(at.a, arity);
ap = RepPredProp(PredPropByFunc(f,CurrentModule));
} else {
ap = RepPredProp(PredPropByAtom(at.a,CurrentModule));
}
}
/// auxiliary routine to find a predicate in the current module.
PredEntry *YAPPredicate::getPred( Term t, Term **outp ) {
CACHE_REGS
Term m = CurrentModule ;
t = Yap_StripModule(t, &m);
if (IsVarTerm(t) || IsNumTerm(t)) {
ap = (PredEntry *)NULL;
if (outp) *outp = (Term *)NULL;
}
if (IsAtomTerm(t)) {
ap = RepPredProp(PredPropByAtom(AtomOfTerm(t), m));
if (outp) *outp = (Term *)NULL;
} else if (IsPairTerm(t)) {
ap = RepPredProp(PredPropByFunc(FunctorCsult, PROLOG_MODULE));
if (outp) *outp = HR;
HR[0] = RepPair(t)[0];
HR[1] = m;
HR+=2;
} else {
Functor f = FunctorOfTerm(t);
if (IsExtensionFunctor(f)) {
ap = (PredEntry *)NULL;
if (outp) *outp = (Term *)NULL;
}
ap = RepPredProp(PredPropByFunc(f, m));
if (outp) *outp = RepAppl(t)+1;
}
return ap;
}
YAPPredicate::YAPPredicate(YAPFunctor f) {
CACHE_REGS
ap = RepPredProp(PredPropByFunc(f.f,CurrentModule));
}
void
YAPQuery::initQuery( Term *t )
YAPQuery::initQuery( Term *ts )
{
CACHE_REGS
CACHE_REGS
this->oq = (YAPQuery *)LOCAL_execution;
LOCAL_execution = (struct open_query_struct *)this;
this->q_open=1;
this->q_state=0;
this->q_flags = 0;
this->q_g = t;
this->oq = (YAPQuery *)LOCAL_execution;
LOCAL_execution = (struct open_query_struct *)this;
this->q_open=1;
this->q_state=0;
this->q_flags = PL_Q_PASS_EXCEPTION;
this->q_g = ts;
}
void
YAPQuery::initQuery( YAPTerm t[], arity_t arity )
{
Term *ts = new Term[arity];
for (arity_t i = 0; i < arity; i++)
ts[i] = t[i].term();
return initQuery( ts );
}
YAPQuery::YAPQuery(YAPFunctor f, YAPTerm mod, YAPTerm t[]): YAPPredicate(f, mod)
{
/* ignore flags for now */
initQuery( (Term *)t );
/* ignore flags for now */
initQuery( t , f.arity());
}
YAPQuery::YAPQuery(YAPFunctor f, YAPTerm t[]): YAPPredicate(f)
{
/* ignore flags for now */
initQuery( (Term *)t );
/* ignore flags for now */
initQuery( t , f.arity());
}
YAPQuery::YAPQuery(YAPPredicate p, YAPTerm t[]): YAPPredicate(p.ap)
{
initQuery( (Term *)t );
initQuery( t , p.ap->ArityOfPE);
}
YAPQuery::YAPQuery(char *s): YAPPredicate(s, &this->q_g)
{
Term *t = this->q_g;
initQuery( t );
YAPListTerm YAPQuery::namedVars() {
CACHE_REGS
Term o = Yap_GetFromSlot( this->vnames.t PASS_REGS );
return YAPListTerm( o );
}
int YAPQuery::next()
bool YAPQuery::next()
{
CACHE_REGS
int result;
if (this->q_open != 1) return 0;
if (setjmp(((YAPQuery *)LOCAL_execution)->q_env))
return 0;
// don't forget, on success these guys must create slots
if (this->q_state == 0) {
result = YAP_EnterGoal((YAP_PredEntryPtr)this->ap, this->q_g, &this->q_h);
} else {
LOCAL_AllowRestart = this->q_open;
result = YAP_RetryGoal(&this->q_h);
}
this->q_state = 1;
if (result == 0) {
YAP_LeaveGoal(FALSE, &this->q_h);
this->q_open = 0;
}
return result;
CACHE_REGS
int result;
if (this->q_open != 1) return false;
if (setjmp(((YAPQuery *)LOCAL_execution)->q_env))
return false;
// don't forget, on success these guys must create slots
if (this->q_state == 0) {
// extern void toggle_low_level_trace(void);
//toggle_low_level_trace();
result = (bool)YAP_EnterGoal((YAP_PredEntryPtr)this->ap, this->q_g, &this->q_h);
} else {
LOCAL_AllowRestart = this->q_open;
result = (bool)YAP_RetryGoal(&this->q_h);
}
this->q_state = 1;
if (!result) {
YAP_LeaveGoal(FALSE, &this->q_h);
this->q_open = 0;
}
return result;
}
void YAPQuery::cut()
{
CACHE_REGS
CACHE_REGS
if (this->q_open != 1 || this->q_state == 0) return;
YAP_LeaveGoal(FALSE, &this->q_h);
this->q_open = 0;
LOCAL_execution = (struct open_query_struct *)this->oq;
if (this->q_open != 1 || this->q_state == 0) return;
YAP_LeaveGoal(FALSE, &this->q_h);
this->q_open = 0;
LOCAL_execution = (struct open_query_struct *)this->oq;
}
void YAPQuery::close()
{
CACHE_REGS
CACHE_REGS
if (EX && !(this->q_flags & (PL_Q_CATCH_EXCEPTION))) {
EX = NULL;
}
/* need to implement backtracking here */
if (this->q_open != 1 || this->q_state == 0) {
return;
}
YAP_LeaveGoal(FALSE, &this->q_h);
this->q_open = 0;
LOCAL_execution = (struct open_query_struct *)this->oq;
if (EX && !(this->q_flags & (PL_Q_CATCH_EXCEPTION))) {
EX = (struct DB_TERM *)NULL;
}
/* need to implement backtracking here */
if (this->q_open != 1 || this->q_state == 0) {
return;
}
YAP_LeaveGoal(FALSE, &this->q_h);
this->q_open = 0;
LOCAL_execution = (struct open_query_struct *)this->oq;
}
int YAPPredicate::call(YAPTerm t[])
{
YAPQuery q = YAPQuery(*this, t);
int ret = q.next();
q.cut();
q.close();
return ret;
YAPQuery q = YAPQuery(*this, t);
int ret;
ret = q.next();
q.cut();
q.close();
return ret;
}
YAPEngine::YAPEngine(YAPParams const& params)
{ YAP_Init( (YAP_init_args *)&params.init_args ); }
static YAPEngine *curren;
#if __ANDROID__
#include <jni.h>
#include <string.h>
extern AAssetManager *assetManager;
extern char *Yap_AndroidBufp;
static size_t Yap_AndroidMax, Yap_AndroidSz;
extern void(*Yap_DisplayWithJava)(int c);
static void
displayWithJava(int c)
{
char *ptr = Yap_AndroidBufp;
ptr[ Yap_AndroidSz++ ] = c;
if (Yap_AndroidMax-1 == Yap_AndroidSz) {
if (Yap_AndroidMax < 32*1024) {
Yap_AndroidMax *= 2;
} else {
Yap_AndroidMax += 32*1024;
}
Yap_AndroidBufp = (char *)realloc( ptr, Yap_AndroidMax);
}
Yap_AndroidBufp[Yap_AndroidSz] = '\0';
if (c == '\n' ) {
Yap_AndroidBufp[Yap_AndroidSz] = '\0';
curren->run(Yap_AndroidBufp);
Yap_AndroidSz = 0;
}
}
#endif
YAPEngine::YAPEngine( char *savedState,
size_t stackSize,
size_t trailSize,
size_t maxStackSize,
size_t maxTrailSize,
char *libDir,
char *bootFile,
char *goal,
char *topLevel,
bool script,
bool fastBoot,
YAPCallback *cb): _callback(0)
{ // a single engine can be active
#if __ANDROID__
if (GLOBAL_assetManager == (AAssetManager *)NULL)
return;
Yap_DisplayWithJava = displayWithJava;
Yap_AndroidBufp = (char *)malloc(Yap_AndroidMax = 4096);
Yap_AndroidBufp[0] = '\0';
Yap_AndroidSz = 0;
#endif
memset((void *)&init_args, 0, sizeof(init_args));
init_args.SavedState = savedState;
init_args.StackSize = stackSize;
init_args.TrailSize = trailSize;
init_args.MaxStackSize = maxStackSize;
init_args.MaxTrailSize = maxTrailSize;
init_args.YapLibDir = libDir;
init_args.YapPrologBootFile = bootFile;
init_args.YapPrologGoal = goal;
init_args.YapPrologTopLevelGoal = topLevel;
init_args.HaltAfterConsult = script;
init_args.FastBoot = fastBoot;
delYAPCallback();
if (cb) setYAPCallback(cb);
curren = this;
YAP_Init( &init_args );
}
YAPQuery *YAPEngine::query( char *s ) {
YAPQuery *n = new YAPQuery( s );
return n;
}

View File

@ -13,16 +13,31 @@
* with the swig interface language generator. It uses ideas from the old YAP
* interface and from the SWI foreign language interface.
*
* @{
*
*/
#include <stdlib.h>
// Bad export from Python
#ifdef HAVE_STAT
#undef HAVE_STAT
#endif
#include <config.h>
extern "C" {
#include <stddef.h>
#ifdef __cplusplus
#define old_cplusplus __cplusplus
#undef __cplusplus
#endif
#if USE_GMP
#include <gmp.h>
#endif
extern "C" {
#ifdef old_cplusplus
#define __cplusplus old_cplusplus
#undef old_cplusplus
#endif
#include "Yap.h"
@ -44,6 +59,8 @@ extern "C" {
#include "YapText.h"
#include "yapie.hh"
#if HAVE_STDARG_H
#include <stdarg.h>
#endif
@ -56,382 +73,534 @@ extern "C" {
#include <string.h>
#endif
#if _MSC_VER || defined(__MINGW32__)
#if _MSC_VER || defined(__MINGW32__)
#include <windows.h>
#endif
#Ifdef CACHE_REGS
#ifdef CACHE_REGS
#undef CACHE_REGS
#endif
// taken from yap_structs.h
#include "iopreds.h"
// we cannot consult YapInterface.h, that conflicts with what we declare, though
// it shouldn't
extern Term Yap_StringToTerm(const char *s, size_t len, term_t bindings);
// we cannot consult YapInterface.h, that conflicts with what we declare, though
// it shouldn't
}
//#include <vector>
class YAPEngine;
class YAPTermHandle;
class YAPAtom;
class YAPFunctor;
class YAPApplTerm;
class YAPPairTerm;
class YAPQuery;
/**
* @brief Generic Prolog Term
*/
class YAPTerm {
friend class YAPPredicate;
friend class YAPTermHandle;
friend class YAPApplTerm;
friend class YAPPairTerm;
friend class YAPPredicate;
friend class YAPApplTerm;
friend class YAPPairTerm;
friend class YAPListTerm;
friend class YAPQuery;
protected:
Term t;
yhandle_t t; /// handle to term, equivalent to term_t
void mk(Term t0); /// internal method to convert from term to handle
Term gt(); /// get handle and obtain term
YAPTerm(Term tn) { mk( tn ); } /// private method to convert from Term (internal YAP representation) to YAPTerm
inline Term term() { return gt(); } /// private method to convert from YAPTerm to Term (internal YAP representation)
public:
YAPTerm() { t = TermNil; } // do nothing constructor
YAPTerm(void *ptr) { CACHE_REGS t = MkIntegerTerm( (Int)ptr ); }
YAPTerm(Term tn) { t = tn; }
YAPTerm(char *s) { Term tp ; t = YAP_ReadBuffer(s,&tp); }
// do nothing constructor
YAPTerm() { mk(TermNil); }
/// integer to term
YAPTerm(intptr_t i);
/// pointer to term
YAPTerm(void *ptr);
/// parse string s and construct a term.
YAPTerm(char *s) { Term tp ; mk( YAP_ReadBuffer(s,&tp) ); }
/// extract the tag of a term, after dereferencing.
YAP_tag_t tag();
/// copy the term ( term copy )
YAPTerm deepCopy();
//const YAPTerm *vars();
/// this term is == to t1
bool exactlyEqual(YAPTerm t1);
bool unify(YAPTerm t1); /// t = t1
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
intptr_t hashTerm(size_t sz, size_t depth, bool variant); /// term hash,
bool isVar() { return IsVarTerm( gt() ); } /// type check for unbound
bool isAtom() { return IsAtomTerm( gt() ); } /// type check for atom
bool isInteger() { return IsIntegerTerm( gt() ); } /// type check for integer
bool isFloat() { return IsFloatTerm( gt() ); } /// type check for floating-point
bool isString() { return IsStringTerm( gt() ); } /// type check for a string " ... "
bool isCompound() { return !(IsVarTerm( gt() ) || IsNumTerm( gt() )); } /// is a primitive term
bool isAppl() { return IsApplTerm( gt() ); } /// is a structured term
bool isPair() { return IsPairTerm( gt() ); } /// is a pair term
bool isGround() { return Yap_IsGroundTerm( gt() ); } /// term is ground
bool isList() { return Yap_IsListTerm( gt() ); } /// term is a list
YAP_tag_t tag();
YAPTerm deepCopy();
bool exactlyEqual(YAPTerm t1);
bool unify(YAPTerm t1);
bool unifiable(YAPTerm t1);
bool variant(YAPTerm t1);
intptr_t hash(size_t sz, size_t depth, bool variant);
bool isVar() { return IsVarTerm(t); }
bool isAtom() { return IsAtomTerm(t); }
bool isInteger() { return IsIntegerTerm(t); }
bool isFloat() { return IsFloatTerm(t); }
bool isCompound() { return !(IsVarTerm(t) || IsNumTerm(t)); }
bool isAppl() { return IsApplTerm(t); }
bool isPair() { return IsPairTerm(t); }
bool isGround() { return Yap_IsGroundTerm(t); }
bool isList() { return Yap_IsListTerm(t); }
bool isString() { return IsStringTerm(t); }
/// extract the argument i of the term, where i in 1...arity
inline YAPTerm getArg(int i) {
Term t0 = gt();
if (IsApplTerm(t0))
return YAPTerm(ArgOfTerm(i, t0));
else if (IsPairTerm(t0)) {
if (i==1)
return YAPTerm(HeadOfTerm(t0));
if (i==2)
return YAPTerm(TailOfTerm(t0));
}
return YAPTerm((Term)0);
}
/// return a string with a textual representation of the term
char *text();
};
/**
* @brief Variable Term
*/
class YAPVarTerm: private YAPTerm {
class YAPVarTerm: public YAPTerm {
YAPVarTerm(Term t) { if (IsVarTerm(t)) mk( t ); }
public:
YAPVarTerm(): YAPTerm() { CACHE_REGS t = MkVarTerm(); }
CELL *getVar() { return VarOfTerm(t); }
bool unbound() { return IsUnboundVar(VarOfTerm(t)); }
/// constructor
YAPVarTerm();
/// get the internal representation
CELL *getVar() { return VarOfTerm( gt() ); }
/// is the variable bound to another one
bool unbound() { return IsUnboundVar(VarOfTerm( gt() )); }
};
/**
* @brief Compound Term
*/
class YAPApplTerm: private YAPTerm {
class YAPApplTerm: public YAPTerm {
friend class YAPTerm;
YAPApplTerm(Term t0) { mk(t0); }
public:
YAPApplTerm(YAPFunctor f, YAPTerm ts[]);
YAPApplTerm(YAPFunctor f);
YAPFunctor getFunctor();
YAPTerm getArg(unsigned int i);
YAPApplTerm(YAPTerm t0) { mk(t0.term()); }
YAPApplTerm(YAPFunctor f, YAPTerm ts[]);
YAPApplTerm(YAPFunctor f);
YAPFunctor getFunctor();
YAPTerm getArg(int i);
};
/**
* @brief List Constructor Term
*/
class YAPPairTerm: private YAPTerm {
class YAPPairTerm: public YAPTerm {
friend class YAPTerm;
YAPPairTerm(Term t0) { if (IsPairTerm(t0)) mk( t0 ); else mk(0); }
public:
YAPPairTerm(YAPTerm hd, YAPTerm tl);
YAPPairTerm();
YAPTerm getHead() { return YAPTerm(HeadOfTerm(t)); }
YAPTerm getTail() { return YAPTerm(TailOfTerm(t)); }
YAPPairTerm(YAPTerm hd, YAPTerm tl);
YAPPairTerm();
YAPTerm getHead() { return YAPTerm(HeadOfTerm( gt() )); }
YAPTerm getTail() { return YAPTerm(TailOfTerm( gt() )); }
};
/**
* @brief Integer Term
*/
class YAPIntegerTerm: private YAPTerm {
class YAPIntegerTerm: public YAPTerm {
public:
YAPIntegerTerm(intptr_t i) { CACHE_REGS t = MkIntegerTerm( i ); }
intptr_t getInteger(YAPIntegerTerm t) { return IntegerOfTerm(t.t); }
bool isTagged(YAPIntegerTerm i) { return IsIntTerm( t ); }
YAPIntegerTerm(intptr_t i);
intptr_t getInteger() { return IntegerOfTerm( gt() ); }
bool isTagged() { return IsIntTerm( gt() ); }
};
/*
class YAPListTerm: private YAPPairTerm {
class YAPListTerm: public YAPTerm {
public:
YAPListTerm(YAPTerm ts[], size_t n);
YAPListTerm(Term ts[], size_t n);
YAPListTerm( vector<YAPTerm> v );
size_t length() { Term *tailp; return Yap_SkipList(&t, &tailp); }
vector<YAPTerm> toVector();
/// Create a list term out of a standard term. Check if a valid operation.
///
/// @param[in] the term
YAPListTerm(Term t0) { mk(t0); /* else type_error */ }
/* /// Create a list term out of an array of terms.
///
/// @param[in] the array of terms
/// @param[in] the length of the array
YAPListTerm(YAPTerm ts[], size_t n);
*/
// YAPListTerm( vector<YAPTerm> v );
/// Return the number of elements in a list term.
size_t length() { Term *tailp; Term t1 = gt(); return Yap_SkipList(&t1, &tailp); }
/// Extract the first element of a list.
///
/// @param[in] the list
YAPTerm car();
/// Extract the tail elements of a list.
///
/// @param[in] the list
YAPListTerm cdr()
{
Term to = gt();
if (IsPairTerm( to ))
return YAPListTerm(TailOfTerm( to ));
else
return MkIntTerm(-1);
}
/// Check if the list is empty.
///
/// @param[in] the list
bool nil();
};
*/
/**
* @brief Atom
*/
class YAPAtom {
friend class YAPPredicate;
friend class YAPFunctor;
friend class YAPAtomTerm;
Atom a;
friend class YAPPredicate;
friend class YAPFunctor;
friend class YAPAtomTerm;
Atom a;
/// construct new YAPAtom from Atom
YAPAtom( Atom at ) { a = at; }
public:
YAPAtom( Atom at ) { a = at; }
YAPAtom( char * s) { a = Yap_LookupAtom( s ); }
YAPAtom( wchar_t * s) { a = Yap_LookupMaybeWideAtom( s ); }
YAPAtom( char * s, size_t len) { a = Yap_LookupAtomWithLength( s, len ); }
YAPAtom( wchar_t * s, size_t len) { a = Yap_LookupMaybeWideAtomWithLength( s, len ); }
char *name(void);
/// construct new YAPAtom from string
YAPAtom( char * s) { a = Yap_LookupAtom( s ); }
/// construct new YAPAtom from wide string
YAPAtom( wchar_t * s) { a = Yap_LookupMaybeWideAtom( s ); }
/// construct new YAPAtom from max-length string
YAPAtom( char * s, size_t len) { a = Yap_LookupAtomWithLength( s, len ); }
/// construct new YAPAtom from max-length wide string
YAPAtom( wchar_t * s, size_t len) { a = Yap_LookupMaybeWideAtomWithLength( s, len ); }
/// get name of atom
char *getName(void);
};
/**
* @brief String Term
*/
class YAPStringTerm: private YAPTerm {
class YAPStringTerm: public YAPTerm {
public:
YAPStringTerm(char *s) ;
YAPStringTerm(char *s, size_t len);
YAPStringTerm(wchar_t *s) ;
YAPStringTerm(wchar_t *s, size_t len);
const char *getString() { return StringOfTerm(t); }
/// your standard constructor
YAPStringTerm(char *s) ;
/// use this one to construct length limited strings
YAPStringTerm(char *s, size_t len);
/// construct using wide chars
YAPStringTerm(wchar_t *s) ;
/// construct using length-limited wide chars
YAPStringTerm(wchar_t *s, size_t len);
const char *getString() { return StringOfTerm( gt() ); }
};
/**
* @brief Atom Term
*/
class YAPAtomTerm: private YAPTerm {
class YAPAtomTerm: public YAPTerm {
public:
YAPAtomTerm(YAPAtom a): YAPTerm() { t = MkAtomTerm(a.a); }
YAPAtomTerm(Atom a): YAPTerm() { t = MkAtomTerm(a); }
YAPAtomTerm(char *s) ;
YAPAtomTerm(char *s, size_t len);
YAPAtomTerm(wchar_t *s) ;
YAPAtomTerm(wchar_t *s, size_t len);
YAPAtom getAtom() { return YAPAtom(AtomOfTerm(t)); }
YAPAtomTerm(YAPAtom a): YAPTerm() { mk( MkAtomTerm(a.a) ); }
YAPAtomTerm(Atom a): YAPTerm() { mk( MkAtomTerm(a) ); }
YAPAtomTerm(char *s) ;
YAPAtomTerm(char *s, size_t len);
YAPAtomTerm(wchar_t *s) ;
YAPAtomTerm(wchar_t *s, size_t len);
YAPAtom getAtom() { return YAPAtom(AtomOfTerm( gt() )); }
};
/**
* @brief Functor
* @brief YAPFunctor represents Prolog functors Name/Arity
*/
class YAPFunctor {
friend class YAPApplTerm;
friend class YAPPredicate;
Functor f;
friend class YAPApplTerm;
friend class YAPPredicate;
Functor f;
/// Constructor: receives Prolog functor and casts it to YAPFunctor
///
/// Notice that this is designed for internal use only.
YAPFunctor( Functor ff) { f = ff; }
public:
YAPFunctor( char * s, unsigned int arity) { f = Yap_MkFunctor( Yap_LookupAtom( s ), arity ); }
YAPFunctor( wchar_t * s, unsigned int arity) { f = Yap_MkFunctor( Yap_LookupWideAtom( s ), arity ); }
YAPFunctor( YAPAtom at, unsigned int arity) { f = Yap_MkFunctor( at.a, arity ); }
YAPFunctor( Functor ff) { f = ff; }
/// Constructor: receives name as a string plus arity
///
/// Notice that this is designed for ISO-LATIN-1 right now
YAPFunctor( char * s, arity_t arity) { f = Yap_MkFunctor( Yap_LookupAtom( s ), arity ); }
/// Constructor: receives name as a wide string plus arity
///
/// 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
YAPFunctor( YAPAtom at, arity_t arity) { f = Yap_MkFunctor( at.a, arity ); }
Atom name(void) {
return NameOfFunctor( f );
}
/// Getter: extract name of functor as an atom
///
/// this is for external usage.
YAPAtom name(void) {
return YAPAtom( NameOfFunctor( f ) );
}
unsigned int arity(void) {
return ArityOfFunctor( f );
}
/// Getter: extract arity of functor as an unsigned integer
///
/// this is for external usage.
arity_t arity(void) {
return ArityOfFunctor( f );
}
};
/**
* @brief Term Handle
*/
class YAPTermHandle {
long int handle;
public:
YAPTermHandle(Term t) {
CACHE_REGS
handle = Yap_InitSlot(t PASS_REGS);
}
~YAPTermHandle(void) {
CACHE_REGS
Yap_RecoverSlots(1, handle PASS_REGS);
}
YAPTerm get() {
CACHE_REGS
return new YAPTerm( Yap_GetFromSlot(handle PASS_REGS) );
}
void set(YAPTerm t) {
CACHE_REGS
Yap_PutInSlot(handle, t.t PASS_REGS);
}
};
/**
* @brief Predicate
* @brief Predicates
*
* This class interfaces with PredEntry in Yatom.g
*/
class YAPPredicate {
friend class YAPQuery;
PredEntry *ap;
// trick to communicate t[] back to yapquery
YAPPredicate(char *s, Term **th) {
CACHE_REGS
Term t, tp, m = CurrentModule ;
t = YAP_ReadBuffer(s,&tp);
t = Yap_StripModule(t, &m);
if (IsVarTerm(t) || IsNumTerm(t))
ap = NULL;
if (IsAtomTerm(t)) {
ap = RepPredProp(PredPropByAtom(AtomOfTerm(t), m));
*th = NULL;
} else if (IsApplTerm(t)) {
ap = RepPredProp(PredPropByFunc(FunctorOfTerm(t), m));
*th = RepAppl(t)+1;
} else {
ap = NULL;
}
}
friend class YAPQuery;
private:
PredEntry *ap;
/// auxiliary routine to find a predicate in the current module.
PredEntry *getPred( Term t, Term **outp ) ;
/// String constructor for predicates
///
/// It also communicates the array of arguments t[] abd the array of variables
/// back to yapquery
YAPPredicate(const char *s, Term **outp, YAPTerm& vnames ) throw (int);
/// Term constructor for predicates
///
/// It is just a call to getPred
inline YAPPredicate(Term t) {
ap = getPred( t , (Term **)NULL );
}
/// Cast constructor for predicates,
/// if we have the implementation data.
///
inline YAPPredicate(PredEntry *pe) {
ap = pe;
}
public:
YAPPredicate(PredEntry *pe) {
ap = pe;
}
YAPPredicate(YAPFunctor f) {
CACHE_REGS
ap = RepPredProp(PredPropByFunc(f.f,CurrentModule));
}
YAPPredicate(YAPFunctor f, YAPTerm mod) {
ap = RepPredProp(PredPropByFunc(f.f,mod.t));
}
YAPPredicate(YAPAtom at, YAPTerm mod) {
ap = RepPredProp(PredPropByAtom(at.a,mod.t));
}
YAPPredicate(YAPAtom at) {
CACHE_REGS
ap = RepPredProp(PredPropByAtom(at.a,CurrentModule));
}
YAPPredicate(YAPAtom at, unsigned int arity, YAPTerm mod) {
if (arity) {
Functor f = Yap_MkFunctor(at.a, arity);
ap = RepPredProp(PredPropByFunc(f,mod.t));
} else {
ap = RepPredProp(PredPropByAtom(at.a,mod.t));
}
}
YAPPredicate(YAPAtom at, unsigned int arity) {
CACHE_REGS
if (arity) {
Functor f = Yap_MkFunctor(at.a, arity);
ap = RepPredProp(PredPropByFunc(f,CurrentModule));
} else {
ap = RepPredProp(PredPropByAtom(at.a,CurrentModule));
}
}
YAPPredicate(char *s) {
CACHE_REGS
Term t, tp, m = CurrentModule ;
t = YAP_ReadBuffer(s,&tp);
t = Yap_StripModule(t, &m);
if (IsVarTerm(t) || IsNumTerm(t))
ap = NULL;
if (IsAtomTerm(t)) {
ap = RepPredProp(PredPropByAtom(AtomOfTerm(t), m));
} else {
ap = RepPredProp(PredPropByFunc(FunctorOfTerm(t), m));
}
}
int call(YAPTerm ts[]);
/// Functor constructor for predicates
///
/// Asssumes that we use the current module.
YAPPredicate(YAPFunctor f);
/// Functor constructor for predicates, is given a specific module.
///
inline YAPPredicate(YAPFunctor f, YAPTerm mod) {
ap = RepPredProp(PredPropByFunc(f.f,mod.t));
}
/// Name/arity constructor for predicates.
///
inline YAPPredicate(YAPAtom at, YAPTerm mod) {
ap = RepPredProp(PredPropByAtom(at.a,mod.t));
}
/// Name/0 constructor for predicates.
///
YAPPredicate(YAPAtom at);
/// Mod:Name/Arity constructor for predicates.
///
inline YAPPredicate(YAPAtom at, arity_t arity, YAPTerm mod) {
if (arity) {
Functor f = Yap_MkFunctor(at.a, arity);
ap = RepPredProp(PredPropByFunc(f,mod.t));
} else {
ap = RepPredProp(PredPropByAtom(at.a,mod.t));
}
}
/// Atom/Arity constructor for predicates.
///
YAPPredicate(YAPAtom at, arity_t arity);
/// String constructor for predicates.
///
/// String is a Prolog term, we extract the main functor after considering the module qualifiers.
inline YAPPredicate(char *s) throw (int) {
Term t, tp;
t = YAP_ReadBuffer(s,&tp);
if (t == 0L)
throw YAPError::YAP_SYNTAX_ERROR;
ap = getPred( t, (Term **)NULL );
}
/// String constructor for predicates, also keeps arguments in tp[]
///
/// String is a Prolog term, we extract the main functor after considering the module qualifiers.
inline YAPPredicate(char *s, Term **outp) throw (int) {
Term t, tp;
t = YAP_ReadBuffer(s,&tp);
if (t == 0L)
throw YAPError::YAP_SYNTAX_ERROR;
ap = getPred( t, (Term **)NULL );
}
/// meta-call this predicate, with arguments ts[]
///
int call(YAPTerm ts[]);
/// module of a predicate
///
/// notice that modules are currently treated as atoms, this should change.
YAPAtom module() {
if (ap->ModuleOfPred == PROLOG_MODULE)
return YAPAtom(AtomProlog);
else
return YAPAtom(AtomOfTerm(ap->ModuleOfPred));
}
/// name of predicate
///
/// notice that we return the atom, not a string.
YAPAtom name() { if (ap->ArityOfPE)
return YAPAtom((Atom)ap->FunctorOfPred);
else
return YAPAtom(NameOfFunctor(ap->FunctorOfPred));
}
/// arity of predicate
///
/// we return a positive number.
arity_t getArity() { return ap->ArityOfPE; }
};
/**
* @brief Term Handle
* @brief Queries
*
* interface to a YAP Query;
* uses an SWI-like status info internally.
*/
class YAPQuery: private YAPPredicate {
int q_open;
int q_state;
Term *q_g;
yamop *q_p, *q_cp;
jmp_buf q_env;
int q_flags;
YAP_dogoalinfo q_h;
YAPQuery *oq;
void initQuery( Term *t );
class YAPQuery: public YAPPredicate {
int q_open;
int q_state;
Term *q_g;
yamop *q_p, *q_cp;
jmp_buf q_env;
int q_flags;
YAP_dogoalinfo q_h;
YAPQuery *oq;
YAPTerm vnames;
void initQuery( Term ts[] );
void initQuery( YAPTerm t[], arity_t arity );
public:
/// full constructor, is given a functor, module, and an array of terms that must hav at least
/// the same arity as the functor.
YAPQuery(YAPFunctor f, YAPTerm mod, YAPTerm t[]);
YAPQuery(YAPFunctor f, YAPTerm t[]);
YAPQuery(YAPPredicate p, YAPTerm t[]);
YAPQuery(char *s);
// YAPQuery(YAPTerm t);
int next();
void cut();
void close();
/// main constructor, uses a predicate and an array of terms
///
/// It is given a YAPPredicate _p_ , and an array of terms that must have at least
/// the same arity as the functor.
YAPQuery(YAPPredicate p, YAPTerm t[]);
/// full constructor,
///
/// It is given a functor, module, and an array of terms that must have at least
/// the same arity as the functor.
YAPQuery(YAPFunctor f, YAPTerm mod, YAPTerm t[]);
/// functor/term constructor,
///
/// It is given a functor, and an array of terms that must have at least
/// the same arity as the functor. Works within the current module.
YAPQuery(YAPFunctor f, YAPTerm t[]);
/// string constructor without varnames
///
/// It is given a string, calls the parser and obtains a Prolog term that should be a callable
/// goal. It does not ask for a list of variables.
inline YAPQuery(char *s): YAPPredicate(s, &this->q_g)
{
this->vnames = vnames;
Term *ts = this->q_g;
initQuery( ts );
}
/// string constructor with varnames
///
/// It is given a string, calls the parser and obtains a Prolog term that should be a callable
/// goal and a list of variables. Useful for top-level simulation. Works within the current module.
inline YAPQuery(char *s, YAPTerm &vnames): YAPPredicate(s, &this->q_g, vnames)
{
this->vnames = vnames;
Term *ts = this->q_g;
initQuery( ts );
}
/// set flags for query execution, currently only for exception handling
void setFlag(int flag) {q_flags |= flag; }
/// reset flags for query execution, currently only for exception handling
void resetFlag(int flag) {q_flags &= ~flag; }
/// first query
///
/// actually implemented by calling the next();
inline bool first() { return next(); }
/// ask for the next solution of the current query
/// same call for every solution
bool next();
/// remove alternatives in the current search space, and finish the current query
void cut();
/// finish the current query: undo all bindings.
void close();
/// query variables.
YAPListTerm namedVars();
};
class YAPParams;
// Java support
/// This class implements a callback Prolog-side. It will be inherited by the Java or Python
/// class that actually implements the callback.
class YAPCallback {
public:
virtual ~YAPCallback() { printf("~YAPCallback\n"); }
virtual void run() { __android_log_print(ANDROID_LOG_INFO, __FUNCTION__, "callback"); }
virtual void run(char *s) { }
};
/**
* @brief YAP Constructor
* @brief YAP Engine: takes care of the execution environment
where we can go executing goals.
*
*
*/
class YAPEngine {
private:
YAPCallback *_callback;
YAP_init_args init_args;
YAPError yerror;
public:
YAPEngine(YAPParams const& params); /// construct a new engine
YAPQuery *query( char *s ) { return new YAPQuery( s ); } /// build a query on the engine
YAPEngine(char *savedState = (char *)NULL,
size_t stackSize = 0,
size_t trailSize = 0,
size_t maxStackSize = 0,
size_t maxTrailSize = 0,
char *libDir = (char *)NULL,
char *bootFile = (char *)NULL,
char *goal = (char *)NULL,
char *topLevel = (char *)NULL,
bool script = FALSE,
bool fastBoot = FALSE,
YAPCallback *callback=(YAPCallback *)NULL); /// construct a new engine, including aaccess to callbacks
/// kill engine
~YAPEngine() { delYAPCallback(); }
/// remove current callback
void delYAPCallback() { _callback = 0; }
/// set a new callback
void setYAPCallback(YAPCallback *cb) { delYAPCallback(); _callback = cb; }
/// execute the callback.
void run() { if (_callback) _callback->run(); }
/// execute the callback with a text argument.
void run( char *s) { if (_callback) _callback->run(s); }
/// execute the callback with a text argument.
YAPError hasError( ) { return yerror; }
/// build a query on the engine
YAPQuery *query( char *s );
};
/**
* @brief Parameters for YAP Constructor
* @}
*
*/
class YAPParams {
friend class YAPEngine;
YAP_init_args init_args;
public:
YAPParams();
// sets all the default values for each data member
YAPParams& savedState( char * f);
YAPParams& stackSize(size_t sz);
YAPParams& trailSize(size_t sz);
YAPParams& maxStackSize(size_t sz);
YAPParams& maxTrailSize(size_t sz);
YAPParams& libDir(char *p);
YAPParams& bootFile(char *f);
YAPParams& goal(char *g);
YAPParams& topLevel(char *g);
YAPParams& script(bool v);
YAPParams& fastBoot(bool v);
};
inline YAPParams::YAPParams()
{ Yap_InitDefaults( &init_args, NULL ); }
inline YAPParams& YAPParams::savedState( char * f)
{ init_args.SavedState = f; return *this; }
inline YAPParams& YAPParams::stackSize(size_t sz)
{ init_args.StackSize = sz; return *this; }
inline YAPParams& YAPParams::trailSize(size_t sz)
{ init_args.TrailSize = sz; return *this; }
inline YAPParams& YAPParams::maxStackSize(size_t sz)
{ init_args.MaxStackSize = sz; return *this; }
inline YAPParams& YAPParams::maxTrailSize(size_t sz)
{ init_args.MaxTrailSize = sz; return *this; }
inline YAPParams& YAPParams::libDir(char *p)
{ init_args.YapLibDir = p; return *this; }
inline YAPParams& YAPParams::bootFile(char *f)
{ init_args.YapPrologBootFile = f; return *this; }
inline YAPParams& YAPParams::goal(char *g)
{ init_args.YapPrologGoal = g; return *this; }
inline YAPParams& YAPParams::topLevel(char *g)
{ init_args.YapPrologTopLevelGoal = g; return *this; }
inline YAPParams& YAPParams::script(bool v)
{ init_args.HaltAfterConsult = v; return *this; }
inline YAPParams& YAPParams::fastBoot(bool v)
{ init_args.FastBoot = v; return *this; }

16
CXX/yapie.hh Normal file
View File

@ -0,0 +1,16 @@
class YAPError {
public:
static const int YAP_SYNTAX_ERROR = 0x10000; //> syntax error
static const int YAP_DOMAIN_ERROR = 0x20000; //> usually illegal parameter, like asin( 2 )
static const int YAP_TYPE_ERROR = 0x40000; //> usually illegal parameter in the language, like ( 2 mod 3.0 )
static const int YAP_PERMISSION_ERROR = 0x80000; //> wrong para,eter
static const int YAP_EVALUATION_ERROR = 0x100000; //> bad arithmetic expressions
static const int YAP_RESOURCE_ERROR = 0x200000; //> no resource available, like MEM
static const int YAP_REPRESENTATION_ERROR = 0x400000; //> bad UTF-8 strings, etc
static const int YAP_EXISTENCE_ERROR = 0x800000; //> object not found
static const int YAP_PROFILER = 0x100000; //> improve profiling support.
static const int YAP_OTHER_ERROR = 0x2000000; //> anything
};

View File

@ -18,12 +18,13 @@
#ifndef ATOMS_H
#define ATOMS_H 1
#undef EXTERN
#ifndef EXTERN
#ifndef ADTDEFS_C
#define EXTERN static
#else
#define EXTERN
#endif
#endif
#include <wchar.h>
@ -106,6 +107,7 @@ typedef struct PropEntryStruct
#define MaxArity 255
typedef CELL arity_t;
#define FunctorProperty ((PropFlags)(0xbb00))
@ -114,7 +116,7 @@ typedef struct FunctorEntryStruct
{
Prop NextOfPE; /* used to chain properties */
PropFlags KindOfPE; /* kind of property */
unsigned int ArityOfFE; /* arity of functor */
arity_t ArityOfFE; /* arity of functor */
Atom NameOfFE; /* back pointer to owner atom */
Prop PropsOfFE; /* pointer to list of properties for this functor */
#if defined(YAPOR) || defined(THREADS)

View File

@ -691,6 +691,33 @@ INLINE_ONLY EXTERN inline void restore_B(void) {
#define BBREG BB
#endif /* YAPOR_SBA || TABLING */
// define how to handle frozen segments in tabling, etv.
#ifdef FROZEN_STACKS
#ifdef YAPOR_SBA
#define PROTECT_FROZEN_H(CPTR) \
((Unsigned((Int)((CPTR)->cp_h)-(Int)(H_FZ)) < \
Unsigned((Int)(B_FZ)-(Int)(H_FZ))) ? \
(CPTR)->cp_h : H_FZ)
#define PROTECT_FROZEN_B(CPTR) \
((Unsigned((Int)(CPTR)-(Int)(H_FZ)) < \
Unsigned((Int)(B_FZ)-(Int)(H_FZ))) ? \
(CPTR) : B_FZ)
/*
#define PROTECT_FROZEN_H(CPTR) ((CPTR)->cp_h > H_FZ && (CPTR)->cp_h < (CELL *)B_FZ ? (CPTR)->cp_h : H_FZ )
#define PROTECT_FROZEN_B(CPTR) ((CPTR) < B_FZ && (CPTR) > (choiceptr)H_FZ ? (CPTR) : B_FZ )
*/
#else /* TABLING */
#define PROTECT_FROZEN_B(CPTR) (YOUNGER_CP(CPTR, B_FZ) ? CPTR : B_FZ)
#define PROTECT_FROZEN_H(CPTR) (((CPTR)->cp_h > H_FZ) ? (CPTR)->cp_h : H_FZ)
#endif /* YAPOR_SBA */
#else
#define PROTECT_FROZEN_B(CPTR) (CPTR)
#define PROTECT_FROZEN_H(CPTR) (CPTR)->cp_h
#endif /* FROZEN_STACKS */
#if !defined(THREADS)
/* use actual addresses for regs */
#define PRECOMPUTE_REGADDRESS 1

View File

@ -66,9 +66,10 @@
#define YAP_PROTECTED_MASK 0x00000000L
#include "inline-only.h"
INLINE_ONLY inline EXTERN int IsVarTerm (Term);
INLINE_ONLY inline EXTERN int
INLINE_ONLY int IsVarTerm (Term);
INLINE_ONLY int
IsVarTerm (Term t)
{
return (int) (Signed (t) >= 0);
@ -76,9 +77,9 @@ IsVarTerm (Term t)
INLINE_ONLY inline EXTERN int IsNonVarTerm (Term);
INLINE_ONLY int IsNonVarTerm (Term);
INLINE_ONLY inline EXTERN int
INLINE_ONLY int
IsNonVarTerm (Term t)
{
return (int) (Signed (t) < 0);
@ -86,9 +87,9 @@ IsNonVarTerm (Term t)
INLINE_ONLY inline EXTERN Term *RepPair (Term);
INLINE_ONLY Term *RepPair (Term);
INLINE_ONLY inline EXTERN Term *
INLINE_ONLY Term *
RepPair (Term t)
{
return (Term *) (NonTagPart (t));
@ -96,9 +97,9 @@ RepPair (Term t)
INLINE_ONLY inline EXTERN Term AbsPair (Term *);
INLINE_ONLY Term AbsPair (Term *);
INLINE_ONLY inline EXTERN Term
INLINE_ONLY Term
AbsPair (Term * p)
{
return (Term) (TAGGEDA (PairTag, (p)));
@ -106,9 +107,9 @@ AbsPair (Term * p)
INLINE_ONLY inline EXTERN Int IsPairTerm (Term);
INLINE_ONLY Int IsPairTerm (Term);
INLINE_ONLY inline EXTERN Int
INLINE_ONLY Int
IsPairTerm (Term t)
{
return (Int) (BitOn (PairBit, (t)));
@ -116,9 +117,9 @@ IsPairTerm (Term t)
INLINE_ONLY inline EXTERN Term *RepAppl (Term);
INLINE_ONLY Term *RepAppl (Term);
INLINE_ONLY inline EXTERN Term *
INLINE_ONLY Term *
RepAppl (Term t)
{
return (Term *) (NonTagPart (t));
@ -126,9 +127,9 @@ RepAppl (Term t)
INLINE_ONLY inline EXTERN Term AbsAppl (Term *);
INLINE_ONLY Term AbsAppl (Term *);
INLINE_ONLY inline EXTERN Term
INLINE_ONLY Term
AbsAppl (Term * p)
{
return (Term) (TAGGEDA (ApplTag, (p)));
@ -136,9 +137,9 @@ AbsAppl (Term * p)
INLINE_ONLY inline EXTERN Int IsApplTerm (Term);
INLINE_ONLY Int IsApplTerm (Term);
INLINE_ONLY inline EXTERN Int
INLINE_ONLY Int
IsApplTerm (Term t)
{
return (Int) (BitOn (ApplBit, (t)));
@ -146,9 +147,9 @@ IsApplTerm (Term t)
INLINE_ONLY inline EXTERN Int IsAtomOrIntTerm (Term);
INLINE_ONLY Int IsAtomOrIntTerm (Term);
INLINE_ONLY inline EXTERN Int
INLINE_ONLY Int
IsAtomOrIntTerm (Term t)
{
return (Int) (!(Unsigned (t) & CompBits));
@ -157,9 +158,9 @@ IsAtomOrIntTerm (Term t)
INLINE_ONLY inline EXTERN Term AdjustPtr (Term t, Term off);
INLINE_ONLY Term AdjustPtr (Term t, Term off);
INLINE_ONLY inline EXTERN Term
INLINE_ONLY Term
AdjustPtr (Term t, Term off)
{
return (Term) ((t) + off);
@ -167,9 +168,9 @@ AdjustPtr (Term t, Term off)
INLINE_ONLY inline EXTERN Term AdjustIDBPtr (Term t, Term off);
INLINE_ONLY Term AdjustIDBPtr (Term t, Term off);
INLINE_ONLY inline EXTERN Term
INLINE_ONLY Term
AdjustIDBPtr (Term t, Term off)
{
return (Term) ((t) + off);

View File

@ -14,6 +14,8 @@
* version: $Id: Tags_32LowTag.h,v 1.4 2008-01-30 10:35:43 vsc Exp $ *
*************************************************************************/
#if SIZEOF_INT_P==4 && USE_LOW32_TAGS
#define TAG_LOW_BITS_32 1
/* Version for 32 bit addresses machines,
@ -196,3 +198,6 @@ IntOfTerm (Term t)
{
return (Int) (((Int) (t << 1)) >> (SHIFT_LOW_TAG + SHIFT_HIGH_TAG + 1));
}
#endif

View File

@ -49,6 +49,8 @@ are now 1 in compound terms and structures.
*/
#if SIZEOF_INT_P==4 && !defined(USE_LOW32_TAGS)
#define TAGS_FAST_OPS 1
#define SHIFT_HIGH_TAG 29
@ -320,3 +322,8 @@ AdjustIDBPtr (Term t, Term off)
#endif
#endif /* SIZEOF_INT_P==4 */

View File

@ -37,6 +37,8 @@ property list
*/
#if FALSE
#define SHIFT_HIGH_TAG 29
#define MKTAG(HI,LO) ((((UInt) (HI))<<SHIFT_HIGH_TAG)|(LO))
@ -188,3 +190,5 @@ IntOfTerm (Term t)
{
return (Int) (((Int) (t << 3)) >> (3 + 2));
}
#endif /* NOT IN USE */

View File

@ -21,6 +21,8 @@
* version: $Id: Tags_64bits.h,v 1.3 2008-05-15 13:41:46 vsc Exp $ *
*************************************************************************/
#if SIZEOF_INT_P==8
#define TAG_64BITS 1
/* Version for 64 bit addresses machines,
@ -192,3 +194,7 @@ IntOfTerm (Term t)
{
return (Int) ((Int) (Unsigned (t) << 3) >> 6);
}
#endif /* 64 Bits */

49
H/Yap.h
View File

@ -37,6 +37,10 @@
#error THREADS only works with YAPOR_THREADS
#endif /* THREADS && (YAPOR_COW || YAPOR_SBA || YAPOR_COPY) */
// Bad export from Python
#ifdef HAVE_STAT
#undef HAVE_STAT
#endif
#include "config.h"
#define FunAdr(X) X
@ -49,6 +53,13 @@
/* bzero */
#include <strings.h>
#endif
#if HAVE_STDINT_H
#include <stdint.h>
#endif
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
/*
@ -86,6 +97,10 @@
#define TERM_EXTENSIONS 1
#endif /* COROUTINING && !TERM_EXTENSIONS */
/* truth-values */
#define TRUE 1
#define FALSE 0
/* Microsoft's Visual C++ Compiler */
#ifdef _MSC_VER /* adjust a config.h from mingw32 to work with vc++ */
#ifdef HAVE_GCC
@ -155,10 +170,6 @@
#define EXTERN
#endif /* ADTDEFS_C */
/* truth-values */
#define TRUE 1
#define FALSE 0
/* null pointer */
#define NIL 0
@ -280,6 +291,12 @@ typedef pthread_rwlock_t rwlock_t;
#include <locks_pthread.h>
#endif
#define FUNC_READ_LOCK(X) READ_LOCK((X)->FRWLock)
#define FUNC_READ_UNLOCK(X) READ_UNLOCK((X)->FRWLock)
#define FUNC_WRITE_LOCK(X) WRITE_LOCK((X)->FRWLock)
#define FUNC_WRITE_UNLOCK(X) WRITE_UNLOCK((X)->FRWLock)
/*************************************************************************************************
use an auxiliary function for ranges
*************************************************************************************************/
@ -296,6 +313,14 @@ typedef pthread_rwlock_t rwlock_t;
#define OUTSIDE(MIN,X,MAX) ((void *)(X) < (void *)(MIN) || (void *)(X) > (void *)(MAX))
#endif
/*************************************************************************************************
main exports in YapInterface.h
*************************************************************************************************/
/* Basic exports */
#include "YapDefs.h"
/*************************************************************************************************
Atoms
*************************************************************************************************/
@ -438,6 +463,21 @@ extern ADDR Yap_HeapBase;
extern int Yap_output_msg;
#endif
#if __ANDROID__
#include <android/asset_manager.h>
#include <android/asset_manager_jni.h>
#include <android/log.h>
#else
static inline char * __android_log_print(int i,const char *loc,const char *msg,...) {
return NULL;
}
#define ANDROID_LOG_INFO 0
#define ANDROID_LOG_ERROR 0
#define ANDROID_LOG_DEBUG 0
#endif
/*************************************************************************************************
variables concerned with atoms table
*************************************************************************************************/
@ -675,7 +715,6 @@ typedef struct scratch_block_struct {
#endif /* YAPOR || TABLING */
/*************************************************************************************************
GLOBAL and LOCAL variables
*************************************************************************************************/

View File

@ -19,7 +19,7 @@
/**
@group term_t_slots
@groupdef term_t_slots
Also known as term handles, slots are offsets to entries in the local stack. YAP never compresses the local stack, so slots are respected by the garbage collector,
hence providing a way to access terms without being exposed to stack shifts or garbage-collection.
@ -28,13 +28,13 @@ hence providing a way to access terms without being exposed to stack shifts or g
of a function. Hence, slots should always be used as local variables.
Slots are organized as follows:
---- Offset of next pointer in chain (tagged as an Int)
---- Number of entries (tagged as Int), in the example TAG(INT,4)
---- Offset of next pointer in chain (tagged as an handle_t)
---- Number of entries (tagged as handle_t), in the example TAG(INT,4)
Entry
Entry
Entry
Entry
---- Number of entries (tagged as Int), in the example TAG(INT,4)
---- Number of entries (tagged as handle_t), in the example TAG(INT,4)
Slots are not known to the yaam. Instead, A new set of slots is created when the emulator calls user C-code.
(see YAP_Execute* functions). They are also created:
@ -49,9 +49,9 @@ This section lists the main internal functions for slot management. These functi
*************************************************************************************************/
/// @brief start a new set of slots, linking them to the last active slots (who may, or not, be active).
static inline Int
static inline yhandle_t
Yap_StartSlots( USES_REGS1 ) {
Int CurSlot = LOCAL_CurSlot;
yhandle_t CurSlot = LOCAL_CurSlot;
// if (CurSlot == LCL0-(ASP+(IntOfTerm(ASP[0])+2)))
// return CurSlot;
/* new slot */
@ -65,56 +65,56 @@ Yap_StartSlots( USES_REGS1 ) {
/// @brief reset slots to a well-known position in the stack
static inline void
Yap_CloseSlots( Int slot USES_REGS ) {
Yap_CloseSlots( yhandle_t slot USES_REGS ) {
LOCAL_CurSlot = slot;
}
/// @brief report the current position of the slots, assuming that they occupy the top of the stack.
static inline Int
static inline yhandle_t
Yap_CurrentSlot( USES_REGS1 ) {
return IntOfTerm(ASP[0]);
}
/// @brief read from a slot.
static inline Term
Yap_GetFromSlot(Int slot USES_REGS)
Yap_GetFromSlot(yhandle_t slot USES_REGS)
{
return(Deref(LCL0[slot]));
}
/// @brief read from a slot. but does not try to dereference the slot.
static inline Term
Yap_GetDerefedFromSlot(Int slot USES_REGS)
Yap_GetDerefedFromSlot(yhandle_t slot USES_REGS)
{
return LCL0[slot];
}
/// @brief read the object in a slot. but do not try to dereference the slot.
static inline Term
Yap_GetPtrFromSlot(Int slot USES_REGS)
Yap_GetPtrFromSlot(yhandle_t slot USES_REGS)
{
return(LCL0[slot]);
}
/// @brief get the memory address of a slot
static inline Term *
Yap_AddressFromSlot(Int slot USES_REGS)
Yap_AddressFromSlot(yhandle_t slot USES_REGS)
{
return(LCL0+slot);
}
/// @brief store term in a slot
static inline void
Yap_PutInSlot(Int slot, Term t USES_REGS)
Yap_PutInSlot(yhandle_t slot, Term t USES_REGS)
{
LCL0[slot] = t;
}
/// @brief allocate n empty new slots
static inline Int
static inline yhandle_t
Yap_NewSlots(int n USES_REGS)
{
Int old_slots = IntOfTerm(ASP[0]), oldn = n;
yhandle_t old_slots = IntOfTerm(ASP[0]), oldn = n;
while (n > 0) {
RESET_VARIABLE(ASP);
ASP--;
@ -128,7 +128,7 @@ Yap_NewSlots(int n USES_REGS)
static inline Int
Yap_InitSlot(Term t USES_REGS)
{
Int old_slots = IntOfTerm(ASP[0]);
yhandle_t old_slots = IntOfTerm(ASP[0]);
*ASP = t;
ASP--;
ASP[old_slots+2] = ASP[0] = MkIntTerm(old_slots+1);
@ -137,9 +137,9 @@ Yap_InitSlot(Term t USES_REGS)
/// @brief Succeeds if it is to recover the space allocated for $n$ contiguos slots starting at topSlot.
static inline int
Yap_RecoverSlots(int n, Int topSlot USES_REGS)
Yap_RecoverSlots(int n, yhandle_t topSlot USES_REGS)
{
Int old_slots = IntOfTerm(ASP[0]);
yhandle_t old_slots = IntOfTerm(ASP[0]);
if (old_slots < n) {
return FALSE;
}

View File

@ -16,6 +16,13 @@
#ifndef YAP_H
#include "YapTermConfig.h"
#if HAVE_STDINT_H
#include <stdint.h>
#endif
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
typedef void *Functor;
typedef void *Atom;
@ -31,11 +38,12 @@ typedef void *Atom;
/* defines integer types Int and UInt (unsigned) with the same size as a ptr
** and integer types Short and UShort with half the size of a ptr */
/* */ typedef intptr_t Int;
/* */ typedef uintptr_t UInt;
#if SIZEOF_INT_P==4
#if SIZEOF_INT==4
/* */ typedef int Int;
/* */ typedef unsigned int UInt;
#define Int_FORMAT "%d"
#define UInt_FORMAT "%u"
@ -62,22 +70,16 @@ typedef void *Atom;
#elif SIZEOF_INT_P==8
#if SIZEOF_INT==8
/* */ typedef int Int;
/* */ typedef unsigned int UInt;
#define Int_FORMAT "%d"
#define UInt_FORMAT "%u"
#elif SIZEOF_LONG_INT==8
/* */ typedef long int Int;
/* */ typedef unsigned long int UInt;
#define Int_FORMAT "%ld"
#define UInt_FORMAT "%lu"
# elif SIZEOF_LONG_LONG_INT==8
/* */ typedef long long int Int;
/* */ typedef unsigned long long int UInt;
#define Int_FORMAT "%I64d"
#define UInt_FORMAT "%I64u"
@ -129,6 +131,8 @@ typedef UInt BITS32;
typedef CELL Term;
typedef Int yhandle_t;
/* */ typedef double Float;
#if SIZEOF_INT<SIZEOF_INT_P

View File

@ -370,7 +370,7 @@ Yap_ListOfAtomsToAtom(Term t0 USES_REGS)
inp.type = YAP_STRING_ATOMS;
out.type = YAP_STRING_ATOM;
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
return NULL;
return (Atom)NULL;
return out.val.a;
}
@ -406,7 +406,7 @@ Yap_ListOfCodesToAtom(Term t0 USES_REGS)
inp.type = YAP_STRING_CODES;
out.type = YAP_STRING_ATOM;
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
return NULL;
return (Atom)NULL;
return out.val.a;
}
@ -870,7 +870,7 @@ Yap_ConcatAtoms(Term t1, Term t2 USES_REGS)
inpv[1].sz = 0;
out.type = YAP_STRING_ATOM;
if (!Yap_Concat_Text(2, inpv, &out PASS_REGS))
return NULL;
return (Atom)NULL;
return out.val.a;
}
@ -886,7 +886,7 @@ Yap_ConcatAtomics(Term t1, Term t2 USES_REGS)
inpv[1].sz = 0;
out.type = YAP_STRING_ATOM;
if (!Yap_Concat_Text(2, inpv, &out PASS_REGS))
return NULL;
return (Atom)NULL;
return out.val.a;
}
@ -921,8 +921,8 @@ Yap_SpliceAtom(Term t1, Atom ats[], size_t cut, size_t max USES_REGS)
outv[0].sz = 0;
outv[1].type = YAP_STRING_ATOM;
outv[1].sz = 0;
if (!Yap_Splice_Text(2, cuts, &inp, NULL, outv PASS_REGS))
return NULL;
if (!Yap_Splice_Text(2, cuts, &inp, (encoding_t *)NULL, outv PASS_REGS))
return (Atom)NULL;
ats[0] = outv[0].val.a;
ats[1] = outv[1].val.a;
return ats[0];
@ -941,8 +941,8 @@ Yap_SubtractHeadAtom(Term t1, Term th USES_REGS)
outv[1].type = YAP_STRING_ATOM;
outv[1].val.t = 0;
outv[1].sz = 0;
if (!Yap_Splice_Text(2, NULL, &inp, NULL, outv PASS_REGS))
return NULL;
if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, (encoding_t *)NULL, outv PASS_REGS))
return (Atom)NULL;
return outv[1].val.a;
}
@ -959,8 +959,8 @@ Yap_SubtractTailAtom(Term t1, Term th USES_REGS)
outv[0].sz = 0;
outv[1].type = YAP_STRING_ATOM;
outv[1].val.t = th;
if (!Yap_Splice_Text(2, NULL, &inp, NULL, outv PASS_REGS))
return NULL;
if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, (encoding_t *)NULL, outv PASS_REGS))
return (Atom)NULL;
return outv[0].val.a;
}
@ -977,7 +977,7 @@ Yap_SpliceString(Term t1, Term ts[], size_t cut, size_t max USES_REGS)
outv[1].sz = 0;
cuts[0] = cut;
cuts[1] = max;
if (!Yap_Splice_Text(2, cuts, &inp, NULL, outv PASS_REGS))
if (!Yap_Splice_Text(2, cuts, &inp, (encoding_t *)NULL, outv PASS_REGS))
return 0L;
ts[0] = outv[0].val.t;
ts[1] = outv[1].val.t;
@ -997,7 +997,7 @@ Yap_SubtractHeadString(Term t1, Term th USES_REGS)
outv[1].type = YAP_STRING_STRING;
outv[1].val.t = 0;
outv[1].sz = 0;
if (!Yap_Splice_Text(2, NULL, &inp, NULL, outv PASS_REGS))
if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, (encoding_t *)NULL, outv PASS_REGS))
return 0L;
return outv[1].val.t;
}
@ -1014,7 +1014,7 @@ Yap_SubtractTailString(Term t1, Term th USES_REGS)
outv[0].sz = 0;
outv[1].type = YAP_STRING_STRING;
outv[1].val.t = th;
if (!Yap_Splice_Text(2, NULL, &inp, NULL, outv PASS_REGS))
if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, (encoding_t *)NULL, outv PASS_REGS))
return 0L;
return outv[0].val.t;
}

View File

@ -25,13 +25,13 @@ int Yap_GetName(char *,UInt,Term);
Term Yap_GetValue(Atom);
int Yap_HasOp(Atom);
struct operator_entry *Yap_GetOpPropForAModuleHavingALock(AtomEntry *, Term);
Atom Yap_LookupAtom(char *);
Atom Yap_LookupAtomWithLength(char *, size_t);
Atom Yap_LookupUTF8Atom(char *);
Atom Yap_LookupMaybeWideAtom(wchar_t *);
Atom Yap_LookupMaybeWideAtomWithLength(wchar_t *, size_t);
Atom Yap_FullLookupAtom(char *);
void Yap_LookupAtomWithAddress(char *,AtomEntry *);
Atom Yap_LookupAtom(const char *);
Atom Yap_LookupAtomWithLength(const char *, size_t);
Atom Yap_LookupUTF8Atom(const char *);
Atom Yap_LookupMaybeWideAtom(const wchar_t *);
Atom Yap_LookupMaybeWideAtomWithLength(const wchar_t *, size_t);
Atom Yap_FullLookupAtom(const char *);
void Yap_LookupAtomWithAddress(const char *,AtomEntry *);
Prop Yap_NewPredPropByFunctor(struct FunctorEntryStruct *, Term);
Prop Yap_NewPredPropByAtom(struct AtomEntryStruct *, Term);
Prop Yap_PredPropByFunctorNonThreadLocal(struct FunctorEntryStruct *, Term);
@ -126,7 +126,7 @@ void Yap_InitCdMgr(void);
struct pred_entry * Yap_PredFromClause( Term t USES_REGS );
int Yap_discontiguous(struct pred_entry *ap USES_REGS );
int Yap_multiple(struct pred_entry *ap USES_REGS );
void Yap_init_consult(int, char *);
void Yap_init_consult(int, const char *);
void Yap_end_consult(void);
void Yap_Abolish(struct pred_entry *);
void Yap_BuildMegaClause(struct pred_entry *);
@ -182,6 +182,7 @@ Int Yap_exec_absmi(int);
void Yap_trust_last(void);
Term Yap_GetException(void);
void Yap_PrepGoal(UInt, CELL *, choiceptr USES_REGS);
int Yap_execute_pred(struct pred_entry *ppe, CELL *pt USES_REGS);
int Yap_dogc( int extra_args, Term *tp USES_REGS );
/* exo.c */
@ -244,12 +245,12 @@ void Yap_DebugEndline(void);
int Yap_DebugGetc(void);
#endif
int Yap_IsOpType(char *);
void Yap_InitCPred(char *, unsigned long int, CPredicate, UInt);
void Yap_InitAsmPred(char *, unsigned long int, int, CPredicate, UInt);
void Yap_InitCmpPred(char *, unsigned long int, CmpPredicate, UInt);
void Yap_InitCPredBack(char *, unsigned long int, unsigned int, CPredicate,CPredicate,UInt);
void Yap_InitCPredBackCut(char *, unsigned long int, unsigned int, CPredicate,CPredicate,CPredicate,UInt);
void Yap_InitCPredBack_(char *, unsigned long int, unsigned int, CPredicate,CPredicate,CPredicate,UInt);
void Yap_InitCPred(const char *, UInt, CPredicate, UInt);
void Yap_InitAsmPred(const char *, UInt, int, CPredicate, UInt);
void Yap_InitCmpPred(const char *, UInt, CmpPredicate, UInt);
void Yap_InitCPredBack(const char *, UInt, unsigned int, CPredicate,CPredicate,UInt);
void Yap_InitCPredBackCut(const char *, UInt, unsigned int, CPredicate,CPredicate,CPredicate,UInt);
void Yap_InitCPredBack_(const char *, UInt, unsigned int, CPredicate,CPredicate,CPredicate,UInt);
void Yap_InitWorkspace(UInt,UInt,UInt,UInt,UInt,int,int,int);
#ifdef YAPOR
@ -368,7 +369,7 @@ int Yap_signal_index(const char *);
#ifdef MAC
void Yap_SetTextFile(char *);
#endif
int Yap_getcwd(const char *, int);
char *Yap_getcwd(const char *, size_t);
void Yap_cputime_interval(Int *,Int *);
void Yap_systime_interval(Int *,Int *);
void Yap_walltime_interval(Int *,Int *);
@ -385,6 +386,8 @@ void Yap_WinError(char *);
/* threads.c */
void Yap_InitThreadPreds(void);
void Yap_InitFirstWorkerThreadHandle(void);
int Yap_ThreadID( void );
int Yap_NOfThreads( void );
#if THREADS
int Yap_InitThread(int);
#endif
@ -425,6 +428,7 @@ int Yap_IsAcyclicTerm(Term);
void Yap_InitUtilCPreds(void);
Int Yap_TermHash(Term, Int, Int, int);
Int Yap_NumberVars(Term, Int, int);
Term Yap_TermVariables( Term t, UInt arity USES_REGS );
Term Yap_UnNumberTerm(Term, int);
Int Yap_SkipList(Term *, Term **);
/* yap.c */

View File

@ -657,8 +657,8 @@ typedef enum
{
DiscontiguousPredFlag = ((UInt)0x00000010 << EXTRA_FLAG_BASE), /* predicates whose clauses may be all-over the place.. */
SysExportPredFlag = ((UInt)0x00000008 << EXTRA_FLAG_BASE), /* reuse export list to prolog module. */
NoDebugPredFlag = ((UInt)0x00000004 << EXTRA_FLAG_BASE), /* cannot trace this preducate */
NoTracePredFlag = ((UInt)0x00000002 << EXTRA_FLAG_BASE), /* cannot trace this preducate */
NoTracePredFlag = ((UInt)0x00000004 << EXTRA_FLAG_BASE), /* cannot trace this predicate */
NoSpyPredFlag = ((UInt)0x00000002 << EXTRA_FLAG_BASE), /* cannot spy this predicate */
QuasiQuotationPredFlag = ((UInt)0x00000001 << EXTRA_FLAG_BASE), /* SWI-like quasi quotations */
MegaClausePredFlag = (UInt)0x80000000, /* predicate is implemented as a mega-clause */
ThreadLocalPredFlag = (UInt)0x40000000, /* local to a thread */
@ -1267,7 +1267,7 @@ Yap_GetTranslationProp(Atom at)
while (p0 && p->KindOfPE != TranslationProperty)
p = RepTranslationProp(p0 = p->NextOfPE);
READ_UNLOCK(ae->ARWLock);
if (p0 == NIL) return NULL;
if (p0 == NIL) return (TranslationEntry *)NULL;
return p;
}
@ -1655,10 +1655,10 @@ PredPropByFunc (Functor fe, Term cur_mod)
{
Prop p0;
WRITE_LOCK (fe->FRWLock);
FUNC_WRITE_LOCK (fe);
p0 = GetPredPropByFuncHavingLock(fe, cur_mod);
if (p0) {
WRITE_UNLOCK (fe->FRWLock);
FUNC_WRITE_UNLOCK (fe);
return p0;
}
return Yap_NewPredPropByFunctor (fe, cur_mod);
@ -1713,10 +1713,10 @@ PredPropByFuncAndMod (Functor fe, Term cur_mod)
{
Prop p0;
WRITE_LOCK (fe->FRWLock);
FUNC_WRITE_LOCK (fe);
p0 = GetPredPropByFuncAndModHavingLock(fe, cur_mod);
if (p0) {
WRITE_UNLOCK (fe->FRWLock);
FUNC_WRITE_UNLOCK (fe);
return p0;
}
return Yap_NewPredPropByFunctor (fe, cur_mod);

View File

@ -379,7 +379,7 @@ restore_absmi_regs(REGSTORE * old_regs)
#define DO_PREFETCH(TYPE) to_go = (void *)(NEXTOP(PREG,TYPE)->opc)
#define DO_PREFETCH_W(TYPE) to_go = (void *)(NEXTOP(PREG,TYPE)->u.o.opcw)
#define DO_PREFETCH_W(TYPE) to_go = (void *)(NEXTOP(PREG,TYPE)->y_u.o.opcw)
#if LIMITED_PREFETCH||USE_PREFETCH
@ -466,7 +466,7 @@ restore_absmi_regs(REGSTORE * old_regs)
JMP((void *)(PREG->opc))
#define JMPNextW() \
JMP((void *)(PREG->u.o.opcw))
JMP((void *)(PREG->y_u.o.opcw))
#if USE_THREADED_CODE && (LIMITED_PREFETCH || USE_PREFETCH)

View File

@ -65,30 +65,6 @@
#include <stdio.h>
#endif
#ifdef FROZEN_STACKS
#ifdef YAPOR_SBA
#define PROTECT_FROZEN_H(CPTR) \
((Unsigned((Int)((CPTR)->cp_h)-(Int)(H_FZ)) < \
Unsigned((Int)(B_FZ)-(Int)(H_FZ))) ? \
(CPTR)->cp_h : H_FZ)
#define PROTECT_FROZEN_B(CPTR) \
((Unsigned((Int)(CPTR)-(Int)(H_FZ)) < \
Unsigned((Int)(B_FZ)-(Int)(H_FZ))) ? \
(CPTR) : B_FZ)
/*
#define PROTECT_FROZEN_H(CPTR) ((CPTR)->cp_h > H_FZ && (CPTR)->cp_h < (CELL *)B_FZ ? (CPTR)->cp_h : H_FZ )
#define PROTECT_FROZEN_B(CPTR) ((CPTR) < B_FZ && (CPTR) > (choiceptr)H_FZ ? (CPTR) : B_FZ )
*/
#else /* TABLING */
#define PROTECT_FROZEN_B(CPTR) (YOUNGER_CP(CPTR, B_FZ) ? CPTR : B_FZ)
#define PROTECT_FROZEN_H(CPTR) (((CPTR)->cp_h > H_FZ) ? (CPTR)->cp_h : H_FZ)
#endif /* YAPOR_SBA */
#else
#define PROTECT_FROZEN_B(CPTR) (CPTR)
#define PROTECT_FROZEN_H(CPTR) (CPTR)->cp_h
#endif /* FROZEN_STACKS */
#if ALIGN_LONGS
/* */ typedef Int DISPREG;
/* */ typedef CELL SMALLUNSGN;
@ -882,7 +858,7 @@ typedef struct yami {
Term c;
CELL next;
} yxc;
} u;
} y_u;
} yamop;
typedef yamop yamopp;
@ -891,7 +867,7 @@ typedef yamop yamopp;
#define OPCW u.ox.opcw
#define NEXTOP(V,TYPE) ((yamop *)(&((V)->u.TYPE.next)))
#define NEXTOP(V,TYPE) ((yamop *)(&((V)->y_u.TYPE.next)))
#define PREVOP(V,TYPE) ((yamop *)((CODEADDR)(V)-(CELL)NEXTOP((yamop *)NULL,TYPE)))
@ -1072,13 +1048,13 @@ CELL *ENV_Parent(CELL *env)
static inline
UInt ENV_Size(yamop *cp)
{
return (((yamop *)((CODEADDR)(cp) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->u.Osbpp.s);
return (((yamop *)((CODEADDR)(cp) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->y_u.Osbpp.s);
}
static inline
struct pred_entry *ENV_ToP(yamop *cp)
{
return (((yamop *)((CODEADDR)(cp) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->u.Osbpp.p);
return (((yamop *)((CODEADDR)(cp) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->y_u.Osbpp.p);
}
static inline
@ -1096,13 +1072,13 @@ UInt EnvSize(yamop *cp)
static inline
CELL *EnvBMap(yamop *p)
{
return (((yamop *)((CODEADDR)(p) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->u.Osbpp.bmap);
return (((yamop *)((CODEADDR)(p) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->y_u.Osbpp.bmap);
}
static inline
struct pred_entry *EnvPreg(yamop *p)
{
return (((yamop *)((CODEADDR)(p) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->u.Osbpp.p0);
return (((yamop *)((CODEADDR)(p) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->y_u.Osbpp.p0);
}
/* access to instructions */

View File

@ -253,7 +253,7 @@ extern void Yap_WakeUp(CELL *v);
#define Bind_Local(A,D) { TRAIL_LOCAL(A,D); *(A) = (D); }
#define Bind_Global(A,D) { *(A) = (D); if (__builtin_expect(GlobalIsAttVar(A),0)) Yap_WakeUp(A); else TRAIL_GLOBAL(A,D); }
#define Bind(A,D) { *(A) = (D); if (A < HR) { if (__builtin_expect(GlobalIsAttVar(A),0)) Yap_WakeUp(A); else TRAIL_GLOBAL(A,D); } else { TRAIL_LOCAL(A,D); } }
#define YapBind(A,D) { *(A) = (D); if (A < HR) { if (__builtin_expect(GlobalIsAttVar(A),0)) Yap_WakeUp(A); else TRAIL_GLOBAL(A,D); } else { TRAIL_LOCAL(A,D); } }
#define Bind_NonAtt(A,D) { *(A) = (D); TRAIL(A,D); }
#define Bind_Global_NonAtt(A,D) { *(A) = (D); TRAIL_GLOBAL(A,D); }
#define Bind_and_Trail(A,D) { *(A) = (D); DO_TRAIL(A, D); }
@ -326,7 +326,7 @@ close_attvar_chain(CELL *dvarsmin, CELL *dvarsmax) {
dvarsmin += 1;
do {
CELL *newv;
Bind(dvarsmin+1, dvarsmin[1]);
YapBind(dvarsmin+1, dvarsmin[1]);
if (IsUnboundVar(dvarsmin))
break;
newv = CellPtr(*dvarsmin);
@ -400,7 +400,7 @@ Yap_unify_constant(register Term a, register Term cons)
}
deref_body(a,pt,unify_cons_unk,unify_cons_nonvar);
Bind(pt,cons);
YapBind(pt,cons);
return(TRUE);
}

View File

@ -21,7 +21,7 @@
/* consulting files */
typedef union CONSULT_OBJ {
char *filename;
const char *filename;
int mode;
Prop p;
UInt c;
@ -33,7 +33,7 @@ typedef union CONSULT_OBJ {
#define ASSEMBLING_INDEX 1
#define ASSEMBLING_EINDEX 2
#define NextDynamicClause(X) (((yamop *)X)->u.Otapl.d)
#define NextDynamicClause(X) (((yamop *)X)->y_u.Otapl.d)
#define PredFirstClause 0
#define PredMiddleClause 1
@ -202,7 +202,7 @@ INLINE_ONLY EXTERN inline CELL *
EXO_OFFSET_TO_ADDRESS(struct index_t *it, BITS32 off)
{
if (off == 0L)
return NULL;
return (CELL *)NULL;
return (it->cls)+(off-1)*it->arity;
}

View File

@ -185,7 +185,7 @@ typedef enum compiler_op {
equal_op,
exit_op,
#endif
fetch_args_for_bccall,
fetch_args_for_bccall_op,
bccall_op,
blob_op,
string_op,

View File

@ -18,11 +18,11 @@ struct cut_c_str{
#define CUT_C_STR_SIZE ((sizeof(struct cut_c_str))/(sizeof(CELL)))
#define EXTRA_CBACK_CUT_ARG(Type,Offset) \
((Type) (*(Type *)(((CELL *)Yap_REGS.CUT_C_TOP) - (((yamop *)Yap_REGS.CUT_C_TOP->try_userc_cut_yamop)->u.OtapFs.extra)) + (Offset-1)))
((Type) (*(Type *)(((CELL *)Yap_REGS.CUT_C_TOP) - (((yamop *)Yap_REGS.CUT_C_TOP->try_userc_cut_yamop)->y_u.OtapFs.extra)) + (Offset-1)))
#define CUT_C_PUSH(YAMOP,S_YREG) \
{ \
if ((YAMOP)->u.OtapFs.f){ \
if ((YAMOP)->y_u.OtapFs.f){ \
S_YREG = S_YREG - CUT_C_STR_SIZE; \
cut_c_str_ptr new_top = (cut_c_str_ptr) S_YREG; \
new_top->try_userc_cut_yamop = YAMOP; \
@ -37,8 +37,8 @@ struct cut_c_str{
#define POP_EXECUTE() \
cut_c_str_ptr TOP = Yap_REGS.CUT_C_TOP; \
CPredicate func = (CPredicate)((yamop *)TOP->try_userc_cut_yamop)->u.OtapFs.f; \
PredEntry *pred = (PredEntry *)((yamop *)TOP->try_userc_cut_yamop)->u.OtapFs.p; \
CPredicate func = (CPredicate)((yamop *)TOP->try_userc_cut_yamop)->y_u.OtapFs.f; \
PredEntry *pred = (PredEntry *)((yamop *)TOP->try_userc_cut_yamop)->y_u.OtapFs.p; \
YAP_ExecuteOnCut(pred, func, TOP); \
cut_c_pop();

View File

@ -1,119 +1,123 @@
/* This file, dglobals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update misc/GLOBALS instead */
#define GLOBAL_Initialised Yap_global->Initialised_
#define GLOBAL_InitialisedFromPL Yap_global->InitialisedFromPL_
#define GLOBAL_PL_Argc Yap_global->PL_Argc_
#define GLOBAL_PL_Argv Yap_global->PL_Argv_
#define GLOBAL_HaltHooks Yap_global->HaltHooks_
#define GLOBAL_AllowLocalExpansion Yap_global->AllowLocalExpansion_
#define GLOBAL_AllowGlobalExpansion Yap_global->AllowGlobalExpansion_
#define GLOBAL_AllowTrailExpansion Yap_global->AllowTrailExpansion_
#define GLOBAL_SizeOfOverflow Yap_global->SizeOfOverflow_
#define GLOBAL_AGcThreshold Yap_global->AGcThreshold_
#define GLOBAL_AGCHook Yap_global->AGCHook_
#if THREADS
#define GLOBAL_NOfThreads Yap_global->NOfThreads_
#define GLOBAL_NOfThreadsCreated Yap_global->NOfThreadsCreated_
#define GLOBAL_ThreadsTotalTime Yap_global->ThreadsTotalTime_
#define GLOBAL_ThreadHandlesLock Yap_global->ThreadHandlesLock_
#endif
#if defined(YAPOR) || defined(THREADS)
#define GLOBAL_BGL Yap_global->BGL_
#endif
#if defined(YAPOR) || defined(TABLING)
#define GLOBAL_optyap_data Yap_global->optyap_data_
#endif /* YAPOR || TABLING */
#define GLOBAL_PrologShouldHandleInterrupts Yap_global->PrologShouldHandleInterrupts_
#if defined(THREADS)
#define GLOBAL_master_thread Yap_global->master_thread_
#endif /* THREADS */
#define GLOBAL_stdout Yap_global->stdout_
#define GLOBAL_stderr Yap_global->stderr_
#define GLOBAL_argv Yap_global->argv_
#define GLOBAL_argc Yap_global->argc_
#ifdef COROUTINING
#define GLOBAL_attas Yap_global->attas_
#endif
#define GLOBAL_agc_calls Yap_global->agc_calls_
#define GLOBAL_agc_collected Yap_global->agc_collected_
#define GLOBAL_tot_agc_time Yap_global->tot_agc_time_
#define GLOBAL_tot_agc_recovered Yap_global->tot_agc_recovered_
#if HAVE_MMAP
#define GLOBAL_mmap_arrays Yap_global->mmap_arrays_
#endif
#ifdef DEBUG
#define GLOBAL_Option Yap_global->Option_
#define GLOBAL_logfile Yap_global->logfile_
#endif
#if defined(COFF) || defined(A_OUT)
#define GLOBAL_Executable Yap_global->Executable_
#endif
#define GLOBAL_OpaqueHandlersCount Yap_global->OpaqueHandlersCount_
#define GLOBAL_OpaqueHandlers Yap_global->OpaqueHandlers_
#if __simplescalar__
#define GLOBAL_pwd Yap_global->pwd_
#endif
#define GLOBAL_RestoreFile Yap_global->RestoreFile_
#define GLOBAL_ProfCalls Yap_global->ProfCalls_
#define GLOBAL_ProfGCs Yap_global->ProfGCs_
#define GLOBAL_ProfHGrows Yap_global->ProfHGrows_
#define GLOBAL_ProfSGrows Yap_global->ProfSGrows_
#define GLOBAL_ProfMallocs Yap_global->ProfMallocs_
#define GLOBAL_ProfIndexing Yap_global->ProfIndexing_
#define GLOBAL_ProfOn Yap_global->ProfOn_
#define GLOBAL_ProfOns Yap_global->ProfOns_
#define GLOBAL_ProfilerRoot Yap_global->ProfilerRoot_
#define GLOBAL_ProfilerNil Yap_global->ProfilerNil_
#define GLOBAL_DIRNAME Yap_global->DIRNAME_
#if LOW_PROF
#define GLOBAL_ProfilerOn Yap_global->ProfilerOn_
#define GLOBAL_FProf Yap_global->FProf_
#define GLOBAL_FPreds Yap_global->FPreds_
#endif /* LOW_PROF */
/* This file, dglobals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update misc/GLOBALS instead */
#define GLOBAL_Initialised Yap_global->Initialised_
#define GLOBAL_InitialisedFromPL Yap_global->InitialisedFromPL_
#define GLOBAL_PL_Argc Yap_global->PL_Argc_
#define GLOBAL_PL_Argv Yap_global->PL_Argv_
#define GLOBAL_HaltHooks Yap_global->HaltHooks_
#define GLOBAL_AllowLocalExpansion Yap_global->AllowLocalExpansion_
#define GLOBAL_AllowGlobalExpansion Yap_global->AllowGlobalExpansion_
#define GLOBAL_AllowTrailExpansion Yap_global->AllowTrailExpansion_
#define GLOBAL_SizeOfOverflow Yap_global->SizeOfOverflow_
#define GLOBAL_AGcThreshold Yap_global->AGcThreshold_
#define GLOBAL_AGCHook Yap_global->AGCHook_
#if __ANDROID__
#define GLOBAL_assetManager Yap_global->assetManager_
#endif
#if THREADS
#define GLOBAL_NOfThreads Yap_global->NOfThreads_
#define GLOBAL_NOfThreadsCreated Yap_global->NOfThreadsCreated_
#define GLOBAL_ThreadsTotalTime Yap_global->ThreadsTotalTime_
#define GLOBAL_ThreadHandlesLock Yap_global->ThreadHandlesLock_
#endif
#if defined(YAPOR) || defined(THREADS)
#define GLOBAL_BGL Yap_global->BGL_
#endif
#if defined(YAPOR) || defined(TABLING)
#define GLOBAL_optyap_data Yap_global->optyap_data_
#endif /* YAPOR || TABLING */
#define GLOBAL_PrologShouldHandleInterrupts Yap_global->PrologShouldHandleInterrupts_
#if defined(THREADS)
#define GLOBAL_master_thread Yap_global->master_thread_
#endif /* THREADS */
#define GLOBAL_stdout Yap_global->stdout_
#define GLOBAL_stderr Yap_global->stderr_
#define GLOBAL_argv Yap_global->argv_
#define GLOBAL_argc Yap_global->argc_
#ifdef COROUTINING
#define GLOBAL_attas Yap_global->attas_
#endif
#define GLOBAL_agc_calls Yap_global->agc_calls_
#define GLOBAL_agc_collected Yap_global->agc_collected_
#define GLOBAL_tot_agc_time Yap_global->tot_agc_time_
#define GLOBAL_tot_agc_recovered Yap_global->tot_agc_recovered_
#if HAVE_MMAP
#define GLOBAL_mmap_arrays Yap_global->mmap_arrays_
#endif
#ifdef DEBUG
#define GLOBAL_Option Yap_global->Option_
#define GLOBAL_logfile Yap_global->logfile_
#endif
#if defined(COFF) || defined(A_OUT)
#define GLOBAL_Executable Yap_global->Executable_
#endif
#define GLOBAL_OpaqueHandlersCount Yap_global->OpaqueHandlersCount_
#define GLOBAL_OpaqueHandlers Yap_global->OpaqueHandlers_
#if __simplescalar__
#define GLOBAL_pwd Yap_global->pwd_
#endif
#define GLOBAL_RestoreFile Yap_global->RestoreFile_
#define GLOBAL_ProfCalls Yap_global->ProfCalls_
#define GLOBAL_ProfGCs Yap_global->ProfGCs_
#define GLOBAL_ProfHGrows Yap_global->ProfHGrows_
#define GLOBAL_ProfSGrows Yap_global->ProfSGrows_
#define GLOBAL_ProfMallocs Yap_global->ProfMallocs_
#define GLOBAL_ProfIndexing Yap_global->ProfIndexing_
#define GLOBAL_ProfOn Yap_global->ProfOn_
#define GLOBAL_ProfOns Yap_global->ProfOns_
#define GLOBAL_ProfilerRoot Yap_global->ProfilerRoot_
#define GLOBAL_ProfilerNil Yap_global->ProfilerNil_
#define GLOBAL_DIRNAME Yap_global->DIRNAME_
#if LOW_PROF
#define GLOBAL_ProfilerOn Yap_global->ProfilerOn_
#define GLOBAL_FProf Yap_global->FProf_
#define GLOBAL_FPreds Yap_global->FPreds_
#endif /* LOW_PROF */

View File

@ -1,428 +1,435 @@
/* This file, dlocals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update misc/LOCALS instead */
#define LOCAL_c_input_stream LOCAL->c_input_stream_
#define REMOTE_c_input_stream(wid) REMOTE(wid)->c_input_stream_
#define LOCAL_c_output_stream LOCAL->c_output_stream_
#define REMOTE_c_output_stream(wid) REMOTE(wid)->c_output_stream_
#define LOCAL_c_error_stream LOCAL->c_error_stream_
#define REMOTE_c_error_stream(wid) REMOTE(wid)->c_error_stream_
#define LOCAL_OldASP LOCAL->OldASP_
#define REMOTE_OldASP(wid) REMOTE(wid)->OldASP_
#define LOCAL_OldLCL0 LOCAL->OldLCL0_
#define REMOTE_OldLCL0(wid) REMOTE(wid)->OldLCL0_
#define LOCAL_OldTR LOCAL->OldTR_
#define REMOTE_OldTR(wid) REMOTE(wid)->OldTR_
#define LOCAL_OldGlobalBase LOCAL->OldGlobalBase_
#define REMOTE_OldGlobalBase(wid) REMOTE(wid)->OldGlobalBase_
#define LOCAL_OldH LOCAL->OldH_
#define REMOTE_OldH(wid) REMOTE(wid)->OldH_
#define LOCAL_OldH0 LOCAL->OldH0_
#define REMOTE_OldH0(wid) REMOTE(wid)->OldH0_
#define LOCAL_OldTrailBase LOCAL->OldTrailBase_
#define REMOTE_OldTrailBase(wid) REMOTE(wid)->OldTrailBase_
#define LOCAL_OldTrailTop LOCAL->OldTrailTop_
#define REMOTE_OldTrailTop(wid) REMOTE(wid)->OldTrailTop_
#define LOCAL_OldHeapBase LOCAL->OldHeapBase_
#define REMOTE_OldHeapBase(wid) REMOTE(wid)->OldHeapBase_
#define LOCAL_OldHeapTop LOCAL->OldHeapTop_
#define REMOTE_OldHeapTop(wid) REMOTE(wid)->OldHeapTop_
#define LOCAL_ClDiff LOCAL->ClDiff_
#define REMOTE_ClDiff(wid) REMOTE(wid)->ClDiff_
#define LOCAL_GDiff LOCAL->GDiff_
#define REMOTE_GDiff(wid) REMOTE(wid)->GDiff_
#define LOCAL_HDiff LOCAL->HDiff_
#define REMOTE_HDiff(wid) REMOTE(wid)->HDiff_
#define LOCAL_GDiff0 LOCAL->GDiff0_
#define REMOTE_GDiff0(wid) REMOTE(wid)->GDiff0_
#define LOCAL_GSplit LOCAL->GSplit_
#define REMOTE_GSplit(wid) REMOTE(wid)->GSplit_
#define LOCAL_LDiff LOCAL->LDiff_
#define REMOTE_LDiff(wid) REMOTE(wid)->LDiff_
#define LOCAL_TrDiff LOCAL->TrDiff_
#define REMOTE_TrDiff(wid) REMOTE(wid)->TrDiff_
#define LOCAL_XDiff LOCAL->XDiff_
#define REMOTE_XDiff(wid) REMOTE(wid)->XDiff_
#define LOCAL_DelayDiff LOCAL->DelayDiff_
#define REMOTE_DelayDiff(wid) REMOTE(wid)->DelayDiff_
#define LOCAL_BaseDiff LOCAL->BaseDiff_
#define REMOTE_BaseDiff(wid) REMOTE(wid)->BaseDiff_
#define LOCAL_ReductionsCounter LOCAL->ReductionsCounter_
#define REMOTE_ReductionsCounter(wid) REMOTE(wid)->ReductionsCounter_
#define LOCAL_PredEntriesCounter LOCAL->PredEntriesCounter_
#define REMOTE_PredEntriesCounter(wid) REMOTE(wid)->PredEntriesCounter_
#define LOCAL_RetriesCounter LOCAL->RetriesCounter_
#define REMOTE_RetriesCounter(wid) REMOTE(wid)->RetriesCounter_
#define LOCAL_ReductionsCounterOn LOCAL->ReductionsCounterOn_
#define REMOTE_ReductionsCounterOn(wid) REMOTE(wid)->ReductionsCounterOn_
#define LOCAL_PredEntriesCounterOn LOCAL->PredEntriesCounterOn_
#define REMOTE_PredEntriesCounterOn(wid) REMOTE(wid)->PredEntriesCounterOn_
#define LOCAL_RetriesCounterOn LOCAL->RetriesCounterOn_
#define REMOTE_RetriesCounterOn(wid) REMOTE(wid)->RetriesCounterOn_
#define LOCAL_ConsultSp LOCAL->ConsultSp_
#define REMOTE_ConsultSp(wid) REMOTE(wid)->ConsultSp_
#define LOCAL_ConsultCapacity LOCAL->ConsultCapacity_
#define REMOTE_ConsultCapacity(wid) REMOTE(wid)->ConsultCapacity_
#define LOCAL_ConsultBase LOCAL->ConsultBase_
#define REMOTE_ConsultBase(wid) REMOTE(wid)->ConsultBase_
#define LOCAL_ConsultLow LOCAL->ConsultLow_
#define REMOTE_ConsultLow(wid) REMOTE(wid)->ConsultLow_
#define LOCAL_GlobalArena LOCAL->GlobalArena_
#define REMOTE_GlobalArena(wid) REMOTE(wid)->GlobalArena_
#define LOCAL_GlobalArenaOverflows LOCAL->GlobalArenaOverflows_
#define REMOTE_GlobalArenaOverflows(wid) REMOTE(wid)->GlobalArenaOverflows_
#define LOCAL_ArenaOverflows LOCAL->ArenaOverflows_
#define REMOTE_ArenaOverflows(wid) REMOTE(wid)->ArenaOverflows_
#define LOCAL_DepthArenas LOCAL->DepthArenas_
#define REMOTE_DepthArenas(wid) REMOTE(wid)->DepthArenas_
#define LOCAL_ArithError LOCAL->ArithError_
#define REMOTE_ArithError(wid) REMOTE(wid)->ArithError_
#define LOCAL_LastAssertedPred LOCAL->LastAssertedPred_
#define REMOTE_LastAssertedPred(wid) REMOTE(wid)->LastAssertedPred_
#define LOCAL_ScannerStack LOCAL->ScannerStack_
#define REMOTE_ScannerStack(wid) REMOTE(wid)->ScannerStack_
#define LOCAL_ScannerExtraBlocks LOCAL->ScannerExtraBlocks_
#define REMOTE_ScannerExtraBlocks(wid) REMOTE(wid)->ScannerExtraBlocks_
#define LOCAL_BallTerm LOCAL->BallTerm_
#define REMOTE_BallTerm(wid) REMOTE(wid)->BallTerm_
#define LOCAL_ActiveSignals LOCAL->ActiveSignals_
#define REMOTE_ActiveSignals(wid) REMOTE(wid)->ActiveSignals_
#define LOCAL_MaxActiveSignals LOCAL->MaxActiveSignals_
#define REMOTE_MaxActiveSignals(wid) REMOTE(wid)->MaxActiveSignals_
#define LOCAL_FirstActiveSignal LOCAL->FirstActiveSignal_
#define REMOTE_FirstActiveSignal(wid) REMOTE(wid)->FirstActiveSignal_
#define LOCAL_LastActiveSignal LOCAL->LastActiveSignal_
#define REMOTE_LastActiveSignal(wid) REMOTE(wid)->LastActiveSignal_
#define LOCAL_IPredArity LOCAL->IPredArity_
#define REMOTE_IPredArity(wid) REMOTE(wid)->IPredArity_
#define LOCAL_ProfEnd LOCAL->ProfEnd_
#define REMOTE_ProfEnd(wid) REMOTE(wid)->ProfEnd_
#define LOCAL_UncaughtThrow LOCAL->UncaughtThrow_
#define REMOTE_UncaughtThrow(wid) REMOTE(wid)->UncaughtThrow_
#define LOCAL_DoingUndefp LOCAL->DoingUndefp_
#define REMOTE_DoingUndefp(wid) REMOTE(wid)->DoingUndefp_
#define LOCAL_StartLine LOCAL->StartLine_
#define REMOTE_StartLine(wid) REMOTE(wid)->StartLine_
#define LOCAL_ScratchPad LOCAL->ScratchPad_
#define REMOTE_ScratchPad(wid) REMOTE(wid)->ScratchPad_
#ifdef COROUTINING
#define LOCAL_WokenGoals LOCAL->WokenGoals_
#define REMOTE_WokenGoals(wid) REMOTE(wid)->WokenGoals_
#define LOCAL_AttsMutableList LOCAL->AttsMutableList_
#define REMOTE_AttsMutableList(wid) REMOTE(wid)->AttsMutableList_
#endif
#define LOCAL_GcGeneration LOCAL->GcGeneration_
#define REMOTE_GcGeneration(wid) REMOTE(wid)->GcGeneration_
#define LOCAL_GcPhase LOCAL->GcPhase_
#define REMOTE_GcPhase(wid) REMOTE(wid)->GcPhase_
#define LOCAL_GcCurrentPhase LOCAL->GcCurrentPhase_
#define REMOTE_GcCurrentPhase(wid) REMOTE(wid)->GcCurrentPhase_
#define LOCAL_GcCalls LOCAL->GcCalls_
#define REMOTE_GcCalls(wid) REMOTE(wid)->GcCalls_
#define LOCAL_TotGcTime LOCAL->TotGcTime_
#define REMOTE_TotGcTime(wid) REMOTE(wid)->TotGcTime_
#define LOCAL_TotGcRecovered LOCAL->TotGcRecovered_
#define REMOTE_TotGcRecovered(wid) REMOTE(wid)->TotGcRecovered_
#define LOCAL_LastGcTime LOCAL->LastGcTime_
#define REMOTE_LastGcTime(wid) REMOTE(wid)->LastGcTime_
#define LOCAL_LastSSTime LOCAL->LastSSTime_
#define REMOTE_LastSSTime(wid) REMOTE(wid)->LastSSTime_
#define LOCAL_OpenArray LOCAL->OpenArray_
#define REMOTE_OpenArray(wid) REMOTE(wid)->OpenArray_
#define LOCAL_total_marked LOCAL->total_marked_
#define REMOTE_total_marked(wid) REMOTE(wid)->total_marked_
#define LOCAL_total_oldies LOCAL->total_oldies_
#define REMOTE_total_oldies(wid) REMOTE(wid)->total_oldies_
#define LOCAL_current_B LOCAL->current_B_
#define REMOTE_current_B(wid) REMOTE(wid)->current_B_
#define LOCAL_prev_HB LOCAL->prev_HB_
#define REMOTE_prev_HB(wid) REMOTE(wid)->prev_HB_
#define LOCAL_HGEN LOCAL->HGEN_
#define REMOTE_HGEN(wid) REMOTE(wid)->HGEN_
#define LOCAL_iptop LOCAL->iptop_
#define REMOTE_iptop(wid) REMOTE(wid)->iptop_
#if defined(GC_NO_TAGS)
#define LOCAL_bp LOCAL->bp_
#define REMOTE_bp(wid) REMOTE(wid)->bp_
#endif
#define LOCAL_sTR LOCAL->sTR_
#define REMOTE_sTR(wid) REMOTE(wid)->sTR_
#define LOCAL_sTR0 LOCAL->sTR0_
#define REMOTE_sTR0(wid) REMOTE(wid)->sTR0_
#define LOCAL_new_TR LOCAL->new_TR_
#define REMOTE_new_TR(wid) REMOTE(wid)->new_TR_
#define LOCAL_cont_top0 LOCAL->cont_top0_
#define REMOTE_cont_top0(wid) REMOTE(wid)->cont_top0_
#define LOCAL_cont_top LOCAL->cont_top_
#define REMOTE_cont_top(wid) REMOTE(wid)->cont_top_
#define LOCAL_discard_trail_entries LOCAL->discard_trail_entries_
#define REMOTE_discard_trail_entries(wid) REMOTE(wid)->discard_trail_entries_
#define LOCAL_gc_ma_hash_table LOCAL->gc_ma_hash_table_
#define REMOTE_gc_ma_hash_table(wid) REMOTE(wid)->gc_ma_hash_table_
#define LOCAL_gc_ma_h_top LOCAL->gc_ma_h_top_
#define REMOTE_gc_ma_h_top(wid) REMOTE(wid)->gc_ma_h_top_
#define LOCAL_gc_ma_h_list LOCAL->gc_ma_h_list_
#define REMOTE_gc_ma_h_list(wid) REMOTE(wid)->gc_ma_h_list_
#define LOCAL_gc_timestamp LOCAL->gc_timestamp_
#define REMOTE_gc_timestamp(wid) REMOTE(wid)->gc_timestamp_
#define LOCAL_db_vec LOCAL->db_vec_
#define REMOTE_db_vec(wid) REMOTE(wid)->db_vec_
#define LOCAL_db_vec0 LOCAL->db_vec0_
#define REMOTE_db_vec0(wid) REMOTE(wid)->db_vec0_
#define LOCAL_db_root LOCAL->db_root_
#define REMOTE_db_root(wid) REMOTE(wid)->db_root_
#define LOCAL_db_nil LOCAL->db_nil_
#define REMOTE_db_nil(wid) REMOTE(wid)->db_nil_
#define LOCAL_gc_restore LOCAL->gc_restore_
#define REMOTE_gc_restore(wid) REMOTE(wid)->gc_restore_
#define LOCAL_extra_gc_cells LOCAL->extra_gc_cells_
#define REMOTE_extra_gc_cells(wid) REMOTE(wid)->extra_gc_cells_
#define LOCAL_extra_gc_cells_base LOCAL->extra_gc_cells_base_
#define REMOTE_extra_gc_cells_base(wid) REMOTE(wid)->extra_gc_cells_base_
#define LOCAL_extra_gc_cells_top LOCAL->extra_gc_cells_top_
#define REMOTE_extra_gc_cells_top(wid) REMOTE(wid)->extra_gc_cells_top_
#define LOCAL_extra_gc_cells_size LOCAL->extra_gc_cells_size_
#define REMOTE_extra_gc_cells_size(wid) REMOTE(wid)->extra_gc_cells_size_
#define LOCAL_DynamicArrays LOCAL->DynamicArrays_
#define REMOTE_DynamicArrays(wid) REMOTE(wid)->DynamicArrays_
#define LOCAL_StaticArrays LOCAL->StaticArrays_
#define REMOTE_StaticArrays(wid) REMOTE(wid)->StaticArrays_
#define LOCAL_GlobalVariables LOCAL->GlobalVariables_
#define REMOTE_GlobalVariables(wid) REMOTE(wid)->GlobalVariables_
#define LOCAL_AllowRestart LOCAL->AllowRestart_
#define REMOTE_AllowRestart(wid) REMOTE(wid)->AllowRestart_
#define LOCAL_CMemFirstBlock LOCAL->CMemFirstBlock_
#define REMOTE_CMemFirstBlock(wid) REMOTE(wid)->CMemFirstBlock_
#define LOCAL_CMemFirstBlockSz LOCAL->CMemFirstBlockSz_
#define REMOTE_CMemFirstBlockSz(wid) REMOTE(wid)->CMemFirstBlockSz_
#define LOCAL_nperm LOCAL->nperm_
#define REMOTE_nperm(wid) REMOTE(wid)->nperm_
#define LOCAL_LabelFirstArray LOCAL->LabelFirstArray_
#define REMOTE_LabelFirstArray(wid) REMOTE(wid)->LabelFirstArray_
#define LOCAL_LabelFirstArraySz LOCAL->LabelFirstArraySz_
#define REMOTE_LabelFirstArraySz(wid) REMOTE(wid)->LabelFirstArraySz_
#define LOCAL_PL_local_data_p LOCAL->PL_local_data_p_
#define REMOTE_PL_local_data_p(wid) REMOTE(wid)->PL_local_data_p_
#ifdef THREADS
#define LOCAL_ThreadHandle LOCAL->ThreadHandle_
#define REMOTE_ThreadHandle(wid) REMOTE(wid)->ThreadHandle_
#endif /* THREADS */
#if defined(YAPOR) || defined(TABLING)
#define LOCAL_optyap_data LOCAL->optyap_data_
#define REMOTE_optyap_data(wid) REMOTE(wid)->optyap_data_
#endif /* YAPOR || TABLING */
#define LOCAL_InterruptsDisabled LOCAL->InterruptsDisabled_
#define REMOTE_InterruptsDisabled(wid) REMOTE(wid)->InterruptsDisabled_
#define LOCAL_execution LOCAL->execution_
#define REMOTE_execution(wid) REMOTE(wid)->execution_
#if LOW_LEVEL_TRACER
#define LOCAL_total_choicepoints LOCAL->total_choicepoints_
#define REMOTE_total_choicepoints(wid) REMOTE(wid)->total_choicepoints_
#endif
#define LOCAL_consult_level LOCAL->consult_level_
#define REMOTE_consult_level(wid) REMOTE(wid)->consult_level_
#if defined(YAPOR) || defined(THREADS)
#define LOCAL_SignalLock LOCAL->SignalLock_
#define REMOTE_SignalLock(wid) REMOTE(wid)->SignalLock_
#endif
#define LOCAL_LocalBase LOCAL->LocalBase_
#define REMOTE_LocalBase(wid) REMOTE(wid)->LocalBase_
#define LOCAL_GlobalBase LOCAL->GlobalBase_
#define REMOTE_GlobalBase(wid) REMOTE(wid)->GlobalBase_
#define LOCAL_TrailBase LOCAL->TrailBase_
#define REMOTE_TrailBase(wid) REMOTE(wid)->TrailBase_
#define LOCAL_TrailTop LOCAL->TrailTop_
#define REMOTE_TrailTop(wid) REMOTE(wid)->TrailTop_
#define LOCAL_ErrorMessage LOCAL->ErrorMessage_
#define REMOTE_ErrorMessage(wid) REMOTE(wid)->ErrorMessage_
#define LOCAL_Error_Term LOCAL->Error_Term_
#define REMOTE_Error_Term(wid) REMOTE(wid)->Error_Term_
#ifdef THREADS
#define LOCAL_Error_TYPE LOCAL->Error_TYPE_
#define REMOTE_Error_TYPE(wid) REMOTE(wid)->Error_TYPE_
#else
#define LOCAL_Error_TYPE LOCAL->Error_TYPE_
#define REMOTE_Error_TYPE(wid) REMOTE(wid)->Error_TYPE_
#endif
#define LOCAL_Error_Size LOCAL->Error_Size_
#define REMOTE_Error_Size(wid) REMOTE(wid)->Error_Size_
#define LOCAL_ErrorSay LOCAL->ErrorSay_
#define REMOTE_ErrorSay(wid) REMOTE(wid)->ErrorSay_
#define LOCAL_IOBotch LOCAL->IOBotch_
#define REMOTE_IOBotch(wid) REMOTE(wid)->IOBotch_
#define LOCAL_tokptr LOCAL->tokptr_
#define REMOTE_tokptr(wid) REMOTE(wid)->tokptr_
#define LOCAL_toktide LOCAL->toktide_
#define REMOTE_toktide(wid) REMOTE(wid)->toktide_
#define LOCAL_VarTable LOCAL->VarTable_
#define REMOTE_VarTable(wid) REMOTE(wid)->VarTable_
#define LOCAL_AnonVarTable LOCAL->AnonVarTable_
#define REMOTE_AnonVarTable(wid) REMOTE(wid)->AnonVarTable_
#define LOCAL_Comments LOCAL->Comments_
#define REMOTE_Comments(wid) REMOTE(wid)->Comments_
#define LOCAL_CommentsTail LOCAL->CommentsTail_
#define REMOTE_CommentsTail(wid) REMOTE(wid)->CommentsTail_
#define LOCAL_CommentsNextChar LOCAL->CommentsNextChar_
#define REMOTE_CommentsNextChar(wid) REMOTE(wid)->CommentsNextChar_
#define LOCAL_CommentsBuff LOCAL->CommentsBuff_
#define REMOTE_CommentsBuff(wid) REMOTE(wid)->CommentsBuff_
#define LOCAL_CommentsBuffPos LOCAL->CommentsBuffPos_
#define REMOTE_CommentsBuffPos(wid) REMOTE(wid)->CommentsBuffPos_
#define LOCAL_CommentsBuffLim LOCAL->CommentsBuffLim_
#define REMOTE_CommentsBuffLim(wid) REMOTE(wid)->CommentsBuffLim_
#define LOCAL_RestartEnv LOCAL->RestartEnv_
#define REMOTE_RestartEnv(wid) REMOTE(wid)->RestartEnv_
#define LOCAL_FileNameBuf LOCAL->FileNameBuf_
#define REMOTE_FileNameBuf(wid) REMOTE(wid)->FileNameBuf_
#define LOCAL_FileNameBuf2 LOCAL->FileNameBuf2_
#define REMOTE_FileNameBuf2(wid) REMOTE(wid)->FileNameBuf2_
#define LOCAL_PrologMode LOCAL->PrologMode_
#define REMOTE_PrologMode(wid) REMOTE(wid)->PrologMode_
#define LOCAL_CritLocks LOCAL->CritLocks_
#define REMOTE_CritLocks(wid) REMOTE(wid)->CritLocks_
#ifdef ANALYST
#define LOCAL_opcount LOCAL->opcount_
#define REMOTE_opcount(wid) REMOTE(wid)->opcount_
#define LOCAL_2opcount LOCAL->2opcount_
#define REMOTE_2opcount(wid) REMOTE(wid)->2opcount_
#endif /* ANALYST */
#define LOCAL_s_dbg LOCAL->s_dbg_
#define REMOTE_s_dbg(wid) REMOTE(wid)->s_dbg_
#define LOCAL_matherror LOCAL->matherror_
#define REMOTE_matherror(wid) REMOTE(wid)->matherror_
#define LOCAL_CurrentError LOCAL->CurrentError_
#define REMOTE_CurrentError(wid) REMOTE(wid)->CurrentError_
#define LOCAL_heap_overflows LOCAL->heap_overflows_
#define REMOTE_heap_overflows(wid) REMOTE(wid)->heap_overflows_
#define LOCAL_total_heap_overflow_time LOCAL->total_heap_overflow_time_
#define REMOTE_total_heap_overflow_time(wid) REMOTE(wid)->total_heap_overflow_time_
#define LOCAL_stack_overflows LOCAL->stack_overflows_
#define REMOTE_stack_overflows(wid) REMOTE(wid)->stack_overflows_
#define LOCAL_total_stack_overflow_time LOCAL->total_stack_overflow_time_
#define REMOTE_total_stack_overflow_time(wid) REMOTE(wid)->total_stack_overflow_time_
#define LOCAL_delay_overflows LOCAL->delay_overflows_
#define REMOTE_delay_overflows(wid) REMOTE(wid)->delay_overflows_
#define LOCAL_total_delay_overflow_time LOCAL->total_delay_overflow_time_
#define REMOTE_total_delay_overflow_time(wid) REMOTE(wid)->total_delay_overflow_time_
#define LOCAL_trail_overflows LOCAL->trail_overflows_
#define REMOTE_trail_overflows(wid) REMOTE(wid)->trail_overflows_
#define LOCAL_total_trail_overflow_time LOCAL->total_trail_overflow_time_
#define REMOTE_total_trail_overflow_time(wid) REMOTE(wid)->total_trail_overflow_time_
#define LOCAL_atom_table_overflows LOCAL->atom_table_overflows_
#define REMOTE_atom_table_overflows(wid) REMOTE(wid)->atom_table_overflows_
#define LOCAL_total_atom_table_overflow_time LOCAL->total_atom_table_overflow_time_
#define REMOTE_total_atom_table_overflow_time(wid) REMOTE(wid)->total_atom_table_overflow_time_
#ifdef LOAD_DYLD
#define LOCAL_dl_errno LOCAL->dl_errno_
#define REMOTE_dl_errno(wid) REMOTE(wid)->dl_errno_
#endif
#ifdef LOW_LEVEL_TRACER
#define LOCAL_do_trace_primitives LOCAL->do_trace_primitives_
#define REMOTE_do_trace_primitives(wid) REMOTE(wid)->do_trace_primitives_
#endif
#define LOCAL_ExportAtomHashChain LOCAL->ExportAtomHashChain_
#define REMOTE_ExportAtomHashChain(wid) REMOTE(wid)->ExportAtomHashChain_
#define LOCAL_ExportAtomHashTableSize LOCAL->ExportAtomHashTableSize_
#define REMOTE_ExportAtomHashTableSize(wid) REMOTE(wid)->ExportAtomHashTableSize_
#define LOCAL_ExportAtomHashTableNum LOCAL->ExportAtomHashTableNum_
#define REMOTE_ExportAtomHashTableNum(wid) REMOTE(wid)->ExportAtomHashTableNum_
#define LOCAL_ExportFunctorHashChain LOCAL->ExportFunctorHashChain_
#define REMOTE_ExportFunctorHashChain(wid) REMOTE(wid)->ExportFunctorHashChain_
#define LOCAL_ExportFunctorHashTableSize LOCAL->ExportFunctorHashTableSize_
#define REMOTE_ExportFunctorHashTableSize(wid) REMOTE(wid)->ExportFunctorHashTableSize_
#define LOCAL_ExportFunctorHashTableNum LOCAL->ExportFunctorHashTableNum_
#define REMOTE_ExportFunctorHashTableNum(wid) REMOTE(wid)->ExportFunctorHashTableNum_
#define LOCAL_ExportPredEntryHashChain LOCAL->ExportPredEntryHashChain_
#define REMOTE_ExportPredEntryHashChain(wid) REMOTE(wid)->ExportPredEntryHashChain_
#define LOCAL_ExportPredEntryHashTableSize LOCAL->ExportPredEntryHashTableSize_
#define REMOTE_ExportPredEntryHashTableSize(wid) REMOTE(wid)->ExportPredEntryHashTableSize_
#define LOCAL_ExportPredEntryHashTableNum LOCAL->ExportPredEntryHashTableNum_
#define REMOTE_ExportPredEntryHashTableNum(wid) REMOTE(wid)->ExportPredEntryHashTableNum_
#define LOCAL_ExportDBRefHashChain LOCAL->ExportDBRefHashChain_
#define REMOTE_ExportDBRefHashChain(wid) REMOTE(wid)->ExportDBRefHashChain_
#define LOCAL_ExportDBRefHashTableSize LOCAL->ExportDBRefHashTableSize_
#define REMOTE_ExportDBRefHashTableSize(wid) REMOTE(wid)->ExportDBRefHashTableSize_
#define LOCAL_ExportDBRefHashTableNum LOCAL->ExportDBRefHashTableNum_
#define REMOTE_ExportDBRefHashTableNum(wid) REMOTE(wid)->ExportDBRefHashTableNum_
#define LOCAL_ImportAtomHashChain LOCAL->ImportAtomHashChain_
#define REMOTE_ImportAtomHashChain(wid) REMOTE(wid)->ImportAtomHashChain_
#define LOCAL_ImportAtomHashTableSize LOCAL->ImportAtomHashTableSize_
#define REMOTE_ImportAtomHashTableSize(wid) REMOTE(wid)->ImportAtomHashTableSize_
#define LOCAL_ImportAtomHashTableNum LOCAL->ImportAtomHashTableNum_
#define REMOTE_ImportAtomHashTableNum(wid) REMOTE(wid)->ImportAtomHashTableNum_
#define LOCAL_ImportFunctorHashChain LOCAL->ImportFunctorHashChain_
#define REMOTE_ImportFunctorHashChain(wid) REMOTE(wid)->ImportFunctorHashChain_
#define LOCAL_ImportFunctorHashTableSize LOCAL->ImportFunctorHashTableSize_
#define REMOTE_ImportFunctorHashTableSize(wid) REMOTE(wid)->ImportFunctorHashTableSize_
#define LOCAL_ImportFunctorHashTableNum LOCAL->ImportFunctorHashTableNum_
#define REMOTE_ImportFunctorHashTableNum(wid) REMOTE(wid)->ImportFunctorHashTableNum_
#define LOCAL_ImportOPCODEHashChain LOCAL->ImportOPCODEHashChain_
#define REMOTE_ImportOPCODEHashChain(wid) REMOTE(wid)->ImportOPCODEHashChain_
#define LOCAL_ImportOPCODEHashTableSize LOCAL->ImportOPCODEHashTableSize_
#define REMOTE_ImportOPCODEHashTableSize(wid) REMOTE(wid)->ImportOPCODEHashTableSize_
#define LOCAL_ImportPredEntryHashChain LOCAL->ImportPredEntryHashChain_
#define REMOTE_ImportPredEntryHashChain(wid) REMOTE(wid)->ImportPredEntryHashChain_
#define LOCAL_ImportPredEntryHashTableSize LOCAL->ImportPredEntryHashTableSize_
#define REMOTE_ImportPredEntryHashTableSize(wid) REMOTE(wid)->ImportPredEntryHashTableSize_
#define LOCAL_ImportPredEntryHashTableNum LOCAL->ImportPredEntryHashTableNum_
#define REMOTE_ImportPredEntryHashTableNum(wid) REMOTE(wid)->ImportPredEntryHashTableNum_
#define LOCAL_ImportDBRefHashChain LOCAL->ImportDBRefHashChain_
#define REMOTE_ImportDBRefHashChain(wid) REMOTE(wid)->ImportDBRefHashChain_
#define LOCAL_ImportDBRefHashTableSize LOCAL->ImportDBRefHashTableSize_
#define REMOTE_ImportDBRefHashTableSize(wid) REMOTE(wid)->ImportDBRefHashTableSize_
#define LOCAL_ImportDBRefHashTableNum LOCAL->ImportDBRefHashTableNum_
#define REMOTE_ImportDBRefHashTableNum(wid) REMOTE(wid)->ImportDBRefHashTableNum_
#define LOCAL_ImportFAILCODE LOCAL->ImportFAILCODE_
#define REMOTE_ImportFAILCODE(wid) REMOTE(wid)->ImportFAILCODE_
#define LOCAL_FunctorVar LOCAL->FunctorVar_
#define REMOTE_FunctorVar(wid) REMOTE(wid)->FunctorVar_
#define LOCAL_ibnds LOCAL->ibnds_
#define REMOTE_ibnds(wid) REMOTE(wid)->ibnds_
#define LOCAL_exo_it LOCAL->exo_it_
#define REMOTE_exo_it(wid) REMOTE(wid)->exo_it_
#define LOCAL_exo_base LOCAL->exo_base_
#define REMOTE_exo_base(wid) REMOTE(wid)->exo_base_
#define LOCAL_exo_arity LOCAL->exo_arity_
#define REMOTE_exo_arity(wid) REMOTE(wid)->exo_arity_
#define LOCAL_exo_arg LOCAL->exo_arg_
#define REMOTE_exo_arg(wid) REMOTE(wid)->exo_arg_
#define LOCAL_search_atoms LOCAL->search_atoms_
#define REMOTE_search_atoms(wid) REMOTE(wid)->search_atoms_
#define LOCAL_CurSlot LOCAL->CurSlot_
#define REMOTE_CurSlot(wid) REMOTE(wid)->CurSlot_
#define LOCAL_SourceModule LOCAL->SourceModule_
#define REMOTE_SourceModule(wid) REMOTE(wid)->SourceModule_
#define LOCAL_MAX_SIZE LOCAL->MAX_SIZE_
#define REMOTE_MAX_SIZE(wid) REMOTE(wid)->MAX_SIZE_
/* This file, dlocals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update misc/LOCALS instead */
#define LOCAL_c_input_stream LOCAL->c_input_stream_
#define REMOTE_c_input_stream(wid) REMOTE(wid)->c_input_stream_
#define LOCAL_c_output_stream LOCAL->c_output_stream_
#define REMOTE_c_output_stream(wid) REMOTE(wid)->c_output_stream_
#define LOCAL_c_error_stream LOCAL->c_error_stream_
#define REMOTE_c_error_stream(wid) REMOTE(wid)->c_error_stream_
#define LOCAL_OldASP LOCAL->OldASP_
#define REMOTE_OldASP(wid) REMOTE(wid)->OldASP_
#define LOCAL_OldLCL0 LOCAL->OldLCL0_
#define REMOTE_OldLCL0(wid) REMOTE(wid)->OldLCL0_
#define LOCAL_OldTR LOCAL->OldTR_
#define REMOTE_OldTR(wid) REMOTE(wid)->OldTR_
#define LOCAL_OldGlobalBase LOCAL->OldGlobalBase_
#define REMOTE_OldGlobalBase(wid) REMOTE(wid)->OldGlobalBase_
#define LOCAL_OldH LOCAL->OldH_
#define REMOTE_OldH(wid) REMOTE(wid)->OldH_
#define LOCAL_OldH0 LOCAL->OldH0_
#define REMOTE_OldH0(wid) REMOTE(wid)->OldH0_
#define LOCAL_OldTrailBase LOCAL->OldTrailBase_
#define REMOTE_OldTrailBase(wid) REMOTE(wid)->OldTrailBase_
#define LOCAL_OldTrailTop LOCAL->OldTrailTop_
#define REMOTE_OldTrailTop(wid) REMOTE(wid)->OldTrailTop_
#define LOCAL_OldHeapBase LOCAL->OldHeapBase_
#define REMOTE_OldHeapBase(wid) REMOTE(wid)->OldHeapBase_
#define LOCAL_OldHeapTop LOCAL->OldHeapTop_
#define REMOTE_OldHeapTop(wid) REMOTE(wid)->OldHeapTop_
#define LOCAL_ClDiff LOCAL->ClDiff_
#define REMOTE_ClDiff(wid) REMOTE(wid)->ClDiff_
#define LOCAL_GDiff LOCAL->GDiff_
#define REMOTE_GDiff(wid) REMOTE(wid)->GDiff_
#define LOCAL_HDiff LOCAL->HDiff_
#define REMOTE_HDiff(wid) REMOTE(wid)->HDiff_
#define LOCAL_GDiff0 LOCAL->GDiff0_
#define REMOTE_GDiff0(wid) REMOTE(wid)->GDiff0_
#define LOCAL_GSplit LOCAL->GSplit_
#define REMOTE_GSplit(wid) REMOTE(wid)->GSplit_
#define LOCAL_LDiff LOCAL->LDiff_
#define REMOTE_LDiff(wid) REMOTE(wid)->LDiff_
#define LOCAL_TrDiff LOCAL->TrDiff_
#define REMOTE_TrDiff(wid) REMOTE(wid)->TrDiff_
#define LOCAL_XDiff LOCAL->XDiff_
#define REMOTE_XDiff(wid) REMOTE(wid)->XDiff_
#define LOCAL_DelayDiff LOCAL->DelayDiff_
#define REMOTE_DelayDiff(wid) REMOTE(wid)->DelayDiff_
#define LOCAL_BaseDiff LOCAL->BaseDiff_
#define REMOTE_BaseDiff(wid) REMOTE(wid)->BaseDiff_
#define LOCAL_ReductionsCounter LOCAL->ReductionsCounter_
#define REMOTE_ReductionsCounter(wid) REMOTE(wid)->ReductionsCounter_
#define LOCAL_PredEntriesCounter LOCAL->PredEntriesCounter_
#define REMOTE_PredEntriesCounter(wid) REMOTE(wid)->PredEntriesCounter_
#define LOCAL_RetriesCounter LOCAL->RetriesCounter_
#define REMOTE_RetriesCounter(wid) REMOTE(wid)->RetriesCounter_
#define LOCAL_ReductionsCounterOn LOCAL->ReductionsCounterOn_
#define REMOTE_ReductionsCounterOn(wid) REMOTE(wid)->ReductionsCounterOn_
#define LOCAL_PredEntriesCounterOn LOCAL->PredEntriesCounterOn_
#define REMOTE_PredEntriesCounterOn(wid) REMOTE(wid)->PredEntriesCounterOn_
#define LOCAL_RetriesCounterOn LOCAL->RetriesCounterOn_
#define REMOTE_RetriesCounterOn(wid) REMOTE(wid)->RetriesCounterOn_
#define LOCAL_ConsultSp LOCAL->ConsultSp_
#define REMOTE_ConsultSp(wid) REMOTE(wid)->ConsultSp_
#define LOCAL_ConsultCapacity LOCAL->ConsultCapacity_
#define REMOTE_ConsultCapacity(wid) REMOTE(wid)->ConsultCapacity_
#define LOCAL_ConsultBase LOCAL->ConsultBase_
#define REMOTE_ConsultBase(wid) REMOTE(wid)->ConsultBase_
#define LOCAL_ConsultLow LOCAL->ConsultLow_
#define REMOTE_ConsultLow(wid) REMOTE(wid)->ConsultLow_
#define LOCAL_GlobalArena LOCAL->GlobalArena_
#define REMOTE_GlobalArena(wid) REMOTE(wid)->GlobalArena_
#define LOCAL_GlobalArenaOverflows LOCAL->GlobalArenaOverflows_
#define REMOTE_GlobalArenaOverflows(wid) REMOTE(wid)->GlobalArenaOverflows_
#define LOCAL_ArenaOverflows LOCAL->ArenaOverflows_
#define REMOTE_ArenaOverflows(wid) REMOTE(wid)->ArenaOverflows_
#define LOCAL_DepthArenas LOCAL->DepthArenas_
#define REMOTE_DepthArenas(wid) REMOTE(wid)->DepthArenas_
#define LOCAL_ArithError LOCAL->ArithError_
#define REMOTE_ArithError(wid) REMOTE(wid)->ArithError_
#define LOCAL_LastAssertedPred LOCAL->LastAssertedPred_
#define REMOTE_LastAssertedPred(wid) REMOTE(wid)->LastAssertedPred_
#define LOCAL_ScannerStack LOCAL->ScannerStack_
#define REMOTE_ScannerStack(wid) REMOTE(wid)->ScannerStack_
#define LOCAL_ScannerExtraBlocks LOCAL->ScannerExtraBlocks_
#define REMOTE_ScannerExtraBlocks(wid) REMOTE(wid)->ScannerExtraBlocks_
#define LOCAL_BallTerm LOCAL->BallTerm_
#define REMOTE_BallTerm(wid) REMOTE(wid)->BallTerm_
#define LOCAL_MaxActiveSignals LOCAL->MaxActiveSignals_
#define REMOTE_MaxActiveSignals(wid) REMOTE(wid)->MaxActiveSignals_
#define LOCAL_FirstActiveSignal LOCAL->FirstActiveSignal_
#define REMOTE_FirstActiveSignal(wid) REMOTE(wid)->FirstActiveSignal_
#define LOCAL_LastActiveSignal LOCAL->LastActiveSignal_
#define REMOTE_LastActiveSignal(wid) REMOTE(wid)->LastActiveSignal_
#define LOCAL_ActiveSignals LOCAL->ActiveSignals_
#define REMOTE_ActiveSignals(wid) REMOTE(wid)->ActiveSignals_
#define LOCAL_IPredArity LOCAL->IPredArity_
#define REMOTE_IPredArity(wid) REMOTE(wid)->IPredArity_
#define LOCAL_ProfEnd LOCAL->ProfEnd_
#define REMOTE_ProfEnd(wid) REMOTE(wid)->ProfEnd_
#define LOCAL_UncaughtThrow LOCAL->UncaughtThrow_
#define REMOTE_UncaughtThrow(wid) REMOTE(wid)->UncaughtThrow_
#define LOCAL_DoingUndefp LOCAL->DoingUndefp_
#define REMOTE_DoingUndefp(wid) REMOTE(wid)->DoingUndefp_
#define LOCAL_StartLine LOCAL->StartLine_
#define REMOTE_StartLine(wid) REMOTE(wid)->StartLine_
#define LOCAL_ScratchPad LOCAL->ScratchPad_
#define REMOTE_ScratchPad(wid) REMOTE(wid)->ScratchPad_
#ifdef COROUTINING
#define LOCAL_WokenGoals LOCAL->WokenGoals_
#define REMOTE_WokenGoals(wid) REMOTE(wid)->WokenGoals_
#define LOCAL_AttsMutableList LOCAL->AttsMutableList_
#define REMOTE_AttsMutableList(wid) REMOTE(wid)->AttsMutableList_
#endif
#define LOCAL_GcGeneration LOCAL->GcGeneration_
#define REMOTE_GcGeneration(wid) REMOTE(wid)->GcGeneration_
#define LOCAL_GcPhase LOCAL->GcPhase_
#define REMOTE_GcPhase(wid) REMOTE(wid)->GcPhase_
#define LOCAL_GcCurrentPhase LOCAL->GcCurrentPhase_
#define REMOTE_GcCurrentPhase(wid) REMOTE(wid)->GcCurrentPhase_
#define LOCAL_GcCalls LOCAL->GcCalls_
#define REMOTE_GcCalls(wid) REMOTE(wid)->GcCalls_
#define LOCAL_TotGcTime LOCAL->TotGcTime_
#define REMOTE_TotGcTime(wid) REMOTE(wid)->TotGcTime_
#define LOCAL_TotGcRecovered LOCAL->TotGcRecovered_
#define REMOTE_TotGcRecovered(wid) REMOTE(wid)->TotGcRecovered_
#define LOCAL_LastGcTime LOCAL->LastGcTime_
#define REMOTE_LastGcTime(wid) REMOTE(wid)->LastGcTime_
#define LOCAL_LastSSTime LOCAL->LastSSTime_
#define REMOTE_LastSSTime(wid) REMOTE(wid)->LastSSTime_
#define LOCAL_OpenArray LOCAL->OpenArray_
#define REMOTE_OpenArray(wid) REMOTE(wid)->OpenArray_
#define LOCAL_total_marked LOCAL->total_marked_
#define REMOTE_total_marked(wid) REMOTE(wid)->total_marked_
#define LOCAL_total_oldies LOCAL->total_oldies_
#define REMOTE_total_oldies(wid) REMOTE(wid)->total_oldies_
#define LOCAL_current_B LOCAL->current_B_
#define REMOTE_current_B(wid) REMOTE(wid)->current_B_
#define LOCAL_prev_HB LOCAL->prev_HB_
#define REMOTE_prev_HB(wid) REMOTE(wid)->prev_HB_
#define LOCAL_HGEN LOCAL->HGEN_
#define REMOTE_HGEN(wid) REMOTE(wid)->HGEN_
#define LOCAL_iptop LOCAL->iptop_
#define REMOTE_iptop(wid) REMOTE(wid)->iptop_
#if defined(GC_NO_TAGS)
#define LOCAL_bp LOCAL->bp_
#define REMOTE_bp(wid) REMOTE(wid)->bp_
#endif
#define LOCAL_sTR LOCAL->sTR_
#define REMOTE_sTR(wid) REMOTE(wid)->sTR_
#define LOCAL_sTR0 LOCAL->sTR0_
#define REMOTE_sTR0(wid) REMOTE(wid)->sTR0_
#define LOCAL_new_TR LOCAL->new_TR_
#define REMOTE_new_TR(wid) REMOTE(wid)->new_TR_
#define LOCAL_cont_top0 LOCAL->cont_top0_
#define REMOTE_cont_top0(wid) REMOTE(wid)->cont_top0_
#define LOCAL_cont_top LOCAL->cont_top_
#define REMOTE_cont_top(wid) REMOTE(wid)->cont_top_
#define LOCAL_discard_trail_entries LOCAL->discard_trail_entries_
#define REMOTE_discard_trail_entries(wid) REMOTE(wid)->discard_trail_entries_
#define LOCAL_gc_ma_hash_table LOCAL->gc_ma_hash_table_
#define REMOTE_gc_ma_hash_table(wid) REMOTE(wid)->gc_ma_hash_table_
#define LOCAL_gc_ma_h_top LOCAL->gc_ma_h_top_
#define REMOTE_gc_ma_h_top(wid) REMOTE(wid)->gc_ma_h_top_
#define LOCAL_gc_ma_h_list LOCAL->gc_ma_h_list_
#define REMOTE_gc_ma_h_list(wid) REMOTE(wid)->gc_ma_h_list_
#define LOCAL_gc_timestamp LOCAL->gc_timestamp_
#define REMOTE_gc_timestamp(wid) REMOTE(wid)->gc_timestamp_
#define LOCAL_db_vec LOCAL->db_vec_
#define REMOTE_db_vec(wid) REMOTE(wid)->db_vec_
#define LOCAL_db_vec0 LOCAL->db_vec0_
#define REMOTE_db_vec0(wid) REMOTE(wid)->db_vec0_
#define LOCAL_db_root LOCAL->db_root_
#define REMOTE_db_root(wid) REMOTE(wid)->db_root_
#define LOCAL_db_nil LOCAL->db_nil_
#define REMOTE_db_nil(wid) REMOTE(wid)->db_nil_
#define LOCAL_gc_restore LOCAL->gc_restore_
#define REMOTE_gc_restore(wid) REMOTE(wid)->gc_restore_
#define LOCAL_extra_gc_cells LOCAL->extra_gc_cells_
#define REMOTE_extra_gc_cells(wid) REMOTE(wid)->extra_gc_cells_
#define LOCAL_extra_gc_cells_base LOCAL->extra_gc_cells_base_
#define REMOTE_extra_gc_cells_base(wid) REMOTE(wid)->extra_gc_cells_base_
#define LOCAL_extra_gc_cells_top LOCAL->extra_gc_cells_top_
#define REMOTE_extra_gc_cells_top(wid) REMOTE(wid)->extra_gc_cells_top_
#define LOCAL_extra_gc_cells_size LOCAL->extra_gc_cells_size_
#define REMOTE_extra_gc_cells_size(wid) REMOTE(wid)->extra_gc_cells_size_
#define LOCAL_DynamicArrays LOCAL->DynamicArrays_
#define REMOTE_DynamicArrays(wid) REMOTE(wid)->DynamicArrays_
#define LOCAL_StaticArrays LOCAL->StaticArrays_
#define REMOTE_StaticArrays(wid) REMOTE(wid)->StaticArrays_
#define LOCAL_GlobalVariables LOCAL->GlobalVariables_
#define REMOTE_GlobalVariables(wid) REMOTE(wid)->GlobalVariables_
#define LOCAL_AllowRestart LOCAL->AllowRestart_
#define REMOTE_AllowRestart(wid) REMOTE(wid)->AllowRestart_
#define LOCAL_CMemFirstBlock LOCAL->CMemFirstBlock_
#define REMOTE_CMemFirstBlock(wid) REMOTE(wid)->CMemFirstBlock_
#define LOCAL_CMemFirstBlockSz LOCAL->CMemFirstBlockSz_
#define REMOTE_CMemFirstBlockSz(wid) REMOTE(wid)->CMemFirstBlockSz_
#define LOCAL_nperm LOCAL->nperm_
#define REMOTE_nperm(wid) REMOTE(wid)->nperm_
#define LOCAL_LabelFirstArray LOCAL->LabelFirstArray_
#define REMOTE_LabelFirstArray(wid) REMOTE(wid)->LabelFirstArray_
#define LOCAL_LabelFirstArraySz LOCAL->LabelFirstArraySz_
#define REMOTE_LabelFirstArraySz(wid) REMOTE(wid)->LabelFirstArraySz_
#define LOCAL_PL_local_data_p LOCAL->PL_local_data_p_
#define REMOTE_PL_local_data_p(wid) REMOTE(wid)->PL_local_data_p_
#ifdef THREADS
#define LOCAL_ThreadHandle LOCAL->ThreadHandle_
#define REMOTE_ThreadHandle(wid) REMOTE(wid)->ThreadHandle_
#endif /* THREADS */
#if defined(YAPOR) || defined(TABLING)
#define LOCAL_optyap_data LOCAL->optyap_data_
#define REMOTE_optyap_data(wid) REMOTE(wid)->optyap_data_
#endif /* YAPOR || TABLING */
#define LOCAL_InterruptsDisabled LOCAL->InterruptsDisabled_
#define REMOTE_InterruptsDisabled(wid) REMOTE(wid)->InterruptsDisabled_
#define LOCAL_execution LOCAL->execution_
#define REMOTE_execution(wid) REMOTE(wid)->execution_
#if LOW_LEVEL_TRACER
#define LOCAL_total_choicepoints LOCAL->total_choicepoints_
#define REMOTE_total_choicepoints(wid) REMOTE(wid)->total_choicepoints_
#endif
#define LOCAL_consult_level LOCAL->consult_level_
#define REMOTE_consult_level(wid) REMOTE(wid)->consult_level_
#if defined(YAPOR) || defined(THREADS)
#define LOCAL_SignalLock LOCAL->SignalLock_
#define REMOTE_SignalLock(wid) REMOTE(wid)->SignalLock_
#endif
#define LOCAL_LocalBase LOCAL->LocalBase_
#define REMOTE_LocalBase(wid) REMOTE(wid)->LocalBase_
#define LOCAL_GlobalBase LOCAL->GlobalBase_
#define REMOTE_GlobalBase(wid) REMOTE(wid)->GlobalBase_
#define LOCAL_TrailBase LOCAL->TrailBase_
#define REMOTE_TrailBase(wid) REMOTE(wid)->TrailBase_
#define LOCAL_TrailTop LOCAL->TrailTop_
#define REMOTE_TrailTop(wid) REMOTE(wid)->TrailTop_
#define LOCAL_ErrorMessage LOCAL->ErrorMessage_
#define REMOTE_ErrorMessage(wid) REMOTE(wid)->ErrorMessage_
#define LOCAL_Error_Term LOCAL->Error_Term_
#define REMOTE_Error_Term(wid) REMOTE(wid)->Error_Term_
#ifdef THREADS
#define LOCAL_Error_TYPE LOCAL->Error_TYPE_
#define REMOTE_Error_TYPE(wid) REMOTE(wid)->Error_TYPE_
#else
#define LOCAL_Error_TYPE LOCAL->Error_TYPE_
#define REMOTE_Error_TYPE(wid) REMOTE(wid)->Error_TYPE_
#endif
#define LOCAL_Error_Size LOCAL->Error_Size_
#define REMOTE_Error_Size(wid) REMOTE(wid)->Error_Size_
#define LOCAL_ErrorSay LOCAL->ErrorSay_
#define REMOTE_ErrorSay(wid) REMOTE(wid)->ErrorSay_
#define LOCAL_IOBotch LOCAL->IOBotch_
#define REMOTE_IOBotch(wid) REMOTE(wid)->IOBotch_
#define LOCAL_tokptr LOCAL->tokptr_
#define REMOTE_tokptr(wid) REMOTE(wid)->tokptr_
#define LOCAL_toktide LOCAL->toktide_
#define REMOTE_toktide(wid) REMOTE(wid)->toktide_
#define LOCAL_VarTable LOCAL->VarTable_
#define REMOTE_VarTable(wid) REMOTE(wid)->VarTable_
#define LOCAL_AnonVarTable LOCAL->AnonVarTable_
#define REMOTE_AnonVarTable(wid) REMOTE(wid)->AnonVarTable_
#define LOCAL_Comments LOCAL->Comments_
#define REMOTE_Comments(wid) REMOTE(wid)->Comments_
#define LOCAL_CommentsTail LOCAL->CommentsTail_
#define REMOTE_CommentsTail(wid) REMOTE(wid)->CommentsTail_
#define LOCAL_CommentsNextChar LOCAL->CommentsNextChar_
#define REMOTE_CommentsNextChar(wid) REMOTE(wid)->CommentsNextChar_
#define LOCAL_CommentsBuff LOCAL->CommentsBuff_
#define REMOTE_CommentsBuff(wid) REMOTE(wid)->CommentsBuff_
#define LOCAL_CommentsBuffPos LOCAL->CommentsBuffPos_
#define REMOTE_CommentsBuffPos(wid) REMOTE(wid)->CommentsBuffPos_
#define LOCAL_CommentsBuffLim LOCAL->CommentsBuffLim_
#define REMOTE_CommentsBuffLim(wid) REMOTE(wid)->CommentsBuffLim_
#define LOCAL_RestartEnv LOCAL->RestartEnv_
#define REMOTE_RestartEnv(wid) REMOTE(wid)->RestartEnv_
#define LOCAL_FileNameBuf LOCAL->FileNameBuf_
#define REMOTE_FileNameBuf(wid) REMOTE(wid)->FileNameBuf_
#define LOCAL_FileNameBuf2 LOCAL->FileNameBuf2_
#define REMOTE_FileNameBuf2(wid) REMOTE(wid)->FileNameBuf2_
#define LOCAL_PrologMode LOCAL->PrologMode_
#define REMOTE_PrologMode(wid) REMOTE(wid)->PrologMode_
#define LOCAL_CritLocks LOCAL->CritLocks_
#define REMOTE_CritLocks(wid) REMOTE(wid)->CritLocks_
#ifdef ANALYST
#define LOCAL_opcount LOCAL->opcount_
#define REMOTE_opcount(wid) REMOTE(wid)->opcount_
#define LOCAL_2opcount LOCAL->2opcount_
#define REMOTE_2opcount(wid) REMOTE(wid)->2opcount_
#endif /* ANALYST */
#define LOCAL_s_dbg LOCAL->s_dbg_
#define REMOTE_s_dbg(wid) REMOTE(wid)->s_dbg_
#define LOCAL_matherror LOCAL->matherror_
#define REMOTE_matherror(wid) REMOTE(wid)->matherror_
#define LOCAL_CurrentError LOCAL->CurrentError_
#define REMOTE_CurrentError(wid) REMOTE(wid)->CurrentError_
#define LOCAL_heap_overflows LOCAL->heap_overflows_
#define REMOTE_heap_overflows(wid) REMOTE(wid)->heap_overflows_
#define LOCAL_total_heap_overflow_time LOCAL->total_heap_overflow_time_
#define REMOTE_total_heap_overflow_time(wid) REMOTE(wid)->total_heap_overflow_time_
#define LOCAL_stack_overflows LOCAL->stack_overflows_
#define REMOTE_stack_overflows(wid) REMOTE(wid)->stack_overflows_
#define LOCAL_total_stack_overflow_time LOCAL->total_stack_overflow_time_
#define REMOTE_total_stack_overflow_time(wid) REMOTE(wid)->total_stack_overflow_time_
#define LOCAL_delay_overflows LOCAL->delay_overflows_
#define REMOTE_delay_overflows(wid) REMOTE(wid)->delay_overflows_
#define LOCAL_total_delay_overflow_time LOCAL->total_delay_overflow_time_
#define REMOTE_total_delay_overflow_time(wid) REMOTE(wid)->total_delay_overflow_time_
#define LOCAL_trail_overflows LOCAL->trail_overflows_
#define REMOTE_trail_overflows(wid) REMOTE(wid)->trail_overflows_
#define LOCAL_total_trail_overflow_time LOCAL->total_trail_overflow_time_
#define REMOTE_total_trail_overflow_time(wid) REMOTE(wid)->total_trail_overflow_time_
#define LOCAL_atom_table_overflows LOCAL->atom_table_overflows_
#define REMOTE_atom_table_overflows(wid) REMOTE(wid)->atom_table_overflows_
#define LOCAL_total_atom_table_overflow_time LOCAL->total_atom_table_overflow_time_
#define REMOTE_total_atom_table_overflow_time(wid) REMOTE(wid)->total_atom_table_overflow_time_
#ifdef LOAD_DYLD
#define LOCAL_dl_errno LOCAL->dl_errno_
#define REMOTE_dl_errno(wid) REMOTE(wid)->dl_errno_
#endif
#ifdef LOW_LEVEL_TRACER
#define LOCAL_do_trace_primitives LOCAL->do_trace_primitives_
#define REMOTE_do_trace_primitives(wid) REMOTE(wid)->do_trace_primitives_
#endif
#define LOCAL_ExportAtomHashChain LOCAL->ExportAtomHashChain_
#define REMOTE_ExportAtomHashChain(wid) REMOTE(wid)->ExportAtomHashChain_
#define LOCAL_ExportAtomHashTableSize LOCAL->ExportAtomHashTableSize_
#define REMOTE_ExportAtomHashTableSize(wid) REMOTE(wid)->ExportAtomHashTableSize_
#define LOCAL_ExportAtomHashTableNum LOCAL->ExportAtomHashTableNum_
#define REMOTE_ExportAtomHashTableNum(wid) REMOTE(wid)->ExportAtomHashTableNum_
#define LOCAL_ExportFunctorHashChain LOCAL->ExportFunctorHashChain_
#define REMOTE_ExportFunctorHashChain(wid) REMOTE(wid)->ExportFunctorHashChain_
#define LOCAL_ExportFunctorHashTableSize LOCAL->ExportFunctorHashTableSize_
#define REMOTE_ExportFunctorHashTableSize(wid) REMOTE(wid)->ExportFunctorHashTableSize_
#define LOCAL_ExportFunctorHashTableNum LOCAL->ExportFunctorHashTableNum_
#define REMOTE_ExportFunctorHashTableNum(wid) REMOTE(wid)->ExportFunctorHashTableNum_
#define LOCAL_ExportPredEntryHashChain LOCAL->ExportPredEntryHashChain_
#define REMOTE_ExportPredEntryHashChain(wid) REMOTE(wid)->ExportPredEntryHashChain_
#define LOCAL_ExportPredEntryHashTableSize LOCAL->ExportPredEntryHashTableSize_
#define REMOTE_ExportPredEntryHashTableSize(wid) REMOTE(wid)->ExportPredEntryHashTableSize_
#define LOCAL_ExportPredEntryHashTableNum LOCAL->ExportPredEntryHashTableNum_
#define REMOTE_ExportPredEntryHashTableNum(wid) REMOTE(wid)->ExportPredEntryHashTableNum_
#define LOCAL_ExportDBRefHashChain LOCAL->ExportDBRefHashChain_
#define REMOTE_ExportDBRefHashChain(wid) REMOTE(wid)->ExportDBRefHashChain_
#define LOCAL_ExportDBRefHashTableSize LOCAL->ExportDBRefHashTableSize_
#define REMOTE_ExportDBRefHashTableSize(wid) REMOTE(wid)->ExportDBRefHashTableSize_
#define LOCAL_ExportDBRefHashTableNum LOCAL->ExportDBRefHashTableNum_
#define REMOTE_ExportDBRefHashTableNum(wid) REMOTE(wid)->ExportDBRefHashTableNum_
#define LOCAL_ImportAtomHashChain LOCAL->ImportAtomHashChain_
#define REMOTE_ImportAtomHashChain(wid) REMOTE(wid)->ImportAtomHashChain_
#define LOCAL_ImportAtomHashTableSize LOCAL->ImportAtomHashTableSize_
#define REMOTE_ImportAtomHashTableSize(wid) REMOTE(wid)->ImportAtomHashTableSize_
#define LOCAL_ImportAtomHashTableNum LOCAL->ImportAtomHashTableNum_
#define REMOTE_ImportAtomHashTableNum(wid) REMOTE(wid)->ImportAtomHashTableNum_
#define LOCAL_ImportFunctorHashChain LOCAL->ImportFunctorHashChain_
#define REMOTE_ImportFunctorHashChain(wid) REMOTE(wid)->ImportFunctorHashChain_
#define LOCAL_ImportFunctorHashTableSize LOCAL->ImportFunctorHashTableSize_
#define REMOTE_ImportFunctorHashTableSize(wid) REMOTE(wid)->ImportFunctorHashTableSize_
#define LOCAL_ImportFunctorHashTableNum LOCAL->ImportFunctorHashTableNum_
#define REMOTE_ImportFunctorHashTableNum(wid) REMOTE(wid)->ImportFunctorHashTableNum_
#define LOCAL_ImportOPCODEHashChain LOCAL->ImportOPCODEHashChain_
#define REMOTE_ImportOPCODEHashChain(wid) REMOTE(wid)->ImportOPCODEHashChain_
#define LOCAL_ImportOPCODEHashTableSize LOCAL->ImportOPCODEHashTableSize_
#define REMOTE_ImportOPCODEHashTableSize(wid) REMOTE(wid)->ImportOPCODEHashTableSize_
#define LOCAL_ImportPredEntryHashChain LOCAL->ImportPredEntryHashChain_
#define REMOTE_ImportPredEntryHashChain(wid) REMOTE(wid)->ImportPredEntryHashChain_
#define LOCAL_ImportPredEntryHashTableSize LOCAL->ImportPredEntryHashTableSize_
#define REMOTE_ImportPredEntryHashTableSize(wid) REMOTE(wid)->ImportPredEntryHashTableSize_
#define LOCAL_ImportPredEntryHashTableNum LOCAL->ImportPredEntryHashTableNum_
#define REMOTE_ImportPredEntryHashTableNum(wid) REMOTE(wid)->ImportPredEntryHashTableNum_
#define LOCAL_ImportDBRefHashChain LOCAL->ImportDBRefHashChain_
#define REMOTE_ImportDBRefHashChain(wid) REMOTE(wid)->ImportDBRefHashChain_
#define LOCAL_ImportDBRefHashTableSize LOCAL->ImportDBRefHashTableSize_
#define REMOTE_ImportDBRefHashTableSize(wid) REMOTE(wid)->ImportDBRefHashTableSize_
#define LOCAL_ImportDBRefHashTableNum LOCAL->ImportDBRefHashTableNum_
#define REMOTE_ImportDBRefHashTableNum(wid) REMOTE(wid)->ImportDBRefHashTableNum_
#define LOCAL_ImportFAILCODE LOCAL->ImportFAILCODE_
#define REMOTE_ImportFAILCODE(wid) REMOTE(wid)->ImportFAILCODE_
#define LOCAL_FunctorVar LOCAL->FunctorVar_
#define REMOTE_FunctorVar(wid) REMOTE(wid)->FunctorVar_
#if __ANDROID__
#define LOCAL_assetManager LOCAL->assetManager_
#define REMOTE_assetManager(wid) REMOTE(wid)->assetManager_
#define LOCAL_InAssetDir LOCAL->InAssetDir_
#define REMOTE_InAssetDir(wid) REMOTE(wid)->InAssetDir_
#endif
#define LOCAL_ibnds LOCAL->ibnds_
#define REMOTE_ibnds(wid) REMOTE(wid)->ibnds_
#define LOCAL_exo_it LOCAL->exo_it_
#define REMOTE_exo_it(wid) REMOTE(wid)->exo_it_
#define LOCAL_exo_base LOCAL->exo_base_
#define REMOTE_exo_base(wid) REMOTE(wid)->exo_base_
#define LOCAL_exo_arity LOCAL->exo_arity_
#define REMOTE_exo_arity(wid) REMOTE(wid)->exo_arity_
#define LOCAL_exo_arg LOCAL->exo_arg_
#define REMOTE_exo_arg(wid) REMOTE(wid)->exo_arg_
#define LOCAL_search_atoms LOCAL->search_atoms_
#define REMOTE_search_atoms(wid) REMOTE(wid)->search_atoms_
#define LOCAL_CurSlot LOCAL->CurSlot_
#define REMOTE_CurSlot(wid) REMOTE(wid)->CurSlot_
#define LOCAL_SourceModule LOCAL->SourceModule_
#define REMOTE_SourceModule(wid) REMOTE(wid)->SourceModule_
#define LOCAL_MAX_SIZE LOCAL->MAX_SIZE_
#define REMOTE_MAX_SIZE(wid) REMOTE(wid)->MAX_SIZE_

File diff suppressed because it is too large Load Diff

View File

@ -14,195 +14,195 @@
break;
case _get_2atoms:
if (iarg == Yap_regnotoreg(1)) {
if (IsApplTerm(cl->u.cc.c1)) {
CELL *pt = RepAppl(cl->u.cc.c1);
if (IsApplTerm(cl->y_u.cc.c1)) {
CELL *pt = RepAppl(cl->y_u.cc.c1);
clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.cc.c1;
clause->ucd.t_ptr = cl->y_u.cc.c1;
} else
clause->Tag = cl->u.cc.c1;
clause->Tag = cl->y_u.cc.c1;
return;
}
if (iarg == Yap_regnotoreg(2)) {
if (IsApplTerm(cl->u.cc.c2)) {
CELL *pt = RepAppl(cl->u.cc.c2);
if (IsApplTerm(cl->y_u.cc.c2)) {
CELL *pt = RepAppl(cl->y_u.cc.c2);
clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.cc.c2;
clause->ucd.t_ptr = cl->y_u.cc.c2;
} else
clause->Tag = cl->u.cc.c2;
clause->Tag = cl->y_u.cc.c2;
return;
}
cl = NEXTOP(cl,cc);
break;
case _get_3atoms:
if (iarg == Yap_regnotoreg(1)) {
if (IsApplTerm(cl->u.ccc.c1)) {
CELL *pt = RepAppl(cl->u.ccc.c1);
if (IsApplTerm(cl->y_u.ccc.c1)) {
CELL *pt = RepAppl(cl->y_u.ccc.c1);
clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.ccc.c1;
clause->ucd.t_ptr = cl->y_u.ccc.c1;
} else
clause->Tag = cl->u.ccc.c1;
clause->Tag = cl->y_u.ccc.c1;
return;
}
if (iarg == Yap_regnotoreg(2)) {
if (IsApplTerm(cl->u.ccc.c2)) {
CELL *pt = RepAppl(cl->u.ccc.c2);
if (IsApplTerm(cl->y_u.ccc.c2)) {
CELL *pt = RepAppl(cl->y_u.ccc.c2);
clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.ccc.c2;
clause->ucd.t_ptr = cl->y_u.ccc.c2;
} else
clause->Tag = cl->u.ccc.c2;
clause->Tag = cl->y_u.ccc.c2;
return;
}
if (iarg == Yap_regnotoreg(3)) {
if (IsApplTerm(cl->u.ccc.c3)) {
CELL *pt = RepAppl(cl->u.ccc.c3);
if (IsApplTerm(cl->y_u.ccc.c3)) {
CELL *pt = RepAppl(cl->y_u.ccc.c3);
clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.ccc.c3;
clause->ucd.t_ptr = cl->y_u.ccc.c3;
} else
clause->Tag = cl->u.ccc.c3;
clause->Tag = cl->y_u.ccc.c3;
return;
}
cl = NEXTOP(cl,ccc);
break;
case _get_4atoms:
if (iarg == Yap_regnotoreg(1)) {
if (IsApplTerm(cl->u.cccc.c1)) {
CELL *pt = RepAppl(cl->u.cccc.c1);
if (IsApplTerm(cl->y_u.cccc.c1)) {
CELL *pt = RepAppl(cl->y_u.cccc.c1);
clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.cccc.c1;
clause->ucd.t_ptr = cl->y_u.cccc.c1;
} else
clause->Tag = cl->u.cccc.c1;
clause->Tag = cl->y_u.cccc.c1;
return;
}
if (iarg == Yap_regnotoreg(2)) {
if (IsApplTerm(cl->u.cccc.c2)) {
CELL *pt = RepAppl(cl->u.cccc.c2);
if (IsApplTerm(cl->y_u.cccc.c2)) {
CELL *pt = RepAppl(cl->y_u.cccc.c2);
clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.cccc.c2;
clause->ucd.t_ptr = cl->y_u.cccc.c2;
} else
clause->Tag = cl->u.cccc.c2;
clause->Tag = cl->y_u.cccc.c2;
return;
}
if (iarg == Yap_regnotoreg(3)) {
if (IsApplTerm(cl->u.cccc.c3)) {
CELL *pt = RepAppl(cl->u.cccc.c3);
if (IsApplTerm(cl->y_u.cccc.c3)) {
CELL *pt = RepAppl(cl->y_u.cccc.c3);
clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.cccc.c3;
clause->ucd.t_ptr = cl->y_u.cccc.c3;
} else
clause->Tag = cl->u.cccc.c3;
clause->Tag = cl->y_u.cccc.c3;
return;
}
if (iarg == Yap_regnotoreg(4)) {
if (IsApplTerm(cl->u.cccc.c4)) {
CELL *pt = RepAppl(cl->u.cccc.c4);
if (IsApplTerm(cl->y_u.cccc.c4)) {
CELL *pt = RepAppl(cl->y_u.cccc.c4);
clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.cccc.c4;
clause->ucd.t_ptr = cl->y_u.cccc.c4;
} else
clause->Tag = cl->u.cccc.c4;
clause->Tag = cl->y_u.cccc.c4;
return;
}
cl = NEXTOP(cl,cccc);
break;
case _get_5atoms:
if (iarg == Yap_regnotoreg(1)) {
if (IsApplTerm(cl->u.ccccc.c1)) {
CELL *pt = RepAppl(cl->u.ccccc.c1);
if (IsApplTerm(cl->y_u.ccccc.c1)) {
CELL *pt = RepAppl(cl->y_u.ccccc.c1);
clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.ccccc.c1;
clause->ucd.t_ptr = cl->y_u.ccccc.c1;
} else
clause->Tag = cl->u.ccccc.c1;
clause->Tag = cl->y_u.ccccc.c1;
return;
}
if (iarg == Yap_regnotoreg(2)) {
if (IsApplTerm(cl->u.ccccc.c2)) {
CELL *pt = RepAppl(cl->u.ccccc.c2);
if (IsApplTerm(cl->y_u.ccccc.c2)) {
CELL *pt = RepAppl(cl->y_u.ccccc.c2);
clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.ccccc.c2;
clause->ucd.t_ptr = cl->y_u.ccccc.c2;
} else
clause->Tag = cl->u.ccccc.c2;
clause->Tag = cl->y_u.ccccc.c2;
return;
}
if (iarg == Yap_regnotoreg(3)) {
if (IsApplTerm(cl->u.ccccc.c3)) {
CELL *pt = RepAppl(cl->u.ccccc.c3);
if (IsApplTerm(cl->y_u.ccccc.c3)) {
CELL *pt = RepAppl(cl->y_u.ccccc.c3);
clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.ccccc.c3;
clause->ucd.t_ptr = cl->y_u.ccccc.c3;
} else
clause->Tag = cl->u.ccccc.c3;
clause->Tag = cl->y_u.ccccc.c3;
return;
}
if (iarg == Yap_regnotoreg(4)) {
if (IsApplTerm(cl->u.ccccc.c4)) {
CELL *pt = RepAppl(cl->u.ccccc.c4);
if (IsApplTerm(cl->y_u.ccccc.c4)) {
CELL *pt = RepAppl(cl->y_u.ccccc.c4);
clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.ccccc.c4;
clause->ucd.t_ptr = cl->y_u.ccccc.c4;
} else
clause->Tag = cl->u.ccccc.c4;
clause->Tag = cl->y_u.ccccc.c4;
return;
}
if (iarg == Yap_regnotoreg(5)) {
if (IsApplTerm(cl->u.ccccc.c5)) {
CELL *pt = RepAppl(cl->u.ccccc.c5);
if (IsApplTerm(cl->y_u.ccccc.c5)) {
CELL *pt = RepAppl(cl->y_u.ccccc.c5);
clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.ccccc.c5;
clause->ucd.t_ptr = cl->y_u.ccccc.c5;
} else
clause->Tag = cl->u.ccccc.c5;
clause->Tag = cl->y_u.ccccc.c5;
return;
}
cl = NEXTOP(cl,ccccc);
break;
case _get_6atoms:
if (iarg == Yap_regnotoreg(1)) {
if (IsApplTerm(cl->u.cccccc.c1)) {
CELL *pt = RepAppl(cl->u.cccccc.c1);
if (IsApplTerm(cl->y_u.cccccc.c1)) {
CELL *pt = RepAppl(cl->y_u.cccccc.c1);
clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.cccccc.c1;
clause->ucd.t_ptr = cl->y_u.cccccc.c1;
} else
clause->Tag = cl->u.cccccc.c1;
clause->Tag = cl->y_u.cccccc.c1;
return;
}
if (iarg == Yap_regnotoreg(2)) {
if (IsApplTerm(cl->u.cccccc.c2)) {
CELL *pt = RepAppl(cl->u.cccccc.c2);
if (IsApplTerm(cl->y_u.cccccc.c2)) {
CELL *pt = RepAppl(cl->y_u.cccccc.c2);
clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.cccccc.c2;
clause->ucd.t_ptr = cl->y_u.cccccc.c2;
} else
clause->Tag = cl->u.cccccc.c2;
clause->Tag = cl->y_u.cccccc.c2;
return;
}
if (iarg == Yap_regnotoreg(3)) {
if (IsApplTerm(cl->u.cccccc.c3)) {
CELL *pt = RepAppl(cl->u.cccccc.c3);
if (IsApplTerm(cl->y_u.cccccc.c3)) {
CELL *pt = RepAppl(cl->y_u.cccccc.c3);
clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.cccccc.c3;
clause->ucd.t_ptr = cl->y_u.cccccc.c3;
} else
clause->Tag = cl->u.cccccc.c3;
clause->Tag = cl->y_u.cccccc.c3;
return;
}
if (iarg == Yap_regnotoreg(4)) {
if (IsApplTerm(cl->u.cccccc.c4)) {
CELL *pt = RepAppl(cl->u.cccccc.c4);
if (IsApplTerm(cl->y_u.cccccc.c4)) {
CELL *pt = RepAppl(cl->y_u.cccccc.c4);
clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.cccccc.c4;
clause->ucd.t_ptr = cl->y_u.cccccc.c4;
} else
clause->Tag = cl->u.cccccc.c4;
clause->Tag = cl->y_u.cccccc.c4;
return;
}
if (iarg == Yap_regnotoreg(5)) {
if (IsApplTerm(cl->u.cccccc.c5)) {
CELL *pt = RepAppl(cl->u.cccccc.c5);
if (IsApplTerm(cl->y_u.cccccc.c5)) {
CELL *pt = RepAppl(cl->y_u.cccccc.c5);
clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.cccccc.c5;
clause->ucd.t_ptr = cl->y_u.cccccc.c5;
} else
clause->Tag = cl->u.cccccc.c5;
clause->Tag = cl->y_u.cccccc.c5;
return;
}
if (iarg == Yap_regnotoreg(6)) {
if (IsApplTerm(cl->u.cccccc.c6)) {
CELL *pt = RepAppl(cl->u.cccccc.c6);
if (IsApplTerm(cl->y_u.cccccc.c6)) {
CELL *pt = RepAppl(cl->y_u.cccccc.c6);
clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.cccccc.c6;
clause->ucd.t_ptr = cl->y_u.cccccc.c6;
} else
clause->Tag = cl->u.cccccc.c6;
clause->Tag = cl->y_u.cccccc.c6;
return;
}
cl = NEXTOP(cl,cccccc);
@ -383,28 +383,28 @@
cl = NEXTOP(cl,ou);
break;
case _save_appl_x:
if (iarg == cl->u.ox.x) {
if (iarg == cl->y_u.ox.x) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,ox);
break;
case _save_appl_x_write:
if (iarg == cl->u.ox.x) {
if (iarg == cl->y_u.ox.x) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,ox);
break;
case _save_pair_x:
if (iarg == cl->u.ox.x) {
if (iarg == cl->y_u.ox.x) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,ox);
break;
case _save_pair_x_write:
if (iarg == cl->u.ox.x) {
if (iarg == cl->y_u.ox.x) {
clause->Tag = (CELL)NULL;
return;
}
@ -423,14 +423,14 @@
cl = NEXTOP(cl,ox);
break;
case _unify_l_x_var:
if (iarg == cl->u.ox.x) {
if (iarg == cl->y_u.ox.x) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,ox);
break;
case _unify_l_x_var_write:
if (iarg == cl->u.ox.x) {
if (iarg == cl->y_u.ox.x) {
clause->Tag = (CELL)NULL;
return;
}
@ -449,58 +449,58 @@
cl = NEXTOP(cl,ox);
break;
case _unify_x_var:
if (iarg == cl->u.ox.x) {
if (iarg == cl->y_u.ox.x) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,ox);
break;
case _unify_x_var_write:
if (iarg == cl->u.ox.x) {
if (iarg == cl->y_u.ox.x) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,ox);
break;
case _unify_l_x_var2:
if (iarg == cl->u.oxx.xl) {
if (iarg == cl->y_u.oxx.xl) {
clause->Tag = (CELL)NULL;
return;
}
if (iarg == cl->u.oxx.xr) {
if (iarg == cl->y_u.oxx.xr) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,oxx);
break;
case _unify_l_x_var2_write:
if (iarg == cl->u.oxx.xl) {
if (iarg == cl->y_u.oxx.xl) {
clause->Tag = (CELL)NULL;
return;
}
if (iarg == cl->u.oxx.xr) {
if (iarg == cl->y_u.oxx.xr) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,oxx);
break;
case _unify_x_var2:
if (iarg == cl->u.oxx.xl) {
if (iarg == cl->y_u.oxx.xl) {
clause->Tag = (CELL)NULL;
return;
}
if (iarg == cl->u.oxx.xr) {
if (iarg == cl->y_u.oxx.xr) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,oxx);
break;
case _unify_x_var2_write:
if (iarg == cl->u.oxx.xl) {
if (iarg == cl->y_u.oxx.xl) {
clause->Tag = (CELL)NULL;
return;
}
if (iarg == cl->u.oxx.xr) {
if (iarg == cl->y_u.oxx.xr) {
clause->Tag = (CELL)NULL;
return;
}
@ -558,7 +558,7 @@
cl = NEXTOP(cl,s);
break;
case _get_list:
if (iarg == cl->u.x.x) {
if (iarg == cl->y_u.x.x) {
clause->Tag = AbsPair(NULL);
clause->ucd.WorkPC = NEXTOP(cl,x);
return;
@ -566,21 +566,21 @@
cl = NEXTOP(cl,x);
break;
case _put_list:
if (iarg == cl->u.x.x) {
if (iarg == cl->y_u.x.x) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,x);
break;
case _put_dbterm:
if (iarg == cl->u.xD.x) {
if (iarg == cl->y_u.xD.x) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,xD);
break;
case _get_bigint:
if (iarg == cl->u.xN.x) {
if (iarg == cl->y_u.xN.x) {
clause->Tag = AbsAppl((CELL *)FunctorBigInt);
clause->ucd.t_ptr = (CELL)NULL;
return;
@ -588,78 +588,78 @@
cl = NEXTOP(cl,xN);
break;
case _put_bigint:
if (iarg == cl->u.xN.x) {
if (iarg == cl->y_u.xN.x) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,xN);
break;
case _get_atom:
if (iarg == cl->u.xc.x) {
if (IsApplTerm(cl->u.xc.c)) {
CELL *pt = RepAppl(cl->u.xc.c);
if (iarg == cl->y_u.xc.x) {
if (IsApplTerm(cl->y_u.xc.c)) {
CELL *pt = RepAppl(cl->y_u.xc.c);
clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.xc.c;
clause->ucd.t_ptr = cl->y_u.xc.c;
} else
clause->Tag = cl->u.xc.c;
clause->Tag = cl->y_u.xc.c;
return;
}
cl = NEXTOP(cl,xc);
break;
case _put_atom:
if (iarg == cl->u.xc.x) {
if (iarg == cl->y_u.xc.x) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,xc);
break;
case _get_float:
if (iarg == cl->u.xd.x) {
if (iarg == cl->y_u.xd.x) {
clause->Tag = AbsAppl((CELL *)FunctorDouble);
clause->ucd.t_ptr = AbsAppl(cl->u.xd.d);
clause->ucd.t_ptr = AbsAppl(cl->y_u.xd.d);
return;
}
cl = NEXTOP(cl,xd);
break;
case _put_float:
if (iarg == cl->u.xd.x) {
if (iarg == cl->y_u.xd.x) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,xd);
break;
case _get_struct:
if (iarg == cl->u.xfa.x) {
clause->Tag = AbsAppl((CELL *)cl->u.xfa.f);
if (iarg == cl->y_u.xfa.x) {
clause->Tag = AbsAppl((CELL *)cl->y_u.xfa.f);
clause->ucd.WorkPC = NEXTOP(cl,xfa);
return;
}
cl = NEXTOP(cl,xfa);
break;
case _put_struct:
if (iarg == cl->u.xfa.x) {
if (iarg == cl->y_u.xfa.x) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,xfa);
break;
case _get_longint:
if (iarg == cl->u.xi.x) {
if (iarg == cl->y_u.xi.x) {
clause->Tag = AbsAppl((CELL *)FunctorLongInt);
clause->ucd.t_ptr = AbsAppl(cl->u.xi.i);
clause->ucd.t_ptr = AbsAppl(cl->y_u.xi.i);
return;
}
cl = NEXTOP(cl,xi);
break;
case _put_longint:
if (iarg == cl->u.xi.x) {
if (iarg == cl->y_u.xi.x) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,xi);
break;
case _get_string:
if (iarg == cl->u.xu.x) {
if (iarg == cl->y_u.xu.x) {
clause->Tag = AbsAppl((CELL *)FunctorString);
clause->ucd.t_ptr = (CELL)NULL;
return;
@ -667,23 +667,23 @@
cl = NEXTOP(cl,xu);
break;
case _get_x_val:
if (cl->u.xx.xl == iarg ||
cl->u.xx.xr == iarg) {
if (cl->y_u.xx.xl == iarg ||
cl->y_u.xx.xr == iarg) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,xx);
break;
case _get_x_var:
if (cl->u.xx.xr == iarg ||
cl->u.xx.xl == iarg) {
if (cl->y_u.xx.xr == iarg ||
cl->y_u.xx.xl == iarg) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,xx);
break;
case _gl_void_valx:
if (iarg == cl->u.xx.xl) {
if (iarg == cl->y_u.xx.xl) {
clause->Tag = AbsPair(NULL);
clause->ucd.WorkPC = cl;
return;
@ -691,19 +691,19 @@
cl = NEXTOP(cl,xx);
break;
case _gl_void_varx:
if (iarg == cl->u.xx.xl) {
if (iarg == cl->y_u.xx.xl) {
clause->Tag = AbsPair(NULL);
clause->ucd.WorkPC = cl;
return;
}
if (iarg == cl->u.xx.xr) {
if (iarg == cl->y_u.xx.xr) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,xx);
break;
case _glist_valx:
if (iarg == cl->u.xx.xl) {
if (iarg == cl->y_u.xx.xl) {
clause->Tag = AbsPair(NULL);
clause->ucd.WorkPC = cl;
return;
@ -711,46 +711,46 @@
cl = NEXTOP(cl,xx);
break;
case _put_x_val:
if (cl->u.xx.xl == iarg ||
cl->u.xx.xr == iarg) {
if (cl->y_u.xx.xl == iarg ||
cl->y_u.xx.xr == iarg) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,xx);
break;
case _put_x_var:
if (iarg == cl->u.xx.xl) {
if (iarg == cl->y_u.xx.xl) {
clause->Tag = (CELL)NULL;
return;
}
if (iarg == cl->u.xx.xr) {
if (iarg == cl->y_u.xx.xr) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,xx);
break;
case _put_xx_val:
if (cl->u.xxxx.xl1 == iarg ||
cl->u.xxxx.xr1 == iarg) {
if (cl->y_u.xxxx.xl1 == iarg ||
cl->y_u.xxxx.xr1 == iarg) {
clause->Tag = (CELL)NULL;
return;
}
if (cl->u.xxxx.xl2 == iarg ||
cl->u.xxxx.xr2 == iarg) {
if (cl->y_u.xxxx.xl2 == iarg ||
cl->y_u.xxxx.xr2 == iarg) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,xxxx);
break;
case _get_y_val:
if (cl->u.yx.x == iarg) {
if (cl->y_u.yx.x == iarg) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,yx);
break;
case _get_y_var:
if (cl->u.yx.x == iarg) {
if (cl->y_u.yx.x == iarg) {
clause->Tag = (CELL)NULL;
return;
}
@ -763,7 +763,7 @@
cl = NEXTOP(cl,yx);
break;
case _glist_valy:
if (iarg == cl->u.yx.x) {
if (iarg == cl->y_u.yx.x) {
clause->Tag = AbsPair(NULL);
clause->ucd.WorkPC = cl;
return;
@ -771,32 +771,32 @@
cl = NEXTOP(cl,yx);
break;
case _put_unsafe:
if (cl->u.yx.x == iarg) {
if (cl->y_u.yx.x == iarg) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,yx);
break;
case _put_y_val:
if (cl->u.yx.x == iarg) {
if (cl->y_u.yx.x == iarg) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,yx);
break;
case _put_y_var:
if (iarg == cl->u.yx.x) {
if (iarg == cl->y_u.yx.x) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,yx);
break;
case _get_yy_var:
if (cl->u.yyxx.x1 == iarg) {
if (cl->y_u.yyxx.x1 == iarg) {
clause->Tag = (CELL)NULL;
return;
}
if (cl->u.yyxx.x2 == iarg) {
if (cl->y_u.yyxx.x2 == iarg) {
clause->Tag = (CELL)NULL;
return;
}

View File

@ -1,119 +1,123 @@
/* This file, hglobals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update misc/GLOBALS instead */
typedef struct global_data {
int Initialised_;
int InitialisedFromPL_;
int PL_Argc_;
char** PL_Argv_;
struct halt_hook* HaltHooks_;
int AllowLocalExpansion_;
int AllowGlobalExpansion_;
int AllowTrailExpansion_;
UInt SizeOfOverflow_;
UInt AGcThreshold_;
Agc_hook AGCHook_;
#if THREADS
UInt NOfThreads_;
UInt NOfThreadsCreated_;
UInt ThreadsTotalTime_;
lockvar ThreadHandlesLock_;
#endif
#if defined(YAPOR) || defined(THREADS)
lockvar BGL_;
#endif
#if defined(YAPOR) || defined(TABLING)
struct global_optyap_data optyap_data_;
#endif /* YAPOR || TABLING */
int PrologShouldHandleInterrupts_;
#if defined(THREADS)
pthread_t master_thread_;
#endif /* THREADS */
struct io_stream* stdout_;
struct io_stream* stderr_;
char** argv_;
int argc_;
#ifdef COROUTINING
ext_op attas_[attvars_ext+1];
#endif
int agc_calls_;
YAP_ULONG_LONG agc_collected_;
Int tot_agc_time_;
Int tot_agc_recovered_;
#if HAVE_MMAP
struct MMAP_ARRAY_BLOCK* mmap_arrays_;
#endif
#ifdef DEBUG
char Option_[20];
YP_FILE* logfile_;
#endif
#if defined(COFF) || defined(A_OUT)
char Executable_[YAP_FILENAME_MAX];
#endif
int OpaqueHandlersCount_;
struct opaque_handler_struct* OpaqueHandlers_;
#if __simplescalar__
char pwd_[YAP_FILENAME_MAX];
#endif
char* RestoreFile_;
Int ProfCalls_;
Int ProfGCs_;
Int ProfHGrows_;
Int ProfSGrows_;
Int ProfMallocs_;
Int ProfIndexing_;
Int ProfOn_;
Int ProfOns_;
struct RB_red_blk_node* ProfilerRoot_;
struct RB_red_blk_node* ProfilerNil_;
char* DIRNAME_;
#if LOW_PROF
int ProfilerOn_;
FILE* FProf_;
FILE* FPreds_;
#endif /* LOW_PROF */
} w_shared;
/* This file, hglobals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update misc/GLOBALS instead */
typedef struct global_data {
int Initialised_;
int InitialisedFromPL_;
int PL_Argc_;
char** PL_Argv_;
struct halt_hook* HaltHooks_;
int AllowLocalExpansion_;
int AllowGlobalExpansion_;
int AllowTrailExpansion_;
UInt SizeOfOverflow_;
UInt AGcThreshold_;
Agc_hook AGCHook_;
#if __ANDROID__
struct AAssetManager* assetManager_;
#endif
#if THREADS
UInt NOfThreads_;
UInt NOfThreadsCreated_;
UInt ThreadsTotalTime_;
lockvar ThreadHandlesLock_;
#endif
#if defined(YAPOR) || defined(THREADS)
lockvar BGL_;
#endif
#if defined(YAPOR) || defined(TABLING)
struct global_optyap_data optyap_data_;
#endif /* YAPOR || TABLING */
int PrologShouldHandleInterrupts_;
#if defined(THREADS)
pthread_t master_thread_;
#endif /* THREADS */
struct io_stream* stdout_;
struct io_stream* stderr_;
char** argv_;
int argc_;
#ifdef COROUTINING
ext_op attas_[attvars_ext+1];
#endif
int agc_calls_;
YAP_ULONG_LONG agc_collected_;
Int tot_agc_time_;
Int tot_agc_recovered_;
#if HAVE_MMAP
struct MMAP_ARRAY_BLOCK* mmap_arrays_;
#endif
#ifdef DEBUG
char Option_[20];
YP_FILE* logfile_;
#endif
#if defined(COFF) || defined(A_OUT)
char Executable_[YAP_FILENAME_MAX];
#endif
int OpaqueHandlersCount_;
struct opaque_handler_struct* OpaqueHandlers_;
#if __simplescalar__
char pwd_[YAP_FILENAME_MAX];
#endif
char* RestoreFile_;
Int ProfCalls_;
Int ProfGCs_;
Int ProfHGrows_;
Int ProfSGrows_;
Int ProfMallocs_;
Int ProfIndexing_;
Int ProfOn_;
Int ProfOns_;
struct RB_red_blk_node* ProfilerRoot_;
struct RB_red_blk_node* ProfilerNil_;
char* DIRNAME_;
#if LOW_PROF
int ProfilerOn_;
FILE* FProf_;
FILE* FPreds_;
#endif /* LOW_PROF */
} w_shared;

View File

@ -1,242 +1,247 @@
/* This file, hlocals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update misc/LOCALS instead */
typedef struct worker_local {
int c_input_stream_;
int c_output_stream_;
int c_error_stream_;
CELL* OldASP_;
CELL* OldLCL0_;
tr_fr_ptr OldTR_;
CELL* OldGlobalBase_;
CELL* OldH_;
CELL* OldH0_;
ADDR OldTrailBase_;
ADDR OldTrailTop_;
ADDR OldHeapBase_;
ADDR OldHeapTop_;
Int ClDiff_;
Int GDiff_;
Int HDiff_;
Int GDiff0_;
CELL* GSplit_;
Int LDiff_;
Int TrDiff_;
Int XDiff_;
Int DelayDiff_;
Int BaseDiff_;
YAP_ULONG_LONG ReductionsCounter_;
YAP_ULONG_LONG PredEntriesCounter_;
YAP_ULONG_LONG RetriesCounter_;
int ReductionsCounterOn_;
int PredEntriesCounterOn_;
int RetriesCounterOn_;
union CONSULT_OBJ* ConsultSp_;
UInt ConsultCapacity_;
union CONSULT_OBJ* ConsultBase_;
union CONSULT_OBJ* ConsultLow_;
Term GlobalArena_;
UInt GlobalArenaOverflows_;
Int ArenaOverflows_;
Int DepthArenas_;
int ArithError_;
struct pred_entry* LastAssertedPred_;
char* ScannerStack_;
struct scanner_extra_alloc* ScannerExtraBlocks_;
struct DB_TERM* BallTerm_;
UInt* ActiveSignals_;
UInt MaxActiveSignals_;
UInt FirstActiveSignal_;
UInt LastActiveSignal_;
UInt IPredArity_;
yamop* ProfEnd_;
int UncaughtThrow_;
int DoingUndefp_;
Int StartLine_;
scratch_block ScratchPad_;
#ifdef COROUTINING
Term WokenGoals_;
Term AttsMutableList_;
#endif
Term GcGeneration_;
Term GcPhase_;
UInt GcCurrentPhase_;
UInt GcCalls_;
Int TotGcTime_;
YAP_ULONG_LONG TotGcRecovered_;
Int LastGcTime_;
Int LastSSTime_;
CELL* OpenArray_;
Int total_marked_;
Int total_oldies_;
struct choicept* current_B_;
CELL* prev_HB_;
CELL* HGEN_;
CELL** iptop_;
#if defined(GC_NO_TAGS)
char* bp_;
#endif
tr_fr_ptr sTR_;
tr_fr_ptr sTR0_;
tr_fr_ptr new_TR_;
struct gc_mark_continuation* cont_top0_;
struct gc_mark_continuation* cont_top_;
int discard_trail_entries_;
gc_ma_hash_entry gc_ma_hash_table_[GC_MAVARS_HASH_SIZE];
gc_ma_hash_entry* gc_ma_h_top_;
gc_ma_hash_entry* gc_ma_h_list_;
UInt gc_timestamp_;
ADDR db_vec_;
ADDR db_vec0_;
struct RB_red_blk_node* db_root_;
struct RB_red_blk_node* db_nil_;
sigjmp_buf gc_restore_;
CELL* extra_gc_cells_;
CELL* extra_gc_cells_base_;
CELL* extra_gc_cells_top_;
UInt extra_gc_cells_size_;
struct array_entry* DynamicArrays_;
struct static_array_entry* StaticArrays_;
struct global_entry* GlobalVariables_;
int AllowRestart_;
struct mem_blk* CMemFirstBlock_;
UInt CMemFirstBlockSz_;
int nperm_;
Int* LabelFirstArray_;
UInt LabelFirstArraySz_;
struct PL_local_data* PL_local_data_p_;
#ifdef THREADS
struct thandle ThreadHandle_;
#endif /* THREADS */
#if defined(YAPOR) || defined(TABLING)
struct local_optyap_data optyap_data_;
#endif /* YAPOR || TABLING */
int InterruptsDisabled_;
struct open_query_struct* execution_;
#if LOW_LEVEL_TRACER
Int total_choicepoints_;
#endif
int consult_level_;
#if defined(YAPOR) || defined(THREADS)
lockvar SignalLock_;
#endif
ADDR LocalBase_;
ADDR GlobalBase_;
ADDR TrailBase_;
ADDR TrailTop_;
char* ErrorMessage_;
Term Error_Term_;
#ifdef THREADS
Term Error_TYPE_;
#else
yap_error_number Error_TYPE_;
#endif
UInt Error_Size_;
char ErrorSay_[MAX_ERROR_MSG_SIZE];
jmp_buf IOBotch_;
TokEntry* tokptr_;
TokEntry* toktide_;
VarEntry* VarTable_;
VarEntry* AnonVarTable_;
Term Comments_;
CELL* CommentsTail_;
CELL* CommentsNextChar_;
wchar_t* CommentsBuff_;
size_t CommentsBuffPos_;
size_t CommentsBuffLim_;
sigjmp_buf RestartEnv_;
char FileNameBuf_[YAP_FILENAME_MAX];
char FileNameBuf2_[YAP_FILENAME_MAX];
Int PrologMode_;
int CritLocks_;
#ifdef ANALYST
YAP_ULONG_LONG opcount_[_std_top+1];
YAP_ULONG_LONG 2opcount[_std_top+1][_std_top+1]_;
#endif /* ANALYST */
struct db_globs* s_dbg_;
yap_error_number matherror_;
yap_error_number CurrentError_;
int heap_overflows_;
Int total_heap_overflow_time_;
int stack_overflows_;
Int total_stack_overflow_time_;
int delay_overflows_;
Int total_delay_overflow_time_;
int trail_overflows_;
Int total_trail_overflow_time_;
int atom_table_overflows_;
Int total_atom_table_overflow_time_;
#ifdef LOAD_DYLD
int dl_errno_;
#endif
#ifdef LOW_LEVEL_TRACER
int do_trace_primitives_;
#endif
struct export_atom_hash_entry_struct *ExportAtomHashChain_;
UInt ExportAtomHashTableSize_;
UInt ExportAtomHashTableNum_;
struct export_functor_hash_entry_struct *ExportFunctorHashChain_;
UInt ExportFunctorHashTableSize_;
UInt ExportFunctorHashTableNum_;
struct export_pred_entry_hash_entry_struct *ExportPredEntryHashChain_;
UInt ExportPredEntryHashTableSize_;
UInt ExportPredEntryHashTableNum_;
struct export_dbref_hash_entry_struct *ExportDBRefHashChain_;
UInt ExportDBRefHashTableSize_;
UInt ExportDBRefHashTableNum_;
struct import_atom_hash_entry_struct **ImportAtomHashChain_;
UInt ImportAtomHashTableSize_;
UInt ImportAtomHashTableNum_;
struct import_functor_hash_entry_struct **ImportFunctorHashChain_;
UInt ImportFunctorHashTableSize_;
UInt ImportFunctorHashTableNum_;
struct import_opcode_hash_entry_struct **ImportOPCODEHashChain_;
UInt ImportOPCODEHashTableSize_;
struct import_pred_entry_hash_entry_struct **ImportPredEntryHashChain_;
UInt ImportPredEntryHashTableSize_;
UInt ImportPredEntryHashTableNum_;
struct import_dbref_hash_entry_struct **ImportDBRefHashChain_;
UInt ImportDBRefHashTableSize_;
UInt ImportDBRefHashTableNum_;
yamop *ImportFAILCODE_;
Functor FunctorVar_;
UInt ibnds_[256];
struct index_t* exo_it_;
CELL* exo_base_;
UInt exo_arity_;
UInt exo_arg_;
struct scan_atoms* search_atoms_;
Int CurSlot_;
Term SourceModule_;
size_t MAX_SIZE_;
} w_local;
/* This file, hlocals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update misc/LOCALS instead */
typedef struct worker_local {
int c_input_stream_;
int c_output_stream_;
int c_error_stream_;
CELL* OldASP_;
CELL* OldLCL0_;
tr_fr_ptr OldTR_;
CELL* OldGlobalBase_;
CELL* OldH_;
CELL* OldH0_;
ADDR OldTrailBase_;
ADDR OldTrailTop_;
ADDR OldHeapBase_;
ADDR OldHeapTop_;
Int ClDiff_;
Int GDiff_;
Int HDiff_;
Int GDiff0_;
CELL* GSplit_;
Int LDiff_;
Int TrDiff_;
Int XDiff_;
Int DelayDiff_;
Int BaseDiff_;
YAP_ULONG_LONG ReductionsCounter_;
YAP_ULONG_LONG PredEntriesCounter_;
YAP_ULONG_LONG RetriesCounter_;
int ReductionsCounterOn_;
int PredEntriesCounterOn_;
int RetriesCounterOn_;
union CONSULT_OBJ* ConsultSp_;
UInt ConsultCapacity_;
union CONSULT_OBJ* ConsultBase_;
union CONSULT_OBJ* ConsultLow_;
Term GlobalArena_;
UInt GlobalArenaOverflows_;
Int ArenaOverflows_;
Int DepthArenas_;
int ArithError_;
struct pred_entry* LastAssertedPred_;
char* ScannerStack_;
struct scanner_extra_alloc* ScannerExtraBlocks_;
struct DB_TERM* BallTerm_;
UInt MaxActiveSignals_;
UInt FirstActiveSignal_;
UInt LastActiveSignal_;
UInt* ActiveSignals_;
UInt IPredArity_;
yamop* ProfEnd_;
int UncaughtThrow_;
int DoingUndefp_;
Int StartLine_;
scratch_block ScratchPad_;
#ifdef COROUTINING
Term WokenGoals_;
Term AttsMutableList_;
#endif
Term GcGeneration_;
Term GcPhase_;
UInt GcCurrentPhase_;
UInt GcCalls_;
Int TotGcTime_;
YAP_ULONG_LONG TotGcRecovered_;
Int LastGcTime_;
Int LastSSTime_;
CELL* OpenArray_;
Int total_marked_;
Int total_oldies_;
struct choicept* current_B_;
CELL* prev_HB_;
CELL* HGEN_;
CELL** iptop_;
#if defined(GC_NO_TAGS)
char* bp_;
#endif
tr_fr_ptr sTR_;
tr_fr_ptr sTR0_;
tr_fr_ptr new_TR_;
struct gc_mark_continuation* cont_top0_;
struct gc_mark_continuation* cont_top_;
int discard_trail_entries_;
gc_ma_hash_entry gc_ma_hash_table_[GC_MAVARS_HASH_SIZE];
gc_ma_hash_entry* gc_ma_h_top_;
gc_ma_hash_entry* gc_ma_h_list_;
UInt gc_timestamp_;
ADDR db_vec_;
ADDR db_vec0_;
struct RB_red_blk_node* db_root_;
struct RB_red_blk_node* db_nil_;
sigjmp_buf gc_restore_;
CELL* extra_gc_cells_;
CELL* extra_gc_cells_base_;
CELL* extra_gc_cells_top_;
UInt extra_gc_cells_size_;
struct array_entry* DynamicArrays_;
struct static_array_entry* StaticArrays_;
struct global_entry* GlobalVariables_;
int AllowRestart_;
struct mem_blk* CMemFirstBlock_;
UInt CMemFirstBlockSz_;
int nperm_;
Int* LabelFirstArray_;
UInt LabelFirstArraySz_;
struct PL_local_data* PL_local_data_p_;
#ifdef THREADS
struct thandle ThreadHandle_;
#endif /* THREADS */
#if defined(YAPOR) || defined(TABLING)
struct local_optyap_data optyap_data_;
#endif /* YAPOR || TABLING */
int InterruptsDisabled_;
struct open_query_struct* execution_;
#if LOW_LEVEL_TRACER
Int total_choicepoints_;
#endif
int consult_level_;
#if defined(YAPOR) || defined(THREADS)
lockvar SignalLock_;
#endif
ADDR LocalBase_;
ADDR GlobalBase_;
ADDR TrailBase_;
ADDR TrailTop_;
char* ErrorMessage_;
Term Error_Term_;
#ifdef THREADS
Term Error_TYPE_;
#else
yap_error_number Error_TYPE_;
#endif
UInt Error_Size_;
char ErrorSay_[MAX_ERROR_MSG_SIZE];
jmp_buf IOBotch_;
TokEntry* tokptr_;
TokEntry* toktide_;
VarEntry* VarTable_;
VarEntry* AnonVarTable_;
Term Comments_;
CELL* CommentsTail_;
CELL* CommentsNextChar_;
wchar_t* CommentsBuff_;
size_t CommentsBuffPos_;
size_t CommentsBuffLim_;
sigjmp_buf RestartEnv_;
char FileNameBuf_[YAP_FILENAME_MAX];
char FileNameBuf2_[YAP_FILENAME_MAX];
Int PrologMode_;
int CritLocks_;
#ifdef ANALYST
YAP_ULONG_LONG opcount_[_std_top+1];
YAP_ULONG_LONG 2opcount[_std_top+1][_std_top+1]_;
#endif /* ANALYST */
struct db_globs* s_dbg_;
yap_error_number matherror_;
yap_error_number CurrentError_;
int heap_overflows_;
Int total_heap_overflow_time_;
int stack_overflows_;
Int total_stack_overflow_time_;
int delay_overflows_;
Int total_delay_overflow_time_;
int trail_overflows_;
Int total_trail_overflow_time_;
int atom_table_overflows_;
Int total_atom_table_overflow_time_;
#ifdef LOAD_DYLD
int dl_errno_;
#endif
#ifdef LOW_LEVEL_TRACER
int do_trace_primitives_;
#endif
struct export_atom_hash_entry_struct *ExportAtomHashChain_;
UInt ExportAtomHashTableSize_;
UInt ExportAtomHashTableNum_;
struct export_functor_hash_entry_struct *ExportFunctorHashChain_;
UInt ExportFunctorHashTableSize_;
UInt ExportFunctorHashTableNum_;
struct export_pred_entry_hash_entry_struct *ExportPredEntryHashChain_;
UInt ExportPredEntryHashTableSize_;
UInt ExportPredEntryHashTableNum_;
struct export_dbref_hash_entry_struct *ExportDBRefHashChain_;
UInt ExportDBRefHashTableSize_;
UInt ExportDBRefHashTableNum_;
struct import_atom_hash_entry_struct **ImportAtomHashChain_;
UInt ImportAtomHashTableSize_;
UInt ImportAtomHashTableNum_;
struct import_functor_hash_entry_struct **ImportFunctorHashChain_;
UInt ImportFunctorHashTableSize_;
UInt ImportFunctorHashTableNum_;
struct import_opcode_hash_entry_struct **ImportOPCODEHashChain_;
UInt ImportOPCODEHashTableSize_;
struct import_pred_entry_hash_entry_struct **ImportPredEntryHashChain_;
UInt ImportPredEntryHashTableSize_;
UInt ImportPredEntryHashTableNum_;
struct import_dbref_hash_entry_struct **ImportDBRefHashChain_;
UInt ImportDBRefHashTableSize_;
UInt ImportDBRefHashTableNum_;
yamop *ImportFAILCODE_;
Functor FunctorVar_;
#if __ANDROID__
struct AAssetManager* assetManager_;
char* InAssetDir_;
#endif
UInt ibnds_[256];
struct index_t* exo_it_;
CELL* exo_base_;
UInt exo_arity_;
UInt exo_arg_;
struct scan_atoms* search_atoms_;
yhandle_t CurSlot_;
Term SourceModule_;
size_t MAX_SIZE_;
} w_local;

View File

@ -376,7 +376,7 @@
FunctorContext2 = Yap_MkFunctor(AtomContext,2);
FunctorConsistencyError = Yap_MkFunctor(AtomConsistencyError,1);
FunctorCreep = Yap_MkFunctor(AtomCreep,1);
FunctorCsult = Yap_MkFunctor(AtomCsult,1);
FunctorCsult = Yap_MkFunctor(AtomCsult,2);
FunctorCurrentModule = Yap_MkFunctor(AtomCurrentModule,1);
FunctorCutBy = Yap_MkFunctor(AtomCutBy,1);
FunctorDBREF = Yap_MkFunctor(AtomDBREF,1);

View File

@ -1,119 +1,123 @@
/* This file, iglobals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update misc/GLOBALS instead */
static void InitGlobal(void) {
GLOBAL_Initialised = FALSE;
GLOBAL_InitialisedFromPL = FALSE;
GLOBAL_PL_Argc = 0;
GLOBAL_PL_Argv = NULL;
GLOBAL_HaltHooks = NULL;
GLOBAL_AllowLocalExpansion = TRUE;
GLOBAL_AllowGlobalExpansion = TRUE;
GLOBAL_AllowTrailExpansion = TRUE;
GLOBAL_SizeOfOverflow = 0;
GLOBAL_AGcThreshold = 10000;
GLOBAL_AGCHook = NULL;
#if THREADS
GLOBAL_NOfThreads = 1;
GLOBAL_NOfThreadsCreated = 1;
GLOBAL_ThreadsTotalTime = 0L;
INIT_LOCK(GLOBAL_ThreadHandlesLock);
#endif
#if defined(YAPOR) || defined(THREADS)
INIT_LOCK(GLOBAL_BGL);
#endif
#if defined(YAPOR) || defined(TABLING)
#endif /* YAPOR || TABLING */
#if defined(THREADS)
#endif /* THREADS */
GLOBAL_stdout = Soutput;
GLOBAL_stderr = Serror;
#ifdef COROUTINING
#endif
GLOBAL_tot_agc_time = 0;
GLOBAL_tot_agc_recovered = 0;
#if HAVE_MMAP
GLOBAL_mmap_arrays = NULL;
#endif
#ifdef DEBUG
#endif
#if defined(COFF) || defined(A_OUT)
#endif
GLOBAL_OpaqueHandlersCount = 0;
GLOBAL_OpaqueHandlers = NULL;
#if __simplescalar__
#endif
GLOBAL_DIRNAME = NULL;
#if LOW_PROF
GLOBAL_ProfilerOn = FALSE;
GLOBAL_FProf = NULL;
GLOBAL_FPreds = NULL;
#endif /* LOW_PROF */
}
/* This file, iglobals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update misc/GLOBALS instead */
static void InitGlobal(void) {
GLOBAL_Initialised = FALSE;
GLOBAL_InitialisedFromPL = FALSE;
GLOBAL_PL_Argc = 0;
GLOBAL_PL_Argv = NULL;
GLOBAL_HaltHooks = NULL;
GLOBAL_AllowLocalExpansion = TRUE;
GLOBAL_AllowGlobalExpansion = TRUE;
GLOBAL_AllowTrailExpansion = TRUE;
GLOBAL_SizeOfOverflow = 0;
GLOBAL_AGcThreshold = 10000;
GLOBAL_AGCHook = NULL;
#if __ANDROID__
GLOBAL_assetManager = GLOBAL_assetManager;
#endif
#if THREADS
GLOBAL_NOfThreads = 1;
GLOBAL_NOfThreadsCreated = 1;
GLOBAL_ThreadsTotalTime = 0L;
INIT_LOCK(GLOBAL_ThreadHandlesLock);
#endif
#if defined(YAPOR) || defined(THREADS)
INIT_LOCK(GLOBAL_BGL);
#endif
#if defined(YAPOR) || defined(TABLING)
#endif /* YAPOR || TABLING */
#if defined(THREADS)
#endif /* THREADS */
GLOBAL_stdout = Soutput;
GLOBAL_stderr = Serror;
#ifdef COROUTINING
#endif
GLOBAL_tot_agc_time = 0;
GLOBAL_tot_agc_recovered = 0;
#if HAVE_MMAP
GLOBAL_mmap_arrays = NULL;
#endif
#ifdef DEBUG
#endif
#if defined(COFF) || defined(A_OUT)
#endif
GLOBAL_OpaqueHandlersCount = 0;
GLOBAL_OpaqueHandlers = NULL;
#if __simplescalar__
#endif
GLOBAL_DIRNAME = NULL;
#if LOW_PROF
GLOBAL_ProfilerOn = FALSE;
GLOBAL_FProf = NULL;
GLOBAL_FPreds = NULL;
#endif /* LOW_PROF */
}

View File

@ -1,242 +1,247 @@
/* This file, ilocals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update misc/LOCALS instead */
static void InitWorker(int wid) {
REMOTE_c_input_stream(wid) = 0;
REMOTE_c_output_stream(wid) = 1;
REMOTE_c_error_stream(wid) = 2;
REMOTE_OldASP(wid) = NULL;
REMOTE_OldLCL0(wid) = NULL;
REMOTE_OldTR(wid) = NULL;
REMOTE_OldGlobalBase(wid) = NULL;
REMOTE_OldH(wid) = NULL;
REMOTE_OldH0(wid) = NULL;
REMOTE_OldTrailBase(wid) = NULL;
REMOTE_OldTrailTop(wid) = NULL;
REMOTE_OldHeapBase(wid) = NULL;
REMOTE_OldHeapTop(wid) = NULL;
REMOTE_ClDiff(wid) = 0L;
REMOTE_GDiff(wid) = 0L;
REMOTE_HDiff(wid) = 0L;
REMOTE_GDiff0(wid) = 0L;
REMOTE_GSplit(wid) = NULL;
REMOTE_LDiff(wid) = 0L;
REMOTE_TrDiff(wid) = 0L;
REMOTE_XDiff(wid) = 0L;
REMOTE_DelayDiff(wid) = 0L;
REMOTE_BaseDiff(wid) = 0L;
REMOTE_ReductionsCounter(wid) = 0L;
REMOTE_PredEntriesCounter(wid) = 0L;
REMOTE_RetriesCounter(wid) = 0L;
REMOTE_ReductionsCounterOn(wid) = 0L;
REMOTE_PredEntriesCounterOn(wid) = 0L;
REMOTE_RetriesCounterOn(wid) = 0L;
REMOTE_ConsultSp(wid) = NULL;
REMOTE_ConsultBase(wid) = NULL;
REMOTE_ConsultLow(wid) = NULL;
REMOTE_GlobalArena(wid) = 0L;
REMOTE_GlobalArenaOverflows(wid) = 0L;
REMOTE_ArenaOverflows(wid) = 0L;
REMOTE_DepthArenas(wid) = 0;
REMOTE_ArithError(wid) = FALSE;
REMOTE_LastAssertedPred(wid) = NULL;
REMOTE_ScannerStack(wid) = NULL;
REMOTE_ScannerExtraBlocks(wid) = NULL;
REMOTE_BallTerm(wid) = NULL;
REMOTE_MaxActiveSignals(wid) = 64L;
REMOTE_FirstActiveSignal(wid) = 0L;
REMOTE_LastActiveSignal(wid) = 0L;
REMOTE_ActiveSignals(wid) = Yap_InitSignals(wid);
REMOTE_IPredArity(wid) = 0L;
REMOTE_ProfEnd(wid) = NULL;
REMOTE_UncaughtThrow(wid) = FALSE;
REMOTE_DoingUndefp(wid) = FALSE;
REMOTE_StartLine(wid) = 0L;
InitScratchPad(wid);
#ifdef COROUTINING
REMOTE_WokenGoals(wid) = 0L;
REMOTE_AttsMutableList(wid) = 0L;
#endif
REMOTE_GcGeneration(wid) = 0L;
REMOTE_GcPhase(wid) = 0L;
REMOTE_GcCurrentPhase(wid) = 0L;
REMOTE_GcCalls(wid) = 0L;
REMOTE_TotGcTime(wid) = 0L;
REMOTE_TotGcRecovered(wid) = 0L;
REMOTE_LastGcTime(wid) = 0L;
REMOTE_LastSSTime(wid) = 0L;
REMOTE_OpenArray(wid) = NULL;
REMOTE_total_marked(wid) = 0L;
REMOTE_total_oldies(wid) = 0L;
REMOTE_current_B(wid) = NULL;
REMOTE_prev_HB(wid) = NULL;
REMOTE_HGEN(wid) = NULL;
REMOTE_iptop(wid) = NULL;
#if defined(GC_NO_TAGS)
REMOTE_bp(wid) = NULL;
#endif
REMOTE_sTR(wid) = NULL;
REMOTE_sTR0(wid) = NULL;
REMOTE_new_TR(wid) = NULL;
REMOTE_cont_top0(wid) = NULL;
REMOTE_cont_top(wid) = NULL;
REMOTE_discard_trail_entries(wid) = 0;
REMOTE_gc_ma_h_top(wid) = NULL;
REMOTE_gc_ma_h_list(wid) = NULL;
REMOTE_gc_timestamp(wid) = 0L;
REMOTE_db_vec(wid) = NULL;
REMOTE_db_vec0(wid) = NULL;
REMOTE_db_root(wid) = NULL;
REMOTE_db_nil(wid) = NULL;
REMOTE_extra_gc_cells_size(wid) = 256;
REMOTE_DynamicArrays(wid) = NULL;
REMOTE_StaticArrays(wid) = NULL;
REMOTE_GlobalVariables(wid) = NULL;
REMOTE_AllowRestart(wid) = FALSE;
REMOTE_CMemFirstBlock(wid) = NULL;
REMOTE_CMemFirstBlockSz(wid) = 0L;
REMOTE_nperm(wid) = 0L;
REMOTE_LabelFirstArray(wid) = NULL;
REMOTE_LabelFirstArraySz(wid) = 0L;
REMOTE_PL_local_data_p(wid) = Yap_InitThreadIO(wid);
#ifdef THREADS
InitThreadHandle(wid);
#endif /* THREADS */
#if defined(YAPOR) || defined(TABLING)
Yap_init_local_optyap_data(wid);
#endif /* YAPOR || TABLING */
REMOTE_InterruptsDisabled(wid) = FALSE;
REMOTE_execution(wid) = NULL;
#if LOW_LEVEL_TRACER
REMOTE_total_choicepoints(wid) = 0;
#endif
REMOTE_consult_level(wid) = 0;
#if defined(YAPOR) || defined(THREADS)
INIT_LOCK(REMOTE_SignalLock(wid));
#endif
#ifdef THREADS
#else
#endif
REMOTE_PrologMode(wid) = BootMode;
REMOTE_CritLocks(wid) = 0;
#ifdef ANALYST
#endif /* ANALYST */
REMOTE_matherror(wid) = YAP_NO_ERROR;
REMOTE_CurrentError(wid) = YAP_NO_ERROR;
REMOTE_heap_overflows(wid) = 0;
REMOTE_total_heap_overflow_time(wid) = 0;
REMOTE_stack_overflows(wid) = 0;
REMOTE_total_stack_overflow_time(wid) = 0;
REMOTE_delay_overflows(wid) = 0;
REMOTE_total_delay_overflow_time(wid) = 0;
REMOTE_trail_overflows(wid) = 0;
REMOTE_total_trail_overflow_time(wid) = 0;
REMOTE_atom_table_overflows(wid) = 0;
REMOTE_total_atom_table_overflow_time(wid) = 0;
#ifdef LOAD_DYLD
REMOTE_dl_errno(wid) = 0;
#endif
#ifdef LOW_LEVEL_TRACER
REMOTE_do_trace_primitives(wid) = TRUE;
#endif
REMOTE_ExportAtomHashChain(wid) = NULL;
REMOTE_ExportAtomHashTableSize(wid) = 0;
REMOTE_ExportAtomHashTableNum(wid) = 0;
REMOTE_ExportFunctorHashChain(wid) = NULL;
REMOTE_ExportFunctorHashTableSize(wid) = 0;
REMOTE_ExportFunctorHashTableNum(wid) = 0;
REMOTE_ExportPredEntryHashChain(wid) = NULL;
REMOTE_ExportPredEntryHashTableSize(wid) = 0;
REMOTE_ExportPredEntryHashTableNum(wid) = 0;
REMOTE_ExportDBRefHashChain(wid) = NULL;
REMOTE_ExportDBRefHashTableSize(wid) = 0;
REMOTE_ExportDBRefHashTableNum(wid) = 0;
REMOTE_ImportAtomHashChain(wid) = NULL;
REMOTE_ImportAtomHashTableSize(wid) = 0;
REMOTE_ImportAtomHashTableNum(wid) = 0;
REMOTE_ImportFunctorHashChain(wid) = NULL;
REMOTE_ImportFunctorHashTableSize(wid) = 0;
REMOTE_ImportFunctorHashTableNum(wid) = 0;
REMOTE_ImportOPCODEHashChain(wid) = NULL;
REMOTE_ImportOPCODEHashTableSize(wid) = 0;
REMOTE_ImportPredEntryHashChain(wid) = NULL;
REMOTE_ImportPredEntryHashTableSize(wid) = 0;
REMOTE_ImportPredEntryHashTableNum(wid) = 0;
REMOTE_ImportDBRefHashChain(wid) = NULL;
REMOTE_ImportDBRefHashTableSize(wid) = 0;
REMOTE_ImportDBRefHashTableNum(wid) = 0;
REMOTE_ImportFAILCODE(wid) = NULL;
REMOTE_FunctorVar(wid) = FunctorVar;
REMOTE_exo_it(wid) = NULL;
REMOTE_exo_base(wid) = NULL;
REMOTE_exo_arity(wid) = 0;
REMOTE_exo_arg(wid) = 0;
REMOTE_CurSlot(wid) = 0;
REMOTE_SourceModule(wid) = 0;
REMOTE_MAX_SIZE(wid) = 1024L;
}
/* This file, ilocals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update misc/LOCALS instead */
static void InitWorker(int wid) {
REMOTE_c_input_stream(wid) = 0;
REMOTE_c_output_stream(wid) = 1;
REMOTE_c_error_stream(wid) = 2;
REMOTE_OldASP(wid) = NULL;
REMOTE_OldLCL0(wid) = NULL;
REMOTE_OldTR(wid) = NULL;
REMOTE_OldGlobalBase(wid) = NULL;
REMOTE_OldH(wid) = NULL;
REMOTE_OldH0(wid) = NULL;
REMOTE_OldTrailBase(wid) = NULL;
REMOTE_OldTrailTop(wid) = NULL;
REMOTE_OldHeapBase(wid) = NULL;
REMOTE_OldHeapTop(wid) = NULL;
REMOTE_ClDiff(wid) = 0L;
REMOTE_GDiff(wid) = 0L;
REMOTE_HDiff(wid) = 0L;
REMOTE_GDiff0(wid) = 0L;
REMOTE_GSplit(wid) = NULL;
REMOTE_LDiff(wid) = 0L;
REMOTE_TrDiff(wid) = 0L;
REMOTE_XDiff(wid) = 0L;
REMOTE_DelayDiff(wid) = 0L;
REMOTE_BaseDiff(wid) = 0L;
REMOTE_ReductionsCounter(wid) = 0L;
REMOTE_PredEntriesCounter(wid) = 0L;
REMOTE_RetriesCounter(wid) = 0L;
REMOTE_ReductionsCounterOn(wid) = 0L;
REMOTE_PredEntriesCounterOn(wid) = 0L;
REMOTE_RetriesCounterOn(wid) = 0L;
REMOTE_ConsultSp(wid) = NULL;
REMOTE_ConsultBase(wid) = NULL;
REMOTE_ConsultLow(wid) = NULL;
REMOTE_GlobalArena(wid) = 0L;
REMOTE_GlobalArenaOverflows(wid) = 0L;
REMOTE_ArenaOverflows(wid) = 0L;
REMOTE_DepthArenas(wid) = 0;
REMOTE_ArithError(wid) = FALSE;
REMOTE_LastAssertedPred(wid) = NULL;
REMOTE_ScannerStack(wid) = NULL;
REMOTE_ScannerExtraBlocks(wid) = NULL;
REMOTE_BallTerm(wid) = NULL;
REMOTE_MaxActiveSignals(wid) = 64L;
REMOTE_FirstActiveSignal(wid) = 0L;
REMOTE_LastActiveSignal(wid) = 0L;
REMOTE_ActiveSignals(wid) = Yap_InitSignals(wid);
REMOTE_IPredArity(wid) = 0L;
REMOTE_ProfEnd(wid) = NULL;
REMOTE_UncaughtThrow(wid) = FALSE;
REMOTE_DoingUndefp(wid) = FALSE;
REMOTE_StartLine(wid) = 0L;
InitScratchPad(wid);
#ifdef COROUTINING
REMOTE_WokenGoals(wid) = 0L;
REMOTE_AttsMutableList(wid) = 0L;
#endif
REMOTE_GcGeneration(wid) = 0L;
REMOTE_GcPhase(wid) = 0L;
REMOTE_GcCurrentPhase(wid) = 0L;
REMOTE_GcCalls(wid) = 0L;
REMOTE_TotGcTime(wid) = 0L;
REMOTE_TotGcRecovered(wid) = 0L;
REMOTE_LastGcTime(wid) = 0L;
REMOTE_LastSSTime(wid) = 0L;
REMOTE_OpenArray(wid) = NULL;
REMOTE_total_marked(wid) = 0L;
REMOTE_total_oldies(wid) = 0L;
REMOTE_current_B(wid) = NULL;
REMOTE_prev_HB(wid) = NULL;
REMOTE_HGEN(wid) = NULL;
REMOTE_iptop(wid) = NULL;
#if defined(GC_NO_TAGS)
REMOTE_bp(wid) = NULL;
#endif
REMOTE_sTR(wid) = NULL;
REMOTE_sTR0(wid) = NULL;
REMOTE_new_TR(wid) = NULL;
REMOTE_cont_top0(wid) = NULL;
REMOTE_cont_top(wid) = NULL;
REMOTE_discard_trail_entries(wid) = 0;
REMOTE_gc_ma_h_top(wid) = NULL;
REMOTE_gc_ma_h_list(wid) = NULL;
REMOTE_gc_timestamp(wid) = 0L;
REMOTE_db_vec(wid) = NULL;
REMOTE_db_vec0(wid) = NULL;
REMOTE_db_root(wid) = NULL;
REMOTE_db_nil(wid) = NULL;
REMOTE_extra_gc_cells_size(wid) = 256;
REMOTE_DynamicArrays(wid) = NULL;
REMOTE_StaticArrays(wid) = NULL;
REMOTE_GlobalVariables(wid) = NULL;
REMOTE_AllowRestart(wid) = FALSE;
REMOTE_CMemFirstBlock(wid) = NULL;
REMOTE_CMemFirstBlockSz(wid) = 0L;
REMOTE_nperm(wid) = 0L;
REMOTE_LabelFirstArray(wid) = NULL;
REMOTE_LabelFirstArraySz(wid) = 0L;
REMOTE_PL_local_data_p(wid) = Yap_InitThreadIO(wid);
#ifdef THREADS
InitThreadHandle(wid);
#endif /* THREADS */
#if defined(YAPOR) || defined(TABLING)
Yap_init_local_optyap_data(wid);
#endif /* YAPOR || TABLING */
REMOTE_InterruptsDisabled(wid) = FALSE;
REMOTE_execution(wid) = NULL;
#if LOW_LEVEL_TRACER
REMOTE_total_choicepoints(wid) = 0;
#endif
REMOTE_consult_level(wid) = 0;
#if defined(YAPOR) || defined(THREADS)
INIT_LOCK(REMOTE_SignalLock(wid));
#endif
#ifdef THREADS
#else
#endif
REMOTE_PrologMode(wid) = BootMode;
REMOTE_CritLocks(wid) = 0;
#ifdef ANALYST
#endif /* ANALYST */
REMOTE_matherror(wid) = YAP_NO_ERROR;
REMOTE_CurrentError(wid) = YAP_NO_ERROR;
REMOTE_heap_overflows(wid) = 0;
REMOTE_total_heap_overflow_time(wid) = 0;
REMOTE_stack_overflows(wid) = 0;
REMOTE_total_stack_overflow_time(wid) = 0;
REMOTE_delay_overflows(wid) = 0;
REMOTE_total_delay_overflow_time(wid) = 0;
REMOTE_trail_overflows(wid) = 0;
REMOTE_total_trail_overflow_time(wid) = 0;
REMOTE_atom_table_overflows(wid) = 0;
REMOTE_total_atom_table_overflow_time(wid) = 0;
#ifdef LOAD_DYLD
REMOTE_dl_errno(wid) = 0;
#endif
#ifdef LOW_LEVEL_TRACER
REMOTE_do_trace_primitives(wid) = TRUE;
#endif
REMOTE_ExportAtomHashChain(wid) = NULL;
REMOTE_ExportAtomHashTableSize(wid) = 0;
REMOTE_ExportAtomHashTableNum(wid) = 0;
REMOTE_ExportFunctorHashChain(wid) = NULL;
REMOTE_ExportFunctorHashTableSize(wid) = 0;
REMOTE_ExportFunctorHashTableNum(wid) = 0;
REMOTE_ExportPredEntryHashChain(wid) = NULL;
REMOTE_ExportPredEntryHashTableSize(wid) = 0;
REMOTE_ExportPredEntryHashTableNum(wid) = 0;
REMOTE_ExportDBRefHashChain(wid) = NULL;
REMOTE_ExportDBRefHashTableSize(wid) = 0;
REMOTE_ExportDBRefHashTableNum(wid) = 0;
REMOTE_ImportAtomHashChain(wid) = NULL;
REMOTE_ImportAtomHashTableSize(wid) = 0;
REMOTE_ImportAtomHashTableNum(wid) = 0;
REMOTE_ImportFunctorHashChain(wid) = NULL;
REMOTE_ImportFunctorHashTableSize(wid) = 0;
REMOTE_ImportFunctorHashTableNum(wid) = 0;
REMOTE_ImportOPCODEHashChain(wid) = NULL;
REMOTE_ImportOPCODEHashTableSize(wid) = 0;
REMOTE_ImportPredEntryHashChain(wid) = NULL;
REMOTE_ImportPredEntryHashTableSize(wid) = 0;
REMOTE_ImportPredEntryHashTableNum(wid) = 0;
REMOTE_ImportDBRefHashChain(wid) = NULL;
REMOTE_ImportDBRefHashTableSize(wid) = 0;
REMOTE_ImportDBRefHashTableNum(wid) = 0;
REMOTE_ImportFAILCODE(wid) = NULL;
REMOTE_FunctorVar(wid) = FunctorVar;
#if __ANDROID__
REMOTE_assetManager(wid) = GLOBAL_assetManager;
REMOTE_InAssetDir(wid) = NULL;
#endif
REMOTE_exo_it(wid) = NULL;
REMOTE_exo_base(wid) = NULL;
REMOTE_exo_arity(wid) = 0;
REMOTE_exo_arg(wid) = 0;
REMOTE_CurSlot(wid) = 0;
REMOTE_SourceModule(wid) = 0;
REMOTE_MAX_SIZE(wid) = 1024L;
}

View File

@ -5,7 +5,7 @@
#define INLINE_ONLY __attribute__((gnu_inline,always_inline))
//#define INLINE_ONLY
#else
#define INLINE_ONLY
#define INLINE_ONLY inline EXTERN
#endif
#endif

View File

@ -551,6 +551,7 @@
YAP_AtomToInt(Yap_LookupAtom("runtime"));
YAP_AtomToInt(Yap_LookupAtom("save_class"));
YAP_AtomToInt(Yap_LookupAtom("save_option"));
YAP_AtomToInt(Yap_LookupAtom("scripting"));
YAP_AtomToInt(Yap_LookupAtom("see"));
YAP_AtomToInt(Yap_LookupAtom("seed"));
YAP_AtomToInt(Yap_LookupAtom("seek_method"));

View File

@ -1,33 +0,0 @@
#define SHORT_ADDRESSES 0
#undef SHORT_INTS
#undef SHORT_SPACE
#define FUNCTION_ADRESSES 0
#define ALIGN_LONGS 1
#undef LOW_ABSMI
#define MSHIFTOFFS 1
#define HAVE_SIGNAL 1
#define UInt unsigned int
#define UShort unsigned short
#define Int int
#define FFIEEE 1
#define Float float
#define FAFloat double
#define FunAdr(X) X
#define MIPSEL
#define HAVE_PROTO 1

View File

@ -28,6 +28,7 @@
#endif
#endif
// SWI Options
#define O_STRING 1
#define O_QUASIQUOTATIONS 1
@ -344,7 +345,7 @@ OpenList(int n USES_REGS)
BACKUP_H();
while (HR+2*n > ASP-1024) {
if (!Yap_dogc( 0, NULL PASS_REGS )) {
if (!Yap_dogc( 0, (Term *)NULL PASS_REGS )) {
RECOVER_H();
return FALSE;
}
@ -383,5 +384,4 @@ CloseList(Term t0, Term tail)
}
#endif /* PL_SHARED_INCLUDE */

View File

@ -251,4 +251,6 @@ atom_t ATOM_;
intptr_t system_thread_id(PL_thread_info_t *info);
#endif
extern Term Yap_StringToTerm(const char *s, size_t len, term_t bindings);
#endif /* PL_YAP_H */

View File

@ -102,7 +102,7 @@ typedef enum {
} qlf_tag_t;
#define STATIC_PRED_FLAGS (SourcePredFlag|DynamicPredFlag|LogUpdatePredFlag|CompiledPredFlag|MultiFileFlag|TabledPredFlag|MegaClausePredFlag|CountPredFlag|ProfiledPredFlag|ThreadLocalPredFlag|AtomDBPredFlag|ModuleTransparentPredFlag|NumberDBPredFlag|MetaPredFlag|SyncPredFlag|BackCPredFlag)
#define EXTRA_PRED_FLAGS (QuasiQuotationPredFlag|NoTracePredFlag|NoDebugPredFlag)
#define EXTRA_PRED_FLAGS (QuasiQuotationPredFlag|NoTracePredFlag|NoSpyPredFlag)
#define SYSTEM_PRED_FLAGS (BackCPredFlag|UserCPredFlag|CArgsPredFlag|AsmPredFlag|CPredFlag|BinaryPredFlag)

View File

@ -18,56 +18,56 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
switch (op) {
/* instructions type D */
case _write_dbterm:
pc->u.D.D = DBGroundTermAdjust(pc->u.D.D);
pc->y_u.D.D = DBGroundTermAdjust(pc->y_u.D.D);
pc = NEXTOP(pc,D);
break;
/* instructions type Illss */
case _enter_lu_pred:
pc->u.Illss.I = PtoLUIndexAdjust(pc->u.Illss.I);
pc->u.Illss.l1 = PtoOpAdjust(pc->u.Illss.l1);
pc->u.Illss.l2 = PtoOpAdjust(pc->u.Illss.l2);
pc->u.Illss.s = ConstantAdjust(pc->u.Illss.s);
pc->u.Illss.e = ConstantAdjust(pc->u.Illss.e);
pc->y_u.Illss.I = PtoLUIndexAdjust(pc->y_u.Illss.I);
pc->y_u.Illss.l1 = PtoOpAdjust(pc->y_u.Illss.l1);
pc->y_u.Illss.l2 = PtoOpAdjust(pc->y_u.Illss.l2);
pc->y_u.Illss.s = ConstantAdjust(pc->y_u.Illss.s);
pc->y_u.Illss.e = ConstantAdjust(pc->y_u.Illss.e);
opc = NEXTOP(pc,Illss);
pc = pc->u.Illss.l1;
pc = pc->y_u.Illss.l1;
break;
/* instructions type L */
case _alloc_for_logical_pred:
pc->u.L.ClBase = PtoLUClauseAdjust(pc->u.L.ClBase);
pc->y_u.L.ClBase = PtoLUClauseAdjust(pc->y_u.L.ClBase);
pc = NEXTOP(pc,L);
break;
/* instructions type N */
case _write_bigint:
pc->u.N.b = BlobTermInCodeAdjust(pc->u.N.b);
pc->y_u.N.b = BlobTermInCodeAdjust(pc->y_u.N.b);
pc = NEXTOP(pc,N);
break;
/* instructions type Osblp */
case _either:
case _or_else:
OrArgAdjust(pc->u.Osblp.or_arg);
pc->u.Osblp.s = ConstantAdjust(pc->u.Osblp.s);
pc->u.Osblp.bmap = CellPtoHeapAdjust(pc->u.Osblp.bmap);
pc->u.Osblp.l = PtoOpAdjust(pc->u.Osblp.l);
pc->u.Osblp.p0 = PtoPredAdjust(pc->u.Osblp.p0);
OrArgAdjust(pc->y_u.Osblp.or_arg);
pc->y_u.Osblp.s = ConstantAdjust(pc->y_u.Osblp.s);
pc->y_u.Osblp.bmap = CellPtoHeapAdjust(pc->y_u.Osblp.bmap);
pc->y_u.Osblp.l = PtoOpAdjust(pc->y_u.Osblp.l);
pc->y_u.Osblp.p0 = PtoPredAdjust(pc->y_u.Osblp.p0);
pc = NEXTOP(pc,Osblp);
break;
/* instructions type Osbmp */
case _p_execute:
case _p_execute_tail:
OrArgAdjust(pc->u.Osbmp.or_arg);
pc->u.Osbmp.s = ConstantAdjust(pc->u.Osbmp.s);
pc->u.Osbmp.bmap = CellPtoHeapAdjust(pc->u.Osbmp.bmap);
pc->u.Osbmp.mod = ModuleAdjust(pc->u.Osbmp.mod);
pc->u.Osbmp.p0 = PtoPredAdjust(pc->u.Osbmp.p0);
OrArgAdjust(pc->y_u.Osbmp.or_arg);
pc->y_u.Osbmp.s = ConstantAdjust(pc->y_u.Osbmp.s);
pc->y_u.Osbmp.bmap = CellPtoHeapAdjust(pc->y_u.Osbmp.bmap);
pc->y_u.Osbmp.mod = ModuleAdjust(pc->y_u.Osbmp.mod);
pc->y_u.Osbmp.p0 = PtoPredAdjust(pc->y_u.Osbmp.p0);
pc = NEXTOP(pc,Osbmp);
break;
/* instructions type Osbpa */
case _ensure_space:
OrArgAdjust(pc->u.Osbpa.or_arg);
pc->u.Osbpa.s = ConstantAdjust(pc->u.Osbpa.s);
pc->u.Osbpa.bmap = CellPtoHeapAdjust(pc->u.Osbpa.bmap);
pc->u.Osbpa.p = PtoPredAdjust(pc->u.Osbpa.p);
pc->u.Osbpa.i = ArityAdjust(pc->u.Osbpa.i);
OrArgAdjust(pc->y_u.Osbpa.or_arg);
pc->y_u.Osbpa.s = ConstantAdjust(pc->y_u.Osbpa.s);
pc->y_u.Osbpa.bmap = CellPtoHeapAdjust(pc->y_u.Osbpa.bmap);
pc->y_u.Osbpa.p = PtoPredAdjust(pc->y_u.Osbpa.p);
pc->y_u.Osbpa.i = ArityAdjust(pc->y_u.Osbpa.i);
pc = NEXTOP(pc,Osbpa);
break;
/* instructions type Osbpp */
@ -76,22 +76,22 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _call_usercpred:
case _fcall:
case _p_execute2:
OrArgAdjust(pc->u.Osbpp.or_arg);
pc->u.Osbpp.s = ConstantAdjust(pc->u.Osbpp.s);
pc->u.Osbpp.bmap = CellPtoHeapAdjust(pc->u.Osbpp.bmap);
pc->u.Osbpp.p = PtoPredAdjust(pc->u.Osbpp.p);
pc->u.Osbpp.p0 = PtoPredAdjust(pc->u.Osbpp.p0);
OrArgAdjust(pc->y_u.Osbpp.or_arg);
pc->y_u.Osbpp.s = ConstantAdjust(pc->y_u.Osbpp.s);
pc->y_u.Osbpp.bmap = CellPtoHeapAdjust(pc->y_u.Osbpp.bmap);
pc->y_u.Osbpp.p = PtoPredAdjust(pc->y_u.Osbpp.p);
pc->y_u.Osbpp.p0 = PtoPredAdjust(pc->y_u.Osbpp.p0);
pc = NEXTOP(pc,Osbpp);
break;
/* instructions type OtILl */
case _count_trust_logical:
case _profiled_trust_logical:
case _trust_logical:
OrArgAdjust(pc->u.OtILl.or_arg);
TabEntryAdjust(pc->u.OtILl.te);
pc->u.OtILl.block = PtoLUIndexAdjust(pc->u.OtILl.block);
pc->u.OtILl.d = PtoLUClauseAdjust(pc->u.OtILl.d);
pc->u.OtILl.n = PtoOpAdjust(pc->u.OtILl.n);
OrArgAdjust(pc->y_u.OtILl.or_arg);
TabEntryAdjust(pc->y_u.OtILl.te);
pc->y_u.OtILl.block = PtoLUIndexAdjust(pc->y_u.OtILl.block);
pc->y_u.OtILl.d = PtoLUClauseAdjust(pc->y_u.OtILl.d);
pc->y_u.OtILl.n = PtoOpAdjust(pc->y_u.OtILl.n);
pc = opc;
break;
/* instructions type OtaLl */
@ -99,12 +99,12 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _profiled_retry_logical:
case _retry_logical:
case _try_logical:
OrArgAdjust(pc->u.OtaLl.or_arg);
TabEntryAdjust(pc->u.OtaLl.te);
pc->u.OtaLl.s = ArityAdjust(pc->u.OtaLl.s);
pc->u.OtaLl.d = PtoLUClauseAdjust(pc->u.OtaLl.d);
pc->u.OtaLl.n = PtoOpAdjust(pc->u.OtaLl.n);
pc = pc->u.OtaLl.n;
OrArgAdjust(pc->y_u.OtaLl.or_arg);
TabEntryAdjust(pc->y_u.OtaLl.te);
pc->y_u.OtaLl.s = ArityAdjust(pc->y_u.OtaLl.s);
pc->y_u.OtaLl.d = PtoLUClauseAdjust(pc->y_u.OtaLl.d);
pc->y_u.OtaLl.n = PtoOpAdjust(pc->y_u.OtaLl.n);
pc = pc->y_u.OtaLl.n;
break;
/* instructions type OtapFs */
case _cut_c:
@ -113,12 +113,12 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _retry_userc:
case _try_c:
case _try_userc:
OrArgAdjust(pc->u.OtapFs.or_arg);
TabEntryAdjust(pc->u.OtapFs.te);
pc->u.OtapFs.s = ArityAdjust(pc->u.OtapFs.s);
pc->u.OtapFs.p = PtoPredAdjust(pc->u.OtapFs.p);
pc->u.OtapFs.f = ExternalFunctionAdjust(pc->u.OtapFs.f);
pc->u.OtapFs.extra = ConstantAdjust(pc->u.OtapFs.extra);
OrArgAdjust(pc->y_u.OtapFs.or_arg);
TabEntryAdjust(pc->y_u.OtapFs.te);
pc->y_u.OtapFs.s = ArityAdjust(pc->y_u.OtapFs.s);
pc->y_u.OtapFs.p = PtoPredAdjust(pc->y_u.OtapFs.p);
pc->y_u.OtapFs.f = ExternalFunctionAdjust(pc->y_u.OtapFs.f);
pc->y_u.OtapFs.extra = ConstantAdjust(pc->y_u.OtapFs.extra);
pc = NEXTOP(pc,OtapFs);
break;
/* instructions type Otapl */
@ -137,77 +137,77 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _try_and_mark:
case _try_clause:
case _try_me:
OrArgAdjust(pc->u.Otapl.or_arg);
TabEntryAdjust(pc->u.Otapl.te);
pc->u.Otapl.s = ArityAdjust(pc->u.Otapl.s);
pc->u.Otapl.p = PtoPredAdjust(pc->u.Otapl.p);
pc->u.Otapl.d = PtoOpAdjust(pc->u.Otapl.d);
OrArgAdjust(pc->y_u.Otapl.or_arg);
TabEntryAdjust(pc->y_u.Otapl.te);
pc->y_u.Otapl.s = ArityAdjust(pc->y_u.Otapl.s);
pc->y_u.Otapl.p = PtoPredAdjust(pc->y_u.Otapl.p);
pc->y_u.Otapl.d = PtoOpAdjust(pc->y_u.Otapl.d);
pc = NEXTOP(pc,Otapl);
break;
/* instructions type aFlp */
case _native_me:
pc->u.aFlp.n = ArityAdjust(pc->u.aFlp.n);
pc->u.aFlp.native = ExternalFunctionAdjust(pc->u.aFlp.native);
pc->u.aFlp.native_next = PtoOpAdjust(pc->u.aFlp.native_next);
pc->u.aFlp.p = PtoPredAdjust(pc->u.aFlp.p);
pc->y_u.aFlp.n = ArityAdjust(pc->y_u.aFlp.n);
pc->y_u.aFlp.native = ExternalFunctionAdjust(pc->y_u.aFlp.native);
pc->y_u.aFlp.native_next = PtoOpAdjust(pc->y_u.aFlp.native_next);
pc->y_u.aFlp.p = PtoPredAdjust(pc->y_u.aFlp.p);
pc = NEXTOP(pc,aFlp);
break;
/* instructions type c */
case _write_atom:
pc->u.c.c = ConstantTermAdjust(pc->u.c.c);
pc->y_u.c.c = ConstantTermAdjust(pc->y_u.c.c);
pc = NEXTOP(pc,c);
break;
/* instructions type cc */
case _get_2atoms:
pc->u.cc.c1 = ConstantTermAdjust(pc->u.cc.c1);
pc->u.cc.c2 = ConstantTermAdjust(pc->u.cc.c2);
pc->y_u.cc.c1 = ConstantTermAdjust(pc->y_u.cc.c1);
pc->y_u.cc.c2 = ConstantTermAdjust(pc->y_u.cc.c2);
pc = NEXTOP(pc,cc);
break;
/* instructions type ccc */
case _get_3atoms:
pc->u.ccc.c1 = ConstantTermAdjust(pc->u.ccc.c1);
pc->u.ccc.c2 = ConstantTermAdjust(pc->u.ccc.c2);
pc->u.ccc.c3 = ConstantTermAdjust(pc->u.ccc.c3);
pc->y_u.ccc.c1 = ConstantTermAdjust(pc->y_u.ccc.c1);
pc->y_u.ccc.c2 = ConstantTermAdjust(pc->y_u.ccc.c2);
pc->y_u.ccc.c3 = ConstantTermAdjust(pc->y_u.ccc.c3);
pc = NEXTOP(pc,ccc);
break;
/* instructions type cccc */
case _get_4atoms:
pc->u.cccc.c1 = ConstantTermAdjust(pc->u.cccc.c1);
pc->u.cccc.c2 = ConstantTermAdjust(pc->u.cccc.c2);
pc->u.cccc.c3 = ConstantTermAdjust(pc->u.cccc.c3);
pc->u.cccc.c4 = ConstantTermAdjust(pc->u.cccc.c4);
pc->y_u.cccc.c1 = ConstantTermAdjust(pc->y_u.cccc.c1);
pc->y_u.cccc.c2 = ConstantTermAdjust(pc->y_u.cccc.c2);
pc->y_u.cccc.c3 = ConstantTermAdjust(pc->y_u.cccc.c3);
pc->y_u.cccc.c4 = ConstantTermAdjust(pc->y_u.cccc.c4);
pc = NEXTOP(pc,cccc);
break;
/* instructions type ccccc */
case _get_5atoms:
pc->u.ccccc.c1 = ConstantTermAdjust(pc->u.ccccc.c1);
pc->u.ccccc.c2 = ConstantTermAdjust(pc->u.ccccc.c2);
pc->u.ccccc.c3 = ConstantTermAdjust(pc->u.ccccc.c3);
pc->u.ccccc.c4 = ConstantTermAdjust(pc->u.ccccc.c4);
pc->u.ccccc.c5 = ConstantTermAdjust(pc->u.ccccc.c5);
pc->y_u.ccccc.c1 = ConstantTermAdjust(pc->y_u.ccccc.c1);
pc->y_u.ccccc.c2 = ConstantTermAdjust(pc->y_u.ccccc.c2);
pc->y_u.ccccc.c3 = ConstantTermAdjust(pc->y_u.ccccc.c3);
pc->y_u.ccccc.c4 = ConstantTermAdjust(pc->y_u.ccccc.c4);
pc->y_u.ccccc.c5 = ConstantTermAdjust(pc->y_u.ccccc.c5);
pc = NEXTOP(pc,ccccc);
break;
/* instructions type cccccc */
case _get_6atoms:
pc->u.cccccc.c1 = ConstantTermAdjust(pc->u.cccccc.c1);
pc->u.cccccc.c2 = ConstantTermAdjust(pc->u.cccccc.c2);
pc->u.cccccc.c3 = ConstantTermAdjust(pc->u.cccccc.c3);
pc->u.cccccc.c4 = ConstantTermAdjust(pc->u.cccccc.c4);
pc->u.cccccc.c5 = ConstantTermAdjust(pc->u.cccccc.c5);
pc->u.cccccc.c6 = ConstantTermAdjust(pc->u.cccccc.c6);
pc->y_u.cccccc.c1 = ConstantTermAdjust(pc->y_u.cccccc.c1);
pc->y_u.cccccc.c2 = ConstantTermAdjust(pc->y_u.cccccc.c2);
pc->y_u.cccccc.c3 = ConstantTermAdjust(pc->y_u.cccccc.c3);
pc->y_u.cccccc.c4 = ConstantTermAdjust(pc->y_u.cccccc.c4);
pc->y_u.cccccc.c5 = ConstantTermAdjust(pc->y_u.cccccc.c5);
pc->y_u.cccccc.c6 = ConstantTermAdjust(pc->y_u.cccccc.c6);
pc = NEXTOP(pc,cccccc);
break;
/* instructions type clll */
case _if_not_then:
pc->u.clll.c = ConstantTermAdjust(pc->u.clll.c);
pc->u.clll.l1 = PtoOpAdjust(pc->u.clll.l1);
pc->u.clll.l2 = PtoOpAdjust(pc->u.clll.l2);
pc->u.clll.l3 = PtoOpAdjust(pc->u.clll.l3);
pc->y_u.clll.c = ConstantTermAdjust(pc->y_u.clll.c);
pc->y_u.clll.l1 = PtoOpAdjust(pc->y_u.clll.l1);
pc->y_u.clll.l2 = PtoOpAdjust(pc->y_u.clll.l2);
pc->y_u.clll.l3 = PtoOpAdjust(pc->y_u.clll.l3);
pc = NEXTOP(pc,clll);
break;
/* instructions type d */
case _write_float:
DoubleInCodeAdjust(pc->u.d.d);
DoubleInCodeAdjust(pc->y_u.d.d);
pc = NEXTOP(pc,d);
break;
/* instructions type e */
@ -245,13 +245,13 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
/* instructions type fa */
case _write_l_struc:
case _write_struct:
pc->u.fa.f = FuncAdjust(pc->u.fa.f);
pc->u.fa.a = ArityAdjust(pc->u.fa.a);
pc->y_u.fa.f = FuncAdjust(pc->y_u.fa.f);
pc->y_u.fa.a = ArityAdjust(pc->y_u.fa.a);
pc = NEXTOP(pc,fa);
break;
/* instructions type i */
case _write_longint:
IntegerInCodeAdjust(pc->u.i.i);
IntegerInCodeAdjust(pc->y_u.i.i);
pc = NEXTOP(pc,i);
break;
/* instructions type l */
@ -269,16 +269,16 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _try_clause3:
case _try_clause4:
case _try_in:
pc->u.l.l = PtoOpAdjust(pc->u.l.l);
pc->y_u.l.l = PtoOpAdjust(pc->y_u.l.l);
if (op == _Ystop) return;
pc = NEXTOP(pc,l);
break;
/* instructions type llll */
case _switch_on_type:
pc->u.llll.l1 = PtoOpAdjust(pc->u.llll.l1);
pc->u.llll.l2 = PtoOpAdjust(pc->u.llll.l2);
pc->u.llll.l3 = PtoOpAdjust(pc->u.llll.l3);
pc->u.llll.l4 = PtoOpAdjust(pc->u.llll.l4);
pc->y_u.llll.l1 = PtoOpAdjust(pc->y_u.llll.l1);
pc->y_u.llll.l2 = PtoOpAdjust(pc->y_u.llll.l2);
pc->y_u.llll.l3 = PtoOpAdjust(pc->y_u.llll.l3);
pc->y_u.llll.l4 = PtoOpAdjust(pc->y_u.llll.l4);
pc = NEXTOP(pc,llll);
break;
/* instructions type lp */
@ -289,8 +289,8 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _try_exo:
case _try_exo_udi:
case _user_switch:
pc->u.lp.l = PtoOpAdjust(pc->u.lp.l);
pc->u.lp.p = PtoPredAdjust(pc->u.lp.p);
pc->y_u.lp.l = PtoOpAdjust(pc->y_u.lp.l);
pc->y_u.lp.p = PtoPredAdjust(pc->y_u.lp.p);
pc = NEXTOP(pc,lp);
break;
/* instructions type o */
@ -302,21 +302,21 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _unify_list_write:
case _unify_void:
case _unify_void_write:
pc->u.o.opcw = OpcodeAdjust(pc->u.o.opcw);
pc->y_u.o.opcw = OpcodeAdjust(pc->y_u.o.opcw);
pc = NEXTOP(pc,o);
break;
/* instructions type oD */
case _unify_dbterm:
case _unify_l_dbterm:
pc->u.oD.opcw = OpcodeAdjust(pc->u.oD.opcw);
pc->u.oD.D = DBGroundTermAdjust(pc->u.oD.D);
pc->y_u.oD.opcw = OpcodeAdjust(pc->y_u.oD.opcw);
pc->y_u.oD.D = DBGroundTermAdjust(pc->y_u.oD.D);
pc = NEXTOP(pc,oD);
break;
/* instructions type oN */
case _unify_bigint:
case _unify_l_bigint:
pc->u.oN.opcw = OpcodeAdjust(pc->u.oN.opcw);
pc->u.oN.b = BlobTermInCodeAdjust(pc->u.oN.b);
pc->y_u.oN.opcw = OpcodeAdjust(pc->y_u.oN.opcw);
pc->y_u.oN.b = BlobTermInCodeAdjust(pc->y_u.oN.b);
pc = NEXTOP(pc,oN);
break;
/* instructions type oc */
@ -324,8 +324,8 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _unify_atom_write:
case _unify_l_atom:
case _unify_l_atom_write:
pc->u.oc.opcw = OpcodeAdjust(pc->u.oc.opcw);
pc->u.oc.c = ConstantTermAdjust(pc->u.oc.c);
pc->y_u.oc.opcw = OpcodeAdjust(pc->y_u.oc.opcw);
pc->y_u.oc.c = ConstantTermAdjust(pc->y_u.oc.c);
pc = NEXTOP(pc,oc);
break;
/* instructions type od */
@ -333,8 +333,8 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _unify_float_write:
case _unify_l_float:
case _unify_l_float_write:
pc->u.od.opcw = OpcodeAdjust(pc->u.od.opcw);
DoubleInCodeAdjust(pc->u.od.d);
pc->y_u.od.opcw = OpcodeAdjust(pc->y_u.od.opcw);
DoubleInCodeAdjust(pc->y_u.od.d);
pc = NEXTOP(pc,od);
break;
/* instructions type ofa */
@ -342,9 +342,9 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _unify_l_struc_write:
case _unify_struct:
case _unify_struct_write:
pc->u.ofa.opcw = OpcodeAdjust(pc->u.ofa.opcw);
pc->u.ofa.f = FuncAdjust(pc->u.ofa.f);
pc->u.ofa.a = ArityAdjust(pc->u.ofa.a);
pc->y_u.ofa.opcw = OpcodeAdjust(pc->y_u.ofa.opcw);
pc->y_u.ofa.f = FuncAdjust(pc->y_u.ofa.f);
pc->y_u.ofa.a = ArityAdjust(pc->y_u.ofa.a);
pc = NEXTOP(pc,ofa);
break;
/* instructions type oi */
@ -352,17 +352,17 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _unify_l_longint_write:
case _unify_longint:
case _unify_longint_write:
pc->u.oi.opcw = OpcodeAdjust(pc->u.oi.opcw);
IntegerInCodeAdjust(pc->u.oi.i);
pc->y_u.oi.opcw = OpcodeAdjust(pc->y_u.oi.opcw);
IntegerInCodeAdjust(pc->y_u.oi.i);
pc = NEXTOP(pc,oi);
break;
/* instructions type ollll */
case _switch_list_nl:
pc->u.ollll.pop = OpcodeAdjust(pc->u.ollll.pop);
pc->u.ollll.l1 = PtoOpAdjust(pc->u.ollll.l1);
pc->u.ollll.l2 = PtoOpAdjust(pc->u.ollll.l2);
pc->u.ollll.l3 = PtoOpAdjust(pc->u.ollll.l3);
pc->u.ollll.l4 = PtoOpAdjust(pc->u.ollll.l4);
pc->y_u.ollll.pop = OpcodeAdjust(pc->y_u.ollll.pop);
pc->y_u.ollll.l1 = PtoOpAdjust(pc->y_u.ollll.l1);
pc->y_u.ollll.l2 = PtoOpAdjust(pc->y_u.ollll.l2);
pc->y_u.ollll.l3 = PtoOpAdjust(pc->y_u.ollll.l3);
pc->y_u.ollll.l4 = PtoOpAdjust(pc->y_u.ollll.l4);
pc = NEXTOP(pc,ollll);
break;
/* instructions type os */
@ -373,23 +373,23 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _unify_l_n_voids_write:
case _unify_n_voids:
case _unify_n_voids_write:
pc->u.os.opcw = OpcodeAdjust(pc->u.os.opcw);
pc->u.os.s = ConstantAdjust(pc->u.os.s);
pc->y_u.os.opcw = OpcodeAdjust(pc->y_u.os.opcw);
pc->y_u.os.s = ConstantAdjust(pc->y_u.os.s);
pc = NEXTOP(pc,os);
break;
/* instructions type osc */
case _unify_n_atoms:
case _unify_n_atoms_write:
pc->u.osc.opcw = OpcodeAdjust(pc->u.osc.opcw);
pc->u.osc.s = ConstantAdjust(pc->u.osc.s);
pc->u.osc.c = ConstantTermAdjust(pc->u.osc.c);
pc->y_u.osc.opcw = OpcodeAdjust(pc->y_u.osc.opcw);
pc->y_u.osc.s = ConstantAdjust(pc->y_u.osc.s);
pc->y_u.osc.c = ConstantTermAdjust(pc->y_u.osc.c);
pc = NEXTOP(pc,osc);
break;
/* instructions type ou */
case _unify_l_string:
case _unify_string:
pc->u.ou.opcw = OpcodeAdjust(pc->u.ou.opcw);
pc->u.ou.ut = BlobTermInCodeAdjust(pc->u.ou.ut);
pc->y_u.ou.opcw = OpcodeAdjust(pc->y_u.ou.opcw);
pc->y_u.ou.ut = BlobTermInCodeAdjust(pc->y_u.ou.ut);
pc = NEXTOP(pc,ou);
break;
/* instructions type ox */
@ -409,8 +409,8 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _unify_x_val_write:
case _unify_x_var:
case _unify_x_var_write:
pc->u.ox.opcw = OpcodeAdjust(pc->u.ox.opcw);
pc->u.ox.x = XAdjust(pc->u.ox.x);
pc->y_u.ox.opcw = OpcodeAdjust(pc->y_u.ox.opcw);
pc->y_u.ox.x = XAdjust(pc->y_u.ox.x);
pc = NEXTOP(pc,ox);
break;
/* instructions type oxx */
@ -418,9 +418,9 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _unify_l_x_var2_write:
case _unify_x_var2:
case _unify_x_var2_write:
pc->u.oxx.opcw = OpcodeAdjust(pc->u.oxx.opcw);
pc->u.oxx.xl = XAdjust(pc->u.oxx.xl);
pc->u.oxx.xr = XAdjust(pc->u.oxx.xr);
pc->y_u.oxx.opcw = OpcodeAdjust(pc->y_u.oxx.opcw);
pc->y_u.oxx.xl = XAdjust(pc->y_u.oxx.xl);
pc->y_u.oxx.xr = XAdjust(pc->y_u.oxx.xr);
pc = NEXTOP(pc,oxx);
break;
/* instructions type oy */
@ -440,8 +440,8 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _unify_y_val_write:
case _unify_y_var:
case _unify_y_var_write:
pc->u.oy.opcw = OpcodeAdjust(pc->u.oy.opcw);
pc->u.oy.y = YAdjust(pc->u.oy.y);
pc->y_u.oy.opcw = OpcodeAdjust(pc->y_u.oy.opcw);
pc->y_u.oy.y = YAdjust(pc->y_u.oy.y);
pc = NEXTOP(pc,oy);
break;
/* instructions type p */
@ -454,43 +454,43 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _retry_profiled:
case _retry_udi:
case _try_udi:
pc->u.p.p = PtoPredAdjust(pc->u.p.p);
pc->y_u.p.p = PtoPredAdjust(pc->y_u.p.p);
pc = NEXTOP(pc,p);
break;
/* instructions type plxxs */
case _call_bfunc_xx:
pc->u.plxxs.p = PtoPredAdjust(pc->u.plxxs.p);
pc->u.plxxs.f = PtoOpAdjust(pc->u.plxxs.f);
pc->u.plxxs.x1 = XAdjust(pc->u.plxxs.x1);
pc->u.plxxs.x2 = XAdjust(pc->u.plxxs.x2);
pc->u.plxxs.flags = ConstantAdjust(pc->u.plxxs.flags);
pc->y_u.plxxs.p = PtoPredAdjust(pc->y_u.plxxs.p);
pc->y_u.plxxs.f = PtoOpAdjust(pc->y_u.plxxs.f);
pc->y_u.plxxs.x1 = XAdjust(pc->y_u.plxxs.x1);
pc->y_u.plxxs.x2 = XAdjust(pc->y_u.plxxs.x2);
pc->y_u.plxxs.flags = ConstantAdjust(pc->y_u.plxxs.flags);
pc = NEXTOP(pc,plxxs);
break;
/* instructions type plxys */
case _call_bfunc_xy:
case _call_bfunc_yx:
pc->u.plxys.p = PtoPredAdjust(pc->u.plxys.p);
pc->u.plxys.f = PtoOpAdjust(pc->u.plxys.f);
pc->u.plxys.x = XAdjust(pc->u.plxys.x);
pc->u.plxys.y = YAdjust(pc->u.plxys.y);
pc->u.plxys.flags = ConstantAdjust(pc->u.plxys.flags);
pc->y_u.plxys.p = PtoPredAdjust(pc->y_u.plxys.p);
pc->y_u.plxys.f = PtoOpAdjust(pc->y_u.plxys.f);
pc->y_u.plxys.x = XAdjust(pc->y_u.plxys.x);
pc->y_u.plxys.y = YAdjust(pc->y_u.plxys.y);
pc->y_u.plxys.flags = ConstantAdjust(pc->y_u.plxys.flags);
pc = NEXTOP(pc,plxys);
break;
/* instructions type plyys */
case _call_bfunc_yy:
pc->u.plyys.p = PtoPredAdjust(pc->u.plyys.p);
pc->u.plyys.f = PtoOpAdjust(pc->u.plyys.f);
pc->u.plyys.y1 = YAdjust(pc->u.plyys.y1);
pc->u.plyys.y2 = YAdjust(pc->u.plyys.y2);
pc->u.plyys.flags = ConstantAdjust(pc->u.plyys.flags);
pc->y_u.plyys.p = PtoPredAdjust(pc->y_u.plyys.p);
pc->y_u.plyys.f = PtoOpAdjust(pc->y_u.plyys.f);
pc->y_u.plyys.y1 = YAdjust(pc->y_u.plyys.y1);
pc->y_u.plyys.y2 = YAdjust(pc->y_u.plyys.y2);
pc->y_u.plyys.flags = ConstantAdjust(pc->y_u.plyys.flags);
pc = NEXTOP(pc,plyys);
break;
/* instructions type pp */
case _dexecute:
case _execute:
case _execute_cpred:
pc->u.pp.p = PtoPredAdjust(pc->u.pp.p);
pc->u.pp.p0 = PtoPredAdjust(pc->u.pp.p0);
pc->y_u.pp.p = PtoPredAdjust(pc->y_u.pp.p);
pc->y_u.pp.p0 = PtoPredAdjust(pc->y_u.pp.p0);
pc = NEXTOP(pc,pp);
break;
/* instructions type s */
@ -499,29 +499,29 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _cut_t:
case _pop_n:
case _write_n_voids:
pc->u.s.s = ConstantAdjust(pc->u.s.s);
pc->y_u.s.s = ConstantAdjust(pc->y_u.s.s);
pc = NEXTOP(pc,s);
break;
/* instructions type sc */
case _write_n_atoms:
pc->u.sc.s = ConstantAdjust(pc->u.sc.s);
pc->u.sc.c = ConstantTermAdjust(pc->u.sc.c);
pc->y_u.sc.s = ConstantAdjust(pc->y_u.sc.s);
pc->y_u.sc.c = ConstantTermAdjust(pc->y_u.sc.c);
pc = NEXTOP(pc,sc);
break;
/* instructions type sllll */
case _switch_on_sub_arg_type:
pc->u.sllll.s = ConstantAdjust(pc->u.sllll.s);
pc->u.sllll.l1 = PtoOpAdjust(pc->u.sllll.l1);
pc->u.sllll.l2 = PtoOpAdjust(pc->u.sllll.l2);
pc->u.sllll.l3 = PtoOpAdjust(pc->u.sllll.l3);
pc->u.sllll.l4 = PtoOpAdjust(pc->u.sllll.l4);
pc->y_u.sllll.s = ConstantAdjust(pc->y_u.sllll.s);
pc->y_u.sllll.l1 = PtoOpAdjust(pc->y_u.sllll.l1);
pc->y_u.sllll.l2 = PtoOpAdjust(pc->y_u.sllll.l2);
pc->y_u.sllll.l3 = PtoOpAdjust(pc->y_u.sllll.l3);
pc->y_u.sllll.l4 = PtoOpAdjust(pc->y_u.sllll.l4);
pc = NEXTOP(pc,sllll);
break;
/* instructions type slp */
case _call_c_wfail:
pc->u.slp.s = ConstantAdjust(pc->u.slp.s);
pc->u.slp.l = PtoOpAdjust(pc->u.slp.l);
pc->u.slp.p = PtoPredAdjust(pc->u.slp.p);
pc->y_u.slp.s = ConstantAdjust(pc->y_u.slp.s);
pc->y_u.slp.l = PtoOpAdjust(pc->y_u.slp.l);
pc->y_u.slp.p = PtoPredAdjust(pc->y_u.slp.p);
pc = NEXTOP(pc,slp);
break;
/* instructions type sssl */
@ -531,21 +531,21 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _if_func:
case _switch_on_cons:
case _switch_on_func:
pc->u.sssl.s = ConstantAdjust(pc->u.sssl.s);
pc->u.sssl.e = ConstantAdjust(pc->u.sssl.e);
pc->u.sssl.w = ConstantAdjust(pc->u.sssl.w);
pc->u.sssl.l = PtoOpAdjust(pc->u.sssl.l);
AdjustSwitchTable(op, pc->u.sssl.l, pc->u.sssl.s);
pc->y_u.sssl.s = ConstantAdjust(pc->y_u.sssl.s);
pc->y_u.sssl.e = ConstantAdjust(pc->y_u.sssl.e);
pc->y_u.sssl.w = ConstantAdjust(pc->y_u.sssl.w);
pc->y_u.sssl.l = PtoOpAdjust(pc->y_u.sssl.l);
AdjustSwitchTable(op, pc->y_u.sssl.l, pc->y_u.sssl.s);
pc = NEXTOP(pc,sssl);
break;
/* instructions type sssllp */
case _expand_clauses:
pc->u.sssllp.s1 = ConstantAdjust(pc->u.sssllp.s1);
pc->u.sssllp.s2 = ConstantAdjust(pc->u.sssllp.s2);
pc->u.sssllp.s3 = ConstantAdjust(pc->u.sssllp.s3);
pc->u.sssllp.sprev = PtoOpAdjust(pc->u.sssllp.sprev);
pc->u.sssllp.snext = PtoOpAdjust(pc->u.sssllp.snext);
pc->u.sssllp.p = PtoPredAdjust(pc->u.sssllp.p);
pc->y_u.sssllp.s1 = ConstantAdjust(pc->y_u.sssllp.s1);
pc->y_u.sssllp.s2 = ConstantAdjust(pc->y_u.sssllp.s2);
pc->y_u.sssllp.s3 = ConstantAdjust(pc->y_u.sssllp.s3);
pc->y_u.sssllp.sprev = PtoOpAdjust(pc->y_u.sssllp.sprev);
pc->y_u.sssllp.snext = PtoOpAdjust(pc->y_u.sssllp.snext);
pc->y_u.sssllp.p = PtoPredAdjust(pc->y_u.sssllp.p);
pc = NEXTOP(pc,sssllp);
break;
/* instructions type x */
@ -556,50 +556,50 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _write_x_loc:
case _write_x_val:
case _write_x_var:
pc->u.x.x = XAdjust(pc->u.x.x);
pc->y_u.x.x = XAdjust(pc->y_u.x.x);
pc = NEXTOP(pc,x);
break;
/* instructions type xD */
case _get_dbterm:
case _put_dbterm:
pc->u.xD.x = XAdjust(pc->u.xD.x);
pc->u.xD.D = DBGroundTermAdjust(pc->u.xD.D);
pc->y_u.xD.x = XAdjust(pc->y_u.xD.x);
pc->y_u.xD.D = DBGroundTermAdjust(pc->y_u.xD.D);
pc = NEXTOP(pc,xD);
break;
/* instructions type xN */
case _get_bigint:
case _put_bigint:
pc->u.xN.x = XAdjust(pc->u.xN.x);
pc->u.xN.b = BlobTermInCodeAdjust(pc->u.xN.b);
pc->y_u.xN.x = XAdjust(pc->y_u.xN.x);
pc->y_u.xN.b = BlobTermInCodeAdjust(pc->y_u.xN.b);
pc = NEXTOP(pc,xN);
break;
/* instructions type xc */
case _get_atom:
case _put_atom:
pc->u.xc.x = XAdjust(pc->u.xc.x);
pc->u.xc.c = ConstantTermAdjust(pc->u.xc.c);
pc->y_u.xc.x = XAdjust(pc->y_u.xc.x);
pc->y_u.xc.c = ConstantTermAdjust(pc->y_u.xc.c);
pc = NEXTOP(pc,xc);
break;
/* instructions type xd */
case _get_float:
case _put_float:
pc->u.xd.x = XAdjust(pc->u.xd.x);
DoubleInCodeAdjust(pc->u.xd.d);
pc->y_u.xd.x = XAdjust(pc->y_u.xd.x);
DoubleInCodeAdjust(pc->y_u.xd.d);
pc = NEXTOP(pc,xd);
break;
/* instructions type xfa */
case _get_struct:
case _put_struct:
pc->u.xfa.x = XAdjust(pc->u.xfa.x);
pc->u.xfa.f = FuncAdjust(pc->u.xfa.f);
pc->u.xfa.a = ArityAdjust(pc->u.xfa.a);
pc->y_u.xfa.x = XAdjust(pc->y_u.xfa.x);
pc->y_u.xfa.f = FuncAdjust(pc->y_u.xfa.f);
pc->y_u.xfa.a = ArityAdjust(pc->y_u.xfa.a);
pc = NEXTOP(pc,xfa);
break;
/* instructions type xi */
case _get_longint:
case _put_longint:
pc->u.xi.x = XAdjust(pc->u.xi.x);
IntegerInCodeAdjust(pc->u.xi.i);
pc->y_u.xi.x = XAdjust(pc->y_u.xi.x);
IntegerInCodeAdjust(pc->y_u.xi.i);
pc = NEXTOP(pc,xi);
break;
/* instructions type xl */
@ -613,37 +613,37 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _p_number_x:
case _p_primitive_x:
case _p_var_x:
pc->u.xl.x = XAdjust(pc->u.xl.x);
pc->u.xl.F = PtoOpAdjust(pc->u.xl.F);
pc->y_u.xl.x = XAdjust(pc->y_u.xl.x);
pc->y_u.xl.F = PtoOpAdjust(pc->y_u.xl.F);
pc = NEXTOP(pc,xl);
break;
/* instructions type xll */
case _jump_if_nonvar:
pc->u.xll.x = XAdjust(pc->u.xll.x);
pc->u.xll.l1 = PtoOpAdjust(pc->u.xll.l1);
pc->u.xll.l2 = PtoOpAdjust(pc->u.xll.l2);
pc->y_u.xll.x = XAdjust(pc->y_u.xll.x);
pc->y_u.xll.l1 = PtoOpAdjust(pc->y_u.xll.l1);
pc->y_u.xll.l2 = PtoOpAdjust(pc->y_u.xll.l2);
pc = NEXTOP(pc,xll);
break;
/* instructions type xllll */
case _switch_on_arg_type:
pc->u.xllll.x = XAdjust(pc->u.xllll.x);
pc->u.xllll.l1 = PtoOpAdjust(pc->u.xllll.l1);
pc->u.xllll.l2 = PtoOpAdjust(pc->u.xllll.l2);
pc->u.xllll.l3 = PtoOpAdjust(pc->u.xllll.l3);
pc->u.xllll.l4 = PtoOpAdjust(pc->u.xllll.l4);
pc->y_u.xllll.x = XAdjust(pc->y_u.xllll.x);
pc->y_u.xllll.l1 = PtoOpAdjust(pc->y_u.xllll.l1);
pc->y_u.xllll.l2 = PtoOpAdjust(pc->y_u.xllll.l2);
pc->y_u.xllll.l3 = PtoOpAdjust(pc->y_u.xllll.l3);
pc->y_u.xllll.l4 = PtoOpAdjust(pc->y_u.xllll.l4);
pc = NEXTOP(pc,xllll);
break;
/* instructions type xps */
case _commit_b_x:
pc->u.xps.x = XAdjust(pc->u.xps.x);
pc->u.xps.p0 = PtoPredAdjust(pc->u.xps.p0);
pc->u.xps.s = ConstantAdjust(pc->u.xps.s);
pc->y_u.xps.x = XAdjust(pc->y_u.xps.x);
pc->y_u.xps.p0 = PtoPredAdjust(pc->y_u.xps.p0);
pc->y_u.xps.s = ConstantAdjust(pc->y_u.xps.s);
pc = NEXTOP(pc,xps);
break;
/* instructions type xu */
case _get_string:
pc->u.xu.x = XAdjust(pc->u.xu.x);
pc->u.xu.ut = BlobTermInCodeAdjust(pc->u.xu.ut);
pc->y_u.xu.x = XAdjust(pc->y_u.xu.x);
pc->y_u.xu.ut = BlobTermInCodeAdjust(pc->y_u.xu.ut);
pc = NEXTOP(pc,xu);
break;
/* instructions type xx */
@ -654,15 +654,15 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _glist_valx:
case _put_x_val:
case _put_x_var:
pc->u.xx.xl = XAdjust(pc->u.xx.xl);
pc->u.xx.xr = XAdjust(pc->u.xx.xr);
pc->y_u.xx.xl = XAdjust(pc->y_u.xx.xl);
pc->y_u.xx.xr = XAdjust(pc->y_u.xx.xr);
pc = NEXTOP(pc,xx);
break;
/* instructions type xxc */
case _p_func2s_cv:
pc->u.xxc.x = XAdjust(pc->u.xxc.x);
pc->u.xxc.xi = XAdjust(pc->u.xxc.xi);
pc->u.xxc.c = ConstantTermAdjust(pc->u.xxc.c);
pc->y_u.xxc.x = XAdjust(pc->y_u.xxc.x);
pc->y_u.xxc.xi = XAdjust(pc->y_u.xxc.xi);
pc->y_u.xxc.c = ConstantTermAdjust(pc->y_u.xxc.c);
pc = NEXTOP(pc,xxc);
break;
/* instructions type xxn */
@ -679,9 +679,9 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _p_slr_cv:
case _p_slr_vc:
case _p_times_vc:
pc->u.xxn.x = XAdjust(pc->u.xxn.x);
pc->u.xxn.xi = XAdjust(pc->u.xxn.xi);
pc->u.xxn.c = IntegerAdjust(pc->u.xxn.c);
pc->y_u.xxn.x = XAdjust(pc->y_u.xxn.x);
pc->y_u.xxn.xi = XAdjust(pc->y_u.xxn.xi);
pc->y_u.xxn.c = IntegerAdjust(pc->y_u.xxn.c);
pc = NEXTOP(pc,xxn);
break;
/* instructions type xxx */
@ -696,24 +696,24 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _p_sll_vv:
case _p_slr_vv:
case _p_times_vv:
pc->u.xxx.x = XAdjust(pc->u.xxx.x);
pc->u.xxx.x1 = XAdjust(pc->u.xxx.x1);
pc->u.xxx.x2 = XAdjust(pc->u.xxx.x2);
pc->y_u.xxx.x = XAdjust(pc->y_u.xxx.x);
pc->y_u.xxx.x1 = XAdjust(pc->y_u.xxx.x1);
pc->y_u.xxx.x2 = XAdjust(pc->y_u.xxx.x2);
pc = NEXTOP(pc,xxx);
break;
/* instructions type xxxx */
case _put_xx_val:
pc->u.xxxx.xl1 = XAdjust(pc->u.xxxx.xl1);
pc->u.xxxx.xl2 = XAdjust(pc->u.xxxx.xl2);
pc->u.xxxx.xr1 = XAdjust(pc->u.xxxx.xr1);
pc->u.xxxx.xr2 = XAdjust(pc->u.xxxx.xr2);
pc->y_u.xxxx.xl1 = XAdjust(pc->y_u.xxxx.xl1);
pc->y_u.xxxx.xl2 = XAdjust(pc->y_u.xxxx.xl2);
pc->y_u.xxxx.xr1 = XAdjust(pc->y_u.xxxx.xr1);
pc->y_u.xxxx.xr2 = XAdjust(pc->y_u.xxxx.xr2);
pc = NEXTOP(pc,xxxx);
break;
/* instructions type xxy */
case _p_func2f_xy:
pc->u.xxy.x = XAdjust(pc->u.xxy.x);
pc->u.xxy.x1 = XAdjust(pc->u.xxy.x1);
pc->u.xxy.y2 = YAdjust(pc->u.xxy.y2);
pc->y_u.xxy.x = XAdjust(pc->y_u.xxy.x);
pc->y_u.xxy.x1 = XAdjust(pc->y_u.xxy.x1);
pc->y_u.xxy.y2 = YAdjust(pc->y_u.xxy.y2);
pc = NEXTOP(pc,xxy);
break;
/* instructions type y */
@ -721,7 +721,7 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _write_y_loc:
case _write_y_val:
case _write_y_var:
pc->u.y.y = YAdjust(pc->u.y.y);
pc->y_u.y.y = YAdjust(pc->y_u.y.y);
pc = NEXTOP(pc,y);
break;
/* instructions type yl */
@ -735,15 +735,15 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _p_number_y:
case _p_primitive_y:
case _p_var_y:
pc->u.yl.y = YAdjust(pc->u.yl.y);
pc->u.yl.F = PtoOpAdjust(pc->u.yl.F);
pc->y_u.yl.y = YAdjust(pc->y_u.yl.y);
pc->y_u.yl.F = PtoOpAdjust(pc->y_u.yl.F);
pc = NEXTOP(pc,yl);
break;
/* instructions type yps */
case _commit_b_y:
pc->u.yps.y = YAdjust(pc->u.yps.y);
pc->u.yps.p0 = PtoPredAdjust(pc->u.yps.p0);
pc->u.yps.s = ConstantAdjust(pc->u.yps.s);
pc->y_u.yps.y = YAdjust(pc->y_u.yps.y);
pc->y_u.yps.p0 = PtoPredAdjust(pc->y_u.yps.p0);
pc->y_u.yps.s = ConstantAdjust(pc->y_u.yps.s);
pc = NEXTOP(pc,yps);
break;
/* instructions type yx */
@ -755,15 +755,15 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _put_unsafe:
case _put_y_val:
case _put_y_var:
pc->u.yx.y = YAdjust(pc->u.yx.y);
pc->u.yx.x = XAdjust(pc->u.yx.x);
pc->y_u.yx.y = YAdjust(pc->y_u.yx.y);
pc->y_u.yx.x = XAdjust(pc->y_u.yx.x);
pc = NEXTOP(pc,yx);
break;
/* instructions type yxc */
case _p_func2s_y_cv:
pc->u.yxc.y = YAdjust(pc->u.yxc.y);
pc->u.yxc.xi = XAdjust(pc->u.yxc.xi);
pc->u.yxc.c = ConstantTermAdjust(pc->u.yxc.c);
pc->y_u.yxc.y = YAdjust(pc->y_u.yxc.y);
pc->y_u.yxc.xi = XAdjust(pc->y_u.yxc.xi);
pc->y_u.yxc.c = ConstantTermAdjust(pc->y_u.yxc.c);
pc = NEXTOP(pc,yxc);
break;
/* instructions type yxn */
@ -780,9 +780,9 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _p_slr_y_cv:
case _p_slr_y_vc:
case _p_times_y_vc:
pc->u.yxn.y = YAdjust(pc->u.yxn.y);
pc->u.yxn.xi = XAdjust(pc->u.yxn.xi);
pc->u.yxn.c = IntegerAdjust(pc->u.yxn.c);
pc->y_u.yxn.y = YAdjust(pc->y_u.yxn.y);
pc->y_u.yxn.xi = XAdjust(pc->y_u.yxn.xi);
pc->y_u.yxn.c = IntegerAdjust(pc->y_u.yxn.c);
pc = NEXTOP(pc,yxn);
break;
/* instructions type yxx */
@ -797,25 +797,25 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _p_sll_y_vv:
case _p_slr_y_vv:
case _p_times_y_vv:
pc->u.yxx.y = YAdjust(pc->u.yxx.y);
pc->u.yxx.x1 = XAdjust(pc->u.yxx.x1);
pc->u.yxx.x2 = XAdjust(pc->u.yxx.x2);
pc->y_u.yxx.y = YAdjust(pc->y_u.yxx.y);
pc->y_u.yxx.x1 = XAdjust(pc->y_u.yxx.x1);
pc->y_u.yxx.x2 = XAdjust(pc->y_u.yxx.x2);
pc = NEXTOP(pc,yxx);
break;
/* instructions type yyx */
case _p_func2f_yy:
pc->u.yyx.y1 = YAdjust(pc->u.yyx.y1);
pc->u.yyx.y2 = YAdjust(pc->u.yyx.y2);
pc->u.yyx.x = XAdjust(pc->u.yyx.x);
pc->y_u.yyx.y1 = YAdjust(pc->y_u.yyx.y1);
pc->y_u.yyx.y2 = YAdjust(pc->y_u.yyx.y2);
pc->y_u.yyx.x = XAdjust(pc->y_u.yyx.x);
pc = NEXTOP(pc,yyx);
break;
/* instructions type yyxx */
case _get_yy_var:
case _put_y_vals:
pc->u.yyxx.y1 = YAdjust(pc->u.yyxx.y1);
pc->u.yyxx.y2 = YAdjust(pc->u.yyxx.y2);
pc->u.yyxx.x1 = XAdjust(pc->u.yyxx.x1);
pc->u.yyxx.x2 = XAdjust(pc->u.yyxx.x2);
pc->y_u.yyxx.y1 = YAdjust(pc->y_u.yyxx.y1);
pc->y_u.yyxx.y2 = YAdjust(pc->y_u.yyxx.y2);
pc->y_u.yyxx.x1 = XAdjust(pc->y_u.yyxx.x1);
pc->y_u.yyxx.x2 = XAdjust(pc->y_u.yyxx.x2);
pc = NEXTOP(pc,yyxx);
break;
#ifdef YAPOR
@ -823,11 +823,11 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _getwork:
case _getwork_seq:
case _sync:
OrArgAdjust(pc->u.Otapl.or_arg);
TabEntryAdjust(pc->u.Otapl.te);
pc->u.Otapl.s = ArityAdjust(pc->u.Otapl.s);
pc->u.Otapl.p = PtoPredAdjust(pc->u.Otapl.p);
pc->u.Otapl.d = PtoOpAdjust(pc->u.Otapl.d);
OrArgAdjust(pc->y_u.Otapl.or_arg);
TabEntryAdjust(pc->y_u.Otapl.te);
pc->y_u.Otapl.s = ArityAdjust(pc->y_u.Otapl.s);
pc->y_u.Otapl.p = PtoPredAdjust(pc->y_u.Otapl.p);
pc->y_u.Otapl.d = PtoOpAdjust(pc->y_u.Otapl.d);
pc = NEXTOP(pc,Otapl);
break;
/* instructions type e */
@ -852,11 +852,11 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _table_try_answer:
case _table_try_me:
case _table_try_single:
OrArgAdjust(pc->u.Otapl.or_arg);
TabEntryAdjust(pc->u.Otapl.te);
pc->u.Otapl.s = ArityAdjust(pc->u.Otapl.s);
pc->u.Otapl.p = PtoPredAdjust(pc->u.Otapl.p);
pc->u.Otapl.d = PtoOpAdjust(pc->u.Otapl.d);
OrArgAdjust(pc->y_u.Otapl.or_arg);
TabEntryAdjust(pc->y_u.Otapl.te);
pc->y_u.Otapl.s = ArityAdjust(pc->y_u.Otapl.s);
pc->y_u.Otapl.p = PtoPredAdjust(pc->y_u.Otapl.p);
pc->y_u.Otapl.d = PtoOpAdjust(pc->y_u.Otapl.d);
pc = NEXTOP(pc,Otapl);
break;
/* instructions type e */
@ -868,7 +868,7 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
break;
/* instructions type s */
case _table_new_answer:
pc->u.s.s = ConstantAdjust(pc->u.s.s);
pc->y_u.s.s = ConstantAdjust(pc->y_u.s.s);
pc = NEXTOP(pc,s);
break;
/* instructions type e */
@ -943,15 +943,15 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
/* this instruction is hardwired */
case _or_last:
#ifdef YAPOR
OrArgAdjust(pc->u.Osblp.or_arg);
pc->u.Osblp.s = ConstantAdjust(pc->u.Osblp.s);
pc->u.Osblp.bmap = CellPtoHeapAdjust(pc->u.Osblp.bmap);
pc->u.Osblp.l = PtoOpAdjust(pc->u.Osblp.l);
pc->u.Osblp.p0 = PtoPredAdjust(pc->u.Osblp.p0);
OrArgAdjust(pc->y_u.Osblp.or_arg);
pc->y_u.Osblp.s = ConstantAdjust(pc->y_u.Osblp.s);
pc->y_u.Osblp.bmap = CellPtoHeapAdjust(pc->y_u.Osblp.bmap);
pc->y_u.Osblp.l = PtoOpAdjust(pc->y_u.Osblp.l);
pc->y_u.Osblp.p0 = PtoPredAdjust(pc->y_u.Osblp.p0);
pc = NEXTOP(pc,Osblp);
break;
#else
pc->u.p.p = PtoPredAdjust(pc->u.p.p);
pc->y_u.p.p = PtoPredAdjust(pc->y_u.p.p);
pc = NEXTOP(pc,p);
break;
#endif

View File

@ -1,119 +1,123 @@
/* This file, rglobals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update misc/GLOBALS instead */
static void RestoreGlobal(void) {
#if THREADS
REINIT_LOCK(GLOBAL_ThreadHandlesLock);
#endif
#if defined(YAPOR) || defined(THREADS)
REINIT_LOCK(GLOBAL_BGL);
#endif
#if defined(YAPOR) || defined(TABLING)
#endif /* YAPOR || TABLING */
#if defined(THREADS)
#endif /* THREADS */
#ifdef COROUTINING
#endif
#if HAVE_MMAP
#endif
#ifdef DEBUG
#endif
#if defined(COFF) || defined(A_OUT)
#endif
#if __simplescalar__
#endif
#if LOW_PROF
#endif /* LOW_PROF */
}
/* This file, rglobals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update misc/GLOBALS instead */
static void RestoreGlobal(void) {
#if __ANDROID__
#endif
#if THREADS
REINIT_LOCK(GLOBAL_ThreadHandlesLock);
#endif
#if defined(YAPOR) || defined(THREADS)
REINIT_LOCK(GLOBAL_BGL);
#endif
#if defined(YAPOR) || defined(TABLING)
#endif /* YAPOR || TABLING */
#if defined(THREADS)
#endif /* THREADS */
#ifdef COROUTINING
#endif
#if HAVE_MMAP
#endif
#ifdef DEBUG
#endif
#if defined(COFF) || defined(A_OUT)
#endif
#if __simplescalar__
#endif
#if LOW_PROF
#endif /* LOW_PROF */
}

View File

@ -294,14 +294,14 @@ do_clean_susp_clauses(yamop *ipc USES_REGS) {
yamop **st = (yamop **)NEXTOP(ipc,sssllp);
ipc->opc = Yap_opcode(_expand_clauses);
ipc->u.sssllp.p = PtoPredAdjust(ipc->u.sssllp.p);
if (ipc->u.sssllp.sprev) {
ipc->u.sssllp.sprev = PtoOpAdjust(ipc->u.sssllp.sprev);
ipc->y_u.sssllp.p = PtoPredAdjust(ipc->y_u.sssllp.p);
if (ipc->y_u.sssllp.sprev) {
ipc->y_u.sssllp.sprev = PtoOpAdjust(ipc->y_u.sssllp.sprev);
}
if (ipc->u.sssllp.snext) {
ipc->u.sssllp.snext = PtoOpAdjust(ipc->u.sssllp.snext);
if (ipc->y_u.sssllp.snext) {
ipc->y_u.sssllp.snext = PtoOpAdjust(ipc->y_u.sssllp.snext);
}
for (i = 0; i < ipc->u.sssllp.s1; i++, st++) {
for (i = 0; i < ipc->y_u.sssllp.s1; i++, st++) {
if (*st) {
*st = PtoOpAdjust(*st);
}
@ -766,10 +766,10 @@ RestoreEnvInst(yamop start[2], yamop **instp, op_numbers opc, PredEntry *pred)
yamop *ipc = start;
ipc->opc = Yap_opcode(_call);
ipc->u.Osbpp.p = pred;
ipc->u.Osbpp.p0 = pred;
ipc->u.Osbpp.bmap = NULL;
ipc->u.Osbpp.s = -Signed(RealEnvSize);
ipc->y_u.Osbpp.p = pred;
ipc->y_u.Osbpp.p0 = pred;
ipc->y_u.Osbpp.bmap = NULL;
ipc->y_u.Osbpp.s = -Signed(RealEnvSize);
ipc = NEXTOP(ipc, Osbpp);
ipc->opc = Yap_opcode(opc);
*instp = ipc;
@ -782,15 +782,15 @@ RestoreOtaplInst__(yamop start[1], OPCODE opc, PredEntry *pe USES_REGS)
/* this is a place holder, it should not really be used */
ipc->opc = Yap_opcode(opc);
ipc->u.Otapl.s = 0;
ipc->u.Otapl.p = pe;
if (ipc->u.Otapl.d)
ipc->u.Otapl.d = PtoOpAdjust(ipc->u.Otapl.d);
ipc->y_u.Otapl.s = 0;
ipc->y_u.Otapl.p = pe;
if (ipc->y_u.Otapl.d)
ipc->y_u.Otapl.d = PtoOpAdjust(ipc->y_u.Otapl.d);
#ifdef YAPOR
INIT_YAMOP_LTT(ipc, 1);
#endif /* YAPOR */
#ifdef TABLING
ipc->u.Otapl.te = NULL;
ipc->y_u.Otapl.te = NULL;
#endif /* TABLING */
}
@ -818,7 +818,7 @@ RestoreExpandList__( USES_REGS1 )
yamop *ptr = Yap_heap_regs->expand_clauses_first;
while (ptr) {
do_clean_susp_clauses(ptr PASS_REGS);
ptr = ptr->u.sssllp.snext;
ptr = ptr->y_u.sssllp.snext;
}
}
}

View File

@ -1,242 +1,247 @@
/* This file, rlocals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update misc/LOCALS instead */
static void RestoreWorker(int wid USES_REGS) {
REMOTE_GlobalArena(wid) = TermToGlobalOrAtomAdjust(REMOTE_GlobalArena(wid));
RestoreBallTerm(wid);
#ifdef COROUTINING
REMOTE_WokenGoals(wid) = TermToGlobalAdjust(REMOTE_WokenGoals(wid));
REMOTE_AttsMutableList(wid) = TermToGlobalAdjust(REMOTE_AttsMutableList(wid));
#endif
REMOTE_GcGeneration(wid) = TermToGlobalAdjust(REMOTE_GcGeneration(wid));
REMOTE_GcPhase(wid) = TermToGlobalAdjust(REMOTE_GcPhase(wid));
#if defined(GC_NO_TAGS)
#endif
REMOTE_DynamicArrays(wid) = PtoArrayEAdjust(REMOTE_DynamicArrays(wid));
REMOTE_StaticArrays(wid) = PtoArraySAdjust(REMOTE_StaticArrays(wid));
REMOTE_GlobalVariables(wid) = PtoGlobalEAdjust(REMOTE_GlobalVariables(wid));
#ifdef THREADS
#endif /* THREADS */
#if defined(YAPOR) || defined(TABLING)
#endif /* YAPOR || TABLING */
#if LOW_LEVEL_TRACER
#endif
#if defined(YAPOR) || defined(THREADS)
REINIT_LOCK(REMOTE_SignalLock(wid));
#endif
#ifdef THREADS
#else
#endif
#ifdef ANALYST
#endif /* ANALYST */
#ifdef LOAD_DYLD
#endif
#ifdef LOW_LEVEL_TRACER
#endif
}
/* This file, rlocals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update misc/LOCALS instead */
static void RestoreWorker(int wid USES_REGS) {
REMOTE_GlobalArena(wid) = TermToGlobalOrAtomAdjust(REMOTE_GlobalArena(wid));
RestoreBallTerm(wid);
#ifdef COROUTINING
REMOTE_WokenGoals(wid) = TermToGlobalAdjust(REMOTE_WokenGoals(wid));
REMOTE_AttsMutableList(wid) = TermToGlobalAdjust(REMOTE_AttsMutableList(wid));
#endif
REMOTE_GcGeneration(wid) = TermToGlobalAdjust(REMOTE_GcGeneration(wid));
REMOTE_GcPhase(wid) = TermToGlobalAdjust(REMOTE_GcPhase(wid));
#if defined(GC_NO_TAGS)
#endif
REMOTE_DynamicArrays(wid) = PtoArrayEAdjust(REMOTE_DynamicArrays(wid));
REMOTE_StaticArrays(wid) = PtoArraySAdjust(REMOTE_StaticArrays(wid));
REMOTE_GlobalVariables(wid) = PtoGlobalEAdjust(REMOTE_GlobalVariables(wid));
#ifdef THREADS
#endif /* THREADS */
#if defined(YAPOR) || defined(TABLING)
#endif /* YAPOR || TABLING */
#if LOW_LEVEL_TRACER
#endif
#if defined(YAPOR) || defined(THREADS)
REINIT_LOCK(REMOTE_SignalLock(wid));
#endif
#ifdef THREADS
#else
#endif
#ifdef ANALYST
#endif /* ANALYST */
#ifdef LOAD_DYLD
#endif
#ifdef LOW_LEVEL_TRACER
#endif
#if __ANDROID__
#endif
}

View File

@ -13,61 +13,61 @@
switch (op) {
/* instructions type D */
case _write_dbterm:
CHECK(save_DBGroundTerm(stream, pc->u.D.D));
CHECK(save_DBGroundTerm(stream, pc->y_u.D.D));
pc = NEXTOP(pc,D);
break;
/* instructions type Illss */
case _enter_lu_pred:
CHECK(save_PtoLUIndex(stream, pc->u.Illss.I));
CHECK(save_PtoOp(stream, pc->u.Illss.l1));
CHECK(save_PtoOp(stream, pc->u.Illss.l2));
CHECK(save_Constant(stream, pc->u.Illss.s));
CHECK(save_Constant(stream, pc->u.Illss.e));
CHECK(save_PtoLUIndex(stream, pc->y_u.Illss.I));
CHECK(save_PtoOp(stream, pc->y_u.Illss.l1));
CHECK(save_PtoOp(stream, pc->y_u.Illss.l2));
CHECK(save_Constant(stream, pc->y_u.Illss.s));
CHECK(save_Constant(stream, pc->y_u.Illss.e));
pc = NEXTOP(pc,Illss);
break;
/* instructions type L */
case _alloc_for_logical_pred:
CHECK(save_PtoLUClause(stream, pc->u.L.ClBase));
CHECK(save_PtoLUClause(stream, pc->y_u.L.ClBase));
pc = NEXTOP(pc,L);
break;
/* instructions type N */
case _write_bigint:
CHECK(save_BlobTermInCode(stream, pc->u.N.b));
CHECK(save_BlobTermInCode(stream, pc->y_u.N.b));
pc = NEXTOP(pc,N);
break;
/* instructions type Osblp */
case _either:
case _or_else:
#ifdef YAPOR
CHECK(save_OrArg(stream, pc->u.Osblp.or_arg));
CHECK(save_OrArg(stream, pc->y_u.Osblp.or_arg));
#endif
CHECK(save_Constant(stream, pc->u.Osblp.s));
CHECK(save_CellPtoHeap(stream, pc->u.Osblp.bmap));
CHECK(save_PtoOp(stream, pc->u.Osblp.l));
CHECK(save_PtoPred(stream, pc->u.Osblp.p0));
CHECK(save_Constant(stream, pc->y_u.Osblp.s));
CHECK(save_CellPtoHeap(stream, pc->y_u.Osblp.bmap));
CHECK(save_PtoOp(stream, pc->y_u.Osblp.l));
CHECK(save_PtoPred(stream, pc->y_u.Osblp.p0));
pc = NEXTOP(pc,Osblp);
break;
/* instructions type Osbmp */
case _p_execute:
case _p_execute_tail:
#ifdef YAPOR
CHECK(save_OrArg(stream, pc->u.Osbmp.or_arg));
CHECK(save_OrArg(stream, pc->y_u.Osbmp.or_arg));
#endif
CHECK(save_Constant(stream, pc->u.Osbmp.s));
CHECK(save_CellPtoHeap(stream, pc->u.Osbmp.bmap));
CHECK(save_Module(stream, pc->u.Osbmp.mod));
CHECK(save_PtoPred(stream, pc->u.Osbmp.p0));
CHECK(save_Constant(stream, pc->y_u.Osbmp.s));
CHECK(save_CellPtoHeap(stream, pc->y_u.Osbmp.bmap));
CHECK(save_Module(stream, pc->y_u.Osbmp.mod));
CHECK(save_PtoPred(stream, pc->y_u.Osbmp.p0));
pc = NEXTOP(pc,Osbmp);
break;
/* instructions type Osbpa */
case _ensure_space:
#ifdef YAPOR
CHECK(save_OrArg(stream, pc->u.Osbpa.or_arg));
CHECK(save_OrArg(stream, pc->y_u.Osbpa.or_arg));
#endif
CHECK(save_Constant(stream, pc->u.Osbpa.s));
CHECK(save_CellPtoHeap(stream, pc->u.Osbpa.bmap));
CHECK(save_PtoPred(stream, pc->u.Osbpa.p));
CHECK(save_Arity(stream, pc->u.Osbpa.i));
CHECK(save_Constant(stream, pc->y_u.Osbpa.s));
CHECK(save_CellPtoHeap(stream, pc->y_u.Osbpa.bmap));
CHECK(save_PtoPred(stream, pc->y_u.Osbpa.p));
CHECK(save_Arity(stream, pc->y_u.Osbpa.i));
pc = NEXTOP(pc,Osbpa);
break;
/* instructions type Osbpp */
@ -77,12 +77,12 @@
case _fcall:
case _p_execute2:
#ifdef YAPOR
CHECK(save_OrArg(stream, pc->u.Osbpp.or_arg));
CHECK(save_OrArg(stream, pc->y_u.Osbpp.or_arg));
#endif
CHECK(save_Constant(stream, pc->u.Osbpp.s));
CHECK(save_CellPtoHeap(stream, pc->u.Osbpp.bmap));
CHECK(save_PtoPred(stream, pc->u.Osbpp.p));
CHECK(save_PtoPred(stream, pc->u.Osbpp.p0));
CHECK(save_Constant(stream, pc->y_u.Osbpp.s));
CHECK(save_CellPtoHeap(stream, pc->y_u.Osbpp.bmap));
CHECK(save_PtoPred(stream, pc->y_u.Osbpp.p));
CHECK(save_PtoPred(stream, pc->y_u.Osbpp.p0));
pc = NEXTOP(pc,Osbpp);
break;
/* instructions type OtILl */
@ -90,14 +90,14 @@
case _profiled_trust_logical:
case _trust_logical:
#ifdef YAPOR
CHECK(save_OrArg(stream, pc->u.OtILl.or_arg));
CHECK(save_OrArg(stream, pc->y_u.OtILl.or_arg));
#endif
#ifdef TABLING
CHECK(save_TabEntry(stream, pc->u.OtILl.te));
CHECK(save_TabEntry(stream, pc->y_u.OtILl.te));
#endif
CHECK(save_PtoLUIndex(stream, pc->u.OtILl.block));
CHECK(save_PtoLUClause(stream, pc->u.OtILl.d));
CHECK(save_PtoOp(stream, pc->u.OtILl.n));
CHECK(save_PtoLUIndex(stream, pc->y_u.OtILl.block));
CHECK(save_PtoLUClause(stream, pc->y_u.OtILl.d));
CHECK(save_PtoOp(stream, pc->y_u.OtILl.n));
pc = NEXTOP(pc,OtILl);
break;
/* instructions type OtaLl */
@ -106,14 +106,14 @@
case _retry_logical:
case _try_logical:
#ifdef YAPOR
CHECK(save_OrArg(stream, pc->u.OtaLl.or_arg));
CHECK(save_OrArg(stream, pc->y_u.OtaLl.or_arg));
#endif
#ifdef TABLING
CHECK(save_TabEntry(stream, pc->u.OtaLl.te));
CHECK(save_TabEntry(stream, pc->y_u.OtaLl.te));
#endif
CHECK(save_Arity(stream, pc->u.OtaLl.s));
CHECK(save_PtoLUClause(stream, pc->u.OtaLl.d));
CHECK(save_PtoOp(stream, pc->u.OtaLl.n));
CHECK(save_Arity(stream, pc->y_u.OtaLl.s));
CHECK(save_PtoLUClause(stream, pc->y_u.OtaLl.d));
CHECK(save_PtoOp(stream, pc->y_u.OtaLl.n));
pc = NEXTOP(pc,OtaLl);
break;
/* instructions type OtapFs */
@ -124,15 +124,15 @@
case _try_c:
case _try_userc:
#ifdef YAPOR
CHECK(save_OrArg(stream, pc->u.OtapFs.or_arg));
CHECK(save_OrArg(stream, pc->y_u.OtapFs.or_arg));
#endif
#ifdef TABLING
CHECK(save_TabEntry(stream, pc->u.OtapFs.te));
CHECK(save_TabEntry(stream, pc->y_u.OtapFs.te));
#endif
CHECK(save_Arity(stream, pc->u.OtapFs.s));
CHECK(save_PtoPred(stream, pc->u.OtapFs.p));
CHECK(save_ExternalFunction(stream, pc->u.OtapFs.f));
CHECK(save_Constant(stream, pc->u.OtapFs.extra));
CHECK(save_Arity(stream, pc->y_u.OtapFs.s));
CHECK(save_PtoPred(stream, pc->y_u.OtapFs.p));
CHECK(save_ExternalFunction(stream, pc->y_u.OtapFs.f));
CHECK(save_Constant(stream, pc->y_u.OtapFs.extra));
pc = NEXTOP(pc,OtapFs);
break;
/* instructions type Otapl */
@ -152,80 +152,80 @@
case _try_clause:
case _try_me:
#ifdef YAPOR
CHECK(save_OrArg(stream, pc->u.Otapl.or_arg));
CHECK(save_OrArg(stream, pc->y_u.Otapl.or_arg));
#endif
#ifdef TABLING
CHECK(save_TabEntry(stream, pc->u.Otapl.te));
CHECK(save_TabEntry(stream, pc->y_u.Otapl.te));
#endif
CHECK(save_Arity(stream, pc->u.Otapl.s));
CHECK(save_PtoPred(stream, pc->u.Otapl.p));
CHECK(save_PtoOp(stream, pc->u.Otapl.d));
CHECK(save_Arity(stream, pc->y_u.Otapl.s));
CHECK(save_PtoPred(stream, pc->y_u.Otapl.p));
CHECK(save_PtoOp(stream, pc->y_u.Otapl.d));
pc = NEXTOP(pc,Otapl);
break;
/* instructions type aFlp */
case _native_me:
CHECK(save_Arity(stream, pc->u.aFlp.n));
CHECK(save_ExternalFunction(stream, pc->u.aFlp.native));
CHECK(save_PtoOp(stream, pc->u.aFlp.native_next));
CHECK(save_PtoPred(stream, pc->u.aFlp.p));
CHECK(save_Arity(stream, pc->y_u.aFlp.n));
CHECK(save_ExternalFunction(stream, pc->y_u.aFlp.native));
CHECK(save_PtoOp(stream, pc->y_u.aFlp.native_next));
CHECK(save_PtoPred(stream, pc->y_u.aFlp.p));
pc = NEXTOP(pc,aFlp);
break;
/* instructions type c */
case _write_atom:
CHECK(save_ConstantTerm(stream, pc->u.c.c));
CHECK(save_ConstantTerm(stream, pc->y_u.c.c));
pc = NEXTOP(pc,c);
break;
/* instructions type cc */
case _get_2atoms:
CHECK(save_ConstantTerm(stream, pc->u.cc.c1));
CHECK(save_ConstantTerm(stream, pc->u.cc.c2));
CHECK(save_ConstantTerm(stream, pc->y_u.cc.c1));
CHECK(save_ConstantTerm(stream, pc->y_u.cc.c2));
pc = NEXTOP(pc,cc);
break;
/* instructions type ccc */
case _get_3atoms:
CHECK(save_ConstantTerm(stream, pc->u.ccc.c1));
CHECK(save_ConstantTerm(stream, pc->u.ccc.c2));
CHECK(save_ConstantTerm(stream, pc->u.ccc.c3));
CHECK(save_ConstantTerm(stream, pc->y_u.ccc.c1));
CHECK(save_ConstantTerm(stream, pc->y_u.ccc.c2));
CHECK(save_ConstantTerm(stream, pc->y_u.ccc.c3));
pc = NEXTOP(pc,ccc);
break;
/* instructions type cccc */
case _get_4atoms:
CHECK(save_ConstantTerm(stream, pc->u.cccc.c1));
CHECK(save_ConstantTerm(stream, pc->u.cccc.c2));
CHECK(save_ConstantTerm(stream, pc->u.cccc.c3));
CHECK(save_ConstantTerm(stream, pc->u.cccc.c4));
CHECK(save_ConstantTerm(stream, pc->y_u.cccc.c1));
CHECK(save_ConstantTerm(stream, pc->y_u.cccc.c2));
CHECK(save_ConstantTerm(stream, pc->y_u.cccc.c3));
CHECK(save_ConstantTerm(stream, pc->y_u.cccc.c4));
pc = NEXTOP(pc,cccc);
break;
/* instructions type ccccc */
case _get_5atoms:
CHECK(save_ConstantTerm(stream, pc->u.ccccc.c1));
CHECK(save_ConstantTerm(stream, pc->u.ccccc.c2));
CHECK(save_ConstantTerm(stream, pc->u.ccccc.c3));
CHECK(save_ConstantTerm(stream, pc->u.ccccc.c4));
CHECK(save_ConstantTerm(stream, pc->u.ccccc.c5));
CHECK(save_ConstantTerm(stream, pc->y_u.ccccc.c1));
CHECK(save_ConstantTerm(stream, pc->y_u.ccccc.c2));
CHECK(save_ConstantTerm(stream, pc->y_u.ccccc.c3));
CHECK(save_ConstantTerm(stream, pc->y_u.ccccc.c4));
CHECK(save_ConstantTerm(stream, pc->y_u.ccccc.c5));
pc = NEXTOP(pc,ccccc);
break;
/* instructions type cccccc */
case _get_6atoms:
CHECK(save_ConstantTerm(stream, pc->u.cccccc.c1));
CHECK(save_ConstantTerm(stream, pc->u.cccccc.c2));
CHECK(save_ConstantTerm(stream, pc->u.cccccc.c3));
CHECK(save_ConstantTerm(stream, pc->u.cccccc.c4));
CHECK(save_ConstantTerm(stream, pc->u.cccccc.c5));
CHECK(save_ConstantTerm(stream, pc->u.cccccc.c6));
CHECK(save_ConstantTerm(stream, pc->y_u.cccccc.c1));
CHECK(save_ConstantTerm(stream, pc->y_u.cccccc.c2));
CHECK(save_ConstantTerm(stream, pc->y_u.cccccc.c3));
CHECK(save_ConstantTerm(stream, pc->y_u.cccccc.c4));
CHECK(save_ConstantTerm(stream, pc->y_u.cccccc.c5));
CHECK(save_ConstantTerm(stream, pc->y_u.cccccc.c6));
pc = NEXTOP(pc,cccccc);
break;
/* instructions type clll */
case _if_not_then:
CHECK(save_ConstantTerm(stream, pc->u.clll.c));
CHECK(save_PtoOp(stream, pc->u.clll.l1));
CHECK(save_PtoOp(stream, pc->u.clll.l2));
CHECK(save_PtoOp(stream, pc->u.clll.l3));
CHECK(save_ConstantTerm(stream, pc->y_u.clll.c));
CHECK(save_PtoOp(stream, pc->y_u.clll.l1));
CHECK(save_PtoOp(stream, pc->y_u.clll.l2));
CHECK(save_PtoOp(stream, pc->y_u.clll.l3));
pc = NEXTOP(pc,clll);
break;
/* instructions type d */
case _write_float:
CHECK(save_DoubleInCode(stream, pc->u.d.d));
CHECK(save_DoubleInCode(stream, pc->y_u.d.d));
pc = NEXTOP(pc,d);
break;
/* instructions type e */
@ -263,13 +263,13 @@
/* instructions type fa */
case _write_l_struc:
case _write_struct:
CHECK(save_Func(stream, pc->u.fa.f));
CHECK(save_Arity(stream, pc->u.fa.a));
CHECK(save_Func(stream, pc->y_u.fa.f));
CHECK(save_Arity(stream, pc->y_u.fa.a));
pc = NEXTOP(pc,fa);
break;
/* instructions type i */
case _write_longint:
CHECK(save_IntegerInCode(stream, pc->u.i.i));
CHECK(save_IntegerInCode(stream, pc->y_u.i.i));
pc = NEXTOP(pc,i);
break;
/* instructions type l */
@ -287,15 +287,15 @@
case _try_clause3:
case _try_clause4:
case _try_in:
CHECK(save_PtoOp(stream, pc->u.l.l));
CHECK(save_PtoOp(stream, pc->y_u.l.l));
pc = NEXTOP(pc,l);
break;
/* instructions type llll */
case _switch_on_type:
CHECK(save_PtoOp(stream, pc->u.llll.l1));
CHECK(save_PtoOp(stream, pc->u.llll.l2));
CHECK(save_PtoOp(stream, pc->u.llll.l3));
CHECK(save_PtoOp(stream, pc->u.llll.l4));
CHECK(save_PtoOp(stream, pc->y_u.llll.l1));
CHECK(save_PtoOp(stream, pc->y_u.llll.l2));
CHECK(save_PtoOp(stream, pc->y_u.llll.l3));
CHECK(save_PtoOp(stream, pc->y_u.llll.l4));
pc = NEXTOP(pc,llll);
break;
/* instructions type lp */
@ -306,8 +306,8 @@
case _try_exo:
case _try_exo_udi:
case _user_switch:
CHECK(save_PtoOp(stream, pc->u.lp.l));
CHECK(save_PtoPred(stream, pc->u.lp.p));
CHECK(save_PtoOp(stream, pc->y_u.lp.l));
CHECK(save_PtoPred(stream, pc->y_u.lp.p));
pc = NEXTOP(pc,lp);
break;
/* instructions type o */
@ -319,21 +319,21 @@
case _unify_list_write:
case _unify_void:
case _unify_void_write:
CHECK(save_Opcode(stream, pc->u.o.opcw));
CHECK(save_Opcode(stream, pc->y_u.o.opcw));
pc = NEXTOP(pc,o);
break;
/* instructions type oD */
case _unify_dbterm:
case _unify_l_dbterm:
CHECK(save_Opcode(stream, pc->u.oD.opcw));
CHECK(save_DBGroundTerm(stream, pc->u.oD.D));
CHECK(save_Opcode(stream, pc->y_u.oD.opcw));
CHECK(save_DBGroundTerm(stream, pc->y_u.oD.D));
pc = NEXTOP(pc,oD);
break;
/* instructions type oN */
case _unify_bigint:
case _unify_l_bigint:
CHECK(save_Opcode(stream, pc->u.oN.opcw));
CHECK(save_BlobTermInCode(stream, pc->u.oN.b));
CHECK(save_Opcode(stream, pc->y_u.oN.opcw));
CHECK(save_BlobTermInCode(stream, pc->y_u.oN.b));
pc = NEXTOP(pc,oN);
break;
/* instructions type oc */
@ -341,8 +341,8 @@
case _unify_atom_write:
case _unify_l_atom:
case _unify_l_atom_write:
CHECK(save_Opcode(stream, pc->u.oc.opcw));
CHECK(save_ConstantTerm(stream, pc->u.oc.c));
CHECK(save_Opcode(stream, pc->y_u.oc.opcw));
CHECK(save_ConstantTerm(stream, pc->y_u.oc.c));
pc = NEXTOP(pc,oc);
break;
/* instructions type od */
@ -350,8 +350,8 @@
case _unify_float_write:
case _unify_l_float:
case _unify_l_float_write:
CHECK(save_Opcode(stream, pc->u.od.opcw));
CHECK(save_DoubleInCode(stream, pc->u.od.d));
CHECK(save_Opcode(stream, pc->y_u.od.opcw));
CHECK(save_DoubleInCode(stream, pc->y_u.od.d));
pc = NEXTOP(pc,od);
break;
/* instructions type ofa */
@ -359,9 +359,9 @@
case _unify_l_struc_write:
case _unify_struct:
case _unify_struct_write:
CHECK(save_Opcode(stream, pc->u.ofa.opcw));
CHECK(save_Func(stream, pc->u.ofa.f));
CHECK(save_Arity(stream, pc->u.ofa.a));
CHECK(save_Opcode(stream, pc->y_u.ofa.opcw));
CHECK(save_Func(stream, pc->y_u.ofa.f));
CHECK(save_Arity(stream, pc->y_u.ofa.a));
pc = NEXTOP(pc,ofa);
break;
/* instructions type oi */
@ -369,17 +369,17 @@
case _unify_l_longint_write:
case _unify_longint:
case _unify_longint_write:
CHECK(save_Opcode(stream, pc->u.oi.opcw));
CHECK(save_IntegerInCode(stream, pc->u.oi.i));
CHECK(save_Opcode(stream, pc->y_u.oi.opcw));
CHECK(save_IntegerInCode(stream, pc->y_u.oi.i));
pc = NEXTOP(pc,oi);
break;
/* instructions type ollll */
case _switch_list_nl:
CHECK(save_Opcode(stream, pc->u.ollll.pop));
CHECK(save_PtoOp(stream, pc->u.ollll.l1));
CHECK(save_PtoOp(stream, pc->u.ollll.l2));
CHECK(save_PtoOp(stream, pc->u.ollll.l3));
CHECK(save_PtoOp(stream, pc->u.ollll.l4));
CHECK(save_Opcode(stream, pc->y_u.ollll.pop));
CHECK(save_PtoOp(stream, pc->y_u.ollll.l1));
CHECK(save_PtoOp(stream, pc->y_u.ollll.l2));
CHECK(save_PtoOp(stream, pc->y_u.ollll.l3));
CHECK(save_PtoOp(stream, pc->y_u.ollll.l4));
pc = NEXTOP(pc,ollll);
break;
/* instructions type os */
@ -390,23 +390,23 @@
case _unify_l_n_voids_write:
case _unify_n_voids:
case _unify_n_voids_write:
CHECK(save_Opcode(stream, pc->u.os.opcw));
CHECK(save_Constant(stream, pc->u.os.s));
CHECK(save_Opcode(stream, pc->y_u.os.opcw));
CHECK(save_Constant(stream, pc->y_u.os.s));
pc = NEXTOP(pc,os);
break;
/* instructions type osc */
case _unify_n_atoms:
case _unify_n_atoms_write:
CHECK(save_Opcode(stream, pc->u.osc.opcw));
CHECK(save_Constant(stream, pc->u.osc.s));
CHECK(save_ConstantTerm(stream, pc->u.osc.c));
CHECK(save_Opcode(stream, pc->y_u.osc.opcw));
CHECK(save_Constant(stream, pc->y_u.osc.s));
CHECK(save_ConstantTerm(stream, pc->y_u.osc.c));
pc = NEXTOP(pc,osc);
break;
/* instructions type ou */
case _unify_l_string:
case _unify_string:
CHECK(save_Opcode(stream, pc->u.ou.opcw));
CHECK(save_BlobTermInCode(stream, pc->u.ou.ut));
CHECK(save_Opcode(stream, pc->y_u.ou.opcw));
CHECK(save_BlobTermInCode(stream, pc->y_u.ou.ut));
pc = NEXTOP(pc,ou);
break;
/* instructions type ox */
@ -426,8 +426,8 @@
case _unify_x_val_write:
case _unify_x_var:
case _unify_x_var_write:
CHECK(save_Opcode(stream, pc->u.ox.opcw));
CHECK(save_X(stream, pc->u.ox.x));
CHECK(save_Opcode(stream, pc->y_u.ox.opcw));
CHECK(save_X(stream, pc->y_u.ox.x));
pc = NEXTOP(pc,ox);
break;
/* instructions type oxx */
@ -435,9 +435,9 @@
case _unify_l_x_var2_write:
case _unify_x_var2:
case _unify_x_var2_write:
CHECK(save_Opcode(stream, pc->u.oxx.opcw));
CHECK(save_X(stream, pc->u.oxx.xl));
CHECK(save_X(stream, pc->u.oxx.xr));
CHECK(save_Opcode(stream, pc->y_u.oxx.opcw));
CHECK(save_X(stream, pc->y_u.oxx.xl));
CHECK(save_X(stream, pc->y_u.oxx.xr));
pc = NEXTOP(pc,oxx);
break;
/* instructions type oy */
@ -457,8 +457,8 @@
case _unify_y_val_write:
case _unify_y_var:
case _unify_y_var_write:
CHECK(save_Opcode(stream, pc->u.oy.opcw));
CHECK(save_Y(stream, pc->u.oy.y));
CHECK(save_Opcode(stream, pc->y_u.oy.opcw));
CHECK(save_Y(stream, pc->y_u.oy.y));
pc = NEXTOP(pc,oy);
break;
/* instructions type p */
@ -471,43 +471,43 @@
case _retry_profiled:
case _retry_udi:
case _try_udi:
CHECK(save_PtoPred(stream, pc->u.p.p));
CHECK(save_PtoPred(stream, pc->y_u.p.p));
pc = NEXTOP(pc,p);
break;
/* instructions type plxxs */
case _call_bfunc_xx:
CHECK(save_PtoPred(stream, pc->u.plxxs.p));
CHECK(save_PtoOp(stream, pc->u.plxxs.f));
CHECK(save_X(stream, pc->u.plxxs.x1));
CHECK(save_X(stream, pc->u.plxxs.x2));
CHECK(save_Constant(stream, pc->u.plxxs.flags));
CHECK(save_PtoPred(stream, pc->y_u.plxxs.p));
CHECK(save_PtoOp(stream, pc->y_u.plxxs.f));
CHECK(save_X(stream, pc->y_u.plxxs.x1));
CHECK(save_X(stream, pc->y_u.plxxs.x2));
CHECK(save_Constant(stream, pc->y_u.plxxs.flags));
pc = NEXTOP(pc,plxxs);
break;
/* instructions type plxys */
case _call_bfunc_xy:
case _call_bfunc_yx:
CHECK(save_PtoPred(stream, pc->u.plxys.p));
CHECK(save_PtoOp(stream, pc->u.plxys.f));
CHECK(save_X(stream, pc->u.plxys.x));
CHECK(save_Y(stream, pc->u.plxys.y));
CHECK(save_Constant(stream, pc->u.plxys.flags));
CHECK(save_PtoPred(stream, pc->y_u.plxys.p));
CHECK(save_PtoOp(stream, pc->y_u.plxys.f));
CHECK(save_X(stream, pc->y_u.plxys.x));
CHECK(save_Y(stream, pc->y_u.plxys.y));
CHECK(save_Constant(stream, pc->y_u.plxys.flags));
pc = NEXTOP(pc,plxys);
break;
/* instructions type plyys */
case _call_bfunc_yy:
CHECK(save_PtoPred(stream, pc->u.plyys.p));
CHECK(save_PtoOp(stream, pc->u.plyys.f));
CHECK(save_Y(stream, pc->u.plyys.y1));
CHECK(save_Y(stream, pc->u.plyys.y2));
CHECK(save_Constant(stream, pc->u.plyys.flags));
CHECK(save_PtoPred(stream, pc->y_u.plyys.p));
CHECK(save_PtoOp(stream, pc->y_u.plyys.f));
CHECK(save_Y(stream, pc->y_u.plyys.y1));
CHECK(save_Y(stream, pc->y_u.plyys.y2));
CHECK(save_Constant(stream, pc->y_u.plyys.flags));
pc = NEXTOP(pc,plyys);
break;
/* instructions type pp */
case _dexecute:
case _execute:
case _execute_cpred:
CHECK(save_PtoPred(stream, pc->u.pp.p));
CHECK(save_PtoPred(stream, pc->u.pp.p0));
CHECK(save_PtoPred(stream, pc->y_u.pp.p));
CHECK(save_PtoPred(stream, pc->y_u.pp.p0));
pc = NEXTOP(pc,pp);
break;
/* instructions type s */
@ -516,29 +516,29 @@
case _cut_t:
case _pop_n:
case _write_n_voids:
CHECK(save_Constant(stream, pc->u.s.s));
CHECK(save_Constant(stream, pc->y_u.s.s));
pc = NEXTOP(pc,s);
break;
/* instructions type sc */
case _write_n_atoms:
CHECK(save_Constant(stream, pc->u.sc.s));
CHECK(save_ConstantTerm(stream, pc->u.sc.c));
CHECK(save_Constant(stream, pc->y_u.sc.s));
CHECK(save_ConstantTerm(stream, pc->y_u.sc.c));
pc = NEXTOP(pc,sc);
break;
/* instructions type sllll */
case _switch_on_sub_arg_type:
CHECK(save_Constant(stream, pc->u.sllll.s));
CHECK(save_PtoOp(stream, pc->u.sllll.l1));
CHECK(save_PtoOp(stream, pc->u.sllll.l2));
CHECK(save_PtoOp(stream, pc->u.sllll.l3));
CHECK(save_PtoOp(stream, pc->u.sllll.l4));
CHECK(save_Constant(stream, pc->y_u.sllll.s));
CHECK(save_PtoOp(stream, pc->y_u.sllll.l1));
CHECK(save_PtoOp(stream, pc->y_u.sllll.l2));
CHECK(save_PtoOp(stream, pc->y_u.sllll.l3));
CHECK(save_PtoOp(stream, pc->y_u.sllll.l4));
pc = NEXTOP(pc,sllll);
break;
/* instructions type slp */
case _call_c_wfail:
CHECK(save_Constant(stream, pc->u.slp.s));
CHECK(save_PtoOp(stream, pc->u.slp.l));
CHECK(save_PtoPred(stream, pc->u.slp.p));
CHECK(save_Constant(stream, pc->y_u.slp.s));
CHECK(save_PtoOp(stream, pc->y_u.slp.l));
CHECK(save_PtoPred(stream, pc->y_u.slp.p));
pc = NEXTOP(pc,slp);
break;
/* instructions type sssl */
@ -548,20 +548,20 @@
case _if_func:
case _switch_on_cons:
case _switch_on_func:
CHECK(save_Constant(stream, pc->u.sssl.s));
CHECK(save_Constant(stream, pc->u.sssl.e));
CHECK(save_Constant(stream, pc->u.sssl.w));
CHECK(save_PtoOp(stream, pc->u.sssl.l));
CHECK(save_Constant(stream, pc->y_u.sssl.s));
CHECK(save_Constant(stream, pc->y_u.sssl.e));
CHECK(save_Constant(stream, pc->y_u.sssl.w));
CHECK(save_PtoOp(stream, pc->y_u.sssl.l));
pc = NEXTOP(pc,sssl);
break;
/* instructions type sssllp */
case _expand_clauses:
CHECK(save_Constant(stream, pc->u.sssllp.s1));
CHECK(save_Constant(stream, pc->u.sssllp.s2));
CHECK(save_Constant(stream, pc->u.sssllp.s3));
CHECK(save_PtoOp(stream, pc->u.sssllp.sprev));
CHECK(save_PtoOp(stream, pc->u.sssllp.snext));
CHECK(save_PtoPred(stream, pc->u.sssllp.p));
CHECK(save_Constant(stream, pc->y_u.sssllp.s1));
CHECK(save_Constant(stream, pc->y_u.sssllp.s2));
CHECK(save_Constant(stream, pc->y_u.sssllp.s3));
CHECK(save_PtoOp(stream, pc->y_u.sssllp.sprev));
CHECK(save_PtoOp(stream, pc->y_u.sssllp.snext));
CHECK(save_PtoPred(stream, pc->y_u.sssllp.p));
pc = NEXTOP(pc,sssllp);
break;
/* instructions type x */
@ -572,50 +572,50 @@
case _write_x_loc:
case _write_x_val:
case _write_x_var:
CHECK(save_X(stream, pc->u.x.x));
CHECK(save_X(stream, pc->y_u.x.x));
pc = NEXTOP(pc,x);
break;
/* instructions type xD */
case _get_dbterm:
case _put_dbterm:
CHECK(save_X(stream, pc->u.xD.x));
CHECK(save_DBGroundTerm(stream, pc->u.xD.D));
CHECK(save_X(stream, pc->y_u.xD.x));
CHECK(save_DBGroundTerm(stream, pc->y_u.xD.D));
pc = NEXTOP(pc,xD);
break;
/* instructions type xN */
case _get_bigint:
case _put_bigint:
CHECK(save_X(stream, pc->u.xN.x));
CHECK(save_BlobTermInCode(stream, pc->u.xN.b));
CHECK(save_X(stream, pc->y_u.xN.x));
CHECK(save_BlobTermInCode(stream, pc->y_u.xN.b));
pc = NEXTOP(pc,xN);
break;
/* instructions type xc */
case _get_atom:
case _put_atom:
CHECK(save_X(stream, pc->u.xc.x));
CHECK(save_ConstantTerm(stream, pc->u.xc.c));
CHECK(save_X(stream, pc->y_u.xc.x));
CHECK(save_ConstantTerm(stream, pc->y_u.xc.c));
pc = NEXTOP(pc,xc);
break;
/* instructions type xd */
case _get_float:
case _put_float:
CHECK(save_X(stream, pc->u.xd.x));
CHECK(save_DoubleInCode(stream, pc->u.xd.d));
CHECK(save_X(stream, pc->y_u.xd.x));
CHECK(save_DoubleInCode(stream, pc->y_u.xd.d));
pc = NEXTOP(pc,xd);
break;
/* instructions type xfa */
case _get_struct:
case _put_struct:
CHECK(save_X(stream, pc->u.xfa.x));
CHECK(save_Func(stream, pc->u.xfa.f));
CHECK(save_Arity(stream, pc->u.xfa.a));
CHECK(save_X(stream, pc->y_u.xfa.x));
CHECK(save_Func(stream, pc->y_u.xfa.f));
CHECK(save_Arity(stream, pc->y_u.xfa.a));
pc = NEXTOP(pc,xfa);
break;
/* instructions type xi */
case _get_longint:
case _put_longint:
CHECK(save_X(stream, pc->u.xi.x));
CHECK(save_IntegerInCode(stream, pc->u.xi.i));
CHECK(save_X(stream, pc->y_u.xi.x));
CHECK(save_IntegerInCode(stream, pc->y_u.xi.i));
pc = NEXTOP(pc,xi);
break;
/* instructions type xl */
@ -629,37 +629,37 @@
case _p_number_x:
case _p_primitive_x:
case _p_var_x:
CHECK(save_X(stream, pc->u.xl.x));
CHECK(save_PtoOp(stream, pc->u.xl.F));
CHECK(save_X(stream, pc->y_u.xl.x));
CHECK(save_PtoOp(stream, pc->y_u.xl.F));
pc = NEXTOP(pc,xl);
break;
/* instructions type xll */
case _jump_if_nonvar:
CHECK(save_X(stream, pc->u.xll.x));
CHECK(save_PtoOp(stream, pc->u.xll.l1));
CHECK(save_PtoOp(stream, pc->u.xll.l2));
CHECK(save_X(stream, pc->y_u.xll.x));
CHECK(save_PtoOp(stream, pc->y_u.xll.l1));
CHECK(save_PtoOp(stream, pc->y_u.xll.l2));
pc = NEXTOP(pc,xll);
break;
/* instructions type xllll */
case _switch_on_arg_type:
CHECK(save_X(stream, pc->u.xllll.x));
CHECK(save_PtoOp(stream, pc->u.xllll.l1));
CHECK(save_PtoOp(stream, pc->u.xllll.l2));
CHECK(save_PtoOp(stream, pc->u.xllll.l3));
CHECK(save_PtoOp(stream, pc->u.xllll.l4));
CHECK(save_X(stream, pc->y_u.xllll.x));
CHECK(save_PtoOp(stream, pc->y_u.xllll.l1));
CHECK(save_PtoOp(stream, pc->y_u.xllll.l2));
CHECK(save_PtoOp(stream, pc->y_u.xllll.l3));
CHECK(save_PtoOp(stream, pc->y_u.xllll.l4));
pc = NEXTOP(pc,xllll);
break;
/* instructions type xps */
case _commit_b_x:
CHECK(save_X(stream, pc->u.xps.x));
CHECK(save_PtoPred(stream, pc->u.xps.p0));
CHECK(save_Constant(stream, pc->u.xps.s));
CHECK(save_X(stream, pc->y_u.xps.x));
CHECK(save_PtoPred(stream, pc->y_u.xps.p0));
CHECK(save_Constant(stream, pc->y_u.xps.s));
pc = NEXTOP(pc,xps);
break;
/* instructions type xu */
case _get_string:
CHECK(save_X(stream, pc->u.xu.x));
CHECK(save_BlobTermInCode(stream, pc->u.xu.ut));
CHECK(save_X(stream, pc->y_u.xu.x));
CHECK(save_BlobTermInCode(stream, pc->y_u.xu.ut));
pc = NEXTOP(pc,xu);
break;
/* instructions type xx */
@ -670,15 +670,15 @@
case _glist_valx:
case _put_x_val:
case _put_x_var:
CHECK(save_X(stream, pc->u.xx.xl));
CHECK(save_X(stream, pc->u.xx.xr));
CHECK(save_X(stream, pc->y_u.xx.xl));
CHECK(save_X(stream, pc->y_u.xx.xr));
pc = NEXTOP(pc,xx);
break;
/* instructions type xxc */
case _p_func2s_cv:
CHECK(save_X(stream, pc->u.xxc.x));
CHECK(save_X(stream, pc->u.xxc.xi));
CHECK(save_ConstantTerm(stream, pc->u.xxc.c));
CHECK(save_X(stream, pc->y_u.xxc.x));
CHECK(save_X(stream, pc->y_u.xxc.xi));
CHECK(save_ConstantTerm(stream, pc->y_u.xxc.c));
pc = NEXTOP(pc,xxc);
break;
/* instructions type xxn */
@ -695,9 +695,9 @@
case _p_slr_cv:
case _p_slr_vc:
case _p_times_vc:
CHECK(save_X(stream, pc->u.xxn.x));
CHECK(save_X(stream, pc->u.xxn.xi));
CHECK(save_Integer(stream, pc->u.xxn.c));
CHECK(save_X(stream, pc->y_u.xxn.x));
CHECK(save_X(stream, pc->y_u.xxn.xi));
CHECK(save_Integer(stream, pc->y_u.xxn.c));
pc = NEXTOP(pc,xxn);
break;
/* instructions type xxx */
@ -712,24 +712,24 @@
case _p_sll_vv:
case _p_slr_vv:
case _p_times_vv:
CHECK(save_X(stream, pc->u.xxx.x));
CHECK(save_X(stream, pc->u.xxx.x1));
CHECK(save_X(stream, pc->u.xxx.x2));
CHECK(save_X(stream, pc->y_u.xxx.x));
CHECK(save_X(stream, pc->y_u.xxx.x1));
CHECK(save_X(stream, pc->y_u.xxx.x2));
pc = NEXTOP(pc,xxx);
break;
/* instructions type xxxx */
case _put_xx_val:
CHECK(save_X(stream, pc->u.xxxx.xl1));
CHECK(save_X(stream, pc->u.xxxx.xl2));
CHECK(save_X(stream, pc->u.xxxx.xr1));
CHECK(save_X(stream, pc->u.xxxx.xr2));
CHECK(save_X(stream, pc->y_u.xxxx.xl1));
CHECK(save_X(stream, pc->y_u.xxxx.xl2));
CHECK(save_X(stream, pc->y_u.xxxx.xr1));
CHECK(save_X(stream, pc->y_u.xxxx.xr2));
pc = NEXTOP(pc,xxxx);
break;
/* instructions type xxy */
case _p_func2f_xy:
CHECK(save_X(stream, pc->u.xxy.x));
CHECK(save_X(stream, pc->u.xxy.x1));
CHECK(save_Y(stream, pc->u.xxy.y2));
CHECK(save_X(stream, pc->y_u.xxy.x));
CHECK(save_X(stream, pc->y_u.xxy.x1));
CHECK(save_Y(stream, pc->y_u.xxy.y2));
pc = NEXTOP(pc,xxy);
break;
/* instructions type y */
@ -737,7 +737,7 @@
case _write_y_loc:
case _write_y_val:
case _write_y_var:
CHECK(save_Y(stream, pc->u.y.y));
CHECK(save_Y(stream, pc->y_u.y.y));
pc = NEXTOP(pc,y);
break;
/* instructions type yl */
@ -751,15 +751,15 @@
case _p_number_y:
case _p_primitive_y:
case _p_var_y:
CHECK(save_Y(stream, pc->u.yl.y));
CHECK(save_PtoOp(stream, pc->u.yl.F));
CHECK(save_Y(stream, pc->y_u.yl.y));
CHECK(save_PtoOp(stream, pc->y_u.yl.F));
pc = NEXTOP(pc,yl);
break;
/* instructions type yps */
case _commit_b_y:
CHECK(save_Y(stream, pc->u.yps.y));
CHECK(save_PtoPred(stream, pc->u.yps.p0));
CHECK(save_Constant(stream, pc->u.yps.s));
CHECK(save_Y(stream, pc->y_u.yps.y));
CHECK(save_PtoPred(stream, pc->y_u.yps.p0));
CHECK(save_Constant(stream, pc->y_u.yps.s));
pc = NEXTOP(pc,yps);
break;
/* instructions type yx */
@ -771,15 +771,15 @@
case _put_unsafe:
case _put_y_val:
case _put_y_var:
CHECK(save_Y(stream, pc->u.yx.y));
CHECK(save_X(stream, pc->u.yx.x));
CHECK(save_Y(stream, pc->y_u.yx.y));
CHECK(save_X(stream, pc->y_u.yx.x));
pc = NEXTOP(pc,yx);
break;
/* instructions type yxc */
case _p_func2s_y_cv:
CHECK(save_Y(stream, pc->u.yxc.y));
CHECK(save_X(stream, pc->u.yxc.xi));
CHECK(save_ConstantTerm(stream, pc->u.yxc.c));
CHECK(save_Y(stream, pc->y_u.yxc.y));
CHECK(save_X(stream, pc->y_u.yxc.xi));
CHECK(save_ConstantTerm(stream, pc->y_u.yxc.c));
pc = NEXTOP(pc,yxc);
break;
/* instructions type yxn */
@ -796,9 +796,9 @@
case _p_slr_y_cv:
case _p_slr_y_vc:
case _p_times_y_vc:
CHECK(save_Y(stream, pc->u.yxn.y));
CHECK(save_X(stream, pc->u.yxn.xi));
CHECK(save_Integer(stream, pc->u.yxn.c));
CHECK(save_Y(stream, pc->y_u.yxn.y));
CHECK(save_X(stream, pc->y_u.yxn.xi));
CHECK(save_Integer(stream, pc->y_u.yxn.c));
pc = NEXTOP(pc,yxn);
break;
/* instructions type yxx */
@ -813,25 +813,25 @@
case _p_sll_y_vv:
case _p_slr_y_vv:
case _p_times_y_vv:
CHECK(save_Y(stream, pc->u.yxx.y));
CHECK(save_X(stream, pc->u.yxx.x1));
CHECK(save_X(stream, pc->u.yxx.x2));
CHECK(save_Y(stream, pc->y_u.yxx.y));
CHECK(save_X(stream, pc->y_u.yxx.x1));
CHECK(save_X(stream, pc->y_u.yxx.x2));
pc = NEXTOP(pc,yxx);
break;
/* instructions type yyx */
case _p_func2f_yy:
CHECK(save_Y(stream, pc->u.yyx.y1));
CHECK(save_Y(stream, pc->u.yyx.y2));
CHECK(save_X(stream, pc->u.yyx.x));
CHECK(save_Y(stream, pc->y_u.yyx.y1));
CHECK(save_Y(stream, pc->y_u.yyx.y2));
CHECK(save_X(stream, pc->y_u.yyx.x));
pc = NEXTOP(pc,yyx);
break;
/* instructions type yyxx */
case _get_yy_var:
case _put_y_vals:
CHECK(save_Y(stream, pc->u.yyxx.y1));
CHECK(save_Y(stream, pc->u.yyxx.y2));
CHECK(save_X(stream, pc->u.yyxx.x1));
CHECK(save_X(stream, pc->u.yyxx.x2));
CHECK(save_Y(stream, pc->y_u.yyxx.y1));
CHECK(save_Y(stream, pc->y_u.yyxx.y2));
CHECK(save_X(stream, pc->y_u.yyxx.x1));
CHECK(save_X(stream, pc->y_u.yyxx.x2));
pc = NEXTOP(pc,yyxx);
break;
#ifdef YAPOR
@ -840,14 +840,14 @@
case _getwork_seq:
case _sync:
#ifdef YAPOR
CHECK(save_OrArg(stream, pc->u.Otapl.or_arg));
CHECK(save_OrArg(stream, pc->y_u.Otapl.or_arg));
#endif
#ifdef TABLING
CHECK(save_TabEntry(stream, pc->u.Otapl.te));
CHECK(save_TabEntry(stream, pc->y_u.Otapl.te));
#endif
CHECK(save_Arity(stream, pc->u.Otapl.s));
CHECK(save_PtoPred(stream, pc->u.Otapl.p));
CHECK(save_PtoOp(stream, pc->u.Otapl.d));
CHECK(save_Arity(stream, pc->y_u.Otapl.s));
CHECK(save_PtoPred(stream, pc->y_u.Otapl.p));
CHECK(save_PtoOp(stream, pc->y_u.Otapl.d));
pc = NEXTOP(pc,Otapl);
break;
/* instructions type e */
@ -873,14 +873,14 @@
case _table_try_me:
case _table_try_single:
#ifdef YAPOR
CHECK(save_OrArg(stream, pc->u.Otapl.or_arg));
CHECK(save_OrArg(stream, pc->y_u.Otapl.or_arg));
#endif
#ifdef TABLING
CHECK(save_TabEntry(stream, pc->u.Otapl.te));
CHECK(save_TabEntry(stream, pc->y_u.Otapl.te));
#endif
CHECK(save_Arity(stream, pc->u.Otapl.s));
CHECK(save_PtoPred(stream, pc->u.Otapl.p));
CHECK(save_PtoOp(stream, pc->u.Otapl.d));
CHECK(save_Arity(stream, pc->y_u.Otapl.s));
CHECK(save_PtoPred(stream, pc->y_u.Otapl.p));
CHECK(save_PtoOp(stream, pc->y_u.Otapl.d));
pc = NEXTOP(pc,Otapl);
break;
/* instructions type e */
@ -892,7 +892,7 @@
break;
/* instructions type s */
case _table_new_answer:
CHECK(save_Constant(stream, pc->u.s.s));
CHECK(save_Constant(stream, pc->y_u.s.s));
pc = NEXTOP(pc,s);
break;
/* instructions type e */

View File

@ -3,20 +3,12 @@
#define THREADS_H 1
typedef struct thread_attr_struct {
UInt ssize;
UInt tsize;
UInt sysize;
int (*cancel)(int thread);
Term egoal;
} thread_attr;
#ifdef THREADS
Int Yap_thread_self(void);
int Yap_get_thread_ref_count(int);
void Yap_set_thread_ref_count(int,int);
CELL Yap_thread_create_engine(thread_attr *);
CELL Yap_thread_create_engine(YAP_thread_attr *);
Int Yap_thread_attach_engine(int);
Int Yap_thread_detach_engine(int);
Int Yap_thread_destroy_engine(int);

View File

@ -30,7 +30,7 @@
} else if (IN_BETWEEN(H0,pt,HR) && IsAttVar(pt)) {
CELL val = Deref(*pt);
if (IsVarTerm(val)) {
Bind(pt, MkAtomTerm(AtomCut));
YapBind(pt, MkAtomTerm(AtomCut));
Yap_WakeUp(pt);
}
} else if ((*pt & (LogUpdMask|IndexMask)) == (LogUpdMask|IndexMask)) {
@ -131,7 +131,7 @@
if (IN_BETWEEN(H0,pt,HR) && IsAttVar(pt)) {
CELL val = Deref(*pt);
if (IsVarTerm(val)) {
Bind(VarOfTerm(val), MkAtomTerm(AtomCut));
YapBind(VarOfTerm(val), MkAtomTerm(AtomCut));
Yap_WakeUp(pt);
}
} else if ((*pt & (LogUpdMask|IndexMask)) == (LogUpdMask|IndexMask)) {

View File

@ -30,7 +30,7 @@ typedef struct udi_info *UdiInfo;
/* to ease code for a UdiInfo hash table*/
#define HASH_FIND_UdiInfo(head,find,out) \
HASH_FIND(hh,head,find,sizeof(PredEntry *),out)
HASH_FIND(hh,head,find,sizeof(PredEntry),out)
#define HASH_ADD_UdiInfo(head,p,add) \
HASH_ADD_KEYPTR(hh,head,p,sizeof(PredEntry *),add)

View File

@ -15,10 +15,10 @@
break;
/* instructions type Illss */
case _enter_lu_pred:
return walk_got_lu_block(pc->u.Illss.I, startp, endp);
return walk_got_lu_block(pc->y_u.Illss.I, startp, endp);
/* instructions type L */
case _alloc_for_logical_pred:
return walk_got_lu_clause(pc->u.L.ClBase, startp, endp);
return walk_got_lu_clause(pc->y_u.L.ClBase, startp, endp);
/* instructions type N */
case _write_bigint:
pc = NEXTOP(pc,N);
@ -27,7 +27,7 @@
case _either:
case _or_else:
clause_code = TRUE;
pp = pc->u.Osblp.p0;
pp = pc->y_u.Osblp.p0;
pc = NEXTOP(pc,Osblp);
break;
/* instructions type Osbmp */
@ -41,30 +41,30 @@
break;
/* instructions type Osbpp */
case _call_cpred:
pp = pc->u.Osbpp.p;
pp = pc->y_u.Osbpp.p;
return walk_found_c_pred(pp, startp, endp);
case _call_usercpred:
pp = pc->u.Osbpp.p;
pp = pc->y_u.Osbpp.p;
return walk_found_c_pred(pp, startp, endp);
case _p_execute2:
return found_meta_call(startp, endp);
case _call:
case _fcall:
clause_code = TRUE;
pp = pc->u.Osbpp.p0;
pp = pc->y_u.Osbpp.p0;
pc = NEXTOP(pc,Osbpp);
break;
/* instructions type OtILl */
case _count_trust_logical:
case _profiled_trust_logical:
case _trust_logical:
return walk_got_lu_block(pc->u.OtILl.block, startp, endp);
return walk_got_lu_block(pc->y_u.OtILl.block, startp, endp);
/* instructions type OtaLl */
case _count_retry_logical:
case _profiled_retry_logical:
case _retry_logical:
case _try_logical:
pc = pc->u.OtaLl.n;
pc = pc->y_u.OtaLl.n;
break;
/* instructions type OtapFs */
case _cut_c:
@ -74,7 +74,7 @@
case _try_c:
case _try_userc:
clause_code = TRUE;
pp = pc->u.OtapFs.p;
pp = pc->y_u.OtapFs.p;
pc = NEXTOP(pc,OtapFs);
break;
/* instructions type Otapl */
@ -94,7 +94,7 @@
case _try_clause:
case _try_me:
clause_code = FALSE;
pp = pc->u.Otapl.p;
pp = pc->y_u.Otapl.p;
pc = NEXTOP(pc,Otapl);
break;
/* instructions type aFlp */
@ -342,7 +342,7 @@
/* instructions type p */
case _lock_lu:
case _procceed:
pp = pc->u.p.p;
pp = pc->y_u.p.p;
if (pp->PredFlags & MegaClausePredFlag)
return found_mega_clause(pp, startp, endp);
clause_code = TRUE;
@ -372,12 +372,12 @@
break;
/* instructions type pp */
case _execute_cpred:
pp = pc->u.pp.p;
pp = pc->y_u.pp.p;
return walk_found_c_pred(pp, startp, endp);
case _dexecute:
case _execute:
clause_code = TRUE;
pp = pc->u.pp.p0;
pp = pc->y_u.pp.p0;
pc = NEXTOP(pc,pp);
break;
/* instructions type s */
@ -398,7 +398,7 @@
break;
/* instructions type slp */
case _call_c_wfail:
pp = pc->u.slp.p;
pp = pc->y_u.slp.p;
return walk_found_c_pred(pp, startp, endp);
/* instructions type sssl */
case _go_on_cons:
@ -619,7 +619,7 @@
case _getwork_seq:
case _sync:
clause_code = FALSE;
pp = pc->u.Otapl.p;
pp = pc->y_u.Otapl.p;
pc = NEXTOP(pc,Otapl);
break;
/* instructions type e */
@ -644,7 +644,7 @@
case _table_try_me:
case _table_try_single:
clause_code = FALSE;
pp = pc->u.Otapl.p;
pp = pc->y_u.Otapl.p;
pc = NEXTOP(pc,Otapl);
break;
/* instructions type e */
@ -728,13 +728,13 @@
/* this instruction is hardwired */
case _or_last:
#ifdef YAPOR
pp = pc->u.Osblp.p0;
pp = pc->y_u.Osblp.p0;
if (pp->PredFlags & MegaClausePredFlag)
return found_mega_clause(pp, startp, endp);
clause_code = TRUE;
pc = NEXTOP(pc,Osblp);
#else
pp = pc->u.p.p;
pp = pc->y_u.p.p;
if (pp->PredFlags & MegaClausePredFlag)
return found_mega_clause(pp, startp, endp);
clause_code = TRUE;

View File

@ -266,14 +266,14 @@ int Yap_PlFGetchar(void);
int Yap_GetCharForSIGINT(void);
Int Yap_StreamToFileNo(Term);
Term Yap_OpenStream(FILE *,char *,Term,int);
Term Yap_StringToTerm(char *,Term *);
char *Yap_TermToString(Term t, char *s, size_t sz, size_t *length, int *encoding, int flags);
char *Yap_HandleToString(term_t l, size_t sz, size_t *length, int *encoding, int flags);
int Yap_GetFreeStreamD(void);
int Yap_GetFreeStreamDForReading(void);
Term Yap_WStringToList(wchar_t *);
Term Yap_WStringToListOfAtoms(wchar_t *);
Atom Yap_LookupWideAtom( wchar_t * );
Atom Yap_LookupWideAtom( const wchar_t * );
#define YAP_INPUT_STREAM 0x01
#define YAP_OUTPUT_STREAM 0x02

223
JIT/HPP/EnvironmentInit.h Normal file
View File

@ -0,0 +1,223 @@
#if YAP_STAT_PREDS
#include <papi.h>
#endif
extern Environment ExpEnv;
#if YAP_JIT
Int STD_PROTO(Get_N_Cores,(void));
X_API Int STD_PROTO(Init_Analysis_Struc,(void));
X_API Int STD_PROTO(Init_Transform_Struc,(void));
X_API Int STD_PROTO(Init_Codegen_Struc,(void));
X_API Int STD_PROTO(Init_Config_Struc,(void));
#if YAP_STAT_PREDS
X_API Int STD_PROTO(Init_Stats_Struc, (void));
#endif
#endif /* YAP_JIT */
#if YAP_DBG_PREDS
X_API Int STD_PROTO(Init_Debug_Struc,(void));
#endif
X_API Int STD_PROTO(YAP_Init_ExpEnv,(void));
#if YAP_JIT
Int
Get_N_Cores() {
#ifdef WIN32
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);
return sysinfo.dwNumberOfProcessors;
#elif MACOS
int nm[2];
size_t len = 4;
uint32_t count;
nm[0] = CTL_HW; nm[1] = HRW_AVAILCPU;
sysctl(nm, 2, &count, &len, NULL, 0);
if(count < 1) {
nm[1] = HRW_NCPU;
sysctl(nm, 2, &count, &len, NULL, 0);
if(count < 1) { count = 1; }
}
return count;
#else
return sysconf(_SC_NPROCESSORS_ONLN);
#endif
}
X_API Int
Init_Analysis_Struc()
{
ExpEnv.analysis_struc.stats_enabled = 0;
ExpEnv.analysis_struc.time_pass_enabled = 0;
ExpEnv.analysis_struc.pointtoverifymodule = NOPOINT;
ExpEnv.analysis_struc.n = 0;
ExpEnv.analysis_struc.act_an = NULL;
ExpEnv.analysis_struc.outfile = (CELL)malloc(7*sizeof(char));
strcpy(((char*)ExpEnv.analysis_struc.outfile), "STDERR");
return TRUE;
}
X_API Int
Init_Transform_Struc()
{
ExpEnv.transform_struc.optlevel = 3;
ExpEnv.transform_struc.n = 0;
ExpEnv.transform_struc.act_tr = NULL;
ExpEnv.transform_struc.opt_args.arg_promotion_max_elements = 3;
ExpEnv.transform_struc.opt_args.strip_symbols_pass_type = 0;
ExpEnv.transform_struc.opt_args.scalar_replace_aggregates_threshold = -1;
ExpEnv.transform_struc.opt_args.loop_unswitch_optimize_for_size = 0;
ExpEnv.transform_struc.opt_args.loop_unroll_threshold = -1;
ExpEnv.transform_struc.opt_args.inline_threshold = 225;
ExpEnv.transform_struc.unit_at_time_enabled = 1;
ExpEnv.transform_struc.simplify_libcalls_enabled = 1;
ExpEnv.transform_struc.link_time_opt.enabled = 0;
ExpEnv.transform_struc.link_time_opt.internalize = 0;
ExpEnv.transform_struc.link_time_opt.runinliner = 0;
return TRUE;
}
X_API Int
Init_Codegen_Struc()
{
ExpEnv.codegen_struc.struc_targetopt.noframepointerelim = 0;
ExpEnv.codegen_struc.struc_targetopt.lessprecisefpmadoption = 0;
ExpEnv.codegen_struc.struc_targetopt.noexcessfpprecision = 0;
ExpEnv.codegen_struc.struc_targetopt.unsafefpmath = 0;
ExpEnv.codegen_struc.struc_targetopt.honorsigndependentroundingfpmathoption = 0;
ExpEnv.codegen_struc.struc_targetopt.usesoftfloat = 0;
ExpEnv.codegen_struc.struc_targetopt.jitexceptionhandling = 0;
ExpEnv.codegen_struc.struc_targetopt.jitemitdebuginfo = 0;
ExpEnv.codegen_struc.struc_targetopt.jitemitdebuginfotodisk = 0;
ExpEnv.codegen_struc.struc_targetopt.guaranteedtailcallopt = 0;
ExpEnv.codegen_struc.struc_targetopt.disabletailcalls = 0;
ExpEnv.codegen_struc.struc_targetopt.fastisel = 0;
ExpEnv.codegen_struc.struc_targetopt.floatabitype = 0;
ExpEnv.codegen_struc.struc_enginebuilder.engineoptlevel = 3;
ExpEnv.codegen_struc.struc_enginebuilder.relocmodel = 0;
ExpEnv.codegen_struc.struc_enginebuilder.codemodel = 1;
ExpEnv.codegen_struc.struc_enginebuilder.usemcjit = 0;
ExpEnv.codegen_struc.struc_enginebuilder.regallocator = REG_ALLOC_GREEDY;
return TRUE;
}
X_API Int
Init_Config_Struc()
{
if (Yap_ExecutionMode == MIXED_MODE) {
ExpEnv.config_struc.execution_mode = SMART_JIT;
ExpEnv.config_struc.frequency_type = COUNTER;
ExpEnv.config_struc.frequency_bound = 1024.0;
ExpEnv.config_struc.profiling_startp = 0.72;
ExpEnv.config_struc.mainclause_ty = HROT_AND_CALLEE;
ExpEnv.config_struc.torecompile = 1;
}
else {
if (Yap_ExecutionMode == COMPILED)
ExpEnv.config_struc.execution_mode = JUST_COMPILED;
else
ExpEnv.config_struc.execution_mode = JUST_INTERPRETED;
ExpEnv.config_struc.frequency_type = NO_FREQ;
ExpEnv.config_struc.frequency_bound = 0.0;
ExpEnv.config_struc.profiling_startp = 0.0;
ExpEnv.config_struc.mainclause_ty = UNUSED;
ExpEnv.config_struc.torecompile = 0;
}
ExpEnv.config_struc.ncores = Get_N_Cores();
ExpEnv.config_struc.useonlypi = 0;
ExpEnv.config_struc.compilation_threads = 0;
ExpEnv.config_struc.threaded_compiler_threads = NULL;
ExpEnv.config_struc.posthreads = NULL;
return TRUE;
}
#if YAP_STAT_PREDS
X_API Int
Init_Stats_Struc()
{
ExpEnv.stats_struc.papi_initialized = 0;
ExpEnv.stats_struc.papi_eventset = PAPI_NULL;
return TRUE;
}
#endif
#endif /* YAP_JIT */
#if YAP_DBG_PREDS
X_API Int
Init_Debug_Struc()
{
#define OPCODE(OP,TYPE) \
ExpEnv.debug_struc.pyaam_##OP.print = (Int)NO_PLACE; \
ExpEnv.debug_struc.pyaam_##OP.msg_before = 0; \
ExpEnv.debug_struc.pyaam_##OP.msg_after = 0;
#include "YapAppliedOpcodes.h"
#undef OPCODE
#define BBLOCK(BB) \
ExpEnv.debug_struc.pbbs_##BB.print = (Int)NO_PLACE; \
ExpEnv.debug_struc.pbbs_##BB.msg_before = 0; \
ExpEnv.debug_struc.pbbs_##BB.msg_after = 0;
#include "Yap_AppliedBasicBlocks.h"
#undef BBLOCK
ExpEnv.debug_struc.pmainclause_on_head.print = (Int)NO_PLACE;
ExpEnv.debug_struc.pmainclause_on_head.msg_before = 0;
ExpEnv.debug_struc.pmainclause_on_head.msg_after = 0;
ExpEnv.debug_struc.pprint_intermediate.print_to_std = 0;
ExpEnv.debug_struc.pprint_intermediate.print_to_file = 0;
ExpEnv.debug_struc.pprint_intermediate.std_name = 0;
ExpEnv.debug_struc.pprint_intermediate.file_name = 0;
ExpEnv.debug_struc.pprint_llva.print_llva_before = 0;
ExpEnv.debug_struc.pprint_llva.print_llva_after = 0;
ExpEnv.debug_struc.pprint_me.interpreted_backtrack = 0;
ExpEnv.debug_struc.pprint_me.profiled_interpreted_backtrack = 0;
ExpEnv.debug_struc.pprint_me.native_backtrack = 0;
ExpEnv.debug_struc.pprint_me.interpreted_treat_heap = 0;
ExpEnv.debug_struc.pprint_me.native_treat_heap = 0;
ExpEnv.debug_struc.pprint_me.interpreted_treat_trail = 0;
ExpEnv.debug_struc.pprint_me.native_treat_trail = 0;
ExpEnv.debug_struc.pprint_me.criticals = 0;
ExpEnv.debug_struc.pprint_me.at_compilation = 0;
ExpEnv.debug_struc.pprint_me.at_recompilation = 0;
ExpEnv.debug_struc.pprint_me.nativerun_init = 0;
ExpEnv.debug_struc.pprint_me.nativerun_exit_by_success = 0;
ExpEnv.debug_struc.pprint_me.nativerun_exit_by_fail = 0;
ExpEnv.debug_struc.act_predicate_msgs.info_msgs = 0;
ExpEnv.debug_struc.act_predicate_msgs.success_msgs = 0;
ExpEnv.debug_struc.act_predicate_msgs.warning_msgs = 1;
ExpEnv.debug_struc.act_predicate_msgs.error_msgs = 1;
ExpEnv.debug_struc.act_predicate_actions.exit_on_warning = 0;
ExpEnv.debug_struc.act_predicate_actions.disable_on_warning = 1;
ExpEnv.debug_struc.act_predicate_actions.exit_on_error = 1;
return TRUE;
}
#endif
X_API Int
YAP_Init_ExpEnv()
{
//ExpEnv.in = (char*)malloc(1024*sizeof(char));
//strcpy(ExpEnv.in, fin);
#if YAP_JIT
Init_Analysis_Struc();
Init_Transform_Struc();
Init_Codegen_Struc();
Init_Config_Struc();
#if YAP_STAT_PREDS
Init_Stats_Struc();
#endif
#endif /* YAP_JIT */
#if YAP_DBG_PREDS
Init_Debug_Struc();
#endif
return TRUE;
}

2421
JIT/HPP/IsGround.h Normal file

File diff suppressed because it is too large Load Diff

24
JIT/HPP/JIT.hh Normal file
View File

@ -0,0 +1,24 @@
#ifndef JIT_HPP
#define JIT_HPP
#ifdef __cplusplus
#include <vector>
#include <string>
#include <cstdio>
#include <iostream>
#include <fstream>
#include <time.h>
#include <dlfcn.h>
#include "config.h"
#include "absmi.h"
using namespace std;
#else
#define LIMIT_COUNT 4096
#endif
#endif

104
JIT/HPP/JIT_Compiler.hh Normal file
View File

@ -0,0 +1,104 @@
#ifndef JIT_COMPILER_HPP
#define JIT_COMPILER_HPP
#ifdef __cplusplus
#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Instructions.h"
#include "llvm/Linker.h"
#include "llvm/PassManager.h"
#include "llvm/CallGraphSCCPass.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Assembly/PrintModulePass.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/MachineCodeInfo.h"
#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/ExecutionEngine/Interpreter.h"
#include "llvm/ExecutionEngine/GenericValue.h"
#include "llvm/ExecutionEngine/JITMemoryManager.h"
#include "llvm/ExecutionEngine/JITEventListener.h"
#include "llvm/Support/DataStream.h"
#include "llvm/Support/IRReader.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/raw_os_ostream.h"
#include "llvm/Support/IRBuilder.h"
#include "llvm/Support/PathV1.h"
#include "llvm/Support/TypeBuilder.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Target/TargetLibraryInfo.h"
#include "llvm/Analysis/Passes.h"
#include "llvm/Analysis/IVUsers.h"
#include "llvm/Analysis/Lint.h"
#include "llvm/Analysis/DebugInfo.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/RegionPass.h"
#include "llvm/Analysis/CFGPrinter.h"
#include "llvm/Analysis/DomPrinter.h"
#include "llvm/Analysis/BranchProbabilityInfo.h"
#include "llvm/Analysis/RegionPrinter.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/system_error.h"
#include "llvm/Support/Process.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Vectorize.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#include "llvm/Transforms/Utils/Cloning.h"
using namespace llvm;
#include <fcntl.h>
#include <errno.h>
#include "JIT.hpp"
using namespace std;
extern short global;
extern Environment ExpEnv;
extern NativeContext *NativeArea;
class JIT_Compiler {
private:
/* main method of JIT Compiler: compiles by clang, analyzes, optimizs and generates code accordingly the user choices */
void* compile_all(LLVMContext* &Context, yamop* p);
/* aid method to 'compile_all': adds register allocator pass to be used.
WARNING: don't use! For some reasons llvm crashes when I use it */
void set_regalloc_pass(PassManager &PM);
/* aid method to 'compile_all': optimizes module by individual transform passes or transform level */
void optimize_module(llvm::Module* &M);
/* aid method to 'compile_all': analyzes module by individual analysis passes */
void analyze_module(llvm::Module* &M);
public:
/* method invoked by wrapper 'call_JIT_Compiler' */
void* compile(yamop*);
};
#else
struct JIT_Compiler{}; // Doing this, I can call class 'JIT_Compiler' from C code
#endif
#ifdef __cplusplus
extern "C" void* call_JIT_Compiler(JIT_Compiler* jc, yamop* p) { return jc->compile(p); }
extern "C" void shutdown_llvm() { llvm_shutdown(); }
#endif //#ifdef __cplusplus
#endif

183
JIT/HPP/PassPrinters.hh Normal file
View File

@ -0,0 +1,183 @@
/**
* The code below is adapted from opt tool according to clearance and conditions established in NCSA license as follows:
* Copyright (c) 2003 University of Illinois. All rights reserved.
* Developed by: LLVM Developer Group
* University of Illinois
* http://llvm.org/
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
* files (the "Software"), to deal with the Software without restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
* is furnished to do so, subject to the following conditions:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimers.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimers
* in the documentation and/or other materials provided with the distribution.
* Neither the names of LLVM Developer Group, University of Illinois, nor the names of its contributors may be used to endorse or
* promote products derived from this Software without specific prior written permission.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HROLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
**/
struct CallGraphSCCPassPrinter : public CallGraphSCCPass {
static char ID;
const PassInfo *PassToPrint;
std::string PassName;
CallGraphSCCPassPrinter(const PassInfo *PI) :
CallGraphSCCPass(ID), PassToPrint(PI) {
std::string PassToPrintName = PassToPrint->getPassName();
PassName = "CallGraphSCCPass Printer: " + PassToPrintName;
}
virtual bool runOnSCC(CallGraphSCC &SCC) {
errs() << "Printing analysis '" << PassToPrint->getPassName() << "':\n";
// Get and print pass...
for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I) {
Function *F = (*I)->getFunction();
if (F)
getAnalysisID<Pass>(PassToPrint->getTypeInfo()).print(errs(),
F->getParent());
}
return false;
}
virtual const char *getPassName() const { return PassName.c_str(); }
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequiredID(PassToPrint->getTypeInfo());
AU.setPreservesAll();
}
};
char CallGraphSCCPassPrinter::ID = 0;
struct ModulePassPrinter : public ModulePass {
static char ID;
const PassInfo *PassToPrint;
std::string PassName;
ModulePassPrinter(const PassInfo *PI)
: ModulePass(ID), PassToPrint(PI) {
std::string PassToPrintName = PassToPrint->getPassName();
PassName = "ModulePass Printer: " + PassToPrintName;
}
virtual bool runOnModule(Module &M) {
errs() << "Printing analysis '" << PassToPrint->getPassName() << "':\n";
// Get and print pass...
getAnalysisID<Pass>(PassToPrint->getTypeInfo()).print(errs(), &M);
return false;
}
virtual const char *getPassName() const { return PassName.c_str(); }
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequiredID(PassToPrint->getTypeInfo());
AU.setPreservesAll();
}
};
char ModulePassPrinter::ID = 0;
struct FunctionPassPrinter : public FunctionPass {
const PassInfo *PassToPrint;
static char ID;
std::string PassName;
FunctionPassPrinter(const PassInfo *PI)
: FunctionPass(ID), PassToPrint(PI) {
std::string PassToPrintName = PassToPrint->getPassName();
PassName = "FunctionPass Printer: " + PassToPrintName;
}
virtual bool runOnFunction(Function &F) {
errs() << "Printing analysis '" << PassToPrint->getPassName()
<< "' for function '" << F.getName() << "':\n";
// Get and print pass...
getAnalysisID<Pass>(PassToPrint->getTypeInfo()).print(errs(),
F.getParent());
return false;
}
virtual const char *getPassName() const { return PassName.c_str(); }
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequiredID(PassToPrint->getTypeInfo());
AU.setPreservesAll();
}
};
char FunctionPassPrinter::ID = 0;
struct LoopPassPrinter : public LoopPass {
static char ID;
const PassInfo *PassToPrint;
std::string PassName;
LoopPassPrinter(const PassInfo *PI) :
LoopPass(ID), PassToPrint(PI) {
std::string PassToPrintName = PassToPrint->getPassName();
PassName = "LoopPass Printer: " + PassToPrintName;
}
virtual bool runOnLoop(Loop *L, LPPassManager &LPM) {
errs() << "Printing analysis '" << PassToPrint->getPassName() << "':\n";
// Get and print pass...
getAnalysisID<Pass>(PassToPrint->getTypeInfo()).print(errs(),
L->getHeader()->getParent()->getParent());
return false;
}
virtual const char *getPassName() const { return PassName.c_str(); }
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequiredID(PassToPrint->getTypeInfo());
AU.setPreservesAll();
}
};
char LoopPassPrinter::ID = 0;
struct RegionPassPrinter : public RegionPass {
static char ID;
const PassInfo *PassToPrint;
std::string PassName;
RegionPassPrinter(const PassInfo *PI) : RegionPass(ID),
PassToPrint(PI) {
std::string PassToPrintName = PassToPrint->getPassName();
PassName = "RegionPass Printer: " + PassToPrintName;
}
virtual bool runOnRegion(Region *R, RGPassManager &RGM) {
errs() << "Printing analysis '" << PassToPrint->getPassName() << "' for "
<< "region: '" << R->getNameStr() << "' in function '"
<< R->getEntry()->getParent()->getName() << "':\n";
// Get and print pass...
getAnalysisID<Pass>(PassToPrint->getTypeInfo()).print(errs(),
R->getEntry()->getParent()->getParent());
return false;
}
virtual const char *getPassName() const { return PassName.c_str(); }
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequiredID(PassToPrint->getTypeInfo());
AU.setPreservesAll();
}
};
char RegionPassPrinter::ID = 0;

File diff suppressed because it is too large Load Diff

1503
JIT/HPP/Yap_BasicBlocks.h Normal file

File diff suppressed because it is too large Load Diff

73
JIT/HPP/debug_printers.h Normal file
View File

@ -0,0 +1,73 @@
void print_main_when_head(yamop*, enumPlace);
inline void
print_main_when_head(yamop* p, enumPlace place)
{
if((ExpEnv.debug_struc.pmainclause_on_head.print & place) == place) {
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__);
fprintf(stderr, "%s", (char*)ExpEnv.debug_struc.pmainclause_on_head.msg_before);
print_preg(p);
fprintf(stderr, "%s", (char*)ExpEnv.debug_struc.pmainclause_on_head.msg_after);
}
}
void print_instruction(yamop*, enumPlace);
inline void
print_instruction(yamop* p, enumPlace place)
{
op_numbers op = Yap_op_from_opcode(p->opc);
switch(op) {
#define OPCODE(OP,TYPE) \
case _##OP: \
if((ExpEnv.debug_struc.pyaam_##OP.print & place) == place) { \
char *tmp = (char*)malloc((16+strlen((char*)ExpEnv.debug_struc.pyaam_##OP.msg_after))*sizeof(char)); \
switch(place) { \
case ON_INTERPRETER: \
strcpy(tmp, " (as standard)"); \
break; \
case ON_PROFILED_INTERPRETER: \
strcpy(tmp, " (as profiled)"); \
break; \
case ON_NATIVE: \
strcpy(tmp, " (as native)"); \
break; \
default:; \
} \
strcat(tmp, (char*)ExpEnv.debug_struc.pyaam_##OP.msg_after); \
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__); \
print_op((char*)ExpEnv.debug_struc.pyaam_##OP.msg_before, op, tmp); \
} \
break;
#include "YapAppliedOpcodes.h"
#undef OPCODE
default:;
}
}
#if YAP_JIT
void print_block(YAP_BBs, enumPlace);
inline void
print_block(YAP_BBs block, enumPlace place)
{
switch(block) {
#define BBLOCK(BB) \
case BB: \
if((ExpEnv.debug_struc.pbbs_##BB.print & place) == place) { \
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__); \
fprintf(stderr, "%s", (char*)ExpEnv.debug_struc.pbbs_##BB.msg_before); \
fprint_block(block); \
{ \
if (place == ON_NATIVE) fprintf(stderr, " (on native)"); \
else fprintf(stderr, " (on interpreter)"); \
} \
fprintf(stderr, "%s", (char*)ExpEnv.debug_struc.pbbs_##BB.msg_after); \
} \
break;
#include "Yap_AppliedBasicBlocks.h"
#undef BBLOCK
default:;
}
}
#endif

4016
JIT/HPP/fprintblock.h Normal file

File diff suppressed because it is too large Load Diff

545
JIT/HPP/indexing_ext.h Normal file
View File

@ -0,0 +1,545 @@
#define USER_SWITCH_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
{ \
yamop *new = Yap_udi_search((*_PREG)->u.lp.p); \
if (!new) { \
(*_PREG) = (*_PREG)->u.lp.l; \
JMPNext(); \
} \
else { \
(*_PREG) = new; \
JMPNext(); \
} \
}
#define USER_SWITCH_END \
BLOCK = (CELL)USER_SWITCH_END;
#define SWITCH_ON_TYPE_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = CACHED_A1(); \
Int nonvar = 1; \
if (IsVarTerm(d0)) { \
nonvar = 0; \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
copy_jmp_address((*_PREG)->u.llll.l4); \
(*_PREG) = (*_PREG)->u.llll.l4; \
JMPNext(); \
} \
} \
if (nonvar) { \
if (IsPairTerm(d0)) { \
(*_SREG) = RepPair(d0); \
copy_jmp_address((*_PREG)->u.llll.l1); \
(*_PREG) = (*_PREG)->u.llll.l1; \
JMPNext(); \
} \
else if (!IsApplTerm(d0)) { \
copy_jmp_address((*_PREG)->u.llll.l2); \
(*_PREG) = (*_PREG)->u.llll.l2; \
I_R = d0; \
JMPNext(); \
} \
else { \
copy_jmp_address((*_PREG)->u.llll.l3); \
(*_PREG) = (*_PREG)->u.llll.l3; \
(*_SREG) = RepAppl(d0); \
JMPNext(); \
} \
}
#define SWITCH_ON_TYPE_END \
BLOCK = (CELL)SWITCH_ON_TYPE_END;
#if UNIQUE_TAG_FOR_PAIRS
#define SWITCH_LIST_NL_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
ALWAYS_LOOKAHEAD((*_PREG)->u.ollll.pop); \
d0 = CACHED_A1(); \
Int nonvar = 0; \
Int pair = 1; \
if (!IsPairTerm(d0)) { \
pair = 0; \
do { \
if (!IsVarTerm(d0)) { \
if (d0 == TermNil) { \
(*_PREG) = (*_PREG)->u.ollll.l2; \
JMPNext(); \
} \
else { \
if (IsApplTerm(d0)) { \
copy_jmp_address((*_PREG)->u.ollll.l3); \
(*_PREG) = (*_PREG)->u.ollll.l3; \
(*_SREG) = RepAppl(d0); \
JMPNext(); \
} else { \
copy_jmp_address((*_PREG)->u.ollll.l3); \
(*_PREG) = (*_PREG)->u.ollll.l3; \
I_R = d0; \
JMPNext(); \
} \
} \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(pt0); \
if (Unsigned(pt0) == (d0)) break; \
if (IsPairTerm(d0)) { \
pair = 1; \
break; \
} \
} while (TRUE); \
if (!nonvar && !pair) { \
copy_jmp_address((*_PREG)->u.ollll.l4); \
(*_PREG) = (*_PREG)->u.ollll.l4; \
JMPNext(); \
} \
} \
if (!nonvar && pair) { \
copy_jmp_address((*_PREG)->u.ollll.l1); \
(*_PREG) = (*_PREG)->u.ollll.l1; \
(*_SREG) = RepPair(d0); \
ALWAYS_GONext(); \
}
#else
#define SWITCH_LIST_NL_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
ALWAYS_LOOKAHEAD((*_PREG)->u.ollll.pop); \
d0 = CACHED_A1(); \
Int nonvar = 0; \
if (IsVarTerm(d0)) { \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
copy_jmp_address((*_PREG)->u.ollll.l4); \
(*_PREG) = (*_PREG)->u.ollll.l4; \
JMPNext(); \
} \
} \
if (nonvar) { \
if (__builtin_expect(IsPairTerm(d0),1)) { \
copy_jmp_address((*_PREG)->u.ollll.l1); \
(*_PREG) = (*_PREG)->u.ollll.l1; \
(*_SREG) = RepPair(d0); \
ALWAYS_GONext(); \
} \
if (d0 == TermNil) { \
(*_PREG) = (*_PREG)->u.ollll.l2; \
JMPNext(); \
} \
else { \
if (IsApplTerm(d0)) { \
copy_jmp_address((*_PREG)->u.ollll.l3); \
(*_PREG) = (*_PREG)->u.ollll.l3; \
(*_SREG) = RepAppl(d0); \
JMPNext(); \
} else { \
copy_jmp_address((*_PREG)->u.ollll.l3); \
(*_PREG) = (*_PREG)->u.ollll.l3; \
I_R = d0; \
JMPNext(); \
} \
} \
}
#endif
#define SWITCH_LIST_NL_END \
BLOCK = (CELL)SWITCH_LIST_NL_END;
#define SWITCH_ON_ARG_TYPE_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = XREG((*_PREG)->u.xllll.x); \
Int nonvar = 1; \
if (IsVarTerm(d0)) { \
nonvar = 0; \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
copy_jmp_address((*_PREG)->u.xllll.l4); \
(*_PREG) = (*_PREG)->u.xllll.l4; \
JMPNext(); \
} \
} \
if (nonvar) { \
if (IsPairTerm(d0)) { \
copy_jmp_address((*_PREG)->u.xllll.l1); \
(*_PREG) = (*_PREG)->u.xllll.l1; \
(*_SREG) = RepPair(d0); \
JMPNext(); \
} \
else if (!IsApplTerm(d0)) { \
copy_jmp_address((*_PREG)->u.xllll.l2); \
(*_PREG) = (*_PREG)->u.xllll.l2; \
I_R = d0; \
JMPNext(); \
} \
else { \
copy_jmp_address((*_PREG)->u.xllll.l3); \
(*_PREG) = (*_PREG)->u.xllll.l3; \
(*_SREG) = RepAppl(d0); \
JMPNext(); \
} \
}
#define SWITCH_ON_ARG_TYPE_END \
BLOCK = (CELL)SWITCH_ON_ARG_TYPE_END;
#define SWITCH_ON_SUB_ARG_TYPE_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = (*_SREG)[(*_PREG)->u.sllll.s]; \
Int nonvar = 1; \
if (IsVarTerm(d0)) { \
nonvar = 0; \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
copy_jmp_address((*_PREG)->u.sllll.l4); \
(*_PREG) = (*_PREG)->u.sllll.l4; \
JMPNext(); \
} \
} \
if (nonvar) { \
if (IsPairTerm(d0)) { \
copy_jmp_address((*_PREG)->u.sllll.l1); \
(*_PREG) = (*_PREG)->u.sllll.l1; \
(*_SREG) = RepPair(d0); \
JMPNext(); \
} \
else if (!IsApplTerm(d0)) { \
copy_jmp_address((*_PREG)->u.sllll.l2); \
(*_PREG) = (*_PREG)->u.sllll.l2; \
I_R = d0; \
JMPNext(); \
} \
else { \
copy_jmp_address((*_PREG)->u.sllll.l3); \
(*_PREG) = (*_PREG)->u.sllll.l3; \
(*_SREG) = RepAppl(d0); \
JMPNext(); \
} \
}
#define SWITCH_ON_SUB_ARG_TYPE_END \
BLOCK = (CELL)SWITCH_ON_SUB_ARG_TYPE_END;
#define JUMP_IF_VAR_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = CACHED_A1(); \
Int nonvar = 1; \
if (IsVarTerm(d0)) { \
nonvar = 0; \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
copy_jmp_address((*_PREG)->u.l.l); \
(*_PREG) = (*_PREG)->u.l.l; \
JMPNext(); \
} \
} \
if (nonvar) { \
(*_PREG) = NEXTOP((*_PREG), l); \
JMPNext(); \
}
#define JUMP_IF_VAR_END \
BLOCK = (CELL)JUMP_IF_VAR_END;
#define JUMP_IF_NONVAR_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = XREG((*_PREG)->u.xll.x); \
Int nonvar = 0; \
if (IsVarTerm(d0)) { \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
(*_PREG) = NEXTOP((*_PREG), xll); \
JMPNext(); \
} \
} \
if (nonvar) { \
copy_jmp_address((*_PREG)->u.xll.l1); \
(*_PREG) = (*_PREG)->u.xll.l1; \
JMPNext(); \
}
#define JUMP_IF_NONVAR_END \
BLOCK = (CELL)JUMP_IF_NONVAR_END;
#define IF_NOT_THEN_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = CACHED_A1(); \
Int nonvar = 1; \
if (IsVarTerm(d0)) { \
nonvar = 0; \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
copy_jmp_address((*_PREG)->u.clll.l3); \
(*_PREG) = (*_PREG)->u.clll.l3; \
JMPNext(); \
} \
} \
if (nonvar) { \
if (d0 == (*_PREG)->u.clll.c) { \
copy_jmp_address((*_PREG)->u.clll.l2); \
(*_PREG) = (*_PREG)->u.clll.l2; \
JMPNext(); \
} \
else { \
copy_jmp_address((*_PREG)->u.clll.l1); \
(*_PREG) = (*_PREG)->u.clll.l1; \
JMPNext(); \
} \
}
#define IF_NOT_THEN_END \
BLOCK = (CELL)IF_NOT_THEN_END;
#define HRASH_SHIFT 6
#define SWITCH_ON_FUNC_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0, d1; \
register CELL *pt0; \
d1 = *(*_SREG)++; \
{ \
CELL \
Mask = ((*_PREG)->u.sssl.s - 1) << 1, \
hash = d1 >> (HRASH_SHIFT - 1) & Mask; \
CELL *base; \
base = (CELL *)(*_PREG)->u.sssl.l; \
pt0 = base + hash; \
d0 = pt0[0]; \
if (d0 == d1 || d0 == 0) { \
copy_jmp_addressa(pt0+1); \
(*_PREG) = (yamop *) (pt0[1]); \
JMPNext(); \
} \
else { \
register CELL d = ((d1 | 1) << 1) & Mask; \
while (1) { \
hash = (hash + d) & Mask; \
pt0 = base + hash; \
d0 = pt0[0]; \
if (d0 == d1 || d0 == 0) { \
copy_jmp_addressa(pt0+1); \
(*_PREG) = (yamop *) pt0[1]; \
break; \
} \
} \
} \
}
#define SWITCH_ON_FUNC_END \
BLOCK = (CELL)SWITCH_ON_FUNC_END;
#define SWITCH_ON_CONS_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0, d1; \
register CELL *pt0; \
d1 = I_R; \
{ \
CELL \
Mask = ((*_PREG)->u.sssl.s - 1) << 1, \
hash = d1 >> (HRASH_SHIFT - 1) & Mask; \
CELL *base; \
base = (CELL *)(*_PREG)->u.sssl.l; \
pt0 = base + hash; \
d0 = pt0[0]; \
if (d0 == d1 || d0 == 0) { \
copy_jmp_addressa(pt0+1); \
(*_PREG) = (yamop *) (pt0[1]); \
JMPNext(); \
} \
else { \
register CELL d = ((d1 | 1) << 1) & Mask; \
while (1) { \
hash = (hash + d) & Mask; \
pt0 = base + hash; \
d0 = pt0[0]; \
if (d0 == d1 || d0 == 0) { \
copy_jmp_addressa(pt0+1); \
(*_PREG) = (yamop *) pt0[1]; \
break; \
} \
} \
} \
}
#define SWITCH_ON_CONS_END \
BLOCK = (CELL)SWITCH_ON_CONS_END;
#define GO_ON_FUNC_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
{ \
CELL *pt = (CELL *)((*_PREG)->u.sssl.l); \
d0 = *(*_SREG)++; \
if (d0 == pt[0]) { \
copy_jmp_addressa(pt+1); \
(*_PREG) = (yamop *) pt[1]; \
JMPNext(); \
} else { \
copy_jmp_addressa(pt+3); \
(*_PREG) = (yamop *) pt[3]; \
JMPNext(); \
} \
}
#define GO_ON_FUNC_END \
BLOCK = (CELL)GO_ON_FUNC_END;
#define GO_ON_CONS_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
{ \
CELL *pt = (CELL *)((*_PREG)->u.sssl.l); \
d0 = I_R; \
if (d0 == pt[0]) { \
copy_jmp_addressa(pt+1); \
(*_PREG) = (yamop *) pt[1]; \
JMPNext(); \
} else { \
copy_jmp_addressa(pt+3); \
(*_PREG) = (yamop *) pt[3]; \
JMPNext(); \
} \
}
#define GO_ON_CONS_END \
BLOCK = (CELL)GO_ON_CONS_END;
#define IF_FUNC_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d1; \
register CELL *pt0; \
pt0 = (CELL *) (*_PREG)->u.sssl.l; \
d1 = *(*_SREG)++; \
while (pt0[0] != d1 && pt0[0] != (CELL)NULL ) { \
pt0 += 2; \
} \
copy_jmp_addressa(pt0+1); \
(*_PREG) = (yamop *) (pt0[1]); \
JMPNext();
#define IF_FUNC_END \
BLOCK = (CELL)IF_FUNC_END;
#define IF_CONS_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d1; \
register CELL *pt0; \
pt0 = (CELL *) (*_PREG)->u.sssl.l; \
d1 = I_R; \
while (pt0[0] != d1 && pt0[0] != 0L ) { \
pt0 += 2; \
} \
copy_jmp_addressa(pt0+1); \
(*_PREG) = (yamop *) (pt0[1]); \
JMPNext();
#define IF_CONS_END \
BLOCK = (CELL)IF_CONS_END;
#define INDEX_DBREF_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
(*_PREG) = NEXTOP((*_PREG), e); \
I_R = AbsAppl((*_SREG)-1); \
GONext();
#define INDEX_DBREF_END \
BLOCK = (CELL)INDEX_DBREF_END;
#define INDEX_BLOB_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
(*_PREG) = NEXTOP((*_PREG), e); \
I_R = Yap_DoubleP_key((*_SREG)); \
GONext();
#define INDEX_BLOB_END \
BLOCK = (CELL)INDEX_BLOB_END;
#define INDEX_LONG_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
(*_PREG) = NEXTOP((*_PREG), e); \
I_R = Yap_IntP_key((*_SREG)); \
GONext();
#define INDEX_LONG_END \
BLOCK = (CELL)INDEX_LONG_INSTINIT;

563
JIT/HPP/indexing_ext_d.h Normal file
View File

@ -0,0 +1,563 @@
#define USER_SWITCH_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
{ \
yamop *new = Yap_udi_search((*_PREG)->u.lp.p); \
if (!new) { \
(*_PREG) = (*_PREG)->u.lp.l; \
JMPNext(); \
} \
else { \
(*_PREG) = new; \
JMPNext(); \
} \
}
#define USER_SWITCH_END \
BLOCK = (CELL)USER_SWITCH_END;
#define SWITCH_ON_TYPE_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = CACHED_A1(); \
Int nonvar = 1; \
if (IsVarTerm(d0)) { \
nonvar = 0; \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
copy_jmp_address((*_PREG)->u.llll.l4); \
(*_PREG) = (*_PREG)->u.llll.l4; \
JMPNext(); \
} \
} \
if (nonvar) { \
if (IsPairTerm(d0)) { \
(*_SREG) = RepPair(d0); \
copy_jmp_address((*_PREG)->u.llll.l1); \
(*_PREG) = (*_PREG)->u.llll.l1; \
JMPNext(); \
} \
else if (!IsApplTerm(d0)) { \
copy_jmp_address((*_PREG)->u.llll.l2); \
(*_PREG) = (*_PREG)->u.llll.l2; \
I_R = d0; \
JMPNext(); \
} \
else { \
copy_jmp_address((*_PREG)->u.llll.l3); \
(*_PREG) = (*_PREG)->u.llll.l3; \
(*_SREG) = RepAppl(d0); \
JMPNext(); \
} \
}
#define SWITCH_ON_TYPE_END \
BLOCK = (CELL)SWITCH_ON_TYPE_END;
#if UNIQUE_TAG_FOR_PAIRS
#define SWITCH_LIST_NL_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
ALWAYS_LOOKAHEAD((*_PREG)->u.ollll.pop); \
d0 = CACHED_A1(); \
Int nonvar = 0; \
Int pair = 1; \
if (!IsPairTerm(d0)) { \
pair = 0; \
do { \
if (!IsVarTerm(d0)) { \
if (d0 == TermNil) { \
(*_PREG) = (*_PREG)->u.ollll.l2; \
JMPNext(); \
} \
else { \
if (IsApplTerm(d0)) { \
copy_jmp_address((*_PREG)->u.ollll.l3); \
(*_PREG) = (*_PREG)->u.ollll.l3; \
(*_SREG) = RepAppl(d0); \
JMPNext(); \
} else { \
copy_jmp_address((*_PREG)->u.ollll.l3); \
(*_PREG) = (*_PREG)->u.ollll.l3; \
I_R = d0; \
JMPNext(); \
} \
} \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(pt0); \
if (Unsigned(pt0) == (d0)) break; \
if (IsPairTerm(d0)) { \
pair = 1; \
break; \
} \
} while (TRUE); \
if (!nonvar && !pair) { \
copy_jmp_address((*_PREG)->u.ollll.l4); \
(*_PREG) = (*_PREG)->u.ollll.l4; \
JMPNext(); \
} \
} \
if (!nonvar && pair) { \
copy_jmp_address((*_PREG)->u.ollll.l1); \
(*_PREG) = (*_PREG)->u.ollll.l1; \
(*_SREG) = RepPair(d0); \
ALWAYS_GONext(); \
}
#else
#define SWITCH_LIST_NL_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
ALWAYS_LOOKAHEAD((*_PREG)->u.ollll.pop); \
d0 = CACHED_A1(); \
Int nonvar = 0; \
if (IsVarTerm(d0)) { \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
copy_jmp_address((*_PREG)->u.ollll.l4); \
(*_PREG) = (*_PREG)->u.ollll.l4; \
JMPNext(); \
} \
} \
if (nonvar) { \
if (__builtin_expect(IsPairTerm(d0),1)) { \
copy_jmp_address((*_PREG)->u.ollll.l1); \
(*_PREG) = (*_PREG)->u.ollll.l1; \
(*_SREG) = RepPair(d0); \
ALWAYS_GONext(); \
} \
if (d0 == TermNil) { \
(*_PREG) = (*_PREG)->u.ollll.l2; \
JMPNext(); \
} \
else { \
if (IsApplTerm(d0)) { \
copy_jmp_address((*_PREG)->u.ollll.l3); \
(*_PREG) = (*_PREG)->u.ollll.l3; \
(*_SREG) = RepAppl(d0); \
JMPNext(); \
} else { \
copy_jmp_address((*_PREG)->u.ollll.l3); \
(*_PREG) = (*_PREG)->u.ollll.l3; \
I_R = d0; \
JMPNext(); \
} \
} \
}
#endif
#define SWITCH_LIST_NL_END \
BLOCK = (CELL)SWITCH_LIST_NL_END;
#define SWITCH_ON_ARG_TYPE_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = XREG((*_PREG)->u.xllll.x); \
Int nonvar = 1; \
if (IsVarTerm(d0)) { \
nonvar = 0; \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
copy_jmp_address((*_PREG)->u.xllll.l4); \
(*_PREG) = (*_PREG)->u.xllll.l4; \
JMPNext(); \
} \
} \
if (nonvar) { \
if (IsPairTerm(d0)) { \
copy_jmp_address((*_PREG)->u.xllll.l1); \
(*_PREG) = (*_PREG)->u.xllll.l1; \
(*_SREG) = RepPair(d0); \
JMPNext(); \
} \
else if (!IsApplTerm(d0)) { \
copy_jmp_address((*_PREG)->u.xllll.l2); \
(*_PREG) = (*_PREG)->u.xllll.l2; \
I_R = d0; \
JMPNext(); \
} \
else { \
copy_jmp_address((*_PREG)->u.xllll.l3); \
(*_PREG) = (*_PREG)->u.xllll.l3; \
(*_SREG) = RepAppl(d0); \
JMPNext(); \
} \
}
#define SWITCH_ON_ARG_TYPE_END \
BLOCK = (CELL)SWITCH_ON_ARG_TYPE_END;
#define SWITCH_ON_SUB_ARG_TYPE_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = (*_SREG)[(*_PREG)->u.sllll.s]; \
Int nonvar = 1; \
if (IsVarTerm(d0)) { \
nonvar = 0; \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
copy_jmp_address((*_PREG)->u.sllll.l4); \
(*_PREG) = (*_PREG)->u.sllll.l4; \
JMPNext(); \
} \
} \
if (nonvar) { \
if (IsPairTerm(d0)) { \
copy_jmp_address((*_PREG)->u.sllll.l1); \
(*_PREG) = (*_PREG)->u.sllll.l1; \
(*_SREG) = RepPair(d0); \
JMPNext(); \
} \
else if (!IsApplTerm(d0)) { \
copy_jmp_address((*_PREG)->u.sllll.l2); \
(*_PREG) = (*_PREG)->u.sllll.l2; \
I_R = d0; \
JMPNext(); \
} \
else { \
copy_jmp_address((*_PREG)->u.sllll.l3); \
(*_PREG) = (*_PREG)->u.sllll.l3; \
(*_SREG) = RepAppl(d0); \
JMPNext(); \
} \
}
#define SWITCH_ON_SUB_ARG_TYPE_END \
BLOCK = (CELL)SWITCH_ON_SUB_ARG_TYPE_END;
#define JUMP_IF_VAR_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = CACHED_A1(); \
Int nonvar = 1; \
if (IsVarTerm(d0)) { \
nonvar = 0; \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
copy_jmp_address((*_PREG)->u.l.l); \
(*_PREG) = (*_PREG)->u.l.l; \
JMPNext(); \
} \
} \
if (nonvar) { \
(*_PREG) = NEXTOP((*_PREG), l); \
JMPNext(); \
}
#define JUMP_IF_VAR_END \
BLOCK = (CELL)JUMP_IF_VAR_END;
#define JUMP_IF_NONVAR_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = XREG((*_PREG)->u.xll.x); \
Int nonvar = 0; \
if (IsVarTerm(d0)) { \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
(*_PREG) = NEXTOP((*_PREG), xll); \
JMPNext(); \
} \
} \
if (nonvar) { \
copy_jmp_address((*_PREG)->u.xll.l1); \
(*_PREG) = (*_PREG)->u.xll.l1; \
JMPNext(); \
}
#define JUMP_IF_NONVAR_END \
BLOCK = (CELL)JUMP_IF_NONVAR_END;
#define IF_NOT_THEN_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = CACHED_A1(); \
Int nonvar = 1; \
if (IsVarTerm(d0)) { \
nonvar = 0; \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
copy_jmp_address((*_PREG)->u.clll.l3); \
(*_PREG) = (*_PREG)->u.clll.l3; \
JMPNext(); \
} \
} \
if (nonvar) { \
if (d0 == (*_PREG)->u.clll.c) { \
copy_jmp_address((*_PREG)->u.clll.l2); \
(*_PREG) = (*_PREG)->u.clll.l2; \
JMPNext(); \
} \
else { \
copy_jmp_address((*_PREG)->u.clll.l1); \
(*_PREG) = (*_PREG)->u.clll.l1; \
JMPNext(); \
} \
}
#define IF_NOT_THEN_END \
BLOCK = (CELL)IF_NOT_THEN_END;
#define HRASH_SHIFT 6
#define SWITCH_ON_FUNC_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0, d1; \
register CELL *pt0; \
d1 = *(*_SREG)++; \
{ \
CELL \
Mask = ((*_PREG)->u.sssl.s - 1) << 1, \
hash = d1 >> (HRASH_SHIFT - 1) & Mask; \
CELL *base; \
base = (CELL *)(*_PREG)->u.sssl.l; \
pt0 = base + hash; \
d0 = pt0[0]; \
if (d0 == d1 || d0 == 0) { \
copy_jmp_addressa(pt0+1); \
(*_PREG) = (yamop *) (pt0[1]); \
JMPNext(); \
} \
else { \
register CELL d = ((d1 | 1) << 1) & Mask; \
while (1) { \
hash = (hash + d) & Mask; \
pt0 = base + hash; \
d0 = pt0[0]; \
if (d0 == d1 || d0 == 0) { \
copy_jmp_addressa(pt0+1); \
(*_PREG) = (yamop *) pt0[1]; \
break; \
} \
} \
} \
}
#define SWITCH_ON_FUNC_END \
BLOCK = (CELL)SWITCH_ON_FUNC_END;
#define SWITCH_ON_CONS_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0, d1; \
register CELL *pt0; \
d1 = I_R; \
{ \
CELL \
Mask = ((*_PREG)->u.sssl.s - 1) << 1, \
hash = d1 >> (HRASH_SHIFT - 1) & Mask; \
CELL *base; \
base = (CELL *)(*_PREG)->u.sssl.l; \
pt0 = base + hash; \
d0 = pt0[0]; \
if (d0 == d1 || d0 == 0) { \
copy_jmp_addressa(pt0+1); \
(*_PREG) = (yamop *) (pt0[1]); \
JMPNext(); \
} \
else { \
register CELL d = ((d1 | 1) << 1) & Mask; \
while (1) { \
hash = (hash + d) & Mask; \
pt0 = base + hash; \
d0 = pt0[0]; \
if (d0 == d1 || d0 == 0) { \
copy_jmp_addressa(pt0+1); \
(*_PREG) = (yamop *) pt0[1]; \
break; \
} \
} \
} \
}
#define SWITCH_ON_CONS_END \
BLOCK = (CELL)SWITCH_ON_CONS_END;
#define GO_ON_FUNC_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
{ \
CELL *pt = (CELL *)((*_PREG)->u.sssl.l); \
d0 = *(*_SREG)++; \
if (d0 == pt[0]) { \
copy_jmp_addressa(pt+1); \
(*_PREG) = (yamop *) pt[1]; \
JMPNext(); \
} else { \
copy_jmp_addressa(pt+3); \
(*_PREG) = (yamop *) pt[3]; \
JMPNext(); \
} \
}
#define GO_ON_FUNC_END \
BLOCK = (CELL)GO_ON_FUNC_END;
#define GO_ON_CONS_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
{ \
CELL *pt = (CELL *)((*_PREG)->u.sssl.l); \
d0 = I_R; \
if (d0 == pt[0]) { \
copy_jmp_addressa(pt+1); \
(*_PREG) = (yamop *) pt[1]; \
JMPNext(); \
} else { \
copy_jmp_addressa(pt+3); \
(*_PREG) = (yamop *) pt[3]; \
JMPNext(); \
} \
}
#define GO_ON_CONS_END \
BLOCK = (CELL)GO_ON_CONS_END;
#define IF_FUNC_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d1; \
register CELL *pt0; \
pt0 = (CELL *) (*_PREG)->u.sssl.l; \
d1 = *(*_SREG)++; \
while (pt0[0] != d1 && pt0[0] != (CELL)NULL ) { \
pt0 += 2; \
} \
copy_jmp_addressa(pt0+1); \
(*_PREG) = (yamop *) (pt0[1]); \
JMPNext();
#define IF_FUNC_END \
BLOCK = (CELL)IF_FUNC_END;
#define IF_CONS_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d1; \
register CELL *pt0; \
pt0 = (CELL *) (*_PREG)->u.sssl.l; \
d1 = I_R; \
while (pt0[0] != d1 && pt0[0] != 0L ) { \
pt0 += 2; \
} \
copy_jmp_addressa(pt0+1); \
(*_PREG) = (yamop *) (pt0[1]); \
JMPNext();
#define IF_CONS_END \
BLOCK = (CELL)IF_CONS_END;
#define INDEX_DBREF_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
(*_PREG) = NEXTOP((*_PREG), e); \
I_R = AbsAppl((*_SREG)-1); \
GONext();
#define INDEX_DBREF_END \
BLOCK = (CELL)INDEX_DBREF_END;
#define INDEX_BLOB_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
(*_PREG) = NEXTOP((*_PREG), e); \
I_R = Yap_DoubleP_key((*_SREG)); \
GONext();
#define INDEX_BLOB_END \
BLOCK = (CELL)INDEX_BLOB_END;
#define INDEX_LONG_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
(*_PREG) = NEXTOP((*_PREG), e); \
I_R = Yap_IntP_key((*_SREG)); \
GONext();
#define INDEX_LONG_END \
BLOCK = (CELL)INDEX_LONG_INSTINIT;

1316
JIT/HPP/indexing_std.h Normal file

File diff suppressed because it is too large Load Diff

1350
JIT/HPP/indexing_std_d.h Normal file

File diff suppressed because it is too large Load Diff

45
JIT/HPP/jit_predicates.hh Normal file
View File

@ -0,0 +1,45 @@
#include "Yap.h"
#include "clause.h"
#include "eval.h"
#if HRAVE_ERRNO_H
#include <errno.h>
#else
extern int errno;
#endif
#include <string.h>
#include <ctype.h>
#define UPPER_ENTRY(S) \
tmp = (char*)malloc((strlen(S)+1)*sizeof(char)); \
while (S[i]) { \
if (S[i] != '-' && S[i] != '_' && S[i] != ' ') { \
if ((S[i] >= '0' && S[i] <= '9') || (S[i] == '.')) \
tmp[j] = S[i]; \
else \
tmp[j] = toupper(S[i]); \
j++; \
} \
i++; \
} \
tmp[j] = 0; \
strcpy(S, tmp); \
free(tmp);
#if YAP_JIT
void Yap_InitJitAnalysisPreds( void );
void Yap_InitJitCodegenPreds( void );
void Yap_InitJitConfigPreds( void );
void Yap_InitJitTransformPreds( void );
#if YAP_STAT_PREDS
void Yap_InitJitStatisticPreds( void );
#endif
#endif /* YAP_JIT */
#if YAP_DBG_PREDS
void Yap_InitJitDebugPreds( void );
#endif
Environment ExpEnv;
#if YAP_JIT
extern NativeContext *NativeArea;
extern IntermediatecodeContext *IntermediatecodeArea;
#endif

2398
JIT/HPP/lastop.h Normal file

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More