From 6e9882c3697de97c1b7ddfb6b8dc987be1aa258a Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Sun, 20 May 2018 15:47:13 +0100 Subject: [PATCH 1/4] format --- docs/custom/DoxygenLayout.xml | 194 ++++++++++++++++++++++++++++++++++ 1 file changed, 194 insertions(+) create mode 100644 docs/custom/DoxygenLayout.xml diff --git a/docs/custom/DoxygenLayout.xml b/docs/custom/DoxygenLayout.xml new file mode 100644 index 000000000..1cdc7e17d --- /dev/null +++ b/docs/custom/DoxygenLayout.xml @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From b7a97a5b19757d524b7de8f5746413b76b5892c9 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Mon, 21 May 2018 14:45:24 +0100 Subject: [PATCH 2/4] error handling --- CXX/yapi.cpp | 198 ++++++++++-------- docs/md/extensions.md | 15 -- os/iopreds.c | 11 +- packages/python/pyio.c | 77 +++---- .../yap_kernel/yap_ipython/prolog/jupyter.yap | 18 +- 5 files changed, 168 insertions(+), 151 deletions(-) diff --git a/CXX/yapi.cpp b/CXX/yapi.cpp index c0db4b720..76aad64a0 100644 --- a/CXX/yapi.cpp +++ b/CXX/yapi.cpp @@ -34,9 +34,10 @@ X_API bool do_init_python(void); YAPPredicate::YAPPredicate(Term &t, Term &tmod, CELL *&ts, const char *pname) { Term t0 = t; ap = nullptr; + Yap_DebugPlWriteln(t); restart: if (IsVarTerm(t)) { - throw YAPError( SOURCE(), INSTANTIATION_ERROR, t0, pname); + throw YAPError(SOURCE(), INSTANTIATION_ERROR, t0, pname); } else if (IsAtomTerm(t)) { ap = RepPredProp(Yap_GetPredPropByAtom(AtomOfTerm(t), tmod)); ts = nullptr; @@ -49,15 +50,16 @@ restart: } else if (IsApplTerm(t)) { Functor fun = FunctorOfTerm(t); if (IsExtensionFunctor(fun)) { - throw YAPError( SOURCE(), TYPE_ERROR_CALLABLE, Yap_PredicateIndicator(t, tmod), pname); + throw YAPError(SOURCE(), TYPE_ERROR_CALLABLE, + Yap_PredicateIndicator(t, tmod), pname); } if (fun == FunctorModule) { tmod = ArgOfTerm(1, t); if (IsVarTerm(tmod)) { - throw YAPError( SOURCE(), INSTANTIATION_ERROR, t0, pname); + throw YAPError(SOURCE(), INSTANTIATION_ERROR, t0, pname); } if (!IsAtomTerm(tmod)) { - throw YAPError( SOURCE(), TYPE_ERROR_ATOM, t0, pname); + throw YAPError(SOURCE(), TYPE_ERROR_ATOM, t0, pname); } t = ArgOfTerm(2, t); goto restart; @@ -65,32 +67,32 @@ restart: ap = RepPredProp(Yap_GetPredPropByFunc(fun, tmod)); ts = RepAppl(t) + 1; } else { - throw YAPError( SOURCE(), TYPE_ERROR_CALLABLE, t0, pname); + throw YAPError(SOURCE(), TYPE_ERROR_CALLABLE, t0, pname); } } - Term YAPTerm::getArg(arity_t i) { - BACKUP_MACHINE_REGS(); - Term tf = 0; - Term t0 = gt(); +Term YAPTerm::getArg(arity_t i) { + BACKUP_MACHINE_REGS(); + Term tf = 0; + Term t0 = gt(); - if (IsApplTerm(t0)) { - if (i > ArityOfFunctor(FunctorOfTerm(t0))) - throw YAPError( SOURCE(), DOMAIN_ERROR_OUT_OF_RANGE, t0, "t0.getArg()"); - tf = (ArgOfTerm(i, t0)); - } else if (IsPairTerm(t0)) { - if (i == 1) - tf = (HeadOfTerm(t0)); - else if (i == 2) - tf = (TailOfTerm(t0)); - else - throw YAPError( SOURCE(), DOMAIN_ERROR_OUT_OF_RANGE, t0, "t0.getArg()"); - } else { - throw YAPError( SOURCE(), TYPE_ERROR_COMPOUND, t0, "t0.getArg()"); - } - RECOVER_MACHINE_REGS(); - return tf; + if (IsApplTerm(t0)) { + if (i > ArityOfFunctor(FunctorOfTerm(t0))) + throw YAPError(SOURCE(), DOMAIN_ERROR_OUT_OF_RANGE, t0, "t0.getArg()"); + tf = (ArgOfTerm(i, t0)); + } else if (IsPairTerm(t0)) { + if (i == 1) + tf = (HeadOfTerm(t0)); + else if (i == 2) + tf = (TailOfTerm(t0)); + else + throw YAPError(SOURCE(), DOMAIN_ERROR_OUT_OF_RANGE, t0, "t0.getArg()"); + } else { + throw YAPError(SOURCE(), TYPE_ERROR_COMPOUND, t0, "t0.getArg()"); } + RECOVER_MACHINE_REGS(); + return tf; +} YAPAtomTerm::YAPAtomTerm(char s[]) { // build string BACKUP_H(); @@ -265,7 +267,7 @@ Term &YAPTerm::operator[](arity_t i) { tf = RepPair(t0) + 1; RECOVER_MACHINE_REGS(); } else { - throw YAPError( SOURCE(), TYPE_ERROR_COMPOUND, t0, ""); + throw YAPError(SOURCE(), TYPE_ERROR_COMPOUND, t0, ""); } RECOVER_MACHINE_REGS(); return *tf; @@ -303,22 +305,21 @@ YAPPairTerm::YAPPairTerm() { } std::vector YAPPairTerm::listToArray() { - Term *tailp; - Term t1 = gt(); - Int l = Yap_SkipList(&t1, &tailp); - if (l < 0) { - throw YAPError( SOURCE(), TYPE_ERROR_LIST, (t), nullptr); - } - std::vector o = std::vector(l); - int i = 0; - Term t = gt(); - while (t != TermNil) { - o[i++] = HeadOfTerm(t); - t = TailOfTerm(t); - } - return o; + Term *tailp; + Term t1 = gt(); + Int l = Yap_SkipList(&t1, &tailp); + if (l < 0) { + throw YAPError(SOURCE(), TYPE_ERROR_LIST, (t), nullptr); } - + std::vector o = std::vector(l); + int i = 0; + Term t = gt(); + while (t != TermNil) { + o[i++] = HeadOfTerm(t); + t = TailOfTerm(t); + } + return o; +} YAP_tag_t YAPTerm::tag() { Term tt = gt(); @@ -375,14 +376,14 @@ Term YAPTerm::deepCopy() { } Term YAPListTerm::cdr() { - Term to = gt(); - if (IsPairTerm(to)) - return (TailOfTerm(to)); - else if (to == TermNil) - return TermNil; - /* error */ - throw YAPError( SOURCE(), TYPE_ERROR_LIST, to, ""); - } + Term to = gt(); + if (IsPairTerm(to)) + return (TailOfTerm(to)); + else if (to == TermNil) + return TermNil; + /* error */ + throw YAPError(SOURCE(), TYPE_ERROR_LIST, to, ""); +} Term YAPListTerm::dup() { yhandle_t tn; @@ -431,7 +432,7 @@ Term YAPListTerm::car() { if (IsPairTerm(to)) return (HeadOfTerm(to)); else { - throw YAPError( SOURCE(), TYPE_ERROR_LIST, to, ""); + throw YAPError(SOURCE(), TYPE_ERROR_LIST, to, ""); return TermUnique; } } @@ -487,7 +488,8 @@ bool YAPEngine::call(YAPPredicate ap, YAPTerm ts[]) { if (LOCAL_CommittedError != nullptr) { std::cerr << "Exception received by " << __func__ << "( " - << YAPError( LOCAL_CommittedError).text() << ").\n Forwarded...\n\n"; + << YAPError(LOCAL_CommittedError).text() + << ").\n Forwarded...\n\n"; // Yap_PopTermFromDB(info->errorTerm); // throw throw YAPError( SOURCE(), ); } @@ -508,8 +510,10 @@ bool YAPEngine::mgoal(Term t, Term tmod) { try { if (IsStringTerm(tmod)) tmod = MkAtomTerm(Yap_LookupAtom(StringOfTerm(tmod))); - PredEntry *ap = (new YAPPredicate(t, tmod, ts, "C++"))->ap; - if (ap == nullptr || ap->OpcodeOfPred == UNDEF_OPCODE) { + YAPPredicate *p = new YAPPredicate(t, tmod, ts, "C++"); + PredEntry *ap = nullptr; + if (p == nullptr || (ap = p->ap) == nullptr || + ap->OpcodeOfPred == UNDEF_OPCODE) { ap = rewriteUndefEngineQuery(ap, t, tmod); } if (IsApplTerm(t)) @@ -527,27 +531,37 @@ bool YAPEngine::mgoal(Term t, Term tmod) { q.CurSlot = Yap_StartSlots(); q.p = P; q.cp = CP; - // allow Prolog style exception handling - // don't forget, on success these guys may create slots + // allow Prolog style exception handling + // don't forget, on success these guys may create slots __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "exec "); - + result = (bool)YAP_EnterGoal(ap, nullptr, &q); if (LOCAL_CommittedError != nullptr && - LOCAL_CommittedError->errorNo != YAP_NO_ERROR) { - throw YAPError( LOCAL_CommittedError); + LOCAL_CommittedError->errorNo != YAP_NO_ERROR) { + throw YAPError(LOCAL_CommittedError); + } + { + YAP_LeaveGoal(result, &q); + if (LOCAL_CommittedError != nullptr && + LOCAL_CommittedError->errorNo != YAP_NO_ERROR) { + throw YAPError(LOCAL_CommittedError); + } + // PyEval_RestoreThread(_save); + RECOVER_MACHINE_REGS(); + return result; + } + } catch (...) { + if (LOCAL_CommittedError != nullptr && + LOCAL_CommittedError->errorNo != YAP_NO_ERROR) { + std::cerr << "Exception received by " << __func__ << "( " + << YAPError(LOCAL_CommittedError).text() + << ").\n Forwarded...\n\n"; + // free(LOCAL_CommittedError); + LOCAL_CommittedError->errorNo = YAP_NO_ERROR; + LOCAL_ActiveError->errorNo = YAP_NO_ERROR; + LOCAL_CommittedError = nullptr; + return false; } - { - YAP_LeaveGoal(result, &q); - // PyEval_RestoreThread(_save); - RECOVER_MACHINE_REGS(); - return result; - } - } catch ( ... ) { - if (LOCAL_CommittedError != nullptr && - LOCAL_CommittedError->errorNo != YAP_NO_ERROR) { - std::cerr << "Exception received by " << __func__ << "( " - << YAPError( LOCAL_CommittedError).text() << ").\n Forwarded...\n\n"; - } } } @@ -585,7 +599,7 @@ Term YAPEngine::fun(Term t) { name = AtomDot; f = FunctorDot; } else { - throw YAPError( SOURCE(), TYPE_ERROR_CALLABLE, t, 0); + throw YAPError(SOURCE(), TYPE_ERROR_CALLABLE, t, 0); return 0L; } XREGS[arity + 1] = MkVarTerm(); @@ -606,7 +620,8 @@ Term YAPEngine::fun(Term t) { bool result = (bool)YAP_EnterGoal(ap, nullptr, &q); if (LOCAL_CommittedError != nullptr) { std::cerr << "Exception received by " << __func__ << "( " - << YAPError( LOCAL_CommittedError).text() << ").\n Forwarded...\n\n"; + << YAPError(LOCAL_CommittedError).text() + << ").\n Forwarded...\n\n"; // Yap_PopTermFromDB(info->errorTerm); // throw throw YAPError( SOURCE(), ); } @@ -725,9 +740,9 @@ bool YAPQuery::next() { YAP_LeaveGoal(false, &q_h); Yap_CloseHandles(q_handles); q_open = false; - if (LOCAL_CommittedError != nullptr) { - // Yap_PopTermFromDB(info->errorTerm); - // throw throw YAPError( ); + if (LOCAL_CommittedError != nullptr) { + // Yap_PopTermFromDB(info->errorTerm); + // throw throw YAPError( ); Term es[2]; es[0] = TermError; es[1] = MkErrorTerm(LOCAL_CommittedError); @@ -911,15 +926,15 @@ PredEntry *YAPPredicate::getPred(YAPTerm &tt, CELL *&outp) { CACHE_REGS Term m = Yap_CurrentModule(), t = tt.term(); t = Yap_StripModule(t, &m); - - std::cerr << "Exception received by " << __func__ << "( " - << tt.text() << ").\n Forwarded...\n\n"; + + std::cerr << "Exception received by " << __func__ << "( " << tt.text() + << ").\n Forwarded...\n\n"; if (IsVarTerm(t) || IsNumTerm(t)) { if (IsVarTerm(t)) - throw YAPError( SOURCE(), INSTANTIATION_ERROR, tt.term(), 0); + throw YAPError(SOURCE(), INSTANTIATION_ERROR, tt.term(), 0); else if (IsNumTerm(t)) - throw YAPError( SOURCE(), TYPE_ERROR_CALLABLE, tt.term(), 0); + throw YAPError(SOURCE(), TYPE_ERROR_CALLABLE, tt.term(), 0); } tt.put(t); if (IsAtomTerm(t)) { @@ -938,7 +953,7 @@ PredEntry *YAPPredicate::getPred(YAPTerm &tt, CELL *&outp) { } Functor f = FunctorOfTerm(t); if (IsExtensionFunctor(f)) { - throw YAPError( SOURCE(), TYPE_ERROR_CALLABLE, t, 0); + throw YAPError(SOURCE(), TYPE_ERROR_CALLABLE, t, 0); } else { ap = RepPredProp(PredPropByFunc(f, m)); outp = RepAppl(t) + 1; @@ -1002,31 +1017,32 @@ void *YAPPrologPredicate::retractClause(YAPTerm skeleton, bool all) { std::string YAPError::text() { char buf[256]; - std::string s = ""; + return "Error"; +#if 0 +std::stringstream s; + s << ""; if (info->errorNo == YAP_NO_ERROR) return 0; - if (info->errorFunction) { + if (info->errorFunction) { s += info->errorFile; s += ":"; sprintf(buf, "%ld", (long int)info->errorLine); s += buf; s += ":0 in C-code"; } + return s; if (info->prologPredLine) { s += "\n"; s += info->prologPredFile; s += ":"; - sprintf(buf, "%ld", (long int)info->prologPredLine); - s += buf; // std::to_string(info->prologPredLine) ; + s << info->prologPredLine; // YAPIntegerTerm(info->prologPredLine).text(); s += ":0 "; s += info->prologPredModule; s += ":"; s += (info->prologPredName); s += "/"; - sprintf(buf, "%ld", (long int)info->prologPredArity); - s += // std::to_string(info->prologPredArity); - buf; + s << info->prologPredArity; } s += " error "; if (info->classAsText == nullptr) @@ -1035,12 +1051,13 @@ std::string YAPError::text() { s += info->classAsText; s += "."; if (info->errorAsText == nullptr) - info->errorAsText = Yap_errorName(info->errorNo); + info->errorAsText = Yap_errorName(info->errorNo); if (info->errorAsText != nullptr) s += info->errorAsText; s += ".\n"; // printf("%s\n", s.c_str()); return s.c_str(); +#endif } void YAPEngine::reSet() { @@ -1063,7 +1080,6 @@ void YAPEngine::reSet() { RECOVER_MACHINE_REGS(); } - Term YAPEngine::top_level(std::string s) { /// parse string s and make term with var names /// available. @@ -1072,7 +1088,7 @@ Term YAPEngine::top_level(std::string s) { ARG2 = tp; ARG3 = MkVarTerm(); if (ARG1 == 0) - throw YAPError( SOURCE(), SYNTAX_ERROR, ARG1, "in input query"); + throw YAPError(SOURCE(), SYNTAX_ERROR, ARG1, "in input query"); YAPPredicate p = YAPPredicate(YAP_TopGoal()); YAPQuery *Q = new YAPQuery(p, 0); Term ts[2]; diff --git a/docs/md/extensions.md b/docs/md/extensions.md index 8d474593b..778ff48ed 100644 --- a/docs/md/extensions.md +++ b/docs/md/extensions.md @@ -7,20 +7,5 @@ YAP includes a number of extensions over the original Prolog language. Next, we discuss how to use the most important ones. - + @ref Rational_Trees - - + @ref AttributedVariables - - + @ref DepthLimited - - + @ref Tabling - - + @ref Threads - - + @ref Profiling - - + @ref YAPArrays - - + @ref Parallelism @} diff --git a/os/iopreds.c b/os/iopreds.c index bbfc238a6..38ff9c30f 100644 --- a/os/iopreds.c +++ b/os/iopreds.c @@ -28,7 +28,8 @@ static char SccsId[] = "%W% %G%"; */ /* * This file includes the definition of a miscellania of standard predicates * - *for yap refering to: Files and GLOBAL_Streams, Simple Input/Output, + *for yap refering to: Files and GLOBAL_1588 + *ams, Simple Input/Output, * */ @@ -1584,7 +1585,7 @@ int Yap_OpenStream(Term tin, const char *io_mode, Term user_name, st->file = fopen(fname, io_mode); } if (!st->file) { - + fprintf(stderr, "trying %s\n", fname); PlIOError(EXISTENCE_ERROR_SOURCE_SINK, tin, "%s", fname); /* extract BACK info passed through the stream descriptor */ return -1; @@ -1632,12 +1633,10 @@ int Yap_OpenStream(Term tin, const char *io_mode, Term user_name, if (!strchr(io_mode, 'b') && binary_file(fname)) { UNLOCK(st->streamlock); if (errno == ENOENT && !strchr(io_mode, 'r')) { - PlIOError(EXISTENCE_ERROR_SOURCE_SINK, - tin, "%s: %s", fname, + PlIOError(EXISTENCE_ERROR_SOURCE_SINK, tin, "%s: %s", fname, strerror(errno)); } else { - PlIOError(PERMISSION_ERROR_OPEN_SOURCE_SINK, - tin, "%s: %s", fname, + PlIOError(PERMISSION_ERROR_OPEN_SOURCE_SINK, tin, "%s: %s", fname, strerror(errno)); } } diff --git a/packages/python/pyio.c b/packages/python/pyio.c index eef418471..11c7ae539 100644 --- a/packages/python/pyio.c +++ b/packages/python/pyio.c @@ -7,8 +7,7 @@ YAP_Term TermErrStream, TermOutStream; -static int py_put(int sno, int ch) -{ +static int py_put(int sno, int ch) { // PyObject *pyw; // buffer // int pyw_kind; // PyObject *pyw_data; @@ -16,13 +15,13 @@ static int py_put(int sno, int ch) if (st->user_name == TermOutStream) { term_t tg = python_acquire_GIL(); PySys_WriteStdout("%C", ch); - python_release_GIL(tg); - return ch; + python_release_GIL(tg); + return ch; } if (st->user_name == TermErrStream) { - term_t tg = python_acquire_GIL(); - PySys_WriteStderr("%C", ch); - python_release_GIL(tg); + term_t tg = python_acquire_GIL(); + PySys_WriteStderr("%C", ch); + python_release_GIL(tg); return ch; } char s[2]; @@ -33,8 +32,7 @@ static int py_put(int sno, int ch) PyObject_CallMethodObjArgs(st->u.private_data, PyUnicode_FromString("write"), PyUnicode_FromString(s), NULL); python_release_GIL(g0); - if ((err = PyErr_Occurred())) - { + if ((err = PyErr_Occurred())) { PyErr_SetString( err, "Error in put\n"); // %s:%s:%d!\n", __FILE__, __FUNCTION__, __LINE__); @@ -43,7 +41,8 @@ static int py_put(int sno, int ch) } VFS_t pystream; - static void *py_open(VFS_t *me, const char *name, const char *io_mode, int sno) { +static void *py_open(VFS_t *me, const char *name, const char *io_mode, + int sno) { #if HAVE_STRCASESTR if (strcasestr(name, "/python/") == name) name += strlen("/python/"); @@ -52,34 +51,36 @@ VFS_t pystream; name += strlen("/python/"); #endif term_t ctk = python_acquire_GIL(); - PyObject *pystream = string_to_python(name, true, NULL); - if (pystream == NULL || pystream == Py_None) { - python_release_GIL(ctk); - return NULL; - } + PyObject *pystream = string_to_python(name, true, NULL); + if (pystream == NULL || pystream == Py_None) { + python_release_GIL(ctk); + return NULL; + } StreamDesc *st = YAP_RepStreamFromId(sno); st->name = YAP_LookupAtom(name); - if (strcmp(name,"sys.stdout") == 0) { + if (strcmp(name, "sys.stdout") == 0) { st->user_name = TermOutStream; - } else if(strcmp(name,"sys.stderr") == 0) { + } else if (strcmp(name, "sys.stderr") == 0) { st->user_name = TermErrStream; } else { st->user_name = YAP_MkAtomTerm(st->name); } // we assume object is already open, so there is no need to open it. - st->u.private_data = pystream; + if (PyCallable_Check(pystream)) + st->u.private_data = PyObject_Call(pystream, PyTuple_New(0), NULL); + else + st->u.private_data = pystream; st->vfs = me; - python_release_GIL(ctk); + python_release_GIL(ctk); return st; } static bool py_close(int sno) { StreamDesc *st = YAP_RepStreamFromId(sno); - if (strcmp(st->name,"sys.stdout") && - strcmp(st->name,"sys.stderr")) { - Py_XDECREF(st->u.private_data); + if (strcmp(st->name, "sys.stdout") && strcmp(st->name, "sys.stderr")) { + Py_XDECREF(st->u.private_data); } - st->u.private_data = NULL; + st->u.private_data = NULL; st->vfs = NULL; return true; @@ -87,19 +88,20 @@ static bool py_close(int sno) { static bool getLine(int inp) { char *myrl_line = NULL; - StreamDesc *rl_instream = YAP_RepStreamFromId(inp); - term_t ctk = python_acquire_GIL(); - fprintf(stderr,"in"); - PyObject*prompt = PyUnicode_FromString( "?- "), - *msg = PyUnicode_FromString(" **input** "); + StreamDesc *rl_instream = YAP_RepStreamFromId(inp); + term_t ctk = python_acquire_GIL(); + fprintf(stderr, "in"); + PyObject *prompt = PyUnicode_FromString("?- "), + *msg = PyUnicode_FromString(" **input** "); /* window of vulnerability opened */ - myrl_line = PyUnicode_AsUTF8(PyObject_CallFunctionObjArgs(rl_instream->u.private_data,msg,prompt,NULL)); + myrl_line = PyUnicode_AsUTF8(PyObject_CallFunctionObjArgs( + rl_instream->u.private_data, msg, prompt, NULL)); python_release_GIL(ctk); - rl_instream->u.irl.ptr = rl_instream->u.irl.buf = (const unsigned char*)myrl_line; + rl_instream->u.irl.ptr = rl_instream->u.irl.buf = + (const unsigned char *)myrl_line; myrl_line = NULL; return true; } - static int py_getc(int sno) { StreamDesc *s = YAP_RepStreamFromId(sno); @@ -117,7 +119,7 @@ static int py_getc(int sno) { } else { return EOF; } -return ch; + return ch; } /** @@ -151,23 +153,22 @@ static int py_peek(int sno) { return ch; } - static int64_t py_seek(int sno, int64_t where, int how) { StreamDesc *g0 = YAP_RepStreamFromId(sno); - term_t s0 = python_acquire_GIL(); + term_t s0 = python_acquire_GIL(); PyObject *fseek = PyObject_GetAttrString(g0->u.private_data, "seek"); PyObject *pyr = PyObject_CallFunctionObjArgs(fseek, PyLong_FromLong(where), PyLong_FromLong(how), NULL); - python_release_GIL(s0); -return PyLong_AsLong(pyr); + python_release_GIL(s0); + return PyLong_AsLong(pyr); } static void py_flush(int sno) { StreamDesc *s = YAP_GetStreamFromId(sno); - term_t tg = python_acquire_GIL(); + term_t tg = python_acquire_GIL(); PyObject *flush = PyObject_GetAttrString(s->u.private_data, "flush"); PyObject_CallFunction(flush, NULL); - python_release_GIL(tg); + python_release_GIL(tg); } #if 0 diff --git a/packages/python/yap_kernel/yap_ipython/prolog/jupyter.yap b/packages/python/yap_kernel/yap_ipython/prolog/jupyter.yap index e48564a62..a1ac4b3dc 100644 --- a/packages/python/yap_kernel/yap_ipython/prolog/jupyter.yap +++ b/packages/python/yap_kernel/yap_ipython/prolog/jupyter.yap @@ -20,7 +20,6 @@ % ] %% ). :- [library(hacks)]. - :- reexport(library(yapi)). :- use_module(library(lists)). :- use_module(library(maplist)). @@ -274,4 +273,21 @@ close_events( Self ) :- fail. close_events( _ ). + +:- if( current_prolog_flag(apple, true) ). + +:- putenv( 'LC_ALL', 'en_us:UTF-8'). + +plot_inline :- + X := self.inline_plotting, + nb_setval(inline, X ), + X = true, + !, + := ( + import( matplotlib ), + matplotlib.use( `nbagg` ) + ). + +:- endif. + %:- ( start_low_level_trace ). From 03d8a645438e9b35963e0718d431579e16e5fb25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Tue, 22 May 2018 00:25:32 +0100 Subject: [PATCH 3/4] small fixes --- packages/bdd/simplecudd/general.h | 2 +- packages/bdd/simplecudd/problogbdd.c | 5 +++-- packages/bdd/simplecudd_lfi/simplecudd.c | 2 +- packages/real/CMakeLists.txt | 4 ++-- packages/swi-minisat2/C/Solver.C | 6 +++--- packages/swi-minisat2/C/SolverTypes.h | 2 +- packages/swi-minisat2/C/Vec.h | 12 ++++++------ 7 files changed, 17 insertions(+), 16 deletions(-) diff --git a/packages/bdd/simplecudd/general.h b/packages/bdd/simplecudd/general.h index 4b22bef5d..53effc35b 100644 --- a/packages/bdd/simplecudd/general.h +++ b/packages/bdd/simplecudd/general.h @@ -200,7 +200,7 @@ int getRealNumber(char *c, double *number); int getIntNumber(char *c, int *number); -inline int getPosNumber(char *c, int *number); +//inline int getPosNumber(char *c, int *number); int IsRealNumber(char *c); int IsPosNumber(const char *c); int IsNumber(const char *c); diff --git a/packages/bdd/simplecudd/problogbdd.c b/packages/bdd/simplecudd/problogbdd.c index 1080ae23c..8e1b7ea8b 100644 --- a/packages/bdd/simplecudd/problogbdd.c +++ b/packages/bdd/simplecudd/problogbdd.c @@ -188,12 +188,13 @@ //#include //#include +#include #include "simplecudd.h" #include "problogmath.h" #include #include -#define VERSION "2.0.1" +#define PROBLOGBDD_VERSION "2.0.1" #ifndef max @@ -1550,7 +1551,7 @@ int argtype(const char *arg) { } void printhelp(int argc, char **arg) { - fprintf(stderr, "\n\nProbLogBDD Tool Version: %s\n\n", VERSION); + fprintf(stderr, "\n\nProbLogBDD Tool Version: %s\n\n", PROBLOGBDD_VERSION); fprintf(stderr, "SimpleCUDD library (www.cs.kuleuven.be/~theo/tools/simplecudd.html)\n"); fprintf(stderr, "SimpleCUDD was developed at Katholieke Universiteit Leuven(www.kuleuven.be)\n"); fprintf(stderr, "Copyright Katholieke Universiteit Leuven 2008\n"); diff --git a/packages/bdd/simplecudd_lfi/simplecudd.c b/packages/bdd/simplecudd_lfi/simplecudd.c index 2e1934e2e..41a21e026 100644 --- a/packages/bdd/simplecudd_lfi/simplecudd.c +++ b/packages/bdd/simplecudd_lfi/simplecudd.c @@ -400,7 +400,7 @@ int simpleNamedBDDtoDot(DdManager *manager, namedvars varmap, DdNode *bdd, // Cudd_AutodynEnable(mana, CUDD_REORDER_EXACT); // Cudd_ReduceHeap(manager, CUDD_REORDER_SIFT, 1); - ret = Cudd_DumpDot(manager, 1, f, varmap.vars, NULL, fd); + ret = Cudd_DumpDot(manager, 1, f, (const char *const *)varmap.vars, NULL, fd); fclose(fd); return ret; } diff --git a/packages/real/CMakeLists.txt b/packages/real/CMakeLists.txt index efe165e6a..7f5d24bd5 100644 --- a/packages/real/CMakeLists.txt +++ b/packages/real/CMakeLists.txt @@ -252,8 +252,8 @@ include_directories ( ) add_lib(real ${REAL_SOURCES}) -link_directories(${R_LIBDIR}) - target_link_libraries (real R libYap) + + target_link_libraries (real ${LIBR_SO} libYap) check_include_files( "stdio.h;R.h" HAVE_R_H ) check_include_files( "R.h;Rembedded.h" HAVE_R_EMBEDDED_H ) diff --git a/packages/swi-minisat2/C/Solver.C b/packages/swi-minisat2/C/Solver.C index 795c26b24..4b61c6de6 100644 --- a/packages/swi-minisat2/C/Solver.C +++ b/packages/swi-minisat2/C/Solver.C @@ -63,8 +63,8 @@ Solver::Solver() : Solver::~Solver() { - for (int i = 0; i < learnts.size(); i++) free(learnts[i]); - for (int i = 0; i < clauses.size(); i++) free(clauses[i]); + for (int i = 0; i < learnts.size(); i++) std::free(learnts[i]); + for (int i = 0; i < clauses.size(); i++) std::free(clauses[i]); } @@ -163,7 +163,7 @@ void Solver::detachClause(Clause& c) { void Solver::removeClause(Clause& c) { detachClause(c); - free(&c); } + std::free(&c); } bool Solver::satisfied(const Clause& c) const { diff --git a/packages/swi-minisat2/C/SolverTypes.h b/packages/swi-minisat2/C/SolverTypes.h index 75eaebd8d..567e57f1d 100644 --- a/packages/swi-minisat2/C/SolverTypes.h +++ b/packages/swi-minisat2/C/SolverTypes.h @@ -147,7 +147,7 @@ template Clause* Clause_new(const V& ps, bool learnt) { assert(sizeof(Lit) == sizeof(uint32_t)); assert(sizeof(float) == sizeof(uint32_t)); - void* mem = malloc(sizeof(Clause) + sizeof(uint32_t)*(ps.size())); + void* mem = std::malloc(sizeof(Clause) + sizeof(uint32_t)*(ps.size())); return new (mem) Clause(ps, learnt); } /*_________________________________________________________________________________________________ | diff --git a/packages/swi-minisat2/C/Vec.h b/packages/swi-minisat2/C/Vec.h index e780aa167..14e00adbc 100644 --- a/packages/swi-minisat2/C/Vec.h +++ b/packages/swi-minisat2/C/Vec.h @@ -27,7 +27,7 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA //================================================================================================= // Automatically resizable arrays // -// NOTE! Don't use this vector on datatypes that cannot be re-located in memory (with realloc) +// NOTE! Don't use this vector on datatypes that cannot be re-located in memory (with std::realloc) template class vec { @@ -79,9 +79,9 @@ public: // Stack interface: #if 1 - void push (void) { if (sz == cap) { cap = imax(2, (cap*3+1)>>1); data = (T*)realloc(data, cap * sizeof(T)); } new (&data[sz]) T(); sz++; } - //void push (const T& elem) { if (sz == cap) { cap = imax(2, (cap*3+1)>>1); data = (T*)realloc(data, cap * sizeof(T)); } new (&data[sz]) T(elem); sz++; } - void push (const T& elem) { if (sz == cap) { cap = imax(2, (cap*3+1)>>1); data = (T*)realloc(data, cap * sizeof(T)); } data[sz++] = elem; } + void push (void) { if (sz == cap) { cap = imax(2, (cap*3+1)>>1); data = (T*)std::realloc(data, cap * sizeof(T)); } new (&data[sz]) T(); sz++; } + //void push (const T& elem) { if (sz == cap) { cap = imax(2, (cap*3+1)>>1); data = (T*)std::realloc(data, cap * sizeof(T)); } new (&data[sz]) T(elem); sz++; } + void push (const T& elem) { if (sz == cap) { cap = imax(2, (cap*3+1)>>1); data = (T*)std::realloc(data, cap * sizeof(T)); } data[sz++] = elem; } void push_ (const T& elem) { assert(sz < cap); data[sz++] = elem; } #else void push (void) { if (sz == cap) grow(sz+1); new (&data[sz]) T() ; sz++; } @@ -106,7 +106,7 @@ void vec::grow(int min_cap) { if (min_cap <= cap) return; if (cap == 0) cap = (min_cap >= 2) ? min_cap : 2; else do cap = (cap*3+1) >> 1; while (cap < min_cap); - data = (T*)realloc(data, cap * sizeof(T)); } + data = (T*)std::realloc(data, cap * sizeof(T)); } template void vec::growTo(int size, const T& pad) { @@ -127,7 +127,7 @@ void vec::clear(bool dealloc) { if (data != NULL){ for (int i = 0; i < sz; i++) data[i].~T(); sz = 0; - if (dealloc) free(data), data = NULL, cap = 0; } } + if (dealloc) std::free(data), data = NULL, cap = 0; } } #endif From 9ea75834ff478616fa04127b3e9126a7dcc5d69d Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Tue, 22 May 2018 12:23:52 +0100 Subject: [PATCH 4/4] docs & compilation --- CXX/yapi.cpp | 5 +- H/YapGFlagInfo.h | 1163 +++++++++++++++++----------------- cmake/FindR.cmake | 14 +- docs/Doxyfile.in | 34 +- packages/real/CMakeLists.txt | 231 +------ pl/control.yap | 23 +- 6 files changed, 623 insertions(+), 847 deletions(-) diff --git a/CXX/yapi.cpp b/CXX/yapi.cpp index 76aad64a0..6b2ab35bc 100644 --- a/CXX/yapi.cpp +++ b/CXX/yapi.cpp @@ -556,10 +556,9 @@ bool YAPEngine::mgoal(Term t, Term tmod) { std::cerr << "Exception received by " << __func__ << "( " << YAPError(LOCAL_CommittedError).text() << ").\n Forwarded...\n\n"; + YAP_LeaveGoal(result, &q); + // free(LOCAL_CommittedError); - LOCAL_CommittedError->errorNo = YAP_NO_ERROR; - LOCAL_ActiveError->errorNo = YAP_NO_ERROR; - LOCAL_CommittedError = nullptr; return false; } } diff --git a/H/YapGFlagInfo.h b/H/YapGFlagInfo.h index 848f54e12..a964d5cd1 100644 --- a/H/YapGFlagInfo.h +++ b/H/YapGFlagInfo.h @@ -8,10 +8,8 @@ * * ************************************************************************** * * - * File: YapGFlagInfo.h * - * Last rev: * - * mods: * - * comments: global flag enumeration. * + * File: YapGFlagInfo.h * Last rev: + ** mods: * comments: global flag enumeration. * * * *************************************************************************/ @@ -24,601 +22,588 @@ @brief global flags and their values. */ - START_GLOBAL_FLAGS - - /** - `address_bits` - Number of address bits in the machine, either 64 or 32 bits +START_GLOBAL_FLAGS + +YAP_FLAG(ADDRESS_BITS_FLAG, "address_bits", false, nat, BITNESS, NULL), /**< + Number of address bits in the machine, either 64 or 32 bits. */ - YAP_FLAG(ADDRESS_BITS_FLAG, "address_bits", false, nat, BITNESS, NULL), - /**< `agc_margin` - An integer: if this amount of atoms has been created since the last - atom-garbage collection, perform atom garbage collection at the first - opportunity. Initial value is 10,000. May be changed. A value of 0 - (zero) disables atom garbage collection. - */ - YAP_FLAG(AGC_MARGIN_FLAG, "agc_margin", true, nat, "10000", - agc_threshold), + YAP_FLAG(AGC_MARGIN_FLAG, "agc_margin", true, nat, "10000", + agc_threshold), /**< - /**< `allow_assert_for_static_predicates` allow asserting and retracting clauses of static - predicates. */ - YAP_FLAG(ALLOW_ASSERT_FOR_STATIC_PREDICATES, - "allow_assert_for_static_predicates", true, booleanFlag, "true", - NULL), +An integer: if this amount of atoms has been created since the last +atom-garbage collection, perform atom garbage collection at the first +opportunity. Initial value is 10,000. May be changed. A value of 0 +(zero) disables atom garbage collection. +*/ - /**< `allow_variable_name_as_functor` boolean flag allows constructs such as - ~~~ - Tree(Node(L,node,R)) :- - Tree(L), - Tree(R). - ~~~ - */ - YAP_FLAG( ALLOW_VARIABLE_NAME_AS_FUNCTOR_FLAG, "allow_variable_name_as_functor", false, booleanFlag, "false", NULL), + YAP_FLAG(ALLOW_ASSERT_FOR_STATIC_PREDICATES, + "allow_assert_for_static_predicates", true, booleanFlag, "true", + NULL), /**< + boolean: allow asserting and retracting clauses of static + predicates. */ + + YAP_FLAG(ALLOW_VARIABLE_NAME_AS_FUNCTOR_FLAG, + "allow_variable_name_as_functor", false, booleanFlag, "false", + NULL), /**< + + boolean flag allows syntax such + as + ~~~ + Tree(Node(L,node,R)) :- + Tree(L), + Tree(R). + ~~~ + */ + + /**< `answer_format` how to present answers, default is `~p`. */ + YAP_FLAG(ANSWER_FORMAT_FLAG, "answer_format", true, isatom, "~p", NULL), - /**< `answer_format` how to present answers, default is `~p`. */ - YAP_FLAG(ANSWER_FORMAT_FLAG, "answer_format", true, isatom, "~p", - NULL), #if __APPLE__ - /**< - `apple`: read-only boolean, a machine running an Apple Operating System * - */ - YAP_FLAG(APPLE_FLAG, "apple", false, booleanFlag, "true", - NULL), + YAP_FLAG(APPLE_FLAG, "apple", false, booleanFlag, "true", NULL), /**< + `read-only boolean, a machine running an Apple Operating System * + * #endif - YAP_FLAG(ARCH_FLAG, "arch", false, isatom, YAP_ARCH, NULL), - YAP_FLAG(ARGV_FLAG, "argv", false, argv, "@boot", NULL), - /**< `arithmetic_exceptions` - - Read-write flag telling whether arithmetic exceptions generate - Prolog exceptions. If enabled: - - ~~~ - ?- X is 2/0. - ERROR!! - ZERO DIVISOR ERROR- X is Exp - ~~~ - - If disabled: - ~~~ - ?- X is 2/0. - X = (+inf). - ~~~ - - It is `true` by default, but it is disabled by packages like CLP(BN) and - ProbLog. - */ - YAP_FLAG(ARITHMETIC_EXCEPTIONS_FLAG, "arithmetic_exceptions", true, - booleanFlag, "true", NULL), - /**> - If _Value_ is unbound, tell whether a back quoted list of characters - token is converted to a list of atoms, `chars`, to a list of integers, - `codes`, or to a single atom, `atom`. If _Value_ is bound, set to - the corresponding behavior. The default value is `string` - */ - YAP_FLAG(BACK_QUOTES_FLAG, "back_quotes", true, isatom, "true", NULL), - /**< `bounded` is iso - - Read-only flag telling whether integers are bounded. The value depends - on whether YAP uses the GMP library or not. - */ - - YAP_FLAG(BOUNDED_FLAG, "bounded", false, booleanFlag, "false", - NULL), - YAP_FLAG(C_CC_FLAG, "c_cc", false, isatom, C_CC, NULL), - YAP_FLAG(C_CFLAGS_FLAG, "c_cflags", false, isatom, C_CFLAGS, NULL), - YAP_FLAG(C_LDFLAGS_FLAG, "c_ldflags", false, isatom, C_LDFLAGS, NULL), - YAP_FLAG(C_LIBPLSO_FLAG, "c_libplso", false, isatom, C_LIBPLSO, NULL), - YAP_FLAG(C_LIBS_FLAG, "c_libs", false, isatom, C_LIBS, NULL), - /**< `char_conversion is iso` - - Writable flag telling whether a character conversion table is used when - reading terms. The default value for this flag is `off` except in - `sicstus` and `iso` language modes, where it is `on`. - */ - YAP_FLAG(CHAR_CONVERSION_FLAG, "char_conversion", true, booleanFlag, - "false", NULL), - /**< `character_escapes is iso ` - - Writable flag telling whether a character escapes are enables, - `true`, or disabled, `false`. The default value for this flag is - `true`. */ - YAP_FLAG(CHARACTER_ESCAPES_FLAG, "character_escapes", true, booleanFlag, - "true", NULL), - YAP_FLAG(COLON_SETS_CALLING_CONTEXT_FLAG, "colon_sets_calling_context", - true, booleanFlag, "true", NULL), - /**< `compiled_at ` - - Read-only flag that gives the time when the main YAP binary was compiled. It is - obtained staight from the __TIME__ macro, as defined in the C99. - */ - YAP_FLAG(COMPILED_AT_FLAG, "compiled_at", false, isatom, YAP_COMPILED_AT, - NULL), - /**< `debug is iso ` - - If _Value_ is unbound, tell whether debugging is `true` or - `false`. If _Value_ is bound to `true` enable debugging, and if - it is bound to `false` disable debugging. - */ - YAP_FLAG(DEBUG_FLAG, "debug", true, booleanFlag, "false", - NULL), - YAP_FLAG(DEBUG_INFO_FLAG, "debug_info", true, booleanFlag, "true", NULL), - YAP_FLAG(DEBUG_ON_ERROR_FLAG, "debug_on_error", true, booleanFlag, "true", - NULL), - /**< `debugger_print_options ` - - If bound, set the argument to the `write_term/3` options the - debugger uses to write terms. If unbound, show the current options. - */ - YAP_FLAG(DEBUGGER_PRINT_OPTIONS_FLAG, "debugger_print_options", true, - list_option, - "[quoted(true),numbervars(true),portrayed(true),max_depth(10)]", - NULL), - YAP_FLAG(DEBUGGER_SHOW_CONTEXT_FLAG, "debugger_show_context", true, - booleanFlag, "false", NULL), - /**< `dialect ` - - Read-only flag that always returns `yap`. - */ - YAP_FLAG(DIALECT_FLAG, "dialect", false, ro, "yap", - NULL), - /**< `discontiguous_warnings ` - - If `true` (default `true`) YAP checks for definitions of the same predicate that - are separated by clauses for other predicates. This may indicate that different - procedures have the same name. - - The declaration discontiguous/1 disables this warning for user-specified - predicates. - - */ - YAP_FLAG(DISCONTIGUOUS_WARNINGS_FLAG, "discontiguous_warnings", true, - booleanFlag, "true", NULL), - /**< `dollar_as_lower_case ` - - If `off` (default) consider the character `$` a control character, if - `on` consider `$` a lower case character. - */ - YAP_FLAG(DOLLAR_AS_LOWER_CASE_FLAG, "dollar_as_lower_case", true, - booleanFlag, "false", - NULL), - /**< `double_quotes is iso ` - - If _Value_ is unbound, tell whether a double quoted list of characters - token is converted to a list of atoms, `chars`, to a list of integers, - `codes`, or to a single atom, `atom`. If _Value_ is bound, set to - the corresponding behavior. The default value is `codes`. */ - YAP_FLAG(DOUBLE_QUOTES_FLAG, "double_quotes", true, isatom, "codes", - dqs), - YAP_FLAG(EDITOR_FLAG, "editor", true, isatom, "$EDITOR", NULL), - /**< `executable ` - - Read-only flag. It unifies with an atom that gives the - original program path. - */ - YAP_FLAG(EXECUTABLE_FLAG, "executable", false, executable, "@boot", - NULL), - /**< `fast ` - - If `on` allow fast machine code, if `off` (default) disable it. Only - available in experimental implementations. - */ - YAP_FLAG(FAST_FLAG, "fast", true, booleanFlag, "false", NULL), - YAP_FLAG(FILE_NAME_VARIABLES_FLAG, "file_name_variables", true, booleanFlag, - "true", NULL), - /**< + `float_format ` - - C-library `printf()` format specification used by write/1 and - friends to determine how floating point numbers are printed. The - default is `%.15g`. The specified value is passed to `printf()` - without further checking. For example, if you want less digits - printed, `%g` will print all floats using 6 digits instead of the - default 15. - */ - YAP_FLAG(FLOAT_FORMAT_FLAG, "float_format", true, isatom, "%.16f", - NULL), - /**< `gc` - - If `on` allow garbage collection (default), if `off` disable it. - */ - YAP_FLAG(GC_FLAG, "gc", true, booleanFlag, "on", NULL), - /**< `gc_margin ` - - Set or show the minimum free stack before starting garbage - collection. The default depends on total stack size. - - */ - YAP_FLAG(GC_MARGIN_FLAG, "gc_margin", true, nat, "0", - gc_margin), - /**< `gc_trace ` - - If `off` (default) do not show information on garbage collection - and stack shifts, if `on` inform when a garbage collection or stack - shift happened, if verbose give detailed information on garbage - collection and stack shifts. Last, if `very_verbose` give detailed - information on data-structures found during the garbage collection - process, namely, on choice-points. - */ - YAP_FLAG(GC_TRACE_FLAG, "gc_trace", true, isatom, "off", - NULL), - /**< `generate_debug_info ` - - If `true` (default) generate debugging information for - procedures, including source mode. If `false` predicates no - information is generated, although debugging is still possible, and - source mode is disabled. - - */ - YAP_FLAG(GENERATE_DEBUGGING_INFO_FLAG, "generate_debug_info", true, - booleanFlag, "true", NULL), - YAP_FLAG(GMP_VERSION_FLAG, "gmp_version", false, isatom, "4.8.12", NULL), - YAP_FLAG(HALT_AFTER_CONSULT_FLAG, "halt_after_consult", false, booleanFlag, - "false", NULL), - /**< home ` - - the root of the YAP installation, by default `/usr/local` in Unix or - `c:\Yap` in Windows system. Can only be set at configure time - */ - YAP_FLAG(HOME_FLAG, "home", false, isatom, YAP_ROOTDIR, NULL), - /**< host_type ` - - Return `configure` system information, including the machine-id - for which YAP was compiled and Operating System information. - */ - YAP_FLAG(HOST_TYPE_FLAG, "host_type", false, isatom, HOST_ALIAS, - NULL), - /**< `index ` - - If `on` allow indexing (default), if `off` disable it, if - `single` allow on first argument only. - */ - YAP_FLAG(INDEX_FLAG, "index", true, indexer, "multi", NULL), - /**< `Index_sub_term_search_depth ` - - Maximum bound on searching sub-terms for indexing, if `0` (default) no bound. - */ - YAP_FLAG(INDEX_SUB_TERM_SEARCH_DEPTH_FLAG, "index_sub_term_search_depth", - true, nat, "0", NULL), - /**< `informational_messages ` - - If `on` allow printing of informational messages, such as the ones - that are printed when consulting. If `off` disable printing - these messages. It is `on` by default except if YAP is booted with - the `-L` flag. - */ - YAP_FLAG(INFORMATIONAL_MESSAGES_FLAG, "informational_messages", true, - isatom, "normal", NULL), - /**< `integer_rounding_function is iso ` - - Read-only flag telling the rounding function used for integers. Takes the value - `toward_zero` for the current version of YAP. - */ - YAP_FLAG(INTEGER_ROUNDING_FUNCTION_FLAG, "integer_rounding_function", true, - isatom, "toward_zero", - NULL), - YAP_FLAG(ISO_FLAG, "iso", true, booleanFlag, "false", NULL), - /**< `language ` - - Choose whether YAP follows native, closer to C-Prolog, `yap`, iso-prolog, - `iso` or SICStus Prolog, `sicstus`. The current default is - `cprolog`. This flag affects update semantics, leashing mode, - style checking, handling calls to undefined procedures, how directives - are interpreted, when to use dynamic, character escapes, and how files - are consulted. Also check the `dialect` option. - */ - YAP_FLAG(LANGUAGE_FLAG, "language", true, isatom, "yap", - NULL), - /**< if defined, first location where YAP expects to find the YAP Prolog library. Takes precedence over library_directory */ - YAP_FLAG(PROLOG_LIBRARY_DIRECTORY_FLAG, "prolog_library_directory", true, isatom, "", NULL), - - /**< if defined, first location where YAP expects to find the YAP Prolog shared libraries (DLLS). Takes precedence over executable_directory/2. */ - YAP_FLAG(PROLOG_FOREIGN_DIRECTORY_FLAG, "prolog_foreign_directory", true, isatom, "", NULL), - - /**< `max_arity is iso ` - - Read-only flag telling the maximum arity of a functor. Takes the value - `unbounded` for the current version of YAP. - */ - YAP_FLAG(MAX_ARITY_FLAG, "max_arity", false, isatom, "unbounded", - NULL), - YAP_FLAG(MAX_TAGGED_INTEGER_FLAG, "max_tagged_integer", false, at2n, - "INT_MAX", NULL), - YAP_FLAG(MAX_THREADS_FLAG, "max_threads", false, at2n, "MAX_THREADS", NULL), - YAP_FLAG(MAX_WORKERS_FLAG, "max_workers", false, at2n, "MAX_WORKERS", NULL), - YAP_FLAG(MIN_TAGGED_INTEGER_FLAG, "min_tagged_integer", false, at2n, - "INT_MIN", NULL), - YAP_FLAG(N_OF_INTEGER_KEYS_IN_DB_FLAG, "n_of_integer_keys_in_db", false, ro, - "256", NULL), - YAP_FLAG(OCCURS_CHECK_FLAG, "occurs_check", true, booleanFlag, "false", - NULL), - /**< `open_expands_filename ` - - If `true` the open/3 builtin performs filename-expansion - before opening a file (SICStus Prolog like). If `false` it does not - (SWI-Prolog like). - */ - YAP_FLAG(OPEN_EXPANDS_FILENAME_FLAG, "open_expands_filename", true, - booleanFlag, "false", NULL), - /**< `open_shared_object ` - - If true, `open_shared_object/2` and friends are implemented, - providing access to shared libraries (`.so` files) or to dynamic link - libraries (`.DLL` files). - */ - YAP_FLAG(OPEN_SHARED_OBJECT_FLAG, "open_shared_object", true, booleanFlag, - "true", NULL), - /**< `module_independent_operators ` - - If `true` an operator declaration will be valid for every module in the - program. This is for compatibility with old software that - might expect module-independent operators. - */ - // YAP_FLAG(MODULE_INDEPENDENT_OPERATORS_FLAG, - // "module_independent_operators", true, booleanFlag, - // "false", NULL), - - YAP_FLAG(OPTIMISE_FLAG, "optimise", true, booleanFlag, "false", NULL), - YAP_FLAG(OS_ARGV_FLAG, "os_argv", false, os_argv, "@boot", NULL), - YAP_FLAG(PID_FLAG, "pid", false, sys_pid, "@boot", NULL), - YAP_FLAG(PIPE_FLAG, "pipe", true, booleanFlag, "true", NULL), - /**< `profiling ` - - If `off` (default) do not compile call counting information for - procedures. If `on` compile predicates so that they calls and - retries to the predicate may be counted. Profiling data can be read through the - call_count_data/3 built-in. - */ - YAP_FLAG(PROFILING_FLAG, "profiling", true, booleanFlag, "false", - NULL), - /**< `prompt_alternatives_on(atom, - changeable) ` - - SWI-Compatible option, determines prompting for alternatives in the Prolog - toplevel. Default is groundness, YAP prompts for alternatives if and - only if the query contains variables. The alternative, default in SWI-Prolog is - determinism which implies the system prompts for alternatives if the - goal succeeded while leaving choicepoints. */ - YAP_FLAG(PROMPT_ALTERNATIVES_ON_FLAG, "prompt_alternatives_on", true, - isatom, "determinism", NULL), - YAP_FLAG(QUASI_QUOTATIONS_FLAG, "quasi_quotations", true, booleanFlag, - "true", NULL), - /**< `readline(boolean, changeable)` - } - - enable the use of the readline library for console interactions, true by default - if readline was found. */ - YAP_FLAG(READLINE_FLAG, "readline", true, booleanFlag, "false", - Yap_InitReadline), - YAP_FLAG(REPORT_ERROR_FLAG, "report_error", true, booleanFlag, "true", - NULL), - /**<`resource_database` - Name of the resource file (saved-state or Prolog file) used to construct - the YAP - run-time environment. - */ - YAP_FLAG(RESOURCE_DATABASE_FLAG, "resource_database", false, isatom, - YAP_BOOTSTRAP, NULL), - - /**<`saved_program` - if `true` YAP booted from a `yss` file, usually `startup.yss'. If - `false`, YAP booted from a Prolog file, by default `boot.yap`. - */ - YAP_FLAG(SAVED_PROGRAM_FLAG, "saved_program", false, booleanFlag, "false", - NULL), - - /**< `shared_object_extension ` - - Suffix associated with loadable code. - */ - YAP_FLAG(SHARED_OBJECT_EXTENSION_FLAG, "shared_object_extension", false, - isatom, SO_EXT, NULL), - /**< `shared_object_search_path ` - - Name of the environment variable used by the system to search for shared - objects. - - */ - YAP_FLAG(SHARED_OBJECT_SEARCH_PATH_FLAG, "shared_object_search_path", true, - isatom, SO_PATH, NULL), - /**< `single_quoted text is usuallly interpreted as atoms. This flagTerm allows other inerpretations such as strings_contains_strings */ - YAP_FLAG(SINGLE_QUOTES_FLAG, "single_quotes", true, isatom, "atom", - sqf), - - /**< `signals` - - If `true` (default) YAP handles Signals such as `^C` - (`SIGINT`). - - */ - YAP_FLAG(SIGNALS_FLAG, "signals", true, booleanFlag, "true", - NULL), - /**< `source` - - If `true` maintain the source for all clauses. Notice that this is trivially - supported for facts, and always supported for dynamic code. - - */ - YAP_FLAG(SOURCE_FLAG, "source", true, booleanFlag, "true", - NULL), - /**< `strict_iso ` - - If _Value_ is unbound, tell whether strict ISO compatibility mode - is `on` or `off`. If _Value_ is bound to `on` set - language mode to `iso` and enable strict mode. If _Value_ is - bound to `off` disable strict mode, and keep the current language - mode. The default for YAP is `off`. - Under strict ISO Prolog mode all calls to non-ISO built-ins generate an - error. Compilation of clauses that would call non-ISO built-ins will - also generate errors. Pre-processing for grammar rules is also - disabled. Module expansion is still performed. - Arguably, ISO Prolog does not provide all the functionality required - from a modern Prolog system. Moreover, because most Prolog - implementations do not fully implement the standard and because the - standard itself gives the implementor latitude in a few important - questions, such as the unification algorithm and maximum size for - numbers there is no guarantee that programs compliant with this mode - will work the same way in every Prolog and in every platform. We thus - believe this mode is mostly useful when investigating how a program - depends on a Prolog's platform specific features. - - */ - YAP_FLAG(STRICT_ISO_FLAG, "strict_iso", true, booleanFlag, "false", - NULL), - /**< `system_options ` - - This read only flag tells which options were used to compile - YAP. Currently it informs whether the system supports `big_numbers`, - `coroutining`, `depth_limit`, `low_level_tracer`, - `or-parallelism`, `rational_trees`, `readline`, `tabling`, - `threads`, or the `wam_profiler`. - */ - YAP_FLAG(SYSTEM_OPTIONS_FLAG, "system_options", false, options, - SYSTEM_OPTIONS, NULL), - YAP_FLAG(SYSTEM_THREAD_ID_FLAG, "system_thread_id", false, sys_thread_id, - "@boot", NULL), - /**< `tabling_mode` - - Sets or reads the tabling mode for all tabled predicates. Please - (see Tabling) for the list of options. - - */ - YAP_FLAG(TABLING_MODE_FLAG, "tabling_mode", true, isatom, "[]", - NULL), - YAP_FLAG(THREADS_FLAG, "threads", false, ro, "MAX_THREADS", NULL), - YAP_FLAG(TIMEZONE_FLAG, "timezone", false, ro, "18000", NULL), - YAP_FLAG(TOPLEVEL_PRINT_ANON_FLAG, "toplevel_print_anon", true, booleanFlag, - "true", NULL), - /**< `toplevel_hook ` - - If bound, set the argument to a goal to be executed before entering the - top-level. If unbound show the current goal or `true` if none is - presented. Only the first solution is considered and the goal is not - backtracked into. - - */ - YAP_FLAG(TOPLEVEL_PRINT_OPTIONS_FLAG, "toplevel_print_options", true, - list_option, "[quoted(true),numbervars(true),portrayed(true)]", - NULL), - YAP_FLAG(TOPLEVEL_PROMPT_FLAG, "toplevel_prompt", true, isatom, "?- ", - mkprompt), - YAP_FLAG(TTY_CONTROL_FLAG, "tty_control", true, booleanFlag, "true", NULL), - /**< `unix` - - Read-only BooleanFlag flag that unifies with `true` if YAP is - running on an Unix system. Defined if the C-compiler used to compile - this version of YAP either defines `__unix__` or `unix`. - */ - YAP_FLAG(UNIX_FLAG, "unix", false, ro, "true", NULL), - /**< `update_semantics ` - - Define whether YAP should follow `immediate` update - semantics, as in C-Prolog (default), `logical` update semantics, - as in Quintus Prolog, SICStus Prolog, or in the ISO standard. There is - also an intermediate mode, `logical_assert`, where dynamic - procedures follow logical semantics but the internal data base still - follows immediate semantics. - */ - YAP_FLAG(UPDATE_SEMANTICS_FLAG, "update_semantics", true, isatom, "logical", - NULL), - /**< - `user_flags ` - - Define the behaviour of set_prolog_flag/2 if the flag is not known. Values - are `silent`, `warning` and `error`. The first two create the flag - on-the-fly, with `warning` printing a message. The value `error` is - consistent with ISO: it raises an existence error and does not create the - flag. See also `create_prolog_flag/3`. The default is`error`, and developers - are encouraged to use `create_prolog_flag/3` to create flags for their - library. - */ - YAP_FLAG(USER_FLAGS_FLAG, "user_flags", true, isatom, "error", NULL), - /**< `unknown is iso` - - Corresponds to calling the unknown/2 built-in. Possible ISO values - are `error`, `fail`, and `warning`. Yap includes the following extensions: - `fast_fail` does not invoke any handler. - */ - YAP_FLAG(UNKNOWN_FLAG, "unknown", true, isatom, "error", - Yap_unknown), - YAP_FLAG(VARIABLE_NAMES_MAY_END_WITH_QUOTES_FLAG, - "variable_names_may_end_with_quotes", true, booleanFlag, "false", - NULL), - /**< `verbose ` - - If `normal` allow printing of informational and banner messages, - such as the ones that are printed when consulting. If `silent` - disable printing these messages. It is `normal` by default except if - YAP is booted with the `-q` or `-L` flag. - - */ - YAP_FLAG(VERBOSE_FLAG, "verbose", true, isatom, "normal", - NULL), - YAP_FLAG(VERBOSE_AUTOLOAD_FLAG, "verbose_autoload", true, booleanFlag, - "false", NULL), - /**< `verbose_file_search ` - - If `true` allow printing of informational messages when - searching for file names. If `false` disable printing these messages. It - is `false` by default except if YAP is booted with the `-L` - flag. - */ - YAP_FLAG(VERBOSE_FILE_SEARCH_FLAG, "verbose_file_search", true, booleanFlag, - "false", NULL), - /**< `verbose_load ` - - If `true` allow printing of informational messages when - consulting files. If `false` disable printing these messages. It - is `normal` by default except if YAP is booted with the `-L` - flag. - */ - YAP_FLAG(VERBOSE_LOAD_FLAG, "verbose_load", true, isatom, "normal", - NULL), - /**< `version_data ` - - Read-only flag that unifies with a number of the form - `_Major_ * 100000 + _Minor_ *100 + _Patch_`, where - _Major_ is the major version, _Minor_ is the minor version, - and _Patch_ is the patch number. - */ - YAP_FLAG(VERSION_FLAG, "version", false, nat, YAP_NUMERIC_VERSION, - NULL), - /**< - `version ` Read-only flag that returns a compound term with the - current version of YAP. The term will have the name `yap` and arity 4, the first - argument will be the - major version, the second the minor version, the third the patch number, and the - last one is reserved. - - */ - YAP_FLAG(VERSION_DATA_FLAG, "version_data", false, ro, YAP_TVERSION, - NULL), - /**< `version_git ` - ` - this is the unique identifier for the last commit of the current GIT HEAD, it - xan be used to identify versions that differ on small (or large) updates. - */ - YAP_FLAG(VERSION_GIT_FLAG, "version_git", false, isatom, YAP_GIT_HEAD, - NULL), - YAP_FLAG(WRITE_ATTRIBUTES_FLAG, "write_attributes", true, isatom, "ignore", - NULL), + + + YAP_FLAG(ARCH_FLAG, "arch", false, isatom, YAP_ARCH, NULL),/**< + `apple`: read-only atom, it describes the ISA used in this version of YAP. + Available from YAP_AEH. + */ + + YAP_FLAG(ARGV_FLAG, "argv", false, argv, "@boot", NULL), + /**< `arithmetic_exceptions` + + Read-write flag telling whether arithmetic exceptions generate + Prolog exceptions. If enabled: + + ~~~ + ?- X is 2/0. + ERROR!! + ZERO DIVISOR ERROR- X is Exp + ~~~ + + If disabled: + ~~~ + ?- X is 2/0. + X = (+inf). + ~~~ + + It is `true` by default, but it is disabled by packages like CLP(BN) and + ProbLog. + */ + YAP_FLAG(ARITHMETIC_EXCEPTIONS_FLAG, "arithmetic_exceptions", true, + booleanFlag, "true", NULL), + /**> + If _Value_ is unbound, tell whether a back quoted list of characters + token is converted to a list of atoms, `chars`, to a list of integers, + `codes`, or to a single atom, `atom`. If _Value_ is bound, set to + the corresponding behavior. The default value is `string` + */ + YAP_FLAG(BACK_QUOTES_FLAG, "back_quotes", true, isatom, "true", NULL), + /**< `bounded` is iso + + Read-only flag telling whether integers are bounded. The value depends + on whether YAP uses the GMP library or not. + */ + + YAP_FLAG(BOUNDED_FLAG, "bounded", false, booleanFlag, "false", NULL), + YAP_FLAG(C_CC_FLAG, "c_cc", false, isatom, C_CC, NULL), + YAP_FLAG(C_CFLAGS_FLAG, "c_cflags", false, isatom, C_CFLAGS, NULL), + YAP_FLAG(C_LDFLAGS_FLAG, "c_ldflags", false, isatom, C_LDFLAGS, NULL), + YAP_FLAG(C_LIBPLSO_FLAG, "c_libplso", false, isatom, C_LIBPLSO, NULL), + YAP_FLAG(C_LIBS_FLAG, "c_libs", false, isatom, C_LIBS, NULL), + /**< `char_conversion is iso` + + Writable flag telling whether a character conversion table is used when + reading terms. The default value for this flag is `off` except in + `sicstus` and `iso` language modes, where it is `on`. + */ + YAP_FLAG(CHAR_CONVERSION_FLAG, "char_conversion", true, booleanFlag, + "false", NULL), + /**< `character_escapes is iso ` + + Writable flag telling whether a character escapes are enables, + `true`, or disabled, `false`. The default value for this flag is + `true`. */ + YAP_FLAG(CHARACTER_ESCAPES_FLAG, "character_escapes", true, booleanFlag, + "true", NULL), + YAP_FLAG(COLON_SETS_CALLING_CONTEXT_FLAG, "colon_sets_calling_context", + true, booleanFlag, "true", NULL), + /**< `compiled_at ` + + Read-only flag that gives the time when the main YAP binary was compiled. It + is obtained staight from the __TIME__ macro, as defined in the C99. + */ + YAP_FLAG(COMPILED_AT_FLAG, "compiled_at", false, isatom, YAP_COMPILED_AT, + NULL), + /**< `debug is iso ` + + If _Value_ is unbound, tell whether debugging is `true` or + `false`. If _Value_ is bound to `true` enable debugging, and if + it is bound to `false` disable debugging. + */ + YAP_FLAG(DEBUG_FLAG, "debug", true, booleanFlag, "false", NULL), + YAP_FLAG(DEBUG_INFO_FLAG, "debug_info", true, booleanFlag, "true", NULL), + YAP_FLAG(DEBUG_ON_ERROR_FLAG, "debug_on_error", true, booleanFlag, "true", + NULL), + /**< `debugger_print_options ` + + If bound, set the argument to the `write_term/3` options the + debugger uses to write terms. If unbound, show the current options. + */ + YAP_FLAG(DEBUGGER_PRINT_OPTIONS_FLAG, "debugger_print_options", true, + list_option, + "[quoted(true),numbervars(true),portrayed(true),max_depth(10)]", + NULL), + YAP_FLAG(DEBUGGER_SHOW_CONTEXT_FLAG, "debugger_show_context", true, + booleanFlag, "false", NULL), + /**< `dialect ` + + Read-only flag that always returns `yap`. + */ + YAP_FLAG(DIALECT_FLAG, "dialect", false, ro, "yap", NULL), + /**< `discontiguous_warnings ` + + If `true` (default `true`) YAP checks for definitions of the same predicate + that are separated by clauses for other predicates. This may indicate that + different procedures have the same name. + + The declaration discontiguous/1 disables this warning for user-specified + predicates. + + */ + YAP_FLAG(DISCONTIGUOUS_WARNINGS_FLAG, "discontiguous_warnings", true, + booleanFlag, "true", NULL), + /**< `dollar_as_lower_case ` + + If `off` (default) consider the character `$` a control character, if + `on` consider `$` a lower case character. + */ + YAP_FLAG(DOLLAR_AS_LOWER_CASE_FLAG, "dollar_as_lower_case", true, + booleanFlag, "false", NULL), + /**< `double_quotes is iso ` + + If _Value_ is unbound, tell whether a double quoted list of characters + token is converted to a list of atoms, `chars`, to a list of integers, + `codes`, or to a single atom, `atom`. If _Value_ is bound, set to + the corresponding behavior. The default value is `codes`. */ + YAP_FLAG(DOUBLE_QUOTES_FLAG, "double_quotes", true, isatom, "codes", dqs), + YAP_FLAG(EDITOR_FLAG, "editor", true, isatom, "$EDITOR", NULL), + /**< `executable ` + + Read-only flag. It unifies with an atom that gives the + original program path. + */ + YAP_FLAG(EXECUTABLE_FLAG, "executable", false, executable, "@boot", NULL), + /**< `fast ` + + If `on` allow fast machine code, if `off` (default) disable it. Only + available in experimental implementations. + */ + YAP_FLAG(FAST_FLAG, "fast", true, booleanFlag, "false", NULL), + YAP_FLAG(FILE_NAME_VARIABLES_FLAG, "file_name_variables", true, booleanFlag, + "true", NULL), + /**< + `float_format ` + + C-library `printf()` format specification used by write/1 and + friends to determine how floating point numbers are printed. The + default is `%.15g`. The specified value is passed to `printf()` + without further checking. For example, if you want less digits + printed, `%g` will print all floats using 6 digits instead of the + default 15. + */ + YAP_FLAG(FLOAT_FORMAT_FLAG, "float_format", true, isatom, "%.16f", NULL), + /**< `gc` + + If `on` allow garbage collection (default), if `off` disable it. + */ + YAP_FLAG(GC_FLAG, "gc", true, booleanFlag, "on", NULL), + /**< `gc_margin ` + + Set or show the minimum free stack before starting garbage + collection. The default depends on total stack size. + + */ + YAP_FLAG(GC_MARGIN_FLAG, "gc_margin", true, nat, "0", gc_margin), + /**< `gc_trace ` + + If `off` (default) do not show information on garbage collection + and stack shifts, if `on` inform when a garbage collection or stack + shift happened, if verbose give detailed information on garbage + collection and stack shifts. Last, if `very_verbose` give detailed + information on data-structures found during the garbage collection + process, namely, on choice-points. + */ + YAP_FLAG(GC_TRACE_FLAG, "gc_trace", true, isatom, "off", NULL), + /**< `generate_debug_info ` + + If `true` (default) generate debugging information for + procedures, including source mode. If `false` predicates no + information is generated, although debugging is still possible, and + source mode is disabled. + + */ + YAP_FLAG(GENERATE_DEBUGGING_INFO_FLAG, "generate_debug_info", true, + booleanFlag, "true", NULL), + YAP_FLAG(GMP_VERSION_FLAG, "gmp_version", false, isatom, "4.8.12", NULL), + YAP_FLAG(HALT_AFTER_CONSULT_FLAG, "halt_after_consult", false, booleanFlag, + "false", NULL), + /**< home ` + + the root of the YAP installation, by default `/usr/local` in Unix or + `c:\Yap` in Windows system. Can only be set at configure time + */ + YAP_FLAG(HOME_FLAG, "home", false, isatom, YAP_ROOTDIR, NULL), + /**< host_type ` + + Return `configure` system information, including the machine-id + for which YAP was compiled and Operating System information. + */ + YAP_FLAG(HOST_TYPE_FLAG, "host_type", false, isatom, HOST_ALIAS, NULL), + /**< `index ` + + If `on` allow indexing (default), if `off` disable it, if + `single` allow on first argument only. + */ + YAP_FLAG(INDEX_FLAG, "index", true, indexer, "multi", NULL), + /**< `Index_sub_term_search_depth ` + + Maximum bound on searching sub-terms for indexing, if `0` (default) no + bound. + */ + YAP_FLAG(INDEX_SUB_TERM_SEARCH_DEPTH_FLAG, "index_sub_term_search_depth", + true, nat, "0", NULL), + /**< `informational_messages ` + + If `on` allow printing of informational messages, such as the ones + that are printed when consulting. If `off` disable printing + these messages. It is `on` by default except if YAP is booted with + the `-L` flag. + */ + YAP_FLAG(INFORMATIONAL_MESSAGES_FLAG, "informational_messages", true, + isatom, "normal", NULL), + /**< `integer_rounding_function is iso ` + + Read-only flag telling the rounding function used for integers. Takes the + value `toward_zero` for the current version of YAP. + */ + YAP_FLAG(INTEGER_ROUNDING_FUNCTION_FLAG, "integer_rounding_function", true, + isatom, "toward_zero", NULL), + YAP_FLAG(ISO_FLAG, "iso", true, booleanFlag, "false", NULL), + /**< `language ` + + Choose whether YAP follows native, closer to C-Prolog, `yap`, iso-prolog, + `iso` or SICStus Prolog, `sicstus`. The current default is + `cprolog`. This flag affects update semantics, leashing mode, + style checking, handling calls to undefined procedures, how directives + are interpreted, when to use dynamic, character escapes, and how files + are consulted. Also check the `dialect` option. + */ + YAP_FLAG(LANGUAGE_FLAG, "language", true, isatom, "yap", NULL), + /**< if defined, first location where YAP expects to find the YAP Prolog + library. Takes precedence over library_directory */ + YAP_FLAG(PROLOG_LIBRARY_DIRECTORY_FLAG, "prolog_library_directory", true, + isatom, "", NULL), + + /**< if defined, first location where YAP expects to find the YAP Prolog + shared libraries (DLLS). Takes precedence over executable_directory/2. */ + YAP_FLAG(PROLOG_FOREIGN_DIRECTORY_FLAG, "prolog_foreign_directory", true, + isatom, "", NULL), + + /**< `max_arity is iso ` + + Read-only flag telling the maximum arity of a functor. Takes the value + `unbounded` for the current version of YAP. + */ + YAP_FLAG(MAX_ARITY_FLAG, "max_arity", false, isatom, "unbounded", NULL), + YAP_FLAG(MAX_TAGGED_INTEGER_FLAG, "max_tagged_integer", false, at2n, + "INT_MAX", NULL), + YAP_FLAG(MAX_THREADS_FLAG, "max_threads", false, at2n, "MAX_THREADS", NULL), + YAP_FLAG(MAX_WORKERS_FLAG, "max_workers", false, at2n, "MAX_WORKERS", NULL), + YAP_FLAG(MIN_TAGGED_INTEGER_FLAG, "min_tagged_integer", false, at2n, + "INT_MIN", NULL), + YAP_FLAG(N_OF_INTEGER_KEYS_IN_DB_FLAG, "n_of_integer_keys_in_db", false, ro, + "256", NULL), + YAP_FLAG(OCCURS_CHECK_FLAG, "occurs_check", true, booleanFlag, "false", + NULL), + /**< `open_expands_filename ` + + If `true` the open/3 builtin performs filename-expansion + before opening a file (SICStus Prolog like). If `false` it does not + (SWI-Prolog like). + */ + YAP_FLAG(OPEN_EXPANDS_FILENAME_FLAG, "open_expands_filename", true, + booleanFlag, "false", NULL), + /**< `open_shared_object ` + + If true, `open_shared_object/2` and friends are implemented, + providing access to shared libraries (`.so` files) or to dynamic link + libraries (`.DLL` files). + */ + YAP_FLAG(OPEN_SHARED_OBJECT_FLAG, "open_shared_object", true, booleanFlag, + "true", NULL), + /**< `module_independent_operators ` + + If `true` an operator declaration will be valid for every module in the + program. This is for compatibility with old software that + might expect module-independent operators. + */ + // YAP_FLAG(MODULE_INDEPENDENT_OPERATORS_FLAG, + // "module_independent_operators", true, booleanFlag, + // "false", NULL), + + YAP_FLAG(OPTIMISE_FLAG, "optimise", true, booleanFlag, "false", NULL), + YAP_FLAG(OS_ARGV_FLAG, "os_argv", false, os_argv, "@boot", NULL), + YAP_FLAG(PID_FLAG, "pid", false, sys_pid, "@boot", NULL), + YAP_FLAG(PIPE_FLAG, "pipe", true, booleanFlag, "true", NULL), + /**< `profiling ` + + If `off` (default) do not compile call counting information for + procedures. If `on` compile predicates so that they calls and + retries to the predicate may be counted. Profiling data can be read through + the call_count_data/3 built-in. + */ + YAP_FLAG(PROFILING_FLAG, "profiling", true, booleanFlag, "false", NULL), + /**< `prompt_alternatives_on(atom, + changeable) ` + + SWI-Compatible option, determines prompting for alternatives in the Prolog + toplevel. Default is groundness, YAP prompts for alternatives if + and only if the query contains variables. The alternative, default in + SWI-Prolog is determinism which implies the system prompts for + alternatives if the goal succeeded while leaving choicepoints. */ + YAP_FLAG(PROMPT_ALTERNATIVES_ON_FLAG, "prompt_alternatives_on", true, + isatom, "determinism", NULL), + YAP_FLAG(QUASI_QUOTATIONS_FLAG, "quasi_quotations", true, booleanFlag, + "true", NULL), + /**< `readline(boolean, changeable)` + } + + enable the use of the readline library for console interactions, true by + default if readline was found. */ + YAP_FLAG(READLINE_FLAG, "readline", true, booleanFlag, "false", + Yap_InitReadline), + YAP_FLAG(REPORT_ERROR_FLAG, "report_error", true, booleanFlag, "true", + NULL), + /**<`resource_database` + Name of the resource file (saved-state or Prolog file) used to construct + the YAP + run-time environment. + */ + YAP_FLAG(RESOURCE_DATABASE_FLAG, "resource_database", false, isatom, + YAP_BOOTSTRAP, NULL), + + /**<`saved_program` + if `true` YAP booted from a `yss` file, usually `startup.yss'. If + `false`, YAP booted from a Prolog file, by default `boot.yap`. + */ + YAP_FLAG(SAVED_PROGRAM_FLAG, "saved_program", false, booleanFlag, "false", + NULL), + + /**< `shared_object_extension ` + + Suffix associated with loadable code. + */ + YAP_FLAG(SHARED_OBJECT_EXTENSION_FLAG, "shared_object_extension", false, + isatom, SO_EXT, NULL), + /**< `shared_object_search_path ` + + Name of the environment variable used by the system to search for shared + objects. + + */ + YAP_FLAG(SHARED_OBJECT_SEARCH_PATH_FLAG, "shared_object_search_path", true, + isatom, SO_PATH, NULL), + /**< `single_quoted text is usuallly interpreted as atoms. This flagTerm + allows other inerpretations such as strings_contains_strings */ + YAP_FLAG(SINGLE_QUOTES_FLAG, "single_quotes", true, isatom, "atom", sqf), + + /**< `signals` + + If `true` (default) YAP handles Signals such as `^C` + (`SIGINT`). + + */ + YAP_FLAG(SIGNALS_FLAG, "signals", true, booleanFlag, "true", NULL), + /**< `source` + + If `true` maintain the source for all clauses. Notice that this is trivially + supported for facts, and always supported for dynamic code. + + */ + YAP_FLAG(SOURCE_FLAG, "source", true, booleanFlag, "true", NULL), + /**< `strict_iso ` + + If _Value_ is unbound, tell whether strict ISO compatibility mode + is `on` or `off`. If _Value_ is bound to `on` set + language mode to `iso` and enable strict mode. If _Value_ is + bound to `off` disable strict mode, and keep the current language + mode. The default for YAP is `off`. + Under strict ISO Prolog mode all calls to non-ISO built-ins generate an + error. Compilation of clauses that would call non-ISO built-ins will + also generate errors. Pre-processing for grammar rules is also + disabled. Module expansion is still performed. + Arguably, ISO Prolog does not provide all the functionality required + from a modern Prolog system. Moreover, because most Prolog + implementations do not fully implement the standard and because the + standard itself gives the implementor latitude in a few important + questions, such as the unification algorithm and maximum size for + numbers there is no guarantee that programs compliant with this mode + will work the same way in every Prolog and in every platform. We thus + believe this mode is mostly useful when investigating how a program + depends on a Prolog's platform specific features. + + */ + YAP_FLAG(STRICT_ISO_FLAG, "strict_iso", true, booleanFlag, "false", NULL), + /**< `system_options ` + + This read only flag tells which options were used to compile + YAP. Currently it informs whether the system supports `big_numbers`, + `coroutining`, `depth_limit`, `low_level_tracer`, + `or-parallelism`, `rational_trees`, `readline`, `tabling`, + `threads`, or the `wam_profiler`. + */ + YAP_FLAG(SYSTEM_OPTIONS_FLAG, "system_options", false, options, + SYSTEM_OPTIONS, NULL), + YAP_FLAG(SYSTEM_THREAD_ID_FLAG, "system_thread_id", false, sys_thread_id, + "@boot", NULL), + /**< `tabling_mode` + + Sets or reads the tabling mode for all tabled predicates. Please + (see Tabling) for the list of options. + + */ + YAP_FLAG(TABLING_MODE_FLAG, "tabling_mode", true, isatom, "[]", NULL), + YAP_FLAG(THREADS_FLAG, "threads", false, ro, "MAX_THREADS", NULL), + YAP_FLAG(TIMEZONE_FLAG, "timezone", false, ro, "18000", NULL), + YAP_FLAG(TOPLEVEL_PRINT_ANON_FLAG, "toplevel_print_anon", true, booleanFlag, + "true", NULL), + /**< `toplevel_hook ` + + If bound, set the argument to a goal to be executed before entering the + top-level. If unbound show the current goal or `true` if none is + presented. Only the first solution is considered and the goal is not + backtracked into. + + */ + YAP_FLAG(TOPLEVEL_PRINT_OPTIONS_FLAG, "toplevel_print_options", true, + list_option, "[quoted(true),numbervars(true),portrayed(true)]", + NULL), + YAP_FLAG(TOPLEVEL_PROMPT_FLAG, "toplevel_prompt", true, isatom, "?- ", + mkprompt), + YAP_FLAG(TTY_CONTROL_FLAG, "tty_control", true, booleanFlag, "true", NULL), + /**< `unix` + + Read-only BooleanFlag flag that unifies with `true` if YAP is + running on an Unix system. Defined if the C-compiler used to compile + this version of YAP either defines `__unix__` or `unix`. + */ + YAP_FLAG(UNIX_FLAG, "unix", false, ro, "true", NULL), + /**< `update_semantics ` + + Define whether YAP should follow `immediate` update + semantics, as in C-Prolog (default), `logical` update semantics, + as in Quintus Prolog, SICStus Prolog, or in the ISO standard. There is + also an intermediate mode, `logical_assert`, where dynamic + procedures follow logical semantics but the internal data base still + follows immediate semantics. + */ + YAP_FLAG(UPDATE_SEMANTICS_FLAG, "update_semantics", true, isatom, "logical", + NULL), + /**< + `user_flags ` + + Define the behaviour of set_prolog_flag/2 if the flag is not known. Values + are `silent`, `warning` and `error`. The first two create the flag + on-the-fly, with `warning` printing a message. The value `error` is + consistent with ISO: it raises an existence error and does not create the + flag. See also `create_prolog_flag/3`. The default is`error`, and developers + are encouraged to use `create_prolog_flag/3` to create flags for their + library. + */ + YAP_FLAG(USER_FLAGS_FLAG, "user_flags", true, isatom, "error", NULL), + /**< `unknown is iso` + + Corresponds to calling the unknown/2 built-in. Possible ISO values + are `error`, `fail`, and `warning`. Yap includes the following extensions: + `fast_fail` does not invoke any handler. + */ + YAP_FLAG(UNKNOWN_FLAG, "unknown", true, isatom, "error", Yap_unknown), + YAP_FLAG(VARIABLE_NAMES_MAY_END_WITH_QUOTES_FLAG, + "variable_names_may_end_with_quotes", true, booleanFlag, "false", + NULL), + /**< `verbose ` + + If `normal` allow printing of informational and banner messages, + such as the ones that are printed when consulting. If `silent` + disable printing these messages. It is `normal` by default except if + YAP is booted with the `-q` or `-L` flag. + + */ + YAP_FLAG(VERBOSE_FLAG, "verbose", true, isatom, "normal", NULL), + YAP_FLAG(VERBOSE_AUTOLOAD_FLAG, "verbose_autoload", true, booleanFlag, + "false", NULL), + /**< `verbose_file_search ` + + If `true` allow printing of informational messages when + searching for file names. If `false` disable printing these messages. It + is `false` by default except if YAP is booted with the `-L` + flag. + */ + YAP_FLAG(VERBOSE_FILE_SEARCH_FLAG, "verbose_file_search", true, booleanFlag, + "false", NULL), + /**< `verbose_load ` + + If `true` allow printing of informational messages when + consulting files. If `false` disable printing these messages. It + is `normal` by default except if YAP is booted with the `-L` + flag. + */ + YAP_FLAG(VERBOSE_LOAD_FLAG, "verbose_load", true, isatom, "normal", NULL), + /**< `version_data ` + + Read-only flag that unifies with a number of the form + `_Major_ * 100000 + _Minor_ *100 + _Patch_`, where + _Major_ is the major version, _Minor_ is the minor version, + and _Patch_ is the patch number. + */ + YAP_FLAG(VERSION_FLAG, "version", false, nat, YAP_NUMERIC_VERSION, NULL), + /**< + `version ` Read-only flag that returns a compound term with the + current version of YAP. The term will have the name `yap` and arity 4, the + first argument will be the major version, the second the minor version, the + third the patch number, and the last one is reserved. + + */ + YAP_FLAG(VERSION_DATA_FLAG, "version_data", false, ro, YAP_TVERSION, NULL), + /**< `version_git ` + ` + this is the unique identifier for the last commit of the current GIT HEAD, + it xan be used to identify versions that differ on small (or large) updates. + */ + YAP_FLAG(VERSION_GIT_FLAG, "version_git", false, isatom, YAP_GIT_HEAD, + NULL), + YAP_FLAG(WRITE_ATTRIBUTES_FLAG, "write_attributes", true, isatom, "ignore", + NULL), #if __WINDOWS__ - /**< `windows` + /**< `windows` - Read-only booleanFlag flag that unifies with `true` if YAP is - running on an Windows machine. - */ - YAP_FLAG(WINDOWS_FLAG, "windows", false, ro, "true", NULL), + Read-only booleanFlag flag that unifies with `true` if YAP is + running on an Windows machine. + */ + YAP_FLAG(WINDOWS_FLAG, "windows", false, ro, "true", NULL), #endif - /**< `write_strings ` + /**< `write_strings ` - Writable flag telling whether the system should write lists of - integers that are writable character codes using the list notation. It - is `on` if enables or `off` if disabled. The default value for - this flag is `off`. - */ - YAP_FLAG(WRITE_STRINGS_FLAG, "write_strings", true, booleanFlag, "false", - NULL), + Writable flag telling whether the system should write lists of + integers that are writable character codes using the list notation. It + is `on` if enables or `off` if disabled. The default value for + this flag is `off`. + */ + YAP_FLAG(WRITE_STRINGS_FLAG, "write_strings", true, booleanFlag, "false", + NULL), - END_GLOBAL_FLAGS + END_GLOBAL_FLAGS -//! @} + //! @} diff --git a/cmake/FindR.cmake b/cmake/FindR.cmake index 1cc3d749e..b64cf144a 100644 --- a/cmake/FindR.cmake +++ b/cmake/FindR.cmake @@ -66,10 +66,12 @@ if(R_COMMAND) find_library(R_LIBRARY_READLINE readline DOC "(Optional) system readline library. Only required if the R libraries were built with readline support.") - - # Note: R_LIBRARY_BASE is added to R_LIBRARIES twice; this may be due to circular linking dependencies; needs further investigation - set(R_LIBRARIES ${R_LIBRARY_BASE} ${R_LIBRARY_BLAS} ${R_LIBRARY_LAPACK} ${R_LIBRARY_BASE}) - if(R_LIBRARY_READLINE) - set(R_LIBRARIES ${R_LIBRARIES} ${R_LIBRARY_READLINE}) - endif() +else() + message(SEND_ERROR "FindR.cmake requires the following variables to be set: R_COMMAND") +endif() + +# Note: R_LIBRARY_BASE is added to R_LIBRARIES twice; this may be due to circular linking dependencies; needs further investigation +set(R_LIBRARIES ${R_LIBRARY_BASE} ${R_LIBRARY_BLAS} ${R_LIBRARY_LAPACK} ${R_LIBRARY_BASE}) +if(R_LIBRARY_READLINE) + set(R_LIBRARIES ${R_LIBRARIES} ${R_LIBRARY_READLINE}) endif() diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 14e688253..ffb771ad0 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -892,14 +892,14 @@ EXCLUDE = # The default value is: NO. EXCLUDE_SYMLINKS = NO - + # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. # # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories for example use the pattern */test/* - + EXCLUDE_PATTERNS = @DOCS_EXCLUDE@ # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names @@ -2109,20 +2109,20 @@ INCLUDE_FILE_PATTERNS = # recursively expanded use the := operator instead of the = operator. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -PREDEFINED = # - # YAP_FLAG(ITEM,NAME,WRITABLE,DEF,INIT,HELPER)=ITEM \ - # START_LOCAL_FLAGS="enum THREAD_LOCAL_FLAGS {" \ - # END_LOCAL_FLAGS=" };"\ - # START_GLOBAL_FLAGS="enum GLOBAL_FLAGS {" \ - # END_GLOBAL_FLAGS="};" \ - # LOCAL(A, B)="A B" \ - # LOCAL_INIT(A, B, C)="A B;B = C" \ - # LOCAL_ARRAY(A, B, C)="A B[C]" \ - # LOCAL_ARRAY_ARRAY(A, B, C,D)="A B[C][D]"\ - # LOCAL_INIT(A, B, C, D)="A B[C][D]"\ - # LOCAL_INITF(A, B, C)=" A B; C"\ - # LOCAL_INIT_RESTORE(A,B,C,D)="A B; C; D;"\ - # PREG=Yap_REGS.P_ +PREDEFINED = \ + YAP_FLAG(ITEM,NAME,WRITABLE,DEF,INIT,HELPER):=NAME \ + START_LOCAL_FLAGS:="enum THREAD_LOCAL_FLAGS {" \ + END_LOCAL_FLAGS:=" };"\ + START_GLOBAL_FLAGS:="enum GLOBAL_FLAGS {" \ + END_GLOBAL_FLAGS:="};" \ + LOCAL(A, B):="A B" \ + LOCAL_INIT(A, B, C):="A B;B := C" \ + LOCAL_ARRAY(A, B, C):="A B[C]" \ + LOCAL_ARRAY_ARRAY(A, B, C,D):="A B[C][D]"\ + LOCAL_INIT(A, B, C, D):="A B[C][D]"\ + LOCAL_INITF(A, B, C):=" A B; C"\ + LOCAL_INIT_RESTORE(A,B,C,D):="A B; C; D;"\ + PREG:=Yap_REGS.P_ # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The @@ -2131,7 +2131,7 @@ PREDEFINED = # # definition found in the source code. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -EXPAND_AS_DEFINED = +EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will # remove all references to function-like macros that are alone on a line, have diff --git a/packages/real/CMakeLists.txt b/packages/real/CMakeLists.txt index 7f5d24bd5..0151bee32 100644 --- a/packages/real/CMakeLists.txt +++ b/packages/real/CMakeLists.txt @@ -19,231 +19,24 @@ # # Variable search order: # 1. Attempt to locate and set R_COMMAND -# - If unsuccessful, generate error and prompt user to manually set R_COMMAND +# If unsuccessful, generate error and prompt user to manually set R_COMMAND # 2. Use R_COMMAND to set R_HOME # 3. Locate other libraries in the priority: # 1. Within a user-built instance of R at R_HOME # 2. Within an installed instance of R # 3. Within external system libraries # + +if (R_LIBRARIES AND R_INCLUDE_DIR) set_package_properties(R PROPERTIES DESCRIPTION "The R Project for Statistical Computing." - URL "https://www.r-project.org/") - -find_program ( - R_COMMAND - NAMES R r -) - -if (R_COMMAND) - # find the R binary - - MESSAGE(STATUS "Looking for R executable") - IF(NOT R_EXECUTABLE) - FIND_PROGRAM(R_EXECUTABLE R) - IF(R_EXECUTABLE-NOTFOUND) - MESSAGE(FATAL_ERROR "Could NOT find R (TODO: name option)") - ELSE(R_EXECUTABLE-NOTFOUND) - MESSAGE(STATUS "Using R at ${R_EXECUTABLE}") - ENDIF(R_EXECUTABLE-NOTFOUND) - - ENDIF(NOT R_EXECUTABLE) - - - # find R_HOME - - MESSAGE(STATUS "Looking for R_HOME") - IF(NOT R_HOME) - EXECUTE_PROCESS( - COMMAND ${R_EXECUTABLE} "--slave" "--no-save" "-e" "cat(R.home())" - OUTPUT_VARIABLE R_HOME) - ENDIF(NOT R_HOME) - IF(NOT R_HOME) - MESSAGE(FATAL_ERROR "Could NOT determine R_HOME (probably you misspecified the location of R)") - ELSE(NOT R_HOME) - MESSAGE(STATUS "R_HOME is ${R_HOME}") - ENDIF(NOT R_HOME) - - # find R include dir - - MESSAGE(STATUS "Looking for R include files") - IF(NOT R_INCLUDEDIR) - IF(WIN32 OR APPLE) # This version of the test will not work with R < 2.9.0, but the other version (in the else part) will not work on windows or apple (but we do not really need to support ancient versions of R, there). - EXECUTE_PROCESS( - COMMAND ${R_EXECUTABLE} "--slave" "--no-save" "-e" "cat(R.home('include'))" - OUTPUT_VARIABLE R_INCLUDEDIR) - ELSE(WIN32 OR APPLE) - EXECUTE_PROCESS( - COMMAND ${R_EXECUTABLE} CMD sh -c "echo -n $R_INCLUDE_DIR" - OUTPUT_VARIABLE R_INCLUDEDIR) - ENDIF(WIN32 OR APPLE) - ELSE(NOT R_INCLUDEDIR) - MESSAGE(STATUS "Location specified by user") - ENDIF(NOT R_INCLUDEDIR) - - IF(NOT R_INCLUDEDIR) - SET(R_INCLUDEDIR ${R_HOME}/include) - MESSAGE(STATUS "Not findable via R. Guessing") - ENDIF(NOT R_INCLUDEDIR) - MESSAGE(STATUS "Include files should be at ${R_INCLUDEDIR}. Checking for R.h") - - IF(NOT R_H) - FIND_FILE(R_H - R.h - PATHS ${R_INCLUDEDIR} - NO_DEFAULT_PATH) - ENDIF(NOT R_H) - - IF(NOT R_H) - MESSAGE(FATAL_ERROR "Not found") - ELSE(NOT R_H) - MESSAGE(STATUS "Found at ${R_H}") - GET_FILENAME_COMPONENT(R_INCLUDEDIR ${R_H} - PATH) - ENDIF(NOT R_H) - - # check for existence of libR.so - - IF(NOT LIBR_SO) - MESSAGE(STATUS "Checking for existence of R shared library") - FIND_LIBRARY(LIBR_SO - R - PATHS ${R_HOME}/lib ${R_SHAREDLIBDIR} ${R_HOME}/bin - NO_DEFAULT_PATH) - endif(NOT LIBR_SO) - - - IF(NOT LIBR_SO) - MESSAGE(FATAL_ERROR "Not found. Make sure the location of R was detected correctly, above, and R was compiled with the --enable-shlib option") - ELSE(NOT LIBR_SO) - MESSAGE(STATUS "Exists at ${LIBR_SO}") - GET_FILENAME_COMPONENT(R_SHAREDLIBDIR ${LIBR_SO} - PATH) - SET(R_USED_LIBS R) - ENDIF(NOT LIBR_SO) - - - # for at least some versions of R, we seem to have to link against -lRlapack. Else loading some - # R packages will fail due to unresolved symbols, or we can't link against -lR. - # However, we can't do this unconditionally, - # as this is not available in some configurations of R - - MESSAGE(STATUS "Checking whether we should link against Rlapack library") - FIND_LIBRARY(LIBR_LAPACK - Rlapack - PATHS ${R_SHAREDLIBDIR} - NO_DEFAULT_PATH) - IF(NOT LIBR_LAPACK) - MESSAGE(STATUS "No, it does not exist in ${R_SHAREDLIBDIR}") - ELSE(NOT LIBR_LAPACK) - MESSAGE(STATUS "Yes, ${LIBR_LAPACK} exists") - SET(R_USED_LIBS ${R_USED_LIBS} Rlapack) - IF(WIN32 OR APPLE) - ELSE(WIN32 OR APPLE) - # needed when linking to Rlapack on linux for some unknown reason. - # apparently not needed on windows (let's see, when it comes back to bite us, though) - # and compiling on windows is hard enough even without requiring libgfortran, too. - SET(R_USED_LIBS ${R_USED_LIBS} gfortran) - ENDIF(WIN32 OR APPLE) - ENDIF(NOT LIBR_LAPACK) - - # for at least some versions of R, we seem to have to link against -lRlapack. Else loading some - # R packages will fail due to unresolved symbols, or we can't link against -lR. - # However, we can't do this unconditionally, - # as this is not available in some configurations of R - - MESSAGE(STATUS "Checking whether we should link against Rblas library") - FIND_LIBRARY(LIBR_BLAS - Rblas - PATHS ${R_SHAREDLIBDIR} - NO_DEFAULT_PATH) - IF(NOT LIBR_BLAS) - MESSAGE(STATUS "No, it does not exist in ${R_SHAREDLIBDIR}") - ELSE(NOT LIBR_BLAS) - MESSAGE(STATUS "Yes, ${LIBR_BLAS} exists") - SET(R_USED_LIBS ${R_USED_LIBS} Rblas) - ENDIF(NOT LIBR_BLAS) - - # find R package library location - IF(WIN32) - SET(PATH_SEP ";") - ELSE(WIN32) - SET(PATH_SEP ":") - ENDIF(WIN32) - - MESSAGE(STATUS "Checking for R package library location to use") - IF(NOT R_LIBDIR) - EXECUTE_PROCESS( - COMMAND ${R_EXECUTABLE} "--slave" "--no-save" "-e" "cat(paste(unique (c(.Library.site, .Library)), collapse='${PATH_SEP}'))" - OUTPUT_VARIABLE R_LIBDIR) - ELSE(NOT R_LIBDIR) - MESSAGE(STATUS "Location specified by user") - ENDIF(NOT R_LIBDIR) - - # strip whitespace - STRING(REGEX REPLACE "[ \n]+" - "" R_LIBDIR - "${R_LIBDIR}") - - # strip leading colon(s) - STRING(REGEX REPLACE "^${PATH_SEP}+" - "" R_LIBDIR - "${R_LIBDIR}") - - # strip trailing colon(s) - STRING(REGEX REPLACE "${PATH_SEP}+$" - "" R_LIBDIR - "${R_LIBDIR}") - - # find first path - STRING(REGEX REPLACE "${PATH_SEP}" - " " R_LIBDIR - "${R_LIBDIR}") - - IF(NOT R_LIBDIR) - MESSAGE(STATUS "Not reliably determined or specified. Guessing.") - SET(R_LIBDIR ${R_HOME}/library) - ENDIF(NOT R_LIBDIR) - - SET(R_LIBDIRS ${R_LIBDIR}) - SEPARATE_ARGUMENTS(R_LIBDIRS) - - SET(R_LIBDIR) - FOREACH(CURRENTDIR ${R_LIBDIRS}) - IF(NOT USE_R_LIBDIR) - IF(EXISTS ${CURRENTDIR}) - SET(R_LIBDIR ${CURRENTDIR}) - SET(USE_R_LIBDIR 1) - ELSE(EXISTS ${CURRENTDIR}) - MESSAGE(STATUS "${CURRENTDIR} does not exist. Skipping") - ENDIF(EXISTS ${CURRENTDIR}) - ENDIF(NOT USE_R_LIBDIR) - ENDFOREACH(CURRENTDIR ${R_LIBDIRS}) - - IF(NOT EXISTS ${R_LIBDIR}) - MESSAGE(FATAL_ERROR "No existing library location found") - ELSE(NOT EXISTS ${R_LIBDIR}) - MESSAGE(STATUS "Will use ${R_LIBDIR}") - ENDIF(NOT EXISTS ${R_LIBDIR}) -endif() -#macro_optional_find_package (R ON) - -if (R_INCLUDEDIR AND R_LIBDIR) - add_feature_info(R yes "Real") - - set (REAL_SOURCES - real.c -) - -set (REAL_PL - real.pl -) - -add_to_group( REAL_PL pl_library) - + + URL "https://www.r-project.org/") +add_lib(real ${REAL_SOURCES}) + target_link_libraries (real ${R_LIBRARIES} libYap) include_directories ( - ${CMAKE_CURRENT_BINARY_DIR} - ${R_INCLUDEDIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${R_INCLUDE_DIR} ) list (APPEND CMAKE_REQUIRED_INCLUDES @@ -251,12 +44,8 @@ include_directories ( ${R_INCLUDE_DIR} ) - add_lib(real ${REAL_SOURCES}) - - target_link_libraries (real ${LIBR_SO} libYap) - check_include_files( "stdio.h;R.h" HAVE_R_H ) - check_include_files( "R.h;Rembedded.h" HAVE_R_EMBEDDED_H ) + check_include_files( "R.h,;Rembedded.h" HAVE_R_EMBEDDED_H ) check_include_files( "Rembedded.h;Rinterface.h" HAVE_R_INTERFACE_H ) configure_file ("rconfig.h.cmake" "rconfig.h" ) diff --git a/pl/control.yap b/pl/control.yap index f4935ddf0..650e81969 100644 --- a/pl/control.yap +++ b/pl/control.yap @@ -82,11 +82,12 @@ @addtogroup YAPControl - -%% @{ +@ingroup builtins */ +%% @{ + /** @pred forall(: _Cond_,: _Action_) @@ -618,13 +619,13 @@ break :- '$break'( false ). -/** +/** * @pred at_halt( G ) * * Hook predicate: _G_ must be called on exit. - * - * @param _G_: the hook - * + * + * @param _G_: the hook + * * @return succeeds with side-effect. */at_halt(G) :- recorda('$halt', G, _), @@ -657,16 +658,16 @@ halt(X) :- set_value('$live','$false'), '$halt'(X). -/** +/** * @pred prolog_current_frame(-Env) * * reports a reference to the last execution environment _Env_. * YAP creates an enviroment when a clause contains several sub-goals. * Facts and simple recursion do not need an environment, - * - * @param Env - * - * @return + * + * @param Env + * + * @return */prolog_current_frame(Env) :- Env is '$env'.