This commit was generated by cvs2svn to compensate for changes in r4,
which included commits to RCS files with non-trunk default branches. git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@5 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
113
VC/include/Atoms.h
Executable file
113
VC/include/Atoms.h
Executable file
@@ -0,0 +1,113 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* 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 *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#ifndef ADTDEFS_C
|
||||
#define EXTERN static
|
||||
#else
|
||||
#define EXTERN
|
||||
#endif
|
||||
|
||||
/********* 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
|
||||
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 PropOfAE; /* property list for this atom */
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
rwlock_t ARWLock;
|
||||
#endif
|
||||
|
||||
char StrOfAE[MIN_ARRAY]; /* representation of atom as a string */
|
||||
}
|
||||
AtomEntry;
|
||||
|
||||
/* Props and Atoms are stored in chains, ending with a NIL */
|
||||
#if USE_OFFSETS
|
||||
# define EndOfPAEntr(P) ( Addr(P) == AtomBase)
|
||||
#else
|
||||
# define EndOfPAEntr(P) ( Addr(P) == NIL )
|
||||
#endif
|
||||
|
||||
#define AtomName(at) RepAtom(at)->StrOfAE
|
||||
|
||||
|
||||
/* ********************** Properties **********************************/
|
||||
|
||||
#if USE_OFFSETS
|
||||
#define USE_OFFSETS_IN_PROPS 1
|
||||
#else
|
||||
#define USE_OFFSETS_IN_PROPS 0
|
||||
#endif
|
||||
|
||||
typedef SFLAGS PropFlags;
|
||||
|
||||
/* basic property entry structure */
|
||||
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) = ... */
|
||||
|
||||
#define MaxArity 255
|
||||
|
||||
|
||||
#define FunctorProperty ((PropFlags)(0xbb00))
|
||||
|
||||
/* functor property */
|
||||
typedef struct FunctorEntryStruct
|
||||
{
|
||||
Prop NextOfPE; /* used to chain properties */
|
||||
PropFlags KindOfPE; /* kind of property */
|
||||
unsigned int ArityOfFE; /* arity of functor */
|
||||
Atom NameOfFE; /* back pointer to owner atom */
|
||||
Prop PropsOfFE; /* pointer to list of properties for this functor */
|
||||
}
|
||||
FunctorEntry;
|
||||
|
||||
typedef FunctorEntry *Functor;
|
187
VC/include/Tags_24bits.h
Normal file
187
VC/include/Tags_24bits.h
Normal file
@@ -0,0 +1,187 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* 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: Tags_24bits.h.m4 *
|
||||
* Last rev: December 90 *
|
||||
* mods: *
|
||||
* comments: Tag Scheme for machines with 24 bits adresses (m68000) *
|
||||
* version: $Id: Tags_24bits.h,v 1.1.1.1 2001-04-09 19:53:40 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
/* Version for 24 bit addresses (68000)
|
||||
Each term is represented internally as an unsigned 32 bit integer as
|
||||
follows:
|
||||
tag value
|
||||
ints 1m1000 numeric value
|
||||
floats 1m1001 floating point value
|
||||
pairs 1mr10. ptr to pair
|
||||
aplied functor 1mr01. ptr to functor followed by args
|
||||
ref 0mr000 address of cell
|
||||
undefined 0mr000 pointing to itself
|
||||
|
||||
*/
|
||||
|
||||
#define AllTagBits 0xfc000000L
|
||||
#define TagBits 0xbc000000L
|
||||
#define MaskAdr 0x03ffffffL
|
||||
#define AdrHiBit 0x02000000L
|
||||
#define NumberTag 0xa0000000L
|
||||
#define FloatTag 0xa4000000L
|
||||
#define AtomTag 0x84000000L
|
||||
#define PairTag 0x90000000L
|
||||
#define ApplTag 0x88000000L
|
||||
#define RefTag 0x80000000L
|
||||
|
||||
#define MaskBits 6
|
||||
|
||||
#define PairBit 0x10000000L
|
||||
#define ApplBit 0x08000000L
|
||||
#define CompBits 0x18000000L
|
||||
#define NumberMask 0xb8000000L
|
||||
#define MAX_ABS_INT /* 0xfe00000LL */ ((((UInt)(1<<7))-1) << SHIFT_HIGH_TAG)
|
||||
|
||||
#define NonTagPart(X) (Signed(X) & MaskAdr)
|
||||
#define TAGGEDA(TAG,V) (TAG | Unsigned(V))
|
||||
#define TAGGED(TAG,V) (TAG | NonTagPart(Unsigned(V)))
|
||||
#define NONTAGGED(TAG,V) NonTagPart(Unsigned(V))
|
||||
#define BitOn(Bit,V) (Bit & Unsigned(V))
|
||||
#define CHKTAG(t,Tag) ((Unsigned(t)&TagBits)==Tag)
|
||||
|
||||
/* bits that should not be used by anyone but us */
|
||||
#define YAP_PROTECTED_MASK 0x00000000L
|
||||
|
||||
|
||||
inline EXTERN int IsVarTerm (Term);
|
||||
|
||||
inline EXTERN int
|
||||
IsVarTerm (Term t)
|
||||
{
|
||||
return (int) (Signed (t) >= 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN int IsNonVarTerm (Term);
|
||||
|
||||
inline EXTERN int
|
||||
IsNonVarTerm (Term t)
|
||||
{
|
||||
return (int) (Signed (t) < 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term *RepPair (Term);
|
||||
|
||||
inline EXTERN Term *
|
||||
RepPair (Term t)
|
||||
{
|
||||
return (Term *) (NonTagPart (t));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term AbsPair (Term *);
|
||||
|
||||
inline EXTERN Term
|
||||
AbsPair (Term * p)
|
||||
{
|
||||
return (Term) (TAGGEDA (PairTag, (p)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int IsPairTerm (Term);
|
||||
|
||||
inline EXTERN Int
|
||||
IsPairTerm (Term t)
|
||||
{
|
||||
return (Int) (BitOn (PairBit, (t)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term *RepAppl (Term);
|
||||
|
||||
inline EXTERN Term *
|
||||
RepAppl (Term t)
|
||||
{
|
||||
return (Term *) (NonTagPart (t));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term AbsAppl (Term *);
|
||||
|
||||
inline EXTERN Term
|
||||
AbsAppl (Term * p)
|
||||
{
|
||||
return (Term) (TAGGEDA (ApplTag, (p)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int IsApplTerm (Term);
|
||||
|
||||
inline EXTERN Int
|
||||
IsApplTerm (Term t)
|
||||
{
|
||||
return (Int) (BitOn (ApplBit, (t)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int IsAtomOrIntTerm (Term);
|
||||
|
||||
inline EXTERN Int
|
||||
IsAtomOrIntTerm (Term t)
|
||||
{
|
||||
return (Int) (!(Unsigned (t) & CompBits));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term AdjustPtr (Term t, Term off);
|
||||
|
||||
inline EXTERN Term
|
||||
AdjustPtr (Term t, Term off)
|
||||
{
|
||||
return (Term) ((t) + off);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term AdjustIDBPtr (Term t, Term off);
|
||||
|
||||
inline EXTERN Term
|
||||
AdjustIDBPtr (Term t, Term off)
|
||||
{
|
||||
return (Term) ((t) + off);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static inline Int
|
||||
IntOfTerm (Term t)
|
||||
{
|
||||
Int n;
|
||||
n = (Unsigned (t) & MaskPrim) >> 2;
|
||||
|
||||
if (Unsigned (t) & AdrHiBit)
|
||||
n |= 0xfc000000;
|
||||
return (n);
|
||||
}
|
203
VC/include/Tags_32LowTag.h
Normal file
203
VC/include/Tags_32LowTag.h
Normal file
@@ -0,0 +1,203 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* 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: Tags_32LowTag.h.m4 *
|
||||
* Last rev: December 90 *
|
||||
* mods: *
|
||||
* comments: Original Tag Scheme for machines with 32 bits adresses *
|
||||
* version: $Id: Tags_32LowTag.h,v 1.1.1.1 2001-04-09 19:53:40 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
#define TAG_LOW_BITS_32 1
|
||||
|
||||
/* Version for 32 bit addresses machines,
|
||||
Each term is represented internally as an unsigned 32 bit integer as
|
||||
follows:
|
||||
tag value
|
||||
ints m.....110 numeric value
|
||||
atoms m.....010 offset of atom entry
|
||||
pairs mr.....11 ptr to pair
|
||||
aplied functor mr.....01 ptr to functor followed by args
|
||||
ref mr.....00 address of cell
|
||||
undefined mr.....00 address of cell pointing to itself
|
||||
|
||||
functors are represented as ptrs to the functor entry in the atom
|
||||
property list
|
||||
|
||||
*/
|
||||
|
||||
#define SHIFT_LOW_TAG 2
|
||||
#define SHIFT_HIGH_TAG 2
|
||||
|
||||
#define MKTAG(HI,LO) ((((UInt) (HI))<<SHIFT_HIGH_TAG)|(LO))
|
||||
|
||||
#define TagBits /* 0x00000007L */ MKTAG(0x1,3)
|
||||
#define LowTagBits /* 0x00000003L */ MKTAG(0x0,3)
|
||||
#define LowBit /* 0x00000001L */ MKTAG(0x0,1)
|
||||
#define HighTagBits /* 0x0000000cL */ MKTAG(0x1,0)
|
||||
#define NumberTag /* 0x0000000dL */ MKTAG(0x1,2)
|
||||
#define AtomTag /* 0x00000006L */ MKTAG(0x0,2)
|
||||
|
||||
/*
|
||||
subtract the total for tag bits, plus 1 bit for GC, plus another
|
||||
for sign
|
||||
*/
|
||||
#define MAX_ABS_INT ((Int)0x04000000L)
|
||||
|
||||
/*
|
||||
UNIQUE_TAG_FOR_PAIR gives the representation for pair an
|
||||
unique tag
|
||||
|
||||
This allows optimisation of switch_list
|
||||
|
||||
*/
|
||||
#define UNIQUE_TAG_FOR_PAIRS 1
|
||||
|
||||
#define PairBits /* 0x00000003L */ MKTAG(0x0,3)
|
||||
#define ApplBit /* 0x00000001L */ MKTAG(0x0,1)
|
||||
#define PrimiBits /* 0x00000002L */ MKTAG(0x0,2)
|
||||
#define NumberBits /* 0x0000000aL */ MKTAG(0x2,2)
|
||||
#define NumberMask /* 0x0000000bL */ MKTAG(0x2,3)
|
||||
|
||||
#define NonTagPart(V) (Unsigned(V)>>(SHIFT_LOW_TAG+SHIFT_HIGH_TAG))
|
||||
#define TAGGED(TAG,V) (((Unsigned(V)<<(SHIFT_HIGH_TAG+SHIFT_LOW_TAG+1))>>1)|(TAG))
|
||||
#define NONTAGGED(TAG,V) ((Unsigned(V)<<(SHIFT_HIGH_TAG+SHIFT_LOW_TAG+1))>>1)
|
||||
#define TAGGEDA(TAG,V) ((Unsigned(V) << (SHIFT_HIGH_TAG+SHIFT_LOW_TAG))|(TAG))
|
||||
#define CHKTAG(t,Tag) ((Unsigned(t)&TagBits)==Tag)
|
||||
|
||||
/* bits that should not be used by anyone but us */
|
||||
#define YAP_PROTECTED_MASK 0xc0000000L
|
||||
|
||||
|
||||
inline EXTERN int IsVarTerm (Term);
|
||||
|
||||
inline EXTERN int
|
||||
IsVarTerm (Term t)
|
||||
{
|
||||
return (int) (!((t) & LowTagBits));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN int IsNonVarTerm (Term);
|
||||
|
||||
inline EXTERN int
|
||||
IsNonVarTerm (Term t)
|
||||
{
|
||||
return (int) (((t) & LowTagBits));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term *RepPair (Term);
|
||||
|
||||
inline EXTERN Term *
|
||||
RepPair (Term t)
|
||||
{
|
||||
return (Term *) ((t) - PairBits);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term AbsPair (Term *);
|
||||
|
||||
inline EXTERN Term
|
||||
AbsPair (Term * p)
|
||||
{
|
||||
return (Term) (Unsigned (p) + PairBits);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int IsPairTerm (Term);
|
||||
|
||||
inline EXTERN Int
|
||||
IsPairTerm (Term t)
|
||||
{
|
||||
return (Int) ((((t) & LowTagBits) == PairBits));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term *RepAppl (Term);
|
||||
|
||||
inline EXTERN Term *
|
||||
RepAppl (Term t)
|
||||
{
|
||||
return (Term *) (((t) - ApplBit));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term AbsAppl (Term *);
|
||||
|
||||
inline EXTERN Term
|
||||
AbsAppl (Term * p)
|
||||
{
|
||||
return (Term) (Unsigned (p) + ApplBit);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int IsApplTerm (Term);
|
||||
|
||||
inline EXTERN Int
|
||||
IsApplTerm (Term t)
|
||||
{
|
||||
return (Int) ((((t) & LowTagBits) == ApplBit));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int IsAtomOrIntTerm (Term);
|
||||
|
||||
inline EXTERN Int
|
||||
IsAtomOrIntTerm (Term t)
|
||||
{
|
||||
return (Int) ((((t) & LowTagBits) == 2));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term AdjustPtr (Term t, Term off);
|
||||
|
||||
inline EXTERN Term
|
||||
AdjustPtr (Term t, Term off)
|
||||
{
|
||||
return (Term) ((t) + off);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term AdjustIDBPtr (Term t, Term off);
|
||||
|
||||
inline EXTERN Term
|
||||
AdjustIDBPtr (Term t, Term off)
|
||||
{
|
||||
return (Term) ((t) + off);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int IntOfTerm (Term);
|
||||
|
||||
inline EXTERN Int
|
||||
IntOfTerm (Term t)
|
||||
{
|
||||
return (Int) (((Int) (t << 1)) >> (SHIFT_LOW_TAG + SHIFT_HIGH_TAG + 1));
|
||||
}
|
319
VC/include/Tags_32Ops.h
Normal file
319
VC/include/Tags_32Ops.h
Normal file
@@ -0,0 +1,319 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* 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: Tags_32Ops.h.m4 *
|
||||
* Last rev: December 90 *
|
||||
* mods: *
|
||||
* comments: Original Tag Scheme for machines with 32 bits adresses *
|
||||
* version: $Id: Tags_32Ops.h,v 1.1.1.1 2001-04-09 19:53:40 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
/*
|
||||
|
||||
Version for 32 bit addresses machines,
|
||||
Each term is represented internally as an unsigned 32 bit integer as
|
||||
follows:
|
||||
tag value
|
||||
ints 1m1....01 numeric value
|
||||
atoms 1m0....01 offset of atom entry
|
||||
pairs 1mr....11 ptr to pair
|
||||
aplied functor 1mr....00 ptr to functor followed by args
|
||||
undefined 0mr....00 address of cell pointing to itself
|
||||
|
||||
functors are represented as ptrs to the functor entry in the atom
|
||||
property list
|
||||
|
||||
This version speeds up access to lists and to compound
|
||||
terms by using the XOR and NOT operations to build their tags. This
|
||||
saves operations on RISC machines.
|
||||
|
||||
As a further optimisation, only pairs or compound terms have
|
||||
the second lowest bit set. This allows one to recognise lists or
|
||||
compound terms with a single operation.
|
||||
|
||||
The main problem is that the default value of the M and R bits for GC
|
||||
are now 1 in compound terms and structures.
|
||||
|
||||
*/
|
||||
|
||||
#define TAGS_FAST_OPS 1
|
||||
|
||||
#define SHIFT_HIGH_TAG 29
|
||||
|
||||
#define MKTAG(HI,LO) ((((UInt) (HI))<<SHIFT_HIGH_TAG)|(LO))
|
||||
|
||||
#define TagBits /* 0xb0000003L */ MKTAG(0x5,3)
|
||||
#define LowTagBits /* 0x00000003L */ MKTAG(0x0,3)
|
||||
#define LowBit /* 0x00000001L */ MKTAG(0x0,1)
|
||||
#define HighTagBits /* 0xf0000000L */ MKTAG(0x7,0)
|
||||
#define AdrHiBit /* 0x08000000L */ (((UInt)1) << (SHIFT_HIGH_TAG-1))
|
||||
#define MaskAdr /* 0x1ffffffcL */ ((((UInt)1) << (SHIFT_HIGH_TAG))-4)
|
||||
#define MaskPrim /* 0x0ffffffcL */ ((((UInt)1) << (SHIFT_HIGH_TAG))-4)
|
||||
#define NumberTag /* 0xb0000001L */ MKTAG(0x5,2)
|
||||
#define AtomTag /* 0x90000001L */ MKTAG(0x4,2)
|
||||
#define MAX_ABS_INT /* 0xfe00000LL */ ((Int)0x04000000L)
|
||||
|
||||
/* bits that should not be used by anyone but us */
|
||||
#define YAP_PROTECTED_MASK 0xe0000000L
|
||||
|
||||
#define MaskBits 4
|
||||
|
||||
/*
|
||||
UNIQUE_TAG_FOR_PAIR gives the representation for pair an
|
||||
unique tag
|
||||
|
||||
This allows optimisation of switch_list
|
||||
|
||||
*/
|
||||
#if defined(i386) || defined(sparc) || defined(_POWER)
|
||||
#define UNIQUE_TAG_FOR_PAIRS 1
|
||||
#endif
|
||||
|
||||
#if UNIQUE_TAG_FOR_PAIRS
|
||||
#define PairBit /* 0x00000001L */ 1
|
||||
#define ApplBit /* 0x00000000L */ 0
|
||||
#else
|
||||
#define PairBit /* 0x00000000L */ 0
|
||||
#define ApplBit /* 0x00000001L */ 1
|
||||
#endif
|
||||
|
||||
#define NonTagPart(X) (Signed(X) & MaskPrim)
|
||||
#define TAGGEDA(TAG,V) (TAG | Unsigned(V))
|
||||
#define TAGGED(TAG,V) (TAG | NonTagPart(Unsigned(V)<<2))
|
||||
#define NONTAGGED(TAG,V) NonTagPart(Unsigned(V)<<2)
|
||||
#define BitOn(Bit,V) (Bit & Unsigned(V))
|
||||
#define CHKTAG(t,Tag) ((Unsigned(t)&TagBits)==Tag)
|
||||
|
||||
/* never forget to surround arguments to a macro by brackets */
|
||||
|
||||
inline EXTERN int IsVarTerm (Term);
|
||||
|
||||
inline EXTERN int
|
||||
IsVarTerm (Term t)
|
||||
{
|
||||
return (int) (Signed (t) >= 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN int IsNonVarTerm (Term);
|
||||
|
||||
inline EXTERN int
|
||||
IsNonVarTerm (Term t)
|
||||
{
|
||||
return (int) (Signed (t) < 0);
|
||||
}
|
||||
|
||||
|
||||
#if UNIQUE_TAG_FOR_PAIRS
|
||||
|
||||
inline EXTERN Term *RepPair (Term);
|
||||
|
||||
inline EXTERN Term *
|
||||
RepPair (Term t)
|
||||
{
|
||||
return (Term *) ((~(t)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term AbsPair (Term *);
|
||||
|
||||
inline EXTERN Term
|
||||
AbsPair (Term * p)
|
||||
{
|
||||
return (Term) ((~Unsigned (p)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int IsPairTerm (Term);
|
||||
|
||||
inline EXTERN Int
|
||||
IsPairTerm (Term t)
|
||||
{
|
||||
return (Int) (((t) & PairBit));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term *RepAppl (Term);
|
||||
|
||||
inline EXTERN Term *
|
||||
RepAppl (Term t)
|
||||
{
|
||||
return (Term *) ((-Signed (t)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term AbsAppl (Term *);
|
||||
|
||||
inline EXTERN Term
|
||||
AbsAppl (Term * p)
|
||||
{
|
||||
return (Term) ((-Signed (p)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int IsApplTerm (Term);
|
||||
|
||||
inline EXTERN Int
|
||||
IsApplTerm (Term t)
|
||||
{
|
||||
return (Int) ((!((t) & LowTagBits)));
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
inline EXTERN Term *RepPair (Term);
|
||||
|
||||
inline EXTERN Term *
|
||||
RepPair (Term t)
|
||||
{
|
||||
return (Term *) ((-Signed (t)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term AbsPair (Term *);
|
||||
|
||||
inline EXTERN Term
|
||||
AbsPair (Term * p)
|
||||
{
|
||||
return (Term) (((CELL) (-Signed (p))));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int IsPairTerm (Term);
|
||||
|
||||
inline EXTERN Int
|
||||
IsPairTerm (Term t)
|
||||
{
|
||||
return (Int) ((!((t) & LowTagBits)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term *RepAppl (Term);
|
||||
|
||||
inline EXTERN Term *
|
||||
RepAppl (Term t)
|
||||
{
|
||||
return (Term *) ((~(t)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term AbsAppl (Term *);
|
||||
|
||||
inline EXTERN Term
|
||||
AbsAppl (Term * p)
|
||||
{
|
||||
return (Term) ((~Unsigned (p)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int IsApplTerm (Term);
|
||||
|
||||
inline EXTERN Int
|
||||
IsApplTerm (Term t)
|
||||
{
|
||||
return (Int) (((t) & ApplBit));
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
inline EXTERN Int IsAtomOrIntTerm (Term);
|
||||
|
||||
inline EXTERN Int
|
||||
IsAtomOrIntTerm (Term t)
|
||||
{
|
||||
return (Int) (((Unsigned (t) & LowTagBits) == 0x2));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int IntOfTerm (Term);
|
||||
|
||||
inline EXTERN Int
|
||||
IntOfTerm (Term t)
|
||||
{
|
||||
return (Int) ((Int) (Unsigned (t) << 3) >> 5);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if UNIQUE_TAG_FOR_PAIRS
|
||||
|
||||
inline EXTERN Term AdjustPtr (Term t, Term off);
|
||||
|
||||
inline EXTERN Term
|
||||
AdjustPtr (Term t, Term off)
|
||||
{
|
||||
return (Term) (((IsVarTerm (t)
|
||||
|| IsAtomOrIntTerm (t)) ? (t) +
|
||||
(off) : (IsPairTerm (t) ? (CELL)
|
||||
AbsPair ((CELL *) ((CELL) RepPair (t) +
|
||||
(off))) : (t) - (off))));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term AdjustIDBPtr (Term t, Term off);
|
||||
|
||||
inline EXTERN Term
|
||||
AdjustIDBPtr (Term t, Term off)
|
||||
{
|
||||
return (Term) (IsVarTerm (t) ? (t) + (off) : (t) - (off));
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
inline EXTERN Term AdjustPtr (Term t, Term off);
|
||||
|
||||
inline EXTERN Term
|
||||
AdjustPtr (Term t, Term off)
|
||||
{
|
||||
return (Term) (((IsVarTerm (t)
|
||||
|| IsAtomOrIntTerm (t)) ? (t) +
|
||||
(off) : (IsApplTerm (t) ? (CELL)
|
||||
AbsAppl ((CELL *) ((CELL) RepAppl (t) +
|
||||
(off))) : (t) - (off))));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term AdjustIDBPtr (Term t, Term off);
|
||||
|
||||
inline EXTERN Term
|
||||
AdjustIDBPtr (Term t, Term off)
|
||||
{
|
||||
return (Term) (IsVarTerm (t) ? (t) +
|
||||
(off) : (IsApplTerm (t) ? (CELL)
|
||||
AbsAppl ((CELL *) ((CELL) RepAppl (t) +
|
||||
(off))) : (t) - (off)));
|
||||
}
|
||||
|
||||
|
||||
#endif
|
190
VC/include/Tags_32bits.h
Normal file
190
VC/include/Tags_32bits.h
Normal file
@@ -0,0 +1,190 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* 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: Tags_32bits.h.m4 *
|
||||
* Last rev: December 90 *
|
||||
* mods: *
|
||||
* comments: Original Tag Scheme for machines with 32 bits adresses *
|
||||
* version: $Id: Tags_32bits.h,v 1.1.1.1 2001-04-09 19:53:41 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
/* Original version for 32 bit addresses machines,
|
||||
Each term is represented internally as an unsigned 32 bit integer as
|
||||
follows:
|
||||
tag value
|
||||
ints 1m1....00 numeric value
|
||||
atoms 1m0....00 offset of atom entry
|
||||
pairs 1mr....01 ptr to pair
|
||||
aplied functor 1mr....10 ptr to functor followed by args
|
||||
ref 0mr....00 address of cell
|
||||
undefined 0mr....00 address of cell pointing to itself
|
||||
|
||||
functors are represented as ptrs to the functor entry in the atom
|
||||
property list
|
||||
|
||||
*/
|
||||
|
||||
#define SHIFT_HIGH_TAG 29
|
||||
|
||||
#define MKTAG(HI,LO) ((((UInt) (HI))<<SHIFT_HIGH_TAG)|(LO))
|
||||
|
||||
#define TagBits /* 0xe0000003L */ MKTAG(0x7,3)
|
||||
#define LowTagBits /* 0x00000003L */ MKTAG(0x0,3)
|
||||
#define HighTagBits /* 0xe0000000L */ MKTAG(0x7,0)
|
||||
#define AdrHiBit /* 0x10000000L */ (((UInt)1) << (SHIFT_HIGH_TAG-1))
|
||||
#define MaskAdr /* 0x1ffffffcL */ ((((UInt)1) << SHIFT_HIGH_TAG)-4)
|
||||
#define MaskPrim /* 0x0ffffffcL */ ((((UInt)1) << (SHIFT_HIGH_TAG))-4)
|
||||
#define NumberTag /* 0xa0000000L */ MKTAG(0x5,0)
|
||||
#define AtomTag /* 0x80000000L */ MKTAG(0x4,0)
|
||||
#define PairTag /* 0x80000001L */ MKTAG(0x4,1)
|
||||
#define ApplTag /* 0x80000002L */ MKTAG(0x4,2)
|
||||
#define MAX_ABS_INT /* 0x04000000L */ (1 << (SHIFT_HIGH_TAG-3))
|
||||
|
||||
/* bits that should not be used by anyone but us */
|
||||
#define YAP_PROTECTED_MASK 0xe0000000L
|
||||
|
||||
#define MaskBits 4
|
||||
|
||||
#define PairBit /* 0x00000001L */ 1
|
||||
#define ApplBit /* 0x00000002L */ 2
|
||||
|
||||
#define NonTagPart(X) (Signed(X) & MaskPrim)
|
||||
#define TAGGEDA(TAG,V) (TAG | Unsigned(V))
|
||||
#define TAGGED(TAG,V) (TAG | NonTagPart(Unsigned(V)<<2))
|
||||
#define NONTAGGED(TAG,V) NonTagPart(Unsigned(V)<<2)
|
||||
#define BitOn(Bit,V) (Bit & Unsigned(V))
|
||||
#define CHKTAG(t,Tag) ((Unsigned(t)&TagBits)==Tag)
|
||||
|
||||
|
||||
inline EXTERN int IsVarTerm (Term);
|
||||
|
||||
inline EXTERN int
|
||||
IsVarTerm (Term t)
|
||||
{
|
||||
return (int) (Signed (t) >= 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN int IsNonVarTerm (Term);
|
||||
|
||||
inline EXTERN int
|
||||
IsNonVarTerm (Term t)
|
||||
{
|
||||
return (int) (Signed (t) < 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term *RepPair (Term);
|
||||
|
||||
inline EXTERN Term *
|
||||
RepPair (Term t)
|
||||
{
|
||||
return (Term *) (NonTagPart (t));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term AbsPair (Term *);
|
||||
|
||||
inline EXTERN Term
|
||||
AbsPair (Term * p)
|
||||
{
|
||||
return (Term) (TAGGEDA (PairTag, (p)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int IsPairTerm (Term);
|
||||
|
||||
inline EXTERN Int
|
||||
IsPairTerm (Term t)
|
||||
{
|
||||
return (Int) (BitOn (PairBit, (t)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term *RepAppl (Term);
|
||||
|
||||
inline EXTERN Term *
|
||||
RepAppl (Term t)
|
||||
{
|
||||
return (Term *) (NonTagPart (t));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term AbsAppl (Term *);
|
||||
|
||||
inline EXTERN Term
|
||||
AbsAppl (Term * p)
|
||||
{
|
||||
return (Term) (TAGGEDA (ApplTag, (p)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int IsApplTerm (Term);
|
||||
|
||||
inline EXTERN Int
|
||||
IsApplTerm (Term t)
|
||||
{
|
||||
return (Int) (BitOn (ApplBit, (t)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN int IsAtomOrIntTerm (Term);
|
||||
|
||||
inline EXTERN int
|
||||
IsAtomOrIntTerm (Term t)
|
||||
{
|
||||
return (int) (((Unsigned (t) & LowTagBits) == 0));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term AdjustPtr (Term t, Term off);
|
||||
|
||||
inline EXTERN Term
|
||||
AdjustPtr (Term t, Term off)
|
||||
{
|
||||
return (Term) ((t) + off);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term AdjustIDBPtr (Term t, Term off);
|
||||
|
||||
inline EXTERN Term
|
||||
AdjustIDBPtr (Term t, Term off)
|
||||
{
|
||||
return (Term) ((t) + off);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int IntOfTerm (Term);
|
||||
|
||||
inline EXTERN Int
|
||||
IntOfTerm (Term t)
|
||||
{
|
||||
return (Int) (((Int) (t << 3)) >> (3 + 2));
|
||||
}
|
192
VC/include/Tags_64bits.h
Normal file
192
VC/include/Tags_64bits.h
Normal file
@@ -0,0 +1,192 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* 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: Tags_32Ops.h.m4 *
|
||||
* Last rev: December 90 *
|
||||
* mods: *
|
||||
* comments: Original Tag Scheme for machines with 32 bits adresses *
|
||||
* version: $Id: Tags_64bits.h,v 1.1.1.1 2001-04-09 19:53:41 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
#define TAG_64BITS 1
|
||||
|
||||
/* Version for 64 bit addresses machines,
|
||||
Each term is represented internally as an unsigned 64 bit integer as
|
||||
follows:
|
||||
tag value
|
||||
ints 0m1....001 numeric value
|
||||
atoms 0m0....001 offset of atom entry
|
||||
pairs 0mr....011 ptr to pair
|
||||
aplied functor 0mr....101 ptr to functor followed by args
|
||||
undefined 0mr....000 address of cell pointing to itself
|
||||
|
||||
functors are represented as ptrs to the functor entry in the atom
|
||||
property list
|
||||
|
||||
We rely on the fact that addresses are always multiple of 8.
|
||||
|
||||
*/
|
||||
|
||||
#define SHIFT_HIGH_TAG 61
|
||||
|
||||
#define MKTAG(HI,LO) ((((UInt) (HI))<<SHIFT_HIGH_TAG)|(LO))
|
||||
|
||||
#define TagBits /* 0x30000007L */ MKTAG(0x1,7)
|
||||
#define LowTagBits /* 0x00000007L */ MKTAG(0x0,7)
|
||||
#define HighTagBits /* 0x70000000L */ MKTAG(0x1,0)
|
||||
#define AdrHiBit /* 0x08000000L */ (((UInt)1) << (SHIFT_HIGH_TAG-1))
|
||||
#define MaskPrim /* 0x0ffffff8L */ ((((UInt)1) << (SHIFT_HIGH_TAG))-8)
|
||||
#define NumberTag /* 0x30000001L */ MKTAG(0x1,1)
|
||||
#define AtomTag /* 0x10000001L */ MKTAG(0x0,1)
|
||||
#define MAX_ABS_INT /* 0xfe00000LL */ (((UInt)1) << (63-(2+4)))
|
||||
|
||||
/* bits that should not be used by anyone but us */
|
||||
#define YAP_PROTECTED_MASK 0xe000000000000000L
|
||||
|
||||
#define UNIQUE_TAG_FOR_PAIRS 1
|
||||
|
||||
#define PrimiBit /* 0x00000001L */ 1
|
||||
#define PairBits /* 0x00000003L */ 3
|
||||
#define ApplBits /* 0x00000005L */ 5
|
||||
#define PrimiBits /* 0x70000004L */ MKTAG(0x7,7)
|
||||
#define NumberMask /* 0x20000007L */ MKTAG(0x2,7)
|
||||
|
||||
#define NonTagPart(X) (Signed(X) & MaskPrim)
|
||||
#define TAGGEDA(TAG,V) (TAG | Unsigned(V))
|
||||
#define TAGGED(TAG,V) (TAG | NonTagPart(Unsigned(V)<<3)) /* SQRT(8) */
|
||||
#define NONTAGGED(TAG,V) NonTagPart(Unsigned(V)<<3) /* SQRT(8) */
|
||||
#define CHKTAG(t,Tag) ((Unsigned(t)&TagBits)==Tag)
|
||||
|
||||
|
||||
inline EXTERN int IsVarTerm (Term);
|
||||
|
||||
inline EXTERN int
|
||||
IsVarTerm (Term t)
|
||||
{
|
||||
return (int) ((!((t) & 0x1)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN int IsNonVarTerm (Term);
|
||||
|
||||
inline EXTERN int
|
||||
IsNonVarTerm (Term t)
|
||||
{
|
||||
return (int) (((t) & 0x1));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term *RepPair (Term);
|
||||
|
||||
inline EXTERN Term *
|
||||
RepPair (Term t)
|
||||
{
|
||||
return (Term *) (((t) - PairBits));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term AbsPair (Term *);
|
||||
|
||||
inline EXTERN Term
|
||||
AbsPair (Term * p)
|
||||
{
|
||||
return (Term) (((CELL) (p) + PairBits));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int IsPairTerm (Term);
|
||||
|
||||
inline EXTERN Int
|
||||
IsPairTerm (Term t)
|
||||
{
|
||||
return (Int) (((t) & 0x2));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term *RepAppl (Term);
|
||||
|
||||
inline EXTERN Term *
|
||||
RepAppl (Term t)
|
||||
{
|
||||
return (Term *) (((t) - ApplBits));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term AbsAppl (Term *);
|
||||
|
||||
inline EXTERN Term
|
||||
AbsAppl (Term * p)
|
||||
{
|
||||
return (Term) (((CELL) (p) + ApplBits));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int IsApplTerm (Term);
|
||||
|
||||
inline EXTERN Int
|
||||
IsApplTerm (Term t)
|
||||
{
|
||||
return (Int) ((((t) & 0x4)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int IsAtomOrIntTerm (Term);
|
||||
|
||||
inline EXTERN Int
|
||||
IsAtomOrIntTerm (Term t)
|
||||
{
|
||||
return (Int) ((((t) & LowTagBits) == 0x1));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term AdjustPtr (Term t, Term off);
|
||||
|
||||
inline EXTERN Term
|
||||
AdjustPtr (Term t, Term off)
|
||||
{
|
||||
return (Term) (((t) + off));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term AdjustIDBPtr (Term t, Term off);
|
||||
|
||||
inline EXTERN Term
|
||||
AdjustIDBPtr (Term t, Term off)
|
||||
{
|
||||
return (Term) ((t) + off);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int IntOfTerm (Term);
|
||||
|
||||
inline EXTERN Int
|
||||
IntOfTerm (Term t)
|
||||
{
|
||||
return (Int) ((Int) (Unsigned (t) << 3) >> 6);
|
||||
}
|
482
VC/include/TermExt.h
Normal file
482
VC/include/TermExt.h
Normal file
@@ -0,0 +1,482 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* 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: TermExt.h *
|
||||
* mods: *
|
||||
* comments: Extensions to standard terms for YAP *
|
||||
* version: $Id: TermExt.h,v 1.1.1.1 2001-04-09 19:53:41 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
#if USE_OFFSETS
|
||||
#define AtomFoundVar ((Atom)(&(((special_functors *)(NULL))->AtFoundVar)))
|
||||
#define AtomNil ((Atom)(&(((special_functors *)(NULL))->AtNil)))
|
||||
#define AtomDot ((Atom)(&(((special_functors *)(NULL))->AtDot)))
|
||||
#else
|
||||
#define AtomFoundVar AbsAtom(&(SF_STORE->AtFoundVar))
|
||||
#define AtomNil AbsAtom(&(SF_STORE->AtNil))
|
||||
#define AtomDot AbsAtom(&(SF_STORE->AtDot))
|
||||
#endif
|
||||
|
||||
#define TermFoundVar MkAtomTerm(AtomFoundVar)
|
||||
#define TermNil MkAtomTerm(AtomNil)
|
||||
#define TermDot MkAtomTerm(AtomDot)
|
||||
|
||||
#ifdef IN_SECOND_QUADRANT
|
||||
typedef enum
|
||||
{
|
||||
db_ref_e = sizeof (Functor *) | RBIT,
|
||||
long_int_e = 2 * sizeof (Functor *) | RBIT,
|
||||
#ifdef USE_GMP
|
||||
big_int_e = 3 * sizeof (Functor *) | RBIT,
|
||||
double_e = 4 * sizeof (Functor *) | RBIT
|
||||
#else
|
||||
double_e = 3 * sizeof (Functor *) | RBIT
|
||||
#endif
|
||||
}
|
||||
blob_type;
|
||||
#else
|
||||
typedef enum
|
||||
{
|
||||
db_ref_e = sizeof (Functor *),
|
||||
long_int_e = 2 * sizeof (Functor *),
|
||||
#ifdef USE_GMP
|
||||
big_int_e = 3 * sizeof (Functor *),
|
||||
double_e = 4 * sizeof (Functor *)
|
||||
#else
|
||||
double_e = 3 * sizeof (Functor *)
|
||||
#endif
|
||||
}
|
||||
blob_type;
|
||||
#endif
|
||||
|
||||
#define FunctorDBRef ((Functor)(db_ref_e))
|
||||
#define FunctorLongInt ((Functor)(long_int_e))
|
||||
#ifdef USE_GMP
|
||||
#define FunctorBigInt ((Functor)(big_int_e))
|
||||
#endif
|
||||
#define FunctorDouble ((Functor)(double_e))
|
||||
#define EndSpecials (double_e)
|
||||
|
||||
|
||||
inline EXTERN blob_type BlobOfFunctor (Functor f);
|
||||
|
||||
inline EXTERN blob_type
|
||||
BlobOfFunctor (Functor f)
|
||||
{
|
||||
return (blob_type) ((CELL) f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define SF_STORE ((special_functors *)HEAP_INIT_BASE)
|
||||
|
||||
#ifdef COROUTINING
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* what to do when someone tries to bind our term to someone else
|
||||
in some predefined context */
|
||||
void (*bind_op) (Term *, Term);
|
||||
/* what to do if someone wants to copy our constraint */
|
||||
int (*copy_term_op) (Term, CELL ***);
|
||||
/* op called to do marking in GC */
|
||||
void (*mark_op) (CELL *);
|
||||
}
|
||||
ext_op;
|
||||
|
||||
/* known delays */
|
||||
typedef enum
|
||||
{
|
||||
empty_ext = 0 * sizeof (ext_op), /* default op, this should never be called */
|
||||
susp_ext = 1 * sizeof (ext_op), /* support for delayable goals */
|
||||
attvars_ext = 2 * sizeof (ext_op), /* support for attributed variables */
|
||||
/* add your own extensions here */
|
||||
/* keep this one */
|
||||
}
|
||||
exts;
|
||||
|
||||
|
||||
/* array with the ops for your favourite extensions */
|
||||
extern ext_op attas[attvars_ext + 1];
|
||||
|
||||
#endif
|
||||
|
||||
/* make sure that these data structures are the first thing to be allocated
|
||||
in the heap when we start the system */
|
||||
typedef struct special_functors_struct
|
||||
{
|
||||
AtomEntry AtFoundVar;
|
||||
char AtFoundVarChars[8];
|
||||
AtomEntry AtNil;
|
||||
char AtNilChars[8];
|
||||
AtomEntry AtDot;
|
||||
char AtDotChars[8];
|
||||
}
|
||||
special_functors;
|
||||
|
||||
#if SIZEOF_DOUBLE == SIZEOF_LONG_INT
|
||||
|
||||
inline EXTERN Term MkFloatTerm (Float);
|
||||
|
||||
inline EXTERN Term
|
||||
MkFloatTerm (Float dbl)
|
||||
{
|
||||
return (Term) ((H[0] = (CELL) FunctorDouble, *(Float *) (H + 1) =
|
||||
dbl, H[2] = ((2 * sizeof (CELL) + EndSpecials) | MBIT), H +=
|
||||
3, AbsAppl (H - 3)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline EXTERN Float FloatOfTerm (Term t);
|
||||
|
||||
inline EXTERN Float
|
||||
FloatOfTerm (Term t)
|
||||
{
|
||||
return (Float) (*(Float *) (RepAppl (t) + 1));
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define InitUnalignedFloat()
|
||||
|
||||
#else
|
||||
|
||||
#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
|
||||
|
||||
#ifdef i386X
|
||||
#define DOUBLE_ALIGNED(ADDR) TRUE
|
||||
#else
|
||||
/* first, need to address the alignment problem */
|
||||
#define DOUBLE_ALIGNED(ADDR) ((CELL)(ADDR) & 0x4)
|
||||
#endif
|
||||
|
||||
inline EXTERN Float STD_PROTO (CpFloatUnaligned, (CELL *));
|
||||
|
||||
|
||||
inline EXTERN void STD_PROTO (AlignGlobalForDouble, (void));
|
||||
|
||||
inline EXTERN Float
|
||||
CpFloatUnaligned (CELL * ptr)
|
||||
{
|
||||
union
|
||||
{
|
||||
Float f;
|
||||
CELL d[2];
|
||||
}
|
||||
u;
|
||||
u.d[0] = ptr[1];
|
||||
u.d[1] = ptr[2];
|
||||
return (u.f);
|
||||
}
|
||||
|
||||
|
||||
inline EXTERN Term MkFloatTerm (Float);
|
||||
|
||||
inline EXTERN Term
|
||||
MkFloatTerm (Float dbl)
|
||||
{
|
||||
return (Term) ((AlignGlobalForDouble (), H[0] =
|
||||
(CELL) FunctorDouble, *(Float *) (H + 1) = dbl, H[3] =
|
||||
((3 * sizeof (CELL) + EndSpecials) | MBIT), H +=
|
||||
4, AbsAppl (H - 4)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline EXTERN Float FloatOfTerm (Term t);
|
||||
|
||||
inline EXTERN Float
|
||||
FloatOfTerm (Term t)
|
||||
{
|
||||
return (Float) ((DOUBLE_ALIGNED (RepAppl (t)) ? *(Float *) (RepAppl (t) + 1)
|
||||
: CpFloatUnaligned (RepAppl (t))));
|
||||
}
|
||||
|
||||
|
||||
/* no alignment problems for 64 bit machines */
|
||||
#else
|
||||
/* OOPS, YAP only understands Floats that are as large as cells or that
|
||||
take two cells!!! */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
inline EXTERN int IsFloatTerm (Term);
|
||||
|
||||
inline EXTERN int
|
||||
IsFloatTerm (Term t)
|
||||
{
|
||||
return (int) (IsApplTerm (t) && FunctorOfTerm (t) == FunctorDouble);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* extern Functor FunctorLongInt; */
|
||||
|
||||
inline EXTERN Term MkLongIntTerm (Int);
|
||||
|
||||
inline EXTERN Term
|
||||
MkLongIntTerm (Int i)
|
||||
{
|
||||
return (Term) ((H[0] = (CELL) FunctorLongInt, H[1] = (CELL) i, H[2] =
|
||||
((2 * sizeof (CELL) + EndSpecials) | MBIT), H +=
|
||||
3, AbsAppl (H - 3)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int LongIntOfTerm (Term t);
|
||||
|
||||
inline EXTERN Int
|
||||
LongIntOfTerm (Term t)
|
||||
{
|
||||
return (Int) (RepAppl (t)[1]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN int IsLongIntTerm (Term);
|
||||
|
||||
inline EXTERN int
|
||||
IsLongIntTerm (Term t)
|
||||
{
|
||||
return (int) (IsApplTerm (t) && FunctorOfTerm (t) == FunctorLongInt);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef USE_GMP
|
||||
#include <stdio.h>
|
||||
#include <gmp.h>
|
||||
|
||||
|
||||
MP_INT *STD_PROTO (PreAllocBigNum, (void));
|
||||
void STD_PROTO (ClearAllocBigNum, (void));
|
||||
MP_INT *STD_PROTO (InitBigNum, (Int));
|
||||
Term STD_PROTO (MkBigIntTerm, (MP_INT *));
|
||||
MP_INT *STD_PROTO (BigIntOfTerm, (Term));
|
||||
|
||||
|
||||
inline EXTERN int IsBigIntTerm (Term);
|
||||
|
||||
inline EXTERN int
|
||||
IsBigIntTerm (Term t)
|
||||
{
|
||||
return (int) (IsApplTerm (t) && FunctorOfTerm (t) == FunctorBigInt);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline EXTERN int IsLargeIntTerm (Term);
|
||||
|
||||
inline EXTERN int
|
||||
IsLargeIntTerm (Term t)
|
||||
{
|
||||
return (int) (IsApplTerm (t)
|
||||
&& ((FunctorOfTerm (t) <= FunctorBigInt)
|
||||
&& (FunctorOfTerm (t) >= FunctorLongInt)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
inline EXTERN int IsBigIntTerm (Term);
|
||||
|
||||
inline EXTERN int
|
||||
IsBigIntTerm (Term t)
|
||||
{
|
||||
return (int) (FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline EXTERN int IsLargeIntTerm (Term);
|
||||
|
||||
inline EXTERN int
|
||||
IsLargeIntTerm (Term t)
|
||||
{
|
||||
return (int) (IsApplTerm (t) && FunctorOfTerm (t) == FunctorLongInt);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/* extern Functor FunctorLongInt; */
|
||||
|
||||
inline EXTERN int IsLargeNumTerm (Term);
|
||||
|
||||
inline EXTERN int
|
||||
IsLargeNumTerm (Term t)
|
||||
{
|
||||
return (int) (IsApplTerm (t)
|
||||
&& ((FunctorOfTerm (t) <= FunctorDouble)
|
||||
&& (FunctorOfTerm (t) >= FunctorLongInt)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline EXTERN int IsNumTerm (Term);
|
||||
|
||||
inline EXTERN int
|
||||
IsNumTerm (Term t)
|
||||
{
|
||||
return (int) ((IsIntTerm (t) || IsLargeNumTerm (t)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int IsAtomicTerm (Term);
|
||||
|
||||
inline EXTERN Int
|
||||
IsAtomicTerm (Term t)
|
||||
{
|
||||
return (Int) (IsAtomOrIntTerm (t) || IsLargeNumTerm (t));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int IsExtensionFunctor (Functor);
|
||||
|
||||
inline EXTERN Int
|
||||
IsExtensionFunctor (Functor f)
|
||||
{
|
||||
return (Int) (f <= FunctorDouble);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int IsBlobFunctor (Functor);
|
||||
|
||||
inline EXTERN Int
|
||||
IsBlobFunctor (Functor f)
|
||||
{
|
||||
return (Int) ((f <= FunctorDouble && f >= FunctorDBRef));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int IsPrimitiveTerm (Term);
|
||||
|
||||
inline EXTERN Int
|
||||
IsPrimitiveTerm (Term t)
|
||||
{
|
||||
return (Int) ((IsAtomOrIntTerm (t)
|
||||
|| (IsApplTerm (t) && IsBlobFunctor (FunctorOfTerm (t)))));
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef TERM_EXTENSIONS
|
||||
|
||||
|
||||
inline EXTERN Int IsAttachFunc (Functor);
|
||||
|
||||
inline EXTERN Int
|
||||
IsAttachFunc (Functor f)
|
||||
{
|
||||
return (Int) (FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int IsAttachedTerm (Term);
|
||||
|
||||
inline EXTERN Int
|
||||
IsAttachedTerm (Term t)
|
||||
{
|
||||
return (Int) ((IsVarTerm (t) && VarOfTerm (t) < H0));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline EXTERN exts ExtFromCell (CELL *);
|
||||
|
||||
inline EXTERN exts
|
||||
ExtFromCell (CELL * pt)
|
||||
{
|
||||
return (exts) (pt[1]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
inline EXTERN Int IsAttachFunc (Functor);
|
||||
|
||||
inline EXTERN Int
|
||||
IsAttachFunc (Functor f)
|
||||
{
|
||||
return (Int) (FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline EXTERN Int IsAttachedTerm (Term);
|
||||
|
||||
inline EXTERN Int
|
||||
IsAttachedTerm (Term t)
|
||||
{
|
||||
return (Int) (FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
EXTERN int STD_PROTO (unify_extension, (Functor, CELL, CELL *, CELL));
|
||||
|
||||
inline EXTERN int
|
||||
unify_extension (Functor f, CELL d0, CELL * pt0, CELL d1)
|
||||
{
|
||||
switch (BlobOfFunctor (f))
|
||||
{
|
||||
case db_ref_e:
|
||||
return (d0 == d1);
|
||||
case long_int_e:
|
||||
return (pt0[1] == RepAppl (d1)[1]);
|
||||
#ifdef USE_GMP
|
||||
case big_int_e:
|
||||
return (mpz_cmp (BigIntOfTerm (d0), BigIntOfTerm (d1)) == 0);
|
||||
#endif /* USE_GMP */
|
||||
case double_e:
|
||||
{
|
||||
CELL *pt1 = RepAppl (d1);
|
||||
return (pt0[1] == pt1[1]
|
||||
#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
|
||||
&& pt0[2] == pt1[2]
|
||||
#endif
|
||||
);
|
||||
}
|
||||
}
|
||||
return (FALSE);
|
||||
}
|
1079
VC/include/Yap.h
Normal file
1079
VC/include/Yap.h
Normal file
File diff suppressed because it is too large
Load Diff
1223
VC/include/Yatom.h
Normal file
1223
VC/include/Yatom.h
Normal file
File diff suppressed because it is too large
Load Diff
179
VC/include/config.h
Normal file
179
VC/include/config.h
Normal file
@@ -0,0 +1,179 @@
|
||||
/* config.h. Generated automatically by configure. */
|
||||
|
||||
/* are we using gcc */
|
||||
#define HAVE_GCC 1
|
||||
|
||||
/* should we use gcc threaded code (i.e. goto *adrs) */
|
||||
#define USE_THREADED_CODE 1
|
||||
|
||||
/* Should we use lib readline ? */
|
||||
/* #undef HAVE_LIBREADLINE */
|
||||
|
||||
/* Should we use gmp ? */
|
||||
/* #undef HAVE_LIBGMP */
|
||||
|
||||
/* does the compiler support inline ? */
|
||||
/* #undef inline */
|
||||
|
||||
/* Do we have Ansi headers ? */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Host Name ? */
|
||||
#define HOST_ALIAS "i386-pc-cygwin32"
|
||||
|
||||
/* #undef HAVE_SYS_WAIT_H */
|
||||
#define NO_UNION_WAIT 1
|
||||
|
||||
#define HAVE_ARPA_INET_H 1
|
||||
#define HAVE_CTYPE_H 1
|
||||
#define HAVE_DIRECT_H 1
|
||||
#define HAVE_ERRNO_H 1
|
||||
#define HAVE_FCNTL_H 1
|
||||
/* #undef HAVE_FENV_H */
|
||||
/* #undef HAVE_FPU_CONTROL_H */
|
||||
#define HAVE_IEEEFP_H 1
|
||||
#define HAVE_LIMITS_H 1
|
||||
#define HAVE_MEMORY_H 1
|
||||
#define HAVE_NETDB_H 1
|
||||
#define HAVE_NETINET_IN_H 1
|
||||
/* #undef HAVE_REGEX_H */
|
||||
/* #undef HAVE_SIGINFO_H */
|
||||
#define HAVE_STDARG_H 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_SYS_FILE_H 1
|
||||
#define HAVE_SYS_MMAN_H 1
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
#define HAVE_SYS_RESOURCE_H 1
|
||||
#define HAVE_SYS_SELECT_H 1
|
||||
/* #undef HAVE_SYS_SHM_H */
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
#define HAVE_SYS_TIMES_H 1
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
/* #undef HAVE_SYS_UCONTEXT_H */
|
||||
#define HAVE_SYS_UN_H 1
|
||||
#define HAVE_TIME_H 1
|
||||
#define HAVE_UNISTD_H 1
|
||||
#define HAVE_WINSOCK_H 1
|
||||
#define HAVE_WINSOCK2_H 1
|
||||
/* #undef HAVE_GMP_H */
|
||||
|
||||
/* Do we have restartable syscalls */
|
||||
/* #undef HAVE_RESTARTABLE_SYSCALLS */
|
||||
|
||||
/* is 'tms' defined in <sys/time.h> ? */
|
||||
/* #undef TM_IN_SYS_TIME */
|
||||
|
||||
/* define type of prt returned by malloc: char or void */
|
||||
#define MALLOC_T void *
|
||||
|
||||
/* Define byte order */
|
||||
/* #undef WORDS_BIGENDIAN */
|
||||
|
||||
/* Define sizes of some basic types */
|
||||
#define SIZEOF_INT_P 4
|
||||
#define SIZEOF_INT 4
|
||||
#define SIZEOF_SHORT_INT 2
|
||||
#define SIZEOF_LONG_INT 4
|
||||
#define SIZEOF_LONG_LONG_INT 8
|
||||
#define SIZEOF_FLOAT 4
|
||||
#define SIZEOF_DOUBLE 8
|
||||
|
||||
/* Define representation of floats */
|
||||
/* only one of the following shoud be set */
|
||||
/* to add a new representation you must edit FloatOfTerm and MkFloatTerm
|
||||
in adtdefs.c
|
||||
*/
|
||||
#define FFIEEE 1
|
||||
/* #undef FFVAX */ /* manual */
|
||||
|
||||
/* Define the standard type of a float argument to a function */
|
||||
#define FAFloat double /* manual */
|
||||
|
||||
/* Define return type for signal */
|
||||
#define RETSIGTYPE void
|
||||
|
||||
/* #undef HAVE_ALARM */
|
||||
/* #undef HAVE_ASINH */
|
||||
/* #undef HAVE_ACOSH */
|
||||
/* #undef HAVE_ATANH */
|
||||
#define HAVE_CHDIR 1
|
||||
#define HAVE_DUP2 1
|
||||
/* #undef HAVE_FETESTEXCEPT */
|
||||
/* #undef HAVE_FINITE */
|
||||
/* #undef HAVE_GETRUSAGE */
|
||||
#define HAVE_GETCWD 1
|
||||
#define HAVE_GETENV 1
|
||||
/* #undef HAVE_GETHRTIME */
|
||||
/* #undef HAVE_GETPWNAM */
|
||||
/* #undef HAVE_GETTIMEOFDAY */
|
||||
/* #undef HAVE_GETWD */
|
||||
#define HAVE_ISATTY 1
|
||||
/* #undef HAVE_ISNAN */
|
||||
#define HAVE_LABS 1
|
||||
/* #undef HAVE_LINK */
|
||||
/* #undef HAVE_MMAP */
|
||||
#define HAVE_MEMCPY 1
|
||||
#define HAVE_MEMMOVE 1
|
||||
/* #undef HAVE_MKSTEMP */
|
||||
#define HAVE_PUTENV 1
|
||||
#define HAVE_RAND 1
|
||||
/* #undef HAVE_RANDOM */
|
||||
/* #undef HAVE_RINT */
|
||||
/* #undef HAVE_SBRK */
|
||||
#define HAVE_STAT 1
|
||||
/* #undef HAVE_SELECT */
|
||||
#define HAVE_SETBUF 1
|
||||
/* #undef HAVE_SHMAT */
|
||||
/* #undef HAVE_SIGACTION */
|
||||
/* #undef HAVE_SIGGETMASK */
|
||||
#define HAVE_SIGNAL 1
|
||||
/* #undef HAVE_SIGPROCMASK */
|
||||
#define HAVE_SIGSEGV 1
|
||||
#define HAVE_SIGSETJMP 0
|
||||
/* #undef HAVE_SNPRINTF */
|
||||
/* #undef HAVE_SOCKET */
|
||||
#define HAVE_STRERROR 1
|
||||
#define HAVE_STRNCAT 1
|
||||
#define HAVE_STRNCPY 1
|
||||
#define HAVE_STRCHR 1
|
||||
#define HAVE_STRTOD 1
|
||||
#define HAVE_SYSTEM 1
|
||||
/* #undef HAVE_TIMES */
|
||||
#define HAVE_TMPNAM 1
|
||||
/* #undef HAVE_VSNPRINTF */
|
||||
#define HAVE_ENVIRON 1
|
||||
#define HAVE_MPZ_XOR 0
|
||||
|
||||
#define SELECT_TYPE_ARG1
|
||||
#define SELECT_TYPE_ARG234
|
||||
#define SELECT_TYPE_ARG5
|
||||
|
||||
#define TYPE_SELECT_
|
||||
#define MYTYPE(X) MYTYPE1#X
|
||||
|
||||
/* define how to pass the address of a function */
|
||||
#define FunAdr(Fn) Fn
|
||||
|
||||
#define ALIGN_LONGS 1
|
||||
#define LOW_ABSMI 0
|
||||
|
||||
#define MSHIFTOFFS 1
|
||||
|
||||
#define USE_MMAP (HAVE_MMAP)
|
||||
#define USE_SHM (HAVE_SHMAT & !HAVE_MMAP)
|
||||
#define USE_SBRK (HAVE_SBRK & !HAVE_MMAP & !HAVE_SHMAT)
|
||||
|
||||
/* for OSes that do not allow user access to the first
|
||||
quadrant of the memory space */
|
||||
/* #undef FORCE_SECOND_QUADRANT */
|
||||
|
||||
#if (HAVE_SOCKET || defined(__MINGW32__)) && !defined(SIMICS)
|
||||
#define USE_SOCKET 1
|
||||
#endif
|
||||
|
||||
#if HAVE_GMP_H && HAVE_LIBGMP
|
||||
#define USE_GMP 1
|
||||
#endif
|
||||
|
128
VC/include/corout_utils.h
Normal file
128
VC/include/corout_utils.h
Normal file
@@ -0,0 +1,128 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* YAP Prolog *
|
||||
* *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
* *
|
||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: corout_utils.h *
|
||||
* Last rev: *
|
||||
* mods: *
|
||||
* comments: Co-routining from within YAP *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
STATIC_PROTO (Term SDeref, (Term));
|
||||
STATIC_PROTO (Term SDerefa, (CELL *));
|
||||
STATIC_PROTO (sus_tag * deref_susp_chain, (sus_tag *));
|
||||
|
||||
static inline Term
|
||||
SDeref (Term a)
|
||||
{
|
||||
while (IsVarTerm (a))
|
||||
{
|
||||
Term *b = (Term *) a;
|
||||
a = *b;
|
||||
#if SBA
|
||||
if (a == (0))
|
||||
return (CELL) b;
|
||||
#else
|
||||
if (a == ((Term) b))
|
||||
return a;
|
||||
#endif
|
||||
}
|
||||
return (a);
|
||||
}
|
||||
|
||||
static inline Term
|
||||
SDerefa (CELL * b)
|
||||
{
|
||||
Term a = *b;
|
||||
while (IsVarTerm (a))
|
||||
{
|
||||
#if SBA
|
||||
if (a == (0))
|
||||
return (CELL) b;
|
||||
#else
|
||||
if (a == ((Term) b))
|
||||
return a;
|
||||
#endif
|
||||
b = (Term *) a;
|
||||
a = *b;
|
||||
}
|
||||
return (a);
|
||||
}
|
||||
|
||||
static inline CELL *
|
||||
SADerefa (CELL * b)
|
||||
{
|
||||
Term a = *b;
|
||||
while (IsVarTerm (a))
|
||||
{
|
||||
#if SBA
|
||||
if (a == (0))
|
||||
return b;
|
||||
#else
|
||||
if (a == ((Term) b))
|
||||
return b;
|
||||
#endif
|
||||
b = (Term *) a;
|
||||
a = *b;
|
||||
}
|
||||
return (b);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term SArgOfTerm (int i, Term t);
|
||||
|
||||
inline EXTERN Term
|
||||
SArgOfTerm (int i, Term t)
|
||||
{
|
||||
return (Term) (SDerefa (RepAppl (t) + (i)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term SHeadOfTerm (Term);
|
||||
|
||||
inline EXTERN Term
|
||||
SHeadOfTerm (Term t)
|
||||
{
|
||||
return (Term) (SDerefa (RepPair (t)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term STailOfTerm (Term);
|
||||
|
||||
inline EXTERN Term
|
||||
STailOfTerm (Term t)
|
||||
{
|
||||
return (Term) (SDerefa (RepPair (t) + 1));
|
||||
}
|
||||
|
||||
|
||||
|
||||
static inline sus_tag *
|
||||
deref_susp_chain (sus_tag * susp)
|
||||
{
|
||||
/* we may have bound several suspension chains together. Follow the
|
||||
reference chain
|
||||
*/
|
||||
while (IsVarTerm (susp->ActiveSus)
|
||||
&& susp->ActiveSus != (CELL) & susp->ActiveSus)
|
||||
susp =
|
||||
(sus_tag *) (susp->ActiveSus - (Int) (&(((sus_tag *) (0))->ActiveSus)));
|
||||
return (susp);
|
||||
}
|
604
VC/include/sshift.h
Normal file
604
VC/include/sshift.h
Normal file
@@ -0,0 +1,604 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* 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: sshift.h *
|
||||
* Last rev: 19/2/88 *
|
||||
* mods: *
|
||||
* comments: stack shifter functionality for YAP *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
|
||||
/* The difference between the old stack pointers and the new ones */
|
||||
extern Int HDiff, GDiff, LDiff, TrDiff, XDiff, DelayDiff;
|
||||
|
||||
/* The old stack pointers */
|
||||
extern CELL *OldASP, *OldLCL0;
|
||||
extern tr_fr_ptr OldTR;
|
||||
extern CELL *OldGlobalBase, *OldH, *OldH0;
|
||||
extern ADDR OldTrailBase, OldTrailTop;
|
||||
extern ADDR OldHeapBase, OldHeapTop;
|
||||
|
||||
#define CharP(ptr) ((char *) (ptr))
|
||||
|
||||
|
||||
inline EXTERN int IsHeapP (CELL *);
|
||||
|
||||
inline EXTERN int
|
||||
IsHeapP (CELL * ptr)
|
||||
{
|
||||
return (int) ((ptr >= (CELL *) HeapBase && ptr <= (CELL *) HeapTop));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Adjusting cells and pointers to cells */
|
||||
|
||||
inline EXTERN CELL *PtoGloAdjust (CELL *);
|
||||
|
||||
inline EXTERN CELL *
|
||||
PtoGloAdjust (CELL * ptr)
|
||||
{
|
||||
return (CELL *) (((CELL *) (CharP (ptr) + GDiff)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN CELL *PtoDelayAdjust (CELL *);
|
||||
|
||||
inline EXTERN CELL *
|
||||
PtoDelayAdjust (CELL * ptr)
|
||||
{
|
||||
return (CELL *) (((CELL *) (CharP (ptr) + DelayDiff)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN tr_fr_ptr PtoTRAdjust (tr_fr_ptr);
|
||||
|
||||
inline EXTERN tr_fr_ptr
|
||||
PtoTRAdjust (tr_fr_ptr ptr)
|
||||
{
|
||||
return (tr_fr_ptr) (((tr_fr_ptr) (CharP (ptr) + TrDiff)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN CELL *CellPtoTRAdjust (CELL *);
|
||||
|
||||
inline EXTERN CELL *
|
||||
CellPtoTRAdjust (CELL * ptr)
|
||||
{
|
||||
return (CELL *) (((CELL *) (CharP (ptr) + TrDiff)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN CELL *PtoLocAdjust (CELL *);
|
||||
|
||||
inline EXTERN CELL *
|
||||
PtoLocAdjust (CELL * ptr)
|
||||
{
|
||||
return (CELL *) (((CELL *) (CharP (ptr) + LDiff)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN choiceptr ChoicePtrAdjust (choiceptr);
|
||||
|
||||
inline EXTERN choiceptr
|
||||
ChoicePtrAdjust (choiceptr ptr)
|
||||
{
|
||||
return (choiceptr) (((choiceptr) (CharP (ptr) + LDiff)));
|
||||
}
|
||||
|
||||
|
||||
#ifdef TABLING
|
||||
|
||||
inline EXTERN choiceptr ConsumerChoicePtrAdjust (choiceptr);
|
||||
|
||||
inline EXTERN choiceptr
|
||||
ConsumerChoicePtrAdjust (choiceptr ptr)
|
||||
{
|
||||
return (choiceptr) (((choiceptr) (CharP (ptr) + LDiff)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN choiceptr GeneratorChoicePtrAdjust (choiceptr);
|
||||
|
||||
inline EXTERN choiceptr
|
||||
GeneratorChoicePtrAdjust (choiceptr ptr)
|
||||
{
|
||||
return (choiceptr) (((choiceptr) (CharP (ptr) + LDiff)));
|
||||
}
|
||||
|
||||
|
||||
#endif /* TABLING */
|
||||
|
||||
|
||||
inline EXTERN CELL GlobalAdjust (CELL);
|
||||
|
||||
inline EXTERN CELL
|
||||
GlobalAdjust (CELL val)
|
||||
{
|
||||
return (CELL) ((val + GDiff));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN CELL DelayAdjust (CELL);
|
||||
|
||||
inline EXTERN CELL
|
||||
DelayAdjust (CELL val)
|
||||
{
|
||||
return (CELL) ((val + DelayDiff));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN ADDR GlobalAddrAdjust (ADDR);
|
||||
|
||||
inline EXTERN ADDR
|
||||
GlobalAddrAdjust (ADDR ptr)
|
||||
{
|
||||
return (ADDR) ((ptr + GDiff));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN ADDR DelayAddrAdjust (ADDR);
|
||||
|
||||
inline EXTERN ADDR
|
||||
DelayAddrAdjust (ADDR ptr)
|
||||
{
|
||||
return (ADDR) ((ptr + DelayDiff));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN CELL LocalAdjust (CELL);
|
||||
|
||||
inline EXTERN CELL
|
||||
LocalAdjust (CELL val)
|
||||
{
|
||||
return (CELL) ((val + LDiff));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN ADDR LocalAddrAdjust (ADDR);
|
||||
|
||||
inline EXTERN ADDR
|
||||
LocalAddrAdjust (ADDR ptr)
|
||||
{
|
||||
return (ADDR) ((ptr + LDiff));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN CELL TrailAdjust (CELL);
|
||||
|
||||
inline EXTERN CELL
|
||||
TrailAdjust (CELL val)
|
||||
{
|
||||
return (CELL) ((val + TrDiff));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN ADDR TrailAddrAdjust (ADDR);
|
||||
|
||||
inline EXTERN ADDR
|
||||
TrailAddrAdjust (ADDR ptr)
|
||||
{
|
||||
return (ADDR) ((ptr + TrDiff));
|
||||
}
|
||||
|
||||
|
||||
/* heap data structures */
|
||||
|
||||
inline EXTERN Functor FuncAdjust (Functor);
|
||||
|
||||
inline EXTERN Functor
|
||||
FuncAdjust (Functor f)
|
||||
{
|
||||
return (Functor) ((Functor) (CharP (f) + HDiff));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN CELL *CellPtoHeapAdjust (CELL *);
|
||||
|
||||
inline EXTERN CELL *
|
||||
CellPtoHeapAdjust (CELL * ptr)
|
||||
{
|
||||
return (CELL *) (((CELL *) (CharP (ptr) + HDiff)));
|
||||
}
|
||||
|
||||
|
||||
#if USE_OFFSETS
|
||||
|
||||
inline EXTERN Atom AtomAdjust (Atom);
|
||||
|
||||
inline EXTERN Atom
|
||||
AtomAdjust (Atom at)
|
||||
{
|
||||
return (Atom) ((at));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term AtomTermAdjust (Term);
|
||||
|
||||
inline EXTERN Term
|
||||
AtomTermAdjust (Term at)
|
||||
{
|
||||
return (Term) ((at));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Prop PropAdjust (Prop);
|
||||
|
||||
inline EXTERN Prop
|
||||
PropAdjust (Prop p)
|
||||
{
|
||||
return (Prop) ((p));
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
inline EXTERN Atom AtomAdjust (Atom);
|
||||
|
||||
inline EXTERN Atom
|
||||
AtomAdjust (Atom at)
|
||||
{
|
||||
return (Atom) ((Atom) (CharP (at) + HDiff));
|
||||
}
|
||||
|
||||
|
||||
#if MMAP_ADDR >= 0x40000000
|
||||
|
||||
inline EXTERN Term AtomTermAdjust (Term);
|
||||
|
||||
inline EXTERN Term
|
||||
AtomTermAdjust (Term at)
|
||||
{
|
||||
return (Term) ((at));
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
inline EXTERN Term AtomTermAdjust (Term);
|
||||
|
||||
inline EXTERN Term
|
||||
AtomTermAdjust (Term at)
|
||||
{
|
||||
return (Term) (MkAtomTerm ((Atom) (CharP (AtomOfTerm (at) + HDiff))));
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
inline EXTERN Prop PropAdjust (Prop);
|
||||
|
||||
inline EXTERN Prop
|
||||
PropAdjust (Prop p)
|
||||
{
|
||||
return (Prop) ((Prop) (CharP (p) + HDiff));
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
#if TAGS_FAST_OPS
|
||||
|
||||
inline EXTERN Term BlobTermAdjust (Term);
|
||||
|
||||
inline EXTERN Term
|
||||
BlobTermAdjust (Term t)
|
||||
{
|
||||
return (Term) ((t - HDiff));
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
inline EXTERN Term BlobTermAdjust (Term);
|
||||
|
||||
inline EXTERN Term
|
||||
BlobTermAdjust (Term t)
|
||||
{
|
||||
return (Term) ((t + HDiff));
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
inline EXTERN AtomEntry *AtomEntryAdjust (AtomEntry *);
|
||||
|
||||
inline EXTERN AtomEntry *
|
||||
AtomEntryAdjust (AtomEntry * at)
|
||||
{
|
||||
return (AtomEntry *) ((AtomEntry *) (CharP (at) + HDiff));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN consult_obj *ConsultObjAdjust (consult_obj *);
|
||||
|
||||
inline EXTERN consult_obj *
|
||||
ConsultObjAdjust (consult_obj * co)
|
||||
{
|
||||
return (consult_obj *) ((consult_obj *) (CharP (co) + HDiff));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN DBRef DBRefAdjust (DBRef);
|
||||
|
||||
inline EXTERN DBRef
|
||||
DBRefAdjust (DBRef dbr)
|
||||
{
|
||||
return (DBRef) ((DBRef) (CharP (dbr) + HDiff));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Term CodeAdjust (Term);
|
||||
|
||||
inline EXTERN Term
|
||||
CodeAdjust (Term dbr)
|
||||
{
|
||||
return (Term) (((Term) (dbr) + HDiff));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN ADDR AddrAdjust (ADDR);
|
||||
|
||||
inline EXTERN ADDR
|
||||
AddrAdjust (ADDR addr)
|
||||
{
|
||||
return (ADDR) ((ADDR) (CharP (addr) + HDiff));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN CODEADDR CodeAddrAdjust (CODEADDR);
|
||||
|
||||
inline EXTERN CODEADDR
|
||||
CodeAddrAdjust (CODEADDR addr)
|
||||
{
|
||||
return (CODEADDR) ((CODEADDR) (CharP (addr) + HDiff));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN BlockHeader *BlockAdjust (BlockHeader *);
|
||||
|
||||
inline EXTERN BlockHeader *
|
||||
BlockAdjust (BlockHeader * addr)
|
||||
{
|
||||
return (BlockHeader *) ((BlockHeader *) (CharP (addr) + HDiff));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN yamop *PtoOpAdjust (yamop *);
|
||||
|
||||
inline EXTERN yamop *
|
||||
PtoOpAdjust (yamop * ptr)
|
||||
{
|
||||
return (yamop *) (((yamop *) (CharP (ptr) + HDiff)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN CELL *PtoHeapCellAdjust (CELL *);
|
||||
|
||||
inline EXTERN CELL *
|
||||
PtoHeapCellAdjust (CELL * ptr)
|
||||
{
|
||||
return (CELL *) (((CELL *) (CharP (ptr) + HDiff)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN PredEntry *PtoPredAdjust (PredEntry *);
|
||||
|
||||
inline EXTERN PredEntry *
|
||||
PtoPredAdjust (PredEntry * ptr)
|
||||
{
|
||||
return (PredEntry *) (((CELL *) (CharP (ptr) + HDiff)));
|
||||
}
|
||||
|
||||
|
||||
#if PRECOMPUTE_REGADDRESS
|
||||
|
||||
inline EXTERN AREG XAdjust (AREG);
|
||||
|
||||
inline EXTERN AREG
|
||||
XAdjust (AREG reg)
|
||||
{
|
||||
return (AREG) ((AREG) ((reg) + XDiff));
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
inline EXTERN AREG XAdjust (AREG);
|
||||
|
||||
inline EXTERN AREG
|
||||
XAdjust (AREG reg)
|
||||
{
|
||||
return (AREG) ((reg));
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
inline EXTERN YREG YAdjust (YREG);
|
||||
|
||||
inline EXTERN YREG
|
||||
YAdjust (YREG reg)
|
||||
{
|
||||
return (YREG) ((reg));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline EXTERN int IsOldLocal (CELL);
|
||||
|
||||
inline EXTERN int
|
||||
IsOldLocal (CELL reg)
|
||||
{
|
||||
return (int) (IN_BETWEEN (OldASP, reg, OldLCL0));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* require because the trail might contain dangling pointers */
|
||||
|
||||
inline EXTERN int IsOldLocalInTR (CELL);
|
||||
|
||||
inline EXTERN int
|
||||
IsOldLocalInTR (CELL reg)
|
||||
{
|
||||
return (int) (IN_BETWEEN (OldH, reg, OldLCL0));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN int IsOldLocalInTRPtr (CELL *);
|
||||
|
||||
inline EXTERN int
|
||||
IsOldLocalInTRPtr (CELL * ptr)
|
||||
{
|
||||
return (int) (IN_BETWEEN (OldH, ptr, OldLCL0));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline EXTERN int IsOldH (CELL);
|
||||
|
||||
inline EXTERN int
|
||||
IsOldH (CELL reg)
|
||||
{
|
||||
return (int) ((CharP (reg) == CharP (OldH)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
inline EXTERN int IsOldGlobal (CELL);
|
||||
|
||||
inline EXTERN int
|
||||
IsOldGlobal (CELL reg)
|
||||
{
|
||||
return (int) (IN_BETWEEN (OldH0, reg, OldH));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN int IsOldGlobalPtr (CELL *);
|
||||
|
||||
inline EXTERN int
|
||||
IsOldGlobalPtr (CELL * ptr)
|
||||
{
|
||||
return (int) (IN_BETWEEN (OldH0, ptr, OldH));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN int IsOldDelay (CELL);
|
||||
|
||||
inline EXTERN int
|
||||
IsOldDelay (CELL reg)
|
||||
{
|
||||
return (int) (IN_BETWEEN (OldGlobalBase, reg, OldH0));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN int IsOldDelayPtr (CELL *);
|
||||
|
||||
inline EXTERN int
|
||||
IsOldDelayPtr (CELL * ptr)
|
||||
{
|
||||
return (int) (IN_BETWEEN (OldGlobalBase, ptr, OldH0));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN int IsOldTrail (CELL);
|
||||
|
||||
inline EXTERN int
|
||||
IsOldTrail (CELL reg)
|
||||
{
|
||||
return (int) (IN_BETWEEN (OldTrailBase, reg, OldTR));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN int IsOldTrailPtr (CELL *);
|
||||
|
||||
inline EXTERN int
|
||||
IsOldTrailPtr (CELL * ptr)
|
||||
{
|
||||
return (int) (IN_BETWEEN (OldTrailBase, ptr, OldTR));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN int IsOldCode (CELL);
|
||||
|
||||
inline EXTERN int
|
||||
IsOldCode (CELL reg)
|
||||
{
|
||||
return (int) (IN_BETWEEN (OldHeapBase, reg, OldHeapTop));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN int IsOldCodeCellPtr (CELL *);
|
||||
|
||||
inline EXTERN int
|
||||
IsOldCodeCellPtr (CELL * ptr)
|
||||
{
|
||||
return (int) (IN_BETWEEN (OldHeapBase, ptr, OldHeapTop));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN int IsGlobal (CELL);
|
||||
|
||||
inline EXTERN int
|
||||
IsGlobal (CELL reg)
|
||||
{
|
||||
return (int) (IN_BETWEEN (GlobalBase, reg, H));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void STD_PROTO (AdjustStacksAndTrail, (void));
|
||||
void STD_PROTO (AdjustRegs, (int));
|
Reference in New Issue
Block a user