2010-11-30 21:59:45 +00:00
|
|
|
void Yap_swi_install(void);
|
|
|
|
void Yap_install_blobs(void);
|
|
|
|
|
|
|
|
typedef struct open_query_struct {
|
|
|
|
int open;
|
|
|
|
int state;
|
2013-02-05 14:22:17 +00:00
|
|
|
YAP_Term *g;
|
|
|
|
PredEntry *pe;
|
2010-11-30 21:59:45 +00:00
|
|
|
yamop *p, *cp;
|
|
|
|
jmp_buf env;
|
2013-01-18 14:26:24 +00:00
|
|
|
int flags;
|
2013-02-05 14:22:17 +00:00
|
|
|
YAP_dogoalinfo h;
|
2010-11-30 21:59:45 +00:00
|
|
|
} open_query;
|
|
|
|
|
|
|
|
#define addr_hash(V) (((CELL) (V)) >> 4 & (N_SWI_HASH-1))
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
add_to_hash(Int i, ADDR key)
|
|
|
|
{
|
2013-10-04 13:22:00 +01:00
|
|
|
|
2010-11-30 21:59:45 +00:00
|
|
|
UInt h = addr_hash(key);
|
|
|
|
while (SWI_ReverseHash[h].key) {
|
|
|
|
h = (h+1)%N_SWI_HASH;
|
|
|
|
}
|
|
|
|
SWI_ReverseHash[h].key = key;
|
|
|
|
SWI_ReverseHash[h].pos = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
static atom_t
|
|
|
|
in_hash(ADDR key)
|
|
|
|
{
|
|
|
|
UInt h = addr_hash(key);
|
|
|
|
while (SWI_ReverseHash[h].key) {
|
|
|
|
if (SWI_ReverseHash[h].key == key)
|
|
|
|
return SWI_ReverseHash[h].pos;
|
|
|
|
h = (h+1)%N_SWI_HASH;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline atom_t
|
|
|
|
AtomToSWIAtom(Atom at)
|
|
|
|
{
|
2013-10-04 13:22:00 +01:00
|
|
|
TranslationEntry *p;
|
|
|
|
|
|
|
|
if ((p = Yap_GetTranslationProp(at)) != NULL)
|
|
|
|
return (atom_t)(p->Translation*2+1);
|
2010-11-30 21:59:45 +00:00
|
|
|
return (atom_t)at;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Atom
|
|
|
|
SWIAtomToAtom(atom_t at)
|
|
|
|
{
|
2013-10-12 12:46:01 +01:00
|
|
|
if ((CELL)at & 1)
|
2013-10-04 13:22:00 +01:00
|
|
|
return SWI_Atoms[at/2];
|
2010-11-30 21:59:45 +00:00
|
|
|
return (Atom)at;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Term
|
|
|
|
SWIModuleToModule(module_t m)
|
|
|
|
{
|
2011-03-07 16:02:55 +00:00
|
|
|
CACHE_REGS
|
2010-11-30 21:59:45 +00:00
|
|
|
if (m)
|
2013-11-13 10:38:20 +00:00
|
|
|
return MkAtomTerm(m->AtomOfME);
|
2010-11-30 21:59:45 +00:00
|
|
|
if (CurrentModule)
|
|
|
|
return CurrentModule;
|
|
|
|
return USER_MODULE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline functor_t
|
|
|
|
FunctorToSWIFunctor(Functor at)
|
|
|
|
{
|
|
|
|
atom_t ats;
|
|
|
|
if ((ats = in_hash((ADDR)at)))
|
2010-12-02 19:38:15 +00:00
|
|
|
return (functor_t)((CELL)ats*4+2);
|
2010-11-30 21:59:45 +00:00
|
|
|
return (functor_t)at;
|
|
|
|
}
|
|
|
|
|
2010-12-02 19:41:48 +00:00
|
|
|
/* This is silly, but let's keep it like that for now */
|
2010-11-30 21:59:45 +00:00
|
|
|
static inline Functor
|
2010-12-02 12:10:03 +00:00
|
|
|
SWIFunctorToFunctor(functor_t f)
|
2010-11-30 21:59:45 +00:00
|
|
|
{
|
2010-12-02 19:38:15 +00:00
|
|
|
if ((CELL)(f) & 2 && ((CELL)f) < N_SWI_FUNCTORS*4+2)
|
|
|
|
return SWI_Functors[((CELL)f)/4];
|
2010-12-02 12:10:03 +00:00
|
|
|
return (Functor)f;
|
2010-11-30 21:59:45 +00:00
|
|
|
}
|
|
|
|
|
2013-11-21 00:22:03 +00:00
|
|
|
#define isDefinedProcedure(pred) TRUE // TBD
|