YAP 7.1.0
attvar.h
1/*************************************************************************
2* *
3* YAP Prolog *
4* *
5* Yap Prolog was developed at NCCUP - Universidade do Porto *
6* *
7* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
8* *
9**************************************************************************
10* *
11* File: corout.c *
12* Last rev: *
13* mods: *
14* comments: Co-routining from within YAP *
15* *
16*************************************************************************/
17#ifdef SCCS
18static char SccsId[]="%W% %G%";
19#endif
20
21#ifndef ATTVAR_H
22
23#define ATTVAR_H 1
24
25#include <TermExt.h>
26
44/*
45 attvar_entry is just a Prolog structure such that the first argument is
46 a pointer to the next args
47*/
48
49typedef struct attvar_struct {
50 Functor AttFunc; /* functor for attvar */
51 Term Done; /* if unbound suspension active, if bound terminated */
52 Term Future; /* value the variable will take */
53 Term Atts; /* actual data */
55
56#define ATT_RECORD_ARITY 3
57
58 #define MAX_EMPTY_WAKEUPS 16
59
60/*
61 attvar_entry is just a Prolog structure such that the first argument is
62 a pointer to the next args
63*/
64
65
66INLINE_ONLY bool IsAttachFunc(Functor);
67
68INLINE_ONLY bool IsAttachFunc(Functor f) { return (Int)(FALSE); }
69
70#define IsAttachedTerm(t) __IsAttachedTerm(t PASS_REGS)
71
72INLINE_ONLY bool __IsAttachedTerm(Term USES_REGS);
73
74INLINE_ONLY bool __IsAttachedTerm(Term t USES_REGS) {
75 return (IsVarTerm(t) &&
76 IsAttVar(VarOfTerm(t)));
77}
78
79INLINE_ONLY bool GlobalIsAttachedTerm(Term);
80
81INLINE_ONLY bool GlobalIsAttachedTerm(Term t) {
82 return (IsVarTerm(t) &&
83 GlobalIsAttVar(VarOfTerm(t)));
84}
85
86#define SafeIsAttachedTerm(t) __SafeIsAttachedTerm((t)PASS_REGS)
87
88INLINE_ONLY bool __SafeIsAttachedTerm(Term USES_REGS);
89
90INLINE_ONLY bool __SafeIsAttachedTerm(Term t USES_REGS) {
91 return IsVarTerm(t) && IsAttVar(VarOfTerm(t));
92}
93
94static inline Term
95AbsAttVar(attvar_record *attvar_ptr) {
96 return attvar_ptr->Done;
97}
98
99static inline attvar_record *
100RepAttVar(Term *var_ptr) {
101 return (attvar_record *)(var_ptr-1);
102}
103
104extern void AddToQueue(attvar_record *attv USES_REGS);
105
106#define TermVoidAtt TermFoundVar
107
108#endif
109
Attributed variales are controlled by the attvar_record.
Definition: attvar.h:49