2001-04-09 20:54:03 +01:00
|
|
|
/*************************************************************************
|
2015-11-09 11:25:55 +00:00
|
|
|
* *
|
|
|
|
* YAP Prolog *
|
|
|
|
* *
|
|
|
|
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
|
|
|
* *
|
|
|
|
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
|
|
|
* *
|
|
|
|
**************************************************************************
|
|
|
|
* *
|
|
|
|
* File: attvar.c *
|
|
|
|
* Last rev: *
|
|
|
|
* mods: *
|
|
|
|
* comments: YAP support for attributed vars *
|
|
|
|
* *
|
|
|
|
*************************************************************************/
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef SCCS
|
2015-11-06 18:22:31 +00:00
|
|
|
static char SccsId[] = "%W% %G%";
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "Yap.h"
|
|
|
|
|
|
|
|
#include "Yatom.h"
|
2009-10-23 14:22:17 +01:00
|
|
|
#include "YapHeap.h"
|
2001-04-09 20:54:03 +01:00
|
|
|
#include "heapgc.h"
|
|
|
|
#include "attvar.h"
|
|
|
|
#ifndef NULL
|
|
|
|
#define NULL (void *)0
|
|
|
|
#endif
|
|
|
|
|
2015-01-04 23:58:23 +00:00
|
|
|
/** @{ */
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
/** @defgroup Attribute_Variables_Builtins Implementation of Attribute
|
2015-11-09 11:25:55 +00:00
|
|
|
Declarations
|
2015-01-04 23:58:23 +00:00
|
|
|
@ingroup Attributed_Variables
|
|
|
|
*/
|
|
|
|
|
2004-06-23 18:24:20 +01:00
|
|
|
#ifdef COROUTINING
|
|
|
|
|
2006-01-07 02:12:32 +00:00
|
|
|
#define TermVoidAtt TermFoundVar
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static CELL *AddToQueue(attvar_record *attv USES_REGS) {
|
2001-04-09 20:54:03 +01:00
|
|
|
Term t[2];
|
2004-06-05 04:37:01 +01:00
|
|
|
Term WGs, ng;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
t[0] = (CELL) & (attv->Done);
|
2001-04-09 20:54:03 +01:00
|
|
|
t[1] = attv->Value;
|
|
|
|
/* follow the chain */
|
2011-05-04 10:11:41 +01:00
|
|
|
WGs = Yap_ReadTimedVar(LOCAL_WokenGoals);
|
2004-06-05 04:37:01 +01:00
|
|
|
ng = Yap_MkApplTerm(FunctorAttGoal, 2, t);
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2011-05-04 10:11:41 +01:00
|
|
|
Yap_UpdateTimedVar(LOCAL_WokenGoals, MkPairTerm(ng, WGs));
|
2001-04-09 20:54:03 +01:00
|
|
|
if ((Term)WGs == TermNil) {
|
|
|
|
/* from now on, we have to start waking up goals */
|
2004-01-23 02:23:51 +00:00
|
|
|
Yap_signal(YAP_WAKEUP_SIGNAL);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2015-11-06 18:22:31 +00:00
|
|
|
return (RepAppl(ng) + 2);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static void AddFailToQueue(USES_REGS1) {
|
2004-06-05 04:37:01 +01:00
|
|
|
Term WGs;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
/* follow the chain */
|
2011-05-04 10:11:41 +01:00
|
|
|
WGs = Yap_ReadTimedVar(LOCAL_WokenGoals);
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2011-05-04 10:11:41 +01:00
|
|
|
Yap_UpdateTimedVar(LOCAL_WokenGoals, MkPairTerm(MkAtomTerm(AtomFail), WGs));
|
2001-04-09 20:54:03 +01:00
|
|
|
if ((Term)WGs == TermNil) {
|
|
|
|
/* from now on, we have to start waking up goals */
|
2004-01-23 02:23:51 +00:00
|
|
|
Yap_signal(YAP_WAKEUP_SIGNAL);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static attvar_record *BuildNewAttVar(USES_REGS1) {
|
2010-03-08 09:18:52 +00:00
|
|
|
attvar_record *newv;
|
|
|
|
|
|
|
|
/* add a new attributed variable */
|
2014-01-19 21:15:05 +00:00
|
|
|
newv = (attvar_record *)HR;
|
2015-11-06 18:22:31 +00:00
|
|
|
HR = (CELL *)(newv + 1);
|
2010-03-08 09:18:52 +00:00
|
|
|
newv->AttFunc = FunctorAttVar;
|
|
|
|
RESET_VARIABLE(&(newv->Value));
|
|
|
|
RESET_VARIABLE(&(newv->Done));
|
|
|
|
RESET_VARIABLE(&(newv->Atts));
|
|
|
|
return newv;
|
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static int CopyAttVar(CELL *orig, struct cp_frame **to_visit_ptr,
|
|
|
|
CELL *res USES_REGS) {
|
2010-03-08 09:18:52 +00:00
|
|
|
register attvar_record *attv = RepAttVar(orig);
|
2001-04-09 20:54:03 +01:00
|
|
|
register attvar_record *newv;
|
2007-09-21 14:52:52 +01:00
|
|
|
struct cp_frame *to_visit = *to_visit_ptr;
|
2005-09-09 18:24:39 +01:00
|
|
|
CELL *vt;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
if (!(newv = BuildNewAttVar(PASS_REGS1)))
|
2004-09-09 21:00:59 +01:00
|
|
|
return FALSE;
|
2005-09-09 18:24:39 +01:00
|
|
|
vt = &(attv->Atts);
|
2015-11-06 18:22:31 +00:00
|
|
|
to_visit->start_cp = vt - 1;
|
2007-09-21 14:52:52 +01:00
|
|
|
to_visit->end_cp = vt;
|
2005-10-28 18:38:50 +01:00
|
|
|
if (IsVarTerm(attv->Atts)) {
|
2014-01-19 21:15:05 +00:00
|
|
|
Bind_Global_NonAtt(&newv->Atts, (CELL)HR);
|
|
|
|
to_visit->to = HR;
|
|
|
|
HR++;
|
2005-10-28 18:38:50 +01:00
|
|
|
} else {
|
2007-09-21 14:52:52 +01:00
|
|
|
to_visit->to = &(newv->Atts);
|
2005-10-28 18:38:50 +01:00
|
|
|
}
|
2007-09-21 14:52:52 +01:00
|
|
|
to_visit->oldv = vt[-1];
|
|
|
|
to_visit->ground = FALSE;
|
2015-11-06 18:22:31 +00:00
|
|
|
*to_visit_ptr = to_visit + 1;
|
|
|
|
*res = (CELL) & (newv->Done);
|
2005-09-09 18:24:39 +01:00
|
|
|
return TRUE;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Term AttVarToTerm(CELL *orig) {
|
2010-03-08 09:18:52 +00:00
|
|
|
attvar_record *attv = RepAttVar(orig);
|
2005-09-09 18:24:39 +01:00
|
|
|
|
|
|
|
return attv->Atts;
|
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static int IsEmptyWakeUp(Term atts) {
|
2013-04-30 21:23:01 +01:00
|
|
|
Atom name = NameOfFunctor(FunctorOfTerm(atts));
|
|
|
|
Atom *pt = EmptyWakeups;
|
|
|
|
int i = 0;
|
|
|
|
while (i < MaxEmptyWakeups) {
|
2015-11-06 18:22:31 +00:00
|
|
|
if (pt[i++] == name)
|
|
|
|
return TRUE;
|
2013-04-30 21:23:01 +01:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
void Yap_MkEmptyWakeUp(Atom mod) {
|
2013-04-30 21:23:01 +01:00
|
|
|
if (MaxEmptyWakeups == MAX_EMPTY_WAKEUPS)
|
2015-11-06 18:22:31 +00:00
|
|
|
Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
|
|
|
|
"too many modules that do not wake up");
|
2013-04-30 21:23:01 +01:00
|
|
|
EmptyWakeups[MaxEmptyWakeups++] = mod;
|
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static int TermToAttVar(Term attvar, Term to USES_REGS) {
|
|
|
|
attvar_record *attv = BuildNewAttVar(PASS_REGS1);
|
2005-09-09 18:24:39 +01:00
|
|
|
if (!attv)
|
|
|
|
return FALSE;
|
2011-03-18 19:34:58 +00:00
|
|
|
Bind_Global_NonAtt(&attv->Atts, attvar);
|
2010-03-08 09:18:52 +00:00
|
|
|
*VarOfTerm(to) = AbsAttVar(attv);
|
2005-09-09 18:24:39 +01:00
|
|
|
return TRUE;
|
2001-12-17 18:31:11 +00:00
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static void WakeAttVar(CELL *pt1, CELL reg2 USES_REGS) {
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
/* if bound to someone else, follow until we find the last one */
|
2010-03-08 09:18:52 +00:00
|
|
|
attvar_record *attv = RepAttVar(pt1);
|
2014-01-19 21:15:05 +00:00
|
|
|
CELL *myH = HR;
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL *bind_ptr;
|
|
|
|
|
2010-03-15 14:17:30 +00:00
|
|
|
if (IsVarTerm(Deref(attv->Atts))) {
|
|
|
|
/* no attributes to wake */
|
|
|
|
return;
|
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
if (IsVarTerm(reg2)) {
|
2004-09-10 21:18:01 +01:00
|
|
|
if (pt1 == VarOfTerm(reg2))
|
|
|
|
return;
|
2001-04-09 20:54:03 +01:00
|
|
|
if (IsAttachedTerm(reg2)) {
|
2010-03-08 09:18:52 +00:00
|
|
|
attvar_record *susp2 = RepAttVar(VarOfTerm(reg2));
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
/* binding two suspended variables, be careful */
|
|
|
|
if (susp2 >= attv) {
|
2015-11-06 18:22:31 +00:00
|
|
|
if (!IsVarTerm(susp2->Value) || !IsUnboundVar(&susp2->Value)) {
|
|
|
|
/* oops, our goal is on the queue to be woken */
|
|
|
|
if (!Yap_unify(susp2->Value, (CELL)pt1)) {
|
|
|
|
AddFailToQueue(PASS_REGS1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Bind_Global_NonAtt(&(susp2->Value), (CELL)pt1);
|
|
|
|
AddToQueue(susp2 PASS_REGS);
|
|
|
|
return;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
} else {
|
2011-03-18 19:34:58 +00:00
|
|
|
Bind_NonAtt(VarOfTerm(reg2), (CELL)pt1);
|
2001-04-09 20:54:03 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-04-30 21:23:01 +01:00
|
|
|
if (IsEmptyWakeUp(attv->Atts)) {
|
|
|
|
Bind_Global_NonAtt(&(attv->Value), reg2);
|
|
|
|
Bind_Global_NonAtt(&(attv->Done), attv->Value);
|
|
|
|
return;
|
|
|
|
}
|
2004-09-18 15:03:42 +01:00
|
|
|
if (!IsVarTerm(attv->Value) || !IsUnboundVar(&attv->Value)) {
|
2002-04-13 05:39:03 +01:00
|
|
|
/* oops, our goal is on the queue to be woken */
|
2002-11-18 18:18:05 +00:00
|
|
|
if (!Yap_unify(attv->Value, reg2)) {
|
2015-11-06 18:22:31 +00:00
|
|
|
AddFailToQueue(PASS_REGS1);
|
2002-04-13 05:39:03 +01:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2011-03-07 16:02:55 +00:00
|
|
|
bind_ptr = AddToQueue(attv PASS_REGS);
|
2001-04-09 20:54:03 +01:00
|
|
|
if (IsNonVarTerm(reg2)) {
|
|
|
|
if (IsPairTerm(reg2) && RepPair(reg2) == myH)
|
2014-01-19 21:15:05 +00:00
|
|
|
reg2 = AbsPair(HR);
|
2001-04-09 20:54:03 +01:00
|
|
|
else if (IsApplTerm(reg2) && RepAppl(reg2) == myH)
|
2014-01-19 21:15:05 +00:00
|
|
|
reg2 = AbsAppl(HR);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
*bind_ptr = reg2;
|
2011-03-18 19:34:58 +00:00
|
|
|
Bind_Global_NonAtt(&(attv->Value), reg2);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
void Yap_WakeUp(CELL *pt0) {
|
2011-03-07 16:02:55 +00:00
|
|
|
CACHE_REGS
|
2015-11-09 11:25:55 +00:00
|
|
|
CELL d0 = *pt0;
|
2004-06-05 04:37:01 +01:00
|
|
|
RESET_VARIABLE(pt0);
|
2011-03-07 16:02:55 +00:00
|
|
|
WakeAttVar(pt0, d0 PASS_REGS);
|
2004-06-05 04:37:01 +01:00
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static void mark_attvar(CELL *orig) { return; }
|
2004-06-05 04:37:01 +01:00
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Term BuildAttTerm(Functor mfun, UInt ar USES_REGS) {
|
2014-01-19 21:15:05 +00:00
|
|
|
CELL *h0 = HR;
|
2005-09-09 18:24:39 +01:00
|
|
|
UInt i;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
if (HR + (1024 + ar) > ASP) {
|
|
|
|
LOCAL_Error_Size = ar * sizeof(CELL);
|
2005-09-09 18:24:39 +01:00
|
|
|
return 0L;
|
2001-07-04 17:48:54 +01:00
|
|
|
}
|
2014-01-19 21:15:05 +00:00
|
|
|
HR[0] = (CELL)mfun;
|
2015-11-06 18:22:31 +00:00
|
|
|
RESET_VARIABLE(HR + 1);
|
2014-01-19 21:15:05 +00:00
|
|
|
HR += 2;
|
2015-11-06 18:22:31 +00:00
|
|
|
for (i = 1; i < ar; i++) {
|
2014-01-19 21:15:05 +00:00
|
|
|
*HR = TermVoidAtt;
|
|
|
|
HR++;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2005-09-09 18:24:39 +01:00
|
|
|
return AbsAppl(h0);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Term SearchAttsForModule(Term start, Functor mfun) {
|
2005-09-09 18:24:39 +01:00
|
|
|
do {
|
2015-11-06 18:22:31 +00:00
|
|
|
if (IsVarTerm(start) || FunctorOfTerm(start) == mfun)
|
2005-09-09 18:24:39 +01:00
|
|
|
return start;
|
2015-11-06 18:22:31 +00:00
|
|
|
start = ArgOfTerm(1, start);
|
2005-09-09 18:24:39 +01:00
|
|
|
} while (TRUE);
|
2004-06-05 04:37:01 +01:00
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Term SearchAttsForModuleName(Term start, Atom mname) {
|
2005-09-09 18:24:39 +01:00
|
|
|
do {
|
2015-11-06 18:22:31 +00:00
|
|
|
if (IsVarTerm(start) || NameOfFunctor(FunctorOfTerm(start)) == mname)
|
2005-09-09 18:24:39 +01:00
|
|
|
return start;
|
2015-11-06 18:22:31 +00:00
|
|
|
start = ArgOfTerm(1, start);
|
2005-09-09 18:24:39 +01:00
|
|
|
} while (TRUE);
|
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static void AddNewModule(attvar_record *attv, Term t, int new,
|
|
|
|
int do_it USES_REGS) {
|
|
|
|
CELL *newp = RepAppl(t) + 2;
|
2006-01-07 02:12:32 +00:00
|
|
|
UInt i, ar = ArityOfFunctor((Functor)newp[-2]);
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
for (i = 1; i < ar; i++) {
|
2006-01-07 02:12:32 +00:00
|
|
|
Term n = Deref(*newp);
|
|
|
|
if (n == TermFreeTerm) {
|
|
|
|
*newp = TermVoidAtt;
|
|
|
|
} else {
|
|
|
|
if (n != TermVoidAtt)
|
2015-11-06 18:22:31 +00:00
|
|
|
do_it = TRUE;
|
2006-01-07 02:12:32 +00:00
|
|
|
}
|
|
|
|
newp++;
|
|
|
|
}
|
|
|
|
if (!do_it)
|
|
|
|
return;
|
2011-03-18 19:34:58 +00:00
|
|
|
if (new) {
|
|
|
|
attv->Atts = t;
|
|
|
|
} else if (IsVarTerm(attv->Atts)) {
|
2015-11-06 18:22:31 +00:00
|
|
|
MaBind(&(attv->Atts), t);
|
2005-09-09 18:24:39 +01:00
|
|
|
} else {
|
|
|
|
Term *wherep = &attv->Atts;
|
|
|
|
|
|
|
|
do {
|
|
|
|
if (IsVarTerm(*wherep)) {
|
2015-11-06 18:22:31 +00:00
|
|
|
Bind_Global_NonAtt(wherep, t);
|
|
|
|
return;
|
2005-09-09 18:24:39 +01:00
|
|
|
} else {
|
2015-11-06 18:22:31 +00:00
|
|
|
wherep = RepAppl(Deref(*wherep)) + 1;
|
2005-09-09 18:24:39 +01:00
|
|
|
}
|
|
|
|
} while (TRUE);
|
2003-02-14 10:52:00 +00:00
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static void ReplaceAtts(attvar_record *attv, Term oatt, Term att USES_REGS) {
|
2005-09-09 18:24:39 +01:00
|
|
|
UInt ar = ArityOfFunctor(FunctorOfTerm(oatt)), i;
|
2015-11-06 18:22:31 +00:00
|
|
|
CELL *oldp = RepAppl(oatt) + 1;
|
2006-01-02 02:16:19 +00:00
|
|
|
CELL *newp;
|
2005-09-09 18:24:39 +01:00
|
|
|
|
2006-01-02 02:16:19 +00:00
|
|
|
if (oldp > HB) {
|
|
|
|
oldp++;
|
2015-11-06 18:22:31 +00:00
|
|
|
newp = RepAppl(att) + 2;
|
2006-01-02 02:16:19 +00:00
|
|
|
/* if deterministic */
|
2006-01-07 02:12:32 +00:00
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
for (i = 1; i < ar; i++) {
|
2006-01-07 02:12:32 +00:00
|
|
|
Term n = Deref(*newp);
|
|
|
|
if (n != TermFreeTerm) {
|
2015-11-06 18:22:31 +00:00
|
|
|
*oldp = n;
|
2006-01-02 02:16:19 +00:00
|
|
|
}
|
|
|
|
oldp++;
|
|
|
|
newp++;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2015-11-06 18:22:31 +00:00
|
|
|
newp = RepAppl(att) + 1;
|
2005-09-09 18:24:39 +01:00
|
|
|
*newp++ = *oldp++;
|
2015-11-06 18:22:31 +00:00
|
|
|
for (i = 1; i < ar; i++) {
|
2006-01-07 02:12:32 +00:00
|
|
|
Term n = Deref(*newp);
|
|
|
|
|
|
|
|
if (n == TermFreeTerm) {
|
|
|
|
*newp = Deref(*oldp);
|
2002-04-06 04:54:18 +01:00
|
|
|
}
|
2005-09-09 18:24:39 +01:00
|
|
|
oldp++;
|
|
|
|
newp++;
|
2002-04-06 04:54:18 +01:00
|
|
|
}
|
2005-09-09 18:24:39 +01:00
|
|
|
if (attv->Atts == oatt) {
|
|
|
|
if (RepAppl(attv->Atts) >= HB)
|
|
|
|
attv->Atts = att;
|
|
|
|
else
|
|
|
|
MaBind(&(attv->Atts), att);
|
|
|
|
} else {
|
|
|
|
Term *wherep = &attv->Atts;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2005-09-09 18:24:39 +01:00
|
|
|
do {
|
|
|
|
if (*wherep == oatt) {
|
2015-11-06 18:22:31 +00:00
|
|
|
MaBind(wherep, att);
|
|
|
|
return;
|
2005-09-09 18:24:39 +01:00
|
|
|
} else {
|
2015-11-06 18:22:31 +00:00
|
|
|
wherep = RepAppl(Deref(*wherep)) + 1;
|
2005-09-09 18:24:39 +01:00
|
|
|
}
|
|
|
|
} while (TRUE);
|
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static void DelAllAtts(attvar_record *attv USES_REGS) {
|
2010-03-27 10:57:21 +00:00
|
|
|
MaBind(&(attv->Done), attv->Value);
|
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static void DelAtts(attvar_record *attv, Term oatt USES_REGS) {
|
|
|
|
Term t = ArgOfTerm(1, oatt);
|
2005-10-18 18:04:43 +01:00
|
|
|
if (attv->Atts == oatt) {
|
2010-03-27 10:57:21 +00:00
|
|
|
if (IsVarTerm(t)) {
|
2011-03-07 16:02:55 +00:00
|
|
|
DelAllAtts(attv PASS_REGS);
|
2010-03-27 10:57:21 +00:00
|
|
|
return;
|
|
|
|
}
|
2005-10-18 18:04:43 +01:00
|
|
|
if (RepAppl(attv->Atts) >= HB)
|
2010-03-27 10:57:21 +00:00
|
|
|
attv->Atts = t;
|
2005-10-18 18:04:43 +01:00
|
|
|
else
|
2010-03-27 10:57:21 +00:00
|
|
|
MaBind(&(attv->Atts), t);
|
2005-10-18 18:04:43 +01:00
|
|
|
} else {
|
|
|
|
Term *wherep = &attv->Atts;
|
|
|
|
|
|
|
|
do {
|
|
|
|
if (*wherep == oatt) {
|
2015-11-06 18:22:31 +00:00
|
|
|
MaBind(wherep, t);
|
|
|
|
return;
|
2005-10-18 18:04:43 +01:00
|
|
|
} else {
|
2015-11-06 18:22:31 +00:00
|
|
|
wherep = RepAppl(Deref(*wherep)) + 1;
|
2005-10-18 18:04:43 +01:00
|
|
|
}
|
|
|
|
} while (TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static void PutAtt(Int pos, Term atts, Term att USES_REGS) {
|
2014-01-19 21:15:05 +00:00
|
|
|
if (IsVarTerm(att) && VarOfTerm(att) > HR && VarOfTerm(att) < LCL0) {
|
2005-09-09 18:24:39 +01:00
|
|
|
/* globalise locals */
|
|
|
|
Term tnew = MkVarTerm();
|
2013-04-17 02:04:53 +01:00
|
|
|
Bind_NonAtt(VarOfTerm(att), tnew);
|
2005-09-09 18:24:39 +01:00
|
|
|
att = tnew;
|
|
|
|
}
|
2015-11-06 18:22:31 +00:00
|
|
|
MaBind(RepAppl(atts) + pos, att);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Int BindAttVar(attvar_record *attv USES_REGS) {
|
2004-09-18 15:03:42 +01:00
|
|
|
if (IsVarTerm(attv->Done) && IsUnboundVar(&attv->Done)) {
|
2003-02-14 10:52:00 +00:00
|
|
|
/* make sure we are not trying to bind a variable against itself */
|
|
|
|
if (!IsVarTerm(attv->Value)) {
|
2011-03-18 19:34:58 +00:00
|
|
|
Bind_Global_NonAtt(&(attv->Done), attv->Value);
|
2003-02-14 10:52:00 +00:00
|
|
|
} else if (IsVarTerm(attv->Value)) {
|
|
|
|
Term t = Deref(attv->Value);
|
|
|
|
if (IsVarTerm(t)) {
|
2015-11-06 18:22:31 +00:00
|
|
|
if (IsAttachedTerm(t)) {
|
|
|
|
attvar_record *attv2 = RepAttVar(VarOfTerm(t));
|
|
|
|
if (attv2 < attv) {
|
|
|
|
Bind_Global_NonAtt(&(attv->Done), t);
|
|
|
|
} else {
|
|
|
|
Bind_Global_NonAtt(&(attv2->Done), AbsAttVar(attv));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Yap_Error(SYSTEM_ERROR_INTERNAL, (CELL) & (attv->Done),
|
|
|
|
"attvar was bound when unset");
|
|
|
|
return (FALSE);
|
|
|
|
}
|
2003-02-14 10:52:00 +00:00
|
|
|
} else {
|
2015-11-06 18:22:31 +00:00
|
|
|
Bind_Global_NonAtt(&(attv->Done), t);
|
2003-02-14 10:52:00 +00:00
|
|
|
}
|
|
|
|
}
|
2015-11-06 18:22:31 +00:00
|
|
|
return (TRUE);
|
2001-04-09 20:54:03 +01:00
|
|
|
} else {
|
2015-11-06 18:22:31 +00:00
|
|
|
Yap_Error(SYSTEM_ERROR_INTERNAL, (CELL) & (attv->Done),
|
|
|
|
"attvar was bound when set");
|
|
|
|
return (FALSE);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Int UnBindAttVar(attvar_record *attv) {
|
2009-09-09 23:59:25 +01:00
|
|
|
RESET_VARIABLE(&(attv->Value));
|
2015-11-06 18:22:31 +00:00
|
|
|
return (TRUE);
|
2009-09-09 23:59:25 +01:00
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Term GetAllAtts(attvar_record *attv) {
|
2005-09-09 18:24:39 +01:00
|
|
|
/* check if we are already there */
|
|
|
|
return attv->Atts;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Int p_put_att(USES_REGS1) {
|
2001-04-09 20:54:03 +01:00
|
|
|
/* receive a variable in ARG1 */
|
|
|
|
Term inp = Deref(ARG1);
|
|
|
|
/* if this is unbound, ok */
|
|
|
|
if (IsVarTerm(inp)) {
|
2005-09-09 18:24:39 +01:00
|
|
|
attvar_record *attv;
|
|
|
|
Atom modname = AtomOfTerm(Deref(ARG2));
|
|
|
|
UInt ar = IntegerOfTerm(Deref(ARG3));
|
|
|
|
Functor mfun;
|
|
|
|
Term tatts;
|
|
|
|
int new = FALSE;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2005-09-09 18:24:39 +01:00
|
|
|
if (IsAttachedTerm(inp)) {
|
2010-03-08 09:18:52 +00:00
|
|
|
attv = RepAttVar(VarOfTerm(inp));
|
2005-09-09 18:24:39 +01:00
|
|
|
} else {
|
2015-11-06 18:22:31 +00:00
|
|
|
while (!(attv = BuildNewAttVar(PASS_REGS1))) {
|
|
|
|
LOCAL_Error_Size = sizeof(attvar_record);
|
|
|
|
if (!Yap_gcl(LOCAL_Error_Size, 5, ENV, gc_P(P, CP))) {
|
|
|
|
Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2005-09-09 18:24:39 +01:00
|
|
|
new = TRUE;
|
2004-09-27 21:45:04 +01:00
|
|
|
}
|
2015-11-06 18:22:31 +00:00
|
|
|
mfun = Yap_MkFunctor(modname, ar);
|
|
|
|
if (IsVarTerm(tatts = SearchAttsForModule(attv->Atts, mfun))) {
|
|
|
|
while (!(tatts = BuildAttTerm(mfun, ar PASS_REGS))) {
|
|
|
|
if (!Yap_gcl(LOCAL_Error_Size, 5, ENV, gc_P(P, CP))) {
|
|
|
|
Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-09-27 21:45:04 +01:00
|
|
|
}
|
2012-08-14 22:07:26 +01:00
|
|
|
{
|
2015-11-06 18:22:31 +00:00
|
|
|
CELL *ptr = VarOfTerm(Deref(ARG1));
|
|
|
|
CELL d0 = AbsAttVar(attv);
|
|
|
|
Bind_NonAtt(ptr, d0);
|
2012-08-14 22:07:26 +01:00
|
|
|
}
|
2011-03-07 16:02:55 +00:00
|
|
|
AddNewModule(attv, tatts, new, TRUE PASS_REGS);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2011-03-07 16:02:55 +00:00
|
|
|
PutAtt(IntegerOfTerm(Deref(ARG4)), tatts, Deref(ARG5) PASS_REGS);
|
2004-09-27 21:45:04 +01:00
|
|
|
return TRUE;
|
2001-04-09 20:54:03 +01:00
|
|
|
} else {
|
2015-11-06 18:22:31 +00:00
|
|
|
Yap_Error(REPRESENTATION_ERROR_VARIABLE, inp,
|
|
|
|
"first argument of put_attributes/2");
|
2009-05-23 03:51:48 +01:00
|
|
|
return FALSE;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Int p_put_att_term(USES_REGS1) {
|
2005-10-31 18:12:51 +00:00
|
|
|
/* receive a variable in ARG1 */
|
|
|
|
Term inp = Deref(ARG1);
|
|
|
|
/* if this is unbound, ok */
|
|
|
|
if (IsVarTerm(inp)) {
|
|
|
|
attvar_record *attv;
|
|
|
|
|
|
|
|
if (IsAttachedTerm(inp)) {
|
2010-03-08 09:18:52 +00:00
|
|
|
attv = RepAttVar(VarOfTerm(inp));
|
2011-03-18 19:34:58 +00:00
|
|
|
MaBind(&(attv->Atts), Deref(ARG2));
|
2005-10-31 18:12:51 +00:00
|
|
|
} else {
|
2015-11-06 18:22:31 +00:00
|
|
|
while (!(attv = BuildNewAttVar(PASS_REGS1))) {
|
|
|
|
LOCAL_Error_Size = sizeof(attvar_record);
|
|
|
|
if (!Yap_gcl(LOCAL_Error_Size, 5, ENV, gc_P(P, CP))) {
|
|
|
|
Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
inp = Deref(ARG1);
|
2005-10-31 18:12:51 +00:00
|
|
|
}
|
2011-03-18 19:34:58 +00:00
|
|
|
Bind_NonAtt(VarOfTerm(inp), AbsAttVar(attv));
|
|
|
|
attv->Atts = Deref(ARG2);
|
2005-10-31 18:12:51 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
} else {
|
2015-11-06 18:22:31 +00:00
|
|
|
Yap_Error(REPRESENTATION_ERROR_VARIABLE, inp,
|
|
|
|
"first argument of put_att_term/2");
|
|
|
|
return (FALSE);
|
2005-10-31 18:12:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Int p_rm_att(USES_REGS1) {
|
2004-06-05 04:37:01 +01:00
|
|
|
/* receive a variable in ARG1 */
|
|
|
|
Term inp = Deref(ARG1);
|
|
|
|
/* if this is unbound, ok */
|
|
|
|
if (IsVarTerm(inp)) {
|
2005-09-09 18:24:39 +01:00
|
|
|
attvar_record *attv;
|
|
|
|
Atom modname = AtomOfTerm(Deref(ARG2));
|
|
|
|
UInt ar = IntegerOfTerm(Deref(ARG3));
|
|
|
|
Functor mfun;
|
|
|
|
Term tatts;
|
|
|
|
int new = FALSE;
|
2004-06-05 04:37:01 +01:00
|
|
|
|
2005-09-09 18:24:39 +01:00
|
|
|
if (IsAttachedTerm(inp)) {
|
2010-03-08 09:18:52 +00:00
|
|
|
attv = RepAttVar(VarOfTerm(inp));
|
2005-09-09 18:24:39 +01:00
|
|
|
} else {
|
2015-11-06 18:22:31 +00:00
|
|
|
while (!(attv = BuildNewAttVar(PASS_REGS1))) {
|
|
|
|
LOCAL_Error_Size = sizeof(attvar_record);
|
|
|
|
if (!Yap_gcl(LOCAL_Error_Size, 5, ENV, gc_P(P, CP))) {
|
|
|
|
Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-06-05 04:37:01 +01:00
|
|
|
}
|
2005-09-09 18:24:39 +01:00
|
|
|
new = TRUE;
|
2010-03-08 09:18:52 +00:00
|
|
|
Yap_unify(ARG1, AbsAttVar(attv));
|
2004-06-05 04:37:01 +01:00
|
|
|
}
|
2015-11-06 18:22:31 +00:00
|
|
|
mfun = Yap_MkFunctor(modname, ar);
|
|
|
|
if (IsVarTerm(tatts = SearchAttsForModule(attv->Atts, mfun))) {
|
2011-03-07 16:02:55 +00:00
|
|
|
while (!(tatts = BuildAttTerm(mfun, ar PASS_REGS))) {
|
2015-11-06 18:22:31 +00:00
|
|
|
if (!Yap_gcl(LOCAL_Error_Size, 4, ENV, gc_P(P, CP))) {
|
|
|
|
Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-09-27 21:45:04 +01:00
|
|
|
}
|
2015-11-06 18:22:31 +00:00
|
|
|
AddNewModule(attv, tatts, new, FALSE PASS_REGS);
|
2005-09-09 18:24:39 +01:00
|
|
|
} else {
|
2011-03-07 16:02:55 +00:00
|
|
|
PutAtt(IntegerOfTerm(Deref(ARG4)), tatts, TermVoidAtt PASS_REGS);
|
2004-09-27 21:45:04 +01:00
|
|
|
}
|
|
|
|
return TRUE;
|
2004-06-05 04:37:01 +01:00
|
|
|
} else {
|
2015-11-06 18:22:31 +00:00
|
|
|
Yap_Error(REPRESENTATION_ERROR_VARIABLE, inp, "first argument of rm_att/2");
|
|
|
|
return (FALSE);
|
2004-06-05 04:37:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Int p_put_atts(USES_REGS1) {
|
2001-04-09 20:54:03 +01:00
|
|
|
/* receive a variable in ARG1 */
|
|
|
|
Term inp = Deref(ARG1);
|
2005-09-09 18:24:39 +01:00
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
/* if this is unbound, ok */
|
|
|
|
if (IsVarTerm(inp)) {
|
2005-09-09 18:24:39 +01:00
|
|
|
attvar_record *attv;
|
2010-03-30 12:45:32 +01:00
|
|
|
Term otatts;
|
2005-09-09 18:24:39 +01:00
|
|
|
Term tatts = Deref(ARG2);
|
|
|
|
Functor mfun = FunctorOfTerm(tatts);
|
|
|
|
int new = FALSE;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2005-09-09 18:24:39 +01:00
|
|
|
if (IsAttachedTerm(inp)) {
|
2010-03-08 09:18:52 +00:00
|
|
|
attv = RepAttVar(VarOfTerm(inp));
|
2005-09-09 18:24:39 +01:00
|
|
|
} else {
|
2015-11-06 18:22:31 +00:00
|
|
|
while (!(attv = BuildNewAttVar(PASS_REGS1))) {
|
|
|
|
LOCAL_Error_Size = sizeof(attvar_record);
|
|
|
|
if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, gc_P(P, CP))) {
|
|
|
|
Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2005-09-09 18:24:39 +01:00
|
|
|
new = TRUE;
|
2010-03-08 09:18:52 +00:00
|
|
|
Yap_unify(ARG1, AbsAttVar(attv));
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2015-11-06 18:22:31 +00:00
|
|
|
/* we may have a stack shift meanwhile!! */
|
2010-03-30 12:45:32 +01:00
|
|
|
tatts = Deref(ARG2);
|
2011-02-02 20:14:36 +00:00
|
|
|
if (IsVarTerm(tatts)) {
|
2015-11-06 18:22:31 +00:00
|
|
|
Yap_Error(INSTANTIATION_ERROR, tatts, "second argument of put_att/2");
|
2011-02-02 20:14:36 +00:00
|
|
|
return FALSE;
|
|
|
|
} else if (!IsApplTerm(tatts)) {
|
2015-11-06 18:22:31 +00:00
|
|
|
Yap_Error(TYPE_ERROR_COMPOUND, tatts, "second argument of put_att/2");
|
2011-02-02 20:14:36 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2015-11-06 18:22:31 +00:00
|
|
|
if (IsVarTerm(otatts = SearchAttsForModule(attv->Atts, mfun))) {
|
2011-03-07 16:02:55 +00:00
|
|
|
AddNewModule(attv, tatts, new, FALSE PASS_REGS);
|
2005-09-09 18:24:39 +01:00
|
|
|
} else {
|
2011-03-07 16:02:55 +00:00
|
|
|
ReplaceAtts(attv, otatts, tatts PASS_REGS);
|
2005-09-09 18:24:39 +01:00
|
|
|
}
|
|
|
|
return TRUE;
|
2001-04-09 20:54:03 +01:00
|
|
|
} else {
|
2015-11-06 18:22:31 +00:00
|
|
|
Yap_Error(REPRESENTATION_ERROR_VARIABLE, inp,
|
|
|
|
"first argument of put_att/2");
|
2005-09-09 18:24:39 +01:00
|
|
|
return FALSE;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Int p_del_atts(USES_REGS1) {
|
2005-10-18 18:04:43 +01:00
|
|
|
/* receive a variable in ARG1 */
|
|
|
|
Term inp = Deref(ARG1);
|
|
|
|
Term otatts;
|
|
|
|
|
|
|
|
/* if this is unbound, ok */
|
|
|
|
if (IsVarTerm(inp)) {
|
|
|
|
attvar_record *attv;
|
|
|
|
Term tatts = Deref(ARG2);
|
|
|
|
Functor mfun = FunctorOfTerm(tatts);
|
|
|
|
|
|
|
|
if (IsAttachedTerm(inp)) {
|
2010-03-08 09:18:52 +00:00
|
|
|
attv = RepAttVar(VarOfTerm(inp));
|
2005-10-18 18:04:43 +01:00
|
|
|
} else {
|
|
|
|
return TRUE;
|
|
|
|
}
|
2015-11-06 18:22:31 +00:00
|
|
|
if (IsVarTerm(otatts = SearchAttsForModule(attv->Atts, mfun))) {
|
2005-10-18 18:04:43 +01:00
|
|
|
return TRUE;
|
|
|
|
} else {
|
2011-03-07 16:02:55 +00:00
|
|
|
DelAtts(attv, otatts PASS_REGS);
|
2005-10-18 18:04:43 +01:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
} else {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Int p_del_all_atts(USES_REGS1) {
|
2010-03-03 19:08:17 +00:00
|
|
|
/* receive a variable in ARG1 */
|
|
|
|
Term inp = Deref(ARG1);
|
|
|
|
|
|
|
|
/* if this is unbound, ok */
|
|
|
|
if (IsVarTerm(inp) && IsAttachedTerm(inp)) {
|
|
|
|
attvar_record *attv;
|
2015-11-06 18:22:31 +00:00
|
|
|
|
2010-03-08 09:18:52 +00:00
|
|
|
attv = RepAttVar(VarOfTerm(inp));
|
2011-03-07 16:02:55 +00:00
|
|
|
DelAllAtts(attv PASS_REGS);
|
2015-11-06 18:22:31 +00:00
|
|
|
}
|
2010-03-03 19:08:17 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Int p_get_att(USES_REGS1) {
|
2001-04-09 20:54:03 +01:00
|
|
|
/* receive a variable in ARG1 */
|
2005-09-09 18:24:39 +01:00
|
|
|
Term inp = Deref(ARG1);
|
2001-04-09 20:54:03 +01:00
|
|
|
/* if this is unbound, ok */
|
|
|
|
if (IsVarTerm(inp)) {
|
2005-09-09 18:24:39 +01:00
|
|
|
Atom modname = AtomOfTerm(Deref(ARG2));
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
if (IsAttachedTerm(inp)) {
|
2005-09-09 18:24:39 +01:00
|
|
|
attvar_record *attv;
|
|
|
|
Term tout, tatts;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2010-03-08 09:18:52 +00:00
|
|
|
attv = RepAttVar(VarOfTerm(inp));
|
2015-11-06 18:22:31 +00:00
|
|
|
if (IsVarTerm(tatts = SearchAttsForModuleName(attv->Atts, modname)))
|
|
|
|
return FALSE;
|
|
|
|
tout = ArgOfTerm(IntegerOfTerm(Deref(ARG3)), tatts);
|
|
|
|
if (tout == TermVoidAtt)
|
|
|
|
return FALSE;
|
|
|
|
return Yap_unify(tout, ARG4);
|
2005-09-09 18:24:39 +01:00
|
|
|
} else {
|
|
|
|
/* Yap_Error(INSTANTIATION_ERROR,inp,"get_att/2"); */
|
|
|
|
return FALSE;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
} else {
|
2015-11-06 18:22:31 +00:00
|
|
|
Yap_Error(REPRESENTATION_ERROR_VARIABLE, inp,
|
|
|
|
"first argument of get_att/2");
|
|
|
|
return (FALSE);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Int p_free_att(USES_REGS1) {
|
2001-04-09 20:54:03 +01:00
|
|
|
/* receive a variable in ARG1 */
|
2005-09-09 18:24:39 +01:00
|
|
|
Term inp = Deref(ARG1);
|
2001-04-09 20:54:03 +01:00
|
|
|
/* if this is unbound, ok */
|
|
|
|
if (IsVarTerm(inp)) {
|
2005-09-09 18:24:39 +01:00
|
|
|
Atom modname = AtomOfTerm(Deref(ARG2));
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
if (IsAttachedTerm(inp)) {
|
2005-09-09 18:24:39 +01:00
|
|
|
attvar_record *attv;
|
|
|
|
Term tout, tatts;
|
|
|
|
|
2010-03-08 09:18:52 +00:00
|
|
|
attv = RepAttVar(VarOfTerm(inp));
|
2015-11-06 18:22:31 +00:00
|
|
|
if (IsVarTerm(tatts = SearchAttsForModuleName(attv->Atts, modname)))
|
|
|
|
return TRUE;
|
|
|
|
tout = ArgOfTerm(IntegerOfTerm(Deref(ARG3)), tatts);
|
2006-01-07 02:12:32 +00:00
|
|
|
return (tout == TermVoidAtt);
|
2005-09-09 18:24:39 +01:00
|
|
|
} else {
|
|
|
|
/* Yap_Error(INSTANTIATION_ERROR,inp,"get_att/2"); */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
} else {
|
2015-11-06 18:22:31 +00:00
|
|
|
Yap_Error(REPRESENTATION_ERROR_VARIABLE, inp,
|
|
|
|
"first argument of free_att/2");
|
|
|
|
return (FALSE);
|
2005-09-09 18:24:39 +01:00
|
|
|
}
|
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Int p_get_atts(USES_REGS1) {
|
2005-09-09 18:24:39 +01:00
|
|
|
/* receive a variable in ARG1 */
|
|
|
|
Term inp = Deref(ARG1);
|
|
|
|
/* if this is unbound, ok */
|
|
|
|
if (IsVarTerm(inp)) {
|
|
|
|
if (IsAttachedTerm(inp)) {
|
|
|
|
attvar_record *attv;
|
|
|
|
Term tatts;
|
|
|
|
Term access = Deref(ARG2);
|
|
|
|
Functor mfun = FunctorOfTerm(access);
|
|
|
|
UInt ar, i;
|
|
|
|
CELL *old, *new;
|
|
|
|
|
2010-03-08 09:18:52 +00:00
|
|
|
attv = RepAttVar(VarOfTerm(inp));
|
2015-11-06 18:22:31 +00:00
|
|
|
if (IsVarTerm(tatts = SearchAttsForModule(attv->Atts, mfun)))
|
|
|
|
return FALSE;
|
|
|
|
|
2005-09-09 18:24:39 +01:00
|
|
|
ar = ArityOfFunctor(mfun);
|
2015-11-06 18:22:31 +00:00
|
|
|
new = RepAppl(access) + 2;
|
|
|
|
old = RepAppl(tatts) + 2;
|
|
|
|
for (i = 1; i < ar; i++, new ++, old++) {
|
|
|
|
if (*new != TermFreeTerm) {
|
|
|
|
if (*old == TermVoidAtt && *new != TermVoidAtt)
|
|
|
|
return FALSE;
|
|
|
|
if (*new == TermVoidAtt &&*old != TermVoidAtt)
|
|
|
|
return FALSE;
|
|
|
|
if (!Yap_unify(*new, *old))
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2005-09-09 18:24:39 +01:00
|
|
|
return TRUE;
|
|
|
|
} else {
|
|
|
|
/* Yap_Error(INSTANTIATION_ERROR,inp,"get_att/2"); */
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
} else {
|
2015-11-06 18:22:31 +00:00
|
|
|
return (FALSE);
|
2005-09-09 18:24:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Int p_has_atts(USES_REGS1) {
|
2005-09-09 18:24:39 +01:00
|
|
|
/* receive a variable in ARG1 */
|
|
|
|
Term inp = Deref(ARG1);
|
|
|
|
/* if this is unbound, ok */
|
|
|
|
if (IsVarTerm(inp)) {
|
|
|
|
if (IsAttachedTerm(inp)) {
|
|
|
|
attvar_record *attv;
|
|
|
|
Term tatts;
|
|
|
|
Term access = Deref(ARG2);
|
|
|
|
Functor mfun = FunctorOfTerm(access);
|
|
|
|
|
2010-03-08 09:18:52 +00:00
|
|
|
attv = RepAttVar(VarOfTerm(inp));
|
2015-11-06 18:22:31 +00:00
|
|
|
return !IsVarTerm(tatts = SearchAttsForModule(attv->Atts, mfun));
|
2005-09-09 18:24:39 +01:00
|
|
|
} else {
|
|
|
|
/* Yap_Error(INSTANTIATION_ERROR,inp,"get_att/2"); */
|
|
|
|
return FALSE;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
} else {
|
2015-11-06 18:22:31 +00:00
|
|
|
Yap_Error(REPRESENTATION_ERROR_VARIABLE, inp,
|
|
|
|
"first argument of has_atts/2");
|
|
|
|
return (FALSE);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Int p_bind_attvar(USES_REGS1) {
|
2001-04-09 20:54:03 +01:00
|
|
|
/* receive a variable in ARG1 */
|
2015-11-06 18:22:31 +00:00
|
|
|
Term inp = Deref(ARG1);
|
2001-04-09 20:54:03 +01:00
|
|
|
/* if this is unbound, ok */
|
|
|
|
if (IsVarTerm(inp)) {
|
|
|
|
if (IsAttachedTerm(inp)) {
|
2010-03-08 09:18:52 +00:00
|
|
|
attvar_record *attv = RepAttVar(VarOfTerm(inp));
|
2015-11-06 18:22:31 +00:00
|
|
|
return (BindAttVar(attv PASS_REGS));
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2015-11-06 18:22:31 +00:00
|
|
|
return (true);
|
2001-04-09 20:54:03 +01:00
|
|
|
} else {
|
2015-11-06 18:22:31 +00:00
|
|
|
Yap_Error(REPRESENTATION_ERROR_VARIABLE, inp,
|
|
|
|
"first argument of bind_attvar/2");
|
|
|
|
return (false);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Int p_unbind_attvar(USES_REGS1) {
|
2009-09-09 23:59:25 +01:00
|
|
|
/* receive a variable in ARG1 */
|
2015-11-06 18:22:31 +00:00
|
|
|
Term inp = Deref(ARG1);
|
2009-09-09 23:59:25 +01:00
|
|
|
/* if this is unbound, ok */
|
|
|
|
if (IsVarTerm(inp)) {
|
|
|
|
if (IsAttachedTerm(inp)) {
|
2010-03-08 09:18:52 +00:00
|
|
|
attvar_record *attv = RepAttVar(VarOfTerm(inp));
|
2015-11-06 18:22:31 +00:00
|
|
|
return (UnBindAttVar(attv));
|
2009-09-09 23:59:25 +01:00
|
|
|
}
|
2015-11-06 18:22:31 +00:00
|
|
|
return (TRUE);
|
2009-09-09 23:59:25 +01:00
|
|
|
} else {
|
2015-11-06 18:22:31 +00:00
|
|
|
Yap_Error(REPRESENTATION_ERROR_VARIABLE, inp,
|
|
|
|
"first argument of bind_attvar/2");
|
|
|
|
return (FALSE);
|
2009-09-09 23:59:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Int p_get_all_atts(USES_REGS1) {
|
2001-04-09 20:54:03 +01:00
|
|
|
/* receive a variable in ARG1 */
|
|
|
|
Term inp = Deref(ARG1);
|
|
|
|
/* if this is unbound, ok */
|
|
|
|
if (IsVarTerm(inp)) {
|
|
|
|
if (IsAttachedTerm(inp)) {
|
2010-03-08 09:18:52 +00:00
|
|
|
attvar_record *attv = RepAttVar(VarOfTerm(inp));
|
2015-11-06 18:22:31 +00:00
|
|
|
return Yap_unify(ARG2, GetAllAtts(attv));
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2004-12-16 05:57:32 +00:00
|
|
|
return TRUE;
|
2001-04-09 20:54:03 +01:00
|
|
|
} else {
|
2015-11-06 18:22:31 +00:00
|
|
|
Yap_Error(REPRESENTATION_ERROR_VARIABLE, inp,
|
|
|
|
"first argument of get_all_atts/2");
|
2004-12-16 05:57:32 +00:00
|
|
|
return FALSE;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static int ActiveAtt(Term tatt, UInt ar) {
|
|
|
|
CELL *cp = RepAppl(tatt) + 1;
|
2005-10-18 18:04:43 +01:00
|
|
|
UInt i;
|
|
|
|
|
|
|
|
for (i = 1; i < ar; i++) {
|
2006-01-07 02:12:32 +00:00
|
|
|
if (cp[i] != TermVoidAtt)
|
2005-10-18 18:04:43 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Int p_modules_with_atts(USES_REGS1) {
|
2005-09-09 18:24:39 +01:00
|
|
|
/* receive a variable in ARG1 */
|
|
|
|
Term inp = Deref(ARG1);
|
|
|
|
/* if this is unbound, ok */
|
|
|
|
if (IsVarTerm(inp)) {
|
|
|
|
if (IsAttachedTerm(inp)) {
|
2010-03-08 09:18:52 +00:00
|
|
|
attvar_record *attv = RepAttVar(VarOfTerm(inp));
|
2014-01-19 21:15:05 +00:00
|
|
|
CELL *h0 = HR;
|
2005-09-09 18:24:39 +01:00
|
|
|
Term tatt;
|
|
|
|
|
|
|
|
if (IsVarTerm(tatt = attv->Atts))
|
2015-11-06 18:22:31 +00:00
|
|
|
return Yap_unify(ARG2, TermNil);
|
2005-09-09 18:24:39 +01:00
|
|
|
while (!IsVarTerm(tatt)) {
|
2015-11-06 18:22:31 +00:00
|
|
|
Functor f = FunctorOfTerm(tatt);
|
|
|
|
if (HR != h0)
|
|
|
|
HR[-1] = AbsPair(HR);
|
|
|
|
if (ActiveAtt(tatt, ArityOfFunctor(f))) {
|
|
|
|
*HR = MkAtomTerm(NameOfFunctor(f));
|
|
|
|
HR += 2;
|
|
|
|
}
|
|
|
|
tatt = ArgOfTerm(1, tatt);
|
2005-09-09 18:24:39 +01:00
|
|
|
}
|
2014-01-19 21:15:05 +00:00
|
|
|
if (h0 != HR) {
|
2015-11-06 18:22:31 +00:00
|
|
|
HR[-1] = TermNil;
|
|
|
|
return Yap_unify(ARG2, AbsPair(h0));
|
2005-10-18 18:04:43 +01:00
|
|
|
}
|
2005-09-09 18:24:39 +01:00
|
|
|
}
|
2015-11-06 18:22:31 +00:00
|
|
|
return Yap_unify(ARG2, TermNil);
|
2005-10-18 18:04:43 +01:00
|
|
|
} else {
|
2015-11-06 18:22:31 +00:00
|
|
|
Yap_Error(REPRESENTATION_ERROR_VARIABLE, inp,
|
|
|
|
"first argument of modules_with_attributes/2");
|
2005-10-18 18:04:43 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Int p_swi_all_atts(USES_REGS1) {
|
2005-10-18 18:04:43 +01:00
|
|
|
/* receive a variable in ARG1 */
|
|
|
|
Term inp = Deref(ARG1);
|
2008-12-24 09:04:44 +00:00
|
|
|
Functor attf = FunctorAtt1;
|
2005-10-18 18:04:43 +01:00
|
|
|
|
|
|
|
/* if this is unbound, ok */
|
|
|
|
if (IsVarTerm(inp)) {
|
|
|
|
if (IsAttachedTerm(inp)) {
|
2010-03-08 09:18:52 +00:00
|
|
|
attvar_record *attv = RepAttVar(VarOfTerm(inp));
|
2014-01-19 21:15:05 +00:00
|
|
|
CELL *h0 = HR;
|
2005-10-18 18:04:43 +01:00
|
|
|
Term tatt;
|
|
|
|
|
|
|
|
if (IsVarTerm(tatt = attv->Atts))
|
2015-11-06 18:22:31 +00:00
|
|
|
return Yap_unify(ARG2, TermNil);
|
2005-10-18 18:04:43 +01:00
|
|
|
while (!IsVarTerm(tatt)) {
|
2015-11-06 18:22:31 +00:00
|
|
|
Functor f = FunctorOfTerm(tatt);
|
|
|
|
UInt ar = ArityOfFunctor(f);
|
|
|
|
|
|
|
|
if (HR != h0)
|
|
|
|
HR[-1] = AbsAppl(HR);
|
|
|
|
HR[0] = (CELL)attf;
|
|
|
|
HR[1] = MkAtomTerm(NameOfFunctor(f));
|
|
|
|
/* SWI */
|
|
|
|
if (ar == 2)
|
|
|
|
HR[2] = ArgOfTerm(2, tatt);
|
|
|
|
else
|
|
|
|
HR[2] = tatt;
|
|
|
|
HR += 4;
|
|
|
|
HR[-1] = AbsAppl(HR);
|
|
|
|
tatt = ArgOfTerm(1, tatt);
|
2005-10-18 18:04:43 +01:00
|
|
|
}
|
2014-01-19 21:15:05 +00:00
|
|
|
if (h0 != HR) {
|
2015-11-06 18:22:31 +00:00
|
|
|
HR[-1] = TermNil;
|
|
|
|
return Yap_unify(ARG2, AbsAppl(h0));
|
2005-10-18 18:04:43 +01:00
|
|
|
}
|
|
|
|
}
|
2015-11-06 18:22:31 +00:00
|
|
|
return Yap_unify(ARG2, TermNil);
|
2005-09-09 18:24:39 +01:00
|
|
|
} else {
|
2015-11-06 18:22:31 +00:00
|
|
|
Yap_Error(REPRESENTATION_ERROR_VARIABLE, inp,
|
|
|
|
"first argument of get_all_swi_atts/2");
|
2005-09-09 18:24:39 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Term AllAttVars(USES_REGS1) {
|
2010-03-10 14:06:07 +00:00
|
|
|
CELL *pt = H0;
|
2014-01-19 21:15:05 +00:00
|
|
|
CELL *myH = HR;
|
2015-11-06 18:22:31 +00:00
|
|
|
|
2011-09-20 09:53:06 +01:00
|
|
|
while (pt < myH) {
|
2015-11-06 18:22:31 +00:00
|
|
|
switch (*pt) {
|
|
|
|
case (CELL) FunctorAttVar:
|
|
|
|
if (IsUnboundVar(pt + 1)) {
|
|
|
|
if (ASP - myH < 1024) {
|
|
|
|
LOCAL_Error_Size = (ASP - HR) * sizeof(CELL);
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
if (myH != HR) {
|
|
|
|
myH[-1] = AbsPair(myH);
|
|
|
|
}
|
|
|
|
myH[0] = AbsAttVar((attvar_record *)pt);
|
|
|
|
myH += 2;
|
2010-03-10 14:06:07 +00:00
|
|
|
}
|
2015-11-06 18:22:31 +00:00
|
|
|
pt += (1 + ATT_RECORD_ARITY);
|
2010-03-10 14:06:07 +00:00
|
|
|
break;
|
2015-11-06 18:22:31 +00:00
|
|
|
case (CELL) FunctorDouble:
|
|
|
|
#if SIZEOF_DOUBLE == 2 * SIZEOF_INT_P
|
2010-03-10 14:06:07 +00:00
|
|
|
pt += 4;
|
|
|
|
#else
|
|
|
|
pt += 3;
|
|
|
|
#endif
|
|
|
|
break;
|
2015-11-06 18:22:31 +00:00
|
|
|
case (CELL) FunctorString:
|
|
|
|
pt += 3 + pt[1];
|
2013-12-02 14:49:41 +00:00
|
|
|
break;
|
2015-11-06 18:22:31 +00:00
|
|
|
case (CELL) FunctorBigInt: {
|
|
|
|
Int sz = 3 +
|
2015-11-09 11:25:55 +00:00
|
|
|
(sizeof(MP_INT) +
|
|
|
|
(((MP_INT *)(pt + 2))->_mp_alloc * sizeof(mp_limb_t))) /
|
|
|
|
sizeof(CELL);
|
2015-11-06 18:22:31 +00:00
|
|
|
pt += sz;
|
|
|
|
} break;
|
|
|
|
case (CELL) FunctorLongInt:
|
2010-03-10 14:06:07 +00:00
|
|
|
pt += 3;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pt++;
|
|
|
|
}
|
|
|
|
}
|
2014-01-19 21:15:05 +00:00
|
|
|
if (myH != HR) {
|
|
|
|
Term out = AbsPair(HR);
|
2010-03-10 14:06:07 +00:00
|
|
|
myH[-1] = TermNil;
|
2014-01-19 21:15:05 +00:00
|
|
|
HR = myH;
|
2010-03-10 14:06:07 +00:00
|
|
|
return out;
|
|
|
|
} else {
|
|
|
|
return TermNil;
|
|
|
|
}
|
|
|
|
}
|
2015-11-06 18:22:31 +00:00
|
|
|
|
|
|
|
static Int p_all_attvars(USES_REGS1) {
|
2010-03-10 14:06:07 +00:00
|
|
|
do {
|
|
|
|
Term out;
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
if (!(out = AllAttVars(PASS_REGS1))) {
|
|
|
|
if (!Yap_gcl(LOCAL_Error_Size, 1, ENV, gc_P(P, CP))) {
|
|
|
|
Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2010-03-10 14:06:07 +00:00
|
|
|
} else {
|
2015-11-06 18:22:31 +00:00
|
|
|
return Yap_unify(ARG1, out);
|
2010-03-10 14:06:07 +00:00
|
|
|
}
|
|
|
|
} while (TRUE);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
/** @pred attvar( _-Var_)
|
2015-01-04 23:58:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
Succeed if _Var_ is an attributed variable.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
2015-11-06 18:22:31 +00:00
|
|
|
static Int p_is_attvar(USES_REGS1) {
|
2001-04-09 20:54:03 +01:00
|
|
|
Term t = Deref(ARG1);
|
2015-11-06 18:22:31 +00:00
|
|
|
return (IsVarTerm(t) && IsAttVar(VarOfTerm(t)));
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2002-07-17 21:25:30 +01:00
|
|
|
/* check if we are not redoing effort */
|
2015-11-06 18:22:31 +00:00
|
|
|
static Int p_attvar_bound(USES_REGS1) {
|
2002-07-17 21:25:30 +01:00
|
|
|
Term t = Deref(ARG1);
|
2015-11-06 18:22:31 +00:00
|
|
|
return IsVarTerm(t) && IsAttachedTerm(t) &&
|
2015-11-09 11:25:55 +00:00
|
|
|
!IsUnboundVar(&(RepAttVar(VarOfTerm(t))->Done));
|
2002-07-17 21:25:30 +01:00
|
|
|
}
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Int p_void_term(USES_REGS1) { return Yap_unify(ARG1, TermVoidAtt); }
|
2006-01-17 14:10:42 +00:00
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Int p_free_term(USES_REGS1) { return Yap_unify(ARG1, TermFreeTerm); }
|
2006-01-17 14:10:42 +00:00
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Int p_fast_unify(USES_REGS1) {
|
2008-11-14 14:50:54 +00:00
|
|
|
/*
|
|
|
|
Case we want to unify two variables, but we do not
|
|
|
|
think there is a point in waking them up
|
|
|
|
*/
|
|
|
|
Term t1, t2;
|
|
|
|
CELL *a, *b;
|
|
|
|
if (!IsVarTerm(t1 = Deref(ARG1)))
|
|
|
|
return FALSE;
|
|
|
|
if (!IsVarTerm(t2 = Deref(ARG2)))
|
|
|
|
return FALSE;
|
|
|
|
a = VarOfTerm(t1);
|
|
|
|
b = VarOfTerm(t2);
|
2015-11-06 18:22:31 +00:00
|
|
|
if (a > b) {
|
|
|
|
Bind_Global_NonAtt(a, t2);
|
|
|
|
} else if ((a) < (b)) {
|
|
|
|
Bind_Global_NonAtt(b, t1);
|
2008-11-14 14:50:54 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-06-23 18:24:20 +01:00
|
|
|
#else
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Int p_all_attvars(USES_REGS1) { return FALSE; }
|
2004-06-23 18:24:20 +01:00
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Int p_is_attvar(USES_REGS1) { return FALSE; }
|
2004-06-23 18:24:20 +01:00
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
static Int p_attvar_bound(USES_REGS1) { return FALSE; }
|
2004-06-23 18:24:20 +01:00
|
|
|
|
|
|
|
#endif /* COROUTINING */
|
|
|
|
|
2015-11-06 18:22:31 +00:00
|
|
|
void Yap_InitAttVarPreds(void) {
|
2011-03-07 16:02:55 +00:00
|
|
|
CACHE_REGS
|
2015-11-09 11:25:55 +00:00
|
|
|
Term OldCurrentModule = CurrentModule;
|
2004-06-23 18:24:20 +01:00
|
|
|
CurrentModule = ATTRIBUTES_MODULE;
|
|
|
|
#ifdef COROUTINING
|
2011-05-25 16:40:36 +01:00
|
|
|
GLOBAL_attas[attvars_ext].bind_op = WakeAttVar;
|
|
|
|
GLOBAL_attas[attvars_ext].copy_term_op = CopyAttVar;
|
|
|
|
GLOBAL_attas[attvars_ext].to_term_op = AttVarToTerm;
|
|
|
|
GLOBAL_attas[attvars_ext].term_to_op = TermToAttVar;
|
|
|
|
GLOBAL_attas[attvars_ext].mark_op = mark_attvar;
|
2005-09-09 18:24:39 +01:00
|
|
|
Yap_InitCPred("get_att", 4, p_get_att, SafePredFlag);
|
|
|
|
Yap_InitCPred("get_module_atts", 2, p_get_atts, SafePredFlag);
|
|
|
|
Yap_InitCPred("has_module_atts", 2, p_has_atts, SafePredFlag);
|
2002-11-18 18:18:05 +00:00
|
|
|
Yap_InitCPred("get_all_atts", 2, p_get_all_atts, SafePredFlag);
|
2005-10-18 18:04:43 +01:00
|
|
|
Yap_InitCPred("get_all_swi_atts", 2, p_swi_all_atts, SafePredFlag);
|
2005-09-09 18:24:39 +01:00
|
|
|
Yap_InitCPred("free_att", 3, p_free_att, SafePredFlag);
|
|
|
|
Yap_InitCPred("put_att", 5, p_put_att, 0);
|
2009-02-10 14:56:43 +00:00
|
|
|
Yap_InitCPred("put_att_term", 2, p_put_att_term, 0);
|
2005-09-09 18:24:39 +01:00
|
|
|
Yap_InitCPred("put_module_atts", 2, p_put_atts, 0);
|
2005-10-18 18:04:43 +01:00
|
|
|
Yap_InitCPred("del_all_module_atts", 2, p_del_atts, 0);
|
2010-03-03 19:08:17 +00:00
|
|
|
Yap_InitCPred("del_all_atts", 1, p_del_all_atts, 0);
|
2005-09-09 18:24:39 +01:00
|
|
|
Yap_InitCPred("rm_att", 4, p_rm_att, 0);
|
2002-11-18 18:18:05 +00:00
|
|
|
Yap_InitCPred("bind_attvar", 1, p_bind_attvar, SafePredFlag);
|
2009-09-09 23:59:25 +01:00
|
|
|
Yap_InitCPred("unbind_attvar", 1, p_unbind_attvar, SafePredFlag);
|
2015-11-06 18:22:31 +00:00
|
|
|
Yap_InitCPred("modules_with_attributes", 2, p_modules_with_atts,
|
|
|
|
SafePredFlag);
|
2005-09-09 18:24:39 +01:00
|
|
|
Yap_InitCPred("void_term", 1, p_void_term, SafePredFlag);
|
|
|
|
Yap_InitCPred("free_term", 1, p_free_term, SafePredFlag);
|
2008-11-14 14:50:54 +00:00
|
|
|
Yap_InitCPred("fast_unify_attributed", 2, p_fast_unify, 0);
|
2004-06-23 18:24:20 +01:00
|
|
|
#endif /* COROUTINING */
|
2005-08-23 22:27:39 +01:00
|
|
|
Yap_InitCPred("all_attvars", 1, p_all_attvars, 0);
|
2004-05-13 21:54:58 +01:00
|
|
|
CurrentModule = OldCurrentModule;
|
2015-11-06 18:22:31 +00:00
|
|
|
Yap_InitCPred("attvar", 1, p_is_attvar, SafePredFlag | TestPredFlag);
|
|
|
|
Yap_InitCPred("$att_bound", 1, p_attvar_bound, SafePredFlag | TestPredFlag);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2015-01-04 23:58:23 +00:00
|
|
|
/** @} */
|