YAP 7.1.0
yapi.cpp
1
2extern "C" {
3
4
5#include "inline-only.h"
6#define _EXPORT_KERNEL 1
7}
8
9#include <vector>
10
11#include "yapi.hh"
12
13
14
15extern "C" {
16
17#if __ANDROID__
18#include "android/log.h"
19#endif
20
21#if YAP_PYTHON
22#include "Python.h"
23#endif
24
25#include "YapBlobs.h"
26#include "YapInterface.h"
27#include "iopreds.h"
28
29#include "YapInit.h"
30
31X_API extern char *Yap_TermToBuffer(Term t, int flags);
32
33X_API extern void YAP_UserCPredicate(const char *, YAP_UserCPred, arity_t arity);
34X_API extern void YAP_UserCPredicateWithArgs(const char *, YAP_UserCPred, arity_t,
35 YAP_Term);
36X_API extern void YAP_UserBackCPredicate(const char *, YAP_UserCPred, YAP_UserCPred,
37 YAP_Arity, YAP_Arity);
38
39#if YAP_PYTHON
40X_API bool do_init_python(void);
41#endif
42}
43
44static void YAPCatchError() {
45 if (LOCAL_CommittedError != nullptr &&
46 LOCAL_CommittedError->errorNo != YAP_NO_ERROR) {
47 // Yap_PopTermFromDB(info->errorTerm);
48 // throw throw YAPError( );
49 Term es[2];
50 es[0] = TermError;
51 es[1] = MkErrorTerm(LOCAL_CommittedError);
52 Functor f = Yap_MkFunctor(Yap_LookupAtom("print_message"), 2);
53 YAP_RunGoalOnce(Yap_MkApplTerm(f, 2, es));
54 // Yap_PopTermFromDB(info->errorTerm);
55 // throw throw YAPError( SOURCE(), );
56 } else if (LOCAL_ActiveError != nullptr &&
57 LOCAL_ActiveError->errorNo != YAP_NO_ERROR) {
58 // Yap_PopTermFromDB(info->errorTerm);
59 // throw throw YAPError( );
60 Term es[2];
61 es[0] = TermError;
62 es[1] = MkErrorTerm(LOCAL_ActiveError);
63 Functor f = Yap_MkFunctor(Yap_LookupAtom("print_message"), 2);
64 YAP_RunGoalOnce(Yap_MkApplTerm(f, 2, es));
65 // Yap_PopTermFromDB(info->errorTerm);
66 // throw throw YAPError( SOURCE(), );
67 }
68}
69
70YAPPredicate::YAPPredicate(Term &t, Term &tmod, CELL *&ts, const char *pname) {
71 Term t0 = t;
72 ap = nullptr;
73restart:
74 if (IsVarTerm(t)) {
75 throw YAPError(SOURCE(), INSTANTIATION_ERROR, t0, pname);
76 } else if (IsAtomTerm(t)) {
77 ap = RepPredProp(Yap_GetPredPropByAtom(AtomOfTerm(t), tmod));
78 ts = nullptr;
79 } else if (IsIntegerTerm(t) && tmod == IDB_MODULE) {
80 ts = nullptr;
81 ap = Yap_FindLUIntKey(IntegerOfTerm(t));
82 } else if (IsPairTerm(t)) {
83 t = Yap_MkApplTerm(FunctorCsult, 1, &t);
84 goto restart;
85 } else if (IsApplTerm(t)) {
86 Functor fun = FunctorOfTerm(t);
87 if (IsExtensionFunctor(fun)) {
88 throw YAPError(SOURCE(), TYPE_ERROR_CALLABLE,
89 Yap_TermToIndicator(t, tmod), pname);
90 }
91 if (fun == FunctorModule) {
92 tmod = ArgOfTerm(1, t);
93 if (IsVarTerm(tmod)) {
94 throw YAPError(SOURCE(), INSTANTIATION_ERROR, t0, pname);
95 }
96 if (!IsAtomTerm(tmod)) {
97 throw YAPError(SOURCE(), TYPE_ERROR_ATOM, t0, pname);
98 }
99 t = ArgOfTerm(2, t);
100 goto restart;
101 }
102 ap = RepPredProp(Yap_GetPredPropByFunc(fun, tmod));
103 ts = RepAppl(t) + 1;
104 } else {
105 throw YAPError(SOURCE(), TYPE_ERROR_CALLABLE, t0, pname);
106 }
107}
108
109Term YAPTerm::getArg(arity_t i) {
110 BACKUP_MACHINE_REGS();
111 Term tf = 0;
112 Term t0 = gt();
113
114 if (IsApplTerm(t0)) {
115 if (i > ArityOfFunctor(FunctorOfTerm(t0)))
116 throw YAPError(SOURCE(), DOMAIN_ERROR_OUT_OF_RANGE, t0, "t0.getArg()");
117 tf = (ArgOfTerm(i, t0));
118 } else if (IsPairTerm(t0)) {
119 if (i == 1)
120 tf = (HeadOfTerm(t0));
121 else if (i == 2)
122 tf = (TailOfTerm(t0));
123 else
124 throw YAPError(SOURCE(), DOMAIN_ERROR_OUT_OF_RANGE, t0, "t0.getArg()");
125 } else {
126 throw YAPError(SOURCE(), TYPE_ERROR_COMPOUND, t0, "t0.getArg()");
127 }
128 RECOVER_MACHINE_REGS();
129 return tf;
130}
131
132YAPAtomTerm::YAPAtomTerm(char s[]) { // build string
133 BACKUP_H();
134
135 CACHE_REGS
136 seq_tv_t inp, out;
137 inp.enc = LOCAL_encoding;
138 inp.val.c = s;
139 inp.type = YAP_STRING_CHARS;
140 out.type = YAP_STRING_ATOM;
141 if (Yap_CVT_Text(&inp, &out PASS_REGS))
142 mk(MkAtomTerm(out.val.a));
143 else
144 hdl = 0L;
145 RECOVER_H();
146}
147
148YAPAtomTerm::YAPAtomTerm(char *s, size_t len) { // build string
149 BACKUP_H();
150
151 CACHE_REGS
152 seq_tv_t inp, out;
153 inp.val.c = s;
154 inp.type = YAP_STRING_CHARS;
155 inp.enc = LOCAL_encoding;
156 out.type = YAP_STRING_ATOM | YAP_STRING_NCHARS | YAP_STRING_TRUNC;
157 out.max = len;
158 if (Yap_CVT_Text(&inp, &out PASS_REGS))
159 mk(MkAtomTerm(out.val.a));
160 else
161 hdl = 0L;
162 RECOVER_H();
163}
164
165YAPAtomTerm::YAPAtomTerm(wchar_t *s) : YAPTerm() { // build string
166 BACKUP_H();
167
168 CACHE_REGS
169 seq_tv_t inp, out;
170 inp.val.w = s;
171 inp.type = YAP_STRING_WCHARS;
172 out.type = YAP_STRING_ATOM;
173 if (Yap_CVT_Text(&inp, &out PASS_REGS))
174 mk(MkAtomTerm(out.val.a));
175 else
176 hdl = 0L;
177 RECOVER_H();
178}
179
180YAPAtomTerm::YAPAtomTerm(wchar_t *s, size_t len) : YAPTerm() { // build string
181 BACKUP_H();
182
183 CACHE_REGS
184 seq_tv_t inp, out;
185 inp.val.w = s;
186 inp.type = YAP_STRING_WCHARS;
187 out.type = YAP_STRING_ATOM | YAP_STRING_NCHARS | YAP_STRING_TRUNC;
188 out.max = len;
189 if (Yap_CVT_Text(&inp, &out PASS_REGS))
190 mk(MkAtomTerm(out.val.a));
191 else
192 hdl = 0L;
193 RECOVER_H();
194}
195
196YAPStringTerm::YAPStringTerm(char *s) { // build string
197 BACKUP_H();
198
199 CACHE_REGS
200 Term ts = MkStringTerm(s);
201 mk(ts);
202 RECOVER_H();
203}
204
205YAPStringTerm::YAPStringTerm(char *s, size_t len) { // build string
206 BACKUP_H();
207
208 CACHE_REGS
209
210 seq_tv_t inp, out;
211 inp.val.c = s;
212 inp.type = YAP_STRING_CHARS;
213 out.type = YAP_STRING_STRING | YAP_STRING_NCHARS | YAP_STRING_TRUNC;
214 out.max = len;
215 if (Yap_CVT_Text(&inp, &out PASS_REGS))
216 mk(out.val.t);
217 else
218 hdl = 0L;
219 RECOVER_H();
220}
221
222YAPStringTerm::YAPStringTerm(wchar_t *s) : YAPTerm() { // build string
223 BACKUP_H();
224
225 CACHE_REGS
226
227 seq_tv_t inp, out;
228 inp.val.w = s;
229 inp.type = YAP_STRING_WCHARS;
230 out.type = YAP_STRING_STRING;
231 if (Yap_CVT_Text(&inp, &out PASS_REGS))
232 mk(out.val.t);
233 else
234 hdl = 0L;
235 RECOVER_H();
236}
237
238YAPStringTerm::YAPStringTerm(wchar_t *s, size_t len)
239 : YAPTerm() { // build string
240 BACKUP_H();
241
242 CACHE_REGS
243
244 seq_tv_t inp, out;
245 inp.val.w = s;
246 inp.type = YAP_STRING_WCHARS;
247 out.type = YAP_STRING_STRING | YAP_STRING_NCHARS | YAP_STRING_TRUNC;
248 out.max = len;
249 if (Yap_CVT_Text(&inp, &out PASS_REGS))
250 mk(out.val.t);
251 else
252 hdl = 0L;
253 RECOVER_H();
254}
255
257 BACKUP_H();
258 arity_t arity = ArityOfFunctor(f.f);
259 Term o = Yap_MkNewApplTerm(f.f, arity);
260 Term *tt = RepAppl(o) + 1;
261 for (arity_t i = 0; i < arity; i++)
262 tt[i] = ts[i].term();
263 mk(o);
264 RECOVER_H();
265}
266
267YAPApplTerm::YAPApplTerm(const std::string f, std::vector<Term> ts) {
268 BACKUP_H();
269 arity_t arity = ts.size();
270 Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity);
271 Term o = AbsAppl(HR);
272 Term *tt = HR;
273 HR+=1+arity;
274 *tt++=(CELL)ff;
275 for (arity_t i = 0; i < arity; i++)
276 tt[i] = ts[i];
277 mk(o);
278 RECOVER_H();
279}
280
281
282
283
284YAPApplTerm::YAPApplTerm(const std::string f, std::vector<YAPTerm> ts) {
285 BACKUP_H();
286 arity_t arity = ts.size();
287 Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity);
288 Term o = AbsAppl(HR);
289 Term *tt = HR;
290 HR+=1+arity;
291 *tt++=(CELL)ff;
292 for (arity_t i = 0; i < arity; i++)
293 tt[i] = ts[i].term();
294 mk(o);
295 RECOVER_H();
296}
297
298
299
301 BACKUP_H();
302 arity_t arity = ArityOfFunctor(f.f);
303 mk(Yap_MkNewApplTerm(f.f, arity));
304 RECOVER_H();
305}
306
307Term &YAPTerm::operator[](arity_t i) {
308 BACKUP_MACHINE_REGS();
309 Term t0 = gt();
310 Term *tf = nullptr;
311 if (IsApplTerm(t0)) {
312 // Functor f = FunctorOfTerm(t0);
313 // if (IsExtensionFunctor(f))
314 // return 0;
315 tf = RepAppl(t0) + (i + 1);
316 } else if (IsPairTerm(t0)) {
317 if (i == 0)
318 tf = RepPair(t0);
319 else if (i == 1)
320 tf = RepPair(t0) + 1;
321 RECOVER_MACHINE_REGS();
322 } else {
323 throw YAPError(SOURCE(), TYPE_ERROR_COMPOUND, t0, "");
324 }
325 RECOVER_MACHINE_REGS();
326 return *tf;
327}
328
329Term &YAPListTerm::operator[](arity_t i) {
330 BACKUP_MACHINE_REGS();
331 Term t0 = gt();
332 while (IsPairTerm(t0)) {
333 if (i == 0) {
334 return *RepPair(t0);
335 } else {
336 t0 = TailOfTerm(t0);
337 }
338 }
339 return *RepPair(t0);
340}
341
342YAPPairTerm::YAPPairTerm(YAPTerm th, YAPTerm tl) {
343 CACHE_REGS
344 BACKUP_H();
345 mk(MkPairTerm(th.term(), tl.term()));
346 RECOVER_H();
347}
348
349YAPPairTerm::YAPPairTerm() {
350 BACKUP_H();
351 mk(TermNil);
352 RECOVER_H();
353}
354
355std::vector<Term> YAPPairTerm::listToArray() {
356 Term *tailp;
357 Term t1 = gt();
358 Int l = Yap_SkipList(&t1, &tailp);
359 if (l < 0) {
360 throw YAPError(SOURCE(), TYPE_ERROR_LIST, t1, nullptr);
361 }
362 std::vector<Term> o = *new std::vector<Term>(l);
363 int i = 0;
364 Term t = gt();
365 while (t != TermNil) {
366 o[i++] = HeadOfTerm(t);
367 t = TailOfTerm(t);
368 }
369 return o;
370}
371
372std::vector<YAPTerm> YAPPairTerm::listToVector() {
373 Term *tailp;
374 Term t1 = gt();
375 Int len = Yap_SkipList(&t1, &tailp);
376 if (len < 0) {
377 throw YAPError(SOURCE(), TYPE_ERROR_LIST, (t1), nullptr);
378 }
379 std::vector<YAPTerm> o = *new std::vector<YAPTerm>(len);
380 int i = 0;
381 Term l = gt();
382 while (l != TermNil) {
383 o[i++] = YAPTerm(HeadOfTerm(l));
384 l = TailOfTerm(l);
385 }
386 return o;
387}
388
389YAP_tag_t YAPTerm::tag() {
390 Term tt = gt();
391 if (IsVarTerm(tt)) {
392 CELL *pt = VarOfTerm(tt);
393 if (IsUnboundVar(pt)) {
394 CACHE_REGS
395 if (IsAttVar(pt))
396 return YAP_TAG_ATT;
397 return YAP_TAG_UNBOUND;
398 }
399 return YAP_TAG_REF;
400 }
401 if (IsPairTerm(tt))
402 return YAP_TAG_PAIR;
403 if (IsAtomOrIntTerm(tt)) {
404 if (IsAtomTerm(tt))
405 return YAP_TAG_ATOM;
406 return YAP_TAG_INT;
407 } else {
408 Functor f = FunctorOfTerm(tt);
409
410 if (IsExtensionFunctor(f)) {
411 if (f == FunctorDBRef) {
412 return YAP_TAG_DBREF;
413 }
414 if (f == FunctorLongInt) {
415 return YAP_TAG_LONG_INT;
416 }
417 if (f == FunctorBigInt) {
418 big_blob_type bt = (big_blob_type)RepAppl(tt)[1];
419 switch (bt) {
420 case BIG_INT:
421 return YAP_TAG_BIG_INT;
422 case BIG_RATIONAL:
423 return YAP_TAG_RATIONAL;
424 default:
425 return YAP_TAG_OPAQUE;
426 }
427 }
428 }
429 return YAP_TAG_APPL;
430 }
431}
432
434 yhandle_t tn;
435 BACKUP_MACHINE_REGS();
436
437 tn = Yap_CopyTerm(gt());
438
439 RECOVER_MACHINE_REGS();
440 return (tn);
441}
442
444 Term to = gt();
445 if (IsPairTerm(to))
446 return (TailOfTerm(to));
447 else if (to == TermNil)
448 return TermNil;
449 /* error */
450 throw YAPError(SOURCE(), TYPE_ERROR_LIST, to, "");
451}
452
454 BACKUP_MACHINE_REGS();
455 Term t0 = gt();
456 Term tf = 0;
457 while (IsApplTerm(t0) && FunctorOfTerm(t0) == FunctorComma) {
458 if (i == 0) {
459 return *(RepAppl(t0)+1);
460 } else {
461 t0 = ArgOfTerm(2,t0);
462 i--;
463 }
464 }
465 RECOVER_MACHINE_REGS();
466 return RepPair(tf)[i];
467}
468
470 yhandle_t tn;
471 BACKUP_MACHINE_REGS();
472
473 tn = Yap_CopyTerm(gt());
474
475 RECOVER_MACHINE_REGS();
476 return tn;
477}
478
479const char *YAPQuery::text() { return YAPTerm(goal).text(); }
480
481YAPIntegerTerm::YAPIntegerTerm(intptr_t i) {
482 CACHE_REGS Term tn = MkIntegerTerm(i);
483 mk(tn);
484}
485
486/*
487YAPTerm *YAPTerm::vars()
488{
489 BACKUP_MACHINE_REGS();
490 CACHE_REGS
491 YAPPairTerm lv = YAPPairTerm(Yap_TermVariables(gt(), TermNil PASS_REGS));
492 RECOVER_MACHINE_REGS();
493 return lv;
494}
495 */
496
498 CACHE_REGS
499 mk(MkIntegerTerm((Int)ptr));
500}
501
503 Term to = gt();
504 if (IsPairTerm(to))
505 return (HeadOfTerm(to));
506 else {
507 throw YAPError(SOURCE(), TYPE_ERROR_LIST, to, "");
508 return TermUnique;
509 }
510}
511
512YAPListTerm::YAPListTerm(Term ts[], size_t n) {
513 BACKUP_H();
514 while (HR + n * 3 > ASP-1024) {
515 RECOVER_H();
516 if (!Yap_dogc( PASS_REGS1 )) {
517 mk(TermNil);
518 }
519 BACKUP_H();
520 }
521 Term rc = AbsAppl(HR);
522 CELL *ptr = HR;
523 HR+=2*n;
524 for (size_t i=0; i< n; i++) {
525 ptr[0] = MkGlobal(ts[i]);
526 ptr[1] = AbsPair(ptr+2);
527 ptr += 2;
528 }
529 ptr[-1] = TermNil;
530 mk(rc);
531}
532
533YAPListTerm::YAPListTerm(const std::vector<Term> ts) {
534 CACHE_REGS
535 BACKUP_H();
536 size_t n=ts.size();
537 if (n == 0)
538 mk(TermNil);
539 while (HR + n * 2 > ASP - 1024) {
540 RECOVER_H();
541 if (!Yap_dogc( PASS_REGS1 )) {
542 mk(TermNil);
543 }
544 BACKUP_H();
545 }
546 Term a = AbsPair(HR);
547 CELL *ptr = HR;
548 HR += 2*n;
549 for (arity_t i = 0; i < n; i++) {
550 ptr[0] = MkGlobal(ts[i]);
551 ptr[1] = AbsPair(ptr + 2);
552 ptr += 2;
553 }
554 ptr[-1]=TermNil;
555 mk(a);
556 RECOVER_H();
557}
558
559
561 Term to = gt();
562 if (IsApplTerm(to)&& FunctorOfTerm(to)==FunctorComma)
563 return (ArgOfTerm(1,to));
564 else {
565 throw YAPError(SOURCE(), TYPE_ERROR_LIST, to, "");
566 return TermUnique;
567 }
568}
569
571 Term to = gt();
572 if (IsApplTerm(to)&& FunctorOfTerm(to)==FunctorComma)
573 return (ArgOfTerm(2,to));
574 else {
575 throw YAPError(SOURCE(), TYPE_ERROR_LIST, to, "");
576 return TermUnique;
577 }
578}
579
580YAPConjunctiveTerm::YAPConjunctiveTerm(const std::vector<Term> ts) {
581 CACHE_REGS
582 BACKUP_H();
583 size_t n=ts.size();
584 if (n == 0) {
585 mk(TermNil);
586 return;
587 }
588 if (n == 1) {
589 mk(ts[0]);
590 return;
591 }
592 while (HR + n * 3 > ASP - 1024) {
593 RECOVER_H();
594 if (!Yap_dogc( PASS_REGS1 )) {
595 mk(TermNil);
596 }
597 BACKUP_H();
598 }
599 Term a = AbsAppl(HR);
600 CELL *ptr = HR;
601 HR += 3*(n-1);
602 for (arity_t i = 0; i < n-1; i++) {
603 ptr[0] = (CELL)FunctorComma;
604 ptr[1] = MkGlobal(ts[i]);
605 ptr[2] = AbsAppl(ptr + 3);
606 ptr += 3;
607 }
608 ptr[-1]=ts[n-1];
609 mk(a);
610 RECOVER_H();
611}
612
613
614YAPConjunctiveTerm::YAPConjunctiveTerm(const Term ts[], size_t n) {
615 CACHE_REGS
616 BACKUP_H();
617 if (n == 0) {
618 mk(TermNil);
619 return;
620 }
621 if (n == 1) {
622 mk(ts[0]);
623 return;
624 }
625 while (HR + n * 3 > ASP - 1024) {
626 RECOVER_H();
627 if (!Yap_dogc( PASS_REGS1 )) {
628 mk(TermNil);
629 }
630 BACKUP_H();
631 }
632 Term a = AbsAppl(HR);
633 CELL *ptr = HR;
634 HR += 3*(n-1);
635 for (arity_t i = 0; i < n-1; i++) {
636 ptr[0] = (CELL)FunctorComma;
637 ptr[1] = MkGlobal(ts[i]);
638 ptr[2] = AbsAppl(ptr + 3);
639 ptr += 3;
640 }
641 ptr[-1]=ts[n-1];
642 mk(a);
643 RECOVER_H();
644}
645
646
647const char *YAPAtom::getName(void) { return Yap_AtomToUTF8Text(a); }
648
649void YAPQuery::openQuery() {
650 CACHE_REGS
651 if (ap == NULL || ap->OpcodeOfPred == UNDEF_OPCODE) {
652 ap = rewriteUndefQuery();
653 }
654 q_open = true;
655 setNext();
656}
657
659 CACHE_REGS
660 if (ap.ap == NULL)
661 return false;
662 BACKUP_MACHINE_REGS();
663 arity_t arity = ap.getArity();
664 bool result;
666
667 q.CurSlot = Yap_StartSlots();
668 q.p = P;
669
670 q.cp = CP;
671 q.b0 = LCL0-CellPtr(B);
672 q.env0 = LCL0-ENV;
673 for (arity_t i = 0; i < arity; i++)
674 XREGS[i + 1] = ts[i].term();
675
676 // allow Prolog style exceotion handling
677 // don't forget, on success these bindings will still be there);
678 result = YAP_EnterGoal(ap.ap, nullptr, &q);
679 YAP_LeaveGoal(result, &q);
680
681 YAPCatchError();
682
683 RECOVER_MACHINE_REGS();
684 return result;
685}
686
687bool YAPEngine::mgoal(Term t, Term tmod, bool release) {
688#if YAP_PYTHON
689 // std::cerr << "mgoal(in) " << YAPTerm(tmod).text() << ":" << YAPTerm(t).text() << "\n";
690 // PyThreadState *_save;
691
692 // std::cerr << "mgoal " << YAPTerm(t).text() << "\n";
693 // _save = PyEval_SaveThread();
694#endif
695 CACHE_REGS
697 BACKUP_MACHINE_REGS();
698
699 Term *ts = nullptr;
700 q.CurSlot = Yap_StartSlots();
701 q.p = P;
702 q.cp = CP;
703 Int oenv = LCL0-ENV;
704 Int oB = LCL0-CellPtr(B);
705 PredEntry *ap = nullptr;
706 if (IsStringTerm(tmod))
707 tmod = MkAtomTerm(Yap_LookupAtom(StringOfTerm(tmod)));
708 ap = Yap_get_pred(t, tmod, "C++");
709 if (ap == nullptr ||
710 ap->OpcodeOfPred == UNDEF_OPCODE) {
711 ap = rewriteUndefEngineQuery(ap, t, tmod);
712 }
713 if (false && ap->PredFlags & MetaPredFlag) {
714 ts[0] = tmod;
715 ts[1] = t;
716 ARG1 = Yap_MkApplTerm(FunctorModule,2,ts);
717 ap = PredCall;
718 } else {
719 if (IsApplTerm(t))
720 ts = RepAppl(t) + 1;
721 else if (IsPairTerm(t))
722 ts = RepPair(t);
723 /* legal ap */
724
725 arity_t arity = ap->ArityOfPE;
726
727 for (arity_t i = 0; i < arity; i++) {
728 XREGS[i + 1] = ts[i];
729 }
730 }
731 ts = nullptr;
732 bool result;
733 // allow Prolog style exception handling
734 // don't forget, on success these guys may create slots
735 //__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "exec ");
736 Term ocmod = CurrentModule;
737 Term osmod = LOCAL_SourceModule;
738 CurrentModule = LOCAL_SourceModule = tmod;
739 result = (bool)YAP_EnterGoal(ap, nullptr, &q);
740 LOCAL_SourceModule = osmod;
741 CurrentModule = ocmod;
742 // std::cerr << "mgoal " << YAPTerm(tmod).text() << ":" << YAPTerm(t).text() << "\n
743 YAP_LeaveGoal(result, &q);
744 if (release)
745 HR = B->cp_h;
746 ENV = LCL0-oenv;
747 B = (choiceptr)(LCL0-oB);
748 // PyEval_RestoreThread(_save);
749 RECOVER_MACHINE_REGS();
750 return result;
751}
756
757 BACKUP_MACHINE_REGS();
758 HR = B->cp_h;
759
760 RECOVER_MACHINE_REGS();
761}
762
763Term YAPEngine::fun(Term t) {
764 CACHE_REGS
765 BACKUP_MACHINE_REGS();
767 Term tmod = Yap_CurrentModule(), *ts = nullptr;
768 PredEntry *ap;
769 arity_t arity;
770 Functor f;
771 Atom name;
772 q.CurSlot = Yap_StartSlots();
773 q.p = P;
774 q.cp = CP;
775
776 Int oenv = LCL0-ENV;
777 Int oB = LCL0-CellPtr(B);
778
779 if (IsApplTerm(t)) {
780 ts = RepAppl(t) + 1;
781 f = (Functor)ts[-1];
782 name = NameOfFunctor(f);
783 arity = ArityOfFunctor(f);
784 for (arity_t i = 0; i < arity; i++)
785 HR[i + 1] = ts[i];
786 arity++;
787 } else if (IsAtomTerm(t)) {
788 name = AtomOfTerm(t);
789 f = nullptr;
790 arity = 1;
791 } else if (IsPairTerm(t)) {
792 HR[1] = ts[0];
793 HR[2] = ts[1];
794 arity = 3;
795 name = AtomDot;
796 f = FunctorDot;
797 } else {
798 Yap_CloseSlots(q.CurSlot);
799 throw YAPError(SOURCE(), TYPE_ERROR_CALLABLE, t, 0);
800 return 0L;
801 }
802 Term ot = XREGS[arity + 1] = MkVarTerm();
803 yhandle_t h = Yap_InitHandle(ot);
804 arity++;
805 HR += arity;
806 f = Yap_MkFunctor(name, arity);
807 ap = (PredEntry *)(PredPropByFunc(f, tmod));
808 if (ap == nullptr || ap->OpcodeOfPred == UNDEF_OPCODE) {
809 Term g = (Yap_MkApplTerm(f, arity, ts));
810 ap = rewriteUndefEngineQuery(ap, g, (ap->ModuleOfPred));
811 }
812 // make sure this is safe
813 // allow Prolog style exception handling
814 //__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "exec ");
815
816 bool result = (bool)YAP_EnterGoal(ap, nullptr, &q);
817 if (result)
818 ot = Yap_GetFromHandle(h);
819 else
820 ot = TermNone;
821 YAPCatchError();
822 {
823
824 YAP_LeaveGoal(result, &q);
825 ENV = LCL0-oenv;
826
827 B = (choiceptr)(LCL0-oB);
828 // PyEval_RestoreThread(_save);
829 RECOVER_MACHINE_REGS();
830 Yap_CloseSlots(q.CurSlot);
831 return ot;
832 }
833 }
834
835YAPQuery::YAPQuery(YAPFunctor f, YAPTerm mod, YAPTerm ts[])
836 : YAPPredicate(f, mod) {
837
838 /* ignore flags for now */
839 BACKUP_MACHINE_REGS();
840 Term goal;
841
842 if (ts) {
843
844 goal = YAPApplTerm(f, ts).term();
845 nts = RepAppl(goal) + 1;
846 size_t arity = f.arity();
847 for (arity_t i = 0; i < arity; i++)
848 XREGS[i + 1] = nts[i];
849 } else {
850 goal = MkVarTerm();
851 }
852 openQuery();
853 names = new YAPPairTerm(TermNil);
854 RECOVER_MACHINE_REGS();
855}
856
857YAPQuery::YAPQuery(YAPFunctor f, YAPTerm mod, Term ts[])
858 : YAPPredicate(f, mod) {
859
860 /* ignore flags for now */
861 BACKUP_MACHINE_REGS();
862 Term goal;
863
864 if (ts) {
865 size_t arity = f.arity();
866 goal = Yap_MkApplTerm(Yap_MkFunctor(f.name().asAtom(),arity), arity, ts);
867 nts = RepAppl(goal) + 1;
868 for (arity_t i = 0; i < arity; i++)
869 XREGS[i + 1] = ts[i];
870 } else {
871 goal = MkVarTerm();
872 }
873 openQuery();
874 names = new YAPPairTerm(TermNil);
875 RECOVER_MACHINE_REGS();
876}
877
878#if 0
879YAPQuery::YAPQuery(YAPFunctor f, YAPTerm ts[]) : YAPPredicate(f) {
880 /* ignore flags for now */
881 BACKUP_MACHINE_REGS();
882 if (ts) {
883goal = YAPApplTerm(f, nts);
884 } else {
885 goal = YAPVarTerm();
886 nts = nullptr;
887 }
888 names = new YAPPairTerm( TermNil );
889 openQuery(term(), nts);
890 RECOVER_MACHINE_REGS();
891}
892#endif
893
894YAPQuery::YAPQuery(YAPPredicate p, YAPTerm ts[]) : YAPPredicate(p.ap) {
895 BACKUP_MACHINE_REGS();
896 try {
897 arity_t arity = p.ap->ArityOfPE;
898 if (arity) {
899 goal = YAPApplTerm(YAPFunctor(p.ap->FunctorOfPred), ts).term();
900 for (arity_t i = 0; i < arity; i++)
901 XREGS[i + 1] = ts[i].term();
902 openQuery();
903 } else {
904 goal = MkAtomTerm((Atom)(p.ap->FunctorOfPred));
905 openQuery();
906 }
907 names = new YAPPairTerm(TermNil);
908 } catch (...) {
909 }
910 RECOVER_MACHINE_REGS();
911}
912
914 CACHE_REGS
915 bool result = false;
916 // std::cerr << "next " << YAPTerm(goal).text() << "\n";
917 q_h.CurSlot = Yap_StartSlots();
918 q_h.p = P;
919 q_h.cp = CP;
920
921 sigjmp_buf buf, *oldp = (sigjmp_buf *)LOCAL_RestartEnv;
922 e = nullptr;
923 BACKUP_MACHINE_REGS();
924 if (!q_open)
925 return false;
926 LOCAL_RestartEnv = &buf;
927 // don't forget, on success these guys may create slots
928 __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "exec ");
929
930 if (q_state == 0) {
931 // Yap_do_low_level_trace = 1;
932 result = (bool)YAP_EnterGoal(ap, nullptr, &q_h);
933 } else {
934 LOCAL_AllowRestart = q_open;
935 result = (bool)YAP_RetryGoal(&q_h);
936 }
937 q_state = 1;
938 __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "out %d", result);
939 if (!result) {
940 YAP_LeaveGoal(result, &q_h);
941 Yap_CloseHandles(q_h.CurSlot);
942 q_open = false;
943 } else if(deterministic()) {
944 YAP_LeaveGoal(result, &q_h);
945 q_open = false;
946 }
947
948 YAPCatchError();
949 RECOVER_MACHINE_REGS();
950 LOCAL_RestartEnv = oldp;
951 return result;
952}
953
954PredEntry *YAPQuery::rewriteUndefQuery() {
955 Term ts[2];
956 ts[0] = CurrentModule;
957 ts[1] = goal;
958 goal = Yap_MkApplTerm(FunctorModule, 2, ts);
959 ARG1 = goal = Yap_SaveTerm(goal);
960 return ap = PredCall;
961}
962
963PredEntry *YAPEngine::rewriteUndefEngineQuery(PredEntry *a, Term &tgoal,Term mod)
964{
965 Term ts[2];
966 ts[0]=mod;
967 ts[1] = tgoal;
968 tgoal = Yap_MkApplTerm(FunctorModule, 2, ts);
969 tgoal = Yap_SaveTerm(Yap_MkApplTerm(FunctorCall, 1, &tgoal));
970 LOCAL_ActiveError->errorNo = YAP_NO_ERROR;
971 return PredCall;
972
973 // return YAPApplTerm(FunctorUndefinedQuery, ts);
974}
975
977 CACHE_REGS
978
979 BACKUP_MACHINE_REGS();
980 if (!q_open || q_state == 0)
981 return;
982 YAP_LeaveGoal(true, &q_h);
983 q_open = false;
984 // LOCAL_execution = this;
985 RECOVER_MACHINE_REGS();
986}
987
989 CACHE_REGS
990
991 BACKUP_MACHINE_REGS();
992 if (!q_open || q_state == 0)
993 return false;
994 choiceptr myB = (choiceptr)(LCL0 - q_h.b_entry);
995 return (B >= myB);
996 RECOVER_MACHINE_REGS();
997}
998
999YAPTerm YAPQuery::getTerm(yhandle_t t) { return YAPTerm(t); }
1000
1002 CACHE_REGS
1003
1004 RECOVER_MACHINE_REGS();
1005 Yap_ResetException(worker_id);
1006 /* need to implement backtracking here */
1007 if (q_open != true || q_state == 0) {
1008 RECOVER_MACHINE_REGS();
1009 return;
1010 }
1011 YAP_LeaveGoal(false, &q_h);
1012 q_open = 0;
1013 Yap_CloseHandles(q_h.CurSlot);
1014 // LOCAL_execution = this;
1015 RECOVER_MACHINE_REGS();
1016}
1017
1018#if __ANDROID__
1019
1020#include <jni.h>
1021#include <string.h>
1022
1023JNIEnv *Yap_jenv;
1024
1025extern JNIEXPORT jint JNICALL JNI_MySQLOnLoad(JavaVM *vm, void *reserved);
1026
1027JNIEXPORT jint JNICALL JNI_MySQLOnLoad(JavaVM *vm, void *reserved) {
1028 JNIEnv *env;
1029 if (vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_6) != JNI_OK) {
1030 return -1;
1031 }
1032 Yap_jenv = env;
1033
1034 return JNI_VERSION_1_6;
1035}
1036
1037char *Yap_AndroidBufp;
1038
1039static size_t Yap_AndroidMax, Yap_AndroidSz;
1040
1041extern void (*Yap_DisplayWithJava)(int c);
1042
1043static YAPCallback *cb = new YAPCallback();
1044
1045void Yap_displayWithJava(int c) {
1046 char *ptr = Yap_AndroidBufp;
1047 if (!ptr)
1048 ptr = Yap_AndroidBufp = (char *)malloc(Yap_AndroidSz);
1049 ptr[Yap_AndroidSz++] = c;
1050 if (Yap_AndroidMax - 1 == Yap_AndroidSz) {
1051 if (Yap_AndroidMax < 32 * 1024) {
1052 Yap_AndroidMax *= 2;
1053 } else {
1054 Yap_AndroidMax += 32 * 1024;
1055 }
1056 Yap_AndroidBufp = (char *)realloc(ptr, Yap_AndroidMax);
1057 }
1058 Yap_AndroidBufp[Yap_AndroidSz] = '\0';
1059 if (c == '\n') {
1060 Yap_AndroidBufp[Yap_AndroidSz] = '\0';
1061 cb->run(Yap_AndroidBufp);
1062 Yap_AndroidSz = 0;
1063 }
1064}
1065
1066#endif
1067
1068void YAPEngine::doInit(YAP_file_type_t BootMode, YAPEngineArgs *engineArgs) {
1069 if (GLOBAL_Initialised)
1070 return;
1071 GLOBAL_Initialised = true;
1072 YAP_Init(engineArgs);
1073// yerror = throw YAPError( SOURCE(), );
1074CurrentModule = LOCAL_SourceModule = TermUser;
1075#if YAP_PYTHON
1076 do_init_python();
1077#endif
1078 // std::string s = "initialize_prolog";
1079 // YAPPredicate p = YAPPredicate(MkAtomTerm(Yap_LookupAtom(s.c_str())));
1080 // YAPQuery initq = YAPQuery(YAPPredicate(p), nullptr);
1081 // if (initq.next()) {
1082 // initq.cut();
1083 // }
1084 CurrentModule = TermUser;
1085 LOCAL_SourceModule = TermUser;
1086}
1087
1088YAPEngine::YAPEngine(int argc, char *argv[],
1089 YAPCallback *cb)
1090 : _callback(0) { // a single engine can be active
1091
1092 YAP_file_type_t BootMode;
1093 engine_args = new YAPEngineArgs();
1094 BootMode = YAP_parse_yap_arguments(argc, argv, engine_args);
1095 // delYAPCallback()b
1096 // if (cb)
1097 // setYAPCallback(cb);
1098
1099 doInit(BootMode, engine_args);
1100 CurrentModule = LOCAL_SourceModule = TermUser;
1101}
1102
1104 CACHE_REGS
1105 ap = RepPredProp(PredPropByAtom(at.a, Yap_CurrentModule()));
1106}
1107
1109 CACHE_REGS
1110 if (arity) {
1111 Functor f = Yap_MkFunctor(at.a, arity);
1112 ap = RepPredProp(PredPropByFunc(f, Yap_CurrentModule()));
1113 } else {
1114 ap = RepPredProp(PredPropByAtom(at.a, Yap_CurrentModule()));
1115 }
1116}
1117
1119PredEntry *YAPPredicate::getPred(Term &t, Term &m, CELL *&out) {
1120 CACHE_REGS
1121 t = Yap_StripModule(t, &m);
1122
1123 if (IsVarTerm(t) || IsNumTerm(t)) {
1124 if (IsVarTerm(t))
1125 throw YAPError(SOURCE(), INSTANTIATION_ERROR, t, 0);
1126 else if (IsNumTerm(t))
1127 throw YAPError(SOURCE(), TYPE_ERROR_CALLABLE, t, 0);
1128 }
1129 if (IsAtomTerm(t)) {
1130 ap = RepPredProp(PredPropByAtom(AtomOfTerm(t), m));
1131 return ap;
1132 } else if (IsPairTerm(t)) {
1133 Term ts[2], *s = (out ? out : ts);
1134 Functor FunctorConsult = Yap_MkFunctor(Yap_LookupAtom("consult"), 1);
1135 s[1] = t;
1136 s[0] = m;
1137 t = Yap_MkApplTerm(FunctorModule, 2, s);
1138 t = Yap_MkApplTerm(FunctorConsult, 1, &t);
1139 if (!out)
1140 out = RepAppl(t) + 1;
1141 }
1142 Functor f = FunctorOfTerm(t);
1143 if (IsExtensionFunctor(f)) {
1144 throw YAPError(SOURCE(), TYPE_ERROR_CALLABLE, t, 0);
1145 } else {
1146 ap = RepPredProp(PredPropByFunc(f, m));
1147 if (out)
1148 memmove(out, (const CELL *)RepAppl(t) + 1, ap->ArityOfPE * sizeof(CELL));
1149 else
1150 out = RepAppl(t) + 1;
1151 }
1152 return ap;
1153}
1154
1156 CACHE_REGS
1157
1158 RECOVER_MACHINE_REGS();
1159 Term tt = cl.gt();
1160 Term ntt = cl.gt();
1161 yamop *codeaddr =
1162 Yap_cclause(tt, ap->ArityOfPE, (last ? TermAssertz : TermAsserta), Yap_CurrentModule()); /* vsc: give the number of arguments
1163 to cclause in case there is overflow */
1164 if (LOCAL_ErrorMessage) {
1165 RECOVER_MACHINE_REGS();
1166 return false;
1167 }
1168 Term *tref = &ntt;
1169 if (Yap_addclause(ntt, codeaddr, (last ? TermAssertz : TermAsserta),
1170 Yap_CurrentModule(), tref)) {
1171 RECOVER_MACHINE_REGS();
1172 }
1173 return tref;
1174}
1175
1177 CACHE_REGS
1178 arity_t i;
1179 RECOVER_MACHINE_REGS();
1180 Term tt = AbsAppl(HR);
1181 *HR++ = (CELL)(ap->FunctorOfPred);
1182 for (i = 0; i < ap->ArityOfPE; i++, cl++)
1183 *HR++ = cl->gt();
1184 yamop *codeaddr = Yap_cclause(tt, ap->ArityOfPE, (last ? TermAssertz : TermAsserta), Yap_CurrentModule()); /* vsc: give the number of arguments
1185 to cclause in case there is overflow */
1186 if (LOCAL_ErrorMessage) {
1187 RECOVER_MACHINE_REGS();
1188 return false;
1189 }
1190 Term *tref = &tt;
1191 if (Yap_addclause(tt, codeaddr, (last ? TermAssertz : TermAsserta),
1192 Yap_CurrentModule(), tref)) {
1193 RECOVER_MACHINE_REGS();
1194 }
1195 return tref;
1196}
1197
1199 return 0;
1200}
1201
1202std::string YAPError::text() {
1203
1204 return "Error";
1205#if 0
1206std::stringstream s;
1207 s << "";
1208 if (info->errorNo == YAP_NO_ERROR)
1209 return 0;
1210 if (info->errorFunction) {
1211 s += info->errorFile;
1212 s += ":";
1213 sprintf(buf, "%ld", (long int)info->errorLine);
1214 s += buf;
1215 s += ":0 in C-code";
1216 }
1217 return s;
1218 if (info->prologPredLine) {
1219 s += "\n";
1220 s += info->prologPredFile;
1221 s += ":";
1222 s << info->prologPredLine;
1223 // YAPIntegerTerm(info->prologPredLine).text();
1224 s += ":0 ";
1225 s += info->prologPredModule;
1226 s += ":";
1227 s += (info->prologPredName);
1228 s += "/";
1229 s << info->prologPredArity;
1230 }
1231 s += " error ";
1232 if (info->classAsText == nullptr)
1233 info->classAsText = Yap_errorClassName(info->errorClass);
1234 if (info->classAsText != nullptr)
1235 s += info->classAsText;
1236 s += ".";
1237 if (info->errorAsText == nullptr)
1238 info->errorAsText = Yap_errorName(info->errorNo);
1239 if (info->errorAsText != nullptr)
1240 s += info->errorAsText;
1241 s += ".\n";
1242 // printf("%s\n", s.c_str());
1243 return s.c_str();
1244#endif
1245}
1246
1248 /* ignore flags for now */
1249 if (B && B->cp_b && B->cp_ap != NOCODE)
1250 // YAP_LeaveGoal(false, &q);
1251 LOCAL_ActiveError->errorNo = YAP_NO_ERROR;
1252 if (LOCAL_CommittedError) {
1253 LOCAL_CommittedError->errorNo = YAP_NO_ERROR;
1254 free(LOCAL_CommittedError);
1255 LOCAL_CommittedError = NULL;
1256 }
1257 pop_text_stack(0);
1258 LOCAL_CurSlot = 0;
1259}
1260
1261Term YAPEngine::top_level(std::string s) {
1264 Term tp;
1265 ARG1 = YAP_ReadBuffer(s.data(), &tp);
1266 ARG2 = tp;
1267 ARG3 = MkVarTerm();
1268 if (ARG1 == 0)
1269 throw YAPError(SOURCE(), SYNTAX_ERROR, ARG1, "in input query");
1270 YAPPredicate p = YAPPredicate(YAP_TopGoal());
1271 YAPQuery *Q = new YAPQuery(p, 0);
1272 Term ts[2];
1273 ts[0] = MkAddressTerm(Q);
1274 if (Q->next()) {
1275 ts[1] = ARG3;
1276 } else {
1277 ts[1] = TermNil;
1278 }
1279 return YAP_MkApplTerm(YAP_MkFunctor(YAP_LookupAtom("t"), 2), 2, ts);
1280}
1281
1283
1286 Term ts[2];
1287 ts[0] = MkAddressTerm(Q);
1288 if (Q->next()) {
1289 ts[1] = ARG3;
1290 } else {
1291 ts[1] = TermNil;
1292 }
1293 return YAP_MkApplTerm(YAP_MkFunctor(YAP_LookupAtom("t"), 2), 2, ts);
1294}
X_API YAP_file_type_t YAP_parse_yap_arguments(int argc, char *argv[], YAP_init_args *iap)
Parse command line.
Definition: yap-args.c:607
bool Yap_ResetException(yap_error_descriptor_t *i)
clean up (notice that the code ensures ActiveError exists on exit
Definition: errors.c:1425
@ argv
read-only atom, it describes the list with all arguments received by YAP at boot
Definition: YapGFlagInfo.h:89
@ source
If true maintain the source for all clauses.
Definition: YapGFlagInfo.h:601
PredEntry * getPred(Term &t, Term &tm, CELL *&outp)
auxiliary routine to find a predicate in the current module
Definition: yapi.cpp:1119
YAPPredicate()
Empty constructor for predicates.
Definition: yapdb.hh:100
bool assertFact(YAPTerm *tuple, bool last=true)
add a new tuple
Definition: yapi.cpp:1176
bool assertClause(YAPTerm clause, bool last=true, YAPTerm source=YAPTerm())
add a new clause
Definition: yapi.cpp:1155
void * retractClause(YAPTerm skeleton, bool all=false)
retract at least the first clause matching the predicate
Definition: yapi.cpp:1198
Predicates.
Definition: yapdb.hh:83
std::string text()
the term that caused the bug
Definition: yapi.cpp:1202
take information on a Prolog error:
Definition: yapie.hh:31
const char * getName(void)
get name of atom
Definition: yapi.cpp:647
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
YAPEngine(YAPEngineArgs *cargs)
construct a new engine; may use a variable number of arguments
Definition: yapq.hh:328
Term top_level(std::string s)
Definition: yapi.cpp:1261
void reSet()
reset Prolog state
Definition: yapi.cpp:1247
Term Yap_CurrentModule()
current module for the engine
Definition: yapq.hh:371
void release()
assune that there are no stack pointers, just release memory
Definition: yapi.cpp:755
const char * text()
represent the top-goal
Definition: yapi.cpp:479
Term next_answer(YAPQuery *&Q)
Definition: yapi.cpp:1282
void close()
remove alternatives in the current search space, and finish the current query finish the current quer...
Definition: yapi.cpp:1001
bool deterministic()
does this query have open choice-points? or is it deterministic?
Definition: yapi.cpp:988
bool next()
ask for the next solution of the current query same call for every solution
Definition: yapi.cpp:913
bool call(YAPPredicate ap, YAPTerm ts[])
current directory for the engine
Definition: yapi.cpp:658
YAPTerm getTerm(yhandle_t t)
convert a ref to a binding
Definition: yapi.cpp:999
bool mgoal(Term t, Term tmod, bool release=false)
ru1n a goal in a module
Definition: yapi.cpp:687
void cut()
query variables
Definition: yapi.cpp:976
This class implements a callback Prolog-side.
Definition: yapq.hh:170
Queries and engines.
Definition: yapq.hh:38
Setup all arguments to a new engine.
Definition: yapq.hh:178
Term deepCopy()
copy the term ( term copy )
Definition: yapi.cpp:433
void mk(Term t0)
create a new YAPTerm from a term
Definition: yapt.hh:74
Term dup()
copy a list
Definition: yapi.cpp:469
Term car()
Extract the first element of a list.
Definition: yapi.cpp:502
YAP_tag_t tag()
construct a term out of an integer (if you know object type use YAPIntegerTerm) YAPTerm(long int num)...
Definition: yapi.cpp:389
Term gt()
handle to term, equivalent to term_t
Definition: yapt.hh:57
YAPTerm()
private method to convert from Term (internal YAP representation) to YAPTerm
Definition: yapt.hh:96
Term & operator[](size_t n)
Extract the nth element.
Definition: yapi.cpp:329
virtual Term getArg(arity_t i)
term is a list
Definition: yapi.cpp:109
YAPListTerm()
Definition: yapt.hh:506
YAPStringTerm(char *s)
your standard constructor
Definition: yapi.cpp:196
virtual arity_t arity()
extract the arity of the term variables have arity 0
Definition: yapt.hh:228
virtual const char * text()
return a string with a textual representation of the term
Definition: yapt.hh:243
Term cdr()
Extract the tail elements of a list.
Definition: yapi.cpp:443
YAPApplTerm(Term t0)
There are very many ways to build one of these terms:
Definition: yapt.hh:286
Term & operator[](arity_t n)
from YAPTerm to Term (internal YAP representation) fetch a sub-term
Definition: yapi.cpp:307
Compound Term.
Definition: yapt.hh:279
List Constructor Term.
Definition: yapt.hh:448
Generic Prolog Term.
Definition: yapt.hh:42
Variable Term.
Definition: yapt.hh:652
A matrix.
Definition: matrix.c:68
Definition: Yatom.h:544
uintptr_t prologPredLine
line where error clause defined
Definition: YapError.h:231
const char * errorFunction
C-function.
Definition: YapError.h:218
const char * errorFile
C-file.
Definition: YapError.h:220
yap_error_number errorNo
error identifier
Definition: YapError.h:207
yap_error_class_number errorClass
kind of error: derived from errorNo;
Definition: YapError.h:209
const char * prologPredName
Prolog predicate that caused the error: name.
Definition: YapError.h:223
char * classAsText
errorClass as text
Definition: YapError.h:213
char * errorAsText
errorNo as text
Definition: YapError.h:211
const char * prologPredFile
Prolog predicate that caused the error:line
Definition: YapError.h:229
intptr_t errorLine
c-code that generated the error C-line
Definition: YapError.h:216
const char * prologPredModule
Prolog predicate that caused the error:module
Definition: YapError.h:227
uintptr_t prologPredArity
Prolog predicate that caused the error:arity.
Definition: YapError.h:225
Definition: amidefs.h:264
entry file for the YAP C++ interface
#define SOURCE()
short version
Definition: yapie.hh:71