YAP 7.1.0
Atoms.h
1/*************************************************************************
2* *
3* YAP Prolog %W% %G%
4* *
5* Yap Prolog was developed at NCCUP - Universidade do Porto *
6* *
7* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
8* *
9**************************************************************************
10* *
11* File: Atoms.h.m4 *
12* Last rev: 19/2/88 *
13* mods: *
14* comments: atom properties header file for YAP *
15* *
16*************************************************************************/
17
18#ifndef ATOMS_H
19#define ATOMS_H 1
20
21#ifndef EXTERN
22#ifndef ADTDEFS_C
23#define EXTERN static
24#else
25#define EXTERN
26#endif
27#endif
28
29#include <wchar.h>
30
31typedef struct atom_blob {
32 size_t length;
33 char data[MIN_ARRAY];
35
36/********* operations for atoms ****************************************/
37
38/* Atoms are assumed to be uniquely represented by an OFFSET and to have
39 associated with them a struct of type AtomEntry
40 The two functions
41 RepAtom : Atom -> *AtomEntry
42 AbsAtom : *AtomEntry -> Atom
43 are used to encapsulate the implementation of atoms
44*/
45
46typedef struct AtomEntryStruct *Atom;
47typedef struct PropEntryStruct *Prop;
48
49/* I can only define the structure after I define the actual atoms */
50
51/* atom structure */
52typedef struct AtomEntryStruct {
53 Atom NextOfAE; /* used to build hash chains */
54 Prop PropsOfAE; /* property list for this atom */
55#if defined(YAPOR) || defined(THREADS)
56 rwlock_t ARWLock;
57#endif
58
59 union {
60 unsigned char uUStrOfAE[MIN_ARRAY]; /* representation of atom as a string */
61 char uStrOfAE[MIN_ARRAY]; /* representation of atom as a string */
62 struct atom_blob blob[MIN_ARRAY];
63 } rep;
64} AtomEntry;
65
66// compatible with C and C++;
67typedef struct ExtraAtomEntryStruct {
68 Atom NextOfAE; /* used to build hash chains */
69 Prop PropsOfAE; /* property list for this atom */
70#if defined(YAPOR) || defined(THREADS)
71 rwlock_t ARWLock;
72#endif
73
74 union {
75 unsigned char uUStrOfAE[4]; /* representation of atom as a string */
76 char uStrOfAE[4]; /* representation of atom as a string */
77 struct atom_blob blob[2];
78 } rep;
80
81#define UStrOfAE rep.uUStrOfAE
82#define StrOfAE rep.uStrOfAE
83
84/* Props and Atoms are stored in chains, ending with a NIL */
85#ifdef USE_OFFSETS
86#define EndOfPAEntr(P) (Addr(P) == AtomBase)
87#else
88#define EndOfPAEntr(P) (Addr(P) == NIL)
89#endif
90
91/* ********************** Properties **********************************/
92
93#if defined(USE_OFFSETS)
94#define USE_OFFSETS_IN_PROPS 1
95#else
96#define USE_OFFSETS_IN_PROPS 0
97#endif
98
99typedef CELL PropFlags;
100
101/* basic property entry structure */
102typedef struct PropEntryStruct {
103 Prop NextOfPE; /* used to chain properties */
104 PropFlags KindOfPE; /* kind of property */
105} PropEntry;
106
107/* ************************* Functors **********************************/
108
109/* Functor data type
110 abstype Functor = atom # int
111 with MkFunctor(a,n) = ...
112 and NameOfFunctor(f) = ...
113 and ArityOfFunctor(f) = ... */
114
115#define MaxArity 255
116
117typedef size_t arity_t;
118
119#define FunctorProperty ((PropFlags)(0xbb00))
120
121/* functor property */
122typedef struct FunctorEntryStruct {
123 Prop NextOfPE; /* used to chain properties */
124 PropFlags KindOfPE; /* kind of property */
125 arity_t ArityOfFE; /* arity of functor */
126 Atom NameOfFE; /* back pointer to owner atom */
127 Prop PropsOfFE; /* pointer to list of properties for this functor */
128#if defined(YAPOR) || defined(THREADS)
129 rwlock_t FRWLock;
130#endif
132
133typedef FunctorEntry *Functor;
134
135#endif /* ATOMS_H */