This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/H/Atoms.h

136 lines
3.8 KiB
C
Raw Normal View History

/*************************************************************************
* *
* 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: Atoms.h.m4 *
* Last rev: 19/2/88 *
* mods: *
* comments: atom properties header file for YAP *
* *
*************************************************************************/
#ifndef ATOMS_H
#define ATOMS_H 1
2014-05-25 20:50:07 +01:00
#ifndef EXTERN
#ifndef ADTDEFS_C
2016-07-31 16:23:19 +01:00
#define EXTERN static
#else
#define EXTERN
#endif
2014-05-25 20:50:07 +01:00
#endif
#include <wchar.h>
2016-07-31 16:23:19 +01:00
typedef struct atom_blob {
size_t length;
char data[MIN_ARRAY];
} atom_blob_t;
/********* operations for atoms ****************************************/
/* Atoms are assumed to be uniquely represented by an OFFSET and to have
associated with them a struct of type AtomEntry
The two functions
2016-07-31 16:23:19 +01:00
RepAtom : Atom -> *AtomEntry
AbsAtom : *AtomEntry -> Atom
are used to encapsulate the implementation of atoms
*/
typedef struct AtomEntryStruct *Atom;
typedef struct PropEntryStruct *Prop;
/* I can only define the structure after I define the actual atoms */
/* atom structure */
2016-07-31 16:23:19 +01:00
typedef struct AtomEntryStruct {
Atom NextOfAE; /* used to build hash chains */
Prop PropsOfAE; /* property list for this atom */
#if defined(YAPOR) || defined(THREADS)
rwlock_t ARWLock;
#endif
union {
2016-07-31 16:23:19 +01:00
unsigned char uUStrOfAE[MIN_ARRAY]; /* representation of atom as a string */
char uStrOfAE[MIN_ARRAY]; /* representation of atom as a string */
struct atom_blob blob[MIN_ARRAY];
} rep;
2016-07-31 16:23:19 +01:00
} AtomEntry;
2015-02-09 01:53:28 +00:00
// compatible with C and C++;
2016-07-31 16:23:19 +01:00
typedef struct ExtraAtomEntryStruct {
Atom NextOfAE; /* used to build hash chains */
Prop PropsOfAE; /* property list for this atom */
2015-02-09 01:53:28 +00:00
#if defined(YAPOR) || defined(THREADS)
rwlock_t ARWLock;
#endif
union {
2016-07-31 16:23:19 +01:00
unsigned char uUStrOfAE[4]; /* representation of atom as a string */
char uStrOfAE[4]; /* representation of atom as a string */
2015-02-13 12:26:08 +00:00
struct atom_blob blob[2];
2015-02-09 01:53:28 +00:00
} rep;
2016-07-31 16:23:19 +01:00
} ExtraAtomEntry;
2015-02-09 01:53:28 +00:00
2015-09-21 23:05:36 +01:00
#define UStrOfAE rep.uUStrOfAE
#define StrOfAE rep.uStrOfAE
/* Props and Atoms are stored in chains, ending with a NIL */
#ifdef USE_OFFSETS
2016-07-31 16:23:19 +01:00
#define EndOfPAEntr(P) (Addr(P) == AtomBase)
#else
2016-07-31 16:23:19 +01:00
#define EndOfPAEntr(P) (Addr(P) == NIL)
#endif
/* ********************** Properties **********************************/
#if defined(USE_OFFSETS)
#define USE_OFFSETS_IN_PROPS 1
#else
#define USE_OFFSETS_IN_PROPS 0
#endif
typedef SFLAGS PropFlags;
/* basic property entry structure */
2016-07-31 16:23:19 +01:00
typedef struct PropEntryStruct {
Prop NextOfPE; /* used to chain properties */
PropFlags KindOfPE; /* kind of property */
} PropEntry;
/* ************************* Functors **********************************/
2016-07-31 16:23:19 +01:00
/* Functor data type
abstype Functor = atom # int
with MkFunctor(a,n) = ...
and NameOfFunctor(f) = ...
and ArityOfFunctor(f) = ... */
2016-07-31 16:23:19 +01:00
#define MaxArity 255
2016-07-31 16:23:19 +01:00
typedef size_t arity_t;
2016-07-31 16:23:19 +01:00
#define FunctorProperty ((PropFlags)(0xbb00))
/* functor property */
2016-07-31 16:23:19 +01:00
typedef struct FunctorEntryStruct {
Prop NextOfPE; /* used to chain properties */
PropFlags KindOfPE; /* kind of property */
arity_t ArityOfFE; /* arity of functor */
Atom NameOfFE; /* back pointer to owner atom */
Prop PropsOfFE; /* pointer to list of properties for this functor */
#if defined(YAPOR) || defined(THREADS)
rwlock_t FRWLock;
#endif
} FunctorEntry;
typedef FunctorEntry *Functor;
#endif /* ATOMS_H */