2015-06-19 00:50:41 +01:00
|
|
|
/*************************************************************************
|
2005-05-27 23:27:59 +01:00
|
|
|
* *
|
|
|
|
* YAP Prolog %W% %G%
|
|
|
|
* *
|
|
|
|
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
|
|
|
* *
|
|
|
|
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
|
|
|
* *
|
|
|
|
**************************************************************************
|
|
|
|
* *
|
|
|
|
* File: YAtom.h.m4 *
|
|
|
|
* Last rev: 19/2/88 *
|
|
|
|
* mods: *
|
|
|
|
* comments: atom properties header file for YAP *
|
|
|
|
* *
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
/* This code can only be defined *after* including Regs.h!!! */
|
|
|
|
|
2009-03-24 13:27:36 +00:00
|
|
|
#ifndef YATOM_H
|
|
|
|
#define YATOM_H 1
|
|
|
|
|
2008-03-25 22:03:14 +00:00
|
|
|
#ifdef USE_OFFSETS
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Atom AbsAtom(AtomEntry *p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Atom AbsAtom(AtomEntry *p) {
|
|
|
|
return (Atom)(Addr(p) - AtomBase);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN AtomEntry *RepAtom(Atom a);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN AtomEntry *RepAtom(Atom a) {
|
2013-04-25 23:15:04 +01:00
|
|
|
return (AtomEntry *) (AtomBase + Unsigned (a);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Atom AbsAtom(AtomEntry *p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
INLINE_ONLY inline EXTERN Atom AbsAtom(AtomEntry *p) { return (Atom)(p); }
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN AtomEntry *RepAtom(Atom a);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN AtomEntry *RepAtom(Atom a) {
|
|
|
|
return (AtomEntry *)(a);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if USE_OFFSETS_IN_PROPS
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsProp(PropEntry *p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsProp(PropEntry *p) {
|
|
|
|
return (Prop)(Addr(p) - AtomBase);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN PropEntry *RepProp(Prop p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN PropEntry *RepProp(Prop p) {
|
|
|
|
return (PropEntry *)(AtomBase + Unsigned(p));
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsProp(PropEntry *p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsProp(PropEntry *p) { return (Prop)(p); }
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN PropEntry *RepProp(Prop p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN PropEntry *RepProp(Prop p) {
|
|
|
|
return (PropEntry *)(p);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if USE_OFFSETS_IN_PROPS
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN FunctorEntry *RepFunctorProp(Prop p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN FunctorEntry *RepFunctorProp(Prop p) {
|
|
|
|
return (FunctorEntry *)(AtomBase + Unsigned(p));
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsFunctorProp(FunctorEntry *p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsFunctorProp(FunctorEntry *p) {
|
|
|
|
return (Prop)(Addr(p) - AtomBase);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN FunctorEntry *RepFunctorProp(Prop p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN FunctorEntry *RepFunctorProp(Prop p) {
|
|
|
|
return (FunctorEntry *)(p);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsFunctorProp(FunctorEntry *p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsFunctorProp(FunctorEntry *p) {
|
|
|
|
return (Prop)(p);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Int ArityOfFunctor(Functor);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Int ArityOfFunctor(Functor Fun) {
|
|
|
|
return (Int)(((FunctorEntry *)Fun)->ArityOfFE);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Atom NameOfFunctor(Functor);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Atom NameOfFunctor(Functor Fun) {
|
|
|
|
return (Atom)(((FunctorEntry *)Fun)->NameOfFE);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN PropFlags IsFunctorProperty(int);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN PropFlags IsFunctorProperty(int flags) {
|
|
|
|
return (PropFlags)((flags == FunctorProperty));
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* summary of property codes used
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
00 00 predicate entry
|
|
|
|
80 00 db property
|
|
|
|
bb 00 functor entry
|
|
|
|
ff df sparse functor
|
|
|
|
ff ex arithmetic property
|
|
|
|
ff f4 translation
|
|
|
|
ff f5 blob
|
|
|
|
ff f6 hold
|
|
|
|
ff f7 array
|
|
|
|
ff f8 wide atom
|
|
|
|
ff fa module property
|
|
|
|
ff fb blackboard property
|
|
|
|
ff fc value property
|
|
|
|
ff fd global property
|
|
|
|
ff fe flag property
|
|
|
|
ff ff op property
|
2005-05-27 23:27:59 +01:00
|
|
|
*/
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
/* Global Variable property */
|
|
|
|
typedef struct global_entry {
|
|
|
|
Prop NextOfPE; /* used to chain properties */
|
|
|
|
PropFlags KindOfPE; /* kind of property */
|
2006-08-22 17:12:46 +01:00
|
|
|
#if defined(YAPOR) || defined(THREADS)
|
2016-01-03 02:06:09 +00:00
|
|
|
rwlock_t GRWLock; /* a simple lock to protect this entry */
|
2006-08-22 17:12:46 +01:00
|
|
|
#if THREADS
|
2016-01-03 02:06:09 +00:00
|
|
|
unsigned int owner_id; /* owner thread */
|
2006-08-22 17:12:46 +01:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
struct AtomEntryStruct *AtomOfGE; /* parent atom for deletion */
|
2016-01-03 02:06:09 +00:00
|
|
|
struct global_entry *NextGE; /* linked list of global entries */
|
|
|
|
Term global; /* index in module table */
|
|
|
|
Term AttChain; /* index in module table */
|
2006-08-22 17:12:46 +01:00
|
|
|
} GlobalEntry;
|
|
|
|
|
|
|
|
#if USE_OFFSETS_IN_PROPS
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN GlobalEntry *RepGlobalProp(Prop p);
|
2006-08-22 17:12:46 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN GlobalEntry *RepGlobalProp(Prop p) {
|
|
|
|
return (GlobalEntry *)(AtomBase + Unsigned(p));
|
2006-08-22 17:12:46 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsGlobalProp(GlobalEntry *p);
|
2006-08-22 17:12:46 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsGlobalProp(GlobalEntry *p) {
|
|
|
|
return (Prop)(Addr(p) - AtomBase);
|
2006-08-22 17:12:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN GlobalEntry *RepGlobalProp(Prop p);
|
2006-08-22 17:12:46 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN GlobalEntry *RepGlobalProp(Prop p) {
|
|
|
|
return (GlobalEntry *)(p);
|
2006-08-22 17:12:46 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsGlobalProp(GlobalEntry *p);
|
2006-08-22 17:12:46 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsGlobalProp(GlobalEntry *p) {
|
|
|
|
return (Prop)(p);
|
2006-08-22 17:12:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
#define GlobalProperty ((PropFlags)0xfffd)
|
2006-08-22 17:12:46 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN PropFlags IsGlobalProperty(int);
|
2006-08-22 17:12:46 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN PropFlags IsGlobalProperty(int flags) {
|
|
|
|
return (PropFlags)((flags == GlobalProperty));
|
2006-08-22 17:12:46 +01:00
|
|
|
}
|
|
|
|
|
2016-04-28 15:01:16 +01:00
|
|
|
/** Module property: low-level data used to manage modes.
|
|
|
|
|
2016-07-31 16:31:22 +01:00
|
|
|
Includes lists of pedicates, operators and other well-defIned
|
|
|
|
properties.
|
2016-04-28 15:01:16 +01:00
|
|
|
*/
|
2016-01-03 02:06:09 +00:00
|
|
|
typedef struct mod_entry {
|
2016-07-31 16:31:22 +01:00
|
|
|
Prop NextOfPE; /** chain of atom properties */
|
|
|
|
PropFlags KindOfPE; /** kind of property */
|
|
|
|
struct pred_entry *PredForME; /** index in module table */
|
2016-04-28 15:01:16 +01:00
|
|
|
struct operator_entry *OpForME; /** index in operator table */
|
2016-07-31 16:31:22 +01:00
|
|
|
Atom AtomOfME; /** module's name */
|
|
|
|
Atom OwnerFile; /** module's owner file */
|
2007-04-16 16:24:24 +01:00
|
|
|
#if defined(YAPOR) || defined(THREADS)
|
2016-04-28 15:01:16 +01:00
|
|
|
rwlock_t ModRWLock; /** a read-write lock to protect the entry */
|
2007-04-16 16:24:24 +01:00
|
|
|
#endif
|
2016-04-28 15:01:16 +01:00
|
|
|
unsigned int flags; /** Module local flags (from SWI compat) */
|
|
|
|
struct mod_entry *NextME; /** next module */
|
2005-05-27 23:27:59 +01:00
|
|
|
} ModEntry;
|
|
|
|
|
|
|
|
#if USE_OFFSETS_IN_PROPS
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN ModEntry *RepModProp(Prop p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN ModEntry *RepModProp(Prop p) {
|
|
|
|
return (ModEntry *)(AtomBase + Unsigned(p));
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsModProp(ModEntry *p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsModProp(ModEntry *p) {
|
|
|
|
return (Prop)(Addr(p) - AtomBase);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN ModEntry *RepModProp(Prop p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN ModEntry *RepModProp(Prop p) {
|
|
|
|
return (ModEntry *)(p);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsModProp(ModEntry *p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsModProp(ModEntry *p) { return (Prop)(p); }
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
#define ModToTerm(m) (m == PROLOG_MODULE ? TermProlog : m)
|
2015-04-13 13:28:17 +01:00
|
|
|
|
2005-05-27 23:27:59 +01:00
|
|
|
#endif
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
#define ModProperty ((PropFlags)0xfffa)
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-04-10 14:21:17 +01:00
|
|
|
INLINE_ONLY inline EXTERN bool IsModProperty(int);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-04-10 14:21:17 +01:00
|
|
|
INLINE_ONLY inline EXTERN bool IsModProperty(int flags) {
|
|
|
|
return flags == ModProperty;
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2015-06-19 00:50:41 +01:00
|
|
|
/* Flags on module. Most of these flags are copied to the read context
|
|
|
|
in pl-read.c.
|
|
|
|
*/
|
2016-01-03 02:06:09 +00:00
|
|
|
#define M_SYSTEM (0x0001) /* system module */
|
|
|
|
#define M_CHARESCAPE (0x0002) /* module */
|
|
|
|
#define DBLQ_CHARS (0x0004) /* "ab" --> ['a', 'b'] */
|
|
|
|
#define DBLQ_ATOM (0x0008) /* "ab" --> 'ab' */
|
|
|
|
#define DBLQ_STRING (0x0010) /* "ab" --> "ab" */
|
|
|
|
#define DBLQ_CODES (0x0020) /* "ab" --> [0'a, 0'b] */
|
|
|
|
#define DBLQ_MASK (DBLQ_CHARS | DBLQ_ATOM | DBLQ_STRING | DBLQ_CODES)
|
|
|
|
#define BCKQ_CHARS (0x0040) /* `ab` --> ['a', 'b'] */
|
|
|
|
#define BCKQ_ATOM (0x0080) /* `ab` --> 'ab' */
|
|
|
|
#define BCKQ_STRING (0x0100) /* `ab` --> "ab" */
|
|
|
|
#define BCKQ_CODES (0x0200) /* `ab` --> [0'a, 0'b] */
|
|
|
|
#define BCKQ_MASK (BCKQ_CHARS | BCKQ_ATOM | BCKQ_STRING | BCKQ_CODES)
|
|
|
|
#define UNKNOWN_FAIL (0x0400) /* module */
|
|
|
|
#define UNKNOWN_WARNING (0x0800) /* module */
|
|
|
|
#define UNKNOWN_ERROR (0x1000) /* module */
|
|
|
|
#define UNKNOWN_FAST_FAIL (0x2000) /* module */
|
|
|
|
#define UNKNOWN_ABORT (0x4000) /* module */
|
|
|
|
#define UNKNOWN_HALT (0x8000) /* module */
|
|
|
|
#define UNKNOWN_MASK \
|
|
|
|
(UNKNOWN_ERROR | UNKNOWN_WARNING | UNKNOWN_FAIL | UNKNOWN_FAST_FAIL | \
|
|
|
|
UNKNOWN_ABORT | UNKNOWN_HALT)
|
|
|
|
|
2016-07-31 16:31:22 +01:00
|
|
|
Term Yap_getUnknownModule(ModEntry *m);
|
2016-01-03 02:06:09 +00:00
|
|
|
void Yap_setModuleFlags(ModEntry *n, ModEntry *o);
|
|
|
|
|
2005-05-27 23:27:59 +01:00
|
|
|
/* operator property entry structure */
|
2016-01-03 02:06:09 +00:00
|
|
|
typedef struct operator_entry {
|
|
|
|
Prop NextOfPE; /* used to chain properties */
|
|
|
|
PropFlags KindOfPE; /* kind of property */
|
2005-05-27 23:27:59 +01:00
|
|
|
#if defined(YAPOR) || defined(THREADS)
|
2016-01-03 02:06:09 +00:00
|
|
|
rwlock_t OpRWLock; /* a read-write lock to protect the entry */
|
2005-05-27 23:27:59 +01:00
|
|
|
#endif
|
2016-07-31 16:31:22 +01:00
|
|
|
Atom OpName; /* atom name */
|
|
|
|
Term OpModule; /* module of predicate */
|
|
|
|
struct operator_entry *OpNext; /* next in list of operators */
|
2016-04-28 15:01:16 +01:00
|
|
|
struct operator_entry *NextForME; /* next in list of module operators */
|
2016-07-31 16:31:22 +01:00
|
|
|
BITS16 Prefix, Infix, Posfix; /**o precedences */
|
2005-05-27 23:27:59 +01:00
|
|
|
} OpEntry;
|
|
|
|
#if USE_OFFSETS_IN_PROPS
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN OpEntry *RepOpProp(Prop p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN OpEntry *RepOpProp(Prop p) {
|
|
|
|
return (OpEntry *)(AtomBase + Unsigned(p));
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsOpProp(OpEntry *p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsOpProp(OpEntry *p) {
|
|
|
|
return (Prop)(Addr(p) - AtomBase);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN OpEntry *RepOpProp(Prop p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN OpEntry *RepOpProp(Prop p) { return (OpEntry *)(p); }
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsOpProp(OpEntry *p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsOpProp(OpEntry *p) { return (Prop)(p); }
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
#endif
|
2016-01-03 02:06:09 +00:00
|
|
|
#define OpProperty ((PropFlags)0xffff)
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-04-10 14:21:17 +01:00
|
|
|
INLINE_ONLY inline EXTERN bool IsOpProperty(PropFlags);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-04-10 14:21:17 +01:00
|
|
|
INLINE_ONLY inline EXTERN bool IsOpProperty(PropFlags flags) {
|
|
|
|
return flags == OpProperty;
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
typedef enum { INFIX_OP = 0, POSFIX_OP = 1, PREFIX_OP = 2 } op_type;
|
2009-11-20 00:33:14 +00:00
|
|
|
|
2016-03-05 12:12:37 +00:00
|
|
|
OpEntry *Yap_GetOpProp(Atom, op_type, Term CACHE_TYPE);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-02-28 19:32:55 +00:00
|
|
|
int Yap_IsPrefixOp(Atom, int *, int *);
|
2016-01-03 02:06:09 +00:00
|
|
|
int Yap_IsOp(Atom);
|
2016-02-28 19:32:55 +00:00
|
|
|
int Yap_IsInfixOp(Atom, int *, int *, int *);
|
2016-07-31 16:31:22 +01:00
|
|
|
int Yap_IsPosfixOp(Atom, int *, int *);
|
|
|
|
bool Yap_dup_op(OpEntry *op, ModEntry *she);
|
|
|
|
|
|
|
|
/* defines related to operator specifications */
|
2016-01-03 02:06:09 +00:00
|
|
|
#define MaskPrio 0x0fff
|
|
|
|
#define DcrlpFlag 0x1000
|
|
|
|
#define DcrrpFlag 0x2000
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
typedef union arith_ret *eval_ret;
|
|
|
|
|
|
|
|
/* expression property entry structure */
|
2016-01-03 02:06:09 +00:00
|
|
|
typedef struct {
|
|
|
|
Prop NextOfPE; /* used to chain properties */
|
|
|
|
PropFlags KindOfPE; /* kind of property */
|
2005-05-27 23:27:59 +01:00
|
|
|
unsigned int ArityOfEE;
|
|
|
|
BITS16 ENoOfEE;
|
|
|
|
BITS16 FlagsOfEE;
|
|
|
|
/* operations that implement the expression */
|
2008-12-04 23:33:32 +00:00
|
|
|
int FOfEE;
|
2005-05-27 23:27:59 +01:00
|
|
|
} ExpEntry;
|
|
|
|
#if USE_OFFSETS_IN_PROPS
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN ExpEntry *RepExpProp(Prop p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN ExpEntry *RepExpProp(Prop p) {
|
|
|
|
return (ExpEntry *)(AtomBase + Unsigned(p));
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsExpProp(ExpEntry *p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsExpProp(ExpEntry *p) {
|
|
|
|
return (Prop)(Addr(p) - AtomBase);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN ExpEntry *RepExpProp(Prop p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN ExpEntry *RepExpProp(Prop p) {
|
|
|
|
return (ExpEntry *)(p);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsExpProp(ExpEntry *p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsExpProp(ExpEntry *p) { return (Prop)(p); }
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
#endif
|
2016-01-03 02:06:09 +00:00
|
|
|
#define ExpProperty 0xffe0
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
/* only unary and binary expressions are acceptable */
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN PropFlags IsExpProperty(int);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN PropFlags IsExpProperty(int flags) {
|
|
|
|
return (PropFlags)((flags == ExpProperty));
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* value property entry structure */
|
2016-01-03 02:06:09 +00:00
|
|
|
typedef struct {
|
|
|
|
Prop NextOfPE; /* used to chain properties */
|
|
|
|
PropFlags KindOfPE; /* kind of property */
|
2005-05-27 23:27:59 +01:00
|
|
|
#if defined(YAPOR) || defined(THREADS)
|
2016-01-03 02:06:09 +00:00
|
|
|
rwlock_t VRWLock; /* a read-write lock to protect the entry */
|
2005-05-27 23:27:59 +01:00
|
|
|
#endif
|
2016-01-03 02:06:09 +00:00
|
|
|
Term ValueOfVE; /* (atomic) value associated with the atom */
|
2005-05-27 23:27:59 +01:00
|
|
|
} ValEntry;
|
|
|
|
#if USE_OFFSETS_IN_PROPS
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN ValEntry *RepValProp(Prop p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN ValEntry *RepValProp(Prop p) {
|
|
|
|
return (ValEntry *)(AtomBase + Unsigned(p));
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsValProp(ValEntry *p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsValProp(ValEntry *p) {
|
|
|
|
return (Prop)(Addr(p) - AtomBase);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN ValEntry *RepValProp(Prop p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN ValEntry *RepValProp(Prop p) {
|
|
|
|
return (ValEntry *)(p);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsValProp(ValEntry *p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsValProp(ValEntry *p) { return (Prop)(p); }
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
#endif
|
2016-01-03 02:06:09 +00:00
|
|
|
#define ValProperty ((PropFlags)0xfffc)
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
/* predicate property entry structure */
|
|
|
|
/* AsmPreds are things like var, nonvar, atom ...which are implemented
|
2016-01-03 02:06:09 +00:00
|
|
|
through dedicated machine instructions. In this case the 8 lower
|
|
|
|
bits of PredFlags are used to hold the machine instruction code
|
|
|
|
for the pred.
|
2005-05-27 23:27:59 +01:00
|
|
|
C_Preds are things write, read, ... implemented in C. In this case
|
2016-01-03 02:06:09 +00:00
|
|
|
CodeOfPred holds the address of the correspondent C-function.
|
2013-12-11 01:05:51 +00:00
|
|
|
|
2014-11-25 12:03:48 +00:00
|
|
|
don't forget to also add in qly.h
|
2005-05-27 23:27:59 +01:00
|
|
|
*/
|
2016-01-03 02:06:09 +00:00
|
|
|
typedef uint64_t pred_flags_t;
|
2015-06-19 00:50:41 +01:00
|
|
|
|
2016-05-13 11:42:35 +01:00
|
|
|
#define ProfiledPredFlag \
|
|
|
|
((pred_flags_t)0x2000000000) /* pred is being profiled */
|
2016-01-03 02:06:09 +00:00
|
|
|
#define DiscontiguousPredFlag \
|
2016-03-29 02:02:43 +01:00
|
|
|
((pred_flags_t)0x1000000000) /* predicates whose clauses may be all-over \
|
|
|
|
the place.. */
|
2015-01-18 01:32:13 +00:00
|
|
|
#define SysExportPredFlag ((pred_flags_t)0x800000000)
|
2014-11-28 02:31:30 +00:00
|
|
|
/* reuse export list to prolog module. */
|
2016-01-03 02:06:09 +00:00
|
|
|
#define NoTracePredFlag \
|
|
|
|
((pred_flags_t)0x400000000) /* cannot trace this predicate */
|
|
|
|
#define NoSpyPredFlag \
|
|
|
|
((pred_flags_t)0x200000000) /* cannot spy this predicate */
|
|
|
|
#define QuasiQuotationPredFlag \
|
|
|
|
((pred_flags_t)0x100000000) /* SWI-like quasi quotations */
|
|
|
|
#define MegaClausePredFlag \
|
|
|
|
((pred_flags_t)0x80000000) /* predicate is implemented as a mega-clause */
|
|
|
|
#define ThreadLocalPredFlag ((pred_flags_t)0x40000000) /* local to a thread */
|
|
|
|
#define MultiFileFlag ((pred_flags_t)0x20000000) /* is multi-file */
|
2016-03-29 02:02:43 +01:00
|
|
|
#define UserCPredFlag \
|
|
|
|
((pred_flags_t)0x10000000) /* CPred defined by the user \
|
|
|
|
*/
|
2016-01-03 02:06:09 +00:00
|
|
|
#define LogUpdatePredFlag \
|
|
|
|
((pred_flags_t)0x08000000) /* dynamic predicate with log. upd. sem. */
|
|
|
|
#define InUsePredFlag ((pred_flags_t)0x04000000) /* count calls to pred */
|
|
|
|
#define CountPredFlag ((pred_flags_t)0x02000000) /* count calls to pred */
|
|
|
|
#define HiddenPredFlag ((pred_flags_t)0x01000000) /* invisible predicate */
|
|
|
|
#define CArgsPredFlag \
|
|
|
|
((pred_flags_t)0x00800000) /* SWI-like C-interface pred. */
|
|
|
|
#define SourcePredFlag \
|
|
|
|
((pred_flags_t)0x00400000) /* static predicate with source declaration */
|
|
|
|
#define MetaPredFlag \
|
|
|
|
((pred_flags_t)0x00200000) /* predicate subject to a meta declaration */
|
|
|
|
#define SyncPredFlag \
|
|
|
|
((pred_flags_t)0x00100000) /* has to synch before it can execute */
|
2016-03-29 02:02:43 +01:00
|
|
|
#define NumberDBPredFlag \
|
|
|
|
((pred_flags_t)0x00080000) /* entry for an atom key \
|
|
|
|
*/
|
|
|
|
#define AtomDBPredFlag ((pred_flags_t)0x00040000) /* entry for a number key */
|
2016-01-03 02:06:09 +00:00
|
|
|
// #define GoalExPredFlag ((pred_flags_t)0x00020000) /// predicate that is
|
|
|
|
// called by goal_expand */
|
|
|
|
#define TestPredFlag ((pred_flags_t)0x00010000) /* is a test (optim. comit) */
|
|
|
|
#define AsmPredFlag ((pred_flags_t)0x00008000) /* inline */
|
|
|
|
#define StandardPredFlag ((pred_flags_t)0x00004000) /* system predicate */
|
|
|
|
#define DynamicPredFlag ((pred_flags_t)0x00002000) /* dynamic predicate */
|
|
|
|
#define CPredFlag ((pred_flags_t)0x00001000) /* written in C */
|
|
|
|
#define SafePredFlag ((pred_flags_t)0x00000800) /* does not alter arguments */
|
|
|
|
#define CompiledPredFlag ((pred_flags_t)0x00000400) /* is static */
|
|
|
|
#define IndexedPredFlag ((pred_flags_t)0x00000200) /* has indexing code */
|
|
|
|
#define SpiedPredFlag ((pred_flags_t)0x00000100) /* is a spy point */
|
|
|
|
#define BinaryPredFlag ((pred_flags_t)0x00000080) /* test predicate */
|
|
|
|
#define TabledPredFlag ((pred_flags_t)0x00000040) /* is tabled */
|
|
|
|
#define SequentialPredFlag \
|
|
|
|
((pred_flags_t)0x00000020) /* may not create parallel choice points! */
|
2016-03-29 02:02:43 +01:00
|
|
|
#define BackCPredFlag \
|
|
|
|
((pred_flags_t)0x00000008) /* Myddas Imported pred \
|
|
|
|
*/
|
2016-01-03 02:06:09 +00:00
|
|
|
#define ModuleTransparentPredFlag \
|
|
|
|
((pred_flags_t)0x00000004) /* ModuleTransparent pred */
|
|
|
|
#define SWIEnvPredFlag ((pred_flags_t)0x00000002) /* new SWI interface */
|
|
|
|
#define UDIPredFlag ((pred_flags_t)0x00000001) /* User Defined Indexing */
|
|
|
|
|
|
|
|
#define SystemPredFlags \
|
|
|
|
(AsmPredFlag | StandardPredFlag | CPredFlag | BinaryPredFlag | BackCPredFlag)
|
|
|
|
#define ForeignPredFlags \
|
2016-03-29 02:02:43 +01:00
|
|
|
(AsmPredFlag | SWIEnvPredFlag | CPredFlag | BinaryPredFlag | UDIPredFlag | \
|
|
|
|
CArgsPredFlag | UserCPredFlag | SafePredFlag | BackCPredFlag)
|
2016-01-03 02:06:09 +00:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
#define StatePredFlags \
|
|
|
|
(InUsePredFlag | CountPredFlag | SpiedPredFlag | IndexedPredFlag)
|
2016-01-03 02:06:09 +00:00
|
|
|
#define is_system(pe) (pe->PredFlags & SystemPredFlags)
|
|
|
|
#define is_dynamic(pe) (pe->PredFlags & DynamicPredFlag)
|
2016-01-12 17:03:57 +00:00
|
|
|
#define is_foreign(pe) (pe->PredFlags & ForeignPredFlags)
|
2016-01-03 02:06:09 +00:00
|
|
|
#define is_static(pe) (pe->PredFlags & CompiledPredFlag)
|
|
|
|
#define is_logupd(pe) (pe->PredFlags & LogUpdatePredFlag)
|
|
|
|
#ifdef TABLING
|
|
|
|
#define is_tabled(pe) (pe->PredFlags & TabledPredFlag)
|
|
|
|
#endif /* TABLING */
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
/* profile data */
|
2016-01-03 02:06:09 +00:00
|
|
|
typedef struct {
|
|
|
|
UInt NOfEntries; /* nbr of times head unification succeeded */
|
|
|
|
UInt NOfHeadSuccesses; /* nbr of times head unification succeeded */
|
|
|
|
UInt NOfRetries; /* nbr of times a clause for the pred
|
|
|
|
was retried */
|
2005-05-27 23:27:59 +01:00
|
|
|
#if defined(YAPOR) || defined(THREADS)
|
2016-01-03 02:06:09 +00:00
|
|
|
lockvar lock; /* a simple lock to protect this entry */
|
2005-05-27 23:27:59 +01:00
|
|
|
#endif
|
|
|
|
} profile_data;
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
typedef enum { LUCALL_EXEC, LUCALL_ASSERT, LUCALL_RETRACT } timestamp_type;
|
2006-10-10 15:08:17 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
#define TIMESTAMP_EOT ((UInt)(~0L))
|
|
|
|
#define TIMESTAMP_RESET (TIMESTAMP_EOT - 1024)
|
2006-11-15 00:13:37 +00:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
typedef struct pred_entry {
|
|
|
|
Prop NextOfPE; /* used to chain properties */
|
|
|
|
PropFlags KindOfPE; /* kind of property */
|
2005-05-27 23:27:59 +01:00
|
|
|
struct yami *CodeOfPred;
|
2016-01-03 02:06:09 +00:00
|
|
|
OPCODE OpcodeOfPred; /* undefcode, indexcode, spycode, .... */
|
2015-01-06 17:47:58 +00:00
|
|
|
pred_flags_t PredFlags;
|
2016-01-03 02:06:09 +00:00
|
|
|
UInt ArityOfPE; /* arity of property */
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
struct yami *TrueCodeOfPred; /* code address */
|
2005-05-27 23:27:59 +01:00
|
|
|
struct yami *FirstClause;
|
|
|
|
struct yami *LastClause;
|
|
|
|
UInt NOfClauses;
|
|
|
|
OPCODE ExpandCode;
|
|
|
|
} p_code;
|
|
|
|
CPredicate f_code;
|
|
|
|
CmpPredicate d_code;
|
2016-01-03 02:06:09 +00:00
|
|
|
} cs; /* if needing to spy or to lock */
|
|
|
|
Functor FunctorOfPred; /* functor for Predicate */
|
|
|
|
union {
|
|
|
|
Atom OwnerFile; /* File where the predicate was defined */
|
|
|
|
Int IndxId; /* Index for a certain key */
|
2005-05-27 23:27:59 +01:00
|
|
|
} src;
|
|
|
|
#if defined(YAPOR) || defined(THREADS)
|
2016-01-03 02:06:09 +00:00
|
|
|
lockvar PELock; /* a simple lock to protect expansion */
|
2005-05-27 23:27:59 +01:00
|
|
|
#endif
|
|
|
|
#ifdef TABLING
|
|
|
|
tab_ent_ptr TableOfPred;
|
2016-01-03 02:06:09 +00:00
|
|
|
#endif /* TABLING */
|
2005-09-08 22:59:58 +01:00
|
|
|
#ifdef BEAM
|
|
|
|
struct Predicates *beamTable;
|
|
|
|
#endif
|
2016-09-21 04:53:33 +01:00
|
|
|
struct yami *MetaEntryOfPred; /* allow direct access from meta-calls */
|
|
|
|
Term ModuleOfPred; /* module for this definition */
|
2006-10-10 15:08:17 +01:00
|
|
|
UInt TimeStampOfPred;
|
2015-04-13 13:28:17 +01:00
|
|
|
timestamp_type LastCallOfPred;
|
2005-05-27 23:27:59 +01:00
|
|
|
/* This must be at an odd number of cells, otherwise it
|
|
|
|
will not be aligned on RISC machines */
|
2016-01-03 02:06:09 +00:00
|
|
|
profile_data *StatisticsForPred; /* enable profiling for predicate */
|
|
|
|
struct pred_entry *NextPredOfModule; /* next pred for same module */
|
|
|
|
struct pred_entry *NextPredOfHash; /* next pred for same module */
|
|
|
|
} PredEntry;
|
|
|
|
#define PEProp ((PropFlags)(0x0000))
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
#if USE_OFFSETS_IN_PROPS
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN PredEntry *RepPredProp(Prop p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN PredEntry *RepPredProp(Prop p) {
|
|
|
|
return (PredEntry *)(AtomBase + Unsigned(p));
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsPredProp(PredEntry *p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsPredProp(PredEntry *p) {
|
|
|
|
return (Prop)(Addr(p) - AtomBase);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN PredEntry *RepPredProp(Prop p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN PredEntry *RepPredProp(Prop p) {
|
2015-06-19 00:50:41 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
return (PredEntry *)(p);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsPredProp(PredEntry *p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsPredProp(PredEntry *p) { return (Prop)(p); }
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN PropFlags IsPredProperty(int);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN PropFlags IsPredProperty(int flags) {
|
|
|
|
return (PropFlags)((flags == PEProp));
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-04-19 23:30:02 +01:00
|
|
|
INLINE_ONLY inline EXTERN Atom NameOfPred(PredEntry *pe);
|
|
|
|
|
|
|
|
INLINE_ONLY inline EXTERN Atom NameOfPred(PredEntry *pe) {
|
|
|
|
if (pe->ModuleOfPred == IDB_MODULE) {
|
|
|
|
return NULL;
|
|
|
|
} else if (pe->ArityOfPE == 0) {
|
|
|
|
return (Atom)pe->FunctorOfPred;
|
|
|
|
} else {
|
|
|
|
Functor f = pe->FunctorOfPred;
|
|
|
|
return NameOfFunctor(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-31 16:31:22 +01:00
|
|
|
extern const char *IndicatorOfPred(PredEntry *pe);
|
|
|
|
|
2016-09-27 18:31:12 +01:00
|
|
|
extern PredEntry *Yap_get_pred(Term t, Term tmod, const char *pname);
|
|
|
|
|
2016-07-31 16:31:22 +01:00
|
|
|
profile_data *Yap_initProfiler(PredEntry *p);
|
2016-05-13 11:42:35 +01:00
|
|
|
|
2005-05-27 23:27:59 +01:00
|
|
|
/* Flags for code or dbase entry */
|
|
|
|
/* There are several flags for code and data base entries */
|
2016-01-03 02:06:09 +00:00
|
|
|
typedef enum {
|
|
|
|
ExoMask = 0x1000000, /* is exo code */
|
|
|
|
FuncSwitchMask = 0x800000, /* is a switch of functors */
|
|
|
|
HasDBTMask = 0x400000, /* includes a pointer to a DBTerm */
|
|
|
|
MegaMask = 0x200000, /* mega clause */
|
|
|
|
FactMask = 0x100000, /* a fact */
|
|
|
|
SwitchRootMask = 0x80000, /* root for the index tree */
|
|
|
|
SwitchTableMask = 0x40000, /* switch table */
|
|
|
|
HasBlobsMask = 0x20000, /* blobs which may be in use */
|
|
|
|
ProfFoundMask = 0x10000, /* clause is being counted by profiler */
|
|
|
|
DynamicMask = 0x8000, /* dynamic predicate */
|
|
|
|
InUseMask = 0x4000, /* this block is being used */
|
|
|
|
ErasedMask = 0x2000, /* this block has been erased */
|
|
|
|
IndexMask = 0x1000, /* indexing code */
|
|
|
|
DBClMask = 0x0800, /* data base structure */
|
|
|
|
LogUpdRuleMask = 0x0400, /* code is for a log upd rule with env */
|
|
|
|
LogUpdMask = 0x0200, /* logic update index. */
|
|
|
|
StaticMask = 0x0100, /* static predicates */
|
|
|
|
DirtyMask = 0x0080, /* LUIndices */
|
|
|
|
HasCutMask = 0x0040, /* ! */
|
|
|
|
SrcMask = 0x0020, /* has a source term, only for static references */
|
|
|
|
/* other flags belong to DB */
|
2005-05-27 23:27:59 +01:00
|
|
|
} dbentry_flags;
|
|
|
|
|
2015-01-06 17:47:58 +00:00
|
|
|
/* predicate initialization */
|
2016-03-29 02:02:43 +01:00
|
|
|
void Yap_InitCPred(const char *name, arity_t arity, CPredicate f,
|
|
|
|
pred_flags_t flags);
|
|
|
|
void Yap_InitAsmPred(const char *name, arity_t arity, int code, CPredicate asmc,
|
|
|
|
pred_flags_t flags);
|
|
|
|
void Yap_InitCmpPred(const char *name, arity_t arity, CmpPredicate cmp,
|
|
|
|
pred_flags_t flags);
|
|
|
|
void Yap_InitCPredBack(const char *name, arity_t arity, arity_t extra,
|
|
|
|
CPredicate call, CPredicate retry, pred_flags_t flags);
|
|
|
|
void Yap_InitCPredBackCut(const char *name, arity_t arity, arity_t extra,
|
|
|
|
CPredicate call, CPredicate retry, CPredicate cut,
|
|
|
|
pred_flags_t flags);
|
|
|
|
void Yap_InitCPredBack_(const char *name, arity_t arity, arity_t extra,
|
|
|
|
CPredicate call, CPredicate retry, CPredicate cut,
|
|
|
|
pred_flags_t flags);
|
2015-01-06 17:47:58 +00:00
|
|
|
|
2005-05-27 23:27:59 +01:00
|
|
|
/* *********************** DBrefs **************************************/
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
typedef struct DB_TERM {
|
2005-05-27 23:27:59 +01:00
|
|
|
#ifdef COROUTINING
|
2007-11-06 17:02:13 +00:00
|
|
|
union {
|
2016-01-03 02:06:09 +00:00
|
|
|
CELL attachments; /* attached terms */
|
2013-11-05 17:59:19 +00:00
|
|
|
Int line_number;
|
2007-11-06 17:02:13 +00:00
|
|
|
struct DB_TERM *NextDBT;
|
|
|
|
} ag;
|
2005-05-27 23:27:59 +01:00
|
|
|
#endif
|
2016-01-03 02:06:09 +00:00
|
|
|
struct DB_STRUCT **DBRefs; /* pointer to other references */
|
|
|
|
CELL NOfCells; /* Size of Term */
|
|
|
|
CELL Entry; /* entry point */
|
|
|
|
Term Contents[MIN_ARRAY]; /* stored term */
|
2005-05-27 23:27:59 +01:00
|
|
|
} DBTerm;
|
|
|
|
|
2012-06-30 19:42:14 +01:00
|
|
|
INLINE_ONLY inline EXTERN DBTerm *TermToDBTerm(Term);
|
2007-11-06 17:02:13 +00:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN DBTerm *TermToDBTerm(Term X) {
|
2007-11-06 17:02:13 +00:00
|
|
|
if (IsPairTerm(X)) {
|
2016-01-03 02:06:09 +00:00
|
|
|
return (DBTerm *)((unsigned char *)RepPair(X) - (CELL) &
|
|
|
|
(((DBTerm *)NULL)->Contents));
|
2007-11-06 17:02:13 +00:00
|
|
|
} else {
|
2016-01-03 02:06:09 +00:00
|
|
|
return (DBTerm *)((unsigned char *)RepAppl(X) - (CELL) &
|
|
|
|
(((DBTerm *)NULL)->Contents));
|
2007-11-06 17:02:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-27 23:27:59 +01:00
|
|
|
/* The ordering of the first 3 fields should be compatible with lu_clauses */
|
2016-01-03 02:06:09 +00:00
|
|
|
typedef struct DB_STRUCT {
|
|
|
|
Functor id; /* allow pointers to this struct to id */
|
2005-05-27 23:27:59 +01:00
|
|
|
/* as dbref */
|
2016-01-03 02:06:09 +00:00
|
|
|
CELL Flags; /* Term Flags */
|
2005-05-27 23:27:59 +01:00
|
|
|
#if defined(YAPOR) || defined(THREADS)
|
2016-01-03 02:06:09 +00:00
|
|
|
lockvar lock; /* a simple lock to protect this entry */
|
2011-04-14 18:51:11 +01:00
|
|
|
#endif
|
|
|
|
#if MULTIPLE_STACKS
|
2016-01-03 02:06:09 +00:00
|
|
|
Int ref_count; /* how many branches are using this entry */
|
2005-05-27 23:27:59 +01:00
|
|
|
#endif
|
2016-01-03 02:06:09 +00:00
|
|
|
CELL NOfRefsTo; /* Number of references pointing here */
|
|
|
|
struct struct_dbentry *Parent; /* key of DBase reference */
|
|
|
|
struct yami *Code; /* pointer to code if this is a clause */
|
|
|
|
struct DB_STRUCT *Prev; /* Previous element in chain */
|
|
|
|
struct DB_STRUCT *Next; /* Next element in chain */
|
|
|
|
struct DB_STRUCT *p, *n; /* entry's age, negative if from recorda,
|
|
|
|
positive if it was recordz */
|
|
|
|
CELL Mask; /* parts that should be cleared */
|
|
|
|
CELL Key; /* A mask that can be used to check before
|
|
|
|
you unify */
|
2005-05-27 23:27:59 +01:00
|
|
|
DBTerm DBT;
|
|
|
|
} DBStruct;
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
#define DBStructFlagsToDBStruct(X) \
|
|
|
|
((DBRef)((unsigned char *)(X) - (CELL) & (((DBRef)NULL)->Flags)))
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2014-10-13 12:34:52 +01:00
|
|
|
#if MULTIPLE_STACKS
|
2005-05-27 23:27:59 +01:00
|
|
|
#define INIT_DBREF_COUNT(X) (X)->ref_count = 0
|
2016-01-03 02:06:09 +00:00
|
|
|
#define INC_DBREF_COUNT(X) (X)->ref_count++
|
|
|
|
#define DEC_DBREF_COUNT(X) (X)->ref_count--
|
|
|
|
#define DBREF_IN_USE(X) ((X)->ref_count != 0)
|
2005-05-27 23:27:59 +01:00
|
|
|
#else
|
|
|
|
#define INIT_DBREF_COUNT(X)
|
2016-01-03 02:06:09 +00:00
|
|
|
#define INC_DBREF_COUNT(X)
|
|
|
|
#define DEC_DBREF_COUNT(X)
|
|
|
|
#define DBREF_IN_USE(X) ((X)->Flags & InUseMask)
|
2005-05-27 23:27:59 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef DBStruct *DBRef;
|
|
|
|
|
|
|
|
/* extern Functor FunctorDBRef; */
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN int IsDBRefTerm(Term);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN int IsDBRefTerm(Term t) {
|
|
|
|
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorDBRef);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Term MkDBRefTerm(DBRef);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Term MkDBRefTerm(DBRef p) {
|
|
|
|
return (Term)((AbsAppl(((CELL *)(p)))));
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN DBRef DBRefOfTerm(Term t);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN DBRef DBRefOfTerm(Term t) {
|
|
|
|
return (DBRef)(((DBRef)(RepAppl(t))));
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN int IsRefTerm(Term);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN int IsRefTerm(Term t) {
|
|
|
|
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorDBRef);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN CODEADDR RefOfTerm(Term t);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN CODEADDR RefOfTerm(Term t) {
|
|
|
|
return (CODEADDR)(DBRefOfTerm(t));
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
typedef struct struct_dbentry {
|
|
|
|
Prop NextOfPE; /* used to chain properties */
|
|
|
|
PropFlags KindOfPE; /* kind of property */
|
|
|
|
unsigned int ArityOfDB; /* kind of property */
|
|
|
|
Functor FunctorOfDB; /* functor for this property */
|
2005-05-27 23:27:59 +01:00
|
|
|
#if defined(YAPOR) || defined(THREADS)
|
2016-01-03 02:06:09 +00:00
|
|
|
rwlock_t DBRWLock; /* a simple lock to protect this entry */
|
2005-05-27 23:27:59 +01:00
|
|
|
#endif
|
2016-01-03 02:06:09 +00:00
|
|
|
DBRef First; /* first DBase entry */
|
|
|
|
DBRef Last; /* last DBase entry */
|
|
|
|
Term ModuleOfDB; /* module for this definition */
|
|
|
|
DBRef F0, L0; /* everyone */
|
2005-05-27 23:27:59 +01:00
|
|
|
} DBEntry;
|
|
|
|
typedef DBEntry *DBProp;
|
2016-01-03 02:06:09 +00:00
|
|
|
#define DBProperty ((PropFlags)0x8000)
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
typedef struct {
|
|
|
|
Prop NextOfPE; /* used to chain properties */
|
|
|
|
PropFlags KindOfPE; /* kind of property */
|
|
|
|
unsigned int ArityOfDB; /* kind of property */
|
|
|
|
Functor FunctorOfDB; /* functor for this property */
|
2005-05-27 23:27:59 +01:00
|
|
|
#if defined(YAPOR) || defined(THREADS)
|
2016-01-03 02:06:09 +00:00
|
|
|
rwlock_t DBRWLock; /* a simple lock to protect this entry */
|
2005-05-27 23:27:59 +01:00
|
|
|
#endif
|
2016-01-03 02:06:09 +00:00
|
|
|
DBRef First; /* first DBase entry */
|
|
|
|
DBRef Last; /* last DBase entry */
|
|
|
|
Term ModuleOfDB; /* module for this definition */
|
|
|
|
Int NOfEntries; /* age counter */
|
|
|
|
DBRef Index; /* age counter */
|
2005-05-27 23:27:59 +01:00
|
|
|
} LogUpdDBEntry;
|
|
|
|
typedef LogUpdDBEntry *LogUpdDBProp;
|
2016-01-03 02:06:09 +00:00
|
|
|
#define CodeDBBit 0x2
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
#define CodeDBProperty (DBProperty | CodeDBBit)
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN PropFlags IsDBProperty(int);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN PropFlags IsDBProperty(int flags) {
|
|
|
|
return (PropFlags)((flags & ~CodeDBBit) == DBProperty);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#if USE_OFFSETS_IN_PROPS
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN DBProp RepDBProp(Prop p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN DBProp RepDBProp(Prop p) {
|
|
|
|
return (DBProp)(AtomBase + Unsigned(p));
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsDBProp(DBProp p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsDBProp(DBProp p) {
|
|
|
|
return (Prop)(Addr(p) - AtomBase);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN DBProp RepDBProp(Prop p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN DBProp RepDBProp(Prop p) { return (DBProp)(p); }
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsDBProp(DBProp p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsDBProp(DBProp p) { return (Prop)(p); }
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* These are the actual flags for DataBase terms */
|
2016-01-03 02:06:09 +00:00
|
|
|
typedef enum {
|
2005-05-27 23:27:59 +01:00
|
|
|
DBAtomic = 0x1,
|
|
|
|
DBVar = 0x2,
|
|
|
|
DBNoVars = 0x4,
|
|
|
|
DBComplex = 0x8,
|
|
|
|
DBCode = 0x10,
|
|
|
|
DBNoCode = 0x20,
|
|
|
|
DBWithRefs = 0x40
|
|
|
|
} db_term_flags;
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
typedef struct {
|
|
|
|
Prop NextOfPE; /* used to chain properties */
|
|
|
|
PropFlags KindOfPE; /* kind of property */
|
|
|
|
Atom KeyOfBB; /* functor for this property */
|
|
|
|
Term Element; /* blackboard element */
|
2005-05-27 23:27:59 +01:00
|
|
|
#if defined(YAPOR) || defined(THREADS)
|
2016-01-03 02:06:09 +00:00
|
|
|
rwlock_t BBRWLock; /* a read-write lock to protect the entry */
|
2005-05-27 23:27:59 +01:00
|
|
|
#endif
|
2016-01-03 02:06:09 +00:00
|
|
|
Term ModuleOfBB; /* module for this definition */
|
2005-05-27 23:27:59 +01:00
|
|
|
} BlackBoardEntry;
|
|
|
|
typedef BlackBoardEntry *BBProp;
|
|
|
|
|
|
|
|
#if USE_OFFSETS_IN_PROPS
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN BlackBoardEntry *RepBBProp(Prop p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN BlackBoardEntry *RepBBProp(Prop p) {
|
|
|
|
return (BlackBoardEntry *)(AtomBase + Unsigned(p));
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsBBProp(BlackBoardEntry *p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsBBProp(BlackBoardEntry *p) {
|
|
|
|
return (Prop)(Addr(p) - AtomBase);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN BlackBoardEntry *RepBBProp(Prop p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN BlackBoardEntry *RepBBProp(Prop p) {
|
|
|
|
return (BlackBoardEntry *)(p);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsBBProp(BlackBoardEntry *p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsBBProp(BlackBoardEntry *p) {
|
|
|
|
return (Prop)(p);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
#define BBProperty ((PropFlags)0xfffb)
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN PropFlags IsBBProperty(int);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN PropFlags IsBBProperty(int flags) {
|
|
|
|
return (PropFlags)((flags == BBProperty));
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2007-12-05 12:17:25 +00:00
|
|
|
/* hold property entry structure */
|
2016-01-03 02:06:09 +00:00
|
|
|
typedef struct hold_entry {
|
|
|
|
Prop NextOfPE; /* used to chain properties */
|
|
|
|
PropFlags KindOfPE; /* kind of property */
|
|
|
|
UInt RefsOfPE; /* used to count the number of holds */
|
2007-12-05 12:17:25 +00:00
|
|
|
} HoldEntry;
|
|
|
|
|
|
|
|
#if USE_OFFSETS_IN_PROPS
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN HoldEntry *RepHoldProp(Prop p);
|
2007-12-05 12:17:25 +00:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN HoldEntry *RepHoldProp(Prop p) {
|
|
|
|
return (HoldEntry *)(AtomBase + Unsigned(p));
|
2007-12-05 12:17:25 +00:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsHoldProp(HoldEntry *p);
|
2007-12-05 12:17:25 +00:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsHoldProp(HoldEntry *p) {
|
|
|
|
return (Prop)(Addr(p) - AtomBase);
|
2007-12-05 12:17:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN HoldEntry *RepHoldProp(Prop p);
|
2007-12-05 12:17:25 +00:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN HoldEntry *RepHoldProp(Prop p) {
|
|
|
|
return (HoldEntry *)(p);
|
2007-12-05 12:17:25 +00:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsHoldProp(HoldEntry *p);
|
2007-12-05 12:17:25 +00:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsHoldProp(HoldEntry *p) { return (Prop)(p); }
|
2007-12-05 12:17:25 +00:00
|
|
|
|
|
|
|
#endif
|
2013-10-04 13:22:00 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
#define HoldProperty 0xfff6
|
2007-12-05 12:17:25 +00:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
/* translation property entry structure */
|
|
|
|
typedef struct translation_entry {
|
|
|
|
Prop NextOfPE; /* used to chain properties */
|
|
|
|
PropFlags KindOfPE; /* kind of property */
|
|
|
|
arity_t arity; /* refers to atom (0) or functor(N > 0) */
|
|
|
|
Int Translation; /* used to hash the atom as an integer; */
|
|
|
|
} TranslationEntry;
|
2013-10-04 13:22:00 +01:00
|
|
|
|
|
|
|
#if USE_OFFSETS_IN_PROPS
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN TranslationEntry *RepTranslationProp(Prop p);
|
2013-10-04 13:22:00 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN TranslationEntry *RepTranslationProp(Prop p) {
|
|
|
|
return (TranslationEntry *)(AtomBase + Unsigned(p));
|
2013-10-04 13:22:00 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsTranslationProp(TranslationEntry *p);
|
2013-10-04 13:22:00 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsTranslationProp(TranslationEntry *p) {
|
|
|
|
return (Prop)(Addr(p) - AtomBase);
|
2013-10-04 13:22:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN TranslationEntry *RepTranslationProp(Prop p);
|
2013-10-04 13:22:00 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN TranslationEntry *RepTranslationProp(Prop p) {
|
|
|
|
return (TranslationEntry *)(p);
|
2013-10-04 13:22:00 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsTranslationProp(TranslationEntry *p);
|
2013-10-04 13:22:00 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsTranslationProp(TranslationEntry *p) {
|
|
|
|
return (Prop)(p);
|
2013-10-04 13:22:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2016-01-03 02:06:09 +00:00
|
|
|
#define TranslationProperty 0xfff4
|
2013-10-04 13:22:00 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
bool Yap_PutAtomTranslation(Atom a, arity_t arity, Int i);
|
2013-10-04 13:22:00 +01:00
|
|
|
|
|
|
|
/* get translation prop for atom; */
|
2016-01-03 02:06:09 +00:00
|
|
|
static inline TranslationEntry *Yap_GetTranslationProp(Atom at, arity_t arity) {
|
2013-10-04 13:22:00 +01:00
|
|
|
Prop p0;
|
|
|
|
AtomEntry *ae = RepAtom(at);
|
|
|
|
TranslationEntry *p;
|
|
|
|
|
|
|
|
READ_LOCK(ae->ARWLock);
|
|
|
|
p = RepTranslationProp(p0 = ae->PropsOfAE);
|
2016-01-03 02:06:09 +00:00
|
|
|
while (p0 && (p->KindOfPE != TranslationProperty || p->arity != arity))
|
2013-10-04 13:22:00 +01:00
|
|
|
p = RepTranslationProp(p0 = p->NextOfPE);
|
|
|
|
READ_UNLOCK(ae->ARWLock);
|
2016-01-03 02:06:09 +00:00
|
|
|
if (p0 == NIL)
|
|
|
|
return (TranslationEntry *)NULL;
|
2015-08-07 22:57:53 +01:00
|
|
|
p->arity = arity;
|
2013-10-04 13:22:00 +01:00
|
|
|
return p;
|
|
|
|
}
|
2015-04-13 13:28:17 +01:00
|
|
|
|
2016-04-10 14:21:17 +01:00
|
|
|
INLINE_ONLY inline EXTERN bool IsTranslationProperty(PropFlags);
|
2007-12-05 12:17:25 +00:00
|
|
|
|
2016-04-10 14:21:17 +01:00
|
|
|
INLINE_ONLY inline EXTERN bool IsTranslationProperty(PropFlags flags) {
|
|
|
|
return flags == TranslationProperty;
|
2007-12-05 12:17:25 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 16:41:53 +00:00
|
|
|
/*** handle named mutexes */
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
/* named mutex property entry structure */
|
|
|
|
typedef struct mutex_entry {
|
|
|
|
Prop NextOfPE; /* used to chain properties */
|
|
|
|
PropFlags KindOfPE; /* kind of property */
|
|
|
|
void *Mutex; /* used to hash the atom as an integer; */
|
|
|
|
} MutexEntry;
|
2014-11-25 16:41:53 +00:00
|
|
|
|
|
|
|
#if USE_OFFSETS_IN_PROPS
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN MutexEntry *RepMutexProp(Prop p);
|
2014-11-25 16:41:53 +00:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN MutexEntry *RepMutexProp(Prop p) {
|
|
|
|
return (MutexEntry *)(AtomBase + Unsigned(p));
|
|
|
|
}
|
2014-11-25 16:41:53 +00:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsMutexProp(MutexEntry *p);
|
2014-11-25 16:41:53 +00:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsMutexProp(MutexEntry *p) {
|
|
|
|
return (Prop)(Addr(p) - AtomBase);
|
|
|
|
}
|
2014-11-25 16:41:53 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN MutexEntry *RepMutexProp(Prop p);
|
2014-11-25 16:41:53 +00:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN MutexEntry *RepMutexProp(Prop p) {
|
|
|
|
return (MutexEntry *)(p);
|
|
|
|
}
|
2014-11-25 16:41:53 +00:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsMutexProp(MutexEntry *p);
|
2014-11-25 16:41:53 +00:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsMutexProp(MutexEntry *p) { return (Prop)(p); }
|
2014-11-25 16:41:53 +00:00
|
|
|
|
|
|
|
#endif
|
2016-01-03 02:06:09 +00:00
|
|
|
#define MutexProperty 0xfff5
|
2014-11-25 16:41:53 +00:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
bool Yap_PutAtomMutex(Atom a, void *ptr);
|
2014-11-25 16:41:53 +00:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
/* get mutex prop for atom; */
|
|
|
|
static inline void *Yap_GetMutexFromProp(Atom at) {
|
|
|
|
Prop p0;
|
|
|
|
AtomEntry *ae = RepAtom(at);
|
|
|
|
MutexEntry *p;
|
2014-11-25 16:41:53 +00:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
READ_LOCK(ae->ARWLock);
|
|
|
|
p = RepMutexProp(p0 = ae->PropsOfAE);
|
|
|
|
while (p0 && p->KindOfPE != MutexProperty)
|
|
|
|
p = RepMutexProp(p0 = p->NextOfPE);
|
|
|
|
READ_UNLOCK(ae->ARWLock);
|
|
|
|
if (p0 == NIL)
|
|
|
|
return NULL;
|
|
|
|
return p->Mutex;
|
|
|
|
}
|
2014-11-25 16:41:53 +00:00
|
|
|
|
2016-04-10 14:21:17 +01:00
|
|
|
INLINE_ONLY inline EXTERN bool IsMutexProperty(PropFlags);
|
2014-11-25 16:41:53 +00:00
|
|
|
|
2016-04-10 14:21:17 +01:00
|
|
|
INLINE_ONLY inline EXTERN bool IsMutexProperty(PropFlags flags) {
|
2016-01-03 02:06:09 +00:00
|
|
|
return (PropFlags)((flags == MutexProperty));
|
|
|
|
}
|
2014-11-25 16:41:53 +00:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
/* end of code for named mutexes */
|
2015-04-13 13:28:17 +01:00
|
|
|
|
2014-01-02 19:11:06 +00:00
|
|
|
typedef enum {
|
|
|
|
STATIC_ARRAY = 1,
|
|
|
|
DYNAMIC_ARRAY = 2,
|
|
|
|
MMAP_ARRAY = 4,
|
|
|
|
FIXED_ARRAY = 8
|
|
|
|
} array_type;
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
/* array property entry structure */
|
|
|
|
/* first case is for dynamic arrays */
|
2016-01-03 02:06:09 +00:00
|
|
|
typedef struct array_entry {
|
|
|
|
Prop NextOfPE; /* used to chain properties */
|
|
|
|
PropFlags KindOfPE; /* kind of property */
|
|
|
|
Int ArrayEArity; /* Arity of Array (positive) */
|
2014-01-02 19:11:06 +00:00
|
|
|
array_type TypeOfAE;
|
2005-05-27 23:27:59 +01:00
|
|
|
#if defined(YAPOR) || defined(THREADS)
|
2016-01-03 02:06:09 +00:00
|
|
|
rwlock_t ArRWLock; /* a read-write lock to protect the entry */
|
2005-09-22 04:26:13 +01:00
|
|
|
#if THREADS
|
|
|
|
unsigned int owner_id;
|
2005-11-17 13:40:18 +00:00
|
|
|
#endif
|
2005-09-22 04:26:13 +01:00
|
|
|
#endif
|
2005-10-28 18:38:50 +01:00
|
|
|
struct array_entry *NextAE;
|
2016-01-03 02:06:09 +00:00
|
|
|
Term ValueOfVE; /* Pointer to the actual array */
|
2005-05-27 23:27:59 +01:00
|
|
|
} ArrayEntry;
|
|
|
|
|
|
|
|
/* second case is for static arrays */
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
typedef struct {
|
2005-10-19 20:00:48 +01:00
|
|
|
Term tlive;
|
|
|
|
Term tstore;
|
|
|
|
} live_term;
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
typedef union {
|
2005-05-27 23:27:59 +01:00
|
|
|
Int *ints;
|
|
|
|
char *chars;
|
|
|
|
unsigned char *uchars;
|
|
|
|
Float *floats;
|
|
|
|
AtomEntry **ptrs;
|
|
|
|
Term *atoms;
|
|
|
|
Term *dbrefs;
|
|
|
|
DBTerm **terms;
|
2005-10-19 20:00:48 +01:00
|
|
|
live_term *lterms;
|
2005-05-27 23:27:59 +01:00
|
|
|
} statarray_elements;
|
|
|
|
|
|
|
|
/* next, the actual data structure */
|
2016-01-03 02:06:09 +00:00
|
|
|
typedef struct static_array_entry {
|
|
|
|
Prop NextOfPE; /* used to chain properties */
|
|
|
|
PropFlags KindOfPE; /* kind of property */
|
|
|
|
Int ArrayEArity; /* Arity of Array (negative) */
|
2014-01-02 19:11:06 +00:00
|
|
|
array_type TypeOfAE;
|
2005-05-27 23:27:59 +01:00
|
|
|
#if defined(YAPOR) || defined(THREADS)
|
2016-01-03 02:06:09 +00:00
|
|
|
rwlock_t ArRWLock; /* a read-write lock to protect the entry */
|
2005-05-27 23:27:59 +01:00
|
|
|
#endif
|
2005-10-28 18:38:50 +01:00
|
|
|
struct static_array_entry *NextAE;
|
2016-01-03 02:06:09 +00:00
|
|
|
static_array_types ArrayType; /* Type of Array Elements. */
|
|
|
|
statarray_elements ValueOfVE; /* Pointer to the Array itself */
|
2005-05-27 23:27:59 +01:00
|
|
|
} StaticArrayEntry;
|
|
|
|
|
|
|
|
#if USE_OFFSETS_IN_PROPS
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN ArrayEntry *RepArrayProp(Prop p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN ArrayEntry *RepArrayProp(Prop p) {
|
|
|
|
return (ArrayEntry *)(AtomBase + Unsigned(p));
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsArrayProp(ArrayEntry *p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsArrayProp(ArrayEntry *p) {
|
|
|
|
return (Prop)(Addr(p) - AtomBase);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN StaticArrayEntry *RepStaticArrayProp(Prop p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN StaticArrayEntry *RepStaticArrayProp(Prop p) {
|
|
|
|
return (StaticArrayEntry *)(AtomBase + Unsigned(p));
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsStaticArrayProp(StaticArrayEntry *p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsStaticArrayProp(StaticArrayEntry *p) {
|
|
|
|
return (Prop)(Addr(p) - AtomBase);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN ArrayEntry *RepArrayProp(Prop p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN ArrayEntry *RepArrayProp(Prop p) {
|
|
|
|
return (ArrayEntry *)(p);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsArrayProp(ArrayEntry *p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsArrayProp(ArrayEntry *p) { return (Prop)(p); }
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN StaticArrayEntry *RepStaticArrayProp(Prop p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN StaticArrayEntry *RepStaticArrayProp(Prop p) {
|
|
|
|
return (StaticArrayEntry *)(p);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsStaticArrayProp(StaticArrayEntry *p);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsStaticArrayProp(StaticArrayEntry *p) {
|
|
|
|
return (Prop)(p);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2016-01-03 02:06:09 +00:00
|
|
|
#define ArrayProperty ((PropFlags)0xfff7)
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-04-10 14:21:17 +01:00
|
|
|
INLINE_ONLY inline EXTERN bool ArrayIsDynamic(ArrayEntry *);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-04-10 14:21:17 +01:00
|
|
|
INLINE_ONLY inline EXTERN bool ArrayIsDynamic(ArrayEntry *are) {
|
|
|
|
return ((are)->TypeOfAE & DYNAMIC_ARRAY) != 0;
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2016-04-10 14:21:17 +01:00
|
|
|
INLINE_ONLY inline EXTERN bool IsArrayProperty(PropFlags);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-04-10 14:21:17 +01:00
|
|
|
INLINE_ONLY inline EXTERN bool IsArrayProperty(PropFlags flags) {
|
|
|
|
return flags == ArrayProperty;
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2010-11-29 23:17:06 +00:00
|
|
|
/* SWI Blob property */
|
2016-01-03 02:06:09 +00:00
|
|
|
typedef struct YAP_blob_prop_entry {
|
|
|
|
Prop NextOfPE; /* used to chain properties */
|
|
|
|
PropFlags KindOfPE; /* kind of property */
|
|
|
|
struct YAP_blob_t *blob_type; /* type of blob */
|
2015-10-22 00:33:38 +01:00
|
|
|
} YAP_BlobPropEntry;
|
2010-11-29 23:17:06 +00:00
|
|
|
|
|
|
|
#if USE_OFFSETS_IN_PROPS
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN YAP_BlobPropEntry *RepBlobProp(Prop p);
|
2010-11-29 23:17:06 +00:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN YAP_BlobPropEntry *RepBlobProp(Prop p) {
|
|
|
|
return (YAP_BlobPropEntry *)(AtomBase + Unsigned(p));
|
2010-11-29 23:17:06 +00:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN AtomEntry *AbsBlobProp(BlobPropEntry *p);
|
2010-11-29 23:17:06 +00:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsBlobProp(YAP_BlobPropEntry *p) {
|
|
|
|
return (Prop)(Addr(p) - AtomBase);
|
2010-11-29 23:17:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN YAP_BlobPropEntry *RepBlobProp(Prop p);
|
2010-11-29 23:17:06 +00:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN YAP_BlobPropEntry *RepBlobProp(Prop p) {
|
|
|
|
return (YAP_BlobPropEntry *)(p);
|
2010-11-29 23:17:06 +00:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsBlobProp(YAP_BlobPropEntry *p);
|
2010-11-29 23:17:06 +00:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsBlobProp(YAP_BlobPropEntry *p) {
|
|
|
|
return (Prop)(p);
|
2010-11-29 23:17:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
#define BlobProperty ((PropFlags)0xfffe)
|
2010-11-29 23:17:06 +00:00
|
|
|
|
2016-04-10 14:21:17 +01:00
|
|
|
INLINE_ONLY inline EXTERN bool IsBlobProperty(PropFlags);
|
2010-11-29 23:17:06 +00:00
|
|
|
|
2016-04-19 23:30:02 +01:00
|
|
|
INLINE_ONLY inline EXTERN bool IsBlobProperty(PropFlags flags) {
|
2016-04-10 14:21:17 +01:00
|
|
|
return flags == BlobProperty;
|
2010-11-29 23:17:06 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 14:21:17 +01:00
|
|
|
INLINE_ONLY inline EXTERN bool IsBlob(Atom);
|
2010-11-29 23:17:06 +00:00
|
|
|
|
2016-04-10 14:21:17 +01:00
|
|
|
INLINE_ONLY inline EXTERN bool IsBlob(Atom at) {
|
|
|
|
return RepAtom(at)->PropsOfAE != NIL &&
|
2016-01-03 02:06:09 +00:00
|
|
|
IsBlobProperty(RepBlobProp(RepAtom(at)->PropsOfAE)->KindOfPE);
|
2010-11-29 23:17:06 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 14:21:17 +01:00
|
|
|
INLINE_ONLY inline EXTERN bool IsValProperty(PropFlags);
|
2015-06-19 00:50:41 +01:00
|
|
|
|
2016-04-10 14:21:17 +01:00
|
|
|
INLINE_ONLY inline EXTERN bool IsValProperty(PropFlags flags) {
|
|
|
|
return flags == ValProperty;
|
2015-06-19 00:50:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* flag property entry structure */
|
|
|
|
|
2016-05-12 11:43:26 +01:00
|
|
|
typedef Term (*flag_func)(Term);
|
|
|
|
typedef bool (*flag_helper_func)(Term);
|
2015-06-19 00:50:41 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
typedef struct {
|
|
|
|
Prop NextOfPE; /* used to chain properties */
|
|
|
|
PropFlags KindOfPE; /* kind of property */
|
2015-06-19 00:50:41 +01:00
|
|
|
#if defined(YAPOR) || defined(THREADS)
|
2016-01-03 02:06:09 +00:00
|
|
|
rwlock_t VRWLock; /* a read-write lock to protect the entry */
|
2015-06-19 00:50:41 +01:00
|
|
|
#endif
|
2016-01-03 02:06:09 +00:00
|
|
|
int FlagOfVE; /* (atomic) value associated with the atom */
|
2015-06-19 00:50:41 +01:00
|
|
|
bool global, atomic, rw;
|
2016-05-12 11:43:26 +01:00
|
|
|
flag_func type;
|
|
|
|
flag_helper_func helper;
|
2015-06-19 00:50:41 +01:00
|
|
|
} FlagEntry;
|
|
|
|
#if USE_OFFSETS_IN_PROPS
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN FlagEntry *RepFlagProp(Prop p);
|
2015-06-19 00:50:41 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN FlagEntry *RepFlagProp(Prop p) {
|
|
|
|
return (FlagEntry *)(AtomBase + Unsigned(p));
|
2015-06-19 00:50:41 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsFlagProp(FlagEntry *p);
|
2015-06-19 00:50:41 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsValProp(FlagEntry *p) {
|
|
|
|
return (Prop)(Addr(p) - AtomBase);
|
2015-06-19 00:50:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN FlagEntry *RepFlagProp(Prop p);
|
2015-06-19 00:50:41 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN FlagEntry *RepFlagProp(Prop p) {
|
|
|
|
return (FlagEntry *)(p);
|
2015-06-19 00:50:41 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsFlagProp(FlagEntry *p);
|
2015-06-19 00:50:41 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN Prop AbsFlagProp(FlagEntry *p) { return (Prop)(p); }
|
2015-06-19 00:50:41 +01:00
|
|
|
|
|
|
|
#endif
|
2016-01-03 02:06:09 +00:00
|
|
|
#define FlagProperty ((PropFlags)0xfff9)
|
2015-06-19 00:50:41 +01:00
|
|
|
|
2016-04-10 14:21:17 +01:00
|
|
|
INLINE_ONLY inline EXTERN bool IsFlagProperty(PropFlags);
|
|
|
|
|
|
|
|
INLINE_ONLY inline EXTERN bool IsFlagProperty(PropFlags flags) {
|
2016-04-19 23:30:02 +01:00
|
|
|
return flags == FlagProperty;
|
2015-06-19 00:50:41 +01:00
|
|
|
}
|
|
|
|
|
2005-05-27 23:27:59 +01:00
|
|
|
/* Proto types */
|
|
|
|
|
|
|
|
/* cdmgr.c */
|
2013-04-25 23:15:04 +01:00
|
|
|
int Yap_RemoveIndexation(PredEntry *);
|
|
|
|
void Yap_UpdateTimestamps(PredEntry *);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
/* dbase.c */
|
2013-04-25 23:15:04 +01:00
|
|
|
void Yap_ErDBE(DBRef);
|
|
|
|
DBTerm *Yap_StoreTermInDB(Term, int);
|
|
|
|
DBTerm *Yap_StoreTermInDBPlusExtraSpace(Term, UInt, UInt *);
|
|
|
|
Term Yap_FetchTermFromDB(DBTerm *);
|
2013-11-05 17:59:19 +00:00
|
|
|
Term Yap_FetchClauseTermFromDB(DBTerm *);
|
2013-04-25 23:15:04 +01:00
|
|
|
Term Yap_PopTermFromDB(DBTerm *);
|
|
|
|
void Yap_ReleaseTermFromDB(DBTerm *);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
/* init.c */
|
2013-04-25 23:15:04 +01:00
|
|
|
Atom Yap_GetOp(OpEntry *, int *, int);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
/* vsc: redefined to GetAProp to avoid conflicts with Windows header files */
|
2013-04-25 23:15:04 +01:00
|
|
|
Prop Yap_GetAProp(Atom, PropFlags);
|
|
|
|
Prop Yap_GetAPropHavingLock(AtomEntry *, PropFlags);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
#define PROLOG_MODULE 0
|
2007-09-29 00:18:17 +01:00
|
|
|
|
2009-10-23 14:22:17 +01:00
|
|
|
#include "YapHeap.h"
|
2007-09-29 00:18:17 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
#define PredHashInitialSize ((UInt)1039)
|
|
|
|
#define PredHashIncrement ((UInt)7919)
|
2010-03-21 22:12:42 +00:00
|
|
|
|
2015-06-19 00:50:41 +01:00
|
|
|
/*************************************************************************************************
|
|
|
|
flag support
|
|
|
|
*************************************************************************************************/
|
|
|
|
|
|
|
|
#include "YapFlags.h"
|
2013-04-25 23:15:04 +01:00
|
|
|
INLINE_ONLY EXTERN inline UInt PRED_HASH(FunctorEntry *, Term, UInt);
|
2007-09-29 00:18:17 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY EXTERN inline UInt PRED_HASH(FunctorEntry *fe, Term cur_mod,
|
|
|
|
UInt size) {
|
|
|
|
return (((CELL)fe + cur_mod) >> 2) % size;
|
2007-09-29 00:18:17 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY EXTERN inline Prop GetPredPropByFuncAndModHavingLock(FunctorEntry *,
|
|
|
|
Term);
|
2013-04-25 23:15:04 +01:00
|
|
|
INLINE_ONLY EXTERN inline Prop PredPropByFuncAndMod(FunctorEntry *, Term);
|
|
|
|
INLINE_ONLY EXTERN inline Prop PredPropByAtomAndMod(Atom, Term);
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY EXTERN inline Prop GetPredPropByFuncHavingLock(FunctorEntry *,
|
|
|
|
Term);
|
|
|
|
INLINE_ONLY EXTERN inline Prop PredPropByFunc(Functor fe, Term cur_mod);
|
|
|
|
INLINE_ONLY EXTERN inline Prop PredPropByAtom(Atom at, Term cur_mod);
|
2007-09-29 00:18:17 +01:00
|
|
|
|
2009-03-24 13:27:36 +00:00
|
|
|
#ifdef THREADS
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
Prop Yap_NewThreadPred(struct pred_entry *CACHE_TYPE);
|
2013-04-25 23:15:04 +01:00
|
|
|
Prop Yap_NewPredPropByFunctor(Functor, Term);
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY EXTERN inline struct pred_entry *
|
|
|
|
Yap_GetThreadPred(struct pred_entry *CACHE_TYPE);
|
2009-03-24 13:27:36 +00:00
|
|
|
|
2012-06-30 19:42:14 +01:00
|
|
|
INLINE_ONLY EXTERN inline struct pred_entry *
|
2016-01-03 02:06:09 +00:00
|
|
|
Yap_GetThreadPred(struct pred_entry *ap USES_REGS) {
|
2009-03-24 13:27:36 +00:00
|
|
|
Functor f = ap->FunctorOfPred;
|
2016-01-03 02:06:09 +00:00
|
|
|
Term mod = ap->ModuleOfPred;
|
2011-05-09 19:55:06 +01:00
|
|
|
Prop p0 = AbsPredProp(LOCAL_ThreadHandle.local_preds);
|
2009-03-24 13:27:36 +00:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
while (p0) {
|
2009-03-24 13:27:36 +00:00
|
|
|
PredEntry *ap = RepPredProp(p0);
|
2016-01-03 02:06:09 +00:00
|
|
|
if (ap->FunctorOfPred == f && ap->ModuleOfPred == mod)
|
|
|
|
return ap;
|
2009-03-24 13:27:36 +00:00
|
|
|
p0 = ap->NextOfPE;
|
|
|
|
}
|
2011-03-07 16:02:55 +00:00
|
|
|
return RepPredProp(Yap_NewThreadPred(ap PASS_REGS));
|
2009-03-24 13:27:36 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY EXTERN inline Prop GetPredPropByFuncHavingLock(FunctorEntry *fe,
|
|
|
|
Term cur_mod) {
|
2007-09-29 00:18:17 +01:00
|
|
|
PredEntry *p;
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2007-11-01 10:01:35 +00:00
|
|
|
if (!(p = RepPredProp(fe->PropsOfFE))) {
|
2007-09-29 00:18:17 +01:00
|
|
|
return NIL;
|
2007-11-01 10:01:35 +00:00
|
|
|
}
|
2007-09-29 00:18:17 +01:00
|
|
|
if ((p->ModuleOfPred == cur_mod || !(p->ModuleOfPred))) {
|
2008-03-25 22:03:14 +00:00
|
|
|
#ifdef THREADS
|
2007-09-29 00:18:17 +01:00
|
|
|
/* Thread Local Predicates */
|
|
|
|
if (p->PredFlags & ThreadLocalPredFlag) {
|
2016-01-03 02:06:09 +00:00
|
|
|
return AbsPredProp(Yap_GetThreadPred(p INIT_REGS));
|
2007-09-29 00:18:17 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return AbsPredProp(p);
|
|
|
|
}
|
|
|
|
if (p->NextOfPE) {
|
2016-01-03 02:06:09 +00:00
|
|
|
UInt hash = PRED_HASH(fe, cur_mod, PredHashTableSize);
|
2007-09-29 00:18:17 +01:00
|
|
|
READ_LOCK(PredHashRWLock);
|
|
|
|
p = PredHash[hash];
|
2015-04-13 13:28:17 +01:00
|
|
|
|
2007-09-29 00:18:17 +01:00
|
|
|
while (p) {
|
2016-01-03 02:06:09 +00:00
|
|
|
if (p->FunctorOfPred == fe && p->ModuleOfPred == cur_mod) {
|
2008-03-25 22:03:14 +00:00
|
|
|
#ifdef THREADS
|
2016-01-03 02:06:09 +00:00
|
|
|
/* Thread Local Predicates */
|
|
|
|
if (p->PredFlags & ThreadLocalPredFlag) {
|
|
|
|
READ_UNLOCK(PredHashRWLock);
|
|
|
|
return AbsPredProp(Yap_GetThreadPred(p INIT_REGS));
|
|
|
|
}
|
2005-05-27 23:27:59 +01:00
|
|
|
#endif
|
2016-01-03 02:06:09 +00:00
|
|
|
READ_UNLOCK(PredHashRWLock);
|
|
|
|
return AbsPredProp(p);
|
|
|
|
}
|
2015-04-19 04:13:12 +01:00
|
|
|
p = p->NextPredOfHash;
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
2007-09-29 00:18:17 +01:00
|
|
|
READ_UNLOCK(PredHashRWLock);
|
|
|
|
}
|
|
|
|
return NIL;
|
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY EXTERN inline Prop PredPropByFunc(Functor fe, Term cur_mod)
|
2007-09-29 00:18:17 +01:00
|
|
|
/* get predicate entry for ap/arity; create it if neccessary. */
|
|
|
|
{
|
|
|
|
Prop p0;
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
FUNC_WRITE_LOCK(fe);
|
2007-09-29 00:18:17 +01:00
|
|
|
p0 = GetPredPropByFuncHavingLock(fe, cur_mod);
|
|
|
|
if (p0) {
|
2016-01-03 02:06:09 +00:00
|
|
|
FUNC_WRITE_UNLOCK(fe);
|
2007-09-29 00:18:17 +01:00
|
|
|
return p0;
|
|
|
|
}
|
2016-01-03 02:06:09 +00:00
|
|
|
return Yap_NewPredPropByFunctor(fe, cur_mod);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2012-06-30 19:42:14 +01:00
|
|
|
INLINE_ONLY EXTERN inline Prop
|
2016-01-03 02:06:09 +00:00
|
|
|
GetPredPropByFuncAndModHavingLock(FunctorEntry *fe, Term cur_mod) {
|
2011-09-05 00:11:06 +01:00
|
|
|
PredEntry *p;
|
|
|
|
|
|
|
|
if (!(p = RepPredProp(fe->PropsOfFE))) {
|
|
|
|
return NIL;
|
|
|
|
}
|
|
|
|
if (p->ModuleOfPred == cur_mod) {
|
|
|
|
#ifdef THREADS
|
|
|
|
/* Thread Local Predicates */
|
|
|
|
if (p->PredFlags & ThreadLocalPredFlag) {
|
2016-01-03 02:06:09 +00:00
|
|
|
return AbsPredProp(Yap_GetThreadPred(p INIT_REGS));
|
2011-09-05 00:11:06 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return AbsPredProp(p);
|
|
|
|
}
|
|
|
|
if (p->NextOfPE) {
|
2016-01-03 02:06:09 +00:00
|
|
|
UInt hash = PRED_HASH(fe, cur_mod, PredHashTableSize);
|
2011-09-05 00:11:06 +01:00
|
|
|
READ_LOCK(PredHashRWLock);
|
|
|
|
p = PredHash[hash];
|
2015-04-13 13:28:17 +01:00
|
|
|
|
2011-09-05 00:11:06 +01:00
|
|
|
while (p) {
|
2016-01-03 02:06:09 +00:00
|
|
|
if (p->FunctorOfPred == fe && p->ModuleOfPred == cur_mod) {
|
2011-09-05 00:11:06 +01:00
|
|
|
#ifdef THREADS
|
2016-01-03 02:06:09 +00:00
|
|
|
/* Thread Local Predicates */
|
|
|
|
if (p->PredFlags & ThreadLocalPredFlag) {
|
|
|
|
READ_UNLOCK(PredHashRWLock);
|
|
|
|
return AbsPredProp(Yap_GetThreadPred(p INIT_REGS));
|
|
|
|
}
|
2011-09-05 00:11:06 +01:00
|
|
|
#endif
|
2016-01-03 02:06:09 +00:00
|
|
|
READ_UNLOCK(PredHashRWLock);
|
|
|
|
return AbsPredProp(p);
|
|
|
|
}
|
2015-04-19 04:13:12 +01:00
|
|
|
p = p->NextPredOfHash;
|
2011-09-05 00:11:06 +01:00
|
|
|
}
|
|
|
|
READ_UNLOCK(PredHashRWLock);
|
|
|
|
}
|
|
|
|
return NIL;
|
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY EXTERN inline Prop PredPropByFuncAndMod(Functor fe, Term cur_mod)
|
2011-09-05 00:11:06 +01:00
|
|
|
/* get predicate entry for ap/arity; create it if neccessary. */
|
|
|
|
{
|
|
|
|
Prop p0;
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
FUNC_WRITE_LOCK(fe);
|
2011-09-05 00:11:06 +01:00
|
|
|
p0 = GetPredPropByFuncAndModHavingLock(fe, cur_mod);
|
|
|
|
if (p0) {
|
2016-01-03 02:06:09 +00:00
|
|
|
FUNC_WRITE_UNLOCK(fe);
|
2011-09-05 00:11:06 +01:00
|
|
|
return p0;
|
|
|
|
}
|
2016-01-03 02:06:09 +00:00
|
|
|
return Yap_NewPredPropByFunctor(fe, cur_mod);
|
2011-09-05 00:11:06 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY EXTERN inline Prop PredPropByAtom(Atom at, Term cur_mod)
|
2005-05-27 23:27:59 +01:00
|
|
|
/* get predicate entry for ap/arity; create it if neccessary. */
|
|
|
|
{
|
|
|
|
Prop p0;
|
2016-01-03 02:06:09 +00:00
|
|
|
AtomEntry *ae = RepAtom(at);
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
WRITE_LOCK(ae->ARWLock);
|
2005-05-27 23:27:59 +01:00
|
|
|
p0 = ae->PropsOfAE;
|
2016-01-03 02:06:09 +00:00
|
|
|
while (p0) {
|
|
|
|
PredEntry *pe = RepPredProp(p0);
|
|
|
|
if (pe->KindOfPE == PEProp &&
|
|
|
|
(pe->ModuleOfPred == cur_mod || !pe->ModuleOfPred)) {
|
2008-03-25 22:03:14 +00:00
|
|
|
#ifdef THREADS
|
2016-01-03 02:06:09 +00:00
|
|
|
/* Thread Local Predicates */
|
|
|
|
if (pe->PredFlags & ThreadLocalPredFlag) {
|
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
|
|
|
return AbsPredProp(Yap_GetThreadPred(pe INIT_REGS));
|
|
|
|
}
|
2011-09-05 00:11:06 +01:00
|
|
|
#endif
|
2016-01-03 02:06:09 +00:00
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
|
|
|
return (p0);
|
2011-09-05 00:11:06 +01:00
|
|
|
}
|
2016-01-03 02:06:09 +00:00
|
|
|
p0 = pe->NextOfPE;
|
|
|
|
}
|
|
|
|
return Yap_NewPredPropByAtom(ae, cur_mod);
|
2011-09-05 00:11:06 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY EXTERN inline Prop PredPropByAtomAndMod(Atom at, Term cur_mod)
|
2011-09-05 00:11:06 +01:00
|
|
|
/* get predicate entry for ap/arity; create it if neccessary. */
|
|
|
|
{
|
|
|
|
Prop p0;
|
2016-01-03 02:06:09 +00:00
|
|
|
AtomEntry *ae = RepAtom(at);
|
2011-09-05 00:11:06 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
WRITE_LOCK(ae->ARWLock);
|
2011-09-05 00:11:06 +01:00
|
|
|
p0 = ae->PropsOfAE;
|
2016-01-03 02:06:09 +00:00
|
|
|
while (p0) {
|
|
|
|
PredEntry *pe = RepPredProp(p0);
|
|
|
|
if (pe->KindOfPE == PEProp && (pe->ModuleOfPred == cur_mod)) {
|
2011-09-05 00:11:06 +01:00
|
|
|
#ifdef THREADS
|
2016-01-03 02:06:09 +00:00
|
|
|
/* Thread Local Predicates */
|
|
|
|
if (pe->PredFlags & ThreadLocalPredFlag) {
|
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
|
|
|
return AbsPredProp(Yap_GetThreadPred(pe INIT_REGS));
|
|
|
|
}
|
2005-05-27 23:27:59 +01:00
|
|
|
#endif
|
2016-01-03 02:06:09 +00:00
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
|
|
|
return (p0);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
2016-01-03 02:06:09 +00:00
|
|
|
p0 = pe->NextOfPE;
|
|
|
|
}
|
|
|
|
return Yap_NewPredPropByAtom(ae, cur_mod);
|
2005-05-27 23:27:59 +01:00
|
|
|
}
|
|
|
|
|
2010-07-25 11:22:16 +01:00
|
|
|
#if DEBUG_PELOCKING
|
2016-01-03 02:06:09 +00:00
|
|
|
#define PELOCK(I, Z) \
|
|
|
|
{ \
|
|
|
|
LOCK((Z)->PELock); \
|
|
|
|
(Z)->StatisticsForPred->NOfEntries = (I); \
|
|
|
|
(Z)->StatisticsForPred->NOfHeadSuccesses = pthread_self(); \
|
|
|
|
}
|
|
|
|
#define UNLOCKPE(I, Z) \
|
|
|
|
((Z)->StatisticsForPred->NOfRetries = (I), UNLOCK((Z)->PELock))
|
2014-10-19 03:51:56 +01:00
|
|
|
#elif YAPOR || THREADS
|
2016-01-03 02:06:09 +00:00
|
|
|
#define PELOCK(I, Z) (LOCK((Z)->PELock))
|
|
|
|
#define UNLOCKPE(I, Z) (UNLOCK((Z)->PELock))
|
2014-10-19 03:51:56 +01:00
|
|
|
#else
|
2016-01-03 02:06:09 +00:00
|
|
|
#define PELOCK(I, Z)
|
|
|
|
#define UNLOCKPE(I, Z)
|
2010-07-25 11:22:16 +01:00
|
|
|
#endif
|
|
|
|
|
2013-04-25 23:15:04 +01:00
|
|
|
INLINE_ONLY EXTERN inline void AddPropToAtom(AtomEntry *, PropEntry *p);
|
2010-12-02 11:49:58 +00:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY EXTERN inline void AddPropToAtom(AtomEntry *ae, PropEntry *p) {
|
2015-04-13 13:28:17 +01:00
|
|
|
/* old properties should be always last, and wide atom properties
|
2011-08-17 22:35:29 +01:00
|
|
|
should always be first */
|
2011-08-17 19:16:21 +01:00
|
|
|
p->NextOfPE = ae->PropsOfAE;
|
|
|
|
ae->PropsOfAE = AbsProp(p);
|
|
|
|
}
|
2013-11-16 00:27:02 +00:00
|
|
|
|
2015-06-19 00:50:41 +01:00
|
|
|
// auxiliary functions
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN const char *AtomName(Atom at);
|
2015-06-19 00:50:41 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
/**
|
2016-01-31 10:42:08 +00:00
|
|
|
* AtomName(Atom at): get a string with the name of an Atom. Assumes 8 bit
|
2016-01-03 02:06:09 +00:00
|
|
|
*representation.
|
|
|
|
*
|
2015-06-19 00:50:41 +01:00
|
|
|
* @param at the atom
|
2016-01-03 02:06:09 +00:00
|
|
|
*
|
|
|
|
* @return a ponter to an immutable sequence of characters.
|
2015-06-19 00:50:41 +01:00
|
|
|
*/
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN const char *AtomName(Atom at) {
|
|
|
|
return RepAtom(at)->rep.uStrOfAE;
|
2015-06-19 00:50:41 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN const char *AtomTermName(Term t);
|
2015-06-19 00:50:41 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
/**
|
2016-03-29 02:02:43 +01:00
|
|
|
* AtomTermName(Term t): get a string with the name of a term storing an Atom.
|
|
|
|
*Assumes 8
|
2016-01-03 02:06:09 +00:00
|
|
|
*bit representation.
|
|
|
|
*
|
2015-06-19 00:50:41 +01:00
|
|
|
* @param t the atom term
|
2016-01-03 02:06:09 +00:00
|
|
|
*
|
2015-06-19 00:50:41 +01:00
|
|
|
* @return a ponter to an immutable sequence of characters.
|
2016-01-03 02:06:09 +00:00
|
|
|
*
|
2015-06-19 00:50:41 +01:00
|
|
|
* @note: this routine does not support wide chars.
|
|
|
|
*/
|
2016-01-03 02:06:09 +00:00
|
|
|
INLINE_ONLY inline EXTERN const char *AtomTermName(Term t) {
|
|
|
|
return RepAtom(AtomOfTerm(t))->rep.uStrOfAE;
|
2015-06-19 00:50:41 +01:00
|
|
|
}
|
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
bool Yap_ResetException(int wid);
|
|
|
|
bool Yap_HasException(void);
|
|
|
|
Term Yap_GetException(void);
|
|
|
|
Term Yap_PeekException(void);
|
|
|
|
bool Yap_PutException(Term t);
|
|
|
|
INLINE_ONLY inline EXTERN bool Yap_HasException(void) {
|
|
|
|
return LOCAL_BallTerm != NULL;
|
|
|
|
}
|
|
|
|
INLINE_ONLY inline EXTERN DBTerm *Yap_RefToException(void) {
|
|
|
|
DBTerm *dbt = LOCAL_BallTerm;
|
|
|
|
LOCAL_BallTerm = NULL;
|
|
|
|
return dbt;
|
|
|
|
}
|
|
|
|
INLINE_ONLY inline EXTERN void Yap_CopyException(DBTerm *dbt) {
|
|
|
|
LOCAL_BallTerm = dbt;
|
|
|
|
}
|
|
|
|
bool Yap_RaiseException(void);
|
|
|
|
|
2011-08-17 22:35:29 +01:00
|
|
|
#endif
|