new atoms and functors
This commit is contained in:
parent
460dfafcc8
commit
2213bc6f36
2
H/ATOMS
2
H/ATOMS
@ -430,6 +430,7 @@ A WakeUpGoal F "$wake_up_goal"
|
||||
A Warning N "warning"
|
||||
A When F "$when"
|
||||
A Write N "write"
|
||||
A WriteTerm N "write_term"
|
||||
A Xml N "xml"
|
||||
A YapHacks N "yap_hacks"
|
||||
A ZeroDivisor N "zero_divisor"
|
||||
@ -569,4 +570,5 @@ F TypeError TypeError 2
|
||||
F UMinus Minus 1
|
||||
F UPlus Plus 1
|
||||
F VBar VBar 2
|
||||
F WriteTerm WriteTerm 2
|
||||
F HiddenVar HiddenVar 1
|
||||
|
84
H/Atoms.h
84
H/Atoms.h
@ -20,7 +20,7 @@
|
||||
|
||||
#ifndef EXTERN
|
||||
#ifndef ADTDEFS_C
|
||||
#define EXTERN static
|
||||
#define EXTERN static
|
||||
#else
|
||||
#define EXTERN
|
||||
#endif
|
||||
@ -28,7 +28,7 @@
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
typedef struct atom_blob {
|
||||
typedef struct atom_blob {
|
||||
size_t length;
|
||||
char data[MIN_ARRAY];
|
||||
} atom_blob_t;
|
||||
@ -38,66 +38,59 @@ typedef struct atom_blob {
|
||||
/* Atoms are assumed to be uniquely represented by an OFFSET and to have
|
||||
associated with them a struct of type AtomEntry
|
||||
The two functions
|
||||
RepAtom : Atom -> *AtomEntry
|
||||
AbsAtom : *AtomEntry -> Atom
|
||||
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 */
|
||||
typedef struct AtomEntryStruct
|
||||
{
|
||||
Atom NextOfAE; /* used to build hash chains */
|
||||
Prop PropsOfAE; /* property list for this atom */
|
||||
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 {
|
||||
unsigned char uUStrOfAE[MIN_ARRAY]; /* representation of atom as a string */
|
||||
char uStrOfAE[MIN_ARRAY]; /* representation of atom as a string */
|
||||
wchar_t uWStrOfAE[MIN_ARRAY]; /* representation of atom as a string */
|
||||
unsigned char uUStrOfAE[MIN_ARRAY]; /* representation of atom as a string */
|
||||
char uStrOfAE[MIN_ARRAY]; /* representation of atom as a string */
|
||||
wchar_t uWStrOfAE[MIN_ARRAY]; /* representation of atom as a string */
|
||||
struct atom_blob blob[MIN_ARRAY];
|
||||
} rep;
|
||||
}
|
||||
AtomEntry;
|
||||
} AtomEntry;
|
||||
|
||||
// compatible with C and C++;
|
||||
typedef struct ExtraAtomEntryStruct
|
||||
{
|
||||
Atom NextOfAE; /* used to build hash chains */
|
||||
Prop PropsOfAE; /* property list for this atom */
|
||||
typedef struct ExtraAtomEntryStruct {
|
||||
Atom NextOfAE; /* used to build hash chains */
|
||||
Prop PropsOfAE; /* property list for this atom */
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
rwlock_t ARWLock;
|
||||
#endif
|
||||
|
||||
union {
|
||||
unsigned char uUStrOfAE[4]; /* representation of atom as a string */
|
||||
char uStrOfAE[4]; /* representation of atom as a string */
|
||||
wchar_t uWStrOfAE[2]; /* representation of atom as a string */
|
||||
unsigned char uUStrOfAE[4]; /* representation of atom as a string */
|
||||
char uStrOfAE[4]; /* representation of atom as a string */
|
||||
wchar_t uWStrOfAE[2]; /* representation of atom as a string */
|
||||
struct atom_blob blob[2];
|
||||
} rep;
|
||||
}
|
||||
ExtraAtomEntry;
|
||||
} ExtraAtomEntry;
|
||||
|
||||
#define UStrOfAE rep.uUStrOfAE
|
||||
#define StrOfAE rep.uStrOfAE
|
||||
#define WStrOfAE rep.uWStrOfAE
|
||||
|
||||
|
||||
/* Props and Atoms are stored in chains, ending with a NIL */
|
||||
#ifdef USE_OFFSETS
|
||||
# define EndOfPAEntr(P) ( Addr(P) == AtomBase)
|
||||
#define EndOfPAEntr(P) (Addr(P) == AtomBase)
|
||||
#else
|
||||
# define EndOfPAEntr(P) ( Addr(P) == NIL )
|
||||
#define EndOfPAEntr(P) (Addr(P) == NIL)
|
||||
#endif
|
||||
|
||||
|
||||
/* ********************** Properties **********************************/
|
||||
|
||||
#if defined(USE_OFFSETS)
|
||||
@ -109,34 +102,32 @@ typedef struct ExtraAtomEntryStruct
|
||||
typedef SFLAGS PropFlags;
|
||||
|
||||
/* basic property entry structure */
|
||||
typedef struct PropEntryStruct
|
||||
{
|
||||
Prop NextOfPE; /* used to chain properties */
|
||||
PropFlags KindOfPE; /* kind of property */
|
||||
typedef struct PropEntryStruct {
|
||||
Prop NextOfPE; /* used to chain properties */
|
||||
PropFlags KindOfPE; /* kind of property */
|
||||
} PropEntry;
|
||||
|
||||
/* ************************* Functors **********************************/
|
||||
|
||||
/* Functor data type
|
||||
abstype Functor = atom # int
|
||||
with MkFunctor(a,n) = ...
|
||||
and NameOfFunctor(f) = ...
|
||||
and ArityOfFunctor(f) = ... */
|
||||
/* Functor data type
|
||||
abstype Functor = atom # int
|
||||
with MkFunctor(a,n) = ...
|
||||
and NameOfFunctor(f) = ...
|
||||
and ArityOfFunctor(f) = ... */
|
||||
|
||||
#define MaxArity 255
|
||||
#define MaxArity 255
|
||||
|
||||
typedef CELL arity_t;
|
||||
typedef size_t arity_t;
|
||||
|
||||
#define FunctorProperty ((PropFlags)(0xbb00))
|
||||
#define FunctorProperty ((PropFlags)(0xbb00))
|
||||
|
||||
/* functor property */
|
||||
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 */
|
||||
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
|
||||
@ -144,5 +135,4 @@ typedef struct FunctorEntryStruct
|
||||
|
||||
typedef FunctorEntry *Functor;
|
||||
|
||||
|
||||
#endif /* ATOMS_H */
|
||||
|
@ -425,6 +425,7 @@
|
||||
AtomWarning = Yap_LookupAtom("warning"); TermWarning = MkAtomTerm(AtomWarning);
|
||||
AtomWhen = Yap_FullLookupAtom("$when"); TermWhen = MkAtomTerm(AtomWhen);
|
||||
AtomWrite = Yap_LookupAtom("write"); TermWrite = MkAtomTerm(AtomWrite);
|
||||
AtomWriteTerm = Yap_LookupAtom("write_term"); TermWriteTerm = MkAtomTerm(AtomWriteTerm);
|
||||
AtomXml = Yap_LookupAtom("xml"); TermXml = MkAtomTerm(AtomXml);
|
||||
AtomYapHacks = Yap_LookupAtom("yap_hacks"); TermYapHacks = MkAtomTerm(AtomYapHacks);
|
||||
AtomZeroDivisor = Yap_LookupAtom("zero_divisor"); TermZeroDivisor = MkAtomTerm(AtomZeroDivisor);
|
||||
@ -564,4 +565,5 @@
|
||||
FunctorUMinus = Yap_MkFunctor(AtomMinus,1);
|
||||
FunctorUPlus = Yap_MkFunctor(AtomPlus,1);
|
||||
FunctorVBar = Yap_MkFunctor(AtomVBar,2);
|
||||
FunctorWriteTerm = Yap_MkFunctor(AtomWriteTerm,2);
|
||||
FunctorHiddenVar = Yap_MkFunctor(AtomHiddenVar,1);
|
||||
|
@ -425,6 +425,7 @@
|
||||
AtomWarning = AtomAdjust(AtomWarning); TermWarning = MkAtomTerm(AtomWarning);
|
||||
AtomWhen = AtomAdjust(AtomWhen); TermWhen = MkAtomTerm(AtomWhen);
|
||||
AtomWrite = AtomAdjust(AtomWrite); TermWrite = MkAtomTerm(AtomWrite);
|
||||
AtomWriteTerm = AtomAdjust(AtomWriteTerm); TermWriteTerm = MkAtomTerm(AtomWriteTerm);
|
||||
AtomXml = AtomAdjust(AtomXml); TermXml = MkAtomTerm(AtomXml);
|
||||
AtomYapHacks = AtomAdjust(AtomYapHacks); TermYapHacks = MkAtomTerm(AtomYapHacks);
|
||||
AtomZeroDivisor = AtomAdjust(AtomZeroDivisor); TermZeroDivisor = MkAtomTerm(AtomZeroDivisor);
|
||||
@ -564,4 +565,5 @@
|
||||
FunctorUMinus = FuncAdjust(FunctorUMinus);
|
||||
FunctorUPlus = FuncAdjust(FunctorUPlus);
|
||||
FunctorVBar = FuncAdjust(FunctorVBar);
|
||||
FunctorWriteTerm = FuncAdjust(FunctorWriteTerm);
|
||||
FunctorHiddenVar = FuncAdjust(FunctorHiddenVar);
|
||||
|
1129
H/generated/tatoms.h
1129
H/generated/tatoms.h
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user