YAP 7.1.0
yapa.hh
Go to the documentation of this file.
1
4
5#ifndef YAPA_HH
6#define YAPA_HH 1
7
32enum PropTag {
34 PRED_TAG = PEProp, // 0x0000,
36 DB_TAG = DBProperty, // 0x8000,
38 FUNCTOR_TAG = FunctorProperty, // 0xBB00,
39 // SPARSE_FUNCTOR_TAG = 0xFFDF,
41 ARITHMETIC_PROPERTY_TAG = ExpProperty, // 0xFFE0,
43 TRANSLATION_TAG = TranslationProperty, // 0xFFF4,
45 HOLD_TAG = HoldProperty, // 0xFFF6
47 MUTEX_TAG = MutexProperty, // 0xFFF6,
49 ARRAY_TAG = ArrayProperty, // 0xFFF7,
51 MODULE_TAG = ModProperty, // 0xFFFA,
53 BLACKBOARD_TAG = BBProperty, // 0xFFFB,
55 VALUE_TAG = ValProperty, // 0xFFFC,
57 GLOBAL_VAR_TAG = GlobalProperty, // 0xFFFD
59 BLOB_TAG = BlobProperty, // 0xFFFE,
61 OPERATOR_TAG = OpProperty, // 0xFFFF,
62};
63
71class X_API YAPAtom {
72 friend class YAPEngine;
73 friend class YAPModuleProp;
74 friend class YAPPredicate;
75 friend class YAPFunctor;
76 friend class YAPAtomTerm;
77 friend class YAProp;
78 friend class YAPModule;
79 friend class YAPQuery;
80 Atom a;
82 YAPAtom( Atom at ) { a = at; }
83public:
85 YAPAtom( const char * s) { a = Yap_LookupAtom( s ); }
87 YAPAtom( const wchar_t * s) { CACHE_REGS a = UTF32ToAtom( s PASS_REGS ); }
89 //YAPAtom( const wchar_t * s) { a = Yap_LookupMaybeWideAtom( s ); }
91 YAPAtom( const char * s, size_t len) { a = Yap_LookupAtomWithLength( s, len ); }
93 const char *getName(void);
95 inline const char *text(void) { return getName(); } ;
97 Prop getProp( PropTag tag ) { return Yap_GetAProp( a , (PropFlags)tag ); };
99 Atom asAtom() { return a; };
100};
101
109class X_API YAPProp {
110 friend class YAPModuleProp;
111 friend class YAPFunctor;
113 YAPProp() { }
115 PropTag tag( Prop p ) { return (PropTag)(p->KindOfPE); }
116public:
119 virtual ~YAPProp() {};
120};
121
125class X_API YAPFunctor : public YAPProp {
126 friend class YAPApplTerm;
127 friend class YAPTerm;
128 friend class YAPPredicate;
129 friend class YAPQuery;
130 Functor f;
134 inline YAPFunctor(Functor ff) { f = ff; }
135
136public:
140 YAPFunctor(YAPAtom at, uintptr_t arity) { f = Yap_MkFunctor(at.a, arity); }
141
147 inline YAPFunctor(const char *s, uintptr_t arity, bool isutf8 = true) {
148 f = Yap_MkFunctor(Yap_LookupAtom(s), arity);
149 }
156 inline YAPFunctor(const wchar_t *s, uintptr_t arity) {
157 CACHE_REGS f = Yap_MkFunctor(UTF32ToAtom(s PASS_REGS), arity);
158 }
162 inline YAPAtom name() { return YAPAtom(NameOfFunctor(f)); };
163
167 inline arity_t arity() { return ArityOfFunctor(f); };
168
172 inline Functor fun() { return f; };
173};
174
175
176#endif /* YAPA_HH */
YAPModule A YAPModule describes a bare module, which in YAP is just a name.
Definition: yapdb.hh:46
YAPModuleProp A YAPModuleProp controls access to a module property.
Definition: yapdb.hh:65
Predicates.
Definition: yapdb.hh:83
Atom asAtom()
as Atom
Definition: yapa.hh:99
YAPAtom(const wchar_t *s)
construct new YAPAtom from UTF-8 string
Definition: yapa.hh:87
YAPAtom(const char *s, size_t len)
construct new YAPAtom from wide string
Definition: yapa.hh:91
arity_t arity()
Getter: extract arity of functor as an unsigned integer.
Definition: yapa.hh:167
Functor fun()
Getter: extract the C functor.
Definition: yapa.hh:172
YAPFunctor(YAPAtom at, uintptr_t arity)
Constructor: receives name as an atom, plus arity.
Definition: yapa.hh:140
const char * text(void)
get name of (other way)
Definition: yapa.hh:95
virtual ~YAPProp()
get name of property virtual YAPAtom name();
Definition: yapa.hh:119
YAPAtom(const char *s)
construct new YAPAtom from UTF-8 string
Definition: yapa.hh:85
YAPAtom name()
Getter: extract name of functor as an atom.
Definition: yapa.hh:162
YAPFunctor(const wchar_t *s, uintptr_t arity)
Constructor: receives name as a wide string plus arity.
Definition: yapa.hh:156
Prop getProp(PropTag tag)
get prop of type
Definition: yapa.hh:97
YAPFunctor(const char *s, uintptr_t arity, bool isutf8=true)
Constructor: receives name as a string plus arity.
Definition: yapa.hh:147
Atom A YAP data-base is a collection of atoms, where each atom has a name and a set of Properties.
Definition: yapa.hh:71
YAPFunctor represents Prolog functors Name/Arity.
Definition: yapa.hh:125
Prop A YAP Propery is ameta-class for everything one can in a atom.
Definition: yapa.hh:109
PropTag
Definition: yapa.hh:32
@ TRANSLATION_TAG
map the atom to an integer
Definition: yapa.hh:43
@ PRED_TAG
predicate
Definition: yapa.hh:34
@ BLACKBOARD_TAG
the original SICStus blackboard
Definition: yapa.hh:53
@ OPERATOR_TAG
Prolog operator,.
Definition: yapa.hh:61
@ ARRAY_TAG
A typed array, may be in-db or in-stack deped.
Definition: yapa.hh:49
@ MUTEX_TAG
named mutEX
Definition: yapa.hh:47
@ GLOBAL_VAR_TAG
Demoen's proposal for gkobal variables.
Definition: yapa.hh:57
@ ARITHMETIC_PROPERTY_TAG
arithmetic function
Definition: yapa.hh:41
@ HOLD_TAG
ensure the atom may not be garbafe colected
Definition: yapa.hh:45
@ MODULE_TAG
module
Definition: yapa.hh:51
@ FUNCTOR_TAG
generic functor, may include sub-properties
Definition: yapa.hh:38
@ VALUE_TAG
associate an atomic value with the atom
Definition: yapa.hh:55
@ DB_TAG
db key, may be associated with a functor
Definition: yapa.hh:36
@ BLOB_TAG
SWI-STYLE ATOM Extension.
Definition: yapa.hh:59
YAP Engine: takes care of the execution environment where we can go executing goals.
Definition: yapq.hh:317
Queries and engines.
Definition: yapq.hh:38
Compound Term.
Definition: yapt.hh:279
Atom Term Term Representation of an Atom.
Definition: yapt.hh:613
Generic Prolog Term.
Definition: yapt.hh:42