indenting
This commit is contained in:
parent
7f8ebe18d0
commit
d6148eb8ad
307
C/adtdefs.c
307
C/adtdefs.c
@ -36,22 +36,20 @@ static char SccsId[] = "%W% %G%";
|
|||||||
|
|
||||||
/* this routine must be run at least having a read lock on ae */
|
/* this routine must be run at least having a read lock on ae */
|
||||||
static Prop
|
static Prop
|
||||||
GetFunctorProp(AtomEntry *ae, unsigned int arity)
|
GetFunctorProp(AtomEntry *ae,
|
||||||
{ /* look property list of atom a for kind */
|
unsigned int arity) { /* look property list of atom a for kind */
|
||||||
FunctorEntry *pp;
|
FunctorEntry *pp;
|
||||||
|
|
||||||
pp = RepFunctorProp(ae->PropsOfAE);
|
pp = RepFunctorProp(ae->PropsOfAE);
|
||||||
while (!EndOfPAEntr(pp) &&
|
while (!EndOfPAEntr(pp) &&
|
||||||
(!IsFunctorProperty(pp->KindOfPE) ||
|
(!IsFunctorProperty(pp->KindOfPE) || pp->ArityOfFE != arity))
|
||||||
pp->ArityOfFE != arity))
|
|
||||||
pp = RepFunctorProp(pp->NextOfPE);
|
pp = RepFunctorProp(pp->NextOfPE);
|
||||||
return (AbsFunctorProp(pp));
|
return (AbsFunctorProp(pp));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vsc: We must guarantee that IsVarTerm(functor) returns true! */
|
/* vsc: We must guarantee that IsVarTerm(functor) returns true! */
|
||||||
static inline Functor
|
static inline Functor InlinedUnlockedMkFunctor(AtomEntry *ae,
|
||||||
InlinedUnlockedMkFunctor(AtomEntry *ae, unsigned int arity)
|
unsigned int arity) {
|
||||||
{
|
|
||||||
FunctorEntry *p;
|
FunctorEntry *p;
|
||||||
Prop p0;
|
Prop p0;
|
||||||
|
|
||||||
@ -72,16 +70,12 @@ InlinedUnlockedMkFunctor(AtomEntry *ae, unsigned int arity)
|
|||||||
return ((Functor)p);
|
return ((Functor)p);
|
||||||
}
|
}
|
||||||
|
|
||||||
Functor
|
Functor Yap_UnlockedMkFunctor(AtomEntry *ae, unsigned int arity) {
|
||||||
Yap_UnlockedMkFunctor(AtomEntry *ae, unsigned int arity)
|
|
||||||
{
|
|
||||||
return (InlinedUnlockedMkFunctor(ae, arity));
|
return (InlinedUnlockedMkFunctor(ae, arity));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vsc: We must guarantee that IsVarTerm(functor) returns true! */
|
/* vsc: We must guarantee that IsVarTerm(functor) returns true! */
|
||||||
Functor
|
Functor Yap_MkFunctor(Atom ap, unsigned int arity) {
|
||||||
Yap_MkFunctor(Atom ap, unsigned int arity)
|
|
||||||
{
|
|
||||||
AtomEntry *ae = RepAtom(ap);
|
AtomEntry *ae = RepAtom(ap);
|
||||||
Functor f;
|
Functor f;
|
||||||
|
|
||||||
@ -92,9 +86,7 @@ Yap_MkFunctor(Atom ap, unsigned int arity)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* vsc: We must guarantee that IsVarTerm(functor) returns true! */
|
/* vsc: We must guarantee that IsVarTerm(functor) returns true! */
|
||||||
void
|
void Yap_MkFunctorWithAddress(Atom ap, unsigned int arity, FunctorEntry *p) {
|
||||||
Yap_MkFunctorWithAddress(Atom ap, unsigned int arity, FunctorEntry *p)
|
|
||||||
{
|
|
||||||
AtomEntry *ae = RepAtom(ap);
|
AtomEntry *ae = RepAtom(ap);
|
||||||
|
|
||||||
WRITE_LOCK(ae->ARWLock);
|
WRITE_LOCK(ae->ARWLock);
|
||||||
@ -105,9 +97,7 @@ Yap_MkFunctorWithAddress(Atom ap, unsigned int arity, FunctorEntry *p)
|
|||||||
WRITE_UNLOCK(ae->ARWLock);
|
WRITE_UNLOCK(ae->ARWLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static Atom
|
inline static Atom SearchInInvisible(const unsigned char *atom) {
|
||||||
SearchInInvisible(const unsigned char *atom)
|
|
||||||
{
|
|
||||||
AtomEntry *chain;
|
AtomEntry *chain;
|
||||||
|
|
||||||
READ_LOCK(INVISIBLECHAIN.AERWLock);
|
READ_LOCK(INVISIBLECHAIN.AERWLock);
|
||||||
@ -122,8 +112,7 @@ SearchInInvisible(const unsigned char *atom)
|
|||||||
return (AbsAtom(chain));
|
return (AbsAtom(chain));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Atom
|
static inline Atom SearchAtom(const unsigned char *p, Atom a) {
|
||||||
SearchAtom(const unsigned char *p, Atom a) {
|
|
||||||
AtomEntry *ae;
|
AtomEntry *ae;
|
||||||
|
|
||||||
/* search atom in chain */
|
/* search atom in chain */
|
||||||
@ -137,8 +126,7 @@ SearchAtom(const unsigned char *p, Atom a) {
|
|||||||
return (NIL);
|
return (NIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Atom
|
static inline Atom SearchWideAtom(const wchar_t *p, Atom a) {
|
||||||
SearchWideAtom(const wchar_t *p, Atom a) {
|
|
||||||
AtomEntry *ae;
|
AtomEntry *ae;
|
||||||
|
|
||||||
/* search atom in chain */
|
/* search atom in chain */
|
||||||
@ -153,8 +141,7 @@ SearchWideAtom(const wchar_t *p, Atom a) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Atom
|
static Atom
|
||||||
LookupAtom(const unsigned char *atom)
|
LookupAtom(const unsigned char *atom) { /* lookup atom in atom table */
|
||||||
{ /* lookup atom in atom table */
|
|
||||||
UInt hash;
|
UInt hash;
|
||||||
const unsigned char *p;
|
const unsigned char *p;
|
||||||
Atom a, na;
|
Atom a, na;
|
||||||
@ -188,7 +175,8 @@ LookupAtom(const unsigned char *atom)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* add new atom to start of chain */
|
/* add new atom to start of chain */
|
||||||
ae = (AtomEntry *) Yap_AllocAtomSpace((sizeof *ae) + strlen((const char *)atom) + 1);
|
ae = (AtomEntry *)Yap_AllocAtomSpace((sizeof *ae) +
|
||||||
|
strlen((const char *)atom) + 1);
|
||||||
if (ae == NULL) {
|
if (ae == NULL) {
|
||||||
WRITE_UNLOCK(HashChain[hash].AERWLock);
|
WRITE_UNLOCK(HashChain[hash].AERWLock);
|
||||||
return NIL;
|
return NIL;
|
||||||
@ -209,10 +197,8 @@ LookupAtom(const unsigned char *atom)
|
|||||||
return na;
|
return na;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Atom
|
static Atom
|
||||||
LookupWideAtom(const wchar_t *atom)
|
LookupWideAtom(const wchar_t *atom) { /* lookup atom in atom table */
|
||||||
{ /* lookup atom in atom table */
|
|
||||||
CELL hash;
|
CELL hash;
|
||||||
wchar_t *p;
|
wchar_t *p;
|
||||||
Atom a, na;
|
Atom a, na;
|
||||||
@ -248,7 +234,8 @@ LookupWideAtom(const wchar_t *atom)
|
|||||||
#endif
|
#endif
|
||||||
/* add new atom to start of chain */
|
/* add new atom to start of chain */
|
||||||
sz = wcslen(atom);
|
sz = wcslen(atom);
|
||||||
ae = (AtomEntry *) Yap_AllocAtomSpace((size_t)(((AtomEntry *)NULL)+1) + sizeof(wchar_t)*(sz + 1));
|
ae = (AtomEntry *)Yap_AllocAtomSpace((size_t)(((AtomEntry *)NULL) + 1) +
|
||||||
|
sizeof(wchar_t) * (sz + 1));
|
||||||
if (ae == NULL) {
|
if (ae == NULL) {
|
||||||
WRITE_UNLOCK(WideHashChain[hash].AERWLock);
|
WRITE_UNLOCK(WideHashChain[hash].AERWLock);
|
||||||
return NIL;
|
return NIL;
|
||||||
@ -277,16 +264,16 @@ LookupWideAtom(const wchar_t *atom)
|
|||||||
return na;
|
return na;
|
||||||
}
|
}
|
||||||
|
|
||||||
Atom
|
Atom Yap_LookupMaybeWideAtom(
|
||||||
Yap_LookupMaybeWideAtom(const wchar_t *atom)
|
const wchar_t *atom) { /* lookup atom in atom table */
|
||||||
{ /* lookup atom in atom table */
|
|
||||||
wchar_t *p = (wchar_t *)atom, c;
|
wchar_t *p = (wchar_t *)atom, c;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
unsigned char *ptr, *ptr0;
|
unsigned char *ptr, *ptr0;
|
||||||
Atom at;
|
Atom at;
|
||||||
|
|
||||||
while ((c = *p++)) {
|
while ((c = *p++)) {
|
||||||
if (c > 255) return LookupWideAtom(atom);
|
if (c > 255)
|
||||||
|
return LookupWideAtom(atom);
|
||||||
len++;
|
len++;
|
||||||
}
|
}
|
||||||
/* not really a wide atom */
|
/* not really a wide atom */
|
||||||
@ -294,15 +281,15 @@ Yap_LookupMaybeWideAtom(const wchar_t *atom)
|
|||||||
ptr0 = ptr = Yap_AllocCodeSpace(len + 1);
|
ptr0 = ptr = Yap_AllocCodeSpace(len + 1);
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
return NIL;
|
return NIL;
|
||||||
while ((*ptr++ = *p++));
|
while ((*ptr++ = *p++))
|
||||||
|
;
|
||||||
at = LookupAtom(ptr0);
|
at = LookupAtom(ptr0);
|
||||||
Yap_FreeCodeSpace(ptr0);
|
Yap_FreeCodeSpace(ptr0);
|
||||||
return at;
|
return at;
|
||||||
}
|
}
|
||||||
|
|
||||||
Atom
|
Atom Yap_LookupMaybeWideAtomWithLength(
|
||||||
Yap_LookupMaybeWideAtomWithLength(const wchar_t *atom, size_t len0)
|
const wchar_t *atom, size_t len0) { /* lookup atom in atom table */
|
||||||
{ /* lookup atom in atom table */
|
|
||||||
Atom at;
|
Atom at;
|
||||||
int wide = FALSE;
|
int wide = FALSE;
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
@ -346,9 +333,8 @@ Yap_LookupMaybeWideAtomWithLength(const wchar_t *atom, size_t len0)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Atom
|
Atom Yap_LookupAtomWithLength(const char *atom,
|
||||||
Yap_LookupAtomWithLength(const char *atom, size_t len0)
|
size_t len0) { /* lookup atom in atom table */
|
||||||
{ /* lookup atom in atom table */
|
|
||||||
Atom at;
|
Atom at;
|
||||||
unsigned char *ptr;
|
unsigned char *ptr;
|
||||||
|
|
||||||
@ -363,27 +349,20 @@ Yap_LookupAtomWithLength(const char *atom, size_t len0)
|
|||||||
return at;
|
return at;
|
||||||
}
|
}
|
||||||
|
|
||||||
Atom
|
Atom Yap_LookupAtom(const char *atom) { /* lookup atom in atom table */
|
||||||
Yap_LookupAtom(const char *atom)
|
|
||||||
{ /* lookup atom in atom table */
|
|
||||||
return LookupAtom((const unsigned char *)atom);
|
return LookupAtom((const unsigned char *)atom);
|
||||||
}
|
}
|
||||||
|
|
||||||
Atom
|
Atom Yap_ULookupAtom(
|
||||||
Yap_ULookupAtom(const unsigned char *atom)
|
const unsigned char *atom) { /* lookup atom in atom table */
|
||||||
{ /* lookup atom in atom table */
|
|
||||||
return LookupAtom(atom);
|
return LookupAtom(atom);
|
||||||
}
|
}
|
||||||
|
|
||||||
Atom
|
Atom Yap_LookupWideAtom(const wchar_t *atom) { /* lookup atom in atom table */
|
||||||
Yap_LookupWideAtom(const wchar_t *atom)
|
|
||||||
{ /* lookup atom in atom table */
|
|
||||||
return LookupWideAtom(atom);
|
return LookupWideAtom(atom);
|
||||||
}
|
}
|
||||||
|
|
||||||
Atom
|
Atom Yap_FullLookupAtom(const char *atom) { /* lookup atom in atom table */
|
||||||
Yap_FullLookupAtom(const char *atom)
|
|
||||||
{ /* lookup atom in atom table */
|
|
||||||
Atom t;
|
Atom t;
|
||||||
|
|
||||||
if ((t = SearchInInvisible((const unsigned char *)atom)) != NIL) {
|
if ((t = SearchInInvisible((const unsigned char *)atom)) != NIL) {
|
||||||
@ -392,10 +371,8 @@ Yap_FullLookupAtom(const char *atom)
|
|||||||
return (LookupAtom((const unsigned char *)atom));
|
return (LookupAtom((const unsigned char *)atom));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void Yap_LookupAtomWithAddress(const char *atom,
|
||||||
Yap_LookupAtomWithAddress(const char *atom,
|
AtomEntry *ae) { /* lookup atom in atom table */
|
||||||
AtomEntry *ae)
|
|
||||||
{ /* lookup atom in atom table */
|
|
||||||
register CELL hash;
|
register CELL hash;
|
||||||
register const unsigned char *p;
|
register const unsigned char *p;
|
||||||
Atom a;
|
Atom a;
|
||||||
@ -403,12 +380,14 @@ Yap_LookupAtomWithAddress(const char *atom,
|
|||||||
/* compute hash */
|
/* compute hash */
|
||||||
p = (const unsigned char *)atom;
|
p = (const unsigned char *)atom;
|
||||||
hash = HashFunction(p) % AtomHashTableSize;
|
hash = HashFunction(p) % AtomHashTableSize;
|
||||||
/* ask for a WRITE lock because it is highly unlikely we shall find anything */
|
/* ask for a WRITE lock because it is highly unlikely we shall find anything
|
||||||
|
*/
|
||||||
WRITE_LOCK(HashChain[hash].AERWLock);
|
WRITE_LOCK(HashChain[hash].AERWLock);
|
||||||
a = HashChain[hash].Entry;
|
a = HashChain[hash].Entry;
|
||||||
/* search atom in chain */
|
/* search atom in chain */
|
||||||
if (SearchAtom(p, a) != NIL) {
|
if (SearchAtom(p, a) != NIL) {
|
||||||
Yap_Error(SYSTEM_ERROR_INTERNAL,TermNil,"repeated initialisation for atom %s", ae);
|
Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
|
||||||
|
"repeated initialization for atom %s", ae);
|
||||||
WRITE_UNLOCK(HashChain[hash].AERWLock);
|
WRITE_UNLOCK(HashChain[hash].AERWLock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -422,9 +401,7 @@ Yap_LookupAtomWithAddress(const char *atom,
|
|||||||
WRITE_UNLOCK(HashChain[hash].AERWLock);
|
WRITE_UNLOCK(HashChain[hash].AERWLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void Yap_ReleaseAtom(Atom atom) { /* Releases an atom from the hash chain */
|
||||||
Yap_ReleaseAtom(Atom atom)
|
|
||||||
{ /* Releases an atom from the hash chain */
|
|
||||||
register Int hash;
|
register Int hash;
|
||||||
register const unsigned char *p;
|
register const unsigned char *p;
|
||||||
AtomEntry *inChain;
|
AtomEntry *inChain;
|
||||||
@ -452,8 +429,8 @@ Yap_ReleaseAtom(Atom atom)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Prop
|
static Prop
|
||||||
GetAPropHavingLock(AtomEntry *ae, PropFlags kind)
|
GetAPropHavingLock(AtomEntry *ae,
|
||||||
{ /* look property list of atom a for kind */
|
PropFlags kind) { /* look property list of atom a for kind */
|
||||||
PropEntry *pp;
|
PropEntry *pp;
|
||||||
|
|
||||||
pp = RepProp(ae->PropsOfAE);
|
pp = RepProp(ae->PropsOfAE);
|
||||||
@ -462,15 +439,13 @@ GetAPropHavingLock(AtomEntry *ae, PropFlags kind)
|
|||||||
return (AbsProp(pp));
|
return (AbsProp(pp));
|
||||||
}
|
}
|
||||||
|
|
||||||
Prop
|
Prop Yap_GetAPropHavingLock(
|
||||||
Yap_GetAPropHavingLock(AtomEntry *ae, PropFlags kind)
|
AtomEntry *ae, PropFlags kind) { /* look property list of atom a for kind */
|
||||||
{ /* look property list of atom a for kind */
|
|
||||||
return GetAPropHavingLock(ae, kind);
|
return GetAPropHavingLock(ae, kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Prop
|
static Prop
|
||||||
GetAProp(Atom a, PropFlags kind)
|
GetAProp(Atom a, PropFlags kind) { /* look property list of atom a for kind */
|
||||||
{ /* look property list of atom a for kind */
|
|
||||||
AtomEntry *ae = RepAtom(a);
|
AtomEntry *ae = RepAtom(a);
|
||||||
Prop out;
|
Prop out;
|
||||||
|
|
||||||
@ -480,22 +455,19 @@ GetAProp(Atom a, PropFlags kind)
|
|||||||
return (out);
|
return (out);
|
||||||
}
|
}
|
||||||
|
|
||||||
Prop
|
Prop Yap_GetAProp(Atom a,
|
||||||
Yap_GetAProp(Atom a, PropFlags kind)
|
PropFlags kind) { /* look property list of atom a for kind */
|
||||||
{ /* look property list of atom a for kind */
|
|
||||||
return GetAProp(a, kind);
|
return GetAProp(a, kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
OpEntry *
|
OpEntry *Yap_GetOpPropForAModuleHavingALock(
|
||||||
Yap_GetOpPropForAModuleHavingALock(Atom a, Term mod)
|
Atom a, Term mod) { /* look property list of atom a for kind */
|
||||||
{ /* look property list of atom a for kind */
|
|
||||||
AtomEntry *ae = RepAtom(a);
|
AtomEntry *ae = RepAtom(a);
|
||||||
PropEntry *pp;
|
PropEntry *pp;
|
||||||
|
|
||||||
pp = RepProp(ae->PropsOfAE);
|
pp = RepProp(ae->PropsOfAE);
|
||||||
while (!EndOfPAEntr(pp) &&
|
while (!EndOfPAEntr(pp) &&
|
||||||
(pp->KindOfPE != OpProperty ||
|
(pp->KindOfPE != OpProperty || ((OpEntry *)pp)->OpModule != mod))
|
||||||
((OpEntry *)pp)->OpModule != mod))
|
|
||||||
pp = RepProp(pp->NextOfPE);
|
pp = RepProp(pp->NextOfPE);
|
||||||
if (EndOfPAEntr(pp)) {
|
if (EndOfPAEntr(pp)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -503,16 +475,13 @@ Yap_GetOpPropForAModuleHavingALock(Atom a, Term mod)
|
|||||||
return (OpEntry *)pp;
|
return (OpEntry *)pp;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int Yap_HasOp(Atom a) { /* look property list of atom a for kind */
|
||||||
Yap_HasOp(Atom a)
|
|
||||||
{ /* look property list of atom a for kind */
|
|
||||||
AtomEntry *ae = RepAtom(a);
|
AtomEntry *ae = RepAtom(a);
|
||||||
PropEntry *pp;
|
PropEntry *pp;
|
||||||
|
|
||||||
READ_LOCK(ae->ARWLock);
|
READ_LOCK(ae->ARWLock);
|
||||||
pp = RepProp(ae->PropsOfAE);
|
pp = RepProp(ae->PropsOfAE);
|
||||||
while (!EndOfPAEntr(pp) &&
|
while (!EndOfPAEntr(pp) && (pp->KindOfPE != OpProperty))
|
||||||
( pp->KindOfPE != OpProperty))
|
|
||||||
pp = RepProp(pp->NextOfPE);
|
pp = RepProp(pp->NextOfPE);
|
||||||
READ_UNLOCK(ae->ARWLock);
|
READ_UNLOCK(ae->ARWLock);
|
||||||
if (EndOfPAEntr(pp)) {
|
if (EndOfPAEntr(pp)) {
|
||||||
@ -523,8 +492,8 @@ Yap_HasOp(Atom a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
OpEntry *
|
OpEntry *
|
||||||
Yap_OpPropForModule(Atom a, Term mod)
|
Yap_OpPropForModule(Atom a,
|
||||||
{ /* look property list of atom a for kind */
|
Term mod) { /* look property list of atom a for kind */
|
||||||
AtomEntry *ae = RepAtom(a);
|
AtomEntry *ae = RepAtom(a);
|
||||||
PropEntry *pp;
|
PropEntry *pp;
|
||||||
OpEntry *info = NULL;
|
OpEntry *info = NULL;
|
||||||
@ -561,8 +530,9 @@ Yap_OpPropForModule(Atom a, Term mod)
|
|||||||
}
|
}
|
||||||
|
|
||||||
OpEntry *
|
OpEntry *
|
||||||
Yap_GetOpProp(Atom a, op_type type USES_REGS)
|
Yap_GetOpProp(Atom a,
|
||||||
{ /* look property list of atom a for kind */
|
op_type type
|
||||||
|
USES_REGS) { /* look property list of atom a for kind */
|
||||||
AtomEntry *ae = RepAtom(a);
|
AtomEntry *ae = RepAtom(a);
|
||||||
PropEntry *pp;
|
PropEntry *pp;
|
||||||
OpEntry *oinfo = NULL;
|
OpEntry *oinfo = NULL;
|
||||||
@ -576,8 +546,7 @@ Yap_GetOpProp(Atom a, op_type type USES_REGS)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
info = (OpEntry *)pp;
|
info = (OpEntry *)pp;
|
||||||
if (info->OpModule != CurrentModule &&
|
if (info->OpModule != CurrentModule && info->OpModule != PROLOG_MODULE) {
|
||||||
info->OpModule != PROLOG_MODULE) {
|
|
||||||
pp = RepProp(pp->NextOfPE);
|
pp = RepProp(pp->NextOfPE);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -617,9 +586,7 @@ Yap_GetOpProp(Atom a, op_type type USES_REGS)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline static Prop GetPredPropByAtomHavingLock(AtomEntry *ae, Term cur_mod)
|
||||||
inline static Prop
|
|
||||||
GetPredPropByAtomHavingLock(AtomEntry* ae, Term cur_mod)
|
|
||||||
/* get predicate entry for ap/arity; create it if neccessary. */
|
/* get predicate entry for ap/arity; create it if neccessary. */
|
||||||
{
|
{
|
||||||
Prop p0;
|
Prop p0;
|
||||||
@ -642,8 +609,7 @@ GetPredPropByAtomHavingLock(AtomEntry* ae, Term cur_mod)
|
|||||||
return (NIL);
|
return (NIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Prop
|
Prop Yap_GetPredPropByAtom(Atom at, Term cur_mod)
|
||||||
Yap_GetPredPropByAtom(Atom at, Term cur_mod)
|
|
||||||
/* get predicate entry for ap/arity; create it if neccessary. */
|
/* get predicate entry for ap/arity; create it if neccessary. */
|
||||||
{
|
{
|
||||||
Prop p0;
|
Prop p0;
|
||||||
@ -655,9 +621,8 @@ Yap_GetPredPropByAtom(Atom at, Term cur_mod)
|
|||||||
return (p0);
|
return (p0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline static Prop GetPredPropByAtomHavingLockInThisModule(AtomEntry *ae,
|
||||||
inline static Prop
|
Term cur_mod)
|
||||||
GetPredPropByAtomHavingLockInThisModule(AtomEntry* ae, Term cur_mod)
|
|
||||||
/* get predicate entry for ap/arity; create it if neccessary. */
|
/* get predicate entry for ap/arity; create it if neccessary. */
|
||||||
{
|
{
|
||||||
Prop p0;
|
Prop p0;
|
||||||
@ -679,8 +644,7 @@ GetPredPropByAtomHavingLockInThisModule(AtomEntry* ae, Term cur_mod)
|
|||||||
return (NIL);
|
return (NIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Prop
|
Prop Yap_GetPredPropByAtomInThisModule(Atom at, Term cur_mod)
|
||||||
Yap_GetPredPropByAtomInThisModule(Atom at, Term cur_mod)
|
|
||||||
/* get predicate entry for ap/arity; create it if neccessary. */
|
/* get predicate entry for ap/arity; create it if neccessary. */
|
||||||
{
|
{
|
||||||
Prop p0;
|
Prop p0;
|
||||||
@ -692,9 +656,7 @@ Yap_GetPredPropByAtomInThisModule(Atom at, Term cur_mod)
|
|||||||
return (p0);
|
return (p0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Prop Yap_GetPredPropByFunc(Functor f, Term cur_mod)
|
||||||
Prop
|
|
||||||
Yap_GetPredPropByFunc(Functor f, Term cur_mod)
|
|
||||||
/* get predicate entry for ap/arity; */
|
/* get predicate entry for ap/arity; */
|
||||||
{
|
{
|
||||||
Prop p0;
|
Prop p0;
|
||||||
@ -706,8 +668,7 @@ Yap_GetPredPropByFunc(Functor f, Term cur_mod)
|
|||||||
return (p0);
|
return (p0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Prop
|
Prop Yap_GetPredPropByFuncInThisModule(Functor f, Term cur_mod)
|
||||||
Yap_GetPredPropByFuncInThisModule(Functor f, Term cur_mod)
|
|
||||||
/* get predicate entry for ap/arity; */
|
/* get predicate entry for ap/arity; */
|
||||||
{
|
{
|
||||||
Prop p0;
|
Prop p0;
|
||||||
@ -718,8 +679,7 @@ Yap_GetPredPropByFuncInThisModule(Functor f, Term cur_mod)
|
|||||||
return (p0);
|
return (p0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Prop
|
Prop Yap_GetPredPropHavingLock(Atom ap, unsigned int arity, Term mod)
|
||||||
Yap_GetPredPropHavingLock(Atom ap, unsigned int arity, Term mod)
|
|
||||||
/* get predicate entry for ap/arity; */
|
/* get predicate entry for ap/arity; */
|
||||||
{
|
{
|
||||||
Prop p0;
|
Prop p0;
|
||||||
@ -737,9 +697,7 @@ Yap_GetPredPropHavingLock(Atom ap, unsigned int arity, Term mod)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* get expression entry for at/arity; */
|
/* get expression entry for at/arity; */
|
||||||
Prop
|
Prop Yap_GetExpProp(Atom at, unsigned int arity) {
|
||||||
Yap_GetExpProp(Atom at, unsigned int arity)
|
|
||||||
{
|
|
||||||
Prop p0;
|
Prop p0;
|
||||||
AtomEntry *ae = RepAtom(at);
|
AtomEntry *ae = RepAtom(at);
|
||||||
ExpEntry *p;
|
ExpEntry *p;
|
||||||
@ -753,9 +711,7 @@ Yap_GetExpProp(Atom at, unsigned int arity)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* get expression entry for at/arity, at is already locked; */
|
/* get expression entry for at/arity, at is already locked; */
|
||||||
Prop
|
Prop Yap_GetExpPropHavingLock(AtomEntry *ae, unsigned int arity) {
|
||||||
Yap_GetExpPropHavingLock(AtomEntry *ae, unsigned int arity)
|
|
||||||
{
|
|
||||||
Prop p0;
|
Prop p0;
|
||||||
ExpEntry *p;
|
ExpEntry *p;
|
||||||
|
|
||||||
@ -766,12 +722,11 @@ Yap_GetExpPropHavingLock(AtomEntry *ae, unsigned int arity)
|
|||||||
return (p0);
|
return (p0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int ExpandPredHash(void) {
|
||||||
ExpandPredHash(void)
|
|
||||||
{
|
|
||||||
UInt new_size = PredHashTableSize + PredHashIncrement;
|
UInt new_size = PredHashTableSize + PredHashIncrement;
|
||||||
PredEntry **oldp = PredHash;
|
PredEntry **oldp = PredHash;
|
||||||
PredEntry **np = (PredEntry **) Yap_AllocAtomSpace(sizeof(PredEntry **)*new_size);
|
PredEntry **np =
|
||||||
|
(PredEntry **)Yap_AllocAtomSpace(sizeof(PredEntry **) * new_size);
|
||||||
UInt i;
|
UInt i;
|
||||||
|
|
||||||
if (!np) {
|
if (!np) {
|
||||||
@ -798,9 +753,7 @@ ExpandPredHash(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* fe is supposed to be locked */
|
/* fe is supposed to be locked */
|
||||||
Prop
|
Prop Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod) {
|
||||||
Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod)
|
|
||||||
{
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
PredEntry *p = (PredEntry *)Yap_AllocAtomSpace(sizeof(*p));
|
PredEntry *p = (PredEntry *)Yap_AllocAtomSpace(sizeof(*p));
|
||||||
|
|
||||||
@ -889,18 +842,19 @@ Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod)
|
|||||||
}
|
}
|
||||||
FUNC_WRITE_UNLOCK(fe);
|
FUNC_WRITE_UNLOCK(fe);
|
||||||
{
|
{
|
||||||
Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred)+1, p, GPROF_NEW_PRED_FUNC);
|
Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred) + 1, p,
|
||||||
|
GPROF_NEW_PRED_FUNC);
|
||||||
if (!(p->PredFlags & (CPredFlag | AsmPredFlag))) {
|
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_FUNC);
|
Yap_inform_profiler_of_clause(&(p->cs.p_code.ExpandCode),
|
||||||
|
&(p->cs.p_code.ExpandCode) + 1, p,
|
||||||
|
GPROF_NEW_PRED_FUNC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return AbsPredProp(p);
|
return AbsPredProp(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if THREADS
|
#if THREADS
|
||||||
Prop
|
Prop Yap_NewThreadPred(PredEntry *ap USES_REGS) {
|
||||||
Yap_NewThreadPred(PredEntry *ap USES_REGS)
|
|
||||||
{
|
|
||||||
PredEntry *p = (PredEntry *)Yap_AllocAtomSpace(sizeof(*p));
|
PredEntry *p = (PredEntry *)Yap_AllocAtomSpace(sizeof(*p));
|
||||||
|
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
@ -933,23 +887,26 @@ Yap_NewThreadPred(PredEntry *ap USES_REGS)
|
|||||||
p->NextOfPE = AbsPredProp(LOCAL_ThreadHandle.local_preds);
|
p->NextOfPE = AbsPredProp(LOCAL_ThreadHandle.local_preds);
|
||||||
LOCAL_ThreadHandle.local_preds = p;
|
LOCAL_ThreadHandle.local_preds = p;
|
||||||
p->FunctorOfPred = ap->FunctorOfPred;
|
p->FunctorOfPred = ap->FunctorOfPred;
|
||||||
Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred)+1, p, GPROF_NEW_PRED_THREAD);
|
Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred) + 1, p,
|
||||||
|
GPROF_NEW_PRED_THREAD);
|
||||||
if (falseGlobalPrologFlag(DEBUG_INFO_FLAG)) {
|
if (falseGlobalPrologFlag(DEBUG_INFO_FLAG)) {
|
||||||
p->PredFlags |= (NoSpyPredFlag | NoTracePredFlag);
|
p->PredFlags |= (NoSpyPredFlag | NoTracePredFlag);
|
||||||
}
|
}
|
||||||
if (!(p->PredFlags & (CPredFlag | AsmPredFlag))) {
|
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);
|
Yap_inform_profiler_of_clause(&(p->cs.p_code.ExpandCode),
|
||||||
|
&(p->cs.p_code.ExpandCode) + 1, p,
|
||||||
|
GPROF_NEW_PRED_THREAD);
|
||||||
}
|
}
|
||||||
return AbsPredProp(p);
|
return AbsPredProp(p);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Prop
|
Prop Yap_NewPredPropByAtom(AtomEntry *ae, Term cur_mod) {
|
||||||
Yap_NewPredPropByAtom(AtomEntry *ae, Term cur_mod)
|
Prop p0;
|
||||||
{ Prop p0;
|
|
||||||
PredEntry *p = (PredEntry *)Yap_AllocAtomSpace(sizeof(*p));
|
PredEntry *p = (PredEntry *)Yap_AllocAtomSpace(sizeof(*p));
|
||||||
|
|
||||||
/* Printf("entering %s:%s/0\n", RepAtom(AtomOfTerm(cur_mod))->StrOfAE, ae->StrOfAE); */
|
/* Printf("entering %s:%s/0\n", RepAtom(AtomOfTerm(cur_mod))->StrOfAE,
|
||||||
|
* ae->StrOfAE); */
|
||||||
|
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
WRITE_UNLOCK(ae->ARWLock);
|
WRITE_UNLOCK(ae->ARWLock);
|
||||||
@ -1002,16 +959,18 @@ Yap_NewPredPropByAtom(AtomEntry *ae, Term cur_mod)
|
|||||||
}
|
}
|
||||||
WRITE_UNLOCK(ae->ARWLock);
|
WRITE_UNLOCK(ae->ARWLock);
|
||||||
{
|
{
|
||||||
Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred)+1, p, GPROF_NEW_PRED_ATOM);
|
Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred) + 1, p,
|
||||||
|
GPROF_NEW_PRED_ATOM);
|
||||||
if (!(p->PredFlags & (CPredFlag | AsmPredFlag))) {
|
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_ATOM);
|
Yap_inform_profiler_of_clause(&(p->cs.p_code.ExpandCode),
|
||||||
|
&(p->cs.p_code.ExpandCode) + 1, p,
|
||||||
|
GPROF_NEW_PRED_ATOM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return p0;
|
return p0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Prop
|
Prop Yap_PredPropByFunctorNonThreadLocal(Functor f, Term cur_mod)
|
||||||
Yap_PredPropByFunctorNonThreadLocal(Functor f, Term cur_mod)
|
|
||||||
/* get predicate entry for ap/arity; create it if neccessary. */
|
/* get predicate entry for ap/arity; create it if neccessary. */
|
||||||
{
|
{
|
||||||
PredEntry *p;
|
PredEntry *p;
|
||||||
@ -1022,9 +981,7 @@ Yap_PredPropByFunctorNonThreadLocal(Functor f, Term cur_mod)
|
|||||||
|
|
||||||
if ((p->ModuleOfPred == cur_mod || !(p->ModuleOfPred))) {
|
if ((p->ModuleOfPred == cur_mod || !(p->ModuleOfPred))) {
|
||||||
/* don't match multi-files */
|
/* don't match multi-files */
|
||||||
if (!(p->PredFlags & MultiFileFlag) ||
|
if (!(p->PredFlags & MultiFileFlag) || p->ModuleOfPred || !cur_mod ||
|
||||||
p->ModuleOfPred ||
|
|
||||||
!cur_mod ||
|
|
||||||
cur_mod == TermProlog) {
|
cur_mod == TermProlog) {
|
||||||
FUNC_WRITE_UNLOCK(f);
|
FUNC_WRITE_UNLOCK(f);
|
||||||
return AbsPredProp(p);
|
return AbsPredProp(p);
|
||||||
@ -1036,9 +993,7 @@ Yap_PredPropByFunctorNonThreadLocal(Functor f, Term cur_mod)
|
|||||||
p = PredHash[hash];
|
p = PredHash[hash];
|
||||||
|
|
||||||
while (p) {
|
while (p) {
|
||||||
if (p->FunctorOfPred == f &&
|
if (p->FunctorOfPred == f && p->ModuleOfPred == cur_mod) {
|
||||||
p->ModuleOfPred == cur_mod)
|
|
||||||
{
|
|
||||||
READ_UNLOCK(PredHashRWLock);
|
READ_UNLOCK(PredHashRWLock);
|
||||||
FUNC_WRITE_UNLOCK(f);
|
FUNC_WRITE_UNLOCK(f);
|
||||||
return AbsPredProp(p);
|
return AbsPredProp(p);
|
||||||
@ -1050,8 +1005,7 @@ Yap_PredPropByFunctorNonThreadLocal(Functor f, Term cur_mod)
|
|||||||
return Yap_NewPredPropByFunctor(f, cur_mod);
|
return Yap_NewPredPropByFunctor(f, cur_mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
Prop
|
Prop Yap_PredPropByAtomNonThreadLocal(Atom at, Term cur_mod)
|
||||||
Yap_PredPropByAtomNonThreadLocal(Atom at, Term cur_mod)
|
|
||||||
/* get predicate entry for ap/arity; create it if neccessary. */
|
/* get predicate entry for ap/arity; create it if neccessary. */
|
||||||
{
|
{
|
||||||
Prop p0;
|
Prop p0;
|
||||||
@ -1064,9 +1018,7 @@ Yap_PredPropByAtomNonThreadLocal(Atom at, Term cur_mod)
|
|||||||
if (pe->KindOfPE == PEProp &&
|
if (pe->KindOfPE == PEProp &&
|
||||||
(pe->ModuleOfPred == cur_mod || !pe->ModuleOfPred)) {
|
(pe->ModuleOfPred == cur_mod || !pe->ModuleOfPred)) {
|
||||||
/* don't match multi-files */
|
/* don't match multi-files */
|
||||||
if (!(pe->PredFlags & MultiFileFlag) ||
|
if (!(pe->PredFlags & MultiFileFlag) || pe->ModuleOfPred || !cur_mod ||
|
||||||
pe->ModuleOfPred ||
|
|
||||||
!cur_mod ||
|
|
||||||
cur_mod == TermProlog) {
|
cur_mod == TermProlog) {
|
||||||
WRITE_UNLOCK(ae->ARWLock);
|
WRITE_UNLOCK(ae->ARWLock);
|
||||||
return (p0);
|
return (p0);
|
||||||
@ -1077,11 +1029,7 @@ Yap_PredPropByAtomNonThreadLocal(Atom at, Term cur_mod)
|
|||||||
return Yap_NewPredPropByAtom(ae, cur_mod);
|
return Yap_NewPredPropByAtom(ae, cur_mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Term Yap_GetValue(Atom a) {
|
||||||
|
|
||||||
Term
|
|
||||||
Yap_GetValue(Atom a)
|
|
||||||
{
|
|
||||||
Prop p0 = GetAProp(a, ValProperty);
|
Prop p0 = GetAProp(a, ValProperty);
|
||||||
Term out;
|
Term out;
|
||||||
|
|
||||||
@ -1111,9 +1059,7 @@ Yap_GetValue(Atom a)
|
|||||||
return (out);
|
return (out);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void Yap_PutValue(Atom a, Term v) {
|
||||||
Yap_PutValue(Atom a, Term v)
|
|
||||||
{
|
|
||||||
AtomEntry *ae = RepAtom(a);
|
AtomEntry *ae = RepAtom(a);
|
||||||
Prop p0;
|
Prop p0;
|
||||||
ValEntry *p;
|
ValEntry *p;
|
||||||
@ -1157,7 +1103,8 @@ Yap_PutValue(Atom a, Term v)
|
|||||||
if (IsApplTerm(t0)) {
|
if (IsApplTerm(t0)) {
|
||||||
Yap_FreeCodeSpace((char *)(RepAppl(t0)));
|
Yap_FreeCodeSpace((char *)(RepAppl(t0)));
|
||||||
}
|
}
|
||||||
pt = (CELL *) Yap_AllocAtomSpace(sizeof(CELL)*(1 + 2*sizeof(Float)/sizeof(CELL)));
|
pt = (CELL *)Yap_AllocAtomSpace(sizeof(CELL) *
|
||||||
|
(1 + 2 * sizeof(Float) / sizeof(CELL)));
|
||||||
if (pt == NULL) {
|
if (pt == NULL) {
|
||||||
WRITE_UNLOCK(ae->ARWLock);
|
WRITE_UNLOCK(ae->ARWLock);
|
||||||
return;
|
return;
|
||||||
@ -1192,8 +1139,7 @@ Yap_PutValue(Atom a, Term v)
|
|||||||
#ifdef USE_GMP
|
#ifdef USE_GMP
|
||||||
} else if (IsBigIntTerm(v)) {
|
} else if (IsBigIntTerm(v)) {
|
||||||
CELL *ap = RepAppl(v);
|
CELL *ap = RepAppl(v);
|
||||||
Int sz =
|
Int sz = sizeof(MP_INT) + sizeof(CELL) +
|
||||||
sizeof(MP_INT)+sizeof(CELL)+
|
|
||||||
(((MP_INT *)(ap + 1))->_mp_alloc * sizeof(mp_limb_t));
|
(((MP_INT *)(ap + 1))->_mp_alloc * sizeof(mp_limb_t));
|
||||||
CELL *pt = (CELL *)Yap_AllocAtomSpace(sz);
|
CELL *pt = (CELL *)Yap_AllocAtomSpace(sz);
|
||||||
|
|
||||||
@ -1209,8 +1155,7 @@ Yap_PutValue(Atom a, Term v)
|
|||||||
#endif
|
#endif
|
||||||
} else if (IsStringTerm(v)) {
|
} else if (IsStringTerm(v)) {
|
||||||
CELL *ap = RepAppl(v);
|
CELL *ap = RepAppl(v);
|
||||||
Int sz =
|
Int sz = sizeof(CELL) * (3 + ap[1]);
|
||||||
sizeof(CELL)*(3+ap[1]);
|
|
||||||
CELL *pt = (CELL *)Yap_AllocAtomSpace(sz);
|
CELL *pt = (CELL *)Yap_AllocAtomSpace(sz);
|
||||||
|
|
||||||
if (pt == NULL) {
|
if (pt == NULL) {
|
||||||
@ -1232,9 +1177,7 @@ Yap_PutValue(Atom a, Term v)
|
|||||||
WRITE_UNLOCK(p->VRWLock);
|
WRITE_UNLOCK(p->VRWLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool Yap_PutAtomTranslation(Atom a, arity_t arity, Int i) {
|
||||||
Yap_PutAtomTranslation(Atom a, arity_t arity, Int i)
|
|
||||||
{
|
|
||||||
AtomEntry *ae = RepAtom(a);
|
AtomEntry *ae = RepAtom(a);
|
||||||
Prop p0;
|
Prop p0;
|
||||||
TranslationEntry *p;
|
TranslationEntry *p;
|
||||||
@ -1258,9 +1201,7 @@ Yap_PutAtomTranslation(Atom a, arity_t arity, Int i)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool Yap_PutFunctorTranslation(Atom a, arity_t arity, Int i) {
|
||||||
Yap_PutFunctorTranslation(Atom a, arity_t arity, Int i)
|
|
||||||
{
|
|
||||||
AtomEntry *ae = RepAtom(a);
|
AtomEntry *ae = RepAtom(a);
|
||||||
Prop p0;
|
Prop p0;
|
||||||
TranslationEntry *p;
|
TranslationEntry *p;
|
||||||
@ -1284,9 +1225,7 @@ Yap_PutFunctorTranslation(Atom a, arity_t arity, Int i)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool Yap_PutAtomMutex(Atom a, void *i) {
|
||||||
Yap_PutAtomMutex(Atom a, void * i)
|
|
||||||
{
|
|
||||||
AtomEntry *ae = RepAtom(a);
|
AtomEntry *ae = RepAtom(a);
|
||||||
Prop p0;
|
Prop p0;
|
||||||
MutexEntry *p;
|
MutexEntry *p;
|
||||||
@ -1309,9 +1248,7 @@ Yap_PutAtomMutex(Atom a, void * i)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Term
|
Term Yap_ArrayToList(register Term *tp, size_t nof) {
|
||||||
Yap_ArrayToList(register Term *tp, size_t nof)
|
|
||||||
{
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
register Term *pt = tp + nof;
|
register Term *pt = tp + nof;
|
||||||
register Term t;
|
register Term t;
|
||||||
@ -1329,9 +1266,7 @@ Yap_ArrayToList(register Term *tp, size_t nof)
|
|||||||
return (t);
|
return (t);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int Yap_GetName(char *s, UInt max, Term t) {
|
||||||
Yap_GetName(char *s, UInt max, Term t)
|
|
||||||
{
|
|
||||||
register Term Head;
|
register Term Head;
|
||||||
register Int i;
|
register Int i;
|
||||||
|
|
||||||
@ -1356,9 +1291,7 @@ Yap_GetName(char *s, UInt max, Term t)
|
|||||||
|
|
||||||
#ifdef SFUNC
|
#ifdef SFUNC
|
||||||
|
|
||||||
Term
|
Term MkSFTerm(Functor f, int n, Term *a, empty_value) {
|
||||||
MkSFTerm(Functor f, int n, Term *a, empty_value)
|
|
||||||
{
|
|
||||||
Term t, p = AbsAppl(H);
|
Term t, p = AbsAppl(H);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -1376,9 +1309,7 @@ MkSFTerm(Functor f, int n, Term *a, empty_value)
|
|||||||
return (p);
|
return (p);
|
||||||
}
|
}
|
||||||
|
|
||||||
CELL *
|
CELL *ArgsOfSFTerm(Term t) {
|
||||||
ArgsOfSFTerm(Term t)
|
|
||||||
{
|
|
||||||
CELL *p = RepAppl(t) + 1;
|
CELL *p = RepAppl(t) + 1;
|
||||||
|
|
||||||
while (*p != (CELL)p)
|
while (*p != (CELL)p)
|
||||||
@ -1388,10 +1319,7 @@ ArgsOfSFTerm(Term t)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static HoldEntry *InitAtomHold(void) {
|
||||||
static HoldEntry *
|
|
||||||
InitAtomHold(void)
|
|
||||||
{
|
|
||||||
HoldEntry *x = (HoldEntry *)Yap_AllocAtomSpace(sizeof(struct hold_entry));
|
HoldEntry *x = (HoldEntry *)Yap_AllocAtomSpace(sizeof(struct hold_entry));
|
||||||
if (x == NULL) {
|
if (x == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1402,17 +1330,14 @@ InitAtomHold(void)
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int Yap_AtomIncreaseHold(Atom at) {
|
||||||
Yap_AtomIncreaseHold(Atom at)
|
|
||||||
{
|
|
||||||
AtomEntry *ae = RepAtom(at);
|
AtomEntry *ae = RepAtom(at);
|
||||||
HoldEntry *pp;
|
HoldEntry *pp;
|
||||||
Prop *opp = &(ae->PropsOfAE);
|
Prop *opp = &(ae->PropsOfAE);
|
||||||
|
|
||||||
WRITE_LOCK(ae->ARWLock);
|
WRITE_LOCK(ae->ARWLock);
|
||||||
pp = RepHoldProp(ae->PropsOfAE);
|
pp = RepHoldProp(ae->PropsOfAE);
|
||||||
while (!EndOfPAEntr(pp)
|
while (!EndOfPAEntr(pp) && pp->KindOfPE != HoldProperty) {
|
||||||
&& pp->KindOfPE != HoldProperty) {
|
|
||||||
opp = &(pp->NextOfPE);
|
opp = &(pp->NextOfPE);
|
||||||
pp = RepHoldProp(pp->NextOfPE);
|
pp = RepHoldProp(pp->NextOfPE);
|
||||||
}
|
}
|
||||||
@ -1430,17 +1355,14 @@ Yap_AtomIncreaseHold(Atom at)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int Yap_AtomDecreaseHold(Atom at) {
|
||||||
Yap_AtomDecreaseHold(Atom at)
|
|
||||||
{
|
|
||||||
AtomEntry *ae = RepAtom(at);
|
AtomEntry *ae = RepAtom(at);
|
||||||
HoldEntry *pp;
|
HoldEntry *pp;
|
||||||
Prop *opp = &(ae->PropsOfAE);
|
Prop *opp = &(ae->PropsOfAE);
|
||||||
|
|
||||||
WRITE_LOCK(ae->ARWLock);
|
WRITE_LOCK(ae->ARWLock);
|
||||||
pp = RepHoldProp(ae->PropsOfAE);
|
pp = RepHoldProp(ae->PropsOfAE);
|
||||||
while (!EndOfPAEntr(pp)
|
while (!EndOfPAEntr(pp) && pp->KindOfPE != HoldProperty) {
|
||||||
&& pp->KindOfPE != HoldProperty) {
|
|
||||||
opp = &(pp->NextOfPE);
|
opp = &(pp->NextOfPE);
|
||||||
pp = RepHoldProp(pp->NextOfPE);
|
pp = RepHoldProp(pp->NextOfPE);
|
||||||
}
|
}
|
||||||
@ -1456,4 +1378,3 @@ Yap_AtomDecreaseHold(Atom at)
|
|||||||
WRITE_UNLOCK(ae->ARWLock);
|
WRITE_UNLOCK(ae->ARWLock);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user