2012-05-14 15:06:18 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* *
|
|
|
|
* YAP Prolog %W% %G% *
|
|
|
|
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
|
|
|
* *
|
|
|
|
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-2012 *
|
|
|
|
* *
|
|
|
|
**************************************************************************
|
|
|
|
* *
|
|
|
|
* File: YapCompounTerm.h *
|
|
|
|
* mods: *
|
|
|
|
* comments: main header file for YAP *
|
|
|
|
* version: $Id: Yap.h,v 1.38 2008-06-18 10:02:27 vsc Exp $ *
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
/*************************************************************************************************
|
|
|
|
High level macros to access arguments
|
|
|
|
*************************************************************************************************/
|
|
|
|
|
|
|
|
#ifndef YAPCOMPOUNDTERM_H
|
|
|
|
|
|
|
|
#define YAPCOMPOUNDTERM_H 1
|
|
|
|
|
2012-06-29 22:44:08 +01:00
|
|
|
#include "inline-only.h"
|
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
EXTERN Int Yap_unify(Term a, Term b);
|
2012-05-14 15:06:18 +01:00
|
|
|
|
2012-06-30 19:42:14 +01:00
|
|
|
INLINE_ONLY EXTERN inline Term Deref(Term a);
|
2012-05-14 15:06:18 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
INLINE_ONLY EXTERN inline Term Deref(Term a) {
|
|
|
|
while (IsVarTerm(a)) {
|
|
|
|
Term *b = (Term *)a;
|
|
|
|
a = *b;
|
|
|
|
if (a == ((Term)b))
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
return (a);
|
2012-05-14 15:06:18 +01:00
|
|
|
}
|
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
INLINE_ONLY EXTERN inline CELL *GetTermAdress(Term a);
|
|
|
|
|
|
|
|
|
2012-06-30 19:42:14 +01:00
|
|
|
INLINE_ONLY EXTERN inline Term Derefa(CELL *b);
|
2012-05-14 15:06:18 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
INLINE_ONLY EXTERN inline Term Derefa(CELL *b) {
|
2012-05-14 15:06:18 +01:00
|
|
|
Term a = *b;
|
2016-03-29 02:02:43 +01:00
|
|
|
restart:
|
2012-05-14 15:06:18 +01:00
|
|
|
if (!IsVarTerm(a)) {
|
2016-03-29 02:02:43 +01:00
|
|
|
return (a);
|
2012-05-14 15:06:18 +01:00
|
|
|
} else if (a == (CELL)b) {
|
2016-03-29 02:02:43 +01:00
|
|
|
return (a);
|
2012-05-14 15:06:18 +01:00
|
|
|
} else {
|
|
|
|
b = (CELL *)a;
|
|
|
|
a = *b;
|
|
|
|
goto restart;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
INLINE_ONLY inline EXTERN Term ArgOfTerm(int i, Term t);
|
2012-05-14 15:06:18 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
INLINE_ONLY inline EXTERN Term ArgOfTerm(int i, Term t)
|
2015-07-23 01:33:30 +01:00
|
|
|
|
2012-05-14 15:06:18 +01:00
|
|
|
{
|
2016-03-29 02:02:43 +01:00
|
|
|
return (Term)(Derefa(RepAppl(t) + (i)));
|
2012-05-14 15:06:18 +01:00
|
|
|
}
|
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
INLINE_ONLY inline EXTERN Term HeadOfTerm(Term);
|
2012-05-14 15:06:18 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
INLINE_ONLY inline EXTERN Term HeadOfTerm(Term t) {
|
|
|
|
return (Term)(Derefa(RepPair(t)));
|
2012-05-14 15:06:18 +01:00
|
|
|
}
|
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
INLINE_ONLY inline EXTERN Term TailOfTerm(Term);
|
2012-05-14 15:06:18 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
INLINE_ONLY inline EXTERN Term TailOfTerm(Term t) {
|
|
|
|
return (Term)(Derefa(RepPair(t) + 1));
|
2012-05-14 15:06:18 +01:00
|
|
|
}
|
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
INLINE_ONLY inline EXTERN Term ArgOfTermCell(int i, Term t);
|
2012-05-14 15:06:18 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
INLINE_ONLY inline EXTERN Term ArgOfTermCell(int i, Term t) {
|
|
|
|
return (Term)((CELL)(RepAppl(t) + (i)));
|
2012-05-14 15:06:18 +01:00
|
|
|
}
|
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
INLINE_ONLY inline EXTERN Term HeadOfTermCell(Term);
|
2012-05-14 15:06:18 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
INLINE_ONLY inline EXTERN Term HeadOfTermCell(Term t) {
|
|
|
|
return (Term)((CELL)(RepPair(t)));
|
2012-05-14 15:06:18 +01:00
|
|
|
}
|
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
INLINE_ONLY inline EXTERN Term TailOfTermCell(Term);
|
2012-05-14 15:06:18 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
INLINE_ONLY inline EXTERN Term TailOfTermCell(Term t) {
|
|
|
|
return (Term)((CELL)(RepPair(t) + 1));
|
2012-05-14 15:06:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* YAPCOMPOUNDTERM_H */
|