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