Stasinos noticed that _YAP_ breaks C standard: use Yap_ instead.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@691 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
212c64f782
commit
d7f80ea1ad
86
C/adtdefs.c
86
C/adtdefs.c
@ -61,7 +61,7 @@ InlinedUnlockedMkFunctor(AtomEntry *ae, unsigned int arity)
|
||||
if (p0 != NIL) {
|
||||
return ((Functor) RepProp(p0));
|
||||
}
|
||||
p = (FunctorEntry *) _YAP_AllocAtomSpace(sizeof(*p));
|
||||
p = (FunctorEntry *) Yap_AllocAtomSpace(sizeof(*p));
|
||||
p->KindOfPE = FunctorProperty;
|
||||
p->NameOfFE = AbsAtom(ae);
|
||||
p->ArityOfFE = arity;
|
||||
@ -73,14 +73,14 @@ InlinedUnlockedMkFunctor(AtomEntry *ae, unsigned int arity)
|
||||
}
|
||||
|
||||
Functor
|
||||
_YAP_UnlockedMkFunctor(AtomEntry *ae, unsigned int arity)
|
||||
Yap_UnlockedMkFunctor(AtomEntry *ae, unsigned int arity)
|
||||
{
|
||||
return(InlinedUnlockedMkFunctor(ae, arity));
|
||||
}
|
||||
|
||||
/* vsc: We must guarantee that IsVarTerm(functor) returns true! */
|
||||
Functor
|
||||
_YAP_MkFunctor(Atom ap, unsigned int arity)
|
||||
Yap_MkFunctor(Atom ap, unsigned int arity)
|
||||
{
|
||||
AtomEntry *ae = RepAtom(ap);
|
||||
Functor f;
|
||||
@ -93,7 +93,7 @@ _YAP_MkFunctor(Atom ap, unsigned int arity)
|
||||
|
||||
/* vsc: We must guarantee that IsVarTerm(functor) returns true! */
|
||||
void
|
||||
_YAP_MkFunctorWithAddress(Atom ap, unsigned int arity, FunctorEntry *p)
|
||||
Yap_MkFunctorWithAddress(Atom ap, unsigned int arity, FunctorEntry *p)
|
||||
{
|
||||
AtomEntry *ae = RepAtom(ap);
|
||||
|
||||
@ -160,7 +160,7 @@ LookupAtom(char *atom)
|
||||
return(a);
|
||||
}
|
||||
/* add new atom to start of chain */
|
||||
ae = (AtomEntry *) _YAP_AllocAtomSpace((sizeof *ae) + strlen(atom));
|
||||
ae = (AtomEntry *) Yap_AllocAtomSpace((sizeof *ae) + strlen(atom));
|
||||
a = AbsAtom(ae);
|
||||
ae->NextOfAE = HashChain[hash].Entry;
|
||||
HashChain[hash].Entry = a;
|
||||
@ -173,13 +173,13 @@ LookupAtom(char *atom)
|
||||
}
|
||||
|
||||
Atom
|
||||
_YAP_LookupAtom(char *atom)
|
||||
Yap_LookupAtom(char *atom)
|
||||
{ /* lookup atom in atom table */
|
||||
return(LookupAtom(atom));
|
||||
}
|
||||
|
||||
Atom
|
||||
_YAP_FullLookupAtom(char *atom)
|
||||
Yap_FullLookupAtom(char *atom)
|
||||
{ /* lookup atom in atom table */
|
||||
Atom t;
|
||||
|
||||
@ -190,7 +190,7 @@ _YAP_FullLookupAtom(char *atom)
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_LookupAtomWithAddress(char *atom, AtomEntry *ae)
|
||||
Yap_LookupAtomWithAddress(char *atom, AtomEntry *ae)
|
||||
{ /* lookup atom in atom table */
|
||||
register CELL hash;
|
||||
register unsigned char *p;
|
||||
@ -204,7 +204,7 @@ _YAP_LookupAtomWithAddress(char *atom, AtomEntry *ae)
|
||||
a = HashChain[hash].Entry;
|
||||
/* search atom in chain */
|
||||
if (SearchAtom(p, a) != NIL) {
|
||||
_YAP_Error(FATAL_ERROR,TermNil,"repeated initialisation for atom %s", ae);
|
||||
Yap_Error(FATAL_ERROR,TermNil,"repeated initialisation for atom %s", ae);
|
||||
WRITE_UNLOCK(HashChain[hash].AERWLock);
|
||||
return;
|
||||
}
|
||||
@ -218,7 +218,7 @@ _YAP_LookupAtomWithAddress(char *atom, AtomEntry *ae)
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_ReleaseAtom(Atom atom)
|
||||
Yap_ReleaseAtom(Atom atom)
|
||||
{ /* Releases an atom from the hash chain */
|
||||
register Int hash;
|
||||
register unsigned char *p;
|
||||
@ -257,7 +257,7 @@ GetAPropHavingLock(AtomEntry *ae, PropFlags kind)
|
||||
}
|
||||
|
||||
Prop
|
||||
_YAP_GetAPropHavingLock(AtomEntry *ae, PropFlags kind)
|
||||
Yap_GetAPropHavingLock(AtomEntry *ae, PropFlags kind)
|
||||
{ /* look property list of atom a for kind */
|
||||
return (GetAPropHavingLock(ae,kind));
|
||||
}
|
||||
@ -275,7 +275,7 @@ GetAProp(Atom a, PropFlags kind)
|
||||
}
|
||||
|
||||
Prop
|
||||
_YAP_GetAProp(Atom a, PropFlags kind)
|
||||
Yap_GetAProp(Atom a, PropFlags kind)
|
||||
{ /* look property list of atom a for kind */
|
||||
return GetAProp(a,kind);
|
||||
}
|
||||
@ -299,7 +299,7 @@ GetPredPropByAtomHavingLock(AtomEntry* ae, SMALLUNSGN cur_mod)
|
||||
}
|
||||
|
||||
Prop
|
||||
_YAP_GetPredPropByAtom(Atom at, SMALLUNSGN cur_mod)
|
||||
Yap_GetPredPropByAtom(Atom at, SMALLUNSGN cur_mod)
|
||||
/* get predicate entry for ap/arity; create it if neccessary. */
|
||||
{
|
||||
Prop p0;
|
||||
@ -332,7 +332,7 @@ GetPredPropByFuncHavingLock(Functor f, SMALLUNSGN cur_mod)
|
||||
}
|
||||
|
||||
Prop
|
||||
_YAP_GetPredPropByFunc(Functor f, SMALLUNSGN cur_mod)
|
||||
Yap_GetPredPropByFunc(Functor f, SMALLUNSGN cur_mod)
|
||||
/* get predicate entry for ap/arity; */
|
||||
{
|
||||
Prop p0;
|
||||
@ -344,7 +344,7 @@ _YAP_GetPredPropByFunc(Functor f, SMALLUNSGN cur_mod)
|
||||
}
|
||||
|
||||
Prop
|
||||
_YAP_GetPredPropHavingLock(Atom ap, unsigned int arity, SMALLUNSGN mod)
|
||||
Yap_GetPredPropHavingLock(Atom ap, unsigned int arity, SMALLUNSGN mod)
|
||||
/* get predicate entry for ap/arity; */
|
||||
{
|
||||
Prop p0;
|
||||
@ -363,7 +363,7 @@ _YAP_GetPredPropHavingLock(Atom ap, unsigned int arity, SMALLUNSGN mod)
|
||||
|
||||
/* get expression entry for at/arity; */
|
||||
Prop
|
||||
_YAP_GetExpProp(Atom at, unsigned int arity)
|
||||
Yap_GetExpProp(Atom at, unsigned int arity)
|
||||
{
|
||||
Prop p0;
|
||||
AtomEntry *ae = RepAtom(at);
|
||||
@ -379,7 +379,7 @@ _YAP_GetExpProp(Atom at, unsigned int arity)
|
||||
|
||||
/* get expression entry for at/arity, at is already locked; */
|
||||
Prop
|
||||
_YAP_GetExpPropHavingLock(AtomEntry *ae, unsigned int arity)
|
||||
Yap_GetExpPropHavingLock(AtomEntry *ae, unsigned int arity)
|
||||
{
|
||||
Prop p0;
|
||||
ExpEntry *p;
|
||||
@ -391,10 +391,10 @@ _YAP_GetExpPropHavingLock(AtomEntry *ae, unsigned int arity)
|
||||
}
|
||||
|
||||
Prop
|
||||
_YAP_NewPredPropByFunctor(FunctorEntry *fe, SMALLUNSGN cur_mod)
|
||||
Yap_NewPredPropByFunctor(FunctorEntry *fe, SMALLUNSGN cur_mod)
|
||||
{
|
||||
Prop p0;
|
||||
PredEntry *p = (PredEntry *) _YAP_AllocAtomSpace(sizeof(*p));
|
||||
PredEntry *p = (PredEntry *) Yap_AllocAtomSpace(sizeof(*p));
|
||||
|
||||
/* printf("entering %s:%s/%d\n", RepAtom(AtomOfTerm(ModuleName[cur_mod]))->StrOfAE, RepAtom(fe->NameOfFE)->StrOfAE, fe->ArityOfFE); */
|
||||
|
||||
@ -426,10 +426,10 @@ _YAP_NewPredPropByFunctor(FunctorEntry *fe, SMALLUNSGN cur_mod)
|
||||
}
|
||||
|
||||
Prop
|
||||
_YAP_NewPredPropByAtom(AtomEntry *ae, SMALLUNSGN cur_mod)
|
||||
Yap_NewPredPropByAtom(AtomEntry *ae, SMALLUNSGN cur_mod)
|
||||
{
|
||||
Prop p0;
|
||||
PredEntry *p = (PredEntry *) _YAP_AllocAtomSpace(sizeof(*p));
|
||||
PredEntry *p = (PredEntry *) Yap_AllocAtomSpace(sizeof(*p));
|
||||
|
||||
/* Printf("entering %s:%s/0\n", RepAtom(AtomOfTerm(ModuleName[cur_mod]))->StrOfAE, ae->StrOfAE); */
|
||||
|
||||
@ -461,7 +461,7 @@ _YAP_NewPredPropByAtom(AtomEntry *ae, SMALLUNSGN cur_mod)
|
||||
}
|
||||
|
||||
Term
|
||||
_YAP_GetValue(Atom a)
|
||||
Yap_GetValue(Atom a)
|
||||
{
|
||||
Prop p0 = GetAProp(a, ValProperty);
|
||||
Term out;
|
||||
@ -479,7 +479,7 @@ _YAP_GetValue(Atom a)
|
||||
}
|
||||
#ifdef USE_GMP
|
||||
else {
|
||||
out = _YAP_MkBigIntTerm(_YAP_BigIntOfTerm(out));
|
||||
out = Yap_MkBigIntTerm(Yap_BigIntOfTerm(out));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -488,7 +488,7 @@ _YAP_GetValue(Atom a)
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_PutValue(Atom a, Term v)
|
||||
Yap_PutValue(Atom a, Term v)
|
||||
{
|
||||
AtomEntry *ae = RepAtom(a);
|
||||
Prop p0;
|
||||
@ -502,7 +502,7 @@ _YAP_PutValue(Atom a, Term v)
|
||||
WRITE_LOCK(p->VRWLock);
|
||||
WRITE_UNLOCK(ae->ARWLock);
|
||||
} else {
|
||||
p = (ValEntry *) _YAP_AllocAtomSpace(sizeof(ValEntry));
|
||||
p = (ValEntry *) Yap_AllocAtomSpace(sizeof(ValEntry));
|
||||
p->NextOfPE = RepAtom(a)->PropsOfAE;
|
||||
RepAtom(a)->PropsOfAE = AbsValProp(p);
|
||||
p->KindOfPE = ValProperty;
|
||||
@ -528,9 +528,9 @@ _YAP_PutValue(Atom a, Term v)
|
||||
pt = RepAppl(t0);
|
||||
} else {
|
||||
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)));
|
||||
p->ValueOfVE = AbsAppl(pt);
|
||||
pt[0] = (CELL)FunctorDouble;
|
||||
}
|
||||
@ -547,9 +547,9 @@ _YAP_PutValue(Atom a, Term v)
|
||||
pt = RepAppl(t0);
|
||||
} else {
|
||||
if (IsApplTerm(t0)) {
|
||||
_YAP_FreeCodeSpace((char *) (RepAppl(t0)));
|
||||
Yap_FreeCodeSpace((char *) (RepAppl(t0)));
|
||||
}
|
||||
pt = (CELL *) _YAP_AllocAtomSpace(2*sizeof(CELL));
|
||||
pt = (CELL *) Yap_AllocAtomSpace(2*sizeof(CELL));
|
||||
p->ValueOfVE = AbsAppl(pt);
|
||||
pt[0] = (CELL)FunctorLongInt;
|
||||
}
|
||||
@ -560,9 +560,9 @@ _YAP_PutValue(Atom a, Term v)
|
||||
Int sz =
|
||||
sizeof(MP_INT)+sizeof(CELL)+
|
||||
(((MP_INT *)(ap+1))->_mp_alloc*sizeof(mp_limb_t));
|
||||
CELL *pt = (CELL *) _YAP_AllocAtomSpace(sz);
|
||||
CELL *pt = (CELL *) Yap_AllocAtomSpace(sz);
|
||||
if (IsApplTerm(t0)) {
|
||||
_YAP_FreeCodeSpace((char *) RepAppl(t0));
|
||||
Yap_FreeCodeSpace((char *) RepAppl(t0));
|
||||
}
|
||||
memcpy((void *)pt, (void *)ap, sz);
|
||||
p->ValueOfVE = AbsAppl(pt);
|
||||
@ -570,7 +570,7 @@ _YAP_PutValue(Atom a, Term v)
|
||||
} else {
|
||||
if (IsApplTerm(t0)) {
|
||||
/* recover space */
|
||||
_YAP_FreeCodeSpace((char *) (RepAppl(p->ValueOfVE)));
|
||||
Yap_FreeCodeSpace((char *) (RepAppl(p->ValueOfVE)));
|
||||
}
|
||||
p->ValueOfVE = v;
|
||||
}
|
||||
@ -578,7 +578,7 @@ _YAP_PutValue(Atom a, Term v)
|
||||
}
|
||||
|
||||
Term
|
||||
_YAP_StringToList(char *s)
|
||||
Yap_StringToList(char *s)
|
||||
{
|
||||
register Term t;
|
||||
register unsigned char *cp = (unsigned char *)s + strlen(s);
|
||||
@ -591,7 +591,7 @@ _YAP_StringToList(char *s)
|
||||
}
|
||||
|
||||
Term
|
||||
_YAP_StringToListOfAtoms(char *s)
|
||||
Yap_StringToListOfAtoms(char *s)
|
||||
{
|
||||
register Term t;
|
||||
char so[2];
|
||||
@ -607,7 +607,7 @@ _YAP_StringToListOfAtoms(char *s)
|
||||
}
|
||||
|
||||
Term
|
||||
_YAP_ArrayToList(register Term *tp, int nof)
|
||||
Yap_ArrayToList(register Term *tp, int nof)
|
||||
{
|
||||
register Term *pt = tp + nof;
|
||||
register Term t;
|
||||
@ -626,7 +626,7 @@ _YAP_ArrayToList(register Term *tp, int nof)
|
||||
}
|
||||
|
||||
int
|
||||
_YAP_GetName(char *s, UInt max, Term t)
|
||||
Yap_GetName(char *s, UInt max, Term t)
|
||||
{
|
||||
register Term Head;
|
||||
register Int i;
|
||||
@ -643,7 +643,7 @@ _YAP_GetName(char *s, UInt max, Term t)
|
||||
*s++ = i;
|
||||
t = TailOfTerm(t);
|
||||
if (--max == 0) {
|
||||
_YAP_Error(FATAL_ERROR,t,"not enough space for GetName");
|
||||
Yap_Error(FATAL_ERROR,t,"not enough space for GetName");
|
||||
}
|
||||
}
|
||||
*s = '\0';
|
||||
@ -685,7 +685,7 @@ ArgsOfSFTerm(Term t)
|
||||
#endif
|
||||
|
||||
long
|
||||
_YAP_NewSlots(int n)
|
||||
Yap_NewSlots(int n)
|
||||
{
|
||||
Int old_slots = IntOfTerm(ASP[0]), oldn = n;
|
||||
while (n > 0) {
|
||||
@ -698,7 +698,7 @@ _YAP_NewSlots(int n)
|
||||
}
|
||||
|
||||
long
|
||||
_YAP_InitSlot(Term t)
|
||||
Yap_InitSlot(Term t)
|
||||
{
|
||||
Int old_slots = IntOfTerm(ASP[0]);
|
||||
*ASP = t;
|
||||
@ -708,7 +708,7 @@ _YAP_InitSlot(Term t)
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_RecoverSlots(int n)
|
||||
Yap_RecoverSlots(int n)
|
||||
{
|
||||
Int old_slots = IntOfTerm(ASP[0]);
|
||||
ASP += n;
|
||||
@ -716,19 +716,19 @@ _YAP_RecoverSlots(int n)
|
||||
}
|
||||
|
||||
Term
|
||||
_YAP_GetFromSlot(long slot)
|
||||
Yap_GetFromSlot(long slot)
|
||||
{
|
||||
return(Deref(LCL0[slot]));
|
||||
}
|
||||
|
||||
Term *
|
||||
_YAP_AddressFromSlot(long slot)
|
||||
Yap_AddressFromSlot(long slot)
|
||||
{
|
||||
return(LCL0+slot);
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_PutInSlot(long slot, Term t)
|
||||
Yap_PutInSlot(long slot, Term t)
|
||||
{
|
||||
LCL0[slot] = t;
|
||||
}
|
||||
|
40
C/agc.c
40
C/agc.c
@ -25,7 +25,7 @@ static char SccsId[] = "@(#)agc.c 1.3 3/15/90";
|
||||
|
||||
#ifdef DEBUG
|
||||
/* #define DEBUG_RESTORE2 1 */
|
||||
#define errout _YAP_stderr
|
||||
#define errout Yap_stderr
|
||||
#endif
|
||||
|
||||
STATIC_PROTO(void RestoreEntries, (PropEntry *));
|
||||
@ -227,7 +227,7 @@ mark_trail(void)
|
||||
|
||||
pt = (CELL *)TR;
|
||||
/* moving the trail is simple */
|
||||
while (pt != (CELL *)_YAP_TrailBase) {
|
||||
while (pt != (CELL *)Yap_TrailBase) {
|
||||
register CELL reg = pt[-1];
|
||||
pt--;
|
||||
if (!IsVarTerm(reg)) {
|
||||
@ -266,7 +266,7 @@ mark_global(void)
|
||||
* to clean the global now that functors are just variables pointing to
|
||||
* the code
|
||||
*/
|
||||
pt = CellPtr(_YAP_GlobalBase);
|
||||
pt = CellPtr(Yap_GlobalBase);
|
||||
while (pt < H) {
|
||||
register CELL reg;
|
||||
|
||||
@ -343,8 +343,8 @@ clean_atoms(void)
|
||||
#endif
|
||||
*patm = at->NextOfAE;
|
||||
atm = at->NextOfAE;
|
||||
agc_collected += _YAP_SizeOfBlock((char *)at);
|
||||
_YAP_FreeCodeSpace((char *)at);
|
||||
agc_collected += Yap_SizeOfBlock((char *)at);
|
||||
Yap_FreeCodeSpace((char *)at);
|
||||
}
|
||||
}
|
||||
HashPtr++;
|
||||
@ -362,8 +362,8 @@ clean_atoms(void)
|
||||
#endif
|
||||
*patm = at->NextOfAE;
|
||||
atm = at->NextOfAE;
|
||||
agc_collected += _YAP_SizeOfBlock((char *)at);
|
||||
_YAP_FreeCodeSpace((char *)at);
|
||||
agc_collected += Yap_SizeOfBlock((char *)at);
|
||||
Yap_FreeCodeSpace((char *)at);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -371,38 +371,38 @@ clean_atoms(void)
|
||||
static void
|
||||
atom_gc(void)
|
||||
{
|
||||
int gc_verbose = _YAP_is_gc_verbose();
|
||||
int gc_verbose = Yap_is_gc_verbose();
|
||||
int gc_trace = 0;
|
||||
|
||||
|
||||
Int time_start, agc_time;
|
||||
if (_YAP_GetValue(AtomGcTrace) != TermNil)
|
||||
if (Yap_GetValue(AtomGcTrace) != TermNil)
|
||||
gc_trace = 1;
|
||||
agc_calls++;
|
||||
agc_collected = 0;
|
||||
if (gc_trace) {
|
||||
fprintf(_YAP_stderr, "[agc]\n");
|
||||
fprintf(Yap_stderr, "[agc]\n");
|
||||
} else if (gc_verbose) {
|
||||
fprintf(_YAP_stderr, "[AGC] Start of atom garbage collection %d:\n", agc_calls);
|
||||
fprintf(Yap_stderr, "[AGC] Start of atom garbage collection %d:\n", agc_calls);
|
||||
}
|
||||
time_start = _YAP_cputime();
|
||||
time_start = Yap_cputime();
|
||||
/* get the number of active registers */
|
||||
YAPEnterCriticalSection();
|
||||
mark_stacks();
|
||||
mark_atoms();
|
||||
clean_atoms();
|
||||
YAPLeaveCriticalSection();
|
||||
agc_time = _YAP_cputime()-time_start;
|
||||
agc_time = Yap_cputime()-time_start;
|
||||
tot_agc_time += agc_time;
|
||||
tot_agc_recovered += agc_collected;
|
||||
if (gc_verbose) {
|
||||
fprintf(_YAP_stderr, "[AGC] collected %d bytes.\n", agc_collected);
|
||||
fprintf(_YAP_stderr, "[AGC] GC %d took %g sec, total of %g sec doing GC so far.\n", agc_calls, (double)agc_time/1000, (double)tot_agc_time/1000);
|
||||
fprintf(Yap_stderr, "[AGC] collected %d bytes.\n", agc_collected);
|
||||
fprintf(Yap_stderr, "[AGC] GC %d took %g sec, total of %g sec doing GC so far.\n", agc_calls, (double)agc_time/1000, (double)tot_agc_time/1000);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_atom_gc(void)
|
||||
Yap_atom_gc(void)
|
||||
{
|
||||
atom_gc();
|
||||
}
|
||||
@ -423,13 +423,13 @@ p_inform_agc(void)
|
||||
Term tt = MkIntegerTerm(agc_calls);
|
||||
Term ts = MkIntegerTerm(tot_agc_recovered);
|
||||
|
||||
return(_YAP_unify(tn, ARG2) && _YAP_unify(tt, ARG1) && _YAP_unify(ts, ARG3));
|
||||
return(Yap_unify(tn, ARG2) && Yap_unify(tt, ARG1) && Yap_unify(ts, ARG3));
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_init_agc(void)
|
||||
Yap_init_agc(void)
|
||||
{
|
||||
_YAP_InitCPred("$atom_gc", 0, p_atom_gc, 0);
|
||||
_YAP_InitCPred("$inform_agc", 3, p_inform_agc, 0);
|
||||
Yap_InitCPred("$atom_gc", 0, p_atom_gc, 0);
|
||||
Yap_InitCPred("$inform_agc", 3, p_inform_agc, 0);
|
||||
}
|
||||
|
216
C/alloc.c
216
C/alloc.c
@ -12,7 +12,7 @@
|
||||
* Last rev: *
|
||||
* mods: *
|
||||
* comments: allocating space *
|
||||
* version:$Id: alloc.c,v 1.27 2002-11-11 17:37:52 vsc Exp $ *
|
||||
* version:$Id: alloc.c,v 1.28 2002-11-18 17:56:30 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
#ifdef SCCS
|
||||
static char SccsId[] = "%W% %G%";
|
||||
@ -76,7 +76,7 @@ STATIC_PROTO(void AddToFreeList, (BlockHeader *));
|
||||
/* Yap workspace management */
|
||||
|
||||
int
|
||||
_YAP_SizeOfBlock(CODEADDR p)
|
||||
Yap_SizeOfBlock(CODEADDR p)
|
||||
{
|
||||
BlockHeader *b = (BlockHeader *) (p - sizeof(YAP_SEG_SIZE));
|
||||
YAP_SEG_SIZE s = (b->b_size) & ~InUseFlag;
|
||||
@ -155,10 +155,10 @@ FreeBlock(BlockHeader *b)
|
||||
sp = &(b->b_size) + (b->b_size & ~InUseFlag);
|
||||
if (*sp != b->b_size) {
|
||||
#if !SHORT_INTS
|
||||
fprintf(_YAP_stderr, "** sanity check failed in FreeBlock %p %x %x\n",
|
||||
fprintf(Yap_stderr, "** sanity check failed in FreeBlock %p %x %x\n",
|
||||
b, b->b_size, Unsigned(*sp));
|
||||
#else
|
||||
fprintf(_YAP_stderr, "** sanity check failed in FreeBlock %p %lx %lx\n",
|
||||
fprintf(Yap_stderr, "** sanity check failed in FreeBlock %p %lx %lx\n",
|
||||
b, b->b_size, *sp);
|
||||
#endif
|
||||
return;
|
||||
@ -265,7 +265,7 @@ AllocHeap(unsigned int size)
|
||||
HeapUsed += size * sizeof(CELL) + sizeof(YAP_SEG_SIZE);
|
||||
|
||||
#ifdef YAPOR
|
||||
if (HeapTop > Addr(_YAP_GlobalBase) - MinHeapGap) {
|
||||
if (HeapTop > Addr(Yap_GlobalBase) - MinHeapGap) {
|
||||
abort_optyap("No heap left in function AllocHeap");
|
||||
}
|
||||
#else
|
||||
@ -278,7 +278,7 @@ AllocHeap(unsigned int size)
|
||||
UNLOCK(HeapTopLock);
|
||||
}
|
||||
/* we destroyed the stack */
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, "Stack Crashed against Heap...");
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, "Stack Crashed against Heap...");
|
||||
return(NULL);
|
||||
} else {
|
||||
if (HeapTop + size * sizeof(CELL) + sizeof(YAP_SEG_SIZE) < Addr(AuxSp)) {
|
||||
@ -320,7 +320,7 @@ AllocHeap(unsigned int size)
|
||||
/* If you need to dinamically allocate space from the heap, this is
|
||||
* the macro you should use */
|
||||
ADDR
|
||||
_YAP_PreAllocCodeSpace(void)
|
||||
Yap_PreAllocCodeSpace(void)
|
||||
{
|
||||
LOCK(HeapTopLock);
|
||||
HEAPTOP_OWN(worker_id);
|
||||
@ -331,7 +331,7 @@ _YAP_PreAllocCodeSpace(void)
|
||||
/* Grabbing the HeapTop is an excellent idea for a sequential system,
|
||||
but does work as well in parallel systems. Anyway, this will do for now */
|
||||
void
|
||||
_YAP_ReleasePreAllocCodeSpace(ADDR ptr)
|
||||
Yap_ReleasePreAllocCodeSpace(ADDR ptr)
|
||||
{
|
||||
HEAPTOP_DISOWN(worker_id);
|
||||
UNLOCK(HeapTopLock);
|
||||
@ -349,19 +349,19 @@ FreeCodeSpace(char *p)
|
||||
/* If you need to dinamically allocate space from the heap, this is
|
||||
* the macro you should use */
|
||||
void
|
||||
_YAP_FreeCodeSpace(char *p)
|
||||
Yap_FreeCodeSpace(char *p)
|
||||
{
|
||||
FreeCodeSpace(p);
|
||||
}
|
||||
|
||||
char *
|
||||
_YAP_AllocAtomSpace(unsigned int size)
|
||||
Yap_AllocAtomSpace(unsigned int size)
|
||||
{
|
||||
return (AllocHeap(size));
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_FreeAtomSpace(char *p)
|
||||
Yap_FreeAtomSpace(char *p)
|
||||
{
|
||||
FreeCodeSpace(p);
|
||||
}
|
||||
@ -375,7 +375,7 @@ AllocCodeSpace(unsigned int size)
|
||||
}
|
||||
|
||||
char *
|
||||
_YAP_AllocCodeSpace(unsigned int size)
|
||||
Yap_AllocCodeSpace(unsigned int size)
|
||||
{
|
||||
return AllocCodeSpace(size);
|
||||
}
|
||||
@ -393,7 +393,7 @@ _YAP_AllocCodeSpace(unsigned int size)
|
||||
/* functions: */
|
||||
/* void *InitWorkSpace(int s) - initial workspace allocation */
|
||||
/* int ExtendWorkSpace(int s) - extend workspace */
|
||||
/* int _YAP_FreeWorkSpace() - release workspace */
|
||||
/* int Yap_FreeWorkSpace() - release workspace */
|
||||
/************************************************************************/
|
||||
|
||||
#if defined(_WIN32)
|
||||
@ -410,21 +410,21 @@ static int
|
||||
ExtendWorkSpace(Int s)
|
||||
{
|
||||
LPVOID b;
|
||||
prolog_exec_mode OldPrologMode = _YAP_PrologMode;
|
||||
prolog_exec_mode OldPrologMode = Yap_PrologMode;
|
||||
|
||||
_YAP_PrologMode = ExtendStackMode;
|
||||
s = ((s-1)/_YAP_page_size+1)*_YAP_page_size;
|
||||
Yap_PrologMode = ExtendStackMode;
|
||||
s = ((s-1)/Yap_page_size+1)*Yap_page_size;
|
||||
b = VirtualAlloc(brk, s, MEM_COMMIT, PAGE_READWRITE);
|
||||
if (b) {
|
||||
brk = (LPVOID) ((Int) brk + s);
|
||||
_YAP_PrologMode = OldPrologMode;
|
||||
Yap_PrologMode = OldPrologMode;
|
||||
return TRUE;
|
||||
}
|
||||
_YAP_ErrorMessage = _YAP_ErrorSay;
|
||||
snprintf4(_YAP_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
Yap_ErrorMessage = Yap_ErrorSay;
|
||||
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
"VirtualAlloc could not commit %ld bytes",
|
||||
(long int)s);
|
||||
_YAP_PrologMode = OldPrologMode;
|
||||
Yap_PrologMode = OldPrologMode;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -435,12 +435,12 @@ InitWorkSpace(Int s)
|
||||
LPVOID b;
|
||||
|
||||
GetSystemInfo(&si);
|
||||
_YAP_page_size = si.dwPageSize;
|
||||
Yap_page_size = si.dwPageSize;
|
||||
b = VirtualAlloc(BASE_ADDRESS, MAX_WORKSPACE, MEM_RESERVE, PAGE_NOACCESS);
|
||||
if (b==NULL) {
|
||||
b = VirtualAlloc(0x0, MAX_WORKSPACE, MEM_RESERVE, PAGE_NOACCESS);
|
||||
if (b == NULL) {
|
||||
_YAP_Error(FATAL_ERROR,TermNil,"VirtualAlloc failed");
|
||||
Yap_Error(FATAL_ERROR,TermNil,"VirtualAlloc failed");
|
||||
return(0);
|
||||
}
|
||||
fprintf(stderr,"[ Warning: YAP reserving space at variable address %p ]\n", b);
|
||||
@ -450,13 +450,13 @@ InitWorkSpace(Int s)
|
||||
if (ExtendWorkSpace(s)) {
|
||||
return BASE_ADDRESS;
|
||||
} else {
|
||||
_YAP_Error(FATAL_ERROR,TermNil,"VirtualAlloc Failed");
|
||||
Yap_Error(FATAL_ERROR,TermNil,"VirtualAlloc Failed");
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
_YAP_FreeWorkSpace(void)
|
||||
Yap_FreeWorkSpace(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@ -496,14 +496,14 @@ InitWorkSpace(Int s)
|
||||
a = mmap(((void *)MMAP_ADDR), (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
|
||||
if (a != (MALLOC_T)MMAP_ADDR) {
|
||||
_YAP_Error(FATAL_ERROR, TermNil, "mmap could not map ANON at %p, got %p", (void *)MMAP_ADDR, a);
|
||||
Yap_Error(FATAL_ERROR, TermNil, "mmap could not map ANON at %p, got %p", (void *)MMAP_ADDR, a);
|
||||
return(NULL);
|
||||
}
|
||||
#elif defined(__APPLE__)
|
||||
a = mmap(((void *)MMAP_ADDR), (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0);
|
||||
if (a != (MALLOC_T)MMAP_ADDR) {
|
||||
_YAP_Error(FATAL_ERROR, TermNil, "mmap could not map ANON at %p, got %p", (void *)MMAP_ADDR,a );
|
||||
Yap_Error(FATAL_ERROR, TermNil, "mmap could not map ANON at %p, got %p", (void *)MMAP_ADDR,a );
|
||||
return(NULL);
|
||||
}
|
||||
#else
|
||||
@ -514,9 +514,9 @@ InitWorkSpace(Int s)
|
||||
strncpy(file,"/tmp/YAP.TMPXXXXXX", 256);
|
||||
if (mkstemp(file) == -1) {
|
||||
#if HAVE_STRERROR
|
||||
_YAP_Error(FATAL_ERROR, TermNil, "mkstemp could not create temporary file %s (%s)", file, strerror(errno));
|
||||
Yap_Error(FATAL_ERROR, TermNil, "mkstemp could not create temporary file %s (%s)", file, strerror(errno));
|
||||
#else
|
||||
_YAP_Error(FATAL_ERROR, TermNil, "mkstemp could not create temporary file %s", file);
|
||||
Yap_Error(FATAL_ERROR, TermNil, "mkstemp could not create temporary file %s", file);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
@ -531,21 +531,21 @@ InitWorkSpace(Int s)
|
||||
#endif /* HAVE_MKSTEMP */
|
||||
fd = open(file, O_CREAT|O_RDWR);
|
||||
if (fd < 0) {
|
||||
_YAP_Error(FATAL_ERROR, TermNil, "mmap could not open %s", file);
|
||||
Yap_Error(FATAL_ERROR, TermNil, "mmap could not open %s", file);
|
||||
return NULL;
|
||||
}
|
||||
if (lseek(fd, s, SEEK_SET) < 0) {
|
||||
_YAP_Error(FATAL_ERROR, TermNil, "mmap could not lseek in mmapped file %s", file);
|
||||
Yap_Error(FATAL_ERROR, TermNil, "mmap could not lseek in mmapped file %s", file);
|
||||
close(fd);
|
||||
return FALSE;
|
||||
}
|
||||
if (write(fd, "", 1) < 0) {
|
||||
_YAP_Error(FATAL_ERROR, TermNil, "mmap could not write in mmapped file %s", file);
|
||||
Yap_Error(FATAL_ERROR, TermNil, "mmap could not write in mmapped file %s", file);
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
if (unlink(file) < 0) {
|
||||
_YAP_Error(FATAL_ERROR,TermNil, "mmap could not unlink mmapped file %s", file);
|
||||
Yap_Error(FATAL_ERROR,TermNil, "mmap could not unlink mmapped file %s", file);
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
@ -554,7 +554,7 @@ InitWorkSpace(Int s)
|
||||
a = mmap(((void *)MMAP_ADDR), (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
MAP_PRIVATE | MAP_FIXED, fd, 0);
|
||||
if (a != (MALLOC_T)MMAP_ADDR) {
|
||||
_YAP_Error(FATAL_ERROR, TermNil, "mmap could not map at %p, got %p", (void *)MMAP_ADDR, a);
|
||||
Yap_Error(FATAL_ERROR, TermNil, "mmap could not map at %p, got %p", (void *)MMAP_ADDR, a);
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
@ -562,11 +562,11 @@ InitWorkSpace(Int s)
|
||||
MAP_PRIVATE, fd, 0);
|
||||
if ((CELL)a & YAP_PROTECTED_MASK) {
|
||||
close(fd);
|
||||
_YAP_Error(FATAL_ERROR, TermNil, "mmapped address %p collides with YAP tags", a);
|
||||
Yap_Error(FATAL_ERROR, TermNil, "mmapped address %p collides with YAP tags", a);
|
||||
return NULL;
|
||||
}
|
||||
if (close(fd) == -1) {
|
||||
_YAP_Error(FATAL_ERROR, TermNil, "while closing mmaped file");
|
||||
Yap_Error(FATAL_ERROR, TermNil, "while closing mmaped file");
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
@ -578,7 +578,7 @@ InitWorkSpace(Int s)
|
||||
(a == (MALLOC_T) - 1)
|
||||
#endif
|
||||
{
|
||||
_YAP_Error(FATAL_ERROR, TermNil, "mmap cannot allocate memory ***");
|
||||
Yap_Error(FATAL_ERROR, TermNil, "mmap cannot allocate memory ***");
|
||||
return(NULL);
|
||||
}
|
||||
WorkSpaceTop = (char *) a + s;
|
||||
@ -594,36 +594,36 @@ ExtendWorkSpace(Int s)
|
||||
#else
|
||||
|
||||
MALLOC_T a;
|
||||
prolog_exec_mode OldPrologMode = _YAP_PrologMode;
|
||||
prolog_exec_mode OldPrologMode = Yap_PrologMode;
|
||||
|
||||
#if defined(_AIX) || defined(__hpux)
|
||||
_YAP_PrologMode = ExtendStackMode;
|
||||
Yap_PrologMode = ExtendStackMode;
|
||||
a = mmap(WorkSpaceTop, (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
_YAP_PrologMode = ExtendStackMode;
|
||||
Yap_PrologMode = ExtendStackMode;
|
||||
a = mmap(WorkSpaceTop, (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0);
|
||||
#else
|
||||
int fd;
|
||||
_YAP_PrologMode = ExtendStackMode;
|
||||
Yap_PrologMode = ExtendStackMode;
|
||||
fd = open("/dev/zero", O_RDWR);
|
||||
if (fd < 0) {
|
||||
#if HAVE_MKSTEMP
|
||||
char file[256];
|
||||
strncpy(file,"/tmp/YAP.TMPXXXXXX",256);
|
||||
if (mkstemp(file) == -1) {
|
||||
_YAP_ErrorMessage = _YAP_ErrorSay;
|
||||
Yap_ErrorMessage = Yap_ErrorSay;
|
||||
#if HAVE_STRERROR
|
||||
snprintf5(_YAP_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
snprintf5(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
"mkstemp could not create temporary file %s (%s)",
|
||||
file, strerror(errno));
|
||||
#else
|
||||
snprintf4(_YAP_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
"mkstemp could not create temporary file %s", file);
|
||||
#endif /* HAVE_STRERROR */
|
||||
_YAP_PrologMode = OldPrologMode;
|
||||
Yap_PrologMode = OldPrologMode;
|
||||
return FALSE;
|
||||
}
|
||||
#else
|
||||
@ -637,33 +637,33 @@ ExtendWorkSpace(Int s)
|
||||
#endif /* HAVE_MKSTEMP */
|
||||
fd = open(file, O_CREAT|O_RDWR);
|
||||
if (fd < 0) {
|
||||
_YAP_ErrorMessage = _YAP_ErrorSay;
|
||||
snprintf4(_YAP_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
Yap_ErrorMessage = Yap_ErrorSay;
|
||||
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
"mmap could not open %s", file);
|
||||
_YAP_PrologMode = OldPrologMode;
|
||||
Yap_PrologMode = OldPrologMode;
|
||||
return FALSE;
|
||||
}
|
||||
if (lseek(fd, s, SEEK_SET) < 0) {
|
||||
_YAP_ErrorMessage = _YAP_ErrorSay;
|
||||
snprintf4(_YAP_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
Yap_ErrorMessage = Yap_ErrorSay;
|
||||
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
"mmap could not lseek in mmapped file %s", file);
|
||||
_YAP_PrologMode = OldPrologMode;
|
||||
Yap_PrologMode = OldPrologMode;
|
||||
close(fd);
|
||||
return FALSE;
|
||||
}
|
||||
if (write(fd, "", 1) < 0) {
|
||||
_YAP_ErrorMessage = _YAP_ErrorSay;
|
||||
snprintf4(_YAP_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
Yap_ErrorMessage = Yap_ErrorSay;
|
||||
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
"mmap could not write in mmapped file %s", file);
|
||||
_YAP_PrologMode = OldPrologMode;
|
||||
Yap_PrologMode = OldPrologMode;
|
||||
close(fd);
|
||||
return FALSE;
|
||||
}
|
||||
if (unlink(file) < 0) {
|
||||
_YAP_ErrorMessage = _YAP_ErrorSay;
|
||||
snprintf4(_YAP_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
Yap_ErrorMessage = Yap_ErrorSay;
|
||||
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
"mmap could not unlink mmapped file %s", file);
|
||||
_YAP_PrologMode = OldPrologMode;
|
||||
Yap_PrologMode = OldPrologMode;
|
||||
close(fd);
|
||||
return FALSE;
|
||||
}
|
||||
@ -676,46 +676,46 @@ ExtendWorkSpace(Int s)
|
||||
#endif
|
||||
, fd, 0);
|
||||
if (close(fd) == -1) {
|
||||
_YAP_ErrorMessage = _YAP_ErrorSay;
|
||||
Yap_ErrorMessage = Yap_ErrorSay;
|
||||
#if HAVE_STRERROR
|
||||
snprintf4(_YAP_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
"mmap could not close file (%s) ]\n", strerror(errno));
|
||||
#else
|
||||
snprintf3(_YAP_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
snprintf3(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
"mmap could not close file ]\n");
|
||||
#endif
|
||||
_YAP_PrologMode = OldPrologMode;
|
||||
Yap_PrologMode = OldPrologMode;
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
if (a == (MALLOC_T) - 1) {
|
||||
_YAP_ErrorMessage = _YAP_ErrorSay;
|
||||
Yap_ErrorMessage = Yap_ErrorSay;
|
||||
#if HAVE_STRERROR
|
||||
snprintf5(_YAP_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
snprintf5(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
"could not allocate %d bytes (%s)", (int)s, strerror(errno));
|
||||
#else
|
||||
snprintf4(_YAP_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
"could not allocate %d bytes", (int)s);
|
||||
#endif
|
||||
_YAP_PrologMode = OldPrologMode;
|
||||
Yap_PrologMode = OldPrologMode;
|
||||
return FALSE;
|
||||
}
|
||||
if (a != WorkSpaceTop) {
|
||||
_YAP_ErrorMessage = _YAP_ErrorSay;
|
||||
snprintf5(_YAP_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
Yap_ErrorMessage = Yap_ErrorSay;
|
||||
snprintf5(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
"mmap could not grow memory at %p, got %p", WorkSpaceTop, a );
|
||||
_YAP_PrologMode = OldPrologMode;
|
||||
Yap_PrologMode = OldPrologMode;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
WorkSpaceTop = (char *) a + s;
|
||||
_YAP_PrologMode = OldPrologMode;
|
||||
Yap_PrologMode = OldPrologMode;
|
||||
return TRUE;
|
||||
#endif /* YAPOR */
|
||||
}
|
||||
|
||||
int
|
||||
_YAP_FreeWorkSpace(void)
|
||||
Yap_FreeWorkSpace(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@ -740,15 +740,15 @@ InitWorkSpace(Int s)
|
||||
|
||||
/* mapping heap area */
|
||||
if((shm_id = shmget(IPC_PRIVATE, (size_t)s, SHM_R|SHM_W)) == -1) {
|
||||
_YAP_Error(FATAL_ERROR, TermNil, "could not shmget %d bytes", s);
|
||||
Yap_Error(FATAL_ERROR, TermNil, "could not shmget %d bytes", s);
|
||||
return(NULL);
|
||||
}
|
||||
if((ptr = (MALLOC_T)shmat(shm_id, (void *) MMAP_ADDR, 0)) == (MALLOC_T) -1) {
|
||||
_YAP_Error(FATAL_ERROR, TermNil, "could not shmat at %p", MMAP_ADDR);
|
||||
Yap_Error(FATAL_ERROR, TermNil, "could not shmat at %p", MMAP_ADDR);
|
||||
return(NULL);
|
||||
}
|
||||
if (shmctl(shm_id, IPC_RMID, 0) != 0) {
|
||||
_YAP_Error(FATAL_ERROR, TermNil, "could not remove shm segment", shm_id);
|
||||
Yap_Error(FATAL_ERROR, TermNil, "could not remove shm segment", shm_id);
|
||||
return(NULL);
|
||||
}
|
||||
WorkSpaceTop = (char *) ptr + s;
|
||||
@ -765,22 +765,22 @@ ExtendWorkSpace(Int s)
|
||||
PrologMode = ExtendStackMode;
|
||||
/* mapping heap area */
|
||||
if((shm_id = shmget(IPC_PRIVATE, (size_t)s, SHM_R|SHM_W)) == -1) {
|
||||
_YAP_ErrorMessage = _YAP_ErrorSay;
|
||||
snprintf4(_YAP_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
Yap_ErrorMessage = Yap_ErrorSay;
|
||||
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
"could not shmget %d bytes", s);
|
||||
PrologMode = OldPrologMode;
|
||||
return(FALSE);
|
||||
}
|
||||
if((ptr = (MALLOC_T)shmat(shm_id, WorkSpaceTop, 0)) == (MALLOC_T) -1) {
|
||||
_YAP_ErrorMessage = _YAP_ErrorSay;
|
||||
snprintf4(_YAP_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
Yap_ErrorMessage = Yap_ErrorSay;
|
||||
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
"could not shmat at %p", MMAP_ADDR);
|
||||
PrologMode = OldPrologMode;
|
||||
return(FALSE);
|
||||
}
|
||||
if (shmctl(shm_id, IPC_RMID, 0) != 0) {
|
||||
_YAP_ErrorMessage = _YAP_ErrorSay;
|
||||
snprintf4(_YAP_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
Yap_ErrorMessage = Yap_ErrorSay;
|
||||
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
"could not remove shm segment", shm_id);
|
||||
PrologMode = OldPrologMode;
|
||||
return(FALSE);
|
||||
@ -791,7 +791,7 @@ ExtendWorkSpace(Int s)
|
||||
}
|
||||
|
||||
int
|
||||
_YAP_FreeWorkSpace(void)
|
||||
Yap_FreeWorkSpace(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@ -825,7 +825,7 @@ InitWorkSpace(Int s)
|
||||
MALLOC_T ptr = (MALLOC_T)sbrk(s);
|
||||
|
||||
if (ptr == ((MALLOC_T) - 1)) {
|
||||
_YAP_Error(FATAL_ERROR, TermNil, "could not allocate %d bytes", s);
|
||||
Yap_Error(FATAL_ERROR, TermNil, "could not allocate %d bytes", s);
|
||||
return(NULL);
|
||||
}
|
||||
return(ptr);
|
||||
@ -839,8 +839,8 @@ ExtendWorkSpace(Int s)
|
||||
|
||||
PrologMode = ExtendStackMode;
|
||||
if (ptr == ((MALLOC_T) - 1)) {
|
||||
_YAP_ErrorMessage = _YAP_ErrorSay;
|
||||
snprintf4(_YAP_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
Yap_ErrorMessage = Yap_ErrorSay;
|
||||
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
"could not expand stacks over %d bytes", s);
|
||||
PrologMode = OldPrologMode;
|
||||
return(FALSE);
|
||||
@ -850,7 +850,7 @@ ExtendWorkSpace(Int s)
|
||||
}
|
||||
|
||||
int
|
||||
_YAP_FreeWorkSpace(void)
|
||||
Yap_FreeWorkSpace(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@ -885,7 +885,7 @@ free(MALLOC_T ptr)
|
||||
}
|
||||
if (!ptr)
|
||||
return;
|
||||
if ((char *) ptr < _YAP_HeapBase || (char *) ptr > HeapTop)
|
||||
if ((char *) ptr < Yap_HeapBase || (char *) ptr > HeapTop)
|
||||
return;
|
||||
if (!(b->b_size & InUseFlag))
|
||||
return;
|
||||
@ -955,7 +955,7 @@ InitWorkSpace(Int s)
|
||||
total_space = s;
|
||||
|
||||
if (ptr == NULL) {
|
||||
_YAP_Error(FATAL_ERROR, TermNil, "could not allocate %d bytes", s);
|
||||
Yap_Error(FATAL_ERROR, TermNil, "could not allocate %d bytes", s);
|
||||
return(NULL);
|
||||
}
|
||||
return(ptr);
|
||||
@ -970,24 +970,24 @@ ExtendWorkSpace(Int s)
|
||||
PrologMode = ExtendStackMode;
|
||||
total_space += s;
|
||||
if (total_space < MAX_SPACE) return(TRUE);
|
||||
ptr = (MALLOC_T)realloc((void *)_YAP_HeapBase, total_space);
|
||||
ptr = (MALLOC_T)realloc((void *)Yap_HeapBase, total_space);
|
||||
if (ptr == NULL) {
|
||||
_YAP_ErrorMessage = _YAP_ErrorSay;
|
||||
snprintf4(_YAP_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
Yap_ErrorMessage = Yap_ErrorSay;
|
||||
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
"could not allocate %d bytes", s);
|
||||
PrologMode = OldPrologMode;
|
||||
return(FALSE);
|
||||
}
|
||||
if (ptr != (MALLOC_T)_YAP_HeapBase) {
|
||||
_YAP_ErrorMessage = _YAP_ErrorSay;
|
||||
snprintf4(_YAP_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
if (ptr != (MALLOC_T)Yap_HeapBase) {
|
||||
Yap_ErrorMessage = Yap_ErrorSay;
|
||||
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
"could not expand contiguous stacks %d bytes", s);
|
||||
PrologMode = OldPrologMode;
|
||||
return(FALSE);
|
||||
}
|
||||
if ((CELL)ptr & MBIT) {
|
||||
_YAP_ErrorMessage = _YAP_ErrorSay;
|
||||
snprintf5(_YAP_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
Yap_ErrorMessage = Yap_ErrorSay;
|
||||
snprintf5(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
|
||||
"memory at %p conflicts with MBIT %lx", ptr, (unsigned long)MBIT);
|
||||
PrologMode = OldPrologMode;
|
||||
return(FALSE);
|
||||
@ -997,7 +997,7 @@ ExtendWorkSpace(Int s)
|
||||
}
|
||||
|
||||
int
|
||||
_YAP_FreeWorkSpace(void)
|
||||
Yap_FreeWorkSpace(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@ -1007,13 +1007,13 @@ static void
|
||||
InitHeap(void *heap_addr)
|
||||
{
|
||||
/* allocate space */
|
||||
_YAP_HeapBase = heap_addr;
|
||||
Yap_HeapBase = heap_addr;
|
||||
|
||||
/* reserve space for specially allocated functors and atoms so that
|
||||
their values can be known statically */
|
||||
HeapTop = _YAP_HeapBase + AdjustSize(sizeof(all_heap_codes));
|
||||
HeapTop = Yap_HeapBase + AdjustSize(sizeof(all_heap_codes));
|
||||
|
||||
HeapMax = HeapUsed = HeapTop-_YAP_HeapBase;
|
||||
HeapMax = HeapUsed = HeapTop-Yap_HeapBase;
|
||||
|
||||
*((YAP_SEG_SIZE *) HeapTop) = InUseFlag;
|
||||
HeapTop = HeapTop + sizeof(YAP_SEG_SIZE);
|
||||
@ -1039,13 +1039,13 @@ InitHeap(void *heap_addr)
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_InitHeap(void *heap_addr)
|
||||
Yap_InitHeap(void *heap_addr)
|
||||
{
|
||||
InitHeap(heap_addr);
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_InitMemory(int Trail, int Heap, int Stack)
|
||||
Yap_InitMemory(int Trail, int Heap, int Stack)
|
||||
{
|
||||
Int pm, sa, ta;
|
||||
|
||||
@ -1060,12 +1060,12 @@ _YAP_InitMemory(int Trail, int Heap, int Stack)
|
||||
|
||||
InitHeap(InitWorkSpace(pm));
|
||||
|
||||
_YAP_TrailTop = _YAP_HeapBase + pm;
|
||||
_YAP_LocalBase = _YAP_TrailTop - ta;
|
||||
_YAP_TrailBase = _YAP_LocalBase + sizeof(CELL);
|
||||
Yap_TrailTop = Yap_HeapBase + pm;
|
||||
Yap_LocalBase = Yap_TrailTop - ta;
|
||||
Yap_TrailBase = Yap_LocalBase + sizeof(CELL);
|
||||
|
||||
_YAP_GlobalBase = _YAP_LocalBase - sa;
|
||||
AuxTop = _YAP_GlobalBase - CellSize; /* avoid confusions while
|
||||
Yap_GlobalBase = Yap_LocalBase - sa;
|
||||
AuxTop = Yap_GlobalBase - CellSize; /* avoid confusions while
|
||||
* * restoring */
|
||||
AuxSp = (CELL *) AuxTop;
|
||||
|
||||
@ -1073,12 +1073,12 @@ _YAP_InitMemory(int Trail, int Heap, int Stack)
|
||||
#if SIZEOF_INT_P!=SIZEOF_INT
|
||||
if (output_msg) {
|
||||
fprintf(stderr, "HeapBase = %p GlobalBase = %p\n LocalBase = %p TrailTop = %p\n",
|
||||
_YAP_HeapBase, _YAP_GlobalBase, _YAP_LocalBase, _YAP_TrailTop);
|
||||
Yap_HeapBase, Yap_GlobalBase, Yap_LocalBase, Yap_TrailTop);
|
||||
#else
|
||||
if (output_msg) {
|
||||
fprintf(stderr, "HeapBase = %x GlobalBase = %x\n LocalBase = %x TrailTop = %x\n",
|
||||
(UInt) _YAP_HeapBase, (UInt) _YAP_GlobalBase,
|
||||
(UInt) _YAP_LocalBase, (UInt) _YAP_TrailTop);
|
||||
(UInt) Yap_HeapBase, (UInt) Yap_GlobalBase,
|
||||
(UInt) Yap_LocalBase, (UInt) Yap_TrailTop);
|
||||
#endif
|
||||
|
||||
#if !SHORT_INTS
|
||||
@ -1094,7 +1094,7 @@ _YAP_InitMemory(int Trail, int Heap, int Stack)
|
||||
}
|
||||
|
||||
int
|
||||
_YAP_ExtendWorkSpace(Int s)
|
||||
Yap_ExtendWorkSpace(Int s)
|
||||
{
|
||||
return ExtendWorkSpace(s);
|
||||
}
|
||||
|
108
C/amasm.c
108
C/amasm.c
@ -297,8 +297,8 @@ DumpOpCodes(void)
|
||||
|
||||
while (i < 30) {
|
||||
for (j = i; j <= _std_top; j += 25)
|
||||
fprintf(_YAP_stderr, "%5d %6lx", j, absmadr(j));
|
||||
fputc('\n',_YAP_stderr);
|
||||
fprintf(Yap_stderr, "%5d %6lx", j, absmadr(j));
|
||||
fputc('\n',Yap_stderr);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
@ -317,7 +317,7 @@ opcode(op_numbers op)
|
||||
}
|
||||
|
||||
OPCODE
|
||||
_YAP_opcode(op_numbers op)
|
||||
Yap_opcode(op_numbers op)
|
||||
{
|
||||
return (opcode(op));
|
||||
}
|
||||
@ -731,15 +731,15 @@ a_p(op_numbers opcode)
|
||||
break;
|
||||
default:
|
||||
op = _p_equal; /* just to make some compilers happy */
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, "internal assembler error for built-in (%d)", (Flags & 0x7f));
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, "internal assembler error for built-in (%d)", (Flags & 0x7f));
|
||||
save_machine_regs();
|
||||
longjmp(_YAP_CompilerBotch, 1);
|
||||
longjmp(Yap_CompilerBotch, 1);
|
||||
}
|
||||
a_e(op);
|
||||
if (!comit_ok) {
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,"internal assembler error for commit");
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,"internal assembler error for commit");
|
||||
save_machine_regs();
|
||||
longjmp(_YAP_CompilerBotch, 1);
|
||||
longjmp(Yap_CompilerBotch, 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -748,10 +748,10 @@ a_p(op_numbers opcode)
|
||||
if (!comit_ok && (Flags & TestPredFlag)) {
|
||||
if (pass_no) {
|
||||
if (Flags & UserCPredFlag) {
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"user defined predicate cannot be a test predicate");
|
||||
save_machine_regs();
|
||||
longjmp(_YAP_CompilerBotch, 1);
|
||||
longjmp(Yap_CompilerBotch, 1);
|
||||
} else
|
||||
code_p->opc = emit_op(_call_c_wfail);
|
||||
code_p->u.sdl.s =
|
||||
@ -796,9 +796,9 @@ a_p(op_numbers opcode)
|
||||
GONEXT(sla);
|
||||
}
|
||||
if (!comit_ok) {
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, "internal assembler error for commit");
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, "internal assembler error for commit");
|
||||
save_machine_regs();
|
||||
longjmp(_YAP_CompilerBotch,1);
|
||||
longjmp(Yap_CompilerBotch,1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -838,9 +838,9 @@ a_p(op_numbers opcode)
|
||||
GONEXT(l);
|
||||
}
|
||||
if (!comit_ok) {
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, "internal assembler error for commit");
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, "internal assembler error for commit");
|
||||
save_machine_regs();
|
||||
longjmp(_YAP_CompilerBotch,1);
|
||||
longjmp(Yap_CompilerBotch,1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -862,7 +862,7 @@ a_empty_call(void)
|
||||
code_p->opc = emit_op(_fcall);
|
||||
}
|
||||
if (pass_no) {
|
||||
PredEntry *pe = RepPredProp(_YAP_GetPredPropByAtom(AtomTrue,0));
|
||||
PredEntry *pe = RepPredProp(Yap_GetPredPropByAtom(AtomTrue,0));
|
||||
code_p->u.sla.s = emit_count(-Signed(RealEnvSize) - CELLSIZE *
|
||||
cpc->rnd2);
|
||||
code_p->u.sla.l = emit_a((CELL)&(pe->StateOfPred));
|
||||
@ -906,7 +906,7 @@ compile_cmp_flags(char *s)
|
||||
if (strcmp(s,">") == 0) return(GT_OK_IN_CMP);
|
||||
if (strcmp(s,"=:=") == 0) return(EQ_OK_IN_CMP);
|
||||
if (strcmp(s,"=\\=") == 0) return(GT_OK_IN_CMP|LT_OK_IN_CMP);
|
||||
_YAP_Error(SYSTEM_ERROR, x1_arg, "internal assembler error in flags for %s", s);
|
||||
Yap_Error(SYSTEM_ERROR, x1_arg, "internal assembler error in flags for %s", s);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@ -1189,7 +1189,7 @@ a_either(op_numbers opcode, CELL opr, CELL lab)
|
||||
#endif /* YAPOR */
|
||||
{
|
||||
if (pass_no) {
|
||||
Prop fe = _YAP_GetPredPropByAtom(AtomTrue,0);
|
||||
Prop fe = Yap_GetPredPropByAtom(AtomTrue,0);
|
||||
code_p->opc = emit_op(opcode);
|
||||
code_p->u.sla.s = emit_count(opr);
|
||||
code_p->u.sla.l = emit_a(lab);
|
||||
@ -1712,40 +1712,40 @@ a_f2(int var)
|
||||
if (pass_no) {
|
||||
switch (opc) {
|
||||
case _plus:
|
||||
_YAP_Error(SYSTEM_ERROR, x1_arg, "internal assembler error CX for +/2");
|
||||
Yap_Error(SYSTEM_ERROR, x1_arg, "internal assembler error CX for +/2");
|
||||
save_machine_regs();
|
||||
longjmp(_YAP_CompilerBotch, 1);
|
||||
longjmp(Yap_CompilerBotch, 1);
|
||||
break;
|
||||
case _minus:
|
||||
code_p->opc = emit_op(_p_minus_y_cv);
|
||||
break;
|
||||
case _times:
|
||||
_YAP_Error(SYSTEM_ERROR, x1_arg, "internal assembler error CX for */2");
|
||||
Yap_Error(SYSTEM_ERROR, x1_arg, "internal assembler error CX for */2");
|
||||
save_machine_regs();
|
||||
longjmp(_YAP_CompilerBotch, 1);
|
||||
longjmp(Yap_CompilerBotch, 1);
|
||||
break;
|
||||
case _div:
|
||||
code_p->opc = emit_op(_p_div_y_cv);
|
||||
break;
|
||||
case _and:
|
||||
_YAP_Error(SYSTEM_ERROR, x1_arg, "internal assembler error CX for /\\/2");
|
||||
Yap_Error(SYSTEM_ERROR, x1_arg, "internal assembler error CX for /\\/2");
|
||||
save_machine_regs();
|
||||
longjmp(_YAP_CompilerBotch, 1);
|
||||
longjmp(Yap_CompilerBotch, 1);
|
||||
break;
|
||||
case _or:
|
||||
_YAP_Error(SYSTEM_ERROR, x1_arg, "internal assembler error CX for \\//2");
|
||||
Yap_Error(SYSTEM_ERROR, x1_arg, "internal assembler error CX for \\//2");
|
||||
save_machine_regs();
|
||||
longjmp(_YAP_CompilerBotch, 1);
|
||||
longjmp(Yap_CompilerBotch, 1);
|
||||
break;
|
||||
case _sll:
|
||||
code_p->opc = emit_op(_p_sll_y_cv);
|
||||
save_machine_regs();
|
||||
longjmp(_YAP_CompilerBotch, 1);
|
||||
longjmp(Yap_CompilerBotch, 1);
|
||||
break;
|
||||
case _slr:
|
||||
code_p->opc = emit_op(_p_slr_y_cv);
|
||||
save_machine_regs();
|
||||
longjmp(_YAP_CompilerBotch, 1);
|
||||
longjmp(Yap_CompilerBotch, 1);
|
||||
break;
|
||||
case _arg:
|
||||
code_p->opc = emit_op(_p_arg_y_cv);
|
||||
@ -1767,9 +1767,9 @@ a_f2(int var)
|
||||
code_p->opc = emit_op(_p_plus_y_vc);
|
||||
break;
|
||||
case _minus:
|
||||
_YAP_Error(SYSTEM_ERROR, x2_arg, "internal assembler error XC for -/2");
|
||||
Yap_Error(SYSTEM_ERROR, x2_arg, "internal assembler error XC for -/2");
|
||||
save_machine_regs();
|
||||
longjmp(_YAP_CompilerBotch, 1);
|
||||
longjmp(Yap_CompilerBotch, 1);
|
||||
break;
|
||||
case _times:
|
||||
code_p->opc = emit_op(_p_times_y_vc);
|
||||
@ -1790,9 +1790,9 @@ a_f2(int var)
|
||||
code_p->opc = emit_op(_p_slr_y_vc);
|
||||
break;
|
||||
case _arg:
|
||||
_YAP_Error(SYSTEM_ERROR, x2_arg, "internal assembler error for arg/3");
|
||||
Yap_Error(SYSTEM_ERROR, x2_arg, "internal assembler error for arg/3");
|
||||
save_machine_regs();
|
||||
longjmp(_YAP_CompilerBotch, 1);
|
||||
longjmp(Yap_CompilerBotch, 1);
|
||||
break;
|
||||
case _functor:
|
||||
code_p->opc = emit_op(_p_func2s_y_vc);
|
||||
@ -1851,30 +1851,30 @@ a_f2(int var)
|
||||
if (pass_no) {
|
||||
switch (opc) {
|
||||
case _plus:
|
||||
_YAP_Error(SYSTEM_ERROR, x1_arg, "internal assembler error CX for +/2");
|
||||
Yap_Error(SYSTEM_ERROR, x1_arg, "internal assembler error CX for +/2");
|
||||
save_machine_regs();
|
||||
longjmp(_YAP_CompilerBotch, 1);
|
||||
longjmp(Yap_CompilerBotch, 1);
|
||||
break;
|
||||
case _minus:
|
||||
code_p->opc = emit_op(_p_minus_cv);
|
||||
break;
|
||||
case _times:
|
||||
_YAP_Error(SYSTEM_ERROR, x1_arg, "internal assembler error CX for */2");
|
||||
Yap_Error(SYSTEM_ERROR, x1_arg, "internal assembler error CX for */2");
|
||||
save_machine_regs();
|
||||
longjmp(_YAP_CompilerBotch, 1);
|
||||
longjmp(Yap_CompilerBotch, 1);
|
||||
break;
|
||||
case _div:
|
||||
code_p->opc = emit_op(_p_div_cv);
|
||||
break;
|
||||
case _and:
|
||||
_YAP_Error(SYSTEM_ERROR, x1_arg, "internal assembler error CX for /\\/2");
|
||||
Yap_Error(SYSTEM_ERROR, x1_arg, "internal assembler error CX for /\\/2");
|
||||
save_machine_regs();
|
||||
longjmp(_YAP_CompilerBotch, 1);
|
||||
longjmp(Yap_CompilerBotch, 1);
|
||||
break;
|
||||
case _or:
|
||||
_YAP_Error(SYSTEM_ERROR, x1_arg, "internal assembler error CX for \\//2");
|
||||
Yap_Error(SYSTEM_ERROR, x1_arg, "internal assembler error CX for \\//2");
|
||||
save_machine_regs();
|
||||
longjmp(_YAP_CompilerBotch, 1);
|
||||
longjmp(Yap_CompilerBotch, 1);
|
||||
break;
|
||||
case _sll:
|
||||
code_p->opc = emit_op(_p_sll_cv);
|
||||
@ -1902,9 +1902,9 @@ a_f2(int var)
|
||||
code_p->opc = emit_op(_p_plus_vc);
|
||||
break;
|
||||
case _minus:
|
||||
_YAP_Error(SYSTEM_ERROR, x2_arg, "internal assembler error XC for -/2");
|
||||
Yap_Error(SYSTEM_ERROR, x2_arg, "internal assembler error XC for -/2");
|
||||
save_machine_regs();
|
||||
longjmp(_YAP_CompilerBotch, 1);
|
||||
longjmp(Yap_CompilerBotch, 1);
|
||||
break;
|
||||
case _times:
|
||||
code_p->opc = emit_op(_p_times_vc);
|
||||
@ -1925,9 +1925,9 @@ a_f2(int var)
|
||||
code_p->opc = emit_op(_p_slr_vc);
|
||||
break;
|
||||
case _arg:
|
||||
_YAP_Error(SYSTEM_ERROR, x2_arg, "internal assembler error for arg/3");
|
||||
Yap_Error(SYSTEM_ERROR, x2_arg, "internal assembler error for arg/3");
|
||||
save_machine_regs();
|
||||
longjmp(_YAP_CompilerBotch, 1);
|
||||
longjmp(Yap_CompilerBotch, 1);
|
||||
break;
|
||||
case _functor:
|
||||
code_p->opc = emit_op(_p_func2s_vc);
|
||||
@ -1985,7 +1985,7 @@ do_pass(void)
|
||||
cl_p->ClFlags |= HasBlobsMask;
|
||||
}
|
||||
cl_p->u2.ClExt = NULL;
|
||||
cl_p->Owner = _YAP_ConsultingFile();
|
||||
cl_p->Owner = Yap_ConsultingFile();
|
||||
}
|
||||
code_p = (yamop *)(cl_p->ClCode);
|
||||
IPredArity = cpc->rnd2; /* number of args */
|
||||
@ -2396,7 +2396,7 @@ do_pass(void)
|
||||
if (!pass_no) {
|
||||
if (CellPtr(label_offset+cpc->rnd1) > ASP-256) {
|
||||
save_machine_regs();
|
||||
longjmp(_YAP_CompilerBotch,3);
|
||||
longjmp(Yap_CompilerBotch,3);
|
||||
}
|
||||
|
||||
if ( (char *)(label_offset+cpc->rnd1) > freep)
|
||||
@ -2545,9 +2545,9 @@ do_pass(void)
|
||||
break;
|
||||
case fetch_args_for_bccall:
|
||||
if (cpc->nextInst->op != bccall_op) {
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, "compiling binary test", (int) cpc->op);
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, "compiling binary test", (int) cpc->op);
|
||||
save_machine_regs();
|
||||
longjmp(_YAP_CompilerBotch, 1);
|
||||
longjmp(Yap_CompilerBotch, 1);
|
||||
}
|
||||
a_bfunc(cpc->nextInst->rnd2);
|
||||
break;
|
||||
@ -2566,9 +2566,9 @@ do_pass(void)
|
||||
case name_op:
|
||||
break;
|
||||
default:
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, "instruction %d found while assembling", (int) cpc->op);
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, "instruction %d found while assembling", (int) cpc->op);
|
||||
save_machine_regs();
|
||||
longjmp(_YAP_CompilerBotch, 1);
|
||||
longjmp(Yap_CompilerBotch, 1);
|
||||
}
|
||||
cpc = cpc->nextInst;
|
||||
}
|
||||
@ -2577,7 +2577,7 @@ do_pass(void)
|
||||
}
|
||||
|
||||
CODEADDR
|
||||
_YAP_assemble(int mode)
|
||||
Yap_assemble(int mode)
|
||||
{
|
||||
/*
|
||||
* the assembly proccess is done in two passes: 1 - a first pass
|
||||
@ -2594,8 +2594,8 @@ _YAP_assemble(int mode)
|
||||
asm_error = FALSE;
|
||||
do_pass();
|
||||
if (asm_error) {
|
||||
_YAP_Error_TYPE = SYSTEM_ERROR;
|
||||
_YAP_ErrorMessage = "internal assembler error";
|
||||
Yap_Error_TYPE = SYSTEM_ERROR;
|
||||
Yap_ErrorMessage = "internal assembler error";
|
||||
return (NIL);
|
||||
}
|
||||
pass_no = 1;
|
||||
@ -2610,9 +2610,9 @@ _YAP_assemble(int mode)
|
||||
#else
|
||||
size = (CELL)code_p;
|
||||
#endif
|
||||
while ((code_addr = (CODEADDR) _YAP_AllocCodeSpace(size)) == NULL) {
|
||||
if (!_YAP_growheap(TRUE)) {
|
||||
_YAP_Error_TYPE = SYSTEM_ERROR;
|
||||
while ((code_addr = (CODEADDR) Yap_AllocCodeSpace(size)) == NULL) {
|
||||
if (!Yap_growheap(TRUE)) {
|
||||
Yap_Error_TYPE = SYSTEM_ERROR;
|
||||
return (NIL);
|
||||
}
|
||||
}
|
||||
|
686
C/analyst.c
686
C/analyst.c
File diff suppressed because it is too large
Load Diff
26
C/arith0.c
26
C/arith0.c
@ -68,12 +68,12 @@ static E_FUNC
|
||||
p_inf(E_ARGS)
|
||||
{
|
||||
#ifdef _MSC_VER /* Microsoft's Visual C++ Compiler */
|
||||
_YAP_Error(TYPE_ERROR_EVALUABLE, TermNil, "evaluating infinity");
|
||||
Yap_Error(TYPE_ERROR_EVALUABLE, TermNil, "evaluating infinity");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#else
|
||||
if (yap_flags[LANGUAGE_MODE_FLAG] == 1) {/* iso */
|
||||
_YAP_Error(TYPE_ERROR_EVALUABLE, TermNil, "evaluating infinity");
|
||||
Yap_Error(TYPE_ERROR_EVALUABLE, TermNil, "evaluating infinity");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
} else {
|
||||
@ -91,12 +91,12 @@ static E_FUNC
|
||||
p_nan(E_ARGS)
|
||||
{
|
||||
#ifdef _MSC_VER /* Microsoft's Visual C++ Compiler */
|
||||
_YAP_Error(TYPE_ERROR_EVALUABLE, TermNil, "evaluating infinity");
|
||||
Yap_Error(TYPE_ERROR_EVALUABLE, TermNil, "evaluating infinity");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#else
|
||||
if (yap_flags[LANGUAGE_MODE_FLAG] == 1) {/* iso */
|
||||
_YAP_Error(TYPE_ERROR_EVALUABLE, TermNil, "evaluating not-a-number");
|
||||
Yap_Error(TYPE_ERROR_EVALUABLE, TermNil, "evaluating not-a-number");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
} else {
|
||||
@ -108,13 +108,13 @@ p_nan(E_ARGS)
|
||||
static E_FUNC
|
||||
p_random(E_ARGS)
|
||||
{
|
||||
RFLOAT(_YAP_random());
|
||||
RFLOAT(Yap_random());
|
||||
}
|
||||
|
||||
static E_FUNC
|
||||
p_cputime(E_ARGS)
|
||||
{
|
||||
RFLOAT((Float)_YAP_cputime()/1000.0);
|
||||
RFLOAT((Float)Yap_cputime()/1000.0);
|
||||
}
|
||||
|
||||
static E_FUNC
|
||||
@ -204,19 +204,19 @@ static InitConstEntry InitConstTab[] = {
|
||||
};
|
||||
|
||||
void
|
||||
_YAP_InitConstExps(void)
|
||||
Yap_InitConstExps(void)
|
||||
{
|
||||
unsigned int i;
|
||||
ExpEntry *p;
|
||||
|
||||
for (i = 0; i < sizeof(InitConstTab)/sizeof(InitConstEntry); ++i) {
|
||||
AtomEntry *ae = RepAtom(_YAP_LookupAtom(InitConstTab[i].OpName));
|
||||
AtomEntry *ae = RepAtom(Yap_LookupAtom(InitConstTab[i].OpName));
|
||||
WRITE_LOCK(ae->ARWLock);
|
||||
if (_YAP_GetExpPropHavingLock(ae, 0)) {
|
||||
if (Yap_GetExpPropHavingLock(ae, 0)) {
|
||||
WRITE_UNLOCK(ae->ARWLock);
|
||||
break;
|
||||
}
|
||||
p = (ExpEntry *) _YAP_AllocAtomSpace(sizeof(ExpEntry));
|
||||
p = (ExpEntry *) Yap_AllocAtomSpace(sizeof(ExpEntry));
|
||||
p->KindOfPE = ExpProperty;
|
||||
p->ArityOfEE = 0;
|
||||
p->ENoOfEE = 0;
|
||||
@ -229,16 +229,16 @@ _YAP_InitConstExps(void)
|
||||
|
||||
/* This routine is called from Restore to make sure we have the same arithmetic operators */
|
||||
int
|
||||
_YAP_ReInitConstExps(void)
|
||||
Yap_ReInitConstExps(void)
|
||||
{
|
||||
unsigned int i;
|
||||
Prop p;
|
||||
|
||||
for (i = 0; i < sizeof(InitConstTab)/sizeof(InitConstEntry); ++i) {
|
||||
AtomEntry *ae = RepAtom(_YAP_FullLookupAtom(InitConstTab[i].OpName));
|
||||
AtomEntry *ae = RepAtom(Yap_FullLookupAtom(InitConstTab[i].OpName));
|
||||
|
||||
WRITE_LOCK(ae->ARWLock);
|
||||
if ((p = _YAP_GetExpPropHavingLock(ae, 0)) == NULL) {
|
||||
if ((p = Yap_GetExpPropHavingLock(ae, 0)) == NULL) {
|
||||
WRITE_UNLOCK(ae->ARWLock);
|
||||
return(FALSE);
|
||||
}
|
||||
|
406
C/arith1.c
406
C/arith1.c
File diff suppressed because it is too large
Load Diff
312
C/arith2.c
312
C/arith2.c
@ -37,7 +37,7 @@ static char SccsId[] = "%W% %G%";
|
||||
#define RBIG(v) (o)->big = v; return(big_int_e)
|
||||
#define RERROR() return(db_ref_e)
|
||||
|
||||
#define ArithIEval(t,v) _YAP_Eval(t,v)
|
||||
#define ArithIEval(t,v) Yap_Eval(t,v)
|
||||
|
||||
inline static Functor
|
||||
AritFunctorOfTerm(Term t) {
|
||||
@ -64,7 +64,7 @@ EvalToTerm(blob_type f, union arith_ret *res)
|
||||
return(MkFloatTerm(res->dbl));
|
||||
#ifdef USE_GMP
|
||||
case big_int_e:
|
||||
return(_YAP_MkBigIntTerm(res->big));
|
||||
return(Yap_MkBigIntTerm(res->big));
|
||||
#endif
|
||||
default:
|
||||
return(TermNil);
|
||||
@ -104,7 +104,7 @@ p_mod(Term t1, Term t2 E_ARGS)
|
||||
RINT(IntegerOfTerm(t1) % i2);
|
||||
}
|
||||
case (CELL)double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t2, "mod/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t2, "mod/2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
@ -117,11 +117,11 @@ p_mod(Term t1, Term t2 E_ARGS)
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.Int = IntegerOfTerm(t1);
|
||||
bt1 = long_int_e;
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
}
|
||||
break;
|
||||
case (CELL)double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t1, "mod/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t1, "mod/2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
@ -133,50 +133,50 @@ p_mod(Term t1, Term t2 E_ARGS)
|
||||
/* modulo between bignum and integer */
|
||||
{
|
||||
Int i2 = IntegerOfTerm(t2);
|
||||
MP_INT *l1 = _YAP_BigIntOfTerm(t1);
|
||||
MP_INT *l1 = Yap_BigIntOfTerm(t1);
|
||||
|
||||
if (i2 > 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
Int r = mpz_mod_ui(new, l1, i2);
|
||||
|
||||
_YAP_CleanBigNum();
|
||||
Yap_CleanBigNum();
|
||||
RINT((mpz_sgn(l1) ? r : -r));
|
||||
} else if (i2 == 0) {
|
||||
goto zero_divisor;
|
||||
} else {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
Int r = mpz_mod_ui(new, l1, -i2);
|
||||
|
||||
_YAP_CleanBigNum();
|
||||
Yap_CleanBigNum();
|
||||
RINT((mpz_sgn(l1) ? r : -r));
|
||||
}
|
||||
}
|
||||
case (CELL)big_int_e:
|
||||
/* two bignums */
|
||||
{
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_mod(new, _YAP_BigIntOfTerm(t1), _YAP_BigIntOfTerm(t2));
|
||||
mpz_mod(new, Yap_BigIntOfTerm(t1), Yap_BigIntOfTerm(t2));
|
||||
RBIG(new);
|
||||
}
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t2, "mod/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t2, "mod/2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.big = _YAP_BigIntOfTerm(t1);
|
||||
v1.big = Yap_BigIntOfTerm(t1);
|
||||
bt1 = big_int_e;
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
bt1 = _YAP_Eval(t1, &v1);
|
||||
bt1 = Yap_Eval(t1, &v1);
|
||||
/* don't know anything about second */
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
}
|
||||
/* second case, no need no evaluation */
|
||||
switch (bt1) {
|
||||
@ -187,7 +187,7 @@ p_mod(Term t1, Term t2 E_ARGS)
|
||||
if (v2.Int == 0) goto zero_divisor;
|
||||
RINT(v1.Int % v2.Int);
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "mod/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "mod/2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
@ -197,11 +197,11 @@ p_mod(Term t1, Term t2 E_ARGS)
|
||||
RINT(v1.Int);
|
||||
#endif
|
||||
default:
|
||||
/* _YAP_Error */
|
||||
/* Yap_Error */
|
||||
RERROR();
|
||||
}
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), "mod/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), "mod/2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
@ -210,30 +210,30 @@ p_mod(Term t1, Term t2 E_ARGS)
|
||||
case long_int_e:
|
||||
/* big mod integer */
|
||||
if (v2.Int > 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
Int r = mpz_mod_ui(new, v1.big, v2.Int);
|
||||
|
||||
_YAP_CleanBigNum();
|
||||
Yap_CleanBigNum();
|
||||
RINT((mpz_sgn(v1.big) ? r : -r));
|
||||
} else if (v2.Int == 0) {
|
||||
goto zero_divisor;
|
||||
} else {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
Int r = mpz_mod_ui(new, v1.big, -v2.Int);
|
||||
|
||||
_YAP_CleanBigNum();
|
||||
Yap_CleanBigNum();
|
||||
RINT((mpz_sgn(v1.big) ? r : -r));
|
||||
}
|
||||
case double_e:
|
||||
/* big // float */
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "mod/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "mod/2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
case (CELL)big_int_e:
|
||||
/* big * big */
|
||||
{
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_mod(new, v1.big, v2.big);
|
||||
RBIG(new);
|
||||
@ -248,7 +248,7 @@ p_mod(Term t1, Term t2 E_ARGS)
|
||||
RERROR();
|
||||
}
|
||||
zero_divisor:
|
||||
_YAP_Error(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is mod 0");
|
||||
Yap_Error(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is mod 0");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
@ -264,14 +264,14 @@ fdiv_bigint(MP_INT *b1,MP_INT *b2)
|
||||
mpf_t f1,f2;
|
||||
Float res;
|
||||
|
||||
_YAP_PreAllocBigNum();
|
||||
Yap_PreAllocBigNum();
|
||||
mpf_init(f1);
|
||||
mpf_init(f2);
|
||||
mpf_set_z(f1, b1);
|
||||
mpf_set_z(f2, b2);
|
||||
mpf_div(f1, f1, f2);
|
||||
res = mpf_get_d(f1);
|
||||
_YAP_CleanBigNum();
|
||||
Yap_CleanBigNum();
|
||||
return(res);
|
||||
} else {
|
||||
return(f1/f2);
|
||||
@ -312,7 +312,7 @@ p_fdiv(Term t1, Term t2 E_ARGS)
|
||||
case (CELL)big_int_e:
|
||||
{
|
||||
Int i1 = IntegerOfTerm(t1);
|
||||
Float f2 = mpz_get_d(_YAP_BigIntOfTerm(t2));
|
||||
Float f2 = mpz_get_d(Yap_BigIntOfTerm(t2));
|
||||
RFLOAT(i1/f2);
|
||||
}
|
||||
#endif
|
||||
@ -320,7 +320,7 @@ p_fdiv(Term t1, Term t2 E_ARGS)
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.Int = IntegerOfTerm(t1);
|
||||
bt1 = long_int_e;
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
}
|
||||
break;
|
||||
case double_e:
|
||||
@ -341,14 +341,14 @@ p_fdiv(Term t1, Term t2 E_ARGS)
|
||||
#ifdef USE_GMP
|
||||
case big_int_e:
|
||||
{
|
||||
RFLOAT(FloatOfTerm(t1)/mpz_get_d(_YAP_BigIntOfTerm(t2)));
|
||||
RFLOAT(FloatOfTerm(t1)/mpz_get_d(Yap_BigIntOfTerm(t2)));
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.dbl = FloatOfTerm(t1);
|
||||
bt1 = double_e;
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
}
|
||||
break;
|
||||
#ifdef USE_GMP
|
||||
@ -359,30 +359,30 @@ p_fdiv(Term t1, Term t2 E_ARGS)
|
||||
case long_int_e:
|
||||
{
|
||||
Int i = IntegerOfTerm(t2);
|
||||
RFLOAT(mpz_get_d(_YAP_BigIntOfTerm(t1))/(Float)i);
|
||||
RFLOAT(mpz_get_d(Yap_BigIntOfTerm(t1))/(Float)i);
|
||||
}
|
||||
case big_int_e:
|
||||
/* two bignums*/
|
||||
RFLOAT(fdiv_bigint(_YAP_BigIntOfTerm(t1),_YAP_BigIntOfTerm(t2)));
|
||||
// RFLOAT(mpz_get_d(_YAP_BigIntOfTerm(t1))/mpz_get_d(_YAP_BigIntOfTerm(t2)));
|
||||
RFLOAT(fdiv_bigint(Yap_BigIntOfTerm(t1),Yap_BigIntOfTerm(t2)));
|
||||
// RFLOAT(mpz_get_d(Yap_BigIntOfTerm(t1))/mpz_get_d(Yap_BigIntOfTerm(t2)));
|
||||
case double_e:
|
||||
{
|
||||
Float dbl = FloatOfTerm(t2);
|
||||
RFLOAT(mpz_get_d(_YAP_BigIntOfTerm(t1))/dbl);
|
||||
RFLOAT(mpz_get_d(Yap_BigIntOfTerm(t1))/dbl);
|
||||
}
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.big = _YAP_BigIntOfTerm(t1);
|
||||
v1.big = Yap_BigIntOfTerm(t1);
|
||||
bt1 = big_int_e;
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
bt1 = _YAP_Eval(t1, &v1);
|
||||
bt1 = Yap_Eval(t1, &v1);
|
||||
/* don't know anything about second */
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
}
|
||||
/* second case, no need no evaluation */
|
||||
switch (bt1) {
|
||||
@ -400,7 +400,7 @@ p_fdiv(Term t1, Term t2 E_ARGS)
|
||||
RFLOAT(v1.Int/mpz_get_d(v2.big));
|
||||
#endif
|
||||
default:
|
||||
/* _YAP_Error */
|
||||
/* Yap_Error */
|
||||
RERROR();
|
||||
}
|
||||
case double_e:
|
||||
@ -447,7 +447,7 @@ p_fdiv(Term t1, Term t2 E_ARGS)
|
||||
static void
|
||||
mpz_xor(MP_INT *new, MP_INT *r1, MP_INT *r2)
|
||||
{
|
||||
MP_INT *n2 = _YAP_PreAllocBigNum(), *n3 = _YAP_PreAllocBigNum();
|
||||
MP_INT *n2 = Yap_PreAllocBigNum(), *n3 = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_ior(new, r1, r2);
|
||||
mpz_com(n2, r1);
|
||||
@ -455,7 +455,7 @@ mpz_xor(MP_INT *new, MP_INT *r1, MP_INT *r2)
|
||||
mpz_com(n3, r2);
|
||||
mpz_and(n3, n3, new);
|
||||
mpz_ior(new, n2, n3);
|
||||
_YAP_CleanBigNum();
|
||||
Yap_CleanBigNum();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@ -479,16 +479,16 @@ p_xor(Term t1, Term t2 E_ARGS)
|
||||
/* two integers */
|
||||
RINT(IntegerOfTerm(t1) ^ IntegerOfTerm(t2));
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t2, "#/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t2, "#/2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
case big_int_e:
|
||||
{
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_set_si(new,IntOfTerm(t1));
|
||||
mpz_xor(new, new, _YAP_BigIntOfTerm(t2));
|
||||
mpz_xor(new, new, Yap_BigIntOfTerm(t2));
|
||||
RBIG(new);
|
||||
}
|
||||
#endif
|
||||
@ -496,11 +496,11 @@ p_xor(Term t1, Term t2 E_ARGS)
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.Int = IntegerOfTerm(t1);
|
||||
bt1 = long_int_e;
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
}
|
||||
break;
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t1, "#/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t1, "#/2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
@ -510,38 +510,38 @@ p_xor(Term t1, Term t2 E_ARGS)
|
||||
switch (BlobOfFunctor(f2)) {
|
||||
case long_int_e:
|
||||
{
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_set_si(new,IntOfTerm(t2));
|
||||
mpz_xor(new, _YAP_BigIntOfTerm(t1), new);
|
||||
mpz_xor(new, Yap_BigIntOfTerm(t1), new);
|
||||
RBIG(new);
|
||||
}
|
||||
case big_int_e:
|
||||
/* two bignums */
|
||||
{
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_xor(new, _YAP_BigIntOfTerm(t1), _YAP_BigIntOfTerm(t2));
|
||||
mpz_xor(new, Yap_BigIntOfTerm(t1), Yap_BigIntOfTerm(t2));
|
||||
RBIG(new);
|
||||
}
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t2, "#/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t2, "#/2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.big = _YAP_BigIntOfTerm(t1);
|
||||
v1.big = Yap_BigIntOfTerm(t1);
|
||||
bt1 = big_int_e;
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
bt1 = _YAP_Eval(t1, &v1);
|
||||
bt1 = Yap_Eval(t1, &v1);
|
||||
/* don't know anything about second */
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
}
|
||||
/* second case, no need no evaluation */
|
||||
switch (bt1) {
|
||||
@ -550,14 +550,14 @@ p_xor(Term t1, Term t2 E_ARGS)
|
||||
case long_int_e:
|
||||
RINT(v1.Int ^ v2.Int);
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "#/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "#/2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
case big_int_e:
|
||||
{
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_set_si(new,v1.Int);
|
||||
mpz_xor(new, new, v2.big);
|
||||
@ -565,11 +565,11 @@ p_xor(Term t1, Term t2 E_ARGS)
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
/* _YAP_Error */
|
||||
/* Yap_Error */
|
||||
RERROR();
|
||||
}
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), "#/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), "#/2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
@ -578,7 +578,7 @@ p_xor(Term t1, Term t2 E_ARGS)
|
||||
case long_int_e:
|
||||
/* anding a bignum with an integer is easy */
|
||||
{
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_set_si(new,v2.Int);
|
||||
mpz_xor(new, v1.big, new);
|
||||
@ -586,14 +586,14 @@ p_xor(Term t1, Term t2 E_ARGS)
|
||||
}
|
||||
case double_e:
|
||||
/* big // float */
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "\\/ /2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "\\/ /2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
case big_int_e:
|
||||
/* big * big */
|
||||
{
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_xor(new, v1.big, v2.big);
|
||||
RBIG(new);
|
||||
@ -642,7 +642,7 @@ p_atan2(Term t1, Term t2 E_ARGS)
|
||||
case big_int_e:
|
||||
{
|
||||
Int i1 = IntegerOfTerm(t1);
|
||||
Float f2 = mpz_get_d(_YAP_BigIntOfTerm(t2));
|
||||
Float f2 = mpz_get_d(Yap_BigIntOfTerm(t2));
|
||||
RFLOAT(atan2(i1,f2));
|
||||
}
|
||||
#endif
|
||||
@ -650,7 +650,7 @@ p_atan2(Term t1, Term t2 E_ARGS)
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.Int = IntegerOfTerm(t1);
|
||||
bt1 = long_int_e;
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
}
|
||||
break;
|
||||
case double_e:
|
||||
@ -671,14 +671,14 @@ p_atan2(Term t1, Term t2 E_ARGS)
|
||||
#ifdef USE_GMP
|
||||
case big_int_e:
|
||||
{
|
||||
RFLOAT(atan2(FloatOfTerm(t1),mpz_get_d(_YAP_BigIntOfTerm(t2))));
|
||||
RFLOAT(atan2(FloatOfTerm(t1),mpz_get_d(Yap_BigIntOfTerm(t2))));
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.dbl = FloatOfTerm(t1);
|
||||
bt1 = double_e;
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
}
|
||||
break;
|
||||
#ifdef USE_GMP
|
||||
@ -689,29 +689,29 @@ p_atan2(Term t1, Term t2 E_ARGS)
|
||||
case long_int_e:
|
||||
{
|
||||
Int i = IntegerOfTerm(t2);
|
||||
RFLOAT(atan2(mpz_get_d(_YAP_BigIntOfTerm(t1)),i));
|
||||
RFLOAT(atan2(mpz_get_d(Yap_BigIntOfTerm(t1)),i));
|
||||
}
|
||||
case big_int_e:
|
||||
/* two bignums */
|
||||
RFLOAT(atan2(mpz_get_d(_YAP_BigIntOfTerm(t1)),mpz_get_d(_YAP_BigIntOfTerm(t2))));
|
||||
RFLOAT(atan2(mpz_get_d(Yap_BigIntOfTerm(t1)),mpz_get_d(Yap_BigIntOfTerm(t2))));
|
||||
case double_e:
|
||||
{
|
||||
Float dbl = FloatOfTerm(t2);
|
||||
RFLOAT(atan2(mpz_get_d(_YAP_BigIntOfTerm(t1)),dbl));
|
||||
RFLOAT(atan2(mpz_get_d(Yap_BigIntOfTerm(t1)),dbl));
|
||||
}
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.big = _YAP_BigIntOfTerm(t1);
|
||||
v1.big = Yap_BigIntOfTerm(t1);
|
||||
bt1 = big_int_e;
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
bt1 = _YAP_Eval(t1, &v1);
|
||||
bt1 = Yap_Eval(t1, &v1);
|
||||
/* don't know anything about second */
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
}
|
||||
/* second case, no need no evaluation */
|
||||
switch (bt1) {
|
||||
@ -729,7 +729,7 @@ p_atan2(Term t1, Term t2 E_ARGS)
|
||||
RFLOAT(atan2(v1.Int,mpz_get_d(v2.big)));
|
||||
#endif
|
||||
default:
|
||||
/* _YAP_Error */
|
||||
/* Yap_Error */
|
||||
RERROR();
|
||||
}
|
||||
case double_e:
|
||||
@ -804,7 +804,7 @@ p_power(Term t1, Term t2 E_ARGS)
|
||||
case big_int_e:
|
||||
{
|
||||
Int i1 = IntegerOfTerm(t1);
|
||||
Float f2 = mpz_get_d(_YAP_BigIntOfTerm(t2));
|
||||
Float f2 = mpz_get_d(Yap_BigIntOfTerm(t2));
|
||||
RFLOAT(pow(i1,f2));
|
||||
}
|
||||
#endif
|
||||
@ -812,7 +812,7 @@ p_power(Term t1, Term t2 E_ARGS)
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.Int = IntegerOfTerm(t1);
|
||||
bt1 = long_int_e;
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
}
|
||||
break;
|
||||
case double_e:
|
||||
@ -833,14 +833,14 @@ p_power(Term t1, Term t2 E_ARGS)
|
||||
#ifdef USE_GMP
|
||||
case big_int_e:
|
||||
{
|
||||
RFLOAT(pow(FloatOfTerm(t1),mpz_get_d(_YAP_BigIntOfTerm(t2))));
|
||||
RFLOAT(pow(FloatOfTerm(t1),mpz_get_d(Yap_BigIntOfTerm(t2))));
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.dbl = FloatOfTerm(t1);
|
||||
bt1 = double_e;
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
}
|
||||
break;
|
||||
#ifdef USE_GMP
|
||||
@ -851,29 +851,29 @@ p_power(Term t1, Term t2 E_ARGS)
|
||||
case long_int_e:
|
||||
{
|
||||
Int i = IntegerOfTerm(t2);
|
||||
RFLOAT(pow(mpz_get_d(_YAP_BigIntOfTerm(t1)),i));
|
||||
RFLOAT(pow(mpz_get_d(Yap_BigIntOfTerm(t1)),i));
|
||||
}
|
||||
case big_int_e:
|
||||
/* two bignums */
|
||||
RFLOAT(pow(mpz_get_d(_YAP_BigIntOfTerm(t1)),mpz_get_d(_YAP_BigIntOfTerm(t2))));
|
||||
RFLOAT(pow(mpz_get_d(Yap_BigIntOfTerm(t1)),mpz_get_d(Yap_BigIntOfTerm(t2))));
|
||||
case double_e:
|
||||
{
|
||||
Float dbl = FloatOfTerm(t2);
|
||||
RFLOAT(pow(mpz_get_d(_YAP_BigIntOfTerm(t1)),dbl));
|
||||
RFLOAT(pow(mpz_get_d(Yap_BigIntOfTerm(t1)),dbl));
|
||||
}
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.big = _YAP_BigIntOfTerm(t1);
|
||||
v1.big = Yap_BigIntOfTerm(t1);
|
||||
bt1 = big_int_e;
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
bt1 = _YAP_Eval(t1, &v1);
|
||||
bt1 = Yap_Eval(t1, &v1);
|
||||
/* don't know anything about second */
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
}
|
||||
/* second case, no need no evaluation */
|
||||
switch (bt1) {
|
||||
@ -891,7 +891,7 @@ p_power(Term t1, Term t2 E_ARGS)
|
||||
RFLOAT(pow(v1.Int,mpz_get_d(v2.big)));
|
||||
#endif
|
||||
default:
|
||||
/* _YAP_Error */
|
||||
/* Yap_Error */
|
||||
RERROR();
|
||||
}
|
||||
case double_e:
|
||||
@ -947,7 +947,7 @@ gcd(Int m11,Int m21)
|
||||
}
|
||||
if (m11<0 || m21<0) { /* overflow? */
|
||||
/* Oflow = 1; */
|
||||
_YAP_Error(EVALUATION_ERROR_INT_OVERFLOW, MkIntegerTerm(m11),
|
||||
Yap_Error(EVALUATION_ERROR_INT_OVERFLOW, MkIntegerTerm(m11),
|
||||
"gcd/2 with %d and %d", m11, m21);
|
||||
P = (yamop *)FAILCODE;
|
||||
return(1);
|
||||
@ -969,7 +969,7 @@ Int gcdmult(Int m11,Int m21,Int *pm11) /* *pm11 gets multiplier of m11 */
|
||||
}
|
||||
if (m11<0 || m21<0) { /* overflow? */
|
||||
/* Oflow = 1; */
|
||||
_YAP_Error(EVALUATION_ERROR_INT_OVERFLOW, MkIntegerTerm(m11),
|
||||
Yap_Error(EVALUATION_ERROR_INT_OVERFLOW, MkIntegerTerm(m11),
|
||||
"gcdmult/2 with %d and %d", m11, m21);
|
||||
P = (yamop *)FAILCODE;
|
||||
return(1);
|
||||
@ -1007,7 +1007,7 @@ p_gcd(Term t1, Term t2 E_ARGS)
|
||||
RINT(gcd(i1,i2));
|
||||
}
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t2, "gcd/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t2, "gcd/2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
@ -1018,14 +1018,14 @@ p_gcd(Term t1, Term t2 E_ARGS)
|
||||
Int i = IntegerOfTerm(t1);
|
||||
|
||||
if (i > 0) {
|
||||
RINT(mpz_gcd_ui(NULL,_YAP_BigIntOfTerm(t2),i));
|
||||
RINT(mpz_gcd_ui(NULL,Yap_BigIntOfTerm(t2),i));
|
||||
} else if (i == 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_abs(new, _YAP_BigIntOfTerm(t2));
|
||||
mpz_abs(new, Yap_BigIntOfTerm(t2));
|
||||
RBIG(new);
|
||||
} else {
|
||||
RINT(mpz_gcd_ui(NULL,_YAP_BigIntOfTerm(t2),-i));
|
||||
RINT(mpz_gcd_ui(NULL,Yap_BigIntOfTerm(t2),-i));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1033,11 +1033,11 @@ p_gcd(Term t1, Term t2 E_ARGS)
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.Int = IntegerOfTerm(t1);
|
||||
bt1 = long_int_e;
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
}
|
||||
break;
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t1, "gcd/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t1, "gcd/2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
@ -1051,42 +1051,42 @@ p_gcd(Term t1, Term t2 E_ARGS)
|
||||
Int i = IntegerOfTerm(t2);
|
||||
|
||||
if (i > 0) {
|
||||
RINT(mpz_gcd_ui(NULL,_YAP_BigIntOfTerm(t1),i));
|
||||
RINT(mpz_gcd_ui(NULL,Yap_BigIntOfTerm(t1),i));
|
||||
} else if (i == 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_abs(new, _YAP_BigIntOfTerm(t1));
|
||||
mpz_abs(new, Yap_BigIntOfTerm(t1));
|
||||
RBIG(new);
|
||||
} else {
|
||||
RINT(mpz_gcd_ui(NULL,_YAP_BigIntOfTerm(t1),-i));
|
||||
RINT(mpz_gcd_ui(NULL,Yap_BigIntOfTerm(t1),-i));
|
||||
}
|
||||
}
|
||||
case big_int_e:
|
||||
/* two bignums */
|
||||
{
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_gcd(new, _YAP_BigIntOfTerm(t1), _YAP_BigIntOfTerm(t2));
|
||||
mpz_gcd(new, Yap_BigIntOfTerm(t1), Yap_BigIntOfTerm(t2));
|
||||
RBIG(new);
|
||||
}
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t2, "gcd/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t2, "gcd/2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.big = _YAP_BigIntOfTerm(t1);
|
||||
v1.big = Yap_BigIntOfTerm(t1);
|
||||
bt1 = big_int_e;
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
bt1 = _YAP_Eval(t1, &v1);
|
||||
bt1 = Yap_Eval(t1, &v1);
|
||||
/* don't know anything about second */
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
}
|
||||
/* second case, no need no evaluation */
|
||||
switch (bt1) {
|
||||
@ -1102,7 +1102,7 @@ p_gcd(Term t1, Term t2 E_ARGS)
|
||||
RINT(gcd(i1,i2));
|
||||
}
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "gcd/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "gcd/2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
@ -1112,7 +1112,7 @@ p_gcd(Term t1, Term t2 E_ARGS)
|
||||
if (v1.Int > 0) {
|
||||
RINT(mpz_gcd_ui(NULL,v2.big,v1.Int));
|
||||
} else if (v1.Int == 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_abs(new, v2.big);
|
||||
RBIG(new);
|
||||
@ -1122,11 +1122,11 @@ p_gcd(Term t1, Term t2 E_ARGS)
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
/* _YAP_Error */
|
||||
/* Yap_Error */
|
||||
RERROR();
|
||||
}
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), "gcd/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), "gcd/2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
@ -1138,7 +1138,7 @@ p_gcd(Term t1, Term t2 E_ARGS)
|
||||
if (v2.Int > 0) {
|
||||
RINT(mpz_gcd_ui(NULL,v1.big,v2.Int));
|
||||
} else if (v2.Int == 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_abs(new, v1.big);
|
||||
RBIG(new);
|
||||
@ -1148,13 +1148,13 @@ p_gcd(Term t1, Term t2 E_ARGS)
|
||||
}
|
||||
case double_e:
|
||||
/* big // float */
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "gcd/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "gcd/2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
case big_int_e:
|
||||
if (v2.Int > 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
mpz_gcd(new, v1.big, v2.big);
|
||||
RBIG(new);
|
||||
}
|
||||
@ -1204,7 +1204,7 @@ p_min(Term t1, Term t2 E_ARGS)
|
||||
case big_int_e:
|
||||
{
|
||||
Int i = IntegerOfTerm(t1);
|
||||
MP_INT *b = _YAP_BigIntOfTerm(t2);
|
||||
MP_INT *b = Yap_BigIntOfTerm(t2);
|
||||
|
||||
if (mpz_cmp_si(b,i) < 0) {
|
||||
RBIG(b);
|
||||
@ -1216,7 +1216,7 @@ p_min(Term t1, Term t2 E_ARGS)
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.Int = IntegerOfTerm(t1);
|
||||
bt1 = long_int_e;
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
}
|
||||
break;
|
||||
case double_e:
|
||||
@ -1246,7 +1246,7 @@ p_min(Term t1, Term t2 E_ARGS)
|
||||
case big_int_e:
|
||||
{
|
||||
Float fl1 = FloatOfTerm(t1);
|
||||
Float fl2 = mpz_get_d(_YAP_BigIntOfTerm(t2));
|
||||
Float fl2 = mpz_get_d(Yap_BigIntOfTerm(t2));
|
||||
if (fl1 <= fl2) {
|
||||
RFLOAT(fl1);
|
||||
}
|
||||
@ -1257,7 +1257,7 @@ p_min(Term t1, Term t2 E_ARGS)
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.dbl = FloatOfTerm(t1);
|
||||
bt1 = double_e;
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
}
|
||||
break;
|
||||
#ifdef USE_GMP
|
||||
@ -1268,7 +1268,7 @@ p_min(Term t1, Term t2 E_ARGS)
|
||||
case long_int_e:
|
||||
{
|
||||
Int i = IntegerOfTerm(t2);
|
||||
MP_INT *b = _YAP_BigIntOfTerm(t1);
|
||||
MP_INT *b = Yap_BigIntOfTerm(t1);
|
||||
|
||||
if (mpz_cmp_si(b,i) < 0) {
|
||||
RBIG(b);
|
||||
@ -1278,8 +1278,8 @@ p_min(Term t1, Term t2 E_ARGS)
|
||||
case big_int_e:
|
||||
/* two bignums */
|
||||
{
|
||||
MP_INT *b1 = _YAP_BigIntOfTerm(t1);
|
||||
MP_INT *b2 = _YAP_BigIntOfTerm(t2);
|
||||
MP_INT *b1 = Yap_BigIntOfTerm(t1);
|
||||
MP_INT *b2 = Yap_BigIntOfTerm(t2);
|
||||
|
||||
if (mpz_cmp(b1,b2) < 0) {
|
||||
RBIG(b1);
|
||||
@ -1289,7 +1289,7 @@ p_min(Term t1, Term t2 E_ARGS)
|
||||
case double_e:
|
||||
{
|
||||
Float fl1 = FloatOfTerm(t2);
|
||||
Float fl2 = mpz_get_d(_YAP_BigIntOfTerm(t1));
|
||||
Float fl2 = mpz_get_d(Yap_BigIntOfTerm(t1));
|
||||
if (fl1 <= fl2) {
|
||||
RFLOAT(fl1);
|
||||
}
|
||||
@ -1297,17 +1297,17 @@ p_min(Term t1, Term t2 E_ARGS)
|
||||
}
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.big = _YAP_BigIntOfTerm(t1);
|
||||
v1.big = Yap_BigIntOfTerm(t1);
|
||||
bt1 = big_int_e;
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
bt1 = _YAP_Eval(t1, &v1);
|
||||
bt1 = Yap_Eval(t1, &v1);
|
||||
/* don't know anything about second */
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
}
|
||||
/* second case, no need no evaluation */
|
||||
switch (bt1) {
|
||||
@ -1335,7 +1335,7 @@ p_min(Term t1, Term t2 E_ARGS)
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
/* _YAP_Error */
|
||||
/* Yap_Error */
|
||||
RERROR();
|
||||
}
|
||||
case double_e:
|
||||
@ -1443,7 +1443,7 @@ p_max(Term t1, Term t2 E_ARGS)
|
||||
case big_int_e:
|
||||
{
|
||||
Int i = IntegerOfTerm(t1);
|
||||
MP_INT *b = _YAP_BigIntOfTerm(t2);
|
||||
MP_INT *b = Yap_BigIntOfTerm(t2);
|
||||
|
||||
if (mpz_cmp_si(b,i) > 0) {
|
||||
RBIG(b);
|
||||
@ -1455,7 +1455,7 @@ p_max(Term t1, Term t2 E_ARGS)
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.Int = IntegerOfTerm(t1);
|
||||
bt1 = long_int_e;
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
}
|
||||
break;
|
||||
case double_e:
|
||||
@ -1485,7 +1485,7 @@ p_max(Term t1, Term t2 E_ARGS)
|
||||
case big_int_e:
|
||||
{
|
||||
Float fl1 = FloatOfTerm(t1);
|
||||
Float fl2 = mpz_get_d(_YAP_BigIntOfTerm(t2));
|
||||
Float fl2 = mpz_get_d(Yap_BigIntOfTerm(t2));
|
||||
if (fl1 >= fl2) {
|
||||
RFLOAT(fl1);
|
||||
}
|
||||
@ -1496,7 +1496,7 @@ p_max(Term t1, Term t2 E_ARGS)
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.dbl = FloatOfTerm(t1);
|
||||
bt1 = double_e;
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
}
|
||||
break;
|
||||
#ifdef USE_GMP
|
||||
@ -1507,7 +1507,7 @@ p_max(Term t1, Term t2 E_ARGS)
|
||||
case long_int_e:
|
||||
{
|
||||
Int i = IntegerOfTerm(t2);
|
||||
MP_INT *b = _YAP_BigIntOfTerm(t1);
|
||||
MP_INT *b = Yap_BigIntOfTerm(t1);
|
||||
|
||||
if (mpz_cmp_si(b,i) > 0) {
|
||||
RBIG(b);
|
||||
@ -1517,8 +1517,8 @@ p_max(Term t1, Term t2 E_ARGS)
|
||||
case big_int_e:
|
||||
/* two bignums */
|
||||
{
|
||||
MP_INT *b1 = _YAP_BigIntOfTerm(t1);
|
||||
MP_INT *b2 = _YAP_BigIntOfTerm(t2);
|
||||
MP_INT *b1 = Yap_BigIntOfTerm(t1);
|
||||
MP_INT *b2 = Yap_BigIntOfTerm(t2);
|
||||
|
||||
if (mpz_cmp(b1,b2) > 0) {
|
||||
RBIG(b1);
|
||||
@ -1528,7 +1528,7 @@ p_max(Term t1, Term t2 E_ARGS)
|
||||
case double_e:
|
||||
{
|
||||
Float fl1 = FloatOfTerm(t2);
|
||||
Float fl2 = mpz_get_d(_YAP_BigIntOfTerm(t1));
|
||||
Float fl2 = mpz_get_d(Yap_BigIntOfTerm(t1));
|
||||
if (fl1 >= fl2) {
|
||||
RFLOAT(fl1);
|
||||
}
|
||||
@ -1536,17 +1536,17 @@ p_max(Term t1, Term t2 E_ARGS)
|
||||
}
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.big = _YAP_BigIntOfTerm(t1);
|
||||
v1.big = Yap_BigIntOfTerm(t1);
|
||||
bt1 = big_int_e;
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
bt1 = _YAP_Eval(t1, &v1);
|
||||
bt1 = Yap_Eval(t1, &v1);
|
||||
/* don't know anything about second */
|
||||
bt2 = _YAP_Eval(t2, &v2);
|
||||
bt2 = Yap_Eval(t2, &v2);
|
||||
}
|
||||
/* second case, no need no evaluation */
|
||||
switch (bt1) {
|
||||
@ -1574,7 +1574,7 @@ p_max(Term t1, Term t2 E_ARGS)
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
/* _YAP_Error */
|
||||
/* Yap_Error */
|
||||
RERROR();
|
||||
}
|
||||
case double_e:
|
||||
@ -1681,50 +1681,50 @@ p_binary_is(void)
|
||||
blob_type f;
|
||||
|
||||
if (IsVarTerm(t)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t, "X is Y");
|
||||
Yap_Error(INSTANTIATION_ERROR,t, "X is Y");
|
||||
return(FALSE);
|
||||
}
|
||||
if (IsIntTerm(t)) {
|
||||
blob_type f = InitBinTab[IntOfTerm(t)].f(Deref(ARG3),Deref(ARG4),&res);
|
||||
return (_YAP_unify_constant(ARG1,EvalToTerm(f,&res)));
|
||||
return (Yap_unify_constant(ARG1,EvalToTerm(f,&res)));
|
||||
}
|
||||
if (IsAtomTerm(t)) {
|
||||
Atom name = AtomOfTerm(t);
|
||||
ExpEntry *p;
|
||||
|
||||
if (EndOfPAEntr(p = RepExpProp(_YAP_GetExpProp(name, 2)))) {
|
||||
if (EndOfPAEntr(p = RepExpProp(Yap_GetExpProp(name, 2)))) {
|
||||
Term ti[2];
|
||||
|
||||
/* error */
|
||||
ti[0] = t;
|
||||
ti[1] = MkIntTerm(2);
|
||||
t = _YAP_MkApplTerm(_YAP_MkFunctor(_YAP_LookupAtom("/"),2), 2, ti);
|
||||
_YAP_Error(TYPE_ERROR_EVALUABLE, t,
|
||||
t = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("/"),2), 2, ti);
|
||||
Yap_Error(TYPE_ERROR_EVALUABLE, t,
|
||||
"functor %s/%d for arithmetic expression",
|
||||
RepAtom(name)->StrOfAE,2);
|
||||
P = (yamop *)FAILCODE;
|
||||
return(FALSE);
|
||||
}
|
||||
f = p->FOfEE.binary(Deref(ARG3),Deref(ARG4),&res);
|
||||
return (_YAP_unify_constant(ARG1,EvalToTerm(f,&res)));
|
||||
return (Yap_unify_constant(ARG1,EvalToTerm(f,&res)));
|
||||
}
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_InitBinaryExps(void)
|
||||
Yap_InitBinaryExps(void)
|
||||
{
|
||||
unsigned int i;
|
||||
ExpEntry *p;
|
||||
|
||||
for (i = 0; i < sizeof(InitBinTab)/sizeof(InitBinEntry); ++i) {
|
||||
AtomEntry *ae = RepAtom(_YAP_LookupAtom(InitBinTab[i].OpName));
|
||||
AtomEntry *ae = RepAtom(Yap_LookupAtom(InitBinTab[i].OpName));
|
||||
WRITE_LOCK(ae->ARWLock);
|
||||
if (_YAP_GetExpPropHavingLock(ae, 2)) {
|
||||
if (Yap_GetExpPropHavingLock(ae, 2)) {
|
||||
WRITE_UNLOCK(ae->ARWLock);
|
||||
break;
|
||||
}
|
||||
p = (ExpEntry *) _YAP_AllocAtomSpace(sizeof(ExpEntry));
|
||||
p = (ExpEntry *) Yap_AllocAtomSpace(sizeof(ExpEntry));
|
||||
p->KindOfPE = ExpProperty;
|
||||
p->ArityOfEE = 2;
|
||||
p->ENoOfEE = 2;
|
||||
@ -1733,21 +1733,21 @@ _YAP_InitBinaryExps(void)
|
||||
ae->PropsOfAE = AbsExpProp(p);
|
||||
WRITE_UNLOCK(ae->ARWLock);
|
||||
}
|
||||
_YAP_InitCPred("is", 4, p_binary_is, TestPredFlag | SafePredFlag);
|
||||
Yap_InitCPred("is", 4, p_binary_is, TestPredFlag | SafePredFlag);
|
||||
}
|
||||
|
||||
/* This routine is called from Restore to make sure we have the same arithmetic operators */
|
||||
int
|
||||
_YAP_ReInitBinaryExps(void)
|
||||
Yap_ReInitBinaryExps(void)
|
||||
{
|
||||
unsigned int i;
|
||||
Prop p;
|
||||
|
||||
for (i = 0; i < sizeof(InitBinTab)/sizeof(InitBinEntry); ++i) {
|
||||
AtomEntry *ae = RepAtom(_YAP_FullLookupAtom(InitBinTab[i].OpName));
|
||||
AtomEntry *ae = RepAtom(Yap_FullLookupAtom(InitBinTab[i].OpName));
|
||||
|
||||
WRITE_LOCK(ae->ARWLock);
|
||||
if ((p = _YAP_GetExpPropHavingLock(ae, 2)) == NULL) {
|
||||
if ((p = Yap_GetExpPropHavingLock(ae, 2)) == NULL) {
|
||||
WRITE_UNLOCK(ae->ARWLock);
|
||||
return(FALSE);
|
||||
}
|
||||
|
260
C/arrays.c
260
C/arrays.c
@ -173,7 +173,7 @@ AccessNamedArray(Atom a, Int indx)
|
||||
|
||||
READ_LOCK(ptr->ArRWLock);
|
||||
if (-(pp->ArrayEArity) <= indx || indx < 0) {
|
||||
/* _YAP_Error(DOMAIN_ERROR_ARRAY_OVERFLOW, MkIntegerTerm(indx), "access_array");*/
|
||||
/* Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW, MkIntegerTerm(indx), "access_array");*/
|
||||
READ_UNLOCK(ptr->ArRWLock);
|
||||
P = (yamop *)FAILCODE;
|
||||
return(MkAtomTerm(AtomFoundVar));
|
||||
@ -259,7 +259,7 @@ AccessNamedArray(Atom a, Int indx)
|
||||
|
||||
READ_UNLOCK(ptr->ArRWLock);
|
||||
if (ref != NULL) {
|
||||
TRef = _YAP_FetchTermFromDB(ref,3);
|
||||
TRef = Yap_FetchTermFromDB(ref,3);
|
||||
} else {
|
||||
P = (yamop *)FAILCODE;
|
||||
TRef = TermNil;
|
||||
@ -273,7 +273,7 @@ AccessNamedArray(Atom a, Int indx)
|
||||
}
|
||||
}
|
||||
else {
|
||||
_YAP_Error(EXISTENCE_ERROR_ARRAY,MkAtomTerm(a),"named array");
|
||||
Yap_Error(EXISTENCE_ERROR_ARRAY,MkAtomTerm(a),"named array");
|
||||
return (TermNil);
|
||||
}
|
||||
|
||||
@ -291,22 +291,22 @@ p_access_array(void)
|
||||
union arith_ret v;
|
||||
if (IsIntTerm(ti))
|
||||
indx = IntOfTerm(ti);
|
||||
else if (_YAP_Eval(ti, &v) == long_int_e)
|
||||
else if (Yap_Eval(ti, &v) == long_int_e)
|
||||
indx = v.Int;
|
||||
else {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER,ti,"access_array");
|
||||
Yap_Error(TYPE_ERROR_INTEGER,ti,"access_array");
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
_YAP_Error(INSTANTIATION_ERROR,ti,"access_array");
|
||||
Yap_Error(INSTANTIATION_ERROR,ti,"access_array");
|
||||
return (TermNil);
|
||||
}
|
||||
|
||||
if (IsNonVarTerm(t)) {
|
||||
if (IsApplTerm(t)) {
|
||||
if (indx >= ArityOfFunctor(FunctorOfTerm(t)) || indx < 0) {
|
||||
/* _YAP_Error(DOMAIN_ERROR_ARRAY_OVERFLOW, MkIntegerTerm(indx), "access_array");*/
|
||||
/* Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW, MkIntegerTerm(indx), "access_array");*/
|
||||
P = (yamop *)FAILCODE;
|
||||
return(FALSE);
|
||||
}
|
||||
@ -317,14 +317,14 @@ p_access_array(void)
|
||||
return(FALSE);
|
||||
}
|
||||
} else {
|
||||
_YAP_Error(TYPE_ERROR_ARRAY,t,"access_array");
|
||||
Yap_Error(TYPE_ERROR_ARRAY,t,"access_array");
|
||||
return(FALSE);
|
||||
}
|
||||
} else {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t,"access_array");
|
||||
Yap_Error(INSTANTIATION_ERROR,t,"access_array");
|
||||
return(FALSE);
|
||||
}
|
||||
return (_YAP_unify(tf, ARG3));
|
||||
return (Yap_unify(tf, ARG3));
|
||||
}
|
||||
|
||||
static Int
|
||||
@ -337,35 +337,35 @@ p_array_arg(void)
|
||||
union arith_ret v;
|
||||
if (IsIntTerm(ti))
|
||||
indx = IntOfTerm(ti);
|
||||
else if (_YAP_Eval(ti, &v) == long_int_e)
|
||||
else if (Yap_Eval(ti, &v) == long_int_e)
|
||||
indx = v.Int;
|
||||
else {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER,ti,"array_arg");
|
||||
Yap_Error(TYPE_ERROR_INTEGER,ti,"array_arg");
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
_YAP_Error(INSTANTIATION_ERROR,ti,"array_arg");
|
||||
Yap_Error(INSTANTIATION_ERROR,ti,"array_arg");
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
t = Deref(ARG2);
|
||||
if (IsNonVarTerm(t)) {
|
||||
if (IsApplTerm(t)) {
|
||||
return (_YAP_unify(((RepAppl(t))[indx + 1]), ARG1));
|
||||
return (Yap_unify(((RepAppl(t))[indx + 1]), ARG1));
|
||||
}
|
||||
else if (IsAtomTerm(t)) {
|
||||
Term tf = AccessNamedArray(AtomOfTerm(t), indx);
|
||||
if (tf == MkAtomTerm(AtomFoundVar)) {
|
||||
return(FALSE);
|
||||
}
|
||||
return (_YAP_unify(tf, ARG1));
|
||||
return (Yap_unify(tf, ARG1));
|
||||
}
|
||||
else
|
||||
_YAP_Error(TYPE_ERROR_ARRAY,t,"array_arg");
|
||||
Yap_Error(TYPE_ERROR_ARRAY,t,"array_arg");
|
||||
}
|
||||
else
|
||||
_YAP_Error(INSTANTIATION_ERROR,t,"array_arg");
|
||||
Yap_Error(INSTANTIATION_ERROR,t,"array_arg");
|
||||
|
||||
return (FALSE);
|
||||
|
||||
@ -382,7 +382,7 @@ InitNamedArray(ArrayEntry * p, Int dim)
|
||||
/* place terms in reverse order */
|
||||
Bind_Global(&(p->ValueOfVE),AbsAppl(H));
|
||||
tp = H;
|
||||
tp[0] = (CELL)_YAP_MkFunctor(AtomArray, dim);
|
||||
tp[0] = (CELL)Yap_MkFunctor(AtomArray, dim);
|
||||
tp++;
|
||||
p->ArrayEArity = dim;
|
||||
/* Initialise the array as a set of variables */
|
||||
@ -399,7 +399,7 @@ CreateNamedArray(PropEntry * pp, Int dim, AtomEntry *ae)
|
||||
{
|
||||
ArrayEntry *p;
|
||||
|
||||
p = (ArrayEntry *) _YAP_AllocAtomSpace(sizeof(*p));
|
||||
p = (ArrayEntry *) Yap_AllocAtomSpace(sizeof(*p));
|
||||
p->KindOfPE = ArrayProperty;
|
||||
p->NextOfPE = ae->PropsOfAE;
|
||||
INIT_RWLOCK(p->ArRWLock);
|
||||
@ -439,10 +439,10 @@ AllocateStaticArraySpace(StaticArrayEntry *p, static_array_types atype, Int arra
|
||||
asize = array_size*sizeof(DBRef);
|
||||
break;
|
||||
}
|
||||
while ((p->ValueOfVE.floats = (Float *) _YAP_AllocAtomSpace(asize) ) == NULL) {
|
||||
while ((p->ValueOfVE.floats = (Float *) Yap_AllocAtomSpace(asize) ) == NULL) {
|
||||
YAPLeaveCriticalSection();
|
||||
if (!_YAP_growheap(FALSE)) {
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, _YAP_ErrorMessage);
|
||||
if (!Yap_growheap(FALSE)) {
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return;
|
||||
}
|
||||
YAPEnterCriticalSection();
|
||||
@ -454,7 +454,7 @@ static void
|
||||
CreateStaticArray(AtomEntry *ae, Int dim, static_array_types type, CODEADDR start_addr, StaticArrayEntry *p)
|
||||
{
|
||||
if (EndOfPAEntr(p)) {
|
||||
p = (StaticArrayEntry *) _YAP_AllocAtomSpace(sizeof(*p));
|
||||
p = (StaticArrayEntry *) Yap_AllocAtomSpace(sizeof(*p));
|
||||
p->KindOfPE = ArrayProperty;
|
||||
p->NextOfPE = ae->PropsOfAE;
|
||||
INIT_RWLOCK(p->ArRWLock);
|
||||
@ -520,7 +520,7 @@ ResizeStaticArray(StaticArrayEntry *pp, Int dim)
|
||||
return;
|
||||
pp->ArrayEArity = -dim;
|
||||
#if HAVE_MMAP
|
||||
if (pp->ValueOfVE.chars < (char *)_YAP_HeapBase ||
|
||||
if (pp->ValueOfVE.chars < (char *)Yap_HeapBase ||
|
||||
pp->ValueOfVE.chars > (char *)HeapTop) {
|
||||
ResizeMmappedArray(pp, dim, (void *)(pp->ValueOfVE.chars));
|
||||
return;
|
||||
@ -595,10 +595,10 @@ p_create_array(void)
|
||||
union arith_ret v;
|
||||
if (IsIntTerm(ti))
|
||||
size = IntOfTerm(ti);
|
||||
else if (_YAP_Eval(ti, &v) == long_int_e)
|
||||
else if (Yap_Eval(ti, &v) == long_int_e)
|
||||
size = v.Int;
|
||||
else {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER,ti,"create_array");
|
||||
Yap_Error(TYPE_ERROR_INTEGER,ti,"create_array");
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
@ -607,15 +607,15 @@ p_create_array(void)
|
||||
/* Create an anonymous array */
|
||||
Functor farray;
|
||||
|
||||
farray = _YAP_MkFunctor(AtomArray, size);
|
||||
farray = Yap_MkFunctor(AtomArray, size);
|
||||
if (H+1+size > ASP-1024) {
|
||||
if (!_YAP_gc(2, ENV, P)) {
|
||||
_YAP_Error(OUT_OF_STACK_ERROR,TermNil,_YAP_ErrorMessage);
|
||||
if (!Yap_gc(2, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
} else {
|
||||
if (H+1+size > ASP-1024) {
|
||||
if (!_YAP_growstack( sizeof(CELL) * (size+1-(H-ASP-1024)))) {
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, _YAP_ErrorMessage);
|
||||
if (!Yap_growstack( sizeof(CELL) * (size+1-(H-ASP-1024)))) {
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@ -628,7 +628,7 @@ p_create_array(void)
|
||||
RESET_VARIABLE(H);
|
||||
H++;
|
||||
}
|
||||
return (_YAP_unify(t, ARG1));
|
||||
return (Yap_unify(t, ARG1));
|
||||
}
|
||||
else if (IsAtomTerm(t)) {
|
||||
/* Create a named array */
|
||||
@ -642,8 +642,8 @@ p_create_array(void)
|
||||
if (EndOfPAEntr(pp)) {
|
||||
if (H+1+size > ASP-1024) {
|
||||
WRITE_UNLOCK(ae->ARWLock);
|
||||
if (!_YAP_gc(2, ENV, P)) {
|
||||
_YAP_Error(OUT_OF_STACK_ERROR,TermNil,_YAP_ErrorMessage);
|
||||
if (!Yap_gc(2, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
} else
|
||||
goto restart;
|
||||
@ -656,12 +656,12 @@ p_create_array(void)
|
||||
|
||||
WRITE_UNLOCK(ae->ARWLock);
|
||||
if (!IsVarTerm(app->ValueOfVE) || !IsUnboundVar(app->ValueOfVE))
|
||||
_YAP_Error(PERMISSION_ERROR_CREATE_ARRAY,t,"create_array",
|
||||
Yap_Error(PERMISSION_ERROR_CREATE_ARRAY,t,"create_array",
|
||||
ae->StrOfAE);
|
||||
else {
|
||||
if (H+1+size > ASP-1024) {
|
||||
if (!_YAP_gc(2, ENV, P)) {
|
||||
_YAP_Error(OUT_OF_STACK_ERROR,TermNil,_YAP_ErrorMessage);
|
||||
if (!Yap_gc(2, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
} else
|
||||
goto restart;
|
||||
@ -685,23 +685,23 @@ p_create_static_array(void)
|
||||
static_array_types props;
|
||||
|
||||
if (IsVarTerm(ti)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,ti,"create static array");
|
||||
Yap_Error(INSTANTIATION_ERROR,ti,"create static array");
|
||||
return (FALSE);
|
||||
} else if (IsIntTerm(ti))
|
||||
size = IntOfTerm(ti);
|
||||
else {
|
||||
union arith_ret v;
|
||||
if (_YAP_Eval(ti, &v) == long_int_e) {
|
||||
if (Yap_Eval(ti, &v) == long_int_e) {
|
||||
size = v.Int;
|
||||
}
|
||||
else {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER,ti,"create static array");
|
||||
Yap_Error(TYPE_ERROR_INTEGER,ti,"create static array");
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
if (IsVarTerm(tprops)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,tprops,"create static array");
|
||||
Yap_Error(INSTANTIATION_ERROR,tprops,"create static array");
|
||||
return (FALSE);
|
||||
} else if (IsAtomTerm(tprops)) {
|
||||
char *atname = RepAtom(AtomOfTerm(tprops))->StrOfAE;
|
||||
@ -722,16 +722,16 @@ p_create_static_array(void)
|
||||
else if (!strcmp(atname, "term"))
|
||||
props = array_of_terms;
|
||||
else {
|
||||
_YAP_Error(DOMAIN_ERROR_ARRAY_TYPE,tprops,"create static array");
|
||||
Yap_Error(DOMAIN_ERROR_ARRAY_TYPE,tprops,"create static array");
|
||||
return(FALSE);
|
||||
}
|
||||
} else {
|
||||
_YAP_Error(TYPE_ERROR_ATOM,tprops,"create static array");
|
||||
Yap_Error(TYPE_ERROR_ATOM,tprops,"create static array");
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
if (IsVarTerm(t)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t,"create static array");
|
||||
Yap_Error(INSTANTIATION_ERROR,t,"create static array");
|
||||
return (FALSE);
|
||||
}
|
||||
else if (IsAtomTerm(t)) {
|
||||
@ -754,15 +754,15 @@ p_create_static_array(void)
|
||||
CreateStaticArray(ae, size, props, NULL, pp);
|
||||
return (TRUE);
|
||||
} else {
|
||||
_YAP_Error(PERMISSION_ERROR_CREATE_ARRAY,t,"cannot create static array over dynamic array");
|
||||
Yap_Error(PERMISSION_ERROR_CREATE_ARRAY,t,"cannot create static array over dynamic array");
|
||||
return (FALSE);
|
||||
}
|
||||
} else {
|
||||
_YAP_Error(PERMISSION_ERROR_CREATE_ARRAY,t,"cannot create static array over static array");
|
||||
Yap_Error(PERMISSION_ERROR_CREATE_ARRAY,t,"cannot create static array over static array");
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
_YAP_Error(TYPE_ERROR_ATOM,t,"create static array");
|
||||
Yap_Error(TYPE_ERROR_ATOM,t,"create static array");
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
@ -806,23 +806,23 @@ p_resize_static_array(void)
|
||||
Int size;
|
||||
|
||||
if (IsVarTerm(ti)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,ti,"resize a static array");
|
||||
Yap_Error(INSTANTIATION_ERROR,ti,"resize a static array");
|
||||
return (FALSE);
|
||||
} else if (IsIntTerm(ti))
|
||||
size = IntOfTerm(ti);
|
||||
else {
|
||||
union arith_ret v;
|
||||
if (_YAP_Eval(ti, &v) == long_int_e) {
|
||||
if (Yap_Eval(ti, &v) == long_int_e) {
|
||||
size = v.Int;
|
||||
}
|
||||
else {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER,ti,"resize a static array");
|
||||
Yap_Error(TYPE_ERROR_INTEGER,ti,"resize a static array");
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
if (IsVarTerm(t)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t,"resize a static array");
|
||||
Yap_Error(INSTANTIATION_ERROR,t,"resize a static array");
|
||||
return (FALSE);
|
||||
}
|
||||
else if (IsAtomTerm(t)) {
|
||||
@ -833,15 +833,15 @@ p_resize_static_array(void)
|
||||
while (!EndOfPAEntr(pp) && pp->KindOfPE != ArrayProperty)
|
||||
pp = RepStaticArrayProp(pp->NextOfPE);
|
||||
if (EndOfPAEntr(pp) || pp->ValueOfVE.ints == NULL) {
|
||||
_YAP_Error(PERMISSION_ERROR_RESIZE_ARRAY,t,"resize a static array");
|
||||
Yap_Error(PERMISSION_ERROR_RESIZE_ARRAY,t,"resize a static array");
|
||||
return(FALSE);
|
||||
} else {
|
||||
Int osize = - pp->ArrayEArity;
|
||||
ResizeStaticArray(pp, size);
|
||||
return(_YAP_unify(ARG2,MkIntegerTerm(osize)));
|
||||
return(Yap_unify(ARG2,MkIntegerTerm(osize)));
|
||||
}
|
||||
} else {
|
||||
_YAP_Error(TYPE_ERROR_ATOM,t,"resize a static array");
|
||||
Yap_Error(TYPE_ERROR_ATOM,t,"resize a static array");
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
@ -854,7 +854,7 @@ p_close_static_array(void)
|
||||
Term t = Deref(ARG1);
|
||||
|
||||
if (IsVarTerm(t)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t,"close static array");
|
||||
Yap_Error(INSTANTIATION_ERROR,t,"close static array");
|
||||
return (FALSE);
|
||||
}
|
||||
else if (IsAtomTerm(t)) {
|
||||
@ -873,12 +873,12 @@ p_close_static_array(void)
|
||||
StaticArrayEntry *ptr = (StaticArrayEntry *)pp;
|
||||
if (ptr->ValueOfVE.ints != NULL) {
|
||||
#if HAVE_MMAP
|
||||
if (ptr->ValueOfVE.chars < (char *)_YAP_HeapBase ||
|
||||
if (ptr->ValueOfVE.chars < (char *)Yap_HeapBase ||
|
||||
ptr->ValueOfVE.chars > (char *)HeapTop) {
|
||||
return(CloseMmappedArray(ptr, (void *)ptr->ValueOfVE.chars));
|
||||
}
|
||||
#endif
|
||||
_YAP_FreeAtomSpace((char *)(ptr->ValueOfVE.ints));
|
||||
Yap_FreeAtomSpace((char *)(ptr->ValueOfVE.ints));
|
||||
ptr->ValueOfVE.ints = NULL;
|
||||
ptr->ArrayEArity = 0;
|
||||
return(TRUE);
|
||||
@ -887,7 +887,7 @@ p_close_static_array(void)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_YAP_Error(TYPE_ERROR_ATOM,t,"close static array");
|
||||
Yap_Error(TYPE_ERROR_ATOM,t,"close static array");
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
@ -932,21 +932,21 @@ CloseMmappedArray(StaticArrayEntry *pp, void *area)
|
||||
optr = ptr;
|
||||
}
|
||||
if (ptr == NULL) {
|
||||
_YAP_Error(SYSTEM_ERROR,ARG1,"close_mmapped_array (array chain incoherent)", strerror(errno));
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"close_mmapped_array (array chain incoherent)", strerror(errno));
|
||||
return(FALSE);
|
||||
}
|
||||
if (munmap(ptr->start, ptr->size) == -1) {
|
||||
_YAP_Error(SYSTEM_ERROR,ARG1,"close_mmapped_array (munmap: %s)", strerror(errno));
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"close_mmapped_array (munmap: %s)", strerror(errno));
|
||||
return(FALSE);
|
||||
}
|
||||
optr->next = ptr->next;
|
||||
pp->ValueOfVE.ints = NULL;
|
||||
pp->ArrayEArity = 0;
|
||||
if (close(ptr->fd) < 0) {
|
||||
_YAP_Error(SYSTEM_ERROR,ARG1,"close_mmapped_array (close: %s)", strerror(errno));
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"close_mmapped_array (close: %s)", strerror(errno));
|
||||
return(FALSE);
|
||||
}
|
||||
_YAP_FreeAtomSpace((char *)ptr);
|
||||
Yap_FreeAtomSpace((char *)ptr);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
@ -966,24 +966,24 @@ ResizeMmappedArray(StaticArrayEntry *pp, Int dim, void *area)
|
||||
and last we initialise again
|
||||
*/
|
||||
if (munmap(ptr->start, ptr->size) == -1) {
|
||||
_YAP_Error(SYSTEM_ERROR,ARG1,"resize_mmapped_array (munmap: %s)", strerror(errno));
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"resize_mmapped_array (munmap: %s)", strerror(errno));
|
||||
return;
|
||||
}
|
||||
total_size = (ptr->size / ptr->items)*dim;
|
||||
if (ftruncate(ptr->fd, total_size) < 0) {
|
||||
_YAP_Error(SYSTEM_ERROR,ARG1,"resize_mmapped_array (ftruncate: %s)", strerror(errno));
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"resize_mmapped_array (ftruncate: %s)", strerror(errno));
|
||||
return;
|
||||
}
|
||||
if (lseek(ptr->fd, total_size-1, SEEK_SET) < 0) {
|
||||
_YAP_Error(SYSTEM_ERROR,ARG1,"resize_mmapped_array (lseek: %s)", strerror(errno));
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"resize_mmapped_array (lseek: %s)", strerror(errno));
|
||||
return;
|
||||
}
|
||||
if (write(ptr->fd, "", 1) < 0) {
|
||||
_YAP_Error(SYSTEM_ERROR,ARG1,"resize_mmapped_array (write: %s)", strerror(errno));
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"resize_mmapped_array (write: %s)", strerror(errno));
|
||||
return;
|
||||
}
|
||||
if ((ptr->start = (void *)mmap(0, (size_t) total_size, PROT_READ | PROT_WRITE, MAP_SHARED, ptr->fd, 0)) == (void *) - 1) {
|
||||
_YAP_Error(SYSTEM_ERROR,ARG1,"resize_mmapped_array (mmap: %s)", strerror(errno));
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"resize_mmapped_array (mmap: %s)", strerror(errno));
|
||||
return;
|
||||
}
|
||||
ptr->size = total_size;
|
||||
@ -1009,23 +1009,23 @@ p_create_mmapped_array(void)
|
||||
int fd;
|
||||
|
||||
if (IsVarTerm(ti)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,ti,"create_mmapped_array");
|
||||
Yap_Error(INSTANTIATION_ERROR,ti,"create_mmapped_array");
|
||||
return (FALSE);
|
||||
} else if (IsIntTerm(ti))
|
||||
size = IntOfTerm(ti);
|
||||
else {
|
||||
union arith_ret v;
|
||||
if (_YAP_Eval(ti, &v) == long_int_e) {
|
||||
if (Yap_Eval(ti, &v) == long_int_e) {
|
||||
size = v.Int;
|
||||
}
|
||||
else {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER,ti,"create_mmapped_array");
|
||||
Yap_Error(TYPE_ERROR_INTEGER,ti,"create_mmapped_array");
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
if (IsVarTerm(tprops)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,tprops,"create_mmapped_array");
|
||||
Yap_Error(INSTANTIATION_ERROR,tprops,"create_mmapped_array");
|
||||
return (FALSE);
|
||||
} else if (IsAtomTerm(tprops)) {
|
||||
char *atname = RepAtom(AtomOfTerm(tprops))->StrOfAE;
|
||||
@ -1051,16 +1051,16 @@ p_create_mmapped_array(void)
|
||||
props = array_of_uchars;
|
||||
total_size = size*sizeof(unsigned char);
|
||||
} else {
|
||||
_YAP_Error(DOMAIN_ERROR_ARRAY_TYPE,tprops,"create_mmapped_array");
|
||||
Yap_Error(DOMAIN_ERROR_ARRAY_TYPE,tprops,"create_mmapped_array");
|
||||
return(FALSE);
|
||||
}
|
||||
} else {
|
||||
_YAP_Error(TYPE_ERROR_ATOM,tprops,"create_mmapped_array");
|
||||
Yap_Error(TYPE_ERROR_ATOM,tprops,"create_mmapped_array");
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
if (IsVarTerm(tfile)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,tfile,"create_mmapped_array");
|
||||
Yap_Error(INSTANTIATION_ERROR,tfile,"create_mmapped_array");
|
||||
return (FALSE);
|
||||
} else if (IsAtomTerm(tfile)) {
|
||||
char *filename = RepAtom(AtomOfTerm(tfile))->StrOfAE;
|
||||
@ -1068,26 +1068,26 @@ p_create_mmapped_array(void)
|
||||
|
||||
fd = open(filename, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR);
|
||||
if (fd == -1) {
|
||||
_YAP_Error(SYSTEM_ERROR,ARG1,"create_mmapped_array (open: %s)", strerror(errno));
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"create_mmapped_array (open: %s)", strerror(errno));
|
||||
return(FALSE);
|
||||
}
|
||||
if (lseek(fd, total_size-1, SEEK_SET) < 0)
|
||||
_YAP_Error(SYSTEM_ERROR,tfile,"create_mmapped_array (lseek: %s)", strerror(errno));
|
||||
Yap_Error(SYSTEM_ERROR,tfile,"create_mmapped_array (lseek: %s)", strerror(errno));
|
||||
if (write(fd, "", 1) < 0)
|
||||
_YAP_Error(SYSTEM_ERROR,tfile,"create_mmapped_array (write: %s)", strerror(errno));
|
||||
Yap_Error(SYSTEM_ERROR,tfile,"create_mmapped_array (write: %s)", strerror(errno));
|
||||
/*
|
||||
if (ftruncate(fd, total_size) < 0)
|
||||
_YAP_Error(SYSTEM_ERROR,tfile,"create_mmapped_array");
|
||||
Yap_Error(SYSTEM_ERROR,tfile,"create_mmapped_array");
|
||||
*/
|
||||
if ((array_addr = (CODEADDR)mmap(0, (size_t) total_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == (CODEADDR) - 1)
|
||||
_YAP_Error(SYSTEM_ERROR,tfile,"create_mmapped_array (mmap: %s)", strerror(errno));
|
||||
Yap_Error(SYSTEM_ERROR,tfile,"create_mmapped_array (mmap: %s)", strerror(errno));
|
||||
} else {
|
||||
_YAP_Error(TYPE_ERROR_ATOM,tfile,"create_mmapped_array");
|
||||
Yap_Error(TYPE_ERROR_ATOM,tfile,"create_mmapped_array");
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
if (IsVarTerm(t)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t,"create_mmapped_array");
|
||||
Yap_Error(INSTANTIATION_ERROR,t,"create_mmapped_array");
|
||||
return (FALSE);
|
||||
}
|
||||
else if (IsAtomTerm(t)) {
|
||||
@ -1106,7 +1106,7 @@ p_create_mmapped_array(void)
|
||||
mmap_array_block *ptr;
|
||||
|
||||
CreateStaticArray(ae, size, props, array_addr, pp);
|
||||
ptr = (mmap_array_block *)_YAP_AllocAtomSpace(sizeof(mmap_array_block));
|
||||
ptr = (mmap_array_block *)Yap_AllocAtomSpace(sizeof(mmap_array_block));
|
||||
ptr->name = AbsAtom(ae);
|
||||
ptr->size = total_size;
|
||||
ptr->items = size;
|
||||
@ -1118,15 +1118,15 @@ p_create_mmapped_array(void)
|
||||
} else {
|
||||
WRITE_UNLOCK(pp->ArRWLock);
|
||||
WRITE_UNLOCK(ae->ARWLock);
|
||||
_YAP_Error(DOMAIN_ERROR_ARRAY_TYPE,t,"create_mmapped_array", ae->StrOfAE);
|
||||
Yap_Error(DOMAIN_ERROR_ARRAY_TYPE,t,"create_mmapped_array", ae->StrOfAE);
|
||||
return(FALSE);
|
||||
}
|
||||
} else {
|
||||
_YAP_Error(TYPE_ERROR_ATOM,t,"create_mmapped_array");
|
||||
Yap_Error(TYPE_ERROR_ATOM,t,"create_mmapped_array");
|
||||
return (FALSE);
|
||||
}
|
||||
#else
|
||||
_YAP_Error(SYSTEM_ERROR,ARG1,"create_mmapped_array (mmap)");
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"create_mmapped_array (mmap)");
|
||||
return (FALSE);
|
||||
#endif
|
||||
}
|
||||
@ -1139,7 +1139,7 @@ replace_array_references_complex(register CELL *pt0,
|
||||
Term Var)
|
||||
{
|
||||
|
||||
register CELL **to_visit = (CELL **) _YAP_PreAllocCodeSpace();
|
||||
register CELL **to_visit = (CELL **) Yap_PreAllocCodeSpace();
|
||||
CELL **to_visit_base = to_visit;
|
||||
|
||||
loop:
|
||||
@ -1235,7 +1235,7 @@ loop:
|
||||
}
|
||||
|
||||
Bind_Global(PtrOfTerm(Var), TermNil);
|
||||
_YAP_ReleasePreAllocCodeSpace((ADDR)to_visit);
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)to_visit);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1285,7 +1285,7 @@ p_array_references(void)
|
||||
Term t1 = HeadOfTerm(t);
|
||||
Term t2 = TailOfTerm(t);
|
||||
|
||||
return (_YAP_unify(t1, ARG2) && _YAP_unify(t2, ARG3));
|
||||
return (Yap_unify(t1, ARG2) && Yap_unify(t2, ARG3));
|
||||
}
|
||||
|
||||
static Int
|
||||
@ -1301,22 +1301,22 @@ p_assign_static(void)
|
||||
indx = IntOfTerm(t2);
|
||||
else {
|
||||
union arith_ret v;
|
||||
if (_YAP_Eval(t2, &v) == long_int_e) {
|
||||
if (Yap_Eval(t2, &v) == long_int_e) {
|
||||
indx = v.Int;
|
||||
} else {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER,t2,"update_array");
|
||||
Yap_Error(TYPE_ERROR_INTEGER,t2,"update_array");
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t2,"update_array");
|
||||
Yap_Error(INSTANTIATION_ERROR,t2,"update_array");
|
||||
return (FALSE);
|
||||
}
|
||||
t3 = Deref(ARG3);
|
||||
|
||||
t1 = Deref(ARG1);
|
||||
if (IsVarTerm(t1)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t1,"update_array");
|
||||
Yap_Error(INSTANTIATION_ERROR,t1,"update_array");
|
||||
return(FALSE);
|
||||
}
|
||||
if (!IsAtomTerm(t1)) {
|
||||
@ -1325,11 +1325,11 @@ p_assign_static(void)
|
||||
Functor f = FunctorOfTerm(t1);
|
||||
/* store the terms to visit */
|
||||
if (IsExtensionFunctor(f)) {
|
||||
_YAP_Error(TYPE_ERROR_ARRAY,t1,"update_array");
|
||||
Yap_Error(TYPE_ERROR_ARRAY,t1,"update_array");
|
||||
return(FALSE);
|
||||
}
|
||||
if (indx > 0 && indx > ArityOfFunctor(f)) {
|
||||
_YAP_Error(DOMAIN_ERROR_ARRAY_OVERFLOW,t2,"update_array");
|
||||
Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW,t2,"update_array");
|
||||
return(FALSE);
|
||||
}
|
||||
ptr = RepAppl(t1)+indx+1;
|
||||
@ -1337,11 +1337,11 @@ p_assign_static(void)
|
||||
MaBind(ptr, t3);
|
||||
return(TRUE);
|
||||
#else
|
||||
_YAP_Error(SYSTEM_ERROR,t2,"update_array");
|
||||
Yap_Error(SYSTEM_ERROR,t2,"update_array");
|
||||
return(FALSE);
|
||||
#endif
|
||||
} else {
|
||||
_YAP_Error(TYPE_ERROR_ATOM,t1,"update_array");
|
||||
Yap_Error(TYPE_ERROR_ATOM,t1,"update_array");
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
@ -1356,7 +1356,7 @@ p_assign_static(void)
|
||||
}
|
||||
|
||||
if (EndOfPAEntr(ptr)) {
|
||||
_YAP_Error(EXISTENCE_ERROR_ARRAY,t1,"assign_static %s", RepAtom(AtomOfTerm(t1))->StrOfAE);
|
||||
Yap_Error(EXISTENCE_ERROR_ARRAY,t1,"assign_static %s", RepAtom(AtomOfTerm(t1))->StrOfAE);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
@ -1365,7 +1365,7 @@ p_assign_static(void)
|
||||
ArrayEntry *pp = (ArrayEntry *)ptr;
|
||||
CELL *pt;
|
||||
if (indx < 0 || indx >= pp->ArrayEArity) {
|
||||
_YAP_Error(DOMAIN_ERROR_ARRAY_OVERFLOW,t2,"assign_static");
|
||||
Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW,t2,"assign_static");
|
||||
READ_UNLOCK(((ArrayEntry *)ptr)->ArRWLock);
|
||||
return(FALSE);
|
||||
}
|
||||
@ -1376,7 +1376,7 @@ p_assign_static(void)
|
||||
MaBind(pt, t3);
|
||||
return(TRUE);
|
||||
#else
|
||||
_YAP_Error(SYSTEM_ERROR,t2,"update_array");
|
||||
Yap_Error(SYSTEM_ERROR,t2,"update_array");
|
||||
return(FALSE);
|
||||
#endif
|
||||
}
|
||||
@ -1384,12 +1384,12 @@ p_assign_static(void)
|
||||
/* a static array */
|
||||
if (IsVarTerm(t3)) {
|
||||
WRITE_UNLOCK(ptr->ArRWLock);
|
||||
_YAP_Error(INSTANTIATION_ERROR,t3,"assign_static");
|
||||
Yap_Error(INSTANTIATION_ERROR,t3,"assign_static");
|
||||
return (FALSE);
|
||||
}
|
||||
if (indx < 0 || indx >= - ptr->ArrayEArity) {
|
||||
WRITE_UNLOCK(ptr->ArRWLock);
|
||||
_YAP_Error(DOMAIN_ERROR_ARRAY_OVERFLOW,t2,"assign_static");
|
||||
Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW,t2,"assign_static");
|
||||
return(FALSE);
|
||||
}
|
||||
switch (ptr->ArrayType) {
|
||||
@ -1400,11 +1400,11 @@ p_assign_static(void)
|
||||
|
||||
if (IsIntTerm(t3))
|
||||
i = IntOfTerm(t3);
|
||||
else if (_YAP_Eval(t3, &v) == long_int_e)
|
||||
else if (Yap_Eval(t3, &v) == long_int_e)
|
||||
i = v.Int;
|
||||
else {
|
||||
WRITE_UNLOCK(ptr->ArRWLock);
|
||||
_YAP_Error(TYPE_ERROR_INTEGER,t3,"assign_static");
|
||||
Yap_Error(TYPE_ERROR_INTEGER,t3,"assign_static");
|
||||
return (FALSE);
|
||||
}
|
||||
ptr->ValueOfVE.ints[indx]= i;
|
||||
@ -1418,15 +1418,15 @@ p_assign_static(void)
|
||||
|
||||
if (IsIntTerm(t3))
|
||||
i = IntOfTerm(t3);
|
||||
else if (_YAP_Eval(t3, &v) == long_int_e)
|
||||
else if (Yap_Eval(t3, &v) == long_int_e)
|
||||
i = v.Int;
|
||||
else {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER,t3,"assign_static");
|
||||
Yap_Error(TYPE_ERROR_INTEGER,t3,"assign_static");
|
||||
return (FALSE);
|
||||
}
|
||||
if (i > 127 || i < -128) {
|
||||
WRITE_UNLOCK(ptr->ArRWLock);
|
||||
_YAP_Error(TYPE_ERROR_BYTE,t3,"assign_static");
|
||||
Yap_Error(TYPE_ERROR_BYTE,t3,"assign_static");
|
||||
return (FALSE);
|
||||
}
|
||||
ptr->ValueOfVE.chars[indx]= i;
|
||||
@ -1440,16 +1440,16 @@ p_assign_static(void)
|
||||
|
||||
if (IsIntTerm(t3))
|
||||
i = IntOfTerm(t3);
|
||||
else if (_YAP_Eval(t3, &v) == long_int_e)
|
||||
else if (Yap_Eval(t3, &v) == long_int_e)
|
||||
i = v.Int;
|
||||
else {
|
||||
WRITE_UNLOCK(ptr->ArRWLock);
|
||||
_YAP_Error(TYPE_ERROR_INTEGER,t3,"assign_static");
|
||||
Yap_Error(TYPE_ERROR_INTEGER,t3,"assign_static");
|
||||
return (FALSE);
|
||||
}
|
||||
if (i > 255 || i < 0) {
|
||||
WRITE_UNLOCK(ptr->ArRWLock);
|
||||
_YAP_Error(TYPE_ERROR_UBYTE,t3,"assign_static");
|
||||
Yap_Error(TYPE_ERROR_UBYTE,t3,"assign_static");
|
||||
return (FALSE);
|
||||
}
|
||||
ptr->ValueOfVE.chars[indx]= i;
|
||||
@ -1463,11 +1463,11 @@ p_assign_static(void)
|
||||
|
||||
if (IsFloatTerm(t3))
|
||||
f = FloatOfTerm(t3);
|
||||
else if (_YAP_Eval(t3, &v) == double_e)
|
||||
else if (Yap_Eval(t3, &v) == double_e)
|
||||
f = v.dbl;
|
||||
else {
|
||||
WRITE_UNLOCK(ptr->ArRWLock);
|
||||
_YAP_Error(TYPE_ERROR_FLOAT,t3,"assign_static");
|
||||
Yap_Error(TYPE_ERROR_FLOAT,t3,"assign_static");
|
||||
return (FALSE);
|
||||
}
|
||||
ptr->ValueOfVE.floats[indx]= f;
|
||||
@ -1482,7 +1482,7 @@ p_assign_static(void)
|
||||
r = IntegerOfTerm(t3);
|
||||
else {
|
||||
WRITE_UNLOCK(ptr->ArRWLock);
|
||||
_YAP_Error(TYPE_ERROR_PTR,t3,"assign_static");
|
||||
Yap_Error(TYPE_ERROR_PTR,t3,"assign_static");
|
||||
return (FALSE);
|
||||
}
|
||||
ptr->ValueOfVE.ptrs[indx]= (AtomEntry *)r;
|
||||
@ -1493,7 +1493,7 @@ p_assign_static(void)
|
||||
{
|
||||
if (!IsAtomTerm(t3)) {
|
||||
WRITE_UNLOCK(ptr->ArRWLock);
|
||||
_YAP_Error(TYPE_ERROR_ATOM,t3,"assign_static");
|
||||
Yap_Error(TYPE_ERROR_ATOM,t3,"assign_static");
|
||||
return (FALSE);
|
||||
}
|
||||
ptr->ValueOfVE.atoms[indx]= t3;
|
||||
@ -1507,7 +1507,7 @@ p_assign_static(void)
|
||||
|
||||
if (!IsDBRefTerm(t3)) {
|
||||
WRITE_UNLOCK(ptr->ArRWLock);
|
||||
_YAP_Error(TYPE_ERROR_DBREF,t3,"assign_static");
|
||||
Yap_Error(TYPE_ERROR_DBREF,t3,"assign_static");
|
||||
return (FALSE);
|
||||
}
|
||||
ptr->ValueOfVE.dbrefs[indx]= t3;
|
||||
@ -1523,9 +1523,9 @@ p_assign_static(void)
|
||||
DBRef ref = ptr->ValueOfVE.terms[indx];
|
||||
|
||||
if (ref != NULL) {
|
||||
_YAP_ReleaseTermFromDB(ref);
|
||||
Yap_ReleaseTermFromDB(ref);
|
||||
}
|
||||
ptr->ValueOfVE.terms[indx] = _YAP_StoreTermInDB(3,3);
|
||||
ptr->ValueOfVE.terms[indx] = Yap_StoreTermInDB(3,3);
|
||||
if (ptr->ValueOfVE.terms[indx] == NULL){
|
||||
WRITE_UNLOCK(ptr->ArRWLock);
|
||||
return(FALSE);
|
||||
@ -1564,20 +1564,20 @@ p_sync_mmapped_arrays(void)
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_InitArrayPreds(void)
|
||||
Yap_InitArrayPreds(void)
|
||||
{
|
||||
_YAP_InitCPred("$create_array", 2, p_create_array, SyncPredFlag);
|
||||
_YAP_InitCPred("$array_references", 3, p_array_references, SafePredFlag);
|
||||
_YAP_InitCPred("$array_arg", 3, p_array_arg, SafePredFlag);
|
||||
_YAP_InitCPred("static_array", 3, p_create_static_array, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("resize_static_array", 3, p_resize_static_array, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("mmapped_array", 4, p_create_mmapped_array, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("update_array", 3, p_assign_static, SafePredFlag);
|
||||
_YAP_InitCPred("array_element", 3, p_access_array, 0);
|
||||
_YAP_InitCPred("close_static_array", 1, p_close_static_array, SafePredFlag);
|
||||
_YAP_InitCPred("$sync_mmapped_arrays", 0, p_sync_mmapped_arrays, SafePredFlag);
|
||||
_YAP_InitCPred("$compile_array_refs", 0, p_compile_array_refs, SafePredFlag);
|
||||
_YAP_InitCPred("$array_refs_compiled", 0, p_array_refs_compiled, SafePredFlag);
|
||||
_YAP_InitCPred("$has_static_array", 1, p_has_static_array, TestPredFlag|SafePredFlag);
|
||||
Yap_InitCPred("$create_array", 2, p_create_array, SyncPredFlag);
|
||||
Yap_InitCPred("$array_references", 3, p_array_references, SafePredFlag);
|
||||
Yap_InitCPred("$array_arg", 3, p_array_arg, SafePredFlag);
|
||||
Yap_InitCPred("static_array", 3, p_create_static_array, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("resize_static_array", 3, p_resize_static_array, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("mmapped_array", 4, p_create_mmapped_array, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("update_array", 3, p_assign_static, SafePredFlag);
|
||||
Yap_InitCPred("array_element", 3, p_access_array, 0);
|
||||
Yap_InitCPred("close_static_array", 1, p_close_static_array, SafePredFlag);
|
||||
Yap_InitCPred("$sync_mmapped_arrays", 0, p_sync_mmapped_arrays, SafePredFlag);
|
||||
Yap_InitCPred("$compile_array_refs", 0, p_compile_array_refs, SafePredFlag);
|
||||
Yap_InitCPred("$array_refs_compiled", 0, p_array_refs_compiled, SafePredFlag);
|
||||
Yap_InitCPred("$has_static_array", 1, p_has_static_array, TestPredFlag|SafePredFlag);
|
||||
}
|
||||
|
||||
|
114
C/attvar.c
114
C/attvar.c
@ -44,15 +44,15 @@ AddToQueue(attvar_record *attv)
|
||||
t[0] = (CELL)&(attv->Done);
|
||||
t[1] = attv->Value;
|
||||
/* follow the chain */
|
||||
WGs = (sus_record *)_YAP_ReadTimedVar(WokenGoals);
|
||||
WGs = (sus_record *)Yap_ReadTimedVar(WokenGoals);
|
||||
new = (sus_record *)H;
|
||||
H = (CELL *)(new+1);
|
||||
new->NR = (sus_record *)(&(new->NR));
|
||||
new->SG = _YAP_MkApplTerm(FunctorAttGoal, 2, t);
|
||||
new->SG = Yap_MkApplTerm(FunctorAttGoal, 2, t);
|
||||
new->NS = new;
|
||||
|
||||
if ((Term)WGs == TermNil) {
|
||||
_YAP_UpdateTimedVar(WokenGoals, (CELL)new);
|
||||
Yap_UpdateTimedVar(WokenGoals, (CELL)new);
|
||||
/* from now on, we have to start waking up goals */
|
||||
if (CreepFlag != Unsigned(LCL0) - Unsigned(H0))
|
||||
CreepFlag = Unsigned(LCL0);
|
||||
@ -71,7 +71,7 @@ AddFailToQueue(void)
|
||||
sus_record *new;
|
||||
|
||||
/* follow the chain */
|
||||
WGs = (sus_record *)_YAP_ReadTimedVar(WokenGoals);
|
||||
WGs = (sus_record *)Yap_ReadTimedVar(WokenGoals);
|
||||
new = (sus_record *)H;
|
||||
H = (CELL *)(new+1);
|
||||
new->NR = (sus_record *)(&(new->NR));
|
||||
@ -79,7 +79,7 @@ AddFailToQueue(void)
|
||||
new->NS = new;
|
||||
|
||||
if ((Term)WGs == TermNil) {
|
||||
_YAP_UpdateTimedVar(WokenGoals, (CELL)new);
|
||||
Yap_UpdateTimedVar(WokenGoals, (CELL)new);
|
||||
/* from now on, we have to start waking up goals */
|
||||
if (CreepFlag != Unsigned(LCL0) - Unsigned(H0))
|
||||
CreepFlag = Unsigned(LCL0);
|
||||
@ -101,13 +101,13 @@ CopyAttVar(CELL *orig, CELL ***to_visit_ptr, CELL *res)
|
||||
Int j;
|
||||
|
||||
/* add a new attributed variable */
|
||||
newv = (attvar_record *)_YAP_ReadTimedVar(DelayedVars);
|
||||
newv = (attvar_record *)Yap_ReadTimedVar(DelayedVars);
|
||||
if (H0 - (CELL *)newv < 1024+(2*NUM_OF_ATTS))
|
||||
return(FALSE);
|
||||
RESET_VARIABLE(&(newv->Done));
|
||||
newv->sus_id = attvars_ext;
|
||||
RESET_VARIABLE(&(newv->Value));
|
||||
newv->NS = _YAP_UpdateTimedVar(AttsMutableList, (CELL)&(newv->Done));
|
||||
newv->NS = Yap_UpdateTimedVar(AttsMutableList, (CELL)&(newv->Done));
|
||||
for (j = 0; j < NUM_OF_ATTS; j++) {
|
||||
Term t = Deref(attv->Atts[2*j+1]);
|
||||
newv->Atts[2*j] = time;
|
||||
@ -135,7 +135,7 @@ CopyAttVar(CELL *orig, CELL ***to_visit_ptr, CELL *res)
|
||||
}
|
||||
*to_visit_ptr = to_visit;
|
||||
*res = (CELL)&(newv->Done);
|
||||
_YAP_UpdateTimedVar(DelayedVars, (CELL)(newv->Atts+2*j));
|
||||
Yap_UpdateTimedVar(DelayedVars, (CELL)(newv->Atts+2*j));
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
@ -177,14 +177,14 @@ WakeAttVar(CELL* pt1, CELL reg2)
|
||||
/* binding two suspended variables, be careful */
|
||||
if (susp2->sus_id != attvars_ext) {
|
||||
/* joining two different kinds of suspensions */
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, "joining two different suspensions not implemented");
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, "joining two different suspensions not implemented");
|
||||
return;
|
||||
}
|
||||
if (susp2 >= attv) {
|
||||
if (susp2 == attv) return;
|
||||
if (!IsVarTerm(susp2->Value) || !IsUnboundVar(susp2->Value)) {
|
||||
/* oops, our goal is on the queue to be woken */
|
||||
if (!_YAP_unify(susp2->Value, (CELL)pt1)) {
|
||||
if (!Yap_unify(susp2->Value, (CELL)pt1)) {
|
||||
AddFailToQueue();
|
||||
}
|
||||
}
|
||||
@ -199,7 +199,7 @@ WakeAttVar(CELL* pt1, CELL reg2)
|
||||
}
|
||||
if (!IsVarTerm(attv->Value) || !IsUnboundVar(attv->Value)) {
|
||||
/* oops, our goal is on the queue to be woken */
|
||||
if (!_YAP_unify(attv->Value, reg2)) {
|
||||
if (!Yap_unify(attv->Value, reg2)) {
|
||||
AddFailToQueue();
|
||||
}
|
||||
return;
|
||||
@ -221,17 +221,17 @@ mark_attvar(CELL *orig)
|
||||
register attvar_record *attv = (attvar_record *)orig;
|
||||
Int i;
|
||||
|
||||
_YAP_mark_external_reference(&(attv->Value));
|
||||
_YAP_mark_external_reference(&(attv->Done));
|
||||
Yap_mark_external_reference(&(attv->Value));
|
||||
Yap_mark_external_reference(&(attv->Done));
|
||||
for (i = 0; i < NUM_OF_ATTS; i++) {
|
||||
_YAP_mark_external_reference(attv->Atts+2*i+1);
|
||||
Yap_mark_external_reference(attv->Atts+2*i+1);
|
||||
}
|
||||
}
|
||||
|
||||
#if FROZEN_STACKS
|
||||
static Term
|
||||
CurrentTime(void) {
|
||||
return(MkIntegerTerm(TR-(tr_fr_ptr)_YAP_TrailBase));
|
||||
return(MkIntegerTerm(TR-(tr_fr_ptr)Yap_TrailBase));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -244,7 +244,7 @@ InitVarTime(void) {
|
||||
/* so we just init a TR cell that will not harm anyone */
|
||||
Bind((CELL *)(TR+1),AbsAppl(H-1));
|
||||
}
|
||||
return(MkIntegerTerm(B->cp_tr-(tr_fr_ptr)_YAP_TrailBase));
|
||||
return(MkIntegerTerm(B->cp_tr-(tr_fr_ptr)Yap_TrailBase));
|
||||
#else
|
||||
Term t = (CELL)H;
|
||||
*H++ = TermFoundVar;
|
||||
@ -256,7 +256,7 @@ static Int
|
||||
PutAtt(attvar_record *attv, Int i, Term tatt) {
|
||||
Int pos = i*2;
|
||||
#if FROZEN_STACKS
|
||||
tr_fr_ptr timestmp = (tr_fr_ptr)_YAP_TrailBase+IntegerOfTerm(attv->Atts[pos]);
|
||||
tr_fr_ptr timestmp = (tr_fr_ptr)Yap_TrailBase+IntegerOfTerm(attv->Atts[pos]);
|
||||
if (B->cp_tr <= timestmp
|
||||
&& timestmp <= TR) {
|
||||
#if defined(SBA)
|
||||
@ -297,7 +297,7 @@ RmAtt(attvar_record *attv, Int i) {
|
||||
Int pos = i *2;
|
||||
if (!IsVarTerm(attv->Atts[pos+1])) {
|
||||
#if FROZEN_STACKS
|
||||
tr_fr_ptr timestmp = (tr_fr_ptr)_YAP_TrailBase+IntegerOfTerm(attv->Atts[pos]);
|
||||
tr_fr_ptr timestmp = (tr_fr_ptr)Yap_TrailBase+IntegerOfTerm(attv->Atts[pos]);
|
||||
if (B->cp_tr <= timestmp
|
||||
&& timestmp <= TR) {
|
||||
RESET_VARIABLE(attv->Atts+(pos+1));
|
||||
@ -344,13 +344,13 @@ BuildNewAttVar(Term t, Int i, Term tatt)
|
||||
Term time;
|
||||
int j;
|
||||
|
||||
attvar_record *attv = (attvar_record *)_YAP_ReadTimedVar(DelayedVars);
|
||||
attvar_record *attv = (attvar_record *)Yap_ReadTimedVar(DelayedVars);
|
||||
if (H0 - (CELL *)attv < 1024+(2*NUM_OF_ATTS)) {
|
||||
H[0] = t;
|
||||
H[1] = tatt;
|
||||
H += 2;
|
||||
if (!_YAP_growglobal(NULL)) {
|
||||
_YAP_Error(SYSTEM_ERROR, t, _YAP_ErrorMessage);
|
||||
if (!Yap_growglobal(NULL)) {
|
||||
Yap_Error(SYSTEM_ERROR, t, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
H -= 2;
|
||||
@ -365,9 +365,9 @@ BuildNewAttVar(Term t, Int i, Term tatt)
|
||||
attv->Atts[2*j] = time;
|
||||
RESET_VARIABLE(attv->Atts+2*j+1);
|
||||
}
|
||||
attv->NS = _YAP_UpdateTimedVar(AttsMutableList, (CELL)&(attv->Done));
|
||||
attv->NS = Yap_UpdateTimedVar(AttsMutableList, (CELL)&(attv->Done));
|
||||
Bind((CELL *)t,(CELL)attv);
|
||||
_YAP_UpdateTimedVar(DelayedVars,(CELL)(attv->Atts+2*j));
|
||||
Yap_UpdateTimedVar(DelayedVars,(CELL)(attv->Atts+2*j));
|
||||
/* if i < 0 then we have the list of arguments */
|
||||
if (i < 0) {
|
||||
Int j = 0;
|
||||
@ -408,7 +408,7 @@ BindAttVar(attvar_record *attv) {
|
||||
Bind_Global(&(attv->Done), attv->Value);
|
||||
return(TRUE);
|
||||
} else {
|
||||
_YAP_Error(SYSTEM_ERROR,(CELL)&(attv->Done),"attvar was bound when set");
|
||||
Yap_Error(SYSTEM_ERROR,(CELL)&(attv->Done),"attvar was bound when set");
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
@ -437,8 +437,8 @@ AllAttVars(Term t) {
|
||||
}
|
||||
|
||||
Term
|
||||
_YAP_CurrentAttVars(void) {
|
||||
return(AllAttVars(_YAP_ReadTimedVar(AttsMutableList)));
|
||||
Yap_CurrentAttVars(void) {
|
||||
return(AllAttVars(Yap_ReadTimedVar(AttsMutableList)));
|
||||
|
||||
}
|
||||
|
||||
@ -453,14 +453,14 @@ p_put_att(void) {
|
||||
exts id = (exts)attv->sus_id;
|
||||
|
||||
if (id != attvars_ext) {
|
||||
_YAP_Error(TYPE_ERROR_VARIABLE,inp,"put_attributes/2");
|
||||
Yap_Error(TYPE_ERROR_VARIABLE,inp,"put_attributes/2");
|
||||
return(FALSE);
|
||||
}
|
||||
return(PutAtt(attv, IntegerOfTerm(Deref(ARG2)), Deref(ARG3)));
|
||||
}
|
||||
return(BuildNewAttVar(inp, IntegerOfTerm(Deref(ARG2)), Deref(ARG3)));
|
||||
} else {
|
||||
_YAP_Error(TYPE_ERROR_VARIABLE,inp,"put_attributes/2");
|
||||
Yap_Error(TYPE_ERROR_VARIABLE,inp,"put_attributes/2");
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
@ -476,14 +476,14 @@ p_rm_att(void) {
|
||||
exts id = (exts)attv->sus_id;
|
||||
|
||||
if (id != attvars_ext) {
|
||||
_YAP_Error(TYPE_ERROR_VARIABLE,inp,"delete_attribute/2");
|
||||
Yap_Error(TYPE_ERROR_VARIABLE,inp,"delete_attribute/2");
|
||||
return(FALSE);
|
||||
}
|
||||
return(RmAtt(attv, IntegerOfTerm(Deref(ARG2))));
|
||||
}
|
||||
return(TRUE);
|
||||
} else {
|
||||
_YAP_Error(TYPE_ERROR_VARIABLE,inp,"delete_attribute/2");
|
||||
Yap_Error(TYPE_ERROR_VARIABLE,inp,"delete_attribute/2");
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
@ -500,16 +500,16 @@ p_get_att(void) {
|
||||
exts id = (exts)attv->sus_id;
|
||||
|
||||
if (id != attvars_ext) {
|
||||
_YAP_Error(TYPE_ERROR_VARIABLE,inp,"get_att/2");
|
||||
Yap_Error(TYPE_ERROR_VARIABLE,inp,"get_att/2");
|
||||
return(FALSE);
|
||||
}
|
||||
out = GetAtt(attv,IntegerOfTerm(Deref(ARG2)));
|
||||
return(!IsVarTerm(out) && _YAP_unify(ARG3,out));
|
||||
return(!IsVarTerm(out) && Yap_unify(ARG3,out));
|
||||
}
|
||||
/* _YAP_Error(INSTANTIATION_ERROR,inp,"get_att/2");*/
|
||||
/* Yap_Error(INSTANTIATION_ERROR,inp,"get_att/2");*/
|
||||
return(FALSE);
|
||||
} else {
|
||||
_YAP_Error(TYPE_ERROR_VARIABLE,inp,"get_att/2");
|
||||
Yap_Error(TYPE_ERROR_VARIABLE,inp,"get_att/2");
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
@ -525,14 +525,14 @@ p_free_att(void) {
|
||||
exts id = (exts)attv->sus_id;
|
||||
|
||||
if (id != attvars_ext) {
|
||||
_YAP_Error(TYPE_ERROR_VARIABLE,inp,"get_att/2");
|
||||
Yap_Error(TYPE_ERROR_VARIABLE,inp,"get_att/2");
|
||||
return(FALSE);
|
||||
}
|
||||
return(FreeAtt(attv,IntegerOfTerm(Deref(ARG2))));
|
||||
}
|
||||
return(TRUE);
|
||||
} else {
|
||||
_YAP_Error(TYPE_ERROR_VARIABLE,inp,"free_att/2");
|
||||
Yap_Error(TYPE_ERROR_VARIABLE,inp,"free_att/2");
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
@ -548,14 +548,14 @@ p_bind_attvar(void) {
|
||||
exts id = (exts)attv->sus_id;
|
||||
|
||||
if (id != attvars_ext) {
|
||||
_YAP_Error(TYPE_ERROR_VARIABLE,inp,"get_att/2");
|
||||
Yap_Error(TYPE_ERROR_VARIABLE,inp,"get_att/2");
|
||||
return(FALSE);
|
||||
}
|
||||
return(BindAttVar(attv));
|
||||
}
|
||||
return(TRUE);
|
||||
} else {
|
||||
_YAP_Error(TYPE_ERROR_VARIABLE,inp,"bind_att/2");
|
||||
Yap_Error(TYPE_ERROR_VARIABLE,inp,"bind_att/2");
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
@ -571,14 +571,14 @@ p_get_all_atts(void) {
|
||||
exts id = (exts)(attv->sus_id);
|
||||
|
||||
if (id != attvars_ext) {
|
||||
_YAP_Error(TYPE_ERROR_VARIABLE,inp,"get_att/2");
|
||||
Yap_Error(TYPE_ERROR_VARIABLE,inp,"get_att/2");
|
||||
return(FALSE);
|
||||
}
|
||||
return(_YAP_unify(ARG2,GetAllAtts(attv)));
|
||||
return(Yap_unify(ARG2,GetAllAtts(attv)));
|
||||
}
|
||||
return(TRUE);
|
||||
} else {
|
||||
_YAP_Error(TYPE_ERROR_VARIABLE,inp,"get_att/2");
|
||||
Yap_Error(TYPE_ERROR_VARIABLE,inp,"get_att/2");
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
@ -588,21 +588,21 @@ p_inc_atts(void)
|
||||
{
|
||||
Term t = MkIntegerTerm(NUM_OF_ATTS);
|
||||
NUM_OF_ATTS++;
|
||||
return(_YAP_unify(ARG1,t));
|
||||
return(Yap_unify(ARG1,t));
|
||||
}
|
||||
|
||||
static Int
|
||||
p_n_atts(void)
|
||||
{
|
||||
Term t = MkIntegerTerm(NUM_OF_ATTS);
|
||||
return(_YAP_unify(ARG1,t));
|
||||
return(Yap_unify(ARG1,t));
|
||||
}
|
||||
|
||||
static Int
|
||||
p_all_attvars(void)
|
||||
{
|
||||
Term t = _YAP_ReadTimedVar(AttsMutableList);
|
||||
return(_YAP_unify(ARG1,AllAttVars(t)));
|
||||
Term t = Yap_ReadTimedVar(AttsMutableList);
|
||||
return(Yap_unify(ARG1,AllAttVars(t)));
|
||||
}
|
||||
|
||||
static Int
|
||||
@ -625,24 +625,24 @@ p_attvar_bound(void)
|
||||
!IsUnboundVar(((attvar_record *)VarOfTerm(t))->Done));
|
||||
}
|
||||
|
||||
void _YAP_InitAttVarPreds(void)
|
||||
void Yap_InitAttVarPreds(void)
|
||||
{
|
||||
attas[attvars_ext].bind_op = WakeAttVar;
|
||||
attas[attvars_ext].copy_term_op = CopyAttVar;
|
||||
attas[attvars_ext].to_term_op = AttVarToTerm;
|
||||
attas[attvars_ext].term_to_op = TermToAttVar;
|
||||
attas[attvars_ext].mark_op = mark_attvar;
|
||||
_YAP_InitCPred("get_att", 3, p_get_att, SafePredFlag);
|
||||
_YAP_InitCPred("get_all_atts", 2, p_get_all_atts, SafePredFlag);
|
||||
_YAP_InitCPred("free_att", 2, p_free_att, SafePredFlag);
|
||||
_YAP_InitCPred("put_att", 3, p_put_att, 0);
|
||||
_YAP_InitCPred("rm_att", 2, p_rm_att, SafePredFlag);
|
||||
_YAP_InitCPred("inc_n_of_atts", 1, p_inc_atts, SafePredFlag);
|
||||
_YAP_InitCPred("n_of_atts", 1, p_n_atts, SafePredFlag);
|
||||
_YAP_InitCPred("bind_attvar", 1, p_bind_attvar, SafePredFlag);
|
||||
_YAP_InitCPred("all_attvars", 1, p_all_attvars, SafePredFlag);
|
||||
_YAP_InitCPred("$is_att_variable", 1, p_is_attvar, SafePredFlag|TestPredFlag);
|
||||
_YAP_InitCPred("$att_bound", 1, p_attvar_bound, SafePredFlag|TestPredFlag);
|
||||
Yap_InitCPred("get_att", 3, p_get_att, SafePredFlag);
|
||||
Yap_InitCPred("get_all_atts", 2, p_get_all_atts, SafePredFlag);
|
||||
Yap_InitCPred("free_att", 2, p_free_att, SafePredFlag);
|
||||
Yap_InitCPred("put_att", 3, p_put_att, 0);
|
||||
Yap_InitCPred("rm_att", 2, p_rm_att, SafePredFlag);
|
||||
Yap_InitCPred("inc_n_of_atts", 1, p_inc_atts, SafePredFlag);
|
||||
Yap_InitCPred("n_of_atts", 1, p_n_atts, SafePredFlag);
|
||||
Yap_InitCPred("bind_attvar", 1, p_bind_attvar, SafePredFlag);
|
||||
Yap_InitCPred("all_attvars", 1, p_all_attvars, SafePredFlag);
|
||||
Yap_InitCPred("$is_att_variable", 1, p_is_attvar, SafePredFlag|TestPredFlag);
|
||||
Yap_InitCPred("$att_bound", 1, p_attvar_bound, SafePredFlag|TestPredFlag);
|
||||
}
|
||||
|
||||
#endif /* COROUTINING */
|
||||
|
72
C/bb.c
72
C/bb.c
@ -38,10 +38,10 @@ PutBBProp(AtomEntry *ae, SMALLUNSGN mod) /* get BBentry for at; */
|
||||
p = RepBBProp(p0 = p->NextOfPE);
|
||||
}
|
||||
if (p0 == NIL) {
|
||||
p = (BBProp)_YAP_AllocAtomSpace(sizeof(*p));
|
||||
p = (BBProp)Yap_AllocAtomSpace(sizeof(*p));
|
||||
if (p == NULL) {
|
||||
WRITE_UNLOCK(ae->ARWLock);
|
||||
_YAP_Error(SYSTEM_ERROR,ARG1,"could not allocate space in bb_put/2");
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"could not allocate space in bb_put/2");
|
||||
return(NULL);
|
||||
}
|
||||
p->NextOfPE = ae->PropsOfAE;
|
||||
@ -64,7 +64,7 @@ PutIntBBProp(Int key, SMALLUNSGN mod) /* get BBentry for at; */
|
||||
UInt hash_key;
|
||||
|
||||
if (INT_BB_KEYS == NULL) {
|
||||
INT_BB_KEYS = (Prop *)_YAP_AllocCodeSpace(sizeof(Prop)*INT_BB_KEYS_SIZE);
|
||||
INT_BB_KEYS = (Prop *)Yap_AllocCodeSpace(sizeof(Prop)*INT_BB_KEYS_SIZE);
|
||||
if (INT_BB_KEYS != NULL) {
|
||||
UInt i = 0;
|
||||
Prop *pp = INT_BB_KEYS;
|
||||
@ -73,7 +73,7 @@ PutIntBBProp(Int key, SMALLUNSGN mod) /* get BBentry for at; */
|
||||
pp++;
|
||||
}
|
||||
} else {
|
||||
_YAP_Error(SYSTEM_ERROR,ARG1,"could not allocate space in bb_put/2");
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"could not allocate space in bb_put/2");
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
@ -87,10 +87,10 @@ PutIntBBProp(Int key, SMALLUNSGN mod) /* get BBentry for at; */
|
||||
}
|
||||
if (p0 == NIL) {
|
||||
YAPEnterCriticalSection();
|
||||
p = (BBProp)_YAP_AllocAtomSpace(sizeof(*p));
|
||||
p = (BBProp)Yap_AllocAtomSpace(sizeof(*p));
|
||||
if (p == NULL) {
|
||||
YAPLeaveCriticalSection();
|
||||
_YAP_Error(SYSTEM_ERROR,ARG1,"could not allocate space in bb_put/2");
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"could not allocate space in bb_put/2");
|
||||
return(NULL);
|
||||
}
|
||||
p->ModuleOfBB = mod;
|
||||
@ -157,10 +157,10 @@ resize_bb_int_keys(UInt new_size) {
|
||||
YAPLeaveCriticalSection();
|
||||
return(TRUE);
|
||||
}
|
||||
new = (Prop *)_YAP_AllocCodeSpace(sizeof(Prop)*new_size);
|
||||
new = (Prop *)Yap_AllocCodeSpace(sizeof(Prop)*new_size);
|
||||
if (new == NULL) {
|
||||
YAPLeaveCriticalSection();
|
||||
_YAP_Error(SYSTEM_ERROR,ARG1,"could not allocate space");
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"could not allocate space");
|
||||
return(FALSE);
|
||||
}
|
||||
for (i = 0; i < new_size; i++) {
|
||||
@ -179,7 +179,7 @@ resize_bb_int_keys(UInt new_size) {
|
||||
}
|
||||
}
|
||||
}
|
||||
_YAP_FreeCodeSpace((char *)INT_BB_KEYS);
|
||||
Yap_FreeCodeSpace((char *)INT_BB_KEYS);
|
||||
INT_BB_KEYS = new;
|
||||
INT_BB_KEYS_SIZE = new_size;
|
||||
YAPLeaveCriticalSection();
|
||||
@ -193,7 +193,7 @@ AddBBProp(Term t1, char *msg, SMALLUNSGN mod)
|
||||
|
||||
restart:
|
||||
if (IsVarTerm(t1)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t1, msg);
|
||||
Yap_Error(INSTANTIATION_ERROR, t1, msg);
|
||||
return(NULL);
|
||||
} if (IsAtomTerm(t1)) {
|
||||
p = PutBBProp(RepAtom(AtomOfTerm(t1)), mod);
|
||||
@ -203,14 +203,14 @@ AddBBProp(Term t1, char *msg, SMALLUNSGN mod)
|
||||
Term tmod = ArgOfTerm(1, t1);
|
||||
if (!IsVarTerm(tmod) ) {
|
||||
t1 = ArgOfTerm(2, t1);
|
||||
mod = _YAP_LookupModule(tmod);
|
||||
mod = Yap_LookupModule(tmod);
|
||||
goto restart;
|
||||
} else {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t1, msg);
|
||||
Yap_Error(INSTANTIATION_ERROR, t1, msg);
|
||||
return(NULL);
|
||||
}
|
||||
} else {
|
||||
_YAP_Error(TYPE_ERROR_ATOM, t1, msg);
|
||||
Yap_Error(TYPE_ERROR_ATOM, t1, msg);
|
||||
return(NULL);
|
||||
}
|
||||
return(p);
|
||||
@ -223,7 +223,7 @@ FetchBBProp(Term t1, char *msg, SMALLUNSGN mod)
|
||||
|
||||
restart:
|
||||
if (IsVarTerm(t1)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t1, msg);
|
||||
Yap_Error(INSTANTIATION_ERROR, t1, msg);
|
||||
return(NULL);
|
||||
} if (IsAtomTerm(t1)) {
|
||||
p = GetBBProp(RepAtom(AtomOfTerm(t1)), mod);
|
||||
@ -232,15 +232,15 @@ FetchBBProp(Term t1, char *msg, SMALLUNSGN mod)
|
||||
} else if (IsApplTerm(t1) && FunctorOfTerm(t1) == FunctorModule) {
|
||||
Term tmod = ArgOfTerm(1, t1);
|
||||
if (!IsVarTerm(tmod) ) {
|
||||
mod = _YAP_LookupModule(tmod);
|
||||
mod = Yap_LookupModule(tmod);
|
||||
t1 = ArgOfTerm(2, t1);
|
||||
goto restart;
|
||||
} else {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t1, msg);
|
||||
Yap_Error(INSTANTIATION_ERROR, t1, msg);
|
||||
return(NULL);
|
||||
}
|
||||
} else {
|
||||
_YAP_Error(TYPE_ERROR_ATOM, t1, msg);
|
||||
Yap_Error(TYPE_ERROR_ATOM, t1, msg);
|
||||
return(NULL);
|
||||
}
|
||||
return(p);
|
||||
@ -255,9 +255,9 @@ p_bb_put(void)
|
||||
return(FALSE);
|
||||
WRITE_LOCK(p->BBRWLock);
|
||||
if (p->Element != NULL) {
|
||||
_YAP_ReleaseTermFromDB(p->Element);
|
||||
Yap_ReleaseTermFromDB(p->Element);
|
||||
}
|
||||
p->Element = _YAP_StoreTermInDB(2,2);
|
||||
p->Element = Yap_StoreTermInDB(2,2);
|
||||
WRITE_UNLOCK(p->BBRWLock);
|
||||
return(p->Element != NULL);
|
||||
}
|
||||
@ -271,9 +271,9 @@ p_bb_get(void)
|
||||
if (p == NULL || p->Element == NULL)
|
||||
return(FALSE);
|
||||
READ_LOCK(p->BBRWLock);
|
||||
out = _YAP_FetchTermFromDB(p->Element,3);
|
||||
out = Yap_FetchTermFromDB(p->Element,3);
|
||||
READ_UNLOCK(p->BBRWLock);
|
||||
return(_YAP_unify(ARG2,out));
|
||||
return(Yap_unify(ARG2,out));
|
||||
}
|
||||
|
||||
static Int
|
||||
@ -286,12 +286,12 @@ p_bb_delete(void)
|
||||
p = FetchBBProp(t1, "bb_delete/2", CurrentModule);
|
||||
if (p == NULL || p->Element == NULL)
|
||||
return(FALSE);
|
||||
out = _YAP_FetchTermFromDB(p->Element,3);
|
||||
out = Yap_FetchTermFromDB(p->Element,3);
|
||||
WRITE_LOCK(p->BBRWLock);
|
||||
_YAP_ReleaseTermFromDB(p->Element);
|
||||
Yap_ReleaseTermFromDB(p->Element);
|
||||
p->Element = NULL;
|
||||
WRITE_UNLOCK(p->BBRWLock);
|
||||
return(_YAP_unify(ARG2,out));
|
||||
return(Yap_unify(ARG2,out));
|
||||
}
|
||||
|
||||
static Int
|
||||
@ -305,14 +305,14 @@ p_bb_update(void)
|
||||
if (p == NULL || p->Element == NULL)
|
||||
return(FALSE);
|
||||
WRITE_LOCK(p->BBRWLock);
|
||||
out = _YAP_FetchTermFromDB(p->Element,3);
|
||||
if (!_YAP_unify(ARG2,out)) {
|
||||
out = Yap_FetchTermFromDB(p->Element,3);
|
||||
if (!Yap_unify(ARG2,out)) {
|
||||
WRITE_UNLOCK(p->BBRWLock);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
_YAP_ReleaseTermFromDB(p->Element);
|
||||
p->Element = _YAP_StoreTermInDB(3,3);
|
||||
Yap_ReleaseTermFromDB(p->Element);
|
||||
p->Element = Yap_StoreTermInDB(3,3);
|
||||
WRITE_UNLOCK(p->BBRWLock);
|
||||
return(p->Element != NULL);
|
||||
}
|
||||
@ -322,22 +322,22 @@ p_resize_bb_int_keys(void)
|
||||
{
|
||||
Term t1 = Deref(ARG1);
|
||||
if (IsVarTerm(t1)) {
|
||||
return(_YAP_unify(ARG1,MkIntegerTerm((Int)INT_BB_KEYS_SIZE)));
|
||||
return(Yap_unify(ARG1,MkIntegerTerm((Int)INT_BB_KEYS_SIZE)));
|
||||
}
|
||||
if (!IsIntegerTerm(t1)) {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t1, "yap_flag(resize_bb_int_keys,T)");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t1, "yap_flag(resize_bb_int_keys,T)");
|
||||
return(FALSE);
|
||||
}
|
||||
return(resize_bb_int_keys(IntegerOfTerm(t1)));
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_InitBBPreds(void)
|
||||
Yap_InitBBPreds(void)
|
||||
{
|
||||
_YAP_InitCPred("bb_put", 2, p_bb_put, 0);
|
||||
_YAP_InitCPred("bb_get", 2, p_bb_get, 0);
|
||||
_YAP_InitCPred("bb_delete", 2, p_bb_delete, 0);
|
||||
_YAP_InitCPred("bb_update", 3, p_bb_update, 0);
|
||||
_YAP_InitCPred("$resize_bb_int_keys", 1, p_resize_bb_int_keys, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("bb_put", 2, p_bb_put, 0);
|
||||
Yap_InitCPred("bb_get", 2, p_bb_get, 0);
|
||||
Yap_InitCPred("bb_delete", 2, p_bb_delete, 0);
|
||||
Yap_InitCPred("bb_update", 3, p_bb_update, 0);
|
||||
Yap_InitCPred("$resize_bb_int_keys", 1, p_resize_bb_int_keys, SafePredFlag|SyncPredFlag);
|
||||
}
|
||||
|
||||
|
18
C/bignum.c
18
C/bignum.c
@ -35,7 +35,7 @@ static char SccsId[] = "%W% %G%";
|
||||
static CELL *pre_alloc_base = NULL, *alloc_ptr;
|
||||
|
||||
MP_INT *
|
||||
_YAP_PreAllocBigNum(void)
|
||||
Yap_PreAllocBigNum(void)
|
||||
{
|
||||
MP_INT *ret;
|
||||
|
||||
@ -54,14 +54,14 @@ _YAP_PreAllocBigNum(void)
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_CleanBigNum(void)
|
||||
Yap_CleanBigNum(void)
|
||||
{
|
||||
H = pre_alloc_base;
|
||||
pre_alloc_base = NULL;
|
||||
}
|
||||
|
||||
MP_INT *
|
||||
_YAP_InitBigNum(Int in)
|
||||
Yap_InitBigNum(Int in)
|
||||
{
|
||||
MP_INT *ret;
|
||||
|
||||
@ -99,7 +99,7 @@ AllocBigNumSpace(size_t size)
|
||||
alloc_ptr[0] = size;
|
||||
alloc_ptr += size+1;
|
||||
if (alloc_ptr > ASP-1024)
|
||||
_YAP_Error(SYSTEM_ERROR,TermNil,"no space for bignum");
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,"no space for bignum");
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ ReAllocBigNumSpace(void *optr, size_t osize, size_t size)
|
||||
alloc_ptr += (size-osize);
|
||||
((CELL *)optr)[-1] = size;
|
||||
if (alloc_ptr > ASP-1024)
|
||||
_YAP_Error(SYSTEM_ERROR,TermNil,"no space for bignum");
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,"no space for bignum");
|
||||
return(optr);
|
||||
}
|
||||
out = AllocBigNumSpace(size);
|
||||
@ -154,7 +154,7 @@ FreeBigNumSpace(void *optr, size_t size)
|
||||
pre_alloc_base;
|
||||
*/
|
||||
Term
|
||||
_YAP_MkBigIntTerm(MP_INT *big)
|
||||
Yap_MkBigIntTerm(MP_INT *big)
|
||||
{
|
||||
CELL *new = (CELL *)(big+1);
|
||||
Int nlimbs = (big->_mp_alloc)*(sizeof(mp_limb_t)/CellSize);
|
||||
@ -198,7 +198,7 @@ _YAP_MkBigIntTerm(MP_INT *big)
|
||||
}
|
||||
|
||||
MP_INT *
|
||||
_YAP_BigIntOfTerm(Term t)
|
||||
Yap_BigIntOfTerm(Term t)
|
||||
{
|
||||
MP_INT *new = (MP_INT *)(RepAppl(t)+1);
|
||||
|
||||
@ -220,7 +220,7 @@ p_is_bignum(void)
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_InitBigNums(void)
|
||||
Yap_InitBigNums(void)
|
||||
{
|
||||
#ifdef USE_GMP
|
||||
/* YAP style memory allocation */
|
||||
@ -229,5 +229,5 @@ _YAP_InitBigNums(void)
|
||||
ReAllocBigNumSpace,
|
||||
FreeBigNumSpace);
|
||||
#endif
|
||||
_YAP_InitCPred("$bignum", 1, p_is_bignum, SafePredFlag);
|
||||
Yap_InitCPred("$bignum", 1, p_is_bignum, SafePredFlag);
|
||||
}
|
||||
|
142
C/c_interface.c
142
C/c_interface.c
@ -262,7 +262,7 @@ YAP_AtomName(Atom a)
|
||||
X_API Atom
|
||||
YAP_LookupAtom(char *c)
|
||||
{
|
||||
return(_YAP_LookupAtom(c));
|
||||
return(Yap_LookupAtom(c));
|
||||
}
|
||||
|
||||
X_API Atom
|
||||
@ -270,7 +270,7 @@ YAP_FullLookupAtom(char *c)
|
||||
{
|
||||
Atom at;
|
||||
|
||||
at = _YAP_FullLookupAtom(c);
|
||||
at = Yap_FullLookupAtom(c);
|
||||
return(at);
|
||||
}
|
||||
|
||||
@ -304,7 +304,7 @@ YAP_MkNewPairTerm()
|
||||
Term t;
|
||||
BACKUP_H();
|
||||
|
||||
t = _YAP_MkNewPairTerm();
|
||||
t = Yap_MkNewPairTerm();
|
||||
|
||||
RECOVER_H();
|
||||
return(t);
|
||||
@ -328,7 +328,7 @@ YAP_MkApplTerm(Functor f,unsigned long int arity, Term args[])
|
||||
Term t;
|
||||
BACKUP_H();
|
||||
|
||||
t = _YAP_MkApplTerm(f, arity, args);
|
||||
t = Yap_MkApplTerm(f, arity, args);
|
||||
|
||||
RECOVER_H();
|
||||
return(t);
|
||||
@ -340,7 +340,7 @@ YAP_MkNewApplTerm(Functor f,unsigned long int arity)
|
||||
Term t;
|
||||
BACKUP_H();
|
||||
|
||||
t = _YAP_MkNewApplTerm(f, arity);
|
||||
t = Yap_MkNewApplTerm(f, arity);
|
||||
|
||||
RECOVER_H();
|
||||
return(t);
|
||||
@ -364,7 +364,7 @@ YAP_ArgOfTerm(Int n, Term t)
|
||||
X_API Functor
|
||||
YAP_MkFunctor(Atom a, Int n)
|
||||
{
|
||||
return (_YAP_MkFunctor(a, n));
|
||||
return (Yap_MkFunctor(a, n));
|
||||
}
|
||||
|
||||
X_API Atom
|
||||
@ -422,7 +422,7 @@ YAP_Unify(Term t1, Term t2)
|
||||
Int out;
|
||||
BACKUP_MACHINE_REGS();
|
||||
|
||||
out = _YAP_unify(t1, t2);
|
||||
out = Yap_unify(t1, t2);
|
||||
|
||||
RECOVER_MACHINE_REGS();
|
||||
return(out);
|
||||
@ -431,37 +431,37 @@ YAP_Unify(Term t1, Term t2)
|
||||
X_API long
|
||||
YAP_NewSlots(int n)
|
||||
{
|
||||
return _YAP_NewSlots(n);
|
||||
return Yap_NewSlots(n);
|
||||
}
|
||||
|
||||
X_API long
|
||||
YAP_InitSlot(Term t)
|
||||
{
|
||||
return _YAP_InitSlot(t);
|
||||
return Yap_InitSlot(t);
|
||||
}
|
||||
|
||||
X_API void
|
||||
YAP_RecoverSlots(int n)
|
||||
{
|
||||
_YAP_RecoverSlots(n);
|
||||
Yap_RecoverSlots(n);
|
||||
}
|
||||
|
||||
X_API Term
|
||||
YAP_GetFromSlot(long slot)
|
||||
{
|
||||
return _YAP_GetFromSlot(slot);
|
||||
return Yap_GetFromSlot(slot);
|
||||
}
|
||||
|
||||
X_API Term *
|
||||
YAP_AddressFromSlot(long slot)
|
||||
{
|
||||
return _YAP_AddressFromSlot(slot);
|
||||
return Yap_AddressFromSlot(slot);
|
||||
}
|
||||
|
||||
X_API void
|
||||
YAP_PutInSlot(long slot, Term t)
|
||||
{
|
||||
_YAP_PutInSlot(slot, t);
|
||||
Yap_PutInSlot(slot, t);
|
||||
}
|
||||
|
||||
|
||||
@ -573,10 +573,10 @@ YAP_CallProlog(Term t)
|
||||
Term tmod = ArgOfTerm(1,t);
|
||||
if (IsVarTerm(tmod)) return(FALSE);
|
||||
if (!IsAtomTerm(tmod)) return(FALSE);
|
||||
mod = _YAP_LookupModule(tmod);
|
||||
mod = Yap_LookupModule(tmod);
|
||||
t = ArgOfTerm(2,t);
|
||||
}
|
||||
out = _YAP_execute_goal(t, 0, mod);
|
||||
out = Yap_execute_goal(t, 0, mod);
|
||||
RECOVER_MACHINE_REGS();
|
||||
return(out);
|
||||
}
|
||||
@ -587,9 +587,9 @@ YAP_AllocSpaceFromYap(unsigned int size)
|
||||
void *ptr;
|
||||
BACKUP_MACHINE_REGS();
|
||||
|
||||
if ((ptr = _YAP_AllocCodeSpace(size)) == NULL) {
|
||||
if (!_YAP_growheap(FALSE)) {
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, _YAP_ErrorMessage);
|
||||
if ((ptr = Yap_AllocCodeSpace(size)) == NULL) {
|
||||
if (!Yap_growheap(FALSE)) {
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
@ -601,7 +601,7 @@ YAP_AllocSpaceFromYap(unsigned int size)
|
||||
X_API void
|
||||
YAP_FreeSpaceFromYap(void *ptr)
|
||||
{
|
||||
_YAP_FreeCodeSpace(ptr);
|
||||
Yap_FreeCodeSpace(ptr);
|
||||
}
|
||||
|
||||
/* copy a string to a buffer */
|
||||
@ -616,15 +616,15 @@ YAP_StringToBuffer(Term t, char *buf, unsigned int bufsize)
|
||||
|
||||
Head = HeadOfTerm(t);
|
||||
if (IsVarTerm(Head)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,Head,"user defined procedure");
|
||||
Yap_Error(INSTANTIATION_ERROR,Head,"user defined procedure");
|
||||
return(FALSE);
|
||||
} else if (!IsIntTerm(Head)) {
|
||||
_YAP_Error(REPRESENTATION_ERROR_CHARACTER_CODE,Head,"user defined procedure");
|
||||
Yap_Error(REPRESENTATION_ERROR_CHARACTER_CODE,Head,"user defined procedure");
|
||||
return(FALSE);
|
||||
}
|
||||
i = IntOfTerm(Head);
|
||||
if (i < 0 || i > 255) {
|
||||
_YAP_Error(REPRESENTATION_ERROR_CHARACTER_CODE,Head,"user defined procedure");
|
||||
Yap_Error(REPRESENTATION_ERROR_CHARACTER_CODE,Head,"user defined procedure");
|
||||
return(FALSE);
|
||||
}
|
||||
buf[j++] = i;
|
||||
@ -634,10 +634,10 @@ YAP_StringToBuffer(Term t, char *buf, unsigned int bufsize)
|
||||
}
|
||||
t = TailOfTerm(t);
|
||||
if (IsVarTerm(t)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t,"user defined procedure");
|
||||
Yap_Error(INSTANTIATION_ERROR,t,"user defined procedure");
|
||||
return(FALSE);
|
||||
} else if (!IsPairTerm(t) && t != TermNil) {
|
||||
_YAP_Error(TYPE_ERROR_LIST, t, "user defined procedure");
|
||||
Yap_Error(TYPE_ERROR_LIST, t, "user defined procedure");
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
@ -653,7 +653,7 @@ YAP_BufferToString(char *s)
|
||||
Term t;
|
||||
BACKUP_H();
|
||||
|
||||
t = _YAP_StringToList(s);
|
||||
t = Yap_StringToList(s);
|
||||
|
||||
RECOVER_H();
|
||||
return(t);
|
||||
@ -666,7 +666,7 @@ YAP_BufferToAtomList(char *s)
|
||||
Term t;
|
||||
BACKUP_H();
|
||||
|
||||
t = _YAP_StringToListOfAtoms(s);
|
||||
t = Yap_StringToListOfAtoms(s);
|
||||
|
||||
RECOVER_H();
|
||||
return(t);
|
||||
@ -676,7 +676,7 @@ YAP_BufferToAtomList(char *s)
|
||||
X_API void
|
||||
YAP_Error(char *buf)
|
||||
{
|
||||
_YAP_Error(SYSTEM_ERROR,TermNil,buf);
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,buf);
|
||||
}
|
||||
|
||||
static void myputc (int ch)
|
||||
@ -691,7 +691,7 @@ YAP_RunGoal(Term t)
|
||||
yamop *old_CP = CP;
|
||||
BACKUP_MACHINE_REGS();
|
||||
|
||||
out = _YAP_RunTopGoal(t);
|
||||
out = Yap_RunTopGoal(t);
|
||||
if (out) {
|
||||
P = (yamop *)ENV[E_CP];
|
||||
ENV = (CELL *)ENV[E_E];
|
||||
@ -713,10 +713,10 @@ YAP_RestartGoal(void)
|
||||
|
||||
P = (yamop *)FAILCODE;
|
||||
do_putcf = myputc;
|
||||
out = _YAP_exec_absmi(TRUE);
|
||||
out = Yap_exec_absmi(TRUE);
|
||||
if (out == FALSE) {
|
||||
/* cleanup */
|
||||
_YAP_trust_last();
|
||||
Yap_trust_last();
|
||||
}
|
||||
|
||||
RECOVER_MACHINE_REGS();
|
||||
@ -729,7 +729,7 @@ YAP_ContinueGoal(void)
|
||||
int out;
|
||||
BACKUP_MACHINE_REGS();
|
||||
|
||||
out = _YAP_exec_absmi(TRUE);
|
||||
out = Yap_exec_absmi(TRUE);
|
||||
|
||||
RECOVER_MACHINE_REGS();
|
||||
return(out);
|
||||
@ -767,9 +767,9 @@ YAP_InitConsult(int mode, char *filename)
|
||||
BACKUP_MACHINE_REGS();
|
||||
|
||||
if (mode == YAP_CONSULT_MODE)
|
||||
_YAP_init_consult(FALSE, filename);
|
||||
Yap_init_consult(FALSE, filename);
|
||||
else
|
||||
_YAP_init_consult(TRUE, filename);
|
||||
Yap_init_consult(TRUE, filename);
|
||||
|
||||
RECOVER_MACHINE_REGS();
|
||||
}
|
||||
@ -779,7 +779,7 @@ YAP_EndConsult(void)
|
||||
{
|
||||
BACKUP_MACHINE_REGS();
|
||||
|
||||
_YAP_end_consult();
|
||||
Yap_end_consult();
|
||||
|
||||
RECOVER_MACHINE_REGS();
|
||||
}
|
||||
@ -794,14 +794,14 @@ YAP_Read(int (*mygetc)(void))
|
||||
|
||||
do_getf = mygetc;
|
||||
old_TR = TR;
|
||||
_YAP_tokptr = _YAP_toktide = _YAP_tokenizer(do_yap_getc, do_yap_getc);
|
||||
if (_YAP_ErrorMessage)
|
||||
Yap_tokptr = Yap_toktide = Yap_tokenizer(do_yap_getc, do_yap_getc);
|
||||
if (Yap_ErrorMessage)
|
||||
{
|
||||
TR = old_TR;
|
||||
save_machine_regs();
|
||||
return(0);
|
||||
}
|
||||
t = _YAP_Parse();
|
||||
t = Yap_Parse();
|
||||
TR = old_TR;
|
||||
|
||||
RECOVER_MACHINE_REGS();
|
||||
@ -814,7 +814,7 @@ YAP_Write(Term t, void (*myputc)(int), int flags)
|
||||
BACKUP_MACHINE_REGS();
|
||||
|
||||
do_putcf = myputc;
|
||||
_YAP_plwrite (t, do_yap_putc, flags);
|
||||
Yap_plwrite (t, do_yap_putc, flags);
|
||||
|
||||
RECOVER_MACHINE_REGS();
|
||||
}
|
||||
@ -822,22 +822,22 @@ YAP_Write(Term t, void (*myputc)(int), int flags)
|
||||
X_API char *
|
||||
YAP_CompileClause(Term t)
|
||||
{
|
||||
char *_YAP_ErrorMessage;
|
||||
char *Yap_ErrorMessage;
|
||||
CODEADDR codeaddr;
|
||||
int mod = CurrentModule;
|
||||
|
||||
BACKUP_MACHINE_REGS();
|
||||
|
||||
_YAP_ErrorMessage = NULL;
|
||||
Yap_ErrorMessage = NULL;
|
||||
ARG1 = t;
|
||||
codeaddr = _YAP_cclause (t,0, mod);
|
||||
codeaddr = Yap_cclause (t,0, mod);
|
||||
if (codeaddr != NULL) {
|
||||
t = Deref(ARG1); /* just in case there was an heap overflow */
|
||||
_YAP_addclause (t, codeaddr, TRUE, mod);
|
||||
Yap_addclause (t, codeaddr, TRUE, mod);
|
||||
}
|
||||
|
||||
RECOVER_MACHINE_REGS();
|
||||
return(_YAP_ErrorMessage);
|
||||
return(Yap_ErrorMessage);
|
||||
}
|
||||
|
||||
/* this routine is supposed to be called from an external program
|
||||
@ -850,11 +850,11 @@ YAP_Init(YAP_init_args *yap_init)
|
||||
CELL Trail = 0, Stack = 0, Heap = 0;
|
||||
BACKUP_MACHINE_REGS();
|
||||
|
||||
_YAP_argv = yap_init->Argv;
|
||||
_YAP_argc = yap_init->Argc;
|
||||
Yap_argv = yap_init->Argv;
|
||||
Yap_argc = yap_init->Argc;
|
||||
if (yap_init->SavedState != NULL ||
|
||||
yap_init->YapPrologBootFile == NULL) {
|
||||
if (_YAP_SavedInfo (yap_init->SavedState, yap_init->YapLibDir, &Trail, &Stack, &Heap) != 1) {
|
||||
if (Yap_SavedInfo (yap_init->SavedState, yap_init->YapLibDir, &Trail, &Stack, &Heap) != 1) {
|
||||
return(YAP_BOOT_FROM_SAVED_ERROR);
|
||||
}
|
||||
}
|
||||
@ -877,18 +877,18 @@ YAP_Init(YAP_init_args *yap_init)
|
||||
Heap = yap_init->HeapSize;
|
||||
}
|
||||
|
||||
_YAP_InitStacks (Heap, Stack, Trail,
|
||||
Yap_InitStacks (Heap, Stack, Trail,
|
||||
yap_init->NumberWorkers,
|
||||
yap_init->SchedulerLoop,
|
||||
yap_init->DelayedReleaseLoad
|
||||
);
|
||||
_YAP_InitYaamRegs();
|
||||
Yap_InitYaamRegs();
|
||||
|
||||
#if HAVE_MPI
|
||||
_YAP_InitMPI ();
|
||||
Yap_InitMPI ();
|
||||
#endif
|
||||
#if HAVE_MPE
|
||||
_YAP_InitMPE ();
|
||||
Yap_InitMPE ();
|
||||
#endif
|
||||
|
||||
if (yap_init->YapPrologRCFile != NULL) {
|
||||
@ -900,7 +900,7 @@ YAP_Init(YAP_init_args *yap_init)
|
||||
}
|
||||
if (yap_init->SavedState != NULL ||
|
||||
yap_init->YapPrologBootFile == NULL) {
|
||||
restore_result = _YAP_Restore(yap_init->SavedState, yap_init->YapLibDir);
|
||||
restore_result = Yap_Restore(yap_init->SavedState, yap_init->YapLibDir);
|
||||
} else {
|
||||
restore_result = FAIL_RESTORE;
|
||||
}
|
||||
@ -918,12 +918,12 @@ YAP_Init(YAP_init_args *yap_init)
|
||||
In the SBA we cannot just happily inherit registers
|
||||
from the other workers
|
||||
*/
|
||||
_YAP_InitYaamRegs();
|
||||
Yap_InitYaamRegs();
|
||||
#endif
|
||||
/* slaves, waiting for work */
|
||||
CurrentModule = 1;
|
||||
P = GETWORK_FIRST_TIME;
|
||||
_YAP_exec_absmi(FALSE);
|
||||
Yap_exec_absmi(FALSE);
|
||||
abort_optyap("abstract machine unexpected exit");
|
||||
}
|
||||
#endif /* YAPOR */
|
||||
@ -931,7 +931,7 @@ YAP_Init(YAP_init_args *yap_init)
|
||||
RECOVER_MACHINE_REGS();
|
||||
|
||||
if (yap_init->YapPrologRCFile != NULL) {
|
||||
_YAP_PutValue(_YAP_FullLookupAtom("$consult_on_boot"), MkAtomTerm(_YAP_LookupAtom(yap_init->YapPrologRCFile)));
|
||||
Yap_PutValue(Yap_FullLookupAtom("$consult_on_boot"), MkAtomTerm(Yap_LookupAtom(yap_init->YapPrologRCFile)));
|
||||
/*
|
||||
This must be done again after restore, as yap_flags
|
||||
has been overwritten ....
|
||||
@ -977,13 +977,13 @@ YAP_FastInit(char saved_state[])
|
||||
X_API void
|
||||
YAP_PutValue(Atom at, Term t)
|
||||
{
|
||||
_YAP_PutValue(at, t);
|
||||
Yap_PutValue(at, t);
|
||||
}
|
||||
|
||||
X_API Term
|
||||
YAP_GetValue(Atom at)
|
||||
{
|
||||
return(_YAP_GetValue(at));
|
||||
return(Yap_GetValue(at));
|
||||
}
|
||||
|
||||
X_API int
|
||||
@ -996,11 +996,11 @@ YAP_Reset(void)
|
||||
while (B->cp_b != NULL)
|
||||
B = B->cp_b;
|
||||
P = (yamop *)FAILCODE;
|
||||
if (_YAP_exec_absmi(0) != 0)
|
||||
if (Yap_exec_absmi(0) != 0)
|
||||
return(FALSE);
|
||||
}
|
||||
/* reinitialise the engine */
|
||||
_YAP_InitYaamRegs();
|
||||
Yap_InitYaamRegs();
|
||||
|
||||
RECOVER_MACHINE_REGS();
|
||||
return(TRUE);
|
||||
@ -1009,14 +1009,14 @@ YAP_Reset(void)
|
||||
X_API void
|
||||
YAP_Exit(int retval)
|
||||
{
|
||||
_YAP_exit(retval);
|
||||
Yap_exit(retval);
|
||||
}
|
||||
|
||||
X_API void
|
||||
YAP_InitSocks(char *host, long port)
|
||||
{
|
||||
#if USE_SOCKET
|
||||
_YAP_init_socks(host, port);
|
||||
Yap_init_socks(host, port);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1031,7 +1031,7 @@ YAP_SetOutputMessage(void)
|
||||
X_API int
|
||||
YAP_StreamToFileNo(Term t)
|
||||
{
|
||||
return(_YAP_StreamToFileNo(t));
|
||||
return(Yap_StreamToFileNo(t));
|
||||
}
|
||||
|
||||
X_API void
|
||||
@ -1039,7 +1039,7 @@ YAP_CloseAllOpenStreams(void)
|
||||
{
|
||||
BACKUP_H();
|
||||
|
||||
_YAP_CloseStreams(FALSE);
|
||||
Yap_CloseStreams(FALSE);
|
||||
|
||||
RECOVER_H();
|
||||
}
|
||||
@ -1051,7 +1051,7 @@ YAP_OpenStream(void *fh, char *name, Term nm, int flags)
|
||||
|
||||
BACKUP_H();
|
||||
|
||||
retv = _YAP_OpenStream((FILE *)fh, name, nm, flags);
|
||||
retv = Yap_OpenStream((FILE *)fh, name, nm, flags);
|
||||
|
||||
RECOVER_H();
|
||||
return retv;
|
||||
@ -1061,14 +1061,14 @@ X_API void
|
||||
YAP_Throw(Term t)
|
||||
{
|
||||
BACKUP_MACHINE_REGS();
|
||||
_YAP_JumpToEnv(t);
|
||||
Yap_JumpToEnv(t);
|
||||
RECOVER_MACHINE_REGS();
|
||||
}
|
||||
|
||||
X_API int
|
||||
YAP_LookupModule(Term t)
|
||||
{
|
||||
return(_YAP_LookupModule(t));
|
||||
return(Yap_LookupModule(t));
|
||||
}
|
||||
|
||||
X_API Term
|
||||
@ -1080,7 +1080,7 @@ YAP_ModuleName(int i)
|
||||
X_API void
|
||||
YAP_Halt(int i)
|
||||
{
|
||||
_YAP_exit(i);
|
||||
Yap_exit(i);
|
||||
}
|
||||
|
||||
X_API CELL *
|
||||
@ -1095,7 +1095,7 @@ YAP_Predicate(Atom a, unsigned long int arity, int m)
|
||||
if (arity == 0) {
|
||||
return((void *)RepPredProp(PredPropByAtom(a,m)));
|
||||
} else {
|
||||
Functor f = _YAP_MkFunctor(a, arity);
|
||||
Functor f = Yap_MkFunctor(a, arity);
|
||||
return((void *)RepPredProp(PredPropByFunc(f,m)));
|
||||
}
|
||||
}
|
||||
@ -1117,14 +1117,14 @@ YAP_PredicateInfo(void *p, Atom* a, unsigned long int* arity, int* m)
|
||||
X_API void
|
||||
YAP_UserCPredicate(char *name, CPredicate def, unsigned long int arity)
|
||||
{
|
||||
_YAP_InitCPred(name, arity, def, UserCPredFlag);
|
||||
Yap_InitCPred(name, arity, def, UserCPredFlag);
|
||||
}
|
||||
|
||||
X_API void
|
||||
YAP_UserBackCPredicate(char *name, CPredicate init, CPredicate cont,
|
||||
unsigned long int arity, unsigned int extra)
|
||||
{
|
||||
_YAP_InitCPredBack(name, arity, extra, init, cont, UserCPredFlag);
|
||||
Yap_InitCPredBack(name, arity, extra, init, cont, UserCPredFlag);
|
||||
}
|
||||
|
||||
X_API void
|
||||
@ -1135,9 +1135,9 @@ YAP_UserCPredicateWithArgs(char *a, CPredicate f, unsigned long int arity, int m
|
||||
CurrentModule = mod;
|
||||
YAP_UserCPredicate(a,f,arity);
|
||||
if (arity == 0) {
|
||||
pe = RepPredProp(PredPropByAtom(_YAP_LookupAtom(a),mod));
|
||||
pe = RepPredProp(PredPropByAtom(Yap_LookupAtom(a),mod));
|
||||
} else {
|
||||
Functor f = _YAP_MkFunctor(_YAP_LookupAtom(a), arity);
|
||||
Functor f = Yap_MkFunctor(Yap_LookupAtom(a), arity);
|
||||
pe = RepPredProp(PredPropByFunc(f,mod));
|
||||
}
|
||||
pe->PredFlags |= CArgsPredFlag;
|
||||
|
148
C/cmppreds.c
148
C/cmppreds.c
@ -98,7 +98,7 @@ static int compare_complex(register CELL *pt0, register CELL *pt0_end, register
|
||||
out = IntOfTerm(d0) - LongIntOfTerm(d1);
|
||||
#ifdef USE_GMP
|
||||
} else if (IsBigIntTerm(d1)) {
|
||||
out = -mpz_cmp_si(_YAP_BigIntOfTerm(d1), IntOfTerm(d0));
|
||||
out = -mpz_cmp_si(Yap_BigIntOfTerm(d1), IntOfTerm(d0));
|
||||
#endif
|
||||
} else if (IsRefTerm(d1))
|
||||
out = 1 ;
|
||||
@ -124,7 +124,7 @@ static int compare_complex(register CELL *pt0, register CELL *pt0_end, register
|
||||
out = LongIntOfTerm(d0) - LongIntOfTerm(d1);
|
||||
#ifdef USE_GMP
|
||||
} else if (IsBigIntTerm(d1)) {
|
||||
out = -mpz_cmp_si(_YAP_BigIntOfTerm(d1), LongIntOfTerm(d0));
|
||||
out = -mpz_cmp_si(Yap_BigIntOfTerm(d1), LongIntOfTerm(d0));
|
||||
#endif
|
||||
} else if (IsRefTerm(d1)) {
|
||||
out = 1 ;
|
||||
@ -137,13 +137,13 @@ static int compare_complex(register CELL *pt0, register CELL *pt0_end, register
|
||||
#ifdef USE_GMP
|
||||
else if (IsBigIntTerm(d0)) {
|
||||
if (IsIntTerm(d1))
|
||||
out = mpz_cmp_si(_YAP_BigIntOfTerm(d0), IntOfTerm(d1));
|
||||
out = mpz_cmp_si(Yap_BigIntOfTerm(d0), IntOfTerm(d1));
|
||||
else if (IsFloatTerm(d1)) {
|
||||
out = 1;
|
||||
} else if (IsLongIntTerm(d1))
|
||||
out = mpz_cmp_si(_YAP_BigIntOfTerm(d0), LongIntOfTerm(d1));
|
||||
out = mpz_cmp_si(Yap_BigIntOfTerm(d0), LongIntOfTerm(d1));
|
||||
else if (IsBigIntTerm(d1))
|
||||
out = mpz_cmp(_YAP_BigIntOfTerm(d0), _YAP_BigIntOfTerm(d1));
|
||||
out = mpz_cmp(Yap_BigIntOfTerm(d0), Yap_BigIntOfTerm(d1));
|
||||
else if (IsRefTerm(d1))
|
||||
out = 1 ;
|
||||
else out = -1;
|
||||
@ -308,7 +308,7 @@ compare(register Term t1,register Term t2) /* compare terms t1 and t2 */
|
||||
return(IntOfTerm(t1) - LongIntOfTerm(t2));
|
||||
#ifdef USE_GMP
|
||||
if (IsBigIntTerm(t2))
|
||||
return(-mpz_cmp_si(_YAP_BigIntOfTerm(t2),IntOfTerm(t1)));
|
||||
return(-mpz_cmp_si(Yap_BigIntOfTerm(t2),IntOfTerm(t1)));
|
||||
#endif
|
||||
if (IsRefTerm(t2))
|
||||
return (1);
|
||||
@ -331,7 +331,7 @@ compare(register Term t1,register Term t2) /* compare terms t1 and t2 */
|
||||
return (LongIntOfTerm(t1) - LongIntOfTerm(t2));
|
||||
#ifdef USE_GMP
|
||||
if (IsBigIntTerm(t2))
|
||||
return(-mpz_cmp_si(_YAP_BigIntOfTerm(t2), LongIntOfTerm(t1)));
|
||||
return(-mpz_cmp_si(Yap_BigIntOfTerm(t2), LongIntOfTerm(t1)));
|
||||
#endif
|
||||
if (IsRefTerm(t2))
|
||||
return (1);
|
||||
@ -340,14 +340,14 @@ compare(register Term t1,register Term t2) /* compare terms t1 and t2 */
|
||||
#ifdef USE_GMP
|
||||
if (IsBigIntTerm(t1)) {
|
||||
if (IsIntTerm(t2))
|
||||
return(mpz_cmp_si(_YAP_BigIntOfTerm(t1), IntOfTerm(t2)));
|
||||
return(mpz_cmp_si(Yap_BigIntOfTerm(t1), IntOfTerm(t2)));
|
||||
if (IsFloatTerm(t2)) {
|
||||
return(1);
|
||||
}
|
||||
if (IsLongIntTerm(t2))
|
||||
return(mpz_cmp_si(_YAP_BigIntOfTerm(t1), LongIntOfTerm(t2)));
|
||||
return(mpz_cmp_si(Yap_BigIntOfTerm(t1), LongIntOfTerm(t2)));
|
||||
if (IsBigIntTerm(t2))
|
||||
return(mpz_cmp(_YAP_BigIntOfTerm(t1), _YAP_BigIntOfTerm(t2)));
|
||||
return(mpz_cmp(Yap_BigIntOfTerm(t1), Yap_BigIntOfTerm(t2)));
|
||||
if (IsRefTerm(t2))
|
||||
return(1);
|
||||
return(-1);
|
||||
@ -400,7 +400,7 @@ compare(register Term t1,register Term t2) /* compare terms t1 and t2 */
|
||||
}
|
||||
}
|
||||
|
||||
int _YAP_compare_terms(register CELL d0, register CELL d1)
|
||||
int Yap_compare_terms(register CELL d0, register CELL d1)
|
||||
{
|
||||
return (compare(d0,d1));
|
||||
}
|
||||
@ -416,29 +416,29 @@ p_compare(void)
|
||||
p = AtomGT;
|
||||
else
|
||||
p = AtomEQ;
|
||||
return (_YAP_unify_constant(ARG1, MkAtomTerm(p)));
|
||||
return (Yap_unify_constant(ARG1, MkAtomTerm(p)));
|
||||
}
|
||||
|
||||
inline static int
|
||||
int_cmp(Int dif)
|
||||
{
|
||||
if (dif < 0)
|
||||
return(_YAP_unify_constant(ARG1,MkAtomTerm(AtomLT)));
|
||||
return(Yap_unify_constant(ARG1,MkAtomTerm(AtomLT)));
|
||||
else if (dif > 0)
|
||||
return(_YAP_unify_constant(ARG1,MkAtomTerm(AtomGT)));
|
||||
return(Yap_unify_constant(ARG1,MkAtomTerm(AtomGT)));
|
||||
else
|
||||
return(_YAP_unify_constant(ARG1,MkAtomTerm(AtomEQ)));
|
||||
return(Yap_unify_constant(ARG1,MkAtomTerm(AtomEQ)));
|
||||
}
|
||||
|
||||
inline static int
|
||||
flt_cmp(Float dif)
|
||||
{
|
||||
if (dif < 0.0)
|
||||
return(_YAP_unify_constant(ARG1,MkAtomTerm(AtomLT)));
|
||||
return(Yap_unify_constant(ARG1,MkAtomTerm(AtomLT)));
|
||||
else if (dif > 0.0)
|
||||
return(_YAP_unify_constant(ARG1,MkAtomTerm(AtomGT)));
|
||||
return(Yap_unify_constant(ARG1,MkAtomTerm(AtomGT)));
|
||||
else
|
||||
return(_YAP_unify_constant(ARG1,MkAtomTerm(AtomEQ)));
|
||||
return(Yap_unify_constant(ARG1,MkAtomTerm(AtomEQ)));
|
||||
}
|
||||
|
||||
|
||||
@ -451,11 +451,11 @@ p_acomp(void)
|
||||
union arith_ret v1;
|
||||
|
||||
if (IsVarTerm(t1)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t1, "=:=/2");
|
||||
Yap_Error(INSTANTIATION_ERROR, t1, "=:=/2");
|
||||
return(FALSE);
|
||||
}
|
||||
if (IsVarTerm(t2)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t2, "=:=/2");
|
||||
Yap_Error(INSTANTIATION_ERROR, t2, "=:=/2");
|
||||
return(FALSE);
|
||||
}
|
||||
if (IsIntegerTerm(t1) && IsIntegerTerm(t2)) {
|
||||
@ -463,12 +463,12 @@ p_acomp(void)
|
||||
} if (IsFloatTerm(t1) && IsFloatTerm(t2)) {
|
||||
return(flt_cmp(FloatOfTerm(t1)-FloatOfTerm(t2)));
|
||||
}
|
||||
bt1 = _YAP_Eval(t1, &v1);
|
||||
bt1 = Yap_Eval(t1, &v1);
|
||||
switch (bt1) {
|
||||
case long_int_e:
|
||||
{
|
||||
union arith_ret v2;
|
||||
blob_type bt2 = _YAP_Eval(t2, &v2);
|
||||
blob_type bt2 = Yap_Eval(t2, &v2);
|
||||
|
||||
switch (bt2) {
|
||||
case long_int_e:
|
||||
@ -486,7 +486,7 @@ p_acomp(void)
|
||||
case double_e:
|
||||
{
|
||||
union arith_ret v2;
|
||||
blob_type bt2 = _YAP_Eval(t2, &v2);
|
||||
blob_type bt2 = Yap_Eval(t2, &v2);
|
||||
|
||||
switch (bt2) {
|
||||
case long_int_e:
|
||||
@ -505,7 +505,7 @@ p_acomp(void)
|
||||
case big_int_e:
|
||||
{
|
||||
union arith_ret v2;
|
||||
blob_type bt2 = _YAP_Eval(t2, &v2);
|
||||
blob_type bt2 = Yap_Eval(t2, &v2);
|
||||
|
||||
switch (bt2) {
|
||||
case long_int_e:
|
||||
@ -531,23 +531,23 @@ a_eq(Term t1, Term t2)
|
||||
union arith_ret v1;
|
||||
|
||||
if (IsVarTerm(t1)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t1, "=:=/2");
|
||||
Yap_Error(INSTANTIATION_ERROR, t1, "=:=/2");
|
||||
return(FALSE);
|
||||
}
|
||||
if (IsVarTerm(t2)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t2, "=:=/2");
|
||||
Yap_Error(INSTANTIATION_ERROR, t2, "=:=/2");
|
||||
return(FALSE);
|
||||
}
|
||||
if (IsIntegerTerm(t1) && IsIntegerTerm(t2))
|
||||
return (IntegerOfTerm(t1) == IntegerOfTerm(t2));
|
||||
if (IsFloatTerm(t1) && IsFloatTerm(t2))
|
||||
return (FloatOfTerm(t1) == FloatOfTerm(t2));
|
||||
bt1 = _YAP_Eval(t1, &v1);
|
||||
bt1 = Yap_Eval(t1, &v1);
|
||||
switch (bt1) {
|
||||
case long_int_e:
|
||||
{
|
||||
union arith_ret v2;
|
||||
blob_type bt2 = _YAP_Eval(t2, &v2);
|
||||
blob_type bt2 = Yap_Eval(t2, &v2);
|
||||
|
||||
switch (bt2) {
|
||||
case long_int_e:
|
||||
@ -565,7 +565,7 @@ a_eq(Term t1, Term t2)
|
||||
case double_e:
|
||||
{
|
||||
union arith_ret v2;
|
||||
blob_type bt2 = _YAP_Eval(t2, &v2);
|
||||
blob_type bt2 = Yap_Eval(t2, &v2);
|
||||
|
||||
switch (bt2) {
|
||||
case long_int_e:
|
||||
@ -584,7 +584,7 @@ a_eq(Term t1, Term t2)
|
||||
case big_int_e:
|
||||
{
|
||||
union arith_ret v2;
|
||||
blob_type bt2 = _YAP_Eval(t2, &v2);
|
||||
blob_type bt2 = Yap_Eval(t2, &v2);
|
||||
|
||||
switch (bt2) {
|
||||
case long_int_e:
|
||||
@ -616,23 +616,23 @@ a_dif(Term t1, Term t2)
|
||||
union arith_ret v1;
|
||||
|
||||
if (IsVarTerm(t1)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t1, "=\\=/2");
|
||||
Yap_Error(INSTANTIATION_ERROR, t1, "=\\=/2");
|
||||
return(FALSE);
|
||||
}
|
||||
if (IsVarTerm(t2)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t2, "=\\=/2");
|
||||
Yap_Error(INSTANTIATION_ERROR, t2, "=\\=/2");
|
||||
return(FALSE);
|
||||
}
|
||||
if (IsIntegerTerm(t1) && IsIntegerTerm(t2))
|
||||
return (IntegerOfTerm(t1) != IntegerOfTerm(t2));
|
||||
if (IsFloatTerm(t1) && IsFloatTerm(t2))
|
||||
return (FloatOfTerm(t1) != FloatOfTerm(t2));
|
||||
bt1 = _YAP_Eval(t1, &v1);
|
||||
bt1 = Yap_Eval(t1, &v1);
|
||||
switch (bt1) {
|
||||
case long_int_e:
|
||||
{
|
||||
union arith_ret v2;
|
||||
blob_type bt2 = _YAP_Eval(t2, &v2);
|
||||
blob_type bt2 = Yap_Eval(t2, &v2);
|
||||
|
||||
switch (bt2) {
|
||||
case long_int_e:
|
||||
@ -650,7 +650,7 @@ a_dif(Term t1, Term t2)
|
||||
case double_e:
|
||||
{
|
||||
union arith_ret v2;
|
||||
blob_type bt2 = _YAP_Eval(t2, &v2);
|
||||
blob_type bt2 = Yap_Eval(t2, &v2);
|
||||
|
||||
switch (bt2) {
|
||||
case long_int_e:
|
||||
@ -669,7 +669,7 @@ a_dif(Term t1, Term t2)
|
||||
case big_int_e:
|
||||
{
|
||||
union arith_ret v2;
|
||||
blob_type bt2 = _YAP_Eval(t2, &v2);
|
||||
blob_type bt2 = Yap_Eval(t2, &v2);
|
||||
|
||||
switch (bt2) {
|
||||
case long_int_e:
|
||||
@ -701,23 +701,23 @@ a_gt(Term t1, Term t2)
|
||||
union arith_ret v1;
|
||||
|
||||
if (IsVarTerm(t1)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t1, ">/2");
|
||||
Yap_Error(INSTANTIATION_ERROR, t1, ">/2");
|
||||
return(FALSE);
|
||||
}
|
||||
if (IsVarTerm(t2)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t2, ">/2");
|
||||
Yap_Error(INSTANTIATION_ERROR, t2, ">/2");
|
||||
return(FALSE);
|
||||
}
|
||||
if (IsIntegerTerm(t1) && IsIntegerTerm(t2))
|
||||
return (IntegerOfTerm(t1) > IntegerOfTerm(t2));
|
||||
if (IsFloatTerm(t1) && IsFloatTerm(t2))
|
||||
return (FloatOfTerm(t1) > FloatOfTerm(t2));
|
||||
bt1 = _YAP_Eval(t1, &v1);
|
||||
bt1 = Yap_Eval(t1, &v1);
|
||||
switch (bt1) {
|
||||
case long_int_e:
|
||||
{
|
||||
union arith_ret v2;
|
||||
blob_type bt2 = _YAP_Eval(t2, &v2);
|
||||
blob_type bt2 = Yap_Eval(t2, &v2);
|
||||
|
||||
switch (bt2) {
|
||||
case long_int_e:
|
||||
@ -735,7 +735,7 @@ a_gt(Term t1, Term t2)
|
||||
case double_e:
|
||||
{
|
||||
union arith_ret v2;
|
||||
blob_type bt2 = _YAP_Eval(t2, &v2);
|
||||
blob_type bt2 = Yap_Eval(t2, &v2);
|
||||
|
||||
switch (bt2) {
|
||||
case long_int_e:
|
||||
@ -754,7 +754,7 @@ a_gt(Term t1, Term t2)
|
||||
case big_int_e:
|
||||
{
|
||||
union arith_ret v2;
|
||||
blob_type bt2 = _YAP_Eval(t2, &v2);
|
||||
blob_type bt2 = Yap_Eval(t2, &v2);
|
||||
|
||||
switch (bt2) {
|
||||
case long_int_e:
|
||||
@ -786,23 +786,23 @@ a_ge(Term t1, Term t2)
|
||||
union arith_ret v1;
|
||||
|
||||
if (IsVarTerm(t1)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t1, ">=/2");
|
||||
Yap_Error(INSTANTIATION_ERROR, t1, ">=/2");
|
||||
return(FALSE);
|
||||
}
|
||||
if (IsVarTerm(t2)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t1, ">=/2");
|
||||
Yap_Error(INSTANTIATION_ERROR, t1, ">=/2");
|
||||
return(FALSE);
|
||||
}
|
||||
if (IsIntegerTerm(t1) && IsIntegerTerm(t2))
|
||||
return (IntegerOfTerm(t1) >= IntegerOfTerm(t2));
|
||||
if (IsFloatTerm(t1) && IsFloatTerm(t2))
|
||||
return (FloatOfTerm(t1) >= FloatOfTerm(t2));
|
||||
bt1 = _YAP_Eval(t1, &v1);
|
||||
bt1 = Yap_Eval(t1, &v1);
|
||||
switch (bt1) {
|
||||
case long_int_e:
|
||||
{
|
||||
union arith_ret v2;
|
||||
blob_type bt2 = _YAP_Eval(t2, &v2);
|
||||
blob_type bt2 = Yap_Eval(t2, &v2);
|
||||
|
||||
switch (bt2) {
|
||||
case long_int_e:
|
||||
@ -820,7 +820,7 @@ a_ge(Term t1, Term t2)
|
||||
case double_e:
|
||||
{
|
||||
union arith_ret v2;
|
||||
blob_type bt2 = _YAP_Eval(t2, &v2);
|
||||
blob_type bt2 = Yap_Eval(t2, &v2);
|
||||
|
||||
switch (bt2) {
|
||||
case long_int_e:
|
||||
@ -839,7 +839,7 @@ a_ge(Term t1, Term t2)
|
||||
case big_int_e:
|
||||
{
|
||||
union arith_ret v2;
|
||||
blob_type bt2 = _YAP_Eval(t2, &v2);
|
||||
blob_type bt2 = Yap_Eval(t2, &v2);
|
||||
|
||||
switch (bt2) {
|
||||
case long_int_e:
|
||||
@ -871,23 +871,23 @@ a_lt(Term t1, Term t2)
|
||||
union arith_ret v1;
|
||||
|
||||
if (IsVarTerm(t1)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t1, "</2");
|
||||
Yap_Error(INSTANTIATION_ERROR, t1, "</2");
|
||||
return(FALSE);
|
||||
}
|
||||
if (IsVarTerm(t2)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t2, "</2");
|
||||
Yap_Error(INSTANTIATION_ERROR, t2, "</2");
|
||||
return(FALSE);
|
||||
}
|
||||
if (IsIntegerTerm(t1) && IsIntegerTerm(t2))
|
||||
return (IntegerOfTerm(t1) < IntegerOfTerm(t2));
|
||||
if (IsFloatTerm(t1) && IsFloatTerm(t2))
|
||||
return (FloatOfTerm(t1) < FloatOfTerm(t2));
|
||||
bt1 = _YAP_Eval(t1, &v1);
|
||||
bt1 = Yap_Eval(t1, &v1);
|
||||
switch (bt1) {
|
||||
case long_int_e:
|
||||
{
|
||||
union arith_ret v2;
|
||||
blob_type bt2 = _YAP_Eval(t2, &v2);
|
||||
blob_type bt2 = Yap_Eval(t2, &v2);
|
||||
|
||||
switch (bt2) {
|
||||
case long_int_e:
|
||||
@ -905,7 +905,7 @@ a_lt(Term t1, Term t2)
|
||||
case double_e:
|
||||
{
|
||||
union arith_ret v2;
|
||||
blob_type bt2 = _YAP_Eval(t2, &v2);
|
||||
blob_type bt2 = Yap_Eval(t2, &v2);
|
||||
|
||||
switch (bt2) {
|
||||
case long_int_e:
|
||||
@ -924,7 +924,7 @@ a_lt(Term t1, Term t2)
|
||||
case big_int_e:
|
||||
{
|
||||
union arith_ret v2;
|
||||
blob_type bt2 = _YAP_Eval(t2, &v2);
|
||||
blob_type bt2 = Yap_Eval(t2, &v2);
|
||||
|
||||
switch (bt2) {
|
||||
case long_int_e:
|
||||
@ -956,23 +956,23 @@ a_le(Term t1, Term t2)
|
||||
union arith_ret v1;
|
||||
|
||||
if (IsVarTerm(t1)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t1, "=</2");
|
||||
Yap_Error(INSTANTIATION_ERROR, t1, "=</2");
|
||||
return(FALSE);
|
||||
}
|
||||
if (IsVarTerm(t2)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t2, "=</2");
|
||||
Yap_Error(INSTANTIATION_ERROR, t2, "=</2");
|
||||
return(FALSE);
|
||||
}
|
||||
if (IsIntegerTerm(t1) && IsIntegerTerm(t2))
|
||||
return (IntegerOfTerm(t1) <= IntegerOfTerm(t2));
|
||||
if (IsFloatTerm(t1) && IsFloatTerm(t2))
|
||||
return (FloatOfTerm(t1) <= FloatOfTerm(t2));
|
||||
bt1 = _YAP_Eval(t1, &v1);
|
||||
bt1 = Yap_Eval(t1, &v1);
|
||||
switch (bt1) {
|
||||
case long_int_e:
|
||||
{
|
||||
union arith_ret v2;
|
||||
blob_type bt2 = _YAP_Eval(t2, &v2);
|
||||
blob_type bt2 = Yap_Eval(t2, &v2);
|
||||
|
||||
switch (bt2) {
|
||||
case long_int_e:
|
||||
@ -990,7 +990,7 @@ a_le(Term t1, Term t2)
|
||||
case double_e:
|
||||
{
|
||||
union arith_ret v2;
|
||||
blob_type bt2 = _YAP_Eval(t2, &v2);
|
||||
blob_type bt2 = Yap_Eval(t2, &v2);
|
||||
|
||||
switch (bt2) {
|
||||
case long_int_e:
|
||||
@ -1009,7 +1009,7 @@ a_le(Term t1, Term t2)
|
||||
case big_int_e:
|
||||
{
|
||||
union arith_ret v2;
|
||||
blob_type bt2 = _YAP_Eval(t2, &v2);
|
||||
blob_type bt2 = Yap_Eval(t2, &v2);
|
||||
|
||||
switch (bt2) {
|
||||
case long_int_e:
|
||||
@ -1066,19 +1066,19 @@ p_gen_ge(void)
|
||||
|
||||
|
||||
void
|
||||
_YAP_InitCmpPreds(void)
|
||||
Yap_InitCmpPreds(void)
|
||||
{
|
||||
_YAP_InitCmpPred("=:=", 2, a_eq, p_eq, SafePredFlag | BinaryTestPredFlag);
|
||||
_YAP_InitCmpPred("=\\=", 2, a_dif, p_dif, SafePredFlag | BinaryTestPredFlag);
|
||||
_YAP_InitCmpPred(">", 2, a_gt, p_gt, SafePredFlag | BinaryTestPredFlag);
|
||||
_YAP_InitCmpPred("=<", 2, a_le, p_le, SafePredFlag | BinaryTestPredFlag);
|
||||
_YAP_InitCmpPred("<", 2, a_lt, p_lt, SafePredFlag | BinaryTestPredFlag);
|
||||
_YAP_InitCmpPred(">=", 2, a_ge, p_ge, SafePredFlag | BinaryTestPredFlag);
|
||||
_YAP_InitCPred("$a_compare", 3, p_acomp, TestPredFlag | SafePredFlag);
|
||||
_YAP_InitCPred("\\==", 2, p_noteq, TestPredFlag | SafePredFlag);
|
||||
_YAP_InitCPred("@<", 2, p_gen_lt, TestPredFlag | SafePredFlag);
|
||||
_YAP_InitCPred("@=<", 2, p_gen_le, TestPredFlag | SafePredFlag);
|
||||
_YAP_InitCPred("@>", 2, p_gen_gt, TestPredFlag | SafePredFlag);
|
||||
_YAP_InitCPred("@>=", 2, p_gen_ge, TestPredFlag | SafePredFlag);
|
||||
_YAP_InitCPred("compare", 3, p_compare, TestPredFlag | SafePredFlag);
|
||||
Yap_InitCmpPred("=:=", 2, a_eq, p_eq, SafePredFlag | BinaryTestPredFlag);
|
||||
Yap_InitCmpPred("=\\=", 2, a_dif, p_dif, SafePredFlag | BinaryTestPredFlag);
|
||||
Yap_InitCmpPred(">", 2, a_gt, p_gt, SafePredFlag | BinaryTestPredFlag);
|
||||
Yap_InitCmpPred("=<", 2, a_le, p_le, SafePredFlag | BinaryTestPredFlag);
|
||||
Yap_InitCmpPred("<", 2, a_lt, p_lt, SafePredFlag | BinaryTestPredFlag);
|
||||
Yap_InitCmpPred(">=", 2, a_ge, p_ge, SafePredFlag | BinaryTestPredFlag);
|
||||
Yap_InitCPred("$a_compare", 3, p_acomp, TestPredFlag | SafePredFlag);
|
||||
Yap_InitCPred("\\==", 2, p_noteq, TestPredFlag | SafePredFlag);
|
||||
Yap_InitCPred("@<", 2, p_gen_lt, TestPredFlag | SafePredFlag);
|
||||
Yap_InitCPred("@=<", 2, p_gen_le, TestPredFlag | SafePredFlag);
|
||||
Yap_InitCPred("@>", 2, p_gen_gt, TestPredFlag | SafePredFlag);
|
||||
Yap_InitCPred("@>=", 2, p_gen_ge, TestPredFlag | SafePredFlag);
|
||||
Yap_InitCPred("compare", 3, p_compare, TestPredFlag | SafePredFlag);
|
||||
}
|
||||
|
706
C/compiler.c
706
C/compiler.c
File diff suppressed because it is too large
Load Diff
174
C/computils.c
174
C/computils.c
@ -48,9 +48,9 @@ static compiler_vm_op ic;
|
||||
|
||||
static CELL *cptr;
|
||||
|
||||
char _YAP_Option[20];
|
||||
char Yap_Option[20];
|
||||
|
||||
YP_FILE *_YAP_logfile;
|
||||
YP_FILE *Yap_logfile;
|
||||
#endif
|
||||
|
||||
static char *
|
||||
@ -66,19 +66,19 @@ AllocCMem (int size)
|
||||
freep += size;
|
||||
if (ASP <= CellPtr (freep) + 256) {
|
||||
save_machine_regs();
|
||||
longjmp(_YAP_CompilerBotch,3);
|
||||
longjmp(Yap_CompilerBotch,3);
|
||||
}
|
||||
return (p);
|
||||
}
|
||||
|
||||
char *
|
||||
_YAP_AllocCMem (int size)
|
||||
Yap_AllocCMem (int size)
|
||||
{
|
||||
return(AllocCMem(size));
|
||||
}
|
||||
|
||||
int
|
||||
_YAP_is_a_test_pred (Term arg, SMALLUNSGN mod)
|
||||
Yap_is_a_test_pred (Term arg, SMALLUNSGN mod)
|
||||
{
|
||||
if (IsVarTerm (arg))
|
||||
return (FALSE);
|
||||
@ -103,7 +103,7 @@ _YAP_is_a_test_pred (Term arg, SMALLUNSGN mod)
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_emit (compiler_vm_op o, Int r1, CELL r2)
|
||||
Yap_emit (compiler_vm_op o, Int r1, CELL r2)
|
||||
{
|
||||
PInstr *p;
|
||||
p = (PInstr *) AllocCMem (sizeof (*p));
|
||||
@ -121,7 +121,7 @@ _YAP_emit (compiler_vm_op o, Int r1, CELL r2)
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_emit_3ops (compiler_vm_op o, CELL r1, CELL r2, CELL r3)
|
||||
Yap_emit_3ops (compiler_vm_op o, CELL r1, CELL r2, CELL r3)
|
||||
{
|
||||
PInstr *p;
|
||||
p = (PInstr *) AllocCMem (sizeof (*p)+sizeof(CELL));
|
||||
@ -140,7 +140,7 @@ _YAP_emit_3ops (compiler_vm_op o, CELL r1, CELL r2, CELL r3)
|
||||
}
|
||||
|
||||
CELL *
|
||||
_YAP_emit_extra_size (compiler_vm_op o, CELL r1, int size)
|
||||
Yap_emit_extra_size (compiler_vm_op o, CELL r1, int size)
|
||||
{
|
||||
PInstr *p;
|
||||
p = (PInstr *) AllocCMem (sizeof (*p) + size - CellSize);
|
||||
@ -240,7 +240,7 @@ bip_name(Int op, char *s)
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_bip_name(Int op, char *s) {
|
||||
Yap_bip_name(Int op, char *s) {
|
||||
bip_name(op,s);
|
||||
}
|
||||
|
||||
@ -258,7 +258,7 @@ ShowOp (f)
|
||||
{
|
||||
case 'a':
|
||||
case 'n':
|
||||
_YAP_plwrite ((Term) arg, _YAP_DebugPutc, 0);
|
||||
Yap_plwrite ((Term) arg, Yap_DebugPutc, 0);
|
||||
break;
|
||||
case 'b':
|
||||
/* write a variable bitmap for a call */
|
||||
@ -266,32 +266,32 @@ ShowOp (f)
|
||||
int max = arg/(8*sizeof(CELL)), i;
|
||||
CELL *ptr = cptr;
|
||||
for (i = 0; i <= max; i++) {
|
||||
_YAP_plwrite(MkIntegerTerm((Int)(*ptr++)), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite(MkIntegerTerm((Int)(*ptr++)), Yap_DebugPutc, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'l':
|
||||
_YAP_plwrite (MkIntTerm (arg), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite (MkIntTerm (arg), Yap_DebugPutc, 0);
|
||||
break;
|
||||
case 'B':
|
||||
{
|
||||
char s[32];
|
||||
|
||||
bip_name(rn,s);
|
||||
_YAP_plwrite (MkAtomTerm(_YAP_LookupAtom(s)), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite (MkAtomTerm(Yap_LookupAtom(s)), Yap_DebugPutc, 0);
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
_YAP_plwrite (MkIntTerm (rn), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite (MkIntTerm (rn), Yap_DebugPutc, 0);
|
||||
break;
|
||||
case 'z':
|
||||
_YAP_plwrite (MkIntTerm (cpc->rnd3), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite (MkIntTerm (cpc->rnd3), Yap_DebugPutc, 0);
|
||||
break;
|
||||
case 'v':
|
||||
{
|
||||
Ventry *v = (Ventry *) arg;
|
||||
_YAP_DebugPutc (_YAP_c_error_stream,v->KindOfVE == PermVar ? 'Y' : 'X');
|
||||
_YAP_plwrite (MkIntTerm ((v->NoOfVE) & MaskVarAdrs), _YAP_DebugPutc, 0);
|
||||
Yap_DebugPutc (Yap_c_error_stream,v->KindOfVE == PermVar ? 'Y' : 'X');
|
||||
Yap_plwrite (MkIntTerm ((v->NoOfVE) & MaskVarAdrs), Yap_DebugPutc, 0);
|
||||
}
|
||||
break;
|
||||
case 'N':
|
||||
@ -301,14 +301,14 @@ ShowOp (f)
|
||||
cpc = cpc->nextInst;
|
||||
arg = cpc->rnd1;
|
||||
v = (Ventry *) arg;
|
||||
_YAP_DebugPutc (_YAP_c_error_stream,v->KindOfVE == PermVar ? 'Y' : 'X');
|
||||
_YAP_plwrite (MkIntTerm ((v->NoOfVE) & MaskVarAdrs), _YAP_DebugPutc, 0);
|
||||
Yap_DebugPutc (Yap_c_error_stream,v->KindOfVE == PermVar ? 'Y' : 'X');
|
||||
Yap_plwrite (MkIntTerm ((v->NoOfVE) & MaskVarAdrs), Yap_DebugPutc, 0);
|
||||
}
|
||||
break;
|
||||
case 'm':
|
||||
_YAP_plwrite (MkAtomTerm ((Atom) arg), _YAP_DebugPutc, 0);
|
||||
_YAP_DebugPutc (_YAP_c_error_stream,'/');
|
||||
_YAP_plwrite (MkIntTerm (rn), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite (MkAtomTerm ((Atom) arg), Yap_DebugPutc, 0);
|
||||
Yap_DebugPutc (Yap_c_error_stream,'/');
|
||||
Yap_plwrite (MkIntTerm (rn), Yap_DebugPutc, 0);
|
||||
break;
|
||||
case 'p':
|
||||
{
|
||||
@ -318,14 +318,14 @@ ShowOp (f)
|
||||
SMALLUNSGN mod = 0;
|
||||
|
||||
if (p->ModuleOfPred) mod = IntOfTerm(p->ModuleOfPred);
|
||||
_YAP_plwrite (ModuleName[mod], _YAP_DebugPutc, 0);
|
||||
_YAP_DebugPutc (_YAP_c_error_stream,':');
|
||||
Yap_plwrite (ModuleName[mod], Yap_DebugPutc, 0);
|
||||
Yap_DebugPutc (Yap_c_error_stream,':');
|
||||
if (arity == 0)
|
||||
_YAP_plwrite (MkAtomTerm ((Atom)f), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite (MkAtomTerm ((Atom)f), Yap_DebugPutc, 0);
|
||||
else
|
||||
_YAP_plwrite (MkAtomTerm (NameOfFunctor (f)), _YAP_DebugPutc, 0);
|
||||
_YAP_DebugPutc (_YAP_c_error_stream,'/');
|
||||
_YAP_plwrite (MkIntTerm (arity), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite (MkAtomTerm (NameOfFunctor (f)), Yap_DebugPutc, 0);
|
||||
Yap_DebugPutc (Yap_c_error_stream,'/');
|
||||
Yap_plwrite (MkIntTerm (arity), Yap_DebugPutc, 0);
|
||||
}
|
||||
break;
|
||||
case 'P':
|
||||
@ -336,88 +336,88 @@ ShowOp (f)
|
||||
SMALLUNSGN mod = 0;
|
||||
|
||||
if (p->ModuleOfPred) mod = IntOfTerm(p->ModuleOfPred);
|
||||
_YAP_plwrite (ModuleName[mod], _YAP_DebugPutc, 0);
|
||||
_YAP_DebugPutc (_YAP_c_error_stream,':');
|
||||
Yap_plwrite (ModuleName[mod], Yap_DebugPutc, 0);
|
||||
Yap_DebugPutc (Yap_c_error_stream,':');
|
||||
if (arity == 0)
|
||||
_YAP_plwrite (MkAtomTerm ((Atom)f), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite (MkAtomTerm ((Atom)f), Yap_DebugPutc, 0);
|
||||
else
|
||||
_YAP_plwrite (MkAtomTerm (NameOfFunctor (f)), _YAP_DebugPutc, 0);
|
||||
_YAP_DebugPutc (_YAP_c_error_stream,'/');
|
||||
_YAP_plwrite (MkIntTerm (arity), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite (MkAtomTerm (NameOfFunctor (f)), Yap_DebugPutc, 0);
|
||||
Yap_DebugPutc (Yap_c_error_stream,'/');
|
||||
Yap_plwrite (MkIntTerm (arity), Yap_DebugPutc, 0);
|
||||
}
|
||||
break;
|
||||
case 'f':
|
||||
if (IsExtensionFunctor((Functor)arg)) {
|
||||
if ((Functor)arg == FunctorDBRef) {
|
||||
_YAP_plwrite(MkAtomTerm(_YAP_LookupAtom("DBRef")), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite(MkAtomTerm(Yap_LookupAtom("DBRef")), Yap_DebugPutc, 0);
|
||||
} else if ((Functor)arg == FunctorLongInt) {
|
||||
_YAP_plwrite(MkAtomTerm(_YAP_LookupAtom("LongInt")), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite(MkAtomTerm(Yap_LookupAtom("LongInt")), Yap_DebugPutc, 0);
|
||||
} else if ((Functor)arg == FunctorDouble) {
|
||||
_YAP_plwrite(MkAtomTerm(_YAP_LookupAtom("Double")), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite(MkAtomTerm(Yap_LookupAtom("Double")), Yap_DebugPutc, 0);
|
||||
}
|
||||
} else {
|
||||
_YAP_plwrite(MkAtomTerm(NameOfFunctor ((Functor) arg)), _YAP_DebugPutc, 0);
|
||||
_YAP_DebugPutc (_YAP_c_error_stream,'/');
|
||||
_YAP_plwrite(MkIntTerm(ArityOfFunctor ((Functor) arg)), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite(MkAtomTerm(NameOfFunctor ((Functor) arg)), Yap_DebugPutc, 0);
|
||||
Yap_DebugPutc (Yap_c_error_stream,'/');
|
||||
Yap_plwrite(MkIntTerm(ArityOfFunctor ((Functor) arg)), Yap_DebugPutc, 0);
|
||||
}
|
||||
break;
|
||||
case 'r':
|
||||
_YAP_DebugPutc (_YAP_c_error_stream,'A');
|
||||
_YAP_plwrite (MkIntTerm (rn), _YAP_DebugPutc, 0);
|
||||
Yap_DebugPutc (Yap_c_error_stream,'A');
|
||||
Yap_plwrite (MkIntTerm (rn), Yap_DebugPutc, 0);
|
||||
break;
|
||||
case 'h':
|
||||
{
|
||||
CELL my_arg = *cptr++;
|
||||
if (my_arg & 1)
|
||||
_YAP_plwrite (MkIntTerm (my_arg),
|
||||
_YAP_DebugPutc, 0);
|
||||
Yap_plwrite (MkIntTerm (my_arg),
|
||||
Yap_DebugPutc, 0);
|
||||
else if (my_arg == (CELL) FAILCODE)
|
||||
_YAP_plwrite (MkAtomTerm (AtomFail), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite (MkAtomTerm (AtomFail), Yap_DebugPutc, 0);
|
||||
else
|
||||
_YAP_plwrite (MkIntegerTerm ((Int) my_arg),
|
||||
_YAP_DebugPutc, 0);
|
||||
Yap_plwrite (MkIntegerTerm ((Int) my_arg),
|
||||
Yap_DebugPutc, 0);
|
||||
}
|
||||
break;
|
||||
case 'g':
|
||||
if (arg & 1)
|
||||
_YAP_plwrite (MkIntTerm (arg),
|
||||
_YAP_DebugPutc, 0);
|
||||
Yap_plwrite (MkIntTerm (arg),
|
||||
Yap_DebugPutc, 0);
|
||||
else if (arg == (CELL) FAILCODE)
|
||||
_YAP_plwrite (MkAtomTerm (AtomFail), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite (MkAtomTerm (AtomFail), Yap_DebugPutc, 0);
|
||||
else
|
||||
_YAP_plwrite (MkIntegerTerm ((Int) arg), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite (MkIntegerTerm ((Int) arg), Yap_DebugPutc, 0);
|
||||
break;
|
||||
case 'i':
|
||||
_YAP_plwrite (MkIntTerm (arg), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite (MkIntTerm (arg), Yap_DebugPutc, 0);
|
||||
break;
|
||||
case 'j':
|
||||
{
|
||||
Functor fun = (Functor)*cptr++;
|
||||
if (IsExtensionFunctor(fun)) {
|
||||
if (fun == FunctorDBRef) {
|
||||
_YAP_plwrite(MkAtomTerm(_YAP_LookupAtom("DBRef")), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite(MkAtomTerm(Yap_LookupAtom("DBRef")), Yap_DebugPutc, 0);
|
||||
} else if (fun == FunctorLongInt) {
|
||||
_YAP_plwrite(MkAtomTerm(_YAP_LookupAtom("LongInt")), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite(MkAtomTerm(Yap_LookupAtom("LongInt")), Yap_DebugPutc, 0);
|
||||
} else if (fun == FunctorDouble) {
|
||||
_YAP_plwrite(MkAtomTerm(_YAP_LookupAtom("Double")), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite(MkAtomTerm(Yap_LookupAtom("Double")), Yap_DebugPutc, 0);
|
||||
}
|
||||
} else {
|
||||
_YAP_plwrite (MkAtomTerm(NameOfFunctor(fun)), _YAP_DebugPutc, 0);
|
||||
_YAP_DebugPutc (_YAP_c_error_stream,'/');
|
||||
_YAP_plwrite (MkIntTerm(ArityOfFunctor(fun)), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite (MkAtomTerm(NameOfFunctor(fun)), Yap_DebugPutc, 0);
|
||||
Yap_DebugPutc (Yap_c_error_stream,'/');
|
||||
Yap_plwrite (MkIntTerm(ArityOfFunctor(fun)), Yap_DebugPutc, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'O':
|
||||
_YAP_plwrite(AbsAppl(cptr), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite(AbsAppl(cptr), Yap_DebugPutc, 0);
|
||||
break;
|
||||
case 'x':
|
||||
_YAP_plwrite (MkIntTerm (rn >> 1), _YAP_DebugPutc, 0);
|
||||
_YAP_DebugPutc (_YAP_c_error_stream,'\t');
|
||||
_YAP_plwrite (MkIntTerm (rn & 1), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite (MkIntTerm (rn >> 1), Yap_DebugPutc, 0);
|
||||
Yap_DebugPutc (Yap_c_error_stream,'\t');
|
||||
Yap_plwrite (MkIntTerm (rn & 1), Yap_DebugPutc, 0);
|
||||
break;
|
||||
case 'o':
|
||||
_YAP_plwrite ((Term) * cptr++, _YAP_DebugPutc, 0);
|
||||
Yap_plwrite ((Term) * cptr++, Yap_DebugPutc, 0);
|
||||
case 'c':
|
||||
{
|
||||
int i;
|
||||
@ -426,23 +426,23 @@ ShowOp (f)
|
||||
CELL my_arg;
|
||||
if (*cptr)
|
||||
{
|
||||
_YAP_plwrite ((Term) * cptr++, _YAP_DebugPutc, 0);
|
||||
Yap_plwrite ((Term) * cptr++, Yap_DebugPutc, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
_YAP_plwrite (MkIntTerm (0), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite (MkIntTerm (0), Yap_DebugPutc, 0);
|
||||
cptr++;
|
||||
}
|
||||
_YAP_DebugPutc (_YAP_c_error_stream,'\t');
|
||||
Yap_DebugPutc (Yap_c_error_stream,'\t');
|
||||
my_arg = *cptr++;
|
||||
if (my_arg & 1)
|
||||
_YAP_plwrite (MkIntTerm (my_arg),
|
||||
_YAP_DebugPutc, 0);
|
||||
Yap_plwrite (MkIntTerm (my_arg),
|
||||
Yap_DebugPutc, 0);
|
||||
else if (my_arg == (CELL) FAILCODE)
|
||||
_YAP_plwrite (MkAtomTerm (AtomFail), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite (MkAtomTerm (AtomFail), Yap_DebugPutc, 0);
|
||||
else
|
||||
_YAP_plwrite (MkIntegerTerm ((Int) my_arg), _YAP_DebugPutc, 0);
|
||||
_YAP_DebugPutc (_YAP_c_error_stream,'\n');
|
||||
Yap_plwrite (MkIntegerTerm ((Int) my_arg), Yap_DebugPutc, 0);
|
||||
Yap_DebugPutc (Yap_c_error_stream,'\n');
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -454,36 +454,36 @@ ShowOp (f)
|
||||
CELL my_arg;
|
||||
if (*cptr)
|
||||
{
|
||||
_YAP_plwrite (MkAtomTerm (NameOfFunctor ((Functor) * cptr)), _YAP_DebugPutc, 0);
|
||||
_YAP_DebugPutc (_YAP_c_error_stream,'/');
|
||||
_YAP_plwrite (MkIntTerm (ArityOfFunctor ((Functor) * cptr++)), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite (MkAtomTerm (NameOfFunctor ((Functor) * cptr)), Yap_DebugPutc, 0);
|
||||
Yap_DebugPutc (Yap_c_error_stream,'/');
|
||||
Yap_plwrite (MkIntTerm (ArityOfFunctor ((Functor) * cptr++)), Yap_DebugPutc, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
_YAP_plwrite (MkIntTerm (0), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite (MkIntTerm (0), Yap_DebugPutc, 0);
|
||||
cptr++;
|
||||
}
|
||||
_YAP_DebugPutc (_YAP_c_error_stream,'\t');
|
||||
Yap_DebugPutc (Yap_c_error_stream,'\t');
|
||||
my_arg = *cptr++;
|
||||
if (my_arg & 1)
|
||||
_YAP_plwrite (MkIntTerm (my_arg),
|
||||
_YAP_DebugPutc, 0);
|
||||
Yap_plwrite (MkIntTerm (my_arg),
|
||||
Yap_DebugPutc, 0);
|
||||
else if (my_arg == (CELL) FAILCODE)
|
||||
_YAP_plwrite (MkAtomTerm (AtomFail), _YAP_DebugPutc, 0);
|
||||
Yap_plwrite (MkAtomTerm (AtomFail), Yap_DebugPutc, 0);
|
||||
else
|
||||
_YAP_plwrite (MkIntegerTerm ((Int) my_arg), _YAP_DebugPutc, 0);
|
||||
_YAP_DebugPutc (_YAP_c_error_stream,'\n');
|
||||
Yap_plwrite (MkIntegerTerm ((Int) my_arg), Yap_DebugPutc, 0);
|
||||
Yap_DebugPutc (Yap_c_error_stream,'\n');
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_YAP_DebugPutc (_YAP_c_error_stream,'%');
|
||||
_YAP_DebugPutc (_YAP_c_error_stream,ch);
|
||||
Yap_DebugPutc (Yap_c_error_stream,'%');
|
||||
Yap_DebugPutc (Yap_c_error_stream,ch);
|
||||
}
|
||||
else
|
||||
_YAP_DebugPutc (_YAP_c_error_stream,ch);
|
||||
Yap_DebugPutc (Yap_c_error_stream,ch);
|
||||
}
|
||||
_YAP_DebugPutc (_YAP_c_error_stream,'\n');
|
||||
Yap_DebugPutc (Yap_c_error_stream,'\n');
|
||||
}
|
||||
|
||||
static char *opformat[] =
|
||||
@ -654,7 +654,7 @@ static char *opformat[] =
|
||||
|
||||
|
||||
void
|
||||
_YAP_ShowCode ()
|
||||
Yap_ShowCode ()
|
||||
{
|
||||
CELL *OldH = H;
|
||||
|
||||
@ -671,7 +671,7 @@ _YAP_ShowCode ()
|
||||
ShowOp (opformat[ic]);
|
||||
cpc = cpc->nextInst;
|
||||
}
|
||||
_YAP_DebugPutc (_YAP_c_error_stream,'\n');
|
||||
Yap_DebugPutc (Yap_c_error_stream,'\n');
|
||||
H = OldH;
|
||||
}
|
||||
|
||||
|
114
C/corout.c
114
C/corout.c
@ -164,13 +164,13 @@ UpdateSVarList(sus_record *sl)
|
||||
/* make sl the new head of the suspension list, and update the list
|
||||
to use the old one. Note that the list is only bound once,
|
||||
MutableList is the one variable being updated all the time */
|
||||
return((sus_record *)_YAP_UpdateTimedVar(MutableList, (CELL)sl));
|
||||
return((sus_record *)Yap_UpdateTimedVar(MutableList, (CELL)sl));
|
||||
}
|
||||
|
||||
inline static sus_record *
|
||||
GetSVarList(void)
|
||||
{
|
||||
Term t = _YAP_ReadTimedVar(MutableList);
|
||||
Term t = Yap_ReadTimedVar(MutableList);
|
||||
/* just return the start of the list */
|
||||
if (t == TermNil)
|
||||
return(NULL);
|
||||
@ -190,7 +190,7 @@ GetSVarList(void)
|
||||
|
||||
static Term
|
||||
ListOfWokenGoals(void) {
|
||||
sus_record *pt = (sus_record *)_YAP_ReadTimedVar(WokenGoals);
|
||||
sus_record *pt = (sus_record *)Yap_ReadTimedVar(WokenGoals);
|
||||
Term t;
|
||||
|
||||
t = TermNil;
|
||||
@ -203,7 +203,7 @@ ListOfWokenGoals(void) {
|
||||
}
|
||||
|
||||
Term
|
||||
_YAP_ListOfWokenGoals(void) {
|
||||
Yap_ListOfWokenGoals(void) {
|
||||
return ListOfWokenGoals();
|
||||
}
|
||||
|
||||
@ -211,10 +211,10 @@ _YAP_ListOfWokenGoals(void) {
|
||||
static void ReleaseGoals(sus_record *from)
|
||||
{
|
||||
/* follow the chain */
|
||||
sus_record *WGs = (sus_record *)_YAP_ReadTimedVar(WokenGoals);
|
||||
sus_record *WGs = (sus_record *)Yap_ReadTimedVar(WokenGoals);
|
||||
|
||||
if ((Term)WGs == TermNil) {
|
||||
_YAP_UpdateTimedVar(WokenGoals, (CELL)from);
|
||||
Yap_UpdateTimedVar(WokenGoals, (CELL)from);
|
||||
} else {
|
||||
/* add to the end of the current list of suspended goals */
|
||||
CELL *where_to = (CELL *)Deref((CELL)WGs);
|
||||
@ -335,14 +335,14 @@ CopySuspendedVar(CELL *orig, CELL ***to_visit_ptr, CELL *res)
|
||||
register sus_tag *sreg = (sus_tag *)orig, *vs;
|
||||
|
||||
/* add a new suspension */
|
||||
vs = (sus_tag *)_YAP_ReadTimedVar(DelayedVars);
|
||||
vs = (sus_tag *)Yap_ReadTimedVar(DelayedVars);
|
||||
if (H0 - (CELL *)vs < 1024)
|
||||
return(FALSE);
|
||||
RESET_VARIABLE(&(vs->ActiveSus));
|
||||
vs->sus_id = susp_ext;
|
||||
vs->SG = copy_suspended_goals(sreg->SG, to_visit_ptr);
|
||||
*res = (CELL)&(vs->ActiveSus);
|
||||
_YAP_UpdateTimedVar(DelayedVars, (CELL)(vs+1));
|
||||
Yap_UpdateTimedVar(DelayedVars, (CELL)(vs+1));
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
@ -386,14 +386,14 @@ TermToSuspendedVar(Term gs, Term var)
|
||||
{
|
||||
register sus_tag *vs;
|
||||
/* add a new suspension */
|
||||
vs = (sus_tag *)_YAP_ReadTimedVar(DelayedVars);
|
||||
vs = (sus_tag *)Yap_ReadTimedVar(DelayedVars);
|
||||
if (H0 - (CELL *)vs < 1024)
|
||||
return(FALSE);
|
||||
RESET_VARIABLE(&(vs->ActiveSus));
|
||||
vs->sus_id = susp_ext;
|
||||
vs->SG = terms_to_suspended_goals(gs);
|
||||
_YAP_unify(var,(CELL)&(vs->ActiveSus));
|
||||
_YAP_UpdateTimedVar(DelayedVars, (CELL)(vs+1));
|
||||
Yap_unify(var,(CELL)&(vs->ActiveSus));
|
||||
Yap_UpdateTimedVar(DelayedVars, (CELL)(vs+1));
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
@ -404,10 +404,10 @@ mark_sus_record(sus_record *sg)
|
||||
if (MARKED(((CELL)(sg->NR))))
|
||||
return;
|
||||
MARK(((CELL *)&(sg->NR)));
|
||||
_YAP_inc_mark_variable();
|
||||
_YAP_mark_variable((CELL *)&(sg->SG));
|
||||
Yap_inc_mark_variable();
|
||||
Yap_mark_variable((CELL *)&(sg->SG));
|
||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||
_YAP_inc_mark_variable();
|
||||
Yap_inc_mark_variable();
|
||||
if (!IsAtomTerm((CELL)(sg->NS)))
|
||||
mark_sus_record(sg->NS);
|
||||
MARK(((CELL *)&(sg->NS)));
|
||||
@ -419,12 +419,12 @@ static void mark_suspended_goal(CELL *orig)
|
||||
register sus_tag *sreg = (sus_tag *)orig;
|
||||
|
||||
mark_sus_record(sreg->SG);
|
||||
_YAP_mark_external_reference(((CELL *)&(sreg->SG)));
|
||||
Yap_mark_external_reference(((CELL *)&(sreg->SG)));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_YAP_mark_all_suspended_goals(void)
|
||||
Yap_mark_all_suspended_goals(void)
|
||||
{
|
||||
sus_record *sg = GetSVarList();
|
||||
if (sg == NULL)
|
||||
@ -474,7 +474,7 @@ Wake(CELL *pt1, CELL reg2)
|
||||
/* binding two suspended variables, be careful */
|
||||
if (susp2->sus_id != susp_ext) {
|
||||
/* joining two suspensions */
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, "joining two suspensions not implemented");
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, "joining two suspensions not implemented");
|
||||
return;
|
||||
}
|
||||
/* join the two suspended lists */
|
||||
@ -573,19 +573,19 @@ freeze_goal(Term t, Term g)
|
||||
id = (exts)(susp->sus_id);
|
||||
if (id != susp_ext) {
|
||||
/* obtain the term */
|
||||
_YAP_Error(SYSTEM_ERROR,TermNil,"multiple suspensions not supported");
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,"multiple suspensions not supported");
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
AddSuspendedGoal(g, susp->SG);
|
||||
return(TRUE);
|
||||
}
|
||||
vs = (sus_tag *)_YAP_ReadTimedVar(DelayedVars);
|
||||
vs = (sus_tag *)Yap_ReadTimedVar(DelayedVars);
|
||||
if (H0 - (CELL *)vs < 1024) {
|
||||
ARG1 = t;
|
||||
ARG2 = g;
|
||||
if (!_YAP_growglobal(NULL)) {
|
||||
_YAP_Error(SYSTEM_ERROR, t, _YAP_ErrorMessage);
|
||||
if (!Yap_growglobal(NULL)) {
|
||||
Yap_Error(SYSTEM_ERROR, t, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
t = ARG1;
|
||||
@ -603,13 +603,13 @@ freeze_goal(Term t, Term g)
|
||||
vs->sus_id = susp_ext;
|
||||
vs->SG = gf;
|
||||
RESET_VARIABLE(&(vs->ActiveSus));
|
||||
_YAP_UpdateTimedVar(DelayedVars, (CELL)(vs+1));
|
||||
Yap_UpdateTimedVar(DelayedVars, (CELL)(vs+1));
|
||||
Bind_Global((CELL *)t,(CELL)&(vs->ActiveSus));
|
||||
return(TRUE);
|
||||
}
|
||||
else {
|
||||
/* Oops, first argument was bound :-( */
|
||||
_YAP_Error(TYPE_ERROR_VARIABLE, t, "freeze/2");
|
||||
Yap_Error(TYPE_ERROR_VARIABLE, t, "freeze/2");
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
@ -621,7 +621,7 @@ p_read_svar_list(void)
|
||||
{
|
||||
#ifdef COROUTINING
|
||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||
return(_YAP_unify(ARG1, MutableList) && _YAP_unify(ARG2, AttsMutableList));
|
||||
return(Yap_unify(ARG1, MutableList) && Yap_unify(ARG2, AttsMutableList));
|
||||
#else
|
||||
return(TRUE);
|
||||
#endif
|
||||
@ -725,7 +725,7 @@ static Int p_frozen_goals(void)
|
||||
}
|
||||
HB = B->cp_h;
|
||||
#endif
|
||||
return(_YAP_unify(ARG2,t));
|
||||
return(Yap_unify(ARG2,t));
|
||||
}
|
||||
|
||||
/* return a queue with all goals frozen in the system */
|
||||
@ -733,11 +733,11 @@ static Int p_all_frozen_goals(void)
|
||||
{
|
||||
#ifdef COROUTINING
|
||||
/* initially, we do not know of any goals frozen */
|
||||
Term t = _YAP_CurrentAttVars();
|
||||
Term t = Yap_CurrentAttVars();
|
||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||
sus_record *x = GetSVarList();
|
||||
if (x == NULL)
|
||||
return(_YAP_unify(ARG1,t));
|
||||
return(Yap_unify(ARG1,t));
|
||||
/* okay, we are on top of the list of variables. Let's burn rubber!
|
||||
*/
|
||||
while ((CELL)x != TermNil) {
|
||||
@ -745,9 +745,9 @@ static Int p_all_frozen_goals(void)
|
||||
x = x->NS;
|
||||
}
|
||||
#endif
|
||||
return(_YAP_unify(ARG1,t));
|
||||
return(Yap_unify(ARG1,t));
|
||||
#else
|
||||
return(_YAP_unify(ARG1,TermNil));
|
||||
return(Yap_unify(ARG1,TermNil));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -777,7 +777,7 @@ static int can_unify_complex(register CELL *pt0,
|
||||
CELL *saved_HB;
|
||||
choiceptr saved_B;
|
||||
|
||||
register CELL **to_visit = (CELL **)_YAP_PreAllocCodeSpace();
|
||||
register CELL **to_visit = (CELL **)Yap_PreAllocCodeSpace();
|
||||
CELL **to_visit_base = to_visit;
|
||||
|
||||
/* make sure to trail all bindings */
|
||||
@ -878,7 +878,7 @@ static int can_unify_complex(register CELL *pt0,
|
||||
goto comparison_failed;
|
||||
#ifdef USE_GMP
|
||||
case (CELL)FunctorBigInt:
|
||||
if (mpz_cmp(_YAP_BigIntOfTerm(d0),_YAP_BigIntOfTerm(d1)) == 0) continue;
|
||||
if (mpz_cmp(Yap_BigIntOfTerm(d0),Yap_BigIntOfTerm(d1)) == 0) continue;
|
||||
goto comparison_failed;
|
||||
#endif /* USE_GMP */
|
||||
default:
|
||||
@ -929,7 +929,7 @@ static int can_unify_complex(register CELL *pt0,
|
||||
goto loop;
|
||||
}
|
||||
/* success */
|
||||
_YAP_ReleasePreAllocCodeSpace((ADDR)to_visit);
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)to_visit);
|
||||
/* restore B, and later HB */
|
||||
B = saved_B;
|
||||
HB = saved_HB;
|
||||
@ -942,7 +942,7 @@ static int can_unify_complex(register CELL *pt0,
|
||||
|
||||
comparison_failed:
|
||||
/* failure */
|
||||
_YAP_ReleasePreAllocCodeSpace((ADDR)to_visit);
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)to_visit);
|
||||
#ifdef RATIONAL_TREES
|
||||
while (to_visit > (CELL **)to_visit_base) {
|
||||
to_visit -= 4;
|
||||
@ -1015,7 +1015,7 @@ can_unify(Term t1, Term t2, Term *Vars)
|
||||
return(FALSE);
|
||||
#ifdef USE_GMP
|
||||
case (CELL)FunctorBigInt:
|
||||
if (mpz_cmp(_YAP_BigIntOfTerm(t1),_YAP_BigIntOfTerm(t2)) == 0) return(TRUE);
|
||||
if (mpz_cmp(Yap_BigIntOfTerm(t1),Yap_BigIntOfTerm(t2)) == 0) return(TRUE);
|
||||
return(FALSE);
|
||||
#endif /* USE_GMP */
|
||||
default:
|
||||
@ -1035,7 +1035,7 @@ static int non_ground_complex(register CELL *pt0,
|
||||
Term *Var)
|
||||
{
|
||||
|
||||
register CELL **to_visit = (CELL **)_YAP_PreAllocCodeSpace();
|
||||
register CELL **to_visit = (CELL **)Yap_PreAllocCodeSpace();
|
||||
CELL **to_visit_base = to_visit;
|
||||
|
||||
loop:
|
||||
@ -1113,12 +1113,12 @@ static int non_ground_complex(register CELL *pt0,
|
||||
}
|
||||
|
||||
/* the term is ground */
|
||||
_YAP_ReleasePreAllocCodeSpace((ADDR)to_visit);
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)to_visit);
|
||||
return(FALSE);
|
||||
|
||||
var_found:
|
||||
/* the term is non-ground */
|
||||
_YAP_ReleasePreAllocCodeSpace((ADDR)to_visit);
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)to_visit);
|
||||
#ifdef RATIONAL_TREES
|
||||
while (to_visit > (CELL **)to_visit_base) {
|
||||
to_visit -= 3;
|
||||
@ -1165,7 +1165,7 @@ static Int p_can_unify(void)
|
||||
Term r = TermNil;
|
||||
if (!can_unify(ARG1, ARG2, &r))
|
||||
return(FALSE);
|
||||
return (_YAP_unify(ARG3, r));
|
||||
return (Yap_unify(ARG3, r));
|
||||
#else
|
||||
return(FALSE);
|
||||
#endif
|
||||
@ -1178,7 +1178,7 @@ static Int p_non_ground(void)
|
||||
Term r;
|
||||
if (!non_ground(ARG1, &r))
|
||||
return(FALSE);
|
||||
return (_YAP_unify(ARG2, r));
|
||||
return (Yap_unify(ARG2, r));
|
||||
#else
|
||||
return(FALSE);
|
||||
#endif
|
||||
@ -1198,13 +1198,13 @@ static Int p_coroutining(void)
|
||||
static Int p_awoken_goals(void)
|
||||
{
|
||||
#ifdef COROUTINING
|
||||
Term WGs = _YAP_ReadTimedVar(WokenGoals);
|
||||
Term WGs = Yap_ReadTimedVar(WokenGoals);
|
||||
if (WGs == TermNil) {
|
||||
return(FALSE);
|
||||
}
|
||||
WGs = ListOfWokenGoals();
|
||||
_YAP_UpdateTimedVar(WokenGoals, TermNil);
|
||||
return(_YAP_unify(ARG1,WGs));
|
||||
Yap_UpdateTimedVar(WokenGoals, TermNil);
|
||||
return(Yap_unify(ARG1,WGs));
|
||||
#else
|
||||
return(FALSE);
|
||||
#endif
|
||||
@ -1212,7 +1212,7 @@ static Int p_awoken_goals(void)
|
||||
|
||||
#ifdef COROUTINING
|
||||
void
|
||||
_YAP_WakeUp(CELL *pt0) {
|
||||
Yap_WakeUp(CELL *pt0) {
|
||||
CELL d0 = *pt0;
|
||||
RESET_VARIABLE(pt0);
|
||||
TR--;
|
||||
@ -1221,7 +1221,7 @@ _YAP_WakeUp(CELL *pt0) {
|
||||
#endif
|
||||
|
||||
|
||||
void _YAP_InitCoroutPreds(void)
|
||||
void Yap_InitCoroutPreds(void)
|
||||
{
|
||||
#ifdef COROUTINING
|
||||
Atom at;
|
||||
@ -1232,21 +1232,21 @@ void _YAP_InitCoroutPreds(void)
|
||||
attas[susp_ext].to_term_op = SuspendedVarToTerm;
|
||||
attas[susp_ext].term_to_op = TermToSuspendedVar;
|
||||
attas[susp_ext].mark_op = mark_suspended_goal;
|
||||
at = _YAP_LookupAtom("$wake_up_goal");
|
||||
pred = RepPredProp(PredPropByFunc(_YAP_MkFunctor(at, 2),0));
|
||||
at = Yap_LookupAtom("$wake_up_goal");
|
||||
pred = RepPredProp(PredPropByFunc(Yap_MkFunctor(at, 2),0));
|
||||
WakeUpCode = pred;
|
||||
_YAP_InitAttVarPreds();
|
||||
Yap_InitAttVarPreds();
|
||||
#endif /* COROUTINING */
|
||||
_YAP_InitCPred("$read_svar_list", 2, p_read_svar_list, SafePredFlag);
|
||||
_YAP_InitCPred("$set_svar_list", 2, p_set_svar_list, SafePredFlag);
|
||||
_YAP_InitCPred("$freeze", 2, p_freeze, 0);
|
||||
_YAP_InitCPred("freeze_on_first", 2, p_freeze_on_first, TestPredFlag);
|
||||
_YAP_InitCPred("$frozen_goals", 2, p_frozen_goals, SafePredFlag);
|
||||
_YAP_InitCPred("$all_frozen_goals", 1, p_all_frozen_goals, SafePredFlag);
|
||||
_YAP_InitCPred("$can_unify", 3, p_can_unify, SafePredFlag);
|
||||
_YAP_InitCPred("$non_ground", 2, p_non_ground, SafePredFlag);
|
||||
_YAP_InitCPred("$coroutining", 0, p_coroutining, SafePredFlag);
|
||||
_YAP_InitCPred("$awoken_goals", 1, p_awoken_goals, SafePredFlag);
|
||||
Yap_InitCPred("$read_svar_list", 2, p_read_svar_list, SafePredFlag);
|
||||
Yap_InitCPred("$set_svar_list", 2, p_set_svar_list, SafePredFlag);
|
||||
Yap_InitCPred("$freeze", 2, p_freeze, 0);
|
||||
Yap_InitCPred("freeze_on_first", 2, p_freeze_on_first, TestPredFlag);
|
||||
Yap_InitCPred("$frozen_goals", 2, p_frozen_goals, SafePredFlag);
|
||||
Yap_InitCPred("$all_frozen_goals", 1, p_all_frozen_goals, SafePredFlag);
|
||||
Yap_InitCPred("$can_unify", 3, p_can_unify, SafePredFlag);
|
||||
Yap_InitCPred("$non_ground", 2, p_non_ground, SafePredFlag);
|
||||
Yap_InitCPred("$coroutining", 0, p_coroutining, SafePredFlag);
|
||||
Yap_InitCPred("$awoken_goals", 1, p_awoken_goals, SafePredFlag);
|
||||
}
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@ STD_PROTO(static Int p_set_depth_limit, (void));
|
||||
|
||||
static Int p_get_depth_limit(void)
|
||||
{
|
||||
return(_YAP_unify_constant(ARG1, MkIntTerm(IntOfTerm(DEPTH/2))));
|
||||
return(Yap_unify_constant(ARG1, MkIntTerm(IntOfTerm(DEPTH/2))));
|
||||
}
|
||||
|
||||
static Int p_set_depth_limit(void)
|
||||
@ -37,10 +37,10 @@ static Int p_set_depth_limit(void)
|
||||
Term d = Deref(ARG1);
|
||||
|
||||
if (IsVarTerm(d)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, d, "set-depth_limit");
|
||||
Yap_Error(INSTANTIATION_ERROR, d, "set-depth_limit");
|
||||
return(FALSE);
|
||||
} else if (!IsIntegerTerm(d)) {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, d, "set-depth_limit");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, d, "set-depth_limit");
|
||||
return(FALSE);
|
||||
}
|
||||
d = MkIntTerm(IntegerOfTerm(d)*2);
|
||||
@ -51,10 +51,10 @@ static Int p_set_depth_limit(void)
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
void _YAP_InitItDeepenPreds(void)
|
||||
void Yap_InitItDeepenPreds(void)
|
||||
{
|
||||
_YAP_InitCPred("get_depth_limit", 1, p_get_depth_limit, SafePredFlag);
|
||||
_YAP_InitCPred("$set_depth_limit", 1, p_set_depth_limit, 0);
|
||||
Yap_InitCPred("get_depth_limit", 1, p_get_depth_limit, SafePredFlag);
|
||||
Yap_InitCPred("$set_depth_limit", 1, p_set_depth_limit, 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
552
C/errors.c
552
C/errors.c
File diff suppressed because it is too large
Load Diff
46
C/eval.c
46
C/eval.c
@ -27,7 +27,7 @@ static char SccsId[] = "%W% %G%";
|
||||
#include "Heap.h"
|
||||
#include "eval.h"
|
||||
|
||||
yap_error_number _YAP_matherror = YAP_NO_ERROR;
|
||||
yap_error_number Yap_matherror = YAP_NO_ERROR;
|
||||
|
||||
#define E_FUNC blob_type
|
||||
#define E_ARGS arith_retptr o
|
||||
@ -48,7 +48,7 @@ EvalToTerm(blob_type bt, union arith_ret *res)
|
||||
return(MkFloatTerm(res->dbl));
|
||||
#ifdef USE_GMP
|
||||
case big_int_e:
|
||||
return(_YAP_MkBigIntTerm(res->big));
|
||||
return(Yap_MkBigIntTerm(res->big));
|
||||
#endif
|
||||
default:
|
||||
return(TermNil);
|
||||
@ -59,7 +59,7 @@ static E_FUNC
|
||||
Eval(Term t, E_ARGS)
|
||||
{
|
||||
if (IsVarTerm(t)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,TermNil,"in arithmetic");
|
||||
Yap_Error(INSTANTIATION_ERROR,TermNil,"in arithmetic");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
}
|
||||
@ -72,7 +72,7 @@ Eval(Term t, E_ARGS)
|
||||
RFLOAT(FloatOfTerm(t));
|
||||
#ifdef USE_GMP
|
||||
case (CELL)FunctorBigInt:
|
||||
RBIG(_YAP_BigIntOfTerm(t));
|
||||
RBIG(Yap_BigIntOfTerm(t));
|
||||
#endif
|
||||
default:
|
||||
{
|
||||
@ -80,14 +80,14 @@ Eval(Term t, E_ARGS)
|
||||
Atom name = NameOfFunctor(fun);
|
||||
ExpEntry *p;
|
||||
|
||||
if (EndOfPAEntr(p = RepExpProp(_YAP_GetExpProp(name, n)))) {
|
||||
if (EndOfPAEntr(p = RepExpProp(Yap_GetExpProp(name, n)))) {
|
||||
Term ti[2];
|
||||
|
||||
/* error */
|
||||
ti[0] = t;
|
||||
ti[1] = MkIntegerTerm(n);
|
||||
t = _YAP_MkApplTerm(_YAP_MkFunctor(_YAP_LookupAtom("/"),2), 2, ti);
|
||||
_YAP_Error(TYPE_ERROR_EVALUABLE, t,
|
||||
t = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("/"),2), 2, ti);
|
||||
Yap_Error(TYPE_ERROR_EVALUABLE, t,
|
||||
"functor %s/%d for arithmetic expression",
|
||||
RepAtom(name)->StrOfAE,n);
|
||||
P = (yamop *)FAILCODE;
|
||||
@ -106,9 +106,9 @@ Eval(Term t, E_ARGS)
|
||||
Atom name = AtomOfTerm(t);
|
||||
ExpEntry *p;
|
||||
|
||||
if (EndOfPAEntr(p = RepExpProp(_YAP_GetExpProp(name, 0)))) {
|
||||
if (EndOfPAEntr(p = RepExpProp(Yap_GetExpProp(name, 0)))) {
|
||||
/* error */
|
||||
_YAP_Error(TYPE_ERROR_EVALUABLE, t,
|
||||
Yap_Error(TYPE_ERROR_EVALUABLE, t,
|
||||
"atom %s for arithmetic expression",
|
||||
RepAtom(name)->StrOfAE);
|
||||
P = (yamop *)FAILCODE;
|
||||
@ -119,10 +119,10 @@ Eval(Term t, E_ARGS)
|
||||
}
|
||||
|
||||
E_FUNC
|
||||
_YAP_Eval(Term t, E_ARGS)
|
||||
Yap_Eval(Term t, E_ARGS)
|
||||
{
|
||||
if (IsVarTerm(t)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,TermNil,"in arithmetic");
|
||||
Yap_Error(INSTANTIATION_ERROR,TermNil,"in arithmetic");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
}
|
||||
@ -135,7 +135,7 @@ _YAP_Eval(Term t, E_ARGS)
|
||||
RFLOAT(FloatOfTerm(t));
|
||||
#ifdef USE_GMP
|
||||
case (CELL)FunctorBigInt:
|
||||
RBIG(_YAP_BigIntOfTerm(t));
|
||||
RBIG(Yap_BigIntOfTerm(t));
|
||||
#endif
|
||||
default:
|
||||
{
|
||||
@ -143,14 +143,14 @@ _YAP_Eval(Term t, E_ARGS)
|
||||
Atom name = NameOfFunctor(fun);
|
||||
ExpEntry *p;
|
||||
|
||||
if (EndOfPAEntr(p = RepExpProp(_YAP_GetExpProp(name, n)))) {
|
||||
if (EndOfPAEntr(p = RepExpProp(Yap_GetExpProp(name, n)))) {
|
||||
Term ti[2];
|
||||
|
||||
/* error */
|
||||
ti[0] = t;
|
||||
ti[1] = MkIntegerTerm(n);
|
||||
t = _YAP_MkApplTerm(_YAP_MkFunctor(_YAP_LookupAtom("/"),2), 2, ti);
|
||||
_YAP_Error(TYPE_ERROR_EVALUABLE, t,
|
||||
t = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("/"),2), 2, ti);
|
||||
Yap_Error(TYPE_ERROR_EVALUABLE, t,
|
||||
"functor %s/%d for arithmetic expression",
|
||||
RepAtom(name)->StrOfAE,n);
|
||||
P = (yamop *)FAILCODE;
|
||||
@ -169,9 +169,9 @@ _YAP_Eval(Term t, E_ARGS)
|
||||
Atom name = AtomOfTerm(t);
|
||||
ExpEntry *p;
|
||||
|
||||
if (EndOfPAEntr(p = RepExpProp(_YAP_GetExpProp(name, 0)))) {
|
||||
if (EndOfPAEntr(p = RepExpProp(Yap_GetExpProp(name, 0)))) {
|
||||
/* error */
|
||||
_YAP_Error(TYPE_ERROR_EVALUABLE, t,
|
||||
Yap_Error(TYPE_ERROR_EVALUABLE, t,
|
||||
"atom %s for arithmetic expression",
|
||||
RepAtom(name)->StrOfAE);
|
||||
P = (yamop *)FAILCODE;
|
||||
@ -188,16 +188,16 @@ p_is(void)
|
||||
blob_type bt;
|
||||
|
||||
bt = Eval(Deref(ARG2), &res);
|
||||
return (_YAP_unify_constant(ARG1,EvalToTerm(bt,&res)));
|
||||
return (Yap_unify_constant(ARG1,EvalToTerm(bt,&res)));
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_InitEval(void)
|
||||
Yap_InitEval(void)
|
||||
{
|
||||
/* here are the arithmetical predicates */
|
||||
_YAP_InitConstExps();
|
||||
_YAP_InitUnaryExps();
|
||||
_YAP_InitBinaryExps();
|
||||
_YAP_InitCPred("is", 2, p_is, TestPredFlag | SafePredFlag);
|
||||
Yap_InitConstExps();
|
||||
Yap_InitUnaryExps();
|
||||
Yap_InitBinaryExps();
|
||||
Yap_InitCPred("is", 2, p_is, TestPredFlag | SafePredFlag);
|
||||
}
|
||||
|
||||
|
306
C/exec.c
306
C/exec.c
@ -29,8 +29,8 @@ STATIC_PROTO(Int p_execute0, (void));
|
||||
STATIC_PROTO(Int p_at_execute, (void));
|
||||
|
||||
/************ table of C-Predicates *************/
|
||||
CPredicate _YAP_c_predicates[MAX_C_PREDS];
|
||||
cmp_entry _YAP_cmp_funcs[MAX_CMP_FUNCS];
|
||||
CPredicate Yap_c_predicates[MAX_C_PREDS];
|
||||
cmp_entry Yap_cmp_funcs[MAX_CMP_FUNCS];
|
||||
|
||||
static Term
|
||||
current_cp_as_integer(void)
|
||||
@ -52,7 +52,7 @@ CallPredicate(PredEntry *pen, choiceptr cut_pt) {
|
||||
DEPTH -= MkIntConstant(2);
|
||||
#endif /* DEPTH_LIMIT */
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
if (_YAP_do_low_level_trace)
|
||||
if (Yap_do_low_level_trace)
|
||||
low_level_trace(enter_pred,pen,XREGS+1);
|
||||
#endif /* LOW_LEVEL_TRACE */
|
||||
CP = P;
|
||||
@ -79,13 +79,13 @@ CallMetaCall(SMALLUNSGN mod) {
|
||||
}
|
||||
|
||||
Term
|
||||
_YAP_ExecuteCallMetaCall(SMALLUNSGN mod) {
|
||||
Yap_ExecuteCallMetaCall(SMALLUNSGN mod) {
|
||||
Term ts[4];
|
||||
ts[0] = ARG1;
|
||||
ts[1] = current_cp_as_integer(); /* p_save_cp */
|
||||
ts[2] = ARG1;
|
||||
ts[3] = ModuleName[mod];
|
||||
return(_YAP_MkApplTerm(PredMetaCall->FunctorOfPred,4,ts));
|
||||
return(Yap_MkApplTerm(PredMetaCall->FunctorOfPred,4,ts));
|
||||
}
|
||||
|
||||
static Int
|
||||
@ -94,7 +94,7 @@ CallError(yap_error_number err, SMALLUNSGN mod)
|
||||
if (yap_flags[LANGUAGE_MODE_FLAG] == 1) {
|
||||
return(CallMetaCall(mod));
|
||||
} else {
|
||||
_YAP_Error(err, ARG1, "call/1");
|
||||
Yap_Error(err, ARG1, "call/1");
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
@ -121,7 +121,7 @@ CallClause(PredEntry *pen, unsigned int arity, Int position)
|
||||
DEPTH -= MkIntConstant(2);
|
||||
#endif /* DEPTH_LIMIT */
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
if (_YAP_do_low_level_trace)
|
||||
if (Yap_do_low_level_trace)
|
||||
low_level_trace(enter_pred,pen,XREGS+1);
|
||||
#endif /* LOW_LEVEL_TRACE */
|
||||
ENV = YENV;
|
||||
@ -176,7 +176,7 @@ CallClause(PredEntry *pen, unsigned int arity, Int position)
|
||||
return (Unsigned(pen));
|
||||
}
|
||||
} else {
|
||||
_YAP_Error(SYSTEM_ERROR,ARG1,"debugger tries to debug clause for builtin");
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"debugger tries to debug clause for builtin");
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
@ -194,7 +194,7 @@ p_save_cp(void)
|
||||
BIND((CELL *)t,td,bind_save_cp);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(CellPtr(t), td);
|
||||
if (CellPtr(t) < H0) _YAP_WakeUp((CELL *)t);
|
||||
if (CellPtr(t) < H0) Yap_WakeUp((CELL *)t);
|
||||
bind_save_cp:
|
||||
#endif
|
||||
return(TRUE);
|
||||
@ -203,7 +203,7 @@ p_save_cp(void)
|
||||
static Int
|
||||
EnterCreepMode(SMALLUNSGN mod) {
|
||||
PredEntry *PredSpy = RepPredProp(PredPropByFunc(FunctorSpy,0));
|
||||
Term tn = _YAP_MkApplTerm(_YAP_MkFunctor(AtomMetaCall,1),1,&ARG1);
|
||||
Term tn = Yap_MkApplTerm(Yap_MkFunctor(AtomMetaCall,1),1,&ARG1);
|
||||
ARG1 = MkPairTerm(ModuleName[mod],tn);
|
||||
CreepFlag = CalculateStackGap();
|
||||
P_before_spy = P;
|
||||
@ -219,17 +219,17 @@ PushModule(Term t,SMALLUNSGN mod) {
|
||||
Term ti[2], tf[2];
|
||||
ti[0] = tmod;
|
||||
ti[1] = ArgOfTerm(1,t);
|
||||
tf[0] = _YAP_MkApplTerm(FunctorModule,2,ti);
|
||||
tf[0] = Yap_MkApplTerm(FunctorModule,2,ti);
|
||||
ti[0] = tmod;
|
||||
ti[1] = ArgOfTerm(2,t);
|
||||
tf[1] = _YAP_MkApplTerm(FunctorModule,2,ti);
|
||||
return(_YAP_MkApplTerm(f,2,tf));
|
||||
tf[1] = Yap_MkApplTerm(FunctorModule,2,ti);
|
||||
return(Yap_MkApplTerm(f,2,tf));
|
||||
} else {
|
||||
Term ti[2], tf[1];
|
||||
ti[0] = tmod;
|
||||
ti[1] = ArgOfTerm(1,t);
|
||||
tf[0] = _YAP_MkApplTerm(FunctorModule,2,ti);
|
||||
return(_YAP_MkApplTerm(f,1,tf));
|
||||
tf[0] = Yap_MkApplTerm(FunctorModule,2,ti);
|
||||
return(Yap_MkApplTerm(f,1,tf));
|
||||
}
|
||||
}
|
||||
|
||||
@ -263,7 +263,7 @@ do_execute(Term t, SMALLUNSGN mod)
|
||||
if (f == FunctorModule) {
|
||||
Term tmod = ArgOfTerm(1,t);
|
||||
if (!IsVarTerm(tmod) && IsAtomTerm(tmod)) {
|
||||
mod = _YAP_LookupModule(tmod);
|
||||
mod = Yap_LookupModule(tmod);
|
||||
t = ArgOfTerm(2,t);
|
||||
goto restart_exec;
|
||||
}
|
||||
@ -338,7 +338,7 @@ p_execute_within(void)
|
||||
unsigned int arity;
|
||||
Prop pe;
|
||||
Atom a;
|
||||
SMALLUNSGN mod = _YAP_LookupModule(tmod);
|
||||
SMALLUNSGN mod = Yap_LookupModule(tmod);
|
||||
#ifdef SBA
|
||||
choiceptr cut_pt = (choiceptr)IntegerOfTerm(Deref(ARG2));
|
||||
#else
|
||||
@ -375,7 +375,7 @@ p_execute_within(void)
|
||||
if (f == FunctorModule) {
|
||||
Term tmod = ArgOfTerm(1,t);
|
||||
if (!IsVarTerm(tmod) && IsAtomTerm(tmod)) {
|
||||
mod = _YAP_LookupModule(tmod);
|
||||
mod = Yap_LookupModule(tmod);
|
||||
t = ArgOfTerm(2,t);
|
||||
goto restart_exec;
|
||||
}
|
||||
@ -464,7 +464,7 @@ p_execute_within2(void)
|
||||
if (f == FunctorModule) {
|
||||
Term tmod = ArgOfTerm(1,t);
|
||||
if (!IsVarTerm(tmod) && IsAtomTerm(tmod)) {
|
||||
mod = _YAP_LookupModule(tmod);
|
||||
mod = Yap_LookupModule(tmod);
|
||||
t = ArgOfTerm(2,t);
|
||||
goto restart_exec;
|
||||
}
|
||||
@ -557,11 +557,11 @@ p_execute0(void)
|
||||
Term tmod = Deref(ARG2);
|
||||
unsigned int arity;
|
||||
Prop pe;
|
||||
SMALLUNSGN mod = _YAP_LookupModule(tmod);
|
||||
SMALLUNSGN mod = Yap_LookupModule(tmod);
|
||||
|
||||
restart_exec:
|
||||
if (IsVarTerm(t)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,ARG3,"call/1");
|
||||
Yap_Error(INSTANTIATION_ERROR,ARG3,"call/1");
|
||||
return(FALSE);
|
||||
} else if (IsAtomTerm(t)) {
|
||||
Atom a = AtomOfTerm(t);
|
||||
@ -576,7 +576,7 @@ p_execute0(void)
|
||||
if (f == FunctorModule) {
|
||||
Term tmod = ArgOfTerm(1,t);
|
||||
if (!IsVarTerm(tmod) && IsAtomTerm(tmod)) {
|
||||
mod = _YAP_LookupModule(tmod);
|
||||
mod = Yap_LookupModule(tmod);
|
||||
t = ArgOfTerm(2,t);
|
||||
goto restart_exec;
|
||||
}
|
||||
@ -602,7 +602,7 @@ p_execute0(void)
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
_YAP_Error(TYPE_ERROR_CALLABLE,ARG3,"call/1");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE,ARG3,"call/1");
|
||||
return(FALSE);
|
||||
}
|
||||
/* N = arity; */
|
||||
@ -614,7 +614,7 @@ static Int
|
||||
p_execute_0(void)
|
||||
{ /* '$execute_0'(Goal) */
|
||||
Term t = Deref(ARG1);
|
||||
SMALLUNSGN mod = _YAP_LookupModule(Deref(ARG2));
|
||||
SMALLUNSGN mod = Yap_LookupModule(Deref(ARG2));
|
||||
Prop pe;
|
||||
|
||||
if (IsAtomTerm(t)) {
|
||||
@ -627,7 +627,7 @@ p_execute_0(void)
|
||||
CELL *ptr;
|
||||
|
||||
if (IsExtensionFunctor(f)) {
|
||||
_YAP_Error(TYPE_ERROR_CALLABLE, t, "call_with_args/1");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, t, "call_with_args/1");
|
||||
return(FALSE);
|
||||
}
|
||||
pe = PredPropByFunc(f, mod);
|
||||
@ -639,7 +639,7 @@ p_execute_0(void)
|
||||
} else {
|
||||
CELL *ptr;
|
||||
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(AtomDot,2), mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(AtomDot,2), mod);
|
||||
ptr = RepPair(t);
|
||||
XREGS[1] = ptr[0];
|
||||
XREGS[2] = ptr[1];
|
||||
@ -651,18 +651,18 @@ static Int
|
||||
p_execute_1(void)
|
||||
{ /* '$execute_0'(Goal) */
|
||||
Term t = Deref(ARG1);
|
||||
SMALLUNSGN mod = _YAP_LookupModule(Deref(ARG3));
|
||||
SMALLUNSGN mod = Yap_LookupModule(Deref(ARG3));
|
||||
Prop pe;
|
||||
|
||||
if (!IsAtomTerm(t)) {
|
||||
_YAP_Error(TYPE_ERROR_ATOM,ARG1,"call_with_args/2");
|
||||
Yap_Error(TYPE_ERROR_ATOM,ARG1,"call_with_args/2");
|
||||
return(FALSE);
|
||||
}
|
||||
if (IsAtomTerm(t)) {
|
||||
Atom a;
|
||||
a = AtomOfTerm(t);
|
||||
ARG1 = ARG2;
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(a,1),mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(a,1),mod);
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor f = FunctorOfTerm(t);
|
||||
Int Arity, i;
|
||||
@ -670,12 +670,12 @@ p_execute_1(void)
|
||||
CELL *ptr;
|
||||
|
||||
if (IsExtensionFunctor(f)) {
|
||||
_YAP_Error(TYPE_ERROR_CALLABLE, t, "call_with_args/2");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, t, "call_with_args/2");
|
||||
return(FALSE);
|
||||
}
|
||||
Arity = ArityOfFunctor(f);
|
||||
a = NameOfFunctor(f);
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(a,Arity+1), mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(a,Arity+1), mod);
|
||||
XREGS[Arity+1] = ARG2;
|
||||
ptr = RepAppl(t)+1;
|
||||
for (i=1;i<=Arity;i++) {
|
||||
@ -684,7 +684,7 @@ p_execute_1(void)
|
||||
} else {
|
||||
CELL *ptr;
|
||||
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(AtomDot,3), mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(AtomDot,3), mod);
|
||||
ptr = RepPair(t);
|
||||
XREGS[3] = ARG2;
|
||||
XREGS[1] = ptr[0];
|
||||
@ -697,7 +697,7 @@ static Int
|
||||
p_execute_2(void)
|
||||
{ /* '$execute_2'(Goal) */
|
||||
Term t = Deref(ARG1);
|
||||
SMALLUNSGN mod = _YAP_LookupModule(Deref(ARG4));
|
||||
SMALLUNSGN mod = Yap_LookupModule(Deref(ARG4));
|
||||
Prop pe;
|
||||
|
||||
if (IsAtomTerm(t)) {
|
||||
@ -705,7 +705,7 @@ p_execute_2(void)
|
||||
a = AtomOfTerm(t);
|
||||
ARG1 = ARG2;
|
||||
ARG2 = ARG3;
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(a,2),mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(a,2),mod);
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor f = FunctorOfTerm(t);
|
||||
Int Arity, i;
|
||||
@ -713,12 +713,12 @@ p_execute_2(void)
|
||||
CELL *ptr;
|
||||
|
||||
if (IsExtensionFunctor(f)) {
|
||||
_YAP_Error(TYPE_ERROR_CALLABLE, t, "call_with_args/3");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, t, "call_with_args/3");
|
||||
return(FALSE);
|
||||
}
|
||||
Arity = ArityOfFunctor(f);
|
||||
a = NameOfFunctor(f);
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(a,Arity+2), mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(a,Arity+2), mod);
|
||||
XREGS[Arity+2] = ARG3;
|
||||
XREGS[Arity+1] = ARG2;
|
||||
ptr = RepAppl(t)+1;
|
||||
@ -728,7 +728,7 @@ p_execute_2(void)
|
||||
} else {
|
||||
CELL *ptr;
|
||||
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(AtomDot,4), mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(AtomDot,4), mod);
|
||||
ptr = RepPair(t);
|
||||
XREGS[4] = ARG3;
|
||||
XREGS[3] = ARG2;
|
||||
@ -742,11 +742,11 @@ static Int
|
||||
p_execute_3(void)
|
||||
{ /* '$execute_3'(Goal) */
|
||||
Term t = Deref(ARG1);
|
||||
SMALLUNSGN mod = _YAP_LookupModule(Deref(ARG5));
|
||||
SMALLUNSGN mod = Yap_LookupModule(Deref(ARG5));
|
||||
Prop pe;
|
||||
|
||||
if (!IsAtomTerm(t)) {
|
||||
_YAP_Error(TYPE_ERROR_ATOM,ARG1,"call_with_args/4");
|
||||
Yap_Error(TYPE_ERROR_ATOM,ARG1,"call_with_args/4");
|
||||
return(FALSE);
|
||||
}
|
||||
if (IsAtomTerm(t)) {
|
||||
@ -755,7 +755,7 @@ p_execute_3(void)
|
||||
ARG1 = ARG2;
|
||||
ARG2 = ARG3;
|
||||
ARG3 = ARG4;
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(a,3),mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(a,3),mod);
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor f = FunctorOfTerm(t);
|
||||
Int Arity, i;
|
||||
@ -763,12 +763,12 @@ p_execute_3(void)
|
||||
CELL *ptr;
|
||||
|
||||
if (IsExtensionFunctor(f)) {
|
||||
_YAP_Error(TYPE_ERROR_CALLABLE, t, "call_with_args/2");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, t, "call_with_args/2");
|
||||
return(FALSE);
|
||||
}
|
||||
Arity = ArityOfFunctor(f);
|
||||
a = NameOfFunctor(f);
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(a,Arity+3), mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(a,Arity+3), mod);
|
||||
XREGS[Arity+3] = ARG4;
|
||||
XREGS[Arity+2] = ARG3;
|
||||
XREGS[Arity+1] = ARG2;
|
||||
@ -779,7 +779,7 @@ p_execute_3(void)
|
||||
} else {
|
||||
CELL *ptr;
|
||||
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(AtomDot,5), mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(AtomDot,5), mod);
|
||||
ptr = RepPair(t);
|
||||
XREGS[5] = ARG4;
|
||||
XREGS[4] = ARG3;
|
||||
@ -794,7 +794,7 @@ static Int
|
||||
p_execute_4(void)
|
||||
{ /* '$execute_4'(Goal) */
|
||||
Term t = Deref(ARG1);
|
||||
SMALLUNSGN mod = _YAP_LookupModule(Deref(ARG6));
|
||||
SMALLUNSGN mod = Yap_LookupModule(Deref(ARG6));
|
||||
Prop pe;
|
||||
|
||||
if (IsAtomTerm(t)) {
|
||||
@ -804,7 +804,7 @@ p_execute_4(void)
|
||||
ARG2 = ARG3;
|
||||
ARG3 = ARG4;
|
||||
ARG4 = ARG5;
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(a,4),mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(a,4),mod);
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor f = FunctorOfTerm(t);
|
||||
Int Arity, i;
|
||||
@ -812,12 +812,12 @@ p_execute_4(void)
|
||||
CELL *ptr;
|
||||
|
||||
if (IsExtensionFunctor(f)) {
|
||||
_YAP_Error(TYPE_ERROR_CALLABLE, t, "call_with_args/5");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, t, "call_with_args/5");
|
||||
return(FALSE);
|
||||
}
|
||||
Arity = ArityOfFunctor(f);
|
||||
a = NameOfFunctor(f);
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(a,Arity+4), mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(a,Arity+4), mod);
|
||||
XREGS[Arity+4] = ARG5;
|
||||
XREGS[Arity+3] = ARG4;
|
||||
XREGS[Arity+2] = ARG3;
|
||||
@ -829,7 +829,7 @@ p_execute_4(void)
|
||||
} else {
|
||||
CELL *ptr;
|
||||
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(AtomDot,6), mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(AtomDot,6), mod);
|
||||
ptr = RepPair(t);
|
||||
XREGS[6] = ARG5;
|
||||
XREGS[5] = ARG4;
|
||||
@ -845,7 +845,7 @@ static Int
|
||||
p_execute_5(void)
|
||||
{ /* '$execute_5'(Goal) */
|
||||
Term t = Deref(ARG1);
|
||||
SMALLUNSGN mod = _YAP_LookupModule(Deref(ARG7));
|
||||
SMALLUNSGN mod = Yap_LookupModule(Deref(ARG7));
|
||||
Prop pe;
|
||||
|
||||
if (IsAtomTerm(t)) {
|
||||
@ -856,7 +856,7 @@ p_execute_5(void)
|
||||
ARG3 = ARG4;
|
||||
ARG4 = ARG5;
|
||||
ARG5 = ARG6;
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(a,5),mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(a,5),mod);
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor f = FunctorOfTerm(t);
|
||||
Int Arity, i;
|
||||
@ -864,12 +864,12 @@ p_execute_5(void)
|
||||
CELL *ptr;
|
||||
|
||||
if (IsExtensionFunctor(f)) {
|
||||
_YAP_Error(TYPE_ERROR_CALLABLE, t, "call_with_args/6");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, t, "call_with_args/6");
|
||||
return(FALSE);
|
||||
}
|
||||
Arity = ArityOfFunctor(f);
|
||||
a = NameOfFunctor(f);
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(a,Arity+5), mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(a,Arity+5), mod);
|
||||
XREGS[Arity+5] = ARG6;
|
||||
XREGS[Arity+4] = ARG5;
|
||||
XREGS[Arity+3] = ARG4;
|
||||
@ -882,7 +882,7 @@ p_execute_5(void)
|
||||
} else {
|
||||
CELL *ptr;
|
||||
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(AtomDot,7), mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(AtomDot,7), mod);
|
||||
ptr = RepPair(t);
|
||||
XREGS[7] = ARG6;
|
||||
XREGS[6] = ARG5;
|
||||
@ -899,7 +899,7 @@ static Int
|
||||
p_execute_6(void)
|
||||
{ /* '$execute_6'(Goal) */
|
||||
Term t = Deref(ARG1);
|
||||
SMALLUNSGN mod = _YAP_LookupModule(Deref(ARG8));
|
||||
SMALLUNSGN mod = Yap_LookupModule(Deref(ARG8));
|
||||
Prop pe;
|
||||
|
||||
if (IsAtomTerm(t)) {
|
||||
@ -911,7 +911,7 @@ p_execute_6(void)
|
||||
ARG4 = ARG5;
|
||||
ARG5 = ARG6;
|
||||
ARG6 = ARG7;
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(a,6),mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(a,6),mod);
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor f = FunctorOfTerm(t);
|
||||
Int Arity, i;
|
||||
@ -919,12 +919,12 @@ p_execute_6(void)
|
||||
CELL *ptr;
|
||||
|
||||
if (IsExtensionFunctor(f)) {
|
||||
_YAP_Error(TYPE_ERROR_CALLABLE, t, "call_with_args/7");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, t, "call_with_args/7");
|
||||
return(FALSE);
|
||||
}
|
||||
Arity = ArityOfFunctor(f);
|
||||
a = NameOfFunctor(f);
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(a,Arity+6), mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(a,Arity+6), mod);
|
||||
XREGS[Arity+6] = ARG7;
|
||||
XREGS[Arity+5] = ARG6;
|
||||
XREGS[Arity+4] = ARG5;
|
||||
@ -938,7 +938,7 @@ p_execute_6(void)
|
||||
} else {
|
||||
CELL *ptr;
|
||||
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(AtomDot,8), mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(AtomDot,8), mod);
|
||||
ptr = RepPair(t);
|
||||
XREGS[8] = ARG7;
|
||||
XREGS[7] = ARG6;
|
||||
@ -956,7 +956,7 @@ static Int
|
||||
p_execute_7(void)
|
||||
{ /* '$execute_7'(Goal) */
|
||||
Term t = Deref(ARG1);
|
||||
SMALLUNSGN mod = _YAP_LookupModule(Deref(ARG9));
|
||||
SMALLUNSGN mod = Yap_LookupModule(Deref(ARG9));
|
||||
Prop pe;
|
||||
|
||||
if (IsAtomTerm(t)) {
|
||||
@ -969,7 +969,7 @@ p_execute_7(void)
|
||||
ARG5 = ARG6;
|
||||
ARG6 = ARG7;
|
||||
ARG7 = ARG8;
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(a,7),mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(a,7),mod);
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor f = FunctorOfTerm(t);
|
||||
Int Arity, i;
|
||||
@ -977,12 +977,12 @@ p_execute_7(void)
|
||||
CELL *ptr;
|
||||
|
||||
if (IsExtensionFunctor(f)) {
|
||||
_YAP_Error(TYPE_ERROR_CALLABLE, t, "call_with_args/8");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, t, "call_with_args/8");
|
||||
return(FALSE);
|
||||
}
|
||||
Arity = ArityOfFunctor(f);
|
||||
a = NameOfFunctor(f);
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(a,Arity+7), mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(a,Arity+7), mod);
|
||||
XREGS[Arity+7] = ARG8;
|
||||
XREGS[Arity+6] = ARG7;
|
||||
XREGS[Arity+5] = ARG6;
|
||||
@ -997,7 +997,7 @@ p_execute_7(void)
|
||||
} else {
|
||||
CELL *ptr;
|
||||
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(AtomDot,9), mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(AtomDot,9), mod);
|
||||
ptr = RepPair(t);
|
||||
XREGS[9] = ARG8;
|
||||
XREGS[8] = ARG7;
|
||||
@ -1016,7 +1016,7 @@ static Int
|
||||
p_execute_8(void)
|
||||
{ /* '$execute_8'(Goal) */
|
||||
Term t = Deref(ARG1);
|
||||
SMALLUNSGN mod = _YAP_LookupModule(Deref(ARG10));
|
||||
SMALLUNSGN mod = Yap_LookupModule(Deref(ARG10));
|
||||
Prop pe;
|
||||
|
||||
if (IsAtomTerm(t)) {
|
||||
@ -1030,7 +1030,7 @@ p_execute_8(void)
|
||||
ARG6 = ARG7;
|
||||
ARG7 = ARG8;
|
||||
ARG8 = ARG9;
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(a,8),mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(a,8),mod);
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor f = FunctorOfTerm(t);
|
||||
Int Arity, i;
|
||||
@ -1038,12 +1038,12 @@ p_execute_8(void)
|
||||
CELL *ptr;
|
||||
|
||||
if (IsExtensionFunctor(f)) {
|
||||
_YAP_Error(TYPE_ERROR_CALLABLE, t, "call_with_args/9");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, t, "call_with_args/9");
|
||||
return(FALSE);
|
||||
}
|
||||
Arity = ArityOfFunctor(f);
|
||||
a = NameOfFunctor(f);
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(a,Arity+8), mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(a,Arity+8), mod);
|
||||
XREGS[Arity+8] = ARG9;
|
||||
XREGS[Arity+7] = ARG8;
|
||||
XREGS[Arity+6] = ARG7;
|
||||
@ -1059,7 +1059,7 @@ p_execute_8(void)
|
||||
} else {
|
||||
CELL *ptr;
|
||||
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(AtomDot,10), mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(AtomDot,10), mod);
|
||||
ptr = RepPair(t);
|
||||
XREGS[10] = ARG9;
|
||||
XREGS[9] = ARG8;
|
||||
@ -1079,7 +1079,7 @@ static Int
|
||||
p_execute_9(void)
|
||||
{ /* '$execute_9'(Goal) */
|
||||
Term t = Deref(ARG1);
|
||||
SMALLUNSGN mod = _YAP_LookupModule(Deref(ARG11));
|
||||
SMALLUNSGN mod = Yap_LookupModule(Deref(ARG11));
|
||||
Prop pe;
|
||||
|
||||
if (IsAtomTerm(t)) {
|
||||
@ -1094,7 +1094,7 @@ p_execute_9(void)
|
||||
ARG7 = ARG8;
|
||||
ARG8 = ARG9;
|
||||
ARG9 = ARG10;
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(a,9),mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(a,9),mod);
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor f = FunctorOfTerm(t);
|
||||
Int Arity, i;
|
||||
@ -1102,12 +1102,12 @@ p_execute_9(void)
|
||||
CELL *ptr;
|
||||
|
||||
if (IsExtensionFunctor(f)) {
|
||||
_YAP_Error(TYPE_ERROR_CALLABLE, t, "call_with_args/10");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, t, "call_with_args/10");
|
||||
return(FALSE);
|
||||
}
|
||||
Arity = ArityOfFunctor(f);
|
||||
a = NameOfFunctor(f);
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(a,Arity+9), mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(a,Arity+9), mod);
|
||||
XREGS[Arity+9] = ARG10;
|
||||
XREGS[Arity+8] = ARG9;
|
||||
XREGS[Arity+7] = ARG8;
|
||||
@ -1124,7 +1124,7 @@ p_execute_9(void)
|
||||
} else {
|
||||
CELL *ptr;
|
||||
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(AtomDot,11), mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(AtomDot,11), mod);
|
||||
ptr = RepPair(t);
|
||||
XREGS[11] = ARG10;
|
||||
XREGS[10] = ARG9;
|
||||
@ -1145,7 +1145,7 @@ static Int
|
||||
p_execute_10(void)
|
||||
{ /* '$execute_10'(Goal) */
|
||||
Term t = Deref(ARG1);
|
||||
SMALLUNSGN mod = _YAP_LookupModule(Deref(ARG12));
|
||||
SMALLUNSGN mod = Yap_LookupModule(Deref(ARG12));
|
||||
Prop pe;
|
||||
|
||||
if (IsAtomTerm(t)) {
|
||||
@ -1161,7 +1161,7 @@ p_execute_10(void)
|
||||
ARG8 = ARG9;
|
||||
ARG9 = ARG10;
|
||||
ARG10 = ARG11;
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(a,10),mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(a,10),mod);
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor f = FunctorOfTerm(t);
|
||||
Int Arity, i;
|
||||
@ -1169,12 +1169,12 @@ p_execute_10(void)
|
||||
CELL *ptr;
|
||||
|
||||
if (IsExtensionFunctor(f)) {
|
||||
_YAP_Error(TYPE_ERROR_CALLABLE, t, "call_with_args/11");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, t, "call_with_args/11");
|
||||
return(FALSE);
|
||||
}
|
||||
Arity = ArityOfFunctor(f);
|
||||
a = NameOfFunctor(f);
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(a,Arity+10), mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(a,Arity+10), mod);
|
||||
XREGS[Arity+10] = ARG11;
|
||||
XREGS[Arity+9] = ARG10;
|
||||
XREGS[Arity+8] = ARG9;
|
||||
@ -1192,7 +1192,7 @@ p_execute_10(void)
|
||||
} else {
|
||||
CELL *ptr;
|
||||
|
||||
pe = PredPropByFunc(_YAP_MkFunctor(AtomDot,12), mod);
|
||||
pe = PredPropByFunc(Yap_MkFunctor(AtomDot,12), mod);
|
||||
ptr = RepPair(t);
|
||||
XREGS[12] = ARG11;
|
||||
XREGS[11] = ARG10;
|
||||
@ -1215,9 +1215,9 @@ static Int
|
||||
p_execute_depth_limit(void) {
|
||||
Term d = Deref(ARG2);
|
||||
if (IsVarTerm(d)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,d,"depth_bound_call/2");
|
||||
Yap_Error(INSTANTIATION_ERROR,d,"depth_bound_call/2");
|
||||
} else if (!IsIntTerm(d)) {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, d, "depth_bound_call/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, d, "depth_bound_call/2");
|
||||
return(FALSE);
|
||||
}
|
||||
DEPTH = MkIntTerm(IntOfTerm(d)*2);
|
||||
@ -1239,7 +1239,7 @@ p_at_execute(void)
|
||||
unsigned int arity;
|
||||
Prop pe;
|
||||
Atom a;
|
||||
SMALLUNSGN mod = _YAP_LookupModule(tmod);
|
||||
SMALLUNSGN mod = Yap_LookupModule(tmod);
|
||||
|
||||
restart_exec:
|
||||
if (IsAtomTerm(t)) {
|
||||
@ -1256,14 +1256,14 @@ p_at_execute(void)
|
||||
if (f == FunctorModule) {
|
||||
Term tmod = ArgOfTerm(1,t);
|
||||
if (!IsVarTerm(tmod) && IsAtomTerm(tmod)) {
|
||||
mod = _YAP_LookupModule(tmod);
|
||||
mod = Yap_LookupModule(tmod);
|
||||
t = ArgOfTerm(2,t);
|
||||
goto restart_exec;
|
||||
}
|
||||
if (IsVarTerm(tmod)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, ARG1, "calling clause in debugger");
|
||||
Yap_Error(INSTANTIATION_ERROR, ARG1, "calling clause in debugger");
|
||||
}
|
||||
_YAP_Error(TYPE_ERROR_ATOM, ARG1, "calling clause in debugger");
|
||||
Yap_Error(TYPE_ERROR_ATOM, ARG1, "calling clause in debugger");
|
||||
}
|
||||
pe = PredPropByFunc(f,mod);
|
||||
if (RepPredProp(pe)->PredFlags & PushModPredFlag) {
|
||||
@ -1300,12 +1300,12 @@ static int
|
||||
exec_absmi(int top)
|
||||
{
|
||||
int lval;
|
||||
if (top && (lval = sigsetjmp (_YAP_RestartEnv, 1)) != 0) {
|
||||
if (top && (lval = sigsetjmp (Yap_RestartEnv, 1)) != 0) {
|
||||
switch(lval) {
|
||||
case 1:
|
||||
{ /* restart */
|
||||
/* otherwise, SetDBForThrow will fail entering critical mode */
|
||||
_YAP_PrologMode = UserMode;
|
||||
Yap_PrologMode = UserMode;
|
||||
/* find out where to cut to */
|
||||
#if defined(__GNUC__)
|
||||
#if defined(hppa) || defined(__alpha)
|
||||
@ -1320,18 +1320,18 @@ exec_absmi(int top)
|
||||
yap_flags[SPY_CREEP_FLAG] = 0;
|
||||
CreepFlag = CalculateStackGap();
|
||||
P = (yamop *)FAILCODE;
|
||||
_YAP_PrologMode = UserMode;
|
||||
Yap_PrologMode = UserMode;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
/* arithmetic exception */
|
||||
/* must be done here, otherwise siglongjmp will clobber all the registers */
|
||||
_YAP_Error(_YAP_matherror,TermNil,NULL);
|
||||
Yap_Error(Yap_matherror,TermNil,NULL);
|
||||
/* reset the registers so that we don't have trash in abstract machine */
|
||||
_YAP_set_fpu_exceptions(yap_flags[LANGUAGE_MODE_FLAG] == 1);
|
||||
Yap_set_fpu_exceptions(yap_flags[LANGUAGE_MODE_FLAG] == 1);
|
||||
P = (yamop *)FAILCODE;
|
||||
_YAP_PrologMode = UserMode;
|
||||
Yap_PrologMode = UserMode;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
@ -1340,12 +1340,12 @@ exec_absmi(int top)
|
||||
}
|
||||
default:
|
||||
/* do nothing */
|
||||
_YAP_PrologMode = UserMode;
|
||||
Yap_PrologMode = UserMode;
|
||||
}
|
||||
} else {
|
||||
_YAP_PrologMode = UserMode;
|
||||
Yap_PrologMode = UserMode;
|
||||
}
|
||||
return(_YAP_absmi(0));
|
||||
return(Yap_absmi(0));
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1396,20 +1396,20 @@ do_goal(CODEADDR CodeAdr, int arity, CELL *pt, int args_to_save, int top)
|
||||
YENV[E_CB] = Unsigned (B);
|
||||
P = (yamop *) CodeAdr;
|
||||
CP = YESCODE;
|
||||
S = CellPtr (RepPredProp (PredPropByFunc (_YAP_MkFunctor(AtomCall, 1),0))); /* A1 mishaps */
|
||||
S = CellPtr (RepPredProp (PredPropByFunc (Yap_MkFunctor(AtomCall, 1),0))); /* A1 mishaps */
|
||||
|
||||
return(exec_absmi(top));
|
||||
}
|
||||
|
||||
int
|
||||
_YAP_exec_absmi(int top)
|
||||
Yap_exec_absmi(int top)
|
||||
{
|
||||
return exec_absmi(top);
|
||||
}
|
||||
|
||||
|
||||
Int
|
||||
_YAP_execute_goal(Term t, int nargs, SMALLUNSGN mod)
|
||||
Yap_execute_goal(Term t, int nargs, SMALLUNSGN mod)
|
||||
{
|
||||
Int out;
|
||||
CODEADDR CodeAdr;
|
||||
@ -1433,7 +1433,7 @@ _YAP_execute_goal(Term t, int nargs, SMALLUNSGN mod)
|
||||
Functor f = FunctorOfTerm(t);
|
||||
|
||||
if (IsBlobFunctor(f)) {
|
||||
_YAP_Error(TYPE_ERROR_CALLABLE,t,"call/1");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE,t,"call/1");
|
||||
return(FALSE);
|
||||
}
|
||||
/* I cannot use the standard macro here because
|
||||
@ -1442,7 +1442,7 @@ _YAP_execute_goal(Term t, int nargs, SMALLUNSGN mod)
|
||||
pt = RepAppl(t)+1;
|
||||
pe = PredPropByFunc(f, mod);
|
||||
} else {
|
||||
_YAP_Error(TYPE_ERROR_CALLABLE,t,"call/1");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE,t,"call/1");
|
||||
return(FALSE);
|
||||
}
|
||||
ppe = RepPredProp(pe);
|
||||
@ -1508,13 +1508,13 @@ _YAP_execute_goal(Term t, int nargs, SMALLUNSGN mod)
|
||||
HB = PROTECT_FROZEN_H(B);
|
||||
return(FALSE);
|
||||
} else {
|
||||
_YAP_Error(SYSTEM_ERROR,TermNil,"emulator crashed");
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,"emulator crashed");
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_trust_last(void)
|
||||
Yap_trust_last(void)
|
||||
{
|
||||
ASP = B->cp_env;
|
||||
P = (yamop *)(B->cp_env[E_CP]);
|
||||
@ -1533,7 +1533,7 @@ _YAP_trust_last(void)
|
||||
}
|
||||
|
||||
int
|
||||
_YAP_RunTopGoal(Term t)
|
||||
Yap_RunTopGoal(Term t)
|
||||
{
|
||||
CODEADDR CodeAdr;
|
||||
Prop pe;
|
||||
@ -1553,13 +1553,13 @@ _YAP_RunTopGoal(Term t)
|
||||
Functor f = FunctorOfTerm(t);
|
||||
|
||||
if (IsBlobFunctor(f)) {
|
||||
_YAP_Error(TYPE_ERROR_CALLABLE,t,"call/1");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE,t,"call/1");
|
||||
return(FALSE);
|
||||
}
|
||||
if (f == FunctorModule) {
|
||||
Term tmod = ArgOfTerm(1,t);
|
||||
if (!IsVarTerm(tmod) && IsAtomTerm(tmod)) {
|
||||
mod = _YAP_LookupModule(tmod);
|
||||
mod = Yap_LookupModule(tmod);
|
||||
t = ArgOfTerm(2,t);
|
||||
goto restart_runtopgoal;
|
||||
}
|
||||
@ -1567,11 +1567,11 @@ _YAP_RunTopGoal(Term t)
|
||||
/* I cannot use the standard macro here because
|
||||
otherwise I would dereference the argument and
|
||||
might skip a svar */
|
||||
pe = _YAP_GetPredPropByFunc(f, CurrentModule);
|
||||
pe = Yap_GetPredPropByFunc(f, CurrentModule);
|
||||
pt = RepAppl(t)+1;
|
||||
arity = ArityOfFunctor(f);
|
||||
} else {
|
||||
_YAP_Error(TYPE_ERROR_CALLABLE,t,"call/1");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE,t,"call/1");
|
||||
return(FALSE);
|
||||
}
|
||||
ppe = RepPredProp(pe);
|
||||
@ -1586,9 +1586,9 @@ _YAP_RunTopGoal(Term t)
|
||||
return(FALSE);
|
||||
}
|
||||
CodeAdr = ppe->CodeOfPred;
|
||||
if (_YAP_TrailTop - HeapTop < 2048) {
|
||||
_YAP_PrologMode = BootMode;
|
||||
_YAP_Error(SYSTEM_ERROR,TermNil,
|
||||
if (Yap_TrailTop - HeapTop < 2048) {
|
||||
Yap_PrologMode = BootMode;
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,
|
||||
"unable to boot because of too little heap space");
|
||||
}
|
||||
goal_out = do_goal(CodeAdr, arity, pt, 0, TRUE);
|
||||
@ -1617,7 +1617,7 @@ p_restore_regs(void)
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
if (IsVarTerm(t)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t,"support for coroutining");
|
||||
Yap_Error(INSTANTIATION_ERROR,t,"support for coroutining");
|
||||
return(FALSE);
|
||||
}
|
||||
if (IsAtomTerm(t)) return(TRUE);
|
||||
@ -1633,7 +1633,7 @@ p_restore_regs2(void)
|
||||
Term t = Deref(ARG1), d0;
|
||||
choiceptr pt0;
|
||||
if (IsVarTerm(t)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t,"support for coroutining");
|
||||
Yap_Error(INSTANTIATION_ERROR,t,"support for coroutining");
|
||||
return(FALSE);
|
||||
}
|
||||
d0 = Deref(ARG2);
|
||||
@ -1641,7 +1641,7 @@ p_restore_regs2(void)
|
||||
restore_regs(t);
|
||||
}
|
||||
if (IsVarTerm(d0)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,d0,"support for coroutining");
|
||||
Yap_Error(INSTANTIATION_ERROR,d0,"support for coroutining");
|
||||
return(FALSE);
|
||||
}
|
||||
if (!IsIntegerTerm(d0)) {
|
||||
@ -1714,9 +1714,9 @@ JumpToEnv(Term t) {
|
||||
if (B == NULL) {
|
||||
B = B0;
|
||||
#if PUSH_REGS
|
||||
restore_absmi_regs(&_YAP_standard_regs);
|
||||
restore_absmi_regs(&Yap_standard_regs);
|
||||
#endif
|
||||
siglongjmp(_YAP_RestartEnv,1);
|
||||
siglongjmp(Yap_RestartEnv,1);
|
||||
}
|
||||
/* is it a continuation? */
|
||||
env = B->cp_env;
|
||||
@ -1747,7 +1747,7 @@ JumpToEnv(Term t) {
|
||||
}
|
||||
|
||||
Int
|
||||
_YAP_JumpToEnv(Term t) {
|
||||
Yap_JumpToEnv(Term t) {
|
||||
return JumpToEnv(t);
|
||||
}
|
||||
|
||||
@ -1759,23 +1759,23 @@ p_jump_env(void) {
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_InitYaamRegs(void)
|
||||
Yap_InitYaamRegs(void)
|
||||
{
|
||||
#if PUSH_REGS
|
||||
/* Guarantee that after a longjmp we go back to the original abstract
|
||||
machine registers */
|
||||
_YAP_regp = &_YAP_standard_regs;
|
||||
Yap_regp = &Yap_standard_regs;
|
||||
#endif /* PUSH_REGS */
|
||||
_YAP_PutValue (AtomBreak, MkIntTerm (0));
|
||||
_YAP_PutValue (AtomIndex, MkAtomTerm (AtomTrue));
|
||||
Yap_PutValue (AtomBreak, MkIntTerm (0));
|
||||
Yap_PutValue (AtomIndex, MkAtomTerm (AtomTrue));
|
||||
AuxSp = (CELL *)AuxTop;
|
||||
TR = (tr_fr_ptr)_YAP_TrailBase;
|
||||
TR = (tr_fr_ptr)Yap_TrailBase;
|
||||
#ifdef COROUTINING
|
||||
H = H0 = ((CELL *) _YAP_GlobalBase)+ 2048;
|
||||
H = H0 = ((CELL *) Yap_GlobalBase)+ 2048;
|
||||
#else
|
||||
H = H0 = (CELL *) _YAP_GlobalBase;
|
||||
H = H0 = (CELL *) Yap_GlobalBase;
|
||||
#endif
|
||||
LCL0 = ASP = (CELL *) _YAP_LocalBase;
|
||||
LCL0 = ASP = (CELL *) Yap_LocalBase;
|
||||
/* notice that an initial choice-point and environment
|
||||
*must* be created since for the garbage collector to work */
|
||||
B = NULL;
|
||||
@ -1798,43 +1798,43 @@ _YAP_InitYaamRegs(void)
|
||||
/* for slots to work */
|
||||
*--ASP = MkIntTerm(0);
|
||||
#if COROUTINING
|
||||
RESET_VARIABLE((CELL *)_YAP_GlobalBase);
|
||||
DelayedVars = _YAP_NewTimedVar((CELL)_YAP_GlobalBase);
|
||||
WokenGoals = _YAP_NewTimedVar(TermNil);
|
||||
MutableList = _YAP_NewTimedVar(TermNil);
|
||||
AttsMutableList = _YAP_NewTimedVar(TermNil);
|
||||
RESET_VARIABLE((CELL *)Yap_GlobalBase);
|
||||
DelayedVars = Yap_NewTimedVar((CELL)Yap_GlobalBase);
|
||||
WokenGoals = Yap_NewTimedVar(TermNil);
|
||||
MutableList = Yap_NewTimedVar(TermNil);
|
||||
AttsMutableList = Yap_NewTimedVar(TermNil);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_InitExecFs(void)
|
||||
Yap_InitExecFs(void)
|
||||
{
|
||||
_YAP_InitCPred("$execute", 1, p_execute, 0);
|
||||
_YAP_InitCPred("$execute_in_mod", 2, p_execute_in_mod, 0);
|
||||
_YAP_InitCPred("$execute_within", 4, p_execute_within, 0);
|
||||
_YAP_InitCPred("$execute_within", 1, p_execute_within2, 0);
|
||||
_YAP_InitCPred("$last_execute_within", 1, p_execute_within2, 0);
|
||||
_YAP_InitCPred("$execute", 3, p_at_execute, 0);
|
||||
_YAP_InitCPred("$call_with_args", 2, p_execute_0, 0);
|
||||
_YAP_InitCPred("$call_with_args", 3, p_execute_1, 0);
|
||||
_YAP_InitCPred("$call_with_args", 4, p_execute_2, 0);
|
||||
_YAP_InitCPred("$call_with_args", 5, p_execute_3, 0);
|
||||
_YAP_InitCPred("$call_with_args", 6, p_execute_4, 0);
|
||||
_YAP_InitCPred("$call_with_args", 7, p_execute_5, 0);
|
||||
_YAP_InitCPred("$call_with_args", 8, p_execute_6, 0);
|
||||
_YAP_InitCPred("$call_with_args", 9, p_execute_7, 0);
|
||||
_YAP_InitCPred("$call_with_args", 10, p_execute_8, 0);
|
||||
_YAP_InitCPred("$call_with_args", 11, p_execute_9, 0);
|
||||
_YAP_InitCPred("$call_with_args", 12, p_execute_10, 0);
|
||||
Yap_InitCPred("$execute", 1, p_execute, 0);
|
||||
Yap_InitCPred("$execute_in_mod", 2, p_execute_in_mod, 0);
|
||||
Yap_InitCPred("$execute_within", 4, p_execute_within, 0);
|
||||
Yap_InitCPred("$execute_within", 1, p_execute_within2, 0);
|
||||
Yap_InitCPred("$last_execute_within", 1, p_execute_within2, 0);
|
||||
Yap_InitCPred("$execute", 3, p_at_execute, 0);
|
||||
Yap_InitCPred("$call_with_args", 2, p_execute_0, 0);
|
||||
Yap_InitCPred("$call_with_args", 3, p_execute_1, 0);
|
||||
Yap_InitCPred("$call_with_args", 4, p_execute_2, 0);
|
||||
Yap_InitCPred("$call_with_args", 5, p_execute_3, 0);
|
||||
Yap_InitCPred("$call_with_args", 6, p_execute_4, 0);
|
||||
Yap_InitCPred("$call_with_args", 7, p_execute_5, 0);
|
||||
Yap_InitCPred("$call_with_args", 8, p_execute_6, 0);
|
||||
Yap_InitCPred("$call_with_args", 9, p_execute_7, 0);
|
||||
Yap_InitCPred("$call_with_args", 10, p_execute_8, 0);
|
||||
Yap_InitCPred("$call_with_args", 11, p_execute_9, 0);
|
||||
Yap_InitCPred("$call_with_args", 12, p_execute_10, 0);
|
||||
#ifdef DEPTH_LIMIT
|
||||
_YAP_InitCPred("$execute_under_depth_limit", 2, p_execute_depth_limit, 0);
|
||||
Yap_InitCPred("$execute_under_depth_limit", 2, p_execute_depth_limit, 0);
|
||||
#endif
|
||||
_YAP_InitCPred("$execute0", 2, p_execute0, 0);
|
||||
_YAP_InitCPred("$save_current_choice_point", 1, p_save_cp, 0);
|
||||
_YAP_InitCPred("$pred_goal_expansion_on", 0, p_pred_goal_expansion_on, SafePredFlag);
|
||||
_YAP_InitCPred("$restore_regs", 1, p_restore_regs, SafePredFlag);
|
||||
_YAP_InitCPred("$restore_regs", 2, p_restore_regs2, SafePredFlag);
|
||||
_YAP_InitCPred("$clean_ifcp", 1, p_clean_ifcp, SafePredFlag);
|
||||
_YAP_InitCPred("$jump_env_and_store_ball", 1, p_jump_env, 0);
|
||||
Yap_InitCPred("$execute0", 2, p_execute0, 0);
|
||||
Yap_InitCPred("$save_current_choice_point", 1, p_save_cp, 0);
|
||||
Yap_InitCPred("$pred_goal_expansion_on", 0, p_pred_goal_expansion_on, SafePredFlag);
|
||||
Yap_InitCPred("$restore_regs", 1, p_restore_regs, SafePredFlag);
|
||||
Yap_InitCPred("$restore_regs", 2, p_restore_regs2, SafePredFlag);
|
||||
Yap_InitCPred("$clean_ifcp", 1, p_clean_ifcp, SafePredFlag);
|
||||
Yap_InitCPred("$jump_env_and_store_ball", 1, p_jump_env, 0);
|
||||
}
|
||||
|
||||
|
228
C/grow.c
228
C/grow.c
@ -99,24 +99,24 @@ static void
|
||||
SetHeapRegs(void)
|
||||
{
|
||||
#ifdef undf7
|
||||
fprintf(_YAP_stderr,"HeapBase = %x\tHeapTop=%x\nGlobalBase=%x\tGlobalTop=%x\nLocalBase=%x\tLocatTop=%x\n", _YAP_HeapBase, HeapTop, _YAP_GlobalBase, H, LCL0, ASP);
|
||||
fprintf(Yap_stderr,"HeapBase = %x\tHeapTop=%x\nGlobalBase=%x\tGlobalTop=%x\nLocalBase=%x\tLocatTop=%x\n", Yap_HeapBase, HeapTop, Yap_GlobalBase, H, LCL0, ASP);
|
||||
#endif
|
||||
/* The old stack pointers */
|
||||
OldLCL0 = LCL0;
|
||||
OldASP = ASP;
|
||||
OldGlobalBase = (CELL *)_YAP_GlobalBase;
|
||||
OldGlobalBase = (CELL *)Yap_GlobalBase;
|
||||
OldH = H;
|
||||
OldH0 = H0;
|
||||
OldTrailBase = _YAP_TrailBase;
|
||||
OldTrailTop = _YAP_TrailTop;
|
||||
OldTrailBase = Yap_TrailBase;
|
||||
OldTrailTop = Yap_TrailTop;
|
||||
OldTR = TR;
|
||||
OldHeapBase = _YAP_HeapBase;
|
||||
OldHeapBase = Yap_HeapBase;
|
||||
OldHeapTop = HeapTop;
|
||||
/* Adjust stack addresses */
|
||||
_YAP_TrailBase = TrailAddrAdjust(_YAP_TrailBase);
|
||||
_YAP_TrailTop = TrailAddrAdjust(_YAP_TrailTop);
|
||||
_YAP_GlobalBase = DelayAddrAdjust(_YAP_GlobalBase);
|
||||
_YAP_LocalBase = LocalAddrAdjust(_YAP_LocalBase);
|
||||
Yap_TrailBase = TrailAddrAdjust(Yap_TrailBase);
|
||||
Yap_TrailTop = TrailAddrAdjust(Yap_TrailTop);
|
||||
Yap_GlobalBase = DelayAddrAdjust(Yap_GlobalBase);
|
||||
Yap_LocalBase = LocalAddrAdjust(Yap_LocalBase);
|
||||
AuxSp = PtoDelayAdjust(AuxSp);
|
||||
AuxTop = DelayAddrAdjust(AuxTop);
|
||||
/* The registers pointing to one of the stacks */
|
||||
@ -155,16 +155,16 @@ SetStackRegs(void)
|
||||
OldASP = ASP;
|
||||
OldH = H;
|
||||
OldH0 = H0;
|
||||
OldGlobalBase = (CELL *)_YAP_GlobalBase;
|
||||
OldTrailTop = _YAP_TrailTop;
|
||||
OldTrailBase = _YAP_TrailBase;
|
||||
OldGlobalBase = (CELL *)Yap_GlobalBase;
|
||||
OldTrailTop = Yap_TrailTop;
|
||||
OldTrailBase = Yap_TrailBase;
|
||||
OldTR = TR;
|
||||
OldHeapBase = _YAP_HeapBase;
|
||||
OldHeapBase = Yap_HeapBase;
|
||||
OldHeapTop = HeapTop;
|
||||
/* The local and aux stack addresses */
|
||||
_YAP_TrailBase = TrailAddrAdjust(_YAP_TrailBase);
|
||||
_YAP_TrailTop = TrailAddrAdjust(_YAP_TrailTop);
|
||||
_YAP_LocalBase = LocalAddrAdjust(_YAP_LocalBase);
|
||||
Yap_TrailBase = TrailAddrAdjust(Yap_TrailBase);
|
||||
Yap_TrailTop = TrailAddrAdjust(Yap_TrailTop);
|
||||
Yap_LocalBase = LocalAddrAdjust(Yap_LocalBase);
|
||||
TR = PtoTRAdjust(TR);
|
||||
/* The registers pointing to the local stack */
|
||||
ENV = PtoLocAdjust(ENV);
|
||||
@ -200,7 +200,7 @@ MoveGlobal(void)
|
||||
* absmi.asm
|
||||
*/
|
||||
#if HAVE_MEMMOVE
|
||||
cpcellsd((CELL *)_YAP_GlobalBase, (CELL *)OldGlobalBase, OldH - (CELL *)OldGlobalBase);
|
||||
cpcellsd((CELL *)Yap_GlobalBase, (CELL *)OldGlobalBase, OldH - (CELL *)OldGlobalBase);
|
||||
#else
|
||||
cpcellsd(H, OldH, OldH - (CELL *)OldGlobalBase);
|
||||
#endif
|
||||
@ -236,7 +236,7 @@ AdjustAppl(register CELL t0)
|
||||
#ifdef DEBUG
|
||||
else {
|
||||
/* strange cell */
|
||||
/* fprintf(_YAP_stderr,"[ garbage appl %lx found in stacks by stack shifter ]\n", t0);*/
|
||||
/* fprintf(Yap_stderr,"[ garbage appl %lx found in stacks by stack shifter ]\n", t0);*/
|
||||
}
|
||||
#endif
|
||||
return(t0);
|
||||
@ -256,7 +256,7 @@ AdjustPair(register CELL t0)
|
||||
else if (IsHeapP(t))
|
||||
return (AbsPair(CellPtoHeapAdjust(t)));
|
||||
#ifdef DEBUG
|
||||
/* fprintf(_YAP_stderr,"[ garbage pair %lx found in stacks by stack shifter ]\n", t0);*/
|
||||
/* fprintf(Yap_stderr,"[ garbage pair %lx found in stacks by stack shifter ]\n", t0);*/
|
||||
#endif
|
||||
return(t0);
|
||||
}
|
||||
@ -268,7 +268,7 @@ AdjustTrail(int adjusting_heap)
|
||||
|
||||
ptt = TR;
|
||||
/* moving the trail is simple */
|
||||
while (ptt != (tr_fr_ptr)_YAP_TrailBase) {
|
||||
while (ptt != (tr_fr_ptr)Yap_TrailBase) {
|
||||
register CELL reg = TrailTerm(ptt-1);
|
||||
#ifdef FROZEN_STACKS
|
||||
register CELL reg2 = TrailVal(ptt-1);
|
||||
@ -295,7 +295,7 @@ AdjustTrail(int adjusting_heap)
|
||||
}
|
||||
#ifdef DEBUG
|
||||
else
|
||||
fprintf(_YAP_stderr,"[ garbage heap ptr %p to %lx found in trail at %p by stack shifter ]\n", ptr, (unsigned long int)*ptr, ptt);
|
||||
fprintf(Yap_stderr,"[ garbage heap ptr %p to %lx found in trail at %p by stack shifter ]\n", ptr, (unsigned long int)*ptr, ptt);
|
||||
#endif
|
||||
}
|
||||
} else if (IsPairTerm(reg)) {
|
||||
@ -367,7 +367,7 @@ AdjustGlobal(void)
|
||||
* to clean the global now that functors are just variables pointing to
|
||||
* the code
|
||||
*/
|
||||
pt = CellPtr(_YAP_GlobalBase);
|
||||
pt = CellPtr(Yap_GlobalBase);
|
||||
while (pt < H) {
|
||||
register CELL reg;
|
||||
|
||||
@ -437,7 +437,7 @@ AdjustStacksAndTrail(void)
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_AdjustStacksAndTrail(void)
|
||||
Yap_AdjustStacksAndTrail(void)
|
||||
{
|
||||
AdjustStacksAndTrail();
|
||||
}
|
||||
@ -481,7 +481,7 @@ AdjustRegs(int n)
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_AdjustRegs(int n)
|
||||
Yap_AdjustRegs(int n)
|
||||
{
|
||||
AdjustRegs(n);
|
||||
}
|
||||
@ -495,17 +495,17 @@ static_growheap(long size, int fix_code)
|
||||
|
||||
/* adjust to a multiple of 256) */
|
||||
size = AdjustPageSize(size);
|
||||
_YAP_ErrorMessage = NULL;
|
||||
if (!_YAP_ExtendWorkSpace(size)) {
|
||||
strncat(_YAP_ErrorMessage,": heap crashed against stacks", MAX_ERROR_MSG_SIZE);
|
||||
Yap_ErrorMessage = NULL;
|
||||
if (!Yap_ExtendWorkSpace(size)) {
|
||||
strncat(Yap_ErrorMessage,": heap crashed against stacks", MAX_ERROR_MSG_SIZE);
|
||||
return(FALSE);
|
||||
}
|
||||
start_growth_time = _YAP_cputime();
|
||||
gc_verbose = _YAP_is_gc_verbose();
|
||||
start_growth_time = Yap_cputime();
|
||||
gc_verbose = Yap_is_gc_verbose();
|
||||
heap_overflows++;
|
||||
if (gc_verbose) {
|
||||
fprintf(_YAP_stderr, "[HO] Heap overflow %d\n", heap_overflows);
|
||||
fprintf(_YAP_stderr, "[HO] growing the heap %ld bytes\n", size);
|
||||
fprintf(Yap_stderr, "[HO] Heap overflow %d\n", heap_overflows);
|
||||
fprintf(Yap_stderr, "[HO] growing the heap %ld bytes\n", size);
|
||||
}
|
||||
ASP -= 256;
|
||||
TrDiff = LDiff = GDiff = DelayDiff = size;
|
||||
@ -525,11 +525,11 @@ static_growheap(long size, int fix_code)
|
||||
AdjustRegs(MaxTemps);
|
||||
YAPLeaveCriticalSection();
|
||||
ASP += 256;
|
||||
growth_time = _YAP_cputime()-start_growth_time;
|
||||
growth_time = Yap_cputime()-start_growth_time;
|
||||
total_heap_overflow_time += growth_time;
|
||||
if (gc_verbose) {
|
||||
fprintf(_YAP_stderr, "[HO] took %g sec\n", (double)growth_time/1000);
|
||||
fprintf(_YAP_stderr, "[HO] Total of %g sec expanding heap \n", (double)total_heap_overflow_time/1000);
|
||||
fprintf(Yap_stderr, "[HO] took %g sec\n", (double)growth_time/1000);
|
||||
fprintf(Yap_stderr, "[HO] Total of %g sec expanding heap \n", (double)total_heap_overflow_time/1000);
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
@ -543,17 +543,17 @@ static_growglobal(long size, CELL **ptr)
|
||||
|
||||
/* adjust to a multiple of 256) */
|
||||
size = AdjustPageSize(size);
|
||||
_YAP_ErrorMessage = NULL;
|
||||
if (!_YAP_ExtendWorkSpace(size)) {
|
||||
strncat(_YAP_ErrorMessage,": global crashed against local", MAX_ERROR_MSG_SIZE);
|
||||
Yap_ErrorMessage = NULL;
|
||||
if (!Yap_ExtendWorkSpace(size)) {
|
||||
strncat(Yap_ErrorMessage,": global crashed against local", MAX_ERROR_MSG_SIZE);
|
||||
return(FALSE);
|
||||
}
|
||||
start_growth_time = _YAP_cputime();
|
||||
gc_verbose = _YAP_is_gc_verbose();
|
||||
start_growth_time = Yap_cputime();
|
||||
gc_verbose = Yap_is_gc_verbose();
|
||||
delay_overflows++;
|
||||
if (gc_verbose) {
|
||||
fprintf(_YAP_stderr, "[DO] Delay overflow %d\n", delay_overflows);
|
||||
fprintf(_YAP_stderr, "[DO] growing the stacks %ld bytes\n", size);
|
||||
fprintf(Yap_stderr, "[DO] Delay overflow %d\n", delay_overflows);
|
||||
fprintf(Yap_stderr, "[DO] growing the stacks %ld bytes\n", size);
|
||||
}
|
||||
ASP -= 256;
|
||||
TrDiff = LDiff = GDiff = size;
|
||||
@ -568,11 +568,11 @@ static_growglobal(long size, CELL **ptr)
|
||||
*ptr = PtoLocAdjust(*ptr);
|
||||
YAPLeaveCriticalSection();
|
||||
ASP += 256;
|
||||
growth_time = _YAP_cputime()-start_growth_time;
|
||||
growth_time = Yap_cputime()-start_growth_time;
|
||||
total_delay_overflow_time += growth_time;
|
||||
if (gc_verbose) {
|
||||
fprintf(_YAP_stderr, "[DO] took %g sec\n", (double)growth_time/1000);
|
||||
fprintf(_YAP_stderr, "[DO] Total of %g sec expanding stacks \n", (double)total_delay_overflow_time/1000);
|
||||
fprintf(Yap_stderr, "[DO] took %g sec\n", (double)growth_time/1000);
|
||||
fprintf(Yap_stderr, "[DO] Total of %g sec expanding stacks \n", (double)total_delay_overflow_time/1000);
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
@ -644,7 +644,7 @@ fix_tabling_info(void)
|
||||
#endif /* TABLING */
|
||||
|
||||
int
|
||||
_YAP_growheap(int fix_code)
|
||||
Yap_growheap(int fix_code)
|
||||
{
|
||||
unsigned long size = sizeof(CELL) * 16 * 1024L;
|
||||
int shift_factor = (heap_overflows > 8 ? 8 : heap_overflows);
|
||||
@ -652,7 +652,7 @@ _YAP_growheap(int fix_code)
|
||||
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
if (NOfThreads != 1) {
|
||||
_YAP_Error(SYSTEM_ERROR,TermNil,"cannot grow Heap: more than a worker/thread running");
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,"cannot grow Heap: more than a worker/thread running");
|
||||
return(FALSE);
|
||||
}
|
||||
#endif
|
||||
@ -688,13 +688,13 @@ _YAP_growheap(int fix_code)
|
||||
}
|
||||
|
||||
int
|
||||
_YAP_growglobal(CELL **ptr)
|
||||
Yap_growglobal(CELL **ptr)
|
||||
{
|
||||
unsigned long sz = sizeof(CELL) * 16 * 1024L;
|
||||
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
if (NOfThreads != 1) {
|
||||
_YAP_Error(SYSTEM_ERROR,TermNil,"cannot grow Global: more than a worker/thread running");
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,"cannot grow Global: more than a worker/thread running");
|
||||
return(FALSE);
|
||||
}
|
||||
#endif
|
||||
@ -716,27 +716,27 @@ growstack(long size)
|
||||
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
if (NOfThreads != 1) {
|
||||
_YAP_Error(SYSTEM_ERROR,TermNil,"cannot grow Local: more than a worker/thread running");
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,"cannot grow Local: more than a worker/thread running");
|
||||
return(FALSE);
|
||||
}
|
||||
#endif
|
||||
/* adjust to a multiple of 256) */
|
||||
size = AdjustPageSize(size);
|
||||
_YAP_ErrorMessage = NULL;
|
||||
if (!_YAP_ExtendWorkSpace(size)) {
|
||||
strncat(_YAP_ErrorMessage,": local crashed against global", MAX_ERROR_MSG_SIZE);
|
||||
Yap_ErrorMessage = NULL;
|
||||
if (!Yap_ExtendWorkSpace(size)) {
|
||||
strncat(Yap_ErrorMessage,": local crashed against global", MAX_ERROR_MSG_SIZE);
|
||||
return(FALSE);
|
||||
}
|
||||
start_growth_time = _YAP_cputime();
|
||||
gc_verbose = _YAP_is_gc_verbose();
|
||||
start_growth_time = Yap_cputime();
|
||||
gc_verbose = Yap_is_gc_verbose();
|
||||
stack_overflows++;
|
||||
if (gc_verbose) {
|
||||
fprintf(_YAP_stderr, "[SO] Stack Overflow %d\n", stack_overflows);
|
||||
fprintf(_YAP_stderr, "[SO] Heap: %8ld cells (%p-%p)\n", (unsigned long int)(H-(CELL *)_YAP_GlobalBase),_YAP_GlobalBase,H);
|
||||
fprintf(_YAP_stderr, "[SO] Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
|
||||
fprintf(_YAP_stderr, "[SO] Trail:%8ld cells (%p-%p)\n",
|
||||
(unsigned long int)(TR-(tr_fr_ptr)_YAP_TrailBase),_YAP_TrailBase,TR);
|
||||
fprintf(_YAP_stderr, "[SO] growing the stacks %ld bytes\n", size);
|
||||
fprintf(Yap_stderr, "[SO] Stack Overflow %d\n", stack_overflows);
|
||||
fprintf(Yap_stderr, "[SO] Heap: %8ld cells (%p-%p)\n", (unsigned long int)(H-(CELL *)Yap_GlobalBase),Yap_GlobalBase,H);
|
||||
fprintf(Yap_stderr, "[SO] Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
|
||||
fprintf(Yap_stderr, "[SO] Trail:%8ld cells (%p-%p)\n",
|
||||
(unsigned long int)(TR-(tr_fr_ptr)Yap_TrailBase),Yap_TrailBase,TR);
|
||||
fprintf(Yap_stderr, "[SO] growing the stacks %ld bytes\n", size);
|
||||
}
|
||||
TrDiff = LDiff = size;
|
||||
XDiff = HDiff = GDiff = DelayDiff = 0;
|
||||
@ -752,17 +752,17 @@ growstack(long size)
|
||||
YAPLeaveCriticalSection();
|
||||
CreepFlag = CalculateStackGap();
|
||||
ASP += 256;
|
||||
growth_time = _YAP_cputime()-start_growth_time;
|
||||
growth_time = Yap_cputime()-start_growth_time;
|
||||
total_stack_overflow_time += growth_time;
|
||||
if (gc_verbose) {
|
||||
fprintf(_YAP_stderr, "[SO] took %g sec\n", (double)growth_time/1000);
|
||||
fprintf(_YAP_stderr, "[SO] Total of %g sec expanding stacks \n", (double)total_stack_overflow_time/1000);
|
||||
fprintf(Yap_stderr, "[SO] took %g sec\n", (double)growth_time/1000);
|
||||
fprintf(Yap_stderr, "[SO] Total of %g sec expanding stacks \n", (double)total_stack_overflow_time/1000);
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
int
|
||||
_YAP_growstack(long size)
|
||||
Yap_growstack(long size)
|
||||
{
|
||||
return growstack(size);
|
||||
}
|
||||
@ -819,9 +819,9 @@ AdjustScannerStacks(TokEntry **tksp, VarEntry **vep)
|
||||
ves = *vep = (VarEntry *)TrailAddrAdjust((ADDR)ves);
|
||||
AdjustVarTable(ves);
|
||||
}
|
||||
ves = _YAP_AnonVarTable;
|
||||
ves = Yap_AnonVarTable;
|
||||
if (ves != NULL) {
|
||||
ves = _YAP_AnonVarTable = VarEntryAdjust(ves);
|
||||
ves = Yap_AnonVarTable = VarEntryAdjust(ves);
|
||||
}
|
||||
while (ves != NULL) {
|
||||
VarEntry *vetmp = ves->VarLeft;
|
||||
@ -836,35 +836,35 @@ AdjustScannerStacks(TokEntry **tksp, VarEntry **vep)
|
||||
|
||||
/* Used by parser when we're short of stack space */
|
||||
int
|
||||
_YAP_growstack_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
||||
Yap_growstack_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
||||
{
|
||||
Int start_growth_time, growth_time;
|
||||
int gc_verbose;
|
||||
long size = sizeof(CELL)*(LCL0-(CELL *)_YAP_GlobalBase);
|
||||
long size = sizeof(CELL)*(LCL0-(CELL *)Yap_GlobalBase);
|
||||
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
if (NOfThreads != 1) {
|
||||
_YAP_Error(SYSTEM_ERROR,TermNil,"cannot grow Parser Stack: more than a worker/thread running");
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,"cannot grow Parser Stack: more than a worker/thread running");
|
||||
return(FALSE);
|
||||
}
|
||||
#endif
|
||||
/* adjust to a multiple of 256) */
|
||||
size = AdjustPageSize(size);
|
||||
_YAP_ErrorMessage = NULL;
|
||||
if (!_YAP_ExtendWorkSpace(size)) {
|
||||
strncat(_YAP_ErrorMessage,": parser stack overflowed", MAX_ERROR_MSG_SIZE);
|
||||
Yap_ErrorMessage = NULL;
|
||||
if (!Yap_ExtendWorkSpace(size)) {
|
||||
strncat(Yap_ErrorMessage,": parser stack overflowed", MAX_ERROR_MSG_SIZE);
|
||||
return(FALSE);
|
||||
}
|
||||
start_growth_time = _YAP_cputime();
|
||||
gc_verbose = _YAP_is_gc_verbose();
|
||||
start_growth_time = Yap_cputime();
|
||||
gc_verbose = Yap_is_gc_verbose();
|
||||
stack_overflows++;
|
||||
if (gc_verbose) {
|
||||
fprintf(_YAP_stderr, "[SO] Stack overflow %d\n", stack_overflows);
|
||||
fprintf(_YAP_stderr, "[SO] Heap: %8ld cells (%p-%p)\n", (unsigned long int)(H-(CELL *)_YAP_GlobalBase),(CELL *)_YAP_GlobalBase,H);
|
||||
fprintf(_YAP_stderr, "[SO] Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
|
||||
fprintf(_YAP_stderr, "[SO] Trail:%8ld cells (%p-%p)\n",
|
||||
(unsigned long int)(TR-(tr_fr_ptr)_YAP_TrailBase),_YAP_TrailBase,TR);
|
||||
fprintf(_YAP_stderr, "[SO] growing the stacks %ld bytes\n", size);
|
||||
fprintf(Yap_stderr, "[SO] Stack overflow %d\n", stack_overflows);
|
||||
fprintf(Yap_stderr, "[SO] Heap: %8ld cells (%p-%p)\n", (unsigned long int)(H-(CELL *)Yap_GlobalBase),(CELL *)Yap_GlobalBase,H);
|
||||
fprintf(Yap_stderr, "[SO] Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
|
||||
fprintf(Yap_stderr, "[SO] Trail:%8ld cells (%p-%p)\n",
|
||||
(unsigned long int)(TR-(tr_fr_ptr)Yap_TrailBase),Yap_TrailBase,TR);
|
||||
fprintf(Yap_stderr, "[SO] growing the stacks %ld bytes\n", size);
|
||||
}
|
||||
TrDiff = LDiff = size;
|
||||
XDiff = HDiff = GDiff = DelayDiff = 0;
|
||||
@ -885,11 +885,11 @@ _YAP_growstack_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
||||
YAPLeaveCriticalSection();
|
||||
CreepFlag = CalculateStackGap();
|
||||
ASP += 256;
|
||||
growth_time = _YAP_cputime()-start_growth_time;
|
||||
growth_time = Yap_cputime()-start_growth_time;
|
||||
total_stack_overflow_time += growth_time;
|
||||
if (gc_verbose) {
|
||||
fprintf(_YAP_stderr, "[SO] took %g sec\n", (double)growth_time/1000);
|
||||
fprintf(_YAP_stderr, "[SO] Total of %g sec expanding stacks \n", (double)total_stack_overflow_time/1000);
|
||||
fprintf(Yap_stderr, "[SO] took %g sec\n", (double)growth_time/1000);
|
||||
fprintf(Yap_stderr, "[SO] Total of %g sec expanding stacks \n", (double)total_stack_overflow_time/1000);
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
@ -897,14 +897,14 @@ _YAP_growstack_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
||||
|
||||
/* Used by do_goal() when we're short of stack space */
|
||||
int
|
||||
_YAP_growtrail(long size)
|
||||
Yap_growtrail(long size)
|
||||
{
|
||||
Int start_growth_time = _YAP_cputime(), growth_time;
|
||||
int gc_verbose = _YAP_is_gc_verbose();
|
||||
Int start_growth_time = Yap_cputime(), growth_time;
|
||||
int gc_verbose = Yap_is_gc_verbose();
|
||||
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
if (NOfThreads != 1) {
|
||||
_YAP_Error(SYSTEM_ERROR,TermNil,"cannot grow trail: more than a worker/thread running");
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,"cannot grow trail: more than a worker/thread running");
|
||||
return(FALSE);
|
||||
}
|
||||
#endif
|
||||
@ -912,22 +912,22 @@ _YAP_growtrail(long size)
|
||||
size = AdjustPageSize(size);
|
||||
trail_overflows++;
|
||||
if (gc_verbose) {
|
||||
fprintf(_YAP_stderr, "[TO] Trail overflow %d\n", trail_overflows);
|
||||
fprintf(_YAP_stderr, "[TO] growing the trail %ld bytes\n", size);
|
||||
fprintf(Yap_stderr, "[TO] Trail overflow %d\n", trail_overflows);
|
||||
fprintf(Yap_stderr, "[TO] growing the trail %ld bytes\n", size);
|
||||
}
|
||||
_YAP_ErrorMessage = NULL;
|
||||
if (!_YAP_ExtendWorkSpace(size)) {
|
||||
strncat(_YAP_ErrorMessage,": trail stack overflowed", MAX_ERROR_MSG_SIZE);
|
||||
Yap_ErrorMessage = NULL;
|
||||
if (!Yap_ExtendWorkSpace(size)) {
|
||||
strncat(Yap_ErrorMessage,": trail stack overflowed", MAX_ERROR_MSG_SIZE);
|
||||
return(FALSE);
|
||||
}
|
||||
YAPEnterCriticalSection();
|
||||
_YAP_TrailTop += size;
|
||||
Yap_TrailTop += size;
|
||||
YAPLeaveCriticalSection();
|
||||
growth_time = _YAP_cputime()-start_growth_time;
|
||||
growth_time = Yap_cputime()-start_growth_time;
|
||||
total_trail_overflow_time += growth_time;
|
||||
if (gc_verbose) {
|
||||
fprintf(_YAP_stderr, "[TO] took %g sec\n", (double)growth_time/1000);
|
||||
fprintf(_YAP_stderr, "[TO] Total of %g sec expanding stacks \n", (double)total_stack_overflow_time/1000);
|
||||
fprintf(Yap_stderr, "[TO] took %g sec\n", (double)growth_time/1000);
|
||||
fprintf(Yap_stderr, "[TO] Total of %g sec expanding stacks \n", (double)total_stack_overflow_time/1000);
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
@ -939,7 +939,7 @@ p_inform_trail_overflows(void)
|
||||
Term tn = MkIntTerm(trail_overflows);
|
||||
Term tt = MkIntegerTerm(total_trail_overflow_time);
|
||||
|
||||
return(_YAP_unify(tn, ARG1) && _YAP_unify(tt, ARG2));
|
||||
return(Yap_unify(tn, ARG1) && Yap_unify(tt, ARG2));
|
||||
}
|
||||
|
||||
/* :- grow_heap(Size) */
|
||||
@ -950,15 +950,15 @@ p_growheap(void)
|
||||
Term t1 = Deref(ARG1);
|
||||
|
||||
if (IsVarTerm(t1)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t1, "grow_heap/1");
|
||||
Yap_Error(INSTANTIATION_ERROR, t1, "grow_heap/1");
|
||||
return(FALSE);
|
||||
} else if (!IsIntTerm(t1)) {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t1, "grow_heap/1");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t1, "grow_heap/1");
|
||||
return(FALSE);
|
||||
}
|
||||
diff = IntOfTerm(t1);
|
||||
if (diff < 0) {
|
||||
_YAP_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t1, "grow_heap/1");
|
||||
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t1, "grow_heap/1");
|
||||
}
|
||||
return(static_growheap(diff, FALSE));
|
||||
}
|
||||
@ -969,7 +969,7 @@ p_inform_heap_overflows(void)
|
||||
Term tn = MkIntTerm(heap_overflows);
|
||||
Term tt = MkIntegerTerm(total_heap_overflow_time);
|
||||
|
||||
return(_YAP_unify(tn, ARG1) && _YAP_unify(tt, ARG2));
|
||||
return(Yap_unify(tn, ARG1) && Yap_unify(tt, ARG2));
|
||||
}
|
||||
|
||||
/* :- grow_stack(Size) */
|
||||
@ -980,15 +980,15 @@ p_growstack(void)
|
||||
Term t1 = Deref(ARG1);
|
||||
|
||||
if (IsVarTerm(t1)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t1, "grow_stack/1");
|
||||
Yap_Error(INSTANTIATION_ERROR, t1, "grow_stack/1");
|
||||
return(FALSE);
|
||||
} else if (!IsIntTerm(t1)) {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t1, "grow_stack/1");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t1, "grow_stack/1");
|
||||
return(FALSE);
|
||||
}
|
||||
diff = IntOfTerm(t1);
|
||||
if (diff < 0) {
|
||||
_YAP_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t1, "grow_stack/1");
|
||||
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t1, "grow_stack/1");
|
||||
}
|
||||
return(growstack(diff));
|
||||
}
|
||||
@ -999,12 +999,12 @@ p_inform_stack_overflows(void)
|
||||
Term tn = MkIntTerm(stack_overflows);
|
||||
Term tt = MkIntegerTerm(total_stack_overflow_time);
|
||||
|
||||
return(_YAP_unify(tn, ARG1) && _YAP_unify(tt, ARG2));
|
||||
return(Yap_unify(tn, ARG1) && Yap_unify(tt, ARG2));
|
||||
|
||||
}
|
||||
|
||||
Int
|
||||
_YAP_total_stack_shift_time(void)
|
||||
Yap_total_stack_shift_time(void)
|
||||
{
|
||||
return(total_heap_overflow_time+
|
||||
total_stack_overflow_time+
|
||||
@ -1012,13 +1012,13 @@ _YAP_total_stack_shift_time(void)
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_InitGrowPreds(void)
|
||||
Yap_InitGrowPreds(void)
|
||||
{
|
||||
_YAP_InitCPred("$grow_heap", 1, p_growheap, SafePredFlag);
|
||||
_YAP_InitCPred("$grow_stack", 1, p_growstack, SafePredFlag);
|
||||
_YAP_InitCPred("$inform_trail_overflows", 2, p_inform_trail_overflows, SafePredFlag);
|
||||
_YAP_InitCPred("$inform_heap_overflows", 2, p_inform_heap_overflows, SafePredFlag);
|
||||
_YAP_InitCPred("$inform_stack_overflows", 2, p_inform_stack_overflows, SafePredFlag);
|
||||
_YAP_init_gc();
|
||||
_YAP_init_agc();
|
||||
Yap_InitCPred("$grow_heap", 1, p_growheap, SafePredFlag);
|
||||
Yap_InitCPred("$grow_stack", 1, p_growstack, SafePredFlag);
|
||||
Yap_InitCPred("$inform_trail_overflows", 2, p_inform_trail_overflows, SafePredFlag);
|
||||
Yap_InitCPred("$inform_heap_overflows", 2, p_inform_heap_overflows, SafePredFlag);
|
||||
Yap_InitCPred("$inform_stack_overflows", 2, p_inform_stack_overflows, SafePredFlag);
|
||||
Yap_init_gc();
|
||||
Yap_init_agc();
|
||||
}
|
||||
|
248
C/heapgc.c
248
C/heapgc.c
@ -104,8 +104,8 @@ PUSH_CONTINUATION(CELL *v, int nof) {
|
||||
if (nof == 0) return;
|
||||
x = cont_top;
|
||||
x++;
|
||||
if ((ADDR)x > _YAP_TrailTop-1024)
|
||||
_YAP_growtrail(64 * 1024L);
|
||||
if ((ADDR)x > Yap_TrailTop-1024)
|
||||
Yap_growtrail(64 * 1024L);
|
||||
x->v = v;
|
||||
x->nof = nof;
|
||||
cont_top = x;
|
||||
@ -288,8 +288,8 @@ static inline struct gc_ma_h_entry *
|
||||
GC_ALLOC_NEW_MASPACE(void)
|
||||
{
|
||||
gc_ma_h_inner_struct *new = gc_ma_h_top;
|
||||
if ((char *)gc_ma_h_top > _YAP_TrailTop-1024)
|
||||
_YAP_growtrail(64 * 1024L);
|
||||
if ((char *)gc_ma_h_top > Yap_TrailTop-1024)
|
||||
Yap_growtrail(64 * 1024L);
|
||||
gc_ma_h_top++;
|
||||
cont_top = (cont *)gc_ma_h_top;
|
||||
#ifdef EASY_SHUNTING
|
||||
@ -386,8 +386,8 @@ push_registers(Int num_regs, yamop *nextop)
|
||||
for (i = 1; i <= num_regs; i++)
|
||||
TrailTerm(TR++) = (CELL) XREGS[i];
|
||||
/* push any live registers we might have hanging around */
|
||||
if (nextop->opc == _YAP_opcode(_move_back) ||
|
||||
nextop->opc == _YAP_opcode(_skip)) {
|
||||
if (nextop->opc == Yap_opcode(_move_back) ||
|
||||
nextop->opc == Yap_opcode(_skip)) {
|
||||
CELL *lab = (CELL *)(nextop->u.l.l);
|
||||
CELL max = lab[0];
|
||||
Int curr = lab[1];
|
||||
@ -437,8 +437,8 @@ pop_registers(Int num_regs, yamop *nextop)
|
||||
for (i = 1; i <= num_regs; i++)
|
||||
XREGS[i] = TrailTerm(ptr++);
|
||||
/* pop any live registers we might have hanging around */
|
||||
if (nextop->opc == _YAP_opcode(_move_back) ||
|
||||
nextop->opc == _YAP_opcode(_skip)) {
|
||||
if (nextop->opc == Yap_opcode(_move_back) ||
|
||||
nextop->opc == Yap_opcode(_skip)) {
|
||||
CELL *lab = (CELL *)(nextop->u.l.l);
|
||||
CELL max = lab[0];
|
||||
Int curr = lab[1];
|
||||
@ -496,10 +496,10 @@ store_ref_in_dbtable(DBRef entry)
|
||||
dbentry parent = db_vec0;
|
||||
dbentry new = db_vec;
|
||||
|
||||
if ((ADDR)new > _YAP_TrailTop-1024)
|
||||
_YAP_growtrail(64 * 1024L);
|
||||
if ((ADDR)new > Yap_TrailTop-1024)
|
||||
Yap_growtrail(64 * 1024L);
|
||||
new->val = entry;
|
||||
new->lim = (CELL *)((CODEADDR)entry+_YAP_SizeOfBlock((CODEADDR)entry));
|
||||
new->lim = (CELL *)((CODEADDR)entry+Yap_SizeOfBlock((CODEADDR)entry));
|
||||
new->left = new->right = NULL;
|
||||
if (db_vec == db_vec0) {
|
||||
db_vec++;
|
||||
@ -532,10 +532,10 @@ store_cl_in_dbtable(Clause *cl)
|
||||
dbentry parent = db_vec0;
|
||||
dbentry new = db_vec;
|
||||
|
||||
if ((ADDR)new > _YAP_TrailTop-1024)
|
||||
_YAP_growtrail(64 * 1024L);
|
||||
if ((ADDR)new > Yap_TrailTop-1024)
|
||||
Yap_growtrail(64 * 1024L);
|
||||
new->val = (DBRef)cl;
|
||||
new->lim = (CELL *)((CODEADDR)cl + _YAP_SizeOfBlock((CODEADDR)cl));
|
||||
new->lim = (CELL *)((CODEADDR)cl + Yap_SizeOfBlock((CODEADDR)cl));
|
||||
new->left = new->right = NULL;
|
||||
if (db_vec == db_vec0) {
|
||||
db_vec++;
|
||||
@ -593,7 +593,7 @@ init_dbtable(tr_fr_ptr trail_ptr) {
|
||||
Clause *cl = DeadClauses;
|
||||
|
||||
db_vec0 = db_vec = (dbentry)TR;
|
||||
while (trail_ptr > (tr_fr_ptr)_YAP_TrailBase) {
|
||||
while (trail_ptr > (tr_fr_ptr)Yap_TrailBase) {
|
||||
register CELL trail_cell;
|
||||
|
||||
trail_ptr--;
|
||||
@ -612,7 +612,7 @@ init_dbtable(tr_fr_ptr trail_ptr) {
|
||||
#ifdef SBA
|
||||
(ADDR) pt0 >= HeapTop
|
||||
#else
|
||||
(ADDR) pt0 >= _YAP_TrailBase
|
||||
(ADDR) pt0 >= Yap_TrailBase
|
||||
#endif
|
||||
) {
|
||||
continue;
|
||||
@ -691,17 +691,17 @@ inc_vars_of_type(CELL *curr,gc_types val) {
|
||||
static void
|
||||
put_type_info(unsigned long total)
|
||||
{
|
||||
fprintf(_YAP_stderr,"[GC] type info for %lu cells\n", total);
|
||||
fprintf(_YAP_stderr,"[GC] %lu vars\n", vars[gc_var]);
|
||||
fprintf(_YAP_stderr,"[GC] %lu refs\n", vars[gc_ref]);
|
||||
fprintf(_YAP_stderr,"[GC] %lu references from env\n", env_vars);
|
||||
fprintf(_YAP_stderr,"[GC] %lu atoms\n", vars[gc_atom]);
|
||||
fprintf(_YAP_stderr,"[GC] %lu small ints\n", vars[gc_int]);
|
||||
fprintf(_YAP_stderr,"[GC] %lu other numbers\n", vars[gc_num]);
|
||||
fprintf(_YAP_stderr,"[GC] %lu lists\n", vars[gc_list]);
|
||||
fprintf(_YAP_stderr,"[GC] %lu compound terms\n", vars[gc_appl]);
|
||||
fprintf(_YAP_stderr,"[GC] %lu functors\n", vars[gc_func]);
|
||||
fprintf(_YAP_stderr,"[GC] %lu suspensions\n", vars[gc_susp]);
|
||||
fprintf(Yap_stderr,"[GC] type info for %lu cells\n", total);
|
||||
fprintf(Yap_stderr,"[GC] %lu vars\n", vars[gc_var]);
|
||||
fprintf(Yap_stderr,"[GC] %lu refs\n", vars[gc_ref]);
|
||||
fprintf(Yap_stderr,"[GC] %lu references from env\n", env_vars);
|
||||
fprintf(Yap_stderr,"[GC] %lu atoms\n", vars[gc_atom]);
|
||||
fprintf(Yap_stderr,"[GC] %lu small ints\n", vars[gc_int]);
|
||||
fprintf(Yap_stderr,"[GC] %lu other numbers\n", vars[gc_num]);
|
||||
fprintf(Yap_stderr,"[GC] %lu lists\n", vars[gc_list]);
|
||||
fprintf(Yap_stderr,"[GC] %lu compound terms\n", vars[gc_appl]);
|
||||
fprintf(Yap_stderr,"[GC] %lu functors\n", vars[gc_func]);
|
||||
fprintf(Yap_stderr,"[GC] %lu suspensions\n", vars[gc_susp]);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -894,7 +894,7 @@ mark_variable(CELL_PTR current)
|
||||
}
|
||||
#ifdef DEBUG
|
||||
else if (next < (CELL *)AtomBase || next < (CELL *)HeapTop)
|
||||
fprintf(_YAP_stderr, "ooops while marking %lx, %p at %p\n", (unsigned long int)ccur, current, next);
|
||||
fprintf(Yap_stderr, "ooops while marking %lx, %p at %p\n", (unsigned long int)ccur, current, next);
|
||||
#endif
|
||||
#ifdef INSTRUMENT_GC
|
||||
else
|
||||
@ -1006,7 +1006,7 @@ mark_variable(CELL_PTR current)
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_mark_variable(CELL_PTR current)
|
||||
Yap_mark_variable(CELL_PTR current)
|
||||
{
|
||||
mark_variable(current);
|
||||
}
|
||||
@ -1084,7 +1084,7 @@ mark_external_reference(CELL *ptr) {
|
||||
*/
|
||||
|
||||
void
|
||||
_YAP_mark_external_reference(CELL *ptr) {
|
||||
Yap_mark_external_reference(CELL *ptr) {
|
||||
mark_external_reference(ptr);
|
||||
}
|
||||
|
||||
@ -1104,7 +1104,7 @@ mark_regs(tr_fr_ptr old_TR)
|
||||
static void
|
||||
mark_delays(CELL *max)
|
||||
{
|
||||
CELL *ptr = (CELL *)_YAP_GlobalBase;
|
||||
CELL *ptr = (CELL *)Yap_GlobalBase;
|
||||
for (; ptr < max; ptr++) {
|
||||
mark_external_reference(ptr);
|
||||
}
|
||||
@ -1125,7 +1125,7 @@ mark_environments(CELL_PTR gc_ENV, OPREG size, CELL *pvbmap)
|
||||
|
||||
#ifdef DEBUG
|
||||
if (size < 0 || size > 512)
|
||||
fprintf(_YAP_stderr,"Oops, env size for %p is %ld\n", gc_ENV, (unsigned long int)size);
|
||||
fprintf(Yap_stderr,"Oops, env size for %p is %ld\n", gc_ENV, (unsigned long int)size);
|
||||
#endif
|
||||
if ((cl = (Clause *)find_ref_in_dbtable((DBRef)gc_ENV[E_CP])) != NULL) {
|
||||
cl->ClFlags |= GcFoundMask;
|
||||
@ -1194,12 +1194,12 @@ mark_environments(CELL_PTR gc_ENV, OPREG size, CELL *pvbmap)
|
||||
#if 0
|
||||
if (size < 0) {
|
||||
PredEntry *pe = EnvPreg(gc_ENV[E_CP]);
|
||||
op_numbers op = _YAP_op_from_opcode(ENV_ToOp(gc_ENV[E_CP]));
|
||||
fprintf(_YAP_stderr,"ENV %p-%p(%d) %s\n", gc_ENV, pvbmap, size-EnvSizeInCells, op_names[op]);
|
||||
op_numbers op = Yap_op_from_opcode(ENV_ToOp(gc_ENV[E_CP]));
|
||||
fprintf(Yap_stderr,"ENV %p-%p(%d) %s\n", gc_ENV, pvbmap, size-EnvSizeInCells, op_names[op]);
|
||||
if (pe->ArityOfPE)
|
||||
fprintf(_YAP_stderr," %s/%d\n", RepAtom(NameOfFunctor(pe->FunctorOfPred))->StrOfAE, pe->ArityOfPE);
|
||||
fprintf(Yap_stderr," %s/%d\n", RepAtom(NameOfFunctor(pe->FunctorOfPred))->StrOfAE, pe->ArityOfPE);
|
||||
else
|
||||
fprintf(_YAP_stderr," %s\n", RepAtom((Atom)(pe->FunctorOfPred))->StrOfAE);
|
||||
fprintf(Yap_stderr," %s\n", RepAtom((Atom)(pe->FunctorOfPred))->StrOfAE);
|
||||
}
|
||||
#endif
|
||||
gc_ENV = (CELL_PTR) gc_ENV[E_E]; /* link to prev
|
||||
@ -1261,7 +1261,7 @@ mark_trail(tr_fr_ptr trail_ptr, tr_fr_ptr trail_base, CELL *gc_H, choiceptr gc_B
|
||||
/* I decided to allow pointers from the Heap back into the trail.
|
||||
The point of doing so is to have dynamic arrays */
|
||||
mark_external_reference(hp);
|
||||
} else if ((hp < (CELL *)gc_B && hp >= gc_H) || hp > (CELL *)_YAP_TrailBase) {
|
||||
} else if ((hp < (CELL *)gc_B && hp >= gc_H) || hp > (CELL *)Yap_TrailBase) {
|
||||
/* clean the trail, avoid dangling pointers! */
|
||||
RESET_VARIABLE(&TrailTerm(trail_ptr));
|
||||
#ifdef FROZEN_STACKS
|
||||
@ -1280,8 +1280,8 @@ mark_trail(tr_fr_ptr trail_ptr, tr_fr_ptr trail_base, CELL *gc_H, choiceptr gc_B
|
||||
tr_fr_ptr nsTR = (tr_fr_ptr)cont_top0;
|
||||
CELL *cptr = (CELL *)trail_cell;
|
||||
|
||||
if ((ADDR)nsTR > _YAP_TrailTop-1024)
|
||||
_YAP_growtrail(64 * 1024L);
|
||||
if ((ADDR)nsTR > Yap_TrailTop-1024)
|
||||
Yap_growtrail(64 * 1024L);
|
||||
TrailTerm(nsTR) = (CELL)NULL;
|
||||
TrailTerm(nsTR+1) = *hp;
|
||||
TrailTerm(nsTR+2) = trail_cell;
|
||||
@ -1456,7 +1456,7 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose)
|
||||
#endif
|
||||
{
|
||||
op = rtp->opc;
|
||||
opnum = _YAP_op_from_opcode(op);
|
||||
opnum = Yap_op_from_opcode(op);
|
||||
}
|
||||
if (very_verbose) {
|
||||
switch (opnum) {
|
||||
@ -1481,13 +1481,13 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose)
|
||||
Atom at;
|
||||
Int arity;
|
||||
SMALLUNSGN mod;
|
||||
if (_YAP_PredForCode((CODEADDR)gc_B->cp_ap, &at, &arity, &mod)) {
|
||||
if (Yap_PredForCode((CODEADDR)gc_B->cp_ap, &at, &arity, &mod)) {
|
||||
if (arity)
|
||||
fprintf(_YAP_stderr,"[GC] %s/%d marked %d (%s)\n", RepAtom(at)->StrOfAE, arity, total_marked, op_names[opnum]);
|
||||
fprintf(Yap_stderr,"[GC] %s/%d marked %d (%s)\n", RepAtom(at)->StrOfAE, arity, total_marked, op_names[opnum]);
|
||||
else
|
||||
fprintf(_YAP_stderr,"[GC] %s marked %d (%s)\n", RepAtom(at)->StrOfAE, total_marked, op_names[opnum]);
|
||||
fprintf(Yap_stderr,"[GC] %s marked %d (%s)\n", RepAtom(at)->StrOfAE, total_marked, op_names[opnum]);
|
||||
} else
|
||||
fprintf(_YAP_stderr,"[GC] marked %d (%s)\n", total_marked, op_names[opnum]);
|
||||
fprintf(Yap_stderr,"[GC] marked %d (%s)\n", total_marked, op_names[opnum]);
|
||||
}
|
||||
break;
|
||||
#ifdef TABLING
|
||||
@ -1495,12 +1495,12 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose)
|
||||
case _table_answer_resolution:
|
||||
{
|
||||
PredEntry *pe = ENV_ToP(gc_B->cp_cp);
|
||||
op_numbers caller_op = _YAP_op_from_opcode(ENV_ToOp(gc_B->cp_cp));
|
||||
op_numbers caller_op = Yap_op_from_opcode(ENV_ToOp(gc_B->cp_cp));
|
||||
/* first condition checks if this was a meta-call */
|
||||
if ((caller_op != _call && caller_op != _fcall) || pe == NULL) {
|
||||
fprintf(_YAP_stderr,"[GC] marked %d (%s)\n", total_marked, op_names[opnum]);
|
||||
fprintf(Yap_stderr,"[GC] marked %d (%s)\n", total_marked, op_names[opnum]);
|
||||
} else
|
||||
fprintf(_YAP_stderr,"[GC] %s/%d marked %d (%s)\n", RepAtom(NameOfFunctor(pe->FunctorOfPred))->StrOfAE, pe->ArityOfPE, total_marked, op_names[opnum]);
|
||||
fprintf(Yap_stderr,"[GC] %s/%d marked %d (%s)\n", RepAtom(NameOfFunctor(pe->FunctorOfPred))->StrOfAE, pe->ArityOfPE, total_marked, op_names[opnum]);
|
||||
}
|
||||
break;
|
||||
case _trie_retry_var:
|
||||
@ -1513,19 +1513,19 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose)
|
||||
case _trie_trust_list:
|
||||
case _trie_retry_struct:
|
||||
case _trie_trust_struct:
|
||||
fprintf(_YAP_stderr,"[GC] marked %d (%s)\n", total_marked, op_names[opnum]);
|
||||
fprintf(Yap_stderr,"[GC] marked %d (%s)\n", total_marked, op_names[opnum]);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
{
|
||||
PredEntry *pe = (PredEntry *)gc_B->cp_ap->u.ld.p;
|
||||
if (pe == NULL) {
|
||||
fprintf(_YAP_stderr,"[GC] marked %d (%s)\n", total_marked, op_names[opnum]);
|
||||
fprintf(Yap_stderr,"[GC] marked %d (%s)\n", total_marked, op_names[opnum]);
|
||||
} else
|
||||
if (pe->ArityOfPE)
|
||||
fprintf(_YAP_stderr,"[GC] %s/%d marked %d (%s)\n", RepAtom(NameOfFunctor(pe->FunctorOfPred))->StrOfAE, pe->ArityOfPE, total_marked, op_names[opnum]);
|
||||
fprintf(Yap_stderr,"[GC] %s/%d marked %d (%s)\n", RepAtom(NameOfFunctor(pe->FunctorOfPred))->StrOfAE, pe->ArityOfPE, total_marked, op_names[opnum]);
|
||||
else
|
||||
fprintf(_YAP_stderr,"[GC] %s marked %d (%s)\n", RepAtom((Atom)(pe->FunctorOfPred))->StrOfAE, total_marked, op_names[opnum]);
|
||||
fprintf(Yap_stderr,"[GC] %s marked %d (%s)\n", RepAtom((Atom)(pe->FunctorOfPred))->StrOfAE, total_marked, op_names[opnum]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1612,7 +1612,7 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose)
|
||||
case _count_retry:
|
||||
rtp = NEXTOP(rtp,l);
|
||||
op = rtp->opc;
|
||||
opnum = _YAP_op_from_opcode(op);
|
||||
opnum = Yap_op_from_opcode(op);
|
||||
goto restart_cp;
|
||||
case _trust_fail:
|
||||
nargs = 0;
|
||||
@ -1752,7 +1752,7 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose)
|
||||
nargs = rtp->u.ld.s;
|
||||
break;
|
||||
default:
|
||||
fprintf(_YAP_stderr, "OOps in GC: Unexpected opcode: %d\n", opnum);
|
||||
fprintf(Yap_stderr, "OOps in GC: Unexpected opcode: %d\n", opnum);
|
||||
nargs = 0;
|
||||
#else
|
||||
default:
|
||||
@ -1803,7 +1803,7 @@ into_relocation_chain(CELL_PTR current, CELL_PTR next)
|
||||
*next = AbsAppl((CELL *)
|
||||
((MARKED(cnext) ? MBIT : 0) | RBIT | (Int) current));
|
||||
} else {
|
||||
fprintf(_YAP_stderr," OH MY GOD !!!!!!!!!!!!\n");
|
||||
fprintf(Yap_stderr," OH MY GOD !!!!!!!!!!!!\n");
|
||||
}
|
||||
#else
|
||||
CELL current_tag;
|
||||
@ -1838,11 +1838,11 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR)
|
||||
we don't compress TR if we have freeze.
|
||||
*/
|
||||
{
|
||||
Int size = old_TR-(tr_fr_ptr)_YAP_TrailBase;
|
||||
Int size = old_TR-(tr_fr_ptr)Yap_TrailBase;
|
||||
size -= discard_trail_entries;
|
||||
while (gc_B != NULL) {
|
||||
size -= (UInt)(gc_B->cp_tr);
|
||||
gc_B->cp_tr = (tr_fr_ptr)_YAP_TrailBase+size;
|
||||
gc_B->cp_tr = (tr_fr_ptr)Yap_TrailBase+size;
|
||||
gc_B = gc_B->cp_b;
|
||||
}
|
||||
}
|
||||
@ -1860,7 +1860,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR)
|
||||
}
|
||||
|
||||
/* next, follows the real trail entries */
|
||||
trail_ptr = (tr_fr_ptr)_YAP_TrailBase;
|
||||
trail_ptr = (tr_fr_ptr)Yap_TrailBase;
|
||||
dest = trail_ptr;
|
||||
while (trail_ptr < old_TR) {
|
||||
register CELL trail_cell;
|
||||
@ -1922,7 +1922,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR)
|
||||
#ifdef SBA
|
||||
(ADDR) pt0 >= HeapTop
|
||||
#else
|
||||
(ADDR) pt0 >= _YAP_TrailBase
|
||||
(ADDR) pt0 >= Yap_TrailBase
|
||||
#endif
|
||||
) {
|
||||
trail_ptr++;
|
||||
@ -1953,7 +1953,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR)
|
||||
dbr->Flags &= ~InUseMask;
|
||||
DEC_DBREF_COUNT(dbr);
|
||||
if (dbr->Flags & ErasedMask) {
|
||||
_YAP_ErDBE(dbr);
|
||||
Yap_ErDBE(dbr);
|
||||
}
|
||||
} else {
|
||||
Clause *cl = ClauseFlagsToClause((CELL)pt0);
|
||||
@ -1968,7 +1968,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR)
|
||||
if (erase) {
|
||||
/* at this point,
|
||||
no one is accessing the clause */
|
||||
_YAP_ErCl(cl);
|
||||
Yap_ErCl(cl);
|
||||
}
|
||||
}
|
||||
RESET_VARIABLE(&TrailTerm(dest));
|
||||
@ -2029,27 +2029,27 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR)
|
||||
}
|
||||
new_TR = dest;
|
||||
if (is_gc_verbose()) {
|
||||
if (old_TR != (tr_fr_ptr)_YAP_TrailBase)
|
||||
fprintf(_YAP_stderr,
|
||||
if (old_TR != (tr_fr_ptr)Yap_TrailBase)
|
||||
fprintf(Yap_stderr,
|
||||
"[GC] Trail: discarded %d (%ld%%) cells out of %ld\n",
|
||||
discard_trail_entries,
|
||||
(unsigned long int)(discard_trail_entries*100/(old_TR-(tr_fr_ptr)_YAP_TrailBase)),
|
||||
(unsigned long int)(old_TR-(tr_fr_ptr)_YAP_TrailBase));
|
||||
(unsigned long int)(discard_trail_entries*100/(old_TR-(tr_fr_ptr)Yap_TrailBase)),
|
||||
(unsigned long int)(old_TR-(tr_fr_ptr)Yap_TrailBase));
|
||||
#ifdef DEBUG
|
||||
if (hp_entrs > 0)
|
||||
fprintf(_YAP_stderr,
|
||||
fprintf(Yap_stderr,
|
||||
"[GC] Trail: unmarked %ld dbentries (%ld%%) out of %ld\n",
|
||||
(long int)hp_not_in_use,
|
||||
(long int)(hp_not_in_use*100/hp_entrs),
|
||||
(long int)hp_entrs);
|
||||
if (hp_in_use_erased > 0 && hp_erased > 0)
|
||||
fprintf(_YAP_stderr,
|
||||
fprintf(Yap_stderr,
|
||||
"[GC] Trail: deleted %ld dbentries (%ld%%) out of %ld\n",
|
||||
(long int)hp_erased,
|
||||
(long int)(hp_erased*100/(hp_erased+hp_in_use_erased)),
|
||||
(long int)(hp_erased+hp_in_use_erased));
|
||||
#endif
|
||||
fprintf(_YAP_stderr,
|
||||
fprintf(Yap_stderr,
|
||||
"[GC] Heap: recovered %ld bytes (%ld%%) out of %ld\n",
|
||||
(unsigned long int)(OldHeapUsed-HeapUsed),
|
||||
(unsigned long int)((OldHeapUsed-HeapUsed)/(OldHeapUsed/100)),
|
||||
@ -2062,7 +2062,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR)
|
||||
char *ocl = (char *)cl;
|
||||
cl = cl->u.NextCl;
|
||||
*cptr = cl;
|
||||
_YAP_FreeCodeSpace(ocl);
|
||||
Yap_FreeCodeSpace(ocl);
|
||||
} else {
|
||||
cl->ClFlags &= ~GcFoundMask;
|
||||
cptr = &(cl->u.NextCl);
|
||||
@ -2180,12 +2180,12 @@ sweep_choicepoints(choiceptr gc_B)
|
||||
#endif
|
||||
{
|
||||
op = rtp->opc;
|
||||
opnum = _YAP_op_from_opcode(op);
|
||||
opnum = Yap_op_from_opcode(op);
|
||||
}
|
||||
|
||||
restart_cp:
|
||||
/*
|
||||
* fprintf(_YAP_stderr,"sweeping cps: %x, %x, %x\n",
|
||||
* fprintf(Yap_stderr,"sweeping cps: %x, %x, %x\n",
|
||||
* *gc_B,CP_Extra(gc_B),CP_Nargs(gc_B));
|
||||
*/
|
||||
/* any choice point */
|
||||
@ -2223,7 +2223,7 @@ sweep_choicepoints(choiceptr gc_B)
|
||||
case _count_retry:
|
||||
rtp = NEXTOP(rtp,l);
|
||||
op = rtp->opc;
|
||||
opnum = _YAP_op_from_opcode(op);
|
||||
opnum = Yap_op_from_opcode(op);
|
||||
goto restart_cp;
|
||||
#ifdef TABLING
|
||||
case _table_answer_resolution:
|
||||
@ -2465,7 +2465,7 @@ update_relocation_chain(CELL_PTR current, CELL_PTR dest)
|
||||
}
|
||||
#ifdef DEBUG
|
||||
else {
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, "ATOMIC in a GC relocation chain");
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, "ATOMIC in a GC relocation chain");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -2601,7 +2601,7 @@ compact_heap(void)
|
||||
|
||||
#ifdef DEBUG
|
||||
if (total_marked != found_marked)
|
||||
fprintf(_YAP_stderr,"[GC] Upward (%d): %ld total against %ld found\n",
|
||||
fprintf(Yap_stderr,"[GC] Upward (%d): %ld total against %ld found\n",
|
||||
gc_calls,
|
||||
(unsigned long int)total_marked,
|
||||
(unsigned long int)found_marked);
|
||||
@ -2659,7 +2659,7 @@ compact_heap(void)
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (total_marked != found_marked)
|
||||
fprintf(_YAP_stderr,"[GC] Downward (%d): %ld total against %ld found\n",
|
||||
fprintf(Yap_stderr,"[GC] Downward (%d): %ld total against %ld found\n",
|
||||
gc_calls,
|
||||
(unsigned long int)total_marked,
|
||||
(unsigned long int)found_marked);
|
||||
@ -2702,7 +2702,7 @@ adjust_cp_hbs(void)
|
||||
gc_B->cp_h = H0;
|
||||
break;
|
||||
} else {
|
||||
_YAP_Error(SYSTEM_ERROR,TermNil,"Bug in Garbage collector");
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,"Bug in Garbage collector");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2793,7 +2793,7 @@ icompact_heap(void)
|
||||
|
||||
#ifdef DEBUG
|
||||
if (total_marked != found_marked)
|
||||
fprintf(_YAP_stderr,"[GC] Upward (%d): %ld total against %ld found\n",
|
||||
fprintf(Yap_stderr,"[GC] Upward (%d): %ld total against %ld found\n",
|
||||
gc_calls,
|
||||
(unsigned long int)total_marked,
|
||||
(unsigned long int)found_marked);
|
||||
@ -2848,7 +2848,7 @@ icompact_heap(void)
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (total_marked != found_marked)
|
||||
fprintf(_YAP_stderr,"[GC] Downward (%d): %ld total against %ld found\n",
|
||||
fprintf(Yap_stderr,"[GC] Downward (%d): %ld total against %ld found\n",
|
||||
gc_calls,
|
||||
(unsigned long int)total_marked,
|
||||
(unsigned long int)found_marked);
|
||||
@ -2903,7 +2903,7 @@ marking_phase(tr_fr_ptr old_TR, CELL *current_env, yamop *curp, CELL *max)
|
||||
/* These two must be marked first so that our trail optimisation won't lose
|
||||
values */
|
||||
#ifdef COROUTINING
|
||||
_YAP_mark_all_suspended_goals();
|
||||
Yap_mark_all_suspended_goals();
|
||||
#endif
|
||||
mark_regs(old_TR); /* active registers & trail */
|
||||
#ifdef COROUTINING
|
||||
@ -2921,7 +2921,7 @@ marking_phase(tr_fr_ptr old_TR, CELL *current_env, yamop *curp, CELL *max)
|
||||
static void
|
||||
sweep_delays(CELL *max)
|
||||
{
|
||||
CELL *ptr = (CELL *)_YAP_GlobalBase;
|
||||
CELL *ptr = (CELL *)Yap_GlobalBase;
|
||||
while (ptr < max) {
|
||||
if (MARKED(*ptr)) {
|
||||
UNMARK(ptr);
|
||||
@ -2952,12 +2952,12 @@ compaction_phase(tr_fr_ptr old_TR, CELL *current_env, yamop *curp, CELL *max)
|
||||
#ifdef HYBRID_SCHEME
|
||||
#ifdef DEBUG
|
||||
if (total_marked != iptop-(CELL_PTR *)H && iptop < (CELL_PTR *)ASP -1024)
|
||||
fprintf(_YAP_stderr,"[GC] Oops on iptop-H (%d) vs %d\n", iptop-(CELL_PTR *)H, total_marked);
|
||||
fprintf(Yap_stderr,"[GC] Oops on iptop-H (%d) vs %d\n", iptop-(CELL_PTR *)H, total_marked);
|
||||
#endif
|
||||
if (iptop < (CELL_PTR *)ASP && 10*total_marked < H-H0) {
|
||||
#ifdef INSTRUMENT_GC
|
||||
int effectiveness = (((H-H0)-total_marked)*100)/(H-H0);
|
||||
fprintf(_YAP_stderr,"[GC] using pointers (%d)\n", effectiveness);
|
||||
fprintf(Yap_stderr,"[GC] using pointers (%d)\n", effectiveness);
|
||||
#endif
|
||||
quicksort((CELL_PTR *)H, 0, (iptop-(CELL_PTR *)H)-1);
|
||||
adjust_cp_hbs();
|
||||
@ -2983,7 +2983,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
|
||||
tr_fr_ptr old_TR;
|
||||
Int m_time, c_time, time_start, gc_time;
|
||||
#if COROUTINING
|
||||
CELL *max = (CELL *)_YAP_ReadTimedVar(DelayedVars);
|
||||
CELL *max = (CELL *)Yap_ReadTimedVar(DelayedVars);
|
||||
#else
|
||||
CELL *max = NULL;
|
||||
#endif
|
||||
@ -2992,8 +2992,8 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
|
||||
|
||||
#if COROUTINING
|
||||
if (H0 - max < 1024+(2*NUM_OF_ATTS)) {
|
||||
if (!_YAP_growglobal(¤t_env)) {
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, _YAP_ErrorMessage);
|
||||
if (!Yap_growglobal(¤t_env)) {
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@ -3021,40 +3021,40 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
|
||||
#ifdef DEBUG
|
||||
check_global();
|
||||
#endif
|
||||
if (_YAP_GetValue(AtomGcTrace) != TermNil)
|
||||
if (Yap_GetValue(AtomGcTrace) != TermNil)
|
||||
gc_trace = 1;
|
||||
/* sanity check: can we still do garbage_collection ? */
|
||||
if ((CELL)_YAP_TrailTop & (MBIT|RBIT)) {
|
||||
if ((CELL)Yap_TrailTop & (MBIT|RBIT)) {
|
||||
/* oops, we can't */
|
||||
if (gc_verbose) {
|
||||
fprintf(_YAP_stderr, "[GC] TrailTop at %p clashes with gc bits: %lx\n", _YAP_TrailTop, (unsigned long int)(MBIT|RBIT));
|
||||
fprintf(_YAP_stderr, "[GC] garbage collection disallowed\n");
|
||||
fprintf(Yap_stderr, "[GC] TrailTop at %p clashes with gc bits: %lx\n", Yap_TrailTop, (unsigned long int)(MBIT|RBIT));
|
||||
fprintf(Yap_stderr, "[GC] garbage collection disallowed\n");
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
gc_calls++;
|
||||
if (gc_trace) {
|
||||
fprintf(_YAP_stderr, "[gc]\n");
|
||||
fprintf(Yap_stderr, "[gc]\n");
|
||||
} else if (gc_verbose) {
|
||||
fprintf(_YAP_stderr, "[GC] Start of garbage collection %d:\n", gc_calls);
|
||||
fprintf(Yap_stderr, "[GC] Start of garbage collection %d:\n", gc_calls);
|
||||
#ifndef EARLY_RESET
|
||||
fprintf(_YAP_stderr, "[GC] no early reset in trail\n");
|
||||
fprintf(Yap_stderr, "[GC] no early reset in trail\n");
|
||||
#endif
|
||||
fprintf(_YAP_stderr, "[GC] Global: %8ld cells (%p-%p)\n", (long int)heap_cells,H0,H);
|
||||
fprintf(_YAP_stderr, "[GC] Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
|
||||
fprintf(_YAP_stderr, "[GC] Trail:%8ld cells (%p-%p)\n",
|
||||
(unsigned long int)(TR-(tr_fr_ptr)_YAP_TrailBase),_YAP_TrailBase,TR);
|
||||
fprintf(Yap_stderr, "[GC] Global: %8ld cells (%p-%p)\n", (long int)heap_cells,H0,H);
|
||||
fprintf(Yap_stderr, "[GC] Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
|
||||
fprintf(Yap_stderr, "[GC] Trail:%8ld cells (%p-%p)\n",
|
||||
(unsigned long int)(TR-(tr_fr_ptr)Yap_TrailBase),Yap_TrailBase,TR);
|
||||
}
|
||||
if (HeapTop >= _YAP_GlobalBase - MinHeapGap) {
|
||||
if (HeapTop >= Yap_GlobalBase - MinHeapGap) {
|
||||
*--ASP = (CELL)current_env;
|
||||
if (!_YAP_growheap(FALSE)) {
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, _YAP_ErrorMessage);
|
||||
if (!Yap_growheap(FALSE)) {
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
}
|
||||
current_env = (CELL *)*ASP;
|
||||
ASP++;
|
||||
}
|
||||
time_start = _YAP_cputime();
|
||||
time_start = Yap_cputime();
|
||||
total_marked = 0;
|
||||
discard_trail_entries = 0;
|
||||
#ifdef HYBRID_SCHEME
|
||||
@ -3065,26 +3065,26 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
|
||||
old_TR = TR;
|
||||
push_registers(predarity, nextop);
|
||||
marking_phase(old_TR, current_env, nextop, max);
|
||||
m_time = _YAP_cputime();
|
||||
m_time = Yap_cputime();
|
||||
gc_time = m_time-time_start;
|
||||
if (heap_cells)
|
||||
effectiveness = ((heap_cells-total_marked)*100)/heap_cells;
|
||||
else
|
||||
effectiveness = 0;
|
||||
if (gc_verbose) {
|
||||
fprintf(_YAP_stderr, "[GC] Mark: Recovered %ld cells of %ld (%ld%%) in %g sec\n",
|
||||
fprintf(Yap_stderr, "[GC] Mark: Recovered %ld cells of %ld (%ld%%) in %g sec\n",
|
||||
(long int)(heap_cells-total_marked), (long int)heap_cells, (long int)effectiveness, (double)(m_time-time_start)/1000);
|
||||
#ifdef INSTRUMENT_GC
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<16; i++) {
|
||||
if (chain[i]) {
|
||||
fprintf(_YAP_stderr, "[GC] chain[%d]=%lu\n", i, chain[i]);
|
||||
fprintf(Yap_stderr, "[GC] chain[%d]=%lu\n", i, chain[i]);
|
||||
}
|
||||
}
|
||||
put_type_info((unsigned long int)total_marked);
|
||||
fprintf(_YAP_stderr,"[GC] %lu/%ld before and %lu/%ld after\n", old_vars, (unsigned long int)(B->cp_h-H0), new_vars, (unsigned long int)(H-B->cp_h));
|
||||
fprintf(_YAP_stderr,"[GC] %ld choicepoints\n", num_bs);
|
||||
fprintf(Yap_stderr,"[GC] %lu/%ld before and %lu/%ld after\n", old_vars, (unsigned long int)(B->cp_h-H0), new_vars, (unsigned long int)(H-B->cp_h));
|
||||
fprintf(Yap_stderr,"[GC] %ld choicepoints\n", num_bs);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -3094,16 +3094,16 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
|
||||
pop_registers(predarity, nextop);
|
||||
TR = new_TR;
|
||||
YAPLeaveCriticalSection();
|
||||
c_time = _YAP_cputime();
|
||||
c_time = Yap_cputime();
|
||||
if (gc_verbose) {
|
||||
fprintf(_YAP_stderr, "[GC] Compress: took %g sec\n", (double)(c_time-time_start)/1000);
|
||||
fprintf(Yap_stderr, "[GC] Compress: took %g sec\n", (double)(c_time-time_start)/1000);
|
||||
}
|
||||
gc_time += (c_time-time_start);
|
||||
tot_gc_time += gc_time;
|
||||
tot_gc_recovered += heap_cells-total_marked;
|
||||
if (gc_verbose) {
|
||||
fprintf(_YAP_stderr, "[GC] GC %d took %g sec, total of %g sec doing GC so far.\n", gc_calls, (double)gc_time/1000, (double)tot_gc_time/1000);
|
||||
fprintf(_YAP_stderr, "[GC] Left %ld cells free in stacks.\n",
|
||||
fprintf(Yap_stderr, "[GC] GC %d took %g sec, total of %g sec doing GC so far.\n", gc_calls, (double)gc_time/1000, (double)tot_gc_time/1000);
|
||||
fprintf(Yap_stderr, "[GC] Left %ld cells free in stacks.\n",
|
||||
(unsigned long int)(ASP-H));
|
||||
}
|
||||
check_global();
|
||||
@ -3117,13 +3117,13 @@ is_gc_verbose(void)
|
||||
/* always give info when we are debugging gc */
|
||||
return(TRUE);
|
||||
#else
|
||||
return(_YAP_GetValue(AtomGcVerbose) != TermNil ||
|
||||
_YAP_GetValue(AtomGcVeryVerbose) != TermNil);
|
||||
return(Yap_GetValue(AtomGcVerbose) != TermNil ||
|
||||
Yap_GetValue(AtomGcVeryVerbose) != TermNil);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
_YAP_is_gc_verbose(void)
|
||||
Yap_is_gc_verbose(void)
|
||||
{
|
||||
return is_gc_verbose();
|
||||
}
|
||||
@ -3131,11 +3131,11 @@ _YAP_is_gc_verbose(void)
|
||||
static int
|
||||
is_gc_very_verbose(void)
|
||||
{
|
||||
return(_YAP_GetValue(AtomGcVeryVerbose) != TermNil);
|
||||
return(Yap_GetValue(AtomGcVeryVerbose) != TermNil);
|
||||
}
|
||||
|
||||
Int
|
||||
_YAP_total_gc_time(void)
|
||||
Yap_total_gc_time(void)
|
||||
{
|
||||
return(tot_gc_time);
|
||||
}
|
||||
@ -3147,13 +3147,13 @@ p_inform_gc(void)
|
||||
Term tt = MkIntegerTerm(gc_calls);
|
||||
Term ts = MkIntegerTerm((tot_gc_recovered*sizeof(CELL)));
|
||||
|
||||
return(_YAP_unify(tn, ARG2) && _YAP_unify(tt, ARG1) && _YAP_unify(ts, ARG3));
|
||||
return(Yap_unify(tn, ARG2) && Yap_unify(tt, ARG1) && Yap_unify(ts, ARG3));
|
||||
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
_YAP_gc(Int predarity, CELL *current_env, yamop *nextop)
|
||||
Yap_gc(Int predarity, CELL *current_env, yamop *nextop)
|
||||
{
|
||||
Int gc_margin = 128;
|
||||
Term Tgc_margin;
|
||||
@ -3162,13 +3162,13 @@ _YAP_gc(Int predarity, CELL *current_env, yamop *nextop)
|
||||
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
if (NOfThreads != 1) {
|
||||
_YAP_Error(SYSTEM_ERROR,TermNil,"cannot perform garbage collection: more than a worker/thread running");
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,"cannot perform garbage collection: more than a worker/thread running");
|
||||
return(FALSE);
|
||||
}
|
||||
#endif
|
||||
if (_YAP_GetValue(AtomGc) != TermNil)
|
||||
if (Yap_GetValue(AtomGc) != TermNil)
|
||||
gc_on = TRUE;
|
||||
if (IsIntTerm(Tgc_margin = _YAP_GetValue(AtomGcMargin)))
|
||||
if (IsIntTerm(Tgc_margin = Yap_GetValue(AtomGcMargin)))
|
||||
gc_margin = IntOfTerm(Tgc_margin);
|
||||
else {
|
||||
if (gc_calls < 8)
|
||||
@ -3195,14 +3195,14 @@ _YAP_gc(Int predarity, CELL *current_env, yamop *nextop)
|
||||
gc_margin = ((gc_margin >> 16) + 1) << 16;
|
||||
if (gc_margin < gap)
|
||||
gc_margin = gap;
|
||||
while (gc_margin >= gap && !_YAP_growstack(gc_margin))
|
||||
while (gc_margin >= gap && !Yap_growstack(gc_margin))
|
||||
gc_margin = gc_margin/2;
|
||||
check_global();
|
||||
return(gc_margin >= gap);
|
||||
}
|
||||
/*
|
||||
* debug for(save_total=1; save_total<=N; ++save_total)
|
||||
* plwrite(XREGS[save_total],_YAP_DebugPutc,0);
|
||||
* plwrite(XREGS[save_total],Yap_DebugPutc,0);
|
||||
*/
|
||||
return ( TRUE );
|
||||
}
|
||||
@ -3216,14 +3216,14 @@ p_gc(void)
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_init_gc(void)
|
||||
Yap_init_gc(void)
|
||||
{
|
||||
_YAP_InitCPred("$gc", 0, p_gc, 0);
|
||||
_YAP_InitCPred("$inform_gc", 3, p_inform_gc, 0);
|
||||
Yap_InitCPred("$gc", 0, p_gc, 0);
|
||||
Yap_InitCPred("$inform_gc", 3, p_inform_gc, 0);
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_inc_mark_variable()
|
||||
Yap_inc_mark_variable()
|
||||
{
|
||||
total_marked++;
|
||||
}
|
||||
|
138
C/index.c
138
C/index.c
@ -126,33 +126,33 @@ static int followed_by_cut(yamop * code)
|
||||
register yamop *p = code;
|
||||
while (TRUE)
|
||||
{
|
||||
if (p->opc == _YAP_opcode(_get_x_var))
|
||||
if (p->opc == Yap_opcode(_get_x_var))
|
||||
p = NEXTOP(p,xx);
|
||||
if (p->opc == _YAP_opcode(_get_y_var))
|
||||
if (p->opc == Yap_opcode(_get_y_var))
|
||||
p = NEXTOP(p,yx);
|
||||
else if (p->opc == _YAP_opcode(_allocate))
|
||||
else if (p->opc == Yap_opcode(_allocate))
|
||||
p = NEXTOP(p,e);
|
||||
else if (p->opc == _YAP_opcode(_unify_x_var))
|
||||
else if (p->opc == Yap_opcode(_unify_x_var))
|
||||
p = NEXTOP(p,ox);
|
||||
else if (p->opc == _YAP_opcode(_unify_y_var))
|
||||
else if (p->opc == Yap_opcode(_unify_y_var))
|
||||
p = NEXTOP(p,oy);
|
||||
else if (p->opc == _YAP_opcode(_unify_l_x_var))
|
||||
else if (p->opc == Yap_opcode(_unify_l_x_var))
|
||||
p = NEXTOP(p,ox);
|
||||
else if (p->opc == _YAP_opcode(_unify_l_y_var))
|
||||
else if (p->opc == Yap_opcode(_unify_l_y_var))
|
||||
p = NEXTOP(p,oy);
|
||||
else if (p->opc == _YAP_opcode(_unify_void))
|
||||
else if (p->opc == Yap_opcode(_unify_void))
|
||||
p = NEXTOP(p,o);
|
||||
else if (p->opc == _YAP_opcode(_unify_n_voids))
|
||||
else if (p->opc == Yap_opcode(_unify_n_voids))
|
||||
p = NEXTOP(p,os);
|
||||
else if (p->opc == _YAP_opcode(_unify_l_void))
|
||||
else if (p->opc == Yap_opcode(_unify_l_void))
|
||||
p = NEXTOP(p,o);
|
||||
else if (p->opc == _YAP_opcode(_unify_l_n_voids))
|
||||
else if (p->opc == Yap_opcode(_unify_l_n_voids))
|
||||
p = NEXTOP(p,os);
|
||||
else if (p->opc == _YAP_opcode(_cut))
|
||||
else if (p->opc == Yap_opcode(_cut))
|
||||
return(TRUE);
|
||||
else if (p->opc == _YAP_opcode(_cut_t))
|
||||
else if (p->opc == Yap_opcode(_cut_t))
|
||||
return(TRUE);
|
||||
else if (p->opc == _YAP_opcode(_cut_e))
|
||||
else if (p->opc == Yap_opcode(_cut_e))
|
||||
return(TRUE);
|
||||
else return(FALSE);
|
||||
}
|
||||
@ -165,7 +165,7 @@ static int followed_by_cut(yamop * code)
|
||||
inline static void
|
||||
emit_tr(compiler_vm_op op, yamop * Address, int NClauses, int HasCut)
|
||||
{
|
||||
_YAP_emit(op, Unsigned(Address), (NClauses << 1) + HasCut);
|
||||
Yap_emit(op, Unsigned(Address), (NClauses << 1) + HasCut);
|
||||
}
|
||||
|
||||
/* emits an opcode followed by an adress */
|
||||
@ -180,7 +180,7 @@ emit_try(compiler_vm_op op, int op_offset, yamop * Address, int NClauses, int Ha
|
||||
return;
|
||||
}
|
||||
}
|
||||
_YAP_emit((compiler_vm_op)((int)op + op_offset), Unsigned(Address), (NClauses << 1) + HasCut);
|
||||
Yap_emit((compiler_vm_op)((int)op + op_offset), Unsigned(Address), (NClauses << 1) + HasCut);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -200,7 +200,7 @@ inline static yamop *
|
||||
SecB(yamop * Arg)
|
||||
{
|
||||
yamop *pc = NEXTOP(Arg,ld);
|
||||
if (pc->opc == _YAP_opcode(_get_struct))
|
||||
if (pc->opc == Yap_opcode(_get_struct))
|
||||
return (NEXTOP(pc,xf));
|
||||
else
|
||||
return (NEXTOP(pc,xc));
|
||||
@ -225,7 +225,7 @@ inline static yamop *
|
||||
ThiB(yamop * Arg)
|
||||
{
|
||||
yamop *pc = NEXTOP(NEXTOP(Arg,ld),x);
|
||||
if (pc->opc == _YAP_opcode(_unify_struct))
|
||||
if (pc->opc == Yap_opcode(_unify_struct))
|
||||
return (NEXTOP(pc,of));
|
||||
else
|
||||
return (NEXTOP(pc,oc));
|
||||
@ -249,9 +249,9 @@ emit_cp_inst(compiler_vm_op op, yamop * Address, int Flag, int NClausesAfter)
|
||||
|
||||
indexed_code_for_cut = NIL;
|
||||
if (op != try_op && profiling)
|
||||
_YAP_emit(retry_profiled_op, Unsigned(CurrentPred), Zero);
|
||||
Yap_emit(retry_profiled_op, Unsigned(CurrentPred), Zero);
|
||||
else if (op != try_op && call_counting)
|
||||
_YAP_emit(count_retry_op, Unsigned(CurrentPred), Zero);
|
||||
Yap_emit(count_retry_op, Unsigned(CurrentPred), Zero);
|
||||
if (NGroups == 1)
|
||||
Flag = Flag | LoneGroup;
|
||||
else if (Flag & LastGroup) {
|
||||
@ -346,8 +346,8 @@ static CELL
|
||||
emit_space(compiler_vm_op op, int space, int nof)
|
||||
{
|
||||
labelno += 2;
|
||||
_YAP_emit(label_op, labelno, Zero);
|
||||
StorePoint = _YAP_emit_extra_size(op, Unsigned(nof), space);
|
||||
Yap_emit(label_op, labelno, Zero);
|
||||
StorePoint = Yap_emit_extra_size(op, Unsigned(nof), space);
|
||||
return (labelno);
|
||||
}
|
||||
|
||||
@ -356,11 +356,11 @@ static CELL
|
||||
emit_go(int Gender, Term Name)
|
||||
{
|
||||
labelno += 2;
|
||||
_YAP_emit(label_op, labelno, Zero);
|
||||
Yap_emit(label_op, labelno, Zero);
|
||||
if (Gender == ApplCl)
|
||||
StorePoint = _YAP_emit_extra_size(go_f_op, Zero, 3 * CellSize);
|
||||
StorePoint = Yap_emit_extra_size(go_f_op, Zero, 3 * CellSize);
|
||||
else
|
||||
StorePoint = _YAP_emit_extra_size(go_c_op, Zero, 3 * CellSize);
|
||||
StorePoint = Yap_emit_extra_size(go_c_op, Zero, 3 * CellSize);
|
||||
*StorePoint++ = Unsigned(Name);
|
||||
StorePoint[1] = (CELL)FailAddress;
|
||||
return (labelno);
|
||||
@ -371,7 +371,7 @@ emit_go(int Gender, Term Name)
|
||||
static void
|
||||
emit_if_not(Term T1, CELL Ad1, CELL Ad2)
|
||||
{
|
||||
StorePoint = _YAP_emit_extra_size(if_not_op, Zero, 3 * CellSize);
|
||||
StorePoint = Yap_emit_extra_size(if_not_op, Zero, 3 * CellSize);
|
||||
*StorePoint++ = Unsigned(T1);
|
||||
*StorePoint++ = Unsigned(Ad1);
|
||||
StorePoint[0] = Unsigned(Ad2);
|
||||
@ -470,8 +470,8 @@ NGroupsIn(PredEntry *ap)
|
||||
if (y != PresentGroup) {
|
||||
Group++->Last = (ActualCl - 1)->Code;
|
||||
NGroups++;
|
||||
if ((ADDR)Group > _YAP_TrailTop-1024)
|
||||
_YAP_growtrail(64 * 1024L);
|
||||
if ((ADDR)Group > Yap_TrailTop-1024)
|
||||
Yap_growtrail(64 * 1024L);
|
||||
Group->First = q;
|
||||
Group->Start = ActualCl;
|
||||
Group->NCl = 0;
|
||||
@ -502,7 +502,7 @@ NGroupsIn(PredEntry *ap)
|
||||
if (ASP <= CellPtr (ActualCl) + 256) {
|
||||
freep = (char *)ActualCl;
|
||||
save_machine_regs();
|
||||
longjmp(_YAP_CompilerBotch, 3);
|
||||
longjmp(Yap_CompilerBotch, 3);
|
||||
}
|
||||
(Group->Type[x])++;
|
||||
(Group->NCl)++;
|
||||
@ -598,7 +598,7 @@ BuildHash(CELL *WhereTo, int NOfEntries, int TableSize, int Gend)
|
||||
}
|
||||
#ifdef DEBUG
|
||||
#ifdef CLASHES
|
||||
fprintf(_YAP_stderr,"hash table clashes: %d %d\n", clashes, NOfEntries);
|
||||
fprintf(Yap_stderr,"hash table clashes: %d %d\n", clashes, NOfEntries);
|
||||
#endif /* CLASHES */
|
||||
#endif /* DEBUG */
|
||||
}
|
||||
@ -627,7 +627,7 @@ TreatEntry(EntryDef *Entrance, int Gender, int PositionFlag, GroupDef *Gr)
|
||||
/* last group, meaning we already have a choice point set */
|
||||
register yamop * k = (Entrance->First)->Code;
|
||||
labelno += 2;
|
||||
_YAP_emit(label_op, Entrance->Code = labelno, Zero);
|
||||
Yap_emit(label_op, Entrance->Code = labelno, Zero);
|
||||
if (PositionFlag & HeadIndex) {
|
||||
emit_tr(trust_op, ThiB(k), 1, clause_has_cut(k));
|
||||
} else {
|
||||
@ -641,7 +641,7 @@ TreatEntry(EntryDef *Entrance, int Gender, int PositionFlag, GroupDef *Gr)
|
||||
/* a single alternative and a catchall clause */
|
||||
register yamop * k = (Entrance->First)->Code;
|
||||
labelno += 2;
|
||||
_YAP_emit(label_op, Entrance->Code = labelno, Zero);
|
||||
Yap_emit(label_op, Entrance->Code = labelno, Zero);
|
||||
/* if we are in a list */
|
||||
if (PositionFlag & HeadIndex) {
|
||||
/* we cannot emit to SecLB because switch might have already
|
||||
@ -683,7 +683,7 @@ TreatEntry(EntryDef *Entrance, int Gender, int PositionFlag, GroupDef *Gr)
|
||||
nofalts = Gr->NofClausesAfter+nofentries;
|
||||
k = Entrance->First;
|
||||
labelno += 2;
|
||||
_YAP_emit(label_op, (Entrance->Code = labelno), Zero);
|
||||
Yap_emit(label_op, (Entrance->Code = labelno), Zero);
|
||||
emit_cp_inst(try_op, k->Code, PositionFlag, nofalts);
|
||||
nofalts--;
|
||||
if (indexed_code_for_cut != NIL) {
|
||||
@ -696,7 +696,7 @@ TreatEntry(EntryDef *Entrance, int Gender, int PositionFlag, GroupDef *Gr)
|
||||
emit_cp_inst(trust_op, k->Code, PositionFlag, nofalts);
|
||||
/* emit a jump with the place to jump to after finishing this group */
|
||||
if (NGroups > 1 && !(PositionFlag & LastGroup) && !ExtendedSingle)
|
||||
_YAP_emit(jump_op, (CELL)((Gr+1)->First), Zero);
|
||||
Yap_emit(jump_op, (CELL)((Gr+1)->First), Zero);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -725,8 +725,8 @@ DealFixed(ClauseDef *j, int Gender, compiler_vm_op op, int Flag, GroupDef *Gr)
|
||||
while (l < NDiffTerms && Entry->Class != HeadName)
|
||||
Entry++, l++;
|
||||
if (l == NDiffTerms) {
|
||||
if ((ADDR)Entry > _YAP_TrailTop-1024)
|
||||
_YAP_growtrail(64 * 1024L);
|
||||
if ((ADDR)Entry > Yap_TrailTop-1024)
|
||||
Yap_growtrail(64 * 1024L);
|
||||
Entry->Class = HeadName;
|
||||
Entry->Last = Entry->First = j;
|
||||
NDiffTerms++;
|
||||
@ -784,7 +784,7 @@ DealFixedWithBips(ClauseDef *j, int NClauses, int Flag, GroupDef *Gr)
|
||||
|
||||
labelno += 2;
|
||||
my_labelno = labelno;
|
||||
_YAP_emit(label_op, labelno, Zero);
|
||||
Yap_emit(label_op, labelno, Zero);
|
||||
#ifdef AGRESSIVE_BIPS
|
||||
if (j->Name != 0x0 && j->Next->Name != 0x0) {
|
||||
/*
|
||||
@ -809,7 +809,7 @@ DealFixedWithBips(ClauseDef *j, int NClauses, int Flag, GroupDef *Gr)
|
||||
while (j->Name != 0x0) i++, j = j->Next;
|
||||
Gr->NofClausesAfter = old_NAlts + G->NCl - i;
|
||||
DealFixed(j0, AtCl, switch_c_op, FirstIndex | IsAtom, Gr);
|
||||
_YAP_emit(label_op, old_labelno, Zero);
|
||||
Yap_emit(label_op, old_labelno, Zero);
|
||||
FailAddress = old_FailAddress;
|
||||
ExtendedSingle = old_ExtendedSingle;
|
||||
Gr->NofClausesAfter = old_NAlts;
|
||||
@ -836,7 +836,7 @@ DealFixedWithBips(ClauseDef *j, int NClauses, int Flag, GroupDef *Gr)
|
||||
emit_cp_inst(trust_op, j->Code, Flag, nofalts);
|
||||
/* emit a jump with the place to jump to after finishing this group */
|
||||
if (NGroups > 1 && !(Flag & LastGroup) && !ExtendedSingle)
|
||||
_YAP_emit(jump_op, (CELL)((Gr+1)->First), Zero);
|
||||
Yap_emit(jump_op, (CELL)((Gr+1)->First), Zero);
|
||||
return(my_labelno);
|
||||
}
|
||||
|
||||
@ -850,14 +850,14 @@ DealCons(int i)
|
||||
if (FinalGr(i)) {
|
||||
yamop * Cl = FindFirst(i, AtCl);
|
||||
labelno += 2;
|
||||
_YAP_emit(label_op, labelno, Zero);
|
||||
Yap_emit(label_op, labelno, Zero);
|
||||
emit_tr(trust_op, Cl, 1, clause_has_cut(Cl));
|
||||
return (labelno);
|
||||
} else if (ExtendedSingle) {
|
||||
yamop * Cl = FindFirst(i, AtCl);
|
||||
|
||||
labelno += 2;
|
||||
_YAP_emit(label_op, labelno, Zero);
|
||||
Yap_emit(label_op, labelno, Zero);
|
||||
emit_tr(try_op, Cl, 2, clause_has_cut(Cl));
|
||||
emit_tr(trust_op, FailAddress, 1, clause_has_cut(FailAddress));
|
||||
return (labelno);
|
||||
@ -895,13 +895,13 @@ DealAppl(int i)
|
||||
if (FinalGr(i)) {
|
||||
yamop * Cl = FindFirst(i, ApplCl);
|
||||
labelno += 2;
|
||||
_YAP_emit(label_op, labelno, Zero);
|
||||
Yap_emit(label_op, labelno, Zero);
|
||||
emit_tr(trust_op, Cl, 1, clause_has_cut(Cl));
|
||||
return (labelno);
|
||||
} else if (ExtendedSingle) {
|
||||
yamop * Cl = FindFirst(i, ApplCl);
|
||||
labelno += 2;
|
||||
_YAP_emit(label_op, labelno, Zero);
|
||||
Yap_emit(label_op, labelno, Zero);
|
||||
emit_tr(try_op, Cl, 2, clause_has_cut(Cl));
|
||||
emit_tr(trust_op, FailAddress, 1, clause_has_cut(FailAddress));
|
||||
return (labelno);
|
||||
@ -929,12 +929,12 @@ StartList(int i)
|
||||
j++;
|
||||
if (FinalGr(i)) {
|
||||
labelno += 2;
|
||||
_YAP_emit(label_op, labelno, Zero);
|
||||
Yap_emit(label_op, labelno, Zero);
|
||||
emit_tr(trust_op, SecLB(j->Code), 1, clause_has_cut(j->Code));
|
||||
return (labelno);
|
||||
} else if (ExtendedSingle) {
|
||||
labelno += 2;
|
||||
_YAP_emit(label_op, labelno, Zero);
|
||||
Yap_emit(label_op, labelno, Zero);
|
||||
emit_tr(try_op, SecLB(j->Code), 2, clause_has_cut(j->Code));
|
||||
emit_tr(trust_op, FailAddress, 1, clause_has_cut(FailAddress));
|
||||
return (labelno);
|
||||
@ -978,7 +978,7 @@ DealLList(ClauseDef *j, int NOfClauses, int PositionFlag, int NG)
|
||||
else if (NOfClauses == 1) {
|
||||
if (FinalGr(NG)) {
|
||||
labelno += 2;
|
||||
_YAP_emit(label_op, labelno, Zero);
|
||||
Yap_emit(label_op, labelno, Zero);
|
||||
if (PositionFlag & FirstIndex)
|
||||
emit_tr(trust_op, SecLB(j->Code), 1, clause_has_cut(j->Code));
|
||||
else
|
||||
@ -986,7 +986,7 @@ DealLList(ClauseDef *j, int NOfClauses, int PositionFlag, int NG)
|
||||
return (labelno);
|
||||
} else if (ExtendedSingle) {
|
||||
labelno += 2;
|
||||
_YAP_emit(label_op, labelno, Zero);
|
||||
Yap_emit(label_op, labelno, Zero);
|
||||
if (PositionFlag & FirstIndex)
|
||||
emit_tr(try_op, SecLB(j->Code), 2, clause_has_cut(j->Code));
|
||||
else
|
||||
@ -1001,7 +1001,7 @@ DealLList(ClauseDef *j, int NOfClauses, int PositionFlag, int NG)
|
||||
if (FinalGr(NG))
|
||||
PositionFlag |= LastGroup;
|
||||
labelno += 2;
|
||||
_YAP_emit(label_op, labelno, Zero);
|
||||
Yap_emit(label_op, labelno, Zero);
|
||||
nofalts = Groups[NG].NofClausesAfter+NOfClauses;
|
||||
emit_cp_inst(try_op, j->Code, PositionFlag, nofalts);
|
||||
nofalts--;
|
||||
@ -1017,7 +1017,7 @@ DealLList(ClauseDef *j, int NOfClauses, int PositionFlag, int NG)
|
||||
emit_cp_inst(trust_op, j->Code, PositionFlag, nofalts);
|
||||
/* emit a jump with the place to jump to after finishing this group */
|
||||
if (NGroups > 1 && !(PositionFlag & LastGroup) && !ExtendedSingle)
|
||||
_YAP_emit(jump_op, (CELL)(Groups[NG+1].First), Zero);
|
||||
Yap_emit(jump_op, (CELL)(Groups[NG+1].First), Zero);
|
||||
return (labelno);
|
||||
}
|
||||
}
|
||||
@ -1095,7 +1095,7 @@ DealList(int i)
|
||||
else
|
||||
VFlags = FirstIndex | LastFoundList;
|
||||
labelno += 2;
|
||||
_YAP_emit(label_op, labelno, Zero);
|
||||
Yap_emit(label_op, labelno, Zero);
|
||||
emit_cp_inst(try_op, j->Code, VFlags, nofalts);
|
||||
nofalts--;
|
||||
if (indexed_code_for_cut != NIL) {
|
||||
@ -1110,7 +1110,7 @@ DealList(int i)
|
||||
emit_cp_inst(trust_op, j->Code, VFlags, nofalts);
|
||||
/* emit a jump with the place to jump to after finishing this group */
|
||||
if (NGroups > 1 && !(VFlags & LastGroup) && !ExtendedSingle)
|
||||
_YAP_emit(jump_op, (CELL)(Groups[i+1].First), Zero);
|
||||
Yap_emit(jump_op, (CELL)(Groups[i+1].First), Zero);
|
||||
return (labelno);
|
||||
}
|
||||
}
|
||||
@ -1239,11 +1239,11 @@ IndexVarGr(int Count)
|
||||
Cla++;
|
||||
nofalts--;
|
||||
} else if (Count == NGroups - 1 && Gr->NCl == 1) {
|
||||
_YAP_emit(label_op, Unsigned(Gr->First), Zero);
|
||||
Yap_emit(label_op, Unsigned(Gr->First), Zero);
|
||||
emit_tr(trust_op, Body((Cla)->Code), 1, clause_has_cut(Cla->Code));
|
||||
return;
|
||||
} else {
|
||||
_YAP_emit(label_op, Unsigned(Gr->First), Zero);
|
||||
Yap_emit(label_op, Unsigned(Gr->First), Zero);
|
||||
emit_tr(retry_op, Body((Cla)->Code), nofalts, clause_has_cut(Cla->Code));
|
||||
Cla++;
|
||||
nofalts--;
|
||||
@ -1277,7 +1277,7 @@ ComplexCase(void)
|
||||
|
||||
if (IsExtendedSingle(0))
|
||||
return (SimpleCase());
|
||||
_YAP_emit(jump_v_op, (CELL) FirstCl, Zero);
|
||||
Yap_emit(jump_v_op, (CELL) FirstCl, Zero);
|
||||
if (Groups[0].Type[VarCl] == 0)
|
||||
i = 0;
|
||||
else {
|
||||
@ -1317,19 +1317,19 @@ SpecialCases(void)
|
||||
}
|
||||
|
||||
CODEADDR
|
||||
_YAP_PredIsIndexable(PredEntry *ap)
|
||||
Yap_PredIsIndexable(PredEntry *ap)
|
||||
{
|
||||
int NGr, Indexable = 0;
|
||||
CODEADDR indx_out = NIL;
|
||||
log_update = 0;
|
||||
|
||||
if (setjmp(_YAP_CompilerBotch) == 3) {
|
||||
if (setjmp(Yap_CompilerBotch) == 3) {
|
||||
/* just duplicate the stack */
|
||||
restore_machine_regs();
|
||||
_YAP_gc(ap->ArityOfPE, ENV, CP);
|
||||
Yap_gc(ap->ArityOfPE, ENV, CP);
|
||||
}
|
||||
restart_index:
|
||||
_YAP_ErrorMessage = NULL;
|
||||
Yap_ErrorMessage = NULL;
|
||||
labelno = 1;
|
||||
RemovedCl = FALSE;
|
||||
FirstCl = (yamop *)(ap->FirstClause);
|
||||
@ -1351,7 +1351,7 @@ _YAP_PredIsIndexable(PredEntry *ap)
|
||||
Entries = (EntryDef *) (Groups + NGroups);
|
||||
CodeStart = cpc = NIL;
|
||||
freep = (char *) (ArOfCl + NClauses);
|
||||
if (_YAP_ErrorMessage != NULL) {
|
||||
if (Yap_ErrorMessage != NULL) {
|
||||
return (NIL);
|
||||
}
|
||||
if (CurrentPred->PredFlags & LogUpdatePredFlag) {
|
||||
@ -1370,7 +1370,7 @@ _YAP_PredIsIndexable(PredEntry *ap)
|
||||
Indexable = SpecialCases();
|
||||
}
|
||||
if (CellPtr(freep) >= ASP) {
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, "out of stack space while indexing");
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, "out of stack space while indexing");
|
||||
return(NIL);
|
||||
}
|
||||
if (log_update && NClauses > 1) {
|
||||
@ -1378,8 +1378,8 @@ _YAP_PredIsIndexable(PredEntry *ap)
|
||||
Clause *cl;
|
||||
|
||||
Indexable = TRUE;
|
||||
_YAP_emit(label_op, log_update, Zero);
|
||||
_YAP_emit(try_op, Unsigned(Body(ArOfCl[0].Code)), Zero);
|
||||
Yap_emit(label_op, log_update, Zero);
|
||||
Yap_emit(try_op, Unsigned(Body(ArOfCl[0].Code)), Zero);
|
||||
cl = ClauseCodeToClause(ArOfCl[0].Code);
|
||||
if (cl->ClFlags & LogUpdRuleMask) {
|
||||
cl->u2.ClExt->u.EC.ClRefs++;
|
||||
@ -1387,7 +1387,7 @@ _YAP_PredIsIndexable(PredEntry *ap)
|
||||
cl->u2.ClUse++;
|
||||
}
|
||||
for (i = 1; i < NClauses-1; i++) {
|
||||
_YAP_emit(retry_op, Unsigned(Body(ArOfCl[i].Code)), Zero);
|
||||
Yap_emit(retry_op, Unsigned(Body(ArOfCl[i].Code)), Zero);
|
||||
cl = ClauseCodeToClause(ArOfCl[0].Code);
|
||||
if (cl->ClFlags & LogUpdRuleMask) {
|
||||
cl->u2.ClExt->u.EC.ClRefs++;
|
||||
@ -1395,7 +1395,7 @@ _YAP_PredIsIndexable(PredEntry *ap)
|
||||
cl->u2.ClUse++;
|
||||
}
|
||||
}
|
||||
_YAP_emit(trust_op, Unsigned(Body(ArOfCl[i].Code)), Zero);
|
||||
Yap_emit(trust_op, Unsigned(Body(ArOfCl[i].Code)), Zero);
|
||||
cl = ClauseCodeToClause(ArOfCl[i].Code);
|
||||
if (cl->ClFlags & LogUpdRuleMask) {
|
||||
cl->u2.ClExt->u.EC.ClRefs++;
|
||||
@ -1407,13 +1407,13 @@ _YAP_PredIsIndexable(PredEntry *ap)
|
||||
return (NIL);
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
if (_YAP_Option['i' - 'a' + 1]) {
|
||||
_YAP_ShowCode();
|
||||
if (Yap_Option['i' - 'a' + 1]) {
|
||||
Yap_ShowCode();
|
||||
}
|
||||
#endif
|
||||
if ((indx_out = _YAP_assemble(ASSEMBLING_INDEX)) == NIL) {
|
||||
if (!_YAP_growheap(FALSE)) {
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, _YAP_ErrorMessage);
|
||||
if ((indx_out = Yap_assemble(ASSEMBLING_INDEX)) == NIL) {
|
||||
if (!Yap_growheap(FALSE)) {
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
}
|
||||
goto restart_index;
|
||||
|
106
C/inlines.c
106
C/inlines.c
@ -245,7 +245,7 @@ p_var(void)
|
||||
static Int
|
||||
p_equal(void)
|
||||
{ /* ?=? */
|
||||
return(_YAP_IUnify(ARG1, ARG2));
|
||||
return(Yap_IUnify(ARG1, ARG2));
|
||||
}
|
||||
|
||||
static Int
|
||||
@ -288,7 +288,7 @@ p_eq(void)
|
||||
return(LongIntOfTerm(d0) == LongIntOfTerm(d1));
|
||||
#ifdef USE_GMP
|
||||
case (CELL)FunctorBigInt:
|
||||
return (mpz_cmp(_YAP_BigIntOfTerm(d0), _YAP_BigIntOfTerm(d1)) == 0);
|
||||
return (mpz_cmp(Yap_BigIntOfTerm(d0), Yap_BigIntOfTerm(d1)) == 0);
|
||||
#endif
|
||||
case (CELL)FunctorDouble:
|
||||
return(FloatOfTerm(d0) == FloatOfTerm(d1));
|
||||
@ -362,7 +362,7 @@ p_dif(void)
|
||||
* woken goals that should be ok, but otherwise we need
|
||||
* to restore WokenGoals to its previous value.
|
||||
*/
|
||||
CELL OldWokenGoals = _YAP_ReadTimedVar(WokenGoals);
|
||||
CELL OldWokenGoals = Yap_ReadTimedVar(WokenGoals);
|
||||
|
||||
#endif
|
||||
/* We will have to look inside compound terms */
|
||||
@ -377,7 +377,7 @@ p_dif(void)
|
||||
HBREG = H;
|
||||
B = (choiceptr) H;
|
||||
save_hb();
|
||||
if (_YAP_IUnify(d0, d1) == TRUE) {
|
||||
if (Yap_IUnify(d0, d1) == TRUE) {
|
||||
/* restore B, no need to restore HB */
|
||||
B = pt1;
|
||||
return(FALSE);
|
||||
@ -386,7 +386,7 @@ p_dif(void)
|
||||
/* restore B, and later HB */
|
||||
ENDCHO(pt1);
|
||||
BEGP(pt1);
|
||||
/* untrail all bindings made by _YAP_IUnify */
|
||||
/* untrail all bindings made by Yap_IUnify */
|
||||
while (TR != (tr_fr_ptr)pt0) {
|
||||
pt1 = (CELL *) TrailTerm(--TR);
|
||||
RESET_VARIABLE(pt1);
|
||||
@ -396,7 +396,7 @@ p_dif(void)
|
||||
}
|
||||
#ifdef COROUTINING
|
||||
/* now restore Woken Goals to its old value */
|
||||
_YAP_UpdateTimedVar(WokenGoals, OldWokenGoals);
|
||||
Yap_UpdateTimedVar(WokenGoals, OldWokenGoals);
|
||||
#endif
|
||||
return(TRUE);
|
||||
ENDP(pt0);
|
||||
@ -432,7 +432,7 @@ p_arg(void)
|
||||
else if (IsLongIntTerm(d0)) {
|
||||
d0 = LongIntOfTerm(d0);
|
||||
} else {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER,d0,"arg 1 of arg/3");
|
||||
Yap_Error(TYPE_ERROR_INTEGER,d0,"arg 1 of arg/3");
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
@ -453,10 +453,10 @@ p_arg(void)
|
||||
save_hb();
|
||||
if ((Int)d0 <= 0 ||
|
||||
(Int)d0 > ArityOfFunctor((Functor) d1) ||
|
||||
_YAP_IUnify(pt0[d0], ARG3) == FALSE) {
|
||||
Yap_IUnify(pt0[d0], ARG3) == FALSE) {
|
||||
/* don't complain here for Prolog compatibility
|
||||
if ((Int)d0 <= 0) {
|
||||
_YAP_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO,
|
||||
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO,
|
||||
MkIntegerTerm(d0),"arg 1 of arg/3");
|
||||
}
|
||||
*/
|
||||
@ -470,41 +470,41 @@ p_arg(void)
|
||||
pt0 = RepPair(d1);
|
||||
if (d0 == 1) {
|
||||
save_hb();
|
||||
if (_YAP_IUnify((CELL)pt0, ARG3) == FALSE) {
|
||||
if (Yap_IUnify((CELL)pt0, ARG3) == FALSE) {
|
||||
return(FALSE);
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
else if (d0 == 2) {
|
||||
save_hb();
|
||||
if (_YAP_IUnify((CELL)(pt0+1), ARG3) == FALSE) {
|
||||
if (Yap_IUnify((CELL)(pt0+1), ARG3) == FALSE) {
|
||||
return(FALSE);
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
else {
|
||||
if ((Int)d0 < 0)
|
||||
_YAP_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO,
|
||||
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO,
|
||||
MkIntegerTerm(d0),"arg 1 of arg/3");
|
||||
return(FALSE);
|
||||
}
|
||||
ENDP(pt0);
|
||||
}
|
||||
else {
|
||||
_YAP_Error(TYPE_ERROR_COMPOUND, d1, "arg 2 of arg/3");
|
||||
Yap_Error(TYPE_ERROR_COMPOUND, d1, "arg 2 of arg/3");
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
BEGP(pt0);
|
||||
deref_body(d1, pt0, arg_arg2_unk, arg_arg2_nvar);
|
||||
_YAP_Error(INSTANTIATION_ERROR,(CELL)pt0,"arg 2 of arg/3");;
|
||||
Yap_Error(INSTANTIATION_ERROR,(CELL)pt0,"arg 2 of arg/3");;
|
||||
ENDP(pt0);
|
||||
return(FALSE);
|
||||
ENDD(d1);
|
||||
|
||||
BEGP(pt0);
|
||||
deref_body(d0, pt0, arg_arg1_unk, arg_arg1_nvar);
|
||||
_YAP_Error(INSTANTIATION_ERROR,(CELL)pt0,"arg 1 of arg/3");;
|
||||
Yap_Error(INSTANTIATION_ERROR,(CELL)pt0,"arg 1 of arg/3");;
|
||||
ENDP(pt0);
|
||||
return(FALSE);
|
||||
ENDD(d0);
|
||||
@ -571,7 +571,7 @@ p_functor(void) /* functor(?,?,?) */
|
||||
BIND(pt0, d0, bind_func_nvar_var);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(pt0, d0);
|
||||
if (pt0 < H0) _YAP_WakeUp(pt0);
|
||||
if (pt0 < H0) Yap_WakeUp(pt0);
|
||||
bind_func_nvar_var:
|
||||
#endif
|
||||
/* have to buffer ENDP and label */
|
||||
@ -598,7 +598,7 @@ p_functor(void) /* functor(?,?,?) */
|
||||
/* Done */
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(pt0, d0);
|
||||
if (pt0 < H0) _YAP_WakeUp(pt0);
|
||||
if (pt0 < H0) Yap_WakeUp(pt0);
|
||||
bind_func_nvar3_var:
|
||||
#endif
|
||||
return(TRUE);
|
||||
@ -624,11 +624,11 @@ p_functor(void) /* functor(?,?,?) */
|
||||
if (IsIntTerm(d1))
|
||||
d1 = IntOfTerm(d1);
|
||||
else {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER,ARG3,"functor/3");
|
||||
Yap_Error(TYPE_ERROR_INTEGER,ARG3,"functor/3");
|
||||
return(FALSE);
|
||||
}
|
||||
if (!IsAtomicTerm(d0)) {
|
||||
_YAP_Error(TYPE_ERROR_ATOMIC,d0,"functor/3");
|
||||
Yap_Error(TYPE_ERROR_ATOMIC,d0,"functor/3");
|
||||
return(FALSE);
|
||||
}
|
||||
/* We made it!!!!! we got in d0 the name, in d1 the arity and
|
||||
@ -642,7 +642,7 @@ p_functor(void) /* functor(?,?,?) */
|
||||
else if ((Int)d1 > 0) {
|
||||
/* now let's build a compound term */
|
||||
if (!IsAtomTerm(d0)) {
|
||||
_YAP_Error(TYPE_ERROR_ATOM,d0,"functor/3");
|
||||
Yap_Error(TYPE_ERROR_ATOM,d0,"functor/3");
|
||||
return(FALSE);
|
||||
}
|
||||
BEGP(pt1);
|
||||
@ -650,13 +650,13 @@ p_functor(void) /* functor(?,?,?) */
|
||||
return(FALSE);
|
||||
}
|
||||
else
|
||||
d0 = (CELL) _YAP_MkFunctor(AtomOfTerm(d0), (Int) d1);
|
||||
d0 = (CELL) Yap_MkFunctor(AtomOfTerm(d0), (Int) d1);
|
||||
pt1 = H;
|
||||
*pt1++ = d0;
|
||||
d0 = AbsAppl(H);
|
||||
if (pt1+d1 > ENV - CreepFlag) {
|
||||
if (!_YAP_gc(3, ENV, P)) {
|
||||
_YAP_Error(OUT_OF_STACK_ERROR, TermNil, _YAP_ErrorMessage);
|
||||
if (!Yap_gc(3, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
}
|
||||
goto restart;
|
||||
@ -669,7 +669,7 @@ p_functor(void) /* functor(?,?,?) */
|
||||
H = pt1;
|
||||
ENDP(pt1);
|
||||
} else if ((Int)d1 < 0) {
|
||||
_YAP_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO,MkIntegerTerm(d1),"functor/3");
|
||||
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO,MkIntegerTerm(d1),"functor/3");
|
||||
return(FALSE);
|
||||
}
|
||||
/* else if arity is 0 just pass d0 through */
|
||||
@ -677,7 +677,7 @@ p_functor(void) /* functor(?,?,?) */
|
||||
BIND(pt0, d0, bind_func_var_3nvar);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(pt0, d0);
|
||||
if (pt0 < H0) _YAP_WakeUp(pt0);
|
||||
if (pt0 < H0) Yap_WakeUp(pt0);
|
||||
bind_func_var_3nvar:
|
||||
#endif
|
||||
return(TRUE);
|
||||
@ -685,7 +685,7 @@ p_functor(void) /* functor(?,?,?) */
|
||||
|
||||
BEGP(pt1);
|
||||
deref_body(d1, pt1, func_var_3unk, func_var_3nvar);
|
||||
_YAP_Error(INSTANTIATION_ERROR,(CELL)pt1,"functor/3");
|
||||
Yap_Error(INSTANTIATION_ERROR,(CELL)pt1,"functor/3");
|
||||
ENDP(pt1);
|
||||
/* Oops, third argument was unbound */
|
||||
return(FALSE);
|
||||
@ -694,7 +694,7 @@ p_functor(void) /* functor(?,?,?) */
|
||||
BEGP(pt1);
|
||||
|
||||
deref_body(d0, pt1, func_var_2unk, func_var_2nvar);
|
||||
_YAP_Error(INSTANTIATION_ERROR,(CELL)pt1,"functor/3");
|
||||
Yap_Error(INSTANTIATION_ERROR,(CELL)pt1,"functor/3");
|
||||
ENDP(pt1);
|
||||
/* Oops, second argument was unbound too */
|
||||
return(FALSE);
|
||||
@ -751,37 +751,37 @@ p_cut_by( void)
|
||||
static Int
|
||||
p_erroneous_call(void)
|
||||
{
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, "bad call to internal built-in");
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, "bad call to internal built-in");
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_InitInlines(void)
|
||||
Yap_InitInlines(void)
|
||||
{
|
||||
_YAP_InitAsmPred("$$cut_by", 1, _cut_by, p_cut_by, SafePredFlag);
|
||||
Yap_InitAsmPred("$$cut_by", 1, _cut_by, p_cut_by, SafePredFlag);
|
||||
|
||||
_YAP_InitAsmPred("atom", 1, _atom, p_atom, SafePredFlag);
|
||||
_YAP_InitAsmPred("atomic", 1, _atomic, p_atomic, SafePredFlag);
|
||||
_YAP_InitAsmPred("integer", 1, _integer, p_integer, SafePredFlag);
|
||||
_YAP_InitAsmPred("nonvar", 1, _nonvar, p_nonvar, SafePredFlag);
|
||||
_YAP_InitAsmPred("number", 1, _number, p_number, SafePredFlag);
|
||||
_YAP_InitAsmPred("var", 1, _var, p_var, SafePredFlag);
|
||||
_YAP_InitAsmPred("db_reference", 1, _db_ref, p_db_ref, SafePredFlag);
|
||||
_YAP_InitAsmPred("primitive", 1, _primitive, p_primitive, SafePredFlag);
|
||||
_YAP_InitAsmPred("compound", 1, _compound, p_compound, SafePredFlag);
|
||||
_YAP_InitAsmPred("float", 1, _float, p_float, SafePredFlag);
|
||||
_YAP_InitAsmPred("=", 2, _equal, p_equal, SafePredFlag);
|
||||
_YAP_InitAsmPred("\\=", 2, _dif, p_dif, SafePredFlag);
|
||||
_YAP_InitAsmPred("==", 2, _eq, p_eq, SafePredFlag);
|
||||
_YAP_InitAsmPred("arg", 3, _arg, p_arg, SafePredFlag);
|
||||
_YAP_InitAsmPred("functor", 3, _functor, p_functor, SafePredFlag);
|
||||
_YAP_InitAsmPred("$plus", 3, _plus, p_erroneous_call, SafePredFlag);
|
||||
_YAP_InitAsmPred("$minus", 3, _minus, p_erroneous_call, SafePredFlag);
|
||||
_YAP_InitAsmPred("$times", 3, _times, p_erroneous_call, SafePredFlag);
|
||||
_YAP_InitAsmPred("$div", 3, _div, p_erroneous_call, SafePredFlag);
|
||||
_YAP_InitAsmPred("$and", 3, _and, p_erroneous_call, SafePredFlag);
|
||||
_YAP_InitAsmPred("$or", 3, _or, p_erroneous_call, SafePredFlag);
|
||||
_YAP_InitAsmPred("$sll", 3, _sll, p_erroneous_call, SafePredFlag);
|
||||
_YAP_InitAsmPred("$slr", 3, _slr, p_erroneous_call, SafePredFlag);
|
||||
Yap_InitAsmPred("atom", 1, _atom, p_atom, SafePredFlag);
|
||||
Yap_InitAsmPred("atomic", 1, _atomic, p_atomic, SafePredFlag);
|
||||
Yap_InitAsmPred("integer", 1, _integer, p_integer, SafePredFlag);
|
||||
Yap_InitAsmPred("nonvar", 1, _nonvar, p_nonvar, SafePredFlag);
|
||||
Yap_InitAsmPred("number", 1, _number, p_number, SafePredFlag);
|
||||
Yap_InitAsmPred("var", 1, _var, p_var, SafePredFlag);
|
||||
Yap_InitAsmPred("db_reference", 1, _db_ref, p_db_ref, SafePredFlag);
|
||||
Yap_InitAsmPred("primitive", 1, _primitive, p_primitive, SafePredFlag);
|
||||
Yap_InitAsmPred("compound", 1, _compound, p_compound, SafePredFlag);
|
||||
Yap_InitAsmPred("float", 1, _float, p_float, SafePredFlag);
|
||||
Yap_InitAsmPred("=", 2, _equal, p_equal, SafePredFlag);
|
||||
Yap_InitAsmPred("\\=", 2, _dif, p_dif, SafePredFlag);
|
||||
Yap_InitAsmPred("==", 2, _eq, p_eq, SafePredFlag);
|
||||
Yap_InitAsmPred("arg", 3, _arg, p_arg, SafePredFlag);
|
||||
Yap_InitAsmPred("functor", 3, _functor, p_functor, SafePredFlag);
|
||||
Yap_InitAsmPred("$plus", 3, _plus, p_erroneous_call, SafePredFlag);
|
||||
Yap_InitAsmPred("$minus", 3, _minus, p_erroneous_call, SafePredFlag);
|
||||
Yap_InitAsmPred("$times", 3, _times, p_erroneous_call, SafePredFlag);
|
||||
Yap_InitAsmPred("$div", 3, _div, p_erroneous_call, SafePredFlag);
|
||||
Yap_InitAsmPred("$and", 3, _and, p_erroneous_call, SafePredFlag);
|
||||
Yap_InitAsmPred("$or", 3, _or, p_erroneous_call, SafePredFlag);
|
||||
Yap_InitAsmPred("$sll", 3, _sll, p_erroneous_call, SafePredFlag);
|
||||
Yap_InitAsmPred("$slr", 3, _slr, p_erroneous_call, SafePredFlag);
|
||||
}
|
||||
|
||||
|
1212
C/iopreds.c
1212
C/iopreds.c
File diff suppressed because it is too large
Load Diff
18
C/load_aix.c
18
C/load_aix.c
@ -27,7 +27,7 @@
|
||||
* locate the executable of Yap
|
||||
*/
|
||||
void
|
||||
_YAP_FindExecutable(char *name)
|
||||
Yap_FindExecutable(char *name)
|
||||
{
|
||||
}
|
||||
|
||||
@ -45,35 +45,35 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
|
||||
/* load wants to follow the LIBRARY_PATH */
|
||||
if (ofiles->next != NULL || libs != NULL) {
|
||||
strcpy(_YAP_ErrorSay," Load Failed: in AIX you must load a single object file");
|
||||
strcpy(Yap_ErrorSay," Load Failed: in AIX you must load a single object file");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
if (!_YAP_TrueFileName(ofiles->s, _YAP_FileNameBuf, TRUE)) {
|
||||
strcpy(_YAP_ErrorSay, " Trying to open unexisting file in LoadForeign ");
|
||||
if (!Yap_TrueFileName(ofiles->s, Yap_FileNameBuf, TRUE)) {
|
||||
strcpy(Yap_ErrorSay, " Trying to open unexisting file in LoadForeign ");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
/* In AIX, just call load and everything will go in */
|
||||
if ((*init_proc=((YapInitProc *)load(_YAP_FileNameBuf,0,NULL))) == NULL) {
|
||||
strcpy(_YAP_ErrorSay,sys_errlist[errno]);
|
||||
if ((*init_proc=((YapInitProc *)load(Yap_FileNameBuf,0,NULL))) == NULL) {
|
||||
strcpy(Yap_ErrorSay,sys_errlist[errno]);
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
return LOAD_SUCCEEDED;
|
||||
}
|
||||
|
||||
Int
|
||||
_YAP_LoadForeign(StringList ofiles, StringList libs,
|
||||
Yap_LoadForeign(StringList ofiles, StringList libs,
|
||||
char *proc_name, YapInitProc *init_proc)
|
||||
{
|
||||
return LoadForeign(ofiles, libs, proc_name, init_proc);
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_ShutdownLoadForeign(void)
|
||||
Yap_ShutdownLoadForeign(void)
|
||||
{
|
||||
}
|
||||
|
||||
Int
|
||||
_YAP_ReLoadForeign(StringList ofiles, StringList libs,
|
||||
Yap_ReLoadForeign(StringList ofiles, StringList libs,
|
||||
char *proc_name, YapInitProc *init_proc)
|
||||
{
|
||||
return(LoadForeign(ofiles,libs, proc_name, init_proc));
|
||||
|
@ -55,7 +55,7 @@ static char YapExecutable[YAP_FILE_MAX];
|
||||
* locate the executable of Yap
|
||||
*/
|
||||
void
|
||||
_YAP_FindExecutable(char *name)
|
||||
Yap_FindExecutable(char *name)
|
||||
{
|
||||
register char *cp, *cp2;
|
||||
struct stat stbuf;
|
||||
@ -64,10 +64,10 @@ _YAP_FindExecutable(char *name)
|
||||
cp = (char *)getenv("PATH");
|
||||
if (cp == NULL)
|
||||
cp = ".:/usr/ucb:/bin:/usr/bin:/usr/local/bin";
|
||||
if (*_YAP_argv[0] == '/') {
|
||||
if (oktox(_YAP_argv[0])) {
|
||||
strcpy(_YAP_FileNameBuf, _YAP_argv[0]);
|
||||
_YAP_TrueFileName(_YAP_FileNameBuf, YapExecutable, TRUE);
|
||||
if (*Yap_argv[0] == '/') {
|
||||
if (oktox(Yap_argv[0])) {
|
||||
strcpy(Yap_FileNameBuf, Yap_argv[0]);
|
||||
Yap_TrueFileName(Yap_FileNameBuf, YapExecutable, TRUE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -79,24 +79,24 @@ _YAP_FindExecutable(char *name)
|
||||
* argv[0]
|
||||
*/
|
||||
|
||||
for (cp2 = _YAP_FileNameBuf; (*cp) != 0 && (*cp) != ':';)
|
||||
for (cp2 = Yap_FileNameBuf; (*cp) != 0 && (*cp) != ':';)
|
||||
*cp2++ = *cp++;
|
||||
*cp2++ = '/';
|
||||
strcpy(cp2, _YAP_argv[0]);
|
||||
strcpy(cp2, Yap_argv[0]);
|
||||
if (*cp)
|
||||
cp++;
|
||||
if (!oktox(_YAP_FileNameBuf))
|
||||
if (!oktox(Yap_FileNameBuf))
|
||||
continue;
|
||||
_YAP_TrueFileName(_YAP_FileNameBuf, YapExecutable, TRUE);
|
||||
Yap_TrueFileName(Yap_FileNameBuf, YapExecutable, TRUE);
|
||||
return;
|
||||
}
|
||||
/* one last try for dual systems */
|
||||
strcpy(_YAP_FileNameBuf, _YAP_argv[0]);
|
||||
_YAP_TrueFileName(_YAP_FileNameBuf, YapExecutable, TRUE);
|
||||
strcpy(Yap_FileNameBuf, Yap_argv[0]);
|
||||
Yap_TrueFileName(Yap_FileNameBuf, YapExecutable, TRUE);
|
||||
if (oktox(YapExecutable))
|
||||
return;
|
||||
else
|
||||
_YAP_Error(SYSTEM_ERROR,MkAtomTerm(_YAP_LookupAtom(YapExecutable)),
|
||||
Yap_Error(SYSTEM_ERROR,MkAtomTerm(Yap_LookupAtom(YapExecutable)),
|
||||
"cannot find file being executed");
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ LoadForeign(StringList ofiles,
|
||||
/* prepare the magic */
|
||||
if (strlen(o_files) + strlen(l_files) + strlen(proc_name) +
|
||||
strlen(YapExecutable) > 2*MAXPATHLEN) {
|
||||
strcpy(_YAP_ErrorSay, " too many parameters in load_foreign/3 ");
|
||||
strcpy(Yap_ErrorSay, " too many parameters in load_foreign/3 ");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
sprintf(command, "/usr/bin/ld -N -A %s -o %s -u _%s %s %s -lc",
|
||||
@ -165,12 +165,12 @@ LoadForeign(StringList ofiles,
|
||||
/* now, do the magic */
|
||||
if (system(command) != 0) {
|
||||
unlink(tfile);
|
||||
strcpy(_YAP_ErrorSay," ld returned error status in load_foreign_files ");
|
||||
strcpy(Yap_ErrorSay," ld returned error status in load_foreign_files ");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
/* now check the music has played */
|
||||
if ((fildes = open(tfile, O_RDONLY)) < 0) {
|
||||
strcpy(_YAP_ErrorSay," unable to open temp file in load_foreign_files ");
|
||||
strcpy(Yap_ErrorSay," unable to open temp file in load_foreign_files ");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
/* it did, get the mice */
|
||||
@ -184,8 +184,8 @@ LoadForeign(StringList ofiles,
|
||||
/* keep this copy */
|
||||
firstloadImSz = loadImageSize;
|
||||
/* now fetch the space we need */
|
||||
if (!(FCodeBase = _YAP_AllocCodeSpace((int) loadImageSize))) {
|
||||
strcpy(_YAP_ErrorSay," unable to allocate space for external code ");
|
||||
if (!(FCodeBase = Yap_AllocCodeSpace((int) loadImageSize))) {
|
||||
strcpy(Yap_ErrorSay," unable to allocate space for external code ");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
/* now, a new incantation to load the new foreign code */
|
||||
@ -196,17 +196,17 @@ LoadForeign(StringList ofiles,
|
||||
/* and do it */
|
||||
if (system(command) != 0) {
|
||||
unlink(tfile);
|
||||
strcpy(_YAP_ErrorSay," ld returned error status in load_foreign_files ");
|
||||
strcpy(Yap_ErrorSay," ld returned error status in load_foreign_files ");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
if ((fildes = open(tfile, O_RDONLY)) < 0) {
|
||||
strcpy(_YAP_ErrorSay," unable to open temp file in load_foreign_files ");
|
||||
strcpy(Yap_ErrorSay," unable to open temp file in load_foreign_files ");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
read(fildes, (char *) &header, sizeof(header));
|
||||
loadImageSize = header.a_text + header.a_data + header.a_bss;
|
||||
if (firstloadImSz < loadImageSize) {
|
||||
strcpy(_YAP_ErrorSay," miscalculation in load_foreign/3 ");
|
||||
strcpy(Yap_ErrorSay," miscalculation in load_foreign/3 ");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
/* now search for our init function */
|
||||
@ -217,11 +217,11 @@ LoadForeign(StringList ofiles,
|
||||
func_info[0].n_un.n_name = entry_fun;
|
||||
func_info[1].n_un.n_name = NULL;
|
||||
if (nlist(tfile, func_info) == -1) {
|
||||
strcpy(_YAP_ErrorSay," in nlist(3) ");
|
||||
strcpy(Yap_ErrorSay," in nlist(3) ");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
if (func_info[0].n_type == 0) {
|
||||
strcpy(_YAP_ErrorSay," in nlist(3) ");
|
||||
strcpy(Yap_ErrorSay," in nlist(3) ");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
*init_proc = (YapInitProc)(func_info[0].n_value);
|
||||
@ -242,19 +242,19 @@ LoadForeign(StringList ofiles,
|
||||
}
|
||||
|
||||
Int
|
||||
_YAP_LoadForeign(StringList ofiles, StringList libs,
|
||||
Yap_LoadForeign(StringList ofiles, StringList libs,
|
||||
char *proc_name, YapInitProc *init_proc)
|
||||
{
|
||||
return LoadForeign(ofiles, libs, proc_name, init_proc);
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_ShutdownLoadForeign(void)
|
||||
Yap_ShutdownLoadForeign(void)
|
||||
{
|
||||
}
|
||||
|
||||
Int
|
||||
_YAP_ReLoadForeign(StringList ofiles, StringList libs,
|
||||
Yap_ReLoadForeign(StringList ofiles, StringList libs,
|
||||
char *proc_name, YapInitProc *init_proc)
|
||||
{
|
||||
return(LoadForeign(ofiles,libs, proc_name, init_proc));
|
||||
|
@ -53,7 +53,7 @@ static char YapExecutable[YAP_FILE_MAX];
|
||||
* locate the executable of Yap
|
||||
*/
|
||||
void
|
||||
_YAP_FindExecutable(char *name)
|
||||
Yap_FindExecutable(char *name)
|
||||
{
|
||||
register char *cp, *cp2;
|
||||
struct stat stbuf;
|
||||
@ -62,10 +62,10 @@ _YAP_FindExecutable(char *name)
|
||||
cp = (char *)getenv("PATH");
|
||||
if (cp == NULL)
|
||||
cp = ".:/usr/ucb:/bin:/usr/bin:/usr/local/bin";
|
||||
if (*_YAP_argv[0] == '/') {
|
||||
if (oktox(_YAP_argv[0])) {
|
||||
strcpy(_YAP_FileNameBuf, _YAP_argv[0]);
|
||||
_YAP_TrueFileName(_YAP_FileNameBuf, YapExecutable, TRUE);
|
||||
if (*Yap_argv[0] == '/') {
|
||||
if (oktox(Yap_argv[0])) {
|
||||
strcpy(Yap_FileNameBuf, Yap_argv[0]);
|
||||
Yap_TrueFileName(Yap_FileNameBuf, YapExecutable, TRUE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -77,24 +77,24 @@ _YAP_FindExecutable(char *name)
|
||||
* argv[0]
|
||||
*/
|
||||
|
||||
for (cp2 = _YAP_FileNameBuf; (*cp) != 0 && (*cp) != ':';)
|
||||
for (cp2 = Yap_FileNameBuf; (*cp) != 0 && (*cp) != ':';)
|
||||
*cp2++ = *cp++;
|
||||
*cp2++ = '/';
|
||||
strcpy(cp2, _YAP_argv[0]);
|
||||
strcpy(cp2, Yap_argv[0]);
|
||||
if (*cp)
|
||||
cp++;
|
||||
if (!oktox(_YAP_FileNameBuf))
|
||||
if (!oktox(Yap_FileNameBuf))
|
||||
continue;
|
||||
_YAP_TrueFileName(_YAP_FileNameBuf, YapExecutable, TRUE);
|
||||
Yap_TrueFileName(Yap_FileNameBuf, YapExecutable, TRUE);
|
||||
return;
|
||||
}
|
||||
/* one last try for dual systems */
|
||||
strcpy(_YAP_FileNameBuf, _YAP_argv[0]);
|
||||
_YAP_TrueFileName(_YAP_FileNameBuf, YapExecutable, TRUE);
|
||||
strcpy(Yap_FileNameBuf, Yap_argv[0]);
|
||||
Yap_TrueFileName(Yap_FileNameBuf, YapExecutable, TRUE);
|
||||
if (oktox(YapExecutable))
|
||||
return;
|
||||
else
|
||||
_YAP_Error(SYSTEM_ERROR,MkAtomTerm(_YAP_LookupAtom(YapExecutable)),
|
||||
Yap_Error(SYSTEM_ERROR,MkAtomTerm(Yap_LookupAtom(YapExecutable)),
|
||||
"cannot find file being executed");
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ LoadForeign(StringList ofiles,
|
||||
/* prepare the magic */
|
||||
if (strlen(o_files) + strlen(l_files) + strlen(proc_name) +
|
||||
strlen(YapExecutable) > 2*MAXPATHLEN) {
|
||||
strcpy(_YAP_ErrorSay, " too many parameters in load_foreign/3 ");
|
||||
strcpy(Yap_ErrorSay, " too many parameters in load_foreign/3 ");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
sprintf(command, "/usr/bin/ld -N -A %s -o %s %s %s -lc",
|
||||
@ -166,12 +166,12 @@ LoadForeign(StringList ofiles,
|
||||
/* now, do the magic */
|
||||
if (system(command) != 0) {
|
||||
unlink(tfile);
|
||||
strcpy(_YAP_ErrorSay," ld returned error status in load_foreign_files ");
|
||||
strcpy(Yap_ErrorSay," ld returned error status in load_foreign_files ");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
/* now check the music has played */
|
||||
if ((fildes = open(tfile, O_RDONLY)) < 0) {
|
||||
strcpy(_YAP_ErrorSay," unable to open temp file in load_foreign_files ");
|
||||
strcpy(Yap_ErrorSay," unable to open temp file in load_foreign_files ");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
/* it did, get the mice */
|
||||
@ -196,12 +196,12 @@ LoadForeign(StringList ofiles,
|
||||
/* keep this copy */
|
||||
firstloadImSz = loadImageSize;
|
||||
/* now fetch the space we need */
|
||||
if (!(FCodeBase = _YAP_AllocCodeSpace((int) loadImageSize))
|
||||
if (!(FCodeBase = Yap_AllocCodeSpace((int) loadImageSize))
|
||||
#ifdef pyr
|
||||
|| activate_code(ForeignCodeBase, u1)
|
||||
#endif /* pyr */
|
||||
) {
|
||||
strcpy(_YAP_ErrorSay," unable to allocate space for external code ");
|
||||
strcpy(Yap_ErrorSay," unable to allocate space for external code ");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
#ifdef mips
|
||||
@ -215,7 +215,7 @@ LoadForeign(StringList ofiles,
|
||||
sprintf(command, "ld -x -A %s -T %lx -o %s -u %s %s %s -lc",
|
||||
ostabf,
|
||||
((unsigned long) (((unsigned long) (ForeignCodeBase)) &
|
||||
((unsigned long) (~_YAP_HeapBase))
|
||||
((unsigned long) (~Yap_HeapBase))
|
||||
)
|
||||
), tfile, entry_point, o_files, l_files);
|
||||
#else
|
||||
@ -234,11 +234,11 @@ LoadForeign(StringList ofiles,
|
||||
/* and do it */
|
||||
if (system(command) != 0) {
|
||||
unlink(tfile);
|
||||
strcpy(_YAP_ErrorSay," ld returned error status in load_foreign_files ");
|
||||
strcpy(Yap_ErrorSay," ld returned error status in load_foreign_files ");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
if ((fildes = open(tfile, O_RDONLY)) < 0) {
|
||||
strcpy(_YAP_ErrorSay," unable to open temp file in load_foreign_files ");
|
||||
strcpy(Yap_ErrorSay," unable to open temp file in load_foreign_files ");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
read(fildes, (char *) &fileHeader, sizeof(fileHeader));
|
||||
@ -250,7 +250,7 @@ LoadForeign(StringList ofiles,
|
||||
}
|
||||
loadImageSize = sysHeader.tsize + sysHeader.dsize + sysHeader.bsize;
|
||||
if (firstloadImSz < loadImageSize) {
|
||||
strcpy(_YAP_ErrorSay," miscalculation in load_foreign/3 ");
|
||||
strcpy(Yap_ErrorSay," miscalculation in load_foreign/3 ");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
/* now search for our init function */
|
||||
@ -266,11 +266,11 @@ LoadForeign(StringList ofiles,
|
||||
func_info[0].n_name = entry_fun;
|
||||
func_info[1].n_name = NULL;
|
||||
if (nlist(tfile, func_info) == -1) {
|
||||
strcpy(_YAP_ErrorSay," in nlist(3) ");
|
||||
strcpy(Yap_ErrorSay," in nlist(3) ");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
if (func_info[0].n_type == 0) {
|
||||
strcpy(_YAP_ErrorSay," in nlist(3) ");
|
||||
strcpy(Yap_ErrorSay," in nlist(3) ");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
*init_proc = (YapInitProc)(func_info[0].n_value);
|
||||
@ -291,19 +291,19 @@ LoadForeign(StringList ofiles,
|
||||
}
|
||||
|
||||
Int
|
||||
_YAP_LoadForeign(StringList ofiles, StringList libs,
|
||||
Yap_LoadForeign(StringList ofiles, StringList libs,
|
||||
char *proc_name, YapInitProc *init_proc)
|
||||
{
|
||||
return LoadForeign(ofiles, libs, proc_name, init_proc);
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_ShutdownLoadForeign(void)
|
||||
Yap_ShutdownLoadForeign(void)
|
||||
{
|
||||
}
|
||||
|
||||
Int
|
||||
_YAP_ReLoadForeign(StringList ofiles, StringList libs,
|
||||
Yap_ReLoadForeign(StringList ofiles, StringList libs,
|
||||
char *proc_name, YapInitProc *init_proc)
|
||||
{
|
||||
return(LoadForeign(ofiles,libs, proc_name, init_proc));
|
||||
|
36
C/load_dl.c
36
C/load_dl.c
@ -30,7 +30,7 @@
|
||||
* locate the executable of Yap
|
||||
*/
|
||||
void
|
||||
_YAP_FindExecutable(char *name)
|
||||
Yap_FindExecutable(char *name)
|
||||
{
|
||||
}
|
||||
|
||||
@ -48,18 +48,18 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
void *handle;
|
||||
|
||||
/* dlopen wants to follow the LD_CONFIG_PATH */
|
||||
if (!_YAP_TrueFileName(ofiles->s, _YAP_FileNameBuf, TRUE)) {
|
||||
strcpy(_YAP_ErrorSay, "[ Trying to open unexisting file in LoadForeign ]");
|
||||
if (!Yap_TrueFileName(ofiles->s, Yap_FileNameBuf, TRUE)) {
|
||||
strcpy(Yap_ErrorSay, "[ Trying to open unexisting file in LoadForeign ]");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
#ifdef __osf__
|
||||
if((handle=dlopen(_YAP_FileNameBuf,RTLD_LAZY)) == 0)
|
||||
if((handle=dlopen(Yap_FileNameBuf,RTLD_LAZY)) == 0)
|
||||
#else
|
||||
if((handle=dlopen(_YAP_FileNameBuf,RTLD_LAZY|RTLD_GLOBAL)) == 0)
|
||||
if((handle=dlopen(Yap_FileNameBuf,RTLD_LAZY|RTLD_GLOBAL)) == 0)
|
||||
#endif
|
||||
{
|
||||
fprintf(stderr,"dlopen of %s failed with error %s\n", _YAP_FileNameBuf, dlerror());
|
||||
/* strcpy(_YAP_ErrorSay,dlerror());*/
|
||||
fprintf(stderr,"dlopen of %s failed with error %s\n", Yap_FileNameBuf, dlerror());
|
||||
/* strcpy(Yap_ErrorSay,dlerror());*/
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
}
|
||||
|
||||
if(! *init_proc) {
|
||||
strcpy(_YAP_ErrorSay,"Could not locate initialization routine");
|
||||
strcpy(Yap_ErrorSay,"Could not locate initialization routine");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
|
||||
@ -81,20 +81,20 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
while (libs) {
|
||||
|
||||
if (libs->s[0] == '-') {
|
||||
strcpy(_YAP_FileNameBuf,"lib");
|
||||
strcat(_YAP_FileNameBuf,libs->s+2);
|
||||
strcat(_YAP_FileNameBuf,".so");
|
||||
strcpy(Yap_FileNameBuf,"lib");
|
||||
strcat(Yap_FileNameBuf,libs->s+2);
|
||||
strcat(Yap_FileNameBuf,".so");
|
||||
} else {
|
||||
strcpy(_YAP_FileNameBuf,libs->s);
|
||||
strcpy(Yap_FileNameBuf,libs->s);
|
||||
}
|
||||
|
||||
#ifdef __osf__
|
||||
if((libs->handle=dlopen(_YAP_FileNameBuf,RTLD_LAZY)) == NULL)
|
||||
if((libs->handle=dlopen(Yap_FileNameBuf,RTLD_LAZY)) == NULL)
|
||||
#else
|
||||
if((libs->handle=dlopen(_YAP_FileNameBuf,RTLD_LAZY|RTLD_GLOBAL)) == NULL)
|
||||
if((libs->handle=dlopen(Yap_FileNameBuf,RTLD_LAZY|RTLD_GLOBAL)) == NULL)
|
||||
#endif
|
||||
{
|
||||
strcpy(_YAP_ErrorSay,dlerror());
|
||||
strcpy(Yap_ErrorSay,dlerror());
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
libs = libs->next;
|
||||
@ -103,14 +103,14 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
}
|
||||
|
||||
Int
|
||||
_YAP_LoadForeign(StringList ofiles, StringList libs,
|
||||
Yap_LoadForeign(StringList ofiles, StringList libs,
|
||||
char *proc_name, YapInitProc *init_proc)
|
||||
{
|
||||
return LoadForeign(ofiles, libs, proc_name, init_proc);
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_ShutdownLoadForeign(void)
|
||||
Yap_ShutdownLoadForeign(void)
|
||||
{
|
||||
ForeignObj *f_code;
|
||||
|
||||
@ -135,7 +135,7 @@ _YAP_ShutdownLoadForeign(void)
|
||||
}
|
||||
|
||||
Int
|
||||
_YAP_ReLoadForeign(StringList ofiles, StringList libs,
|
||||
Yap_ReLoadForeign(StringList ofiles, StringList libs,
|
||||
char *proc_name, YapInitProc *init_proc)
|
||||
{
|
||||
return(LoadForeign(ofiles,libs, proc_name, init_proc));
|
||||
|
16
C/load_dld.c
16
C/load_dld.c
@ -28,7 +28,7 @@ static char YapExecutable[YAP_FILE_MAX];
|
||||
* locate the executable of Yap
|
||||
*/
|
||||
void
|
||||
_YAP_FindExecutable(char *name)
|
||||
Yap_FindExecutable(char *name)
|
||||
{
|
||||
/* use dld_find_executable */
|
||||
char *res;
|
||||
@ -54,7 +54,7 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
if(firstTime) {
|
||||
error = dld_init(YapExecutable);
|
||||
if(error) {
|
||||
strcpy(_YAP_ErrorSay,dld_strerror(error));
|
||||
strcpy(Yap_ErrorSay,dld_strerror(error));
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
firstTime=0;
|
||||
@ -62,7 +62,7 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
|
||||
while (ofiles) {
|
||||
if((error=dld_link(ofiles->s)) !=0) {
|
||||
strcpy(_YAP_ErrorSay,dld_strerror(error));
|
||||
strcpy(Yap_ErrorSay,dld_strerror(error));
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
ofiles = ofiles->next;
|
||||
@ -72,14 +72,14 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
/* TODO: handle libs */
|
||||
*init_proc = (YapInitProc) dld_get_func(proc_name);
|
||||
if(! *init_proc) {
|
||||
strcpy(_YAP_ErrorSay,"Could not locate initialization routine");
|
||||
strcpy(Yap_ErrorSay,"Could not locate initialization routine");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
if(!dld_function_executable_p(proc_name)) {
|
||||
char **undefs = dld_list_undefined_sym();
|
||||
char **p = undefs;
|
||||
int k = dld_undefined_sym_count;
|
||||
strcpy(_YAP_ErrorSay,"Could not resolve all symbols");
|
||||
strcpy(Yap_ErrorSay,"Could not resolve all symbols");
|
||||
while(k) {
|
||||
YP_printf("[undefined symbol %s]\n",*p++);
|
||||
--k;
|
||||
@ -92,19 +92,19 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
}
|
||||
|
||||
Int
|
||||
_YAP_LoadForeign(StringList ofiles, StringList libs,
|
||||
Yap_LoadForeign(StringList ofiles, StringList libs,
|
||||
char *proc_name, YapInitProc *init_proc)
|
||||
{
|
||||
return LoadForeign(ofiles, libs, proc_name, init_proc);
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_ShutdownLoadForeign(void)
|
||||
Yap_ShutdownLoadForeign(void)
|
||||
{
|
||||
}
|
||||
|
||||
Int
|
||||
_YAP_ReLoadForeign(StringList ofiles, StringList libs,
|
||||
Yap_ReLoadForeign(StringList ofiles, StringList libs,
|
||||
char *proc_name, YapInitProc *init_proc)
|
||||
{
|
||||
return(LoadForeign(ofiles,libs, proc_name, init_proc));
|
||||
|
24
C/load_dll.c
24
C/load_dll.c
@ -28,7 +28,7 @@
|
||||
* locate the executable of Yap
|
||||
*/
|
||||
void
|
||||
_YAP_FindExecutable(char *name)
|
||||
Yap_FindExecutable(char *name)
|
||||
{
|
||||
}
|
||||
|
||||
@ -45,8 +45,8 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
while (ofiles) {
|
||||
HINSTANCE handle;
|
||||
|
||||
if (_YAP_TrueFileName(ofiles->s, _YAP_FileNameBuf, TRUE) &&
|
||||
(handle=LoadLibrary(_YAP_FileNameBuf)) != 0)
|
||||
if (Yap_TrueFileName(ofiles->s, Yap_FileNameBuf, TRUE) &&
|
||||
(handle=LoadLibrary(Yap_FileNameBuf)) != 0)
|
||||
{
|
||||
if (*init_proc == NULL)
|
||||
*init_proc = (YapInitProc)GetProcAddress((HMODULE)handle, proc_name);
|
||||
@ -60,15 +60,15 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
HINSTANCE handle;
|
||||
|
||||
if (libs->s[0] == '-') {
|
||||
strcat(_YAP_FileNameBuf,libs->s+2);
|
||||
strcat(_YAP_FileNameBuf,".dll");
|
||||
strcat(Yap_FileNameBuf,libs->s+2);
|
||||
strcat(Yap_FileNameBuf,".dll");
|
||||
} else {
|
||||
strcpy(_YAP_FileNameBuf,libs->s);
|
||||
strcpy(Yap_FileNameBuf,libs->s);
|
||||
}
|
||||
|
||||
if((handle=LoadLibrary(_YAP_FileNameBuf)) == 0)
|
||||
if((handle=LoadLibrary(Yap_FileNameBuf)) == 0)
|
||||
{
|
||||
/* strcpy(_YAP_ErrorSay,dlerror());*/
|
||||
/* strcpy(Yap_ErrorSay,dlerror());*/
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
}
|
||||
|
||||
if(*init_proc == NULL) {
|
||||
strcpy(_YAP_ErrorSay,"Could not locate initialization routine");
|
||||
strcpy(Yap_ErrorSay,"Could not locate initialization routine");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
|
||||
@ -87,19 +87,19 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
}
|
||||
|
||||
Int
|
||||
_YAP_LoadForeign(StringList ofiles, StringList libs,
|
||||
Yap_LoadForeign(StringList ofiles, StringList libs,
|
||||
char *proc_name, YapInitProc *init_proc)
|
||||
{
|
||||
return LoadForeign(ofiles, libs, proc_name, init_proc);
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_ShutdownLoadForeign(void)
|
||||
Yap_ShutdownLoadForeign(void)
|
||||
{
|
||||
}
|
||||
|
||||
Int
|
||||
_YAP_ReLoadForeign(StringList ofiles, StringList libs,
|
||||
Yap_ReLoadForeign(StringList ofiles, StringList libs,
|
||||
char *proc_name, YapInitProc *init_proc)
|
||||
{
|
||||
return(LoadForeign(ofiles,libs, proc_name, init_proc));
|
||||
|
@ -63,7 +63,7 @@ mydlerror(void)
|
||||
* locate the executable of Yap
|
||||
*/
|
||||
void
|
||||
_YAP_FindExecutable(char *name)
|
||||
Yap_FindExecutable(char *name)
|
||||
{
|
||||
}
|
||||
|
||||
@ -122,14 +122,14 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
void *handle;
|
||||
|
||||
/* mydlopen wants to follow the LD_CONFIG_PATH */
|
||||
if (!_YAP_TrueFileName(ofiles->s, _YAP_FileNameBuf, TRUE)) {
|
||||
strcpy(_YAP_ErrorSay, "[ Trying to open unexisting file in LoadForeign ]");
|
||||
if (!Yap_TrueFileName(ofiles->s, Yap_FileNameBuf, TRUE)) {
|
||||
strcpy(Yap_ErrorSay, "[ Trying to open unexisting file in LoadForeign ]");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
if((handle=mydlopen(_YAP_FileNameBuf)) == 0)
|
||||
if((handle=mydlopen(Yap_FileNameBuf)) == 0)
|
||||
{
|
||||
fprintf(stderr,"calling dlopen with error %s\n", mydlerror());
|
||||
/* strcpy(_YAP_ErrorSay,dlerror());*/
|
||||
/* strcpy(Yap_ErrorSay,dlerror());*/
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
|
||||
@ -142,16 +142,16 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
while (libs) {
|
||||
|
||||
if (libs->s[0] == '-') {
|
||||
strcpy(_YAP_FileNameBuf,"lib");
|
||||
strcat(_YAP_FileNameBuf,libs->s+2);
|
||||
strcat(_YAP_FileNameBuf,".so");
|
||||
strcpy(Yap_FileNameBuf,"lib");
|
||||
strcat(Yap_FileNameBuf,libs->s+2);
|
||||
strcat(Yap_FileNameBuf,".so");
|
||||
} else {
|
||||
strcpy(_YAP_FileNameBuf,libs->s);
|
||||
strcpy(Yap_FileNameBuf,libs->s);
|
||||
}
|
||||
|
||||
if((libs->handle=mydlopen(_YAP_FileNameBuf)) == NULL)
|
||||
if((libs->handle=mydlopen(Yap_FileNameBuf)) == NULL)
|
||||
{
|
||||
strcpy(_YAP_ErrorSay,mydlerror());
|
||||
strcpy(Yap_ErrorSay,mydlerror());
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
libs = libs->next;
|
||||
@ -160,7 +160,7 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
*init_proc = (YapInitProc) mydlsym(proc_name);
|
||||
|
||||
if(! *init_proc) {
|
||||
strcpy(_YAP_ErrorSay,"Could not locate initialization routine");
|
||||
strcpy(Yap_ErrorSay,"Could not locate initialization routine");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
|
||||
@ -168,14 +168,14 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
}
|
||||
|
||||
Int
|
||||
_YAP_LoadForeign(StringList ofiles, StringList libs,
|
||||
Yap_LoadForeign(StringList ofiles, StringList libs,
|
||||
char *proc_name, YapInitProc *init_proc)
|
||||
{
|
||||
return LoadForeign(ofiles, libs, proc_name, init_proc);
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_ShutdownLoadForeign(void)
|
||||
Yap_ShutdownLoadForeign(void)
|
||||
{
|
||||
ForeignObj *f_code;
|
||||
|
||||
@ -200,7 +200,7 @@ _YAP_ShutdownLoadForeign(void)
|
||||
}
|
||||
|
||||
Int
|
||||
_YAP_ReLoadForeign(StringList ofiles, StringList libs,
|
||||
Yap_ReLoadForeign(StringList ofiles, StringList libs,
|
||||
char *proc_name, YapInitProc *init_proc)
|
||||
{
|
||||
return(LoadForeign(ofiles,libs, proc_name, init_proc));
|
||||
|
@ -47,7 +47,7 @@ p_load_foreign(void)
|
||||
StringList new;
|
||||
Int returncode = FALSE;
|
||||
|
||||
strcpy(_YAP_ErrorSay,"Invalid arguments");
|
||||
strcpy(Yap_ErrorSay,"Invalid arguments");
|
||||
|
||||
/* collect the list of object files */
|
||||
t = Deref(ARG1);
|
||||
@ -55,7 +55,7 @@ p_load_foreign(void)
|
||||
if (t == TermNil) break;
|
||||
t1 = HeadOfTerm(t);
|
||||
t = TailOfTerm(t);
|
||||
new = (StringList) _YAP_AllocCodeSpace(sizeof(StringListItem));
|
||||
new = (StringList) Yap_AllocCodeSpace(sizeof(StringListItem));
|
||||
new->next = ofiles;
|
||||
new->s = RepAtom(AtomOfTerm(t1))->StrOfAE;
|
||||
ofiles = new;
|
||||
@ -67,7 +67,7 @@ p_load_foreign(void)
|
||||
if (t == TermNil) break;
|
||||
t1 = HeadOfTerm(t);
|
||||
t = TailOfTerm(t);
|
||||
new = (StringList) _YAP_AllocCodeSpace(sizeof(StringListItem));
|
||||
new = (StringList) Yap_AllocCodeSpace(sizeof(StringListItem));
|
||||
new->next = libs;
|
||||
new->s = RepAtom(AtomOfTerm(t1))->StrOfAE;
|
||||
libs = new;
|
||||
@ -80,14 +80,14 @@ p_load_foreign(void)
|
||||
|
||||
|
||||
/* call the OS specific function for dynamic loading */
|
||||
if(_YAP_LoadForeign(ofiles,libs,InitProcName,&InitProc)==LOAD_SUCCEEDED) {
|
||||
if(Yap_LoadForeign(ofiles,libs,InitProcName,&InitProc)==LOAD_SUCCEEDED) {
|
||||
(*InitProc)();
|
||||
returncode = TRUE;
|
||||
}
|
||||
|
||||
/* I should recover space if load foreign fails */
|
||||
if (returncode == TRUE) {
|
||||
ForeignObj *f_code = (ForeignObj *)_YAP_AllocCodeSpace(sizeof(ForeignObj));
|
||||
ForeignObj *f_code = (ForeignObj *)Yap_AllocCodeSpace(sizeof(ForeignObj));
|
||||
f_code->objs = ofiles;
|
||||
f_code->libs = libs;
|
||||
f_code->f = InitProcName;
|
||||
@ -100,22 +100,22 @@ p_load_foreign(void)
|
||||
|
||||
static Int
|
||||
p_obj_suffix(void) {
|
||||
return(_YAP_unify(_YAP_StringToList(SHLIB_SUFFIX),ARG1));
|
||||
return(Yap_unify(Yap_StringToList(SHLIB_SUFFIX),ARG1));
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_InitLoadForeign(void)
|
||||
Yap_InitLoadForeign(void)
|
||||
{
|
||||
if (_YAP_argv == NULL)
|
||||
_YAP_FindExecutable("yap");
|
||||
if (Yap_argv == NULL)
|
||||
Yap_FindExecutable("yap");
|
||||
else
|
||||
_YAP_FindExecutable(_YAP_argv[0]);
|
||||
_YAP_InitCPred("$load_foreign_files", 3, p_load_foreign, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("$obj_suffix", 1, p_obj_suffix, SafePredFlag);
|
||||
Yap_FindExecutable(Yap_argv[0]);
|
||||
Yap_InitCPred("$load_foreign_files", 3, p_load_foreign, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("$obj_suffix", 1, p_obj_suffix, SafePredFlag);
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_ReOpenLoadForeign(void)
|
||||
Yap_ReOpenLoadForeign(void)
|
||||
{
|
||||
ForeignObj *f_code = ForeignCodeLoaded;
|
||||
SMALLUNSGN OldModule = CurrentModule;
|
||||
@ -123,7 +123,7 @@ _YAP_ReOpenLoadForeign(void)
|
||||
|
||||
while (f_code != NULL) {
|
||||
CurrentModule = f_code->module;
|
||||
if(_YAP_ReLoadForeign(f_code->objs,f_code->libs,f_code->f,&InitProc)==LOAD_SUCCEEDED) {
|
||||
if(Yap_ReLoadForeign(f_code->objs,f_code->libs,f_code->f,&InitProc)==LOAD_SUCCEEDED) {
|
||||
(*InitProc)();
|
||||
}
|
||||
f_code = f_code->next;
|
||||
|
@ -26,7 +26,7 @@
|
||||
* locate the executable of Yap
|
||||
*/
|
||||
void
|
||||
_YAP_FindExecutable(char *name)
|
||||
Yap_FindExecutable(char *name)
|
||||
{
|
||||
}
|
||||
|
||||
@ -36,20 +36,20 @@ _YAP_FindExecutable(char *name)
|
||||
* code file and locates an initialization routine
|
||||
*/
|
||||
Int
|
||||
_YAP_LoadForeign(StringList ofiles, StringList libs,
|
||||
Yap_LoadForeign(StringList ofiles, StringList libs,
|
||||
char *proc_name, YapInitProc *init_proc)
|
||||
{
|
||||
strcpy(_YAP_ErrorSay,"load_foreign not supported in this version of Yap");
|
||||
strcpy(Yap_ErrorSay,"load_foreign not supported in this version of Yap");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_ShutdownLoadForeign(void)
|
||||
Yap_ShutdownLoadForeign(void)
|
||||
{
|
||||
}
|
||||
|
||||
Int
|
||||
_YAP_ReLoadForeign(StringList ofiles, StringList libs,
|
||||
Yap_ReLoadForeign(StringList ofiles, StringList libs,
|
||||
char *proc_name, YapInitProc *init_proc)
|
||||
{
|
||||
return(LoadForeign(ofiles,libs, proc_name, init_proc));
|
||||
|
36
C/load_shl.c
36
C/load_shl.c
@ -16,7 +16,7 @@
|
||||
* locate the executable of Yap
|
||||
*/
|
||||
|
||||
void _YAP_FindExecutable(char *name)
|
||||
void Yap_FindExecutable(char *name)
|
||||
{
|
||||
}
|
||||
|
||||
@ -41,17 +41,17 @@ LoadForeign( StringList ofiles, StringList libs,
|
||||
int valid_fname;
|
||||
|
||||
/* shl_load wants to follow the LD_CONFIG_PATH */
|
||||
valid_fname = _YAP_TrueFileName( ofiles->s, _YAP_FileNameBuf, TRUE );
|
||||
valid_fname = Yap_TrueFileName( ofiles->s, Yap_FileNameBuf, TRUE );
|
||||
|
||||
if( !valid_fname ) {
|
||||
strcpy( _YAP_ErrorSay, "[ Trying to open non-existing file in LoadForeign ]" );
|
||||
strcpy( Yap_ErrorSay, "[ Trying to open non-existing file in LoadForeign ]" );
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
|
||||
ofiles->handle = _YAP_AllocCodeSpace( sizeof(shl_t) );
|
||||
*(shl_t *)ofiles->handle = shl_load( _YAP_FileNameBuf, BIND_DEFERRED, 0 );
|
||||
ofiles->handle = Yap_AllocCodeSpace( sizeof(shl_t) );
|
||||
*(shl_t *)ofiles->handle = shl_load( Yap_FileNameBuf, BIND_DEFERRED, 0 );
|
||||
if( *(shl_t *)ofiles->handle == NULL ) {
|
||||
strncpy( _YAP_ErrorSay, strerror(errno), MAX_ERROR_MSG_SIZE );
|
||||
strncpy( Yap_ErrorSay, strerror(errno), MAX_ERROR_MSG_SIZE );
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
|
||||
@ -64,24 +64,24 @@ LoadForeign( StringList ofiles, StringList libs,
|
||||
}
|
||||
|
||||
if( init_missing ) {
|
||||
strcpy( _YAP_ErrorSay, "Could not locate initialization routine" );
|
||||
strcpy( Yap_ErrorSay, "Could not locate initialization routine" );
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
|
||||
while( libs ) {
|
||||
|
||||
if( libs->s[0] == '-' ) {
|
||||
strcpy( _YAP_FileNameBuf, "lib" );
|
||||
strcat( _YAP_FileNameBuf, libs->s+2 );
|
||||
strcat( _YAP_FileNameBuf, ".sl" );
|
||||
strcpy( Yap_FileNameBuf, "lib" );
|
||||
strcat( Yap_FileNameBuf, libs->s+2 );
|
||||
strcat( Yap_FileNameBuf, ".sl" );
|
||||
}
|
||||
else {
|
||||
strcpy( _YAP_FileNameBuf, libs->s );
|
||||
strcpy( Yap_FileNameBuf, libs->s );
|
||||
}
|
||||
|
||||
*(shl_t *)libs->handle = shl_load( _YAP_FileNameBuf, BIND_DEFERRED, 0 );
|
||||
*(shl_t *)libs->handle = shl_load( Yap_FileNameBuf, BIND_DEFERRED, 0 );
|
||||
if( *(shl_t *)libs->handle == NULL ) {
|
||||
strncpy( _YAP_ErrorSay, strerror(errno), MAX_ERROR_MSG_SIZE );
|
||||
strncpy( Yap_ErrorSay, strerror(errno), MAX_ERROR_MSG_SIZE );
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
|
||||
@ -93,14 +93,14 @@ LoadForeign( StringList ofiles, StringList libs,
|
||||
|
||||
|
||||
Int
|
||||
_YAP_LoadForeign(StringList ofiles, StringList libs,
|
||||
Yap_LoadForeign(StringList ofiles, StringList libs,
|
||||
char *proc_name, YapInitProc *init_proc)
|
||||
{
|
||||
return LoadForeign(ofiles, libs, proc_name, init_proc);
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_ShutdownLoadForeign( void )
|
||||
Yap_ShutdownLoadForeign( void )
|
||||
{
|
||||
ForeignObj *f_code;
|
||||
int err;
|
||||
@ -117,7 +117,7 @@ _YAP_ShutdownLoadForeign( void )
|
||||
perror( NULL );
|
||||
return;
|
||||
}
|
||||
_YAP_FreeCodeSpace( objs->handle );
|
||||
Yap_FreeCodeSpace( objs->handle );
|
||||
objs = objs->next;
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ _YAP_ShutdownLoadForeign( void )
|
||||
perror( NULL );
|
||||
return;
|
||||
}
|
||||
_YAP_FreeCodeSpace( libs->handle );
|
||||
Yap_FreeCodeSpace( libs->handle );
|
||||
libs = libs->next;
|
||||
}
|
||||
f_code = f_code->next;
|
||||
@ -137,7 +137,7 @@ _YAP_ShutdownLoadForeign( void )
|
||||
}
|
||||
|
||||
Int
|
||||
_YAP_ReLoadForeign(StringList ofiles, StringList libs,
|
||||
Yap_ReLoadForeign(StringList ofiles, StringList libs,
|
||||
char *proc_name, YapInitProc *init_proc)
|
||||
{
|
||||
ShutdownLoadForeign();
|
||||
|
60
C/mavar.c
60
C/mavar.c
@ -35,32 +35,32 @@ p_setarg(void)
|
||||
CELL ti = Deref(ARG1), ts = Deref(ARG2);
|
||||
Int i;
|
||||
if (IsVarTerm(ti)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,ti,"setarg/3");
|
||||
Yap_Error(INSTANTIATION_ERROR,ti,"setarg/3");
|
||||
return(FALSE);
|
||||
} else {
|
||||
if (IsIntTerm(ti))
|
||||
i = IntOfTerm(ti);
|
||||
else {
|
||||
union arith_ret v;
|
||||
if (_YAP_Eval(ti, &v) == long_int_e) {
|
||||
if (Yap_Eval(ti, &v) == long_int_e) {
|
||||
i = v.Int;
|
||||
} else {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER,ti,"setarg/3");
|
||||
Yap_Error(TYPE_ERROR_INTEGER,ti,"setarg/3");
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (IsVarTerm(ts)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,ts,"setarg/3");
|
||||
Yap_Error(INSTANTIATION_ERROR,ts,"setarg/3");
|
||||
} else if(IsApplTerm(ts)) {
|
||||
CELL *pt;
|
||||
if (IsExtensionFunctor(FunctorOfTerm(ts))) {
|
||||
_YAP_Error(TYPE_ERROR_COMPOUND,ts,"setarg/3");
|
||||
Yap_Error(TYPE_ERROR_COMPOUND,ts,"setarg/3");
|
||||
return(FALSE);
|
||||
}
|
||||
if (i < 0 || i > (Int)ArityOfFunctor(FunctorOfTerm(ts))) {
|
||||
if (i<0)
|
||||
_YAP_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO,ts,"setarg/3");
|
||||
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO,ts,"setarg/3");
|
||||
return(FALSE);
|
||||
}
|
||||
pt = RepAppl(ts)+i;
|
||||
@ -70,14 +70,14 @@ p_setarg(void)
|
||||
CELL *pt;
|
||||
if (i != 1 || i != 2) {
|
||||
if (i<0)
|
||||
_YAP_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO,ts,"setarg/3");
|
||||
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO,ts,"setarg/3");
|
||||
return(FALSE);
|
||||
}
|
||||
pt = RepPair(ts)+i-1;
|
||||
/* the evil deed is to be done now */
|
||||
MaBind(pt, Deref(ARG3));
|
||||
} else {
|
||||
_YAP_Error(TYPE_ERROR_COMPOUND,ts,"setarg/3");
|
||||
Yap_Error(TYPE_ERROR_COMPOUND,ts,"setarg/3");
|
||||
return(FALSE);
|
||||
}
|
||||
return(TRUE);
|
||||
@ -112,7 +112,7 @@ static void
|
||||
CreateTimedVar(Term val)
|
||||
{
|
||||
timed_var *tv = (timed_var *)H;
|
||||
tv->clock = MkIntegerTerm(B->cp_tr-(tr_fr_ptr)_YAP_TrailBase);
|
||||
tv->clock = MkIntegerTerm(B->cp_tr-(tr_fr_ptr)Yap_TrailBase);
|
||||
if (B->cp_tr == TR) {
|
||||
/* we run the risk of not making non-determinate bindings before
|
||||
the end of the night */
|
||||
@ -127,7 +127,7 @@ static void
|
||||
CreateEmptyTimedVar(void)
|
||||
{
|
||||
timed_var *tv = (timed_var *)H;
|
||||
tv->clock = MkIntegerTerm(B->cp_tr-(tr_fr_ptr)_YAP_TrailBase);
|
||||
tv->clock = MkIntegerTerm(B->cp_tr-(tr_fr_ptr)Yap_TrailBase);
|
||||
if (B->cp_tr == TR) {
|
||||
/* we run the risk of not making non-determinate bindings before
|
||||
the end of the night */
|
||||
@ -158,13 +158,13 @@ NewTimedVar(CELL val)
|
||||
}
|
||||
|
||||
Term
|
||||
_YAP_NewTimedVar(CELL val)
|
||||
Yap_NewTimedVar(CELL val)
|
||||
{
|
||||
return NewTimedVar(val);
|
||||
}
|
||||
|
||||
Term
|
||||
_YAP_NewEmptyTimedVar(void)
|
||||
Yap_NewEmptyTimedVar(void)
|
||||
{
|
||||
Term out = AbsAppl(H);
|
||||
#if FROZEN_STACKS
|
||||
@ -189,7 +189,7 @@ ReadTimedVar(Term inv)
|
||||
}
|
||||
|
||||
Term
|
||||
_YAP_ReadTimedVar(Term inv)
|
||||
Yap_ReadTimedVar(Term inv)
|
||||
{
|
||||
return ReadTimedVar(inv);
|
||||
}
|
||||
@ -202,7 +202,7 @@ UpdateTimedVar(Term inv, Term new)
|
||||
timed_var *tv = (timed_var *)(RepAppl(inv)+1);
|
||||
CELL t = tv->value;
|
||||
#if FROZEN_STACKS
|
||||
tr_fr_ptr timestmp = (tr_fr_ptr)_YAP_TrailBase + IntegerOfTerm(tv->clock);
|
||||
tr_fr_ptr timestmp = (tr_fr_ptr)Yap_TrailBase + IntegerOfTerm(tv->clock);
|
||||
|
||||
if (B->cp_tr <= timestmp && timestmp <= TR) {
|
||||
/* last assignment more recent than last B */
|
||||
@ -219,7 +219,7 @@ UpdateTimedVar(Term inv, Term new)
|
||||
} else {
|
||||
Term nclock;
|
||||
MaBind(&(tv->value), new);
|
||||
nclock = MkIntegerTerm(TR-(tr_fr_ptr)_YAP_TrailBase);
|
||||
nclock = MkIntegerTerm(TR-(tr_fr_ptr)Yap_TrailBase);
|
||||
MaBind(&(tv->clock), nclock);
|
||||
}
|
||||
#else
|
||||
@ -246,7 +246,7 @@ UpdateTimedVar(Term inv, Term new)
|
||||
|
||||
/* update a timed var with a new value */
|
||||
Term
|
||||
_YAP_UpdateTimedVar(Term inv, Term new)
|
||||
Yap_UpdateTimedVar(Term inv, Term new)
|
||||
{
|
||||
return UpdateTimedVar(inv, new);
|
||||
}
|
||||
@ -255,7 +255,7 @@ static Int
|
||||
p_create_mutable(void)
|
||||
{
|
||||
Term t = NewTimedVar(Deref(ARG1));
|
||||
return(_YAP_unify(ARG2,t));
|
||||
return(Yap_unify(ARG2,t));
|
||||
}
|
||||
|
||||
static Int
|
||||
@ -263,19 +263,19 @@ p_get_mutable(void)
|
||||
{
|
||||
Term t = Deref(ARG2);
|
||||
if (IsVarTerm(t)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t, "get_mutable/3");
|
||||
Yap_Error(INSTANTIATION_ERROR, t, "get_mutable/3");
|
||||
return(FALSE);
|
||||
}
|
||||
if (!IsApplTerm(t)) {
|
||||
_YAP_Error(TYPE_ERROR_COMPOUND,t,"get_mutable/3");
|
||||
Yap_Error(TYPE_ERROR_COMPOUND,t,"get_mutable/3");
|
||||
return(FALSE);
|
||||
}
|
||||
if (FunctorOfTerm(t) != FunctorMutable) {
|
||||
_YAP_Error(DOMAIN_ERROR_MUTABLE,t,"get_mutable/3");
|
||||
Yap_Error(DOMAIN_ERROR_MUTABLE,t,"get_mutable/3");
|
||||
return(FALSE);
|
||||
}
|
||||
t = ReadTimedVar(t);
|
||||
return(_YAP_unify(ARG1, t));
|
||||
return(Yap_unify(ARG1, t));
|
||||
}
|
||||
|
||||
static Int
|
||||
@ -283,15 +283,15 @@ p_update_mutable(void)
|
||||
{
|
||||
Term t = Deref(ARG2);
|
||||
if (IsVarTerm(t)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t, "update_mutable/3");
|
||||
Yap_Error(INSTANTIATION_ERROR, t, "update_mutable/3");
|
||||
return(FALSE);
|
||||
}
|
||||
if (!IsApplTerm(t)) {
|
||||
_YAP_Error(TYPE_ERROR_COMPOUND,t,"update_mutable/3");
|
||||
Yap_Error(TYPE_ERROR_COMPOUND,t,"update_mutable/3");
|
||||
return(FALSE);
|
||||
}
|
||||
if (FunctorOfTerm(t) != FunctorMutable) {
|
||||
_YAP_Error(DOMAIN_ERROR_MUTABLE,t,"update_mutable/3");
|
||||
Yap_Error(DOMAIN_ERROR_MUTABLE,t,"update_mutable/3");
|
||||
return(FALSE);
|
||||
}
|
||||
UpdateTimedVar(t, Deref(ARG1));
|
||||
@ -317,14 +317,14 @@ p_is_mutable(void)
|
||||
#endif
|
||||
|
||||
void
|
||||
_YAP_InitMaVarCPreds(void)
|
||||
Yap_InitMaVarCPreds(void)
|
||||
{
|
||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||
/* The most famous contributions of SICStus to the Prolog language */
|
||||
_YAP_InitCPred("setarg", 3, p_setarg, SafePredFlag);
|
||||
_YAP_InitCPred("create_mutable", 2, p_create_mutable, SafePredFlag);
|
||||
_YAP_InitCPred("get_mutable", 2, p_get_mutable, SafePredFlag);
|
||||
_YAP_InitCPred("update_mutable", 2, p_update_mutable, SafePredFlag);
|
||||
_YAP_InitCPred("is_mutable", 1, p_is_mutable, SafePredFlag);
|
||||
Yap_InitCPred("setarg", 3, p_setarg, SafePredFlag);
|
||||
Yap_InitCPred("create_mutable", 2, p_create_mutable, SafePredFlag);
|
||||
Yap_InitCPred("get_mutable", 2, p_get_mutable, SafePredFlag);
|
||||
Yap_InitCPred("update_mutable", 2, p_update_mutable, SafePredFlag);
|
||||
Yap_InitCPred("is_mutable", 1, p_is_mutable, SafePredFlag);
|
||||
#endif
|
||||
}
|
||||
|
32
C/modules.c
32
C/modules.c
@ -27,7 +27,7 @@ STATIC_PROTO(Int p_current_module1, (void));
|
||||
|
||||
#define ByteAdr(X) ((char *) &(X))
|
||||
Term
|
||||
_YAP_Module_Name(CODEADDR cap)
|
||||
Yap_Module_Name(CODEADDR cap)
|
||||
{
|
||||
PredEntry *ap = (PredEntry *)cap;
|
||||
|
||||
@ -57,13 +57,13 @@ LookupModule(Term a)
|
||||
}
|
||||
ModuleName[i = NoOfModules++] = a;
|
||||
if (NoOfModules == MaxModules) {
|
||||
_YAP_Error(SYSTEM_ERROR,a,"number of modules overflowed");
|
||||
Yap_Error(SYSTEM_ERROR,a,"number of modules overflowed");
|
||||
}
|
||||
return (i);
|
||||
}
|
||||
|
||||
SMALLUNSGN
|
||||
_YAP_LookupModule(Term a)
|
||||
Yap_LookupModule(Term a)
|
||||
{
|
||||
return(LookupModule(a));
|
||||
}
|
||||
@ -73,7 +73,7 @@ p_current_module(void)
|
||||
{ /* $current_module(Old,New) */
|
||||
Term t;
|
||||
|
||||
if (!_YAP_unify_constant(ARG1, ModuleName[CurrentModule]))
|
||||
if (!Yap_unify_constant(ARG1, ModuleName[CurrentModule]))
|
||||
return (0);
|
||||
t = Deref(ARG2);
|
||||
if (IsVarTerm(t) || !IsAtomTerm(t))
|
||||
@ -85,7 +85,7 @@ p_current_module(void)
|
||||
static Int
|
||||
p_current_module1(void)
|
||||
{ /* $current_module(Old) */
|
||||
if (!_YAP_unify_constant(ARG1, ModuleName[CurrentModule]))
|
||||
if (!Yap_unify_constant(ARG1, ModuleName[CurrentModule]))
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
@ -104,10 +104,10 @@ p_module_number(void)
|
||||
Term tname = Deref(ARG1);
|
||||
Term t;
|
||||
if (IsVarTerm(tname)) {
|
||||
return(_YAP_unify(tname, ModuleName[IntOfTerm(Deref(ARG2))]));
|
||||
return(Yap_unify(tname, ModuleName[IntOfTerm(Deref(ARG2))]));
|
||||
}else {
|
||||
t = MkIntTerm(LookupModule(Deref(ARG1)));
|
||||
_YAP_unify(t,ARG2);
|
||||
Yap_unify(t,ARG2);
|
||||
ARG2 = t;
|
||||
}
|
||||
return(TRUE);
|
||||
@ -123,7 +123,7 @@ cont_current_module(void)
|
||||
cut_fail();
|
||||
}
|
||||
EXTRA_CBACK_ARG(1,1) = MkIntTerm(mod+1);
|
||||
return(_YAP_unify(ARG1,t));
|
||||
return(Yap_unify(ARG1,t));
|
||||
}
|
||||
|
||||
static Int
|
||||
@ -134,18 +134,18 @@ init_current_module(void)
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_InitModules(void)
|
||||
Yap_InitModules(void)
|
||||
{
|
||||
ModuleName[PrimitivesModule = 0] =
|
||||
MkAtomTerm(_YAP_LookupAtom("prolog"));
|
||||
MkAtomTerm(Yap_LookupAtom("prolog"));
|
||||
ModuleName[1] =
|
||||
MkAtomTerm(_YAP_LookupAtom("user"));
|
||||
MkAtomTerm(Yap_LookupAtom("user"));
|
||||
NoOfModules = 2;
|
||||
CurrentModule = 0;
|
||||
_YAP_InitCPred("$current_module", 2, p_current_module, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("$current_module", 1, p_current_module1, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("$change_module", 1, p_change_module, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("$module_number", 2, p_module_number, SafePredFlag);
|
||||
_YAP_InitCPredBack("$all_current_modules", 1, 1, init_current_module, cont_current_module,
|
||||
Yap_InitCPred("$current_module", 2, p_current_module, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("$current_module", 1, p_current_module1, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("$change_module", 1, p_change_module, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("$module_number", 2, p_module_number, SafePredFlag);
|
||||
Yap_InitCPredBack("$all_current_modules", 1, 1, init_current_module, cont_current_module,
|
||||
SafePredFlag|SyncPredFlag);
|
||||
}
|
||||
|
14
C/other.c
14
C/other.c
@ -23,21 +23,21 @@ static char SccsId[] = "%W% %G%";
|
||||
#include "Yatom.h"
|
||||
#include "Heap.h"
|
||||
|
||||
/* exile _YAP_standard_regs here, otherwise WIN32 linkers may complain */
|
||||
REGSTORE _YAP_standard_regs;
|
||||
/* exile Yap_standard_regs here, otherwise WIN32 linkers may complain */
|
||||
REGSTORE Yap_standard_regs;
|
||||
|
||||
#if PUSH_REGS
|
||||
|
||||
REGSTORE *_YAP_regp;
|
||||
REGSTORE *Yap_regp;
|
||||
|
||||
#else
|
||||
|
||||
REGSTORE _YAP_REGS;
|
||||
REGSTORE Yap_REGS;
|
||||
|
||||
#endif
|
||||
|
||||
Term
|
||||
_YAP_MkNewPairTerm(void)
|
||||
Yap_MkNewPairTerm(void)
|
||||
{
|
||||
register CELL *p = H;
|
||||
|
||||
@ -48,7 +48,7 @@ _YAP_MkNewPairTerm(void)
|
||||
}
|
||||
|
||||
Term
|
||||
_YAP_MkApplTerm(Functor f, unsigned int n, register Term *a)
|
||||
Yap_MkApplTerm(Functor f, unsigned int n, register Term *a)
|
||||
/* build compound term with functor f and n
|
||||
* args a */
|
||||
{
|
||||
@ -65,7 +65,7 @@ _YAP_MkApplTerm(Functor f, unsigned int n, register Term *a)
|
||||
}
|
||||
|
||||
Term
|
||||
_YAP_MkNewApplTerm(Functor f, unsigned int n)
|
||||
Yap_MkNewApplTerm(Functor f, unsigned int n)
|
||||
/* build compound term with functor f and n
|
||||
* args a */
|
||||
{
|
||||
|
172
C/parser.c
172
C/parser.c
@ -79,7 +79,7 @@ static JMPBUFF FailBuff;
|
||||
|
||||
#define TRY(S,P) \
|
||||
{ Volatile JMPBUFF saveenv;\
|
||||
Volatile TokEntry *saveT=_YAP_tokptr; \
|
||||
Volatile TokEntry *saveT=Yap_tokptr; \
|
||||
Volatile CELL *saveH=H;\
|
||||
Volatile int savecurprio=curprio;\
|
||||
saveenv=FailBuff;\
|
||||
@ -91,39 +91,39 @@ static JMPBUFF FailBuff;
|
||||
else { FailBuff=saveenv; \
|
||||
H=saveH; \
|
||||
curprio = savecurprio; \
|
||||
_YAP_tokptr=saveT; \
|
||||
Yap_tokptr=saveT; \
|
||||
}\
|
||||
}\
|
||||
|
||||
#define TRY3(S,P,F) \
|
||||
{ Volatile JMPBUFF saveenv;\
|
||||
Volatile TokEntry *saveT=_YAP_tokptr; Volatile CELL *saveH=H;\
|
||||
Volatile TokEntry *saveT=Yap_tokptr; Volatile CELL *saveH=H;\
|
||||
saveenv=FailBuff;\
|
||||
if(!setjmp(FailBuff.JmpBuff)) {\
|
||||
S;\
|
||||
FailBuff=saveenv;\
|
||||
P;\
|
||||
}\
|
||||
else { FailBuff=saveenv; H=saveH; _YAP_tokptr=saveT; F }\
|
||||
else { FailBuff=saveenv; H=saveH; Yap_tokptr=saveT; F }\
|
||||
}\
|
||||
|
||||
#define FAIL longjmp(FailBuff.JmpBuff,1)
|
||||
|
||||
VarEntry *
|
||||
_YAP_LookupVar(char *var) /* lookup variable in variables table */
|
||||
Yap_LookupVar(char *var) /* lookup variable in variables table */
|
||||
{
|
||||
VarEntry *p;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (_YAP_Option[4])
|
||||
fprintf(_YAP_stderr,"[LookupVar %s]", var);
|
||||
if (Yap_Option[4])
|
||||
fprintf(Yap_stderr,"[LookupVar %s]", var);
|
||||
#endif
|
||||
if (var[0] != '_' || var[1] != '\0') {
|
||||
VarEntry **op = &_YAP_VarTable;
|
||||
VarEntry **op = &Yap_VarTable;
|
||||
unsigned char *vp = (unsigned char *)var;
|
||||
CELL hv;
|
||||
|
||||
p = _YAP_VarTable;
|
||||
p = Yap_VarTable;
|
||||
HashFunction(vp, hv);
|
||||
while (p != NULL) {
|
||||
CELL hpv = p->hv;
|
||||
@ -146,16 +146,16 @@ _YAP_LookupVar(char *var) /* lookup variable in variables table */
|
||||
p = p->VarRight;
|
||||
}
|
||||
}
|
||||
p = (VarEntry *) _YAP_AllocScannerMemory(strlen(var) + sizeof(VarEntry));
|
||||
p = (VarEntry *) Yap_AllocScannerMemory(strlen(var) + sizeof(VarEntry));
|
||||
*op = p;
|
||||
p->VarLeft = p->VarRight = NULL;
|
||||
p->hv = hv;
|
||||
strcpy(p->VarRep, var);
|
||||
} else {
|
||||
/* anon var */
|
||||
p = (VarEntry *) _YAP_AllocScannerMemory(sizeof(VarEntry) + 2);
|
||||
p->VarLeft = _YAP_AnonVarTable;
|
||||
_YAP_AnonVarTable = p;
|
||||
p = (VarEntry *) Yap_AllocScannerMemory(sizeof(VarEntry) + 2);
|
||||
p->VarLeft = Yap_AnonVarTable;
|
||||
Yap_AnonVarTable = p;
|
||||
p->VarRight = NULL;
|
||||
p->hv = 0L;
|
||||
p->VarRep[0] = '_';
|
||||
@ -170,11 +170,11 @@ VarNames(VarEntry *p,Term l)
|
||||
{
|
||||
if (p != NULL) {
|
||||
if (strcmp(p->VarRep, "_") != 0) {
|
||||
Term o = MkPairTerm(MkPairTerm(_YAP_StringToList(p->VarRep), p->VarAdr),
|
||||
Term o = MkPairTerm(MkPairTerm(Yap_StringToList(p->VarRep), p->VarAdr),
|
||||
VarNames(p->VarRight,
|
||||
VarNames(p->VarLeft,l)));
|
||||
if (H > ASP-4096) {
|
||||
longjmp(_YAP_IOBotch,1);
|
||||
longjmp(Yap_IOBotch,1);
|
||||
}
|
||||
return(o);
|
||||
} else {
|
||||
@ -186,7 +186,7 @@ VarNames(VarEntry *p,Term l)
|
||||
}
|
||||
|
||||
Term
|
||||
_YAP_VarNames(VarEntry *p,Term l)
|
||||
Yap_VarNames(VarEntry *p,Term l)
|
||||
{
|
||||
return VarNames(p,l);
|
||||
}
|
||||
@ -210,7 +210,7 @@ IsPrefixOp(Prop opinfo,int *pptr, int *rpptr)
|
||||
}
|
||||
|
||||
int
|
||||
_YAP_IsPrefixOp(Prop opinfo,int *pptr, int *rpptr)
|
||||
Yap_IsPrefixOp(Prop opinfo,int *pptr, int *rpptr)
|
||||
{
|
||||
return IsPrefixOp(opinfo,pptr,rpptr);
|
||||
}
|
||||
@ -236,7 +236,7 @@ IsInfixOp(Prop opinfo, int *pptr, int *lpptr, int *rpptr)
|
||||
}
|
||||
|
||||
int
|
||||
_YAP_IsInfixOp(Prop opinfo, int *pptr, int *lpptr, int *rpptr)
|
||||
Yap_IsInfixOp(Prop opinfo, int *pptr, int *lpptr, int *rpptr)
|
||||
{
|
||||
return IsInfixOp(opinfo, pptr, lpptr, rpptr);
|
||||
}
|
||||
@ -259,7 +259,7 @@ IsPosfixOp(Prop opinfo, int *pptr, int *lpptr)
|
||||
}
|
||||
|
||||
int
|
||||
_YAP_IsPosfixOp(Prop opinfo, int *pptr, int *lpptr)
|
||||
Yap_IsPosfixOp(Prop opinfo, int *pptr, int *lpptr)
|
||||
{
|
||||
return IsPosfixOp(opinfo, pptr, lpptr);
|
||||
}
|
||||
@ -267,24 +267,24 @@ _YAP_IsPosfixOp(Prop opinfo, int *pptr, int *lpptr)
|
||||
inline static void
|
||||
GNextToken(void)
|
||||
{
|
||||
if (_YAP_tokptr->Tok == Ord(eot_tok))
|
||||
if (Yap_tokptr->Tok == Ord(eot_tok))
|
||||
return;
|
||||
#ifdef EMACS
|
||||
if ((_YAP_tokptr = _YAP_tokptr->TokNext)->TokPos > _YAP_toktide->TokPos)
|
||||
_YAP_toktide = _YAP_tokptr;
|
||||
if ((Yap_tokptr = Yap_tokptr->TokNext)->TokPos > Yap_toktide->TokPos)
|
||||
Yap_toktide = Yap_tokptr;
|
||||
#else
|
||||
if (_YAP_tokptr == _YAP_toktide)
|
||||
_YAP_toktide = _YAP_tokptr = _YAP_tokptr->TokNext;
|
||||
if (Yap_tokptr == Yap_toktide)
|
||||
Yap_toktide = Yap_tokptr = Yap_tokptr->TokNext;
|
||||
else
|
||||
_YAP_tokptr = _YAP_tokptr->TokNext;
|
||||
Yap_tokptr = Yap_tokptr->TokNext;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline static void
|
||||
checkfor(Term c)
|
||||
{
|
||||
if (_YAP_tokptr->Tok != Ord(Ponctuation_tok)
|
||||
|| _YAP_tokptr->TokInfo != c)
|
||||
if (Yap_tokptr->Tok != Ord(Ponctuation_tok)
|
||||
|| Yap_tokptr->TokInfo != c)
|
||||
FAIL;
|
||||
NextToken;
|
||||
}
|
||||
@ -295,7 +295,7 @@ ParseArgs(Atom a)
|
||||
int nargs = 0;
|
||||
Term *p, t;
|
||||
#ifdef SFUNC
|
||||
SFEntry *pe = (SFEntry *) _YAP_GetAProp(a, SFProperty);
|
||||
SFEntry *pe = (SFEntry *) Yap_GetAProp(a, SFProperty);
|
||||
#endif
|
||||
|
||||
NextToken;
|
||||
@ -305,9 +305,9 @@ ParseArgs(Atom a)
|
||||
*tp++ = Unsigned(ParseTerm(999));
|
||||
ParserAuxSp = (tr_fr_ptr)tp;
|
||||
++nargs;
|
||||
if (_YAP_tokptr->Tok != Ord(Ponctuation_tok))
|
||||
if (Yap_tokptr->Tok != Ord(Ponctuation_tok))
|
||||
break;
|
||||
if (((int) _YAP_tokptr->TokInfo) != ',')
|
||||
if (((int) Yap_tokptr->TokInfo) != ',')
|
||||
break;
|
||||
NextToken;
|
||||
}
|
||||
@ -317,16 +317,16 @@ ParseArgs(Atom a)
|
||||
* order
|
||||
*/
|
||||
if (H > ASP-(nargs+1)) {
|
||||
_YAP_ErrorMessage = "Stack Overflow";
|
||||
Yap_ErrorMessage = "Stack Overflow";
|
||||
FAIL;
|
||||
}
|
||||
#ifdef SFUNC
|
||||
if (pe)
|
||||
t = MkSFTerm(_YAP_MkFunctor(a, SFArity), nargs, p, pe->NilValue);
|
||||
t = MkSFTerm(Yap_MkFunctor(a, SFArity), nargs, p, pe->NilValue);
|
||||
else
|
||||
t = _YAP_MkApplTerm(_YAP_MkFunctor(a, nargs), nargs, p);
|
||||
t = Yap_MkApplTerm(Yap_MkFunctor(a, nargs), nargs, p);
|
||||
#else
|
||||
t = _YAP_MkApplTerm(_YAP_MkFunctor(a, nargs), nargs, p);
|
||||
t = Yap_MkApplTerm(Yap_MkFunctor(a, nargs), nargs, p);
|
||||
#endif
|
||||
/* check for possible overflow against local stack */
|
||||
checkfor((Term) ')');
|
||||
@ -344,25 +344,25 @@ ParseList(void)
|
||||
to_store = H;
|
||||
H+=2;
|
||||
to_store[0] = ParseTerm(999);
|
||||
if (_YAP_tokptr->Tok == Ord(Ponctuation_tok)) {
|
||||
if (((int) _YAP_tokptr->TokInfo) == ',') {
|
||||
if (Yap_tokptr->Tok == Ord(Ponctuation_tok)) {
|
||||
if (((int) Yap_tokptr->TokInfo) == ',') {
|
||||
NextToken;
|
||||
if (_YAP_tokptr->Tok == Ord(Name_tok)
|
||||
&& strcmp(RepAtom((Atom)(_YAP_tokptr->TokInfo))->StrOfAE, "..") == 0) {
|
||||
if (Yap_tokptr->Tok == Ord(Name_tok)
|
||||
&& strcmp(RepAtom((Atom)(Yap_tokptr->TokInfo))->StrOfAE, "..") == 0) {
|
||||
NextToken;
|
||||
to_store[1] = ParseTerm(999);
|
||||
} else {
|
||||
/* check for possible overflow against local stack */
|
||||
if (H > ASP-4096) {
|
||||
to_store[1] = TermNil;
|
||||
_YAP_ErrorMessage = "Stack Overflow";
|
||||
Yap_ErrorMessage = "Stack Overflow";
|
||||
FAIL;
|
||||
} else {
|
||||
to_store[1] = AbsPair(H);
|
||||
goto loop;
|
||||
}
|
||||
}
|
||||
} else if (((int) _YAP_tokptr->TokInfo) == '|') {
|
||||
} else if (((int) Yap_tokptr->TokInfo) == '|') {
|
||||
NextToken;
|
||||
to_store[1] = ParseTerm(999);
|
||||
} else {
|
||||
@ -391,29 +391,29 @@ ParseTerm(int prio)
|
||||
Volatile VarEntry *varinfo;
|
||||
Volatile int curprio = 0, opprio, oplprio, oprprio;
|
||||
|
||||
switch (_YAP_tokptr->Tok) {
|
||||
switch (Yap_tokptr->Tok) {
|
||||
case Name_tok:
|
||||
t = _YAP_tokptr->TokInfo;
|
||||
t = Yap_tokptr->TokInfo;
|
||||
NextToken;
|
||||
if ((_YAP_tokptr->Tok != Ord(Ponctuation_tok)
|
||||
|| Unsigned(_YAP_tokptr->TokInfo) != 'l')
|
||||
&& (opinfo = _YAP_GetAProp((Atom) t, OpProperty))
|
||||
if ((Yap_tokptr->Tok != Ord(Ponctuation_tok)
|
||||
|| Unsigned(Yap_tokptr->TokInfo) != 'l')
|
||||
&& (opinfo = Yap_GetAProp((Atom) t, OpProperty))
|
||||
&& IsPrefixOp(opinfo, &opprio, &oprprio)
|
||||
) {
|
||||
/* special rules apply for +1, -2.3, etc... */
|
||||
if (_YAP_tokptr->Tok == Number_tok) {
|
||||
if (Yap_tokptr->Tok == Number_tok) {
|
||||
if ((Atom)t == AtomMinus) {
|
||||
t = _YAP_tokptr->TokInfo;
|
||||
t = Yap_tokptr->TokInfo;
|
||||
if (IsIntTerm(t))
|
||||
t = MkIntTerm(-IntOfTerm(t));
|
||||
else if (IsFloatTerm(t))
|
||||
t = MkFloatTerm(-FloatOfTerm(t));
|
||||
#ifdef USE_GMP
|
||||
else if (IsBigIntTerm(t)) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_neg(new, _YAP_BigIntOfTerm(t));
|
||||
t = _YAP_MkBigIntTerm(new);
|
||||
mpz_neg(new, Yap_BigIntOfTerm(t));
|
||||
t = Yap_MkBigIntTerm(new);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
@ -421,12 +421,12 @@ ParseTerm(int prio)
|
||||
NextToken;
|
||||
break;
|
||||
} else if ((Atom)t == AtomPlus) {
|
||||
t = _YAP_tokptr->TokInfo;
|
||||
t = Yap_tokptr->TokInfo;
|
||||
NextToken;
|
||||
break;
|
||||
}
|
||||
} else if (_YAP_tokptr->Tok == Name_tok) {
|
||||
Atom at = (Atom)_YAP_tokptr->TokInfo;
|
||||
} else if (Yap_tokptr->Tok == Name_tok) {
|
||||
Atom at = (Atom)Yap_tokptr->TokInfo;
|
||||
#ifndef _MSC_VER
|
||||
if ((Atom)t == AtomPlus) {
|
||||
if (at == AtomInf) {
|
||||
@ -455,12 +455,12 @@ ParseTerm(int prio)
|
||||
/* try to parse as a prefix operator */
|
||||
TRY(
|
||||
/* build appl on the heap */
|
||||
func = _YAP_MkFunctor((Atom) t, 1);
|
||||
func = Yap_MkFunctor((Atom) t, 1);
|
||||
t = ParseTerm(oprprio);
|
||||
t = _YAP_MkApplTerm(func, 1, &t);
|
||||
t = Yap_MkApplTerm(func, 1, &t);
|
||||
/* check for possible overflow against local stack */
|
||||
if (H > ASP-4096) {
|
||||
_YAP_ErrorMessage = "Stack Overflow";
|
||||
Yap_ErrorMessage = "Stack Overflow";
|
||||
FAIL;
|
||||
}
|
||||
curprio = opprio;
|
||||
@ -469,35 +469,35 @@ ParseTerm(int prio)
|
||||
)
|
||||
}
|
||||
}
|
||||
if (_YAP_tokptr->Tok == Ord(Ponctuation_tok)
|
||||
&& Unsigned(_YAP_tokptr->TokInfo) == 'l')
|
||||
if (Yap_tokptr->Tok == Ord(Ponctuation_tok)
|
||||
&& Unsigned(Yap_tokptr->TokInfo) == 'l')
|
||||
t = ParseArgs((Atom) t);
|
||||
else
|
||||
t = MkAtomTerm((Atom)t);
|
||||
break;
|
||||
|
||||
case Number_tok:
|
||||
t = _YAP_tokptr->TokInfo;
|
||||
t = Yap_tokptr->TokInfo;
|
||||
NextToken;
|
||||
break;
|
||||
|
||||
case String_tok: /* build list on the heap */
|
||||
{
|
||||
Volatile char *p = (char *) _YAP_tokptr->TokInfo;
|
||||
Volatile char *p = (char *) Yap_tokptr->TokInfo;
|
||||
if (*p == 0)
|
||||
t = MkAtomTerm(AtomNil);
|
||||
else if (yap_flags[YAP_DOUBLE_QUOTES_FLAG] == STRING_AS_CHARS)
|
||||
t = _YAP_StringToListOfAtoms(p);
|
||||
t = Yap_StringToListOfAtoms(p);
|
||||
else if (yap_flags[YAP_DOUBLE_QUOTES_FLAG] == STRING_AS_ATOM)
|
||||
t = MkAtomTerm(_YAP_LookupAtom(p));
|
||||
t = MkAtomTerm(Yap_LookupAtom(p));
|
||||
else
|
||||
t = _YAP_StringToList(p);
|
||||
t = Yap_StringToList(p);
|
||||
NextToken;
|
||||
}
|
||||
break;
|
||||
|
||||
case Var_tok:
|
||||
varinfo = (VarEntry *) (_YAP_tokptr->TokInfo);
|
||||
varinfo = (VarEntry *) (Yap_tokptr->TokInfo);
|
||||
if ((t = varinfo->VarAdr) == TermNil) {
|
||||
t = varinfo->VarAdr = MkVarTerm();
|
||||
}
|
||||
@ -505,7 +505,7 @@ ParseTerm(int prio)
|
||||
break;
|
||||
|
||||
case Ponctuation_tok:
|
||||
switch ((int) _YAP_tokptr->TokInfo) {
|
||||
switch ((int) Yap_tokptr->TokInfo) {
|
||||
case '(':
|
||||
case 'l': /* non solo ( */
|
||||
NextToken;
|
||||
@ -519,16 +519,16 @@ ParseTerm(int prio)
|
||||
break;
|
||||
case '{':
|
||||
NextToken;
|
||||
if (_YAP_tokptr->Tok == Ord(Ponctuation_tok) &&
|
||||
Unsigned(_YAP_tokptr->TokInfo) == '}') {
|
||||
if (Yap_tokptr->Tok == Ord(Ponctuation_tok) &&
|
||||
Unsigned(Yap_tokptr->TokInfo) == '}') {
|
||||
t = MkAtomTerm(NameOfFunctor(FunctorBraces));
|
||||
NextToken;
|
||||
} else {
|
||||
t = ParseTerm(1200);
|
||||
t = _YAP_MkApplTerm(FunctorBraces, 1, &t);
|
||||
t = Yap_MkApplTerm(FunctorBraces, 1, &t);
|
||||
/* check for possible overflow against local stack */
|
||||
if (H > ASP-4096) {
|
||||
_YAP_ErrorMessage = "Stack Overflow";
|
||||
Yap_ErrorMessage = "Stack Overflow";
|
||||
FAIL;
|
||||
}
|
||||
checkfor((Term) '}');
|
||||
@ -546,24 +546,24 @@ ParseTerm(int prio)
|
||||
|
||||
/* main loop to parse infix and posfix operators starts here */
|
||||
while (TRUE) {
|
||||
if (_YAP_tokptr->Tok == Ord(Name_tok)
|
||||
&& (opinfo = _YAP_GetAProp((Atom)(_YAP_tokptr->TokInfo), OpProperty))) {
|
||||
if (Yap_tokptr->Tok == Ord(Name_tok)
|
||||
&& (opinfo = Yap_GetAProp((Atom)(Yap_tokptr->TokInfo), OpProperty))) {
|
||||
Prop save_opinfo = opinfo;
|
||||
if (IsInfixOp(opinfo, &opprio, &oplprio, &oprprio)
|
||||
&& opprio <= prio && oplprio >= curprio) {
|
||||
/* try parsing as infix operator */
|
||||
Volatile int oldprio = curprio;
|
||||
TRY3(
|
||||
func = _YAP_MkFunctor((Atom) _YAP_tokptr->TokInfo, 2);
|
||||
func = Yap_MkFunctor((Atom) Yap_tokptr->TokInfo, 2);
|
||||
NextToken;
|
||||
{
|
||||
Term args[2];
|
||||
args[0] = t;
|
||||
args[1] = ParseTerm(oprprio);
|
||||
t = _YAP_MkApplTerm(func, 2, args);
|
||||
t = Yap_MkApplTerm(func, 2, args);
|
||||
/* check for possible overflow against local stack */
|
||||
if (H > ASP-4096) {
|
||||
_YAP_ErrorMessage = "Stack Overflow";
|
||||
Yap_ErrorMessage = "Stack Overflow";
|
||||
FAIL;
|
||||
}
|
||||
},
|
||||
@ -578,10 +578,10 @@ ParseTerm(int prio)
|
||||
if (IsPosfixOp(opinfo, &opprio, &oplprio)
|
||||
&& opprio <= prio && oplprio >= curprio) {
|
||||
/* parse as posfix operator */
|
||||
t = _YAP_MkApplTerm(_YAP_MkFunctor((Atom) _YAP_tokptr->TokInfo, 1), 1, &t);
|
||||
t = Yap_MkApplTerm(Yap_MkFunctor((Atom) Yap_tokptr->TokInfo, 1), 1, &t);
|
||||
/* check for possible overflow against local stack */
|
||||
if (H > ASP-4096) {
|
||||
_YAP_ErrorMessage = "Stack Overflow";
|
||||
Yap_ErrorMessage = "Stack Overflow";
|
||||
FAIL;
|
||||
}
|
||||
curprio = opprio;
|
||||
@ -590,38 +590,38 @@ ParseTerm(int prio)
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (_YAP_tokptr->Tok == Ord(Ponctuation_tok)) {
|
||||
if (Unsigned(_YAP_tokptr->TokInfo) == ',' &&
|
||||
if (Yap_tokptr->Tok == Ord(Ponctuation_tok)) {
|
||||
if (Unsigned(Yap_tokptr->TokInfo) == ',' &&
|
||||
prio >= 1000 && curprio <= 999) {
|
||||
Volatile Term args[2];
|
||||
NextToken;
|
||||
args[0] = t;
|
||||
args[1] = ParseTerm(1000);
|
||||
t = _YAP_MkApplTerm(_YAP_MkFunctor(AtomComma, 2), 2, args);
|
||||
t = Yap_MkApplTerm(Yap_MkFunctor(AtomComma, 2), 2, args);
|
||||
/* check for possible overflow against local stack */
|
||||
if (H > ASP-4096) {
|
||||
_YAP_ErrorMessage = "Stack Overflow";
|
||||
Yap_ErrorMessage = "Stack Overflow";
|
||||
FAIL;
|
||||
}
|
||||
curprio = 1000;
|
||||
continue;
|
||||
} else if (Unsigned(_YAP_tokptr->TokInfo) == '|' && prio >= 1100 &&
|
||||
} else if (Unsigned(Yap_tokptr->TokInfo) == '|' && prio >= 1100 &&
|
||||
curprio <= 1099) {
|
||||
Volatile Term args[2];
|
||||
NextToken;
|
||||
args[0] = t;
|
||||
args[1] = ParseTerm(1100);
|
||||
t = _YAP_MkApplTerm(FunctorVBar, 2, args);
|
||||
t = Yap_MkApplTerm(FunctorVBar, 2, args);
|
||||
/* check for possible overflow against local stack */
|
||||
if (H > ASP-4096) {
|
||||
_YAP_ErrorMessage = "Stack Overflow";
|
||||
Yap_ErrorMessage = "Stack Overflow";
|
||||
FAIL;
|
||||
}
|
||||
curprio = 1100;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (_YAP_tokptr->Tok <= Ord(String_tok))
|
||||
if (Yap_tokptr->Tok <= Ord(String_tok))
|
||||
FAIL;
|
||||
break;
|
||||
}
|
||||
@ -630,12 +630,12 @@ ParseTerm(int prio)
|
||||
|
||||
|
||||
Term
|
||||
_YAP_Parse(void)
|
||||
Yap_Parse(void)
|
||||
{
|
||||
Volatile Term t;
|
||||
if (!setjmp(FailBuff.JmpBuff)) {
|
||||
t = ParseTerm(1200);
|
||||
if (_YAP_tokptr->Tok != Ord(eot_tok))
|
||||
if (Yap_tokptr->Tok != Ord(eot_tok))
|
||||
return (0L);
|
||||
return (t);
|
||||
} else
|
||||
|
304
C/save.c
304
C/save.c
@ -164,7 +164,7 @@ myread(int fd, char *buff, Int len)
|
||||
while (len > 16000) {
|
||||
int nchars = read(fd, buff, 16000);
|
||||
if (nchars <= 0)
|
||||
_YAP_Error(FATAL_ERROR,TermNil,"bad saved state, system corrupted");
|
||||
Yap_Error(FATAL_ERROR,TermNil,"bad saved state, system corrupted");
|
||||
len -= 16000;
|
||||
buff += 16000;
|
||||
}
|
||||
@ -191,7 +191,7 @@ void myread(int fd, char *buffer, Int len) {
|
||||
while (len > 0) {
|
||||
nread = read(fd, buffer, (int)len);
|
||||
if (nread < 1) {
|
||||
_YAP_Error(FATAL_ERROR,TermNil,"bad saved state, system corrupted");
|
||||
Yap_Error(FATAL_ERROR,TermNil,"bad saved state, system corrupted");
|
||||
}
|
||||
buffer += nread;
|
||||
len -= nread;
|
||||
@ -205,7 +205,7 @@ void mywrite(int fd, char *buff, Int len) {
|
||||
while (len > 0) {
|
||||
nwritten = (Int)write(fd, buff, (int)len);
|
||||
if (nwritten == -1) {
|
||||
_YAP_Error(SYSTEM_ERROR,TermNil,"write error while saving");
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,"write error while saving");
|
||||
}
|
||||
buff += nwritten;
|
||||
len -= nwritten;
|
||||
@ -229,7 +229,7 @@ static int splfild = 0;
|
||||
#ifdef DEBUG_RESTORE4
|
||||
static FILE *errout;
|
||||
#else
|
||||
#define errout _YAP_stderr
|
||||
#define errout Yap_stderr
|
||||
#endif
|
||||
|
||||
#endif /* DEBUG */
|
||||
@ -311,7 +311,7 @@ get_header_cell(void)
|
||||
int count = 0, n;
|
||||
while (count < sizeof(CELL)) {
|
||||
if ((n = read(splfild, &l, sizeof(CELL)-count)) < 0) {
|
||||
_YAP_ErrorMessage = "corrupt saved state";
|
||||
Yap_ErrorMessage = "corrupt saved state";
|
||||
return(0L);
|
||||
}
|
||||
count += n;
|
||||
@ -350,25 +350,25 @@ put_info(int info, int mode)
|
||||
/* current state of stacks, to be used by SavedInfo */
|
||||
#if defined(YAPOR) || defined(TABLING)
|
||||
/* space available in heap area */
|
||||
putout(Unsigned(_YAP_GlobalBase)-Unsigned(_YAP_HeapBase));
|
||||
putout(Unsigned(Yap_GlobalBase)-Unsigned(Yap_HeapBase));
|
||||
/* space available for stacks */
|
||||
putout(Unsigned(_YAP_LocalBase)-Unsigned(_YAP_GlobalBase)+CellSize);
|
||||
putout(Unsigned(Yap_LocalBase)-Unsigned(Yap_GlobalBase)+CellSize);
|
||||
#else
|
||||
/* space available in heap area */
|
||||
putout(Unsigned(_YAP_GlobalBase)-Unsigned(_YAP_HeapBase));
|
||||
putout(Unsigned(Yap_GlobalBase)-Unsigned(Yap_HeapBase));
|
||||
/* space available for stacks */
|
||||
putout(Unsigned(_YAP_LocalBase)-Unsigned(_YAP_GlobalBase));
|
||||
putout(Unsigned(Yap_LocalBase)-Unsigned(Yap_GlobalBase));
|
||||
#endif /* YAPOR || TABLING */
|
||||
/* space available for trail */
|
||||
putout(Unsigned(_YAP_TrailTop)-Unsigned(_YAP_TrailBase));
|
||||
putout(Unsigned(Yap_TrailTop)-Unsigned(Yap_TrailBase));
|
||||
/* Space used in heap area */
|
||||
putout(Unsigned(HeapTop)-Unsigned(_YAP_HeapBase));
|
||||
putout(Unsigned(HeapTop)-Unsigned(Yap_HeapBase));
|
||||
/* Space used for local stack */
|
||||
putout(Unsigned(LCL0)-Unsigned(ASP));
|
||||
/* Space used for global stack */
|
||||
putout(Unsigned(H) - Unsigned(_YAP_GlobalBase));
|
||||
putout(Unsigned(H) - Unsigned(Yap_GlobalBase));
|
||||
/* Space used for trail */
|
||||
putout(Unsigned(TR) - Unsigned(_YAP_TrailBase));
|
||||
putout(Unsigned(TR) - Unsigned(Yap_TrailBase));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -413,7 +413,7 @@ save_regs(int mode)
|
||||
putout(which_save);
|
||||
/* Now start by saving the code */
|
||||
/* the heap boundaries */
|
||||
putcellptr(CellPtr(_YAP_HeapBase));
|
||||
putcellptr(CellPtr(Yap_HeapBase));
|
||||
putcellptr(CellPtr(HeapTop));
|
||||
/* and the space it ocuppies */
|
||||
putout(Unsigned(HeapUsed));
|
||||
@ -425,7 +425,7 @@ save_regs(int mode)
|
||||
if (which_save == 2) {
|
||||
putout(ARG2);
|
||||
}
|
||||
putcellptr(CellPtr(_YAP_TrailBase));
|
||||
putcellptr(CellPtr(Yap_TrailBase));
|
||||
}
|
||||
}
|
||||
|
||||
@ -439,7 +439,7 @@ save_code_info(void)
|
||||
|
||||
OPCODE my_ops[_std_top+1];
|
||||
for (i = _Ystop; i <= _std_top; ++i)
|
||||
my_ops[i] = _YAP_opcode(i);
|
||||
my_ops[i] = Yap_opcode(i);
|
||||
mywrite(splfild, (char *)my_ops, sizeof(OPCODE)*(_std_top+1));
|
||||
}
|
||||
/* Then the c-functions */
|
||||
@ -447,19 +447,19 @@ save_code_info(void)
|
||||
{
|
||||
UInt i;
|
||||
for (i = 0; i < NumberOfCPreds; ++i)
|
||||
putcellptr(CellPtr(_YAP_c_predicates[i]));
|
||||
putcellptr(CellPtr(Yap_c_predicates[i]));
|
||||
}
|
||||
/* Then the cmp-functions */
|
||||
putout(NumberOfCmpFuncs);
|
||||
{
|
||||
UInt i;
|
||||
for (i = 0; i < NumberOfCmpFuncs; ++i) {
|
||||
putcellptr(CellPtr(_YAP_cmp_funcs[i].p));
|
||||
putcellptr(CellPtr(_YAP_cmp_funcs[i].f));
|
||||
putcellptr(CellPtr(Yap_cmp_funcs[i].p));
|
||||
putcellptr(CellPtr(Yap_cmp_funcs[i].f));
|
||||
}
|
||||
}
|
||||
/* and the current character codes */
|
||||
mywrite(splfild, _YAP_chtype, NUMBER_OF_CHARS);
|
||||
mywrite(splfild, Yap_chtype, NUMBER_OF_CHARS);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -469,9 +469,9 @@ save_heap(void)
|
||||
/* Then save the whole heap */
|
||||
#if defined(YAPOR) || defined(TABLING)
|
||||
/* skip the local and global data structures */
|
||||
j = Unsigned(&GLOBAL) - Unsigned(_YAP_HeapBase);
|
||||
j = Unsigned(&GLOBAL) - Unsigned(Yap_HeapBase);
|
||||
putout(j);
|
||||
mywrite(splfild, (char *) _YAP_HeapBase, j);
|
||||
mywrite(splfild, (char *) Yap_HeapBase, j);
|
||||
#ifdef USE_HEAP
|
||||
j = Unsigned(HeapTop) - Unsigned(&HashChain);
|
||||
putout(j);
|
||||
@ -485,9 +485,9 @@ save_heap(void)
|
||||
mywrite(splfild, (char *) TopAllocBlockArea, j);
|
||||
#endif
|
||||
#else
|
||||
j = Unsigned(HeapTop) - Unsigned(_YAP_HeapBase);
|
||||
j = Unsigned(HeapTop) - Unsigned(Yap_HeapBase);
|
||||
/* store 10 more cells because of the memory manager */
|
||||
mywrite(splfild, (char *) _YAP_HeapBase, j);
|
||||
mywrite(splfild, (char *) Yap_HeapBase, j);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -503,16 +503,16 @@ save_stacks(int mode)
|
||||
j = Unsigned(LCL0) - Unsigned(ASP);
|
||||
mywrite(splfild, (char *) ASP, j);
|
||||
/* Save the global stack */
|
||||
j = Unsigned(H) - Unsigned(_YAP_GlobalBase);
|
||||
mywrite(splfild, (char *) _YAP_GlobalBase, j);
|
||||
j = Unsigned(H) - Unsigned(Yap_GlobalBase);
|
||||
mywrite(splfild, (char *) Yap_GlobalBase, j);
|
||||
/* Save the trail */
|
||||
j = Unsigned(TR) - Unsigned(_YAP_TrailBase);
|
||||
mywrite(splfild, (char *) _YAP_TrailBase, j);
|
||||
j = Unsigned(TR) - Unsigned(Yap_TrailBase);
|
||||
mywrite(splfild, (char *) Yap_TrailBase, j);
|
||||
break;
|
||||
case DO_ONLY_CODE:
|
||||
{
|
||||
tr_fr_ptr tr_ptr = TR;
|
||||
while (tr_ptr != (tr_fr_ptr)_YAP_TrailBase) {
|
||||
while (tr_ptr != (tr_fr_ptr)Yap_TrailBase) {
|
||||
CELL val = TrailTerm(tr_ptr-1);
|
||||
if (IsVarTerm(val)) {
|
||||
CELL *d1 = VarOfTerm(val);
|
||||
@ -550,13 +550,13 @@ do_save(int mode) {
|
||||
NewFileInfo('YAPS', 'MYap');
|
||||
#endif
|
||||
Term t1 = Deref(ARG1);
|
||||
if (!_YAP_GetName(_YAP_FileNameBuf, YAP_FILENAME_MAX, t1)) {
|
||||
_YAP_Error(TYPE_ERROR_LIST,t1,"save/1");
|
||||
if (!Yap_GetName(Yap_FileNameBuf, YAP_FILENAME_MAX, t1)) {
|
||||
Yap_Error(TYPE_ERROR_LIST,t1,"save/1");
|
||||
return(FALSE);
|
||||
}
|
||||
_YAP_CloseStreams(TRUE);
|
||||
if ((splfild = open_file(_YAP_FileNameBuf, O_WRONLY | O_CREAT)) < 0) {
|
||||
_YAP_Error(SYSTEM_ERROR,MkAtomTerm(_YAP_LookupAtom(_YAP_FileNameBuf)),
|
||||
Yap_CloseStreams(TRUE);
|
||||
if ((splfild = open_file(Yap_FileNameBuf, O_WRONLY | O_CREAT)) < 0) {
|
||||
Yap_Error(SYSTEM_ERROR,MkAtomTerm(Yap_LookupAtom(Yap_FileNameBuf)),
|
||||
"restore/1, open(%s)", strerror(errno));
|
||||
return(FALSE);
|
||||
}
|
||||
@ -576,7 +576,7 @@ p_save(void)
|
||||
{
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
if (NOfThreads != 1) {
|
||||
_YAP_Error(SYSTEM_ERROR,TermNil,"cannot perform save: more than a worker/thread running");
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,"cannot perform save: more than a worker/thread running");
|
||||
return(FALSE);
|
||||
}
|
||||
#endif
|
||||
@ -590,13 +590,13 @@ p_save2(void)
|
||||
{
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
if (NOfThreads != 1) {
|
||||
_YAP_Error(SYSTEM_ERROR,TermNil,
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,
|
||||
"cannot perform save: more than a worker/thread running");
|
||||
return(FALSE);
|
||||
}
|
||||
#endif
|
||||
which_save = 2;
|
||||
return(do_save(DO_EVERYTHING) && _YAP_unify(ARG2,MkIntTerm(1)));
|
||||
return(do_save(DO_EVERYTHING) && Yap_unify(ARG2,MkIntTerm(1)));
|
||||
}
|
||||
|
||||
/* Just save the program, not the stacks */
|
||||
@ -621,7 +621,7 @@ check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap)
|
||||
/* skip the first line */
|
||||
do {
|
||||
if (read(splfild, pp, 1) < 0) {
|
||||
_YAP_ErrorMessage = "corrupt saved state";
|
||||
Yap_ErrorMessage = "corrupt saved state";
|
||||
return(FAIL_RESTORE);
|
||||
}
|
||||
} while (pp[0] != 1);
|
||||
@ -631,89 +631,89 @@ check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap)
|
||||
int count = 0, n, to_read = Unsigned(strlen(msg) + 1);
|
||||
while (count < to_read) {
|
||||
if ((n = read(splfild, pp, to_read-count)) < 0) {
|
||||
_YAP_ErrorMessage = "corrupt saved state";
|
||||
Yap_ErrorMessage = "corrupt saved state";
|
||||
return(FAIL_RESTORE);
|
||||
}
|
||||
count += n;
|
||||
}
|
||||
}
|
||||
if (pp[0] != 'Y' && pp[1] != 'A' && pp[0] != 'P') {
|
||||
_YAP_ErrorMessage = "corrupt saved state";
|
||||
Yap_ErrorMessage = "corrupt saved state";
|
||||
return(FAIL_RESTORE);
|
||||
}
|
||||
if (strcmp(pp, msg) != 0) {
|
||||
_YAP_ErrorMessage = "saved state for different version of YAP";
|
||||
Yap_ErrorMessage = "saved state for different version of YAP";
|
||||
return(FAIL_RESTORE);
|
||||
}
|
||||
/* check info on header */
|
||||
/* ignore info on saved state */
|
||||
*info = get_header_cell();
|
||||
if (_YAP_ErrorMessage)
|
||||
if (Yap_ErrorMessage)
|
||||
return(FAIL_RESTORE);
|
||||
/* check the restore mode */
|
||||
mode = get_header_cell();
|
||||
if (_YAP_ErrorMessage)
|
||||
if (Yap_ErrorMessage)
|
||||
return(FAIL_RESTORE);
|
||||
/* check the number of c-predicates */
|
||||
c_preds = get_header_cell();
|
||||
if (_YAP_ErrorMessage)
|
||||
if (Yap_ErrorMessage)
|
||||
return(FAIL_RESTORE);
|
||||
if (_YAP_HeapBase != NULL && c_preds != NumberOfCPreds) {
|
||||
_YAP_ErrorMessage = "saved state with different number of built-ins";
|
||||
if (Yap_HeapBase != NULL && c_preds != NumberOfCPreds) {
|
||||
Yap_ErrorMessage = "saved state with different number of built-ins";
|
||||
return(FAIL_RESTORE);
|
||||
}
|
||||
cmp_funcs = get_header_cell();
|
||||
if (_YAP_ErrorMessage)
|
||||
if (Yap_ErrorMessage)
|
||||
return(FAIL_RESTORE);
|
||||
if (_YAP_HeapBase != NULL && cmp_funcs != NumberOfCmpFuncs) {
|
||||
_YAP_ErrorMessage = "saved state with different built-ins";
|
||||
if (Yap_HeapBase != NULL && cmp_funcs != NumberOfCmpFuncs) {
|
||||
Yap_ErrorMessage = "saved state with different built-ins";
|
||||
return(FAIL_RESTORE);
|
||||
}
|
||||
if (mode != DO_EVERYTHING && mode != DO_ONLY_CODE) {
|
||||
_YAP_ErrorMessage = "corrupt saved state";
|
||||
Yap_ErrorMessage = "corrupt saved state";
|
||||
return(FAIL_RESTORE);
|
||||
}
|
||||
/* ignore info on stacks size */
|
||||
*AHeap = get_header_cell();
|
||||
*AStack = get_header_cell();
|
||||
*ATrail = get_header_cell();
|
||||
if (_YAP_ErrorMessage)
|
||||
if (Yap_ErrorMessage)
|
||||
return(FAIL_RESTORE);
|
||||
/* now, check whether we got enough enough space to load the
|
||||
saved space */
|
||||
hp_size = get_cell();
|
||||
if (_YAP_ErrorMessage)
|
||||
if (Yap_ErrorMessage)
|
||||
return(FAIL_RESTORE);
|
||||
while (_YAP_HeapBase != NULL && hp_size > Unsigned(AuxTop) - Unsigned(_YAP_HeapBase)) {
|
||||
if(!_YAP_growheap(FALSE)) {
|
||||
while (Yap_HeapBase != NULL && hp_size > Unsigned(AuxTop) - Unsigned(Yap_HeapBase)) {
|
||||
if(!Yap_growheap(FALSE)) {
|
||||
return(FAIL_RESTORE);
|
||||
}
|
||||
}
|
||||
if (mode == DO_EVERYTHING) {
|
||||
lc_size = get_cell();
|
||||
if (_YAP_ErrorMessage)
|
||||
if (Yap_ErrorMessage)
|
||||
return(FAIL_RESTORE);
|
||||
gb_size=get_cell();
|
||||
if (_YAP_ErrorMessage)
|
||||
if (Yap_ErrorMessage)
|
||||
return(FAIL_RESTORE);
|
||||
if (_YAP_HeapBase != NULL && lc_size+gb_size > Unsigned(_YAP_LocalBase) - Unsigned(_YAP_GlobalBase)) {
|
||||
_YAP_ErrorMessage = "not enough stack space for restore";
|
||||
if (Yap_HeapBase != NULL && lc_size+gb_size > Unsigned(Yap_LocalBase) - Unsigned(Yap_GlobalBase)) {
|
||||
Yap_ErrorMessage = "not enough stack space for restore";
|
||||
return(FAIL_RESTORE);
|
||||
}
|
||||
if (_YAP_HeapBase != NULL && (tr_size = get_cell()) > Unsigned(_YAP_TrailTop) - Unsigned(_YAP_TrailBase)) {
|
||||
_YAP_ErrorMessage = "not enough trail space for restore";
|
||||
if (Yap_HeapBase != NULL && (tr_size = get_cell()) > Unsigned(Yap_TrailTop) - Unsigned(Yap_TrailBase)) {
|
||||
Yap_ErrorMessage = "not enough trail space for restore";
|
||||
return(FAIL_RESTORE);
|
||||
}
|
||||
} else {
|
||||
/* skip cell size */
|
||||
get_header_cell();
|
||||
if (_YAP_ErrorMessage)
|
||||
if (Yap_ErrorMessage)
|
||||
return(FAIL_RESTORE);
|
||||
get_header_cell();
|
||||
if (_YAP_ErrorMessage)
|
||||
if (Yap_ErrorMessage)
|
||||
return(FAIL_RESTORE);
|
||||
get_header_cell();
|
||||
if (_YAP_ErrorMessage)
|
||||
if (Yap_ErrorMessage)
|
||||
return(FAIL_RESTORE);
|
||||
}
|
||||
return(mode);
|
||||
@ -727,7 +727,7 @@ get_heap_info(void)
|
||||
OldHeapTop = (ADDR) get_cellptr();
|
||||
OldHeapUsed = (Int) get_cell();
|
||||
FreeBlocks = (BlockHeader *) get_cellptr();
|
||||
HDiff = Unsigned(_YAP_HeapBase) - Unsigned(OldHeapBase);
|
||||
HDiff = Unsigned(Yap_HeapBase) - Unsigned(OldHeapBase);
|
||||
}
|
||||
|
||||
/* Gets the register array */
|
||||
@ -736,7 +736,7 @@ get_heap_info(void)
|
||||
static void
|
||||
get_regs(int flag)
|
||||
{
|
||||
CELL *NewGlobalBase = (CELL *)_YAP_GlobalBase;
|
||||
CELL *NewGlobalBase = (CELL *)Yap_GlobalBase;
|
||||
CELL *NewLCL0 = LCL0;
|
||||
CELL *OldXREGS;
|
||||
|
||||
@ -788,13 +788,13 @@ get_regs(int flag)
|
||||
/* Save the old register where we can easily access them */
|
||||
OldASP = ASP;
|
||||
OldLCL0 = LCL0;
|
||||
OldGlobalBase = (CELL *)_YAP_GlobalBase;
|
||||
OldGlobalBase = (CELL *)Yap_GlobalBase;
|
||||
OldH = H;
|
||||
OldTR = TR;
|
||||
GDiff = Unsigned(NewGlobalBase) - Unsigned(_YAP_GlobalBase);
|
||||
GDiff = Unsigned(NewGlobalBase) - Unsigned(Yap_GlobalBase);
|
||||
LDiff = Unsigned(NewLCL0) - Unsigned(LCL0);
|
||||
TrDiff = LDiff;
|
||||
_YAP_GlobalBase = (ADDR)NewGlobalBase;
|
||||
Yap_GlobalBase = (ADDR)NewGlobalBase;
|
||||
LCL0 = NewLCL0;
|
||||
}
|
||||
}
|
||||
@ -815,17 +815,17 @@ check_funcs(void)
|
||||
int out = FALSE;
|
||||
|
||||
if ((old_NumberOfCPreds = get_cell()) != NumberOfCPreds) {
|
||||
_YAP_Error(SYSTEM_ERROR,TermNil,"bad saved state, different number of functions (%d vs %d), system corrupted, old_NumberOfCPreds, NumberOfCPreds");
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,"bad saved state, different number of functions (%d vs %d), system corrupted, old_NumberOfCPreds, NumberOfCPreds");
|
||||
}
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < old_NumberOfCPreds; ++i) {
|
||||
CELL *old_pred = get_cellptr();
|
||||
out = (out || old_pred != CellPtr(_YAP_c_predicates[i]));
|
||||
out = (out || old_pred != CellPtr(Yap_c_predicates[i]));
|
||||
}
|
||||
}
|
||||
if ((old_NumberOfCmpFuncs = get_cell()) != NumberOfCmpFuncs) {
|
||||
_YAP_Error(SYSTEM_ERROR,TermNil,"bad saved state, different number of comparison functions (%d vs %d), system corrupted", old_NumberOfCmpFuncs, NumberOfCmpFuncs);
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,"bad saved state, different number of comparison functions (%d vs %d), system corrupted", old_NumberOfCmpFuncs, NumberOfCmpFuncs);
|
||||
}
|
||||
{
|
||||
unsigned int i;
|
||||
@ -834,11 +834,11 @@ check_funcs(void)
|
||||
CELL *old_f = get_cellptr();
|
||||
/* if (AddrAdjust((ADDR)old_p) != cmp_funcs[i].p) {
|
||||
|
||||
_YAP_Error(SYSTEM_ERROR,TermNil,"bad saved state, comparison function is in wrong place (%p vs %p), system corrupted", AddrAdjust((ADDR)old_p), cmp_funcs[i].p);
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,"bad saved state, comparison function is in wrong place (%p vs %p), system corrupted", AddrAdjust((ADDR)old_p), cmp_funcs[i].p);
|
||||
} */
|
||||
_YAP_cmp_funcs[i].p = (PredEntry *)AddrAdjust((ADDR)old_p);
|
||||
Yap_cmp_funcs[i].p = (PredEntry *)AddrAdjust((ADDR)old_p);
|
||||
out = (out ||
|
||||
old_f != CellPtr(_YAP_cmp_funcs[i].f));
|
||||
old_f != CellPtr(Yap_cmp_funcs[i].f));
|
||||
}
|
||||
}
|
||||
return(out);
|
||||
@ -848,7 +848,7 @@ check_funcs(void)
|
||||
static void
|
||||
get_hash(void)
|
||||
{
|
||||
myread(splfild, _YAP_chtype , NUMBER_OF_CHARS);
|
||||
myread(splfild, Yap_chtype , NUMBER_OF_CHARS);
|
||||
}
|
||||
|
||||
/* Copy all of the old code to the new Heap */
|
||||
@ -858,24 +858,24 @@ CopyCode(void)
|
||||
#if defined(YAPOR) || defined(TABLING)
|
||||
/* skip the local and global data structures */
|
||||
CELL j = get_cell();
|
||||
if (j != Unsigned(&GLOBAL) - Unsigned(_YAP_HeapBase)) {
|
||||
_YAP_Error(FATAL_ERROR,TermNil,"bad saved state, system corrupted");
|
||||
if (j != Unsigned(&GLOBAL) - Unsigned(Yap_HeapBase)) {
|
||||
Yap_Error(FATAL_ERROR,TermNil,"bad saved state, system corrupted");
|
||||
}
|
||||
myread(splfild, (char *) _YAP_HeapBase, j);
|
||||
myread(splfild, (char *) Yap_HeapBase, j);
|
||||
#ifdef USE_HEAP
|
||||
j = get_cell();
|
||||
myread(splfild, (char *) &HashChain, j);
|
||||
#else
|
||||
j = get_cell();
|
||||
if (j != Unsigned(BaseAllocArea) - Unsigned(&HashChain)) {
|
||||
_YAP_Error(FATAL_ERROR,TermNil,"bad saved state, system corrupted");
|
||||
Yap_Error(FATAL_ERROR,TermNil,"bad saved state, system corrupted");
|
||||
}
|
||||
myread(splfild, (char *) &HashChain, j);
|
||||
j = get_cell();
|
||||
myread(splfild, (char *) TopAllocBlockArea, j);
|
||||
#endif
|
||||
#else
|
||||
myread(splfild, (char *) _YAP_HeapBase,
|
||||
myread(splfild, (char *) Yap_HeapBase,
|
||||
(Unsigned(OldHeapTop) - Unsigned(OldHeapBase)));
|
||||
#endif
|
||||
}
|
||||
@ -892,9 +892,9 @@ CopyStacks(void)
|
||||
NewASP = (char *) (Unsigned(ASP) + (Unsigned(LCL0) - Unsigned(OldLCL0)));
|
||||
myread(splfild, (char *) NewASP, j);
|
||||
j = Unsigned(H) - Unsigned(OldGlobalBase);
|
||||
myread(splfild, (char *) _YAP_GlobalBase, j);
|
||||
myread(splfild, (char *) Yap_GlobalBase, j);
|
||||
j = Unsigned(TR) - Unsigned(OldTrailBase);
|
||||
myread(splfild, _YAP_TrailBase, j);
|
||||
myread(splfild, Yap_TrailBase, j);
|
||||
}
|
||||
|
||||
/* Copy the local and global stack and also the trail to their new home */
|
||||
@ -904,7 +904,7 @@ CopyTrailEntries(void)
|
||||
{
|
||||
CELL entry, *Entries;
|
||||
|
||||
Entries = (CELL *)_YAP_TrailBase;
|
||||
Entries = (CELL *)Yap_TrailBase;
|
||||
do {
|
||||
*Entries++ = entry = get_cell();
|
||||
} while ((CODEADDR)entry != NULL);
|
||||
@ -933,7 +933,7 @@ get_coded(int flag, OPCODE old_ops[])
|
||||
/* Check CRC */
|
||||
myread(splfild, my_end_msg, 256);
|
||||
if (strcmp(end_msg,my_end_msg) != 0)
|
||||
_YAP_Error(FATAL_ERROR,TermNil,"bad saved state, system corrupted");
|
||||
Yap_Error(FATAL_ERROR,TermNil,"bad saved state, system corrupted");
|
||||
return(funcs_moved);
|
||||
}
|
||||
|
||||
@ -980,7 +980,7 @@ static void
|
||||
recompute_mask(DBRef dbr)
|
||||
{
|
||||
if (dbr->Flags & DBNoVars) {
|
||||
dbr->Mask = _YAP_EvalMasks((Term) dbr->Entry, &(dbr->Key));
|
||||
dbr->Mask = Yap_EvalMasks((Term) dbr->Entry, &(dbr->Key));
|
||||
} else if (dbr->Flags & DBComplex) {
|
||||
/* This is quite nasty, we want to recalculate the mask but
|
||||
we don't want to rebuild the whole term. We'll just build whatever we
|
||||
@ -1025,7 +1025,7 @@ recompute_mask(DBRef dbr)
|
||||
}
|
||||
x++;
|
||||
}
|
||||
dbr->Mask = _YAP_EvalMasks(out, &(dbr->Key));
|
||||
dbr->Mask = Yap_EvalMasks(out, &(dbr->Key));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1053,11 +1053,11 @@ rehash(CELL *oldcode, int NOfE, int KindOfEntries)
|
||||
basep = H;
|
||||
if (H + (NOfE*2) > ASP) {
|
||||
basep = (CELL *)TR;
|
||||
if (basep + (NOfE*2) > (CELL *)_YAP_TrailTop) {
|
||||
if (!_YAP_growtrail((ADDR)(basep + (NOfE*2))-_YAP_TrailTop)) {
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
if (basep + (NOfE*2) > (CELL *)Yap_TrailTop) {
|
||||
if (!Yap_growtrail((ADDR)(basep + (NOfE*2))-Yap_TrailTop)) {
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"not enough space to restore hash tables for indexing");
|
||||
_YAP_exit(1);
|
||||
Yap_exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1109,7 +1109,7 @@ CCodeAdjust(PredEntry *pe, CODEADDR c)
|
||||
{
|
||||
/* add this code to a list of ccalls that must be adjusted */
|
||||
|
||||
return ((CODEADDR)(_YAP_c_predicates[pe->StateOfPred]));
|
||||
return ((CODEADDR)(Yap_c_predicates[pe->StateOfPred]));
|
||||
}
|
||||
|
||||
static CODEADDR
|
||||
@ -1117,7 +1117,7 @@ NextCCodeAdjust(PredEntry *pe, CODEADDR c)
|
||||
{
|
||||
/* add this code to a list of ccalls that must be adjusted */
|
||||
|
||||
return ((CODEADDR)(_YAP_c_predicates[pe->StateOfPred+1]));
|
||||
return ((CODEADDR)(Yap_c_predicates[pe->StateOfPred+1]));
|
||||
}
|
||||
|
||||
|
||||
@ -1127,11 +1127,11 @@ DirectCCodeAdjust(PredEntry *pe, CODEADDR c)
|
||||
/* add this code to a list of ccalls that must be adjusted */
|
||||
unsigned int i;
|
||||
for (i = 0; i < NumberOfCmpFuncs; i++) {
|
||||
if (_YAP_cmp_funcs[i].p == pe) {
|
||||
return((CODEADDR)(_YAP_cmp_funcs[i].f));
|
||||
if (Yap_cmp_funcs[i].p == pe) {
|
||||
return((CODEADDR)(Yap_cmp_funcs[i].f));
|
||||
}
|
||||
}
|
||||
_YAP_Error(FATAL_ERROR,TermNil,"bad saved state, ccalls corrupted");
|
||||
Yap_Error(FATAL_ERROR,TermNil,"bad saved state, ccalls corrupted");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
@ -1181,7 +1181,7 @@ RestoreForeignCodeStructure(void)
|
||||
static void
|
||||
RestoreIOStructures(void)
|
||||
{
|
||||
_YAP_InitStdStreams();
|
||||
Yap_InitStdStreams();
|
||||
}
|
||||
|
||||
/* restores the list of free space, with its curious structure */
|
||||
@ -1272,7 +1272,7 @@ ShowEntries(pp)
|
||||
PropEntry *pp;
|
||||
{
|
||||
while (!EndOfPAEntr(pp)) {
|
||||
fprintf(_YAP_stderr,"Estou a ver a prop %x em %x\n", pp->KindOfPE, pp);
|
||||
fprintf(Yap_stderr,"Estou a ver a prop %x em %x\n", pp->KindOfPE, pp);
|
||||
pp = RepProp(pp->NextOfPE);
|
||||
}
|
||||
}
|
||||
@ -1287,7 +1287,7 @@ ShowAtoms()
|
||||
AtomEntry *at;
|
||||
at = RepAtom(HashPtr->Entry);
|
||||
do {
|
||||
fprintf(_YAP_stderr,"Passei ao %s em %x\n", at->StrOfAE, at);
|
||||
fprintf(Yap_stderr,"Passei ao %s em %x\n", at->StrOfAE, at);
|
||||
ShowEntries(RepProp(at->PropsOfAE));
|
||||
} while (!EndOfPAEntr(at = RepAtom(at->NextOfAE)));
|
||||
}
|
||||
@ -1305,19 +1305,19 @@ commit_to_saved_state(char *s, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *A
|
||||
|
||||
if ((mode = check_header(Astate,ATrail,AStack,AHeap)) == FAIL_RESTORE)
|
||||
return(FAIL_RESTORE);
|
||||
_YAP_PrologMode = BootMode;
|
||||
if (_YAP_HeapBase) {
|
||||
Yap_PrologMode = BootMode;
|
||||
if (Yap_HeapBase) {
|
||||
if (!yap_flags[HALT_AFTER_CONSULT_FLAG]) {
|
||||
_YAP_TrueFileName(s,_YAP_FileNameBuf2, YAP_FILENAME_MAX);
|
||||
fprintf(_YAP_stderr, "[ Restoring file %s ]\n", _YAP_FileNameBuf2);
|
||||
Yap_TrueFileName(s,Yap_FileNameBuf2, YAP_FILENAME_MAX);
|
||||
fprintf(Yap_stderr, "[ Restoring file %s ]\n", Yap_FileNameBuf2);
|
||||
}
|
||||
_YAP_CloseStreams(TRUE);
|
||||
Yap_CloseStreams(TRUE);
|
||||
}
|
||||
#ifdef DEBUG_RESTORE4
|
||||
/*
|
||||
* This should be another file, like the log file
|
||||
*/
|
||||
errout = _YAP_stderr;
|
||||
errout = Yap_stderr;
|
||||
#endif
|
||||
return(mode);
|
||||
}
|
||||
@ -1339,22 +1339,22 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac
|
||||
{
|
||||
int mode = FAIL_RESTORE;
|
||||
|
||||
_YAP_ErrorMessage = NULL;
|
||||
Yap_ErrorMessage = NULL;
|
||||
if (inpf == NULL)
|
||||
inpf = StartUpFile;
|
||||
if (inpf != NULL && (splfild = open_file(inpf, O_RDONLY)) > 0) {
|
||||
if ((mode = commit_to_saved_state(inpf,Astate,ATrail,AStack,AHeap)) != FAIL_RESTORE)
|
||||
return(mode);
|
||||
}
|
||||
if (!_YAP_dir_separator(inpf[0]) && !_YAP_volume_header(inpf)) {
|
||||
if (!Yap_dir_separator(inpf[0]) && !Yap_volume_header(inpf)) {
|
||||
/*
|
||||
we have a relative path for the file, try to do somewhat better
|
||||
using YAPLIBDIR or friends.
|
||||
*/
|
||||
if (YapLibDir != NULL) {
|
||||
cat_file_name(_YAP_FileNameBuf, Yap_LibDir, inpf, YAP_FILENAME_MAX);
|
||||
if ((splfild = open_file(_YAP_FileNameBuf, O_RDONLY)) > 0) {
|
||||
if ((mode = commit_to_saved_state(_YAP_FileNameBuf,Astate,ATrail,AStack,AHeap)) != FAIL_RESTORE)
|
||||
cat_file_name(Yap_FileNameBuf, Yap_LibDir, inpf, YAP_FILENAME_MAX);
|
||||
if ((splfild = open_file(Yap_FileNameBuf, O_RDONLY)) > 0) {
|
||||
if ((mode = commit_to_saved_state(Yap_FileNameBuf,Astate,ATrail,AStack,AHeap)) != FAIL_RESTORE)
|
||||
return(mode);
|
||||
}
|
||||
}
|
||||
@ -1362,24 +1362,24 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac
|
||||
{
|
||||
char *yap_env = getenv("YAPLIBDIR");
|
||||
if (yap_env != NULL) {
|
||||
cat_file_name(_YAP_FileNameBuf, yap_env, inpf, YAP_FILENAME_MAX);
|
||||
if ((splfild = open_file(_YAP_FileNameBuf, O_RDONLY)) > 0) {
|
||||
if ((mode = commit_to_saved_state(_YAP_FileNameBuf,Astate,ATrail,AStack,AHeap)) != FAIL_RESTORE)
|
||||
cat_file_name(Yap_FileNameBuf, yap_env, inpf, YAP_FILENAME_MAX);
|
||||
if ((splfild = open_file(Yap_FileNameBuf, O_RDONLY)) > 0) {
|
||||
if ((mode = commit_to_saved_state(Yap_FileNameBuf,Astate,ATrail,AStack,AHeap)) != FAIL_RESTORE)
|
||||
return(mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (LIB_DIR != NULL) {
|
||||
cat_file_name(_YAP_FileNameBuf, LIB_DIR, inpf, YAP_FILENAME_MAX);
|
||||
if ((splfild = open_file(_YAP_FileNameBuf, O_RDONLY)) > 0) {
|
||||
if ((mode = commit_to_saved_state(_YAP_FileNameBuf,Astate,ATrail,AStack,AHeap)) != FAIL_RESTORE)
|
||||
cat_file_name(Yap_FileNameBuf, LIB_DIR, inpf, YAP_FILENAME_MAX);
|
||||
if ((splfild = open_file(Yap_FileNameBuf, O_RDONLY)) > 0) {
|
||||
if ((mode = commit_to_saved_state(Yap_FileNameBuf,Astate,ATrail,AStack,AHeap)) != FAIL_RESTORE)
|
||||
return(mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, _YAP_ErrorMessage);
|
||||
_YAP_ErrorMessage = NULL;
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||
Yap_ErrorMessage = NULL;
|
||||
return(FAIL_RESTORE);
|
||||
}
|
||||
|
||||
@ -1390,7 +1390,7 @@ CloseRestore(void)
|
||||
ShowAtoms();
|
||||
#endif
|
||||
close_file();
|
||||
_YAP_PrologMode = UserMode;
|
||||
Yap_PrologMode = UserMode;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1400,7 +1400,7 @@ check_opcodes(OPCODE old_ops[])
|
||||
int have_shifted = FALSE;
|
||||
op_numbers op = _Ystop;
|
||||
for (op = _Ystop; op < _std_top; op++) {
|
||||
if (_YAP_opcode(op) != old_ops[op]) {
|
||||
if (Yap_opcode(op) != old_ops[op]) {
|
||||
have_shifted = TRUE;
|
||||
break;
|
||||
}
|
||||
@ -1414,7 +1414,7 @@ check_opcodes(OPCODE old_ops[])
|
||||
static void
|
||||
RestoreHeap(OPCODE old_ops[], int functions_moved)
|
||||
{
|
||||
int heap_moved = (OldHeapBase != _YAP_HeapBase), opcodes_moved;
|
||||
int heap_moved = (OldHeapBase != Yap_HeapBase), opcodes_moved;
|
||||
|
||||
opcodes_moved = check_opcodes(old_ops);
|
||||
/* opcodes_moved has side-effects and should be tried first */
|
||||
@ -1425,9 +1425,9 @@ RestoreHeap(OPCODE old_ops[], int functions_moved)
|
||||
if (heap_moved) {
|
||||
RestoreFreeSpace();
|
||||
}
|
||||
_YAP_InitAbsmi();
|
||||
if (!(_YAP_ReInitConstExps() && _YAP_ReInitUnaryExps() && _YAP_ReInitBinaryExps()))
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, "arithmetic operator not in saved state");
|
||||
Yap_InitAbsmi();
|
||||
if (!(Yap_ReInitConstExps() && Yap_ReInitUnaryExps() && Yap_ReInitBinaryExps()))
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, "arithmetic operator not in saved state");
|
||||
#ifdef DEBUG_RESTORE1
|
||||
fprintf(errout, "phase 1 done\n");
|
||||
#endif
|
||||
@ -1438,7 +1438,7 @@ RestoreHeap(OPCODE old_ops[], int functions_moved)
|
||||
* state
|
||||
*/
|
||||
int
|
||||
_YAP_SavedInfo(char *FileName, char *YapLibDir, CELL *ATrail, CELL *AStack, CELL *AHeap)
|
||||
Yap_SavedInfo(char *FileName, char *YapLibDir, CELL *ATrail, CELL *AStack, CELL *AHeap)
|
||||
{
|
||||
CELL MyTrail, MyStack, MyHeap, MyState;
|
||||
int mode;
|
||||
@ -1446,7 +1446,7 @@ _YAP_SavedInfo(char *FileName, char *YapLibDir, CELL *ATrail, CELL *AStack, CELL
|
||||
mode = OpenRestore(FileName, YapLibDir, &MyState, &MyTrail, &MyStack, &MyHeap);
|
||||
close_file();
|
||||
if (mode == FAIL_RESTORE) {
|
||||
_YAP_ErrorMessage = NULL;
|
||||
Yap_ErrorMessage = NULL;
|
||||
return(0);
|
||||
}
|
||||
if (! *AHeap)
|
||||
@ -1467,7 +1467,7 @@ UnmarkTrEntries(void)
|
||||
B = (choiceptr)LCL0;
|
||||
B--;
|
||||
B->cp_ap = NOCODE;
|
||||
Entries = (CELL *)_YAP_TrailBase;
|
||||
Entries = (CELL *)Yap_TrailBase;
|
||||
while ((entry = *Entries++) != (CELL)NULL) {
|
||||
if (IsVarTerm(entry)) {
|
||||
RESET_VARIABLE((CELL *)entry);
|
||||
@ -1480,9 +1480,9 @@ UnmarkTrEntries(void)
|
||||
Flags(ent) = flags;
|
||||
if (FlagOn(ErasedMask, flags)) {
|
||||
if (FlagOn(DBClMask, flags)) {
|
||||
_YAP_ErDBE((DBRef) (ent - (CELL) &(((DBRef) NIL)->Flags)));
|
||||
Yap_ErDBE((DBRef) (ent - (CELL) &(((DBRef) NIL)->Flags)));
|
||||
} else {
|
||||
_YAP_ErCl(ClauseFlagsToClause(ent));
|
||||
Yap_ErCl(ClauseFlagsToClause(ent));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1509,7 +1509,7 @@ Restore(char *s, char *lib_dir)
|
||||
CELL MyTrail, MyStack, MyHeap, MyState;
|
||||
if ((restore_mode = OpenRestore(s, lib_dir, &MyState, &MyTrail, &MyStack, &MyHeap)) == FAIL_RESTORE)
|
||||
return(FALSE);
|
||||
_YAP_ShutdownLoadForeign();
|
||||
Yap_ShutdownLoadForeign();
|
||||
in_limbo = TRUE;
|
||||
funcs_moved = get_coded(restore_mode, old_ops);
|
||||
restore_regs(restore_mode);
|
||||
@ -1518,15 +1518,15 @@ Restore(char *s, char *lib_dir)
|
||||
RestoreHeap(old_ops, funcs_moved);
|
||||
switch(restore_mode) {
|
||||
case DO_EVERYTHING:
|
||||
if (OldHeapBase != _YAP_HeapBase ||
|
||||
if (OldHeapBase != Yap_HeapBase ||
|
||||
OldLCL0 != LCL0 ||
|
||||
OldGlobalBase != (CELL *)_YAP_GlobalBase ||
|
||||
OldTrailBase != _YAP_TrailBase) {
|
||||
_YAP_AdjustStacksAndTrail();
|
||||
OldGlobalBase != (CELL *)Yap_GlobalBase ||
|
||||
OldTrailBase != Yap_TrailBase) {
|
||||
Yap_AdjustStacksAndTrail();
|
||||
if (which_save == 2) {
|
||||
_YAP_AdjustRegs(2);
|
||||
Yap_AdjustRegs(2);
|
||||
} else {
|
||||
_YAP_AdjustRegs(1);
|
||||
Yap_AdjustRegs(1);
|
||||
}
|
||||
break;
|
||||
#ifdef DEBUG_RESTORE2
|
||||
@ -1536,22 +1536,22 @@ Restore(char *s, char *lib_dir)
|
||||
break;
|
||||
case DO_ONLY_CODE:
|
||||
UnmarkTrEntries();
|
||||
_YAP_InitYaamRegs();
|
||||
Yap_InitYaamRegs();
|
||||
break;
|
||||
}
|
||||
_YAP_ReOpenLoadForeign();
|
||||
_YAP_InitPlIO();
|
||||
Yap_ReOpenLoadForeign();
|
||||
Yap_InitPlIO();
|
||||
/* reset time */
|
||||
_YAP_ReInitWallTime();
|
||||
Yap_ReInitWallTime();
|
||||
CloseRestore();
|
||||
if (which_save == 2) {
|
||||
_YAP_unify(ARG2, MkIntTerm(0));
|
||||
Yap_unify(ARG2, MkIntTerm(0));
|
||||
}
|
||||
return(restore_mode);
|
||||
}
|
||||
|
||||
int
|
||||
_YAP_Restore(char *s, char *lib_dir)
|
||||
Yap_Restore(char *s, char *lib_dir)
|
||||
{
|
||||
return Restore(s, lib_dir);
|
||||
}
|
||||
@ -1564,29 +1564,29 @@ p_restore(void)
|
||||
Term t1 = Deref(ARG1);
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
if (NOfThreads != 1) {
|
||||
_YAP_Error(SYSTEM_ERROR,TermNil,"cannot perform save: more than a worker/thread running");
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,"cannot perform save: more than a worker/thread running");
|
||||
return(FALSE);
|
||||
}
|
||||
#endif
|
||||
if (!_YAP_GetName(_YAP_FileNameBuf, YAP_FILENAME_MAX, t1)) {
|
||||
_YAP_Error(TYPE_ERROR_LIST,t1,"restore/1");
|
||||
if (!Yap_GetName(Yap_FileNameBuf, YAP_FILENAME_MAX, t1)) {
|
||||
Yap_Error(TYPE_ERROR_LIST,t1,"restore/1");
|
||||
return(FALSE);
|
||||
}
|
||||
if ((mode = Restore(_YAP_FileNameBuf, NULL)) == DO_ONLY_CODE) {
|
||||
if ((mode = Restore(Yap_FileNameBuf, NULL)) == DO_ONLY_CODE) {
|
||||
#if PUSH_REGS
|
||||
restore_absmi_regs(&_YAP_standard_regs);
|
||||
restore_absmi_regs(&Yap_standard_regs);
|
||||
#endif
|
||||
/* back to the top level we go */
|
||||
siglongjmp(_YAP_RestartEnv,3);
|
||||
siglongjmp(Yap_RestartEnv,3);
|
||||
}
|
||||
return(mode != FAIL_RESTORE);
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_InitSavePreds(void)
|
||||
Yap_InitSavePreds(void)
|
||||
{
|
||||
_YAP_InitCPred("$save", 1, p_save, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("$save", 2, p_save2, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("$save_program", 1, p_save_program, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("$restore", 1, p_restore, SyncPredFlag);
|
||||
Yap_InitCPred("$save", 1, p_save, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("$save", 2, p_save2, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("$save_program", 1, p_save_program, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("$restore", 1, p_restore, SyncPredFlag);
|
||||
}
|
||||
|
232
C/scanner.c
232
C/scanner.c
@ -125,7 +125,7 @@ EF,
|
||||
};
|
||||
|
||||
#define chtype (chtype0+1)
|
||||
char *_YAP_chtype = chtype0+1;
|
||||
char *Yap_chtype = chtype0+1;
|
||||
|
||||
static int ch, chbuff, o_ch;
|
||||
|
||||
@ -150,8 +150,8 @@ AllocScannerMemory(unsigned int size)
|
||||
size = AdjustSize(size);
|
||||
TR = (tr_fr_ptr)(AuxSpScan+size);
|
||||
#if !OS_HANDLES_TR_OVERFLOW
|
||||
if (Unsigned(_YAP_TrailTop) == Unsigned(TR)) {
|
||||
if(!_YAP_growtrail (sizeof(CELL) * 16 * 1024L)) {
|
||||
if (Unsigned(Yap_TrailTop) == Unsigned(TR)) {
|
||||
if(!Yap_growtrail (sizeof(CELL) * 16 * 1024L)) {
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
@ -160,7 +160,7 @@ AllocScannerMemory(unsigned int size)
|
||||
}
|
||||
|
||||
char *
|
||||
_YAP_AllocScannerMemory(unsigned int size)
|
||||
Yap_AllocScannerMemory(unsigned int size)
|
||||
{
|
||||
return AllocScannerMemory(size);
|
||||
}
|
||||
@ -182,11 +182,11 @@ my_getch(void)
|
||||
ch = chbuff;
|
||||
}
|
||||
else {
|
||||
ch = (*Nextch) (_YAP_c_input_stream);
|
||||
ch = (*Nextch) (Yap_c_input_stream);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (_YAP_Option[1])
|
||||
fprintf(_YAP_stderr, "[getch %c]", ch);
|
||||
if (Yap_Option[1])
|
||||
fprintf(Yap_stderr, "[getch %c]", ch);
|
||||
#endif
|
||||
return(ch);
|
||||
}
|
||||
@ -200,11 +200,11 @@ my_get_quoted_ch(void)
|
||||
ch = chbuff;
|
||||
}
|
||||
else {
|
||||
ch = (*QuotedNextch) (_YAP_c_input_stream);
|
||||
ch = (*QuotedNextch) (Yap_c_input_stream);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (_YAP_Option[1])
|
||||
fprintf(_YAP_stderr, "[getch %c]",ch);
|
||||
if (Yap_Option[1])
|
||||
fprintf(Yap_stderr, "[getch %c]",ch);
|
||||
#endif
|
||||
return (ch);
|
||||
}
|
||||
@ -218,7 +218,7 @@ float_send(char *s)
|
||||
#if HAVE_FINITE
|
||||
if (yap_flags[LANGUAGE_MODE_FLAG] == 1) { /* iso */
|
||||
if (!finite(f)) {
|
||||
_YAP_ErrorMessage = "Float overflow while scanning";
|
||||
Yap_ErrorMessage = "Float overflow while scanning";
|
||||
return(MkEvalFl(0.0));
|
||||
}
|
||||
}
|
||||
@ -232,10 +232,10 @@ read_int_overflow(const char *s, Int base, Int val)
|
||||
{
|
||||
#ifdef USE_GMP
|
||||
/* try to scan it as a bignum */
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_init_set_str (new, s, base);
|
||||
return(_YAP_MkBigIntTerm(new));
|
||||
return(Yap_MkBigIntTerm(new));
|
||||
#else
|
||||
/* try to scan it as a float */
|
||||
return(MkIntegerTerm(val));
|
||||
@ -264,7 +264,7 @@ get_num(void)
|
||||
}
|
||||
if (ch == '\'') {
|
||||
if (base > 36) {
|
||||
_YAP_ErrorMessage = "Admissible bases are 0..36";
|
||||
Yap_ErrorMessage = "Admissible bases are 0..36";
|
||||
return (TermNil);
|
||||
}
|
||||
might_be_float = FALSE;
|
||||
@ -333,17 +333,17 @@ get_num(void)
|
||||
ascii = so_far*8+(ch-'0');
|
||||
my_get_quoted_ch();
|
||||
if (ch != '\\') {
|
||||
_YAP_ErrorMessage = "invalid octal escape sequence";
|
||||
Yap_ErrorMessage = "invalid octal escape sequence";
|
||||
}
|
||||
} else if (ch == '\\') {
|
||||
ascii = so_far;
|
||||
} else {
|
||||
_YAP_ErrorMessage = "invalid octal escape sequence";
|
||||
Yap_ErrorMessage = "invalid octal escape sequence";
|
||||
}
|
||||
} else if (ch == '\\') {
|
||||
ascii = so_far;
|
||||
} else {
|
||||
_YAP_ErrorMessage = "invalid octal escape sequence";
|
||||
Yap_ErrorMessage = "invalid octal escape sequence";
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -361,12 +361,12 @@ get_num(void)
|
||||
(my_isupper(ch) ? ch - 'A' : ch - 'a') + 10);
|
||||
my_get_quoted_ch();
|
||||
if (ch != '\\') {
|
||||
_YAP_ErrorMessage = "invalid hexadecimal escape sequence";
|
||||
Yap_ErrorMessage = "invalid hexadecimal escape sequence";
|
||||
}
|
||||
} else if (ch == '\\') {
|
||||
ascii = so_far;
|
||||
} else {
|
||||
_YAP_ErrorMessage = "invalid hexadecimal escape sequence";
|
||||
Yap_ErrorMessage = "invalid hexadecimal escape sequence";
|
||||
}
|
||||
} else if (ch == '\\') {
|
||||
ascii = so_far;
|
||||
@ -378,7 +378,7 @@ get_num(void)
|
||||
/* accept sequence. Note that the ISO standard does not
|
||||
consider this sequence legal, whereas SICStus would
|
||||
eat up the escape sequence. */
|
||||
_YAP_ErrorMessage = "invalid escape sequence";
|
||||
Yap_ErrorMessage = "invalid escape sequence";
|
||||
}
|
||||
}
|
||||
/* a quick way to represent ASCII */
|
||||
@ -485,19 +485,19 @@ get_num(void)
|
||||
/* given a function Nxtch scan until we either find the number
|
||||
or end of file */
|
||||
Term
|
||||
_YAP_scan_num(int (*Nxtch) (int))
|
||||
Yap_scan_num(int (*Nxtch) (int))
|
||||
{
|
||||
Term out;
|
||||
int sign = 1;
|
||||
|
||||
Nextch = Nxtch;
|
||||
_YAP_ErrorMessage = NULL;
|
||||
ch = Nextch(_YAP_c_input_stream);
|
||||
Yap_ErrorMessage = NULL;
|
||||
ch = Nextch(Yap_c_input_stream);
|
||||
if (ch == '-') {
|
||||
sign = -1;
|
||||
ch = Nextch(_YAP_c_input_stream);
|
||||
ch = Nextch(Yap_c_input_stream);
|
||||
} else if (ch == '+') {
|
||||
ch = Nextch(_YAP_c_input_stream);
|
||||
ch = Nextch(Yap_c_input_stream);
|
||||
}
|
||||
if (chtype[ch] != NU) {
|
||||
return(TermNil);
|
||||
@ -509,7 +509,7 @@ _YAP_scan_num(int (*Nxtch) (int))
|
||||
else if (IsFloatTerm(out))
|
||||
out = MkFloatTerm(-FloatOfTerm(out));
|
||||
}
|
||||
if (_YAP_ErrorMessage != NULL || ch != -1)
|
||||
if (Yap_ErrorMessage != NULL || ch != -1)
|
||||
return(TermNil);
|
||||
return(out);
|
||||
}
|
||||
@ -523,7 +523,7 @@ token(void)
|
||||
char *charp, *mp;
|
||||
unsigned int len;
|
||||
|
||||
TokImage = ((AtomEntry *) ( _YAP_PreAllocCodeSpace()))->StrOfAE;
|
||||
TokImage = ((AtomEntry *) ( Yap_PreAllocCodeSpace()))->StrOfAE;
|
||||
charp = TokImage;
|
||||
while (chtype[ch] == BS)
|
||||
my_getch();
|
||||
@ -532,10 +532,10 @@ token(void)
|
||||
case CC:
|
||||
while (my_getch() != 10 && chtype[ch] != EF);
|
||||
if (chtype[ch] != EF) {
|
||||
_YAP_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
return (token());
|
||||
} else {
|
||||
_YAP_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
return (eot_tok);
|
||||
}
|
||||
case UC:
|
||||
@ -548,19 +548,19 @@ token(void)
|
||||
*charp++ = '\0';
|
||||
if (!isvar) {
|
||||
/* don't do this in iso */
|
||||
TokenInfo = Unsigned(_YAP_LookupAtom(TokImage));
|
||||
_YAP_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
TokenInfo = Unsigned(Yap_LookupAtom(TokImage));
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
return (Name_tok);
|
||||
}
|
||||
else {
|
||||
TokenInfo = Unsigned(_YAP_LookupVar(TokImage));
|
||||
_YAP_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
TokenInfo = Unsigned(Yap_LookupVar(TokImage));
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
return (Var_tok);
|
||||
}
|
||||
|
||||
case NU:
|
||||
TokenInfo = get_num();
|
||||
_YAP_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
return (Number_tok);
|
||||
|
||||
case QT:
|
||||
@ -570,7 +570,7 @@ token(void)
|
||||
my_get_quoted_ch();
|
||||
while (1) {
|
||||
if (charp + 1024 > (char *)AuxSp) {
|
||||
_YAP_ErrorMessage = "Heap Overflow While Scanning: please increase code space (-h)";
|
||||
Yap_ErrorMessage = "Heap Overflow While Scanning: please increase code space (-h)";
|
||||
break;
|
||||
}
|
||||
if (ch == quote) {
|
||||
@ -651,7 +651,7 @@ token(void)
|
||||
*charp++ = so_far*8+(ch-'0');
|
||||
my_get_quoted_ch();
|
||||
if (ch != '\\') {
|
||||
_YAP_ErrorMessage = "invalid octal escape sequence";
|
||||
Yap_ErrorMessage = "invalid octal escape sequence";
|
||||
} else {
|
||||
my_get_quoted_ch();
|
||||
}
|
||||
@ -659,13 +659,13 @@ token(void)
|
||||
*charp++ = so_far;
|
||||
my_get_quoted_ch();
|
||||
} else {
|
||||
_YAP_ErrorMessage = "invalid octal escape sequence";
|
||||
Yap_ErrorMessage = "invalid octal escape sequence";
|
||||
}
|
||||
} else if (ch == '\\') {
|
||||
*charp++ = so_far;
|
||||
my_get_quoted_ch();
|
||||
} else {
|
||||
_YAP_ErrorMessage = "invalid octal escape sequence";
|
||||
Yap_ErrorMessage = "invalid octal escape sequence";
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -683,7 +683,7 @@ token(void)
|
||||
(my_isupper(ch) ? ch - 'A' : ch - 'a') + 10);
|
||||
my_get_quoted_ch();
|
||||
if (ch != '\\') {
|
||||
_YAP_ErrorMessage = "invalid hexadecimal escape sequence";
|
||||
Yap_ErrorMessage = "invalid hexadecimal escape sequence";
|
||||
} else {
|
||||
my_get_quoted_ch();
|
||||
}
|
||||
@ -691,13 +691,13 @@ token(void)
|
||||
*charp++ = so_far;
|
||||
my_get_quoted_ch();
|
||||
} else {
|
||||
_YAP_ErrorMessage = "invalid hexadecimal escape sequence";
|
||||
Yap_ErrorMessage = "invalid hexadecimal escape sequence";
|
||||
}
|
||||
} else if (ch == '\\') {
|
||||
*charp++ = so_far;
|
||||
my_get_quoted_ch();
|
||||
} else {
|
||||
_YAP_ErrorMessage = "invalid hexadecimal escape sequence";
|
||||
Yap_ErrorMessage = "invalid hexadecimal escape sequence";
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -705,10 +705,10 @@ token(void)
|
||||
/* accept sequence. Note that the ISO standard does not
|
||||
consider this sequence legal, whereas SICStus would
|
||||
eat up the escape sequence. */
|
||||
_YAP_ErrorMessage = "invalid escape sequence";
|
||||
Yap_ErrorMessage = "invalid escape sequence";
|
||||
}
|
||||
} else if (chtype[ch] == EF) {
|
||||
_YAP_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
return (eot_tok);
|
||||
} else {
|
||||
*charp++ = ch;
|
||||
@ -717,9 +717,9 @@ token(void)
|
||||
++len;
|
||||
if (charp > (char *)AuxSp - 1024) {
|
||||
/* Not enough space to read in the string. */
|
||||
_YAP_ErrorMessage = "not enough heap space to read in string or quoted atom";
|
||||
Yap_ErrorMessage = "not enough heap space to read in string or quoted atom";
|
||||
/* serious error now */
|
||||
_YAP_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
return(eot_tok);
|
||||
}
|
||||
}
|
||||
@ -727,18 +727,18 @@ token(void)
|
||||
if (quote == '"') {
|
||||
mp = AllocScannerMemory(len + 1);
|
||||
if (mp == NULL) {
|
||||
_YAP_ErrorMessage = "not enough stack space to read in string or quoted atom";
|
||||
_YAP_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
Yap_ErrorMessage = "not enough stack space to read in string or quoted atom";
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
return(eot_tok);
|
||||
}
|
||||
strcpy(mp, TokImage);
|
||||
TokenInfo = Unsigned(mp);
|
||||
_YAP_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
return (String_tok);
|
||||
}
|
||||
else {
|
||||
TokenInfo = Unsigned(_YAP_LookupAtom(TokImage));
|
||||
_YAP_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
TokenInfo = Unsigned(Yap_LookupAtom(TokImage));
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
return (Name_tok);
|
||||
}
|
||||
|
||||
@ -751,19 +751,19 @@ token(void)
|
||||
my_getch();
|
||||
}
|
||||
if (chtype[ch] == EF) {
|
||||
_YAP_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
return (eot_tok);
|
||||
}
|
||||
my_getch();
|
||||
_YAP_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
return (token());
|
||||
}
|
||||
if (och == '.' && (chtype[ch] == BS || chtype[ch] == EF
|
||||
|| chtype[ch] == CC)) {
|
||||
_YAP_eot_before_eof = TRUE;
|
||||
Yap_eot_before_eof = TRUE;
|
||||
if (chtype[ch] == CC)
|
||||
while (my_getch() != 10 && chtype[ch] != EF);
|
||||
_YAP_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
return (eot_tok);
|
||||
}
|
||||
else {
|
||||
@ -771,8 +771,8 @@ token(void)
|
||||
for (; chtype[ch] == SY; my_getch())
|
||||
*charp++ = ch;
|
||||
*charp = '\0';
|
||||
TokenInfo = Unsigned(_YAP_LookupAtom(TokImage));
|
||||
_YAP_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
TokenInfo = Unsigned(Yap_LookupAtom(TokImage));
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
return (Name_tok);
|
||||
}
|
||||
|
||||
@ -780,8 +780,8 @@ token(void)
|
||||
*charp++ = ch;
|
||||
*charp++ = '\0';
|
||||
my_getch();
|
||||
TokenInfo = Unsigned(_YAP_LookupAtom(TokImage));
|
||||
_YAP_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
TokenInfo = Unsigned(Yap_LookupAtom(TokImage));
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
return (Name_tok);
|
||||
|
||||
case BK:
|
||||
@ -792,44 +792,44 @@ token(void)
|
||||
if (och == '[' && ch == ']') {
|
||||
TokenInfo = Unsigned(AtomNil);
|
||||
my_getch();
|
||||
_YAP_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
return (Name_tok);
|
||||
}
|
||||
else {
|
||||
TokenInfo = och;
|
||||
_YAP_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
return (Ponctuation_tok);
|
||||
}
|
||||
|
||||
case EF:
|
||||
_YAP_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
return (eot_tok);
|
||||
#ifdef DEBUG
|
||||
default:
|
||||
fprintf(_YAP_stderr, "\n++++ token: wrong char type %c %d\n", ch, chtype[ch]);
|
||||
_YAP_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
fprintf(Yap_stderr, "\n++++ token: wrong char type %c %d\n", ch, chtype[ch]);
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
return (eot_tok);
|
||||
#else
|
||||
default:
|
||||
_YAP_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
return (eot_tok); /* Just to make lint happy */
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
TokEntry *
|
||||
_YAP_tokenizer(int (*Nxtch) (int), int (*QuotedNxtch) (int))
|
||||
Yap_tokenizer(int (*Nxtch) (int), int (*QuotedNxtch) (int))
|
||||
{
|
||||
TokEntry *t, *l, *p;
|
||||
enum TokenKinds kind;
|
||||
int solo_flag = TRUE;
|
||||
|
||||
_YAP_ErrorMessage = NULL;
|
||||
_YAP_VarTable = NULL;
|
||||
_YAP_AnonVarTable = NULL;
|
||||
Yap_ErrorMessage = NULL;
|
||||
Yap_VarTable = NULL;
|
||||
Yap_AnonVarTable = NULL;
|
||||
Nextch = Nxtch;
|
||||
QuotedNextch = QuotedNxtch;
|
||||
_YAP_eot_before_eof = FALSE;
|
||||
Yap_eot_before_eof = FALSE;
|
||||
l = NIL;
|
||||
p = NIL; /* Just to make lint happy */
|
||||
ch = ' ';
|
||||
@ -840,7 +840,7 @@ _YAP_tokenizer(int (*Nxtch) (int), int (*QuotedNxtch) (int))
|
||||
do {
|
||||
t = (TokEntry *) AllocScannerMemory(sizeof(TokEntry));
|
||||
if (t == NULL) {
|
||||
_YAP_ErrorMessage = "not enough stack space to read in term";
|
||||
Yap_ErrorMessage = "not enough stack space to read in term";
|
||||
if (p != NIL)
|
||||
p->TokInfo = eot_tok;
|
||||
/* serious error now */
|
||||
@ -860,7 +860,7 @@ _YAP_tokenizer(int (*Nxtch) (int), int (*QuotedNxtch) (int))
|
||||
}
|
||||
t->Tok = Ord(kind);
|
||||
#ifdef DEBUG
|
||||
if(_YAP_Option[2]) fprintf(_YAP_stderr,"[Token %d %ld]",Ord(kind),(unsigned long int)TokenInfo);
|
||||
if(Yap_Option[2]) fprintf(Yap_stderr,"[Token %d %ld]",Ord(kind),(unsigned long int)TokenInfo);
|
||||
#endif
|
||||
t->TokInfo = (Term) TokenInfo;
|
||||
t->TokPos = TokenPos;
|
||||
@ -873,18 +873,18 @@ _YAP_tokenizer(int (*Nxtch) (int), int (*QuotedNxtch) (int))
|
||||
static inline int
|
||||
debug_fgetch(void)
|
||||
{
|
||||
int ch = _YAP_PlFGetchar();
|
||||
if (_YAP_Option[1])
|
||||
fprintf(_YAP_stderr, "[getch %c,%d]", ch,ch);
|
||||
int ch = Yap_PlFGetchar();
|
||||
if (Yap_Option[1])
|
||||
fprintf(Yap_stderr, "[getch %c,%d]", ch,ch);
|
||||
return (ch);
|
||||
}
|
||||
#define my_fgetch() (ch = debug_fgetch())
|
||||
#else
|
||||
#define my_fgetch() (ch = _YAP_PlFGetchar())
|
||||
#define my_fgetch() (ch = Yap_PlFGetchar())
|
||||
#endif
|
||||
|
||||
TokEntry *
|
||||
_YAP_fast_tokenizer(void)
|
||||
Yap_fast_tokenizer(void)
|
||||
{
|
||||
/* I hope, a compressed version of the last
|
||||
* three files */
|
||||
@ -894,10 +894,10 @@ _YAP_fast_tokenizer(void)
|
||||
register int ch, och;
|
||||
int solo_flag = TRUE;
|
||||
|
||||
_YAP_ErrorMessage = NULL;
|
||||
_YAP_VarTable = NULL;
|
||||
_YAP_AnonVarTable = NULL;
|
||||
_YAP_eot_before_eof = FALSE;
|
||||
Yap_ErrorMessage = NULL;
|
||||
Yap_VarTable = NULL;
|
||||
Yap_AnonVarTable = NULL;
|
||||
Yap_eot_before_eof = FALSE;
|
||||
l = NIL;
|
||||
p = NIL; /* Just to make lint happy */
|
||||
my_fgetch();
|
||||
@ -908,7 +908,7 @@ _YAP_fast_tokenizer(void)
|
||||
do {
|
||||
t = (TokEntry *) AllocScannerMemory(sizeof(TokEntry));
|
||||
if (t == NULL) {
|
||||
_YAP_ErrorMessage = "not enough stack space to read in term";
|
||||
Yap_ErrorMessage = "not enough stack space to read in term";
|
||||
if (p != NIL)
|
||||
p->TokInfo = eot_tok;
|
||||
/* serious error now */
|
||||
@ -928,7 +928,7 @@ _YAP_fast_tokenizer(void)
|
||||
|
||||
get_tok:
|
||||
|
||||
charp = TokImage = ((AtomEntry *) ( _YAP_PreAllocCodeSpace()))->StrOfAE;
|
||||
charp = TokImage = ((AtomEntry *) ( Yap_PreAllocCodeSpace()))->StrOfAE;
|
||||
while (chtype[ch] == BS)
|
||||
my_fgetch();
|
||||
TokenPos = GetCurInpPos();
|
||||
@ -937,7 +937,7 @@ _YAP_fast_tokenizer(void)
|
||||
while (my_fgetch() != 10 && chtype[ch] != EF);
|
||||
if (chtype[ch] != EF) {
|
||||
my_fgetch();
|
||||
_YAP_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
goto get_tok;
|
||||
}
|
||||
else
|
||||
@ -955,13 +955,13 @@ _YAP_fast_tokenizer(void)
|
||||
*charp++ = ch;
|
||||
*charp++ = '\0';
|
||||
if (!isvar) {
|
||||
TokenInfo = Unsigned(_YAP_LookupAtom(TokImage));
|
||||
TokenInfo = Unsigned(Yap_LookupAtom(TokImage));
|
||||
if (ch == '(')
|
||||
solo_flag = FALSE;
|
||||
kind = Name_tok;
|
||||
}
|
||||
else {
|
||||
TokenInfo = Unsigned(_YAP_LookupVar(TokImage));
|
||||
TokenInfo = Unsigned(Yap_LookupVar(TokImage));
|
||||
kind = Var_tok;
|
||||
}
|
||||
break;
|
||||
@ -1056,17 +1056,17 @@ _YAP_fast_tokenizer(void)
|
||||
ascii = so_far*8+(ch-'0');
|
||||
my_fgetch();
|
||||
if (ch != '\\') {
|
||||
_YAP_ErrorMessage = "invalid octal escape sequence";
|
||||
Yap_ErrorMessage = "invalid octal escape sequence";
|
||||
}
|
||||
} else if (ch == '\\') {
|
||||
ascii = so_far;
|
||||
} else {
|
||||
_YAP_ErrorMessage = "invalid octal escape sequence";
|
||||
Yap_ErrorMessage = "invalid octal escape sequence";
|
||||
}
|
||||
} else if (ch == '\\') {
|
||||
ascii = so_far;
|
||||
} else {
|
||||
_YAP_ErrorMessage = "invalid octal escape sequence";
|
||||
Yap_ErrorMessage = "invalid octal escape sequence";
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1084,18 +1084,18 @@ _YAP_fast_tokenizer(void)
|
||||
(my_isupper(ch) ? ch - 'A' : ch - 'a') + 10);
|
||||
my_fgetch();
|
||||
if (ch != '\\') {
|
||||
_YAP_ErrorMessage = "invalid hexadecimal escape sequence";
|
||||
Yap_ErrorMessage = "invalid hexadecimal escape sequence";
|
||||
}
|
||||
} else if (ch == '\\') {
|
||||
ascii = so_far;
|
||||
} else {
|
||||
_YAP_ErrorMessage = "invalid hexadecimal escape sequence";
|
||||
Yap_ErrorMessage = "invalid hexadecimal escape sequence";
|
||||
}
|
||||
} else if (ch == '\\') {
|
||||
ascii = so_far;
|
||||
my_fgetch();
|
||||
} else {
|
||||
_YAP_ErrorMessage = "invalid hexadecimal escape sequence";
|
||||
Yap_ErrorMessage = "invalid hexadecimal escape sequence";
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1103,7 +1103,7 @@ _YAP_fast_tokenizer(void)
|
||||
/* accept sequence. Note that the ISO standard does not
|
||||
consider this sequence legal, whereas SICStus would
|
||||
eat up the escape sequence. */
|
||||
_YAP_ErrorMessage = "invalid escape sequence";
|
||||
Yap_ErrorMessage = "invalid escape sequence";
|
||||
}
|
||||
}
|
||||
my_fgetch();
|
||||
@ -1170,9 +1170,9 @@ _YAP_fast_tokenizer(void)
|
||||
t->Tok = Ord(Number_tok);
|
||||
#ifdef DEBUG
|
||||
/*
|
||||
* if(_YAP_Option[2
|
||||
* if(Yap_Option[2
|
||||
* ])
|
||||
* fprintf(_YAP_stderr,"[To
|
||||
* fprintf(Yap_stderr,"[To
|
||||
* ken %d
|
||||
* %d]",Ord(ki
|
||||
* nd),TokenIn
|
||||
@ -1186,11 +1186,11 @@ _YAP_fast_tokenizer(void)
|
||||
t->TokPos = TokenPos;
|
||||
t = (TokEntry *) AllocScannerMemory(sizeof(TokEntry));
|
||||
if (t == NULL) {
|
||||
_YAP_ErrorMessage = "not enough stack space to read in term";
|
||||
Yap_ErrorMessage = "not enough stack space to read in term";
|
||||
if (p != NIL)
|
||||
p->TokInfo = eot_tok;
|
||||
/* serious error now */
|
||||
_YAP_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
return(l);
|
||||
}
|
||||
|
||||
@ -1241,11 +1241,11 @@ _YAP_fast_tokenizer(void)
|
||||
t =
|
||||
(TokEntry *) AllocScannerMemory(sizeof(TokEntry));
|
||||
if (t == NULL) {
|
||||
_YAP_ErrorMessage = "not enough stack space to read in term";
|
||||
Yap_ErrorMessage = "not enough stack space to read in term";
|
||||
if (p != NIL)
|
||||
p->TokInfo = eot_tok;
|
||||
/* serious error now */
|
||||
_YAP_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
return(l);
|
||||
}
|
||||
|
||||
@ -1305,7 +1305,7 @@ _YAP_fast_tokenizer(void)
|
||||
my_fgetch();
|
||||
while (1) {
|
||||
if (charp + 1024 > (char *)AuxSp) {
|
||||
_YAP_ErrorMessage = "Heap Overflow While Scanning: please increase code space (-h)";
|
||||
Yap_ErrorMessage = "Heap Overflow While Scanning: please increase code space (-h)";
|
||||
break;
|
||||
}
|
||||
if (ch == quote) {
|
||||
@ -1385,7 +1385,7 @@ _YAP_fast_tokenizer(void)
|
||||
*charp++ = so_far*8+(ch-'0');
|
||||
my_fgetch();
|
||||
if (ch != '\\') {
|
||||
_YAP_ErrorMessage = "invalid octal escape sequence";
|
||||
Yap_ErrorMessage = "invalid octal escape sequence";
|
||||
} else {
|
||||
my_fgetch();
|
||||
}
|
||||
@ -1393,13 +1393,13 @@ _YAP_fast_tokenizer(void)
|
||||
*charp++ = so_far;
|
||||
my_fgetch();
|
||||
} else {
|
||||
_YAP_ErrorMessage = "invalid octal escape sequence";
|
||||
Yap_ErrorMessage = "invalid octal escape sequence";
|
||||
}
|
||||
} else if (ch == '\\') {
|
||||
*charp++ = so_far;
|
||||
my_fgetch();
|
||||
} else {
|
||||
_YAP_ErrorMessage = "invalid octal escape sequence";
|
||||
Yap_ErrorMessage = "invalid octal escape sequence";
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1417,7 +1417,7 @@ _YAP_fast_tokenizer(void)
|
||||
(my_isupper(ch) ? ch - 'A' : ch - 'a') + 10);
|
||||
my_fgetch();
|
||||
if (ch != '\\') {
|
||||
_YAP_ErrorMessage = "invalid hexadecimal escape sequence";
|
||||
Yap_ErrorMessage = "invalid hexadecimal escape sequence";
|
||||
} else {
|
||||
my_fgetch();
|
||||
}
|
||||
@ -1425,13 +1425,13 @@ _YAP_fast_tokenizer(void)
|
||||
*charp++ = so_far;
|
||||
my_fgetch();
|
||||
} else {
|
||||
_YAP_ErrorMessage = "invalid hexadecimal escape sequence";
|
||||
Yap_ErrorMessage = "invalid hexadecimal escape sequence";
|
||||
}
|
||||
} else if (ch == '\\') {
|
||||
*charp++ = so_far;
|
||||
my_fgetch();
|
||||
} else {
|
||||
_YAP_ErrorMessage = "invalid hexadecimal escape sequence";
|
||||
Yap_ErrorMessage = "invalid hexadecimal escape sequence";
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1439,7 +1439,7 @@ _YAP_fast_tokenizer(void)
|
||||
/* accept sequence. Note that the ISO standard does not
|
||||
consider this sequence legal, whereas SICStus would
|
||||
eat up the escape sequence. */
|
||||
_YAP_ErrorMessage = "invalid escape sequence";
|
||||
Yap_ErrorMessage = "invalid escape sequence";
|
||||
}
|
||||
} else {
|
||||
*charp++ = ch;
|
||||
@ -1452,7 +1452,7 @@ _YAP_fast_tokenizer(void)
|
||||
++len;
|
||||
if (charp > (char *)AuxSp - 1024) {
|
||||
/* Not enough space to read in the string. */
|
||||
_YAP_ErrorMessage = "not enough heap space to read in string or quoted atom";
|
||||
Yap_ErrorMessage = "not enough heap space to read in string or quoted atom";
|
||||
/* serious error now */
|
||||
kind = eot_tok;
|
||||
}
|
||||
@ -1461,7 +1461,7 @@ _YAP_fast_tokenizer(void)
|
||||
if (quote == '"') {
|
||||
mp = AllocScannerMemory(len + 1);
|
||||
if (mp == NULL) {
|
||||
_YAP_ErrorMessage = "not enough stack space to read in string or quoted atom";
|
||||
Yap_ErrorMessage = "not enough stack space to read in string or quoted atom";
|
||||
/* serious error now */
|
||||
kind = eot_tok;
|
||||
}
|
||||
@ -1470,7 +1470,7 @@ _YAP_fast_tokenizer(void)
|
||||
kind = String_tok;
|
||||
}
|
||||
else {
|
||||
TokenInfo = Unsigned(_YAP_LookupAtom(TokImage));
|
||||
TokenInfo = Unsigned(Yap_LookupAtom(TokImage));
|
||||
if (ch == '(')
|
||||
solo_flag = FALSE;
|
||||
kind = Name_tok;
|
||||
@ -1491,12 +1491,12 @@ _YAP_fast_tokenizer(void)
|
||||
break;
|
||||
}
|
||||
my_fgetch();
|
||||
_YAP_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
goto get_tok;
|
||||
}
|
||||
if (och == '.' && (chtype[ch] == BS || chtype[ch] == EF
|
||||
|| chtype[ch] == CC)) {
|
||||
_YAP_eot_before_eof = TRUE;
|
||||
Yap_eot_before_eof = TRUE;
|
||||
if (chtype[ch] == CC)
|
||||
while (my_fgetch() != 10 && chtype[ch] != EF);
|
||||
kind = eot_tok;
|
||||
@ -1506,7 +1506,7 @@ _YAP_fast_tokenizer(void)
|
||||
for (; chtype[ch] == SY; my_fgetch())
|
||||
*charp++ = ch;
|
||||
*charp = '\0';
|
||||
TokenInfo = Unsigned(_YAP_LookupAtom(TokImage));
|
||||
TokenInfo = Unsigned(Yap_LookupAtom(TokImage));
|
||||
if (ch == '(')
|
||||
solo_flag = FALSE;
|
||||
kind = Name_tok;
|
||||
@ -1517,7 +1517,7 @@ _YAP_fast_tokenizer(void)
|
||||
*charp++ = ch;
|
||||
*charp++ = '\0';
|
||||
my_fgetch();
|
||||
TokenInfo = Unsigned(_YAP_LookupAtom(TokImage));
|
||||
TokenInfo = Unsigned(Yap_LookupAtom(TokImage));
|
||||
if (ch == '(')
|
||||
solo_flag = FALSE;
|
||||
kind = Name_tok;
|
||||
@ -1552,7 +1552,7 @@ _YAP_fast_tokenizer(void)
|
||||
break;
|
||||
#ifdef DEBUG
|
||||
default:
|
||||
fprintf(_YAP_stderr, "\n++++ token: wrong char type %c %d\n", ch, chtype[ch]);
|
||||
fprintf(Yap_stderr, "\n++++ token: wrong char type %c %d\n", ch, chtype[ch]);
|
||||
kind = eot_tok;
|
||||
#else
|
||||
default:
|
||||
@ -1563,12 +1563,12 @@ _YAP_fast_tokenizer(void)
|
||||
|
||||
t->Tok = Ord(kind);
|
||||
#ifdef DEBUG
|
||||
if(_YAP_Option[2]) fprintf(_YAP_stderr,"[Token %d %ld]\n",Ord(kind),(unsigned long int)TokenInfo);
|
||||
if(Yap_Option[2]) fprintf(Yap_stderr,"[Token %d %ld]\n",Ord(kind),(unsigned long int)TokenInfo);
|
||||
#endif
|
||||
t->TokInfo = (Term) TokenInfo;
|
||||
t->TokPos = TokenPos;
|
||||
t->TokNext = NIL;
|
||||
_YAP_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
} while (kind != eot_tok);
|
||||
return (l);
|
||||
}
|
||||
|
38
C/sort.c
38
C/sort.c
@ -58,8 +58,8 @@ build_new_list(CELL *pt, Term t)
|
||||
}
|
||||
pt += 2;
|
||||
if (pt > ASP - 4096) {
|
||||
if (!_YAP_gc(2, ENV, P)) {
|
||||
_YAP_Error(OUT_OF_STACK_ERROR, TermNil, _YAP_ErrorMessage);
|
||||
if (!Yap_gc(2, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
}
|
||||
t = Deref(ARG1);
|
||||
@ -101,7 +101,7 @@ void simple_mergesort(CELL *pt, Int size, int my_p)
|
||||
/* while there are elements in the left or right vector do compares */
|
||||
while (pt_left < end_pt_left && pt_right < end_pt) {
|
||||
/* if the element to the left is larger than the one to the right */
|
||||
if (_YAP_compare_terms(pt_left[0], pt_right[0]) <= 0) {
|
||||
if (Yap_compare_terms(pt_left[0], pt_right[0]) <= 0) {
|
||||
/* copy the one to the left */
|
||||
pt[0] = pt_left[0];
|
||||
/* and avance the two pointers */
|
||||
@ -130,7 +130,7 @@ void simple_mergesort(CELL *pt, Int size, int my_p)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (size > 1 && (_YAP_compare_terms(pt[0],pt[2]) > 0)) {
|
||||
if (size > 1 && (Yap_compare_terms(pt[0],pt[2]) > 0)) {
|
||||
CELL t = pt[2];
|
||||
pt[2+my_p] = pt[0];
|
||||
pt[my_p] = t;
|
||||
@ -181,7 +181,7 @@ int key_mergesort(CELL *pt, Int size, int my_p, Functor FuncDMinus)
|
||||
if (IsVarTerm(t1) || !IsApplTerm(t1) || FunctorOfTerm(t1) != FuncDMinus)
|
||||
return(FALSE);
|
||||
t1 = ArgOfTerm(1,t1);
|
||||
if (_YAP_compare_terms(t0, t1) <= 0) {
|
||||
if (Yap_compare_terms(t0, t1) <= 0) {
|
||||
/* copy the one to the left */
|
||||
pt[0] = pt_left[0];
|
||||
/* and avance the two pointers */
|
||||
@ -218,7 +218,7 @@ int key_mergesort(CELL *pt, Int size, int my_p, Functor FuncDMinus)
|
||||
if (IsVarTerm(t1) || !IsApplTerm(t1) || FunctorOfTerm(t1) != FuncDMinus)
|
||||
return(FALSE);
|
||||
t1 = ArgOfTerm(1,t1);
|
||||
if (_YAP_compare_terms(t0,t1) > 0) {
|
||||
if (Yap_compare_terms(t0,t1) > 0) {
|
||||
CELL t = pt[2];
|
||||
pt[2+my_p] = pt[0];
|
||||
pt[my_p] = t;
|
||||
@ -266,7 +266,7 @@ Int compact_mergesort(CELL *pt, Int size, int my_p)
|
||||
/* while there are elements in the left or right vector do compares */
|
||||
while (pt_left < end_pt_left && pt_right < end_pt_right) {
|
||||
/* if the element to the left is larger than the one to the right */
|
||||
Int cmp = _YAP_compare_terms(pt_left[0], pt_right[0]);
|
||||
Int cmp = Yap_compare_terms(pt_left[0], pt_right[0]);
|
||||
if (cmp < 0) {
|
||||
/* copy the one to the left */
|
||||
pt[0] = pt_left[0];
|
||||
@ -302,7 +302,7 @@ Int compact_mergesort(CELL *pt, Int size, int my_p)
|
||||
}
|
||||
return(size);
|
||||
} else if (size == 2) {
|
||||
Int cmp = _YAP_compare_terms(pt[0],pt[2]);
|
||||
Int cmp = Yap_compare_terms(pt[0],pt[2]);
|
||||
if (cmp > 0) {
|
||||
/* swap */
|
||||
CELL t = pt[2];
|
||||
@ -354,7 +354,7 @@ p_sort(void)
|
||||
if (size < 0)
|
||||
return(FALSE);
|
||||
if (size < 2)
|
||||
return(_YAP_unify(ARG1, ARG2));
|
||||
return(Yap_unify(ARG1, ARG2));
|
||||
pt = H; /* because of possible garbage collection */
|
||||
/* make sure no one writes on our temp data structure */
|
||||
H += size*2;
|
||||
@ -364,7 +364,7 @@ p_sort(void)
|
||||
H = pt+size*2;
|
||||
adjust_vector(pt, size);
|
||||
out = AbsPair(pt);
|
||||
return(_YAP_unify(out, ARG2));
|
||||
return(Yap_unify(out, ARG2));
|
||||
}
|
||||
|
||||
static Int
|
||||
@ -379,14 +379,14 @@ p_msort(void)
|
||||
if (size < 0)
|
||||
return(FALSE);
|
||||
if (size < 2)
|
||||
return(_YAP_unify(ARG1, ARG2));
|
||||
return(Yap_unify(ARG1, ARG2));
|
||||
pt = H; /* because of possible garbage collection */
|
||||
/* reserve the necessary space */
|
||||
H += size*2;
|
||||
simple_mergesort(pt, size, M_EVEN);
|
||||
adjust_vector(pt, size);
|
||||
out = AbsPair(pt);
|
||||
return(_YAP_unify(out, ARG2));
|
||||
return(Yap_unify(out, ARG2));
|
||||
}
|
||||
|
||||
static Int
|
||||
@ -401,21 +401,21 @@ p_ksort(void)
|
||||
if (size < 0)
|
||||
return(FALSE);
|
||||
if (size < 2)
|
||||
return(_YAP_unify(ARG1, ARG2));
|
||||
return(Yap_unify(ARG1, ARG2));
|
||||
/* reserve the necessary space */
|
||||
pt = H; /* because of possible garbage collection */
|
||||
H += size*2;
|
||||
if (!key_mergesort(pt, size, M_EVEN, _YAP_MkFunctor(AtomMinus,2)))
|
||||
if (!key_mergesort(pt, size, M_EVEN, Yap_MkFunctor(AtomMinus,2)))
|
||||
return(FALSE);
|
||||
adjust_vector(pt, size);
|
||||
out = AbsPair(pt);
|
||||
return(_YAP_unify(out, ARG2));
|
||||
return(Yap_unify(out, ARG2));
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_InitSortPreds(void)
|
||||
Yap_InitSortPreds(void)
|
||||
{
|
||||
_YAP_InitCPred("$sort", 2, p_sort, 0);
|
||||
_YAP_InitCPred("$msort", 2, p_msort, 0);
|
||||
_YAP_InitCPred("$keysort", 2, p_ksort, 0);
|
||||
Yap_InitCPred("$sort", 2, p_sort, 0);
|
||||
Yap_InitCPred("$msort", 2, p_msort, 0);
|
||||
Yap_InitCPred("$keysort", 2, p_ksort, 0);
|
||||
}
|
||||
|
790
C/stdpreds.c
790
C/stdpreds.c
File diff suppressed because it is too large
Load Diff
392
C/sysbits.c
392
C/sysbits.c
File diff suppressed because it is too large
Load Diff
46
C/tracer.c
46
C/tracer.c
@ -32,7 +32,7 @@ static int do_trace_primitives = TRUE;
|
||||
static int
|
||||
TracePutchar(int sno, int ch)
|
||||
{
|
||||
return(putc(ch, _YAP_stderr)); /* use standard error stream, which is supposed to be 2*/
|
||||
return(putc(ch, Yap_stderr)); /* use standard error stream, which is supposed to be 2*/
|
||||
}
|
||||
|
||||
static void
|
||||
@ -40,35 +40,35 @@ send_tracer_message(char *start, char *name, Int arity, char *mname, CELL *args)
|
||||
{
|
||||
if (name == NULL) {
|
||||
#ifdef YAPOR
|
||||
fprintf(_YAP_stderr, "(%d)%s", worker_id, start);
|
||||
fprintf(Yap_stderr, "(%d)%s", worker_id, start);
|
||||
#else
|
||||
fprintf(_YAP_stderr, "%s", start);
|
||||
fprintf(Yap_stderr, "%s", start);
|
||||
#endif
|
||||
} else {
|
||||
int i;
|
||||
|
||||
if (arity) {
|
||||
fprintf(_YAP_stderr, "%s %s:%s(", start, mname, name);
|
||||
fprintf(Yap_stderr, "%s %s:%s(", start, mname, name);
|
||||
} else {
|
||||
fprintf(_YAP_stderr, "%s %s:%s", start, mname, name);
|
||||
fprintf(Yap_stderr, "%s %s:%s", start, mname, name);
|
||||
}
|
||||
for (i= 0; i < arity; i++) {
|
||||
if (i > 0) fprintf(_YAP_stderr, ",");
|
||||
if (i > 0) fprintf(Yap_stderr, ",");
|
||||
#if DEBUG
|
||||
#if COROUTINING
|
||||
_YAP_Portray_delays = TRUE;
|
||||
Yap_Portray_delays = TRUE;
|
||||
#endif
|
||||
#endif
|
||||
_YAP_plwrite(args[i], TracePutchar, Handle_vars_f);
|
||||
Yap_plwrite(args[i], TracePutchar, Handle_vars_f);
|
||||
#if DEBUG
|
||||
#if COROUTINING
|
||||
_YAP_Portray_delays = FALSE;
|
||||
Yap_Portray_delays = FALSE;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
if (arity) fprintf(_YAP_stderr, ")");
|
||||
if (arity) fprintf(Yap_stderr, ")");
|
||||
}
|
||||
fprintf(_YAP_stderr, "\n");
|
||||
fprintf(Yap_stderr, "\n");
|
||||
}
|
||||
|
||||
#if defined(__GNUC__)
|
||||
@ -81,7 +81,7 @@ unsigned long vsc_count;
|
||||
static int
|
||||
check_trail_consistency(void) {
|
||||
tr_fr_ptr ptr = TR;
|
||||
while (ptr > (CELL *)_YAP_TrailBase) {
|
||||
while (ptr > (CELL *)Yap_TrailBase) {
|
||||
ptr = --ptr;
|
||||
if (!IsVarTerm(TrailTerm(ptr))) {
|
||||
if (IsApplTerm(TrailTerm(ptr))) {
|
||||
@ -119,7 +119,7 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
||||
/* if (vsc_count > 500000) exit(0); */
|
||||
/* if (gc_calls < 1) return; */
|
||||
#if defined(__GNUC__)
|
||||
fprintf(_YAP_stderr,"%llu ", vsc_count);
|
||||
fprintf(Yap_stderr,"%llu ", vsc_count);
|
||||
#endif
|
||||
/* check_trail_consistency(); */
|
||||
if (pred == NULL) {
|
||||
@ -130,7 +130,7 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
||||
}
|
||||
switch (port) {
|
||||
case enter_pred:
|
||||
mname = RepAtom(AtomOfTerm(_YAP_Module_Name((CODEADDR)pred)))->StrOfAE;
|
||||
mname = RepAtom(AtomOfTerm(Yap_Module_Name((CODEADDR)pred)))->StrOfAE;
|
||||
arity = pred->ArityOfPE;
|
||||
if (arity == 0)
|
||||
s = RepAtom((Atom)pred->FunctorOfPred)->StrOfAE;
|
||||
@ -153,7 +153,7 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
||||
if (pred == NULL) {
|
||||
send_tracer_message("RETRY TABLE: ", NULL, 0, NULL, args);
|
||||
} else {
|
||||
mname = RepAtom(AtomOfTerm(_YAP_Module_Name((CODEADDR)pred)))->StrOfAE;
|
||||
mname = RepAtom(AtomOfTerm(Yap_Module_Name((CODEADDR)pred)))->StrOfAE;
|
||||
arity = pred->ArityOfPE;
|
||||
if (arity == 0)
|
||||
s = RepAtom((Atom)pred->FunctorOfPred)->StrOfAE;
|
||||
@ -170,7 +170,7 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
||||
if (pred == NULL) {
|
||||
send_tracer_message("RETRY TABLE: ", NULL, 0, NULL, args);
|
||||
} else {
|
||||
mname = RepAtom(AtomOfTerm(_YAP_Module_Name((CODEADDR)pred)))->StrOfAE;
|
||||
mname = RepAtom(AtomOfTerm(Yap_Module_Name((CODEADDR)pred)))->StrOfAE;
|
||||
arity = pred->ArityOfPE;
|
||||
if (arity == 0)
|
||||
s = RepAtom((Atom)pred->FunctorOfPred)->StrOfAE;
|
||||
@ -182,7 +182,7 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
||||
}
|
||||
break;
|
||||
case retry_pred:
|
||||
mname = RepAtom(AtomOfTerm(_YAP_Module_Name((CODEADDR)pred)))->StrOfAE;
|
||||
mname = RepAtom(AtomOfTerm(Yap_Module_Name((CODEADDR)pred)))->StrOfAE;
|
||||
arity = pred->ArityOfPE;
|
||||
if (arity == 0)
|
||||
s = RepAtom((Atom)pred->FunctorOfPred)->StrOfAE;
|
||||
@ -199,27 +199,27 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
||||
void
|
||||
toggle_low_level_trace(void)
|
||||
{
|
||||
_YAP_do_low_level_trace = !_YAP_do_low_level_trace;
|
||||
Yap_do_low_level_trace = !Yap_do_low_level_trace;
|
||||
}
|
||||
|
||||
static Int p_start_low_level_trace(void)
|
||||
{
|
||||
_YAP_do_low_level_trace = TRUE;
|
||||
Yap_do_low_level_trace = TRUE;
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
static Int p_stop_low_level_trace(void)
|
||||
{
|
||||
_YAP_do_low_level_trace = FALSE;
|
||||
Yap_do_low_level_trace = FALSE;
|
||||
do_trace_primitives = TRUE;
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_InitLowLevelTrace(void)
|
||||
Yap_InitLowLevelTrace(void)
|
||||
{
|
||||
_YAP_InitCPred("start_low_level_trace", 0, p_start_low_level_trace, SafePredFlag);
|
||||
_YAP_InitCPred("stop_low_level_trace", 0, p_stop_low_level_trace, SafePredFlag);
|
||||
Yap_InitCPred("start_low_level_trace", 0, p_start_low_level_trace, SafePredFlag);
|
||||
Yap_InitCPred("stop_low_level_trace", 0, p_stop_low_level_trace, SafePredFlag);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
62
C/unify.c
62
C/unify.c
@ -199,7 +199,7 @@ OCUnify_complex(register CELL *pt0, register CELL *pt0_end,
|
||||
goto cufail;
|
||||
#ifdef USE_GMP
|
||||
case (CELL)FunctorBigInt:
|
||||
if (mpz_cmp(_YAP_BigIntOfTerm(d0),_YAP_BigIntOfTerm(d1)) == 0) continue;
|
||||
if (mpz_cmp(Yap_BigIntOfTerm(d0),Yap_BigIntOfTerm(d1)) == 0) continue;
|
||||
goto cufail;
|
||||
#endif /* USE_GMP */
|
||||
default:
|
||||
@ -233,7 +233,7 @@ OCUnify_complex(register CELL *pt0, register CELL *pt0_end,
|
||||
BIND_GLOBAL(ptd1, d0, bind_ocunify1);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(ptd1, d0);
|
||||
if (ptd1 < H0) _YAP_WakeUp(ptd1);
|
||||
if (ptd1 < H0) Yap_WakeUp(ptd1);
|
||||
bind_ocunify1:
|
||||
#endif
|
||||
if (rational_tree_loop(ptd1-1, ptd1, to_visit))
|
||||
@ -255,7 +255,7 @@ OCUnify_complex(register CELL *pt0, register CELL *pt0_end,
|
||||
BIND_GLOBAL(ptd0, d1, bind_ocunify2);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(ptd0, d1);
|
||||
if (ptd0 < H0) _YAP_WakeUp(ptd0);
|
||||
if (ptd0 < H0) Yap_WakeUp(ptd0);
|
||||
bind_ocunify2:
|
||||
#endif
|
||||
if (rational_tree_loop(ptd0-1, ptd0, to_visit))
|
||||
@ -294,7 +294,7 @@ cufail:
|
||||
return (FALSE);
|
||||
#if SHADOW_REGS
|
||||
#if defined(B) || defined(TR)
|
||||
#undef _YAP_REGS
|
||||
#undef Yap_REGS
|
||||
#endif /* defined(B) || defined(TR) */
|
||||
#endif
|
||||
}
|
||||
@ -350,7 +350,7 @@ oc_unify_nvar_nvar:
|
||||
return(FloatOfTerm(AbsAppl(pt0)) == FloatOfTerm(AbsAppl(pt1)));
|
||||
#ifdef USE_GMP
|
||||
case (CELL)FunctorBigInt:
|
||||
return(mpz_cmp(_YAP_BigIntOfTerm(AbsAppl(pt0)),_YAP_BigIntOfTerm(AbsAppl(pt0))) == 0);
|
||||
return(mpz_cmp(Yap_BigIntOfTerm(AbsAppl(pt0)),Yap_BigIntOfTerm(AbsAppl(pt0))) == 0);
|
||||
#endif /* USE_GMP */
|
||||
default:
|
||||
return(FALSE);
|
||||
@ -368,7 +368,7 @@ oc_unify_nvar_nvar:
|
||||
BIND(pt1, d0, bind_ocunify4);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(pt1, d0);
|
||||
if (pt1 < H0) _YAP_WakeUp(pt1);
|
||||
if (pt1 < H0) Yap_WakeUp(pt1);
|
||||
bind_ocunify4:
|
||||
#endif
|
||||
if (rational_tree(d0))
|
||||
@ -383,7 +383,7 @@ oc_unify_var_nvar:
|
||||
BIND(pt0, d1, bind_ocunify5);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(pt0, d1);
|
||||
if (pt0 < H0) _YAP_WakeUp(pt0);
|
||||
if (pt0 < H0) Yap_WakeUp(pt0);
|
||||
bind_ocunify5:
|
||||
#endif
|
||||
if (rational_tree(d1))
|
||||
@ -395,7 +395,7 @@ oc_unify_var_nvar:
|
||||
UnifyCells(pt0, pt1, uc1, uc2);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(pt0, (CELL)pt1);
|
||||
if (pt0 < H0) _YAP_WakeUp(pt0);
|
||||
if (pt0 < H0) Yap_WakeUp(pt0);
|
||||
uc1:
|
||||
#endif
|
||||
return (TRUE);
|
||||
@ -403,7 +403,7 @@ oc_unify_var_nvar:
|
||||
uc2:
|
||||
DO_TRAIL(pt1, (CELL)pt0);
|
||||
if (pt1 < H0) {
|
||||
_YAP_WakeUp(pt1);
|
||||
Yap_WakeUp(pt1);
|
||||
}
|
||||
#endif
|
||||
return (TRUE);
|
||||
@ -434,13 +434,13 @@ p_acyclic(void)
|
||||
}
|
||||
|
||||
int
|
||||
_YAP_IUnify(register CELL d0, register CELL d1)
|
||||
Yap_IUnify(register CELL d0, register CELL d1)
|
||||
{
|
||||
#if SHADOW_REGS
|
||||
#if defined(B) || defined(TR)
|
||||
register REGSTORE *regp = &_YAP_REGS;
|
||||
register REGSTORE *regp = &Yap_REGS;
|
||||
|
||||
#define _YAP_REGS (*regp)
|
||||
#define Yap_REGS (*regp)
|
||||
#endif /* defined(B) || defined(TR) */
|
||||
#endif
|
||||
|
||||
@ -487,7 +487,7 @@ unify_nvar_nvar:
|
||||
return(FloatOfTerm(AbsAppl(pt0)) == FloatOfTerm(AbsAppl(pt1)));
|
||||
#ifdef USE_GMP
|
||||
case (CELL)FunctorBigInt:
|
||||
return(mpz_cmp(_YAP_BigIntOfTerm(AbsAppl(pt0)),_YAP_BigIntOfTerm(AbsAppl(pt0))) == 0);
|
||||
return(mpz_cmp(Yap_BigIntOfTerm(AbsAppl(pt0)),Yap_BigIntOfTerm(AbsAppl(pt0))) == 0);
|
||||
#endif /* USE_GMP */
|
||||
default:
|
||||
return(FALSE);
|
||||
@ -505,7 +505,7 @@ unify_nvar_nvar:
|
||||
BIND(pt1, d0, bind_unify3);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(pt1, d0);
|
||||
if (pt1 < H0) _YAP_WakeUp(pt1);
|
||||
if (pt1 < H0) Yap_WakeUp(pt1);
|
||||
bind_unify3:
|
||||
#endif
|
||||
return (TRUE);
|
||||
@ -518,7 +518,7 @@ unify_var_nvar:
|
||||
BIND(pt0, d1, bind_unify4);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(pt0, d1);
|
||||
if (pt0 < H0) _YAP_WakeUp(pt0);
|
||||
if (pt0 < H0) Yap_WakeUp(pt0);
|
||||
bind_unify4:
|
||||
#endif
|
||||
return (TRUE);
|
||||
@ -534,7 +534,7 @@ unify_var_nvar_trail:
|
||||
UnifyCells(pt0, pt1, uc1, uc2);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(pt0, (CELL)pt1);
|
||||
if (pt0 < H0) _YAP_WakeUp(pt0);
|
||||
if (pt0 < H0) Yap_WakeUp(pt0);
|
||||
uc1:
|
||||
#endif
|
||||
return (TRUE);
|
||||
@ -542,13 +542,13 @@ unify_var_nvar_trail:
|
||||
uc2:
|
||||
DO_TRAIL(pt1, (CELL)pt0);
|
||||
if (pt1 < H0) {
|
||||
_YAP_WakeUp(pt1);
|
||||
Yap_WakeUp(pt1);
|
||||
}
|
||||
return (TRUE);
|
||||
#endif
|
||||
#if SHADOW_REGS
|
||||
#if defined(B) || defined(TR)
|
||||
#undef _YAP_REGS
|
||||
#undef Yap_REGS
|
||||
#endif /* defined(B) || defined(TR) */
|
||||
#endif
|
||||
}
|
||||
@ -579,9 +579,9 @@ InitReverseLookupOpcode(void)
|
||||
int hash_size_mask = OP_HASH_SIZE-1;
|
||||
|
||||
if (OP_RTABLE == NULL)
|
||||
OP_RTABLE = (opentry *)_YAP_AllocCodeSpace(OP_HASH_SIZE*sizeof(struct opcode_tab_entry));
|
||||
OP_RTABLE = (opentry *)Yap_AllocCodeSpace(OP_HASH_SIZE*sizeof(struct opcode_tab_entry));
|
||||
if (OP_RTABLE == NULL) {
|
||||
_YAP_Error(FATAL_ERROR, TermNil,
|
||||
Yap_Error(FATAL_ERROR, TermNil,
|
||||
"Couldn't obtain space for the reverse translation opcode table");
|
||||
}
|
||||
opeptr = OP_RTABLE;
|
||||
@ -594,11 +594,11 @@ InitReverseLookupOpcode(void)
|
||||
}
|
||||
}
|
||||
opeptr = OP_RTABLE;
|
||||
opeptr[rtable_hash_op(_YAP_opcode(_Ystop),hash_size_mask)].opc
|
||||
= _YAP_opcode(_Ystop);
|
||||
opeptr[rtable_hash_op(Yap_opcode(_Ystop),hash_size_mask)].opc
|
||||
= Yap_opcode(_Ystop);
|
||||
/* now place entries */
|
||||
for (i = _std_top; i > _Ystop; i--) {
|
||||
OPCODE opc = _YAP_opcode(i);
|
||||
OPCODE opc = Yap_opcode(i);
|
||||
int j = rtable_hash_op(opc,hash_size_mask);
|
||||
|
||||
while (opeptr[j].opc != NIL) {
|
||||
@ -614,7 +614,7 @@ InitReverseLookupOpcode(void)
|
||||
/* given an opcode find the corresponding opnumber. This should make
|
||||
switches on ops a much easier operation */
|
||||
op_numbers
|
||||
_YAP_op_from_opcode(OPCODE opc)
|
||||
Yap_op_from_opcode(OPCODE opc)
|
||||
{
|
||||
int j = rtable_hash_op(opc,OP_HASH_SIZE-1);
|
||||
|
||||
@ -628,7 +628,7 @@ _YAP_op_from_opcode(OPCODE opc)
|
||||
}
|
||||
#else
|
||||
op_numbers
|
||||
_YAP_op_from_opcode(OPCODE opc)
|
||||
Yap_op_from_opcode(OPCODE opc)
|
||||
{
|
||||
return((op_numbers)opc);
|
||||
}
|
||||
@ -636,20 +636,20 @@ _YAP_op_from_opcode(OPCODE opc)
|
||||
|
||||
|
||||
void
|
||||
_YAP_InitUnify(void)
|
||||
Yap_InitUnify(void)
|
||||
{
|
||||
_YAP_InitCPred("unify_with_occurs_check", 2, p_ocunify, SafePredFlag);
|
||||
_YAP_InitCPred("cyclic_term", 1, p_cyclic, SafePredFlag|TestPredFlag);
|
||||
_YAP_InitCPred("acyclic_term", 1, p_acyclic, SafePredFlag|TestPredFlag);
|
||||
Yap_InitCPred("unify_with_occurs_check", 2, p_ocunify, SafePredFlag);
|
||||
Yap_InitCPred("cyclic_term", 1, p_cyclic, SafePredFlag|TestPredFlag);
|
||||
Yap_InitCPred("acyclic_term", 1, p_acyclic, SafePredFlag|TestPredFlag);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_YAP_InitAbsmi(void)
|
||||
Yap_InitAbsmi(void)
|
||||
{
|
||||
/* initialise access to abstract machine instructions */
|
||||
#if USE_THREADED_CODE
|
||||
_YAP_absmi(1);
|
||||
Yap_absmi(1);
|
||||
InitReverseLookupOpcode();
|
||||
#endif
|
||||
}
|
||||
|
122
C/userpreds.c
122
C/userpreds.c
@ -139,14 +139,14 @@ Term T1, T2;
|
||||
Term t2 = Deref(T2);
|
||||
if (IsVarTerm(t1)) { /* Testing for variables should be done first */
|
||||
if (IsVarTerm(t2) || IsPrimitiveTerm(t2))
|
||||
return (_YAP_unify(T1, t2));
|
||||
return (Yap_unify(T1, t2));
|
||||
if (occurs_check(t1, t2))
|
||||
return (_YAP_unify(T1, t2));
|
||||
return (Yap_unify(T1, t2));
|
||||
return (FALSE);
|
||||
}
|
||||
if (IsVarTerm(t2)) {
|
||||
if (occurs_check(t2, t1))
|
||||
return (_YAP_unify(T2, t1));
|
||||
return (Yap_unify(T2, t1));
|
||||
return (FALSE);
|
||||
}
|
||||
if (IsPrimitiveTerm(t1)) {
|
||||
@ -220,10 +220,10 @@ p_counter()
|
||||
return (FALSE);
|
||||
a = AtomOfTerm(T1);
|
||||
if (IsVarTerm(T2)) {
|
||||
TCount = _YAP_GetValue(a);
|
||||
TCount = Yap_GetValue(a);
|
||||
if (!IsIntTerm(TCount))
|
||||
return (FALSE);
|
||||
_YAP_unify_constant(ARG2, TCount); /* always succeeds */
|
||||
Yap_unify_constant(ARG2, TCount); /* always succeeds */
|
||||
val = IntOfTerm(TCount);
|
||||
} else {
|
||||
if (!IsIntTerm(T2))
|
||||
@ -232,8 +232,8 @@ p_counter()
|
||||
}
|
||||
val++;
|
||||
/* The atom will now take the incremented value */
|
||||
_YAP_PutValue(a, TNext = MkIntTerm(val));
|
||||
return (_YAP_unify_constant(ARG3, TNext));
|
||||
Yap_PutValue(a, TNext = MkIntTerm(val));
|
||||
return (Yap_unify_constant(ARG3, TNext));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -272,7 +272,7 @@ p_iconcat()
|
||||
while (L0 = *--Tkp)
|
||||
L1 = MkPairTerm(L0, L1);
|
||||
T2 = L1;
|
||||
return (_YAP_unify(T2, ARG3));
|
||||
return (Yap_unify(T2, ARG3));
|
||||
}
|
||||
#endif /* COMMENT */
|
||||
|
||||
@ -295,7 +295,7 @@ p_iconcat()
|
||||
*Tkp++ = Deref(ARG2);
|
||||
T2 = *H;
|
||||
H = Tkp;
|
||||
return (_YAP_unify(T2, ARG3));
|
||||
return (Yap_unify(T2, ARG3));
|
||||
}
|
||||
|
||||
#endif /* USERPREDS */
|
||||
@ -333,7 +333,7 @@ p_clean() /* predicate clean for ets */
|
||||
if ((*pt++ = *ntp++) == MkAtomTerm(AtomDollarUndef))
|
||||
pt -= 2;
|
||||
H = pt;
|
||||
return (_YAP_unify(tn, ARG2));
|
||||
return (Yap_unify(tn, ARG2));
|
||||
}
|
||||
#endif
|
||||
for (i = 1; i <= arity; ++i) {
|
||||
@ -341,8 +341,8 @@ p_clean() /* predicate clean for ets */
|
||||
t = MkVarTerm();
|
||||
Args[i - 1] = t;
|
||||
}
|
||||
t = _YAP_MkApplTerm(FunctorOfTerm(t1), arity, Args);
|
||||
return (_YAP_unify(ARG2, t));
|
||||
t = Yap_MkApplTerm(FunctorOfTerm(t1), arity, Args);
|
||||
return (Yap_unify(ARG2, t));
|
||||
}
|
||||
|
||||
static Term *subs_table;
|
||||
@ -364,7 +364,7 @@ Term T1, T2;
|
||||
if (subs_table[i] == T2)
|
||||
return (FALSE);
|
||||
if (T2 < T1) { /* T1 gets instantiated with T2 */
|
||||
_YAP_unify(T1, T2);
|
||||
Yap_unify(T1, T2);
|
||||
for (i = 0; i < subs_entries; ++i)
|
||||
if (subs_table[i] == T1) {
|
||||
subs_table[i] = T2;
|
||||
@ -374,7 +374,7 @@ Term T1, T2;
|
||||
return (TRUE);
|
||||
}
|
||||
/* T2 gets instantiated with T1 */
|
||||
_YAP_unify(T1, T2);
|
||||
Yap_unify(T1, T2);
|
||||
for (i = 0; i < subs_entries; ++i)
|
||||
if (subs_table[i] == T1)
|
||||
return (TRUE);
|
||||
@ -385,7 +385,7 @@ Term T1, T2;
|
||||
for (i = 0; i < subs_entries; ++i)
|
||||
if (subs_table[i] == T2)
|
||||
return (FALSE);
|
||||
return (_YAP_unify(T1, T2));
|
||||
return (Yap_unify(T1, T2));
|
||||
}
|
||||
if (IsPrimitiveTerm(T1)) {
|
||||
if (IsFloatTerm(T1))
|
||||
@ -506,7 +506,7 @@ p_namelength()
|
||||
}
|
||||
if (IsAtomTerm(t)) {
|
||||
Term tf = MkIntTerm(strlen(RepAtom(AtomOfTerm(t))->StrOfAE));
|
||||
return (_YAP_unify_constant(ARG2, tf));
|
||||
return (Yap_unify_constant(ARG2, tf));
|
||||
} else if (IsIntTerm(t)) {
|
||||
register int i = 1, k = IntOfTerm(t);
|
||||
if (k < 0)
|
||||
@ -514,7 +514,7 @@ p_namelength()
|
||||
while (k > 10)
|
||||
++i, k /= 10;
|
||||
tf = MkIntTerm(i);
|
||||
return (_YAP_unify_constant(ARG2, tf));
|
||||
return (Yap_unify_constant(ARG2, tf));
|
||||
} else
|
||||
return (FALSE);
|
||||
}
|
||||
@ -527,7 +527,7 @@ p_getpid()
|
||||
#else
|
||||
Term t = MkIntTerm(1);
|
||||
#endif
|
||||
return (_YAP_unify_constant(ARG1, t));
|
||||
return (Yap_unify_constant(ARG1, t));
|
||||
}
|
||||
|
||||
static int
|
||||
@ -536,7 +536,7 @@ p_exit()
|
||||
register Term t = Deref(ARG1);
|
||||
if (IsVarTerm(t) || !IsIntTerm(t))
|
||||
return (FALSE);
|
||||
_YAP_exit((int) IntOfTerm(t));
|
||||
Yap_exit((int) IntOfTerm(t));
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
@ -557,7 +557,7 @@ p_setcounter()
|
||||
{
|
||||
register Term t = Deref(ARG1);
|
||||
if (IsVarTerm(t) || !IsIntTerm(t)) {
|
||||
return (_YAP_unify_constant(ARG1, MkIntTerm(current_pos)));
|
||||
return (Yap_unify_constant(ARG1, MkIntTerm(current_pos)));
|
||||
} else {
|
||||
current_pos = IntOfTerm(t);
|
||||
return (TRUE);
|
||||
@ -596,34 +596,34 @@ p_grab_tokens()
|
||||
Functor IdFunctor, VarFunctor;
|
||||
char ch, IdChars[255], *chp;
|
||||
|
||||
IdAtom = _YAP_LookupAtom("id");
|
||||
IdFunctor = _YAP_MkFunctor(IdAtom, 1);
|
||||
VarAtom = _YAP_LookupAtom("var");
|
||||
VarFunctor = _YAP_MkFunctor(VarAtom, 1);
|
||||
IdAtom = Yap_LookupAtom("id");
|
||||
IdFunctor = Yap_MkFunctor(IdAtom, 1);
|
||||
VarAtom = Yap_LookupAtom("var");
|
||||
VarFunctor = Yap_MkFunctor(VarAtom, 1);
|
||||
p0 = p;
|
||||
ch = _YAP_PlGetchar();
|
||||
ch = Yap_PlGetchar();
|
||||
while (1) {
|
||||
while (ch <= ' ' && ch != EOF)
|
||||
ch = _YAP_PlGetchar();
|
||||
ch = Yap_PlGetchar();
|
||||
if (ch == '.' || ch == EOF)
|
||||
break;
|
||||
if (ch == '%') {
|
||||
while ((ch = _YAP_PlGetchar()) != 10);
|
||||
ch = _YAP_PlGetchar();
|
||||
while ((ch = Yap_PlGetchar()) != 10);
|
||||
ch = Yap_PlGetchar();
|
||||
continue;
|
||||
}
|
||||
if (ch == '\'') {
|
||||
chp = IdChars;
|
||||
while (1) {
|
||||
ch = _YAP_PlGetchar();
|
||||
ch = Yap_PlGetchar();
|
||||
if (ch == '\'')
|
||||
break;
|
||||
*chp++ = ch;
|
||||
}
|
||||
*chp = 0;
|
||||
t = MkAtomTerm(_YAP_LookupAtom(IdChars));
|
||||
*p-- = _YAP_MkApplTerm(IdFunctor, 1, &t);
|
||||
ch = _YAP_PlGetchar();
|
||||
t = MkAtomTerm(Yap_LookupAtom(IdChars));
|
||||
*p-- = Yap_MkApplTerm(IdFunctor, 1, &t);
|
||||
ch = Yap_PlGetchar();
|
||||
continue;
|
||||
|
||||
}
|
||||
@ -631,40 +631,40 @@ p_grab_tokens()
|
||||
chp = IdChars;
|
||||
*chp++ = ch;
|
||||
while (1) {
|
||||
ch = _YAP_PlGetchar();
|
||||
ch = Yap_PlGetchar();
|
||||
if (!idchar(ch))
|
||||
break;
|
||||
*chp++ = ch;
|
||||
}
|
||||
*chp = 0;
|
||||
t = MkAtomTerm(_YAP_LookupAtom(IdChars));
|
||||
*p-- = _YAP_MkApplTerm(VarFunctor, 1, &t);
|
||||
t = MkAtomTerm(Yap_LookupAtom(IdChars));
|
||||
*p-- = Yap_MkApplTerm(VarFunctor, 1, &t);
|
||||
continue;
|
||||
}
|
||||
if (idstarter(ch)) {
|
||||
chp = IdChars;
|
||||
*chp++ = ch;
|
||||
while (1) {
|
||||
ch = _YAP_PlGetchar();
|
||||
ch = Yap_PlGetchar();
|
||||
if (!idchar(ch))
|
||||
break;
|
||||
*chp++ = ch;
|
||||
}
|
||||
*chp = 0;
|
||||
t = MkAtomTerm(_YAP_LookupAtom(IdChars));
|
||||
*p-- = _YAP_MkApplTerm(IdFunctor, 1, &t);
|
||||
t = MkAtomTerm(Yap_LookupAtom(IdChars));
|
||||
*p-- = Yap_MkApplTerm(IdFunctor, 1, &t);
|
||||
continue;
|
||||
}
|
||||
IdChars[0] = ch;
|
||||
IdChars[1] = 0;
|
||||
*p-- = MkAtomTerm(_YAP_LookupAtom(IdChars));
|
||||
ch = _YAP_PlGetchar();
|
||||
*p-- = MkAtomTerm(Yap_LookupAtom(IdChars));
|
||||
ch = Yap_PlGetchar();
|
||||
}
|
||||
t = MkAtomTerm(AtomNil);
|
||||
while (p != p0) {
|
||||
t = MkPairTerm(*++p, t);
|
||||
}
|
||||
return (_YAP_unify(ARG1, t));
|
||||
return (Yap_unify(ARG1, t));
|
||||
}
|
||||
|
||||
#endif /* EUROTRA */
|
||||
@ -687,8 +687,8 @@ p_softfunctor()
|
||||
return (FALSE);
|
||||
a = AtomOfTerm(t1);
|
||||
WRITE_LOCK(RepAtom(a)->ARWLock);
|
||||
if ((p0 = _YAP_GetAProp(a, SFProperty)) == NIL) {
|
||||
pe = (SFEntry *) _YAP_AllocAtomSpace(sizeof(*pe));
|
||||
if ((p0 = Yap_GetAProp(a, SFProperty)) == NIL) {
|
||||
pe = (SFEntry *) Yap_AllocAtomSpace(sizeof(*pe));
|
||||
pe->NextOfPE = RepAtom(a)->PropsOfAE;
|
||||
pe->KindOfPE = SFProperty;
|
||||
RepAtom(a)->PropsOfAE = AbsSFProp(pe);
|
||||
@ -712,34 +712,34 @@ p_matching_distances(void)
|
||||
*/
|
||||
|
||||
void
|
||||
_YAP_InitUserCPreds(void)
|
||||
Yap_InitUserCPreds(void)
|
||||
{
|
||||
#ifdef XINTERFACE
|
||||
_YAP_InitXPreds();
|
||||
Yap_InitXPreds();
|
||||
#endif
|
||||
#ifdef EUROTRA
|
||||
_YAP_InitCPred("clean", 2, p_clean, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("name_length", 2, p_namelength, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("get_pid", 1, p_getpid, SafePredFlag);
|
||||
_YAP_InitCPred("exit", 1, p_exit, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("incr_counter", 1, p_incrcounter, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("set_counter", 1, p_setcounter, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("trap_signal", 0, p_trapsignal, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("mark2_grab_tokens", 1, p_grab_tokens, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("subsumes", 2, p_subsumes, SafePredFlag);
|
||||
Yap_InitCPred("clean", 2, p_clean, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("name_length", 2, p_namelength, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("get_pid", 1, p_getpid, SafePredFlag);
|
||||
Yap_InitCPred("exit", 1, p_exit, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("incr_counter", 1, p_incrcounter, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("set_counter", 1, p_setcounter, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("trap_signal", 0, p_trapsignal, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("mark2_grab_tokens", 1, p_grab_tokens, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("subsumes", 2, p_subsumes, SafePredFlag);
|
||||
#endif
|
||||
#ifdef SFUNC
|
||||
_YAP_InitCPred("sparse_functor", 2, p_softfunctor, SafePredFlag);
|
||||
Yap_InitCPred("sparse_functor", 2, p_softfunctor, SafePredFlag);
|
||||
#endif /* SFUNC */
|
||||
/* _YAP_InitCPred("match_distances", 3, p_matching_distances, SafePredFlag); */
|
||||
/* _YAP_InitCPred("unify",2,p_unify,SafePredFlag); */
|
||||
/* _YAP_InitCPred("occurs_check",2,p_occurs_check,SafePredFlag); */
|
||||
/* _YAP_InitCPred("counter",3,p_counter,SafePredFlag); */
|
||||
/* _YAP_InitCPred("iconcat",3,p_iconcat,SafePredFlag); */
|
||||
/* Yap_InitCPred("match_distances", 3, p_matching_distances, SafePredFlag); */
|
||||
/* Yap_InitCPred("unify",2,p_unify,SafePredFlag); */
|
||||
/* Yap_InitCPred("occurs_check",2,p_occurs_check,SafePredFlag); */
|
||||
/* Yap_InitCPred("counter",3,p_counter,SafePredFlag); */
|
||||
/* Yap_InitCPred("iconcat",3,p_iconcat,SafePredFlag); */
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_YAP_InitUserBacks(void)
|
||||
Yap_InitUserBacks(void)
|
||||
{
|
||||
}
|
||||
|
116
C/utilpreds.c
116
C/utilpreds.c
@ -86,7 +86,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *H
|
||||
*ptf = AbsPair(H);
|
||||
ptf++;
|
||||
#ifdef RATIONAL_TREES
|
||||
if (to_visit + 4 >= (CELL **)_YAP_GlobalBase) {
|
||||
if (to_visit + 4 >= (CELL **)Yap_GlobalBase) {
|
||||
goto heap_overflow;
|
||||
}
|
||||
to_visit[0] = pt0;
|
||||
@ -98,7 +98,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *H
|
||||
to_visit += 4;
|
||||
#else
|
||||
if (pt0 < pt0_end) {
|
||||
if (to_visit + 3 >= (CELL **)_YAP_GlobalBase) {
|
||||
if (to_visit + 3 >= (CELL **)Yap_GlobalBase) {
|
||||
goto heap_overflow;
|
||||
}
|
||||
to_visit[0] = pt0;
|
||||
@ -136,7 +136,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *H
|
||||
ptf++;
|
||||
/* store the terms to visit */
|
||||
#ifdef RATIONAL_TREES
|
||||
if (to_visit + 4 >= (CELL **)_YAP_GlobalBase) {
|
||||
if (to_visit + 4 >= (CELL **)Yap_GlobalBase) {
|
||||
goto heap_overflow;
|
||||
}
|
||||
to_visit[0] = pt0;
|
||||
@ -148,7 +148,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *H
|
||||
to_visit += 4;
|
||||
#else
|
||||
if (pt0 < pt0_end) {
|
||||
if (to_visit + 3 >= (CELL **)_YAP_GlobalBase) {
|
||||
if (to_visit + 3 >= (CELL **)Yap_GlobalBase) {
|
||||
goto heap_overflow;
|
||||
}
|
||||
to_visit[0] = pt0;
|
||||
@ -189,7 +189,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *H
|
||||
*ptf++ = (CELL) ptd0;
|
||||
} else {
|
||||
if (dvars == NULL) {
|
||||
dvars = (CELL *)_YAP_ReadTimedVar(DelayedVars);
|
||||
dvars = (CELL *)Yap_ReadTimedVar(DelayedVars);
|
||||
}
|
||||
bp[0] = to_visit;
|
||||
CurTR = TR;
|
||||
@ -309,15 +309,15 @@ CopyTerm(Term inp) {
|
||||
if ((res = copy_complex_term(Hi-2, Hi-1, Hi, Hi)) < 0) {
|
||||
ARG1 = t;
|
||||
if (res == -1) { /* handle overflow */
|
||||
if (!_YAP_gc(2, ENV, P)) {
|
||||
_YAP_Error(OUT_OF_STACK_ERROR, TermNil, _YAP_ErrorMessage);
|
||||
if (!Yap_gc(2, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
}
|
||||
t = Deref(ARG1);
|
||||
goto restart_attached;
|
||||
} else { /* handle overflow */
|
||||
if (!_YAP_growheap(FALSE)) {
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, _YAP_ErrorMessage);
|
||||
if (!Yap_growheap(FALSE)) {
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
}
|
||||
t = Deref(ARG1);
|
||||
@ -345,15 +345,15 @@ CopyTerm(Term inp) {
|
||||
if ((res = copy_complex_term(ap-1, ap+1, Hi, Hi)) < 0) {
|
||||
ARG1 = t;
|
||||
if (res == -1) { /* handle overflow */
|
||||
if (!_YAP_gc(2, ENV, P)) {
|
||||
_YAP_Error(OUT_OF_STACK_ERROR, TermNil, _YAP_ErrorMessage);
|
||||
if (!Yap_gc(2, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
}
|
||||
t = Deref(ARG1);
|
||||
goto restart_list;
|
||||
} else { /* handle overflow */
|
||||
if (!_YAP_growheap(FALSE)) {
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, _YAP_ErrorMessage);
|
||||
if (!Yap_growheap(FALSE)) {
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
}
|
||||
t = Deref(ARG1);
|
||||
@ -380,15 +380,15 @@ CopyTerm(Term inp) {
|
||||
if ((res = copy_complex_term(ap, ap+ArityOfFunctor(f), HB0+1, HB0)) < 0) {
|
||||
ARG1 = t;
|
||||
if (res == -1) {
|
||||
if (!_YAP_gc(2, ENV, P)) {
|
||||
_YAP_Error(OUT_OF_STACK_ERROR, TermNil, _YAP_ErrorMessage);
|
||||
if (!Yap_gc(2, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
}
|
||||
t = Deref(ARG1);
|
||||
goto restart_appl;
|
||||
} else { /* handle overflow */
|
||||
if (!_YAP_growheap(FALSE)) {
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, _YAP_ErrorMessage);
|
||||
if (!Yap_growheap(FALSE)) {
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
}
|
||||
t = Deref(ARG1);
|
||||
@ -401,14 +401,14 @@ CopyTerm(Term inp) {
|
||||
}
|
||||
|
||||
Term
|
||||
_YAP_CopyTerm(Term inp) {
|
||||
Yap_CopyTerm(Term inp) {
|
||||
return CopyTerm(inp);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_copy_term(void) /* copy term t to a new instance */
|
||||
{
|
||||
return(_YAP_unify(ARG2,CopyTerm(ARG1)));
|
||||
return(Yap_unify(ARG2,CopyTerm(ARG1)));
|
||||
}
|
||||
|
||||
static int copy_complex_term_no_delays(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *HLow)
|
||||
@ -439,7 +439,7 @@ static int copy_complex_term_no_delays(register CELL *pt0, register CELL *pt0_en
|
||||
*ptf = AbsPair(H);
|
||||
ptf++;
|
||||
#ifdef RATIONAL_TREES
|
||||
if (to_visit + 4 >= (CELL **)_YAP_GlobalBase) {
|
||||
if (to_visit + 4 >= (CELL **)Yap_GlobalBase) {
|
||||
goto heap_overflow;
|
||||
}
|
||||
to_visit[0] = pt0;
|
||||
@ -451,7 +451,7 @@ static int copy_complex_term_no_delays(register CELL *pt0, register CELL *pt0_en
|
||||
to_visit += 4;
|
||||
#else
|
||||
if (pt0 < pt0_end) {
|
||||
if (to_visit + 3 >= (CELL **)_YAP_GlobalBase) {
|
||||
if (to_visit + 3 >= (CELL **)Yap_GlobalBase) {
|
||||
goto heap_overflow;
|
||||
}
|
||||
to_visit[0] = pt0;
|
||||
@ -487,7 +487,7 @@ static int copy_complex_term_no_delays(register CELL *pt0, register CELL *pt0_en
|
||||
ptf++;
|
||||
/* store the terms to visit */
|
||||
#ifdef RATIONAL_TREES
|
||||
if (to_visit + 4 >= (CELL **)_YAP_GlobalBase) {
|
||||
if (to_visit + 4 >= (CELL **)Yap_GlobalBase) {
|
||||
goto heap_overflow;
|
||||
}
|
||||
to_visit[0] = pt0;
|
||||
@ -498,7 +498,7 @@ static int copy_complex_term_no_delays(register CELL *pt0, register CELL *pt0_en
|
||||
*pt0 = AbsAppl(H);
|
||||
to_visit += 4;
|
||||
#else
|
||||
if (to_visit + 3 >= (CELL **)_YAP_GlobalBase) {
|
||||
if (to_visit + 3 >= (CELL **)Yap_GlobalBase) {
|
||||
goto heap_overflow;
|
||||
}
|
||||
if (pt0 < pt0_end) {
|
||||
@ -618,15 +618,15 @@ CopyTermNoDelays(Term inp) {
|
||||
res = copy_complex_term_no_delays(ap-1, ap+1, H-2, H-2);
|
||||
if (res) {
|
||||
if (res == -1) { /* handle overflow */
|
||||
if (!_YAP_gc(2, ENV, P)) {
|
||||
_YAP_Error(OUT_OF_STACK_ERROR, TermNil, _YAP_ErrorMessage);
|
||||
if (!Yap_gc(2, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
}
|
||||
t = Deref(ARG1);
|
||||
goto restart_list;
|
||||
} else { /* handle overflow */
|
||||
if (!_YAP_growheap(FALSE)) {
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, _YAP_ErrorMessage);
|
||||
if (!Yap_growheap(FALSE)) {
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
}
|
||||
t = Deref(ARG1);
|
||||
@ -650,15 +650,15 @@ CopyTermNoDelays(Term inp) {
|
||||
res = copy_complex_term_no_delays(ap, ap+ArityOfFunctor(f), HB0+1, HB0);
|
||||
if (res) {
|
||||
if (res == -1) {
|
||||
if (!_YAP_gc(2, ENV, P)) {
|
||||
_YAP_Error(OUT_OF_STACK_ERROR, TermNil, _YAP_ErrorMessage);
|
||||
if (!Yap_gc(2, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
}
|
||||
t = Deref(ARG1);
|
||||
goto restart_appl;
|
||||
} else { /* handle overflow */
|
||||
if (!_YAP_growheap(FALSE)) {
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, _YAP_ErrorMessage);
|
||||
if (!Yap_growheap(FALSE)) {
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
}
|
||||
t = Deref(ARG1);
|
||||
@ -672,7 +672,7 @@ CopyTermNoDelays(Term inp) {
|
||||
static Int
|
||||
p_copy_term_no_delays(void) /* copy term t to a new instance */
|
||||
{
|
||||
return(_YAP_unify(ARG2,CopyTermNoDelays(ARG1)));
|
||||
return(Yap_unify(ARG2,CopyTermNoDelays(ARG1)));
|
||||
}
|
||||
|
||||
|
||||
@ -773,7 +773,7 @@ static Term vars_in_complex_term(register CELL *pt0, register CELL *pt0_end)
|
||||
Term t2 = Deref(ARG2);
|
||||
if (IsVarTerm(t2)) {
|
||||
RESET_VARIABLE(H-1);
|
||||
_YAP_unify((CELL)(H-1),ARG2);
|
||||
Yap_unify((CELL)(H-1),ARG2);
|
||||
} else {
|
||||
H[-1] = t2; /* don't need to trail */
|
||||
}
|
||||
@ -794,8 +794,8 @@ p_variables_in_term(void) /* variables in term t */
|
||||
H += 2;
|
||||
RESET_VARIABLE(H-2);
|
||||
RESET_VARIABLE(H-1);
|
||||
_YAP_unify((CELL)(H-2),ARG1);
|
||||
_YAP_unify((CELL)(H-1),ARG2);
|
||||
Yap_unify((CELL)(H-2),ARG1);
|
||||
Yap_unify((CELL)(H-1),ARG2);
|
||||
} else if (IsPrimitiveTerm(t))
|
||||
out = ARG2;
|
||||
else if (IsPairTerm(t)) {
|
||||
@ -808,7 +808,7 @@ p_variables_in_term(void) /* variables in term t */
|
||||
RepAppl(t)+
|
||||
ArityOfFunctor(f));
|
||||
}
|
||||
return(_YAP_unify(ARG3,out));
|
||||
return(Yap_unify(ARG3,out));
|
||||
}
|
||||
|
||||
static Term non_singletons_in_complex_term(register CELL *pt0, register CELL *pt0_end)
|
||||
@ -911,7 +911,7 @@ static Term non_singletons_in_complex_term(register CELL *pt0, register CELL *pt
|
||||
if (H != InitialH) {
|
||||
/* close the list */
|
||||
RESET_VARIABLE(H-1);
|
||||
_YAP_unify((CELL)(H-1),ARG2);
|
||||
Yap_unify((CELL)(H-1),ARG2);
|
||||
return(output);
|
||||
} else {
|
||||
return(ARG2);
|
||||
@ -934,7 +934,7 @@ p_non_singletons_in_term(void) /* non_singletons in term t */
|
||||
else out = non_singletons_in_complex_term(RepAppl(t),
|
||||
RepAppl(t)+
|
||||
ArityOfFunctor(FunctorOfTerm(t)));
|
||||
return(_YAP_unify(ARG3,out));
|
||||
return(Yap_unify(ARG3,out));
|
||||
}
|
||||
|
||||
static Int ground_complex_term(register CELL *pt0, register CELL *pt0_end)
|
||||
@ -1251,24 +1251,24 @@ GvNTermHash(void)
|
||||
|
||||
|
||||
if (IsVarTerm(t2)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t2,"term_hash/4");
|
||||
Yap_Error(INSTANTIATION_ERROR,t2,"term_hash/4");
|
||||
return(FALSE);
|
||||
}
|
||||
if (!IsIntegerTerm(t2)) {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER,t2,"term_hash/4");
|
||||
Yap_Error(TYPE_ERROR_INTEGER,t2,"term_hash/4");
|
||||
return(FALSE);
|
||||
}
|
||||
depth = IntegerOfTerm(t2);
|
||||
if (depth == 0) {
|
||||
if (IsVarTerm(t1)) return(TRUE);
|
||||
return(_YAP_unify(ARG4,MkIntTerm(0)));
|
||||
return(Yap_unify(ARG4,MkIntTerm(0)));
|
||||
}
|
||||
if (IsVarTerm(t3)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t3,"term_hash/4");
|
||||
Yap_Error(INSTANTIATION_ERROR,t3,"term_hash/4");
|
||||
return(FALSE);
|
||||
}
|
||||
if (!IsIntegerTerm(t3)) {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER,t3,"term_hash/4");
|
||||
Yap_Error(TYPE_ERROR_INTEGER,t3,"term_hash/4");
|
||||
return(FALSE);
|
||||
}
|
||||
size = IntegerOfTerm(t3);
|
||||
@ -1283,7 +1283,7 @@ GvNTermHash(void)
|
||||
i3 = GvNht[2];
|
||||
i2 ^= i3; i1 ^= i2; i1 = (((i3 << 7) + i2) << 7) + i1;
|
||||
result = MkIntegerTerm(i1 % size);
|
||||
return(_YAP_unify(ARG4,result));
|
||||
return(Yap_unify(ARG4,result));
|
||||
}
|
||||
|
||||
static int variant_complex(register CELL *pt0, register CELL *pt0_end, register
|
||||
@ -1685,30 +1685,30 @@ camacho_dum(void)
|
||||
|
||||
/* build output list */
|
||||
|
||||
t1 = MkAtomTerm(_YAP_LookupAtom("[]"));
|
||||
t1 = MkAtomTerm(Yap_LookupAtom("[]"));
|
||||
t2 = MkPairTerm(MkIntegerTerm(max), t1);
|
||||
|
||||
return(_YAP_unify(t2, ARG1));
|
||||
return(Yap_unify(t2, ARG1));
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* DEBUG */
|
||||
|
||||
void _YAP_InitUtilCPreds(void)
|
||||
void Yap_InitUtilCPreds(void)
|
||||
{
|
||||
_YAP_InitCPred("copy_term", 2, p_copy_term, 0);
|
||||
_YAP_InitCPred("$copy_term_but_not_constraints", 2, p_copy_term_no_delays, 0);
|
||||
_YAP_InitCPred("ground", 1, p_ground, SafePredFlag);
|
||||
_YAP_InitCPred("$variables_in_term", 3, p_variables_in_term, SafePredFlag);
|
||||
_YAP_InitCPred("variable_in_term", 2, p_var_in_term, SafePredFlag);
|
||||
_YAP_InitCPred("$non_singletons_in_term", 3, p_non_singletons_in_term, SafePredFlag);
|
||||
_YAP_InitCPred("term_hash", 4, GvNTermHash, SafePredFlag);
|
||||
_YAP_InitCPred("variant", 2, p_variant, SafePredFlag);
|
||||
_YAP_InitCPred("subsumes", 2, p_subsumes, SafePredFlag);
|
||||
Yap_InitCPred("copy_term", 2, p_copy_term, 0);
|
||||
Yap_InitCPred("$copy_term_but_not_constraints", 2, p_copy_term_no_delays, 0);
|
||||
Yap_InitCPred("ground", 1, p_ground, SafePredFlag);
|
||||
Yap_InitCPred("$variables_in_term", 3, p_variables_in_term, SafePredFlag);
|
||||
Yap_InitCPred("variable_in_term", 2, p_var_in_term, SafePredFlag);
|
||||
Yap_InitCPred("$non_singletons_in_term", 3, p_non_singletons_in_term, SafePredFlag);
|
||||
Yap_InitCPred("term_hash", 4, GvNTermHash, SafePredFlag);
|
||||
Yap_InitCPred("variant", 2, p_variant, SafePredFlag);
|
||||
Yap_InitCPred("subsumes", 2, p_subsumes, SafePredFlag);
|
||||
#ifdef DEBUG
|
||||
_YAP_InitCPred("$force_trail_expansion", 1, p_force_trail_expansion, SafePredFlag);
|
||||
_YAP_InitCPred("dum", 1, camacho_dum, SafePredFlag);
|
||||
Yap_InitCPred("$force_trail_expansion", 1, p_force_trail_expansion, SafePredFlag);
|
||||
Yap_InitCPred("dum", 1, camacho_dum, SafePredFlag);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
130
C/write.c
130
C/write.c
@ -60,7 +60,7 @@ static int Quote_illegal, Ignore_ops, Handle_vars, Use_portray;
|
||||
static int keep_terms;
|
||||
|
||||
|
||||
#define wrputc(X) ((*writech)(_YAP_c_output_stream,X)) /* writes a character */
|
||||
#define wrputc(X) ((*writech)(Yap_c_output_stream,X)) /* writes a character */
|
||||
|
||||
static void
|
||||
wrputn(Int n) /* writes an integer */
|
||||
@ -154,24 +154,24 @@ legalAtom(char *s) /* Is this a legal atom ? */
|
||||
register int ch = *s;
|
||||
if (ch == '\0')
|
||||
return(FALSE);
|
||||
if (_YAP_chtype[ch] != LC) {
|
||||
if (Yap_chtype[ch] != LC) {
|
||||
if (ch == '[')
|
||||
return (*++s == ']' && !(*++s));
|
||||
else if (ch == '{')
|
||||
return (*++s == '}' && !(*++s));
|
||||
else if (_YAP_chtype[ch] == SL)
|
||||
else if (Yap_chtype[ch] == SL)
|
||||
return (!*++s);
|
||||
else if ((ch == ',' || ch == '.') && !s[1])
|
||||
return (FALSE);
|
||||
else
|
||||
while (ch) {
|
||||
if (_YAP_chtype[ch] != SY) return (FALSE);
|
||||
if (Yap_chtype[ch] != SY) return (FALSE);
|
||||
ch = *++s;
|
||||
}
|
||||
return (TRUE);
|
||||
} else
|
||||
while ((ch = *++s) != 0)
|
||||
if (_YAP_chtype[ch] > NU)
|
||||
if (Yap_chtype[ch] > NU)
|
||||
return (FALSE);
|
||||
return (TRUE);
|
||||
}
|
||||
@ -179,25 +179,25 @@ legalAtom(char *s) /* Is this a legal atom ? */
|
||||
static int LeftOpToProtect(Atom at, int p)
|
||||
{
|
||||
int op, rp;
|
||||
Prop opinfo = _YAP_GetAProp(at, OpProperty);
|
||||
return(opinfo && _YAP_IsPrefixOp(opinfo, &op, &rp) );
|
||||
Prop opinfo = Yap_GetAProp(at, OpProperty);
|
||||
return(opinfo && Yap_IsPrefixOp(opinfo, &op, &rp) );
|
||||
}
|
||||
|
||||
static int RightOpToProtect(Atom at, int p)
|
||||
{
|
||||
int op, lp;
|
||||
Prop opinfo = _YAP_GetAProp(at, OpProperty);
|
||||
return(opinfo && _YAP_IsPosfixOp(opinfo, &op, &lp) );
|
||||
Prop opinfo = Yap_GetAProp(at, OpProperty);
|
||||
return(opinfo && Yap_IsPosfixOp(opinfo, &op, &lp) );
|
||||
}
|
||||
|
||||
static wtype
|
||||
AtomIsSymbols(char *s) /* Is this atom just formed by symbols ? */
|
||||
{
|
||||
int ch;
|
||||
if (_YAP_chtype[(int)s[0]] == SL && s[1] == '\0')
|
||||
if (Yap_chtype[(int)s[0]] == SL && s[1] == '\0')
|
||||
return(separator);
|
||||
while ((ch = *s++) != '\0') {
|
||||
if (_YAP_chtype[ch] != SY)
|
||||
if (Yap_chtype[ch] != SY)
|
||||
return(alphanum);
|
||||
}
|
||||
return(symbol);
|
||||
@ -212,7 +212,7 @@ putAtom(Atom atom) /* writes an atom */
|
||||
|
||||
/* #define CRYPT_FOR_STEVE 1*/
|
||||
#ifdef CRYPT_FOR_STEVE
|
||||
if (_YAP_GetValue(_YAP_LookupAtom("crypt_atoms")) != TermNil && _YAP_GetAProp(atom, OpProperty) == NIL) {
|
||||
if (Yap_GetValue(Yap_LookupAtom("crypt_atoms")) != TermNil && Yap_GetAProp(atom, OpProperty) == NIL) {
|
||||
char s[16];
|
||||
sprintf(s,"x%x", (CELL)s);
|
||||
wrputs(s);
|
||||
@ -302,10 +302,10 @@ write_var(CELL *t)
|
||||
if (CellPtr(t) < H0) {
|
||||
#if COROUTINING
|
||||
#if DEBUG
|
||||
if (_YAP_Portray_delays) {
|
||||
if (Yap_Portray_delays) {
|
||||
exts ext = ExtFromCell(t);
|
||||
|
||||
_YAP_Portray_delays = FALSE;
|
||||
Yap_Portray_delays = FALSE;
|
||||
if (ext == susp_ext) {
|
||||
wrputs("$DL(");
|
||||
write_var(t);
|
||||
@ -321,12 +321,12 @@ write_var(CELL *t)
|
||||
wrputc(',');
|
||||
if (keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
sl = _YAP_InitSlot((CELL)attv);
|
||||
sl = Yap_InitSlot((CELL)attv);
|
||||
}
|
||||
writeTerm((Term)&(attv->Value), 999, 1, FALSE);
|
||||
if (keep_terms) {
|
||||
attv = (attvar_record *)_YAP_GetFromSlot(sl);
|
||||
_YAP_RecoverSlots(1);
|
||||
attv = (attvar_record *)Yap_GetFromSlot(sl);
|
||||
Yap_RecoverSlots(1);
|
||||
}
|
||||
for (i = 0; i < NUM_OF_ATTS; i ++) {
|
||||
if (!IsVarTerm(attv->Atts[2*i+1])) {
|
||||
@ -335,24 +335,24 @@ write_var(CELL *t)
|
||||
wrputc(',');
|
||||
if (keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
sl = _YAP_InitSlot((CELL)attv);
|
||||
sl = Yap_InitSlot((CELL)attv);
|
||||
}
|
||||
writeTerm((Term)&(attv->Atts[2*i+1]), 999, 1, FALSE);
|
||||
if (keep_terms) {
|
||||
attv = (attvar_record *)_YAP_GetFromSlot(sl);
|
||||
_YAP_RecoverSlots(1);
|
||||
attv = (attvar_record *)Yap_GetFromSlot(sl);
|
||||
Yap_RecoverSlots(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
wrputc(')');
|
||||
}
|
||||
_YAP_Portray_delays = TRUE;
|
||||
Yap_Portray_delays = TRUE;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
wrputc('D');
|
||||
wrputn(((Int) (t- CellPtr(_YAP_GlobalBase))));
|
||||
wrputn(((Int) (t- CellPtr(Yap_GlobalBase))));
|
||||
} else {
|
||||
wrputn(((Int) (t- H0)));
|
||||
}
|
||||
@ -365,7 +365,7 @@ writeTerm(Term t, int p, int depth, int rinfixarg)
|
||||
|
||||
{
|
||||
if (*max_depth != 0 && depth > *max_depth) {
|
||||
putAtom(_YAP_LookupAtom("..."));
|
||||
putAtom(Yap_LookupAtom("..."));
|
||||
return;
|
||||
}
|
||||
if (EX != 0)
|
||||
@ -386,9 +386,9 @@ writeTerm(Term t, int p, int depth, int rinfixarg)
|
||||
#ifdef USE_GMP
|
||||
} else if (IsBigIntTerm(t)) {
|
||||
char *s = (char *)TR;
|
||||
while (s+2+mpz_sizeinbase(_YAP_BigIntOfTerm(t), 10) > (char *)_YAP_TrailTop)
|
||||
_YAP_growtrail(64*1024);
|
||||
mpz_get_str(s, 10, _YAP_BigIntOfTerm(t));
|
||||
while (s+2+mpz_sizeinbase(Yap_BigIntOfTerm(t), 10) > (char *)Yap_TrailTop)
|
||||
Yap_growtrail(64*1024);
|
||||
mpz_get_str(s, 10, Yap_BigIntOfTerm(t));
|
||||
wrputs(s);
|
||||
#endif
|
||||
} else if (IsPairTerm(t)) {
|
||||
@ -401,17 +401,17 @@ writeTerm(Term t, int p, int depth, int rinfixarg)
|
||||
long sl = 0;
|
||||
|
||||
targs[0] = t;
|
||||
_YAP_PutValue(AtomPortray, MkAtomTerm(AtomNil));
|
||||
Yap_PutValue(AtomPortray, MkAtomTerm(AtomNil));
|
||||
if (EX != 0L) old_EX = EX;
|
||||
/* *--ASP = MkIntTerm(0); */
|
||||
sl = _YAP_InitSlot(t);
|
||||
_YAP_execute_goal(_YAP_MkApplTerm(FunctorPortray, 1, targs), 0, 1);
|
||||
t = _YAP_GetFromSlot(sl);
|
||||
_YAP_RecoverSlots(1);
|
||||
sl = Yap_InitSlot(t);
|
||||
Yap_execute_goal(Yap_MkApplTerm(FunctorPortray, 1, targs), 0, 1);
|
||||
t = Yap_GetFromSlot(sl);
|
||||
Yap_RecoverSlots(1);
|
||||
if (old_EX != 0L) EX = old_EX;
|
||||
Use_portray = TRUE;
|
||||
Use_portray = TRUE;
|
||||
if (_YAP_GetValue(AtomPortray) == MkAtomTerm(AtomTrue))
|
||||
if (Yap_GetValue(AtomPortray) == MkAtomTerm(AtomTrue))
|
||||
return;
|
||||
}
|
||||
if (yap_flags[WRITE_QUOTED_STRING_FLAG] && IsStringTerm(t)) {
|
||||
@ -424,7 +424,7 @@ writeTerm(Term t, int p, int depth, int rinfixarg)
|
||||
long sl= 0;
|
||||
|
||||
if (*max_list && eldepth > *max_list) {
|
||||
putAtom(_YAP_LookupAtom("..."));
|
||||
putAtom(Yap_LookupAtom("..."));
|
||||
wrputc(']');
|
||||
lastw = separator;
|
||||
return;
|
||||
@ -432,12 +432,12 @@ writeTerm(Term t, int p, int depth, int rinfixarg)
|
||||
eldepth++;
|
||||
if (keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
sl = _YAP_InitSlot(t);
|
||||
sl = Yap_InitSlot(t);
|
||||
}
|
||||
writeTerm(HeadOfTermCell(t), 999, new_depth, FALSE);
|
||||
if (keep_terms) {
|
||||
t = _YAP_GetFromSlot(sl);
|
||||
_YAP_RecoverSlots(1);
|
||||
t = Yap_GetFromSlot(sl);
|
||||
Yap_RecoverSlots(1);
|
||||
}
|
||||
ti = TailOfTerm(t);
|
||||
if (IsVarTerm(ti))
|
||||
@ -465,7 +465,7 @@ writeTerm(Term t, int p, int depth, int rinfixarg)
|
||||
|
||||
Arity = ArityOfFunctor(functor);
|
||||
atom = NameOfFunctor(functor);
|
||||
opinfo = _YAP_GetAProp(atom, OpProperty);
|
||||
opinfo = Yap_GetAProp(atom, OpProperty);
|
||||
#ifdef SFUNC
|
||||
if (Arity == SFArity) {
|
||||
int argno = 1;
|
||||
@ -485,13 +485,13 @@ writeTerm(Term t, int p, int depth, int rinfixarg)
|
||||
/* cannot use the term directly with the SBA */
|
||||
if (keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
sl = _YAP_InitSlot((CELL)p);
|
||||
sl = Yap_InitSlot((CELL)p);
|
||||
}
|
||||
writeTerm(Deref(p++), 999, depth + 1, FALSE);
|
||||
if (keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
p = (CELL *)_YAP_GetFromSlot(sl);
|
||||
_YAP_RecoverSlots(1);
|
||||
p = (CELL *)Yap_GetFromSlot(sl);
|
||||
Yap_RecoverSlots(1);
|
||||
}
|
||||
if (*p)
|
||||
wrputc(',');
|
||||
@ -508,19 +508,19 @@ writeTerm(Term t, int p, int depth, int rinfixarg)
|
||||
long sl = 0;
|
||||
|
||||
targs[0] = t;
|
||||
_YAP_PutValue(AtomPortray, MkAtomTerm(AtomNil));
|
||||
Yap_PutValue(AtomPortray, MkAtomTerm(AtomNil));
|
||||
if (EX != 0L) old_EX = EX;
|
||||
sl = _YAP_InitSlot(t);
|
||||
_YAP_execute_goal(_YAP_MkApplTerm(FunctorPortray, 1, targs),0, 1);
|
||||
t = _YAP_GetFromSlot(sl);
|
||||
_YAP_RecoverSlots(1);
|
||||
sl = Yap_InitSlot(t);
|
||||
Yap_execute_goal(Yap_MkApplTerm(FunctorPortray, 1, targs),0, 1);
|
||||
t = Yap_GetFromSlot(sl);
|
||||
Yap_RecoverSlots(1);
|
||||
if (old_EX != 0L) EX = old_EX;
|
||||
Use_portray = TRUE;
|
||||
if (_YAP_GetValue(AtomPortray) == MkAtomTerm(AtomTrue) || EX != 0L)
|
||||
if (Yap_GetValue(AtomPortray) == MkAtomTerm(AtomTrue) || EX != 0L)
|
||||
return;
|
||||
}
|
||||
if (!Ignore_ops &&
|
||||
Arity == 1 && opinfo && _YAP_IsPrefixOp(opinfo, &op,
|
||||
Arity == 1 && opinfo && Yap_IsPrefixOp(opinfo, &op,
|
||||
&rp)
|
||||
#ifdef DO_NOT_WRITE_PLUS_AND_MINUS_AS_PREFIX
|
||||
&&
|
||||
@ -557,7 +557,7 @@ writeTerm(Term t, int p, int depth, int rinfixarg)
|
||||
lastw = separator;
|
||||
}
|
||||
} else if (!Ignore_ops &&
|
||||
Arity == 1 && opinfo && _YAP_IsPosfixOp(opinfo, &op, &lp)) {
|
||||
Arity == 1 && opinfo && Yap_IsPosfixOp(opinfo, &op, &lp)) {
|
||||
Term tleft = ArgOfTerm(1, t);
|
||||
long sl = 0;
|
||||
int bracket_left =
|
||||
@ -576,13 +576,13 @@ writeTerm(Term t, int p, int depth, int rinfixarg)
|
||||
}
|
||||
if (keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
sl = _YAP_InitSlot(t);
|
||||
sl = Yap_InitSlot(t);
|
||||
}
|
||||
writeTerm(ArgOfTermCell(1,t), lp, depth + 1, rinfixarg);
|
||||
if (keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
t = _YAP_GetFromSlot(sl);
|
||||
_YAP_RecoverSlots(1);
|
||||
t = Yap_GetFromSlot(sl);
|
||||
Yap_RecoverSlots(1);
|
||||
}
|
||||
if (bracket_left) {
|
||||
wrputc(')');
|
||||
@ -594,7 +594,7 @@ writeTerm(Term t, int p, int depth, int rinfixarg)
|
||||
lastw = separator;
|
||||
}
|
||||
} else if (!Ignore_ops &&
|
||||
Arity == 2 && opinfo && _YAP_IsInfixOp(opinfo, &op, &lp,
|
||||
Arity == 2 && opinfo && Yap_IsInfixOp(opinfo, &op, &lp,
|
||||
&rp) ) {
|
||||
Term tleft = ArgOfTerm(1, t);
|
||||
Term tright = ArgOfTerm(2, t);
|
||||
@ -619,13 +619,13 @@ writeTerm(Term t, int p, int depth, int rinfixarg)
|
||||
}
|
||||
if (keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
sl = _YAP_InitSlot(t);
|
||||
sl = Yap_InitSlot(t);
|
||||
}
|
||||
writeTerm(ArgOfTermCell(1, t), lp, depth + 1, rinfixarg);
|
||||
if (keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
t = _YAP_GetFromSlot(sl);
|
||||
_YAP_RecoverSlots(1);
|
||||
t = Yap_GetFromSlot(sl);
|
||||
Yap_RecoverSlots(1);
|
||||
}
|
||||
if (bracket_left) {
|
||||
wrputc(')');
|
||||
@ -682,13 +682,13 @@ writeTerm(Term t, int p, int depth, int rinfixarg)
|
||||
lastw = separator;
|
||||
if (keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
sl = _YAP_InitSlot(t);
|
||||
sl = Yap_InitSlot(t);
|
||||
}
|
||||
writeTerm(ArgOfTermCell(1,t), 999, depth + 1, FALSE);
|
||||
if (keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
t = _YAP_GetFromSlot(sl);
|
||||
_YAP_RecoverSlots(1);
|
||||
t = Yap_GetFromSlot(sl);
|
||||
Yap_RecoverSlots(1);
|
||||
}
|
||||
wrputc(')');
|
||||
lastw = separator;
|
||||
@ -707,13 +707,13 @@ writeTerm(Term t, int p, int depth, int rinfixarg)
|
||||
for (op = 1; op <= Arity; ++op) {
|
||||
if (keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
sl = _YAP_InitSlot(t);
|
||||
sl = Yap_InitSlot(t);
|
||||
}
|
||||
writeTerm(ArgOfTermCell(op, t), 999, depth + 1, FALSE);
|
||||
if (keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
t = _YAP_GetFromSlot(sl);
|
||||
_YAP_RecoverSlots(1);
|
||||
t = Yap_GetFromSlot(sl);
|
||||
Yap_RecoverSlots(1);
|
||||
}
|
||||
if (op != Arity) {
|
||||
wrputc(',');
|
||||
@ -731,13 +731,13 @@ writeTerm(Term t, int p, int depth, int rinfixarg)
|
||||
|
||||
if (keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
sl = _YAP_InitSlot(t);
|
||||
sl = Yap_InitSlot(t);
|
||||
}
|
||||
writeTerm(ArgOfTermCell(op, t), 999, depth + 1, FALSE);
|
||||
if (keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
t = _YAP_GetFromSlot(sl);
|
||||
_YAP_RecoverSlots(1);
|
||||
t = Yap_GetFromSlot(sl);
|
||||
Yap_RecoverSlots(1);
|
||||
}
|
||||
if (op != Arity) {
|
||||
wrputc(',');
|
||||
@ -751,7 +751,7 @@ writeTerm(Term t, int p, int depth, int rinfixarg)
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_plwrite(Term t, int (*mywrite) (int, int), int flags)
|
||||
Yap_plwrite(Term t, int (*mywrite) (int, int), int flags)
|
||||
/* term to be written */
|
||||
/* consumer */
|
||||
/* write options */
|
||||
|
302
C/ypsocks.c
302
C/ypsocks.c
@ -191,7 +191,7 @@ crash(char *msg)
|
||||
}
|
||||
|
||||
void
|
||||
_YAP_init_socks(char *host, long interface_port)
|
||||
Yap_init_socks(char *host, long interface_port)
|
||||
{
|
||||
int s;
|
||||
int r;
|
||||
@ -230,57 +230,57 @@ _YAP_init_socks(char *host, long interface_port)
|
||||
|
||||
r = connect ( s, (struct sockaddr *) &soadr, sizeof(soadr));
|
||||
if (r<0) {
|
||||
fprintf(_YAP_stderr,"connect failed with %d\n",r);
|
||||
fprintf(Yap_stderr,"connect failed with %d\n",r);
|
||||
crash("[ could not connect to interface]");
|
||||
}
|
||||
/* now reopen stdin stdout and stderr */
|
||||
#if HAVE_DUP2 && !defined(__MINGW32__)
|
||||
if(dup2(s,0)<0) {
|
||||
fprintf(_YAP_stderr,"could not dup2 stdin\n");
|
||||
fprintf(Yap_stderr,"could not dup2 stdin\n");
|
||||
return;
|
||||
}
|
||||
if(dup2(s,1)<0) {
|
||||
fprintf(_YAP_stderr,"could not dup2 stdout\n");
|
||||
fprintf(Yap_stderr,"could not dup2 stdout\n");
|
||||
return;
|
||||
}
|
||||
if(dup2(s,2)<0) {
|
||||
fprintf(_YAP_stderr,"could not dup2 stderr\n");
|
||||
fprintf(Yap_stderr,"could not dup2 stderr\n");
|
||||
return;
|
||||
}
|
||||
#elif _MSC_VER || defined(__MINGW32__)
|
||||
if(_dup2(s,0)<0) {
|
||||
fprintf(_YAP_stderr,"could not dup2 stdin\n");
|
||||
fprintf(Yap_stderr,"could not dup2 stdin\n");
|
||||
return;
|
||||
}
|
||||
if(_dup2(s,1)<0) {
|
||||
fprintf(_YAP_stderr,"could not dup2 stdout\n");
|
||||
fprintf(Yap_stderr,"could not dup2 stdout\n");
|
||||
return;
|
||||
}
|
||||
if(_dup2(s,2)<0) {
|
||||
fprintf(_YAP_stderr,"could not dup2 stderr\n");
|
||||
fprintf(Yap_stderr,"could not dup2 stderr\n");
|
||||
return;
|
||||
}
|
||||
#else
|
||||
if(dup2(s,0)<0) {
|
||||
fprintf(_YAP_stderr,"could not dup2 stdin\n");
|
||||
fprintf(Yap_stderr,"could not dup2 stdin\n");
|
||||
return;
|
||||
}
|
||||
yp_iob[0].cnt = 0;
|
||||
yp_iob[0].flags = _YP_IO_SOCK | _YP_IO_READ;
|
||||
if(dup2(s,1)<0) {
|
||||
fprintf(_YAP_stderr,"could not dup2 stdout\n");
|
||||
fprintf(Yap_stderr,"could not dup2 stdout\n");
|
||||
return;
|
||||
}
|
||||
yp_iob[1].cnt = 0;
|
||||
yp_iob[1].flags = _YP_IO_SOCK | _YP_IO_WRITE;
|
||||
if(dup2(s,2)<0) {
|
||||
fprintf(_YAP_stderr,"could not dup2 stderr\n");
|
||||
fprintf(Yap_stderr,"could not dup2 stderr\n");
|
||||
return;
|
||||
}
|
||||
yp_iob[2].cnt = 0;
|
||||
yp_iob[2].flags = _YP_IO_SOCK | _YP_IO_WRITE;
|
||||
#endif
|
||||
_YAP_sockets_io = 1;
|
||||
Yap_sockets_io = 1;
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
_close(s);
|
||||
#else
|
||||
@ -300,27 +300,27 @@ p_socket(void)
|
||||
Term out;
|
||||
|
||||
if (IsVarTerm(t1)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t1,"socket/4");
|
||||
Yap_Error(INSTANTIATION_ERROR,t1,"socket/4");
|
||||
return(FALSE);
|
||||
}
|
||||
if (!IsAtomTerm(t1)) {
|
||||
_YAP_Error(TYPE_ERROR_ATOM,t1,"socket/4");
|
||||
Yap_Error(TYPE_ERROR_ATOM,t1,"socket/4");
|
||||
return(FALSE);
|
||||
}
|
||||
if (IsVarTerm(t2)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t2,"socket/4");
|
||||
Yap_Error(INSTANTIATION_ERROR,t2,"socket/4");
|
||||
return(FALSE);
|
||||
}
|
||||
if (!IsAtomTerm(t2)) {
|
||||
_YAP_Error(TYPE_ERROR_ATOM,t2,"socket/4");
|
||||
Yap_Error(TYPE_ERROR_ATOM,t2,"socket/4");
|
||||
return(FALSE);
|
||||
}
|
||||
if (IsVarTerm(t3)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t3,"socket/4");
|
||||
Yap_Error(INSTANTIATION_ERROR,t3,"socket/4");
|
||||
return(FALSE);
|
||||
}
|
||||
if (!IsIntTerm(t3)) {
|
||||
_YAP_Error(TYPE_ERROR_ATOM,t3,"socket/4");
|
||||
Yap_Error(TYPE_ERROR_ATOM,t3,"socket/4");
|
||||
return(FALSE);
|
||||
}
|
||||
sdomain = RepAtom(AtomOfTerm(t1))->StrOfAE;
|
||||
@ -421,18 +421,18 @@ p_socket(void)
|
||||
fd = socket(domain, type, protocol);
|
||||
if (invalid_socket_fd(fd)) {
|
||||
#if HAVE_STRERROR
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket/4 (socket: %s)", strerror(socket_errno));
|
||||
#else
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket/4 (socket)");
|
||||
#endif
|
||||
return(FALSE);
|
||||
}
|
||||
if (domain == AF_UNIX || domain == AF_LOCAL )
|
||||
out = _YAP_InitSocketStream(fd, new_socket, af_unix);
|
||||
out = Yap_InitSocketStream(fd, new_socket, af_unix);
|
||||
else if (domain == AF_INET )
|
||||
out = _YAP_InitSocketStream(fd, new_socket, af_inet);
|
||||
out = Yap_InitSocketStream(fd, new_socket, af_inet);
|
||||
else {
|
||||
/* ok, we currently don't support these sockets */
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
@ -443,11 +443,11 @@ p_socket(void)
|
||||
return(FALSE);
|
||||
}
|
||||
if (out == TermNil) return(FALSE);
|
||||
return(_YAP_unify(out,ARG4));
|
||||
return(Yap_unify(out,ARG4));
|
||||
}
|
||||
|
||||
Int
|
||||
_YAP_CloseSocket(int fd, socket_info status, socket_domain domain)
|
||||
Yap_CloseSocket(int fd, socket_info status, socket_domain domain)
|
||||
{
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
/* prevent further writing
|
||||
@ -457,7 +457,7 @@ _YAP_CloseSocket(int fd, socket_info status, socket_domain domain)
|
||||
char bfr;
|
||||
|
||||
if (shutdown(fd, 1) != 0) {
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_close/1 (close)");
|
||||
return(FALSE);
|
||||
}
|
||||
@ -467,7 +467,7 @@ _YAP_CloseSocket(int fd, socket_info status, socket_domain domain)
|
||||
/* prevent further reading
|
||||
from the socket */
|
||||
if (shutdown(fd, 0) < 0) {
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_close/1 (close)");
|
||||
return(FALSE);
|
||||
}
|
||||
@ -475,10 +475,10 @@ _YAP_CloseSocket(int fd, socket_info status, socket_domain domain)
|
||||
/* close the socket */
|
||||
if (closesocket(fd) != 0) {
|
||||
#if HAVE_STRERROR
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_close/1 (close: %s)", strerror(socket_errno));
|
||||
#else
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_close/1 (close)");
|
||||
#endif
|
||||
}
|
||||
@ -487,10 +487,10 @@ _YAP_CloseSocket(int fd, socket_info status, socket_domain domain)
|
||||
status == client_socket) {
|
||||
if (shutdown(fd,2) < 0) {
|
||||
#if HAVE_STRERROR
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_close/1 (shutdown: %s)", strerror(socket_errno));
|
||||
#else
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_close/1 (shutdown)");
|
||||
#endif
|
||||
return(FALSE);
|
||||
@ -498,10 +498,10 @@ _YAP_CloseSocket(int fd, socket_info status, socket_domain domain)
|
||||
}
|
||||
if (close(fd) != 0) {
|
||||
#if HAVE_STRERROR
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_close/1 (close: %s)", strerror(socket_errno));
|
||||
#else
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_close/1 (close)");
|
||||
#endif
|
||||
#endif
|
||||
@ -516,10 +516,10 @@ p_socket_close(void)
|
||||
Term t1 = Deref(ARG1);
|
||||
int sno;
|
||||
|
||||
if ((sno = _YAP_CheckSocketStream(t1, "socket_close/1")) < 0) {
|
||||
if ((sno = Yap_CheckSocketStream(t1, "socket_close/1")) < 0) {
|
||||
return (FALSE);
|
||||
}
|
||||
_YAP_CloseStream(sno);
|
||||
Yap_CloseStream(sno);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
@ -533,21 +533,21 @@ p_socket_bind(void)
|
||||
socket_info status;
|
||||
int fd;
|
||||
|
||||
if ((sno = _YAP_CheckSocketStream(t1, "socket_bind/2")) < 0) {
|
||||
if ((sno = Yap_CheckSocketStream(t1, "socket_bind/2")) < 0) {
|
||||
return (FALSE);
|
||||
}
|
||||
status = _YAP_GetSocketStatus(sno);
|
||||
fd = _YAP_GetStreamFd(sno);
|
||||
status = Yap_GetSocketStatus(sno);
|
||||
fd = Yap_GetStreamFd(sno);
|
||||
if (status != new_socket) {
|
||||
/* ok, this should be an error, as you are trying to bind */
|
||||
return(FALSE);
|
||||
}
|
||||
if (IsVarTerm(t2)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t2,"socket_bind/2");
|
||||
Yap_Error(INSTANTIATION_ERROR,t2,"socket_bind/2");
|
||||
return(FALSE);
|
||||
}
|
||||
if (!IsApplTerm(t2)) {
|
||||
_YAP_Error(DOMAIN_ERROR_STREAM,t2,"socket_bind/2");
|
||||
Yap_Error(DOMAIN_ERROR_STREAM,t2,"socket_bind/2");
|
||||
return(FALSE);
|
||||
}
|
||||
fun = FunctorOfTerm(t2);
|
||||
@ -559,17 +559,17 @@ p_socket_bind(void)
|
||||
int len;
|
||||
|
||||
if (IsVarTerm(taddr)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t2,"socket_bind/2");
|
||||
Yap_Error(INSTANTIATION_ERROR,t2,"socket_bind/2");
|
||||
return(FALSE);
|
||||
}
|
||||
if (!IsAtomTerm(taddr)) {
|
||||
_YAP_Error(TYPE_ERROR_ATOM,taddr,"socket_bind/2");
|
||||
Yap_Error(TYPE_ERROR_ATOM,taddr,"socket_bind/2");
|
||||
return(FALSE);
|
||||
}
|
||||
s = RepAtom(AtomOfTerm(taddr))->StrOfAE;
|
||||
sock.sun_family = AF_UNIX;
|
||||
if ((len = strlen(s)) > 107) /* hit me with a broomstick */ {
|
||||
_YAP_Error(DOMAIN_ERROR_STREAM,taddr,"socket_bind/2");
|
||||
Yap_Error(DOMAIN_ERROR_STREAM,taddr,"socket_bind/2");
|
||||
return(FALSE);
|
||||
}
|
||||
sock.sun_family=AF_UNIX;
|
||||
@ -579,15 +579,15 @@ p_socket_bind(void)
|
||||
((size_t) (((struct sockaddr_un *) 0)->sun_path) + len))
|
||||
< 0) {
|
||||
#if HAVE_STRERROR
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_bind/2 (bind: %s)", strerror(socket_errno));
|
||||
#else
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_bind/2 (bind)");
|
||||
#endif
|
||||
return(FALSE);
|
||||
}
|
||||
_YAP_UpdateSocketStream(sno, server_socket, af_unix);
|
||||
Yap_UpdateSocketStream(sno, server_socket, af_unix);
|
||||
return(TRUE);
|
||||
} else
|
||||
#endif
|
||||
@ -603,16 +603,16 @@ p_socket_bind(void)
|
||||
if (IsVarTerm(thost)) {
|
||||
saddr.sin_addr.s_addr = INADDR_ANY;
|
||||
} else if (!IsAtomTerm(thost)) {
|
||||
_YAP_Error(TYPE_ERROR_ATOM,thost,"socket_bind/2");
|
||||
Yap_Error(TYPE_ERROR_ATOM,thost,"socket_bind/2");
|
||||
return(FALSE);
|
||||
} else {
|
||||
shost = RepAtom(AtomOfTerm(thost))->StrOfAE;
|
||||
if((he=gethostbyname(shost))==NULL) {
|
||||
#if HAVE_STRERROR
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_bind/2 (gethostbyname: %s)", strerror(socket_errno));
|
||||
#else
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_bind/2 (gethostbyname)");
|
||||
#endif
|
||||
return(FALSE);
|
||||
@ -628,10 +628,10 @@ p_socket_bind(void)
|
||||
saddr.sin_family = AF_INET;
|
||||
if(bind(fd,(struct sockaddr *)&saddr, sizeof(saddr))==-1) {
|
||||
#if HAVE_STRERROR
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_bind/2 (bind: %s)", strerror(socket_errno));
|
||||
#else
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_bind/2 (bind)");
|
||||
#endif
|
||||
return(FALSE);
|
||||
@ -643,18 +643,18 @@ p_socket_bind(void)
|
||||
Term t;
|
||||
if (getsockname(fd, (struct sockaddr *)&saddr, &namelen) < 0) {
|
||||
#if HAVE_STRERROR
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_bind/2 (getsockname: %s)", strerror(socket_errno));
|
||||
#else
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_bind/2 (getsockname)");
|
||||
#endif
|
||||
return(FALSE);
|
||||
}
|
||||
t = MkIntTerm(ntohs(saddr.sin_port));
|
||||
_YAP_unify(ArgOfTermCell(2, t2),t);
|
||||
Yap_unify(ArgOfTermCell(2, t2),t);
|
||||
}
|
||||
_YAP_UpdateSocketStream(sno, server_socket, af_inet);
|
||||
Yap_UpdateSocketStream(sno, server_socket, af_inet);
|
||||
return(TRUE);
|
||||
} else
|
||||
return(FALSE);
|
||||
@ -672,20 +672,20 @@ p_socket_connect(void)
|
||||
int flag;
|
||||
Term out;
|
||||
|
||||
if ((sno = _YAP_CheckSocketStream(t1, "socket_connect/3")) < 0) {
|
||||
if ((sno = Yap_CheckSocketStream(t1, "socket_connect/3")) < 0) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (IsVarTerm(t2)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t2,"socket_connect/3");
|
||||
Yap_Error(INSTANTIATION_ERROR,t2,"socket_connect/3");
|
||||
return(FALSE);
|
||||
}
|
||||
if (!IsApplTerm(t2)) {
|
||||
_YAP_Error(DOMAIN_ERROR_STREAM,t2,"socket_connect/3");
|
||||
Yap_Error(DOMAIN_ERROR_STREAM,t2,"socket_connect/3");
|
||||
return(FALSE);
|
||||
}
|
||||
fun = FunctorOfTerm(t2);
|
||||
fd = _YAP_GetStreamFd(sno);
|
||||
status = _YAP_GetSocketStatus(sno);
|
||||
fd = Yap_GetStreamFd(sno);
|
||||
status = Yap_GetSocketStatus(sno);
|
||||
if (status != new_socket) {
|
||||
/* ok, this should be an error, as you are trying to bind */
|
||||
return(FALSE);
|
||||
@ -698,17 +698,17 @@ p_socket_connect(void)
|
||||
int len;
|
||||
|
||||
if (IsVarTerm(taddr)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t2,"socket_connect/3");
|
||||
Yap_Error(INSTANTIATION_ERROR,t2,"socket_connect/3");
|
||||
return(FALSE);
|
||||
}
|
||||
if (!IsAtomTerm(taddr)) {
|
||||
_YAP_Error(TYPE_ERROR_ATOM,taddr,"socket_connect/3");
|
||||
Yap_Error(TYPE_ERROR_ATOM,taddr,"socket_connect/3");
|
||||
return(FALSE);
|
||||
}
|
||||
s = RepAtom(AtomOfTerm(taddr))->StrOfAE;
|
||||
sock.sun_family = AF_UNIX;
|
||||
if ((len = strlen(s)) > 107) /* beat me with a broomstick */ {
|
||||
_YAP_Error(DOMAIN_ERROR_STREAM,taddr,"socket_connect/3");
|
||||
Yap_Error(DOMAIN_ERROR_STREAM,taddr,"socket_connect/3");
|
||||
return(FALSE);
|
||||
}
|
||||
sock.sun_family=AF_UNIX;
|
||||
@ -718,15 +718,15 @@ p_socket_connect(void)
|
||||
((size_t) (((struct sockaddr_un *) 0)->sun_path) + len)))
|
||||
< 0) {
|
||||
#if HAVE_STRERROR
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_connect/3 (connect: %s)", strerror(socket_errno));
|
||||
#else
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_connect/3 (connect)");
|
||||
#endif
|
||||
return(FALSE);
|
||||
}
|
||||
_YAP_UpdateSocketStream(sno, client_socket, af_unix);
|
||||
Yap_UpdateSocketStream(sno, client_socket, af_unix);
|
||||
} else
|
||||
#endif
|
||||
if (fun == FunctorAfInet) {
|
||||
@ -740,19 +740,19 @@ p_socket_connect(void)
|
||||
|
||||
memset((void *)&saddr,(int) 0, sizeof(saddr));
|
||||
if (IsVarTerm(thost)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,thost,"socket_connect/3");
|
||||
Yap_Error(INSTANTIATION_ERROR,thost,"socket_connect/3");
|
||||
return(FALSE);
|
||||
} else if (!IsAtomTerm(thost)) {
|
||||
_YAP_Error(TYPE_ERROR_ATOM,thost,"socket_connect/3");
|
||||
Yap_Error(TYPE_ERROR_ATOM,thost,"socket_connect/3");
|
||||
return(FALSE);
|
||||
} else {
|
||||
shost = RepAtom(AtomOfTerm(thost))->StrOfAE;
|
||||
if((he=gethostbyname(shost))==NULL) {
|
||||
#if HAVE_STRERROR
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_connect/3 (gethostbyname: %s)", strerror(socket_errno));
|
||||
#else
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_connect/3 (gethostbyname)");
|
||||
#endif
|
||||
return(FALSE);
|
||||
@ -760,10 +760,10 @@ p_socket_connect(void)
|
||||
memcpy((void *)&saddr.sin_addr, (void *)he->h_addr_list[0], he->h_length);
|
||||
}
|
||||
if (IsVarTerm(tport)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,tport,"socket_connect/3");
|
||||
Yap_Error(INSTANTIATION_ERROR,tport,"socket_connect/3");
|
||||
return(FALSE);
|
||||
} else if (!IsIntegerTerm(tport)) {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER,tport,"socket_connect/3");
|
||||
Yap_Error(TYPE_ERROR_INTEGER,tport,"socket_connect/3");
|
||||
return(FALSE);
|
||||
} else {
|
||||
port = (unsigned short int)IntegerOfTerm(tport);
|
||||
@ -775,10 +775,10 @@ p_socket_connect(void)
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_LINGER, (char *) &ling,
|
||||
sizeof(ling)) < 0) {
|
||||
#if HAVE_STRERROR
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_connect/3 (setsockopt_linger: %s)", strerror(socket_errno));
|
||||
#else
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_connect/3 (setsockopt_linger)");
|
||||
#endif
|
||||
return(FALSE);
|
||||
@ -786,19 +786,19 @@ p_socket_connect(void)
|
||||
flag = connect(fd,(struct sockaddr *)&saddr, sizeof(saddr));
|
||||
if(flag<0) {
|
||||
#if HAVE_STRERROR
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_connect/3 (connect: %s)", strerror(socket_errno));
|
||||
#else
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_connect/3 (connect)");
|
||||
#endif
|
||||
return(FALSE);
|
||||
}
|
||||
_YAP_UpdateSocketStream(sno, client_socket, af_inet);
|
||||
Yap_UpdateSocketStream(sno, client_socket, af_inet);
|
||||
} else
|
||||
return(FALSE);
|
||||
out = t1;
|
||||
return(_YAP_unify(out,ARG3));
|
||||
return(Yap_unify(out,ARG3));
|
||||
}
|
||||
|
||||
static Int
|
||||
@ -811,34 +811,34 @@ p_socket_listen(void)
|
||||
int fd;
|
||||
Int j;
|
||||
|
||||
if ((sno = _YAP_CheckSocketStream(t1, "socket_listen/2")) < 0) {
|
||||
if ((sno = Yap_CheckSocketStream(t1, "socket_listen/2")) < 0) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (IsVarTerm(t2)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t2,"socket_listen/2");
|
||||
Yap_Error(INSTANTIATION_ERROR,t2,"socket_listen/2");
|
||||
return(FALSE);
|
||||
}
|
||||
if (!IsIntTerm(t2)) {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER,t2,"socket_listen/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER,t2,"socket_listen/2");
|
||||
return(FALSE);
|
||||
}
|
||||
j = IntOfTerm(t2);
|
||||
if (j < 0) {
|
||||
_YAP_Error(DOMAIN_ERROR_STREAM,t1,"socket_listen/2");
|
||||
Yap_Error(DOMAIN_ERROR_STREAM,t1,"socket_listen/2");
|
||||
return(FALSE);
|
||||
}
|
||||
fd = _YAP_GetStreamFd(sno);
|
||||
status = _YAP_GetSocketStatus(sno);
|
||||
fd = Yap_GetStreamFd(sno);
|
||||
status = Yap_GetSocketStatus(sno);
|
||||
if (status != server_socket) {
|
||||
/* ok, this should be an error, as you are trying to bind */
|
||||
return(FALSE);
|
||||
}
|
||||
if (listen(fd,j) < 0) {
|
||||
#if HAVE_STRERROR
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_listen/2 (listen: %s)", strerror(socket_errno));
|
||||
#else
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_listen/2 (listen)");
|
||||
#endif
|
||||
}
|
||||
@ -855,16 +855,16 @@ p_socket_accept(void)
|
||||
int ofd, fd;
|
||||
Term out;
|
||||
|
||||
if ((sno = _YAP_CheckSocketStream(t1, "socket_accept/3")) < 0) {
|
||||
if ((sno = Yap_CheckSocketStream(t1, "socket_accept/3")) < 0) {
|
||||
return (FALSE);
|
||||
}
|
||||
ofd = _YAP_GetStreamFd(sno);
|
||||
status = _YAP_GetSocketStatus(sno);
|
||||
ofd = Yap_GetStreamFd(sno);
|
||||
status = Yap_GetSocketStatus(sno);
|
||||
if (status != server_socket) {
|
||||
/* ok, this should be an error, as you are trying to bind */
|
||||
return(FALSE);
|
||||
}
|
||||
domain = _YAP_GetSocketDomain(sno);
|
||||
domain = Yap_GetSocketDomain(sno);
|
||||
#if HAVE_SYS_UN_H
|
||||
if (domain == af_unix) {
|
||||
char tmp[sizeof(struct sockaddr_un)+107]; /* hit me with a broomstick */
|
||||
@ -875,15 +875,15 @@ p_socket_accept(void)
|
||||
memset((void *)&caddr,(int) 0, len);
|
||||
if ((fd=accept(ofd, (struct sockaddr *)tmp, &len)) < 0) {
|
||||
#if HAVE_STRERROR
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_accept/3 (accept: %s)", strerror(socket_errno));
|
||||
#else
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_accept/3 (accept)");
|
||||
#endif
|
||||
}
|
||||
/* ignore 2nd argument */
|
||||
out = _YAP_InitSocketStream(fd, server_session_socket, af_unix );
|
||||
out = Yap_InitSocketStream(fd, server_session_socket, af_unix );
|
||||
} else
|
||||
#endif
|
||||
if (domain == af_inet) {
|
||||
@ -896,31 +896,31 @@ p_socket_accept(void)
|
||||
memset((void *)&caddr,(int) 0, sizeof(caddr));
|
||||
if (invalid_socket_fd(fd=accept(ofd, (struct sockaddr *)&caddr, &len))) {
|
||||
#if HAVE_STRERROR
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_accept/3 (accept: %s)", strerror(socket_errno));
|
||||
#else
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_accept/3 (accept)");
|
||||
#endif
|
||||
return(FALSE);
|
||||
}
|
||||
if ((s = inet_ntoa(caddr.sin_addr)) == NULL) {
|
||||
#if HAVE_STRERROR
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_accept/3 (inet_ntoa: %s)", strerror(socket_errno));
|
||||
#else
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_accept/3 (inet_ntoa)");
|
||||
#endif
|
||||
}
|
||||
tcli = MkAtomTerm(_YAP_LookupAtom(s));
|
||||
if (!_YAP_unify(ARG2,tcli))
|
||||
tcli = MkAtomTerm(Yap_LookupAtom(s));
|
||||
if (!Yap_unify(ARG2,tcli))
|
||||
return(FALSE);
|
||||
out = _YAP_InitSocketStream(fd, server_session_socket, af_inet );
|
||||
out = Yap_InitSocketStream(fd, server_session_socket, af_inet );
|
||||
} else
|
||||
return(FALSE);
|
||||
if (out == TermNil) return(FALSE);
|
||||
return(_YAP_unify(out,ARG3));
|
||||
return(Yap_unify(out,ARG3));
|
||||
}
|
||||
|
||||
static Int
|
||||
@ -935,15 +935,15 @@ p_socket_buffering(void)
|
||||
unsigned int bufsize, len;
|
||||
int sno;
|
||||
|
||||
if ((sno = _YAP_CheckSocketStream(t1, "socket_buffering/4")) < 0) {
|
||||
if ((sno = Yap_CheckSocketStream(t1, "socket_buffering/4")) < 0) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (IsVarTerm(t2)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t2,"socket_buffering/4");
|
||||
Yap_Error(INSTANTIATION_ERROR,t2,"socket_buffering/4");
|
||||
return(FALSE);
|
||||
}
|
||||
if (!IsAtomTerm(t2)) {
|
||||
_YAP_Error(TYPE_ERROR_ATOM,t2,"socket_buffering/4");
|
||||
Yap_Error(TYPE_ERROR_ATOM,t2,"socket_buffering/4");
|
||||
return(FALSE);
|
||||
}
|
||||
mode = AtomOfTerm(t2);
|
||||
@ -952,28 +952,28 @@ p_socket_buffering(void)
|
||||
else if (mode == AtomWrite)
|
||||
writing = TRUE;
|
||||
else {
|
||||
_YAP_Error(DOMAIN_ERROR_IO_MODE,t2,"socket_buffering/4");
|
||||
Yap_Error(DOMAIN_ERROR_IO_MODE,t2,"socket_buffering/4");
|
||||
return(FALSE);
|
||||
}
|
||||
fd = _YAP_GetStreamFd(sno);
|
||||
fd = Yap_GetStreamFd(sno);
|
||||
if (writing) {
|
||||
getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &bufsize, &len);
|
||||
} else {
|
||||
getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &bufsize, &len);
|
||||
}
|
||||
if (!_YAP_unify(ARG3,MkIntegerTerm(bufsize)))
|
||||
if (!Yap_unify(ARG3,MkIntegerTerm(bufsize)))
|
||||
return(FALSE);
|
||||
if (IsVarTerm(t4)) {
|
||||
bufsize = BUFSIZ;
|
||||
} else {
|
||||
Int siz;
|
||||
if (!IsIntegerTerm(t4)) {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER,t4,"socket_buffering/4");
|
||||
Yap_Error(TYPE_ERROR_INTEGER,t4,"socket_buffering/4");
|
||||
return(FALSE);
|
||||
}
|
||||
siz = IntegerOfTerm(t4);
|
||||
if (siz < 0) {
|
||||
_YAP_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO,t4,"socket_buffering/4");
|
||||
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO,t4,"socket_buffering/4");
|
||||
return(FALSE);
|
||||
}
|
||||
bufsize = siz;
|
||||
@ -997,8 +997,8 @@ select_out_list(Term t1, fd_set *readfds_ptr)
|
||||
Term next = select_out_list(TailOfTerm(t1), readfds_ptr);
|
||||
Term Head = HeadOfTerm(t1);
|
||||
|
||||
sno = _YAP_CheckIOStream(Head,"stream_select/5");
|
||||
fd = _YAP_GetStreamFd(sno);
|
||||
sno = Yap_CheckIOStream(Head,"stream_select/5");
|
||||
fd = Yap_GetStreamFd(sno);
|
||||
if (FD_ISSET(fd, readfds_ptr))
|
||||
return(MkPairTerm(Head,next));
|
||||
else
|
||||
@ -1024,27 +1024,27 @@ p_socket_select(void)
|
||||
Term tout = TermNil, ti, Head;
|
||||
|
||||
if (IsVarTerm(t1)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t1,"socket_select/5");
|
||||
Yap_Error(INSTANTIATION_ERROR,t1,"socket_select/5");
|
||||
return(FALSE);
|
||||
}
|
||||
if (!IsPairTerm(t1)) {
|
||||
_YAP_Error(TYPE_ERROR_LIST,t1,"socket_select/5");
|
||||
Yap_Error(TYPE_ERROR_LIST,t1,"socket_select/5");
|
||||
return(FALSE);
|
||||
}
|
||||
if (IsVarTerm(t2)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t2,"socket_select/5");
|
||||
Yap_Error(INSTANTIATION_ERROR,t2,"socket_select/5");
|
||||
return(FALSE);
|
||||
}
|
||||
if (!IsIntegerTerm(t2)) {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER,t2,"socket_select/5");
|
||||
Yap_Error(TYPE_ERROR_INTEGER,t2,"socket_select/5");
|
||||
return(FALSE);
|
||||
}
|
||||
if (IsVarTerm(t3)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t3,"socket_select/5");
|
||||
Yap_Error(INSTANTIATION_ERROR,t3,"socket_select/5");
|
||||
return(FALSE);
|
||||
}
|
||||
if (!IsIntegerTerm(t3)) {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER,t3,"socket_select/5");
|
||||
Yap_Error(TYPE_ERROR_INTEGER,t3,"socket_select/5");
|
||||
return(FALSE);
|
||||
}
|
||||
FD_ZERO(&readfds);
|
||||
@ -1061,10 +1061,10 @@ p_socket_select(void)
|
||||
int sno;
|
||||
|
||||
Head = HeadOfTerm(ti);
|
||||
sno = _YAP_CheckIOStream(Head,"stream_select/5");
|
||||
sno = Yap_CheckIOStream(Head,"stream_select/5");
|
||||
if (sno < 0)
|
||||
return(FALSE);
|
||||
fd = _YAP_GetStreamFd(sno);
|
||||
fd = Yap_GetStreamFd(sno);
|
||||
FD_SET(fd, &readfds);
|
||||
if (fd > fdmax)
|
||||
fdmax = fd;
|
||||
@ -1083,16 +1083,16 @@ p_socket_select(void)
|
||||
/* do the real work */
|
||||
if (select(fdmax+1, &readfds, &writefds, &exceptfds, ptime) < 0) {
|
||||
#if HAVE_STRERROR
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_select/5 (select: %s)", strerror(socket_errno));
|
||||
#else
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"socket_select/5 (select)");
|
||||
#endif
|
||||
}
|
||||
tout = select_out_list(t1, &readfds);
|
||||
/* we're done, just pass the info back */
|
||||
return(_YAP_unify(ARG4,tout));
|
||||
return(Yap_unify(ARG4,tout));
|
||||
}
|
||||
|
||||
|
||||
@ -1102,16 +1102,16 @@ p_current_host(void) {
|
||||
Term t1 = Deref(ARG1), out;
|
||||
|
||||
if (!IsVarTerm(t1) && !IsAtomTerm(t1)) {
|
||||
_YAP_Error(TYPE_ERROR_ATOM,t1,"current_host/2");
|
||||
Yap_Error(TYPE_ERROR_ATOM,t1,"current_host/2");
|
||||
return(FALSE);
|
||||
}
|
||||
name = oname;
|
||||
if (gethostname(name, sizeof(oname)) < 0) {
|
||||
#if HAVE_STRERROR
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"current_host/2 (gethostname: %s)", strerror(socket_errno));
|
||||
#else
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"current_host/2 (gethostname)");
|
||||
#endif
|
||||
return(FALSE);
|
||||
@ -1122,10 +1122,10 @@ p_current_host(void) {
|
||||
/* not a fully qualified name, ask the name server */
|
||||
if((he=gethostbyname(name))==NULL) {
|
||||
#if HAVE_STRERROR
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"current_host/2 (gethostbyname: %s)", strerror(socket_errno));
|
||||
#else
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"current_host/2 (gethostbyname)");
|
||||
#endif
|
||||
return(FALSE);
|
||||
@ -1145,7 +1145,7 @@ p_current_host(void) {
|
||||
else {
|
||||
int isize = strlen(sin);
|
||||
if (isize >= 256) {
|
||||
_YAP_Error(SYSTEM_ERROR, ARG1,
|
||||
Yap_Error(SYSTEM_ERROR, ARG1,
|
||||
"current_host/2 (input longer than longest FAQ host name)");
|
||||
return(FALSE);
|
||||
}
|
||||
@ -1158,8 +1158,8 @@ p_current_host(void) {
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
out = MkAtomTerm(_YAP_LookupAtom(name));
|
||||
return(_YAP_unify(ARG1,out));
|
||||
out = MkAtomTerm(Yap_LookupAtom(name));
|
||||
return(Yap_unify(ARG1,out));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1173,62 +1173,62 @@ p_hostname_address(void) {
|
||||
|
||||
if (!IsVarTerm(t1)) {
|
||||
if (!IsAtomTerm(t1)) {
|
||||
_YAP_Error(TYPE_ERROR_ATOM,t1,"hostname_address/2");
|
||||
Yap_Error(TYPE_ERROR_ATOM,t1,"hostname_address/2");
|
||||
return(FALSE);
|
||||
} else tin = t1;
|
||||
} else if (IsVarTerm(t2)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR,t1,"hostname_address/5");
|
||||
Yap_Error(INSTANTIATION_ERROR,t1,"hostname_address/5");
|
||||
return(FALSE);
|
||||
} else if (!IsAtomTerm(t2)) {
|
||||
_YAP_Error(TYPE_ERROR_ATOM,t2,"hostname_address/2");
|
||||
Yap_Error(TYPE_ERROR_ATOM,t2,"hostname_address/2");
|
||||
return(FALSE);
|
||||
} else tin = t2;
|
||||
s = RepAtom(AtomOfTerm(tin))->StrOfAE;
|
||||
if (IsVarTerm(t1)) {
|
||||
if ((he = gethostbyaddr(s, strlen(s), AF_INET)) == NULL) {
|
||||
#if HAVE_STRERROR
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"hostname_address/2 (gethostbyname: %s)", strerror(socket_errno));
|
||||
#else
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"hostname_address/2 (gethostbyname)");
|
||||
#endif
|
||||
}
|
||||
out = MkAtomTerm(_YAP_LookupAtom((char *)(he->h_name)));
|
||||
return(_YAP_unify(out, ARG1));
|
||||
out = MkAtomTerm(Yap_LookupAtom((char *)(he->h_name)));
|
||||
return(Yap_unify(out, ARG1));
|
||||
} else {
|
||||
struct in_addr adr;
|
||||
if ((he = gethostbyname(s)) == NULL) {
|
||||
#if HAVE_STRERROR
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"hostname_address/2 (gethostbyname: %s)", strerror(socket_errno));
|
||||
#else
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"hostname_address/2 (gethostbyname)");
|
||||
#endif
|
||||
}
|
||||
memcpy((char *) &adr,
|
||||
(char *) he->h_addr_list[0], (size_t) he->h_length);
|
||||
out = MkAtomTerm(_YAP_LookupAtom(inet_ntoa(adr)));
|
||||
return(_YAP_unify(out, ARG2));
|
||||
out = MkAtomTerm(Yap_LookupAtom(inet_ntoa(adr)));
|
||||
return(Yap_unify(out, ARG2));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
_YAP_InitSockets(void)
|
||||
Yap_InitSockets(void)
|
||||
{
|
||||
#ifdef USE_SOCKET
|
||||
_YAP_InitCPred("socket", 4, p_socket, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("socket_close", 1, p_socket_close, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("socket_bind", 2, p_socket_bind, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("socket_connect", 3, p_socket_connect, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("socket_listen", 2, p_socket_listen, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("socket_accept", 3, p_socket_accept, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("$socket_buffering", 4, p_socket_buffering, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("$socket_select", 4, p_socket_select, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("current_host", 1, p_current_host, SafePredFlag);
|
||||
_YAP_InitCPred("hostname_address", 2, p_hostname_address, SafePredFlag);
|
||||
Yap_InitCPred("socket", 4, p_socket, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("socket_close", 1, p_socket_close, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("socket_bind", 2, p_socket_bind, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("socket_connect", 3, p_socket_connect, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("socket_listen", 2, p_socket_listen, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("socket_accept", 3, p_socket_accept, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("$socket_buffering", 4, p_socket_buffering, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("$socket_select", 4, p_socket_select, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("current_host", 1, p_current_host, SafePredFlag);
|
||||
Yap_InitCPred("hostname_address", 2, p_hostname_address, SafePredFlag);
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
{
|
||||
WSADATA info;
|
||||
|
10
H/Foreign.h
10
H/Foreign.h
@ -103,11 +103,11 @@ typedef void (*YapInitProc)(void);
|
||||
#define STD_PROTO(F,A) F A
|
||||
#endif
|
||||
|
||||
void STD_PROTO(_YAP_FindExecutable,(char *));
|
||||
Int STD_PROTO(_YAP_LoadForeign,(StringList, StringList, char *, YapInitProc *));
|
||||
Int STD_PROTO(_YAP_ReLoadForeign,(StringList, StringList, char *, YapInitProc *));
|
||||
void STD_PROTO(_YAP_ReOpenLoadForeign,(void));
|
||||
void STD_PROTO(_YAP_ShutdownLoadForeign,(void));
|
||||
void STD_PROTO(Yap_FindExecutable,(char *));
|
||||
Int STD_PROTO(Yap_LoadForeign,(StringList, StringList, char *, YapInitProc *));
|
||||
Int STD_PROTO(Yap_ReLoadForeign,(StringList, StringList, char *, YapInitProc *));
|
||||
void STD_PROTO(Yap_ReOpenLoadForeign,(void));
|
||||
void STD_PROTO(Yap_ShutdownLoadForeign,(void));
|
||||
|
||||
|
||||
|
||||
|
280
H/Regs.h
280
H/Regs.h
@ -10,7 +10,7 @@
|
||||
* File: Regs.h *
|
||||
* mods: *
|
||||
* comments: YAP abstract machine registers *
|
||||
* version: $Id: Regs.h,v 1.17 2002-11-11 17:37:58 vsc Exp $ *
|
||||
* version: $Id: Regs.h,v 1.18 2002-11-18 18:13:14 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
|
||||
@ -132,73 +132,73 @@ typedef struct
|
||||
REGSTORE;
|
||||
|
||||
|
||||
extern REGSTORE *_YAP_regp;
|
||||
extern REGSTORE *Yap_regp;
|
||||
|
||||
#if !PUSH_X
|
||||
|
||||
/* keep X as a global variable */
|
||||
|
||||
Term _YAP_XREGS[MaxTemps]; /* 29 */
|
||||
Term Yap_XREGS[MaxTemps]; /* 29 */
|
||||
|
||||
#define XREGS _YAP_XREGS
|
||||
#define XREGS Yap_XREGS
|
||||
|
||||
#endif
|
||||
|
||||
#define _YAP_REGS (*_YAP_regp)
|
||||
#define Yap_REGS (*Yap_regp)
|
||||
|
||||
#else /* PUSH_REGS */
|
||||
|
||||
Term X[MaxTemps]; /* 29 */
|
||||
|
||||
#define XREGS _YAP_REGS.X
|
||||
#define XREGS Yap_REGS.X
|
||||
|
||||
}
|
||||
REGSTORE;
|
||||
|
||||
extern REGSTORE _YAP_REGS;
|
||||
extern REGSTORE Yap_REGS;
|
||||
#endif /* PUSH_REGS */
|
||||
|
||||
#define MinTrailGap (sizeof(CELL)*1024)
|
||||
#define MinHeapGap (sizeof(CELL)*4096)
|
||||
#define MinStackGap (sizeof(CELL)*8*1024)
|
||||
extern int _YAP_stack_overflows;
|
||||
extern int Yap_stack_overflows;
|
||||
|
||||
|
||||
#define ENV _YAP_REGS.ENV_ /* current environment */
|
||||
#define ASP _YAP_REGS.ASP_ /* top of local stack */
|
||||
#define H0 _YAP_REGS.H0_ /* base of heap (global) stack */
|
||||
#define LCL0 _YAP_REGS.LCL0_ /* local stack base */
|
||||
#define ENV Yap_REGS.ENV_ /* current environment */
|
||||
#define ASP Yap_REGS.ASP_ /* top of local stack */
|
||||
#define H0 Yap_REGS.H0_ /* base of heap (global) stack */
|
||||
#define LCL0 Yap_REGS.LCL0_ /* local stack base */
|
||||
|
||||
#if defined(__GNUC__) && defined(sparc) && !defined(__NetBSD__)
|
||||
|
||||
#define P _YAP_REGS.P_ /* prolog machine program counter */
|
||||
#define YENV _YAP_REGS.YENV_ /* current environment (may differ from ENV)*/
|
||||
#define S _YAP_REGS.S_ /* structure pointer */
|
||||
#define P Yap_REGS.P_ /* prolog machine program counter */
|
||||
#define YENV Yap_REGS.YENV_ /* current environment (may differ from ENV)*/
|
||||
#define S Yap_REGS.S_ /* structure pointer */
|
||||
|
||||
register CELL *H asm ("g6");
|
||||
register tr_fr_ptr TR asm ("g7");
|
||||
#ifdef __svr4__
|
||||
register choiceptr B asm ("g5");
|
||||
#else
|
||||
#define B _YAP_REGS.B_ /* latest choice point */
|
||||
#define B Yap_REGS.B_ /* latest choice point */
|
||||
#endif
|
||||
#define CP _YAP_REGS.CP_ /* continuation program counter */
|
||||
#define HB _YAP_REGS.HB_ /* heap (global) stack top at time of latest c.p. */
|
||||
#define CreepFlag _YAP_REGS.CreepFlag_
|
||||
#define CP Yap_REGS.CP_ /* continuation program counter */
|
||||
#define HB Yap_REGS.HB_ /* heap (global) stack top at time of latest c.p. */
|
||||
#define CreepFlag Yap_REGS.CreepFlag_
|
||||
|
||||
EXTERN inline void save_machine_regs(void) {
|
||||
_YAP_REGS.H_ = H;
|
||||
_YAP_REGS.TR_ = TR;
|
||||
Yap_REGS.H_ = H;
|
||||
Yap_REGS.TR_ = TR;
|
||||
#ifdef __svr4__
|
||||
_YAP_REGS.B_ = B;
|
||||
Yap_REGS.B_ = B;
|
||||
#endif
|
||||
}
|
||||
|
||||
EXTERN inline void restore_machine_regs(void) {
|
||||
H = _YAP_REGS.H_;
|
||||
TR = _YAP_REGS.TR_;
|
||||
H = Yap_REGS.H_;
|
||||
TR = Yap_REGS.TR_;
|
||||
#ifdef __svr4__
|
||||
B = _YAP_REGS.B_;
|
||||
B = Yap_REGS.B_;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -215,11 +215,11 @@ EXTERN inline void restore_machine_regs(void) {
|
||||
TR = BK_TR
|
||||
|
||||
EXTERN inline void save_H(void) {
|
||||
_YAP_REGS.H_ = H;
|
||||
Yap_REGS.H_ = H;
|
||||
}
|
||||
|
||||
EXTERN inline void restore_H(void) {
|
||||
H = _YAP_REGS.H_;
|
||||
H = Yap_REGS.H_;
|
||||
}
|
||||
|
||||
#define BACKUP_H() CELL *BK_H = H; restore_H()
|
||||
@ -228,13 +228,13 @@ EXTERN inline void restore_H(void) {
|
||||
|
||||
EXTERN inline void save_B(void) {
|
||||
#ifdef __svr4__
|
||||
_YAP_REGS.B_ = B;
|
||||
Yap_REGS.B_ = B;
|
||||
#endif
|
||||
}
|
||||
|
||||
EXTERN inline void restore_B(void) {
|
||||
#ifdef __svr4__
|
||||
B = _YAP_REGS.B_;
|
||||
B = Yap_REGS.B_;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -250,8 +250,8 @@ EXTERN inline void restore_B(void) {
|
||||
|
||||
#elif defined(__GNUC__) && defined(__alpha)
|
||||
|
||||
#define P _YAP_REGS.P_ /* prolog machine program counter */
|
||||
#define YENV _YAP_REGS.YENV_ /* current environment (may differ from ENV) */
|
||||
#define P Yap_REGS.P_ /* prolog machine program counter */
|
||||
#define YENV Yap_REGS.YENV_ /* current environment (may differ from ENV) */
|
||||
register CELL *H asm ("$9");
|
||||
register CELL *HB asm ("$10");
|
||||
register choiceptr B asm ("$11");
|
||||
@ -260,7 +260,7 @@ register CELL *S asm ("$13");
|
||||
register tr_fr_ptr TR asm ("$14");
|
||||
/* gcc+debug chokes if $15 is in use on alphas */
|
||||
#ifdef DEBUG
|
||||
#define CreepFlag _YAP_REGS.CreepFlag_
|
||||
#define CreepFlag Yap_REGS.CreepFlag_
|
||||
#else
|
||||
register CELL CreepFlag asm ("$15");
|
||||
#endif
|
||||
@ -268,25 +268,25 @@ register CELL CreepFlag asm ("$15");
|
||||
/* Interface with foreign code, make sure the foreign code sees all the
|
||||
registers the way they used to be */
|
||||
EXTERN inline void save_machine_regs(void) {
|
||||
_YAP_REGS.H_ = H;
|
||||
_YAP_REGS.HB_ = HB;
|
||||
_YAP_REGS.B_ = B;
|
||||
_YAP_REGS.CP_ = CP;
|
||||
Yap_REGS.H_ = H;
|
||||
Yap_REGS.HB_ = HB;
|
||||
Yap_REGS.B_ = B;
|
||||
Yap_REGS.CP_ = CP;
|
||||
#ifndef DEBUG
|
||||
_YAP_REGS.CreepFlag_ = CreepFlag;
|
||||
Yap_REGS.CreepFlag_ = CreepFlag;
|
||||
#endif
|
||||
_YAP_REGS.TR_ = TR;
|
||||
Yap_REGS.TR_ = TR;
|
||||
}
|
||||
|
||||
EXTERN inline void restore_machine_regs(void) {
|
||||
H = _YAP_REGS.H_;
|
||||
HB = _YAP_REGS.HB_;
|
||||
B = _YAP_REGS.B_;
|
||||
CP = _YAP_REGS.CP_;
|
||||
H = Yap_REGS.H_;
|
||||
HB = Yap_REGS.HB_;
|
||||
B = Yap_REGS.B_;
|
||||
CP = Yap_REGS.CP_;
|
||||
#ifndef DEBUG
|
||||
CreepFlag = _YAP_REGS.CreepFlag_;
|
||||
CreepFlag = Yap_REGS.CreepFlag_;
|
||||
#endif
|
||||
TR = _YAP_REGS.TR_;
|
||||
TR = Yap_REGS.TR_;
|
||||
}
|
||||
|
||||
#define BACKUP_MACHINE_REGS() \
|
||||
@ -308,11 +308,11 @@ EXTERN inline void restore_machine_regs(void) {
|
||||
TR = BK_TR
|
||||
|
||||
EXTERN inline void save_H(void) {
|
||||
_YAP_REGS.H_ = H;
|
||||
Yap_REGS.H_ = H;
|
||||
}
|
||||
|
||||
EXTERN inline void restore_H(void) {
|
||||
H = _YAP_REGS.H_;
|
||||
H = Yap_REGS.H_;
|
||||
}
|
||||
|
||||
#define BACKUP_H() CELL *BK_H = H; restore_H()
|
||||
@ -320,11 +320,11 @@ EXTERN inline void restore_H(void) {
|
||||
#define RECOVER_H() save_H(); H = BK_H
|
||||
|
||||
EXTERN inline void save_B(void) {
|
||||
_YAP_REGS.B_ = B;
|
||||
Yap_REGS.B_ = B;
|
||||
}
|
||||
|
||||
EXTERN inline void restore_B(void) {
|
||||
B = _YAP_REGS.B_;
|
||||
B = Yap_REGS.B_;
|
||||
}
|
||||
|
||||
#define BACKUP_B() choiceptr BK_B = B; restore_B()
|
||||
@ -332,17 +332,17 @@ EXTERN inline void restore_B(void) {
|
||||
#define RECOVER_B() save_B(); B = BK_B
|
||||
|
||||
EXTERN inline void save_TR(void) {
|
||||
_YAP_REGS.TR_ = TR;
|
||||
Yap_REGS.TR_ = TR;
|
||||
}
|
||||
|
||||
EXTERN inline void restore_TR(void) {
|
||||
TR = _YAP_REGS.TR_;
|
||||
TR = Yap_REGS.TR_;
|
||||
}
|
||||
|
||||
#elif defined(__GNUC__) && defined(mips)
|
||||
|
||||
#define P _YAP_REGS.P_ /* prolog machine program counter */
|
||||
#define YENV _YAP_REGS.YENV_ /* current environment (may differ from ENV) */
|
||||
#define P Yap_REGS.P_ /* prolog machine program counter */
|
||||
#define YENV Yap_REGS.YENV_ /* current environment (may differ from ENV) */
|
||||
register CELL *H asm ("$16");
|
||||
register CELL *HB asm ("$17");
|
||||
register choiceptr B asm ("$18");
|
||||
@ -352,21 +352,21 @@ register CELL CreepFlag asm ("$21");
|
||||
register tr_fr_ptr TR asm ("$22");
|
||||
|
||||
EXTERN inline void save_machine_regs(void) {
|
||||
_YAP_REGS.H_ = H;
|
||||
_YAP_REGS.HB_ = HB;
|
||||
_YAP_REGS.B_ = B;
|
||||
_YAP_REGS.CP_ = CP;
|
||||
_YAP_REGS.CreepFlag_ = CreepFlag;
|
||||
_YAP_REGS.TR_ = TR;
|
||||
Yap_REGS.H_ = H;
|
||||
Yap_REGS.HB_ = HB;
|
||||
Yap_REGS.B_ = B;
|
||||
Yap_REGS.CP_ = CP;
|
||||
Yap_REGS.CreepFlag_ = CreepFlag;
|
||||
Yap_REGS.TR_ = TR;
|
||||
}
|
||||
|
||||
EXTERN inline void restore_machine_regs(void) {
|
||||
H = _YAP_REGS.H_;
|
||||
HB = _YAP_REGS.HB_;
|
||||
B = _YAP_REGS.B_;
|
||||
CP = _YAP_REGS.CP_;
|
||||
CreepFlag = _YAP_REGS.CreepFlag_;
|
||||
TR = _YAP_REGS.TR_;
|
||||
H = Yap_REGS.H_;
|
||||
HB = Yap_REGS.HB_;
|
||||
B = Yap_REGS.B_;
|
||||
CP = Yap_REGS.CP_;
|
||||
CreepFlag = Yap_REGS.CreepFlag_;
|
||||
TR = Yap_REGS.TR_;
|
||||
}
|
||||
|
||||
#define BACKUP_MACHINE_REGS() \
|
||||
@ -388,11 +388,11 @@ EXTERN inline void restore_machine_regs(void) {
|
||||
TR = BK_TR
|
||||
|
||||
EXTERN inline void save_H(void) {
|
||||
_YAP_REGS.H_ = H;
|
||||
Yap_REGS.H_ = H;
|
||||
}
|
||||
|
||||
EXTERN inline void restore_H(void) {
|
||||
H = _YAP_REGS.H_;
|
||||
H = Yap_REGS.H_;
|
||||
}
|
||||
|
||||
#define BACKUP_H() CELL *BK_H = H; restore_H()
|
||||
@ -400,11 +400,11 @@ EXTERN inline void restore_H(void) {
|
||||
#define RECOVER_H() save_H(); H = BK_H
|
||||
|
||||
EXTERN inline void save_B(void) {
|
||||
_YAP_REGS.B_ = B;
|
||||
Yap_REGS.B_ = B;
|
||||
}
|
||||
|
||||
EXTERN inline void restore_B(void) {
|
||||
B = _YAP_REGS.B_;
|
||||
B = Yap_REGS.B_;
|
||||
}
|
||||
|
||||
#define BACKUP_B() choiceptr BK_B = B; restore_B()
|
||||
@ -413,8 +413,8 @@ EXTERN inline void restore_B(void) {
|
||||
|
||||
#elif defined(__GNUC__) && defined(hppa)
|
||||
|
||||
#define P _YAP_REGS.P_ /* prolog machine program counter */
|
||||
#define YENV _YAP_REGS.YENV_ /* current environment (may differ from ENV) */
|
||||
#define P Yap_REGS.P_ /* prolog machine program counter */
|
||||
#define YENV Yap_REGS.YENV_ /* current environment (may differ from ENV) */
|
||||
register CELL *H asm ("r12");
|
||||
register CELL *HB asm ("r13");
|
||||
register choiceptr B asm ("r14");
|
||||
@ -424,21 +424,21 @@ register CELL CreepFlag asm ("r17");
|
||||
register tr_fr_ptr TR asm ("r18");
|
||||
|
||||
EXTERN inline void save_machine_regs(void) {
|
||||
_YAP_REGS.H_ = H;
|
||||
_YAP_REGS.HB_ = HB;
|
||||
_YAP_REGS.B_ = B;
|
||||
_YAP_REGS.CP_ = CP;
|
||||
_YAP_REGS.CreepFlag_ = CreepFlag;
|
||||
_YAP_REGS.TR_ = TR;
|
||||
Yap_REGS.H_ = H;
|
||||
Yap_REGS.HB_ = HB;
|
||||
Yap_REGS.B_ = B;
|
||||
Yap_REGS.CP_ = CP;
|
||||
Yap_REGS.CreepFlag_ = CreepFlag;
|
||||
Yap_REGS.TR_ = TR;
|
||||
}
|
||||
|
||||
EXTERN inline void restore_machine_regs(void) {
|
||||
H = _YAP_REGS.H_;
|
||||
HB = _YAP_REGS.HB_;
|
||||
B = _YAP_REGS.B_;
|
||||
CP = _YAP_REGS.CP_;
|
||||
CreepFlag = _YAP_REGS.CreepFlag_;
|
||||
TR = _YAP_REGS.TR_;
|
||||
H = Yap_REGS.H_;
|
||||
HB = Yap_REGS.HB_;
|
||||
B = Yap_REGS.B_;
|
||||
CP = Yap_REGS.CP_;
|
||||
CreepFlag = Yap_REGS.CreepFlag_;
|
||||
TR = Yap_REGS.TR_;
|
||||
}
|
||||
|
||||
#define BACKUP_MACHINE_REGS() \
|
||||
@ -460,11 +460,11 @@ EXTERN inline void restore_machine_regs(void) {
|
||||
TR = BK_TR
|
||||
|
||||
EXTERN inline void save_H(void) {
|
||||
_YAP_REGS.H_ = H;
|
||||
Yap_REGS.H_ = H;
|
||||
}
|
||||
|
||||
EXTERN inline void restore_H(void) {
|
||||
H = _YAP_REGS.H_;
|
||||
H = Yap_REGS.H_;
|
||||
}
|
||||
|
||||
#define BACKUP_H() CELL *BK_H = H; restore_H()
|
||||
@ -472,11 +472,11 @@ EXTERN inline void restore_H(void) {
|
||||
#define RECOVER_H() save_H(); H = BK_H
|
||||
|
||||
EXTERN inline void save_B(void) {
|
||||
_YAP_REGS.B_ = B;
|
||||
Yap_REGS.B_ = B;
|
||||
}
|
||||
|
||||
EXTERN inline void restore_B(void) {
|
||||
B = _YAP_REGS.B_;
|
||||
B = Yap_REGS.B_;
|
||||
}
|
||||
|
||||
#define BACKUP_B() choiceptr BK_B = B; restore_B()
|
||||
@ -484,11 +484,11 @@ EXTERN inline void restore_B(void) {
|
||||
#define RECOVER_B() save_B(); B = BK_B
|
||||
|
||||
EXTERN inline void save_TR(void) {
|
||||
_YAP_REGS.TR_ = TR;
|
||||
Yap_REGS.TR_ = TR;
|
||||
}
|
||||
|
||||
EXTERN inline void restore_TR(void) {
|
||||
TR = _YAP_REGS.TR_;
|
||||
TR = Yap_REGS.TR_;
|
||||
}
|
||||
|
||||
#elif defined(__GNUC__) && defined(_POWER)
|
||||
@ -516,26 +516,26 @@ register yamop *CP asm ("r17");
|
||||
register CELL *S asm ("r18");
|
||||
register CELL *YENV asm ("r19");
|
||||
register tr_fr_ptr TR asm ("r20");
|
||||
#define P _YAP_REGS.P_ /* prolog machine program counter */
|
||||
#define P Yap_REGS.P_ /* prolog machine program counter */
|
||||
|
||||
EXTERN inline void save_machine_regs(void) {
|
||||
_YAP_REGS.CreepFlag_ = CreepFlag;
|
||||
_YAP_REGS.H_ = H;
|
||||
_YAP_REGS.HB_ = HB;
|
||||
_YAP_REGS.B_ = B;
|
||||
_YAP_REGS.CP_ = CP;
|
||||
_YAP_REGS.YENV_ = YENV;
|
||||
_YAP_REGS.TR_ = TR;
|
||||
Yap_REGS.CreepFlag_ = CreepFlag;
|
||||
Yap_REGS.H_ = H;
|
||||
Yap_REGS.HB_ = HB;
|
||||
Yap_REGS.B_ = B;
|
||||
Yap_REGS.CP_ = CP;
|
||||
Yap_REGS.YENV_ = YENV;
|
||||
Yap_REGS.TR_ = TR;
|
||||
}
|
||||
|
||||
EXTERN inline void restore_machine_regs(void) {
|
||||
CreepFlag = _YAP_REGS.CreepFlag_;
|
||||
H = _YAP_REGS.H_;
|
||||
HB = _YAP_REGS.HB_;
|
||||
B = _YAP_REGS.B_;
|
||||
CP = _YAP_REGS.CP_;
|
||||
YENV = _YAP_REGS.YENV_;
|
||||
TR = _YAP_REGS.TR_;
|
||||
CreepFlag = Yap_REGS.CreepFlag_;
|
||||
H = Yap_REGS.H_;
|
||||
HB = Yap_REGS.HB_;
|
||||
B = Yap_REGS.B_;
|
||||
CP = Yap_REGS.CP_;
|
||||
YENV = Yap_REGS.YENV_;
|
||||
TR = Yap_REGS.TR_;
|
||||
}
|
||||
|
||||
#define BACKUP_MACHINE_REGS() \
|
||||
@ -557,11 +557,11 @@ EXTERN inline void restore_machine_regs(void) {
|
||||
TR = BK_TR
|
||||
|
||||
EXTERN inline void save_H(void) {
|
||||
_YAP_REGS.H_ = H;
|
||||
Yap_REGS.H_ = H;
|
||||
}
|
||||
|
||||
EXTERN inline void restore_H(void) {
|
||||
H = _YAP_REGS.H_;
|
||||
H = Yap_REGS.H_;
|
||||
}
|
||||
|
||||
#define BACKUP_H() CELL *BK_H = H; restore_H()
|
||||
@ -569,11 +569,11 @@ EXTERN inline void restore_H(void) {
|
||||
#define RECOVER_H() save_H(); H = BK_H
|
||||
|
||||
EXTERN inline void save_B(void) {
|
||||
_YAP_REGS.B_ = B;
|
||||
Yap_REGS.B_ = B;
|
||||
}
|
||||
|
||||
EXTERN inline void restore_B(void) {
|
||||
B = _YAP_REGS.B_;
|
||||
B = Yap_REGS.B_;
|
||||
}
|
||||
|
||||
#define BACKUP_B() choiceptr BK_B = B; restore_B()
|
||||
@ -582,15 +582,15 @@ EXTERN inline void restore_B(void) {
|
||||
|
||||
#else
|
||||
|
||||
#define CP _YAP_REGS.CP_ /* continuation program counter */
|
||||
#define P _YAP_REGS.P_ /* prolog machine program counter */
|
||||
#define YENV _YAP_REGS.YENV_ /* current environment (may differ from ENV) */
|
||||
#define S _YAP_REGS.S_ /* structure pointer */
|
||||
#define H _YAP_REGS.H_ /* top of heap (global) stack */
|
||||
#define B _YAP_REGS.B_ /* latest choice point */
|
||||
#define TR _YAP_REGS.TR_ /* top of trail */
|
||||
#define HB _YAP_REGS.HB_ /* heap (global) stack top at time of latest c.p. */
|
||||
#define CreepFlag _YAP_REGS.CreepFlag_
|
||||
#define CP Yap_REGS.CP_ /* continuation program counter */
|
||||
#define P Yap_REGS.P_ /* prolog machine program counter */
|
||||
#define YENV Yap_REGS.YENV_ /* current environment (may differ from ENV) */
|
||||
#define S Yap_REGS.S_ /* structure pointer */
|
||||
#define H Yap_REGS.H_ /* top of heap (global) stack */
|
||||
#define B Yap_REGS.B_ /* latest choice point */
|
||||
#define TR Yap_REGS.TR_ /* top of trail */
|
||||
#define HB Yap_REGS.HB_ /* heap (global) stack top at time of latest c.p. */
|
||||
#define CreepFlag Yap_REGS.CreepFlag_
|
||||
|
||||
EXTERN inline void save_machine_regs(void) {
|
||||
}
|
||||
@ -624,36 +624,36 @@ EXTERN inline void restore_B(void) {
|
||||
|
||||
#endif
|
||||
|
||||
#define AuxSp _YAP_REGS.AuxSp_
|
||||
#define AuxTop _YAP_REGS.AuxTop_
|
||||
#define HeapPlus _YAP_REGS.HeapPlus_ /*To avoid any chock with HeapTop */
|
||||
#define MyTR _YAP_REGS.MyTR_
|
||||
#define TopB _YAP_REGS.TopB_
|
||||
#define DelayedB _YAP_REGS.DelayedB_
|
||||
#define FlipFlop _YAP_REGS.FlipFlop_
|
||||
#define EX _YAP_REGS.EX_
|
||||
#define DEPTH _YAP_REGS.DEPTH_
|
||||
#define AuxSp Yap_REGS.AuxSp_
|
||||
#define AuxTop Yap_REGS.AuxTop_
|
||||
#define HeapPlus Yap_REGS.HeapPlus_ /*To avoid any chock with HeapTop */
|
||||
#define MyTR Yap_REGS.MyTR_
|
||||
#define TopB Yap_REGS.TopB_
|
||||
#define DelayedB Yap_REGS.DelayedB_
|
||||
#define FlipFlop Yap_REGS.FlipFlop_
|
||||
#define EX Yap_REGS.EX_
|
||||
#define DEPTH Yap_REGS.DEPTH_
|
||||
#if (defined(YAPOR) && defined(SBA)) || defined(TABLING)
|
||||
#define H_FZ _YAP_REGS.H_FZ_
|
||||
#define B_FZ _YAP_REGS.B_FZ_
|
||||
#define TR_FZ _YAP_REGS.TR_FZ_
|
||||
#define H_FZ Yap_REGS.H_FZ_
|
||||
#define B_FZ Yap_REGS.B_FZ_
|
||||
#define TR_FZ Yap_REGS.TR_FZ_
|
||||
#endif
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
#define worker_id (_YAP_REGS.worker_id_)
|
||||
#define worker_id (Yap_REGS.worker_id_)
|
||||
#ifdef SBA
|
||||
#define BSEG _YAP_REGS.BSEG_
|
||||
#define binding_array _YAP_REGS.binding_array_
|
||||
#define sba_offset _YAP_REGS.sba_offset_
|
||||
#define sba_end _YAP_REGS.sba_end_
|
||||
#define sba_size _YAP_REGS.sba_size_
|
||||
#define frame_head _YAP_REGS.frame_head_
|
||||
#define frame_tail _YAP_REGS.frame_tail_
|
||||
#define BSEG Yap_REGS.BSEG_
|
||||
#define binding_array Yap_REGS.binding_array_
|
||||
#define sba_offset Yap_REGS.sba_offset_
|
||||
#define sba_end Yap_REGS.sba_end_
|
||||
#define sba_size Yap_REGS.sba_size_
|
||||
#define frame_head Yap_REGS.frame_head_
|
||||
#define frame_tail Yap_REGS.frame_tail_
|
||||
#endif /* SBA */
|
||||
#endif /* YAPOR */
|
||||
#ifdef COROUTINING
|
||||
#define DelayedVars _YAP_REGS.DelayedVars_
|
||||
#define DelayedVars Yap_REGS.DelayedVars_
|
||||
#endif
|
||||
#define CurrentModule _YAP_REGS.CurrentModule_
|
||||
#define CurrentModule Yap_REGS.CurrentModule_
|
||||
|
||||
#define REG_SIZE sizeof(REGS)/sizeof(CELL *)
|
||||
|
||||
@ -683,7 +683,7 @@ EXTERN inline void restore_B(void) {
|
||||
#define HBREG HB
|
||||
|
||||
#if (defined(YAPOR) && defined(SBA)) || defined(TABLING)
|
||||
#define BB _YAP_REGS.BB_
|
||||
#define BB Yap_REGS.BB_
|
||||
#define BBREG BB
|
||||
#endif
|
||||
|
||||
@ -700,7 +700,7 @@ EXTERN inline void restore_B(void) {
|
||||
when we come from a longjmp */
|
||||
#if PUSH_REGS
|
||||
/* In this case we need to initialise the abstract registers */
|
||||
REGSTORE _YAP_standard_regs;
|
||||
REGSTORE Yap_standard_regs;
|
||||
#endif /* PUSH_REGS */
|
||||
|
||||
/******************* controlling debugging ****************************/
|
||||
|
310
H/Yapproto.h
310
H/Yapproto.h
@ -10,7 +10,7 @@
|
||||
* File: Yap.proto *
|
||||
* mods: *
|
||||
* comments: Function declarations for YAP *
|
||||
* version: $Id: Yapproto.h,v 1.28 2002-11-11 17:37:58 vsc Exp $ *
|
||||
* version: $Id: Yapproto.h,v 1.29 2002-11-18 18:13:25 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
/* prototype file for Yap */
|
||||
@ -25,32 +25,32 @@ typedef Int (*CmpPredicate)(Term, Term);
|
||||
|
||||
|
||||
/* absmi.c */
|
||||
Int STD_PROTO(_YAP_absmi,(int));
|
||||
Int STD_PROTO(Yap_absmi,(int));
|
||||
|
||||
/* adtdefs.c */
|
||||
Term STD_PROTO(_YAP_ArrayToList,(Term *,int));
|
||||
int STD_PROTO(_YAP_GetName,(char *,UInt,Term));
|
||||
Term STD_PROTO(_YAP_GetValue,(Atom));
|
||||
Atom STD_PROTO(_YAP_LookupAtom,(char *));
|
||||
Atom STD_PROTO(_YAP_FullLookupAtom,(char *));
|
||||
void STD_PROTO(_YAP_LookupAtomWithAddress,(char *,AtomEntry *));
|
||||
Prop STD_PROTO(_YAP_NewPredPropByFunctor,(struct FunctorEntryStruct *, SMALLUNSGN));
|
||||
Prop STD_PROTO(_YAP_NewPredPropByAtom,(struct AtomEntryStruct *, SMALLUNSGN));
|
||||
Functor STD_PROTO(_YAP_UnlockedMkFunctor,(AtomEntry *,unsigned int));
|
||||
Functor STD_PROTO(_YAP_MkFunctor,(Atom,unsigned int));
|
||||
void STD_PROTO(_YAP_MkFunctorWithAddress,(Atom,unsigned int,FunctorEntry *));
|
||||
void STD_PROTO(_YAP_PutValue,(Atom,Term));
|
||||
void STD_PROTO(_YAP_ReleaseAtom,(Atom));
|
||||
Term STD_PROTO(_YAP_StringToList,(char *));
|
||||
Term STD_PROTO(_YAP_StringToListOfAtoms,(char *));
|
||||
Term STD_PROTO(Yap_ArrayToList,(Term *,int));
|
||||
int STD_PROTO(Yap_GetName,(char *,UInt,Term));
|
||||
Term STD_PROTO(Yap_GetValue,(Atom));
|
||||
Atom STD_PROTO(Yap_LookupAtom,(char *));
|
||||
Atom STD_PROTO(Yap_FullLookupAtom,(char *));
|
||||
void STD_PROTO(Yap_LookupAtomWithAddress,(char *,AtomEntry *));
|
||||
Prop STD_PROTO(Yap_NewPredPropByFunctor,(struct FunctorEntryStruct *, SMALLUNSGN));
|
||||
Prop STD_PROTO(Yap_NewPredPropByAtom,(struct AtomEntryStruct *, SMALLUNSGN));
|
||||
Functor STD_PROTO(Yap_UnlockedMkFunctor,(AtomEntry *,unsigned int));
|
||||
Functor STD_PROTO(Yap_MkFunctor,(Atom,unsigned int));
|
||||
void STD_PROTO(Yap_MkFunctorWithAddress,(Atom,unsigned int,FunctorEntry *));
|
||||
void STD_PROTO(Yap_PutValue,(Atom,Term));
|
||||
void STD_PROTO(Yap_ReleaseAtom,(Atom));
|
||||
Term STD_PROTO(Yap_StringToList,(char *));
|
||||
Term STD_PROTO(Yap_StringToListOfAtoms,(char *));
|
||||
|
||||
long STD_PROTO(_YAP_InitSlot,(Term));
|
||||
long STD_PROTO(_YAP_NewSlots,(int));
|
||||
Term STD_PROTO(_YAP_GetFromSlot,(long));
|
||||
void STD_PROTO(_YAP_RecoverSlots,(int));
|
||||
Term STD_PROTO(_YAP_GetFromSlot,(long));
|
||||
Term *STD_PROTO(_YAP_AddressFromSlot,(long));
|
||||
void STD_PROTO(_YAP_PutInSlot,(long, Term));
|
||||
long STD_PROTO(Yap_InitSlot,(Term));
|
||||
long STD_PROTO(Yap_NewSlots,(int));
|
||||
Term STD_PROTO(Yap_GetFromSlot,(long));
|
||||
void STD_PROTO(Yap_RecoverSlots,(int));
|
||||
Term STD_PROTO(Yap_GetFromSlot,(long));
|
||||
Term *STD_PROTO(Yap_AddressFromSlot,(long));
|
||||
void STD_PROTO(Yap_PutInSlot,(long, Term));
|
||||
|
||||
|
||||
#if SFUNC
|
||||
@ -58,246 +58,246 @@ Term STD_PROTO(MkSFTerm,(Functor,int,Term *,Term));
|
||||
CELL STD_PROTO(*ArgsOfSFTerm,(Term));
|
||||
#endif
|
||||
|
||||
Prop STD_PROTO(_YAP_GetPredPropByAtom,(Atom, SMALLUNSGN));
|
||||
Prop STD_PROTO(_YAP_GetPredPropByFunc,(Functor, SMALLUNSGN));
|
||||
Prop STD_PROTO(_YAP_GetPredPropHavingLock,(Atom,unsigned int,SMALLUNSGN));
|
||||
Prop STD_PROTO(_YAP_GetExpProp,(Atom,unsigned int));
|
||||
Prop STD_PROTO(_YAP_GetExpPropHavingLock,(AtomEntry *,unsigned int));
|
||||
Prop STD_PROTO(Yap_GetPredPropByAtom,(Atom, SMALLUNSGN));
|
||||
Prop STD_PROTO(Yap_GetPredPropByFunc,(Functor, SMALLUNSGN));
|
||||
Prop STD_PROTO(Yap_GetPredPropHavingLock,(Atom,unsigned int,SMALLUNSGN));
|
||||
Prop STD_PROTO(Yap_GetExpProp,(Atom,unsigned int));
|
||||
Prop STD_PROTO(Yap_GetExpPropHavingLock,(AtomEntry *,unsigned int));
|
||||
|
||||
/* agc.c */
|
||||
void STD_PROTO(_YAP_atom_gc, (void));
|
||||
void STD_PROTO(_YAP_init_agc, (void));
|
||||
void STD_PROTO(Yap_atom_gc, (void));
|
||||
void STD_PROTO(Yap_init_agc, (void));
|
||||
|
||||
/* alloc.c */
|
||||
int STD_PROTO(_YAP_SizeOfBlock,(CODEADDR));
|
||||
void STD_PROTO(_YAP_FreeCodeSpace,(char *));
|
||||
char *STD_PROTO(_YAP_AllocAtomSpace,(unsigned int));
|
||||
char *STD_PROTO(_YAP_AllocCodeSpace,(unsigned int));
|
||||
ADDR STD_PROTO(_YAP_AllocFromForeignArea,(Int));
|
||||
int STD_PROTO(_YAP_ExtendWorkSpace,(Int));
|
||||
void STD_PROTO(_YAP_FreeAtomSpace,(char *));
|
||||
int STD_PROTO(_YAP_FreeWorkSpace, (void));
|
||||
void STD_PROTO(_YAP_InitMemory,(int,int,int));
|
||||
int STD_PROTO(Yap_SizeOfBlock,(CODEADDR));
|
||||
void STD_PROTO(Yap_FreeCodeSpace,(char *));
|
||||
char *STD_PROTO(Yap_AllocAtomSpace,(unsigned int));
|
||||
char *STD_PROTO(Yap_AllocCodeSpace,(unsigned int));
|
||||
ADDR STD_PROTO(Yap_AllocFromForeignArea,(Int));
|
||||
int STD_PROTO(Yap_ExtendWorkSpace,(Int));
|
||||
void STD_PROTO(Yap_FreeAtomSpace,(char *));
|
||||
int STD_PROTO(Yap_FreeWorkSpace, (void));
|
||||
void STD_PROTO(Yap_InitMemory,(int,int,int));
|
||||
|
||||
/* amasm.c */
|
||||
OPCODE STD_PROTO(_YAP_opcode,(op_numbers));
|
||||
OPCODE STD_PROTO(Yap_opcode,(op_numbers));
|
||||
|
||||
/* analyst.c */
|
||||
#ifdef ANALYST
|
||||
void STD_PROTO(_YAP_InitAnalystPreds,(void));
|
||||
void STD_PROTO(Yap_InitAnalystPreds,(void));
|
||||
#endif /* ANALYST */
|
||||
|
||||
/* arrays.c */
|
||||
void STD_PROTO(_YAP_InitArrayPreds,(void));
|
||||
void STD_PROTO(Yap_InitArrayPreds,(void));
|
||||
|
||||
/* attvar.c */
|
||||
Term STD_PROTO(_YAP_CurrentAttVars,(void));
|
||||
void STD_PROTO(_YAP_InitAttVarPreds,(void));
|
||||
Term STD_PROTO(Yap_CurrentAttVars,(void));
|
||||
void STD_PROTO(Yap_InitAttVarPreds,(void));
|
||||
|
||||
/* bb.c */
|
||||
void STD_PROTO(_YAP_InitBBPreds,(void));
|
||||
void STD_PROTO(Yap_InitBBPreds,(void));
|
||||
|
||||
/* bignum.c */
|
||||
void STD_PROTO(_YAP_InitBigNums,(void));
|
||||
void STD_PROTO(Yap_InitBigNums,(void));
|
||||
|
||||
/* c_interface.c */
|
||||
Int STD_PROTO(YAP_Execute,(struct pred_entry *, CPredicate));
|
||||
|
||||
/* cdmgr.c */
|
||||
void STD_PROTO(_YAP_addclause,(Term,CODEADDR,int,int));
|
||||
Term STD_PROTO(_YAP_all_calls,(void));
|
||||
Atom STD_PROTO(_YAP_ConsultingFile,(void));
|
||||
Int STD_PROTO(_YAP_PredForCode,(CODEADDR, Atom *, Int *, SMALLUNSGN *));
|
||||
void STD_PROTO(_YAP_InitCdMgr,(void));
|
||||
void STD_PROTO(Yap_addclause,(Term,CODEADDR,int,int));
|
||||
Term STD_PROTO(Yap_all_calls,(void));
|
||||
Atom STD_PROTO(Yap_ConsultingFile,(void));
|
||||
Int STD_PROTO(Yap_PredForCode,(CODEADDR, Atom *, Int *, SMALLUNSGN *));
|
||||
void STD_PROTO(Yap_InitCdMgr,(void));
|
||||
#if EMACS
|
||||
int STD_PROTO(where_new_clause, (Prop, int));
|
||||
#endif
|
||||
void STD_PROTO(_YAP_init_consult,(int, char *));
|
||||
void STD_PROTO(_YAP_end_consult,(void));
|
||||
void STD_PROTO(Yap_init_consult,(int, char *));
|
||||
void STD_PROTO(Yap_end_consult,(void));
|
||||
|
||||
|
||||
/* cmppreds.c */
|
||||
int STD_PROTO(_YAP_compare_terms,(Term,Term));
|
||||
void STD_PROTO(_YAP_InitCmpPreds,(void));
|
||||
int STD_PROTO(Yap_compare_terms,(Term,Term));
|
||||
void STD_PROTO(Yap_InitCmpPreds,(void));
|
||||
|
||||
/* compiler.c */
|
||||
CODEADDR STD_PROTO(_YAP_cclause,(Term, int, int));
|
||||
CODEADDR STD_PROTO(Yap_cclause,(Term, int, int));
|
||||
|
||||
/* computils.c */
|
||||
|
||||
/* corout.c */
|
||||
void STD_PROTO(_YAP_InitCoroutPreds,(void));
|
||||
void STD_PROTO(Yap_InitCoroutPreds,(void));
|
||||
#ifdef COROUTINING
|
||||
Term STD_PROTO(_YAP_ListOfWokenGoals,(void));
|
||||
void STD_PROTO(_YAP_WakeUp,(CELL *));
|
||||
void STD_PROTO(_YAP_mark_all_suspended_goals,(void));
|
||||
Term STD_PROTO(Yap_ListOfWokenGoals,(void));
|
||||
void STD_PROTO(Yap_WakeUp,(CELL *));
|
||||
void STD_PROTO(Yap_mark_all_suspended_goals,(void));
|
||||
#endif
|
||||
|
||||
/* dbase.c */
|
||||
int STD_PROTO(_YAP_DBTrailOverflow,(void));
|
||||
CELL STD_PROTO(_YAP_EvalMasks,(Term,CELL *));
|
||||
void STD_PROTO(_YAP_InitBackDB,(void));
|
||||
void STD_PROTO(_YAP_InitDBPreds,(void));
|
||||
int STD_PROTO(Yap_DBTrailOverflow,(void));
|
||||
CELL STD_PROTO(Yap_EvalMasks,(Term,CELL *));
|
||||
void STD_PROTO(Yap_InitBackDB,(void));
|
||||
void STD_PROTO(Yap_InitDBPreds,(void));
|
||||
|
||||
/* errors.c */
|
||||
void STD_PROTO(_YAP_exit,(int));
|
||||
yamop *STD_PROTO(_YAP_Error,(yap_error_number,Term,char *msg, ...));
|
||||
void STD_PROTO(Yap_exit,(int));
|
||||
yamop *STD_PROTO(Yap_Error,(yap_error_number,Term,char *msg, ...));
|
||||
|
||||
/* eval.c */
|
||||
void STD_PROTO(_YAP_InitEval,(void));
|
||||
void STD_PROTO(Yap_InitEval,(void));
|
||||
|
||||
/* exec.c */
|
||||
Term STD_PROTO(_YAP_ExecuteCallMetaCall,(SMALLUNSGN mod));
|
||||
void STD_PROTO(_YAP_InitExecFs,(void));
|
||||
Int STD_PROTO(_YAP_JumpToEnv,(Term));
|
||||
int STD_PROTO(_YAP_RunTopGoal,(Term));
|
||||
Int STD_PROTO(_YAP_execute_goal,(Term, int, SMALLUNSGN));
|
||||
int STD_PROTO(_YAP_exec_absmi,(int));
|
||||
void STD_PROTO(_YAP_trust_last,(void));
|
||||
Term STD_PROTO(Yap_ExecuteCallMetaCall,(SMALLUNSGN mod));
|
||||
void STD_PROTO(Yap_InitExecFs,(void));
|
||||
Int STD_PROTO(Yap_JumpToEnv,(Term));
|
||||
int STD_PROTO(Yap_RunTopGoal,(Term));
|
||||
Int STD_PROTO(Yap_execute_goal,(Term, int, SMALLUNSGN));
|
||||
int STD_PROTO(Yap_exec_absmi,(int));
|
||||
void STD_PROTO(Yap_trust_last,(void));
|
||||
|
||||
|
||||
/* grow.c */
|
||||
Int STD_PROTO(_YAP_total_stack_shift_time,(void));
|
||||
void STD_PROTO(_YAP_InitGrowPreds, (void));
|
||||
int STD_PROTO(_YAP_growheap, (int));
|
||||
int STD_PROTO(_YAP_growstack, (long));
|
||||
int STD_PROTO(_YAP_growtrail, (long));
|
||||
int STD_PROTO(_YAP_growglobal, (CELL **));
|
||||
Int STD_PROTO(Yap_total_stack_shift_time,(void));
|
||||
void STD_PROTO(Yap_InitGrowPreds, (void));
|
||||
int STD_PROTO(Yap_growheap, (int));
|
||||
int STD_PROTO(Yap_growstack, (long));
|
||||
int STD_PROTO(Yap_growtrail, (long));
|
||||
int STD_PROTO(Yap_growglobal, (CELL **));
|
||||
|
||||
/* heapgc.c */
|
||||
Int STD_PROTO(_YAP_total_gc_time,(void));
|
||||
void STD_PROTO(_YAP_init_gc,(void));
|
||||
int STD_PROTO(_YAP_is_gc_verbose, (void));
|
||||
int STD_PROTO(_YAP_gc, (Int, CELL *, yamop *));
|
||||
Int STD_PROTO(Yap_total_gc_time,(void));
|
||||
void STD_PROTO(Yap_init_gc,(void));
|
||||
int STD_PROTO(Yap_is_gc_verbose, (void));
|
||||
int STD_PROTO(Yap_gc, (Int, CELL *, yamop *));
|
||||
|
||||
/* init.c */
|
||||
#ifdef DEBUG
|
||||
int STD_PROTO(_YAP_DebugPutc,(int,int));
|
||||
void STD_PROTO(_YAP_DebugSetIFile,(char *));
|
||||
void STD_PROTO(_YAP_DebugEndline,(void));
|
||||
int STD_PROTO(_YAP_DebugGetc,(void));
|
||||
int STD_PROTO(Yap_DebugPutc,(int,int));
|
||||
void STD_PROTO(Yap_DebugSetIFile,(char *));
|
||||
void STD_PROTO(Yap_DebugEndline,(void));
|
||||
int STD_PROTO(Yap_DebugGetc,(void));
|
||||
#endif
|
||||
int STD_PROTO(_YAP_IsOpType,(char *));
|
||||
void STD_PROTO(_YAP_InitStacks,(int,int,int,int,int,int));
|
||||
void STD_PROTO(_YAP_InitCPred,(char *, unsigned long int, CPredicate, int));
|
||||
void STD_PROTO(_YAP_InitAsmPred,(char *, unsigned long int, int, CPredicate, int));
|
||||
void STD_PROTO(_YAP_InitCmpPred,(char *, unsigned long int, CmpPredicate, CPredicate, int));
|
||||
void STD_PROTO(_YAP_InitCPredBack,(char *, unsigned long int, unsigned int, CPredicate,CPredicate,int));
|
||||
void STD_PROTO(_YAP_InitYaamRegs,(void));
|
||||
void STD_PROTO(_YAP_ReInitWallTime, (void));
|
||||
int STD_PROTO(_YAP_OpDec,(int,char *,Atom));
|
||||
int STD_PROTO(Yap_IsOpType,(char *));
|
||||
void STD_PROTO(Yap_InitStacks,(int,int,int,int,int,int));
|
||||
void STD_PROTO(Yap_InitCPred,(char *, unsigned long int, CPredicate, int));
|
||||
void STD_PROTO(Yap_InitAsmPred,(char *, unsigned long int, int, CPredicate, int));
|
||||
void STD_PROTO(Yap_InitCmpPred,(char *, unsigned long int, CmpPredicate, CPredicate, int));
|
||||
void STD_PROTO(Yap_InitCPredBack,(char *, unsigned long int, unsigned int, CPredicate,CPredicate,int));
|
||||
void STD_PROTO(Yap_InitYaamRegs,(void));
|
||||
void STD_PROTO(Yap_ReInitWallTime, (void));
|
||||
int STD_PROTO(Yap_OpDec,(int,char *,Atom));
|
||||
|
||||
/* inlines.c */
|
||||
void STD_PROTO(_YAP_InitInlines,(void));
|
||||
void STD_PROTO(Yap_InitInlines,(void));
|
||||
|
||||
/* iopreds.c */
|
||||
void STD_PROTO(_YAP_InitPlIO,(void));
|
||||
void STD_PROTO(_YAP_InitBackIO,(void));
|
||||
void STD_PROTO(_YAP_InitIOPreds,(void));
|
||||
void STD_PROTO(Yap_InitPlIO,(void));
|
||||
void STD_PROTO(Yap_InitBackIO,(void));
|
||||
void STD_PROTO(Yap_InitIOPreds,(void));
|
||||
|
||||
/* depth_lim.c */
|
||||
void STD_PROTO(_YAP_InitItDeepenPreds,(void));
|
||||
void STD_PROTO(Yap_InitItDeepenPreds,(void));
|
||||
|
||||
/* load_foreign.c */
|
||||
void STD_PROTO(_YAP_InitLoadForeign,(void));
|
||||
void STD_PROTO(Yap_InitLoadForeign,(void));
|
||||
|
||||
/* mavar.c */
|
||||
void STD_PROTO(_YAP_InitMaVarCPreds,(void));
|
||||
Term STD_PROTO(_YAP_NewTimedVar,(Term));
|
||||
Term STD_PROTO(_YAP_NewEmptyTimedVar,(void));
|
||||
Term STD_PROTO(_YAP_ReadTimedVar,(Term));
|
||||
Term STD_PROTO(_YAP_UpdateTimedVar,(Term, Term));
|
||||
void STD_PROTO(Yap_InitMaVarCPreds,(void));
|
||||
Term STD_PROTO(Yap_NewTimedVar,(Term));
|
||||
Term STD_PROTO(Yap_NewEmptyTimedVar,(void));
|
||||
Term STD_PROTO(Yap_ReadTimedVar,(Term));
|
||||
Term STD_PROTO(Yap_UpdateTimedVar,(Term, Term));
|
||||
|
||||
/* modules.c */
|
||||
SMALLUNSGN STD_PROTO(_YAP_LookupModule,(Term));
|
||||
Term STD_PROTO(_YAP_Module_Name, (CODEADDR));
|
||||
void STD_PROTO(_YAP_InitModules, (void));
|
||||
SMALLUNSGN STD_PROTO(Yap_LookupModule,(Term));
|
||||
Term STD_PROTO(Yap_Module_Name, (CODEADDR));
|
||||
void STD_PROTO(Yap_InitModules, (void));
|
||||
|
||||
#if HAVE_MPI
|
||||
/* mpi.c */
|
||||
void STD_PROTO(_YAP_InitMPI,(void));
|
||||
void STD_PROTO(Yap_InitMPI,(void));
|
||||
#endif
|
||||
|
||||
#if HAVE_MPE
|
||||
/* mpe.c */
|
||||
void STD_PROTO(_YAP_InitMPE,(void));
|
||||
void STD_PROTO(Yap_InitMPE,(void));
|
||||
#endif
|
||||
|
||||
|
||||
/* other.c */
|
||||
Term STD_PROTO(_YAP_MkApplTerm,(Functor,unsigned int,Term *));
|
||||
Term STD_PROTO(_YAP_MkNewApplTerm,(Functor,unsigned int));
|
||||
Term STD_PROTO(_YAP_MkNewPairTerm,(void));
|
||||
Term STD_PROTO(Yap_MkApplTerm,(Functor,unsigned int,Term *));
|
||||
Term STD_PROTO(Yap_MkNewApplTerm,(Functor,unsigned int));
|
||||
Term STD_PROTO(Yap_MkNewPairTerm,(void));
|
||||
|
||||
|
||||
/* parser.c */
|
||||
int STD_PROTO(_YAP_IsPrefixOp,(Prop,int *,int *));
|
||||
int STD_PROTO(_YAP_IsInfixOp,(Prop,int *,int *,int *));
|
||||
int STD_PROTO(_YAP_IsPosfixOp,(Prop,int *,int *));
|
||||
Term STD_PROTO(_YAP_Parse,(void));
|
||||
int STD_PROTO(Yap_IsPrefixOp,(Prop,int *,int *));
|
||||
int STD_PROTO(Yap_IsInfixOp,(Prop,int *,int *,int *));
|
||||
int STD_PROTO(Yap_IsPosfixOp,(Prop,int *,int *));
|
||||
Term STD_PROTO(Yap_Parse,(void));
|
||||
|
||||
/* save.c */
|
||||
int STD_PROTO(_YAP_SavedInfo,(char *,char *,CELL *,CELL *,CELL *));
|
||||
int STD_PROTO(_YAP_Restore,(char *, char *));
|
||||
void STD_PROTO(_YAP_InitSavePreds,(void));
|
||||
int STD_PROTO(Yap_SavedInfo,(char *,char *,CELL *,CELL *,CELL *));
|
||||
int STD_PROTO(Yap_Restore,(char *, char *));
|
||||
void STD_PROTO(Yap_InitSavePreds,(void));
|
||||
|
||||
/* scanner.c */
|
||||
|
||||
/* sort.c */
|
||||
void STD_PROTO(_YAP_InitSortPreds,(void));
|
||||
void STD_PROTO(Yap_InitSortPreds,(void));
|
||||
|
||||
/* stdpreds.c */
|
||||
void STD_PROTO(_YAP_InitBackCPreds,(void));
|
||||
void STD_PROTO(_YAP_InitCPreds,(void));
|
||||
void STD_PROTO(_YAP_show_statistics,(void));
|
||||
Int STD_PROTO(_YAP_creep,(void));
|
||||
void STD_PROTO(Yap_InitBackCPreds,(void));
|
||||
void STD_PROTO(Yap_InitCPreds,(void));
|
||||
void STD_PROTO(Yap_show_statistics,(void));
|
||||
Int STD_PROTO(Yap_creep,(void));
|
||||
|
||||
/* sysbits.c */
|
||||
void STD_PROTO(_YAP_set_fpu_exceptions,(int));
|
||||
Int STD_PROTO(_YAP_cputime,(void));
|
||||
Int STD_PROTO(_YAP_walltime,(void));
|
||||
int STD_PROTO(_YAP_dir_separator,(int));
|
||||
int STD_PROTO(_YAP_volume_header,(char *));
|
||||
void STD_PROTO(_YAP_InitSysPath,(void));
|
||||
void STD_PROTO(Yap_set_fpu_exceptions,(int));
|
||||
Int STD_PROTO(Yap_cputime,(void));
|
||||
Int STD_PROTO(Yap_walltime,(void));
|
||||
int STD_PROTO(Yap_dir_separator,(int));
|
||||
int STD_PROTO(Yap_volume_header,(char *));
|
||||
void STD_PROTO(Yap_InitSysPath,(void));
|
||||
#if MAC
|
||||
void STD_PROTO(_YAP_SetTextFile,(char *));
|
||||
void STD_PROTO(Yap_SetTextFile,(char *));
|
||||
#endif
|
||||
void STD_PROTO(_YAP_cputime_interval,(Int *,Int *));
|
||||
void STD_PROTO(_YAP_walltime_interval,(Int *,Int *));
|
||||
void STD_PROTO(_YAP_InitSysbits,(void));
|
||||
void STD_PROTO(_YAP_InitSysPreds,(void));
|
||||
int STD_PROTO(_YAP_TrueFileName, (char *, char *, int));
|
||||
int STD_PROTO(_YAP_ProcessSIGINT,(void));
|
||||
double STD_PROTO(_YAP_random, (void));
|
||||
void STD_PROTO(Yap_cputime_interval,(Int *,Int *));
|
||||
void STD_PROTO(Yap_walltime_interval,(Int *,Int *));
|
||||
void STD_PROTO(Yap_InitSysbits,(void));
|
||||
void STD_PROTO(Yap_InitSysPreds,(void));
|
||||
int STD_PROTO(Yap_TrueFileName, (char *, char *, int));
|
||||
int STD_PROTO(Yap_ProcessSIGINT,(void));
|
||||
double STD_PROTO(Yap_random, (void));
|
||||
|
||||
/* tracer.c */
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
void STD_PROTO(_YAP_InitLowLevelTrace,(void));
|
||||
void STD_PROTO(Yap_InitLowLevelTrace,(void));
|
||||
#endif
|
||||
|
||||
/* unify.c */
|
||||
void STD_PROTO(_YAP_InitAbsmi,(void));
|
||||
void STD_PROTO(_YAP_InitUnify,(void));
|
||||
int STD_PROTO(_YAP_IUnify,(register CELL d0,register CELL d1));
|
||||
op_numbers STD_PROTO(_YAP_op_from_opcode,(OPCODE));
|
||||
void STD_PROTO(Yap_InitAbsmi,(void));
|
||||
void STD_PROTO(Yap_InitUnify,(void));
|
||||
int STD_PROTO(Yap_IUnify,(register CELL d0,register CELL d1));
|
||||
op_numbers STD_PROTO(Yap_op_from_opcode,(OPCODE));
|
||||
|
||||
/* userpreds.c */
|
||||
void STD_PROTO(_YAP_InitUserCPreds,(void));
|
||||
void STD_PROTO(_YAP_InitUserBacks,(void));
|
||||
void STD_PROTO(Yap_InitUserCPreds,(void));
|
||||
void STD_PROTO(Yap_InitUserBacks,(void));
|
||||
|
||||
/* utilpreds.c */
|
||||
Term STD_PROTO(_YAP_CopyTerm,(Term));
|
||||
void STD_PROTO(_YAP_InitUtilCPreds,(void));
|
||||
Term STD_PROTO(Yap_CopyTerm,(Term));
|
||||
void STD_PROTO(Yap_InitUtilCPreds,(void));
|
||||
|
||||
/* yap.c */
|
||||
|
||||
/* ypsocks.c */
|
||||
void STD_PROTO(_YAP_InitSockets,(void));
|
||||
void STD_PROTO(Yap_InitSockets,(void));
|
||||
#ifdef USE_SOCKET
|
||||
void STD_PROTO(_YAP_init_socks,(char *, long));
|
||||
void STD_PROTO(Yap_init_socks,(char *, long));
|
||||
#endif
|
||||
|
||||
/* opt.preds.c */
|
||||
void STD_PROTO(_YAP_init_optyap_preds,(void));
|
||||
void STD_PROTO(Yap_init_optyap_preds,(void));
|
||||
|
||||
|
||||
|
16
H/absmi.h
16
H/absmi.h
@ -168,14 +168,14 @@ static char *op_names[_std_top + 1] =
|
||||
inline EXTERN void
|
||||
init_absmi_regs(REGSTORE * absmi_regs)
|
||||
{
|
||||
memcpy(absmi_regs, _YAP_regp, sizeof(REGSTORE));
|
||||
memcpy(absmi_regs, Yap_regp, sizeof(REGSTORE));
|
||||
}
|
||||
|
||||
inline EXTERN void
|
||||
restore_absmi_regs(REGSTORE * old_regs)
|
||||
{
|
||||
memcpy(old_regs, _YAP_regp, sizeof(REGSTORE));
|
||||
_YAP_regp = old_regs;
|
||||
memcpy(old_regs, Yap_regp, sizeof(REGSTORE));
|
||||
Yap_regp = old_regs;
|
||||
}
|
||||
#endif /* PUSH_REGS */
|
||||
|
||||
@ -681,7 +681,7 @@ Macros to check the limits of stacks
|
||||
|
||||
#else
|
||||
|
||||
#define check_trail() if (Unsigned(_YAP_TrailTop) - Unsigned(TR) < MinTrailGap) \
|
||||
#define check_trail() if (Unsigned(Yap_TrailTop) - Unsigned(TR) < MinTrailGap) \
|
||||
goto notrailleft
|
||||
|
||||
#endif
|
||||
@ -1154,9 +1154,9 @@ IUnify_complex(CELL *pt0, CELL *pt0_end, CELL *pt1)
|
||||
{
|
||||
#if SHADOW_REGS
|
||||
#if defined(B) || defined(TR)
|
||||
register REGSTORE *regp = &_YAP_REGS;
|
||||
register REGSTORE *regp = &Yap_REGS;
|
||||
|
||||
#define _YAP_REGS (*regp)
|
||||
#define Yap_REGS (*regp)
|
||||
#endif /* defined(B) || defined(TR) || defined(HB) */
|
||||
#endif
|
||||
|
||||
@ -1311,7 +1311,7 @@ cufail:
|
||||
return (FALSE);
|
||||
#if SHADOW_REGS
|
||||
#if defined(B) || defined(TR)
|
||||
#undef _YAP_REGS
|
||||
#undef Yap_REGS
|
||||
#endif /* defined(B) || defined(TR) */
|
||||
#endif
|
||||
}
|
||||
@ -1405,7 +1405,7 @@ loop:
|
||||
return (FALSE);
|
||||
#ifdef USE_GMP
|
||||
case (CELL)FunctorBigInt:
|
||||
if (IsBigIntTerm(d1) && mpz_cmp((MP_INT *)(ap2+1),_YAP_BigIntOfTerm(d1)) == 0) continue;
|
||||
if (IsBigIntTerm(d1) && mpz_cmp((MP_INT *)(ap2+1),Yap_BigIntOfTerm(d1)) == 0) continue;
|
||||
UNWIND_CUNIF();
|
||||
return (FALSE);
|
||||
#endif /* USE_GMP */
|
||||
|
@ -77,8 +77,8 @@ typedef struct FREEB {
|
||||
#define ALIGN_YAPTYPE(X,TYPE) (((CELL)(X)+(sizeof(TYPE)-1)) & ~(sizeof(TYPE)-1))
|
||||
|
||||
/* I'll assume page size is always a power of two */
|
||||
#define AdjustPageSize(X) ((X) & (_YAP_page_size-1) ? \
|
||||
((X) + _YAP_page_size) & (~(_YAP_page_size-1)) : \
|
||||
#define AdjustPageSize(X) ((X) & (Yap_page_size-1) ? \
|
||||
((X) + Yap_page_size) & (~(Yap_page_size-1)) : \
|
||||
(X) )
|
||||
|
||||
#define BlockTrailer(b) ((YAP_SEG_SIZE *)b)[((BlockHeader *) b)->b_size]
|
||||
@ -86,9 +86,9 @@ typedef struct FREEB {
|
||||
#define FreeBlocks heap_regs->free_blocks
|
||||
|
||||
/* Operating system and architecture dependent page size */
|
||||
extern int _YAP_page_size;
|
||||
extern int Yap_page_size;
|
||||
|
||||
void STD_PROTO(_YAP_InitHeap, (void *));
|
||||
void STD_PROTO(Yap_InitHeap, (void *));
|
||||
|
||||
#if USE_MMAP
|
||||
|
||||
|
@ -554,16 +554,16 @@ typedef struct choicept {
|
||||
/* access to instructions */
|
||||
|
||||
#if USE_THREADED_CODE
|
||||
extern void **_YAP_ABSMI_OPCODES;
|
||||
extern void **Yap_ABSMI_OPCODES;
|
||||
|
||||
#define absmadr(i) ((OPCODE)(_YAP_ABSMI_OPCODES[(i)]))
|
||||
#define absmadr(i) ((OPCODE)(Yap_ABSMI_OPCODES[(i)]))
|
||||
#else
|
||||
#define absmadr(i) ((OPCODE)(i))
|
||||
#endif
|
||||
|
||||
/* used to find out how many instructions of each kind are executed */
|
||||
#ifdef ANALYST
|
||||
extern int _YAP_opcount[_std_top+1];
|
||||
extern int Yap_opcount[_std_top+1];
|
||||
#endif /* ANALYST */
|
||||
|
||||
#if DEPTH_LIMIT
|
||||
|
16
H/amiops.h
16
H/amiops.h
@ -324,7 +324,7 @@ Binding Macros for Multiple Assignment Variables.
|
||||
#define BIND_GLOBALCELL(A,D) *(A) = (D); \
|
||||
if ((A) >= HBREG) continue; \
|
||||
TRAIL_GLOBAL(A,D); if ((A) >= H0) continue; \
|
||||
_YAP_WakeUp((A)); continue
|
||||
Yap_WakeUp((A)); continue
|
||||
#else
|
||||
#define BIND_GLOBAL2(A,D,LAB,LAB1) BIND_GLOBAL(A,D,LAB)
|
||||
|
||||
@ -365,14 +365,14 @@ Unification Routines
|
||||
|
||||
*************************************************************/
|
||||
|
||||
EXTERN Int STD_PROTO(_YAP_unify,(Term,Term));
|
||||
EXTERN Int STD_PROTO(Yap_unify,(Term,Term));
|
||||
|
||||
EXTERN inline
|
||||
Int _YAP_unify(Term t0, Term t1)
|
||||
Int Yap_unify(Term t0, Term t1)
|
||||
{
|
||||
tr_fr_ptr TR0 = TR;
|
||||
|
||||
if (_YAP_IUnify(t0,t1)) {
|
||||
if (Yap_IUnify(t0,t1)) {
|
||||
return(TRUE);
|
||||
} else {
|
||||
while(TR != TR0) {
|
||||
@ -403,10 +403,10 @@ Int _YAP_unify(Term t0, Term t1)
|
||||
}
|
||||
}
|
||||
|
||||
EXTERN Int STD_PROTO(_YAP_unify_constant,(Term,Term));
|
||||
EXTERN Int STD_PROTO(Yap_unify_constant,(Term,Term));
|
||||
|
||||
EXTERN inline Int
|
||||
_YAP_unify_constant(register Term a, register Term cons)
|
||||
Yap_unify_constant(register Term a, register Term cons)
|
||||
{
|
||||
CELL *pt;
|
||||
deref_head(a,unify_cons_unk);
|
||||
@ -430,7 +430,7 @@ _YAP_unify_constant(register Term a, register Term cons)
|
||||
return(FloatOfTerm(a) == FloatOfTerm(cons));
|
||||
#ifdef USE_GMP
|
||||
case (CELL)FunctorBigInt:
|
||||
return(mpz_cmp(_YAP_BigIntOfTerm(a),_YAP_BigIntOfTerm(cons)) == 0);
|
||||
return(mpz_cmp(Yap_BigIntOfTerm(a),Yap_BigIntOfTerm(cons)) == 0);
|
||||
#endif /* USE_GMP */
|
||||
default:
|
||||
return(FALSE);
|
||||
@ -444,7 +444,7 @@ _YAP_unify_constant(register Term a, register Term cons)
|
||||
BIND(pt,cons,wake_for_cons);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(pt, cons);
|
||||
if (pt < H0) _YAP_WakeUp(pt);
|
||||
if (pt < H0) Yap_WakeUp(pt);
|
||||
wake_for_cons:
|
||||
#endif
|
||||
return(TRUE);
|
||||
|
272
H/arith2.h
272
H/arith2.h
@ -25,7 +25,7 @@ add_int(Int i, Int j E_ARGS)
|
||||
Int x = i+j;
|
||||
#if USE_GMP
|
||||
if ((i^j) >= 0 && (i^x) < 0) {
|
||||
MP_INT *new = _YAP_InitBigNum(i);
|
||||
MP_INT *new = Yap_InitBigNum(i);
|
||||
if (j > 0) {
|
||||
mpz_add_ui(new, new, j);
|
||||
RBIG(new);
|
||||
@ -69,16 +69,16 @@ p_plus(Term t1, Term t2 E_ARGS)
|
||||
case big_int_e:
|
||||
{
|
||||
Int i1 = IntegerOfTerm(t1);
|
||||
MP_INT *l2 = _YAP_BigIntOfTerm(t2);
|
||||
MP_INT *l2 = Yap_BigIntOfTerm(t2);
|
||||
|
||||
if (i1 > 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
mpz_add_ui(new, l2, i1);
|
||||
RBIG(new);
|
||||
} else if (i1 == 0) {
|
||||
RBIG(l2);
|
||||
} else {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_sub_ui(new, l2, -i1);
|
||||
RBIG(new);
|
||||
@ -103,7 +103,7 @@ p_plus(Term t1, Term t2 E_ARGS)
|
||||
RFLOAT(FloatOfTerm(t1)+FloatOfTerm(t2));
|
||||
#ifdef USE_GMP
|
||||
case big_int_e:
|
||||
RFLOAT(FloatOfTerm(t1)+mpz_get_d(_YAP_BigIntOfTerm(t2)));
|
||||
RFLOAT(FloatOfTerm(t1)+mpz_get_d(Yap_BigIntOfTerm(t2)));
|
||||
#endif
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
@ -120,17 +120,17 @@ p_plus(Term t1, Term t2 E_ARGS)
|
||||
case long_int_e:
|
||||
{
|
||||
Int i2 = IntegerOfTerm(t2);
|
||||
MP_INT *l1 = _YAP_BigIntOfTerm(t1);
|
||||
MP_INT *l1 = Yap_BigIntOfTerm(t1);
|
||||
|
||||
if (i2 > 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_add_ui(new, l1, i2);
|
||||
RBIG(new);
|
||||
} else if (i2 == 0) {
|
||||
RBIG(l1);
|
||||
} else {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_sub_ui(new, l1, -i2);
|
||||
RBIG(new);
|
||||
@ -139,16 +139,16 @@ p_plus(Term t1, Term t2 E_ARGS)
|
||||
case big_int_e:
|
||||
/* two bignums */
|
||||
{
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_add(new, _YAP_BigIntOfTerm(t1), _YAP_BigIntOfTerm(t2));
|
||||
mpz_add(new, Yap_BigIntOfTerm(t1), Yap_BigIntOfTerm(t2));
|
||||
RBIG(new);
|
||||
}
|
||||
case double_e:
|
||||
RFLOAT(mpz_get_d(_YAP_BigIntOfTerm(t1))+FloatOfTerm(t2));
|
||||
RFLOAT(mpz_get_d(Yap_BigIntOfTerm(t1))+FloatOfTerm(t2));
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.big = _YAP_BigIntOfTerm(t1);
|
||||
v1.big = Yap_BigIntOfTerm(t1);
|
||||
bt1 = big_int_e;
|
||||
bt2 = ArithIEval(t2, &v2);
|
||||
break;
|
||||
@ -174,14 +174,14 @@ p_plus(Term t1, Term t2 E_ARGS)
|
||||
case big_int_e:
|
||||
{
|
||||
if (v1.Int > 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_add_ui(new, v2.big, v1.Int);
|
||||
RBIG(new);
|
||||
} else if (v1.Int == 0) {
|
||||
RBIG(v2.big);
|
||||
} else {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_add_ui(new, v2.big, -v1.Int);
|
||||
RBIG(new);
|
||||
@ -215,14 +215,14 @@ p_plus(Term t1, Term t2 E_ARGS)
|
||||
case long_int_e:
|
||||
/* big * integer */
|
||||
if (v2.Int > 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_add_ui(new, v1.big, v2.Int);
|
||||
RBIG(new);
|
||||
} else if (v2.Int == 0) {
|
||||
RBIG(v1.big);
|
||||
} else {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_sub_ui(new, v2.big, -v1.Int);
|
||||
RBIG(new);
|
||||
@ -233,7 +233,7 @@ p_plus(Term t1, Term t2 E_ARGS)
|
||||
case big_int_e:
|
||||
/* big * big */
|
||||
{
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_add(new, v1.big, v2.big);
|
||||
RBIG(new);
|
||||
@ -279,20 +279,20 @@ p_minus(Term t1, Term t2 E_ARGS)
|
||||
case big_int_e:
|
||||
{
|
||||
Int i1 = IntegerOfTerm(t1);
|
||||
MP_INT *l2 = _YAP_BigIntOfTerm(t2);
|
||||
MP_INT *l2 = Yap_BigIntOfTerm(t2);
|
||||
|
||||
if (i1 > 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
mpz_sub_ui(new, l2, i1);
|
||||
mpz_neg(new, new);
|
||||
RBIG(new);
|
||||
} else if (i1 == 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_neg(new, l2);
|
||||
RBIG(new);
|
||||
} else {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_add_ui(new, l2, -i1);
|
||||
mpz_neg(new,new);
|
||||
@ -321,7 +321,7 @@ p_minus(Term t1, Term t2 E_ARGS)
|
||||
#ifdef USE_GMP
|
||||
case big_int_e:
|
||||
{
|
||||
RFLOAT(FloatOfTerm(t1)-mpz_get_d(_YAP_BigIntOfTerm(t2)));
|
||||
RFLOAT(FloatOfTerm(t1)-mpz_get_d(Yap_BigIntOfTerm(t2)));
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
@ -339,17 +339,17 @@ p_minus(Term t1, Term t2 E_ARGS)
|
||||
case long_int_e:
|
||||
{
|
||||
Int i2 = IntegerOfTerm(t2);
|
||||
MP_INT *l1 = _YAP_BigIntOfTerm(t1);
|
||||
MP_INT *l1 = Yap_BigIntOfTerm(t1);
|
||||
|
||||
if (i2 > 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_sub_ui(new, l1, i2);
|
||||
RBIG(new);
|
||||
} else if (i2 == 0) {
|
||||
RBIG(l1);
|
||||
} else {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_add_ui(new, l1, -i2);
|
||||
RBIG(new);
|
||||
@ -358,18 +358,18 @@ p_minus(Term t1, Term t2 E_ARGS)
|
||||
case big_int_e:
|
||||
/* two bignums */
|
||||
{
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_sub(new, _YAP_BigIntOfTerm(t1), _YAP_BigIntOfTerm(t2));
|
||||
mpz_sub(new, Yap_BigIntOfTerm(t1), Yap_BigIntOfTerm(t2));
|
||||
RBIG(new);
|
||||
}
|
||||
case double_e:
|
||||
{
|
||||
RFLOAT(mpz_get_d(_YAP_BigIntOfTerm(t1))-FloatOfTerm(t2));
|
||||
RFLOAT(mpz_get_d(Yap_BigIntOfTerm(t1))-FloatOfTerm(t2));
|
||||
}
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.big = _YAP_BigIntOfTerm(t1);
|
||||
v1.big = Yap_BigIntOfTerm(t1);
|
||||
bt1 = big_int_e;
|
||||
bt2 = ArithIEval(t2, &v2);
|
||||
break;
|
||||
@ -397,17 +397,17 @@ p_minus(Term t1, Term t2 E_ARGS)
|
||||
case big_int_e:
|
||||
{
|
||||
if (v1.Int > 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_sub_ui(new, v2.big, v1.Int);
|
||||
mpz_neg(new, new);
|
||||
RBIG(new);
|
||||
} else if (v1.Int == 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
mpz_neg(new, v2.big);
|
||||
RBIG(new);
|
||||
} else {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_add_ui(new, v2.big, -v1.Int);
|
||||
mpz_neg(new, new);
|
||||
@ -442,14 +442,14 @@ p_minus(Term t1, Term t2 E_ARGS)
|
||||
case long_int_e:
|
||||
/* big * integer */
|
||||
if (v2.Int > 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_sub_ui(new, v1.big, v2.Int);
|
||||
RBIG(new);
|
||||
} else if (v2.Int == 0) {
|
||||
RBIG(v1.big);
|
||||
} else {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_add_ui(new, v2.big, -v1.Int);
|
||||
RBIG(new);
|
||||
@ -460,7 +460,7 @@ p_minus(Term t1, Term t2 E_ARGS)
|
||||
case big_int_e:
|
||||
/* big * big */
|
||||
{
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_sub(new, v1.big, v2.big);
|
||||
RBIG(new);
|
||||
@ -504,7 +504,7 @@ times_int(Int i1, Int i2 E_ARGS) {
|
||||
RINT(z);
|
||||
overflow:
|
||||
{
|
||||
MP_INT *new = _YAP_InitBigNum(i1);
|
||||
MP_INT *new = Yap_InitBigNum(i1);
|
||||
if (i2 > 0) {
|
||||
mpz_mul_ui(new, new, i2);
|
||||
RBIG(new);
|
||||
@ -549,16 +549,16 @@ p_times(Term t1, Term t2 E_ARGS)
|
||||
case big_int_e:
|
||||
{
|
||||
Int i1 = IntegerOfTerm(t1);
|
||||
MP_INT *l2 = _YAP_BigIntOfTerm(t2);
|
||||
MP_INT *l2 = Yap_BigIntOfTerm(t2);
|
||||
|
||||
if (i1 > 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
mpz_mul_ui(new, l2, i1);
|
||||
RBIG(new);
|
||||
} else if (i1 == 0) {
|
||||
RINT(0);
|
||||
} else {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_mul_ui(new, l2, -i1);
|
||||
mpz_neg(new, new);
|
||||
@ -587,7 +587,7 @@ p_times(Term t1, Term t2 E_ARGS)
|
||||
#ifdef USE_GMP
|
||||
case big_int_e:
|
||||
{
|
||||
RFLOAT(FloatOfTerm(t1)*mpz_get_d(_YAP_BigIntOfTerm(t2)));
|
||||
RFLOAT(FloatOfTerm(t1)*mpz_get_d(Yap_BigIntOfTerm(t2)));
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
@ -605,17 +605,17 @@ p_times(Term t1, Term t2 E_ARGS)
|
||||
case long_int_e:
|
||||
{
|
||||
Int i2 = IntegerOfTerm(t2);
|
||||
MP_INT *l1 = _YAP_BigIntOfTerm(t1);
|
||||
MP_INT *l1 = Yap_BigIntOfTerm(t1);
|
||||
|
||||
if (i2 > 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_mul_ui(new, l1, i2);
|
||||
RBIG(new);
|
||||
} else if (i2 == 0) {
|
||||
RINT(0);
|
||||
} else {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_mul_ui(new, l1, -i2);
|
||||
mpz_neg(new, new);
|
||||
@ -625,18 +625,18 @@ p_times(Term t1, Term t2 E_ARGS)
|
||||
case big_int_e:
|
||||
/* two bignums */
|
||||
{
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_mul(new, _YAP_BigIntOfTerm(t1), _YAP_BigIntOfTerm(t2));
|
||||
mpz_mul(new, Yap_BigIntOfTerm(t1), Yap_BigIntOfTerm(t2));
|
||||
RBIG(new);
|
||||
}
|
||||
case double_e:
|
||||
{
|
||||
RFLOAT(mpz_get_d(_YAP_BigIntOfTerm(t1))*FloatOfTerm(t2));
|
||||
RFLOAT(mpz_get_d(Yap_BigIntOfTerm(t1))*FloatOfTerm(t2));
|
||||
}
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.big = _YAP_BigIntOfTerm(t1);
|
||||
v1.big = Yap_BigIntOfTerm(t1);
|
||||
bt1 = big_int_e;
|
||||
bt2 = ArithIEval(t2, &v2);
|
||||
break;
|
||||
@ -664,14 +664,14 @@ p_times(Term t1, Term t2 E_ARGS)
|
||||
case big_int_e:
|
||||
{
|
||||
if (v1.Int > 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_mul_ui(new, v2.big, v1.Int);
|
||||
RBIG(new);
|
||||
} else if (v1.Int == 0) {
|
||||
RINT(0);
|
||||
} else {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_mul_ui(new, v2.big, -v1.Int);
|
||||
mpz_neg(new, new);
|
||||
@ -706,14 +706,14 @@ p_times(Term t1, Term t2 E_ARGS)
|
||||
case long_int_e:
|
||||
/* big * integer */
|
||||
if (v2.Int > 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_mul_ui(new, v1.big, v2.Int);
|
||||
RBIG(new);
|
||||
} else if (v2.Int == 0) {
|
||||
RINT(0);
|
||||
} else {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_mul_ui(new, v2.big, -v1.Int);
|
||||
mpz_neg(new, new);
|
||||
@ -725,7 +725,7 @@ p_times(Term t1, Term t2 E_ARGS)
|
||||
case big_int_e:
|
||||
/* big * big */
|
||||
{
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_mul(new, v1.big, v2.big);
|
||||
RBIG(new);
|
||||
@ -762,7 +762,7 @@ p_div(Term t1, Term t2 E_ARGS)
|
||||
Int i2 = IntegerOfTerm(t2);
|
||||
|
||||
if (i2 == 0) {
|
||||
_YAP_Error(EVALUATION_ERROR_ZERO_DIVISOR, t2, "// /2");
|
||||
Yap_Error(EVALUATION_ERROR_ZERO_DIVISOR, t2, "// /2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
@ -770,7 +770,7 @@ p_div(Term t1, Term t2 E_ARGS)
|
||||
RINT(IntegerOfTerm(t1) / i2);
|
||||
}
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t2, "// /2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t2, "// /2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
@ -787,7 +787,7 @@ p_div(Term t1, Term t2 E_ARGS)
|
||||
}
|
||||
break;
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t1, "// /2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t1, "// /2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
@ -799,20 +799,20 @@ p_div(Term t1, Term t2 E_ARGS)
|
||||
/* dividing a bignum by an integer */
|
||||
{
|
||||
Int i2 = IntegerOfTerm(t2);
|
||||
MP_INT *l1 = _YAP_BigIntOfTerm(t1);
|
||||
MP_INT *l1 = Yap_BigIntOfTerm(t1);
|
||||
|
||||
if (i2 > 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_tdiv_q_ui(new, l1, i2);
|
||||
RBIG(new);
|
||||
} else if (i2 == 0) {
|
||||
_YAP_Error(EVALUATION_ERROR_ZERO_DIVISOR, t2, "// /2");
|
||||
Yap_Error(EVALUATION_ERROR_ZERO_DIVISOR, t2, "// /2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
} else {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_tdiv_q_ui(new, l1, -i2);
|
||||
mpz_neg(new, new);
|
||||
@ -822,19 +822,19 @@ p_div(Term t1, Term t2 E_ARGS)
|
||||
case big_int_e:
|
||||
/* two bignums */
|
||||
{
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_tdiv_q(new, _YAP_BigIntOfTerm(t1), _YAP_BigIntOfTerm(t2));
|
||||
mpz_tdiv_q(new, Yap_BigIntOfTerm(t1), Yap_BigIntOfTerm(t2));
|
||||
RBIG(new);
|
||||
}
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t2, "// /2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t2, "// /2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.big = _YAP_BigIntOfTerm(t1);
|
||||
v1.big = Yap_BigIntOfTerm(t1);
|
||||
bt1 = big_int_e;
|
||||
bt2 = ArithIEval(t2, &v2);
|
||||
break;
|
||||
@ -853,14 +853,14 @@ p_div(Term t1, Term t2 E_ARGS)
|
||||
case long_int_e:
|
||||
/* two integers */
|
||||
if (v2.Int == 0) {
|
||||
_YAP_Error(EVALUATION_ERROR_ZERO_DIVISOR, t2, "// /2");
|
||||
Yap_Error(EVALUATION_ERROR_ZERO_DIVISOR, t2, "// /2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
}
|
||||
RINT(v1.Int / v2.Int);
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "// /2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "// /2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
@ -870,11 +870,11 @@ p_div(Term t1, Term t2 E_ARGS)
|
||||
RINT(0);
|
||||
#endif
|
||||
default:
|
||||
/* _YAP_Error */
|
||||
/* Yap_Error */
|
||||
RERROR();
|
||||
}
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), "// /2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), "// /2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
@ -883,17 +883,17 @@ p_div(Term t1, Term t2 E_ARGS)
|
||||
case long_int_e:
|
||||
/* big // integer */
|
||||
if (v2.Int > 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_tdiv_q_ui(new, v1.big, v2.Int);
|
||||
RBIG(new);
|
||||
} else if (v2.Int == 0) {
|
||||
_YAP_Error(EVALUATION_ERROR_ZERO_DIVISOR, t2, "// /2");
|
||||
Yap_Error(EVALUATION_ERROR_ZERO_DIVISOR, t2, "// /2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
} else {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_tdiv_q_ui(new, v2.big, -v1.Int);
|
||||
mpz_neg(new, new);
|
||||
@ -901,14 +901,14 @@ p_div(Term t1, Term t2 E_ARGS)
|
||||
}
|
||||
case double_e:
|
||||
/* big // float */
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "// /2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "// /2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
case big_int_e:
|
||||
/* big * big */
|
||||
{
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_tdiv_q(new, v1.big, v2.big);
|
||||
RBIG(new);
|
||||
@ -943,13 +943,13 @@ p_and(Term t1, Term t2 E_ARGS)
|
||||
/* two integers */
|
||||
RINT(IntegerOfTerm(t1) & IntegerOfTerm(t2));
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t2, "/\\ /2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t2, "/\\ /2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
case big_int_e:
|
||||
{
|
||||
unsigned long int i2 = mpz_get_ui(_YAP_BigIntOfTerm(t2));
|
||||
unsigned long int i2 = mpz_get_ui(Yap_BigIntOfTerm(t2));
|
||||
RINT(IntegerOfTerm(t1) & i2);
|
||||
}
|
||||
#endif
|
||||
@ -961,7 +961,7 @@ p_and(Term t1, Term t2 E_ARGS)
|
||||
}
|
||||
break;
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t1, "/\\ /2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t1, "/\\ /2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
@ -972,25 +972,25 @@ p_and(Term t1, Term t2 E_ARGS)
|
||||
case long_int_e:
|
||||
/* anding a bignum with an integer is easy */
|
||||
{
|
||||
unsigned long int i1 = mpz_get_ui(_YAP_BigIntOfTerm(t1));
|
||||
unsigned long int i1 = mpz_get_ui(Yap_BigIntOfTerm(t1));
|
||||
RINT(i1 & IntegerOfTerm(t2));
|
||||
}
|
||||
case big_int_e:
|
||||
/* two bignums */
|
||||
{
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_and(new, _YAP_BigIntOfTerm(t1), _YAP_BigIntOfTerm(t2));
|
||||
mpz_and(new, Yap_BigIntOfTerm(t1), Yap_BigIntOfTerm(t2));
|
||||
RBIG(new);
|
||||
}
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t2, "/\\ /2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t2, "/\\ /2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.big = _YAP_BigIntOfTerm(t1);
|
||||
v1.big = Yap_BigIntOfTerm(t1);
|
||||
bt1 = big_int_e;
|
||||
bt2 = ArithIEval(t2, &v2);
|
||||
break;
|
||||
@ -1009,7 +1009,7 @@ p_and(Term t1, Term t2 E_ARGS)
|
||||
case long_int_e:
|
||||
RINT(v1.Int & v2.Int);
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "/\\ /2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "/\\ /2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
@ -1021,11 +1021,11 @@ p_and(Term t1, Term t2 E_ARGS)
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
/* _YAP_Error */
|
||||
/* Yap_Error */
|
||||
RERROR();
|
||||
}
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), "/\\ /2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), "/\\ /2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
@ -1039,14 +1039,14 @@ p_and(Term t1, Term t2 E_ARGS)
|
||||
}
|
||||
case double_e:
|
||||
/* big // float */
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "/\\ /2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "/\\ /2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
case big_int_e:
|
||||
/* big * big */
|
||||
{
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_and(new, v1.big, v2.big);
|
||||
RBIG(new);
|
||||
@ -1081,16 +1081,16 @@ p_or(Term t1, Term t2 E_ARGS)
|
||||
/* two integers */
|
||||
RINT(IntegerOfTerm(t1) | IntegerOfTerm(t2));
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t2, "\\/ /2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t2, "\\/ /2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
case big_int_e:
|
||||
{
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_set_si(new,IntOfTerm(t1));
|
||||
mpz_ior(new, new, _YAP_BigIntOfTerm(t2));
|
||||
mpz_ior(new, new, Yap_BigIntOfTerm(t2));
|
||||
RBIG(new);
|
||||
}
|
||||
#endif
|
||||
@ -1102,7 +1102,7 @@ p_or(Term t1, Term t2 E_ARGS)
|
||||
}
|
||||
break;
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t1, "\\/ /2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t1, "\\/ /2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
@ -1112,28 +1112,28 @@ p_or(Term t1, Term t2 E_ARGS)
|
||||
switch (BlobOfFunctor(f2)) {
|
||||
case long_int_e:
|
||||
{
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_set_si(new,IntOfTerm(t2));
|
||||
mpz_ior(new, _YAP_BigIntOfTerm(t1), new);
|
||||
mpz_ior(new, Yap_BigIntOfTerm(t1), new);
|
||||
RBIG(new);
|
||||
}
|
||||
case big_int_e:
|
||||
/* two bignums */
|
||||
{
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_ior(new, _YAP_BigIntOfTerm(t1), _YAP_BigIntOfTerm(t2));
|
||||
mpz_ior(new, Yap_BigIntOfTerm(t1), Yap_BigIntOfTerm(t2));
|
||||
RBIG(new);
|
||||
}
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t2, "\\/ /2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t2, "\\/ /2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.big = _YAP_BigIntOfTerm(t1);
|
||||
v1.big = Yap_BigIntOfTerm(t1);
|
||||
bt1 = big_int_e;
|
||||
bt2 = ArithIEval(t2, &v2);
|
||||
break;
|
||||
@ -1152,14 +1152,14 @@ p_or(Term t1, Term t2 E_ARGS)
|
||||
case long_int_e:
|
||||
RINT(v1.Int | v2.Int);
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "\\/ /2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "\\/ /2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
case big_int_e:
|
||||
{
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_set_si(new,v1.Int);
|
||||
|
||||
@ -1168,11 +1168,11 @@ p_or(Term t1, Term t2 E_ARGS)
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
/* _YAP_Error */
|
||||
/* Yap_Error */
|
||||
RERROR();
|
||||
}
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), "\\/ /2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), "\\/ /2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
@ -1181,7 +1181,7 @@ p_or(Term t1, Term t2 E_ARGS)
|
||||
case long_int_e:
|
||||
/* anding a bignum with an integer is easy */
|
||||
{
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_set_si(new, v2.Int);
|
||||
mpz_ior(new, v1.big, new);
|
||||
@ -1189,14 +1189,14 @@ p_or(Term t1, Term t2 E_ARGS)
|
||||
}
|
||||
case double_e:
|
||||
/* big // float */
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "\\/ /2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "\\/ /2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
case big_int_e:
|
||||
/* big * big */
|
||||
{
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_ior(new, v1.big, v2.big);
|
||||
RBIG(new);
|
||||
@ -1234,12 +1234,12 @@ p_sll(Term t1, Term t2 E_ARGS)
|
||||
/* two integers */
|
||||
RINT(IntegerOfTerm(t1) << IntegerOfTerm(t2));
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t2, "<</2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t2, "<</2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
case big_int_e:
|
||||
_YAP_Error(DOMAIN_ERROR_SHIFT_COUNT_OVERFLOW, t2, "<</2");
|
||||
Yap_Error(DOMAIN_ERROR_SHIFT_COUNT_OVERFLOW, t2, "<</2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#endif
|
||||
@ -1251,7 +1251,7 @@ p_sll(Term t1, Term t2 E_ARGS)
|
||||
}
|
||||
break;
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t1, "<< /2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t1, "<< /2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
@ -1262,33 +1262,33 @@ p_sll(Term t1, Term t2 E_ARGS)
|
||||
case long_int_e:
|
||||
{
|
||||
Int i2 = IntegerOfTerm(t2);
|
||||
MP_INT *l1 = _YAP_BigIntOfTerm(t1);
|
||||
MP_INT *l1 = Yap_BigIntOfTerm(t1);
|
||||
|
||||
if (i2 > 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
mpz_mul_2exp(new, l1, i2);
|
||||
RBIG(new);
|
||||
} else if (i2 == 0) {
|
||||
RBIG(l1);
|
||||
} else {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_tdiv_q_2exp(new, l1, -i2);
|
||||
RBIG(new);
|
||||
}
|
||||
}
|
||||
case big_int_e:
|
||||
_YAP_Error(DOMAIN_ERROR_SHIFT_COUNT_OVERFLOW, t2, "<</2");
|
||||
Yap_Error(DOMAIN_ERROR_SHIFT_COUNT_OVERFLOW, t2, "<</2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t2, "<</2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t2, "<</2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.big = _YAP_BigIntOfTerm(t1);
|
||||
v1.big = Yap_BigIntOfTerm(t1);
|
||||
bt1 = big_int_e;
|
||||
bt2 = ArithIEval(t2, &v2);
|
||||
break;
|
||||
@ -1307,22 +1307,22 @@ p_sll(Term t1, Term t2 E_ARGS)
|
||||
case long_int_e:
|
||||
RINT(v1.Int << v2.Int);
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "<</2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "<</2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
case big_int_e:
|
||||
_YAP_Error(DOMAIN_ERROR_SHIFT_COUNT_OVERFLOW, t2, "<</2");
|
||||
Yap_Error(DOMAIN_ERROR_SHIFT_COUNT_OVERFLOW, t2, "<</2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#endif
|
||||
default:
|
||||
/* _YAP_Error */
|
||||
/* Yap_Error */
|
||||
RERROR();
|
||||
}
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), "<</2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), "<</2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
@ -1332,13 +1332,13 @@ p_sll(Term t1, Term t2 E_ARGS)
|
||||
/* big << int */
|
||||
{
|
||||
if (v2.Int > 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
mpz_mul_2exp(new, v1.big, v2.Int);
|
||||
RBIG(new);
|
||||
} else if (v2.Int == 0) {
|
||||
RBIG(v1.big);
|
||||
} else {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_tdiv_q_2exp(new, v1.big, -v2.Int);
|
||||
RBIG(new);
|
||||
@ -1346,13 +1346,13 @@ p_sll(Term t1, Term t2 E_ARGS)
|
||||
}
|
||||
case double_e:
|
||||
/* big << float */
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "<</2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), "<</2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
case big_int_e:
|
||||
/* big << big */
|
||||
_YAP_Error(DOMAIN_ERROR_SHIFT_COUNT_OVERFLOW, t2, "<</2");
|
||||
Yap_Error(DOMAIN_ERROR_SHIFT_COUNT_OVERFLOW, t2, "<</2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
default:
|
||||
@ -1388,12 +1388,12 @@ p_slr(Term t1, Term t2 E_ARGS)
|
||||
/* two integers */
|
||||
RINT(IntegerOfTerm(t1) >> IntegerOfTerm(t2));
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t2, ">>/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t2, ">>/2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
case big_int_e:
|
||||
_YAP_Error(DOMAIN_ERROR_SHIFT_COUNT_OVERFLOW, t2, ">>/2");
|
||||
Yap_Error(DOMAIN_ERROR_SHIFT_COUNT_OVERFLOW, t2, ">>/2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#endif
|
||||
@ -1405,7 +1405,7 @@ p_slr(Term t1, Term t2 E_ARGS)
|
||||
}
|
||||
break;
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t1, ">>/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t1, ">>/2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
@ -1416,33 +1416,33 @@ p_slr(Term t1, Term t2 E_ARGS)
|
||||
case long_int_e:
|
||||
{
|
||||
Int i2 = IntegerOfTerm(t2);
|
||||
MP_INT *l1 = _YAP_BigIntOfTerm(t1);
|
||||
MP_INT *l1 = Yap_BigIntOfTerm(t1);
|
||||
|
||||
if (i2 > 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
mpz_tdiv_q_2exp(new, l1, i2);
|
||||
RBIG(new);
|
||||
} else if (i2 == 0) {
|
||||
RBIG(l1);
|
||||
} else {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_mul_2exp(new, l1, -i2);
|
||||
RBIG(new);
|
||||
}
|
||||
}
|
||||
case big_int_e:
|
||||
_YAP_Error(DOMAIN_ERROR_SHIFT_COUNT_OVERFLOW, t2, ">>/2");
|
||||
Yap_Error(DOMAIN_ERROR_SHIFT_COUNT_OVERFLOW, t2, ">>/2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t2, ">>/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t2, ">>/2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
v1.big = _YAP_BigIntOfTerm(t1);
|
||||
v1.big = Yap_BigIntOfTerm(t1);
|
||||
bt1 = big_int_e;
|
||||
bt2 = ArithIEval(t2, &v2);
|
||||
break;
|
||||
@ -1461,22 +1461,22 @@ p_slr(Term t1, Term t2 E_ARGS)
|
||||
case long_int_e:
|
||||
RINT(v1.Int >> v2.Int);
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), ">>/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), ">>/2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
case big_int_e:
|
||||
_YAP_Error(DOMAIN_ERROR_SHIFT_COUNT_OVERFLOW, t2, ">>/2");
|
||||
Yap_Error(DOMAIN_ERROR_SHIFT_COUNT_OVERFLOW, t2, ">>/2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#endif
|
||||
default:
|
||||
/* _YAP_Error */
|
||||
/* Yap_Error */
|
||||
RERROR();
|
||||
}
|
||||
case double_e:
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), ">>/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), ">>/2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
@ -1486,13 +1486,13 @@ p_slr(Term t1, Term t2 E_ARGS)
|
||||
/* big >> int */
|
||||
{
|
||||
if (v2.Int > 0) {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
mpz_tdiv_q_2exp(new, v1.big, v2.Int);
|
||||
RBIG(new);
|
||||
} else if (v2.Int == 0) {
|
||||
RBIG(v1.big);
|
||||
} else {
|
||||
MP_INT *new = _YAP_PreAllocBigNum();
|
||||
MP_INT *new = Yap_PreAllocBigNum();
|
||||
|
||||
mpz_mul_2exp(new, v1.big, -v2.Int);
|
||||
RBIG(new);
|
||||
@ -1500,13 +1500,13 @@ p_slr(Term t1, Term t2 E_ARGS)
|
||||
}
|
||||
case double_e:
|
||||
/* big >> float */
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), ">>/2");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v2.dbl), ">>/2");
|
||||
/* make GCC happy */
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
case big_int_e:
|
||||
/* big >> big */
|
||||
_YAP_Error(DOMAIN_ERROR_SHIFT_COUNT_OVERFLOW, t2, ">>/2");
|
||||
Yap_Error(DOMAIN_ERROR_SHIFT_COUNT_OVERFLOW, t2, ">>/2");
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
default:
|
||||
|
@ -117,8 +117,8 @@ typedef struct clause_struct {
|
||||
#endif
|
||||
|
||||
/* cdmgr.c */
|
||||
void STD_PROTO(_YAP_RemoveLogUpdIndex,(Clause *));
|
||||
void STD_PROTO(_YAP_IPred,(CODEADDR sp));
|
||||
void STD_PROTO(Yap_RemoveLogUpdIndex,(Clause *));
|
||||
void STD_PROTO(Yap_IPred,(CODEADDR sp));
|
||||
|
||||
/* dbase.c */
|
||||
void STD_PROTO(_YAP_ErCl,(Clause *));
|
||||
void STD_PROTO(Yap_ErCl,(Clause *));
|
||||
|
18
H/compile.h
18
H/compile.h
@ -250,17 +250,17 @@ typedef struct CEXPENTRY {
|
||||
#define Two 2
|
||||
|
||||
|
||||
CODEADDR STD_PROTO(_YAP_assemble,(int));
|
||||
void STD_PROTO(_YAP_emit,(compiler_vm_op,Int,CELL));
|
||||
void STD_PROTO(_YAP_emit_3ops,(compiler_vm_op,CELL,CELL,CELL));
|
||||
CELL *STD_PROTO(_YAP_emit_extra_size,(compiler_vm_op,CELL,int));
|
||||
char *STD_PROTO(_YAP_AllocCMem,(int));
|
||||
int STD_PROTO(_YAP_is_a_test_pred,(Term, SMALLUNSGN));
|
||||
void STD_PROTO(_YAP_bip_name,(Int, char *));
|
||||
CODEADDR STD_PROTO(Yap_assemble,(int));
|
||||
void STD_PROTO(Yap_emit,(compiler_vm_op,Int,CELL));
|
||||
void STD_PROTO(Yap_emit_3ops,(compiler_vm_op,CELL,CELL,CELL));
|
||||
CELL *STD_PROTO(Yap_emit_extra_size,(compiler_vm_op,CELL,int));
|
||||
char *STD_PROTO(Yap_AllocCMem,(int));
|
||||
int STD_PROTO(Yap_is_a_test_pred,(Term, SMALLUNSGN));
|
||||
void STD_PROTO(Yap_bip_name,(Int, char *));
|
||||
#ifdef DEBUG
|
||||
void STD_PROTO(_YAP_ShowCode,(void));
|
||||
void STD_PROTO(Yap_ShowCode,(void));
|
||||
#endif /* DEBUG */
|
||||
|
||||
|
||||
extern jmp_buf _YAP_CompilerBotch;
|
||||
extern jmp_buf Yap_CompilerBotch;
|
||||
|
||||
|
20
H/eval.h
20
H/eval.h
@ -50,8 +50,8 @@ typedef union arith_ret {
|
||||
/*
|
||||
#define RINT(v) return(MkIntegerTerm(v))
|
||||
#define RFLOAT(v) return(MkFloatTerm(v))
|
||||
#define RBIG(v) return(_YAP_MkBigIntTerm(v))
|
||||
#define RBIG_FL(v) return(_YAP_MkBigIntTerm((MP_INT *)(Int)v))
|
||||
#define RBIG(v) return(Yap_MkBigIntTerm(v))
|
||||
#define RBIG_FL(v) return(Yap_MkBigIntTerm((MP_INT *)(Int)v))
|
||||
#define RERROR() return(MkIntTerm(0))
|
||||
*/
|
||||
|
||||
@ -88,14 +88,14 @@ Functor STD_PROTO(EvalArg,(Term,arith_retptr));
|
||||
#define FL(X) ((double)(X))
|
||||
#endif
|
||||
|
||||
extern yap_error_number _YAP_matherror;
|
||||
extern yap_error_number Yap_matherror;
|
||||
|
||||
void STD_PROTO(_YAP_InitConstExps,(void));
|
||||
void STD_PROTO(_YAP_InitUnaryExps,(void));
|
||||
void STD_PROTO(_YAP_InitBinaryExps,(void));
|
||||
void STD_PROTO(Yap_InitConstExps,(void));
|
||||
void STD_PROTO(Yap_InitUnaryExps,(void));
|
||||
void STD_PROTO(Yap_InitBinaryExps,(void));
|
||||
|
||||
int STD_PROTO(_YAP_ReInitConstExps,(void));
|
||||
int STD_PROTO(_YAP_ReInitUnaryExps,(void));
|
||||
int STD_PROTO(_YAP_ReInitBinaryExps,(void));
|
||||
int STD_PROTO(Yap_ReInitConstExps,(void));
|
||||
int STD_PROTO(Yap_ReInitUnaryExps,(void));
|
||||
int STD_PROTO(Yap_ReInitBinaryExps,(void));
|
||||
|
||||
blob_type STD_PROTO(_YAP_Eval,(Term, union arith_ret *));
|
||||
blob_type STD_PROTO(Yap_Eval,(Term, union arith_ret *));
|
||||
|
@ -51,7 +51,7 @@
|
||||
#define ONHEAP(ptr) (CellPtr(ptr) >= H0 && CellPtr(ptr) < H)
|
||||
|
||||
/* is ptr a pointer to code space? */
|
||||
#define ONCODE(ptr) (Addr(ptr) < HeapTop && Addr(ptr) >= _YAP_HeapBase)
|
||||
#define ONCODE(ptr) (Addr(ptr) < HeapTop && Addr(ptr) >= Yap_HeapBase)
|
||||
|
||||
/* is val pointing to something bound to the heap? */
|
||||
|
||||
@ -138,9 +138,9 @@ typedef CELL *CELL_PTR;
|
||||
|
||||
#define ENVSIZE(E) EnvSize(((CELL *)E)[E_CP])
|
||||
|
||||
void STD_PROTO(_YAP_mark_variable, (CELL *));
|
||||
void STD_PROTO(_YAP_mark_external_reference, (CELL *));
|
||||
void STD_PROTO(_YAP_inc_mark_variable, (void));
|
||||
void STD_PROTO(Yap_mark_variable, (CELL *));
|
||||
void STD_PROTO(Yap_mark_external_reference, (CELL *));
|
||||
void STD_PROTO(Yap_inc_mark_variable, (void));
|
||||
|
||||
|
||||
|
||||
|
@ -103,11 +103,11 @@ StreamDesc;
|
||||
|
||||
#define ALIASES_BLOCK_SIZE 8
|
||||
|
||||
void STD_PROTO (_YAP_InitStdStreams, (void));
|
||||
void STD_PROTO (Yap_InitStdStreams, (void));
|
||||
|
||||
EXTERN inline int
|
||||
GetCurInpPos (void)
|
||||
{
|
||||
return (Stream[_YAP_c_input_stream].linecount);
|
||||
return (Stream[Yap_c_input_stream].linecount);
|
||||
}
|
||||
|
||||
|
70
H/rheap.h
70
H/rheap.h
@ -39,37 +39,37 @@ restore_codes(void)
|
||||
{
|
||||
heap_regs->heap_top = AddrAdjust(OldHeapTop);
|
||||
#ifdef YAPOR
|
||||
heap_regs->getworkfirsttimecode.opc = _YAP_opcode(_getwork_first_time);
|
||||
heap_regs->getworkcode.opc = _YAP_opcode(_getwork);
|
||||
heap_regs->getworkfirsttimecode.opc = Yap_opcode(_getwork_first_time);
|
||||
heap_regs->getworkcode.opc = Yap_opcode(_getwork);
|
||||
INIT_YAMOP_LTT(&(heap_regs->getworkcode), 0);
|
||||
heap_regs->getworkcode_seq.opc = _YAP_opcode(_getwork_seq);
|
||||
heap_regs->getworkcode_seq.opc = Yap_opcode(_getwork_seq);
|
||||
INIT_YAMOP_LTT(&(heap_regs->getworkcode_seq), 0);
|
||||
#endif /* YAPOR */
|
||||
#ifdef TABLING
|
||||
heap_regs->tablecompletioncode.opc = _YAP_opcode(_table_completion);
|
||||
heap_regs->tableanswerresolutioncode.opc = _YAP_opcode(_table_answer_resolution);
|
||||
heap_regs->tablecompletioncode.opc = Yap_opcode(_table_completion);
|
||||
heap_regs->tableanswerresolutioncode.opc = Yap_opcode(_table_answer_resolution);
|
||||
#ifdef YAPOR
|
||||
INIT_YAMOP_LTT(&(heap_regs->tablecompletioncode), 0);
|
||||
INIT_YAMOP_LTT(&(heap_regs->tableanswerresolutioncode), 0);
|
||||
#endif /* YAPOR */
|
||||
#endif /* TABLING */
|
||||
heap_regs->failcode = _YAP_opcode(_op_fail);
|
||||
heap_regs->failcode_1 = _YAP_opcode(_op_fail);
|
||||
heap_regs->failcode_2 = _YAP_opcode(_op_fail);
|
||||
heap_regs->failcode_3 = _YAP_opcode(_op_fail);
|
||||
heap_regs->failcode_4 = _YAP_opcode(_op_fail);
|
||||
heap_regs->failcode_5 = _YAP_opcode(_op_fail);
|
||||
heap_regs->failcode_6 = _YAP_opcode(_op_fail);
|
||||
heap_regs->failcode = Yap_opcode(_op_fail);
|
||||
heap_regs->failcode_1 = Yap_opcode(_op_fail);
|
||||
heap_regs->failcode_2 = Yap_opcode(_op_fail);
|
||||
heap_regs->failcode_3 = Yap_opcode(_op_fail);
|
||||
heap_regs->failcode_4 = Yap_opcode(_op_fail);
|
||||
heap_regs->failcode_5 = Yap_opcode(_op_fail);
|
||||
heap_regs->failcode_6 = Yap_opcode(_op_fail);
|
||||
|
||||
heap_regs->env_for_trustfail_code.op = _YAP_opcode(_call);
|
||||
heap_regs->trustfailcode = _YAP_opcode(_trust_fail);
|
||||
heap_regs->env_for_trustfail_code.op = Yap_opcode(_call);
|
||||
heap_regs->trustfailcode = Yap_opcode(_trust_fail);
|
||||
|
||||
heap_regs->env_for_yes_code.op = _YAP_opcode(_call);
|
||||
heap_regs->yescode.opc = _YAP_opcode(_Ystop);
|
||||
heap_regs->undef_op = _YAP_opcode(_undef_p);
|
||||
heap_regs->index_op = _YAP_opcode(_index_pred);
|
||||
heap_regs->fail_op = _YAP_opcode(_op_fail);
|
||||
heap_regs->nocode.opc = _YAP_opcode(_Nstop);
|
||||
heap_regs->env_for_yes_code.op = Yap_opcode(_call);
|
||||
heap_regs->yescode.opc = Yap_opcode(_Ystop);
|
||||
heap_regs->undef_op = Yap_opcode(_undef_p);
|
||||
heap_regs->index_op = Yap_opcode(_index_pred);
|
||||
heap_regs->fail_op = Yap_opcode(_op_fail);
|
||||
heap_regs->nocode.opc = Yap_opcode(_Nstop);
|
||||
#ifdef YAPOR
|
||||
INIT_YAMOP_LTT(&(heap_regs->nocode), 1);
|
||||
#endif /* YAPOR */
|
||||
@ -77,7 +77,7 @@ restore_codes(void)
|
||||
#ifdef YAPOR
|
||||
INIT_YAMOP_LTT(&(heap_regs->rtrycode), 1);
|
||||
#endif /* YAPOR */
|
||||
((yamop *)(&heap_regs->rtrycode))->opc = _YAP_opcode(_retry_and_mark);
|
||||
((yamop *)(&heap_regs->rtrycode))->opc = Yap_opcode(_retry_and_mark);
|
||||
if (((yamop *)(&heap_regs->rtrycode))->u.ld.d != NIL)
|
||||
((yamop *)(&heap_regs->rtrycode))->u.ld.d =
|
||||
CodeAddrAdjust(((yamop *)(&heap_regs->rtrycode))->u.ld.d);
|
||||
@ -490,7 +490,7 @@ RestoreDBEntry(DBRef dbr)
|
||||
if (dbr->Flags & DBWithRefs) {
|
||||
DBRef *cp;
|
||||
DBRef tm;
|
||||
cp = (DBRef *) ((CODEADDR) dbr + _YAP_SizeOfBlock(CodePtr(dbr)));
|
||||
cp = (DBRef *) ((CODEADDR) dbr + Yap_SizeOfBlock(CodePtr(dbr)));
|
||||
while ((tm = *--cp) != 0)
|
||||
*cp = DBRefAdjust(tm);
|
||||
}
|
||||
@ -588,8 +588,8 @@ RestoreClause(Clause *Cl, int mode)
|
||||
/* Get the stored operator */
|
||||
pc = Cl->ClCode;
|
||||
do {
|
||||
op_numbers op = _YAP_op_from_opcode(pc->opc);
|
||||
pc->opc = _YAP_opcode(op);
|
||||
op_numbers op = Yap_op_from_opcode(pc->opc);
|
||||
pc->opc = Yap_opcode(op);
|
||||
#ifdef DEBUG_RESTORE2
|
||||
YP_fprintf(errout, "%s\n", op_names[op]);
|
||||
#endif
|
||||
@ -868,7 +868,7 @@ RestoreClause(Clause *Cl, int mode)
|
||||
case _save_pair_x:
|
||||
case _save_appl_x_write:
|
||||
case _save_appl_x:
|
||||
pc->u.ox.opcw = _YAP_opcode(_YAP_op_from_opcode(pc->u.ox.opcw));
|
||||
pc->u.ox.opcw = Yap_opcode(Yap_op_from_opcode(pc->u.ox.opcw));
|
||||
pc->u.ox.x = XAdjust(pc->u.ox.x);
|
||||
pc = NEXTOP(pc,ox);
|
||||
break;
|
||||
@ -877,7 +877,7 @@ RestoreClause(Clause *Cl, int mode)
|
||||
case _unify_x_var2_write:
|
||||
case _unify_l_x_var2:
|
||||
case _unify_l_x_var2_write:
|
||||
pc->u.oxx.opcw = _YAP_opcode(_YAP_op_from_opcode(pc->u.oxx.opcw));
|
||||
pc->u.oxx.opcw = Yap_opcode(Yap_op_from_opcode(pc->u.oxx.opcw));
|
||||
pc->u.oxx.xl = XAdjust(pc->u.oxx.xl);
|
||||
pc->u.oxx.xr = XAdjust(pc->u.oxx.xr);
|
||||
pc = NEXTOP(pc,oxx);
|
||||
@ -899,7 +899,7 @@ RestoreClause(Clause *Cl, int mode)
|
||||
case _save_pair_y:
|
||||
case _save_appl_y_write:
|
||||
case _save_appl_y:
|
||||
pc->u.oy.opcw = _YAP_opcode(_YAP_op_from_opcode(pc->u.oy.opcw));
|
||||
pc->u.oy.opcw = Yap_opcode(Yap_op_from_opcode(pc->u.oy.opcw));
|
||||
pc->u.oy.y = YAdjust(pc->u.oy.y);
|
||||
pc = NEXTOP(pc,oy);
|
||||
break;
|
||||
@ -912,7 +912,7 @@ RestoreClause(Clause *Cl, int mode)
|
||||
case _unify_list:
|
||||
case _unify_l_list_write:
|
||||
case _unify_l_list:
|
||||
pc->u.o.opcw = _YAP_opcode(_YAP_op_from_opcode(pc->u.o.opcw));
|
||||
pc->u.o.opcw = Yap_opcode(Yap_op_from_opcode(pc->u.o.opcw));
|
||||
pc = NEXTOP(pc,o);
|
||||
break;
|
||||
/* instructions type os */
|
||||
@ -920,7 +920,7 @@ RestoreClause(Clause *Cl, int mode)
|
||||
case _unify_n_voids:
|
||||
case _unify_l_n_voids_write:
|
||||
case _unify_l_n_voids:
|
||||
pc->u.os.opcw = _YAP_opcode(_YAP_op_from_opcode(pc->u.os.opcw));
|
||||
pc->u.os.opcw = Yap_opcode(Yap_op_from_opcode(pc->u.os.opcw));
|
||||
pc = NEXTOP(pc,os);
|
||||
break;
|
||||
/* instructions type oc */
|
||||
@ -934,7 +934,7 @@ RestoreClause(Clause *Cl, int mode)
|
||||
case _unify_l_longint:
|
||||
case _unify_bigint:
|
||||
case _unify_l_bigint:
|
||||
pc->u.oc.opcw = _YAP_opcode(_YAP_op_from_opcode(pc->u.oc.opcw));
|
||||
pc->u.oc.opcw = Yap_opcode(Yap_op_from_opcode(pc->u.oc.opcw));
|
||||
{
|
||||
Term t = pc->u.oc.c;
|
||||
if (IsAtomTerm(t))
|
||||
@ -947,7 +947,7 @@ RestoreClause(Clause *Cl, int mode)
|
||||
/* instructions type osc */
|
||||
case _unify_n_atoms_write:
|
||||
case _unify_n_atoms:
|
||||
pc->u.osc.opcw = _YAP_opcode(_YAP_op_from_opcode(pc->u.osc.opcw));
|
||||
pc->u.osc.opcw = Yap_opcode(Yap_op_from_opcode(pc->u.osc.opcw));
|
||||
{
|
||||
Term t = pc->u.osc.c;
|
||||
if (IsAtomTerm(t))
|
||||
@ -960,7 +960,7 @@ RestoreClause(Clause *Cl, int mode)
|
||||
case _unify_struct:
|
||||
case _unify_l_struc_write:
|
||||
case _unify_l_struc:
|
||||
pc->u.of.opcw = _YAP_opcode(_YAP_op_from_opcode(pc->u.of.opcw));
|
||||
pc->u.of.opcw = Yap_opcode(Yap_op_from_opcode(pc->u.of.opcw));
|
||||
pc->u.of.f = FuncAdjust(pc->u.of.f);
|
||||
pc = NEXTOP(pc,of);
|
||||
break;
|
||||
@ -1063,7 +1063,7 @@ RestoreClause(Clause *Cl, int mode)
|
||||
break;
|
||||
/* instructions type ollll */
|
||||
case _switch_list_nl_prefetch:
|
||||
pc->u.ollll.pop = _YAP_opcode(_YAP_op_from_opcode(pc->u.ollll.pop));
|
||||
pc->u.ollll.pop = Yap_opcode(Yap_op_from_opcode(pc->u.ollll.pop));
|
||||
pc->u.ollll.l1 = CodeAddrAdjust(pc->u.ollll.l1);
|
||||
pc->u.ollll.l2 = CodeAddrAdjust(pc->u.ollll.l2);
|
||||
pc->u.ollll.l3 = CodeAddrAdjust(pc->u.ollll.l3);
|
||||
@ -1458,7 +1458,7 @@ CleanCode(PredEntry *pp)
|
||||
pp->FunctorOfPred = (Functor)AtomAdjust((Atom)(pp->FunctorOfPred));
|
||||
if (pp->OwnerFile)
|
||||
pp->OwnerFile = AtomAdjust(pp->OwnerFile);
|
||||
pp->OpcodeOfPred = _YAP_opcode(_YAP_op_from_opcode(pp->OpcodeOfPred));
|
||||
pp->OpcodeOfPred = Yap_opcode(Yap_op_from_opcode(pp->OpcodeOfPred));
|
||||
if (pp->PredFlags & CPredFlag) {
|
||||
if (pp->PredFlags & BinaryTestPredFlag) {
|
||||
pp->TrueCodeOfPred = DirectCCodeAdjust(pp,pp->TrueCodeOfPred);
|
||||
@ -1619,7 +1619,7 @@ RestoreEntries(PropEntry *pp)
|
||||
break;
|
||||
default:
|
||||
/* OOPS */
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
"Invalid Atom Property %d at %p", pp->KindOfPE, pp);
|
||||
return;
|
||||
}
|
||||
|
@ -27,10 +27,10 @@ typedef enum {
|
||||
} yap_low_level_port;
|
||||
|
||||
void STD_PROTO(low_level_trace,(yap_low_level_port, PredEntry *, CELL *));
|
||||
void STD_PROTO(_YAP_InitLowLevelTrace,(void));
|
||||
void STD_PROTO(Yap_InitLowLevelTrace,(void));
|
||||
void STD_PROTO(toggle_low_level_trace,(void));
|
||||
|
||||
extern int _YAP_do_low_level_trace;
|
||||
extern int Yap_do_low_level_trace;
|
||||
|
||||
#endif
|
||||
|
||||
|
78
H/yapio.h
78
H/yapio.h
@ -62,9 +62,9 @@
|
||||
#endif
|
||||
|
||||
#define YP_FILE FILE
|
||||
extern YP_FILE *_YAP_stdin;
|
||||
extern YP_FILE *_YAP_stdout;
|
||||
extern YP_FILE *_YAP_stderr;
|
||||
extern YP_FILE *Yap_stdin;
|
||||
extern YP_FILE *Yap_stdout;
|
||||
extern YP_FILE *Yap_stderr;
|
||||
|
||||
int STD_PROTO(YP_putc,(int, int));
|
||||
|
||||
@ -168,7 +168,7 @@ extern YP_FILE yp_iob[YP_MAX_FILES];
|
||||
#define YAP_FILENAME_MAX 1024 /* This is ok for Linux, should be ok for everyone */
|
||||
#endif
|
||||
|
||||
extern char _YAP_FileNameBuf[YAP_FILENAME_MAX], _YAP_FileNameBuf2[YAP_FILENAME_MAX];
|
||||
extern char Yap_FileNameBuf[YAP_FILENAME_MAX], Yap_FileNameBuf2[YAP_FILENAME_MAX];
|
||||
|
||||
typedef YP_FILE *YP_File;
|
||||
|
||||
@ -227,14 +227,14 @@ typedef enum{ /* we accept two domains for the moment, IPV6 may follow */
|
||||
af_unix /* or AF_FILE */
|
||||
} socket_domain;
|
||||
|
||||
Term STD_PROTO(_YAP_InitSocketStream,(int, socket_info, socket_domain));
|
||||
int STD_PROTO(_YAP_CheckSocketStream,(Term, char *));
|
||||
socket_domain STD_PROTO(_YAP_GetSocketDomain,(int));
|
||||
socket_info STD_PROTO(_YAP_GetSocketStatus,(int));
|
||||
void STD_PROTO(_YAP_UpdateSocketStream,(int, socket_info, socket_domain));
|
||||
Term STD_PROTO(Yap_InitSocketStream,(int, socket_info, socket_domain));
|
||||
int STD_PROTO(Yap_CheckSocketStream,(Term, char *));
|
||||
socket_domain STD_PROTO(Yap_GetSocketDomain,(int));
|
||||
socket_info STD_PROTO(Yap_GetSocketStatus,(int));
|
||||
void STD_PROTO(Yap_UpdateSocketStream,(int, socket_info, socket_domain));
|
||||
|
||||
/* routines in ypsocks.c */
|
||||
Int STD_PROTO(_YAP_CloseSocket,(int, socket_info, socket_domain));
|
||||
Int STD_PROTO(Yap_CloseSocket,(int, socket_info, socket_domain));
|
||||
|
||||
#endif /* USE_SOCKET */
|
||||
|
||||
@ -246,42 +246,42 @@ typedef struct AliasDescS {
|
||||
|
||||
/****************** character definition table **************************/
|
||||
#define NUMBER_OF_CHARS 256
|
||||
extern char *_YAP_chtype;
|
||||
extern char *Yap_chtype;
|
||||
|
||||
/*************** variables concerned with parsing *********************/
|
||||
extern TokEntry *_YAP_tokptr, *_YAP_toktide;
|
||||
extern VarEntry *_YAP_VarTable, *_YAP_AnonVarTable;
|
||||
extern int _YAP_eot_before_eof;
|
||||
extern TokEntry *Yap_tokptr, *Yap_toktide;
|
||||
extern VarEntry *Yap_VarTable, *Yap_AnonVarTable;
|
||||
extern int Yap_eot_before_eof;
|
||||
|
||||
/* parser stack, used to be AuxSp, now is ASP */
|
||||
#define ParserAuxSp (TR)
|
||||
|
||||
/* routines in parser.c */
|
||||
VarEntry STD_PROTO(*_YAP_LookupVar,(char *));
|
||||
Term STD_PROTO(_YAP_VarNames,(VarEntry *,Term));
|
||||
VarEntry STD_PROTO(*Yap_LookupVar,(char *));
|
||||
Term STD_PROTO(Yap_VarNames,(VarEntry *,Term));
|
||||
|
||||
/* routines ins scanner.c */
|
||||
TokEntry STD_PROTO(*_YAP_tokenizer,(int (*)(int), int (*)(int)));
|
||||
TokEntry STD_PROTO(*_YAP_fast_tokenizer,(void));
|
||||
Term STD_PROTO(_YAP_scan_num,(int (*)(int)));
|
||||
char STD_PROTO(*_YAP_AllocScannerMemory,(unsigned int));
|
||||
TokEntry STD_PROTO(*Yap_tokenizer,(int (*)(int), int (*)(int)));
|
||||
TokEntry STD_PROTO(*Yap_fast_tokenizer,(void));
|
||||
Term STD_PROTO(Yap_scan_num,(int (*)(int)));
|
||||
char STD_PROTO(*Yap_AllocScannerMemory,(unsigned int));
|
||||
|
||||
/* routines in iopreds.c */
|
||||
Int STD_PROTO(_YAP_FirstLineInParse,(void));
|
||||
int STD_PROTO(_YAP_CheckIOStream,(Term, char *));
|
||||
int STD_PROTO(_YAP_GetStreamFd,(int));
|
||||
void STD_PROTO(_YAP_CloseStreams,(int));
|
||||
void STD_PROTO(_YAP_CloseStream,(int));
|
||||
int STD_PROTO(_YAP_PlGetchar,(void));
|
||||
int STD_PROTO(_YAP_PlFGetchar,(void));
|
||||
int STD_PROTO(_YAP_GetCharForSIGINT,(void));
|
||||
int STD_PROTO(_YAP_StreamToFileNo,(Term));
|
||||
Term STD_PROTO(_YAP_OpenStream,(FILE *,char *,Term,int));
|
||||
Int STD_PROTO(Yap_FirstLineInParse,(void));
|
||||
int STD_PROTO(Yap_CheckIOStream,(Term, char *));
|
||||
int STD_PROTO(Yap_GetStreamFd,(int));
|
||||
void STD_PROTO(Yap_CloseStreams,(int));
|
||||
void STD_PROTO(Yap_CloseStream,(int));
|
||||
int STD_PROTO(Yap_PlGetchar,(void));
|
||||
int STD_PROTO(Yap_PlFGetchar,(void));
|
||||
int STD_PROTO(Yap_GetCharForSIGINT,(void));
|
||||
int STD_PROTO(Yap_StreamToFileNo,(Term));
|
||||
Term STD_PROTO(Yap_OpenStream,(FILE *,char *,Term,int));
|
||||
|
||||
extern int
|
||||
_YAP_c_input_stream,
|
||||
_YAP_c_output_stream,
|
||||
_YAP_c_error_stream;
|
||||
Yap_c_input_stream,
|
||||
Yap_c_output_stream,
|
||||
Yap_c_error_stream;
|
||||
|
||||
#define YAP_INPUT_STREAM 0x01
|
||||
#define YAP_OUTPUT_STREAM 0x02
|
||||
@ -299,10 +299,10 @@ extern int
|
||||
#define Use_portray_f 8
|
||||
|
||||
/* write.c */
|
||||
void STD_PROTO(_YAP_plwrite,(Term,int (*)(int, int),int));
|
||||
void STD_PROTO(Yap_plwrite,(Term,int (*)(int, int),int));
|
||||
|
||||
/* grow.c */
|
||||
int STD_PROTO(_YAP_growstack_in_parser, (tr_fr_ptr *, TokEntry **, VarEntry **));
|
||||
int STD_PROTO(Yap_growstack_in_parser, (tr_fr_ptr *, TokEntry **, VarEntry **));
|
||||
|
||||
|
||||
|
||||
@ -314,7 +314,7 @@ extern int errno;
|
||||
|
||||
#if DEBUG
|
||||
#if COROUTINING
|
||||
extern int _YAP_Portray_delays;
|
||||
extern int Yap_Portray_delays;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -325,13 +325,13 @@ extern int _YAP_Portray_delays;
|
||||
#define CONTINUE_ON_PARSER_ERROR 2
|
||||
#define EXCEPTION_ON_PARSER_ERROR 3
|
||||
|
||||
extern jmp_buf _YAP_IOBotch;
|
||||
extern jmp_buf Yap_IOBotch;
|
||||
|
||||
#ifdef DEBUG
|
||||
extern YP_FILE *_YAP_logfile;
|
||||
extern YP_FILE *Yap_logfile;
|
||||
#endif
|
||||
|
||||
#if USE_SOCKET
|
||||
extern int _YAP_sockets_io;
|
||||
extern int Yap_sockets_io;
|
||||
#endif
|
||||
|
||||
|
@ -9,14 +9,14 @@
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: mpe.c *
|
||||
* Last rev: $Date: 2002-11-11 17:38:03 $ *
|
||||
* Last rev: $Date: 2002-11-18 18:16:43 $ *
|
||||
* mods: *
|
||||
* comments: Interface to an MPE library *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef lint
|
||||
static char *rcsid = "$Header: /Users/vitor/Yap/yap-cvsbackup/library/mpi/mpe.c,v 1.4 2002-11-11 17:38:03 vsc Exp $";
|
||||
static char *rcsid = "$Header: /Users/vitor/Yap/yap-cvsbackup/library/mpi/mpe.c,v 1.5 2002-11-18 18:16:43 vsc Exp $";
|
||||
#endif
|
||||
|
||||
#include "Yap.h"
|
||||
@ -204,14 +204,14 @@ p_log() /* mpe_log(+EventType, +EventNum, +EventStr) */
|
||||
|
||||
|
||||
void
|
||||
_YAP_InitMPE(void)
|
||||
Yap_InitMPE(void)
|
||||
{
|
||||
_YAP_InitCPred( "mpe_open", 0, p_init, SafePredFlag );
|
||||
_YAP_InitCPred( "mpe_start", 0, p_start, SafePredFlag );
|
||||
_YAP_InitCPred( "mpe_close", 1, p_close, SafePredFlag );
|
||||
_YAP_InitCPred( "mpe_create_event", 1, p_create_event, SafePredFlag );
|
||||
_YAP_InitCPred( "mpe_create_state", 4, p_create_state, SafePredFlag );
|
||||
_YAP_InitCPred( "mpe_log", 3, p_log, SafePredFlag );
|
||||
Yap_InitCPred( "mpe_open", 0, p_init, SafePredFlag );
|
||||
Yap_InitCPred( "mpe_start", 0, p_start, SafePredFlag );
|
||||
Yap_InitCPred( "mpe_close", 1, p_close, SafePredFlag );
|
||||
Yap_InitCPred( "mpe_create_event", 1, p_create_event, SafePredFlag );
|
||||
Yap_InitCPred( "mpe_create_state", 4, p_create_state, SafePredFlag );
|
||||
Yap_InitCPred( "mpe_log", 3, p_log, SafePredFlag );
|
||||
}
|
||||
|
||||
#endif /* HAVE_MPE */
|
||||
|
@ -9,14 +9,14 @@
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: mpi.c *
|
||||
* Last rev: $Date: 2002-11-12 10:25:11 $ *
|
||||
* Last rev: $Date: 2002-11-18 18:16:51 $ *
|
||||
* mods: *
|
||||
* comments: Interface to an MPI library *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef lint
|
||||
static char *rcsid = "$Header: /Users/vitor/Yap/yap-cvsbackup/library/mpi/mpi.c,v 1.15 2002-11-12 10:25:11 stasinos Exp $";
|
||||
static char *rcsid = "$Header: /Users/vitor/Yap/yap-cvsbackup/library/mpi/mpi.c,v 1.16 2002-11-18 18:16:51 vsc Exp $";
|
||||
#endif
|
||||
|
||||
#include "Yap.h"
|
||||
@ -82,8 +82,8 @@ expand_buffer( int space )
|
||||
|
||||
tmp = malloc( bufsize + space );
|
||||
if( tmp == NULL ) {
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, "out of memory" );
|
||||
_YAP_exit( EXIT_FAILURE );
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, "out of memory" );
|
||||
Yap_exit( EXIT_FAILURE );
|
||||
}
|
||||
memcpy( tmp, buf, bufsize );
|
||||
#if 0
|
||||
@ -100,8 +100,8 @@ expand_buffer( int space )
|
||||
printf("realloc'ed space...");
|
||||
#endif
|
||||
if( buf == NULL ) {
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, "out of memory");
|
||||
_YAP_exit( EXIT_FAILURE );
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, "out of memory");
|
||||
Yap_exit( EXIT_FAILURE );
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -158,43 +158,43 @@ mpi_parse(void)
|
||||
CELL *old_H;
|
||||
|
||||
/* Scans the term using stack space */
|
||||
_YAP_eot_before_eof = FALSE;
|
||||
Yap_eot_before_eof = FALSE;
|
||||
|
||||
/* the first arg is the getc_for_read, diff only if CharConv is on */
|
||||
tokstart = _YAP_tokptr = _YAP_toktide = _YAP_tokenizer(mpi_getc, mpi_getc);
|
||||
tokstart = Yap_tokptr = Yap_toktide = Yap_tokenizer(mpi_getc, mpi_getc);
|
||||
|
||||
/* preserve value of H after scanning: otherwise we may lose strings
|
||||
and floats */
|
||||
old_H = H;
|
||||
|
||||
if ( mpi_eob() && !_YAP_eot_before_eof) {
|
||||
if ( mpi_eob() && !Yap_eot_before_eof) {
|
||||
if (tokstart != NIL && tokstart->Tok != Ord (eot_tok)) {
|
||||
/* we got the end of file from an abort */
|
||||
if (_YAP_ErrorMessage == "Abort") {
|
||||
if (Yap_ErrorMessage == "Abort") {
|
||||
TR = old_TR;
|
||||
return TermNil;
|
||||
}
|
||||
/* we need to force the next reading to also give end of file.*/
|
||||
buf[bufptr] = EOF;
|
||||
_YAP_ErrorMessage = "[ Error: end of file found before end of term ]";
|
||||
Yap_ErrorMessage = "[ Error: end of file found before end of term ]";
|
||||
} else {
|
||||
/* restore TR */
|
||||
TR = old_TR;
|
||||
|
||||
return (_YAP_unify_constant(t, MkAtomTerm(AtomEof)));
|
||||
return (Yap_unify_constant(t, MkAtomTerm(AtomEof)));
|
||||
}
|
||||
}
|
||||
repeat_cycle:
|
||||
TR_before_parse = TR;
|
||||
if( _YAP_ErrorMessage || (t = _YAP_Parse())==0 ) {
|
||||
if (_YAP_ErrorMessage && (strcmp(_YAP_ErrorMessage,"Stack Overflow") == 0)) {
|
||||
if( Yap_ErrorMessage || (t = Yap_Parse())==0 ) {
|
||||
if (Yap_ErrorMessage && (strcmp(Yap_ErrorMessage,"Stack Overflow") == 0)) {
|
||||
/* ignore term we just built */
|
||||
TR = TR_before_parse;
|
||||
H = old_H;
|
||||
if (_YAP_growstack_in_parser(&old_TR, &tokstart, &_YAP_VarTable)) {
|
||||
if (Yap_growstack_in_parser(&old_TR, &tokstart, &Yap_VarTable)) {
|
||||
old_H = H;
|
||||
_YAP_tokptr = _YAP_toktide = tokstart;
|
||||
_YAP_ErrorMessage = NULL;
|
||||
Yap_tokptr = Yap_toktide = tokstart;
|
||||
Yap_ErrorMessage = NULL;
|
||||
goto repeat_cycle;
|
||||
}
|
||||
}
|
||||
@ -206,8 +206,8 @@ mpi_parse(void)
|
||||
failing the predicate: the parse cannot fail unless there
|
||||
is a problem with MPI or the pretty printer.
|
||||
*/
|
||||
_YAP_Error(SYSTEM_ERROR, TermNil, "Failed to parse MPI_Recv()'ed term" );
|
||||
_YAP_exit( EXIT_FAILURE );
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, "Failed to parse MPI_Recv()'ed term" );
|
||||
Yap_exit( EXIT_FAILURE );
|
||||
|
||||
} else {
|
||||
/* parsing succeeded */
|
||||
@ -257,7 +257,7 @@ Yap exit(FAILURE), whereas in Yap/LAM mpi_open/3 simply fails.
|
||||
Term t;
|
||||
|
||||
t = MkIntegerTerm(retv);
|
||||
_YAP_Error( SYSTEM_ERROR, t, "MPI_Init() returned non-zero" );
|
||||
Yap_Error( SYSTEM_ERROR, t, "MPI_Init() returned non-zero" );
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
@ -265,9 +265,9 @@ Yap exit(FAILURE), whereas in Yap/LAM mpi_open/3 simply fails.
|
||||
MPI_Comm_rank( MPI_COMM_WORLD, &rank );
|
||||
MPI_Get_processor_name( processor_name, &namelen );
|
||||
|
||||
retv = _YAP_unify(t_rank, MkIntTerm(rank));
|
||||
retv = retv && _YAP_unify(t_numprocs, MkIntTerm(numprocs));
|
||||
retv = retv && _YAP_unify(t_procname, MkAtomTerm(_YAP_LookupAtom(processor_name)));
|
||||
retv = Yap_unify(t_rank, MkIntTerm(rank));
|
||||
retv = retv && Yap_unify(t_numprocs, MkIntTerm(numprocs));
|
||||
retv = retv && Yap_unify(t_procname, MkAtomTerm(Yap_LookupAtom(processor_name)));
|
||||
|
||||
return retv;
|
||||
}
|
||||
@ -289,25 +289,25 @@ p_mpi_send() /* mpi_send(+data, +destination, +tag) */
|
||||
|
||||
/* The first argument (data) must be bound */
|
||||
if (IsVarTerm(t_data)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t_data, "mpi_send");
|
||||
Yap_Error(INSTANTIATION_ERROR, t_data, "mpi_send");
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* The second and third args must be bount to integers */
|
||||
if (IsVarTerm(t_dest)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t_dest, "mpi_send");
|
||||
Yap_Error(INSTANTIATION_ERROR, t_dest, "mpi_send");
|
||||
return (FALSE);
|
||||
} else if( !IsIntegerTerm(t_dest) ) {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t_dest, "mpi_send");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t_dest, "mpi_send");
|
||||
return (FALSE);
|
||||
} else {
|
||||
dest = IntOfTerm( t_dest );
|
||||
}
|
||||
if (IsVarTerm(t_tag)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t_tag, "mpi_send");
|
||||
Yap_Error(INSTANTIATION_ERROR, t_tag, "mpi_send");
|
||||
return (FALSE);
|
||||
} else if( !IsIntegerTerm(t_tag) ) {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t_tag, "mpi_send");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t_tag, "mpi_send");
|
||||
return (FALSE);
|
||||
} else {
|
||||
tag = IntOfTerm( t_tag );
|
||||
@ -315,7 +315,7 @@ p_mpi_send() /* mpi_send(+data, +destination, +tag) */
|
||||
|
||||
bufptr = 0;
|
||||
/* Turn the term into its ASCII representation */
|
||||
_YAP_plwrite( t_data, mpi_putc, 5 );
|
||||
Yap_plwrite( t_data, mpi_putc, 5 );
|
||||
bufstrlen = (size_t)bufptr;
|
||||
|
||||
/* The buf is not NULL-terminated and does not have the
|
||||
@ -363,7 +363,7 @@ p_mpi_receive() /* mpi_receive(-data, ?orig, ?tag) */
|
||||
|
||||
/* The first argument (data) must be unbound */
|
||||
if(!IsVarTerm(t_data)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t_data, "mpi_receive");
|
||||
Yap_Error(INSTANTIATION_ERROR, t_data, "mpi_receive");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -373,7 +373,7 @@ p_mpi_receive() /* mpi_receive(-data, ?orig, ?tag) */
|
||||
if (IsVarTerm(t_orig)) {
|
||||
orig = MPI_ANY_SOURCE;
|
||||
} else if( !IsIntegerTerm(t_orig) ) {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t_orig, "mpi_receive");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t_orig, "mpi_receive");
|
||||
return (FALSE);
|
||||
} else {
|
||||
orig = IntOfTerm( t_orig );
|
||||
@ -384,7 +384,7 @@ p_mpi_receive() /* mpi_receive(-data, ?orig, ?tag) */
|
||||
if (IsVarTerm(t_tag)) {
|
||||
tag = MPI_ANY_TAG;
|
||||
} else if( !IsIntegerTerm(t_tag) ) {
|
||||
_YAP_Error(TYPE_ERROR_INTEGER, t_tag, "mpi_receive");
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t_tag, "mpi_receive");
|
||||
return (FALSE);
|
||||
} else
|
||||
tag = IntOfTerm( t_tag );
|
||||
@ -412,7 +412,7 @@ p_mpi_receive() /* mpi_receive(-data, ?orig, ?tag) */
|
||||
/* Already know the source from MPI_Probe() */
|
||||
if( orig == MPI_ANY_SOURCE ) {
|
||||
orig = status.MPI_SOURCE;
|
||||
retv = _YAP_unify(t_orig, MkIntTerm(orig));
|
||||
retv = Yap_unify(t_orig, MkIntTerm(orig));
|
||||
if( retv == FALSE ) {
|
||||
printf("PROBLEM: file %s, line %d\n", __FILE__, __LINE__);
|
||||
}
|
||||
@ -421,7 +421,7 @@ p_mpi_receive() /* mpi_receive(-data, ?orig, ?tag) */
|
||||
/* Already know the tag from MPI_Probe() */
|
||||
if( tag == MPI_ANY_TAG ) {
|
||||
tag = status.MPI_TAG;
|
||||
retv = _YAP_unify(t_tag, MkIntTerm(status.MPI_TAG));
|
||||
retv = Yap_unify(t_tag, MkIntTerm(status.MPI_TAG));
|
||||
if( retv == FALSE ) {
|
||||
printf("PROBLEM: file %s, line %d\n", __FILE__, __LINE__);
|
||||
}
|
||||
@ -451,13 +451,13 @@ p_mpi_receive() /* mpi_receive(-data, ?orig, ?tag) */
|
||||
|
||||
/* parse received string into a Prolog term */
|
||||
bufptr = 0;
|
||||
retv = _YAP_unify(ARG1, mpi_parse());
|
||||
retv = Yap_unify(ARG1, mpi_parse());
|
||||
|
||||
#if 0
|
||||
/* check up on mpi_parse():
|
||||
convert the newly-parsed term back to text and print */
|
||||
bufptr = 0;
|
||||
_YAP_plwrite( t_data, mpi_putc, 5 );
|
||||
Yap_plwrite( t_data, mpi_putc, 5 );
|
||||
mpi_putc( 0, '.' );
|
||||
mpi_putc( 0, ' ' );
|
||||
buf[bufptr] = 0;
|
||||
@ -484,7 +484,7 @@ p_mpi_bcast3() /* mpi_bcast( ?data, +root, +max_size ) */
|
||||
/* The second argument must be bound to an integer (the rank of
|
||||
root processor */
|
||||
if (IsVarTerm(t_root)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t_root, "mpi_bcast");
|
||||
Yap_Error(INSTANTIATION_ERROR, t_root, "mpi_bcast");
|
||||
return FALSE;
|
||||
}
|
||||
root = IntOfTerm( t_root );
|
||||
@ -493,12 +493,12 @@ p_mpi_bcast3() /* mpi_bcast( ?data, +root, +max_size ) */
|
||||
be bound to the term to be sent. */
|
||||
if( root == rank ) {
|
||||
if( IsVarTerm(t_data) ) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t_data, "mpi_bcast");
|
||||
Yap_Error(INSTANTIATION_ERROR, t_data, "mpi_bcast");
|
||||
return FALSE;
|
||||
}
|
||||
bufptr = 0;
|
||||
/* Turn the term into its ASCII representation */
|
||||
_YAP_plwrite( t_data, mpi_putc, 5 );
|
||||
Yap_plwrite( t_data, mpi_putc, 5 );
|
||||
/* NULL-terminate the string and add the ". " termination
|
||||
required by the parser. */
|
||||
buf[bufptr] = 0;
|
||||
@ -509,7 +509,7 @@ p_mpi_bcast3() /* mpi_bcast( ?data, +root, +max_size ) */
|
||||
/* The third argument must be bound to an integer (the maximum length
|
||||
of the broadcast term's ASCII representation */
|
||||
if (IsVarTerm(t_max_size)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t_max_size, "mpi_bcast");
|
||||
Yap_Error(INSTANTIATION_ERROR, t_max_size, "mpi_bcast");
|
||||
return FALSE;
|
||||
}
|
||||
/* allow for the ". " bit and the NULL at the end */
|
||||
@ -543,7 +543,7 @@ p_mpi_bcast3() /* mpi_bcast( ?data, +root, +max_size ) */
|
||||
else {
|
||||
/* ARG1 must be unbound so that it can receive data */
|
||||
if( !IsVarTerm(t_data) ) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t_data, "mpi_bcast");
|
||||
Yap_Error(INSTANTIATION_ERROR, t_data, "mpi_bcast");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -551,7 +551,7 @@ p_mpi_bcast3() /* mpi_bcast( ?data, +root, +max_size ) */
|
||||
bufptr = 0;
|
||||
|
||||
/* parse received string into a Prolog term */
|
||||
return _YAP_unify(mpi_parse(), ARG1);
|
||||
return Yap_unify(mpi_parse(), ARG1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -570,7 +570,7 @@ p_mpi_bcast2() /* mpi_bcast( ?data, +root ) */
|
||||
/* The second argument must be bound to an integer (the rank of
|
||||
root processor */
|
||||
if (IsVarTerm(t_root)) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t_root, "mpi_bcast");
|
||||
Yap_Error(INSTANTIATION_ERROR, t_root, "mpi_bcast");
|
||||
return FALSE;
|
||||
}
|
||||
root = IntOfTerm( t_root );
|
||||
@ -580,12 +580,12 @@ p_mpi_bcast2() /* mpi_bcast( ?data, +root ) */
|
||||
be bound to the term to be sent. */
|
||||
if( root == rank ) {
|
||||
if( IsVarTerm(t_data) ) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t_data, "mpi_bcast");
|
||||
Yap_Error(INSTANTIATION_ERROR, t_data, "mpi_bcast");
|
||||
return FALSE;
|
||||
}
|
||||
bufptr = 0;
|
||||
/* Turn the term into its ASCII representation */
|
||||
_YAP_plwrite( t_data, mpi_putc, 5 );
|
||||
Yap_plwrite( t_data, mpi_putc, 5 );
|
||||
/* NULL-terminate the string and add the ". " termination
|
||||
required by the parser. */
|
||||
buf[bufptr] = 0;
|
||||
@ -595,7 +595,7 @@ p_mpi_bcast2() /* mpi_bcast( ?data, +root ) */
|
||||
/* Otherwise, it must a variable */
|
||||
else {
|
||||
if( !IsVarTerm(t_data) ) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t_data, "mpi_bcast");
|
||||
Yap_Error(INSTANTIATION_ERROR, t_data, "mpi_bcast");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@ -631,7 +631,7 @@ p_mpi_bcast2() /* mpi_bcast( ?data, +root ) */
|
||||
else {
|
||||
/* ARG1 must be unbound so that it can receive data */
|
||||
if( !IsVarTerm(t_data) ) {
|
||||
_YAP_Error(INSTANTIATION_ERROR, t_data, "mpi_bcast");
|
||||
Yap_Error(INSTANTIATION_ERROR, t_data, "mpi_bcast");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -639,7 +639,7 @@ p_mpi_bcast2() /* mpi_bcast( ?data, +root ) */
|
||||
bufptr = 0;
|
||||
|
||||
/* parse received string into a Prolog term */
|
||||
return _YAP_unify(ARG1, mpi_parse());
|
||||
return Yap_unify(ARG1, mpi_parse());
|
||||
}
|
||||
}
|
||||
|
||||
@ -662,31 +662,31 @@ p_mpi_barrier() /* mpi_barrier/0 */
|
||||
|
||||
|
||||
void
|
||||
_YAP_InitMPI(void)
|
||||
Yap_InitMPI(void)
|
||||
{
|
||||
int i,j;
|
||||
|
||||
mpi_argv = malloc( _YAP_argc * sizeof(char *) );
|
||||
mpi_argv[0] = strdup( _YAP_argv[0] );
|
||||
mpi_argv = malloc( Yap_argc * sizeof(char *) );
|
||||
mpi_argv[0] = strdup( Yap_argv[0] );
|
||||
|
||||
bufsize = RECV_BUF_SIZE;
|
||||
buf = malloc(bufsize * sizeof(char));
|
||||
|
||||
for( i=1; i<_YAP_argc; ++i ) {
|
||||
if( !strcmp(_YAP_argv[i], "--") ) { ++i; break; }
|
||||
for( i=1; i<Yap_argc; ++i ) {
|
||||
if( !strcmp(Yap_argv[i], "--") ) { ++i; break; }
|
||||
}
|
||||
for( j=1; i<_YAP_argc; ++i, ++j ) {
|
||||
mpi_argv[j] = strdup( _YAP_argv[i] );
|
||||
for( j=1; i<Yap_argc; ++i, ++j ) {
|
||||
mpi_argv[j] = strdup( Yap_argv[i] );
|
||||
}
|
||||
mpi_argc = j;
|
||||
|
||||
mpi_argv[0] = strdup( _YAP_argv[0] );
|
||||
mpi_argv[0] = strdup( Yap_argv[0] );
|
||||
|
||||
#if 0
|
||||
/* DEBUG */
|
||||
printf( "_YAP_argc = %d\n", _YAP_argc );
|
||||
for( i=0; i<_YAP_argc; ++i ) {
|
||||
printf( "%d %s\n", i, _YAP_argv[i] );
|
||||
printf( "Yap_argc = %d\n", Yap_argc );
|
||||
for( i=0; i<Yap_argc; ++i ) {
|
||||
printf( "%d %s\n", i, Yap_argv[i] );
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -698,7 +698,7 @@ _YAP_InitMPI(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* With MPICH MPI__YAP_Init() must be called during initialisation,
|
||||
/* With MPICH MPI_Yap_Init() must be called during initialisation,
|
||||
but with LAM it can be called from Prolog (mpi_open/3).
|
||||
See also the comment at "if ! HAVE_LIBMPICH" above!
|
||||
*/
|
||||
@ -711,8 +711,8 @@ _YAP_InitMPI(void)
|
||||
Term t;
|
||||
|
||||
t = MkIntegerTerm(retv);
|
||||
_YAP_Error(SYSTEM_ERROR, t, "MPI_Init() returned non-zero");
|
||||
_YAP_exit( EXIT_FAILURE );
|
||||
Yap_Error(SYSTEM_ERROR, t, "MPI_Init() returned non-zero");
|
||||
Yap_exit( EXIT_FAILURE );
|
||||
}
|
||||
#if 0
|
||||
/* DEBUG */
|
||||
@ -723,13 +723,13 @@ _YAP_InitMPI(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
_YAP_InitCPred( "mpi_open", 3, p_mpi_open, SyncPredFlag );
|
||||
_YAP_InitCPred( "mpi_close", 0, p_mpi_close, SafePredFlag|SyncPredFlag );
|
||||
_YAP_InitCPred( "mpi_send", 3, p_mpi_send, SafePredFlag|SyncPredFlag );
|
||||
_YAP_InitCPred( "mpi_receive", 3, p_mpi_receive, SyncPredFlag );
|
||||
_YAP_InitCPred( "mpi_bcast", 3, p_mpi_bcast3, SyncPredFlag );
|
||||
_YAP_InitCPred( "mpi_bcast", 2, p_mpi_bcast2, SyncPredFlag );
|
||||
_YAP_InitCPred( "mpi_barrier", 0, p_mpi_barrier, SyncPredFlag );
|
||||
Yap_InitCPred( "mpi_open", 3, p_mpi_open, SyncPredFlag );
|
||||
Yap_InitCPred( "mpi_close", 0, p_mpi_close, SafePredFlag|SyncPredFlag );
|
||||
Yap_InitCPred( "mpi_send", 3, p_mpi_send, SafePredFlag|SyncPredFlag );
|
||||
Yap_InitCPred( "mpi_receive", 3, p_mpi_receive, SyncPredFlag );
|
||||
Yap_InitCPred( "mpi_bcast", 3, p_mpi_bcast3, SyncPredFlag );
|
||||
Yap_InitCPred( "mpi_bcast", 2, p_mpi_bcast2, SyncPredFlag );
|
||||
Yap_InitCPred( "mpi_barrier", 0, p_mpi_barrier, SyncPredFlag );
|
||||
}
|
||||
|
||||
#endif /* HAVE_MPI */
|
||||
|
@ -10,7 +10,7 @@
|
||||
* File: TermExt.h *
|
||||
* mods: *
|
||||
* comments: Extensions to standard terms for YAP *
|
||||
* version: $Id: TermExt.h.m4,v 1.7 2002-11-11 17:38:07 vsc Exp $ *
|
||||
* version: $Id: TermExt.h.m4,v 1.8 2002-11-18 18:17:04 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
#if USE_OFFSETS
|
||||
@ -162,11 +162,11 @@ Inline(IsLongIntTerm, int, Term, t, IsApplTerm(t) && FunctorOfTerm(t) == Functor
|
||||
#include <gmp.h>
|
||||
|
||||
|
||||
MP_INT *STD_PROTO(_YAP_PreAllocBigNum,(void));
|
||||
MP_INT *STD_PROTO(_YAP_InitBigNum,(Int));
|
||||
Term STD_PROTO(_YAP_MkBigIntTerm, (MP_INT *));
|
||||
MP_INT *STD_PROTO(_YAP_BigIntOfTerm, (Term));
|
||||
void STD_PROTO(_YAP_CleanBigNum,(void));
|
||||
MP_INT *STD_PROTO(Yap_PreAllocBigNum,(void));
|
||||
MP_INT *STD_PROTO(Yap_InitBigNum,(Int));
|
||||
Term STD_PROTO(Yap_MkBigIntTerm, (MP_INT *));
|
||||
MP_INT *STD_PROTO(Yap_BigIntOfTerm, (Term));
|
||||
void STD_PROTO(Yap_CleanBigNum,(void));
|
||||
|
||||
Inline(IsBigIntTerm, int, Term, t, IsApplTerm(t) && FunctorOfTerm(t) == FunctorBigInt)
|
||||
|
||||
@ -222,7 +222,7 @@ unify_extension(Functor f, CELL d0, CELL *pt0, CELL d1)
|
||||
return(pt0[1] == RepAppl(d1)[1]);
|
||||
#ifdef USE_GMP
|
||||
case big_int_e:
|
||||
return (mpz_cmp(_YAP_BigIntOfTerm(d0),_YAP_BigIntOfTerm(d1)) == 0);
|
||||
return (mpz_cmp(Yap_BigIntOfTerm(d0),Yap_BigIntOfTerm(d1)) == 0);
|
||||
#endif /* USE_GMP */
|
||||
case double_e:
|
||||
{
|
||||
|
86
m4/Yap.h.m4
86
m4/Yap.h.m4
@ -10,7 +10,7 @@
|
||||
* File: Yap.h.m4 *
|
||||
* mods: *
|
||||
* comments: main header file for YAP *
|
||||
* version: $Id: Yap.h.m4,v 1.36 2002-11-11 17:38:08 vsc Exp $ *
|
||||
* version: $Id: Yap.h.m4,v 1.37 2002-11-18 18:17:13 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
@ -222,19 +222,19 @@
|
||||
|
||||
#ifdef USE_GMP
|
||||
#ifdef __GNUC__
|
||||
typedef long long int SIGNED_YAP_LONG_LONG;
|
||||
typedef long long int SIGNEDYap_LONG_LONG;
|
||||
typedef unsigned long long int YAP_LONG_LONG;
|
||||
#else
|
||||
typedef long int SIGNED_YAP_LONG_LONG;
|
||||
typedef long int SIGNEDYap_LONG_LONG;
|
||||
typedef unsigned long int YAP_LONG_LONG;
|
||||
#endif
|
||||
#else
|
||||
typedef long int SIGNED_YAP_LONG_LONG;
|
||||
typedef long int SIGNEDYap_LONG_LONG;
|
||||
typedef unsigned long int YAP_LONG_LONG;
|
||||
#endif
|
||||
|
||||
#if DEBUG
|
||||
extern char _YAP_Option[20];
|
||||
extern char Yap_Option[20];
|
||||
#endif
|
||||
|
||||
/* #define FORCE_SECOND_QUADRANT 1 */
|
||||
@ -268,8 +268,8 @@ extern char _YAP_Option[20];
|
||||
#define HEAP_INIT_BASE (MMAP_ADDR)
|
||||
#define AtomBase ((char *)MMAP_ADDR)
|
||||
#else
|
||||
#define HEAP_INIT_BASE ((CELL)_YAP_HeapBase)
|
||||
#define AtomBase (_YAP_HeapBase)
|
||||
#define HEAP_INIT_BASE ((CELL)Yap_HeapBase)
|
||||
#define AtomBase (Yap_HeapBase)
|
||||
#endif
|
||||
|
||||
|
||||
@ -393,7 +393,7 @@ typedef volatile int lockvar;
|
||||
#define siglongjmp(Env, Arg) longjmp(Env, Arg)
|
||||
#endif
|
||||
|
||||
extern sigjmp_buf _YAP_RestartEnv; /* used to restart after an abort */
|
||||
extern sigjmp_buf Yap_RestartEnv; /* used to restart after an abort */
|
||||
|
||||
/* Support for arrays */
|
||||
#include "arrays.h"
|
||||
@ -485,9 +485,9 @@ typedef enum {
|
||||
UNKNOWN_ERROR
|
||||
} yap_error_number;
|
||||
|
||||
extern char *_YAP_ErrorMessage; /* used to pass error messages */
|
||||
extern Term _YAP_Error_Term; /* used to pass error terms */
|
||||
extern yap_error_number _YAP_Error_TYPE; /* used to pass the error */
|
||||
extern char *Yap_ErrorMessage; /* used to pass error messages */
|
||||
extern Term Yap_Error_Term; /* used to pass error terms */
|
||||
extern yap_error_number Yap_Error_TYPE; /* used to pass the error */
|
||||
|
||||
typedef enum {
|
||||
YAP_INT_BOUNDED_FLAG = 0,
|
||||
@ -641,11 +641,11 @@ and RefOfTerm(t) : Term -> DBRef = ...
|
||||
|
||||
/************* variables related to memory allocation *******************/
|
||||
/* must be before TermExt.h */
|
||||
extern ADDR _YAP_HeapBase,
|
||||
_YAP_LocalBase,
|
||||
_YAP_GlobalBase,
|
||||
_YAP_TrailBase,
|
||||
_YAP_TrailTop;
|
||||
extern ADDR Yap_HeapBase,
|
||||
Yap_LocalBase,
|
||||
Yap_GlobalBase,
|
||||
Yap_TrailBase,
|
||||
Yap_TrailTop;
|
||||
|
||||
|
||||
/* applies to unbound variables */
|
||||
@ -776,7 +776,7 @@ typedef struct opcode_tab_entry {
|
||||
|
||||
/******************* storing error messages ****************************/
|
||||
#define MAX_ERROR_MSG_SIZE 256
|
||||
extern char _YAP_ErrorSay[MAX_ERROR_MSG_SIZE];
|
||||
extern char Yap_ErrorSay[MAX_ERROR_MSG_SIZE];
|
||||
|
||||
/********************* how to write a Prolog term ***********************/
|
||||
|
||||
@ -793,13 +793,13 @@ typedef enum {
|
||||
ExtendStackMode = 128 /* trying to extend stack */
|
||||
} prolog_exec_mode;
|
||||
|
||||
extern prolog_exec_mode _YAP_PrologMode;
|
||||
extern int _YAP_CritLocks;
|
||||
extern prolog_exec_mode Yap_PrologMode;
|
||||
extern int Yap_CritLocks;
|
||||
|
||||
/************** Access to yap initial arguments ***************************/
|
||||
|
||||
extern char **_YAP_argv;
|
||||
extern int _YAP_argc;
|
||||
extern char **Yap_argv;
|
||||
extern int Yap_argc;
|
||||
|
||||
/******************* number of modules ****************************/
|
||||
|
||||
@ -812,21 +812,21 @@ extern int _YAP_argc;
|
||||
LOCK(GLOBAL_LOCKS_heap_access); \
|
||||
GLOBAL_LOCKS_who_locked_heap = worker_id; \
|
||||
} \
|
||||
_YAP_PrologMode |= CritMode; \
|
||||
_YAP_CritLocks++; \
|
||||
Yap_PrologMode |= CritMode; \
|
||||
Yap_CritLocks++; \
|
||||
}
|
||||
#define YAPLeaveCriticalSection() \
|
||||
{ \
|
||||
_YAP_CritLocks--; \
|
||||
if (!_YAP_CritLocks) { \
|
||||
_YAP_PrologMode &= ~CritMode; \
|
||||
if (_YAP_PrologMode & InterruptMode) { \
|
||||
_YAP_PrologMode &= ~InterruptMode; \
|
||||
_YAP_ProcessSIGINT(); \
|
||||
Yap_CritLocks--; \
|
||||
if (!Yap_CritLocks) { \
|
||||
Yap_PrologMode &= ~CritMode; \
|
||||
if (Yap_PrologMode & InterruptMode) { \
|
||||
Yap_PrologMode &= ~InterruptMode; \
|
||||
Yap_ProcessSIGINT(); \
|
||||
} \
|
||||
if (_YAP_PrologMode & AbortMode) { \
|
||||
_YAP_PrologMode &= ~AbortMode; \
|
||||
_YAP_Error(PURE_ABORT, 0, ""); \
|
||||
if (Yap_PrologMode & AbortMode) { \
|
||||
Yap_PrologMode &= ~AbortMode; \
|
||||
Yap_Error(PURE_ABORT, 0, ""); \
|
||||
} \
|
||||
GLOBAL_LOCKS_who_locked_heap = MAX_WORKERS; \
|
||||
UNLOCK(GLOBAL_LOCKS_heap_access); \
|
||||
@ -835,21 +835,21 @@ extern int _YAP_argc;
|
||||
#else
|
||||
#define YAPEnterCriticalSection() \
|
||||
{ \
|
||||
_YAP_PrologMode |= CritMode; \
|
||||
_YAP_CritLocks++; \
|
||||
Yap_PrologMode |= CritMode; \
|
||||
Yap_CritLocks++; \
|
||||
}
|
||||
#define YAPLeaveCriticalSection() \
|
||||
{ \
|
||||
_YAP_CritLocks--; \
|
||||
if (!_YAP_CritLocks) { \
|
||||
_YAP_PrologMode &= ~CritMode; \
|
||||
if (_YAP_PrologMode & InterruptMode) { \
|
||||
_YAP_PrologMode &= ~InterruptMode; \
|
||||
_YAP_ProcessSIGINT(); \
|
||||
Yap_CritLocks--; \
|
||||
if (!Yap_CritLocks) { \
|
||||
Yap_PrologMode &= ~CritMode; \
|
||||
if (Yap_PrologMode & InterruptMode) { \
|
||||
Yap_PrologMode &= ~InterruptMode; \
|
||||
Yap_ProcessSIGINT(); \
|
||||
} \
|
||||
if (_YAP_PrologMode & AbortMode) { \
|
||||
_YAP_PrologMode &= ~AbortMode; \
|
||||
_YAP_Error(PURE_ABORT, 0, ""); \
|
||||
if (Yap_PrologMode & AbortMode) { \
|
||||
Yap_PrologMode &= ~AbortMode; \
|
||||
Yap_Error(PURE_ABORT, 0, ""); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
@ -248,8 +248,8 @@ typedef struct {
|
||||
CmpPredicate f;
|
||||
} cmp_entry;
|
||||
|
||||
extern CPredicate _YAP_c_predicates[MAX_C_PREDS];
|
||||
extern cmp_entry _YAP_cmp_funcs[MAX_CMP_FUNCS];
|
||||
extern CPredicate Yap_c_predicates[MAX_C_PREDS];
|
||||
extern cmp_entry Yap_cmp_funcs[MAX_CMP_FUNCS];
|
||||
|
||||
|
||||
/* Flags for code or dbase entry */
|
||||
@ -487,23 +487,23 @@ Inline(IsArrayProperty, PropFlags, int, flags, (flags == ArrayProperty) )
|
||||
/* Proto types */
|
||||
|
||||
/* cdmgr.c */
|
||||
int STD_PROTO(_YAP_RemoveIndexation,(PredEntry *));
|
||||
int STD_PROTO(Yap_RemoveIndexation,(PredEntry *));
|
||||
|
||||
/* dbase.c */
|
||||
void STD_PROTO(_YAP_ErDBE,(DBRef));
|
||||
DBRef STD_PROTO(_YAP_StoreTermInDB,(int,int));
|
||||
Term STD_PROTO(_YAP_FetchTermFromDB,(DBRef,int));
|
||||
void STD_PROTO(_YAP_ReleaseTermFromDB,(DBRef));
|
||||
void STD_PROTO(Yap_ErDBE,(DBRef));
|
||||
DBRef STD_PROTO(Yap_StoreTermInDB,(int,int));
|
||||
Term STD_PROTO(Yap_FetchTermFromDB,(DBRef,int));
|
||||
void STD_PROTO(Yap_ReleaseTermFromDB,(DBRef));
|
||||
|
||||
/* .c */
|
||||
CODEADDR STD_PROTO(_YAP_PredIsIndexable,(PredEntry *));
|
||||
CODEADDR STD_PROTO(Yap_PredIsIndexable,(PredEntry *));
|
||||
|
||||
/* init.c */
|
||||
Atom STD_PROTO(_YAP_GetOp,(OpEntry *,int *,int));
|
||||
Atom STD_PROTO(Yap_GetOp,(OpEntry *,int *,int));
|
||||
|
||||
/* vsc: redefined to GetAProp to avoid conflicts with Windows header files */
|
||||
Prop STD_PROTO(_YAP_GetAProp,(Atom,PropFlags));
|
||||
Prop STD_PROTO(_YAP_GetAPropHavingLock,(AtomEntry *,PropFlags));
|
||||
Prop STD_PROTO(Yap_GetAProp,(Atom,PropFlags));
|
||||
Prop STD_PROTO(Yap_GetAPropHavingLock,(AtomEntry *,PropFlags));
|
||||
|
||||
EXTERN inline Prop
|
||||
PredPropByFunc(Functor f, SMALLUNSGN cur_mod)
|
||||
@ -523,7 +523,7 @@ PredPropByFunc(Functor f, SMALLUNSGN cur_mod)
|
||||
}
|
||||
p0 = p->NextOfPE;
|
||||
}
|
||||
return(_YAP_NewPredPropByFunctor(fe,cur_mod));
|
||||
return(Yap_NewPredPropByFunctor(fe,cur_mod));
|
||||
}
|
||||
|
||||
EXTERN inline Prop
|
||||
@ -544,12 +544,12 @@ PredPropByAtom(Atom at, SMALLUNSGN cur_mod)
|
||||
}
|
||||
p0 = pe->NextOfPE;
|
||||
}
|
||||
return(_YAP_NewPredPropByAtom(ae,cur_mod));
|
||||
return(Yap_NewPredPropByAtom(ae,cur_mod));
|
||||
}
|
||||
|
||||
ADDR STD_PROTO(_YAP_PreAllocCodeSpace, (void));
|
||||
ADDR STD_PROTO(Yap_PreAllocCodeSpace, (void));
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
void STD_PROTO(_YAP_ReleasePreAllocCodeSpace, (ADDR));
|
||||
void STD_PROTO(Yap_ReleasePreAllocCodeSpace, (ADDR));
|
||||
#else
|
||||
#define _YAP_ReleasePreAllocCodeSpace(x)
|
||||
#define Yap_ReleasePreAllocCodeSpace(x)
|
||||
#endif
|
||||
|
@ -33,7 +33,7 @@ extern ADDR OldHeapBase, OldHeapTop;
|
||||
|
||||
#define CharP(ptr) ((char *) (ptr))
|
||||
|
||||
Inline(IsHeapP, int, CELL *, ptr, (ptr >= (CELL *)_YAP_HeapBase && ptr <= (CELL *)HeapTop) )
|
||||
Inline(IsHeapP, int, CELL *, ptr, (ptr >= (CELL *)Yap_HeapBase && ptr <= (CELL *)HeapTop) )
|
||||
|
||||
/* Adjusting cells and pointers to cells */
|
||||
Inline(PtoGloAdjust, CELL *, CELL *, ptr, ((CELL *)(CharP(ptr) + GDiff)) )
|
||||
@ -108,7 +108,7 @@ Inline(IsOldTrail, int, CELL, reg, IN_BETWEEN(OldTrailBase, reg, OldTR) )
|
||||
Inline(IsOldTrailPtr, int, CELL *, ptr, IN_BETWEEN(OldTrailBase, ptr, OldTR) )
|
||||
Inline(IsOldCode, int, CELL, reg, IN_BETWEEN(OldHeapBase, reg, OldHeapTop) )
|
||||
Inline(IsOldCodeCellPtr, int, CELL *, ptr, IN_BETWEEN(OldHeapBase, ptr, OldHeapTop) )
|
||||
Inline(IsGlobal, int, CELL, reg, IN_BETWEEN(_YAP_GlobalBase, reg, H) )
|
||||
Inline(IsGlobal, int, CELL, reg, IN_BETWEEN(Yap_GlobalBase, reg, H) )
|
||||
|
||||
void STD_PROTO(_YAP_AdjustStacksAndTrail, (void));
|
||||
void STD_PROTO(_YAP_AdjustRegs, (int));
|
||||
void STD_PROTO(Yap_AdjustStacksAndTrail, (void));
|
||||
void STD_PROTO(Yap_AdjustRegs, (int));
|
||||
|
Reference in New Issue
Block a user