diff --git a/.configure-custom.sh b/.configure-custom.sh index 12243128a..dec040a31 100644 --- a/.configure-custom.sh +++ b/.configure-custom.sh @@ -1,7 +1,9 @@ -ENABLE_VARS="clpbn|yes|WITH_CLPBN \ +ENABLE_VARS="brew|yes|WITH_BREW\ + clpbn|yes|WITH_CLPBN \ cplint|yes|WITH_CPLINT \ horus|yes|WITH_HORUS \ clpr|yes|WITH_CLPR \ + macports|yes|WITH_MACPORTS\ problog|yes|WITH_PROBLOG \ jit|no|WITH_JIT \ chr|no|WITH_CHR \ @@ -10,11 +12,15 @@ WITH_VARS="swig|yes|WITH_SWIG \ mpi|yes|WITH_MPI \ gecode|yes|WITH_GECODE \ docs|yes|WITH_DOCS \ - r|yes|WITH_REAL \ + r|yes|WITH_R \ + myddas|yes|WITH_MYDDAS \ cudd|yes|WITH_CUDD \ xml2|yes|WITH_XML2 \ raptor|yes|WITH_RAPTOR \ python|yes|WITH_PYTHON \ openssl|yes|WITH_OPENSSL\ + java|yes|WITH_JAVA + lbfgs|yes|WITH_LBFGS + extensions|yes|WITH_EXTENSIONS readline|yes|WITH_READLINE \ - gmp|yes|WITH_GMP " + gmp|yes|WITH_GMP" diff --git a/.gitignore b/.gitignore index 0b74c14d2..faccf25e8 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ *.dll docs/yap.info* .build +build tags TGSautom4te.cache cscope.* @@ -24,7 +25,6 @@ tmtags* .Rhistory .zedstate config.h -Yap.h YapConfig.h YapTermConfig.h .graffiti @@ -42,7 +42,6 @@ groups .cproject .dir-locals.el .DS_store -.kateproject .project .pydevproject .Rhistory @@ -150,7 +149,7 @@ yap-6.3.workspace yap-6.3.geany YAP.project CBlocks -yPQ +yPQ *.tmp YAP.sublime* yap32 @@ -203,4 +202,16 @@ mxe build library/system/#CMakeLists.txt# -*.txt# \ No newline at end of file +*.txt# +cmake/CMakeCache.txt + +C/compiling_error.txt + +cmake/compile_commands.json + +cmake/cudd_config.h + +cmake/docs/Doxyfile + +*.stackdump +*.gz diff --git a/C/absmi.c b/C/absmi.c index 75f207f91..76f9cfc73 100755 --- a/C/absmi.c +++ b/C/absmi.c @@ -22,25 +22,49 @@ @file absmi.c -@defgroup Efficiency Efficiency Considerations -@ingroup YAPProgramming +@{ We next discuss several issues on trying to make Prolog programs run fast in YAP. We assume two different programming styles: -+ Execution of deterministic programs ofte -n ++ Execution of deterministic programs often boils down to a recursive loop of the form: ~~~~~ +loop(Done). loop(Env) :- do_something(Env,NewEnv), loop(NewEnv). ~~~~~ + +or to the repeat-fail loop: + +~~~~~ +loop(Inp) :- + do_something(Inp,Out), + out_and_fail(Out). +~~~~~ + + +@} + +@defgroup Implementation Implementation Considerations +@ingroup YAPProgramming + +This section is about the YAP implementation, and is mostly of +interest to hackers. + +@{ + +@defgroup Emulator The Abstract Machine Emulator +@ingroup Implementation + */ +/// code belongs to the emulator #define IN_ABSMI_C 1 #define _INATIVE 1 +/// use tmp variables that are placed in registers #define HAS_CACHE_REGS 1 #include "absmi.h" @@ -195,12 +219,12 @@ static int check_alarm_fail_int(int CONT USES_REGS) { } static int stack_overflow(PredEntry *pe, CELL *env, yamop *cp, - arity_t nargs USES_REGS) { + arity_t nargs USES_REGS) { if (Unsigned(YREG) - Unsigned(HR) < StackGap(PASS_REGS1) || Yap_get_signal(YAP_STOVF_SIGNAL)) { S = (CELL *)pe; if (!Yap_locked_gc(nargs, env, cp)) { - Yap_NilError(RESOURCE_ERROR_STACK, LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK, "stack overflow: gc failed"); return 0; } return 1; @@ -215,7 +239,7 @@ static int code_overflow(CELL *yenv USES_REGS) { /* do a garbage collection first to check if we can recover memory */ if (!Yap_locked_growheap(false, 0, NULL)) { Yap_NilError(RESOURCE_ERROR_HEAP, "YAP failed to grow heap: %s", - LOCAL_ErrorMessage); + "malloc/mmap failed"); return 0; } CACHE_A1(); @@ -502,8 +526,8 @@ static int interrupt_execute(USES_REGS1) { } if (PP) UNLOCKPE(1, PP); - PP = P->y_u.pp.p0; - if ((P->y_u.pp.p->PredFlags & (NoTracePredFlag | HiddenPredFlag)) && + PP = P->y_u.Osbpp.p0; + if ((P->y_u.Osbpp.p->PredFlags & (NoTracePredFlag | HiddenPredFlag)) && Yap_only_has_signal(YAP_CREEP_SIGNAL)) { return 2; } @@ -511,11 +535,11 @@ static int interrupt_execute(USES_REGS1) { if ((v = code_overflow(YENV PASS_REGS)) >= 0) { return v; } - if ((v = stack_overflow(P->y_u.pp.p, ENV, CP, - P->y_u.pp.p->ArityOfPE PASS_REGS)) >= 0) { + if ((v = stack_overflow(P->y_u.Osbpp.p, ENV, CP, + P->y_u.Osbpp.p->ArityOfPE PASS_REGS)) >= 0) { return v; } - return interrupt_handler(P->y_u.pp.p PASS_REGS); + return interrupt_handler(P->y_u.Osbpp.p PASS_REGS); } static int interrupt_call(USES_REGS1) { @@ -665,7 +689,7 @@ static int interrupt_deallocate(USES_REGS1) { return rc; } if (!Yap_locked_gc(0, ENV, YESCODE)) { - Yap_NilError(RESOURCE_ERROR_STACK, LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK, "stack overflow: gc failed"); } S = ASP; S[E_CB] = (CELL)(LCL0 - cut_b); @@ -840,8 +864,8 @@ static int interrupt_dexecute(USES_REGS1) { #endif if (PP) UNLOCKPE(1, PP); - PP = P->y_u.pp.p0; - pe = P->y_u.pp.p; + PP = P->y_u.Osbpp.p0; + pe = P->y_u.Osbpp.p; if ((pe->PredFlags & (NoTracePredFlag | HiddenPredFlag)) && Yap_only_has_signal(YAP_CREEP_SIGNAL)) { return 2; @@ -853,8 +877,8 @@ static int interrupt_dexecute(USES_REGS1) { if ((v = code_overflow(YENV PASS_REGS)) >= 0) { return v; } - if ((v = stack_overflow(P->y_u.pp.p, (CELL *)YENV[E_E], (yamop *)YENV[E_CP], - P->y_u.pp.p->ArityOfPE PASS_REGS)) >= 0) { + if ((v = stack_overflow(P->y_u.Osbpp.p, (CELL *)YENV[E_E], (yamop *)YENV[E_CP], + P->y_u.Osbpp.p->ArityOfPE PASS_REGS)) >= 0) { return v; } /* first, deallocate */ @@ -892,7 +916,6 @@ static int interrupt_dexecute(USES_REGS1) { static void undef_goal(USES_REGS1) { PredEntry *pe = PredFromDefCode(P); - BEGD(d0); /* avoid trouble with undefined dynamic procedures */ /* I assume they were not locked beforehand */ @@ -902,12 +925,26 @@ static void undef_goal(USES_REGS1) { PP = pe; } #endif - if (pe->PredFlags & (DynamicPredFlag | LogUpdatePredFlag | MultiFileFlag) || - pe == UndefCode) { + if (pe->PredFlags & (DynamicPredFlag | LogUpdatePredFlag | MultiFileFlag) ) { +#if defined(YAPOR) || defined(THREADS) + UNLOCKPE(19, PP); + PP = NULL; +#endif + CalculateStackGap(PASS_REGS1); + P = FAILCODE; + return; + } + if (UndefCode == NULL || UndefCode->OpcodeOfPred == UNDEF_OPCODE) { + fprintf(stderr,"call to undefined Predicates %s ->", IndicatorOfPred(pe)); + Yap_DebugPlWriteln(ARG1); + fputc(':', stderr); + Yap_DebugPlWriteln(ARG2); + fprintf(stderr," error handler not available, failing\n"); #if defined(YAPOR) || defined(THREADS) UNLOCKPE(19, PP); PP = NULL; #endif + CalculateStackGap(PASS_REGS1); P = FAILCODE; return; } @@ -915,16 +952,16 @@ static void undef_goal(USES_REGS1) { UNLOCKPE(19, PP); PP = NULL; #endif - d0 = pe->ArityOfPE; - if (d0 == 0) { - HR[1] = MkAtomTerm((Atom)(pe->FunctorOfPred)); + if (pe->ArityOfPE == 0) { + d0 = MkAtomTerm((Atom)(pe->FunctorOfPred)); } else { - HR[d0 + 2] = AbsAppl(HR); - *HR = (CELL)pe->FunctorOfPred; - HR++; + d0 = AbsAppl(HR); + *HR++ = (CELL)pe->FunctorOfPred; + CELL *ip=HR, *imax = HR+pe->ArityOfPE; + HR = imax; BEGP(pt1); pt1 = XREGS + 1; - for (; d0 > 0; --d0) { + for (; ip < imax; ip++) { BEGD(d1); BEGP(pt0); pt0 = pt1++; @@ -932,18 +969,17 @@ static void undef_goal(USES_REGS1) { deref_head(d1, undef_unk); undef_nonvar: /* just copy it to the heap */ - *HR++ = d1; + *ip = d1; continue; derefa_body(d1, pt0, undef_unk, undef_nonvar); if (pt0 <= HR) { /* variable is safe */ - *HR++ = (CELL)pt0; + *ip = (CELL)pt0; } else { /* bind it, in case it is a local variable */ - d1 = Unsigned(HR); - RESET_VARIABLE(HR); - HR += 1; + d1 = Unsigned(ip); + RESET_VARIABLE(ip); Bind_Local(pt0, d1); } ENDP(pt0); @@ -951,11 +987,20 @@ static void undef_goal(USES_REGS1) { } ENDP(pt1); } - ENDD(d0); - HR[0] = Yap_Module_Name(pe); - ARG1 = (Term)AbsPair(HR); + ARG1 = AbsPair(HR); + HR[1] = d0; +ENDD(d0); + if (pe->ModuleOfPred == PROLOG_MODULE) { + if (CurrentModule == PROLOG_MODULE) + HR[0] = TermProlog; + else + HR[0] = CurrentModule; + } else { + HR[0] = Yap_Module_Name(pe); + } ARG2 = Yap_getUnknownModule(Yap_GetModuleEntry(HR[0])); HR += 2; + #ifdef LOW_LEVEL_TRACER if (Yap_do_low_level_trace) low_level_trace(enter_pred, UndefCode, XREGS + 1); @@ -1146,7 +1191,6 @@ Int Yap_absmi(int inp) { #ifdef SHADOW_S register CELL *SREG = Yap_REGS.S_; #else -#define SREG S #endif /* SHADOW_S */ /* The indexing register so that we will not destroy ARG1 without @@ -1420,3 +1464,7 @@ default: /* dummy function that is needed for profiler */ int Yap_absmiEND(void) { return 1; } + +/// @} + +/// @} diff --git a/C/absmi_insts.i b/C/absmi_insts.i index 8c70a2895..6e2e8885c 100644 --- a/C/absmi_insts.i +++ b/C/absmi_insts.i @@ -1102,7 +1102,7 @@ PP = NULL; #endif if (!Yap_gc(3, ENV, CP)) { - Yap_NilError(RESOURCE_ERROR_STACK, LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK, "stack overflow: gc failed"); FAIL(); } #if defined(YAPOR) || defined(THREADS) @@ -1226,7 +1226,7 @@ PREG = NEXTOP(PREG,Osbpa); saveregs(); if (!Yap_gcl(sz, arity, YENV, PREG)) { - Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,"stack overflow: gc failed"); setregs(); FAIL(); } else { @@ -10927,7 +10927,7 @@ /* make sure we have something to show for our trouble */ saveregs(); if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,xxx),Osbpp))) { - Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,"stack overflow: gc failed"); setregs(); JMPNext(); } else { @@ -11044,7 +11044,7 @@ /* make sure we have something to show for our trouble */ saveregs(); if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,xxc),Osbpp))) { - Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,"stack overflow: gc failed"); setregs(); JMPNext(); } else { @@ -11154,7 +11154,7 @@ /* make sure we have something to show for our trouble */ saveregs(); if (!Yap_gc(0, YREG, NEXTOP(NEXTOP(PREG,xxn),Osbpp))) { - Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,"stack overflow: gc failed"); setregs(); JMPNext(); } else { @@ -11261,7 +11261,7 @@ /* make sure we have something to show for our trouble */ saveregs(); if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,yxx),Osbpp))) { - Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,"stack overflow: gc failed"); setregs(); JMPNext(); } else { @@ -11388,7 +11388,7 @@ /* make sure we have something to show for our trouble */ saveregs(); if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,yxc),Osbpp))) { - Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,"stack overflow: gc failed"); setregs(); JMPNext(); } else { @@ -11516,7 +11516,7 @@ /* make sure we have something to show for our trouble */ saveregs(); if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,yxn),Osbpp))) { - Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,"stack overflow: gc failed"); setregs(); JMPNext(); } else { @@ -11892,7 +11892,7 @@ /* make sure we have something to show for our trouble */ saveregs(); if (!Yap_gcl((1+d1)*sizeof(CELL), 3, YREG, NEXTOP(NEXTOP(PREG,e),Osbmp))) { - Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,"stack overflow: gc failed" ); setregs(); JMPNext(); } else { diff --git a/C/adtdefs.c b/C/adtdefs.c index f067d5965..87ea9c6b4 100755 --- a/C/adtdefs.c +++ b/C/adtdefs.c @@ -27,6 +27,7 @@ static char SccsId[] = "%W% %G%"; #include "Yap.h" #include "Yatom.h" #include "clause.h" +#include "alloc.h" #include "yapio.h" #include #include @@ -45,9 +46,9 @@ uint64_t HashFunction(const unsigned char *CHP) { } return hash; /* - UInt OUT=0, i = 1; - while(*CHP != '\0') { OUT += (UInt)(*CHP++); } - return OUT; + UInt OUT=0, i = 1; + while(*CHP != '\0') { OUT += (UInt)(*CHP++); } + return OUT; */ } @@ -133,11 +134,12 @@ inline static Atom SearchInInvisible(const unsigned char *atom) { static inline Atom SearchAtom(const unsigned char *p, Atom a) { AtomEntry *ae; + const char *ps = (const char *)p; /* search atom in chain */ while (a != NIL) { ae = RepAtom(a); - if (strcmp((char *)ae->StrOfAE, (const char *)p) == 0) { + if (strcmp(ae->StrOfAE, ps) == 0) { return (a); } a = ae->NextOfAE; @@ -145,6 +147,30 @@ static inline Atom SearchAtom(const unsigned char *p, Atom a) { return (NIL); } +Atom +Yap_AtomInUse(const char *atom) { /* lookup atom in atom table */ + uint64_t hash; + const unsigned char *p; + Atom a, na = NIL; + size_t sz = AtomHashTableSize; + + /* compute hash */ + p =( const unsigned char *) atom; + + hash = HashFunction(p); + hash = hash % sz; + /* we'll start by holding a read lock in order to avoid contention */ + READ_LOCK(HashChain[hash].AERWLock); + a = HashChain[hash].Entry; + /* search atom in chain */ + na = SearchAtom(p, a); + if (na != NIL ) { + READ_UNLOCK(HashChain[hash].AERWLock); + return (na); + } + READ_UNLOCK(HashChain[hash].AERWLock); + return NIL; +} static Atom LookupAtom(const unsigned char *atom) { /* lookup atom in atom table */ @@ -178,27 +204,35 @@ LookupAtom(const unsigned char *atom) { /* lookup atom in atom table */ na = SearchAtom(atom, a); if (na != NIL) { WRITE_UNLOCK(HashChain[hash].AERWLock); - return (na); + return na; } } #endif /* add new atom to start of chain */ - ae = (AtomEntry *)Yap_AllocAtomSpace((sizeof *ae) + - strlen((const char *)atom) + 1); + if (atom[0] == '\0') { + sz = YAP_ALIGN; + } else { + sz = strlen((const char *)atom); + } + size_t asz = (sizeof *ae) + ( sz+1); + ae = malloc(asz); if (ae == NULL) { WRITE_UNLOCK(HashChain[hash].AERWLock); return NIL; } + // enable fast hashing by making sure that + // the last cell is fully initialized. + CELL *aec = (CELL*)ae; + aec[asz/(YAP_ALIGN+1)-1] = 0; NOfAtoms++; na = AbsAtom(ae); ae->PropsOfAE = NIL; - if (ae->UStrOfAE != atom) - strcpy((char *)ae->StrOfAE, (const char *)atom); + strcpy(ae->StrOfAE, (const char *)atom); + ae->NextOfAE = a; HashChain[hash].Entry = na; INIT_RWLOCK(ae->ARWLock); WRITE_UNLOCK(HashChain[hash].AERWLock); - if (NOfAtoms > 2 * AtomHashTableSize) { Yap_signal(YAP_CDOVF_SIGNAL); } @@ -207,1061 +241,1062 @@ LookupAtom(const unsigned char *atom) { /* lookup atom in atom table */ } Atom Yap_LookupAtomWithLength(const char *atom, - size_t len0) { /* lookup atom in atom table */ - Atom at; - unsigned char *ptr; + size_t len0) { /* lookup atom in atom table */ + Atom at; + unsigned char *ptr; - /* not really a wide atom */ - ptr = Yap_AllocCodeSpace(len0 + 1); - if (!ptr) - return NIL; - memcpy(ptr, atom, len0); - ptr[len0] = '\0'; + /* not really a wide atom */ + ptr = Yap_AllocCodeSpace(len0 + 1); + if (!ptr) + return NIL; + memmove(ptr, atom, len0); + ptr[len0] = '\0'; at = LookupAtom(ptr); - Yap_FreeCodeSpace(ptr); - return at; -} - -Atom Yap_LookupAtom(const char *atom) { /* lookup atom in atom table */ - return LookupAtom((const unsigned char *)atom); -} - -Atom Yap_ULookupAtom( - const unsigned char *atom) { /* lookup atom in atom table */ - return LookupAtom(atom); -} - - -Atom Yap_FullLookupAtom(const char *atom) { /* lookup atom in atom table */ - Atom t; - - if ((t = SearchInInvisible((const unsigned char *)atom)) != NIL) { - return (t); + Yap_FreeCodeSpace(ptr); + return at; } - return (LookupAtom((const unsigned char *)atom)); -} -void Yap_LookupAtomWithAddress(const char *atom, - AtomEntry *ae) { /* lookup atom in atom table */ - register CELL hash; - register const unsigned char *p; - Atom a; + Atom Yap_LookupAtom(const char *atom) { /* lookup atom in atom table */ + return LookupAtom((const unsigned char *)atom); + } - /* compute hash */ - p = (const unsigned char *)atom; - hash = HashFunction(p) % AtomHashTableSize; - /* ask for a WRITE lock because it is highly unlikely we shall find anything - */ - WRITE_LOCK(HashChain[hash].AERWLock); - a = HashChain[hash].Entry; - /* search atom in chain */ - if (SearchAtom(p, a) != NIL) { - Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, - "repeated initialization for atom %s", ae); + Atom Yap_ULookupAtom( + const unsigned char *atom) { /* lookup atom in atom table */ + return LookupAtom(atom); + } + + + Atom Yap_FullLookupAtom(const char *atom) { /* lookup atom in atom table */ + Atom t; + + if ((t = SearchInInvisible((const unsigned char *)atom)) != NIL) { + return (t); + } + return (LookupAtom((const unsigned char *)atom)); + } + + void Yap_LookupAtomWithAddress(const char *atom, + AtomEntry *ae) { /* lookup atom in atom table */ + register CELL hash; + register const unsigned char *p; + Atom a; + + /* compute hash */ + p = (const unsigned char *)atom; + hash = HashFunction(p) % AtomHashTableSize; + /* ask for a WRITE lock because it is highly unlikely we shall find anything + */ + WRITE_LOCK(HashChain[hash].AERWLock); + a = HashChain[hash].Entry; + /* search atom in chain */ + if (SearchAtom(p, a) != NIL) { + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, + "repeated initialization for atom %s", ae); + WRITE_UNLOCK(HashChain[hash].AERWLock); + return; + } + /* add new atom to start of chain */ + NOfAtoms++; + ae->NextOfAE = a; + HashChain[hash].Entry = AbsAtom(ae); + ae->PropsOfAE = NIL; + strcpy((char *)ae->StrOfAE, (char *)atom); + INIT_RWLOCK(ae->ARWLock); WRITE_UNLOCK(HashChain[hash].AERWLock); - return; } - /* add new atom to start of chain */ - NOfAtoms++; - ae->NextOfAE = a; - HashChain[hash].Entry = AbsAtom(ae); - ae->PropsOfAE = NIL; - strcpy((char *)ae->StrOfAE, (char *)atom); - INIT_RWLOCK(ae->ARWLock); - WRITE_UNLOCK(HashChain[hash].AERWLock); -} -void Yap_ReleaseAtom(Atom atom) { /* Releases an atom from the hash chain */ - register Int hash; - register const unsigned char *p; - AtomEntry *inChain; - AtomEntry *ap = RepAtom(atom); - char unsigned *name = ap->UStrOfAE; + void Yap_ReleaseAtom(Atom atom) { /* Releases an atom from the hash chain */ + register Int hash; + register const unsigned char *p; + AtomEntry *inChain; + AtomEntry *ap = RepAtom(atom); + char unsigned *name = ap->UStrOfAE; - /* compute hash */ - p = name; - hash = HashFunction(p) % AtomHashTableSize; - WRITE_LOCK(HashChain[hash].AERWLock); - if (HashChain[hash].Entry == atom) { - NOfAtoms--; - HashChain[hash].Entry = ap->NextOfAE; + /* compute hash */ + p = name; + hash = HashFunction(p) % AtomHashTableSize; + WRITE_LOCK(HashChain[hash].AERWLock); + if (HashChain[hash].Entry == atom) { + NOfAtoms--; + HashChain[hash].Entry = ap->NextOfAE; + WRITE_UNLOCK(HashChain[hash].AERWLock); + return; + } + /* else */ + inChain = RepAtom(HashChain[hash].Entry); + while (inChain && inChain->NextOfAE != atom) + inChain = RepAtom(inChain->NextOfAE); + if (!inChain) + return; + WRITE_LOCK(inChain->ARWLock); + inChain->NextOfAE = ap->NextOfAE; + WRITE_UNLOCK(inChain->ARWLock); WRITE_UNLOCK(HashChain[hash].AERWLock); - return; + ap->NextOfAE = NULL; } - /* else */ - inChain = RepAtom(HashChain[hash].Entry); - while (inChain && inChain->NextOfAE != atom) - inChain = RepAtom(inChain->NextOfAE); - if (!inChain) - return; - WRITE_LOCK(inChain->ARWLock); - inChain->NextOfAE = ap->NextOfAE; - WRITE_UNLOCK(inChain->ARWLock); - WRITE_UNLOCK(HashChain[hash].AERWLock); - ap->NextOfAE = NULL; -} -static Prop -GetAPropHavingLock(AtomEntry *ae, - PropFlags kind) { /* look property list of atom a for kind */ - PropEntry *pp; + static Prop + GetAPropHavingLock(AtomEntry *ae, + PropFlags kind) { /* look property list of atom a for kind */ + PropEntry *pp; - pp = RepProp(ae->PropsOfAE); - while (!EndOfPAEntr(pp) && pp->KindOfPE != kind) - pp = RepProp(pp->NextOfPE); - return (AbsProp(pp)); -} + pp = RepProp(ae->PropsOfAE); + while (!EndOfPAEntr(pp) && pp->KindOfPE != kind) + pp = RepProp(pp->NextOfPE); + return (AbsProp(pp)); + } -Prop Yap_GetAPropHavingLock( - AtomEntry *ae, PropFlags kind) { /* look property list of atom a for kind */ - return GetAPropHavingLock(ae, kind); -} + Prop Yap_GetAPropHavingLock( + AtomEntry *ae, PropFlags kind) { /* look property list of atom a for kind */ + return GetAPropHavingLock(ae, kind); + } -static Prop -GetAProp(Atom a, PropFlags kind) { /* look property list of atom a for kind */ - AtomEntry *ae = RepAtom(a); - Prop out; + static Prop + GetAProp(Atom a, PropFlags kind) { /* look property list of atom a for kind */ + AtomEntry *ae = RepAtom(a); + Prop out; - READ_LOCK(ae->ARWLock); - out = GetAPropHavingLock(ae, kind); - READ_UNLOCK(ae->ARWLock); - return (out); -} + READ_LOCK(ae->ARWLock); + out = GetAPropHavingLock(ae, kind); + READ_UNLOCK(ae->ARWLock); + return (out); + } -Prop Yap_GetAProp(Atom a, - PropFlags kind) { /* look property list of atom a for kind */ - return GetAProp(a, kind); -} + Prop Yap_GetAProp(Atom a, + PropFlags kind) { /* look property list of atom a for kind */ + return GetAProp(a, kind); + } -OpEntry *Yap_GetOpPropForAModuleHavingALock( - Atom a, Term mod) { /* look property list of atom a for kind */ - AtomEntry *ae = RepAtom(a); - PropEntry *pp; + OpEntry *Yap_GetOpPropForAModuleHavingALock( + Atom a, Term mod) { /* look property list of atom a for kind */ + AtomEntry *ae = RepAtom(a); + PropEntry *pp; - pp = RepProp(ae->PropsOfAE); - while (!EndOfPAEntr(pp) && - (pp->KindOfPE != OpProperty || ((OpEntry *)pp)->OpModule != mod)) - pp = RepProp(pp->NextOfPE); - if (EndOfPAEntr(pp)) { + pp = RepProp(ae->PropsOfAE); + while (!EndOfPAEntr(pp) && + (pp->KindOfPE != OpProperty || ((OpEntry *)pp)->OpModule != mod)) + pp = RepProp(pp->NextOfPE); + if (EndOfPAEntr(pp)) { + return NULL; + } + return (OpEntry *)pp; + } + + int Yap_HasOp(Atom a) { /* look property list of atom a for kind */ + AtomEntry *ae = RepAtom(a); + PropEntry *pp; + + READ_LOCK(ae->ARWLock); + pp = RepProp(ae->PropsOfAE); + while (!EndOfPAEntr(pp) && (pp->KindOfPE != OpProperty)) + pp = RepProp(pp->NextOfPE); + READ_UNLOCK(ae->ARWLock); + if (EndOfPAEntr(pp)) { + return FALSE; + } else { + return TRUE; + } + } + + OpEntry * + Yap_OpPropForModule(Atom a, + Term mod) { /* look property list of atom a for kind */ + AtomEntry *ae = RepAtom(a); + PropEntry *pp; + OpEntry *info = NULL; + + if (mod == TermProlog) + mod = PROLOG_MODULE; + WRITE_LOCK(ae->ARWLock); + pp = RepProp(ae->PropsOfAE); + while (!EndOfPAEntr(pp)) { + if (pp->KindOfPE == OpProperty) { + info = (OpEntry *)pp; + if (info->OpModule == mod) { + WRITE_LOCK(info->OpRWLock); + WRITE_UNLOCK(ae->ARWLock); + return info; + } + } + pp = pp->NextOfPE; + } + info = (OpEntry *)Yap_AllocAtomSpace(sizeof(OpEntry)); + info->KindOfPE = Ord(OpProperty); + info->NextOfPE = NULL; + info->OpModule = mod; + info->OpName = a; + LOCK(OpListLock); + info->OpNext = OpList; + OpList = info; + UNLOCK(OpListLock); + AddPropToAtom(ae, (PropEntry *)info); + INIT_RWLOCK(info->OpRWLock); + WRITE_LOCK(info->OpRWLock); + WRITE_UNLOCK(ae->ARWLock); + info->Prefix = info->Infix = info->Posfix = 0; + return info; + } + + OpEntry * + Yap_GetOpProp(Atom a, op_type type, + Term cmod USES_REGS) { /* look property list of atom a for kind */ + AtomEntry *ae = RepAtom(a); + PropEntry *pp; + OpEntry *oinfo = NULL; + + READ_LOCK(ae->ARWLock); + pp = RepProp(ae->PropsOfAE); + while (!EndOfPAEntr(pp)) { + OpEntry *info = NULL; + if (pp->KindOfPE != OpProperty) { + pp = RepProp(pp->NextOfPE); + continue; + } + info = (OpEntry *)pp; + if (info->OpModule != cmod && info->OpModule != PROLOG_MODULE) { + pp = RepProp(pp->NextOfPE); + continue; + } + if (type == INFIX_OP) { + if (!info->Infix) { + pp = RepProp(pp->NextOfPE); + continue; + } + } else if (type == POSFIX_OP) { + if (!info->Posfix) { + pp = RepProp(pp->NextOfPE); + continue; + } + } else { + if (!info->Prefix) { + pp = RepProp(pp->NextOfPE); + continue; + } + } + /* if it is not the latest module */ + if (info->OpModule == PROLOG_MODULE) { + /* cannot commit now */ + oinfo = info; + pp = RepProp(pp->NextOfPE); + } else { + READ_LOCK(info->OpRWLock); + READ_UNLOCK(ae->ARWLock); + return info; + } + } + if (oinfo) { + READ_LOCK(oinfo->OpRWLock); + READ_UNLOCK(ae->ARWLock); + return oinfo; + } + READ_UNLOCK(ae->ARWLock); return NULL; } - return (OpEntry *)pp; -} -int Yap_HasOp(Atom a) { /* look property list of atom a for kind */ - AtomEntry *ae = RepAtom(a); - PropEntry *pp; + inline static Prop GetPredPropByAtomHavingLock(AtomEntry *ae, Term cur_mod) + /* get predicate entry for ap/arity; create it if neccessary. */ + { + Prop p0; - READ_LOCK(ae->ARWLock); - pp = RepProp(ae->PropsOfAE); - while (!EndOfPAEntr(pp) && (pp->KindOfPE != OpProperty)) - pp = RepProp(pp->NextOfPE); - READ_UNLOCK(ae->ARWLock); - if (EndOfPAEntr(pp)) { - return FALSE; - } else { + p0 = ae->PropsOfAE; + while (p0) { + PredEntry *pe = RepPredProp(p0); + if (pe->KindOfPE == PEProp && + (pe->ModuleOfPred == cur_mod || !pe->ModuleOfPred)) { + return (p0); +#if THREADS + /* Thread Local Predicates */ + if (pe->PredFlags & ThreadLocalPredFlag) { + return AbsPredProp(Yap_GetThreadPred(pe INIT_REGS)); + } +#endif + } + p0 = pe->NextOfPE; + } + return (NIL); + } + + Prop Yap_GetPredPropByAtom(Atom at, Term cur_mod) + /* get predicate entry for ap/arity; create it if neccessary. */ + { + Prop p0; + AtomEntry *ae = RepAtom(at); + + READ_LOCK(ae->ARWLock); + p0 = GetPredPropByAtomHavingLock(ae, cur_mod); + READ_UNLOCK(ae->ARWLock); + return (p0); + } + + inline static Prop GetPredPropByAtomHavingLockInThisModule(AtomEntry *ae, Term cur_mod) + /* get predicate entry for ap/arity; create it if neccessary. */ + { + Prop p0; + + p0 = ae->PropsOfAE; + while (p0) { + PredEntry *pe = RepPredProp(p0); + if (pe->KindOfPE == PEProp && pe->ModuleOfPred == cur_mod) { +#if THREADS + /* Thread Local Predicates */ + if (pe->PredFlags & ThreadLocalPredFlag) { + return AbsPredProp(Yap_GetThreadPred(pe INIT_REGS)); + } +#endif + return (p0); + } + p0 = pe->NextOfPE; + } + return (NIL); + } + + Prop Yap_GetPredPropByAtomInThisModule(Atom at, Term cur_mod) + /* get predicate entry for ap/arity; create it if neccessary. */ + { + Prop p0; + AtomEntry *ae = RepAtom(at); + + READ_LOCK(ae->ARWLock); + p0 = GetPredPropByAtomHavingLockInThisModule(ae, cur_mod); + READ_UNLOCK(ae->ARWLock); + return (p0); + } + + + Prop Yap_GetPredPropByFunc(Functor f, Term cur_mod) + /* get predicate entry for ap/arity; */ + { + Prop p0; + FUNC_READ_LOCK(f); + + p0 = GetPredPropByFuncHavingLock(f, cur_mod); + + FUNC_READ_UNLOCK(f); + return (p0); + } + + Prop Yap_GetPredPropByFuncInThisModule(Functor f, Term cur_mod) + /* get predicate entry for ap/arity; */ + { + Prop p0; + + FUNC_READ_LOCK(f); + p0 = GetPredPropByFuncHavingLock(f, cur_mod); + FUNC_READ_UNLOCK(f); + return (p0); + } + + Prop Yap_GetPredPropHavingLock(Atom ap, unsigned int arity, Term mod) + /* get predicate entry for ap/arity; */ + { + Prop p0; + AtomEntry *ae = RepAtom(ap); + Functor f; + + if (arity == 0) { + GetPredPropByAtomHavingLock(ae, mod); + } + f = InlinedUnlockedMkFunctor(ae, arity); + FUNC_READ_LOCK(f); + p0 = GetPredPropByFuncHavingLock(f, mod); + FUNC_READ_UNLOCK(f); + return (p0); + } + + /* get expression entry for at/arity; */ + Prop Yap_GetExpProp(Atom at, unsigned int arity) { + Prop p0; + AtomEntry *ae = RepAtom(at); + ExpEntry *p; + + READ_LOCK(ae->ARWLock); + p = RepExpProp(p0 = ae->PropsOfAE); + while (p0 && (p->KindOfPE != ExpProperty || p->ArityOfEE != arity)) + p = RepExpProp(p0 = p->NextOfPE); + READ_UNLOCK(ae->ARWLock); + return (p0); + } + + /* get expression entry for at/arity, at is already locked; */ + Prop Yap_GetExpPropHavingLock(AtomEntry *ae, unsigned int arity) { + Prop p0; + ExpEntry *p; + + p = RepExpProp(p0 = ae->PropsOfAE); + while (p0 && (p->KindOfPE != ExpProperty || p->ArityOfEE != arity)) + p = RepExpProp(p0 = p->NextOfPE); + + return (p0); + } + + static int ExpandPredHash(void) { + UInt new_size = PredHashTableSize + PredHashIncrement; + PredEntry **oldp = PredHash; + PredEntry **np = + (PredEntry **)Yap_AllocAtomSpace(sizeof(PredEntry **) * new_size); + UInt i; + + if (!np) { + return FALSE; + } + for (i = 0; i < new_size; i++) { + np[i] = NULL; + } + for (i = 0; i < PredHashTableSize; i++) { + PredEntry *p = PredHash[i]; + + while (p) { + PredEntry *nextp = p->NextPredOfHash; + UInt hsh = PRED_HASH(p->FunctorOfPred, p->ModuleOfPred, new_size); + p->NextPredOfHash = np[hsh]; + np[hsh] = p; + p = nextp; + } + } + PredHashTableSize = new_size; + PredHash = np; + Yap_FreeAtomSpace((ADDR)oldp); return TRUE; } -} -OpEntry * -Yap_OpPropForModule(Atom a, - Term mod) { /* look property list of atom a for kind */ - AtomEntry *ae = RepAtom(a); - PropEntry *pp; - OpEntry *info = NULL; + /* fe is supposed to be locked */ + Prop Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod) { + PredEntry *p = (PredEntry *)Yap_AllocAtomSpace(sizeof(*p)); - if (mod == TermProlog) - mod = PROLOG_MODULE; - WRITE_LOCK(ae->ARWLock); - pp = RepProp(ae->PropsOfAE); - while (!EndOfPAEntr(pp)) { - if (pp->KindOfPE == OpProperty) { - info = (OpEntry *)pp; - if (info->OpModule == mod) { - WRITE_LOCK(info->OpRWLock); - WRITE_UNLOCK(ae->ARWLock); - return info; - } - } - pp = pp->NextOfPE; - } - info = (OpEntry *)Yap_AllocAtomSpace(sizeof(OpEntry)); - info->KindOfPE = Ord(OpProperty); - info->OpModule = mod; - info->OpName = a; - LOCK(OpListLock); - info->OpNext = OpList; - OpList = info; - UNLOCK(OpListLock); - AddPropToAtom(ae, (PropEntry *)info); - INIT_RWLOCK(info->OpRWLock); - WRITE_LOCK(info->OpRWLock); - WRITE_UNLOCK(ae->ARWLock); - info->Prefix = info->Infix = info->Posfix = 0; - return info; -} - -OpEntry * -Yap_GetOpProp(Atom a, op_type type, - Term cmod USES_REGS) { /* look property list of atom a for kind */ - AtomEntry *ae = RepAtom(a); - PropEntry *pp; - OpEntry *oinfo = NULL; - - READ_LOCK(ae->ARWLock); - pp = RepProp(ae->PropsOfAE); - while (!EndOfPAEntr(pp)) { - OpEntry *info = NULL; - if (pp->KindOfPE != OpProperty) { - pp = RepProp(pp->NextOfPE); - continue; - } - info = (OpEntry *)pp; - if (info->OpModule != cmod && info->OpModule != PROLOG_MODULE) { - pp = RepProp(pp->NextOfPE); - continue; - } - if (type == INFIX_OP) { - if (!info->Infix) { - pp = RepProp(pp->NextOfPE); - continue; - } - } else if (type == POSFIX_OP) { - if (!info->Posfix) { - pp = RepProp(pp->NextOfPE); - continue; - } - } else { - if (!info->Prefix) { - pp = RepProp(pp->NextOfPE); - continue; - } - } - /* if it is not the latest module */ - if (info->OpModule == PROLOG_MODULE) { - /* cannot commit now */ - oinfo = info; - pp = RepProp(pp->NextOfPE); - } else { - READ_LOCK(info->OpRWLock); - READ_UNLOCK(ae->ARWLock); - return info; - } - } - if (oinfo) { - READ_LOCK(oinfo->OpRWLock); - READ_UNLOCK(ae->ARWLock); - return oinfo; - } - READ_UNLOCK(ae->ARWLock); - return NULL; -} - -inline static Prop GetPredPropByAtomHavingLock(AtomEntry *ae, Term cur_mod) -/* get predicate entry for ap/arity; create it if neccessary. */ -{ - Prop p0; - - p0 = ae->PropsOfAE; - while (p0) { - PredEntry *pe = RepPredProp(p0); - if (pe->KindOfPE == PEProp && - (pe->ModuleOfPred == cur_mod || !pe->ModuleOfPred)) { - return (p0); -#if THREADS - /* Thread Local Predicates */ - if (pe->PredFlags & ThreadLocalPredFlag) { - return AbsPredProp(Yap_GetThreadPred(pe INIT_REGS)); - } -#endif - } - p0 = pe->NextOfPE; - } - return (NIL); -} - -Prop Yap_GetPredPropByAtom(Atom at, Term cur_mod) -/* get predicate entry for ap/arity; create it if neccessary. */ -{ - Prop p0; - AtomEntry *ae = RepAtom(at); - - READ_LOCK(ae->ARWLock); - p0 = GetPredPropByAtomHavingLock(ae, cur_mod); - READ_UNLOCK(ae->ARWLock); - return (p0); -} - -inline static Prop GetPredPropByAtomHavingLockInThisModule(AtomEntry *ae, - Term cur_mod) -/* get predicate entry for ap/arity; create it if neccessary. */ -{ - Prop p0; - - p0 = ae->PropsOfAE; - while (p0) { - PredEntry *pe = RepPredProp(p0); - if (pe->KindOfPE == PEProp && pe->ModuleOfPred == cur_mod) { -#if THREADS - /* Thread Local Predicates */ - if (pe->PredFlags & ThreadLocalPredFlag) { - return AbsPredProp(Yap_GetThreadPred(pe INIT_REGS)); - } -#endif - return (p0); - } - p0 = pe->NextOfPE; - } - return (NIL); -} - -Prop Yap_GetPredPropByAtomInThisModule(Atom at, Term cur_mod) -/* get predicate entry for ap/arity; create it if neccessary. */ -{ - Prop p0; - AtomEntry *ae = RepAtom(at); - - READ_LOCK(ae->ARWLock); - p0 = GetPredPropByAtomHavingLockInThisModule(ae, cur_mod); - READ_UNLOCK(ae->ARWLock); - return (p0); -} - -Prop Yap_GetPredPropByFunc(Functor f, Term cur_mod) -/* get predicate entry for ap/arity; */ -{ - Prop p0; - - FUNC_READ_LOCK(f); - - p0 = GetPredPropByFuncHavingLock(f, cur_mod); - FUNC_READ_UNLOCK(f); - return (p0); -} - -Prop Yap_GetPredPropByFuncInThisModule(Functor f, Term cur_mod) -/* get predicate entry for ap/arity; */ -{ - Prop p0; - - FUNC_READ_LOCK(f); - p0 = GetPredPropByFuncHavingLock(f, cur_mod); - FUNC_READ_UNLOCK(f); - return (p0); -} - -Prop Yap_GetPredPropHavingLock(Atom ap, unsigned int arity, Term mod) -/* get predicate entry for ap/arity; */ -{ - Prop p0; - AtomEntry *ae = RepAtom(ap); - Functor f; - - if (arity == 0) { - GetPredPropByAtomHavingLock(ae, mod); - } - f = InlinedUnlockedMkFunctor(ae, arity); - FUNC_READ_LOCK(f); - p0 = GetPredPropByFuncHavingLock(f, mod); - FUNC_READ_UNLOCK(f); - return (p0); -} - -/* get expression entry for at/arity; */ -Prop Yap_GetExpProp(Atom at, unsigned int arity) { - Prop p0; - AtomEntry *ae = RepAtom(at); - ExpEntry *p; - - READ_LOCK(ae->ARWLock); - p = RepExpProp(p0 = ae->PropsOfAE); - while (p0 && (p->KindOfPE != ExpProperty || p->ArityOfEE != arity)) - p = RepExpProp(p0 = p->NextOfPE); - READ_UNLOCK(ae->ARWLock); - return (p0); -} - -/* get expression entry for at/arity, at is already locked; */ -Prop Yap_GetExpPropHavingLock(AtomEntry *ae, unsigned int arity) { - Prop p0; - ExpEntry *p; - - p = RepExpProp(p0 = ae->PropsOfAE); - while (p0 && (p->KindOfPE != ExpProperty || p->ArityOfEE != arity)) - p = RepExpProp(p0 = p->NextOfPE); - - return (p0); -} - -static int ExpandPredHash(void) { - UInt new_size = PredHashTableSize + PredHashIncrement; - PredEntry **oldp = PredHash; - PredEntry **np = - (PredEntry **)Yap_AllocAtomSpace(sizeof(PredEntry **) * new_size); - UInt i; - - if (!np) { - return FALSE; - } - for (i = 0; i < new_size; i++) { - np[i] = NULL; - } - for (i = 0; i < PredHashTableSize; i++) { - PredEntry *p = PredHash[i]; - - while (p) { - PredEntry *nextp = p->NextPredOfHash; - UInt hsh = PRED_HASH(p->FunctorOfPred, p->ModuleOfPred, new_size); - p->NextPredOfHash = np[hsh]; - np[hsh] = p; - p = nextp; - } - } - PredHashTableSize = new_size; - PredHash = np; - Yap_FreeAtomSpace((ADDR)oldp); - return TRUE; -} - -/* fe is supposed to be locked */ -Prop Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod) { - PredEntry *p = (PredEntry *)Yap_AllocAtomSpace(sizeof(*p)); - - if (p == NULL) { - WRITE_UNLOCK(fe->FRWLock); - return NULL; - } - if (cur_mod == TermProlog || cur_mod == 0L) { - p->ModuleOfPred = 0L; - } else - p->ModuleOfPred = cur_mod; - // TRUE_FUNC_WRITE_LOCK(fe); - INIT_LOCK(p->PELock); - p->KindOfPE = PEProp; - p->ArityOfPE = fe->ArityOfFE; - p->cs.p_code.FirstClause = p->cs.p_code.LastClause = NULL; - p->cs.p_code.NOfClauses = 0; - p->PredFlags = 0L; - p->src.OwnerFile = Yap_source_file_name(); - p->OpcodeOfPred = UNDEF_OPCODE; - p->CodeOfPred = p->cs.p_code.TrueCodeOfPred = (yamop *)(&(p->OpcodeOfPred)); - p->cs.p_code.ExpandCode = EXPAND_OP_CODE; - p->TimeStampOfPred = 0L; - p->LastCallOfPred = LUCALL_ASSERT; - p->MetaEntryOfPred = NULL; - if (cur_mod == TermProlog) - p->ModuleOfPred = 0L; - else - p->ModuleOfPred = cur_mod; - p->StatisticsForPred = NULL; - Yap_NewModulePred(cur_mod, p); - -#ifdef TABLING - p->TableOfPred = NULL; -#endif /* TABLING */ -#ifdef BEAM - p->beamTable = NULL; -#endif /* BEAM */ - /* careful that they don't cross MkFunctor */ - if (!trueGlobalPrologFlag(DEBUG_INFO_FLAG)) { - p->PredFlags |= NoTracePredFlag; - } - p->FunctorOfPred = fe; - if (fe->PropsOfFE) { - UInt hsh = PRED_HASH(fe, cur_mod, PredHashTableSize); - - WRITE_LOCK(PredHashRWLock); - if (10 * (PredsInHashTable + 1) > 6 * PredHashTableSize) { - if (!ExpandPredHash()) { - Yap_FreeCodeSpace((ADDR)p); - WRITE_UNLOCK(PredHashRWLock); - FUNC_WRITE_UNLOCK(fe); - return NULL; - } - /* retry hashing */ - hsh = PRED_HASH(fe, cur_mod, PredHashTableSize); - } - PredsInHashTable++; - if (p->ModuleOfPred == 0L) { - PredEntry *pe = RepPredProp(fe->PropsOfFE); - - hsh = PRED_HASH(fe, pe->ModuleOfPred, PredHashTableSize); - /* should be the first one */ - pe->NextPredOfHash = PredHash[hsh]; - PredHash[hsh] = pe; - fe->PropsOfFE = AbsPredProp(p); - p->NextOfPE = AbsPredProp(pe); - } else { - p->NextPredOfHash = PredHash[hsh]; - PredHash[hsh] = p; - p->NextOfPE = fe->PropsOfFE->NextOfPE; - fe->PropsOfFE->NextOfPE = AbsPredProp(p); - } - WRITE_UNLOCK(PredHashRWLock); - } else { - fe->PropsOfFE = AbsPredProp(p); - p->NextOfPE = NIL; - } - FUNC_WRITE_UNLOCK(fe); - { - Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred) + 1, p, - GPROF_NEW_PRED_FUNC); - if (!(p->PredFlags & (CPredFlag | AsmPredFlag))) { - Yap_inform_profiler_of_clause(&(p->cs.p_code.ExpandCode), - &(p->cs.p_code.ExpandCode) + 1, p, - GPROF_NEW_PRED_FUNC); - } - } - return AbsPredProp(p); -} - -#if THREADS -Prop Yap_NewThreadPred(PredEntry *ap USES_REGS) { - PredEntry *p = (PredEntry *)Yap_AllocAtomSpace(sizeof(*p)); - - if (p == NULL) { - return NIL; - } - INIT_LOCK(p->PELock); - p->StatisticsForPred = NULL : p->KindOfPE = PEProp; - p->ArityOfPE = ap->ArityOfPE; - p->cs.p_code.FirstClause = p->cs.p_code.LastClause = NULL; - p->cs.p_code.NOfClauses = 0; - p->PredFlags = ap->PredFlags & ~(IndexedPredFlag | SpiedPredFlag); -#if SIZEOF_INT_P == 4 - p->ExtraPredFlags = 0L; -#endif - p->MetaEntryOfPred = NULL; - p->src.OwnerFile = ap->src.OwnerFile; - p->OpcodeOfPred = FAIL_OPCODE; - p->CodeOfPred = p->cs.p_code.TrueCodeOfPred = (yamop *)(&(p->OpcodeOfPred)); - p->cs.p_code.ExpandCode = EXPAND_OP_CODE; - p->ModuleOfPred = ap->ModuleOfPred; - p->NextPredOfModule = NULL; - p->TimeStampOfPred = 0L; - p->LastCallOfPred = LUCALL_ASSERT; -#ifdef TABLING - p->TableOfPred = NULL; -#endif /* TABLING */ -#ifdef BEAM - p->beamTable = NULL; -#endif - /* careful that they don't cross MkFunctor */ - p->NextOfPE = AbsPredProp(LOCAL_ThreadHandle.local_preds); - LOCAL_ThreadHandle.local_preds = p; - p->FunctorOfPred = ap->FunctorOfPred; - Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred) + 1, p, - GPROF_NEW_PRED_THREAD); - if (falseGlobalPrologFlag(DEBUG_INFO_FLAG)) { - p->PredFlags |= (NoSpyPredFlag | NoTracePredFlag); - } - if (!(p->PredFlags & (CPredFlag | AsmPredFlag))) { - Yap_inform_profiler_of_clause(&(p->cs.p_code.ExpandCode), - &(p->cs.p_code.ExpandCode) + 1, p, - GPROF_NEW_PRED_THREAD); - } - return AbsPredProp(p); -} -#endif - -Prop Yap_NewPredPropByAtom(AtomEntry *ae, Term cur_mod) { - Prop p0; - PredEntry *p = (PredEntry *)Yap_AllocAtomSpace(sizeof(*p)); - CACHE_REGS - /* Printf("entering %s:%s/0\n", RepAtom(AtomOfTerm(cur_mod))->StrOfAE, - * ae->StrOfAE); */ - - if (p == NULL) { - WRITE_UNLOCK(ae->ARWLock); - return NIL; - } - INIT_LOCK(p->PELock); - p->KindOfPE = PEProp; - p->ArityOfPE = 0; - p->StatisticsForPred = NULL; - p->cs.p_code.FirstClause = p->cs.p_code.LastClause = NULL; - p->cs.p_code.NOfClauses = 0; - p->PredFlags = 0L; - p->src.OwnerFile = Yap_source_file_name(); - p->OpcodeOfPred = UNDEF_OPCODE; - p->cs.p_code.ExpandCode = EXPAND_OP_CODE; - p->CodeOfPred = p->cs.p_code.TrueCodeOfPred = (yamop *)(&(p->OpcodeOfPred)); - p->MetaEntryOfPred = NULL; - if (cur_mod == TermProlog) - p->ModuleOfPred = 0; - else - p->ModuleOfPred = cur_mod; - Yap_NewModulePred(cur_mod, p); - p->TimeStampOfPred = 0L; - p->LastCallOfPred = LUCALL_ASSERT; -#ifdef TABLING - p->TableOfPred = NULL; -#endif /* TABLING */ -#ifdef BEAM - p->beamTable = NULL; -#endif - /* careful that they don't cross MkFunctor */ - AddPropToAtom(ae, (PropEntry *)p); - p0 = AbsPredProp(p); - p->FunctorOfPred = (Functor)AbsAtom(ae); - if (!trueGlobalPrologFlag(DEBUG_INFO_FLAG)) { - p->PredFlags |= (NoTracePredFlag | NoSpyPredFlag); - } - if (Yap_isSystemModule(CurrentModule)) - p->PredFlags |= StandardPredFlag; - WRITE_UNLOCK(ae->ARWLock); - { - Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred) + 1, p, - GPROF_NEW_PRED_ATOM); - if (!(p->PredFlags & (CPredFlag | AsmPredFlag))) { - Yap_inform_profiler_of_clause(&(p->cs.p_code.ExpandCode), - &(p->cs.p_code.ExpandCode) + 1, p, - GPROF_NEW_PRED_ATOM); - } - } - return p0; -} - -Prop Yap_PredPropByFunctorNonThreadLocal(Functor f, Term cur_mod) -/* get predicate entry for ap/arity; create it if neccessary. */ -{ - PredEntry *p; - - FUNC_WRITE_LOCK(f); - if (!(p = RepPredProp(f->PropsOfFE))) - return Yap_NewPredPropByFunctor(f, cur_mod); - - if ((p->ModuleOfPred == cur_mod || !(p->ModuleOfPred))) { - /* don't match multi-files */ - if (!(p->PredFlags & MultiFileFlag) || p->ModuleOfPred || !cur_mod || - cur_mod == TermProlog) { - FUNC_WRITE_UNLOCK(f); - return AbsPredProp(p); - } - } - if (p->NextOfPE) { - UInt hash = PRED_HASH(f, cur_mod, PredHashTableSize); - READ_LOCK(PredHashRWLock); - p = PredHash[hash]; - - while (p) { - if (p->FunctorOfPred == f && p->ModuleOfPred == cur_mod) { - READ_UNLOCK(PredHashRWLock); - FUNC_WRITE_UNLOCK(f); - return AbsPredProp(p); - } - p = p->NextPredOfHash; - } - READ_UNLOCK(PredHashRWLock); - } - return Yap_NewPredPropByFunctor(f, cur_mod); -} - -Prop Yap_PredPropByAtomNonThreadLocal(Atom at, Term cur_mod) -/* get predicate entry for ap/arity; create it if neccessary. */ -{ - Prop p0; - AtomEntry *ae = RepAtom(at); - - WRITE_LOCK(ae->ARWLock); - p0 = ae->PropsOfAE; - while (p0) { - PredEntry *pe = RepPredProp(p0); - if (pe->KindOfPE == PEProp && - (pe->ModuleOfPred == cur_mod || !pe->ModuleOfPred)) { - /* don't match multi-files */ - if (!(pe->PredFlags & MultiFileFlag) || pe->ModuleOfPred || !cur_mod || - cur_mod == TermProlog) { - WRITE_UNLOCK(ae->ARWLock); - return (p0); - } - } - p0 = pe->NextOfPE; - } - return Yap_NewPredPropByAtom(ae, cur_mod); -} - -Term Yap_GetValue(Atom a) { - Prop p0 = GetAProp(a, ValProperty); - Term out; - - if (p0 == NIL) - return (TermNil); - READ_LOCK(RepValProp(p0)->VRWLock); - out = RepValProp(p0)->ValueOfVE; - if (IsApplTerm(out)) { - Functor f = FunctorOfTerm(out); - if (f == FunctorDouble) { - CACHE_REGS - out = MkFloatTerm(FloatOfTerm(out)); - } else if (f == FunctorLongInt) { - CACHE_REGS - out = MkLongIntTerm(LongIntOfTerm(out)); - } else if (f == FunctorString) { - CACHE_REGS - out = MkStringTerm(StringOfTerm(out)); - } -#ifdef USE_GMP - else { - out = Yap_MkBigIntTerm(Yap_BigIntOfTerm(out)); - } -#endif - } - READ_UNLOCK(RepValProp(p0)->VRWLock); - return (out); -} - -void Yap_PutValue(Atom a, Term v) { - AtomEntry *ae = RepAtom(a); - Prop p0; - ValEntry *p; - Term t0; - - WRITE_LOCK(ae->ARWLock); - p0 = GetAPropHavingLock(ae, ValProperty); - if (p0 != NIL) { - p = RepValProp(p0); - WRITE_LOCK(p->VRWLock); - WRITE_UNLOCK(ae->ARWLock); - } else { - p = (ValEntry *)Yap_AllocAtomSpace(sizeof(ValEntry)); if (p == NULL) { - WRITE_UNLOCK(ae->ARWLock); - return; + WRITE_UNLOCK(fe->FRWLock); + return NULL; + } + if (cur_mod == TermProlog || cur_mod == 0L) { + p->ModuleOfPred = 0L; + } else + p->ModuleOfPred = cur_mod; + // TRUE_FUNC_WRITE_LOCK(fe); + INIT_LOCK(p->PELock); + p->KindOfPE = PEProp; + p->ArityOfPE = fe->ArityOfFE; + p->cs.p_code.FirstClause = p->cs.p_code.LastClause = NULL; + p->cs.p_code.NOfClauses = 0; + p->PredFlags = UndefPredFlag; + p->src.OwnerFile = Yap_source_file_name(); + p->OpcodeOfPred = UNDEF_OPCODE; + p->CodeOfPred = p->cs.p_code.TrueCodeOfPred = (yamop *)(&(p->OpcodeOfPred)); + p->cs.p_code.ExpandCode = EXPAND_OP_CODE; + p->TimeStampOfPred = 0L; + p->LastCallOfPred = LUCALL_ASSERT; + p->MetaEntryOfPred = NULL; + if (cur_mod == TermProlog) + p->ModuleOfPred = 0L; + else + p->ModuleOfPred = cur_mod; + p->StatisticsForPred = NULL; + Yap_NewModulePred(cur_mod, p); + +#ifdef TABLING + p->TableOfPred = NULL; +#endif /* TABLING */ +#ifdef BEAM + p->beamTable = NULL; +#endif /* BEAM */ + /* careful that they don't cross MkFunctor */ + if (!trueGlobalPrologFlag(DEBUG_INFO_FLAG)) { + p->PredFlags |= NoTracePredFlag; + } + p->FunctorOfPred = fe; + if (fe->PropsOfFE) { + UInt hsh = PRED_HASH(fe, cur_mod, PredHashTableSize); + + WRITE_LOCK(PredHashRWLock); + if (10 * (PredsInHashTable + 1) > 6 * PredHashTableSize) { + if (!ExpandPredHash()) { + Yap_FreeCodeSpace((ADDR)p); + WRITE_UNLOCK(PredHashRWLock); + FUNC_WRITE_UNLOCK(fe); + return NULL; + } + /* retry hashing */ + hsh = PRED_HASH(fe, cur_mod, PredHashTableSize); + } + PredsInHashTable++; + if (p->ModuleOfPred == 0L) { + PredEntry *pe = RepPredProp(fe->PropsOfFE); + + hsh = PRED_HASH(fe, pe->ModuleOfPred, PredHashTableSize); + /* should be the first one */ + pe->NextPredOfHash = PredHash[hsh]; + PredHash[hsh] = pe; + fe->PropsOfFE = AbsPredProp(p); + p->NextOfPE = AbsPredProp(pe); + } else { + p->NextPredOfHash = PredHash[hsh]; + PredHash[hsh] = p; + p->NextOfPE = fe->PropsOfFE->NextOfPE; + fe->PropsOfFE->NextOfPE = AbsPredProp(p); + } + WRITE_UNLOCK(PredHashRWLock); + } else { + fe->PropsOfFE = AbsPredProp(p); + p->NextOfPE = NIL; + } + FUNC_WRITE_UNLOCK(fe); + { + Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred) + 1, p, + GPROF_NEW_PRED_FUNC); + if (!(p->PredFlags & (CPredFlag | AsmPredFlag))) { + Yap_inform_profiler_of_clause(&(p->cs.p_code.ExpandCode), + &(p->cs.p_code.ExpandCode) + 1, p, + GPROF_NEW_PRED_FUNC); + } + } + return AbsPredProp(p); + } + +#if THREADS + Prop Yap_NewThreadPred(PredEntry *ap USES_REGS) { + PredEntry *p = (PredEntry *)Yap_AllocAtomSpace(sizeof(*p)); + + if (p == NULL) { + return NIL; + } + INIT_LOCK(p->PELock); + p->StatisticsForPred = NULL : p->KindOfPE = PEProp; + p->ArityOfPE = ap->ArityOfPE; + p->cs.p_code.FirstClause = p->cs.p_code.LastClause = NULL; + p->cs.p_code.NOfClauses = 0; + p->PredFlags = ap->PredFlags & ~(IndexedPredFlag | SpiedPredFlag); +#if SIZEOF_INT_P == 4 + p->ExtraPredFlags = 0L; +#endif + p->MetaEntryOfPred = NULL; + p->src.OwnerFile = ap->src.OwnerFile; + p->OpcodeOfPred = FAIL_OPCODE; + p->CodeOfPred = p->cs.p_code.TrueCodeOfPred = (yamop *)(&(p->OpcodeOfPred)); + p->cs.p_code.ExpandCode = EXPAND_OP_CODE; + p->ModuleOfPred = ap->ModuleOfPred; + p->NextPredOfModule = NULL; + p->TimeStampOfPred = 0L; + p->LastCallOfPred = LUCALL_ASSERT; +#ifdef TABLING + p->TableOfPred = NULL; +#endif /* TABLING */ +#ifdef BEAM + p->beamTable = NULL; +#endif + /* careful that they don't cross MkFunctor */ + p->NextOfPE = AbsPredProp(LOCAL_ThreadHandle.local_preds); + LOCAL_ThreadHandle.local_preds = p; + p->FunctorOfPred = ap->FunctorOfPred; + Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred) + 1, p, + GPROF_NEW_PRED_THREAD); + if (falseGlobalPrologFlag(DEBUG_INFO_FLAG)) { + p->PredFlags |= (NoSpyPredFlag | NoTracePredFlag); + } + if (!(p->PredFlags & (CPredFlag | AsmPredFlag))) { + Yap_inform_profiler_of_clause(&(p->cs.p_code.ExpandCode), + &(p->cs.p_code.ExpandCode) + 1, p, + GPROF_NEW_PRED_THREAD); + } + return AbsPredProp(p); + } +#endif + + Prop Yap_NewPredPropByAtom(AtomEntry *ae, Term cur_mod) { + Prop p0; + PredEntry *p = (PredEntry *)Yap_AllocAtomSpace(sizeof(*p)); + CACHE_REGS + /* Printf("entering %s:%s/0\n", RepAtom(AtomOfTerm(cur_mod))->StrOfAE, + * ae->StrOfAE); */ + + if (p == NULL) { + WRITE_UNLOCK(ae->ARWLock); + return NIL; + } + INIT_LOCK(p->PELock); + p->KindOfPE = PEProp; + p->ArityOfPE = 0; + p->StatisticsForPred = NULL; + p->cs.p_code.FirstClause = p->cs.p_code.LastClause = NULL; + p->cs.p_code.NOfClauses = 0; + p->PredFlags = UndefPredFlag; + p->src.OwnerFile = Yap_source_file_name(); + p->OpcodeOfPred = UNDEF_OPCODE; + p->cs.p_code.ExpandCode = EXPAND_OP_CODE; + p->CodeOfPred = p->cs.p_code.TrueCodeOfPred = (yamop *)(&(p->OpcodeOfPred)); + p->MetaEntryOfPred = NULL; + if (cur_mod == TermProlog) + p->ModuleOfPred = 0; + else + p->ModuleOfPred = cur_mod; + Yap_NewModulePred(cur_mod, p); + p->TimeStampOfPred = 0L; + p->LastCallOfPred = LUCALL_ASSERT; +#ifdef TABLING + p->TableOfPred = NULL; +#endif /* TABLING */ +#ifdef BEAM + p->beamTable = NULL; +#endif + /* careful that they don't cross MkFunctor */ + AddPropToAtom(ae, (PropEntry *)p); + p0 = AbsPredProp(p); + p->FunctorOfPred = (Functor)AbsAtom(ae); + if (!trueGlobalPrologFlag(DEBUG_INFO_FLAG)) { + p->PredFlags |= (NoTracePredFlag | NoSpyPredFlag); + } + if (Yap_isSystemModule(CurrentModule)) + p->PredFlags |= StandardPredFlag; + WRITE_UNLOCK(ae->ARWLock); + { + Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred) + 1, p, + GPROF_NEW_PRED_ATOM); + if (!(p->PredFlags & (CPredFlag | AsmPredFlag))) { + Yap_inform_profiler_of_clause(&(p->cs.p_code.ExpandCode), + &(p->cs.p_code.ExpandCode) + 1, p, + GPROF_NEW_PRED_ATOM); + } + } + return p0; + } + + Prop Yap_PredPropByFunctorNonThreadLocal(Functor f, Term cur_mod) + /* get predicate entry for ap/arity; create it if neccessary. */ + { + PredEntry *p; + + FUNC_WRITE_LOCK(f); + if (!(p = RepPredProp(f->PropsOfFE))) + return Yap_NewPredPropByFunctor(f, cur_mod); + + if ((p->ModuleOfPred == cur_mod || !(p->ModuleOfPred))) { + /* don't match multi-files */ + if (/*!(p->PredFlags & MultiFileFlag) ||*/ true || p->ModuleOfPred || !cur_mod || + cur_mod == TermProlog) { + FUNC_WRITE_UNLOCK(f); + return AbsPredProp(p); + } + } + if (p->NextOfPE) { + UInt hash = PRED_HASH(f, cur_mod, PredHashTableSize); + READ_LOCK(PredHashRWLock); + p = PredHash[hash]; + + while (p) { + if (p->FunctorOfPred == f && p->ModuleOfPred == cur_mod) { + READ_UNLOCK(PredHashRWLock); + FUNC_WRITE_UNLOCK(f); + return AbsPredProp(p); + } + p = p->NextPredOfHash; + } + READ_UNLOCK(PredHashRWLock); + } + return Yap_NewPredPropByFunctor(f, cur_mod); + } + + Prop Yap_PredPropByAtomNonThreadLocal(Atom at, Term cur_mod) + /* get predicate entry for ap/arity; create it if neccessary. */ + { + Prop p0; + AtomEntry *ae = RepAtom(at); + + WRITE_LOCK(ae->ARWLock); + p0 = ae->PropsOfAE; + while (p0) { + PredEntry *pe = RepPredProp(p0); + if (pe->KindOfPE == PEProp && + (pe->ModuleOfPred == cur_mod || !pe->ModuleOfPred)) { + /* don't match multi-files */ + if (/*!(pe->PredFlags & MultiFileFlag) ||*/ true || pe->ModuleOfPred || !cur_mod || + cur_mod == TermProlog) { + WRITE_UNLOCK(ae->ARWLock); + return (p0); + } + } + p0 = pe->NextOfPE; + } + return Yap_NewPredPropByAtom(ae, cur_mod); + } + + Term Yap_GetValue(Atom a) { + Prop p0 = GetAProp(a, ValProperty); + Term out; + + if (p0 == NIL) + return (TermNil); + READ_LOCK(RepValProp(p0)->VRWLock); + out = RepValProp(p0)->ValueOfVE; + if (IsApplTerm(out)) { + Functor f = FunctorOfTerm(out); + if (f == FunctorDouble) { + CACHE_REGS + out = MkFloatTerm(FloatOfTerm(out)); + } else if (f == FunctorLongInt) { + CACHE_REGS + out = MkLongIntTerm(LongIntOfTerm(out)); + } else if (f == FunctorString) { + CACHE_REGS + out = MkStringTerm(StringOfTerm(out)); + } +#ifdef USE_GMP + else { + out = Yap_MkBigIntTerm(Yap_BigIntOfTerm(out)); + } +#endif + } + READ_UNLOCK(RepValProp(p0)->VRWLock); + return (out); + } + + void Yap_PutValue(Atom a, Term v) { + AtomEntry *ae = RepAtom(a); + Prop p0; + ValEntry *p; + Term t0; + + WRITE_LOCK(ae->ARWLock); + p0 = GetAPropHavingLock(ae, ValProperty); + if (p0 != NIL) { + p = RepValProp(p0); + WRITE_LOCK(p->VRWLock); + WRITE_UNLOCK(ae->ARWLock); + } else { + p = (ValEntry *)Yap_AllocAtomSpace(sizeof(ValEntry)); + if (p == NULL) { + WRITE_UNLOCK(ae->ARWLock); + return; + } + p->KindOfPE = ValProperty; + p->ValueOfVE = TermNil; + AddPropToAtom(RepAtom(a), (PropEntry *)p); + /* take care that the lock for the property will be inited even + if someone else searches for the property */ + INIT_RWLOCK(p->VRWLock); + WRITE_LOCK(p->VRWLock); + WRITE_UNLOCK(ae->ARWLock); + } + t0 = p->ValueOfVE; + if (IsFloatTerm(v)) { + /* store a float in code space, so that we can access the property */ + union { + Float f; + CELL ar[sizeof(Float) / sizeof(CELL)]; + } un; + CELL *pt, *iptr; + unsigned int i; + + un.f = FloatOfTerm(v); + if (IsFloatTerm(t0)) { + pt = RepAppl(t0); + } else { + if (IsApplTerm(t0)) { + Yap_FreeCodeSpace((char *)(RepAppl(t0))); + } + pt = (CELL *)Yap_AllocAtomSpace(sizeof(CELL) * + (1 + 2 * sizeof(Float) / sizeof(CELL))); + if (pt == NULL) { + WRITE_UNLOCK(ae->ARWLock); + return; + } + p->ValueOfVE = AbsAppl(pt); + pt[0] = (CELL)FunctorDouble; + } + + iptr = pt + 1; + for (i = 0; i < sizeof(Float) / sizeof(CELL); i++) { + *iptr++ = (CELL)un.ar[i]; + } + } else if (IsLongIntTerm(v)) { + CELL *pt; + Int val = LongIntOfTerm(v); + + if (IsLongIntTerm(t0)) { + pt = RepAppl(t0); + } else { + if (IsApplTerm(t0)) { + Yap_FreeCodeSpace((char *)(RepAppl(t0))); + } + pt = (CELL *)Yap_AllocAtomSpace(2 * sizeof(CELL)); + if (pt == NULL) { + WRITE_UNLOCK(ae->ARWLock); + return; + } + p->ValueOfVE = AbsAppl(pt); + pt[0] = (CELL)FunctorLongInt; + } + pt[1] = (CELL)val; +#ifdef USE_GMP + } else if (IsBigIntTerm(v)) { + CELL *ap = RepAppl(v); + Int sz = sizeof(MP_INT) + sizeof(CELL) + + (((MP_INT *)(ap + 1))->_mp_alloc * sizeof(mp_limb_t)); + CELL *pt = (CELL *)Yap_AllocAtomSpace(sz); + + if (pt == NULL) { + WRITE_UNLOCK(ae->ARWLock); + return; + } + if (IsApplTerm(t0)) { + Yap_FreeCodeSpace((char *)RepAppl(t0)); + } + memmove((void *)pt, (void *)ap, sz); + p->ValueOfVE = AbsAppl(pt); +#endif + } else if (IsStringTerm(v)) { + CELL *ap = RepAppl(v); + Int sz = sizeof(CELL) * (3 + ap[1]); + CELL *pt = (CELL *)Yap_AllocAtomSpace(sz); + + if (pt == NULL) { + WRITE_UNLOCK(ae->ARWLock); + return; + } + if (IsApplTerm(t0)) { + Yap_FreeCodeSpace((char *)RepAppl(t0)); + } + memmove((void *)pt, (void *)ap, sz); + p->ValueOfVE = AbsAppl(pt); + } else { + if (IsApplTerm(t0)) { + /* recover space */ + Yap_FreeCodeSpace((char *)(RepAppl(p->ValueOfVE))); + } + p->ValueOfVE = v; + } + WRITE_UNLOCK(p->VRWLock); + } + + bool Yap_PutAtomTranslation(Atom a, arity_t arity, Int i) { + AtomEntry *ae = RepAtom(a); + Prop p0; + TranslationEntry *p; + + WRITE_LOCK(ae->ARWLock); + p0 = GetAPropHavingLock(ae, TranslationProperty); + if (p0 == NIL) { + p = (TranslationEntry *)Yap_AllocAtomSpace(sizeof(TranslationEntry)); + if (p == NULL) { + WRITE_UNLOCK(ae->ARWLock); + return false; + } + p->KindOfPE = TranslationProperty; + p->Translation = i; + p->arity = arity; + AddPropToAtom(RepAtom(a), (PropEntry *)p); } - p->KindOfPE = ValProperty; - p->ValueOfVE = TermNil; - AddPropToAtom(RepAtom(a), (PropEntry *)p); /* take care that the lock for the property will be inited even if someone else searches for the property */ - INIT_RWLOCK(p->VRWLock); - WRITE_LOCK(p->VRWLock); WRITE_UNLOCK(ae->ARWLock); + return true; } - t0 = p->ValueOfVE; - if (IsFloatTerm(v)) { - /* store a float in code space, so that we can access the property */ - union { - Float f; - CELL ar[sizeof(Float) / sizeof(CELL)]; - } un; - CELL *pt, *iptr; - unsigned int i; - un.f = FloatOfTerm(v); - if (IsFloatTerm(t0)) { - pt = RepAppl(t0); - } else { - if (IsApplTerm(t0)) { - Yap_FreeCodeSpace((char *)(RepAppl(t0))); + bool Yap_PutFunctorTranslation(Atom a, arity_t arity, Int i) { + AtomEntry *ae = RepAtom(a); + Prop p0; + TranslationEntry *p; + + WRITE_LOCK(ae->ARWLock); + p0 = GetAPropHavingLock(ae, TranslationProperty); + if (p0 == NIL) { + p = (TranslationEntry *)Yap_AllocAtomSpace(sizeof(TranslationEntry)); + if (p == NULL) { + WRITE_UNLOCK(ae->ARWLock); + return false; } - pt = (CELL *)Yap_AllocAtomSpace(sizeof(CELL) * - (1 + 2 * sizeof(Float) / sizeof(CELL))); - if (pt == NULL) { - WRITE_UNLOCK(ae->ARWLock); - return; + p->KindOfPE = TranslationProperty; + p->Translation = i; + p->arity = arity; + AddPropToAtom(RepAtom(a), (PropEntry *)p); + } + /* take care that the lock for the property will be inited even + if someone else searches for the property */ + WRITE_UNLOCK(ae->ARWLock); + return true; + } + + bool Yap_PutAtomMutex(Atom a, void *i) { + AtomEntry *ae = RepAtom(a); + Prop p0; + MutexEntry *p; + + WRITE_LOCK(ae->ARWLock); + p0 = GetAPropHavingLock(ae, MutexProperty); + if (p0 == NIL) { + p = (MutexEntry *)Yap_AllocAtomSpace(sizeof(MutexEntry)); + if (p == NULL) { + WRITE_UNLOCK(ae->ARWLock); + return false; } - p->ValueOfVE = AbsAppl(pt); - pt[0] = (CELL)FunctorDouble; + p->KindOfPE = MutexProperty; + p->Mutex = i; + AddPropToAtom(RepAtom(a), (PropEntry *)p); } - - iptr = pt + 1; - for (i = 0; i < sizeof(Float) / sizeof(CELL); i++) { - *iptr++ = (CELL)un.ar[i]; - } - } else if (IsLongIntTerm(v)) { - CELL *pt; - Int val = LongIntOfTerm(v); - - if (IsLongIntTerm(t0)) { - pt = RepAppl(t0); - } else { - if (IsApplTerm(t0)) { - Yap_FreeCodeSpace((char *)(RepAppl(t0))); - } - pt = (CELL *)Yap_AllocAtomSpace(2 * sizeof(CELL)); - if (pt == NULL) { - WRITE_UNLOCK(ae->ARWLock); - return; - } - p->ValueOfVE = AbsAppl(pt); - pt[0] = (CELL)FunctorLongInt; - } - pt[1] = (CELL)val; -#ifdef USE_GMP - } else if (IsBigIntTerm(v)) { - CELL *ap = RepAppl(v); - Int sz = sizeof(MP_INT) + sizeof(CELL) + - (((MP_INT *)(ap + 1))->_mp_alloc * sizeof(mp_limb_t)); - CELL *pt = (CELL *)Yap_AllocAtomSpace(sz); - - if (pt == NULL) { - WRITE_UNLOCK(ae->ARWLock); - return; - } - if (IsApplTerm(t0)) { - Yap_FreeCodeSpace((char *)RepAppl(t0)); - } - memcpy((void *)pt, (void *)ap, sz); - p->ValueOfVE = AbsAppl(pt); -#endif - } else if (IsStringTerm(v)) { - CELL *ap = RepAppl(v); - Int sz = sizeof(CELL) * (3 + ap[1]); - CELL *pt = (CELL *)Yap_AllocAtomSpace(sz); - - if (pt == NULL) { - WRITE_UNLOCK(ae->ARWLock); - return; - } - if (IsApplTerm(t0)) { - Yap_FreeCodeSpace((char *)RepAppl(t0)); - } - memcpy((void *)pt, (void *)ap, sz); - p->ValueOfVE = AbsAppl(pt); - } else { - if (IsApplTerm(t0)) { - /* recover space */ - Yap_FreeCodeSpace((char *)(RepAppl(p->ValueOfVE))); - } - p->ValueOfVE = v; + /* take care that the lock for the property will be inited even + if someone else searches for the property */ + WRITE_UNLOCK(ae->ARWLock); + return true; } - WRITE_UNLOCK(p->VRWLock); -} -bool Yap_PutAtomTranslation(Atom a, arity_t arity, Int i) { - AtomEntry *ae = RepAtom(a); - Prop p0; - TranslationEntry *p; + Term Yap_ArrayToList(register Term *tp, size_t nof) { + CACHE_REGS + register Term *pt = tp + nof; + register Term t; - WRITE_LOCK(ae->ARWLock); - p0 = GetAPropHavingLock(ae, TranslationProperty); - if (p0 == NIL) { - p = (TranslationEntry *)Yap_AllocAtomSpace(sizeof(TranslationEntry)); - if (p == NULL) { - WRITE_UNLOCK(ae->ARWLock); - return false; - } - p->KindOfPE = TranslationProperty; - p->Translation = i; - p->arity = arity; - AddPropToAtom(RepAtom(a), (PropEntry *)p); - } - /* take care that the lock for the property will be inited even - if someone else searches for the property */ - WRITE_UNLOCK(ae->ARWLock); - return true; -} - -bool Yap_PutFunctorTranslation(Atom a, arity_t arity, Int i) { - AtomEntry *ae = RepAtom(a); - Prop p0; - TranslationEntry *p; - - WRITE_LOCK(ae->ARWLock); - p0 = GetAPropHavingLock(ae, TranslationProperty); - if (p0 == NIL) { - p = (TranslationEntry *)Yap_AllocAtomSpace(sizeof(TranslationEntry)); - if (p == NULL) { - WRITE_UNLOCK(ae->ARWLock); - return false; - } - p->KindOfPE = TranslationProperty; - p->Translation = i; - p->arity = arity; - AddPropToAtom(RepAtom(a), (PropEntry *)p); - } - /* take care that the lock for the property will be inited even - if someone else searches for the property */ - WRITE_UNLOCK(ae->ARWLock); - return true; -} - -bool Yap_PutAtomMutex(Atom a, void *i) { - AtomEntry *ae = RepAtom(a); - Prop p0; - MutexEntry *p; - - WRITE_LOCK(ae->ARWLock); - p0 = GetAPropHavingLock(ae, MutexProperty); - if (p0 == NIL) { - p = (MutexEntry *)Yap_AllocAtomSpace(sizeof(MutexEntry)); - if (p == NULL) { - WRITE_UNLOCK(ae->ARWLock); - return false; - } - p->KindOfPE = MutexProperty; - p->Mutex = i; - AddPropToAtom(RepAtom(a), (PropEntry *)p); - } - /* take care that the lock for the property will be inited even - if someone else searches for the property */ - WRITE_UNLOCK(ae->ARWLock); - return true; -} - -Term Yap_ArrayToList(register Term *tp, size_t nof) { - CACHE_REGS - register Term *pt = tp + nof; - register Term t; - - t = MkAtomTerm(AtomNil); - while (pt > tp) { - Term tm = *--pt; + t = MkAtomTerm(AtomNil); + while (pt > tp) { + Term tm = *--pt; #if YAPOR_SBA - if (tm == 0) - t = MkPairTerm((CELL)pt, t); - else + if (tm == 0) + t = MkPairTerm((CELL)pt, t); + else #endif - t = MkPairTerm(tm, t); - } - return (t); -} - -int Yap_GetName(char *s, UInt max, Term t) { - register Term Head; - register Int i; - - if (IsVarTerm(t) || !IsPairTerm(t)) - return FALSE; - while (IsPairTerm(t)) { - Head = HeadOfTerm(t); - if (!IsNumTerm(Head)) - return (FALSE); - i = IntOfTerm(Head); - if (i < 0 || i > MAX_ISO_LATIN1) - return FALSE; - *s++ = i; - t = TailOfTerm(t); - if (--max == 0) { - Yap_Error(SYSTEM_ERROR_FATAL, t, "not enough space for GetName"); + t = MkPairTerm(tm, t); } + return (t); + } + + int Yap_GetName(char *s, UInt max, Term t) { + register Term Head; + register Int i; + + if (IsVarTerm(t) || !IsPairTerm(t)) + return FALSE; + while (IsPairTerm(t)) { + Head = HeadOfTerm(t); + if (!IsNumTerm(Head)) + return (FALSE); + i = IntOfTerm(Head); + if (i < 0 || i > MAX_ISO_LATIN1) + return FALSE; + *s++ = i; + t = TailOfTerm(t); + if (--max == 0) { + Yap_Error(SYSTEM_ERROR_FATAL, t, "not enough space for GetName"); + } + } + *s = '\0'; + return TRUE; } - *s = '\0'; - return TRUE; -} #ifdef SFUNC -Term MkSFTerm(Functor f, int n, Term *a, empty_value) { - Term t, p = AbsAppl(H); - int i; + Term MkSFTerm(Functor f, int n, Term *a, empty_value) { + Term t, p = AbsAppl(H); + int i; - *H++ = f; - RESET_VARIABLE(H); - ++H; - for (i = 1; i <= n; ++i) { - t = Derefa(a++); - if (t != empty_value) { - *H++ = i; - *H++ = t; + *H++ = f; + RESET_VARIABLE(H); + ++H; + for (i = 1; i <= n; ++i) { + t = Derefa(a++); + if (t != empty_value) { + *H++ = i; + *H++ = t; + } } + *H++ = 0; + return (p); } - *H++ = 0; - return (p); -} -CELL *ArgsOfSFTerm(Term t) { - CELL *p = RepAppl(t) + 1; + CELL *ArgsOfSFTerm(Term t) { + CELL *p = RepAppl(t) + 1; - while (*p != (CELL)p) - p = CellPtr(*p) + 1; - return (p + 1); -} + while (*p != (CELL)p) + p = CellPtr(*p) + 1; + return (p + 1); + } #endif -static HoldEntry *InitAtomHold(void) { - HoldEntry *x = (HoldEntry *)Yap_AllocAtomSpace(sizeof(struct hold_entry)); - if (x == NULL) { - return NULL; + static HoldEntry *InitAtomHold(void) { + HoldEntry *x = (HoldEntry *)Yap_AllocAtomSpace(sizeof(struct hold_entry)); + if (x == NULL) { + return NULL; + } + x->KindOfPE = HoldProperty; + x->NextOfPE = NIL; + x->RefsOfPE = 1; + return x; } - x->KindOfPE = HoldProperty; - x->NextOfPE = NIL; - x->RefsOfPE = 1; - return x; -} -int Yap_AtomIncreaseHold(Atom at) { - AtomEntry *ae = RepAtom(at); - HoldEntry *pp; - Prop *opp = &(ae->PropsOfAE); + int Yap_AtomIncreaseHold(Atom at) { + AtomEntry *ae = RepAtom(at); + HoldEntry *pp; + Prop *opp = &(ae->PropsOfAE); - WRITE_LOCK(ae->ARWLock); - pp = RepHoldProp(ae->PropsOfAE); - while (!EndOfPAEntr(pp) && pp->KindOfPE != HoldProperty) { - opp = &(pp->NextOfPE); - pp = RepHoldProp(pp->NextOfPE); + WRITE_LOCK(ae->ARWLock); + pp = RepHoldProp(ae->PropsOfAE); + while (!EndOfPAEntr(pp) && pp->KindOfPE != HoldProperty) { + opp = &(pp->NextOfPE); + pp = RepHoldProp(pp->NextOfPE); + } + if (!pp) { + HoldEntry *new = InitAtomHold(); + if (!new) { + WRITE_UNLOCK(ae->ARWLock); + return FALSE; + } + *opp = AbsHoldProp(new); + } else { + pp->RefsOfPE++; + } + WRITE_UNLOCK(ae->ARWLock); + return TRUE; } - if (!pp) { - HoldEntry *new = InitAtomHold(); - if (!new) { + + int Yap_AtomDecreaseHold(Atom at) { + AtomEntry *ae = RepAtom(at); + HoldEntry *pp; + Prop *opp = &(ae->PropsOfAE); + + WRITE_LOCK(ae->ARWLock); + pp = RepHoldProp(ae->PropsOfAE); + while (!EndOfPAEntr(pp) && pp->KindOfPE != HoldProperty) { + opp = &(pp->NextOfPE); + pp = RepHoldProp(pp->NextOfPE); + } + if (!pp) { WRITE_UNLOCK(ae->ARWLock); return FALSE; } - *opp = AbsHoldProp(new); - } else { - pp->RefsOfPE++; - } - WRITE_UNLOCK(ae->ARWLock); - return TRUE; -} - -int Yap_AtomDecreaseHold(Atom at) { - AtomEntry *ae = RepAtom(at); - HoldEntry *pp; - Prop *opp = &(ae->PropsOfAE); - - WRITE_LOCK(ae->ARWLock); - pp = RepHoldProp(ae->PropsOfAE); - while (!EndOfPAEntr(pp) && pp->KindOfPE != HoldProperty) { - opp = &(pp->NextOfPE); - pp = RepHoldProp(pp->NextOfPE); - } - if (!pp) { + pp->RefsOfPE--; + if (!pp->RefsOfPE) { + *opp = pp->NextOfPE; + Yap_FreeCodeSpace((ADDR)pp); + } WRITE_UNLOCK(ae->ARWLock); - return FALSE; + return TRUE; } - pp->RefsOfPE--; - if (!pp->RefsOfPE) { - *opp = pp->NextOfPE; - Yap_FreeCodeSpace((ADDR)pp); - } - WRITE_UNLOCK(ae->ARWLock); - return TRUE; -} -const char *IndicatorOfPred(PredEntry *pe) { - const char *mods; - Atom at; - arity_t arity; - if (pe->ModuleOfPred == IDB_MODULE) { - mods = "idb"; - if (pe->PredFlags & NumberDBPredFlag) { - snprintf(LOCAL_FileNameBuf, YAP_FILENAME_MAX, "idb:" UInt_FORMAT, - (Int)(pe->FunctorOfPred)); - return LOCAL_FileNameBuf; - } else if (pe->PredFlags & AtomDBPredFlag) { - at = (Atom)pe->FunctorOfPred; - arity = 0; + const char *IndicatorOfPred(PredEntry *pe) { + const char *mods; + Atom at; + arity_t arity; + if (pe->ModuleOfPred == IDB_MODULE) { + mods = "idb"; + if (pe->PredFlags & NumberDBPredFlag) { + snprintf(LOCAL_FileNameBuf, YAP_FILENAME_MAX, "idb:" UInt_FORMAT, + (Int)(pe->FunctorOfPred)); + return LOCAL_FileNameBuf; + } else if (pe->PredFlags & AtomDBPredFlag) { + at = (Atom)pe->FunctorOfPred; + arity = 0; + } else { + at = NameOfFunctor(pe->FunctorOfPred); + arity = ArityOfFunctor(pe->FunctorOfPred); + } } else { - at = NameOfFunctor(pe->FunctorOfPred); - arity = ArityOfFunctor(pe->FunctorOfPred); - } - } else { - if (pe->ModuleOfPred == 0) - mods = "prolog"; - else - mods = RepAtom(AtomOfTerm(pe->ModuleOfPred))->StrOfAE; - arity = pe->ArityOfPE; - if (arity == 0) { - at = (Atom)pe->FunctorOfPred; - } else { - at = NameOfFunctor(pe->FunctorOfPred); + if (pe->ModuleOfPred == 0) + mods = "prolog"; + else + mods = RepAtom(AtomOfTerm(pe->ModuleOfPred))->StrOfAE; + arity = pe->ArityOfPE; + if (arity == 0) { + at = (Atom)pe->FunctorOfPred; + } else { + at = NameOfFunctor(pe->FunctorOfPred); + } } + snprintf(LOCAL_FileNameBuf, YAP_FILENAME_MAX, "%s:%s/" UInt_FORMAT, mods, + RepAtom(at)->StrOfAE, arity); + return LOCAL_FileNameBuf; } - snprintf(LOCAL_FileNameBuf, YAP_FILENAME_MAX, "%s:%s/" UInt_FORMAT, mods, - RepAtom(at)->StrOfAE, arity); - return LOCAL_FileNameBuf; -} diff --git a/C/adtdefs.c.new b/C/adtdefs.c.new new file mode 100755 index 000000000..02c395d45 --- /dev/null +++ b/C/adtdefs.c.new @@ -0,0 +1,1268 @@ +/************************************************************************* +* * +* YAP Prolog * +* * +* Yap Prolog was developed at NCCUP - Universidade do Porto * +* * +* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * +* * +************************************************************************** +* * +* File: adtdefs.c * +* Last rev: * +* mods: * +* comments: abstract machine definitions * +* * +*************************************************************************/ +#ifdef SCCS +static char SccsId[] = "%W% %G%"; +#endif + +#define ADTDEFS_C + +#ifdef __SUNPRO_CC +#define inline +#endif + +#include "Yap.h" +#include "Yatom.h" +#include "clause.h" +#include "yapio.h" +#include +#include +#if HAVE_STRING_Hq +#include +#endif + +uint64_t HashFunction(const unsigned char *CHP) { + /* djb2 */ + uint64_t hash = 5381; + uint64_t c; + + while ((c = *CHP++) != '\0') { + /* hash = ((hash << 5) + hash) + c; hash * 33 + c */ + hash = hash * (uint64_t)33 + c; + } + return hash; + /* + UInt OUT=0, i = 1; + while(*CHP != '\0') { OUT += (UInt)(*CHP++); } + return OUT; + */ +} + +/* this routine must be run at least having a read lock on ae */ +static Prop +GetFunctorProp(AtomEntry *ae, + arity_t arity) { /* look property list of atom a for kind */ + + PropEntry *p = ae->PropsOfAE; + while (p != NIL) { + if (p->KindOfPE == FunctorProperty && + RepFunctorProp(p)->ArityOfFE == arity) { + return p; + } + p = p->NextOfPE; + } + return NIL; +} + +/* vsc: We must guarantee that IsVarTerm(functor) returns true! */ +static inline Functor InlinedUnlockedMkFunctor(AtomEntry *ae, arity_t arity) { + FunctorEntry *p; + Prop p0; + + p0 = GetFunctorProp(ae, arity); + if (p0 != NIL) { + return ((Functor)RepProp(p0)); + } + p = (FunctorEntry *)Yap_AllocAtomSpace(sizeof(*p)); + if (!p) + return NULL; + p->KindOfPE = FunctorProperty; + p->NameOfFE = AbsAtom(ae); + p->ArityOfFE = arity; + p->PropsOfFE = NIL; + INIT_RWLOCK(p->FRWLock); + /* respect the first property, in case this is a wide atom */ + AddPropToAtom(ae, (PropEntry *)p); + return ((Functor)p); +} + +Functor Yap_UnlockedMkFunctor(AtomEntry *ae, arity_t arity) { + return (InlinedUnlockedMkFunctor(ae, arity)); +} + +/* vsc: We must guarantee that IsVarTerm(functor) returns true! */ +Functor Yap_MkFunctor(Atom ap, arity_t arity) { + AtomEntry *ae = RepAtom(ap); + Functor f; + + WRITE_LOCK(ae->ARWLock); + f = InlinedUnlockedMkFunctor(ae, arity); + WRITE_UNLOCK(ae->ARWLock); + return f; +} + +/* vsc: We must guarantee that IsVarTerm(functor) returns true! */ +void Yap_MkFunctorWithAddress(Atom ap, unsigned int arity, FunctorEntry *p) { + AtomEntry *ae = RepAtom(ap); + + WRITE_LOCK(ae->ARWLock); + p->KindOfPE = FunctorProperty; + p->NameOfFE = ap; + p->ArityOfFE = arity; + AddPropToAtom(ae, (PropEntry *)p); + WRITE_UNLOCK(ae->ARWLock); +} + +inline static Atom SearchInInvisible(const unsigned char *atom) { + AtomEntry *chain; + + READ_LOCK(INVISIBLECHAIN.AERWLock); + chain = RepAtom(INVISIBLECHAIN.Entry); + while (!EndOfPAEntr(chain) && strcmp((char *)chain->StrOfAE, (char *)atom)) { + chain = RepAtom(chain->NextOfAE); + } + READ_UNLOCK(INVISIBLECHAIN.AERWLock); + if (EndOfPAEntr(chain)) + return (NIL); + else + return (AbsAtom(chain)); +} + +static inline Atom SearchAtom(const unsigned char *p, Atom a) { + AtomEntry *ae; + + /* search atom in chain */ + while (a != NIL) { + ae = RepAtom(a); + if (strcmp((char *)ae->StrOfAE, (const char *)p) == 0) { + return (a); + } + a = ae->NextOfAE; + } + return (NIL); +} + + +static Atom +LookupAtom(const unsigned char *atom) { /* lookup atom in atom table */ + uint64_t hash; + const unsigned char *p; + Atom a, na = NIL; + AtomEntry *ae; + size_t sz = AtomHashTableSize; + + /* compute hash */ + p = atom; + + hash = HashFunction(p); + hash = hash % sz; + /* we'll start by holding a read lock in order to avoid contention */ + READ_LOCK(HashChain[hash].AERWLock); + a = HashChain[hash].Entry; + /* search atom in chain */ + na = SearchAtom(atom, a); + if (na != NIL) { + READ_UNLOCK(HashChain[hash].AERWLock); + return (na); + } + READ_UNLOCK(HashChain[hash].AERWLock); + /* we need a write lock */ + WRITE_LOCK(HashChain[hash].AERWLock); +/* concurrent version of Yap, need to take care */ +#if defined(YAPOR) || defined(THREADS) + if (a != HashChain[hash].Entry) { + a = HashChain[hash].Entry; + na = SearchAtom(atom, a); + if (na != NIL) { + WRITE_UNLOCK(HashChain[hash].AERWLock); + return na; + } + } +#endif + /* add new atom to start of chain */ + size_t asz = strlen((const char *)atom); + + ae = (AtomEntry *)Yap_AllocAtomSpace((sizeof *ae) + + asz+4); + if (ae == NULL) { + WRITE_UNLOCK(HashChain[hash].AERWLock); + return NIL; + } + NOfAtoms++; + na = AbsAtom(ae); + ae->PropsOfAE = NIL; + stpncpy((char *)ae->StrOfAE, (const char *)atom, asz+1); + + ae->NextOfAE = a; + HashChain[hash].Entry = na; + INIT_RWLOCK(ae->ARWLock); + WRITE_UNLOCK(HashChain[hash].AERWLock); + if (NOfAtoms > 2 * AtomHashTableSize) { + Yap_signal(YAP_CDOVF_SIGNAL); + } + + return na; +} + +Atom Yap_LookupAtomWithLength(const char *atom, + size_t len0) { /* lookup atom in atom table */ + Atom at; + unsigned char *ptr; + + /* not really a wide atom */ + ptr = Yap_AllocCodeSpace(len0 + 1); + if (!ptr) + return NIL; + memmove(ptr, atom, len0); + ptr[len0] = '\0'; + at = LookupAtom(ptr); + Yap_FreeCodeSpace(ptr); + return at; +} + +Atom Yap_LookupAtom(const char *atom) { /* lookup atom in atom table */ + return LookupAtom((const unsigned char *)atom); +} + +Atom Yap_ULookupAtom( + const unsigned char *atom) { /* lookup atom in atom table */ + return LookupAtom(atom); +} + + +Atom Yap_FullLookupAtom(const char *atom) { /* lookup atom in atom table */ + Atom t; + + if ((t = SearchInInvisible((const unsigned char *)atom)) != NIL) { + return (t); + } + return (LookupAtom((const unsigned char *)atom)); +} + +void Yap_LookupAtomWithAddress(const char *atom, + AtomEntry *ae) { /* lookup atom in atom table */ + register CELL hash; + register const unsigned char *p; + Atom a; + + /* compute hash */ + p = (const unsigned char *)atom; + hash = HashFunction(p) % AtomHashTableSize; + /* ask for a WRITE lock because it is highly unlikely we shall find anything + */ + WRITE_LOCK(HashChain[hash].AERWLock); + a = HashChain[hash].Entry; + /* search atom in chain */ + if (SearchAtom(p, a) != NIL) { + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, + "repeated initialization for atom %s", ae); + WRITE_UNLOCK(HashChain[hash].AERWLock); + return; + } + /* add new atom to start of chain */ + NOfAtoms++; + ae->NextOfAE = a; + HashChain[hash].Entry = AbsAtom(ae); + ae->PropsOfAE = NIL; + strcpy((char *)ae->StrOfAE, (char *)atom); + INIT_RWLOCK(ae->ARWLock); + WRITE_UNLOCK(HashChain[hash].AERWLock); +} + +void Yap_ReleaseAtom(Atom atom) { /* Releases an atom from the hash chain */ + register Int hash; + register const unsigned char *p; + AtomEntry *inChain; + AtomEntry *ap = RepAtom(atom); + char unsigned *name = ap->UStrOfAE; + + /* compute hash */ + p = name; + hash = HashFunction(p) % AtomHashTableSize; + WRITE_LOCK(HashChain[hash].AERWLock); + if (HashChain[hash].Entry == atom) { + NOfAtoms--; + HashChain[hash].Entry = ap->NextOfAE; + WRITE_UNLOCK(HashChain[hash].AERWLock); + return; + } + /* else */ + inChain = RepAtom(HashChain[hash].Entry); + while (inChain && inChain->NextOfAE != atom) + inChain = RepAtom(inChain->NextOfAE); + if (!inChain) + return; + WRITE_LOCK(inChain->ARWLock); + inChain->NextOfAE = ap->NextOfAE; + WRITE_UNLOCK(inChain->ARWLock); + WRITE_UNLOCK(HashChain[hash].AERWLock); + ap->NextOfAE = NULL; +} + +static Prop +GetAPropHavingLock(AtomEntry *ae, + PropFlags kind) { /* look property list of atom a for kind */ + PropEntry *pp; + + pp = RepProp(ae->PropsOfAE); + while (!EndOfPAEntr(pp) && pp->KindOfPE != kind) + pp = RepProp(pp->NextOfPE); + return (AbsProp(pp)); +} + +Prop Yap_GetAPropHavingLock( + AtomEntry *ae, PropFlags kind) { /* look property list of atom a for kind */ + return GetAPropHavingLock(ae, kind); +} + +static Prop +GetAProp(Atom a, PropFlags kind) { /* look property list of atom a for kind */ + AtomEntry *ae = RepAtom(a); + Prop out; + + READ_LOCK(ae->ARWLock); + out = GetAPropHavingLock(ae, kind); + READ_UNLOCK(ae->ARWLock); + return (out); +} + +Prop Yap_GetAProp(Atom a, + PropFlags kind) { /* look property list of atom a for kind */ + return GetAProp(a, kind); +} + +OpEntry *Yap_GetOpPropForAModuleHavingALock( + Atom a, Term mod) { /* look property list of atom a for kind */ + AtomEntry *ae = RepAtom(a); + PropEntry *pp; + + pp = RepProp(ae->PropsOfAE); + while (!EndOfPAEntr(pp) && + (pp->KindOfPE != OpProperty || ((OpEntry *)pp)->OpModule != mod)) + pp = RepProp(pp->NextOfPE); + if (EndOfPAEntr(pp)) { + return NULL; + } + return (OpEntry *)pp; +} + +int Yap_HasOp(Atom a) { /* look property list of atom a for kind */ + AtomEntry *ae = RepAtom(a); + PropEntry *pp; + + READ_LOCK(ae->ARWLock); + pp = RepProp(ae->PropsOfAE); + while (!EndOfPAEntr(pp) && (pp->KindOfPE != OpProperty)) + pp = RepProp(pp->NextOfPE); + READ_UNLOCK(ae->ARWLock); + if (EndOfPAEntr(pp)) { + return FALSE; + } else { + return TRUE; + } +} + +OpEntry * +Yap_OpPropForModule(Atom a, + Term mod) { /* look property list of atom a for kind */ + AtomEntry *ae = RepAtom(a); + PropEntry *pp; + OpEntry *info = NULL; + + if (mod == TermProlog) + mod = PROLOG_MODULE; + WRITE_LOCK(ae->ARWLock); + pp = RepProp(ae->PropsOfAE); + while (!EndOfPAEntr(pp)) { + if (pp->KindOfPE == OpProperty) { + info = (OpEntry *)pp; + if (info->OpModule == mod) { + WRITE_LOCK(info->OpRWLock); + WRITE_UNLOCK(ae->ARWLock); + return info; + } + } + pp = pp->NextOfPE; + } + info = (OpEntry *)Yap_AllocAtomSpace(sizeof(OpEntry)); + info->KindOfPE = Ord(OpProperty); + info->OpModule = mod; + info->OpName = a; + LOCK(OpListLock); + info->OpNext = OpList; + OpList = info; + UNLOCK(OpListLock); + AddPropToAtom(ae, (PropEntry *)info); + INIT_RWLOCK(info->OpRWLock); + WRITE_LOCK(info->OpRWLock); + WRITE_UNLOCK(ae->ARWLock); + info->Prefix = info->Infix = info->Posfix = 0; + return info; +} + +OpEntry * +Yap_GetOpProp(Atom a, op_type type, + Term cmod USES_REGS) { /* look property list of atom a for kind */ + AtomEntry *ae = RepAtom(a); + PropEntry *pp; + OpEntry *oinfo = NULL; + + READ_LOCK(ae->ARWLock); + pp = RepProp(ae->PropsOfAE); + while (!EndOfPAEntr(pp)) { + OpEntry *info = NULL; + if (pp->KindOfPE != OpProperty) { + pp = RepProp(pp->NextOfPE); + continue; + } + info = (OpEntry *)pp; + if (info->OpModule != cmod && info->OpModule != PROLOG_MODULE) { + pp = RepProp(pp->NextOfPE); + continue; + } + if (type == INFIX_OP) { + if (!info->Infix) { + pp = RepProp(pp->NextOfPE); + continue; + } + } else if (type == POSFIX_OP) { + if (!info->Posfix) { + pp = RepProp(pp->NextOfPE); + continue; + } + } else { + if (!info->Prefix) { + pp = RepProp(pp->NextOfPE); + continue; + } + } + /* if it is not the latest module */ + if (info->OpModule == PROLOG_MODULE) { + /* cannot commit now */ + oinfo = info; + pp = RepProp(pp->NextOfPE); + } else { + READ_LOCK(info->OpRWLock); + READ_UNLOCK(ae->ARWLock); + return info; + } + } + if (oinfo) { + READ_LOCK(oinfo->OpRWLock); + READ_UNLOCK(ae->ARWLock); + return oinfo; + } + READ_UNLOCK(ae->ARWLock); + return NULL; +} + +inline static Prop GetPredPropByAtomHavingLock(AtomEntry *ae, Term cur_mod) +/* get predicate entry for ap/arity; create it if neccessary. */ +{ + Prop p0; + + p0 = ae->PropsOfAE; + while (p0) { + PredEntry *pe = RepPredProp(p0); + if (pe->KindOfPE == PEProp && + (pe->ModuleOfPred == cur_mod || !pe->ModuleOfPred)) { + return (p0); +#if THREADS + /* Thread Local Predicates */ + if (pe->PredFlags & ThreadLocalPredFlag) { + return AbsPredProp(Yap_GetThreadPred(pe INIT_REGS)); + } +#endif + } + p0 = pe->NextOfPE; + } + return (NIL); +} + +Prop Yap_GetPredPropByAtom(Atom at, Term cur_mod) +/* get predicate entry for ap/arity; create it if neccessary. */ +{ + Prop p0; + AtomEntry *ae = RepAtom(at); + + READ_LOCK(ae->ARWLock); + p0 = GetPredPropByAtomHavingLock(ae, cur_mod); + READ_UNLOCK(ae->ARWLock); + return (p0); +} + +inline static Prop GetPredPropByAtomHavingLockInThisModule(AtomEntry *ae, Term cur_mod) +/* get predicate entry for ap/arity; create it if neccessary. */ +{ + Prop p0; + + p0 = ae->PropsOfAE; + while (p0) { + PredEntry *pe = RepPredProp(p0); + if (pe->KindOfPE == PEProp && pe->ModuleOfPred == cur_mod) { +#if THREADS + /* Thread Local Predicates */ + if (pe->PredFlags & ThreadLocalPredFlag) { + return AbsPredProp(Yap_GetThreadPred(pe INIT_REGS)); + } +#endif + return (p0); + } + p0 = pe->NextOfPE; + } + return (NIL); +} + +Prop Yap_GetPredPropByAtomInThisModule(Atom at, Term cur_mod) +/* get predicate entry for ap/arity; create it if neccessary. */ +{ + Prop p0; + AtomEntry *ae = RepAtom(at); + + READ_LOCK(ae->ARWLock); + p0 = GetPredPropByAtomHavingLockInThisModule(ae, cur_mod); + READ_UNLOCK(ae->ARWLock); + return (p0); +} + + +Prop Yap_GetPredPropByFunc(Functor f, Term cur_mod) +/* get predicate entry for ap/arity; */ +{ + Prop p0; + FUNC_READ_LOCK(f); + + p0 = GetPredPropByFuncHavingLock(f, cur_mod); + + FUNC_READ_UNLOCK(f); + return (p0); +} + +Prop Yap_GetPredPropByFuncInThisModule(Functor f, Term cur_mod) +/* get predicate entry for ap/arity; */ +{ + Prop p0; + + FUNC_READ_LOCK(f); + p0 = GetPredPropByFuncHavingLock(f, cur_mod); + FUNC_READ_UNLOCK(f); + return (p0); +} + +Prop Yap_GetPredPropHavingLock(Atom ap, unsigned int arity, Term mod) +/* get predicate entry for ap/arity; */ +{ + Prop p0; + AtomEntry *ae = RepAtom(ap); + Functor f; + + if (arity == 0) { + GetPredPropByAtomHavingLock(ae, mod); + } + f = InlinedUnlockedMkFunctor(ae, arity); + FUNC_READ_LOCK(f); + p0 = GetPredPropByFuncHavingLock(f, mod); + FUNC_READ_UNLOCK(f); + return (p0); +} + +/* get expression entry for at/arity; */ +Prop Yap_GetExpProp(Atom at, unsigned int arity) { + Prop p0; + AtomEntry *ae = RepAtom(at); + ExpEntry *p; + + READ_LOCK(ae->ARWLock); + p = RepExpProp(p0 = ae->PropsOfAE); + while (p0 && (p->KindOfPE != ExpProperty || p->ArityOfEE != arity)) + p = RepExpProp(p0 = p->NextOfPE); + READ_UNLOCK(ae->ARWLock); + return (p0); +} + +/* get expression entry for at/arity, at is already locked; */ +Prop Yap_GetExpPropHavingLock(AtomEntry *ae, unsigned int arity) { + Prop p0; + ExpEntry *p; + + p = RepExpProp(p0 = ae->PropsOfAE); + while (p0 && (p->KindOfPE != ExpProperty || p->ArityOfEE != arity)) + p = RepExpProp(p0 = p->NextOfPE); + + return (p0); +} + +static int ExpandPredHash(void) { + UInt new_size = PredHashTableSize + PredHashIncrement; + PredEntry **oldp = PredHash; + PredEntry **np = + (PredEntry **)Yap_AllocAtomSpace(sizeof(PredEntry **) * new_size); + UInt i; + + if (!np) { + return FALSE; + } + for (i = 0; i < new_size; i++) { + np[i] = NULL; + } + for (i = 0; i < PredHashTableSize; i++) { + PredEntry *p = PredHash[i]; + + while (p) { + PredEntry *nextp = p->NextPredOfHash; + UInt hsh = PRED_HASH(p->FunctorOfPred, p->ModuleOfPred, new_size); + p->NextPredOfHash = np[hsh]; + np[hsh] = p; + p = nextp; + } + } + PredHashTableSize = new_size; + PredHash = np; + Yap_FreeAtomSpace((ADDR)oldp); + return TRUE; +} + +/* fe is supposed to be locked */ +Prop Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod) { + PredEntry *p = (PredEntry *)Yap_AllocAtomSpace(sizeof(*p)); + + if (p == NULL) { + WRITE_UNLOCK(fe->FRWLock); + return NULL; + } + if (cur_mod == TermProlog || cur_mod == 0L) { + p->ModuleOfPred = 0L; + } else + p->ModuleOfPred = cur_mod; + // TRUE_FUNC_WRITE_LOCK(fe); + INIT_LOCK(p->PELock); + p->KindOfPE = PEProp; + p->ArityOfPE = fe->ArityOfFE; + p->cs.p_code.FirstClause = p->cs.p_code.LastClause = NULL; + p->cs.p_code.NOfClauses = 0; + p->PredFlags = UndefPredFlag; + p->src.OwnerFile = Yap_source_file_name(); + p->OpcodeOfPred = UNDEF_OPCODE; + p->CodeOfPred = p->cs.p_code.TrueCodeOfPred = (yamop *)(&(p->OpcodeOfPred)); + p->cs.p_code.ExpandCode = EXPAND_OP_CODE; + p->TimeStampOfPred = 0L; + p->LastCallOfPred = LUCALL_ASSERT; + p->MetaEntryOfPred = NULL; + if (cur_mod == TermProlog) + p->ModuleOfPred = 0L; + else + p->ModuleOfPred = cur_mod; + p->StatisticsForPred = NULL; + Yap_NewModulePred(cur_mod, p); + +#ifdef TABLING + p->TableOfPred = NULL; +#endif /* TABLING */ +#ifdef BEAM + p->beamTable = NULL; +#endif /* BEAM */ + /* careful that they don't cross MkFunctor */ + if (!trueGlobalPrologFlag(DEBUG_INFO_FLAG)) { + p->PredFlags |= NoTracePredFlag; + } + p->FunctorOfPred = fe; + if (fe->PropsOfFE) { + UInt hsh = PRED_HASH(fe, cur_mod, PredHashTableSize); + + WRITE_LOCK(PredHashRWLock); + if (10 * (PredsInHashTable + 1) > 6 * PredHashTableSize) { + if (!ExpandPredHash()) { + Yap_FreeCodeSpace((ADDR)p); + WRITE_UNLOCK(PredHashRWLock); + FUNC_WRITE_UNLOCK(fe); + return NULL; + } + /* retry hashing */ + hsh = PRED_HASH(fe, cur_mod, PredHashTableSize); + } + PredsInHashTable++; + if (p->ModuleOfPred == 0L) { + PredEntry *pe = RepPredProp(fe->PropsOfFE); + + hsh = PRED_HASH(fe, pe->ModuleOfPred, PredHashTableSize); + /* should be the first one */ + pe->NextPredOfHash = PredHash[hsh]; + PredHash[hsh] = pe; + fe->PropsOfFE = AbsPredProp(p); + p->NextOfPE = AbsPredProp(pe); + } else { + p->NextPredOfHash = PredHash[hsh]; + PredHash[hsh] = p; + p->NextOfPE = fe->PropsOfFE->NextOfPE; + fe->PropsOfFE->NextOfPE = AbsPredProp(p); + } + WRITE_UNLOCK(PredHashRWLock); + } else { + fe->PropsOfFE = AbsPredProp(p); + p->NextOfPE = NIL; + } + FUNC_WRITE_UNLOCK(fe); + { + Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred) + 1, p, + GPROF_NEW_PRED_FUNC); + if (!(p->PredFlags & (CPredFlag | AsmPredFlag))) { + Yap_inform_profiler_of_clause(&(p->cs.p_code.ExpandCode), + &(p->cs.p_code.ExpandCode) + 1, p, + GPROF_NEW_PRED_FUNC); + } + } + return AbsPredProp(p); +} + +#if THREADS +Prop Yap_NewThreadPred(PredEntry *ap USES_REGS) { + PredEntry *p = (PredEntry *)Yap_AllocAtomSpace(sizeof(*p)); + + if (p == NULL) { + return NIL; + } + INIT_LOCK(p->PELock); + p->StatisticsForPred = NULL : p->KindOfPE = PEProp; + p->ArityOfPE = ap->ArityOfPE; + p->cs.p_code.FirstClause = p->cs.p_code.LastClause = NULL; + p->cs.p_code.NOfClauses = 0; + p->PredFlags = ap->PredFlags & ~(IndexedPredFlag | SpiedPredFlag); +#if SIZEOF_INT_P == 4 + p->ExtraPredFlags = 0L; +#endif + p->MetaEntryOfPred = NULL; + p->src.OwnerFile = ap->src.OwnerFile; + p->OpcodeOfPred = FAIL_OPCODE; + p->CodeOfPred = p->cs.p_code.TrueCodeOfPred = (yamop *)(&(p->OpcodeOfPred)); + p->cs.p_code.ExpandCode = EXPAND_OP_CODE; + p->ModuleOfPred = ap->ModuleOfPred; + p->NextPredOfModule = NULL; + p->TimeStampOfPred = 0L; + p->LastCallOfPred = LUCALL_ASSERT; +#ifdef TABLING + p->TableOfPred = NULL; +#endif /* TABLING */ +#ifdef BEAM + p->beamTable = NULL; +#endif + /* careful that they don't cross MkFunctor */ + p->NextOfPE = AbsPredProp(LOCAL_ThreadHandle.local_preds); + LOCAL_ThreadHandle.local_preds = p; + p->FunctorOfPred = ap->FunctorOfPred; + Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred) + 1, p, + GPROF_NEW_PRED_THREAD); + if (falseGlobalPrologFlag(DEBUG_INFO_FLAG)) { + p->PredFlags |= (NoSpyPredFlag | NoTracePredFlag); + } + if (!(p->PredFlags & (CPredFlag | AsmPredFlag))) { + Yap_inform_profiler_of_clause(&(p->cs.p_code.ExpandCode), + &(p->cs.p_code.ExpandCode) + 1, p, + GPROF_NEW_PRED_THREAD); + } + return AbsPredProp(p); +} +#endif + +Prop Yap_NewPredPropByAtom(AtomEntry *ae, Term cur_mod) { + Prop p0; + PredEntry *p = (PredEntry *)Yap_AllocAtomSpace(sizeof(*p)); + CACHE_REGS + /* Printf("entering %s:%s/0\n", RepAtom(AtomOfTerm(cur_mod))->StrOfAE, + * ae->StrOfAE); */ + + if (p == NULL) { + WRITE_UNLOCK(ae->ARWLock); + return NIL; + } + INIT_LOCK(p->PELock); + p->KindOfPE = PEProp; + p->ArityOfPE = 0; + p->StatisticsForPred = NULL; + p->cs.p_code.FirstClause = p->cs.p_code.LastClause = NULL; + p->cs.p_code.NOfClauses = 0; + p->PredFlags = UndefPredFlag; + p->src.OwnerFile = Yap_source_file_name(); + p->OpcodeOfPred = UNDEF_OPCODE; + p->cs.p_code.ExpandCode = EXPAND_OP_CODE; + p->CodeOfPred = p->cs.p_code.TrueCodeOfPred = (yamop *)(&(p->OpcodeOfPred)); + p->MetaEntryOfPred = NULL; + if (cur_mod == TermProlog) + p->ModuleOfPred = 0; + else + p->ModuleOfPred = cur_mod; + Yap_NewModulePred(cur_mod, p); + p->TimeStampOfPred = 0L; + p->LastCallOfPred = LUCALL_ASSERT; +#ifdef TABLING + p->TableOfPred = NULL; +#endif /* TABLING */ +#ifdef BEAM + p->beamTable = NULL; +#endif + /* careful that they don't cross MkFunctor */ + AddPropToAtom(ae, (PropEntry *)p); + p0 = AbsPredProp(p); + p->FunctorOfPred = (Functor)AbsAtom(ae); + if (!trueGlobalPrologFlag(DEBUG_INFO_FLAG)) { + p->PredFlags |= (NoTracePredFlag | NoSpyPredFlag); + } + if (Yap_isSystemModule(CurrentModule)) + p->PredFlags |= StandardPredFlag; + WRITE_UNLOCK(ae->ARWLock); + { + Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred) + 1, p, + GPROF_NEW_PRED_ATOM); + if (!(p->PredFlags & (CPredFlag | AsmPredFlag))) { + Yap_inform_profiler_of_clause(&(p->cs.p_code.ExpandCode), + &(p->cs.p_code.ExpandCode) + 1, p, + GPROF_NEW_PRED_ATOM); + } + } + return p0; +} + +Prop Yap_PredPropByFunctorNonThreadLocal(Functor f, Term cur_mod) +/* get predicate entry for ap/arity; create it if neccessary. */ +{ + PredEntry *p; + + FUNC_WRITE_LOCK(f); + if (!(p = RepPredProp(f->PropsOfFE))) + return Yap_NewPredPropByFunctor(f, cur_mod); + + if ((p->ModuleOfPred == cur_mod || !(p->ModuleOfPred))) { + /* don't match multi-files */ + if (/*!(p->PredFlags & MultiFileFlag) ||*/ true || p->ModuleOfPred || !cur_mod || + cur_mod == TermProlog) { + FUNC_WRITE_UNLOCK(f); + return AbsPredProp(p); + } + } + if (p->NextOfPE) { + UInt hash = PRED_HASH(f, cur_mod, PredHashTableSize); + READ_LOCK(PredHashRWLock); + p = PredHash[hash]; + + while (p) { + if (p->FunctorOfPred == f && p->ModuleOfPred == cur_mod) { + READ_UNLOCK(PredHashRWLock); + FUNC_WRITE_UNLOCK(f); + return AbsPredProp(p); + } + p = p->NextPredOfHash; + } + READ_UNLOCK(PredHashRWLock); + } + return Yap_NewPredPropByFunctor(f, cur_mod); +} + +Prop Yap_PredPropByAtomNonThreadLocal(Atom at, Term cur_mod) +/* get predicate entry for ap/arity; create it if neccessary. */ +{ + Prop p0; + AtomEntry *ae = RepAtom(at); + + WRITE_LOCK(ae->ARWLock); + p0 = ae->PropsOfAE; + while (p0) { + PredEntry *pe = RepPredProp(p0); + if (pe->KindOfPE == PEProp && + (pe->ModuleOfPred == cur_mod || !pe->ModuleOfPred)) { + /* don't match multi-files */ + if (/*!(pe->PredFlags & MultiFileFlag) ||*/ true || pe->ModuleOfPred || !cur_mod || + cur_mod == TermProlog) { + WRITE_UNLOCK(ae->ARWLock); + return (p0); + } + } + p0 = pe->NextOfPE; + } + return Yap_NewPredPropByAtom(ae, cur_mod); +} + +Term Yap_GetValue(Atom a) { + Prop p0 = GetAProp(a, ValProperty); + Term out; + + if (p0 == NIL) + return (TermNil); + READ_LOCK(RepValProp(p0)->VRWLock); + out = RepValProp(p0)->ValueOfVE; + if (IsApplTerm(out)) { + Functor f = FunctorOfTerm(out); + if (f == FunctorDouble) { + CACHE_REGS + out = MkFloatTerm(FloatOfTerm(out)); + } else if (f == FunctorLongInt) { + CACHE_REGS + out = MkLongIntTerm(LongIntOfTerm(out)); + } else if (f == FunctorString) { + CACHE_REGS + out = MkStringTerm(StringOfTerm(out)); + } +#ifdef USE_GMP + else { + out = Yap_MkBigIntTerm(Yap_BigIntOfTerm(out)); + } +#endif + } + READ_UNLOCK(RepValProp(p0)->VRWLock); + return (out); +} + +void Yap_PutValue(Atom a, Term v) { + AtomEntry *ae = RepAtom(a); + Prop p0; + ValEntry *p; + Term t0; + + WRITE_LOCK(ae->ARWLock); + p0 = GetAPropHavingLock(ae, ValProperty); + if (p0 != NIL) { + p = RepValProp(p0); + WRITE_LOCK(p->VRWLock); + WRITE_UNLOCK(ae->ARWLock); + } else { + p = (ValEntry *)Yap_AllocAtomSpace(sizeof(ValEntry)); + if (p == NULL) { + WRITE_UNLOCK(ae->ARWLock); + return; + } + p->KindOfPE = ValProperty; + p->ValueOfVE = TermNil; + AddPropToAtom(RepAtom(a), (PropEntry *)p); + /* take care that the lock for the property will be inited even + if someone else searches for the property */ + INIT_RWLOCK(p->VRWLock); + WRITE_LOCK(p->VRWLock); + WRITE_UNLOCK(ae->ARWLock); + } + t0 = p->ValueOfVE; + if (IsFloatTerm(v)) { + /* store a float in code space, so that we can access the property */ + union { + Float f; + CELL ar[sizeof(Float) / sizeof(CELL)]; + } un; + CELL *pt, *iptr; + unsigned int i; + + un.f = FloatOfTerm(v); + if (IsFloatTerm(t0)) { + pt = RepAppl(t0); + } else { + if (IsApplTerm(t0)) { + Yap_FreeCodeSpace((char *)(RepAppl(t0))); + } + pt = (CELL *)Yap_AllocAtomSpace(sizeof(CELL) * + (1 + 2 * sizeof(Float) / sizeof(CELL))); + if (pt == NULL) { + WRITE_UNLOCK(ae->ARWLock); + return; + } + p->ValueOfVE = AbsAppl(pt); + pt[0] = (CELL)FunctorDouble; + } + + iptr = pt + 1; + for (i = 0; i < sizeof(Float) / sizeof(CELL); i++) { + *iptr++ = (CELL)un.ar[i]; + } + } else if (IsLongIntTerm(v)) { + CELL *pt; + Int val = LongIntOfTerm(v); + + if (IsLongIntTerm(t0)) { + pt = RepAppl(t0); + } else { + if (IsApplTerm(t0)) { + Yap_FreeCodeSpace((char *)(RepAppl(t0))); + } + pt = (CELL *)Yap_AllocAtomSpace(2 * sizeof(CELL)); + if (pt == NULL) { + WRITE_UNLOCK(ae->ARWLock); + return; + } + p->ValueOfVE = AbsAppl(pt); + pt[0] = (CELL)FunctorLongInt; + } + pt[1] = (CELL)val; +#ifdef USE_GMP + } else if (IsBigIntTerm(v)) { + CELL *ap = RepAppl(v); + Int sz = sizeof(MP_INT) + sizeof(CELL) + + (((MP_INT *)(ap + 1))->_mp_alloc * sizeof(mp_limb_t)); + CELL *pt = (CELL *)Yap_AllocAtomSpace(sz); + + if (pt == NULL) { + WRITE_UNLOCK(ae->ARWLock); + return; + } + if (IsApplTerm(t0)) { + Yap_FreeCodeSpace((char *)RepAppl(t0)); + } + memmove((void *)pt, (void *)ap, sz); + p->ValueOfVE = AbsAppl(pt); +#endif + } else if (IsStringTerm(v)) { + CELL *ap = RepAppl(v); + Int sz = sizeof(CELL) * (3 + ap[1]); + CELL *pt = (CELL *)Yap_AllocAtomSpace(sz); + + if (pt == NULL) { + WRITE_UNLOCK(ae->ARWLock); + return; + } + if (IsApplTerm(t0)) { + Yap_FreeCodeSpace((char *)RepAppl(t0)); + } + memmove((void *)pt, (void *)ap, sz); + p->ValueOfVE = AbsAppl(pt); + } else { + if (IsApplTerm(t0)) { + /* recover space */ + Yap_FreeCodeSpace((char *)(RepAppl(p->ValueOfVE))); + } + p->ValueOfVE = v; + } + WRITE_UNLOCK(p->VRWLock); +} + +bool Yap_PutAtomTranslation(Atom a, arity_t arity, Int i) { + AtomEntry *ae = RepAtom(a); + Prop p0; + TranslationEntry *p; + + WRITE_LOCK(ae->ARWLock); + p0 = GetAPropHavingLock(ae, TranslationProperty); + if (p0 == NIL) { + p = (TranslationEntry *)Yap_AllocAtomSpace(sizeof(TranslationEntry)); + if (p == NULL) { + WRITE_UNLOCK(ae->ARWLock); + return false; + } + p->KindOfPE = TranslationProperty; + p->Translation = i; + p->arity = arity; + AddPropToAtom(RepAtom(a), (PropEntry *)p); + } + /* take care that the lock for the property will be inited even + if someone else searches for the property */ + WRITE_UNLOCK(ae->ARWLock); + return true; +} + +bool Yap_PutFunctorTranslation(Atom a, arity_t arity, Int i) { + AtomEntry *ae = RepAtom(a); + Prop p0; + TranslationEntry *p; + + WRITE_LOCK(ae->ARWLock); + p0 = GetAPropHavingLock(ae, TranslationProperty); + if (p0 == NIL) { + p = (TranslationEntry *)Yap_AllocAtomSpace(sizeof(TranslationEntry)); + if (p == NULL) { + WRITE_UNLOCK(ae->ARWLock); + return false; + } + p->KindOfPE = TranslationProperty; + p->Translation = i; + p->arity = arity; + AddPropToAtom(RepAtom(a), (PropEntry *)p); + } + /* take care that the lock for the property will be inited even + if someone else searches for the property */ + WRITE_UNLOCK(ae->ARWLock); + return true; +} + +bool Yap_PutAtomMutex(Atom a, void *i) { + AtomEntry *ae = RepAtom(a); + Prop p0; + MutexEntry *p; + + WRITE_LOCK(ae->ARWLock); + p0 = GetAPropHavingLock(ae, MutexProperty); + if (p0 == NIL) { + p = (MutexEntry *)Yap_AllocAtomSpace(sizeof(MutexEntry)); + if (p == NULL) { + WRITE_UNLOCK(ae->ARWLock); + return false; + } + p->KindOfPE = MutexProperty; + p->Mutex = i; + AddPropToAtom(RepAtom(a), (PropEntry *)p); + } + /* take care that the lock for the property will be inited even + if someone else searches for the property */ + WRITE_UNLOCK(ae->ARWLock); + return true; +} + +Term Yap_ArrayToList(register Term *tp, size_t nof) { + CACHE_REGS + register Term *pt = tp + nof; + register Term t; + + t = MkAtomTerm(AtomNil); + while (pt > tp) { + Term tm = *--pt; +#if YAPOR_SBA + if (tm == 0) + t = MkPairTerm((CELL)pt, t); + else +#endif + t = MkPairTerm(tm, t); + } + return (t); +} + +int Yap_GetName(char *s, UInt max, Term t) { + register Term Head; + register Int i; + + if (IsVarTerm(t) || !IsPairTerm(t)) + return FALSE; + while (IsPairTerm(t)) { + Head = HeadOfTerm(t); + if (!IsNumTerm(Head)) + return (FALSE); + i = IntOfTerm(Head); + if (i < 0 || i > MAX_ISO_LATIN1) + return FALSE; + *s++ = i; + t = TailOfTerm(t); + if (--max == 0) { + Yap_Error(SYSTEM_ERROR_FATAL, t, "not enough space for GetName"); + } + } + *s = '\0'; + return TRUE; +} + +#ifdef SFUNC + +Term MkSFTerm(Functor f, int n, Term *a, empty_value) { + Term t, p = AbsAppl(H); + int i; + + *H++ = f; + RESET_VARIABLE(H); + ++H; + for (i = 1; i <= n; ++i) { + t = Derefa(a++); + if (t != empty_value) { + *H++ = i; + *H++ = t; + } + } + *H++ = 0; + return (p); +} + +CELL *ArgsOfSFTerm(Term t) { + CELL *p = RepAppl(t) + 1; + + while (*p != (CELL)p) + p = CellPtr(*p) + 1; + return (p + 1); +} + +#endif + +static HoldEntry *InitAtomHold(void) { + HoldEntry *x = (HoldEntry *)Yap_AllocAtomSpace(sizeof(struct hold_entry)); + if (x == NULL) { + return NULL; + } + x->KindOfPE = HoldProperty; + x->NextOfPE = NIL; + x->RefsOfPE = 1; + return x; +} + +int Yap_AtomIncreaseHold(Atom at) { + AtomEntry *ae = RepAtom(at); + HoldEntry *pp; + Prop *opp = &(ae->PropsOfAE); + + WRITE_LOCK(ae->ARWLock); + pp = RepHoldProp(ae->PropsOfAE); + while (!EndOfPAEntr(pp) && pp->KindOfPE != HoldProperty) { + opp = &(pp->NextOfPE); + pp = RepHoldProp(pp->NextOfPE); + } + if (!pp) { + HoldEntry *new = InitAtomHold(); + if (!new) { + WRITE_UNLOCK(ae->ARWLock); + return FALSE; + } + *opp = AbsHoldProp(new); + } else { + pp->RefsOfPE++; + } + WRITE_UNLOCK(ae->ARWLock); + return TRUE; +} + +int Yap_AtomDecreaseHold(Atom at) { + AtomEntry *ae = RepAtom(at); + HoldEntry *pp; + Prop *opp = &(ae->PropsOfAE); + + WRITE_LOCK(ae->ARWLock); + pp = RepHoldProp(ae->PropsOfAE); + while (!EndOfPAEntr(pp) && pp->KindOfPE != HoldProperty) { + opp = &(pp->NextOfPE); + pp = RepHoldProp(pp->NextOfPE); + } + if (!pp) { + WRITE_UNLOCK(ae->ARWLock); + return FALSE; + } + pp->RefsOfPE--; + if (!pp->RefsOfPE) { + *opp = pp->NextOfPE; + Yap_FreeCodeSpace((ADDR)pp); + } + WRITE_UNLOCK(ae->ARWLock); + return TRUE; +} + +const char *IndicatorOfPred(PredEntry *pe) { + const char *mods; + Atom at; + arity_t arity; + if (pe->ModuleOfPred == IDB_MODULE) { + mods = "idb"; + if (pe->PredFlags & NumberDBPredFlag) { + snprintf(LOCAL_FileNameBuf, YAP_FILENAME_MAX, "idb:" UInt_FORMAT, + (Int)(pe->FunctorOfPred)); + return LOCAL_FileNameBuf; + } else if (pe->PredFlags & AtomDBPredFlag) { + at = (Atom)pe->FunctorOfPred; + arity = 0; + } else { + at = NameOfFunctor(pe->FunctorOfPred); + arity = ArityOfFunctor(pe->FunctorOfPred); + } + } else { + if (pe->ModuleOfPred == 0) + mods = "prolog"; + else + mods = RepAtom(AtomOfTerm(pe->ModuleOfPred))->StrOfAE; + arity = pe->ArityOfPE; + if (arity == 0) { + at = (Atom)pe->FunctorOfPred; + } else { + at = NameOfFunctor(pe->FunctorOfPred); + } + } + snprintf(LOCAL_FileNameBuf, YAP_FILENAME_MAX, "%s:%s/" UInt_FORMAT, mods, + RepAtom(at)->StrOfAE, arity); + return LOCAL_FileNameBuf; +} diff --git a/C/agc.c b/C/agc.c index 5a4b74f85..8b9417a3d 100755 --- a/C/agc.c +++ b/C/agc.c @@ -340,8 +340,8 @@ mark_global_cell(CELL *pt) Int sz = 3 + (sizeof(MP_INT)+ (((MP_INT *)(pt+2))->_mp_alloc*sizeof(mp_limb_t)))/sizeof(CELL); - Opaque_CallOnGCMark f; - Opaque_CallOnGCRelocate f2; + YAP_Opaque_CallOnGCMark f; + YAP_Opaque_CallOnGCRelocate f2; Term t = AbsAppl(pt); if ( (f = Yap_blob_gc_mark_handler(t)) ) { diff --git a/C/alloc.c b/C/alloc.c index 8614ebbe6..e9d5789d4 100644 --- a/C/alloc.c +++ b/C/alloc.c @@ -1,19 +1,18 @@ /************************************************************************* -* * -* YAP Prolog * -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * -* * -************************************************************************** -* * -* File: alloc.c * -* Last rev: * -* mods: * -* comments: allocating space * -* version:$Id: alloc.c,v 1.95 2008-05-10 23:24:11 vsc Exp $ * -*************************************************************************/ + * * + * YAP Prolog * + * * + * Yap Prolog was developed at NCCUP - Universidade do Porto * + * * + * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * + * * + ************************************************************************** + * * + * File: alloc.c * Last + *rev: * mods: + ** comments: allocating space * + * version:$Id: alloc.c,v 1.95 2008-05-10 23:24:11 vsc Exp $ * + *************************************************************************/ #ifdef SCCS static char SccsId[] = "%W% %G%"; @@ -43,6 +42,12 @@ static char SccsId[] = "%W% %G%"; #if HAVE_FCNTL_H #include #endif +#if HAVE_SYS_TIME_H +#include +#endif +#if HAVE_SYS_RESOURCE_H +#include +#endif #if HAVE_SYS_STAT_H #include #endif @@ -77,11 +82,13 @@ void *my_malloc(size_t sz) { p = malloc(sz); // Yap_DebugPuts(stderr,"gof\n"); - if (Yap_do_low_level_trace) - fprintf(stderr, "+ %p: %" Sizet_F "\n", p, sz); - if (sz > 500 && write_malloc++ > 0) - __android_log_print(ANDROID_LOG_ERROR, "YAPDroid ", "+ %d %p", write_malloc, - p); + if (Yap_do_low_level_trace) { +#if __ANDROID__ + // __android_log_print(ANDROID_LOG_ERROR, "YAPDroid ", "+ %d %p", write_malloc,p); +#else + fprintf(stderr, "+s %p\n @%p %ld\n", p, TR, LCL0 - (CELL *)LCL0); +#endif + } return p; } @@ -89,22 +96,22 @@ void *my_realloc(void *ptr, size_t sz) { void *p; p = realloc(ptr, sz); - if (Yap_do_low_level_trace) + //if (Yap_do_low_level_trace) // fprintf(stderr, "+ %p -> %p : " Sizet_F "\n", ptr, p, sz); - // Yap_DebugPuts(stderr,"gof\n"); - if (sz > 500 && write_malloc++ > 0) - __android_log_print(ANDROID_LOG_ERROR, "YAPDroid ", "* %d %p", write_malloc, - p); + // Yap_DebugPuts(stderr,"gof\n"); +// if (sz > 500 && write_malloc++ > 0) +// __android_log_print(ANDROID_LOG_ERROR, "YAPDroid ", "* %d %p", +// write_malloc, p); return p; } void my_free(void *p) { // printf("f %p\n",p); if (Yap_do_low_level_trace) - fprintf(stderr, "+ %p\n", p); - if (write_malloc && write_malloc++ > 0) - __android_log_print(ANDROID_LOG_ERROR, "YAPDroid ", "- %d %p", write_malloc, - p); + fprintf(stderr, "- %p\n @%p %ld\n", p, TR, (long int)(LCL0 - (CELL *)B) ); + //if (write_malloc && write_malloc++ > 0) +// __android_log_print(ANDROID_LOG_ERROR, "YAPDroid ", "- %d %p", write_malloc, +// p); free(p); // Yap_DebugPuts(stderr,"gof\n"); @@ -296,7 +303,7 @@ ADDR Yap_InitPreAllocCodeSpace(int wid) { #else my_malloc(sz) #endif - )) { + )) { REMOTE_PrologMode(wid) &= ~MallocMode; #if USE_DL_MALLOC UNLOCK(DLMallocLock); @@ -382,6 +389,17 @@ void Yap_InitHeap(void *heap_addr) { HeapMax = 0; } +// get an approximation to total memory data-base size. + size_t Yap_HeapUsed(void) +{ + #if HAVE_MALLINFO + struct mallinfo mi = mallinfo(); + return mi.uordblks - (LOCAL_TrailTop-LOCAL_GlobalBase); +#else + return Yap_ClauseSpace+Yap_IndexSpace_Tree+Yap_LUClauseSpace+Yap_LUIndexSpace_CP; +#endif +} + static void InitExStacks(int wid, int Trail, int Stack) { CACHE_REGS UInt pm, sa; @@ -393,7 +411,7 @@ static void InitExStacks(int wid, int Trail, int Stack) { Stack = MinStackSpace; pm = (Trail + Stack) * K; /* memory to be * requested */ - sa = Stack * K; /* stack area size */ + sa = Stack * K; /* stack area size */ #ifdef THREADS if (wid) @@ -671,7 +689,7 @@ static char *AllocHeap(size_t size) { LOCK(FreeBlocksLock); if ((b = GetBlock(size))) { if (b->b_size >= size + 24 + 1) { - n = (BlockHeader *)(((YAP_SEG_SIZE *)b) + size + 1)v; + n = (BlockHeader *)(((YAP_SEG_SIZE *)b) + size + 1) v; n->b_size = b->b_size - size - 1; b->b_size = size; AddToFreeList(n); @@ -1328,7 +1346,7 @@ XX realloc(MALLOC_T ptr, size_t size) { MALLOC_T new = malloc(size); if (ptr) - memcpy(new, ptr, size); + memmove(new, ptr, size); free(ptr); return (new); } @@ -1455,7 +1473,7 @@ void Yap_InitMemory(UInt Trail, UInt Heap, UInt Stack) { #endif pm = (Trail + Heap + Stack); /* memory to be * requested */ - sa = Stack; /* stack area size */ + sa = Stack; /* stack area size */ ta = Trail; /* trail area size */ #if RANDOMIZE_START_ADDRESS @@ -1477,7 +1495,7 @@ void Yap_InitMemory(UInt Trail, UInt Heap, UInt Stack) { LOCAL_GlobalBase = LOCAL_LocalBase - sa; HeapLim = LOCAL_GlobalBase; /* avoid confusions while - * * restoring */ + * * restoring */ #if !USE_DL_MALLOC AuxTop = (ADDR)(AuxSp = (CELL *)LOCAL_GlobalBase); #endif @@ -1496,8 +1514,9 @@ void Yap_InitMemory(UInt Trail, UInt Heap, UInt Stack) { (UInt)LOCAL_TrailTop); #endif - fprintf(stderr, "Heap+Aux: " UInt_FORMAT "\tLocal+Global: " UInt_FORMAT - "\tTrail: " UInt_FORMAT "\n", + fprintf(stderr, + "Heap+Aux: " UInt_FORMAT "\tLocal+Global: " UInt_FORMAT + "\tTrail: " UInt_FORMAT "\n", pm - sa - ta, sa, ta); } #endif /* DEBUG */ diff --git a/C/amasm.c b/C/amasm.c index ca67e65af..076c908f0 100755 --- a/C/amasm.c +++ b/C/amasm.c @@ -1434,10 +1434,12 @@ a_p(op_numbers opcode, clause_info *clinfo, yamop *code_p, int pass_no, if (Flags & CPredFlag) { code_p->opc = emit_op(_execute_cpred); } - code_p->y_u.pp.p = RepPredProp(fe); - code_p->y_u.pp.p0 = clinfo->CurrentPred; + code_p->y_u.Osbpp.p = RepPredProp(fe); + code_p->y_u.Osbpp.p0 = clinfo->CurrentPred; + code_p->y_u.Osbpp.s = 0; + code_p->y_u.Osbpp.bmap = NULL; } - GONEXT(pp); + GONEXT(Osbpp); } else { if (pass_no) code_p->y_u.p.p = RepPredProp(fe); @@ -3901,7 +3903,7 @@ yamop *Yap_InitCommaContinuation(PredEntry *pe) { GONEXT(Osbmp); for (i = 0; i < arity; i++) GONEXT(yx); - GONEXT(pp); + GONEXT(Osbmp); pe->MetaEntryOfPred = code_p = Yap_AllocCodeSpace((size_t)code_p); code_p->opc = opcode(_call); @@ -3917,8 +3919,8 @@ Yap_AllocCodeSpace((size_t)code_p); GONEXT(yx); } code_p->opc = opcode(_dexecute); - code_p->y_u.pp.p0 = PredMetaCall; - code_p->y_u.pp.p = pe; - GONEXT(pp); + code_p->y_u.Osbpp.p0 = PredMetaCall; + code_p->y_u.Osbpp.p = pe; + GONEXT(Osbpp); return pe->MetaEntryOfPred; } diff --git a/C/args.c b/C/args.c index 8f65b5d5a..252f05223 100644 --- a/C/args.c +++ b/C/args.c @@ -38,92 +38,90 @@ int Yap_ArgKey(Atom key, const param_t *def, int n) { return -1; } -#define failed(e, t, a) failed__(e, t, a PASS_REGS) +#define YAP_XARGINFO(Error, Message) -static xarg *failed__(yap_error_number e, Term t, xarg *a USES_REGS) { - free(a); - return NULL; -} -xarg *Yap_ArgListToVector(Term listl, const param_t *def, int n) { +xarg *Yap_ArgListToVector__(const char *file, const char *function, int lineno, + Term listl, const param_t *def, int n, + yap_error_number err) { CACHE_REGS - listl = Deref(listl); - xarg *a = calloc(n, sizeof(xarg)); - if (IsApplTerm(listl) && FunctorOfTerm(listl) == FunctorModule) - listl = ArgOfTerm(2, listl); + xarg *a; + listl = Deref(listl); + if (IsVarTerm(listl)) { + Yap_ThrowError__(file, function, lineno, INSTANTIATION_ERROR, listl, + "while opening listl = ArgOfTerm(2, listl ,k)"); + } + a = calloc(n, sizeof(xarg)); + if (!IsPairTerm(listl) && listl != TermNil) { - if (IsVarTerm(listl)) { - return failed(INSTANTIATION_ERROR, listl, a); - } if (IsAtomTerm(listl)) { xarg *na = matchKey(AtomOfTerm(listl), a, n, def); if (!na) { - return failed(TYPE_ERROR_LIST, listl, a); + Yap_ThrowError__(file, function, lineno, TYPE_ERROR_LIST, listl, "match key"); } } else if (IsApplTerm(listl)) { Functor f = FunctorOfTerm(listl); if (IsExtensionFunctor(f)) { - return failed(TYPE_ERROR_LIST, listl, a); + Yap_ThrowError__(file, function, lineno, TYPE_ERROR_LIST, listl, "callable"); } arity_t arity = ArityOfFunctor(f); if (arity != 1) { - return failed(TYPE_ERROR_LIST, listl, a); + Yap_ThrowError__(file, function, lineno, TYPE_ERROR_LIST, listl, "bad arity"); } xarg *na = matchKey(NameOfFunctor(f), a, n, def); if (!na) { - return failed(TYPE_ERROR_LIST, listl, a); + Yap_ThrowError__(file, function, lineno, err, listl, "no match"); } na->used = true; na->tvalue = ArgOfTerm(1, listl); - return a; } else { - return failed(TYPE_ERROR_LIST, listl, a); + Yap_ThrowError__(file, function, lineno, TYPE_ERROR_ATOM, listl, "not atom"); } listl = MkPairTerm(listl, TermNil); } while (IsPairTerm(listl)) { Term hd = HeadOfTerm(listl); listl = TailOfTerm(listl); - if (IsVarTerm(hd) || IsVarTerm(listl)) { - if (IsVarTerm(hd)) { - return failed(INSTANTIATION_ERROR, hd, a); - } else { - return failed(INSTANTIATION_ERROR, listl, a); - } + if (IsVarTerm(hd)) { + Yap_ThrowError__(file, function, lineno, INSTANTIATION_ERROR, hd, "sub-element"); + } + if (IsVarTerm(listl)) { + Yap_ThrowError__(file, function, lineno, INSTANTIATION_ERROR, listl, "sub-list"); } if (IsAtomTerm(hd)) { xarg *na = matchKey(AtomOfTerm(hd), a, n, def); if (!na) - return failed(DOMAIN_ERROR_GENERIC_ARGUMENT, hd, a); + Yap_ThrowError__(file, function, lineno, err, hd, "bad match in list"); na->used = true; na->tvalue = TermNil; continue; } else if (IsApplTerm(hd)) { Functor f = FunctorOfTerm(hd); if (IsExtensionFunctor(f)) { - return failed(TYPE_ERROR_PARAMETER, hd, a); + Yap_ThrowError__(file, function, lineno, err, hd, "bad compound"); } arity_t arity = ArityOfFunctor(f); if (arity != 1) { - return failed(DOMAIN_ERROR_OUT_OF_RANGE, hd, a); + Yap_ThrowError__(file, function, lineno, DOMAIN_ERROR_OUT_OF_RANGE, hd, + "high arity"); } xarg *na = matchKey(NameOfFunctor(f), a, n, def); if (!na) { - return failed(DOMAIN_ERROR_GENERIC_ARGUMENT, hd, a); + Yap_ThrowError__(file, function, lineno, err, hd, "no match"); } na->used = true; na->tvalue = ArgOfTerm(1, hd); } else { - return failed(TYPE_ERROR_PARAMETER, hd, a); + Yap_ThrowError__(file, function, lineno, err, hd, "bad type"); } } if (IsVarTerm(listl)) { - return failed(INSTANTIATION_ERROR, listl, a); + Yap_ThrowError__(file, function, lineno, INSTANTIATION_ERROR, listl, "unbound"); } else if (listl != TermNil) { - return failed(TYPE_ERROR_LIST, listl, a); + Yap_ThrowError__(file, function, lineno, TYPE_ERROR_LIST, listl, "bad list"); } return a; -} + } static xarg *matchKey2(Atom key, xarg *e0, int n, const param2_t *def) { int i; @@ -136,50 +134,53 @@ static xarg *matchKey2(Atom key, xarg *e0, int n, const param2_t *def) { } return NULL; } - /// Yap_ArgList2ToVector is much the same as before, /// but assumes parameters also have something called a /// scope -xarg *Yap_ArgList2ToVector(Term listl, const param2_t *def, int n) { +xarg *Yap_ArgList2ToVector__(const char *file, const char *function, int lineno,Term listl, const param2_t *def, int n, yap_error_number err) { CACHE_REGS xarg *a = calloc(n, sizeof(xarg)); if (!IsPairTerm(listl) && listl != TermNil) { if (IsVarTerm(listl)) { - return failed(INSTANTIATION_ERROR, listl, a); + Yap_ThrowError__(file, function, lineno, INSTANTIATION_ERROR, listl, "unbound"); } if (IsAtomTerm(listl)) { xarg *na = matchKey2(AtomOfTerm(listl), a, n, def); if (!na) { - return failed(DOMAIN_ERROR_GENERIC_ARGUMENT, listl, a); + Yap_ThrowError__(file, function, lineno, err, + listl, "bad match"); } } if (IsApplTerm(listl)) { Functor f = FunctorOfTerm(listl); if (IsExtensionFunctor(f)) { - return failed(TYPE_ERROR_PARAMETER, listl, a); + Yap_ThrowError__(file, function, lineno, TYPE_ERROR_PARAMETER, listl, + "bad compound"); } arity_t arity = ArityOfFunctor(f); if (arity != 1) { - return failed(TYPE_ERROR_LIST, listl, a); + Yap_ThrowError__(file, function, lineno, TYPE_ERROR_LIST, listl, "bad arity"); } xarg *na = matchKey2(NameOfFunctor(f), a, n, def); if (!na) { - return failed(DOMAIN_ERROR_GENERIC_ARGUMENT, listl, a); + Yap_ThrowError__(file, function, lineno, DOMAIN_ERROR_GENERIC_ARGUMENT, + listl, "bad match"); } } else { - return failed(TYPE_ERROR_LIST, listl, a); + Yap_ThrowError__(file, function, lineno, TYPE_ERROR_LIST, listl, ""); } listl = MkPairTerm(listl, TermNil); } while (IsPairTerm(listl)) { Term hd = HeadOfTerm(listl); if (IsVarTerm(hd)) { - return failed(INSTANTIATION_ERROR, hd, a); + Yap_ThrowError__(file, function, lineno, INSTANTIATION_ERROR, hd, ""); } if (IsAtomTerm(hd)) { xarg *na = matchKey2(AtomOfTerm(hd), a, n, def); if (!na) { - return failed(DOMAIN_ERROR_GENERIC_ARGUMENT, hd, a); + Yap_ThrowError__(file, function, lineno, DOMAIN_ERROR_GENERIC_ARGUMENT, + hd, "bad match"); } na->used = true; na->tvalue = TermNil; @@ -187,29 +188,32 @@ xarg *Yap_ArgList2ToVector(Term listl, const param2_t *def, int n) { } else if (IsApplTerm(hd)) { Functor f = FunctorOfTerm(hd); if (IsExtensionFunctor(f)) { - return failed(TYPE_ERROR_PARAMETER, hd, a); + Yap_ThrowError__(file, function, lineno, TYPE_ERROR_PARAMETER, hd, "bad compound"); } arity_t arity = ArityOfFunctor(f); if (arity != 1) { - return failed(DOMAIN_ERROR_GENERIC_ARGUMENT, hd, a); + Yap_ThrowError__(file, function, lineno, DOMAIN_ERROR_GENERIC_ARGUMENT, + hd, "bad arity"); } xarg *na = matchKey2(NameOfFunctor(f), a, n, def); if (na) { na->used = 1; na->tvalue = ArgOfTerm(1, hd); } else { - return failed(DOMAIN_ERROR_GENERIC_ARGUMENT, hd, a); + Yap_ThrowError__(file, function, lineno, err, + hd, "bad key"); } + return a; } else { - return failed(INSTANTIATION_ERROR, hd, a); + Yap_ThrowError__(file, function, lineno, INSTANTIATION_ERROR, hd, "unbound"); } listl = TailOfTerm(listl); } if (IsVarTerm(listl)) { - return failed(INSTANTIATION_ERROR, listl, a); + Yap_ThrowError__(file, function, lineno, INSTANTIATION_ERROR, listl, ""); } if (TermNil != listl) { - return failed(TYPE_ERROR_LIST, listl, a); + Yap_ThrowError__(file, function, lineno, TYPE_ERROR_LIST, listl, ""); } return a; } diff --git a/C/arith0.c b/C/arith0.c index 7d8a023aa..132b09d93 100644 --- a/C/arith0.c +++ b/C/arith0.c @@ -112,6 +112,7 @@ static char SccsId[] = "%W% %G%"; #include "Yatom.h" #include "YapHeap.h" #include "YapEval.h" +#include "alloc.h" @@ -172,9 +173,11 @@ eval0(Int fi) { } case op_heapused: /// - heapused - /// Heap (data-base) space used, in bytes. + /// Heap (data-base) space used, in bytes. In fact YAP either reports + /// the total memory malloced, or the amount of allocated space in + /// predicates. /// - RINT(HeapUsed); + RINT(Yap_HeapUsed()); case op_localsp: /// - local /// Local stack in use, in bytes @@ -191,7 +194,10 @@ eval0(Int fi) { #if YAPOR_SBA RINT((Int)B); #else + if (B) RINT(LCL0 - (CELL *)B); + else + RINT(0); #endif case op_env: /// - $env @@ -284,6 +290,7 @@ Yap_InitConstExps(void) } } + /* This routine is called from Restore to make sure we have the same arithmetic operators */ int Yap_ReInitConstExps(void) diff --git a/C/arith1.c b/C/arith1.c index abaab04cc..f40fc3b4b 100644 --- a/C/arith1.c +++ b/C/arith1.c @@ -8,14 +8,12 @@ * * ************************************************************************** * * - * File: arith1.c * - * Last rev: * - * mods: * - * comments: arithmetical expression evaluation * + * File: arith1.c * Last rev: + ** mods: * comments: arithmetical expression evaluation * * * *************************************************************************/ #ifdef SCCS -static char SccsId[] = "%W% %G%"; +static char SccsId[] = "%W% %G%"; #endif /** @@ -109,20 +107,24 @@ static char SccsId[] = "%W% %G%"; - integer( _X_)

@anchor integer_1_op - If _X_ evaluates to a float, the integer between the value of _X_ and 0 closest to the value of _X_, else if _X_ evaluates to an - integer, the value of _X_. + If _X_ evaluates to a float, the integer between the value of _X_ and 0 +closest to the value of _X_, else if _X_ evaluates to an integer, the value of +_X_. - float( _X_) [ISO]

@anchor float_1_op - If _X_ evaluates to an integer, the corresponding float, else the float itself. + If _X_ evaluates to an integer, the corresponding float, else the float +itself. - float_fractional_part( _X_) [ISO]

@anchor float_fractional_part_1 - The fractional part of the floating point number _X_, or `0.0` if _X_ is an integer. In the `iso` language mode, _X_ must be an integer. + The fractional part of the floating point number _X_, or `0.0` if _X_ is +an integer. In the `iso` language mode, _X_ must be an integer. - float_integer_part( _X_) [ISO]

@anchor float_integer_part_1 - The float giving the integer part of the floating point number _X_, or _X_ if _X_ is an integer. In the `iso` language mode, _X_ must be an integer. + The float giving the integer part of the floating point number _X_, or _X_ +if _X_ is an integer. In the `iso` language mode, _X_ must be an integer. - abs( _X_) [ISO]

@anchor abs_1 @@ -132,7 +134,8 @@ static char SccsId[] = "%W% %G%"; The integer that is the smallest integral value not smaller than _X_. - In `iso` language mode the argument must be a floating point-number and the result is an integer. + In `iso` language mode the argument must be a floating point-number and the +result is an integer. - floor( _X_) [ISO]

@anchor floor_1 @@ -143,14 +146,19 @@ static char SccsId[] = "%W% %G%"; - round( _X_) [ISO]

@anchor round_1 - The nearest integral value to _X_. If _X_ is equidistant to two integers, it will be rounded to the closest even integral value. + The nearest integral value to _X_. If _X_ is equidistant to two integers, +it will be rounded to the closest even integral value. - In `iso` language mode the argument must be a floating point-number, the result is an integer and it the float is equidistant it is rounded up, that is, to the least integer greater than _X_. + In `iso` language mode the argument must be a floating point-number, the +result is an integer and it the float is equidistant it is rounded up, that is, +to the least integer greater than _X_. - sign( _X_) [ISO]

@anchor sign_1 - Return 1 if the _X_ evaluates to a positive integer, 0 it if evaluates to 0, and -1 if it evaluates to a negative integer. If _X_ - evaluates to a floating-point number return 1.0 for a positive _X_, 0.0 for 0.0, and -1.0 otherwise. + Return 1 if the _X_ evaluates to a positive integer, 0 it if evaluates to +0, and -1 if it evaluates to a negative integer. If _X_ evaluates to a +floating-point number return 1.0 for a positive _X_, 0.0 for 0.0, and -1.0 +otherwise. - truncate( _X_) [ISO]

@anchor truncate_1 @@ -158,13 +166,13 @@ static char SccsId[] = "%W% %G%"; - rational( _X_)

@anchor rational_1_op - Convert the expression _X_ to a rational number or integer. The function returns the input on integers and rational numbers. For - floating point numbers, the returned rational number exactly represents - the float. As floats cannot exactly represent all decimal numbers the - results may be surprising. In the examples below, doubles can represent - `0.25` and the result is as expected, in contrast to the result of - `rational(0.1)`. The function `rationalize/1` gives a more - intuitive result. + Convert the expression _X_ to a rational number or integer. The function +returns the input on integers and rational numbers. For floating point numbers, +the returned rational number exactly represents the float. As floats cannot +exactly represent all decimal numbers the results may be surprising. In the +examples below, doubles can represent `0.25` and the result is as expected, in +contrast to the result of `rational(0.1)`. The function `rationalize/1` gives a +more intuitive result. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~prolog ?- A is rational(0.25). @@ -176,8 +184,8 @@ A = 3602879701896397 rdiv 36028797018963968 - rationalize( _X_)

@anchor rationalize_1 Convert the expression _X_ to a rational number or integer. The function is - similar to [rational/1](@ref rational_1), but the result is only accurate within the - rounding error of floating point numbers, generally producing a much + similar to [rational/1](@ref rational_1), but the result is only accurate +within the rounding error of floating point numbers, generally producing a much smaller denominator. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~prolog @@ -202,7 +210,8 @@ A = 1 rdiv 10 - popcount( _X_)

@anchor popcount_1 - The number of bits set to `1` in the binary representation of the non-negative integer _X_. + The number of bits set to `1` in the binary representation of the +non-negative integer _X_. - [ _X_]

@@ -226,17 +235,15 @@ X is Y*10+C-48. */ #include "Yap.h" -#include "Yatom.h" -#include "YapHeap.h" #include "YapEval.h" +#include "YapHeap.h" +#include "Yatom.h" -static Term -float_to_int(Float v USES_REGS) -{ -#if USE_GMP +static Term float_to_int(Float v USES_REGS) { +#if USE_GMP Int i = (Int)v; - if (i-v == 0.0) { + if (i - v == 0.0) { return MkIntegerTerm(i); } else { return Yap_gmp_float_to_big(v); @@ -246,11 +253,11 @@ float_to_int(Float v USES_REGS) #endif } -#define RBIG_FL(v) return(float_to_int(v PASS_REGS)) +#define RBIG_FL(v) return (float_to_int(v PASS_REGS)) typedef struct init_un_eval { - char *OpName; - arith1_op f; + char *OpName; + arith1_op f; } InitUnEntry; /* Some compilers just don't get it */ @@ -263,18 +270,16 @@ typedef struct init_un_eval { #endif #if !HAVE_ASINH -#define asinh(F) (log((F)+sqrt((F)*(F)+1))) +#define asinh(F) (log((F) + sqrt((F) * (F) + 1))) #endif #if !HAVE_ACOSH -#define acosh(F) (log((F)+sqrt((F)*(F)-1))) +#define acosh(F) (log((F) + sqrt((F) * (F)-1))) #endif #if !HAVE_ATANH -#define atanh(F) (log((1+(F))/(1-(F)))/2) +#define atanh(F) (log((1 + (F)) / (1 - (F))) / 2) #endif - -static inline Float -get_float(Term t) { +static inline Float get_float(Term t) { if (IsFloatTerm(t)) { return FloatOfTerm(t); } @@ -296,130 +301,156 @@ get_float(Term t) { #if HAVE_RINT #define my_rint(X) rint(X) #else -static -double my_rint(double x) -{ +static double my_rint(double x) { double y, z; Int n; if (x >= 0) { y = x + 0.5; z = floor(y); - n = (Int) z; + n = (Int)z; if (y == z && n % 2) - return(z-1); + return (z - 1); } else { y = x - 0.5; z = ceil(y); - n = (Int) z; + n = (Int)z; if (y == z && n % 2) - return(z+1); + return (z + 1); } - return(z); + return (z); } #endif static Int -msb(Int inp USES_REGS) /* calculate the most significant bit for an integer */ +msb(Int inp USES_REGS) /* calculate the most significant bit for an integer */ { /* the obvious solution: do it by using binary search */ Int out = 0; if (inp < 0) { Yap_ArithError(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, MkIntegerTerm(inp), - "msb/1 received %d", inp); + "msb/1 received %d", inp); } #if HAVE__BUILTIN_FFSLL - out = __builtin_ffsll(inp); + out = __builtin_ffsll(inp); #elif HAVE_FFSLL - out = ffsll(inp); + out = ffsll(inp); #else - if (inp==0) + if (inp == 0) return 0L; #if SIZEOF_INT_P == 8 - if (inp & ((CELL)0xffffffffLL << 32)) {inp >>= 32; out += 32;} + if (inp & ((CELL)0xffffffffLL << 32)) { + inp >>= 32; + out += 32; + } #endif - if (inp & ((CELL)0xffffL << 16)) {inp >>= 16; out += 16;} - if (inp & ((CELL)0xffL << 8)) {inp >>= 8; out += 8;} - if (inp & ((CELL)0xfL << 4)) {inp >>= 4; out += 4;} - if (inp & ((CELL)0x3L << 2)) {inp >>= 2; out += 2;} - if (inp & ((CELL)0x1 << 1)) out++; + if (inp & ((CELL)0xffffL << 16)) { + inp >>= 16; + out += 16; + } + if (inp & ((CELL)0xffL << 8)) { + inp >>= 8; + out += 8; + } + if (inp & ((CELL)0xfL << 4)) { + inp >>= 4; + out += 4; + } + if (inp & ((CELL)0x3L << 2)) { + inp >>= 2; + out += 2; + } + if (inp & ((CELL)0x1 << 1)) + out++; #endif return out; } -Int -Yap_msb(Int inp USES_REGS) /* calculate the most significant bit for an integer */ +Int Yap_msb( + Int inp USES_REGS) /* calculate the most significant bit for an integer */ { return msb(inp PASS_REGS); } - static Int -lsb(Int inp USES_REGS) /* calculate the least significant bit for an integer */ +lsb(Int inp USES_REGS) /* calculate the least significant bit for an integer */ { /* the obvious solution: do it by using binary search */ Int out = 0; if (inp < 0) { Yap_ArithError(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, MkIntegerTerm(inp), - "msb/1 received %d", inp); + "msb/1 received %d", inp); } - if (inp==0) + if (inp == 0) return 0L; #if SIZEOF_INT_P == 8 - if (!(inp & (CELL)0xffffffffLL)) {inp >>= 32; out += 32;} + if (!(inp & (CELL)0xffffffffLL)) { + inp >>= 32; + out += 32; + } #endif - if (!(inp & (CELL)0xffffL)) {inp >>= 16; out += 16;} - if (!(inp & (CELL)0xffL)) {inp >>= 8; out += 8;} - if (!(inp & (CELL)0xfL)) {inp >>= 4; out += 4;} - if (!(inp & (CELL)0x3L)) {inp >>= 2; out += 2;} - if (!(inp & ((CELL)0x1))) out++; + if (!(inp & (CELL)0xffffL)) { + inp >>= 16; + out += 16; + } + if (!(inp & (CELL)0xffL)) { + inp >>= 8; + out += 8; + } + if (!(inp & (CELL)0xfL)) { + inp >>= 4; + out += 4; + } + if (!(inp & (CELL)0x3L)) { + inp >>= 2; + out += 2; + } + if (!(inp & ((CELL)0x1))) + out++; return out; } -static Int -popcount(Int inp USES_REGS) /* calculate the least significant bit for an integer */ +static Int popcount( + Int inp USES_REGS) /* calculate the least significant bit for an integer */ { /* the obvious solution: do it by using binary search */ Int c = 0, j = 0, m = ((CELL)1); if (inp < 0) { - Yap_ArithError(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, MkIntegerTerm(inp), - "popcount/1 received %d", inp); + Yap_ArithError(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, MkIntegerTerm(inp), + "popcount/1 received %d", inp); } - if (inp==0) + if (inp == 0) return 0L; - for(j=0,c=0; j= 0) { - RFLOAT(log(dbl)); - } else { - Yap_ArithError(EVALUATION_ERROR_UNDEFINED, t, "log(%f)", dbl); - } + case op_log: { + Float dbl = get_float(t); + if (dbl >= 0) { + RFLOAT(log(dbl)); + } else { + Yap_ArithError(EVALUATION_ERROR_UNDEFINED, t, "log(%f)", dbl); } - case op_log10: - { - Float dbl = get_float(t); - if (dbl >= 0) { - RFLOAT(log10(dbl)); - } else { - Yap_ArithError(EVALUATION_ERROR_UNDEFINED, t, "log10(%f)", dbl); - } + } + case op_log10: { + Float dbl = get_float(t); + if (dbl >= 0) { + RFLOAT(log10(dbl)); + } else { + Yap_ArithError(EVALUATION_ERROR_UNDEFINED, t, "log10(%f)", dbl); } - case op_sqrt: - { - Float dbl = get_float(t), out; - out = sqrt(dbl); + } + case op_sqrt: { + Float dbl = get_float(t), out; + out = sqrt(dbl); #if HAVE_ISNAN - if (isnan(out)) { - Yap_ArithError(EVALUATION_ERROR_UNDEFINED, t, "sqrt(%f)", dbl); - } + if (isnan(out)) { + Yap_ArithError(EVALUATION_ERROR_UNDEFINED, t, "sqrt(%f)", dbl); + } #endif - RFLOAT(out); - } - case op_sin: - { - Float dbl = get_float(t), out; - out = sin(dbl); - RFLOAT(out); - } - case op_cos: - { - Float dbl = get_float(t), out; - out = cos(dbl); - RFLOAT(out); - } - case op_tan: - { - Float dbl = get_float(t), out; - out = tan(dbl); - RFLOAT(out); - } - case op_sinh: - { - Float dbl = get_float(t), out; - out = sinh(dbl); - RFLOAT(out); - } - case op_cosh: - { - Float dbl = get_float(t), out; - out = cosh(dbl); - RFLOAT(out); - } - case op_tanh: - { - Float dbl = get_float(t), out; - out = tanh(dbl); - RFLOAT(out); - } - case op_asin: - { - Float dbl, out; + RFLOAT(out); + } + case op_sin: { + Float dbl = get_float(t), out; + out = sin(dbl); + RFLOAT(out); + } + case op_cos: { + Float dbl = get_float(t), out; + out = cos(dbl); + RFLOAT(out); + } + case op_tan: { + Float dbl = get_float(t), out; + out = tan(dbl); + RFLOAT(out); + } + case op_sinh: { + Float dbl = get_float(t), out; + out = sinh(dbl); + RFLOAT(out); + } + case op_cosh: { + Float dbl = get_float(t), out; + out = cosh(dbl); + RFLOAT(out); + } + case op_tanh: { + Float dbl = get_float(t), out; + out = tanh(dbl); + RFLOAT(out); + } + case op_asin: { + Float dbl, out; - dbl = get_float(t); - out = asin(dbl); + dbl = get_float(t); + out = asin(dbl); #if HAVE_ISNAN - if (isnan(out)) { - Yap_ArithError(EVALUATION_ERROR_UNDEFINED, t, "asin(%f)", dbl); - } -#endif - RFLOAT(out); + if (isnan(out)) { + Yap_ArithError(EVALUATION_ERROR_UNDEFINED, t, "asin(%f)", dbl); } - case op_acos: - { - Float dbl, out; +#endif + RFLOAT(out); + } + case op_acos: { + Float dbl, out; - dbl = get_float(t); - out = acos(dbl); + dbl = get_float(t); + out = acos(dbl); #if HAVE_ISNAN - if (isnan(out)) { - Yap_ArithError(EVALUATION_ERROR_UNDEFINED, t, "acos(%f)", dbl); - } -#endif - RFLOAT(out); + if (isnan(out)) { + Yap_ArithError(EVALUATION_ERROR_UNDEFINED, t, "acos(%f)", dbl); } - case op_atan: - { - Float dbl, out; +#endif + RFLOAT(out); + } + case op_atan: { + Float dbl, out; - dbl = get_float(t); - out = atan(dbl); + dbl = get_float(t); + out = atan(dbl); #if HAVE_ISNAN - if (isnan(out)) { - Yap_ArithError(DOMAIN_ERROR_OUT_OF_RANGE, t, "atan(%f)", dbl); - } -#endif - RFLOAT(out); + if (isnan(out)) { + Yap_ArithError(DOMAIN_ERROR_OUT_OF_RANGE, t, "atan(%f)", dbl); } - case op_asinh: - { - Float dbl, out; +#endif + RFLOAT(out); + } + case op_asinh: { + Float dbl, out; - dbl = get_float(t); - out = asinh(dbl); + dbl = get_float(t); + out = asinh(dbl); #if HAVE_ISNAN - if (isnan(out)) { - Yap_ArithError(DOMAIN_ERROR_OUT_OF_RANGE, t, "asinh(%f)", dbl); - } -#endif - RFLOAT(out); + if (isnan(out)) { + Yap_ArithError(DOMAIN_ERROR_OUT_OF_RANGE, t, "asinh(%f)", dbl); } - case op_acosh: - { - Float dbl, out; +#endif + RFLOAT(out); + } + case op_acosh: { + Float dbl, out; - dbl = get_float(t); - out = acosh(dbl); + dbl = get_float(t); + out = acosh(dbl); #if HAVE_ISNAN - if (isnan(out)) { - Yap_ArithError(DOMAIN_ERROR_OUT_OF_RANGE, t, "acosh(%f)", dbl); - } -#endif - RFLOAT(out); + if (isnan(out)) { + Yap_ArithError(DOMAIN_ERROR_OUT_OF_RANGE, t, "acosh(%f)", dbl); } - case op_atanh: - { - Float dbl, out; +#endif + RFLOAT(out); + } + case op_atanh: { + Float dbl, out; - dbl = get_float(t); - out = atanh(dbl); + dbl = get_float(t); + out = atanh(dbl); #if HAVE_ISNAN - if (isnan(out)) { - Yap_ArithError(DOMAIN_ERROR_OUT_OF_RANGE, t, "atanh(%f)", dbl); - } -#endif - RFLOAT(out); + if (isnan(out)) { + Yap_ArithError(DOMAIN_ERROR_OUT_OF_RANGE, t, "atanh(%f)", dbl); } - case op_lgamma: - { +#endif + RFLOAT(out); + } + case op_lgamma: { #if HAVE_LGAMMA - Float dbl; + Float dbl; - dbl = get_float(t); - RFLOAT(lgamma(dbl)); + dbl = get_float(t); + RFLOAT(lgamma(dbl)); #else - RERROR(); + RERROR(); #endif - } - case op_erf: - { + } + case op_erf: { #if HAVE_ERF - Float dbl = get_float(t), out; - out = erf(dbl); - RFLOAT(out); + Float dbl = get_float(t), out; + out = erf(dbl); + RFLOAT(out); #else - RERROR(); + RERROR(); #endif - } - case op_erfc: - { + } + case op_erfc: { #if HAVE_ERF - Float dbl = get_float(t), out; - out = erfc(dbl); - RFLOAT(out); + Float dbl = get_float(t), out; + out = erfc(dbl); + RFLOAT(out); #else - RERROR(); + RERROR(); #endif - } + } /* floor(x) maximum integer greatest or equal to X @@ -626,127 +639,127 @@ eval1(Int fi, Term t USES_REGS) { ISO only converts from float -> int/big */ - case op_floor: - { - Float dbl; + case op_floor: { + Float dbl; - switch (ETypeOfTerm(t)) { - case long_int_e: - return t; - case double_e: - dbl = FloatOfTerm(t); - break; - case big_int_e: + switch (ETypeOfTerm(t)) { + case long_int_e: + return t; + case double_e: + dbl = FloatOfTerm(t); + break; + case big_int_e: #ifdef USE_GMP - return Yap_gmp_floor(t); + return Yap_gmp_floor(t); #endif - default: - RERROR(); - } + default: + RERROR(); + } #if HAVE_ISNAN - if (isnan(dbl)) { - Yap_ArithError(DOMAIN_ERROR_OUT_OF_RANGE, t, "integer(%f)", dbl); - } + if (isnan(dbl)) { + Yap_ArithError(DOMAIN_ERROR_OUT_OF_RANGE, t, "integer(%f)", dbl); + } #endif #if HAVE_ISINF - if (isinf(dbl)) { - Yap_ArithError(EVALUATION_ERROR_INT_OVERFLOW, MkFloatTerm(dbl), "integer\ -(%f)",dbl); - } -#endif - RBIG_FL(floor(dbl)); + if (isinf(dbl)) { + Yap_ArithError(EVALUATION_ERROR_INT_OVERFLOW, MkFloatTerm(dbl), "integer\ +(%f)", + dbl); } - case op_ceiling: - { - Float dbl; - switch (ETypeOfTerm(t)) { - case long_int_e: - return t; - case double_e: - dbl = FloatOfTerm(t); - break; - case big_int_e: -#ifdef USE_GMP - return Yap_gmp_ceiling(t); #endif - default: - RERROR(); - } + RBIG_FL(floor(dbl)); + } + case op_ceiling: { + Float dbl; + switch (ETypeOfTerm(t)) { + case long_int_e: + return t; + case double_e: + dbl = FloatOfTerm(t); + break; + case big_int_e: +#ifdef USE_GMP + return Yap_gmp_ceiling(t); +#endif + default: + RERROR(); + } #if HAVE_ISNAN - if (isnan(dbl)) { - Yap_ArithError(DOMAIN_ERROR_OUT_OF_RANGE, t, "integer(%f)", dbl); - } + if (isnan(dbl)) { + Yap_ArithError(DOMAIN_ERROR_OUT_OF_RANGE, t, "integer(%f)", dbl); + } #endif #if HAVE_ISINF - if (isinf(dbl)) { - Yap_ArithError(EVALUATION_ERROR_INT_OVERFLOW, MkFloatTerm(dbl), "integer\ -(%f)",dbl); - } -#endif - RBIG_FL(ceil(dbl)); + if (isinf(dbl)) { + Yap_ArithError(EVALUATION_ERROR_INT_OVERFLOW, MkFloatTerm(dbl), "integer\ +(%f)", + dbl); } - case op_round: - { - Float dbl; +#endif + RBIG_FL(ceil(dbl)); + } + case op_round: { + Float dbl; - switch (ETypeOfTerm(t)) { - case long_int_e: - return t; - case double_e: - dbl = FloatOfTerm(t); - break; - case big_int_e: + switch (ETypeOfTerm(t)) { + case long_int_e: + return t; + case double_e: + dbl = FloatOfTerm(t); + break; + case big_int_e: #ifdef USE_GMP - return Yap_gmp_round(t); + return Yap_gmp_round(t); #endif - default: - RERROR(); - } + default: + RERROR(); + } #if HAVE_ISNAN - if (isnan(dbl)) { - Yap_ArithError(DOMAIN_ERROR_OUT_OF_RANGE, t, "integer(%f)", dbl); - } + if (isnan(dbl)) { + Yap_ArithError(DOMAIN_ERROR_OUT_OF_RANGE, t, "integer(%f)", dbl); + } #endif #if HAVE_ISINF - if (isinf(dbl)) { - Yap_ArithError(EVALUATION_ERROR_INT_OVERFLOW, MkFloatTerm(dbl), "integer\ -(%f)",dbl); - } -#endif - RBIG_FL(my_rint(dbl)); + if (isinf(dbl)) { + Yap_ArithError(EVALUATION_ERROR_INT_OVERFLOW, MkFloatTerm(dbl), "integer\ +(%f)", + dbl); } +#endif + RBIG_FL(my_rint(dbl)); + } case op_truncate: - case op_integer: - { - Float dbl; - switch (ETypeOfTerm(t)) { - case long_int_e: - return t; - case double_e: - dbl = FloatOfTerm(t); - break; - case big_int_e: + case op_integer: { + Float dbl; + switch (ETypeOfTerm(t)) { + case long_int_e: + return t; + case double_e: + dbl = FloatOfTerm(t); + break; + case big_int_e: #ifdef USE_GMP - return Yap_gmp_trunc(t); + return Yap_gmp_trunc(t); #endif - default: - RERROR(); - } + default: + RERROR(); + } #if HAVE_ISNAN - if (isnan(dbl)) { - Yap_ArithError(DOMAIN_ERROR_OUT_OF_RANGE, t, "integer(%f)", dbl); - } + if (isnan(dbl)) { + Yap_ArithError(DOMAIN_ERROR_OUT_OF_RANGE, t, "integer(%f)", dbl); + } #endif #if HAVE_ISINF - if (isinf(dbl)) { - Yap_ArithError(EVALUATION_ERROR_INT_OVERFLOW, MkFloatTerm(dbl), "integer (%f)",dbl); - } -#endif - if (dbl < 0.0) - RBIG_FL(ceil(dbl)); - else - RBIG_FL(floor(dbl)); + if (isinf(dbl)) { + Yap_ArithError(EVALUATION_ERROR_INT_OVERFLOW, MkFloatTerm(dbl), + "integer (%f)", dbl); } +#endif + if (dbl < 0.0) + RBIG_FL(ceil(dbl)); + else + RBIG_FL(floor(dbl)); + } case op_float: switch (ETypeOfTerm(t)) { case long_int_e: @@ -842,17 +855,16 @@ eval1(Int fi, Term t USES_REGS) { switch (ETypeOfTerm(t)) { case long_int_e: if (isoLanguageFlag()) { /* iso */ - Yap_ArithError(TYPE_ERROR_FLOAT, t, "X is float_fractional_part(%f)", IntegerOfTerm(t)); + Yap_ArithError(TYPE_ERROR_FLOAT, t, "X is float_fractional_part(%f)", + IntegerOfTerm(t)); } else { - RFLOAT(0.0); + RFLOAT(0.0); } - case double_e: - { - Float dbl; - dbl = FloatOfTerm(t); - RFLOAT(dbl-ceil(dbl)); - } - break; + case double_e: { + Float dbl; + dbl = FloatOfTerm(t); + RFLOAT(dbl - ceil(dbl)); + } break; case big_int_e: #ifdef USE_GMP return Yap_gmp_float_fractional_part(t); @@ -863,7 +875,8 @@ eval1(Int fi, Term t USES_REGS) { case op_fintp: switch (ETypeOfTerm(t)) { case long_int_e: - Yap_ArithError(TYPE_ERROR_FLOAT, t, "X is float_integer_part(%f)", IntegerOfTerm(t)); + Yap_ArithError(TYPE_ERROR_FLOAT, t, "X is float_integer_part(%f)", + IntegerOfTerm(t)); case double_e: RFLOAT(rint(FloatOfTerm(t))); break; @@ -876,19 +889,17 @@ eval1(Int fi, Term t USES_REGS) { } case op_sign: switch (ETypeOfTerm(t)) { - case long_int_e: - { - Int x = IntegerOfTerm(t); + case long_int_e: { + Int x = IntegerOfTerm(t); - RINT((x > 0 ? 1 : (x < 0 ? -1 : 0))); - } - case double_e: - { + RINT((x > 0 ? 1 : (x < 0 ? -1 : 0))); + } + case double_e: { - Float dbl = FloatOfTerm(t); + Float dbl = FloatOfTerm(t); - RINT((dbl > 0.0 ? 1 : (dbl < 0.0 ? -1 : 0))); - } + RINT((dbl > 0.0 ? 1 : (dbl < 0.0 ? -1 : 0))); + } case big_int_e: #ifdef USE_GMP return Yap_gmp_sign(t); @@ -899,7 +910,7 @@ eval1(Int fi, Term t USES_REGS) { case op_random1: switch (ETypeOfTerm(t)) { case long_int_e: - RINT(Yap_random()*IntegerOfTerm(t)); + RINT(Yap_random() * IntegerOfTerm(t)); case double_e: Yap_ArithError(TYPE_ERROR_INTEGER, t, "random(%f)", FloatOfTerm(t)); case big_int_e: @@ -914,65 +925,56 @@ eval1(Int fi, Term t USES_REGS) { RERROR(); } -Term Yap_eval_unary(Int f, Term t) -{ +Term Yap_eval_unary(Int f, Term t) { CACHE_REGS - return eval1(f,t PASS_REGS); + return eval1(f, t PASS_REGS); } -static InitUnEntry InitUnTab[] = { - {"+", op_uplus}, - {"-", op_uminus}, - {"\\", op_unot}, - {"exp", op_exp}, - {"log", op_log}, - {"log10", op_log10}, - {"sqrt", op_sqrt}, - {"sin", op_sin}, - {"cos", op_cos}, - {"tan", op_tan}, - {"sinh", op_sinh}, - {"cosh", op_cosh}, - {"tanh", op_tanh}, - {"asin", op_asin}, - {"acos", op_acos}, - {"atan", op_atan}, - {"asinh", op_asinh}, - {"acosh", op_acosh}, - {"atanh", op_atanh}, - {"floor", op_floor}, - {"ceiling", op_ceiling}, - {"round", op_round}, - {"truncate", op_truncate}, - {"integer", op_integer}, - {"float", op_float}, - {"abs", op_abs}, - {"msb", op_msb}, - {"lsb", op_lsb}, - {"popcount", op_popcount}, - {"float_fractional_part", op_ffracp}, - {"float_integer_part", op_fintp}, - {"sign", op_sign}, - {"lgamma", op_lgamma}, - {"erf",op_erf}, - {"erfc",op_erfc}, - {"rational",op_rational}, - {"rationalize",op_rationalize}, - {"random", op_random1} -}; +static InitUnEntry InitUnTab[] = {{"+", op_uplus}, + {"-", op_uminus}, + {"\\", op_unot}, + {"exp", op_exp}, + {"log", op_log}, + {"log10", op_log10}, + {"sqrt", op_sqrt}, + {"sin", op_sin}, + {"cos", op_cos}, + {"tan", op_tan}, + {"sinh", op_sinh}, + {"cosh", op_cosh}, + {"tanh", op_tanh}, + {"asin", op_asin}, + {"acos", op_acos}, + {"atan", op_atan}, + {"asinh", op_asinh}, + {"acosh", op_acosh}, + {"atanh", op_atanh}, + {"floor", op_floor}, + {"ceiling", op_ceiling}, + {"round", op_round}, + {"truncate", op_truncate}, + {"integer", op_integer}, + {"float", op_float}, + {"abs", op_abs}, + {"msb", op_msb}, + {"lsb", op_lsb}, + {"popcount", op_popcount}, + {"float_fractional_part", op_ffracp}, + {"float_integer_part", op_fintp}, + {"sign", op_sign}, + {"lgamma", op_lgamma}, + {"erf", op_erf}, + {"erfc", op_erfc}, + {"rational", op_rational}, + {"rationalize", op_rationalize}, + {"random", op_random1}}; -Atom -Yap_NameOfUnaryOp(int i) -{ - return Yap_LookupAtom(InitUnTab[i].OpName); -} +Atom Yap_NameOfUnaryOp(int i) { return Yap_LookupAtom(InitUnTab[i].OpName); } -static Int -p_unary_is( USES_REGS1 ) -{ /* X is Y */ +static Int p_unary_is(USES_REGS1) { /* X is Y */ Term t = Deref(ARG2); Term top; - yap_error_number err; + bool go; if (IsVarTerm(t)) { Yap_EvalError(INSTANTIATION_ERROR, t, "unbound unary operator"); @@ -980,23 +982,13 @@ p_unary_is( USES_REGS1 ) } Yap_ClearExs(); top = Yap_Eval(Deref(ARG3)); - if ((err=Yap_FoundArithError())) { - Yap_EvalError(err,ARG3,"X is op(Y): error in Y "); - return FALSE; - } if (IsIntTerm(t)) { Term tout; Int i; i = IntegerOfTerm(t); tout = eval1(i, top PASS_REGS); - if ((err=Yap_FoundArithError())) { - Functor f = Yap_MkFunctor( Yap_NameOfUnaryOp(i), 1 ); - Term t = Yap_MkApplTerm( f, 1, &top ); - Yap_EvalError(err, t ,"error in %s/1 ", RepAtom(NameOfFunctor(f))->StrOfAE); - return FALSE; - } - return Yap_unify_constant(ARG1,tout); + return Yap_unify_constant(ARG1, tout); } else if (IsAtomTerm(t)) { Atom name = AtomOfTerm(t); ExpEntry *p; @@ -1004,53 +996,49 @@ p_unary_is( USES_REGS1 ) if (EndOfPAEntr(p = RepExpProp(Yap_GetExpProp(name, 1)))) { Yap_EvalError(TYPE_ERROR_EVALUABLE, takeIndicator(t), - "functor %s/1 for arithmetic expression", - RepAtom(name)->StrOfAE); + "functor %s/1 for arithmetic expression", + RepAtom(name)->StrOfAE); return FALSE; } - out= eval1(p->FOfEE, top PASS_REGS); - if ((err=Yap_FoundArithError())) { - return FALSE; - } - return Yap_unify_constant(ARG1,out); + do { + out = eval1(p->FOfEE, top PASS_REGS); + go = Yap_CheckArithError(); + } while (go); + return Yap_unify_constant(ARG1, out); } - return(FALSE); + return false; } -static Int -p_unary_op_as_integer( USES_REGS1 ) -{ /* X is Y */ +static Int p_unary_op_as_integer(USES_REGS1) { /* X is Y */ Term t = Deref(ARG1); if (IsVarTerm(t)) { - Yap_EvalError(INSTANTIATION_ERROR,t, "X is _Y"); - return(FALSE); + Yap_EvalError(INSTANTIATION_ERROR, t, "X is _Y"); + return (FALSE); } if (IsIntTerm(t)) { - return Yap_unify_constant(ARG2,t); + return Yap_unify_constant(ARG2, t); } if (IsAtomTerm(t)) { Atom name = AtomOfTerm(t); ExpEntry *p; if (EndOfPAEntr(p = RepExpProp(Yap_GetExpProp(name, 1)))) { - return Yap_unify(ARG1,ARG2); + return Yap_unify(ARG1, ARG2); } - return Yap_unify_constant(ARG2,MkIntTerm(p->FOfEE)); + return Yap_unify_constant(ARG2, MkIntTerm(p->FOfEE)); } - return(FALSE); + return (FALSE); } -void -Yap_InitUnaryExps(void) -{ - unsigned int i; - ExpEntry *p; +void Yap_InitUnaryExps(void) { + unsigned int i; + ExpEntry *p; - for (i = 0; i < sizeof(InitUnTab)/sizeof(InitUnEntry); ++i) { + for (i = 0; i < sizeof(InitUnTab) / sizeof(InitUnEntry); ++i) { AtomEntry *ae = RepAtom(Yap_LookupAtom(InitUnTab[i].OpName)); if (ae == NULL) { - Yap_EvalError(RESOURCE_ERROR_HEAP,TermNil,"at InitUnaryExps"); + Yap_EvalError(RESOURCE_ERROR_HEAP, TermNil, "at InitUnaryExps"); return; } WRITE_LOCK(ae->ARWLock); @@ -1058,7 +1046,7 @@ Yap_InitUnaryExps(void) WRITE_UNLOCK(ae->ARWLock); break; } - p = (ExpEntry *) Yap_AllocAtomSpace(sizeof(ExpEntry)); + p = (ExpEntry *)Yap_AllocAtomSpace(sizeof(ExpEntry)); p->KindOfPE = ExpProperty; p->ArityOfEE = 1; p->ENoOfEE = 1; @@ -1067,11 +1055,10 @@ Yap_InitUnaryExps(void) WRITE_UNLOCK(ae->ARWLock); } Yap_InitCPred("is", 3, p_unary_is, TestPredFlag | SafePredFlag); - Yap_InitCPred("$unary_op_as_integer", 2, p_unary_op_as_integer, TestPredFlag|SafePredFlag);} - -/* This routine is called from Restore to make sure we have the same arithmetic operators */ -int -Yap_ReInitUnaryExps(void) -{ - return TRUE; + Yap_InitCPred("$unary_op_as_integer", 2, p_unary_op_as_integer, + TestPredFlag | SafePredFlag); } + +/* This routine is called from Restore to make sure we have the same arithmetic + * operators */ +int Yap_ReInitUnaryExps(void) { return TRUE; } diff --git a/C/arith2.c b/C/arith2.c index 5a26fced4..00ff629c9 100644 --- a/C/arith2.c +++ b/C/arith2.c @@ -213,7 +213,7 @@ p_div2(Term t1, Term t2 USES_REGS) { Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is " Int_FORMAT " div 0", i1); if (i1 == Int_MIN && i2 == -1) { #ifdef USE_GMP - return Yap_gmp_add_ints(Int_MAX, 1); + return Yap_gmp_add_ints(Int_MAX, 1); #else Yap_ArithError(EVALUATION_ERROR_INT_OVERFLOW, t1, "// /2 with %d and %d", i1, i2); @@ -443,7 +443,7 @@ p_xor(Term t1, Term t2 USES_REGS) { switch (ETypeOfTerm(t1)) { case long_int_e: - + switch (ETypeOfTerm(t2)) { case long_int_e: /* two integers */ @@ -643,7 +643,7 @@ p_power(Term t1, Term t2 USES_REGS) } /* next function is adapted from: - Inline C++ integer exponentiation routines + Inline C++ integer exponentiation routines Version 1.01 Copyright (C) 1999-2004 John C. Bowman */ @@ -654,9 +654,9 @@ ipow(Int x, Int p) if (p == 0) return ((CELL)1); if (x == 0 && p > 0) return 0L; - if(p < 0) + if(p < 0) return (-p % 2) ? x : ((CELL)1); - + r = ((CELL)1); for(;;) { if(p & 1) { @@ -1142,167 +1142,125 @@ static InitBinEntry InitBinTab[] = { {"rdiv", op_rdiv} }; -static Int +static Int p_binary_is( USES_REGS1 ) { /* X is Y */ Term t = Deref(ARG2); - Term t1, t2; - yap_error_number err; + Term t1, t2, tout; if (IsVarTerm(t)) { Yap_ArithError(INSTANTIATION_ERROR,t, "VAR(X , Y)"); return(FALSE); } - Yap_ClearExs(); - t1 = Yap_Eval(Deref(ARG3)); - if ((err = Yap_FoundArithError())) { - Atom name; - if (IsIntTerm(t)) { - Int i = IntOfTerm(t); - name = Yap_NameOfBinaryOp(i); - } else { - name = AtomOfTerm(Deref(ARG2)); - } - Yap_EvalError(err,ARG3,"X is ~s/2: error in first argument ", RepAtom(name)->StrOfAE); - return FALSE; - } + Yap_ClearExs(); + t1 = Yap_Eval(Deref(ARG3)); t2 = Yap_Eval(Deref(ARG4)); - if ((err=Yap_FoundArithError())) { - Atom name; - if (IsIntTerm(t)) { - Int i = IntOfTerm(t); - name = Yap_NameOfBinaryOp(i); - } else { - name = AtomOfTerm(Deref(ARG2)); - } - Yap_EvalError(err,ARG3,"X is ~s/2: error in first argument ", RepAtom(name)->StrOfAE); - return FALSE; - } if (IsIntTerm(t)) { Int i = IntOfTerm(t); - Term tout = eval2(i, t1, t2 PASS_REGS); - if ((err = Yap_FoundArithError()) != YAP_NO_ERROR) { - Term ts[2], terr; - Atom name = Yap_NameOfBinaryOp( i ); - Functor f = Yap_MkFunctor( name, 2 ); - ts[0] = t1; - ts[1] = t2; - terr = Yap_MkApplTerm( f, 2, ts ); - Yap_EvalError(err, terr ,"error in %s/2 ", RepAtom(name)->StrOfAE); - return FALSE; - } + bool go; + do { + go = false; + tout = eval2(i, t1, t2 PASS_REGS); + go = Yap_CheckArithError(); + } while (go); return Yap_unify_constant(ARG1,tout); } if (IsAtomTerm(t)) { Atom name = AtomOfTerm(t); ExpEntry *p; - Term out; - + bool go; + int j; if (EndOfPAEntr(p = RepExpProp(Yap_GetExpProp(name, 2)))) { - Yap_EvalError(TYPE_ERROR_EVALUABLE, takeIndicator(t), - "functor %s/2 for arithmetic expression", - RepAtom(name)->StrOfAE); - P = FAILCODE; - return(FALSE); + Yap_EvalError(TYPE_ERROR_EVALUABLE, t, "`%s ", name->StrOfAE + ); } - out= eval2(p->FOfEE, t1, t2 PASS_REGS); - if ((err = Yap_FoundArithError()) != YAP_NO_ERROR) { - Term ts[2], terr; - Functor f = Yap_MkFunctor( name, 2 ); - ts[0] = t1; - ts[1] = t2; - terr = Yap_MkApplTerm( f, 2, ts ); - Yap_EvalError(err, terr ,"error in ~s/2 ", RepAtom(name)->StrOfAE); - return FALSE; - } - return Yap_unify_constant(ARG1,out); + j = p->FOfEE; + + do { + go = false; + Yap_ClearExs(); + tout = eval2(j, t1, t2 PASS_REGS); + go = Yap_CheckArithError(); + } while (go); + return Yap_unify_constant(ARG1,tout); } return FALSE; } -static Int +static Int do_arith23(arith2_op op USES_REGS) { /* X is Y */ Term t = Deref(ARG1); - Int out; - Term t1, t2; - yap_error_number err; + bool go; + Term t1, t2, out; - Yap_ClearExs(); if (IsVarTerm(t)) { Yap_EvalError(INSTANTIATION_ERROR,t, "X is Y"); return(FALSE); } - t1 = Yap_Eval(t); - if (t1 == 0L) - return FALSE; + do { + go = false; + Yap_ClearExs(); + t1 = Yap_Eval(t); t2 = Yap_Eval(Deref(ARG2)); - if (t2 == 0L) - return FALSE; out= eval2(op, t1, t2 PASS_REGS); - if ((err=Yap_FoundArithError())) { - Term ts[2], t; - Functor f = Yap_MkFunctor( Yap_NameOfBinaryOp(op), 2 ); - ts[0] = t1; - ts[1] = t2; - t = Yap_MkApplTerm( f, 2, ts ); - Yap_EvalError(err, t ,"error in ~s(Y,Z) ",Yap_NameOfBinaryOp(op)); - return FALSE; - } + + go = Yap_CheckArithError(); + } while (go); return Yap_unify_constant(ARG3,out); } -static Int +static Int export_p_plus( USES_REGS1 ) { /* X is Y */ return do_arith23(op_plus PASS_REGS); } -static Int +static Int export_p_minus( USES_REGS1 ) { /* X is Y */ return do_arith23(op_minus PASS_REGS); } -static Int +static Int export_p_times( USES_REGS1 ) { /* X is Y */ return do_arith23(op_times PASS_REGS); } -static Int +static Int export_p_div( USES_REGS1 ) { /* X is Y */ return do_arith23(op_div PASS_REGS); } -static Int +static Int export_p_and( USES_REGS1 ) { /* X is Y */ return do_arith23(op_and PASS_REGS); } -static Int +static Int export_p_or( USES_REGS1 ) { /* X is Y */ return do_arith23(op_or PASS_REGS); } -static Int +static Int export_p_slr( USES_REGS1 ) { /* X is Y */ return do_arith23(op_slr PASS_REGS); } -static Int +static Int export_p_sll( USES_REGS1 ) { /* X is Y */ return do_arith23(op_sll PASS_REGS); } -static Int +static Int p_binary_op_as_integer( USES_REGS1 ) { /* X is Y */ Term t = Deref(ARG1); @@ -1317,7 +1275,6 @@ p_binary_op_as_integer( USES_REGS1 ) if (IsAtomTerm(t)) { Atom name = AtomOfTerm(t); ExpEntry *p; - if (EndOfPAEntr(p = RepExpProp(Yap_GetExpProp(name, 2)))) { return Yap_unify(ARG1,ARG2); } @@ -1376,4 +1333,3 @@ Yap_ReInitBinaryExps(void) { return(TRUE); } - diff --git a/C/arrays.c b/C/arrays.c index eb219ad3c..f0fa0fb11 100644 --- a/C/arrays.c +++ b/C/arrays.c @@ -1,21 +1,25 @@ /******************************************************************""******* -* * -* YAP Prolog * -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * -* * -************************************************************************** -* * -* File: arrays.c * -* Last rev: * -* mods: * -* comments: Array Manipulation Routines * -* * -*************************************************************************/ + * * + * YAP Prolog * + * * + * Yap Prolog was developed at NCCUP - Universidade do Porto * + * * + * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * + * * + ************************************************************************** + * * + * File: arrays.c * Last rev: + ** mods: * comments: Array Manipulation Routines * + * * + *************************************************************************/ -/** @defgroup YAPArrays Named Arrays +/** + +@file arrays.c + +@namespace prolog + +@addtogroup YAPArrays Named Arrays @ingroup extensions @{ @@ -100,9 +104,9 @@ The following predicates manipulate arrays: */ #include "Yap.h" +#include "YapEval.h" #include "Yatom.h" #include "clause.h" -#include "YapEval.h" #include "heapgc.h" #if HAVE_ERRNO_H #include @@ -367,7 +371,7 @@ static ArrayEntry *GetArrayEntry(Atom at, int owner) { #if THREADS && pp->owner_id != worker_id #endif - ) + ) pp = RepArrayProp(pp->NextOfPE); READ_UNLOCK(ae->ARWLock); return pp; @@ -693,6 +697,7 @@ static StaticArrayEntry *CreateStaticArray(AtomEntry *ae, size_t dim, } } p->KindOfPE = ArrayProperty; + p->ValueOfVE.ints = NULL; INIT_RWLOCK(p->ArRWLock); AddPropToAtom(ae, (PropEntry *)p); p->NextAE = LOCAL_StaticArrays; @@ -979,7 +984,7 @@ restart: #if THREADS && ((ArrayEntry *)pp)->owner_id != worker_id #endif - ) + ) pp = RepProp(pp->NextOfPE); if (EndOfPAEntr(pp)) { if (HR + 1 + size > ASP - 1024) { @@ -1018,22 +1023,49 @@ restart: return (FALSE); } +#define CREATE_ARRAY_DEFS() \ + PAR("type", isatom, CREATE_ARRAY_TYPE), \ + PAR("address", filler, CREATE_ARRAY_ADDRESS), \ + PAR("int", filler, CREATE_ARRAY_INT), \ + PAR("dbref", filler, CREATE_ARRAY_DBREF), \ + PAR("float", filler, CREATE_ARRAY_FLOAT), \ + PAR("ptr", filler, CREATE_ARRAY_PTR), \ + PAR("atom", filler, CREATE_ARRAY_ATOM), \ + PAR("char", filler, CREATE_ARRAY_CHAR), \ + PAR("unsigned_char", filler, CREATE_ARRAY_UNSIGNED_CHAR), \ + PAR("term", filler, CREATE_ARRAY_TERM), \ + PAR("nb_term", filler, CREATE_ARRAY_NB_TERM) + +#define PAR(x, y, z) z + +typedef enum create_array_enum_choices { + CREATE_ARRAY_DEFS() +} create_array_choices_t; + +#undef PAR + +#define PAR(x, y, z) \ + { x, y, z } + +static const param_t create_array_defs[] = {CREATE_ARRAY_DEFS()}; +#undef PAR + /* create an array (+Name, + Size, +Props) */ -static Int - /** @pred static_array(+ _Name_, + _Size_, + _Type_) +/** @pred static_array(+ _Name_, + _Size_, + _Type_) - Create a new static array with name _Name_. Note that the _Name_ - must be an atom (named array). The _Size_ must evaluate to an - integer. The _Type_ must be bound to one of types mentioned - previously. - */ - create_static_array(USES_REGS1) { +Create a new static array with name _Name_. Note that the _Name_ +must be an atom (named array). The _Size_ must evaluate to an +integer. The _Type_ must be bound to one of types mentioned +previously. +*/ +static Int create_static_array(USES_REGS1) { Term ti = Deref(ARG2); Term t = Deref(ARG1); Term tprops = Deref(ARG3); Int size; static_array_types props; + void *address = NULL; if (IsVarTerm(ti)) { Yap_Error(INSTANTIATION_ERROR, ti, "create static array"); @@ -1048,46 +1080,68 @@ static Int return (FALSE); } } - - if (IsVarTerm(tprops)) { - Yap_Error(INSTANTIATION_ERROR, tprops, "create static array"); - return (FALSE); - } else if (IsAtomTerm(tprops)) { - char *atname = (char *)RepAtom(AtomOfTerm(tprops))->StrOfAE; - if (!strcmp(atname, "int")) - props = array_of_ints; - else if (!strcmp(atname, "dbref")) - props = array_of_dbrefs; - else if (!strcmp(atname, "float")) - props = array_of_doubles; - else if (!strcmp(atname, "ptr")) - props = array_of_ptrs; - else if (!strcmp(atname, "atom")) - props = array_of_atoms; - else if (!strcmp(atname, "char")) - props = array_of_chars; - else if (!strcmp(atname, "unsigned_char")) - props = array_of_uchars; - else if (!strcmp(atname, "term")) - props = array_of_terms; - else if (!strcmp(atname, "nb_term")) - props = array_of_nb_terms; - else { - Yap_Error(DOMAIN_ERROR_ARRAY_TYPE, tprops, "create static array"); - return (FALSE); + xarg *args = + Yap_ArgListToVector(tprops, create_array_defs, CREATE_ARRAY_NB_TERM, + DOMAIN_ERROR_CREATE_ARRAY_OPTION); + if (args == NULL) { + if (LOCAL_Error_TYPE != YAP_NO_ERROR) { + Yap_Error(LOCAL_Error_TYPE, tprops, NULL); } - } else { - Yap_Error(TYPE_ERROR_ATOM, tprops, "create static array"); - return (FALSE); + return false; } + if (args[CREATE_ARRAY_TYPE].used) { + tprops = args[CREATE_ARRAY_TYPE].tvalue; + { + char *atname = (char *)RepAtom(AtomOfTerm(tprops))->StrOfAE; + if (!strcmp(atname, "int")) + props = array_of_ints; + else if (!strcmp(atname, "dbref")) + props = array_of_dbrefs; + else if (!strcmp(atname, "float")) + props = array_of_doubles; + else if (!strcmp(atname, "ptr")) + props = array_of_ptrs; + else if (!strcmp(atname, "atom")) + props = array_of_atoms; + else if (!strcmp(atname, "char")) + props = array_of_chars; + else if (!strcmp(atname, "unsigned_char")) + props = array_of_uchars; + else if (!strcmp(atname, "term")) + props = array_of_terms; + else if (!strcmp(atname, "nb_term")) + props = array_of_nb_terms; + } + } + if (args[CREATE_ARRAY_ADDRESS].used) { + address = AddressOfTerm(args[CREATE_ARRAY_ADDRESS].tvalue); + } + if (args[CREATE_ARRAY_INT].used) + props = array_of_ints; + if (args[CREATE_ARRAY_DBREF].used) + props = array_of_dbrefs; + if (args[CREATE_ARRAY_FLOAT].used) + props = array_of_doubles; + if (args[CREATE_ARRAY_PTR].used) + props = array_of_ptrs; + if (args[CREATE_ARRAY_ATOM].used) + props = array_of_atoms; + if (args[CREATE_ARRAY_CHAR].used) + props = array_of_chars; + if (args[CREATE_ARRAY_UNSIGNED_CHAR].used) + props = array_of_uchars; + if (args[CREATE_ARRAY_TERM].used) + props = array_of_terms; + if (args[CREATE_ARRAY_NB_TERM].used) + props = array_of_nb_terms; + StaticArrayEntry *pp; if (IsVarTerm(t)) { Yap_Error(INSTANTIATION_ERROR, t, "create static array"); return (FALSE); } else if (IsAtomTerm(t)) { /* Create a named array */ AtomEntry *ae = RepAtom(AtomOfTerm(t)); - StaticArrayEntry *pp; ArrayEntry *app; WRITE_LOCK(ae->ARWLock); @@ -1097,42 +1151,36 @@ static Int app = (ArrayEntry *)pp; if (EndOfPAEntr(pp) || pp->ValueOfVE.ints == NULL) { - pp = CreateStaticArray(ae, size, props, NULL, pp PASS_REGS); + pp = CreateStaticArray(ae, size, props, address, pp PASS_REGS); if (pp == NULL || pp->ValueOfVE.ints == NULL) { - WRITE_UNLOCK(ae->ARWLock); - return FALSE; + return TRUE; } - WRITE_UNLOCK(ae->ARWLock); - return TRUE; } else if (ArrayIsDynamic(app)) { if (IsVarTerm(app->ValueOfVE) && IsUnboundVar(&app->ValueOfVE)) { pp = CreateStaticArray(ae, size, props, NULL, pp PASS_REGS); - WRITE_UNLOCK(ae->ARWLock); - if (pp == NULL) { - return false; - } - return true; } else { - WRITE_UNLOCK(ae->ARWLock); Yap_Error(PERMISSION_ERROR_CREATE_ARRAY, t, "cannot create static array over dynamic array"); - return false; } } else { - if (pp->ArrayEArity == size && pp->ArrayType == props) { - WRITE_UNLOCK(ae->ARWLock); - return true; + if (pp->ArrayType != props) { + Yap_Error(TYPE_ERROR_ATOM, t, "create static array %d/%d %d/%d", + pp->ArrayEArity, size, pp->ArrayType, props); + pp = NULL; + } else { + AllocateStaticArraySpace(pp, props, pp->ValueOfVE.ints, size PASS_REGS); } - Yap_FreeCodeSpace(pp->ValueOfVE.floats); - WRITE_UNLOCK(ae->ARWLock); - return true; } + WRITE_UNLOCK(ae->ARWLock); + if (!pp) { + return false; + } + return true; } - Yap_Error(TYPE_ERROR_ATOM, t, "create static array"); return false; } -/// create a new vectir in a given name Name. If one exists, destroy prrexisting +/// create a new vector in a given name Name. If one exists, destroy prrexisting /// onr StaticArrayEntry *Yap_StaticVector(Atom Name, size_t size, static_array_types props) { diff --git a/C/atomic.c b/C/atomic.c index 4fb14bb92..96be7955b 100755 --- a/C/atomic.c +++ b/C/atomic.c @@ -1,19 +1,19 @@ /************************************************************************* -* * -* YAP Prolog * -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V. Santos Costa and Universidade do Porto 1985-- * -* * -************************************************************************** -* * -* File: atoms.c * -* comments: General-purpose C implemented system predicates * -* * -* Last rev: $Date: 2008-07-24 16:02:00 $,$Author: vsc $ * -* * -*************************************************************************/ + * * + * YAP Prolog * + * * + * Yap Prolog was developed at NCCUP - Universidade do Porto * + * * + * Copyright L.Damas, V. Santos Costa and Universidade do Porto 1985-- * + * * + ************************************************************************** + * * + * File: atoms.c * + * comments: General-purpose C implemented system predicates * + * * + * Last rev: $Date: 2008-07-24 16:02:00 $,$Author: vsc $ * + * * + *************************************************************************/ #ifdef SCCS static char SccsId[] = "%W% %G%"; #endif @@ -21,15 +21,21 @@ static char SccsId[] = "%W% %G%"; /** * @file atomic.c * + * @namespace prolog + * + */ + +/** * @defgroup Predicates_on_Atoms Predicates on Atoms and Strings * @ingroup builtins * @{ - -@brief The following predicates are used to manipulate atoms, strings, lists of codes and lists of chars: - -\toc - -*/ + * + * @brief The following predicates are used to manipulate atoms, strings, lists + * of codes and lists of chars: + * + * \toc + * + */ #define HAS_CACHE_REGS 1 /* @@ -91,7 +97,7 @@ static int AlreadyHidden(unsigned char *name) { Notice that defining a new atom with the same characters will result in a different atom.xs - **/ +**/ static Int hide_atom(USES_REGS1) { /* hide(+Atom) */ Atom atomToInclude; Term t1 = Deref(ARG1); @@ -141,7 +147,7 @@ static Int hide_atom(USES_REGS1) { /* hide(+Atom) */ /** @pred hidden_atom( +Atom ) Is the atom _Ãtom_ visible to Prolog? - **/ +**/ static Int hidden_atom(USES_REGS1) { /* '$hidden_atom'(+F) */ Atom at; AtomEntry *chain; @@ -169,9 +175,9 @@ static Int hidden_atom(USES_REGS1) { /* '$hidden_atom'(+F) */ Make hidden atom _Atom_ visible Note that the operation fails if another atom with name _Atom_ was defined - since. + since. - **/ +**/ static Int unhide_atom(USES_REGS1) { /* unhide_atom(+Atom) */ AtomEntry *atom, *old, *chain; Term t1 = Deref(ARG1); @@ -210,6 +216,16 @@ static Int unhide_atom(USES_REGS1) { /* unhide_atom(+Atom) */ return (TRUE); } +/** @pred char_code(? _A_,? _I_) is iso + + + The built-in succeeds with _A_ bound to character represented as an + atom, and _I_ bound to the character code represented as an + integer. At least, one of either _A_ or _I_ must be bound before + the call. + + +*/ static Int char_code(USES_REGS1) { Int t0 = Deref(ARG1); if (IsVarTerm(t0)) { @@ -258,54 +274,82 @@ static Int char_code(USES_REGS1) { Atom at = AtomOfTerm(t0); Term tf; unsigned char *c = RepAtom(at)->UStrOfAE; - int32_t v; - c += get_utf8(c, 1, &v); - if (c[0] != '\0') { - Yap_Error(TYPE_ERROR_CHARACTER, t0, "char_code/2"); - return FALSE; - } + int32_t v = IntegerOfTerm(ARG1); + + get_utf8(c, -1, &v); + if (!v) + return false; tf = MkIntTerm(v); return Yap_unify(ARG2, tf); } } -static Int name(USES_REGS1) { /* name(?Atomic,?String) */ - Term t = Deref(ARG2), NewT, AtomNameT = Deref(ARG1); - LOCAL_MAX_SIZE = 1024; +/** @pred name( _A_, _L_) + + The predicate holds when at least one of the arguments is ground + (otherwise, an error message will be displayed). The argument _A_ will + be unified with an atomic symbol and _L_ with the list of the ASCII + codes for the characters of the external representation of _A_. + + ~~~~~{.prolog} + name(yap,L). + ~~~~~ + will return: + + ~~~~~{.prolog} + L = [121,97,112]. + ~~~~~ + and + + ~~~~~{.prolog} + name(3,L). + ~~~~~ + will return: + + ~~~~~{.prolog} + L = [51]. + ~~~~~ + + +*/ +static Int name(USES_REGS1) { /* name(?Atomic,?String) */ + Term t2 = Deref(ARG2), NewT, t1 = Deref(ARG1); + LOCAL_MAX_SIZE = 1024; int l = push_text_stack(); + restart_aux: - if (Yap_IsGroundTerm(AtomNameT)) { - if (!IsVarTerm(t) && !IsPairTerm(t) && t != TermNil) { + if (Yap_IsGroundTerm(t1)) { + if (!IsVarTerm(t2) && !IsPairTerm(t2) && t2 != TermNil) { Yap_Error(TYPE_ERROR_LIST, ARG2, "name/2"); pop_text_stack(l); - ReleaseAndReturn(FALSE); + return false; } // verify if an atom, int, float or bi§gnnum - NewT = Yap_AtomicToListOfCodes(AtomNameT PASS_REGS); + NewT = Yap_AtomSWIToListOfCodes(t1 PASS_REGS); if (NewT) { pop_text_stack(l); - ReleaseAndReturn(Yap_unify(NewT, ARG2)); + return Yap_unify(NewT, ARG2); } // else - } else if (IsVarTerm(t)) { - Yap_Error(INSTANTIATION_ERROR, t, "name/2"); + } else if (IsVarTerm(t2)) { + Yap_Error(INSTANTIATION_ERROR, t2, "name/2"); pop_text_stack(l); - return FALSE; + return false; } else { - Term at = Yap_ListToAtomic(t PASS_REGS); + Term at = Yap_ListToAtomic(t2 PASS_REGS); if (at) { pop_text_stack(l); - ReleaseAndReturn(Yap_unify(at, ARG1)); + return Yap_unify(at, ARG1); } } if (LOCAL_Error_TYPE && Yap_HandleError("atom/2")) { - AtomNameT = Deref(ARG1); - t = Deref(ARG2); + t1 = Deref(ARG1); + t2 = Deref(ARG2); goto restart_aux; } pop_text_stack(l); - ReleaseAndReturn(FALSE); + return false; } static Int string_to_atomic( @@ -320,14 +364,14 @@ restart_aux: t = Yap_StringToAtomic(t1 PASS_REGS); if (t != 0L) { pop_text_stack(l); - ReleaseAndReturn(Yap_unify(t, t2)); + return Yap_unify(t, t2); } // else } else if (IsVarTerm(t1)) { Term t0 = Yap_AtomicToString(t2 PASS_REGS); if (t0) { pop_text_stack(l); - ReleaseAndReturn(Yap_unify(t0, t1)); + return Yap_unify(t0, t1); } } else { LOCAL_Error_TYPE = TYPE_ERROR_STRING; @@ -338,11 +382,35 @@ restart_aux: goto restart_aux; } pop_text_stack(l); - ReleaseAndReturn(FALSE); + return false; } -static Int string_to_atom( - USES_REGS1) { /* string_to_atom(?String,?Atom) */ +/// @pred atomic_to_string(?Atomic.?String) +// +// reverse to string_to_atomic(_Atomic_, _String_). +// The second argument may be a sequence of codes or atoms. +// +static Int atomic_to_string(USES_REGS1) { + Term t1 = ARG1; + ARG1 = ARG2, ARG2 = t1; + return string_to_atomic(PASS_REGS1); +} + +/// @pred string_to_atom(?String, ?Atom) +// +// Verifies if (a) at least one of the argument is bound. If +// _String_ is bound it must be a string term, list if codes, or +// list of atoms, and _Atom_ musr be bound to a symbol with the +// same text. Otherwise, _Atom_ must be an _Atom_ and _String_ +// will unify with a string term of the same text. +// +// Notes: +// - some versions of YAP allow the first argument to be a +// number. Please use +// atomic_to_string/2 in this YAP. +// +static Int string_to_atom(USES_REGS1) { /* string_to_atom(?String,?Atom) + */ Term t2 = Deref(ARG2), t1 = Deref(ARG1); LOCAL_MAX_SIZE = 1024; int l = push_text_stack(); @@ -354,14 +422,14 @@ restart_aux: at = Yap_StringSWIToAtom(t1 PASS_REGS); if (at) { pop_text_stack(l); - ReleaseAndReturn(Yap_unify(MkAtomTerm(at), t2)); + return Yap_unify(MkAtomTerm(at), t2); } // else } else if (IsVarTerm(t1)) { Term t0 = Yap_AtomSWIToString(t2 PASS_REGS); if (t0) { pop_text_stack(l); - ReleaseAndReturn(Yap_unify(t0, t1)); + return Yap_unify(t0, t1); } } else { LOCAL_Error_TYPE = TYPE_ERROR_ATOM; @@ -372,7 +440,21 @@ restart_aux: goto restart_aux; } pop_text_stack(l); - ReleaseAndReturn(FALSE); + return false; +} + +/// @pred atom_to_string(?Atom.?String) +// +// reverse to string_to_atom(_Atom_, _String_). +// The second argument may be a sequence of codes or +// atoms. +// +static Int atom_to_string(USES_REGS1) { /* string_to_atom(?String,?Atom) + */ + Term t2 = ARG1; + ARG1 = ARG2; + ARG2 = t2; + return string_to_atom(PASS_REGS1); } static Int string_to_list(USES_REGS1) { @@ -385,12 +467,14 @@ restart_aux: Term t1 = Yap_ListToString(list PASS_REGS); if (t1) { pop_text_stack(l); - ReleaseAndReturn(Yap_unify(ARG1, t1)); + return Yap_unify(ARG1, t1); } } else if (IsStringTerm(string)) { Term tf = Yap_StringToListOfCodes(string PASS_REGS); - pop_text_stack(l); - ReleaseAndReturn(Yap_unify(ARG2, tf)); + { + pop_text_stack(l); + return Yap_unify(ARG2, tf); + } } else { LOCAL_Error_TYPE = TYPE_ERROR_STRING; } @@ -399,10 +483,18 @@ restart_aux: list = Deref(ARG2); goto restart_aux; } - pop_text_stack(l); - ReleaseAndReturn(FALSE); + { + pop_text_stack(l); + return false; + } } +/// @pred atom_string(?Atom.?String) +// +// reverse to string_to_atom(_Atom_, _String_). +// The second argument may be a sequence of codes or +// atoms. +// static Int atom_string(USES_REGS1) { Term t1 = Deref(ARG1), t2 = Deref(ARG2); LOCAL_MAX_SIZE = 1024; @@ -413,13 +505,20 @@ restart_aux: Atom at; // verify if an atom, int, float or bignnum at = Yap_StringSWIToAtom(t2 PASS_REGS); - if (at) - ReleaseAndReturn(Yap_unify(MkAtomTerm(at), t1)); + if (at) { + { + pop_text_stack(l); + return Yap_unify(MkAtomTerm(at), t1); + } + } + LOCAL_Error_TYPE = YAP_NO_ERROR; // else } else if (IsAtomTerm(t1)) { Term t0 = Yap_AtomSWIToString(t1 PASS_REGS); - if (t0) - ReleaseAndReturn(Yap_unify(t0, t2)); + if (t0) { + pop_text_stack(l); + return Yap_unify(t0, t2); + } } else { LOCAL_Error_TYPE = TYPE_ERROR_ATOM; } @@ -428,9 +527,33 @@ restart_aux: t2 = Deref(ARG2); goto restart_aux; } - ReleaseAndReturn(FALSE); + { + pop_text_stack(l); + return false; + } } +// The second argument may be a sequence of codes or +// atoms. +// +static Int string_atom(USES_REGS1) { /* string_to_atom(?String,?Atom) + */ + Term t2 = ARG1; + ARG1 = ARG2; + ARG2 = t2; + return atom_string(PASS_REGS1); +} + +/** @pred atom_chars(? _A_,? _L_) is iso + + + The predicate holds when at least one of the arguments is + ground (otherwise, an error message will be displayed). + The argument _A_ must be unifiable with an atom, and the + argument _L_ with the list of the characters of _A_. + + +*/ static Int atom_chars(USES_REGS1) { Term t1; LOCAL_MAX_SIZE = 1024; @@ -440,14 +563,18 @@ restart_aux: t1 = Deref(ARG1); if (IsAtomTerm(t1)) { Term tf = Yap_AtomSWIToListOfAtoms(t1 PASS_REGS); - if (tf) - ReleaseAndReturn(Yap_unify(ARG2, tf)); + if (tf) { + pop_text_stack(l); + return Yap_unify(ARG2, tf); + } } else if (IsVarTerm(t1)) { /* ARG1 unbound */ Term t = Deref(ARG2); Atom af = Yap_ListOfAtomsToAtom(t PASS_REGS); - if (af) - ReleaseAndReturn(Yap_unify(ARG1, MkAtomTerm(af))); + if (af) { + pop_text_stack(l); + return Yap_unify(ARG1, MkAtomTerm(af)); + } /* error handling */ } else { LOCAL_Error_TYPE = TYPE_ERROR_ATOM; @@ -455,33 +582,54 @@ restart_aux: if (LOCAL_Error_TYPE && Yap_HandleError("atom_chars/2")) { goto restart_aux; } - ReleaseAndReturn(false); + { + pop_text_stack(l); + return false; + } } +/** @pred atom_codes(?A, ?L) is iso + + + The predicate holds when at least one of the arguments is + ground (otherwise, YAP will generate an error event. _A_ must be unifiable + with an atom, and the argument _L_ with the list of the character codes for + string _A_. + + +*/ static Int atom_codes(USES_REGS1) { Term t1; - t1 = Deref(ARG1); + LOCAL_MAX_SIZE = 1024; int l = push_text_stack(); + restart_aux: + t1 = Deref(ARG1); if (IsAtomTerm(t1)) { - Term tf = Yap_AtomToListOfCodes(t1 PASS_REGS); - if (tf) - ReleaseAndReturn(Yap_unify(ARG2, tf)); + Term tf = Yap_AtomSWIToListOfCodes(t1 PASS_REGS); + if (tf) { + pop_text_stack(l); + return Yap_unify(ARG2, tf); + } } else if (IsVarTerm(t1)) { /* ARG1 unbound */ Term t = Deref(ARG2); - Atom af = Yap_ListToAtom(t PASS_REGS); - if (af) - ReleaseAndReturn(Yap_unify(ARG1, MkAtomTerm(af))); - } else if (IsVarTerm(t1)) { - LOCAL_Error_TYPE = TYPE_ERROR_ATOM; + Atom af = Yap_ListOfCodesToAtom(t PASS_REGS); + if (af) { + pop_text_stack(l); + return Yap_unify(ARG1, MkAtomTerm(af)); + } + /* error handling */ + } else { + Yap_ThrowError(TYPE_ERROR_ATOM, t1, NULL); } - /* error handling */ if (LOCAL_Error_TYPE && Yap_HandleError("atom_codes/2")) { - t1 = Deref(ARG1); goto restart_aux; } - ReleaseAndReturn(FALSE); + { + pop_text_stack(l); + return false; + } } static Int string_codes(USES_REGS1) { @@ -491,14 +639,18 @@ static Int string_codes(USES_REGS1) { restart_aux: if (IsStringTerm(t1)) { Term tf = Yap_StringSWIToListOfCodes(t1 PASS_REGS); - if (tf) - ReleaseAndReturn(Yap_unify(ARG2, tf)); + if (tf) { + pop_text_stack(l); + return Yap_unify(ARG2, tf); + } } else if (IsVarTerm(t1)) { /* ARG1 unbound */ Term t = Deref(ARG2); Term tf = Yap_ListSWIToString(t PASS_REGS); - if (tf) - ReleaseAndReturn(Yap_unify(ARG1, tf)); + if (tf) { + pop_text_stack(l); + return Yap_unify(ARG1, tf); + } } else { LOCAL_Error_TYPE = TYPE_ERROR_STRING; } @@ -507,7 +659,10 @@ restart_aux: t1 = Deref(ARG1); goto restart_aux; } - ReleaseAndReturn(FALSE); + { + pop_text_stack(l); + return false; + } } static Int string_chars(USES_REGS1) { @@ -517,14 +672,18 @@ static Int string_chars(USES_REGS1) { restart_aux: if (IsStringTerm(t1)) { Term tf = Yap_StringSWIToListOfAtoms(t1 PASS_REGS); - if (tf) - ReleaseAndReturn(Yap_unify(ARG2, tf)); + if (tf) { + pop_text_stack(l); + return Yap_unify(ARG2, tf); + } } else if (IsVarTerm(t1)) { /* ARG1 unbound */ Term t = Deref(ARG2); Term tf = Yap_ListSWIToString(t PASS_REGS); - if (tf) - ReleaseAndReturn(Yap_unify(ARG1, tf)); + if (tf) { + pop_text_stack(l); + return Yap_unify(ARG1, tf); + } } else { LOCAL_Error_TYPE = TYPE_ERROR_STRING; } @@ -533,33 +692,32 @@ restart_aux: t1 = Deref(ARG1); goto restart_aux; } - ReleaseAndReturn(FALSE); + { + pop_text_stack(l); + return false; + } } /** @pred number_chars(? _I_,? _L_) is iso -The predicate holds when at least one of the arguments is ground -(otherwise, an error message will be displayed). The argument _I_ must -be unifiable with a number, and the argument _L_ with the list of the -characters of the external representation of _I_. + The predicate holds when at least one of the arguments is + ground (otherwise, an error message will be displayed). + The argument _I_ must be unifiable with a number, and the + argument _L_ with the list of the characters of the + external representation of _I_. */ static Int number_chars(USES_REGS1) { Term t1; int l = push_text_stack(); -restart_aux: t1 = Deref(ARG1); if (IsNumTerm(t1)) { Term t2 = Deref(ARG2); - if (IsVarTerm(t2)) { - t1 = Yap_NumberToListOfAtoms(t1 PASS_REGS); - } - if (t1) { - ReleaseAndReturn(Yap_unify(t1, t2)); - } else { - t2 = Yap_ListToNumber(t2 PASS_REGS); - if (t2) { - ReleaseAndReturn(Yap_unify(t1, t2)); + Term t12 = Yap_NumberToListOfAtoms(t1 PASS_REGS); + if (t12 && t2) { + { + pop_text_stack(l); + return Yap_unify(t12, t2); } } } else if (IsVarTerm(t1)) { @@ -567,18 +725,33 @@ restart_aux: Term t = Deref(ARG2); Term tf = Yap_ListToNumber(t PASS_REGS); if (tf) { - ReleaseAndReturn(Yap_unify(ARG1, tf)); + pop_text_stack(l); + return Yap_unify(ARG1, tf); } - } else if (IsVarTerm(t1)) { - LOCAL_Error_TYPE = TYPE_ERROR_NUMBER; + pop_text_stack(l); + + LOCAL_ActiveError->errorRawTerm = 0; + Yap_ThrowExistingError(); + + return false; } - /* error handling */ - if (LOCAL_Error_TYPE && Yap_HandleError("number_chars/2")) { - goto restart_aux; - } - ReleaseAndReturn(false); + pop_text_stack(l); + + return true; } +/** @pred number_atom(? _I_,? _A_){te + + + + The predicate holds when at least one of the arguments is + ground (otherwise, an error message will be displayed). + The argument _I_ must be unifiable with a number, and the + argument _A_ must be unifiable with an atom representing + the number. + + +*/ static Int number_atom(USES_REGS1) { Term t1; int l = push_text_stack(); @@ -591,11 +764,17 @@ restart_aux: if (af) { if (IsVarTerm(t2)) { - ReleaseAndReturn(Yap_unify(t1, t2)); + { + pop_text_stack(l); + return Yap_unify(t1, t2); + } } else { t2 = Yap_AtomToNumber(t2 PASS_REGS); if (t2) { - ReleaseAndReturn(Yap_unify(t1, t2)); + { + pop_text_stack(l); + return Yap_unify(t1, t2); + } } } } @@ -603,16 +782,34 @@ restart_aux: /* ARG1 unbound */ Term t = Deref(ARG2); Term tf = Yap_AtomToNumber(t PASS_REGS); - ReleaseAndReturn(Yap_unify(ARG1, tf)); + { + pop_text_stack(l); + return Yap_unify(ARG1, tf); + } } else if (IsVarTerm(t1)) { LOCAL_Error_TYPE = TYPE_ERROR_NUMBER; } /* error handling */ if (LOCAL_Error_TYPE && Yap_HandleError("number_atom/2")) { goto restart_aux; } - ReleaseAndReturn(false); + { + pop_text_stack(l); + return false; + } } +/** @pred number_string(? _I_,? _L_) + + + The predicate holds when at least one of the arguments is + ground (otherwise, an error message will be displayed). + The argument _I_ must be unifiable with a number, and the + argument _L_ must be unifiable with a term string + representing the number. + + +*/ + static Int number_string(USES_REGS1) { Term t1; int l = push_text_stack(); @@ -621,14 +818,18 @@ restart_aux: if (IsNumTerm(t1)) { Term tf; tf = Yap_NumberToString(t1 PASS_REGS); - if (tf) - ReleaseAndReturn(Yap_unify(ARG2, tf)); + if (tf) { + pop_text_stack(l); + return Yap_unify(ARG2, tf); + } } else if (IsVarTerm(t1)) { /* ARG1 unbound */ Term t = Deref(ARG2); Term tf = Yap_StringToNumber(t PASS_REGS); - if (tf) - ReleaseAndReturn(Yap_unify(ARG1, tf)); + if (tf) { + pop_text_stack(l); + return Yap_unify(ARG1, tf); + } } else { LOCAL_Error_TYPE = TYPE_ERROR_NUMBER; } @@ -636,9 +837,23 @@ restart_aux: if (LOCAL_Error_TYPE && Yap_HandleError("number_string/2")) { goto restart_aux; } - ReleaseAndReturn(FALSE); + { + pop_text_stack(l); + return false; + } } +/** @pred number_codes(? _I_,? _L_) + + + The predicate holds when at least one of the arguments is + ground (otherwise, an error message will be displayed). + The argument _I_ must be unifiable with a number, and the + argument _L_ must be unifiable with a list of UNICODE + numbers representing the number. + + +*/ static Int number_codes(USES_REGS1) { Term t1; int l = push_text_stack(); @@ -647,14 +862,18 @@ restart_aux: if (IsNumTerm(t1)) { Term tf; tf = Yap_NumberToListOfCodes(t1 PASS_REGS); - if (tf) - ReleaseAndReturn(Yap_unify(ARG2, tf)); + if (tf) { + pop_text_stack(l); + return Yap_unify(ARG2, tf); + } } else if (IsVarTerm(t1)) { /* ARG1 unbound */ Term t = Deref(ARG2); Term tf = Yap_ListToNumber(t PASS_REGS); - if (tf) - ReleaseAndReturn(Yap_unify(ARG1, tf)); + if (tf) { + pop_text_stack(l); + return Yap_unify(ARG1, tf); + } } else { LOCAL_Error_TYPE = TYPE_ERROR_NUMBER; } @@ -662,41 +881,44 @@ restart_aux: if (LOCAL_Error_TYPE && Yap_HandleError("number_codes/2")) { goto restart_aux; } - ReleaseAndReturn(FALSE); + { + pop_text_stack(l); + return false; + } } static Int cont_atom_concat3(USES_REGS1) { Term t3; Atom ats[2]; Int i, max; - int l = push_text_stack(); restart_aux: t3 = Deref(ARG3); i = IntOfTerm(EXTRA_CBACK_ARG(3, 1)); max = IntOfTerm(EXTRA_CBACK_ARG(3, 2)); EXTRA_CBACK_ARG(3, 1) = MkIntTerm(i + 1); - if (!Yap_SpliceAtom(t3, ats, i, max PASS_REGS) && - LOCAL_Error_TYPE == YAP_NO_ERROR) { - release_cut_fail(); - } else { - if (i < max) { - ReleaseAndReturn(Yap_unify(ARG1, MkAtomTerm(ats[0])) && - Yap_unify(ARG2, MkAtomTerm(ats[1]))); + + int l = push_text_stack(); + bool rc = Yap_SpliceAtom(t3, ats, i, max PASS_REGS); + pop_text_stack(l); + if (LOCAL_Error_TYPE == YAP_NO_ERROR) { + if (rc) { + if (i < max) { + return (Yap_unify(ARG1, MkAtomTerm(ats[0])) && + Yap_unify(ARG2, MkAtomTerm(ats[1]))); + } + return do_cut(Yap_unify(ARG1, MkAtomTerm(ats[0])) && + Yap_unify(ARG2, MkAtomTerm(ats[1]))); + } else { + cut_fail(); } - if (Yap_unify(ARG1, MkAtomTerm(ats[0])) && - Yap_unify(ARG2, MkAtomTerm(ats[1]))) - release_cut_succeed(); - release_cut_fail(); } /* Error handling */ if (LOCAL_Error_TYPE) { if (Yap_HandleError("atom_concat/3")) { goto restart_aux; - } else { - ReleaseAndReturn(false); } } - release_cut_fail(); + cut_fail(); } static Int atom_concat3(USES_REGS1) { @@ -704,7 +926,6 @@ static Int atom_concat3(USES_REGS1) { Term t2, t3, ot; Atom at; bool g1, g2, g3; - int l = push_text_stack(); restart_aux: t1 = Deref(ARG1); t2 = Deref(ARG2); @@ -713,80 +934,88 @@ restart_aux: g2 = Yap_IsGroundTerm(t2); g3 = Yap_IsGroundTerm(t3); if (g1 && g2) { + int l = push_text_stack(); at = Yap_ConcatAtoms(t1, t2 PASS_REGS); + pop_text_stack(l); ot = ARG3; } else if (g1 && g3) { + int l = push_text_stack(); at = Yap_SubtractHeadAtom(t3, t1 PASS_REGS); + pop_text_stack(l); ot = ARG2; } else if (g2 && g3) { + int l = push_text_stack(); at = Yap_SubtractTailAtom(t3, t2 PASS_REGS); + pop_text_stack(l); ot = ARG1; } else if (g3) { + Int len = Yap_AtomToUnicodeLength(t3 PASS_REGS); + if (len <= 0) { + cut_fail(); + } EXTRA_CBACK_ARG(3, 1) = MkIntTerm(0); - EXTRA_CBACK_ARG(3, 2) = MkIntTerm(Yap_AtomToLength(t3 PASS_REGS)); - ReleaseAndReturn(cont_atom_concat3(PASS_REGS1)); + EXTRA_CBACK_ARG(3, 2) = MkIntTerm(len); + { return cont_atom_concat3(PASS_REGS1); } } else { LOCAL_Error_TYPE = INSTANTIATION_ERROR; at = NULL; } - pop_text_stack(l); if (at) { - if (Yap_unify(ot, MkAtomTerm(at))) { - release_cut_succeed(); - } else { - release_cut_fail(); - } + return do_cut(Yap_unify(ot, MkAtomTerm(at))); } /* Error handling */ if (LOCAL_Error_TYPE) { if (Yap_HandleError("atom_concat/3")) { goto restart_aux; - } else { - ReleaseAndReturn(false); } } - release_cut_fail(); + cut_fail(); } #define CastToNumeric(x) CastToNumeric__(x PASS_REGS) static Term CastToNumeric__(Atom at USES_REGS) { Term t; - if ((t = Yap_AtomToNumber(MkAtomTerm(at) PASS_REGS))) + if ((t = Yap_AtomToNumber(MkAtomTerm(at) PASS_REGS))) { return t; - return MkAtomTerm(at); + } else { + return MkAtomTerm(at); + } } static Int cont_atomic_concat3(USES_REGS1) { Term t3; Atom ats[2]; size_t i, max; - int l = push_text_stack(); restart_aux: t3 = Deref(ARG3); i = IntOfTerm(EXTRA_CBACK_ARG(3, 1)); max = IntOfTerm(EXTRA_CBACK_ARG(3, 2)); EXTRA_CBACK_ARG(3, 1) = MkIntTerm(i + 1); - if (!Yap_SpliceAtom(t3, ats, i, max PASS_REGS)) { - release_cut_fail(); + int l = push_text_stack(); + bool rc = Yap_SpliceAtom(t3, ats, i, max PASS_REGS); + pop_text_stack(l); + if (!rc) { + cut_fail(); } else { Term t1 = CastToNumeric(ats[0]); Term t2 = CastToNumeric(ats[1]); - if (i < max) - ReleaseAndReturn(Yap_unify(ARG1, t1) && Yap_unify(ARG2, t2)); + if (i < max) { + return Yap_unify(ARG1, t1) && Yap_unify(ARG2, t2); + } if (Yap_unify(ARG1, t1) && Yap_unify(ARG2, t2)) - release_cut_succeed(); - release_cut_fail(); + cut_succeed(); + cut_fail(); } /* Error handling */ if (LOCAL_Error_TYPE) { if (Yap_HandleError("string_concat/3")) { goto restart_aux; } else { - ReleaseAndReturn(FALSE); + return false; } } - release_cut_fail(); + cut_fail(); } static Int atomic_concat3(USES_REGS1) { @@ -794,7 +1023,6 @@ static Int atomic_concat3(USES_REGS1) { Term t2, t3, ot; Atom at = NULL; bool g1, g2, g3; - int l = push_text_stack(); restart_aux: t1 = Deref(ARG1); t2 = Deref(ARG2); @@ -803,17 +1031,27 @@ restart_aux: g2 = Yap_IsGroundTerm(t2); g3 = Yap_IsGroundTerm(t3); if (g1 && g2) { + int l = push_text_stack(); at = Yap_ConcatAtomics(t1, t2 PASS_REGS); + pop_text_stack(l); ot = ARG3; } else if (g1 && g3) { + int l = push_text_stack(); at = Yap_SubtractHeadAtom(t3, t1 PASS_REGS); + pop_text_stack(l); ot = ARG2; } else if (g2 && g3) { + int l = push_text_stack(); at = Yap_SubtractTailAtom(t3, t2 PASS_REGS); + pop_text_stack(l); ot = ARG1; } else if (g3) { + Int len = Yap_AtomicToUnicodeLength(t3 PASS_REGS); + if (len <= 0) { + cut_fail(); + } EXTRA_CBACK_ARG(3, 1) = MkIntTerm(0); - EXTRA_CBACK_ARG(3, 2) = MkIntTerm(Yap_AtomicToLength(t3 PASS_REGS)); + EXTRA_CBACK_ARG(3, 2) = MkIntTerm(len); return cont_atomic_concat3(PASS_REGS1); } else { LOCAL_Error_TYPE = INSTANTIATION_ERROR; @@ -821,9 +1059,9 @@ restart_aux: } if (at) { if (Yap_unify(ot, MkAtomTerm(at))) { - release_cut_succeed(); + cut_succeed(); } else { - release_cut_fail(); + cut_fail(); } } /* Error handling */ @@ -834,27 +1072,30 @@ restart_aux: return false; } } - release_cut_fail(); + cut_fail(); } static Int cont_string_concat3(USES_REGS1) { Term t3; Term ts[2]; size_t i, max; - int l = push_text_stack(); restart_aux: t3 = Deref(ARG3); i = IntOfTerm(EXTRA_CBACK_ARG(3, 1)); max = IntOfTerm(EXTRA_CBACK_ARG(3, 2)); EXTRA_CBACK_ARG(3, 1) = MkIntTerm(i + 1); - if (!Yap_SpliceString(t3, ts, i, max PASS_REGS)) { - release_cut_fail(); + int l; + l = push_text_stack(); + bool rc = Yap_SpliceString(t3, ts, i, max PASS_REGS); + pop_text_stack(l); + if (!rc) { + cut_fail(); } else { - if (i < max) + if (i < max) { return Yap_unify(ARG1, ts[0]) && Yap_unify(ARG2, ts[1]); - if (Yap_unify(ARG1, ts[0]) && Yap_unify(ARG2, ts[1])) - release_cut_succeed(); - release_cut_fail(); + } + return do_cut(Yap_unify(ARG1, ts[0]) && Yap_unify(ARG2, ts[1])); + cut_succeed(); } /* Error handling */ if (LOCAL_Error_TYPE) { @@ -864,7 +1105,7 @@ restart_aux: return FALSE; } } - release_cut_fail(); + cut_fail(); } static Int string_concat3(USES_REGS1) { @@ -872,7 +1113,6 @@ static Int string_concat3(USES_REGS1) { Term t2, t3, ot; Term tf = 0; bool g1, g2, g3; - int l = push_text_stack(); restart_aux: t1 = Deref(ARG1); t2 = Deref(ARG2); @@ -880,38 +1120,48 @@ restart_aux: g1 = Yap_IsGroundTerm(t1); g2 = Yap_IsGroundTerm(t2); g3 = Yap_IsGroundTerm(t3); + if (g1 && g2) { + int l; + l = push_text_stack(); tf = Yap_ConcatStrings(t1, t2 PASS_REGS); + pop_text_stack(l); ot = ARG3; } else if (g1 && g3) { + int l; + l = push_text_stack(); tf = Yap_SubtractHeadString(t3, t1 PASS_REGS); + pop_text_stack(l); ot = ARG2; } else if (g2 && g3) { + int l; + l = push_text_stack(); tf = Yap_SubtractTailString(t3, t2 PASS_REGS); + pop_text_stack(l); ot = ARG1; } else if (g3) { + Int len = Yap_StringToUnicodeLength(t3 PASS_REGS); + if (len <= 0) { + cut_fail(); + } EXTRA_CBACK_ARG(3, 1) = MkIntTerm(0); - EXTRA_CBACK_ARG(3, 2) = MkIntTerm(Yap_StringToLength(t3 PASS_REGS)); - return cont_string_concat3(PASS_REGS1); + EXTRA_CBACK_ARG(3, 2) = MkIntTerm(len); + { return cont_string_concat3(PASS_REGS1); } } else { LOCAL_Error_TYPE = INSTANTIATION_ERROR; } if (tf) { - if (Yap_unify(ot, tf)) { - release_cut_succeed(); - } else { - release_cut_fail(); - } + return do_cut(Yap_unify(ot, tf)); } /* Error handling */ if (LOCAL_Error_TYPE) { if (Yap_HandleError("atom_concat/3")) { goto restart_aux; } else { - ReleaseAndReturn(false); + return false; } } - release_cut_fail(); + cut_fail(); } static Int cont_string_code3(USES_REGS1) { @@ -920,36 +1170,37 @@ static Int cont_string_code3(USES_REGS1) { utf8proc_int32_t chr; const unsigned char *s; const unsigned char *s0; - int l = push_text_stack(); + int l; + l = push_text_stack(); restart_aux: t2 = Deref(ARG2); s0 = UStringOfTerm(t2); i = IntOfTerm( EXTRA_CBACK_ARG(3, 1)); // offset in coded string, increases by 1..6 - j = IntOfTerm( - EXTRA_CBACK_ARG(3, 2)); // offset in UNICODE string, always increases by 1 + j = IntOfTerm(EXTRA_CBACK_ARG(3, 2)); // offset in UNICODE + // string, always + // increases by 1 s = (s0 + i) + get_utf8((unsigned char *)s0 + i, -1, &chr); if (s[0]) { EXTRA_CBACK_ARG(3, 1) = MkIntTerm(s - s0); EXTRA_CBACK_ARG(3, 2) = MkIntTerm(j + 1); - ReleaseAndReturn(Yap_unify(MkIntegerTerm(chr), ARG3) && - Yap_unify(MkIntegerTerm(j + 1), ARG1)); - } - if (Yap_unify(MkIntegerTerm(chr), ARG3) && - Yap_unify(MkIntegerTerm(j), ARG1)) { - release_cut_succeed(); - } else { - release_cut_fail(); + return (Yap_unify(MkIntegerTerm(chr), ARG3) && + Yap_unify(MkIntegerTerm(j + 1), ARG1)); } + return do_cut(Yap_unify(MkIntegerTerm(chr), ARG3) && + Yap_unify(MkIntegerTerm(j), ARG1)); /* Error handling */ if (LOCAL_Error_TYPE) { if (Yap_HandleError("string_code/3")) { goto restart_aux; } else { - ReleaseAndReturn(FALSE); + { + pop_text_stack(l); + return false; + } } } - release_cut_fail(); + cut_fail(); } static Int string_code3(USES_REGS1) { @@ -970,7 +1221,10 @@ restart_aux: if (IsVarTerm(t1)) { EXTRA_CBACK_ARG(3, 1) = MkIntTerm(0); EXTRA_CBACK_ARG(3, 2) = MkIntTerm(0); - return cont_string_code3(PASS_REGS1); + { + pop_text_stack(l); + return cont_string_code3(PASS_REGS1); + } } else if (!IsIntegerTerm(t1)) { LOCAL_Error_TYPE = TYPE_ERROR_INTEGER; } else { @@ -981,18 +1235,18 @@ restart_aux: if (indx < 0) { LOCAL_Error_TYPE = DOMAIN_ERROR_NOT_LESS_THAN_ZERO; } - release_cut_fail(); + cut_fail(); } ns = skip_utf8(s, indx); if (ns == NULL) { - release_cut_fail(); // silently fail? + cut_fail(); // silently fail? } get_utf8(ns, -1, &chr); if (chr == '\0') - release_cut_fail(); + cut_fail(); if (Yap_unify(ARG3, MkIntegerTerm(chr))) - release_cut_succeed(); - release_cut_fail(); + cut_succeed(); + cut_fail(); } } /* Error handling */ @@ -1000,17 +1254,19 @@ restart_aux: if (Yap_HandleError("string_code/3")) { goto restart_aux; } else { - ReleaseAndReturn(FALSE); + { + pop_text_stack(l); + return false; + } } } - release_cut_fail(); + cut_fail(); } static Int get_string_code3(USES_REGS1) { Term t1; Term t2; const unsigned char *s; - int l = push_text_stack(); restart_aux: t1 = Deref(ARG1); t2 = Deref(ARG2); @@ -1028,38 +1284,38 @@ restart_aux: LOCAL_Error_TYPE = TYPE_ERROR_INTEGER; } else { const unsigned char *ns = s; - utf8proc_int32_t chr; Int indx = IntegerOfTerm(t1); if (indx <= 0) { if (indx < 0) { LOCAL_Error_TYPE = DOMAIN_ERROR_NOT_LESS_THAN_ZERO; } else { - ReleaseAndReturn(false); + return false; } } else { indx -= 1; ns = skip_utf8(ns, indx); if (ns == NULL) { - ReleaseAndReturn(false); - } else { - get_utf8(ns, -1, &chr); - if (chr != '\0') - ReleaseAndReturn(Yap_unify(ARG3, MkIntegerTerm(chr))); + return false; } } - ReleaseAndReturn(FALSE); // replace by error cod )e + utf8proc_int32_t chr; + get_utf8(ns, -1, &chr); + if (chr != '\0') { + return Yap_unify(ARG3, MkIntegerTerm(chr)); + } + return false; } - } + } // replace by error cod )e /* Error handling */ if (LOCAL_Error_TYPE) { if (Yap_HandleError("string_code/3")) { goto restart_aux; } else { - ReleaseAndReturn(FALSE); + return false; } } - release_cut_fail(); + cut_fail(); } static Int atom_concat2(USES_REGS1) { @@ -1073,31 +1329,29 @@ restart_aux: if (*tailp != TermNil) { LOCAL_Error_TYPE = TYPE_ERROR_LIST; } else { - seq_tv_t *inpv = (seq_tv_t *)malloc(n * sizeof(seq_tv_t)), out; + seq_tv_t *inpv = (seq_tv_t *)Malloc(n * sizeof(seq_tv_t)), out; int i = 0; Atom at; if (!inpv) { LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; - free(inpv); goto error; } while (t1 != TermNil) { - inpv[i].type = YAP_STRING_ATOM; - inpv[i].val.t = HeadOfTerm(t1); + inpv[i].type = YAP_STRING_ATOM, inpv[i].val.t = HeadOfTerm(t1); i++; t1 = TailOfTerm(t1); } out.type = YAP_STRING_ATOM; if (!Yap_Concat_Text(n, inpv, &out PASS_REGS)) { - free(inpv); goto error; } - free(inpv); at = out.val.a; - if (at) - ReleaseAndReturn(Yap_unify(ARG2, MkAtomTerm(at))); + if (at) { + pop_text_stack(l); + return Yap_unify(ARG2, MkAtomTerm(at)); + } } error: /* Error handling */ @@ -1105,10 +1359,11 @@ error: if (Yap_HandleError("atom_concat/2")) { goto restart_aux; } else { - ReleaseAndReturn(FALSE); + pop_text_stack(l); + return false; } } - release_cut_fail(); + cut_fail(); } static Int string_concat2(USES_REGS1) { @@ -1122,12 +1377,11 @@ restart_aux: if (*tailp != TermNil) { LOCAL_Error_TYPE = TYPE_ERROR_LIST; } else { - seq_tv_t *inpv = (seq_tv_t *)malloc(n * sizeof(seq_tv_t)), out; + seq_tv_t *inpv = (seq_tv_t *)Malloc(n * sizeof(seq_tv_t)); + seq_tv_t *out = (seq_tv_t *)Malloc(sizeof(seq_tv_t)); int i = 0; - if (!inpv) { LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; - free(inpv); goto error; } @@ -1137,14 +1391,15 @@ restart_aux: i++; t1 = TailOfTerm(t1); } - out.type = YAP_STRING_STRING; - if (!Yap_Concat_Text(n, inpv, &out PASS_REGS)) { - free(inpv); + out->type = YAP_STRING_STRING; + if (!Yap_Concat_Text(n, inpv, out PASS_REGS)) { goto error; } - free(inpv); - if (out.val.t) - ReleaseAndReturn(Yap_unify(ARG2, out.val.t)); + if (out->val.t) { + bool rc = Yap_unify(ARG2, out->val.t); + pop_text_stack(l); + return rc; + } } error: /* Error handling */ @@ -1152,10 +1407,13 @@ error: if (Yap_HandleError("string_code/3")) { goto restart_aux; } else { - ReleaseAndReturn(FALSE); + { + pop_text_stack(l); + return false; + } } } - release_cut_fail(); + cut_fail(); } static Int atomic_concat2(USES_REGS1) { @@ -1169,15 +1427,18 @@ restart_aux: if (*tailp != TermNil) { LOCAL_Error_TYPE = TYPE_ERROR_LIST; } else { - seq_tv_t *inpv = (seq_tv_t *)malloc(n * sizeof(seq_tv_t)), out; + seq_tv_t *inpv = (seq_tv_t *)Malloc(n * sizeof(seq_tv_t)); + seq_tv_t *out = (seq_tv_t *)Malloc(sizeof(seq_tv_t)); int i = 0; Atom at; - if (n == 1) - ReleaseAndReturn(Yap_unify(ARG2, HeadOfTerm(t1))); + if (n == 1) { + bool rc = Yap_unify(ARG2, HeadOfTerm(t1)); + pop_text_stack(l); + return rc; + } if (!inpv) { LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; - free(inpv); goto error; } @@ -1189,22 +1450,23 @@ restart_aux: i++; t1 = TailOfTerm(t1); } - out.type = YAP_STRING_ATOM; - if (!Yap_Concat_Text(n, inpv, &out PASS_REGS)) { - free(inpv); + out->type = YAP_STRING_ATOM; + if (!Yap_Concat_Text(n, inpv, out PASS_REGS)) { goto error; } - free(inpv); - at = out.val.a; - if (at) - ReleaseAndReturn(Yap_unify(ARG2, MkAtomTerm(at))); + at = out->val.a; + pop_text_stack(l); + if (at) { + bool rc = Yap_unify(ARG2, MkAtomTerm(at)); + return rc; + } } error: /* Error handling */ if (LOCAL_Error_TYPE && Yap_HandleError("atom_concat/3")) { goto restart_aux; } - return FALSE; + { return FALSE; } } static Int atomics_to_string2(USES_REGS1) { @@ -1218,13 +1480,12 @@ restart_aux: if (*tailp != TermNil) { LOCAL_Error_TYPE = TYPE_ERROR_LIST; } else { - seq_tv_t *inpv = (seq_tv_t *)malloc(n * sizeof(seq_tv_t)), out; + seq_tv_t *inpv = (seq_tv_t *)Malloc(n * sizeof(seq_tv_t)), out; int i = 0; Atom at; if (!inpv) { LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; - free(inpv); goto error; } @@ -1237,20 +1498,23 @@ restart_aux: } out.type = YAP_STRING_STRING; if (!Yap_Concat_Text(n, inpv, &out PASS_REGS)) { - free(inpv); goto error; } - free(inpv); at = out.val.a; - if (at) - ReleaseAndReturn(Yap_unify(ARG2, MkAtomTerm(at))); + if (at) { + pop_text_stack(l); + return Yap_unify(ARG2, MkAtomTerm(at)); + } } error: /* Error handling */ if (LOCAL_Error_TYPE && Yap_HandleError("atomics_to_string/2")) { goto restart_aux; } - ReleaseAndReturn(FALSE); + { + pop_text_stack(l); + return false; + } } static Int atomics_to_string3(USES_REGS1) { @@ -1265,13 +1529,12 @@ restart_aux: if (*tailp != TermNil) { LOCAL_Error_TYPE = TYPE_ERROR_LIST; } else { - seq_tv_t *inpv = (seq_tv_t *)malloc((n * 2 - 1) * sizeof(seq_tv_t)), out; + seq_tv_t *inpv = (seq_tv_t *)Malloc((n * 2 - 1) * sizeof(seq_tv_t)), out; int i = 0; Atom at; if (!inpv) { LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; - free(inpv); goto error; } @@ -1288,22 +1551,32 @@ restart_aux: } out.type = YAP_STRING_STRING; if (!Yap_Concat_Text(2 * n - 1, inpv, &out PASS_REGS)) { - free(inpv); goto error; } - free(inpv); at = out.val.a; - if (at) - ReleaseAndReturn(Yap_unify(ARG3, MkAtomTerm(at))); + if (at) { + pop_text_stack(l); + return Yap_unify(ARG3, MkAtomTerm(at)); + } } error: /* Error handling */ if (LOCAL_Error_TYPE && Yap_HandleError("atomics_to_string/3")) { goto restart_aux; } - ReleaseAndReturn(FALSE); + pop_text_stack(l); + return false; } +/** @pred atom_length(+ _A_,? _I_) is iso + + + The predicate holds when the first argument is an atom, and + the second unifies with the number of characters forming that + atom. If bound, _I_ must be a non-negative integer. + + +*/ static Int atom_length(USES_REGS1) { Term t1 = Deref(ARG1); Term t2 = Deref(ARG2); @@ -1312,33 +1585,53 @@ static Int atom_length(USES_REGS1) { int l = push_text_stack(); if (!Yap_IsGroundTerm(t1)) { Yap_Error(INSTANTIATION_ERROR, t1, "at first argument"); - ReleaseAndReturn(FALSE); + return false; } else if (!IsAtomTerm(t1)) { Yap_Error(TYPE_ERROR_ATOM, t1, "at first argument"); - ReleaseAndReturn(FALSE); + return false; } if (Yap_IsGroundTerm(t2)) { if (!IsIntegerTerm(t2)) { Yap_Error(TYPE_ERROR_INTEGER, t2, "atom_length/2"); - ReleaseAndReturn(FALSE); + { + pop_text_stack(l); + return false; + }; } else if ((Int)(len = IntegerOfTerm(t2)) < 0) { Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t2, "atom_length/2"); - ReleaseAndReturn(FALSE); + { + pop_text_stack(l); + return false; + }; } } restart_aux: - len = Yap_AtomicToLength(t1 PASS_REGS); - if (len != (size_t)-1) - ReleaseAndReturn(Yap_unify(ARG2, MkIntegerTerm(len))); + len = Yap_AtomToUnicodeLength(t1 PASS_REGS); + if (len != (size_t)-1) { + pop_text_stack(l); + return Yap_unify(ARG2, MkIntegerTerm(len)); + }; /* error handling */ if (LOCAL_Error_TYPE && Yap_HandleError("atom_length/2")) { goto restart_aux; } - ReleaseAndReturn(FALSE); + { + pop_text_stack(l); + return false; + }; } +/** @pred atomic_length(+ _A_,? _I_) is iso + + + The predicate holds when the first argument is a number or + atom, and the second unifies with the number of characters + needed to represent the number, or atom. + + +*/ static Int atomic_length(USES_REGS1) { Term t1 = Deref(ARG1); Term t2 = Deref(ARG2); @@ -1347,28 +1640,42 @@ static Int atomic_length(USES_REGS1) { int l = push_text_stack(); if (!Yap_IsGroundTerm(t1)) { Yap_Error(INSTANTIATION_ERROR, t1, "at first argument"); - ReleaseAndReturn(FALSE); + { + pop_text_stack(l); + return false; + }; } if (IsNonVarTerm(t2)) { if (!IsIntegerTerm(t2)) { Yap_Error(TYPE_ERROR_INTEGER, t2, "atom_length/2"); - ReleaseAndReturn(FALSE); + { + pop_text_stack(l); + return false; + }; } else if ((Int)(len = IntegerOfTerm(t2)) < 0) { Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t2, "atom_length/2"); - ReleaseAndReturn(FALSE); + { + pop_text_stack(l); + return false; + }; } } restart_aux: - len = Yap_AtomicToLength(t1 PASS_REGS); - if (len != (size_t)-1) - ReleaseAndReturn(Yap_unify(ARG2, MkIntegerTerm(len))); + len = Yap_AtomicToUnicodeLength(t1 PASS_REGS); + if (len != (size_t)-1) { + pop_text_stack(l); + return Yap_unify(ARG2, MkIntegerTerm(len)); + }; /* error handling */ if (LOCAL_Error_TYPE && Yap_HandleError("atomic_length/2")) { goto restart_aux; } - ReleaseAndReturn(FALSE); + { + pop_text_stack(l); + return false; + }; } static Int string_length(USES_REGS1) { @@ -1381,29 +1688,41 @@ static Int string_length(USES_REGS1) { if (!IsIntegerTerm(t2)) { Yap_Error(TYPE_ERROR_INTEGER, t2, "string_length/2"); - ReleaseAndReturn(FALSE); + { + pop_text_stack(l); + return false; + }; } if (FALSE && (Int)(len = IntegerOfTerm(t2)) < 0) { Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t2, "string_length/2"); - ReleaseAndReturn(FALSE); + { + pop_text_stack(l); + return false; + }; } } restart_aux: t1 = Deref(ARG1); - len = Yap_AtomicToLength(t1 PASS_REGS); - if (len != (size_t)-1) - ReleaseAndReturn(Yap_unify(ARG2, MkIntegerTerm(len))); + len = Yap_StringToUnicodeLength(t1 PASS_REGS); + if (len != (size_t)-1) { + pop_text_stack(l); + return Yap_unify(ARG2, MkIntegerTerm(len)); + }; /* error handling */ if (LOCAL_Error_TYPE && Yap_HandleError("string_length/2")) { goto restart_aux; } - ReleaseAndReturn(FALSE); + { + pop_text_stack(l); + return false; + }; } /** @pred downcase_text_to_atom(+Text, -Atom) * - * Convert all upper case code-points in text _Text_ to downcase. Unify the - * result as atom _Atom_ with the second argument. + * Convert all upper case code-points in text _Text_ to + * downcase. Unify the result as atom _Atom_ with the second + * argument. * */ static Int downcase_text_to_atom(USES_REGS1) { @@ -1413,13 +1732,19 @@ static Int downcase_text_to_atom(USES_REGS1) { int l = push_text_stack(); if (!Yap_IsGroundTerm(t1)) { Yap_Error(INSTANTIATION_ERROR, t1, "at first argument"); - ReleaseAndReturn(false); + { + pop_text_stack(l); + return false; + }; } if (IsNonVarTerm(t2)) { if (!IsAtomTerm(t2)) { Yap_Error(TYPE_ERROR_ATOM, t2, "at second argument"); - ReleaseAndReturn((FALSE)); + { + pop_text_stack(l); + return (FALSE); + }; } } while (true) { @@ -1427,17 +1752,23 @@ static Int downcase_text_to_atom(USES_REGS1) { if (at == NULL) { if (LOCAL_Error_TYPE && Yap_HandleError("downcase_text_to_atom/2")) continue; - ReleaseAndReturn(false); + + pop_text_stack(l); + return false; } - ReleaseAndReturn(Yap_unify(MkAtomTerm(at), t2)); + + pop_text_stack(l); + return Yap_unify(MkAtomTerm(at), t2); } - ReleaseAndReturn(false); + pop_text_stack(l); + return false; } /** @pred upcase_text_to_atom(+Text, -Atom) * - * Convert all lower case code-points in text _Text_ to up case. Unify the - * result as atom _Atom_ with the second argument. + * Convert all lower case code-points in text _Text_ to up + * case. Unify the result as atom _Atom_ with the second + * argument. * */ static Int upcase_text_to_atom(USES_REGS1) { @@ -1447,13 +1778,19 @@ static Int upcase_text_to_atom(USES_REGS1) { int l = push_text_stack(); if (!Yap_IsGroundTerm(t1)) { Yap_Error(INSTANTIATION_ERROR, t1, "at first argument"); - ReleaseAndReturn(false); + { + pop_text_stack(l); + return false; + }; } if (IsNonVarTerm(t2)) { if (!IsAtomTerm(t2)) { Yap_Error(TYPE_ERROR_ATOM, t2, "at second argument"); - ReleaseAndReturn((FALSE)); + { + pop_text_stack(l); + return (FALSE); + }; } } while (true) { @@ -1461,269 +1798,305 @@ static Int upcase_text_to_atom(USES_REGS1) { if (at == NULL) { if (LOCAL_Error_TYPE && Yap_HandleError("upcase_text_to_atom/2")) continue; - ReleaseAndReturn(false); + { + pop_text_stack(l); + return false; + }; } - ReleaseAndReturn(Yap_unify(MkAtomTerm(at), t2)); + pop_text_stack(l); + return Yap_unify(MkAtomTerm(at), t2); } - ReleaseAndReturn(false); + { + pop_text_stack(l); + return false; + }; } /** @pred downcase_text_to_string(+Text, -String) * - * Convert all upper case code-points in text _Text_ to downcase. Unify the - * result as string _String_ with the second argument. + * Convert all upper case code-points in text _Text_ to + * downcase. Unify the result as string _String_ with the + * second argument. * */ static Int downcase_text_to_string(USES_REGS1) { Term t1 = Deref(ARG1); Term t2 = Deref(ARG2); - int l = push_text_stack(); if (!Yap_IsGroundTerm(t1)) { Yap_Error(INSTANTIATION_ERROR, t1, "at first argument"); - ReleaseAndReturn(false); + return false; } if (IsNonVarTerm(t2)) { if (!IsStringTerm(t2)) { Yap_Error(TYPE_ERROR_STRING, t2, "at second argument"); - ReleaseAndReturn((FALSE)); + return (FALSE); + } + while (true) { + Term t = Yap_AtomicToLowString(t1); + if (t == TermZERO) { + if (LOCAL_Error_TYPE && Yap_HandleError("downcase_text_to_string/2")) + continue; + { return false; }; + } + + return Yap_unify(t, t2); } } - while (true) { - Term t = Yap_AtomicToLowString(t1); - if (t == TermZERO) { - if (LOCAL_Error_TYPE && Yap_HandleError("downcase_text_to_string/2")) - continue; - ReleaseAndReturn(false); - } - ReleaseAndReturn(Yap_unify(t, t2)); - } - ReleaseAndReturn(false); + return false; } /** @pred upcase_text_to_string(+Text, -String) * - * Convert all lower case code-points in text _Text_ to up case. Unify the - * result as string _String_ with the second argument. + * Convert all lower case code-points in text _Text_ to up + * case. Unify the result as string _String_ with the second + * argument. * */ static Int upcase_text_to_string(USES_REGS1) { Term t1 = Deref(ARG1); Term t2 = Deref(ARG2); - int l = push_text_stack(); if (!Yap_IsGroundTerm(t1)) { Yap_Error(INSTANTIATION_ERROR, t1, "at first argument"); - ReleaseAndReturn(false); + return false; } if (IsNonVarTerm(t2)) { if (!IsStringTerm(t2)) { Yap_Error(TYPE_ERROR_STRING, t2, "at second argument"); - ReleaseAndReturn((FALSE)); + return (FALSE); } } + int l = push_text_stack(); while (true) { Term t = Yap_AtomicToUpString(t1); + if (t == TermZERO) { if (LOCAL_Error_TYPE && Yap_HandleError("upcase_text_to_string/2")) continue; - ReleaseAndReturn(false); + + pop_text_stack(l); + + return false; } - ReleaseAndReturn(Yap_unify(t, t2)); + pop_text_stack(l); + return Yap_unify(t, t2); } - ReleaseAndReturn(false); + pop_text_stack(l); + return false; } /** @pred downcase_text_to_codes(+Text, -Codes) * - * Convert all upper case code-points in text _Text_ to downcase. Unify the - * result as a sequence of codes _Codes_ with the second argument. + * Convert all upper case code-points in text _Text_ to + * downcase. Unify the result as a sequence of codes _Codes_ + * with the second argument. * */ static Int downcase_text_to_codes(USES_REGS1) { Term t1 = Deref(ARG1); Term t2 = Deref(ARG2); - int l = push_text_stack(); if (!Yap_IsGroundTerm(t1)) { Yap_Error(INSTANTIATION_ERROR, t1, "at first argument"); - ReleaseAndReturn(false); + return false; } if (IsNonVarTerm(t2)) { if (!Yap_IsListTerm(t2)) { Yap_Error(TYPE_ERROR_LIST, t2, "at second argument"); - ReleaseAndReturn(false); + return false; } } + int l = push_text_stack(); while (true) { Term t = Yap_AtomicToLowListOfCodes(t1); if (t == TermZERO) { if (LOCAL_Error_TYPE && Yap_HandleError("downcase_text_to_codes/2")) continue; - ReleaseAndReturn(false); + pop_text_stack(l); + return false; } - ReleaseAndReturn(Yap_unify(t, t2)); + pop_text_stack(l); + return Yap_unify(t, t2); } - ReleaseAndReturn(false); + pop_text_stack(l); + return false; } /** @pred upcase_text_to_codes(+Text, -Codes) * - * Convert all lower case code-points in text _Text_ to up case. Unify the - * result as a sequence of codes _Codes_ with the second argument. + * Convert all lower case code-points in text _Text_ to up + * case. Unify the result as a sequence of codes _Codes_ with + * the second argument. * */ static Int upcase_text_to_codes(USES_REGS1) { Term t1 = Deref(ARG1); Term t2 = Deref(ARG2); - int l = push_text_stack(); if (!Yap_IsGroundTerm(t1)) { Yap_Error(INSTANTIATION_ERROR, t1, "at first argument"); - ReleaseAndReturn(false); + return false; } if (IsNonVarTerm(t2)) { if (!Yap_IsListTerm(t2)) { Yap_Error(TYPE_ERROR_LIST, t2, "at second argument"); - ReleaseAndReturn((FALSE)); + return (FALSE); } } + int l = push_text_stack(); while (true) { Term t = Yap_AtomicToUpListOfCodes(t1); if (t == TermZERO) { if (LOCAL_Error_TYPE && Yap_HandleError("upcase_text_to_codes/2")) continue; - ReleaseAndReturn(false); + pop_text_stack(l); + return false; } - ReleaseAndReturn(Yap_unify(t, t2)); + pop_text_stack(l); + return Yap_unify(t, t2); } - ReleaseAndReturn(false); + pop_text_stack(l); + return false; } /** @pred downcase_text_to_chars(+Text, -Chars) * - * Convert all upper case code-points in text _Text_ to downcase. Unify the - * result as a sequence of chars _Chars_ with the second argument. + * Convert all upper case code-points in text _Text_ to + * downcase. Unify the result as a sequence of chars _Chars_ + * with the second argument. * */ static Int downcase_text_to_chars(USES_REGS1) { Term t1 = Deref(ARG1); Term t2 = Deref(ARG2); - int l = push_text_stack(); if (!Yap_IsGroundTerm(t1)) { Yap_Error(INSTANTIATION_ERROR, t1, "at first argument"); - ReleaseAndReturn(false); + return false; } if (IsNonVarTerm(t2)) { if (!Yap_IsListTerm(t2)) { Yap_Error(TYPE_ERROR_LIST, t2, "at second argument"); - ReleaseAndReturn(false); + return false; } } + int l = push_text_stack(); while (true) { Term t = Yap_AtomicToLowListOfAtoms(t1); + if (t == TermZERO) { if (LOCAL_Error_TYPE && Yap_HandleError("downcase_text_to_to_chars/2")) continue; - ReleaseAndReturn(false); + pop_text_stack(l); + return false; } - ReleaseAndReturn(Yap_unify(t, t2)); + pop_text_stack(l); + return Yap_unify(t, t2); } - ReleaseAndReturn(false); + pop_text_stack(l); + return false; } /** @pred upcase_text_to_chars(+Text, -Chars) * - * Convert all lower case code-points in text _Text_ to up case. Unify the - * result as a sequence of chars _Chars_ with the second argument. + * Convert all lower case code-points in text _Text_ to up + * case. Unify the result as a sequence of chars _Chars_ with + * the second argument. * */ static Int upcase_text_to_chars(USES_REGS1) { Term t1 = Deref(ARG1); Term t2 = Deref(ARG2); - int l = push_text_stack(); if (!Yap_IsGroundTerm(t1)) { Yap_Error(INSTANTIATION_ERROR, t1, "at first argument"); - ReleaseAndReturn(false); + return false; } if (IsNonVarTerm(t2)) { if (!Yap_IsListTerm(t2)) { Yap_Error(TYPE_ERROR_LIST, t2, "at second argument"); - ReleaseAndReturn((FALSE)); + return (FALSE); } } + int l = push_text_stack(); while (true) { Term t = Yap_AtomicToUpListOfAtoms(t1); if (t == TermZERO) { if (LOCAL_Error_TYPE && Yap_HandleError("upcase_text_to_chars/2")) continue; - ReleaseAndReturn(false); + pop_text_stack(l); + return false; } - ReleaseAndReturn(Yap_unify(t, t2)); + pop_text_stack(l); + return Yap_unify(t, t2); } - ReleaseAndReturn(false); + pop_text_stack(l); + return false; } /* split an atom into two sub-atoms */ static Int atom_split(USES_REGS1) { Term t1 = Deref(ARG1); Term t2 = Deref(ARG2); - size_t len; + size_t u_mid; Term to1, to2; Atom at; - int l = push_text_stack(); if (IsVarTerm(t1)) { Yap_Error(INSTANTIATION_ERROR, t1, "$atom_split/4"); - ReleaseAndReturn((FALSE)); + return (FALSE); } if (!IsAtomTerm(t1)) { Yap_Error(TYPE_ERROR_ATOM, t1, "$atom_split/4"); - ReleaseAndReturn((FALSE)); + return (FALSE); } if (IsVarTerm(t2)) { Yap_Error(INSTANTIATION_ERROR, t2, "$atom_split/4"); - ReleaseAndReturn((FALSE)); + return (FALSE); } if (!IsIntTerm(t2)) { Yap_Error(TYPE_ERROR_INTEGER, t2, "$atom_split/4"); - ReleaseAndReturn((FALSE)); + return (FALSE); } - if ((Int)(len = IntOfTerm(t2)) < 0) { - Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t2, "$atom_split/4"); - ReleaseAndReturn((FALSE)); + if ((Int)(u_mid = IntOfTerm(t2)) < 0) { + Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t2, "atom_split/4"); + return (FALSE); } at = AtomOfTerm(t1); - char *s; - unsigned char *s1, *s10, *s0; - s = RepAtom(at)->StrOfAE; - if (len > strlen(s)) - ReleaseAndReturn((FALSE)); - s1 = s10 = Malloc(len); - s0 = RepAtom(at)->UStrOfAE; - if (s1 + len > (unsigned char *)ASP - 1024) - Yap_Error(RESOURCE_ERROR_STACK, t1, "$atom_split/4"); - size_t j; - for (j = 0; j < len; j++) { - int32_t val; - s0 += get_utf8(s0, 1, &val); - s1 += put_utf8(s1, val); + const char *s = RepAtom(at)->StrOfAE; + const unsigned char *s0 = RepAtom(at)->UStrOfAE; + unsigned char *s1, *s10; + size_t u_len = strlen_utf8(s0); + if (u_mid > u_len) { + return false; } - s1[0] = '\0'; + size_t b_mid = skip_utf8(s0, u_mid) - s0; + s1 = s10 = Malloc(b_mid + 1); + memmove(s1, s, b_mid); + s1[b_mid] = '\0'; to1 = MkAtomTerm(Yap_ULookupAtom(s10)); - to2 = MkAtomTerm(Yap_LookupAtom(s)); - ReleaseAndReturn( - (Yap_unify_constant(ARG3, to1) && Yap_unify_constant(ARG4, to2))); + to2 = MkAtomTerm(Yap_ULookupAtom(s0 + b_mid)); + return Yap_unify_constant(ARG3, to1) && Yap_unify_constant(ARG4, to2); } +/** @pred atom_number(? _Atom_,? _Number_) + + + The predicate holds when at least one of the arguments is + ground (otherwise, an error message will be displayed). If the + argument _Atom_ is an atom, _Number_ must be the number + corresponding to the characters in _Atom_, otherwise the + characters in _Atom_ must encode a number _Number_. + + +*/ static Int atom_number(USES_REGS1) { Term t1; int l = push_text_stack(); @@ -1731,23 +2104,39 @@ restart_aux: t1 = Deref(ARG1); if (Yap_IsGroundTerm(t1)) { Term tf = Yap_AtomToNumber(t1 PASS_REGS); - if (tf) - ReleaseAndReturn(Yap_unify(ARG2, tf)); + if (tf) { + pop_text_stack(l); + return Yap_unify(ARG2, tf); + } } else { /* ARG1 unbound */ Term t = Deref(ARG2); Atom af = Yap_NumberToAtom(t PASS_REGS); - if (af) - ReleaseAndReturn(Yap_unify(ARG1, MkAtomTerm(af))); + if (af) { + pop_text_stack(l); + return Yap_unify(ARG1, MkAtomTerm(af)); + } } /* error handling */ if (LOCAL_Error_TYPE && Yap_HandleError("atom_number/2")) { t1 = Deref(ARG1); goto restart_aux; } - ReleaseAndReturn(FALSE); + pop_text_stack(l); + return false; } +/** @pred atom_number(? _String_,? _Number_) + + + The predicate holds when at least one of the arguments is + ground (otherwise, an error message will be displayed). If the + argument _String_ is a string term, _String_ must be the + number corresponding to the characters in _Atom_, otherwise + the characters in _String_ must encode the number _Number_. + + +*/ static Int string_number(USES_REGS1) { Term t1; int l = push_text_stack(); @@ -1755,21 +2144,28 @@ restart_aux: t1 = Deref(ARG1); if (Yap_IsGroundTerm(t1)) { Term tf = Yap_StringToNumber(t1 PASS_REGS); - if (tf) - ReleaseAndReturn(Yap_unify(ARG2, tf)); + if (tf) { + + pop_text_stack(l); + return Yap_unify(ARG2, tf); + } } else { /* ARG1 unbound */ Term t = Deref(ARG2); Term tf = Yap_NumberToString(t PASS_REGS); - if (tf) - ReleaseAndReturn(Yap_unify(ARG1, tf)); + if (tf) { + pop_text_stack(l); + return Yap_unify(ARG1, tf); + } } + /* error handling */ if (LOCAL_Error_TYPE && Yap_HandleError("string_number/2")) { t1 = Deref(ARG1); goto restart_aux; } - ReleaseAndReturn(FALSE); + pop_text_stack(l); + return false; } #define SUB_ATOM_HAS_MIN 1 @@ -1803,61 +2199,42 @@ static Term build_new_atomic(int mask, const unsigned char *p, size_t minv, outv[n].type = YAP_STRING_ATOM; } else { outv[n].type = YAP_STRING_STRING; - outv[n].val.c = Malloc(512); } - int lvl = push_text_stack(PASS_REGS1); + int l = push_text_stack(); bool rc = Yap_Splice_Text(2 + n, cuts, &inp, outv PASS_REGS); - pop_text_stack(lvl); - if (!rc) + pop_text_stack(l); + if (!rc) { return (false); - if (mask & SUB_ATOM_HAS_ATOM) + } + if (mask & SUB_ATOM_HAS_ATOM) { return (MkAtomTerm(outv[n].val.a)); + } return (outv[n].val.t); } -static int check_sub_atom_at(int minv, Atom at, Atom nat, size_t len) { - const unsigned char *p1; - const unsigned char *p2 = RepAtom(nat)->UStrOfAE; - p1 = skip_utf8(RepAtom(at)->UStrOfAE, minv); - return cmpn_utf8(p1, p2, len) == 0; -} - -static int check_sub_string_at(int minv, const unsigned char *p1, - const unsigned char *p2, size_t len) { +static bool check_sub_string_at(int minv, const unsigned char *p1, + const unsigned char *p2, size_t len) { p1 = skip_utf8((unsigned char *)p1, minv); if (p1 == NULL || p2 == NULL) return p1 == p2; return cmpn_utf8(p1, p2, len) == 0; } -static int check_sub_string_bef(int max, Term at, Term nat) { - size_t len = strlen_utf8(UStringOfTerm(nat)); - int minv = max - len; - const unsigned char *p1, *p2; - int c1; - - if ((Int)(minv - len) < 0) - return FALSE; - - p1 = skip_utf8((unsigned char *)UStringOfTerm(at), minv); - p2 = UStringOfTerm(nat); - while ((c1 = *p1++) == *p2++ && c1) - ; - return c1 == 0; -} - -static int check_sub_atom_bef(int max, Atom at, Atom nat) { - const unsigned char *p1, *p2 = RepAtom(nat)->UStrOfAE; +static bool check_sub_string_bef(int max, const unsigned char *p1, + const unsigned char *p2) { size_t len = strlen_utf8(p2); int minv = max - len; - int c1; + int c2; - if ((Int)(minv - len) < 0) - return false; - p1 = skip_utf8(RepAtom(at)->UStrOfAE, minv); - while ((c1 = *p1++) == *p2++ && c1) + if ((Int)(minv) < 0) + return FALSE; + + p1 = skip_utf8(p1, minv); + if (p1 == NULL || p2 == NULL) + return p1 == p2; + while ((c2 = *p2++) == *p1++ && c2) ; - return c1 == 0; + return c2 == 0; } static Int cont_sub_atomic(USES_REGS1) { @@ -1925,40 +2302,52 @@ static Int cont_sub_atomic(USES_REGS1) { } } else if (mask & SUB_ATOM_HAS_SIZE) { Term nat = build_new_atomic(mask, p, minv, len PASS_REGS); + if (nat == 0) + Yap_ThrowExistingError(); Yap_unify(ARG2, MkIntegerTerm(minv)); Yap_unify(ARG4, MkIntegerTerm(after)); Yap_unify(ARG5, nat); minv++; - if (after-- == 0) + if (after-- == 0) { cut_succeed(); + } } else if (mask & SUB_ATOM_HAS_MIN) { after = sz - (minv + len); Term nat = build_new_atomic(mask, p, minv, len PASS_REGS); + if (nat == 0) + Yap_ThrowExistingError(); Yap_unify(ARG3, MkIntegerTerm(len)); Yap_unify(ARG4, MkIntegerTerm(after)); Yap_unify(ARG5, nat); len++; - if (after-- == 0) + if (after-- == 0) { cut_succeed(); + } } else if (mask & SUB_ATOM_HAS_AFTER) { len = sz - (minv + after); Term nat = build_new_atomic(mask, p, minv, len PASS_REGS); + if (nat == 0) + Yap_ThrowExistingError(); Yap_unify(ARG2, MkIntegerTerm(minv)); Yap_unify(ARG3, MkIntegerTerm(len)); Yap_unify(ARG5, nat); minv++; - if (len-- == 0) + if (len-- == 0) { cut_succeed(); + } } else { Term nat = build_new_atomic(mask, p, minv, len PASS_REGS); + if (nat == 0) + Yap_ThrowExistingError(); Yap_unify(ARG2, MkIntegerTerm(minv)); Yap_unify(ARG3, MkIntegerTerm(len)); Yap_unify(ARG4, MkIntegerTerm(after)); Yap_unify(ARG5, nat); len++; if (after-- == 0) { - if (minv == sz) + if (minv == sz) { cut_succeed(); + } minv++; len = 0; after = sz - minv; @@ -1969,6 +2358,7 @@ static Int cont_sub_atomic(USES_REGS1) { EXTRA_CBACK_ARG(5, 3) = MkIntegerTerm(len); EXTRA_CBACK_ARG(5, 4) = MkIntegerTerm(after); EXTRA_CBACK_ARG(5, 5) = MkIntegerTerm(sz); + return TRUE; } @@ -1979,9 +2369,7 @@ static Int sub_atomic(bool sub_atom, bool sub_string USES_REGS) { const unsigned char *p = NULL; int bnds = 0; Term nat = 0L; - Atom at = NULL; - int l = push_text_stack(); if (sub_atom) mask |= SUB_ATOM_HAS_ATOM; @@ -1994,7 +2382,7 @@ static Int sub_atomic(bool sub_atom, bool sub_string USES_REGS) { sz = strlen_utf8(p); } else { Yap_Error(TYPE_ERROR_ATOM, tat1, "sub_atom/5"); - ReleaseAndReturn(false); + { return false; } } } else if (sub_string) { if (IsStringTerm(tat1)) { @@ -2002,19 +2390,22 @@ static Int sub_atomic(bool sub_atom, bool sub_string USES_REGS) { sz = strlen_utf8(p); } else { Yap_Error(TYPE_ERROR_STRING, tat1, "sub_string/5"); - ReleaseAndReturn(false); + { return false; } } } else { + int l = push_text_stack(); if ((p = Yap_TextToUTF8Buffer(tat1 PASS_REGS))) { + pop_text_stack(l); sz = strlen_utf8(p); } else { - ReleaseAndReturn(false) + pop_text_stack(l); + return false; } } } else { Yap_Error(INSTANTIATION_ERROR, tat1, "sub_atom/5: first variable\n"); - ReleaseAndReturn(false); + return false; } EXTRA_CBACK_ARG(5, 3) = MkIntegerTerm(0); tbef = Deref(ARG2); @@ -2022,12 +2413,12 @@ static Int sub_atomic(bool sub_atom, bool sub_string USES_REGS) { minv = 0; } else if (!IsIntegerTerm(tbef)) { Yap_Error(TYPE_ERROR_INTEGER, tbef, "sub_string/5"); - ReleaseAndReturn(FALSE); + { return false; } } else { minv = IntegerOfTerm(tbef); if ((Int)minv < 0) { Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, tbef, "sub_string/5"); - ReleaseAndReturn(FALSE); + { return false; } }; mask |= SUB_ATOM_HAS_MIN; bnds++; @@ -2036,12 +2427,12 @@ static Int sub_atomic(bool sub_atom, bool sub_string USES_REGS) { len = 0; } else if (!IsIntegerTerm(tsize)) { Yap_Error(TYPE_ERROR_INTEGER, tsize, "sub_string/5"); - ReleaseAndReturn(FALSE); + { return false; } } else { len = IntegerOfTerm(tsize); if ((Int)len < 0) { Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, tsize, "sub_string/5"); - ReleaseAndReturn(FALSE); + { return false; } }; mask |= SUB_ATOM_HAS_SIZE; bnds++; @@ -2050,12 +2441,12 @@ static Int sub_atomic(bool sub_atom, bool sub_string USES_REGS) { after = 0; } else if (!IsIntegerTerm(tafter)) { Yap_Error(TYPE_ERROR_INTEGER, tafter, "sub_string/5"); - ReleaseAndReturn(FALSE); + { return false; } } else { after = IntegerOfTerm(tafter); if ((Int)after < 0) { Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, tafter, "sub_string/5"); - ReleaseAndReturn(FALSE); + { return false; } }; mask |= SUB_ATOM_HAS_AFTER; bnds++; @@ -2064,7 +2455,7 @@ static Int sub_atomic(bool sub_atom, bool sub_string USES_REGS) { if (sub_atom) { if (!IsAtomTerm(tout)) { Yap_Error(TYPE_ERROR_ATOM, tout, "sub_atom/5"); - ReleaseAndReturn(FALSE); + { return false; } } else { Atom oat; mask |= SUB_ATOM_HAS_VAL | SUB_ATOM_HAS_SIZE; @@ -2074,87 +2465,130 @@ static Int sub_atomic(bool sub_atom, bool sub_string USES_REGS) { } else { if (!IsStringTerm(tout)) { Yap_Error(TYPE_ERROR_STRING, tout, "sub_string/5"); - ReleaseAndReturn(FALSE); + { return false; } } else { mask |= SUB_ATOM_HAS_VAL | SUB_ATOM_HAS_SIZE; len = strlen_utf8(UStringOfTerm(tout)); } } - if (!Yap_unify(ARG3, MkIntegerTerm(len))) - release_cut_fail(); + if (!Yap_unify(ARG3, MkIntegerTerm(len))) { + cut_fail(); + } bnds += 2; } /* the problem is deterministic if we have two cases */ if (bnds > 1) { int out = FALSE; - if ((mask & (SUB_ATOM_HAS_MIN | SUB_ATOM_HAS_SIZE)) == - (SUB_ATOM_HAS_MIN | SUB_ATOM_HAS_SIZE)) { - if (minv + len > sz) - release_cut_fail(); - if ((Int)(after = (sz - (minv + len))) < 0) - release_cut_fail(); - nat = build_new_atomic(mask, p, minv, len PASS_REGS); - if (!nat) - release_cut_fail(); - out = Yap_unify(ARG4, MkIntegerTerm(after)) && Yap_unify(ARG5, nat); - } else if ((mask & (SUB_ATOM_HAS_MIN | SUB_ATOM_HAS_AFTER)) == - (SUB_ATOM_HAS_MIN | SUB_ATOM_HAS_AFTER)) { - if (sz < minv + after) - release_cut_fail(); - len = sz - (minv + after); - nat = build_new_atomic(mask, p, minv, len PASS_REGS); - if (!nat) - release_cut_fail(); - out = Yap_unify(ARG3, MkIntegerTerm(len)) && Yap_unify(ARG5, nat); - } else if ((mask & (SUB_ATOM_HAS_SIZE | SUB_ATOM_HAS_AFTER)) == - (SUB_ATOM_HAS_SIZE | SUB_ATOM_HAS_AFTER)) { - if (len + after > sz) - release_cut_fail(); - minv = sz - (len + after); - nat = build_new_atomic(mask, p, minv, len PASS_REGS); - if (!nat) - release_cut_fail(); - out = Yap_unify(ARG2, MkIntegerTerm(minv)) && Yap_unify(ARG5, nat); + if ((mask & (SUB_ATOM_HAS_MIN | SUB_ATOM_HAS_VAL | SUB_ATOM_HAS_AFTER)) == + (SUB_ATOM_HAS_MIN | SUB_ATOM_HAS_VAL | SUB_ATOM_HAS_AFTER)) { + const unsigned char *sm; + if (sub_atom) + sm = RepAtom(AtomOfTerm(tout))->UStrOfAE; + else + sm = UStringOfTerm(tout); + if (mask & SUB_ATOM_HAS_SIZE) { + if (len != strlen_utf8(sm)) { + cut_fail(); + } else { + len = strlen_utf8(sm); + } + } + if (sz != minv + len + after) { + cut_fail(); + } + return do_cut(check_sub_string_at(minv, p, sm, len)); } else if ((mask & (SUB_ATOM_HAS_MIN | SUB_ATOM_HAS_VAL)) == (SUB_ATOM_HAS_MIN | SUB_ATOM_HAS_VAL)) { + if (!Yap_unify(ARG4, MkIntegerTerm(sz - minv - len))) + cut_fail(); if (sub_atom) - out = check_sub_atom_at(minv, at, AtomOfTerm(nat), len); + return do_cut(check_sub_string_at( + minv, p, RepAtom(AtomOfTerm(tout))->UStrOfAE, len)); else - out = check_sub_string_at(minv, p, UStringOfTerm(nat), len); + return do_cut(check_sub_string_at(minv, p, UStringOfTerm(tout), len)); } else if ((mask & (SUB_ATOM_HAS_AFTER | SUB_ATOM_HAS_VAL)) == (SUB_ATOM_HAS_AFTER | SUB_ATOM_HAS_VAL)) { - if (sub_atom) - out = check_sub_atom_bef(sz - after, at, AtomOfTerm(nat)); - else - out = check_sub_string_bef(sz - after, tat1, tout); + if (!Yap_unify(ARG2, MkIntegerTerm(sz - after - len))) + cut_fail(); + if (sub_atom) { + return do_cut(check_sub_string_bef( + sz - after, p, RepAtom(AtomOfTerm(tout))->UStrOfAE)); + } else { + return do_cut(check_sub_string_bef(sz - after, p, UStringOfTerm(tout))); + } + } else if ((mask & (SUB_ATOM_HAS_MIN | SUB_ATOM_HAS_SIZE)) == + (SUB_ATOM_HAS_MIN | SUB_ATOM_HAS_SIZE)) { + if (minv + len + after > sz) { + cut_fail(); + } + if ((Int)(after = (sz - (minv + len))) < 0) { + cut_fail(); + } + nat = build_new_atomic(mask, p, minv, len PASS_REGS); + if (!nat) { + cut_fail(); + } + return do_cut(Yap_unify(ARG4, MkIntegerTerm(after)) && + Yap_unify(ARG5, nat)); + } else if ((mask & (SUB_ATOM_HAS_MIN | SUB_ATOM_HAS_AFTER)) == + (SUB_ATOM_HAS_MIN | SUB_ATOM_HAS_AFTER)) { + if (sz < minv + after) { + cut_fail(); + } + len = sz - (minv + after); + int l = push_text_stack(); + nat = build_new_atomic(mask, p, minv, len PASS_REGS); + pop_text_stack(l); + if (!nat) { + cut_fail(); + } + return do_cut(Yap_unify(ARG3, MkIntegerTerm(len)) && + Yap_unify(ARG5, nat)); + } else if ((mask & (SUB_ATOM_HAS_SIZE | SUB_ATOM_HAS_AFTER)) == + (SUB_ATOM_HAS_SIZE | SUB_ATOM_HAS_AFTER)) { + if (len + after > sz) { + cut_fail(); + } + minv = sz - (len + after); + int l = push_text_stack(); + nat = build_new_atomic(mask, p, minv, len PASS_REGS); + pop_text_stack(l); + if (!nat) { + cut_fail(); + } + return do_cut(Yap_unify(ARG2, MkIntegerTerm(minv)) && + Yap_unify(ARG5, nat)); } else if ((mask & (SUB_ATOM_HAS_SIZE | SUB_ATOM_HAS_VAL)) == (SUB_ATOM_HAS_SIZE | SUB_ATOM_HAS_VAL)) { if (!sub_atom) { out = (strlen_utf8(UStringOfTerm(tout)) == len); - if (!out) - release_cut_fail(); + if (!out) { + cut_fail(); + } } else { out = (strlen(RepAtom(AtomOfTerm(tout))->StrOfAE) == len); - if (!out) - release_cut_fail(); - } - if (len == sz) { - out = out && Yap_unify(ARG1, ARG5) && - Yap_unify(ARG2, MkIntegerTerm(0)) && - Yap_unify(ARG4, MkIntegerTerm(0)); - } else if (len > sz) { - release_cut_fail(); - } else { - mask |= SUB_ATOM_HAS_SIZE; - minv = 0; - after = sz - len; - goto backtrackable; + if (!out) { + cut_fail(); + } + if (len == sz) { + out = out && Yap_unify(ARG1, ARG5) && + Yap_unify(ARG2, MkIntegerTerm(0)) && + Yap_unify(ARG4, MkIntegerTerm(0)); + } else if (len > sz) { + cut_fail(); + } else { + mask |= SUB_ATOM_HAS_SIZE; + minv = 0; + after = sz - len; + goto backtrackable; + } } } - if (out) - release_cut_succeed(); - release_cut_fail(); + if (out) { + cut_succeed(); + } + cut_fail(); } else { if (!(mask & SUB_ATOM_HAS_MIN)) minv = 0; @@ -2169,40 +2603,41 @@ backtrackable: EXTRA_CBACK_ARG(5, 3) = MkIntegerTerm(len); EXTRA_CBACK_ARG(5, 4) = MkIntegerTerm(after); EXTRA_CBACK_ARG(5, 5) = MkIntegerTerm(sz); - ReleaseAndReturn(cont_sub_atomic(PASS_REGS1)); + return cont_sub_atomic(PASS_REGS1); } -/** @pred sub_atom(+ _A_,? _Bef_, ? _Size_, ? _After_, ? _At_out_) is iso +/** @pred sub_atom(+ _A_,? _Bef_, ? _Size_, ? _After_, ? + _At_out_) is iso -True when _A_ and _At_out_ are atoms such that the name of - _At_out_ has size _Size_ and is a sub-string of the name of - _A_, such that _Bef_ is the number of characters before and - _After_ the number of characters afterwards. + True when _A_ and _At_out_ are atoms such that the name of + _At_out_ has size _Size_ and is a sub-string of the name of + _A_, such that _Bef_ is the number of characters before and + _After_ the number of characters afterwards. -Note that _A_ must always be known, but _At_out_ can be unbound when -calling this built-in. If all the arguments for sub_atom/5 but _A_ -are unbound, the built-in will backtrack through all possible -sub-strings of _A_. + Note that _A_ must always be known, but _At_out_ can be + unbound when calling this built-in. If all the arguments for + sub_atom/5 but _A_ are unbound, the built-in will backtrack + through all possible sub-strings of _A_. - */ +*/ static Int sub_atom(USES_REGS1) { return (sub_atomic(true, false PASS_REGS)); } -/** @pred sub_string(+ _S_,? _Bef_, ? _Size_, ? _After_, ? _S_out_) is -iso +/** @pred sub_string(+ _S_,? _Bef_, ? _Size_, ? _After_, ? + _S_out_) is iso -True when _S_ and _S_out_ are strings such that the - _S_out_ has size _Size_ and is a sub-string of - _S_, _Bef_ is the number of characters before, and - _After_ the number of characters afterwards. + True when _S_ and _S_out_ are strings such that the + _S_out_ has size _Size_ and is a sub-string of + _S_, _Bef_ is the number of characters before, and + _After_ the number of characters afterwards. -Note that _S_ must always be known, but _S_out_ can be unbound when -calling this built-in. If all the arguments for sub_string/5 but _S_ -are unbound, the built-in will generate all possible -sub-strings of _S_. + Note that _S_ must always be known, but _S_out_ can be + unbound when calling this built-in. If all the arguments for + sub_string/5 but _S_ are unbound, the built-in will generate + all possible sub-strings of _S_. - */ +*/ static Int sub_string(USES_REGS1) { return sub_atomic(false, true PASS_REGS); } static Int cont_current_atom(USES_REGS1) { @@ -2256,19 +2691,19 @@ static Int cont_current_atom(USES_REGS1) { READ_UNLOCK(ap->ARWLock); } EXTRA_CBACK_ARG(1, 2) = MkIntTerm(i); - return (TRUE); + return true; } else { - return (FALSE); + return false; } } static Int current_atom(USES_REGS1) { /* current_atom(?Atom) - */ + */ Term t1 = Deref(ARG1); if (!IsVarTerm(t1)) { - if (IsAtomTerm(t1)) + if (IsAtomTerm(t1)) { cut_succeed(); - else + } else cut_fail(); } READ_LOCK(HashChain[0].AERWLock); @@ -2297,118 +2732,31 @@ void Yap_InitBackAtoms(void) { void Yap_InitAtomPreds(void) { Yap_InitCPred("name", 2, name, 0); - /** @pred name( _A_, _L_) - - - The predicate holds when at least one of the arguments is ground - (otherwise, an error message will be displayed). The argument _A_ will - be unified with an atomic symbol and _L_ with the list of the ASCII - codes for the characters of the external representation of _A_. - - ~~~~~{.prolog} - name(yap,L). - ~~~~~ - will return: - - ~~~~~{.prolog} - L = [121,97,112]. - ~~~~~ - and - - ~~~~~{.prolog} - name(3,L). - ~~~~~ - will return: - - ~~~~~{.prolog} - L = [51]. - ~~~~~ - - - */ Yap_InitCPred("string_to_atom", 2, string_to_atom, 0); - Yap_InitCPred("atom_string", 2, atom_string, 0); + Yap_InitCPred("atom_to_string", 2, atom_to_string, 0); Yap_InitCPred("string_to_atomic", 2, string_to_atomic, 0); + Yap_InitCPred("atomic_to_string", 2, atomic_to_string, 0); Yap_InitCPred("string_to_list", 2, string_to_list, 0); Yap_InitCPred("char_code", 2, char_code, SafePredFlag); - /** @pred char_code(? _A_,? _I_) is iso - - - The built-in succeeds with _A_ bound to character represented as an - atom, and _I_ bound to the character code represented as an - integer. At least, one of either _A_ or _I_ must be bound before - the call. - - - */ Yap_InitCPred("atom_chars", 2, atom_chars, 0); - /** @pred atom_chars(? _A_,? _L_) is iso - - - The predicate holds when at least one of the arguments is ground - (otherwise, an error message will be displayed). The argument _A_ must - be unifiable with an atom, and the argument _L_ with the list of the - characters of _A_. - - - */ Yap_InitCPred("atom_codes", 2, atom_codes, 0); + Yap_InitCPred("atom_string", 2, atom_string, 0); + Yap_InitCPred("string_atom", 2, string_atom, 0); Yap_InitCPred("string_codes", 2, string_codes, 0); Yap_InitCPred("string_chars", 2, string_chars, 0); Yap_InitCPred("atom_length", 2, atom_length, SafePredFlag); - /** @pred atom_length(+ _A_,? _I_) is iso - - - The predicate holds when the first argument is an atom, and the second - unifies with the number of characters forming that atom. - - - */ Yap_InitCPred("atomic_length", 2, atomic_length, SafePredFlag); Yap_InitCPred("string_length", 2, string_length, SafePredFlag); Yap_InitCPred("$atom_split", 4, atom_split, SafePredFlag); Yap_InitCPred("number_chars", 2, number_chars, 0); Yap_InitCPred("number_atom", 2, number_atom, 0); - /** @pred number_atom(? _I_,? _L_) - - - - The predicate holds when at least one of the arguments is ground - (otherwise, an error message will be displayed). The argument _I_ must - be unifiable with a number, and the argument _L_ must be unifiable - with an atom representing the number. - - - */ Yap_InitCPred("number_string", 2, number_string, 0); Yap_InitCPred("number_codes", 2, number_codes, 0); Yap_InitCPred("atom_number", 2, atom_number, 0); - /** @pred atom_number(? _Atom_,? _Number_) - - - The predicate holds when at least one of the arguments is ground - (otherwise, an error message will be displayed). If the argument - _Atom_ is an atom, _Number_ must be the number corresponding - to the characters in _Atom_, otherwise the characters in - _Atom_ must encode a number _Number_. - - - */ Yap_InitCPred("string_number", 2, string_number, 0); Yap_InitCPred("$atom_concat", 2, atom_concat2, 0); Yap_InitCPred("$string_concat", 2, string_concat2, 0); Yap_InitCPred("atomic_concat", 2, atomic_concat2, 0); - /** @pred atomic_concat(+ _As_,? _A_) - - - The predicate holds when the first argument is a list of atomic terms, - and - the second unifies with the atom obtained by concatenating all the - atomic terms in the first list. The first argument thus may contain - atoms or numbers. - - - */ Yap_InitCPred("atomics_to_string", 2, atomics_to_string2, 0); Yap_InitCPred("atomics_to_string", 3, atomics_to_string3, 0); Yap_InitCPred("get_string_code", 3, get_string_code3, 0); @@ -2417,6 +2765,8 @@ void Yap_InitAtomPreds(void) { Yap_InitCPred("downcase_atom", 2, downcase_text_to_atom, 0); Yap_InitCPred("upcase_text_to_atom", 2, upcase_text_to_atom, 0); Yap_InitCPred("upcase_atom", 2, upcase_text_to_atom, 0); + Yap_InitCPred("text_to_string", 2, downcase_text_to_string, 0); + Yap_InitCPred("text_to_atom", 2, downcase_text_to_string, 0); Yap_InitCPred("downcase_text_to_string", 2, downcase_text_to_string, 0); Yap_InitCPred("upcase_text_to_string", 2, upcase_text_to_string, 0); Yap_InitCPred("downcase_text_to_codes", 2, downcase_text_to_codes, 0); @@ -2433,5 +2783,5 @@ void Yap_InitAtomPreds(void) { } /** -@} + @} */ diff --git a/C/attvar.c b/C/attvar.c index 470d35062..441c27064 100644 --- a/C/attvar.c +++ b/C/attvar.c @@ -8,31 +8,39 @@ * * ************************************************************************** * * - * File: attvar.c * - * Last rev: * - * mods: * - * comments: YAP support for attributed vars * + * File: attvar.c * Last rev: + ** mods: * comments: YAP support for attributed vars * * * *************************************************************************/ #ifdef SCCS static char SccsId[] = "%W% %G%"; #endif +/** + * @file attvar.c + * @author VITOR SANTOS COSTA + * @date Mon Apr 30 09:31:59 2018 + * + * @brief attributed variables + * @namespace prolog + * + */ #include "Yap.h" -#include "Yatom.h" #include "YapHeap.h" -#include "heapgc.h" +#include "Yatom.h" #include "attvar.h" +#include "heapgc.h" #ifndef NULL #define NULL (void *)0 #endif /** - @adefgroup AttributedVariables_Builtins Low-level support for Attributed Variables - + @defgroup AttributedVariables_Builtins Low-level support for Attributed + Variables + @brief Implementation of Attribute Declarations - @ingroup attributes + @ingroup AttributedVariables @{ */ @@ -185,7 +193,7 @@ static void WakeAttVar(CELL *pt1, CELL reg2 USES_REGS) { if (!IsVarTerm(attv->Value) || !IsUnboundVar(&attv->Value)) { /* oops, our goal is on the queue to be woken */ if (!Yap_unify(attv->Value, reg2)) { - AddFailToQueue(PASS_REGS1); + AddFailToQueue(PASS_REGS1); } return; } @@ -202,7 +210,7 @@ static void WakeAttVar(CELL *pt1, CELL reg2 USES_REGS) { void Yap_WakeUp(CELL *pt0) { CACHE_REGS - CELL d0 = *pt0; + CELL d0 = *pt0; RESET_VARIABLE(pt0); WakeAttVar(pt0, d0 PASS_REGS); } @@ -675,7 +683,6 @@ static Int free_att(USES_REGS1) { } } - static Int get_atts(USES_REGS1) { /* receive a variable in ARG1 */ Term inp = Deref(ARG1); @@ -887,7 +894,7 @@ static Term AllAttVars(USES_REGS1) { while (pt < myH) { switch (*pt) { - case (CELL) FunctorAttVar: + case (CELL)FunctorAttVar: if (IsUnboundVar(pt + 1)) { if (ASP - myH < 1024) { LOCAL_Error_Size = (ASP - HR) * sizeof(CELL); @@ -901,24 +908,23 @@ static Term AllAttVars(USES_REGS1) { } pt += (1 + ATT_RECORD_ARITY); break; - case (CELL) FunctorDouble: + case (CELL)FunctorDouble: #if SIZEOF_DOUBLE == 2 * SIZEOF_INT_P pt += 4; #else pt += 3; #endif break; - case (CELL) FunctorString: + case (CELL)FunctorString: pt += 3 + pt[1]; break; - case (CELL) FunctorBigInt: { - Int sz = 3 + - (sizeof(MP_INT) + - (((MP_INT *)(pt + 2))->_mp_alloc * sizeof(mp_limb_t))) / - sizeof(CELL); + case (CELL)FunctorBigInt: { + Int sz = 3 + (sizeof(MP_INT) + + (((MP_INT *)(pt + 2))->_mp_alloc * sizeof(mp_limb_t))) / + sizeof(CELL); pt += sz; } break; - case (CELL) FunctorLongInt: + case (CELL)FunctorLongInt: pt += 3; break; default: @@ -967,7 +973,7 @@ static Int is_attvar(USES_REGS1) { static Int attvar_bound(USES_REGS1) { Term t = Deref(ARG1); return IsVarTerm(t) && IsAttachedTerm(t) && - !IsUnboundVar(&(RepAttVar(VarOfTerm(t))->Done)); + !IsUnboundVar(&(RepAttVar(VarOfTerm(t))->Done)); } static Int void_term(USES_REGS1) { return Yap_unify(ARG1, TermVoidAtt); } @@ -1007,7 +1013,7 @@ static Int attvar_bound(USES_REGS1) { return FALSE; } void Yap_InitAttVarPreds(void) { CACHE_REGS - Term OldCurrentModule = CurrentModule; + Term OldCurrentModule = CurrentModule; CurrentModule = ATTRIBUTES_MODULE; #ifdef COROUTINING GLOBAL_attas[attvars_ext].bind_op = WakeAttVar; @@ -1029,8 +1035,7 @@ void Yap_InitAttVarPreds(void) { Yap_InitCPred("rm_att", 4, rm_att, 0); Yap_InitCPred("bind_attvar", 1, bind_attvar, SafePredFlag); Yap_InitCPred("unbind_attvar", 1, unbind_attvar, SafePredFlag); - Yap_InitCPred("modules_with_attributes", 2, modules_with_atts, - SafePredFlag); + Yap_InitCPred("modules_with_attributes", 2, modules_with_atts, SafePredFlag); Yap_InitCPred("void_term", 1, void_term, SafePredFlag); Yap_InitCPred("free_term", 1, free_term, SafePredFlag); Yap_InitCPred("fast_unify_attributed", 2, fast_unify, 0); diff --git a/C/bb.c b/C/bb.c index 37ca03b72..18a8b8fb2 100644 --- a/C/bb.c +++ b/C/bb.c @@ -18,6 +18,17 @@ static char SccsId[] = "%W% %G%"; #endif +/** + * @file bb.c + * @author VITOR SANTOS COSTA + * @date Mon Apr 30 09:32:54 2018 + * + * @brief blackboard + * + * @namespace prolog + * + */ + /** @defgroup BlackBoard The Blackboard @ingroup builtins diff --git a/C/bignum.c b/C/bignum.c index 3da5acf1d..ab9681a4e 100644 --- a/C/bignum.c +++ b/C/bignum.c @@ -1,22 +1,33 @@ /************************************************************************* -* * -* YAP Prolog * -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * -* * -************************************************************************** -* * -* File: arith1.c * -* Last rev: * -* mods: * -* comments: bignum support through gmp * -* * -*************************************************************************/ + * * + * YAP Prolog * + * * + * Yap Prolog was developed at NCCUP - Universidade do Porto * + * * + * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * + * * + ************************************************************************** + * * + * File: arith1.c * + * Last rev: * + * mods: * + * comments: bignum support through gmp * + * * + *************************************************************************/ #ifdef SCCS -static char SccsId[] = "%W% %G%"; +static char SccsId[] = "%W% %G%"; #endif +/** + * @file bignum.c + * @author VITOR SANTOS COSTA + * @date Mon Apr 30 09:34:59 2018 + * + * @brief BigNums and More + * @namespace prolog + * + * + * + */ #include "Yap.h" #include "Yatom.h" @@ -33,12 +44,10 @@ static char SccsId[] = "%W% %G%"; #include "YapEval.h" #include "alloc.h" -Term -Yap_MkBigIntTerm(MP_INT *big) -{ +Term Yap_MkBigIntTerm(MP_INT *big) { CACHE_REGS Int nlimbs; - MP_INT *dst = (MP_INT *)(HR+2); + MP_INT *dst = (MP_INT *)(HR + 2); CELL *ret = HR; Int bytes; @@ -50,38 +59,33 @@ Yap_MkBigIntTerm(MP_INT *big) // nlimbs = ALIGN_YAPTYPE(bytes,CELL)/CellSize; // this works, but it shouldn't need to do this... nlimbs = big->_mp_alloc; - bytes = nlimbs*sizeof(CELL); - if (nlimbs > (ASP-ret)-1024) { + bytes = nlimbs * sizeof(CELL); + if (nlimbs > (ASP - ret) - 1024) { return TermNil; } HR[0] = (CELL)FunctorBigInt; HR[1] = BIG_INT; dst->_mp_size = big->_mp_size; - dst->_mp_alloc = nlimbs*(CellSize/sizeof(mp_limb_t)); - memmove((void *)(dst+1), (const void *)(big->_mp_d), bytes); - HR = (CELL *)(dst+1)+nlimbs; + dst->_mp_alloc = nlimbs * (CellSize / sizeof(mp_limb_t)); + memmove((void *)(dst + 1), (const void *)(big->_mp_d), bytes); + HR = (CELL *)(dst + 1) + nlimbs; HR[0] = EndSpecials; HR++; return AbsAppl(ret); } +MP_INT *Yap_BigIntOfTerm(Term t) { + MP_INT *new = (MP_INT *)(RepAppl(t) + 2); -MP_INT * -Yap_BigIntOfTerm(Term t) -{ - MP_INT *new = (MP_INT *)(RepAppl(t)+2); - - new->_mp_d = (mp_limb_t *)(new+1); - return(new); + new->_mp_d = (mp_limb_t *)(new + 1); + return (new); } -Term -Yap_MkBigRatTerm(MP_RAT *big) -{ +Term Yap_MkBigRatTerm(MP_RAT *big) { CACHE_REGS Int nlimbs; - MP_INT *dst = (MP_INT *)(HR+2); + MP_INT *dst = (MP_INT *)(HR + 2); MP_INT *num = mpq_numref(big); MP_INT *den = mpq_denref(big); MP_RAT *rat; @@ -89,84 +93,78 @@ Yap_MkBigRatTerm(MP_RAT *big) if (mpz_cmp_si(den, 1) == 0) return Yap_MkBigIntTerm(num); - if ((num->_mp_alloc+den->_mp_alloc)*(sizeof(mp_limb_t)/CellSize) > (ASP-ret)-1024) { + if ((num->_mp_alloc + den->_mp_alloc) * (sizeof(mp_limb_t) / CellSize) > + (ASP - ret) - 1024) { return TermNil; } HR[0] = (CELL)FunctorBigInt; HR[1] = BIG_RATIONAL; dst->_mp_size = 0; - rat = (MP_RAT *)(dst+1); + rat = (MP_RAT *)(dst + 1); rat->_mp_num._mp_size = num->_mp_size; rat->_mp_num._mp_alloc = num->_mp_alloc; - nlimbs = (num->_mp_alloc)*(sizeof(mp_limb_t)/CellSize); - memmove((void *)(rat+1), (const void *)(num->_mp_d), nlimbs*CellSize); + nlimbs = (num->_mp_alloc) * (sizeof(mp_limb_t) / CellSize); + memmove((void *)(rat + 1), (const void *)(num->_mp_d), nlimbs * CellSize); rat->_mp_den._mp_size = den->_mp_size; rat->_mp_den._mp_alloc = den->_mp_alloc; - HR = (CELL *)(rat+1)+nlimbs; - nlimbs = (den->_mp_alloc)*(sizeof(mp_limb_t)/CellSize); - memmove((void *)(HR), (const void *)(den->_mp_d), nlimbs*CellSize); + HR = (CELL *)(rat + 1) + nlimbs; + nlimbs = (den->_mp_alloc) * (sizeof(mp_limb_t) / CellSize); + memmove((void *)(HR), (const void *)(den->_mp_d), nlimbs * CellSize); HR += nlimbs; - dst->_mp_alloc = (HR-(CELL *)(dst+1)); + dst->_mp_alloc = (HR - (CELL *)(dst + 1)); HR[0] = EndSpecials; HR++; return AbsAppl(ret); } -MP_RAT * -Yap_BigRatOfTerm(Term t) -{ - MP_RAT *new = (MP_RAT *)(RepAppl(t)+2+sizeof(MP_INT)/sizeof(CELL)); +MP_RAT *Yap_BigRatOfTerm(Term t) { + MP_RAT *new = (MP_RAT *)(RepAppl(t) + 2 + sizeof(MP_INT) / sizeof(CELL)); mp_limb_t *nt; - nt = new->_mp_num._mp_d = (mp_limb_t *)(new+1); + nt = new->_mp_num._mp_d = (mp_limb_t *)(new + 1); nt += new->_mp_num._mp_alloc; new->_mp_den._mp_d = nt; return new; } -Term -Yap_RatTermToApplTerm(Term t) -{ +Term Yap_RatTermToApplTerm(Term t) { Term ts[2]; MP_RAT *rat = Yap_BigRatOfTerm(t); - ts[0] = Yap_MkBigIntTerm(mpq_numref(rat)); - ts[1] = Yap_MkBigIntTerm(mpq_denref(rat)); - return Yap_MkApplTerm(FunctorRDiv,2,ts); + ts[0] = Yap_MkBigIntTerm(mpq_numref(rat)); + ts[1] = Yap_MkBigIntTerm(mpq_denref(rat)); + return Yap_MkApplTerm(FunctorRDiv, 2, ts); } #endif -Term -Yap_AllocExternalDataInStack(CELL tag, size_t bytes) -{ +Term Yap_AllocExternalDataInStack(CELL tag, size_t bytes, void *pt) { CACHE_REGS Int nlimbs; - MP_INT *dst = (MP_INT *)(HR+2); + MP_INT *dst = (MP_INT *)(HR + 2); CELL *ret = HR; - - nlimbs = ALIGN_BY_TYPE(bytes,CELL)/CellSize; - if (nlimbs > (ASP-ret)-1024) { + CELL **blobp; + + nlimbs = ALIGN_BY_TYPE(bytes, CELL) / CellSize; + if (nlimbs > (ASP - ret) - 1024) { return TermNil; } HR[0] = (CELL)FunctorBigInt; HR[1] = tag; dst->_mp_size = 0; dst->_mp_alloc = nlimbs; - HR = (CELL *)(dst+1)+nlimbs; + HR = (CELL *)(dst + 1) + nlimbs; HR[0] = EndSpecials; HR++; - if (tag != EXTERNAL_BLOB) { - TrailTerm(TR) = AbsPair(ret); - TR++; - } + blobp = (CELL **)pt; + *blobp = (CELL *)(dst + 1); return AbsAppl(ret); } -int Yap_CleanOpaqueVariable(CELL *pt) -{ +int Yap_CleanOpaqueVariable(CELL d) { CELL blob_info, blob_tag; - MP_INT *blobp; + + CELL *pt = RepAppl(HeadOfTerm(d)); #ifdef DEBUG /* sanity checking */ if (pt[0] != (CELL)FunctorBigInt) { @@ -175,23 +173,20 @@ int Yap_CleanOpaqueVariable(CELL *pt) } #endif blob_tag = pt[1]; - if (blob_tag < USER_BLOB_START || - blob_tag >= USER_BLOB_END) { - Yap_Error(SYSTEM_ERROR_INTERNAL, AbsAppl(pt), "clean opaque: bad blob with tag " UInt_FORMAT ,blob_tag); + if (blob_tag < USER_BLOB_START || blob_tag >= USER_BLOB_END) { + Yap_Error(SYSTEM_ERROR_INTERNAL, AbsAppl(pt), + "clean opaque: bad blob with tag " UInt_FORMAT, blob_tag); return FALSE; } - blob_info = blob_tag - USER_BLOB_START; + blob_info = blob_tag; if (!GLOBAL_OpaqueHandlers) - return FALSE; - blobp = (MP_INT *)(pt+2); + return false; if (!GLOBAL_OpaqueHandlers[blob_info].fail_handler) - return TRUE; - return (GLOBAL_OpaqueHandlers[blob_info].fail_handler)((void *)(blobp+1)); + return true; + return (GLOBAL_OpaqueHandlers[blob_info].fail_handler)(d); } -Opaque_CallOnWrite -Yap_blob_write_handler(Term t) -{ +YAP_Opaque_CallOnWrite Yap_blob_write_handler(Term t) { CELL blob_info, blob_tag; CELL *pt = RepAppl(t); @@ -203,21 +198,19 @@ Yap_blob_write_handler(Term t) } #endif blob_tag = pt[1]; - if (blob_tag < USER_BLOB_START || - blob_tag >= USER_BLOB_END) { - Yap_Error(SYSTEM_ERROR_INTERNAL, AbsAppl(pt), "clean opaque: bad blob with tag " UInt_FORMAT ,blob_tag); + if (blob_tag < USER_BLOB_START || blob_tag >= USER_BLOB_END) { + Yap_Error(SYSTEM_ERROR_INTERNAL, AbsAppl(pt), + "clean opaque: bad blob with tag " UInt_FORMAT, blob_tag); return FALSE; } - blob_info = blob_tag - USER_BLOB_START; + blob_info = blob_tag; if (!GLOBAL_OpaqueHandlers) { return NULL; } return GLOBAL_OpaqueHandlers[blob_info].write_handler; } -Opaque_CallOnGCMark -Yap_blob_gc_mark_handler(Term t) -{ +YAP_Opaque_CallOnGCMark Yap_blob_gc_mark_handler(Term t) { CELL blob_info, blob_tag; CELL *pt = RepAppl(t); @@ -229,19 +222,16 @@ Yap_blob_gc_mark_handler(Term t) } #endif blob_tag = pt[1]; - if (blob_tag < USER_BLOB_START || - blob_tag >= USER_BLOB_END) { + if (blob_tag < USER_BLOB_START || blob_tag >= USER_BLOB_END) { return NULL; } - blob_info = blob_tag - USER_BLOB_START; + blob_info = blob_tag; if (!GLOBAL_OpaqueHandlers) return NULL; - return GLOBAL_OpaqueHandlers[blob_info].gc_mark_handler; + return GLOBAL_OpaqueHandlers[blob_info].mark_handler; } -Opaque_CallOnGCRelocate -Yap_blob_gc_relocate_handler(Term t) -{ +YAP_Opaque_CallOnGCRelocate Yap_blob_gc_relocate_handler(Term t) { CELL blob_info, blob_tag; CELL *pt = RepAppl(t); @@ -253,19 +243,18 @@ Yap_blob_gc_relocate_handler(Term t) } #endif blob_tag = pt[1]; - if (blob_tag < USER_BLOB_START || - blob_tag >= USER_BLOB_END) { - Yap_Error(SYSTEM_ERROR_INTERNAL, AbsAppl(pt), "clean opaque: bad blob with tag " UInt_FORMAT ,blob_tag); + if (blob_tag < USER_BLOB_START || blob_tag >= USER_BLOB_END) { + Yap_Error(SYSTEM_ERROR_INTERNAL, AbsAppl(pt), + "clean opaque: bad blob with tag " UInt_FORMAT, blob_tag); return FALSE; } - blob_info = blob_tag - USER_BLOB_START; + blob_info = blob_tag; if (!GLOBAL_OpaqueHandlers) return NULL; - return GLOBAL_OpaqueHandlers[blob_info].gc_relocate_handler; + return GLOBAL_OpaqueHandlers[blob_info].relocate_handler; } -extern Int Yap_blob_tag(Term t) -{ +extern Int Yap_blob_tag(Term t) { CELL *pt = RepAppl(t); #ifdef DEBUG @@ -278,9 +267,7 @@ extern Int Yap_blob_tag(Term t) return pt[1]; } -void * -Yap_blob_info(Term t) -{ +void *Yap_blob_info(Term t) { MP_INT *blobp; CELL *pt = RepAppl(t); @@ -293,88 +280,83 @@ Yap_blob_info(Term t) #endif if (!GLOBAL_OpaqueHandlers) return FALSE; - blobp = (MP_INT *)(pt+2); - return (void *)(blobp+1); + blobp = (MP_INT *)(pt + 2); + return (void *)(blobp + 1); } -Term -Yap_MkULLIntTerm(YAP_ULONG_LONG n) -{ +Term Yap_MkULLIntTerm(YAP_ULONG_LONG n) { #if __GNUC__ && USE_GMP - mpz_t new; - char tmp[256]; - Term t; + mpz_t new; + char tmp[256]; + Term t; #ifdef _WIN32 - snprintf(tmp,256,"%I64u",n); + snprintf(tmp, 256, "%I64u", n); #elif HAVE_SNPRINTF - snprintf(tmp,256,"%llu",n); + snprintf(tmp, 256, "%llu", n); #else - sprintf(tmp,"%llu",n); + sprintf(tmp, "%llu", n); #endif - /* try to scan it as a bignum */ - mpz_init_set_str (new, tmp, 10); - if (mpz_fits_slong_p(new)) { - CACHE_REGS - return MkIntegerTerm(mpz_get_si(new)); - } - t = Yap_MkBigIntTerm(new); - mpz_clear(new); - return t; -#else + /* try to scan it as a bignum */ + mpz_init_set_str(new, tmp, 10); + if (mpz_fits_slong_p(new)) { CACHE_REGS - return MkIntegerTerm(n); + return MkIntegerTerm(mpz_get_si(new)); + } + t = Yap_MkBigIntTerm(new); + mpz_clear(new); + return t; +#else + CACHE_REGS + return MkIntegerTerm(n); #endif } -CELL * -Yap_HeapStoreOpaqueTerm(Term t) -{ +CELL *Yap_HeapStoreOpaqueTerm(Term t) { CELL *ptr = RepAppl(t); size_t sz; void *new; if (ptr[0] == (CELL)FunctorBigInt) { - sz = sizeof(MP_INT)+2*CellSize+ - ((MP_INT *)(ptr+2))->_mp_alloc*sizeof(mp_limb_t); + sz = sizeof(MP_INT) + 2 * CellSize + + ((MP_INT *)(ptr + 2))->_mp_alloc * sizeof(mp_limb_t); } else { /* string */ - sz = sizeof(CELL)*(2+ptr[1]); + sz = sizeof(CELL) * (2 + ptr[1]); } new = Yap_AllocCodeSpace(sz); if (!new) { - Yap_Error(RESOURCE_ERROR_HEAP, TermNil, "subgoal_search_loop: no space for %s", StringOfTerm(t) ); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, + "subgoal_search_loop: no space for %s", StringOfTerm(t)); } else { if (ptr[0] == (CELL)FunctorBigInt) { - MP_INT *new = (MP_INT *)(RepAppl(t)+2); + MP_INT *new = (MP_INT *)(RepAppl(t) + 2); - new->_mp_d = (mp_limb_t *)(new+1); + new->_mp_d = (mp_limb_t *)(new + 1); } memmove(new, ptr, sz); } return new; } - -size_t -Yap_OpaqueTermToString(Term t, char *str, size_t max) -{ +size_t Yap_OpaqueTermToString(Term t, char *str, size_t max) { size_t str_index = 0; - CELL * li = RepAppl(t); + CELL *li = RepAppl(t); unsigned char *ptr = (unsigned char *)StringOfTerm(AbsAppl(li)); if (li[0] == (CELL)FunctorString) { - str_index += sprintf(& str[str_index], "\""); + str_index += sprintf(&str[str_index], "\""); do { utf8proc_int32_t chr; - ptr += get_utf8(ptr, -1, &chr); - if (chr == '\0') break; - str_index += sprintf(str+str_index, "%C", chr); + ptr += get_utf8(ptr, -1, &chr); + if (chr == '\0') + break; + str_index += sprintf(str + str_index, "%C", chr); } while (TRUE); - str_index += sprintf(str+str_index, "\""); + str_index += sprintf(str + str_index, "\""); } else { CELL big_tag = li[1]; if (big_tag == ARRAY_INT || big_tag == ARRAY_FLOAT) { - str_index += sprintf(& str[str_index], "{...}"); + str_index += sprintf(&str[str_index], "{...}"); #ifdef USE_GMP } else if (big_tag == BIG_INT) { MP_INT *big = Yap_BigIntOfTerm(AbsAppl(li)); @@ -398,52 +380,35 @@ Yap_OpaqueTermToString(Term t, char *str, size_t max) return; } } */ - str_index += sprintf(& str[str_index], "0"); + str_index += sprintf(&str[str_index], "0"); } return str_index; } -static Int -p_is_bignum( USES_REGS1 ) -{ +static Int p_is_bignum(USES_REGS1) { #ifdef USE_GMP Term t = Deref(ARG1); - return( - IsNonVarTerm(t) && - IsApplTerm(t) && - FunctorOfTerm(t) == FunctorBigInt && - RepAppl(t)[1] == BIG_INT - ); + return (IsNonVarTerm(t) && IsApplTerm(t) && + FunctorOfTerm(t) == FunctorBigInt && RepAppl(t)[1] == BIG_INT); #else return FALSE; #endif } -static Int -p_is_string( USES_REGS1 ) -{ +static Int p_is_string(USES_REGS1) { Term t = Deref(ARG1); - return( - IsNonVarTerm(t) && - IsApplTerm(t) && - FunctorOfTerm(t) == FunctorString - ); + return (IsNonVarTerm(t) && IsApplTerm(t) && + FunctorOfTerm(t) == FunctorString); } -static Int -p_nb_set_bit( USES_REGS1 ) -{ +static Int p_nb_set_bit(USES_REGS1) { #ifdef USE_GMP Term t = Deref(ARG1); Term ti = Deref(ARG2); Int i; - if (!( - IsNonVarTerm(t) && - IsApplTerm(t) && - FunctorOfTerm(t) == FunctorBigInt && - RepAppl(t)[1] == BIG_INT - )) + if (!(IsNonVarTerm(t) && IsApplTerm(t) && FunctorOfTerm(t) == FunctorBigInt && + RepAppl(t)[1] == BIG_INT)) return FALSE; if (!IsIntegerTerm(ti)) { return FALSE; @@ -462,9 +427,7 @@ p_nb_set_bit( USES_REGS1 ) #endif } -static Int -p_has_bignums( USES_REGS1 ) -{ +static Int p_has_bignums(USES_REGS1) { #ifdef USE_GMP return TRUE; #else @@ -472,9 +435,7 @@ p_has_bignums( USES_REGS1 ) #endif } -static Int -p_is_opaque( USES_REGS1 ) -{ +static Int p_is_opaque(USES_REGS1) { Term t = Deref(ARG1); if (IsVarTerm(t)) return FALSE; @@ -485,14 +446,16 @@ p_is_opaque( USES_REGS1 ) if (f != FunctorBigInt) return FALSE; pt = RepAppl(t); - return ( pt[1] != BIG_RATIONAL || pt[1] != BIG_INT ); + return (pt[1] != BIG_RATIONAL || pt[1] != BIG_INT); } return FALSE; } -static Int -p_is_rational( USES_REGS1 ) -{ + /** @pred rational( ?:T ) + + Checks whether _T_ is a rational number. + */ + static Int p_is_rational(USES_REGS1) { Term t = Deref(ARG1); if (IsVarTerm(t)) return FALSE; @@ -507,14 +470,12 @@ p_is_rational( USES_REGS1 ) if (f != FunctorBigInt) return FALSE; pt = RepAppl(t); - return ( pt[1] == BIG_RATIONAL || pt[1] == BIG_INT ); + return (pt[1] == BIG_RATIONAL || pt[1] == BIG_INT); } return FALSE; } -static Int -p_rational( USES_REGS1 ) -{ +static Int p_rational(USES_REGS1) { #ifdef USE_GMP Term t = Deref(ARG1); Functor f; @@ -534,37 +495,25 @@ p_rational( USES_REGS1 ) return FALSE; rat = Yap_BigRatOfTerm(t); while ((t1 = Yap_MkBigIntTerm(mpq_numref(rat))) == TermNil || - (t2 = Yap_MkBigIntTerm(mpq_denref(rat))) == TermNil) { - UInt size = - (mpq_numref(rat)->_mp_alloc)*(sizeof(mp_limb_t)/CellSize) + - (mpq_denref(rat)->_mp_alloc)*(sizeof(mp_limb_t)/CellSize); + (t2 = Yap_MkBigIntTerm(mpq_denref(rat))) == TermNil) { + UInt size = (mpq_numref(rat)->_mp_alloc) * (sizeof(mp_limb_t) / CellSize) + + (mpq_denref(rat)->_mp_alloc) * (sizeof(mp_limb_t) / CellSize); if (!Yap_gcl(size, 3, ENV, P)) { Yap_Error(RESOURCE_ERROR_STACK, t, LOCAL_ErrorMessage); return FALSE; } } - return - Yap_unify(ARG2, t1) && - Yap_unify(ARG3, t2); + return Yap_unify(ARG2, t1) && Yap_unify(ARG3, t2); #else return FALSE; #endif } -void -Yap_InitBigNums(void) -{ +void Yap_InitBigNums(void) { Yap_InitCPred("$has_bignums", 0, p_has_bignums, SafePredFlag); Yap_InitCPred("$bignum", 1, p_is_bignum, SafePredFlag); Yap_InitCPred("rational", 3, p_rational, 0); Yap_InitCPred("rational", 1, p_is_rational, SafePredFlag); -/** @pred rational( _T_) - - -Checks whether `T` is a rational number. - - -*/ Yap_InitCPred("string", 1, p_is_string, SafePredFlag); Yap_InitCPred("opaque", 1, p_is_opaque, SafePredFlag); Yap_InitCPred("nb_set_bit", 2, p_nb_set_bit, SafePredFlag); diff --git a/C/blobs.c b/C/blobs.c index 7a5b3b5dc..69bcb642c 100644 --- a/C/blobs.c +++ b/C/blobs.c @@ -17,11 +17,7 @@ /* for freeBSD9.1 */ #define _WITH_DPRINTF -#ifdef __APPLE__ -#include "fmemopen.h" -#endif - -#include "blobs.h" +#include "YapBlobs.h" static blob_type_t unregistered_blob_atom = { YAP_BLOB_MAGIC_B, PL_BLOB_NOCOPY | PL_BLOB_TEXT, "unregistered"}; @@ -52,7 +48,7 @@ char *Yap_blob_to_string(AtomEntry *ref, const char *s0, size_t sz) { size_t sz0 = strlcpy(s, (char *)RepAtom(AtomSWIStream)->StrOfAE, sz); #else size_t sz0; - char *f = (char *)memcpy(s, (char *)RepAtom(AtomSWIStream)->StrOfAE, sz); + char *f = (char *)memmove(s, (char *)RepAtom(AtomSWIStream)->StrOfAE, sz); f[0] = '\0'; sz0 = f - s; #endif @@ -160,7 +156,7 @@ AtomEntry *Yap_lookupBlob(void *blob, size_t len, void *type0, int *new) { ae->PropsOfAE = AbsBlobProp(b); ae->NextOfAE = AbsAtom(Blobs); ae->rep.blob->length = len; - memcpy(ae->rep.blob->data, blob, len); + memmove(ae->rep.blob->data, blob, len); Blobs = ae; if (NOfBlobs > NOfBlobsMax) { Yap_signal(YAP_CDOVF_SIGNAL); @@ -209,8 +205,8 @@ bool YAP_get_blob(Term t, void **blob, size_t *len, blob_type_t **type) { return TRUE; } -void *YAP_blob_data(Atom x, size_t *len, blob_type_t **type) { - +void *YAP_blob_data(YAP_Atom at, size_t *len, blob_type_t **type) { +Atom x = at; if (!IsBlob(x)) { if (len) diff --git a/C/c_interface.c b/C/c_interface.c index a535cb95f..85ce12a72 100755 --- a/C/c_interface.c +++ b/C/c_interface.c @@ -19,19 +19,22 @@ /** * @file c_interface.c * - * @addtogroup ChYInterface -*/ + * @addtogroup ChYInterface + */ #ifndef C_INTERFACE_C #define C_INTERFACE_C 1 +#define _EXPORT_KERNEL 1 #include + #if HAVE_UNISTD_H #include #endif -#include + #include + #if HAVE_STDARG_H #include #endif @@ -47,17 +50,24 @@ #include "attvar.h" #include "clause.h" #include "yapio.h" + #ifdef TABLING + #include "tab.macros.h" + #endif /* TABLING */ #ifdef YAPOR #include "or.macros.h" #endif /* YAPOR */ + #include "cut_c.h" -#include "threads.h" + #if HAVE_MALLOC_H + #include + #endif + #include "iopreds.h" #include @@ -76,7 +86,9 @@ struct foreign_context { struct PL_local_data *engine; /* invoking engine */ }; -X_API int YAP_Reset(yap_reset_t mode); +X_API bool python_in_python; + +X_API int YAP_Reset(yap_reset_t mode, bool reset_global); #if !HAVE_STRNCPY #define strncpy(X, Y, Z) strcpy(X, Y) @@ -93,7 +105,6 @@ X_API int YAP_Reset(yap_reset_t mode); #if __ANDROID__ #define BOOT_FROM_SAVED_STATE true #endif -static char BootFile[] = "boot.yap"; /** @defgroup slotInterface Term Handles or Slots @@ -129,7 +140,8 @@ X_API yhandle_t YAP_CurrentSlot(void); /// @brief allocate n empty new slots /// -/// Return a handle to the system's default slo t. iX_API yhandle_t YAP_NewSlots(int NumberOfSlots); +/// Return a handle to the system's default slo t. +/// iX_API yhandle_t YAP_NewSlots(int NumberOfSlots); /// @brief allocate n empty new slots /// @@ -206,6 +218,11 @@ X_API YAP_Term YAP_A(int i) { return (Deref(XREGS[i])); } +X_API YAP_Term YAP_SetA(int i, YAP_Term t) { + CACHE_REGS + return (Deref(XREGS[i])); +} + X_API YAP_Bool YAP_IsIntTerm(YAP_Term t) { return IsIntegerTerm(t); } X_API YAP_Bool YAP_IsNumberTerm(YAP_Term t) { @@ -285,6 +302,16 @@ X_API Term YAP_MkStringTerm(const char *n) { return I; } +X_API Term YAP_MkCharPTerm(char *n) { + CACHE_REGS + Term I; + BACKUP_H(); + + I = MkStringTerm(n); + RECOVER_H(); + return I; +} + X_API Term YAP_MkUnsignedStringTerm(const unsigned char *n) { CACHE_REGS Term I; @@ -313,7 +340,7 @@ X_API Term YAP_MkBigNumTerm(void *big) { #if USE_GMP Term I; BACKUP_H(); - I = Yap_MkBigIntTerm((MP_INT *)big); + I = Yap_MkBigIntTerm(big); RECOVER_H(); return I; #else @@ -413,16 +440,16 @@ X_API Term YAP_MkFloatTerm(double n) { X_API YAP_Float YAP_FloatOfTerm(YAP_Term t) { return (FloatOfTerm(t)); } -X_API Term YAP_MkAtomTerm(Atom n) { +X_API Term YAP_MkAtomTerm(YAP_Atom n) { Term t; t = MkAtomTerm(n); return t; } -X_API Atom YAP_AtomOfTerm(Term t) { return (AtomOfTerm(t)); } +X_API YAP_Atom YAP_AtomOfTerm(Term t) { return (AtomOfTerm(t)); } -X_API bool YAP_IsWideAtom(Atom a) { +X_API bool YAP_IsWideAtom(YAP_Atom a) { const unsigned char *s = RepAtom(a)->UStrOfAE; int32_t v; while (*s) { @@ -433,14 +460,14 @@ X_API bool YAP_IsWideAtom(Atom a) { return false; } -X_API const char *YAP_AtomName(Atom a) { +X_API const char *YAP_AtomName(YAP_Atom a) { const char *o; o = AtomName(a); return (o); } -X_API const wchar_t *YAP_WideAtomName(Atom a) { +X_API const wchar_t *YAP_WideAtomName(YAP_Atom a) { int32_t v; const unsigned char *s = RepAtom(a)->UStrOfAE; size_t n = strlen_utf8(s); @@ -455,7 +482,7 @@ X_API const wchar_t *YAP_WideAtomName(Atom a) { return dest; } -X_API Atom YAP_LookupAtom(const char *c) { +X_API YAP_Atom YAP_LookupAtom(const char *c) { CACHE_REGS Atom a; @@ -473,7 +500,7 @@ X_API Atom YAP_LookupAtom(const char *c) { return NULL; } -X_API Atom YAP_LookupWideAtom(const wchar_t *c) { +X_API YAP_Atom YAP_LookupWideAtom(const wchar_t *c) { CACHE_REGS Atom a; @@ -491,7 +518,7 @@ X_API Atom YAP_LookupWideAtom(const wchar_t *c) { return NULL; } -X_API Atom YAP_FullLookupAtom(const char *c) { +X_API YAP_Atom YAP_FullLookupAtom(const char *c) { CACHE_REGS Atom at; @@ -509,7 +536,7 @@ X_API Atom YAP_FullLookupAtom(const char *c) { return NULL; } -X_API size_t YAP_AtomNameLength(Atom at) { +X_API size_t YAP_AtomNameLength(YAP_Atom at) { if (IsBlob(at)) { return RepAtom(at)->rep.blob->length; } @@ -633,7 +660,7 @@ X_API Int YAP_SkipList(Term *l, Term **tailp) { return length; } -X_API Term YAP_MkApplTerm(Functor f, UInt arity, Term args[]) { +X_API Term YAP_MkApplTerm(YAP_Functor f, UInt arity, Term args[]) { CACHE_REGS Term t; BACKUP_H(); @@ -647,7 +674,7 @@ X_API Term YAP_MkApplTerm(Functor f, UInt arity, Term args[]) { return t; } -X_API Term YAP_MkNewApplTerm(Functor f, UInt arity) { +X_API Term YAP_MkNewApplTerm(YAP_Functor f, UInt arity) { CACHE_REGS Term t; BACKUP_H(); @@ -661,7 +688,7 @@ X_API Term YAP_MkNewApplTerm(Functor f, UInt arity) { return t; } -X_API Functor YAP_FunctorOfTerm(Term t) { return (FunctorOfTerm(t)); } +X_API YAP_Functor YAP_FunctorOfTerm(Term t) { return (FunctorOfTerm(t)); } X_API Term YAP_ArgOfTerm(UInt n, Term t) { return (ArgOfTerm(n, t)); } @@ -673,11 +700,13 @@ X_API Term *YAP_ArgsOfTerm(Term t) { return NULL; } -X_API Functor YAP_MkFunctor(Atom a, UInt n) { return (Yap_MkFunctor(a, n)); } +X_API YAP_Functor YAP_MkFunctor(YAP_Atom a, UInt n) { + return (Yap_MkFunctor(a, n)); +} -X_API Atom YAP_NameOfFunctor(Functor f) { return (NameOfFunctor(f)); } +X_API YAP_Atom YAP_NameOfFunctor(YAP_Functor f) { return (NameOfFunctor(f)); } -X_API UInt YAP_ArityOfFunctor(Functor f) { return (ArityOfFunctor(f)); } +X_API UInt YAP_ArityOfFunctor(YAP_Functor f) { return (ArityOfFunctor(f)); } X_API void *YAP_ExtraSpaceCut(void) { CACHE_REGS @@ -851,27 +880,40 @@ X_API void YAP_PutInSlot(Int slot, Term t) { } typedef Int (*CPredicate0)(void); + typedef Int (*CPredicate1)(yhandle_t); + typedef Int (*CPredicate2)(yhandle_t, yhandle_t); + typedef Int (*CPredicate3)(yhandle_t, yhandle_t, yhandle_t); + typedef Int (*CPredicate4)(yhandle_t, yhandle_t, yhandle_t, yhandle_t); + typedef Int (*CPredicate5)(yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t); + typedef Int (*CPredicate6)(yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t); + typedef Int (*CPredicate7)(yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t); + typedef Int (*CPredicate8)(yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t); + typedef Int (*CPredicate9)(yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t); + typedef Int (*CPredicate10)(yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t); + typedef Int (*CPredicateV)(yhandle_t, yhandle_t, struct foreign_context *); static Int execute_cargs(PredEntry *pe, CPredicate exec_code USES_REGS) { + Int rc; + yhandle_t a1; switch (pe->ArityOfPE) { case 0: { CPredicate0 code0 = (CPredicate0)exec_code; @@ -879,85 +921,98 @@ static Int execute_cargs(PredEntry *pe, CPredicate exec_code USES_REGS) { } case 1: { CPredicate1 code1 = (CPredicate1)exec_code; - yhandle_t a1 = Yap_InitSlots(1, &ARG1); - return code1(a1); - } + a1 = Yap_InitSlots(1, &ARG1); + rc = code1(a1); + } break; case 2: { CPredicate2 code2 = (CPredicate2)exec_code; - yhandle_t a1 = Yap_InitSlots(2, &ARG1); - return code2(a1, a1 + 1); - } + a1 = Yap_InitSlots(2, &ARG1); + rc = code2(a1, a1 + 1); + } break; case 3: { CPredicate3 code3 = (CPredicate3)exec_code; - yhandle_t a1 = Yap_InitSlots(3, &ARG1); - return code3(a1, a1 + 1, a1 + 2); - } + a1 = Yap_InitSlots(3, &ARG1); + rc = code3(a1, a1 + 1, a1 + 2); + } break; case 4: { CPredicate4 code4 = (CPredicate4)exec_code; - yhandle_t a1 = Yap_InitSlots(4, &ARG1); - return code4(a1, a1 + 1, a1 + 2, a1 + 3); - } + a1 = Yap_InitSlots(4, &ARG1); + rc = code4(a1, a1 + 1, a1 + 2, a1 + 3); + } break; case 5: { CPredicate5 code5 = (CPredicate5)exec_code; - yhandle_t a1 = Yap_InitSlots(5, &ARG1); - return code5(a1, a1 + 1, a1 + 2, a1 + 3, a1 + 4); - } + a1 = Yap_InitSlots(5, &ARG1); + rc = code5(a1, a1 + 1, a1 + 2, a1 + 3, a1 + 4); + } break; + case 6: { CPredicate6 code6 = (CPredicate6)exec_code; - yhandle_t a1 = Yap_InitSlots(6, &ARG1); - return code6(a1, a1 + 1, a1 + 2, a1 + 3, a1 + 4, a1 + 5); - } + a1 = Yap_InitSlots(6, &ARG1); + rc = code6(a1, a1 + 1, a1 + 2, a1 + 3, a1 + 4, a1 + 5); + } break; case 7: { CPredicate7 code7 = (CPredicate7)exec_code; - yhandle_t a1 = Yap_InitSlots(7, &ARG1); - return code7(a1, a1 + 1, a1 + 2, a1 + 3, a1 + 4, a1 + 5, a1 + 6); - } + a1 = Yap_InitSlots(7, &ARG1); + rc = code7(a1, a1 + 1, a1 + 2, a1 + 3, a1 + 4, a1 + 5, a1 + 6); + } break; case 8: { CPredicate8 code8 = (CPredicate8)exec_code; - yhandle_t a1 = Yap_InitSlots(8, &ARG1); - return code8(a1, a1 + 1, a1 + 2, a1 + 3, a1 + 4, a1 + 5, a1 + 6, a1 + 7); - } + a1 = Yap_InitSlots(8, &ARG1); + rc = code8(a1, a1 + 1, a1 + 2, a1 + 3, a1 + 4, a1 + 5, a1 + 6, a1 + 7); + } break; case 9: { CPredicate9 code9 = (CPredicate9)exec_code; - yhandle_t a1 = Yap_InitSlots(9, &ARG1); - return code9(a1, a1 + 1, a1 + 2, a1 + 3, a1 + 4, a1 + 5, a1 + 6, a1 + 7, - a1 + 8); - } + a1 = Yap_InitSlots(9, &ARG1); + rc = code9(a1, a1 + 1, a1 + 2, a1 + 3, a1 + 4, a1 + 5, a1 + 6, a1 + 7, + a1 + 8); + } break; case 10: { CPredicate10 code10 = (CPredicate10)exec_code; - yhandle_t a1 = Yap_InitSlots(10, &ARG1); - return code10(a1, a1 + 1, a1 + 2, a1 + 3, a1 + 4, a1 + 5, a1 + 6, a1 + 7, - a1 + 8, a1 + 9); - } + a1 = Yap_InitSlots(10, &ARG1); + rc = code10(a1, a1 + 1, a1 + 2, a1 + 3, a1 + 4, a1 + 5, a1 + 6, a1 + 7, + a1 + 8, a1 + 9); + } break; default: YAP_Error(SYSTEM_ERROR_INTERNAL, TermNil, "YAP only supports SWI C-call with arity =< 10"); - return (FALSE); + return false; } + Yap_RecoverSlots(pe->ArityOfPE, a1); + return rc; } typedef uintptr_t (*CBPredicate0)(struct foreign_context *); + typedef uintptr_t (*CBPredicate1)(yhandle_t, struct foreign_context *); + typedef uintptr_t (*CBPredicate2)(yhandle_t, yhandle_t, struct foreign_context *); + typedef uintptr_t (*CBPredicate3)(yhandle_t, yhandle_t, yhandle_t, struct foreign_context *); + typedef uintptr_t (*CBPredicate4)(yhandle_t, yhandle_t, yhandle_t, yhandle_t, struct foreign_context *); + typedef uintptr_t (*CBPredicate5)(yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, struct foreign_context *); + typedef uintptr_t (*CBPredicate6)(yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, struct foreign_context *); + typedef uintptr_t (*CBPredicate7)(yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, struct foreign_context *); + typedef uintptr_t (*CBPredicate8)(yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, struct foreign_context *); + typedef uintptr_t (*CBPredicate9)(yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, struct foreign_context *); + typedef uintptr_t (*CBPredicate10)(yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, yhandle_t, @@ -1079,7 +1134,7 @@ static uintptr_t complete_exit(choiceptr ptr, int has_cp, return TRUE; } -Int YAP_Execute(PredEntry *pe, CPredicate exec_code) { +X_API Int YAP_Execute(PredEntry *pe, CPredicate exec_code) { CACHE_REGS Int ret; Int OASP = LCL0 - (CELL *)B; @@ -1120,7 +1175,7 @@ Int YAP_Execute(PredEntry *pe, CPredicate exec_code) { #define REDO_INT 0x02 /* Returned an integer */ #define REDO_PTR 0x03 /* returned a pointer */ -Int YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code) { +X_API Int YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code) { CACHE_REGS CELL ocp = LCL0 - (CELL *)B; /* for slots to work */ @@ -1168,8 +1223,8 @@ Int YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code) { } } -Int YAP_ExecuteOnCut(PredEntry *pe, CPredicate exec_code, - struct cut_c_str *top) { +X_API Int YAP_ExecuteOnCut(PredEntry *pe, CPredicate exec_code, + struct cut_c_str *top) { CACHE_REGS Int oB = LCL0 - (CELL *)B; Int val; @@ -1216,7 +1271,7 @@ Int YAP_ExecuteOnCut(PredEntry *pe, CPredicate exec_code, } } -Int YAP_ExecuteNext(PredEntry *pe, CPredicate exec_code) { +X_API Int YAP_ExecuteNext(PredEntry *pe, CPredicate exec_code) { CACHE_REGS /* for slots to work */ Yap_StartSlots(); @@ -1302,10 +1357,12 @@ X_API void YAP_FreeSpaceFromYap(void *ptr) { Yap_FreeCodeSpace(ptr); } * @param bufsize bu * * @return - */ X_API char * -YAP_StringToBuffer(Term t, char *buf, unsigned int bufsize) { + */ +X_API char *YAP_StringToBuffer(Term t, char *buf, unsigned int bufsize) { CACHE_REGS + BACKUP_MACHINE_REGS(); seq_tv_t inp, out; + int l = push_text_stack(); inp.val.t = t; inp.type = YAP_STRING_ATOMS_CODES | YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_TRUNC | YAP_STRING_MALLOC; @@ -1313,9 +1370,18 @@ YAP_StringToBuffer(Term t, char *buf, unsigned int bufsize) { out.type = YAP_STRING_CHARS; out.val.c = buf; out.enc = ENC_ISO_UTF8; - if (!Yap_CVT_Text(&inp, &out PASS_REGS)) + if (!Yap_CVT_Text(&inp, &out PASS_REGS)) { + pop_text_stack(l); + RECOVER_MACHINE_REGS(); return NULL; - return out.val.c; + } else { + RECOVER_MACHINE_REGS(); + if (buf == out.val.c) { + return buf; + } else { + return pop_output_text_stack(l, out.val.c); + } + } } /* copy a string to a buffer */ @@ -1401,11 +1467,10 @@ X_API Term YAP_ReadBuffer(const char *s, Term *tp) { if (*tp) tv = *tp; else - tv = 0; + tv = (Term)0; LOCAL_ErrorMessage = NULL; - const unsigned char *us = (const unsigned char *)s; - while (!(t = Yap_BufferToTermWithPrioBindings(us, strlen(s) + 1, TermNil, - GLOBAL_MaxPriority, tv))) { + while (!(t = Yap_BufferToTermWithPrioBindings(s, TermNil, tv, strlen(s) + 1, + GLOBAL_MaxPriority))) { if (LOCAL_ErrorMessage) { if (!strcmp(LOCAL_ErrorMessage, "Stack Overflow")) { if (!Yap_dogc(0, NULL PASS_REGS)) { @@ -1433,6 +1498,7 @@ X_API Term YAP_ReadBuffer(const char *s, Term *tp) { return 0L; } LOCAL_ErrorMessage = NULL; + RECOVER_H(); return 0; } else { break; @@ -1641,21 +1707,21 @@ X_API void YAP_Error(int myerrno, Term t, const char *buf, ...) { Yap_Error(myerrno, t, tmpbuf); } -X_API PredEntry *YAP_FunctorToPred(Functor func) { +X_API YAP_PredEntryPtr YAP_FunctorToPred(YAP_Functor func) { CACHE_REGS return RepPredProp(PredPropByFunc(func, CurrentModule)); } -X_API PredEntry *YAP_AtomToPred(Atom at) { +X_API YAP_PredEntryPtr YAP_AtomToPred(YAP_Atom at) { CACHE_REGS return RepPredProp(PredPropByAtom(at, CurrentModule)); } -X_API PredEntry *YAP_FunctorToPredInModule(Functor func, Term mod) { +X_API YAP_PredEntryPtr YAP_FunctorToPredInModule(YAP_Functor func, Term mod) { return RepPredProp(PredPropByFunc(func, mod)); } -X_API PredEntry *YAP_AtomToPredInModule(Atom at, Term mod) { +X_API YAP_PredEntryPtr YAP_AtomToPredInModule(YAP_Atom at, Term mod) { return RepPredProp(PredPropByAtom(at, mod)); } @@ -1667,14 +1733,20 @@ static int run_emulator(USES_REGS1) { return out; } -X_API bool YAP_EnterGoal(PredEntry *pe, CELL *ptr, YAP_dogoalinfo *dgi) { +X_API bool YAP_EnterGoal(YAP_PredEntryPtr ape, CELL *ptr, YAP_dogoalinfo *dgi) { CACHE_REGS + PredEntry *pe = ape; bool out; + // fprintf(stderr,"EnterGoal: H=%d ENV=%p B=%d TR=%d P=%p CP=%p + // Slots=%d\n",HR-H0,LCL0-ENV,LCL0-(CELL*)B,(CELL*)TR-LCL0, P, CP, + // LOCAL_CurSlot); BACKUP_MACHINE_REGS(); + LOCAL_ActiveError->errorNo = YAP_NO_ERROR; LOCAL_PrologMode = UserMode; dgi->p = P; dgi->cp = CP; + dgi->b0 = LCL0 - (CELL *)B; dgi->CurSlot = LOCAL_CurSlot; // ensure our current ENV receives current P. @@ -1684,7 +1756,15 @@ X_API bool YAP_EnterGoal(PredEntry *pe, CELL *ptr, YAP_dogoalinfo *dgi) { // slot=%d", pe, pe->CodeOfPred->opc, FAILCODE, Deref(ARG1), Deref(ARG2), // LOCAL_CurSlot); dgi->b = LCL0 - (CELL *)B; + dgi->h = HR - H0; + dgi->tr = (CELL *)TR - LCL0; + // fprintf(stderr,"PrepGoal: H=%d ENV=%p B=%d TR=%d P=%p CP=%p Slots=%d\n", + // HR-H0,LCL0-ENV,LCL0-(CELL*)B,(CELL*)TR-LCL0, P, CP, LOCAL_CurSlot); out = Yap_exec_absmi(true, false); + // fprintf(stderr,"EnterGoal success=%d: H=%d ENV=%p B=%d TR=%d P=%p CP=%p + // Slots=%d\n", out,HR-H0,LCL0-ENV,LCL0-(CELL*)B,(CELL*)TR-LCL0, P, CP, + // LOCAL_CurSlot); + dgi->b = LCL0 - (CELL *)B; if (out) { dgi->EndSlot = LOCAL_CurSlot; Yap_StartSlots(); @@ -1698,25 +1778,31 @@ X_API bool YAP_EnterGoal(PredEntry *pe, CELL *ptr, YAP_dogoalinfo *dgi) { X_API bool YAP_RetryGoal(YAP_dogoalinfo *dgi) { CACHE_REGS - choiceptr myB; + choiceptr myB, myB0; bool out; BACKUP_MACHINE_REGS(); - printf("before RETRY H=%p, ASP=%p, B=%p, ENV=%p, TR=%p %ld\n", HR, ASP, B, ENV, TR, LOCAL_CurSlot); - myB = (choiceptr)(LCL0 - dgi->b); + myB = (choiceptr)(LCL0 - dgi->b); + myB0 = (choiceptr)(LCL0 - dgi->b0); CP = myB->cp_cp; /* sanity check */ - if (B >= myB) { + if (B >= myB0) { return false; } + if (B < myB) { + // get rid of garbage choice-points + B = myB; + } + // fprintf(stderr,"RetryGoal: H=%d ENV=%p B=%d TR=%d P=%p CP=%p Slots=%d\n", + // HR-H0,LCL0-ENV,LCL0-(CELL*)B,(CELL*)TR-LCL0, P, CP, LOCAL_CurSlot); P = FAILCODE; /* make sure we didn't leave live slots when we backtrack */ ASP = (CELL *)B; LOCAL_CurSlot = dgi->EndSlot; out = run_emulator(PASS_REGS1); - printf("out=%d RETRY H=%p, ASP=%p, B=%p, ENV=%p, TR=%p %ld\n", out, HR, ASP, B, ENV, TR, LOCAL_CurSlot); - if (out) { + if (out) { dgi->EndSlot = LOCAL_CurSlot; + dgi->b = LCL0 - (CELL *)B; } else { LOCAL_CurSlot = dgi->CurSlot; // ignore any slots created within the called goal @@ -1725,65 +1811,51 @@ X_API bool YAP_RetryGoal(YAP_dogoalinfo *dgi) { return out; } -X_API bool YAP_LeaveGoal(bool backtrack, YAP_dogoalinfo *dgi) { +X_API bool YAP_LeaveGoal(bool successful, YAP_dogoalinfo *dgi) { CACHE_REGS - choiceptr myB; + choiceptr myB, handler; + // fprintf(stderr,"LeaveGoal success=%d: H=%d ENV=%p B=%ld myB=%ld TR=%d + // P=%p CP=%p Slots=%d\n", + // successful,HR-H0,LCL0-ENV,LCL0-(CELL*)B,dgi->b0,(CELL*)TR-LCL0, P, CP, + // LOCAL_CurSlot); BACKUP_MACHINE_REGS(); myB = (choiceptr)(LCL0 - dgi->b); - if (B < myB) { - /* someone cut us */ - return FALSE; + if (LOCAL_PrologMode & AsyncIntMode) { + Yap_signal(YAP_FAIL_SIGNAL); } - /* prune away choicepoints */ - if (B != myB) { -#ifdef YAPOR - CUT_prune_to(myB); -#endif - B = myB; + handler = B; + while (handler && + LCL0 - LOCAL_CBorder > (CELL *)handler + //&& handler->cp_ap != NOCODE + && handler->cp_b != NULL && handler != myB) { + if (handler < myB) { + handler->cp_ap = TRUSTFAILCODE; + } + B = handler; + handler = handler->cp_b; + if (successful) { + Yap_TrimTrail(); + } else if (!(LOCAL_PrologMode & AsyncIntMode)) { + P = FAILCODE; + Yap_exec_absmi(true, YAP_EXEC_ABSMI); + } } - /* if backtracking asked for, recover space and bindings */ - if (backtrack) { - P = FAILCODE; - Yap_exec_absmi(true, YAP_EXEC_ABSMI); - /* recover stack space */ - HR = B->cp_h; - TR = B->cp_tr; -#ifdef DEPTH_LIMIT - DEPTH = B->cp_depth; -#endif /* DEPTH_LIMIT */ - YENV = ENV = B->cp_env; - } else { - Yap_TrimTrail(); + if (LOCAL_PrologMode & AsyncIntMode) { + Yap_signal(YAP_FAIL_SIGNAL); } -/* recover local stack */ -#ifdef DEPTH_LIMIT - DEPTH = ENV[E_DEPTH]; -#endif - /* make sure we prune C-choicepoints */ - if (POP_CHOICE_POINT(B->cp_b)) { - POP_EXECUTE(); - } - ENV = (CELL *)(ENV[E_E]); - /* ASP should be set to the top of the local stack when we - did the call */ - ASP = B->cp_env; - /* YENV should be set to the current environment */ - YENV = ENV = (CELL *)((B->cp_env)[E_E]); - B = B->cp_b; - // SET_BB(B); - HB = PROTECT_FROZEN_H(B); - CP = dgi->cp; P = dgi->p; - LOCAL_CurSlot = dgi->CurSlot; + CP = dgi->cp; RECOVER_MACHINE_REGS(); + // fprintf(stderr,"LeftGoal success=%d: H=%d ENV=%p B=%d TR=%d P=%p CP=%p + // Slots=%d\n", successful,HR-H0,LCL0-ENV,LCL0-(CELL*)B,(CELL*)TR-LCL0, P, + // CP, LOCAL_CurSlot); return TRUE; } X_API Int YAP_RunGoal(Term t) { CACHE_REGS Term out; - yamop *old_CP = CP; yhandle_t cslot = LOCAL_CurSlot; BACKUP_MACHINE_REGS(); @@ -1793,31 +1865,14 @@ X_API Int YAP_RunGoal(Term t) { LOCAL_PrologMode = UserCCallMode; // should we catch the exception or pass it through? // We'll pass it through - Yap_RaiseException(); - if (out) { - P = (yamop *)ENV[E_CP]; - ENV = (CELL *)ENV[E_E]; - CP = old_CP; - LOCAL_AllowRestart = TRUE; - // we are back to user code again, need slots */ - } else { - ENV = B->cp_env; - ENV = (CELL *)ENV[E_E]; - CP = old_CP; - HR = B->cp_h; - TR = B->cp_tr; - B = B->cp_b; - LOCAL_AllowRestart = FALSE; - SET_ASP(ENV, E_CB * sizeof(CELL)); - // make sure the slots are ok. - } RECOVER_MACHINE_REGS(); LOCAL_CurSlot = cslot; return out; } X_API Term YAP_AllocExternalDataInStack(size_t bytes) { - Term t = Yap_AllocExternalDataInStack(EXTERNAL_BLOB, bytes); + CELL *pt; + Term t = Yap_AllocExternalDataInStack(EXTERNAL_BLOB, bytes, &pt); if (t == TermNil) return 0L; return t; @@ -1833,26 +1888,42 @@ X_API void *YAP_ExternalDataInStackFromTerm(Term t) { X_API YAP_opaque_tag_t YAP_NewOpaqueType(struct YAP_opaque_handler_struct *f) { int i; - if (!GLOBAL_OpaqueHandlers) { + if (!GLOBAL_OpaqueHandlersCount) { GLOBAL_OpaqueHandlers = - malloc(sizeof(opaque_handler_t) * (USER_BLOB_END - USER_BLOB_START)); + malloc(sizeof(YAP_opaque_handler_t) * USER_BLOB_END); if (!GLOBAL_OpaqueHandlers) { /* no room */ return -1; } - } else if (GLOBAL_OpaqueHandlersCount == USER_BLOB_END - USER_BLOB_START) { + GLOBAL_OpaqueHandlersCount = USER_BLOB_START; + } else if (GLOBAL_OpaqueHandlersCount == USER_BLOB_END) { /* all types used */ return -1; } i = GLOBAL_OpaqueHandlersCount++; - memcpy(GLOBAL_OpaqueHandlers + i, f, sizeof(opaque_handler_t)); - return i + USER_BLOB_START; + memmove(GLOBAL_OpaqueHandlers + i, f, sizeof(YAP_opaque_handler_t)); + return i; } -Term YAP_NewOpaqueObject(YAP_opaque_tag_t tag, size_t bytes) { - Term t = Yap_AllocExternalDataInStack((CELL)tag, bytes); +X_API Term YAP_NewOpaqueObject(YAP_opaque_tag_t blob_tag, size_t bytes) { + CELL *pt; + Term t = Yap_AllocExternalDataInStack((CELL)blob_tag, bytes, &pt); if (t == TermNil) return 0L; + pt = RepAppl(t); + blob_tag = pt[1]; + if (blob_tag < USER_BLOB_START || blob_tag >= USER_BLOB_END) { + Yap_Error(SYSTEM_ERROR_INTERNAL, AbsAppl(pt), + "clean opaque: bad blob with tag " UInt_FORMAT, blob_tag); + return FALSE; + } + YAP_opaque_tag_t blob_info = blob_tag; + if (GLOBAL_OpaqueHandlers[blob_info].cut_handler || + GLOBAL_OpaqueHandlers[blob_info].fail_handler) { + *HR++ = t; + *HR++ = TermNil; + TrailTerm(TR) = AbsPair(HR - 2); + } return t; } @@ -1874,14 +1945,12 @@ X_API Int YAP_RunGoalOnce(Term t) { yhandle_t CSlot; BACKUP_MACHINE_REGS(); - Yap_InitYaamRegs(0); CSlot = Yap_StartSlots(); LOCAL_PrologMode = UserMode; - // Yap_heap_regs->yap_do_low_level_trace=true; out = Yap_RunTopGoal(t, true); LOCAL_PrologMode = oldPrologMode; - Yap_CloseSlots(CSlot); + // Yap_CloseSlots(CSlot); if (!(oldPrologMode & UserCCallMode)) { /* called from top-level */ LOCAL_AllowRestart = FALSE; @@ -1890,7 +1959,7 @@ X_API Int YAP_RunGoalOnce(Term t) { } // should we catch the exception or pass it through? // We'll pass it through - Yap_RaiseException(); + // Yap_RaiseException(); if (out) { choiceptr cut_pt, ob; @@ -1912,6 +1981,8 @@ X_API Int YAP_RunGoalOnce(Term t) { Yap_TrimTrail(); } B = cut_pt; + } else { + Yap_CloseSlots(CSlot); } ASP = B->cp_env; ENV = (CELL *)ASP[E_E]; @@ -2024,9 +2095,7 @@ X_API void YAP_PruneGoal(YAP_dogoalinfo *gi) { X_API bool YAP_GoalHasException(Term *t) { CACHE_REGS BACKUP_MACHINE_REGS(); - if (t) - *t = Yap_PeekException(); - return Yap_PeekException(); + return LOCAL_ActiveError->errorNo != YAP_NO_ERROR; } X_API void YAP_ClearExceptions(void) { @@ -2035,42 +2104,56 @@ X_API void YAP_ClearExceptions(void) { Yap_ResetException(worker_id); } -X_API int YAP_InitConsult(int mode, const char *filename, char *full, +X_API int YAP_InitConsult(int mode, const char *fname, char **full, int *osnop) { CACHE_REGS - FILE *f = NULL; int sno; BACKUP_MACHINE_REGS(); - + const char *fl = NULL; + int lvl = push_text_stack(); if (mode == YAP_BOOT_MODE) { mode = YAP_CONSULT_MODE; } + if (fname == NULL || fname[0] == '\0') { + fl = Yap_BOOTFILE; + } + if (fname) { + fl = Yap_AbsoluteFile(fname, true); + if (!fl || !fl[0]) { + pop_text_stack(lvl); + *full = NULL; + return -1; + } else { + *full = pop_output_text_stack(lvl, fl); + } + } else { + pop_text_stack(lvl); + } + + lvl = push_text_stack(); + char *d = Malloc(strlen(fl) + 1); + strcpy(d, fl); bool consulted = (mode == YAP_CONSULT_MODE); - Yap_init_consult(consulted, filename); - const char *fl = Yap_findFile(filename, NULL, BootFilePath, full, true, - YAP_BOOT_PL, true, true); - if (!fl) - return -1; - f = fopen(fl, "r"); - if (!f) - return -1; - if (!f) { + Term tat = MkAtomTerm(Yap_LookupAtom(d)); + sno = Yap_OpenStream(tat, "r", MkAtomTerm(Yap_LookupAtom(fname)), + LOCAL_encoding); + if (sno < 0 || !Yap_ChDir(dirname((char *)d))) { + pop_text_stack(lvl); + *full = NULL; return -1; } - sno = Yap_OpenStream(f, NULL, TermNil, Input_Stream_f); - *osnop = Yap_CheckAlias(AtomLoopStream); - if (!Yap_AddAlias(AtomLoopStream, sno)) { - Yap_CloseStream(sno); - sno = -1; - } - GLOBAL_Stream[sno].name = Yap_LookupAtom(fl); - GLOBAL_Stream[sno].user_name = MkAtomTerm(Yap_LookupAtom(filename)); - GLOBAL_Stream[sno].encoding = ENC_ISO_UTF8; + LOCAL_PrologMode = UserMode; + + Yap_init_consult(consulted, pop_output_text_stack__(lvl, fl)); RECOVER_MACHINE_REGS(); UNLOCK(GLOBAL_Stream[sno].streamlock); return sno; } +/// given a stream descriptor or stream alias (see open/3), +/// return YAP's internal handle. +X_API void *YAP_GetStreamFromId(int no) { return GLOBAL_Stream + no; } + X_API FILE *YAP_TermToStream(Term t) { BACKUP_MACHINE_REGS(); FILE *s; @@ -2085,19 +2168,29 @@ X_API FILE *YAP_TermToStream(Term t) { return NULL; } -X_API void YAP_EndConsult(int sno, int *osnop) { +X_API void YAP_EndConsult(int sno, int *osnop, const char *full) { BACKUP_MACHINE_REGS(); Yap_CloseStream(sno); + int lvl = push_text_stack(); + char *d = Malloc(strlen(full) + 1); + strcpy(d, full); + Yap_ChDir(dirname(d)); if (osnop >= 0) Yap_AddAlias(AtomLoopStream, *osnop); Yap_end_consult(); - + __android_log_print(ANDROID_LOG_INFO, "YAPDroid ", " closing %s:%s(%d), %d", + CurrentModule == 0 + ? "prolog" + : RepAtom(AtomOfTerm(CurrentModule))->StrOfAE, + full, *osnop, sno); + // LOCAL_CurSlot); + pop_text_stack(lvl); RECOVER_MACHINE_REGS(); } X_API Term YAP_Read(FILE *f) { Term o; - int sno = Yap_OpenStream(f, NULL, TermNil, Input_Stream_f); + int sno = Yap_FileStream(f, NULL, TermNil, Input_Stream_f, NULL); BACKUP_MACHINE_REGS(); o = Yap_read_term(sno, TermNil, 1); @@ -2110,23 +2203,28 @@ X_API Term YAP_ReadFromStream(int sno) { Term o; BACKUP_MACHINE_REGS(); - o = Yap_read_term(sno, TermNil, 1); + o = Yap_read_term(sno, TermNil, false); RECOVER_MACHINE_REGS(); return o; } -X_API Term YAP_ReadClauseFromStream(int sno) { - Term o; +X_API Term YAP_ReadClauseFromStream(int sno, Term vs, Term pos) { BACKUP_MACHINE_REGS(); - o = Yap_read_term(sno, TermNil, -1); + Term t = Yap_read_term( + sno, + MkPairTerm(Yap_MkApplTerm(Yap_MkFunctor(AtomVariableNames, 1), 1, &vs), + MkPairTerm(Yap_MkApplTerm(Yap_MkFunctor(AtomTermPosition, 1), + 1, &pos), + TermNil)), + true); RECOVER_MACHINE_REGS(); - return o; + return t; } X_API void YAP_Write(Term t, FILE *f, int flags) { BACKUP_MACHINE_REGS(); - int sno = Yap_OpenStream(f, NULL, TermNil, Output_Stream_f); + int sno = Yap_FileStream(f, NULL, TermNil, Output_Stream_f, NULL); Yap_plwrite(t, GLOBAL_Stream + sno, 0, flags, GLOBAL_MaxPriority); Yap_ReleaseStream(sno); @@ -2150,16 +2248,25 @@ X_API char *YAP_WriteBuffer(Term t, char *buf, size_t sze, int flags) { seq_tv_t inp, out; BACKUP_MACHINE_REGS(); + int l = push_text_stack(); inp.val.t = t; - inp.type = YAP_STRING_TERM; + inp.type = YAP_STRING_TERM | YAP_STRING_DATUM; out.type = YAP_STRING_CHARS; out.val.c = buf; - out.max = sze-1; + out.max = sze - 1; out.enc = LOCAL_encoding; - if (!Yap_CVT_Text(&inp, &out PASS_REGS)) + if (!Yap_CVT_Text(&inp, &out PASS_REGS)) { + RECOVER_MACHINE_REGS(); + pop_text_stack(l); return NULL; - RECOVER_MACHINE_REGS(); - return out.val.c; + } else { + RECOVER_MACHINE_REGS(); + if (buf == out.val.c) { + return buf; + } else { + return pop_output_text_stack(l, out.val.c); + } + } } /// write a a term to n user-provided buffer: make sure not tp @@ -2169,19 +2276,19 @@ X_API int YAP_WriteDynamicBuffer(YAP_Term t, char *buf, size_t sze, char *b; BACKUP_MACHINE_REGS(); - b = Yap_TermToString(t, lengthp, enc, flags); - if (*lengthp >= sze) - *lengthp = sze; - strncpy(buf, b, sze); + b = Yap_TermToBuffer(t, flags); + strncpy(buf, b, sze - 1); + buf[sze] = 0; RECOVER_MACHINE_REGS(); return true; } -X_API char *YAP_CompileClause(Term t) { +X_API bool YAP_CompileClause(Term t) { CACHE_REGS yamop *codeaddr; Term mod = CurrentModule; Term tn = TermNil; + bool ok = true; BACKUP_MACHINE_REGS(); @@ -2190,12 +2297,14 @@ X_API char *YAP_CompileClause(Term t) { ARG1 = t; YAPEnterCriticalSection(); codeaddr = Yap_cclause(t, 0, mod, t); - if (codeaddr != NULL) { + ok = (codeaddr != NULL); + if (ok) { t = Deref(ARG1); /* just in case there was an heap overflow */ if (!Yap_addclause(t, codeaddr, TermAssertz, mod, &tn)) { - YAPLeaveCriticalSection(); - return LOCAL_ErrorMessage; + ok = false; } + } else { + ok = false; } YAPLeaveCriticalSection(); @@ -2203,381 +2312,28 @@ X_API char *YAP_CompileClause(Term t) { if (!Yap_locked_growheap(FALSE, 0, NULL)) { Yap_Error(RESOURCE_ERROR_HEAP, TermNil, "YAP failed to grow heap: %s", LOCAL_ErrorMessage); + ok = false; } } RECOVER_MACHINE_REGS(); - return (LOCAL_ErrorMessage); + if (!ok) { + return NULL; + } + return ok; } -static int yap_lineno = 0; +X_API void YAP_PutValue(YAP_Atom at, Term t) { Yap_PutValue(at, t); } -/* do initial boot by consulting the file boot.yap */ -static void do_bootfile(const char *bootfilename USES_REGS) { - Term t; - int bootfile, osno; - Functor functor_query = Yap_MkFunctor(Yap_LookupAtom("?-"), 1); - Functor functor_command1 = Yap_MkFunctor(Yap_LookupAtom(":-"), 1); - char full[YAP_FILENAME_MAX + 1]; - - /* consult boot.pl */ - /* the consult mode does not matter here, really */ - bootfile = YAP_InitConsult(YAP_BOOT_MODE, bootfilename, full, &osno); - if (bootfile < 0) { - fprintf(stderr, "[ FATAL ERROR: could not open bootfile %s ]\n", - bootfilename); - exit(1); - } - do { - CACHE_REGS - YAP_Reset(YAP_FULL_RESET); - Yap_StartSlots(); - t = YAP_ReadClauseFromStream(bootfile); - - // Yap_DebugPlWriteln(t); - if (t == 0) { - fprintf(stderr, - "[ SYNTAX ERROR: while parsing bootfile %s at line %d ]\n", - bootfilename, yap_lineno); - } else if (YAP_IsVarTerm(t) || t == TermNil) { - fprintf(stderr, "[ line %d: term cannot be compiled ]", yap_lineno); - } else if (YAP_IsPairTerm(t)) { - fprintf(stderr, "[ SYSTEM ERROR: consult not allowed in boot file ]\n"); - fprintf(stderr, "error found at line %d and pos %d", yap_lineno, - fseek(GLOBAL_Stream[bootfile].file, 0L, SEEK_CUR)); - } else if (IsApplTerm(t) && (FunctorOfTerm(t) == functor_query || - FunctorOfTerm(t) == functor_command1)) { - YAP_RunGoalOnce(ArgOfTerm(1, t)); - } else { - Term ts[2]; - char *ErrorMessage; - Functor fun = Yap_MkFunctor(Yap_LookupAtom("$prepare_clause"), 2); - PredEntry *pe = RepPredProp(PredPropByFunc(fun, PROLOG_MODULE)); - - if (pe->OpcodeOfPred != UNDEF_OPCODE && pe->OpcodeOfPred != FAIL_OPCODE) { - ts[0] = t; - RESET_VARIABLE(ts + 1); - if (YAP_RunGoal(Yap_MkApplTerm(fun, 2, ts))) - t = ts[1]; - } - ErrorMessage = YAP_CompileClause(t); - if (ErrorMessage) { - fprintf(stderr, "%s", ErrorMessage); - } - } - } while (t != TermEof); - - YAP_EndConsult(bootfile, &osno); -#if DEBUG - if (Yap_output_msg) - fprintf(stderr, "Boot loaded\n"); -#endif -} - -/** - YAP_DelayInit() - - ensures initialization is done after engine creation. - It receives a pointer to function and a string describing - the module. - */ - -X_API bool YAP_initialized = false; -static int n_mdelays = 0; -static YAP_delaymodule_t *m_delays; - -X_API bool YAP_DelayInit(YAP_ModInit_t f, const char s[]) { - if (m_delays) { - m_delays = realloc(m_delays, (n_mdelays + 1) * sizeof(YAP_delaymodule_t)); - } else { - m_delays = malloc(sizeof(YAP_delaymodule_t)); - } - m_delays[n_mdelays].f = f; - m_delays[n_mdelays].s = s; - n_mdelays++; - return true; -} - -bool Yap_LateInit(const char s[]) { - int i; - for (i = 0; i < n_mdelays; i++) { - if (!strcmp(m_delays[i].s, s)) { - m_delays[i].f(); - return true; - } - } - return false; -} - -static void start_modules(void) { - Term cm = CurrentModule; - size_t i; - for (i = 0; i < n_mdelays; i++) { - CurrentModule = MkAtomTerm(YAP_LookupAtom(m_delays[i].s)); - m_delays[i].f(); - } - CurrentModule = cm; -} - -/// whether Yap is under control of some other system -bool Yap_embedded = true; - -/* this routine is supposed to be called from an external program - that wants to control Yap */ - -YAP_file_type_t YAP_Init(YAP_init_args *yap_init) { - YAP_file_type_t restore_result = yap_init->boot_file_type; - bool do_bootstrap = (restore_result & YAP_CONSULT_MODE); - CELL Trail = 0, Stack = 0, Heap = 0, Atts = 0; - char boot_file[YAP_FILENAME_MAX + 1]; - Int rc; - const char *yroot; - - /* ignore repeated calls to YAP_Init */ - if (YAP_initialized) - return YAP_FOUND_BOOT_ERROR; - - Yap_embedded = yap_init->Embedded; - Yap_page_size = Yap_InitPageSize(); /* init memory page size, required by - later functions */ -#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA) - Yap_init_yapor_global_local_memory(); -#endif /* YAPOR_COPY || YAPOR_COW || YAPOR_SBA */ - // GLOBAL_PrologShouldHandleInterrupts = - // yap_init->PrologShouldHandleInterrupts && - if (!yap_init->Embedded) { - Yap_InitSysbits(0); /* init signal handling and time, required by later - functions */ - GLOBAL_argv = yap_init->Argv; - GLOBAL_argc = yap_init->Argc; - if (0 && ((YAP_QLY && yap_init->SavedState) || - (YAP_BOOT_PL && (yap_init->YapPrologBootFile)))) { - yroot = "."; - } else { - yroot = BootFilePath; - } - } - if (yap_init->SavedState == NULL) { - yap_init->SavedState = YAP_STARTUP; - } - -#if USE_DL_MALLOC - if (yap_init->SavedState == NULL) - yap_init->SavedState = YAP_STARTUP; -#else - yap_init->SavedState = Yap_findFile(yap_init->SavedState, YAP_STARTUP, yap_init->YapLibDir, - boot_file, true, YAP_QLY, true, true); -#endif - if (yap_init->SavedState == NULL) { - restore_result = YAP_BOOT_PL; - } - - if (restore_result == YAP_BOOT_PL) { -#if USE_DL_MALLOC - if (yap_init->YapPrologBootFile == NULL) - yap_init->YapPrologBootFile = BootFile; -#else - yap_init->YapPrologBootFile = - Yap_findFile(yap_init->YapPrologBootFile, BootFile, yroot, boot_file, - true, YAP_BOOT_PL, true, true); -#endif - } - - if (yap_init->TrailSize == 0) { - if (Trail == 0) - Trail = DefTrailSpace; - } else { - Trail = yap_init->TrailSize; - } - // Atts = yap_init->AttsSize; - if (yap_init->StackSize == 0) { - Stack = DefStackSpace; - } else { - Stack = yap_init->StackSize; - } -#ifndef USE_SYSTEM_MALLOC - if (yap_init->HeapSize == 0) { - if (Heap == 0) - Heap = DefHeapSpace; - } else { - Heap = yap_init->HeapSize; - } -#endif - - Yap_InitWorkspace(Heap, Stack, Trail, Atts, yap_init->MaxTableSpaceSize, - yap_init->NumberWorkers, yap_init->SchedulerLoop, - yap_init->DelayedReleaseLoad); - // - - CACHE_REGS - if (Yap_embedded) - if (yap_init->QuietMode) { - setVerbosity(TermSilent); - } - { - if (yap_init->YapPrologRCFile != NULL) { - /* - This must be done before restore, otherwise - restore will print out messages .... - */ - setBooleanGlobalPrologFlag(HALT_AFTER_CONSULT_FLAG, - yap_init->HaltAfterConsult); - } - /* tell the system who should cope with interrupts */ - Yap_ExecutionMode = yap_init->ExecutionMode; - if (do_bootstrap) { - restore_result |= YAP_BOOT_PL; - } else { // try always to boot from the saved state. - if (restore_result == YAP_QLY) { - if (!Yap_SavedInfo(yap_init->SavedState, yap_init->YapLibDir, &Trail, - &Stack, &Heap)) { - restore_result = YAP_BOOT_PL; - } else { - restore_result = - Yap_Restore(yap_init->SavedState, yap_init->YapLibDir); - } - if (restore_result == YAP_FOUND_BOOT_ERROR) { - restore_result = YAP_BOOT_PL; - } - } - } - GLOBAL_FAST_BOOT_FLAG = yap_init->FastBoot; -#if defined(YAPOR) || defined(TABLING) - Yap_init_root_frames(); -#endif /* YAPOR || TABLING */ -#ifdef YAPOR - Yap_init_yapor_workers(); -#if YAPOR_THREADS - if (Yap_thread_self() != 0) { -#else - if (worker_id != 0) { -#endif -#if defined(YAPOR_COPY) || defined(YAPOR_SBA) - /* - In the SBA we cannot just happily inherit registers - from the other workers - */ - Yap_InitYaamRegs(worker_id); -#endif /* YAPOR_COPY || YAPOR_SBA */ -#ifndef YAPOR_THREADS - Yap_InitPreAllocCodeSpace(0); -#endif /* YAPOR_THREADS */ - /* slaves, waiting for work */ - CurrentModule = USER_MODULE; - P = GETWORK_FIRST_TIME; - Yap_exec_absmi(FALSE, YAP_EXEC_ABSMI); - Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, - "abstract machine unexpected exit (YAP_Init)"); - } -#endif /* YAPOR */ - RECOVER_MACHINE_REGS(); - } - /* make sure we do this after restore */ - if (yap_init->MaxStackSize) { - GLOBAL_AllowLocalExpansion = FALSE; - } else { - GLOBAL_AllowLocalExpansion = TRUE; - } - if (yap_init->MaxGlobalSize) { - GLOBAL_AllowGlobalExpansion = FALSE; - } else { - GLOBAL_AllowGlobalExpansion = TRUE; - } - if (yap_init->MaxTrailSize) { - GLOBAL_AllowTrailExpansion = FALSE; - } else { - GLOBAL_AllowTrailExpansion = TRUE; - } - if (yap_init->YapPrologRCFile) { - Yap_PutValue(AtomConsultOnBoot, - MkAtomTerm(Yap_LookupAtom(yap_init->YapPrologRCFile))); - /* - This must be done again after restore, as yap_flags - has been overwritten .... - */ - setBooleanGlobalPrologFlag(HALT_AFTER_CONSULT_FLAG, - yap_init->HaltAfterConsult); - } - if (yap_init->YapPrologTopLevelGoal) { - Yap_PutValue(AtomTopLevelGoal, - MkAtomTerm(Yap_LookupAtom(yap_init->YapPrologTopLevelGoal))); - } - if (yap_init->YapPrologGoal) { - Yap_PutValue(AtomInitGoal, - MkAtomTerm(Yap_LookupAtom(yap_init->YapPrologGoal))); - } - if (yap_init->YapPrologAddPath) { - Yap_PutValue(AtomExtendFileSearchPath, - MkAtomTerm(Yap_LookupAtom(yap_init->YapPrologAddPath))); - } - if (yap_init->QuietMode) { - setVerbosity(TermSilent); - } - if (restore_result == YAP_QLY) { - setAtomicGlobalPrologFlag(RESOURCE_DATABASE_FLAG, - MkAtomTerm(Yap_LookupAtom(yap_init->SavedState))); - LOCAL_PrologMode &= ~BootMode; - CurrentModule = LOCAL_SourceModule = USER_MODULE; - setBooleanGlobalPrologFlag(SAVED_PROGRAM_FLAG, true); - rc = YAP_QLY; - } else { - if (!yap_init->YapPrologBootFile) - yap_init->YapPrologBootFile = BootFile; - rc = YAP_BOOT_PL; - do_bootfile(yap_init->YapPrologBootFile); - setAtomicGlobalPrologFlag( - RESOURCE_DATABASE_FLAG, - MkAtomTerm(Yap_LookupAtom(yap_init->YapPrologBootFile))); - setBooleanGlobalPrologFlag(SAVED_PROGRAM_FLAG, false); - } - start_modules(); - YAP_initialized = true; - return rc; -} - -#if (DefTrailSpace < MinTrailSpace) -#undef DefTrailSpace -#define DefTrailSpace MinTrailSpace -#endif - -#if (DefStackSpace < MinStackSpace) -#undef DefStackSpace -#define DefStackSpace MinStackSpace -#endif - -#if (DefHeapSpace < MinHeapSpace) -#undef DefHeapSpace -#define DefHeapSpace MinHeapSpace -#endif - -#define DEFAULT_NUMBERWORKERS 1 -#define DEFAULT_SCHEDULERLOOP 10 -#define DEFAULT_DELAYEDRELEASELOAD 3 - -X_API YAP_file_type_t YAP_FastInit(char saved_state[], int argc, char *argv[]) { - YAP_init_args init_args; - YAP_file_type_t out; - - if ((out = Yap_InitDefaults(&init_args, saved_state, argc, argv)) != - YAP_FOUND_BOOT_ERROR) - out = YAP_Init(&init_args); - if (out == YAP_FOUND_BOOT_ERROR) { - Yap_Error(init_args.ErrorNo, TermNil, init_args.ErrorCause); - } - return out; -} - -X_API void YAP_PutValue(Atom at, Term t) { Yap_PutValue(at, t); } - -X_API Term YAP_GetValue(Atom at) { return (Yap_GetValue(at)); } +X_API Term YAP_GetValue(YAP_Atom at) { return (Yap_GetValue(at)); } X_API int YAP_CompareTerms(Term t1, Term t2) { return Yap_compare_terms(t1, t2); } -X_API int YAP_Reset(yap_reset_t mode) { +X_API int YAP_Reset(yap_reset_t mode, bool reset_global) { int res = TRUE; BACKUP_MACHINE_REGS(); - res = Yap_Reset(mode); + res = Yap_Reset(mode, reset_global); RECOVER_MACHINE_REGS(); return res; } @@ -2594,10 +2350,17 @@ X_API void YAP_SetOutputMessage(void) { X_API int YAP_StreamToFileNo(Term t) { return (Yap_StreamToFileNo(t)); } +/** + * Obtain a pointer to the YAP representation of a stream. + * @param sno Stream Id + * @return data structure for stream + */ +X_API void *YAP_RepStreamFromId(int sno) { return GLOBAL_Stream + sno; } + X_API void YAP_CloseAllOpenStreams(void) { BACKUP_H(); - Yap_CloseStreams(FALSE); + Yap_CloseStreams(); RECOVER_H(); } @@ -2612,7 +2375,9 @@ X_API void YAP_FlushAllStreams(void) { X_API void YAP_Throw(Term t) { BACKUP_MACHINE_REGS(); - Yap_JumpToEnv(t); + LOCAL_ActiveError->errorNo = THROW_EVENT; + LOCAL_ActiveError->errorGoal = Yap_TermToBuffer(t, 0); + Yap_JumpToEnv(); RECOVER_MACHINE_REGS(); } @@ -2620,7 +2385,9 @@ X_API void YAP_AsyncThrow(Term t) { CACHE_REGS BACKUP_MACHINE_REGS(); LOCAL_PrologMode |= AsyncIntMode; - Yap_JumpToEnv(t); + LOCAL_ActiveError->errorNo = THROW_EVENT; + LOCAL_ActiveError->errorGoal = Yap_TermToBuffer(t, 0); + Yap_JumpToEnv(); LOCAL_PrologMode &= ~AsyncIntMode; RECOVER_MACHINE_REGS(); } @@ -2632,7 +2399,7 @@ X_API CELL *YAP_TopOfLocalStack(void) { return (ASP); } -X_API void *YAP_Predicate(Atom a, UInt arity, Term m) { +X_API void *YAP_Predicate(YAP_Atom a, UInt arity, Term m) { if (arity == 0) { return ((void *)RepPredProp(PredPropByAtom(a, m))); } else { @@ -2641,7 +2408,7 @@ X_API void *YAP_Predicate(Atom a, UInt arity, Term m) { } } -X_API void YAP_PredicateInfo(void *p, Atom *a, UInt *arity, Term *m) { +X_API void YAP_PredicateInfo(void *p, YAP_Atom *a, UInt *arity, Term *m) { PredEntry *pd = (PredEntry *)p; if (pd->ArityOfPE) { *arity = pd->ArityOfPE; @@ -2656,42 +2423,38 @@ X_API void YAP_PredicateInfo(void *p, Atom *a, UInt *arity, Term *m) { *m = TermProlog; } -X_API void YAP_UserCPredicate(const char *name, CPredicate def, arity_t arity) { - Yap_InitCPred(name, arity, def, UserCPredFlag); +X_API void YAP_UserCPredicate(const char *name, YAP_UserCPred def, + YAP_Arity arity) { + Yap_InitCPred(name, arity, (CPredicate)def, UserCPredFlag); } -X_API void YAP_UserBackCPredicate_(const char *name, CPredicate init, - CPredicate cont, arity_t arity, - arity_t extra) { - Yap_InitCPredBackCut(name, arity, extra, init, cont, NULL, UserCPredFlag); +X_API void YAP_UserBackCPredicate_(const char *name, YAP_UserCPred init, + YAP_UserCPred cont, YAP_Arity arity, + YAP_Arity extra) { + Yap_InitCPredBackCut(name, arity, extra, (CPredicate)init, (CPredicate)cont, + NULL, UserCPredFlag); } -X_API void YAP_UserBackCutCPredicate(const char *name, CPredicate init, - CPredicate cont, CPredicate cut, - arity_t arity, arity_t extra) { - Yap_InitCPredBackCut(name, arity, extra, init, cont, cut, UserCPredFlag); +X_API void YAP_UserBackCutCPredicate(const char *name, YAP_UserCPred init, + YAP_UserCPred cont, YAP_UserCPred cut, + YAP_Arity arity, YAP_Arity extra) { + Yap_InitCPredBackCut(name, arity, extra, (CPredicate)init, (CPredicate)cont, + (CPredicate)cut, UserCPredFlag); } -X_API void YAP_UserBackCPredicate(const char *name, CPredicate init, - CPredicate cont, arity_t arity, +X_API void YAP_UserBackCPredicate(const char *name, YAP_UserCPred init, + YAP_UserCPred cont, arity_t arity, arity_t extra) { - Yap_InitCPredBackCut(name, arity, extra, init, cont, NULL, UserCPredFlag); + Yap_InitCPredBackCut(name, arity, extra, (CPredicate)init, (CPredicate)cont, + NULL, UserCPredFlag); } -X_API void YAP_UserCPredicateWithArgs(const char *a, CPredicate f, +X_API void YAP_UserCPredicateWithArgs(const char *a, YAP_UserCPred f, arity_t arity, Term mod) { CACHE_REGS - PredEntry *pe; Term cm = CurrentModule; CurrentModule = mod; - YAP_UserCPredicate(a, f, arity); - if (arity == 0) { - pe = RepPredProp(PredPropByAtom(Yap_LookupAtom(a), mod)); - } else { - Functor f = Yap_MkFunctor(Yap_LookupAtom(a), arity); - pe = RepPredProp(PredPropByFunc(f, mod)); - } - pe->PredFlags |= CArgsPredFlag; + Yap_InitCPred(a, arity, (CPredicate)f, UserCPredFlag | CArgsPredFlag); CurrentModule = cm; } @@ -2707,7 +2470,7 @@ X_API Term YAP_SetCurrentModule(Term new) { return omod; } -X_API Term YAP_CreateModule(Atom at) { +X_API Term YAP_CreateModule(YAP_Atom at) { Term t; WRITE_LOCK(RepAtom(at)->ARWLock); t = Yap_Module(MkAtomTerm(at)); @@ -2763,13 +2526,13 @@ X_API Term YAP_TermNil(void) { return TermNil; } X_API int YAP_IsTermNil(Term t) { return t == TermNil; } -X_API int YAP_AtomGetHold(Atom at) { return Yap_AtomIncreaseHold(at); } +X_API int YAP_AtomGetHold(YAP_Atom at) { return Yap_AtomIncreaseHold(at); } -X_API int YAP_AtomReleaseHold(Atom at) { return Yap_AtomDecreaseHold(at); } +X_API int YAP_AtomReleaseHold(YAP_Atom at) { return Yap_AtomDecreaseHold(at); } -X_API Agc_hook YAP_AGCRegisterHook(Agc_hook hook) { - Agc_hook old = GLOBAL_AGCHook; - GLOBAL_AGCHook = hook; +X_API YAP_agc_hook YAP_AGCRegisterHook(YAP_agc_hook hook) { + YAP_agc_hook old = (YAP_agc_hook)GLOBAL_AGCHook; + GLOBAL_AGCHook = (Agc_hook)hook; return old; } @@ -2779,15 +2542,12 @@ X_API int YAP_HaltRegisterHook(HaltHookFunc hook, void *closure) { X_API char *YAP_cwd(void) { CACHE_REGS - char *buf = NULL; + char *buf = Yap_AllocCodeSpace(FILENAME_MAX + 1); int len; - if (!Yap_getcwd(LOCAL_FileNameBuf, YAP_FILENAME_MAX)) + if (!Yap_getcwd(buf, FILENAME_MAX)) return FALSE; - len = strlen(LOCAL_FileNameBuf); - buf = Yap_AllocCodeSpace(len + 1); - if (!buf) - return NULL; - strncpy(buf, LOCAL_FileNameBuf, len); + len = strlen(buf); + buf = Yap_ReallocCodeSpace(buf, len + 1); return buf; } @@ -3082,7 +2842,7 @@ X_API void YAP_signal(int sig) { Yap_signal(sig); } X_API int YAP_SetYAPFlag(Term flag, Term val) { return setYapFlag(flag, val); } /* yhandle_t YAP_VarSlotToNumber(yhandle_t) */ -yhandle_t YAP_VarSlotToNumber(yhandle_t s) { +X_API yhandle_t YAP_VarSlotToNumber(yhandle_t s) { CACHE_REGS Term *t = (CELL *)Deref(Yap_GetFromSlot(s)); if (t < HR) @@ -3091,14 +2851,15 @@ yhandle_t YAP_VarSlotToNumber(yhandle_t s) { } /* Term YAP_ModuleUser() */ -Term YAP_ModuleUser(void) { return MkAtomTerm(AtomUser); } +X_API Term YAP_ModuleUser(void) { return MkAtomTerm(AtomUser); } /* int YAP_PredicateHasClauses() */ -yhandle_t YAP_NumberOfClausesForPredicate(PredEntry *pe) { +X_API YAP_handle_t YAP_NumberOfClausesForPredicate(YAP_PredEntryPtr ape) { + PredEntry *pe = ape; return pe->cs.p_code.NOfClauses; } -int YAP_MaxOpPriority(Atom at, Term module) { +X_API int YAP_MaxOpPriority(YAP_Atom at, Term module) { AtomEntry *ae = RepAtom(at); OpEntry *info; WRITE_LOCK(ae->ARWLock); @@ -3116,7 +2877,8 @@ int YAP_MaxOpPriority(Atom at, Term module) { return ret; } -int YAP_OpInfo(Atom at, Term module, int opkind, int *yap_type, int *prio) { +X_API int YAP_OpInfo(YAP_Atom at, Term module, int opkind, int *yap_type, + int *prio) { AtomEntry *ae = RepAtom(at); OpEntry *info; int n; @@ -3178,14 +2940,14 @@ int YAP_OpInfo(Atom at, Term module, int opkind, int *yap_type, int *prio) { return 1; } -int YAP_Argv(char ***argvp) { +X_API int YAP_Argv(char ***argvp) { if (argvp) { *argvp = GLOBAL_argv; } return GLOBAL_argc; } -YAP_tag_t YAP_TagOfTerm(Term t) { +X_API YAP_tag_t YAP_TagOfTerm(Term t) { if (IsVarTerm(t)) { CELL *pt = VarOfTerm(t); if (IsUnboundVar(pt)) { @@ -3240,7 +3002,7 @@ Term YAP_BPROLOG_curr_toam_status; * * @return a positive number with the size, or 0. */ -size_t YAP_UTF8_TextLength(Term t) { +X_API size_t YAP_UTF8_TextLength(Term t) { utf8proc_uint8_t dst[8]; size_t sz = 0; @@ -3260,19 +3022,21 @@ size_t YAP_UTF8_TextLength(Term t) { } else { c = '\0'; } + sz += utf8proc_encode_char(c, dst); t = TailOfTerm(t); } } else if (IsAtomTerm(t)) { Atom at = AtomOfTerm(t); - sz = strlen(RepAtom(at)->StrOfAE); + char *s = RepAtom(at)->StrOfAE; + sz = strlen(s); } else if (IsStringTerm(t)) { sz = strlen(StringOfTerm(t)); } return sz; } -Int YAP_ListLength(Term t) { +X_API Int YAP_ListLength(Term t) { Term *aux; Int n = Yap_SkipList(&t, &aux); @@ -3283,14 +3047,16 @@ Int YAP_ListLength(Term t) { return -1; } -Int YAP_NumberVars(Term t, Int nbv) { return Yap_NumberVars(t, nbv, FALSE); } +X_API Int YAP_NumberVars(Term t, Int nbv) { + return Yap_NumberVars(t, nbv, FALSE); +} -Term YAP_UnNumberVars(Term t) { +X_API Term YAP_UnNumberVars(Term t) { /* don't allow sharing of ground terms */ return Yap_UnNumberTerm(t, FALSE); } -int YAP_IsNumberedVariable(Term t) { +X_API int YAP_IsNumberedVariable(Term t) { return IsApplTerm(t) && FunctorOfTerm(t) == FunctorDollarVar && IsIntegerTerm(ArgOfTerm(1, t)); } @@ -3335,7 +3101,7 @@ functor_t *TR_Functors; size_t AtomTranslations, MaxAtomTranslations; size_t FunctorTranslations, MaxFunctorTranslations; -X_API Int YAP_AtomToInt(Atom At) { +X_API Int YAP_AtomToInt(YAP_Atom At) { TranslationEntry *te = Yap_GetTranslationProp(At, 0); if (te != NIL) return te->Translation; @@ -3350,7 +3116,7 @@ X_API Int YAP_AtomToInt(Atom At) { "No more room for translations"); return -1; } - memcpy(nt, ot, sizeof(atom_t) * MaxAtomTranslations); + memmove(nt, ot, sizeof(atom_t) * MaxAtomTranslations); TR_Atoms = nt; free(ot); MaxAtomTranslations *= 2; @@ -3358,10 +3124,10 @@ X_API Int YAP_AtomToInt(Atom At) { return AtomTranslations - 1; } -X_API Atom YAP_IntToAtom(Int i) { return TR_Atoms[i]; } +X_API YAP_Atom YAP_IntToAtom(Int i) { return TR_Atoms[i]; } -X_API Int YAP_FunctorToInt(Functor f) { - Atom At = NameOfFunctor(f); +X_API Int YAP_FunctorToInt(YAP_Functor f) { + YAP_Atom At = NameOfFunctor(f); arity_t arity = ArityOfFunctor(f); TranslationEntry *te = Yap_GetTranslationProp(At, arity); if (te != NIL) @@ -3378,7 +3144,7 @@ X_API Int YAP_FunctorToInt(Functor f) { "No more room for translations"); return -1; } - memcpy(nt, ot, sizeof(functor_t) * MaxFunctorTranslations); + memmove(nt, ot, sizeof(functor_t) * MaxFunctorTranslations); TR_Functors = nt; free(ot); MaxFunctorTranslations *= 2; @@ -3386,10 +3152,21 @@ X_API Int YAP_FunctorToInt(Functor f) { return FunctorTranslations - 1; } -X_API Functor YAP_IntToFunctor(Int i) { return TR_Functors[i]; } +X_API void *YAP_foreign_stream(int sno) { + return GLOBAL_Stream[sno].u.private_data; +} + +X_API YAP_Functor YAP_IntToFunctor(Int i) { return TR_Functors[i]; } X_API void *YAP_shared(void) { return LOCAL_shared; } +X_API YAP_PredEntryPtr YAP_TopGoal(void) { + Functor f = Yap_MkFunctor(Yap_LookupAtom("yap_query"), 3); + Term tmod = MkAtomTerm(Yap_LookupAtom("yapi")); + PredEntry *p = RepPredProp(Yap_GetPredPropByFunc(f, tmod)); + return p; +} + void yap_init(void) {} #endif // C_INTERFACE_C diff --git a/C/cdmgr.c b/C/cdmgr.c index 11f097663..30dc65848 100644 --- a/C/cdmgr.c +++ b/C/cdmgr.c @@ -19,8 +19,8 @@ static char SccsId[] = "@(#)cdmgr.c 1.1 05/02/98"; #endif #include "Yap.h" -#include "clause.h" #include "YapEval.h" +#include "clause.h" #include "tracer.h" #include "yapio.h" #ifdef YAPOR @@ -32,6 +32,7 @@ static char SccsId[] = "@(#)cdmgr.c 1.1 05/02/98"; #if HAVE_STRING_H #include #endif +#include #include #include #include @@ -46,7 +47,7 @@ static void assertz_dynam_clause(PredEntry *, yamop *); static void expand_consult(void); static int not_was_reconsulted(PredEntry *, Term, int); static int RemoveIndexation(PredEntry *); -static Int p_number_of_clauses(USES_REGS1); +static Int number_of_clauses(USES_REGS1); static Int p_compile(USES_REGS1); static Int p_purge_clauses(USES_REGS1); static Int p_setspy(USES_REGS1); @@ -55,7 +56,7 @@ static Int p_startconsult(USES_REGS1); static Int p_showconslultlev(USES_REGS1); static Int p_endconsult(USES_REGS1); static Int p_undefined(USES_REGS1); -static Int p_new_multifile(USES_REGS1); +static Int new_multifile(USES_REGS1); static Int p_is_multifile(USES_REGS1); static Int p_optimizer_on(USES_REGS1); static Int p_optimizer_off(USES_REGS1); @@ -76,7 +77,7 @@ static void kill_first_log_iblock(LogUpdIndex *, LogUpdIndex *, PredEntry *); static void InitConsultStack(void) { CACHE_REGS LOCAL_ConsultLow = (consult_obj *)Yap_AllocCodeSpace(sizeof(consult_obj) * - InitialConsultCapacity); + InitialConsultCapacity); if (LOCAL_ConsultLow == NULL) { Yap_Error(RESOURCE_ERROR_HEAP, TermNil, "No Heap Space in InitCodes"); return; @@ -93,20 +94,32 @@ void Yap_ResetConsultStack(void) { LOCAL_ConsultCapacity = InitialConsultCapacity; } +/** + * Are we compiling a file? + * + */ +bool Yap_Consulting(USES_REGS1) { + return LOCAL_ConsultBase != NULL + && LOCAL_ConsultSp != LOCAL_ConsultLow+LOCAL_ConsultCapacity; +} + /****************************************************************** ADDING AND REMOVE INFO TO A PROCEDURE ******************************************************************/ -/* - * we have three kinds of predicates: dynamic DynamicPredFlag - * static CompiledPredFlag fast FastPredFlag all the +/** + * we have three kinds of predicates: + * + dynamic DynamicPredFlag + * + static CompiledPredFlag fast + * + fast FastPredFlag. + * + * all the * database predicates are supported for dynamic predicates only abolish and * assertz are supported for static predicates no database predicates are * supportted for fast predicates */ - PredEntry *Yap_get_pred(Term t, Term tmod, const char *pname) { Term t0 = t; @@ -115,7 +128,8 @@ restart: Yap_Error(INSTANTIATION_ERROR, t0, pname); return NULL; } else if (IsAtomTerm(t)) { - return RepPredProp(Yap_GetPredPropByAtom(AtomOfTerm(t), tmod)); + PredEntry *ap = RepPredProp(Yap_GetPredPropByAtom(AtomOfTerm(t), tmod)); + return ap; } else if (IsIntegerTerm(t) && tmod == IDB_MODULE) { return Yap_FindLUIntKey(IntegerOfTerm(t)); } else if (IsPairTerm(t)) { @@ -140,7 +154,8 @@ restart: t = ArgOfTerm(2, t); goto restart; } - return RepPredProp(Yap_GetPredPropByFunc(fun, tmod)); + PredEntry *ap = RepPredProp(Yap_GetPredPropByFunc(fun, tmod)); + return ap; } else { Yap_Error(TYPE_ERROR_CALLABLE, t0, pname); } @@ -248,9 +263,9 @@ void Yap_BuildMegaClause(PredEntry *ap) { if (ap->PredFlags & (DynamicPredFlag | LogUpdatePredFlag | MegaClausePredFlag #ifdef TABLING - | TabledPredFlag + | TabledPredFlag #endif /* TABLING */ - | UDIPredFlag) || + | UDIPredFlag) || ap->cs.p_code.FirstClause == NULL || ap->cs.p_code.NOfClauses < 16) { return; } @@ -297,7 +312,7 @@ void Yap_BuildMegaClause(PredEntry *ap) { mcl->ClLine = cl->usc.ClLine; ptr = mcl->ClCode; while (TRUE) { - memcpy((void *)ptr, (void *)cl->ClCode, sz); + memmove((void *)ptr, (void *)cl->ClCode, sz); if (has_blobs) { LOCAL_ClDiff = (char *)(ptr) - (char *)cl->ClCode; restore_opcodes(ptr, NULL PASS_REGS); @@ -376,7 +391,7 @@ static void split_megaclause(PredEntry *ap) { new->ClSize = mcl->ClItemSize; new->usc.ClLine = Yap_source_line_no(); new->ClNext = NULL; - memcpy((void *)new->ClCode, (void *)ptr, mcl->ClItemSize); + memmove((void *)new->ClCode, (void *)ptr, mcl->ClItemSize); if (prev) { prev->ClNext = new; } else { @@ -496,7 +511,7 @@ static void RemoveMainIndex(PredEntry *ap) { #ifdef TABLING || ap->PredFlags & TabledPredFlag #endif /* TABLING */ - ) { + ) { ap->OpcodeOfPred = INDEX_OPCODE; ap->CodeOfPred = ap->cs.p_code.TrueCodeOfPred = (yamop *)(&(ap->OpcodeOfPred)); @@ -1016,10 +1031,11 @@ static void retract_all(PredEntry *p, int in_use) { } p->cs.p_code.FirstClause = NULL; p->cs.p_code.LastClause = NULL; - if (p->PredFlags & (DynamicPredFlag | LogUpdatePredFlag | MultiFileFlag)) { + if (is_live(p)) { p->OpcodeOfPred = FAIL_OPCODE; } else { p->OpcodeOfPred = UNDEF_OPCODE; + p->PredFlags |= UndefPredFlag; } p->cs.p_code.TrueCodeOfPred = p->CodeOfPred = (yamop *)(&(p->OpcodeOfPred)); if (trueGlobalPrologFlag(PROFILING_FLAG)) { @@ -1381,8 +1397,8 @@ static void expand_consult(void) { } new_cs = new_cl + InitialConsultCapacity; /* start copying */ - memcpy((void *)new_cs, (void *)LOCAL_ConsultLow, - OldConsultCapacity * sizeof(consult_obj)); + memmove((void *)new_cs, (void *)LOCAL_ConsultLow, + OldConsultCapacity * sizeof(consult_obj)); /* copying done, release old space */ Yap_FreeCodeSpace((char *)LOCAL_ConsultLow); /* next, set up pointers correctly */ @@ -1448,26 +1464,35 @@ static int not_was_reconsulted(PredEntry *p, Term t, int mode) { return TRUE; /* careful */ } -static void addcl_permission_error(AtomEntry *ap, Int Arity, int in_use) { +static yamop *addcl_permission_error(const char *file, const char *function, + int lineno, AtomEntry *ap, Int Arity, + int in_use) { CACHE_REGS - - LOCAL_Error_TYPE = PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE; - LOCAL_ErrorMessage = Malloc( 256 ); - - if (in_use) { - if (Arity == 0) - sprintf(LOCAL_ErrorMessage, "static predicate %s is in use", ap->StrOfAE); - else - sprintf(LOCAL_ErrorMessage, - "static predicate %s/" Int_FORMAT " is in use", ap->StrOfAE, - Arity); - } else { - if (Arity == 0) - sprintf(LOCAL_ErrorMessage, "system predicate %s", ap->StrOfAE); - else - sprintf(LOCAL_ErrorMessage, "system predicate %s/" Int_FORMAT, - ap->StrOfAE, Arity); - } + Term culprit; + if (Arity == 0) + culprit = MkAtomTerm(AbsAtom(ap)); + else + culprit = Yap_MkNewApplTerm(Yap_MkFunctor(AbsAtom(ap), Arity), Arity); + return (in_use + ? (Arity == 0 + ? Yap_Error__(false, file, function, lineno, + PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE, + culprit, "static predicate %s is in use", + ap->StrOfAE) + : Yap_Error__( + false, file, function, lineno, + PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE, culprit, + "static predicate %s/" Int_FORMAT " is in use", + ap->StrOfAE, Arity)) + : (Arity == 0 + ? Yap_Error__(false, file, function, lineno, + PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE, + culprit, "system predicate %s is in use", + ap->StrOfAE) + : Yap_Error__(false, file, function, lineno, + PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE, + culprit, "system predicate %s/" Int_FORMAT, + ap->StrOfAE, Arity))); } PredEntry *Yap_PredFromClause(Term t USES_REGS) { @@ -1486,7 +1511,9 @@ PredEntry *Yap_PredFromClause(Term t USES_REGS) { t = ArgOfTerm(2, t); } else if (f == FunctorAssert) { t = ArgOfTerm(1, t); - } else if (f == FunctorComma && extra_arity == 2) { + } else if (f == FunctorComma + + && extra_arity == 2) { t = ArgOfTerm(1, t); } else if (f == FunctorDoubleArrow) { extra_arity = 2; @@ -1637,7 +1664,7 @@ Atom Yap_source_file_name(void) { } /** - * @brief we cannot add clauses to the proceduree + * @brief we cannot add clauses to the procedure * * @param p predicate * @@ -1647,6 +1674,14 @@ bool Yap_constPred(PredEntry *p) { pred_flags_t pflags; pflags = p->PredFlags; + if (pflags & + ((UserCPredFlag | CArgsPredFlag | NumberDBPredFlag | AtomDBPredFlag | + TestPredFlag | AsmPredFlag | CPredFlag | BinaryPredFlag))) + return true; + + if (p->PredFlags & + (SysExportPredFlag | MultiFileFlag | DynamicPredFlag | LogUpdatePredFlag)) + return false; if (Yap_isSystemModule(p->ModuleOfPred)) { if (p->cs.p_code.NOfClauses == 0) { p->src.OwnerFile = Yap_source_file_name(); @@ -1656,14 +1691,6 @@ bool Yap_constPred(PredEntry *p) { return false; } } - if (pflags & - ((UserCPredFlag | CArgsPredFlag | NumberDBPredFlag | AtomDBPredFlag | - TestPredFlag | AsmPredFlag | CPredFlag | BinaryPredFlag))) - return true; - - if (p->PredFlags & - (SysExportPredFlag | MultiFileFlag | DynamicPredFlag | LogUpdatePredFlag)) - return false; return false; } @@ -1686,6 +1713,9 @@ bool Yap_addclause(Term t, yamop *cp, Term tmode, Term mod, Term *t4ref) Term tf; int mode; + if (tmode == 0) { + tmode = TermConsult; + } if (tmode == TermConsult) { mode = consult; } else if (tmode == TermReconsult) { @@ -1719,14 +1749,15 @@ bool Yap_addclause(Term t, yamop *cp, Term tmode, Term mod, Term *t4ref) at = NameOfFunctor(f); p = RepPredProp(PredPropByFunc(f, mod)); } - Yap_PutValue(AtomAbol, TermNil); PELOCK(20, p); /* we are redefining a prolog module predicate */ if (Yap_constPred(p)) { - addcl_permission_error(RepAtom(at), Arity, FALSE); + addcl_permission_error(__FILE__, __FUNCTION__, __LINE__, RepAtom(at), Arity, + FALSE); UNLOCKPE(30, p); return false; } + Yap_PutValue(AtomAbol, TermNil); pflags = p->PredFlags; /* we are redefining a prolog module predicate */ if (pflags & MegaClausePredFlag) { @@ -1735,11 +1766,12 @@ bool Yap_addclause(Term t, yamop *cp, Term tmode, Term mod, Term *t4ref) /* The only problem we have now is when we need to throw away Indexing blocks */ - if (pflags & IndexedPredFlag) { + if (pflags & IndexedPredFlag && p->cs.p_code.NOfClauses > 1) { Yap_AddClauseToIndex(p, cp, mode == asserta); } - if (pflags & (SpiedPredFlag | CountPredFlag | ProfiledPredFlag)) + if (pflags & (SpiedPredFlag | CountPredFlag | ProfiledPredFlag)) { spy_flag = true; + } if (Yap_discontiguous(p, tmode PASS_REGS)) { Term disc[3], sc[4]; if (p->ArityOfPE) { @@ -1751,12 +1783,12 @@ bool Yap_addclause(Term t, yamop *cp, Term tmode, Term mod, Term *t4ref) disc[2] = Yap_Module_Name(p); sc[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomDiscontiguous, 3), 3, disc); sc[1] = MkIntegerTerm(Yap_source_line_no()); + __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "source %s ", + RepAtom(LOCAL_SourceFileName)->StrOfAE); sc[2] = MkAtomTerm(LOCAL_SourceFileName); sc[3] = t; t = Yap_MkApplTerm(Yap_MkFunctor(AtomStyleCheck, 4), 4, sc); - sc[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomStyleCheck, 1), 1, &t); - sc[1] = MkAtomTerm(AtomWarning); - Yap_PrintWarning(Yap_MkApplTerm(Yap_MkFunctor(AtomError, 2), 2, sc)); + Yap_PrintWarning(t); } else if (Yap_multiple(p, tmode PASS_REGS)) { Term disc[4], sc[4]; if (p->ArityOfPE) { @@ -1772,9 +1804,7 @@ bool Yap_addclause(Term t, yamop *cp, Term tmode, Term mod, Term *t4ref) sc[2] = MkAtomTerm(LOCAL_SourceFileName); sc[3] = t; t = Yap_MkApplTerm(Yap_MkFunctor(AtomStyleCheck, 4), 4, sc); - sc[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomStyleCheck, 1), 1, &t); - sc[1] = MkAtomTerm(AtomWarning); - Yap_PrintWarning(Yap_MkApplTerm(Yap_MkFunctor(AtomError, 2), 2, sc)); + Yap_PrintWarning(t); } if (mode == consult) not_was_reconsulted(p, t, true); @@ -1809,6 +1839,7 @@ bool Yap_addclause(Term t, yamop *cp, Term tmode, Term mod, Term *t4ref) p->PredFlags = p->PredFlags | CompiledPredFlag; } if (p->cs.p_code.FirstClause == NULL) { + p->PredFlags &= ~UndefPredFlag; if (!(pflags & DynamicPredFlag)) { add_first_static(p, cp, spy_flag); /* make sure we have a place to jump to */ @@ -1867,8 +1898,6 @@ bool Yap_addclause(Term t, yamop *cp, Term tmode, Term mod, Term *t4ref) } else { tf = Yap_MkStaticRefTerm(ClauseCodeToStaticClause(cp), p); } - __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "add %s/%ld %p", - RepAtom(at)->StrOfAE, Arity); if (mod == PROLOG_MODULE) mod = TermProlog; if (pflags & MultiFileFlag) { @@ -1909,7 +1938,12 @@ void Yap_EraseStaticClause(StaticClause *cl, PredEntry *ap, Term mod) { if (ap->cs.p_code.LastClause == cl->ClCode) { /* got rid of all clauses */ ap->cs.p_code.LastClause = ap->cs.p_code.FirstClause = NULL; - ap->OpcodeOfPred = UNDEF_OPCODE; + if (is_live(ap)) { + ap->OpcodeOfPred = FAIL_OPCODE; + } else { + ap->OpcodeOfPred = UNDEF_OPCODE; + ap->PredFlags |= UndefPredFlag; + } ap->cs.p_code.TrueCodeOfPred = (yamop *)(&(ap->OpcodeOfPred)); } else { yamop *ncl = cl->ClNext->ClCode; @@ -2017,9 +2051,9 @@ static Int p_compile(USES_REGS1) { /* '$compile'(+C,+Flags,+C0,-Ref) */ if (mode == assertz && LOCAL_consult_level && mod == CurrentModule) mode = consult; */ - code_adr = Yap_cclause(t, 5, mod, - Deref(ARG3)); /* vsc: give the number of arguments to - cclause() in case there is a overflow */ + code_adr = Yap_cclause(t, 5, mod, Deref(ARG3)); /* vsc: give the number of + arguments to cclause() in case there is a + overflow */ t = Deref(ARG1); /* just in case there was an heap overflow */ if (!LOCAL_ErrorMessage) { YAPEnterCriticalSection(); @@ -2047,12 +2081,12 @@ Atom Yap_ConsultingFile(USES_REGS1) { if (LOCAL_consult_level == 0) { return (AtomUser); } else { - return (Yap_ULookupAtom(LOCAL_ConsultBase[2].filename)); + return LOCAL_ConsultBase[2].f_name; } } /* consult file *file*, *mode* may be one of either consult or reconsult */ -static void init_consult(int mode, const unsigned char *file) { +void Yap_init_consult(int mode, const char *filenam) { CACHE_REGS if (!LOCAL_ConsultSp) { InitConsultStack(); @@ -2061,7 +2095,7 @@ static void init_consult(int mode, const unsigned char *file) { expand_consult(); } LOCAL_ConsultSp--; - LOCAL_ConsultSp->filename = file; + LOCAL_ConsultSp->f_name = Yap_LookupAtom(filenam); LOCAL_ConsultSp--; LOCAL_ConsultSp->mode = mode; LOCAL_ConsultSp--; @@ -2075,17 +2109,13 @@ static void init_consult(int mode, const unsigned char *file) { LOCAL_LastAssertedPred = NULL; } -void Yap_init_consult(int mode, const char *file) { - init_consult(mode, (const unsigned char *)file); -} - static Int p_startconsult(USES_REGS1) { /* '$start_consult'(+Mode) */ Term t; char *smode = RepAtom(AtomOfTerm(Deref(ARG1)))->StrOfAE; int mode; mode = strcmp("consult", (char *)smode); - init_consult(mode, RepAtom(AtomOfTerm(Deref(ARG2)))->UStrOfAE); + Yap_init_consult(mode, RepAtom(AtomOfTerm(Deref(ARG2)))->StrOfAE); t = MkIntTerm(LOCAL_consult_level); return (Yap_unify_constant(ARG3, t)); } @@ -2372,7 +2402,7 @@ static Int p_rmspy(USES_REGS1) { /* '$rm_spy'(+T,+Mod) */ ******************************************************************/ static Int - p_number_of_clauses(USES_REGS1) { /* '$number_of_clauses'(Predicate,M,N) */ + number_of_clauses(USES_REGS1) { /* '$number_of_clauses'(Predicate,M,N) */ Term t = Deref(ARG1); Term mod = Deref(ARG2); int ncl = 0; @@ -2398,47 +2428,41 @@ static Int return (Yap_unify_constant(ARG3, MkIntegerTerm(ncl))); } -static Int p_new_multifile(USES_REGS1) { /* '$new_multifile'(+N,+Ar,+Mod) */ +/* @pred '$new_multifile'(+G,+Mod) + * sets the multi-file flag + * */ +static Int new_multifile(USES_REGS1) { + PredEntry *pe; Atom at; arity_t arity; - PredEntry *pe; - Term t = Deref(ARG1); - Term mod = Deref(ARG3); - if (IsVarTerm(t)) - return (FALSE); - if (IsAtomTerm(t)) - at = AtomOfTerm(t); - else - return (FALSE); - t = Deref(ARG2); - if (IsVarTerm(t)) - return (FALSE); - if (IsIntTerm(t)) - arity = IntOfTerm(t); - else + pe = new_pred(Deref(ARG1), Deref(ARG2), "multifile"); + if (EndOfPAEntr(pe)) return FALSE; + PELOCK(30, pe); + arity = pe->ArityOfPE; if (arity == 0) - pe = RepPredProp(PredPropByAtom(at, mod)); + at = (Atom)pe->FunctorOfPred; else - pe = RepPredProp(PredPropByFunc(Yap_MkFunctor(at, arity), mod)); - PELOCK(26, pe); - if (pe->PredFlags & - (UserCPredFlag | CArgsPredFlag | NumberDBPredFlag | AtomDBPredFlag | - TestPredFlag | AsmPredFlag | CPredFlag | BinaryPredFlag)) { - UNLOCKPE(26, pe); - addcl_permission_error(RepAtom(at), arity, FALSE); - return false; - } + at = NameOfFunctor(pe->FunctorOfPred); + if (pe->PredFlags & MultiFileFlag) { UNLOCKPE(26, pe); return true; } - if (pe->cs.p_code.NOfClauses) { + if (pe->PredFlags & (TabledPredFlag | ForeignPredFlags)) { UNLOCKPE(26, pe); - addcl_permission_error(RepAtom(at), arity, FALSE); + addcl_permission_error(__FILE__, __FUNCTION__, __LINE__, RepAtom(at), arity, + FALSE); return false; } + if (pe->cs.p_code.NOfClauses) { + UNLOCKPE(26, pe); + addcl_permission_error(__FILE__, __FUNCTION__, __LINE__, RepAtom(at), arity, + FALSE); + return false; + } + pe->PredFlags &= ~UndefPredFlag; pe->PredFlags |= MultiFileFlag; /* mutifile-predicates are weird, they do not seat really on the default * module */ @@ -2463,6 +2487,7 @@ static Int p_is_multifile(USES_REGS1) { /* '$is_multifile'(+S,+Mod) */ if (EndOfPAEntr(pe)) return FALSE; PELOCK(27, pe); + out = (pe->PredFlags & MultiFileFlag); UNLOCKPE(44, pe); return (out); @@ -2506,13 +2531,36 @@ static Int new_system_predicate( static Int p_is_system_predicate(USES_REGS1) { /* '$is_multifile'(+S,+Mod) */ PredEntry *pe; - bool out; + Term t1 = Deref(ARG1); - pe = Yap_get_pred(Deref(ARG1), Deref(ARG2), "system_predicate"); + // pe = Yap_get_pred(t1, Deref(ARG2), "system_predicate"); + // if (!pe) + pe = Yap_get_pred(t1, Deref(ARG2), "system_predicate"); + // if (!pe) pe = Yap_get_pred(t1, USER_MODULE, "system_predicate"); if (EndOfPAEntr(pe)) return FALSE; - PELOCK(27, pe); - out = (pe->PredFlags & SystemPredFlags); + return (pe->ModuleOfPred == 0); + // return true; + // PELOCK(27, pe); + // out = (pe->PredFlags & SystemPredFlags); + // UNLOCKPE(44, pe); + // return (out); +} + +static Int + p_is_opaque_predicate(USES_REGS1) { /* '$is_multifile'(+S,+Mod) */ + PredEntry *pe; + Term t1 = Deref(ARG1); + bool out; + + // pe = Yap_get_pred(t1, Deref(ARG2), "system_predicate"); + // if (!pe) + pe = Yap_get_pred(t1, Deref(ARG2), "system_predicate"); + // if (!pe) pe = Yap_get_pred(t1, USER_MODULE, "system_predicate"); + if (EndOfPAEntr(pe)) + return FALSE; + return (pe->ModuleOfPred == 0 || + pe->PredFlags & (SystemPredFlags | ForeignPredFlags)); UNLOCKPE(44, pe); return (out); } @@ -2626,7 +2674,7 @@ static Int p_set_owner_file(USES_REGS1) { /* '$owner_file'(+P,M,F) */ return TRUE; } -static Int p_mk_d(USES_REGS1) { /* '$make_dynamic'(+P) */ +static Int mk_dynamic(USES_REGS1) { /* '$make_dynamic'(+P) */ PredEntry *pe; Atom at; arity_t arity; @@ -2645,7 +2693,8 @@ static Int p_mk_d(USES_REGS1) { /* '$make_dynamic'(+P) */ (UserCPredFlag | CArgsPredFlag | NumberDBPredFlag | AtomDBPredFlag | TestPredFlag | AsmPredFlag | CPredFlag | BinaryPredFlag)) { UNLOCKPE(30, pe); - addcl_permission_error(RepAtom(at), arity, FALSE); + addcl_permission_error(__FILE__, __FUNCTION__, __LINE__, RepAtom(at), arity, + FALSE); return false; } if (pe->PredFlags & LogUpdatePredFlag) { @@ -2658,11 +2707,13 @@ static Int p_mk_d(USES_REGS1) { /* '$make_dynamic'(+P) */ } if (pe->cs.p_code.NOfClauses != 0) { UNLOCKPE(26, pe); - addcl_permission_error(RepAtom(at), arity, FALSE); + addcl_permission_error(__FILE__, __FUNCTION__, __LINE__, RepAtom(at), arity, + FALSE); return false; } if (pe->OpcodeOfPred == UNDEF_OPCODE) { pe->OpcodeOfPred = FAIL_OPCODE; + pe->PredFlags &= ~UndefPredFlag; } pe->src.OwnerFile = Yap_ConsultingFile(PASS_REGS1); pe->PredFlags |= LogUpdatePredFlag; @@ -2683,6 +2734,43 @@ static Int p_is_dynamic(USES_REGS1) { /* '$is_dynamic'(+P) */ return (out); } +/* @pred '$new_multifile'(+G,+Mod) + * sets the multi-file flag + * */ +static Int new_meta_pred(USES_REGS1) { + PredEntry *pe; + Atom at; + arity_t arity; + + pe = new_pred(Deref(ARG1), Deref(ARG2), "meta_predicate"); + if (EndOfPAEntr(pe)) + return false; + PELOCK(30, pe); + arity = pe->ArityOfPE; + if (arity == 0) + at = (Atom)pe->FunctorOfPred; + else + at = NameOfFunctor(pe->FunctorOfPred); + + if (pe->PredFlags & MetaPredFlag) { + UNLOCKPE(26, pe); + return true; + } + if (pe->cs.p_code.NOfClauses) { + UNLOCKPE(26, pe); + addcl_permission_error(__FILE__, __FUNCTION__, __LINE__, RepAtom(at), arity, + FALSE); + return false; + } + pe->PredFlags |= MetaPredFlag; + if (!(pe->PredFlags & (DynamicPredFlag | LogUpdatePredFlag))) { + /* static */ + pe->PredFlags |= (SourcePredFlag | CompiledPredFlag); + } + UNLOCKPE(43, pe); + return true; +} + static Int p_is_metapredicate(USES_REGS1) { /* '$is_metapredicate'(+P) */ PredEntry *pe; bool out; @@ -2708,13 +2796,13 @@ static Int p_pred_exists(USES_REGS1) { /* '$pred_exists'(+P,+M) */ UNLOCKPE(54, pe); return false; } - out = (pe->OpcodeOfPred != UNDEF_OPCODE); + out = (is_live(pe) || pe->OpcodeOfPred != UNDEF_OPCODE); UNLOCKPE(55, pe); return out; } static Int p_set_pred_module(USES_REGS1) { /* '$set_pred_module'(+P,+Mod) - */ + */ PredEntry *pe; pe = Yap_get_pred(Deref(ARG1), CurrentModule, "set_pred_module/1"); @@ -2727,7 +2815,7 @@ static Int p_set_pred_module(USES_REGS1) { /* '$set_pred_module'(+P,+Mod) } static Int p_set_pred_owner(USES_REGS1) { /* '$set_pred_module'(+P,+File) - */ + */ PredEntry *pe; Term a2 = Deref(ARG2); @@ -2783,12 +2871,7 @@ static Int p_undefined(USES_REGS1) { /* '$undefined'(P,Mod) */ if (EndOfPAEntr(pe)) return TRUE; PELOCK(36, pe); - if (pe->PredFlags & (CPredFlag | UserCPredFlag | TestPredFlag | AsmPredFlag | - DynamicPredFlag | LogUpdatePredFlag | TabledPredFlag)) { - UNLOCKPE(57, pe); - return FALSE; - } - if (pe->OpcodeOfPred == UNDEF_OPCODE) { + if (!is_live(pe) && pe->OpcodeOfPred == UNDEF_OPCODE) { UNLOCKPE(58, pe); return TRUE; } @@ -2820,7 +2903,7 @@ static Int p_kill_dynamic(USES_REGS1) { /* '$kill_dynamic'(P,M) */ pe->OpcodeOfPred = UNDEF_OPCODE; pe->cs.p_code.TrueCodeOfPred = pe->CodeOfPred = (yamop *)(&(pe->OpcodeOfPred)); - pe->PredFlags = 0; + pe->PredFlags = UndefPredFlag; UNLOCKPE(62, pe); return (TRUE); } @@ -3020,133 +3103,100 @@ static Int p_clean_up_dead_clauses(USES_REGS1) { void Yap_HidePred(PredEntry *pe) { + if (pe->PredFlags & HiddenPredFlag) + return; pe->PredFlags |= (HiddenPredFlag | NoSpyPredFlag | NoTracePredFlag); -} + if (pe->NextOfPE) { + UInt hash = PRED_HASH(pe->FunctorOfPred, CurrentModule, PredHashTableSize); + READ_LOCK(PredHashRWLock); + PredEntry *p, **op = PredHash + hash; + p = *op; -static Int /* $system_predicate(P) */ - p_stash_predicate(USES_REGS1) { - PredEntry *pe; - - Term t1 = Deref(ARG1); - Term mod = Deref(ARG2); - -restart_system_pred: - if (IsVarTerm(t1)) - return (FALSE); - if (IsAtomTerm(t1)) { - Atom a = AtomOfTerm(t1); - - pe = RepPredProp(Yap_GetPredPropByAtom(a, mod)); - } else if (IsApplTerm(t1)) { - Functor funt = FunctorOfTerm(t1); - if (IsExtensionFunctor(funt)) { - return (FALSE); - } - if (funt == FunctorModule) { - Term nmod = ArgOfTerm(1, t1); - if (IsVarTerm(nmod)) { - Yap_Error(INSTANTIATION_ERROR, ARG1, "hide_predicate/1"); - return (FALSE); + while (p) { + if (p == pe) { + *op = p->NextPredOfHash; + break; } - if (!IsAtomTerm(nmod)) { - Yap_Error(TYPE_ERROR_ATOM, ARG1, "hide_predicate/1"); - return (FALSE); - } - t1 = ArgOfTerm(2, t1); - goto restart_system_pred; + op = &p->NextPredOfHash; + p = p->NextPredOfHash; } - pe = RepPredProp(Yap_GetPredPropByFunc(funt, mod)); - } else if (IsPairTerm(t1)) { - return TRUE; - } else - return FALSE; - if (EndOfPAEntr(pe)) - return FALSE; - Yap_HidePred(pe); - return TRUE; -} - -static Int /* $system_predicate(P) */ - hide_predicate(USES_REGS1) { - PredEntry *pe; - - Term t1 = Deref(ARG1); - Term mod = Deref(ARG2); - -restart_system_pred: - if (IsVarTerm(t1)) - return (FALSE); - if (IsAtomTerm(t1)) { - Atom a = AtomOfTerm(t1); - - pe = RepPredProp(Yap_GetPredPropByAtom(a, mod)); - } else if (IsApplTerm(t1)) { - Functor funt = FunctorOfTerm(t1); - if (IsExtensionFunctor(funt)) { - return (FALSE); + pe->NextPredOfHash = NULL; + } + { + Prop *op, p; + if (pe->ArityOfPE == 0) { + op = &RepAtom(AtomOfTerm((Term)(pe->FunctorOfPred)))->PropsOfAE; + } else { + op = &pe->FunctorOfPred->PropsOfFE; } - if (funt == FunctorModule) { - Term nmod = ArgOfTerm(1, t1); - if (IsVarTerm(nmod)) { - Yap_Error(INSTANTIATION_ERROR, ARG1, "hide_predicate/1"); - return (FALSE); + p = *op; + + while (p) { + if (p == AbsPredProp(pe)) { + *op = p->NextOfPE; + break; } - if (!IsAtomTerm(nmod)) { - Yap_Error(TYPE_ERROR_ATOM, ARG1, "hide_predicate/1"); - return (FALSE); - } - t1 = ArgOfTerm(2, t1); - goto restart_system_pred; + op = &p->NextOfPE; + p = p->NextOfPE; } - pe = RepPredProp(Yap_GetPredPropByFunc(funt, mod)); - } else if (IsPairTerm(t1)) { - return true; - } else - return false; - if (EndOfPAEntr(pe)) - return false; - pe->PredFlags |= (HiddenPredFlag | NoSpyPredFlag | NoTracePredFlag); - return true; + pe->NextOfPE = RepAtom(AtomFoundVar)->PropsOfAE; + RepAtom(AtomFoundVar)->PropsOfAE = AbsPredProp(pe); + } + + { + PredEntry *p, + **op = &Yap_GetModuleEntry(Yap_Module(pe->ModuleOfPred))->PredForME; + p = *op; + + while (p) { + if (p == pe) { + *op = p->NextPredOfModule; + break; + } + op = &p->NextPredOfModule; + p = p->NextPredOfModule; + } + pe->NextPredOfModule = NULL; + } } static Int /* $hidden_predicate(P) */ - p_hidden_predicate(USES_REGS1) { - PredEntry *pe; - - Term t1 = Deref(ARG1); - Term mod = Deref(ARG2); - -restart_system_pred: - if (IsVarTerm(t1)) - return (FALSE); - if (IsAtomTerm(t1)) { - pe = RepPredProp(Yap_GetPredPropByAtom(AtomOfTerm(t1), mod)); - } else if (IsApplTerm(t1)) { - Functor funt = FunctorOfTerm(t1); - if (IsExtensionFunctor(funt)) { - return (FALSE); - } - if (funt == FunctorModule) { - Term nmod = ArgOfTerm(1, t1); - if (IsVarTerm(nmod)) { - Yap_Error(INSTANTIATION_ERROR, ARG1, "hide_predicate/1"); - return (FALSE); - } - if (!IsAtomTerm(nmod)) { - Yap_Error(TYPE_ERROR_ATOM, ARG1, "hide_predicate/1"); - return (FALSE); - } - t1 = ArgOfTerm(2, t1); - goto restart_system_pred; - } - pe = RepPredProp(Yap_GetPredPropByFunc(funt, mod)); - } else if (IsPairTerm(t1)) { - return (TRUE); +hide_predicate(USES_REGS1) { + PredEntry *pe = + Yap_get_pred(Deref(ARG1), Deref(ARG2), "while checking for a procedure"); + if (pe) { + Yap_HidePred(pe); + return true; } else - return (FALSE); - if (EndOfPAEntr(pe)) - return (FALSE); - return (pe->PredFlags & HiddenPredFlag); + return false; +} + +static Int /* $hidden_predicate(P) */ +stash_predicate(USES_REGS1) { + PredEntry *pe = + Yap_get_pred(Deref(ARG1), Deref(ARG2), "while checking for a procedure"); + if (pe) { + pe->PredFlags |= (HiddenPredFlag | NoSpyPredFlag | NoTracePredFlag); + /* + char ns[1024]; + const char *s = (pe->ModuleOfPred == PROLOG_MODULE ? + "__prolog__stash__" : + snprintf(sn,1023,"__%s__".RepAtom(AtomOfTerm( + pe->ModuleOfPred )))); pe->ModuleOfPred = MkAtomTerm(Yap_LookupAtom(s)); + */ + return true; + } else + return false; +} + +static Int /* $hidden_predicate(P) */ +hidden_predicate(USES_REGS1) { + PredEntry *pe = + Yap_get_pred(Deref(ARG1), Deref(ARG2), "while checking for a procedure"); + if (pe) + return (pe->PredFlags & HiddenPredFlag); + else + return false; } static Int fetch_next_lu_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, @@ -3261,7 +3311,7 @@ static Int fetch_next_lu_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, } static Int /* $hidden_predicate(P) */ - p_log_update_clause(USES_REGS1) { +p_log_update_clause(USES_REGS1) { PredEntry *pe; Term t1 = Deref(ARG1); Int ret; @@ -3281,7 +3331,7 @@ static Int /* $hidden_predicate(P) */ } static Int /* $hidden_predicate(P) */ - p_continue_log_update_clause(USES_REGS1) { +p_continue_log_update_clause(USES_REGS1) { PredEntry *pe = (PredEntry *)IntegerOfTerm(Deref(ARG1)); yamop *ipc = (yamop *)IntegerOfTerm(ARG2); @@ -3411,7 +3461,7 @@ static Int fetch_next_lu_clause_erase(PredEntry *pe, yamop *i_code, Term th, } static Int /* $hidden_predicate(P) */ - p_log_update_clause_erase(USES_REGS1) { +p_log_update_clause_erase(USES_REGS1) { PredEntry *pe; Term t1 = Deref(ARG1); Int ret; @@ -3432,7 +3482,7 @@ static Int /* $hidden_predicate(P) */ } static Int /* $hidden_predicate(P) */ - p_continue_log_update_clause_erase(USES_REGS1) { +p_continue_log_update_clause_erase(USES_REGS1) { PredEntry *pe = (PredEntry *)IntegerOfTerm(Deref(ARG1)); yamop *ipc = (yamop *)IntegerOfTerm(ARG2); @@ -3873,7 +3923,7 @@ static Int fetch_next_static_clause(PredEntry *pe, yamop *i_code, Term th, } static Int /* $hidden_predicate(P) */ - p_static_clause(USES_REGS1) { +p_static_clause(USES_REGS1) { PredEntry *pe; Term t1 = Deref(ARG1); yamop *new_cp; @@ -3892,7 +3942,7 @@ static Int /* $hidden_predicate(P) */ } static Int /* $hidden_predicate(P) */ - p_continue_static_clause(USES_REGS1) { +p_continue_static_clause(USES_REGS1) { PredEntry *pe = (PredEntry *)IntegerOfTerm(Deref(ARG1)); yamop *ipc = (yamop *)IntegerOfTerm(ARG2); @@ -4588,9 +4638,9 @@ static bool pred_flag_clause(Functor f, Term mod, const char *name, } #endif tn = Yap_MkApplTerm(f, 2, s); - yamop *code_adr = - Yap_cclause(tn, 2, mod, tn); /* vsc: give the number of arguments to - cclause() in case there is a overflow */ + yamop *code_adr = Yap_cclause(tn, 2, mod, tn); /* vsc: give the number of + arguments to cclause() in case there is a overflow + */ if (LOCAL_ErrorMessage) { return false; } @@ -4687,10 +4737,11 @@ void Yap_InitCdMgr(void) { Yap_InitCPred("$is_exo", 2, p_is_exo, TestPredFlag | SafePredFlag); Yap_InitCPred("$owner_file", 3, owner_file, SafePredFlag); Yap_InitCPred("$set_owner_file", 3, p_set_owner_file, SafePredFlag); - Yap_InitCPred("$mk_d", 2, p_mk_d, SafePredFlag); + Yap_InitCPred("$mk_dynamic", 2, mk_dynamic, SafePredFlag); + Yap_InitCPred("$new_meta_pred", 2, new_meta_pred, SafePredFlag); Yap_InitCPred("$sys_export", 2, p_sys_export, TestPredFlag | SafePredFlag); Yap_InitCPred("$pred_exists", 2, p_pred_exists, TestPredFlag | SafePredFlag); - Yap_InitCPred("$number_of_clauses", 3, p_number_of_clauses, + Yap_InitCPred("$number_of_clauses", 3, number_of_clauses, SafePredFlag | SyncPredFlag); Yap_InitCPred("$undefined", 2, p_undefined, SafePredFlag | TestPredFlag); Yap_InitCPred("$undefp_handler", 2, undefp_handler, @@ -4703,14 +4754,16 @@ void Yap_InitCdMgr(void) { SafePredFlag | SyncPredFlag); Yap_InitCPred("$kill_dynamic", 2, p_kill_dynamic, SafePredFlag | SyncPredFlag); - Yap_InitCPred("$new_multifile", 3, p_new_multifile, - SafePredFlag | SyncPredFlag); + Yap_InitCPred("$new_multifile", 2, new_multifile, + SafePredFlag | SyncPredFlag | HiddenPredFlag); Yap_InitCPred("$is_multifile", 2, p_is_multifile, TestPredFlag | SafePredFlag); Yap_InitCPred("$new_system_predicate", 3, new_system_predicate, SafePredFlag | SyncPredFlag); Yap_InitCPred("$is_system_predicate", 2, p_is_system_predicate, TestPredFlag | SafePredFlag); + Yap_InitCPred("$is_opaque_predicate", 2, p_is_opaque_predicate, + TestPredFlag | SafePredFlag); Yap_InitCPred("$new_discontiguous", 3, p_new_discontiguous, SafePredFlag | SyncPredFlag); Yap_InitCPred("$is_discontiguous", 2, p_is_discontiguous, @@ -4734,8 +4787,8 @@ void Yap_InitCdMgr(void) { Yap_InitCPred("$set_pred_module", 2, p_set_pred_module, SafePredFlag); Yap_InitCPred("$set_pred_owner", 2, p_set_pred_owner, SafePredFlag); Yap_InitCPred("$hide_predicate", 2, hide_predicate, SafePredFlag); - Yap_InitCPred("$stash_predicate", 2, p_stash_predicate, SafePredFlag); - Yap_InitCPred("$hidden_predicate", 2, p_hidden_predicate, SafePredFlag); + Yap_InitCPred("$stash_predicate", 2, stash_predicate, SafePredFlag); + Yap_InitCPred("$hidden_predicate", 2, hidden_predicate, SafePredFlag); Yap_InitCPred("$log_update_clause", 4, p_log_update_clause, SyncPredFlag); Yap_InitCPred("$continue_log_update_clause", 5, p_continue_log_update_clause, SafePredFlag | SyncPredFlag); diff --git a/C/cmppreds.c b/C/cmppreds.c index faa0970c5..0e066d7a3 100644 --- a/C/cmppreds.c +++ b/C/cmppreds.c @@ -16,6 +16,18 @@ * * *************************************************************************/ +/** + * @file cmppreds.c + * @author VITOR SANTOS COSTA + * @date Mon Apr 30 09:35:58 2018 + * + * @brief comparison + * + * @namespace prolog + * + * + * + */ /// @file cmppreds.c /** @@ -540,7 +552,7 @@ Int p_compare(USES_REGS1) { /* compare(?Op,?T1,?T2) */ return Yap_unify_constant(ARG1, MkAtomTerm(p)); } -/** @pred _X_ \== _Y_ is iso +/** @pred X \== Y is iso Terms _X_ and _Y_ are not strictly identical. */ @@ -548,7 +560,7 @@ static Int a_noteq(Term t1, Term t2) { return (compare(t1, t2) != 0); } static Int a_gen_lt(Term t1, Term t2) { return (compare(t1, t2) < 0); } -/** @pred _X_ @=< _Y_ is iso +/** @pred X @=< Y is iso Term _X_ does not follow term _Y_ in the standard order. @@ -556,14 +568,14 @@ Term _X_ does not follow term _Y_ in the standard order. */ static Int a_gen_le(Term t1, Term t2) { return (compare(t1, t2) <= 0); } -/** @pred _X_ @> _Y_ is iso +/** @pred X @> Y is iso Term _X_ does not follow term _Y_ in the standard order */ static Int a_gen_gt(Term t1, Term t2) { return compare(t1, t2) > 0; } -/** @pred _X_ @>= _Y_ is iso +/** @pred X @>= Y is iso Term _X_ does not precede term _Y_ in the standard order. */ @@ -711,7 +723,7 @@ static Int p_acomp(USES_REGS1) { /* $a_compare(?R,+X,+Y) */ } /** - @pred +_X_ =:= _Y_ is iso + @pred +X '=:=' Y is iso Equality of arithmetic expressions The value of the expression _X_ is equal to the value of expression _Y_. @@ -778,7 +790,7 @@ static Int a_gt(Term t1, Term t2) { /* A > B */ } /** - @pred +_X_ >= +_Y_ is iso + @pred +X >= +Y is iso Greater than or equal to arithmetic expressions The value of the expression _X_ is greater than or equal to the @@ -791,7 +803,7 @@ static Int a_ge(Term t1, Term t2) { /* A >= B */ } /** - @pred +_X_ \< +_Y_ is iso + @pred +X < +Y is iso Lesser than arithmetic expressions The value of the expression _X_ is less than the value of expression @@ -806,7 +818,7 @@ static Int a_lt(Term t1, Term t2) { /* A < B */ /** * - @pred _X_ =< + _Y_ + @pred +X =< +Y Lesser than or equal to arithmetic expressions diff --git a/C/compiler.c b/C/compiler.c index 04bbe70b6..dc301c997 100644 --- a/C/compiler.c +++ b/C/compiler.c @@ -719,7 +719,7 @@ restart: dest = Yap_emit_extra_size(blob_op, sz / CellSize, sz, &cglobs->cint); /* copy the bignum */ - memcpy(dest, src, sz); + memmove(dest, src, sz); /* note that we don't need to copy size info, unless we wanted to garbage collect clauses ;-) */ cglobs->cint.icpc = cglobs->cint.cpc; @@ -758,7 +758,7 @@ restart: dest = Yap_emit_extra_size(blob_op, sz / CellSize, sz, &cglobs->cint); /* copy the bignum */ - memcpy(dest, src, sz); + memmove(dest, src, sz); /* note that we don't need to copy size info, unless we wanted to garbage collect clauses ;-) */ cglobs->cint.icpc = cglobs->cint.cpc; @@ -3513,14 +3513,20 @@ yamop *Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, LOCAL_ErrorMessage = "clause head should be atom or compound term"; return (0); } else { - + loop: /* find out which predicate we are compiling for */ if (IsAtomTerm(head)) { Atom ap = AtomOfTerm(head); cglobs.cint.CurrentPred = RepPredProp(PredPropByAtom(ap, mod)); } else { + Functor f = FunctorOfTerm(head); + if (f == FunctorModule) { + mod = ArgOfTerm(1,head); + head = ArgOfTerm(2,head); + goto loop; + } cglobs.cint.CurrentPred = - RepPredProp(PredPropByFunc(FunctorOfTerm(head), mod)); + RepPredProp(PredPropByFunc(f, mod)); } /* insert extra instructions to count calls */ PELOCK(52, cglobs.cint.CurrentPred); @@ -3569,7 +3575,7 @@ yamop *Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, cglobs.space_op->rnd1 = cglobs.space_used; #ifdef DEBUG - if (GLOBAL_Option['g' - 96]) + if (GLOBAL_Option['g' - 96] ) Yap_ShowCode(&cglobs.cint); #endif } else { diff --git a/C/computils.c b/C/computils.c index 3bf9ab27a..ec70e1ef0 100644 --- a/C/computils.c +++ b/C/computils.c @@ -60,13 +60,15 @@ static char SccsId[] = "%W% %G%"; #include "Yap.h" #include "Yatom.h" #include "YapHeap.h" +#define COMPILER_NAMES 1 +#include "YapCompile.h" +#undef COMPILER_NAMES #include "YapCompile.h" #include "yapio.h" #if HAVE_STRING_H #include #endif - /* * The compiler creates an instruction chain which will be assembled after * afterwards @@ -545,7 +547,6 @@ write_functor(Functor f) } } -char *opDesc[] = { mklist(f_arr) }; static void send_pred(PredEntry *p) { @@ -720,7 +721,7 @@ ShowOp (compiler_vm_op ic, const char *f, struct PSEUDO *cpc) Yap_DebugPlWrite (MkIntTerm (rn & 1)); break; case 'w': - Yap_DebugPlWrite (arg); + Yap_DebugPlWrite (MkIntTerm(arg)); break; case 'o': Yap_DebugPlWrite ((Term) * cptr++); diff --git a/C/control_absmi_insts.h b/C/control_absmi_insts.h index ba532782d..59469248e 100644 --- a/C/control_absmi_insts.h +++ b/C/control_absmi_insts.h @@ -1,5 +1,7 @@ /************************************************************************\ - * Cut & Commit Instructions * + * Cut & Commit Inst + +ructions * \************************************************************************/ #ifdef INDENT_CODE @@ -194,18 +196,18 @@ /* Macros for stack trimming */ /* execute Label */ - BOp(execute, pp); + BOp(execute, Osbpp); { PredEntry *pt0; CACHE_Y_AS_ENV(YREG); - pt0 = PREG->y_u.pp.p; + pt0 = PREG->y_u.Osbpp.p; #ifndef NO_CHECKING check_stack(NoStackExecute, HR); goto skip_do_execute; #endif do_execute: FETCH_Y_FROM_ENV(YREG); - pt0 = PREG->y_u.pp.p; + pt0 = PREG->y_u.Osbpp.p; skip_do_execute: #ifdef LOW_LEVEL_TRACER if (Yap_do_low_level_trace) { @@ -244,17 +246,17 @@ /* dexecute Label */ /* joint deallocate and execute */ - BOp(dexecute, pp); + BOp(dexecute, Osbpp); #ifdef LOW_LEVEL_TRACER if (Yap_do_low_level_trace) - low_level_trace(enter_pred,PREG->y_u.pp.p,XREGS+1); + low_level_trace(enter_pred,PREG->y_u.Osbpp.p,XREGS+1); #endif /* LOW_LEVEL_TRACER */ CACHE_Y_AS_ENV(YREG); { PredEntry *pt0; CACHE_A1(); - pt0 = PREG->y_u.pp.p; + pt0 = PREG->y_u.Osbpp.p; #ifndef NO_CHECKING /* check stacks */ check_stack(NoStackDExecute, HR); @@ -262,7 +264,7 @@ #endif continue_dexecute: FETCH_Y_FROM_ENV(YREG); - pt0 = PREG->y_u.pp.p; + pt0 = PREG->y_u.Osbpp.p; skip_dexecute: #ifdef DEPTH_LIMIT if (DEPTH <= MkIntTerm(1)) {/* I assume Module==0 is primitives */ @@ -425,6 +427,8 @@ Op(deallocate, p); CACHE_Y_AS_ENV(YREG); + // do this before checking + SREG = YREG; check_trail(TR); #ifndef NO_CHECKING /* check stacks */ @@ -433,7 +437,6 @@ PREG = NEXTOP(PREG, p); /* other instructions do depend on S being set by deallocate :-( */ - SREG = YREG; CPREG = (yamop *) ENV_YREG[E_CP]; ENV = ENV_YREG = (CELL *) ENV_YREG[E_E]; #ifdef DEPTH_LIMIT diff --git a/C/dbase.c b/C/dbase.c index 195cf6d72..db253b349 100644 --- a/C/dbase.c +++ b/C/dbase.c @@ -18,83 +18,94 @@ static char SccsId[] = "%W% %G%"; #endif +/** + * @file dbase.c + * @author VITOR SANTOS COSTA + * @date Mon Apr 30 09:36:46 2018 + * + * @brief record and other forms of storing terms. + * + */ + + /** @defgroup Internal_Database Internal Data Base -@ingroup builtins -@{ - -Some programs need global information for, e.g. counting or collecting -data obtained by backtracking. As a rule, to keep this information, the -internal data base should be used instead of asserting and retracting -clauses (as most novice programmers do), . -In YAP (as in some other Prolog systems) the internal data base (i.d.b. -for short) is faster, needs less space and provides a better insulation of -program and data than using asserted/retracted clauses. -The i.d.b. is implemented as a set of terms, accessed by keys that -unlikely what happens in (non-Prolog) data bases are not part of the -term. Under each key a list of terms is kept. References are provided so that -terms can be identified: each term in the i.d.b. has a unique reference -(references are also available for clauses of dynamic predicates). - -There is a strong analogy between the i.d.b. and the way dynamic -predicates are stored. In fact, the main i.d.b. predicates might be -implemented using dynamic predicates: - -~~~~~ -recorda(X,T,R) :- asserta(idb(X,T),R). -recordz(X,T,R) :- assertz(idb(X,T),R). -recorded(X,T,R) :- clause(idb(X,T),R). -~~~~~ -We can take advantage of this, the other way around, as it is quite -easy to write a simple Prolog interpreter, using the i.d.b.: - -~~~~~ -asserta(G) :- recorda(interpreter,G,_). -assertz(G) :- recordz(interpreter,G,_). -retract(G) :- recorded(interpreter,G,R), !, erase(R). -call(V) :- var(V), !, fail. -call((H :- B)) :- !, recorded(interpreter,(H :- B),_), call(B). -call(G) :- recorded(interpreter,G,_). -~~~~~ -In YAP, much attention has been given to the implementation of the -i.d.b., especially to the problem of accelerating the access to terms kept in -a large list under the same key. Besides using the key, YAP uses an internal -lookup function, transparent to the user, to find only the terms that might -unify. For instance, in a data base containing the terms - -~~~~~ -b -b(a) -c(d) -e(g) -b(X) -e(h) -~~~~~ - -stored under the key k/1, when executing the query - -~~~~~ -:- recorded(k(_),c(_),R). -~~~~~ - -`recorded` would proceed directly to the third term, spending almost the -time as if `a(X)` or `b(X)` was being searched. -The lookup function uses the functor of the term, and its first three -arguments (when they exist). So, `recorded(k(_),e(h),_)` would go -directly to the last term, while `recorded(k(_),e(_),_)` would find -first the fourth term, and then, after backtracking, the last one. - -This mechanism may be useful to implement a sort of hierarchy, where -the functors of the terms (and eventually the first arguments) work as -secondary keys. - -In the YAP's i.d.b. an optimized representation is used for -terms without free variables. This results in a faster retrieval of terms -and better space usage. Whenever possible, avoid variables in terms in terms -stored in the i.d.b. - - - -*/ + * + * @ingroup builtins + * @{ + * + * Some programs need global information for, e.g. counting or collecting + * data obtained by backtracking. As a rule, to keep this information, the + * internal data base should be used instead of asserting and retracting + * clauses (as most novice programmers do), . + * In YAP (as in some other Prolog systems) the internal data base (i.d.b. + * for short) is faster, needs less space and provides a better insulation of + * program and data than using asserted/retracted clauses. + * The i.d.b. is implemented as a set of terms, accessed by keys that + * unlikely what happens in (non-Prolog) data bases are not part of the + * term. Under each key a list of terms is kept. References are provided so that + * terms can be identified: each term in the i.d.b. has a unique reference + * (references are also available for clauses of dynamic predicates). + * + * There is a strong analogy between the i.d.b. and the way dynamic + * predicates are stored. In fact, the main i.d.b. predicates might be + * implemented using dynamic predicates: + * + * ~~~~~ + * recorda(X,T,R) :- asserta(idb(X,T),R). + * recordz(X,T,R) :- assertz(idb(X,T),R). + * recorded(X,T,R) :- clause(idb(X,T),R). + * ~~~~~ + * We can take advantage of this, the other way around, as it is quite + * easy to write a simple Prolog interpreter, using the i.d.b.: + * + * ~~~~~ + * asserta(G) :- recorda(interpreter,G,_). + * assertz(G) :- recordz(interpreter,G,_). + * retract(G) :- recorded(interpreter,G,R), !, erase(R). + * call(V) :- var(V), !, fail. + * call((H :- B)) :- !, recorded(interpreter,(H :- B),_), call(B). + * call(G) :- recorded(interpreter,G,_). + * ~~~~~ + * In YAP, much attention has been given to the implementation of the + * i.d.b., especially to the problem of accelerating the access to terms kept in + * a large list under the same key. Besides using the key, YAP uses an internal + * lookup function, transparent to the user, to find only the terms that might + * unify. For instance, in a data base containing the terms + * + * ~~~~~ + * b + * b(a) + * c(d) + * e(g) + * b(X) + * e(h) + * ~~~~~ + * + * stored under the key k/1, when executing the query + * + * ~~~~~ + * :- recorded(k(_),c(_),R). + * ~~~~~ + * + * `recorded` would proceed directly to the third term, spending almost the + * time as if `a(X)` or `b(X)` was being searched. + * The lookup function uses the functor of the term, and its first three + * arguments (when they exist). So, `recorded(k(_),e(h),_)` would go + * directly to the last term, while `recorded(k(_),e(_),_)` would find + * first the fourth term, and then, after backtracking, the last one. + * + * This mechanism may be useful to implement a sort of hierarchy, where + * the functors of the terms (and eventually the first arguments) work as + * secondary keys. + * + * In the YAP's i.d.b. an optimized representation is used for + * terms without free variables. This results in a faster retrieval of terms + * and better space usage. Whenever possible, avoid variables in terms in terms + * stored in the i.d.b. + * + * + * + */ #include "Yap.h" #include "attvar.h" @@ -259,7 +270,7 @@ static Int p_rcdz(USES_REGS1); static Int p_rcdzp(USES_REGS1); static Int p_drcdap(USES_REGS1); static Int p_drcdzp(USES_REGS1); -static Term GetDBTerm(DBTerm *, int src CACHE_TYPE); +static Term GetDBTerm(const DBTerm *, int src CACHE_TYPE); static DBProp FetchDBPropFromKey(Term, int, int, char *); static Int i_recorded(DBProp, Term CACHE_TYPE); static Int c_recorded(int CACHE_TYPE); @@ -267,8 +278,8 @@ static Int co_rded(USES_REGS1); static Int in_rdedp(USES_REGS1); static Int co_rdedp(USES_REGS1); static Int p_first_instance(USES_REGS1); -static void ErasePendingRefs(DBTerm *CACHE_TYPE); -static void RemoveDBEntry(DBRef CACHE_TYPE); +static void ErasePendingRefs(const DBTerm *CACHE_TYPE); +static void RemoveDBEntry(const DBRef CACHE_TYPE); static void EraseLogUpdCl(LogUpdClause *); static void MyEraseClause(DynamicClause *CACHE_TYPE); static void PrepareToEraseClause(DynamicClause *, DBRef); @@ -292,10 +303,10 @@ static void sf_include(SFKeep *); #endif static Int p_init_queue(USES_REGS1); static Int p_enqueue(USES_REGS1); -static void keepdbrefs(DBTerm *CACHE_TYPE); +static void keepdbrefs(const DBTerm *ref USES_REGS); static Int p_dequeue(USES_REGS1); static void ErDBE(DBRef CACHE_TYPE); -static void ReleaseTermFromDB(DBTerm *CACHE_TYPE); +static void ReleaseTermFromDB(const DBTerm *ref USES_REGS); static PredEntry *new_lu_entry(Term); static PredEntry *new_lu_int_key(Int); static PredEntry *find_lu_entry(Term); @@ -418,12 +429,6 @@ static Int cmpclls(CELL *a, CELL *b, Int n) { return TRUE; } -#if !THREADS -int Yap_DBTrailOverflow() { - return ((CELL *)LOCAL_s_dbg->lr > (CELL *)LOCAL_s_dbg->tofref - 2048); -} -#endif - /* get DB entry for ap/arity; */ static Prop FindDBPropHavingLock(AtomEntry *ae, int CodeDB, unsigned int arity, Term dbmod) { @@ -633,7 +638,7 @@ static CELL *copy_double(CELL *st, CELL *pt) { static CELL *copy_string(CELL *st, CELL *pt) { UInt sz = pt[1] + 3; /* first thing, store a link to the list before we move on */ - memcpy(st, pt, sizeof(CELL) * sz); + memmove(st, pt, sizeof(CELL) * sz); /* now reserve space */ return st + sz; } @@ -647,7 +652,7 @@ static CELL *copy_big_int(CELL *st, CELL *pt) { st[0] = (CELL)FunctorBigInt; st[1] = pt[1]; /* then the actual number */ - memcpy((void *)(st + 2), (void *)(pt + 2), sz); + memmove((void *)(st + 2), (void *)(pt + 2), sz); st = st + 2 + sz / CellSize; /* then the tail for gc */ st[0] = EndSpecials; @@ -959,7 +964,7 @@ loop: if (HR + sz >= ASP) { goto error2; } - memcpy((void *)HR, (void *)(to_visit_base), sz * sizeof(CELL *)); + memmove((void *)HR, (void *)(to_visit_base), sz * sizeof(CELL *)); to_visit_base = (CELL **)HR; to_visit = to_visit_base + sz; } @@ -1402,12 +1407,14 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, SMALLUNSGN flag; int NOfLinks = 0; /* place DBRefs in ConsultStack */ - DBRef *TmpRefBase = (DBRef *)LOCAL_TrailTop; + DBRef *TmpRefBase; CELL *CodeAbs; /* how much code did we find */ int vars_found = FALSE; yap_error_number oerr = LOCAL_Error_TYPE; - LOCAL_Error_TYPE = YAP_NO_ERROR; + retry_record: + LOCAL_Error_TYPE = YAP_NO_ERROR; + TmpRefBase = (DBRef *)LOCAL_TrailTop; if (p == NULL) { if (IsVarTerm(Tm)) { #ifdef COROUTINING @@ -1481,7 +1488,7 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, /* attachment */ if (IsVarTerm(Tm)) { tt = (CELL)(ppt0->Contents); - ntp = MkDBTerm(VarOfTerm(Tm), VarOfTerm(Tm), ntp0, ntp0 + 1, ntp0 - 1, + ntp = MkDBTerm(VarOfTerm(Tm), VarOfTerm(Tm), ntp0, ntp0 + 1, ntp0 - 1, &attachments, &vars_found, dbg); if (ntp == NULL) { Yap_ReleasePreAllocCodeSpace((ADDR)pp0); @@ -1506,7 +1513,7 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, } else { unsigned int arity; Functor fun; - + vars_found = true; tt = AbsAppl(ppt0->Contents); /* we need to store the functor manually */ fun = FunctorOfTerm(Tm); @@ -1516,13 +1523,37 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, ntp = copy_double(ntp0, RepAppl(Tm)); break; case (CELL)FunctorString: - ntp = copy_string(ntp0, RepAppl(Tm)); + { + UInt sz = 1024+sizeof(CELL)*(3 + RepAppl(Tm)[1]); + if (sz > + (char*)AuxSp-(char*)ppt0) { + LOCAL_Error_Size = sz; + if (!Yap_ExpandPreAllocCodeSpace(LOCAL_Error_Size, NULL, TRUE)) { + Yap_Error(RESOURCE_ERROR_AUXILIARY_STACK, TermNil, LOCAL_ErrorMessage); + return NULL; + } + goto retry_record; + } + } + ntp = copy_string(ntp0, RepAppl(Tm)); break; case (CELL)FunctorDBRef: Yap_ReleasePreAllocCodeSpace((ADDR)pp0); return CreateDBWithDBRef(Tm, p, dbg); #ifdef USE_GMP case (CELL)FunctorBigInt: + { + UInt sz = 1024+sizeof(CELL)*Yap_SizeOfBigInt(Tm); + if (sz > + (char*)AuxSp-(char*)ppt0) { + LOCAL_Error_Size = sizeof(CELL)*(3 + RepAppl(Tm)[1]); + if (!Yap_ExpandPreAllocCodeSpace(LOCAL_Error_Size, NULL, TRUE)) { + Yap_Error(RESOURCE_ERROR_AUXILIARY_STACK, TermNil, LOCAL_ErrorMessage); + return NULL; + } + goto retry_record; + } + } ntp = copy_big_int(ntp0, RepAppl(Tm)); break; #endif @@ -1649,7 +1680,7 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, nar = ppt->Contents + Unsigned(NOfCells); } woar = (link_entry *)nar; - memcpy((void *)woar, (const void *)dbg->LinkAr, + memmove((void *)woar, (const void *)dbg->LinkAr, (size_t)(NOfLinks * sizeof(link_entry))); woar += NOfLinks; #ifdef ALIGN_LONGS @@ -1709,7 +1740,6 @@ static DBRef record(int Flag, Term key, Term t_data, Term t_code USES_REGS) { int needs_vars; struct db_globs dbg; - LOCAL_s_dbg = &dbg; dbg.found_one = NULL; #ifdef SFUNC FathersPlace = NIL; @@ -1785,7 +1815,6 @@ static DBRef record_at(int Flag, DBRef r0, Term t_data, Term t_code USES_REGS) { int needs_vars; struct db_globs dbg; - LOCAL_s_dbg = &dbg; #ifdef SFUNC FathersPlace = NIL; #endif @@ -1870,7 +1899,6 @@ static LogUpdClause *new_lu_db_entry(Term t, PredEntry *pe) { if (!pe || !(pe->PredFlags & ThreadLocalPredFlag)) d_flag |= InQueue; #endif - LOCAL_s_dbg = &dbg; ipc = NEXTOP(((LogUpdClause *)NULL)->ClCode, e); if ((x = (DBTerm *)CreateDBStruct(t, NULL, d_flag, &needs_vars, (UInt)ipc, &dbg)) == NULL) { @@ -2502,7 +2530,7 @@ Int Yap_unify_immediate_ref(DBRef ref USES_REGS) { } } -static Term GetDBTerm(DBTerm *DBSP, int src USES_REGS) { +static Term GetDBTerm(const DBTerm *DBSP, int src USES_REGS) { Term t = DBSP->Entry; if (IsVarTerm(t) @@ -3762,7 +3790,7 @@ static Int p_heap_space_info(USES_REGS1) { * This is called when we are erasing a data base clause, because we may have * pending references */ -static void ErasePendingRefs(DBTerm *entryref USES_REGS) { +static void ErasePendingRefs(const DBTerm *entryref USES_REGS) { DBRef *cp; DBRef ref; @@ -3923,11 +3951,11 @@ static void complete_lu_erase(LogUpdClause *clau) { static void EraseLogUpdCl(LogUpdClause *clau) { PredEntry *ap; - ap = clau->ClPred; /* no need to erase what has been erased */ if (!(clau->ClFlags & ErasedMask)) { - /* get ourselves out of the list */ + clau->ClFlags |= ErasedMask; +/* get ourselves out of the list */ if (clau->ClNext != NULL) { clau->ClNext->ClPrev = clau->ClPrev; } @@ -3951,7 +3979,6 @@ static void EraseLogUpdCl(LogUpdClause *clau) { } ap->cs.p_code.NOfClauses--; } - clau->ClFlags |= ErasedMask; #ifndef THREADS { LogUpdClause *er_head = DBErasedList; @@ -4894,17 +4921,21 @@ static Int cont_current_key_integer(USES_REGS1) { return Yap_unify(term, ARG1) && Yap_unify(term, ARG2); } -Term Yap_FetchTermFromDB(DBTerm *ref) { +Term Yap_FetchTermFromDB(const void *ref) { CACHE_REGS + if (ref == NULL) + return 0; return GetDBTerm(ref, FALSE PASS_REGS); } -Term Yap_FetchClauseTermFromDB(DBTerm *ref) { +Term Yap_FetchClauseTermFromDB(const void *ref) { CACHE_REGS + if (ref == NULL) + return 0; return GetDBTerm(ref, TRUE PASS_REGS); } -Term Yap_PopTermFromDB(DBTerm *ref) { +Term Yap_PopTermFromDB(const void *ref) { CACHE_REGS Term t = GetDBTerm(ref, FALSE PASS_REGS); @@ -4918,7 +4949,6 @@ static DBTerm *StoreTermInDB(Term t, int nargs USES_REGS) { int needs_vars; struct db_globs dbg; - LOCAL_s_dbg = &dbg; LOCAL_Error_Size = 0; while ((x = (DBTerm *)CreateDBStruct(t, (DBProp)NULL, InQueue, &needs_vars, 0, &dbg)) == NULL) { @@ -4949,7 +4979,6 @@ DBTerm *Yap_StoreTermInDBPlusExtraSpace(Term t, UInt extra_size, UInt *sz) { struct db_globs dbg; DBTerm *o; - LOCAL_s_dbg = &dbg; o = (DBTerm *)CreateDBStruct(t, (DBProp)NULL, InQueue, &needs_vars, extra_size, &dbg); *sz = dbg.sz; @@ -5122,7 +5151,7 @@ static Int p_enqueue_unlocked(USES_REGS1) { entry itself is still accessible from a trail entry, so we could not remove the target entry, */ -static void keepdbrefs(DBTerm *entryref USES_REGS) { +static void keepdbrefs (const DBTerm *entryref USES_REGS) { DBRef *cp; DBRef ref; @@ -5281,7 +5310,7 @@ static Int p_resize_int_keys(USES_REGS1) { return resize_int_keys(IntegerOfTerm(t1)); } -static void ReleaseTermFromDB(DBTerm *ref USES_REGS) { +static void ReleaseTermFromDB(const DBTerm *ref USES_REGS) { if (!ref) return; keepdbrefs(ref PASS_REGS); @@ -5289,7 +5318,7 @@ static void ReleaseTermFromDB(DBTerm *ref USES_REGS) { FreeDBSpace((char *)ref); } -void Yap_ReleaseTermFromDB(DBTerm *ref) { +void Yap_ReleaseTermFromDB(const void *ref) { CACHE_REGS ReleaseTermFromDB(ref PASS_REGS); } diff --git a/C/dlmalloc.c b/C/dlmalloc.c index e7ddcb1dd..d522ac825 100644 --- a/C/dlmalloc.c +++ b/C/dlmalloc.c @@ -1978,7 +1978,7 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes; assert(ncopies >= 3); if (ncopies > 9) - memcpy(d, s, copysize); + memmove(d, s, copysize); else { *(d+0) = *(s+0); @@ -2077,7 +2077,7 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes; /* Must alloc, copy, free. */ newmem = mALLOc(nb - MALLOC_ALIGN_MASK); if (newmem != 0) { - memcpy(newmem, oldmem, oldsize - 2*SIZE_SZ); + memmove(newmem, oldmem, oldsize - 2*SIZE_SZ); fREe(oldmem); } } diff --git a/C/errors.c b/C/errors.c index 766ed7558..11d7c2e23 100755 --- a/C/errors.c +++ b/C/errors.c @@ -17,6 +17,7 @@ #include "absmi.h" #include "yapio.h" +#include "YapStreams.h" #if HAVE_STDARG_H #include #endif @@ -32,59 +33,291 @@ #endif #include "Foreign.h" +#define set_key_b(k, ks, q, i, t) \ + if (strcmp(ks, q) == 0) { \ + i->k = ( t == TermTrue ? true : false); \ + return i->k || t == TermFalse; \ + } + +#define set_key_i(k, ks, q, i, t) \ + if (strcmp(ks, q) == 0) { \ + i->k = IsIntegerTerm(t) ? IntegerOfTerm(t) : 0; \ + return IsIntegerTerm(t); \ + } + +#define set_key_s(k, ks, q, i, t) \ + if (strcmp(ks, q) == 0) { \ + const char *s = IsAtomTerm(t) ? RepAtom(AtomOfTerm(t))->StrOfAE \ + : IsStringTerm(t) ? StringOfTerm(t) : NULL; \ + if (s) { \ + char *tmp = calloc(1,strlen(s) + 1); \ + strcpy(tmp, s); \ + i->k = tmp; \ + } \ + return i->k != NULL; \ + } + +static bool setErr(const char *q, yap_error_descriptor_t *i, Term t) { + set_key_i(errorNo, "errorNo", q, i, t); + set_key_i(errorClass, "errorClass", q, i, t); + set_key_s(errorAsText, "errorAsText", q, i, t); + set_key_s(errorGoal, "errorGoal", q, i, t); + set_key_s(classAsText, "classAsText", q, i, t); + set_key_i(errorLine, "errorLine", q, i, t); + set_key_s(errorFunction, "errorFunction", q, i, t); + set_key_s(errorFile, "errorFile", q, i, t); + set_key_i(prologPredLine, "prologPredLine", q, i, t); + set_key_s(prologPredName, "prologPredName", q, i, t); + set_key_i(prologPredArity, "prologPredArity", q, i, t); + set_key_s(prologPredModule, "prologPredModule", q, i, t); + set_key_s(prologPredFile, "prologPredFile", q, i, t); + set_key_i(parserPos, "parserPos", q, i, t); + set_key_i(parserLine, "parserLine", q, i, t); + set_key_i(parserFirstLine, "parserFirstLine", q, i, t); + set_key_i(parserLastLine, "parserLastLine", q, i, t); + set_key_s(parserTextA, "parserTextA", q, i, t); + set_key_s(parserTextB, "parserTextB", q, i, t); + set_key_s(parserFile, "parserFile", q, i, t); + set_key_b(parserReadingCode, "parserReadingcode", q, i, t); + set_key_b(prologConsulting, "prologConsulting", q, i, t); + set_key_s(culprit, "culprit", q, i, t); + set_key_s(errorMsg, "errorMsg", q, i, t); + set_key_i(errorMsgLen, "errorMsgLen", q, i, t); + return false; +} + +#define query_key_b(k, ks, q, i) \ +if (strcmp(ks, q) == 0) { \ + return i->k ? TermTrue : TermFalse; \ + } + +#define query_key_i(k, ks, q, i) \ +if (strcmp(ks, q) == 0) { \ + return MkIntegerTerm(i->k); \ + } + +#define query_key_s(k, ks, q, i) \ +if (strcmp(ks, q) == 0 ) \ +{ if (i->k) return MkAtomTerm(Yap_LookupAtom(i->k)); else return TermNil; } + + +#define query_key_t(k, ks, q, i) \ + if (strcmp(ks, q) == 0) { \ + if (i->k == NULL) return TermNil; \ + Term t; if((t = Yap_BufferToTerm(i->k, TermNil) ) == 0 ) return TermNil; return t; } + +static Term queryErr(const char *q, yap_error_descriptor_t *i) { + query_key_i(errorNo, "errorNo", q, i); + query_key_i(errorClass, "errorClass", q, i); + query_key_s(errorAsText, "errorAsText", q, i); + query_key_t(errorGoal, "errorGoal", q, i); + query_key_s(classAsText, "classAsText", q, i); + query_key_i(errorLine, "errorLine", q, i); + query_key_s(errorFunction, "errorFunction", q, i); + query_key_s(errorFile, "errorFile", q, i); + query_key_i(prologPredLine, "prologPredLine", q, i); + query_key_s(prologPredName, "prologPredName", q, i); + query_key_i(prologPredArity, "prologPredArity", q, i); + query_key_s(prologPredModule, "prologPredModule", q, i); + query_key_s(prologPredFile, "prologPredFile", q, i); + query_key_i(parserPos, "parserPos", q, i); + query_key_i(parserLine, "parserLine", q, i); + query_key_i(parserFirstLine, "parserFirstLine", q, i); + query_key_i(parserLastLine, "parserLastLine", q, i); + query_key_s(parserTextA, "parserTextA", q, i); + query_key_s(parserTextB, "parserTextB", q, i); + query_key_s(parserFile, "parserFile", q, i); + query_key_b(parserReadingCode, "parserReadingCode", q, i); + query_key_b(prologConsulting, "prologConsulting", q, i); + query_key_t(culprit, "culprit", q, i); + query_key_s(errorMsg, "errorMsg", q, i); + query_key_i(errorMsgLen, "errorMsgLen", q, i); + return TermNil; +} + +static void print_key_b(const char *key, bool v) { + const char *b = v ? "true" : "false"; + fprintf(stderr, "%s: %s\n", key, b); +} + +static void print_key_i(const char *key, YAP_Int v) { + fprintf(stderr, "%s: " Int_FORMAT "\n", key, v); +} + +static void print_key_s(const char *key, const char *v) { + fprintf(stderr, "%s: %s\n", key, v); +} + +static void printErr(yap_error_descriptor_t *i) { + + if (i->errorNo == YAP_NO_ERROR) { + return; + } + print_key_i("errorNo", i->errorNo); + print_key_i("errorClass", (i->errorClass = Yap_errorClass(i->errorNo))); + print_key_s("errorAsText", (i->errorAsText=Yap_errorName(i->errorNo) ) ); + print_key_s("errorGoal", i->errorGoal); + print_key_s("classAsText", (i->classAsText=Yap_errorClassName(i->errorClass))); + print_key_i("errorLine", i->errorLine); + print_key_s("errorFunction", i->errorFunction); + print_key_s("errorFile", i->errorFile); + print_key_i("prologPredLine", i->prologPredLine); + print_key_s("prologPredName", i->prologPredName); + print_key_i("prologPredArity", i->prologPredArity); + print_key_s("prologPredModule", i->prologPredModule); + print_key_s("prologPredFile", i->prologPredFile); + print_key_i("parserPos", i->parserPos); + print_key_i("parserLine", i->parserLine); + print_key_i("parserFirstLine", i->parserFirstLine); + print_key_i("parserLastLine", i->parserLastLine); + print_key_s("parserTextA", i->parserTextA); + print_key_s("parserTextB", i->parserTextB); + print_key_s("parserFile", i->parserFile); + print_key_b("parserReadingCode", i->parserReadingCode); + print_key_b("prologConsulting", i->prologConsulting); + print_key_s("culprit", i->culprit); + if (i->errorMsgLen) { + print_key_s("errorMsg", i->errorMsg); + print_key_i("errorMsgLen", i->errorMsgLen); + } +} + +static YAP_Term add_key_b(const char *key, bool v, YAP_Term o0) { + YAP_Term tkv[2]; + tkv[1] = v ? TermTrue : TermFalse; + tkv[0] = MkStringTerm(key); + Term node = Yap_MkApplTerm(FunctorEq, 2, tkv); + return MkPairTerm(node, o0); +} + +static YAP_Term add_key_i(const char *key, YAP_Int v, YAP_Term o0) { + YAP_Term tkv[2]; + tkv[1] = MkIntegerTerm(v), tkv[0] = MkStringTerm(key); + Term node = Yap_MkApplTerm(FunctorEq, 2, tkv); + return MkPairTerm(node, o0); +} + +static YAP_Term add_key_s(const char *key, const char *v, YAP_Term o0) { + Term tkv[2]; + if (!v || v[0] == '\0') + return o0; + tkv[1] = MkStringTerm(v), tkv[0] = MkStringTerm(key); + Term node = Yap_MkApplTerm(FunctorEq, 2, tkv); + return MkPairTerm(node, o0); +} + +static Term err2list(yap_error_descriptor_t *i) { + Term o = TermNil; + if (i->errorNo == YAP_NO_ERROR) { + return o; + } + o = add_key_i("errorNo", i->errorNo, o); + o = add_key_i("errorClass", i->errorClass, o); + o = add_key_s("errorAsText", i->errorAsText, o); + o = add_key_s("errorGoal", i->errorGoal, o); + o = add_key_s("classAsText", i->classAsText, o); + o = add_key_i("errorLineq", i->errorLine, o); + o = add_key_s("errorFunction", i->errorFunction, o); + o = add_key_s("errorFile", i->errorFile, o); + o = add_key_i("prologPredLine", i->prologPredLine, o); + o = add_key_s("prologPredName", i->prologPredName, o); + o = add_key_i("prologPredArity", i->prologPredArity, o); + o = add_key_s("prologPredModule", i->prologPredModule, o); + o = add_key_s("prologPredFile", i->prologPredFile, o); + o = add_key_i("parserPos", i->parserPos, o); + o = add_key_i("parserLine", i->parserLine, o); + o = add_key_i("parserFirstLine", i->parserFirstLine, o); + o = add_key_i("parserLastLine", i->parserLastLine, o); + o = add_key_s("parserTextA", i->parserTextA, o); + o = add_key_s("parserTextB", i->parserTextB, o); + o = add_key_s("parserFile", i->parserFile, o); + o = add_key_b("parserReadingCode", i->parserReadingCode, o); + o = add_key_b("prologConsulting", i->prologConsulting, o); + o = add_key_s("culprit", i->culprit, o); + if (i->errorMsgLen) { + o = add_key_s("errorMsg", i->errorMsg, o); + o = add_key_i("errorMsgLen", i->errorMsgLen, o); + } + return o; +} + bool Yap_Warning(const char *s, ...) { CACHE_REGS va_list ap; PredEntry *pred; bool rc; Term ts[2]; - const char *format; + const char *fmt; char tmpbuf[MAXPATHLEN]; + yap_error_number err; - if (LOCAL_within_print_message) { - /* error within error */ - fprintf(stderr, "%% WARNING WITHIN WARNING\n"); + LOCAL_DoingUndefp = true; + if (LOCAL_PrologMode & InErrorMode && (err = LOCAL_ActiveError->errorNo)) { + fprintf(stderr, "%% Warning %s WITHIN ERROR %s %s\n", s, + Yap_errorClassName(Yap_errorClass(err)), Yap_errorName(err)); Yap_RestartYap(1); } - LOCAL_DoingUndefp = true; - LOCAL_within_print_message = true; + LOCAL_PrologMode |= InErrorMode; pred = RepPredProp(PredPropByFunc(FunctorPrintMessage, PROLOG_MODULE)); // PROCEDURE_print_message2 va_start(ap, s); - format = va_arg(ap, char *); - if (format != NULL) { + fmt = va_arg(ap, char *); + if (fmt != NULL) { #if HAVE_VSNPRINTF - vsnprintf(tmpbuf, MAXPATHLEN - 1, format, ap); + vsnprintf(tmpbuf, MAXPATHLEN - 1, fmt, ap); #else - (void)vsprintf(tmpbuf, format, ap); + (void)vsprintf(tmpbuf, fmt, ap); #endif - } else + } else { return false; + } va_end(ap); if (pred->OpcodeOfPred == UNDEF_OPCODE || pred->OpcodeOfPred == FAIL_OPCODE) { fprintf(stderr, "warning message: %s\n", tmpbuf); LOCAL_DoingUndefp = false; - LOCAL_within_print_message = false; + LOCAL_PrologMode &= ~InErrorMode; return false; } ts[1] = MkAtomTerm(AtomWarning); ts[0] = MkAtomTerm(Yap_LookupAtom(tmpbuf)); rc = Yap_execute_pred(pred, ts, true PASS_REGS); + LOCAL_PrologMode &= ~InErrorMode; return rc; } -void Yap_InitError(yap_error_number e, Term t, const char *msg) { - if (LOCAL_ActiveError->status) { - Yap_exit(1); + +void Yap_InitError__(const char *file, const char *function, int lineno, + yap_error_number e, Term t, ...) { + CACHE_REGS + va_list ap; + va_start(ap, t); + const char *fmt; + char tmpbuf[MAXPATHLEN]; + + fmt = va_arg(ap, char *); + if (fmt != NULL) { +#if HAVE_VSNPRINTF + vsnprintf(tmpbuf, MAXPATHLEN - 1, fmt, ap); +#else + (void)vsprintf(tmpbuf, fmt, ap); +#endif + } else + return; + va_end(ap); + if (LOCAL_ActiveError->errorNo != YAP_NO_ERROR) { + yap_error_number err = LOCAL_ActiveError->errorNo; + fprintf(stderr, "%% Warning %s WITHIN ERROR %s %s\n", Yap_errorName(e), + Yap_errorClassName(Yap_errorClass(err)), Yap_errorName(err)); + return; } LOCAL_ActiveError->errorNo = e; LOCAL_ActiveError->errorFile = NULL; LOCAL_ActiveError->errorFunction = NULL; LOCAL_ActiveError->errorLine = 0; - if (msg) { - LOCAL_Error_Size = strlen(msg); + if (fmt) { + LOCAL_Error_Size = strlen(tmpbuf); LOCAL_ActiveError->errorMsg = malloc(LOCAL_Error_Size + 1); - strcpy(LOCAL_ActiveError->errorMsg, msg); + strcpy((char *)LOCAL_ActiveError->errorMsg, tmpbuf); } else { LOCAL_Error_Size = 0; } @@ -94,33 +327,36 @@ bool Yap_PrintWarning(Term twarning) { CACHE_REGS PredEntry *pred = RepPredProp(PredPropByFunc( FunctorPrintMessage, PROLOG_MODULE)); // PROCEDURE_print_message2; + __android_log_print(ANDROID_LOG_INFO, "YAPDroid ", " warning(%s)", + Yap_TermToBuffer(twarning, Quote_illegal_f | Ignore_ops_f | Unfold_cyclics_f)); Term cmod = (CurrentModule == PROLOG_MODULE ? TermProlog : CurrentModule); bool rc; - Term ts[2]; + Term ts[2], err; - if (LOCAL_within_print_message) { - /* error within error */ - fprintf(stderr, "%% WARNING WITHIN WARNING\n"); - Yap_RestartYap(1); + if (LOCAL_PrologMode & InErrorMode && LOCAL_ActiveError && + LOCAL_ActiveError->errorClass != WARNING && + (err = LOCAL_ActiveError->errorNo)) { + fprintf(stderr, "%% Warning %s while processing error: %s %s\n", + Yap_TermToBuffer(twarning, + Quote_illegal_f | Ignore_ops_f), + Yap_errorClassName(Yap_errorClass(err)), Yap_errorName(err)); + return false; } - LOCAL_DoingUndefp = true; - LOCAL_within_print_message = true; + LOCAL_PrologMode |= InErrorMode; if (pred->OpcodeOfPred == UNDEF_OPCODE || pred->OpcodeOfPred == FAIL_OPCODE) { fprintf(stderr, "warning message:\n"); Yap_DebugPlWrite(twarning); fprintf(stderr, "\n"); LOCAL_DoingUndefp = false; - LOCAL_within_print_message = false; + LOCAL_PrologMode &= ~InErrorMode; CurrentModule = cmod; return false; } ts[1] = twarning; ts[0] = MkAtomTerm(AtomWarning); - HB = B->cp_h = HR; - B->cp_tr = TR; rc = Yap_execute_pred(pred, ts, true PASS_REGS); LOCAL_within_print_message = false; - LOCAL_DoingUndefp = false; + LOCAL_PrologMode &= ~InErrorMode; return rc; } @@ -130,17 +366,30 @@ bool Yap_HandleError__(const char *file, const char *function, int lineno, yap_error_number err = LOCAL_Error_TYPE; const char *serr; + arity_t arity = 2; + if (LOCAL_ErrorMessage) { serr = LOCAL_ErrorMessage; } else { serr = s; } + if (P != FAILCODE) { + if (P->opc == Yap_opcode(_try_c) || P->opc == Yap_opcode(_try_userc) || + P->opc == Yap_opcode(_retry_c) || P->opc == Yap_opcode(_retry_userc)) { + + arity = P->y_u.OtapFs.p->ArityOfPE; + } else { + arity = PREVOP(P, Osbpp)->y_u.Osbpp.p->ArityOfPE; + } + } switch (err) { case RESOURCE_ERROR_STACK: - if (!Yap_gc(2, ENV, gc_P(P, CP))) { - Yap_Error__(file, function, lineno, RESOURCE_ERROR_STACK, ARG1, serr); + if (!Yap_gc(arity, ENV, gc_P(P, CP))) { + Yap_Error__(false, file, function, lineno, RESOURCE_ERROR_STACK, ARG1, + serr); return false; } + LOCAL_PrologMode = UserMode; return true; case RESOURCE_ERROR_AUXILIARY_STACK: if (LOCAL_MAX_SIZE < (char *)AuxSp - AuxBase) { @@ -148,18 +397,24 @@ bool Yap_HandleError__(const char *file, const char *function, int lineno, } if (!Yap_ExpandPreAllocCodeSpace(0, NULL, TRUE)) { /* crash in flames */ - Yap_Error__(file, function, lineno, RESOURCE_ERROR_AUXILIARY_STACK, ARG1, - serr); + Yap_Error__(false, file, function, lineno, RESOURCE_ERROR_AUXILIARY_STACK, + ARG1, serr); return false; } + LOCAL_PrologMode = UserMode; return true; case RESOURCE_ERROR_HEAP: if (!Yap_growheap(FALSE, 0, NULL)) { - Yap_Error__(file, function, lineno, RESOURCE_ERROR_HEAP, ARG2, serr); + Yap_Error__(false, file, function, lineno, RESOURCE_ERROR_HEAP, ARG2, + serr); return false; } default: - Yap_Error__(file, function, lineno, err, TermNil, serr); + + if (LOCAL_PrologMode == UserMode) + Yap_ThrowError__(file, function, lineno, err, LOCAL_RawTerm, serr); + else + LOCAL_PrologMode &= ~InErrorMode; return false; } } @@ -169,9 +424,7 @@ int Yap_SWIHandleError(const char *s, ...) { yap_error_number err = LOCAL_Error_TYPE; char *serr; - if (LOCAL_ErrorMessage) { - serr = LOCAL_ErrorMessage; - } else { + if (s) { serr = (char *)s; } switch (err) { @@ -190,15 +443,15 @@ int Yap_SWIHandleError(const char *s, ...) { Yap_Error(RESOURCE_ERROR_AUXILIARY_STACK, ARG1, serr); return FALSE; } - return TRUE; + return true; case RESOURCE_ERROR_HEAP: - if (!Yap_growheap(FALSE, 0, NULL)) { + if (!Yap_growheap(false, 0, NULL)) { Yap_Error(RESOURCE_ERROR_HEAP, ARG2, serr); - return FALSE; + return false; } default: Yap_Error(err, TermNil, serr); - return (FALSE); + return false; } } @@ -207,7 +460,7 @@ void Yap_RestartYap(int flag) { #if PUSH_REGS restore_absmi_regs(&Yap_standard_regs); #endif - siglongjmp(*LOCAL_RestartEnv, 1); + siglongjmp(*LOCAL_RestartEnv, flag); } static void error_exit_yap(int value) { @@ -251,46 +504,68 @@ static char tmpbuf[YAP_BUF_SIZE]; #undef BEGIN_ERRORS #undef E0 #undef E +#undef E1 #undef E2 #undef END_ERRORS #define BEGIN_ERROR_CLASSES() \ - static Term mkerrorct(yap_error_class_number c, Term *ts) { \ + static Atom mkerrorct(yap_error_class_number c) { \ switch (c) { #define ECLASS(CL, A, B) \ case CL: \ - if (A == 0) \ - return MkAtomTerm(Yap_LookupAtom(A)); \ - else { \ - return Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom(A), B), B, ts); \ - } + return Yap_LookupAtom(A); #define END_ERROR_CLASSES() \ } \ - return TermNil; \ + return NULL; \ } #define BEGIN_ERRORS() \ - static Term mkerrort(yap_error_number e, Term *ts) { \ + static Term mkerrort(yap_error_number e, Term culprit, Term info) { \ + if (!e || !info) return TermNil; \ switch (e) { #define E0(A, B) \ - case A: \ - return mkerrorct(B, ts); + case A: { \ + Term ft[2]; \ + ft[0] = MkAtomTerm(mkerrorct(B)); \ + ft[1] = info; \ + return Yap_MkApplTerm(FunctorError, 2, ft); \ + } #define E(A, B, C) \ - case A: \ - ts -= 1; \ - ts[0] = MkAtomTerm(Yap_LookupAtom(C)); \ - return mkerrorct(B, ts); + case A: { \ + Term ft[2], nt[2]; \ + nt[0] = MkAtomTerm(Yap_LookupAtom(C)); \ + nt[1] = MkVarTerm(); \ + Yap_unify(nt[1], culprit); \ + ft[0] = Yap_MkApplTerm(Yap_MkFunctor(mkerrorct(B), 2), 2, nt); \ + ft[1] = info; \ + return Yap_MkApplTerm(FunctorError, 2, ft); \ + } + +#define E1(A, B, C) \ + case A: { \ + Term ft[2], nt[1]; \ + nt[0] = MkVarTerm(); \ + Yap_unify(nt[0], culprit); \ + ft[0] = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom(C), 1), 1, nt); \ + ft[1] = info; \ + return Yap_MkApplTerm(FunctorError, 2, ft); \ + } #define E2(A, B, C, D) \ - case A: \ - ts -= 2; \ - ts[0] = MkAtomTerm(Yap_LookupAtom(C)); \ - ts[1] = MkAtomTerm(Yap_LookupAtom(D)); \ - return mkerrorct(B, ts); + case A: { \ + Term ft[2], nt[3]; \ + nt[0] = MkAtomTerm(Yap_LookupAtom(C)); \ + nt[1] = MkAtomTerm(Yap_LookupAtom(D)); \ + nt[2] = MkVarTerm(); \ + Yap_unify(nt[2], culprit); \ + ft[0] = Yap_MkApplTerm(Yap_MkFunctor(mkerrorct(B), 3), 3, nt); \ + ft[1] = info; \ + return Yap_MkApplTerm(FunctorError, 2, ft); \ + } #define END_ERRORS() \ } \ @@ -299,36 +574,150 @@ static char tmpbuf[YAP_BUF_SIZE]; #include "YapErrors.h" -void Yap_pushErrorContext(yap_error_descriptor_t *new_error) { - new_error->top_error = LOCAL_ActiveError; +/// add a new error descriptor, either to the top of the stack, +/// or replacing the top; +bool Yap_pushErrorContext(bool link , yap_error_descriptor_t *new_error) { + memset(new_error, 0, sizeof(yap_error_descriptor_t)); + if (link) + new_error->top_error = LOCAL_ActiveError; LOCAL_ActiveError = new_error; + return true; } -yap_error_descriptor_t *Yap_popErrorContext(void) { - yap_error_descriptor_t *new_error = LOCAL_ActiveError; - LOCAL_ActiveError = LOCAL_ActiveError->top_error; - return new_error; +/* static void */ +/* reset_error_description(void) { */ +/* yap_error_descriptor_t *bf = LOCAL_ActiveError->top_error; */ +/* if (Yap_HasException()) */ +/* memset(LOCAL_ActiveError, 0, sizeof(*LOCAL_ActiveError)); */ +/* LOCAL_ActiveError->top_error = bf; */ +/* } */ +yap_error_descriptor_t *Yap_popErrorContext(bool mdnew, bool pass) { + yap_error_descriptor_t *e = LOCAL_ActiveError, *ep = LOCAL_ActiveError->top_error; + // last block + LOCAL_ActiveError = ep; + if (e->errorNo && !ep->errorNo && pass) { + yap_error_descriptor_t *epp = ep->top_error; + memmove(ep, e, sizeof(*e)); + ep->top_error = epp; + } + free(e); + return LOCAL_ActiveError; } - +/** + * Throw an error directly to the error handler + * + * @param file where + * @param function who + * @param lineno when + * @param type what, error code + * @param where how, user information + */ void Yap_ThrowError__(const char *file, const char *function, int lineno, yap_error_number type, Term where, ...) { va_list ap; char tmpbuf[MAXPATHLEN]; va_start(ap, where); - char *format = va_arg(ap, char *); - if (format != NULL) { + char *fmt = va_arg(ap, char *); + if (fmt != NULL) { #if HAVE_VSNPRINTF - (void)vsnprintf(tmpbuf, MAXPATHLEN - 1, format, ap); + (void)vsnprintf(tmpbuf, MAXPATHLEN - 1, fmt, ap); #else - (void)vsprintf(tnpbuf, format, ap); + (void)vsprintf(tnpbuf, fmt, ap); #endif // fprintf(stderr, "warning: "); - Yap_Error__(file, function, lineno, type, where, tmpbuf); + Yap_Error__(true, file, function, lineno, type, where, tmpbuf); } else { - Yap_Error__(file, function, lineno, type, where); + Yap_Error__(true, file, function, lineno, type, where); } - siglongjmp(*LOCAL_RestartEnv, 5); + if (LOCAL_RestartEnv && !LOCAL_delay) { + Yap_RestartYap(5); + } + Yap_exit(5); +} + +/** + * complete delayed error. + * + */ +void Yap_ThrowExistingError(void) { + if (LOCAL_RestartEnv) { + Yap_RestartYap(5); + } + Yap_exit(5); +} + +Term Yap_MkFullError(void) +{ + yap_error_descriptor_t *i = Yap_local.ActiveError; + i->errorAsText = Yap_errorName( i->errorNo ); + i->errorClass = Yap_errorClass( i-> errorNo ); + i->classAsText = Yap_errorClassName(i->errorClass); + return mkerrort(i->errorNo, TermNil , MkSysError(i) ); +} + + +bool Yap_MkErrorRecord(yap_error_descriptor_t *r, const char *file, + const char *function, int lineno, yap_error_number type, + Term where, const char *s) { + if (!Yap_pc_add_location(r, P, B, ENV)) + Yap_env_add_location(r, CP, B, ENV, 0); + if (where == 0L || where == TermNil) { + r->culprit = NULL; + } else { + r->culprit = Yap_TermToBuffer( + where, Quote_illegal_f | Ignore_ops_f); + } + if (type != SYNTAX_ERROR && LOCAL_consult_level > 0) { + r->parserFile = Yap_ConsultingFile(PASS_REGS1)->StrOfAE; + r->parserLine = Yap_source_line_no(); + } + r->errorNo = type; + r->errorAsText = Yap_errorName(type); + r->errorClass = Yap_errorClass(type); + r->classAsText = Yap_errorClassName(r->errorClass); + r->errorLine = lineno; + r->errorFunction = function; + r->errorFile = file; + r->prologConsulting = Yap_Consulting(); + LOCAL_PrologMode |= InErrorMode; + Yap_ClearExs(); + // first, obtain current location + + // sprintf(LOCAL_FileNameBuf, "%s:%d in C-function %s ", file, lineno, + // function); + // tf = MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)); +#if DEBUG_STRICT + if (Yap_heap_regs && !(LOCAL_PrologMode & BootMode)) + fprintf(stderr, "***** Processing Error %d (%lx,%x) %s***\n", type, + (unsigned long int)LOCAL_Signals, LOCAL_PrologMode, fmt); + else + fprintf(stderr, "***** Processing Error %d (%x) %s***\n", type, + LOCAL_PrologMode, fmt); +#endif + if (r->errorNo == SYNTAX_ERROR) { + r->errorClass = SYNTAX_ERROR_CLASS; + } else if (r->errorNo == SYNTAX_ERROR_NUMBER) { + r->errorClass = SYNTAX_ERROR_CLASS; + r->errorNo = SYNTAX_ERROR; + } + if (type == INTERRUPT_EVENT) { + fprintf(stderr, "%% YAP exiting: cannot handle signal %d\n", + (int)IntOfTerm(where)); + Yap_exit(1); + } + // fprintf(stderr, "warning: "); + if (s && s[0]) { + char *ns; + r->errorMsgLen = strlen(s) + 1; + ns = malloc(r->errorMsgLen); + strcpy(ns, s); + r->errorMsg = ns; + } else { + r->errorMsgLen = 0; + r->errorMsg = 0; + } + return true; } /** @@ -351,138 +740,14 @@ void Yap_ThrowError__(const char *file, const char *function, int lineno, * * In a bad day, it has to deal with OOM, abort, and errors within errorts. * - * The list includes the following options: - * + c=c(file, line, function): where the bug was detected; - * - * + e=p(mod, name, arity, cl, file, lin): where the code was entered; - * - * + p=p(mod, name, arity, cl, file, line): the prolog procedure that caused - *the bug, - *and optionally, - * - * + g=g(Goal): the goal that created this mess - * - * + i=i(Comment): an user-written comment on this bug. */ -yamop *Yap_Error__(const char *file, const char *function, int lineno, - yap_error_number type, Term where, ...) { +yamop *Yap_Error__(bool throw, const char *file, const char *function, + int lineno, yap_error_number type, Term where, ...) { CACHE_REGS va_list ap; - CELL nt[3]; - Functor fun; - Term error_t; - Term comment; - char *format; + char *fmt; char s[MAXPATHLEN]; - /* disallow recursive error handling */ - if (LOCAL_PrologMode & InErrorMode) { - fprintf(stderr, "%% ERROR WITHIN ERROR %d: %s\n", LOCAL_Error_TYPE, tmpbuf); - Yap_RestartYap(1); - } - LOCAL_ActiveError->errorNo = type; - LOCAL_ActiveError->errorAsText = Yap_LookupAtom(Yap_errorName(type)); - LOCAL_ActiveError->errorClass = Yap_errorClass(type); - LOCAL_ActiveError->classAsText = - Yap_LookupAtom(Yap_errorClassName(LOCAL_ActiveError->errorClass)); - LOCAL_ActiveError->errorLine = lineno; - LOCAL_ActiveError->errorFunction = function; - LOCAL_ActiveError->errorFile = file; - Yap_find_prolog_culprit(PASS_REGS1); - LOCAL_PrologMode |= InErrorMode; - Yap_ClearExs(); - if (where == 0L) { - where = TermNil; - } -// first, obtain current location -// sprintf(LOCAL_FileNameBuf, "%s:%d in C-function %s ", file, lineno, -// function); -// tf = MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)); -#if DEBUG_STRICT - if (Yap_heap_regs && !(LOCAL_PrologMode & BootMode)) - fprintf(stderr, "***** Processing Error %d (%lx,%x) %s***\n", type, - (unsigned long int)LOCAL_Signals, LOCAL_PrologMode, format); - else - fprintf(stderr, "***** Processing Error %d (%x) %s***\n", type, - LOCAL_PrologMode, format); -#endif - if (type == INTERRUPT_EVENT) { - fprintf(stderr, "%% YAP exiting: cannot handle signal %d\n", - (int)IntOfTerm(where)); - LOCAL_PrologMode &= ~InErrorMode; - Yap_exit(1); - } - if (LOCAL_within_print_message) { - /* error within error */ - fprintf(stderr, "%% ERROR WITHIN WARNING %d: %s\n", LOCAL_Error_TYPE, - tmpbuf); - LOCAL_PrologMode &= ~InErrorMode; - Yap_exit(1); - } - va_start(ap, where); - format = va_arg(ap, char *); - if (format != NULL) { -#if HAVE_VSNPRINTF - (void)vsnprintf(s, MAXPATHLEN - 1, format, ap); -#else - (void)vsprintf(s, format, ap); -#endif - // fprintf(stderr, "warning: "); - comment = MkAtomTerm(Yap_LookupAtom(s)); - } else if (LOCAL_ErrorMessage && LOCAL_ErrorMessage[0]) { - comment = MkAtomTerm(Yap_LookupAtom(LOCAL_ErrorMessage)); - } else { - comment = TermNil; - } - va_end(ap); - if (P == (yamop *)(FAILCODE)) { - LOCAL_PrologMode &= ~InErrorMode; - return P; - } - /* PURE_ABORT may not have set where correctly, BootMode may not have the data - * terms ready */ - if (type == ABORT_EVENT || LOCAL_PrologMode & BootMode) { - where = TermNil; - LOCAL_PrologMode &= ~AbortMode; - LOCAL_PrologMode &= ~InErrorMode; - /* make sure failure will be seen at next port */ - // no need to lock & unlock - if (LOCAL_PrologMode & AsyncIntMode) - Yap_signal(YAP_FAIL_SIGNAL); - P = FAILCODE; - } else { - if (IsVarTerm(where)) { - /* we must be careful someone gave us a copy to a local variable */ - Term t = MkVarTerm(); - Yap_unify(t, where); - where = Deref(where); - } - /* Exit Abort Mode, if we were there */ - LOCAL_PrologMode &= ~AbortMode; - LOCAL_PrologMode |= InErrorMode; - if (!(where = Yap_CopyTerm(where))) { - where = TermNil; - } - } - - if (LOCAL_PrologMode & BootMode) { - /* crash in flames! */ - fprintf(stderr, - "%s:%d:0 YAP Fatal Error %d in function %s:\n %s exiting....\n", - file, lineno, type, function, s); - error_exit_yap(1); - } -#ifdef DEBUG -// DumpActiveGoals( USES_REGS1 ); -#endif /* DEBUG */ - if (!IsVarTerm(where) && IsApplTerm(where) && - FunctorOfTerm(where) == FunctorError) { - error_t = where; - P = (yamop *)FAILCODE; - Yap_JumpToEnv(error_t); - LOCAL_PrologMode &= ~InErrorMode; - return P; - } switch (type) { case SYSTEM_ERROR_INTERNAL: { fprintf(stderr, "%% Internal YAP Error: %s exiting....\n", tmpbuf); @@ -490,7 +755,7 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno, if (LOCAL_PrologMode & BootMode) { fprintf(stderr, "%% YAP crashed while booting %s\n", tmpbuf); } else { - Yap_detect_bug_location(P, FIND_PRED_FROM_ANYWHERE, YAP_BUF_SIZE); + Yap_output_bug_location(P, FIND_PRED_FROM_ANYWHERE, YAP_BUF_SIZE); if (tmpbuf[0]) { fprintf(stderr, "%% Bug found while executing %s\n", tmpbuf); } @@ -516,107 +781,401 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno, error_exit_yap(1); } case ABORT_EVENT: - nt[0] = MkAtomTerm(AtomDAbort); - fun = FunctorDollarVar; + // fun = FunctorDollarVar; // serious = true; - break; + LOCAL_ActiveError->errorNo = ABORT_EVENT; + Yap_JumpToEnv(); + P = FAILCODE; + LOCAL_PrologMode &= ~InErrorMode; + return P; case CALL_COUNTER_UNDERFLOW_EVENT: /* Do a long jump */ LOCAL_ReductionsCounterOn = FALSE; LOCAL_PredEntriesCounterOn = FALSE; LOCAL_RetriesCounterOn = FALSE; - Yap_JumpToEnv(MkAtomTerm(AtomCallCounter)); - P = (yamop *)FAILCODE; + LOCAL_ActiveError->errorNo = CALL_COUNTER_UNDERFLOW_EVENT; + Yap_JumpToEnv(); + P = FAILCODE; LOCAL_PrologMode &= ~InErrorMode; - return (P); + return P; case PRED_ENTRY_COUNTER_UNDERFLOW_EVENT: /* Do a long jump */ LOCAL_ReductionsCounterOn = FALSE; LOCAL_PredEntriesCounterOn = FALSE; LOCAL_RetriesCounterOn = FALSE; - Yap_JumpToEnv(MkAtomTerm(AtomCallAndRetryCounter)); - P = (yamop *)FAILCODE; + LOCAL_ActiveError->errorNo = PRED_ENTRY_COUNTER_UNDERFLOW_EVENT; + Yap_JumpToEnv(); + P = FAILCODE; LOCAL_PrologMode &= ~InErrorMode; - return (P); + return P; case RETRY_COUNTER_UNDERFLOW_EVENT: /* Do a long jump */ LOCAL_ReductionsCounterOn = FALSE; LOCAL_PredEntriesCounterOn = FALSE; LOCAL_RetriesCounterOn = FALSE; - Yap_JumpToEnv(MkAtomTerm(AtomRetryCounter)); - P = (yamop *)FAILCODE; + LOCAL_ActiveError->errorNo = RETRY_COUNTER_UNDERFLOW_EVENT; + Yap_JumpToEnv(); + P = FAILCODE; LOCAL_PrologMode &= ~InErrorMode; - return (P); - default: { + return P; + default: + va_start(ap, where); + fmt = va_arg(ap, char *); + if (fmt != NULL) { +#if HAVE_VSNPRINTF + (void)vsnprintf(s, MAXPATHLEN - 1, fmt, ap); +#else + (void)vsprintf(s, fmt, ap); +#endif + va_end(ap); + break; + } + } + Yap_MkErrorRecord(LOCAL_ActiveError, file, function, lineno, type, where, s); + if (where == 0 || where == TermNil) { + LOCAL_ActiveError->culprit = 0; + } + if (P == (yamop *)(FAILCODE)) { LOCAL_PrologMode &= ~InErrorMode; - Term ts[3]; - ts[2] = where; - nt[0] = mkerrort(type, ts + 2); + return P; } + /* PURE_ABORT may not have set where correctly, BootMode may not have the data + * terms ready */ + if (type == ABORT_EVENT || LOCAL_PrologMode & BootMode) { + LOCAL_PrologMode &= ~AbortMode; + LOCAL_PrologMode &= ~InErrorMode; + /* make sure failure will be seen at next port */ + // no need to lock & unlock + if (LOCAL_PrologMode & AsyncIntMode) + Yap_signal(YAP_FAIL_SIGNAL); + P = FAILCODE; + } else { + /* Exit Abort Mode, if we were there */ + LOCAL_PrologMode &= ~AbortMode; + LOCAL_PrologMode |= InErrorMode; } - LOCAL_PrologMode &= ~InErrorMode; - if (type != ABORT_EVENT) { - Term location; - /* This is used by some complex procedures to detect there was an error */ - if (IsAtomTerm(nt[0])) { - LOCAL_ErrorMessage = RepAtom(AtomOfTerm(nt[0]))->StrOfAE; - } else { - LOCAL_ErrorMessage = - (char *)RepAtom(NameOfFunctor(FunctorOfTerm(nt[0])))->StrOfAE; - } - nt[1] = TermNil; - switch (type) { - case RESOURCE_ERROR_HEAP: - case RESOURCE_ERROR_STACK: - case RESOURCE_ERROR_TRAIL: - comment = MkAtomTerm(Yap_LookupAtom(tmpbuf)); - default: - if (comment != TermNil) - nt[1] = MkPairTerm(MkPairTerm(MkAtomTerm(Yap_LookupAtom("i")), comment), - nt[1]); - if (file && function) { - Term ts[3], t3; - ts[0] = MkAtomTerm(Yap_LookupAtom(file)); - ts[1] = MkIntegerTerm(lineno); - ts[2] = MkAtomTerm(Yap_LookupAtom(function)); - t3 = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("c"), 3), 3, ts); - nt[1] = - MkPairTerm(MkPairTerm(MkAtomTerm(Yap_LookupAtom("c")), t3), nt[1]); - } - if ((location = Yap_pc_location(P, B, ENV)) != TermNil) { - nt[1] = MkPairTerm( - MkPairTerm(MkAtomTerm(Yap_LookupAtom("p")), location), nt[1]); - } - if ((location = Yap_env_location(CP, B, ENV, 0)) != TermNil) { - nt[1] = MkPairTerm( - MkPairTerm(MkAtomTerm(Yap_LookupAtom("e")), location), nt[1]); - } - } - } - /* disable active signals at this point */ - LOCAL_Signals = 0; +#ifdef DEBUG + // DumpActiveGoals( USES_REGS1 ); +#endif /* DEBUG */ + CalculateStackGap(PASS_REGS1); #if DEBUG -// DumpActiveGoals( PASS_REGS1 ); + // DumpActiveGoals( PASS_REGS1 ); #endif /* wait if we we are in user code, it's up to her to decide */ - fun = FunctorError; - error_t = Yap_MkApplTerm(fun, 2, nt); - - if (type == ABORT_EVENT) { - error_t = MkAtomTerm(AtomDAbort); - } else { - error_t = Yap_MkApplTerm(fun, 2, nt); + if (LOCAL_delay) + return P; + if (LOCAL_DoingUndefp) { + LOCAL_DoingUndefp = false; + LOCAL_Signals = 0; + Yap_PrintWarning(MkErrorTerm(Yap_GetException(LOCAL_ActiveError))); + return P; } - Yap_JumpToEnv(error_t); - P = (yamop *)FAILCODE; - - LOCAL_PrologMode &= ~InErrorMode; + // LOCAL_ActiveError = Yap_GetException(); + // reset_error_description(); + if (!throw) { + Yap_JumpToEnv(); + pop_text_stack(LOCAL_MallocDepth+1); + } + LOCAL_PrologMode = UserMode; return P; } +static Int close_error(USES_REGS1) { + if (!LOCAL_CommittedError) + return true; + LOCAL_CommittedError->errorNo = YAP_NO_ERROR; + LOCAL_ErrorMessage = NULL; + free(LOCAL_CommittedError); + LOCAL_CommittedError = NULL; + return true; +} + +#undef BEGIN_ERROR_CLASSES +#undef ECLASS +#undef END_ERROR_CLASSES +#undef BEGIN_ERRORS +#undef E0 +#undef E +#undef E1 +#undef E2 +#undef END_ERRORS + +#define BEGIN_ERROR_CLASSES() typedef enum aux_class { + +#define ECLASS(CL, A, B) CL##__, + +#define END_ERROR_CLASSES() \ + } \ + aux_class_t; + +#define BEGIN_ERRORS() +#define E0(X, Y) +#define E(X, Y, Z) +#define E1(X, Y, Z) +#define E2(X, Y, Z, W) +#define END_ERRORS() + +#include + +#undef BEGIN_ERROR_CLASSES +#undef ECLASS +#undef END_ERROR_CLASSES +#undef BEGIN_ERRORS +#undef E0 +#undef E +#undef E1 +#undef E2 +#undef END_ERRORS + +#define BEGIN_ERROR_CLASSES() static const char *c_error_class_name[] = { + +#define ECLASS(CL, A, B) A, + +#define END_ERROR_CLASSES() \ + NULL \ + } + +typedef struct c_error_info { + int class; + const char *name; +} c_error_t; + +#define BEGIN_ERRORS() static struct c_error_info c_error_list[] = { +#define E0(X, Y) {Y##__, ""}, +#define E(X, Y, Z) {Y##__, Z}, +#define E1(X, Y, Z) {Y##__, Z}, +#define E2(X, Y, Z, W) {Y##__, Z " " W}, +#define END_ERRORS() \ + { YAPC_NO_ERROR, "" } \ + } \ + ; + +#include +#include + +yap_error_class_number Yap_errorClass(yap_error_number e) { + return c_error_list[e].class; +} + +const char *Yap_errorName(yap_error_number e) { return c_error_list[e].name; } + +const char *Yap_errorClassName(yap_error_class_number e) { + return c_error_class_name[e]; +} + +yap_error_descriptor_t *Yap_GetException(yap_error_descriptor_t *i) { + CACHE_REGS + if (i->errorNo != YAP_NO_ERROR) { + yap_error_descriptor_t *t = LOCAL_ActiveError, + *nt = calloc(1,sizeof(yap_error_descriptor_t)); + memmove(nt, t, sizeof(yap_error_descriptor_t)); + return nt; + } + return 0; +} + +void Yap_PrintException(yap_error_descriptor_t *i) { + printErr(LOCAL_ActiveError); +} + +bool Yap_RaiseException(void) { + if (LOCAL_ActiveError == NULL || + LOCAL_ActiveError->errorNo == YAP_NO_ERROR) + return false; + Yap_RestartYap(5); + return false; + //return Yap_JumpToEnv(); +} + +bool Yap_ResetException(yap_error_descriptor_t *i) { + // reset error descriptor + if (!i) + return true; + yap_error_descriptor_t *bf = i->top_error; + memset(i, 0, sizeof(*i)); + i->top_error = bf; + return true; +} + +static Int reset_exception(USES_REGS1) { return Yap_ResetException(worker_id); } + +Term MkErrorTerm(yap_error_descriptor_t *t) { + if (t->errorClass == EVENT) + return t->errorRawTerm; + Term tc = t->culprit ? Yap_BufferToTerm(t->culprit, TermNil) : TermNil; + if (tc == 0) + tc = MkAtomTerm(Yap_LookupAtom(t->culprit)); + return mkerrort(t->errorNo, + tc, + err2list(t)); +} + +static Int read_exception(USES_REGS1) { + yap_error_descriptor_t *t = AddressOfTerm(Deref(ARG1)); + Term rc = MkErrorTerm(t); + // Yap_DebugPlWriteln(rc); + return Yap_unify(ARG2, rc); +} + +static Int print_exception(USES_REGS1) { + Term t1 = Deref(ARG1); + if (IsAddressTerm(t1)) { + yap_error_descriptor_t *t = AddressOfTerm(t1); + printErr(t); + } else { + return Yap_WriteTerm(LOCAL_c_error_stream,t1,TermNil PASS_REGS); + } + // Yap_DebugPlWriteln(rc); + return true; +} + + + +static Int query_exception(USES_REGS1) { + const char *query = NULL; + Term t; + + if (IsAtomTerm((t = Deref(ARG1)))) + query = RepAtom(AtomOfTerm(t))->StrOfAE; + if (IsStringTerm(t)) + query = StringOfTerm(t); + if (!IsAddressTerm(Deref(ARG2))) + return false; + yap_error_descriptor_t *y = AddressOfTerm(Deref(ARG2)); + Term t3 = Deref(ARG3); + //if (IsVarTerm(t3)) { + Term rc = queryErr(query, y); + // Yap_DebugPlWriteln(rc); + return Yap_unify(ARG3, rc); + // } else { + // return setErr(query, y, t3); + // } +} + + +static Int drop_exception(USES_REGS1) { + yap_error_descriptor_t *t = AddressOfTerm(Deref(ARG1)); + free(t); + return true; +} + +static Int new_exception(USES_REGS1) { + Term t = MkSysError(calloc(1, sizeof(yap_error_descriptor_t))); + return Yap_unify(ARG1, t); +} + +static Int get_exception(USES_REGS1) { + yap_error_descriptor_t *i; + Term t; + + if (LOCAL_ActiveError->errorNo != YAP_NO_ERROR) { + i = Yap_GetException(LOCAL_ActiveError); + Yap_ResetException(LOCAL_ActiveError); + LOCAL_PrologMode = UserMode; + if (i->errorRawTerm && + (i->errorClass == EVENT || i->errorNo == SYNTAX_ERROR)) { + t = i->errorRawTerm; + } else if (i->culprit != NULL) { + Term culprit = Yap_BufferToTerm(i->culprit, TermNil); + if (culprit == 0) culprit = TermNil; + t = mkerrort(i->errorNo,culprit , + MkSysError(i)); + } else { + t = mkerrort(i->errorNo, TermNil, MkSysError(i)); + } + return Yap_unify(ARG1, t); + } + return false; +} + +yap_error_descriptor_t *event(Term t, yap_error_descriptor_t *i) { + i->errorNo = ERROR_EVENT; + i->errorClass = EVENT; + i->errorRawTerm = Yap_SaveTerm(t); + return i; +} + +yap_error_descriptor_t *Yap_UserError(Term t, yap_error_descriptor_t *i) { + Term n = t; + bool found = false, wellformed = true; + if (!IsApplTerm(t) || FunctorOfTerm(t) != FunctorError) { + LOCAL_Error_TYPE = THROW_EVENT; + LOCAL_ActiveError->errorClass = EVENT; + LOCAL_ActiveError->errorAsText = Yap_errorName(THROW_EVENT); + LOCAL_ActiveError->classAsText = + Yap_errorClassName(Yap_errorClass(THROW_EVENT)); + LOCAL_ActiveError->errorRawTerm = Yap_SaveTerm(t); + LOCAL_ActiveError->culprit = NULL; + } else if (i->errorNo != YAP_NO_ERROR && i->errorNo != ERROR_EVENT) { + LOCAL_Error_TYPE = i->errorNo; + LOCAL_ActiveError->errorClass = Yap_errorClass(i->errorNo); + LOCAL_ActiveError->errorAsText = Yap_errorName(i->errorNo); + LOCAL_ActiveError->classAsText = + Yap_errorClassName(Yap_errorClass(i->errorNo)); + LOCAL_ActiveError->errorRawTerm = Yap_SaveTerm(t); + LOCAL_ActiveError->culprit = NULL; + } else { + Term t1, t2; + t1 = ArgOfTerm(1, t); + t2 = ArgOfTerm(2, t); + // LOCAL_Error_TYPE = ERROR_EVENT; + wellformed = wellformed && (i->errorAsText != NULL); + if (wellformed) { + int j; + for (j = 0; j < sizeof(c_error_list) / sizeof(struct c_error_info); j++) { + if (!strcmp(c_error_list[j].name, i->errorAsText) && + (c_error_list[j].class == 0 || + !strcmp(i->classAsText, + c_error_class_name[c_error_list[j].class]))) { + if (c_error_list[j].class != PERMISSION_ERROR || + (t1 = ArgOfTerm(2, t1) && IsAtomTerm(t1) && + !strcmp(c_error_list[j].name, + RepAtom(AtomOfTerm(t1))->StrOfAE) && + c_error_list[j].class != EVENT)) { + i->errorNo = j; + i->errorClass = c_error_list[j].class; + found = true; + break; + } + } + } + } else if (IsAtomTerm(t1)) { + const char *err = RepAtom(AtomOfTerm(t1))->StrOfAE; + if (!strcmp(err, "instantiation_error")) { + i->errorClass = INSTANTIATION_ERROR_CLASS; + i->classAsText = "instantiation_error"; + i->errorAsText = "instantiation_error"; + i->errorNo = INSTANTIATION_ERROR; + found = true; + } else if (!strcmp(err, "uninstantiation_error")) { + i->errorClass = UNINSTANTIATION_ERROR_CLASS; + i->classAsText = "uninstantiation_error"; + i->errorAsText = "uninstantiation_error"; + i->errorNo = UNINSTANTIATION_ERROR; + found = true; + } + } + if (i->errorAsText && i->errorAsText[0]) { + char *errs = malloc(strlen(i->errorAsText) + 1); + strcpy(errs, i->errorAsText); + i->errorAsText = errs; + } + if (!found) { + return event(t, i); + } + if (found) { + n = t2; + } + i->errorGoal = Yap_TermToBuffer( + n, Quote_illegal_f | Ignore_ops_f ); + } + Yap_prolog_add_culprit(i PASS_REGS); + return i; +} + static Int is_boolean(USES_REGS1) { Term t = Deref(ARG1); // Term Context = Deref(ARG2)Yap_Error(INSTANTIATION_ERROR, t, NULL);; @@ -642,22 +1201,22 @@ static Int is_callable(USES_REGS1) { // Term Context = Deref(ARG2); while (true) { if (IsVarTerm(G)) { - Yap_Error(INSTANTIATION_ERROR, G, NULL); + Yap_ThrowError(INSTANTIATION_ERROR, G, NULL); return false; } if (IsApplTerm(G)) { Functor f = FunctorOfTerm(G); if (IsExtensionFunctor(f)) { - Yap_Error(TYPE_ERROR_CALLABLE, G, NULL); + Yap_ThrowError(TYPE_ERROR_CALLABLE, G, NULL); } if (f == FunctorModule) { Term tm = ArgOfTerm(1, G); if (IsVarTerm(tm)) { - Yap_Error(INSTANTIATION_ERROR, G, NULL); + Yap_ThrowError(INSTANTIATION_ERROR, G, NULL); return false; } if (!IsAtomTerm(tm)) { - Yap_Error(TYPE_ERROR_CALLABLE, G, NULL); + Yap_ThrowError(TYPE_ERROR_CALLABLE, G, NULL); return false; } G = ArgOfTerm(2, G); @@ -667,7 +1226,7 @@ static Int is_callable(USES_REGS1) { } else if (IsPairTerm(G) || IsAtomTerm(G)) { return true; } else { - Yap_Error(TYPE_ERROR_CALLABLE, G, NULL); + Yap_ThrowError(TYPE_ERROR_CALLABLE, G, NULL); return false; } } @@ -701,81 +1260,15 @@ static Int is_predicate_indicator(USES_REGS1) { return false; } -static Int close_error(USES_REGS1) { - LOCAL_Error_TYPE = YAP_NO_ERROR; - return true; -} - -#undef BEGIN_ERROR_CLASSES -#undef ECLASS -#undef END_ERROR_CLASSES -#undef BEGIN_ERRORS -#undef E0 -#undef E -#undef E2 -#undef END_ERRORS - -#define BEGIN_ERROR_CLASSES() typedef enum aux_class { - -#define ECLASS(CL, A, B) CL##__, - -#define END_ERROR_CLASSES() \ - } \ - aux_class_t; - -#define BEGIN_ERRORS() -#define E0(X, Y) -#define E(X, Y, Z) -#define E2(X, Y, Z, W) -#define END_ERRORS() - -#include - -#undef BEGIN_ERROR_CLASSES -#undef ECLASS -#undef END_ERROR_CLASSES -#undef BEGIN_ERRORS -#undef E0 -#undef E -#undef E2 -#undef END_ERRORS - -#define BEGIN_ERROR_CLASSES() static const char *c_error_class_name[] = { - -#define ECLASS(CL, A, B) A, - -#define END_ERROR_CLASSES() \ - NULL \ - } - -typedef struct c_error_info { - int class; - const char *name; -} c_error_t; - -#define BEGIN_ERRORS() static struct c_error_info c_error_list[] = { -#define E0(X, Y) {Y##__, ""}, -#define E(X, Y, Z) {Y##__, Z}, -#define E2(X, Y, Z, W) {Y##__, Z " " W}, -#define END_ERRORS() \ - { YAPC_NO_ERROR, "" } \ - } \ - ; - -#include - -yap_error_class_number Yap_errorClass(yap_error_number e) { - return c_error_list[e].class; -} - -const char *Yap_errorName(yap_error_number e) { return c_error_list[e].name; } - -const char *Yap_errorClassName(yap_error_class_number e) { - return c_error_class_name[e]; -} - void Yap_InitErrorPreds(void) { CACHE_REGS + Yap_InitCPred("$print_exception<", 1, print_exception, 0); + Yap_InitCPred("$reset_exception", 1, reset_exception, 0); + Yap_InitCPred("$new_exception", 1, new_exception, 0); + Yap_InitCPred("$get_exception", 1, get_exception, 0); + Yap_InitCPred("$read_exception", 2, read_exception, 0); + Yap_InitCPred("$query_exception", 3, query_exception, 0); + Yap_InitCPred("$drop_exception", 1, drop_exception, 0); Yap_InitCPred("$close_error", 0, close_error, HiddenPredFlag); Yap_InitCPred("is_boolean", 2, is_boolean, TestPredFlag); Yap_InitCPred("is_callable", 2, is_callable, TestPredFlag); diff --git a/C/eval.c b/C/eval.c index fefc72cee..90ccf94d3 100644 --- a/C/eval.c +++ b/C/eval.c @@ -17,8 +17,19 @@ #ifdef SCCS static char SccsId[] = "%W% %G%"; #endif - -//! @file eval.c +/** + * @file eval.c + * @author VITOR SANTOS COSTA + * @date Mon Apr 30 09:37:59 2018 + * + * @brief is/2 + * + * + * @namespace prolog + * + * + * + */ //! @{ @@ -91,6 +102,8 @@ static Term get_matrix_element(Term t1, Term t2 USES_REGS) { } static Term Eval(Term t USES_REGS) { + eval_context_t ctx; + ctx.p = LOCAL_ctx; if (IsVarTerm(t)) { Yap_ArithError(INSTANTIATION_ERROR, t, "in arithmetic"); @@ -134,20 +147,19 @@ static Term Eval(Term t USES_REGS) { return get_matrix_element(ArgOfTerm(1, t), t2 PASS_REGS); } } + ctx.f = fun; + ctx.fp = RepAppl(t); + LOCAL_ctx = &ctx; *RepAppl(t) = (CELL)AtomFoundVar; t1 = Eval(ArgOfTerm(1, t) PASS_REGS); - if (t1 == 0L) { - *RepAppl(t) = (CELL)fun; - return FALSE; - } if (n == 1) { *RepAppl(t) = (CELL)fun; + LOCAL_ctx = ctx.p; return Yap_eval_unary(p->FOfEE, t1); } t2 = Eval(ArgOfTerm(2, t) PASS_REGS); *RepAppl(t) = (CELL)fun; - if (t2 == 0L) - return FALSE; + LOCAL_ctx = ctx.p; return Yap_eval_binary(p->FOfEE, t1, t2); } } /* else if (IsPairTerm(t)) */ @@ -161,7 +173,9 @@ static Term Eval(Term t USES_REGS) { } } -Term Yap_InnerEval__(Term t USES_REGS) { return Eval(t PASS_REGS); } +Term Yap_InnerEval__(Term t USES_REGS) { + return Eval(t PASS_REGS); + } #ifdef BEAM Int BEAM_is(void); @@ -196,30 +210,18 @@ arithmetic_operators /// @memberof is/2 static Int p_is(USES_REGS1) { /* X is Y */ - Term out; - yap_error_number err; - + Term out = TermNil; + bool go; Term t = Deref(ARG2); if (IsVarTerm(t)) { - Yap_EvalError(INSTANTIATION_ERROR, t, "X is Y"); + Yap_ThrowError(INSTANTIATION_ERROR, t, "var(Y) in X is Y"); return (FALSE); } - Yap_ClearExs(); do { - out = Yap_InnerEval(Deref(ARG2)); - if ((err = Yap_FoundArithError()) == YAP_NO_ERROR) - break; - if (err == RESOURCE_ERROR_STACK) { - LOCAL_Error_TYPE = YAP_NO_ERROR; - if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, CP)) { - Yap_EvalError(RESOURCE_ERROR_STACK, ARG2, LOCAL_ErrorMessage); - return FALSE; - } - } else { - Yap_EvalError(err, takeIndicator(ARG2), "X is Exp"); - return FALSE; - } - } while (TRUE); + go = false; + out = Yap_Eval(t PASS_REGS); + go = Yap_CheckArithError(); + } while (go); return Yap_unify_constant(ARG1, out); } @@ -257,7 +259,7 @@ static Int p_isnan(USES_REGS1) { /* X isnan Y */ } /** - @pred isinf(? X:float) is det + @pred isinf(? X:float) is det Interface to the IEE754 `isinf` test. */ @@ -387,7 +389,7 @@ void Yap_EvalError__(const char *file, const char *function, int lineno, buf[0] = '\0'; } va_end(ap); - Yap_ThrowError__(file, function, lineno, type, where, buf); + Yap_Error__(false, file, function, lineno, type, where, buf); } /** diff --git a/C/exec.c b/C/exec.c index ee150dc90..92b341905 100755 --- a/C/exec.c +++ b/C/exec.c @@ -1,4 +1,4 @@ -/************************************************************************* + /************************************************************************* * * * YAP Prolog * * * @@ -18,11 +18,23 @@ static char SccsId[] = "@(#)cdmgr.c 1.1 05/02/98"; #endif +/** + * @file exec.c + * @author VITOR SANTOS COSTA + * @date Mon Apr 30 13:48:35 2018 + * + * @brief meta-call + * + * @namespace prolog + * + * + * + */ + #include "absmi.h" #include "attvar.h" #include "cut_c.h" #include "yapio.h" -#include "yapio.h" static bool CallPredicate(PredEntry *, choiceptr, yamop *CACHE_TYPE); // must hold thread worker comm lock at call. @@ -42,13 +54,12 @@ static choiceptr cp_from_integer(Term cpt USES_REGS) { /** * Represents a choice-point as an offset to the top of local stack. This should * *be stable acroos gc or stack shifts. - * @method Yap_cp_as_integer * @param cp pointer to choice-point * @return Term with offset */ Term Yap_cp_as_integer(choiceptr cp) { CACHE_REGS - return cp_as_integer(cp PASS_REGS); + return cp_as_integer(cp PASS_REGS); } /** @@ -122,16 +133,17 @@ inline static bool CallMetaCall(Term t, Term mod USES_REGS) { /** * Transfer control to a meta-call in ARG1, cut up to B. - * @method Yap_ExecuteCallMetaCall + * + * @param g goal * @param mod current module * @return su */ -Term Yap_ExecuteCallMetaCall(Term mod) { +Term Yap_ExecuteCallMetaCall(Term g, Term mod) { CACHE_REGS - Term ts[4]; - ts[0] = ARG1; + Term ts[4]; + ts[0] = g; ts[1] = cp_as_integer(B PASS_REGS); /* p_current_choice_point */ - ts[2] = ARG1; + ts[2] = g; ts[3] = mod; if (Yap_GetGlobal(AtomDebugMeta) == TermOn) { return Yap_MkApplTerm(PredTraceMetaCall->FunctorOfPred, 3, ts); @@ -141,8 +153,8 @@ Term Yap_ExecuteCallMetaCall(Term mod) { Term Yap_PredicateIndicator(Term t, Term mod) { CACHE_REGS - // generate predicate indicator in this case - Term ti[2]; + // generate predicate indicator in this case + Term ti[2]; t = Yap_YapStripModule(t, &mod); if (IsApplTerm(t) && !IsExtensionFunctor(FunctorOfTerm(t))) { ti[0] = MkAtomTerm(NameOfFunctor(FunctorOfTerm(t))); @@ -215,7 +227,7 @@ static Int save_env_b(USES_REGS1) { static PredEntry *new_pred(Term t, Term tmod, char *pname) { Term t0 = t; - restart: +restart: if (IsVarTerm(t)) { Yap_Error(INSTANTIATION_ERROR, t0, pname); return NULL; @@ -270,7 +282,7 @@ static bool CommaCall(Term t, Term mod) { } inline static bool do_execute(Term t, Term mod USES_REGS) { - Term t0 = t; + Term t0 = t, mod0 = mod; t = Yap_YapStripModule(t, &mod); /* first do predicate expansion, even before you process signals. This way you don't get to spy goal_expansion(). */ @@ -279,7 +291,7 @@ inline static bool do_execute(Term t, Term mod USES_REGS) { return EnterCreepMode(t, mod PASS_REGS); } if (IsVarTerm(t) || IsVarTerm(mod)) { - return CallError(INSTANTIATION_ERROR, t0, mod PASS_REGS); + return CallError(INSTANTIATION_ERROR, t0, mod0 PASS_REGS); } if (IsApplTerm(t)) { register Functor f = FunctorOfTerm(t); @@ -291,9 +303,9 @@ inline static bool do_execute(Term t, Term mod USES_REGS) { if (f == FunctorComma && false) { Term t2 = ArgOfTerm(2, t); if (IsVarTerm(t2)) - return CallMetaCall(t, mod PASS_REGS); + return CallMetaCall(t0, mod0 PASS_REGS); if (1 || !CommaCall(t2, mod)) - return CallMetaCall(t, mod PASS_REGS); + return CallMetaCall(t0, mod0 PASS_REGS); Term t1 = ArgOfTerm(1, t); t = t1; @@ -302,11 +314,11 @@ inline static bool do_execute(Term t, Term mod USES_REGS) { return do_execute(t, mod); } } else if (IsExtensionFunctor(f)) { - return CallError(TYPE_ERROR_CALLABLE, t, mod PASS_REGS); + return CallError(TYPE_ERROR_CALLABLE, t0, mod0 PASS_REGS); } arity = ArityOfFunctor(f); if (arity > MaxTemps) { - return CallError(TYPE_ERROR_CALLABLE, t, mod PASS_REGS); + return CallError(TYPE_ERROR_CALLABLE, t0, mod0 PASS_REGS); } pen = RepPredProp(PredPropByFunc(f, mod)); /* You thought we would be over by now */ @@ -315,8 +327,8 @@ inline static bool do_execute(Term t, Term mod USES_REGS) { /* I cannot use the standard macro here because otherwise I would dereference the argument and might skip a svar */ - if (pen->PredFlags & MetaPredFlag) { - return CallMetaCall(t, mod PASS_REGS); + if (pen->PredFlags & (MetaPredFlag | UndefPredFlag | SpiedPredFlag)) { + return CallMetaCall(t0, mod0 PASS_REGS); } pt = RepAppl(t) + 1; for (i = 1; i <= arity; i++) { @@ -347,7 +359,7 @@ inline static bool do_execute(Term t, Term mod USES_REGS) { pe = RepPredProp(PredPropByAtom(a, mod)); return (CallPredicate(pe, B, pe->CodeOfPred PASS_REGS)); } - return CallMetaCall(t, mod PASS_REGS); + return CallMetaCall(t0, mod0 PASS_REGS); } static Term copy_execn_to_heap(Functor f, CELL *pt, unsigned int n, @@ -391,17 +403,17 @@ inline static bool do_execute_n(Term t, Term mod, unsigned int n USES_REGS) { PredEntry *pen; unsigned int i, arity; int j = -n; - Term t0 = t; + Term t0 = t, mod0 = mod; - restart_exec: +restart_exec: if (IsVarTerm(t)) { - return CallError(INSTANTIATION_ERROR, t0, mod PASS_REGS); + return CallError(INSTANTIATION_ERROR, t0, mod0 PASS_REGS); } else if (IsAtomTerm(t)) { arity = n; Name = AtomOfTerm(t); pt = NULL; } else if (IsIntTerm(t)) { - return CallError(TYPE_ERROR_CALLABLE, t, mod PASS_REGS); + return CallError(TYPE_ERROR_CALLABLE, t, mod0 PASS_REGS); } else if (IsPairTerm(t)) { arity = n + 2; pt = RepPair(t); @@ -416,9 +428,9 @@ inline static bool do_execute_n(Term t, Term mod, unsigned int n USES_REGS) { goto restart_exec; } else { if (IsVarTerm(tmod)) { - return CallError(INSTANTIATION_ERROR, t0, tmod PASS_REGS); + return CallError(INSTANTIATION_ERROR, t0, mod0 PASS_REGS); } else { - return CallError(TYPE_ERROR_ATOM, t0, tmod PASS_REGS); + return CallError(TYPE_ERROR_ATOM, t0, mod0 PASS_REGS); } } } @@ -428,23 +440,23 @@ inline static bool do_execute_n(Term t, Term mod, unsigned int n USES_REGS) { } f = Yap_MkFunctor(Name, arity); if (IsExtensionFunctor(f)) { - return CallError(TYPE_ERROR_CALLABLE, t, mod PASS_REGS); + return CallError(TYPE_ERROR_CALLABLE, t0, mod0 PASS_REGS); } if (Yap_has_a_signal() && !LOCAL_InterruptsDisabled) { return EnterCreepMode( - copy_execn_to_heap(f, pt, n, arity, CurrentModule PASS_REGS), - mod PASS_REGS); + copy_execn_to_heap(f, pt, n, arity, CurrentModule PASS_REGS), + mod PASS_REGS); } if (arity > MaxTemps) { - return CallError(TYPE_ERROR_CALLABLE, t, mod PASS_REGS); + return CallError(TYPE_ERROR_CALLABLE, t0, mod0 PASS_REGS); } pen = RepPredProp(PredPropByFunc(f, mod)); /* You thought we would be over by now */ /* but no meta calls require special preprocessing */ - if (pen->PredFlags & MetaPredFlag) { - Term t = copy_execn_to_heap(f, pt, n, arity, mod PASS_REGS); - return (CallMetaCall(t, mod PASS_REGS)); - } + // if (pen->PredFlags & (MetaPredFlag | UndefPredFlag)) { + // Term t = copy_execn_to_heap(f, pt, n, arity, mod PASS_REGS); + // return (CallMetaCall(t0, mod0 PASS_REGS)); + //} /* now let us do what we wanted to do from the beginning !! */ /* I cannot use the standard macro here because otherwise I would dereference the argument and @@ -650,7 +662,7 @@ static Int execute_clause(USES_REGS1) { /* '$execute_clause'(Goal) */ yamop *code; Term clt = Deref(ARG3); - restart_exec: +restart_exec: if (IsVarTerm(t)) { Yap_Error(INSTANTIATION_ERROR, ARG3, "call/1"); return FALSE; @@ -712,26 +724,6 @@ static Int execute_in_mod(USES_REGS1) { /* '$execute'(Goal) */ return do_execute(Deref(ARG1), Deref(ARG2) PASS_REGS); } -typedef enum { - CALLED_FROM_CALL = 0x1, - CALLED_FROM_ANSWER = 0x2, - CALLED_FROM_EXIT = 0x4, - CALLED_FROM_RETRY = 0x8, - CALLED_FROM_FAIL = 0x18, - CALLED_FROM_CUT = 0x20, - CALLED_FROM_EXCEPTION = 0x40, - CALLED_FROM_THROW = 0x80 -} execution_port; - -INLINE_ONLY inline bool called_from_forward(execution_port port) { - return port & (CALLED_FROM_EXIT | CALLED_FROM_CALL | CALLED_FROM_ANSWER | - CALLED_FROM_CUT | CALLED_FROM_THROW); -} - -INLINE_ONLY inline bool called_from_backward(execution_port port) { - return port & (CALLED_FROM_RETRY | CALLED_FROM_FAIL | CALLED_FROM_EXCEPTION); -} - /** * remove choice points created since a call to top-goal. * @@ -744,24 +736,21 @@ static void prune_inner_computation(choiceptr parent) { Int oENV = LCL0 - ENV; cut_pt = B; - while (cut_pt < parent) { - /* make sure we - e C-choicepoints */ - if (POP_CHOICE_POINT(cut_pt->cp_b)) { - POP_EXECUTE(); - } + while (cut_pt->cp_b < parent) { cut_pt = cut_pt->cp_b; } #ifdef YAPOR CUT_prune_to(cut_pt); #endif - B = parent; + B = cut_pt; Yap_TrimTrail(); LOCAL_AllowRestart = FALSE; P = oP; CP = oCP; ENV = LCL0 - oENV; + B = parent; } + /** * restore abstract machine state * after completing a computation. @@ -789,160 +778,82 @@ static void complete_inner_computation(choiceptr old_B) { ENV = myB->cp_env; } -static inline Term *GetTermAddress(CELL a) { - Term *b = NULL; - restart: - if (!IsVarTerm(a)) { - return (b); - } else if (a == (CELL)b) { - return (b); +static Int Yap_ignore(Term t, bool fail USES_REGS) { + yamop *oP = P, *oCP = CP; + Int oENV = LCL0 - ENV; + Int oYENV = LCL0 - YENV; + Int oB = LCL0 - (CELL *)B; + yap_error_descriptor_t *ctx = malloc(sizeof(yap_error_descriptor_t)); + bool newxp = Yap_pushErrorContext(true, ctx); + bool rc = Yap_RunTopGoal(t, false); + if (!rc) { + complete_inner_computation((choiceptr)(LCL0 - oB)); + // We'll pass it through } else { - b = (CELL *)a; - a = *b; - goto restart; + prune_inner_computation((choiceptr)(LCL0 - oB)); } -} - -/** - * call a cleanup routine taking care with the status variable. - */ -static bool call_cleanup(Term t3, Term t4, Term cleanup, - choiceptr B0 USES_REGS) { - CELL *pt = GetTermAddress(t3); - DBTerm *ball = Yap_RefToException(); - if (pt == NULL) - return false; - *pt = cleanup; - bool out = Yap_RunTopGoal(t4, true); - if (out) { - prune_inner_computation(B0); - } else { - complete_inner_computation(B0); - } - pt = GetTermAddress(t3); - if (ball) - Yap_CopyException(ball); - if (pt == NULL) { - return false; - } - RESET_VARIABLE(pt); + Yap_popErrorContext(newxp, true); + P = oP; + CP = oCP; + ENV = LCL0 - oENV; + YENV = LCL0 - oYENV; + B = (choiceptr)(LCL0 - oB); return true; } -/** - * What to do when we exit a protected call - * @method exit_set_call - * @param exec_result result of call (0 or 1) - * @param b0 original choicepointer (pointed to by root) - * @param t3 state - * @param b0 user goal to call on port. - * - * @param USES_REGS [description] - * @return [description] - */ -static bool exit_set_call(execution_port exec_result, choiceptr B0, yamop *oCP, - Term t3, Term t4 USES_REGS) { - Term rc; - - switch (exec_result) { - // we failed - // Exception: we'll pass it through - case CALLED_FROM_EXCEPTION: - // internal exception - { - Term ball = Yap_PeekException(); - Term signal = Yap_MkApplTerm(FunctorException, 1, &ball); - rc = signal; - B = B0; - } - break; - case CALLED_FROM_THROW: - // internal exception - { - Term ball = Yap_PeekException(); - Term signal = Yap_MkApplTerm(FunctorException, 1, &ball); - rc = signal; - B = B0; - } - break; - case CALLED_FROM_RETRY: - // external exception - rc = TermRetry; - // internal failure - return true; - break; - case CALLED_FROM_FAIL: - B = B0; - rc = TermFail; - break; - case CALLED_FROM_EXIT: - // deterministic exit - rc = TermExit; - if (B->cp_b == B0) { - CP = B->cp_cp; - ENV = B->cp_env; - ASP = (CELL *)B; - B = B0; - } - break; - case CALLED_FROM_CUT: - if (B->cp_b == B0) { - CP = B->cp_cp; - ENV = B->cp_env; - ASP = (CELL *)B; - B = B0; - } - rc = TermCut; - break; - case CALLED_FROM_CALL: - // cut exit - rc = TermCall; - break; - case CALLED_FROM_ANSWER: - // cut exit - rc = TermAnswer; - // non deterministic - choiceptr saved_b = B; - CELL *pt = ASP; - CUT_C_PUSH( - NEXTOP(NEXTOP(PredProtectStack->cs.p_code.FirstClause, OtapFs), OtapFs), - pt); // this is where things get complicated, we need to - // protect the stack and be able to backtrack - pt -= 4; - pt[3] = t4; - pt[2] = t3; - pt[1] = MkAddressTerm(oCP); - pt[0] = MkIntegerTerm(LCL0 - (CELL *)B0); - B = (choiceptr)pt; - B--; - B->cp_h = HR; - B->cp_tr = TR; - B->cp_cp = oCP; - B->cp_ap = NEXTOP(PredProtectStack->cs.p_code.FirstClause, OtapFs); - B->cp_env = ENV; - B->cp_b = saved_b; -#ifdef DEPTH_LIMIT - B->cp_depth = saved_b->cp_depth; -#endif /* DEPTH_LIMIT */ - YENV = ASP = (CELL *)B; - YENV[E_CB] = (CELL)B; - HB = HR; - - return true; - } - call_cleanup(t3, t4, rc, B PASS_REGS); +extern void *Yap_blob_info(Term t); +static bool set_watch(Int Bv, Term task) { + CELL *pt; + Term t = Yap_AllocExternalDataInStack((CELL)setup_call_catcher_cleanup_tag, + sizeof(Int), &pt); + if (t == TermNil) + return false; + *pt = Bv; + *HR++ = t; + *HR++ = task; + TrailTerm(TR) = AbsPair(HR - 2); + TR++; return true; } -static Int protect_stack_from_cut(USES_REGS1) { +static bool watch_cut(Term ext USES_REGS) { // called after backtracking.. - /* reinitialize the engine */ - /* the first real choice-point will also have AP=FAIL */ - /* always have an empty slots for people to use */ - YENV = ASP = (CELL *)B; - call_cleanup(B->cp_a3, B->cp_a4, (P == FAILCODE ? TermException : TermCut), - B PASS_REGS); + // + Term task = TailOfTerm(ext); + Term cleanup = ArgOfTerm(3, task); + Term e = 0; + bool complete = IsNonVarTerm(Deref(ArgOfTerm(4, task))); + bool active = ArgOfTerm(5, task) == TermTrue; + bool ex_mode = false; + + if (complete) { + return true; + } + CELL *port_pt = deref_ptr(RepAppl(task) + 2); + CELL *completion_pt = deref_ptr(RepAppl(task) + 4); + if (LOCAL_ActiveError && LOCAL_ActiveError->errorNo != YAP_NO_ERROR) { + e = MkErrorTerm(LOCAL_ActiveError); + Term t; + if (active) { + t = Yap_MkApplTerm(FunctorException, 1, &e); + } else { + t = Yap_MkApplTerm(FunctorExternalException, 1, &e); + } + port_pt[0] = t; + completion_pt[0] = TermException; + } else { + completion_pt[0] = port_pt[0] = TermCut; + } + Yap_ignore(cleanup, false); + CELL *complete_pt = deref_ptr(RepAppl(task) + 4); + complete_pt[0] = TermTrue; + if (ex_mode) { + // Yap_PutException(e); + return true; + } + if (Yap_RaiseException()) + return false; return true; } @@ -953,57 +864,56 @@ static Int protect_stack_from_cut(USES_REGS1) { * @method protect_stack_from_restore * @param USES_REGS1 [env for threaded execution] * @return c - [next answer] -*/ -static Int protect_stack_from_retry(USES_REGS1) { + */ +static bool watch_retry(Term d0 USES_REGS) { // called after backtracking.. // - yamop *oP = P; - Int oENV = LCL0 - ENV; - yamop *oCP = (yamop *)AddressOfTerm(B->cp_a2); - Term t3 = B->cp_a3; - Term t4 = B->cp_a4; - Int b0 = IntegerOfTerm(ARG1); - choiceptr B0 = (choiceptr)(LCL0 - b0); + Term task = TailOfTerm(d0); + bool box = ArgOfTerm(1, task) == TermTrue; + Term cleanup = ArgOfTerm(3, task); + bool complete = !IsVarTerm(ArgOfTerm(4, task)); + bool active = ArgOfTerm(5, task) == TermTrue; + choiceptr B0 = (choiceptr)(LCL0 - IntegerOfTerm(ArgOfTerm(6, task))); - cut_c_pop(); + if (complete) + return true; + CELL *port_pt = deref_ptr(RepAppl(Deref(task)) + 2); + CELL *complete_pt = deref_ptr(RepAppl(Deref(task)) + 4); + Term t, e = 0; + bool ex_mode = false; - // call_cleanup(t3, t4, TermRetry, B0 USES_REGS); - // binding to t3 should be undone - // by next backtrack. - /* first, destroy the current choice-point, - */ - B = B->cp_b; - // B should lead to CP with _ystop,, - P = FAILCODE; - bool res = Yap_exec_absmi(false, CurrentModule); - /* reinitialize the engine */ - /* the first real choice-point will also have AP=FAIL */ - /* always have an empty slots for people to use */ - // ensure that we have slots where we need the - execution_port p; - if (res) { - if (Yap_HasException()) { - p = CALLED_FROM_THROW; - } else if (B->cp_b >= B0) { - p = CALLED_FROM_EXIT; - } else - p = CALLED_FROM_ANSWER; + while (B->cp_ap->opc == FAIL_OPCODE) + B = B->cp_b; + + // just do the frrpest + if (B >= B0 && !ex_mode && !active) + return true; + if (LOCAL_ActiveError && LOCAL_ActiveError->errorNo != YAP_NO_ERROR) { + e = MkErrorTerm(LOCAL_ActiveError); + if (active) { + t = Yap_MkApplTerm(FunctorException, 1, &e); + } else { + t = Yap_MkApplTerm(FunctorExternalException, 1, &e); + } + complete_pt[0] = TermException; + } else if (B >= B0) { + t = TermFail; + complete_pt[0] = t; + + } else if (box) { + t = TermRedo; } else { - if (Yap_HasException()) - p = CALLED_FROM_EXCEPTION; - else - p = CALLED_FROM_FAIL; + return true; } - Int rc = exit_set_call(p, B0, oCP, t3, t4 PASS_REGS); - if (rc) { - CP = oCP; - P = oP; - ENV = LCL0 - oENV; + port_pt[0] = t; + Yap_ignore(cleanup, true); + if (ex_mode) { + // Yap_PutException(e); + return true; } if (Yap_RaiseException()) return false; - return res; + return true; } /** @@ -1014,25 +924,14 @@ static Int protect_stack_from_retry(USES_REGS1) { * @param USES_REGS1 [env for threaded execution] * @return [always succeed] */ -static Int protect_stack(USES_REGS1) { - - // just create the choice-point; - return true; -} static Int setup_call_catcher_cleanup(USES_REGS1) { Term Setup = Deref(ARG1); - Int oENV = LCL0 - ENV; choiceptr B0 = B; - Term t3, t4; - yhandle_t hl = Yap_StartSlots(); - yhandle_t h2 = Yap_InitHandle(ARG2); - yhandle_t h3 = Yap_InitHandle(t3 = Deref(ARG3)); - yhandle_t h4 = Yap_InitHandle(ARG4); - yamop *oCP = CP, *oP = P; + yamop *oP = P, *oCP = CP; + Int oENV = LCL0 - ENV; + Int oYENV = LCL0 - YENV; bool rc; - execution_port port; - Yap_DisableInterrupts(worker_id); rc = Yap_RunTopGoal(Setup, false); Yap_EnableInterrupts(worker_id); @@ -1042,57 +941,66 @@ static Int setup_call_catcher_cleanup(USES_REGS1) { } if (!rc) { complete_inner_computation(B0); - // We'll pass it through + // We'll pass it throughs return false; } else { prune_inner_computation(B0); } - // at this point starts actual goal execution.... - rc = Yap_RunTopGoal(Yap_GetFromSlot(h2), false); - complete_inner_computation(B); - t4 = Yap_GetFromSlot(h4); - t3 = Yap_GetFromSlot(h3); - // make sure that t3 point to our nice cell. - Yap_CloseSlots(hl); + P = oP; + CP = oCP; + ENV = LCL0 - oENV; + YENV = LCL0 - oYENV; + return rc; +} - if (rc) { - // ignore empty choice - while (B->cp_ap->opc == FAIL_OPCODE) - B = B->cp_b; - if (Yap_HasException()) { - port = CALLED_FROM_THROW; - } else if (B->cp_b < B0) { - port = CALLED_FROM_ANSWER; - } else { - port = CALLED_FROM_EXIT; +static Int tag_cleanup(USES_REGS1) { + Int iB = LCL0 - (CELL *)B; + set_watch(iB, Deref(ARG2)); + return Yap_unify(ARG1, MkIntegerTerm(iB)); +} + +static Int cleanup_on_exit(USES_REGS1) { + + choiceptr B0 = (choiceptr)(LCL0 - IntegerOfTerm(Deref(ARG1))); + Term task = Deref(ARG2); + bool box = ArgOfTerm(1, task) == TermTrue; + Term cleanup = ArgOfTerm(3, task); + Term complete = IsNonVarTerm(ArgOfTerm(4, task)); + + while (B->cp_ap->opc == FAIL_OPCODE) + B = B->cp_b; + + if (complete) { + return true; + } + CELL *catcher_pt = deref_ptr(RepAppl(Deref(task)) + 2); + CELL *complete_pt = deref_ptr(RepAppl(Deref(task)) + 4); + if (B < B0) { + // non-deterministic + set_watch(LCL0 - (CELL *)B, task); + if (!box) { + return true; } + catcher_pt[0] = TermAnswer; } else { - if (Yap_HasException()) - port = CALLED_FROM_EXCEPTION; - else - port = CALLED_FROM_FAIL; - } - // store the correct CP, ENV can be recovered from last env. - bool e = exit_set_call(port, B0, oCP, t3, t4 PASS_REGS); - // ensure we have same P - // also, we cannot trust recovered ENV and CP - if (e) { - P = oP; - CP = oCP; - ENV = LCL0 - oENV; + catcher_pt[0] = TermExit; + complete_pt[0] = TermExit; } + Yap_ignore(cleanup, false); + if (B0->cp_ap == NOCODE) + B0->cp_ap = TRUSTFAILCODE; if (Yap_RaiseException()) { return false; } - return rc; + return true; } static bool complete_ge(bool out, Term omod, yhandle_t sl, bool creeping) { CACHE_REGS - if (creeping) { - Yap_signal(YAP_CREEP_SIGNAL); - } + if (creeping) { + Yap_signal(YAP_CREEP_SIGNAL); + } CurrentModule = omod; Yap_CloseSlots(sl); if (out) { @@ -1122,7 +1030,7 @@ static Int _user_expand_goal(USES_REGS1) { ARG1 = Yap_MkApplTerm(FunctorModule, 2, mg_args); ARG2 = Yap_GetFromSlot(h2); if ((pe = RepPredProp( - Yap_GetPredPropByFunc(FunctorGoalExpansion2, SYSTEM_MODULE))) && + Yap_GetPredPropByFunc(FunctorGoalExpansion2, SYSTEM_MODULE))) && pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE && Yap_execute_pred(pe, NULL, false PASS_REGS)) { return complete_ge(true, omod, sl, creeping); @@ -1132,7 +1040,7 @@ static Int _user_expand_goal(USES_REGS1) { ARG3 = Yap_GetFromSlot(h2); /* user:goal_expansion(A,CurMod,B) */ if ((pe = RepPredProp( - Yap_GetPredPropByFunc(FunctorGoalExpansion, USER_MODULE))) && + Yap_GetPredPropByFunc(FunctorGoalExpansion, USER_MODULE))) && pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE && Yap_execute_pred(pe, NULL PASS_REGS, false)) { return complete_ge(true, omod, sl, creeping); @@ -1144,7 +1052,7 @@ static Int _user_expand_goal(USES_REGS1) { /* user:goal_expansion(A,B) */ if (cmod != USER_MODULE && /* we have tried this before */ (pe = RepPredProp( - Yap_GetPredPropByFunc(FunctorGoalExpansion2, USER_MODULE))) && + Yap_GetPredPropByFunc(FunctorGoalExpansion2, USER_MODULE))) && pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE && Yap_execute_pred(pe, NULL PASS_REGS, false)) { return complete_ge(true, omod, sl, creeping); @@ -1164,7 +1072,7 @@ static Int do_term_expansion(USES_REGS1) { ARG1 = g; if ((pe = RepPredProp( - Yap_GetPredPropByFunc(FunctorTermExpansion, USER_MODULE))) && + Yap_GetPredPropByFunc(FunctorTermExpansion, USER_MODULE))) && pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE && Yap_execute_pred(pe, NULL, false PASS_REGS)) { return complete_ge(true, omod, sl, creeping); @@ -1183,7 +1091,7 @@ static Int do_term_expansion(USES_REGS1) { ARG1 = Yap_MkApplTerm(FunctorModule, 2, mg_args); ARG2 = Yap_GetFromSlot(h2); if ((pe = RepPredProp( - Yap_GetPredPropByFunc(FunctorTermExpansion, SYSTEM_MODULE))) && + Yap_GetPredPropByFunc(FunctorTermExpansion, SYSTEM_MODULE))) && pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE && Yap_execute_pred(pe, NULL, false PASS_REGS)) { return complete_ge(true, omod, sl, creeping); @@ -1201,7 +1109,7 @@ static Int execute0(USES_REGS1) { /* '$execute0'(Goal,Mod) */ return EnterCreepMode(t, mod PASS_REGS); } t = Yap_YapStripModule(t, &mod); - restart_exec: +restart_exec: if (IsVarTerm(t)) { Yap_Error(INSTANTIATION_ERROR, ARG3, "call/1"); return false; @@ -1260,8 +1168,91 @@ static Int execute0(USES_REGS1) { /* '$execute0'(Goal,Mod) */ RepPredProp(pe)->CodeOfPred PASS_REGS); } -static Int execute_nonstop(USES_REGS1) { /* '$execute_nonstop'(Goal,Mod) - */ +static Int creep_step(USES_REGS1) { /* '$execute_nonstop'(Goal,Mod) + */ + Term t = Deref(ARG1); + Term mod = Deref(ARG2); + unsigned int arity; + Prop pe; + bool rc; + t = Yap_YapStripModule(t, &mod); + if (IsVarTerm(mod)) { + mod = CurrentModule; + } else if (!IsAtomTerm(mod)) { + Yap_Error(TYPE_ERROR_ATOM, ARG2, "call/1"); + return FALSE; + } + if (IsVarTerm(t)) { + Yap_Error(INSTANTIATION_ERROR, ARG1, "call/1"); + return FALSE; + } else if (IsAtomTerm(t)) { + Atom a = AtomOfTerm(t); + pe = PredPropByAtom(a, mod); + } else if (IsApplTerm(t)) { + register Functor f = FunctorOfTerm(t); + register unsigned int i; + register CELL *pt; + + if (IsExtensionFunctor(f)) + return (FALSE); + pe = PredPropByFunc(f, mod); + arity = ArityOfFunctor(f); + if (arity > MaxTemps) { + return CallError(TYPE_ERROR_CALLABLE, t, mod PASS_REGS); + } + /* I cannot use the standard macro here because + otherwise I would dereference the argument and + might skip a svar */ + pt = RepAppl(t) + 1; + for (i = 1; i <= arity; ++i) { +#if YAPOR_SBA + Term d0 = *pt++; + if (d0 == 0) + XREGS[i] = (CELL)(pt - 1); + else + XREGS[i] = d0; +#else + XREGS[i] = *pt++; +#endif + } + } else { + Yap_Error(TYPE_ERROR_CALLABLE, t, "call/1"); + return FALSE; + } + /* N = arity; */ + /* call may not define new system predicates!! */ + if (RepPredProp(pe)->PredFlags & SpiedPredFlag) { + if (!LOCAL_InterruptsDisabled && Yap_get_signal(YAP_CREEP_SIGNAL)) { + Yap_signal(YAP_CREEP_SIGNAL); + } +#if defined(YAPOR) || defined(THREADS) + if (RepPredProp(pe)->PredFlags & LogUpdatePredFlag) { + PP = RepPredProp(pe); + PELOCK(80, PP); + } +#endif + rc = CallPredicate(RepPredProp(pe), B, + RepPredProp(pe)->cs.p_code.TrueCodeOfPred PASS_REGS); + } else { + rc = CallPredicate(RepPredProp(pe), B, + RepPredProp(pe)->CodeOfPred PASS_REGS); + } + if (!LOCAL_InterruptsDisabled && + (!(RepPredProp(pe)->PredFlags & (AsmPredFlag | CPredFlag)) || + RepPredProp(pe)->OpcodeOfPred == Yap_opcode(_call_bfunc_xx))) { + Yap_signal(YAP_CREEP_SIGNAL); + } + return rc; +} + +/** + * @brief Two argument version of non-interruptible execution: this will + * ignore signals including debugging requests. + * + * @return Int succeeds if it can transfer control. + */ + +static Int execute_nonstop(USES_REGS1) { Term t = Deref(ARG1); Term mod = Deref(ARG2); unsigned int arity; @@ -1336,6 +1327,17 @@ static Int execute_nonstop(USES_REGS1) { /* '$execute_nonstop'(Goal,Mod) } } +/** + * @brief One argument version of non-interruptible execution: this will + * ignore signals including debugging requests. + * + * @return Int succeeds if it can transfer control. + */ +static Int execute_nonstop1(USES_REGS1) { + ARG2 = CurrentModule; + return execute_nonstop(PASS_REGS1); +} + static Int execute_0(USES_REGS1) { /* '$execute_0'(Goal) */ Term mod = CurrentModule; Term t = Yap_YapStripModule(Deref(ARG1), &mod); @@ -1417,17 +1419,23 @@ static Int execute_depth_limit(USES_REGS1) { #endif static bool exec_absmi(bool top, yap_reset_t reset_mode USES_REGS) { - int lval, out; + int lval = 0, out; Int OldBorder = LOCAL_CBorder; - LOCAL_CBorder = LCL0 - (CELL *)B; + // yap_error_descriptor_t *err_info= LOCAL_ActiveError; + LOCAL_CBorder = LCL0 - ENV; + LOCAL_MallocDepth = AllocLevel(); + yhandle_t sls = Yap_CurrentSlot(); + sigjmp_buf signew, *sighold = LOCAL_RestartEnv; LOCAL_RestartEnv = &signew; - - if (top && (lval = sigsetjmp(signew, 1)) != 0) { + volatile int i = AllocLevel(); + if /* top &&*/ ((lval = sigsetjmp(signew, 1)) != 0) { switch (lval) { case 1: { /* restart */ - /* otherwise, SetDBForThrow will fail entering critical mode */ + /* otherwise, SetDBForThrow will fail entering critical mode */ + // LOCAL_ActiveError = err_info; LOCAL_PrologMode = UserMode; + LOCAL_DoingUndefp = false; /* find out where to cut to */ /* siglongjmp resets the TR hardware register */ /* TR and B are crucial, they might have been changed, or not */ @@ -1441,58 +1449,83 @@ static bool exec_absmi(bool top, yap_reset_t reset_mode USES_REGS) { LOCAL_Signals = 0; CalculateStackGap(PASS_REGS1); LOCAL_PrologMode = UserMode; + Yap_CloseSlots(sls); P = (yamop *)FAILCODE; } break; case 2: { + // LOCAL_ActiveError = err_info; /* arithmetic exception */ /* must be done here, otherwise siglongjmp will clobber all the * registers */ /* reset the registers so that we don't have trash in abstract * machine */ + pop_text_stack(i + 1); Yap_set_fpu_exceptions( - getAtomicGlobalPrologFlag(ARITHMETIC_EXCEPTIONS_FLAG)); + getAtomicGlobalPrologFlag(ARITHMETIC_EXCEPTIONS_FLAG)); P = (yamop *)FAILCODE; LOCAL_PrologMode = UserMode; + LOCAL_DoingUndefp = false; + Yap_CloseSlots(sls); } break; case 3: { /* saved state */ + // LOCAL_ActiveError = err_info; + pop_text_stack(i + 1); LOCAL_CBorder = OldBorder; LOCAL_RestartEnv = sighold; + LOCAL_PrologMode = UserMode; + LOCAL_DoingUndefp = false; + Yap_CloseSlots(sls); return false; } case 4: /* abort */ /* can be called from anywhere, must reset registers, */ + // LOCAL_ActiveError = err_info; while (B) { - Yap_JumpToEnv(TermDAbort); - } - LOCAL_PrologMode &= ~AbortMode; + LOCAL_ActiveError->errorNo = ABORT_EVENT; + pop_text_stack(i + 1); + Yap_CloseSlots(sls); + Yap_JumpToEnv(); + } + LOCAL_PrologMode = UserMode; + LOCAL_DoingUndefp = false; P = (yamop *)FAILCODE; - if (LOCAL_CBorder) - LOCAL_CBorder = OldBorder; LOCAL_RestartEnv = sighold; - return false; + Yap_CloseSlots(sls); + pop_text_stack(i + 1); + return false; break; case 5: // going up, unless there is no up to go to. or someone // but we should inform the caller on what happened. - if (B && B->cp_b && B->cp_b <= (choiceptr)(LCL0-LOCAL_CBorder)) { - break; + + // Yap_regp = old_rs; + // LOCAL_ActiveError = err_info; + restore_TR(); + restore_B(); + /* H is not so important, because we're gonna backtrack */ + restore_H(); + /* set stack */ + Yap_JumpToEnv(); + Yap_CloseTemporaryStreams(); + Yap_CloseSlots(sls); + ASP = (CELL *)PROTECT_FROZEN_B(B); + + if (B == NULL || B->cp_b == NULL || + (CELL *)(B->cp_b) > LCL0 - LOCAL_CBorder) { + LOCAL_RestartEnv = sighold; + LOCAL_CBorder = OldBorder; + pop_text_stack(i + 1); + return false; } - LOCAL_RestartEnv = sighold; - LOCAL_PrologMode = UserMode; - LOCAL_CBorder = OldBorder; - return false; - default: - /* do nothing */ - LOCAL_PrologMode = UserMode; + P = FAILCODE; } - } else { - LOCAL_PrologMode = UserMode; } YENV = ASP; YENV[E_CB] = Unsigned(B); + pop_text_stack(i + 1); out = Yap_absmi(0); /* make sure we don't leave a FAIL signal hanging around */ Yap_get_signal(YAP_FAIL_SIGNAL); @@ -1500,6 +1533,7 @@ static bool exec_absmi(bool top, yap_reset_t reset_mode USES_REGS) { CalculateStackGap(PASS_REGS1); LOCAL_CBorder = OldBorder; LOCAL_RestartEnv = sighold; + pop_text_stack(i + 1); return out; } @@ -1550,16 +1584,13 @@ void Yap_PrepGoal(arity_t arity, CELL *pt, choiceptr saved_b USES_REGS) { static bool do_goal(yamop *CodeAdr, int arity, CELL *pt, bool top USES_REGS) { choiceptr saved_b = B; bool out; - Yap_PrepGoal(arity, pt, saved_b PASS_REGS); - CACHE_A1(); + // CACHE_A1(); P = (yamop *)CodeAdr; // S = CellPtr(RepPredProp( // PredPropByFunc(Yap_MkFunctor(AtomCall, 1), 0))); /* A1 mishaps */ out = exec_absmi(top, YAP_EXEC_ABSMI PASS_REGS); - if (top) - Yap_flush(); // if (out) { // out = Yap_GetFromSlot(sl); // } @@ -1570,13 +1601,13 @@ static bool do_goal(yamop *CodeAdr, int arity, CELL *pt, bool top USES_REGS) { bool Yap_exec_absmi(bool top, yap_reset_t has_reset) { CACHE_REGS - return exec_absmi(top, has_reset PASS_REGS); + return exec_absmi(top, has_reset PASS_REGS); } /** * Fails computation up to choice-point bb - * @method Yap_fail_all - * @param USES_REGS [description] + * + * @param USES_REGS thread support */ void Yap_fail_all(choiceptr bb USES_REGS) { yamop *saved_p, *saved_cp; @@ -1584,6 +1615,8 @@ void Yap_fail_all(choiceptr bb USES_REGS) { saved_p = P; saved_cp = CP; /* prune away choicepoints */ + if (B == bb) + return; while (B->cp_b && B->cp_b != bb && B->cp_ap != NOCODE) { B = B->cp_b; #ifdef YAPOR @@ -1673,6 +1706,7 @@ bool Yap_execute_pred(PredEntry *ppe, CELL *pt, bool pass_ex USES_REGS) { /* we have failed, and usually we would backtrack to this B, trouble is, we may also have a delayed cut to do */ if (B != NULL) + HB = B->cp_h; YENV = ENV; // should we catch the exception or pass it through? @@ -1711,7 +1745,7 @@ bool Yap_execute_pred(PredEntry *ppe, CELL *pt, bool pass_ex USES_REGS) { bool Yap_execute_goal(Term t, int nargs, Term mod, bool pass_ex) { CACHE_REGS - Prop pe; + Prop pe; PredEntry *ppe; CELL *pt; /* preserve the current restart environment */ @@ -1748,7 +1782,7 @@ bool Yap_execute_goal(Term t, int nargs, Term mod, bool pass_ex) { void Yap_trust_last(void) { CACHE_REGS - ASP = B->cp_env; + ASP = B->cp_env; CP = B->cp_cp; HR = B->cp_h; #ifdef DEPTH_LIMIT @@ -1766,7 +1800,7 @@ void Yap_trust_last(void) { Term Yap_RunTopGoal(Term t, bool handle_errors) { CACHE_REGS - yamop *CodeAdr; + yamop *CodeAdr; Prop pe; PredEntry *ppe; CELL *pt; @@ -1780,7 +1814,14 @@ Term Yap_RunTopGoal(Term t, bool handle_errors) { Yap_Error(INSTANTIATION_ERROR, t, "call/1"); LOCAL_PrologMode &= ~TopGoalMode; return (FALSE); - } else if (IsAtomTerm(t)) { + } + if (IsPairTerm(t)) { + Term ts[2]; + ts[0] = t; + ts[1] = (CurrentModule == 0 ? TermProlog : CurrentModule); + t = Yap_MkApplTerm(FunctorCsult, 2, ts); + } + if (IsAtomTerm(t)) { Atom a = AtomOfTerm(t); pt = NULL; pe = Yap_GetPredPropByAtom(a, tmod); @@ -1812,7 +1853,7 @@ Term Yap_RunTopGoal(Term t, bool handle_errors) { HR[1] = MkAtomTerm(Yap_LookupAtom("top")); arity = 2; HR += 2; - } else if (ppe->PredFlags & MetaPredFlag) { + } else if (ppe->PredFlags & (MetaPredFlag | UndefPredFlag)) { // we're in a meta-call, rake care about modules // Term ts[2]; @@ -1987,20 +2028,28 @@ static Int cut_up_to_next_disjunction(USES_REGS1) { return TRUE; } -bool Yap_Reset(yap_reset_t mode) { +/** + * Reset the Prolog engine . If _Hard_ resèt the global stack_el. If + * p_no_use_'soft_float keei + * + * @param mode + * @param hard + * + * @return + */ +bool Yap_Reset(yap_reset_t mode, bool hard) { CACHE_REGS - int res = TRUE; + int res = TRUE; Yap_ResetException(worker_id); /* first, backtrack to the root */ - while (B->cp_b) { + while (B) { + P = FAILCODE; + Yap_exec_absmi(true, mode); B = B->cp_b; } - // B shoul lead to CP with _ystop0, - P = FAILCODE; - res = Yap_exec_absmi(true, mode); /* reinitialize the engine */ - // Yap_InitYaamRegs( worker_id ); + Yap_InitYaamRegs(worker_id, false); GLOBAL_Initialised = true; ENV = LCL0; ASP = (CELL *)B; @@ -2029,7 +2078,7 @@ bool is_cleanup_cp(choiceptr cp_b) { return pe == PredSafeCallCleanup; } -static Int JumpToEnv() { +static Int JumpToEnv(USES_REGS1) { choiceptr handler = B; /* just keep the throwm object away, we don't need to care about it */ @@ -2037,94 +2086,48 @@ static Int JumpToEnv() { so get pointers here */ /* find the first choicepoint that may be a catch */ // DBTerm *dbt = Yap_RefToException(); - while (handler && Yap_PredForChoicePt(handler, NULL) != PredDollarCatch) { - //printf("--handler=%p, max=%p\n", handler, LCL0-LOCAL_CBorder); - while (POP_CHOICE_POINT(handler)) { - POP_FAIL_EXECUTE(handler); - } - if (handler == (choiceptr)(LCL0-LOCAL_CBorder)) { - break; - } - /* we are already doing a catch */ - /* make sure we prune C-choicepoints */ - if ((handler->cp_ap == NOCODE && handler->cp_b == NULL) || - (handler->cp_b >= (choiceptr)(LCL0 - LOCAL_CBorder))) { - break; - } + while (handler && Yap_PredForChoicePt(handler, NULL) != PredDollarCatch && + LOCAL_CBorder < LCL0 - (CELL *)handler && handler->cp_ap != NOCODE && + handler->cp_b != NULL) { + handler->cp_ap = TRUSTFAILCODE; handler = handler->cp_b; } if (LOCAL_PrologMode & AsyncIntMode) { Yap_signal(YAP_FAIL_SIGNAL); } - POP_FAIL(handler); + B = handler; - // Yap_CopyException(ref); - if (Yap_PredForChoicePt(B, NULL) == PredDollarCatch) { - /* can recover Heap thanks to copy term :-( */ - /* B->cp_h = H; */ - /* I could backtrack here, but it is easier to leave the unwinding - to the emulator */ - // handler->cp_h = HR; - /* try to recover space */ - /* can only do that when we recover space */ - /* first, backtrack */ - /* so that I recover memory execute op_fail */ - // now put the ball in place - // Yap_CopyException(dbt); - Term t = Yap_GetException(); - if (t == 0) { - return false; - } else if (IsVarTerm(t)) { - t = Yap_MkApplTerm(FunctorGVar, 1, &t); - } - B->cp_h = HR; - HB = HR; - Yap_unify(t, B->cp_a2); - B->cp_tr = TR; - } P = FAILCODE; + LOCAL_DoingUndefp = false; return true; } -bool Yap_JumpToEnv(Term t) { +bool Yap_JumpToEnv(void) { CACHE_REGS - LOCAL_BallTerm = Yap_StoreTermInDB(t, 0); - if (!LOCAL_BallTerm) - return false; if (LOCAL_PrologMode & TopGoalMode) return true; - return JumpToEnv(PASS_REGS); + return JumpToEnv(PASS_REGS1); } /* This does very nasty stuff!!!!! */ static Int jump_env(USES_REGS1) { - Term t = Deref(ARG1); + Term t = Deref(ARG1), t0 = t; if (IsVarTerm(t)) { - Yap_Error(INSTANTIATION_ERROR, t, "throw ball must be bound"); - return false; - } else if (IsApplTerm(t) && FunctorOfTerm(t) == FunctorError) { - Term t2; - - Yap_find_prolog_culprit(PASS_REGS1); - // LOCAL_Error_TYPE = ERROR_EVENT; - t = ArgOfTerm(1, t); - if (IsApplTerm(t) && IsAtomTerm((t2 = ArgOfTerm(1, t)))) { - LOCAL_ActiveError->errorAsText = AtomOfTerm(t2); - LOCAL_ActiveError->classAsText = NameOfFunctor(FunctorOfTerm(t)); - } else if (IsAtomTerm(t)) { - LOCAL_ActiveError->errorAsText = AtomOfTerm(t); - LOCAL_ActiveError->classAsText = NULL; - } - } else { - // LOCAL_Error_TYPE = THROW_EVENT; + Yap_ThrowError(INSTANTIATION_ERROR, t, + "throw/1 must be called instantiated"); } - LOCAL_ActiveError->prologPredName = NULL; - Yap_PutException(t); + // Yap_DebugPlWriteln(t); + // char *buf = Yap_TermToBuffer(t, ENC_ISO_UTF8, + // Quote_illegal_f | Ignore_ops_f | + // Unfold_cyclics_f); + // __android_log_print(ANDROID_LOG_INFO, "YAPDroid ", " throw(%s)", buf); + LOCAL_ActiveError = Yap_UserError(t0, LOCAL_ActiveError); bool out = JumpToEnv(PASS_REGS1); if (B != NULL && P == FAILCODE && B->cp_ap == NOCODE && LCL0 - (CELL *)B > LOCAL_CBorder) { // we're failing up to the top layer } + pop_text_stack(LOCAL_MallocDepth + 1); return out; } @@ -2136,7 +2139,7 @@ static Int generate_pred_info(USES_REGS1) { return TRUE; } -void Yap_InitYaamRegs(int myworker_id) { +void Yap_InitYaamRegs(int myworker_id, bool full_reset) { Term h0var; // getchar(); #if PUSH_REGS @@ -2154,11 +2157,11 @@ void Yap_InitYaamRegs(int myworker_id) { #endif #endif /* PUSH_REGS */ CACHE_REGS - Yap_ResetException(worker_id); + Yap_ResetException(LOCAL_ActiveError); Yap_PutValue(AtomBreak, MkIntTerm(0)); TR = (tr_fr_ptr)REMOTE_TrailBase(myworker_id); HR = H0 = ((CELL *)REMOTE_GlobalBase(myworker_id)) + - 1; // +1: hack to ensure the gc does not try to mark mistakenly + 1; // +1: hack to ensure the gc does not try to mark mistakenly LCL0 = ASP = (CELL *)REMOTE_LocalBase(myworker_id); CurrentTrailTop = (tr_fr_ptr)(REMOTE_TrailTop(myworker_id) - MinTrailGap); /* notice that an initial choice-point and environment @@ -2170,19 +2173,29 @@ void Yap_InitYaamRegs(int myworker_id) { DEPTH = RESET_DEPTH(); #endif STATIC_PREDICATES_MARKED = FALSE; - if (REMOTE_GlobalArena(myworker_id) == 0L || - REMOTE_GlobalArena(myworker_id) == TermNil) { + if (full_reset) { + HR = H0 + 1; + h0var = MkVarTerm(); + REMOTE_GcGeneration(myworker_id) = Yap_NewTimedVar(h0var); + REMOTE_GcCurrentPhase(myworker_id) = 0L; + REMOTE_GcPhase(myworker_id) = + Yap_NewTimedVar(MkIntTerm(REMOTE_GcCurrentPhase(myworker_id))); +#if COROUTINING + REMOTE_WokenGoals(myworker_id) = Yap_NewTimedVar(TermNil); + h0var = MkVarTerm(); + REMOTE_AttsMutableList(myworker_id) = Yap_NewTimedVar(h0var); +#endif + Yap_AllocateDefaultArena(128 * 1024, 2, myworker_id); } else { - HR = RepAppl(REMOTE_GlobalArena(myworker_id)); + HR = Yap_ArenaLimit(REMOTE_GlobalArena(myworker_id)); } - REMOTE_GlobalArena(myworker_id) = TermNil; Yap_InitPreAllocCodeSpace(myworker_id); #ifdef FROZEN_STACKS H_FZ = HR; #ifdef YAPOR_SBA BSEG = #endif /* YAPOR_SBA */ - BBREG = B_FZ = (choiceptr)REMOTE_LocalBase(myworker_id); + BBREG = B_FZ = (choiceptr)REMOTE_LocalBase(myworker_id); TR = TR_FZ = (tr_fr_ptr)REMOTE_TrailBase(myworker_id); #endif /* FROZEN_STACKS */ CalculateStackGap(PASS_REGS1); @@ -2192,22 +2205,11 @@ void Yap_InitYaamRegs(int myworker_id) { LOCAL = REMOTE(myworker_id); worker_id = myworker_id; #endif /* THREADS */ -#if COROUTINING - REMOTE_WokenGoals(myworker_id) = Yap_NewTimedVar(TermNil); - h0var = MkVarTerm(); - REMOTE_AttsMutableList(myworker_id) = Yap_NewTimedVar(h0var); -#endif Yap_RebootSlots(myworker_id); - h0var = MkVarTerm(); - REMOTE_GcGeneration(myworker_id) = Yap_NewTimedVar(h0var); - REMOTE_GcCurrentPhase(myworker_id) = 0L; - REMOTE_GcPhase(myworker_id) = - Yap_NewTimedVar(MkIntTerm(REMOTE_GcCurrentPhase(myworker_id))); #if defined(YAPOR) || defined(THREADS) PP = NULL; PREG_ADDR = NULL; #endif - Yap_AllocateDefaultArena(128 * 1024, 2, myworker_id); cut_c_initialize(myworker_id); Yap_PrepGoal(0, NULL, NULL PASS_REGS); #ifdef FROZEN_STACKS @@ -2215,7 +2217,7 @@ void Yap_InitYaamRegs(int myworker_id) { #ifdef YAPOR_SBA BSEG = #endif /* YAPOR_SBA */ - BBREG = B_FZ = (choiceptr)REMOTE_LocalBase(myworker_id); + BBREG = B_FZ = (choiceptr)REMOTE_LocalBase(myworker_id); TR = TR_FZ = (tr_fr_ptr)REMOTE_TrailBase(myworker_id); #endif /* FROZEN_STACKS */ CalculateStackGap(PASS_REGS1); @@ -2226,50 +2228,6 @@ void Yap_InitYaamRegs(int myworker_id) { #endif } -Term Yap_GetException(void) { - CACHE_REGS - Term t = 0; - - if (LOCAL_BallTerm) { - t = Yap_PopTermFromDB(LOCAL_BallTerm); - } - LOCAL_BallTerm = NULL; - return t; -} - -Term Yap_PeekException(void) { return Yap_FetchTermFromDB(LOCAL_BallTerm); } - -bool Yap_RaiseException(void) { - if (LOCAL_BallTerm == NULL) - return false; - return JumpToEnv(); -} - -bool Yap_PutException(Term t) { - CACHE_REGS - if ((LOCAL_BallTerm = Yap_StoreTermInDB(t, 0)) != NULL) - return true; - - return false; -} - -bool Yap_ResetException(int wid) { - if (REMOTE_ActiveError(wid)->errorTerm) { - Yap_PopTermFromDB(REMOTE_ActiveError(wid)->errorTerm); - } - REMOTE_ActiveError(wid)->errorTerm = NULL; - return true; -} - -static Int reset_exception(USES_REGS1) { return Yap_ResetException(worker_id); } - -static Int get_exception(USES_REGS1) { - Term t = Yap_GetException(); - if (t == 0) - return false; - return Yap_unify(t, ARG1); -} - int Yap_dogc(int extra_args, Term *tp USES_REGS) { UInt arity; yamop *nextpc; @@ -2296,7 +2254,13 @@ int Yap_dogc(int extra_args, Term *tp USES_REGS) { void Yap_InitExecFs(void) { CACHE_REGS - Term cm = CurrentModule; + YAP_opaque_handler_t catcher_ops; + memset(&catcher_ops, 0, sizeof(catcher_ops)); + catcher_ops.cut_handler = watch_cut; + catcher_ops.fail_handler = watch_retry; + setup_call_catcher_cleanup_tag = YAP_NewOpaqueType(&catcher_ops); + + Term cm = CurrentModule; Yap_InitComma(); Yap_InitCPred("$execute", 1, execute, 0); Yap_InitCPred("$execute", 2, execute2, 0); @@ -2328,6 +2292,8 @@ void Yap_InitExecFs(void) { #endif Yap_InitCPred("$execute0", 2, execute0, NoTracePredFlag); Yap_InitCPred("$execute_nonstop", 2, execute_nonstop, NoTracePredFlag); + Yap_InitCPred("$execute_nonstop", 1, execute_nonstop1, NoTracePredFlag); + Yap_InitCPred("$creep_step", 2, creep_step, NoTracePredFlag); Yap_InitCPred("$execute_clause", 4, execute_clause, NoTracePredFlag); Yap_InitCPred("$current_choice_point", 1, current_choice_point, 0); Yap_InitCPred("$current_choicepoint", 1, current_choice_point, 0); @@ -2344,13 +2310,12 @@ void Yap_InitExecFs(void) { Yap_InitCPred("$clean_ifcp", 1, clean_ifcp, SafePredFlag); Yap_InitCPred("qpack_clean_up_to_disjunction", 0, cut_up_to_next_disjunction, SafePredFlag); - Yap_InitCPred("$jump_env_and_store_ball", 1, jump_env, 0); + Yap_InitCPred("throw", 1, jump_env, 0); Yap_InitCPred("$generate_pred_info", 4, generate_pred_info, 0); - Yap_InitCPred("$reset_exception", 1, reset_exception, 0); Yap_InitCPred("_user_expand_goal", 2, _user_expand_goal, 0); Yap_InitCPred("$do_term_expansion", 2, do_term_expansion, 0); - Yap_InitCPred("$get_exception", 1, get_exception, 0); - Yap_InitCPred("setup_call_catcher_cleanup", 4, setup_call_catcher_cleanup, 0); - Yap_InitCPredBackCut("$protect_stack", 4, 0, protect_stack, - protect_stack_from_retry, protect_stack_from_cut, 0); + Yap_InitCPred("$setup_call_catcher_cleanup", 1, setup_call_catcher_cleanup, + 0); + Yap_InitCPred("$cleanup_on_exit", 2, cleanup_on_exit, NoTracePredFlag); + Yap_InitCPred("$tag_cleanup", 2, tag_cleanup, 0); } diff --git a/C/exo.c b/C/exo.c index eb4354ee7..f15ba4329 100755 --- a/C/exo.c +++ b/C/exo.c @@ -87,10 +87,10 @@ inline BITS32 fmix32 ( BITS32 h ) return h; } //----------------------------------------------------------------------------- -INLINE_ONLY inline BITS32 +INLINE_ONLY BITS32 HASH_MURMUR3_32 (UInt arity, CELL *cl, UInt bnds[], UInt sz); -INLINE_ONLY inline BITS32 +INLINE_ONLY BITS32 HASH_MURMUR3_32 (UInt arity, CELL *cl, UInt bnds[], UInt sz) { UInt hash; @@ -139,10 +139,10 @@ HASH_MURMUR3_32 (UInt arity, CELL *cl, UInt bnds[], UInt sz) /*DJB2*/ #define DJB2_OFFSET 5381 -INLINE_ONLY inline BITS32 +INLINE_ONLY BITS32 HASH_DJB2(UInt arity, CELL *cl, UInt bnds[], UInt sz); -INLINE_ONLY inline BITS32 +INLINE_ONLY BITS32 HASH_DJB2(UInt arity, CELL *cl, UInt bnds[], UInt sz) { BITS32 hash; @@ -165,11 +165,11 @@ HASH_DJB2(UInt arity, CELL *cl, UInt bnds[], UInt sz) return hash; } -INLINE_ONLY inline BITS32 +INLINE_ONLY BITS32 HASH_RS(UInt arity, CELL *cl, UInt bnds[], UInt sz); /* RS Hash Function */ -INLINE_ONLY inline BITS32 +INLINE_ONLY BITS32 HASH_RS(UInt arity, CELL *cl, UInt bnds[], UInt sz) { UInt hash=0; @@ -194,7 +194,7 @@ HASH_RS(UInt arity, CELL *cl, UInt bnds[], UInt sz) return hash; } -INLINE_ONLY inline BITS32 +INLINE_ONLY BITS32 HASH_FVN_1A(UInt arity, CELL *cl, UInt bnds[], UInt sz); /* Simple hash function: @@ -203,7 +203,7 @@ HASH_FVN_1A(UInt arity, CELL *cl, UInt bnds[], UInt sz); hash0 spreads extensions coming from different elements. spread over j quadrants. */ -INLINE_ONLY inline BITS32 +INLINE_ONLY BITS32 HASH_FVN_1A(UInt arity, CELL *cl, UInt bnds[], UInt sz) { UInt hash; diff --git a/C/exo_udi.c b/C/exo_udi.c index 90a9cf382..0148cda40 100755 --- a/C/exo_udi.c +++ b/C/exo_udi.c @@ -253,7 +253,7 @@ IntervalUDIRefitIndex(struct index_t **ip, UInt b[] USES_REGS) qsort(s0+1, (size_t)*s0, sizeof(BITS32), compar); it->links[offset0] = s0-sorted0; if (it->udi_free_args) { - memcpy(sorted, s0+1, sizeof(BITS32)*(*s0)); + memmove(sorted, s0+1, sizeof(BITS32)*(*s0)); qsort(sorted, (size_t)*s0, sizeof(BITS32), compar2); sorted += *s0; } diff --git a/C/fail_absmi_insts.h b/C/fail_absmi_insts.h index 16c694546..5d31b381e 100644 --- a/C/fail_absmi_insts.h +++ b/C/fail_absmi_insts.h @@ -4,411 +4,415 @@ #ifdef INDENT_CODE { - { - { #endif /* INDENT_CODE */ - /* trust_fail */ - BOp(trust_fail, e); - { - while (POP_CHOICE_POINT(B->cp_b)) - { - POP_EXECUTE(); - } - } + /* trust_fail */ + BOp(trust_fail, e); + { + while (POP_CHOICE_POINT(B->cp_b)) { + POP_EXECUTE(); + } + } #ifdef YAPOR - { - choiceptr cut_pt; - cut_pt = B->cp_b; - CUT_prune_to(cut_pt); - B = cut_pt; - } + { + choiceptr cut_pt; + cut_pt = B->cp_b; + CUT_prune_to(cut_pt); + B = cut_pt; + } #else - B = B->cp_b; -#endif /* YAPOR */ - goto fail; - ENDBOp(); + B = B->cp_b; +#endif /* YAPOR */ + goto fail; + ENDBOp(); #ifdef YAPOR - shared_fail: - B = Get_LOCAL_top_cp(); - SET_BB(PROTECT_FROZEN_B(B)); - goto fail; -#endif /* YAPOR */ +shared_fail: + B = Get_LOCAL_top_cp(); + SET_BB(PROTECT_FROZEN_B(B)); + goto fail; +#endif /* YAPOR */ - /* fail */ - PBOp(op_fail, e); + /* fail */ + PBOp(op_fail, e); - if (PP) { - UNLOCK(PP->PELock); - PP = NULL; - } + if (PP) { + UNLOCK(PP->PELock); + PP = NULL; + } #ifdef COROUTINING - CACHE_Y_AS_ENV(YREG); - check_stack(NoStackFail, HR); - ENDCACHE_Y_AS_ENV(); + CACHE_Y_AS_ENV(YREG); + check_stack(NoStackFail, HR); + ENDCACHE_Y_AS_ENV(); #endif - fail: - { - register tr_fr_ptr pt0 = TR; +fail : { + register tr_fr_ptr pt0 = TR; #if defined(YAPOR) || defined(THREADS) - if (PP) { - UNLOCK(PP->PELock); - PP = NULL; - } + if (PP) { + UNLOCK(PP->PELock); + PP = NULL; + } #endif - PREG = B->cp_ap; - save_pc(); - CACHE_TR(B->cp_tr); - PREFETCH_OP(PREG); - failloop: - if (pt0 == S_TR) { - SP = SP0; + PREG = B->cp_ap; + save_pc(); + CACHE_TR(B->cp_tr); + PREFETCH_OP(PREG); +failloop: + if (pt0 == S_TR) { + SP = SP0; #ifdef LOW_LEVEL_TRACER - if (Yap_do_low_level_trace) { - int go_on = true; - yamop *ipc = PREG; + if (Yap_do_low_level_trace) { + int go_on = true; + yamop *ipc = PREG; - while (go_on) { - op_numbers opnum = Yap_op_from_opcode(ipc->opc); + while (go_on) { + op_numbers opnum = Yap_op_from_opcode(ipc->opc); - go_on = false; - switch (opnum) { + go_on = false; + switch (opnum) { #ifdef TABLING - case _table_load_answer: - low_level_trace(retry_table_loader, LOAD_CP(B)->cp_pred_entry, NULL); - break; - case _table_try_answer: - case _table_retry_me: - case _table_trust_me: - case _table_retry: - case _table_trust: - case _table_completion: + case _table_load_answer: + low_level_trace(retry_table_loader, LOAD_CP(B)->cp_pred_entry, NULL); + break; + case _table_try_answer: + case _table_retry_me: + case _table_trust_me: + case _table_retry: + case _table_trust: + case _table_completion: #ifdef THREADS_CONSUMER_SHARING - case _table_answer_resolution_completion: + case _table_answer_resolution_completion: #endif /* THREADS_CONSUMER_SHARING */ #ifdef DETERMINISTIC_TABLING - if (IS_DET_GEN_CP(B)) - low_level_trace(retry_table_generator, DET_GEN_CP(B)->cp_pred_entry, NULL); - else + if (IS_DET_GEN_CP(B)) + low_level_trace(retry_table_generator, DET_GEN_CP(B)->cp_pred_entry, + NULL); + else #endif /* DETERMINISTIC_TABLING */ - low_level_trace(retry_table_generator, GEN_CP(B)->cp_pred_entry, (CELL *)(GEN_CP(B) + 1)); - break; - case _table_answer_resolution: - low_level_trace(retry_table_consumer, CONS_CP(B)->cp_pred_entry, NULL); - break; - case _trie_trust_var: - case _trie_retry_var: - case _trie_trust_var_in_pair: - case _trie_retry_var_in_pair: - case _trie_trust_val: - case _trie_retry_val: - case _trie_trust_val_in_pair: - case _trie_retry_val_in_pair: - case _trie_trust_atom: - case _trie_retry_atom: - case _trie_trust_atom_in_pair: - case _trie_retry_atom_in_pair: - case _trie_trust_null: - case _trie_retry_null: - case _trie_trust_null_in_pair: - case _trie_retry_null_in_pair: - case _trie_trust_pair: - case _trie_retry_pair: - case _trie_trust_appl: - case _trie_retry_appl: - case _trie_trust_appl_in_pair: - case _trie_retry_appl_in_pair: - case _trie_trust_extension: - case _trie_retry_extension: - case _trie_trust_double: - case _trie_retry_double: - case _trie_trust_longint: - case _trie_retry_longint: - case _trie_trust_gterm: - case _trie_retry_gterm: - low_level_trace(retry_table_loader, UndefCode, NULL); - break; + low_level_trace(retry_table_generator, GEN_CP(B)->cp_pred_entry, + (CELL *)(GEN_CP(B) + 1)); + break; + case _table_answer_resolution: + low_level_trace(retry_table_consumer, CONS_CP(B)->cp_pred_entry, + NULL); + break; + case _trie_trust_var: + case _trie_retry_var: + case _trie_trust_var_in_pair: + case _trie_retry_var_in_pair: + case _trie_trust_val: + case _trie_retry_val: + case _trie_trust_val_in_pair: + case _trie_retry_val_in_pair: + case _trie_trust_atom: + case _trie_retry_atom: + case _trie_trust_atom_in_pair: + case _trie_retry_atom_in_pair: + case _trie_trust_null: + case _trie_retry_null: + case _trie_trust_null_in_pair: + case _trie_retry_null_in_pair: + case _trie_trust_pair: + case _trie_retry_pair: + case _trie_trust_appl: + case _trie_retry_appl: + case _trie_trust_appl_in_pair: + case _trie_retry_appl_in_pair: + case _trie_trust_extension: + case _trie_retry_extension: + case _trie_trust_double: + case _trie_retry_double: + case _trie_trust_longint: + case _trie_retry_longint: + case _trie_trust_gterm: + case _trie_retry_gterm: + low_level_trace(retry_table_loader, UndefCode, NULL); + break; #endif /* TABLING */ - case _or_else: - case _or_last: - low_level_trace(retry_or, NULL, NULL); - break; - case _retry2: - case _retry3: - case _retry4: - ipc = NEXTOP(ipc,l); - go_on = true; - break; - case _jump: - ipc = ipc->y_u.l.l; - go_on = true; - break; - case _retry_c: - case _retry_userc: - low_level_trace(retry_pred, ipc->y_u.OtapFs.p, B->cp_args); - break; - case _retry_profiled: - case _count_retry: - ipc = NEXTOP(ipc,p); - go_on = true; - break; - case _retry_me: - case _trust_me: - case _count_retry_me: - case _count_trust_me: - case _profiled_retry_me: - case _profiled_trust_me: - case _retry_and_mark: - case _profiled_retry_and_mark: - case _retry: - case _trust: - low_level_trace(retry_pred, ipc->y_u.Otapl.p, B->cp_args); - break; - case _try_logical: - case _retry_logical: - case _profiled_retry_logical: - case _count_retry_logical: - case _trust_logical: - case _profiled_trust_logical: - case _count_trust_logical: - low_level_trace(retry_pred, ipc->y_u.OtILl.d->ClPred, B->cp_args); - break; - case _Nstop: - case _Ystop: - low_level_trace(retry_pred, NULL, B->cp_args); - break; - default: - break; - } - } - } -#endif /* LOW_LEVEL_TRACER */ -#ifdef FROZEN_STACKS -#ifdef YAPOR_SBA - if (pt0 < TR_FZ || pt0 > (ADDR)CurrentTrailTop+MinTrailGap) -#else - if (pt0 < TR_FZ) -#endif /* YAPOR_SBA */ - { - TR = TR_FZ; - TRAIL_LINK(pt0); - } else -#endif /* FROZEN_STACKS */ - RESTORE_TR(); - GONext(); - } - BEGD(d1); - d1 = TrailTerm(pt0-1); - pt0--; - if (IsVarTerm(d1)) { -#if defined(YAPOR_SBA) && defined(YAPOR) - /* clean up the trail when we backtrack */ - if (Unsigned((Int)(d1)-(Int)(H_FZ)) > - Unsigned((Int)(B_FZ)-(Int)(H_FZ))) { - RESET_VARIABLE(STACK_TO_SBA(d1)); - } else -#endif - /* normal variable */ - RESET_VARIABLE(d1); - goto failloop; - } - /* pointer to code space */ - /* or updatable variable */ -#if defined(TERM_EXTENSIONS) || defined(FROZEN_STACKS) || defined(MULTI_ASSIGNMENT_VARIABLES) - if (IsPairTerm(d1)) -#endif /* TERM_EXTENSIONS || FROZEN_STACKS || MULTI_ASSIGNMENT_VARIABLES */ - { - register CELL flags; - CELL *pt1 = RepPair(d1); -#ifdef LIMIT_TABLING - if ((ADDR) pt1 == LOCAL_TrailBase) { - sg_fr_ptr sg_fr = (sg_fr_ptr) TrailVal(pt0); - TrailTerm(pt0) = AbsPair((CELL *)(pt0 - 1)); - SgFr_state(sg_fr)--; /* complete_in_use --> complete : compiled_in_use --> compiled */ - insert_into_global_sg_fr_list(sg_fr); - goto failloop; - } -#endif /* LIMIT_TABLING */ -#ifdef FROZEN_STACKS /* TRAIL */ - /* avoid frozen segments */ - if ( -#ifdef YAPOR_SBA - (ADDR) pt1 >= HeapTop -#else - IN_BETWEEN(LOCAL_TrailBase, pt1, (ADDR)CurrentTrailTop+MinTrailGap) -#endif /* YAPOR_SBA */ - ) - { - pt0 = (tr_fr_ptr) pt1; - goto failloop; - } else -#endif /* FROZEN_STACKS */ - if (IN_BETWEEN(H0,pt1,HR)) { - if (IsAttVar(pt1)) { - goto failloop; - } else if (*pt1 == (CELL)FunctorBigInt) { - Yap_CleanOpaqueVariable(pt1); - goto failloop; - } - } -#ifdef FROZEN_STACKS /* TRAIL */ - /* don't reset frozen variables */ - if (pt0 < TR_FZ) - goto failloop; -#endif - flags = *pt1; -#if MULTIPLE_STACKS - if (FlagOn(DBClMask, flags)) { - DBRef dbr = DBStructFlagsToDBStruct(pt1); - int erase; - - LOCK(dbr->lock); - DEC_DBREF_COUNT(dbr); - erase = (dbr->Flags & ErasedMask) && (dbr->ref_count == 0); - UNLOCK(dbr->lock); - if (erase) { - saveregs(); - Yap_ErDBE(dbr); - setregs(); - } - } else { - if (flags & LogUpdMask) { - if (flags & IndexMask) { - LogUpdIndex *cl = ClauseFlagsToLogUpdIndex(pt1); - int erase; -#if PARALLEL_YAP - PredEntry *ap = cl->ClPred; -#endif - - PELOCK(8,ap); - DEC_CLREF_COUNT(cl); - erase = (cl->ClFlags & ErasedMask) && !(cl->ClRefCount); - if (erase) { - saveregs(); - /* at this point, - we are the only ones accessing the clause, - hence we don't need to have a lock it */ - Yap_ErLogUpdIndex(cl); - setregs(); - } else if (cl->ClFlags & DirtyMask) { - saveregs(); - /* at this point, - we are the only ones accessing the clause, - hence we don't need to have a lock it */ - Yap_CleanUpIndex(cl); - setregs(); - } - UNLOCK(ap->PELock); - } else { - LogUpdClause *cl = ClauseFlagsToLogUpdClause(pt1); - int erase; -#if PARALLEL_YAP - PredEntry *ap = cl->ClPred; -#endif - /* BB support */ - if (ap) { - - PELOCK(9,ap); - DEC_CLREF_COUNT(cl); - erase = (cl->ClFlags & ErasedMask) && !(cl->ClRefCount); - if (erase) { - saveregs(); - /* at this point, - we are the only ones accessing the clause, - hence we don't need to have a lock it */ - Yap_ErLogUpdCl(cl); - setregs(); - } - UNLOCK(ap->PELock); - } - } - } else { - DynamicClause *cl = ClauseFlagsToDynamicClause(pt1); - int erase; - - LOCK(cl->ClLock); - DEC_CLREF_COUNT(cl); - erase = (cl->ClFlags & ErasedMask) && !(cl->ClRefCount); - UNLOCK(cl->ClLock); - if (erase) { - saveregs(); - /* at this point, - we are the only ones accessing the clause, - hence we don't need to have a lock it */ - Yap_ErCl(cl); - setregs(); - } - } - } -#else - ResetFlag(InUseMask, flags); - *pt1 = flags; - if (FlagOn((ErasedMask|DirtyMask), flags)) { - if (FlagOn(DBClMask, flags)) { - saveregs(); - Yap_ErDBE(DBStructFlagsToDBStruct(pt1)); - setregs(); - } else { - saveregs(); - if (flags & LogUpdMask) { - if (flags & IndexMask) { - if (FlagOn(ErasedMask, flags)) { - Yap_ErLogUpdIndex(ClauseFlagsToLogUpdIndex(pt1)); - } else { - Yap_CleanUpIndex(ClauseFlagsToLogUpdIndex(pt1)); - } - } else { - Yap_ErLogUpdCl(ClauseFlagsToLogUpdClause(pt1)); - } - } else { - Yap_ErCl(ClauseFlagsToDynamicClause(pt1)); - } - setregs(); - } - } -#endif - goto failloop; - } -#ifdef MULTI_ASSIGNMENT_VARIABLES - else /* if (IsApplTerm(d1)) */ { - CELL *pt = RepAppl(d1); - /* AbsAppl means */ - /* multi-assignment variable */ - /* so the next cell is the old value */ -#ifdef FROZEN_STACKS - --pt0; - pt[0] = TrailVal(pt0); -#else - pt[0] = TrailTerm(pt0-1); - pt0 -= 2; -#endif /* FROZEN_STACKS */ - goto failloop; - } -#endif - ENDD(d1); - ENDCACHE_TR(); + case _or_else: + case _or_last: + low_level_trace(retry_or, NULL, NULL); + break; + case _retry2: + case _retry3: + case _retry4: + ipc = NEXTOP(ipc, l); + go_on = true; + break; + case _jump: + ipc = ipc->y_u.l.l; + go_on = true; + break; + case _retry_c: + case _retry_userc: + low_level_trace(retry_pred, ipc->y_u.OtapFs.p, B->cp_args); + break; + case _retry_profiled: + case _count_retry: + ipc = NEXTOP(ipc, p); + go_on = true; + break; + case _retry_me: + case _trust_me: + case _count_retry_me: + case _count_trust_me: + case _profiled_retry_me: + case _profiled_trust_me: + case _retry_and_mark: + case _profiled_retry_and_mark: + case _retry: + case _trust: + low_level_trace(retry_pred, ipc->y_u.Otapl.p, B->cp_args); + break; + case _try_logical: + case _retry_logical: + case _profiled_retry_logical: + case _count_retry_logical: + case _trust_logical: + case _profiled_trust_logical: + case _count_trust_logical: + low_level_trace(retry_pred, ipc->y_u.OtILl.d->ClPred, B->cp_args); + break; + case _Nstop: + case _Ystop: + low_level_trace(retry_pred, NULL, B->cp_args); + break; + default: + break; + } } + } +#endif /* LOW_LEVEL_TRACER */ +#ifdef FROZEN_STACKS +#ifdef YAPOR_SBA + if (pt0 < TR_FZ || pt0 > (ADDR)CurrentTrailTop + MinTrailGap) +#else + if (pt0 < TR_FZ) +#endif /* YAPOR_SBA */ + { + TR = TR_FZ; + TRAIL_LINK(pt0); + } else +#endif /* FROZEN_STACKS */ + RESTORE_TR(); + GONext(); + } + BEGD(d1); + d1 = TrailTerm(pt0 - 1); + pt0--; + if (IsVarTerm(d1)) { +#if defined(YAPOR_SBA) && defined(YAPOR) + /* clean up the trail when we backtrack */ + if (Unsigned((Int)(d1) - (Int)(H_FZ)) > + Unsigned((Int)(B_FZ) - (Int)(H_FZ))) { + RESET_VARIABLE(STACK_TO_SBA(d1)); + } else +#endif + /* normal variable */ + RESET_VARIABLE(d1); + goto failloop; + } +/* pointer to code space */ +/* or updatable variable */ +#if defined(TERM_EXTENSIONS) || defined(FROZEN_STACKS) || \ + defined(MULTI_ASSIGNMENT_VARIABLES) + if (IsPairTerm(d1)) +#endif /* TERM_EXTENSIONS || FROZEN_STACKS || MULTI_ASSIGNMENT_VARIABLES */ + { + register CELL flags; + CELL *pt1 = RepPair(d1); +#ifdef LIMIT_TABLING + if ((ADDR)pt1 == LOCAL_TrailBase) { + sg_fr_ptr sg_fr = (sg_fr_ptr)TrailVal(pt0); + TrailTerm(pt0) = AbsPair((CELL *)(pt0 - 1)); + SgFr_state(sg_fr)--; /* complete_in_use --> complete : compiled_in_use --> + compiled */ + insert_into_global_sg_fr_list(sg_fr); + goto failloop; + } +#endif /* LIMIT_TABLING */ +#ifdef FROZEN_STACKS /* TRAIL */ + /* avoid frozen segments */ + if ( +#ifdef YAPOR_SBA + (ADDR)pt1 >= HeapTop +#else + IN_BETWEEN(LOCAL_TrailBase, pt1, (ADDR)CurrentTrailTop + MinTrailGap) +#endif /* YAPOR_SBA */ + ) { + pt0 = (tr_fr_ptr)pt1; + goto failloop; + } else +#endif /* FROZEN_STACKS */ + if (IN_BETWEEN(H0, pt1, HR)) { + if (IsAttVar(pt1)) { + goto failloop; + } else { + TR = pt0; + Yap_CleanOpaqueVariable(d1); + + goto failloop; + } + } +#ifdef FROZEN_STACKS /* TRAIL */ + /* don't reset frozen variables */ + if (pt0 < TR_FZ) + goto failloop; +#endif + flags = *pt1; +#if MULTIPLE_STACKS + if (FlagOn(DBClMask, flags)) { + DBRef dbr = DBStructFlagsToDBStruct(pt1); + int erase; + + LOCK(dbr->lock); + DEC_DBREF_COUNT(dbr); + erase = (dbr->Flags & ErasedMask) && (dbr->ref_count == 0); + UNLOCK(dbr->lock); + if (erase) { + saveregs(); + Yap_ErDBE(dbr); + setregs(); + } + } else { + if (flags & LogUpdMask) { + if (flags & IndexMask) { + LogUpdIndex *cl = ClauseFlagsToLogUpdIndex(pt1); + int erase; +#if PARALLEL_YAP + PredEntry *ap = cl->ClPred; +#endif + + PELOCK(8, ap); + DEC_CLREF_COUNT(cl); + erase = (cl->ClFlags & ErasedMask) && !(cl->ClRefCount); + if (erase) { + saveregs(); + /* at this point, +we are the only ones accessing the clause, +hence we don't need to have a lock it */ + Yap_ErLogUpdIndex(cl); + setregs(); + } else if (cl->ClFlags & DirtyMask) { + saveregs(); + /* at this point, +we are the only ones accessing the clause, +hence we don't need to have a lock it */ + Yap_CleanUpIndex(cl); + setregs(); + } + UNLOCK(ap->PELock); + } else { + LogUpdClause *cl = ClauseFlagsToLogUpdClause(pt1); + int erase; +#if PARALLEL_YAP + PredEntry *ap = cl->ClPred; +#endif + /* BB support */ + if (ap) { + + PELOCK(9, ap); + DEC_CLREF_COUNT(cl); + erase = (cl->ClFlags & ErasedMask) && !(cl->ClRefCount); + if (erase) { + saveregs(); + /* at this point, +we are the only ones accessing the clause, +hence we don't need to have a lock it */ + Yap_ErLogUpdCl(cl); + setregs(); + } + UNLOCK(ap->PELock); + } + } + } else { + DynamicClause *cl = ClauseFlagsToDynamicClause(pt1); + int erase; + + LOCK(cl->ClLock); + DEC_CLREF_COUNT(cl); + erase = (cl->ClFlags & ErasedMask) && !(cl->ClRefCount); + UNLOCK(cl->ClLock); + if (erase) { + saveregs(); + /* at this point, +we are the only ones accessing the clause, +hence we don't need to have a lock it */ + Yap_ErCl(cl); + setregs(); + } + } + } +#else + ResetFlag(InUseMask, flags); + *pt1 = flags; + if (FlagOn((ErasedMask | DirtyMask), flags)) { + if (FlagOn(DBClMask, flags)) { + saveregs(); + Yap_ErDBE(DBStructFlagsToDBStruct(pt1)); + setregs(); + } else { + saveregs(); + if (flags & LogUpdMask) { + if (flags & IndexMask) { + if (FlagOn(ErasedMask, flags)) { + Yap_ErLogUpdIndex(ClauseFlagsToLogUpdIndex(pt1)); + } else { + Yap_CleanUpIndex(ClauseFlagsToLogUpdIndex(pt1)); + } + } else { + Yap_ErLogUpdCl(ClauseFlagsToLogUpdClause(pt1)); + } + } else { + Yap_ErCl(ClauseFlagsToDynamicClause(pt1)); + } + setregs(); + } + } +#endif + goto failloop; + } +#ifdef MULTI_ASSIGNMENT_VARIABLES + else /* if (IsApplTerm(d1)) */ + { + CELL *pt = RepAppl(d1); +/* AbsAppl means */ +/* multi-assignment variable */ +/* so the next cell is the old value */ +#ifdef FROZEN_STACKS + --pt0; + pt[0] = TrailVal(pt0); +#else + pt[0] = TrailTerm(pt0 - 1); + pt0 -= 2; +#endif /* FROZEN_STACKS */ + goto failloop; + } +#endif + ENDD(d1); + ENDCACHE_TR(); +} #ifdef COROUTINING - NoStackFail: - BEGD(d0); +NoStackFail: + BEGD(d0); #ifdef SHADOW_S - Yap_REGS.S_ = SREG; + Yap_REGS.S_ = SREG; #endif - saveregs(); - d0 = interrupt_fail( PASS_REGS1 ); - setregs(); + saveregs(); + d0 = interrupt_fail(PASS_REGS1); + setregs(); #ifdef SHADOW_S - SREG = Yap_REGS.S_; + SREG = Yap_REGS.S_; #endif - if (!d0) FAIL(); - JMPNext(); - ENDD(d0); + if (!d0) + FAIL(); + JMPNext(); + ENDD(d0); #endif /* COROUTINING */ - ENDPBOp(); - - - + ENDPBOp(); +#ifdef INDENT_CODE +} +#endif /* INDENT_CODE */ diff --git a/C/flags.c b/C/flags.c index f670bb1cf..158671cf1 100644 --- a/C/flags.c +++ b/C/flags.c @@ -1,25 +1,43 @@ /************************************************************************* -* * -* YAP Prolog * -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 2015- * -* * -************************************************************************** -* * -* File: flags.c * -* Last rev: * -* mods: * -* comments: abstract machine definitions * -* * -*************************************************************************/ + * * + * YAP Prolog * + * * + * Yap Prolog was developed at NCCUP - Universidade do Porto * + * * + * Copyright L.Damas, V.S.Costa and Universidade do Porto 2015- * + * * + ************************************************************************** + * * + * File: flags.c * + * Last rev: * + * mods: * + * comments: abstract machine definitions * + * * + *************************************************************************/ /** @file C/flags.c - @addtogroup Flags -@ingroup core + @brief Prolog parameter setting, +*/ + +/* + * @namespace prolog + */ + +/** @{ + @defgroup YAPFlags_Impl C-code to handle Prolog flags. + @ingroup YAPFlags + +@brief Low-level code to support flags. + +Prolog Flags can be: += thread-local or global += module-based or module-independent. += read-only or read-write += System or User Defined. += Have type boolean, number, atom constant or may be a general term. + */ // this is where we define flags @@ -51,7 +69,9 @@ static Term indexer(Term inp); static Term stream(Term inp); static bool getenc(Term inp); static bool typein(Term inp); -static bool dqf(Term t2); +static bool dqs(Term t2); +static bool bqs(Term t2); +static bool sqf(Term t2); static bool set_error_stream(Term inp); static bool set_input_stream(Term inp); static bool set_output_stream(Term inp); @@ -60,27 +80,38 @@ static void newFlag(Term fl, Term val); static Int current_prolog_flag(USES_REGS1); static Int set_prolog_flag(USES_REGS1); -#include "Yatom.h" #include "YapEval.h" +#include "Yatom.h" #include "yapio.h" #define YAP_FLAG(ID, NAME, WRITABLE, DEF, INIT, HELPER) \ { NAME, WRITABLE, DEF, INIT, HELPER } +#define START_LOCAL_FLAGS static flag_info local_flags_setup[] = { +#define END_LOCAL_FLAGS \ + LZERO_FLAG \ + } \ + ; + +#define START_GLOBAL_FLAGS static flag_info global_flags_setup[] = { +#define END_GLOBAL_FLAGS \ + GZERO_FLAG \ + } \ + ; + #define GZERO_FLAG \ { NULL, false, NULL, NULL, NULL } #define LZERO_FLAG \ { NULL, false, NULL, NULL, NULL } -static flag_info global_flags_setup[] = { #include "YapGFlagInfo.h" - GZERO_FLAG}; -static flag_info local_flags_setup[] = { #include "YapLFlagInfo.h" - LZERO_FLAG}; static Term indexer(Term inp) { + if (IsStringTerm(inp)) { + inp = MkStringTerm(RepAtom(AtomOfTerm(inp))->StrOfAE); + } if (inp == TermOff || inp == TermSingle || inp == TermCompact || inp == TermMulti || inp == TermOn || inp == TermMax) return inp; @@ -90,13 +121,15 @@ static Term indexer(Term inp) { "set_prolog_flag index in {off,single,compact,multi,on,max}"); return TermZERO; } - Yap_Error(TYPE_ERROR_ATOM, inp, - "set_prolog_flag in {dec10,error,fail,quiet}"); + Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag index to an atom"); return TermZERO; } static bool dqf1(ModEntry *new, Term t2 USES_REGS) { new->flags &= ~(DBLQ_CHARS | DBLQ_CODES | DBLQ_ATOM | DBLQ_STRING); + if (IsStringTerm(t2)) { + t2 = MkStringTerm(RepAtom(AtomOfTerm(t2))->StrOfAE); + } if (IsAtomTerm(t2)) { if (t2 == TermString) { new->flags |= DBLQ_STRING; @@ -112,20 +145,22 @@ static bool dqf1(ModEntry *new, Term t2 USES_REGS) { return true; } /* bad argument, but still an atom */ - Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, t2, "bad option %s for backquoted " - "string flag, use one string, " - "atom, codes or chars", + Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, t2, + "bad option %s for backquoted " + "string flag, use one string, " + "atom, codes or chars", RepAtom(AtomOfTerm(t2))->StrOfAE); return false; } else { - Yap_Error(TYPE_ERROR_ATOM, t2, "set_prolog_flag(double_quotes, %s), should " - "be {string,atom,codes,chars}", + Yap_Error(TYPE_ERROR_ATOM, t2, + "set_prolog_flag(double_quotes, %s), should " + "be {string,atom,codes,chars}", RepAtom(AtomOfTerm(t2))->StrOfAE); return false; } } -static bool dqf(Term t2) { +static bool dqs(Term t2) { CACHE_REGS ModEntry *new = Yap_GetModuleEntry(CurrentModule); return dqf1(new, t2 PASS_REGS); @@ -133,6 +168,9 @@ static bool dqf(Term t2) { static bool bqf1(ModEntry *new, Term t2 USES_REGS) { new->flags &= ~(BCKQ_CHARS | BCKQ_CODES | BCKQ_ATOM | BCKQ_STRING); + if (IsStringTerm(t2)) { + t2 = MkStringTerm(RepAtom(AtomOfTerm(t2))->StrOfAE); + } if (IsAtomTerm(t2)) { if (t2 == TermString) { new->flags |= BCKQ_STRING; @@ -147,9 +185,10 @@ static bool bqf1(ModEntry *new, Term t2 USES_REGS) { new->flags |= BCKQ_CHARS; return true; } - Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, t2, "bad option %s for backquoted " - "string flag, use one string, " - "atom, codes or chars", + Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, t2, + "bad option %s for backquoted " + "string flag, use one string, " + "atom, codes or chars", RepAtom(AtomOfTerm(t2))->StrOfAE); return false; } else { @@ -159,10 +198,57 @@ static bool bqf1(ModEntry *new, Term t2 USES_REGS) { } } +static bool bqs(Term t2) { + CACHE_REGS + ModEntry *new = Yap_GetModuleEntry(CurrentModule); + return bqf1(new, t2 PASS_REGS); +} + +static bool sqf1(ModEntry *new, Term t2 USES_REGS) { + new->flags &= ~(SNGQ_CHARS | SNGQ_CODES | SNGQ_ATOM | SNGQ_STRING); + if (IsStringTerm(t2)) { + t2 = MkStringTerm(RepAtom(AtomOfTerm(t2))->StrOfAE); + } + if (IsAtomTerm(t2)) { + if (t2 == TermString) { + new->flags |= SNGQ_STRING; + return true; + } else if (t2 == TermAtom) { + new->flags |= SNGQ_ATOM; + return true; + } else if (t2 == TermCodes) { + new->flags |= SNGQ_CODES; + return true; + } else if (t2 == TermChars) { + new->flags |= SNGQ_CHARS; + return true; + } + Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, t2, + "bad option %s for backquoted " + "string flag, use one string, " + "atom, codes or chars", + RepAtom(AtomOfTerm(t2))->StrOfAE); + return false; + } else { + Yap_Error(TYPE_ERROR_ATOM, t2, "flag %s is not module-scoped", + RepAtom(AtomOfTerm(t2))->StrOfAE); + return false; + } +} + +static bool sqf(Term t2) { + CACHE_REGS + ModEntry *new = Yap_GetModuleEntry(CurrentModule); + return sqf1(new, t2 PASS_REGS); +} + static Term isaccess(Term inp) { if (inp == TermReadWrite || inp == TermReadOnly) return inp; + if (IsStringTerm(inp)) { + inp = MkStringTerm(RepAtom(AtomOfTerm(inp))->StrOfAE); + } if (IsAtomTerm(inp)) { Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, inp, "set_prolog_flag access in {read_write,read_only}"); @@ -176,8 +262,9 @@ static Term isaccess(Term inp) { static Term stream(Term inp) { if (IsVarTerm(inp)) return inp; - if (Yap_CheckStream(inp, Input_Stream_f | Output_Stream_f | Append_Stream_f | - Socket_Stream_f, + if (Yap_CheckStream(inp, + Input_Stream_f | Output_Stream_f | Append_Stream_f | + Socket_Stream_f, "yap_flag/3") >= 0) return inp; return 0; @@ -186,25 +273,19 @@ static Term stream(Term inp) { static bool set_error_stream(Term inp) { if (IsVarTerm(inp)) return Yap_unify(inp, Yap_StreamUserName(LOCAL_c_error_stream)); - LOCAL_c_error_stream = Yap_CheckStream( - inp, Output_Stream_f | Append_Stream_f | Socket_Stream_f, "yap_flag/3"); - return true; + return Yap_SetErrorStream(inp); } static bool set_input_stream(Term inp) { if (IsVarTerm(inp)) return Yap_unify(inp, Yap_StreamUserName(LOCAL_c_input_stream)); - LOCAL_c_input_stream = - Yap_CheckStream(inp, Input_Stream_f | Socket_Stream_f, "yap_flag/3"); - return true; + return Yap_SetInputStream(inp); } static bool set_output_stream(Term inp) { if (IsVarTerm(inp)) return Yap_unify(inp, Yap_StreamUserName(LOCAL_c_output_stream)); - LOCAL_c_output_stream = Yap_CheckStream( - inp, Output_Stream_f | Append_Stream_f | Socket_Stream_f, "yap_flag/3"); - return true; + return Yap_SetOutputStream(inp); } static Term isground(Term inp) { @@ -215,6 +296,9 @@ static Term flagscope(Term inp) { if (inp == TermGlobal || inp == TermThread || inp == TermModule) return inp; + if (IsStringTerm(inp)) { + inp = MkStringTerm(RepAtom(AtomOfTerm(inp))->StrOfAE); + } if (IsAtomTerm(inp)) { Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, inp, "set_prolog_flag access in {global,module,thread}"); @@ -229,8 +313,11 @@ static bool mkprompt(Term inp) { CACHE_REGS if (IsVarTerm(inp)) { return Yap_unify(inp, MkAtomTerm(Yap_LookupAtom(LOCAL_Prompt))); + } + if (IsStringTerm(inp)) { + inp = MkStringTerm(RepAtom(AtomOfTerm(inp))->StrOfAE); } - if (!IsAtomTerm(inp)) { + if (!IsAtomTerm(inp)) { Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag"); return false; } @@ -241,6 +328,9 @@ static bool mkprompt(Term inp) { static bool getenc(Term inp) { CACHE_REGS + if (IsStringTerm(inp)) { + inp = MkStringTerm(RepAtom(AtomOfTerm(inp))->StrOfAE); + } if (!IsVarTerm(inp) && !IsAtomTerm(inp)) { Yap_Error(TYPE_ERROR_ATOM, inp, "get_encoding"); return false; @@ -272,6 +362,9 @@ static bool typein(Term inp) { tin = TermProlog; return Yap_unify(inp, tin); } + if (IsStringTerm(inp)) { + inp = MkStringTerm(RepAtom(AtomOfTerm(inp))->StrOfAE); + } if (!IsAtomTerm(inp)) { Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag"); return false; @@ -382,6 +475,9 @@ static bool typein(Term inp) { if (IsAtomTerm(hd)) { do { Term hd = HeadOfTerm(inp); + if (IsStringTerm(hd)) { + hd = MkStringTerm(RepAtom(AtomOfTerm(hd))->StrOfAE); + } if (!IsAtomTerm(hd)) { Yap_Error(TYPE_ERROR_TEXT, inp0, "set_prolog_flag in \"...\""); return false; @@ -411,7 +507,7 @@ static bool typein(Term inp) { return true; } - static bool list_atom( Term inp ) { +x static bool list_atom( Term inp ) { if (IsVarTerm(inp)) { Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag in \"...\""); return false; @@ -420,6 +516,10 @@ static bool typein(Term inp) { if (IsPairTerm(inp)) { Term hd = HeadOfTerm(inp); do { + if (IsStringTerm(hd)) { + hd = MkStringTerm(RepAtom(AtomOfTerm(hd))->StrOfAE); + } + if (!IsAtomTerm(hd)) { Yap_Error(TYPE_ERROR_ATOM, inp0, "set_prolog_flag in \"...\""); return false; @@ -444,6 +544,9 @@ static Term list_option(Term inp) { do { Term hd = HeadOfTerm(inp); inp = TailOfTerm(inp); + if (IsStringTerm(hd)) { + hd = MkStringTerm(RepAtom(AtomOfTerm(hd))->StrOfAE); + } if (IsAtomTerm(hd)) { continue; } @@ -464,6 +567,9 @@ static Term list_option(Term inp) { Yap_Error(TYPE_ERROR_LIST, inp0, "set_prolog_flag in [...]"); return TermZERO; } else /* lone option */ { + if (IsStringTerm(inp)) { + inp = MkStringTerm(RepAtom(AtomOfTerm(inp))->StrOfAE); + } if (IsAtomTerm(inp)) { return inp; } else if (IsApplTerm(inp)) { @@ -667,17 +773,17 @@ static bool setYapFlagInModule(Term tflag, Term t2, Term mod) { flag_term *tarr = GLOBAL_Flags; if (!(fv->type(t2))) return false; - + if (fv->helper && !(fv->helper(t2))) return false; Term tout = tarr[fv->FlagOfVE].at; if (IsVarTerm(tout)) { Term t; while ((t = Yap_PopTermFromDB(tarr[fv->FlagOfVE].DBT)) == 0) { - if (!Yap_gc(2, ENV, gc_P(P, CP))) { - Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); - return false; - } + if (!Yap_gc(2, ENV, gc_P(P, CP))) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); + return false; + } } } else if (IsAtomOrIntTerm(t2)) tarr[fv->FlagOfVE].at = t2; @@ -721,9 +827,10 @@ static bool setYapFlagInModule(Term tflag, Term t2, Term mod) { "bad option %s for character_escapes flag, use true or false", RepAtom(AtomOfTerm(tflag))->StrOfAE); return false; - } else if (fv->FlagOfVE == BACKQUOTED_STRING_FLAG) { + } else if (fv->FlagOfVE == BACK_QUOTES_FLAG) { return bqf1(me, t2 PASS_REGS); - ; + } else if (fv->FlagOfVE == SINGLE_QUOTES_FLAG) { + return sqf1(me, t2 PASS_REGS); } // bad key? return false; @@ -750,7 +857,7 @@ static Term getYapFlagInModule(Term tflag, Term mod) { } else if (fv->FlagOfVE == CHARACTER_ESCAPES_FLAG) { if (me->flags & M_CHARESCAPE) return TermTrue; - } else if (fv->FlagOfVE == BACKQUOTED_STRING_FLAG) { + } else if (fv->FlagOfVE == BACK_QUOTES_FLAG) { if (me->flags & BCKQ_CHARS) return TermChars; if (me->flags & BCKQ_CODES) @@ -758,6 +865,14 @@ static Term getYapFlagInModule(Term tflag, Term mod) { if (me->flags & BCKQ_ATOM) return TermAtom; return TermString; + } else if (fv->FlagOfVE == SINGLE_QUOTES_FLAG) { + if (me->flags & SNGQ_CHARS) + return TermChars; + if (me->flags & SNGQ_CODES) + return TermCodes; + if (me->flags & SNGQ_ATOM) + return TermAtom; + return TermString; } else if (fv->FlagOfVE == DOUBLE_QUOTES_FLAG) { if (me->flags & DBLQ_CHARS) return TermChars; @@ -783,7 +898,8 @@ static Int cont_yap_flag(USES_REGS1) { Term modt = CurrentModule; tflag = Yap_StripModule(tflag, &modt); while (i != gmax && i != UNKNOWN_FLAG && i != CHARACTER_ESCAPES_FLAG && - i != BACKQUOTED_STRING_FLAG) + i != BACK_QUOTES_FLAG && i != SINGLE_QUOTES_FLAG && + i != DOUBLE_QUOTES_FLAG) i++; if (i == gmax) cut_fail(); @@ -959,6 +1075,9 @@ static Int current_prolog_flag2(USES_REGS1) { return cont_yap_flag(PASS_REGS1); } do_cut(0); + if (IsStringTerm(tflag)) { + tflag = MkStringTerm(RepAtom(AtomOfTerm(tflag))->StrOfAE); + } if (!IsAtomTerm(tflag)) { Yap_Error(TYPE_ERROR_ATOM, tflag, "current_prolog_flag/3"); return (FALSE); @@ -974,7 +1093,7 @@ static Int current_prolog_flag2(USES_REGS1) { tarr = LOCAL_Flags; tout = tarr[fv->FlagOfVE].at; if (tout == TermZERO) { - Yap_DebugPlWriteln(tflag); + // Yap_DebugPlWriteln(tflag); return false; } if (IsVarTerm(tout)) @@ -987,14 +1106,16 @@ void Yap_setModuleFlags(ModEntry *new, ModEntry *cme) { Atom at = new->AtomOfME; if (at == AtomProlog || CurrentModule == PROLOG_MODULE) { - new->flags = - M_SYSTEM | UNKNOWN_ERROR | M_CHARESCAPE | DBLQ_CODES | BCKQ_STRING; + new->flags = M_SYSTEM | UNKNOWN_ERROR | M_CHARESCAPE | DBLQ_CODES | + BCKQ_STRING | SNGQ_ATOM; if (at == AtomUser) - new->flags = UNKNOWN_ERROR | M_CHARESCAPE | DBLQ_CODES | BCKQ_STRING; + new->flags = + UNKNOWN_ERROR | M_CHARESCAPE | DBLQ_CODES | BCKQ_STRING | SNGQ_ATOM; } else if (cme && cme->flags && cme != new) { new->flags = cme->flags; } else { - new->flags = (UNKNOWN_ERROR | M_CHARESCAPE | DBLQ_CODES | BCKQ_STRING); + new->flags = + (UNKNOWN_ERROR | M_CHARESCAPE | DBLQ_CODES | BCKQ_STRING | SNGQ_ATOM); } // printf("cme=%s new=%s flags=%x\n",cme,at->StrOfAE,new->flags); } @@ -1006,6 +1127,10 @@ bool setYapFlag(Term tflag, Term t2) { Yap_Error(INSTANTIATION_ERROR, tflag, "yap_flag/2"); return (FALSE); } + if (IsStringTerm(tflag)) { + tflag = MkStringTerm(RepAtom(AtomOfTerm(tflag))->StrOfAE); + } + if (IsApplTerm(tflag) && FunctorOfTerm(tflag) == FunctorModule) { Term modt; tflag = Yap_StripModule(tflag, &modt); @@ -1040,7 +1165,9 @@ bool setYapFlag(Term tflag, Term t2) { switch (fv->FlagOfVE) { case UNKNOWN_FLAG: case CHARACTER_ESCAPES_FLAG: - case BACKQUOTED_STRING_FLAG: + case BACK_QUOTES_FLAG: + case DOUBLE_QUOTES_FLAG: + case SINGLE_QUOTES_FLAG: return setYapFlagInModule(tflag, t2, CurrentModule); default: tarr = GLOBAL_Flags; @@ -1080,16 +1207,26 @@ Term Yap_UnknownFlag(Term mod) { Term getYapFlag(Term tflag) { FlagEntry *fv; - flag_term *tarr; - if (IsVarTerm(tflag)) { + flag_term *tarr; + tflag = Deref(tflag); + if (IsVarTerm(tflag)) { Yap_Error(INSTANTIATION_ERROR, tflag, "yap_flag/2"); return (FALSE); } + if (IsStringTerm(tflag)) { + tflag = MkStringTerm(RepAtom(AtomOfTerm(tflag))->StrOfAE); + } if (IsApplTerm(tflag) && FunctorOfTerm(tflag) == FunctorModule) { Term modt; tflag = Yap_StripModule(tflag, &modt); + if (IsStringTerm(tflag)) { + tflag = MkStringTerm(RepAtom(AtomOfTerm(tflag))->StrOfAE); + } if (!isatom(tflag)) return false; + if (IsStringTerm(modt)) { + modt = MkStringTerm(RepAtom(AtomOfTerm(modt))->StrOfAE); + } if (!isatom(modt)) return false; return getYapFlagInModule(tflag, modt); @@ -1098,6 +1235,10 @@ Term getYapFlag(Term tflag) { Yap_Error(TYPE_ERROR_ATOM, tflag, "yap_flag/2"); return (FALSE); } + if (tflag == TermSilent) + { + Yap_DebugPlWriteln(TermSilent); + } fv = GetFlagProp(AtomOfTerm(tflag)); if (!fv) { Term fl = GLOBAL_Flags[USER_FLAGS_FLAG].at; @@ -1141,7 +1282,7 @@ static Int set_prolog_flag(USES_REGS1) { After executing this goal, YAP keeps information on the source of the predicates that will be consulted. This enables the use of -[listing/0](@ref listing), `listing/1` and [clause/2](@ref clause) for those +listing/0, listing/1 and clause/2 for those clauses. The same as `source_mode(_,on)` or as declaring all newly defined @@ -1256,10 +1397,6 @@ static bool setInitialValue(bool bootstrap, flag_func f, const char *s, tarr->at = MkIntTerm(atol(YAP_NUMERIC_VERSION)); return true; } - if (!strcmp(ss, "YAP_NUMERIC_VERSION")) { - tarr->at = MkIntTerm(atol(YAP_NUMERIC_VERSION)); - return true; - } Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, TermNil, "~s should be either true (on) or false (off)", s); return false; @@ -1324,11 +1461,14 @@ static bool setInitialValue(bool bootstrap, flag_func f, const char *s, return false; } CACHE_REGS - const unsigned char *us = (const unsigned char *)s; - t0 = Yap_BufferToTermWithPrioBindings(us, strlen(s) + 1, TermNil, - GLOBAL_MaxPriority, 0L); + const char *us = (const char *)s; + t0 = Yap_BufferToTermWithPrioBindings(us, TermNil, 0L, strlen(s) + 1, + GLOBAL_MaxPriority); if (!t0) return false; + if (IsStringTerm(t0)) { + t0 = MkStringTerm(RepAtom(AtomOfTerm(t0))->StrOfAE); + } if (IsAtomTerm(t0) || IsIntTerm(t0)) { // do yourself flags if (t0 == MkAtomTerm(AtomQuery)) { @@ -1373,12 +1513,16 @@ do_prolog_flag_property(Term tflag, xarg *args; prolog_flag_property_choices_t i; bool rc = true; - args = Yap_ArgList2ToVector(opts, prolog_flag_property_defs, - PROLOG_FLAG_PROPERTY_END); + args = + Yap_ArgList2ToVector(opts, prolog_flag_property_defs, + PROLOG_FLAG_PROPERTY_END, DOMAIN_ERROR_PROLOG_FLAG); if (args == NULL) { Yap_Error(LOCAL_Error_TYPE, opts, NULL); return false; } + if (IsStringTerm(tflag)) { + tflag = MkStringTerm(RepAtom(AtomOfTerm(tflag))->StrOfAE); + } if (!IsAtomTerm(tflag)) { if (IsApplTerm(tflag) && FunctorOfTerm(tflag) == FunctorModule) { Term modt = CurrentModule; @@ -1426,7 +1570,9 @@ do_prolog_flag_property(Term tflag, if (fv->global) { if (fv->FlagOfVE == UNKNOWN_FLAG || fv->FlagOfVE == CHARACTER_ESCAPES_FLAG || - fv->FlagOfVE == BACKQUOTED_STRING_FLAG) + fv->FlagOfVE == SINGLE_QUOTES_FLAG || + fv->FlagOfVE == DOUBLE_QUOTES_FLAG || + fv->FlagOfVE == BACK_QUOTES_FLAG) Yap_unify(TermModule, args[PROLOG_FLAG_PROPERTY_SCOPE].tvalue); rc = rc && Yap_unify(TermGlobal, args[PROLOG_FLAG_PROPERTY_SCOPE].tvalue); @@ -1459,7 +1605,8 @@ static Int cont_prolog_flag_property(USES_REGS1) { /* current_prolog_flag */ lab = MkAtomTerm(Yap_LookupAtom(local_flags_setup[i - gmax].name)); } else { if (i == UNKNOWN_FLAG || i == CHARACTER_ESCAPES_FLAG || - i == BACKQUOTED_STRING_FLAG) { + i == SINGLE_QUOTES_FLAG || i == DOUBLE_QUOTES_FLAG || + i == BACK_QUOTES_FLAG) { Term labs[2]; labs[0] = MkVarTerm(); labs[1] = MkAtomTerm(Yap_LookupAtom(global_flags_setup[i].name)); @@ -1492,6 +1639,9 @@ static Int prolog_flag_property(USES_REGS1) { /* Init current_prolog_flag */ Term t1 = Deref(ARG1); /* make valgrind happy by always filling in memory */ EXTRA_CBACK_ARG(2, 1) = MkIntTerm(0); + if (IsStringTerm(t1)) { + t1 = MkStringTerm(RepAtom(AtomOfTerm(t1))->StrOfAE); + } if (IsVarTerm(t1)) { return (cont_prolog_flag_property(PASS_REGS1)); } else { @@ -1537,8 +1687,9 @@ static Int do_create_prolog_flag(USES_REGS1) { prolog_flag_property_choices_t i; Term tflag = Deref(ARG1), tval = Deref(ARG2), opts = Deref(ARG3); - args = Yap_ArgList2ToVector(opts, prolog_flag_property_defs, - PROLOG_FLAG_PROPERTY_END); + args = + Yap_ArgList2ToVector(opts, prolog_flag_property_defs, + PROLOG_FLAG_PROPERTY_END, DOMAIN_ERROR_PROLOG_FLAG); if (args == NULL) { Yap_Error(LOCAL_Error_TYPE, opts, NULL); return false; @@ -1590,15 +1741,15 @@ static Int do_create_prolog_flag(USES_REGS1) { } /** -* Init System Prolog flags. This is done in two phases: -* early on, it takes care of the atomic flags that are required by other -*modules; -* later, it looks at flags that are structured terms -* -* @param bootstrap: wether this is done before stack initialization, or -*afterwards. -* Complex terms can only be built in the second step. -*/ + * Init System Prolog flags. This is done in two phases: + * early on, it takes care of the atomic flags that are required by other + *modules; + * later, it looks at flags that are structured terms + * + * @param bootstrap: wether this is done before stack initialization, or + *afterwards. + * Complex terms can only be built in the second step. + */ void Yap_InitFlags(bool bootstrap) { CACHE_REGS @@ -1646,13 +1797,13 @@ void Yap_InitFlags(bool bootstrap) { Yap_InitCPredBack("current_prolog_flag", 2, 1, current_prolog_flag, cont_yap_flag, 0); TR = tr0; - /** @pred prolog_flag(? _Flag_,- _Value__) + /** @pred prolog_flag( ?Flag, - Value) - Obtain the value for a YAP Prolog flag, same as current_prolog_flag/2_. + Obtain the value for a YAP Prolog flag, same as current_prolog_flag/2. */ - Yap_InitCPredBack("prolog_flag", 3, 1, current_prolog_flag, cont_yap_flag, + Yap_InitCPredBack("prolog_flag", 3, 1, prolog_flag, cont_yap_flag, 0); - Yap_InitCPredBack("yap_flag", 3, 1, prolog_flag, cont_yap_flag, 0); + Yap_InitCPredBack("yap_flag", 3, 1, yap_flag, cont_yap_flag, 0); Yap_InitCPredBack("prolog_flag", 2, 1, current_prolog_flag2, cont_current_prolog_flag, 0); Yap_InitCPredBack("current_prolog_flag", 2, 1, current_prolog_flag2, @@ -1670,3 +1821,5 @@ void Yap_InitFlags(bool bootstrap) { } /* Accessing and changing the flags for a predicate */ + +// @} diff --git a/C/fli_absmi_insts.h b/C/fli_absmi_insts.h index 8d4a3e0f0..b59b41aa0 100644 --- a/C/fli_absmi_insts.h +++ b/C/fli_absmi_insts.h @@ -56,7 +56,7 @@ CPredicate f = PREG->y_u.Osbpp.p->cs.f_code; PREG = NEXTOP(PREG, Osbpp); saveregs(); - d0 = (f)(PASS_REGS1); + d0 = f(PASS_REGS1); setregs(); #ifdef SHADOW_S SREG = Yap_REGS.S_; @@ -74,7 +74,7 @@ ENDBOp(); /* execute Label */ - BOp(execute_cpred, pp); + BOp(execute_cpred, Osbpp); check_trail(TR); { PredEntry *pt0; @@ -103,7 +103,7 @@ SET_ASP(YREG, E_CB * sizeof(CELL)); /* for slots to work */ #endif /* FROZEN_STACKS */ - pt0 = PREG->y_u.pp.p; + pt0 = PREG->y_u.Osbpp.p; #ifdef LOW_LEVEL_TRACER if (Yap_do_low_level_trace) { low_level_trace(enter_pred, pt0, XREGS + 1); @@ -131,7 +131,7 @@ #endif /* DEPTH_LIMIT */ /* now call C-Code */ { - CPredicate f = PREG->y_u.pp.p->cs.f_code; + CPredicate f = PREG->y_u.Osbpp.p->cs.f_code; yamop *oldPREG = PREG; saveregs(); d0 = f(PASS_REGS1); @@ -623,10 +623,16 @@ BOp(undef_p, e); /* save S for module name */ - saveregs(); + if (LOCAL_DoingUndefp) { + PREG=FAILCODE; + JMPNext(); + } + LOCAL_DoingUndefp = true; + saveregs(); undef_goal(PASS_REGS1); setregs(); /* for profiler */ + LOCAL_DoingUndefp = false; CACHE_A1(); JMPNext(); ENDBOp(); diff --git a/C/globals.c b/C/globals.c index 2826fa41c..1e77bf2d1 100644 --- a/C/globals.c +++ b/C/globals.c @@ -22,10 +22,10 @@ static char SccsId[] = "%W% %G%"; * @file globals.c * @author VITOR SANTOS COSTA * @date Tue Nov 17 23:16:17 2015 - * + * * @brief support for backtrable and non-backtrackable variables in Prolog. - * - * + * + * */ /** @@ -163,6 +163,11 @@ static inline CELL *ArenaLimit(Term arena) { return arena_base + sz; } +/* pointer to top of an arena */ +CELL *Yap_ArenaLimit(Term arena) { + return ArenaLimit(arena); +} + /* pointer to top of an arena */ static inline CELL *ArenaPt(Term arena) { return (CELL *)RepAppl(arena); } @@ -346,18 +351,26 @@ static inline void clean_dirty_tr(tr_fr_ptr TR0 USES_REGS) { } } +#define expand_stack(S0,SP,SF,TYPE) \ + { size_t sz = SF-S0, used = SP-S0; \ + S0 = Realloc(S0, (1024+sz)*sizeof(TYPE) PASS_REGS); \ + SP = S0+used; SF = S0+sz; } + static int copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, int copy_att_vars, CELL *ptf, CELL *HLow USES_REGS) { - struct cp_frame *to_visit0, - *to_visit = (struct cp_frame *)Yap_PreAllocCodeSpace(); + int lvl = push_text_stack(); + struct cp_frame *to_visit0, *to_visit = Malloc(1024*sizeof(struct cp_frame)); + struct cp_frame *to_visit_max; + CELL *HB0 = HB; tr_fr_ptr TR0 = TR; int ground = TRUE; HB = HLow; to_visit0 = to_visit; + to_visit_max = to_visit+1024; loop: while (pt0 < pt0_end) { register CELL d0; @@ -377,8 +390,8 @@ loop: *ptf = AbsPair(HR); ptf++; #ifdef RATIONAL_TREES - if (to_visit + 1 >= (struct cp_frame *)AuxSp) { - goto heap_overflow; + if (to_visit >= to_visit_max-32) { + expand_stack(to_visit0, to_visit, to_visit_max, struct cp_frame); } to_visit->start_cp = pt0; to_visit->end_cp = pt0_end; @@ -390,8 +403,9 @@ loop: to_visit++; #else if (pt0 < pt0_end) { - if (to_visit + 1 >= (CELL **)AuxSp) { - goto heap_overflow; + if (to_visit + 32 >= to_visit_max - 32) { + expand_stack(to_visit0, to_visit, to_visit_max, struct cp_frame); + } to_visit->start_cp = pt0; to_visit->end_cp = pt0_end; @@ -461,7 +475,7 @@ loop: goto overflow; } *ptf++ = AbsAppl(HR); - memcpy(HR, ap2, sizeof(CELL) * (3 + ap2[1])); + memmove(HR, ap2, sizeof(CELL) * (3 + ap2[1])); HR += ap2[1] + 3; break; default: { @@ -488,8 +502,8 @@ loop: ptf++; /* store the terms to visit */ #ifdef RATIONAL_TREES - if (to_visit + 1 >= (struct cp_frame *)AuxSp) { - goto heap_overflow; + if (to_visit + 32 >= to_visit_max) { + expand_stack(to_visit0, to_visit, to_visit_max, struct cp_frame); } to_visit->start_cp = pt0; to_visit->end_cp = pt0_end; @@ -502,7 +516,7 @@ loop: #else if (pt0 < pt0_end) { if (to_visit++ >= (CELL **)AuxSp) { - goto heap_overflow; + expand_stack(to_visit0, to_visit, to_visit_max, struct cp_frame); } to_visit->start_cp = pt0; to_visit->end_cp = pt0_end; @@ -588,6 +602,7 @@ loop: HB = HB0; clean_dirty_tr(TR0 PASS_REGS); /* follow chain of multi-assigned variables */ + pop_text_stack(lvl); return 0; overflow: @@ -606,26 +621,9 @@ overflow: } #endif reset_trail(TR0); + pop_text_stack(lvl); return -1; -heap_overflow: - /* oops, we're in trouble */ - HR = HLow; - /* we've done it */ - /* restore our nice, friendly, term to its original state */ - HB = HB0; -#ifdef RATIONAL_TREES - while (to_visit > to_visit0) { - to_visit--; - pt0 = to_visit->start_cp; - pt0_end = to_visit->end_cp; - ptf = to_visit->to; - *pt0 = to_visit->oldv; - } -#endif - reset_trail(TR0); - return -2; - trail_overflow: /* oops, we're in trouble */ HR = HLow; @@ -642,6 +640,7 @@ trail_overflow: } #endif reset_trail(TR0); + pop_text_stack(lvl); return -4; } @@ -757,7 +756,7 @@ restart: res = -1; goto error_handler; } - memcpy(HR, ap, sizeof(CELL) * (3 + ap[1])); + memmove(HR, ap, sizeof(CELL) * (3 + ap[1])); HR += ap[1] + 3; break; default: { @@ -1244,7 +1243,7 @@ Term Yap_SaveTerm(Term t0) { CACHE_REGS Term to; to = CopyTermToArena( - t0, LOCAL_GlobalArena, FALSE, TRUE, 2, &LOCAL_GlobalArena, + Deref(t0), LOCAL_GlobalArena, FALSE, TRUE, 2, &LOCAL_GlobalArena, garena_overflow_size(ArenaPt(LOCAL_GlobalArena) PASS_REGS) PASS_REGS); if (to == 0L) return to; @@ -2779,7 +2778,7 @@ void Yap_InitGlobals(void) { Yap_InitCPred("nb_create", 4, p_nb_create2, 0L); Yap_InitCPredBack("$nb_current", 1, 1, init_current_nb, cont_current_nb, SafePredFlag); - /// @{ + /// @{ /// @addtogroup nb CurrentModule = GLOBALS_MODULE; Yap_InitCPred("nb_queue", 1, p_nb_queue, 0L); diff --git a/C/gprof.c b/C/gprof.c index 2e7d74758..1de391638 100755 --- a/C/gprof.c +++ b/C/gprof.c @@ -35,7 +35,7 @@ * Revision 1.3 2006/01/17 14:10:40 vsc * YENV may be an HW register (breaks some tabling code) * All YAAM instructions are now brackedted, so Op introduced an { and EndOp introduces an }. This is because Ricardo assumes that. -* Fix attvars when COROUTING is undefined. +* Fix attvars * * Revision 1.2 2005/12/23 00:20:13 vsc * updates to gprof @@ -47,40 +47,40 @@ * * *************************************************************************/ +/// @file gprof.c -/** @defgroup Tick_Profiler Tick Profiler -@ingroup Profiling -@{ - -The tick profiler works by interrupting the Prolog code every so often -and checking at each point the code was. The profiler must be able to -retrace the state of the abstract machine at every moment. The major -advantage of this approach is that it gives the actual amount of time -being spent per procedure, or whether garbage collection dominates -execution time. The major drawback is that tracking down the state of -the abstract machine may take significant time, and in the worst case -may slow down the whole execution. - -The following procedures are available: - -+ profinit - - -Initialise the data-structures for the profiler. Unnecessary for -dynamic profiler. - -+ profon - - -Start profiling. - -+ profoff - - -Stop profiling. - - -*/ +/** @addtogroup Tick_Profiler + * @ingroup Profiling@{ + * + * The tick profiler works by interrupting the Prolog code every so often + * and checking at each point the code was. The pro/filer must be able to + * retrace the state of the abstract machine at every moment. The major + * advantage of this approach is that it gives the actual amount of time + * being spent per procedure, or whether garbage collection dominates + * execution time. The major drawback is that tracking down the state of + * the abstract machine may take significant time, and in the worst case + * may slow down the whole execution. + * + * The following procedures are available: + * + * + profinit/0 + * Initialise the data-structures for the profiler. Unnecessary for + * dynamic profiler. + * + * + profon/0 + * Start profiling. + * + * + profoff/0 + * Stop profiling. + * + * + profoff/0 + * Stop profiling. + * + * + showprofres/0 and showprofres/1 + * Stop tick counts per predicate. + * + * + */ #ifdef SCCS static char SccsId[] = "%W% %G%"; @@ -841,7 +841,7 @@ static void RemoveCode(CODEADDR clau) } } -static int +static Int showprofres( USES_REGS1 ) { buf_ptr buf; @@ -973,7 +973,7 @@ prof_alrm(int signo, siginfo_t *si, void *scv) current_p = PREVOP(P,Osbpp)->y_u.Osbpp.p->CodeOfPred; } else if ((oop = Yap_op_from_opcode(P->opc)) == _execute_cpred) { /* doing C-code */ - current_p = P->y_u.pp.p->CodeOfPred; + current_p = P->y_u.Osbpp.p->CodeOfPred; } else { current_p = P; } diff --git a/C/grow.c b/C/grow.c index cbd532665..e80ee26f1 100755 --- a/C/grow.c +++ b/C/grow.c @@ -205,13 +205,13 @@ CopyLocalAndTrail( USES_REGS1 ) static void IncrementalCopyStacksFromWorker( USES_REGS1 ) { - memcpy((void *) PtoGloAdjust((CELL *)LOCAL_start_global_copy), + memmove((void *) PtoGloAdjust((CELL *)LOCAL_start_global_copy), (void *) (LOCAL_start_global_copy), (size_t) (LOCAL_end_global_copy - LOCAL_start_global_copy)); - memcpy((void *) PtoLocAdjust((CELL *)LOCAL_start_local_copy), + memmove((void *) PtoLocAdjust((CELL *)LOCAL_start_local_copy), (void *) LOCAL_start_local_copy, (size_t) (LOCAL_end_local_copy - LOCAL_start_local_copy)); - memcpy((void *) PtoTRAdjust((tr_fr_ptr)LOCAL_start_trail_copy), + memmove((void *) PtoTRAdjust((tr_fr_ptr)LOCAL_start_trail_copy), (void *) (LOCAL_start_trail_copy), (size_t) (LOCAL_end_trail_copy - LOCAL_start_trail_copy)); } @@ -586,8 +586,8 @@ AdjustGlobal(Int sz, bool thread_copying USES_REGS) (sizeof(MP_INT)+ (((MP_INT *)(pt+2))->_mp_alloc*sizeof(mp_limb_t)))/CellSize; //printf("sz *%ld* at @%ld@\n", sz, pt-H0); - Opaque_CallOnGCMark f; - Opaque_CallOnGCRelocate f2; + YAP_Opaque_CallOnGCMark f; + YAP_Opaque_CallOnGCRelocate f2; Term t = AbsAppl(pt); if ( (f = Yap_blob_gc_mark_handler(t)) ) { diff --git a/C/heapgc.c b/C/heapgc.c index 68415abbe..badd63c7e 100644 --- a/C/heapgc.c +++ b/C/heapgc.c @@ -67,7 +67,7 @@ typedef struct gc_mark_continuation { } cont; /* straightforward binary tree scheme that, given a key, finds a - matching dbref */ + matching dbref */ typedef enum { db_entry, @@ -117,7 +117,7 @@ gc_growtrail(int committed, tr_fr_ptr begsTR, cont *old_cont_top0 USES_REGS) UInt sz = LOCAL_TrailTop-(ADDR)LOCAL_OldTR; /* ask for double the size */ sz = 2*sz; - + if (!Yap_locked_growtrail(sz, TRUE)) { #ifdef EASY_SHUNTING if (begsTR) { @@ -128,13 +128,13 @@ gc_growtrail(int committed, tr_fr_ptr begsTR, cont *old_cont_top0 USES_REGS) TrailTerm(LOCAL_sTR+1) = TrailTerm(begsTR+2); begsTR = newsTR; LOCAL_sTR += 2; - } + } } set_conditionals(LOCAL_sTR PASS_REGS); #endif /* could not find more trail */ save_machine_regs(); - siglongjmp(*LOCAL_gc_restore, 2); + siglongjmp(LOCAL_gc_restore, 2); } } @@ -201,7 +201,7 @@ POPSWAP_POINTER(CELL_PTR *vp, CELL_PTR v USES_REGS) { static inline void exchange(CELL_PTR * b, Int i, Int j) -{ +{ CELL *t = b[j]; b[j] = b[i]; @@ -210,7 +210,7 @@ exchange(CELL_PTR * b, Int i, Int j) static UInt partition(CELL *a[], Int p, Int r) -{ +{ CELL *x; UInt i, j; @@ -245,7 +245,7 @@ static void insort(CELL *a[], Int p, Int q) { Int j; - + for (j = p+1; j <= q; j ++) { CELL *key; Int i; @@ -264,7 +264,7 @@ insort(CELL *a[], Int p, Int q) static void quicksort(CELL *a[], Int p, Int r) -{ +{ Int q; if (p < r) { if (r - p < 100) { @@ -272,7 +272,7 @@ quicksort(CELL *a[], Int p, Int r) return; } exchange(a, p, (p+r)/2); - q = partition (a, p, r); + q = partition (a, p, r); quicksort(a, p, q-1); quicksort(a, q + 1, r); } @@ -288,7 +288,7 @@ quicksort(CELL *a[], Int p, Int r) #ifdef MULTI_ASSIGNMENT_VARIABLES -/* +/* Based in opt.mavar.h. This is a set of routines to find out if a ma trail entry has appeared before in the same trail segment. All ma entries for the same cell are then linked. At the end of mark_trail() only @@ -300,7 +300,7 @@ GC_MAVAR_HASH(CELL *addr) { #if SIZEOF_INT_P==8 return((((unsigned int)((CELL)(addr)))>>3)%GC_MAVARS_HASH_SIZE); #else - return((((unsigned int)((CELL)(addr)))>>2)%GC_MAVARS_HASH_SIZE); + return((((unsigned int)((CELL)(addr)))>>2)%GC_MAVARS_HASH_SIZE); #endif } @@ -397,7 +397,7 @@ check_pr_trail( tr_fr_ptr rc USES_REGS) if (!Yap_locked_growtrail(0, TRUE) || TRUE) { /* could not find more trail */ save_machine_regs(); - siglongjmp(*LOCAL_gc_restore, 2); + siglongjmp( LOCAL_gc_restore, 2); } rc = TR-n; } @@ -505,7 +505,7 @@ push_registers(Int num_regs, yamop *nextop USES_REGS) /* pop the corrected register values from the trail and update the registers */ -static void +static void pop_registers(Int num_regs, yamop *nextop USES_REGS) { int i; @@ -514,7 +514,7 @@ pop_registers(Int num_regs, yamop *nextop USES_REGS) /* pop info on opaque variables */ while (LOCAL_extra_gc_cells > LOCAL_extra_gc_cells_base) { - Opaque_CallOnGCRelocate f; + YAP_Opaque_CallOnGCRelocate f; CELL *ptr = LOCAL_extra_gc_cells-1; size_t n = ptr[0], t = ptr[-1]; @@ -525,8 +525,8 @@ pop_registers(Int num_regs, yamop *nextop USES_REGS) /* error: we don't have enough room */ /* could not find more trail */ save_machine_regs(); - siglongjmp(*LOCAL_gc_restore, 4); - } + siglongjmp(LOCAL_gc_restore, 4); + } } } @@ -579,7 +579,7 @@ pop_registers(Int num_regs, yamop *nextop USES_REGS) while (curslot < topslot) { *curslot++ = TrailTerm(ptr++); } - + } for (i = 1; i <= num_regs; i++) @@ -608,7 +608,7 @@ pop_registers(Int num_regs, yamop *nextop USES_REGS) } #if DEBUG && COUNT_CELLS_MARKED -static int +static int count_cells_marked(void) { CELL *current; @@ -629,7 +629,7 @@ RBMalloc(UInt size USES_REGS) { ADDR new = LOCAL_db_vec; - LOCAL_db_vec += size; + LOCAL_db_vec += size; if ((ADDR)LOCAL_db_vec > LOCAL_TrailTop-1024) { gc_growtrail(FALSE, NULL, NULL PASS_REGS); } @@ -693,8 +693,8 @@ LeftRotate(rb_red_blk_node* x USES_REGS) { if (y->left != rb_nil) y->left->parent=x; /* used to use sentinel here */ /* and do an unconditional assignment instead of testing for nil */ - - y->parent=x->parent; + + y->parent=x->parent; /* instead of checking if x->parent is the root as in the book, we */ /* count on the root sentinel to implicitly take care of this case */ @@ -787,7 +787,7 @@ TreeInsertHelp(rb_red_blk_node* z USES_REGS) { rb_red_blk_node* x; rb_red_blk_node* y; rb_red_blk_node* rb_nil=LOCAL_db_nil; - + z->left=z->right=rb_nil; y=LOCAL_db_root; x=LOCAL_db_root->left; @@ -863,7 +863,7 @@ RBTreeInsert(CODEADDR key, CODEADDR end, db_entry_type db_type USES_REGS) { x->parent->red=0; x->parent->parent->red=1; RightRotate(x->parent->parent PASS_REGS); - } + } } else { /* case for x->parent == x->parent->parent->right */ y=x->parent->parent->left; if (y->red) { @@ -879,7 +879,7 @@ RBTreeInsert(CODEADDR key, CODEADDR end, db_entry_type db_type USES_REGS) { x->parent->red=0; x->parent->parent->red=1; LeftRotate(x->parent->parent PASS_REGS); - } + } } } LOCAL_db_root->left->red=0; @@ -932,7 +932,7 @@ ref_in_use(DBRef ref USES_REGS) return el->in_use; } -static void +static void mark_db_fixed(CELL *ptr USES_REGS) { rb_red_blk_node *el; @@ -942,7 +942,7 @@ mark_db_fixed(CELL *ptr USES_REGS) { } } -static void +static void init_dbtable(tr_fr_ptr trail_ptr USES_REGS) { StaticClause *sc = DeadStaticClauses; MegaClause *mc = DeadMegaClauses; @@ -958,14 +958,14 @@ init_dbtable(tr_fr_ptr trail_ptr USES_REGS) { LOCAL_db_root = RBTreeCreate(); while (trail_ptr > (tr_fr_ptr)LOCAL_TrailBase) { register CELL trail_cell; - + trail_ptr--; - + trail_cell = TrailTerm(trail_ptr); if (!IsVarTerm(trail_cell) && IsPairTerm(trail_cell)) { CELL *pt0 = RepPair(trail_cell); - /* DB pointer */ + /* DB pointer */ CELL flags; #ifdef FROZEN_STACKS /* TRAIL */ @@ -986,16 +986,16 @@ init_dbtable(tr_fr_ptr trail_ptr USES_REGS) { are only pointers, reset the flag */ if (FlagOn(DBClMask, flags)) { DBRef dbr = DBStructFlagsToDBStruct(pt0); - store_in_dbtable((CODEADDR)dbr, + store_in_dbtable((CODEADDR)dbr, (CODEADDR)dbr+sizeof(DBStruct)+sizeof(CELL)*dbr->DBT.NOfCells, db_entry PASS_REGS); } else if (flags & LogUpdMask) { if (flags & IndexMask) { LogUpdIndex *li = ClauseFlagsToLogUpdIndex(pt0); - store_in_dbtable((CODEADDR)li, (CODEADDR)li+li->ClSize, li_entry PASS_REGS); + store_in_dbtable((CODEADDR)li, (CODEADDR)li+li->ClSize, li_entry PASS_REGS); } else { LogUpdClause *cli = ClauseFlagsToLogUpdClause(pt0); - store_in_dbtable((CODEADDR)cli, (CODEADDR)cli+cli->ClSize, lcl_entry PASS_REGS); + store_in_dbtable((CODEADDR)cli, (CODEADDR)cli+cli->ClSize, lcl_entry PASS_REGS); } } else { DynamicClause *dcl = ClauseFlagsToDynamicClause(pt0); @@ -1191,7 +1191,7 @@ check_global(void) { /* mark a heap object and all heap objects accessible from it */ -static void +static void mark_variable(CELL_PTR current USES_REGS) { CELL_PTR next; @@ -1244,7 +1244,7 @@ mark_variable(CELL_PTR current USES_REGS) if (next > current && current < LOCAL_prev_HB && current >= HB && next >= HB && next < LOCAL_prev_HB) { #ifdef INSTRUMENT_GC inc_var(current, current); -#endif +#endif *next = (CELL)current; UNMARK(next); MARK(current); @@ -1254,7 +1254,7 @@ mark_variable(CELL_PTR current USES_REGS) /* can't help here */ #ifdef INSTRUMENT_GC inc_var(current, next); -#endif +#endif current = next; } } else { @@ -1280,7 +1280,7 @@ mark_variable(CELL_PTR current USES_REGS) } } /* try to shorten chains if they go through the current CP */ - } else if (next > HB && + } else if (next > HB && IsVarTerm(cnext) && UNMARK_CELL(cnext) != (CELL)next && current < LCL0) { @@ -1315,7 +1315,7 @@ mark_variable(CELL_PTR current USES_REGS) } else { #ifdef COROUTING LOCAL_total_smarked++; -#endif +#endif #ifdef INSTRUMENT_GC inc_var(current, next); #endif @@ -1325,7 +1325,7 @@ mark_variable(CELL_PTR current USES_REGS) #ifdef INSTRUMENT_GC if (IsAtomTerm(ccur)) inc_vars_of_type(current,gc_atom); - else + else inc_vars_of_type(current, gc_int); #endif POP_CONTINUATION(); @@ -1359,7 +1359,7 @@ mark_variable(CELL_PTR current USES_REGS) POP_CONTINUATION(); } else if (IsApplTerm(ccur)) { register CELL cnext = *next; - + #ifdef INSTRUMENT_GC if (!IsExtensionFunctor((Functor)cnext)) inc_vars_of_type(current,gc_appl); @@ -1384,7 +1384,7 @@ mark_variable(CELL_PTR current USES_REGS) } if ( MARKED_PTR(next) || !ONHEAP(next) ) POP_CONTINUATION(); - + if (next < H0) POP_CONTINUATION(); if (IsExtensionFunctor((Functor)cnext)) { switch (cnext) { @@ -1436,43 +1436,44 @@ mark_variable(CELL_PTR current USES_REGS) MARK(next+sz); } POP_CONTINUATION(); - case (CELL)FunctorBigInt: - { - Opaque_CallOnGCMark f; - Term t = AbsAppl(next); - UInt sz = (sizeof(MP_INT)+CellSize+ - ((MP_INT *)(next+2))->_mp_alloc*sizeof(mp_limb_t))/CellSize; + case (CELL)FunctorBigInt: { + YAP_Opaque_CallOnGCMark f; + Term t = AbsAppl(next); + UInt sz = (sizeof(MP_INT) + CellSize + + ((MP_INT *)(next + 2))->_mp_alloc * sizeof(mp_limb_t)) / + CellSize; - MARK(next); - if ( (f = Yap_blob_gc_mark_handler(t)) ) { - Int n = (f)(Yap_BlobTag(t), Yap_BlobInfo(t), LOCAL_extra_gc_cells, LOCAL_extra_gc_cells_top - (LOCAL_extra_gc_cells+2)); - if (n < 0) { - /* error: we don't have enough room */ - /* could not find more trail */ - save_machine_regs(); - siglongjmp(*LOCAL_gc_restore, 3); - } else if (n > 0) { - CELL *ptr = LOCAL_extra_gc_cells; + MARK(next); + if ((f = Yap_blob_gc_mark_handler(t))) { + Int n = (f)(Yap_BlobTag(t), Yap_BlobInfo(t), LOCAL_extra_gc_cells, + LOCAL_extra_gc_cells_top - (LOCAL_extra_gc_cells + 2)); + if (n < 0) { + /* error: we don't have enough room */ + /* could not find more trail */ + save_machine_regs(); + siglongjmp(LOCAL_gc_restore, 3); + } else if (n > 0) { + CELL *ptr = LOCAL_extra_gc_cells; - LOCAL_extra_gc_cells += n+2; - PUSH_CONTINUATION(ptr, n+1 PASS_REGS); - ptr += n; - ptr[0] = t; - ptr[1] = n+1; - } - } + LOCAL_extra_gc_cells += n + 2; + PUSH_CONTINUATION(ptr, n + 1 PASS_REGS); + ptr += n; + ptr[0] = t; + ptr[1] = n + 1; + } + } - /* size is given by functor + friends */ - if (next < LOCAL_HGEN) { - LOCAL_total_oldies += 2+sz; - } else { - DEBUG_printf0("%p 1\n", next); - DEBUG_printf1("%p %ld\n", next, (long int)(sz+2)); - } - //fprintf(stderr,"%p M %d\n", next,2+sz); - LOCAL_total_marked += 2+sz; - PUSH_POINTER(next PASS_REGS); - sz++; + /* size is given by functor + friends */ + if (next < LOCAL_HGEN) { + LOCAL_total_oldies += 2 + sz; + } else { + DEBUG_printf0("%p 1\n", next); + DEBUG_printf1("%p %ld\n", next, (long int)(sz + 2)); + } + // fprintf(stderr,"%p M %d\n", next,2+sz); + LOCAL_total_marked += 2 + sz; + PUSH_POINTER(next PASS_REGS); + sz++; #if DEBUG if (next[sz] != EndSpecials) { fprintf(stderr,"[ Error: could not find EndSpecials at blob %p type " UInt_FORMAT " ]\n", next, next[1]); @@ -1523,7 +1524,7 @@ mark_variable(CELL_PTR current USES_REGS) } } -void +void Yap_mark_variable(CELL_PTR current) { CACHE_REGS @@ -1556,9 +1557,9 @@ mark_external_reference(CELL *ptr USES_REGS) { if (ONHEAP(next)) { #ifdef HYBRID_SCHEME CELL_PTR *old = LOCAL_iptop; -#endif +#endif mark_variable(ptr PASS_REGS); - POPSWAP_POINTER(old, ptr PASS_REGS); + POPSWAP_POINTER(old, ptr PASS_REGS); } else if (ptr < H0 || ptr > (CELL*)LOCAL_TrailTop) { MARK(ptr); mark_code(ptr, next PASS_REGS); @@ -1567,7 +1568,7 @@ mark_external_reference(CELL *ptr USES_REGS) { /* * mark all heap objects accessible from the trail (which includes the active - * general purpose registers) + * general purpose registers) */ void @@ -1576,12 +1577,12 @@ Yap_mark_external_reference(CELL *ptr) { mark_external_reference(ptr PASS_REGS); } -static void +static void mark_regs(tr_fr_ptr old_TR USES_REGS) { tr_fr_ptr trail_ptr, tr = TR; - + /* first, whatever we dumped on the trail. Easier just to do the registers separately? */ for (trail_ptr = old_TR; trail_ptr < tr; trail_ptr++) { @@ -1592,7 +1593,7 @@ mark_regs(tr_fr_ptr old_TR USES_REGS) /* mark all heap objects accessible from a chain of environments */ -static void +static void mark_environments(CELL_PTR gc_ENV, size_t size, CELL *pvbmap USES_REGS) { CELL_PTR saved_var; @@ -1600,7 +1601,7 @@ mark_environments(CELL_PTR gc_ENV, size_t size, CELL *pvbmap USES_REGS) Int bmap = 0; int currv = 0; - //fprintf(stderr,"ENV %p %ld\n", gc_ENV, size); + //fprintf(stderr,"ENV %p %ld\n", gc_ENV, size); #ifdef DEBUG if (/* size < 0 || */ size > 512) fprintf(stderr,"OOPS in GC: env size for %p is " UInt_FORMAT "\n", gc_ENV, (CELL)size); @@ -1634,7 +1635,7 @@ mark_environments(CELL_PTR gc_ENV, size_t size, CELL *pvbmap USES_REGS) if (bmap < 0 && !MARKED_PTR(saved_var)) { #ifdef INSTRUMENT_GC Term ccur = *saved_var; - + if (IsVarTerm(ccur)) { int len = 1; CELL *mynext= GET_NEXT(ccur); @@ -1658,7 +1659,7 @@ mark_environments(CELL_PTR gc_ENV, size_t size, CELL *pvbmap USES_REGS) } } #endif - mark_external_reference(saved_var PASS_REGS); + mark_external_reference(saved_var PASS_REGS); } bmap <<= 1; currv++; @@ -1696,7 +1697,7 @@ mark_environments(CELL_PTR gc_ENV, size_t size, CELL *pvbmap USES_REGS) } } -/* +/* Cleaning the trail should be quick and simple, right? Well, not really :-(. The problem is that the trail includes a dumping ground of the WAM registers and of extra choice-point fields, which need @@ -1728,7 +1729,7 @@ mark_trail(tr_fr_ptr trail_ptr, tr_fr_ptr trail_base, CELL *gc_H, choiceptr gc_B GC_NEW_MAHASH((gc_ma_hash_entry *)LOCAL_cont_top0 PASS_REGS); while (trail_base < trail_ptr) { register CELL trail_cell; - + trail_cell = TrailTerm(trail_base); if (IsVarTerm(trail_cell)) { CELL *hp = (CELL *)trail_cell; @@ -1736,7 +1737,7 @@ mark_trail(tr_fr_ptr trail_ptr, tr_fr_ptr trail_base, CELL *gc_H, choiceptr gc_B than its new binding is not accessible and we can reset it. Note we must use gc_H to avoid trouble with dangling variables in the heap */ - if (((hp < gc_H && hp >= H0) || (hp > (CELL *)gc_B && hp < LCL0) ) && !MARKED_PTR(hp)) { + if ((hp < gc_H && hp >= H0 ) && !MARKED_PTR(hp)) { /* perform early reset */ /* reset term to be a variable */ RESET_VARIABLE(hp); @@ -1811,15 +1812,9 @@ mark_trail(tr_fr_ptr trail_ptr, tr_fr_ptr trail_base, CELL *gc_H, choiceptr gc_B TrailTerm(trail_base) = (CELL)cptr; mark_external_reference(&TrailTerm(trail_base) PASS_REGS); TrailTerm(trail_base) = trail_cell; - } else if (*cptr == (CELL)FunctorBigInt) { - TrailTerm(trail_base) = AbsAppl(cptr); + } else { mark_external_reference(&TrailTerm(trail_base) PASS_REGS); - TrailTerm(trail_base) = trail_cell; - } -#ifdef DEBUG - else - fprintf(stderr,"OOPS in GC: weird trail entry at %p:" UInt_FORMAT "\n", &TrailTerm(trail_base), (CELL)cptr); -#endif + } } } #if MULTI_ASSIGNMENT_VARIABLES @@ -1846,7 +1841,7 @@ mark_trail(tr_fr_ptr trail_ptr, tr_fr_ptr trail_base, CELL *gc_H, choiceptr gc_B if (!gc_lookup_ma_var(cptr, trail_base PASS_REGS)) { /* check whether this is the first time we see it*/ Term t0 = TrailTerm(trail_base+1); - + if (!IsAtomicTerm(t0)) { CELL *next = GET_NEXT(t0); /* check if we have a garbage entry, where we are setting a @@ -1883,7 +1878,7 @@ mark_trail(tr_fr_ptr trail_ptr, tr_fr_ptr trail_base, CELL *gc_H, choiceptr gc_B mark_external_reference(&(TrailTerm(trail_base)) PASS_REGS); /* reset the gc to believe the original tag */ TrailTerm(trail_base) = AbsAppl((CELL *)TrailTerm(trail_base)); - } + } #endif /* TABLING */ } else { remove_trash_entry: @@ -1909,7 +1904,7 @@ mark_trail(tr_fr_ptr trail_ptr, tr_fr_ptr trail_base, CELL *gc_H, choiceptr gc_B trail_base++; } #if TABLING - /* + /* Ugly, but needed: we're not really sure about what were the new values until the very end */ @@ -1930,7 +1925,7 @@ mark_trail(tr_fr_ptr trail_ptr, tr_fr_ptr trail_base, CELL *gc_H, choiceptr gc_B TrailTerm(LOCAL_sTR+1) = TrailTerm(begsTR+2); begsTR = newsTR; LOCAL_sTR += 2; - } + } LOCAL_sTR0 = OldsTR0; #else LOCAL_cont_top0 = old_cont_top0; @@ -1940,7 +1935,7 @@ mark_trail(tr_fr_ptr trail_ptr, tr_fr_ptr trail_base, CELL *gc_H, choiceptr gc_B /* * mark all heap objects accessible from each choicepoint & its chain of - * environments + * environments */ #ifdef TABLING @@ -1970,21 +1965,21 @@ youngest_cp(choiceptr gc_B, dep_fr_ptr *depfrp) min = DepFr_cons_cp(depfr); } if (depfr && min == DepFr_cons_cp(depfr)) { - *depfrp = DepFr_next(depfr); + *depfrp = DepFr_next(depfr); } return min; } #endif /* TABLING */ -static void +static void mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, bool very_verbose USES_REGS) { - OPCODE + OPCODE trust_lu = Yap_opcode(_trust_logical), count_trust_lu = Yap_opcode(_count_trust_logical), profiled_trust_lu = Yap_opcode(_profiled_trust_logical); - + yamop *lu_cl0 = NEXTOP(PredLogUpdClause0->CodeOfPred,Otapl), *lu_cl = NEXTOP(PredLogUpdClause->CodeOfPred,Otapl), *lu_cle = NEXTOP(PredLogUpdClauseErase->CodeOfPred,Otapl), @@ -2104,7 +2099,7 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, bool very_verbose } case _retry_c: case _retry_userc: - if (gc_B->cp_ap == RETRY_C_RECORDED_K_CODE + if (gc_B->cp_ap == RETRY_C_RECORDED_K_CODE || gc_B->cp_ap == RETRY_C_RECORDEDP_CODE) { /* we have a reference from the choice-point stack to a term */ choiceptr old_b = B; @@ -2129,7 +2124,7 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, bool very_verbose goto restart_cp; case _retry_profiled: case _count_retry: - rtp = NEXTOP(rtp,l); + rtp = NEXTOP(rtp,l); op = rtp->opc; opnum = Yap_op_from_opcode(op); goto restart_cp; @@ -2142,7 +2137,7 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, bool very_verbose CELL *vars_ptr, vars; vars_ptr = (CELL *) (LOAD_CP(gc_B) + 1); vars = *vars_ptr++; - while (vars--) { + while (vars--) { mark_external_reference(vars_ptr PASS_REGS); vars_ptr++; } @@ -2158,12 +2153,12 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, bool very_verbose CELL *vars_ptr, vars; vars_ptr = (CELL *)(GEN_CP(gc_B) + 1); nargs = rtp->y_u.Otapl.s; - while (nargs--) { + while (nargs--) { mark_external_reference(vars_ptr PASS_REGS); vars_ptr++; } vars = *vars_ptr++; - while (vars--) { + while (vars--) { mark_external_reference(vars_ptr PASS_REGS); vars_ptr++; } @@ -2184,13 +2179,13 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, bool very_verbose { vars_ptr = (CELL *)(GEN_CP(gc_B) + 1); nargs = SgFr_arity(GEN_CP(gc_B)->cp_sg_fr); - while (nargs--) { + while (nargs--) { mark_external_reference(vars_ptr PASS_REGS); vars_ptr++; } } vars = *vars_ptr++; - while (vars--) { + while (vars--) { mark_external_reference(vars_ptr PASS_REGS); vars_ptr++; } @@ -2216,18 +2211,18 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, bool very_verbose } else #endif /* MODE_DIRECTED_TABLING */ ans_node = TrNode_child(ans_node); - if (gc_B == DepFr_leader_cp(dep_fr)) { - /* gc_B is a generator-consumer node */ - /* never here if batched scheduling */ + if (gc_B == DepFr_leader_cp(dep_fr)) { + /* gc_B is a generator-consumer node */ + /* never here if batched scheduling */ TABLING_ERROR_CHECKING(generator_consumer, IS_BATCHED_GEN_CP(gc_B)); - vars_ptr = (CELL *) (GEN_CP(gc_B) + 1); - vars_ptr += SgFr_arity(GEN_CP(gc_B)->cp_sg_fr); - } else { - vars_ptr = (CELL *) (CONS_CP(gc_B) + 1); - } + vars_ptr = (CELL *) (GEN_CP(gc_B) + 1); + vars_ptr += SgFr_arity(GEN_CP(gc_B)->cp_sg_fr); + } else { + vars_ptr = (CELL *) (CONS_CP(gc_B) + 1); + } vars = *vars_ptr++; - while (vars--) { + while (vars--) { mark_external_reference(vars_ptr PASS_REGS); vars_ptr++; } @@ -2274,21 +2269,21 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, bool very_verbose subs_arity = vars_ptr[2 + heap_arity + vars_arity]; vars_ptr += 2 + heap_arity + subs_arity + vars_arity; if (subs_arity) { - while (subs_arity--) { + while (subs_arity--) { mark_external_reference(vars_ptr PASS_REGS); vars_ptr--; } } vars_ptr--; /* skip subs_arity entry */ if (vars_arity) { - while (vars_arity--) { + while (vars_arity--) { mark_external_reference(vars_ptr PASS_REGS); vars_ptr--; } } vars_ptr--; /* skip vars_arity entry */ if (heap_arity) { - while (heap_arity--) { + while (heap_arity--) { if (*vars_ptr == 0) /* double/longint extension mark */ break; mark_external_reference(vars_ptr PASS_REGS); @@ -2398,7 +2393,7 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, bool very_verbose nargs = rtp->y_u.Otapl.s; #endif } - + if (gc_B->cp_ap == lu_cl0 || gc_B->cp_ap == lu_cl || @@ -2424,7 +2419,7 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, bool very_verbose saved_reg++) { mark_external_reference(saved_reg PASS_REGS); } - } + } #if TABLING gc_B = youngest_cp(gc_B->cp_b, &depfr); #else @@ -2438,10 +2433,10 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, bool very_verbose /* * insert a cell which points to a heap object into relocation chain of that - * object + * object */ -static inline void +static inline void into_relocation_chain(CELL_PTR current, CELL_PTR next USES_REGS) { CELL current_tag; @@ -2525,7 +2520,7 @@ CleanDeadClauses( USES_REGS1 ) /* insert trail cells which point to heap objects into relocation chains */ -static void +static void sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR USES_REGS) { tr_fr_ptr trail_ptr, dest; @@ -2535,7 +2530,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR USES_REGS) hp_in_use_erased = 0, code_entries = 0; #endif CELL *ptr = LOCAL_extra_gc_cells; - + while (ptr > LOCAL_extra_gc_cells_base) { Int k = ptr[-1], i; ptr = ptr-1; @@ -2553,7 +2548,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR USES_REGS) } #ifndef FROZEN_STACKS - { + { choiceptr current = gc_B; choiceptr next = gc_B->cp_b; tr_fr_ptr source, dest; @@ -2566,7 +2561,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR USES_REGS) n->cp_b = current; current = n; } - + next = current; current = NULL; /* next, clean trail */ @@ -2579,7 +2574,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR USES_REGS) b->cp_tr = dest; next = b->cp_b; b->cp_b = current; - current = b; + current = b; } trail_cell = TrailTerm(source); if (trail_cell != (CELL)source) { @@ -2592,7 +2587,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR USES_REGS) b->cp_tr = dest; next = b->cp_b; b->cp_b = current; - current = b; + current = b; } } #endif /* FROZEN_STACKS */ @@ -2608,7 +2603,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR USES_REGS) } } } - + /* next, follows the real trail entries */ trail_ptr = (tr_fr_ptr)LOCAL_TrailBase; dest = trail_ptr; @@ -2655,7 +2650,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR USES_REGS) if (HEAP_PTR(TrailTerm(dest))) { into_relocation_chain(&TrailTerm(dest), GET_NEXT(trail_cell) PASS_REGS); } - } else if (*pt0 == (CELL)FunctorBigInt) { + } else { TrailTerm(dest) = trail_cell; /* be careful with partial gc */ if (HEAP_PTR(TrailTerm(dest))) { @@ -2694,7 +2689,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR USES_REGS) } else { if (FlagOn(ErasedMask, flags)) { hp_in_use_erased++; - } + } } #endif if (!ref_in_use((DBRef)pt0 PASS_REGS)) { @@ -2724,7 +2719,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR USES_REGS) erase = (indx->ClFlags & ErasedMask && !indx->ClRefCount); if (erase) { - /* at this point, + /* at this point, no one is accessing the clause */ Yap_ErLogUpdIndex(indx); } @@ -2747,7 +2742,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR USES_REGS) cl->ClFlags &= ~InUseMask; erase = ((cl->ClFlags & ErasedMask) && !cl->ClRefCount); if (erase) { - /* at this point, + /* at this point, no one is accessing the clause */ Yap_ErLogUpdCl(cl); } @@ -2767,7 +2762,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR USES_REGS) #endif ; if (erase) { - /* at this point, + /* at this point, no one is accessing the clause */ Yap_ErCl(cl); } @@ -2822,7 +2817,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR USES_REGS) CELL *ptr; /* be sure we don't overwrite before we read */ - if (marked_ptr) + if (marked_ptr) ptr = RepAppl(UNMARK_CELL(trail_cell)); else ptr = RepAppl(trail_cell); @@ -2888,10 +2883,10 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR USES_REGS) /* * insert cells of a chain of environments which point to heap objects into - * relocation chains + * relocation chains */ -static void +static void sweep_environments(CELL_PTR gc_ENV, size_t size, CELL *pvbmap USES_REGS) { CELL_PTR saved_var; @@ -2907,7 +2902,7 @@ sweep_environments(CELL_PTR gc_ENV, size_t size, CELL *pvbmap USES_REGS) if (size > EnvSizeInCells) { int tsize = size - EnvSizeInCells; - + currv = sizeof(CELL)*8-tsize%(sizeof(CELL)*8); if (pvbmap != NULL) { pvbmap += tsize/(sizeof(CELL)*8); @@ -2941,7 +2936,7 @@ sweep_environments(CELL_PTR gc_ENV, size_t size, CELL *pvbmap USES_REGS) } /* have we met this environment before?? */ /* we use the B field in the environment to tell whether we have - been here before or not + been here before or not */ if (!MARKED_PTR(gc_ENV+E_CB)) return; @@ -2980,9 +2975,9 @@ sweep_b(choiceptr gc_B, UInt arity USES_REGS) /* * insert cells of each choicepoint & its chain of environments which point - * to heap objects into relocation chains + * to heap objects into relocation chains */ -static void +static void sweep_choicepoints(choiceptr gc_B USES_REGS) { #ifdef TABLING @@ -3021,7 +3016,7 @@ sweep_choicepoints(choiceptr gc_B USES_REGS) restart_cp: /* * fprintf(stderr,"sweeping cps: %x, %x, %x\n", - * *gc_B,CP_Extra(gc_B),CP_Nargs(gc_B)); + * *gc_B,CP_Extra(gc_B),CP_Nargs(gc_B)); */ /* any choice point */ switch (opnum) { @@ -3062,7 +3057,7 @@ sweep_choicepoints(choiceptr gc_B USES_REGS) sweep_environments(gc_B->cp_env, EnvSize(gc_B->cp_cp), EnvBMap(gc_B->cp_cp) PASS_REGS); vars_ptr = (CELL *) (LOAD_CP(gc_B) + 1); vars = *vars_ptr++; - while (vars--) { + while (vars--) { CELL cp_cell = *vars_ptr; if (MARKED_PTR(vars_ptr)) { UNMARK(vars_ptr); @@ -3096,7 +3091,7 @@ sweep_choicepoints(choiceptr gc_B USES_REGS) vars_ptr++; } vars = *vars_ptr++; - while (vars--) { + while (vars--) { CELL cp_cell = *vars_ptr; if (MARKED_PTR(vars_ptr)) { UNMARK(vars_ptr); @@ -3136,7 +3131,7 @@ sweep_choicepoints(choiceptr gc_B USES_REGS) } } vars = *vars_ptr++; - while (vars--) { + while (vars--) { CELL cp_cell = *vars_ptr; if (MARKED_PTR(vars_ptr)) { UNMARK(vars_ptr); @@ -3178,7 +3173,7 @@ sweep_choicepoints(choiceptr gc_B USES_REGS) } sweep_environments(gc_B->cp_env, EnvSize(gc_B->cp_cp), EnvBMap(gc_B->cp_cp) PASS_REGS); vars = *vars_ptr++; - while (vars--) { + while (vars--) { CELL cp_cell = *vars_ptr; if (MARKED_PTR(vars_ptr)) { UNMARK(vars_ptr); @@ -3231,7 +3226,7 @@ sweep_choicepoints(choiceptr gc_B USES_REGS) subs_arity = vars_ptr[2 + heap_arity + vars_arity]; vars_ptr += 2 + heap_arity + subs_arity + vars_arity; if (subs_arity) { - while (subs_arity--) { + while (subs_arity--) { CELL cp_cell = *vars_ptr; if (MARKED_PTR(vars_ptr)) { UNMARK(vars_ptr); @@ -3244,7 +3239,7 @@ sweep_choicepoints(choiceptr gc_B USES_REGS) } vars_ptr--; /* skip subs_arity entry */ if (vars_arity) { - while (vars_arity--) { + while (vars_arity--) { CELL cp_cell = *vars_ptr; if (MARKED_PTR(vars_ptr)) { UNMARK(vars_ptr); @@ -3306,7 +3301,7 @@ sweep_choicepoints(choiceptr gc_B USES_REGS) case _retry_userc: { register CELL_PTR saved_reg; - + /* for each extra saved register */ for (saved_reg = &(gc_B->cp_a1)+rtp->y_u.OtapFs.s; saved_reg < &(gc_B->cp_a1)+rtp->y_u.OtapFs.s+rtp->y_u.OtapFs.extra; @@ -3402,9 +3397,9 @@ set_next_hb(choiceptr gc_B USES_REGS) /* * move marked objects on the heap upwards over unmarked objects, and reset - * all pointers to point to new locations + * all pointers to point to new locations */ -static void +static void compact_heap( USES_REGS1 ) { CELL_PTR dest, current, next; @@ -3423,7 +3418,7 @@ compact_heap( USES_REGS1 ) /* * upward phase - scan heap from high to low, setting marked upward * ptrs to point to what will be the new locations of the - * objects pointed to + * objects pointed to */ #ifdef TABLING @@ -3527,7 +3522,7 @@ compact_heap( USES_REGS1 ) /* * downward phase - scan heap from low to high, moving marked objects * to their new locations & setting downward pointers to pt to new - * locations + * locations */ dest = (CELL_PTR) start_from; @@ -3544,7 +3539,7 @@ compact_heap( USES_REGS1 ) *dest++ = *current++; } *old_dest = *current; - /* if we have are calling from the C-interface, + /* if we have are calling from the C-interface, we may have an open array when we start the gc */ if (LOCAL_OpenArray) { CELL *start = current + (dest-old_dest); @@ -3605,9 +3600,9 @@ compact_heap( USES_REGS1 ) #ifdef HYBRID_SCHEME /* * move marked objects on the heap upwards over unmarked objects, and reset - * all pointers to point to new locations + * all pointers to point to new locations */ -static void +static void icompact_heap( USES_REGS1 ) { CELL_PTR *iptr, *ibase = (CELL_PTR *)HR; @@ -3624,7 +3619,7 @@ icompact_heap( USES_REGS1 ) /* * upward phase - scan heap from high to low, setting marked upward * ptrs to point to what will be the new locations of the - * objects pointed to + * objects pointed to */ #ifdef TABLING @@ -3710,7 +3705,7 @@ icompact_heap( USES_REGS1 ) /* * downward phase - scan heap from low to high, moving marked objects * to their new locations & setting downward pointers to pt to new - * locations + * locations */ dest = H0; @@ -3789,7 +3784,7 @@ set_conditionals(tr_fr_ptr str USES_REGS) { str -= 2; cptr = (CELL *)TrailTerm(str+1); *cptr = TrailTerm(str); - } + } LOCAL_sTR = LOCAL_sTR0 = NULL; } #endif @@ -3797,10 +3792,10 @@ set_conditionals(tr_fr_ptr str USES_REGS) { /* * mark all objects on the heap that are accessible from active registers, - * the trail, environments, and choicepoints + * the trail, environments, and choicepoints */ -static void +static void marking_phase(tr_fr_ptr old_TR, CELL *current_env, yamop *curp USES_REGS) { @@ -3848,10 +3843,10 @@ sweep_oldgen(CELL *max, CELL *base USES_REGS) /* * move marked heap objects upwards over unmarked objects, and reset all - * pointers to point to new locations + * pointers to point to new locations */ -static void +static void compaction_phase(tr_fr_ptr old_TR, CELL *current_env, yamop *curp USES_REGS) { CELL *CurrentH0 = NULL; @@ -3894,7 +3889,7 @@ compaction_phase(tr_fr_ptr old_TR, CELL *current_env, yamop *curp USES_REGS) H0 = CurrentH0; LOCAL_HGEN = H0; LOCAL_total_marked += LOCAL_total_oldies; - CurrentH0 = NULL; + CurrentH0 = NULL; } quicksort((CELL_PTR *)HR, 0, (LOCAL_iptop-(CELL_PTR *)HR)-1); icompact_heap( PASS_REGS1 ); @@ -3935,8 +3930,6 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop USES_REGS) UInt alloc_sz; int jmp_res; sigjmp_buf jmp; - - LOCAL_gc_restore = &jmp; heap_cells = HR-H0; gc_verbose = is_gc_verbose(); @@ -3997,12 +3990,12 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop USES_REGS) UInt sz; /* we cannot recover, fail system */ - restore_machine_regs(); + restore_machine_regs(); sz = LOCAL_TrailTop-(ADDR)LOCAL_OldTR; /* ask for double the size */ sz = 2*sz; TR = LOCAL_OldTR; - + *--ASP = (CELL)current_env; if ( !Yap_locked_growtrail(sz, FALSE) @@ -4021,9 +4014,9 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop USES_REGS) } } else if (jmp_res == 3) { /* we cannot recover, fail system */ - restore_machine_regs(); + restore_machine_regs(); TR = LOCAL_OldTR; - + LOCAL_total_marked = 0; LOCAL_total_oldies = 0; #ifdef COROUTING @@ -4183,7 +4176,7 @@ p_inform_gc( USES_REGS1 ) Term tn = MkIntegerTerm(LOCAL_TotGcTime); Term tt = MkIntegerTerm(LOCAL_GcCalls); Term ts = Yap_Mk64IntegerTerm((LOCAL_TotGcRecovered*sizeof(CELL))); - + return(Yap_unify(tn, ARG2) && Yap_unify(tt, ARG1) && Yap_unify(ts, ARG3)); } @@ -4205,7 +4198,7 @@ call_gc(UInt gc_lim, Int predarity, CELL *current_env, yamop *nextop USES_REGS) gc_t = TRUE; } else { /* only go exponential for the first 6 calls, that would ask about 2MB minimum */ - if (LOCAL_GcCalls < 8) + if (LOCAL_GcCalls < 8) gc_margin <<= LOCAL_GcCalls; else { /* next grow linearly */ @@ -4220,13 +4213,13 @@ call_gc(UInt gc_lim, Int predarity, CELL *current_env, yamop *nextop USES_REGS) LOCAL_HGEN = VarOfTerm(Yap_ReadTimedVar(LOCAL_GcGeneration)); if (gc_on && !(LOCAL_PrologMode & InErrorMode) && /* make sure there is a point in collecting the heap */ - (ASP-H0)*sizeof(CELL) > gc_lim && + (ASP-H0)*sizeof(CELL) > gc_lim && HR-LOCAL_HGEN > (LCL0-ASP)/2) { effectiveness = do_gc(predarity, current_env, nextop PASS_REGS); if (effectiveness < 0) return FALSE; if (effectiveness > 90 && !gc_t) { - while (gc_margin < (HR-H0)/sizeof(CELL)) + while (gc_margin < (HR-H0)/sizeof(CELL)) gc_margin <<= 1; } } else { @@ -4245,7 +4238,7 @@ call_gc(UInt gc_lim, Int predarity, CELL *current_env, yamop *nextop USES_REGS) } /* * debug for(save_total=1; save_total<=N; ++save_total) - * plwrite(XREGS[save_total],NULL,30,0,0,0); + * plwrite(XREGS[save_total],NULL,30,0,0,0); */ return TRUE; } @@ -4263,7 +4256,7 @@ LeaveGCMode( USES_REGS1 ) } } -int +int Yap_gc(Int predarity, CELL *current_env, yamop *nextop) { int rc; @@ -4271,13 +4264,13 @@ Yap_gc(Int predarity, CELL *current_env, yamop *nextop) return rc; } -int +int Yap_locked_gc(Int predarity, CELL *current_env, yamop *nextop) { CACHE_REGS int res; #if YAPOR_COPY - + fprintf(stderr, "\n\n***** Trying to call the garbage collector in YAPOR/copying ****\n\n\n"); exit( 1 ); #endif @@ -4289,7 +4282,7 @@ Yap_locked_gc(Int predarity, CELL *current_env, yamop *nextop) return res; } -int +int Yap_gcl(UInt gc_lim, Int predarity, CELL *current_env, yamop *nextop) { CACHE_REGS @@ -4306,7 +4299,7 @@ Yap_gcl(UInt gc_lim, Int predarity, CELL *current_env, yamop *nextop) return res; } -int +int Yap_locked_gcl(UInt gc_lim, Int predarity, CELL *current_env, yamop *nextop) { CACHE_REGS @@ -4337,7 +4330,7 @@ p_gc( USES_REGS1 ) return res; } -void +void Yap_init_gc(void) { Yap_InitCPred("$gc", 0, p_gc, 0); diff --git a/C/index.c b/C/index.c index 6fd571344..03e9d41b0 100755 --- a/C/index.c +++ b/C/index.c @@ -633,7 +633,10 @@ type_of_verb(rest,passive). */ -#include "absmi.h" +#include + +#include + #include "YapCompile.h" #if DEBUG #include "yapio.h" @@ -822,7 +825,7 @@ static inline int smaller_or_eq(Term t1, Term t2) { } static inline void clcpy(ClauseDef *d, ClauseDef *s) { - memcpy((void *)d, (void *)s, sizeof(ClauseDef)); + memmove((void *)d, (void *)s, sizeof(ClauseDef)); } static void insort(ClauseDef base[], CELL *p, CELL *q, int my_p) { @@ -2667,7 +2670,7 @@ static ClauseDef *copy_clauses(ClauseDef *max0, ClauseDef *min0, CELL *top, save_machine_regs(); siglongjmp(cint->CompilerBotch, 4); } - memcpy((void *)top, (void *)min0, sz); + memmove((void *)top, (void *)min0, sz); return (ClauseDef *)top; } @@ -2940,13 +2943,15 @@ yamop *Yap_PredIsIndexable(PredEntry *ap, UInt NSlots, yamop *next_pc) { cint.cls = NULL; LOCAL_Error_Size = 0; + if (ap->cs.p_code.NOfClauses < 2) + return NULL; if ((setjres = sigsetjmp(cint.CompilerBotch, 0)) == 3) { restore_machine_regs(); recover_from_failed_susp_on_cls(&cint, 0); if (!Yap_gcl(LOCAL_Error_Size, ap->ArityOfPE + NSlots, ENV, next_pc)) { CleanCls(&cint); Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); - return FAILCODE; + return NULL; } } else if (setjres == 2) { restore_machine_regs(); @@ -2954,7 +2959,7 @@ yamop *Yap_PredIsIndexable(PredEntry *ap, UInt NSlots, yamop *next_pc) { if (!Yap_growheap(FALSE, LOCAL_Error_Size, NULL)) { CleanCls(&cint); Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); - return FAILCODE; + return NULL; } } else if (setjres == 4) { restore_machine_regs(); @@ -2962,7 +2967,7 @@ yamop *Yap_PredIsIndexable(PredEntry *ap, UInt NSlots, yamop *next_pc) { if (!Yap_growtrail(LOCAL_Error_Size, FALSE)) { CleanCls(&cint); Yap_Error(RESOURCE_ERROR_TRAIL, TermNil, LOCAL_ErrorMessage); - return FAILCODE; + return NULL; } } else if (setjres != 0) { restore_machine_regs(); @@ -2970,7 +2975,7 @@ yamop *Yap_PredIsIndexable(PredEntry *ap, UInt NSlots, yamop *next_pc) { if (!Yap_growheap(FALSE, LOCAL_Error_Size, NULL)) { Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); CleanCls(&cint); - return FAILCODE; + return NULL; } } restart_index: @@ -2983,7 +2988,7 @@ restart_index: if (compile_index(&cint) == (UInt)FAILCODE) { Yap_ReleaseCMem(&cint); CleanCls(&cint); - return FAILCODE; + return NULL; } #if DEBUG if (GLOBAL_Option['i' - 'a' + 1]) { diff --git a/C/init.c b/C/init.c index e024e4e50..7fbc7d7db 100755 --- a/C/init.c +++ b/C/init.c @@ -75,8 +75,8 @@ static void SetOp(int, int, char *, Term); static void InitOps(void); static void InitDebug(void); static void CleanBack(PredEntry *, CPredicate, CPredicate, CPredicate); -static void InitStdPreds(void); -static void InitCodes(void); +static void InitStdPreds(struct yap_boot_params *yapi); +static void InitCodes(struct yap_boot_params *yapi); static void InitVersion(void); void exit(int); static void InitWorker(int wid); @@ -165,8 +165,10 @@ The following is the list of the declarations of the predefined operators: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :-op(1200,fx,['?-', ':-']). :-op(1200,xfx,[':-','-->']). -:-op(1150,fx,[block,dynamic,mode,public,multifile,meta_predicate, - sequential,table,initialization]). +:-op(1150,fx,[block, + discontiguous,dynamic, + initialization,mode,multifile,meta_predicate, + public,sequential,table]). :-op(1100,xfy,[';','|']). :-op(1050,xfy,->). :-op(1000,xfy,','). @@ -299,7 +301,7 @@ bool Yap_dup_op(OpEntry *op, ModEntry *she) { OpEntry *info = (OpEntry *)Yap_AllocAtomSpace(sizeof(OpEntry)); if (!info) return false; - memcpy(info, op, sizeof(OpEntry)); + memmove(info, op, sizeof(OpEntry)); info->NextForME = she->OpForME; she->OpForME = info; info->OpModule = MkAtomTerm(she->AtomOfME); @@ -980,12 +982,14 @@ void Yap_InitCPredBack_(const char *Name, arity_t Arity, arity_t Extra, } } -static void InitStdPreds(void) { +static void InitStdPreds(struct yap_boot_params *yapi) +{ + CurrentModule = PROLOG_MODULE; Yap_InitCPreds(); Yap_InitBackCPreds(); BACKUP_MACHINE_REGS(); Yap_InitFlags(false); - Yap_InitPlIO(); + Yap_InitPlIO(yapi); #if HAVE_MPE Yap_InitMPE(); #endif @@ -1159,7 +1163,7 @@ void Yap_init_yapor_workers(void) { worker_id = proc; Yap_remap_yapor_memory(); LOCAL = REMOTE(worker_id); - memcpy(REMOTE(worker_id), REMOTE(0), sizeof(struct worker_local)); + memmove(REMOTE(worker_id), REMOTE(0), sizeof(struct worker_local)); InitWorker(worker_id); break; } else @@ -1268,7 +1272,8 @@ struct worker_local *Yap_local; struct worker_local Yap_local; #endif -static void InitCodes(void) { +static void InitCodes(struct yap_boot_params *yapi) +{ CACHE_REGS #if THREADS int wid; @@ -1315,9 +1320,11 @@ const char *Yap_version(void) { return RepAtom(AtomOfTerm(t))->StrOfAE; } -void Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, +void Yap_InitWorkspace(struct yap_boot_params *yapi, + UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_size, int n_workers, int sch_loop, - int delay_load) { + int delay_load) +{ CACHE_REGS /* initialize system stuff */ @@ -1399,7 +1406,7 @@ void Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, #else Yap_InitAbsmi(); #endif - InitCodes(); + InitCodes(yapi); InitOps(); InitDebug(); InitVersion(); @@ -1428,8 +1435,8 @@ void Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, GLOBAL_AllowLocalExpansion = true; GLOBAL_AllowTrailExpansion = true; Yap_InitExStacks(0, Trail, Stack); - Yap_InitYaamRegs(0); - InitStdPreds(); + Yap_InitYaamRegs(0, true); + InitStdPreds(yapi); /* make sure tmp area is available */ { Yap_ReleasePreAllocCodeSpace(Yap_PreAllocCodeSpace()); } } @@ -1472,7 +1479,7 @@ void Yap_exit(int value) { run_halt_hooks(value); Yap_ShutdownLoadForeign(); } - Yap_CloseStreams(false); + Yap_CloseStreams(); Yap_CloseReadline(); #if USE_SYSTEM_MALLOC #endif diff --git a/C/inlines.c b/C/inlines.c index edc2b2c8b..49ae75e81 100644 --- a/C/inlines.c +++ b/C/inlines.c @@ -21,10 +21,11 @@ @file inlines.c + @{ + @defgroup YAP_Inlines Inlined Tests nad Ter Manipulation @ingroup builtins - @{ */ @@ -51,6 +52,57 @@ static Int p_dif( USES_REGS1 ); static Int p_eq( USES_REGS1 ); static Int p_arg( USES_REGS1 ); static Int p_functor( USES_REGS1 ); +static Int p_fail( USES_REGS1 ); +static Int p_true( USES_REGS1 ); + +/** @pred fail is iso + +Always fails. Defined as if by: + + ~~~~~ + fail :- 2=1. + ~~~~~ +*/ + +/** @pred false is iso + +The same as fail. Defined as if by: + + ~~~~~ + false :- 2=1. + ~~~~~ +*/ + +static Int p_fail( USES_REGS1 ) +{ + return false; +} + +/** @pred true is iso +Succeed. + +Succeeds once. Defined as if by: + + ~~~~~ + true :- true. + ~~~~~ +*/ + +/** @pred otherwise is iso +Succeed. + +Succeeds once. Defined as if by: + + ~~~~~ + otherwise. + ~~~~~ +*/ + + +static Int p_true( USES_REGS1 ) +{ + return true; +} /** @pred atom( _T_) is iso @@ -1150,6 +1202,11 @@ cont_genarg( USES_REGS1 ) CurrentModule = ARG_MODULE; Yap_InitCPredBack("genarg", 3, 3, genarg, cont_genarg,SafePredFlag); CurrentModule = cm; - } + Yap_InitCPred("true", 0, p_true, SafePredFlag); + Yap_InitCPred("otherwise", 0, p_true, SafePredFlag); + Yap_InitCPred("false", 0, p_fail, SafePredFlag); + Yap_InitCPred("fail", 0, p_fail, SafePredFlag); +} +// @} diff --git a/C/load_dl.c b/C/load_dl.c index af5ed6f00..c0989fde4 100755 --- a/C/load_dl.c +++ b/C/load_dl.c @@ -1,17 +1,17 @@ /************************************************************************* -* * -* YAP Prolog * -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * -* * -************************************************************************** -* * -* File: load_dl.c * -* comments: dl based dynamic loaderr of external routines * -* tested on i486-linuxelf * -*************************************************************************/ + * * + * YAP Prolog * + * * + * Yap Prolog was developed at NCCUP - Universidade do Porto * + * * + * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * + * * + ************************************************************************** + * * + * File: load_dl.c * + * comments: dl based dynamic loaderr of external routines * + * tested on i486-linuxelf * + *************************************************************************/ #include "Yap.h" #include "YapHeap.h" @@ -47,7 +47,7 @@ int Yap_CallFunctionByName(const char *thing_string) { | RTLD_NOLOAD #endif #endif - ); + ); // you could do RTLD_NOW as well. shouldn't matter if (!handle) { CACHE_REGS @@ -64,7 +64,7 @@ int Yap_CallFunctionByName(const char *thing_string) { /* * YAP_FindExecutable(argv[0]) should be called on yap initialization to * locate the executable of Yap -*/ + */ char *Yap_FindExecutable(void) { #if HAVE_GETEXECNAME // Solaris @@ -76,11 +76,11 @@ char *Yap_FindExecutable(void) { if (!_NSGetExecutablePath(buf, &size)) { buf = realloc(buf, size + 1); return buf; - } return "yap"; + } + return "yap"; #elif defined(__linux__) - enum { BUFFERSIZE = 1024 }; - char *buf = malloc(BUFFERSIZE); - ssize_t len = readlink("/proc/self/exe", buf, sizeof(buf) - 1); + char *buf = malloc(YAP_FILENAME_MAX); + ssize_t len = readlink("/proc/self/exe", buf, YAP_FILENAME_MAX - 1); if (len != -1) { buf[len] = '\0'; @@ -158,74 +158,55 @@ int Yap_CloseForeignFile(void *handle) { /* * LoadForeign(ofiles,libs,proc_name,init_proc) dynamically loads foreign * code files and libraries and locates an initialization routine -*/ -static Int LoadForeign(StringList ofiles, StringList libs, char *proc_name, + */ +static Int LoadForeign(StringList + ofiles, StringList libs, char *proc_name, YapInitProc *init_proc) { CACHE_REGS + LOCAL_ErrorMessage = NULL; while (libs) { const char *file = AtomName(libs->name); - if (!Yap_findFile(file, NULL, NULL, LOCAL_FileNameBuf, true, YAP_OBJ, true, true)) { - /* use LD_LIBRARY_PATH */ - strncpy(LOCAL_FileNameBuf, (char *)AtomName(libs->name), - YAP_FILENAME_MAX); - } - #ifdef __osf__ if ((libs->handle = dlopen(LOCAL_FileNameBuf, RTLD_LAZY)) == NULL) #else - if ((libs->handle = dlopen(LOCAL_FileNameBuf, RTLD_LAZY | RTLD_GLOBAL)) == + if ((libs->handle = dlopen(file, RTLD_LAZY | RTLD_GLOBAL)) == NULL) #endif { - LOCAL_ErrorMessage = malloc(MAX_ERROR_MSG_SIZE); - strcpy(LOCAL_ErrorMessage, dlerror()); - return LOAD_FAILLED; + if (LOCAL_ErrorMessage == NULL) { + LOCAL_ErrorMessage = malloc(MAX_ERROR_MSG_SIZE); + strcpy(LOCAL_ErrorMessage, dlerror()); + } } libs = libs->next; } while (ofiles) { - void *handle; /* load libraries first so that their symbols are available to other routines */ - - /* dlopen wants to follow the LD_CONFIG_PATH */ const char *file = AtomName(ofiles->name); - if (!Yap_findFile(file, NULL, NULL, LOCAL_FileNameBuf, true, YAP_OBJ, true, true)) { - LOCAL_ErrorMessage = malloc(MAX_ERROR_MSG_SIZE); - strcpy(LOCAL_ErrorMessage, - "%% Trying to open unexisting file in LoadForeign"); - return LOAD_FAILLED; - } -#ifdef __osf__ - if ((handle = dlopen(LOCAL_FileNameBuf, RTLD_LAZY)) == 0) -#else - if ((handle = dlopen(LOCAL_FileNameBuf, RTLD_LAZY | RTLD_GLOBAL)) == 0) -#endif + + if ((ofiles->handle = dlopen(file, RTLD_LAZY | RTLD_GLOBAL)) == + NULL) { - fprintf(stderr, "dlopen of image %s failed: %s\n", LOCAL_FileNameBuf, - dlerror()); - /* strcpy(LOCAL_ErrorSay,dlerror());*/ - return LOAD_FAILLED; + if (LOCAL_ErrorMessage == NULL) { + LOCAL_ErrorMessage = malloc(MAX_ERROR_MSG_SIZE); + fprintf(stderr, "dlopen of image %s failed: %s\n", LOCAL_FileNameBuf, + dlerror()); + } } - ofiles->handle = handle; - - if (proc_name && !*init_proc) - *init_proc = (YapInitProc)dlsym(handle, proc_name); + if (ofiles->handle && proc_name && !*init_proc) + *init_proc = (YapInitProc)dlsym(ofiles->handle, proc_name); ofiles = ofiles->next; } - if (!*init_proc) { - LOCAL_ErrorMessage = malloc(MAX_ERROR_MSG_SIZE); - snprintf(LOCAL_ErrorMessage, - "Could not locate routine %s in %s: %s\n", - proc_name, LOCAL_FileNameBuf, dlerror()); - fprintf(stderr, - "Could not locate routine %s in %s: %s\n", - proc_name, LOCAL_FileNameBuf, dlerror()); + if (!*init_proc && LOCAL_ErrorMessage == NULL) { + char *buf = malloc(1058); + snprintf(buf, 1058 - 1, "Could not locate routine %s in %s: %s\n", + proc_name, LOCAL_FileNameBuf, dlerror()); return LOAD_FAILLED; } diff --git a/C/load_foreign.c b/C/load_foreign.c index aeb2c9351..ed18c3a4a 100644 --- a/C/load_foreign.c +++ b/C/load_foreign.c @@ -13,15 +13,14 @@ * * *************************************************************************/ #ifdef SCCS -static char SccsId[] = "%W% %G%.2"; +static char SccsId[] = "%W% %G%.2"; #endif - #include "Yap.h" -#include "Yatom.h" #include "YapHeap.h" -#include "yapio.h" #include "YapText.h" +#include "Yatom.h" +#include "yapio.h" #include #if HAVE_STRING_H #include @@ -35,11 +34,9 @@ static char SccsId[] = "%W% %G%.2"; #endif #endif -Int p_load_foreign( USES_REGS1 ); +Int p_load_foreign(USES_REGS1); -Int -p_load_foreign( USES_REGS1 ) -{ +Int p_load_foreign(USES_REGS1) { StringList ofiles = NULL; StringList libs = NULL; char *InitProcName; @@ -48,18 +45,22 @@ p_load_foreign( USES_REGS1 ) StringList new; bool returncode = FALSE; yhandle_t CurSlot = Yap_StartSlots(); +#if __ANDROID__ +return true; +#endif // Yap_DebugPlWrite(ARG1); printf("%s\n", " \n"); - //Yap_DebugPlWrite(ARG2); printf("%s\n", " \n"); - //ap_DebugPlWrite(ARG3); printf("%s\n", " \n"); + // Yap_DebugPlWrite(ARG2); printf("%s\n", " \n"); + // ap_DebugPlWrite(ARG3); printf("%s\n", " \n"); /* collect the list of object files */ t = Deref(ARG1); - while(1) { - if (t == TermNil) break; + while (1) { + if (t == TermNil) + break; t1 = HeadOfTerm(t); t = TailOfTerm(t); - new = (StringList) Yap_AllocCodeSpace(sizeof(StringListItem)); + new = (StringList)Yap_AllocCodeSpace(sizeof(StringListItem)); new->next = ofiles; new->name = AtomOfTerm(t1); ofiles = new; @@ -67,11 +68,12 @@ p_load_foreign( USES_REGS1 ) /* collect the list of library files */ t = Deref(ARG2); - while(1) { - if (t == TermNil) break; + while (1) { + if (t == TermNil) + break; t1 = HeadOfTerm(t); t = TailOfTerm(t); - new = (StringList) Yap_AllocCodeSpace(sizeof(StringListItem)); + new = (StringList)Yap_AllocCodeSpace(sizeof(StringListItem)); new->next = libs; new->name = AtomOfTerm(t1); libs = new; @@ -82,17 +84,30 @@ p_load_foreign( USES_REGS1 ) InitProcName = (char *)RepAtom(AtomOfTerm(t1))->StrOfAE; // verify if it was waiting for initialization - if (Yap_LateInit( InitProcName ) ){ - returncode = true; - } else - /* call the OS specific function for dynamic loading */ - if(Yap_LoadForeign(ofiles,libs,InitProcName,&InitProc)==LOAD_SUCCEEDED) { - Yap_StartSlots( ); + if (Yap_LateInit(InitProcName)) { + returncode = true; + } else + /* call the OS specific function for dynamic loading */ + if (Yap_LoadForeign(ofiles, libs, InitProcName, &InitProc) == + LOAD_SUCCEEDED) { + if (InitProc == NULL) { + char *f; + if (ofiles) { + f = RepAtom(ofiles->name)->StrOfAE; + } else { + f = RepAtom(libs->name)->StrOfAE; + } + Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, ARG3, + "Foreign module %s does not have initialization function %s", f, + InitProcName); + return false; + } + Yap_StartSlots(); (*InitProc)(); Yap_CloseSlots(CurSlot); returncode = true; } - + /* I should recover space if load foreign fails */ if (returncode == TRUE) { ForeignObj *f_code = (ForeignObj *)Yap_AllocCodeSpace(sizeof(ForeignObj)); @@ -117,61 +132,60 @@ p_load_foreign( USES_REGS1 ) return returncode; } -static Int -p_open_shared_object( USES_REGS1 ) { +static Int p_open_shared_object(USES_REGS1) { Term t = Deref(ARG1); Term tflags = Deref(ARG2); char *s; void *handle; if (IsVarTerm(t)) { - Yap_Error(INSTANTIATION_ERROR,t,"open_shared_object/3"); + Yap_Error(INSTANTIATION_ERROR, t, "open_shared_object/3"); return FALSE; - } + } if (!IsAtomTerm(t)) { - Yap_Error(TYPE_ERROR_ATOM,t,"open_shared_object/3"); + Yap_Error(TYPE_ERROR_ATOM, t, "open_shared_object/3"); return FALSE; } - + if (IsVarTerm(tflags)) { - Yap_Error(INSTANTIATION_ERROR,tflags,"open_shared_object/3"); - return FALSE; - } - if (!IsIntegerTerm(tflags)) { - Yap_Error(TYPE_ERROR_INTEGER,tflags,"open_shared_object/3"); + Yap_Error(INSTANTIATION_ERROR, tflags, "open_shared_object/3"); return FALSE; } - + if (!IsIntegerTerm(tflags)) { + Yap_Error(TYPE_ERROR_INTEGER, tflags, "open_shared_object/3"); + return FALSE; + } + s = (char *)RepAtom(AtomOfTerm(t))->StrOfAE; - if ((handle = Yap_LoadForeignFile(s, IntegerOfTerm(tflags)))==NULL) { - Yap_Error(EXISTENCE_ERROR_SOURCE_SINK,t,"open_shared_object_failed for %s" - " with %s\n", s, LOCAL_ErrorMessage); + if ((handle = Yap_LoadForeignFile(s, IntegerOfTerm(tflags))) == NULL) { + Yap_Error(EXISTENCE_ERROR_SOURCE_SINK, t, + "open_shared_object_failed for %s" + " with %s\n", + s, LOCAL_ErrorMessage); return FALSE; } else { - return Yap_unify(MkIntegerTerm((Int)handle),ARG3); + return Yap_unify(MkIntegerTerm((Int)handle), ARG3); } } -static Int -p_close_shared_object( USES_REGS1 ) { +static Int p_close_shared_object(USES_REGS1) { Term t = Deref(ARG1); void *handle; if (IsVarTerm(t)) { - Yap_Error(INSTANTIATION_ERROR,t,"close_shared_object/1"); + Yap_Error(INSTANTIATION_ERROR, t, "close_shared_object/1"); return FALSE; - } + } if (!IsIntegerTerm(t)) { - Yap_Error(TYPE_ERROR_INTEGER,t,"close_shared_object/1"); + Yap_Error(TYPE_ERROR_INTEGER, t, "close_shared_object/1"); return FALSE; } handle = (char *)IntegerOfTerm(t); - + return Yap_CloseForeignFile(handle); } -static Int -p_call_shared_object_function( USES_REGS1 ) { +static Int p_call_shared_object_function(USES_REGS1) { Term t = Deref(ARG1); Term tfunc = Deref(ARG2); Term tmod; @@ -180,51 +194,51 @@ p_call_shared_object_function( USES_REGS1 ) { Int res; tmod = CurrentModule; - restart: +restart: if (IsVarTerm(t)) { - Yap_Error(INSTANTIATION_ERROR,t,"call_shared_object_function/2"); + Yap_Error(INSTANTIATION_ERROR, t, "call_shared_object_function/2"); return FALSE; } else if (IsApplTerm(t)) { - Functor fun = FunctorOfTerm(t); + Functor fun = FunctorOfTerm(t); if (fun == FunctorModule) { tmod = ArgOfTerm(1, t); - if (IsVarTerm(tmod) ) { - Yap_Error(INSTANTIATION_ERROR,t,"call_shared_object_function/2"); - return FALSE; + if (IsVarTerm(tmod)) { + Yap_Error(INSTANTIATION_ERROR, t, "call_shared_object_function/2"); + return FALSE; } - if (!IsAtomTerm(tmod) ) { - Yap_Error(TYPE_ERROR_ATOM,ARG1,"call_shared_object_function/2"); - return FALSE; + if (!IsAtomTerm(tmod)) { + Yap_Error(TYPE_ERROR_ATOM, ARG1, "call_shared_object_function/2"); + return FALSE; } t = ArgOfTerm(2, t); goto restart; } } else if (!IsIntegerTerm(t)) { - Yap_Error(TYPE_ERROR_INTEGER,t,"call_shared_object_function/2"); + Yap_Error(TYPE_ERROR_INTEGER, t, "call_shared_object_function/2"); return FALSE; } handle = (void *)IntegerOfTerm(t); if (IsVarTerm(tfunc)) { - Yap_Error(INSTANTIATION_ERROR,t,"call_shared_object_function/2"); + Yap_Error(INSTANTIATION_ERROR, t, "call_shared_object_function/2"); return FALSE; - } + } if (!IsAtomTerm(tfunc)) { - Yap_Error(TYPE_ERROR_ATOM,t,"call_shared_object_function/2/3"); + Yap_Error(TYPE_ERROR_ATOM, t, "call_shared_object_function/2/3"); return FALSE; } CurrentModule = tmod; - res = Yap_CallForeignFile(handle, (char *)RepAtom(AtomOfTerm(tfunc))->StrOfAE); + res = + Yap_CallForeignFile(handle, (char *)RepAtom(AtomOfTerm(tfunc))->StrOfAE); CurrentModule = OldCurrentModule; return res; } -static Int -p_obj_suffix( USES_REGS1 ) { - return Yap_unify(Yap_CharsToListOfCodes(SO_EXT, ENC_ISO_LATIN1 PASS_REGS),ARG1); +static Int p_obj_suffix(USES_REGS1) { + return Yap_unify(Yap_CharsToListOfCodes(SO_EXT, ENC_ISO_LATIN1 PASS_REGS), + ARG1); } -static Int -p_open_shared_objects( USES_REGS1 ) { +static Int p_open_shared_objects(USES_REGS1) { #ifdef SO_EXT return TRUE; #else @@ -232,26 +246,25 @@ p_open_shared_objects( USES_REGS1 ) { #endif } -void -Yap_InitLoadForeign( void ) -{ - Yap_InitCPred("$load_foreign_files", 3, p_load_foreign, SafePredFlag|SyncPredFlag); +void Yap_InitLoadForeign(void) { + Yap_InitCPred("$load_foreign_files", 3, p_load_foreign, + SafePredFlag | SyncPredFlag); Yap_InitCPred("$open_shared_objects", 0, p_open_shared_objects, SafePredFlag); Yap_InitCPred("$open_shared_object", 3, p_open_shared_object, SyncPredFlag); - Yap_InitCPred("close_shared_object", 1, p_close_shared_object, SyncPredFlag|SafePredFlag); -/** @pred close_shared_object(+ _Handle_) + Yap_InitCPred("close_shared_object", 1, p_close_shared_object, + SyncPredFlag | SafePredFlag); + /** @pred close_shared_object(+ _Handle_) -Detach the shared object identified by _Handle_. + Detach the shared object identified by _Handle_. - -*/ - Yap_InitCPred("$call_shared_object_function", 2, p_call_shared_object_function, SyncPredFlag); + + */ + Yap_InitCPred("$call_shared_object_function", 2, + p_call_shared_object_function, SyncPredFlag); Yap_InitCPred("$obj_suffix", 1, p_obj_suffix, SafePredFlag); } -void -Yap_ReOpenLoadForeign(void) -{ +void Yap_ReOpenLoadForeign(void) { CACHE_REGS ForeignObj *f_code = ForeignCodeLoaded; Term OldModule = CurrentModule; @@ -260,19 +273,18 @@ Yap_ReOpenLoadForeign(void) YapInitProc InitProc = NULL; CurrentModule = f_code->module; - if(Yap_ReLoadForeign(f_code->objs,f_code->libs,(char *)RepAtom(f_code->f)->StrOfAE,&InitProc)==LOAD_SUCCEEDED) { + if (Yap_ReLoadForeign(f_code->objs, f_code->libs, + (char *)RepAtom(f_code->f)->StrOfAE, + &InitProc) == LOAD_SUCCEEDED) { if (InitProc) - (*InitProc)(); + (*InitProc)(); } f_code = f_code->next; } CurrentModule = OldModule; } - - - - - - - +X_API bool load_none(void) +{ + return true; +} diff --git a/C/meta_absmi_insts.h b/C/meta_absmi_insts.h index f57546803..7a9bbe541 100644 --- a/C/meta_absmi_insts.h +++ b/C/meta_absmi_insts.h @@ -116,7 +116,7 @@ } pen = RepPredProp(PredPropByFunc(f, mod)); execute_pred_f: - if (pen->PredFlags & MetaPredFlag) { + if (pen->PredFlags & (MetaPredFlag|UndefPredFlag)) { /* just strip all of M:G */ if (f == FunctorModule) { Term tmod = ArgOfTerm(1,d0); @@ -242,7 +242,7 @@ if (DEPTH <= MkIntTerm(1)) {/* I assume Module==0 is primitives */ if (pen->ModuleOfPred) { if (DEPTH == MkIntTerm(0)) { - FAIL(); + FAIL(); } else { DEPTH = RESET_DEPTH(); } diff --git a/C/modules.c b/C/modules.c index 3aa974b07..7a55aacfd 100644 --- a/C/modules.c +++ b/C/modules.c @@ -14,6 +14,8 @@ * comments: module support * * * *************************************************************************/ + + #ifdef SCCSLookupSystemModule static char SccsId[] = "%W% %G%"; #endif @@ -50,9 +52,11 @@ static ModEntry *initMod(AtomEntry *toname, AtomEntry *ae) { INIT_RWLOCK(n->ModRWLock); n->KindOfPE = ModProperty; n->PredForME = NULL; + n->OpForME = NULL; n->NextME = CurrentModules; CurrentModules = n; n->AtomOfME = ae; + n->NextOfPE = NULL; n->OwnerFile = Yap_ConsultingFile(PASS_REGS1); AddPropToAtom(ae, (PropEntry *)n); Yap_setModuleFlags(n, parent); @@ -257,7 +261,7 @@ static Int change_module(USES_REGS1) { /* $change_module(N) */ } static Int current_module1(USES_REGS1) { /* $current_module(Old) - */ + */ if (CurrentModule) return Yap_unify_constant(ARG1, CurrentModule); return Yap_unify_constant(ARG1, TermProlog); @@ -372,57 +376,58 @@ static Int new_system_module(USES_REGS1) { } static Int strip_module(USES_REGS1) { - Term t1 = Deref(ARG1), tmod = CurrentModule; - if (tmod == PROLOG_MODULE) { - tmod = TermProlog; - } - t1 = Yap_StripModule(t1, &tmod); - if (!t1) { - Yap_Error(TYPE_ERROR_CALLABLE, t1, "trying to obtain module"); - return FALSE; - } - return Yap_unify(ARG3, t1) && Yap_unify(ARG2, tmod); + Term t1 = Deref(ARG1), tmod = CurrentModule; + if (tmod == PROLOG_MODULE) { + tmod = TermProlog; + } + t1 = Yap_StripModule(t1, &tmod); + if (!t1) { + Yap_Error(TYPE_ERROR_CALLABLE, t1, "trying to obtain module"); + return FALSE; + } + return Yap_unify(ARG3, t1) && Yap_unify(ARG2, tmod); } static Int yap_strip_clause(USES_REGS1) { - Functor f; - Term t1 = Deref(ARG1), tmod = LOCAL_SourceModule; - if (tmod == PROLOG_MODULE) { - tmod = TermProlog; + Term t1 = Deref(ARG1), tmod = LOCAL_SourceModule; + if (tmod == PROLOG_MODULE) { + tmod = TermProlog; + } + t1 = Yap_StripModule(t1, &tmod); + if (IsVarTerm(t1) || IsVarTerm(tmod)) { + Yap_Error(INSTANTIATION_ERROR, t1, "trying to obtain module"); + return false; + } else if (IsApplTerm(t1)) { + Functor f = FunctorOfTerm(t1); + if (IsExtensionFunctor(f)) { + Yap_Error(TYPE_ERROR_CALLABLE, t1, "trying to obtain module"); + return false; } - t1 = Yap_StripModule(t1, &tmod); - if (IsVarTerm(t1)) { + if (f == FunctorAssert || f == FunctorDoubleArrow) { + Term thmod = tmod; + Term th = ArgOfTerm(1, t1); + th = Yap_StripModule(th, &thmod); + if (IsVarTerm(th)) { Yap_Error(INSTANTIATION_ERROR, t1, "trying to obtain module"); return false; - } else if (IsVarTerm(tmod)) { - Yap_Error(INSTANTIATION_ERROR, tmod, "trying to obtain module"); + } else if (IsVarTerm(thmod)) { + Yap_Error(INSTANTIATION_ERROR, thmod, "trying to obtain module"); return false; - } else if (IsIntTerm(t1) || (IsApplTerm(t1) && IsExtensionFunctor((f = FunctorOfTerm(t1))))) { + } else if (IsIntTerm(th) || + (IsApplTerm(th) && IsExtensionFunctor(FunctorOfTerm(t1)))) { + Yap_Error(TYPE_ERROR_CALLABLE, t1, "trying to obtain module"); + return false; + } else if (!IsAtomTerm(thmod)) { + Yap_Error(TYPE_ERROR_ATOM, thmod, "trying to obtain module"); + return false; + } + } + + } else if (IsIntTerm(t1) || IsIntTerm(tmod)) { Yap_Error(TYPE_ERROR_CALLABLE, t1, "trying to obtain module"); return false; - } else if (!IsAtomTerm(tmod)) { - Yap_Error(TYPE_ERROR_ATOM, tmod, "trying to obtain module"); - return false; - } - if (f == FunctorAssert || f == FunctorDoubleArrow) { - Term thmod = tmod; - Term th = ArgOfTerm(1, t1); - th = Yap_StripModule(th, &thmod); - if (IsVarTerm(th)) { - Yap_Error(INSTANTIATION_ERROR, t1, "trying to obtain module"); - return false; - } else if (IsVarTerm(thmod)) { - Yap_Error(INSTANTIATION_ERROR, thmod, "trying to obtain module"); - return false; - } else if (IsIntTerm(th) || (IsApplTerm(th) && IsExtensionFunctor(FunctorOfTerm(t1)))) { - Yap_Error(TYPE_ERROR_CALLABLE, t1, "trying to obtain module"); - return false; - }else if (!IsAtomTerm(thmod)) { - Yap_Error(TYPE_ERROR_ATOM, thmod, "trying to obtain module"); - return false; - } - } - return Yap_unify(ARG3, t1) && Yap_unify(ARG2, tmod); + } + return Yap_unify(ARG3, t1) && Yap_unify(ARG2, tmod); } Term Yap_YapStripModule(Term t, Term *modp) { @@ -502,7 +507,7 @@ static Int context_module(USES_REGS1) { * @param Mod is the current text source module. * * : _Mod_ is the current read-in or source module. -*/ + */ static Int source_module(USES_REGS1) { if (LOCAL_SourceModule == PROLOG_MODULE) { return Yap_unify(ARG1, TermProlog); @@ -516,7 +521,7 @@ static Int source_module(USES_REGS1) { * @param Mod is the current text source module. * * : _Mod_ is the current read-in or source module. -*/ + */ static Int current_source_module(USES_REGS1) { Term t; if (LOCAL_SourceModule == PROLOG_MODULE) { @@ -607,14 +612,15 @@ void Yap_InitModulesC(void) { SafePredFlag | SyncPredFlag); Yap_InitCPred("$change_module", 1, change_module, SafePredFlag | SyncPredFlag); - Yap_InitCPred("strip_module", 3, strip_module, SafePredFlag | SyncPredFlag); - Yap_InitCPred("$yap_strip_module", 3, yap_strip_module, SafePredFlag | SyncPredFlag); + Yap_InitCPred("strip_module", 3, strip_module, SafePredFlag | SyncPredFlag); + Yap_InitCPred("$yap_strip_module", 3, yap_strip_module, + SafePredFlag | SyncPredFlag); Yap_InitCPred("source_module", 1, source_module, SafePredFlag | SyncPredFlag); Yap_InitCPred("current_source_module", 2, current_source_module, SafePredFlag | SyncPredFlag); - Yap_InitCPred("$yap_strip_clause", 3, yap_strip_clause, - SafePredFlag | SyncPredFlag); - Yap_InitCPred("context_module", 1, context_module, 0); + Yap_InitCPred("$yap_strip_clause", 3, yap_strip_clause, + SafePredFlag | SyncPredFlag); + Yap_InitCPred("context_module", 1, context_module, 0); Yap_InitCPred("$is_system_module", 1, is_system_module, SafePredFlag); Yap_InitCPred("$copy_operators", 2, copy_operators, 0); Yap_InitCPred("new_system_module", 1, new_system_module, SafePredFlag); @@ -626,6 +632,7 @@ void Yap_InitModulesC(void) { void Yap_InitModules(void) { CACHE_REGS + CurrentModules = NULL; LookupSystemModule(MkAtomTerm(AtomProlog)); LOCAL_SourceModule = MkAtomTerm(AtomProlog); LookupModule(USER_MODULE); diff --git a/C/parser.c b/C/parser.c index 1ae196775..b83ecb453 100755 --- a/C/parser.c +++ b/C/parser.c @@ -1,144 +1,29 @@ /************************************************************************* -* * -* YAP Prolog * -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * -* * -************************************************************************** -* * -* File: parser.c * -* Last rev: * -* mods: * -* comments: Prolog's parser * -* * -*************************************************************************/ + * * + * YAP Prolog * + * * + * Yap Prolog was developed at NCCUP - Universidade do Porto * + * * + * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * + * * + ************************************************************************** + * * + * File: parser.c * + * Last rev: * + * mods: * + * comments: Prolog's parser * + * * + *************************************************************************/ #ifdef SCCS static char SccsId[] = "%W% %G%"; #endif -/** - -@addtogroup YAPSyntax - -describe the syntax for Prolog terms. In a second level we describe -the \a tokens from which Prolog \a terms are -built. - -@defgroup Formal_Syntax Syntax of Terms -@ingroup YAPSyntax -@{ - -Below, we describe the syntax of YAP terms from the different -classes of tokens defined above. The formalism used will be BNF, -extended where necessary with attributes denoting integer precedence or -operator type. - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - term -----> subterm(1200) end_of_term_marker - - subterm(N) ----> term(M) [M <= N] - - term(N) ----> op(N, fx) subterm(N-1) - | op(N, fy) subterm(N) - | subterm(N-1) op(N, xfx) subterm(N-1) - | subterm(N-1) op(N, xfy) subterm(N) - | subterm(N) op(N, yfx) subterm(N-1) - | subterm(N-1) op(N, xf) - | subterm(N) op(N, yf) - - term(0) ----> atom '(' arguments ')' - | '(' subterm(1200) ')' - | '{' subterm(1200) '}' - | list - | string - | number - | atom - | variable - - arguments ----> subterm(999) - | subterm(999) ',' arguments - - list ----> '[]' - | '[' list_expr ']' - - list_expr ----> subterm(999) - | subterm(999) list_tail - - list_tail ----> ',' list_expr - | ',..' subterm(999) - | '|' subterm(999) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Notes: - - + \a op(N,T) denotes an atom which has been previously declared with type - \a T and base precedence \a N. - - + Since ',' is itself a pre-declared operator with type \a xfy and - precedence 1000, is \a subterm starts with a '(', \a op must be - followed by a space to avoid ambiguity with the case of a functor - followed by arguments, e.g.: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ (a,b) [the same as '+'(','(a,b)) of arity one] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - versus - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+(a,b) [the same as '+'(a,b) of arity two] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - + -In the first rule for term(0) no blank space should exist between -\a atom and '('. - - + -Each term to be read by the YAP parser must end with a single -dot, followed by a blank (in the sense mentioned in the previous -paragraph). When a name consisting of a single dot could be taken for -the end of term marker, the ambiguity should be avoided by surrounding the -dot with single quotes. - -@} - -*/ - -/* - * Description: - * - * parser: produces a prolog term from an array of tokens - * - * parser usage: the parser takes its input from an array of token descriptions - * addressed by the global variable 'tokptr' and produces a Term as result. A - * macro 'NextToken' should be defined in 'yap.h' for advancing 'tokptr' from - * one token to the next. In the distributed version this macro also updates - * a variable named 'toktide' for keeping track of how far the parser went - * before failling with a syntax error. The parser should be invoked with - * 'tokptr' pointing to the first token. The last token should have type - * 'eot_tok'. The parser return either a Term. Syntactic errors are signaled - * by a return value 0. The parser builds new terms on the 'global stack' and - * also uses an auxiliary stack pointed to by 'AuxSp'. In the distributed - * version this auxiliary stack is assumed to grow downwards. This - * assumption, however, is only relevant to routine 'ParseArgs', and to the - * variable toktide. conclusion: set tokptr pointing to first token set AuxSp - * Call Parse - * - * VSC: Working whithout known bugs in 87/4/6 - * - * LD: -I or +I evaluated by parser 87/4/28 - * - * LD: parser extended 87/4/28 - * - */ #include "Yap.h" +#include "YapEval.h" #include "YapHeap.h" #include "YapText.h" #include "Yatom.h" -#include "YapEval.h" #include "yapio.h" /* stuff we want to use in standard YAP code */ #include "iopreds.h" @@ -157,7 +42,9 @@ dot with single quotes. /* weak backtraking mechanism based on long_jump */ -typedef struct jmp_buff_struct { sigjmp_buf JmpBuff; } JMPBUFF; +typedef struct jmp_buff_struct { + sigjmp_buf JmpBuff; +} JMPBUFF; static void GNextToken(CACHE_TYPE1); static void checkfor(Term, JMPBUFF *, encoding_t CACHE_TYPE); @@ -165,19 +52,20 @@ static Term ParseArgs(Atom, Term, JMPBUFF *, Term, encoding_t, Term CACHE_TYPE); static Term ParseList(JMPBUFF *, encoding_t, Term CACHE_TYPE); static Term ParseTerm(int, JMPBUFF *, encoding_t, Term CACHE_TYPE); -extern Term Yap_tokRep(void* tokptr); -extern const char * Yap_tokText(void *tokptr); +extern Term Yap_tokRep(void *tokptr); +extern const char *Yap_tokText(void *tokptr); static void syntax_msg(const char *msg, ...) { CACHE_REGS va_list ap; if (!LOCAL_ErrorMessage || (LOCAL_Error_TYPE == SYNTAX_ERROR && - LOCAL_ActiveError->prologParserLine < LOCAL_tokptr->TokPos)) { + LOCAL_tokptr->TokPos < LOCAL_ActiveError->parserPos)) { if (!LOCAL_ErrorMessage) { - LOCAL_ErrorMessage = malloc(1024 + 1); + LOCAL_ErrorMessage = malloc(MAX_ERROR_MSG_SIZE + 1); } - LOCAL_ActiveError->prologParserLine = LOCAL_tokptr->TokPos; + LOCAL_ActiveError->parserLine = LOCAL_tokptr->TokLine; + LOCAL_ActiveError->parserPos = LOCAL_tokptr->TokPos; va_start(ap, msg); vsnprintf(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, msg, ap); va_end(ap); @@ -226,7 +114,7 @@ static void syntax_msg(const char *msg, ...) { #define FAIL siglongjmp(FailBuff->JmpBuff, 1) VarEntry *Yap_LookupVar(const char *var) /* lookup variable in variables table - * */ + * */ { CACHE_REGS VarEntry *p; @@ -299,7 +187,7 @@ static Term VarNames(VarEntry *p, Term l USES_REGS) { VarNames(p->VarLeft, l PASS_REGS) PASS_REGS)); if (HR > ASP - 4096) { save_machine_regs(); - longjmp(*LOCAL_IOBotch, 1); + longjmp(LOCAL_IOBotch, 1); } return (o); } else { @@ -329,7 +217,7 @@ static Term Singletons(VarEntry *p, Term l USES_REGS) { Singletons(p->VarLeft, l PASS_REGS) PASS_REGS)); if (HR > ASP - 4096) { save_machine_regs(); - longjmp(*LOCAL_IOBotch, 1); + longjmp(LOCAL_IOBotch, 1); } return (o); } else { @@ -354,7 +242,7 @@ static Term Variables(VarEntry *p, Term l USES_REGS) { Variables(p->VarRight, Variables(p->VarLeft, l PASS_REGS) PASS_REGS)); if (HR > ASP - 4096) { save_machine_regs(); - siglongjmp(*LOCAL_IOBotch, 1); + siglongjmp(LOCAL_IOBotch, 1); } return (o); } else { @@ -364,7 +252,7 @@ static Term Variables(VarEntry *p, Term l USES_REGS) { Term Yap_Variables(VarEntry *p, Term l) { CACHE_REGS - l = Variables(LOCAL_AnonVarTable, l PASS_REGS); + l = Variables(LOCAL_AnonVarTable, l PASS_REGS); return Variables(p, l PASS_REGS); } @@ -468,7 +356,7 @@ inline static void checkfor(Term c, JMPBUFF *FailBuff, strncpy(s, Yap_tokText(LOCAL_tokptr), 1023); syntax_msg("line %d: expected to find " "\'%c....................................\', found %s", - LOCAL_tokptr->TokPos, c, s); + LOCAL_tokptr->TokLine, c, s); FAIL; } NextToken; @@ -549,12 +437,12 @@ static Term ParseArgs(Atom a, Term close, JMPBUFF *FailBuff, Term arg1, func = Yap_MkFunctor(a, 1); if (func == NULL) { - syntax_msg("line %d: Heap Overflow", LOCAL_tokptr->TokPos); + syntax_msg("line %d: Heap Overflow", LOCAL_tokptr->TokLine); FAIL; } t = Yap_MkApplTerm(func, nargs, p); if (HR > ASP - 4096) { - syntax_msg("line %d: Stack Overflow", LOCAL_tokptr->TokPos); + syntax_msg("line %d: Stack Overflow", LOCAL_tokptr->TokLine); return TermNil; } NextToken; @@ -564,7 +452,7 @@ static Term ParseArgs(Atom a, Term close, JMPBUFF *FailBuff, Term arg1, while (1) { Term *tp = (Term *)ParserAuxSp; if (ParserAuxSp + 1 > LOCAL_TrailTop) { - syntax_msg("line %d: Trail Overflow", LOCAL_tokptr->TokPos); + syntax_msg("line %d: Trail Overflow", LOCAL_tokptr->TokLine); FAIL; } *tp++ = Unsigned(ParseTerm(999, FailBuff, enc, cmod PASS_REGS)); @@ -582,12 +470,12 @@ static Term ParseArgs(Atom a, Term close, JMPBUFF *FailBuff, Term arg1, * order */ if (HR > ASP - (nargs + 1)) { - syntax_msg("line %d: Stack Overflow", LOCAL_tokptr->TokPos); + syntax_msg("line %d: Stack Overflow", LOCAL_tokptr->TokLine); FAIL; } func = Yap_MkFunctor(a, nargs); if (func == NULL) { - syntax_msg("line %d: Heap Overflow", LOCAL_tokptr->TokPos); + syntax_msg("line %d: Heap Overflow", LOCAL_tokptr->TokLine); FAIL; } #ifdef SFUNC @@ -602,7 +490,7 @@ static Term ParseArgs(Atom a, Term close, JMPBUFF *FailBuff, Term arg1, t = Yap_MkApplTerm(func, nargs, p); #endif if (HR > ASP - 4096) { - syntax_msg("line %d: Stack Overflow", LOCAL_tokptr->TokPos); + syntax_msg("line %d: Stack Overflow", LOCAL_tokptr->TokLine); return TermNil; } /* check for possible overflow against local stack */ @@ -611,8 +499,8 @@ static Term ParseArgs(Atom a, Term close, JMPBUFF *FailBuff, Term arg1, } static Term MakeAccessor(Term t, Functor f USES_REGS) { - UInt arity = ArityOfFunctor(FunctorOfTerm(t)); - int i; + UInt arity = ArityOfFunctor(FunctorOfTerm(t)); + int i; Term tf[2], tl = TermNil; tf[1] = ArgOfTerm(1, t); @@ -638,7 +526,7 @@ loop: /* check for possible overflow against local stack */ if (HR > ASP - 4096) { to_store[1] = TermNil; - syntax_msg("line %d: Stack Overflow", LOCAL_tokptr->TokPos); + syntax_msg("line %d: Stack Overflow", LOCAL_tokptr->TokLine); FAIL; } else { to_store[1] = AbsPair(HR); @@ -653,7 +541,7 @@ loop: } } else { syntax_msg("line %d: looking for symbol ',','|' got symbol '%s'", - LOCAL_tokptr->TokPos, Yap_tokText(LOCAL_tokptr)); + LOCAL_tokptr->TokLine, Yap_tokText(LOCAL_tokptr)); FAIL; } return (o); @@ -725,13 +613,13 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, encoding_t enc, TRY( /* build appl on the heap */ func = Yap_MkFunctor(AtomOfTerm(t), 1); if (func == NULL) { - syntax_msg("line %d: Heap Overflow", LOCAL_tokptr->TokPos); + syntax_msg("line %d: Heap Overflow", LOCAL_tokptr->TokLine); FAIL; } t = ParseTerm(oprprio, FailBuff, enc, cmod PASS_REGS); t = Yap_MkApplTerm(func, 1, &t); /* check for possible overflow against local stack */ if (HR > ASP - 4096) { - syntax_msg("line %d: Stack Overflow", LOCAL_tokptr->TokPos); + syntax_msg("line %d: Stack Overflow", LOCAL_tokptr->TokLine); FAIL; } curprio = opprio; , break;) @@ -762,7 +650,7 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, encoding_t enc, break; case Error_tok: - syntax_msg("line %d: found ill-formed \"%s\"", LOCAL_tokptr->TokPos, + syntax_msg("line %d: found ill-formed \"%s\"", LOCAL_tokptr->TokLine, Yap_tokText(LOCAL_tokptr)); FAIL; @@ -798,14 +686,14 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, encoding_t enc, t = Yap_MkApplTerm(FunctorBraces, 1, &t); /* check for possible overflow against local stack */ if (HR > ASP - 4096) { - syntax_msg("line %d: Stack Overflow", LOCAL_tokptr->TokPos); + syntax_msg("line %d: Stack Overflow", LOCAL_tokptr->TokLine); FAIL; } checkfor(TermEndCurlyBracket, FailBuff, enc PASS_REGS); break; default: syntax_msg("line %d: unexpected ponctuation signal %s", - LOCAL_tokptr->TokPos, Yap_tokRep(LOCAL_tokptr)); + LOCAL_tokptr->TokLine, Yap_tokRep(LOCAL_tokptr)); FAIL; } break; @@ -896,7 +784,7 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, encoding_t enc, NextToken; break; default: - syntax_msg("line %d: expected operator, got \'%s\'", LOCAL_tokptr->TokPos, + syntax_msg("line %d: expected operator, got \'%s\'", LOCAL_tokptr->TokLine, Yap_tokText(LOCAL_tokptr)); FAIL; } @@ -912,9 +800,8 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, encoding_t enc, /* try parsing as infix operator */ Volatile int oldprio = curprio; TRY3( - func = Yap_MkFunctor(save_opinfo, 2); - if (func == NULL) { - syntax_msg("line %d: Heap Overflow", LOCAL_tokptr->TokPos); + func = Yap_MkFunctor(save_opinfo, 2); if (func == NULL) { + syntax_msg("line %d: Heap Overflow", LOCAL_tokptr->TokLine); FAIL; } NextToken; { @@ -924,7 +811,7 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, encoding_t enc, t = Yap_MkApplTerm(func, 2, args); /* check for possible overflow against local stack */ if (HR > ASP - 4096) { - syntax_msg("line %d: Stack Overflow", LOCAL_tokptr->TokPos); + syntax_msg("line %d: Stack Overflow", LOCAL_tokptr->TokLine); FAIL; } }, @@ -937,13 +824,13 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, encoding_t enc, /* parse as posfix operator */ Functor func = Yap_MkFunctor(AtomOfTerm(LOCAL_tokptr->TokInfo), 1); if (func == NULL) { - syntax_msg("line %d: Heap Overflow", LOCAL_tokptr->TokPos); + syntax_msg("line %d: Heap Overflow", LOCAL_tokptr->TokLine); FAIL; } t = Yap_MkApplTerm(func, 1, &t); /* check for possible overflow against local stack */ if (HR > ASP - 4096) { - syntax_msg("line %d: Stack Overflow", LOCAL_tokptr->TokPos); + syntax_msg("line %d: Stack Overflow", LOCAL_tokptr->TokLine); FAIL; } curprio = opprio; @@ -953,7 +840,8 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, encoding_t enc, break; } if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok)) { - if (LOCAL_tokptr->TokInfo == TermComma && prio >= 1000 && curprio <= 999) { + if (LOCAL_tokptr->TokInfo == TermComma && prio >= 1000 && + curprio <= 999) { Volatile Term args[2]; NextToken; args[0] = t; @@ -961,7 +849,7 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, encoding_t enc, t = Yap_MkApplTerm(FunctorComma, 2, args); /* check for possible overflow against local stack */ if (HR > ASP - 4096) { - syntax_msg("line %d: Stack Overflow", LOCAL_tokptr->TokPos); + syntax_msg("line %d: Stack Overflow", LOCAL_tokptr->TokLine); FAIL; } curprio = 1000; @@ -977,7 +865,7 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, encoding_t enc, t = Yap_MkApplTerm(FunctorVBar, 2, args); /* check for possible overflow against local stack */ if (HR > ASP - 4096) { - syntax_msg("line %d: Stack Overflow", LOCAL_tokptr->TokPos); + syntax_msg("line %d: Stack Overflow", LOCAL_tokptr->TokLine); FAIL; } curprio = opprio; @@ -1000,19 +888,18 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, encoding_t enc, curprio = opprio; continue; } else if (LOCAL_tokptr->TokInfo == TermBeginCurlyBracket && - IsPosfixOp(AtomBraces, &opprio, &oplprio, - cmod PASS_REGS) && + IsPosfixOp(AtomBraces, &opprio, &oplprio, cmod PASS_REGS) && opprio <= prio && oplprio >= curprio) { - t = ParseArgs(AtomBraces, TermEndCurlyBracket, FailBuff, t, - enc, cmod PASS_REGS); + t = ParseArgs(AtomBraces, TermEndCurlyBracket, FailBuff, t, enc, + cmod PASS_REGS); t = MakeAccessor(t, FunctorBraces PASS_REGS); curprio = opprio; continue; } } if (LOCAL_tokptr->Tok <= Ord(String_tok)) { - syntax_msg("line %d: expected operator, got \'%s\'", LOCAL_tokptr->TokPos, - Yap_tokText(LOCAL_tokptr)); + syntax_msg("line %d: expected operator, got \'%s\'", + LOCAL_tokptr->TokLine, Yap_tokText(LOCAL_tokptr)); FAIL; } break; @@ -1022,18 +909,24 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, encoding_t enc, Term Yap_Parse(UInt prio, encoding_t enc, Term cmod) { CACHE_REGS - // ensure that if we throw an exception - // t will be 0. + // ensure that if we throw an exception + // t will be 0. + LOCAL_ActiveError->errorMsg=NULL; + LOCAL_ActiveError->errorMsgLen=0; Volatile Term t = 0; JMPBUFF FailBuff; yhandle_t sls = Yap_StartSlots(); + LOCAL_ErrorMessage = NULL; LOCAL_toktide = LOCAL_tokptr; if (!sigsetjmp(FailBuff.JmpBuff, 0)) { + LOCAL_ActiveError->errorMsg=NULL; + LOCAL_ActiveError->errorMsgLen=0; t = ParseTerm(prio, &FailBuff, enc, cmod PASS_REGS); #if DEBUG if (GLOBAL_Option['p' - 'a' + 1]) { + Yap_DebugPlWrite(MkIntTerm(LOCAL_tokptr->TokLine)); Yap_DebugPutc(stderr, '['); if (t == 0) Yap_DebugPlWrite(MkIntTerm(0)); @@ -1046,12 +939,16 @@ Term Yap_Parse(UInt prio, encoding_t enc, Term cmod) { Yap_CloseSlots(sls); } if (LOCAL_tokptr != NULL && LOCAL_tokptr->Tok != Ord(eot_tok)) { - LOCAL_Error_TYPE = SYNTAX_ERROR; - if (LOCAL_tokptr->TokNext) { - LOCAL_ErrorMessage = "operator misssing . "; - } else { - LOCAL_ErrorMessage = "term does not end on . "; - } + LOCAL_Error_TYPE = SYNTAX_ERROR; + if (LOCAL_tokptr->TokNext) { + size_t sz = strlen("bracket or operator expected."); + LOCAL_ErrorMessage =malloc(sz+1); + strncpy(LOCAL_ErrorMessage, "bracket or operator expected.", sz ); + } else { + size_t sz = strlen("term must end with . or EOF."); + LOCAL_ErrorMessage =malloc(sz+1); + strncpy(LOCAL_ErrorMessage,"term must end with . or EOF.", sz ); + } t = 0; } if (t != 0 && LOCAL_Error_TYPE == SYNTAX_ERROR) { diff --git a/C/qlyr.c b/C/qlyr.c index 850ab4172..9fd35c3e9 100755 --- a/C/qlyr.c +++ b/C/qlyr.c @@ -1,20 +1,20 @@ /************************************************************************* -* * -* YAP Prolog * -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V. Santos Costa and Universidade do Porto 1985-- * -* * -************************************************************************** -* * -* File: qlyr.c * -* comments: quick saver/loader * -* * -* Last rev: $Date: 2011-08-29$,$Author: vsc $ * -* $Log: not supported by cvs2svn $ * -* * -*************************************************************************/ + * * + * YAP Prolog * + * * + * Yap Prolog was developed at NCCUP - Universidade do Porto * + * * + * Copyright L.Damas, V. Santos Costa and Universidade do Porto 1985-- * + * * + ************************************************************************** + * * + * File: qlyr.c * + * comments: quick saver/loader * + * * + * Last rev: $Date: 2011-08-29$,$Author: vsc $ * + * $Log: not supported by cvs2svn $ * + * * + *************************************************************************/ /** * * @file qlyr.c @@ -79,11 +79,18 @@ static char *Yap_AlwaysAllocCodeSpace(UInt size) { return out; } -static void QLYR_ERROR(qlfr_err_t my_err) { + +#define QLYR_ERROR(err) \ + QLYR_ERROR__(__FILE__, __FUNCTION__, __LINE__, err) + + + +static void QLYR_ERROR__(const char *file, const char *function, int lineno, + qlfr_err_t my_err) { // __android_log_print(ANDROID_LOG_INFO, "YAP ", "error %s in saved state // %s",GLOBAL_RestoreFile, qlyr_error[my_err]); - Yap_Error(SYSTEM_ERROR_SAVED_STATE, TermNil, "error %s in saved state %s", - GLOBAL_RestoreFile, qlyr_error[my_err]); + Yap_Error__(false, file, function, lineno, SYSTEM_ERROR_SAVED_STATE, TermNil, "error %s in saved state %s", + GLOBAL_RestoreFile, qlyr_error[my_err]); Yap_exit(1); } @@ -590,8 +597,32 @@ static void RestoreHashPreds(USES_REGS1) {} static void RestoreAtomList(Atom atm USES_REGS) {} +static bool maybe_read_bytes(FILE *stream, void *ptr, size_t sz) { + do { + size_t count; + if ((count = fread(ptr, 1, sz, stream)) == sz) + return true; + if (feof(stream) || ferror(stream)) + return false; + sz -= count; + ptr += count; + } while (true); +} + static size_t read_bytes(FILE *stream, void *ptr, size_t sz) { - return fread(ptr, sz, 1, stream); + do { + size_t count = fread(ptr, 1, sz, stream); + if (count == sz) + return sz; + if (feof(stream)) { + PlIOError(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM, TermNil, "read_qly/3: expected %ld bytes got %ld", sz, count); + return 0; + } else if (ferror(stream)) { + PlIOError(PERMISSION_ERROR_INPUT_STREAM, TermNil, "read_qly/3: expected %ld bytes got error %s", sz, strerror(errno)); + return 0; + } + sz -= count; + } while(true); } static unsigned char read_byte(FILE *stream) { return getc(stream); } @@ -625,34 +656,26 @@ static pred_flags_t read_predFlags(FILE *stream) { return v; } -static bool checkChars(FILE *stream, char s[]) { - int ch, c; - char *p = s; - - while ((ch = *p++)) { - if ((c = read_byte(stream)) != ch) { - return false; - } - } - return TRUE; -} static Atom do_header(FILE *stream) { - char s[256], *p = s, ch; + char s[2049], *p = s, *q; + char h0[] = "#!/bin/sh\nexec_dir=${YAPBINDIR:-"; + char h1[] = "exec $exec_dir/yap $0 \"$@\"\nsaved "; Atom at; - if (!checkChars(stream, "#!/bin/sh\nexec_dir=${YAPBINDIR:-")) + if (!maybe_read_bytes( stream, s, 2048) ) return NIL; - while ((ch = read_byte(stream)) != '\n') - ; - if (!checkChars(stream, "exec $exec_dir/yap $0 \"$@\"\nsaved ")) + if (strstr(s, h0)!= s) return NIL; - while ((ch = read_byte(stream)) != ',') - *p++ = ch; - *p++ = '\0'; - at = Yap_LookupAtom(s); - while ((ch = read_byte(stream))) - ; + if ((p=strstr(s, h1)) == NULL) { + return NIL; + } + p += strlen(h1); + q = strchr(p,','); + if (!q) + return NIL; + q[0] = '\0'; + at = Yap_LookupAtom(p); return at; } @@ -667,13 +690,22 @@ static Int get_header(USES_REGS1) { return FALSE; } if (!(stream = Yap_GetInputStream(t1, "header scanning in qload"))) { - return FALSE; + return false; } - if ((at = do_header(stream)) == NIL) - rc = FALSE; - else + sigjmp_buf signew, *sighold = LOCAL_RestartEnv; + LOCAL_RestartEnv = &signew; + + if (sigsetjmp(signew, 1) != 0) { + LOCAL_RestartEnv = sighold; + return false; + } + if ((at = do_header(stream)) == NIL) + rc = false; + else { rc = Yap_unify(ARG2, MkAtomTerm(at)); - return rc; + } + LOCAL_RestartEnv = sighold; + return rc; } static void ReadHash(FILE *stream) { @@ -696,7 +728,7 @@ static void ReadHash(FILE *stream) { Atom at; qlf_tag_t tg = read_tag(stream); - if (tg == QLY_ATOM) { + if (tg == QLY_ATOM) { char *rep = (char *)AllocTempSpace(); UInt len; @@ -804,6 +836,7 @@ static void ReadHash(FILE *stream) { UInt sz = read_UInt(stream); UInt nrefs = read_UInt(stream); LogUpdClause *ncl = (LogUpdClause *)Yap_AlwaysAllocCodeSpace(sz); + Yap_LUClauseSpace += sz; if (!ncl) { QLYR_ERROR(OUT_OF_CODE_SPACE); } @@ -842,6 +875,7 @@ static void read_clauses(FILE *stream, PredEntry *pp, UInt nclauses, nrefs = cl->ClRefCount; } else { cl = (LogUpdClause *)Yap_AlwaysAllocCodeSpace(size); + Yap_LUClauseSpace += size; } read_bytes(stream, cl, size); cl->ClFlags &= ~InUseMask; @@ -855,6 +889,7 @@ static void read_clauses(FILE *stream, PredEntry *pp, UInt nclauses, char *base = (void *)read_UInt(stream); UInt mask = read_UInt(stream); UInt size = read_UInt(stream); + Yap_ClauseSpace += size; MegaClause *cl = (MegaClause *)Yap_AlwaysAllocCodeSpace(size); if (nclauses) { @@ -886,6 +921,7 @@ static void read_clauses(FILE *stream, PredEntry *pp, UInt nclauses, char *base = (void *)read_UInt(stream); UInt size = read_UInt(stream); DynamicClause *cl = (DynamicClause *)Yap_AlwaysAllocCodeSpace(size); + Yap_LUClauseSpace += size; LOCAL_HDiff = (char *)cl - base; read_bytes(stream, cl, size); @@ -916,6 +952,7 @@ static void read_clauses(FILE *stream, PredEntry *pp, UInt nclauses, char *base = (void *)read_UInt(stream); UInt size = read_UInt(stream); StaticClause *cl = (StaticClause *)Yap_AlwaysAllocCodeSpace(size); + Yap_ClauseSpace += size; LOCAL_HDiff = (char *)cl - base; read_bytes(stream, cl, size); @@ -1044,6 +1081,8 @@ static void ReInitProlog(void) { static Int qload_program(USES_REGS1) { FILE *stream; + + Term t1 = Deref(ARG1); if (IsVarTerm(t1)) { @@ -1053,7 +1092,7 @@ static Int qload_program(USES_REGS1) { if ((stream = Yap_GetInputStream(t1, "from read_program"))) { return FALSE; } - Yap_Reset(YAP_RESET_FROM_RESTORE); + Yap_Reset(YAP_RESET_FROM_RESTORE, true); if (do_header(stream) == NIL) return FALSE; read_module(stream); @@ -1063,10 +1102,10 @@ static Int qload_program(USES_REGS1) { return true; } -YAP_file_type_t Yap_Restore(const char *s, const char *lib_dir) { +YAP_file_type_t Yap_Restore(const char *s) { CACHE_REGS - FILE *stream = Yap_OpenRestore(s, lib_dir); + FILE *stream = Yap_OpenRestore(s); if (!stream) return -1; GLOBAL_RestoreFile = s; diff --git a/C/qlyw.c b/C/qlyw.c index ebe2bfd0f..e7f1e1a18 100755 --- a/C/qlyw.c +++ b/C/qlyw.c @@ -1,20 +1,20 @@ /************************************************************************* -* * -* YAP Prolog * -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V. Santos Costa and Universidade do Porto 1985-- * -* * -************************************************************************** -* * -* File: qlyw.c * -* comments: quick saver/loader * -* * -* Last rev: $Date: 2011-08-29$,$Author: vsc $ * -* $Log: not supported by cvs2svn $ * -* * -*************************************************************************/ + * * + * YAP Prolog * + * * + * Yap Prolog was developed at NCCUP - Universidade do Porto * + * * + * Copyright L.Damas, V. Santos Costa and Universidade do Porto 1985-- * + * * + ************************************************************************** + * * + * File: qlyw.c * + * comments: quick saver/loader * + * * + * Last rev: $Date: 2011-08-29$,$Author: vsc $ * + * $Log: not supported by cvs2svn $ * + * * + *************************************************************************/ /** * @@ -25,49 +25,49 @@ * */ -#include "absmi.h" #include "Foreign.h" +#include "absmi.h" #include "alloc.h" -#include "yapio.h" -#include "iopreds.h" #include "attvar.h" +#include "iopreds.h" +#include "yapio.h" #if HAVE_STRING_H #include #endif #include "qly.h" -static void RestoreEntries(PropEntry *, int USES_REGS); -static void CleanCode(PredEntry * USES_REGS); +static void RestoreEntries(PropEntry *, int USES_REGS); +static void CleanCode(PredEntry *USES_REGS); -static void -GrowAtomTable(void) { +static void GrowAtomTable(void) { CACHE_REGS UInt size = LOCAL_ExportAtomHashTableSize; export_atom_hash_entry_t *p, *newt, *oldt = LOCAL_ExportAtomHashChain; UInt new_size = size + (size > 1024 ? size : 1024); UInt i; - newt = (export_atom_hash_entry_t *)calloc(new_size,sizeof(export_atom_hash_entry_t)); + newt = (export_atom_hash_entry_t *)calloc(new_size, + sizeof(export_atom_hash_entry_t)); if (!newt) { return; } p = oldt; - for (i = 0 ; i < size ; p++,i++) { + for (i = 0; i < size; p++, i++) { Atom a = p->val; export_atom_hash_entry_t *newp; CELL hash; const unsigned char *apt; - - if (!a) continue; + if (!a) + continue; apt = RepAtom(a)->UStrOfAE; - hash = HashFunction(apt)/(2*sizeof(CELL)) % new_size; - newp = newt+hash; + hash = HashFunction(apt) / (2 * sizeof(CELL)) % new_size; + newp = newt + hash; while (newp->val) { newp++; - if (newp == newt+new_size) - newp = newt; + if (newp == newt + new_size) + newp = newt; } newp->val = a; } @@ -76,29 +76,24 @@ GrowAtomTable(void) { free(oldt); } -static void -LookupAtom(Atom at) -{ +static void LookupAtom(Atom at) { CACHE_REGS const unsigned char *p = RepAtom(at)->UStrOfAE; CELL hash = HashFunction(p) % LOCAL_ExportAtomHashTableSize; export_atom_hash_entry_t *a; - a = LOCAL_ExportAtomHashChain+hash; + a = LOCAL_ExportAtomHashChain + hash; while (a->val) { if (a->val == at) { return; } a++; - if (a == LOCAL_ExportAtomHashChain+LOCAL_ExportAtomHashTableSize) + if (a == LOCAL_ExportAtomHashChain + LOCAL_ExportAtomHashTableSize) a = LOCAL_ExportAtomHashChain; - } a->val = at; LOCAL_ExportAtomHashTableNum++; - if (LOCAL_ExportAtomHashTableNum > - LOCAL_ExportAtomHashTableSize/2 - ) { + if (LOCAL_ExportAtomHashTableNum > LOCAL_ExportAtomHashTableSize / 2) { GrowAtomTable(); if (!LOCAL_ExportAtomHashChain) { return; @@ -106,31 +101,32 @@ LookupAtom(Atom at) } } -static void -GrowFunctorTable(void) { +static void GrowFunctorTable(void) { CACHE_REGS UInt size = LOCAL_ExportFunctorHashTableSize; export_functor_hash_entry_t *p, *newt, *oldt = LOCAL_ExportFunctorHashChain; UInt new_size = size + (size > 1024 ? size : 1024); UInt i; - newt = (export_functor_hash_entry_t *)calloc(new_size,sizeof(export_functor_hash_entry_t)); + newt = (export_functor_hash_entry_t *)calloc( + new_size, sizeof(export_functor_hash_entry_t)); if (!newt) { return; } p = oldt; - for (i = 0 ; i < size ; p++,i++) { + for (i = 0; i < size; p++, i++) { Functor f = p->val; export_functor_hash_entry_t *newp; CELL hash; - if (!f) continue; - hash = ((CELL)(f))/(2*sizeof(CELL)) % new_size; - newp = newt+hash; + if (!f) + continue; + hash = ((CELL)(f)) / (2 * sizeof(CELL)) % new_size; + newp = newt + hash; while (newp->val) { newp++; - if (newp == newt+new_size) - newp = newt; + if (newp == newt + new_size) + newp = newt; } newp->val = p->val; newp->arity = p->arity; @@ -141,22 +137,21 @@ GrowFunctorTable(void) { free(oldt); } -static void -LookupFunctor(Functor fun) -{ +static void LookupFunctor(Functor fun) { CACHE_REGS - CELL hash = ((CELL)(fun))/(2*sizeof(CELL)) % LOCAL_ExportFunctorHashTableSize; + CELL hash = + ((CELL)(fun)) / (2 * sizeof(CELL)) % LOCAL_ExportFunctorHashTableSize; export_functor_hash_entry_t *f; Atom name = NameOfFunctor(fun); - UInt arity = ArityOfFunctor(fun); + UInt arity = ArityOfFunctor(fun); - f = LOCAL_ExportFunctorHashChain+hash; + f = LOCAL_ExportFunctorHashChain + hash; while (f->val) { if (f->val == fun) { return; } f++; - if (f == LOCAL_ExportFunctorHashChain+LOCAL_ExportFunctorHashTableSize) + if (f == LOCAL_ExportFunctorHashChain + LOCAL_ExportFunctorHashTableSize) f = LOCAL_ExportFunctorHashChain; } LookupAtom(name); @@ -164,9 +159,7 @@ LookupFunctor(Functor fun) f->name = name; f->arity = arity; LOCAL_ExportFunctorHashTableNum++; - if (LOCAL_ExportFunctorHashTableNum > - LOCAL_ExportFunctorHashTableSize/2 - ) { + if (LOCAL_ExportFunctorHashTableNum > LOCAL_ExportFunctorHashTableSize / 2) { GrowFunctorTable(); if (!LOCAL_ExportFunctorHashChain) { return; @@ -174,31 +167,33 @@ LookupFunctor(Functor fun) } } -static void -GrowPredTable(void) { +static void GrowPredTable(void) { CACHE_REGS UInt size = LOCAL_ExportPredEntryHashTableSize; - export_pred_entry_hash_entry_t *p, *newt, *oldt = LOCAL_ExportPredEntryHashChain; + export_pred_entry_hash_entry_t *p, *newt, + *oldt = LOCAL_ExportPredEntryHashChain; UInt new_size = size + (size > 1024 ? size : 1024); UInt i; - newt = (export_pred_entry_hash_entry_t *)calloc(new_size,sizeof(export_pred_entry_hash_entry_t)); + newt = (export_pred_entry_hash_entry_t *)calloc( + new_size, sizeof(export_pred_entry_hash_entry_t)); if (!newt) { return; } p = oldt; - for (i = 0 ; i < size ; p++,i++) { + for (i = 0; i < size; p++, i++) { PredEntry *pe = p->val; export_pred_entry_hash_entry_t *newp; CELL hash; - if (!pe) continue; - hash = ((CELL)(pe))/(2*sizeof(CELL)) % new_size; - newp = newt+hash; + if (!pe) + continue; + hash = ((CELL)(pe)) / (2 * sizeof(CELL)) % new_size; + newp = newt + hash; while (newp->val) { newp++; - if (newp == newt+new_size) - newp = newt; + if (newp == newt + new_size) + newp = newt; } newp->val = p->val; newp->arity = p->arity; @@ -210,21 +205,21 @@ GrowPredTable(void) { free(oldt); } -static void -LookupPredEntry(PredEntry *pe) -{ +static void LookupPredEntry(PredEntry *pe) { CACHE_REGS - CELL hash = (((CELL)(pe))/(2*sizeof(CELL))) % LOCAL_ExportPredEntryHashTableSize; + CELL hash = + (((CELL)(pe)) / (2 * sizeof(CELL))) % LOCAL_ExportPredEntryHashTableSize; export_pred_entry_hash_entry_t *p; - UInt arity = pe->ArityOfPE; + UInt arity = pe->ArityOfPE; - p = LOCAL_ExportPredEntryHashChain+hash; + p = LOCAL_ExportPredEntryHashChain + hash; while (p->val) { if (p->val == pe) { return; } p++; - if (p == LOCAL_ExportPredEntryHashChain+LOCAL_ExportPredEntryHashTableSize) + if (p == + LOCAL_ExportPredEntryHashChain + LOCAL_ExportPredEntryHashTableSize) p = LOCAL_ExportPredEntryHashChain; } p->arity = arity; @@ -258,8 +253,7 @@ LookupPredEntry(PredEntry *pe) LookupAtom(p->module); LOCAL_ExportPredEntryHashTableNum++; if (LOCAL_ExportPredEntryHashTableNum > - LOCAL_ExportPredEntryHashTableSize/2 - ) { + LOCAL_ExportPredEntryHashTableSize / 2) { GrowPredTable(); if (!LOCAL_ExportPredEntryHashChain) { return; @@ -267,32 +261,32 @@ LookupPredEntry(PredEntry *pe) } } - -static void -GrowDBRefTable(void) { +static void GrowDBRefTable(void) { CACHE_REGS UInt size = LOCAL_ExportDBRefHashTableSize; export_dbref_hash_entry_t *p, *newt, *oldt = LOCAL_ExportDBRefHashChain; UInt new_size = size + (size > 1024 ? size : 1024); UInt i; - newt = (export_dbref_hash_entry_t *)calloc(new_size,sizeof(export_dbref_hash_entry_t)); + newt = (export_dbref_hash_entry_t *)calloc(new_size, + sizeof(export_dbref_hash_entry_t)); if (!newt) { return; } p = oldt; - for (i = 0 ; i < size ; p++,i++) { + for (i = 0; i < size; p++, i++) { DBRef dbr = p->val; export_dbref_hash_entry_t *newp; CELL hash; - if (!dbr) continue; - hash = ((CELL)(dbr))/(2*sizeof(CELL)) % new_size; - newp = newt+hash; + if (!dbr) + continue; + hash = ((CELL)(dbr)) / (2 * sizeof(CELL)) % new_size; + newp = newt + hash; while (newp->val) { newp++; - if (newp == newt+new_size) - newp = newt; + if (newp == newt + new_size) + newp = newt; } newp->val = p->val; newp->sz = p->sz; @@ -303,30 +297,27 @@ GrowDBRefTable(void) { free(oldt); } -static void -LookupDBRef(DBRef ref) -{ +static void LookupDBRef(DBRef ref) { CACHE_REGS - CELL hash = ((CELL)(ref))/(2*sizeof(CELL)) % LOCAL_ExportDBRefHashTableSize; + CELL hash = + ((CELL)(ref)) / (2 * sizeof(CELL)) % LOCAL_ExportDBRefHashTableSize; export_dbref_hash_entry_t *a; - a = LOCAL_ExportDBRefHashChain+hash; + a = LOCAL_ExportDBRefHashChain + hash; while (a->val) { if (a->val == ref) { a->refs++; return; } a++; - if (a == LOCAL_ExportDBRefHashChain+LOCAL_ExportDBRefHashTableSize) + if (a == LOCAL_ExportDBRefHashChain + LOCAL_ExportDBRefHashTableSize) a = LOCAL_ExportDBRefHashChain; } a->val = ref; a->sz = ((LogUpdClause *)ref)->ClSize; a->refs = 1; LOCAL_ExportDBRefHashTableNum++; - if (LOCAL_ExportDBRefHashTableNum > - LOCAL_ExportDBRefHashTableSize/2 - ) { + if (LOCAL_ExportDBRefHashTableNum > LOCAL_ExportDBRefHashTableSize / 2) { GrowDBRefTable(); if (!LOCAL_ExportDBRefHashChain) { return; @@ -334,27 +325,28 @@ LookupDBRef(DBRef ref) } } -static void -InitHash(void) -{ +static void InitHash(void) { CACHE_REGS LOCAL_ExportFunctorHashTableNum = 0; LOCAL_ExportFunctorHashTableSize = EXPORT_FUNCTOR_TABLE_SIZE; - LOCAL_ExportFunctorHashChain = (export_functor_hash_entry_t *)calloc(LOCAL_ExportFunctorHashTableSize, sizeof(export_functor_hash_entry_t )); + LOCAL_ExportFunctorHashChain = (export_functor_hash_entry_t *)calloc( + LOCAL_ExportFunctorHashTableSize, sizeof(export_functor_hash_entry_t)); LOCAL_ExportAtomHashTableNum = 0; LOCAL_ExportAtomHashTableSize = EXPORT_ATOM_TABLE_SIZE; - LOCAL_ExportAtomHashChain = (export_atom_hash_entry_t *)calloc( LOCAL_ExportAtomHashTableSize, sizeof(export_atom_hash_entry_t)); + LOCAL_ExportAtomHashChain = (export_atom_hash_entry_t *)calloc( + LOCAL_ExportAtomHashTableSize, sizeof(export_atom_hash_entry_t)); LOCAL_ExportPredEntryHashTableNum = 0; LOCAL_ExportPredEntryHashTableSize = EXPORT_PRED_ENTRY_TABLE_SIZE; - LOCAL_ExportPredEntryHashChain = (export_pred_entry_hash_entry_t *)calloc(LOCAL_ExportPredEntryHashTableSize, sizeof(export_pred_entry_hash_entry_t)); + LOCAL_ExportPredEntryHashChain = (export_pred_entry_hash_entry_t *)calloc( + LOCAL_ExportPredEntryHashTableSize, + sizeof(export_pred_entry_hash_entry_t)); LOCAL_ExportDBRefHashTableNum = 0; LOCAL_ExportDBRefHashTableSize = EXPORT_DBREF_TABLE_SIZE; - LOCAL_ExportDBRefHashChain = (export_dbref_hash_entry_t *)calloc(EXPORT_DBREF_TABLE_SIZE, sizeof(export_dbref_hash_entry_t)); + LOCAL_ExportDBRefHashChain = (export_dbref_hash_entry_t *)calloc( + EXPORT_DBREF_TABLE_SIZE, sizeof(export_dbref_hash_entry_t)); } -static void -CloseHash(void) -{ +static void CloseHash(void) { CACHE_REGS LOCAL_ExportFunctorHashTableNum = 0; LOCAL_ExportFunctorHashTableSize = 0L; @@ -370,37 +362,27 @@ CloseHash(void) free(LOCAL_ExportDBRefHashChain); } -static inline Atom -AtomAdjust(Atom a) -{ +static inline Atom AtomAdjust(Atom a) { LookupAtom(a); return a; } -static inline Functor -FuncAdjust(Functor f) -{ +static inline Functor FuncAdjust(Functor f) { LookupFunctor(f); return f; } - -static inline Term -AtomTermAdjust(Term t) -{ +static inline Term AtomTermAdjust(Term t) { LookupAtom(AtomOfTerm(t)); return t; } -static inline Term -TermToGlobalOrAtomAdjust(Term t) -{ +static inline Term TermToGlobalOrAtomAdjust(Term t) { if (t && IsAtomTerm(t)) return AtomTermAdjust(t); return t; } - #define IsOldCode(P) FALSE #define IsOldCodeCellPtr(P) FALSE #define IsOldDelay(P) FALSE @@ -420,7 +402,7 @@ TermToGlobalOrAtomAdjust(Term t) #define NoAGCAtomAdjust(P) (P) #define OrArgAdjust(P) #define TabEntryAdjust(P) -#define IntegerAdjust(D) (D) +#define IntegerAdjust(D) (D) #define AddrAdjust(P) (P) #define MFileAdjust(P) (P) #define CodeVarAdjust(P) (P) @@ -430,28 +412,22 @@ TermToGlobalOrAtomAdjust(Term t) #define IntegerInCodeAdjust(P) #define OpcodeAdjust(P) (P) -static inline Term -ModuleAdjust(Term t) -{ - if (!t) return t; +static inline Term ModuleAdjust(Term t) { + if (!t) + return t; return AtomTermAdjust(t); } -static inline PredEntry * -PredEntryAdjust(PredEntry *pe) -{ +static inline PredEntry *PredEntryAdjust(PredEntry *pe) { LookupPredEntry(pe); return pe; } -static inline PredEntry * -PtoPredAdjust(PredEntry *pe) -{ +static inline PredEntry *PtoPredAdjust(PredEntry *pe) { LookupPredEntry(pe); return pe; } - #define ExternalFunctionAdjust(P) (P) #define DBRecordAdjust(P) (P) #define ModEntryPtrAdjust(P) (P) @@ -468,10 +444,8 @@ PtoPredAdjust(PredEntry *pe) #define DelayAdjust(P) (P) #define GlobalAdjust(P) (P) -#define DBRefAdjust(P,DoRef) DBRefAdjust__(P PASS_REGS) -static inline DBRef -DBRefAdjust__ (DBRef dbt USES_REGS) -{ +#define DBRefAdjust(P, DoRef) DBRefAdjust__(P PASS_REGS) +static inline DBRef DBRefAdjust__(DBRef dbt USES_REGS) { LookupDBRef(dbt); return dbt; } @@ -514,67 +488,48 @@ DBRefAdjust__ (DBRef dbt USES_REGS) #define rehash(oldcode, NOfE, KindOfEntries) - -static void RestoreFlags( UInt NFlags ) -{ -} +static void RestoreFlags(UInt NFlags) {} #include "rheap.h" -static void -RestoreHashPreds( USES_REGS1 ) -{ -} +static void RestoreHashPreds(USES_REGS1) {} +static void RestoreAtomList(Atom atm USES_REGS) {} -static void -RestoreAtomList(Atom atm USES_REGS) -{ -} - -static size_t save_bytes(FILE *stream, void *ptr, size_t sz) -{ +static size_t save_bytes(FILE *stream, void *ptr, size_t sz) { return fwrite(ptr, sz, 1, stream); } -static size_t save_byte(FILE *stream, int byte) -{ +static size_t save_byte(FILE *stream, int byte) { fputc(byte, stream); return 1; } -static size_t save_bits16(FILE *stream, BITS16 val) -{ +static size_t save_bits16(FILE *stream, BITS16 val) { BITS16 v = val; return save_bytes(stream, &v, sizeof(BITS16)); } -static size_t save_UInt(FILE *stream, UInt val) -{ +static size_t save_UInt(FILE *stream, UInt val) { UInt v = val; return save_bytes(stream, &v, sizeof(UInt)); } -static size_t save_Int(FILE *stream, Int val) -{ +static size_t save_Int(FILE *stream, Int val) { Int v = val; return save_bytes(stream, &v, sizeof(Int)); } -static size_t save_tag(FILE *stream, qlf_tag_t tag) -{ +static size_t save_tag(FILE *stream, qlf_tag_t tag) { return save_byte(stream, tag); } -static size_t save_predFlags(FILE *stream, pred_flags_t predFlags) -{ +static size_t save_predFlags(FILE *stream, pred_flags_t predFlags) { pred_flags_t v = predFlags; return save_bytes(stream, &v, sizeof(pred_flags_t)); } -static int -SaveHash(FILE *stream) -{ +static int SaveHash(FILE *stream) { CACHE_REGS UInt i; /* first, current opcodes */ @@ -582,25 +537,26 @@ SaveHash(FILE *stream) save_UInt(stream, (UInt)&ARG1); CHECK(save_tag(stream, QLY_START_OPCODES)); save_Int(stream, _std_top); - for (i= 0; i <= _std_top; i++) { + for (i = 0; i <= _std_top; i++) { save_UInt(stream, (UInt)Yap_opcode(i)); } CHECK(save_tag(stream, QLY_START_ATOMS)); CHECK(save_UInt(stream, LOCAL_ExportAtomHashTableNum)); for (i = 0; i < LOCAL_ExportAtomHashTableSize; i++) { - export_atom_hash_entry_t *a = LOCAL_ExportAtomHashChain+i; + export_atom_hash_entry_t *a = LOCAL_ExportAtomHashChain + i; if (a->val) { Atom at = a->val; CHECK(save_UInt(stream, (UInt)at)); - CHECK(save_tag(stream, QLY_ATOM)); - CHECK(save_UInt(stream, strlen((char *)RepAtom(at)->StrOfAE))); - CHECK(save_bytes(stream, (char *)at->StrOfAE, (strlen((char *)at->StrOfAE)+1)*sizeof(char))); + CHECK(save_tag(stream, QLY_ATOM)); + CHECK(save_UInt(stream, strlen((char *)RepAtom(at)->StrOfAE))); + CHECK(save_bytes(stream, (char *)at->StrOfAE, + (strlen((char *)at->StrOfAE) + 1) * sizeof(char))); } } save_tag(stream, QLY_START_FUNCTORS); save_UInt(stream, LOCAL_ExportFunctorHashTableNum); for (i = 0; i < LOCAL_ExportFunctorHashTableSize; i++) { - export_functor_hash_entry_t *f = LOCAL_ExportFunctorHashChain+i; + export_functor_hash_entry_t *f = LOCAL_ExportFunctorHashChain + i; if (!(f->val)) continue; CHECK(save_UInt(stream, (UInt)(f->val))); @@ -610,7 +566,7 @@ SaveHash(FILE *stream) save_tag(stream, QLY_START_PRED_ENTRIES); save_UInt(stream, LOCAL_ExportPredEntryHashTableNum); for (i = 0; i < LOCAL_ExportPredEntryHashTableSize; i++) { - export_pred_entry_hash_entry_t *p = LOCAL_ExportPredEntryHashChain+i; + export_pred_entry_hash_entry_t *p = LOCAL_ExportPredEntryHashChain + i; if (!(p->val)) continue; CHECK(save_UInt(stream, (UInt)(p->val))); @@ -621,7 +577,7 @@ SaveHash(FILE *stream) save_tag(stream, QLY_START_DBREFS); save_UInt(stream, LOCAL_ExportDBRefHashTableNum); for (i = 0; i < LOCAL_ExportDBRefHashTableSize; i++) { - export_dbref_hash_entry_t *p = LOCAL_ExportDBRefHashChain+i; + export_dbref_hash_entry_t *p = LOCAL_ExportDBRefHashChain + i; if (p->val) { CHECK(save_UInt(stream, (UInt)(p->val))); CHECK(save_UInt(stream, p->sz)); @@ -633,9 +589,8 @@ SaveHash(FILE *stream) return 1; } -static size_t -save_clauses(FILE *stream, PredEntry *pp) { - yamop *FirstC, *LastC; +static size_t save_clauses(FILE *stream, PredEntry *pp) { + yamop *FirstC, *LastC; FirstC = pp->cs.p_code.FirstClause; LastC = pp->cs.p_code.LastClause; @@ -647,11 +602,11 @@ save_clauses(FILE *stream, PredEntry *pp) { while (cl != NULL) { if (IN_BETWEEN(cl->ClTimeStart, pp->TimeStampOfPred, cl->ClTimeEnd)) { - UInt size = cl->ClSize; - CHECK(save_tag(stream, QLY_START_LU_CLAUSE)); - CHECK(save_UInt(stream, (UInt)cl)); - CHECK(save_UInt(stream, size)); - CHECK(save_bytes(stream, cl, size)); + UInt size = cl->ClSize; + CHECK(save_tag(stream, QLY_START_LU_CLAUSE)); + CHECK(save_UInt(stream, (UInt)cl)); + CHECK(save_UInt(stream, size)); + CHECK(save_bytes(stream, cl, size)); } cl = cl->ClNext; } @@ -674,7 +629,8 @@ save_clauses(FILE *stream, PredEntry *pp) { CHECK(save_UInt(stream, (UInt)cl)); CHECK(save_UInt(stream, size)); CHECK(save_bytes(stream, dcl, size)); - if (cl == LastC) return 1; + if (cl == LastC) + return 1; cl = NextDynamicClause(cl); } while (TRUE); } else { @@ -689,15 +645,15 @@ save_clauses(FILE *stream, PredEntry *pp) { CHECK(save_UInt(stream, (UInt)cl)); CHECK(save_UInt(stream, size)); CHECK(save_bytes(stream, cl, size)); - if (cl->ClCode == LastC) return 1; + if (cl->ClCode == LastC) + return 1; cl = cl->ClNext; } while (TRUE); } return 1; } -static size_t -save_pred(FILE *stream, PredEntry *ap) { +static size_t save_pred(FILE *stream, PredEntry *ap) { CHECK(save_UInt(stream, (UInt)ap)); CHECK(save_predFlags(stream, ap->PredFlags)); if (ap->PredFlags & ForeignPredFlags) @@ -708,19 +664,17 @@ save_pred(FILE *stream, PredEntry *ap) { return save_clauses(stream, ap); } -static int -clean_pred(PredEntry *pp USES_REGS) { +static int clean_pred(PredEntry *pp USES_REGS) { if (pp->PredFlags & ForeignPredFlags) { return true; } else { - CleanClauses(pp->cs.p_code.FirstClause, pp->cs.p_code.LastClause, pp PASS_REGS); + CleanClauses(pp->cs.p_code.FirstClause, pp->cs.p_code.LastClause, + pp PASS_REGS); } return true; } -static size_t -mark_pred(PredEntry *ap) -{ +static size_t mark_pred(PredEntry *ap) { CACHE_REGS if (ap->ModuleOfPred != IDB_MODULE) { if (ap->ArityOfPE) { @@ -735,7 +689,7 @@ mark_pred(PredEntry *ap) FuncAdjust(ap->FunctorOfPred); } } - if (!(ap->PredFlags & (MultiFileFlag|NumberDBPredFlag)) && + if (!(ap->PredFlags & (MultiFileFlag | NumberDBPredFlag)) && ap->src.OwnerFile) { AtomAdjust(ap->src.OwnerFile); } @@ -743,22 +697,20 @@ mark_pred(PredEntry *ap) return 1; } -static size_t -mark_ops(FILE *stream, Term mod) { +static size_t mark_ops(FILE *stream, Term mod) { OpEntry *op = OpList; while (op) { if (!mod || op->OpModule == mod) { AtomAdjust(op->OpName); if (op->OpModule) - AtomTermAdjust(op->OpModule); + AtomTermAdjust(op->OpModule); } op = op->OpNext; } return 1; } -static size_t -save_ops(FILE *stream, Term mod) { +static size_t save_ops(FILE *stream, Term mod) { OpEntry *op = OpList; while (op) { if (!mod || op->OpModule == mod) { @@ -775,19 +727,20 @@ save_ops(FILE *stream, Term mod) { return 1; } -static int -save_header(FILE *stream, char type[]) -{ - char msg[256]; +static size_t save_header(FILE *stream, char type[]) { + char msg[2048]; - sprintf(msg, "#!/bin/sh\nexec_dir=${YAPBINDIR:-%s}\nexec $exec_dir/yap $0 \"$@\"\n%s %s\n", YAP_BINDIR, type, YAP_FULL_VERSION); - return save_bytes(stream, msg, strlen(msg)+1); + memset(msg, 0, 2048); + sprintf(msg, + "#!/bin/sh\nexec_dir=${YAPBINDIR:-%s}\nexec $exec_dir/yap $0 " + "\"$@\"\n%s %s\n", + YAP_BINDIR, type, YAP_FULL_VERSION); + return save_bytes(stream, msg, 2048); } -static size_t -save_module(FILE *stream, Term mod) { +static size_t save_module(FILE *stream, Term mod) { PredEntry *ap = Yap_ModulePred(mod); - save_header( stream, "saved module," ); + save_header(stream, "saved module,"); InitHash(); ModuleAdjust(mod); while (ap) { @@ -813,12 +766,11 @@ save_module(FILE *stream, Term mod) { return 1; } -static size_t -save_program(FILE *stream) { +static size_t save_program(FILE *stream) { ModEntry *me = CurrentModules; InitHash(); - save_header( stream, "saved state," ); + save_header(stream, "saved state,"); /* should we allow the user to see hidden predicates? */ while (me) { PredEntry *pp; @@ -826,7 +778,7 @@ save_program(FILE *stream) { AtomAdjust(me->AtomOfME); while (pp != NULL) { #if DEBUG - // Yap_PrintPredName( pp ); +// Yap_PrintPredName( pp ); #endif pp = PredEntryAdjust(pp); CHECK(mark_pred(pp)); @@ -858,12 +810,11 @@ save_program(FILE *stream) { return 1; } -static size_t -save_file(FILE *stream, Atom FileName) { +static size_t save_file(FILE *stream, Atom FileName) { ModEntry *me = CurrentModules; InitHash(); - save_header( stream, "saved file," ); + save_header(stream, "saved file,"); /* should we allow the user to see hidden predicates? */ while (me) { PredEntry *pp; @@ -872,10 +823,10 @@ save_file(FILE *stream, Atom FileName) { while (pp != NULL) { pp = PredEntryAdjust(pp); if (pp && - !(pp->PredFlags & (MultiFileFlag|NumberDBPredFlag|AtomDBPredFlag|CPredFlag|AsmPredFlag|UserCPredFlag)) && - pp->ModuleOfPred != IDB_MODULE && - pp->src.OwnerFile == FileName) { - CHECK(mark_pred(pp)); + !(pp->PredFlags & (MultiFileFlag | NumberDBPredFlag | AtomDBPredFlag | + CPredFlag | AsmPredFlag | UserCPredFlag)) && + pp->ModuleOfPred != IDB_MODULE && pp->src.OwnerFile == FileName) { + CHECK(mark_pred(pp)); } pp = pp->NextPredOfModule; } @@ -893,10 +844,11 @@ save_file(FILE *stream, Atom FileName) { CHECK(save_UInt(stream, (UInt)MkAtomTerm(me->AtomOfME))); while (pp != NULL) { if (pp && - !(pp->PredFlags & (MultiFileFlag|NumberDBPredFlag|AtomDBPredFlag|CPredFlag|AsmPredFlag|UserCPredFlag)) && - pp->src.OwnerFile == FileName) { - CHECK(save_tag(stream, QLY_START_PREDICATE)); - CHECK(save_pred(stream, pp)); + !(pp->PredFlags & (MultiFileFlag | NumberDBPredFlag | AtomDBPredFlag | + CPredFlag | AsmPredFlag | UserCPredFlag)) && + pp->src.OwnerFile == FileName) { + CHECK(save_tag(stream, QLY_START_PREDICATE)); + CHECK(save_pred(stream, pp)); } pp = pp->NextPredOfModule; } @@ -909,78 +861,72 @@ save_file(FILE *stream, Atom FileName) { return 1; } -static Int -qsave_module_preds( USES_REGS1 ) -{ +static Int qsave_module_preds(USES_REGS1) { FILE *stream; Term tmod = Deref(ARG2); Term t1 = Deref(ARG1); if (IsVarTerm(t1)) { - Yap_Error(INSTANTIATION_ERROR,t1,"save_module/3"); + Yap_Error(INSTANTIATION_ERROR, t1, "save_module/3"); return FALSE; } if (!IsAtomTerm(t1)) { - Yap_Error(TYPE_ERROR_ATOM,t1,"save_module/3"); - return(FALSE); + Yap_Error(TYPE_ERROR_ATOM, t1, "save_module/3"); + return (FALSE); } - if (!(stream = Yap_GetOutputStream(t1, "save_module") )){ + if (!(stream = Yap_GetOutputStream(t1, "save_module"))) { return FALSE; } if (IsVarTerm(tmod)) { - Yap_Error(INSTANTIATION_ERROR,tmod,"save_module/2"); + Yap_Error(INSTANTIATION_ERROR, tmod, "save_module/2"); return FALSE; } if (!IsAtomTerm(tmod)) { - Yap_Error(TYPE_ERROR_ATOM,tmod,"save_module/2"); + Yap_Error(TYPE_ERROR_ATOM, tmod, "save_module/2"); return FALSE; } return save_module(stream, tmod) != 0; } -static Int -qsave_program( USES_REGS1 ) -{ +static Int qsave_program(USES_REGS1) { FILE *stream; Term t1 = Deref(ARG1); - if (!(stream = Yap_GetOutputStream(t1,"save_program")) ) { + if (!(stream = Yap_GetOutputStream(t1, "save_program"))) { return FALSE; } return save_program(stream) != 0; } -static Int -qsave_file( USES_REGS1 ) -{ +static Int qsave_file(USES_REGS1) { FILE *stream; Term t1 = Deref(ARG1); Term tfile = Deref(ARG2); - if (!(stream = Yap_GetOutputStream(t1, "save_file/2") ) ) { + if (!(stream = Yap_GetOutputStream(t1, "save_file/2"))) { return FALSE; } if (IsVarTerm(tfile)) { - Yap_Error(INSTANTIATION_ERROR,tfile,"save_file/2"); + Yap_Error(INSTANTIATION_ERROR, tfile, "save_file/2"); return FALSE; } if (!IsAtomTerm(tfile)) { - Yap_Error(TYPE_ERROR_ATOM,tfile,"save_file/2"); + Yap_Error(TYPE_ERROR_ATOM, tfile, "save_file/2"); return FALSE; } - return save_file(stream, AtomOfTerm(tfile) ) != 0; + return save_file(stream, AtomOfTerm(tfile)) != 0; } -void Yap_InitQLY(void) -{ - Yap_InitCPred("$qsave_module_preds", 2, qsave_module_preds, SyncPredFlag|UserCPredFlag); - Yap_InitCPred("$qsave_program", 1, qsave_program, SyncPredFlag|UserCPredFlag); - Yap_InitCPred("$qsave_file_preds", 2, qsave_file, SyncPredFlag|UserCPredFlag); +void Yap_InitQLY(void) { + Yap_InitCPred("$qsave_module_preds", 2, qsave_module_preds, + SyncPredFlag | UserCPredFlag); + Yap_InitCPred("$qsave_program", 1, qsave_program, + SyncPredFlag | UserCPredFlag); + Yap_InitCPred("$qsave_file_preds", 2, qsave_file, + SyncPredFlag | UserCPredFlag); if (FALSE) { restore_codes(); } } /// @} - - diff --git a/C/save.c b/C/save.c index 5e3326316..721939e9d 100755 --- a/C/save.c +++ b/C/save.c @@ -1,4 +1,3 @@ - /************************************************************************* * * * YAP Prolog * @@ -9,14 +8,13 @@ * * ************************************************************************** * * - * File: save.c * - * Last rev: * - * mods: * - * comments: saving and restoring a Prolog computation * + * File: save.c * Last + *rev: * mods: + ** comments: saving and restoring a Prolog computation * * * *************************************************************************/ #ifdef SCCS -static char SccsId[] = "@(#)save.c 1.3 3/15/90"; +static char SccsId[] = "@(#)save.c 1.3 3/15/90"; #endif #include "absmi.h" @@ -25,24 +23,24 @@ static char SccsId[] = "@(#)save.c 1.3 3/15/90"; #if HAVE_WINSOCK2_H #include #endif -#include #include +#include #endif #if USE_DL_MALLOC #include "dlmalloc.h" #endif +#include "Foreign.h" #include "YapText.h" #include "sshift.h" #include "yapio.h" -#include "Foreign.h" #if HAVE_STRING_H #include #endif #if !HAVE_STRNCAT -#define strncat(X,Y,Z) strcat(X,Y) +#define strncat(X, Y, Z) strcat(X, Y) #endif #if !HAVE_STRNCPY -#define strncpy(X,Y,Z) strcpy(X,Y) +#define strncpy(X, Y, Z) strcpy(X, Y) #endif #if HAVE_FCNTL_H @@ -61,7 +59,7 @@ static char SccsId[] = "@(#)save.c 1.3 3/15/90"; /********* hack for accesing several kinds of terms. Should be cleaned **/ -static char end_msg[256] ="*** End of YAP saved state *****"; +static char end_msg[256] = "*** End of YAP saved state *****"; /* SWI IO, must be restarted after restore */ void initIO(void); @@ -87,56 +85,57 @@ void initIO(void); #endif -static int myread(FILE *, char *, Int); -static Int mywrite(FILE *, char *, Int); -static FILE *open_file(char *, int); -static int close_file(void); -static Int putout(CELL); -static Int putcellptr(CELL *); -static CELL get_cell(void); -static CELL *get_cellptr( /* CELL * */ void); -static int put_info(int, int CACHE_TYPE); -static int save_regs(int CACHE_TYPE); -static int save_code_info(void); -static int save_heap(void); -static int save_stacks(int CACHE_TYPE); -static int save_crc(void); -static Int do_save(int CACHE_TYPE); -static Int p_save2( CACHE_TYPE1 ); -static Int p_save_program( CACHE_TYPE1 ); -static int check_header(CELL *, CELL *, CELL *, CELL * CACHE_TYPE); -static int get_heap_info(CACHE_TYPE1); -static int get_regs(int CACHE_TYPE); -static int get_insts(OPCODE []); -static int get_hash(void); -static int CopyCode( CACHE_TYPE1 ); -static int CopyStacks( CACHE_TYPE1 ); -static int get_coded(int, OPCODE [] CACHE_TYPE); -static void restore_codes(void); -static void RestoreDB(DBEntry * CACHE_TYPE); -static void RestoreDBTerm(DBTerm *, bool, int CACHE_TYPE); -static void CleanClauses(yamop *First, yamop *Last, PredEntry *pp USES_REGS); -static void rehash(CELL *, int, int CACHE_TYPE); -static void CleanCode(PredEntry * CACHE_TYPE); -static void RestoreEntries(PropEntry *, int CACHE_TYPE); -static void RestoreFreeSpace( CACHE_TYPE1 ); -static void restore_heap(void); +static int myread(FILE *, char *, Int); +static Int mywrite(FILE *, char *, Int); +static FILE *open_file(const char *, int); +static int close_file(void); +static Int putout(CELL); +static Int putcellptr(CELL *); +static CELL get_cell(void); +static CELL *get_cellptr(/* CELL * */ void); +static int put_info(int, int CACHE_TYPE); +static int save_regs(int CACHE_TYPE); +static int save_code_info(void); +static int save_heap(void); +static int save_stacks(int CACHE_TYPE); +static int save_crc(void); +static Int do_save(int CACHE_TYPE); +static Int p_save2(CACHE_TYPE1); +static Int p_save_program(CACHE_TYPE1); +static int check_header(CELL *, CELL *, CELL *, CELL *CACHE_TYPE); +static int get_heap_info(CACHE_TYPE1); +static int get_regs(int CACHE_TYPE); +static int get_insts(OPCODE[]); +static int get_hash(void); +static int CopyCode(CACHE_TYPE1); +static int CopyStacks(CACHE_TYPE1); +static int get_coded(int, OPCODE[] CACHE_TYPE); +static void restore_codes(void); +static void RestoreDB(DBEntry *CACHE_TYPE); +static void RestoreDBTerm(DBTerm *, bool, int CACHE_TYPE); +static void CleanClauses(yamop *First, yamop *Last, PredEntry *pp USES_REGS); +static void rehash(CELL *, int, int CACHE_TYPE); +static void CleanCode(PredEntry *CACHE_TYPE); +static void RestoreEntries(PropEntry *, int CACHE_TYPE); +static void RestoreFreeSpace(CACHE_TYPE1); +static void restore_heap(void); #ifdef DEBUG_RESTORE3 -static void ShowAtoms(void); -static void ShowEntries(PropEntry *); +static void ShowAtoms(void); +static void ShowEntries(PropEntry *); #endif -static int OpenRestore(const char *, const char *, CELL *, CELL *, CELL *, CELL *, FILE **); -static void CloseRestore(void); +static int OpenRestore(const char *, CELL *, CELL *, CELL *, + CELL *, FILE **); +static void CloseRestore(void); #ifndef _WIN32 -static int check_opcodes(OPCODE []); +static int check_opcodes(OPCODE[]); #endif -static void RestoreHeap(OPCODE [] CACHE_TYPE); -static Int p_restore( CACHE_TYPE1 ); -static void restore_heap_regs( CACHE_TYPE1 ); -static void restore_regs(int CACHE_TYPE); +static void RestoreHeap(OPCODE[] CACHE_TYPE); +static Int p_restore(CACHE_TYPE1); +static void restore_heap_regs(CACHE_TYPE1); +static void restore_regs(int CACHE_TYPE); #ifdef MACYAP static void NewFileInfo(long, long); -extern int DefVol; +extern int DefVol; #endif #ifdef _WIN32 @@ -147,52 +146,48 @@ extern int DefVol; #ifdef LIGHT -#include #include +#include -void -LightBug(char *); +void LightBug(char *); -static void -LightBug(s) - char *s; -{ -} +static void LightBug(s) char *s; +{} -#endif /* LIGHT */ +#endif /* LIGHT */ -static Int -do_SYSTEM_ERROR_INTERNAL(yap_error_number etype, const char *msg) -{ +static Int do_SYSTEM_ERROR_INTERNAL(yap_error_number etype, const char *msg) { CACHE_REGS - LOCAL_ErrorMessage = malloc(MAX_ERROR_MSG_SIZE+1); + char *buf = malloc(1043); #if HAVE_SNPRINTF #if HAVE_STRERROR - snprintf(LOCAL_ErrorMessage,MAX_ERROR_MSG_SIZE,"%s (%s when reading %s)", msg, - strerror(errno), LOCAL_FileNameBuf); + snprintf(buf, 1043 - 1, "%s (%s when reading %s)", msg, strerror(errno), + LOCAL_FileNameBuf); #else - snprintf(LOCAL_ErrorSay,MAX_ERROR_MSG_SIZE,"%s, (system error %d when reading %s)",msg,errno,LOCAL_FileNameBuf); + snprintf(buf, 1024 - 1, "%s, (system error %d when reading %s)", msg, errno, + LOCAL_FileNameBuf); #endif #else #if HAVE_STRERROR - sprintf(LOCAL_ErrorSay,"%s, (%s when reading %s)",msg,strerror(errno),LOCAL_FileNameBuf); + snprintf(buf, 1024 - 1, "%s, (%s when reading %s)", msg, strerror(errno), + LOCAL_FileNameBuf); #else - sprintf(LOCAL_ErrorSay,"%s, (system error %d when reading %s)",msg,errno,LOCAL_FileNameBuf); + snprintf(buf, 1024 - 1, "%s, (system error %d when reading %s)", msg, errno, + LOCAL_FileNameBuf); #endif #endif LOCAL_Error_TYPE = etype; return -1; } - -inline static -int myread(FILE *fd, char *buffer, Int len) { +inline static int myread(FILE *fd, char *buffer, Int len) { size_t nread; while (len > 0) { - nread = fread(buffer, 1, (int)len, fd); + nread = fread(buffer, 1, (int)len, fd); if (nread < 1) { - return do_SYSTEM_ERROR_INTERNAL(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM,"bad read on saved state"); + return do_SYSTEM_ERROR_INTERNAL(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM, + "bad read on saved state"); } buffer += nread; len -= nread; @@ -200,15 +195,14 @@ int myread(FILE *fd, char *buffer, Int len) { return len; } -inline static -Int -mywrite(FILE *fd, char *buff, Int len) { +inline static Int mywrite(FILE *fd, char *buff, Int len) { size_t nwritten; - + while (len > 0) { nwritten = fwrite(buff, 1, (size_t)len, fd); if ((long int)nwritten < 0) { - return do_SYSTEM_ERROR_INTERNAL(SYSTEM_ERROR_INTERNAL,"bad write on saved state"); + return do_SYSTEM_ERROR_INTERNAL(SYSTEM_ERROR_INTERNAL, + "bad write on saved state"); } buff += nwritten; len -= nwritten; @@ -216,37 +210,33 @@ mywrite(FILE *fd, char *buff, Int len) { return len; } -#define FullSaved 1 +#define FullSaved 1 /* Where the code was before */ - - -typedef CELL *CELLPOINTER; +typedef CELL *CELLPOINTER; static FILE *splfild = NULL; #ifdef DEBUG #ifdef DEBUG_RESTORE4 -static FILE *errout; +static FILE *errout; #else #define errout GLOBAL_stderr #endif -#endif /* DEBUG */ +#endif /* DEBUG */ -static Int OldHeapUsed; +static Int OldHeapUsed; -static CELL which_save; +static CELL which_save; /* Open a file to read or to write */ -static FILE * -open_file(char *my_file, int flag) -{ +static FILE *open_file(const char *my_file, int flag) { FILE *splfild; char flags[6]; - int i=0; + int i = 0; if (flag & O_RDONLY) { flags[i++] = 'r'; @@ -266,57 +256,47 @@ open_file(char *my_file, int flag) } #endif flags[i] = '\0'; - splfild = fopen( my_file, flags); + splfild = fopen(my_file, flags); #ifdef undf0 fprintf(errout, "Opened file %s\n", my_file); #endif return splfild; } -static int -close_file(void) -{ +static int close_file(void) { if (splfild == 0) return 0; if (fclose(splfild) < 0) - return do_SYSTEM_ERROR_INTERNAL(SYSTEM_ERROR_INTERNAL,"bad close on saved state"); + return do_SYSTEM_ERROR_INTERNAL(SYSTEM_ERROR_INTERNAL, + "bad close on saved state"); splfild = 0; return 1; } /* stores a cell in a file */ -static Int -putout(CELL l) -{ - return mywrite(splfild, (char *) &l, sizeof(CELL)); -} +static Int putout(CELL l) { return mywrite(splfild, (char *)&l, sizeof(CELL)); } /* stores a pointer to a cell in a file */ -static Int -putcellptr(CELL *l) -{ - return mywrite(splfild, (char *) &l, sizeof(CELLPOINTER)); +static Int putcellptr(CELL *l) { + return mywrite(splfild, (char *)&l, sizeof(CELLPOINTER)); } /* gets a cell from a file */ -static CELL -get_cell(void) -{ - CELL l; - myread(splfild, (char *) &l, Unsigned(sizeof(CELL))); +static CELL get_cell(void) { + CELL l; + myread(splfild, (char *)&l, Unsigned(sizeof(CELL))); return (l); } /* gets a cell from a file */ -static CELL -get_header_cell(void) -{ +static CELL get_header_cell(void) { CELL l; size_t count = 0; int n; while (count < sizeof(CELL)) { - if ((n = fread(&l, 1, sizeof(CELL)-count, splfild)) < 0) { - do_SYSTEM_ERROR_INTERNAL(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM,"failed to read saved state header"); + if ((n = fread(&l, 1, sizeof(CELL) - count, splfild)) < 0) { + do_SYSTEM_ERROR_INTERNAL(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM, + "failed to read saved state header"); return 0L; } count += n; @@ -325,12 +305,10 @@ get_header_cell(void) } /* gets a pointer to cell from a file */ -static CELL * -get_cellptr(void) -{ - CELL *l; +static CELL *get_cellptr(void) { + CELL *l; - if (myread(splfild, (char *) &l, Unsigned(sizeof(CELLPOINTER))) < 0) + if (myread(splfild, (char *)&l, Unsigned(sizeof(CELLPOINTER))) < 0) return NULL; return (l); } @@ -339,12 +317,13 @@ get_cellptr(void) * writes the header (at the moment YAPV*), info about what kind of saved * set, the work size, and the space ocuppied */ -static int -put_info(int info, int mode USES_REGS) -{ - char msg[256]; +static int put_info(int info, int mode USES_REGS) { + char msg[256 * 16]; - sprintf(msg, "#!/bin/sh\nexec_dir=${YAPBINDIR:-%s}\nexec $exec_dir/yap $0 \"$@\"\n%cYAP-%s", YAP_BINDIR, 1, YAP_FULL_VERSION); + sprintf(msg, + "#!/bin/sh\nexec_dir=${YAPBINDIR:-%s}\nexec $exec_dir/yap $0 " + "\"$@\"\n%cYAP-%s", + YAP_BINDIR, 1, YAP_FULL_VERSION); if (mywrite(splfild, msg, strlen(msg) + 1)) return -1; if (putout(Unsigned(info)) < 0) @@ -354,19 +333,19 @@ put_info(int info, int mode USES_REGS) return -1; /* current state of stacks, to be used by SavedInfo */ /* space available in heap area */ - if (putout(Unsigned(LOCAL_GlobalBase)-Unsigned(Yap_HeapBase)) < 0) + if (putout(Unsigned(LOCAL_GlobalBase) - Unsigned(Yap_HeapBase)) < 0) return -1; /* space available for stacks */ - if (putout(Unsigned(LOCAL_LocalBase)-Unsigned(LOCAL_GlobalBase)) < 0) + if (putout(Unsigned(LOCAL_LocalBase) - Unsigned(LOCAL_GlobalBase)) < 0) return -1; /* space available for trail */ - if (putout(Unsigned(LOCAL_TrailTop)-Unsigned(LOCAL_TrailBase)) < 0) + if (putout(Unsigned(LOCAL_TrailTop) - Unsigned(LOCAL_TrailBase)) < 0) return -1; /* Space used in heap area */ - if (putout(Unsigned(HeapTop)-Unsigned(Yap_HeapBase)) < 0) + if (putout(Unsigned(HeapTop) - Unsigned(Yap_HeapBase)) < 0) return -1; /* Space used for local stack */ - if (putout(Unsigned(LCL0)-Unsigned(ASP)) < 0) + if (putout(Unsigned(LCL0) - Unsigned(ASP)) < 0) return -1; /* Space used for global stack */ if (putout(Unsigned(HR) - Unsigned(LOCAL_GlobalBase)) < 0) @@ -377,9 +356,7 @@ put_info(int info, int mode USES_REGS) return 0; } -static int -save_regs(int mode USES_REGS) -{ +static int save_regs(int mode USES_REGS) { /* save all registers */ if (putout((CELL)compile_arrays) < 0) return -1; @@ -430,7 +407,7 @@ save_regs(int mode USES_REGS) if (putout(LOCAL_WokenGoals) < 0) return -1; #endif -#ifdef DEPTH_LIMIT +#ifdef DEPTH_LIMIT if (putout(DEPTH) < 0) return -1; #endif @@ -476,7 +453,7 @@ save_regs(int mode USES_REGS) return -1; if (which_save == 2) { if (putout(ARG2) < 0) - return -1; + return -1; } if (putcellptr(CellPtr(LOCAL_TrailBase)) < 0) return -1; @@ -484,29 +461,26 @@ save_regs(int mode USES_REGS) return 0; } -static int -save_code_info(void) -{ +static int save_code_info(void) { /* First the instructions */ { op_numbers i; - OPCODE my_ops[_std_top+1]; + OPCODE my_ops[_std_top + 1]; for (i = _Ystop; i <= _std_top; ++i) my_ops[i] = Yap_opcode(i); - if (mywrite(splfild, (char *)my_ops, sizeof(OPCODE)*(_std_top+1)) < 0) + if (mywrite(splfild, (char *)my_ops, sizeof(OPCODE) * (_std_top + 1)) < 0) return -1; } /* and the current character codes */ - if (mywrite(splfild, (char *)Yap_chtype, NUMBER_OF_CHARS*sizeof(char_kind_t)) < 0) + if (mywrite(splfild, (char *)Yap_chtype, + NUMBER_OF_CHARS * sizeof(char_kind_t)) < 0) return -1; return 0; } -static int -save_heap(void) -{ +static int save_heap(void) { #ifdef USE_SYSTEM_MALLOC return -1; #endif @@ -515,14 +489,12 @@ save_heap(void) Yap_ResetConsultStack(); j = Unsigned(HeapTop) - Unsigned(Yap_HeapBase); /* store 10 more cells because of the memory manager */ - if (mywrite(splfild, (char *) Yap_HeapBase, j) < 0) + if (mywrite(splfild, (char *)Yap_HeapBase, j) < 0) return -1; return 0; } -static int -save_stacks(int mode USES_REGS) -{ +static int save_stacks(int mode USES_REGS) { int j; switch (mode) { @@ -530,38 +502,37 @@ save_stacks(int mode USES_REGS) /* Now, go and save the state */ /* Save the local stack */ j = Unsigned(LCL0) - Unsigned(ASP); - if (mywrite(splfild, (char *) ASP, j) < 0) + if (mywrite(splfild, (char *)ASP, j) < 0) return -1; /* Save the global stack */ j = Unsigned(HR) - Unsigned(LOCAL_GlobalBase); - if (mywrite(splfild, (char *) LOCAL_GlobalBase, j) < 0) + if (mywrite(splfild, (char *)LOCAL_GlobalBase, j) < 0) return -1; /* Save the trail */ j = Unsigned(TR) - Unsigned(LOCAL_TrailBase); - if (mywrite(splfild, (char *) LOCAL_TrailBase, j) < 0) + if (mywrite(splfild, (char *)LOCAL_TrailBase, j) < 0) return -1; break; - case DO_ONLY_CODE: - { - tr_fr_ptr tr_ptr = TR; - while (tr_ptr != (tr_fr_ptr)LOCAL_TrailBase) { - CELL val = TrailTerm(tr_ptr-1); - if (IsVarTerm(val)) { - CELL *d1 = VarOfTerm(val); - if (d1 < (CELL *)HeapTop) { - if (putout(val) < 0) - return -1; - } - } else if (IsPairTerm(val)) { - CELL *d1 = RepPair(val); - if (d1 < (CELL *)HeapTop) { - if (putout(val) < 0) - return -1; - } - } - tr_ptr--; + case DO_ONLY_CODE: { + tr_fr_ptr tr_ptr = TR; + while (tr_ptr != (tr_fr_ptr)LOCAL_TrailBase) { + CELL val = TrailTerm(tr_ptr - 1); + if (IsVarTerm(val)) { + CELL *d1 = VarOfTerm(val); + if (d1 < (CELL *)HeapTop) { + if (putout(val) < 0) + return -1; + } + } else if (IsPairTerm(val)) { + CELL *d1 = RepPair(val); + if (d1 < (CELL *)HeapTop) { + if (putout(val) < 0) + return -1; + } } + tr_ptr--; } + } if (putcellptr(NULL) < 0) return -1; break; @@ -569,31 +540,31 @@ save_stacks(int mode USES_REGS) return 0; } -static int -save_crc(void) -{ +static int save_crc(void) { /* Save a CRC */ return mywrite(splfild, end_msg, 256); } -static Int -do_save(int mode USES_REGS) { +static Int do_save(int mode USES_REGS) { Term t1 = Deref(ARG1); if (Yap_HoleSize) { - Yap_Error(SYSTEM_ERROR_INTERNAL,MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)), - "restore/1: address space has holes of size %ld, cannot save", (long int)Yap_HoleSize); + Yap_Error(SYSTEM_ERROR_INTERNAL, + MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)), + "restore/1: address space has holes of size %ld, cannot save", + (long int)Yap_HoleSize); return FALSE; } if (!Yap_GetName(LOCAL_FileNameBuf, YAP_FILENAME_MAX, t1)) { - Yap_Error(TYPE_ERROR_LIST,t1,"save/1"); + Yap_Error(TYPE_ERROR_LIST, t1, "save/1"); return FALSE; } - Yap_CloseStreams(TRUE); + Yap_CloseStreams(); if ((splfild = open_file(LOCAL_FileNameBuf, O_WRONLY | O_CREAT)) < 0) { - Yap_Error(SYSTEM_ERROR_INTERNAL,MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)), - "restore/1, open(%s)", strerror(errno)); - return(FALSE); + Yap_Error(SYSTEM_ERROR_INTERNAL, + MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)), + "restore/1, open(%s)", strerror(errno)); + return (FALSE); } if (put_info(FullSaved, mode PASS_REGS) < 0) return -1; @@ -612,31 +583,29 @@ do_save(int mode USES_REGS) { } /* Saves a complete prolog environment */ -static Int -p_save2( USES_REGS1 ) -{ +static Int p_save2(USES_REGS1) { Int res; yhandle_t CurSlot = Yap_StartSlots(); Term t; #ifdef YAPOR if (GLOBAL_number_workers != 1) { - Yap_Error(SYSTEM_ERROR_INTERNAL,TermNil, - "cannot perform save: more than a worker/thread running"); - return(FALSE); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, + "cannot perform save: more than a worker/thread running"); + return (FALSE); } #endif /* YAPOR */ #ifdef THREADS if (GLOBAL_NOfThreads != 1) { - Yap_Error(SYSTEM_ERROR_INTERNAL,TermNil, - "cannot perform save: more than a worker/thread running"); - return(FALSE); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, + "cannot perform save: more than a worker/thread running"); + return (FALSE); } #endif /* THREADS */ /* avoid double saves */ if (IsNonVarTerm(t = Deref(ARG2))) return TRUE; - if (!Yap_unify(ARG2,MkIntTerm(1))) + if (!Yap_unify(ARG2, MkIntTerm(1))) return FALSE; which_save = 2; CurSlot = Yap_StartSlots(); @@ -646,9 +615,7 @@ p_save2( USES_REGS1 ) } /* Just save the program, not the stacks */ -static Int -p_save_program( USES_REGS1 ) -{ +static Int p_save_program(USES_REGS1) { which_save = 0; return do_save(DO_ONLY_CODE PASS_REGS); } @@ -656,9 +623,8 @@ p_save_program( USES_REGS1 ) /* Now, to restore the saved code */ /* First check out if we are dealing with a valid file */ -static int -check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap USES_REGS) -{ +static int check_header(CELL *info, CELL *ATrail, CELL *AStack, + CELL *AHeap USES_REGS) { char pp[256]; char msg[256]; CELL hp_size, gb_size, lc_size, tr_size, mode; @@ -669,7 +635,8 @@ check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap USES_REGS) pp[0] = '\0'; do { if ((n = fread(pp, 1, 1, splfild)) <= 0) { - do_SYSTEM_ERROR_INTERNAL(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM,"failed to scan first line from saved state"); + do_SYSTEM_ERROR_INTERNAL(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM, + "failed to scan first line from saved state"); return FAIL_RESTORE; } } while (pp[0] != 1); @@ -678,17 +645,20 @@ check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap USES_REGS) { int count = 0, n, to_read = Unsigned(strlen(msg) + 1); while (count < to_read) { - if ((n = fread(pp, 1, to_read-count, splfild)) <= 0) { - do_SYSTEM_ERROR_INTERNAL(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM,"failed to scan version info from saved state"); - return FAIL_RESTORE; + if ((n = fread(pp, 1, to_read - count, splfild)) <= 0) { + do_SYSTEM_ERROR_INTERNAL( + PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM, + "failed to scan version info from saved state"); + return FAIL_RESTORE; } count += n; } } if (strcmp(pp, msg) != 0) { - strncpy(LOCAL_ErrorMessage, "saved state ", MAX_ERROR_MSG_SIZE-1); - strncat(LOCAL_ErrorMessage, LOCAL_FileNameBuf, MAX_ERROR_MSG_SIZE-1); - strncat(LOCAL_ErrorMessage, " failed to match version ID", MAX_ERROR_MSG_SIZE-1); + strncpy(LOCAL_ErrorMessage, "saved state ", MAX_ERROR_MSG_SIZE - 1); + strncat(LOCAL_ErrorMessage, LOCAL_FileNameBuf, MAX_ERROR_MSG_SIZE - 1); + strncat(LOCAL_ErrorMessage, " failed to match version ID", + MAX_ERROR_MSG_SIZE - 1); LOCAL_Error_TYPE = SYSTEM_ERROR_SAVED_STATE; return FAIL_RESTORE; } @@ -723,8 +693,8 @@ check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap USES_REGS) if (LOCAL_ErrorMessage) return FAIL_RESTORE; while (Yap_HeapBase != NULL && - hp_size > Unsigned(HeapLim) - Unsigned(Yap_HeapBase)) { - if(!Yap_growheap(FALSE, hp_size, NULL)) { + hp_size > Unsigned(HeapLim) - Unsigned(Yap_HeapBase)) { + if (!Yap_growheap(FALSE, hp_size, NULL)) { return FAIL_RESTORE; } } @@ -732,17 +702,21 @@ check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap USES_REGS) lc_size = get_cell(); if (LOCAL_ErrorMessage) return FAIL_RESTORE; - gb_size=get_cell(); + gb_size = get_cell(); if (LOCAL_ErrorMessage) return FAIL_RESTORE; - if (Yap_HeapBase != NULL && lc_size+gb_size > Unsigned(LOCAL_LocalBase) - Unsigned(LOCAL_GlobalBase)) { + if (Yap_HeapBase != NULL && + lc_size + gb_size > + Unsigned(LOCAL_LocalBase) - Unsigned(LOCAL_GlobalBase)) { if (LOCAL_ErrorMessage != NULL) - LOCAL_ErrorMessage = "could not allocate enough stack space"; + LOCAL_ErrorMessage = "could not allocate enough stack space"; return FAIL_RESTORE; } - if (Yap_HeapBase != NULL && (tr_size = get_cell()) > Unsigned(LOCAL_TrailTop) - Unsigned(LOCAL_TrailBase)) { + if (Yap_HeapBase != NULL && + (tr_size = get_cell()) > + Unsigned(LOCAL_TrailTop) - Unsigned(LOCAL_TrailBase)) { if (LOCAL_ErrorMessage != NULL) - LOCAL_ErrorMessage = "could not allocate enough trail space"; + LOCAL_ErrorMessage = "could not allocate enough trail space"; return FAIL_RESTORE; } } else { @@ -757,24 +731,22 @@ check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap USES_REGS) if (LOCAL_ErrorMessage) return FAIL_RESTORE; } - return(mode); + return (mode); } /* Gets the state of the heap, and evaluates the related variables */ -static int -get_heap_info(USES_REGS1) -{ - LOCAL_OldHeapBase = (ADDR) get_cellptr(); +static int get_heap_info(USES_REGS1) { + LOCAL_OldHeapBase = (ADDR)get_cellptr(); if (LOCAL_ErrorMessage) return -1; - LOCAL_OldHeapTop = (ADDR) get_cellptr(); + LOCAL_OldHeapTop = (ADDR)get_cellptr(); if (LOCAL_ErrorMessage) return -1; - OldHeapUsed = (Int) get_cell(); + OldHeapUsed = (Int)get_cell(); if (LOCAL_ErrorMessage) return -1; - FreeBlocks = (BlockHeader *) get_cellptr(); + FreeBlocks = (BlockHeader *)get_cellptr(); if (LOCAL_ErrorMessage) return -1; AuxBase = (ADDR)get_cellptr(); @@ -802,12 +774,10 @@ get_heap_info(USES_REGS1) /* Gets the register array */ /* Saves the old bases for the work areas */ /* and evaluates the difference from the old areas to the new ones */ -static int -get_regs(int flag USES_REGS) -{ - CELL *NewGlobalBase = (CELL *)LOCAL_GlobalBase; - CELL *NewLCL0 = LCL0; - CELL *OldXREGS; +static int get_regs(int flag USES_REGS) { + CELL *NewGlobalBase = (CELL *)LOCAL_GlobalBase; + CELL *NewLCL0 = LCL0; + CELL *OldXREGS; /* Get regs */ compile_arrays = (int)get_cell(); @@ -878,7 +848,7 @@ get_regs(int flag USES_REGS) if (LOCAL_ErrorMessage) return -1; #endif -#ifdef DEPTH_LIMIT +#ifdef DEPTH_LIMIT DEPTH = get_cell(); if (LOCAL_ErrorMessage) return -1; @@ -900,10 +870,10 @@ get_regs(int flag USES_REGS) which_save = get_cell(); if (LOCAL_ErrorMessage) return -1; - LOCAL_XDiff = (CELL)XREGS - (CELL)OldXREGS; + LOCAL_XDiff = (CELL)XREGS - (CELL)OldXREGS; if (LOCAL_ErrorMessage) return -1; - if (get_heap_info( PASS_REGS1 ) < 0) + if (get_heap_info(PASS_REGS1) < 0) return -1; if (flag == DO_EVERYTHING) { ARG1 = get_cell(); @@ -912,7 +882,7 @@ get_regs(int flag USES_REGS) if (which_save == 2) { ARG2 = get_cell(); if (LOCAL_ErrorMessage) - return -1; + return -1; } /* get old trail base */ LOCAL_OldTrailBase = (ADDR)get_cellptr(); @@ -935,24 +905,20 @@ get_regs(int flag USES_REGS) } /* Get the old opcodes and place them in a hash table */ -static int -get_insts(OPCODE old_ops[]) -{ - return myread(splfild, (char *)old_ops, sizeof(OPCODE)*(_std_top+1)); +static int get_insts(OPCODE old_ops[]) { + return myread(splfild, (char *)old_ops, sizeof(OPCODE) * (_std_top + 1)); } /* Get the old atoms hash table */ -static int -get_hash(void) -{ - return myread(splfild, (char *)Yap_chtype , NUMBER_OF_CHARS*sizeof(char_kind_t)); +static int get_hash(void) { + return myread(splfild, (char *)Yap_chtype, + NUMBER_OF_CHARS * sizeof(char_kind_t)); } /* Copy all of the old code to the new Heap */ -static int -CopyCode( USES_REGS1 ) -{ - if (myread(splfild, (char *) Yap_HeapBase, (Unsigned(LOCAL_OldHeapTop) - Unsigned(LOCAL_OldHeapBase))) < 0) { +static int CopyCode(USES_REGS1) { + if (myread(splfild, (char *)Yap_HeapBase, + (Unsigned(LOCAL_OldHeapTop) - Unsigned(LOCAL_OldHeapBase))) < 0) { return -1; } return 1; @@ -960,18 +926,16 @@ CopyCode( USES_REGS1 ) /* Copy the local and global stack and also the trail to their new home */ /* In REGS we still have nonadjusted values !! */ -static int -CopyStacks( USES_REGS1 ) -{ - Int j; - char *NewASP; +static int CopyStacks(USES_REGS1) { + Int j; + char *NewASP; j = Unsigned(LOCAL_OldLCL0) - Unsigned(ASP); - NewASP = (char *) (Unsigned(ASP) + (Unsigned(LCL0) - Unsigned(LOCAL_OldLCL0))); - if (myread(splfild, (char *) NewASP, j) < 0) + NewASP = (char *)(Unsigned(ASP) + (Unsigned(LCL0) - Unsigned(LOCAL_OldLCL0))); + if (myread(splfild, (char *)NewASP, j) < 0) return -1; j = Unsigned(HR) - Unsigned(LOCAL_OldGlobalBase); - if (myread(splfild, (char *) LOCAL_GlobalBase, j) < 0) + if (myread(splfild, (char *)LOCAL_GlobalBase, j) < 0) return -1; j = Unsigned(TR) - Unsigned(LOCAL_OldTrailBase); if (myread(splfild, LOCAL_TrailBase, j)) @@ -981,10 +945,8 @@ CopyStacks( USES_REGS1 ) /* Copy the local and global stack and also the trail to their new home */ /* In REGS we still have nonadjusted values !! */ -static int -CopyTrailEntries( USES_REGS1 ) -{ - CELL entry, *Entries; +static int CopyTrailEntries(USES_REGS1) { + CELL entry, *Entries; Entries = (CELL *)LOCAL_TrailBase; do { @@ -996,9 +958,7 @@ CopyTrailEntries( USES_REGS1 ) } /* get things which are saved in the file */ -static int -get_coded(int flag, OPCODE old_ops[] USES_REGS) -{ +static int get_coded(int flag, OPCODE old_ops[] USES_REGS) { char my_end_msg[256]; if (get_regs(flag PASS_REGS) < 0) @@ -1007,49 +967,44 @@ get_coded(int flag, OPCODE old_ops[] USES_REGS) return -1; if (get_hash() < 0) return -1; - if (CopyCode( PASS_REGS1 ) < 0) + if (CopyCode(PASS_REGS1) < 0) return -1; switch (flag) { case DO_EVERYTHING: - if (CopyStacks( PASS_REGS1 ) < 0) + if (CopyStacks(PASS_REGS1) < 0) return -1; break; case DO_ONLY_CODE: - if (CopyTrailEntries( PASS_REGS1 ) < 0) + if (CopyTrailEntries(PASS_REGS1) < 0) return -1; break; } /* Check CRC */ if (myread(splfild, my_end_msg, 256) < 0) return -1; - if (strcmp(end_msg,my_end_msg) != 0) { + if (strcmp(end_msg, my_end_msg) != 0) { LOCAL_ErrorMessage = "bad trailing CRC in saved state"; return -1; } return 1; } - - /* restore some heap registers */ -static void -restore_heap_regs( USES_REGS1 ) -{ +static void restore_heap_regs(USES_REGS1) { if (HeapTop) { HeapTop = AddrAdjust(HeapTop); - *((YAP_SEG_SIZE *) HeapTop) = InUseFlag; + *((YAP_SEG_SIZE *)HeapTop) = InUseFlag; } // HeapMax = HeapUsed = OldHeapUsed; HeapLim = LOCAL_GlobalBase; } /* adjust abstract machine registers */ -static void -restore_regs(int flag USES_REGS) -{ - restore_heap_regs( PASS_REGS1 ); +static void restore_regs(int flag USES_REGS) { + restore_heap_regs(PASS_REGS1); if (CurrentModule) { - CurrentModule = AtomTermAdjust(CurrentModule);; + CurrentModule = AtomTermAdjust(CurrentModule); + ; } if (flag == DO_EVERYTHING) { CP = PtoOpAdjust(CP); @@ -1066,11 +1021,9 @@ restore_regs(int flag USES_REGS) } } -static void -recompute_mask(DBRef dbr) -{ +static void recompute_mask(DBRef dbr) { if (dbr->Flags & DBNoVars) { - dbr->Mask = Yap_EvalMasks((Term) dbr->DBT.Entry, &(dbr->Key)); + dbr->Mask = Yap_EvalMasks((Term)dbr->DBT.Entry, &(dbr->Key)); } else if (dbr->Flags & DBComplex) { /* This is quite nasty, we want to recalculate the mask but we don't want to rebuild the whole term. We'll just build whatever we @@ -1079,39 +1032,40 @@ recompute_mask(DBRef dbr) CELL *x = (CELL *)HeapTop, *tp; unsigned int Arity, i; Term out; - char *tbase = CharP(dbr->DBT.Contents-1); + char *tbase = CharP(dbr->DBT.Contents - 1); if (IsPairTerm(dbr->DBT.Entry)) { out = AbsPair(x); Arity = 2; - tp = (CELL *)(tbase + (CELL) RepPair(dbr->DBT.Entry)); + tp = (CELL *)(tbase + (CELL)RepPair(dbr->DBT.Entry)); } else { Functor f; - tp = (CELL *)(tbase + (CELL) RepAppl(dbr->DBT.Entry)); + tp = (CELL *)(tbase + (CELL)RepAppl(dbr->DBT.Entry)); f = (Functor)(*tp++); out = AbsAppl(x); Arity = ArityOfFunctor(f); *x++ = (CELL)f; - if (Arity > 3) Arity = 3; + if (Arity > 3) + Arity = 3; } for (i = 0; i < Arity; i++) { - register Term tw = *tp++; + register Term tw = *tp++; if (IsVarTerm(tw)) { - RESET_VARIABLE(x); + RESET_VARIABLE(x); } else if (IsApplTerm(tw)) { - /* just fetch the functor from where it is in the data-base. - This guarantees we have access to references and friends. */ - CELL offset = (CELL)RepAppl(tw); - if (offset > dbr->DBT.NOfCells*sizeof(CELL)) - *x = tw; - else - *x = AbsAppl((CELL *)(tbase + offset)); + /* just fetch the functor from where it is in the data-base. + This guarantees we have access to references and friends. */ + CELL offset = (CELL)RepAppl(tw); + if (offset > dbr->DBT.NOfCells * sizeof(CELL)) + *x = tw; + else + *x = AbsAppl((CELL *)(tbase + offset)); } else if (IsAtomicTerm(tw)) { - *x = tw; + *x = tw; } else if (IsPairTerm(tw)) { - *x = AbsPair(x); + *x = AbsPair(x); } x++; } @@ -1127,27 +1081,25 @@ recompute_mask(DBRef dbr) * routine is very dependent on the hash function used, and it destroys the * previous "hit" order */ -static void -rehash(CELL *oldcode, int NOfE, int KindOfEntries USES_REGS) -{ - register CELL *savep, *basep; - CELL *oldp = oldcode; - int TableSize = NOfE - 1, NOfEntries; - register int i; - int hash; - CELL WorkTerm, failplace = 0; - CELL *Base = oldcode; +static void rehash(CELL *oldcode, int NOfE, int KindOfEntries USES_REGS) { + register CELL *savep, *basep; + CELL *oldp = oldcode; + int TableSize = NOfE - 1, NOfEntries; + register int i; + int hash; + CELL WorkTerm, failplace = 0; + CELL *Base = oldcode; if (LOCAL_HDiff == 0) return; basep = HR; - if (HR + (NOfE*2) > ASP) { + if (HR + (NOfE * 2) > ASP) { basep = (CELL *)TR; - if (basep + (NOfE*2) > (CELL *)LOCAL_TrailTop) { - if (!Yap_growtrail((ADDR)(basep + (NOfE*2))-LOCAL_TrailTop, TRUE)) { - Yap_Error(RESOURCE_ERROR_TRAIL, TermNil, - "not enough space to restore hash tables for indexing"); - Yap_exit(1); + if (basep + (NOfE * 2) > (CELL *)LOCAL_TrailTop) { + if (!Yap_growtrail((ADDR)(basep + (NOfE * 2)) - LOCAL_TrailTop, TRUE)) { + Yap_Error(RESOURCE_ERROR_TRAIL, TermNil, + "not enough space to restore hash tables for indexing"); + Yap_exit(1); } } } @@ -1170,13 +1122,13 @@ rehash(CELL *oldcode, int NOfE, int KindOfEntries USES_REGS) } oldp += 2; } - NOfEntries = (savep - basep)/2; + NOfEntries = (savep - basep) / 2; savep = basep; for (i = 0; i < NOfEntries; ++i) { - register Int d; + register Int d; CELL *hentry; - WorkTerm = savep[i*2]; + WorkTerm = savep[i * 2]; hash = (Unsigned(WorkTerm) >> HASH_SHIFT) & TableSize; hentry = Base + hash * 2; d = TableSize & (Unsigned(WorkTerm) | 1); @@ -1190,27 +1142,18 @@ rehash(CELL *oldcode, int NOfE, int KindOfEntries USES_REGS) hentry = Base + hash * 2; } hentry[0] = WorkTerm; - hentry[1] = savep[i*2+1]; + hentry[1] = savep[i * 2 + 1]; } } - -static void RestoreFlags( UInt NFlags ) -{ -} +static void RestoreFlags(UInt NFlags) {} #include "rheap.h" /* restore the atom entries which are invisible for the user */ -static void -RestoreIOStructures(void) -{ - Yap_InitStdStreams(); -} +static void RestoreIOStructures(void) { Yap_InitStdStreams(); } -static void -RestoreFreeSpace( USES_REGS1 ) -{ +static void RestoreFreeSpace(USES_REGS1) { #if USE_DL_MALLOC Yap_av = (struct malloc_state *)AddrAdjust((ADDR)Yap_av); Yap_RestoreDLMalloc(); @@ -1242,9 +1185,9 @@ RestoreFreeSpace( USES_REGS1 ) bsz = bpt->b_next = BlockAdjust(bpt->b_next); while (bsz != NULL) { if (bsz->b_next_size != NULL) - bsz->b_next_size = BlockAdjust(bsz->b_next_size); + bsz->b_next_size = BlockAdjust(bsz->b_next_size); if (bsz->b_next != NULL) - bsz->b_next = BlockAdjust(bsz->b_next); + bsz->b_next = BlockAdjust(bsz->b_next); bsz = bsz->b_next; } } @@ -1252,14 +1195,12 @@ RestoreFreeSpace( USES_REGS1 ) bpt->b_next_size = BlockAdjust(bpt->b_next_size); bpt = bpt->b_next_size; } - *((YAP_SEG_SIZE *) HeapTop) = InUseFlag; + *((YAP_SEG_SIZE *)HeapTop) = InUseFlag; #endif } -static void -RestoreAtomList(Atom atm USES_REGS) -{ - AtomEntry *at; +static void RestoreAtomList(Atom atm USES_REGS) { + AtomEntry *at; at = RepAtom(atm); if (EndOfPAEntr(at)) @@ -1270,20 +1211,18 @@ RestoreAtomList(Atom atm USES_REGS) } while (!EndOfPAEntr(at)); } - -static void -RestoreHashPreds( USES_REGS1 ) -{ +static void RestoreHashPreds(USES_REGS1) { UInt size = PredHashTableSize; bool malloced = FALSE; PredEntry **np; UInt i; PredEntry **oldp = PredHash; - np = (PredEntry **) Yap_AllocAtomSpace(sizeof(PredEntry *)*size); + np = (PredEntry **)Yap_AllocAtomSpace(sizeof(PredEntry *) * size); if (!np) { - if (!(np = (PredEntry **) malloc(sizeof(PredEntry *)*size))) { - Yap_Error(SYSTEM_ERROR_FATAL,TermNil,"Could not allocate space for pred table"); + if (!(np = (PredEntry **)malloc(sizeof(PredEntry *) * size))) { + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, + "Could not allocate space for pred table"); return; } malloced = TRUE; @@ -1301,7 +1240,7 @@ RestoreHashPreds( USES_REGS1 ) UInt hsh; if (p->NextOfPE) - p->NextOfPE = PropAdjust(p->NextOfPE); + p->NextOfPE = PropAdjust(p->NextOfPE); nextp = p->NextOfPE; CleanCode(p PASS_REGS); hsh = PRED_HASH(p->FunctorOfPred, p->ModuleOfPred, size); @@ -1322,37 +1261,30 @@ RestoreHashPreds( USES_REGS1 ) /* * This is the really tough part, to restore the whole of the heap */ -static void -restore_heap(void) -{ +static void restore_heap(void) { restore_codes(); RestoreIOStructures(); } - #ifdef DEBUG_RESTORE3 -static void -ShowEntries(pp) - PropEntry *pp; +static void ShowEntries(pp) PropEntry *pp; { while (!EndOfPAEntr(pp)) { - fprintf(GLOBAL_stderr,"Estou a ver a prop %x em %x\n", pp->KindOfPE, pp); + fprintf(GLOBAL_stderr, "Estou a ver a prop %x em %x\n", pp->KindOfPE, pp); pp = RepProp(pp->NextOfPE); } } -static void -ShowAtoms() -{ - AtomHashEntry *HashPtr = HashChain; - register int i; +static void ShowAtoms() { + AtomHashEntry *HashPtr = HashChain; + register int i; for (i = 0; i < AtomHashTableSize; ++i) { if (HashPtr->Entry != NIL) { - AtomEntry *at; + AtomEntry *at; at = RepAtom(HashPtr->Entry); do { - fprintf(GLOBAL_stderr,"Passei ao %s em %x\n", at->StrOfAE, at); - ShowEntries(RepProp(at->PropsOfAE)); + fprintf(GLOBAL_stderr, "Passei ao %s em %x\n", at->StrOfAE, at); + ShowEntries(RepProp(at->PropsOfAE)); } while (!EndOfPAEntr(at = RepAtom(at->NextOfAE))); } HashPtr++; @@ -1360,11 +1292,11 @@ ShowAtoms() HashPtr = WideHashChain; for (i = 0; i < WideAtomHashTableSize; ++i) { if (HashPtr->Entry != NIL) { - AtomEntry *at; + AtomEntry *at; at = RepAtom(HashPtr->Entry); do { - fprintf(GLOBAL_stderr,"Passei ao %s em %x\n", at->StrOfAE, at); - ShowEntries(RepProp(at->PropsOfAE)); + fprintf(GLOBAL_stderr, "Passei ao %s em %x\n", at->StrOfAE, at); + ShowEntries(RepProp(at->PropsOfAE)); } while (!EndOfPAEntr(at = RepAtom(at->NextOfAE))); } HashPtr++; @@ -1375,20 +1307,22 @@ ShowAtoms() #include -static int -commit_to_saved_state(char *s, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *AHeap) { - CACHE_REGS - int mode; +static int commit_to_saved_state(const char *s, CELL *Astate, CELL *ATrail, + CELL *AStack, CELL *AHeap) { + CACHE_REGS + int mode; + char tmp[YAP_FILENAME_MAX+1]; - if ((mode = check_header(Astate,ATrail,AStack,AHeap PASS_REGS)) == FAIL_RESTORE) - return(FAIL_RESTORE); + if ((mode = check_header(Astate, ATrail, AStack, AHeap PASS_REGS)) == + FAIL_RESTORE) + return (FAIL_RESTORE); LOCAL_PrologMode = BootMode; if (Yap_HeapBase) { - if (falseGlobalPrologFlag( HALT_AFTER_CONSULT_FLAG ) && !silentMode( )) { - Yap_findFile(s, NULL, NULL, LOCAL_FileNameBuf2, true, YAP_QLY, true, true); - fprintf(stderr, "%% Restoring file %s\n", LOCAL_FileNameBuf2); + if (falseGlobalPrologFlag(HALT_AFTER_CONSULT_FLAG) && !silentMode()) { + strcpy(tmp, Yap_AbsoluteFile(s, true)); + fprintf(stderr, "%% Restoring file %s\n", tmp); } - Yap_CloseStreams(TRUE); + Yap_CloseStreams(); } #ifdef DEBUG_RESTORE4 /* @@ -1399,7 +1333,8 @@ commit_to_saved_state(char *s, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *A return mode; } -static int try_open(char *inpf, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *AHeap, FILE **streamp) { +static int try_open(const char *inpf, CELL *Astate, CELL *ATrail, CELL *AStack, + CELL *AHeap, FILE **streamp) { int mode; if (streamp) { @@ -1411,68 +1346,60 @@ static int try_open(char *inpf, CELL *Astate, CELL *ATrail, CELL *AStack, CELL * if ((splfild = open_file(inpf, O_RDONLY)) < 0) { return FAIL_RESTORE; } - if ((mode = commit_to_saved_state(inpf,Astate,ATrail,AStack,AHeap)) != FAIL_RESTORE) { + if ((mode = commit_to_saved_state(inpf, Astate, ATrail, AStack, AHeap)) != + FAIL_RESTORE) { CACHE_REGS - LOCAL_ErrorMessage = NULL; + LOCAL_ErrorMessage = NULL; return mode; } return mode; } -static int -OpenRestore(const char *inpf, const char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *AHeap, FILE **streamp) -{ +static int OpenRestore(const char *fname, CELL *Astate, + CELL *ATrail, CELL *AStack, CELL *AHeap, + FILE **streamp) { CACHE_REGS - - int mode; - char fname[YAP_FILENAME_MAX +1]; - if (!Yap_findFile( inpf, YAP_STARTUP, YapLibDir, fname, true, YAP_SAVED_STATE, true, true)) - return false; - if (fname[0] && - (mode = try_open(fname,Astate,ATrail,AStack,AHeap,streamp)) != FAIL_RESTORE) { + int mode; + if (fname && fname[0] && (mode = try_open(fname, Astate, ATrail, AStack, AHeap, + streamp)) != FAIL_RESTORE) { + setAtomicGlobalPrologFlag(RESOURCE_DATABASE_FLAG, + MkAtomTerm(Yap_LookupAtom(fname))); return mode; } /* try to open from current directory */ /* could not open file */ if (LOCAL_ErrorMessage == NULL) { - do_SYSTEM_ERROR_INTERNAL(PERMISSION_ERROR_OPEN_SOURCE_SINK,"incorrect saved state "); + do_SYSTEM_ERROR_INTERNAL(PERMISSION_ERROR_OPEN_SOURCE_SINK, + "incorrect saved state "); } else { - strncpy(LOCAL_FileNameBuf, inpf, YAP_FILENAME_MAX-1); - do_SYSTEM_ERROR_INTERNAL(PERMISSION_ERROR_OPEN_SOURCE_SINK,"could not open saved state"); + strncpy(LOCAL_FileNameBuf, fname, YAP_FILENAME_MAX - 1); + do_SYSTEM_ERROR_INTERNAL(PERMISSION_ERROR_OPEN_SOURCE_SINK, + "could not open saved state"); } return FAIL_RESTORE; } -FILE * -Yap_OpenRestore(const char *inpf, const char *YapLibDir) -{ +FILE *Yap_OpenRestore(const char *inpf) { FILE *stream = NULL; if (!inpf) inpf = "startup.yss"; - if (!YapLibDir) { - YapLibDir = YAP_LIBDIR; - } - OpenRestore(inpf, YapLibDir, NULL, NULL, NULL, NULL, &stream); + OpenRestore(inpf, NULL, NULL, NULL, NULL, &stream); return stream; } -static void -CloseRestore(void) -{ +static void CloseRestore(void) { CACHE_REGS #ifdef DEBUG_RESTORE3 - ShowAtoms(); + ShowAtoms(); #endif close_file(); LOCAL_PrologMode = UserMode; } #if !defined(_WIN32) -static int -check_opcodes(OPCODE old_ops[]) -{ +static int check_opcodes(OPCODE old_ops[]) { #if USE_THREADED_CODE bool have_shifted = FALSE; op_numbers op = _Ystop; @@ -1490,11 +1417,9 @@ check_opcodes(OPCODE old_ops[]) } #endif -static void -RestoreHeap(OPCODE old_ops[] USES_REGS) -{ - bool heap_moved = (LOCAL_OldHeapBase != Yap_HeapBase || - LOCAL_XDiff), opcodes_moved; +static void RestoreHeap(OPCODE old_ops[] USES_REGS) { + bool heap_moved = (LOCAL_OldHeapBase != Yap_HeapBase || LOCAL_XDiff), + opcodes_moved; Term mod = CurrentModule; CurrentModule = PROLOG_MODULE; @@ -1508,7 +1433,7 @@ RestoreHeap(OPCODE old_ops[] USES_REGS) /* opcodes_moved has side-effects and should be tried first */ if (heap_moved) { opcodes_moved = TRUE; - RestoreFreeSpace( PASS_REGS1 ); + RestoreFreeSpace(PASS_REGS1); } if (heap_moved || opcodes_moved) { restore_heap(); @@ -1519,10 +1444,10 @@ RestoreHeap(OPCODE old_ops[] USES_REGS) Yap_InitCPreds(); Yap_InitBackCPreds(); } - if (!(Yap_ReInitConstExps() && - Yap_ReInitUnaryExps() && - Yap_ReInitBinaryExps())) { - Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "arithmetic operator not in saved state"); + if (!(Yap_ReInitConstExps() && Yap_ReInitUnaryExps() && + Yap_ReInitBinaryExps())) { + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, + "arithmetic operator not in saved state"); } #ifdef DEBUG_RESTORE1 fprintf(errout, "phase 1 done\n"); @@ -1534,20 +1459,20 @@ RestoreHeap(OPCODE old_ops[] USES_REGS) * This function is called to know about the parameters of the last saved * state */ -int -Yap_SavedInfo(const char *FileName, const char *YapLibDir, CELL *ATrail, CELL *AStack, CELL *AHeap) -{ +int Yap_SavedInfo(const char *FileName, CELL *ATrail, + CELL *AStack, CELL *AHeap) { return DO_ONLY_CODE; CELL MyTrail, MyStack, MyHeap, MyState; - int mode; + int mode; - mode = OpenRestore(FileName, YapLibDir, &MyState, &MyTrail, &MyStack, &MyHeap, NULL); + mode = OpenRestore(FileName, &MyState, &MyTrail, &MyStack, &MyHeap, + NULL); if (mode == FAIL_RESTORE) { return -1; } close_file(); - if (! *AHeap) + if (!*AHeap) *AHeap = MyHeap / 1024; if (mode != DO_ONLY_CODE && *AStack) *AStack = MyStack / 1024; @@ -1556,10 +1481,8 @@ Yap_SavedInfo(const char *FileName, const char *YapLibDir, CELL *ATrail, CELL *A return (MyState); } -static void -UnmarkTrEntries( USES_REGS1 ) -{ - CELL entry, *Entries; +static void UnmarkTrEntries(USES_REGS1) { + CELL entry, *Entries; /* initialize a choice point */ B = (choiceptr)LCL0; @@ -1568,34 +1491,34 @@ UnmarkTrEntries( USES_REGS1 ) Entries = (CELL *)LOCAL_TrailBase; while ((entry = *Entries++) != (CELL)NULL) { if (!IsVarTerm(entry)) { - if(IsPairTerm(entry)) { - CELL *ent = CellPtoHeapAdjust(RepPair(entry)); - register CELL flags; + if (IsPairTerm(entry)) { + CELL *ent = CellPtoHeapAdjust(RepPair(entry)); + register CELL flags; - flags = *ent; - ResetFlag(InUseMask, flags); - *ent = flags; - if (FlagOn((DirtyMask|ErasedMask), flags)) { - if (FlagOn(DBClMask, flags)) { - Yap_ErDBE(DBStructFlagsToDBStruct(ent)); - } else { - if (flags & LogUpdMask) { - if (flags & IndexMask) { - if (FlagOn(ErasedMask, flags)) - Yap_ErLogUpdIndex(ClauseFlagsToLogUpdIndex(ent)); - else - Yap_CleanUpIndex(ClauseFlagsToLogUpdIndex(ent)); - } else { - Yap_ErLogUpdCl(ClauseFlagsToLogUpdClause(ent)); - } - } else { - Yap_ErCl(ClauseFlagsToDynamicClause(ent)); - } - } - } + flags = *ent; + ResetFlag(InUseMask, flags); + *ent = flags; + if (FlagOn((DirtyMask | ErasedMask), flags)) { + if (FlagOn(DBClMask, flags)) { + Yap_ErDBE(DBStructFlagsToDBStruct(ent)); + } else { + if (flags & LogUpdMask) { + if (flags & IndexMask) { + if (FlagOn(ErasedMask, flags)) + Yap_ErLogUpdIndex(ClauseFlagsToLogUpdIndex(ent)); + else + Yap_CleanUpIndex(ClauseFlagsToLogUpdIndex(ent)); + } else { + Yap_ErLogUpdCl(ClauseFlagsToLogUpdClause(ent)); + } + } else { + Yap_ErCl(ClauseFlagsToDynamicClause(ent)); + } + } + } #ifdef MULTI_ASSIGNMENT_VARIABLES } else /* if (IsApplTerm(d1)) */ { - Entries += 2; + Entries += 2; #endif } } @@ -1603,12 +1526,10 @@ UnmarkTrEntries( USES_REGS1 ) B = NULL; } - int in_limbo = FALSE; /* cleanup any records we had in the saved state. They are now inaccessible */ -static void -FreeRecords(void) { +static void FreeRecords(void) { struct record_list *ptr; ptr = Yap_Records; @@ -1625,16 +1546,15 @@ FreeRecords(void) { * This function is called when wanting only to restore the heap and * associated registers */ -static int -Restore(char *s, char *lib_dir USES_REGS) -{ +static int Restore(char *s_dir USES_REGS) { int restore_mode; - OPCODE old_ops[_std_top+1]; + OPCODE old_ops[_std_top + 1]; CELL MyTrail, MyStack, MyHeap, MyState; - if ((restore_mode = OpenRestore(s, lib_dir, &MyState, &MyTrail, &MyStack, &MyHeap, NULL)) == FAIL_RESTORE) - return(FALSE); + if ((restore_mode = OpenRestore(s_dir, &MyState, &MyTrail, &MyStack, + &MyHeap, NULL)) == FAIL_RESTORE) + return (FALSE); Yap_ShutdownLoadForeign(); in_limbo = TRUE; if (get_coded(restore_mode, old_ops PASS_REGS) < 0) @@ -1643,17 +1563,16 @@ Restore(char *s, char *lib_dir USES_REGS) in_limbo = FALSE; /*#endif*/ RestoreHeap(old_ops PASS_REGS); - switch(restore_mode) { + switch (restore_mode) { case DO_EVERYTHING: - if (LOCAL_OldHeapBase != Yap_HeapBase || - LOCAL_OldLCL0 != LCL0 || - LOCAL_OldGlobalBase != (CELL *)LOCAL_GlobalBase || - LOCAL_OldTrailBase != LOCAL_TrailBase) { + if (LOCAL_OldHeapBase != Yap_HeapBase || LOCAL_OldLCL0 != LCL0 || + LOCAL_OldGlobalBase != (CELL *)LOCAL_GlobalBase || + LOCAL_OldTrailBase != LOCAL_TrailBase) { Yap_AdjustStacksAndTrail(); if (which_save == 2) { - Yap_AdjustRegs(2); + Yap_AdjustRegs(2); } else { - Yap_AdjustRegs(1); + Yap_AdjustRegs(1); } break; #ifdef DEBUG_RESTORE2 @@ -1662,8 +1581,8 @@ Restore(char *s, char *lib_dir USES_REGS) } break; case DO_ONLY_CODE: - UnmarkTrEntries( PASS_REGS1 ); - Yap_InitYaamRegs( 0 ); + UnmarkTrEntries(PASS_REGS1); + Yap_InitYaamRegs(0, true); break; } @@ -1675,7 +1594,7 @@ Restore(char *s, char *lib_dir USES_REGS) Yap_ReInitWTime(); #if USE_DL_MALLOC || USE_SYSTEM_MALLOC if (!AuxSp) { - Yap_InitPreAllocCodeSpace( 0 ); + Yap_InitPreAllocCodeSpace(0); } #endif CloseRestore(); @@ -1685,45 +1604,41 @@ Restore(char *s, char *lib_dir USES_REGS) return restore_mode; } -int -Yap_SavedStateRestore(char *s, char *lib_dir) -{ +int Yap_SavedStateRestore(char *s) { CACHE_REGS - return Restore(s, lib_dir PASS_REGS); + return Restore(s PASS_REGS); } -static Int -p_restore( USES_REGS1 ) -{ +static Int p_restore(USES_REGS1) { int mode; - char s[YAP_FILENAME_MAX+1]; + char s[YAP_FILENAME_MAX + 1]; Term t1 = Deref(ARG1); #ifdef YAPOR if (GLOBAL_number_workers != 1) { - Yap_Error(SYSTEM_ERROR_INTERNAL,TermNil,"cannot perform save: more than a worker/thread running"); - return(FALSE); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, + "cannot perform save: more than a worker/thread running"); + return (FALSE); } #endif /* YAPOR */ #ifdef THREADS if (GLOBAL_NOfThreads != 1) { - Yap_Error(SYSTEM_ERROR_INTERNAL,TermNil,"cannot perform save: more than a worker/thread running"); - return(FALSE); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, + "cannot perform save: more than a worker/thread running"); + return (FALSE); } #endif /* THREADS */ if (!Yap_GetName(s, YAP_FILENAME_MAX, t1)) { - Yap_Error(TYPE_ERROR_LIST,t1,"restore/1"); - return(FALSE); + Yap_Error(TYPE_ERROR_LIST, t1, "restore/1"); + return (FALSE); } - if ((mode = Restore(s, NULL PASS_REGS)) == DO_ONLY_CODE) { - Yap_RestartYap( 3 ); + if ((mode = Restore(s PASS_REGS)) == DO_ONLY_CODE) { + Yap_RestartYap(3); } - return(mode != FAIL_RESTORE); + return (mode != FAIL_RESTORE); } -void -Yap_InitSavePreds(void) -{ +void Yap_InitSavePreds(void) { Yap_InitCPred("$save", 2, p_save2, SyncPredFlag); Yap_InitCPred("$save_program", 1, p_save_program, SyncPredFlag); Yap_InitCPred("$restore", 1, p_restore, SyncPredFlag); diff --git a/C/scanner.c b/C/scanner.c index c5bde12e0..f401e94f5 100755 --- a/C/scanner.c +++ b/C/scanner.c @@ -1,19 +1,19 @@ /************************************************************************* -* * -* YAP Prolog * -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-2003 * -* * -************************************************************************** -* * -* File: %W% %G% * -* Last rev: 22-1-03 * -* mods: * -* comments: Prolog's scanner * -* * -*************************************************************************/ + * * + * YAP Prolog * + * * + * Yap Prolog was developed at NCCUP - Universidade do Porto * + * * + * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-2003 * + * * + ************************************************************************** + * * + * File: %W% %G% * + * Last rev: 22-1-03 * + * mods: * + * comments: Prolog's scanner * + * * + *************************************************************************/ /* * Description: @@ -404,10 +404,10 @@ writing, writing a BOM can be requested using the option */ #include "Yap.h" +#include "YapEval.h" #include "YapHeap.h" #include "Yatom.h" #include "alloc.h" -#include "YapEval.h" #include "yapio.h" /* stuff we want to use in standard YAP code */ #include "YapText.h" @@ -447,7 +447,7 @@ static void Yap_setCurrentSourceLocation(struct stream_desc *s) { if (s->status & Pipe_Stream_f) LOCAL_SourceFileName = AtomPipe; else if (s->status & InMemory_Stream_f) - LOCAL_SourceFileName = AtomCharsio; + LOCAL_SourceFileName = s->name; else LOCAL_SourceFileName = s->name; LOCAL_SourceFileLineno = s->linecount; @@ -462,7 +462,7 @@ char_kind_t Yap_chtype0[NUMBER_OF_CHARS + 1] = { BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, /* dle dc1 dc2 dc3 dc4 nak syn etb can em sub esc fs gs rs us - */ + */ BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, /* sp ! " # $ % & ' ( ) * + , - . / */ @@ -484,11 +484,11 @@ char_kind_t Yap_chtype0[NUMBER_OF_CHARS + 1] = { LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, BK, BK, BK, SY, BS, /* 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 - */ + */ BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, /* 144 145 ’ 147 148 149 150 151 152 153 154 155 156 157 158 159 - */ + */ BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, /* ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ­ ® ¯ */ @@ -532,13 +532,22 @@ typedef struct scanner_internals { // standard get char, uses conversion table // and converts to wide -#define getchr(inp) inp->stream_wgetc_for_read(inp - GLOBAL_Stream) +static inline int getchr(struct stream_desc *inp) { + /* if (inp != inp0) { fprintf(stderr,"\n %s + * **********************************\n", AtomName(inp->name)); */ + /* inp0 = inp; */ + /* } */ + int sno = inp - GLOBAL_Stream; + int ch = inp->stream_wgetc_for_read(sno); + // fprintf(stderr,"%c", ch); + return ch; +} // get char for quoted data, eg, quoted atoms and so on // converts to wide -#define getchrq(inp) inp->stream_wgetc(inp - GLOBAL_Stream) -// get char for UTF-8 quoted data, eg, quoted strings -// reads bytes -#define getchru(inp) inp->stream_getc_utf8(inp - GLOBAL_Stream) +static inline int getchrq(struct stream_desc *inp) { + int ch = inp->stream_wgetc(inp - GLOBAL_Stream); + return ch; +} /* in case there is an overflow */ typedef struct scanner_extra_alloc { @@ -603,7 +612,7 @@ static char *AllocScannerMemory(unsigned int size) { if (LOCAL_ScannerExtraBlocks) { struct scanner_extra_alloc *ptr; - if (!(ptr = (struct scanner_extra_alloc *)malloc( + if (!(ptr = (struct scanner_extra_alloc *)Malloc( size + sizeof(ScannerExtraBlock)))) { return NULL; } @@ -618,7 +627,7 @@ static char *AllocScannerMemory(unsigned int size) { if (!Yap_growtrail(alloc_size, TRUE)) { struct scanner_extra_alloc *ptr; - if (!(ptr = (struct scanner_extra_alloc *)malloc( + if (!(ptr = (struct scanner_extra_alloc *)Malloc( size + sizeof(ScannerExtraBlock)))) { return NULL; } @@ -658,7 +667,7 @@ static Term float_send(char *s, int sign) { #endif { CACHE_REGS - return (MkEvalFl(f)); + return MkFloatTerm(f); } } @@ -688,13 +697,12 @@ static int send_error_message(char s[]) { return 0; } -static wchar_t read_quoted_char(int *scan_nextp, - struct stream_desc *inp_stream) { +static wchar_t read_quoted_char(int *scan_nextp, struct stream_desc *st) { int ch; /* escape sequence */ do_switch: - ch = getchrq(inp_stream); + ch = getchrq(st); switch (ch) { case 10: return 0; @@ -705,7 +713,7 @@ do_switch: case 'b': return '\b'; case 'c': - while (chtype((ch = getchrq(inp_stream))) == BS) + while (chtype((ch = getchrq(st))) == BS) ; { if (ch == '\\') { @@ -732,7 +740,7 @@ do_switch: wchar_t wc = '\0'; for (i = 0; i < 4; i++) { - ch = getchrq(inp_stream); + ch = getchrq(st); if (ch >= '0' && ch <= '9') { wc += (ch - '0') << ((3 - i) * 4); } else if (ch >= 'a' && ch <= 'f') { @@ -750,7 +758,7 @@ do_switch: wchar_t wc = '\0'; for (i = 0; i < 8; i++) { - ch = getchrq(inp_stream); + ch = getchrq(st); if (ch >= '0' && ch <= '9') { wc += (ch - '0') << ((7 - i) * 4); } else if (ch >= 'a' && ch <= 'f') { @@ -777,7 +785,7 @@ do_switch: if (trueGlobalPrologFlag(ISO_FLAG)) { return send_error_message("invalid escape sequence"); } else { - ch = getchrq(inp_stream); + ch = getchrq(st); if (ch == '?') { /* delete character */ return 127; } else if (ch >= 'a' && ch < 'z') { /* hexa */ @@ -800,13 +808,13 @@ do_switch: /* follow ISO */ { unsigned char so_far = ch - '0'; - ch = getchrq(inp_stream); + ch = getchrq(st); if (ch >= '0' && ch < '8') { /* octal */ so_far = so_far * 8 + (ch - '0'); - ch = getchrq(inp_stream); + ch = getchrq(st); if (ch >= '0' && ch < '8') { /* octal */ so_far = so_far * 8 + (ch - '0'); - ch = getchrq(inp_stream); + ch = getchrq(st); if (ch != '\\') { return send_error_message("invalid octal escape sequence"); } @@ -826,19 +834,19 @@ do_switch: /* hexadecimal character (YAP allows empty hexadecimal */ { unsigned char so_far = 0; - ch = getchrq(inp_stream); + ch = getchrq(st); if (my_isxdigit(ch, 'f', 'F')) { /* hexa */ so_far = so_far * 16 + (chtype(ch) == NU ? ch - '0' : (my_isupper(ch) ? ch - 'A' : ch - 'a') + 10); - ch = getchrq(inp_stream); + ch = getchrq(st); if (my_isxdigit(ch, 'f', 'F')) { /* hexa */ so_far = so_far * 16 + (chtype(ch) == NU ? ch - '0' : (my_isupper(ch) ? ch - 'A' : ch - 'a') + 10); - ch = getchrq(inp_stream); + ch = getchrq(st); if (ch == '\\') { return so_far; } else { @@ -866,16 +874,16 @@ do_switch: static int num_send_error_message(char s[]) { CACHE_REGS LOCAL_ErrorMessage = s; - return TermNil; + return MkStringTerm(s); } #define number_overflow() \ { \ - size_t nsz = min(max_size * 2, max_size); \ + size_t nsz = Yap_Min(max_size * 2, max_size); \ char *nbuf; \ \ if (buf == buf0) { \ - nbuf = malloc(nsz); \ + nbuf = Malloc(nsz); \ } else { \ nbuf = realloc(buf, nsz); \ } \ @@ -890,7 +898,7 @@ static int num_send_error_message(char s[]) { /* reads a number, either integer or float */ -static Term get_num(int *chp, int *chbuffp, StreamDesc *inp_stream, int sign) { +static Term get_num(int *chp, int *chbuffp, StreamDesc *st, int sign) { int ch = *chp; Int val = 0L, base = ch - '0'; int might_be_float = TRUE, has_overflow = FALSE; @@ -899,7 +907,7 @@ static Term get_num(int *chp, int *chbuffp, StreamDesc *inp_stream, int sign) { int max_size = 254, left = 254; *sp++ = ch; - ch = getchr(inp_stream); + ch = getchr(st); /* * because of things like 00'2, 03'2 and even better 12'2, I need to * do this (have mercy) @@ -909,17 +917,17 @@ static Term get_num(int *chp, int *chbuffp, StreamDesc *inp_stream, int sign) { if (--left == 0) number_overflow(); base = 10 * base + ch - '0'; - ch = getchr(inp_stream); + ch = getchr(st); } if (ch == '\'') { if (base > 36) { - return num_send_error_message("Admissible bases are 0..36"); + Yap_ThrowError(SYNTAX_ERROR, MkIntegerTerm(base), "Admissible bases are 0..36"); } might_be_float = FALSE; if (--left == 0) number_overflow(); *sp++ = ch; - ch = getchr(inp_stream); + ch = getchr(st); if (base == 0) { CACHE_REGS wchar_t ascii = ch; @@ -927,11 +935,11 @@ static Term get_num(int *chp, int *chbuffp, StreamDesc *inp_stream, int sign) { if (ch == '\\' && Yap_GetModuleEntry(CurrentModule)->flags & M_CHARESCAPE) { - ascii = read_quoted_char(&scan_extra, inp_stream); + ascii = read_quoted_char(&scan_extra, st); } /* a quick way to represent ASCII */ if (scan_extra) - *chp = getchr(inp_stream); + *chp = getchr(st); if (sign == -1) { return MkIntegerTerm(-ascii); } @@ -951,7 +959,7 @@ static Term get_num(int *chp, int *chbuffp, StreamDesc *inp_stream, int sign) { val = oval * base + chval; if (oval != (val - chval) / base) /* overflow */ has_overflow = (has_overflow || TRUE); - ch = getchr(inp_stream); + ch = getchr(st); } } } else if (ch == 'x' && base == 0) { @@ -959,7 +967,13 @@ static Term get_num(int *chp, int *chbuffp, StreamDesc *inp_stream, int sign) { if (--left == 0) number_overflow(); *sp++ = ch; - ch = getchr(inp_stream); + ch = getchr(st); + if (!my_isxdigit(ch, 'F', 'f')) { + Term t = ( Yap_local.ActiveError->errorRawTerm ? Yap_local.ActiveError->errorRawTerm : MkIntegerTerm(ch) ); + Yap_local.ActiveError->errorRawTerm = 0; + Yap_ThrowError(SYNTAX_ERROR, t, "invalid hexadecimal digit 0x%C",ch) ; + return 0; + } while (my_isxdigit(ch, 'F', 'f')) { Int oval = val; int chval = @@ -971,17 +985,32 @@ static Term get_num(int *chp, int *chbuffp, StreamDesc *inp_stream, int sign) { val = val * 16 + chval; if (oval != (val - chval) / 16) /* overflow */ has_overflow = TRUE; - ch = getchr(inp_stream); + ch = getchr(st); + } *chp = ch; } else if (ch == 'o' && base == 0) { - might_be_float = FALSE; + might_be_float = false; base = 8; - ch = getchr(inp_stream); + ch = getchr(st); + if (ch < '0' || ch > '7') { + Term t = ( Yap_local.ActiveError->errorRawTerm ? Yap_local.ActiveError->errorRawTerm : MkIntegerTerm(ch) ); + Yap_local.ActiveError->errorRawTerm = 0; + Yap_ThrowError(SYNTAX_ERROR, t, "invalid octal digit 0x%C",ch) ; + return 0; + } } else if (ch == 'b' && base == 0) { - might_be_float = FALSE; + might_be_float = false; base = 2; - ch = getchr(inp_stream); + ch = getchr(st); + if (ch < '0' || ch > '1') { + Term t = ( Yap_local.ActiveError->errorRawTerm ? Yap_local.ActiveError->errorRawTerm : MkIntegerTerm(ch) ); + Yap_local.ActiveError->errorRawTerm = 0; + Yap_ThrowError(SYNTAX_ERROR, t, "invalid binary digit 0x%C",ch) ; + return 0; + } + + } else { val = base; base = 10; @@ -1001,16 +1030,15 @@ static Term get_num(int *chp, int *chbuffp, StreamDesc *inp_stream, int sign) { } val = val * base + ch - '0'; if (val / base != oval || val - oval * base != ch - '0') /* overflow */ - has_overflow = TRUE; - ch = getchr(inp_stream); + has_overflow = true; + ch = getchr(st); } if (might_be_float && (ch == '.' || ch == 'e' || ch == 'E')) { int has_dot = (ch == '.'); if (has_dot) { unsigned char *dp; int dc; - - if (chtype(ch = getchr(inp_stream)) != NU) { + if (chtype(ch = getchr(st)) != NU) { if (ch == 'e' || ch == 'E') { if (trueGlobalPrologFlag(ISO_FLAG)) return num_send_error_message( @@ -1045,21 +1073,21 @@ static Term get_num(int *chp, int *chbuffp, StreamDesc *inp_stream, int sign) { if (--left == 0) number_overflow(); *sp++ = ch; - } while (chtype(ch = getchr(inp_stream)) == NU); + } while (chtype(ch = getchr(st)) == NU); } } if (ch == 'e' || ch == 'E') { if (--left == 0) number_overflow(); *sp++ = ch; - ch = getchr(inp_stream); + ch = getchr(st); if (ch == '-') { if (--left == 0) number_overflow(); *sp++ = '-'; - ch = getchr(inp_stream); + ch = getchr(st); } else if (ch == '+') { - ch = getchr(inp_stream); + ch = getchr(st); } if (chtype(ch) != NU) { CACHE_REGS @@ -1071,7 +1099,7 @@ static Term get_num(int *chp, int *chbuffp, StreamDesc *inp_stream, int sign) { if (--left == 0) number_overflow(); *sp++ = ch; - } while (chtype(ch = getchr(inp_stream)) == NU); + } while (chtype(ch = getchr(st)) == NU); } *sp = '\0'; *chp = ch; @@ -1104,7 +1132,7 @@ Term Yap_scan_num(StreamDesc *inp, bool error_on) { CACHE_REGS Term out; int sign = 1; - int ch, cherr; + int ch, cherr = 0; char *ptr; void *old_tr = TR; @@ -1123,6 +1151,7 @@ Term Yap_scan_num(StreamDesc *inp, bool error_on) { ; #endif TokEntry *tokptr = (TokEntry *)AllocScannerMemory(sizeof(TokEntry)); + tokptr->TokLine = GetCurInpLine(inp); tokptr->TokPos = GetCurInpPos(inp); if (ch == '-') { sign = -1; @@ -1149,13 +1178,9 @@ Term Yap_scan_num(StreamDesc *inp, bool error_on) { while (isspace(ch = getchr(inp))) ; #endif - if (LOCAL_ErrorMessage != NULL || ch != -1 || cherr) { - Yap_clean_tokenizer(old_tr, NULL, NULL); - if (error_on) - Yap_Error(SYNTAX_ERROR, ARG2, "converting number"); - return 0; - } + if (ch == EOF) return out; + return 0; } #define CHECK_SPACE() \ @@ -1180,13 +1205,15 @@ Term Yap_tokRep(void *tokptre) { case Name_tok: if (!info) { info = TermNil; + } else { + info = MkAtomTerm((Atom)info); } return Yap_MkApplTerm(Yap_MkFunctor(AtomAtom, 1), 1, &info); case QuasiQuotes_tok: info = MkAtomTerm(Yap_LookupAtom("")); return Yap_MkApplTerm(Yap_MkFunctor(AtomAtom, 1), 1, &info); case Number_tok: - return Yap_MkApplTerm(Yap_MkFunctor(AtomAtom, 1), 1, &info); + return Yap_MkApplTerm(Yap_MkFunctor(AtomNumber, 1), 1, &info); break; case Var_tok: { Term t[2]; @@ -1223,8 +1250,8 @@ const char *Yap_tokText(void *tokptre) { case eot_tok: return "EOT"; case Ponctuation_tok: - if (info == Terml) - return "("; + if (info == Terml) + return "("; case Error_tok: case BQString_tok: case String_tok: @@ -1255,7 +1282,7 @@ const char *Yap_tokText(void *tokptre) { return "."; } -static void open_comment(int ch, StreamDesc *inp_stream USES_REGS) { +static void open_comment(int ch, StreamDesc *st USES_REGS) { CELL *h0 = HR; HR += 5; h0[0] = AbsAppl(h0 + 2); @@ -1270,10 +1297,10 @@ static void open_comment(int ch, StreamDesc *inp_stream USES_REGS) { LOCAL_CommentsTail = h0 + 1; h0 += 2; h0[0] = (CELL)FunctorMinus; - h0[1] = Yap_StreamPosition(inp_stream - GLOBAL_Stream); + h0[1] = Yap_StreamPosition(st - GLOBAL_Stream); h0[2] = TermNil; LOCAL_CommentsNextChar = h0 + 2; - LOCAL_CommentsBuff = (wchar_t *)malloc(1024 * sizeof(wchar_t)); + LOCAL_CommentsBuff = (wchar_t *)Malloc(1024 * sizeof(wchar_t)); LOCAL_CommentsBuffLim = 1024; LOCAL_CommentsBuff[0] = ch; LOCAL_CommentsBuffPos = 1; @@ -1292,21 +1319,21 @@ static void extend_comment(int ch USES_REGS) { static void close_comment(USES_REGS1) { LOCAL_CommentsBuff[LOCAL_CommentsBuffPos] = '\0'; *LOCAL_CommentsNextChar = Yap_WCharsToString(LOCAL_CommentsBuff PASS_REGS); - free(LOCAL_CommentsBuff); + Free(LOCAL_CommentsBuff); LOCAL_CommentsBuff = NULL; LOCAL_CommentsBuffLim = 0; } // mark that we reached EOF, // next token will be end_of_file) -static void mark_eof(struct stream_desc *inp_stream) { - inp_stream->status |= Push_Eof_Stream_f; +static void mark_eof(struct stream_desc *st) { + st->status |= Push_Eof_Stream_f; } #define add_ch_to_buff(ch) \ { charp += put_utf8(charp, ch); } -TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, +TokEntry *Yap_tokenizer(struct stream_desc *st, bool store_comments, Term *tposp) { CACHE_REGS @@ -1322,14 +1349,15 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, LOCAL_AnonVarTable = NULL; l = NULL; p = NULL; /* Just to make lint happy */ - ch = getchr(inp_stream); + ch = getchr(st); while (chtype(ch) == BS) { - ch = getchr(inp_stream); + och=ch; + ch = getchr(st); } - *tposp = Yap_StreamPosition(inp_stream - GLOBAL_Stream); - Yap_setCurrentSourceLocation(inp_stream); - LOCAL_StartLineCount = inp_stream->linecount; - LOCAL_StartLinePos = inp_stream->linepos; + *tposp = Yap_StreamPosition(st - GLOBAL_Stream); + Yap_setCurrentSourceLocation(st); + LOCAL_StartLineCount = st->linecount; + LOCAL_StartLinePos = st->linepos; do { int quote, isvar; unsigned char *charp, *mp; @@ -1348,22 +1376,23 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, p = t; restart: while (chtype(ch) == BS) { - ch = getchr(inp_stream); + ch = getchr(st); } - t->TokPos = GetCurInpPos(inp_stream); + t->TokPos = GetCurInpPos(st); + t->TokLine = GetCurInpLine(st); switch (chtype(ch)) { case CC: if (store_comments) { - open_comment(ch, inp_stream PASS_REGS); + open_comment(ch, st PASS_REGS); continue_comment: - while ((ch = getchr(inp_stream)) != 10 && chtype(ch) != EF) { + while ((ch = getchr(st)) != 10 && chtype(ch) != EF) { extend_comment(ch PASS_REGS); } extend_comment(ch PASS_REGS); if (chtype(ch) != EF) { - ch = getchr(inp_stream); + ch = getchr(st); if (chtype(ch) == CC) { extend_comment(ch PASS_REGS); goto continue_comment; @@ -1371,7 +1400,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, } close_comment(PASS_REGS1); } else { - while ((ch = getchr(inp_stream)) != 10 && chtype(ch) != EF) + while ((ch = getchr(st)) != 10 && chtype(ch) != EF) ; } if (chtype(ch) != EF) { @@ -1379,15 +1408,15 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, if (t == l) { /* we found a comment before reading characters */ while (chtype(ch) == BS) { - ch = getchr(inp_stream); + ch = getchr(st); } - *tposp = Yap_StreamPosition(inp_stream - GLOBAL_Stream); - Yap_setCurrentSourceLocation(inp_stream); + *tposp = Yap_StreamPosition(st - GLOBAL_Stream); + Yap_setCurrentSourceLocation(st); } goto restart; } else { t->Tok = Ord(kind = eot_tok); - mark_eof(inp_stream); + mark_eof(st); t->TokInfo = TermEof; } break; @@ -1396,22 +1425,22 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, case UL: case LC: { int32_t och = ch; - ch = getchr(inp_stream); + ch = getchr(st); size_t sz = 512; TokImage = Malloc(sz PASS_REGS); scan_name: charp = (unsigned char *)TokImage; isvar = (chtype(och) != LC); add_ch_to_buff(och); - for (; chtype(ch) <= NU; ch = getchr(inp_stream)) { + for (; chtype(ch) <= NU; ch = getchr(st)) { if (charp == TokImage + (sz - 1)) { unsigned char *p0 = TokImage; - sz = min(sz * 2, sz + MBYTE); + sz = Yap_Min(sz * 2, sz + MBYTE); TokImage = Realloc(p0, sz); if (TokImage == NULL) { return CodeSpaceError(t, p, l); } - charp = TokImage - (charp - p0); + charp = TokImage + (charp - p0); } add_ch_to_buff(ch); } @@ -1421,7 +1450,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, return CodeSpaceError(t, p, l); } add_ch_to_buff(ch); - ch = getchr(inp_stream); + ch = getchr(st); } add_ch_to_buff('\0'); if (!isvar) { @@ -1457,8 +1486,8 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, cha = ch; cherr = 0; CHECK_SPACE(); - if ((t->TokInfo = get_num(&cha, &cherr, inp_stream, sign)) == 0L) { - if (p) { + if ((t->TokInfo = get_num(&cha, &cherr, st, sign)) == 0L) { + if (t->TokInfo == 0) { p->Tok = eot_tok; t->TokInfo = TermError; } @@ -1469,7 +1498,8 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, if (cherr) { TokEntry *e; t->Tok = Number_tok; - t->TokPos = GetCurInpPos(inp_stream); + t->TokPos = GetCurInpPos(st); + t->TokLine = GetCurInpLine(st); e = (TokEntry *)AllocScannerMemory(sizeof(TokEntry)); if (e == NULL) { return TrailSpaceError(p, l); @@ -1495,7 +1525,8 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, t->Tok = Ord(Var_tok); t->TokInfo = (Term)Yap_LookupVar("E"); - t->TokPos = GetCurInpPos(inp_stream); + t->TokPos = GetCurInpPos(st); + t->TokLine = GetCurInpLine(st); e2 = (TokEntry *)AllocScannerMemory(sizeof(TokEntry)); if (e2 == NULL) { return TrailSpaceError(p, l); @@ -1528,7 +1559,8 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, if (ch == '(') solo_flag = FALSE; t->TokInfo = MkAtomTerm(AtomE); - t->TokPos = GetCurInpPos(inp_stream); + t->TokLine = GetCurInpLine(st); + t->TokPos = GetCurInpPos(st); e2 = (TokEntry *)AllocScannerMemory(sizeof(TokEntry)); if (e2 == NULL) { return TrailSpaceError(p, l); @@ -1555,12 +1587,12 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, charp = TokImage; quote = ch; len = 0; - ch = getchrq(inp_stream); + ch = getchrq(st); size_t sz = 1024; while (TRUE) { if (charp > TokImage + (sz - 1)) { - TokImage = Realloc(TokImage, min(sz * 2, sz + MBYTE)); + TokImage = Realloc(TokImage, Yap_Min(sz * 2, sz + MBYTE)); if (TokImage == NULL) { return CodeSpaceError(t, p, l); } @@ -1575,23 +1607,23 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, break; } if (ch == quote) { - ch = getchrq(inp_stream); + ch = getchrq(st); if (ch != quote) break; add_ch_to_buff(ch); - ch = getchrq(inp_stream); + ch = getchrq(st); } else if (ch == '\\' && Yap_GetModuleEntry(CurrentModule)->flags & M_CHARESCAPE) { int scan_next = TRUE; - if ((ch = read_quoted_char(&scan_next, inp_stream))) { + if ((ch = read_quoted_char(&scan_next, st))) { add_ch_to_buff(ch); } if (scan_next) { - ch = getchrq(inp_stream); + ch = getchrq(st); } } else { add_ch_to_buff(ch); - ch = getchrq(inp_stream); + ch = getchrq(st); } ++len; } @@ -1602,7 +1634,6 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, if (!(t->TokInfo)) { return CodeSpaceError(t, p, l); } - Free(TokImage); t->Tok = Ord(kind = String_tok); } else if (quote == '`') { t->TokInfo = Yap_CharsToTBQ((char *)TokImage, CurrentModule, @@ -1610,7 +1641,6 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, if (!(t->TokInfo)) { return CodeSpaceError(t, p, l); } - Free(TokImage); t->Tok = Ord(kind = String_tok); } else { t->TokInfo = MkAtomTerm(Yap_ULookupAtom(TokImage)); @@ -1628,9 +1658,9 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, if (ch == '\0') { int pch; t->Tok = Ord(kind = eot_tok); - pch = Yap_peek(inp_stream - GLOBAL_Stream); + pch = Yap_peek(st - GLOBAL_Stream); if (chtype(pch) == EF) { - mark_eof(inp_stream); + mark_eof(st); t->TokInfo = TermEof; } else { t->TokInfo = TermNewLine; @@ -1638,12 +1668,14 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, t->TokInfo = TermEof; return l; } else - ch = getchr(inp_stream); + ch = getchr(st); break; case SY: { int pch; - if (ch == '.' && (pch = Yap_peek(inp_stream - GLOBAL_Stream)) && + if (ch == '.' && (pch = Yap_peek(st - GLOBAL_Stream)) && (chtype(pch) == BS || chtype(pch) == EF || pch == '%')) { + if (chtype(ch) != EF) + getchr(st); t->Tok = Ord(kind = eot_tok); // consume... if (pch == '%') { @@ -1655,7 +1687,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, if (ch == '`') goto quoted_string; och = ch; - ch = getchr(inp_stream); + ch = getchr(st); if (och == '.') { if (chtype(ch) == BS || chtype(ch) == EF || ch == '%') { t->Tok = Ord(kind = eot_tok); @@ -1664,7 +1696,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, return l; } if (chtype(ch) == EF) { - mark_eof(inp_stream); + mark_eof(st); t->TokInfo = TermEof; } else { t->TokInfo = TermNewLine; @@ -1675,12 +1707,12 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, if (och == '/' && ch == '*') { if (store_comments) { CHECK_SPACE(); - open_comment('/', inp_stream PASS_REGS); + open_comment('/', st PASS_REGS); while ((och != '*' || ch != '/') && chtype(ch) != EF) { och = ch; CHECK_SPACE(); extend_comment(ch PASS_REGS); - ch = getchr(inp_stream); + ch = getchr(st); } if (chtype(ch) != EF) { CHECK_SPACE(); @@ -1690,7 +1722,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, } else { while ((och != '*' || ch != '/') && chtype(ch) != EF) { och = ch; - ch = getchr(inp_stream); + ch = getchr(st); } } if (chtype(ch) == EF) { @@ -1699,15 +1731,15 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, break; } else { /* leave comments */ - ch = getchr(inp_stream); + ch = getchr(st); if (t == l) { /* we found a comment before reading characters */ while (chtype(ch) == BS) { - ch = getchr(inp_stream); + ch = getchr(st); } CHECK_SPACE(); - *tposp = Yap_StreamPosition(inp_stream - GLOBAL_Stream); - Yap_setCurrentSourceLocation(inp_stream); + *tposp = Yap_StreamPosition(st - GLOBAL_Stream); + Yap_setCurrentSourceLocation(st); } } goto restart; @@ -1721,7 +1753,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, return l; } if (chtype(ch) == EF) { - mark_eof(inp_stream); + mark_eof(st); t->TokInfo = TermEof; } else { t->TokInfo = TermNl; @@ -1733,9 +1765,9 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, TokImage = Malloc(sz); charp = TokImage; add_ch_to_buff(och); - for (; chtype(ch) == SY; ch = getchr(inp_stream)) { + for (; chtype(ch) == SY; ch = getchr(st)) { if (charp >= TokImage + (sz - 10)) { - sz = min(sz * 2, sz + MBYTE); + sz = Yap_Min(sz * 2, sz + MBYTE); TokImage = Realloc(TokImage, sz); if (!TokImage) return CodeSpaceError(t, p, l); @@ -1764,7 +1796,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, unsigned char chs[2]; chs[0] = ch; chs[1] = '\0'; - ch = getchr(inp_stream); + ch = getchr(st); t->TokInfo = MkAtomTerm(Yap_ULookupAtom(chs)); t->Tok = Ord(kind = Name_tok); if (ch == '(') @@ -1773,7 +1805,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, case BK: och = ch; - ch = getchr(inp_stream); + ch = getchr(st); { unsigned char chs[10]; TokImage = charp = chs; @@ -1783,12 +1815,12 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, } if (och == '(') { while (chtype(ch) == BS) { - ch = getchr(inp_stream); + ch = getchr(st); } if (ch == ')') { t->TokInfo = TermEmptyBrackets; t->Tok = Ord(kind = Name_tok); - ch = getchr(inp_stream); + ch = getchr(st); solo_flag = FALSE; break; } else if (!solo_flag) { @@ -1797,12 +1829,12 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, } } else if (och == '[') { while (chtype(ch) == BS) { - ch = getchr(inp_stream); + ch = getchr(st); }; if (ch == ']') { t->TokInfo = TermNil; t->Tok = Ord(kind = Name_tok); - ch = getchr(inp_stream); + ch = getchr(st); solo_flag = FALSE; break; } @@ -1811,7 +1843,6 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, qq_t *qq = (qq_t *)calloc(sizeof(qq_t), 1); if (!qq) { LOCAL_ErrorMessage = "not enough heap space to read in quasi quote"; - Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); t->Tok = Ord(kind = eot_tok); t->TokInfo = TermOutOfHeapError; return l; @@ -1821,32 +1852,32 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); t->Tok = Ord(kind = eot_tok); t->TokInfo = TermOutOfHeapError; - free(qq); + Free(qq); return l; } else { cur_qq = qq; } t->TokInfo = (CELL)qq; - if (inp_stream->status & Seekable_Stream_f) { - qq->start.byteno = fseek(inp_stream->file, 0, 0); + if (st->status & Seekable_Stream_f) { + qq->start.byteno = fseek(st->file, 0, 0); } else { - qq->start.byteno = inp_stream->charcount - 1; + qq->start.byteno = st->charcount - 1; } - qq->start.lineno = inp_stream->linecount; - qq->start.linepos = inp_stream->linepos - 1; - qq->start.charno = inp_stream->charcount - 1; + qq->start.lineno = st->linecount; + qq->start.linepos = st->linepos - 1; + qq->start.charno = st->charcount - 1; t->Tok = Ord(kind = QuasiQuotes_tok); - ch = getchr(inp_stream); + ch = getchr(st); solo_flag = FALSE; break; } while (chtype(ch) == BS) { - ch = getchr(inp_stream); + ch = getchr(st); }; if (ch == '}') { t->TokInfo = TermBraces; t->Tok = Ord(kind = Name_tok); - ch = getchr(inp_stream); + ch = getchr(st); solo_flag = FALSE; break; } @@ -1855,7 +1886,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, if (!qq) { LOCAL_ErrorMessage = "quasi quoted's || without {|"; Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); - free(cur_qq); + Free(cur_qq); cur_qq = NULL; t->Tok = Ord(kind = eot_tok); t->TokInfo = TermError; @@ -1863,16 +1894,16 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, } cur_qq = NULL; t->TokInfo = (CELL)qq; - if (inp_stream->status & Seekable_Stream_f) { - qq->mid.byteno = fseek(inp_stream->file, 0, 0); + if (st->status & Seekable_Stream_f) { + qq->mid.byteno = fseek(st->file, 0, 0); } else { - qq->mid.byteno = inp_stream->charcount - 1; + qq->mid.byteno = st->charcount - 1; } - qq->mid.lineno = inp_stream->linecount; - qq->mid.linepos = inp_stream->linepos - 1; - qq->mid.charno = inp_stream->charcount - 1; + qq->mid.lineno = st->linecount; + qq->mid.linepos = st->linepos - 1; + qq->mid.charno = st->charcount - 1; t->Tok = Ord(kind = QuasiQuotes_tok); - ch = getchr(inp_stream); + ch = getchr(st); sz = 1024; TokImage = Malloc(sz); if (!TokImage) { @@ -1885,11 +1916,11 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, charp = TokImage; quote = ch; len = 0; - ch = getchrq(inp_stream); + ch = getchrq(st); while (TRUE) { if (ch == '|') { - ch = getchrq(inp_stream); + ch = getchrq(st); if (ch != '}') { } else { charp += put_utf8((unsigned char *)charp, och); @@ -1899,13 +1930,13 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, } } else if (chtype(ch) == EF) { Free(TokImage); - mark_eof(inp_stream); + mark_eof(st); t->Tok = Ord(kind = eot_tok); t->TokInfo = TermOutOfHeapError; break; } else { charp += put_utf8(charp, ch); - ch = getchrq(inp_stream); + ch = getchrq(st); } if (charp > (unsigned char *)AuxSp - 1024) { /* Not enough space to read in the string. */ @@ -1914,7 +1945,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, } } len = charp - (unsigned char *)TokImage; - mp = malloc(len + 1); + mp = Malloc(len + 1); if (mp == NULL) { LOCAL_ErrorMessage = "not enough heap space to read in quasi quote"; Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); @@ -1925,26 +1956,26 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, strncpy((char *)mp, (const char *)TokImage, len + 1); qq->text = (unsigned char *)mp; Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); - if (inp_stream->status & Seekable_Stream_f) { - qq->end.byteno = fseek(inp_stream->file, 0, 0); + if (st->status & Seekable_Stream_f) { + qq->end.byteno = fseek(st->file, 0, 0); } else { - qq->end.byteno = inp_stream->charcount - 1; + qq->end.byteno = st->charcount - 1; } - qq->end.lineno = inp_stream->linecount; - qq->end.linepos = inp_stream->linepos - 1; - qq->end.charno = inp_stream->charcount - 1; + qq->end.lineno = st->linecount; + qq->end.linepos = st->linepos - 1; + qq->end.charno = st->charcount - 1; if (!(t->TokInfo)) { return CodeSpaceError(t, p, l); } Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); solo_flag = FALSE; - ch = getchr(inp_stream); + ch = getchr(st); break; } t->Tok = Ord(kind = Ponctuation_tok); break; case EF: - mark_eof(inp_stream); + mark_eof(st); t->Tok = Ord(kind = eot_tok); t->TokInfo = TermEof; return l; @@ -1966,7 +1997,8 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments, p->TokNext = e; e->Tok = Error_tok; e->TokInfo = MkAtomTerm(Yap_LookupAtom(LOCAL_ErrorMessage)); - e->TokPos = GetCurInpPos(inp_stream); + e->TokPos = GetCurInpPos(st); + e->TokLine = GetCurInpLine(st); e->TokNext = NULL; LOCAL_ErrorMessage = NULL; p = e; @@ -1982,14 +2014,14 @@ void Yap_clean_tokenizer(TokEntry *tokstart, VarEntry *vartable, struct scanner_extra_alloc *ptr = LOCAL_ScannerExtraBlocks; while (ptr) { struct scanner_extra_alloc *next = ptr->next; - free(ptr); + Free(ptr); ptr = next; } TR = (tr_fr_ptr)tokstart; LOCAL_Comments = TermNil; LOCAL_CommentsNextChar = LOCAL_CommentsTail = NULL; if (LOCAL_CommentsBuff) { - free(LOCAL_CommentsBuff); + Free(LOCAL_CommentsBuff); LOCAL_CommentsBuff = NULL; } LOCAL_ScannerStack = NULL; diff --git a/C/signals.c b/C/signals.c index b2684b519..58aca8d47 100755 --- a/C/signals.c +++ b/C/signals.c @@ -28,9 +28,9 @@ static char SccsId[] = "%W% %G%"; #include #include #endif +#include "YapEval.h" #include "YapHeap.h" #include "Yatom.h" -#include "YapEval.h" #include "yapio.h" #ifdef TABLING #include "tab.macros.h" @@ -65,9 +65,8 @@ static yap_signals InteractSIGINT(int ch) { case 'a': /* abort computation */ #if PUSH_REGS -// restore_absmi_regs(&Yap_standard_regs); + // restore_absmi_regs(&Yap_standard_regs); #endif - siglongjmp(LOCAL_RestartEnv, 4); return YAP_ABORT_SIGNAL; case 'b': /* continue */ @@ -111,9 +110,11 @@ static yap_signals InteractSIGINT(int ch) { } } -/* - This function talks to the user about a signal. We assume we are in - the context of the main Prolog thread (trivial in Unix, but hard in WIN32) +/** + This function interacts with the user about a signal. We assume we are in + the context of the main Prolog thread (trivial in Unix, but hard in WIN32). + + */ static yap_signals ProcessSIGINT(void) { CACHE_REGS diff --git a/C/stack.c b/C/stack.c index c1bb25b7a..ec841968d 100644 --- a/C/stack.c +++ b/C/stack.c @@ -1,22 +1,22 @@ /************************************************************************* -* * -* YAP Prolog * -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * -* * -************************************************************************** -* * -* File: stack.c * -* comments: Stack Introspection * -* * -* Last rev: $Date: 2008-07-22 23:34:44 $,$Author: vsc $ * -* $Log: not supported by cvs2svn $ * -* Revision 1.230 2008/06/02 17:20:28 vsc * -* * -* * -*************************************************************************/ + * * + * YAP Prolog * + * * + * Yap Prolog was developed at NCCUP - Universidade do Porto * + * * + * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * + * * + ************************************************************************** + * * + * File: stack.c * + * comments: Stack Introspection * + * * + * Last rev: $Date: 2008-07-22 23:34:44 $,$Author: vsc $ * + * $Log: not supported by cvs2svn $ * + * Revision 1.230 2008/06/02 17:20:28 vsc * + * * + * * + *************************************************************************/ /** * @file stack.c @@ -29,29 +29,42 @@ */ #include "Yap.h" -#include "clause.h" #include "YapEval.h" +#include "clause.h" #include "iopreds.h" #include "tracer.h" #include "yapio.h" + #ifdef YAPOR #include "or.macros.h" #endif /* YAPOR */ #ifdef TABLING + #include "tab.macros.h" + #endif /* TABLING */ #if HAVE_STRING_H + #include + #endif + #include #if !defined(YAPOR) && !defined(THREADS) + static void mark_pred(int, PredEntry *); + static void do_toggle_static_predicates_in_use(int); + #endif + static Int in_use(USES_REGS1); + static Int PredForCode(yamop *, Atom *, arity_t *, Term *, PredEntry **); + static LogUpdIndex *find_owner_log_index(LogUpdIndex *, yamop *); + static StaticIndex *find_owner_static_index(StaticIndex *, yamop *); #define IN_BLOCK(P, B, SZ) \ @@ -102,7 +115,7 @@ static PredEntry *PredForChoicePt(yamop *p_code, op_numbers *opn) { *opn = opnum; switch (opnum) { case _Nstop: - return NULL; + return PredFail; case _jump: p_code = p_code->y_u.l.l; break; @@ -163,13 +176,7 @@ static PredEntry *PredForChoicePt(yamop *p_code, op_numbers *opn) { /* compile error --> return ENV_ToP(gc_B->cp_cp); */ #endif /* TABLING */ case _or_else: - if (p_code == p_code->y_u.Osblp.l) { - /* repeat */ - Atom at = AtomRepeatSpace; - return RepPredProp(PredPropByAtom(at, PROLOG_MODULE)); - } else { - return p_code->y_u.Osblp.p0; - } + return p_code->y_u.Osblp.p0; break; case _or_last: #ifdef YAPOR @@ -202,7 +209,7 @@ static PredEntry *PredForChoicePt(yamop *p_code, op_numbers *opn) { * * usually pretty straightforward, it can fall in trouble with 8 OR-P or tabling. - */ +*/ PredEntry *Yap_PredForChoicePt(choiceptr cp, op_numbers *op) { if (cp == NULL) return NULL; @@ -210,6 +217,7 @@ PredEntry *Yap_PredForChoicePt(choiceptr cp, op_numbers *op) { } #if !defined(YAPOR) && !defined(THREADS) + static yamop *cur_clause(PredEntry *pe, yamop *codeptr) { StaticClause *cl; @@ -260,8 +268,8 @@ bool Yap_search_for_static_predicate_in_use(PredEntry *p, /* check first environments that are younger than our latest choicepoint */ if (check_everything && env_ptr) { /* - I do not need to check environments for asserts, - only for retracts + I do not need to check environments for asserts, + only for retracts */ while (env_ptr && b_ptr > (choiceptr)env_ptr) { yamop *cp = (yamop *)env_ptr[E_CP]; @@ -276,9 +284,9 @@ bool Yap_search_for_static_predicate_in_use(PredEntry *p, } /* now mark the choicepoint */ - if (b_ptr) + if (b_ptr) { pe = PredForChoicePt(b_ptr->cp_ap, NULL); - else + } else return false; if (pe == p) { if (check_everything) @@ -386,14 +394,20 @@ static Int toggle_static_predicates_in_use(USES_REGS1) { static void clause_was_found(PredEntry *pp, Atom *pat, UInt *parity) { if (pp->ModuleOfPred == IDB_MODULE) { if (pp->PredFlags & NumberDBPredFlag) { - *parity = 0; - *pat = AtomInteger; + if (parity) + *parity = 0; + if (pat) + *pat = AtomInteger; } else if (pp->PredFlags & AtomDBPredFlag) { - *parity = 0; - *pat = (Atom)pp->FunctorOfPred; + if (parity) + *parity = 0; + if (pat) + *pat = (Atom)pp->FunctorOfPred; } else { - *pat = NameOfFunctor(pp->FunctorOfPred); - *parity = ArityOfFunctor(pp->FunctorOfPred); + if (pat) + *pat = NameOfFunctor(pp->FunctorOfPred); + if (parity) + *parity = ArityOfFunctor(pp->FunctorOfPred); } } else { if (parity) { @@ -523,6 +537,41 @@ static Int find_code_in_clause(PredEntry *pp, yamop *codeptr, void **startp, return (0); } +/* + static bool put_clause_loc(yap_error_descriptor_t *t, void *clcode, PredEntry + *pp) { + + CACHE_REGS + if (pp->PredFlags & LogUpdatePredFlag) { + LogUpdClause *cl = clcode; + + if (cl->ClFlags & FactMask) { + t->prologPredLine = cl->lusl.ClLine; + } else { + t->prologPredLine = cl->lusl.ClSource->ag.line_number; + } + } else if (pp->PredFlags & DynamicPredFlag) { + // DynamicClause *cl; + // cl = ClauseCodeToDynamicClause(clcode); + + return false; + } else if (pp->PredFlags & MegaClausePredFlag) { + MegaClause *mcl = ClauseCodeToMegaClause(pp->cs.p_code.FirstClause); + t->prologPredLine = mcl->ClLine; + } else { + StaticClause *cl; + cl = clcode; + if (cl->ClFlags & FactMask) { + t->prologPredLine = cl->usc.ClLine; + } else if (cl->ClFlags & SrcMask) { + t->prologPredLine = cl->usc.ClSource->ag.line_number; + } else + return MkIntTerm(0); + } + return MkIntTerm(0); + } +*/ + static Term clause_loc(void *clcode, PredEntry *pp) { CACHE_REGS @@ -607,7 +656,7 @@ static Int code_in_pred(PredEntry *pp, Atom *pat, UInt *parity, PELOCK(40, pp); /* check if the codeptr comes from the indexing code */ - if (pp->PredFlags & IndexedPredFlag) { + if (pp->PredFlags & IndexedPredFlag && pp->OpcodeOfPred != INDEX_OPCODE) { if (pp->PredFlags & LogUpdatePredFlag) { if (code_in_pred_lu_index( ClauseCodeToLogUpdIndex(pp->cs.p_code.TrueCodeOfPred), codeptr, @@ -779,7 +828,8 @@ static PredEntry *found_expand(yamop *pc, void **startp, return pp; } -static PredEntry *found_ystop(yamop *pc, int clause_code, void **startp, void **endp, PredEntry *pp USES_REGS) { +static PredEntry *found_ystop(yamop *pc, int clause_code, void **startp, + void **endp, PredEntry *pp USES_REGS) { if (pc == YESCODE) { pp = RepPredProp(Yap_GetPredPropByAtom(AtomTrue, CurrentModule)); if (startp) @@ -787,17 +837,17 @@ static PredEntry *found_ystop(yamop *pc, int clause_code, void **startp, void ** if (endp) *endp = (CODEADDR)YESCODE + (CELL)(NEXTOP((yamop *)NULL, e)); return pp; - } - if (!pp) { - yamop *o = PREVOP(pc,pp); - if (o->opc ==Yap_opcode(_execute_cpred)) { - pp = o->y_u.pp.p0; - } else { - /* must be an index */ - PredEntry **pep = (PredEntry **)pc->y_u.l.l; - pp = pep[-1]; } - } + if (!pp) { + yamop *o = PREVOP(pc, Osbpp); + if (o->opc == Yap_opcode(_execute_cpred)) { + pp = o->y_u.Osbpp.p0; + } else { + /* must be an index */ + PredEntry **pep = (PredEntry **)pc->y_u.l.l; + pp = pep[-1]; + } + } if (pp->PredFlags & LogUpdatePredFlag) { if (clause_code) { LogUpdClause *cl = ClauseCodeToLogUpdClause(pc->y_u.l.l); @@ -839,7 +889,9 @@ static PredEntry *ClauseInfoForCode(yamop *codeptr, void **startp, return pp; } pc = codeptr; + #include "walkclause.h" + return NULL; } @@ -1069,51 +1121,37 @@ static Term clause_info(yamop *codeptr, PredEntry *pp) { return Yap_MkApplTerm(FunctorModule, 2, ts); } -bool set_clause_info(yamop *codeptr, PredEntry *pp) { +yap_error_descriptor_t *set_clause_info(yap_error_descriptor_t *t, + yamop *codeptr, PredEntry *pp) { CACHE_REGS - Term ts[2]; + void *begin; if (pp->ArityOfPE == 0) { - LOCAL_ActiveError->prologPredName = (Atom)pp->FunctorOfPred; - LOCAL_ActiveError->prologPredArity = 0; + t->prologPredName = AtomName((Atom)pp->FunctorOfPred); + t->prologPredArity = 0; } else { - LOCAL_ActiveError->prologPredName = NameOfFunctor(pp->FunctorOfPred); - LOCAL_ActiveError->prologPredArity = pp->ArityOfPE; + t->prologPredName = AtomName(NameOfFunctor(pp->FunctorOfPred)); + t->prologPredArity = pp->ArityOfPE; } - LOCAL_ActiveError->prologPredModule = - (pp->ModuleOfPred ? pp->ModuleOfPred : TermProlog); - LOCAL_ActiveError->prologPredFile = pp->src.OwnerFile; + t->prologPredModule = + (pp->ModuleOfPred ? RepAtom(AtomOfTerm(pp->ModuleOfPred))->StrOfAE + : "prolog"); + t->prologPredFile = RepAtom(pp->src.OwnerFile)->StrOfAE; if (codeptr->opc == UNDEF_OPCODE) { - LOCAL_ActiveError->prologPredFirstLine = 0; - LOCAL_ActiveError->prologPredLine = 0; - LOCAL_ActiveError->prologPredLastLine = 0; - return true; + t->prologPredLine = 0; + return t; } else if (pp->cs.p_code.NOfClauses) { - if ((LOCAL_ActiveError->prologPredCl = - find_code_in_clause(pp, codeptr, &begin, NULL)) <= 0) { - LOCAL_ActiveError->prologPredLine = 0; + if ((t->prologPredLine = find_code_in_clause(pp, codeptr, &begin, NULL)) <= + 0) { + t->prologPredLine = 0; } else { - LOCAL_ActiveError->prologPredLine = IntegerOfTerm(clause_loc(begin, pp)); + t->prologPredLine = IntegerOfTerm(clause_loc(begin, pp)); } - if (pp->PredFlags & LogUpdatePredFlag) { - LOCAL_ActiveError->prologPredFirstLine = IntegerOfTerm( - ts[0] = clause_loc( - ClauseCodeToLogUpdClause(pp->cs.p_code.FirstClause), pp)); - LOCAL_ActiveError->prologPredLastLine = IntegerOfTerm( - ts[1] = clause_loc(ClauseCodeToLogUpdClause(pp->cs.p_code.LastClause), - pp)); - - } else { - LOCAL_ActiveError->prologPredFirstLine = IntegerOfTerm( - ts[0] = clause_loc( - ClauseCodeToStaticClause(pp->cs.p_code.FirstClause), pp)); - LOCAL_ActiveError->prologPredLastLine = IntegerOfTerm( - ts[1] = clause_loc(ClauseCodeToStaticClause(pp->cs.p_code.LastClause), - pp)); - } - return true; + return t; } else { - return false; + t->prologPredLine = t->errorLine; + t->prologPredFile = t->errorFile; + return t; } } @@ -1141,29 +1179,47 @@ static Term error_culprit(bool internal USES_REGS) { return TermNil; } -bool Yap_find_prolog_culprit(USES_REGS1) { +yap_error_descriptor_t * +Yap_prolog_add_culprit(yap_error_descriptor_t *t PASS_REGS) { PredEntry *pe; void *startp, *endp; // case number 1: Yap_Error called from built-in. pe = ClauseInfoForCode(P, &startp, &endp PASS_REGS); if (pe && (CurrentModule == 0 || !(pe->PredFlags & HiddenPredFlag))) { - return set_clause_info(P, pe); + return set_clause_info(t, P, pe); } else { CELL *curENV = ENV; yamop *curCP = CP; + choiceptr curB = B; PredEntry *pe = EnvPreg(curCP); while (curCP != YESCODE) { - curENV = (CELL *)(curENV[E_E]); - if (curENV == NULL) - break; - pe = EnvPreg(curCP); - if (pe->ModuleOfPred) - return set_clause_info(curCP, pe); - curCP = (yamop *)(curENV[E_CP]); + if (curENV) { + pe = EnvPreg(curCP); + curENV = (CELL *)(curENV[E_E]); + if (curENV < ASP || curENV >= LCL0) { + break; + } + curCP = (yamop *)curENV[E_CP]; + if (pe == NULL) { + pe = PredMetaCall; + } + if (pe->ModuleOfPred || !(pe->PredFlags & HiddenPredFlag)) + return set_clause_info(t, curCP, pe); + curCP = (yamop *)(curENV[E_CP]); + } else if (0) { + if (curB->cp_ap != NOCODE && curB->cp_ap != TRUSTFAILCODE && + curB->cp_ap != FAILCODE) { + pe = curB->cp_ap->y_u.Otapl.p; + if (pe && (pe->ModuleOfPred || !(pe->PredFlags & HiddenPredFlag))) + return set_clause_info(t, curB->cp_ap, pe); + } + curB = curB->cp_b; + } } } - return TermNil; + + return NULL; } static Term all_calls(bool internal USES_REGS) { @@ -1187,19 +1243,20 @@ static Term all_calls(bool internal USES_REGS) { return Yap_MkApplTerm(f, 6, ts); } -/** - * report the current status of the stacks up to level $N$ - * - * @param depth - * - * @return data on the current program counter - */ - Term Yap_all_calls(void) { CACHE_REGS return all_calls(true PASS_REGS); } +/** + * @pred current_stack( +Depth ) + * + * report the current status of the stacks up to level $N$ + * + * @param Depth + * + * @return data on the current Prolog stack. + */ static Int current_stack(USES_REGS1) { Term t; while ((t = all_calls(false PASS_REGS)) == 0L) { @@ -1316,15 +1373,15 @@ void Yap_dump_code_area_for_profiler(void) { while (pp != NULL) { /* if (pp->ArityOfPE) { - fprintf(stderr,"%s/%d %p\n", - RepAtom(NameOfFunctor(pp->FunctorOfPred))->StrOfAE, - pp->ArityOfPE, - pp); - } else { - fprintf(stderr,"%s %p\n", - RepAtom((Atom)(pp->FunctorOfPred))->StrOfAE, - pp); - }*/ + fprintf(stderr,"%%s/%d %p\n", + RepAtom(NameOfFunctor(pp->FunctorOfPred))->StrOfAE, + pp->ArityOfPE, + pp); + } else { + fprintf(stderr,"%%s %p\n", + RepAtom((Atom)(pp->FunctorOfPred))->StrOfAE, + pp); + }*/ add_code_in_pred(pp); pp = pp->NextPredOfModule; } @@ -1368,7 +1425,7 @@ static Term BuildActivePred(PredEntry *ap, CELL *vect) { arity_t i; if (!ap->ArityOfPE) { - return MkVarTerm(); + return MkAtomTerm((Atom)ap->FunctorOfPred); } for (i = 0; i < ap->ArityOfPE; i++) { Term t = Deref(vect[i]); @@ -1630,7 +1687,7 @@ static Int p_choicepoint_info(USES_REGS1) { } static Int /* $parent_pred(Module, Name, Arity) */ - parent_pred(USES_REGS1) { +parent_pred(USES_REGS1) { /* This predicate is called from the debugger. We assume a sequence of the form a -> b */ Atom at; @@ -1646,8 +1703,11 @@ static Int /* $parent_pred(Module, Name, Arity) */ } void Yap_dump_stack(void); + void DumpActiveGoals(CACHE_TYPE1); + static int hidden(Atom); + static int legal_env(CELL *CACHE_TYPE); #define ONLOCAL(ptr) \ @@ -1718,13 +1778,74 @@ void Yap_dump_stack(void) { /* check if handled */ if (handled_exception(PASS_REGS1)) return; -#if DEBUG +#if DEBU fprintf(stderr, "%% YAP regs: P=%p, CP=%p, ASP=%p, H=%p, TR=%p, HeapTop=%p\n", P, CP, ASP, HR, TR, HeapTop); - fprintf(stderr, "%% YAP mode: %ux\n", (unsigned int)LOCAL_PrologMode); - if (LOCAL_ErrorMessage) - fprintf(stderr, "%% LOCAL_ErrorMessage: %s\n", LOCAL_ErrorMessage); #endif + + fprintf(stderr, "%% \n%% =====================================\n%%\n"); + fprintf(stderr, "%% \n%% YAP Status:\n"); + fprintf(stderr, "%% \n%% -------------------------------------\n%%\n"); + yap_error_number errnbr = LOCAL_Error_TYPE; + yap_error_class_number classno = Yap_errorClass(errnbr); + + fprintf(stderr, "%% Error STATUS: %s/%s\n\n", Yap_errorName(errnbr), + Yap_errorClassName(classno)); + + fprintf(stderr, "%% Execution mode\n"); + if (LOCAL_PrologMode & BootMode) + fprintf(stderr, "%% Bootstrap\n"); + if (LOCAL_PrologMode & UserMode) + fprintf(stderr, "%% User Prolo\n"); + if (LOCAL_PrologMode & CritMode) + fprintf(stderr, "%% Exclusive Access Mode\n"); + if (LOCAL_PrologMode & AbortMode) + fprintf(stderr, "%% Abort\n"); + if (LOCAL_PrologMode & InterruptMode) + fprintf(stderr, "%% Interrupt\n"); + if (LOCAL_PrologMode & InErrorMode) + fprintf(stderr, "%% Error\n"); + if (LOCAL_PrologMode & ConsoleGetcMode) + fprintf(stderr, "%% Prompt Console\n"); + if (LOCAL_PrologMode & ExtendStackMode) + fprintf(stderr, "%% Stack expansion \n"); + if (LOCAL_PrologMode & GrowHeapMode) + fprintf(stderr, "%% Data Base Expansion\n"); + if (LOCAL_PrologMode & GrowStackMode) + fprintf(stderr, "%% User Prolog\n"); + if (LOCAL_PrologMode & GCMode) + fprintf(stderr, "%% Garbage Collection\n"); + if (LOCAL_PrologMode & ErrorHandlingMode) + fprintf(stderr, "%% Error handler\n"); + if (LOCAL_PrologMode & CCallMode) + fprintf(stderr, "%% System Foreign Code\n"); + if (LOCAL_PrologMode & UnifyMode) + fprintf(stderr, "%% Off-line Foreign Code\n"); + if (LOCAL_PrologMode & UserCCallMode) + fprintf(stderr, "%% User Foreig C\n"); + if (LOCAL_PrologMode & MallocMode) + fprintf(stderr, "%% Heap Allocaror\n"); + if (LOCAL_PrologMode & SystemMode) + fprintf(stderr, "%% Prolog Internals\n"); + if (LOCAL_PrologMode & AsyncIntMode) + fprintf(stderr, "%% Async Interruot mode\n"); + if (LOCAL_PrologMode & InReadlineMode) + fprintf(stderr, "%% Readline Console\n"); + if (LOCAL_PrologMode & TopGoalMode) + fprintf(stderr, "%% Creating new query\n"); + fprintf(stderr, "%% \n%% -------------------------------------\n%%\n"); + fprintf(stderr, "%% \n%% YAP Program:\n"); + fprintf(stderr, "%% \n%% -------------------------------------\n%%\n"); + fprintf(stderr, "%% Program Position: %s\n\n", Yap_errorName(errno) ); + fprintf(stderr, "%% PC: %s\n", (char *)HR); + Yap_output_bug_location(CP, FIND_PRED_FROM_ANYWHERE, 256); + fprintf(stderr, "%% Continuation: %s\n", (char *)HR); + Yap_output_bug_location(B->cp_ap, FIND_PRED_FROM_ANYWHERE, 256); + fprintf(stderr, "%% Alternative: %s\n", (char *)HR); + + fprintf(stderr, "%% \n%% -------------------------------------\n%%\n"); + fprintf(stderr, "%% \n%% YAP Stack Usage:\n"); + fprintf(stderr, "%% \n%% -------------------------------------\n%%\n"); if (HR > ASP || HR > LCL0) { fprintf(stderr, "%% YAP ERROR: Global Collided against Local (%p--%p)\n", HR, ASP); @@ -1734,7 +1855,7 @@ void Yap_dump_stack(void) { HeapTop, LOCAL_GlobalBase); } else { #if !USE_SYSTEM_MALLOC - fprintf(stderr, "%ldKB of Code Space (%p--%p)\n", + fprintf(stderr, "%%ldKB of Code Space (%p--%p)\n", (long int)((CELL)HeapTop - (CELL)Yap_HeapBase) / 1024, Yap_HeapBase, HeapTop); #if USE_DL_MALLOC @@ -1747,10 +1868,6 @@ void Yap_dump_stack(void) { } #endif #endif - Yap_detect_bug_location(P, FIND_PRED_FROM_ANYWHERE, 256); - fprintf(stderr, "%%\n%% PC: %s\n", (char *)HR); - Yap_detect_bug_location(CP, FIND_PRED_FROM_ANYWHERE, 256); - fprintf(stderr, "%% Continuation: %s\n", (char *)HR); fprintf(stderr, "%% %luKB of Global Stack (%p--%p)\n", (unsigned long int)(sizeof(CELL) * (HR - H0)) / 1024, H0, HR); fprintf(stderr, "%% %luKB of Local Stack (%p--%p)\n", @@ -1773,12 +1890,15 @@ void Yap_dump_stack(void) { } } #endif +fprintf(stderr, "%% \n%% -------------------------------------\n%%\n"); +fprintf(stderr, "%% \n%% YAP Stack:\n"); +fprintf(stderr, "%% \n%% -------------------------------------\n%%\n"); fprintf(stderr, "%% All Active Calls and\n"); fprintf(stderr, "%% Goals With Alternatives Open (Global In " "Use--Local In Use)\n%%\n"); while (b_ptr != NULL) { while (env_ptr && env_ptr <= (CELL *)b_ptr) { - Yap_detect_bug_location(ipc, FIND_PRED_FROM_ENV, 256); + Yap_output_bug_location(ipc, FIND_PRED_FROM_ENV, 256); if (env_ptr == (CELL *)b_ptr && (choiceptr)env_ptr[E_CB] > b_ptr) { b_ptr = b_ptr->cp_b; fprintf(stderr, "%% %s\n", tp); @@ -1794,7 +1914,7 @@ void Yap_dump_stack(void) { } if (b_ptr) { if (!max_count--) { - fprintf(stderr, "%% .....\n"); + fprintf(stderr, "// .....\n"); return; } if (b_ptr->cp_ap && /* tabling */ @@ -1802,7 +1922,7 @@ void Yap_dump_stack(void) { b_ptr->cp_ap->opc != Yap_opcode(_or_last) && b_ptr->cp_ap->opc != Yap_opcode(_Nstop)) { /* we can safely ignore ; because there is always an upper env */ - Yap_detect_bug_location(b_ptr->cp_ap, FIND_PRED_FROM_CP, 256); + Yap_output_bug_location(b_ptr->cp_ap, FIND_PRED_FROM_CP, 256); fprintf(stderr, "%% %s (%luKB--%luKB)\n", tp, (unsigned long int)((b_ptr->cp_h - H0) * sizeof(CELL) / 1024), (unsigned long int)((ADDR)LCL0 - (ADDR)b_ptr) / 1024); @@ -1813,6 +1933,7 @@ void Yap_dump_stack(void) { } } + void DumpActiveGoals(USES_REGS1) { /* try to dump active goals */ CELL *ep = YENV; /* and current environment */ @@ -1868,7 +1989,7 @@ void DumpActiveGoals(USES_REGS1) { op_numbers opnum; if (!ONLOCAL(b_ptr) || b_ptr->cp_b == NULL) break; - fprintf(stderr, "%p ", b_ptr); + fprintf(stderr, "%% %p ", b_ptr); pe = Yap_PredForChoicePt(b_ptr, &opnum); if (opnum == _Nstop) { fprintf(stderr, " ********** C-Code Interface Boundary ***********\n"); @@ -1947,7 +2068,12 @@ void DumpActiveGoals(USES_REGS1) { } } -void Yap_detect_bug_location(yamop *yap_pc, int where_from, int psize) { + +/** + * Used for debugging. + * + */ +void Yap_output_bug_location(yamop *yap_pc, int where_from, int psize) { Atom pred_name; UInt pred_arity; Term pred_module; @@ -1956,39 +2082,40 @@ void Yap_detect_bug_location(yamop *yap_pc, int where_from, int psize) { if ((cl = Yap_PredForCode(yap_pc, where_from, &pred_name, &pred_arity, &pred_module)) == 0) { /* system predicate */ - fprintf(stderr, "%s", "meta-call"); + fprintf(stderr, "%% %s", "meta-call"); } else if (pred_module == 0) { fprintf(stderr, "in prolog:%s/%lu", RepAtom(pred_name)->StrOfAE, (unsigned long int)pred_arity); } else if (cl < 0) { - fprintf(stderr, "%s:%s/%lu", RepAtom(AtomOfTerm(pred_module))->StrOfAE, + fprintf(stderr, "%% %s:%s/%lu", RepAtom(AtomOfTerm(pred_module))->StrOfAE, RepAtom(pred_name)->StrOfAE, (unsigned long int)pred_arity); } else { - fprintf(stderr, "%s:%s/%lu at clause %lu", + fprintf(stderr, "%% %s:%s/%lu at clause %lu", RepAtom(AtomOfTerm(pred_module))->StrOfAE, RepAtom(pred_name)->StrOfAE, (unsigned long int)pred_arity, (unsigned long int)cl); } } -static Term build_bug_location(yamop *codeptr, PredEntry *pe) { +static yap_error_descriptor_t *add_bug_location(yap_error_descriptor_t *p, + yamop *codeptr, PredEntry *pe) { CACHE_REGS - Term p[5]; if (pe->ModuleOfPred == PROLOG_MODULE) - p[0] = TermProlog; + p->prologPredModule = AtomName(AtomProlog); else - p[0] = pe->ModuleOfPred; + p->prologPredModule = AtomName(AtomOfTerm(pe->ModuleOfPred)); if (pe->ArityOfPE) - p[1] = MkAtomTerm(NameOfFunctor(pe->FunctorOfPred)); + p->prologPredName = AtomName(NameOfFunctor(pe->FunctorOfPred)); else - p[1] = MkAtomTerm((Atom)pe->FunctorOfPred); - p[2] = MkIntegerTerm(pe->ArityOfPE); + p->prologPredName = AtomName((Atom)(pe->FunctorOfPred)); + p->prologPredArity = pe->ArityOfPE; + p->prologPredFile = AtomName(pe->src.OwnerFile); + p->prologPredLine = 0; if (pe->src.OwnerFile) { - p[3] = MkAtomTerm(pe->src.OwnerFile); if (pe->PredFlags & MegaClausePredFlag) { MegaClause *mcl; mcl = ClauseCodeToMegaClause(pe->cs.p_code.FirstClause); - p[4] = MkIntegerTerm(mcl->ClLine); + p->prologPredLine = mcl->ClLine; } else { void *clcode; if (find_code_in_clause(pe, codeptr, &clcode, NULL) > 0) { @@ -1996,68 +2123,76 @@ static Term build_bug_location(yamop *codeptr, PredEntry *pe) { LogUpdClause *cl = clcode; if (cl->ClFlags & FactMask) { - p[4] = MkIntegerTerm(cl->lusl.ClLine); - } else { - p[4] = MkIntegerTerm(cl->lusl.ClSource->ag.line_number); + p->prologPredLine = cl->lusl.ClSource->ag.line_number; } } else if (pe->PredFlags & DynamicPredFlag) { - p[4] = MkIntTerm(0); + p->prologPredLine = 0; } else { StaticClause *cl; cl = clcode; if (cl->ClFlags & FactMask) { - p[4] = MkIntTerm(cl->usc.ClLine); + p->prologPredLine = MkIntTerm(cl->usc.ClLine); } else if (cl->ClFlags & SrcMask) { - p[4] = MkIntTerm(cl->usc.ClSource->ag.line_number); + p->prologPredLine = cl->usc.ClSource->ag.line_number; } else - p[4] = MkIntTerm(0); + p->prologPredLine = 0; } } else { - p[4] = MkIntTerm(0); + p->prologPredLine = 0; } } } else if (pe->OpcodeOfPred == UNDEF_OPCODE) { - RESET_VARIABLE(p + 3); - RESET_VARIABLE(p + 4); + p->prologPredFile = "undefined"; } else { // by default, user_input - p[3] = MkAtomTerm(AtomUserIn); - p[4] = MkIntTerm(0); + p->prologPredFile = AtomName(AtomUserIn); + p->prologPredLine = 0; } - return Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("p"), 5), 5, p); + return p; } -Term Yap_pc_location(yamop *pc, choiceptr b_ptr, CELL *env) { +yap_error_descriptor_t *Yap_pc_add_location(yap_error_descriptor_t *t, + void *pc0, void *b_ptr0, + void *env0) { CACHE_REGS - yamop *codeptr = pc; + yamop *xc = pc0; + // choiceptr b_ptr = b_ptr0; + // CELL *env = env0; + PredEntry *pe; if (PP == NULL) { - if (PredForCode(pc, NULL, NULL, NULL, &pe) <= 0) - return TermNil; + if (PredForCode(xc, NULL, NULL, NULL, &pe) <= 0) + return NULL; } else pe = PP; if (pe != NULL // pe->ModuleOfPred != PROLOG_MODULE && // &&!(pe->PredFlags & HiddenPredFlag) - ) { - return build_bug_location(codeptr, pe); + ) { + return add_bug_location(t, xc, pe); } - return TermNil; + return NULL; } -Term Yap_env_location(yamop *cp, choiceptr b_ptr, CELL *env, Int ignore_first) { +yap_error_descriptor_t *Yap_env_add_location(yap_error_descriptor_t *t, + void *cp0, void *b_ptr0, + void *env0, YAP_Int ignore_first) { + yamop *cp = cp0; + choiceptr b_ptr = b_ptr0; + CELL *env = env0; while (true) { if (b_ptr == NULL || env == NULL) - return TermNil; + return NULL; PredEntry *pe = EnvPreg(cp); if (pe == PredTrue) - return TermNil; - if (ignore_first <= 0 && pe + return NULL; + if (ignore_first <= 0 && + pe // pe->ModuleOfPred != PROLOG_MODULE &&s && !(pe->PredFlags & HiddenPredFlag)) { - return build_bug_location(cp, pe); + return add_bug_location(t, cp, pe); } else { if (NULL && b_ptr && b_ptr->cp_env < env) { cp = b_ptr->cp_cp; @@ -2072,14 +2207,43 @@ Term Yap_env_location(yamop *cp, choiceptr b_ptr, CELL *env, Int ignore_first) { } } +/* + Term Yap_env_location(yamop *cp, choiceptr b_ptr, CELL *env, Int ignore_first) + { while (true) { if (b_ptr == NULL || env == NULL) return TermNil; PredEntry + *pe = EnvPreg(cp); if (pe == PredTrue) return TermNil; if (ignore_first <= 0 + && pe + // pe->ModuleOfPred != PROLOG_MODULE &&s + && !(pe->PredFlags & HiddenPredFlag)) { + return add_bug_location(cp, pe); + } else { + if (NULL && b_ptr && b_ptr->cp_env < env) { + cp = b_ptr->cp_cp; + env = b_ptr->cp_env; + b_ptr = b_ptr->cp_b; + } else { + cp = (yamop *)env[E_CP]; + env = ENV_Parent(env); + } + ignore_first--; + } + } + } +*/ + +static Term mkloc(yap_error_descriptor_t *t) { return TermNil; } + static Int clause_location(USES_REGS1) { - return Yap_unify(Yap_pc_location(P, B, ENV), ARG1) && - Yap_unify(Yap_env_location(CP, B, ENV, 1), ARG2); + yap_error_descriptor_t t; + memset(&t, 0, sizeof(yap_error_descriptor_t)); + return Yap_unify(mkloc(Yap_pc_add_location(&t, P, B, ENV)), ARG1) && + Yap_unify(mkloc(Yap_env_add_location(&t, CP, B, ENV, 1)), ARG2); } static Int ancestor_location(USES_REGS1) { - return Yap_unify(Yap_env_location(CP, B, ENV, 2), ARG1) && - Yap_unify(Yap_env_location(CP, B, ENV, 3), ARG2); + yap_error_descriptor_t t; + memset(&t, 0, sizeof(yap_error_descriptor_t)); + return Yap_unify(mkloc(Yap_env_add_location(&t, CP, B, ENV, 2)), ARG2) && + Yap_unify(mkloc(Yap_env_add_location(&t, CP, B, ENV, 3)), ARG2); } void Yap_InitStInfo(void) { diff --git a/C/stackinfo.c b/C/stackinfo.c index b61621b4b..ccd40fec5 100644 --- a/C/stackinfo.c +++ b/C/stackinfo.c @@ -26,7 +26,7 @@ * @brief Get to know what is in your stack. * * - */ +` */ #include "Yap.h" #include "clause.h" diff --git a/C/stdpreds.c b/C/stdpreds.c index 71e38efe0..5517c9091 100755 --- a/C/stdpreds.c +++ b/C/stdpreds.c @@ -948,9 +948,10 @@ static Int current_predicate(USES_REGS1) { static OpEntry *NextOp(Prop pp USES_REGS) { - while (!EndOfPAEntr(pp) && pp->KindOfPE != OpProperty && - (RepOpProp(pp)->OpModule != PROLOG_MODULE - || RepOpProp(pp)->OpModule != CurrentModule) ) + while (!EndOfPAEntr(pp) && + pp->KindOfPE != OpProperty && + (RepOpProp(pp)->OpModule != PROLOG_MODULE || RepOpProp(pp)->OpModule != CurrentModule) + ) pp = pp->NextOfPE; return RepOpProp(pp); } @@ -1348,13 +1349,17 @@ static Int p_statistics_lu_db_size(USES_REGS1) { } static Int p_executable(USES_REGS1) { - if (GLOBAL_argv && GLOBAL_argv[0]) - Yap_findFile(GLOBAL_argv[0], NULL, NULL, LOCAL_FileNameBuf, true, YAP_EXE, - true, true); - else - strncpy(LOCAL_FileNameBuf, Yap_FindExecutable(), YAP_FILENAME_MAX - 1); + int lvl = push_text_stack(); + const char *tmp = - return Yap_unify(MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)), ARG1); + Yap_AbsoluteFile(GLOBAL_argv[0], true); + if (!tmp || tmp[0] == '\0' ) { + tmp = Malloc(YAP_FILENAME_MAX + 1); + strncpy((char *)tmp, Yap_FindExecutable(), YAP_FILENAME_MAX); + } + Atom at = Yap_LookupAtom(tmp); + pop_text_stack(lvl); + return Yap_unify(MkAtomTerm(at), ARG1); } static Int p_system_mode(USES_REGS1) { diff --git a/C/text.c b/C/text.c index 038abf6c5..e64e41bf3 100644 --- a/C/text.c +++ b/C/text.c @@ -1,19 +1,19 @@ /************************************************************************* -* * -* YAP Prolog * -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V. Santos Costa and Universidade do Porto 1985-- * -* * -************************************************************************** -* * -* File: strings.c * -* comments: General-conversion of character sequences. * -* * -* Last rev: $Date: 2008-07-24 16:02:00 $,$Author: vsc $ * -* * -*************************************************************************/ + * * + * YAP Prolog * + * * + * Yap Prolog was developed at NCCUP - Universidade do Porto * + * * + * Copyright L.Damas, V. Santos Costa and Universidade do Porto 1985-- * + * * + ************************************************************************** + * * + * File: strings.c * + * comments: General-conversion of character sequences. * + * * + * Last rev: $Date: 2008-07-24 16:02:00 $,$Author: vsc $ * + * * + *************************************************************************/ #include "Yap.h" #include "YapEval.h" @@ -31,6 +31,13 @@ inline static size_t min_size(size_t i, size_t j) { return (i < j ? i : j); } #define wcsnlen(S, N) min_size(N, wcslen(S)) #endif +#if !defined(HAVE_STPCPY) && !defined(__APPLE__) +inline static void *__stpcpy(void *i, const void *j) { + return strcpy(i, j) + strlen(j); +} +#define stpcpy __stpcpy +#endif + #ifndef NAN #define NAN (0.0 / 0.0) #endif @@ -51,11 +58,49 @@ typedef struct TextBuffer_manager { int lvl; } text_buffer_t; -int push_text_stack(USES_REGS1) { return LOCAL_TextBuffer->lvl++; } +int AllocLevel(void) { return LOCAL_TextBuffer->lvl; } +// void pop_text_stack(int i) { LOCAL_TextBuffer->lvl = i; } +void insert_block(struct mblock *o) { + int lvl = o->lvl; + o->prev = LOCAL_TextBuffer->last[lvl]; + if (o->prev) { + o->prev->next = o; + } + if (LOCAL_TextBuffer->first[lvl]) { + LOCAL_TextBuffer->last[lvl] = o; + } else { + LOCAL_TextBuffer->first[lvl] = LOCAL_TextBuffer->last[lvl] = o; + } + o->next = NULL; +} -int pop_text_stack(int i) { +void release_block(struct mblock *o) { + int lvl = o->lvl; + if (LOCAL_TextBuffer->first[lvl] == o) { + if (LOCAL_TextBuffer->last[lvl] == o) { + LOCAL_TextBuffer->first[lvl] = LOCAL_TextBuffer->last[lvl] = NULL; + } + LOCAL_TextBuffer->first[lvl] = o->next; + } else if (LOCAL_TextBuffer->last[lvl] == o) { + LOCAL_TextBuffer->last[lvl] = o->prev; + } + if (o->prev) + o->prev->next = o->next; + if (o->next) + o->next->prev = o->prev; +} + +int push_text_stack__(USES_REGS1) { + int i = LOCAL_TextBuffer->lvl; + i++; + LOCAL_TextBuffer->lvl = i; + + return i; +} + +int pop_text_stack__(int i) { int lvl = LOCAL_TextBuffer->lvl; - while (lvl > i) { + while (lvl >= i) { struct mblock *p = LOCAL_TextBuffer->first[lvl]; while (p) { struct mblock *np = p->next; @@ -70,20 +115,15 @@ int pop_text_stack(int i) { return lvl; } -void *protected_pop_text_stack(int i, void *protected, bool tmp, - size_t sz USES_REGS) { - void *out = protected; +void *pop_output_text_stack__(int i, const void *export) { int lvl = LOCAL_TextBuffer->lvl; - while (lvl > i) { + bool found = false; + while (lvl >= i) { struct mblock *p = LOCAL_TextBuffer->first[lvl]; while (p) { struct mblock *np = p->next; - if (p + 1 == protected) { - if (tmp) - out = LOCAL_FileNameBuf; - else - out = p; - memcpy(out, protected, sz); + if (p + 1 == export) { + found = true; } else { free(p); } @@ -94,10 +134,23 @@ void *protected_pop_text_stack(int i, void *protected, bool tmp, lvl--; } LOCAL_TextBuffer->lvl = lvl; - return out; -} + if (found) { + if (lvl) { + struct mblock *o = (struct mblock *)export-1; + o->lvl = lvl; + o->prev = o->next = 0; + insert_block(o); -// void pop_text_stack(int i) { LOCAL_TextBuffer->lvl = i; } + } else { + struct mblock *p = (struct mblock *)export-1; + size_t sz = p->sz - sizeof(struct mblock); + memmove(p, p + 1, sz); + export = p; + + } + } + return (void *)export; +} void *Malloc(size_t sz USES_REGS) { int lvl = LOCAL_TextBuffer->lvl; @@ -105,57 +158,76 @@ void *Malloc(size_t sz USES_REGS) { sz = 1024; sz = ALIGN_BY_TYPE(sz + sizeof(struct mblock), CELL); struct mblock *o = malloc(sz); - o->prev = LOCAL_TextBuffer->last[lvl]; - if (o->prev) { - o->prev->next = o; - } - if (LOCAL_TextBuffer->first[lvl]) { - LOCAL_TextBuffer->last[lvl] = o; - } else { - LOCAL_TextBuffer->first[lvl] = LOCAL_TextBuffer->last[lvl] = o; - } - o->next = NULL; + if (!o) + return NULL; o->sz = sz; o->lvl = lvl; + o->prev = o->next = 0; + insert_block(o); + return o + 1; +} + +void *MallocAtLevel(size_t sz, int atL USES_REGS) { + int lvl = LOCAL_TextBuffer->lvl; + if (atL > 0 && atL <= lvl) { + lvl = atL; + } else if (atL < 0 && lvl - atL >= 0) { + lvl += atL; + } else { + return NULL; + } + if (sz == 0) + sz = 1024; + sz = ALIGN_BY_TYPE(sz + sizeof(struct mblock), CELL); + struct mblock *o = malloc(sz); + if (!o) + return NULL; + o->sz = sz; + o->lvl = lvl; + o->prev = o->next = 0; + insert_block(o); return o + 1; } void *Realloc(void *pt, size_t sz USES_REGS) { - sz = ALIGN_BY_TYPE(sz + sizeof(struct mblock), CELL); struct mblock *old = pt, *o; old--; - int lvl = old->lvl; + sz = ALIGN_BY_TYPE(sz + sizeof(struct mblock), CELL); o = realloc(old, sz); - if (o->prev) - o->prev->next = o; - if (o->next) + if (o->next) { o->next->prev = o; - if (LOCAL_TextBuffer->first[lvl] == old) { - LOCAL_TextBuffer->first[lvl] = o; + } else { + LOCAL_TextBuffer->last[o->lvl] = o; } - if (LOCAL_TextBuffer->last[lvl] == old) { - LOCAL_TextBuffer->last[lvl] = o; + if (o->prev) { + o->prev->next = o; + } else { + LOCAL_TextBuffer->first[o->lvl] = o; } - + o->sz = sz; return o + 1; } +/** + * Export a local memory object as a RO object to the outside world, that is, + * recovering as much storage as one can. + * @param pt pointer to object + * @return new object + */ +const void *MallocExportAsRO(const void *pt USES_REGS) { + struct mblock *old = (void *)pt, *o = old - 1; + if (old == NULL) + return NULL; + size_t sz = o->sz; + release_block(o); + memmove((void *)o, pt, sz); + return realloc((void *)o, sz); +} + void Free(void *pt USES_REGS) { struct mblock *o = pt; o--; - if (o->prev) - o->prev->next = o->next; - if (o->next) - o->next->prev = o->prev; - int lvl = o->lvl; - if (LOCAL_TextBuffer->first[lvl] == o) { - if (LOCAL_TextBuffer->last[lvl] == o) { - LOCAL_TextBuffer->first[lvl] = LOCAL_TextBuffer->last[lvl] = NULL; - } - LOCAL_TextBuffer->first[lvl] = o->next; - } else if (LOCAL_TextBuffer->last[lvl] == o) { - LOCAL_TextBuffer->last[lvl] = o->prev; - } + release_block(o); free(o); } @@ -164,11 +236,7 @@ void *Yap_InitTextAllocator(void) { return new; } -static size_t MaxTmp(USES_REGS1) { - - return ((char *)LOCAL_TextBuffer->buf + LOCAL_TextBuffer->sz) - - (char *)LOCAL_TextBuffer->ptr; -} +static size_t MaxTmp(USES_REGS1) { return 1025; } static Term Globalize(Term v USES_REGS) { if (!IsVarTerm(v = Deref(v))) { @@ -181,129 +249,138 @@ static Term Globalize(Term v USES_REGS) { return v; } -static Int SkipListCodes(unsigned char **bufp, Term *l, Term **tailp, - Int *atoms, bool *wide, seq_tv_t *inp USES_REGS) { - Int length = 0; - Term *s; /* slow */ - Term v; /* temporary */ - *wide = false; - unsigned char *st0 = *bufp, *st; +static void *codes2buf(Term t0, void *b0, bool get_codes, + bool fixed USES_REGS) { + unsigned char *st0, *st, ar[16]; + Term t = t0; + size_t length = 0; - if (!st0) { - st0 = Malloc(0); + if (t == TermNil) { + st0 = Malloc(4); + st0[0] = 0; + return st0; } - - do_derefa(v, l, derefa_unk, derefa_nonvar); - *tailp = l; - s = l; - - *bufp = st = st0; - - if (*l == TermNil) { - st[0] = '\0'; - return 0; + if (!IsPairTerm(t)) { + Yap_ThrowError(TYPE_ERROR_LIST, t, "scanning list of codes"); + return NULL; } - if (IsPairTerm(*l)) { - Term hd0 = HeadOfTerm(*l); - if (IsVarTerm(hd0)) { - return -INSTANTIATION_ERROR; + bool codes = IsIntegerTerm(HeadOfTerm(t)); + if (get_codes != codes && fixed) { + if (codes) { + Yap_ThrowError(TYPE_ERROR_INTEGER, HeadOfTerm(t), + "scanning list of codes"); + } else { + Yap_ThrowError(TYPE_ERROR_ATOM, HeadOfTerm(t), "scanning list of atoms"); } - // are we looking for atoms/codes? - // whatever the case, we should be consistent throughout, - // so we should be consistent with the first arg. - if (*atoms == 1) { - if (!IsIntegerTerm(hd0)) { - return -INSTANTIATION_ERROR; + } + if (codes) { + while (IsPairTerm(t)) { + Term hd = HeadOfTerm(t); + if (IsVarTerm(hd)) { + Yap_ThrowError(INSTANTIATION_ERROR, hd, "scanning list of codes"); + return NULL; } - } else if (*atoms == 2) { - if (!IsAtomTerm(hd0)) { - return -TYPE_ERROR_ATOM; + if (!IsIntegerTerm(hd)) { + Yap_ThrowError(TYPE_ERROR_CHARACTER_CODE, hd, "scanning list of codes"); + return NULL; + } + Int code = IntegerOfTerm(hd); + if (code < 0) { + Yap_ThrowError(REPRESENTATION_ERROR_CHARACTER_CODE, hd, + "scanning list of character codes, found %d", code); + return NULL; + } + length += put_utf8(ar, code); + t = TailOfTerm(t); + if (IsVarTerm(t)) { + Yap_ThrowError(INSTANTIATION_ERROR, t, "scanning list of codes"); + return NULL; + } + if (!IsPairTerm(t) && t != TermNil) { + Yap_ThrowError(TYPE_ERROR_LIST, t, "scanning list of codes"); + return NULL; } } + } else { + while (IsPairTerm(t)) { + Term hd = HeadOfTerm(t); + if (IsVarTerm(hd)) { + Yap_ThrowError(INSTANTIATION_ERROR, hd, "scanning list of codes"); + return NULL; + } + if (!IsAtomTerm(hd)) { + Yap_ThrowError(TYPE_ERROR_CHARACTER, hd, "scanning list of texts"); + return NULL; + } + const char *code = RepAtom(AtomOfTerm(hd))->StrOfAE; + if (code < 0) { + Yap_ThrowError(TYPE_ERROR_CHARACTER, hd, "scanning list of atoms"); + return NULL; + } + length += strlen(code); + t = TailOfTerm(t); + if (IsVarTerm(t)) { + Yap_ThrowError(INSTANTIATION_ERROR, t, "scanning list of codes"); + return NULL; + } + if (!IsPairTerm(t) && t != TermNil) { + Yap_ThrowError(TYPE_ERROR_LIST, t, "scanning list of codes"); + return NULL; + } + } + } - do { - int ch; - length++; - { - Term hd = Deref(RepPair(*l)[0]); - if (IsVarTerm(hd)) { - return -INSTANTIATION_ERROR; - } else if (IsAtomTerm(hd)) { - (*atoms)++; - if (*atoms < length) { - *tailp = l; - return -REPRESENTATION_ERROR_CHARACTER_CODE; - } else { - AtomEntry *ae = RepAtom(AtomOfTerm(hd)); - if ((ae->StrOfAE)[1] != '\0') { - length = -REPRESENTATION_ERROR_CHARACTER; - } else { - ch = RepAtom(AtomOfTerm(hd))->StrOfAE[0]; - *wide |= ch > 0x80; - } - } - } else if (IsIntegerTerm(hd)) { - ch = IntegerOfTerm(hd); - if (*atoms) - length = -REPRESENTATION_ERROR_CHARACTER; - else if (ch < 0) { - *tailp = l; - length = -REPRESENTATION_ERROR_CHARACTER_CODE; - } else { - *wide |= ch > 0x80; - } - } else { - length = -TYPE_ERROR_INTEGER; - } - if (length < 0) { - *tailp = l; - return length; - } - } - // now copy char to buffer - int chsz = put_utf8(st, ch); - if (chsz > 0) { - st += chsz; - } - l = RepPair(*l) + 1; - do_derefa(v, l, derefa2_unk, derefa2_nonvar); - } while (*l != *s && IsPairTerm(*l)); + if (!IsVarTerm(t)) { + if (t != TermNil) { + Yap_ThrowError(TYPE_ERROR_LIST, t, "scanning list of codes"); + return NULL; + } } - if (IsVarTerm(*l)) { - return -INSTANTIATION_ERROR; - } - if (*l != TermNil) { - return -TYPE_ERROR_LIST; + + st0 = st = Malloc(length + 1); + t = t0; + if (codes) { + while (IsPairTerm(t)) { + Term hd = HeadOfTerm(t); + Int code = IntegerOfTerm(hd); + + st = st + put_utf8(st, code); + t = TailOfTerm(t); + } + } else { + while (IsPairTerm(t)) { + Term hd = HeadOfTerm(t); + const char *code = RepAtom(AtomOfTerm(hd))->StrOfAE; + st = (unsigned char *)stpcpy((char *)st, code); + t = TailOfTerm(t); + } } st[0] = '\0'; - Malloc((st - st0) + 1); - *tailp = l; - return length; + return st0; } -static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) { +static unsigned char *latin2utf8(seq_tv_t *inp) { unsigned char *b0 = inp->val.uc; - size_t sz = *lengp = strlen(inp->val.c); + size_t sz = strlen(inp->val.c); sz *= 2; int ch; unsigned char *buf = Malloc(sz + 1), *pt = buf; - *lengp = strlen(inp->val.c); if (!buf) return NULL; while ((ch = *b0++)) { int off = put_utf8(pt, ch); - if (off < 0) + if (off < 0) { continue; + } pt += off; } *pt++ = '\0'; return buf; } -static unsigned char *wchar2utf8(seq_tv_t *inp, size_t *lengp) { - *lengp = wcslen(inp->val.w); - size_t sz = *lengp * 4; +static unsigned char *wchar2utf8(seq_tv_t *inp) { + size_t sz = wcslen(inp->val.w) * 4; wchar_t *b0 = inp->val.w; unsigned char *buf = Malloc(sz + 1), *pt = buf; int ch; @@ -315,46 +392,25 @@ static unsigned char *wchar2utf8(seq_tv_t *inp, size_t *lengp) { return buf; } -static void *slice(size_t min, size_t max, unsigned char *buf USES_REGS); - -static unsigned char *to_buffer(unsigned char *buf, Term t, seq_tv_t *inp, - bool *widep, Int *atoms, - size_t *lenp USES_REGS) { - CELL *r = NULL; - Int n; - - if (!buf) { - inp->max = *lenp; - } - unsigned char *bufc = buf; - n = SkipListCodes(&bufc, &t, &r, atoms, widep, inp PASS_REGS); - if (n < 0) { - LOCAL_Error_TYPE = -n; - return NULL; - } - *lenp = n; - return bufc; -} +static void *slice(size_t min, size_t max, const unsigned char *buf USES_REGS); static unsigned char *Yap_ListOfCodesToBuffer(unsigned char *buf, Term t, - seq_tv_t *inp, bool *widep, - size_t *lenp USES_REGS) { - Int atoms = 1; // we only want lists of atoms - return to_buffer(buf, t, inp, widep, &atoms, lenp PASS_REGS); + seq_tv_t *inp USES_REGS) { + bool codes = true, fixed = true; + unsigned char *nbuf = codes2buf(t, buf, codes, fixed PASS_REGS); + return nbuf; } static unsigned char *Yap_ListOfAtomsToBuffer(unsigned char *buf, Term t, - seq_tv_t *inp, bool *widep, - size_t *lenp USES_REGS) { - Int atoms = 2; // we only want lists of integer codes - return to_buffer(buf, t, inp, widep, &atoms, lenp PASS_REGS); + seq_tv_t *inp USES_REGS) { + bool codes = false; + unsigned char *nbuf = codes2buf(t, buf, codes, true PASS_REGS); + return nbuf; } static unsigned char *Yap_ListToBuffer(unsigned char *buf, Term t, - seq_tv_t *inp, bool *widep, - size_t *lenp USES_REGS) { - Int atoms = 0; // we accept both types of lists. - return to_buffer(buf, t, inp, widep, &atoms, lenp PASS_REGS); + seq_tv_t *inp USES_REGS) { + return codes2buf(t, buf, NULL, false PASS_REGS); } #if USE_GEN_TYPE_ERROR @@ -382,16 +438,13 @@ static yap_error_number gen_type_error(int flags) { } #endif -// static int cnt; +// static int cnt; -unsigned char *Yap_readText(seq_tv_t *inp, size_t *lengp) { - unsigned char *s0 = NULL; - bool wide; - - if (LOCAL_Error_TYPE != YAP_NO_ERROR) { - fprintf(stderr, "Sourious error %u\n", LOCAL_Error_TYPE); - LOCAL_Error_TYPE = YAP_NO_ERROR; - } +unsigned char *Yap_readText(seq_tv_t *inp USES_REGS) { +#define POPRET(x) return pop_output_text_stack(lvl, x) + int lvl = push_text_stack(); + char *out = NULL; + yap_error_number err0 = LOCAL_Error_TYPE; /* we know what the term is */ if (!(inp->type & (YAP_STRING_CHARS | YAP_STRING_WCHARS))) { if (!(inp->type & YAP_STRING_TERM)) { @@ -403,161 +456,179 @@ unsigned char *Yap_readText(seq_tv_t *inp, size_t *lengp) { LOCAL_Error_TYPE = TYPE_ERROR_STRING; } else if (!IsPairOrNilTerm(inp->val.t) && !IsStringTerm(inp->val.t) && inp->type == (YAP_STRING_ATOMS_CODES | YAP_STRING_STRING)) { - LOCAL_Error_TYPE = TYPE_ERROR_LIST; - } else if (!IsNumTerm(inp->val.t) && - (inp->type & (YAP_STRING_INT | YAP_STRING_FLOAT | - YAP_STRING_BIG)) == inp->type) { - LOCAL_Error_TYPE = TYPE_ERROR_NUMBER; + LOCAL_ActiveError->errorRawTerm = inp->val.t; + } else if (!IsPairOrNilTerm(inp->val.t) && !IsStringTerm(inp->val.t) && + !IsAtomTerm(inp->val.t) && !(inp->type & YAP_STRING_DATUM)) { + LOCAL_Error_TYPE = TYPE_ERROR_TEXT; } } + if (err0 != LOCAL_Error_TYPE) { + Yap_ThrowError(LOCAL_Error_TYPE, inp->val.t, "while reading text in"); + } } - if (LOCAL_Error_TYPE != YAP_NO_ERROR) - return NULL; + if ((inp->val.t == TermNil) && inp->type & YAP_STRING_PREFER_LIST ) + { + out = Malloc(4); + memset(out, 0, 4); + POPRET( out ); + } if (IsAtomTerm(inp->val.t) && inp->type & YAP_STRING_ATOM) { // this is a term, extract to a buffer, and representation is wide // Yap_DebugPlWriteln(inp->val.t); Atom at = AtomOfTerm(inp->val.t); - if (lengp) - *lengp = strlen(at->StrOfAE); - return at->UStrOfAE; + if (RepAtom(at)->UStrOfAE[0] == 0) { + out = Malloc(4); + memset(out, 0, 4); + POPRET( out ); + } + if (inp->type & YAP_STRING_WITH_BUFFER) { + pop_text_stack(lvl); + return at->UStrOfAE; + } + { + size_t sz = strlen(at->StrOfAE); + out = Malloc(sz + 1); + strcpy(out, at->StrOfAE); + POPRET( out ); + } } if (IsStringTerm(inp->val.t) && inp->type & YAP_STRING_STRING) { // this is a term, extract to a buffer, and representation is wide // Yap_DebugPlWriteln(inp->val.t); - if (lengp) - *lengp = strlen(StringOfTerm(inp->val.t)); - return (unsigned char *)UStringOfTerm(inp->val.t); - } - if (((inp->type & (YAP_STRING_CODES | YAP_STRING_ATOMS)) == - (YAP_STRING_CODES | YAP_STRING_ATOMS)) && - IsPairOrNilTerm(inp->val.t)) { - // Yap_DebugPlWriteln(inp->val.t); - return Yap_ListToBuffer(s0, inp->val.t, inp, &wide, lengp PASS_REGS); - // this is a term, extract to a sfer, and representation is wide - } - if (inp->type & YAP_STRING_CODES && IsPairOrNilTerm(inp->val.t)) { - // Yap_DebugPlWriteln(inp->val.t); - return Yap_ListOfCodesToBuffer(s0, inp->val.t, inp, &wide, lengp PASS_REGS); - // this is a term, extract to a sfer, and representation is wide - } - if (inp->type & YAP_STRING_ATOMS && IsPairOrNilTerm(inp->val.t)) { - // Yap_DebugPlWriteln(inp->val.t); - return Yap_ListOfAtomsToBuffer(s0, inp->val.t, inp, &wide, lengp PASS_REGS); - // this is a term, extract to a buffer, and representation is wide + const char *s = StringOfTerm(inp->val.t); + if (s[0] == 0) { + out = Malloc(4); + memset(out, 0, 4); + POPRET( out ); + } + if (inp->type & YAP_STRING_WITH_BUFFER) { + pop_text_stack(lvl); + return (unsigned char *)UStringOfTerm(inp->val.t); + } + { + inp->type |= YAP_STRING_IN_TMP; + size_t sz = strlen(s); + out = Malloc(sz + 1); + strcpy(out, s); + POPRET( out ); + } + } else if (IsPairOrNilTerm(inp->val.t)) { + if (((inp->type & (YAP_STRING_CODES | YAP_STRING_ATOMS)) == + (YAP_STRING_CODES | YAP_STRING_ATOMS))) { + // Yap_DebugPlWriteln(inp->val.t); + out = (char *)Yap_ListToBuffer(NULL, inp->val.t, inp PASS_REGS); + POPRET( out ); + // this is a term, extract to a sfer, and representation is wide + } + if (inp->type & YAP_STRING_CODES) { + // Yap_DebugPlWriteln(inp->val.t); + out = (char *)Yap_ListOfCodesToBuffer(NULL, inp->val.t, inp PASS_REGS); + // this is a term, extract to a sfer, and representation is wide + POPRET( out ); + } + if (inp->type & YAP_STRING_ATOMS) { + // Yap_DebugPlWriteln(inp->val.t); + out = (char *)Yap_ListOfAtomsToBuffer(NULL, inp->val.t, inp PASS_REGS); + // this is a term, extract to a buffer, and representation is wide + POPRET( out ); + } } if (inp->type & YAP_STRING_INT && IsIntegerTerm(inp->val.t)) { // ASCII, so both LATIN1 and UTF-8 // Yap_DebugPlWriteln(inp->val.t); - char *s; - s = Malloc(0); - if (snprintf(s, MaxTmp(PASS_REGS1) - 1, Int_FORMAT, + out = Malloc(2 * MaxTmp(PASS_REGS1)); + if (snprintf(out, MaxTmp(PASS_REGS1) - 1, Int_FORMAT, IntegerOfTerm(inp->val.t)) < 0) { - AUX_ERROR(inp->val.t, 2 * MaxTmp(PASS_REGS1), s, char); + AUX_ERROR(inp->val.t, 2 * MaxTmp(PASS_REGS1), out, char); } - if (lengp) - *lengp = strlen(s); - return (unsigned char *)s; + POPRET( out ); } if (inp->type & YAP_STRING_FLOAT && IsFloatTerm(inp->val.t)) { - char *s; - // Yap_DebugPlWriteln(inp->val.t); - if (!Yap_FormatFloat(FloatOfTerm(inp->val.t), &s, 1024)) { + out = Malloc(2 * MaxTmp(PASS_REGS1)); + if (!Yap_FormatFloat(FloatOfTerm(inp->val.t), &out, 1024)) { + pop_text_stack(lvl); return NULL; } - if (lengp) - *lengp = strlen(s); - return (unsigned char *)s; - } + POPRET(out); + } #if USE_GMP if (inp->type & YAP_STRING_BIG && IsBigIntTerm(inp->val.t)) { // Yap_DebugPlWriteln(inp->val.t); - char *s; - s = Malloc(0); - if (!Yap_mpz_to_string(Yap_BigIntOfTerm(inp->val.t), s, MaxTmp() - 1, 10)) { - AUX_ERROR(inp->val.t, MaxTmp(PASS_REGS1), s, char); + out = Malloc(MaxTmp()); + if (!Yap_mpz_to_string(Yap_BigIntOfTerm(inp->val.t), out, MaxTmp() - 1, + 10)) { + AUX_ERROR(inp->val.t, MaxTmp(PASS_REGS1), out, char); } - if (lengp) - *lengp = strlen(s); - return inp->val.uc = (unsigned char *)s; + POPRET(out); } #endif if (inp->type & YAP_STRING_TERM) { - // Yap_DebugPlWriteln(inp->val.t); - char *s = (char *)Yap_TermToString(inp->val.t, lengp, ENC_ISO_UTF8, 0); - return inp->val.uc = (unsigned char *)s; + pop_text_stack(lvl); + return (unsigned char *)Yap_TermToBuffer(inp->val.t, 0); } - if (inp->type & YAP_STRING_CHARS) { - if (inp->enc == ENC_ISO_LATIN1) { - return latin2utf8(inp, lengp); - } else if (inp->enc == ENC_ISO_ASCII) { - if (lengp) - *lengp = strlen(inp->val.c); + + if (inp->type & YAP_STRING_CHARS) { + if (inp->enc == ENC_ISO_ASCII) { + pop_text_stack(lvl); return inp->val.uc; - }else { //if (inp->enc == ENC_ISO_UTF8) { - if (lengp) - *lengp = strlen(inp->val.c); + } + + if (inp->enc == ENC_ISO_LATIN1) { + POPRET( (char*)latin2utf8(inp)); + } + + pop_text_stack(lvl); return inp->val.uc; - } } if (inp->type & YAP_STRING_WCHARS) { // printf("%S\n",inp->val.w); - return wchar2utf8(inp, lengp); + POPRET( (char *)wchar2utf8(inp) ); } + pop_text_stack(lvl); return NULL; } -static Term write_strings(unsigned char *s0, seq_tv_t *out, - size_t leng USES_REGS) { - size_t min = 0, max = leng; +static Term write_strings(unsigned char *s0, seq_tv_t *out USES_REGS) { + size_t min = 0, max = strlen((char *)s0); if (out->type & (YAP_STRING_NCHARS | YAP_STRING_TRUNC)) { if (out->type & YAP_STRING_NCHARS) min = out->max; - if (out->type & YAP_STRING_TRUNC && out->max < max) + if (out->type & YAP_STRING_TRUNC && out->max < max) { max = out->max; + s0[max] = '\0'; + } } - unsigned char *s = s0, *lim = s + (max = strlen_utf8(s)); + char *s = (char *)s0; Term t = init_tstring(PASS_REGS1); - unsigned char *cp = s, *buf; - - LOCAL_TERM_ERROR(t, 2 * (lim - s)); - buf = buf_from_tstring(HR); - while (*cp && cp < lim) { - utf8proc_int32_t chr; - int off; - off = get_utf8(cp, -1, &chr); - if (off > 0) - cp += off; - else { - // Yap_Error(TYPE_ERROR_TEXT, t, NULL); - cp++; - } - off = put_utf8(buf, chr); - if (off > 0) - buf += off; - } - if (max >= min) - *buf++ = '\0'; + LOCAL_TERM_ERROR(t, 2 * max); + unsigned char *buf = buf_from_tstring(HR); + if (max == 0) + buf[0] = '\0'; else - while (max < min) { - max++; - buf += put_utf8(buf, '\0'); - } - + strcpy((char *)buf, s); + if (max + 1 < min) { + LOCAL_TERM_ERROR(t, 2 * min); + memset(buf + min, '\0', max); + buf += min; + } else { + buf += max + 1; + } close_tstring(buf PASS_REGS); out->val.t = t; return out->val.t; } -static Term write_atoms(void *s0, seq_tv_t *out, size_t leng USES_REGS) { +static Term write_atoms(void *s0, seq_tv_t *out USES_REGS) { Term t = AbsPair(HR); + char *s1 = (char *)s0; size_t sz = 0; - size_t max = leng; - if (leng == 0) { - out->val.t = t; + size_t max = strlen(s1); + if (s1[0] == '\0') { + out->val.t = TermNil; return TermNil; } if (out->type & (YAP_STRING_NCHARS | YAP_STRING_TRUNC)) { @@ -567,17 +638,19 @@ static Term write_atoms(void *s0, seq_tv_t *out, size_t leng USES_REGS) { unsigned char *s = s0, *lim = s + strnlen((char *)s, max); unsigned char *cp = s; - unsigned char w[10], *wp = w; + unsigned char w[10]; + int wp = 0; LOCAL_TERM_ERROR(t, 2 * (lim - s)); while (cp < lim && *cp) { utf8proc_int32_t chr; CELL *cl; - s += get_utf8(s, 1, &chr); + s += get_utf8(s, -1, &chr); if (chr == '\0') { - wp[0] = '\0'; + w[0] = '\0'; break; } - wp += put_utf8(w, chr); + wp = put_utf8(w, chr); + w[wp] = '\0'; cl = HR; HR += 2; cl[0] = MkAtomTerm(Yap_ULookupAtom(w)); @@ -601,23 +674,23 @@ static Term write_atoms(void *s0, seq_tv_t *out, size_t leng USES_REGS) { return (t); } -static Term write_codes(void *s0, seq_tv_t *out, size_t leng USES_REGS) { - Term t = AbsPair(HR); - size_t sz = 0; - size_t max = leng; - if (leng == 0) { - out->val.t = t; - return TermNil; +static Term write_codes(void *s0, seq_tv_t *out USES_REGS) { + Term t; + size_t sz = strlen(s0); + if (sz == 0) { + if (out->type & YAP_STRING_DIFF) { + out->val.t = Globalize(out->dif PASS_REGS); + } else { + out->val.t = TermNil; + } + return out->val.t; } - if (out->type & (YAP_STRING_NCHARS | YAP_STRING_TRUNC)) { - if (out->type & YAP_STRING_TRUNC && out->max < max) - max = out->max; - } - - unsigned char *s = s0, *lim = s + strlen((char *)s); + unsigned char *s = s0, *lim = s + sz; unsigned char *cp = s; + t = AbsPair(HR); LOCAL_TERM_ERROR(t, 2 * (lim - s)); + t = AbsPair(HR); while (*cp) { utf8proc_int32_t chr; CELL *cl; @@ -628,63 +701,61 @@ static Term write_codes(void *s0, seq_tv_t *out, size_t leng USES_REGS) { HR += 2; cl[0] = MkIntegerTerm(chr); cl[1] = AbsPair(HR); - sz++; - if (sz == max) - break; } - if (out->type & YAP_STRING_DIFF) { - if (sz == 0) - t = out->dif; - else - HR[-1] = Globalize(out->dif PASS_REGS); + if (sz == 0) { + HR[-1] = Globalize(out->dif PASS_REGS); } else { - if (sz == 0) - t = TermNil; - else - HR[-1] = TermNil; + HR[-1] = TermNil; } out->val.t = t; return (t); } -static Atom write_atom(void *s0, seq_tv_t *out, size_t leng USES_REGS) { +static Atom write_atom(void *s0, seq_tv_t *out USES_REGS) { unsigned char *s = s0; int32_t ch; - if (leng == 0) { + if (s[0] == '\0') { return Yap_LookupAtom(""); } + size_t leng = strlen(s0); if (strlen_utf8(s0) <= leng) { return Yap_LookupAtom(s0); } else { - size_t n = get_utf8(s, 1, &ch); + size_t n = get_utf8(s, -1, &ch); unsigned char *buf = Malloc(n + 1); - memcpy(buf, s0, n + 1); + memmove(buf, s0, n + 1); return Yap_ULookupAtom(buf); } } -size_t write_buffer(unsigned char *s0, seq_tv_t *out, size_t leng USES_REGS) { - size_t min = 0, max = leng, room_end; +void *write_buffer(unsigned char *s0, seq_tv_t *out USES_REGS) { + int l = push_text_stack(); + size_t leng = strlen((char *)s0); + size_t min = 0, max = leng; if (out->enc == ENC_ISO_UTF8) { - room_end = strlen((char *)s0) + 1; if (out->val.uc == NULL) { // this should always be the case - out->val.uc = malloc(room_end < 16 ? 16 : room_end); - } - if (out->val.uc != s0) { + out->val.uc = Malloc(leng + 1); + strcpy(out->val.c, (char *)s0); + } else if (out->val.uc != s0) { + out->val.c = Malloc(leng + 1); strcpy(out->val.c, (char *)s0); } } else if (out->enc == ENC_ISO_LATIN1) { - room_end = strlen((char *)s0) + 1; + unsigned char *s = s0; unsigned char *cp = s; unsigned char *buf = out->val.uc; - if (!buf) - return -1; + if (!buf) { + pop_text_stack(l); + return NULL; + } while (*cp) { utf8proc_int32_t chr; int off = get_utf8(cp, -1, &chr); - if (off <= 0 || chr > 255) - return -1; + if (off <= 0 || chr > 255) { + pop_text_stack(l); + return NULL; + } if (off == max) break; cp += off; @@ -699,15 +770,16 @@ size_t write_buffer(unsigned char *s0, seq_tv_t *out, size_t leng USES_REGS) { cp += get_utf8(cp, -1, &chr); *buf++ = chr; } - room_end = buf - out->val.uc; } else if (out->enc == ENC_WCHAR) { unsigned char *s = s0, *lim = s + (max = strnlen((char *)s0, max)); unsigned char *cp = s; wchar_t *buf0, *buf; buf = buf0 = out->val.w; - if (!buf) - return -1; + if (!buf) { + pop_text_stack(l); + return NULL; + } while (*cp && cp < lim) { utf8proc_int32_t chr; cp += get_utf8(cp, -1, &chr); @@ -723,47 +795,50 @@ size_t write_buffer(unsigned char *s0, seq_tv_t *out, size_t leng USES_REGS) { *buf++ = chr; } *buf = '\0'; - room_end = (buf - buf0) + 1; } else { // no other encodings are supported. - room_end = -1; + pop_text_stack(l); + return NULL; } - return room_end; + out->val.c = pop_output_text_stack(l, out->val.c); + return out->val.c; } -static size_t write_length(const unsigned char *s0, seq_tv_t *out, - size_t leng USES_REGS) { - return leng; +static size_t write_length(const unsigned char *s0, seq_tv_t *out USES_REGS) { + return strlen_utf8(s0); } -static Term write_number(unsigned char *s, seq_tv_t *out, int size, +static Term write_number(unsigned char *s, seq_tv_t *out, bool error_on USES_REGS) { Term t; - int i = push_text_stack(); + LOCAL_delay = !error_on; t = Yap_StringToNumberTerm((char *)s, &out->enc, error_on); - pop_text_stack(i); + LOCAL_delay = false; return t; } -static Term string_to_term(void *s, seq_tv_t *out, size_t leng USES_REGS) { +static Term string_to_term(void *s, seq_tv_t *out USES_REGS) { Term o; - o = out->val.t = Yap_BufferToTerm(s, strlen(s) + 1, TermNil); + yap_error_descriptor_t *new_error = malloc(sizeof(yap_error_descriptor_t)); + bool mdnew = Yap_pushErrorContext(true, new_error); + o = out->val.t = Yap_BufferToTerm(s, TermNil); + Yap_popErrorContext(mdnew, true); + return o; } -bool write_Text(unsigned char *inp, seq_tv_t *out, size_t leng USES_REGS) { +bool write_Text(unsigned char *inp, seq_tv_t *out USES_REGS) { /* we know what the term is */ if (out->type == 0) { return true; } - - if (out->type & YAP_STRING_TERM) { - if ((out->val.t = string_to_term(inp, out, leng PASS_REGS)) != 0L) - return out->val.t != 0; + if (LOCAL_Error_TYPE) { + return false; } + if (out->type & (YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG)) { if ((out->val.t = write_number( - inp, out, leng, !(out->type & YAP_STRING_ATOM) PASS_REGS)) != 0L) { + inp, out, !(out->type & YAP_STRING_ATOM) PASS_REGS)) != 0L) { // Yap_DebugPlWriteln(out->val.t); return true; @@ -773,7 +848,7 @@ bool write_Text(unsigned char *inp, seq_tv_t *out, size_t leng USES_REGS) { return false; } if (out->type & (YAP_STRING_ATOM)) { - if ((out->val.a = write_atom(inp, out, leng PASS_REGS)) != NIL) { + if ((out->val.a = write_atom(inp, out PASS_REGS)) != NIL) { Atom at = out->val.a; if (at && (out->type & YAP_STRING_OUTPUT_TERM)) out->val.t = MkAtomTerm(at); @@ -781,40 +856,44 @@ bool write_Text(unsigned char *inp, seq_tv_t *out, size_t leng USES_REGS) { return at != NIL; } } + if (out->type & YAP_STRING_DATUM) { + if ((out->val.t = string_to_term(inp, out PASS_REGS)) != 0L) + return out->val.t != 0; + } switch (out->type & YAP_TYPE_MASK) { case YAP_STRING_CHARS: { - size_t room = write_buffer(inp, out, leng PASS_REGS); + void *room = write_buffer(inp, out PASS_REGS); // printf("%s\n", out->val.c); - return ((Int)room > 0); + return room != NULL; } case YAP_STRING_WCHARS: { - size_t room = write_buffer(inp, out, leng PASS_REGS); + void *room = write_buffer(inp, out PASS_REGS); // printf("%S\n", out->val.w); - return ((Int)room > 0); + return room != NULL; } case YAP_STRING_STRING: - out->val.t = write_strings(inp, out, leng PASS_REGS); + out->val.t = write_strings(inp, out PASS_REGS); // Yap_DebugPlWriteln(out->val.t); return out->val.t != 0; case YAP_STRING_ATOMS: - out->val.t = write_atoms(inp, out, leng PASS_REGS); + out->val.t = write_atoms(inp, out PASS_REGS); // Yap_DebugPlWriteln(out->val.t); return out->val.t != 0; case YAP_STRING_CODES: - out->val.t = write_codes(inp, out, leng PASS_REGS); + out->val.t = write_codes(inp, out PASS_REGS); // Yap_DebugPlWriteln(out->val.t); return out->val.t != 0; case YAP_STRING_LENGTH: - out->val.l = write_length(inp, out, leng PASS_REGS); + out->val.l = write_length(inp, out PASS_REGS); // printf("s\n",out->val.l); return out->val.l != (size_t)(-1); case YAP_STRING_ATOM: - out->val.a = write_atom(inp, out, leng PASS_REGS); + out->val.a = write_atom(inp, out PASS_REGS); // Yap_DebugPlWriteln(out->val.t); return out->val.a != NULL; case YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG: - out->val.t = write_number(inp, out, leng, true PASS_REGS); + out->val.t = write_number(inp, out, true PASS_REGS); // Yap_DebugPlWriteln(out->val.t); return out->val.t != 0; default: { return true; } @@ -852,77 +931,69 @@ bool Yap_CVT_Text(seq_tv_t *inp, seq_tv_t *out USES_REGS) { unsigned char *buf; bool rc; - size_t leng; /* - f//printfmark(stderr, "[ %d ", n++) ; + //printf(stderr, "[ %d ", n++) ; if (inp->type & (YAP_STRING_TERM|YAP_STRING_ATOM|YAP_STRING_ATOMS_CODES - |YAP_STRING_STRING)) - //Yap_DebugPlWriteln(inp->val.t); + |YAP_STRING_STRING)) + //Yap_DebugPlWriteln(inp->val.t); else if (inp->type & YAP_STRING_WCHARS) fprintf(stderr,"S %S\n", inp->val - .w); + .w); else fprintf(stderr,"s %s\n", inp->val.c); -*/ + */ // cnt++; - buf = Yap_readText(inp, &leng PASS_REGS); - if (out->type & (YAP_STRING_NCHARS | YAP_STRING_TRUNC)) { - if (out->max < leng) { - const unsigned char *ptr = skip_utf8(buf, out->max); - size_t diff = (ptr - buf); - char *nbuf = Malloc(diff + 1); - memcpy(nbuf, buf, diff); - nbuf[diff] = '\0'; - leng = out->max; - } - // else if (out->type & YAP_STRING_NCHARS && - // const unsigned char *ptr = skip_utf8(buf, leng) - } + int l = push_text_stack(); + buf = Yap_readText(inp PASS_REGS); if (!buf) { + pop_text_stack(l); return 0L; } - - if (out->type & (YAP_STRING_UPCASE | YAP_STRING_DOWNCASE)) { - if (out->type & YAP_STRING_UPCASE) { - if (!upcase(buf, out)) { - return false; + if (buf[0]) { + size_t leng = strlen_utf8(buf); + if (out->type & (YAP_STRING_NCHARS | YAP_STRING_TRUNC)) { + if (out->max < leng) { + const unsigned char *ptr = skip_utf8(buf, out->max); + size_t diff = (ptr - buf); + char *nbuf = Malloc(diff + 1); + memmove(nbuf, buf, diff); + nbuf[diff] = '\0'; + leng = diff; } + // else if (out->type & YAP_STRING_NCHARS && + // const unsigned char *ptr = skip_utf8(buf) } - if (out->type & YAP_STRING_DOWNCASE) { - if (!downcase(buf, out)) { - return false; + + if (out->type & (YAP_STRING_UPCASE | YAP_STRING_DOWNCASE)) { + if (out->type & YAP_STRING_UPCASE) { + if (!upcase(buf, out)) { + pop_text_stack(l); + return false; + } + } + if (out->type & YAP_STRING_DOWNCASE) { + if (!downcase(buf, out)) { + pop_text_stack(l); + return false; + } } } } - - rc = write_Text(buf, out, leng PASS_REGS); + rc = write_Text(buf, out PASS_REGS); /* fprintf(stderr, " -> "); - if (!rc) fprintf(stderr, "NULL"); - else if (out->type & - (YAP_STRING_TERM|YAP_STRING_ATOMS_CODES - |YAP_STRING_STRING)) //Yap_DebugPlWrite(out->val.t); - else if (out->type & - YAP_STRING_ATOM) //Yap_DebugPlWriteln(MkAtomTerm(out->val.a)); - else if (out->type & YAP_STRING_WCHARS) fprintf(stderr, "%S", - out->val.w); - else - fprintf(stderr, "%s", out->val.c); - fprintf(stderr, "\n]\n"); */ + if (!rc) fprintf(stderr, "NULL"); + else if (out->type & + (YAP_STRING_TERM|YAP_STRING_ATOMS_CODES + |YAP_STRING_STRING)) //Yap_DebugPlWrite(out->val.t); + else if (out->type & + YAP_STRING_ATOM) //Yap_DebugPlWriteln(MkAtomTerm(out->val.a)); + else if (out->type & YAP_STRING_WCHARS) fprintf(stderr, "%S", + out->val.w); + else + fprintf(stderr, "%s", out->val.c); + fprintf(stderr, "\n]\n"); */ + out->val.uc = pop_output_text_stack(l,out->val.uc); return rc; } -static int cmp_Text(const unsigned char *s1, const unsigned char *s2, int l) { - const unsigned char *w1 = s1; - utf8proc_int32_t chr1, chr2; - const unsigned char *w2 = s2; - int i; - for (i = 0; i < l; i++) { - w2 += get_utf8(w2, -1, &chr2); - w1 += get_utf8(w1, -1, &chr1); - if (chr1 - chr2) - return chr1 - chr2; - } - return 0; -} - static unsigned char *concat(int n, void *sv[] USES_REGS) { void *buf; unsigned char *buf0; @@ -930,23 +1001,28 @@ static unsigned char *concat(int n, void *sv[] USES_REGS) { int i; for (i = 0; i < n; i++) { - room += strlen((char *)sv[i]); + char *s = sv[i]; + if (s[0]) + room += strlen(s); } buf = Malloc(room + 1); buf0 = buf; for (i = 0; i < n; i++) { + char *s = sv[i]; + if (!s[0]) + continue; #if _WIN32 || defined(__ANDROID__) - strcpy(buf, sv[i]); + strcpy(buf, s); buf = (char *)buf + strlen(buf); #else - buf = stpcpy(buf, sv[i]); + buf = stpcpy(buf, s); #endif } return buf0; } -static void *slice(size_t min, size_t max, unsigned char *buf USES_REGS) { - unsigned char *nbuf = Malloc((max - min) * 4 + 1); +static void *slice(size_t min, size_t max, const unsigned char *buf USES_REGS) { + unsigned char *nbuf = BaseMalloc((max - min) * 4 + 1); const unsigned char *ptr = skip_utf8(buf, min); unsigned char *nptr = nbuf; utf8proc_int32_t chr; @@ -964,71 +1040,104 @@ static void *slice(size_t min, size_t max, unsigned char *buf USES_REGS) { bool Yap_Concat_Text(int tot, seq_tv_t inp[], seq_tv_t *out USES_REGS) { void **bufv; unsigned char *buf; - int i; - size_t leng; + int i, j; + int lvl = push_text_stack(); bufv = Malloc(tot * sizeof(unsigned char *)); if (!bufv) { + pop_text_stack(lvl); return NULL; } - for (i = 0; i < tot; i++) { - inp[i].type |= YAP_STRING_IN_TMP; - unsigned char *nbuf = Yap_readText(inp + i, &leng PASS_REGS); + for (i = 0, j = 0; i < tot; i++) { + inp[j].type |= YAP_STRING_WITH_BUFFER; + unsigned char *nbuf = Yap_readText(inp + i PASS_REGS); if (!nbuf) { + pop_text_stack(lvl); return NULL; } - bufv[i] = nbuf; + // if (!nbuf[0]) + // continue; + bufv[j++] = nbuf; } - buf = concat(tot, bufv PASS_REGS); - bool rc = write_Text(buf, out, strlen_utf8(buf) PASS_REGS); + if (j == 0) { + buf = Malloc(8); + memset(buf, 0, 4); + } else if (j == 1) { + buf = bufv[0]; + } else { + buf = concat(tot, bufv PASS_REGS); + } + bool rc = write_Text(buf, out PASS_REGS); + pop_text_stack( lvl ); + return rc; } // bool Yap_Splice_Text(int n, size_t cuts[], seq_tv_t *inp, seq_tv_t outv[] USES_REGS) { - unsigned char *buf; - size_t l; + int lvl = push_text_stack(); + const unsigned char *buf; + size_t b_l, u_l; inp->type |= YAP_STRING_IN_TMP; - buf = Yap_readText(inp, &l PASS_REGS); + buf = Yap_readText(inp PASS_REGS); if (!buf) { + pop_text_stack(lvl); return false; } + b_l = strlen((char *)buf); + if (b_l == 0) { + pop_text_stack(lvl); + return false; + } + u_l = strlen_utf8(buf); if (!cuts) { if (n == 2) { - size_t l0, l1; + size_t b_l0, b_l1, u_l0, u_l1; unsigned char *buf0, *buf1; if (outv[0].val.t) { - buf0 = Yap_readText(outv, &l0 PASS_REGS); + buf0 = Yap_readText(outv PASS_REGS); if (!buf0) { return false; } - if (cmp_Text(buf, buf0, l0) != 0) { + b_l0 = strlen((const char *)buf0); + if (memcmp(buf, buf0, b_l0) != 0) { + pop_text_stack(lvl); return false; } - l1 = l - l0; + u_l0 = strlen_utf8(buf0); + u_l1 = u_l - u_l0; - buf1 = slice(l0, l, buf PASS_REGS); - bool rc = write_Text(buf1, outv + 1, l1 PASS_REGS); + b_l1 = b_l - b_l0; + buf1 = slice(u_l0, u_l, buf PASS_REGS); + b_l1 = strlen((const char *)buf1); + bool rc = write_Text(buf1, outv + 1 PASS_REGS); + pop_text_stack(lvl); if (!rc) { return false; } return rc; } else /* if (outv[1].val.t) */ { - buf1 = Yap_readText(outv + 1, &l1 PASS_REGS); + buf1 = Yap_readText(outv + 1 PASS_REGS); if (!buf1) { + pop_text_stack(lvl); return false; } - l0 = l - l1; - if (cmp_Text(skip_utf8((const unsigned char *)buf, l0), buf1, l1) != + b_l1 = strlen((char *)buf1); + u_l1 = strlen_utf8(buf1); + b_l0 = b_l - b_l1; + u_l0 = u_l - u_l1; + if (memcmp(skip_utf8((const unsigned char *)buf, b_l0), buf1, b_l1) != 0) { + pop_text_stack(lvl); return false; } - buf0 = slice(0, l0, buf PASS_REGS); - bool rc = write_Text(buf0, outv, l0 PASS_REGS); + buf0 = slice(0, u_l0, buf PASS_REGS); + buf0 = pop_output_text_stack(lvl, buf0); + bool rc = write_Text(buf0, outv PASS_REGS); return rc; } } @@ -1042,53 +1151,16 @@ bool Yap_Splice_Text(int n, size_t cuts[], seq_tv_t *inp, if (i > 0 && cuts[i] == 0) break; void *bufi = slice(next, cuts[i], buf PASS_REGS); - if (!write_Text(bufi, outv + i, cuts[i] - next PASS_REGS)) { + bufi = pop_output_text_stack(lvl, bufi); + if (!write_Text(bufi, outv + i PASS_REGS)) { return false; } } + pop_text_stack(lvl); return true; } -/** - * Function to convert a generic text term (string, atom, list of codes, list -of< -atoms) into a buff -er. - * - * @param t the term - * @param buf the buffer, if NULL a buffer is malloced, and the user should -reclai it - * @param len buffer size - * @param enc encoding (UTF-8 is strongly recommended) - * - * @return the buffer, or NULL in case of failure. If so, Yap_Error may be -called. - */ -const char *Yap_TextTermToText(Term t, char *buf, size_t len, encoding_t enc) { - CACHE_REGS - seq_tv_t inp, out; - inp.val.t = t; - if (IsAtomTerm(t) && t != TermNil) { - inp.type = YAP_STRING_ATOM; - inp.enc = ENC_ISO_UTF8; - } else if (IsStringTerm(t)) { - inp.type = YAP_STRING_STRING; - inp.enc = ENC_ISO_UTF8; - } else if (IsPairOrNilTerm(t)) { - inp.type = (YAP_STRING_CODES | YAP_STRING_ATOMS); - } else { - Yap_Error(TYPE_ERROR_TEXT, t, NULL); - return false; - } - out.enc = enc; - out.type = YAP_STRING_CHARS; - out.val.c = buf; - if (!Yap_CVT_Text(&inp, &out PASS_REGS)) - return NULL; - return out.val.c; -} - /** * Convert from a predicate structure to an UTF-8 string of the form * @@ -1110,8 +1182,8 @@ const char *Yap_PredIndicatorToUTF8String(PredEntry *ap) { smax = s + 1024; Term tmod = ap->ModuleOfPred; if (tmod) { - Yap_AtomToUTF8Text(AtomOfTerm(tmod), s); - s += strlen(s); + char *sn = Yap_AtomToUTF8Text(AtomOfTerm(tmod)); + stpcpy(s, sn); if (smax - s > 1) { strcat(s, ":"); } else { @@ -1133,7 +1205,7 @@ const char *Yap_PredIndicatorToUTF8String(PredEntry *ap) { return LOCAL_FileNameBuf; } else if (ap->PredFlags & AtomDBPredFlag) { at = (Atom)(ap->FunctorOfPred); - if (!Yap_AtomToUTF8Text(at, s)) + if (!stpcpy(s, Yap_AtomToUTF8Text(at))) return NULL; } else { f = ap->FunctorOfPred; @@ -1148,7 +1220,7 @@ const char *Yap_PredIndicatorToUTF8String(PredEntry *ap) { at = (Atom)(ap->FunctorOfPred); } } - if (!Yap_AtomToUTF8Text(at, s)) { + if (!stpcpy(s, Yap_AtomToUTF8Text(at))) { return NULL; } s += strlen(s); @@ -1161,18 +1233,18 @@ const char *Yap_PredIndicatorToUTF8String(PredEntry *ap) { * _Tguide_ * ≈* @param s the buffer -≈ * @param tguide the guide + ≈ * @param tguide the guide * -≈ * @return the term - */ -Term Yap_MkTextTerm(const char *s, encoding_t enc, Term tguide) { - CACHE_REGS - if (IsAtomTerm(tguide)) + ≈ * @return the term +*/ +Term Yap_MkTextTerm(const char *s, int guide USES_REGS) { + if (guide == YAP_STRING_ATOM) { return MkAtomTerm(Yap_LookupAtom(s)); - if (IsStringTerm(tguide)) + } else if (guide == YAP_STRING_STRING) { return MkStringTerm(s); - if (IsPairTerm(tguide) && IsAtomTerm(HeadOfTerm(tguide))) { - return Yap_CharsToListOfAtoms(s, enc PASS_REGS); + } else if (guide == YAP_STRING_ATOMS) { + return Yap_CharsToListOfAtoms(s, ENC_ISO_UTF8 PASS_REGS); + } else { + return Yap_CharsToListOfCodes(s, ENC_ISO_UTF8 PASS_REGS); } - return Yap_CharsToListOfCodes(s, enc PASS_REGS); } diff --git a/C/text.c.new b/C/text.c.new new file mode 100644 index 000000000..3db58d085 --- /dev/null +++ b/C/text.c.new @@ -0,0 +1,1257 @@ +/************************************************************************* + * * + * YAP Prolog * + * * + * Yap Prolog was developed at NCCUP - Universidade do Porto * + * * + * Copyright L.Damas, V. Santos Costa and Universidade do Porto 1985-- * + * * + ************************************************************************** + * * + * File: strings.c * + * comments: General-conversion of character sequences. * + * * + * Last rev: $Date: 2008-07-24 16:02:00 $,$Author: vsc $ * + * * + *************************************************************************/ + +#include "Yap.h" +#include "YapEval.h" +#include "YapHeap.h" +#include "YapText.h" +#include "Yatom.h" +#include "yapio.h" + +#include +#include +#include + +#ifndef HAVE_WCSNLEN +inline static size_t min_size(size_t i, size_t j) { return (i < j ? i : j); } +#define wcsnlen(S, N) min_size(N, wcslen(S)) +#endif + +#if !defined(HAVE_STPCPY) && !defined(__APPLE__) +inline static void *__stpcpy(void *i, const void *j) { + return strcpy(i, j) + strlen(j); +} +#define stpcpy __stpcpy +#endif + +#ifndef NAN +#define NAN (0.0 / 0.0) +#endif + +#define MAX_PATHNAME 2048 + +struct mblock { + struct mblock *prev, *next; + int lvl; + size_t sz; +}; + +typedef struct TextBuffer_manager { + void *buf, *ptr; + size_t sz; + struct mblock *first[16]; + struct mblock *last[16]; + int lvl; +} text_buffer_t; + +int AllocLevel(void) { return LOCAL_TextBuffer->lvl; } +int push_text_stack__(USES_REGS1) { + int i = LOCAL_TextBuffer->lvl; + i++; + LOCAL_TextBuffer->lvl = i; + + return i; +} + +int pop_text_stack__(int i) { + int lvl = LOCAL_TextBuffer->lvl; + while (lvl >= i) { + struct mblock *p = LOCAL_TextBuffer->first[lvl]; + while (p) { + struct mblock *np = p->next; + free(p); + p = np; + } + LOCAL_TextBuffer->first[lvl] = NULL; + LOCAL_TextBuffer->last[lvl] = NULL; + lvl--; + } + LOCAL_TextBuffer->lvl = lvl; + return lvl; +} + +void *pop_output_text_stack__(int i, const void *export) { + int lvl = LOCAL_TextBuffer->lvl; + while (lvl >= i) { + struct mblock *p = LOCAL_TextBuffer->first[lvl]; + while (p) { + struct mblock *np = p->next; + if (p + 1 == export) { + size_t sz = p->sz - sizeof(struct mblock); + memmove(p, p + 1, sz); + export = p; + } else { + free(p); + } + p = np; + } + LOCAL_TextBuffer->first[lvl] = NULL; + LOCAL_TextBuffer->last[lvl] = NULL; + lvl--; + } + LOCAL_TextBuffer->lvl = lvl; + return (void *)export; +} + +// void pop_text_stack(int i) { LOCAL_TextBuffer->lvl = i; } +void insert_block(struct mblock *o) { + int lvl = o->lvl; + o->prev = LOCAL_TextBuffer->last[lvl]; + if (o->prev) { + o->prev->next = o; + } + if (LOCAL_TextBuffer->first[lvl]) { + LOCAL_TextBuffer->last[lvl] = o; + } else { + LOCAL_TextBuffer->first[lvl] = LOCAL_TextBuffer->last[lvl] = o; + } + o->next = NULL; +} + +void release_block(struct mblock *o) { + int lvl = o->lvl; + if (LOCAL_TextBuffer->first[lvl] == o) { + if (LOCAL_TextBuffer->last[lvl] == o) { + LOCAL_TextBuffer->first[lvl] = LOCAL_TextBuffer->last[lvl] = NULL; + } + LOCAL_TextBuffer->first[lvl] = o->next; + } else if (LOCAL_TextBuffer->last[lvl] == o) { + LOCAL_TextBuffer->last[lvl] = o->prev; + } + if (o->prev) + o->prev->next = o->next; + if (o->next) + o->next->prev = o->prev; +} + +void *Malloc(size_t sz USES_REGS) { + int lvl = LOCAL_TextBuffer->lvl; + if (sz == 0) + sz = 1024; + sz = ALIGN_BY_TYPE(sz + sizeof(struct mblock), CELL); + struct mblock *o = malloc(sz); + if (!o) + return NULL; + o->sz = sz; + o->lvl = lvl; + o->prev = o->next = 0; + insert_block(o); + return o + 1; +} + +void *MallocAtLevel(size_t sz, int atL USES_REGS) { + int lvl = LOCAL_TextBuffer->lvl; + if (atL > 0 && atL <= lvl) { + lvl = atL; + } else if (atL < 0 && lvl - atL >= 0) { + lvl += atL; + } else { + return NULL; + } + if (sz == 0) + sz = 1024; + sz = ALIGN_BY_TYPE(sz + sizeof(struct mblock), CELL); + struct mblock *o = malloc(sz); + if (!o) + return NULL; + o->sz = sz; + o->lvl = lvl; + o->prev = o->next = 0; + insert_block(o); + return o + 1; +} + +void *Realloc(void *pt, size_t sz USES_REGS) { + sz += sizeof(struct mblock); + struct mblock *old = pt, *o; + old--; + release_block(old); + o = realloc(old, sz); + o->sz = sz; + insert_block(o); + + return o + 1; +} + +/** + * Export a local memory object as a RO object to the outside world, that is, + * recovering as much storage as one can. + * @param pt pointer to object + * @return new object + */ +const void *MallocExportAsRO(const void *pt USES_REGS) { + struct mblock *old = (void *)pt, *o = old - 1; + if (old == NULL) + return NULL; + size_t sz = o->sz; + release_block(o); + memmove((void *)o, pt, sz); + return realloc((void *)o, sz); +} + +void Free(void *pt USES_REGS) { + struct mblock *o = pt; + o--; + release_block(o); + free(o); +} + +void *Yap_InitTextAllocator(void) { + struct TextBuffer_manager *new = calloc(sizeof(struct TextBuffer_manager), 1); + return new; +} + +static size_t MaxTmp(USES_REGS1) { return 1025; } + +static Term Globalize(Term v USES_REGS) { + if (!IsVarTerm(v = Deref(v))) { + return v; + } + if (VarOfTerm(v) > HR && VarOfTerm(v) < LCL0) { + Bind_Local(VarOfTerm(v), MkVarTerm()); + v = Deref(v); + } + return v; +} + +static void *codes2buf(Term t0, void *b0, bool get_codes, + bool fixed USES_REGS) { + unsigned char *st0, *st, ar[16]; + Term t = Deref(t0); + size_t length = 0; + + if (t == TermNil) { + st0 = Malloc(4); + st0[0] = 0; + return st0; + } + if (!IsPairTerm(t)) { + Yap_ThrowError(TYPE_ERROR_LIST, t, "scanning list of codes"); + return NULL; + } + bool codes = IsIntegerTerm(HeadOfTerm(t)); + if (get_codes != codes && fixed) { + if (codes) { + Yap_ThrowError(TYPE_ERROR_INTEGER, HeadOfTerm(t), + "scanning list of codes"); + } else { + Yap_ThrowError(TYPE_ERROR_ATOM, HeadOfTerm(t), "scanning list of atoms"); + } + } + if (codes) { + while (IsPairTerm(t)) { + Term hd = HeadOfTerm(t); + if (IsVarTerm(hd)) { + Yap_ThrowError(INSTANTIATION_ERROR, hd, "scanning list of codes"); + return NULL; + } + if (!IsIntegerTerm(hd)) { + Yap_ThrowError(TYPE_ERROR_CHARACTER_CODE, hd, "scanning list of codes"); + return NULL; + } + Int code = IntegerOfTerm(hd); + if (code < 0) { + Yap_ThrowError(REPRESENTATION_ERROR_CHARACTER_CODE, hd, + "scanning list of character codes, found %d", code); + return NULL; + } + length += put_utf8(ar, code); + t = TailOfTerm(t); + if (IsVarTerm(t)) { + Yap_ThrowError(INSTANTIATION_ERROR, t, "scanning list of codes"); + return NULL; + } + if (!IsPairTerm(t) && t != TermNil) { + Yap_ThrowError(TYPE_ERROR_LIST, t, "scanning list of codes"); + return NULL; + } + } + } else { + while (IsPairTerm(t)) { + Term hd = HeadOfTerm(t); + if (IsVarTerm(hd)) { + Yap_ThrowError(INSTANTIATION_ERROR, hd, "scanning list of codes"); + return NULL; + } + if (!IsAtomTerm(hd)) { + Yap_ThrowError(TYPE_ERROR_CHARACTER, hd, "scanning list of texts"); + return NULL; + } + const char *code = RepAtom(AtomOfTerm(hd))->StrOfAE; + if (code < 0) { + Yap_ThrowError(TYPE_ERROR_CHARACTER, hd, "scanning list of atoms"); + return NULL; + } + length += strlen(code); + t = TailOfTerm(t); + if (IsVarTerm(t)) { + Yap_ThrowError(INSTANTIATION_ERROR, t, "scanning list of codes"); + return NULL; + } + if (!IsPairTerm(t) && t != TermNil) { + Yap_ThrowError(TYPE_ERROR_LIST, t, "scanning list of codes"); + return NULL; + } + } + } + + if (!IsVarTerm(t)) { + if (t != TermNil) { + Yap_ThrowError(TYPE_ERROR_LIST, t, "scanning list of codes"); + return NULL; + } + } + + st0 = st = Malloc(length + 1); + t = t0; + if (codes) { + while (IsPairTerm(t)) { + Term hd = HeadOfTerm(t); + Int code = IntegerOfTerm(hd); + + st = st + put_utf8(st, code); + t = TailOfTerm(t); + } + } else { + while (IsPairTerm(t)) { + Term hd = HeadOfTerm(t); + const char *code = RepAtom(AtomOfTerm(hd))->StrOfAE; + st = (unsigned char *)stpcpy((char *)st, code); + t = TailOfTerm(t); + } + } + st[0] = '\0'; + + return st0; +} + +static unsigned char *latin2utf8(seq_tv_t *inp) { + unsigned char *b0 = inp->val.uc; + size_t sz = strlen(inp->val.c); + sz *= 2; + int ch; + unsigned char *buf = Malloc(sz + 1), *pt = buf; + if (!buf) + return NULL; + while ((ch = *b0++)) { + int off = put_utf8(pt, ch); + if (off < 0) { + continue; + } + pt += off; + } + *pt++ = '\0'; + return buf; +} + +static unsigned char *wchar2utf8(seq_tv_t *inp) { + size_t sz = wcslen(inp->val.w) * 4; + wchar_t *b0 = inp->val.w; + unsigned char *buf = Malloc(sz + 1), *pt = buf; + int ch; + if (!buf) + return NULL; + while ((ch = *b0++)) + pt += put_utf8(pt, ch); + *pt++ = '\0'; + return buf; +} + +static void *slice(size_t min, size_t max, const unsigned char *buf USES_REGS); + +static unsigned char *Yap_ListOfCodesToBuffer(unsigned char *buf, Term t, + seq_tv_t *inp USES_REGS) { + bool codes = true, fixed = true; + unsigned char *nbuf = codes2buf(t, buf, codes, fixed PASS_REGS); + return nbuf; +} + +static unsigned char *Yap_ListOfAtomsToBuffer(unsigned char *buf, Term t, + seq_tv_t *inp USES_REGS) { + bool codes = false; + unsigned char *nbuf = codes2buf(t, buf, codes, true PASS_REGS); + return nbuf; +} + +static unsigned char *Yap_ListToBuffer(unsigned char *buf, Term t, + seq_tv_t *inp USES_REGS) { + return codes2buf(t, buf, NULL, false PASS_REGS); +} + +#if USE_GEN_TYPE_ERROR +static yap_error_number gen_type_error(int flags) { + if ((flags & (YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | + YAP_STRING_FLOAT | YAP_STRING_ATOMS_CODES | YAP_STRING_BIG)) == + (YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | + YAP_STRING_ATOMS_CODES | YAP_STRING_BIG)) + return TYPE_ERROR_TEXT; + if ((flags & (YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | + YAP_STRING_FLOAT | YAP_STRING_BIG)) == + (YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | + YAP_STRING_BIG)) + return TYPE_ERROR_ATOMIC; + if ((flags & (YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG)) == + (YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG)) + return TYPE_ERROR_NUMBER; + if (flags & YAP_STRING_ATOM) + return TYPE_ERROR_ATOM; + if (flags & YAP_STRING_STRING) + return TYPE_ERROR_STRING; + if (flags & (YAP_STRING_CODES | YAP_STRING_ATOMS)) + return TYPE_ERROR_LIST; + return TYPE_ERROR_NUMBER; +} +#endif + +static yap_error_number type_error(seq_tv_t *inp) { + if ((inp->type & YAP_STRING_ATOMS_CODES) == YAP_STRING_ATOMS_CODES) + { + return TYPE_ERROR_IN_CHARACTER; + } + if ((inp->type & YAP_STRING_ATOMS) == YAP_STRING_ATOMS) { + return TYPE_ERROR_CHARACTER; + } + if ((inp->type & YAP_STRING_CODES) == YAP_STRING_CODES) { + return TYPE_ERROR_CHARACTER_CODE; + } + if ((inp->type & YAP_STRING_STRING) == YAP_STRING_STRING) { + return TYPE_ERROR_IN_CHARACTER; + } + if ((inp->type & YAP_STRING_CODES) == YAP_STRING_CODES) { + return TYPE_ERROR_IN_CHARACTER; + } + if ((inp->type & (YAP_STRING_ATOM|YAP_STRING_STRING)) == (YAP_STRING_ATOM|YAP_STRING_STRING)) { + return TYPE_ERROR_ATOMIC; + } + if ((inp->type & YAP_STRING_ATOM) == YAP_STRING_ATOM) { + return TYPE_ERROR_IN_CHARACTER; + } + return SYSTEM_ERROR_INTERNAL; +} + +/// @brief translate anything to bufffer UTF-8 +/// +/// @arg input descriptor +unsigned char *Yap_readText(seq_tv_t *inp USES_REGS) { +#define POPRET(x) return pop_output_text_stack(lvl, x) + int lvl = push_text_stack(); + char *out = NULL; + /* we know what the term is */ + if ((inp->type & (YAP_STRING_CHARS | YAP_STRING_WCHARS))) { + //> buffer processing + //> must convert: + if (inp->type & YAP_STRING_CHARS) { + //> - ASCII to UTF-8 + if (inp->enc == ENC_ISO_ASCII) { + pop_text_stack(lvl); + return inp->val.uc; + } + //> - ISO-LATIN-1 to UTF-8 + if (inp->enc == ENC_ISO_LATIN1) { + POPRET( (char*)latin2utf8(inp)); + } + + //> - assume UTF-8 + if (inp->enc == ENC_ISO_UTF8) { + pop_text_stack(lvl); + return inp->val.uc; + } + } + if (inp->type & YAP_STRING_WCHARS) { + // printf("%S\n",inp->val.w); + //> wide includes everything else + POPRET( (char *)wchar2utf8(inp) ); + } + } else { + if (inp->type & YAP_STRING_TERM) { + //> term: anything goes + pop_text_stack(lvl); + return (unsigned char *)Yap_TermToBuffer(inp->val.t, 0); + } + if (IsVarTerm(inp->val.t)) { + Yap_ThrowError(INSTANTIATION_ERROR, inp->val.t, NULL); + } + if (IsPairOrNilTerm(inp->val.t)) { + if (((inp->type & (YAP_STRING_CODES | YAP_STRING_ATOMS)) == + (YAP_STRING_CODES | YAP_STRING_ATOMS))) { + // Yap_DebugPlWriteln(inp->val.t); + out = (char *)Yap_ListToBuffer(NULL, inp->val.t, inp PASS_REGS); + POPRET( out ); + // this is a term, extract to a sfer, and representation is wide + } + if (inp->type & YAP_STRING_CODES) { + // Yap_DebugPlWriteln(inp->val.t); + out = (char *)Yap_ListOfCodesToBuffer(NULL, inp->val.t, inp PASS_REGS); + // this is a term, extract to a sfer, and representation is wide + POPRET( out ); + } + + if (inp->type & YAP_STRING_ATOMS) { + // Yap_DebugPlWriteln(inp->val.t); + out = (char *)Yap_ListOfAtomsToBuffer(NULL, inp->val.t, inp PASS_REGS); + // this is a term, extract to a buffer, and representation is wide + POPRET( out ); + } + } + if (IsStringTerm(inp->val.t)) { + if(!(inp->type & (YAP_STRING_STRING))) { + Yap_ThrowError(type_error(inp), inp->val.t, NULL); + } + // this is a term, extract to a buffer, and representation is wide + // Yap_DebugPlWriteln(inp->val.t); + const char *s = StringOfTerm(inp->val.t); + if (s[0] == 0) { + out = Malloc(4); + memset(out, 0, 4); + POPRET( out ); + } + if (inp->type & YAP_STRING_WITH_BUFFER) { + pop_text_stack(lvl); + return (unsigned char *)UStringOfTerm(inp->val.t); + } + { + inp->type |= YAP_STRING_IN_TMP; + size_t sz = strlen(s); + out = Malloc(sz + 1); + strcpy(out, s); + POPRET( out ); + } + } + if (IsAtomTerm(inp->val.t)) { + if(!(inp->type & (YAP_STRING_ATOM))) { + Yap_ThrowError(type_error(inp), inp->val.t, NULL); + } + // this is a term, extract to a buffer, and representation is wide + // Yap_DebugPlWriteln(inp->val.t); + Atom at = AtomOfTerm(inp->val.t); + if (RepAtom(at)->UStrOfAE[0] == '\0') { + out = Malloc(4); + memset(out, 0, 4); + POPRET( out ); + } + if (inp->type & YAP_STRING_WITH_BUFFER) { + pop_text_stack(lvl); + return at->UStrOfAE; + } else + { + size_t sz = strlen(at->StrOfAE); + out = Malloc(sz + 1); + strcpy(out, at->StrOfAE); + POPRET( out ); + } + } + if (inp->type & YAP_STRING_INT && IsIntegerTerm(inp->val.t)) { + if(!(inp->type & (YAP_STRING_INT))) { + Yap_ThrowError(type_error(inp), inp->val.t, NULL); + } // ASCII, so both LATIN1 and UTF-8 + // Yap_DebugPlWriteln(inp->val.t); + out = Malloc(2 * MaxTmp(PASS_REGS1)); + if (snprintf(out, MaxTmp(PASS_REGS1) - 1, Int_FORMAT, + IntegerOfTerm(inp->val.t)) < 0) { + AUX_ERROR(inp->val.t, 2 * MaxTmp(PASS_REGS1), out, char); + } + POPRET( out ); + } + if (inp->type & YAP_STRING_FLOAT && IsFloatTerm(inp->val.t)) { + if(!(inp->type & (YAP_STRING_FLOAT))) { + Yap_ThrowError(type_error(inp), inp->val.t, NULL); + } // ASCII, so both LATIN1 and UTF-8 + out = Malloc(2 * MaxTmp(PASS_REGS1)); + if (!Yap_FormatFloat(FloatOfTerm(inp->val.t), &out, 1024)) { + pop_text_stack(lvl); + return NULL; + } + POPRET(out); + } +#if USE_GMP + if ( IsBigIntTerm(inp->val.t)) { + if(!(inp->type & (YAP_STRING_BIG))) { + Yap_ThrowError(type_error(inp), inp->val.t, NULL); + } // ASCII, so both LATIN1 and UTF-8 + // Yap_DebugPlWriteln(inp->val.t); + out = Malloc(MaxTmp()); + if (!Yap_mpz_to_string(Yap_BigIntOfTerm(inp->val.t), out, MaxTmp() - 1, + 10)) { + AUX_ERROR(inp->val.t, MaxTmp(PASS_REGS1), out, char); + } + POPRET(out); + } +#endif + } + pop_text_stack(lvl); + Yap_ThrowError(type_error(inp), inp->val.t, NULL); + return NULL; +} + +static Term write_strings(unsigned char *s0, seq_tv_t *out USES_REGS) { + size_t min = 0, max = strlen((char *)s0); + + if (out->type & (YAP_STRING_NCHARS | YAP_STRING_TRUNC)) { + if (out->type & YAP_STRING_NCHARS) + min = out->max; + if (out->type & YAP_STRING_TRUNC && out->max < max) { + max = out->max; + s0[max] = '\0'; + } + } + + char *s = (char *)s0; + Term t = init_tstring(PASS_REGS1); + LOCAL_TERM_ERROR(t, 2 * max); + unsigned char *buf = buf_from_tstring(HR); + if (max == 0) + buf[0] = '\0'; + else + strcpy((char *)buf, s); + if (max + 1 < min) { + LOCAL_TERM_ERROR(t, 2 * min); + memset(buf + min, '\0', max); + buf += min; + } else { + buf += max + 1; + } + close_tstring(buf PASS_REGS); + out->val.t = t; + + return out->val.t; +} + +static Term write_atoms(void *s0, seq_tv_t *out USES_REGS) { + Term t = AbsPair(HR); + char *s1 = (char *)s0; + size_t sz = 0; + size_t max = strlen(s1); + if (s1[0] == '\0') { + out->val.t = TermNil; + return TermNil; + } + if (out->type & (YAP_STRING_NCHARS | YAP_STRING_TRUNC)) { + if (out->type & YAP_STRING_TRUNC && out->max < max) + max = out->max; + } + + unsigned char *s = s0, *lim = s + strnlen((char *)s, max); + unsigned char *cp = s; + unsigned char w[10]; + int wp = 0; + LOCAL_TERM_ERROR(t, 2 * (lim - s)); + while (cp < lim && *cp) { + utf8proc_int32_t chr; + CELL *cl; + s += get_utf8(s, -1, &chr); + if (chr == '\0') { + w[0] = '\0'; + break; + } + wp = put_utf8(w, chr); + w[wp] = '\0'; + cl = HR; + HR += 2; + cl[0] = MkAtomTerm(Yap_ULookupAtom(w)); + cl[1] = AbsPair(HR); + sz++; + if (sz == max) + break; + } + if (out->type & YAP_STRING_DIFF) { + if (sz == 0) + t = out->dif; + else + HR[-1] = Globalize(out->dif PASS_REGS); + } else { + if (sz == 0) + t = TermNil; + else + HR[-1] = TermNil; + } + out->val.t = t; + return (t); +} + +static Term write_codes(void *s0, seq_tv_t *out USES_REGS) { + Term t; + size_t sz = strlen(s0); + if (sz == 0) { + if (out->type & YAP_STRING_DIFF) { + out->val.t = Globalize(out->dif PASS_REGS); + } else { + out->val.t = TermNil; + } + return out->val.t; + } + unsigned char *s = s0, *lim = s + sz; + unsigned char *cp = s; + + t = AbsPair(HR); + LOCAL_TERM_ERROR(t, 2 * (lim - s)); + t = AbsPair(HR); + while (*cp) { + utf8proc_int32_t chr; + CELL *cl; + cp += get_utf8(cp, -1, &chr); + if (chr == '\0') + break; + cl = HR; + HR += 2; + cl[0] = MkIntegerTerm(chr); + cl[1] = AbsPair(HR); + } + if (sz == 0) { + HR[-1] = Globalize(out->dif PASS_REGS); + } else { + HR[-1] = TermNil; + } + out->val.t = t; + return (t); +} + +static Atom write_atom(void *s0, seq_tv_t *out USES_REGS) { + unsigned char *s = s0; + int32_t ch; + if (s[0] == '\0') { + return Yap_LookupAtom(""); + } + size_t leng = strlen(s0); + if (strlen_utf8(s0) <= leng) { + return Yap_LookupAtom(s0); + } else { + size_t n = get_utf8(s, -1, &ch); + unsigned char *buf = Malloc(n + 1); + memmove(buf, s0, n + 1); + return Yap_ULookupAtom(buf); + } +} + +void *write_buffer(unsigned char *s0, seq_tv_t *out USES_REGS) { + int l = push_text_stack(); + size_t leng = strlen((char *)s0); + size_t min = 0, max = leng; + if (out->enc == ENC_ISO_UTF8) { + if (out->val.uc == NULL) { // this should always be the case + out->val.uc = Malloc(leng + 1); + strcpy(out->val.c, (char *)s0); + } else if (out->val.uc != s0) { + out->val.c = Malloc(leng + 1); + strcpy(out->val.c, (char *)s0); + } + } else if (out->enc == ENC_ISO_LATIN1) { + + unsigned char *s = s0; + unsigned char *cp = s; + unsigned char *buf = out->val.uc; + if (!buf) { + pop_text_stack(l); + return NULL; + } + while (*cp) { + utf8proc_int32_t chr; + int off = get_utf8(cp, -1, &chr); + if (off <= 0 || chr > 255) { + pop_text_stack(l); + return NULL; + } + if (off == max) + break; + cp += off; + *buf++ = chr; + } + if (max >= min) + *buf++ = '\0'; + else + while (max < min) { + utf8proc_int32_t chr; + max++; + cp += get_utf8(cp, -1, &chr); + *buf++ = chr; + } + } else if (out->enc == ENC_WCHAR) { + unsigned char *s = s0, *lim = s + (max = strnlen((char *)s0, max)); + unsigned char *cp = s; + wchar_t *buf0, *buf; + + buf = buf0 = out->val.w; + if (!buf) { + pop_text_stack(l); + return NULL; + } + while (*cp && cp < lim) { + utf8proc_int32_t chr; + cp += get_utf8(cp, -1, &chr); + *buf++ = chr; + } + if (max >= min) + *buf++ = '\0'; + else + while (max < min) { + utf8proc_int32_t chr; + max++; + cp += get_utf8(cp, -1, &chr); + *buf++ = chr; + } + *buf = '\0'; + } else { + // no other encodings are supported. + pop_text_stack(l); + return NULL; + } + out->val.c = pop_output_text_stack(l, out->val.c); + return out->val.c; +} + +static size_t write_length(const unsigned char *s0, seq_tv_t *out USES_REGS) { + return strlen_utf8(s0); +} + +static Term write_number(unsigned char *s, seq_tv_t *out, + bool error_on USES_REGS) { + Term t; + LOCAL_delay = !error_on; + t = Yap_StringToNumberTerm((char *)s, &out->enc, error_on); + LOCAL_delay = false; + return t; +} + +static Term string_to_term(void *s, seq_tv_t *out USES_REGS) { + Term o; + yap_error_descriptor_t *new_error = malloc(sizeof(yap_error_descriptor_t)); + bool mdnew = Yap_pushErrorContext(true, new_error); + o = out->val.t = Yap_BufferToTerm(s, TermNil); + Yap_popErrorContext(mdnew, true); + + return o; +} + +bool write_Text(unsigned char *inp, seq_tv_t *out USES_REGS) { + /* we know what the term is */ + if (out->type == 0) { + return true; + } + if (LOCAL_Error_TYPE) { + return false; + } + + if (out->type & (YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG)) { + if ((out->val.t = write_number( + inp, out, !(out->type & YAP_STRING_ATOM) PASS_REGS)) != 0L) { + // Yap_DebugPlWriteln(out->val.t); + + return true; + } + + if (!(out->type & YAP_STRING_ATOM)) + return false; + } + if (out->type & (YAP_STRING_ATOM)) { + if ((out->val.a = write_atom(inp, out PASS_REGS)) != NIL) { + Atom at = out->val.a; + if (at && (out->type & YAP_STRING_OUTPUT_TERM)) + out->val.t = MkAtomTerm(at); + // Yap_DebugPlWriteln(out->val.t); + return at != NIL; + } + } + if (out->type & YAP_STRING_DATUM) { + if ((out->val.t = string_to_term(inp, out PASS_REGS)) != 0L) + return out->val.t != 0; + } + + switch (out->type & YAP_TYPE_MASK) { + case YAP_STRING_CHARS: { + void *room = write_buffer(inp, out PASS_REGS); + // printf("%s\n", out->val.c); + return room != NULL; + } + case YAP_STRING_WCHARS: { + void *room = write_buffer(inp, out PASS_REGS); + // printf("%S\n", out->val.w); + return room != NULL; + } + case YAP_STRING_STRING: + out->val.t = write_strings(inp, out PASS_REGS); + // Yap_DebugPlWriteln(out->val.t); + return out->val.t != 0; + case YAP_STRING_ATOMS: + out->val.t = write_atoms(inp, out PASS_REGS); + // Yap_DebugPlWriteln(out->val.t); + return out->val.t != 0; + case YAP_STRING_CODES: + out->val.t = write_codes(inp, out PASS_REGS); + // Yap_DebugPlWriteln(out->val.t); + return out->val.t != 0; + case YAP_STRING_LENGTH: + out->val.l = write_length(inp, out PASS_REGS); + // printf("s\n",out->val.l); + return out->val.l != (size_t)(-1); + case YAP_STRING_ATOM: + out->val.a = write_atom(inp, out PASS_REGS); + // Yap_DebugPlWriteln(out->val.t); + return out->val.a != NULL; + case YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG: + out->val.t = write_number(inp, out, true PASS_REGS); + // Yap_DebugPlWriteln(out->val.t); + return out->val.t != 0; + default: { return true; } + } + return false; +} + +static size_t upcase(void *s0, seq_tv_t *out USES_REGS) { + + unsigned char *s = s0; + while (*s) { + // assumes the two code have always the same size; + utf8proc_int32_t chr; + get_utf8(s, -1, &chr); + chr = utf8proc_toupper(chr); + s += put_utf8(s, chr); + } + return true; +} + +static size_t downcase(void *s0, seq_tv_t *out USES_REGS) { + + unsigned char *s = s0; + while (*s) { + // assumes the two code have always the same size; + utf8proc_int32_t chr; + get_utf8(s, -1, &chr); + chr = utf8proc_tolower(chr); + s += put_utf8(s, chr); + } + return true; +} + +bool Yap_CVT_Text(seq_tv_t *inp, seq_tv_t *out USES_REGS) { + unsigned char *buf; + bool rc; + + /* + //printf(stderr, "[ %d ", n++) ; + if (inp->type & (YAP_STRING_TERM|YAP_STRING_ATOM|YAP_STRING_ATOMS_CODES + |YAP_STRING_STRING)) + //Yap_DebugPlWriteln(inp->val.t); + else if (inp->type & YAP_STRING_WCHARS) fprintf(stderr,"S %S\n", inp->val + .w); + else fprintf(stderr,"s %s\n", inp->val.c); + */ + // cnt++; + int l = push_text_stack(); + buf = Yap_readText(inp PASS_REGS); + if (!buf) { + pop_text_stack(l); + return 0L; + } + if (buf[0]) { + size_t leng = strlen_utf8(buf); + if (out->type & (YAP_STRING_NCHARS | YAP_STRING_TRUNC)) { + if (out->max < leng) { + const unsigned char *ptr = skip_utf8(buf, out->max); + size_t diff = (ptr - buf); + char *nbuf = Malloc(diff + 1); + memmove(nbuf, buf, diff); + nbuf[diff] = '\0'; + leng = diff; + } + // else if (out->type & YAP_STRING_NCHARS && + // const unsigned char *ptr = skip_utf8(buf) + } + + if (out->type & (YAP_STRING_UPCASE | YAP_STRING_DOWNCASE)) { + if (out->type & YAP_STRING_UPCASE) { + if (!upcase(buf, out)) { + pop_text_stack(l); + return false; + } + } + if (out->type & YAP_STRING_DOWNCASE) { + if (!downcase(buf, out)) { + pop_text_stack(l); + return false; + } + } + } + } + rc = write_Text(buf, out PASS_REGS); + /* fprintf(stderr, " -> "); + if (!rc) fprintf(stderr, "NULL"); + else if (out->type & + (YAP_STRING_TERM|YAP_STRING_ATOMS_CODES + |YAP_STRING_STRING)) //Yap_DebugPlWrite(out->val.t); + else if (out->type & + YAP_STRING_ATOM) //Yap_DebugPlWriteln(MkAtomTerm(out->val.a)); + else if (out->type & YAP_STRING_WCHARS) fprintf(stderr, "%S", + out->val.w); + else + fprintf(stderr, "%s", out->val.c); + fprintf(stderr, "\n]\n"); */ + pop_text_stack(l); + return rc; +} + +static unsigned char *concat(int n, void *sv[] USES_REGS) { + void *buf; + unsigned char *buf0; + size_t room = 0; + int i; + + for (i = 0; i < n; i++) { + char *s = sv[i]; + if (s[0]) + room += strlen(s); + } + buf = Malloc(room + 1); + buf0 = buf; + for (i = 0; i < n; i++) { + char *s = sv[i]; + if (!s[0]) + continue; +#if _WIN32 || defined(__ANDROID__) + strcpy(buf, s); + buf = (char *)buf + strlen(buf); +#else + buf = stpcpy(buf, s); +#endif + } + return buf0; +} + +static void *slice(size_t min, size_t max, const unsigned char *buf USES_REGS) { + unsigned char *nbuf = BaseMalloc((max - min) * 4 + 1); + const unsigned char *ptr = skip_utf8(buf, min); + unsigned char *nptr = nbuf; + utf8proc_int32_t chr; + + while (min++ < max) { + ptr += get_utf8(ptr, -1, &chr); + nptr += put_utf8(nptr, chr); + } + nptr[0] = '\0'; + return nbuf; +} + +// +// Out must be an atom or a string +bool Yap_Concat_Text(int tot, seq_tv_t inp[], seq_tv_t *out USES_REGS) { + void **bufv; + unsigned char *buf; + int i, j; + // int lvl = push_text_stack(); + bufv = Malloc(tot * sizeof(unsigned char *)); + if (!bufv) { + // pop_text_stack(lvl); + return NULL; + } + for (i = 0, j = 0; i < tot; i++) { + // inp[j].type |= YAP_STRING_WITH_BUFFER; + unsigned char *nbuf = Yap_readText(inp + i PASS_REGS); + + if (!nbuf) { + // pop_text_stack(lvl); + return NULL; + } + // if (!nbuf[0]) + // continue; + bufv[j++] = nbuf; + } + if (j == 0) { + buf = Malloc(8); + memset(buf, 0, 4); + } else if (j == 1) { + buf = bufv[0]; + } else { + buf = concat(tot, bufv PASS_REGS); + } + bool rc = write_Text(buf, out PASS_REGS); + // pop_text_stack( lvl ); + + return rc; +} + +// +bool Yap_Splice_Text(int n, size_t cuts[], seq_tv_t *inp, + seq_tv_t outv[] USES_REGS) { + int lvl = push_text_stack(); + const unsigned char *buf; + size_t b_l, u_l; + + inp->type |= YAP_STRING_IN_TMP; + buf = Yap_readText(inp PASS_REGS); + if (!buf) { + pop_text_stack(lvl); + return false; + } + b_l = strlen((char *)buf); + if (b_l == 0) { + pop_text_stack(lvl); + return false; + } + u_l = strlen_utf8(buf); + if (!cuts) { + if (n == 2) { + size_t b_l0, b_l1, u_l0, u_l1; + unsigned char *buf0, *buf1; + + if (outv[0].val.t) { + buf0 = Yap_readText(outv PASS_REGS); + if (!buf0) { + return false; + } + b_l0 = strlen((const char *)buf0); + if (memcmp(buf, buf0, b_l0) != 0) { + pop_text_stack(lvl); + return false; + } + u_l0 = strlen_utf8(buf0); + u_l1 = u_l - u_l0; + + b_l1 = b_l - b_l0; + buf1 = slice(u_l0, u_l, buf PASS_REGS); + b_l1 = strlen((const char *)buf1); + bool rc = write_Text(buf1, outv + 1 PASS_REGS); + pop_text_stack(lvl); + if (!rc) { + return false; + } + return rc; + } else /* if (outv[1].val.t) */ { + buf1 = Yap_readText(outv + 1 PASS_REGS); + if (!buf1) { + pop_text_stack(lvl); + return false; + } + b_l1 = strlen((char *)buf1); + u_l1 = strlen_utf8(buf1); + b_l0 = b_l - b_l1; + u_l0 = u_l - u_l1; + if (memcmp(skip_utf8((const unsigned char *)buf, b_l0), buf1, b_l1) != + 0) { + pop_text_stack(lvl); + return false; + } + buf0 = slice(0, u_l0, buf PASS_REGS); + buf0 = pop_output_text_stack(lvl, buf0); + bool rc = write_Text(buf0, outv PASS_REGS); + return rc; + } + } + } + int i, next; + for (i = 0; i < n; i++) { + if (i == 0) + next = 0; + else + next = cuts[i - 1]; + if (i > 0 && cuts[i] == 0) + break; + void *bufi = slice(next, cuts[i], buf PASS_REGS); + bufi = pop_output_text_stack(lvl, bufi); + if (!write_Text(bufi, outv + i PASS_REGS)) { + return false; + } + } + pop_text_stack(lvl); + + return true; +} + +/** + * Convert from a predicate structure to an UTF-8 string of the form + * + * module:name/arity. + * + * The result is in very volatile memory. + * + * @param s the buffer + * + * @return the temporary string + */ +const char *Yap_PredIndicatorToUTF8String(PredEntry *ap) { + CACHE_REGS + Atom at; + arity_t arity = 0; + Functor f; + char *s, *smax, *s0; + s = s0 = malloc(1024); + smax = s + 1024; + Term tmod = ap->ModuleOfPred; + if (tmod) { + char *sn = Yap_AtomToUTF8Text(AtomOfTerm(tmod)); + stpcpy(s, sn); + if (smax - s > 1) { + strcat(s, ":"); + } else { + return NULL; + } + s++; + } else { + if (smax - s > strlen("prolog:")) { + s = strcpy(s, "prolog:"); + } else { + return NULL; + } + } + // follows the actual functor + if (ap->ModuleOfPred == IDB_MODULE) { + if (ap->PredFlags & NumberDBPredFlag) { + Int key = ap->src.IndxId; + snprintf(s, smax - s, "%" PRIdPTR, key); + return LOCAL_FileNameBuf; + } else if (ap->PredFlags & AtomDBPredFlag) { + at = (Atom)(ap->FunctorOfPred); + if (!stpcpy(s, Yap_AtomToUTF8Text(at))) + return NULL; + } else { + f = ap->FunctorOfPred; + at = NameOfFunctor(f); + arity = ArityOfFunctor(f); + } + } else { + arity = ap->ArityOfPE; + if (arity) { + at = NameOfFunctor(ap->FunctorOfPred); + } else { + at = (Atom)(ap->FunctorOfPred); + } + } + if (!stpcpy(s, Yap_AtomToUTF8Text(at))) { + return NULL; + } + s += strlen(s); + snprintf(s, smax - s, "/%" PRIdPTR, arity); + return s0; +} + +/** + * Convert from a text buffer (8-bit) to a term that has the same type as + * _Tguide_ + * + ≈* @param s the buffer + ≈ * @param tguide the guide + * + ≈ * @return the term +*/ +Term Yap_MkTextTerm(const char *s, int guide USES_REGS) { + if (guide == YAP_STRING_ATOM) { + return MkAtomTerm(Yap_LookupAtom(s)); + } else if (guide == YAP_STRING_STRING) { + return MkStringTerm(s); + } else if (guide == YAP_STRING_ATOMS) { + return Yap_CharsToListOfAtoms(s, ENC_ISO_UTF8 PASS_REGS); + } else { + return Yap_CharsToListOfCodes(s, ENC_ISO_UTF8 PASS_REGS); + } +} diff --git a/C/threads.c b/C/threads.c index 96f51175e..a7a4136ce 100644 --- a/C/threads.c +++ b/C/threads.c @@ -28,7 +28,7 @@ static char SccsId[] = "%W% %G%"; #include "YapHeap.h" #include "YapEval.h" #include "yapio.h" -#include "blobs.h" +#include "YapBlobs.h" #include #if HAVE_UNISTD_H #include @@ -384,7 +384,7 @@ setup_engine(int myworker_id, int init_thread) // create a mbox mboxCreate( MkIntTerm(myworker_id), &REMOTE_ThreadHandle(myworker_id).mbox_handle PASS_REGS ); Yap_InitTime( myworker_id ); - Yap_InitYaamRegs( myworker_id ); + Yap_InitYaamRegs( myworker_id, true] ); REFRESH_CACHE_REGS Yap_ReleasePreAllocCodeSpace(Yap_PreAllocCodeSpace()); /* I exist */ @@ -1174,9 +1174,9 @@ p_with_mutex( USES_REGS1 ) rc = TRUE; } end: - excep = Yap_GetException(); + excep = Yap_GetException(LOCAL_ComiittedError); if ( !UnLockMutex(mut PASS_REGS) ) { - return FALSE; + return FALSE;c } if (creeping) { Yap_signal( YAP_CREEP_SIGNAL ); @@ -1756,7 +1756,7 @@ p_new_mutex(void) p_with_mutex( USES_REGS1 ) { Int mut; - Term t1 = Deref(ARG1), excep; + Term t1 = Deref(ARG1); Int rc = FALSE; Int creeping = Yap_get_signal(YAP_CREEP_SIGNAL); PredEntry *pe; @@ -1813,11 +1813,12 @@ p_new_mutex(void) } end: ARG1 = MkIntegerTerm(mut); - excep = Yap_GetException(); + yap_error_descriptor_t *err = Yap_GetException(); if (creeping) { Yap_signal( YAP_CREEP_SIGNAL ); - } else if ( excep != 0) { - return Yap_JumpToEnv(excep); + } else if ( err ) { + LOCAL_ActiveError->errorNo = err->errorNo; + return Yap_JumpToEnv(); } return rc; } diff --git a/C/tracer.c b/C/tracer.c index ebb1e0783..38bd6e2a1 100644 --- a/C/tracer.c +++ b/C/tracer.c @@ -1,19 +1,19 @@ /************************************************************************* - * * - * YAP Prolog @(#)amidefs.h 1.3 3/15/90 - * * - * Yap Prolog was developed at NCCUP - Universidade do Porto * - * * - * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * - * * - ************************************************************************** - * * - * File: tracer.h * - * Last rev: * - * mods: * - * comments: definitions for low level tracer * - * * - *************************************************************************/ + * * + * YAP Prolog @(#)amidefs.h 1.3 3/15/90 + * * + * Yap Prolog was developed at NCCUP - Universidade do Porto * + * * + * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * + * * + ************************************************************************** + * * + * File: tracer.h * + * Last rev: * + * mods: * + * comments: definitions for low level tracer * + * * + *************************************************************************/ #include "Yap.h" @@ -48,7 +48,7 @@ static char *send_tracer_message(char *start, char *name, arity_t arity, s = s1; expand = false; } - min = 1024; + min = 1024; if (name == NULL) { #ifdef YAPOR d = snprintf(s, max, "(%d)%s", worker_id, start); @@ -81,32 +81,36 @@ static char *send_tracer_message(char *start, char *name, arity_t arity, if (max > 16) { *s++ = ','; *s++ = ' '; - max-=2; + max -= 2; } else { expand = true; continue; } } - const char *sn = Yap_TermToString(args[i], NULL, LOCAL_encoding, + const char *sn = Yap_TermToBuffer(args[i], Quote_illegal_f | Handle_vars_f); size_t sz; if (sn == NULL) { - sn = "<* error *>"; + sn = malloc(strlen("<* error *>")+1); + strcpy((char*)sn, "<* error *>"); } sz = strlen(sn); if (max <= sz) { - min = sz + 1024; + min = sz + 1024; expand = true; + free((void*)sn); continue; } strcpy(s, sn); + free((void*)sn); + sn = NULL; s += sz; - max -= sz; + max -= sz; } if (arity) { *s++ = ' '; *s++ = ')'; - max -= 2; + max -= 2; } } } while (expand); @@ -114,7 +118,7 @@ static char *send_tracer_message(char *start, char *name, arity_t arity, return s; } -#if defined(__GNUC__) +#if defined(__GNUC__) || defined(__clang__) unsigned long long vsc_count; #else unsigned long vsc_count; @@ -159,7 +163,7 @@ void jmp_deb2(void) { fprintf(stderr, "Here\n"); } void jmp_deb(int i) { if (i) - printf("Here we go %ld\n", old_value++); + printf("Here we go " Int_FORMAT "\n", old_value++); if (old_value == 716) jmp_deb2(); } @@ -202,6 +206,7 @@ bool low_level_trace__(yap_low_level_port port, PredEntry *pred, CELL *args) { int l = push_text_stack(); /* extern int gc_calls; */ vsc_count++; + //fprintf(stderr,"%p-%p\n",B->cp_tr,TR); // if (HR < ASP ) return; // fif (vsc_count == 12534) jmp_deb( 2 ); char *buf = Malloc(512), *top = buf + 511, *b = buf; @@ -346,7 +351,7 @@ bool low_level_trace__(yap_low_level_port port, PredEntry *pred, CELL *args) { if (p == pe) { UNLOCK(Yap_heap_regs->low_level_trace_lock); pop_text_stack(l); - ReleaseAndReturn(true); + return (true); } if (env_ptr != NULL) env_ptr = (CELL *)(env_ptr[E_E]); @@ -354,8 +359,9 @@ bool low_level_trace__(yap_low_level_port port, PredEntry *pred, CELL *args) { printf("\n"); } #endif - b += snprintf(b, top - b, "%lld %ld ", vsc_count, LCL0 - (CELL *)B); - b += snprintf(b, top - b, "%ld ", LCL0 - (CELL *)Yap_REGS.CUT_C_TOP); + b += snprintf(b, top - b, "%llud " UInt_FORMAT " ", vsc_count, + LCL0 - (CELL *)B); + b += snprintf(b, top - b, Int_FORMAT " ", LCL0 - (CELL *)Yap_REGS.CUT_C_TOP); #if defined(THREADS) || defined(YAPOR) b += snprintf(b, top - b, "(%d)", worker_id); #endif @@ -363,12 +369,13 @@ bool low_level_trace__(yap_low_level_port port, PredEntry *pred, CELL *args) { if (pred == NULL) { UNLOCK(Yap_low_level_trace_lock); pop_text_stack(l); - ReleaseAndReturn(true); + return (true); } if (pred->ModuleOfPred == PROLOG_MODULE) { if (!LOCAL_do_trace_primitives) { UNLOCK(Yap_low_level_trace_lock); - ReleaseAndReturn(true); + pop_text_stack(l); + return (true); } mname = "prolog"; } else { @@ -453,14 +460,14 @@ bool low_level_trace__(yap_low_level_port port, PredEntry *pred, CELL *args) { } UNLOCK(Yap_low_level_trace_lock); #if __ANDROID__ - __android_log_print(ANDROID_LOG_DEBUG, "YAPDroid", "%s\n", buf); + __android_log_print(ANDROID_LOG_ERROR, "YAPDroid", "%s\n", buf); #else *b++ = '\n'; *b = '\0'; fputs(buf, stderr); #endif pop_text_stack(l); - ReleaseAndReturn(true); + return (true); } void toggle_low_level_trace(void) { @@ -482,7 +489,7 @@ static Int reset_total_choicepoints(USES_REGS1) { } static Int show_low_level_trace(USES_REGS1) { - fprintf(stderr, "Call counter=%llu\n", vsc_count); + fprintf(stderr, "Call counter=%lld\n", vsc_count); return (TRUE); } @@ -508,7 +515,7 @@ not being output. static Int stop_low_level_trace(USES_REGS1) { Yap_do_low_level_trace = FALSE; LOCAL_do_trace_primitives = TRUE; -#if DEBUG_LOCKS +#if DEBUG_LOCKS//// debug_locks = TRUE; #endif return (TRUE); diff --git a/C/unify.c b/C/unify.c index fb535df73..5af55d8d8 100644 --- a/C/unify.c +++ b/C/unify.c @@ -604,12 +604,10 @@ InitReverseLookupOpcode(void) int hash_size_mask = OP_HASH_SIZE-1; UInt sz = OP_HASH_SIZE*sizeof(struct opcode_tab_entry); - while (OP_RTABLE == NULL) { if ((OP_RTABLE = (op_entry *)Yap_AllocCodeSpace(sz)) == NULL) { if (!Yap_growheap(FALSE, sz, NULL)) { Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "Couldn't obtain space for the reverse translation opcode table"); - } } } memset(OP_RTABLE, 0, sz); diff --git a/C/unify_absmi_insts.h b/C/unify_absmi_insts.h index 4ca69ef76..4e05b0696 100644 --- a/C/unify_absmi_insts.h +++ b/C/unify_absmi_insts.h @@ -2,6 +2,8 @@ * Get Instructions * \************************************************************************/ +#include + #ifdef INDENT_CODE { { diff --git a/C/utilpreds.c b/C/utilpreds.c index 0f629a59f..6562b9d93 100644 --- a/C/utilpreds.c +++ b/C/utilpreds.c @@ -77,12 +77,12 @@ static int copy_complex_term(CELL *pt0, CELL *pt0_end, int share, int newattvs, CELL *ptf, CELL *HLow USES_REGS) { - struct cp_frame *to_visit0, *to_visit = (struct cp_frame *)Yap_PreAllocCodeSpace(); + struct cp_frame *to_visit0, *to_visit = (struct cp_frame *)Yap_PreAllocCodeSpace() ; CELL *HB0 = HB; tr_fr_ptr TR0 = TR; int ground = TRUE; - HB = HLow; + HB = HR; to_visit0 = to_visit; loop: while (pt0 < pt0_end) { @@ -182,7 +182,7 @@ copy_complex_term(CELL *pt0, CELL *pt0_end, int share, int newattvs, CELL *ptf, if (HR+sz > ASP - 2048) { goto overflow; } - memcpy((void *)HR, (void *)ap2, sz*sizeof(CELL)); + memmove((void *)HR, (void *)ap2, sz*sizeof(CELL)); HR += sz; } else { *ptf++ = d0; /* you can just copy other extensions. */ @@ -361,7 +361,7 @@ trail_overflow: reset_trail(TR0); LOCAL_Error_Size = (ADDR)AuxSp-(ADDR)to_visit0; return -3; -} + } static Term @@ -531,25 +531,279 @@ p_copy_term_no_delays( USES_REGS1 ) /* copy term t to a new instance */ +typedef struct bp_frame { + CELL *start_cp; + CELL *end_cp; + CELL *to; + CELL *oldp; + CELL oldv; +} bp_frame_t; + + + typedef struct copy_frame { CELL *start_cp; CELL *end_cp; CELL *to; } copy_frame_t; -static Term * -add_to_list( Term *out_e, Term v, Term t USES_REGS) +static Term +add_to_list( Term inp, Term v, Term t PASS_REGS) { - Term ta[2], tv; + Term ta[2]; ta[0] = v; ta[1] = t; - *out_e = tv = MkPairTerm(Yap_MkApplTerm( FunctorEq, 2, ta ), TermNil); - return RepPair(tv)+1; + return MkPairTerm(Yap_MkApplTerm( FunctorEq, 2, ta ), inp); } + static int -break_rationals_complex_term(CELL *pt0, CELL *pt0_end, CELL *ptf, Term *of, Term oi, CELL *HLow USES_REGS) +break_rationals_complex_term(CELL *pt0, CELL *pt0_end, CELL *ptf, Term *vout, Term vin,CELL *HLow USES_REGS) +{ + + struct bp_frame *to_visit0, *to_visit = (struct bp_frame *)Yap_PreAllocCodeSpace() ; + CELL *HB0 = HB; + tr_fr_ptr TR0 = TR; + + HB = HR; + to_visit0 = to_visit; + loop: + while (pt0 < pt0_end) { + register CELL d0; + register CELL *ptd0; + ++ pt0; + ptd0 = pt0; + d0 = *ptd0; + deref_head(d0, copy_term_unk); + copy_term_nvar: + { + if (IsPairTerm(d0)) { + CELL *ap2 = RepPair(d0); + fprintf(stderr, "%ld \n", RepPair(ap2[0])- ptf); + if (IsVarTerm(ap2[0]) && IN_BETWEEN(HB, (ap2[0]),HR)) { + Term v = MkVarTerm(); + *ptf = v; + vin = add_to_list(vin, (CELL)(ptf), AbsPair(ptf) ); + ptf++; + continue; + } + if (to_visit+1 >= (struct bp_frame *)AuxSp) { + goto heap_overflow; + } + *ptf++ = (CELL)(HR); + to_visit->start_cp = pt0; + to_visit->end_cp = pt0_end; + to_visit->to = ptf; + to_visit->oldp = ap2; + d0 = to_visit->oldv = ap2[0]; + /* fool the system into thinking we had a variable there */ + to_visit ++; + pt0 = ap2; + pt0_end = ap2 + 1; + ptf = HR; + *ap2 = AbsPair(HR); + HR += 2; + if (HR > ASP - 2048) { + goto overflow; + } + if (IsVarTerm(d0) && d0 == (CELL)ap2) { + RESET_VARIABLE(ptf); + ptf++; + continue; + } + d0 = Deref(d0); + if (!IsVarTerm(d0)) { + goto copy_term_nvar; + } else { + *ptf++ = d0; + } + continue; + } else if (IsApplTerm(d0)) { + register Functor f; + register CELL *ap2; + /* store the terms to visit */ + ap2 = RepAppl(d0)+1; + f = (Functor)(ap2[-1]); + if (IsExtensionFunctor(f)) { + *ptf++ = d0; /* you can just copy other extensions. */ + continue; + } + if (IsApplTerm(ap2[0]) && IN_BETWEEN(HB, RepAppl(ap2[0]),HR)) { + RESET_VARIABLE(ptf); + vin = add_to_list(vin, (CELL)ptf, ap2[0] ); + ptf++; + continue; + } + + arity_t arity = ArityOfFunctor(f); + if (to_visit+1 >= (struct bp_frame *)AuxSp) { + goto heap_overflow; + } + *ptf++ = AbsAppl(HR); + to_visit->start_cp = pt0; + to_visit->end_cp = pt0_end; + to_visit->to = ptf; + to_visit->oldp = ap2; + d0 = to_visit->oldv = ap2[0]; + /* fool the system into thinking we had a variable there */ + to_visit ++; + pt0 = ap2; + pt0_end = ap2 + (arity-1); + ptf = HR; + if (HR > ASP - 2048) { + goto overflow; + } + *ptf++ =(CELL)f; + *ap2 = AbsAppl(HR); + HR += (arity+1); + if (IsVarTerm(d0) && d0 == (CELL)(ap2)) { + RESET_VARIABLE(ptf); + ptf++; + continue; + } + d0 = Deref(d0); + if (!IsVarTerm(d0)) { + goto copy_term_nvar; + } else { + *ptf++ = d0; + } + continue; + } else { + /* just copy atoms or integers */ + *ptf++ = d0; + } + continue; + } + + derefa_body(d0, ptd0, copy_term_unk, copy_term_nvar); + *ptf++ = (CELL) ptd0; + } + /* Do we still have compound terms to visit */ + if (to_visit > to_visit0) { + to_visit --; + *to_visit->oldp = to_visit->oldv; + ptf = to_visit->to; + pt0 = to_visit->start_cp; + pt0_end = to_visit->end_cp; + goto loop; + } + + /* restore our nice, friendly, term to its original state */ + HB = HB0; + *vout = vin; + return true; + + overflow: + /* oops, we're in trouble */ + HR = HLow; + /* we've done it */ + /* restore our nice, friendly, term to its original state */ + HB = HB0; +#ifdef RATIONAL_TREES + while (to_visit > to_visit0) { + to_visit --; + pt0 = to_visit->start_cp; + pt0_end = to_visit->end_cp; + ptf = to_visit->to; + *to_visit->oldp = to_visit->oldv; + } +#endif + reset_trail(TR0); + /* follow chain of multi-assigned variables */ + return -1; + + heap_overflow: + /* oops, we're in trouble */ + HR = HLow; + /* we've done it */ + /* restore our nice, friendly, term to its original state */ + HB = HB0; +#ifdef RATIONAL_TREES + while (to_visit > to_visit0) { + to_visit --; + pt0 = to_visit->start_cp; + pt0_end = to_visit->end_cp; + ptf = to_visit->to; + *to_visit->oldp = to_visit->oldv; + } +#endif + reset_trail(TR0); + LOCAL_Error_Size = (ADDR)AuxSp-(ADDR)to_visit0; + return -3; +} + + + Term +Yap_BreakRational(Term inp, UInt arity, Term *to, Term ti USES_REGS) { + Term t = Deref(inp); + Term tii = ti; + tr_fr_ptr TR0 = TR; + + if (IsVarTerm(t)) { + *to = ti; + return t; + } else if (IsPrimitiveTerm(t)) { + *to = ti; + return t; + } else if (IsPairTerm(t)) { + CELL *ap; + CELL *Hi; + + restart_list: + ap = RepPair(t); + Hi = HR; + HR += 2; + { + Int res; + if ((res = break_rationals_complex_term(ap-1, ap+1, Hi, to, ti, Hi PASS_REGS)) < 0) { + HR = Hi; + if ((t = handle_cp_overflow(res, TR0, arity, t))== 0L) + return FALSE; + goto restart_list; + } else if (*to == tii) { + HR = Hi; + return t; + } else { + return AbsPair(Hi); + } + } + } else { + Functor f; + CELL *HB0; + CELL *ap; + + restart_appl: + f = FunctorOfTerm(t); + if (IsExtensionFunctor(f)) { + *to = ti; + return t; + } + HB0 = HR; + ap = RepAppl(t); + HR[0] = (CELL)f; + arity = ArityOfFunctor(f); + HR += 1+arity; + + { + Int res; + if ((res = break_rationals_complex_term(ap, ap+(arity), HB0+1, to, ti, HB0 PASS_REGS)) < 0) { + HR = HB0; + if ((t = handle_cp_overflow(res, TR0, arity, t))== 0L) + return FALSE; + goto restart_appl; + } else if (*to == ti) { + HR = HB0; + return t; + } else { + return AbsAppl(HB0); + } + } + } +} + + static int +break_complex_term(CELL *pt0, CELL *pt0_end, CELL *ptf, Term *of, Term oi, CELL *HLow USES_REGS) { struct copy_frame *to_visit0, *to_visit = (struct copy_frame *)Yap_PreAllocCodeSpace(); @@ -586,7 +840,7 @@ break_rationals_complex_term(CELL *pt0, CELL *pt0_end, CELL *ptf, Term *of, Term if (!IsVarTerm(*newp)) { Term v = (CELL)newp, t = *newp; RESET_VARIABLE(newp); - of = add_to_list( of, v, t PASS_REGS); + oi = add_to_list( oi, v, t PASS_REGS); } *ptf++ = (CELL)newp; continue; @@ -667,8 +921,7 @@ break_rationals_complex_term(CELL *pt0, CELL *pt0_end, CELL *ptf, Term *of, Term /* restore our nice, friendly, term to its original state */ HB = HB0; reset_trail(TR0); - RESET_VARIABLE(of); - Yap_unify((CELL)of, oi); + *of = oi; return TRUE; overflow: @@ -677,14 +930,12 @@ break_rationals_complex_term(CELL *pt0, CELL *pt0_end, CELL *ptf, Term *of, Term /* we've done it */ /* restore our nice, friendly, term to its original state */ HB = HB0; -#ifdef RATIONAL_TREES while (to_visit > to_visit0) { to_visit --; pt0 = to_visit->start_cp; pt0_end = to_visit->end_cp; ptf = to_visit->to; } -#endif reset_trail(TR0); /* follow chain of multi-assigned variables */ return -1; @@ -695,28 +946,27 @@ break_rationals_complex_term(CELL *pt0, CELL *pt0_end, CELL *ptf, Term *of, Term /* we've done it */ /* restore our nice, friendly, term to its original state */ HB = HB0; -#ifdef RATIONAL_TREES while (to_visit > to_visit0) { to_visit --; pt0 = to_visit->start_cp; pt0_end = to_visit->end_cp; ptf = to_visit->to; } -#endif reset_trail(TR0); LOCAL_Error_Size = (ADDR)AuxSp-(ADDR)to_visit0; return -3; } - -static Term -BreakRational(Term inp, UInt arity, Term *of, Term oi USES_REGS) { + Term +Yap_BreakTerm(Term inp, UInt arity, Term *to, Term ti USES_REGS) { Term t = Deref(inp); tr_fr_ptr TR0 = TR; if (IsVarTerm(t)) { + *to = ti; return t; } else if (IsPrimitiveTerm(t)) { + *to = ti; return t; } else { CELL *ap; @@ -728,7 +978,7 @@ BreakRational(Term inp, UInt arity, Term *of, Term oi USES_REGS) { { int res; - if ((res = break_rationals_complex_term(ap-1, ap, Hi, of, oi, Hi PASS_REGS)) < 0) { + if ((res = break_complex_term(ap-1, ap, Hi, to, ti, Hi PASS_REGS)) < 0) { HR = Hi; if ((t = handle_cp_overflow(res, TR0, arity, t))== 0L) return FALSE; @@ -739,11 +989,12 @@ BreakRational(Term inp, UInt arity, Term *of, Term oi USES_REGS) { } } + static Int p_break_rational( USES_REGS1 ) { Term tf; - return Yap_unify(ARG2, BreakRational(ARG1, 4, &tf, ARG4 PASS_REGS)) && + return Yap_unify(ARG2, Yap_BreakTerm(ARG1, 4, &tf, ARG4 PASS_REGS)) && Yap_unify(tf, ARG3); } @@ -752,7 +1003,7 @@ static Int p_break_rational3( USES_REGS1 ) { Term tf; - return Yap_unify(ARG2, BreakRational(ARG1, 4, &tf, TermNil PASS_REGS)) && + return Yap_unify(ARG2, Yap_BreakTerm(ARG1, 4, &tf, TermNil PASS_REGS)) && Yap_unify(tf, ARG3); } @@ -800,12 +1051,12 @@ Atom export_atom(Atom at, char **hpp, char *buf, size_t len) ptr = (char *)AdjustSize((CELL*)ptr, buf); p0 = ptr; - *ptr++ = 0; - sz = strlen(RepAtom(at)->StrOfAE); - if (sz + 1 >= len) - return (Atom)NULL; - strcpy(ptr, RepAtom(at)->StrOfAE); - *hpp = ptr+(sz+1); + *ptr++ = 0; + sz = strlen(RepAtom(at)->StrOfAE); + if (sz + 1 >= len) + return (Atom)NULL; + strcpy(ptr, RepAtom(at)->StrOfAE); + *hpp = ptr+(sz+1); return (Atom)(p0-buf); } @@ -827,7 +1078,7 @@ Functor export_functor(Functor f, char **hpp, char *buf, size_t len) return (Functor)(((char *)hptr-buf)+1); } -#define export_derefa_body(D,A,LabelUnk,LabelNonVar) \ +#define export_derefa_body(D,A,LabelUnk,LabelNonVar) \ do { \ if ((CELL *)(D) < CellDifH(HR,HLow)) { (A) = (CELL *)(D); break; } \ (A) = (CELL *)(D); \ @@ -845,7 +1096,7 @@ export_term_to_buffer(Term inpt, char *buf, char *bptr, CELL *t0 , CELL *tf, siz if (buf + len < (char *)((CELL *)td + (tf-t0))) { return FALSE; } - memcpy((void *)td, (void *)t0, (tf-t0)* sizeof(CELL)); + memmove((void *)td, (void *)t0, (tf-t0)* sizeof(CELL)); bf[0] = (td-buf); bf[1] = (tf-t0); bf[2] = inpt; @@ -945,7 +1196,7 @@ export_complex_term(Term tf, CELL *pt0, CELL *pt0_end, char * buf, size_t len0, if (HR+sz > ASP - 2048) { goto overflow; } - memcpy((void *)HR, (void *)ap2, sz*sizeof(CELL)); + memmove((void *)HR, (void *)ap2, sz*sizeof(CELL)); HR += sz; continue; } @@ -1263,7 +1514,7 @@ Yap_ImportTerm(char * buf) { return 0L; } } - memcpy(HR, buf+bc[0], sizeof(CELL)*sz); + memmove(HR, buf+bc[0], sizeof(CELL)*sz); if (IsApplTerm(tinp)) { tret = AbsAppl(HR); import_compound(HR, (char *)HR, buf, HR); @@ -1617,8 +1868,9 @@ p_term_variables( USES_REGS1 ) /* variables in term t */ /** * Exports a nil-terminated list with all the variables in a term. - * @param[in] the term - * @param[in] the arity of the calling predicate (required for exact garbage collection). + * @param[t] the term + * @param[arity] the arity of the calling predicate (required for exact garbage collection). + * @param[USES_REGS] threading */ Term Yap_TermVariables( Term t, UInt arity USES_REGS ) /* variables in term t */ @@ -1649,16 +1901,24 @@ Yap_TermVariables( Term t, UInt arity USES_REGS ) /* variables in term t */ return out; } +typedef struct att_rec { + CELL *beg, *end; + CELL oval; +} att_rec_t; + static Term attvars_in_complex_term(register CELL *pt0, register CELL *pt0_end, Term inp USES_REGS) { - - register CELL **to_visit0, **to_visit = (CELL **)Yap_PreAllocCodeSpace(); + int lvl = push_text_stack(); + att_rec_t *to_visit0, *to_visit = Malloc(1024*sizeof(att_rec_t)); + att_rec_t *to_visit_max; register tr_fr_ptr TR0 = TR; CELL *InitialH = HR; CELL output = AbsPair(HR); to_visit0 = to_visit; - loop: + to_visit_max = to_visit0+1024; + restart: + do { while (pt0 < pt0_end) { register CELL d0; register CELL *ptd0; @@ -1669,7 +1929,7 @@ static Term attvars_in_complex_term(register CELL *pt0, register CELL *pt0_end, attvars_in_term_nvar: { if (IsPairTerm(d0)) { - if (to_visit + 1024 >= (CELL **)AuxSp) { + if (to_visit + 32 >= to_visit_max) { goto aux_overflow; } { @@ -1681,10 +1941,10 @@ static Term attvars_in_complex_term(register CELL *pt0, register CELL *pt0_end, } } #ifdef RATIONAL_TREES - to_visit[0] = pt0; - to_visit[1] = pt0_end; - to_visit[2] = (CELL *)*pt0; - to_visit += 3; + to_visit->beg = pt0; + to_visit->end = pt0_end; + to_visit->oval = *pt0; + to_visit ++; *pt0 = TermNil; #else if (pt0 < pt0_end) { @@ -1696,8 +1956,8 @@ static Term attvars_in_complex_term(register CELL *pt0, register CELL *pt0_end, pt0 = RepPair(d0) - 1; pt0_end = pt0+2; } else if (IsApplTerm(d0)) { - register Functor f; - register CELL *ap2; + Functor f; + CELL *ap2; /* store the terms to visit */ ap2 = RepAppl(d0); f = (Functor)(*ap2); @@ -1705,14 +1965,14 @@ static Term attvars_in_complex_term(register CELL *pt0, register CELL *pt0_end, continue; } /* store the terms to visit */ - if (to_visit + 1024 >= (CELL **)AuxSp) { + if (to_visit + 32 >= to_visit_max) { goto aux_overflow; } #ifdef RATIONAL_TREES - to_visit[0] = pt0; - to_visit[1] = pt0_end; - to_visit[2] = (CELL *)*pt0; - to_visit += 3; + to_visit->beg = pt0; + to_visit->end = pt0_end; + to_visit->oval = *pt0; + to_visit ++; *pt0 = TermNil; #else if (pt0 < pt0_end) { @@ -1721,9 +1981,9 @@ static Term attvars_in_complex_term(register CELL *pt0, register CELL *pt0_end, to_visit += 2; } #endif - d0 = ArityOfFunctor(f); + arity_t a = ArityOfFunctor(f); pt0 = ap2; - pt0_end = ap2 + d0; + pt0_end = ap2 + a; } continue; } @@ -1749,15 +2009,16 @@ static Term attvars_in_complex_term(register CELL *pt0, register CELL *pt0_end, HR += 2; HR[-2] = (CELL)ptd0; /* store the terms to visit */ - if (to_visit + 1024 >= (CELL **)AuxSp) { + if (to_visit + 32 >= to_visit_max) { goto aux_overflow; } #ifdef RATIONAL_TREES - to_visit[0] = pt0; - to_visit[1] = pt0_end; - to_visit[2] = (CELL *)*pt0; - to_visit += 3; - *pt0 = TermNil; + + to_visit->beg = pt0; + to_visit->end = pt0_end; + to_visit->oval = *pt0; + to_visit ++; + *pt0 = TermNil; #else if (pt0 < pt0_end) { to_visit[0] = pt0; @@ -1768,24 +2029,25 @@ static Term attvars_in_complex_term(register CELL *pt0, register CELL *pt0_end, pt0 = &RepAttVar(ptd0)->Value; pt0_end = &RepAttVar(ptd0)->Atts; } + continue; } /* Do we still have compound terms to visit */ - if (to_visit > to_visit0) { + if (to_visit == to_visit0) + break; #ifdef RATIONAL_TREES - to_visit -= 3; - pt0 = to_visit[0]; - pt0_end = to_visit[1]; - *pt0 = (CELL)to_visit[2]; + to_visit --; + pt0 = to_visit->beg; + pt0_end = to_visit->end; + *pt0 = to_visit->oval; #else to_visit -= 2; pt0 = to_visit[0]; pt0_end = to_visit[1]; #endif - goto loop; - } + } while(true); clean_tr(TR0 PASS_REGS); - Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); + pop_text_stack(lvl); if (HR != InitialH) { /* close the list */ Term t2 = Deref(inp); @@ -1803,43 +2065,39 @@ static Term attvars_in_complex_term(register CELL *pt0, register CELL *pt0_end, trail_overflow: #ifdef RATIONAL_TREES while (to_visit > to_visit0) { - to_visit -= 3; - pt0 = to_visit[0]; - *pt0 = (CELL)to_visit[2]; + to_visit --; + pt0 = to_visit->beg; + *pt0 = to_visit->oval; } #endif LOCAL_Error_TYPE = RESOURCE_ERROR_TRAIL; LOCAL_Error_Size = (TR-TR0)*sizeof(tr_fr_ptr *); clean_tr(TR0 PASS_REGS); - Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); + pop_text_stack(lvl); HR = InitialH; return 0L; aux_overflow: - LOCAL_Error_Size = (to_visit-to_visit0)*sizeof(CELL **); -#ifdef RATIONAL_TREES - while (to_visit > to_visit0) { - to_visit -= 3; - pt0 = to_visit[0]; - *pt0 = (CELL)to_visit[2]; - } -#endif - LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK; - clean_tr(TR0 PASS_REGS); - Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); - HR = InitialH; - return 0L; + { + size_t d1 = to_visit-to_visit0; + size_t d2 = to_visit_max-to_visit0; + to_visit0 = Realloc(to_visit0,d2*sizeof(CELL*)+64*1024); + to_visit = to_visit0+d1; + to_visit_max = to_visit0+(d2+(64*1024))/sizeof(CELL **); +} +pt0--; +goto restart; global_overflow: #ifdef RATIONAL_TREES while (to_visit > to_visit0) { - to_visit -= 3; - pt0 = to_visit[0]; - *pt0 = (CELL)to_visit[2]; + to_visit --; + pt0 = to_visit->beg; + *pt0 = to_visit->oval; } #endif clean_tr(TR0 PASS_REGS); - Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); +pop_text_stack(lvl); HR = InitialH; LOCAL_Error_TYPE = RESOURCE_ERROR_STACK; LOCAL_Error_Size = (ASP-HR)*sizeof(CELL); @@ -1865,6 +2123,8 @@ p_term_attvars( USES_REGS1 ) /* variables in term t */ } else { Functor f = FunctorOfTerm(t); + if (IsExtensionFunctor(f)) + return Yap_unify(TermNil, ARG2); out = attvars_in_complex_term(RepAppl(t), RepAppl(t)+ ArityOfFunctor(f), TermNil PASS_REGS); @@ -3467,7 +3727,7 @@ hash_complex_term(register CELL *pt0, *st++ = LongIntOfTerm(d0); break; case (CELL)FunctorString: - memcpy(st, RepAppl(d0), (3+RepAppl(d0)[1])*sizeof(CELL)); + memmove(st, RepAppl(d0), (3+RepAppl(d0)[1])*sizeof(CELL)); st += 3+RepAppl(d0)[1]; break; #ifdef USE_GMP @@ -3482,7 +3742,7 @@ hash_complex_term(register CELL *pt0, goto global_overflow; } /* then the actual number */ - memcpy((void *)(st+1), (void *)(pt+1), sz); + memmove((void *)(st+1), (void *)(pt+1), sz); st = st+sz/CellSize; } break; @@ -4585,16 +4845,22 @@ renumbervar(Term t, Int id USES_REGS) ts[1] = MkIntegerTerm(id); } +extern int vsc; + +int vsc; static Int numbervars_in_complex_term(register CELL *pt0, register CELL *pt0_end, Int numbv, int singles USES_REGS) { - register CELL **to_visit0, **to_visit = (CELL **)Yap_PreAllocCodeSpace(); + int lvl = push_text_stack(); + att_rec_t *to_visit0, *to_visit = Malloc(1024*sizeof(att_rec_t)); + att_rec_t *to_visit_max; register tr_fr_ptr TR0 = TR; CELL *InitialH = HR; to_visit0 = to_visit; - loop: + to_visit_max = to_visit0+1024; +loop: while (pt0 < pt0_end) { register CELL d0; register CELL *ptd0; @@ -4605,14 +4871,14 @@ static Int numbervars_in_complex_term(register CELL *pt0, register CELL *pt0_end vars_in_term_nvar: { if (IsPairTerm(d0)) { - if (to_visit + 1024 >= (CELL **)AuxSp) { + if (to_visit + 32 >= to_visit_max) { goto aux_overflow; } #ifdef RATIONAL_TREES - to_visit[0] = pt0; - to_visit[1] = pt0_end; - to_visit[2] = (CELL *)*pt0; - to_visit += 3; + to_visit->beg = pt0; + to_visit->end = pt0_end; + to_visit->oval = *pt0; + to_visit ++; *pt0 = TermNil; #else if (pt0 < pt0_end) { @@ -4624,8 +4890,8 @@ static Int numbervars_in_complex_term(register CELL *pt0, register CELL *pt0_end pt0 = RepPair(d0) - 1; pt0_end = RepPair(d0) + 1; } else if (IsApplTerm(d0)) { - register Functor f; - register CELL *ap2; + Functor f; + CELL *ap2; /* store the terms to visit */ ap2 = RepAppl(d0); f = (Functor)(*ap2); @@ -4637,21 +4903,16 @@ static Int numbervars_in_complex_term(register CELL *pt0, register CELL *pt0_end continue; } /* store the terms to visit */ - if (to_visit + 1024 >= (CELL **)AuxSp) { - goto aux_overflow; - } + if (to_visit + 32 >= to_visit_max) { + goto aux_overflow; + } #ifdef RATIONAL_TREES - to_visit[0] = pt0; - to_visit[1] = pt0_end; - to_visit[2] = (CELL *)*pt0; - to_visit += 3; - *pt0 = TermNil; #else - if (pt0 < pt0_end) { - to_visit[0] = pt0; - to_visit[1] = pt0_end; - to_visit += 2; - } + to_visit->beg = pt0; + to_visit->end = pt0_end; + to_visit->oval = *pt0; + to_visit ++; + *pt0 = TermNil; #endif d0 = ArityOfFunctor(f); pt0 = ap2; @@ -4687,10 +4948,10 @@ static Int numbervars_in_complex_term(register CELL *pt0, register CELL *pt0_end /* Do we still have compound terms to visit */ if (to_visit > to_visit0) { #ifdef RATIONAL_TREES - to_visit -= 3; - pt0 = to_visit[0]; - pt0_end = to_visit[1]; - *pt0 = (CELL)to_visit[2]; + to_visit --; + pt0 = to_visit->beg; + pt0_end = to_visit->end; + *pt0 = to_visit->oval; #else to_visit -= 2; pt0 = to_visit[0]; @@ -4700,52 +4961,50 @@ static Int numbervars_in_complex_term(register CELL *pt0, register CELL *pt0_end } prune(B PASS_REGS); - Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); + pop_text_stack(lvl); return numbv; trail_overflow: #ifdef RATIONAL_TREES while (to_visit > to_visit0) { - to_visit -= 3; - pt0 = to_visit[0]; - *pt0 = (CELL)to_visit[2]; + to_visit --; + pt0 = to_visit->beg; + pt0_end = to_visit->end; + *pt0 = to_visit->oval; } #endif LOCAL_Error_TYPE = RESOURCE_ERROR_TRAIL; LOCAL_Error_Size = (TR-TR0)*sizeof(tr_fr_ptr *); clean_tr(TR0 PASS_REGS); - Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); HR = InitialH; + pop_text_stack(lvl); return numbv-1; aux_overflow: - LOCAL_Error_Size = (to_visit-to_visit0)*sizeof(CELL **); -#ifdef RATIONAL_TREES - while (to_visit > to_visit0) { - to_visit -= 3; - pt0 = to_visit[0]; - *pt0 = (CELL)to_visit[2]; - } -#endif - LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK; - clean_tr(TR0 PASS_REGS); - Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); - HR = InitialH; - return numbv-1; + { + size_t d1 = to_visit-to_visit0; + size_t d2 = to_visit_max-to_visit0; + to_visit0 = Realloc(to_visit0,d2*sizeof(CELL*)+64*1024); + to_visit = to_visit0+d1; + to_visit_max = to_visit0+(d2+(64*1024))/sizeof(CELL **); +} +pt0--; +goto loop; global_overflow: #ifdef RATIONAL_TREES while (to_visit > to_visit0) { - to_visit -= 3; - pt0 = to_visit[0]; - *pt0 = (CELL)to_visit[2]; + to_visit --; + pt0 = to_visit->beg; + pt0_end = to_visit->end; + *pt0 = to_visit->oval; } #endif clean_tr(TR0 PASS_REGS); - Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); HR = InitialH; LOCAL_Error_TYPE = RESOURCE_ERROR_STACK; LOCAL_Error_Size = (ASP-HR)*sizeof(CELL); + pop_text_stack(lvl); return numbv-1; } diff --git a/C/write.c b/C/write.c index b84b0a14d..8c094676f 100644 --- a/C/write.c +++ b/C/write.c @@ -1,4 +1,3 @@ - /************************************************************************* * * * YAP Prolog * @@ -9,10 +8,9 @@ * * ************************************************************************** * * - * File: write.c * - * Last rev: * - * mods: * - * comments: Writing a Prolog Term * + * File: write.c * Last + *rev: * mods: + ** comments: Writing a Prolog Term * * * *************************************************************************/ #ifdef SCCS @@ -84,28 +82,29 @@ typedef struct write_globs { #define lastw wglb->lw #define last_minus wglb->last_atom_minus -static bool callPortray(Term t, struct DB_TERM **old_EXp, int sno USES_REGS) { +static bool callPortray(Term t, int sno USES_REGS) { PredEntry *pe; Int b0 = LCL0 - (CELL *)B; - *old_EXp = Yap_RefToException(); UNLOCK(GLOBAL_Stream[sno].streamlock); if ((pe = RepPredProp(Yap_GetPredPropByFunc(FunctorPortray, USER_MODULE))) && pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE && Yap_execute_pred(pe, &t, true PASS_REGS)) { choiceptr B0 = (choiceptr)(LCL0 - b0); - if (Yap_HasException() && !*old_EXp) - *old_EXp = Yap_RefToException(); Yap_fail_all(B0 PASS_REGS); LOCK(GLOBAL_Stream[sno].streamlock); return true; } LOCK(GLOBAL_Stream[sno].streamlock); - if (Yap_HasException() && !*old_EXp) - *old_EXp = Yap_RefToException(); + return false; } +#define PROTECT(t,F) { \ + yhandle_t yt = Yap_InitHandle(t); \ + F; \ + t = Yap_PopHandle(yt); \ + } static void wrputn(Int, struct write_globs *); static void wrputf(Float, struct write_globs *); static void wrputref(CODEADDR, int, struct write_globs *); @@ -117,7 +116,7 @@ static void putAtom(Atom, int, struct write_globs *); static void writeTerm(Term, int, int, int, struct write_globs *, struct rewind_term *); -#define wrputc(WF, X) \ +#define wrputc(WF, X) \ (X)->stream_wputc(X - GLOBAL_Stream, WF) /* writes a character */ /* @@ -191,7 +190,7 @@ inline static void wrputs(char *s, StreamDesc *stream) { static char *ensure_space(size_t sz) { CACHE_REGS - char *s; + char *s; s = (char *)Yap_PreAllocCodeSpace(); while (s + sz >= (char *)AuxSp) { @@ -271,10 +270,10 @@ static void writebig(Term t, int p, int depth, int rinfixarg, return; #endif } else if (big_tag >= USER_BLOB_START && big_tag < USER_BLOB_END) { - Opaque_CallOnWrite f; + YAP_Opaque_CallOnWrite f; CELL blob_info; - blob_info = big_tag - USER_BLOB_START; + blob_info = big_tag; if (GLOBAL_OpaqueHandlers && (f = GLOBAL_OpaqueHandlers[blob_info].write_handler)) { (f)(wglb->stream->file, big_tag, ExternalBlobFromTerm(t), 0); @@ -322,7 +321,7 @@ static void wrputf(Float f, struct write_globs *wglb) /* writes a float */ /* always use C locale for writing numbers */ #if O_LOCALE const unsigned char *decimalpoint = - (unsigned char *)localeconv()->decimal_point; + (unsigned char *)localeconv()->decimal_point; size_t l1 = strlen((const char *)decimalpoint + 1); #else const unsigned char decimalpoint[2] = "."; @@ -354,7 +353,7 @@ static void wrputf(Float f, struct write_globs *wglb) /* writes a float */ found_dot = TRUE; wrputs(".0", stream); } - found_dot = TRUE; + found_dot = true; } wrputc(ch, stream); pt++; @@ -378,9 +377,8 @@ static void wrputf(Float f, struct write_globs *wglb) /* writes a float */ int Yap_FormatFloat(Float f, char **s, size_t sz) { CACHE_REGS - struct write_globs wglb; + struct write_globs wglb; int sno; - char *so; sno = Yap_open_buf_write_stream(GLOBAL_Stream[LOCAL_c_output_stream].encoding, 0); @@ -389,10 +387,7 @@ int Yap_FormatFloat(Float f, char **s, size_t sz) { wglb.lw = separator; wglb.stream = GLOBAL_Stream + sno; wrputf(f, &wglb); - wrputc('\0', wglb.stream); - so = Yap_MemExportStreamPtr(sno); - *s = Malloc( strlen(so) )+1; - strcpy(*s, so ); + *s = Yap_MemExportStreamPtr(sno); Yap_CloseStream(sno); return true; } @@ -479,12 +474,12 @@ AtomIsSymbols(unsigned char *s) /* Is this atom just formed by symbols ? */ static void write_quoted(wchar_t ch, wchar_t quote, wrf stream) { CACHE_REGS - if (!(Yap_GetModuleEntry(CurrentModule)->flags & M_CHARESCAPE)) { - wrputc(ch, stream); - if (ch == '\'') - wrputc('\'', stream); /* be careful about quotes */ - return; - } + if (!(Yap_GetModuleEntry(CurrentModule)->flags & M_CHARESCAPE)) { + wrputc(ch, stream); + if (ch == '\'') + wrputc('\'', stream); /* be careful about quotes */ + return; + } if (!(ch < 0xff && chtype(ch) == BS) && ch != '\'' && ch != '\\' && ch != '`') { wrputc(ch, stream); @@ -566,13 +561,15 @@ static void write_string(const unsigned char *s, qt = '"'; wrputc(qt, stream); do { - int delta; - ptr += (delta = get_utf8(ptr, -1, &chr) ); + int delta; + ptr += (delta = get_utf8(ptr, -1, &chr)); if (chr == '\0') { break; } - if (delta == 0) {chr = *ptr++; } + if (delta == 0) { + chr = *ptr++; + } write_quoted(chr, qt, stream); } while (true); wrputc(qt, stream); @@ -588,7 +585,7 @@ static void putAtom(Atom atom, int Quote_illegal, struct write_globs *wglb) { wrputblob(RepAtom(atom), Quote_illegal, wglb); return; } - s = RepAtom(atom)->UStrOfAE; + s = RepAtom(atom)->UStrOfAE; /* #define CRYPT_FOR_STEVE 1*/ #ifdef CRYPT_FOR_STEVE if (Yap_GetValue(AtomCryptAtoms) != TermNil && @@ -609,7 +606,7 @@ static void putAtom(Atom atom, int Quote_illegal, struct write_globs *wglb) { wrputc('\'', stream); while (*s) { int32_t ch; - s += get_utf8(s, 1, &ch); + s += get_utf8(s, -1, &ch); write_quoted(ch, '\'', stream); } wrputc('\'', stream); @@ -678,67 +675,12 @@ static void putUnquotedString(Term string, struct write_globs *wglb) lastw = alphanum; } -static Term from_pointer(CELL *ptr0, struct rewind_term *rwt, - struct write_globs *wglb) { - CACHE_REGS - Term t; - CELL *ptr = ptr0; - - while (IsVarTerm(*ptr) && !IsUnboundVar(ptr)) - ptr = (CELL *)*ptr; - t = *ptr; - if (wglb->Keep_terms) { - struct rewind_term *x = rwt->parent; - - rwt->u_sd.s.old = Yap_InitSlot(t); - rwt->u_sd.s.ptr = Yap_InitSlot((CELL)ptr0); - - if (!IsAtomicTerm(t) && !IsVarTerm(t)) { - while (x) { - if (Yap_GetDerefedFromSlot(x->u_sd.s.old) == t) - return TermFoundVar; - x = x->parent; - } - } - } else { - rwt->u_sd.d.old = t; - rwt->u_sd.d.ptr = ptr0; - if (!IsVarTerm(t) && !IsAtomicTerm(t)) { - struct rewind_term *x = rwt->parent; - - while (x) { - if (x->u_sd.d.old == t) - return TermFoundVar; - x = x->parent; - } - } - } - return t; -} - -static CELL *restore_from_write(struct rewind_term *rwt, - struct write_globs *wglb) { - CACHE_REGS - CELL *ptr; - - if (wglb->Keep_terms) { - ptr = Yap_GetPtrFromSlot(rwt->u_sd.s.ptr); - Yap_RecoverSlots(2, rwt->u_sd.s.old); - // printf("leak=%d %d\n", LOCALCurSlot,rwt->u_sd.s.old) ; - } else { - ptr = rwt->u_sd.d.ptr; - } - rwt->u_sd.s.ptr = 0; - return ptr; -} - -/* writes an unbound variable */ static void write_var(CELL *t, struct write_globs *wglb, struct rewind_term *rwt) { CACHE_REGS - if (lastw == alphanum) { - wrputc(' ', wglb->stream); - } + if (lastw == alphanum) { + wrputc(' ', wglb->stream); + } wrputc('_', wglb->stream); /* make sure we don't get no creepy spaces where they shouldn't be */ lastw = separator; @@ -758,12 +700,11 @@ static void write_var(CELL *t, struct write_globs *wglb, wrputs("$AT(", wglb->stream); write_var(t, wglb, rwt); wrputc(',', wglb->stream); - writeTerm(from_pointer(l, &nrwt, wglb), 999, 1, FALSE, wglb, &nrwt); - l = restore_from_write(&nrwt, wglb); - wrputc(',', wglb->stream); + PROTECT(*t,writeTerm(*l, 999, 1, FALSE, wglb, &nrwt)); + attv = RepAttVar(t); + wrputc(',', wglb->stream); l++; - writeTerm(from_pointer(l, &nrwt, wglb), 999, 1, FALSE, wglb, &nrwt); - restore_from_write(&nrwt, wglb); + writeTerm(*l, 999, 1, FALSE, wglb, &nrwt); wrclose_bracket(wglb, TRUE); } wglb->Portray_delays = TRUE; @@ -776,24 +717,6 @@ static void write_var(CELL *t, struct write_globs *wglb, } } -static Term check_infinite_loop(Term t, struct rewind_term *x, - struct write_globs *wglb) { - CACHE_REGS - if (wglb->Keep_terms) { - while (x) { - if (Yap_GetFromSlot(x->u_sd.s.old) == t) - return TermFoundVar; - x = x->parent; - } - } else { - while (x) { - if (x->u_sd.d.old == t) - return TermFoundVar; - x = x->parent; - } - } - return t; -} static void write_list(Term t, int direction, int depth, struct write_globs *wglb, struct rewind_term *rwt) { @@ -806,14 +729,12 @@ static void write_list(Term t, int direction, int depth, int ndirection; int do_jump; - writeTerm(from_pointer(RepPair(t), &nrwt, wglb), 999, depth + 1, FALSE, - wglb, &nrwt); - t = AbsPair(restore_from_write(&nrwt, wglb)); + PROTECT(t,writeTerm(HeadOfTerm(t), 999, depth + 1, FALSE, + wglb, &nrwt)); ti = TailOfTerm(t); if (IsVarTerm(ti)) break; - if (!IsPairTerm(ti) || - !IsPairTerm((ti = check_infinite_loop(ti, rwt, wglb)))) + if (!IsPairTerm(ti)) break; ndirection = RepPair(ti) - RepPair(t); /* make sure we're not trapped in loops */ @@ -844,29 +765,18 @@ static void write_list(Term t, int direction, int depth, t = ti; } if (IsPairTerm(ti)) { - Term nt = from_pointer(RepPair(t) + 1, &nrwt, wglb); /* we found an infinite loop */ - if (IsAtomTerm(nt)) { - if (lastw == symbol || lastw == separator) { - wrputc(' ', wglb->stream); - } - wrputc('|', wglb->stream); - writeTerm(nt, 999, depth, FALSE, wglb, rwt); - } else { /* keep going on the list */ wrputc(',', wglb->stream); - write_list(nt, direction, depth, wglb, &nrwt); - } - restore_from_write(&nrwt, wglb); + write_list(ti, direction, depth, wglb, &nrwt); } else if (ti != MkAtomTerm(AtomNil)) { if (lastw == symbol || lastw == separator) { wrputc(' ', wglb->stream); } wrputc('|', wglb->stream); lastw = separator; - writeTerm(from_pointer(RepPair(t) + 1, &nrwt, wglb), 999, depth, FALSE, + writeTerm(ti, 999, depth, FALSE, wglb, &nrwt); - restore_from_write(&nrwt, wglb); } } @@ -874,10 +784,9 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, struct rewind_term *rwt) /* term to write */ /* context priority */ - { CACHE_REGS - struct rewind_term nrwt; + struct rewind_term nrwt; nrwt.parent = rwt; nrwt.u_sd.s.ptr = 0; @@ -885,8 +794,6 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg, putAtom(Atom3Dots, wglb->Quote_illegal, wglb); return; } - DBTerm *ex; - Yap_ResetException(worker_id); t = Deref(t); if (IsVarTerm(t)) { write_var((CELL *)t, wglb, &nrwt); @@ -900,20 +807,16 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg, wrputs("'.'(", wglb->stream); lastw = separator; - writeTerm(from_pointer(RepPair(t), &nrwt, wglb), 999, depth + 1, FALSE, - wglb, &nrwt); - t = AbsPair(restore_from_write(&nrwt, wglb)); + PROTECT( t, writeTerm(HeadOfTerm(t), 999, depth + 1, FALSE, + wglb, &nrwt)); wrputs(",", wglb->stream); - writeTerm(from_pointer(RepPair(t) + 1, &nrwt, wglb), 999, depth + 1, + writeTerm(TailOfTerm(t), 999, depth + 1, FALSE, wglb, &nrwt); - restore_from_write(&nrwt, wglb); wrclose_bracket(wglb, TRUE); return; } if (wglb->Use_portray) - if (callPortray(t, &ex, wglb->stream - GLOBAL_Stream PASS_REGS)) { - Yap_CopyException(ex); - Yap_RaiseException(); + if (callPortray(t, wglb->stream - GLOBAL_Stream PASS_REGS)) { return; } if (trueGlobalPrologFlag(WRITE_STRINGS_FLAG) && IsCodesTerm(t)) { @@ -949,7 +852,7 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg, case (CELL)FunctorLongInt: wrputn(LongIntOfTerm(t), wglb); return; - /* case (CELL)FunctorBigInt: */ + /* case (CELL)FunctorBigInt: */ default: writebig(t, p, depth, rinfixarg, wglb, rwt); return; @@ -974,9 +877,8 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg, *p++; lastw = separator; /* cannot use the term directly with the SBA */ - writeTerm(from_pointer(p, &nrwt, wglb), 999, depth + 1, FALSE, wglb, - &nrwt); - p = restore_from_write(&nrwt, wglb) + 1; + PROTECT( t, writeTerm(*p, 999, depth + 1, FALSE, wglb, + &nrwt) ); if (*p) wrputc(',', wglb->stream); argno++; @@ -986,16 +888,14 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg, } #endif if (wglb->Use_portray) { - if (callPortray(t, &ex, wglb->stream - GLOBAL_Stream PASS_REGS)) { - Yap_CopyException(ex); - Yap_RaiseException(); + if (callPortray(t, wglb->stream - GLOBAL_Stream PASS_REGS)) { return; } } if (!wglb->Ignore_ops && Arity == 1 && Yap_IsPrefixOp(atom, &op, &rp)) { Term tright = ArgOfTerm(1, t); int bracket_right = !IsVarTerm(tright) && IsAtomTerm(tright) && - Yap_IsOp(AtomOfTerm(tright)); + Yap_IsOp(AtomOfTerm(tright)); if (op > p) { wropen_bracket(wglb, TRUE); } @@ -1006,9 +906,8 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg, } else if (atom == AtomMinus) { last_minus = TRUE; } - writeTerm(from_pointer(RepAppl(t) + 1, &nrwt, wglb), rp, depth + 1, TRUE, + writeTerm(tright, rp, depth + 1, TRUE, wglb, &nrwt); - restore_from_write(&nrwt, wglb); if (bracket_right) { wrclose_bracket(wglb, TRUE); } @@ -1033,7 +932,7 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg, offset = 1; } bracket_left = - !IsVarTerm(tleft) && IsAtomTerm(tleft) && Yap_IsOp(AtomOfTerm(tleft)); + !IsVarTerm(tleft) && IsAtomTerm(tleft) && Yap_IsOp(AtomOfTerm(tleft)); if (op > p) { /* avoid stuff such as \+ (a,b) being written as \+(a,b) */ wropen_bracket(wglb, TRUE); @@ -1041,9 +940,8 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg, if (bracket_left) { wropen_bracket(wglb, TRUE); } - writeTerm(from_pointer(RepAppl(t) + offset, &nrwt, wglb), lp, depth + 1, + writeTerm(ArgOfTerm(offset,t), lp, depth + 1, rinfixarg, wglb, &nrwt); - restore_from_write(&nrwt, wglb); if (bracket_left) { wrclose_bracket(wglb, TRUE); } @@ -1076,9 +974,9 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg, Term tleft = ArgOfTerm(1, t); Term tright = ArgOfTerm(2, t); int bracket_left = - !IsVarTerm(tleft) && IsAtomTerm(tleft) && Yap_IsOp(AtomOfTerm(tleft)); + !IsVarTerm(tleft) && IsAtomTerm(tleft) && Yap_IsOp(AtomOfTerm(tleft)); int bracket_right = !IsVarTerm(tright) && IsAtomTerm(tright) && - Yap_IsOp(AtomOfTerm(tright)); + Yap_IsOp(AtomOfTerm(tright)); if (op > p) { /* avoid stuff such as \+ (a,b) being written as \+(a,b) */ @@ -1088,9 +986,8 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg, if (bracket_left) { wropen_bracket(wglb, TRUE); } - writeTerm(from_pointer(RepAppl(t) + 1, &nrwt, wglb), lp, depth + 1, - rinfixarg, wglb, &nrwt); - t = AbsAppl(restore_from_write(&nrwt, wglb) - 1); + PROTECT(t,writeTerm(ArgOfTerm(1,t), lp, depth + 1, + rinfixarg, wglb, &nrwt)); if (bracket_left) { wrclose_bracket(wglb, TRUE); } @@ -1109,9 +1006,8 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg, if (bracket_right) { wropen_bracket(wglb, TRUE); } - writeTerm(from_pointer(RepAppl(t) + 2, &nrwt, wglb), rp, depth + 1, TRUE, + writeTerm(ArgOfTerm(2,t), rp, depth + 1, TRUE, wglb, &nrwt); - restore_from_write(&nrwt, wglb); if (bracket_right) { wrclose_bracket(wglb, TRUE); } @@ -1151,17 +1047,15 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg, } else { wrputs("'$VAR'(", wglb->stream); lastw = separator; - writeTerm(from_pointer(RepAppl(t) + 1, &nrwt, wglb), 999, depth + 1, + writeTerm(ArgOfTerm(1, t), 999, depth + 1, FALSE, wglb, &nrwt); - restore_from_write(&nrwt, wglb); wrclose_bracket(wglb, TRUE); } } else if (!wglb->Ignore_ops && functor == FunctorBraces) { wrputc('{', wglb->stream); lastw = separator; - writeTerm(from_pointer(RepAppl(t) + 1, &nrwt, wglb), GLOBAL_MaxPriority, + writeTerm(ArgOfTerm(1, t), GLOBAL_MaxPriority, depth + 1, FALSE, wglb, &nrwt); - restore_from_write(&nrwt, wglb); wrputc('}', wglb->stream); lastw = separator; } else if (atom == AtomArray) { @@ -1172,35 +1066,37 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg, wrputs("...", wglb->stream); break; } - writeTerm(from_pointer(RepAppl(t) + op, &nrwt, wglb), 999, depth + 1, + writeTerm(ArgOfTerm(op, t), 999, depth + 1, FALSE, wglb, &nrwt); - t = AbsAppl(restore_from_write(&nrwt, wglb) - op); if (op != Arity) { + PROTECT(t, writeTerm(ArgOfTerm(op, t), 999, depth + 1, + FALSE, wglb, &nrwt)); wrputc(',', wglb->stream); lastw = separator; } } + writeTerm(ArgOfTerm(op, t), 999, depth + 1, + FALSE, wglb, &nrwt); wrputc('}', wglb->stream); lastw = separator; } else { putAtom(atom, wglb->Quote_illegal, wglb); lastw = separator; wropen_bracket(wglb, FALSE); - for (op = 1; op <= Arity; ++op) { + for (op = 1; op < Arity; ++op) { if (op == wglb->MaxArgs) { wrputc('.', wglb->stream); wrputc('.', wglb->stream); wrputc('.', wglb->stream); break; } - writeTerm(from_pointer(RepAppl(t) + op, &nrwt, wglb), 999, depth + 1, - FALSE, wglb, &nrwt); - restore_from_write(&nrwt, wglb); - if (op != Arity) { + PROTECT(t,writeTerm(ArgOfTerm(op, t), 999, depth + 1, + FALSE, wglb, &nrwt)); wrputc(',', wglb->stream); lastw = separator; - } } + writeTerm(ArgOfTerm(op, t), 999, depth + 1, + FALSE, wglb, &nrwt); wrclose_bracket(wglb, TRUE); } } @@ -1213,13 +1109,16 @@ void Yap_plwrite(Term t, StreamDesc *mywrite, int max_depth, int flags, /* write options */ { CACHE_REGS - struct write_globs wglb; + struct write_globs wglb; struct rewind_term rwt; yhandle_t sls = Yap_CurrentSlot(); + int lvl = push_text_stack(); + if (t == 0) + return; if (!mywrite) { CACHE_REGS - wglb.stream = GLOBAL_Stream + LOCAL_c_error_stream; + wglb.stream = GLOBAL_Stream + LOCAL_c_error_stream; } else wglb.stream = mywrite; wglb.lw = start; @@ -1237,8 +1136,18 @@ void Yap_plwrite(Term t, StreamDesc *mywrite, int max_depth, int flags, rwt.parent = NULL; wglb.Ignore_ops = flags & Ignore_ops_f; wglb.Write_strings = flags & BackQuote_String_f; + if (!(flags & Ignore_cyclics_f) && false) { + Term ts[2]; + ts[0] = Yap_BreakRational(t, 0, ts+1, TermNil PASS_REGS); + //fprintf(stderr, "%lx %lx %lx\n", t, ts[0], ts[1]); + //Yap_DebugPlWriteln(ts[0]); + //ap_DebugPlWriteln(ts[1[); + if (ts[1] != TermNil) { + t = Yap_MkApplTerm( FunctorAtSymbol, 2, ts); + } + } /* protect slots for portray */ - writeTerm(from_pointer(&t, &rwt, &wglb), priority, 1, FALSE, &wglb, &rwt); + writeTerm(t, priority, 1, FALSE, &wglb, &rwt); if (flags & New_Line_f) { if (flags & Fullstop_f) { wrputc('.', wglb.stream); @@ -1252,31 +1161,7 @@ void Yap_plwrite(Term t, StreamDesc *mywrite, int max_depth, int flags, wrputc(' ', wglb.stream); } } - restore_from_write(&rwt, &wglb); Yap_CloseSlots(sls); + pop_text_stack(lvl); } -char *Yap_TermToString(Term t, size_t *lengthp, encoding_t enc, int flags) { - CACHE_REGS - int sno = Yap_open_buf_write_stream(enc, flags); - const char *sf; - DBTerm *e = LOCAL_BallTerm; - - if (sno < 0) - return NULL; - LOCAL_c_output_stream = sno; - if (enc) - GLOBAL_Stream[sno].encoding = enc; - else - GLOBAL_Stream[sno].encoding = LOCAL_encoding; - Yap_plwrite(t, GLOBAL_Stream + sno, 0, flags, GLOBAL_MaxPriority); - - sf = Yap_MemExportStreamPtr(sno); - size_t len = strlen(sf); - char *new = malloc( len + 1 ); - strcpy( new, sf ); - Yap_CloseStream(sno); - if (e) - LOCAL_BallTerm = e; - return new; -} diff --git a/interactive.py b/C/y similarity index 100% rename from interactive.py rename to C/y diff --git a/C/yap-args.c b/C/yap-args.c index 7ec1cc274..6e196d16e 100755 --- a/C/yap-args.c +++ b/C/yap-args.c @@ -1,33 +1,41 @@ -/************************************************************************* -* * -* Yap Prolog * -* * -* Yap Prolog Was Developed At Nccup - Universidade Do Porto * -* * -* Copyright L.Damas, V.S.Costa And Universidade Do Porto 1985-1997 * -* * -************************************************************************** -* * -* File: Yap.C * -* Last Rev: * -* Mods: * -* Comments: Yap's Main File: parse arguments * -* * -*************************************************************************/ -/* static char SccsId[] = "X 4.3.3"; */ +/************************************************************************* + * * + * Yap Prolog * + * * + * Yap Prolog Was Developed At Nccup - Universidade Do Porto * + * * + * Copyright L.Damas, V.S.Costa And Universidade Do Porto 1985-1997 * + * * + ************************************************************************** + * * + * File: Yap.C * Last + *Rev: + * Mods: + ** Comments: Yap's Main File: parse arguments * + * * + *************************************************************************/ +/* static char SccsId[] = "X 4.3.3"; */ #include "Yap.h" #include "YapHeap.h" #include "YapInterface.h" -#include "config.h" +#include "YapStreams.h" +#include "iopreds.h" + #if HAVE_UNISTD_H + #include + #endif #if HAVE_STDINT_H + #include + #endif -#include + #include + +#include #ifdef _MSC_VER /* Microsoft's Visual C++ Compiler */ #ifdef HAVE_UNISTD_H #undef HAVE_UNISTD_H @@ -35,16 +43,325 @@ #endif #include + #if HAVE_STRING_H + #include + #endif #if HAVE_ERRNO_H + #include + #endif #if HAVE_DIRECT_H #include #endif +#if HAVE_LIBGEN_H +#include + +#endif + +X_API bool YAP_initialized = false; +static int n_mdelays = 0; +static YAP_delaymodule_t *m_delays; + +static void init_globals(YAP_init_args *yap_init) { + GLOBAL_FAST_BOOT_FLAG = yap_init->FastBoot; +#if defined(YAPOR) || defined(TABLING) + + Yap_init_root_frames(); + +#endif /* YAPOR || TABLING */ +#ifdef YAPOR + Yap_init_yapor_workers(); +#if YAPOR_THREADS + if (Yap_thread_self() != 0) { +#else + if (worker_id != 0) { +#endif +#if defined(YAPOR_COPY) || defined(YAPOR_SBA) + /* + In the SBA we cannot just happily inherit registers + from the other workers + */ + Yap_InitYaamRegs(worker_id, true); +#endif /* YAPOR_COPY || YAPOR_SBA */ +#ifndef YAPOR_THREADS + Yap_InitPreAllocCodeSpace(0); +#endif /* YAPOR_THREADS */ + /* slaves, waiting for work */ + CurrentModule = USER_MODULE; + P = GETWORK_FIRST_TIME; + Yap_exec_absmi(FALSE, YAP_EXEC_ABSMI); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, + "abstract machine unexpected exit (YAP_Init)"); + } +#endif /* YAPOR */ + RECOVER_MACHINE_REGS(); + /* make sure we do this after restore */ + if (yap_init->MaxStackSize) { + GLOBAL_AllowLocalExpansion = FALSE; + } else { + GLOBAL_AllowLocalExpansion = TRUE; + } + if (yap_init->MaxGlobalSize) { + GLOBAL_AllowGlobalExpansion = FALSE; + } else { + GLOBAL_AllowGlobalExpansion = TRUE; + } + if (yap_init->MaxTrailSize) { + GLOBAL_AllowTrailExpansion = FALSE; + } else { + GLOBAL_AllowTrailExpansion = TRUE; + } + if (yap_init->PrologRCFile) { + Yap_PutValue(AtomConsultOnBoot, + MkAtomTerm(Yap_LookupAtom(yap_init->PrologRCFile))); + /* + This must be done again after restore, as yap_flags + has been overwritten .... + */ + setBooleanGlobalPrologFlag(HALT_AFTER_CONSULT_FLAG, + yap_init->HaltAfterBoot); + } + if (yap_init->PrologTopLevelGoal) { + Yap_PutValue(AtomTopLevelGoal, + MkAtomTerm(Yap_LookupAtom(yap_init->PrologTopLevelGoal))); + } + if (yap_init->PrologGoal) { + Yap_PutValue(AtomInitGoal, + MkAtomTerm(Yap_LookupAtom(yap_init->PrologGoal))); + } + if (yap_init->PrologAddPath) { + Yap_PutValue(AtomExtendFileSearchPath, + MkAtomTerm(Yap_LookupAtom(yap_init->PrologAddPath))); + } + + if (yap_init->QuietMode) { + setVerbosity(TermSilent); + } +} + +const char *Yap_BINDIR, *Yap_ROOTDIR, *Yap_SHAREDIR, *Yap_LIBDIR, *Yap_DLLDIR, + *Yap_PLDIR, *Yap_BOOTSTRAP, *Yap_COMMONSDIR, *Yap_INPUT_STARTUP, + *Yap_OUTPUT_STARTUP, *Yap_BOOTFILE, *Yap_INCLUDEDIR; + +/** + * consult loop in C: used to boot the system, butt supports goal execution and + * recursive consulting. + * + * */ +static bool consult(const char *b_file USES_REGS) { + Term t; + int c_stream, osno, oactive; + Functor functor_query = Yap_MkFunctor(Yap_LookupAtom("?-"), 1); + Functor functor_command1 = Yap_MkFunctor(Yap_LookupAtom(":-"), 1); + Functor functor_compile2 = Yap_MkFunctor(Yap_LookupAtom("c_compile"), 1); + + /* consult in C */ + int lvl = push_text_stack(); + char *full; + /* the consult mode does not matter here, really */ + if ((osno = Yap_CheckAlias(AtomLoopStream)) < 0) { + osno = 0; + } + c_stream = YAP_InitConsult(YAP_BOOT_MODE, b_file, &full, &oactive); + if (c_stream < 0) { + fprintf(stderr, "[ FATAL ERROR: could not open file %s ]\n", b_file); + pop_text_stack(lvl); + exit(1); + } + if (!Yap_AddAlias(AtomLoopStream, c_stream)) { + pop_text_stack(lvl); + return false; + } + + do { + CACHE_REGS + YAP_Reset(YAP_FULL_RESET, false); + Yap_StartSlots(); + Term vs = MkVarTerm(), pos = MkVarTerm(); + t = YAP_ReadClauseFromStream(c_stream, vs, pos); + // Yap_GetNèwSlot(t); + if (t == TermEof) + break; + if (t == 0) { + fprintf(stderr, "[ SYNTAX ERROR: while parsing stream %s at line %ld ]\n", + b_file, GLOBAL_Stream[c_stream].linecount); + } else if (IsVarTerm(t) || t == TermNil) { + fprintf(stderr, "[ line: " Int_FORMAT ": term cannot be compiled ]", + GLOBAL_Stream[c_stream].linecount); + } else if (IsApplTerm(t) && (FunctorOfTerm(t) == functor_query || + FunctorOfTerm(t) == functor_command1)) { + t = ArgOfTerm(1, t); + if (IsApplTerm(t) && FunctorOfTerm(t) == functor_compile2) { + consult(RepAtom(AtomOfTerm(ArgOfTerm(1, t)))->StrOfAE); + } else { + YAP_RunGoalOnce(t); + } + } else { + YAP_CompileClause(t); + } + yap_error_descriptor_t *errd; + if ((errd = Yap_GetException(LOCAL_ActiveError))) { + fprintf(stderr, "%s:%ld:0: Error %s %s Found\n", errd->errorFile, + (long int)errd->errorLine, errd->classAsText, errd->errorAsText); + } + } while (true); + BACKUP_MACHINE_REGS(); + YAP_EndConsult(c_stream, &osno, full); + if (!Yap_AddAlias(AtomLoopStream, osno)) { + pop_text_stack(lvl); + return false; + } + pop_text_stack(lvl); + return true; +} + +/// +/// +static const char *sel(bool dir, bool ok1, const char *s1, bool ok2, + const char *s2, ...) { + if (ok1 && s1) + return s1; + if (ok2) + return s2; + return NULL; +} + +static const char *join(const char *s0, const char *s1) { + CACHE_REGS + + if (!s0 || s0[0] == '\0') + return s1; + if (!s1 || s1[0] == '\0') + return s0; + // int lvl = push_text_stack(); + char *buf = malloc(FILENAME_MAX + 1); + strcpy(buf, s0); + strcat(buf, s1); + return buf; +} + +static void Yap_set_locations(YAP_init_args *iap) { + + /// ROOT_DIR is the home of the YAP system. It can be: + /// -- provided by the user; + /// -- obtained from DESTDIR + DE=efalkRoot + /// + /// It is: + // --_not useful in Android, WIN32; + /// -- DESTDIR/ in Anaconda + /// -- /usr/locall in most Unix style systems + Yap_ROOTDIR = sel(true, iap->ROOTDIR != NULL, iap->ROOTDIR, true, +#if __ANDROID__ + NULL, +#else + join(getenv("DESTDIR"), YAP_ROOTDIR), +#endif + false); + /// BINDIR: where the OS stores header files, namely libYap... + Yap_BINDIR = sel(true, iap->BINDIR != NULL, iap->BINDIR, true, +#if __ANDROID__ + NULL, +#else + join(getenv("DESTDIR"), YAP_BINDIR), +#endif + false); + /// LIBDIR: where the OS stores dynamic libraries, namely libYap... + Yap_LIBDIR = sel(true, iap->LIBDIR != NULL, iap->LIBDIR, true, +#if __ANDROID__ + NULL, +#else + join(getenv("DESTDIR"), YAP_LIBDIR), +#endif + false); + /// DLLDIR: where libraries can find expicitely loaded DLLs + Yap_DLLDIR = sel(true, iap->DLLDIR != NULL, iap->DLLDIR, true, +#if __ANDROID__ + NULL, +#else + join(getenv("DESTDIR"), YAP_DLLDIR), +#endif + false); + /// INCLUDEDIR: where the OS stores header files, namely libYap... + Yap_INCLUDEDIR = sel(true, iap->INCLUDEDIR != NULL, iap->INCLUDEDIR, true, +#if __ANDROID__ + NULL, +#else + join(getenv("DESTDIR"), YAP_INCLUDEDIR), +#endif + false); + /// SHAREDIR: where OS & ARCH independent files live + Yap_SHAREDIR = sel(true, iap->SHAREDIR != NULL, iap->SHAREDIR, true, +#if __ANDROID__ + "/assets", +#else + join(getenv("DESTDIR"), YAP_SHAREDIR), +#endif + false); + /// PLDIR: where we can find Prolog files + Yap_PLDIR = sel(true, iap->PLDIR != NULL, iap->PLDIR, true, +#if __ANDROID__ + "/assets/Yap", +#else + join(getenv("DESTDIR"), YAP_PLDIR), +#endif + false); + /// ``COMMONSDIR: Prolog Commons + Yap_COMMONSDIR = sel(true, iap->COMMONSDIR != NULL, iap->COMMONSDIR, true, +#if __ANDROID__ + "/assets/PrologCommons", +#else + join(getenv("DESTDIR"), YAP_SHAREDIR "/PrologCommons"), +#endif + false); + /// BOOTPLDIR: where we can find Prolog bootstrap files + Yap_BOOTSTRAP = sel(true, iap->BOOTSTRAP != NULL, iap->BOOTSTRAP, true, +#if __ANDROID__ + "/assets/Yap/pl/boot.yap", +#else + join(getenv("DESTDIR"), YAP_BOOTSTRAP), +#endif + false); + /// BOOTFILE: where we can find the core Prolog boot file + Yap_BOOTFILE = sel(false, iap->BOOTFILE != NULL, iap->BOOTFILE, true, +#if __ANDROID__ + "/assets/Yap/pl/boot.yap", +#else + join(getenv("DESTDIR"), YAP_BOOTFILE), +#endif + false); + /// STARTUP: where we can find the core Prolog bootstrap file + Yap_OUTPUT_STARTUP = + sel(false, iap->OUTPUT_STARTUP != NULL, iap->OUTPUT_STARTUP, true, +#if __ANDROID__ + NULL, +#else + join(getenv("DESTDIR"), YAP_OUTPUT_STARTUP), +#endif + false); + Yap_INPUT_STARTUP = + sel(false, iap->INPUT_STARTUP != NULL, iap->INPUT_STARTUP, true, +#if __ANDROID__ + NULL, +#else + join(getenv("DESTDIR"), YAP_INPUT_STARTUP), +#endif + false); + if (Yap_ROOTDIR) + setAtomicGlobalPrologFlag(HOME_FLAG, + MkAtomTerm(Yap_LookupAtom(Yap_ROOTDIR))); + if (Yap_PLDIR) + setAtomicGlobalPrologFlag(PROLOG_LIBRARY_DIRECTORY_FLAG, + MkAtomTerm(Yap_LookupAtom(Yap_PLDIR))); + if (Yap_DLLDIR) + setAtomicGlobalPrologFlag(PROLOG_FOREIGN_DIRECTORY_FLAG, + MkAtomTerm(Yap_LookupAtom(Yap_DLLDIR))); +} + static void print_usage(void) { fprintf(stderr, "\n[ Valid switches for command line arguments: ]\n"); fprintf(stderr, " -? Shows this screen\n"); @@ -68,7 +385,7 @@ static void print_usage(void) { fprintf(stderr, " -GSize Max Area for Global Stack\n"); fprintf(stderr, " -LSize Max Area for Local Stack (number must follow L)\n"); - fprintf(stderr, " -TSize Max Area for Trail (number must follow L)\n"); + fprintf(stderr, " -TSize Max Area for Trail (number must follow T)\n"); fprintf(stderr, " -nosignals disable signal handling from Prolog\n"); fprintf(stderr, "\n[Execution Modes]\n"); fprintf(stderr, " -J0 Interpreted mode (default)\n"); @@ -85,8 +402,9 @@ static void print_usage(void) { defined(YAPOR_THREADS) fprintf(stderr, " -w Number of workers (default: %d)\n", DEFAULT_NUMBERWORKERS); - fprintf(stderr, " -sl Loop scheduler executions before look for hiden " - "shared work (default: %d)\n", + fprintf(stderr, + " -sl Loop scheduler executions before look for hiden " + "shared work (default: %d)\n", DEFAULT_SCHEDULERLOOP); fprintf(stderr, " -d Value of delayed release of load (default: %d)\n", DEFAULT_DELAYEDRELEASELOAD); @@ -135,21 +453,33 @@ static int dump_runtime_variables(void) { return 1; } -YAP_file_type_t Yap_InitDefaults(YAP_init_args *iap, char saved_state[], - int argc, char *argv[]) { +X_API YAP_file_type_t Yap_InitDefaults(void *x, char *saved_state, int argc, + char *argv[]) { + + if (!LOCAL_TextBuffer) + LOCAL_TextBuffer = Yap_InitTextAllocator(); + YAP_init_args *iap = x; memset(iap, 0, sizeof(YAP_init_args)); #if __ANDROID__ iap->boot_file_type = YAP_BOOT_PL; - iap->SavedState = NULL; + iap->INPUT_STARTUP = NULL; + iap->assetManager = NULL; #else iap->boot_file_type = YAP_QLY; - iap->SavedState = saved_state; + iap->INPUT_STARTUP = saved_state; #endif iap->Argc = argc; iap->Argv = argv; - return iap->boot_file_type; + return YAP_QLY; } +/** + * @short Paese command line + * @param argc number of arguments + * @param argv arguments + * @param iap options, see YAP_init_args + * @return boot from saved state or restore; error + */ X_API YAP_file_type_t YAP_parse_yap_arguments(int argc, char *argv[], YAP_init_args *iap) { char *p; @@ -163,24 +493,21 @@ X_API YAP_file_type_t YAP_parse_yap_arguments(int argc, char *argv[], case 'b': iap->boot_file_type = YAP_PL; if (p[1]) - iap->YapPrologBootFile = p + 1; + iap->BOOTFILE = p + 1; else if (argv[1] && *argv[1] != '-') { - iap->YapPrologBootFile = *++argv; + iap->BOOTFILE = *++argv; argc--; - } else { - iap->YapPrologBootFile = "boot.yap"; } break; case 'B': iap->boot_file_type = YAP_BOOT_PL; if (p[1]) - iap->YapPrologBootFile = p + 1; + iap->BOOTSTRAP = p + 1; else if (argv[1] && *argv[1] != '-') { - iap->YapPrologBootFile = *++argv; + iap->BOOTSTRAP = *++argv; argc--; - } else { - iap->YapPrologBootFile = "boot.yap"; } + iap->install = true; break; case '?': print_usage(); @@ -214,7 +541,7 @@ X_API YAP_file_type_t YAP_parse_yap_arguments(int argc, char *argv[], argc--; argv++; if (strcmp(*argv, "none")) { - iap->YapPrologRCFile = *argv; + iap->PrologRCFile = *argv; } break; } @@ -306,7 +633,7 @@ X_API YAP_file_type_t YAP_parse_yap_arguments(int argc, char *argv[], break; } if (ch) { - iap->YapPrologTopLevelGoal = add_end_dot(*argv); + iap->PrologTopLevelGoal = add_end_dot(*argv); } else { *ssize = i; } @@ -381,7 +708,7 @@ X_API YAP_file_type_t YAP_parse_yap_arguments(int argc, char *argv[], goto GetSize; } iap->QuietMode = TRUE; - iap->HaltAfterConsult = TRUE; + iap->HaltAfterBoot = true; case 'l': p++; if (!*++argv) { @@ -390,11 +717,11 @@ X_API YAP_file_type_t YAP_parse_yap_arguments(int argc, char *argv[], exit(1); } else if (!strcmp("--", *argv)) { /* shell script, the next entry should be the file itself */ - iap->YapPrologRCFile = argv[1]; + iap->PrologRCFile = argv[1]; argc = 1; break; } else { - iap->YapPrologRCFile = *argv; + iap->PrologRCFile = *argv; argc--; } if (*p) { @@ -415,7 +742,7 @@ X_API YAP_file_type_t YAP_parse_yap_arguments(int argc, char *argv[], /* run goal before top-level */ case 'g': if ((*argv)[0] == '\0') - iap->YapPrologGoal = *argv; + iap->PrologGoal = *argv; else { argc--; if (argc == 0) { @@ -424,24 +751,24 @@ X_API YAP_file_type_t YAP_parse_yap_arguments(int argc, char *argv[], exit(EXIT_FAILURE); } argv++; - iap->YapPrologGoal = *argv; + iap->PrologGoal = *argv; } break; /* run goal as top-level */ case 'z': if ((*argv)[0] == '\0') - iap->YapPrologTopLevelGoal = *argv; + iap->PrologTopLevelGoal = *argv; else { argc--; if (argc == 0) { - fprintf( - stderr, - " [ YAP unrecoverable error: missing goal for option 'z' ]\n"); + fprintf(stderr, " [ YAP unrecoverable error: missing goal for " + "option 'z' ]\n"); exit(EXIT_FAILURE); } argv++; - iap->YapPrologTopLevelGoal = add_end_dot(*argv); + iap->PrologTopLevelGoal = add_end_dot(*argv); } + iap->HaltAfterBoot = true; break; case 'n': if (!strcmp("nosignals", p)) { @@ -453,14 +780,27 @@ X_API YAP_file_type_t YAP_parse_yap_arguments(int argc, char *argv[], if (!strcmp("-nosignals", p)) { iap->PrologCannotHandleInterrupts = true; break; + } else if (!strncmp("-output-saved-state=", p, + strlen("-output-saved-state="))) { + iap->OUTPUT_STARTUP = p + strlen("-output-saved-state="); } else if (!strncmp("-home=", p, strlen("-home="))) { - GLOBAL_Home = p + strlen("-home="); + iap->ROOTDIR = p + strlen("-home="); + } else if (!strncmp("-system-library-directory=", p, + strlen("-system-library-directory="))) { + iap->LIBDIR = p + strlen("-system-library-directory="); + } else if (!strncmp("-system-shared-directory=", p, + strlen("-system-shared-directory="))) { + iap->SHAREDIR = p + strlen("-system-shared-directory="); + } else if (!strncmp("-prolog-library-directory=", p, + strlen("-prolog-library-directory="))) { + iap->PLDIR = p + strlen("-prolog-library-directory="); + } else if (!strncmp("-dll-library-directory=", p, + strlen("-dll-library-directory="))) { + iap->DLLDIR = p + strlen("-dll-library-directory="); + } else if (!strncmp("-home=", p, strlen("-home="))) { + iap->ROOTDIR = p + strlen("-home="); } else if (!strncmp("-cwd=", p, strlen("-cwd="))) { -#if __WINDOWS__ - if (_chdir(p + strlen("-cwd=")) < 0) { -#else - if (chdir(p + strlen("-cwd=")) < 0) { -#endif + if (!Yap_ChDir(p + strlen("-cwd="))) { fprintf(stderr, " [ YAP unrecoverable error in setting cwd: %s ]\n", strerror(errno)); } @@ -476,10 +816,22 @@ X_API YAP_file_type_t YAP_parse_yap_arguments(int argc, char *argv[], ssize = &(iap->HeapSize); p += strlen("-heap="); goto GetSize; + } else if (!strncmp("-max-stack=", p, strlen("-max-stack="))) { + ssize = &(iap->MaxStackSize); + p += strlen("-max-stack="); + goto GetSize; + } else if (!strncmp("-max-trail=", p, strlen("-max-trail="))) { + ssize = &(iap->MaxTrailSize); + p += strlen("-max-trail="); + goto GetSize; + } else if (!strncmp("-max-heap=", p, strlen("-max-heap="))) { + ssize = &(iap->MaxHeapSize); + p += strlen("-max-heap="); + goto GetSize; } else if (!strncmp("-goal=", p, strlen("-goal="))) { - iap->YapPrologGoal = p + strlen("-goal="); + iap->PrologGoal = p + strlen("-goal="); } else if (!strncmp("-top-level=", p, strlen("-top-level="))) { - iap->YapPrologTopLevelGoal = p + strlen("-top-level="); + iap->PrologTopLevelGoal = p + strlen("-top-level="); } else if (!strncmp("-table=", p, strlen("-table="))) { ssize = &(iap->MaxTableSpaceSize); p += strlen("-table="); @@ -493,17 +845,16 @@ X_API YAP_file_type_t YAP_parse_yap_arguments(int argc, char *argv[], break; case 'p': if ((*argv)[0] == '\0') - iap->YapPrologAddPath = *argv; + iap->PrologAddPath = *argv; else { argc--; if (argc == 0) { - fprintf( - stderr, - " [ YAP unrecoverable error: missing paths for option 'p' ]\n"); + fprintf(stderr, " [ YAP unrecoverable error: missing paths for " + "option 'p' ]\n"); exit(EXIT_FAILURE); } argv++; - iap->YapPrologAddPath = *argv; + iap->PrologAddPath = *argv; } break; /* nf: Begin preprocessor code */ @@ -538,8 +889,222 @@ X_API YAP_file_type_t YAP_parse_yap_arguments(int argc, char *argv[], } } else { - iap->SavedState = p; + iap->INPUT_STARTUP = p; } } return iap->boot_file_type; } + +/** + YAP_DelayInit() + + ensures initialization is done after engine creation. + It receives a pointer to function and a string describing + the module. +*/ + +X_API bool YAP_DelayInit(YAP_ModInit_t f, const char s[]) { + if (m_delays) { + m_delays = realloc(m_delays, (n_mdelays + 1) * sizeof(YAP_delaymodule_t)); + } else { + m_delays = malloc(sizeof(YAP_delaymodule_t)); + } + m_delays[n_mdelays].f = f; + m_delays[n_mdelays].s = s; + n_mdelays++; + return true; +} + +bool Yap_LateInit(const char s[]) { + int i; + for (i = 0; i < n_mdelays; i++) { + if (!strcmp(m_delays[i].s, s)) { + m_delays[i].f(); + return true; + } + } + return false; +} + +struct ssz_t { + size_t Heap, Stack, Trail; +}; + +bool Yap_Embedded; + +static void init_hw(YAP_init_args *yap_init, struct ssz_t *spt) { + Yap_page_size = Yap_InitPageSize(); /* init memory page size, required by + later functions */ +#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA) + Yap_init_yapor_global_local_memory(); +#endif /* YAPOR_COPY || YAPOR_COW || YAPOR_SBA */ + if (yap_init->Embedded) { + yap_init->install = false; + GLOBAL_PrologShouldHandleInterrupts = + yap_init->PrologCannotHandleInterrupts = true; + } else { + GLOBAL_PrologShouldHandleInterrupts = + !yap_init->PrologCannotHandleInterrupts; + } + Yap_InitSysbits(0); /* init signal handling and time, required by later + functions */ + GLOBAL_argv = yap_init->Argv; + GLOBAL_argc = yap_init->Argc; + +#if __ANDROID__ + + // if (yap_init->assetManager) + // Yap_InitAssetManager(); + +#endif + + if (yap_init->TrailSize == 0) { + if (spt->Trail == 0) + spt->Trail = DefTrailSpace; + } else { + spt->Trail = yap_init->TrailSize; + } + // Atts = yap_init->AttsSize; + if (yap_init->StackSize == 0) { + spt->Stack = DefStackSpace; + } else { + spt->Stack = yap_init->StackSize; + } +#ifndef USE_SYSTEM_MALLOC + if (yap_init->HeapSize == 0) { + if (spt->Heap == 0) + spt->Heap = DefHeapSpace; + } else { + spt->Heap = yap_init->HeapSize; + } +#endif +} + +static void end_init(YAP_init_args *iap) { + YAP_initialized = true; + if (iap->HaltAfterBoot) + Yap_exit(0); + LOCAL_PrologMode &= ~BootMode; + CurrentModule = USER_MODULE; +} + +static void start_modules(void) { + Term cm = CurrentModule; + size_t i; + for (i = 0; i < n_mdelays; i++) { + CurrentModule = MkAtomTerm(YAP_LookupAtom(m_delays[i].s)); + m_delays[i].f(); + } + CurrentModule = cm; +} + +/* this routine is supposed to be called from an external program + that wants to control Yap */ + +X_API void YAP_Init(YAP_init_args *yap_init) { + bool try_restore = yap_init->boot_file_type == YAP_QLY; + bool do_bootstrap = yap_init->boot_file_type == YAP_BOOT_PL; + struct ssz_t minfo; + + if (YAP_initialized) + /* ignore repeated calls to YAP_Init */ + return; + if (!LOCAL_TextBuffer) + LOCAL_TextBuffer = Yap_InitTextAllocator(); + + Yap_Embedded = yap_init->Embedded; + + minfo.Trail = 0, minfo.Stack = 0, minfo.Trail = 0; + init_hw(yap_init, &minfo); + Yap_InitWorkspace(yap_init, minfo.Heap, minfo.Stack, minfo.Trail, 0, + yap_init->MaxTableSpaceSize, yap_init->NumberWorkers, + yap_init->SchedulerLoop, yap_init->DelayedReleaseLoad); + // + + CACHE_REGS + + if (yap_init->QuietMode) { + setVerbosity(TermSilent); + } + if (yap_init->PrologRCFile != NULL) { + /* + This must be done before restore, otherwise + restore will print out messages .... + */ + setBooleanGlobalPrologFlag(HALT_AFTER_CONSULT_FLAG, + yap_init->HaltAfterBoot); + } + /* tell the system who should cope with interrupts */ + Yap_ExecutionMode = yap_init->ExecutionMode; + Yap_set_locations(yap_init); + + if (do_bootstrap || !try_restore || + !Yap_SavedInfo(Yap_INPUT_STARTUP, &minfo.Trail, &minfo.Stack, + &minfo.Heap)) { + init_globals(yap_init); + + start_modules(); + CurrentModule = PROLOG_MODULE; + TermEof = MkAtomTerm(Yap_LookupAtom("end_of_file")); + LOCAL_consult_level = -1; + consult(Yap_BOOTSTRAP PASS_REGS); + setAtomicGlobalPrologFlag(RESOURCE_DATABASE_FLAG, + MkAtomTerm(Yap_LookupAtom(Yap_BOOTFILE))); + setBooleanGlobalPrologFlag(SAVED_PROGRAM_FLAG, false); + } else { + if (yap_init->QuietMode) { + setVerbosity(TermSilent); + } + Yap_Restore(Yap_INPUT_STARTUP); + init_globals(yap_init); + + start_modules(); + if (yap_init->install && Yap_OUTPUT_STARTUP) { + setAtomicGlobalPrologFlag(RESOURCE_DATABASE_FLAG, + MkAtomTerm(Yap_LookupAtom(Yap_INPUT_STARTUP))); + setBooleanGlobalPrologFlag(SAVED_PROGRAM_FLAG, true); + } + LOCAL_consult_level = -1; + } + YAP_RunGoalOnce(TermInitProlog); + if (yap_init->install && Yap_OUTPUT_STARTUP) { + Term t = MkAtomTerm(Yap_LookupAtom(Yap_OUTPUT_STARTUP)); + Term g = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("qsave_program"), 1), + 1, &t); + + YAP_RunGoalOnce(g); + } + + end_init(yap_init); +} + +#if (DefTrailSpace < MinTrailSpace) +#undef DefTrailSpace +#define DefTrailSpace MinTrailSpace +#endif + +#if (DefStackSpace < MinStackSpace) +#undef DefStackSpace +#define DefStackSpace MinStackSpace +#endif + +#if (DefHeapSpace < MinHeapSpace) +#undef DefHeapSpace +#define DefHeapSpace MinHeapSpace +#endif + +#define DEFAULT_NUMBERWORKERS 1 +#define DEFAULT_SCHEDULERLOOP 10 +#define DEFAULT_DELAYEDRELEASELOAD 3 + +X_API void YAP_FastInit(char *saved_state, int argc, char *argv[]) { + YAP_init_args init_args; + YAP_file_type_t out; + + if ((out = Yap_InitDefaults(&init_args, saved_state, argc, argv)) != + YAP_FOUND_BOOT_ERROR) + YAP_Init(&init_args); + if (out == YAP_FOUND_BOOT_ERROR) { + Yap_Error(init_args.ErrorNo, TermNil, init_args.ErrorCause); + } +} diff --git a/CMakeDoxyfile.in b/CMakeDoxyfile.in new file mode 100644 index 000000000..251de2734 --- /dev/null +++ b/CMakeDoxyfile.in @@ -0,0 +1,272 @@ +# +# DO NOT EDIT! THIS FILE WAS GENERATED BY CMAKE! +# + +DOXYFILE_ENCODING = @DOXYGEN_DOXYFILE_ENCODING@ +PROJECT_NAME = @DOXYGEN_PROJECT_NAME@ +PROJECT_NUMBER = @DOXYGEN_PROJECT_NUMBER@ +PROJECT_BRIEF = @DOXYGEN_PROJECT_BRIEF@ +PROJECT_LOGO = @DOXYGEN_PROJECT_LOGO@ +OUTPUT_DIRECTORY = @DOXYGEN_OUTPUT_DIRECTORY@ +CREATE_SUBDIRS = @DOXYGEN_CREATE_SUBDIRS@ +ALLOW_UNICODE_NAMES = @DOXYGEN_ALLOW_UNICODE_NAMES@ +OUTPUT_LANGUAGE = @DOXYGEN_OUTPUT_LANGUAGE@ +BRIEF_MEMBER_DESC = @DOXYGEN_BRIEF_MEMBER_DESC@ +REPEAT_BRIEF = @DOXYGEN_REPEAT_BRIEF@ +ABBREVIATE_BRIEF = @DOXYGEN_ABBREVIATE_BRIEF@ +ALWAYS_DETAILED_SEC = @DOXYGEN_ALWAYS_DETAILED_SEC@ +INLINE_INHERITED_MEMB = @DOXYGEN_INLINE_INHERITED_MEMB@ +FULL_PATH_NAMES = @DOXYGEN_FULL_PATH_NAMES@ +STRIP_FROM_PATH = @DOXYGEN_STRIP_FROM_PATH@ +STRIP_FROM_INC_PATH = @DOXYGEN_STRIP_FROM_INC_PATH@ +SHORT_NAMES = @DOXYGEN_SHORT_NAMES@ +JAVADOC_AUTOBRIEF = @DOXYGEN_JAVADOC_AUTOBRIEF@ +QT_AUTOBRIEF = @DOXYGEN_QT_AUTOBRIEF@ +MULTILINE_CPP_IS_BRIEF = @DOXYGEN_MULTILINE_CPP_IS_BRIEF@ +INHERIT_DOCS = @DOXYGEN_INHERIT_DOCS@ +SEPARATE_MEMBER_PAGES = @DOXYGEN_SEPARATE_MEMBER_PAGES@ +TAB_SIZE = @DOXYGEN_TAB_SIZE@ +ALIASES = @DOXYGEN_ALIASES@ +TCL_SUBST = @DOXYGEN_TCL_SUBST@ +OPTIMIZE_OUTPUT_FOR_C = @DOXYGEN_OPTIMIZE_OUTPUT_FOR_C@ +OPTIMIZE_OUTPUT_JAVA = @DOXYGEN_OPTIMIZE_OUTPUT_JAVA@ +OPTIMIZE_FOR_FORTRAN = @DOXYGEN_OPTIMIZE_FOR_FORTRAN@ +OPTIMIZE_OUTPUT_VHDL = @DOXYGEN_OPTIMIZE_OUTPUT_VHDL@ +EXTENSION_MAPPING = @DOXYGEN_EXTENSION_MAPPING@ +MARKDOWN_SUPPORT = @DOXYGEN_MARKDOWN_SUPPORT@ +TOC_INCLUDE_HEADINGS = @DOXYGEN_TOC_INCLUDE_HEADINGS@ +AUTOLINK_SUPPORT = @DOXYGEN_AUTOLINK_SUPPORT@ +BUILTIN_STL_SUPPORT = @DOXYGEN_BUILTIN_STL_SUPPORT@ +CPP_CLI_SUPPORT = @DOXYGEN_CPP_CLI_SUPPORT@ +SIP_SUPPORT = @DOXYGEN_SIP_SUPPORT@ +IDL_PROPERTY_SUPPORT = @DOXYGEN_IDL_PROPERTY_SUPPORT@ +DISTRIBUTE_GROUP_DOC = @DOXYGEN_DISTRIBUTE_GROUP_DOC@ +GROUP_NESTED_COMPOUNDS = @DOXYGEN_GROUP_NESTED_COMPOUNDS@ +SUBGROUPING = @DOXYGEN_SUBGROUPING@ +INLINE_GROUPED_CLASSES = @DOXYGEN_INLINE_GROUPED_CLASSES@ +INLINE_SIMPLE_STRUCTS = @DOXYGEN_INLINE_SIMPLE_STRUCTS@ +TYPEDEF_HIDES_STRUCT = @DOXYGEN_TYPEDEF_HIDES_STRUCT@ +LOOKUP_CACHE_SIZE = @DOXYGEN_LOOKUP_CACHE_SIZE@ +EXTRACT_ALL = @DOXYGEN_EXTRACT_ALL@ +EXTRACT_PRIVATE = @DOXYGEN_EXTRACT_PRIVATE@ +EXTRACT_PACKAGE = @DOXYGEN_EXTRACT_PACKAGE@ +EXTRACT_STATIC = @DOXYGEN_EXTRACT_STATIC@ +EXTRACT_LOCAL_CLASSES = @DOXYGEN_EXTRACT_LOCAL_CLASSES@ +EXTRACT_LOCAL_METHODS = @DOXYGEN_EXTRACT_LOCAL_METHODS@ +EXTRACT_ANON_NSPACES = @DOXYGEN_EXTRACT_ANON_NSPACES@ +HIDE_UNDOC_MEMBERS = @DOXYGEN_HIDE_UNDOC_MEMBERS@ +HIDE_UNDOC_CLASSES = @DOXYGEN_HIDE_UNDOC_CLASSES@ +HIDE_FRIEND_COMPOUNDS = @DOXYGEN_HIDE_FRIEND_COMPOUNDS@ +HIDE_IN_BODY_DOCS = @DOXYGEN_HIDE_IN_BODY_DOCS@ +INTERNAL_DOCS = @DOXYGEN_INTERNAL_DOCS@ +CASE_SENSE_NAMES = @DOXYGEN_CASE_SENSE_NAMES@ +HIDE_SCOPE_NAMES = @DOXYGEN_HIDE_SCOPE_NAMES@ +HIDE_COMPOUND_REFERENCE= @DOXYGEN_HIDE_COMPOUND_REFERENCE@ +SHOW_INCLUDE_FILES = @DOXYGEN_SHOW_INCLUDE_FILES@ +SHOW_GROUPED_MEMB_INC = @DOXYGEN_SHOW_GROUPED_MEMB_INC@ +FORCE_LOCAL_INCLUDES = @DOXYGEN_FORCE_LOCAL_INCLUDES@ +INLINE_INFO = @DOXYGEN_INLINE_INFO@ +SORT_MEMBER_DOCS = @DOXYGEN_SORT_MEMBER_DOCS@ +SORT_BRIEF_DOCS = @DOXYGEN_SORT_BRIEF_DOCS@ +SORT_MEMBERS_CTORS_1ST = @DOXYGEN_SORT_MEMBERS_CTORS_1ST@ +SORT_GROUP_NAMES = @DOXYGEN_SORT_GROUP_NAMES@ +SORT_BY_SCOPE_NAME = @DOXYGEN_SORT_BY_SCOPE_NAME@ +STRICT_PROTO_MATCHING = @DOXYGEN_STRICT_PROTO_MATCHING@ +GENERATE_TODOLIST = @DOXYGEN_GENERATE_TODOLIST@ +GENERATE_TESTLIST = @DOXYGEN_GENERATE_TESTLIST@ +GENERATE_BUGLIST = @DOXYGEN_GENERATE_BUGLIST@ +GENERATE_DEPRECATEDLIST= @DOXYGEN_GENERATE_DEPRECATEDLIST@ +ENABLED_SECTIONS = @DOXYGEN_ENABLED_SECTIONS@ +MAX_INITIALIZER_LINES = @DOXYGEN_MAX_INITIALIZER_LINES@ +SHOW_USED_FILES = @DOXYGEN_SHOW_USED_FILES@ +SHOW_FILES = @DOXYGEN_SHOW_FILES@ +SHOW_NAMESPACES = @DOXYGEN_SHOW_NAMESPACES@ +FILE_VERSION_FILTER = @DOXYGEN_FILE_VERSION_FILTER@ +LAYOUT_FILE = @DOXYGEN_LAYOUT_FILE@ +CITE_BIB_FILES = @DOXYGEN_CITE_BIB_FILES@ +QUIET = @DOXYGEN_QUIET@ +WARNINGS = @DOXYGEN_WARNINGS@ +WARN_IF_UNDOCUMENTED = @DOXYGEN_WARN_IF_UNDOCUMENTED@ +WARN_IF_DOC_ERROR = @DOXYGEN_WARN_IF_DOC_ERROR@ +WARN_NO_PARAMDOC = @DOXYGEN_WARN_NO_PARAMDOC@ +WARN_AS_ERROR = @DOXYGEN_WARN_AS_ERROR@ +WARN_FORMAT = @DOXYGEN_WARN_FORMAT@ +WARN_LOGFILE = @DOXYGEN_WARN_LOGFILE@ +INPUT = @DOXYGEN_INPUT@ +INPUT_ENCODING = @DOXYGEN_INPUT_ENCODING@ +FILE_PATTERNS = @DOXYGEN_FILE_PATTERNS@ +RECURSIVE = @DOXYGEN_RECURSIVE@ +EXCLUDE = @DOXYGEN_EXCLUDE@ +EXCLUDE_SYMLINKS = @DOXYGEN_EXCLUDE_SYMLINKS@ +EXCLUDE_PATTERNS = @DOXYGEN_EXCLUDE_PATTERNS@ +EXCLUDE_SYMBOLS = @DOXYGEN_EXCLUDE_SYMBOLS@ +EXAMPLE_PATH = @DOXYGEN_EXAMPLE_PATH@ +EXAMPLE_PATTERNS = @DOXYGEN_EXAMPLE_PATTERNS@ +EXAMPLE_RECURSIVE = @DOXYGEN_EXAMPLE_RECURSIVE@ +IMAGE_PATH = @DOXYGEN_IMAGE_PATH@ +INPUT_FILTER = @DOXYGEN_INPUT_FILTER@ +FILTER_PATTERNS = @DOXYGEN_FILTER_PATTERNS@ +FILTER_SOURCE_FILES = @DOXYGEN_FILTER_SOURCE_FILES@ +FILTER_SOURCE_PATTERNS = @DOXYGEN_FILTER_SOURCE_PATTERNS@ +USE_MDFILE_AS_MAINPAGE = @DOXYGEN_USE_MDFILE_AS_MAINPAGE@ +SOURCE_BROWSER = @DOXYGEN_SOURCE_BROWSER@ +INLINE_SOURCES = @DOXYGEN_INLINE_SOURCES@ +STRIP_CODE_COMMENTS = @DOXYGEN_STRIP_CODE_COMMENTS@ +REFERENCED_BY_RELATION = @DOXYGEN_REFERENCED_BY_RELATION@ +REFERENCES_RELATION = @DOXYGEN_REFERENCES_RELATION@ +REFERENCES_LINK_SOURCE = @DOXYGEN_REFERENCES_LINK_SOURCE@ +SOURCE_TOOLTIPS = @DOXYGEN_SOURCE_TOOLTIPS@ +USE_HTAGS = @DOXYGEN_USE_HTAGS@ +VERBATIM_HEADERS = @DOXYGEN_VERBATIM_HEADERS@ +CLANG_ASSISTED_PARSING = @DOXYGEN_CLANG_ASSISTED_PARSING@ +CLANG_OPTIONS = @DOXYGEN_CLANG_OPTIONS@ +ALPHABETICAL_INDEX = @DOXYGEN_ALPHABETICAL_INDEX@ +COLS_IN_ALPHA_INDEX = @DOXYGEN_COLS_IN_ALPHA_INDEX@ +IGNORE_PREFIX = @DOXYGEN_IGNORE_PREFIX@ +GENERATE_HTML = @DOXYGEN_GENERATE_HTML@ +HTML_OUTPUT = @DOXYGEN_HTML_OUTPUT@ +HTML_FILE_EXTENSION = @DOXYGEN_HTML_FILE_EXTENSION@ +HTML_HEADER = @DOXYGEN_HTML_HEADER@ +HTML_FOOTER = @DOXYGEN_HTML_FOOTER@ +HTML_STYLESHEET = @DOXYGEN_HTML_STYLESHEET@ +HTML_EXTRA_STYLESHEET = @DOXYGEN_HTML_EXTRA_STYLESHEET@ +HTML_EXTRA_FILES = @DOXYGEN_HTML_EXTRA_FILES@ +HTML_COLORSTYLE_HUE = @DOXYGEN_HTML_COLORSTYLE_HUE@ +HTML_COLORSTYLE_SAT = @DOXYGEN_HTML_COLORSTYLE_SAT@ +HTML_COLORSTYLE_GAMMA = @DOXYGEN_HTML_COLORSTYLE_GAMMA@ +HTML_TIMESTAMP = @DOXYGEN_HTML_TIMESTAMP@ +HTML_DYNAMIC_SECTIONS = @DOXYGEN_HTML_DYNAMIC_SECTIONS@ +HTML_INDEX_NUM_ENTRIES = @DOXYGEN_HTML_INDEX_NUM_ENTRIES@ +GENERATE_DOCSET = @DOXYGEN_GENERATE_DOCSET@ +DOCSET_FEEDNAME = @DOXYGEN_DOCSET_FEEDNAME@ +DOCSET_BUNDLE_ID = @DOXYGEN_DOCSET_BUNDLE_ID@ +DOCSET_PUBLISHER_ID = @DOXYGEN_DOCSET_PUBLISHER_ID@ +DOCSET_PUBLISHER_NAME = @DOXYGEN_DOCSET_PUBLISHER_NAME@ +GENERATE_HTMLHELP = @DOXYGEN_GENERATE_HTMLHELP@ +CHM_FILE = @DOXYGEN_CHM_FILE@ +HHC_LOCATION = @DOXYGEN_HHC_LOCATION@ +GENERATE_CHI = @DOXYGEN_GENERATE_CHI@ +CHM_INDEX_ENCODING = @DOXYGEN_CHM_INDEX_ENCODING@ +BINARY_TOC = @DOXYGEN_BINARY_TOC@ +TOC_EXPAND = @DOXYGEN_TOC_EXPAND@ +GENERATE_QHP = @DOXYGEN_GENERATE_QHP@ +QCH_FILE = @DOXYGEN_QCH_FILE@ +QHP_NAMESPACE = @DOXYGEN_QHP_NAMESPACE@ +QHP_VIRTUAL_FOLDER = @DOXYGEN_QHP_VIRTUAL_FOLDER@ +QHP_CUST_FILTER_NAME = @DOXYGEN_QHP_CUST_FILTER_NAME@ +QHP_CUST_FILTER_ATTRS = @DOXYGEN_QHP_CUST_FILTER_ATTRS@ +QHP_SECT_FILTER_ATTRS = @DOXYGEN_QHP_SECT_FILTER_ATTRS@ +QHG_LOCATION = @DOXYGEN_QHG_LOCATION@ +GENERATE_ECLIPSEHELP = @DOXYGEN_GENERATE_ECLIPSEHELP@ +ECLIPSE_DOC_ID = @DOXYGEN_ECLIPSE_DOC_ID@ +DISABLE_INDEX = @DOXYGEN_DISABLE_INDEX@ +GENERATE_TREEVIEW = @DOXYGEN_GENERATE_TREEVIEW@ +ENUM_VALUES_PER_LINE = @DOXYGEN_ENUM_VALUES_PER_LINE@ +TREEVIEW_WIDTH = @DOXYGEN_TREEVIEW_WIDTH@ +EXT_LINKS_IN_WINDOW = @DOXYGEN_EXT_LINKS_IN_WINDOW@ +FORMULA_FONTSIZE = @DOXYGEN_FORMULA_FONTSIZE@ +FORMULA_TRANSPARENT = @DOXYGEN_FORMULA_TRANSPARENT@ +USE_MATHJAX = @DOXYGEN_USE_MATHJAX@ +MATHJAX_FORMAT = @DOXYGEN_MATHJAX_FORMAT@ +MATHJAX_RELPATH = @DOXYGEN_MATHJAX_RELPATH@ +MATHJAX_EXTENSIONS = @DOXYGEN_MATHJAX_EXTENSIONS@ +MATHJAX_CODEFILE = @DOXYGEN_MATHJAX_CODEFILE@ +SEARCHENGINE = @DOXYGEN_SEARCHENGINE@ +SERVER_BASED_SEARCH = @DOXYGEN_SERVER_BASED_SEARCH@ +EXTERNAL_SEARCH = @DOXYGEN_EXTERNAL_SEARCH@ +SEARCHENGINE_URL = @DOXYGEN_SEARCHENGINE_URL@ +SEARCHDATA_FILE = @DOXYGEN_SEARCHDATA_FILE@ +EXTERNAL_SEARCH_ID = @DOXYGEN_EXTERNAL_SEARCH_ID@ +EXTRA_SEARCH_MAPPINGS = @DOXYGEN_EXTRA_SEARCH_MAPPINGS@ +GENERATE_LATEX = @DOXYGEN_GENERATE_LATEX@ +LATEX_OUTPUT = @DOXYGEN_LATEX_OUTPUT@ +LATEX_CMD_NAME = @DOXYGEN_LATEX_CMD_NAME@ +MAKEINDEX_CMD_NAME = @DOXYGEN_MAKEINDEX_CMD_NAME@ +COMPACT_LATEX = @DOXYGEN_COMPACT_LATEX@ +PAPER_TYPE = @DOXYGEN_PAPER_TYPE@ +EXTRA_PACKAGES = @DOXYGEN_EXTRA_PACKAGES@ +LATEX_HEADER = @DOXYGEN_LATEX_HEADER@ +LATEX_FOOTER = @DOXYGEN_LATEX_FOOTER@ +LATEX_EXTRA_STYLESHEET = @DOXYGEN_LATEX_EXTRA_STYLESHEET@ +LATEX_EXTRA_FILES = @DOXYGEN_LATEX_EXTRA_FILES@ +PDF_HYPERLINKS = @DOXYGEN_PDF_HYPERLINKS@ +USE_PDFLATEX = @DOXYGEN_USE_PDFLATEX@ +LATEX_BATCHMODE = @DOXYGEN_LATEX_BATCHMODE@ +LATEX_HIDE_INDICES = @DOXYGEN_LATEX_HIDE_INDICES@ +LATEX_SOURCE_CODE = @DOXYGEN_LATEX_SOURCE_CODE@ +LATEX_BIB_STYLE = @DOXYGEN_LATEX_BIB_STYLE@ +LATEX_TIMESTAMP = @DOXYGEN_LATEX_TIMESTAMP@ +GENERATE_RTF = @DOXYGEN_GENERATE_RTF@ +RTF_OUTPUT = @DOXYGEN_RTF_OUTPUT@ +COMPACT_RTF = @DOXYGEN_COMPACT_RTF@ +RTF_HYPERLINKS = @DOXYGEN_RTF_HYPERLINKS@ +RTF_STYLESHEET_FILE = @DOXYGEN_RTF_STYLESHEET_FILE@ +RTF_EXTENSIONS_FILE = @DOXYGEN_RTF_EXTENSIONS_FILE@ +RTF_SOURCE_CODE = @DOXYGEN_RTF_SOURCE_CODE@ +GENERATE_MAN = @DOXYGEN_GENERATE_MAN@ +MAN_OUTPUT = @DOXYGEN_MAN_OUTPUT@ +MAN_EXTENSION = @DOXYGEN_MAN_EXTENSION@ +MAN_SUBDIR = @DOXYGEN_MAN_SUBDIR@ +MAN_LINKS = @DOXYGEN_MAN_LINKS@ +GENERATE_XML = @DOXYGEN_GENERATE_XML@ +XML_OUTPUT = @DOXYGEN_XML_OUTPUT@ +XML_PROGRAMLISTING = @DOXYGEN_XML_PROGRAMLISTING@ +GENERATE_DOCBOOK = @DOXYGEN_GENERATE_DOCBOOK@ +DOCBOOK_OUTPUT = @DOXYGEN_DOCBOOK_OUTPUT@ +DOCBOOK_PROGRAMLISTING = @DOXYGEN_DOCBOOK_PROGRAMLISTING@ +GENERATE_AUTOGEN_DEF = @DOXYGEN_GENERATE_AUTOGEN_DEF@ +GENERATE_PERLMOD = @DOXYGEN_GENERATE_PERLMOD@ +PERLMOD_LATEX = @DOXYGEN_PERLMOD_LATEX@ +PERLMOD_PRETTY = @DOXYGEN_PERLMOD_PRETTY@ +PERLMOD_MAKEVAR_PREFIX = @DOXYGEN_PERLMOD_MAKEVAR_PREFIX@ +ENABLE_PREPROCESSING = @DOXYGEN_ENABLE_PREPROCESSING@ +MACRO_EXPANSION = @DOXYGEN_MACRO_EXPANSION@ +EXPAND_ONLY_PREDEF = @DOXYGEN_EXPAND_ONLY_PREDEF@ +SEARCH_INCLUDES = @DOXYGEN_SEARCH_INCLUDES@ +INCLUDE_PATH = @DOXYGEN_INCLUDE_PATH@ +INCLUDE_FILE_PATTERNS = @DOXYGEN_INCLUDE_FILE_PATTERNS@ +PREDEFINED = @DOXYGEN_PREDEFINED@ +EXPAND_AS_DEFINED = @DOXYGEN_EXPAND_AS_DEFINED@ +SKIP_FUNCTION_MACROS = @DOXYGEN_SKIP_FUNCTION_MACROS@ +TAGFILES = @DOXYGEN_TAGFILES@ +GENERATE_TAGFILE = @DOXYGEN_GENERATE_TAGFILE@ +ALLEXTERNALS = @DOXYGEN_ALLEXTERNALS@ +EXTERNAL_GROUPS = @DOXYGEN_EXTERNAL_GROUPS@ +EXTERNAL_PAGES = @DOXYGEN_EXTERNAL_PAGES@ +PERL_PATH = @DOXYGEN_PERL_PATH@ +CLASS_DIAGRAMS = @DOXYGEN_CLASS_DIAGRAMS@ +MSCGEN_PATH = @DOXYGEN_MSCGEN_PATH@ +DIA_PATH = @DOXYGEN_DIA_PATH@ +HIDE_UNDOC_RELATIONS = @DOXYGEN_HIDE_UNDOC_RELATIONS@ +HAVE_DOT = @DOXYGEN_HAVE_DOT@ +DOT_NUM_THREADS = @DOXYGEN_DOT_NUM_THREADS@ +DOT_FONTNAME = @DOXYGEN_DOT_FONTNAME@ +DOT_FONTSIZE = @DOXYGEN_DOT_FONTSIZE@ +DOT_FONTPATH = @DOXYGEN_DOT_FONTPATH@ +CLASS_GRAPH = @DOXYGEN_CLASS_GRAPH@ +COLLABORATION_GRAPH = @DOXYGEN_COLLABORATION_GRAPH@ +GROUP_GRAPHS = @DOXYGEN_GROUP_GRAPHS@ +UML_LOOK = @DOXYGEN_UML_LOOK@ +UML_LIMIT_NUM_FIELDS = @DOXYGEN_UML_LIMIT_NUM_FIELDS@ +TEMPLATE_RELATIONS = @DOXYGEN_TEMPLATE_RELATIONS@ +INCLUDE_GRAPH = @DOXYGEN_INCLUDE_GRAPH@ +INCLUDED_BY_GRAPH = @DOXYGEN_INCLUDED_BY_GRAPH@ +CALL_GRAPH = @DOXYGEN_CALL_GRAPH@ +CALLER_GRAPH = @DOXYGEN_CALLER_GRAPH@ +GRAPHICAL_HIERARCHY = @DOXYGEN_GRAPHICAL_HIERARCHY@ +DIRECTORY_GRAPH = @DOXYGEN_DIRECTORY_GRAPH@ +DOT_IMAGE_FORMAT = @DOXYGEN_DOT_IMAGE_FORMAT@ +INTERACTIVE_SVG = @DOXYGEN_INTERACTIVE_SVG@ +DOT_PATH = @DOXYGEN_DOT_PATH@ +DOTFILE_DIRS = @DOXYGEN_DOTFILE_DIRS@ +MSCFILE_DIRS = @DOXYGEN_MSCFILE_DIRS@ +DIAFILE_DIRS = @DOXYGEN_DIAFILE_DIRS@ +PLANTUML_JAR_PATH = @DOXYGEN_PLANTUML_JAR_PATH@ +PLANTUML_CFG_FILE = @DOXYGEN_PLANTUML_CFG_FILE@ +PLANTUML_INCLUDE_PATH = @DOXYGEN_PLANTUML_INCLUDE_PATH@ +DOT_GRAPH_MAX_NODES = @DOXYGEN_DOT_GRAPH_MAX_NODES@ +MAX_DOT_GRAPH_DEPTH = @DOXYGEN_MAX_DOT_GRAPH_DEPTH@ +DOT_TRANSPARENT = @DOXYGEN_DOT_TRANSPARENT@ +DOT_MULTI_TARGETS = @DOXYGEN_DOT_MULTI_TARGETS@ +GENERATE_LEGEND = @DOXYGEN_GENERATE_LEGEND@ +DOT_CLEANUP = @DOXYGEN_DOT_CLEANUP@ diff --git a/CMakeDoxygenDefaults.cmake b/CMakeDoxygenDefaults.cmake new file mode 100644 index 000000000..506b3b4a0 --- /dev/null +++ b/CMakeDoxygenDefaults.cmake @@ -0,0 +1,654 @@ +# +# DO NOT EDIT! THIS FILE WAS GENERATED BY CMAKE! +# + +if(NOT DEFINED DOXYGEN_DOXYFILE_ENCODING) + set(DOXYGEN_DOXYFILE_ENCODING UTF-8) +endif() +if(NOT DEFINED DOXYGEN_PROJECT_NAME) + set(DOXYGEN_PROJECT_NAME "My Project") +endif() +if(NOT DEFINED DOXYGEN_CREATE_SUBDIRS) + set(DOXYGEN_CREATE_SUBDIRS NO) +endif() +if(NOT DEFINED DOXYGEN_ALLOW_UNICODE_NAMES) + set(DOXYGEN_ALLOW_UNICODE_NAMES NO) +endif() +if(NOT DEFINED DOXYGEN_OUTPUT_LANGUAGE) + set(DOXYGEN_OUTPUT_LANGUAGE English) +endif() +if(NOT DEFINED DOXYGEN_BRIEF_MEMBER_DESC) + set(DOXYGEN_BRIEF_MEMBER_DESC YES) +endif() +if(NOT DEFINED DOXYGEN_REPEAT_BRIEF) + set(DOXYGEN_REPEAT_BRIEF YES) +endif() +if(NOT DEFINED DOXYGEN_ABBREVIATE_BRIEF) + set(DOXYGEN_ABBREVIATE_BRIEF "The $name class" + "The $name widget" + "The $name file" + is + provides + specifies + contains + represents + a + an + the) +endif() +if(NOT DEFINED DOXYGEN_ALWAYS_DETAILED_SEC) + set(DOXYGEN_ALWAYS_DETAILED_SEC NO) +endif() +if(NOT DEFINED DOXYGEN_INLINE_INHERITED_MEMB) + set(DOXYGEN_INLINE_INHERITED_MEMB NO) +endif() +if(NOT DEFINED DOXYGEN_FULL_PATH_NAMES) + set(DOXYGEN_FULL_PATH_NAMES YES) +endif() +if(NOT DEFINED DOXYGEN_SHORT_NAMES) + set(DOXYGEN_SHORT_NAMES NO) +endif() +if(NOT DEFINED DOXYGEN_JAVADOC_AUTOBRIEF) + set(DOXYGEN_JAVADOC_AUTOBRIEF NO) +endif() +if(NOT DEFINED DOXYGEN_QT_AUTOBRIEF) + set(DOXYGEN_QT_AUTOBRIEF NO) +endif() +if(NOT DEFINED DOXYGEN_MULTILINE_CPP_IS_BRIEF) + set(DOXYGEN_MULTILINE_CPP_IS_BRIEF NO) +endif() +if(NOT DEFINED DOXYGEN_INHERIT_DOCS) + set(DOXYGEN_INHERIT_DOCS YES) +endif() +if(NOT DEFINED DOXYGEN_SEPARATE_MEMBER_PAGES) + set(DOXYGEN_SEPARATE_MEMBER_PAGES NO) +endif() +if(NOT DEFINED DOXYGEN_TAB_SIZE) + set(DOXYGEN_TAB_SIZE 4) +endif() +if(NOT DEFINED DOXYGEN_OPTIMIZE_OUTPUT_FOR_C) + set(DOXYGEN_OPTIMIZE_OUTPUT_FOR_C NO) +endif() +if(NOT DEFINED DOXYGEN_OPTIMIZE_OUTPUT_JAVA) + set(DOXYGEN_OPTIMIZE_OUTPUT_JAVA NO) +endif() +if(NOT DEFINED DOXYGEN_OPTIMIZE_FOR_FORTRAN) + set(DOXYGEN_OPTIMIZE_FOR_FORTRAN NO) +endif() +if(NOT DEFINED DOXYGEN_OPTIMIZE_OUTPUT_VHDL) + set(DOXYGEN_OPTIMIZE_OUTPUT_VHDL NO) +endif() +if(NOT DEFINED DOXYGEN_MARKDOWN_SUPPORT) + set(DOXYGEN_MARKDOWN_SUPPORT YES) +endif() +if(NOT DEFINED DOXYGEN_TOC_INCLUDE_HEADINGS) + set(DOXYGEN_TOC_INCLUDE_HEADINGS 0) +endif() +if(NOT DEFINED DOXYGEN_AUTOLINK_SUPPORT) + set(DOXYGEN_AUTOLINK_SUPPORT YES) +endif() +if(NOT DEFINED DOXYGEN_BUILTIN_STL_SUPPORT) + set(DOXYGEN_BUILTIN_STL_SUPPORT NO) +endif() +if(NOT DEFINED DOXYGEN_CPP_CLI_SUPPORT) + set(DOXYGEN_CPP_CLI_SUPPORT NO) +endif() +if(NOT DEFINED DOXYGEN_SIP_SUPPORT) + set(DOXYGEN_SIP_SUPPORT NO) +endif() +if(NOT DEFINED DOXYGEN_IDL_PROPERTY_SUPPORT) + set(DOXYGEN_IDL_PROPERTY_SUPPORT YES) +endif() +if(NOT DEFINED DOXYGEN_DISTRIBUTE_GROUP_DOC) + set(DOXYGEN_DISTRIBUTE_GROUP_DOC NO) +endif() +if(NOT DEFINED DOXYGEN_GROUP_NESTED_COMPOUNDS) + set(DOXYGEN_GROUP_NESTED_COMPOUNDS NO) +endif() +if(NOT DEFINED DOXYGEN_SUBGROUPING) + set(DOXYGEN_SUBGROUPING YES) +endif() +if(NOT DEFINED DOXYGEN_INLINE_GROUPED_CLASSES) + set(DOXYGEN_INLINE_GROUPED_CLASSES NO) +endif() +if(NOT DEFINED DOXYGEN_INLINE_SIMPLE_STRUCTS) + set(DOXYGEN_INLINE_SIMPLE_STRUCTS NO) +endif() +if(NOT DEFINED DOXYGEN_TYPEDEF_HIDES_STRUCT) + set(DOXYGEN_TYPEDEF_HIDES_STRUCT NO) +endif() +if(NOT DEFINED DOXYGEN_LOOKUP_CACHE_SIZE) + set(DOXYGEN_LOOKUP_CACHE_SIZE 0) +endif() +if(NOT DEFINED DOXYGEN_EXTRACT_ALL) + set(DOXYGEN_EXTRACT_ALL NO) +endif() +if(NOT DEFINED DOXYGEN_EXTRACT_PRIVATE) + set(DOXYGEN_EXTRACT_PRIVATE NO) +endif() +if(NOT DEFINED DOXYGEN_EXTRACT_PACKAGE) + set(DOXYGEN_EXTRACT_PACKAGE NO) +endif() +if(NOT DEFINED DOXYGEN_EXTRACT_STATIC) + set(DOXYGEN_EXTRACT_STATIC NO) +endif() +if(NOT DEFINED DOXYGEN_EXTRACT_LOCAL_CLASSES) + set(DOXYGEN_EXTRACT_LOCAL_CLASSES YES) +endif() +if(NOT DEFINED DOXYGEN_EXTRACT_LOCAL_METHODS) + set(DOXYGEN_EXTRACT_LOCAL_METHODS NO) +endif() +if(NOT DEFINED DOXYGEN_EXTRACT_ANON_NSPACES) + set(DOXYGEN_EXTRACT_ANON_NSPACES NO) +endif() +if(NOT DEFINED DOXYGEN_HIDE_UNDOC_MEMBERS) + set(DOXYGEN_HIDE_UNDOC_MEMBERS NO) +endif() +if(NOT DEFINED DOXYGEN_HIDE_UNDOC_CLASSES) + set(DOXYGEN_HIDE_UNDOC_CLASSES NO) +endif() +if(NOT DEFINED DOXYGEN_HIDE_FRIEND_COMPOUNDS) + set(DOXYGEN_HIDE_FRIEND_COMPOUNDS NO) +endif() +if(NOT DEFINED DOXYGEN_HIDE_IN_BODY_DOCS) + set(DOXYGEN_HIDE_IN_BODY_DOCS NO) +endif() +if(NOT DEFINED DOXYGEN_INTERNAL_DOCS) + set(DOXYGEN_INTERNAL_DOCS NO) +endif() +if(NOT DEFINED DOXYGEN_CASE_SENSE_NAMES) + set(DOXYGEN_CASE_SENSE_NAMES YES) +endif() +if(NOT DEFINED DOXYGEN_HIDE_SCOPE_NAMES) + set(DOXYGEN_HIDE_SCOPE_NAMES NO) +endif() +if(NOT DEFINED DOXYGEN_HIDE_COMPOUND_REFERENCE) + set(DOXYGEN_HIDE_COMPOUND_REFERENCE NO) +endif() +if(NOT DEFINED DOXYGEN_SHOW_INCLUDE_FILES) + set(DOXYGEN_SHOW_INCLUDE_FILES YES) +endif() +if(NOT DEFINED DOXYGEN_SHOW_GROUPED_MEMB_INC) + set(DOXYGEN_SHOW_GROUPED_MEMB_INC NO) +endif() +if(NOT DEFINED DOXYGEN_FORCE_LOCAL_INCLUDES) + set(DOXYGEN_FORCE_LOCAL_INCLUDES NO) +endif() +if(NOT DEFINED DOXYGEN_INLINE_INFO) + set(DOXYGEN_INLINE_INFO YES) +endif() +if(NOT DEFINED DOXYGEN_SORT_MEMBER_DOCS) + set(DOXYGEN_SORT_MEMBER_DOCS YES) +endif() +if(NOT DEFINED DOXYGEN_SORT_BRIEF_DOCS) + set(DOXYGEN_SORT_BRIEF_DOCS NO) +endif() +if(NOT DEFINED DOXYGEN_SORT_MEMBERS_CTORS_1ST) + set(DOXYGEN_SORT_MEMBERS_CTORS_1ST NO) +endif() +if(NOT DEFINED DOXYGEN_SORT_GROUP_NAMES) + set(DOXYGEN_SORT_GROUP_NAMES NO) +endif() +if(NOT DEFINED DOXYGEN_SORT_BY_SCOPE_NAME) + set(DOXYGEN_SORT_BY_SCOPE_NAME NO) +endif() +if(NOT DEFINED DOXYGEN_STRICT_PROTO_MATCHING) + set(DOXYGEN_STRICT_PROTO_MATCHING NO) +endif() +if(NOT DEFINED DOXYGEN_GENERATE_TODOLIST) + set(DOXYGEN_GENERATE_TODOLIST YES) +endif() +if(NOT DEFINED DOXYGEN_GENERATE_TESTLIST) + set(DOXYGEN_GENERATE_TESTLIST YES) +endif() +if(NOT DEFINED DOXYGEN_GENERATE_BUGLIST) + set(DOXYGEN_GENERATE_BUGLIST YES) +endif() +if(NOT DEFINED DOXYGEN_GENERATE_DEPRECATEDLIST) + set(DOXYGEN_GENERATE_DEPRECATEDLIST YES) +endif() +if(NOT DEFINED DOXYGEN_MAX_INITIALIZER_LINES) + set(DOXYGEN_MAX_INITIALIZER_LINES 30) +endif() +if(NOT DEFINED DOXYGEN_SHOW_USED_FILES) + set(DOXYGEN_SHOW_USED_FILES YES) +endif() +if(NOT DEFINED DOXYGEN_SHOW_FILES) + set(DOXYGEN_SHOW_FILES YES) +endif() +if(NOT DEFINED DOXYGEN_SHOW_NAMESPACES) + set(DOXYGEN_SHOW_NAMESPACES YES) +endif() +if(NOT DEFINED DOXYGEN_QUIET) + set(DOXYGEN_QUIET NO) +endif() +if(NOT DEFINED DOXYGEN_WARNINGS) + set(DOXYGEN_WARNINGS YES) +endif() +if(NOT DEFINED DOXYGEN_WARN_IF_UNDOCUMENTED) + set(DOXYGEN_WARN_IF_UNDOCUMENTED YES) +endif() +if(NOT DEFINED DOXYGEN_WARN_IF_DOC_ERROR) + set(DOXYGEN_WARN_IF_DOC_ERROR YES) +endif() +if(NOT DEFINED DOXYGEN_WARN_NO_PARAMDOC) + set(DOXYGEN_WARN_NO_PARAMDOC NO) +endif() +if(NOT DEFINED DOXYGEN_WARN_AS_ERROR) + set(DOXYGEN_WARN_AS_ERROR NO) +endif() +if(NOT DEFINED DOXYGEN_WARN_FORMAT) + set(DOXYGEN_WARN_FORMAT "$file:$line: $text") +endif() +if(NOT DEFINED DOXYGEN_INPUT_ENCODING) + set(DOXYGEN_INPUT_ENCODING UTF-8) +endif() +if(NOT DEFINED DOXYGEN_FILE_PATTERNS) + set(DOXYGEN_FILE_PATTERNS *.c + *.cc + *.cxx + *.cpp + *.c++ + *.java + *.ii + *.ixx + *.ipp + *.i++ + *.inl + *.idl + *.ddl + *.odl + *.h + *.hh + *.hxx + *.hpp + *.h++ + *.cs + *.d + *.php + *.php4 + *.php5 + *.phtml + *.inc + *.m + *.markdown + *.md + *.mm + *.dox + *.py + *.pyw + *.f90 + *.f95 + *.f03 + *.f08 + *.f + *.for + *.tcl + *.vhd + *.vhdl + *.ucf + *.qsf) +endif() +if(NOT DEFINED DOXYGEN_RECURSIVE) + set(DOXYGEN_RECURSIVE NO) +endif() +if(NOT DEFINED DOXYGEN_EXCLUDE_SYMLINKS) + set(DOXYGEN_EXCLUDE_SYMLINKS NO) +endif() +if(NOT DEFINED DOXYGEN_EXAMPLE_PATTERNS) + set(DOXYGEN_EXAMPLE_PATTERNS *) +endif() +if(NOT DEFINED DOXYGEN_EXAMPLE_RECURSIVE) + set(DOXYGEN_EXAMPLE_RECURSIVE NO) +endif() +if(NOT DEFINED DOXYGEN_FILTER_SOURCE_FILES) + set(DOXYGEN_FILTER_SOURCE_FILES NO) +endif() +if(NOT DEFINED DOXYGEN_SOURCE_BROWSER) + set(DOXYGEN_SOURCE_BROWSER NO) +endif() +if(NOT DEFINED DOXYGEN_INLINE_SOURCES) + set(DOXYGEN_INLINE_SOURCES NO) +endif() +if(NOT DEFINED DOXYGEN_STRIP_CODE_COMMENTS) + set(DOXYGEN_STRIP_CODE_COMMENTS YES) +endif() +if(NOT DEFINED DOXYGEN_REFERENCED_BY_RELATION) + set(DOXYGEN_REFERENCED_BY_RELATION NO) +endif() +if(NOT DEFINED DOXYGEN_REFERENCES_RELATION) + set(DOXYGEN_REFERENCES_RELATION NO) +endif() +if(NOT DEFINED DOXYGEN_REFERENCES_LINK_SOURCE) + set(DOXYGEN_REFERENCES_LINK_SOURCE YES) +endif() +if(NOT DEFINED DOXYGEN_SOURCE_TOOLTIPS) + set(DOXYGEN_SOURCE_TOOLTIPS YES) +endif() +if(NOT DEFINED DOXYGEN_USE_HTAGS) + set(DOXYGEN_USE_HTAGS NO) +endif() +if(NOT DEFINED DOXYGEN_VERBATIM_HEADERS) + set(DOXYGEN_VERBATIM_HEADERS YES) +endif() +if(NOT DEFINED DOXYGEN_CLANG_ASSISTED_PARSING) + set(DOXYGEN_CLANG_ASSISTED_PARSING NO) +endif() +if(NOT DEFINED DOXYGEN_ALPHABETICAL_INDEX) + set(DOXYGEN_ALPHABETICAL_INDEX YES) +endif() +if(NOT DEFINED DOXYGEN_COLS_IN_ALPHA_INDEX) + set(DOXYGEN_COLS_IN_ALPHA_INDEX 5) +endif() +if(NOT DEFINED DOXYGEN_GENERATE_HTML) + set(DOXYGEN_GENERATE_HTML YES) +endif() +if(NOT DEFINED DOXYGEN_HTML_OUTPUT) + set(DOXYGEN_HTML_OUTPUT html) +endif() +if(NOT DEFINED DOXYGEN_HTML_FILE_EXTENSION) + set(DOXYGEN_HTML_FILE_EXTENSION .html) +endif() +if(NOT DEFINED DOXYGEN_HTML_COLORSTYLE_HUE) + set(DOXYGEN_HTML_COLORSTYLE_HUE 220) +endif() +if(NOT DEFINED DOXYGEN_HTML_COLORSTYLE_SAT) + set(DOXYGEN_HTML_COLORSTYLE_SAT 100) +endif() +if(NOT DEFINED DOXYGEN_HTML_COLORSTYLE_GAMMA) + set(DOXYGEN_HTML_COLORSTYLE_GAMMA 80) +endif() +if(NOT DEFINED DOXYGEN_HTML_TIMESTAMP) + set(DOXYGEN_HTML_TIMESTAMP NO) +endif() +if(NOT DEFINED DOXYGEN_HTML_DYNAMIC_SECTIONS) + set(DOXYGEN_HTML_DYNAMIC_SECTIONS NO) +endif() +if(NOT DEFINED DOXYGEN_HTML_INDEX_NUM_ENTRIES) + set(DOXYGEN_HTML_INDEX_NUM_ENTRIES 100) +endif() +if(NOT DEFINED DOXYGEN_GENERATE_DOCSET) + set(DOXYGEN_GENERATE_DOCSET NO) +endif() +if(NOT DEFINED DOXYGEN_DOCSET_FEEDNAME) + set(DOXYGEN_DOCSET_FEEDNAME "Doxygen generated docs") +endif() +if(NOT DEFINED DOXYGEN_DOCSET_BUNDLE_ID) + set(DOXYGEN_DOCSET_BUNDLE_ID org.doxygen.Project) +endif() +if(NOT DEFINED DOXYGEN_DOCSET_PUBLISHER_ID) + set(DOXYGEN_DOCSET_PUBLISHER_ID org.doxygen.Publisher) +endif() +if(NOT DEFINED DOXYGEN_DOCSET_PUBLISHER_NAME) + set(DOXYGEN_DOCSET_PUBLISHER_NAME Publisher) +endif() +if(NOT DEFINED DOXYGEN_GENERATE_HTMLHELP) + set(DOXYGEN_GENERATE_HTMLHELP NO) +endif() +if(NOT DEFINED DOXYGEN_GENERATE_CHI) + set(DOXYGEN_GENERATE_CHI NO) +endif() +if(NOT DEFINED DOXYGEN_BINARY_TOC) + set(DOXYGEN_BINARY_TOC NO) +endif() +if(NOT DEFINED DOXYGEN_TOC_EXPAND) + set(DOXYGEN_TOC_EXPAND NO) +endif() +if(NOT DEFINED DOXYGEN_GENERATE_QHP) + set(DOXYGEN_GENERATE_QHP NO) +endif() +if(NOT DEFINED DOXYGEN_QHP_NAMESPACE) + set(DOXYGEN_QHP_NAMESPACE org.doxygen.Project) +endif() +if(NOT DEFINED DOXYGEN_QHP_VIRTUAL_FOLDER) + set(DOXYGEN_QHP_VIRTUAL_FOLDER doc) +endif() +if(NOT DEFINED DOXYGEN_GENERATE_ECLIPSEHELP) + set(DOXYGEN_GENERATE_ECLIPSEHELP NO) +endif() +if(NOT DEFINED DOXYGEN_ECLIPSE_DOC_ID) + set(DOXYGEN_ECLIPSE_DOC_ID org.doxygen.Project) +endif() +if(NOT DEFINED DOXYGEN_DISABLE_INDEX) + set(DOXYGEN_DISABLE_INDEX NO) +endif() +if(NOT DEFINED DOXYGEN_GENERATE_TREEVIEW) + set(DOXYGEN_GENERATE_TREEVIEW NO) +endif() +if(NOT DEFINED DOXYGEN_ENUM_VALUES_PER_LINE) + set(DOXYGEN_ENUM_VALUES_PER_LINE 4) +endif() +if(NOT DEFINED DOXYGEN_TREEVIEW_WIDTH) + set(DOXYGEN_TREEVIEW_WIDTH 250) +endif() +if(NOT DEFINED DOXYGEN_EXT_LINKS_IN_WINDOW) + set(DOXYGEN_EXT_LINKS_IN_WINDOW NO) +endif() +if(NOT DEFINED DOXYGEN_FORMULA_FONTSIZE) + set(DOXYGEN_FORMULA_FONTSIZE 10) +endif() +if(NOT DEFINED DOXYGEN_FORMULA_TRANSPARENT) + set(DOXYGEN_FORMULA_TRANSPARENT YES) +endif() +if(NOT DEFINED DOXYGEN_USE_MATHJAX) + set(DOXYGEN_USE_MATHJAX NO) +endif() +if(NOT DEFINED DOXYGEN_MATHJAX_FORMAT) + set(DOXYGEN_MATHJAX_FORMAT HTML-CSS) +endif() +if(NOT DEFINED DOXYGEN_MATHJAX_RELPATH) + set(DOXYGEN_MATHJAX_RELPATH http://cdn.mathjax.org/mathjax/latest) +endif() +if(NOT DEFINED DOXYGEN_SEARCHENGINE) + set(DOXYGEN_SEARCHENGINE YES) +endif() +if(NOT DEFINED DOXYGEN_SERVER_BASED_SEARCH) + set(DOXYGEN_SERVER_BASED_SEARCH NO) +endif() +if(NOT DEFINED DOXYGEN_EXTERNAL_SEARCH) + set(DOXYGEN_EXTERNAL_SEARCH NO) +endif() +if(NOT DEFINED DOXYGEN_SEARCHDATA_FILE) + set(DOXYGEN_SEARCHDATA_FILE searchdata.xml) +endif() +if(NOT DEFINED DOXYGEN_GENERATE_LATEX) + set(DOXYGEN_GENERATE_LATEX YES) +endif() +if(NOT DEFINED DOXYGEN_LATEX_OUTPUT) + set(DOXYGEN_LATEX_OUTPUT latex) +endif() +if(NOT DEFINED DOXYGEN_LATEX_CMD_NAME) + set(DOXYGEN_LATEX_CMD_NAME latex) +endif() +if(NOT DEFINED DOXYGEN_MAKEINDEX_CMD_NAME) + set(DOXYGEN_MAKEINDEX_CMD_NAME makeindex) +endif() +if(NOT DEFINED DOXYGEN_COMPACT_LATEX) + set(DOXYGEN_COMPACT_LATEX NO) +endif() +if(NOT DEFINED DOXYGEN_PAPER_TYPE) + set(DOXYGEN_PAPER_TYPE a4) +endif() +if(NOT DEFINED DOXYGEN_PDF_HYPERLINKS) + set(DOXYGEN_PDF_HYPERLINKS YES) +endif() +if(NOT DEFINED DOXYGEN_USE_PDFLATEX) + set(DOXYGEN_USE_PDFLATEX YES) +endif() +if(NOT DEFINED DOXYGEN_LATEX_BATCHMODE) + set(DOXYGEN_LATEX_BATCHMODE NO) +endif() +if(NOT DEFINED DOXYGEN_LATEX_HIDE_INDICES) + set(DOXYGEN_LATEX_HIDE_INDICES NO) +endif() +if(NOT DEFINED DOXYGEN_LATEX_SOURCE_CODE) + set(DOXYGEN_LATEX_SOURCE_CODE NO) +endif() +if(NOT DEFINED DOXYGEN_LATEX_BIB_STYLE) + set(DOXYGEN_LATEX_BIB_STYLE plain) +endif() +if(NOT DEFINED DOXYGEN_LATEX_TIMESTAMP) + set(DOXYGEN_LATEX_TIMESTAMP NO) +endif() +if(NOT DEFINED DOXYGEN_GENERATE_RTF) + set(DOXYGEN_GENERATE_RTF NO) +endif() +if(NOT DEFINED DOXYGEN_RTF_OUTPUT) + set(DOXYGEN_RTF_OUTPUT rtf) +endif() +if(NOT DEFINED DOXYGEN_COMPACT_RTF) + set(DOXYGEN_COMPACT_RTF NO) +endif() +if(NOT DEFINED DOXYGEN_RTF_HYPERLINKS) + set(DOXYGEN_RTF_HYPERLINKS NO) +endif() +if(NOT DEFINED DOXYGEN_RTF_SOURCE_CODE) + set(DOXYGEN_RTF_SOURCE_CODE NO) +endif() +if(NOT DEFINED DOXYGEN_GENERATE_MAN) + set(DOXYGEN_GENERATE_MAN NO) +endif() +if(NOT DEFINED DOXYGEN_MAN_OUTPUT) + set(DOXYGEN_MAN_OUTPUT man) +endif() +if(NOT DEFINED DOXYGEN_MAN_EXTENSION) + set(DOXYGEN_MAN_EXTENSION .3) +endif() +if(NOT DEFINED DOXYGEN_MAN_LINKS) + set(DOXYGEN_MAN_LINKS NO) +endif() +if(NOT DEFINED DOXYGEN_GENERATE_XML) + set(DOXYGEN_GENERATE_XML NO) +endif() +if(NOT DEFINED DOXYGEN_XML_OUTPUT) + set(DOXYGEN_XML_OUTPUT xml) +endif() +if(NOT DEFINED DOXYGEN_XML_PROGRAMLISTING) + set(DOXYGEN_XML_PROGRAMLISTING YES) +endif() +if(NOT DEFINED DOXYGEN_GENERATE_DOCBOOK) + set(DOXYGEN_GENERATE_DOCBOOK NO) +endif() +if(NOT DEFINED DOXYGEN_DOCBOOK_OUTPUT) + set(DOXYGEN_DOCBOOK_OUTPUT docbook) +endif() +if(NOT DEFINED DOXYGEN_DOCBOOK_PROGRAMLISTING) + set(DOXYGEN_DOCBOOK_PROGRAMLISTING NO) +endif() +if(NOT DEFINED DOXYGEN_GENERATE_AUTOGEN_DEF) + set(DOXYGEN_GENERATE_AUTOGEN_DEF NO) +endif() +if(NOT DEFINED DOXYGEN_GENERATE_PERLMOD) + set(DOXYGEN_GENERATE_PERLMOD NO) +endif() +if(NOT DEFINED DOXYGEN_PERLMOD_LATEX) + set(DOXYGEN_PERLMOD_LATEX NO) +endif() +if(NOT DEFINED DOXYGEN_PERLMOD_PRETTY) + set(DOXYGEN_PERLMOD_PRETTY YES) +endif() +if(NOT DEFINED DOXYGEN_ENABLE_PREPROCESSING) + set(DOXYGEN_ENABLE_PREPROCESSING YES) +endif() +if(NOT DEFINED DOXYGEN_MACRO_EXPANSION) + set(DOXYGEN_MACRO_EXPANSION NO) +endif() +if(NOT DEFINED DOXYGEN_EXPAND_ONLY_PREDEF) + set(DOXYGEN_EXPAND_ONLY_PREDEF NO) +endif() +if(NOT DEFINED DOXYGEN_SEARCH_INCLUDES) + set(DOXYGEN_SEARCH_INCLUDES YES) +endif() +if(NOT DEFINED DOXYGEN_SKIP_FUNCTION_MACROS) + set(DOXYGEN_SKIP_FUNCTION_MACROS YES) +endif() +if(NOT DEFINED DOXYGEN_ALLEXTERNALS) + set(DOXYGEN_ALLEXTERNALS NO) +endif() +if(NOT DEFINED DOXYGEN_EXTERNAL_GROUPS) + set(DOXYGEN_EXTERNAL_GROUPS YES) +endif() +if(NOT DEFINED DOXYGEN_EXTERNAL_PAGES) + set(DOXYGEN_EXTERNAL_PAGES YES) +endif() +if(NOT DEFINED DOXYGEN_PERL_PATH) + set(DOXYGEN_PERL_PATH /usr/bin/perl) +endif() +if(NOT DEFINED DOXYGEN_CLASS_DIAGRAMS) + set(DOXYGEN_CLASS_DIAGRAMS YES) +endif() +if(NOT DEFINED DOXYGEN_HIDE_UNDOC_RELATIONS) + set(DOXYGEN_HIDE_UNDOC_RELATIONS YES) +endif() +if(NOT DEFINED DOXYGEN_HAVE_DOT) + set(DOXYGEN_HAVE_DOT YES) +endif() +if(NOT DEFINED DOXYGEN_DOT_NUM_THREADS) + set(DOXYGEN_DOT_NUM_THREADS 0) +endif() +if(NOT DEFINED DOXYGEN_DOT_FONTNAME) + set(DOXYGEN_DOT_FONTNAME Helvetica) +endif() +if(NOT DEFINED DOXYGEN_DOT_FONTSIZE) + set(DOXYGEN_DOT_FONTSIZE 10) +endif() +if(NOT DEFINED DOXYGEN_CLASS_GRAPH) + set(DOXYGEN_CLASS_GRAPH YES) +endif() +if(NOT DEFINED DOXYGEN_COLLABORATION_GRAPH) + set(DOXYGEN_COLLABORATION_GRAPH YES) +endif() +if(NOT DEFINED DOXYGEN_GROUP_GRAPHS) + set(DOXYGEN_GROUP_GRAPHS YES) +endif() +if(NOT DEFINED DOXYGEN_UML_LOOK) + set(DOXYGEN_UML_LOOK NO) +endif() +if(NOT DEFINED DOXYGEN_UML_LIMIT_NUM_FIELDS) + set(DOXYGEN_UML_LIMIT_NUM_FIELDS 10) +endif() +if(NOT DEFINED DOXYGEN_TEMPLATE_RELATIONS) + set(DOXYGEN_TEMPLATE_RELATIONS NO) +endif() +if(NOT DEFINED DOXYGEN_INCLUDE_GRAPH) + set(DOXYGEN_INCLUDE_GRAPH YES) +endif() +if(NOT DEFINED DOXYGEN_INCLUDED_BY_GRAPH) + set(DOXYGEN_INCLUDED_BY_GRAPH YES) +endif() +if(NOT DEFINED DOXYGEN_CALL_GRAPH) + set(DOXYGEN_CALL_GRAPH NO) +endif() +if(NOT DEFINED DOXYGEN_CALLER_GRAPH) + set(DOXYGEN_CALLER_GRAPH NO) +endif() +if(NOT DEFINED DOXYGEN_GRAPHICAL_HIERARCHY) + set(DOXYGEN_GRAPHICAL_HIERARCHY YES) +endif() +if(NOT DEFINED DOXYGEN_DIRECTORY_GRAPH) + set(DOXYGEN_DIRECTORY_GRAPH YES) +endif() +if(NOT DEFINED DOXYGEN_DOT_IMAGE_FORMAT) + set(DOXYGEN_DOT_IMAGE_FORMAT png) +endif() +if(NOT DEFINED DOXYGEN_INTERACTIVE_SVG) + set(DOXYGEN_INTERACTIVE_SVG NO) +endif() +if(NOT DEFINED DOXYGEN_DOT_GRAPH_MAX_NODES) + set(DOXYGEN_DOT_GRAPH_MAX_NODES 50) +endif() +if(NOT DEFINED DOXYGEN_MAX_DOT_GRAPH_DEPTH) + set(DOXYGEN_MAX_DOT_GRAPH_DEPTH 0) +endif() +if(NOT DEFINED DOXYGEN_DOT_TRANSPARENT) + set(DOXYGEN_DOT_TRANSPARENT NO) +endif() +if(NOT DEFINED DOXYGEN_DOT_MULTI_TARGETS) + set(DOXYGEN_DOT_MULTI_TARGETS NO) +endif() +if(NOT DEFINED DOXYGEN_GENERATE_LEGEND) + set(DOXYGEN_GENERATE_LEGEND YES) +endif() +if(NOT DEFINED DOXYGEN_DOT_CLEANUP) + set(DOXYGEN_DOT_CLEANUP YES) +endif() diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 index 726243473..ab877c7df --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,25 +1,24 @@ + # value of 3.4.0 or lower. +cmake_minimum_required(VERSION 3.4) # Sets the version of CMake required to build the native # library. You should either keep the default value or pass a # value of 3.4.0 or lower. include(CMakeToolsHelpers OPTIONAL) -project( YAP ) +include(FeatureSummary) +include(GNUInstallDirs) -if (ANDROID) - set(YAP_APP_DIR "${CMAKE_SOURCE_DIR}/../..") - cmake_policy(VERSION 3.4) +project(YAP) -else () -cmake_minimum_required(VERSION 2.8) -endif() +set(YAP_APP_DIR "${CMAKE_SOURCE_DIR}/../yaplib") +cmake_policy(VERSION 3.4) -set( - CMAKE_MODULE_PATH - "${CMAKE_SOURCE_DIR}" - "${CMAKE_SOURCE_DIR}/cmake" - ) +set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/cmake") + +set(ANACONDA $ENV{CONDA_BUILD} CACHE BOOL "Anaconda Environment") +#message(STATUS "ANACONDA found: ${ANACONDA}") include(CheckIncludeFiles) include(CheckLibraryExists) @@ -28,9 +27,19 @@ include(CheckTypeSize) include(CMakeDependentOption) include(MacroOptionalAddSubdirectory) include(MacroOptionalFindPackage) -include(MacroLogFeature) +include(FeatureSummary) include(FindPackageHandleStandardArgs) -include (GNUInstallDirs) + +# Optional Components +# +include(CheckIncludeFileCXX) +include(CheckFunctionExists) +include(CheckFunctionExists) +include(CheckPrototypeExists) +include(CheckVariableExists) +include(CheckCXXSourceCompiles) +include(TestBigEndian) +include(GetGitRevisionDescription) # Creates and names a library, sets it as either STATIC # or SHARED, and provides the relative paths to its source code.z @@ -40,113 +49,977 @@ include (GNUInstallDirs) #cross-compilation support # Search packages for host system instead of packages for target system # in case of cross compilation define these macro by toolchain file -if(NOT COMMAND find_host_package) - macro(find_host_package) - find_package(${ARGN}) - endmacro() -endif() -if(NOT COMMAND find_host_program) - macro(find_host_program) - find_program(${ARGN}) - endmacro() -endif() +if (NOT COMMAND find_host_package) + macro(find_host_package) + find_package(${ARGN}) + endmacro() +endif () +if (NOT COMMAND find_host_program) + macro(find_host_program) + find_program(${ARGN}) + endmacro() +endif () +if (POLICY CMP0003) + cmake_policy(SET CMP0003 NEW) +endif () +if (POLICY CMP0068) + cmake_policy(SET CMP0068 NEW) +endif () + +## options: compilation flags option(BUILD_SHARED_LIBS "Build shared library" ON) -set (CMAKE_POSITION_INDEPENDENT_CODE TRUE) -set (CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) +CMAKE_DEPENDENT_OPTION(WITH_SYSTEM_MMAP "Use MMAP for shared memory allocation" ON "NOT WITH_YAPOR_THOR" OFF) +CMAKE_DEPENDENT_OPTION(WITH_SYSTEM_SHM "Use SHM for shared memory allocation" ON "NOT WITH_YAPOR_THOR; NOT WITH_SYSTEM_MMAP" OFF) +OPTION(WITH_CALL_TRACER "support for procedure-call tracing" ${DEBUG}) +option(WITH_YAP_DLL "compile YAP as a DLL" ON) +option(WITH_YAP_STATIC "compile YAP statically" OFF) +option(WITH_YAP_CONDOR "allow YAP to be used from condor" OFF) +option(WITH_YAP_DLL "compile YAP as a DLL" ON) +if (WITH_YAP_CONDOR) + set(WITH_YAP_STATIC ON) + set(WITH_YAP_DLL OFF) +endif () -include(Prelims NO_POLICY_SCOPE) +## options: libraries +option(WITH_THREADED_CODE "threaded code" ON) +option(WITH_MPI "Interface to OpenMPI/MPICH" ON) +option(WITH_READLINE "use readline or libedit" ON) +option(WITH_JIT "just in Time Clause Compilation" OFF) -include(Sources NO_POLICY_SCOPE) +if (APPLE) + option(WITH_BREW "brew" ON) + if (not WITH_BREW) + option(WITH_MACPORTS "mac-ports" ON) + endif() +endif() -include(Model NO_POLICY_SCOPE) +option (WITH_EXTENSIONS "packages and libraries that add value to YAP" ON) -include_directories ( utf8proc packages/myddas packages/myddas/sqlite3/src) +OPTION(WITH_MYDDAS " Enable MYDDAS driver" ${WITH_EXTENSIONS}) +OPTION(WITH_SQLITE3 " Enable MYDDAS SQLITE3 driver" ${WITH_MYDDAS}) +OPTION(WITH_MYSQL " Enable MYDDAS MYSQL driver" ${WITH_MYDDAS}) +OPTION(WITH_ODBC " Enable MYDDAS ODBC driver" ${WITH_MYDDAS}) +OPTION(WITH_POSTGRES " Enable MYDDAS POSTGRES driver" ${WITH_MYDDAS}) +OPTION(WITH_SQLITE3 " Enable MYDDAS SQLITE3 driver" ${WITH_MYDDAS}) +OPTION(WITH_SWIG " Enable SWIG interfaces to foreign languages" ${WITH_EXTENSIONS}) +OPTION(WITH_RAPTOR " Enable the RAPTOR RDF library" ${WITH_EXTENSIONS}) +OPTION(WITH_XML2 " Enable the RAPTOR XML2 library" ${WITH_EXTENSIONS}) +OPTION(WITH_XML " Enable the Prolog XML library" ${WITH_EXTENSIONS}) +OPTION(WITH_CLPBN" Enable the CLPBN and PFL probabilistic languages" ${WITH_EXTENSIONS}) +OPTION(WITH_HORUS " Enable the HORUS inference libraray for CLPBN and PFL" ${WITH_CLPBN}) +option(WITH_PROBLOG "include Problog-I." ${WITH_EXTENSIONS}) +OPTION(WITH_CPLINT " Enable the cplint probabilistic language" ${WITH_EXTENSIONS}) +option(WITH_GECODE "interface gecode constraint solver" ${WITH_EXTENSIONS}) +option(WITH_LBFGS "interface with lbfgs" ${WITH_EXTENSIONS}) +option(WITH_PRISM "use PRISM system in YAP" ${WITH_EXTENSIONS}) +option(WITH_PYTHON "Allow Python->YAP and YAP->Python" ${WITH_EXTENSIONS}) +option(WITH_R "Use R Interface" ${WITH_EXTENSIONS}) +option(WITH_JAVA "Try to use Java (currently Java 6,7,8)" ${WITH_EXTENSIONS}) + +set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) + +#begining stuff for top CMakeLists + +include(MacroLogFeature) + +if (POLICY CMP0042) + cmake_policy(SET CMP0042 NEW) +endif () + +function(add_to_group list output) + set(tmp ${${output}}) + foreach (path ${${list}}) + get_source_file_property(path ${path} LOCATION) + list(APPEND tmp ${path}) + endforeach () + set(${output} ${tmp} CACHE INTERNAL "prolog library files") +endfunction(add_to_group list output) + +function(add_to_libgroup el list) + # add_custom_command( TARGET ${el} POST_BUILD + # COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_BINARY_DIR}/packages/python/swig/yap4py + # DEPENDS ${el} ) + list(APPEND ${list} ${${el}}) + set(${list} ${${list}} CACHE INTERNAL "prolog dll files") +endfunction(add_to_libgroup el list) + + +function(add_to_corelibgroup el list) + # add_custom_command( TARGET ${el} POST_BUILD + # COMMAND ${CMAKE_COMMAND} -E copy $ $ $ ${CMAKE_BINARY_DIR}/packages/python/swig/yap4py + # DEPENDS ${el} ) + list(APPEND ${list} ${${el}}) + set(${list} ${${list}} CACHE INTERNAL "prolog dll files") +endfunction(add_to_corelibgroup el list) + + +if (ANDROID_OLD) + macro(MY_add_custom_target) + endmacro() +else () + macro(MY_add_custom_target) + add_custom_target(${ARGN}) + endmacro() +endif () + +if (WIN32) + macro(add_component arg1) + add_library(${arg1} OBJECT ${ARGN}) + endmacro() +else () + macro(add_component arg1) + add_library(${arg1} OBJECT ${ARGN}) + endmacro() +endif () +macro(add_lib arg1) + add_library(${arg1} SHARED ${ARGN}) + add_to_libgroup(${arg1} YAP_DLLS) +endmacro() +macro(add_corelib arg1) + add_library(${arg1} SHARED ${ARGN}) + add_to_corelibgroup(${arg1} YAP_DLLS) +endmacro() + +if (ANDROID_OLD) + macro(MY_add_dependencies) + endmacro() +else () + macro(MY_add_dependencies) + add_dependencies(${ARGN}) + endmacro() +endif () + +if (ANDROID_OLD) + macro(MY_add_library) + endmacro() +else () + macro(MY_add_library) + add_library(${ARGN}) + endmacro() +endif () if (ANDROID) - include_directories ( - packages/myddas/sqlite3/src/Android/jni/sqlite - packages/myddas/sqlite3/src/Android/jni/sqlite/nativehelper - ) - endif (ANDROID) + macro(MY_add_subdirectory) + endmacro() +else () + macro(MY_add_subdirectory) + add_subdirectory(${ARGN}) + endmacro() +endif () - set_property( SOURCE ${LIBYAP_SOURCES} APPEND PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1) +if (ANDROID_OLD) + macro(MY_include) + endmacro() +else () + macro(MY_include) + include(${ARGN}) + endmacro() +endif () -add_definitions(-DUSE_MYDDAS=1 -DMYDDAS_SQLITE3=1) +if (ANDROID) + macro(MY_install) + endmacro() +else () + macro(MY_install) + install(${ARGN}) + endmacro() +endif () -if (MYSQL_FOUND) - add_definitions(= -DMYDDAS_MYSQL=1) - endif() +if (ANDROID_OLD) + macro(MY_set_target_properties) + endmacro() +else () + macro(MY_set_target_properties) + set_target_properties(${ARGN}) + endmacro() +endif () -if (ODBC_FOUND) - add_definitions(= -DMYDDAS_ODBC=1) - endif() - -if (MYSQL_POSTGRES) - add_definitions(= -DMYDDAS_POSTGRES=1) - endif() - if (MYSQL_POSTGRES) - set(SWIG_SOURCES packages/swig/python/yap_PYTHONwrapper.cxx ) - endif() +if (ANDROID_OLD) + macro(MY_target_link_libraries) + endmacro() +else () + macro(MY_target_link_libraries) + target_link_libraries(${ARGN}) + endmacro() +endif () - if (ANDROID) +# where we have most scripts +# set path to additional CMake modules - ADD_SUBDIRECTORY(os) - ADD_SUBDIRECTORY(OPTYap) - ADD_SUBDIRECTORY(packages/myddas) - ADD_SUBDIRECTORY(utf8proc) - ADD_SUBDIRECTORY(CXX) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +include(disallow) -else() +disallow_intree_builds() - List (APPEND YLIBS $ ) - List (APPEND YLIBS $ ) - List (APPEND YLIBS $ ) - List (APPEND YLIBS $ ) - List (APPEND YLIBS $ ) - List (APPEND YLIBS $ ) -if (WIN32) - List (APPEND YLIBS $ ) - endif() +# set(CMAKE_BUILD_TYPE Debug) - -add_library( # Sets the name of the library. - libYap - - # Sets the library as a shared library. - SHARED - - ${ENGINE_SOURCES} - ${C_INTERFACE_SOURCES} - //${STATIC_SOURCES} - # cmake object libraries - ${YLIBS} - ) - -if (WIN32) - target_link_libraries(libYap ${WINDLLS}) -endif (WIN32) - -include(libYap NO_POLICY_SCOPE) +if ($ENV{CONDA_BUILD}x STREQUAL "1x" ) + set(CMAKE_LIBRARY_ARCHITECTURE $ENV{PREFIX}) + set(CMAKE_PREFIX_PATH $ENV{PREFIX}) + set( R_COMMAND "$ENV{R}") + set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS CONDA_BUILD=1) + list (APPEND CMAKE_REQUIRED_INCLUDES + ${PREFIX}/include + ${SYS_PREFIX}/include + ) + set(YAP_IS_MOVABLE 1) endif() -if (USE_READLINE) - target_link_libraries(libYap ${READLINE_LIBRARIES}) -endif (USE_READLINE) +ADD_CUSTOM_TARGET(run_install COMMAND ${CMAKE_MAKE_PROGRAM} install) + +if (APPLE) + set(MACOSX_RPATH ON) + + if (NOT $ENV{CONDA_BUILD}x STREQUAL "1x") + + set(PATH $ENV{PATH}) + + if (WITH_MACPORTS) + # Add MacPorts + # Detect if the "port" command is valid on this system; if so, return full path + EXECUTE_PROCESS(COMMAND which port RESULT_VARIABLE DETECT_MACPORTS OUTPUT_VARIABLE MACPORTS_PREFIX ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + + IF (${DETECT_MACPORTS} EQUAL 0) + # "/opt/local/bin/port" doesn't have libs, so we get the parent directory + GET_FILENAME_COMPONENT(MACPORTS_PREFIX ${MACPORTS_PREFIX} DIRECTORY) + + # "/opt/local/bin" doesn't have libs, so we get the parent directory + GET_FILENAME_COMPONENT(MACPORTS_PREFIX ${MACPORTS_PREFIX} DIRECTORY) + + # "/opt/local" is where MacPorts lives, add `/lib` suffix and link + LINK_DIRECTORIES(${LINK DIRECTORIES} ${MACPORTS_PREFIX}/lib) + + MESSAGE("WINNING!: ${MACPORTS_PREFIX}/lib") + ENDIF() + ENDIF() + + + if (WITH_BREW) + EXECUTE_PROCESS(COMMAND brew --prefix RESULT_VARIABLE DETECT_BREW OUTPUT_VARIABLE BREW_PREFIX ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + + IF (${DETECT_BREW} EQUAL 0) + + # "/opt/local" is where MacPorts lives, add `/lib` suffix and link + LINK_DIRECTORIES( ${BREW_PREFIX}/lib) + + MESSAGE("BREW!: ${BREW_PREFIX}/lib") + ENDIF() + + + list(INSERT CMAKE_PREFIX_PATH pos + ${BREW_PREFIX}/opt/gmp + ${BREW_PREFIX}/opt/libxml2 + ${BREW_PREFIX}/opt/openmpi + ${BREW_PREFIX}/opt/openssl + ${BREW_PREFIX}/opt/postgresql + ${BREW_PREFIX}/opt/python3 + ${BREW_PREFIX}/opt/readline + ${BREW_PREFIX}/opt/swig + ) + endif () + endif() +endif () + + +set(prefix ${CMAKE_INSTALL_PREFIX}) #BINDIR}) +set(bindir ${CMAKE_INSTALL_PREFIX}/bin) #BINDIR}) +set(includedir ${CMAKE_INSTALL_PREFIX}/include) #INCLUDEDIR}) +set(libdir ${CMAKE_INSTALL_PREFIX}/lib) #LIBDIR}) +set(exec_prefix ${CMAKE_INSTALL_PREFIX}/libexec) #LIBEXECDIR}) +set(datarootdir ${CMAKE_INSTALL_PREFIX}/share) #DATAROOTDIR}) if (ANDROID) - add_dependencies(libYap plmyddas ) + set(datarootdir ${YAP_APP_DIR}/src/generated/assets) +endif () +set(datadir ${CMAKE_INSTALL_PREFIX}/share) #DATADIR}) +set(mandir ${CMAKE_INSTALL_PREFIX}/share/man) #MANDIR}) +set(docdir ${CMAKE_INSTALL_PREFIX}/share/docs) #MANDIR}) - target_link_libraries(libYap android log) +set(libpl ${datadir}/Yap) + +set(dlls ${libdir}/Yap) + +set(YAP_ROOTDIR ${prefix}) +# erootdir -> rootdir +# libdir defined above +set(YAP_DATADIR ${CMAKE_INSTALL_FULL_DATADIR}) +set(YAP_INCLUDEDIR ${CMAKE_INSTALL_FULL_INCLUDEDIR}/Yap) +set(YAP_LIBDIR ${CMAKE_INSTALL_FULL_LIBDIR}) +set(YAP_DLLDIR ${CMAKE_INSTALL_FULL_LIBDIR}/Yap) +set(YAP_PLDIR ${CMAKE_INSTALL_FULL_DATADIR}/Yap) + +set(YAP_INSTALL_DLLDIR ${CMAKE_INSTALL_LIBDIR}/Yap) +set(YAP_INSTALL_PLDIR ${CMAKE_INSTALL_DATADIR}/Yap) + +set(libpl ${YAP_INSTALL_PLDIR}) + +# +# +# include( Sources ) +# +# include( Model ) + +include(cudd ) + +set(pl_library "" CACHE INTERNAL "prolog library files") +set(pl_os_library "" CACHE INTERNAL "prolog os files") +set(pl_boot_library "" CACHE INTERNAL "prolog boot files") + + +find_package(GMP) +# GMP_FOUND - true if GMP/MPIR was found +# GMP_INCLUDE_DIRS - include search path +# GMP_LIBRARIES - libraries to link with +# GMP_LIBRARY_ #add_executable(test ${SOURCES}) + +list(APPEND YAP_SYSTEM_OPTIONS big_numbers) + + + +if (GMP_FOUND) + #config.h needs this (TODO: change in code latter) + include_directories(${GMP_INCLUDE_DIRS}) + check_include_file(gmp.h HAVE_GMP_H) + check_include_file_cxx(gmpxx.h HAVE_GMPXX_H) + + +endif (GMP_FOUND) + + +if (WITH_READLINE) + include(FindReadline) + + List(APPEND YAP_SYSTEM_OPTIONS readline) + # include subdirectories configuration + ## after we have all functionality in + # + # ADD_SUBDIRECTORY(console/terminal) + + if (READLINE_FOUND) + include_directories(${READLINE_INCLUDE_DIR}) + # required for configure + list(APPEND CMAKE_REQUIRED_LIBRARIES ${READLINE_LIBRARIES}) + list(APPEND CMAKE_REQUIRED_INCLUDES ${READLINE_INCLUDE_DIR}) + endif () +endif() + +#MPI STUFF +# library/mpi/mpi.c library/mpi/mpe.c +# library/lammpi/yap_mpi.c library/lammpi/hash.c library/lammpi/prologterms2c.c +# ) + +#WIN STUFF +# SET(PLCONS_SOURCES +# console/LGPL/pl-nt.c +# console/LGPL/pl-ntcon.c +# console/LGPL/pl-ntconsole.c +# console/LGPL/pl-ntmain.c +# ) +set(YAP_FOUND ON) + +set(YAP_MAJOR_VERSION 6) +set(YAP_MINOR_VERSION 4) +set(YAP_PATCH_VERSION 1) + +set(YAP_FULL_VERSION + ${YAP_MAJOR_VERSION}.${YAP_MINOR_VERSION}.${YAP_PATCH_VERSION}) +set(YAP_FVERSION + ${YAP_MAJOR_VERSION}.${YAP_MINOR_VERSION}.${YAP_PATCH_VERSION}) +set(YAP_NUMERIC_VERSION + ${YAP_MAJOR_VERSION}*10000+${YAP_MINOR_VERSION}*100+${YAP_PATCH_VERSION}) +set(MYDDAS_VERSION MYDDAS-0.9.1) + +site_name(YAP_SITE) + + +if (WIN32) + set(YAP_ARCH $ENV{PROCESSOR_ARCHITECTURE}) + set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "MS_WIN64=1") + set(YAP_SYSTEM_OPTIONS "windows " ${YAP_SYSTEM_OPTIONS}) +endif () +if (UNIX) + find_program(UNAME uname) + execute_process( + COMMAND ${UNAME} -m + OUTPUT_VARIABLE YAP_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE) + set(YAP_SYSTEM_OPTIONS "unix " ${YAP_SYSTEM_OPTIONS}) +endif () + + +# +set(MIN_STACKSPACE 1024*SIZEOF_INT_P) +set(MIN_HEAPSPACE 32*1024*SIZEOF_INT_P) +set(MIN_TRAILSPACE 512*SIZEOF_INT_P) +set(DEF_STACKSPACE 0) +set(DEF_HEAPSPACE 0) +set(DEF_TRAILSPACE 0) + +# option (RATIONAL_TREES "support infinite rational trees" ON) +# dd_definitions (-D) + +## don't touch these opts +set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS DEPTH_LIMIT=1;COROUTINING=1;RATIONAL_TREES=1) + +# inform we are compiling YAP +set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "_YAP_NOT_INSTALLED_=1;HAVE_CONFIG_H=1;_GNU_SOURCE=1") + +# Compilation model +# target_compile_definitions(libYap PUBLIC _XOPEN_SOURCE=700 ) + +#add_definitions( -Wall -Wstrict-prototypes -Wmissing-prototypes) + +# Model Specific +set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$:DEBUG=1>) + +#ensure cells are properly aligned in code +set(ALIGN_LONGS 1) + +#ensure best access to slots in environments +set(MSHIFTOFFS 1) + +set(C_COMPILER CMAKE_C_COMPILER_ID) + +if (${C_COMPILER} MATCHES "GNU") + set(HAVE_GCC 1) +endif () + +# compatible compilers +if (${C_COMPILER} MATCHES "Clang") + set(HAVE_GCC 1) +endif () + +if (${C_COMPILER} MATCHES "Intel") + set(HAVE_GCC 1) +endif () + +# rpath stuff, hopefully it works +# use, i.e. don't skip the full RPATH for the build tree +#SET(CMAKE_SKIP_BUILD_RPATH TRUE) + + +# when building, don't use the install RPATH already +## (but later on when installing) +#SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) +# +## SET(CMAKE_INSTALL_FULL_RPATH ${CMAKE_TOP_BINARY_DIR}) +# +## add the automatically determined parts of the RPATH +## which point to directories outside the build tree to the install RPATH +#SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FAlSE) +# +# +## the RPATH to be used when installing, but only if it's not a system directory +#LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${libdir}" isSystemDir) +# IF("${isSystemDir}" STREQUAL "-1") +# SET(CMAKE_INSTALL_RPATH ${libdir}) +#ENDIF("${isSystemDir}" STREQUAL "-1") +# +IF(NOT WIN32 AND NOT APPLE) + LIST(APPEND CMAKE_INSTALL_RPATH \\$ORIGIN/../lib/Yap) + LIST(APPEND CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}) + LIST(APPEND CMAKE_INSTALL_RPATH \\$ORIGIN/../lib) + LIST(APPEND CMAKE_INSTALL_RPATH \\$ORIGIN/../../../lib) +ELSE() + LIST(APPEND CMAKE_INSTALL_RPATH @loader_path/../lib/Yap) + LIST(APPEND CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}) + LIST(APPEND CMAKE_INSTALL_RPATH @loader_path/../lib) + LIST(APPEND CMAKE_INSTALL_RPATH @loader_path/../../../lib) +ENDIF() + +# Model Specific +if (HAVE_GCC) + set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS -Wall) + if (${C_COMPILER} MATCHES "GNU") + set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS $<$:-O3;-fomit-frame-pointer;-fstrict-aliasing;-freorder-blocks;-fsched-interblock>) + else () + set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS $<$:-O3;-fstrict-aliasing;-freorder-blocks;-fsched-interblock>) + endif () + set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS -fexceptions) +endif () + +# set_property( DIRECTORY APPEND_STRING PROPERTY -fsanitize=memory;-fsanitize-memory-track-origins=2) +if (HAVE_GCC) + # replace instructions codes by the address of their code + if (WITH_THREADED_CODE) + set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS THREADED_CODE=1) + endif (WITH_THREADED_CODE) +endif (HAVE_GCC) + +# +#option (YAP_SWI_IO ON) + +#TODO: +if (WITH_CALL_TRACER) + list(APPEND YAP_SYSTEM_OPTIONS "call_tracer " ${YAP_SYSTEM_OPTIONS}) + set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$:LOW_LEVEL_TRACER=1>) +endif (WITH_CALL_TRACER) + +set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS UTF8PROC=1) + +include_directories(utf8proc packages/myddas packages/myddas/sqlite3/src ) + +set_property(SOURCE ${LIBYAP_SOURCES} APPEND PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1) + + +IF (WITH_MYDDAS) + if (ANDROID) + else() + + add_definitions(-DUSE_MYDDAS=1 -DMYDDAS_SQLITE3=1) + + if (MYSQL_FOUND) + add_definitions(= -DMYDDAS_MYSQL=1) + endif () + + if (ODBC_FOUND) + add_definitions(= -DMYDDAS_ODBC=1) + endif () + + if (MYSQL_POSTGRES) + add_definitions(= -DMYDDAS_POSTGRES=1) + endif () + endif(ANDROID) +endif(WITH_MYDDAS) + + +IF (WITH_SWIG) + find_host_package(SWIG) + # macro_log_feature (SWIG_FOUND "Swig" + # "Use SWIG Interface Generator " + # "http://www.swig.org" ON) +ENDIF (WITH_SWIG) + + + +IF (WITH_PYTHON) + include(python ) +ENDIF (WITH_PYTHON) + + +IF (WITH_R) + find_host_package(LibR) + add_subDIRECTORY(packages/real) +ENDIF (WITH_R) + + +List(APPEND YLIBS $) +List(APPEND YLIBS $) +List(APPEND YLIBS $) +List(APPEND YLIBS $) +List(APPEND YLIBS $) +if (WIN32 OR ANDROID) + List(APPEND YLIBS $) + if (WIN32 AND WITH_PYTHON) + List(APPEND YLIBS $) + endif () + if (ANDROID) + List(APPEND YLIBS $) + List(APPEND YLIBS $) + endif () +endif () + +include(Sources) + + +add_corelib( # Sets the name of the library. + libYap + + # Sets the library as a shared library. + SHARED + + ${ENGINE_SOURCES} + ${C_INTERFACE_SOURCES} + //${STATIC_SOURCES} + # cmake object libraries + ${YLIBS} + ) + +if (GMP_FOUND) + target_link_libraries(libYap ${GMP_LIBRARIES}) +endif (GMP_FOUND) + +if (READLINE_FOUND) + target_link_libraries(libYap ${READLINE_LIBRARIES}) + # required for configure endif () +if (WIN32) + target_link_libraries(libYap ${WINDLLS}) + if (WITH_PYTHON AND PYTHON_INCLUDE_DIRS AND PYTHON_LIBRARIES) + target_link_libraries(libYap ${PYTHON_LIBRARIES}) + endif () +endif (WIN32) + +target_link_libraries(libYap m) + + +set(YAP_STARTUP startup.yss) +set(YAP_BOOTFILE boot.yap ) +## define system + +# Optional libraries that affect compilation +# + + +set(CMAKE_TOP_BINARY_DIR ${CMAKE_BINARY_DIR}) +set(YAP_PL_SRCDIR ${CMAKE_SOURCE_DIR}/pl) + +set(YAP_YAPLIB libYap${CMAKE_SHARED_LIBRARY_SUFFIX}) + +string(TIMESTAMP YAP_TIMESTAMP) + +string(SUBSTRING ${CMAKE_SHARED_LIBRARY_SUFFIX} 1 -1 SO_EXT) + +set_property(DIRECTORY PROPERTY CXX_STANDARD 11) + + +include_directories(H + H/generated + include os OPTYap utf8proc JIT/HPP) +include_directories(BEFORE ${CMAKE_BINARY_DIR} ${CMAKE_TOP_BINARY_DIR}) + +if (ANDROID) + include_directories(CXX ${CMAKE_SOURCE_DIR}/../generated/src/jni) +endif () +include(Threads) +# +# include OS and I/o stuff +# +# convenience libraries +# OPTYap exports important flags +# +list(APPEND YAP_SYSTEM_OPTIONS "thread support") + set_target_properties(libYap - PROPERTIES OUTPUT_NAME Yap + PROPERTIES OUTPUT_NAME Yap + ) +MY_set_target_properties(libYap + PROPERTIES VERSION ${YAP_FULL_VERSION} + SOVERSION ${YAP_MAJOR_VERSION}.${YAP_MINOR_VERSION} ) -MY_include(Packages NO_POLICY_SCOPE) -include(Config NO_POLICY_SCOPE) + +#utf-8 is not aPconn option +# we use the nice UTF-8 package +#available at the Julia project + +ADD_SUBDIRECTORY(OPTYap) +ADD_SUBDIRECTORY(os) +ADD_SUBDIRECTORY(packages/myddas) +ADD_SUBDIRECTORY(utf8proc) +ADD_SUBDIRECTORY(library/dialect/swi/fli) +ADD_SUBDIRECTORY(CXX) + + +add_subDIRECTORY(H) + +#bootstrap and saved state +add_subDIRECTORY(pl) + +ADD_SUBDIRECTORY(library) + +ADD_SUBDIRECTORY(swi/library "swiLibrary") + +set_target_properties(libYap + PROPERTIES OUTPUT_NAME Yap + ) + +# file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/packages/python/swig/yap4py) + +if (WITH_PYTHON AND PYTHONLIBS_FOUND AND SWIG_FOUND) + set( ENV{PYTHONPATH} ${CMAKE_BINARY_DIR}/packages/python/swig:${CMAKE_BINARY_DIR}/packages/python/yap_kernel:. ) + add_subdirectory(packages/python/swig) + + include(FindPythonModule) + + find_python_module(jupyter) + find_python_module(wheel) + find_python_module(setuptools) + if (PY_JUPYTER AND PY_WHEEL AND PY_SETUPTOOLS) + add_subdirectory(packages/python/yap_kernel) + else() + message("will not compile yap_kernel, as jupyter=${PY_JUPYTER};wheel=${PY_WHEEL};setuptools=${PY_SETUPTOOLS}") + ENDIF () + +endif () + + +IF ( ANDROID) + set(CMAKE_SWIG_OUTDIR ${YAP_APP_DIR}/src/generated/java/pt/up/yap/lib ) + set(CMAKE_SWIG_OUTPUT ${YAP_APP_DIR}/src/generated/jni ) + set( SWIG_MODULE_NAME pt.up.yap.lib ) + + add_subDIRECTORY(packages/swig ) + + + + + target_link_libraries(libYap ${CMAKE_SOURCE_DIR}/../sqlite-android/jni/${ANDROID_ABI}/libsqliteX.so android log ) + +ENDIF () + + +message(STATUS "Building YAP packages version ${YAP_VERSION}") + + +if (NOT WIN32) + set(BUILD_SHARED_LIBS ON) +endif () + + +if (WITH_JIT) + add_subDIRECTORY(JIT) +endif (WITH_JIT) + + +if (WITH_XML2 OR WITH_RAPTOR) + + add_subDIRECTORY(packages/raptor) + +endif() + + +if (WITH_XML) + + add_subDIRECTORY(packages/xml) + +endif () + + +IF (WITH_CLPBN) + add_subDIRECTORY(packages/CLPBN) +ENDIF (WITH_CLPBN) + +IF (WITH_CPLINT) + add_subDIRECTORY(packages/cplint) +ENDIF (WITH_CPLINT) + + +IF (WITH_DOCS) + get_target_property(YAP_SOURCES libYap SOURCES) + + add_subDIRECTORY(docs) + + + find_host_package(Doxygen) + +ENDIF (WITH_DOCS) + +# add_subDIRECTORY (packages/cuda) + +if (WITH_GECODE) + add_subDIRECTORY(packages/gecode) +endif () + +if (WITH_LBFGS) + add_subDIRECTORY(packages/yap-lbfgs) +endif () + + + + +if (WITH_JAVA) + #detect java setup, as it is shared between different installations. + + find_package(Java COMPONENTS Runtime Development) + # find_package(Java COMPONENTS Development) + # find_package(Java COMPONENTS Runtime) + #find_package(JavaLibs) + + + if (Java_Development_FOUND) + + set (STD_CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK}) + set (CMAKE_FIND_FRAMEWORK LAST) # CMake will find the Java returned by /usr/libexec/java_home. + + macro_optional_find_package(JNI ON) + + + set (CMAKE_FIND_FRAMEWORK ${STD_CMAKE_FIND_FRAMEWORK}) + + if (JNI_FOUND) + + get_filename_component(JAVA_HOME ${JAVA_INCLUDE_PATH} DIRECTORY) + + include(UseJava) + + # + # Java_JAVA_EXECUTABLE = the full path to the Java runtime + # Java_JAVAC_EXECUTABLE = the full path to the Java compiler + # Java_JAVAH_EXECUTABLE = the full path to the Java header generator + # Java_JAVADOC_EXECUTABLE = the full path to the Java documention generator + # Java_IDLJ_EXECUTABLE = the full path to the Java idl compiler + # Java_JAR_EXECUTABLE = the full path to the Java archiver + # Java_JARSIGNER_EXECUTABLE = the full path to the Java jar signer + # Java_VERSION_STRING = Version of java found, eg. 1.6.0_12 + # Java_VERSION_MAJOR = The major version of the package found. + # Java_VERSION_MINOR = The minor version of the package found. + # Java_VERSION_PATCH = The patch version of the package found. + # Java_VERSION_TWEAK = The tweak version of the package found (after '_') + # Java_VERSION = This is set to: $major.$minor.$patch(.$tweak) + # + # The Java_ADDITIONAL_VERSIONS variable can be used to specify a list + # of version numbers that should be taken into account when searching + # for Java. You need to set this variable before calling + + + # + #macro_optional_find_package(JNI ON) + # JNI_INCLUDE_DIRS = the include dirs to use + # JNI_LIBRARIES = the libraries to use + # JNI_FOUND = TRUE if JNI headers and libraries were found. + # JAVA_AWT_LIBRARY = the path to the jawt library + # JAVA_JVM_LIBRARY = the path to the jvm library + # JAVA_INCLUDE_PATH = the include path to jni.h + # JAVA_INCLUDE_PATH2 = the include path to jni_md.h + # JAVA_AWT_INCLUDE_PATH = the include path to jawt.h + + + endif (JNI_FOUND) + + + endif (Java_Development_FOUND) + + add_subDIRECTORY(packages/jpl) + +endif(WITH_JAVA) + +if (WITH_CUDD) + + add_subDIRECTORY(packages/bdd) + +endif() + +if (WITH_PROBLOG) + + add_subDIRECTORY(packages/ProbLog) + +endif() + +if (WITH_MINISAT) + + add_subDIRECTORY(packages/swi-minisat2) + +endif() + +if (WITH_CLPQR) + + add_subDIRECTORY(packages/clpqr) + +endif() + + +#todo: use cmake target builds +# option (USE_MAXPERFORMANCE +# "try using the best flags for specific architecture" OFF) + +# option (USE_MAXMEMORY +# "try using the best flags for using the memory to the most" ON) +#TODO: check MAXMEMORY + +#TODO: use cmake target builds +# option (USE_DEBUGYAP +# "enable C-debugging for YAP" OFF) + +#TODO: use cmake arch/compiler +# option (USE_CYGWIN +# "use cygwin library in WIN32" OFF) + +#TODO: + + +#TODO: detect arch before allow this option +# OPTION(WIN64 +# "compile YAP for win64" OFF) + +# option (APRIL +# "compile Yap to support April ILP system" OFF) +# option (DLCOMPAT +# "use dlcompat library for dynamic loading on Mac OS X" OFF) + +# SHARED PACKAGES with SWI + +# swi packages have both Makefile.in which we will use and +# Makefile.mak, we will use the later to identify this packages +# while we keep both autotools amd cmake working side by side +# Search for available packages which all have a Makefile.mak +#file (GLOB PACKAGES packages/*/Makefile.mak) + +# needed by this packages + + +if (WIN32) + + if (MSVC) + set(MSVC_RUNTIME "dynamic") + ENDIF (MSVC) + + target_link_libraries(libYap wsock32 ws2_32 shlwapi) + +endif (WIN32) + +add_executable(yap-bin ${CONSOLE_SOURCES}) + +set_target_properties(yap-bin PROPERTIES OUTPUT_NAME yap) + + +target_link_libraries(yap-bin libYap) + +install(TARGETS libYap yap-bin + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + ) + + +if (WITH_MPI) + + add_subDIRECTORY(library/lammpi) + + if (MPI_C_FOUND) + + macro_optional_add_subDIRECTORY(library/mpi) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MPI_C_COMPILE_FLAGS} ") + include_directories(${MPI_C_INCLUDE_PATH}) + target_link_libraries(yap-bin ${MPI_C_LIBRARIES}) + if (MPI_C_COMPILE_FLAGS) + set_target_properties(yap-bin PROPERTIES + COMPILE_FLAGS "${MPI_C_COMPILE_FLAGS}") + endif (MPI_C_COMPILE_FLAGS) + + if (MPI_C_LINK_FLAGS) + set_target_properties(yap-bin PROPERTIES + LINK_FLAGS "${MPI_C_LINK_FLAGS}") + endif () + endif (MPI_C_FOUND) + +endif(WITH_MPI) + +## add_subDIRECTORY(utils) + +# + +install(FILES ${INCLUDE_HEADERS} ${CONFIGURATION_HEADERS} DESTINATION ${includedir}/Yap ) + + + +macro_display_feature_log() +if (POLICY CMP0058) + cmake_policy(SET CMP0058 NEW) +endif (POLICY CMP0058) + +include(Config ) + + +feature_summary(DESCRIPTION "Packages found:" + WHAT PACKAGES_FOUND + ) +feature_summary(DESCRIPTION "Packages not found:" + WHAT PACKAGES_NOT_FOUND + ) diff --git a/CXX/CMakeLists.txt b/CXX/CMakeLists.txt index 80259bad8..c1ef100b3 100644 --- a/CXX/CMakeLists.txt +++ b/CXX/CMakeLists.txt @@ -7,30 +7,24 @@ set(SO_PATCH 0) set (CXX_SOURCES yapi.cpp ) - -set (CXX_HEADERS - yapa.hh - yapdb.hh - yapi.h - yapie.hh - yapq.hh -- yapt.hh --) - list(APPEND LIBYAP_SOURCES ${CXX_SOURCES} PARENT_SCOPE) -if ( WIN32) +if ( WIN32 OR ANDROID) add_component (YAP++ ${CXX_SOURCES} ) set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "_YAP_NOT_INSTALLED_=1;HAVE_CONFIG_H=1;_GNU_SOURCE;YAP_KERNEL=1" ) else() - add_external (YAP++ ${CXX_SOURCES} ) - MY_target_link_libraries(YAP++ ${CMAKE_DL_LIBS} libYap) + add_lib(YAP++ ${CXX_SOURCES} ) + if (WITH_PYTHON) + target_link_libraries(YAP++ Py4YAP ) + endif() + target_link_libraries(YAP++ ${CMAKE_DL_LIBS} libYap) + MY_install(TARGETS YAP++ - LIBRARY DESTINATION ${libdir} - RUNTIME DESTINATION ${dlls} - ARCHIVE DESTINATION ${libdir} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) endif() diff --git a/CXX/yapa.hh b/CXX/yapa.hh index 332a9dc2f..8d0454326 100644 --- a/CXX/yapa.hh +++ b/CXX/yapa.hh @@ -24,7 +24,7 @@ * * In a nutshell: * - YAPAtom serves as the gateway to the data-base; - * + * * - YAProp abstracts most data-base objects. * * - PropTag allows distinguishing the different classes of YAPProp. @@ -41,12 +41,12 @@ enum PropTag { ARITHMETIC_PROPERTY_TAG = ExpProperty, // 0xFFE0, /// map the atom to an integer TRANSLATION_TAG = TranslationProperty, // 0xFFF4, - /// ensure the atom may not be garbafe colected - HOLD_TAG = HoldProperty, // 0xFFF6 + /// ensure the atom may not be garbafe colected + HOLD_TAG = HoldProperty, // 0xFFF6 /// named mutEX MUTEX_TAG = MutexProperty, // 0xFFF6, /// A typed array, may be in-db or in-stack deped - ARRAY_TAG = ArrayProperty, // 0xFFF7, + ARRAY_TAG = ArrayProperty, // 0xFFF7, /// module MODULE_TAG = ModProperty, // 0xFFFA, /// the original SICStus blackboard @@ -57,8 +57,8 @@ enum PropTag { GLOBAL_VAR_TAG = GlobalProperty, // 0xFFFD /// SWI-STYLE ATOM Extension BLOB_TAG = BlobProperty, // 0xFFFE, - /// Prolog operator, - OPERATOR_TAG = OpProperty, // 0xFFFF, + /// Prolog operator, + OPERATOR_TAG = OpProperty, // 0xFFFF, }; /** @@ -68,7 +68,7 @@ enum PropTag { * predicates, operators, modules, almost everything. * */ -class YAPAtom { +class X_API YAPAtom { friend class YAPEngine; friend class YAPModuleProp; friend class YAPPredicate; @@ -94,7 +94,7 @@ public: /// get name of (other way) inline const char *text(void) { return getName(); } ; /// get prop of type - Prop getProp( PropTag tag ) { return Yap_GetAProp( a , (PropFlags)tag ); } + Prop getProp( PropTag tag ) { return Yap_GetAProp( a , (PropFlags)tag ); } }; /** @@ -104,7 +104,7 @@ public: * predicates, operators, modules, almost everything. * */ -class YAPProp { +class X_API YAPProp { friend class YAPModuleProp; friend class YAPFunctor; /// does nothing, p is defined by the subclass @@ -115,10 +115,9 @@ public: /// get name of property // virtual YAPAtom name(); virtual ~YAPProp() {}; - + }; -#endif /* YAPA_HH */ +#endif /* YAPA_HH */ /// @} - diff --git a/CXX/yapdb.hh b/CXX/yapdb.hh index cd617862b..d376c7ff8 100644 --- a/CXX/yapdb.hh +++ b/CXX/yapdb.hh @@ -2,12 +2,12 @@ /// /// @brief C++ Interface to generated code. - #ifndef _YAPDB_H #define _YAPDB_H -#define YAP_CPP_DB_INTERFACE 1 +#include +#define YAP_CPP_DB_INTERFACE 1 /** * @@ -43,16 +43,18 @@ class YAPModule; * Info about the module is in YAPModuleProp * */ -class YAPModule : protected YAPAtomTerm { +class X_API YAPModule : protected YAPAtomTerm { friend class YAPPredicate; friend class YAPModuleProp; - YAPModule(Term t) : YAPAtomTerm(t){}; Term t() { return gt(); } Term curModule() { CACHE_REGS return Yap_CurrentModule(); } public: + YAPModule(YAP_Term t) : YAPAtomTerm(t){}; YAPModule() : YAPAtomTerm(curModule()){}; YAPModule(YAPAtom t) : YAPAtomTerm(t){}; + YAPModule(YAPStringTerm t) : YAPAtomTerm(t.getString()){}; + Term term() { return gt(); }; }; /** @@ -60,7 +62,7 @@ public: * A YAPModuleProp controls access to a module property. * */ -class YAPModuleProp : public YAPProp { +class X_API YAPModuleProp : public YAPProp { friend class YAPPredicate; ModEntry *m; @@ -69,64 +71,16 @@ class YAPModuleProp : public YAPProp { public: YAPModuleProp(YAPModule tmod) { m = Yap_GetModuleEntry(tmod.gt()); }; - YAPModuleProp() { CACHE_REGS m = Yap_GetModuleEntry(Yap_CurrentModule()); }; + YAPModuleProp() { m = Yap_GetModuleEntry(Yap_CurrentModule()); }; virtual YAPModule module() { return YAPModule(m->AtomOfME); }; }; -/** - * @brief YAPFunctor represents Prolog functors Name/Arity - */ -class YAPFunctor : public YAPProp { - friend class YAPApplTerm; - friend class YAPTerm; - friend class YAPPredicate; - friend class YAPQuery; - Functor f; - /// Constructor: receives Prolog functor and casts it to YAPFunctor - /// - /// Notice that this is designed for internal use only. - inline YAPFunctor(Functor ff) { f = ff; } - -public: - /// Constructor: receives name as an atom, plus arity - /// - /// This is the default method, and the most popular - YAPFunctor(YAPAtom at, uintptr_t arity) { f = Yap_MkFunctor(at.a, arity); } - - /// Constructor: receives name as a string plus arity - /// - /// Notice that this is designed for ISO-LATIN-1 right now - /// Note: Python confuses the 3 constructors, - /// use YAPFunctorFromString - inline YAPFunctor(const char *s, uintptr_t arity, bool isutf8 = true) { - f = Yap_MkFunctor(Yap_LookupAtom(s), arity); - } - /// Constructor: receives name as a wide string plus arity - /// - /// Notice that this is designed for UNICODE right now - /// - /// Note: Python confuses the 3 constructors, - /// use YAPFunctorFromWideString - inline YAPFunctor(const wchar_t *s, uintptr_t arity) { - CACHE_REGS f = Yap_MkFunctor(UTF32ToAtom(s PASS_REGS), arity); - } - /// Getter: extract name of functor as an atom - /// - /// this is for external usage. - YAPAtom name(void) { return YAPAtom(NameOfFunctor(f)); } - - /// Getter: extract arity of functor as an unsigned integer - /// - /// this is for external usage. - uintptr_t arity(void) { return ArityOfFunctor(f); } -}; - /** * @brief Predicates * * This class interfaces with PredEntry in Yatom. */ -class YAPPredicate : public YAPModuleProp { +class X_API YAPPredicate : public YAPModuleProp { friend class YAPQuery; friend class YAPEngine; @@ -134,46 +88,48 @@ protected: PredEntry *ap; /// auxiliary routine to find a predicate in the current module. - PredEntry *getPred(YAPTerm &t, Term *&outp); + + /// auxiliary routine to find a predicate in the current module. + PredEntry *getPred(Term &t, Term &tm, CELL *&outp); PredEntry *asPred() { return ap; }; - /// String constructor for predicates + /// Empty constructor for predicates /// - /// It also communicates the array of arguments t[] - /// and the array of variables - /// back to yapquery - YAPPredicate(const char *s0, Term &tout, Term &tnames) { - CACHE_REGS - Term *modp = NULL; - const unsigned char *us = (const unsigned char *)s0; - tnames = MkVarTerm(); - tout = - Yap_BufferToTermWithPrioBindings(us, strlen(s0), TermNil, 1200, tnames); - // fprintf(stderr,"ap=%p arity=%d text=%s", ap, ap->ArityOfPE, s); - // Yap_DebugPlWrite(out); - if (tout == 0L) { - Yap_ThrowError(TYPE_ERROR_PREDICATE_INDICATOR, MkStringTerm(s0), "YAPPredicate"); - } - YAPTerm tt = YAPTerm(tout); - ap = getPred(tt, modp); - } + /// Just do nothing. + inline YAPPredicate() {} + YAPPredicate(Term &to, Term &tmod, CELL *&ts, const char *pname); /// Term constructor for predicates /// /// It is just a call to getPred + inline YAPPredicate(Term t, CELL *&v) { + if (t) { + Term tm = Yap_CurrentModule(); + ap = getPred(t, tm, v); + } + } + inline YAPPredicate(Term t) { - CELL *v = NULL; - YAPTerm tt = YAPTerm(t); - ap = getPred(tt, v); + if (t) { + CELL *v = nullptr; + Term tm = Yap_CurrentModule(); + ap = getPred(t, tm, v); + } } /// Term constructor for predicates /// /// It is just a call to getPred + inline YAPPredicate(YAPTerm t, CELL *&v) { + Term tp = t.term(), tm = Yap_CurrentModule(); + ap = getPred(tp, tm, v); + } inline YAPPredicate(YAPTerm t) { - Term *v = nullptr; - ap = getPred(t, v); + CELL *v = nullptr; + Term tp = t.term(); + Term tm = Yap_CurrentModule(); + ap = getPred(tp, tm, v); } /// Cast constructor for predicates, @@ -181,14 +137,42 @@ protected: /// inline YAPPredicate(PredEntry *pe) { ap = pe; } + /// Functor constructor for predicates, is given a specific module. + /// This version avoids manufacturing objects + inline YAPPredicate(Functor f, Term mod) { + ap = RepPredProp(PredPropByFunc(f, mod)); + } + public: + /// String constructor for predicates + /// + /// It also communicates the array of arguments t[] + /// and the array of variables + /// back to yapquery + YAPPredicate(const char *s0, Term &tout, YAPPairTerm &names, CELL *&nts) { + CACHE_REGS + const char *s = (const char *)s0; + Term tnames = MkVarTerm(); + tout = + Yap_BufferToTermWithPrioBindings(s, TermNil, tnames, strlen(s0), 1200); + // fprintf(stderr,"ap=%p arity=%d text=%s", ap, ap->ArityOfPE, s); + // Yap_DebugPlWrite(out); + if (tout == 0L) { + return; + throw YAPError(); + } + Term tm = Yap_CurrentModule(); + ap = getPred(tout, tm, nts); + tout = Yap_SaveTerm(tout); + names = YAPPairTerm(tnames); + } /// Functor constructor for predicates /// /// Asssumes that we use the current module. YAPPredicate(YAPFunctor f) { CACHE_REGS - ap = RepPredProp(PredPropByFunc(f.f, Yap_CurrentModule())); + ap = RepPredProp(PredPropByFunc(f.f, Yap_CurrentModule())); } /// Functor constructor for predicates, is given a specific module. @@ -226,14 +210,14 @@ public: /// inline YAPPredicate(const char *at, uintptr_t arity) { ap = RepPredProp(PredPropByFunc(Yap_MkFunctor(Yap_LookupAtom(at), arity), - CurrentModule)); + Yap_CurrentModule())); }; /// char */module constructor for predicates. /// inline YAPPredicate(const char *at, uintptr_t arity, YAPTerm mod) { ap = RepPredProp( - PredPropByFunc(Yap_MkFunctor(Yap_LookupAtom(at), arity), mod.term())); + PredPropByFunc(Yap_MkFunctor(Yap_LookupAtom(at), arity), mod.term())); }; /// char */module constructor for predicates. @@ -268,7 +252,8 @@ public: YAPFunctor functor() { if (ap->ArityOfPE) return YAPFunctor(ap->FunctorOfPred); -Yap_ThrowError(DOMAIN_ERROR_OUT_OF_RANGE, MkIntTerm(0), "YAPFunctor::functor"); + Yap_ThrowError(DOMAIN_ERROR_OUT_OF_RANGE, MkIntTerm(0), + "YAPFunctor::functor"); } /// arity of predicate @@ -276,6 +261,7 @@ Yap_ThrowError(DOMAIN_ERROR_OUT_OF_RANGE, MkIntTerm(0), "YAPFunctor::functor"); /// we return a positive number. uintptr_t getArity() { return ap->ArityOfPE; } arity_t arity() { return ap->ArityOfPE; } + PredEntry *predEntry() { return ap; } }; /** @@ -283,13 +269,14 @@ Yap_ThrowError(DOMAIN_ERROR_OUT_OF_RANGE, MkIntTerm(0), "YAPFunctor::functor"); * * This class interfaces with Predicates Implemented in Prolog. */ -class YAPPrologPredicate : public YAPPredicate { +class X_API YAPPrologPredicate : public YAPPredicate { public: YAPPrologPredicate(YAPTerm t) : YAPPredicate(t){}; YAPPrologPredicate(const char *s, arity_t arity) : YAPPredicate(s, arity){}; + YAPPrologPredicate(YAPAtom s, arity_t arity) : YAPPredicate(s, arity){}; /// add a new clause bool assertClause(YAPTerm clause, bool last = true, - YAPTerm source = YAPTerm()); + YAPTerm source = YAPTerm()); /// add a new tuple bool assertFact(YAPTerm *tuple, bool last = true); /// retract at least the first clause matching the predicate. @@ -305,15 +292,14 @@ public: * * This class interfaces with Predicates Implemented in Prolog. */ -class YAPFLIP : public YAPPredicate { +class X_API YAPFLIP : public YAPPredicate { public: - YAPFLIP(CPredicate call, YAPAtom name, uintptr_t arity, - YAPModule module = YAPModule(), CPredicate retry = 0, - CPredicate cut = 0, size_t extra = 0, bool test = false) - : YAPPredicate(name, arity, module) { + YAPFLIP(YAP_UserCPred call, YAPAtom name, YAP_Arity arity, + YAPModule module = YAPModule(), YAP_UserCPred retry = 0, + YAP_UserCPred cut = 0, YAP_Arity extra = 0, bool test = false) + : YAPPredicate(name, arity, module) { if (retry) { - Yap_InitCPredBackCut(name.getName(), arity, extra, call, retry, cut, - UserCPredFlag); + YAP_UserBackCutCPredicate(name.getName(), call, retry, cut, arity, extra); } else { if (test) { YAP_UserCPredicate(name.getName(), call, arity); @@ -324,7 +310,7 @@ public: }; YAPFLIP(const char *name, uintptr_t arity, YAPModule module = YAPModule(), bool backtrackable = false) - : YAPPredicate(YAPAtom(name), arity, module) { + : YAPPredicate(YAPAtom(name), arity, module) { if (backtrackable) { Yap_InitCPredBackCut(name, arity, 0, 0, 0, 0, UserCPredFlag); } else { diff --git a/CXX/yapi.cpp b/CXX/yapi.cpp index 0c7fbe08c..c0859d0dd 100644 --- a/CXX/yapi.cpp +++ b/CXX/yapi.cpp @@ -1,41 +1,133 @@ - -#define YAP_CPP_INTERFACE 1 +#include "inline-only.h" +#define _EXPORT_KERNEL 1 #include "yapi.hh" + extern "C" { #if __ANDROID__ #include "android/log.h" #endif -#include "YapInterface.h" -#include "blobs.h" - -X_API extern char *Yap_TermToString(Term t, size_t *length, encoding_t encodingp, - int flags); - -X_API extern void YAP_UserCPredicate(const char *, YAP_UserCPred, arity_t arity); -X_API extern void YAP_UserCPredicateWithArgs(const char *, YAP_UserCPred, arity_t, - YAP_Term); -X_API extern void YAP_UserBackCPredicate(const char *, YAP_UserCPred, YAP_UserCPred, - arity_t, arity_t); #if YAP_PYTHON - extern bool python_in_python; - X_API extern bool init_python(void); - extern X_API bool Py_IsInitialized(); - +#include "Python.h" +#endif + +#include "YapBlobs.h" +#include "YapInterface.h" +#include "iopreds.h" + +#include "YapInit.h" + +X_API char *Yap_TermToBuffer(Term t, int flags); + +X_API void YAP_UserCPredicate(const char *, YAP_UserCPred, arity_t arity); +X_API void YAP_UserCPredicateWithArgs(const char *, YAP_UserCPred, arity_t, + YAP_Term); +X_API void YAP_UserBackCPredicate(const char *, YAP_UserCPred, YAP_UserCPred, + YAP_Arity, YAP_Arity); + +#if YAP_PYTHON +X_API bool do_init_python(void); #endif - } -YAPAtomTerm::YAPAtomTerm(char *s) -{ // build string +static void YAPCatchError() { + if (LOCAL_CommittedError != nullptr && + LOCAL_CommittedError->errorNo != YAP_NO_ERROR) { + // Yap_PopTermFromDB(info->errorTerm); + // throw throw YAPError( ); + Term es[2]; + es[0] = TermError; + es[1] = MkErrorTerm(LOCAL_CommittedError); + Functor f = Yap_MkFunctor(Yap_LookupAtom("print_message"), 2); + YAP_RunGoalOnce(Yap_MkApplTerm(f, 2, es)); + // Yap_PopTermFromDB(info->errorTerm); + // throw throw YAPError( SOURCE(), ); + } else if (LOCAL_ActiveError != nullptr && + LOCAL_ActiveError->errorNo != YAP_NO_ERROR) { + // Yap_PopTermFromDB(info->errorTerm); + // throw throw YAPError( ); + Term es[2]; + es[0] = TermError; + es[1] = MkErrorTerm(LOCAL_ActiveError); + Functor f = Yap_MkFunctor(Yap_LookupAtom("print_message"), 2); + YAP_RunGoalOnce(Yap_MkApplTerm(f, 2, es)); + // Yap_PopTermFromDB(info->errorTerm); + // throw throw YAPError( SOURCE(), ); + } +} + +YAPPredicate::YAPPredicate(Term &t, Term &tmod, CELL *&ts, const char *pname) { + Term t0 = t; + ap = nullptr; +restart: + if (IsVarTerm(t)) { + throw YAPError(SOURCE(), INSTANTIATION_ERROR, t0, pname); + } else if (IsAtomTerm(t)) { + ap = RepPredProp(Yap_GetPredPropByAtom(AtomOfTerm(t), tmod)); + ts = nullptr; + } else if (IsIntegerTerm(t) && tmod == IDB_MODULE) { + ts = nullptr; + ap = Yap_FindLUIntKey(IntegerOfTerm(t)); + } else if (IsPairTerm(t)) { + t = Yap_MkApplTerm(FunctorCsult, 1, &t); + goto restart; + } else if (IsApplTerm(t)) { + Functor fun = FunctorOfTerm(t); + if (IsExtensionFunctor(fun)) { + 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); + } + if (!IsAtomTerm(tmod)) { + throw YAPError(SOURCE(), TYPE_ERROR_ATOM, t0, pname); + } + t = ArgOfTerm(2, t); + goto restart; + } + ap = RepPredProp(Yap_GetPredPropByFunc(fun, tmod)); + ts = RepAppl(t) + 1; + } else { + throw YAPError(SOURCE(), TYPE_ERROR_CALLABLE, t0, pname); + } +} + +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; +} + +YAPAtomTerm::YAPAtomTerm(char s[]) { // build string BACKUP_H(); CACHE_REGS seq_tv_t inp, out; + inp.enc = LOCAL_encoding; inp.val.c = s; inp.type = YAP_STRING_CHARS; out.type = YAP_STRING_ATOM; @@ -46,15 +138,15 @@ YAPAtomTerm::YAPAtomTerm(char *s) RECOVER_H(); } -YAPAtomTerm::YAPAtomTerm(char *s, size_t len) -{ // build string +YAPAtomTerm::YAPAtomTerm(char *s, size_t len) { // build string BACKUP_H(); CACHE_REGS seq_tv_t inp, out; inp.val.c = s; inp.type = YAP_STRING_CHARS; - out.type = YAP_STRING_ATOM | YAP_STRING_NCHARS | YAP_STRING_TRUNC; + inp.enc = LOCAL_encoding; + out.type = YAP_STRING_ATOM | YAP_STRING_NCHARS | YAP_STRING_TRUNC; out.max = len; if (Yap_CVT_Text(&inp, &out PASS_REGS)) mk(MkAtomTerm(out.val.a)); @@ -63,8 +155,7 @@ YAPAtomTerm::YAPAtomTerm(char *s, size_t len) RECOVER_H(); } -YAPAtomTerm::YAPAtomTerm(wchar_t *s) : YAPTerm() -{ // build string +YAPAtomTerm::YAPAtomTerm(wchar_t *s) : YAPTerm() { // build string BACKUP_H(); CACHE_REGS @@ -79,8 +170,7 @@ YAPAtomTerm::YAPAtomTerm(wchar_t *s) : YAPTerm() RECOVER_H(); } -YAPAtomTerm::YAPAtomTerm(wchar_t *s, size_t len) : YAPTerm() -{ // build string +YAPAtomTerm::YAPAtomTerm(wchar_t *s, size_t len) : YAPTerm() { // build string BACKUP_H(); CACHE_REGS @@ -96,24 +186,16 @@ YAPAtomTerm::YAPAtomTerm(wchar_t *s, size_t len) : YAPTerm() RECOVER_H(); } -YAPStringTerm::YAPStringTerm(char *s) -{ // build string +YAPStringTerm::YAPStringTerm(char *s) { // build string BACKUP_H(); CACHE_REGS - seq_tv_t inp, out; - inp.val.c = s; - inp.type = YAP_STRING_CHARS; - out.type = YAP_STRING_STRING; - if (Yap_CVT_Text(&inp, &out PASS_REGS)) - mk(out.val.t); - else - t = 0L; + Term ts = MkStringTerm(s); + mk(ts); RECOVER_H(); } -YAPStringTerm::YAPStringTerm(char *s, size_t len) -{ // build string +YAPStringTerm::YAPStringTerm(char *s, size_t len) { // build string BACKUP_H(); CACHE_REGS @@ -130,8 +212,7 @@ YAPStringTerm::YAPStringTerm(char *s, size_t len) RECOVER_H(); } -YAPStringTerm::YAPStringTerm(wchar_t *s) : YAPTerm() -{ // build string +YAPStringTerm::YAPStringTerm(wchar_t *s) : YAPTerm() { // build string BACKUP_H(); CACHE_REGS @@ -148,8 +229,7 @@ YAPStringTerm::YAPStringTerm(wchar_t *s) : YAPTerm() } YAPStringTerm::YAPStringTerm(wchar_t *s, size_t len) - : YAPTerm() -{ // build string + : YAPTerm() { // build string BACKUP_H(); CACHE_REGS @@ -166,80 +246,130 @@ YAPStringTerm::YAPStringTerm(wchar_t *s, size_t len) RECOVER_H(); } -YAPApplTerm::YAPApplTerm(YAPFunctor f, YAPTerm ts[]) : YAPTerm() -{ +YAPApplTerm::YAPApplTerm(YAPFunctor f, YAPTerm ts[]) { BACKUP_H(); arity_t arity = ArityOfFunctor(f.f); - Term *tt = new Term[arity]; + Term o = Yap_MkNewApplTerm(f.f, arity); + Term *tt = RepAppl(o) + 1; for (arity_t i = 0; i < arity; i++) tt[i] = ts[i].term(); - mk(Yap_MkApplTerm(f.f, arity, tt)); - delete[] tt; + mk(o); RECOVER_H(); } -YAPApplTerm::YAPApplTerm(std::string f, std::vector ts) : YAPTerm() -{ +YAPApplTerm::YAPApplTerm(const std::string f, std::vector ts) { + BACKUP_H(); + arity_t arity = ts.size(); + Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity); + Term o = Yap_MkNewApplTerm(ff, arity); + Term *tt = RepAppl(o) + 1; + for (arity_t i = 0; i < arity; i++) + tt[i] = ts[i]; + mk(o); + RECOVER_H(); +} + +YAPApplTerm::YAPApplTerm(const std::string f, std::vector ts) { + BACKUP_H(); + arity_t arity = ts.size(); + Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity); + Term o = Yap_MkNewApplTerm(ff, arity); + Term *tt = RepAppl(o) + 1; + for (arity_t i = 0; i < arity; i++) + tt[i] = ts[i].term(); + mk(o); + RECOVER_H(); +} + +YAPApplTerm::YAPApplTerm(const std::string f, YAPTerm a1) { BACKUP_H(); - arity_t arity = ts.size(); - std::vector tt(arity); - for (arity_t i = 0; i < arity; i++) - tt[i] = ts[i].term(); + arity_t arity = 1; Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity); - t = Yap_MkApplTerm(ff, arity, &tt[0]); - RECOVER_H(); + Term o = Yap_MkNewApplTerm(ff, arity); + Term *tt = RepAppl(o) + 1; + tt[0] = a1.term(); + mk(o); + RECOVER_H(); } -YAPApplTerm::YAPApplTerm(YAPFunctor f) : YAPTerm() -{ +YAPApplTerm::YAPApplTerm(const std::string f, YAPTerm a1, YAPTerm a2) { + BACKUP_H(); + arity_t arity = 2; + Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity); + Term o = Yap_MkNewApplTerm(ff, arity); + Term *tt = RepAppl(o) + 1; + tt[0] = a1.term(); + tt[1] = a2.term(); + mk(o); + RECOVER_H(); +} + +YAPApplTerm::YAPApplTerm(const std::string f, YAPTerm a1, YAPTerm a2, YAPTerm a3) { + BACKUP_H(); + arity_t arity = 3; + Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity); + Term o = Yap_MkNewApplTerm(ff, arity); + Term *tt = RepAppl(o) + 1; + tt[0] = a1.term(); + tt[2] = a2.term(); + tt[3] = a3.term(); + mk(o); + RECOVER_H(); +} + +YAPApplTerm::YAPApplTerm(const std::string f, YAPTerm a1, YAPTerm a2, YAPTerm a3, YAPTerm a4) { + BACKUP_H(); + arity_t arity = 4; + Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity); + Term o = Yap_MkNewApplTerm(ff, arity); + Term *tt = RepAppl(o) + 1; + tt[0] = a1.term(); + tt[2] = a2.term(); + tt[3] = a3.term(); + tt[4] = a4.term(); + mk(o); + RECOVER_H(); +} + +YAPApplTerm::YAPApplTerm(YAPFunctor f) : YAPTerm() { BACKUP_H(); arity_t arity = ArityOfFunctor(f.f); mk(Yap_MkNewApplTerm(f.f, arity)); RECOVER_H(); } -YAPFunctor YAPApplTerm::getFunctor() { return YAPFunctor(FunctorOfTerm(gt())); } - -Term &YAPTerm::operator[](arity_t i) -{ +Term &YAPTerm::operator[](arity_t i) { BACKUP_MACHINE_REGS(); Term t0 = gt(); - Term tf = 0; - if (IsApplTerm(t0)) - { + Term *tf = nullptr; + if (IsApplTerm(t0)) { // Functor f = FunctorOfTerm(t0); // if (IsExtensionFunctor(f)) // return 0; - tf = RepAppl(t0)[(i + 1)]; - } - else if (IsPairTerm(t0)) - { + tf = RepAppl(t0) + (i + 1); + } else if (IsPairTerm(t0)) { if (i == 0) - tf = HeadOfTerm(t0); + tf = RepPair(t0); else if (i == 1) - tf = TailOfTerm(t0); + tf = RepPair(t0) + 1; RECOVER_MACHINE_REGS(); - tf = RepPair(tf)[i]; + } else { + throw YAPError(SOURCE(), TYPE_ERROR_COMPOUND, t0, ""); } RECOVER_MACHINE_REGS(); - Yap_Error(TYPE_ERROR_COMPOUND, tf, ""); - throw YAPError(); + return *tf; } -Term &YAPListTerm::operator[](arity_t i) -{ +Term &YAPListTerm::operator[](arity_t i) { BACKUP_MACHINE_REGS(); Term t0 = gt(); Term tf = 0; - while (IsPairTerm(t0)) - { - if (i == 0) - { + while (IsPairTerm(t0)) { + if (i == 0) { + tf = HeadOfTerm(t0); break; - } - else - { + } else { t0 = TailOfTerm(t0); i--; } @@ -248,29 +378,41 @@ Term &YAPListTerm::operator[](arity_t i) return RepPair(tf)[i]; } -YAPPairTerm::YAPPairTerm(YAPTerm th, YAPTerm tl) -{ +YAPPairTerm::YAPPairTerm(YAPTerm th, YAPTerm tl) { CACHE_REGS BACKUP_H(); mk(MkPairTerm(th.term(), tl.term())); RECOVER_H(); } -YAPPairTerm::YAPPairTerm() -{ +YAPPairTerm::YAPPairTerm() { BACKUP_H(); mk(TermNil); RECOVER_H(); } -YAP_tag_t YAPTerm::tag() -{ +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 = *new 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(); - if (IsVarTerm(tt)) - { + if (IsVarTerm(tt)) { CELL *pt = VarOfTerm(tt); - if (IsUnboundVar(pt)) - { + if (IsUnboundVar(pt)) { CACHE_REGS if (IsAttVar(pt)) return YAP_TAG_ATT; @@ -280,31 +422,23 @@ YAP_tag_t YAPTerm::tag() } if (IsPairTerm(tt)) return YAP_TAG_PAIR; - if (IsAtomOrIntTerm(tt)) - { + if (IsAtomOrIntTerm(tt)) { if (IsAtomTerm(tt)) return YAP_TAG_ATOM; return YAP_TAG_INT; - } - else - { + } else { Functor f = FunctorOfTerm(tt); - if (IsExtensionFunctor(f)) - { - if (f == FunctorDBRef) - { + if (IsExtensionFunctor(f)) { + if (f == FunctorDBRef) { return YAP_TAG_DBREF; } - if (f == FunctorLongInt) - { + if (f == FunctorLongInt) { return YAP_TAG_LONG_INT; } - if (f == FunctorBigInt) - { + if (f == FunctorBigInt) { big_blob_type bt = (big_blob_type)RepAppl(tt)[1]; - switch (bt) - { + switch (bt) { case BIG_INT: return YAP_TAG_BIG_INT; case BIG_RATIONAL: @@ -318,8 +452,7 @@ YAP_tag_t YAPTerm::tag() } } -Term YAPTerm::deepCopy() -{ +Term YAPTerm::deepCopy() { yhandle_t tn; BACKUP_MACHINE_REGS(); @@ -329,8 +462,17 @@ Term YAPTerm::deepCopy() return (tn); } -Term YAPListTerm::dup() -{ +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 YAPListTerm::dup() { yhandle_t tn; BACKUP_MACHINE_REGS(); @@ -340,8 +482,7 @@ Term YAPListTerm::dup() return tn; } -intptr_t YAPTerm::numberVars(intptr_t i0, bool skip_singletons) -{ +intptr_t YAPTerm::numberVars(intptr_t i0, bool skip_singletons) { BACKUP_MACHINE_REGS(); intptr_t i = Yap_NumberVars(gt(), i0, skip_singletons); @@ -352,8 +493,7 @@ intptr_t YAPTerm::numberVars(intptr_t i0, bool skip_singletons) const char *YAPQuery::text() { return YAPTerm(goal).text(); } -YAPIntegerTerm::YAPIntegerTerm(intptr_t i) -{ +YAPIntegerTerm::YAPIntegerTerm(intptr_t i) { CACHE_REGS Term tn = MkIntegerTerm(i); mk(tn); } @@ -369,287 +509,216 @@ YAPTerm *YAPTerm::vars() } */ -YAPTerm::YAPTerm(void *ptr) -{ +YAPTerm::YAPTerm(void *ptr) { CACHE_REGS mk(MkIntegerTerm((Int)ptr)); } -Term YAPListTerm::car() -{ +Term YAPListTerm::car() { Term to = gt(); if (IsPairTerm(to)) return (HeadOfTerm(to)); - else - { - Yap_Error(TYPE_ERROR_LIST, to, ""); - throw YAPError(); + else { + throw YAPError(SOURCE(), TYPE_ERROR_LIST, to, ""); + return TermUnique; } } -YAPListTerm::YAPListTerm(YAPTerm ts[], arity_t n) -{ +YAPListTerm::YAPListTerm(YAPTerm ts[], arity_t n) { CACHE_REGS BACKUP_H(); if (n == 0) t = TermNil; - while (HR + n * 2 > ASP - 1024) - { + while (HR + n * 2 > ASP - 1024) { RECOVER_H(); - if (!Yap_dogc(0, NULL PASS_REGS)) - { + if (!Yap_dogc(0, NULL PASS_REGS)) { t = TermNil; } BACKUP_H(); } t = AbsPair(HR); - for (arity_t i = 0; i < n; i++) - { + for (arity_t i = 0; i < n; i++) { HR[2 * i] = ts[i].gt(); HR[2 * i + 1] = AbsPair(HR + (2 * i + 2)); } } -YAPVarTerm::YAPVarTerm() -{ +const char *YAPAtom::getName(void) { return Yap_AtomToUTF8Text(a); } + +void YAPQuery::openQuery() { CACHE_REGS - mk(MkVarTerm()); + if (ap == NULL || ap->OpcodeOfPred == UNDEF_OPCODE) { + ap = rewriteUndefQuery(); + } + setNext(); } -const char *YAPAtom::getName(void) { return Yap_AtomToUTF8Text(a, nullptr); } - -void YAPQuery::openQuery(Term t) -{ +bool YAPEngine::call(YAPPredicate ap, YAPTerm ts[]) { CACHE_REGS + if (ap.ap == NULL) + return false; + BACKUP_MACHINE_REGS(); + arity_t arity = ap.getArity(); + bool result; + YAP_dogoalinfo q; + + q.CurSlot = Yap_StartSlots(); + q.p = P; + + q.cp = CP; + for (arity_t i = 0; i < arity; i++) + XREGS[i + 1] = ts[i].term(); + + // allow Prolog style exceotion handling + // don't forget, on success these bindings will still be there); + result = YAP_LeaveGoal(true, &q); + + YAPCatchError(); + + Yap_CloseHandles(q.CurSlot); + pop_text_stack(q.lvl + 1); + + RECOVER_MACHINE_REGS(); + return result; +} + +bool YAPEngine::mgoal(Term t, Term tmod, bool release) { +#if YAP_PYTHON + // std::cerr << "mgoal(in) " << YAPTerm(tmod).text() << ":" << YAPTerm(t).text() << "\n"; + // PyThreadState *_save; + + // std::cerr << "mgoal " << YAPTerm(t).text() << "\n"; + // _save = PyEval_SaveThread(); +#endif + CACHE_REGS + BACKUP_MACHINE_REGS(); + Term *ts = nullptr; + q.CurSlot = Yap_StartSlots(); + q.p = P; + q.cp = CP; + PredEntry *ap = nullptr; + if (IsStringTerm(tmod)) + tmod = MkAtomTerm(Yap_LookupAtom(StringOfTerm(tmod))); + YAPPredicate *p = new YAPPredicate(t, tmod, ts, "C++"); + if (p == nullptr || (ap = p->ap) == nullptr || + ap->OpcodeOfPred == UNDEF_OPCODE) { + ap = rewriteUndefEngineQuery(ap, t, tmod); + } + if (IsApplTerm(t)) + ts = RepAppl(t) + 1; + else if (IsPairTerm(t)) + ts = RepPair(t); + /* legal ap */ arity_t arity = ap->ArityOfPE; - if (arity) - { - Term *ts; - if (IsPairTerm(t)) - { - ts = RepPair(t); - } - else - { - ts = RepAppl(t) + 1; - } - for (arity_t i = 0; i < arity; i++) - { - XREGS[i + 1] = ts[i]; - } - } - // oq = LOCAL_execution; - // LOCAL_execution = this; - q_open = true; - q_state = 0; - q_flags = true; // PL_Q_PASS_EXCEPTION; - q_p = P; - q_cp = CP; - // make sure this is safe - q_handles = LOCAL_CurSlot; + for (arity_t i = 0; i < arity; i++) { + XREGS[i + 1] = ts[i]; + } + ts = nullptr; + bool result; + // 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); + // std::cerr << "mgoal " << YAPTerm(tmod).text() << ":" << YAPTerm(t).text() << "\n"; + + YAP_LeaveGoal(result && !release, &q); + // PyEval_RestoreThread(_save); + RECOVER_MACHINE_REGS(); + return result; } - -bool YAPEngine::call(YAPPredicate ap, YAPTerm ts[]) -{ - try - { - CACHE_REGS - if (ap.ap == NULL) - return false; - BACKUP_MACHINE_REGS(); - arity_t arity = ap.getArity(); - bool result; - YAP_dogoalinfo q; - sigjmp_buf q_env; - - for (arity_t i = 0; i < arity; i++) - XREGS[i + 1] = ts[i].term(); - q.CurSlot = Yap_StartSlots(); - q.p = P; - q.cp = CP; - // allow Prolog style exceotion handling - LOCAL_RestartEnv = &q_env; - if (sigsetjmp(q_env, false)) - { - throw YAPError(); - } - // don't forget, on success these bindings will still be there); - result = YAP_LeaveGoal(false, &q); - Yap_CloseHandles(q.CurSlot); - RECOVER_MACHINE_REGS(); - return result; - } - catch (YAPError e) - { - YAP_LeaveGoal(false, &q); - Yap_CloseHandles(q.CurSlot); - std::cerr << "Exception received by " << YAPApplTerm(ap.functor(), ts).text() << ".\n Forwarded...\n\n"; - throw e; - } -} - -bool YAPEngine::mgoal(Term t, Term tmod) -{ - try - { - CACHE_REGS - BACKUP_MACHINE_REGS(); - Term *ts = nullptr; - PredEntry *ap = Yap_get_pred(t, tmod, "C++"); - if (ap == nullptr) - return false; - arity_t arity = ap->ArityOfPE; - bool result; - sigjmp_buf q_env; - - - if (arity) { - if (IsApplTerm(t)) - { - ts = RepAppl(t) + 1; - } - else - { - ts = RepPair(t); - } - for (arity_t i = 0; i < arity; i++) - XREGS[i + 1] = ts[i]; - } else if ( IsAtomTerm(t)) { - ts = nullptr; - } - q.CurSlot = Yap_StartSlots(); - q.p = P; - q.cp = CP; - // allow Prolog style exceotion handling - LOCAL_RestartEnv = &q_env; - if (sigsetjmp(q_env, false)) - { - throw YAPError(); - } - // 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); - // fprintf(stderr,"in");Yap_DebugPlWrite(t); - { - YAP_LeaveGoal(false, &q); - RECOVER_MACHINE_REGS(); - return result; - } - } - catch (YAPError e) - { - YAP_LeaveGoal(false, &q); - Yap_CloseHandles(q.CurSlot); - throw e; - } -} - -void YAPEngine::release() -{ +/** + * called when a query must be terminated and its state fully recovered, + * @type {[type]} + */ +void YAPEngine::release() { BACKUP_MACHINE_REGS(); YAP_LeaveGoal(FALSE, &q); RECOVER_MACHINE_REGS(); } -YAPTerm YAPEngine::fun(YAPTerm t) -{ - return YAPTerm(fun(t.term())); -} - -Term YAPEngine::fun(Term t) -{ +Term YAPEngine::fun(Term t) { CACHE_REGS - try - { - BACKUP_MACHINE_REGS(); - Term tmod = CurrentModule, *ts = nullptr; - PredEntry *ap; - arity_t arity; - Functor f; - sigjmp_buf q_env; - Atom name; + BACKUP_MACHINE_REGS(); + Term tmod = Yap_CurrentModule(), *ts = nullptr; + PredEntry *ap; + arity_t arity; + Functor f; + Atom name; - BACKUP_MACHINE_REGS(); - fprintf(stderr," ++++ "); - Yap_DebugPlWriteln(t); - fprintf(stderr," ++++\n"); - t = Yap_StripModule(t, &tmod); - if (IsApplTerm(t)) - { - ts = RepAppl(t) + 1; - f = (Functor)ts[-1]; - name = NameOfFunctor(f); - arity = ArityOfFunctor(f); - for (arity_t i = 0; i < arity; i++) - XREGS[i + 1] = ts[i]; - } - else if (IsAtomTerm(t)) - { - name = AtomOfTerm(t); - f = nullptr; - arity = 0; - } - else if (IsPairTerm(t)) - { - XREGS[1] = ts[0]; - XREGS[2] = ts[1]; - arity = 2; - name = AtomDot; - f = FunctorDot; - } - else - { - Yap_ThrowError(TYPE_ERROR_CALLABLE, t, 0); - return 0L; - } - XREGS[arity + 1] = MkVarTerm(); - arity++; - f = Yap_MkFunctor(name, arity); - ap = (PredEntry *)(PredPropByFunc(f, tmod)); - q.CurSlot = Yap_StartSlots(); - q.p = P; - q.cp = CP; - // make sure this is safe - yhandle_t o = Yap_InitHandle(XREGS[arity]); - // allow Prolog style exceotion handling - LOCAL_RestartEnv = &q_env; - if (sigsetjmp(q_env, false)) - { - throw YAPError(); - } - // don't forget, on success these guys may create slots - __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "exec "); - - if (YAP_EnterGoal(ap, nullptr, &q) == 0) - return 0; - XREGS[arity] = Yap_GetFromSlot(o); - __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "out %ld", o); - YAP_LeaveGoal(false, &q); - Yap_CloseHandles(q.CurSlot); - RECOVER_MACHINE_REGS(); - return XREGS[arity]; - Yap_DebugPlWriteln(XREGS[arity]); + if (IsApplTerm(t)) { + ts = RepAppl(t) + 1; + f = (Functor)ts[-1]; + name = NameOfFunctor(f); + arity = ArityOfFunctor(f); + for (arity_t i = 0; i < arity; i++) + XREGS[i + 1] = ts[i]; + } else if (IsAtomTerm(t)) { + name = AtomOfTerm(t); + f = nullptr; + arity = 0; + } else if (IsPairTerm(t)) { + XREGS[1] = ts[0]; + XREGS[2] = ts[1]; + arity = 2; + name = AtomDot; + f = FunctorDot; + } else { + throw YAPError(SOURCE(), TYPE_ERROR_CALLABLE, t, 0); + return 0L; } - catch (YAPError e) + Term ot = XREGS[arity + 1] = MkVarTerm(); + yhandle_t h = Yap_InitHandle(ot); + arity++; + HR += arity; + f = Yap_MkFunctor(name, arity); + ap = (PredEntry *)(PredPropByFunc(f, tmod)); + if (ap == nullptr || ap->OpcodeOfPred == UNDEF_OPCODE) { + Term g = (Yap_MkApplTerm(f, arity, ts)); + ap = rewriteUndefEngineQuery(ap, g, (ap->ModuleOfPred)); + } + q.CurSlot = Yap_StartSlots(); + q.p = P; + q.cp = CP; + // make sure this is safe + // allow Prolog style exception handling + //__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "exec "); + + bool result = (bool)YAP_EnterGoal(ap, nullptr, &q); + if (result) + ot = Yap_GetFromHandle(h); + else + ot = TermNone; + YAPCatchError(); { - YAP_LeaveGoal(false, &q); - Yap_CloseHandles(q.CurSlot); - std::cerr << "Exception received by " << __func__ << "( " << YAPTerm(t).text() << ").\n Forwarded..."; - throw e; + YAP_LeaveGoal(result, &q); + // PyEval_RestoreThread(_save); + RECOVER_MACHINE_REGS(); + return ot; } } YAPQuery::YAPQuery(YAPFunctor f, YAPTerm mod, YAPTerm ts[]) - : YAPPredicate(f, mod) -{ + : YAPPredicate(f, mod) { + /* ignore flags for now */ BACKUP_MACHINE_REGS(); - goal = YAPApplTerm(f, ts); - names = YAPPairTerm( TermNil ); - openQuery(goal.term()); + Term goal; + + if (ts) { + + goal = YAPApplTerm(f, ts).term(); + nts = RepAppl(goal) + 1; + size_t arity = f.arity(); + for (arity_t i = 0; i < arity; i++) + XREGS[i + 1] = nts[i]; + } else { + goal = MkVarTerm(); + } + openQuery(); + names = YAPPairTerm(TermNil); RECOVER_MACHINE_REGS(); } @@ -657,109 +726,96 @@ YAPQuery::YAPQuery(YAPFunctor f, YAPTerm mod, YAPTerm ts[]) YAPQuery::YAPQuery(YAPFunctor f, YAPTerm ts[]) : YAPPredicate(f) { /* ignore flags for now */ BACKUP_MACHINE_REGS(); - goal = YAPTerm( YAPApplTerm(f, ts).gt() ); - names.= YAPPairTerm( TermNil ); - openQuery(goal.term()); + if (ts) { +goal = YAPApplTerm(f, nts); + } else { + goal = YAPVarTerm(); + nts = nullptr; + } + names = YAPPairTerm( TermNil ); + openQuery(term(), nts); RECOVER_MACHINE_REGS(); } #endif -YAPQuery::YAPQuery(YAPPredicate p, YAPTerm ts[]) : YAPPredicate(p.ap) -{ +YAPQuery::YAPQuery(YAPPredicate p, YAPTerm ts[]) : YAPPredicate(p.ap) { BACKUP_MACHINE_REGS(); - goal = YAPApplTerm(YAPFunctor(p.ap->FunctorOfPred), ts); - names = YAPPairTerm( TermNil ); - openQuery(goal.term()); + try { + arity_t arity = p.ap->ArityOfPE; + if (arity) { + goal = YAPApplTerm(YAPFunctor(p.ap->FunctorOfPred), ts).term(); + for (arity_t i = 0; i < arity; i++) + XREGS[i + 1] = ts[i].term(); + openQuery(); + } else { + goal = MkAtomTerm((Atom)(p.ap->FunctorOfPred)); + openQuery(); + } + names = TermNil; + } catch (...) { + } RECOVER_MACHINE_REGS(); } -bool YAPQuery::next() -{ +bool YAPQuery::next() { CACHE_REGS - bool result; - Term terr; - LOCAL_RestartEnv = &q_env; - try - { - BACKUP_MACHINE_REGS(); - if (!q_open) - return false; - if (sigsetjmp(q_env, false)) - { - throw YAPError(); - } - // don't forget, on success these guys may create slots - __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "exec "); + bool result = false; + // std::cerr << "next " << YAPTerm(goal).text() << "\n"; - if (q_state == 0) - { - result = (bool)YAP_EnterGoal(ap, nullptr, &q_h); - } - else - { - LOCAL_AllowRestart = q_open; - result = (bool)YAP_RetryGoal(&q_h); - } - if (result) - { - __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "vnames %d %s %ld", - q_state, vnames.text(), LOCAL_CurSlot); - } - else - { - __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "fail"); - } - q_state = 1; - if ((terr = Yap_GetException())) - { - if ((terr = Yap_GetException())) - { - throw YAPError(); - } - } - __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "out %d", result); + sigjmp_buf buf, *oldp = LOCAL_RestartEnv; + e = nullptr; + BACKUP_MACHINE_REGS(); + if (!q_open) + return false; + LOCAL_RestartEnv = &buf; + // don't forget, on success these guys may create slots + __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "exec "); - if (!result) - { - YAP_LeaveGoal(false, &q_h); - Yap_CloseHandles(q_handles); - q_open = false; - } - else - { - q_handles = Yap_StartSlots(); - } - RECOVER_MACHINE_REGS(); - return result; + if (q_state == 0) { + // Yap_do_low_level_trace = 1; + result = (bool)YAP_EnterGoal(ap, nullptr, &q_h); + } else { + LOCAL_AllowRestart = q_open; + result = (bool)YAP_RetryGoal(&q_h); } - catch (YAPError e) - { + q_state = 1; + __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "out %d", result); + if (!result) { + YAP_LeaveGoal(result, &q_h); q_open = false; - Yap_PopTermFromDB(LOCAL_ActiveError->errorTerm); - memset(LOCAL_ActiveError, 0, sizeof(*LOCAL_ActiveError)); - YAP_LeaveGoal(false, &q_h); - Yap_CloseHandles(q_handles); - q_open = false; - std::cerr << "Exception received by " << __func__ << "( " << YAPTerm(terr).text() << ").\n Forwarded...\n\n"; - throw e; } + YAPCatchError(); + RECOVER_MACHINE_REGS(); + LOCAL_RestartEnv = oldp; + return result; } -void YAPQuery::cut() -{ +PredEntry *YAPQuery::rewriteUndefQuery() { + ARG1 = goal = Yap_SaveTerm(Yap_MkApplTerm(FunctorCall, 1, &goal)); + return ap = PredCall; +} + +PredEntry *YAPEngine::rewriteUndefEngineQuery(PredEntry *a, Term &tgoal, + Term mod) { + tgoal = Yap_MkApplTerm(FunctorCall, 1, &tgoal); + return PredCall; + + // return YAPApplTerm(FunctorUndefinedQuery, ts); +} + +void YAPQuery::cut() { CACHE_REGS BACKUP_MACHINE_REGS(); if (!q_open || q_state == 0) return; - YAP_LeaveGoal(FALSE, &q_h); - q_open = 0; + YAP_LeaveGoal(true, &q_h); + q_open = false; // LOCAL_execution = this; RECOVER_MACHINE_REGS(); } -bool YAPQuery::deterministic() -{ +bool YAPQuery::deterministic() { CACHE_REGS BACKUP_MACHINE_REGS(); @@ -772,27 +828,23 @@ bool YAPQuery::deterministic() YAPTerm YAPQuery::getTerm(yhandle_t t) { return YAPTerm(t); } -void YAPQuery::close() -{ +void YAPQuery::close() { CACHE_REGS RECOVER_MACHINE_REGS(); Yap_ResetException(worker_id); /* need to implement backtracking here */ - if (q_open != true || q_state == 0) - { + if (q_open != true || q_state == 0) { RECOVER_MACHINE_REGS(); return; } - YAP_LeaveGoal(FALSE, &q_h); + YAP_LeaveGoal(false, &q_h); q_open = 0; Yap_CloseHandles(q_handles); // LOCAL_execution = this; RECOVER_MACHINE_REGS(); } -static YAPEngine *curren; - #if __ANDROID__ #include @@ -802,11 +854,9 @@ JNIEnv *Yap_jenv; extern JNIEXPORT jint JNICALL JNI_MySQLOnLoad(JavaVM *vm, void *reserved); -JNIEXPORT jint JNICALL JNI_MySQLOnLoad(JavaVM *vm, void *reserved) -{ +JNIEXPORT jint JNICALL JNI_MySQLOnLoad(JavaVM *vm, void *reserved) { JNIEnv *env; - if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) - { + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { return -1; } Yap_jenv = env; @@ -820,173 +870,121 @@ static size_t Yap_AndroidMax, Yap_AndroidSz; extern void (*Yap_DisplayWithJava)(int c); -void Yap_displayWithJava(int c) -{ +static YAPCallback *cb = new YAPCallback(); + +void Yap_displayWithJava(int c) { char *ptr = Yap_AndroidBufp; if (!ptr) ptr = Yap_AndroidBufp = (char *)malloc(Yap_AndroidSz); ptr[Yap_AndroidSz++] = c; - if (Yap_AndroidMax - 1 == Yap_AndroidSz) - { - if (Yap_AndroidMax < 32 * 1024) - { + if (Yap_AndroidMax - 1 == Yap_AndroidSz) { + if (Yap_AndroidMax < 32 * 1024) { Yap_AndroidMax *= 2; - } - else - { + } else { Yap_AndroidMax += 32 * 1024; } Yap_AndroidBufp = (char *)realloc(ptr, Yap_AndroidMax); } Yap_AndroidBufp[Yap_AndroidSz] = '\0'; - if (c == '\n') - { + if (c == '\n') { Yap_AndroidBufp[Yap_AndroidSz] = '\0'; - curren->run(Yap_AndroidBufp); + cb->run(Yap_AndroidBufp); Yap_AndroidSz = 0; } } #endif -void YAPEngineArgs::fetch_defaults() -{ - Yap_InitDefaults(&init_args, NULL, 0, NULL); +void YAPEngine::doInit(YAP_file_type_t BootMode, YAPEngineArgs *engineArgs) { + if (BootMode == YAP_FOUND_BOOT_ERROR) { + std::cerr << "Exception received by " << __func__ << "( " + << "while booting" + << ").\n Forwarded...\n\n"; + return; + } + YAP_Init(engineArgs); +/* Begin preprocessor code */ +/* live */ +// yerror = throw YAPError( SOURCE(), ); #if YAP_PYTHON - init_args.Embedded = true; - python_in_python = Py_IsInitialized(); + do_init_python(); #endif -} - -void YAPEngine::doInit(YAP_file_type_t BootMode) -{ - - if ((BootMode = YAP_Init(&engine_args.init_args)) == YAP_FOUND_BOOT_ERROR) - { - throw YAPError(); - } - /* Begin preprocessor code */ - /* live */ - __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "$init_system"); -#if __ANDROID__ - Yap_AndroidBufp = (char *)malloc(Yap_AndroidMax = 4096); - Yap_AndroidBufp[0] = '\0'; - Yap_AndroidSz = 0; -#endif - yerror = YAPError(); - -#ifdef YAP_PYTHON - init_python(); -#endif - YAPQuery initq = YAPQuery(YAPAtom("$init_system")); - if (initq.next()) - { - initq.cut(); - } - else - { - // should throw exception - } -} - -YAPEngine::YAPEngine(YAPEngineArgs &argp) - : _callback(0) -{ // a single engine can be active - - engine_args = argp; - YAP_file_type_t BootMode; - __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "YAP %s ", bootFile); - - // delYAPCallback()b - // if (cb) - // setYAPCallback(cb); - curren = this; - BootMode = engine_args.init_args.boot_file_type; - doInit(BootMode); - + // std::string s = "initialize_prolog"; + // YAPPredicate p = YAPPredicate(MkAtomTerm(Yap_LookupAtom(s.c_str()))); + // YAPQuery initq = YAPQuery(YAPPredicate(p), nullptr); + // if (initq.next()) { + // initq.cut(); + // } + CurrentModule = TermUser; } YAPEngine::YAPEngine(int argc, char *argv[], YAPCallback *cb) - : _callback(0) -{ // a single engine can be active + : _callback(0) { // a single engine can be active - engine_args = YAPEngineArgs(); YAP_file_type_t BootMode; - BootMode = YAP_parse_yap_arguments(argc, argv, &engine_args.init_args); + engine_args = new YAPEngineArgs(); + BootMode = YAP_parse_yap_arguments(argc, argv, engine_args); // delYAPCallback()b // if (cb) // setYAPCallback(cb); - curren = this; - doInit(BootMode); + + doInit(BootMode, engine_args); } -YAPPredicate::YAPPredicate(YAPAtom at) -{ +YAPPredicate::YAPPredicate(YAPAtom at) { CACHE_REGS ap = RepPredProp(PredPropByAtom(at.a, Yap_CurrentModule())); } -YAPPredicate::YAPPredicate(YAPAtom at, uintptr_t arity) -{ +YAPPredicate::YAPPredicate(YAPAtom at, uintptr_t arity) { CACHE_REGS - if (arity) - { + if (arity) { Functor f = Yap_MkFunctor(at.a, arity); ap = RepPredProp(PredPropByFunc(f, Yap_CurrentModule())); - } - else - { + } else { ap = RepPredProp(PredPropByAtom(at.a, Yap_CurrentModule())); } } /// auxiliary routine to find a predicate in the current module. -PredEntry *YAPPredicate::getPred(YAPTerm &tt, Term *&outp) -{ +PredEntry *YAPPredicate::getPred(Term &t, Term &m, CELL *&out) { CACHE_REGS - Term m = Yap_CurrentModule(), t = tt.term(); t = Yap_StripModule(t, &m); - if (IsVarTerm(t) || IsNumTerm(t)) - { + + if (IsVarTerm(t) || IsNumTerm(t)) { if (IsVarTerm(t)) - Yap_ThrowError(INSTANTIATION_ERROR, tt.term(), 0); + throw YAPError(SOURCE(), INSTANTIATION_ERROR, t, 0); else if (IsNumTerm(t)) - Yap_ThrowError(TYPE_ERROR_CALLABLE, tt.term(), 0); - throw YAPError(); + throw YAPError(SOURCE(), TYPE_ERROR_CALLABLE, t, 0); } - tt.put(t); - if (IsAtomTerm(t)) - { + if (IsAtomTerm(t)) { ap = RepPredProp(PredPropByAtom(AtomOfTerm(t), m)); - outp = (Term *)NULL; return ap; - } - else if (IsPairTerm(t)) - { - Term ts[2]; - ts[0] = t; - ts[1] = m; - t = Yap_MkApplTerm(FunctorCsult, 2, ts); - tt.put(t); - outp = RepAppl(t) + 1; + } else if (IsPairTerm(t)) { + Term ts[2], *s = (out ? out : ts); + Functor FunctorConsult = Yap_MkFunctor(Yap_LookupAtom("consult"), 1); + s[1] = t; + s[0] = m; + t = Yap_MkApplTerm(FunctorModule, 2, s); + t = Yap_MkApplTerm(FunctorConsult, 1, &t); + if (!out) + out = RepAppl(t) + 1; } Functor f = FunctorOfTerm(t); - if (IsExtensionFunctor(f)) - { - Yap_ThrowError(TYPE_ERROR_CALLABLE, t, 0); - } - else - { + if (IsExtensionFunctor(f)) { + throw YAPError(SOURCE(), TYPE_ERROR_CALLABLE, t, 0); + } else { ap = RepPredProp(PredPropByFunc(f, m)); - outp = RepAppl(t) + 1; + if (out) + memmove(out, (const CELL *)RepAppl(t) + 1, ap->ArityOfPE * sizeof(CELL)); + else + out = RepAppl(t) + 1; } return ap; } -X_API bool YAPPrologPredicate::assertClause(YAPTerm cl, bool last, - YAPTerm source) -{ +bool YAPPrologPredicate::assertClause(YAPTerm cl, bool last, YAPTerm source) { CACHE_REGS RECOVER_MACHINE_REGS(); @@ -997,25 +995,23 @@ X_API bool YAPPrologPredicate::assertClause(YAPTerm cl, bool last, sourcet = source.gt(); else sourcet = TermZERO; - yamop *codeaddr = Yap_cclause(tt, ap->ArityOfPE, Yap_CurrentModule(), - sourcet); /* vsc: give the number of arguments - to cclause in case there is overflow */ - if (LOCAL_ErrorMessage) - { + yamop *codeaddr = + Yap_cclause(tt, ap->ArityOfPE, Yap_CurrentModule(), + sourcet); /* vsc: give the number of arguments + to cclause in case there is overflow */ + if (LOCAL_ErrorMessage) { RECOVER_MACHINE_REGS(); return false; } Term *tref = &ntt; if (Yap_addclause(ntt, codeaddr, (last ? TermAssertz : TermAsserta), - Yap_CurrentModule(), tref)) - { + Yap_CurrentModule(), tref)) { RECOVER_MACHINE_REGS(); } return tref; } -bool YAPPrologPredicate::assertFact(YAPTerm *cl, bool last) -{ +bool YAPPrologPredicate::assertFact(YAPTerm *cl, bool last) { CACHE_REGS arity_t i; RECOVER_MACHINE_REGS(); @@ -1025,98 +1021,111 @@ bool YAPPrologPredicate::assertFact(YAPTerm *cl, bool last) *HR++ = cl->gt(); yamop *codeaddr = Yap_cclause(tt, ap->ArityOfPE, Yap_CurrentModule(), tt); /* vsc: give the number of arguments - to cclause in case there is overflow */ - if (LOCAL_ErrorMessage) - { + to cclause in case there is overflow */ + if (LOCAL_ErrorMessage) { RECOVER_MACHINE_REGS(); return false; } Term *tref = &tt; if (Yap_addclause(tt, codeaddr, (last ? TermAssertz : TermAsserta), - Yap_CurrentModule(), tref)) - { + Yap_CurrentModule(), tref)) { RECOVER_MACHINE_REGS(); } return tref; } -void *YAPPrologPredicate::retractClause(YAPTerm skeleton, bool all) -{ +void *YAPPrologPredicate::retractClause(YAPTerm skeleton, bool all) { return 0; } -std::string YAPError::text() -{ - char buf[256]; - std::string s = ""; - if (LOCAL_ActiveError->errorFunction) - { - s += LOCAL_ActiveError->errorFile; +std::string YAPError::text() { + + return "Error"; +#if 0 +std::stringstream s; + s << ""; + if (info->errorNo == YAP_NO_ERROR) + return 0; + if (info->errorFunction) { + s += info->errorFile; s += ":"; - sprintf(buf, "%ld", (long int)LOCAL_ActiveError->errorLine); + sprintf(buf, "%ld", (long int)info->errorLine); s += buf; s += ":0 in C-code"; } - if (LOCAL_ActiveError->prologPredLine) - { + return s; + if (info->prologPredLine) { s += "\n"; - s += LOCAL_ActiveError->prologPredFile->StrOfAE; + s += info->prologPredFile; s += ":"; - sprintf(buf, "%ld", (long int)LOCAL_ActiveError->prologPredLine); - s += buf; // std::to_string(LOCAL_ActiveError->prologPredLine) ; - // YAPIntegerTerm(LOCAL_ActiveError->prologPredLine).text(); + s << info->prologPredLine; + // YAPIntegerTerm(info->prologPredLine).text(); s += ":0 "; - s += LOCAL_ActiveError->prologPredModule; + s += info->prologPredModule; s += ":"; - s += (LOCAL_ActiveError->prologPredName)->StrOfAE; + s += (info->prologPredName); s += "/"; - sprintf(buf, "%ld", (long int)LOCAL_ActiveError->prologPredArity); - s += // std::to_string(LOCAL_ActiveError->prologPredArity); - buf; + s << info->prologPredArity; } s += " error "; - if (LOCAL_ActiveError->classAsText != nullptr) - s += LOCAL_ActiveError->classAsText->StrOfAE; + if (info->classAsText == nullptr) + info->classAsText = Yap_errorClassName(info->errorClass); + if (info->classAsText != nullptr) + s += info->classAsText; s += "."; - s += LOCAL_ActiveError->errorAsText->StrOfAE; + if (info->errorAsText == nullptr) + info->errorAsText = Yap_errorName(info->errorNo); + if (info->errorAsText != nullptr) + s += info->errorAsText; s += ".\n"; - if (LOCAL_ActiveError->errorTerm) - { - Term t = LOCAL_ActiveError->errorTerm->Entry; - if (t) - { - s += "error term is: "; - s += YAPTerm(t).text(); - s += "\n"; - } - } - printf("%s\n", s.c_str()); + // printf("%s\n", s.c_str()); return s.c_str(); +#endif } -void YAPEngine::reSet() -{ +void YAPEngine::reSet() { /* ignore flags for now */ - BACKUP_MACHINE_REGS(); - Yap_RebootHandles(worker_id); - while (B->cp_b) - B = B->cp_b; - P = FAILCODE; - Yap_exec_absmi(true, YAP_EXEC_ABSMI); - /* recover stack space */ - HR = B->cp_h; - TR = B->cp_tr; -#ifdef DEPTH_LIMIT - DEPTH = B->cp_depth; -#endif /* DEPTH_LIMIT */ - YENV = ENV = B->cp_env; - - RECOVER_MACHINE_REGS(); + if (B && B->cp_b && B->cp_ap != NOCODE) + YAP_LeaveGoal(false, &q); + LOCAL_ActiveError->errorNo = YAP_NO_ERROR; + if (LOCAL_CommittedError) { + LOCAL_CommittedError->errorNo = YAP_NO_ERROR; + free(LOCAL_CommittedError); + LOCAL_CommittedError = NULL; + } } -YAPError::YAPError(yap_error_number id, YAPTerm culprit, std::string txt) -{ - ID = id; - goal = culprit.text(); - info = txt; +Term YAPEngine::top_level(std::string s) { + /// parse string s and make term with var names + /// available. + Term tp; + ARG1 = YAP_ReadBuffer(s.data(), &tp); + ARG2 = tp; + ARG3 = MkVarTerm(); + if (ARG1 == 0) + throw YAPError(SOURCE(), SYNTAX_ERROR, ARG1, "in input query"); + YAPPredicate p = YAPPredicate(YAP_TopGoal()); + YAPQuery *Q = new YAPQuery(p, 0); + Term ts[2]; + ts[0] = MkAddressTerm(Q); + if (Q->next()) { + ts[1] = ARG3; + } else { + ts[1] = TermNil; + } + return YAP_MkApplTerm(YAP_MkFunctor(YAP_LookupAtom("t"), 2), 2, ts); +} + +Term YAPEngine::next_answer(YAPQuery *&Q) { + + /// parse string s and make term with var names + /// available. + Term ts[2]; + ts[0] = MkAddressTerm(Q); + if (Q->next()) { + ts[1] = ARG3; + } else { + ts[1] = TermNil; + } + return YAP_MkApplTerm(YAP_MkFunctor(YAP_LookupAtom("t"), 2), 2, ts); } diff --git a/CXX/yapi.hh b/CXX/yapi.hh old mode 100644 new mode 100755 index a4b840ef8..794e5af61 --- a/CXX/yapi.hh +++ b/CXX/yapi.hh @@ -1,24 +1,33 @@ + /** - @file yapi,hh + @file yapi.hh @brief entry file for the YAP C++ interface */ - #define YAP_CPP_INTERFACE 1 -#include -#include -#include #include +#include +#include + +extern "C"{ +#include "config.h" +} + +#if HAVE_GMPXX_H +#include +#elif HAVE_GMP_H +#include +#endif /*! * - * @ingroup fli_c_cx + * @ingroup fli_c_cxx * @defgroup yap-cplus-interface An object oriented interface for YAP. * - * @{ + * @{ * * * @brief C++ wrapper to terms, predicates and queries @@ -29,18 +38,27 @@ * interface. * */ -#include -#include +extern "C" { + + + +#include // Bad export from Python #include -extern "C" { - #include + +#if YAP_PYTHON + +#include + +extern bool python_in_python; +#endif + #include "Yap.h" #include "Yatom.h" @@ -70,21 +88,35 @@ extern "C" { #endif #if _MSC_VER || defined(__MINGW32__) - //#include +//#include #endif - - // taken from yap_structs.h +// taken from yap_structs.h #include "iopreds.h" - X_API void YAP_UserCPredicate(const char *, YAP_UserCPred, YAP_Arity arity); +X_API extern void YAP_UserCPredicate(const char *, YAP_UserCPred, + YAP_Arity arity); - /* void UserCPredicateWithArgs(const char *name, int *fn(), unsigned int arity) - */ - X_API void YAP_UserCPredicateWithArgs(const char *, YAP_UserCPred, YAP_Arity, - YAP_Term); +/* extern void UserCPredicateWithArgs(const char *name, int *fn(), unsigned int + * arity) + */ +X_API extern void YAP_UserCPredicateWithArgs(const char *, YAP_UserCPred, + YAP_Arity, YAP_Term); + +X_API extern void YAP_UserBackCPredicate(const char *name, + YAP_UserCPred init, + YAP_UserCPred cont, + YAP_Arity arity, YAP_Arity extra); + +X_API extern void YAP_UserBackCutCPredicate(const char *name, + YAP_UserCPred init, + YAP_UserCPred cont, + YAP_UserCPred cut, + YAP_Arity arity, YAP_Arity extra); + +X_API extern YAP_Term YAP_ReadBuffer(const char *s, YAP_Term *tp); + +extern YAP_Term YAP_MkcharPTerm(char *s); - X_API void UserBackCPredicate(const char *name, int *init(), int *cont(), int - arity, int extra); } @@ -98,6 +130,7 @@ class YAPModule; class YAPError; class YAPPredicate; + #include "yapa.hh" #include "yapie.hh" diff --git a/CXX/yapie.hh b/CXX/yapie.hh index c851777e0..93554e3fa 100644 --- a/CXX/yapie.hh +++ b/CXX/yapie.hh @@ -1,12 +1,12 @@ -/** + /** * @file yapie.hh * - * @defgroup yap-cplus-error-hanadlinge Errir Handling in the YAP interface. + * @defgroup yap-cplus-error-hanadlinge Error Handling in the YAP interface. * - * @brief this is an attempt at supporting error + * @brief error handling in C++ and OO languages * * @ingroup yap-cplus-interface - * @tableofcontents + * * * @{ * @@ -15,7 +15,7 @@ * YAP itself. One can also define one's own error objects. * * Errors will be thrown from the `C++` code, and may be processed in - * very different ways. The error object should provide as much data asa + * very different ways. The error object should provide as much data as * possible. */ @@ -23,35 +23,66 @@ #ifndef YAPIE_HH #define YAPIE_HH -class YAPPPredicate; -class YAPTerm; +class X_API YAPPPredicate; + + /// take information on a Prolog error: -class YAPError { - yap_error_number ID; - std::string goal, info; +class X_API YAPError { int swigcode; - + yap_error_descriptor_t *info; + public: - YAPError(){ - //ID = LOCAL_ActiveError->errorNo; + /// wraps the default error descriptor + YAPError() { + info = LOCAL_ActiveError; + if (!info) + LOCAL_ActiveError = info = (yap_error_descriptor_t *)calloc( sizeof( yap_error_descriptor_t ), 1); + // if (info->errorNo != YAP_NO_ERROR) {}; + //std::cerr << "Error detected" << info->errorNo << "\n"; } + /// if des != nullptr, wrap a preexisting error descriptor; + /// otherwise, generate a new one + YAPError(yap_error_descriptor_t *des) { + if (des) + info= des; + else info = (yap_error_descriptor_t *)calloc( sizeof( yap_error_descriptor_t ), 1); + // if (info->errorNo != YAP_NO_ERROR) {}; + //std::cerr << "Error detected" << info->errorNo << "\n"; + + } + + /// error handler object with initial data when receiving the error term - YAPError(yap_error_number id, YAPTerm culprit, std::string txt); + // YAPError( std::string file, std::string function, int lineno, + // yap_error_number id, YAPTerm culprit, std::string txt) { + // info = new yap_error_descriptor_t; + // Yap_MkErrorRecord(info, file.c_str(), function.c_str(), lineno, id, culprit.term(), txt.c_str()); + //} + + /// error handler object with initial data when receiving the error term + YAPError( const char * file, const char * function, int lineno, + yap_error_number id, YAP_Term culprit, const char * txt) { + info = (yap_error_descriptor_t *)calloc( sizeof( yap_error_descriptor_t ), 1); + Yap_MkErrorRecord(info, file, function, lineno, id, culprit, txt); + } + + /// short version +#define SOURCE() __FILE__, __FUNCTION__, __LINE__ /// we just know the error number /// exact error ID - yap_error_number getID() { return LOCAL_ActiveError->errorNo; }; + yap_error_number getID() { return info->errorNo; }; /// class of error yap_error_class_number getErrorClass() { - return Yap_errorClass(LOCAL_ActiveError->errorNo); + return Yap_errorClass(info->errorNo); }; /// where in the code things happened; - const char *getFile() { return LOCAL_ActiveError->errorFile; }; + const char *getFile() { return info->errorFile; }; /// predicate things happened; - Int getLine() { return LOCAL_ActiveError->errorLine; }; + Int getLine() { return info->errorLine; }; /// the term that caused the bug - // YAPTerm getCulprit(LOCAL_ActiveError->errorFile){}; + // YAPTerm getCulprit(info->errorFile){}; /// text describing the Error std::string text(); }; diff --git a/CXX/yapq.hh b/CXX/yapq.hh index 6e69167a3..7fcf764c0 100644 --- a/CXX/yapq.hh +++ b/CXX/yapq.hh @@ -2,15 +2,15 @@ /** * @file yapq.hh * - * @defgroup yap-cplus-query-hanadlinge Query Handling in the YAP interface. + * @defgroup yap-cplus-query-handling Query Handling in the YAP interface. * @brief Engine and Query Management * * @ingroup yap-cplus-interface * * @{ * - * These classes wrap engine and query. An engine is an environment where we can rum - * Prolog, that is, where we can run queries. + * These classes wrap engine and query. An engine is an environment where we + * can rum Prolog, that is, where we can run queries. * * Also, supports callbacks and engine configuration. * @@ -19,36 +19,57 @@ #ifndef YAPQ_HH #define YAPQ_HH 1 -class YAPPredicate; +class X_API YAPPredicate; /** Queries and engines */ +#if __ANDROID__ + +#endif + /** * @brief Queries * * interface to a YAP Query; * uses an SWI-like status info internally. */ -class YAPQuery : public YAPPredicate -{ +class X_API YAPQuery : public YAPPredicate { bool q_open; int q_state; - yhandle_t q_g, q_handles; + yhandle_t q_handles; struct yami *q_p, *q_cp; - sigjmp_buf q_env; int q_flags; YAP_dogoalinfo q_h; - YAPQuery *oq; YAPPairTerm names; - YAPTerm goal; + Term goal; + CELL *nts; // temporaries - Term tnames, tgoal ; + YAPError *e; - void openQuery(Term t); + inline void setNext() { // oq = LOCAL_execution; + // LOCAL_execution = this; + q_open = true; + q_state = 0; + q_flags = true; // PL_Q_PASS_EXCEPTION; + + q_p = P; + q_cp = CP; + // make sure this is safe + q_handles = LOCAL_CurSlot; + }; + + void openQuery(); + + PredEntry *rewriteUndefQuery(); public: + YAPQuery() { + goal = TermTrue; + openQuery(); + }; + inline ~YAPQuery() { close(); } /// main constructor, uses a predicate and an array of terms /// /// It is given a YAPPredicate _p_ , and an array of terms that must have at @@ -66,34 +87,39 @@ public: /// /// It is given a functor, and an array of terms that must have at least /// the same arity as the functor. Works within the current module. - //YAPQuery(YAPFunctor f, YAPTerm t[]); + // YAPQuery(YAPFunctor f, YAPTerm t[]); /// string constructor without varnames /// /// It is given a string, calls the parser and obtains a Prolog term that /// should be a callable /// goal. - inline YAPQuery(const char *s) : YAPPredicate(s, tgoal, tnames) - { + inline YAPQuery(const char *s) : YAPPredicate(s, goal, names, (nts = &ARG1)) { __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "got game %ld", LOCAL_CurSlot); - if (!ap) - return; - __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "%s", vnames.text()); - goal = YAPTerm(tgoal); - names = YAPPairTerm(tnames); - openQuery(tgoal); + + openQuery(); }; + // inline YAPQuery() : YAPPredicate(s, tgoal, tnames) + // { + // __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "got game %ld", + // if (!ap) + // return; + // __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "%s", vnames.text()); + // goal = YAPTerm(tgoal); + // names = YAPPairTerm(tnames); + // openQuery(tgoal); + // }; /// string constructor with just an atom /// - /// It is given an atom, and a Prolog term that should be a callable - /// goal, say `main`, `init`, `live`. - inline YAPQuery(YAPAtom g) : YAPPredicate(g) - { - goal = YAPAtomTerm(g); - names = YAPPairTerm( ); - openQuery(goal.term()); - }; - + /// It i; + ///}; + /// build a query from a term + YAPQuery(YAPTerm t) : YAPPredicate((goal = t.term()), (nts = &ARG1)) { + BACKUP_MACHINE_REGS(); + openQuery(); + names = YAPPairTerm(TermNil); + RECOVER_MACHINE_REGS(); + } /// set flags for query execution, currently only for exception handling void setFlag(int flag) { q_flags |= flag; } /// reset flags for query execution, currently only for exception handling @@ -116,17 +142,16 @@ public: void close(); /// query variables. void cut(); - Term namedVars() {return names.term(); }; + Term namedVars() { return names.term(); }; + YAPPairTerm namedVarTerms() { return names; }; /// query variables, but copied out - std::vector namedVarsVector() { - return names.listToArray(); }; + std::vector namedVarsVector() { return names.listToArray(); }; /// convert a ref to a binding. YAPTerm getTerm(yhandle_t t); /// simple YAP Query; /// just calls YAP and reports success or failure, Useful when we just /// want things done, eg YAPCommand("load_files(library(lists), )") - inline bool command() - { + inline bool command() { bool rc = next(); close(); return rc; @@ -138,178 +163,113 @@ public: /// This class implements a callback Prolog-side. It will be inherited by the /// Java or Python /// class that actually implements the callback. -class YAPCallback -{ +class X_API YAPCallback { public: virtual ~YAPCallback() {} virtual void run() { LOG("callback"); } virtual void run(char *s) {} }; - - class YAPEngine; - /// @brief Setup all arguments to a new engine -class YAPEngineArgs { +struct X_API YAPEngineArgs : YAP_init_args { - friend class YAPEngine; - - YAP_init_args init_args; - - void fetch_defaults(); - public: + YAPEngineArgs() { + // const std::string *s = new std::string("startup.yss"); + Embedded = true; + install = false; - inline void setEmbedded( bool fl ) - { - init_args.Embedded = fl; + Yap_InitDefaults(this, nullptr, 0, nullptr); +#if YAP_PYTHON + Embedded = true; + python_in_python = Py_IsInitialized(); +#endif +#if __ANDROID__ +#endif }; - inline bool getEmbedded( ) - { - return init_args.Embedded; + inline void setEmbedded(bool fl) { Embedded = fl; }; + + inline bool getEmbedded() { return Embedded; }; + + inline void setStackSize(bool fl) { StackSize = fl; }; + + inline bool getStackSize() { return StackSize; }; + + inline void setTrailSize(bool fl) { TrailSize = fl; }; + + inline bool getTrailSize() { return TrailSize; }; + + inline bool getMStackSize() { return StackSize; }; + + inline void setMaxTrailSize(bool fl) { MaxTrailSize = fl; }; + + inline bool getMaxTrailSize() { return MaxTrailSize; }; + + inline void createSavedState(bool fl) { install = fl; }; + + inline bool creatingSavedState() { return install; }; + + inline void setPLDIR(const char *fl) { + LIBDIR = (const char *)malloc(strlen(fl) + 1); + strcpy((char *)LIBDIR, fl); }; - inline void setSavedState( char *fl ) - { - init_args.SavedState = fl; + inline const char *getPLDIR() { return PLDIR; }; + + inline void setINPUT_STARTUP(const char *fl) { + INPUT_STARTUP = (const char *)malloc(strlen(fl) + 1); + strcpy((char *)INPUT_STARTUP, fl); }; - inline const char * getSavedState( ) - { - return init_args.SavedState; + inline const char *getINPUT_STARTUP() { return INPUT_STARTUP; }; + + inline void setOUTPUT_RESTORE(const char *fl) { + OUTPUT_STARTUP = (const char *)malloc(strlen(fl) + 1); + strcpy((char *)OUTPUT_STARTUP, fl); }; - inline void setStackSize( bool fl ) - { - init_args.StackSize = fl; + inline const char *getOUTPUT_STARTUP() { return OUTPUT_STARTUP; }; + + inline void setBOOTFILE(const char *fl) { + BOOTFILE = (const char *)malloc(strlen(fl) + 1); + strcpy((char *)BOOTFILE, fl); }; - inline bool getStackSize( ) - { - return init_args.StackSize; + inline const char *getBOOTFILE() { return BOOTFILE; }; + + inline void setPrologBOOTSTRAP(const char *fl) { + BOOTSTRAP = (const char *)malloc(strlen(fl) + 1); + strcpy((char *)BOOTSTRAP, fl); }; - inline void setTrailSize( bool fl ) - { - init_args.TrailSize = fl; + inline const char *getBOOTSTRAP() { return BOOTSTRAP; }; + + inline void setPrologGoal(const char *fl) { PrologGoal = fl; }; + + inline const char *getPrologGoal() { return PrologGoal; }; + + inline void setPrologTopLevelGoal(const char *fl) { + PrologTopLevelGoal = fl; }; - inline bool getTrailSize( ) - { - return init_args.TrailSize; - }; + inline const char *getPrologTopLevelGoal() { return PrologTopLevelGoal; }; - inline bool getMStackSize( ) - { - return init_args.StackSize; - }; + inline void setHaltAfterBoot(bool fl) { HaltAfterBoot = fl; }; - inline void setMaxTrailSize( bool fl ) - { - init_args.MaxTrailSize = fl; - }; + inline bool getHaltAfterBoot() { return HaltAfterBoot; }; - inline bool getMaxTrailSize( ) - { - return init_args.MaxTrailSize; - }; + inline void setFastBoot(bool fl) { FastBoot = fl; }; - inline void setYapLibDir( const char * fl ) - { - init_args.YapLibDir = fl; - }; + inline bool getFastBoot() { return FastBoot; }; - inline const char * getYapLibDir( ) - { - return init_args.YapLibDir; - }; + inline void setArgc(int fl) { Argc = fl; }; - inline void setYapShareDir( const char * fl ) - { - init_args.YapShareDir = fl; - }; + inline int getArgc() { return Argc; }; - inline const char * getYapShareDir( ) - { - return init_args.YapShareDir; - }; - - inline void setYapPrologBootFile( const char * fl ) - { - init_args.YapPrologBootFile = fl; - }; - - inline const char * getYapPrologBootFile( ) - { - return init_args.YapPrologBootFile; - }; - - inline void setYapPrologGoal( const char * fl ) - { - init_args.YapPrologGoal = fl; - }; - - inline const char * getYapPrologGoal( ) - { - return init_args.YapPrologGoal; - }; - - inline void setYapPrologTopLevelGoal( const char * fl ) - { - init_args.YapPrologTopLevelGoal = fl; - }; - - inline const char * getYapPrologTopLevelGoal( ) - { - return init_args.YapPrologTopLevelGoal; - }; - - inline void setHaltAfterConsult( bool fl ) - { - init_args.HaltAfterConsult = fl; - }; - - inline bool getHaltAfterConsult( ) - { - return init_args.HaltAfterConsult; - }; - - inline void setFastBoot( bool fl ) - { - init_args.FastBoot = fl; - }; - - inline bool getFastBoot( ) - { - return init_args.FastBoot; - }; - - inline void setArgc( int fl ) - { - init_args.Argc = fl; - }; - - inline int getArgc( ) - { - return init_args.Argc; - }; - - inline void setArgv( char ** fl ) - { - init_args.Argv = fl; - }; - - inline char ** getArgv( ) - { - return init_args.Argv; - }; - - - YAPEngineArgs() { - fetch_defaults(); - }; + inline void setArgv(char **fl) { Argv = fl; }; + inline char **getArgv() { return Argv; }; }; /** @@ -318,36 +278,39 @@ public: * * */ -class YAPEngine -{ +class YAPEngine { private: - YAPEngineArgs engine_args; + YAPEngineArgs *engine_args; YAPCallback *_callback; YAPError yerror; - void doInit(YAP_file_type_t BootMode); + void doInit(YAP_file_type_t BootMode, YAPEngineArgs *cargs); YAP_dogoalinfo q; + YAPError e; + PredEntry *rewriteUndefEngineQuery(PredEntry *ap, Term &t, Term tmod); public: /// construct a new engine; may use a variable number of arguments - YAPEngine(YAPEngineArgs &cargs); /// construct a new engine, including aaccess to callbacks - /// construct a new engine using argc/argv list of arguments + YAPEngine(YAPEngineArgs *cargs) { + engine_args = cargs; + // doInit(cargs->boot_file_type); + doInit(YAP_QLY, cargs); + }; /// construct a new engine, including aaccess to callbacks + /// construct a new engine using argc/argv list of arguments YAPEngine(int argc, char *argv[], YAPCallback *callback = (YAPCallback *)NULL); /// kill engine - ~YAPEngine() { delYAPCallback(); } + ~YAPEngine() { delYAPCallback(); }; /// remove current callback - void delYAPCallback() { _callback = 0; } + void delYAPCallback() { _callback = 0; }; /// set a new callback - void setYAPCallback(YAPCallback *cb) - { + void setYAPCallback(YAPCallback *cb) { delYAPCallback(); _callback = cb; - } + }; /// execute the callback. ////void run() { if (_callback) _callback.run(); } /// execute the callback with a text argument. - void run(char *s) - { + void run(char *s) { if (_callback) _callback->run(s); } @@ -358,21 +321,30 @@ public: bool hasError() { return LOCAL_Error_TYPE != YAP_NO_ERROR; } /// build a query on the engine YAPQuery *query(const char *s) { return new YAPQuery(s); }; + /// build a query from a term + YAPQuery *query(YAPTerm t) { return new YAPQuery(t); }; + /// build a query from a Prolog term (internal) + YAPQuery *qt(Term t) { return new YAPQuery(YAPTerm(t)); }; /// current module for the engine - YAPModule currentModule() { return YAPModule(); } + Term Yap_CurrentModule() { return CurrentModule; } /// given a handle, fetch a term from the engine inline YAPTerm getTerm(yhandle_t h) { return YAPTerm(h); } /// current directory for the engine bool call(YAPPredicate ap, YAPTerm ts[]); /// current directory for the engine - bool goalt(YAPTerm Yt) { return Yt.term(); }; - /// current directory for the engine - bool mgoal(Term t, Term tmod); + bool goal(YAPTerm Yt, YAPModule module, bool release = false) { + return mgoal(Yt.term(), module.term(), release); + }; + /// ru1n a goal in a module. + /// + /// By default, memory will only be fully + /// recovered on backtracking. The release option ensures + /// backtracking is called at the very end. + bool mgoal(Term t, Term tmod, bool release = false); /// current directory for the engine - bool goal(Term t) - { - return mgoal(t, CurrentModule); + bool goal(Term t, bool release = false) { + return mgoal(t, Yap_CurrentModule(), release); } /// reset Prolog state void reSet(); @@ -380,23 +352,31 @@ public: // for last execution void release(); - const char *currentDir() - { + const char *currentDir() { char dir[1024]; std::string s = Yap_getcwd(dir, 1024 - 1); return s.c_str(); }; /// report YAP version as a string - const char *version() - { + const char *version() { std::string s = Yap_version(); return s.c_str(); }; //> call a deterninistic predicate: the user will construct aterm of //> arity N-1. YAP adds an extra variable which will have the //> output. - YAPTerm fun(YAPTerm t); + YAPTerm funCall(YAPTerm t) { return YAPTerm(fun(t.term())); }; Term fun(Term t); + //Term fun(YAPTerm t) { return fun(t.term()); }; + //> set a StringFlag, usually a path + //> + bool setStringFlag(std::string arg, std::string path) { + return setYapFlag(MkAtomTerm(Yap_LookupAtom(arg.data())), + MkAtomTerm(Yap_LookupAtom(path.data()))); + }; + + Term top_level(std::string s); + Term next_answer(YAPQuery *&Q); }; #endif /* YAPQ_HH */ diff --git a/CXX/yapt.hh b/CXX/yapt.hh index f950b5814..bf8abb188 100644 --- a/CXX/yapt.hh +++ b/CXX/yapt.hh @@ -25,16 +25,17 @@ #ifndef YAPT_HH #define YAPT_HH 1 -extern "C" { - Term YAP_ReadBuffer(const char *s, Term *tp); -} - class YAPError; +extern "C" { + +X_API extern Term YAP_MkCharPTerm(char *n); +} + /** * @brief Generic Prolog Term */ -class YAPTerm { +class X_API YAPTerm { friend class YAPPredicate; friend class YAPPrologPredicate; friend class YAPQuery; @@ -49,9 +50,9 @@ protected: public: Term gt() { CACHE_REGS - // fprintf(stderr,"?%d,%lx,%p\n",t,LOCAL_HandleBase[t], HR); - // Yap_DebugPlWriteln(LOCAL_HandleBase[t]); - return Yap_GetFromSlot(t); + // fprintf(stderr,"?%d,%lx,%p\n",t,LOCAL_HandleBase[t], HR); + // Yap_DebugPlWriteln(LOCAL_HandleBase[t]); + return Yap_GetFromSlot(t); }; void mk(Term t0) { @@ -66,36 +67,36 @@ public: YAPTerm(Term tn) { mk(tn); }; #ifdef SWIGPYTHON - // YAPTerm(struct _object *inp) { - // Term tinp = pythonToYAP(inp); - // t = Yap_InitSlot(tinp); - //} +// YAPTerm(struct _object *inp) { +// Term tinp = pythonToYAP(inp); +// t = Yap_InitSlot(tinp); +//} #endif /// private method to convert from Term (internal YAP representation) to /// YAPTerm // do nothing constructor - YAPTerm() { t=0; }; + YAPTerm() { t = 0; }; // YAPTerm(yhandle_t i) { t = i; }; /// pointer to term YAPTerm(void *ptr); /// parse string s and construct a term. YAPTerm(char *s) { - Term tp; + Term tp = 0; mk(YAP_ReadBuffer(s, &tp)); } #if 1 /// Term destructor, tries to recover slot - virtual ~YAPTerm() { - // fprintf(stderr,"-%d,%lx,%p ",t,LOCAL_HandleBase[t] ,HR); -/* if (!t) - return; - Yap_DebugPlWriteln(LOCAL_HandleBase[t]); - LOCAL_HandleBase[t] = TermFreeTerm; - while (LOCAL_HandleBase[LOCAL_CurSlot - 1] == TermFreeTerm) { - LOCAL_CurSlot--; - } - */ + virtual ~YAPTerm(){ + // fprintf(stderr,"-%d,%lx,%p ",t,LOCAL_HandleBase[t] ,HR); + /* if (!t) + return; + // Yap_DebugPlWriteln(LOCAL_HandleBase[t]); + LOCAL_HandleBase[t] = TermFreeTerm; + while (LOCAL_HandleBase[LOCAL_CurSlot - 1] == TermFreeTerm) { + LOCAL_CurSlot--; + } + */ }; #endif @@ -114,8 +115,19 @@ public: /// numbervars ( int start, bool process=false ) intptr_t numberVars(intptr_t start, bool skip_singletons = false); inline Term term() { - return gt(); + return Deref(gt()); } /// from YAPTerm to Term (internal YAP representation) + YAPTerm arg(int i) { + BACKUP_MACHINE_REGS(); + Term t0 = gt(); + YAPTerm tf; + if (!IsApplTerm(t0) && !IsPairTerm(t)) + return (Term)0; + tf = YAPTerm(ArgOfTerm(i, t0)); + RECOVER_MACHINE_REGS(); + return tf; + }; + inline void bind(Term b) { LOCAL_HandleBase[t] = b; } inline void bind(YAPTerm *b) { LOCAL_HandleBase[t] = b->term(); } /// from YAPTerm to Term (internal YAP representation) @@ -187,28 +199,9 @@ public: virtual bool isGround() { return Yap_IsGroundTerm(gt()); } /// term is ground virtual bool isList() { return Yap_IsListTerm(gt()); } /// term is a list - /// extract the argument i of the term, where i in 1...arity - virtual Term getArg(arity_t i) { - BACKUP_MACHINE_REGS(); - Term tf = 0; - Term t0 = gt(); - - if (IsApplTerm(t0)) { - if (i > t) YAPError(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 - YAPError(DOMAIN_ERROR_OUT_OF_RANGE, t0, "t0.getArg()"); - } else { - YAPError(TYPE_ERROR_COMPOUND , t0, "t0.getArg()"); - } - RECOVER_MACHINE_REGS(); - return tf; - } + /// extract the argument i of the term, where i in 1...arityvoid + /// *Yap_RepStreamFromId(int sno) + virtual Term getArg(arity_t i); /// extract the arity of the term /// variables have arity 0 @@ -229,21 +222,15 @@ public: /// return a string with a textual representation of the term virtual const char *text() { CACHE_REGS - size_t length = 0; - encoding_t enc = LOCAL_encoding; char *os; BACKUP_MACHINE_REGS(); - if (!(os = Yap_TermToString(Yap_GetFromSlot(t), &length, enc, - Handle_vars_f))) { + if (!(os = Yap_TermToBuffer(Yap_GetFromSlot(t), Handle_vars_f))) { RECOVER_MACHINE_REGS(); return 0; } RECOVER_MACHINE_REGS(); - length = strlen(os) + 1; - char *sm = (char *)malloc(length + 1); - strcpy(sm, os); - return sm; + return os; }; /// return a handle to the term @@ -254,53 +241,83 @@ public: }; /** - * @brief Variable Term + * @brief YAPFunctor represents Prolog functors Name/Arity */ -class YAPVarTerm : public YAPTerm { - YAPVarTerm(Term t) { - if (IsVarTerm(t)) { - mk(t); - } - } +class X_API YAPFunctor : public YAPProp { + friend class YAPApplTerm; + friend class YAPTerm; + friend class YAPPredicate; + friend class YAPQuery; + Functor f; + /// Constructor: receives Prolog functor and casts it to YAPFunctor + /// + /// Notice that this is designed for internal use only. + inline YAPFunctor(Functor ff) { f = ff; } public: - /// constructor - YAPVarTerm(); - /// get the internal representation - CELL *getVar() { return VarOfTerm(gt()); } - /// is the variable bound to another one - bool unbound() { return IsUnboundVar(VarOfTerm(gt())); } - virtual bool isVar() { return true; } /// type check for unbound - virtual bool isAtom() { return false; } /// type check for atom - virtual bool isInteger() { return false; } /// type check for integer - virtual bool isFloat() { return false; } /// type check for floating-point - virtual bool isString() { return false; } /// type check for a string " ... " - virtual bool isCompound() { return false; } /// is a primitive term - virtual bool isAppl() { return false; } /// is a structured term - virtual bool isPair() { return false; } /// is a pair term - virtual bool isGround() { return false; } /// term is ground - virtual bool isList() { return false; } /// term is a list + /// Constructor: receives name as an atom, plus arity + /// + /// This is the default method, and the most popular + YAPFunctor(YAPAtom at, uintptr_t arity) { f = Yap_MkFunctor(at.a, arity); } + + /// Constructor: receives name as a string plus arity + /// + /// Notice that this is designed for ISO-LATIN-1 right now + /// Note: Python confuses the 3 constructors, + /// use YAPFunctorFromString + inline YAPFunctor(const char *s, uintptr_t arity, bool isutf8 = true) { + f = Yap_MkFunctor(Yap_LookupAtom(s), arity); + } + /// Constructor: receives name as a wide string plus arity + /// + /// Notice that this is designed for UNICODE right now + /// + /// Note: Python confuses the 3 constructors, + /// use YAPFunctorFromWideString + inline YAPFunctor(const wchar_t *s, uintptr_t arity) { + CACHE_REGS f = Yap_MkFunctor(UTF32ToAtom(s PASS_REGS), arity); + } + /// Getter: extract name of functor as an atom + /// + /// this is for external usage. + YAPAtom name(void) { return YAPAtom(NameOfFunctor(f)); } + + /// Getter: extract arity of functor as an unsigned integer + /// + /// this is for external usage. + uintptr_t arity(void) { return ArityOfFunctor(f); } }; /** * @brief Compound Term */ -class YAPApplTerm : public YAPTerm { +class X_API YAPApplTerm : public YAPTerm { friend class YAPTerm; public: - YAPApplTerm(Term t0) { mk(t0); } - YAPApplTerm(Functor f, Term ts[]) { +YAPApplTerm(Term t0) { mk(t0); } +YAPApplTerm(Functor f, Term ts[]) { BACKUP_MACHINE_REGS(); Term t0 = Yap_MkApplTerm(f, f->ArityOfFE, ts); mk(t0); RECOVER_MACHINE_REGS(); }; YAPApplTerm(YAPFunctor f, YAPTerm ts[]); - YAPApplTerm(const std::string s, std::vector ts); + YAPApplTerm(const std::string s, unsigned int arity) { + mk(Yap_MkNewApplTerm(Yap_MkFunctor(Yap_LookupAtom(s.c_str()), arity), + arity)); + }; + YAPApplTerm(const std::string s, std::vector ts); + YAPApplTerm(const std::string s, std::vector ts); YAPApplTerm(YAPFunctor f); - YAPFunctor getFunctor(); - Term getArg(arity_t i) { + inline Functor functor() { return FunctorOfTerm(gt()); } + inline YAPFunctor getFunctor() { return YAPFunctor(FunctorOfTerm(gt())); } + YAPApplTerm(const std::string f, YAPTerm a1); + YAPApplTerm(const std::string f, YAPTerm a1, YAPTerm a2); + YAPApplTerm(const std::string f, YAPTerm a1, YAPTerm a2, YAPTerm a3); + YAPApplTerm(const std::string f, YAPTerm a1, YAPTerm a2, YAPTerm a3, YAPTerm a4); + + Term getArg(arity_t i) { BACKUP_MACHINE_REGS(); Term t0 = gt(); Term tf; @@ -308,6 +325,18 @@ public: RECOVER_MACHINE_REGS(); return tf; }; + void putArg(int i, Term targ) { + // BACKUP_MACHINE_REGS(); + Term t0 = gt(); + RepAppl(t0)[i] = Deref(targ); + // RECOVER_MACHINE_REGS(); + }; + void putArg(int i, YAPTerm t) { + // BACKUP_MACHINE_REGS(); + Term t0 = gt(); + RepAppl(t0)[i] = t.term(); + // RECOVER_MACHINE_REGS(); + }; virtual bool isVar() { return false; } /// type check for unbound virtual bool isAtom() { return false; } /// type check for atom virtual bool isInteger() { return false; } /// type check for integer @@ -323,45 +352,32 @@ public: /** * @brief List Constructor Term */ -class YAPPairTerm : public YAPTerm { +class X_API YAPPairTerm : public YAPTerm { friend class YAPTerm; - public: - YAPPairTerm(Term t0) { - t0 = Deref(t0); - if (IsPairTerm(t0) || t0 == TermNil) - mk(t0); - else - Yap_ThrowError(TYPE_ERROR_LIST, t0, "YAPPairTerms"); - } - YAPPairTerm(YAPTerm hd, YAPTerm tl); + YAPPairTerm(Term t0) { + t0 = Deref(t0); + if (IsPairTerm(t0) || t0 == TermNil) + mk(t0); + else + Yap_ThrowError(TYPE_ERROR_LIST, t0, "YAPPairTerms"); + } + YAPPairTerm(YAPTerm hd, YAPTerm tl); YAPPairTerm(); Term getHead() { return (HeadOfTerm(gt())); } Term getTail() { return (TailOfTerm(gt())); } - std::vector listToArray() { - Term *tailp; - Term t1 = gt(); - Int l = Yap_SkipList(&t1, &tailp); - if (l < 0) { - throw YAPError(TYPE_ERROR_LIST, YAPTerm(t), ""); - } - std::vector o = std::vector(l); - int i = 0; - Term t = gt(); - while (t != TermNil) { - o[i++] = HeadOfTerm(t); - t = TailOfTerm(t); - } - return o; - } + YAPTerm car() { return YAPTerm(HeadOfTerm(gt())); } + bool nil() { return gt() == TermNil; } + YAPPairTerm cdr() { return YAPPairTerm(TailOfTerm(gt())); } + std::vector listToArray(); }; /** * @brief Number Term */ -class YAPNumberTerm : public YAPTerm { +class X_API YAPNumberTerm : public YAPTerm { public: YAPNumberTerm(){}; bool isTagged() { return IsIntTerm(gt()); } @@ -371,7 +387,7 @@ public: * @brief Integer Term */ -class YAPIntegerTerm : public YAPNumberTerm { +class X_API YAPIntegerTerm : public YAPNumberTerm { public: YAPIntegerTerm(intptr_t i); intptr_t getInteger() { return IntegerOfTerm(gt()); }; @@ -381,14 +397,14 @@ public: * @brief Floating Point Term */ -class YAPFloatTerm : public YAPNumberTerm { +class X_API YAPFloatTerm : public YAPNumberTerm { public: YAPFloatTerm(double dbl) { mk(MkFloatTerm(dbl)); }; double getFl() { return FloatOfTerm(gt()); }; }; -class YAPListTerm : public YAPTerm { +class X_API YAPListTerm : public YAPTerm { public: /// Create a list term out of a standard term. Check if a valid operation. /// @@ -419,15 +435,7 @@ public: /// Extract the tail elements of a list. /// /// @param[in] the list - Term cdr() { - Term to = gt(); - if (IsPairTerm(to)) - return (TailOfTerm(to)); - else if (to == TermNil) - return TermNil; - /* error */ - throw YAPError(TYPE_ERROR_LIST, YAPTerm(to), ""); - } + Term cdr(); /// copy a list. /// /// @param[in] the list @@ -446,7 +454,7 @@ public: /** * @brief String Term */ -class YAPStringTerm : public YAPTerm { +class X_API YAPStringTerm : public YAPTerm { public: /// your standard constructor YAPStringTerm(char *s); @@ -463,23 +471,26 @@ public: * @brief Atom Term * Term Representation of an Atom */ -class YAPAtomTerm : public YAPTerm { +class X_API YAPAtomTerm : public YAPTerm { friend class YAPModule; // Constructor: receives a C-atom; - YAPAtomTerm(Atom a) { mk(MkAtomTerm(a)); } YAPAtomTerm(Term t) : YAPTerm(t) { IsAtomTerm(t); } public: - // Constructor: receives an atom; + YAPAtomTerm(Atom a) { mk(MkAtomTerm(a)); } + //> Constructor: receives an atom; YAPAtomTerm(YAPAtom a) : YAPTerm() { mk(MkAtomTerm(a.a)); } - // Constructor: receives a sequence of ISO-LATIN1 codes; + //> Constructor: receives a sequence of UTF-8 codes; YAPAtomTerm(char s[]); - // Constructor: receives a sequence of up to n ISO-LATIN1 codes; + // Constructor: receives a sequence of up to n UTF-8 codes; YAPAtomTerm(char *s, size_t len); // Constructor: receives a sequence of wchar_ts, whatever they may be; YAPAtomTerm(wchar_t *s); // Constructor: receives a sequence of n wchar_ts, whatever they may be; YAPAtomTerm(wchar_t *s, size_t len); + // Constructor: receives a std::string; + // YAPAtomTerm(std::string s) { mk(MkAtomTerm(Yap_LookupAtom(s.c_str()))); + // }; bool isVar() { return false; } /// type check for unbound bool isAtom() { return true; } /// type check for atom bool isInteger() { return false; } /// type check for integer @@ -497,4 +508,35 @@ public: }; #endif /* YAPT_HH */ +/** + * @brief Variable Term + */ +class X_API YAPVarTerm : public YAPTerm { + friend class YAPTerm; + +public: + /// constructor + YAPVarTerm() { mk(MkVarTerm()); }; + /// get the internal representation + CELL *getVar() { return VarOfTerm(gt()); } + /// is the variable bound to another one + YAPVarTerm(Term t) { + if (IsVarTerm(t)) { + mk(t); + } + } + /// type check for unbound + bool unbound() { return IsUnboundVar(VarOfTerm(gt())); } + inline bool isVar() { return true; } + inline bool isAtom() { return false; } /// type check for atom + inline bool isInteger() { return false; } /// type check for integer + inline bool isFloat() { return false; } /// type check for floating-point + inline bool isString() { return false; } /// type check for a string " ... " + inline bool isCompound() { return false; } /// is a primitive term + inline bool isAppl() { return false; } /// is a structured term + inline bool isPair() { return false; } /// is a pair term + inline bool isGround() { return false; } /// term is ground + inline bool isList() { return false; } /// term is a list +}; + /// @} diff --git a/H/ATOMS b/H/ATOMS index c43c033f1..8c2ed1f44 100644 --- a/H/ATOMS +++ b/H/ATOMS @@ -7,6 +7,7 @@ // This is supported by YAP directly // A Dot N "." // +A AtSymbol N "@" A 3Dots N "..." A Abol F "$abol" A Access N "access" @@ -20,7 +21,7 @@ A AltNot N "not" A Answer N "answer" A Any N "any" A Append N "append" -A Arg N "arg" +A Arg N "arg" A Array F "$array" A ArrayAccess F "$array_arg" A ArrayOverflow N "array_overflow" @@ -37,6 +38,7 @@ A BeginCurlyBracket N "{" A EndCurlyBracket N "}" A EmptyBrackets N "()" A EmptySquareBrackets N "[]" +A As N "as" A Asserta N "asserta" A AssertaStatic N "asserta_static" A Assertz N "assertz" @@ -134,6 +136,7 @@ A Eq N "=" A Error N "error" A Exception N "exception" A Extensions N "extensions" +A ExternalException N "external_exception" A Evaluable N "evaluable" A EvaluationError N "evaluation_error" A Executable N "executable" @@ -170,6 +173,7 @@ A Full N "full" A Functor N "functor" A GT N ">" A GVar N "var" +A g N "g" A Gc F "$gc" A GcMargin F "$gc_margin" A GcTrace F "$gc_trace" @@ -184,6 +188,7 @@ A GlobalSp N "global_sp" A GlobalTrie N "global_trie" A GoalExpansion N "goal_expansion" A Hat N "^" +A DoubleHat N "^^" A HERE N "\n <====HERE====> \n" A HandleThrow F "$handle_throw" A Heap N "heap" @@ -221,7 +226,7 @@ A Least N "least" A Length F "length" A List N "list" A Line N "line" -A Live F "$live" +A Live F "live" A LoadAnswers N "load_answers" A Local N "local" A LocalSp N "local_sp" @@ -267,7 +272,7 @@ A NotLessThanZero N "not_less_than_zero" A NotNewline N "not_newline" A NotZero N "not_zero" A Number N "number" -A Obj N "o__bj__" +A Obj N "__obj__" A Off N "off" A Offline N "offline" A On N "on" @@ -288,15 +293,15 @@ A OutOfStackError N "out_of_stack_error" A OutOfTrailError N "out_of_trail_error" A Output N "output" A Parameter N "parameter" -A PrologCommonsDir N "prolog_commons_directory" A Past N "past" A PastEndOfStream N "past_end_of_stream" A PermissionError N "permission_error" A Pi N "pi" A Pipe N "pipe" -A Priority N "priority" +A Priority N "priority" A Plus N "+" A Pointer N "pointer" +A Popen N "popen" A Portray F "portray" A PredicateIndicator N "predicate_indicator" A Primitive N "primitive" @@ -305,6 +310,7 @@ A PrivateProcedure N "private_procedure" A Procedure N "procedure" A Profile F "$profile" A Prolog N "prolog" +A PrologCommonsDir N "prolog_commons_directory" A ProtectStack F "$protect_stack" A Qly N "qly" A Query N "?-" @@ -322,6 +328,7 @@ A Reconsult N "reconsult" A RecordedP F "$recordep" A RecordedWithKey F "$recorded_with_key" A RedefineWarnings N "redefine_warnings" +A Redo F "redo" A RedoFreeze F "$redo_freeze" A RefoundVar F "$I_FOUND_THE_VARIABLE_AGAIN" A RelativeTo F "relative_to" @@ -395,6 +402,7 @@ A SystemLibraryDir N "system_library_directory" A T N "t" A Term N "term" A TermExpansion N "term_expansion" +A TermPosition N "term_position" A Terms N "terms" A Text N "text" A TextStream N "text_stream" @@ -414,6 +422,7 @@ A Tuple N "tuple" A Txt N "txt" A TypeError N "type_error" A Undefined N "undefined" +A UndefinedQuery N "undefined_query" A Undefp F "$undefp" A Undefp0 F "$undefp0" A Underflow N "underflow" @@ -425,6 +434,7 @@ A User N "user" A UserErr N "user_error" A UserIn N "user_input" A UserOut N "user_output" +A UTF8 N "utf8" A DollarVar N "$VAR" A VBar N "|" A VarBranches N "var_branches" @@ -451,8 +461,11 @@ F Arg Arg 3 F ArrayEntry ArrayAccess 3 F Arrow Arrow 2 F DoubleArrow DoubleArrow 2 +F As As 2 F Assert1 Assert 1 F Assert Assert 2 +F At At 2 +F AtSymbol AtSymbol 2 F AtFoundOne FoundVar 2 F Atom Atom 1 F Att1 Att1 3 @@ -500,6 +513,7 @@ F Dot9 Dot 9 F DoubleArrow DoubleArrow 2 F DoubleSlash DoubleSlash 2 F EmptySquareBrackets EmptySquareBrackets 2 +F Encoding Encoding 1 F Eq Eq 2 F Error Error 2 F EvaluationError EvaluationError 1 @@ -509,6 +523,7 @@ F ExecuteInMod ExecuteInMod 2 F ExecuteWithin ExecuteWithin 1 F ExistenceError ExistenceError 2 F ExoClause ExoClause 2 +F ExternalException ExternalException 1 F Functor Functor 3 F GAtom Atom 1 F GAtomic Atomic 1 @@ -524,6 +539,7 @@ F GoalExpansion2 GoalExpansion 2 F GoalExpansion GoalExpansion 3 F HandleThrow HandleThrow 3 F Hat Hat 2 +F DoubleHat DoubleHat 1 F I I 2 F Id Id 1 F Info1 Info 1 @@ -550,6 +566,7 @@ F Or Semic 2 F Output Output 1 F PermissionError PermissionError 3 F Plus Plus 2 +F Popen Popen 1 F Portray Portray 1 F PrintMessage PrintMessage 2 F Procedure Procedure 5 @@ -583,6 +600,7 @@ F TimeoutError TimeoutError 2 F TraceMetaCall TraceMetaCall 3 F TypeError TypeError 2 F UMinus Minus 1 +F UndefinedQuery UndefinedQuery 3 F UPlus Plus 1 F VBar VBar 2 F WriteTerm WriteTerm 2 diff --git a/H/Atoms.h b/H/Atoms.h index 0cdcda777..dbac215d6 100644 --- a/H/Atoms.h +++ b/H/Atoms.h @@ -96,7 +96,7 @@ typedef struct ExtraAtomEntryStruct { #define USE_OFFSETS_IN_PROPS 0 #endif -typedef SFLAGS PropFlags; +typedef CELL PropFlags; /* basic property entry structure */ typedef struct PropEntryStruct { diff --git a/H/CMakeLists.txt b/H/CMakeLists.txt new file mode 100644 index 000000000..be369505c --- /dev/null +++ b/H/CMakeLists.txt @@ -0,0 +1,21 @@ + + +file( STRINGS locals.h tmp ) +if (WITH_THREADS) + Foreach(i ${tmp}) + string(REGEX REPLACE "^LOCAL[^(]*[(][^,]+,[^_a-zA-Z0-9]*([_a-zA-Z0-9]+)[^_a-zA-Z0-9,]*,[^_a-zA-Z0-9]*([_a-zA-Z0-9]+)[^)]*.*$" "#define LOCAL_\\0 (Yap_regs.worker_local->\\1)\\n#define REMOTE_\\1(wid) (REMOTE(wid)->\\1)\\n" i2 ${i}) + list( APPEND tmp2 ${i2} "\n") + endforeach() +else() +Foreach(i ${tmp}) +string(REGEX REPLACE "^LOCAL[^(]*[(][ \t]*([^,]+)[ \t]*,[ \t]*([^),]+).*" "#define LOCAL_\\2 (Yap_local.\\2)\\n#define REMOTE_\\2(wid) (REMOTE(wid)->\\2)\\n" i2 ${i}) +list( APPEND tmp2 ${i2} "\n") +endforeach() +endif() +file( WRITE ${CMAKE_TOP_BINARY_DIR}/dlocals.h ${tmp2}) + +add_custom_command( OUTPUT ${CMAKE_TOP_BINARY_DIR}/dlocals.h + COMMAND ${CMAKE_COMMAND} -E COPY ${CMAKE_TOP_BINARY_DIR}/deflocals.h ${CMAKE_TOP_BINARY_DIR}/dlocals.h + DEPENDS locals.h ) + + diff --git a/H/Foreign.h b/H/Foreign.h index 764e7d6f4..6778d06df 100644 --- a/H/Foreign.h +++ b/H/Foreign.h @@ -1,23 +1,23 @@ /************************************************************************* -* * -* YAP Prolog * -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-97 * -* * -************************************************************************** -* * -* File: Foreign.h * -* comments: header file for dynamic loading routines * -*************************************************************************/ + * * + * YAP Prolog * + * * + * Yap Prolog was developed at NCCUP - Universidade do Porto * + * * + * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-97 * + * * + ************************************************************************** + * * + * File: Foreign.h * + * comments: header file for dynamic loading routines * + *************************************************************************/ #define NO_DYN 1 #ifndef FOREIGN_H #define FOREIGN_H -/** +/** @: @file Foreign.h @@ -25,27 +25,30 @@ load_foreign_files/3 has works for the following configurations: - linux: should work both for a.out (untested by me) and ELF; - + - WIN32: works (notice that symbols are not exported by default) - OSX: works using Mach dynamic libs. - osf: should work, but isn't working yet. - + - sunos4: should work, using A.OUT format; - + - svr4, eg solaris: should work, using ELF format; - AIX: should work for 3.2 and 4.1 at least, using ECOFF; - + YAP should be able to load on most BSD Unixes, but you will need to say that here. YAP also supports COFF loading (pretty much the same technique as - used for A.OUT loading) but that is untested so far. + used for A.OUT loading) but that is untested so far. */ +#include "Yap.h" +#include "YapHeap.h" + #ifdef _AIX #undef NO_DYN #endif /* __AIX */ @@ -96,8 +99,8 @@ #endif #endif /* LOAD_DYLD */ -#define LOAD_SUCCEEDED 0 -#define LOAD_FAILLED -1 +#define LOAD_SUCCEEDED 0 +#define LOAD_FAILLED -1 typedef struct StringListItem { Atom name; @@ -115,16 +118,21 @@ typedef struct ForeignLoadItem { typedef void (*YapInitProc)(void); +void *Yap_LoadForeignFile(char *, int); +int Yap_CallForeignFile(void *, char *); +int Yap_CloseForeignFile(void *); +Int Yap_LoadForeign(StringList, StringList, char *, YapInitProc *); +Int Yap_ReLoadForeign(StringList, StringList, char *, YapInitProc *); +void Yap_ReOpenLoadForeign(void); +void Yap_ShutdownLoadForeign(void); -void *Yap_LoadForeignFile(char *, int); -int Yap_CallForeignFile(void *, char *); -int Yap_CloseForeignFile(void *); -Int Yap_LoadForeign(StringList, StringList, char *, YapInitProc *); -Int Yap_ReLoadForeign(StringList, StringList, char *, YapInitProc *); -void Yap_ReOpenLoadForeign(void); -void Yap_ShutdownLoadForeign(void); - -#define EAGER_LOADING 1 +#define EAGER_LOADING 1 #define GLOBAL_LOADING 2 +/** + * stub can always be called at DLL loading. + * + */ +X_API bool load_none(void); + #endif diff --git a/H/GLOBALS b/H/GLOBALS index 6d1bfdbb6..19bd87b75 100755 --- a/H/GLOBALS +++ b/H/GLOBALS @@ -116,7 +116,7 @@ char Executable[YAP_FILENAME_MAX] void #endif int OpaqueHandlersCount =0 -struct opaque_handler_struct* OpaqueHandlers =NULL +struct YAP_opaque_handler_struct* OpaqueHandlers =NULL #if __simplescalar__ char pwd[YAP_FILENAME_MAX] void @@ -169,4 +169,6 @@ int SzOfFileAliases void struct vfs* VFS =Yap_InitAssetManager() +char* cwd =NULL + END_GLOBAL_DATA diff --git a/H/HEAPFIELDS b/H/HEAPFIELDS index 61c73faea..795f8e255 100644 --- a/H/HEAPFIELDS +++ b/H/HEAPFIELDS @@ -90,7 +90,6 @@ ATOMS #ifdef EUROTRA Term TermDollarU MkAT AtomDollarU #endif -Term TermAnswer MkAT AtomAnswer //modules Term USER_MODULE MkAT AtomUser @@ -122,7 +121,7 @@ Prop HIDDEN_PREDICATES =NULL RestoreHiddenPredicates() // make sure we have the streams set at this point. // don't actually want to define a field -void void Yap_InitPlIO() void +void void Yap_InitPlIO(yapi) void union flagTerm* GLOBAL_Flags =0 void UInt GLOBAL_flagCount Yap_InitFlags(true) RestoreFlags(GLOBAL_flagCount) @@ -141,7 +140,7 @@ rwlock_t PredHashRWLock void /* Well-Known Predicates */ struct pred_entry *CreepCode MkPred AtomCreep 1 PROLOG_MODULE -struct pred_entry *UndefCode MkPred AtomUndefp0 2 PROLOG_MODULE +struct pred_entry *UndefCode MkPred AtomUndefp 2 PROLOG_MODULE struct pred_entry *SpyCode MkPred AtomSpy 1 PROLOG_MODULE struct pred_entry *PredFail MkPred AtomFail 0 PROLOG_MODULE struct pred_entry *PredTrue MkPred AtomTrue 0 PROLOG_MODULE @@ -158,6 +157,7 @@ struct pred_entry *PredIs MkPred FunctorIs PROLOG_MODULE struct pred_entry *PredLogUpdClause MkPred FunctorDoLogUpdClause PROLOG_MODULE struct pred_entry *PredLogUpdClauseErase MkPred FunctorDoLogUpdClauseErase PROLOG_MODULE struct pred_entry *PredLogUpdClause0 MkPred FunctorDoLogUpdClause PROLOG_MODULE +struct pred_entry *PredCall MkPred FunctorCall PROLOG_MODULE struct pred_entry *PredMetaCall MkPred FunctorMetaCall PROLOG_MODULE struct pred_entry *PredProtectStack MkPred FunctorProtectStack PROLOG_MODULE struct pred_entry *PredRecordedWithKey MkPred FunctorRecordedWithKey PROLOG_MODULE @@ -168,6 +168,8 @@ struct pred_entry *PredThrow MkPred FunctorThrow PROLOG_MODULE struct pred_entry *PredTraceMetaCall MkPred FunctorTraceMetaCall PROLOG_MODULE struct pred_entry *PredCommentHook MkPred FunctorCommentHook PROLOG_MODULE struct pred_entry *PredProcedure MkLogPred FunctorProcedure PROLOG_MODULE +struct pred_entry *PredUndefinedQuery MkPred FunctorUndefinedQuery PROLOG_MODULE + /* low-level tracer */ #ifdef LOW_LEVEL_TRACER @@ -306,6 +308,9 @@ int NUM_OF_ATTS =1 void UInt Yap_AttsSize void void #endif +/** opaque terms used to wake up on cut of call catcher meta-goal */ +UInt setup_call_catcher_cleanup_tag void void + /* Operators */ struct operator_entry *OpList =NULL OpListAdjust @@ -322,7 +327,7 @@ Atom EmptyWakeups[MAX_EMPTY_WAKEUPS] InitEmptyWakeups() RestoreEmptyWakeups() int MaxEmptyWakeups =0 /* SWI blobs */ -struct YAP_blob_t *BlobTypes =NULL RestoreBlobTypes() +struct _PL_blob_t *BlobTypes =NULL RestoreBlobTypes() struct AtomEntryStruct *Blobs =NULL RestoreBlobs() UInt NOfBlobs =0 UInt NOfBlobsMax =256 diff --git a/H/LOCALS b/H/LOCALS deleted file mode 100755 index 31dac822d..000000000 --- a/H/LOCALS +++ /dev/null @@ -1,323 +0,0 @@ -// Stuff that must be considered local to a thread or worker -START_WORKER_LOCAL - -// Streams -int c_input_stream =0 -int c_output_stream =1 -int c_error_stream =2 - -bool sockets_io =false - -bool within_print_message =false - -// - -// Used by the prompts to check if they are after a newline, and then a -// prompt should be output, or if we are in the middle of a line. -// -bool newline =true - -Atom AtPrompt =AtomNil -char Prompt[MAX_PROMPT+1] void - -encoding_t encoding =Yap_DefaultEncoding() -bool quasi_quotations =false -UInt default_priority =1200 - -bool eot_before_eof =false -UInt max_depth =0 -UInt max_list =0 -UInt max_write_args =0 - - -// Restore info -CELL* OldASP =NULL -CELL* OldLCL0 =NULL -tr_fr_ptr OldTR =NULL -CELL* OldGlobalBase =NULL -CELL* OldH =NULL -CELL* OldH0 =NULL -ADDR OldTrailBase =NULL -ADDR OldTrailTop =NULL -ADDR OldHeapBase =NULL -ADDR OldHeapTop =NULL -Int ClDiff =0L -Int GDiff =0L -Int HDiff =0L -Int GDiff0 =0L -CELL* GSplit =NULL -Int LDiff =0L -Int TrDiff =0L -Int XDiff =0L -Int DelayDiff =0L -Int BaseDiff =0L - -// Reduction counters -YAP_ULONG_LONG ReductionsCounter =0L -YAP_ULONG_LONG PredEntriesCounter =0L -YAP_ULONG_LONG RetriesCounter =0L -int ReductionsCounterOn =0L -int PredEntriesCounterOn =0L -int RetriesCounterOn =0L - -// support for consulting files -/* current consult stack */ -union CONSULT_OBJ* ConsultSp =NULL -/* current maximum number of cells in consult stack */ -UInt ConsultCapacity void -/* top of consult stack */ -union CONSULT_OBJ* ConsultBase =NULL -/* low-water mark for consult */ -union CONSULT_OBJ* ConsultLow =NULL -Term VarNames =((Term)0) -Atom SourceFileName =NULL -UInt SourceFileLineno =0 - -//global variables -Term GlobalArena =0L TermToGlobalOrAtomAdjust -UInt GlobalArenaOverflows =0L -Int ArenaOverflows =0L -Int DepthArenas =0 - -struct pred_entry* LastAssertedPred =NULL -struct pred_entry* TmpPred =NULL -char* ScannerStack =NULL -struct scanner_extra_alloc* ScannerExtraBlocks =NULL - -/// worker control information -/// stack limit after which the stack is managed by C-code. -Int CBorder =0 - - -/// max number of signals (uint64_t) -UInt MaxActiveSignals =64L -/// actual life signals -uint64_t Signals =0L -/// indexing help data? -UInt IPredArity =0L -yamop* ProfEnd =NULL -int DoingUndefp =FALSE -Int StartCharCount =0L -Int StartLineCount =0L -Int StartLinePos =0L -scratch_block ScratchPad InitScratchPad(wid) -#ifdef COROUTINING -Term WokenGoals =0L TermToGlobalAdjust -Term AttsMutableList =0L TermToGlobalAdjust -#endif - - - -// gc_stuff -Term GcGeneration =0L TermToGlobalAdjust -Term GcPhase =0L TermToGlobalAdjust -UInt GcCurrentPhase =0L -UInt GcCalls =0L -Int TotGcTime =0L -YAP_ULONG_LONG TotGcRecovered =0L -Int LastGcTime =0L -Int LastSSTime =0L -CELL* OpenArray =NULL - -/* in a single gc */ -Int total_marked =0L -Int total_oldies =0L -struct choicept* current_B =NULL -CELL* prev_HB =NULL -CELL* HGEN =NULL -CELL** iptop =NULL - -#if defined(GC_NO_TAGS) -char* bp =NULL -#endif -tr_fr_ptr sTR =NULL -tr_fr_ptr sTR0 =NULL -tr_fr_ptr new_TR =NULL -struct gc_mark_continuation* cont_top0 =NULL -struct gc_mark_continuation* cont_top =NULL -int discard_trail_entries =0 -gc_ma_hash_entry gc_ma_hash_table[GC_MAVARS_HASH_SIZE] void -gc_ma_hash_entry* gc_ma_h_top =NULL -gc_ma_hash_entry* gc_ma_h_list =NULL -UInt gc_timestamp =0L -ADDR db_vec =NULL -ADDR db_vec0 =NULL -struct RB_red_blk_node* db_root =NULL -struct RB_red_blk_node* db_nil =NULL - -sigjmp_buf* gc_restore void -CELL* extra_gc_cells void -CELL* extra_gc_cells_base void -CELL* extra_gc_cells_top void -UInt extra_gc_cells_size =256 -struct array_entry* DynamicArrays =NULL PtoArrayEAdjust -struct static_array_entry* StaticArrays =NULL PtoArraySAdjust -struct global_entry* GlobalVariables =NULL PtoGlobalEAdjust -int AllowRestart =FALSE - -// Thread Local Area for Fast Storage of Intermediate Compiled Code -struct mem_blk* CMemFirstBlock =NULL -UInt CMemFirstBlockSz =0L - -// Variable used by the compiler to store number of permanent vars in a clause -int nperm =0 -int jMP =0 -// Thread Local Area for Labels -Int* LabelFirstArray =NULL -UInt LabelFirstArraySz =0L - -// Thread Local Area for SWI-Prolog emulation routines. -// struct PL_local_data* PL_local_data_p =Yap_InitThreadIO(wid) - -#ifdef THREADS -struct thandle ThreadHandle InitThreadHandle(wid) -#endif /* THREADS */ - -#if defined(YAPOR) || defined(TABLING) -struct local_optyap_data optyap_data Yap_init_local_optyap_data(wid) -UInt TabMode =0L -#endif /* YAPOR || TABLING */ - -int InterruptsDisabled =FALSE - -struct open_query_struct* execution =NULL - -#if LOW_LEVEL_TRACER -Int total_choicepoints =0 -#endif - -int consult_level =0 - -// Variables related to memory allocation -ADDR LocalBase void -ADDR GlobalBase void -ADDR TrailBase void -ADDR TrailTop void - -/* error handling info, designed to be easy to pass to the foreign world */ -yap_error_descriptor_t* ActiveError =calloc(sizeof(yap_error_descriptor_t),1) -/// pointer to an exception term, from throw - -jmp_buf* IOBotch void -TokEntry* tokptr void -TokEntry* toktide void -VarEntry* VarTable void -VarEntry* AnonVarTable void -Term Comments void -CELL* CommentsTail void -CELL* CommentsNextChar void -wchar_t* CommentsBuff void -size_t CommentsBuffPos void -size_t CommentsBuffLim void -sigjmp_buf* RestartEnv void -char FileNameBuf[YAP_FILENAME_MAX+1] void -char FileNameBuf2[YAP_FILENAME_MAX+1] void - -struct TextBuffer_manager* TextBuffer =Yap_InitTextAllocator() - -// Prolog State -UInt BreakLevel =0 -Int PrologMode =BootMode -int CritLocks =0 - -// Prolog execution and state flags -union flagTerm* Flags void -UInt flagCount void - -//analyst.c -/* used to find out how many instructions of each kind are executed */ -#ifdef ANALYST -YAP_ULONG_LONG opcount[_std_top+1] void -YAP_ULONG_LONG 2opcount[_std_top+1][_std_top+1] void -#endif /* ANALYST */ - -//dbase.c -struct db_globs* s_dbg void - -//eval.c -Term mathtt void -char* mathstring =NULL - -//grow.c -int heap_overflows =0 -Int total_heap_overflow_time =0 -int stack_overflows =0 -Int total_stack_overflow_time =0 -int delay_overflows =0 -Int total_delay_overflow_time =0 -int trail_overflows =0 -Int total_trail_overflow_time =0 -int atom_table_overflows =0 -Int total_atom_table_overflow_time =0 - -//load_dyld -#ifdef LOAD_DYLD -int dl_errno =0 -#endif - -//tracer.c -#ifdef LOW_LEVEL_TRACER -int do_trace_primitives =TRUE -#endif - -//quick loader -struct export_atom_hash_entry_struct *ExportAtomHashChain =NULL -UInt ExportAtomHashTableSize =0 -UInt ExportAtomHashTableNum =0 -struct export_functor_hash_entry_struct *ExportFunctorHashChain =NULL -UInt ExportFunctorHashTableSize =0 -UInt ExportFunctorHashTableNum =0 -struct export_pred_entry_hash_entry_struct *ExportPredEntryHashChain =NULL -UInt ExportPredEntryHashTableSize =0 -UInt ExportPredEntryHashTableNum =0 -struct export_dbref_hash_entry_struct *ExportDBRefHashChain =NULL -UInt ExportDBRefHashTableSize =0 -UInt ExportDBRefHashTableNum =0 -struct import_atom_hash_entry_struct **ImportAtomHashChain =NULL -UInt ImportAtomHashTableSize =0 -UInt ImportAtomHashTableNum =0 -struct import_functor_hash_entry_struct **ImportFunctorHashChain =NULL -UInt ImportFunctorHashTableSize =0 -UInt ImportFunctorHashTableNum =0 -struct import_opcode_hash_entry_struct **ImportOPCODEHashChain =NULL -UInt ImportOPCODEHashTableSize =0 -struct import_pred_entry_hash_entry_struct **ImportPredEntryHashChain =NULL -UInt ImportPredEntryHashTableSize =0 -UInt ImportPredEntryHashTableNum =0 -struct import_dbref_hash_entry_struct **ImportDBRefHashChain =NULL -UInt ImportDBRefHashTableSize =0 -UInt ImportDBRefHashTableNum =0 -yamop *ImportFAILCODE =NULL - -// exo indexing - -UInt ibnds[256] void -struct index_t* exo_it =NULL -CELL* exo_base =NULL -UInt exo_arity =0 -UInt exo_arg =0 - -// atom completion -struct scan_atoms* search_atoms void -struct pred_entry* SearchPreds void - -/// Slots Status -yhandle_t CurSlot =0 -yhandle_t FrozenHandles =0 -yhandle_t NSlots =0 -CELL* SlotBase =InitHandles(wid) - -// Mutexes -struct swi_mutex* Mutexes =NULL - -Term SourceModule =0 -Term Including =TermNil - -size_t MAX_SIZE =1024L - -/* last call to walltime. */ -uint64_t LastWTime =0 - -void* shared =NULL - -END_WORKER_LOCAL diff --git a/H/Regs.h b/H/Regs.h index 87a4f1357..e4c3ef110 100755 --- a/H/Regs.h +++ b/H/Regs.h @@ -24,32 +24,31 @@ #define MaxTemps 512 #define MaxArithms 32 -#ifdef i386 -#define PUSH_REGS 1 -#undef PUSH_X -#endif +#if defined(__x86_64__) -#ifdef sparc -#define PUSH_REGS 1 -#undef PUSH_X -#endif - -#ifdef __x86_64__ #define PUSH_REGS 1 #undef PUSH_X -#endif -#ifdef __alpha +#elif defined(i386) + +#undef PUSH_REGS +#undef PUSH_X + +#elif defined(sparc) +#define PUSH_REGS 1 +#undef PUSH_X + +#elif defined(__alpha) + #undef PUSH_REGS #undef PUSH_X -#endif -#if defined(_POWER) || defined(__POWERPC__) +#elif defined(_POWER) || defined(__POWERPC__) + #undef PUSH_REGS #undef PUSH_X -#endif -#ifdef hppa +#elif defined( hppa ) #undef PUSH_REGS #undef PUSH_X #endif @@ -72,12 +71,12 @@ #include "inline-only.h" -INLINE_ONLY inline EXTERN void restore_machine_regs(void); -INLINE_ONLY inline EXTERN void save_machine_regs(void); -INLINE_ONLY inline EXTERN void restore_H(void); -INLINE_ONLY inline EXTERN void save_H(void); -INLINE_ONLY inline EXTERN void restore_B(void); -INLINE_ONLY inline EXTERN void save_B(void); +INLINE_ONLY void restore_machine_regs(void); +INLINE_ONLY void save_machine_regs(void); +INLINE_ONLY void restore_H(void); +INLINE_ONLY void save_H(void); +INLINE_ONLY void restore_B(void); +INLINE_ONLY void save_B(void); #define CACHE_REGS #define REFRESH_CACHE_REGS @@ -160,7 +159,7 @@ extern REGSTORE *Yap_regp; #ifdef PUSH_X -#define XREGS (Yap_REGS.XTERMS) +#define XREGS (Yapregp->XTERMS) #else @@ -243,7 +242,7 @@ register CELL CreepFlag asm ("$15"); /* Interface with foreign code, make sure the foreign code sees all the registers the way they used to be */ -INLINE_ONLY EXTERN inline void save_machine_regs(void) { +INLINE_ONLY void save_machine_regs(void) { Yap_REGS.H_ = HR; Yap_REGS.HB_ = HB; Yap_REGS.B_ = B; @@ -254,7 +253,7 @@ INLINE_ONLY EXTERN inline void save_machine_regs(void) { Yap_REGS.TR_ = TR; } -INLINE_ONLY EXTERN inline void restore_machine_regs(void) { +INLINE_ONLY void restore_machine_regs(void) { HR = Yap_REGS.H_; HB = Yap_REGS.HB_; B = Yap_REGS.B_; @@ -283,11 +282,11 @@ INLINE_ONLY EXTERN inline void restore_machine_regs(void) { CP = BK_CP; \ TR = BK_TR -INLINE_ONLY EXTERN inline void save_H(void) { +INLINE_ONLY void save_H(void) { Yap_REGS.H_ = HR; } -INLINE_ONLY EXTERN inline void restore_H(void) { +INLINE_ONLY void restore_H(void) { HR = Yap_REGS.H_; } @@ -295,11 +294,11 @@ INLINE_ONLY EXTERN inline void restore_H(void) { #define RECOVER_H() save_H(); HR = BK_H -INLINE_ONLY EXTERN inline void save_B(void) { +INLINE_ONLY void save_B(void) { Yap_REGS.B_ = B; } -INLINE_ONLY EXTERN inline void restore_B(void) { +INLINE_ONLY void restore_B(void) { B = Yap_REGS.B_; } @@ -310,11 +309,11 @@ INLINE_ONLY EXTERN inline void restore_B(void) { INLINE_ONLY EXTERN void restore_TR(void); INLINE_ONLY EXTERN void save_TR(void); -INLINE_ONLY EXTERN inline void save_TR(void) { +INLINE_ONLY void save_TR(void) { Yap_REGS.TR_ = TR; } -INLINE_ONLY EXTERN inline void restore_TR(void) { +INLINE_ONLY void restore_TR(void) { TR = Yap_REGS.TR_; } @@ -330,7 +329,7 @@ register CELL *S asm ("r16"); register CELL CreepFlag asm ("r17"); register tr_fr_ptr TR asm ("r18"); -INLINE_ONLY EXTERN inline void save_machine_regs(void) { +INLINE_ONLY void save_machine_regs(void) { Yap_REGS.H_ = HR; Yap_REGS.HB_ = HB; Yap_REGS.B_ = B; @@ -339,7 +338,7 @@ INLINE_ONLY EXTERN inline void save_machine_regs(void) { Yap_REGS.TR_ = TR; } -INLINE_ONLY EXTERN inline void restore_machine_regs(void) { +INLINE_ONLY void restore_machine_regs(void) { HR = Yap_REGS.H_; HB = Yap_REGS.HB_; B = Yap_REGS.B_; @@ -366,11 +365,11 @@ INLINE_ONLY EXTERN inline void restore_machine_regs(void) { CP = BK_CP; \ TR = BK_TR -INLINE_ONLY EXTERN inline void save_H(void) { +INLINE_ONLY void save_H(void) { Yap_REGS.H_ = HR; } -INLINE_ONLY EXTERN inline void restore_H(void) { +INLINE_ONLY void restore_H(void) { HR = Yap_REGS.H_; } @@ -378,11 +377,11 @@ INLINE_ONLY EXTERN inline void restore_H(void) { #define RECOVER_H() save_H(); HR = BK_H -INLINE_ONLY EXTERN inline void save_B(void) { +INLINE_ONLY void save_B(void) { Yap_REGS.B_ = B; } -INLINE_ONLY EXTERN inline void restore_B(void) { +INLINE_ONLY void restore_B(void) { B = Yap_REGS.B_; } @@ -393,11 +392,11 @@ INLINE_ONLY EXTERN inline void restore_B(void) { INLINE_ONLY EXTERN void restore_TR(void); INLINE_ONLY EXTERN void save_TR(void); -INLINE_ONLY EXTERN inline void save_TR(void) { +INLINE_ONLY void save_TR(void) { Yap_REGS.TR_ = TR; } -INLINE_ONLY EXTERN inline void restore_TR(void) { +INLINE_ONLY void restore_TR(void) { TR = Yap_REGS.TR_; } @@ -442,7 +441,7 @@ register CELL *YENV asm ("r19"); -INLINE_ONLY EXTERN inline void save_machine_regs(void) { +INLINE_ONLY void save_machine_regs(void) { Yap_REGS.H_ = HR; Yap_REGS.HB_ = HB; Yap_REGS.B_ = B; @@ -451,7 +450,7 @@ INLINE_ONLY EXTERN inline void save_machine_regs(void) { Yap_REGS.TR_ = TR; } -INLINE_ONLY EXTERN inline void restore_machine_regs(void) { +INLINE_ONLY void restore_machine_regs(void) { HR = Yap_REGS.H_; HB = Yap_REGS.HB_; B = Yap_REGS.B_; @@ -476,11 +475,11 @@ INLINE_ONLY EXTERN inline void restore_machine_regs(void) { CP = BK_CP; \ TR = BK_TR -INLINE_ONLY EXTERN inline void save_H(void) { +INLINE_ONLY void save_H(void) { Yap_REGS.H_ = HR; } -INLINE_ONLY EXTERN inline void restore_H(void) { +INLINE_ONLY void restore_H(void) { HR = Yap_REGS.H_; } @@ -488,11 +487,11 @@ INLINE_ONLY EXTERN inline void restore_H(void) { #define RECOVER_H() save_H(); HR = BK_H -INLINE_ONLY EXTERN inline void save_B(void) { +INLINE_ONLY void save_B(void) { Yap_REGS.B_ = B; } -INLINE_ONLY EXTERN inline void restore_B(void) { +INLINE_ONLY void restore_B(void) { B = Yap_REGS.B_; } @@ -503,11 +502,11 @@ INLINE_ONLY EXTERN inline void restore_B(void) { INLINE_ONLY EXTERN void restore_TR(void); INLINE_ONLY EXTERN void save_TR(void); -INLINE_ONLY EXTERN inline void save_TR(void) { +INLINE_ONLY void save_TR(void) { Yap_REGS.TR_ = TR; } -INLINE_ONLY EXTERN inline void restore_TR(void) { +INLINE_ONLY void restore_TR(void) { TR = Yap_REGS.TR_; } @@ -524,30 +523,30 @@ INLINE_ONLY EXTERN inline void restore_TR(void) { #define HB Yap_REGS.HB_ /* heap (global) stack top at time of latest c.p. */ #define CreepFlag Yap_REGS.CreepFlag_ -INLINE_ONLY EXTERN inline void save_machine_regs(void) { +INLINE_ONLY void save_machine_regs(void) { } -INLINE_ONLY EXTERN inline void restore_machine_regs(void) { +INLINE_ONLY void restore_machine_regs(void) { } #define BACKUP_MACHINE_REGS() #define RECOVER_MACHINE_REGS() -INLINE_ONLY EXTERN inline void save_H(void) { +INLINE_ONLY void save_H(void) { } -INLINE_ONLY EXTERN inline void restore_H(void) { +INLINE_ONLY void restore_H(void) { } #define BACKUP_H() #define RECOVER_H() -INLINE_ONLY EXTERN inline void save_B(void) { +INLINE_ONLY void save_B(void) { } -INLINE_ONLY EXTERN inline void restore_B(void) { +INLINE_ONLY void restore_B(void) { } #define BACKUP_B() diff --git a/H/ScannerTypes.h b/H/ScannerTypes.h index c1667f7d9..d7407c7f3 100644 --- a/H/ScannerTypes.h +++ b/H/ScannerTypes.h @@ -13,7 +13,7 @@ typedef enum TokenKinds { typedef struct TOKEN { enum TokenKinds Tok; Term TokInfo; - int TokPos; + intptr_t TokPos, TokLine; struct TOKEN *TokNext; } TokEntry; diff --git a/H/Tags_32LowTag.h b/H/Tags_32LowTag.h index f54202a72..8c70bfcc4 100644 --- a/H/Tags_32LowTag.h +++ b/H/Tags_32LowTag.h @@ -79,9 +79,9 @@ #define YAP_PROTECTED_MASK 0xc0000000L #include "inline-only.h" -INLINE_ONLY inline EXTERN int IsVarTerm (Term); +INLINE_ONLY int IsVarTerm (Term); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int IsVarTerm (Term t) { return (int) (!((t) & LowTagBits)); @@ -89,9 +89,9 @@ IsVarTerm (Term t) -INLINE_ONLY inline EXTERN int IsNonVarTerm (Term); +INLINE_ONLY int IsNonVarTerm (Term); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int IsNonVarTerm (Term t) { return (int) (((t) & LowTagBits)); @@ -99,9 +99,9 @@ IsNonVarTerm (Term t) -INLINE_ONLY inline EXTERN Term *RepPair (Term); +INLINE_ONLY Term *RepPair (Term); -INLINE_ONLY inline EXTERN Term * +INLINE_ONLY Term * RepPair (Term t) { return (Term *) ((t) - PairBits); @@ -109,9 +109,9 @@ RepPair (Term t) -INLINE_ONLY inline EXTERN Term AbsPair (Term *); +INLINE_ONLY Term AbsPair (Term *); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term AbsPair (Term * p) { return (Term) (Unsigned (p) + PairBits); @@ -119,9 +119,9 @@ AbsPair (Term * p) -INLINE_ONLY inline EXTERN Int IsPairTerm (Term); +INLINE_ONLY Int IsPairTerm (Term); -INLINE_ONLY inline EXTERN Int +INLINE_ONLY Int IsPairTerm (Term t) { return (Int) ((((t) & LowTagBits) == PairBits)); @@ -129,9 +129,9 @@ IsPairTerm (Term t) -INLINE_ONLY inline EXTERN Term *RepAppl (Term); +INLINE_ONLY Term *RepAppl (Term); -INLINE_ONLY inline EXTERN Term * +INLINE_ONLY Term * RepAppl (Term t) { return (Term *) (((t) - ApplBit)); @@ -139,9 +139,9 @@ RepAppl (Term t) -INLINE_ONLY inline EXTERN Term AbsAppl (Term *); +INLINE_ONLY Term AbsAppl (Term *); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term AbsAppl (Term * p) { return (Term) (Unsigned (p) + ApplBit); @@ -149,9 +149,9 @@ AbsAppl (Term * p) -INLINE_ONLY inline EXTERN Int IsApplTerm (Term); +INLINE_ONLY Int IsApplTerm (Term); -INLINE_ONLY inline EXTERN Int +INLINE_ONLY Int IsApplTerm (Term t) { return (Int) ((((t) & LowTagBits) == ApplBit)); @@ -159,9 +159,9 @@ IsApplTerm (Term t) -INLINE_ONLY inline EXTERN Int IsAtomOrIntTerm (Term); +INLINE_ONLY Int IsAtomOrIntTerm (Term); -INLINE_ONLY inline EXTERN Int +INLINE_ONLY Int IsAtomOrIntTerm (Term t) { return (Int) ((((t) & LowTagBits) == 2)); @@ -170,9 +170,9 @@ IsAtomOrIntTerm (Term t) -INLINE_ONLY inline EXTERN Term AdjustPtr (Term t, Term off); +INLINE_ONLY Term AdjustPtr (Term t, Term off); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term AdjustPtr (Term t, Term off) { return (Term) ((t) + off); @@ -180,9 +180,9 @@ AdjustPtr (Term t, Term off) -INLINE_ONLY inline EXTERN Term AdjustIDBPtr (Term t, Term off); +INLINE_ONLY Term AdjustIDBPtr (Term t, Term off); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term AdjustIDBPtr (Term t, Term off) { return (Term) ((t) + off); @@ -191,9 +191,9 @@ AdjustIDBPtr (Term t, Term off) -INLINE_ONLY inline EXTERN Int IntOfTerm (Term); +INLINE_ONLY Int IntOfTerm (Term); -INLINE_ONLY inline EXTERN Int +INLINE_ONLY Int IntOfTerm (Term t) { return (Int) (((Int) (t << 1)) >> (SHIFT_LOW_TAG + SHIFT_HIGH_TAG + 1)); diff --git a/H/Tags_32Ops.h b/H/Tags_32Ops.h index 848093cad..f31bede5e 100644 --- a/H/Tags_32Ops.h +++ b/H/Tags_32Ops.h @@ -104,9 +104,9 @@ are now 1 in compound terms and structures. /* never forget to surround arguments to a macro by brackets */ #include "inline-only.h" -INLINE_ONLY inline EXTERN int IsVarTerm (Term); +INLINE_ONLY int IsVarTerm (Term); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int IsVarTerm (Term t) { return (int) (Signed (t) >= 0); @@ -114,9 +114,9 @@ IsVarTerm (Term t) -INLINE_ONLY inline EXTERN int IsNonVarTerm (Term); +INLINE_ONLY int IsNonVarTerm (Term); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int IsNonVarTerm (Term t) { return (int) (Signed (t) < 0); @@ -125,9 +125,9 @@ IsNonVarTerm (Term t) #if UNIQUE_TAG_FOR_PAIRS -INLINE_ONLY inline EXTERN Term *RepPair (Term); +INLINE_ONLY Term *RepPair (Term); -INLINE_ONLY inline EXTERN Term * +INLINE_ONLY Term * RepPair (Term t) { return (Term *) ((~(t))); @@ -135,9 +135,9 @@ RepPair (Term t) -INLINE_ONLY inline EXTERN Term AbsPair (Term *); +INLINE_ONLY Term AbsPair (Term *); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term AbsPair (Term * p) { return (Term) ((~Unsigned (p))); @@ -145,9 +145,9 @@ AbsPair (Term * p) -INLINE_ONLY inline EXTERN Int IsPairTerm (Term); +INLINE_ONLY Int IsPairTerm (Term); -INLINE_ONLY inline EXTERN Int +INLINE_ONLY Int IsPairTerm (Term t) { return (Int) (((t) & PairBit)); @@ -155,9 +155,9 @@ IsPairTerm (Term t) -INLINE_ONLY inline EXTERN Term *RepAppl (Term); +INLINE_ONLY Term *RepAppl (Term); -INLINE_ONLY inline EXTERN Term * +INLINE_ONLY Term * RepAppl (Term t) { return (Term *) ((-Signed (t))); @@ -165,9 +165,9 @@ RepAppl (Term t) -INLINE_ONLY inline EXTERN Term AbsAppl (Term *); +INLINE_ONLY Term AbsAppl (Term *); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term AbsAppl (Term * p) { return (Term) ((-Signed (p))); @@ -175,9 +175,9 @@ AbsAppl (Term * p) -INLINE_ONLY inline EXTERN Int IsApplTerm (Term); +INLINE_ONLY Int IsApplTerm (Term); -INLINE_ONLY inline EXTERN Int +INLINE_ONLY Int IsApplTerm (Term t) { return (Int) ((!((t) & LowTagBits))); @@ -186,9 +186,9 @@ IsApplTerm (Term t) #else -INLINE_ONLY inline EXTERN Term *RepPair (Term); +INLINE_ONLY Term *RepPair (Term); -INLINE_ONLY inline EXTERN Term * +INLINE_ONLY Term * RepPair (Term t) { return (Term *) ((-Signed (t))); @@ -196,9 +196,9 @@ RepPair (Term t) -INLINE_ONLY inline EXTERN Term AbsPair (Term *); +INLINE_ONLY Term AbsPair (Term *); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term AbsPair (Term * p) { return (Term) (((CELL) (-Signed (p)))); @@ -206,9 +206,9 @@ AbsPair (Term * p) -INLINE_ONLY inline EXTERN Int IsPairTerm (Term); +INLINE_ONLY Int IsPairTerm (Term); -INLINE_ONLY inline EXTERN Int +INLINE_ONLY Int IsPairTerm (Term t) { return (Int) ((!((t) & LowTagBits))); @@ -216,9 +216,9 @@ IsPairTerm (Term t) -INLINE_ONLY inline EXTERN Term *RepAppl (Term); +INLINE_ONLY Term *RepAppl (Term); -INLINE_ONLY inline EXTERN Term * +INLINE_ONLY Term * RepAppl (Term t) { return (Term *) ((~(t))); @@ -226,9 +226,9 @@ RepAppl (Term t) -INLINE_ONLY inline EXTERN Term AbsAppl (Term *); +INLINE_ONLY Term AbsAppl (Term *); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term AbsAppl (Term * p) { return (Term) ((~Unsigned (p))); @@ -236,9 +236,9 @@ AbsAppl (Term * p) -INLINE_ONLY inline EXTERN Int IsApplTerm (Term); +INLINE_ONLY Int IsApplTerm (Term); -INLINE_ONLY inline EXTERN Int +INLINE_ONLY Int IsApplTerm (Term t) { return (Int) (((t) & ApplBit)); @@ -247,9 +247,9 @@ IsApplTerm (Term t) #endif -INLINE_ONLY inline EXTERN Int IsAtomOrIntTerm (Term); +INLINE_ONLY Int IsAtomOrIntTerm (Term); -INLINE_ONLY inline EXTERN Int +INLINE_ONLY Int IsAtomOrIntTerm (Term t) { return (Int) (((Unsigned (t) & LowTagBits) == 0x2)); @@ -258,9 +258,9 @@ IsAtomOrIntTerm (Term t) -INLINE_ONLY inline EXTERN Int IntOfTerm (Term); +INLINE_ONLY Int IntOfTerm (Term); -INLINE_ONLY inline EXTERN Int +INLINE_ONLY Int IntOfTerm (Term t) { return (Int) ((Int) (Unsigned (t) << 3) >> 5); @@ -270,9 +270,9 @@ IntOfTerm (Term t) #if UNIQUE_TAG_FOR_PAIRS -INLINE_ONLY inline EXTERN Term AdjustPtr (Term t, Term off); +INLINE_ONLY Term AdjustPtr (Term t, Term off); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term AdjustPtr (Term t, Term off) { return (Term) (((IsVarTerm (t) @@ -284,9 +284,9 @@ AdjustPtr (Term t, Term off) -INLINE_ONLY inline EXTERN Term AdjustIDBPtr (Term t, Term off); +INLINE_ONLY Term AdjustIDBPtr (Term t, Term off); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term AdjustIDBPtr (Term t, Term off) { return (Term) (IsVarTerm (t) ? (t) + (off) : (t) - (off)); @@ -295,9 +295,9 @@ AdjustIDBPtr (Term t, Term off) #else -INLINE_ONLY inline EXTERN Term AdjustPtr (Term t, Term off); +INLINE_ONLY Term AdjustPtr (Term t, Term off); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term AdjustPtr (Term t, Term off) { return (Term) (((IsVarTerm (t) @@ -309,9 +309,9 @@ AdjustPtr (Term t, Term off) -INLINE_ONLY inline EXTERN Term AdjustIDBPtr (Term t, Term off); +INLINE_ONLY Term AdjustIDBPtr (Term t, Term off); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term AdjustIDBPtr (Term t, Term off) { return (Term) (IsVarTerm (t) ? (t) + diff --git a/H/Tags_32bits.h b/H/Tags_32bits.h index 325abb18d..9ad0948d6 100644 --- a/H/Tags_32bits.h +++ b/H/Tags_32bits.h @@ -71,9 +71,9 @@ property list #define CHKTAG(t,Tag) ((Unsigned(t)&TagBits)==Tag) #include "inline-only.h" -INLINE_ONLY inline EXTERN int IsVarTerm (Term); +INLINE_ONLY int IsVarTerm (Term); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int IsVarTerm (Term t) { return (int) (Signed (t) >= 0); @@ -81,9 +81,9 @@ IsVarTerm (Term t) -INLINE_ONLY inline EXTERN int IsNonVarTerm (Term); +INLINE_ONLY int IsNonVarTerm (Term); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int IsNonVarTerm (Term t) { return (int) (Signed (t) < 0); @@ -91,9 +91,9 @@ IsNonVarTerm (Term t) -INLINE_ONLY inline EXTERN Term *RepPair (Term); +INLINE_ONLY Term *RepPair (Term); -INLINE_ONLY inline EXTERN Term * +INLINE_ONLY Term * RepPair (Term t) { return (Term *) (NonTagPart (t)); @@ -101,9 +101,9 @@ RepPair (Term t) -INLINE_ONLY inline EXTERN Term AbsPair (Term *); +INLINE_ONLY Term AbsPair (Term *); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term AbsPair (Term * p) { return (Term) (TAGGEDA (PairTag, (p))); @@ -111,9 +111,9 @@ AbsPair (Term * p) -INLINE_ONLY inline EXTERN Int IsPairTerm (Term); +INLINE_ONLY Int IsPairTerm (Term); -INLINE_ONLY inline EXTERN Int +INLINE_ONLY Int IsPairTerm (Term t) { return (Int) (BitOn (PairBit, (t))); @@ -121,9 +121,9 @@ IsPairTerm (Term t) -INLINE_ONLY inline EXTERN Term *RepAppl (Term); +INLINE_ONLY Term *RepAppl (Term); -INLINE_ONLY inline EXTERN Term * +INLINE_ONLY Term * RepAppl (Term t) { return (Term *) (NonTagPart (t)); @@ -131,9 +131,9 @@ RepAppl (Term t) -INLINE_ONLY inline EXTERN Term AbsAppl (Term *); +INLINE_ONLY Term AbsAppl (Term *); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term AbsAppl (Term * p) { return (Term) (TAGGEDA (ApplTag, (p))); @@ -141,9 +141,9 @@ AbsAppl (Term * p) -INLINE_ONLY inline EXTERN Int IsApplTerm (Term); +INLINE_ONLY Int IsApplTerm (Term); -INLINE_ONLY inline EXTERN Int +INLINE_ONLY Int IsApplTerm (Term t) { return (Int) (BitOn (ApplBit, (t))); @@ -151,9 +151,9 @@ IsApplTerm (Term t) -INLINE_ONLY inline EXTERN int IsAtomOrIntTerm (Term); +INLINE_ONLY int IsAtomOrIntTerm (Term); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int IsAtomOrIntTerm (Term t) { return (int) (((Unsigned (t) & LowTagBits) == 0)); @@ -162,9 +162,9 @@ IsAtomOrIntTerm (Term t) -INLINE_ONLY inline EXTERN Term AdjustPtr (Term t, Term off); +INLINE_ONLY Term AdjustPtr (Term t, Term off); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term AdjustPtr (Term t, Term off) { return (Term) ((t) + off); @@ -172,9 +172,9 @@ AdjustPtr (Term t, Term off) -INLINE_ONLY inline EXTERN Term AdjustIDBPtr (Term t, Term off); +INLINE_ONLY Term AdjustIDBPtr (Term t, Term off); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term AdjustIDBPtr (Term t, Term off) { return (Term) ((t) + off); @@ -183,9 +183,9 @@ AdjustIDBPtr (Term t, Term off) -INLINE_ONLY inline EXTERN Int IntOfTerm (Term); +INLINE_ONLY Int IntOfTerm (Term); -INLINE_ONLY inline EXTERN Int +INLINE_ONLY Int IntOfTerm (Term t) { return (Int) (((Int) (t << 3)) >> (3 + 2)); diff --git a/H/Tags_64bits.h b/H/Tags_64bits.h index 5e9c398f1..0b22fcf8e 100644 --- a/H/Tags_64bits.h +++ b/H/Tags_64bits.h @@ -69,9 +69,9 @@ property list #define CHKTAG(t,Tag) ((Unsigned(t)&TagBits)==Tag) #include "inline-only.h" -INLINE_ONLY inline EXTERN int IsVarTerm (Term); +INLINE_ONLY int IsVarTerm (Term); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int IsVarTerm (Term t) { return (int) ((!((t) & 0x1))); @@ -79,9 +79,9 @@ IsVarTerm (Term t) -INLINE_ONLY inline EXTERN int IsNonVarTerm (Term); +INLINE_ONLY int IsNonVarTerm (Term); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int IsNonVarTerm (Term t) { return (int) (((t) & 0x1)); @@ -89,9 +89,9 @@ IsNonVarTerm (Term t) -INLINE_ONLY inline EXTERN Term *RepPair (Term); +INLINE_ONLY Term *RepPair (Term); -INLINE_ONLY inline EXTERN Term * +INLINE_ONLY Term * RepPair (Term t) { return (Term *) (((t) - PairBits)); @@ -99,9 +99,9 @@ RepPair (Term t) -INLINE_ONLY inline EXTERN Term AbsPair (Term *); +INLINE_ONLY Term AbsPair (Term *); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term AbsPair (Term * p) { return (Term) (((CELL) (p) + PairBits)); @@ -109,9 +109,9 @@ AbsPair (Term * p) -INLINE_ONLY inline EXTERN Int IsPairTerm (Term); +INLINE_ONLY Int IsPairTerm (Term); -INLINE_ONLY inline EXTERN Int +INLINE_ONLY Int IsPairTerm (Term t) { return (Int) (((t) & 0x2)); @@ -119,9 +119,9 @@ IsPairTerm (Term t) -INLINE_ONLY inline EXTERN Term *RepAppl (Term); +INLINE_ONLY Term *RepAppl (Term); -INLINE_ONLY inline EXTERN Term * +INLINE_ONLY Term * RepAppl (Term t) { return (Term *) (((t) - ApplBits)); @@ -129,9 +129,9 @@ RepAppl (Term t) -INLINE_ONLY inline EXTERN Term AbsAppl (Term *); +INLINE_ONLY Term AbsAppl (Term *); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term AbsAppl (Term * p) { return (Term) (((CELL) (p) + ApplBits)); @@ -139,9 +139,9 @@ AbsAppl (Term * p) -INLINE_ONLY inline EXTERN Int IsApplTerm (Term); +INLINE_ONLY Int IsApplTerm (Term); -INLINE_ONLY inline EXTERN Int +INLINE_ONLY Int IsApplTerm (Term t) { return (Int) ((((t) & 0x4))); @@ -149,9 +149,9 @@ IsApplTerm (Term t) -INLINE_ONLY inline EXTERN Int IsAtomOrIntTerm (Term); +INLINE_ONLY Int IsAtomOrIntTerm (Term); -INLINE_ONLY inline EXTERN Int +INLINE_ONLY Int IsAtomOrIntTerm (Term t) { return (Int) ((((t) & LowTagBits) == 0x1)); @@ -160,9 +160,9 @@ IsAtomOrIntTerm (Term t) -INLINE_ONLY inline EXTERN Term AdjustPtr (Term t, Term off); +INLINE_ONLY Term AdjustPtr (Term t, Term off); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term AdjustPtr (Term t, Term off) { return (Term) (((t) + off)); @@ -170,9 +170,9 @@ AdjustPtr (Term t, Term off) -INLINE_ONLY inline EXTERN Term AdjustIDBPtr (Term t, Term off); +INLINE_ONLY Term AdjustIDBPtr (Term t, Term off); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term AdjustIDBPtr (Term t, Term off) { return (Term) ((t) + off); @@ -181,9 +181,9 @@ AdjustIDBPtr (Term t, Term off) -INLINE_ONLY inline EXTERN Int IntOfTerm (Term); +INLINE_ONLY Int IntOfTerm (Term); -INLINE_ONLY inline EXTERN Int +INLINE_ONLY Int IntOfTerm (Term t) { return (Int) ((Int) (Unsigned (t) << 3) >> 6); diff --git a/H/TermExt.h b/H/TermExt.h index e8658cc2c..d6ffa0f79 100755 --- a/H/TermExt.h +++ b/H/TermExt.h @@ -71,9 +71,9 @@ typedef enum { #define IsAttVar(pt) __IsAttVar((pt)PASS_REGS) -INLINE_ONLY inline EXTERN int __IsAttVar(CELL *pt USES_REGS); +INLINE_ONLY int __IsAttVar(CELL *pt USES_REGS); -INLINE_ONLY inline EXTERN int __IsAttVar(CELL *pt USES_REGS) { +INLINE_ONLY int __IsAttVar(CELL *pt USES_REGS) { #ifdef YAP_H return (pt)[-1] == (CELL)attvar_e && pt < HR; #else @@ -81,9 +81,9 @@ INLINE_ONLY inline EXTERN int __IsAttVar(CELL *pt USES_REGS) { #endif } -INLINE_ONLY inline EXTERN int GlobalIsAttVar(CELL *pt); +INLINE_ONLY int GlobalIsAttVar(CELL *pt); -INLINE_ONLY inline EXTERN int GlobalIsAttVar(CELL *pt) { +INLINE_ONLY int GlobalIsAttVar(CELL *pt) { return (pt)[-1] == (CELL)attvar_e; } @@ -95,14 +95,15 @@ typedef enum { ARRAY_INT = 0x21, ARRAY_FLOAT = 0x22, CLAUSE_LIST = 0x40, - EXTERNAL_BLOB = 0x100, /* generic data */ - USER_BLOB_START = 0x1000, /* user defined blob */ - USER_BLOB_END = 0x1100 /* end of user defined blob */ + EXTERNAL_BLOB = 0x0A0, /* generic data */ + GOAL_CUT_POINT = 0x0A1, + USER_BLOB_START = 0x0100, /* user defined blob */ + USER_BLOB_END = 0x0200 /* end of user defined blob */ } big_blob_type; -INLINE_ONLY inline EXTERN blob_type BlobOfFunctor(Functor f); +INLINE_ONLY blob_type BlobOfFunctor(Functor f); -INLINE_ONLY inline EXTERN blob_type BlobOfFunctor(Functor f) { +INLINE_ONLY blob_type BlobOfFunctor(Functor f) { return (blob_type)((CELL)f); } @@ -160,28 +161,28 @@ typedef struct special_functors_struct { } special_functors; #endif /* YAP_H */ -INLINE_ONLY inline EXTERN Float CpFloatUnaligned(CELL *ptr); +INLINE_ONLY Float CpFloatUnaligned(CELL *ptr); #define MkFloatTerm(fl) __MkFloatTerm((fl)PASS_REGS) -INLINE_ONLY inline EXTERN Term __MkFloatTerm(Float USES_REGS); +INLINE_ONLY Term __MkFloatTerm(Float USES_REGS); -INLINE_ONLY inline EXTERN Float FloatOfTerm(Term t); +INLINE_ONLY Float FloatOfTerm(Term t); #if SIZEOF_DOUBLE == SIZEOF_INT_P -INLINE_ONLY inline EXTERN Term __MkFloatTerm(Float dbl USES_REGS) { +INLINE_ONLY Term __MkFloatTerm(Float dbl USES_REGS) { return (Term)((HR[0] = (CELL)FunctorDouble, *(Float *)(HR + 1) = dbl, HR[2] = EndSpecials, HR += 3, AbsAppl(HR - 3))); } -INLINE_ONLY inline EXTERN Float FloatOfTerm(Term t) { +INLINE_ONLY Float FloatOfTerm(Term t) { return (Float)(*(Float *)(RepAppl(t) + 1)); } #define InitUnalignedFloat() -INLINE_ONLY inline EXTERN Float CpFloatUnaligned(CELL *ptr) { +INLINE_ONLY Float CpFloatUnaligned(CELL *ptr) { return *((Float *)ptr); } @@ -191,9 +192,9 @@ INLINE_ONLY inline EXTERN Float CpFloatUnaligned(CELL *ptr) { #define DOUBLE_ALIGNED(ADDR) ((CELL)(ADDR)&0x4) -INLINE_ONLY EXTERN inline void AlignGlobalForDouble(USES_REGS1); +INLINE_ONLY void AlignGlobalForDouble(USES_REGS1); -INLINE_ONLY EXTERN inline void AlignGlobalForDouble(USES_REGS1) { +INLINE_ONLY void AlignGlobalForDouble(USES_REGS1) { /* Force Alignment for floats. Note that garbage collector may break the alignment; */ if (!DOUBLE_ALIGNED(HR)) { @@ -203,13 +204,13 @@ INLINE_ONLY EXTERN inline void AlignGlobalForDouble(USES_REGS1) { } #ifdef i386 -INLINE_ONLY inline EXTERN Float CpFloatUnaligned(CELL *ptr) { +INLINE_ONLY Float CpFloatUnaligned(CELL *ptr) { return *((Float *)(ptr + 1)); } #else /* first, need to address the alignment problem */ -INLINE_ONLY inline EXTERN Float CpFloatUnaligned(CELL *ptr) { +INLINE_ONLY Float CpFloatUnaligned(CELL *ptr) { union { Float f; CELL d[2]; @@ -221,13 +222,13 @@ INLINE_ONLY inline EXTERN Float CpFloatUnaligned(CELL *ptr) { #endif -INLINE_ONLY inline EXTERN Term __MkFloatTerm(Float dbl USES_REGS) { +INLINE_ONLY Term __MkFloatTerm(Float dbl USES_REGS) { return (Term)((AlignGlobalForDouble(PASS_REGS1), HR[0] = (CELL)FunctorDouble, *(Float *)(HR + 1) = dbl, HR[3] = EndSpecials, HR += 4, AbsAppl(HR - 4))); } -INLINE_ONLY inline EXTERN Float FloatOfTerm(Term t) { +INLINE_ONLY Float FloatOfTerm(Term t) { return (Float)((DOUBLE_ALIGNED(RepAppl(t)) ? *(Float *)(RepAppl(t) + 1) : CpFloatUnaligned(RepAppl(t)))); } @@ -246,9 +247,9 @@ OOPS #include #endif -INLINE_ONLY inline EXTERN bool IsFloatTerm(Term); +INLINE_ONLY bool IsFloatTerm(Term); -INLINE_ONLY inline EXTERN bool IsFloatTerm(Term t) { +INLINE_ONLY bool IsFloatTerm(Term t) { return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorDouble); } @@ -256,9 +257,9 @@ INLINE_ONLY inline EXTERN bool IsFloatTerm(Term t) { #define MkLongIntTerm(i) __MkLongIntTerm((i)PASS_REGS) -INLINE_ONLY inline EXTERN Term __MkLongIntTerm(Int USES_REGS); +INLINE_ONLY Term __MkLongIntTerm(Int USES_REGS); -INLINE_ONLY inline EXTERN Term __MkLongIntTerm(Int i USES_REGS) { +INLINE_ONLY Term __MkLongIntTerm(Int i USES_REGS) { HR[0] = (CELL)FunctorLongInt; HR[1] = (CELL)(i); HR[2] = EndSpecials; @@ -266,15 +267,15 @@ INLINE_ONLY inline EXTERN Term __MkLongIntTerm(Int i USES_REGS) { return AbsAppl(HR - 3); } -INLINE_ONLY inline EXTERN Int LongIntOfTerm(Term t); +INLINE_ONLY Int LongIntOfTerm(Term t); -INLINE_ONLY inline EXTERN Int LongIntOfTerm(Term t) { +INLINE_ONLY Int LongIntOfTerm(Term t) { return (Int)(RepAppl(t)[1]); } -INLINE_ONLY inline EXTERN bool IsLongIntTerm(Term); +INLINE_ONLY bool IsLongIntTerm(Term); -INLINE_ONLY inline EXTERN bool IsLongIntTerm(Term t) { +INLINE_ONLY bool IsLongIntTerm(Term t) { return IsApplTerm(t) && FunctorOfTerm(t) == FunctorLongInt; } @@ -287,53 +288,96 @@ INLINE_ONLY inline EXTERN bool IsLongIntTerm(Term t) { /* extern Functor FunctorString; */ + + #define MkStringTerm(i) __MkStringTerm((i)PASS_REGS) -INLINE_ONLY inline EXTERN Term __MkStringTerm(const char *s USES_REGS); +INLINE_ONLY Term __MkStringTerm(const char *s USES_REGS); -INLINE_ONLY inline EXTERN Term __MkStringTerm(const char *s USES_REGS) { +INLINE_ONLY Term __MkStringTerm(const char *s USES_REGS) { Term t = AbsAppl(HR); - size_t sz = ALIGN_BY_TYPE(strlen((char *)s) + 1, CELL); - HR[0] = (CELL)FunctorString; - HR[1] = (CELL)sz; - strcpy((char *)(HR + 2), (const char *)s); - HR[2 + sz] = EndSpecials; + size_t sz; + if ((s[0] == '\0')) { + sz = sizeof(CELL); + HR[0] = (CELL)FunctorString; + HR[1] = (CELL)sz; + HR[2] = 0; + } else { + sz = ALIGN_BY_TYPE(strlen((char *)s) + 1, CELL); + HR[0] = (CELL)FunctorString; + HR[1] = (CELL)sz; + strcpy((char *)(HR + 2), (const char *)s); + } + HR[2 + sz] = EndSpecials; HR += 3 + sz; return t; } #define MkUStringTerm(i) __MkUStringTerm((i)PASS_REGS) -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term __MkUStringTerm(const unsigned char *s USES_REGS); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term __MkUStringTerm(const unsigned char *s USES_REGS) { Term t = AbsAppl(HR); - size_t sz = ALIGN_BY_TYPE(strlen((char *)s) + 1, CELL); - HR[0] = (CELL)FunctorString; - HR[1] = (CELL)sz; - strcpy((char *)(HR + 2), (const char *)s); + size_t sz; + if ((s[0] == '\0')) { + sz = sizeof(CELL); + HR[0] = (CELL)FunctorString; + HR[1] = (CELL)sz; + HR[2] = 0; + } else { + sz = ALIGN_BY_TYPE(strlen((char *)s) + 1, CELL); + HR[0] = (CELL)FunctorString; + HR[1] = (CELL)sz; + strcpy((char *)(HR + 2), (const char *)s); + } + HR[2 + sz] = EndSpecials; + HR += 3 + sz; + return t; +} + +#define MkCharPTerm(i) __MkCharPTerm((i)PASS_REGS) + +INLINE_ONLY Term __MkCharPTerm(char *s USES_REGS); + +INLINE_ONLY Term __MkCharPTerm(char *s USES_REGS) { + Term t = AbsAppl(HR); + size_t sz; + if (s[0] == '\0') { + sz = sizeof(CELL); + HR[0] = (CELL)FunctorString; + HR[1] = (CELL)sz; + HR[2] = 0; + } else { + sz = ALIGN_BY_TYPE(strlen((char *)s) + 1, CELL); + HR[0] = (CELL)FunctorString; + HR[1] = (CELL)sz; + strcpy((char *)(HR + 2), (const char *)s); + } HR[2 + sz] = EndSpecials; HR += 3 + sz; return t; } -INLINE_ONLY inline EXTERN const unsigned char *UStringOfTerm(Term t); -INLINE_ONLY inline EXTERN const unsigned char *UStringOfTerm(Term t) { + +INLINE_ONLY const unsigned char *UStringOfTerm(Term t); + +INLINE_ONLY const unsigned char *UStringOfTerm(Term t) { return (const unsigned char *)(RepAppl(t) + 2); } -INLINE_ONLY inline EXTERN const char *StringOfTerm(Term t); +INLINE_ONLY const char *StringOfTerm(Term t); -INLINE_ONLY inline EXTERN const char *StringOfTerm(Term t) { +INLINE_ONLY const char *StringOfTerm(Term t) { return (const char *)(RepAppl(t) + 2); } -INLINE_ONLY inline EXTERN bool IsStringTerm(Term); +INLINE_ONLY bool IsStringTerm(Term); -INLINE_ONLY inline EXTERN bool IsStringTerm(Term t) { +INLINE_ONLY bool IsStringTerm(Term t) { return IsApplTerm(t) && FunctorOfTerm(t) == FunctorString; } @@ -344,34 +388,18 @@ INLINE_ONLY inline EXTERN bool IsStringTerm(Term t) { #include -#if !defined(__cplusplus) -#include -#endif +INLINE_ONLY bool IsBigIntTerm(Term); -#else - -typedef UInt mp_limb_t; - -typedef struct { - Int _mp_size, _mp_alloc; - mp_limb_t *_mp_d; -} MP_INT; - -typedef struct { - MP_INT _mp_num; - MP_INT _mp_den; -} MP_RAT; - -#endif - -INLINE_ONLY inline EXTERN bool IsBigIntTerm(Term); - -INLINE_ONLY inline EXTERN bool IsBigIntTerm(Term t) { +INLINE_ONLY bool IsBigIntTerm(Term t) { return IsApplTerm(t) && FunctorOfTerm(t) == FunctorBigInt; } -#ifdef USE_GMP + +#if !defined(__cplusplus) +#include +#endif + Term Yap_MkBigIntTerm(MP_INT *); MP_INT *Yap_BigIntOfTerm(Term); @@ -379,25 +407,25 @@ MP_INT *Yap_BigIntOfTerm(Term); Term Yap_MkBigRatTerm(MP_RAT *); MP_RAT *Yap_BigRatOfTerm(Term); -INLINE_ONLY inline EXTERN void MPZ_SET(mpz_t, MP_INT *); +INLINE_ONLY void MPZ_SET(mpz_t, MP_INT *); -INLINE_ONLY inline EXTERN void MPZ_SET(mpz_t dest, MP_INT *src) { +INLINE_ONLY void MPZ_SET(mpz_t dest, MP_INT *src) { dest->_mp_size = src->_mp_size; dest->_mp_alloc = src->_mp_alloc; dest->_mp_d = src->_mp_d; } -INLINE_ONLY inline EXTERN bool IsLargeIntTerm(Term); +INLINE_ONLY bool IsLargeIntTerm(Term); -INLINE_ONLY inline EXTERN bool IsLargeIntTerm(Term t) { +INLINE_ONLY bool IsLargeIntTerm(Term t) { return IsApplTerm(t) && ((FunctorOfTerm(t) <= FunctorBigInt) && (FunctorOfTerm(t) >= FunctorLongInt)); } -INLINE_ONLY inline EXTERN UInt Yap_SizeOfBigInt(Term); +INLINE_ONLY UInt Yap_SizeOfBigInt(Term); -INLINE_ONLY inline EXTERN UInt Yap_SizeOfBigInt(Term t) { +INLINE_ONLY UInt Yap_SizeOfBigInt(Term t) { CELL *pt = RepAppl(t) + 1; return 2 + (sizeof(MP_INT) + (((MP_INT *)pt)->_mp_alloc * sizeof(mp_limb_t))) / @@ -406,9 +434,9 @@ INLINE_ONLY inline EXTERN UInt Yap_SizeOfBigInt(Term t) { #else -INLINE_ONLY inline EXTERN int IsLargeIntTerm(Term); +INLINE_ONLY int IsLargeIntTerm(Term); -INLINE_ONLY inline EXTERN int IsLargeIntTerm(Term t) { +INLINE_ONLY int IsLargeIntTerm(Term t) { return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorLongInt); } @@ -416,59 +444,59 @@ INLINE_ONLY inline EXTERN int IsLargeIntTerm(Term t) { /* extern Functor FunctorLongInt; */ -INLINE_ONLY inline EXTERN bool IsLargeNumTerm(Term); +INLINE_ONLY bool IsLargeNumTerm(Term); -INLINE_ONLY inline EXTERN bool IsLargeNumTerm(Term t) { +INLINE_ONLY bool IsLargeNumTerm(Term t) { return IsApplTerm(t) && ((FunctorOfTerm(t) <= FunctorBigInt) && (FunctorOfTerm(t) >= FunctorDouble)); } -INLINE_ONLY inline EXTERN bool IsExternalBlobTerm(Term, CELL); +INLINE_ONLY bool IsExternalBlobTerm(Term, CELL); -INLINE_ONLY inline EXTERN bool IsExternalBlobTerm(Term t, CELL tag) { +INLINE_ONLY bool IsExternalBlobTerm(Term t, CELL tag) { return IsApplTerm(t) && FunctorOfTerm(t) == FunctorBigInt && RepAppl(t)[1] == tag; } -INLINE_ONLY inline EXTERN void *ExternalBlobFromTerm(Term); +INLINE_ONLY void *ExternalBlobFromTerm(Term); -INLINE_ONLY inline EXTERN void *ExternalBlobFromTerm(Term t) { +INLINE_ONLY void *ExternalBlobFromTerm(Term t) { MP_INT *base = (MP_INT *)(RepAppl(t) + 2); return (void *)(base + 1); } -INLINE_ONLY inline EXTERN bool IsNumTerm(Term); +INLINE_ONLY bool IsNumTerm(Term); -INLINE_ONLY inline EXTERN bool IsNumTerm(Term t) { +INLINE_ONLY bool IsNumTerm(Term t) { return (IsIntTerm(t) || IsLargeNumTerm(t)); } -INLINE_ONLY inline EXTERN bool IsAtomicTerm(Term); +INLINE_ONLY bool IsAtomicTerm(Term); -INLINE_ONLY inline EXTERN bool IsAtomicTerm(Term t) { +INLINE_ONLY bool IsAtomicTerm(Term t) { return IsAtomOrIntTerm(t) || IsLargeNumTerm(t) || IsStringTerm(t); } -INLINE_ONLY inline EXTERN bool IsExtensionFunctor(Functor); +INLINE_ONLY bool IsExtensionFunctor(Functor); -INLINE_ONLY inline EXTERN bool IsExtensionFunctor(Functor f) { +INLINE_ONLY bool IsExtensionFunctor(Functor f) { return f <= FunctorString; } -INLINE_ONLY inline EXTERN bool IsBlobFunctor(Functor); +INLINE_ONLY bool IsBlobFunctor(Functor); -INLINE_ONLY inline EXTERN bool IsBlobFunctor(Functor f) { +INLINE_ONLY bool IsBlobFunctor(Functor f) { return (f <= FunctorString && f >= FunctorDBRef); } -INLINE_ONLY inline EXTERN bool IsPrimitiveTerm(Term); +INLINE_ONLY bool IsPrimitiveTerm(Term); -INLINE_ONLY inline EXTERN bool IsPrimitiveTerm(Term t) { +INLINE_ONLY bool IsPrimitiveTerm(Term t) { return (IsAtomOrIntTerm(t) || (IsApplTerm(t) && IsBlobFunctor(FunctorOfTerm(t)))); @@ -476,61 +504,61 @@ INLINE_ONLY inline EXTERN bool IsPrimitiveTerm(Term t) { #ifdef TERM_EXTENSIONS -INLINE_ONLY inline EXTERN bool IsAttachFunc(Functor); +INLINE_ONLY bool IsAttachFunc(Functor); -INLINE_ONLY inline EXTERN bool IsAttachFunc(Functor f) { return (Int)(FALSE); } +INLINE_ONLY bool IsAttachFunc(Functor f) { return (Int)(FALSE); } #define IsAttachedTerm(t) __IsAttachedTerm(t PASS_REGS) -INLINE_ONLY inline EXTERN bool __IsAttachedTerm(Term USES_REGS); +INLINE_ONLY bool __IsAttachedTerm(Term USES_REGS); -INLINE_ONLY inline EXTERN bool __IsAttachedTerm(Term t USES_REGS) { +INLINE_ONLY bool __IsAttachedTerm(Term t USES_REGS) { return (IsVarTerm(t) && IsAttVar(VarOfTerm(t))); } -INLINE_ONLY inline EXTERN bool GlobalIsAttachedTerm(Term); +INLINE_ONLY bool GlobalIsAttachedTerm(Term); -INLINE_ONLY inline EXTERN bool GlobalIsAttachedTerm(Term t) { +INLINE_ONLY bool GlobalIsAttachedTerm(Term t) { return (IsVarTerm(t) && GlobalIsAttVar(VarOfTerm(t))); } #define SafeIsAttachedTerm(t) __SafeIsAttachedTerm((t)PASS_REGS) -INLINE_ONLY inline EXTERN bool __SafeIsAttachedTerm(Term USES_REGS); +INLINE_ONLY bool __SafeIsAttachedTerm(Term USES_REGS); -INLINE_ONLY inline EXTERN bool __SafeIsAttachedTerm(Term t USES_REGS) { +INLINE_ONLY bool __SafeIsAttachedTerm(Term t USES_REGS) { return IsVarTerm(t) && IsAttVar(VarOfTerm(t)); } -INLINE_ONLY inline EXTERN exts ExtFromCell(CELL *); +INLINE_ONLY exts ExtFromCell(CELL *); -INLINE_ONLY inline EXTERN exts ExtFromCell(CELL *pt) { return attvars_ext; } +INLINE_ONLY exts ExtFromCell(CELL *pt) { return attvars_ext; } #else -INLINE_ONLY inline EXTERN Int IsAttachFunc(Functor); +INLINE_ONLY Int IsAttachFunc(Functor); -INLINE_ONLY inline EXTERN Int IsAttachFunc(Functor f) { return (Int)(FALSE); } +INLINE_ONLY Int IsAttachFunc(Functor f) { return (Int)(FALSE); } -INLINE_ONLY inline EXTERN Int IsAttachedTerm(Term); +INLINE_ONLY Int IsAttachedTerm(Term); -INLINE_ONLY inline EXTERN Int IsAttachedTerm(Term t) { return (Int)(FALSE); } +INLINE_ONLY Int IsAttachedTerm(Term t) { return (Int)(FALSE); } #endif -INLINE_ONLY inline EXTERN Int Yap_BlobTag(Term t); +INLINE_ONLY Int Yap_BlobTag(Term t); -INLINE_ONLY inline EXTERN Int Yap_BlobTag(Term t) { +INLINE_ONLY Int Yap_BlobTag(Term t) { CELL *pt = RepAppl(t); return pt[1]; } -INLINE_ONLY inline EXTERN void *Yap_BlobInfo(Term t); +INLINE_ONLY void *Yap_BlobInfo(Term t); -INLINE_ONLY inline EXTERN void *Yap_BlobInfo(Term t) { +INLINE_ONLY void *Yap_BlobInfo(Term t) { MP_INT *blobp; CELL *pt = RepAppl(t); @@ -540,13 +568,13 @@ INLINE_ONLY inline EXTERN void *Yap_BlobInfo(Term t) { #ifdef YAP_H -INLINE_ONLY inline EXTERN bool unify_extension(Functor, CELL, CELL *, CELL); +INLINE_ONLY bool unify_extension(Functor, CELL, CELL *, CELL); EXTERN bool unify_extension(Functor, CELL, CELL *, CELL); int Yap_gmp_tcmp_big_big(Term, Term); -INLINE_ONLY inline EXTERN bool unify_extension(Functor f, CELL d0, CELL *pt0, +INLINE_ONLY bool unify_extension(Functor f, CELL d0, CELL *pt0, CELL d1) { switch (BlobOfFunctor(f)) { case db_ref_e: diff --git a/H/Yap.h b/H/Yap.h index 40ebc7927..ec1d39ba2 100755 --- a/H/Yap.h +++ b/H/Yap.h @@ -1,4 +1,4 @@ -/************************************************************************* + /************************************************************************* * * * YAP Prolog %W% %G% * * Yap Prolog was developed at NCCUP - Universidade do Porto * @@ -11,7 +11,7 @@ * mods: * * comments: main header file for YAP * * version: $Id: Yap.h,v 1.38 2008-06-18 10:02:27 vsc Exp $ * -*************************************************************************/ +********** ***************************************************************/ #ifndef YAP_H @@ -50,7 +50,7 @@ #endif /* THREADS && (YAPOR_COW || YAPOR_SBA || YAPOR_COPY) */ // Bad export from Python -#include "config.h" +#include "YapConfig.h" #ifndef COROUTINING #define COROUTINING 1 @@ -74,6 +74,28 @@ #include #endif +typedef YAP_Int Int; +typedef YAP_UInt UInt; +typedef YAP_Short Short; +typedef YAP_UShort UShort; + +typedef uint16_t BITS16; +typedef int16_t SBITS16; +typedef uint32_t BITS32; + +typedef YAP_CELL CELL; + +typedef YAP_Term Term; + +#define WordSize sizeof(BITS16) +#define CellSize sizeof(CELL) +#define SmallSize sizeof(SMALLUNSGN) + +typedef YAP_Int Int; +typedef YAP_Float Float; +typedef YAP_handle_t yhandle_t; + +#define TermZERO ((Term)0) /* #define RATIONAL_TREES 1 @@ -151,6 +173,11 @@ typedef void *(*fptr_t)(void); main exports in YapInterface.h *************************************************************************************************/ +extern const char *Yap_BINDIR, *Yap_ROOTDIR, *Yap_SHAREDIR, *Yap_LIBDIR, *Yap_DLLDIR, + *Yap_PLDIR, *Yap_COMMONSDIR, *Yap_STARTUP,*Yap_INPUT_STARTUP,*Yap_OUTPUT_STARTUP, + *Yap_BOOTFILE, *Yap_INCLUDEDIR; + + /* Basic exports */ #include "YapDefs.h" @@ -183,9 +210,9 @@ typedef void *(*fptr_t)(void); #endif #if !defined(HAVE_STRNLEN) -INLINE_ONLY inline EXTERN size_t strnlen(const char *s, size_t maxlen); +INLINE_ONLY size_t strnlen(const char *s, size_t maxlen); -INLINE_ONLY inline EXTERN size_t strnlen(const char *s, size_t maxlen) { +INLINE_ONLY size_t strnlen(const char *s, size_t maxlen) { size_t i = 0; while (s[i]) { if (i == maxlen) @@ -258,6 +285,7 @@ extern size_t Yap_page_size; #define M1 ((CELL)(1024 * 1024)) #define M2 ((CELL)(2048 * 1024)) +typedef YAP_UInt CELL; #if ALIGN_LONGS typedef CELL SFLAGS; #else @@ -447,7 +475,7 @@ extern int Yap_output_msg; #include #include -extern AAssetManager *Yap_assetManager; +extern AAssetManager *Yap_assetManager(void); extern void *Yap_openAssetFile(const char *path); extern bool Yap_isAsset(const char *path); @@ -820,8 +848,10 @@ inline static void LOG0(const char *f, int l, const char *fmt, ...) { #include "GitSHA1.h" -extern bool Yap_embedded, Yap_Server; +extern bool Yap_Embedded, Yap_Server; + +#include "YapText.h" #endif /* YAP_H */ -#include "YapText.h" + diff --git a/H/YapCompile.h b/H/YapCompile.h index 520ef48f7..9ce8f27ba 100644 --- a/H/YapCompile.h +++ b/H/YapCompile.h @@ -1,305 +1,245 @@ /************************************************************************* -* * -* YAP Prolog %W% %G% * -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * -* * +* * +* YAP Prolog %W% %G% * +* * +*Yap Prolog was developed at NCCUP - Universidade do Porto * +* * +* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * +* * ************************************************************************** -* * -* File: YapCompile.h * -* Last rev: * -* mods: * -* comments: compiler data structures and routines * -* * +* * +* File:YapCompile.h * +* Last rev: * +* mods: * +* comments:compiler data structures and routines * +* * *************************************************************************/ /* consult stack management */ -/* virtual machine instruction op-codes */ -#define mklist0(f) \ - f(nop_op, "nop") f(get_var_op, "get_var\t\t%v,%r") f(put_var_op, "put_" \ - "var\t\t%" \ - "v,%r") f( \ - get_val_op, "get_val\t\t%v,%r") f(put_val_op, \ - "put_val\t\t%v,%r") f(get_atom_op, \ - "get_atom\t%a,%" \ - "r") f(put_atom_op, \ - "put_" \ - "atom\t%" \ - "a,%r") \ - f(get_num_op, "get_num\t\t%n,%r") f(put_num_op, "put_num\t\t%n,%r") f( \ - get_float_op, \ - "get_float\t\t%w,%r") f(put_float_op, \ - "put_float\t\t%w,%r") f(get_dbterm_op, \ - "get_dbterm\t%w,%r") \ - f(put_dbterm_op, "put_dbterm\t%w,%r") f(get_longint_op, "get_" \ - "longint\t" \ - "\t%w,%r") f( \ - put_longint_op, \ - "put_longint\t\t%w,%r") f(get_string_op, \ - "get_string\t\t%w,%S") f(put_string_op, \ - "put_" \ - "string\t\t%" \ - "w,%S") \ - f(get_bigint_op, "get_bigint\t\t%l,%r") f(put_bigint_op, "put_" \ - "bigin" \ - "t\t\t" \ - "%l,%" \ - "r") f( \ - get_list_op, \ - "get_list\t%r") f(put_list_op, \ - "put_list\t%r") f(get_struct_op, \ - "get_struct\t%f,%r") \ - f(put_struct_op, "put_struct\t%f,%r") f(put_unsafe_op, "put" \ - "_un" \ - "saf" \ - "e\t" \ - "%v," \ - "%r") f( \ - unify_var_op, \ - "unify_var\t%v") f(write_var_op, \ - "write_var\t%v") f(unify_val_op, \ - "unify_val\t%v") \ - f(write_val_op, "write_val\t%v") f(unify_atom_op, "unif" \ - "y_" \ - "atom" \ - "\t%" \ - "a") f( \ - write_atom_op, \ - "write_atom\t%a") f(unify_num_op, \ - "unify_num\t%n") f(write_num_op, \ - "write_" \ - "num\t%n") \ - f(unify_float_op, "unify_float\t%w") f( \ - write_float_op, \ - "write_float\t%w") f(unify_dbterm_op, \ - "unify_dbterm\t%w") \ - f(write_dbterm_op, "write_dbterm\t%w") f( \ - unify_longint_op, \ - "unify_longint\t%w") f(write_longint_op, \ - "write_longint\t%w") \ - f(unify_string_op, "unify_string\t%S") f( \ - write_string_op, \ - "write_string\t%S") f(unify_bigint_op, \ - "unify_bigint\t%" \ - "l") f(write_bigint_op, \ - "write_" \ - "bigint\t%" \ - "l") \ - f(unify_list_op, "unify_list") f( \ - write_list_op, \ - "write_list") f(unify_struct_op, \ - "unify_struct\t%f") \ - f(write_struct_op, "write_struct\t%" \ - "f") f( \ - write_unsafe_op, \ - "write_unsafe\t%v") f(unify_local_op, \ - "unify_" \ - "local\t%" \ - "v") \ - f(write_local_op, "write " \ - "local\t%v") f( \ - unify_last_list_op, \ - "unify_last_list") \ - f(write_last_list_op, "writ" \ - "e_" \ - "last" \ - "_lis" \ - "t") f( \ - unify_last_struct_op, \ - "unify_last_struct\t%f") \ - f(write_last_struct_op, \ - "write_last_struct\t%" \ - "f") f(unify_last_var_op, \ - "unify_last_" \ - "var\t%v") \ - f( \ - unify_last_val_op, \ - "unify_last_" \ - "val\t%v") f(unify_last_local_op, \ - "u" \ - "n" \ - "i" \ - "f" \ - "y" \ - "_" \ - "l" \ - "a" \ - "s" \ - "t" \ - "_" \ - "l" \ - "o" \ - "c" \ - "a" \ - "l" \ - "\t%v") f(unify_last_atom_op, \ - "unify_last_atom\t%a") f(unify_last_num_op, "unify_last_num\t%n") f(unify_last_float_op, "unify_last_float\t%w") f(unify_last_dbterm_op, "unify_last_dbterm\t%w") f(unify_last_longint_op, "unify_last_longint\t%w") f(unify_last_string_op, "unify_last_string\t%S") f(unify_last_bigint_op, "unify_last_bigint\t%l") f(ensure_space_op, \ - "ensure_space") f(native_op, \ - "native_code") f(f_var_op, "function_to_var\t%v,%B") f(f_val_op, "function_to_val\t%v,%B") f(f_0_op, "function_to_0\t%B") f(align_float_op, \ - "align_float") f(fail_op, "fail") f(cut_op, "cut") f(cutexit_op, \ - "cutexit") f(allocate_op, \ - "allocate") f(deallocate_op, \ - "deallocate") f(tryme_op, \ - "try_me_else\t\t%l\t%x") f(jump_op, \ - "jump\t\t%l") f(jumpi_op, \ - "jump_in_indexing\t\t%i") f(procceed_op, "proceed") f(call_op, "call\t\t%p,%d,%z") f(execute_op, "execute\t\t%p") f(safe_call_op, "sys\t\t%p") f(label_op, \ - "%l:") f(name_op, "name\t\t%m,%d") f(pop_op, \ - "pop\t\t%l") f(retryme_op, \ - "retry_me_else\t\t%l\t%x") f(trustme_op, \ - "trust_me_else_fail\t%x") f(either_op, "either_me\t\t%l,%d,%z") f(orelse_op, "or_else\t\t%l,%z") f(orlast_op, \ - "or_last") f(push_or_op, "push_or") f(pushpop_or_op, "pushpop_or") f(pop_or_op, "pop_or") f(save_b_op, "save_by\t\t%v") f(commit_b_op, \ - "commit_by\t\t%v") f(patch_b_op, "patch_by\t\t%v") f(try_op, \ - "try\t\t%g\t%x") f(retry_op, "retry\t\t%g\t%x") f(trust_op, \ - "trust\t\t%g\t%x") f(try_in_op, \ - "try_in\t\t%g\t%x") f(jump_v_op, \ - "jump_if_var\t\t%g") f(jump_nv_op, "jump_if_nonvar\t\t%g") f(cache_arg_op, "cache_arg\t%r") f(cache_sub_arg_op, "cache_sub_arg\t%d") f(user_switch_op, \ - "user_switch") f(switch_on_type_op, "switch_on_type\t%h\t%h\t%h\t%h") f(switch_c_op, \ - "switch_on_constant\t%i\n%c") f(if_c_op, \ - "if_constant\t%i\n%c") f(switch_f_op, \ - "switch_on_functor\t%i\n%e") f(if_f_op, "if_functor\t%i\n%e") f(if_not_op, "if_not_then\t%i\t%h\t%h\t%h") \ - f(index_dbref_op, \ - "index_on_" \ - "dbref") f(index_blob_op, \ - "i" \ - "n" \ - "d" \ - "e" \ - "x" \ - "_" \ - "o" \ - "n" \ - "_" \ - "b" \ - "l" \ - "o" \ - "b") f(index_string_op, "index_on_string") \ - f(index_long_op, "index_on_blob") f( \ - if_nonvar_op, \ - "check_" \ - "var\t " \ - "%r") f(save_pair_op, "save_pair\t%v") \ - f(save_appl_op, "save_appl\t%v") f( \ - mark_initialized_pvars_op, \ - "pv" \ - "ar" \ - "_b" \ - "it" \ - "ma" \ - "p" \ - "\t" \ - "%l" \ - ",%" \ - "b") f(mark_live_regs_op, \ - "pvar_live_regs\t%l,%b") \ - f(fetch_args_vv_op, "fetch_reg1_reg2\t%N,%N") f( \ - fetch_args_cv_op, \ - "fetch_constant_reg\t%l,%N") f(fetch_args_vc_op, \ - "fetch_reg_constant\t%l,%N") \ - f(fetch_args_iv_op, "fetch_integer_reg\t%d,%N") f( \ - fetch_args_vi_op, \ - "fetch_reg_integer\t%d,%N") f(enter_profiling_op, \ - "enter_profiling\t\t%g") \ - f(retry_profiled_op, "retry_profiled\t\t%g") f( \ - count_call_op, \ - "count_call_op\t\t%g") f(count_retry_op, \ - "count_retry_op\t\t%g") \ - f(restore_tmps_op, "restore_temps\t\t%l") f( \ - restore_tmps_and_skip_op, \ - "restore_temps_and_skip\t\t%l") \ - f(enter_lu_op, "enter_lu") f( \ - empty_call_op, \ - "empty_call\t\t%l,%d") \ - f(bccall_op, \ - "binary_cfunc\t\t%v,%r,%2") \ - f(blob_op, \ - "blob\t%O") \ - f(string_op, \ - "string\t%O") \ - f(label_ctl_op, \ - "label_control\t") -#ifdef YAPOR -#define mklist1(f) mklist0(f) f(sync_op, "sync") +#undef COMPILER_OPS +#undef COMPILER_OPS_END +#undef f + +#ifdef COMPILER_NAMES + +#define COMPILER_OPS() char *opDesc[] = +#define COMPILER_OPS_END() +#define f(x,y) y + #else -#define mklist1(f) mklist0(f) + +#define COMPILER_OPS() typedef enum compiler_op +#define COMPILER_OPS_END() compiler_vm_op +#define f(x,y) x + +#endif + +/* virtual machine instruction op-codes*/ +COMPILER_OPS() { + f(nop_op, "nop"), + f(get_var_op, "get_var\t\t %v,%r"), + f(put_var_op, "put_var\t\t %v,%r"), + f( get_val_op, "get_val\t\t %v,%r"), + f(put_val_op, "put_val\t\t %v,%r"), + f(get_atom_op, "get_atom\t %a,%r"), + f(put_atom_op, "put_atom\t %a,%r"), + f(get_num_op, "get_num\t\t %n,%r"), + f(put_num_op, "put_num\t\t %n,%r"), + f( get_float_op, "get_float\t\t %w,%r"), + f(put_float_op, "put_float\t\t %w,%r"), + f(get_dbterm_op, "get_dbterm\t %w,%r"), + f(put_dbterm_op, "put_dbterm\t %w,%r"), + f(get_longint_op, "get_longint\t\t %w,%r"), + f( put_longint_op, "put_longint\t\t %w,%r"), + f(get_string_op, "get_string\t\t %w,%S"), + f(put_string_op, "put_string\t\t %w,%S"), + f(get_bigint_op, "get_bigint\t\t %l,%r"), + f(put_bigint_op, "put_bigint\t\t %l,%r"), + f( get_list_op, "get_list\t %r"), + f(put_list_op, "put_list\t %r"), + f(get_struct_op, "get_struct\t %f,%r"), + f(put_struct_op, "put_struct\t %f,%r"), + f(put_unsafe_op, "put_unsafe\t %v,%r"), + f( unify_var_op, "unify_var\t %v"), + f(write_var_op, "write_var\t %v"), + f(unify_val_op, "unify_val\t %v"), + f(write_val_op, "write_val\t %v"), + f(unify_atom_op, "unify_atom\t %a"), + f( write_atom_op, "write_atom\t %a"), + f(unify_num_op, "unify_num\t %n"), + f(write_num_op, "write_num\t %n"), + f(unify_float_op, "unify_float\t %w"), + f( write_float_op, "write_float\t %w"), + f(unify_dbterm_op, "unify_dbterm\t %w"), + f(write_dbterm_op, "write_dbterm\t %w"), + f( unify_longint_op, "unify_longint\t %w"), + f(write_longint_op, "write_longint\t %w"), + f(unify_string_op, "unify_string\t %S"), + f( write_string_op, "write_string\t %S"), + f(unify_bigint_op, "unify_bigint\t %l"), + f(write_bigint_op, "write_bigint\t %l"), + f(unify_list_op, "unify_list"), + f( write_list_op, "write_list"), + f(unify_struct_op, "unify_struct\t %f"), + f(write_struct_op, "write_struct\t %f"), + f( write_unsafe_op, "write_unsafe\t %v"), + f(unify_local_op, "unify_local\t %v"), + f(write_local_op, "write local\t %v"), + f( unify_last_list_op, "unify_last_list"), + f(write_last_list_op, "write_last_list"), + f( unify_last_struct_op, "unify_last_struct\t %f"), + f(write_last_struct_op, "write_last_struct\t %f"), + f(unify_last_var_op, "unify_last_var\t %v"), + f( unify_last_val_op, "unify_last_val\t %v"), + f(unify_last_local_op, "unify_last_local\t %v"), + f(unify_last_atom_op, "unify_last_atom\t %a"), + f(unify_last_num_op, "unify_last_num\t %n"), + f(unify_last_float_op, "unify_last_float\t %w"), + f(unify_last_dbterm_op, "unify_last_dbterm\t %w"), + f(unify_last_longint_op, "unify_last_longint\t %w"), + f(unify_last_string_op, "unify_last_string\t %S"), + f(unify_last_bigint_op, "unify_last_bigint\t %l"), + f(ensure_space_op, "ensure_space"), + f(native_op, "native_code"), + f(f_var_op, "function_to_var\t %v,%B"), + f(f_val_op, "function_to_val\t %v,%B"), + f(f_0_op, "function_to_0\t %B"), + f(align_float_op, "align_float"), + f(fail_op, "fail"), + f(cut_op, "cut"), + f(cutexit_op, "cutexit"), + f(allocate_op, "allocate"), + f(deallocate_op, "deallocate"), + f(tryme_op, "try_me_else\t\t %l\t %x"), + f(jump_op, "jump\t\t %l"), + f(jumpi_op, "jump_in_indexing\t\t %i"), + f(procceed_op, "proceed"), + f(call_op, "call\t\t %p,%d,%z"), + f(execute_op, "execute\t\t %p"), + f(safe_call_op, "sys\t\t %p"), + f(label_op, "%l:"), + f(name_op, "name\t\t %m,%d"), + f(pop_op, "pop\t\t %l"), + f(retryme_op, "retry_me_else\t\t %l\t %x"), + f(trustme_op, "trust_me_else_fail\t %x"), + f(either_op, "either_me\t\t %l,%d,%z"), + f(orelse_op, "or_else\t\t %l,%z"), + f(orlast_op, "or_last"), + f(push_or_op, "push_or"), + f(pushpop_or_op, "pushpop_or"), + f(pop_or_op, "pop_or"), + f(save_b_op, "save_by\t\t %v"), + f(commit_b_op, "commit_by\t\t %v"), + f(patch_b_op, "patch_by\t\t %v"), + f(try_op, "try\t\t %g\t %x"), + f(retry_op, "retry\t\t %g\t %x"), + f(trust_op, "trust\t\t %g\t %x"), + f(try_in_op, "try_in\t\t %g\t %x"), + f(jump_v_op, "jump_if_var\t\t %g"), + f(jump_nv_op, "jump_if_nonvar\t\t %g"), + f(cache_arg_op, "cache_arg\t %r"), + f(cache_sub_arg_op, "cache_sub_arg\t %d"), + f(user_switch_op, "user_switch"), + f(switch_on_type_op, "switch_on_type\t %h\t %h\t %h\t %h"), + f(switch_c_op, "switch_on_constant\t %i,n%c"), + f(if_c_op, "if_constant\t %i,n%c"), + f(switch_f_op, "switch_on_functor\t %i,n%e"), + f(if_f_op, "if_functor\t %i,n%e"), + f(if_not_op, "if_not_then\t %i\t %h\t %h\t %h"), + f(index_dbref_op, "index_on_dbref"), + f(index_blob_op, "index_on_blob"), + f(index_string_op, "index_on_string"), + f(index_long_op, "index_on_blob"), + f( if_nonvar_op, "check_var\t %r"), + f(save_pair_op, "save_pair\t %v"), + f(save_appl_op, "save_appl\t %v"), + f( mark_initialized_pvars_op, "pvar_bitmap\t %l,%b"), + f(mark_live_regs_op, "pvar_live_regs\t %l,%b"), + f(fetch_args_vv_op, "fetch_reg1_reg2\t %N,%N"), + f( fetch_args_cv_op, "fetch_constant_reg\t %l,%N"), + f(fetch_args_vc_op, "fetch_reg_constant\t %l,%N"), + f(fetch_args_iv_op, "fetch_integer_reg\t %d,%N"), + f( fetch_args_vi_op, "fetch_reg_integer\t %d,%N"), + f(enter_profiling_op, "enter_profiling\t\t %g"), + f(retry_profiled_op, "retry_profiled\t\t %g"), + f( count_call_op, "count_call_op\t\t %g"), + f(count_retry_op, "count_retry_op\t\t %g"), + f(restore_tmps_op, "restore_temps\t\t %l"), + f( restore_tmps_and_skip_op, "restore_temps_and_skip\t\t %l"), + f(enter_lu_op, "enter_lu"), + f( empty_call_op, "empty_call\t\t %l,%d"), + f(bccall_op, "binary_cfunc\t\t %v,%r,%2"), + f(blob_op, "blob\t %O"), + f(string_op, "string\t %O"), + f(label_ctl_op, "label_control\t"), +#ifdef YAPOR + f(sync_op, "sync"), #endif /* YAPOR */ #ifdef TABLING -#define mklist2(f) \ - mklist1(f) f(table_new_answer_op, "table_new_answer") \ - f(table_try_single_op, "table_try_single\t%g\t%x") -#else -#define mklist2(f) mklist1(f) -#endif /* TABLING */ + f(table_new_answer_op, "table_new_answer"), + f(table_try_single_op, "table_try_single\t %g\t %x"), #ifdef TABLING_INNER_CUTS -#define mklist3(f) mklist2(f) f(clause_with_cut_op, "clause_with_cut") -#else -#define mklist3(f) mklist2(f) + f(clause_with_cut_op, "clause_with_cut"), #endif /* TABLING_INNER_CUTS */ + #endif #ifdef BEAM -#define mklist4(f) \ - mklist3(f) f(run_op, "run_op %1,%4") f(body_op, "body_op %1") f( \ - endgoal_op, "endgoal_op") f(try_me_op, "try_me_op %1,%4") \ - f(retry_me_op, "retry_me_op %1,%4") f(trust_me_op, "trust_me_op %1,%4") \ - f(only_1_clause_op, "only_1_clause_op %1,%4") f( \ - create_first_box_op, "create_first_box_op %1,%4") \ - f(create_box_op, "create_box_op %1,%4") f( \ - create_last_box_op, "create_last_box_op %1,%4") \ - f(remove_box_op, "remove_box_op %1,%4") f( \ - remove_last_box_op, "remove_last_box_op %1,%4") \ - f(prepare_tries, "prepare_tries") f(std_base_op, \ - "std_base_op %1,%4") \ - f(direct_safe_call_op, "direct_safe_call") \ - f(commit_op, ) f(skip_while_var_op, \ - "skip_while_var_op") \ - f(wait_while_var_op, "wait_while_var_op") \ - f(force_wait_op, "force_wait_op") \ - f(is_op, "is_op") \ - f(write_op, "write_op") \ - f(equal_op, "equal_op") \ - f(exit_op, "exit") -#else -#define mklist4(f) mklist3(f) + f(run_op, "run_op %1,%4"), + f(body_op, "body_op %1"), + f( endgoal_op, "endgoal_op"), + f(try_me_op, "try_me_op %1,%4"), + f(retry_me_op, "retry_me_op %1,%4"), + f(trust_me_op, "trust_me_op %1,%4"), + f(only_1_clause_op, "only_1_clause_op %1,%4"), + f( create_first_box_op, "create_first_box_op %1,%4"), + f(create_box_op, "create_box_op %1,%4"), + f( create_last_box_op, "create_last_box_op %1,%4"), + f(remove_box_op, "remove_box_op %1,%4"), + f( remove_last_box_op, "remove_last_box_op %1,%4"), + f(prepare_tries, "prepare_tries"), + f(std_base_op, "std_base_op %1,%4"), + f(direct_safe_call_op, "direct_safe_call"), + f(commit_op, ), + f(skip_while_var_op, "skip_while_var_op"), + f(wait_while_var_op, "wait_while_var_op"), + f(force_wait_op, "force_wait_op"), + f(is_op, "is_op"), + f(write_op, "write_op"), + f(equal_op, "equal_op"), + f(exit_op, "exit"), #endif #ifdef SFUNC -#define mklist(f) \ - mklist4(f) f(get_s_f_op, "get_s_f_op\t%f,%r") \ - f(put_s_f_op, "put_s_f_op\t%f,%r") f(unify_s_f_op, "unify_s_f_op\t%f") \ - f(write_s_f_op, "write_s_f_op\t%f") \ - f(unify_s_var_op, "unify_s_var\t%v,%r") f(write_s_var_op, \ - "write_s_var\t%v,%r") \ - f(unify_s_val_op, "unify_s_val\t%v,%r") \ - f(write_s_val_op, "write_s_val\t%v,%r") \ - f(unify_s_a_op, "unify_s_a\t%a,%r") \ - f(write_s_a_op, "write_s_a\t%a,%r") \ - f(get_s_end_op, "get_s_end") \ - f(put_s_end_op, "put_s_end") \ - f(unify_s_end_op, "unify_s_end") \ - f(write_s_end_op, "write_s_end") -#else -#define mklist(f) mklist4(f) + f(get_s_f_op, "get_s_f_op\t %f,%r"), + f(put_s_f_op, "put_s_f_op\t %f,%r"), + f(unify_s_f_op, "unify_s_f_op\t %f"), + f(write_s_f_op, "write_s_f_op\t %f"), + f(unify_s_var_op, "unify_s_var\t %v,%r"), + f(write_s_var_op, "write_s_var\t %v,%r"), + f(unify_s_val_op, "unify_s_val\t %v,%r"), + f(write_s_val_op, "write_s_val\t %v,%r"), + f(unify_s_a_op, "unify_s_a\t %a,%r"), + f(write_s_a_op, "write_s_a\t %a,%r"), + f(get_s_end_op, "get_s_end"), + f(put_s_end_op, "put_s_end"), + f(unify_s_end_op, "unify_s_end"), + f(write_s_end_op, "write_s_end"), #endif + } COMPILER_OPS_END(); -#define f_enum(x, y) x, -#define f_arr(x, y) y, - -enum compiler_op { mklist(f_enum) }; - -typedef enum compiler_op compiler_vm_op; +#ifndef COMPILER_NAMES typedef struct PSEUDO { - struct PSEUDO *nextInst; - enum compiler_op op; - CELL rnd1; - union { - Int oprnd2; + struct PSEUDO *nextInst; + enum compiler_op op; + CELL rnd1; + union { + Int oprnd2; #if MIN_ARRAY == 0 - CELL opseqt[MIN_ARRAY]; + CELL opseqt[MIN_ARRAY]; #else - CELL opseqt[1]; + CELL opseqt[1]; #endif - } ops; + } ops; } PInstr; #define arnds ops.opseqt @@ -312,26 +252,26 @@ typedef struct PSEUDO { #define rnd8 ops.opseqt[6] typedef struct VENTRY { - CELL SelfOfVE; - Term AdrsOfVE; - Int KindOfVE; - CELL NoOfVE; - PInstr *FirstOpForV; - PInstr *LastOpForV; - BITS16 AgeOfVE; - BITS16 BranchOfVE; - BITS16 LastBranchOfVE; - BITS16 FirstOfVE; - BITS16 RCountOfVE; - BITS16 FlagsOfVE; - struct VENTRY *NextOfVE; + CELL SelfOfVE; + Term AdrsOfVE; + Int KindOfVE; + CELL NoOfVE; + PInstr *FirstOpForV; + PInstr *LastOpForV; + BITS16 AgeOfVE; + BITS16 BranchOfVE; + BITS16 LastBranchOfVE; + BITS16 FirstOfVE; + BITS16 RCountOfVE; + BITS16 FlagsOfVE; + struct VENTRY *NextOfVE; } Ventry; typedef struct CEXPENTRY { - Term TermOfCE; - PInstr *CodeOfCE; - Term VarOfCE; - struct CEXPENTRY *NextCE; + Term TermOfCE; + PInstr *CodeOfCE; + Term VarOfCE; + struct CEXPENTRY *NextCE; } CExpEntry; #define COMPILER_ERR_BOTCH 1 @@ -342,48 +282,48 @@ typedef struct CEXPENTRY { #define OUT_OF_TRAIL_BOTCH 6 typedef struct intermediates { - char *freep; - char *freep0; - struct mem_blk *blks; - char *blk_cur, *blk_top; - struct PSEUDO *cpc; - struct PSEUDO *CodeStart; - struct PSEUDO *icpc; - struct PSEUDO *BlobsStart; - struct dbterm_list *dbterml; - Int *label_offset; - Int *uses; - Term *contents; - struct pred_entry *CurrentPred; - sigjmp_buf CompilerBotch; - yamop *code_addr; - yamop *expand_block; - UInt i_labelno; - UInt exception_handler, success_handler, failure_handler; - /* for expanding code */ - yamop **current_try_lab, **current_trust_lab; - yamop *try_instructions; - struct StructClauseDef *cls; - int clause_has_cut; - UInt term_depth, last_index_at_depth; - UInt last_index_new_depth, last_depth_size; - /* for expanding code */ - union { - struct static_index *si; - struct logic_upd_index *lui; - } current_cl; + char *freep; + char *freep0; + struct mem_blk *blks; + char *blk_cur, *blk_top; + struct PSEUDO *cpc; + struct PSEUDO *CodeStart; + struct PSEUDO *icpc; + struct PSEUDO *BlobsStart; + struct dbterm_list *dbterml; + Int *label_offset; + Int *uses; + Term *contents; + struct pred_entry *CurrentPred; + sigjmp_buf CompilerBotch; + yamop *code_addr; + yamop *expand_block; + UInt i_labelno; + UInt exception_handler, success_handler, failure_handler; + /* for expanding code */ + yamop **current_try_lab, **current_trust_lab; + yamop *try_instructions; + struct StructClauseDef *cls; + int clause_has_cut; + UInt term_depth, last_index_at_depth; + UInt last_index_new_depth, last_depth_size; + /* for expanding code */ + union { + struct static_index *si; + struct logic_upd_index *lui; + } current_cl; } CIntermediates; typedef enum special_label_id_enum { - SPECIAL_LABEL_SUCCESS = 0, - SPECIAL_LABEL_FAILURE = 1, - SPECIAL_LABEL_EXCEPTION = 2 + SPECIAL_LABEL_SUCCESS = 0, + SPECIAL_LABEL_FAILURE = 1, + SPECIAL_LABEL_EXCEPTION = 2 } special_label_id; typedef enum special_label_op_enum { - SPECIAL_LABEL_INIT = 0, - SPECIAL_LABEL_SET = 1, - SPECIAL_LABEL_CLEAR = 2 + SPECIAL_LABEL_INIT = 0, + SPECIAL_LABEL_SET = 1, + SPECIAL_LABEL_CLEAR = 2 } special_label_op; #define SafeVar 0x01 @@ -415,23 +355,20 @@ typedef enum special_label_op_enum { #define One 1 #define Two 2 -extern yamop *Yap_assemble(int, Term, struct pred_entry *, int, - struct intermediates *, UInt); -void Yap_emit(compiler_vm_op, Int, CELL, struct intermediates *); -void Yap_emit_3ops(compiler_vm_op, CELL, CELL, CELL, struct intermediates *); -void Yap_emit_4ops(compiler_vm_op, CELL, CELL, CELL, CELL, - struct intermediates *); -void Yap_emit_5ops(compiler_vm_op, CELL, CELL, CELL, CELL, CELL, - struct intermediates *); -void Yap_emit_6ops(compiler_vm_op, CELL, CELL, CELL, CELL, CELL, CELL, - struct intermediates *); -void Yap_emit_7ops(compiler_vm_op, CELL, CELL, CELL, CELL, CELL, CELL, CELL, - struct intermediates *); -CELL *Yap_emit_extra_size(compiler_vm_op, CELL, int, struct intermediates *); -char *Yap_AllocCMem(UInt, struct intermediates *); -void Yap_ReleaseCMem(struct intermediates *); -int Yap_is_a_test_pred(Term, Term); -void Yap_bip_name(Int, char *); +extern yamop *Yap_assemble(int, Term, struct pred_entry *, int, struct intermediates *, UInt); +extern void Yap_emit(compiler_vm_op, Int, CELL, struct intermediates *); +extern void Yap_emit_3ops(compiler_vm_op, CELL, CELL, CELL, struct intermediates *); +extern void Yap_emit_4ops(compiler_vm_op, CELL, CELL, CELL, CELL, struct intermediates *); +extern void Yap_emit_5ops(compiler_vm_op, CELL, CELL, CELL, CELL, CELL,struct intermediates *); +extern void Yap_emit_6ops(compiler_vm_op, CELL, CELL, CELL, CELL, CELL, CELL,struct intermediates *); +extern void Yap_emit_7ops(compiler_vm_op, CELL, CELL, CELL, CELL, CELL, CELL, CELL, struct intermediates *); +extern CELL *Yap_emit_extra_size(compiler_vm_op, CELL, int, struct intermediates *); +extern char *Yap_AllocCMem(UInt, struct intermediates *); +extern void Yap_ReleaseCMem(struct intermediates *); +extern int Yap_is_a_test_pred(Term, Term); +extern void Yap_bip_name(Int, char *); #ifdef DEBUG -void Yap_ShowCode(struct intermediates *); +extern void Yap_ShowCode(struct intermediates *); #endif /* DEBUG */ + +#endif diff --git a/H/YapCompoundTerm.h b/H/YapCompoundTerm.h index b4cfed5e9..6aaf2e9e1 100644 --- a/H/YapCompoundTerm.h +++ b/H/YapCompoundTerm.h @@ -1,17 +1,17 @@ /************************************************************************* -* * -* YAP Prolog %W% %G% * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-2012 * -* * -************************************************************************** -* * -* File: YapCompounTerm.h * -* mods: * -* comments: main header file for YAP * -* version: $Id: Yap.h,v 1.38 2008-06-18 10:02:27 vsc Exp $ * -*************************************************************************/ + * * + * YAP Prolog %W% %G% * + * Yap Prolog was developed at NCCUP - Universidade do Porto * + * * + * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-2012 * + * * + ************************************************************************** + * * + * File: YapCompounTerm.h * + * mods: * + * comments: main header file for YAP * + * version: $Id: Yap.h,v 1.38 2008-06-18 10:02:27 vsc Exp $ * + *************************************************************************/ /************************************************************************************************* High level macros to access arguments @@ -23,11 +23,11 @@ #include "inline-only.h" -EXTERN Int Yap_unify(Term a, Term b); +EXTERN bool Yap_unify(Term a, Term b); -INLINE_ONLY EXTERN inline Term Deref(Term a); +INLINE_ONLY Term Deref(Term a); -INLINE_ONLY EXTERN inline Term Deref(Term a) { +INLINE_ONLY Term Deref(Term a) { while (IsVarTerm(a)) { Term *b = (Term *)a; a = *b; @@ -37,12 +37,11 @@ INLINE_ONLY EXTERN inline Term Deref(Term a) { return (a); } -INLINE_ONLY EXTERN inline CELL *GetTermAdress(Term a); +INLINE_ONLY CELL *GetTermAdress(Term a); +INLINE_ONLY Term Derefa(CELL *b); -INLINE_ONLY EXTERN inline Term Derefa(CELL *b); - -INLINE_ONLY EXTERN inline Term Derefa(CELL *b) { +INLINE_ONLY Term Derefa(CELL *b) { Term a = *b; restart: if (!IsVarTerm(a)) { @@ -56,41 +55,41 @@ restart: } } -INLINE_ONLY inline EXTERN Term ArgOfTerm(int i, Term t); +INLINE_ONLY Term ArgOfTerm(int i, Term t); -INLINE_ONLY inline EXTERN Term ArgOfTerm(int i, Term t) +INLINE_ONLY Term ArgOfTerm(int i, Term t) { return (Term)(Derefa(RepAppl(t) + (i))); } -INLINE_ONLY inline EXTERN Term HeadOfTerm(Term); +INLINE_ONLY Term HeadOfTerm(Term); -INLINE_ONLY inline EXTERN Term HeadOfTerm(Term t) { +INLINE_ONLY Term HeadOfTerm(Term t) { return (Term)(Derefa(RepPair(t))); } -INLINE_ONLY inline EXTERN Term TailOfTerm(Term); +INLINE_ONLY Term TailOfTerm(Term); -INLINE_ONLY inline EXTERN Term TailOfTerm(Term t) { +INLINE_ONLY Term TailOfTerm(Term t) { return (Term)(Derefa(RepPair(t) + 1)); } -INLINE_ONLY inline EXTERN Term ArgOfTermCell(int i, Term t); +INLINE_ONLY Term ArgOfTermCell(int i, Term t); -INLINE_ONLY inline EXTERN Term ArgOfTermCell(int i, Term t) { +INLINE_ONLY Term ArgOfTermCell(int i, Term t) { return (Term)((CELL)(RepAppl(t) + (i))); } -INLINE_ONLY inline EXTERN Term HeadOfTermCell(Term); +INLINE_ONLY Term HeadOfTermCell(Term); -INLINE_ONLY inline EXTERN Term HeadOfTermCell(Term t) { +INLINE_ONLY Term HeadOfTermCell(Term t) { return (Term)((CELL)(RepPair(t))); } -INLINE_ONLY inline EXTERN Term TailOfTermCell(Term); +INLINE_ONLY Term TailOfTermCell(Term); -INLINE_ONLY inline EXTERN Term TailOfTermCell(Term t) { +INLINE_ONLY Term TailOfTermCell(Term t) { return (Term)((CELL)(RepPair(t) + 1)); } diff --git a/H/YapEval.h b/H/YapEval.h old mode 100644 new mode 100755 index 98690b4ad..48d24c0ed --- a/H/YapEval.h +++ b/H/YapEval.h @@ -1,19 +1,18 @@ /************************************************************************* -* * -* YAP Prolog @(#)YapEval.h 1.2 -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * -* * -************************************************************************** -* * -* File: YapEval.h * -* Last rev: * -* mods: * -* comments: arithmetical functions info * -* * -*************************************************************************/ + * * + * YAP Prolog @(#)YapEval.h 1.2 + * * + * Yap Prolog was developed at NCCUP - Universidade do Porto * + * * + * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * + * * + ************************************************************************** + * * + * File: YapEval.h + ** Last rev: * mods: + ** comments: arithmetical functions info * + * * + *************************************************************************/ /** @@ -49,7 +48,7 @@ in YAP When YAP is built using the GNU multiple precision arithmetic library (GMP), integer arithmetic is unbounded, which means that the size of -integers is only limited by available memory. The type of integer +extern integers is only limited by available memory. The type of integer support can be detected using the Prolog flags bounded, min_integer and max_integer. As the use of GMP is default, most of the following descriptions assume unbounded integer arithmetic. @@ -165,7 +164,7 @@ overflow * @addtogroup arithmetic_operators * @enum arith0_op constant operators * @brief specifies the available unary arithmetic operators -*/ + */ typedef enum { /** pi [ISO] @@ -259,25 +258,25 @@ typedef enum { */ op_log, /** log10( _X_ ) [ISO] - * - * Decimal logarithm. - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} - * ?- between(1, 10, I), Delta is log10(I*10) + log10(1/(I*10)), format('0 + * + * Decimal logarithm. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} + * ?- between(1, 10, I), Delta is log10(I*10) + log10(1/(I*10)), format('0 * == ~3g~n',[Delta]), fail. - * 0 == 0 - * 0 == 0 - * 0 == 0 - * 0 == 0 - * 0 == 0 - * 0 == 0 - * 0 == 0 - * 0 == 0 - * 0 == 2.22e-16 - * 0 == 0 - * false. - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - */ + * 0 == 0 + * 0 == 0 + * 0 == 0 + * 0 == 0 + * 0 == 0 + * 0 == 0 + * 0 == 0 + * 0 == 0 + * 0 == 2.22e-16 + * 0 == 0 + * false. + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ op_log10, op_sqrt, op_sin, @@ -358,11 +357,11 @@ Functor EvalArg(Term); #define FlIsInt(X) (FALSE) #endif -#ifdef M_WILLIAMS +//#if defined(M_WILLIAMS) #define MkEvalFl(X) MkFloatTerm(X) -#else -#define MkEvalFl(X) (FlIsInt(X) ? MkIntTerm((Int)(X)) : MkFloatTerm(X)) -#endif +//#else +//#define MkEvalFl(X) (FlIsInt(X) ? MkIntTerm((Int)(X)) : MkFloatTerm(X)) +//#endif /* Macros used by some of the eval functions */ #define REvalInt(I) \ @@ -391,28 +390,48 @@ void Yap_InitConstExps(void); void Yap_InitUnaryExps(void); void Yap_InitBinaryExps(void); -int Yap_ReInitConstExps(void); -int Yap_ReInitUnaryExps(void); -int Yap_ReInitBinaryExps(void); +extern int Yap_ReInitConstExps(void); +extern int Yap_ReInitUnaryExps(void); +extern int Yap_ReInitBinaryExps(void); -Term Yap_eval_atom(Int); -Term Yap_eval_unary(Int, Term); -Term Yap_eval_binary(Int, Term, Term); +extern Term Yap_eval_atom(Int); +extern Term Yap_eval_unary(Int, Term); +extern Term Yap_eval_binary(Int, Term, Term); -Term Yap_InnerEval__(Term USES_REGS); +typedef struct eval_context { + Functor f; + CELL *fp; + struct eval_context *p; +} eval_context_t; + +extern Term Yap_InnerEval__(Term USES_REGS); #define Yap_EvalError(id, t, ...) \ - Yap_EvalError__(__FILE__, __FUNCTION__, __LINE__, id, t, __VA_ARGS__) -void Yap_EvalError__(const char *, const char *, int, yap_error_number, Term, - ...); + { \ + eval_context_t *ctx = LOCAL_ctx; \ + LOCAL_ctx = NULL; \ + while (ctx) { \ + *ctx->fp = (CELL)(ctx->f); \ + ctx = ctx->p; \ + } \ + Yap_ThrowError__(__FILE__, __FUNCTION__, __LINE__, id, t, __VA_ARGS__); \ + } #define Yap_ArithError(id, t, ...) \ - Yap_ThrowError__(__FILE__, __FUNCTION__, __LINE__, id, t, __VA_ARGS__) -#define Yap_BinError(id) \ - Yap_Error__(__FILE__, __FUNCTION__, __LINE__, id, 0L, "") -#define Yap_AbsmiError(id) \ - Yap_Error__(__FILE__, __FUNCTION__, __LINE__, id, 0L, "") + { \ + eval_context_t *ctx = LOCAL_ctx; \ + LOCAL_ctx = NULL; \ + while (ctx) { \ + *ctx->fp = (CELL)(ctx->f); \ + ctx = ctx->p; \ + } \ + Yap_ThrowError__(__FILE__, __FUNCTION__, __LINE__, id, t, __VA_ARGS__); \ + } +#define Yap_BinError(id) \ + Yap_Error__(false, __FILE__, __FUNCTION__, __LINE__, id, 0L, "") +#define Yap_AbsmiError(id) \ + Yap_ThrowError__(__FILE__, __FUNCTION__, __LINE__, id, 0L, "") #include "inline-only.h" @@ -420,11 +439,32 @@ void Yap_EvalError__(const char *, const char *, int, yap_error_number, Term, #define Yap_InnerEval(x) Yap_InnerEval__(x PASS_REGS) #define Yap_Eval(x) Yap_Eval__(x PASS_REGS) -#define Yap_FoundArithError() Yap_FoundArithError__(PASS_REGS1) -INLINE_ONLY inline EXTERN Term Yap_Eval__(Term t USES_REGS); +static inline bool Yap_CheckArithError(void) +{ + bool on = false; + yap_error_number err; + if (LOCAL_Error_TYPE== RESOURCE_ERROR_STACK) { + LOCAL_Error_TYPE = YAP_NO_ERROR; + if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, CP)) { + on = false; + Yap_ThrowError(RESOURCE_ERROR_STACK, ARG2, "while running arithmetic"); + } else { + on = true; + } + }; + if (trueGlobalPrologFlag( + ARITHMETIC_EXCEPTIONS_FLAG) && + (err = Yap_MathException())) { + Yap_ThrowError(err,ARG2,"Math Error"); + } + return on; + +} -INLINE_ONLY inline EXTERN Term Yap_Eval__(Term t USES_REGS) { +INLINE_ONLY Term Yap_Eval__(Term t USES_REGS); + +INLINE_ONLY Term Yap_Eval__(Term t USES_REGS) { if (t == 0L || (!IsVarTerm(t) && IsNumTerm(t))) return t; return Yap_InnerEval(t); @@ -436,14 +476,6 @@ inline static void Yap_ClearExs(void) { feclearexcept(FE_ALL_EXCEPT); } inline static void Yap_ClearExs(void) {} #endif -inline static yap_error_number Yap_FoundArithError__(USES_REGS1) { - if (LOCAL_Error_TYPE != YAP_NO_ERROR) - return LOCAL_Error_TYPE; - if (trueGlobalPrologFlag( - ARITHMETIC_EXCEPTIONS_FLAG)) // test support for exception - return Yap_MathException(); - return YAP_NO_ERROR; -} static inline Term takeIndicator(Term t) { Term ts[2]; @@ -468,9 +500,7 @@ Atom Yap_NameOfBinaryOp(int i); #define RFLOAT(v) return (MkFloatTerm(v)) #define RBIG(v) return (Yap_MkBigIntTerm(v)) #define RERROR() \ - { \ - return (0L); \ - } + { return (0L); } static inline blob_type ETypeOfTerm(Term t) { if (IsIntTerm(t)) @@ -489,106 +519,106 @@ static inline blob_type ETypeOfTerm(Term t) { } #if USE_GMP -char *Yap_mpz_to_string(MP_INT *b, char *s, size_t sz, int base); +extern char *Yap_mpz_to_string(MP_INT *b, char *s, size_t sz, int base); -Term Yap_gmq_rdiv_int_int(Int, Int); -Term Yap_gmq_rdiv_int_big(Int, Term); -Term Yap_gmq_rdiv_big_int(Term, Int); -Term Yap_gmq_rdiv_big_big(Term, Term); +extern Term Yap_gmq_rdiv_int_int(Int, Int); +extern Term Yap_gmq_rdiv_int_big(Int, Term); +extern Term Yap_gmq_rdiv_big_int(Term, Int); +extern Term Yap_gmq_rdiv_big_big(Term, Term); -Term Yap_gmp_add_ints(Int, Int); -Term Yap_gmp_sub_ints(Int, Int); -Term Yap_gmp_mul_ints(Int, Int); -Term Yap_gmp_sll_ints(Int, Int); -Term Yap_gmp_add_int_big(Int, Term); -Term Yap_gmp_sub_int_big(Int, Term); -Term Yap_gmp_sub_big_int(Term, Int); -Term Yap_gmp_mul_int_big(Int, Term); -Term Yap_gmp_div_int_big(Int, Term); -Term Yap_gmp_div_big_int(Term, Int); -Term Yap_gmp_div2_big_int(Term, Int); -Term Yap_gmp_fdiv_int_big(Int, Term); -Term Yap_gmp_fdiv_big_int(Term, Int); -Term Yap_gmp_and_int_big(Int, Term); -Term Yap_gmp_ior_int_big(Int, Term); -Term Yap_gmp_xor_int_big(Int, Term); -Term Yap_gmp_sll_big_int(Term, Int); -Term Yap_gmp_add_big_big(Term, Term); -Term Yap_gmp_sub_big_big(Term, Term); -Term Yap_gmp_mul_big_big(Term, Term); -Term Yap_gmp_div_big_big(Term, Term); -Term Yap_gmp_div2_big_big(Term, Term); -Term Yap_gmp_fdiv_big_big(Term, Term); -Term Yap_gmp_and_big_big(Term, Term); -Term Yap_gmp_ior_big_big(Term, Term); -Term Yap_gmp_xor_big_big(Term, Term); -Term Yap_gmp_mod_big_big(Term, Term); -Term Yap_gmp_mod_big_int(Term, Int); -Term Yap_gmp_mod_int_big(Int, Term); -Term Yap_gmp_rem_big_big(Term, Term); -Term Yap_gmp_rem_big_int(Term, Int); -Term Yap_gmp_rem_int_big(Int, Term); -Term Yap_gmp_exp_int_int(Int, Int); -Term Yap_gmp_exp_int_big(Int, Term); -Term Yap_gmp_exp_big_int(Term, Int); -Term Yap_gmp_exp_big_big(Term, Term); -Term Yap_gmp_gcd_int_big(Int, Term); -Term Yap_gmp_gcd_big_big(Term, Term); +extern Term Yap_gmp_add_ints(Int, Int); +extern Term Yap_gmp_sub_ints(Int, Int); +extern Term Yap_gmp_mul_ints(Int, Int); +extern Term Yap_gmp_sll_ints(Int, Int); +extern Term Yap_gmp_add_int_big(Int, Term); +extern Term Yap_gmp_sub_int_big(Int, Term); +extern Term Yap_gmp_sub_big_int(Term, Int); +extern Term Yap_gmp_mul_int_big(Int, Term); +extern Term Yap_gmp_div_int_big(Int, Term); +extern Term Yap_gmp_div_big_int(Term, Int); +extern Term Yap_gmp_div2_big_int(Term, Int); +extern Term Yap_gmp_fdiv_int_big(Int, Term); +extern Term Yap_gmp_fdiv_big_int(Term, Int); +extern Term Yap_gmp_and_int_big(Int, Term); +extern Term Yap_gmp_ior_int_big(Int, Term); +extern Term Yap_gmp_xor_int_big(Int, Term); +extern Term Yap_gmp_sll_big_int(Term, Int); +extern Term Yap_gmp_add_big_big(Term, Term); +extern Term Yap_gmp_sub_big_big(Term, Term); +extern Term Yap_gmp_mul_big_big(Term, Term); +extern Term Yap_gmp_div_big_big(Term, Term); +extern Term Yap_gmp_div2_big_big(Term, Term); +extern Term Yap_gmp_fdiv_big_big(Term, Term); +extern Term Yap_gmp_and_big_big(Term, Term); +extern Term Yap_gmp_ior_big_big(Term, Term); +extern Term Yap_gmp_xor_big_big(Term, Term); +extern Term Yap_gmp_mod_big_big(Term, Term); +extern Term Yap_gmp_mod_big_int(Term, Int); +extern Term Yap_gmp_mod_int_big(Int, Term); +extern Term Yap_gmp_rem_big_big(Term, Term); +extern Term Yap_gmp_rem_big_int(Term, Int); +extern Term Yap_gmp_rem_int_big(Int, Term); +extern Term Yap_gmp_exp_int_int(Int, Int); +extern Term Yap_gmp_exp_int_big(Int, Term); +extern Term Yap_gmp_exp_big_int(Term, Int); +extern Term Yap_gmp_exp_big_big(Term, Term); +extern Term Yap_gmp_gcd_int_big(Int, Term); +extern Term Yap_gmp_gcd_big_big(Term, Term); -Term Yap_gmp_big_from_64bits(YAP_LONG_LONG); +extern Term Yap_gmp_big_from_64bits(YAP_LONG_LONG); -Term Yap_gmp_float_to_big(Float); -Term Yap_gmp_float_to_rational(Float); -Term Yap_gmp_float_rationalize(Float); +extern Term Yap_gmp_float_to_big(Float); +extern Term Yap_gmp_float_to_rational(Float); +extern Term Yap_gmp_float_rationalize(Float); Float Yap_gmp_to_float(Term); -Term Yap_gmp_add_float_big(Float, Term); -Term Yap_gmp_sub_float_big(Float, Term); -Term Yap_gmp_sub_big_float(Term, Float); -Term Yap_gmp_mul_float_big(Float, Term); -Term Yap_gmp_fdiv_float_big(Float, Term); -Term Yap_gmp_fdiv_big_float(Term, Float); +extern Term Yap_gmp_add_float_big(Float, Term); +extern Term Yap_gmp_sub_float_big(Float, Term); +extern Term Yap_gmp_sub_big_float(Term, Float); +extern Term Yap_gmp_mul_float_big(Float, Term); +extern Term Yap_gmp_fdiv_float_big(Float, Term); +extern Term Yap_gmp_fdiv_big_float(Term, Float); -int Yap_gmp_cmp_big_int(Term, Int); -int Yap_gmp_cmp_int_big(Int, Term); -int Yap_gmp_cmp_big_float(Term, Float); +extern int Yap_gmp_cmp_big_int(Term, Int); +extern int Yap_gmp_cmp_int_big(Int, Term); +extern int Yap_gmp_cmp_big_float(Term, Float); #define Yap_gmp_cmp_float_big(D, T) (-Yap_gmp_cmp_big_float(T, D)) -int Yap_gmp_cmp_big_big(Term, Term); +extern int Yap_gmp_cmp_big_big(Term, Term); -int Yap_gmp_tcmp_big_int(Term, Int); -int Yap_gmp_tcmp_int_big(Int, Term); -int Yap_gmp_tcmp_big_float(Term, Float); +extern int Yap_gmp_tcmp_big_int(Term, Int); +extern int Yap_gmp_tcmp_int_big(Int, Term); +extern int Yap_gmp_tcmp_big_float(Term, Float); #define Yap_gmp_tcmp_float_big(D, T) (-Yap_gmp_tcmp_big_float(T, D)) -int Yap_gmp_tcmp_big_big(Term, Term); +extern int Yap_gmp_tcmp_big_big(Term, Term); -Term Yap_gmp_neg_int(Int); -Term Yap_gmp_abs_big(Term); -Term Yap_gmp_neg_big(Term); -Term Yap_gmp_unot_big(Term); -Term Yap_gmp_floor(Term); -Term Yap_gmp_ceiling(Term); -Term Yap_gmp_round(Term); -Term Yap_gmp_trunc(Term); -Term Yap_gmp_float_fractional_part(Term); -Term Yap_gmp_float_integer_part(Term); -Term Yap_gmp_sign(Term); -Term Yap_gmp_lsb(Term); -Term Yap_gmp_msb(Term); -Term Yap_gmp_popcount(Term); +extern Term Yap_gmp_neg_int(Int); +extern Term Yap_gmp_abs_big(Term); +extern Term Yap_gmp_neg_big(Term); +extern Term Yap_gmp_unot_big(Term); +extern Term Yap_gmp_floor(Term); +extern Term Yap_gmp_ceiling(Term); +extern Term Yap_gmp_round(Term); +extern Term Yap_gmp_trunc(Term); +extern Term Yap_gmp_float_fractional_part(Term); +extern Term Yap_gmp_float_integer_part(Term); +extern Term Yap_gmp_sign(Term); +extern Term Yap_gmp_lsb(Term); +extern Term Yap_gmp_msb(Term); +extern Term Yap_gmp_popcount(Term); char *Yap_gmp_to_string(Term, char *, size_t, int); size_t Yap_gmp_to_size(Term, int); -int Yap_term_to_existing_big(Term, MP_INT *); -int Yap_term_to_existing_rat(Term, MP_RAT *); +extern int Yap_term_to_existing_big(Term, MP_INT *); +extern int Yap_term_to_existing_rat(Term, MP_RAT *); void Yap_gmp_set_bit(Int i, Term t); #endif #define Yap_Mk64IntegerTerm(i) __Yap_Mk64IntegerTerm((i)PASS_REGS) -INLINE_ONLY inline EXTERN Term __Yap_Mk64IntegerTerm(YAP_LONG_LONG USES_REGS); +INLINE_ONLY Term __Yap_Mk64IntegerTerm(YAP_LONG_LONG USES_REGS); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term __Yap_Mk64IntegerTerm(YAP_LONG_LONG i USES_REGS) { if (i <= Int_MAX && i >= Int_MIN) { return MkIntegerTerm((Int)i); @@ -601,15 +631,20 @@ __Yap_Mk64IntegerTerm(YAP_LONG_LONG i USES_REGS) { } } -#if __clang__ && FALSE /* not in OSX yet */ -#define DO_ADD() \ - if (__builtin_sadd_overflow(i1, i2, &z)) { \ - goto overflow; \ - } -#endif - inline static Term add_int(Int i, Int j USES_REGS) { -#if USE_GMP +#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ > 4) + Int w; + if (!__builtin_add_overflow(i, j, &w)) + RINT(w); + return Yap_gmp_add_ints(i, j); + ; +#elif defined(__GNUC__) && __GNUC__ > 4 + Int w; + if (!__builtin_add_overflow_p(i, j, w)) + RINT(w); + return Yap_gmp_add_ints(i, j); + ; +#elif USE_GMP UInt w = (UInt)i + (UInt)j; if (i > 0) { if (j > 0 && (Int)w < 0) @@ -628,7 +663,7 @@ overflow: } /* calculate the most significant bit for an integer */ -Int Yap_msb(Int inp USES_REGS); +extern Int Yap_msb(Int inp USES_REGS); static inline Term p_plus(Term t1, Term t2 USES_REGS) { switch (ETypeOfTerm(t1)) { diff --git a/H/YapFlags.h b/H/YapFlags.h index d16dbe9bb..a3232f22c 100644 --- a/H/YapFlags.h +++ b/H/YapFlags.h @@ -15,15 +15,17 @@ * * *************************************************************************/ -/** @file YapFlags.h +/** + @file YapFlags.h - @addtogroup Flags +@{ + @addtogroup YAPFlags */ #ifndef YAP_FLAGS_H #define YAP_FLAGS_H 1 -// INLINE_ONLY inline EXTERN bool nat( Term inp ); +// INLINE_ONLY bool nat( Term inp ); #define SYSTEM_OPTION_0 "attributed_variables,rational_trees]" #if THREADS @@ -101,7 +103,7 @@ static inline Term ro(Term inp) { return TermZERO; } -INLINE_ONLY inline EXTERN Term aro(Term inp) { +INLINE_ONLY Term aro(Term inp) { if (IsVarTerm(inp)) { Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag %s", "value must be bound"); @@ -114,9 +116,12 @@ INLINE_ONLY inline EXTERN Term aro(Term inp) { return TermZERO; } -// INLINE_ONLY inline EXTERN Term booleanFlag( Term inp ); +// INLINE_ONLY Term booleanFlag( Term inp ); static inline Term booleanFlag(Term inp) { + if (IsStringTerm(inp)) { + inp = MkStringTerm(RepAtom(AtomOfTerm(inp))->StrOfAE); + } if (inp == TermTrue || inp == TermOn) return TermTrue; if (inp == TermFalse || inp == TermOff) @@ -137,17 +142,20 @@ static inline Term booleanFlag(Term inp) { } static Term synerr(Term inp) { + if (IsStringTerm(inp)) { + inp = MkStringTerm(RepAtom(AtomOfTerm(inp))->StrOfAE); + } if (inp == TermDec10 || inp == TermFail || inp == TermError || inp == TermQuiet) return inp; if (IsAtomTerm(inp)) { - Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, inp, + Yap_ThrowError(DOMAIN_ERROR_OUT_OF_RANGE, inp, "set_prolog_flag in {dec10,error,fail,quiet}"); return TermZERO; } - Yap_Error(TYPE_ERROR_ATOM, inp, - "set_prolog_flag in {dec10,error,fail,quiet}"); + Yap_ThrowError(TYPE_ERROR_ATOM, inp, + "syntax_error flag must be atom"); return TermZERO; } @@ -162,20 +170,7 @@ static inline Term list_filler(Term inp) { return TermZERO; } -static Term bqs(Term inp) { - if (inp == TermCodes || inp == TermString || inp == TermSymbolChar) - return inp; - - if (IsAtomTerm(inp)) { - Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, inp, - "set_prolog_flag in {codes,string}"); - return TermZERO; - } - Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag in {codes,string}"); - return TermZERO; -} - -// INLINE_ONLY inline EXTERN Term isatom( Term inp ); +// INLINE_ONLY Term isatom( Term inp ); static inline Term isatom(Term inp) { if (IsVarTerm(inp)) { @@ -183,17 +178,36 @@ static inline Term isatom(Term inp) { "value must be bound"); return TermZERO; } + if (IsStringTerm(inp)) { + inp = MkStringTerm(RepAtom(AtomOfTerm(inp))->StrOfAE); + } if (IsAtomTerm(inp)) return inp; Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag"); return TermZERO; } +static inline Term isadress(Term inp) { + if (IsVarTerm(inp)) { + Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag %s", + "value must be bound"); + return TermZERO; + } + if (IsAddressTerm(inp)) + return inp; + Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag"); + return TermZERO; +} + static inline Term options(Term inp) { return Yap_IsGroundTerm(inp) ? inp : TermZERO; } -// INLINE_ONLY inline EXTERN Term ok( Term inp ); +static inline const char * rootdir(Term inp) { + return Yap_ROOTDIR; +} + +// INLINE_ONLY Term ok( Term inp ); static inline Term ok(Term inp) { return inp; } @@ -237,16 +251,35 @@ typedef union flagTerm { void Yap_InitFlags(bool); -#define YAP_FLAG(x, NAME, WRITABLE, DEF, INIT, HELPER) x +/** + @pred yap_flag( ?Param, ?Value) -typedef enum { + +Set or read system properties for _Param_: +*/ + + +#define YAP_FLAG(ITEM, NAME, WRITABLE, DEF, INIT, HELPER) ITEM +#define START_LOCAL_FLAGS enum THREAD_LOCAL_FLAGS { +#define END_LOCAL_FLAGS }; +#define START_GLOBAL_FLAGS enum GLOBAL_FLAGS { +#define END_GLOBAL_FLAGS }; + +/* */ #include "YapGFlagInfo.h" -} global_flag_t; -typedef enum { + /* Local flags */ #include "YapLFlagInfo.h" -} local_flag_t; + +#ifndef DOXYGEN + #undef YAP_FLAG +#undef START_LOCAL_FLAGS +#undef END_LOCAL_FLAGS +#undef START_GLOBAL_FLAGS +#undef END_GLOBAL_FLAGS + +#endif bool setYapFlag(Term tflag, Term t2); Term getYapFlag(Term tflag); @@ -300,7 +333,7 @@ static inline bool trueLocalPrologFlag(int id) { return LOCAL_Flags[id].at == TermTrue; } -static inline bool falsePrologFlag(int id) { +static inline bool falseLocalPrologFlag(int id) { CACHE_REGS return LOCAL_Flags[id].at == TermFalse; } @@ -317,8 +350,15 @@ static inline bool silentMode(void) { return GLOBAL_Flags[VERBOSE_FLAG].at == TermSilent; } +static inline bool verboseMode(void) { + return GLOBAL_Flags[VERBOSE_FLAG].at != TermSilent; +} + + static inline void setVerbosity(Term val) { GLOBAL_Flags[VERBOSE_FLAG].at = val; + if (val == TermSilent) + GLOBAL_Flags[VERBOSE_LOAD_FLAG].at = TermFalse; } static inline bool setSyntaxErrorsFlag(Term val) { @@ -334,17 +374,26 @@ static inline Term getSyntaxErrorsFlag(void) { return LOCAL_Flags[SYNTAX_ERRORS_FLAG].at; } -static inline bool setBackQuotesFlag(Term val) { - if (!bqs(val)) - return false; - if (val == TermSymbolChar) - val = TermString; - GLOBAL_Flags[BACKQUOTED_STRING_FLAG].at = val; +// used to overwrite singletons quoteFunc flag +static inline bool setReadTermBackQuotesFlag(Term val) { + + GLOBAL_Flags[BACK_QUOTES_FLAG].at = val; return true; } -static inline Term getBackQuotesFlag(void) { - return GLOBAL_Flags[BACKQUOTED_STRING_FLAG].at; +static inline Term getReadTermBackQuotesFlag(void) { + Term val; + unsigned int flags = Yap_GetModuleEntry(CurrentModule)->flags; + if (flags & BCKQ_ATOM) { + val = TermAtom; + } else if (flags & BCKQ_STRING) { + val = TermString; + } else if (flags & BCKQ_CHARS) { + val = TermChars; + } else { + val = TermCodes; + } +return GLOBAL_Flags[BACK_QUOTES_FLAG].at = val; } static inline Term indexingMode(void) { return GLOBAL_Flags[INDEX_FLAG].at; } @@ -363,8 +412,20 @@ Term Yap_UnknownFlag(Term mod); bool rmdot(Term inp); -xarg *Yap_ArgListToVector(Term listl, const param_t *def, int n); +#define Yap_ArgListToVector(l, def, n, e) \ + Yap_ArgListToVector__(__FILE__, __FUNCTION__, __LINE__, l, def, n, e) -xarg *Yap_ArgList2ToVector(Term listl, const param2_t *def, int n); +extern xarg *Yap_ArgListToVector__(const char *file, const char *function, int lineno,Term listl, const param_t *def, int n, + yap_error_number e); + +#define Yap_ArgListToVector(l, def, n, e) \ + Yap_ArgListToVector__(__FILE__, __FUNCTION__, __LINE__, l, def, n, e) + +extern xarg *Yap_ArgList2ToVector__(const char *file, const char *function, int lineno, Term listl, const param2_t *def, int n, yap_error_number e); + +#define Yap_ArgList2ToVector(l, def, n, e) \ + Yap_ArgList2ToVector__(__FILE__, __FUNCTION__, __LINE__, l, def, n, e) #endif // YAP_FLAGS_H + +/// @} diff --git a/H/YapGFlagInfo.h b/H/YapGFlagInfo.h index e38c65af8..3e9ba6246 100644 --- a/H/YapGFlagInfo.h +++ b/H/YapGFlagInfo.h @@ -1,294 +1,331 @@ /************************************************************************* -* * -* YAP Prolog * -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 2015- * -* * -************************************************************************** -* * -* File: YapGFlagInfo.h * -* Last rev: * -* mods: * -* comments: global flag enumeration. * -* * -*************************************************************************/ + * * + * YAP Prolog * + * * + * Yap Prolog was developed at NCCUP - Universidade do Porto * + * * + * Copyright L.Damas, V.S.Costa and Universidade do Porto 2015- * + * * + ************************************************************************** + * * + * File: YapGFlagInfo.h * Last rev: + ** mods: * comments: global flag enumeration. * + * * + *************************************************************************/ /** @file YapGFlagInfo.h @addtogroup YAPFlags -@ingroup builtins -@{ + @{ - @pred yap_flag( ?Param, ?Value) - - -Set or read system properties for _Param_: - - @enum YapGFlag Prolog - @Brief global flag: - -@enum GlobalFlags Global Flags Dupported ny YAP * + @enum GLOBAL_FLAGS Global Flags supported by YAP + @brief global flags and their values. */ -YAP_FLAG(ADDRESS_BITS_FLAG, "address_bits", false, nat, BITNESS, NULL), /**< `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(AGC_MARGIN_FLAG, "agc_margin", true, nat, "10000", + agc_threshold), /**< -YAP_FLAG(AGC_MARGIN_FLAG, "agc_margin", true, nat, "10000", - agc_threshold), /**< `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(ALLOW_ASSERT_FOR_STATIC_PREDICATES, "allow_assert_for_static_predicates", true, booleanFlag, "true", - NULL), /**< `allow asserting and retracting clauses of static - predicates. */ + NULL), /**< + boolean: allow asserting and retracting clauses of static + predicates. */ - /* YAP_FLAG( ALLOW_VARIABLE_NAME_AS_FUNCTOR_FLAG, - "allow_variable_name_as_functor", true, booleanFlag, "false" , NULL ), - /\**< - `allow_variable_name_as_functor` */ + YAP_FLAG(ALLOW_VARIABLE_NAME_AS_FUNCTOR_FLAG, + "allow_variable_name_as_functor", false, booleanFlag, "false", + NULL), /**< - /* allow - * A(X) - * *\/ - */ - YAP_FLAG(ANSWER_FORMAT_FLAG, "answer_format", true, isatom, "~p", - NULL), /** `arithmetic_exceptions ` + boolean flag allows syntax such + as + ~~~ + Tree(Node(L,node,R)) :- + Tree(L), + Tree(R). + ~~~ + */ -Read-write flag telling whether arithmetic exceptions generate -Prolog exceptions. If enabled: - -~~~~ -?- X is 2/0. -ERROR!! -ZERO DIVISO]]R 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. -*/ -#if __APPLE__ - YAP_FLAG(APPLE_FLAG, "apple", false, booleanFlag, "true", - NULL), /**< `apple` - -Read-only booleanFlag flag that unifies with `true` if YAP is -running on an Apple machine. -*/ + YAP_FLAG(ANSWER_FORMAT_FLAG, "answer_format", true, isatom, "~p", NULL), +/**< how to present answers, default is `~p`. */ +#if __ANDROID__ + YAP_FLAG(ANDROID_FLAG, "android", false, booleanFlag, "true", NULL), /**< + read-only boolean, a machine running an Google's Android version of the + Linux Operating System */ #endif - YAP_FLAG(ARCH_FLAG, "arch", false, isatom, YAP_ARCH, NULL), + +#if __APPLE__ + 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), /**< + read-only atom, it describes the ISA used in this version of YAP. + Available from YAP_ARCH. + */ YAP_FLAG(ARGV_FLAG, "argv", false, argv, "@boot", NULL), YAP_FLAG(ARITHMETIC_EXCEPTIONS_FLAG, "arithmetic_exceptions", true, booleanFlag, "true", NULL), - YAP_FLAG(BACKQUOTED_STRING_FLAG, "backquoted_string", true, isatom, - "string", ), /**> -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 `string` -*/ + /**< - YAP_FLAG(BOUNDED_FLAG, "bounded", false, booleanFlag, "false", - NULL), /**< `bounded` is iso + 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(BACK_QUOTES_FLAG, "back_quotes", true, isatom, "true", bqs), + /**< + 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(BOUNDED_FLAG, "bounded", false, booleanFlag, "false", NULL), + /**< `bounded` is iso + + Read-only flag telling whether integers are bounded. The value depends + on whether YAP uses the GMP library or not. + */ -Read-only flag telling whether integers are bounded. The value depends -on whether YAP uses the GMP library or not. -*/ 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), YAP_FLAG(CHAR_CONVERSION_FLAG, "char_conversion", true, booleanFlag, - "false", NULL), /**< `char_conversion is iso` + "false", 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`. - */ + 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(CHARACTER_ESCAPES_FLAG, "character_escapes", true, booleanFlag, - "true", NULL), /**< `character_escapes is iso ` + "true", NULL), + /**< ` - Writable flag telling whether a character escapes are enables, - `true`, or disabled, `false`. The default value for this flag is - `true`. */ + Writable flag telling whether a character escapes are enabled, + `true`, or disabled, `false`. The default value for this flag is + `true`. */ 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), /**< `compiled_at ` + NULL), + YAP_FLAG(DEBUG_FLAG, "debug", true, booleanFlag, "false", NULL), + /**< -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(DEBUG_FLAG, "debug", true, booleanFlag, "false", - 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. + 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_INFO_FLAG, "debug_info", true, booleanFlag, "true", NULL), YAP_FLAG(DEBUG_ON_ERROR_FLAG, "debug_on_error", true, booleanFlag, "true", NULL), + /**< + 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), /**< `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. -*/ + NULL), YAP_FLAG(DEBUGGER_SHOW_CONTEXT_FLAG, "debugger_show_context", true, booleanFlag, "false", NULL), - YAP_FLAG(DIALECT_FLAG, "dialect", false, ro, "yap", - NULL), /**< `dialect ` + YAP_FLAG(DEFAULT_PARENT_MODULE_FLAG, "default_parent_module", true, isatom, + "user", NULL), + /**< + * A module to be inherited by all other modules. Default is user that + * reexports prolog. + * + * Set it to `prolog` for SICStus Prolog like resolution, to `user` for + * SWI-like. + */ + YAP_FLAG(DIALECT_FLAG, "dialect", false, ro, "yap", NULL), + /**< - Read-only flag that always returns `yap`. - */ + Read-only flag that always returns `yap`. + */ YAP_FLAG(DISCONTIGUOUS_WARNINGS_FLAG, "discontiguous_warnings", true, - booleanFlag, "true", NULL), /**< `discontiguous_warnings ` + booleanFlag, "true", NULL), + /**< -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. + 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. + The declaration discontiguous/1 disables this warning for user-specified + predicates. - */ + */ YAP_FLAG(DOLLAR_AS_LOWER_CASE_FLAG, "dollar_as_lower_case", true, - booleanFlag, "false", - NULL), /**< `dollar_as_lower_case ` + booleanFlag, "false", NULL), + /**< + If `off` (default) consider the character `$` a control character, if +vxu `on` consider `$` a lower case character. + */ + YAP_FLAG(DOUBLE_QUOTES_FLAG, "double_quotes", true, isatom, "codes", dqs), + /**< iso -If `off` (default) consider the character `$` a control character, if -`on` consider `$` a lower case character. -*/ - YAP_FLAG(DOUBLE_QUOTES_FLAG, "double_quotes", true, isatom, "codes", - dqf), /**< `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`. */ + 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(EDITOR_FLAG, "editor", true, isatom, "$EDITOR", NULL), - YAP_FLAG(EXECUTABLE_FLAG, "executable", false, executable, "@boot", - NULL), /**< `executable ` + YAP_FLAG(EXECUTABLE_FLAG, "executable", false, executable, "@boot", NULL), + /**< -Read-only flag. It unifies with an atom that gives the -original program path. -*/ - YAP_FLAG(FAST_FLAG, "fast", true, booleanFlag, "false", NULL), /**< `fast ` + Read-only flag. It unifies with an atom that gives the + original program path. + */ + YAP_FLAG(FAST_FLAG, "fast", true, booleanFlag, "false", NULL), + /**< If `on` allow fast machine code, if `off` (default) disable it. Only -available in experimental implementations. + available in experimental implementations. */ YAP_FLAG(FILE_NAME_VARIABLES_FLAG, "file_name_variables", true, booleanFlag, "true", NULL), - YAP_FLAG(FLOAT_FORMAT_FLAG, "float_format", true, isatom, "%.16g", - NULL), /**< + `float_format ` + YAP_FLAG(FLOAT_FORMAT_FLAG, "float_format", true, isatom, "%.16f", NULL), + /**< - 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. + 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(GC_FLAG, "gc", true, booleanFlag, "on", NULL), /**< `gc` + YAP_FLAG(GC_FLAG, "gc", true, booleanFlag, "on", NULL), + /**< `gc` - If `on` allow garbage collection (default), if `off` disable it. -*/ - YAP_FLAG(GC_MARGIN_FLAG, "gc_margin", true, nat, "0", - gc_margin), /**< `gc_margin ` + If `on` allow garbage collection (default), if `off` disable it. + */ + YAP_FLAG(GC_MARGIN_FLAG, "gc_margin", true, nat, "0", gc_margin), + /**< `gc_margin ` -Set or show the minimum free stack before starting garbage -collection. The default depends on total stack size. + Set or show the minimum free stack before starting garbage + collection. The default depends on total stack size. -*/ - YAP_FLAG(GC_TRACE_FLAG, "gc_trace", true, isatom, "off", - NULL), /**< `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), + /**< + * + 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(GENERATE_DEBUGGING_INFO_FLAG, "generate_debug_info", true, - booleanFlag, "true", NULL), /**< `generate_debug_info ` + booleanFlag, "true", NULL), + /**< ` - 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. + 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(GMP_VERSION_FLAG, "gmp_version", false, isatom, "4.8.12", NULL), YAP_FLAG(HALT_AFTER_CONSULT_FLAG, "halt_after_consult", false, booleanFlag, "false", NULL), - YAP_FLAG(HOME_FLAG, "home", false, isatom, YAP_ROOTDIR, NULL), /**< home ` + YAP_FLAG(HOME_FLAG, "home", false, isatom, YAP_ROOTDIR, 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 + 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(HOST_TYPE_FLAG, "host_type", false, isatom, HOST_ALIAS, 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), /**< host_type ` - -Return `configure` system information, including the machine-id -for which YAP was compiled and Operating System information. -*/ - YAP_FLAG(INDEX_FLAG, "index", true, indexer, "multi", NULL), /**< `index ` + YAP_FLAG(INDEX_FLAG, "index", true, indexer, "multi", NULL), + /**< `index ` If `on` allow indexing (default), if `off` disable it, if -`single` allow on first argument only. + `single` allow on first argument only. */ YAP_FLAG(INDEX_SUB_TERM_SEARCH_DEPTH_FLAG, "index_sub_term_search_depth", - true, nat, "0", NULL), /**< `Index_sub_term_search_depth ` + true, nat, "0", NULL), + /**< `Index_sub_term_search_depth ` -Maximum bound on searching sub-terms for indexing, if `0` (default) no bound. + Maximum bound on searching sub-terms for indexing, if `0` (default) no + bound. */ YAP_FLAG(INFORMATIONAL_MESSAGES_FLAG, "informational_messages", true, - isatom, "normal", NULL), /**< `informational_messages ` + isatom, "normal", 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. -*/ + 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(INTEGER_ROUNDING_FUNCTION_FLAG, "integer_rounding_function", true, - isatom, "toward_zero", - NULL), /**< `integer_rounding_function is iso ` + isatom, "toward_zero", 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. -*/ + Read-only flag telling the rounding function used for integers. Takes the + value `toward_zero` for the current version of YAP. + */ YAP_FLAG(ISO_FLAG, "iso", true, booleanFlag, "false", NULL), - YAP_FLAG(LANGUAGE_FLAG, "language", true, isatom, "yap", - NULL), /**< `language ` + YAP_FLAG(JUPYTER_FLAG, "jupyter", false, booleanFlag, "true", NULL), /**< + read-only boolean, a machine running Jupyter */ + YAP_FLAG(LANGUAGE_FLAG, "language", true, isatom, "yap", 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(MAX_ARITY_FLAG, "max_arity", false, isatom, "unbounded", - NULL), /**< `max_arity is iso ` + 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(PROLOG_LIBRARY_DIRECTORY_FLAG, "prolog_library_directory", true, + isatom, "", NULL), + /**< if defined, first location where YAP expects to find the YAP Prolog + library. Takes precedence over library_directory */ + YAP_FLAG(PROLOG_FOREIGN_DIRECTORY_FLAG, "prolog_foreign_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. */ -Read-only flag telling the maximum arity of a functor. Takes the value -`unbounded` for the current version of YAP. -*/ + /**< `max_arity is iso ` + YAP_FLAG(MAX_ARITY_FLAG, "max_arity", false, isatom, "unbounded", NULL), + + Read-only flag telling the maximum arity of a functor. Takes the value + `unbounded` for the current version of YAP. + */ 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), @@ -300,259 +337,299 @@ Read-only flag telling the maximum arity of a functor. Takes the value YAP_FLAG(OCCURS_CHECK_FLAG, "occurs_check", true, booleanFlag, "false", NULL), YAP_FLAG(OPEN_EXPANDS_FILENAME_FLAG, "open_expands_filename", true, - booleanFlag, "false", NULL), /**< `open_expands_filename ` + 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). - */ + 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_SHARED_OBJECT_FLAG, "open_shared_object", true, booleanFlag, - "true", NULL), /**< `open_shared_object ` + "true", 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(MODULE_INDEPENDENT_OPERATORS_FLAG, - // "module_independent_operators", true, booleanFlag, - // "false", NULL), + If true, `open_shared_object/2` and friends are implemented, + providing access to shared libraries (`.so` files) or to dynamic link + libraries (`.DLL` files). + */ /**< `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. - */ + 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), - YAP_FLAG(PROFILING_FLAG, "profiling", true, booleanFlag, "false", - NULL), /**< `profiling ` + YAP_FLAG(PROFILING_FLAG, "profiling", true, booleanFlag, "false", 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. -*/ + 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(PROMPT_ALTERNATIVES_ON_FLAG, "prompt_alternatives_on", true, - isatom, "determinism", NULL), /**< `prompt_alternatives_on(atom, -changeable) ` + isatom, "determinism", 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. */ + 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(QUASI_QUOTATIONS_FLAG, "quasi_quotations", true, booleanFlag, "true", NULL), YAP_FLAG(READLINE_FLAG, "readline", true, booleanFlag, "false", - Yap_InitReadline), /**< `readline(boolean, changeable)` -} + Yap_InitReadline), + /**< `readline(boolean, changeable)` + } -enable the use of the readline library for console interactions, true by default -if readline was found. */ + enable the use of the readline library for console interactions, true by + default if readline was found. */ + YAP_FLAG(REDEFINE_WARNINGS_FLAG, "redefine_warnings", true, booleanFlag, + "true", NULL), /**< + +If _Value_ is unbound, tell whether warnings for procedures defined +in several different files are `on` or +`off`. If _Value_ is bound to `on` enable these warnings, +and if it is bound to `off` disable them. The default for YAP is +`off`, unless we are in `sicstus` or `iso` mode. +*/ YAP_FLAG(REPORT_ERROR_FLAG, "report_error", true, booleanFlag, "true", NULL), YAP_FLAG(RESOURCE_DATABASE_FLAG, "resource_database", false, isatom, - "boot.yap", NULL), + YAP_BOOTSTRAP, NULL), + /**<`resource_database` - Name of the resource file (saved-state or Prolog file) used to construct + Name of the resource file (saved-state or Prolog file) used to construct the YAP run-time environment. - */ + */ YAP_FLAG(SAVED_PROGRAM_FLAG, "saved_program", false, booleanFlag, "false", 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`. - */ + 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(SHARED_OBJECT_EXTENSION_FLAG, "shared_object_extension", false, - isatom, SO_EXT, NULL), /**< `shared_object_extension ` + isatom, SO_EXT, NULL), -Suffix associated with loadable code. -*/ + /**< `shared_object_extension ` + + Suffix associated with loadable code. + */ YAP_FLAG(SHARED_OBJECT_SEARCH_PATH_FLAG, "shared_object_search_path", true, - isatom, SO_PATH, NULL), /**< `shared_object_search_path ` + isatom, SO_PATH, NULL), + /**< `shared_object_search_path ` -Name of the environment variable used by the system to search for shared -objects. + Name of the environment variable used by the system to search for shared + objects. -*/ - YAP_FLAG(SIGNALS_FLAG, "signals", true, booleanFlag, "true", - NULL), /**< `signals` + */ + YAP_FLAG(SINGLE_QUOTES_FLAG, "single_quotes", true, isatom, "atom", sqf), + /**< `single_quoted text is usuallly interpreted as atoms. This flagTerm + allows other inerpretations such as strings_contains_strings */ - If `true` (default) YAP handles Signals such as `^C` - (`SIGINT`). + YAP_FLAG(SINGLE_VAR_WARNINGS_FLAG, "single_var_warnings", true, booleanFlag, + "true", NULL), /**< + If `true` (default `true`) YAP checks for singleton + variables when loading files. A singleton variable is a + variable that appears ony once in a clause. The name + must start with a capital letter, variables whose name + starts with underscore are never considered singleton. - */ - YAP_FLAG(SOURCE_FLAG, "source", true, booleanFlag, "true", - NULL), /**< `source` + */ + YAP_FLAG(SIGNALS_FLAG, "signals", true, booleanFlag, "true", NULL), + /**< `signals` -If `true` maintain the source for all clauses. Notice that this is trivially -supported for facts, and always supported for dynamic code. + If `true` (default) YAP handles Signals such as `^C` + (`SIGINT`). -*/ - YAP_FLAG(STRICT_ISO_FLAG, "strict_iso", true, booleanFlag, "false", - NULL), /**< `strict_iso ` + */ + YAP_FLAG(SOURCE_FLAG, "source", true, booleanFlag, "true", NULL), + /**< `source` -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. + If `true` maintain the source for all clauses. Notice that this is trivially + supported for facts, and always supported for dynamic code. - */ + */ + YAP_FLAG(STRICT_ISO_FLAG, "strict_iso", true, booleanFlag, "false", 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(SYSTEM_OPTIONS_FLAG, "system_options", false, options, - SYSTEM_OPTIONS, - NULL), /**< `system_options ` + SYSTEM_OPTIONS, 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`. -*/ + 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_THREAD_ID_FLAG, "system_thread_id", false, sys_thread_id, "@boot", NULL), - YAP_FLAG(TABLING_MODE_FLAG, "tabling_mode", true, isatom, "[]", - NULL), /**< `tabling_mode` + YAP_FLAG(TABLING_MODE_FLAG, "tabling_mode", true, isatom, "[]", NULL), + /**< `tabling_mode` -Sets or reads the tabling mode for all tabled predicates. Please -(see Tabling) for the list of options. + Sets or reads the tabling mode for all tabled predicates. Please + (see Tabling) for the list of options. -*/ + */ YAP_FLAG(THREADS_FLAG, "threads", false, ro, "MAX_THREADS", NULL), YAP_FLAG(TIMEZONE_FLAG, "timezone", false, ro, "18000", NULL), + YAP_FLAG(TOPLEVEL_HOOK_FLAG, "toplevel_hook", 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_ANON_FLAG, "toplevel_print_anon", true, booleanFlag, "true", NULL), YAP_FLAG(TOPLEVEL_PRINT_OPTIONS_FLAG, "toplevel_print_options", true, list_option, "[quoted(true),numbervars(true),portrayed(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. - -*/ + NULL), YAP_FLAG(TOPLEVEL_PROMPT_FLAG, "toplevel_prompt", true, isatom, "?- ", mkprompt), YAP_FLAG(TTY_CONTROL_FLAG, "tty_control", true, booleanFlag, "true", NULL), - YAP_FLAG(UNIX_FLAG, "unix", false, ro, "true", NULL), /**< `unix` + YAP_FLAG(UNIX_FLAG, "unix", false, ro, "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`. + running on an Unix system. Defined if the C-compiler used to compile + this version of YAP either defines `__unix__` or `unix`. + */ + /**< `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), /**< `update_semantics ` + NULL), + YAP_FLAG(USER_FLAGS_FLAG, "user_flags", true, isatom, "error", NULL), + /**< + `user_flags ` -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(USER_FLAGS_FLAG, "user_flags", true, isatom, "error", 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(UNKNOWN_FLAG, "unknown", true, isatom, "error", Yap_unknown), + /**< `unknown is iso` - 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. + 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), /**< `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(VARIABLE_NAMES_MAY_END_WITH_QUOTES_FLAG, "variable_names_may_end_with_quotes", true, booleanFlag, "false", NULL), - YAP_FLAG(VERBOSE_FLAG, "verbose", true, isatom, "normal", - NULL), /**< `verbose ` + YAP_FLAG(VERBOSE_FLAG, "verbose", true, isatom, "normal", 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. + 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_AUTOLOAD_FLAG, "verbose_autoload", true, booleanFlag, - "false", NULL), + */ YAP_FLAG(VERBOSE_FILE_SEARCH_FLAG, "verbose_file_search", true, booleanFlag, - "false", NULL), /**< `verbose_file_search ` + "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_LOAD_FLAG, "verbose_load", true, isatom, "normal", - NULL), /**< `verbose_load ` + 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_LOAD_FLAG, "verbose_load", true, booleanFlag, "true", 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(VERSION_FLAG, "version", false, nat, YAP_NUMERIC_VERSION, - NULL), /**< `version_data ` + If `true` allow printing of informational messages when + consulting files. If `false` disable printing these messages. It + is `true` by default except if YAP is booted with the `-L` + flag. + */ + 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. -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_DATA_FLAG, "version_data", false, ro, YAP_TVERSION, - 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_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_GIT_FLAG, "version_git", false, isatom, YAP_GIT_HEAD, - 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. - */ + 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(WRITE_ATTRIBUTES_FLAG, "write_attributes", true, isatom, "ignore", NULL), #if __WINDOWS__ - YAP_FLAG(WINDOWS_FLAG, "windows", false, ro, "true", NULL), /**< `windows ` + /**< `windows` Read-only booleanFlag flag that unifies with `true` if YAP is -running on an Windows machine. + running on an Windows machine. */ + YAP_FLAG(WINDOWS_FLAG, "windows", false, ro, "true", NULL), #endif YAP_FLAG(WRITE_STRINGS_FLAG, "write_strings", true, booleanFlag, "false", - NULL), /**< `write_strings ` + 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`. -*/ -//! @} + /**< `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`. + */ + END_GLOBAL_FLAGS + + //! @} diff --git a/H/YapHandles.h b/H/YapHandles.h index c6c822b3c..cd5d2bc09 100755 --- a/H/YapHandles.h +++ b/H/YapHandles.h @@ -16,7 +16,7 @@ #ifndef YAP_HANDLES_H #define YAP_HANDLES_H 1 -#include "Regs.h" +#include "inline-only.h" #include "Yatom.h" #define LOCAL_CurHandle LOCAL_CurSlot @@ -71,7 +71,7 @@ functions are then exported through corresponding FLI C-functions #define Yap_RebootHandles(wid) Yap_RebootHandles__(wid PASS_REGS) #define Yap_RebootSlots(wid) Yap_RebootHandles__(wid PASS_REGS) -static inline void Yap_RebootHandles__(int wid USES_REGS) { +INLINE_ONLY void Yap_RebootHandles__(int wid USES_REGS) { // fprintf(stderr, " StartHandles = %ld", LOCAL_CurHandle); REMOTE_CurHandle(wid) = 1; } @@ -85,8 +85,8 @@ static inline void Yap_RebootHandles__(int wid USES_REGS) { #define Yap_StartHandles() Yap_StartHandles__(PASS_REGS1) #define Yap_StartSlots() Yap_StartHandles__(PASS_REGS1) -INLINE_ONLY inline EXTERN yhandle_t Yap_StartHandles__(USES_REGS1); -INLINE_ONLY inline EXTERN yhandle_t Yap_StartHandles__(USES_REGS1) { +INLINE_ONLY yhandle_t Yap_StartHandles__(USES_REGS1); +INLINE_ONLY yhandle_t Yap_StartHandles__(USES_REGS1) { // // fprintf(stderr, " StartHandles = %ld", LOCAL_CurHandle); // fprintf(stderr,"SS %s:%d\n", __FILE__, __LINE__);; if (LOCAL_CurHandle < 0) { @@ -105,8 +105,8 @@ INLINE_ONLY inline EXTERN yhandle_t Yap_StartHandles__(USES_REGS1) { #define Yap_CloseHandles(slot) Yap_CloseHandles__(slot PASS_REGS) #define Yap_CloseSlots(slot) Yap_CloseHandles__(slot PASS_REGS) -INLINE_ONLY inline EXTERN void Yap_CloseHandles__(yhandle_t slot USES_REGS); -INLINE_ONLY inline EXTERN void Yap_CloseHandles__(yhandle_t slot USES_REGS) { +INLINE_ONLY void Yap_CloseHandles__(yhandle_t slot USES_REGS); +INLINE_ONLY void Yap_CloseHandles__(yhandle_t slot USES_REGS) { // fprintf(stderr,"CS %s:%d\n", __FILE__, __LINE__); LOCAL_CurHandle = slot; } @@ -116,8 +116,8 @@ INLINE_ONLY inline EXTERN void Yap_CloseHandles__(yhandle_t slot USES_REGS) { /// @brief report the current position of the slots, assuming that they occupy /// the top of the stack. -INLINE_ONLY inline EXTERN yhandle_t Yap_CurrentHandle__(USES_REGS1); -INLINE_ONLY inline EXTERN yhandle_t Yap_CurrentHandle__(USES_REGS1) { +INLINE_ONLY yhandle_t Yap_CurrentHandle__(USES_REGS1); +INLINE_ONLY yhandle_t Yap_CurrentHandle__(USES_REGS1) { return LOCAL_CurHandle; } @@ -125,8 +125,8 @@ INLINE_ONLY inline EXTERN yhandle_t Yap_CurrentHandle__(USES_REGS1) { #define Yap_GetFromSlot(slot) Yap_GetFromHandle__(slot PASS_REGS) /// @brief read from a slot. -INLINE_ONLY inline EXTERN Term Yap_GetFromHandle__(yhandle_t slot USES_REGS); -INLINE_ONLY inline EXTERN Term Yap_GetFromHandle__(yhandle_t slot USES_REGS) { +INLINE_ONLY Term Yap_GetFromHandle__(yhandle_t slot USES_REGS); +INLINE_ONLY Term Yap_GetFromHandle__(yhandle_t slot USES_REGS) { // fprintf(stderr, "GS %s:%d\n", __FILE__, __LINE__); return Deref(LOCAL_HandleBase[slot]); } @@ -136,9 +136,9 @@ INLINE_ONLY inline EXTERN Term Yap_GetFromHandle__(yhandle_t slot USES_REGS) { #define Yap_GetDerefedFromSlot(slot) Yap_GetDerefedFromHandle__(slot PASS_REGS) /// @brief read from a slot. but does not try to dereference the slot. -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term Yap_GetDerefedFromHandle__(yhandle_t slot USES_REGS); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term Yap_GetDerefedFromHandle__(yhandle_t slot USES_REGS) { // fprintf(stderr,"GDS %s:%d\n", __FILE__, __LINE__); return LOCAL_HandleBase[slot]; @@ -148,9 +148,9 @@ Yap_GetDerefedFromHandle__(yhandle_t slot USES_REGS) { #define Yap_GetPtrFromSlot(slot) Yap_GetPtrFromHandle__(slot PASS_REGS) /// @brief read the object in a slot. but do not try to dereference the slot. -INLINE_ONLY inline EXTERN Term * +INLINE_ONLY Term * Yap_GetPtrFromHandle__(yhandle_t slot USES_REGS); -INLINE_ONLY inline EXTERN Term * +INLINE_ONLY Term * Yap_GetPtrFromHandle__(yhandle_t slot USES_REGS) { // fprintf(stderr,"GPS %s:%d\n", __FILE__, __LINE__); return (Term *)LOCAL_HandleBase[slot]; @@ -159,9 +159,9 @@ Yap_GetPtrFromHandle__(yhandle_t slot USES_REGS) { #define Yap_AddressFromHandle(slot) Yap_AddressFromHandle__(slot PASS_REGS) #define Yap_AddressFromSlot(slot) Yap_AddressFromHandle__(slot PASS_REGS) -INLINE_ONLY inline EXTERN CELL * +INLINE_ONLY CELL * Yap_AddressFromHandle__(yhandle_t slot USES_REGS); -INLINE_ONLY inline EXTERN CELL * +INLINE_ONLY CELL * Yap_AddressFromHandle__(yhandle_t slot USES_REGS) { /// @brief get the memory address of a slot @@ -171,23 +171,23 @@ Yap_AddressFromHandle__(yhandle_t slot USES_REGS) { #define Yap_PutInSlot(slot, t) Yap_PutInHandle__(slot, t PASS_REGS) #define Yap_PutInHandle(slot, t) Yap_PutInHandle__(slot, t PASS_REGS) /// @brief store term in a slot -INLINE_ONLY inline EXTERN void Yap_PutInHandle__(yhandle_t slot, +INLINE_ONLY void Yap_PutInHandle__(yhandle_t slot, Term t USES_REGS); -INLINE_ONLY inline EXTERN void Yap_PutInHandle__(yhandle_t slot, +INLINE_ONLY void Yap_PutInHandle__(yhandle_t slot, Term t USES_REGS) { // fprintf(stderr,"PS %s:%d\n", __FILE__, __LINE__); LOCAL_HandleBase[slot] = t; } -#ifndef max -#define max(X, Y) (X > Y ? X : Y) +#ifndef Yap_Max +#define Yap_Max(X, Y) (X > Y ? X : Y) #endif #define ensure_handles ensure_slots -INLINE_ONLY inline EXTERN void ensure_slots(int N USES_REGS) { +INLINE_ONLY void ensure_slots(int N USES_REGS) { if (LOCAL_CurHandle + N >= LOCAL_NHandles) { - size_t inc = max(16 * 1024, LOCAL_NHandles / 2); // measured in cells - inc = max(inc, (size_t)N + 16); // measured in cells + size_t inc = Yap_Max(16 * 1024, LOCAL_NHandles / 2); // measured in cells + inc = Yap_Max(inc, (size_t)N + 16); // measured in cells LOCAL_HandleBase = (CELL *)realloc(LOCAL_HandleBase, (inc + LOCAL_NHandles) * sizeof(CELL)); LOCAL_NHandles += inc; @@ -211,15 +211,17 @@ INLINE_ONLY inline EXTERN void ensure_slots(int N USES_REGS) { #define Yap_PushHandle(t) Yap_InitHandle__(t PASS_REGS) #define Yap_InitSlot(t) Yap_InitHandle__(t PASS_REGS) -INLINE_ONLY inline EXTERN yhandle_t Yap_InitHandle__(Term t USES_REGS); -INLINE_ONLY inline EXTERN yhandle_t Yap_InitHandle__(Term t USES_REGS) { +INLINE_ONLY yhandle_t Yap_InitHandle__(Term t USES_REGS); +INLINE_ONLY yhandle_t Yap_InitHandle__(Term t USES_REGS) { yhandle_t old_slots = LOCAL_CurHandle; ensure_slots(1 PASS_REGS); - if (IsVarTerm(t) && (H0 > (CELL*)t || (CELL*)t > HR)) { - RESET_VARIABLE(HR); - Yap_unify(t,(CELL)HR); t = (CELL)HR++; - } + if (t==0) { + t = MkVarTerm(); + } else if (IsVarTerm(t) ) { + Term tg = MkVarTerm(); + Bind_Global( VarOfTerm(t), tg); +} LOCAL_HandleBase[old_slots] = t; LOCAL_CurHandle++; return old_slots; @@ -231,8 +233,8 @@ INLINE_ONLY inline EXTERN yhandle_t Yap_InitHandle__(Term t USES_REGS) { #define Yap_NewHandles(n) Yap_NewHandles__(n PASS_REGS) #define Yap_NewSlots(n) Yap_NewHandles__(n PASS_REGS) -INLINE_ONLY inline EXTERN yhandle_t Yap_NewHandles__(int n USES_REGS); -INLINE_ONLY inline EXTERN yhandle_t Yap_NewHandles__(int n USES_REGS) { +INLINE_ONLY yhandle_t Yap_NewHandles__(int n USES_REGS); +INLINE_ONLY yhandle_t Yap_NewHandles__(int n USES_REGS) { yhandle_t old_slots = LOCAL_CurHandle; int i; // fprintf(stderr, "NS %s:%d\n", __FILE__, __LINE__); @@ -254,9 +256,9 @@ INLINE_ONLY inline EXTERN yhandle_t Yap_NewHandles__(int n USES_REGS) { #define Yap_InitSlots(n, ts) Yap_InitHandles__(n, ts PASS_REGS) /// @brief create n new slots with terms ts[] -INLINE_ONLY inline EXTERN yhandle_t Yap_InitHandles__(int n, +INLINE_ONLY yhandle_t Yap_InitHandles__(int n, Term *ts USES_REGS); -INLINE_ONLY inline EXTERN yhandle_t Yap_InitHandles__(int n, +INLINE_ONLY yhandle_t Yap_InitHandles__(int n, Term *ts USES_REGS) { yhandle_t old_slots = LOCAL_CurHandle; int i; @@ -283,7 +285,7 @@ static inline bool Yap_RecoverHandles__(int n, yhandle_t topHandle USES_REGS) { return false; } #endif - LOCAL_CurHandle -= n; + LOCAL_CurHandle = topHandle; // fprintf(stderr,"RS %ld %s:%d\n", LOCAL_CurHandle, __FILE__, __LINE__); return true; } diff --git a/H/YapHeap.h b/H/YapHeap.h index 233c5ebc8..5e8551775 100755 --- a/H/YapHeap.h +++ b/H/YapHeap.h @@ -18,6 +18,9 @@ #ifndef HEAP_H #define HEAP_H 1 +#include "Atoms.h" +#include "Yap.h" + #if LOW_PROF #include #endif @@ -31,24 +34,6 @@ typedef int (*SWI_FlushFunction)(void *); typedef int (*SWI_PLGetStreamFunction)(void *); typedef int (*SWI_PLGetStreamPositionFunction)(void *); -typedef int (*Opaque_CallOnFail)(void *); -typedef int (*Opaque_CallOnWrite)(FILE *, int, void *, int); -typedef Int (*Opaque_CallOnGCMark)(int, void *, Term *, Int); -typedef int (*Opaque_CallOnGCRelocate)(int, void *, Term *, Int); - -typedef struct opaque_handler_struct { - Opaque_CallOnFail fail_handler; - Opaque_CallOnWrite write_handler; - Opaque_CallOnGCMark gc_mark_handler; - Opaque_CallOnGCRelocate gc_relocate_handler; -} opaque_handler_t; - -extern Opaque_CallOnWrite Yap_blob_write_handler_from_slot(Int slot); -extern Opaque_CallOnGCMark Yap_blob_gc_mark_handler(Term t); -extern Opaque_CallOnGCRelocate Yap_blob_gc_relocate_handler(Term t); -extern Int Yap_blob_tag_from_slot(Int slot); -extern void *Yap_blob_info_from_slot(Int slot); - #ifndef INT_KEYS_DEFAULT_SIZE #define INT_KEYS_DEFAULT_SIZE 256 #endif @@ -171,10 +156,10 @@ typedef struct various_codes { } all_heap_codes; -#include "hglobals.h" +#include "generated/hglobals.h" -#include "dhstruct.h" -#include "dglobals.h" +#include "generated/dhstruct.h" +#include "generated/dglobals.h" #else typedef struct various_codes { /* memory allocation and management */ @@ -184,17 +169,15 @@ typedef struct various_codes { } all_heap_codes; -#include "tatoms.h" +#include "generated/tatoms.h" -#include "h0struct.h" +#include "generated/h0struct.h" -#include "h0globals.h" +#include "generated/h0globals.h" #endif -#include "hlocals.h" - - +#include "generated/hlocals.h" #include "dlocals.h" @@ -231,7 +214,13 @@ extern struct various_codes *Yap_heap_regs; */ static inline yamop *gc_P(yamop *p, yamop *cp) { - return (p && p->opc == EXECUTE_CPRED_OPCODE ? cp : p); + yamop *n= (p && p->opc == EXECUTE_CPRED_OPCODE ? cp : p); + if (p->opc == Yap_opcode(_try_c) || + p->opc == Yap_opcode(_try_userc) || + p->opc == Yap_opcode(_retry_c) || + p->opc == Yap_opcode(_retry_userc)) + return cp; + return n; } /** @@ -241,9 +230,9 @@ static inline yamop *gc_P(yamop *p, yamop *cp) { #define Yap_CurrentModule() Yap_CurrentModule__(PASS_REGS1) -INLINE_ONLY inline EXTERN Term Yap_CurrentModule__(USES_REGS1); +INLINE_ONLY Term Yap_CurrentModule__(USES_REGS1); -INLINE_ONLY inline EXTERN Term Yap_CurrentModule__(USES_REGS1) { +INLINE_ONLY Term Yap_CurrentModule__(USES_REGS1) { if (CurrentModule) return CurrentModule; return TermProlog; @@ -270,11 +259,11 @@ extern ADDR Yap_ExpandPreAllocCodeSpace(UInt, void *, int); extern ADDR Yap_InitPreAllocCodeSpace(int); #include "inline-only.h" -INLINE_ONLY EXTERN inline ADDR Yap_PreAllocCodeSpace(void); +INLINE_ONLY ADDR Yap_PreAllocCodeSpace(void); -INLINE_ONLY EXTERN inline ADDR Yap_PreAllocCodeSpace(void) { +INLINE_ONLY ADDR Yap_PreAllocCodeSpace(void) { CACHE_REGS - return AuxBase; + return AuxBase; } #endif /* HEAP_H */ diff --git a/H/YapLFlagInfo.h b/H/YapLFlagInfo.h index 4021b62a7..376a4989e 100644 --- a/H/YapLFlagInfo.h +++ b/H/YapLFlagInfo.h @@ -1,91 +1,114 @@ + + /************************************************************************* -* * -* YAP Prolog * -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 2015- * -* * -************************************************************************** -* * -* File: YapLFlagInfo.h * -* Last rev: * -* mods: * -* comments: local flag enumeration. * -* * -*************************************************************************/ + * * + * YAP Prolog * + * * + * Yap Prolog was developed at NCCUP - Universidade do Porto * + * * + * Copyright L.Damas, V.S.Costa and Universidade do Porto 2015- * + * * + ************************************************************************** + * * + * File: YapLFlagInfo.h * Last rev: + ** mods: * comments: local flag enumeration. * + * * + *************************************************************************/ /** @file YapLFlagInfo.h - @addtogroup Flags + @addtogroup YAPFlags +@ingroup builtins +@{ + + + @enum THREAD_LOCAL_FLAGS Local Flags supported by YAP + @brief local flags and their values. */ -YAP_FLAG( AUTOLOAD_FLAG, "autoload", true, booleanFlag, "false" , NULL ), -YAP_FLAG( BREAK_LEVEL_FLAG, "break_level", true, nat, "0" , NULL ), -YAP_FLAG( CALL_COUNTING_FLAG, "call_counting", true, booleanFlag, "true" , NULL ), /** + `call_counting` +START_LOCAL_FLAGS - Predicates compiled with this flag set maintain a counter on the numbers of proceduree calls and of retries. These counters are decreasing counters, and they can be used as timers. Three counters are available: +/** + `autoload`: set the system to look for undefined procedures */ +YAP_FLAG(AUTOLOAD_FLAG, "autoload", true, booleanFlag, "false", NULL), - calls: number of predicate calls since execution started or since system was reset; - retries: number of retries for predicates called since execution started or since counters were reset; - calls_and_retries: count both on predicate calls and retries. - These counters can be used to find out how many calls a certain goal takes to execute. They can also be force the computatiom yp - stopping. +/** + `read-only flag, that tells if Prolog is in an inner top-level */ + YAP_FLAG(BREAK_LEVEL_FLAG, "break_level", true, nat, "0", NULL), - If `on` `fileerrors` is `on`, if `off` (default) - `fileerrors` is disabled. - */ -YAP_FLAG( ENCODING_FLAG, "encoding", true, isatom, "utf-8" , getenc ), -YAP_FLAG( FILEERRORS_FLAG, "fileerrors", true, booleanFlag, "true" , NULL ), /** + `fileerrors` + /** + `call_counting` - If `on` `fileerrors` is `on`, if `off` (default) - `fileerrors` is disabled. - */ -YAP_FLAG( LANGUAGE_MODE_FLAG, "language_mode", true, isatom, "yap" , NULL ), /** + `language_mode` + Predicates compiled with this flag set maintain a counter + on the numbers of proceduree calls and of retries. These counters + are decreasing counters, and they can be used as timers. Three + counters are available: - wweter native mode or trying to emulate a different Prolog. - */ -YAP_FLAG( REDEFINE_WARNINGS_FLAG, "redefine_warnings", true, booleanFlag, "true" , NULL ), /** + `redefine_warnings ` + calls: number of predicate calls since execution started or + since system was reset; retries: number of retries for predicates + called since execution started or since counters were reset; + calls_and_retries: count both on predicate calls and + retries. These counters can be used to find out how many calls a + certain goal takes to execute. They can also be force the + computatiom yp stopping. - If _Value_ is unbound, tell whether warnings for procedures defined -in several different files are `on` or -`off`. If _Value_ is bound to `on` enable these warnings, -and if it is bound to `off` disable them. The default for YAP is -`off`, unless we are in `sicstus` or `iso` mode. + If `on` `fileerrors` is `on`, if `off` (default) + `fileerrors` is disabled. + */ + YAP_FLAG(CALL_COUNTING_FLAG, "call_counting", true, booleanFlag, "true", + NULL), + +/** + support for coding systens, YAP relies on UTF-8 internally. */ -YAP_FLAG( SINGLE_VAR_WARNINGS_FLAG, "single_var_warnings", true, booleanFlag, "true" , NULL ), /** + `single_var_warnings` - If `true` (default `true`) YAP checks for singleton variables when loading files. A singleton variable is a variable that appears ony once in a clause. The name must start with a capital letter, variables whose name starts with underscore are never considered singleton. + YAP_FLAG(ENCODING_FLAG, "encoding", true, isatom, "utf-8", getenc), - */ -YAP_FLAG( STACK_DUMP_ON_ERROR_FLAG, "stack_dump_on_error", true, booleanFlag, "false" , NULL ), /** + `stack_dump_on_error ` +/** + what to do if opening a file fails. - If `true` show a stack dump when YAP finds an error. The default is + */ + YAP_FLAG(FILEERRORS_FLAG, "fileerrors", true, booleanFlag, "true", + NULL), /** + `fileerrors` + + If `on` `fileerrors` is `on`, if `off` (default) + `fileerrors` is disabled. + */ + /** + `language_mode` + + wweter native mode or trying to emulate a different + Prolog. + */ + YAP_FLAG(LANGUAGE_MODE_FLAG, "language_mode", true, isatom, "yap", + NULL), + YAP_FLAG(STACK_DUMP_ON_ERROR_FLAG, "stack_dump_on_error", true, booleanFlag, + "true", NULL), /** + `stack_dump_on_error ` + +If `true` show a stack dump when YAP finds an error. The default is `off`. - */ -YAP_FLAG( STREAM_TYPE_CHECK_FLAG, "stream_type_check", true, isatom, "loose" , NULL ), -YAP_FLAG( SYNTAX_ERRORS_FLAG, "syntax_errors", true, synerr, "error" , NULL ), /** + `syntax_errors` +*/ + YAP_FLAG(STREAM_TYPE_CHECK_FLAG, "stream_type_check", true, isatom, "loose", + NULL), + YAP_FLAG(SYNTAX_ERRORS_FLAG, "syntax_errors", true, synerr, "error", + NULL), /** + `syntax_errors` - Control action to be taken after syntax errors while executing read/1, +Control action to be taken after syntax errors while executing read/1, `read/2`, or `read_term/3`: - + `dec10` ++ `dec10` Report the syntax error and retry reading the term. - + `fail` ++ `fail` Report the syntax error and fail. - + `error` ++ `error` Report the syntax error and generate an error (default). - + `quiet` ++ `quiet` Just fail - */ -YAP_FLAG( TYPEIN_MODULE_FLAG, "typein_module", true, isatom, "user" , typein ), /** + `typein_module ` +*/ + YAP_FLAG(TYPEIN_MODULE_FLAG, "typein_module", true, isatom, "user", + typein), /** + `typein_module ` - If bound, set the current working or type-in module to the argument, +If bound, set the current working or type-in module to the argument, which must be an atom. If unbound, unify the argument with the current working module. - */ - YAP_FLAG( USER_ERROR_FLAG, "user_error", true, stream, "user_error" , set_error_stream ), /** + `user_error1` +*/ + YAP_FLAG(USER_ERROR_FLAG, "user_error", true, stream, "user_error", + set_error_stream), /** + `user_error1` - If the second argument is bound to a stream, set user_error to +If the second argument is bound to a stream, set user_error to this stream. If the second argument is unbound, unify the argument with the current user_error stream. By default, the user_error stream is set to a stream @@ -93,26 +116,32 @@ corresponding to the Unix `stderr` stream. The next example shows how to use this flag: ~~~{.prolog} - ?- open( '/dev/null', append, Error, - [alias(mauri_tripa)] ). +?- open( '/dev/null', append, Error, +[alias(mauri_tripa)] ). - Error = '$stream'(3) ? ; +Error = '$stream'(3) ? ; - no - ?- set_prolog_flag(user_error, mauri_tripa). +no +?- set_prolog_flag(user_error, mauri_tripa). - close(mauri_tripa). +close(mauri_tripa). - yes - ?- +yes +?- ~~~ - We execute three commands. First, we open a stream in write mode and +We execute three commands. First, we open a stream in write mode and give it an alias, in this case `mauri_tripa`. Next, we set user_error to the stream via the alias. Note that after we did so prompts from the system were redirected to the stream `mauri_tripa`. Last, we close the stream. At this point, YAP automatically redirects the user_error alias to the original `stderr`. - */ -YAP_FLAG( USER_INPUT_FLAG, "user_input", true, stream, "user_input" , set_input_stream ), - YAP_FLAG( USER_OUTPUT_FLAG, "user_output", true, stream, "user_output" , set_output_stream ), +*/ + YAP_FLAG(USER_INPUT_FLAG, "user_input", true, stream, "user_input", + set_input_stream), + YAP_FLAG(USER_OUTPUT_FLAG, "user_output", true, stream, "user_output", + set_output_stream), + + END_LOCAL_FLAGS + + /// @} diff --git a/H/YapOpcodes.h b/H/YapOpcodes.h index 4a3336e5c..7cb06d047 100644 --- a/H/YapOpcodes.h +++ b/H/YapOpcodes.h @@ -6,6 +6,26 @@ OPCODE(Nstop ,e), #ifdef YAP_JIT OPCODE(jit_handler ,J), +#endif + OPCODE(cut ,s), + OPCODE(cut_t ,s), + OPCODE(cut_e ,s), + OPCODE(save_b_x ,x), + OPCODE(save_b_y ,y), + OPCODE(commit_b_x ,xps), + OPCODE(commit_b_y ,yps), + OPCODE(execute ,Osbpp), + OPCODE(dexecute ,Osbpp), + OPCODE(fcall ,Osbpp), + OPCODE(call ,Osbpp), + OPCODE(procceed ,p), + OPCODE(allocate ,e), + OPCODE(deallocate ,p), +#ifdef BEAM + OPCODE(retry_eam ,e), +#endif +#ifdef BEAM + OPCODE(run_eam ,os), #endif OPCODE(try_me ,Otapl), OPCODE(retry_me ,Otapl), @@ -43,6 +63,44 @@ OPCODE(retry4 ,l), OPCODE(trust ,Otapl), OPCODE(try_in ,l), + OPCODE(trust_fail ,e), + OPCODE(op_fail ,e), + OPCODE(call_cpred ,Osbpp), + OPCODE(execute_cpred ,Osbpp), + OPCODE(call_usercpred ,Osbpp), + OPCODE(call_c_wfail ,slpp), + OPCODE(try_c ,OtapFs), + OPCODE(retry_c ,OtapFs), + OPCODE(cut_c ,OtapFs), + OPCODE(try_userc ,OtapFs), + OPCODE(retry_userc ,OtapFs), + OPCODE(cut_userc ,OtapFs), + OPCODE(lock_pred ,e), + OPCODE(index_pred ,e), +#ifdef THREADS + OPCODE(thread_local ,e), +#endif + OPCODE(expand_index ,e), + OPCODE(expand_clauses ,sssllp), + OPCODE(undef_p ,e), + OPCODE(spy_pred ,e), + OPCODE(user_switch ,lp), + OPCODE(switch_on_type ,llll), + OPCODE(switch_list_nl ,ollll), + OPCODE(switch_on_arg_type ,xllll), + OPCODE(switch_on_sub_arg_type ,sllll), + OPCODE(jump_if_var ,l), + OPCODE(jump_if_nonvar ,xll), + OPCODE(if_not_then ,clll), + OPCODE(switch_on_func ,sssl), + OPCODE(switch_on_cons ,sssl), + OPCODE(go_on_func ,sssl), + OPCODE(go_on_cons ,sssl), + OPCODE(if_func ,sssl), + OPCODE(if_cons ,sssl), + OPCODE(index_dbref ,e), + OPCODE(index_blob ,e), + OPCODE(index_long ,e), OPCODE(enter_lu_pred ,Illss), OPCODE(profiled_retry_logical ,OtaLl), OPCODE(profiled_trust_logical ,OtILl), @@ -56,28 +114,94 @@ OPCODE(alloc_for_logical_pred ,L), OPCODE(copy_idb_term ,e), OPCODE(unify_idb_term ,e), - OPCODE(trust_fail ,e), - OPCODE(op_fail ,e), - OPCODE(cut ,s), - OPCODE(cut_t ,s), - OPCODE(cut_e ,s), - OPCODE(save_b_x ,x), - OPCODE(save_b_y ,y), - OPCODE(commit_b_x ,xps), - OPCODE(commit_b_y ,yps), - OPCODE(execute ,pp), - OPCODE(dexecute ,pp), - OPCODE(fcall ,Osbpp), - OPCODE(call ,Osbpp), - OPCODE(procceed ,p), - OPCODE(allocate ,e), - OPCODE(deallocate ,p), -#ifdef BEAM - OPCODE(retry_eam ,e), -#endif -#ifdef BEAM - OPCODE(run_eam ,os), -#endif + OPCODE(p_execute_tail ,Osbmp), + OPCODE(p_execute2 ,Osbpp), + OPCODE(p_execute ,Osbmp), + OPCODE(jump ,l), + OPCODE(move_back ,l), + OPCODE(skip ,l), + OPCODE(either ,Osblp), + OPCODE(or_else ,Osblp), + OPCODE(pop_n ,s), + OPCODE(pop ,e), + OPCODE(p_plus_vv ,xxx), + OPCODE(p_plus_vc ,xxn), + OPCODE(p_plus_y_vv ,yxx), + OPCODE(p_plus_y_vc ,yxn), + OPCODE(p_minus_vv ,xxx), + OPCODE(p_minus_cv ,xxn), + OPCODE(p_minus_y_vv ,yxx), + OPCODE(p_minus_y_cv ,yxn), + OPCODE(p_times_vv ,xxx), + OPCODE(p_times_vc ,xxn), + OPCODE(p_times_y_vv ,yxx), + OPCODE(p_times_y_vc ,yxn), + OPCODE(p_div_vv ,xxx), + OPCODE(p_div_vc ,xxn), + OPCODE(p_div_cv ,xxn), + OPCODE(p_div_y_vv ,yxx), + OPCODE(p_div_y_vc ,yxn), + OPCODE(p_div_y_cv ,yxn), + OPCODE(p_and_vv ,xxx), + OPCODE(p_and_vc ,xxn), + OPCODE(p_and_y_vv ,yxx), + OPCODE(p_and_y_vc ,yxn), + OPCODE(p_or_vv ,xxx), + OPCODE(p_or_vc ,xxn), + OPCODE(p_or_y_vv ,yxx), + OPCODE(p_or_y_vc ,yxn), + OPCODE(p_sll_vv ,xxx), + OPCODE(p_sll_vc ,xxn), + OPCODE(p_sll_cv ,xxn), + OPCODE(p_sll_y_vv ,yxx), + OPCODE(p_sll_y_vc ,yxn), + OPCODE(p_sll_y_cv ,yxn), + OPCODE(p_slr_vv ,xxx), + OPCODE(p_slr_vc ,xxn), + OPCODE(p_slr_cv ,xxn), + OPCODE(p_slr_y_vv ,yxx), + OPCODE(p_slr_y_vc ,yxn), + OPCODE(p_slr_y_cv ,yxn), + OPCODE(call_bfunc_xx ,plxxs), + OPCODE(call_bfunc_yx ,plxys), + OPCODE(call_bfunc_xy ,plxys), + OPCODE(call_bfunc_yy ,plyys), + OPCODE(p_equal ,e), + OPCODE(p_arg_vv ,xxx), + OPCODE(p_arg_cv ,xxn), + OPCODE(p_arg_y_vv ,yxx), + OPCODE(p_arg_y_cv ,yxn), + OPCODE(p_func2s_vv ,xxx), + OPCODE(p_func2s_cv ,xxc), + OPCODE(p_func2s_vc ,xxn), + OPCODE(p_func2s_y_vv ,yxx), + OPCODE(p_func2s_y_cv ,yxc), + OPCODE(p_func2s_y_vc ,yxn), + OPCODE(p_func2f_xx ,xxx), + OPCODE(p_func2f_xy ,xxy), + OPCODE(p_func2f_yx ,yxx), + OPCODE(p_func2f_yy ,yyx), + OPCODE(p_functor ,e), + OPCODE(p_atom_x ,xl), + OPCODE(p_atom_y ,yl), + OPCODE(p_atomic_x ,xl), + OPCODE(p_atomic_y ,yl), + OPCODE(p_integer_x ,xl), + OPCODE(p_integer_y ,yl), + OPCODE(p_nonvar_x ,xl), + OPCODE(p_nonvar_y ,yl), + OPCODE(p_number_x ,xl), + OPCODE(p_number_y ,yl), + OPCODE(p_var_x ,xl), + OPCODE(p_var_y ,yl), + OPCODE(p_db_ref_x ,xl), + OPCODE(p_db_ref_y ,yl), + OPCODE(p_primitive_x ,xl), + OPCODE(p_primitive_y ,yl), + OPCODE(p_compound_x ,xl), + OPCODE(p_compound_y ,yl), + OPCODE(p_float_x ,xl), + OPCODE(p_float_y ,yl), OPCODE(get_x_var ,xx), OPCODE(get_y_var ,yx), OPCODE(get_yy_var ,yyxx), @@ -207,134 +331,6 @@ OPCODE(save_appl_x_write ,ox), OPCODE(save_appl_y ,oy), OPCODE(save_appl_y_write ,oy), - OPCODE(call_cpred ,Osbpp), - OPCODE(execute_cpred ,pp), - OPCODE(call_usercpred ,Osbpp), - OPCODE(call_c_wfail ,slpp), - OPCODE(try_c ,OtapFs), - OPCODE(retry_c ,OtapFs), - OPCODE(cut_c ,OtapFs), - OPCODE(try_userc ,OtapFs), - OPCODE(retry_userc ,OtapFs), - OPCODE(cut_userc ,OtapFs), - OPCODE(lock_pred ,e), - OPCODE(index_pred ,e), -#ifdef THREADS - OPCODE(thread_local ,e), -#endif - OPCODE(expand_index ,e), - OPCODE(expand_clauses ,sssllp), - OPCODE(undef_p ,e), - OPCODE(spy_pred ,e), - OPCODE(jump ,l), - OPCODE(move_back ,l), - OPCODE(skip ,l), - OPCODE(either ,Osblp), - OPCODE(or_else ,Osblp), - OPCODE(pop_n ,s), - OPCODE(pop ,e), - OPCODE(user_switch ,lp), - OPCODE(switch_on_type ,llll), - OPCODE(switch_list_nl ,ollll), - OPCODE(switch_on_arg_type ,xllll), - OPCODE(switch_on_sub_arg_type ,sllll), - OPCODE(jump_if_var ,l), - OPCODE(jump_if_nonvar ,xll), - OPCODE(if_not_then ,clll), - OPCODE(switch_on_func ,sssl), - OPCODE(switch_on_cons ,sssl), - OPCODE(go_on_func ,sssl), - OPCODE(go_on_cons ,sssl), - OPCODE(if_func ,sssl), - OPCODE(if_cons ,sssl), - OPCODE(index_dbref ,e), - OPCODE(index_blob ,e), - OPCODE(index_long ,e), - OPCODE(p_atom_x ,xl), - OPCODE(p_atom_y ,yl), - OPCODE(p_atomic_x ,xl), - OPCODE(p_atomic_y ,yl), - OPCODE(p_integer_x ,xl), - OPCODE(p_integer_y ,yl), - OPCODE(p_nonvar_x ,xl), - OPCODE(p_nonvar_y ,yl), - OPCODE(p_number_x ,xl), - OPCODE(p_number_y ,yl), - OPCODE(p_var_x ,xl), - OPCODE(p_var_y ,yl), - OPCODE(p_db_ref_x ,xl), - OPCODE(p_db_ref_y ,yl), - OPCODE(p_primitive_x ,xl), - OPCODE(p_primitive_y ,yl), - OPCODE(p_compound_x ,xl), - OPCODE(p_compound_y ,yl), - OPCODE(p_float_x ,xl), - OPCODE(p_float_y ,yl), - OPCODE(p_plus_vv ,xxx), - OPCODE(p_plus_vc ,xxn), - OPCODE(p_plus_y_vv ,yxx), - OPCODE(p_plus_y_vc ,yxn), - OPCODE(p_minus_vv ,xxx), - OPCODE(p_minus_cv ,xxn), - OPCODE(p_minus_y_vv ,yxx), - OPCODE(p_minus_y_cv ,yxn), - OPCODE(p_times_vv ,xxx), - OPCODE(p_times_vc ,xxn), - OPCODE(p_times_y_vv ,yxx), - OPCODE(p_times_y_vc ,yxn), - OPCODE(p_div_vv ,xxx), - OPCODE(p_div_vc ,xxn), - OPCODE(p_div_cv ,xxn), - OPCODE(p_div_y_vv ,yxx), - OPCODE(p_div_y_vc ,yxn), - OPCODE(p_div_y_cv ,yxn), - OPCODE(p_and_vv ,xxx), - OPCODE(p_and_vc ,xxn), - OPCODE(p_and_y_vv ,yxx), - OPCODE(p_and_y_vc ,yxn), - OPCODE(p_or_vv ,xxx), - OPCODE(p_or_vc ,xxn), - OPCODE(p_or_y_vv ,yxx), - OPCODE(p_or_y_vc ,yxn), - OPCODE(p_sll_vv ,xxx), - OPCODE(p_sll_vc ,xxn), - OPCODE(p_sll_cv ,xxn), - OPCODE(p_sll_y_vv ,yxx), - OPCODE(p_sll_y_vc ,yxn), - OPCODE(p_sll_y_cv ,yxn), - OPCODE(p_slr_vv ,xxx), - OPCODE(p_slr_vc ,xxn), - OPCODE(p_slr_cv ,xxn), - OPCODE(p_slr_y_vv ,yxx), - OPCODE(p_slr_y_vc ,yxn), - OPCODE(p_slr_y_cv ,yxn), - OPCODE(call_bfunc_xx ,plxxs), - OPCODE(call_bfunc_yx ,plxys), - OPCODE(call_bfunc_xy ,plxys), - OPCODE(call_bfunc_yy ,plyys), - OPCODE(p_equal ,e), -#if INLINE_BIG_COMPARISONS - OPCODE(p_dif ,l), - OPCODE(p_eq ,l), -#endif - OPCODE(p_arg_vv ,xxx), - OPCODE(p_arg_cv ,xxn), - OPCODE(p_arg_y_vv ,yxx), - OPCODE(p_arg_y_cv ,yxn), - OPCODE(p_func2s_vv ,xxx), - OPCODE(p_func2s_cv ,xxc), - OPCODE(p_func2s_vc ,xxn), - OPCODE(p_func2s_y_vv ,yxx), - OPCODE(p_func2s_y_cv ,yxc), - OPCODE(p_func2s_y_vc ,yxn), - OPCODE(p_func2f_xx ,xxx), - OPCODE(p_func2f_xy ,xxy), - OPCODE(p_func2f_yx ,yxx), - OPCODE(p_func2f_yy ,yyx), - OPCODE(p_functor ,e), - OPCODE(p_execute_tail ,Osbmp), - OPCODE(p_execute2 ,Osbpp), - OPCODE(p_execute ,Osbmp), #ifdef YAPOR OPCODE(getwork_first_time ,e), OPCODE(getwork ,Otapl), diff --git a/H/YapSignals.h b/H/YapSignals.h index 35fc41835..fb363442b 100755 --- a/H/YapSignals.h +++ b/H/YapSignals.h @@ -77,34 +77,34 @@ typedef enum #define Yap_has_signal(S) Yap_has_signal__(S PASS_REGS) #define Yap_only_has_signal(S) Yap_only_has_signal__(S PASS_REGS) -INLINE_ONLY inline EXTERN uint64_t SIGNAL_TO_BIT( yap_signals sig); +INLINE_ONLY uint64_t SIGNAL_TO_BIT( yap_signals sig); -INLINE_ONLY inline EXTERN uint64_t +INLINE_ONLY uint64_t SIGNAL_TO_BIT( yap_signals sig) { return ((uint64_t)1 << (sig-1)); } -INLINE_ONLY inline EXTERN int Yap_has_a_signal__ ( USES_REGS1 ); +INLINE_ONLY int Yap_has_a_signal__ ( USES_REGS1 ); -INLINE_ONLY inline EXTERN int Yap_has_signal__ ( yap_signals sig USES_REGS ); +INLINE_ONLY int Yap_has_signal__ ( yap_signals sig USES_REGS ); -INLINE_ONLY inline EXTERN int Yap_only_has_signal__(yap_signals sig USES_REGS); +INLINE_ONLY int Yap_only_has_signal__(yap_signals sig USES_REGS); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int Yap_has_a_signal__ (USES_REGS1) { return LOCAL_Signals != ((uint64_t)0); } -INLINE_ONLY inline EXTERN int +INLINE_ONLY int Yap_has_signal__(yap_signals sig USES_REGS) { return (LOCAL_Signals & SIGNAL_TO_BIT(sig)) != ((uint64_t)0); } -INLINE_ONLY inline EXTERN int +INLINE_ONLY int Yap_only_has_signal__(yap_signals sig USES_REGS) { return (LOCAL_Signals & SIGNAL_TO_BIT(sig)) == SIGNAL_TO_BIT(sig); diff --git a/H/YapTags.h b/H/YapTags.h index 2eb5e7b2d..bceab8663 100644 --- a/H/YapTags.h +++ b/H/YapTags.h @@ -156,106 +156,95 @@ applies to unbound variables *************************************************************************************************/ -INLINE_ONLY inline EXTERN Term *VarOfTerm(Term t); +INLINE_ONLY Term *VarOfTerm(Term t); -INLINE_ONLY inline EXTERN Term *VarOfTerm(Term t) { return (Term *)(t); } +INLINE_ONLY Term *VarOfTerm(Term t) { return (Term *)(t); } #ifdef YAPOR_SBA #define RESET_VARIABLE(V) (*(CELL *)(V) = 0) -INLINE_ONLY inline EXTERN Term MkVarTerm__(USES_REGS1); +INLINE_ONLY Term MkVarTerm__(USES_REGS1); -INLINE_ONLY -inline EXTERN Term MkVarTerm__(USES_REGS1) { +INLINE_ONLY Term MkVarTerm__(USES_REGS1) { return (Term)((*HR = 0, HR++)); } -INLINE_ONLY inline EXTERN bool IsUnboundVar(Term *); +INLINE_ONLY bool IsUnboundVar(Term *); -INLINE_ONLY -inline EXTERN bool IsUnboundVar(Term *t) { return (int)(*(t) == +INLINE_ONLY bool IsUnboundVar(Term *t) { return (int)(*(t) == 0); } #else #define RESET_VARIABLE(V) (*(CELL *)(V) = Unsigned(V)) -INLINE_ONLY inline EXTERN Term MkVarTerm__(USES_REGS1); +INLINE_ONLY Term MkVarTerm__(USES_REGS1); -INLINE_ONLY -inline EXTERN Term MkVarTerm__(USES_REGS1) { +INLINE_ONLY Term MkVarTerm__(USES_REGS1) { return (Term)((*HR = (CELL)HR, HR++)); } -INLINE_ONLY inline EXTERN bool IsUnboundVar(Term *); +INLINE_ONLY bool IsUnboundVar(Term *); -INLINE_ONLY - inline EXTERN bool IsUnboundVar(Term *t) { +INLINE_ONLY bool IsUnboundVar(Term *t) { return *(t) == (Term)(t); } #endif -INLINE_ONLY inline EXTERN CELL *PtrOfTerm(Term); +INLINE_ONLY CELL *PtrOfTerm(Term); -INLINE_ONLY - inline EXTERN CELL *PtrOfTerm(Term t) { +INLINE_ONLY CELL *PtrOfTerm(Term t) { return (CELL *)(*(CELL *)(t)); } -INLINE_ONLY inline EXTERN Functor FunctorOfTerm(Term); +INLINE_ONLY Functor FunctorOfTerm(Term); -INLINE_ONLY - inline EXTERN Functor FunctorOfTerm(Term t) { +INLINE_ONLY Functor FunctorOfTerm(Term t) { return (Functor)(*RepAppl(t)); } #if USE_LOW32_TAGS -INLINE_ONLY inline EXTERN Term MkAtomTerm(Atom); +INLINE_ONLY Term MkAtomTerm(Atom); -INLINE_ONLY - inline EXTERN Term MkAtomTerm(Atom a) { +INLINE_ONLY Term MkAtomTerm(Atom a) { return (Term)(AtomTag | (CELL)(a)); } -INLINE_ONLY inline EXTERN Atom AtomOfTerm(Term t); +INLINE_ONLY Atom AtomOfTerm(Term t); -INLINE_ONLY - inline EXTERN Atom AtomOfTerm(Term t) { +INLINE_ONLY Atom AtomOfTerm(Term t) { return (Atom)((~AtomTag & (CELL)(t))); } #else -INLINE_ONLY inline EXTERN Term MkAtomTerm(Atom); +INLINE_ONLY Term MkAtomTerm(Atom); -INLINE_ONLY - inline EXTERN Term MkAtomTerm(Atom at) { +INLINE_ONLY Term MkAtomTerm(Atom at) { return (Term)(TAGGEDA((CELL)AtomTag, (CELL)(at))); } -INLINE_ONLY inline EXTERN Atom AtomOfTerm(Term t); +INLINE_ONLY Atom AtomOfTerm(Term t); -INLINE_ONLY - inline EXTERN Atom AtomOfTerm(Term t) { +INLINE_ONLY Atom AtomOfTerm(Term t) { return (Atom)(NonTagPart(t)); } #endif -INLINE_ONLY inline EXTERN bool IsAtomTerm(Term); +INLINE_ONLY bool IsAtomTerm(Term); -INLINE_ONLY - inline EXTERN bool IsAtomTerm(Term t) { +INLINE_ONLY bool IsAtomTerm(Term t) { return CHKTAG((t), AtomTag); } -INLINE_ONLY inline EXTERN Term MkIntTerm(Int); +INLINE_ONLY Term MkIntTerm(Int); INLINE_ONLY - inline EXTERN Term MkIntTerm(Int n) { + Term MkIntTerm(Int n) { return (Term)(TAGGED(NumberTag, (n))); } @@ -264,24 +253,24 @@ INLINE_ONLY overflow problems are possible */ -INLINE_ONLY inline EXTERN Term MkIntConstant(Int); +INLINE_ONLY Term MkIntConstant(Int); INLINE_ONLY - inline EXTERN Term MkIntConstant(Int n) { + Term MkIntConstant(Int n) { return (Term)(NONTAGGED(NumberTag, (n))); } -INLINE_ONLY inline EXTERN bool IsIntTerm(Term); +INLINE_ONLY bool IsIntTerm(Term); INLINE_ONLY - inline EXTERN bool IsIntTerm(Term t) { + bool IsIntTerm(Term t) { return CHKTAG((t), NumberTag); } -INLINE_ONLY EXTERN inline Term MkPairTerm__(Term head, Term tail USES_REGS); +INLINE_ONLY Term MkPairTerm__(Term head, Term tail USES_REGS); INLINE_ONLY - EXTERN inline Term MkPairTerm__(Term head, Term tail USES_REGS) { + Term MkPairTerm__(Term head, Term tail USES_REGS) { CELL *p = HR; HR[0] = head; @@ -321,25 +310,22 @@ INLINE_ONLY #define MkIntegerTerm(i) __MkIntegerTerm(i PASS_REGS) -INLINE_ONLY inline EXTERN Term __MkIntegerTerm(Int USES_REGS); +INLINE_ONLY Term __MkIntegerTerm(Int USES_REGS); -INLINE_ONLY - inline EXTERN Term __MkIntegerTerm(Int n USES_REGS) { +INLINE_ONLY Term __MkIntegerTerm(Int n USES_REGS) { return (Term)(IntInBnd(n) ? MkIntTerm(n) : MkLongIntTerm(n)); } #endif -INLINE_ONLY inline EXTERN bool IsIntegerTerm(Term); +INLINE_ONLY bool IsIntegerTerm(Term); -INLINE_ONLY - inline EXTERN bool IsIntegerTerm(Term t) { +INLINE_ONLY bool IsIntegerTerm(Term t) { return (int)(IsIntTerm(t) || IsLongIntTerm(t)); } -INLINE_ONLY inline EXTERN Int IntegerOfTerm(Term); +INLINE_ONLY Int IntegerOfTerm(Term); -INLINE_ONLY - inline EXTERN Int IntegerOfTerm(Term t) { +INLINE_ONLY Int IntegerOfTerm(Term t) { return (Int)(IsIntTerm(t) ? IntOfTerm(t) : LongIntOfTerm(t)); } @@ -348,34 +334,30 @@ INLINE_ONLY #define MkAddressTerm(i) __MkAddressTerm(i PASS_REGS) -INLINE_ONLY inline EXTERN Term __MkAddressTerm(void *USES_REGS); +INLINE_ONLY Term __MkAddressTerm(void *USES_REGS); -INLINE_ONLY - inline EXTERN Term __MkAddressTerm(void *n USES_REGS) { +INLINE_ONLY Term __MkAddressTerm(void *n USES_REGS) { return __MkIntegerTerm((Int)n PASS_REGS); } #endif -INLINE_ONLY inline EXTERN bool IsAddressTerm(Term); +INLINE_ONLY bool IsAddressTerm(Term); -INLINE_ONLY - inline EXTERN bool IsAddressTerm(Term t) { +INLINE_ONLY bool IsAddressTerm(Term t) { return (bool)IsIntegerTerm(t); } -INLINE_ONLY inline EXTERN void *AddressOfTerm(Term); +INLINE_ONLY void *AddressOfTerm(Term); -INLINE_ONLY - inline EXTERN void *AddressOfTerm(Term t) { +INLINE_ONLY void *AddressOfTerm(Term t) { return (void *)(IsIntTerm(t) ? IntOfTerm(t) : LongIntOfTerm(t)); } -INLINE_ONLY inline EXTERN Int IsPairTermOrNil (Term); +INLINE_ONLY Int IsPairTermOrNil (Term); -INLINE_ONLY - inline EXTERN Int +INLINE_ONLY Int IsPairOrNilTerm (Term t) { return IsPairTerm(t) || t == TermNil; diff --git a/H/YapText.h b/H/YapText.h index 34b7b9460..1fef851a2 100644 --- a/H/YapText.h +++ b/H/YapText.h @@ -1,52 +1,30 @@ /************************************************************************* -* * -* YAP Prolog * -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * -* * -************************************************************************** -* * -* File: YapMirror.c * -* Last rev: 5/2/88 * -* mods: * -* comments: Term conversion C implemented support * -* * -*************************************************************************/ + * * + * YAP Prolog * + * * + * Yap Prolog was developed at NCCUP - Universidade do Porto * + * * + * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * + * * + ************************************************************************** + * * + * File: YapMirror.c * + * Last rev: 5/2/88 * + * mods: * + * comments: Term conversion C implemented support * + * * + *************************************************************************/ #ifndef YAP_TEXT_H #define YAP_TEXT_H - -#if SIZEOF_WCHAR_T == 2 -#define CHARCODE_MAX 0xffff -#else -#define CHARCODE_MAX 0x10ffff -#endif +#include "Yap.h" /* - * This file defines main data-structure for text conversion and + * @file YapText.h + * @brief This file defines main data-structure for text conversion and * mirroring */ -#include "../utf8proc/utf8proc.h" -#include "Yap.h" - -#define ReleaseAndReturn(r) \ - { \ - pop_text_stack(l); \ - return r; \ - } -#define release_cut_fail() \ - { \ - pop_text_stack(l); \ - cut_fail(); \ - } -#define release_cut_succeed() \ - { \ - pop_text_stack(l); \ - cut_succeed(); \ - } - +#include "YapUTF8.h" /// allocate a temporary text block /// @@ -54,18 +32,37 @@ extern void *Malloc(size_t sz USES_REGS); extern void *Realloc(void *buf, size_t sz USES_REGS); extern void Free(void *buf USES_REGS); -extern int push_text_stack(USES_REGS1); -extern int pop_text_stack(int lvl USES_REGS); -extern void *protected_pop_text_stack(int lvl, void *safe, bool tmp, - size_t sz USES_REGS); +extern void *MallocAtLevel(size_t sz, int atL USES_REGS); +#define BaseMalloc(sz) MallocAtLevel(sz, 1) +extern const void *MallocExportAsRO(const void *blk); + +#ifndef Yap_Min +#define Yap_Min(x, y) (x < y ? x : y) -#ifndef min -#define min(x, y) (x < y ? x : y) #endif #define MBYTE (1024 * 1024) /* Character types for tokenizer and write.c */ +extern int AllocLevel(void); + +#define push_text_stack() \ + (/* fprintf(stderr, " + *** %d %s:%s:%d\n", AllocLevel(),*/ \ + /* __FILE__, __FUNCTION__, __LINE__), */ \ + push_text_stack__(PASS_REGS1)) +extern int push_text_stack__(USES_REGS1); + +#define pop_text_stack(lvl) \ + (/* fprintf(stderr, " - *** %d %s:%s:%d\n", AllocLevel(), __FILE__,*/ \ + /* __FUNCTION__, __LINE__), */ \ + pop_text_stack__(lvl)) +extern int pop_text_stack__(int lvl USES_REGS); + +#define pop_output_text_stack(lvl,p) \ + (/*fprintf(stderr, "-- *** %d %s:%s:%d\n", AllocLevel(), __FILE__,*/ \ + /* __FUNCTION__, __LINE__),*/ \ + pop_output_text_stack__(lvl,p)) +extern void *pop_output_text_stack__(int lvl, const void *ox USES_REGS); /****************** character definition table **************************/ @@ -96,7 +93,7 @@ extern char_kind_t Yap_chtype0[]; char_kind_t Yap_wide_chtype(int ch); -INLINE_ONLY EXTERN inline char_kind_t Yap_wide_chtype(int ch) { +INLINE_ONLY char_kind_t Yap_wide_chtype(int ch) { if (ch < 256) return Yap_chtype[ch]; switch (utf8proc_category(ch)) { @@ -167,7 +164,7 @@ INLINE_ONLY EXTERN inline char_kind_t Yap_wide_chtype(int ch) { return BS; } -INLINE_ONLY EXTERN inline char_kind_t chtype(Int ch) { +INLINE_ONLY char_kind_t chtype(Int ch) { if (ch < NUMBER_OF_CHARS) return Yap_chtype[ch]; return Yap_wide_chtype(ch); @@ -177,166 +174,28 @@ INLINE_ONLY EXTERN inline char_kind_t chtype(Int ch) { #define __android_log_print(...) #endif -INLINE_ONLY inline EXTERN utf8proc_ssize_t get_utf8(const utf8proc_uint8_t *ptr, - size_t n, - utf8proc_int32_t *valp); - -INLINE_ONLY inline EXTERN utf8proc_ssize_t get_utf8(const utf8proc_uint8_t *ptr, - size_t n, - utf8proc_int32_t *valp) { - return utf8proc_iterate(ptr, n, valp); -} - -INLINE_ONLY inline EXTERN utf8proc_ssize_t put_utf8(utf8proc_uint8_t *ptr, - utf8proc_int32_t val); - -INLINE_ONLY inline EXTERN utf8proc_ssize_t put_utf8(utf8proc_uint8_t *ptr, - utf8proc_int32_t val) { - return utf8proc_encode_char(val, ptr); -} - -inline static const utf8proc_uint8_t *skip_utf8(const utf8proc_uint8_t *pt, - utf8proc_ssize_t n) { - utf8proc_ssize_t i; - utf8proc_int32_t b; - for (i = 0; i < n; i++) { - utf8proc_ssize_t l = utf8proc_iterate(pt, -1, &b); - if (b == 0) - return pt; - pt += l; - } - return pt; -} - -inline static utf8proc_ssize_t utf8_nof(utf8proc_int32_t val) { - return utf8proc_charwidth(val); -} - -inline static utf8proc_ssize_t strlen_utf8(const utf8proc_uint8_t *pt) { - utf8proc_ssize_t rc = 0; - utf8proc_int32_t b; - while (true) { - utf8proc_ssize_t l = utf8proc_iterate(pt, -1, &b); - if (b == 0) - return rc; - else if (b > 0) { - pt += l; - rc++; - } else { - pt++; - } - } - return rc; -} - -inline static utf8proc_ssize_t strlen_latin_utf8(const unsigned char *pt) { - utf8proc_ssize_t rc = 0; - utf8proc_uint8_t b; - while (true) { - utf8proc_ssize_t l = utf8proc_encode_char(*pt, &b); - if (b == 0) - return rc; - pt++; - rc += l; - } - return rc; -} - -inline static utf8proc_ssize_t strnlen_latin_utf8(const unsigned char *pt, - size_t max) { - utf8proc_ssize_t rc = 0; - utf8proc_uint8_t b; - while (true) { - utf8proc_ssize_t l = utf8proc_encode_char(*pt, &b); - if (b == 0) - return rc; - pt++; - rc += l; - if (--max == 0) - return rc; - } - return rc; -} - -inline static utf8proc_ssize_t strlen_ucs2_utf8(const wchar_t *pt) { - utf8proc_ssize_t rc = 0; - utf8proc_uint8_t b; - while (true) { - utf8proc_ssize_t l = utf8proc_encode_char(*pt, &b); - if (b == 0) - return rc; - pt++; - rc += l; - } - return rc; -} - -inline static utf8proc_ssize_t strnlen_ucs2_utf8(const wchar_t *pt, - size_t max) { - utf8proc_ssize_t rc = 0; - utf8proc_uint8_t b; - while (true) { - utf8proc_ssize_t l = utf8proc_encode_char(*pt, &b); - if (b == 0) - return rc; - pt++; - rc += l; - if (--max == 0) - return rc; - } - return rc; -} - -inline static int cmpn_utf8(const utf8proc_uint8_t *pt1, - const utf8proc_uint8_t *pt2, utf8proc_ssize_t n) { - utf8proc_ssize_t i; - utf8proc_int32_t b; - for (i = 0; i < n; i++) { - if (pt1[0] != pt2[0]) - return pt1[0] - pt2[0]; - utf8proc_ssize_t l = utf8proc_iterate(pt1, -1, &b); - if (l == 2) { - if (pt1[1] != pt2[1]) - return pt1[1] - pt2[1]; - } else if (l == 3) { - if (pt1[2] != pt2[2]) - return pt1[2] - pt2[2]; - } else if (l == 4) { - if (pt1[3] != pt2[3]) - return pt1[3] - pt2[3]; - } - pt1 += l; - pt2 += l; - } - return 0; -} - -// UTF16 - -#define LEAD_OFFSET ((uint32_t)0xD800 - (uint32_t)(0x10000 >> 10)) -#define SURROGATE_OFFSET \ - ((uint32_t)0x10000 - (uint32_t)(0xD800 << 10) - (uint32_t)0xDC00) - extern const char *Yap_tokText(void *tokptr); -extern Term Yap_tokRep(void *tokptr); +/// represent token *_tokptr_ in string s, maxlength is sz-1 +/// +/// conversion is based on token type. +extern Term Yap_tokRep(void *tokptrXS); // standard strings -typedef enum { - YAP_STRING_STRING = 0x1, /// target is a string term - YAP_STRING_CODES = 0x2, /// target is a list of integer codes - YAP_STRING_ATOMS = 0x4, /// target is a list of kength-1 atom - YAP_STRING_ATOMS_CODES = 0x6, /// targt is list of atoms or codes - YAP_STRING_CHARS = 0x8, /// target is a buffer, with byte-sized units - YAP_STRING_WCHARS = 0x10, /// target is a buffer of wide chars - YAP_STRING_ATOM = 0x20, /// tarfet is an ayom - YAP_STRING_INT = 0x40, /// target is an integer term - YAP_STRING_FLOAT = 0x80, /// target is a floar term - YAP_STRING_BIG = 0x100, /// target is an big num term - YAP_STRING_DATUM = - 0x200, /// associated with previous 3, use actual object if type, not tern - YAP_STRING_LENGTH = - 0x400, /// input: length is fixed; output: return integer with length +typedef enum +{ + YAP_STRING_STRING = 0x1, /// target is a string term + YAP_STRING_CODES = 0x2, /// target is a list of integer codes + YAP_STRING_ATOMS = 0x4, /// target is a list of kength-1 atom + YAP_STRING_ATOMS_CODES = 0x6, /// targt is list of atoms or codes + YAP_STRING_CHARS = 0x8, /// target is a buffer, with byte-sized units + YAP_STRING_WCHARS = 0x10, /// target is a buffer of wide chars + YAP_STRING_ATOM = 0x20, /// tarfet is an ayom + YAP_STRING_INT = 0x40, /// target is an integer term + YAP_STRING_FLOAT = 0x80, /// target is a floar term + YAP_STRING_BIG = 0x100, /// target is an big num term + YAP_STRING_DATUM = 0x200, /// associated with previous 3, use actual object if type, not tern + YAP_STRING_LENGTH = 0x400, /// input: length is fixed; output: return integer with length YAP_STRING_NTH = 0x800, /// input: ignored; output: nth char YAP_STRING_TERM = 0x1000, // Generic term, if nothing else given YAP_STRING_DIFF = 0x2000, // difference list @@ -349,7 +208,8 @@ typedef enum { YAP_STRING_UPCASE = 0x100000, // output on malloced buffer YAP_STRING_DOWNCASE = 0x200000, // output on malloced buffer YAP_STRING_IN_TMP = 0x400000, // temporary space has been allocated - YAP_STRING_OUTPUT_TERM = 0x800000 // when we're not sure + YAP_STRING_OUTPUT_TERM = 0x800000, // when we're not sure + YAP_STRING_PREFER_LIST = 0x1000000 // when we're not sure } enum_seq_type_t; typedef UInt seq_type_t; @@ -419,8 +279,33 @@ static inline seq_type_t mod_to_type(Term mod USES_REGS) { } // string type depends on current module -static inline seq_type_t mod_to_bqtype(Term mod USES_REGS) { +static inline seq_type_t mod_to_atype(Term mod USES_REGS) { + // see pl-incl.h + unsigned int flags = Yap_GetModuleEntry(mod)->flags; + if (flags & SNGQ_ATOM) { + return YAP_STRING_ATOM | YAP_STRING_OUTPUT_TERM; + } else if (flags & SNGQ_STRING) { + return YAP_STRING_STRING; + } else if (flags & SNGQ_CHARS) { + return YAP_STRING_ATOMS; + } + return YAP_STRING_CODES; +} + +// string type depends on current module +static inline seq_type_t mod_to_bqtype(Term mod USES_REGS) { + Term t2; + if ((t2 = GLOBAL_Flags[BACK_QUOTES_FLAG].at)) { + if (t2 == TermString) { + return YAP_STRING_STRING; + } else if (t2 == TermAtom) { + return YAP_STRING_ATOM | YAP_STRING_OUTPUT_TERM; + } else if (t2 == TermCodes) { + return YAP_STRING_CODES; + } + return YAP_STRING_ATOMS; + } // see pl-incl.h unsigned int flags = Yap_GetModuleEntry(mod)->flags; if (flags & BCKQ_ATOM) { @@ -433,15 +318,39 @@ static inline seq_type_t mod_to_bqtype(Term mod USES_REGS) { return YAP_STRING_CODES; } +static inline seq_type_t Yap_TextType(Term t) { + if (IsVarTerm(t = Deref(t))) { + Yap_ThrowError(INSTANTIATION_ERROR, t, "expected text"); + } + if (IsAtomTerm(t)) { + return YAP_STRING_ATOM; + } + if (IsStringTerm(t)) { + return YAP_STRING_STRING; + } + if (IsPairTerm(t)) { + Term hd = HeadOfTerm(t); + if (IsVarTerm(hd)) { + Yap_ThrowError(INSTANTIATION_ERROR, t, "expected text"); + } + if (IsIntegerTerm(hd)) { + return YAP_STRING_CODES; + } + if (IsAtomTerm(hd)) { + return YAP_STRING_ATOMS; + } + } + Yap_ThrowError(TYPE_ERROR_TEXT, t, "expected text"); +} + // the routines -extern unsigned char *Yap_readText(seq_tv_t *inp, size_t *lengp USES_REGS); -extern bool write_Text(unsigned char *inp, seq_tv_t *out, - size_t leng USES_REGS); +extern unsigned char *Yap_readText(seq_tv_t *inp USES_REGS); +extern bool write_Text(unsigned char *inp, seq_tv_t *out USES_REGS); extern bool Yap_CVT_Text(seq_tv_t *inp, seq_tv_t *out USES_REGS); extern bool Yap_Concat_Text(int n, seq_tv_t inp[], seq_tv_t *out USES_REGS); extern bool Yap_Splice_Text(int n, size_t cuts[], seq_tv_t *inp, - seq_tv_t outv[] USES_REGS); + seq_tv_t outv[] USES_REGS); // user friendly interface @@ -449,8 +358,8 @@ static inline Atom Yap_AtomicToLowAtom(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS | - YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | - YAP_STRING_BIG | YAP_STRING_TERM; + YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | + YAP_STRING_BIG | YAP_STRING_TERM; out.type = YAP_STRING_ATOM | YAP_STRING_DOWNCASE; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; @@ -461,8 +370,8 @@ static inline Atom Yap_AtomicToUpAtom(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS | - YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | - YAP_STRING_BIG | YAP_STRING_TERM; + YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | + YAP_STRING_BIG | YAP_STRING_TERM; out.type = YAP_STRING_ATOM | YAP_STRING_UPCASE; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; @@ -473,8 +382,8 @@ static inline Term Yap_AtomicToLowString(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS | - YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | - YAP_STRING_BIG | YAP_STRING_TERM; + YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | + YAP_STRING_BIG | YAP_STRING_TERM; out.type = YAP_STRING_STRING | YAP_STRING_DOWNCASE; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; @@ -485,8 +394,8 @@ static inline Term Yap_AtomicToUpString(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS | - YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | - YAP_STRING_BIG | YAP_STRING_TERM; + YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | + YAP_STRING_BIG | YAP_STRING_TERM; out.type = YAP_STRING_STRING | YAP_STRING_UPCASE; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; @@ -497,8 +406,8 @@ static inline Term Yap_AtomicToLowListOfCodes(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS | - YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | - YAP_STRING_BIG | YAP_STRING_TERM; + YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | + YAP_STRING_BIG | YAP_STRING_TERM; out.type = YAP_STRING_CODES | YAP_STRING_DOWNCASE; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; @@ -509,8 +418,8 @@ static inline Term Yap_AtomicToUpListOfCodes(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS | - YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | - YAP_STRING_BIG | YAP_STRING_TERM; + YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | + YAP_STRING_BIG | YAP_STRING_TERM; out.type = YAP_STRING_CODES | YAP_STRING_UPCASE; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; @@ -521,8 +430,8 @@ static inline Term Yap_AtomicToLowListOfAtoms(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS | - YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | - YAP_STRING_BIG | YAP_STRING_TERM; + YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | + YAP_STRING_BIG | YAP_STRING_TERM; out.type = YAP_STRING_ATOMS | YAP_STRING_DOWNCASE; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; @@ -533,31 +442,31 @@ static inline Term Yap_AtomicToUpListOfAtoms(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS | - YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | - YAP_STRING_BIG | YAP_STRING_TERM; + YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | + YAP_STRING_BIG | YAP_STRING_TERM; out.type = YAP_STRING_ATOMS | YAP_STRING_UPCASE; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; return out.val.t; } -static inline size_t Yap_AtomicToLength(Term t0 USES_REGS) { +static inline size_t Yap_AtomicToUnicodeLength(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS | - YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | - YAP_STRING_BIG | YAP_STRING_TERM; - out.type = YAP_STRING_LENGTH; + YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | + YAP_STRING_BIG | YAP_STRING_TERM; + out.type = YAP_STRING_CHARS | YAP_STRING_OUTPUT_TERM; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; - return out.val.t; + return strlen_utf8(out.val.uc0); } static inline Term Yap_AtomicToListOfAtoms(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | - YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; out.type = YAP_STRING_ATOMS; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; @@ -568,7 +477,7 @@ static inline Term Yap_AtomicToListOfCodes(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | - YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; + YAP_STRING_FLOAT | YAP_STRING_BIG ; out.val.uc = NULL; out.type = YAP_STRING_CODES; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) @@ -580,7 +489,7 @@ static inline Atom Yap_AtomicToAtom(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | - YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; out.val.uc = NULL; out.type = YAP_STRING_ATOM; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) @@ -589,14 +498,17 @@ static inline Atom Yap_AtomicToAtom(Term t0 USES_REGS) { } static inline size_t Yap_AtomToLength(Term t0 USES_REGS) { - seq_tv_t inp, out; - inp.val.t = t0; - inp.type = YAP_STRING_ATOM; - out.val.uc = NULL; - out.type = YAP_STRING_LENGTH; - if (!Yap_CVT_Text(&inp, &out PASS_REGS)) - return (size_t)(-1L); - return out.val.l; + if (!IsAtomTerm(t0)) { + return -TYPE_ERROR_ATOM; + } + return strlen(RepAtom(AtomOfTerm(t0))->StrOfAE); +} + +static inline size_t Yap_AtomToUnicodeLength(Term t0 USES_REGS) { + if (!IsAtomTerm(t0)) { + return -TYPE_ERROR_ATOM; + } + return strlen_utf8(RepAtom(AtomOfTerm(t0))->UStrOfAE); } static inline Term Yap_AtomToListOfAtoms(Term t0 USES_REGS) { @@ -615,8 +527,7 @@ static inline Term Yap_AtomSWIToListOfAtoms(Term t0 USES_REGS) { inp.val.t = t0; inp.type = YAP_STRING_ATOM | YAP_STRING_STRING | YAP_STRING_INT | - YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_ATOMS_CODES | - YAP_STRING_TERM; + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_ATOMS_CODES; out.val.uc = NULL; out.type = YAP_STRING_ATOMS; @@ -636,11 +547,28 @@ static inline Term Yap_AtomToListOfCodes(Term t0 USES_REGS) { return out.val.t; } +static inline Term Yap_AtomSWIToListOfCodes(Term t0 USES_REGS) { + seq_tv_t inp, out; + + inp.val.t = t0; + inp.type = YAP_STRING_ATOM | YAP_STRING_STRING | YAP_STRING_INT | + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_ATOMS_CODES | YAP_STRING_ATOMS_CODES | YAP_STRING_ATOMS_CODES | + YAP_STRING_TERM ; + out.val.uc = NULL; + out.type = YAP_STRING_CODES; + + if (!Yap_CVT_Text(&inp, &out PASS_REGS)) + return 0L; + return out.val.t; +} + + static inline Term Yap_AtomToNumber(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_ATOM; out.val.uc = NULL; + out.enc = ENC_ISO_UTF8; out.type = YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; @@ -665,9 +593,10 @@ static inline Term Yap_AtomSWIToString(Term t0 USES_REGS) { inp.val.t = t0; inp.type = YAP_STRING_ATOM | YAP_STRING_STRING | YAP_STRING_INT | - YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_ATOMS_CODES; + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_ATOMS_CODES ; out.val.uc = NULL; out.type = YAP_STRING_STRING; + out.enc = ENC_ISO_UTF8; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; @@ -679,7 +608,7 @@ static inline Term Yap_AtomicToString(Term t0 USES_REGS) { inp.val.t = t0; inp.type = YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | - YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; out.val.uc = NULL; out.type = YAP_STRING_STRING; @@ -693,9 +622,10 @@ static inline Term Yap_AtomicToTDQ(Term t0, Term mod USES_REGS) { inp.val.t = t0; inp.type = YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | - YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; out.val.uc = NULL; out.type = mod_to_type(mod PASS_REGS); + out.enc = ENC_ISO_UTF8; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; @@ -718,7 +648,7 @@ static inline Term Yap_AtomicToTBQ(Term t0, Term mod USES_REGS) { inp.val.t = t0; inp.type = YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | - YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; out.val.uc = NULL; out.type = mod_to_bqtype(mod PASS_REGS); @@ -735,13 +665,14 @@ static inline Atom Yap_CharsToAtom(const char *s, encoding_t enc USES_REGS) { inp.type = YAP_STRING_CHARS; out.val.uc = NULL; out.type = YAP_STRING_ATOM; + out.enc = ENC_ISO_UTF8; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; return out.val.a; } static inline Term Yap_CharsToListOfAtoms(const char *s, - encoding_t enc USES_REGS) { + encoding_t enc USES_REGS) { seq_tv_t inp, out; inp.val.c0 = s; @@ -755,7 +686,7 @@ static inline Term Yap_CharsToListOfAtoms(const char *s, } static inline Term Yap_CharsToListOfCodes(const char *s, - encoding_t enc USES_REGS) { + encoding_t enc USES_REGS) { seq_tv_t inp, out; inp.val.c0 = s; @@ -793,7 +724,7 @@ static inline Atom Yap_UTF8ToAtom(const unsigned char *s USES_REGS) { } static inline Term Yap_CharsToDiffListOfCodes(const char *s, Term tail, - encoding_t enc USES_REGS) { + encoding_t enc USES_REGS) { seq_tv_t inp, out; inp.val.c0 = s; @@ -808,7 +739,7 @@ static inline Term Yap_CharsToDiffListOfCodes(const char *s, Term tail, } static inline Term Yap_UTF8ToDiffListOfCodes(const char *s, - Term tail USES_REGS) { + Term tail USES_REGS) { seq_tv_t inp, out; inp.val.c0 = s; @@ -823,7 +754,7 @@ static inline Term Yap_UTF8ToDiffListOfCodes(const char *s, } static inline Term Yap_WCharsToDiffListOfCodes(const wchar_t *s, - Term tail USES_REGS) { + Term tail USES_REGS) { seq_tv_t inp, out; inp.val.w0 = s; @@ -850,28 +781,27 @@ static inline Term Yap_CharsToString(const char *s, encoding_t enc USES_REGS) { return out.val.t; } -static inline char *Yap_AtomToUTF8Text(Atom at, const char *s USES_REGS) { +static inline char *Yap_AtomToUTF8Text(Atom at USES_REGS) { + return RepAtom(at)->StrOfAE; +} + +static inline Term Yap_CharsToTAQ(const char *s, Term mod, + encoding_t enc USES_REGS) { seq_tv_t inp, out; - inp.val.a = at; - inp.type = YAP_STRING_ATOM; - out.type = YAP_STRING_CHARS; + inp.val.c0 = s; + inp.type = YAP_STRING_CHARS; + inp.mod = mod; + inp.enc = enc; + out.type = mod_to_atype(mod PASS_REGS); out.val.uc = NULL; - out.enc = ENC_ISO_UTF8; - if (s) { - out.val.c0 = s; - out.type |= YAP_STRING_WITH_BUFFER; - } else { - out.type |= YAP_STRING_MALLOC; - out.val.c = NULL; - } if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; - return out.val.c; + return out.val.t; } static inline Term Yap_CharsToTDQ(const char *s, Term mod, - encoding_t enc USES_REGS) { + encoding_t enc USES_REGS) { seq_tv_t inp, out; inp.val.c0 = s; @@ -886,7 +816,7 @@ static inline Term Yap_CharsToTDQ(const char *s, Term mod, } static inline Term Yap_CharsToTBQ(const char *s, Term mod, - encoding_t enc USES_REGS) { + encoding_t enc USES_REGS) { seq_tv_t inp, out; inp.val.c0 = s; @@ -906,6 +836,7 @@ static inline Atom Yap_ListOfAtomsToAtom(Term t0 USES_REGS) { inp.type = YAP_STRING_ATOMS; out.type = YAP_STRING_ATOM; out.val.uc = NULL; + out.enc = ENC_ISO_UTF8; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return (Atom)NULL; return out.val.a; @@ -916,8 +847,9 @@ static inline Term Yap_ListOfAtomsToNumber(Term t0 USES_REGS) { inp.val.t = t0; inp.type = YAP_STRING_ATOMS; out.type = - YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; + YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; out.val.uc = NULL; + out.enc = ENC_ISO_UTF8; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; return out.val.t; @@ -929,6 +861,7 @@ static inline Term Yap_ListOfAtomsToString(Term t0 USES_REGS) { inp.type = YAP_STRING_ATOMS; out.type = YAP_STRING_STRING; out.val.uc = NULL; + out.enc = ENC_ISO_UTF8; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; return out.val.t; @@ -940,6 +873,7 @@ static inline Atom Yap_ListOfCodesToAtom(Term t0 USES_REGS) { inp.type = YAP_STRING_CODES; out.type = YAP_STRING_ATOM; out.val.uc = NULL; + out.enc = ENC_ISO_UTF8; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return (Atom)NULL; return out.val.a; @@ -950,6 +884,7 @@ static inline Term Yap_ListOfCodesToNumber(Term t0 USES_REGS) { inp.val.t = t0; inp.type = YAP_STRING_CODES; out.type = YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG; + out.enc = ENC_ISO_UTF8; out.val.uc = NULL; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; @@ -958,10 +893,12 @@ static inline Term Yap_ListOfCodesToNumber(Term t0 USES_REGS) { static inline Term Yap_ListOfCodesToString(Term t0 USES_REGS) { seq_tv_t inp, out; + inp.val.t = t0; inp.type = YAP_STRING_CODES; out.val.uc = NULL; out.type = YAP_STRING_STRING; + out.enc = ENC_ISO_UTF8; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; return out.val.t; @@ -973,6 +910,7 @@ static inline Atom Yap_ListToAtom(Term t0 USES_REGS) { inp.type = YAP_STRING_ATOMS_CODES; out.val.uc = NULL; out.type = YAP_STRING_ATOM; + out.enc = ENC_ISO_UTF8; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; return out.val.a; @@ -983,8 +921,9 @@ static inline Term Yap_ListToAtomic(Term t0 USES_REGS) { inp.val.t = t0; inp.type = YAP_STRING_STRING | YAP_STRING_ATOMS_CODES | YAP_STRING_TERM; out.val.uc = NULL; + out.enc = ENC_ISO_UTF8; out.type = YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | - YAP_STRING_BIG | YAP_STRING_OUTPUT_TERM; + YAP_STRING_BIG | YAP_STRING_OUTPUT_TERM; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; return out.val.t; @@ -996,6 +935,7 @@ static inline Term Yap_ListToNumber(Term t0 USES_REGS) { inp.val.t = t0; inp.type = YAP_STRING_STRING | YAP_STRING_ATOMS_CODES; out.val.uc = NULL; + out.enc = ENC_ISO_UTF8; out.type = YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) @@ -1010,6 +950,7 @@ static inline Term Yap_ListToString(Term t0 USES_REGS) { inp.type = YAP_STRING_STRING | YAP_STRING_ATOMS_CODES | YAP_STRING_TERM; out.val.uc = NULL; out.type = YAP_STRING_STRING; + out.enc = ENC_ISO_UTF8; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; @@ -1021,10 +962,11 @@ static inline Term Yap_ListSWIToString(Term t0 USES_REGS) { inp.val.t = t0; inp.type = YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_ATOMS_CODES | - YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG | - YAP_STRING_OUTPUT_TERM; + YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG | + YAP_STRING_OUTPUT_TERM | YAP_STRING_PREFER_LIST; out.val.uc = NULL; out.type = YAP_STRING_STRING; + out.enc = ENC_ISO_UTF8; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; @@ -1038,6 +980,7 @@ static inline Term YapListToTDQ(Term t0, Term mod USES_REGS) { inp.type = YAP_STRING_STRING | YAP_STRING_ATOMS_CODES | YAP_STRING_TERM; out.val.uc = NULL; out.type = mod_to_type(mod PASS_REGS); + out.enc = ENC_ISO_UTF8; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; @@ -1051,6 +994,7 @@ static inline Term YapListToTBQ(Term t0, Term mod USES_REGS) { inp.type = YAP_STRING_STRING | YAP_STRING_ATOMS_CODES | YAP_STRING_TERM; out.val.uc = NULL; out.type = mod_to_bqtype(mod PASS_REGS); + out.enc = ENC_ISO_UTF8; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; @@ -1058,12 +1002,13 @@ static inline Term YapListToTBQ(Term t0, Term mod USES_REGS) { } static inline Atom Yap_NCharsToAtom(const char *s, size_t len, - encoding_t enc USES_REGS) { + encoding_t enc USES_REGS) { seq_tv_t inp, out; inp.val.c0 = s; inp.type = YAP_STRING_CHARS | YAP_STRING_NCHARS; inp.enc = enc; + out.enc = ENC_ISO_UTF8; out.type = YAP_STRING_ATOM; out.val.uc = NULL; out.max = len; @@ -1073,7 +1018,7 @@ static inline Atom Yap_NCharsToAtom(const char *s, size_t len, } static inline Term Yap_CharsToDiffListOfAtoms(const char *s, encoding_t enc, - Term tail USES_REGS) { + Term tail USES_REGS) { seq_tv_t inp, out; inp.val.c0 = s; @@ -1087,7 +1032,7 @@ static inline Term Yap_CharsToDiffListOfAtoms(const char *s, encoding_t enc, } static inline Term Yap_NCharsToListOfCodes(const char *s, size_t len, - encoding_t enc USES_REGS) { + encoding_t enc USES_REGS) { seq_tv_t inp, out; inp.val.c0 = s; @@ -1101,7 +1046,7 @@ static inline Term Yap_NCharsToListOfCodes(const char *s, size_t len, } static inline Term Yap_NCharsToString(const char *s, size_t len, - encoding_t enc USES_REGS) { + encoding_t enc USES_REGS) { seq_tv_t inp, out; inp.val.c0 = s; @@ -1115,7 +1060,7 @@ static inline Term Yap_NCharsToString(const char *s, size_t len, } static inline Term Yap_NCharsToTDQ(const char *s, size_t len, encoding_t enc, - Term mod USES_REGS) { + Term mod USES_REGS) { seq_tv_t inp, out; inp.val.c0 = s; @@ -1130,7 +1075,7 @@ static inline Term Yap_NCharsToTDQ(const char *s, size_t len, encoding_t enc, } static inline Term Yap_NCharsToTBQ(const char *s, size_t len, encoding_t enc, - Term mod USES_REGS) { + Term mod USES_REGS) { seq_tv_t inp, out; inp.val.c0 = s; @@ -1148,7 +1093,7 @@ static inline Atom Yap_NumberToAtom(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = - YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; + YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; out.type = YAP_STRING_ATOM; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; @@ -1159,7 +1104,7 @@ static inline Term Yap_NumberToListOfAtoms(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = - YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; + YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; out.type = YAP_STRING_ATOMS; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; @@ -1170,7 +1115,7 @@ static inline Term Yap_NumberToListOfCodes(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = - YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; + YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; out.type = YAP_STRING_CODES; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; @@ -1181,7 +1126,7 @@ static inline Term Yap_NumberToString(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = - YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; + YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; out.type = YAP_STRING_STRING; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; @@ -1201,7 +1146,7 @@ static inline Atom Yap_NWCharsToAtom(const wchar_t *s, size_t len USES_REGS) { } static inline Term Yap_NWCharsToListOfAtoms(const wchar_t *s, - size_t len USES_REGS) { + size_t len USES_REGS) { seq_tv_t inp, out; inp.val.w0 = s; @@ -1214,7 +1159,7 @@ static inline Term Yap_NWCharsToListOfAtoms(const wchar_t *s, } static inline Term Yap_NWCharsToListOfCodes(const wchar_t *s, - size_t len USES_REGS) { + size_t len USES_REGS) { seq_tv_t inp, out; inp.val.w0 = s; @@ -1255,8 +1200,8 @@ static inline Atom Yap_StringSWIToAtom(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | - YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_ATOMS_CODES | - YAP_STRING_TERM; + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_ATOMS_CODES | + YAP_STRING_TERM; out.type = YAP_STRING_ATOM; out.val.uc = NULL; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) @@ -1269,22 +1214,18 @@ static inline size_t Yap_StringToAtomic(Term t0 USES_REGS) { inp.val.t = t0; inp.type = YAP_STRING_STRING; out.type = - YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG; + YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG; out.val.uc = NULL; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; return out.val.t; } -static inline size_t Yap_StringToLength(Term t0 USES_REGS) { - seq_tv_t inp, out; - inp.val.t = t0; - inp.type = YAP_STRING_STRING; - out.type = YAP_STRING_LENGTH; - out.val.uc = NULL; - if (!Yap_CVT_Text(&inp, &out PASS_REGS)) - return (size_t)(-1L); - return out.val.l; +static inline size_t Yap_StringToUnicodeLength(Term t0 USES_REGS) { + if (!IsStringTerm(t0)) { + return -TYPE_ERROR_STRING; + } + return strlen_utf8(UStringOfTerm(t0)); } static inline size_t Yap_StringToListOfAtoms(Term t0 USES_REGS) { @@ -1302,8 +1243,8 @@ static inline size_t Yap_StringSWIToListOfAtoms(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | - YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_ATOMS_CODES | - YAP_STRING_TERM; + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_ATOMS_CODES | + YAP_STRING_TERM; out.type = YAP_STRING_ATOMS; out.val.uc = NULL; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) @@ -1326,8 +1267,8 @@ static inline size_t Yap_StringSWIToListOfCodes(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | - YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_ATOMS_CODES | - YAP_STRING_TERM; + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_ATOMS_CODES | + YAP_STRING_TERM; out.type = YAP_STRING_CODES; out.val.uc = NULL; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) @@ -1340,8 +1281,9 @@ static inline Term Yap_StringToNumber(Term t0 USES_REGS) { inp.val.t = t0; inp.type = YAP_STRING_STRING; out.type = - YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; + YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; out.val.uc = NULL; + out.enc = ENC_ISO_UTF8; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; return out.val.t; @@ -1352,7 +1294,7 @@ static inline Atom Yap_TextToAtom(Term t0 USES_REGS) { inp.val.t = t0; inp.type = YAP_STRING_ATOM | YAP_STRING_STRING | YAP_STRING_CODES | - YAP_STRING_ATOMS_CODES; + YAP_STRING_ATOMS_CODES; out.val.uc = NULL; out.type = YAP_STRING_ATOM; @@ -1366,7 +1308,7 @@ static inline Term Yap_TextToString(Term t0 USES_REGS) { inp.val.t = t0; inp.type = YAP_STRING_ATOM | YAP_STRING_STRING | YAP_STRING_CODES | - YAP_STRING_ATOMS_CODES; + YAP_STRING_ATOMS_CODES; out.val.uc = NULL; out.type = YAP_STRING_STRING; @@ -1386,7 +1328,24 @@ static inline void Yap_OverwriteUTF8BufferToLowCase(void *buf USES_REGS) { } } -static inline const unsigned char *Yap_TextToUTF8Buffer(Term t0 USES_REGS) { +/** + * Function to convert a generic text term (string, atom, list of codes, list + of< + atoms) into a buff + er. + * + * @param t the term + * @param buf the buffer, if NULL a buffer is malloced, and the user should + reclai it + * @param len buffer size + * @param enc encoding (UTF-8 is strongly recommended) + * + * @return the buffer, or NULL in case of failure. If so, Yap_Error may be + called. + * + * notice that it must be called from a push memory. +*/ +static inline const char *Yap_TextTermToText(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; @@ -1397,7 +1356,22 @@ static inline const unsigned char *Yap_TextToUTF8Buffer(Term t0 USES_REGS) { out.enc = ENC_ISO_UTF8; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) - return 0L; + return NULL; + return out.val.c0; +} + +static inline const unsigned char *Yap_TextToUTF8Buffer(Term t0 USES_REGS) { + seq_tv_t inp, out; + + inp.val.t = t0; + inp.type = YAP_STRING_ATOM | YAP_STRING_STRING | YAP_STRING_CODES | + YAP_STRING_ATOMS_CODES; + out.val.uc = NULL; + out.type = YAP_STRING_CHARS | YAP_STRING_MALLOC; + out.enc = ENC_ISO_UTF8; + + if (!Yap_CVT_Text(&inp, &out PASS_REGS)) + return NULL; return out.val.uc0; } @@ -1412,8 +1386,10 @@ static inline Atom UTF32ToAtom(const wchar_t *s USES_REGS) { inp.type = YAP_STRING_WCHARS; out.type = YAP_STRING_ATOM; out.max = -1; - if (!Yap_CVT_Text(&inp, &out PASS_REGS)) - return 0L; + if (!Yap_CVT_Text(&inp, &out PASS_REGS)) { + LOCAL_Error_TYPE = (LOCAL_Error_TYPE == TYPE_ERROR_TEXT ? TYPE_ERROR_ATOM : LOCAL_Error_TYPE ); + return NULL; + } return out.val.a; } @@ -1461,21 +1437,25 @@ static inline Term Yap_WCharsToString(const wchar_t *s USES_REGS) { inp.type = YAP_STRING_WCHARS; out.type = YAP_STRING_STRING; out.val.uc = NULL; - if (!Yap_CVT_Text(&inp, &out PASS_REGS)) + if (!Yap_CVT_Text(&inp, &out PASS_REGS)) { + LOCAL_Error_TYPE = (LOCAL_Error_TYPE == TYPE_ERROR_TEXT ? TYPE_ERROR_STRING : LOCAL_Error_TYPE ); return 0L; + } return out.val.t; } static inline Atom Yap_ConcatAtoms(Term t1, Term t2 USES_REGS) { seq_tv_t inpv[2], out; inpv[0].val.t = t1; - inpv[0].type = YAP_STRING_ATOM; + inpv[0].type = YAP_STRING_ATOM | YAP_STRING_TERM; inpv[1].val.t = t2; inpv[1].type = YAP_STRING_ATOM; out.type = YAP_STRING_ATOM; out.val.uc = NULL; - if (!Yap_Concat_Text(2, inpv, &out PASS_REGS)) - return (Atom)NULL; + if (!Yap_Concat_Text(2, inpv, &out PASS_REGS)) { + LOCAL_Error_TYPE = (LOCAL_Error_TYPE == TYPE_ERROR_TEXT ? TYPE_ERROR_ATOM : LOCAL_Error_TYPE ); + return NULL; + } return out.val.a; } @@ -1483,10 +1463,10 @@ static inline Atom Yap_ConcatAtomics(Term t1, Term t2 USES_REGS) { seq_tv_t inpv[2], out; inpv[0].val.t = t1; inpv[0].type = YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | - YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; inpv[1].val.t = t2; inpv[1].type = YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | - YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; out.type = YAP_STRING_ATOM; out.val.uc = NULL; if (!Yap_Concat_Text(2, inpv, &out PASS_REGS)) @@ -1502,13 +1482,15 @@ static inline Term Yap_ConcatStrings(Term t1, Term t2 USES_REGS) { inpv[1].type = YAP_STRING_STRING; out.type = YAP_STRING_STRING; - if (!Yap_Concat_Text(2, inpv, &out PASS_REGS)) + if (!Yap_Concat_Text(2, inpv, &out PASS_REGS)){ + LOCAL_Error_TYPE = (LOCAL_Error_TYPE == TYPE_ERROR_TEXT ? TYPE_ERROR_STRING : LOCAL_Error_TYPE ); return 0L; + } return out.val.t; } static inline Atom Yap_SpliceAtom(Term t1, Atom ats[], size_t cut, - size_t max USES_REGS) { + size_t max USES_REGS) { seq_tv_t outv[2], inp; size_t cuts[2]; cuts[0] = cut; @@ -1517,8 +1499,10 @@ static inline Atom Yap_SpliceAtom(Term t1, Atom ats[], size_t cut, inp.val.t = t1; outv[0].type = YAP_STRING_ATOM; outv[1].type = YAP_STRING_ATOM; - if (!Yap_Splice_Text(2, cuts, &inp, outv PASS_REGS)) - return (Atom)NULL; + if (!Yap_Splice_Text(2, cuts, &inp, outv PASS_REGS)) { + LOCAL_Error_TYPE = (LOCAL_Error_TYPE == TYPE_ERROR_TEXT ? TYPE_ERROR_ATOM : LOCAL_Error_TYPE ); + return NULL; + } ats[0] = outv[0].val.a; ats[1] = outv[1].val.a; return ats[0]; @@ -1532,8 +1516,10 @@ static inline Atom Yap_SubtractHeadAtom(Term t1, Term th USES_REGS) { outv[0].val.t = th; outv[1].type = YAP_STRING_ATOM; outv[1].val.t = 0; - if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, outv PASS_REGS)) - return (Atom)NULL; + if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, outv PASS_REGS)) { + LOCAL_Error_TYPE = (LOCAL_Error_TYPE == TYPE_ERROR_TEXT ? TYPE_ERROR_ATOM : LOCAL_Error_TYPE ); + return NULL; + } return outv[1].val.a; } @@ -1545,13 +1531,15 @@ static inline Atom Yap_SubtractTailAtom(Term t1, Term th USES_REGS) { outv[0].val.t = 0; outv[1].type = YAP_STRING_ATOM; outv[1].val.t = th; - if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, outv PASS_REGS)) - return (Atom)NULL; + if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, outv PASS_REGS)) { + LOCAL_Error_TYPE = (LOCAL_Error_TYPE == TYPE_ERROR_TEXT ? TYPE_ERROR_ATOM : LOCAL_Error_TYPE ); + return 0L; + } return outv[0].val.a; } static inline Term Yap_SpliceString(Term t1, Term ts[], size_t cut, - size_t max USES_REGS) { + size_t max USES_REGS) { seq_tv_t outv[2], inp; size_t cuts[2]; inp.type = YAP_STRING_STRING; @@ -1560,8 +1548,10 @@ static inline Term Yap_SpliceString(Term t1, Term ts[], size_t cut, outv[1].type = YAP_STRING_STRING; cuts[0] = cut; cuts[1] = max; - if (!Yap_Splice_Text(2, cuts, &inp, outv PASS_REGS)) + if (!Yap_Splice_Text(2, cuts, &inp, outv PASS_REGS)){ + LOCAL_Error_TYPE = (LOCAL_Error_TYPE == TYPE_ERROR_TEXT ? TYPE_ERROR_STRING : LOCAL_Error_TYPE ); return 0L; + } ts[0] = outv[0].val.t; ts[1] = outv[1].val.t; return ts[0]; @@ -1575,8 +1565,10 @@ static inline Term Yap_SubtractHeadString(Term t1, Term th USES_REGS) { outv[0].val.t = th; outv[1].type = YAP_STRING_STRING; outv[1].val.t = 0; - if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, outv PASS_REGS)) + if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, outv PASS_REGS)){ + LOCAL_Error_TYPE = (LOCAL_Error_TYPE == TYPE_ERROR_TEXT ? TYPE_ERROR_STRING : LOCAL_Error_TYPE ); return 0L; + } return outv[1].val.t; } @@ -1588,12 +1580,13 @@ static inline Term Yap_SubtractTailString(Term t1, Term th USES_REGS) { outv[0].val.t = 0; outv[1].type = YAP_STRING_STRING; outv[1].val.t = th; - if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, outv PASS_REGS)) + if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, outv PASS_REGS)){ + LOCAL_Error_TYPE = (LOCAL_Error_TYPE == TYPE_ERROR_TEXT ? TYPE_ERROR_STRING : LOCAL_Error_TYPE ); return 0L; + } return outv[0].val.t; } #endif // ≈YAP_TEXT_H -const char *Yap_TextTermToText(Term t, char *buf, size_t len, encoding_t enc); -Term Yap_MkTextTerm(const char *s, encoding_t e, Term tguide); +extern Term Yap_MkTextTerm(const char *s, int guide USES_REGS); diff --git a/H/Yapproto.h b/H/Yapproto.h index 85270a5ef..4b49fe050 100755 --- a/H/Yapproto.h +++ b/H/Yapproto.h @@ -14,6 +14,14 @@ *************************************************************************/ /* prototype file for Yap */ +/// @file Yapproto.h +/// +/// @brief Prototype Declarations + +#ifndef YAP_PROTOS_H +#define YAP_PROTOS_H 1 + +#include "YapDefs.h" /* absmi.c */ extern Int Yap_absmi(int); @@ -27,6 +35,7 @@ extern int Yap_HasOp(Atom); extern struct operator_entry * Yap_GetOpPropForAModuleHavingALock(struct AtomEntryStruct *, Term); extern Atom Yap_LookupAtom(const char *); +extern Atom Yap_AtomInUse(const char *atom); extern Atom Yap_ULookupAtom(const unsigned char *); extern Atom Yap_LookupAtomWithLength(const char *, size_t); extern Atom Yap_FullLookupAtom(const char *); @@ -101,10 +110,11 @@ extern int Yap_IsStringTerm(Term); extern int Yap_IsWideStringTerm(Term); extern Term Yap_RatTermToApplTerm(Term); extern void Yap_InitBigNums(void); -extern Term Yap_AllocExternalDataInStack(CELL, size_t); -extern int Yap_CleanOpaqueVariable(CELL *); +extern Term Yap_AllocExternalDataInStack(CELL, size_t, void *); +extern int Yap_CleanOpaqueVariable(Term t); extern CELL *Yap_HeapStoreOpaqueTerm(Term t); extern size_t Yap_OpaqueTermToString(Term t, char *str, size_t max); +extern Int Yap_blob_tag(Term t); /* c_interface.c */ #ifndef YAP_CPP_INTERFACE @@ -118,6 +128,7 @@ extern X_API Int YAP_RunGoalOnce(Term); /* cdmgr.c */ extern Term Yap_all_calls(void); extern Atom Yap_ConsultingFile(USES_REGS1); +extern bool Yap_Consulting(USES_REGS1); extern struct pred_entry *Yap_PredForChoicePt(choiceptr bptr, op_numbers *op); extern void Yap_InitCdMgr(void); extern struct pred_entry *Yap_PredFromClause(Term t USES_REGS); @@ -170,7 +181,11 @@ extern void Yap_InitDBPreds(void); extern const char *Yap_PrintPredName(struct pred_entry *ap); #endif extern void Yap_RestartYap(int); -extern void Yap_exit(int); +extern void Yap_exit(int) +#ifndef MSC_VER +__attribute__((noreturn)) +#endif +; extern bool Yap_Warning(const char *s, ...); extern bool Yap_PrintWarning(Term t); extern bool Yap_HandleError__(const char *file, const char *function, int lineno, @@ -185,9 +200,9 @@ extern void Yap_InitEval(void); /* exec.c */ extern void Yap_fail_all(choiceptr bb USES_REGS); -extern Term Yap_ExecuteCallMetaCall(Term); +extern Term Yap_ExecuteCallMetaCall(Term,Term); extern void Yap_InitExecFs(void); -extern bool Yap_JumpToEnv(Term); +extern bool Yap_JumpToEnv(void); extern Term Yap_RunTopGoal(Term, bool); extern bool Yap_execute_goal(Term, int, Term, bool); extern bool Yap_exec_absmi(bool, yap_reset_t); @@ -203,7 +218,7 @@ extern bool Yap_Execute(Term t USES_REGS); /* exo.c */ extern void Yap_InitExoPreds(void); extern void Yap_udi_Interval_init(void); -extern bool Yap_Reset(yap_reset_t mode); +extern bool Yap_Reset(yap_reset_t mode, bool hard); /* foreign.c */ extern char *Yap_FindExecutable(void); @@ -230,8 +245,9 @@ extern void Yap_InitGlobals(void); extern Term Yap_SaveTerm(Term); extern Term Yap_SetGlobalVal(Atom, Term); extern Term Yap_GetGlobal(Atom); -extern Int Yap_DeleteGlobal(Atom); +extern Int Yap_DeleteGlobal(Atom); extern void Yap_AllocateDefaultArena(Int, Int, int); +extern CELL *Yap_ArenaLimit(Term arena); /* grow.c */ extern Int Yap_total_stack_shift_time(void); @@ -261,7 +277,7 @@ extern int Yap_locked_gcl(UInt, Int, CELL *, yamop *); /* init.c */ extern int Yap_IsOpType(char *); -extern void Yap_InitWorkspace(UInt, UInt, UInt, UInt, UInt, int, int, int); +extern void Yap_InitWorkspace(struct yap_boot_params *, UInt, UInt, UInt, UInt, UInt, int, int, int); extern bool Yap_AddCallToFli(struct pred_entry *pe, CPredicate call); extern bool Yap_AddRetryToFli(struct pred_entry *pe, CPredicate re); extern bool Yap_AddCutToFli(struct pred_entry *pe, CPredicate cut); @@ -275,7 +291,7 @@ extern void Yap_KillStacks(int); #else extern void Yap_KillStacks(int); #endif -extern void Yap_InitYaamRegs(int); +extern void Yap_InitYaamRegs(int, bool full_reset); extern void Yap_ReInitWTime(void); extern int Yap_OpDec(int, char *, Atom, Term); extern void Yap_CloseScratchPad(void); @@ -285,7 +301,9 @@ extern void Yap_InitInlines(void); extern int Yap_eq(Term, Term); /* iopreds.c */ -extern void Yap_InitPlIO(void); +extern bool Yap_IsAbsolutePath(const char *p, bool); +extern Atom Yap_TemporaryFile(const char *prefix, int *fd); +extern void Yap_InitPlIO( struct yap_boot_params *ts ); extern void Yap_InitBackIO(void); extern void Yap_InitIOPreds(void); extern void Yap_DebugPlWrite(Term t); @@ -293,13 +311,11 @@ extern void Yap_DebugPlWriteln(Term t); extern void Yap_DebugErrorPutc(int n); extern void Yap_DebugErrorPuts(const char *s); extern void Yap_DebugWriteIndicator(struct pred_entry *ap); -extern void Yap_PlWriteToStream(Term, int, int); extern void Yap_CloseReadline(void); /* depth_lim.c */ extern bool Yap_InitReadline(Term t); extern void Yap_InitItDeepenPreds(void); extern struct AliasDescS *Yap_InitStandardAliases(void); -extern struct vfs *Yap_InitAssetManager(void); /* load_foreign.c */ extern void Yap_InitLoadForeign(void); @@ -348,16 +364,16 @@ extern void Yap_InitReadUtil(void); /* qly.c */ extern void Yap_InitQLY(void); -extern YAP_file_type_t Yap_Restore(const char *, const char *); +extern YAP_file_type_t Yap_Restore(const char *); extern void Yap_InitQLYR(void); /* range.c */ extern void Yap_InitRange(void); /* save.c */ -extern int Yap_SavedInfo(const char *, const char *, CELL *, CELL *, CELL *); -extern int Yap_SavedStateRestore(char *, char *); -extern FILE *Yap_OpenRestore(const char *, const char *); +extern int Yap_SavedInfo(const char *, CELL *, CELL *, CELL *); +extern int Yap_SavedStateRestore(char *); +extern FILE *Yap_OpenRestore(const char *); extern void Yap_InitSavePreds(void); /* scanner.c */ @@ -376,7 +392,7 @@ extern void Yap_InitSortPreds(void); /* stack.c */ extern void Yap_InitStInfo(void); extern void Yap_dump_stack(void); -extern void Yap_detect_bug_location(yamop *yap_pc, int where_from, int psize); +extern void Yap_output_bug_location(yamop *yap_pc, int where_from, int psize); #if !defined(YAPOR) && !defined(THREADS) extern bool Yap_search_for_static_predicate_in_use(struct pred_entry *, bool); @@ -388,6 +404,10 @@ extern void Yap_InitCPreds(void); extern void Yap_show_statistics(void); extern int Yap_IsOpMaxPrio(Atom); +extern bool Yap_SetInputStream( Term sd ); +extern bool Yap_SetOutputStream( Term sd ); +extern bool Yap_SetErrorStream( Term sd ); + /* sysbits.c */ extern size_t Yap_InitPageSize(void); extern bool Yap_set_fpu_exceptions(Term); @@ -399,14 +419,14 @@ extern int Yap_signal_index(const char *); #ifdef MAC extern void Yap_SetTextFile(char *); #endif +extern const char *Yap_AbsoluteFile(const char *spec, bool expand); #if __ANDROID__ #include -extern AAssetManager *Yap_assetManager; extern void *Yap_openAssetFile(const char *path); extern bool Yap_isAsset(const char *path); #endif -extern const char *Yap_getcwd(const char *, size_t); +extern const char *Yap_getcwd( char *, size_t); extern void Yap_cputime_interval(Int *, Int *); extern void Yap_systime_interval(Int *, Int *); extern void Yap_InitSysbits(int wid); @@ -419,12 +439,12 @@ extern char *Yap_RegistryGetString(char *); extern void Yap_WinError(char *); #endif -extern const char *Yap_AbsoluteFile(const char *spec, char *obuf, bool ok); extern const char *Yap_AbsoluteFileInBuffer(const char *spec, char *outp, size_t sz, bool ok); -extern const char *Yap_findFile(const char *isource, const char *idef, - const char *root, char *result, bool access, - YAP_file_type_t ftype, bool expand_root, bool in_lib); +extern bool Yap_ChDir(const char *path); +bool Yap_isDirectory(const char *FileName); +extern bool Yap_Exists(const char *f); + /* threads.c */ extern void Yap_InitThreadPreds(void); extern void Yap_InitFirstWorkerThreadHandle(void); @@ -474,7 +494,10 @@ extern Int Yap_TermHash(Term, Int, Int, int); extern Int Yap_NumberVars(Term, Int, bool); extern Term Yap_TermVariables(Term t, UInt arity USES_REGS); extern Term Yap_UnNumberTerm(Term, int); -extern Int Yap_SkipList(Term *, Term **); +extern Int Yap_SkipList(Term *, Term **); +extern Term Yap_BreakRational(Term inp, UInt arity, Term *of, Term oi USES_REGS); +extern Term Yap_BreakTerml(Term inp, UInt arity, Term *of, Term oi USES_REGS); + /* yap.c */ /* write.c */ @@ -486,13 +509,17 @@ extern int Yap_get_stream_handle(Term, int, int, void *); extern Term Yap_get_stream_position(void *); extern struct AtomEntryStruct *Yap_lookupBlob(void *blob, size_t len, void *type, int *newp); +extern void *Yap_RepStreamFromId(int sno); /* opt.preds.c */ extern void Yap_init_optyap_preds(void); /* pl-file.c */ // struct PL_local_data *Yap_InitThreadIO(int wid); -extern void Yap_flush(void); +extern void Yap_flush_all(void); + +extern X_API YAP_opaque_tag_t +YAP_NewOpaqueType(struct YAP_opaque_handler_struct *f); /* pl-yap.c */ extern Int Yap_source_line_no(void); @@ -512,3 +539,7 @@ extern void init_myddas(void); #if !HAVE_STRNCPY #define strncpy(X, Y, Z) strcpy(X, Y) #endif + +#endif /* YAP_PROTOS_H */ + +/// @} diff --git a/H/Yatom.h b/H/Yatom.h index d5f5d9018..78b96255b 100755 --- a/H/Yatom.h +++ b/H/Yatom.h @@ -1,147 +1,127 @@ /************************************************************************* -* * -* YAP Prolog %W% %G% -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * -* * -************************************************************************** -* * -* File: YAtom.h.m4 * -* Last rev: 19/2/88 * -* mods: * -* comments: atom properties header file for YAP * -* * -*************************************************************************/ + * * + * YAP Prolog %W% %G% + * * + * Yap Prolog was developed at NCCUP - Universidade do Porto * + * * + * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * + * * + ************************************************************************** + * * + * File: YAtom.h.m4 * + * Last rev: 19/2/88 * + * mods: * + * comments: atom properties header file for YAP * + * * + *************************************************************************/ /* This code can only be defined *after* including Regs.h!!! */ #ifndef YATOM_H #define YATOM_H 1 +INLINE_ONLY Atom AbsAtom(AtomEntry *p); +INLINE_ONLY AtomEntry *RepAtom(Atom a); + #ifdef USE_OFFSETS +INLINE_ONLY Atom AbsAtom(AtomEntry *p) { return (Atom)(Addr(p) - AtomBase); } -INLINE_ONLY inline EXTERN Atom AbsAtom(AtomEntry *p); - -INLINE_ONLY inline EXTERN Atom AbsAtom(AtomEntry *p) { - return (Atom)(Addr(p) - AtomBase); -} - -INLINE_ONLY inline EXTERN AtomEntry *RepAtom(Atom a); - -INLINE_ONLY inline EXTERN AtomEntry *RepAtom(Atom a) { +INLINE_ONLY AtomEntry *RepAtom(Atom a) { return (AtomEntry *) (AtomBase + Unsigned (a); } #else - -INLINE_ONLY inline EXTERN Atom AbsAtom(AtomEntry *p); - -INLINE_ONLY inline EXTERN Atom AbsAtom(AtomEntry *p) { return (Atom)(p); } - -INLINE_ONLY inline EXTERN AtomEntry *RepAtom(Atom a); - -INLINE_ONLY inline EXTERN AtomEntry *RepAtom(Atom a) { - return (AtomEntry *)(a); -} +INLINE_ONLY Atom AbsAtom(AtomEntry *p) { return (Atom)(p); } +INLINE_ONLY AtomEntry *RepAtom(Atom a) { return (AtomEntry *)(a); } #endif #if USE_OFFSETS_IN_PROPS -INLINE_ONLY inline EXTERN Prop AbsProp(PropEntry *p); +INLINE_ONLY Prop AbsProp(PropEntry *p); -INLINE_ONLY inline EXTERN Prop AbsProp(PropEntry *p) { - return (Prop)(Addr(p) - AtomBase); -} +INLINE_ONLY Prop AbsProp(PropEntry *p) { return (Prop)(Addr(p) - AtomBase); } -INLINE_ONLY inline EXTERN PropEntry *RepProp(Prop p); +INLINE_ONLY PropEntry *RepProp(Prop p); -INLINE_ONLY inline EXTERN PropEntry *RepProp(Prop p) { +INLINE_ONLY PropEntry *RepProp(Prop p) { return (PropEntry *)(AtomBase + Unsigned(p)); } #else -INLINE_ONLY inline EXTERN Prop AbsProp(PropEntry *p); +INLINE_ONLY Prop AbsProp(PropEntry *p); -INLINE_ONLY inline EXTERN Prop AbsProp(PropEntry *p) { return (Prop)(p); } +INLINE_ONLY Prop AbsProp(PropEntry *p) { return (Prop)(p); } -INLINE_ONLY inline EXTERN PropEntry *RepProp(Prop p); +INLINE_ONLY PropEntry *RepProp(Prop p); -INLINE_ONLY inline EXTERN PropEntry *RepProp(Prop p) { - return (PropEntry *)(p); -} +INLINE_ONLY PropEntry *RepProp(Prop p) { return (PropEntry *)(p); } #endif #if USE_OFFSETS_IN_PROPS -INLINE_ONLY inline EXTERN FunctorEntry *RepFunctorProp(Prop p); +INLINE_ONLY FunctorEntry *RepFunctorProp(Prop p); -INLINE_ONLY inline EXTERN FunctorEntry *RepFunctorProp(Prop p) { +INLINE_ONLY FunctorEntry *RepFunctorProp(Prop p) { return (FunctorEntry *)(AtomBase + Unsigned(p)); } -INLINE_ONLY inline EXTERN Prop AbsFunctorProp(FunctorEntry *p); +INLINE_ONLY Prop AbsFunctorProp(FunctorEntry *p); -INLINE_ONLY inline EXTERN Prop AbsFunctorProp(FunctorEntry *p) { +INLINE_ONLY Prop AbsFunctorProp(FunctorEntry *p) { return (Prop)(Addr(p) - AtomBase); } #else -INLINE_ONLY inline EXTERN FunctorEntry *RepFunctorProp(Prop p); +INLINE_ONLY FunctorEntry *RepFunctorProp(Prop p); -INLINE_ONLY inline EXTERN FunctorEntry *RepFunctorProp(Prop p) { - return (FunctorEntry *)(p); -} +INLINE_ONLY FunctorEntry *RepFunctorProp(Prop p) { return (FunctorEntry *)(p); } -INLINE_ONLY inline EXTERN Prop AbsFunctorProp(FunctorEntry *p); +INLINE_ONLY Prop AbsFunctorProp(FunctorEntry *p); -INLINE_ONLY inline EXTERN Prop AbsFunctorProp(FunctorEntry *p) { - return (Prop)(p); -} +INLINE_ONLY Prop AbsFunctorProp(FunctorEntry *p) { return (Prop)(p); } #endif -INLINE_ONLY inline EXTERN Int ArityOfFunctor(Functor); +INLINE_ONLY arity_t ArityOfFunctor(Functor); -INLINE_ONLY inline EXTERN Int ArityOfFunctor(Functor Fun) { - return (Int)(((FunctorEntry *)Fun)->ArityOfFE); +INLINE_ONLY arity_t ArityOfFunctor(Functor Fun) { + return (arity_t)(((FunctorEntry *)Fun)->ArityOfFE); } -INLINE_ONLY inline EXTERN Atom NameOfFunctor(Functor); +INLINE_ONLY Atom NameOfFunctor(Functor); -INLINE_ONLY inline EXTERN Atom NameOfFunctor(Functor Fun) { +INLINE_ONLY Atom NameOfFunctor(Functor Fun) { return (Atom)(((FunctorEntry *)Fun)->NameOfFE); } -INLINE_ONLY inline EXTERN PropFlags IsFunctorProperty(int); +INLINE_ONLY PropFlags IsFunctorProperty(int); -INLINE_ONLY inline EXTERN PropFlags IsFunctorProperty(int flags) { +INLINE_ONLY PropFlags IsFunctorProperty(int flags) { return (PropFlags)((flags == FunctorProperty)); } /* summary of property codes used - 00 00 predicate entry - 80 00 db property - bb 00 functor entry - ff df sparse functor - ff ex arithmetic property - ff f4 translation - ff f5 blob - ff f6 hold - ff f7 array - ff f8 wide atom - ff fa module property - ff fb blackboard property - ff fc value property - ff fd global property - ff fe flag property - ff ff op property + 00 00 predicate entry + 80 00 db property + bb 00 functor entry + ff df sparse functor + ff ex arithmetic property + ff f4 translation + ff f5 blob + ff f6 hold + ff f7 array + ff f8 wide atom + ff fa module property + ff fb blackboard property + ff fc value property + ff fd global property + ff fe flag property + ff ff op property */ /* Global Variable property */ @@ -162,39 +142,35 @@ typedef struct global_entry { #if USE_OFFSETS_IN_PROPS -INLINE_ONLY inline EXTERN GlobalEntry *RepGlobalProp(Prop p); +INLINE_ONLY GlobalEntry *RepGlobalProp(Prop p); -INLINE_ONLY inline EXTERN GlobalEntry *RepGlobalProp(Prop p) { +INLINE_ONLY GlobalEntry *RepGlobalProp(Prop p) { return (GlobalEntry *)(AtomBase + Unsigned(p)); } -INLINE_ONLY inline EXTERN Prop AbsGlobalProp(GlobalEntry *p); +INLINE_ONLY Prop AbsGlobalProp(GlobalEntry *p); -INLINE_ONLY inline EXTERN Prop AbsGlobalProp(GlobalEntry *p) { +INLINE_ONLY Prop AbsGlobalProp(GlobalEntry *p) { return (Prop)(Addr(p) - AtomBase); } #else -INLINE_ONLY inline EXTERN GlobalEntry *RepGlobalProp(Prop p); +INLINE_ONLY GlobalEntry *RepGlobalProp(Prop p); -INLINE_ONLY inline EXTERN GlobalEntry *RepGlobalProp(Prop p) { - return (GlobalEntry *)(p); -} +INLINE_ONLY GlobalEntry *RepGlobalProp(Prop p) { return (GlobalEntry *)(p); } -INLINE_ONLY inline EXTERN Prop AbsGlobalProp(GlobalEntry *p); +INLINE_ONLY Prop AbsGlobalProp(GlobalEntry *p); -INLINE_ONLY inline EXTERN Prop AbsGlobalProp(GlobalEntry *p) { - return (Prop)(p); -} +INLINE_ONLY Prop AbsGlobalProp(GlobalEntry *p) { return (Prop)(p); } #endif #define GlobalProperty ((PropFlags)0xfffd) -INLINE_ONLY inline EXTERN PropFlags IsGlobalProperty(int); +INLINE_ONLY PropFlags IsGlobalProperty(int); -INLINE_ONLY inline EXTERN PropFlags IsGlobalProperty(int flags) { +INLINE_ONLY PropFlags IsGlobalProperty(int flags) { return (PropFlags)((flags == GlobalProperty)); } @@ -219,29 +195,25 @@ typedef struct mod_entry { #if USE_OFFSETS_IN_PROPS -INLINE_ONLY inline EXTERN ModEntry *RepModProp(Prop p); +INLINE_ONLY ModEntry *RepModProp(Prop p); -INLINE_ONLY inline EXTERN ModEntry *RepModProp(Prop p) { +INLINE_ONLY ModEntry *RepModProp(Prop p) { return (ModEntry *)(AtomBase + Unsigned(p)); } -INLINE_ONLY inline EXTERN Prop AbsModProp(ModEntry *p); +INLINE_ONLY Prop AbsModProp(ModEntry *p); -INLINE_ONLY inline EXTERN Prop AbsModProp(ModEntry *p) { - return (Prop)(Addr(p) - AtomBase); -} +INLINE_ONLY Prop AbsModProp(ModEntry *p) { return (Prop)(Addr(p) - AtomBase); } #else -INLINE_ONLY inline EXTERN ModEntry *RepModProp(Prop p); +INLINE_ONLY ModEntry *RepModProp(Prop p); -INLINE_ONLY inline EXTERN ModEntry *RepModProp(Prop p) { - return (ModEntry *)(p); -} +INLINE_ONLY ModEntry *RepModProp(Prop p) { return (ModEntry *)(p); } -INLINE_ONLY inline EXTERN Prop AbsModProp(ModEntry *p); +INLINE_ONLY Prop AbsModProp(ModEntry *p); -INLINE_ONLY inline EXTERN Prop AbsModProp(ModEntry *p) { return (Prop)(p); } +INLINE_ONLY Prop AbsModProp(ModEntry *p) { return (Prop)(p); } #define ModToTerm(m) (m == PROLOG_MODULE ? TermProlog : m) @@ -249,11 +221,9 @@ INLINE_ONLY inline EXTERN Prop AbsModProp(ModEntry *p) { return (Prop)(p); } #define ModProperty ((PropFlags)0xfffa) -INLINE_ONLY inline EXTERN bool IsModProperty(int); +INLINE_ONLY bool IsModProperty(int); -INLINE_ONLY inline EXTERN bool IsModProperty(int flags) { - return flags == ModProperty; -} +INLINE_ONLY bool IsModProperty(int flags) { return flags == ModProperty; } /* Flags on module. Most of these flags are copied to the read context in pl-read.c. @@ -279,6 +249,11 @@ INLINE_ONLY inline EXTERN bool IsModProperty(int flags) { #define UNKNOWN_MASK \ (UNKNOWN_ERROR | UNKNOWN_WARNING | UNKNOWN_FAIL | UNKNOWN_FAST_FAIL | \ UNKNOWN_ABORT | UNKNOWN_HALT) +#define SNGQ_CHARS (0x10000) /* 'ab' --> [a, b] */ +#define SNGQ_ATOM (0x20000) /* 'ab' --> ab */ +#define SNGQ_STRING (0x40000) /* 'ab' --> "ab" */ +#define SNGQ_CODES (0x80000) /* 'ab' --> [0'a, 0'b] */ +#define SNGQ_MASK (BCKQ_CHARS | BCKQ_ATOM | BCKQ_STRING | BCKQ_CODES) Term Yap_getUnknownModule(ModEntry *m); void Yap_setModuleFlags(ModEntry *n, ModEntry *o); @@ -298,36 +273,32 @@ typedef struct operator_entry { } OpEntry; #if USE_OFFSETS_IN_PROPS -INLINE_ONLY inline EXTERN OpEntry *RepOpProp(Prop p); +INLINE_ONLY OpEntry *RepOpProp(Prop p); -INLINE_ONLY inline EXTERN OpEntry *RepOpProp(Prop p) { +INLINE_ONLY OpEntry *RepOpProp(Prop p) { return (OpEntry *)(AtomBase + Unsigned(p)); } -INLINE_ONLY inline EXTERN Prop AbsOpProp(OpEntry *p); +INLINE_ONLY Prop AbsOpProp(OpEntry *p); -INLINE_ONLY inline EXTERN Prop AbsOpProp(OpEntry *p) { - return (Prop)(Addr(p) - AtomBase); -} +INLINE_ONLY Prop AbsOpProp(OpEntry *p) { return (Prop)(Addr(p) - AtomBase); } #else -INLINE_ONLY inline EXTERN OpEntry *RepOpProp(Prop p); +INLINE_ONLY OpEntry *RepOpProp(Prop p); -INLINE_ONLY inline EXTERN OpEntry *RepOpProp(Prop p) { return (OpEntry *)(p); } +INLINE_ONLY OpEntry *RepOpProp(Prop p) { return (OpEntry *)(p); } -INLINE_ONLY inline EXTERN Prop AbsOpProp(OpEntry *p); +INLINE_ONLY Prop AbsOpProp(OpEntry *p); -INLINE_ONLY inline EXTERN Prop AbsOpProp(OpEntry *p) { return (Prop)(p); } +INLINE_ONLY Prop AbsOpProp(OpEntry *p) { return (Prop)(p); } #endif #define OpProperty ((PropFlags)0xffff) -INLINE_ONLY inline EXTERN bool IsOpProperty(PropFlags); +INLINE_ONLY bool IsOpProperty(PropFlags); -INLINE_ONLY inline EXTERN bool IsOpProperty(PropFlags flags) { - return flags == OpProperty; -} +INLINE_ONLY bool IsOpProperty(PropFlags flags) { return flags == OpProperty; } typedef enum { INFIX_OP = 0, POSFIX_OP = 1, PREFIX_OP = 2 } op_type; @@ -358,38 +329,34 @@ typedef struct { } ExpEntry; #if USE_OFFSETS_IN_PROPS -INLINE_ONLY inline EXTERN ExpEntry *RepExpProp(Prop p); +INLINE_ONLY ExpEntry *RepExpProp(Prop p); -INLINE_ONLY inline EXTERN ExpEntry *RepExpProp(Prop p) { +INLINE_ONLY ExpEntry *RepExpProp(Prop p) { return (ExpEntry *)(AtomBase + Unsigned(p)); } -INLINE_ONLY inline EXTERN Prop AbsExpProp(ExpEntry *p); +INLINE_ONLY Prop AbsExpProp(ExpEntry *p); -INLINE_ONLY inline EXTERN Prop AbsExpProp(ExpEntry *p) { - return (Prop)(Addr(p) - AtomBase); -} +INLINE_ONLY Prop AbsExpProp(ExpEntry *p) { return (Prop)(Addr(p) - AtomBase); } #else -INLINE_ONLY inline EXTERN ExpEntry *RepExpProp(Prop p); +INLINE_ONLY ExpEntry *RepExpProp(Prop p); -INLINE_ONLY inline EXTERN ExpEntry *RepExpProp(Prop p) { - return (ExpEntry *)(p); -} +INLINE_ONLY ExpEntry *RepExpProp(Prop p) { return (ExpEntry *)(p); } -INLINE_ONLY inline EXTERN Prop AbsExpProp(ExpEntry *p); +INLINE_ONLY Prop AbsExpProp(ExpEntry *p); -INLINE_ONLY inline EXTERN Prop AbsExpProp(ExpEntry *p) { return (Prop)(p); } +INLINE_ONLY Prop AbsExpProp(ExpEntry *p) { return (Prop)(p); } #endif #define ExpProperty 0xffe0 /* only unary and binary expressions are acceptable */ -INLINE_ONLY inline EXTERN PropFlags IsExpProperty(int); +INLINE_ONLY PropFlags IsExpProperty(int); -INLINE_ONLY inline EXTERN PropFlags IsExpProperty(int flags) { +INLINE_ONLY PropFlags IsExpProperty(int flags) { return (PropFlags)((flags == ExpProperty)); } @@ -404,29 +371,25 @@ typedef struct { } ValEntry; #if USE_OFFSETS_IN_PROPS -INLINE_ONLY inline EXTERN ValEntry *RepValProp(Prop p); +INLINE_ONLY ValEntry *RepValProp(Prop p); -INLINE_ONLY inline EXTERN ValEntry *RepValProp(Prop p) { +INLINE_ONLY ValEntry *RepValProp(Prop p) { return (ValEntry *)(AtomBase + Unsigned(p)); } -INLINE_ONLY inline EXTERN Prop AbsValProp(ValEntry *p); +INLINE_ONLY Prop AbsValProp(ValEntry *p); -INLINE_ONLY inline EXTERN Prop AbsValProp(ValEntry *p) { - return (Prop)(Addr(p) - AtomBase); -} +INLINE_ONLY Prop AbsValProp(ValEntry *p) { return (Prop)(Addr(p) - AtomBase); } #else -INLINE_ONLY inline EXTERN ValEntry *RepValProp(Prop p); +INLINE_ONLY ValEntry *RepValProp(Prop p); -INLINE_ONLY inline EXTERN ValEntry *RepValProp(Prop p) { - return (ValEntry *)(p); -} +INLINE_ONLY ValEntry *RepValProp(Prop p) { return (ValEntry *)(p); } -INLINE_ONLY inline EXTERN Prop AbsValProp(ValEntry *p); +INLINE_ONLY Prop AbsValProp(ValEntry *p); -INLINE_ONLY inline EXTERN Prop AbsValProp(ValEntry *p) { return (Prop)(p); } +INLINE_ONLY Prop AbsValProp(ValEntry *p) { return (Prop)(p); } #endif #define ValProperty ((PropFlags)0xfffc) @@ -441,73 +404,67 @@ INLINE_ONLY inline EXTERN Prop AbsValProp(ValEntry *p) { return (Prop)(p); } don't forget to also add in qly.h */ +/// Different predicate flags typedef uint64_t pred_flags_t; - -#define ProfiledPredFlag \ - ((pred_flags_t)0x2000000000) /* pred is being profiled */ +#define UndefPredFlag \ + ((pred_flags_t)0x4000000000) //< Predicate not explicitely defined. +#define ProfiledPredFlag ((pred_flags_t)0x2000000000) //< pred is being profiled #define DiscontiguousPredFlag \ - ((pred_flags_t)0x1000000000) /* predicates whose clauses may be all-over \ - the place.. */ -#define SysExportPredFlag ((pred_flags_t)0x800000000) -/* reuse export list to prolog module. */ + ((pred_flags_t)0x1000000000) //< predicates whose clauses may be all-over the + // place.. +#define SysExportPredFlag \ + ((pred_flags_t)0x800000000) //< reuse export list to prolog module. #define NoTracePredFlag \ - ((pred_flags_t)0x400000000) /* cannot trace this predicate */ -#define NoSpyPredFlag \ - ((pred_flags_t)0x200000000) /* cannot spy this predicate */ + ((pred_flags_t)0x400000000) //< cannot trace this predicate +#define NoSpyPredFlag ((pred_flags_t)0x200000000) //< cannot spy this predicate #define QuasiQuotationPredFlag \ - ((pred_flags_t)0x100000000) /* SWI-like quasi quotations */ + ((pred_flags_t)0x100000000) //< SWI-like quasi quotations #define MegaClausePredFlag \ - ((pred_flags_t)0x80000000) /* predicate is implemented as a mega-clause */ -#define ThreadLocalPredFlag ((pred_flags_t)0x40000000) /* local to a thread */ -#define MultiFileFlag ((pred_flags_t)0x20000000) /* is multi-file */ -#define UserCPredFlag \ - ((pred_flags_t)0x10000000) /* CPred defined by the user \ - */ + ((pred_flags_t)0x80000000) //< predicate is implemented as a mega-clause +#define ThreadLocalPredFlag ((pred_flags_t)0x40000000) //< local to a thread +#define MultiFileFlag ((pred_flags_t)0x20000000) //< is multi-file +#define UserCPredFlag ((pred_flags_t)0x10000000) //< CPred defined by the user #define LogUpdatePredFlag \ - ((pred_flags_t)0x08000000) /* dynamic predicate with log. upd. sem. */ -#define InUsePredFlag ((pred_flags_t)0x04000000) /* count calls to pred */ -#define CountPredFlag ((pred_flags_t)0x02000000) /* count calls to pred */ -#define HiddenPredFlag ((pred_flags_t)0x01000000) /* invisible predicate */ -#define CArgsPredFlag \ - ((pred_flags_t)0x00800000) /* SWI-like C-interface pred. */ + ((pred_flags_t)0x08000000) //< dynamic predicate with log. upd. sem. +#define InUsePredFlag ((pred_flags_t)0x04000000) //< count calls to pred +#define CountPredFlag ((pred_flags_t)0x02000000) //< count calls to pred +#define HiddenPredFlag ((pred_flags_t)0x01000000) //< invisible predicate +#define CArgsPredFlag ((pred_flags_t)0x00800000) //< SWI-like C-interface pred. #define SourcePredFlag \ - ((pred_flags_t)0x00400000) /* static predicate with source declaration */ + ((pred_flags_t)0x00400000) //< static predicate with source declaration #define MetaPredFlag \ - ((pred_flags_t)0x00200000) /* predicate subject to a meta declaration */ + ((pred_flags_t)0x00200000) //< predicate subject to a meta declaration #define SyncPredFlag \ - ((pred_flags_t)0x00100000) /* has to synch before it can execute */ -#define NumberDBPredFlag \ - ((pred_flags_t)0x00080000) /* entry for an atom key \ - */ -#define AtomDBPredFlag ((pred_flags_t)0x00040000) /* entry for a number key */ + ((pred_flags_t)0x00100000) //< has to synch before it can execute +#define NumberDBPredFlag ((pred_flags_t)0x00080000) //< entry for an atom key +#define AtomDBPredFlag ((pred_flags_t)0x00040000) //< entry for a number key // #define GoalExPredFlag ((pred_flags_t)0x00020000) /// predicate that is -// called by goal_expand */ -#define TestPredFlag ((pred_flags_t)0x00010000) /* is a test (optim. comit) */ -#define AsmPredFlag ((pred_flags_t)0x00008000) /* inline */ -#define StandardPredFlag ((pred_flags_t)0x00004000) /* system predicate */ -#define DynamicPredFlag ((pred_flags_t)0x00002000) /* dynamic predicate */ -#define CPredFlag ((pred_flags_t)0x00001000) /* written in C */ -#define SafePredFlag ((pred_flags_t)0x00000800) /* does not alter arguments */ -#define CompiledPredFlag ((pred_flags_t)0x00000400) /* is static */ -#define IndexedPredFlag ((pred_flags_t)0x00000200) /* has indexing code */ -#define SpiedPredFlag ((pred_flags_t)0x00000100) /* is a spy point */ -#define BinaryPredFlag ((pred_flags_t)0x00000080) /* test predicate */ -#define TabledPredFlag ((pred_flags_t)0x00000040) /* is tabled */ +// called by goal_expand +#define TestPredFlag ((pred_flags_t)0x00010000) //< is a test (optim. comit) +#define AsmPredFlag ((pred_flags_t)0x00008000) //< inline +#define StandardPredFlag ((pred_flags_t)0x00004000) //< system predicate +#define DynamicPredFlag ((pred_flags_t)0x00002000) //< dynamic predicate +#define CPredFlag ((pred_flags_t)0x00001000) //< written in C +#define SafePredFlag ((pred_flags_t)0x00000800) //< does not alter arguments +#define CompiledPredFlag ((pred_flags_t)0x00000400) //< is static +#define IndexedPredFlag ((pred_flags_t)0x00000200) //< has indexing code +#define SpiedPredFlag ((pred_flags_t)0x00000100) //< is a spy point +#define BinaryPredFlag ((pred_flags_t)0x00000080) //< test predicate +#define TabledPredFlag ((pred_flags_t)0x00000040) //< is tabled #define SequentialPredFlag \ - ((pred_flags_t)0x00000020) /* may not create parallel choice points! */ -#define BackCPredFlag \ - ((pred_flags_t)0x00000008) /* Myddas Imported pred \ - */ -#define ModuleTransparentPredFlag \ - ((pred_flags_t)0x00000004) /* ModuleTransparent pred */ -#define SWIEnvPredFlag ((pred_flags_t)0x00000002) /* new SWI interface */ -#define UDIPredFlag ((pred_flags_t)0x00000001) /* User Defined Indexing */ + ((pred_flags_t)0x00000020) //< may not create parallel choice points! +#define BackCPredFlag ((pred_flags_t)0x00000008) //< Myddas Imported pred +#define ModuleTransparentPredFlag ((pred_flags_t)0x00000004) +#define SWIEnvPredFlag ((pred_flags_t)0x00000002) //< new SWI interface +#define UDIPredFlag ((pred_flags_t)0x00000001) //< User Defined Indexing #define SystemPredFlags \ (AsmPredFlag | StandardPredFlag | CPredFlag | BinaryPredFlag | BackCPredFlag) #define ForeignPredFlags \ (AsmPredFlag | SWIEnvPredFlag | CPredFlag | BinaryPredFlag | UDIPredFlag | \ CArgsPredFlag | UserCPredFlag | SafePredFlag | BackCPredFlag) +#define LivePredFlags \ + (LogUpdatePredFlag | MultiFileFlag | TabledPredFlag | ForeignPredFlags) #define StatePredFlags \ (InUsePredFlag | CountPredFlag | SpiedPredFlag | IndexedPredFlag) @@ -516,6 +473,7 @@ typedef uint64_t pred_flags_t; #define is_foreign(pe) (pe->PredFlags & ForeignPredFlags) #define is_static(pe) (pe->PredFlags & CompiledPredFlag) #define is_logupd(pe) (pe->PredFlags & LogUpdatePredFlag) +#define is_live(pe) (pe->PredFlags & LivePredFlags) #ifdef TABLING #define is_tabled(pe) (pe->PredFlags & TabledPredFlag) #endif /* TABLING */ @@ -582,42 +540,39 @@ typedef struct pred_entry { #if USE_OFFSETS_IN_PROPS -INLINE_ONLY inline EXTERN PredEntry *RepPredProp(Prop p); +INLINE_ONLY PredEntry *RepPredProp(Prop p); -INLINE_ONLY inline EXTERN PredEntry *RepPredProp(Prop p) { +INLINE_ONLY PredEntry *RepPredProp(Prop p) { return (PredEntry *)(AtomBase + Unsigned(p)); } -INLINE_ONLY inline EXTERN Prop AbsPredProp(PredEntry *p); +INLINE_ONLY Prop AbsPredProp(PredEntry *p); -INLINE_ONLY inline EXTERN Prop AbsPredProp(PredEntry *p) { +INLINE_ONLY Prop AbsPredProp(PredEntry *p) { return (Prop)(Addr(p) - AtomBase); } #else -INLINE_ONLY inline EXTERN PredEntry *RepPredProp(Prop p); +INLINE_ONLY PredEntry *RepPredProp(Prop p); -INLINE_ONLY inline EXTERN PredEntry *RepPredProp(Prop p) { +INLINE_ONLY PredEntry *RepPredProp(Prop p) { return (PredEntry *)(p); } - return (PredEntry *)(p); -} +INLINE_ONLY Prop AbsPredProp(PredEntry *p); -INLINE_ONLY inline EXTERN Prop AbsPredProp(PredEntry *p); - -INLINE_ONLY inline EXTERN Prop AbsPredProp(PredEntry *p) { return (Prop)(p); } +INLINE_ONLY Prop AbsPredProp(PredEntry *p) { return (Prop)(p); } #endif -INLINE_ONLY inline EXTERN PropFlags IsPredProperty(int); +INLINE_ONLY PropFlags IsPredProperty(int); -INLINE_ONLY inline EXTERN PropFlags IsPredProperty(int flags) { +INLINE_ONLY PropFlags IsPredProperty(int flags) { return (PropFlags)((flags == PEProp)); } -INLINE_ONLY inline EXTERN Atom NameOfPred(PredEntry *pe); +INLINE_ONLY Atom NameOfPred(PredEntry *pe); -INLINE_ONLY inline EXTERN Atom NameOfPred(PredEntry *pe) { +INLINE_ONLY Atom NameOfPred(PredEntry *pe) { if (pe->ModuleOfPred == IDB_MODULE) { return NULL; } else if (pe->ArityOfPE == 0) { @@ -692,9 +647,9 @@ typedef struct DB_TERM { Term Contents[MIN_ARRAY]; /* stored term */ } DBTerm; -INLINE_ONLY inline EXTERN DBTerm *TermToDBTerm(Term); +INLINE_ONLY DBTerm *TermToDBTerm(Term); -INLINE_ONLY inline EXTERN DBTerm *TermToDBTerm(Term X) { +INLINE_ONLY DBTerm *TermToDBTerm(Term X) { if (IsPairTerm(X)) { return (DBTerm *)((unsigned char *)RepPair(X) - (CELL) & (((DBTerm *)NULL)->Contents)); @@ -747,35 +702,31 @@ typedef DBStruct *DBRef; /* extern Functor FunctorDBRef; */ -INLINE_ONLY inline EXTERN int IsDBRefTerm(Term); +INLINE_ONLY int IsDBRefTerm(Term); -INLINE_ONLY inline EXTERN int IsDBRefTerm(Term t) { +INLINE_ONLY int IsDBRefTerm(Term t) { return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorDBRef); } -INLINE_ONLY inline EXTERN Term MkDBRefTerm(DBRef); +INLINE_ONLY Term MkDBRefTerm(DBRef); -INLINE_ONLY inline EXTERN Term MkDBRefTerm(DBRef p) { +INLINE_ONLY Term MkDBRefTerm(DBRef p) { return (Term)((AbsAppl(((CELL *)(p))))); } -INLINE_ONLY inline EXTERN DBRef DBRefOfTerm(Term t); +INLINE_ONLY DBRef DBRefOfTerm(Term t); -INLINE_ONLY inline EXTERN DBRef DBRefOfTerm(Term t) { - return (DBRef)(((DBRef)(RepAppl(t)))); -} +INLINE_ONLY DBRef DBRefOfTerm(Term t) { return (DBRef)(((DBRef)(RepAppl(t)))); } -INLINE_ONLY inline EXTERN int IsRefTerm(Term); +INLINE_ONLY int IsRefTerm(Term); -INLINE_ONLY inline EXTERN int IsRefTerm(Term t) { +INLINE_ONLY int IsRefTerm(Term t) { return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorDBRef); } -INLINE_ONLY inline EXTERN CODEADDR RefOfTerm(Term t); +INLINE_ONLY CODEADDR RefOfTerm(Term t); -INLINE_ONLY inline EXTERN CODEADDR RefOfTerm(Term t) { - return (CODEADDR)(DBRefOfTerm(t)); -} +INLINE_ONLY CODEADDR RefOfTerm(Term t) { return (CODEADDR)(DBRefOfTerm(t)); } typedef struct struct_dbentry { Prop NextOfPE; /* used to chain properties */ @@ -812,35 +763,33 @@ typedef LogUpdDBEntry *LogUpdDBProp; #define CodeDBProperty (DBProperty | CodeDBBit) -INLINE_ONLY inline EXTERN PropFlags IsDBProperty(int); +INLINE_ONLY PropFlags IsDBProperty(int); -INLINE_ONLY inline EXTERN PropFlags IsDBProperty(int flags) { +INLINE_ONLY PropFlags IsDBProperty(int flags) { return (PropFlags)((flags & ~CodeDBBit) == DBProperty); } #if USE_OFFSETS_IN_PROPS -INLINE_ONLY inline EXTERN DBProp RepDBProp(Prop p); +INLINE_ONLY DBProp RepDBProp(Prop p); -INLINE_ONLY inline EXTERN DBProp RepDBProp(Prop p) { +INLINE_ONLY DBProp RepDBProp(Prop p) { return (DBProp)(AtomBase + Unsigned(p)); } -INLINE_ONLY inline EXTERN Prop AbsDBProp(DBProp p); +INLINE_ONLY Prop AbsDBProp(DBProp p); -INLINE_ONLY inline EXTERN Prop AbsDBProp(DBProp p) { - return (Prop)(Addr(p) - AtomBase); -} +INLINE_ONLY Prop AbsDBProp(DBProp p) { return (Prop)(Addr(p) - AtomBase); } #else -INLINE_ONLY inline EXTERN DBProp RepDBProp(Prop p); +INLINE_ONLY DBProp RepDBProp(Prop p); -INLINE_ONLY inline EXTERN DBProp RepDBProp(Prop p) { return (DBProp)(p); } +INLINE_ONLY DBProp RepDBProp(Prop p) { return (DBProp)(p); } -INLINE_ONLY inline EXTERN Prop AbsDBProp(DBProp p); +INLINE_ONLY Prop AbsDBProp(DBProp p); -INLINE_ONLY inline EXTERN Prop AbsDBProp(DBProp p) { return (Prop)(p); } +INLINE_ONLY Prop AbsDBProp(DBProp p) { return (Prop)(p); } #endif @@ -869,39 +818,37 @@ typedef BlackBoardEntry *BBProp; #if USE_OFFSETS_IN_PROPS -INLINE_ONLY inline EXTERN BlackBoardEntry *RepBBProp(Prop p); +INLINE_ONLY BlackBoardEntry *RepBBProp(Prop p); -INLINE_ONLY inline EXTERN BlackBoardEntry *RepBBProp(Prop p) { +INLINE_ONLY BlackBoardEntry *RepBBProp(Prop p) { return (BlackBoardEntry *)(AtomBase + Unsigned(p)); } -INLINE_ONLY inline EXTERN Prop AbsBBProp(BlackBoardEntry *p); +INLINE_ONLY Prop AbsBBProp(BlackBoardEntry *p); -INLINE_ONLY inline EXTERN Prop AbsBBProp(BlackBoardEntry *p) { +INLINE_ONLY Prop AbsBBProp(BlackBoardEntry *p) { return (Prop)(Addr(p) - AtomBase); } #else -INLINE_ONLY inline EXTERN BlackBoardEntry *RepBBProp(Prop p); +INLINE_ONLY BlackBoardEntry *RepBBProp(Prop p); -INLINE_ONLY inline EXTERN BlackBoardEntry *RepBBProp(Prop p) { +INLINE_ONLY BlackBoardEntry *RepBBProp(Prop p) { return (BlackBoardEntry *)(p); } -INLINE_ONLY inline EXTERN Prop AbsBBProp(BlackBoardEntry *p); +INLINE_ONLY Prop AbsBBProp(BlackBoardEntry *p); -INLINE_ONLY inline EXTERN Prop AbsBBProp(BlackBoardEntry *p) { - return (Prop)(p); -} +INLINE_ONLY Prop AbsBBProp(BlackBoardEntry *p) { return (Prop)(p); } #endif #define BBProperty ((PropFlags)0xfffb) -INLINE_ONLY inline EXTERN PropFlags IsBBProperty(int); +INLINE_ONLY PropFlags IsBBProperty(int); -INLINE_ONLY inline EXTERN PropFlags IsBBProperty(int flags) { +INLINE_ONLY PropFlags IsBBProperty(int flags) { return (PropFlags)((flags == BBProperty)); } @@ -914,29 +861,27 @@ typedef struct hold_entry { #if USE_OFFSETS_IN_PROPS -INLINE_ONLY inline EXTERN HoldEntry *RepHoldProp(Prop p); +INLINE_ONLY HoldEntry *RepHoldProp(Prop p); -INLINE_ONLY inline EXTERN HoldEntry *RepHoldProp(Prop p) { +INLINE_ONLY HoldEntry *RepHoldProp(Prop p) { return (HoldEntry *)(AtomBase + Unsigned(p)); } -INLINE_ONLY inline EXTERN Prop AbsHoldProp(HoldEntry *p); +INLINE_ONLY Prop AbsHoldProp(HoldEntry *p); -INLINE_ONLY inline EXTERN Prop AbsHoldProp(HoldEntry *p) { +INLINE_ONLY Prop AbsHoldProp(HoldEntry *p) { return (Prop)(Addr(p) - AtomBase); } #else -INLINE_ONLY inline EXTERN HoldEntry *RepHoldProp(Prop p); +INLINE_ONLY HoldEntry *RepHoldProp(Prop p); -INLINE_ONLY inline EXTERN HoldEntry *RepHoldProp(Prop p) { - return (HoldEntry *)(p); -} +INLINE_ONLY HoldEntry *RepHoldProp(Prop p) { return (HoldEntry *)(p); } -INLINE_ONLY inline EXTERN Prop AbsHoldProp(HoldEntry *p); +INLINE_ONLY Prop AbsHoldProp(HoldEntry *p); -INLINE_ONLY inline EXTERN Prop AbsHoldProp(HoldEntry *p) { return (Prop)(p); } +INLINE_ONLY Prop AbsHoldProp(HoldEntry *p) { return (Prop)(p); } #endif @@ -952,31 +897,29 @@ typedef struct translation_entry { #if USE_OFFSETS_IN_PROPS -INLINE_ONLY inline EXTERN TranslationEntry *RepTranslationProp(Prop p); +INLINE_ONLY TranslationEntry *RepTranslationProp(Prop p); -INLINE_ONLY inline EXTERN TranslationEntry *RepTranslationProp(Prop p) { +INLINE_ONLY TranslationEntry *RepTranslationProp(Prop p) { return (TranslationEntry *)(AtomBase + Unsigned(p)); } -INLINE_ONLY inline EXTERN Prop AbsTranslationProp(TranslationEntry *p); +INLINE_ONLY Prop AbsTranslationProp(TranslationEntry *p); -INLINE_ONLY inline EXTERN Prop AbsTranslationProp(TranslationEntry *p) { +INLINE_ONLY Prop AbsTranslationProp(TranslationEntry *p) { return (Prop)(Addr(p) - AtomBase); } #else -INLINE_ONLY inline EXTERN TranslationEntry *RepTranslationProp(Prop p); +INLINE_ONLY TranslationEntry *RepTranslationProp(Prop p); -INLINE_ONLY inline EXTERN TranslationEntry *RepTranslationProp(Prop p) { +INLINE_ONLY TranslationEntry *RepTranslationProp(Prop p) { return (TranslationEntry *)(p); } -INLINE_ONLY inline EXTERN Prop AbsTranslationProp(TranslationEntry *p); +INLINE_ONLY Prop AbsTranslationProp(TranslationEntry *p); -INLINE_ONLY inline EXTERN Prop AbsTranslationProp(TranslationEntry *p) { - return (Prop)(p); -} +INLINE_ONLY Prop AbsTranslationProp(TranslationEntry *p) { return (Prop)(p); } #endif #define TranslationProperty 0xfff4 @@ -1000,9 +943,9 @@ static inline TranslationEntry *Yap_GetTranslationProp(Atom at, arity_t arity) { return p; } -INLINE_ONLY inline EXTERN bool IsTranslationProperty(PropFlags); +INLINE_ONLY bool IsTranslationProperty(PropFlags); -INLINE_ONLY inline EXTERN bool IsTranslationProperty(PropFlags flags) { +INLINE_ONLY bool IsTranslationProperty(PropFlags flags) { return flags == TranslationProperty; } @@ -1017,29 +960,27 @@ typedef struct mutex_entry { #if USE_OFFSETS_IN_PROPS -INLINE_ONLY inline EXTERN MutexEntry *RepMutexProp(Prop p); +INLINE_ONLY MutexEntry *RepMutexProp(Prop p); -INLINE_ONLY inline EXTERN MutexEntry *RepMutexProp(Prop p) { +INLINE_ONLY MutexEntry *RepMutexProp(Prop p) { return (MutexEntry *)(AtomBase + Unsigned(p)); } -INLINE_ONLY inline EXTERN Prop AbsMutexProp(MutexEntry *p); +INLINE_ONLY Prop AbsMutexProp(MutexEntry *p); -INLINE_ONLY inline EXTERN Prop AbsMutexProp(MutexEntry *p) { +INLINE_ONLY Prop AbsMutexProp(MutexEntry *p) { return (Prop)(Addr(p) - AtomBase); } #else -INLINE_ONLY inline EXTERN MutexEntry *RepMutexProp(Prop p); +INLINE_ONLY MutexEntry *RepMutexProp(Prop p); -INLINE_ONLY inline EXTERN MutexEntry *RepMutexProp(Prop p) { - return (MutexEntry *)(p); -} +INLINE_ONLY MutexEntry *RepMutexProp(Prop p) { return (MutexEntry *)(p); } -INLINE_ONLY inline EXTERN Prop AbsMutexProp(MutexEntry *p); +INLINE_ONLY Prop AbsMutexProp(MutexEntry *p); -INLINE_ONLY inline EXTERN Prop AbsMutexProp(MutexEntry *p) { return (Prop)(p); } +INLINE_ONLY Prop AbsMutexProp(MutexEntry *p) { return (Prop)(p); } #endif #define MutexProperty 0xfff5 @@ -1062,9 +1003,9 @@ static inline void *Yap_GetMutexFromProp(Atom at) { return p->Mutex; } -INLINE_ONLY inline EXTERN bool IsMutexProperty(PropFlags); +INLINE_ONLY bool IsMutexProperty(PropFlags); -INLINE_ONLY inline EXTERN bool IsMutexProperty(PropFlags flags) { +INLINE_ONLY bool IsMutexProperty(PropFlags flags) { return (PropFlags)((flags == MutexProperty)); } @@ -1129,66 +1070,62 @@ typedef struct static_array_entry { #if USE_OFFSETS_IN_PROPS -INLINE_ONLY inline EXTERN ArrayEntry *RepArrayProp(Prop p); +INLINE_ONLY ArrayEntry *RepArrayProp(Prop p); -INLINE_ONLY inline EXTERN ArrayEntry *RepArrayProp(Prop p) { +INLINE_ONLY ArrayEntry *RepArrayProp(Prop p) { return (ArrayEntry *)(AtomBase + Unsigned(p)); } -INLINE_ONLY inline EXTERN Prop AbsArrayProp(ArrayEntry *p); +INLINE_ONLY Prop AbsArrayProp(ArrayEntry *p); -INLINE_ONLY inline EXTERN Prop AbsArrayProp(ArrayEntry *p) { +INLINE_ONLY Prop AbsArrayProp(ArrayEntry *p) { return (Prop)(Addr(p) - AtomBase); } -INLINE_ONLY inline EXTERN StaticArrayEntry *RepStaticArrayProp(Prop p); +INLINE_ONLY StaticArrayEntry *RepStaticArrayProp(Prop p); -INLINE_ONLY inline EXTERN StaticArrayEntry *RepStaticArrayProp(Prop p) { +INLINE_ONLY StaticArrayEntry *RepStaticArrayProp(Prop p) { return (StaticArrayEntry *)(AtomBase + Unsigned(p)); } -INLINE_ONLY inline EXTERN Prop AbsStaticArrayProp(StaticArrayEntry *p); +INLINE_ONLY Prop AbsStaticArrayProp(StaticArrayEntry *p); -INLINE_ONLY inline EXTERN Prop AbsStaticArrayProp(StaticArrayEntry *p) { +INLINE_ONLY Prop AbsStaticArrayProp(StaticArrayEntry *p) { return (Prop)(Addr(p) - AtomBase); } #else -INLINE_ONLY inline EXTERN ArrayEntry *RepArrayProp(Prop p); +INLINE_ONLY ArrayEntry *RepArrayProp(Prop p); -INLINE_ONLY inline EXTERN ArrayEntry *RepArrayProp(Prop p) { - return (ArrayEntry *)(p); -} +INLINE_ONLY ArrayEntry *RepArrayProp(Prop p) { return (ArrayEntry *)(p); } -INLINE_ONLY inline EXTERN Prop AbsArrayProp(ArrayEntry *p); +INLINE_ONLY Prop AbsArrayProp(ArrayEntry *p); -INLINE_ONLY inline EXTERN Prop AbsArrayProp(ArrayEntry *p) { return (Prop)(p); } +INLINE_ONLY Prop AbsArrayProp(ArrayEntry *p) { return (Prop)(p); } -INLINE_ONLY inline EXTERN StaticArrayEntry *RepStaticArrayProp(Prop p); +INLINE_ONLY StaticArrayEntry *RepStaticArrayProp(Prop p); -INLINE_ONLY inline EXTERN StaticArrayEntry *RepStaticArrayProp(Prop p) { +INLINE_ONLY StaticArrayEntry *RepStaticArrayProp(Prop p) { return (StaticArrayEntry *)(p); } -INLINE_ONLY inline EXTERN Prop AbsStaticArrayProp(StaticArrayEntry *p); +INLINE_ONLY Prop AbsStaticArrayProp(StaticArrayEntry *p); -INLINE_ONLY inline EXTERN Prop AbsStaticArrayProp(StaticArrayEntry *p) { - return (Prop)(p); -} +INLINE_ONLY Prop AbsStaticArrayProp(StaticArrayEntry *p) { return (Prop)(p); } #endif #define ArrayProperty ((PropFlags)0xfff7) -INLINE_ONLY inline EXTERN bool ArrayIsDynamic(ArrayEntry *); +INLINE_ONLY bool ArrayIsDynamic(ArrayEntry *); -INLINE_ONLY inline EXTERN bool ArrayIsDynamic(ArrayEntry *are) { +INLINE_ONLY bool ArrayIsDynamic(ArrayEntry *are) { return ((are)->TypeOfAE & DYNAMIC_ARRAY) != 0; } -INLINE_ONLY inline EXTERN bool IsArrayProperty(PropFlags); +INLINE_ONLY bool IsArrayProperty(PropFlags); -INLINE_ONLY inline EXTERN bool IsArrayProperty(PropFlags flags) { +INLINE_ONLY bool IsArrayProperty(PropFlags flags) { return flags == ArrayProperty; } @@ -1196,59 +1133,55 @@ INLINE_ONLY inline EXTERN bool IsArrayProperty(PropFlags flags) { typedef struct YAP_blob_prop_entry { Prop NextOfPE; /* used to chain properties */ PropFlags KindOfPE; /* kind of property */ - struct YAP_blob_t *blob_type; /* type of blob */ + struct _PL_blob_t *blob_type; /* type of blob */ } YAP_BlobPropEntry; #if USE_OFFSETS_IN_PROPS -INLINE_ONLY inline EXTERN YAP_BlobPropEntry *RepBlobProp(Prop p); +INLINE_ONLY YAP_BlobPropEntry *RepBlobProp(Prop p); -INLINE_ONLY inline EXTERN YAP_BlobPropEntry *RepBlobProp(Prop p) { +INLINE_ONLY YAP_BlobPropEntry *RepBlobProp(Prop p) { return (YAP_BlobPropEntry *)(AtomBase + Unsigned(p)); } -INLINE_ONLY inline EXTERN AtomEntry *AbsBlobProp(BlobPropEntry *p); +INLINE_ONLY AtomEntry *AbsBlobProp(BlobPropEntry *p); -INLINE_ONLY inline EXTERN Prop AbsBlobProp(YAP_BlobPropEntry *p) { +INLINE_ONLY Prop AbsBlobProp(YAP_BlobPropEntry *p) { return (Prop)(Addr(p) - AtomBase); } #else -INLINE_ONLY inline EXTERN YAP_BlobPropEntry *RepBlobProp(Prop p); +INLINE_ONLY YAP_BlobPropEntry *RepBlobProp(Prop p); -INLINE_ONLY inline EXTERN YAP_BlobPropEntry *RepBlobProp(Prop p) { +INLINE_ONLY YAP_BlobPropEntry *RepBlobProp(Prop p) { return (YAP_BlobPropEntry *)(p); } -INLINE_ONLY inline EXTERN Prop AbsBlobProp(YAP_BlobPropEntry *p); +INLINE_ONLY Prop AbsBlobProp(YAP_BlobPropEntry *p); -INLINE_ONLY inline EXTERN Prop AbsBlobProp(YAP_BlobPropEntry *p) { - return (Prop)(p); -} +INLINE_ONLY Prop AbsBlobProp(YAP_BlobPropEntry *p) { return (Prop)(p); } #endif #define BlobProperty ((PropFlags)0xfffe) -INLINE_ONLY inline EXTERN bool IsBlobProperty(PropFlags); +INLINE_ONLY bool IsBlobProperty(PropFlags); -INLINE_ONLY inline EXTERN bool IsBlobProperty(PropFlags flags) { +INLINE_ONLY bool IsBlobProperty(PropFlags flags) { return flags == BlobProperty; } -INLINE_ONLY inline EXTERN bool IsBlob(Atom); +INLINE_ONLY bool IsBlob(Atom); -INLINE_ONLY inline EXTERN bool IsBlob(Atom at) { +INLINE_ONLY bool IsBlob(Atom at) { return RepAtom(at)->PropsOfAE != NIL && IsBlobProperty(RepBlobProp(RepAtom(at)->PropsOfAE)->KindOfPE); } -INLINE_ONLY inline EXTERN bool IsValProperty(PropFlags); +INLINE_ONLY bool IsValProperty(PropFlags); -INLINE_ONLY inline EXTERN bool IsValProperty(PropFlags flags) { - return flags == ValProperty; -} +INLINE_ONLY bool IsValProperty(PropFlags flags) { return flags == ValProperty; } /* flag property entry structure */ @@ -1268,53 +1201,53 @@ typedef struct { } FlagEntry; #if USE_OFFSETS_IN_PROPS -INLINE_ONLY inline EXTERN FlagEntry *RepFlagProp(Prop p); +INLINE_ONLY FlagEntry *RepFlagProp(Prop p); -INLINE_ONLY inline EXTERN FlagEntry *RepFlagProp(Prop p) { +INLINE_ONLY FlagEntry *RepFlagProp(Prop p) { return (FlagEntry *)(AtomBase + Unsigned(p)); } -INLINE_ONLY inline EXTERN Prop AbsFlagProp(FlagEntry *p); +INLINE_ONLY Prop AbsFlagProp(FlagEntry *p); -INLINE_ONLY inline EXTERN Prop AbsValProp(FlagEntry *p) { - return (Prop)(Addr(p) - AtomBase); -} +INLINE_ONLY Prop AbsValProp(FlagEntry *p) { return (Prop)(Addr(p) - AtomBase); } #else -INLINE_ONLY inline EXTERN FlagEntry *RepFlagProp(Prop p); +INLINE_ONLY FlagEntry *RepFlagProp(Prop p); -INLINE_ONLY inline EXTERN FlagEntry *RepFlagProp(Prop p) { - return (FlagEntry *)(p); -} +INLINE_ONLY FlagEntry *RepFlagProp(Prop p) { return (FlagEntry *)(p); } -INLINE_ONLY inline EXTERN Prop AbsFlagProp(FlagEntry *p); +INLINE_ONLY Prop AbsFlagProp(FlagEntry *p); -INLINE_ONLY inline EXTERN Prop AbsFlagProp(FlagEntry *p) { return (Prop)(p); } +INLINE_ONLY Prop AbsFlagProp(FlagEntry *p) { return (Prop)(p); } #endif #define FlagProperty ((PropFlags)0xfff9) -INLINE_ONLY inline EXTERN bool IsFlagProperty(PropFlags); +INLINE_ONLY bool IsFlagProperty(PropFlags); -INLINE_ONLY inline EXTERN bool IsFlagProperty(PropFlags flags) { +INLINE_ONLY bool IsFlagProperty(PropFlags flags) { return flags == FlagProperty; } /* Proto types */ +extern char *Yap_TermToBuffer(Term t, int flags); + +extern Term Yap_BufferToTerm(const char *s, Term opts); + /* cdmgr.c */ -int Yap_RemoveIndexation(PredEntry *); -void Yap_UpdateTimestamps(PredEntry *); +extern int Yap_RemoveIndexation(PredEntry *); +extern void Yap_UpdateTimestamps(PredEntry *); /* dbase.c */ -void Yap_ErDBE(DBRef); -DBTerm *Yap_StoreTermInDB(Term, int); +extern void Yap_ErDBE(DBRef); +extern DBTerm *Yap_StoreTermInDB(Term, int); DBTerm *Yap_StoreTermInDBPlusExtraSpace(Term, UInt, UInt *); -Term Yap_FetchTermFromDB(DBTerm *); -Term Yap_FetchClauseTermFromDB(DBTerm *); -Term Yap_PopTermFromDB(DBTerm *); -void Yap_ReleaseTermFromDB(DBTerm *); +Term Yap_FetchTermFromDB(const void *); +Term Yap_FetchClauseTermFromDB(const void *); +Term Yap_PopTermFromDB(const void *); +void Yap_ReleaseTermFromDB(const void *); /* init.c */ Atom Yap_GetOp(OpEntry *, int *, int); @@ -1335,30 +1268,27 @@ Prop Yap_GetAPropHavingLock(AtomEntry *, PropFlags); *************************************************************************************************/ #include "YapFlags.h" -INLINE_ONLY EXTERN inline UInt PRED_HASH(FunctorEntry *, Term, UInt); -INLINE_ONLY EXTERN inline UInt PRED_HASH(FunctorEntry *fe, Term cur_mod, - UInt size) { +INLINE_ONLY UInt PRED_HASH(FunctorEntry *, Term, UInt); + +INLINE_ONLY UInt PRED_HASH(FunctorEntry *fe, Term cur_mod, UInt size) { return (((CELL)fe + cur_mod) >> 2) % size; } -INLINE_ONLY EXTERN inline Prop GetPredPropByFuncAndModHavingLock(FunctorEntry *, - Term); -INLINE_ONLY EXTERN inline Prop PredPropByFuncAndMod(FunctorEntry *, Term); -INLINE_ONLY EXTERN inline Prop PredPropByAtomAndMod(Atom, Term); -INLINE_ONLY EXTERN inline Prop GetPredPropByFuncHavingLock(FunctorEntry *, - Term); -INLINE_ONLY EXTERN inline Prop PredPropByFunc(Functor fe, Term cur_mod); -INLINE_ONLY EXTERN inline Prop PredPropByAtom(Atom at, Term cur_mod); +INLINE_ONLY Prop GetPredPropByFuncAndModHavingLock(FunctorEntry *, Term); +INLINE_ONLY Prop PredPropByFuncAndMod(FunctorEntry *, Term); +INLINE_ONLY Prop PredPropByAtomAndMod(Atom, Term); +INLINE_ONLY Prop GetPredPropByFuncHavingLock(FunctorEntry *, Term); +INLINE_ONLY Prop PredPropByFunc(Functor fe, Term cur_mod); +INLINE_ONLY Prop PredPropByAtom(Atom at, Term cur_mod); #ifdef THREADS Prop Yap_NewThreadPred(struct pred_entry *CACHE_TYPE); Prop Yap_NewPredPropByFunctor(Functor, Term); -INLINE_ONLY EXTERN inline struct pred_entry * -Yap_GetThreadPred(struct pred_entry *CACHE_TYPE); +INLINE_ONLY struct pred_entry *Yap_GetThreadPred(struct pred_entry *CACHE_TYPE); -INLINE_ONLY EXTERN inline struct pred_entry * +INLINE_ONLY struct pred_entry * Yap_GetThreadPred(struct pred_entry *ap USES_REGS) { Functor f = ap->FunctorOfPred; Term mod = ap->ModuleOfPred; @@ -1374,8 +1304,7 @@ Yap_GetThreadPred(struct pred_entry *ap USES_REGS) { } #endif -INLINE_ONLY EXTERN inline Prop GetPredPropByFuncHavingLock(FunctorEntry *fe, - Term cur_mod) { +INLINE_ONLY Prop GetPredPropByFuncHavingLock(FunctorEntry *fe, Term cur_mod) { PredEntry *p; if (!(p = RepPredProp(fe->PropsOfFE))) { @@ -1414,7 +1343,7 @@ INLINE_ONLY EXTERN inline Prop GetPredPropByFuncHavingLock(FunctorEntry *fe, return NIL; } -INLINE_ONLY EXTERN inline Prop PredPropByFunc(Functor fe, Term cur_mod) +INLINE_ONLY Prop PredPropByFunc(Functor fe, Term cur_mod) /* get predicate entry for ap/arity; create it if neccessary. */ { Prop p0; @@ -1428,14 +1357,14 @@ INLINE_ONLY EXTERN inline Prop PredPropByFunc(Functor fe, Term cur_mod) return Yap_NewPredPropByFunctor(fe, cur_mod); } -INLINE_ONLY EXTERN inline Prop -GetPredPropByFuncAndModHavingLock(FunctorEntry *fe, Term cur_mod) { +INLINE_ONLY Prop GetPredPropByFuncAndModHavingLock(FunctorEntry *fe, + Term cur_mod) { PredEntry *p; if (!(p = RepPredProp(fe->PropsOfFE))) { return NIL; } - if (p->ModuleOfPred == cur_mod) { + if (p->ModuleOfPred == cur_mod || p->ModuleOfPred == 0) { #ifdef THREADS /* Thread Local Predicates */ if (p->PredFlags & ThreadLocalPredFlag) { @@ -1468,7 +1397,7 @@ GetPredPropByFuncAndModHavingLock(FunctorEntry *fe, Term cur_mod) { return NIL; } -INLINE_ONLY EXTERN inline Prop PredPropByFuncAndMod(Functor fe, Term cur_mod) +INLINE_ONLY Prop PredPropByFuncAndMod(Functor fe, Term cur_mod) /* get predicate entry for ap/arity; create it if neccessary. */ { Prop p0; @@ -1482,7 +1411,7 @@ INLINE_ONLY EXTERN inline Prop PredPropByFuncAndMod(Functor fe, Term cur_mod) return Yap_NewPredPropByFunctor(fe, cur_mod); } -INLINE_ONLY EXTERN inline Prop PredPropByAtom(Atom at, Term cur_mod) +INLINE_ONLY Prop PredPropByAtom(Atom at, Term cur_mod) /* get predicate entry for ap/arity; create it if neccessary. */ { Prop p0; @@ -1509,7 +1438,7 @@ INLINE_ONLY EXTERN inline Prop PredPropByAtom(Atom at, Term cur_mod) return Yap_NewPredPropByAtom(ae, cur_mod); } -INLINE_ONLY EXTERN inline Prop PredPropByAtomAndMod(Atom at, Term cur_mod) +INLINE_ONLY Prop PredPropByAtomAndMod(Atom at, Term cur_mod) /* get predicate entry for ap/arity; create it if neccessary. */ { Prop p0; @@ -1519,7 +1448,8 @@ INLINE_ONLY EXTERN inline Prop PredPropByAtomAndMod(Atom at, Term cur_mod) p0 = ae->PropsOfAE; while (p0) { PredEntry *pe = RepPredProp(p0); - if (pe->KindOfPE == PEProp && (pe->ModuleOfPred == cur_mod)) { + if (pe->KindOfPE == PEProp && + (pe->ModuleOfPred == cur_mod || pe->ModuleOfPred == 0)) { #ifdef THREADS /* Thread Local Predicates */ if (pe->PredFlags & ThreadLocalPredFlag) { @@ -1552,18 +1482,18 @@ INLINE_ONLY EXTERN inline Prop PredPropByAtomAndMod(Atom at, Term cur_mod) #define UNLOCKPE(I, Z) #endif -INLINE_ONLY EXTERN inline void AddPropToAtom(AtomEntry *, PropEntry *p); +INLINE_ONLY void AddPropToAtom(AtomEntry *, PropEntry *p); -INLINE_ONLY EXTERN inline void AddPropToAtom(AtomEntry *ae, PropEntry *p) { +INLINE_ONLY void AddPropToAtom(AtomEntry *ae, PropEntry *p) { /* old properties should be always last, and wide atom properties should always be first */ - p->NextOfPE = ae->PropsOfAE; - ae->PropsOfAE = AbsProp(p); + p->NextOfPE = ae->PropsOfAE; + ae->PropsOfAE = AbsProp(p); } // auxiliary functions -INLINE_ONLY inline EXTERN const char *AtomName(Atom at); +INLINE_ONLY const char *AtomName(Atom at); /** * AtomName(Atom at): get a string with the name of an Atom. Assumes 8 bit @@ -1573,11 +1503,9 @@ INLINE_ONLY inline EXTERN const char *AtomName(Atom at); * * @return a ponter to an immutable sequence of characters. */ -INLINE_ONLY inline EXTERN const char *AtomName(Atom at) { - return RepAtom(at)->rep.uStrOfAE; -} +INLINE_ONLY const char *AtomName(Atom at) { return RepAtom(at)->rep.uStrOfAE; } -INLINE_ONLY inline EXTERN const char *AtomTermName(Term t); +INLINE_ONLY const char *AtomTermName(Term t); /** * AtomTermName(Term t): get a string with the name of a term storing an Atom. @@ -1590,26 +1518,31 @@ INLINE_ONLY inline EXTERN const char *AtomTermName(Term t); * * @note: this routine does not support wide chars. */ -INLINE_ONLY inline EXTERN const char *AtomTermName(Term t) { +INLINE_ONLY const char *AtomTermName(Term t) { return RepAtom(AtomOfTerm(t))->rep.uStrOfAE; } -bool Yap_ResetException(int wid); -bool Yap_HasException(void); -Term Yap_GetException(void); -Term Yap_PeekException(void); -bool Yap_PutException(Term t); -INLINE_ONLY inline EXTERN bool Yap_HasException(void) { - return LOCAL_BallTerm != NULL; +extern Term MkErrorTerm(yap_error_descriptor_t *t); + +extern bool Yap_ResetException(yap_error_descriptor_t *i); +extern bool Yap_HasException(void); +extern yap_error_descriptor_t *Yap_GetException(); +extern void Yap_PrintException(yap_error_descriptor_t *i); +INLINE_ONLY bool Yap_HasException(void) { + extern yap_error_number Yap_MathException__(USES_REGS1); + yap_error_number me; + if ((me = Yap_MathException__(PASS_REGS1)) && LOCAL_ActiveError->errorNo != YAP_NO_ERROR) { + LOCAL_ActiveError->errorNo = me; + } + return LOCAL_ActiveError->errorNo != YAP_NO_ERROR; } -INLINE_ONLY inline EXTERN DBTerm *Yap_RefToException(void) { - DBTerm *dbt = LOCAL_BallTerm; - LOCAL_BallTerm = NULL; - return dbt; + +INLINE_ONLY Term MkSysError(yap_error_descriptor_t *i) { + Term et = MkAddressTerm(i); + return Yap_MkApplTerm(FunctorException, 1, &et); } -INLINE_ONLY inline EXTERN void Yap_CopyException(DBTerm *dbt) { - LOCAL_BallTerm = dbt; -} -bool Yap_RaiseException(void); +yap_error_descriptor_t *Yap_UserError(Term t, yap_error_descriptor_t *i); + +extern bool Yap_RaiseException(void); #endif diff --git a/H/absmi.h b/H/absmi.h index deb0c78b6..2a3e9bacf 100755 --- a/H/absmi.h +++ b/H/absmi.h @@ -37,7 +37,7 @@ /* * Machine and compiler dependent definitions */ -#ifdef __GNUC__ +#if 1 //def __GNUC__ #ifdef hppa #define SHADOW_P 1 @@ -51,19 +51,31 @@ #define SHADOW_Y 1 #define SHADOW_REGS 1 #define USE_PREFETCH 1 -#endif -#if defined(_POWER) || defined(__POWERPC__) +#elif defined(_POWER) || defined(__POWERPC__) #define SHADOW_P 1 #define SHADOW_REGS 1 #define USE_PREFETCH 1 +#elif defined(__x86_64__) +#define SHADOW_P 1 +#ifdef BP_FREE +#undef BP_FREE #endif +#undef SHADOW_S +//#define SHADOW_Y 1 +#define S_IN_MEM 1 +#define Y_IN_MEM 1 +#define TR_IN_MEM 1 +#define LIMITED_PREFETCH 1 + +#elif defined(__i386__) +#undef SHADOW_S -#ifdef i386 #define Y_IN_MEM 1 #define S_IN_MEM 1 #define TR_IN_MEM 1 #define HAVE_FEW_REGS 1 #define LIMITED_PREFETCH 1 + #ifdef BP_FREE /*************************************************************** * Use bp as PREG for X86 machines * @@ -86,21 +98,9 @@ register struct yami *P1REG asm("bp"); /* can't use yamop before Yap.h */ #define TR_IN_MEM 1 #endif /* sparc_ */ -#ifdef __x86_64__ -#define SHADOW_P 1 -#ifdef BP_FREE -#undef BP_FREE -#endif -#define SHADOW_S 1 -//#define SHADOW_Y 1 -#define S_IN_MEM 1 -#define Y_IN_MEM 1 -#define TR_IN_MEM 1 -#define LIMITED_PREFETCH 1 -#endif /* __x86_64__ */ #if defined(__arm__) || defined(__thumb__) || defined(mips) || \ - defined(__mips64) || defined(__aarch64__) + defined(__mips64) || defined(__arch64__) #define Y_IN_MEM 1 #define S_IN_MEM 1 @@ -119,9 +119,11 @@ register struct yami *P1REG asm("bp"); /* can't use yamop before Yap.h */ #define SHADOW_S 1 #endif -#ifdef i386 +#if defined(__x86_64__) +#define Y_IN_MEM 1 +#define TR_IN_MEM 1 +#elif defined(i386) #define Y_IN_MEM 1 -#define S_IN_MEM 1 #define TR_IN_MEM 1 #define HAVE_FEW_REGS 1 #endif @@ -173,20 +175,20 @@ register struct yami *P1REG asm("bp"); /* can't use yamop before Yap.h */ /*************************************************************** * Trick to copy REGS into absmi local environment * ***************************************************************/ -INLINE_ONLY inline EXTERN void init_absmi_regs(REGSTORE *absmi_regs); +INLINE_ONLY void init_absmi_regs(REGSTORE *absmi_regs); /* regp is a global variable */ -INLINE_ONLY inline EXTERN void init_absmi_regs(REGSTORE *absmi_regs) { +INLINE_ONLY void init_absmi_regs(REGSTORE *absmi_regs) { CACHE_REGS - memcpy(absmi_regs, Yap_regp, sizeof(REGSTORE)); + memmove(absmi_regs, Yap_regp, sizeof(REGSTORE)); } -INLINE_ONLY inline EXTERN void restore_absmi_regs(REGSTORE *old_regs); +INLINE_ONLY void restore_absmi_regs(REGSTORE *old_regs); -INLINE_ONLY inline EXTERN void restore_absmi_regs(REGSTORE *old_regs) { +INLINE_ONLY void restore_absmi_regs(REGSTORE *old_regs) { CACHE_REGS - memcpy(old_regs, Yap_regp, sizeof(REGSTORE)); + memmove(old_regs, Yap_regp, sizeof(REGSTORE)); #ifdef THREADS pthread_setspecific(Yap_yaamregs_key, (void *)old_regs); LOCAL_ThreadHandle.current_yaam_regs = old_regs; @@ -295,7 +297,7 @@ INLINE_ONLY inline EXTERN void restore_absmi_regs(REGSTORE *old_regs) { { \ YREG = (A) -#define FETCH_Y_FROM_ENV(A) (A) +#define FETCH_Y_FROM_ENV(A) ((YENV) = (A)) #define ENDCACHE_Y_AS_ENV() } @@ -305,30 +307,6 @@ INLINE_ONLY inline EXTERN void restore_absmi_regs(REGSTORE *old_regs) { #endif -#if S_IN_MEM - -#define CACHE_A1() - -#define CACHED_A1() ARG1 - -#else - -#ifndef _NATIVE - -#define CACHE_A1() (SREG = (CELL *)ARG1) - -#define CACHED_A1() ((CELL)SREG) - -#else - -#define CACHE_A1() ((*_SREG) = (CELL *)ARG1) - -#define CACHED_A1() ((CELL)(*_SREG)) - -#endif /* _NATIVE */ - -#endif /* S_IN_MEM */ - /*************************************************************** * TR is usually, but not always, a register. This affects * * backtracking * @@ -359,6 +337,10 @@ INLINE_ONLY inline EXTERN void restore_absmi_regs(REGSTORE *old_regs) { * This affects unification instructions * ***************************************************************/ +#if !SHADOW_S +#define SREG S +#endif + #if S_IN_MEM /* jump through hoops because idiotic gcc will go and read S from @@ -374,11 +356,19 @@ INLINE_ONLY inline EXTERN void restore_absmi_regs(REGSTORE *old_regs) { #define READ_IN_S() S_SREG = SREG +#define CACHE_A1() (SREG = (CELL *)ARG1) + +#define CACHED_A1() ((CELL)SREG) + #else #define READ_IN_S() S_SREG = *_SREG -#endif +#define CACHE_A1() ((*_SREG) = (CELL *)ARG1) + +#define CACHED_A1() ((CELL)(*_SREG)) + + #endif #else @@ -390,6 +380,10 @@ INLINE_ONLY inline EXTERN void restore_absmi_regs(REGSTORE *old_regs) { #define READ_IN_S() +#define CACHE_A1() + +#define CACHED_A1() (ARG1) + #define S_SREG SREG #endif @@ -2457,7 +2451,7 @@ extern yamop *headoftrace; #define Yap_AsmError(e, d) \ { \ saveregs(); \ - Yap_ThrowError(e, d, "while exwcuting inlined built-in"); \ + Yap_ThrowError(e, d, "while executing inlined built-in"); \ setregs(); \ } diff --git a/H/alloc.h b/H/alloc.h index fdfe16776..8022e8240 100644 --- a/H/alloc.h +++ b/H/alloc.h @@ -96,10 +96,11 @@ typedef struct FREEB { /* Operating system and architecture dependent page size */ extern size_t Yap_page_size; -void Yap_InitHeap(void *); -UInt Yap_ExtendWorkSpaceThroughHole(UInt); -void Yap_AllocHole(UInt, UInt); - +extern void Yap_InitHeap(void *); +extern UInt Yap_ExtendWorkSpaceThroughHole(UInt); +extern void Yap_AllocHole(UInt, UInt); +extern size_t Yap_HeapUsed(void); +; #if USE_SYSTEM_MMAP && ! defined(__CYGWIN__) #include @@ -107,7 +108,7 @@ void Yap_AllocHole(UInt, UInt); #elif USE_SYSTEM_SHM - + #elif USE_SBRK @@ -120,10 +121,10 @@ void *sbrk(caddr_t); typedef unsigned size_t; -MALLOC_T malloc(size_t); -void free(MALLOC_T); -MALLOC_T realloc(MALLOC_T,size_t); -MALLOC_T calloc(size_t,size_t); +extern MALLOC_T malloc(size_t); +extern void free(MALLOC_T); +extern MALLOC_T realloc(MALLOC_T,size_t); +extern MALLOC_T calloc(size_t,size_t); #endif diff --git a/H/amidefs.h b/H/amidefs.h index e7ef7e159..02925a56f 100644 --- a/H/amidefs.h +++ b/H/amidefs.h @@ -10,57 +10,12 @@ * * * File: amidefs.h * * comments: Abstract machine peculiarities * - * * - * Last rev: $Date: 2008-07-22 23:34:49 $ * - * $Log: not supported by cvs2svn $ - * Revision 1.33 2007/11/26 23:43:09 vsc - * fixes to support threads and assert correctly, even if inefficiently. - * - * Revision 1.32 2006/10/10 14:08:17 vsc - * small fixes on threaded implementation. - * - * Revision 1.31 2006/09/20 20:03:51 vsc - * improve indexing on floats - * fix sending large lists to DB - * - * Revision 1.30 2005/12/17 03:25:39 vsc - * major changes to support online event-based profiling - * improve error discovery and restart on scanner. - * - * Revision 1.29 2005/07/06 15:10:15 vsc - * improvements to compiler: merged instructions and fixes for -> - * - * Revision 1.28 2005/05/30 06:07:35 vsc - * changes to support more tagging schemes from tabulation. - * - * Revision 1.27 2005/04/10 04:01:13 vsc - * bug fixes, I hope! - * - * Revision 1.26 2004/09/30 21:37:41 vsc - * fixes for thread support - * - * Revision 1.25 2004/09/27 20:45:04 vsc - * Mega clauses - * Fixes to sizeof(expand_clauses) which was being overestimated - * Fixes to profiling+indexing - * Fixes to reallocation of memory after restoring - * Make sure all clauses, even for C, end in _Ystop - * Don't reuse space for Streams - * Fix Stream_F on StreaNo+1 - * - * Revision 1.24 2004/04/14 19:10:40 vsc - * expand_clauses: keep a list of clauses to expand - * fix new trail scheme for multi-assignment variables - * - * Revision 1.23 2004/03/31 01:03:10 vsc - * support expand group of clauses - * - * Revision 1.22 2004/03/10 14:59:55 vsc - * optimise -> for type tests - * * - * * + * * *************************************************************************/ +#ifndef AMIDEFS_H +#define AMIDEFS_H 1 + #ifndef NULL #include #endif @@ -557,11 +512,6 @@ typedef struct yami { struct pred_entry *p; CELL next; } p; - struct { - struct pred_entry *p; - struct pred_entry *p0; - CELL next; - } pp; struct { COUNT s; CELL next; @@ -870,7 +820,7 @@ typedef yamop yamopp; #define PREVOP(V,TYPE) ((yamop *)((CODEADDR)(V)-(CELL)NEXTOP((yamop *)NULL,TYPE))) #if defined(TABLING) || defined(YAPOR_SBA) -typedef struct trail_frame { + typedef struct trail_frame { Term term; CELL value; } *tr_fr_ptr; @@ -1092,3 +1042,5 @@ extern void **Yap_ABSMI_OPCODES; #else #endif + +#endif \ No newline at end of file diff --git a/H/amijit.h b/H/amijit.h index e9244b7c3..39daff70e 100644 --- a/H/amijit.h +++ b/H/amijit.h @@ -95,7 +95,7 @@ typedef enum{ t_createLowerExpectIntrinsicPass, //Removes llvm.expect intrinsics and creates "block_weights" metadata t_createLowerInvokePass, //Converts invoke and unwind instructions to use sjlj exception handling mechanisms t_createLowerSwitchPass, //Converts SwitchInst instructions into a sequence of chained binary branch instructions - t_createMemCpyOptPass, //Performs optimizations related to eliminating memcpy calls and/or combining multiple stores into memset's + t_createMemCpyOptPass, //Performs optimizations related to eliminating memmove calls and/or combining multiple stores into memset's t_createMergeFunctionsPass, //Discovers identical functions and collapses them t_createObjCARCAPElimPass, //ObjC ARC autorelease pool elimination t_createObjCARCContractPass, //Late ObjC ARC cleanups diff --git a/H/amiops.h b/H/amiops.h index 465aab56a..12514a8c9 100644 --- a/H/amiops.h +++ b/H/amiops.h @@ -1,29 +1,31 @@ /************************************************************************* -* * -* YAP Prolog * -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * -* * -************************************************************************** -* * -* File: amiops.h * -* Last rev: * -* mods: * -* comments: Basic abstract machine operations, such as * -* dereferencing, binding, trailing, and unification. * -* * -*************************************************************************/ + * * + * YAP Prolog * + * * + * Yap Prolog was developed at NCCUP - Universidade do Porto * + * * + * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * + * * + ************************************************************************** + * * + * File: amiops.h * + * Last rev: * + * mods: * + * comments: Basic abstract machine operations, such as * + * dereferencing, binding, trailing, and unification. * + * * + *************************************************************************/ #ifdef SCCS -static char SccsId[] = "%W% %G%"; +static char SccsId[] = "%W% %G%"; #endif /* SCCS */ +#ifndef AMIOPS_H +#define AMIOPS_H 1 + #include "inline-only.h" -#define IsArrayReference(a) ((a)->array_access_func == FunctorArrayAccess) - +#define IsArrayReference(a) ((a)->array_access_func == FunctorArrayAccess) /* dereferencing macros */ @@ -36,72 +38,105 @@ Dereferencing macros /* For DEREFD, D has both the input and the exit argument */ /* A is only used locally */ -#define profiled_deref_head_TEST(D,Label) \ - if (IsVarTerm(D)) { \ - if (!strcmp(#D, "d0")) { EMIT_CONDITIONAL_SUCCESS("IsVarTerm(d0)"); } \ - else if (!strcmp(#D, "d1")) { EMIT_CONDITIONAL_SUCCESS("IsVarTerm(d1)"); } \ - goto Label; \ - } \ - if (!strcmp(#D, "d0")) { EMIT_CONDITIONAL_FAIL("IsVarTerm(d0)"); } \ - else if (!strcmp(#D, "d1")) { EMIT_CONDITIONAL_FAIL("IsVarTerm(d1)"); } +#define profiled_deref_head_TEST(D, Label) \ + if (IsVarTerm(D)) { \ + if (!strcmp(#D, "d0")) { \ + EMIT_CONDITIONAL_SUCCESS("IsVarTerm(d0)"); \ + } else if (!strcmp(#D, "d1")) { \ + EMIT_CONDITIONAL_SUCCESS("IsVarTerm(d1)"); \ + } \ + goto Label; \ + } \ + if (!strcmp(#D, "d0")) { \ + EMIT_CONDITIONAL_FAIL("IsVarTerm(d0)"); \ + } else if (!strcmp(#D, "d1")) { \ + EMIT_CONDITIONAL_FAIL("IsVarTerm(d1)"); \ + } -#define deref_head(D,Label) if (IsVarTerm(D)) goto Label +#define deref_head(D, Label) \ + if (IsVarTerm(D)) \ + goto Label -#define profiled_deref_body(D,A,LabelUnk,LabelNonVar) \ - do { \ - if(!IsVarTerm(D)) goto LabelNonVar; \ -LabelUnk: \ - (A) = (CELL *)(D); \ - (D) = *(CELL *)(D); \ - if (!strcmp(#D, "d0") && !strcmp(#A, "pt0")) { EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D0PT0); } \ - else if (!strcmp(#D, "d0") && !strcmp(#A, "pt1")) { EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D0PT1); } \ - else if (!strcmp(#D, "d0") && !strcmp(#A, "S_SREG")) { EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D0S_SREG); } \ - else if (!strcmp(#D, "d1") && !strcmp(#A, "pt0")) { EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D1PT0); } \ - else if (!strcmp(#D, "d1") && !strcmp(#A, "pt1")) { EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D1PT1); } \ -} while (Unsigned(A) != (D)); - - -#define deref_body(D,A,LabelUnk,LabelNonVar) \ - do { \ - if(!IsVarTerm(D)) goto LabelNonVar; \ - LabelUnk: \ - (A) = (CELL *)(D); \ - (D) = *(CELL *)(D); \ - } while (Unsigned(A) != (D)) - -#define do_derefa(D,A,LabelUnk,LabelDone) \ - (D) = *(CELL *)(A); \ - if (IsNonVarTerm(D)) goto LabelDone; \ - goto LabelUnk; \ - do { \ - (A) = (CELL *)(D); \ - (D) = *(CELL *)(D); \ - if(!IsVarTerm(D)) goto LabelDone; \ - LabelUnk: ; \ - } while (Unsigned(A) != (D));\ - LabelDone: - -#define profiled_derefa_body(D,A,LabelUnk,LabelNonVar) \ - do { \ - (A) = (CELL *)(D); \ - (D) = *(CELL *)(D); \ - if (!strcmp(#D, "d0") && !strcmp(#A, "pt0")) { EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D0PT0); } \ - else if (!strcmp(#D, "d0") && !strcmp(#A, "pt1")) { EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D0PT1); } \ - else if (!strcmp(#D, "d0") && !strcmp(#A, "S_SREG")) { EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D0S_SREG); } \ - else if (!strcmp(#D, "d1") && !strcmp(#A, "pt0")) { EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D1PT0); } \ - else if (!strcmp(#D, "d1") && !strcmp(#A, "pt1")) { EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D1PT1); } \ - if(!IsVarTerm(D)) goto LabelNonVar; \ - LabelUnk: ; \ +#define profiled_deref_body(D, A, LabelUnk, LabelNonVar) \ + do { \ + if (!IsVarTerm(D)) \ + goto LabelNonVar; \ + LabelUnk: \ + (A) = (CELL *)(D); \ + (D) = *(CELL *)(D); \ + if (!strcmp(#D, "d0") && !strcmp(#A, "pt0")) { \ + EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D0PT0); \ + } else if (!strcmp(#D, "d0") && !strcmp(#A, "pt1")) { \ + EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D0PT1); \ + } else if (!strcmp(#D, "d0") && !strcmp(#A, "S_SREG")) { \ + EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D0S_SREG); \ + } else if (!strcmp(#D, "d1") && !strcmp(#A, "pt0")) { \ + EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D1PT0); \ + } else if (!strcmp(#D, "d1") && !strcmp(#A, "pt1")) { \ + EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D1PT1); \ + } \ } while (Unsigned(A) != (D)); +#define deref_body(D, A, LabelUnk, LabelNonVar) \ + do { \ + if (!IsVarTerm(D)) \ + goto LabelNonVar; \ + LabelUnk: \ + (A) = (CELL *)(D); \ + (D) = *(CELL *)(D); \ + } while (Unsigned(A) != (D)) -#define derefa_body(D,A,LabelUnk,LabelNonVar) \ - do { \ - (A) = (CELL *)(D); \ - (D) = *(CELL *)(D); \ - if(!IsVarTerm(D)) goto LabelNonVar; \ - LabelUnk: ; \ - } while (Unsigned(A) != (D)) +#define deref_body(D, A, LabelUnk, LabelNonVar) \ + do { \ + if (!IsVarTerm(D)) \ + goto LabelNonVar; \ + LabelUnk: \ + (A) = (CELL *)(D); \ + (D) = *(CELL *)(D); \ + } while (Unsigned(A) != (D)) + +#define do_derefa(D, A, LabelUnk, LabelDone) \ + (D) = *(CELL *)(A); \ + if (IsNonVarTerm(D)) \ + goto LabelDone; \ + goto LabelUnk; \ + do { \ + (A) = (CELL *)(D); \ + (D) = *(CELL *)(D); \ + if (!IsVarTerm(D)) \ + goto LabelDone; \ + LabelUnk:; \ + } while (Unsigned(A) != (D)); \ + LabelDone: + +#define profiled_derefa_body(D, A, LabelUnk, LabelNonVar) \ + do { \ + (A) = (CELL *)(D); \ + (D) = *(CELL *)(D); \ + if (!strcmp(#D, "d0") && !strcmp(#A, "pt0")) { \ + EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D0PT0); \ + } else if (!strcmp(#D, "d0") && !strcmp(#A, "pt1")) { \ + EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D0PT1); \ + } else if (!strcmp(#D, "d0") && !strcmp(#A, "S_SREG")) { \ + EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D0S_SREG); \ + } else if (!strcmp(#D, "d1") && !strcmp(#A, "pt0")) { \ + EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D1PT0); \ + } else if (!strcmp(#D, "d1") && !strcmp(#A, "pt1")) { \ + EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D1PT1); \ + } \ + if (!IsVarTerm(D)) \ + goto LabelNonVar; \ + LabelUnk:; \ + } while (Unsigned(A) != (D)); + +#define derefa_body(D, A, LabelUnk, LabelNonVar) \ + do { \ + (A) = (CELL *)(D); \ + (D) = *(CELL *)(D); \ + if (!IsVarTerm(D)) \ + goto LabelNonVar; \ + LabelUnk:; \ + } while (Unsigned(A) != (D)) #if UNIQUE_TAG_FOR_PAIRS @@ -109,21 +144,39 @@ LabelUnk: \ speed up detection of dereferenced pairs, but will be slow for the other cases. - The only instruction where this seems useful is + The only instruction where this seems useful is switch_list_nl */ -#define deref_list_head(D,Label) if (!IsPairTerm(D)) goto Label +#define deref_list_head(D, Label) \ + if (!IsPairTerm(D)) \ + goto Label -#define deref_list_body(D,A,LabelList,LabelNonVar) \ - do { \ - if (!IsVarTerm(D)) goto LabelNonVar; \ - (A) = (CELL *)(D); \ - (D) = *(A); \ - if (Unsigned(A) == (D)) break; \ - if (IsPairTerm(D)) goto LabelList; \ - } while (TRUE); +#define deref_list_body(D, A, LabelList, LabelNonVar) \ + do { \ + if (!IsVarTerm(D)) \ + goto LabelNonVar; \ + (A) = (CELL *)(D); \ + (D) = *(A); \ + if (Unsigned(A) == (D)) \ + break; \ + if (IsPairTerm(D)) \ + goto LabelList; \ + } while (TRUE); +INLINE_ONLY CELL *deref_ptr(CELL *A); + +INLINE_ONLY CELL *deref_ptr(CELL *A) { + Term D = *A; + do { + if (!IsVarTerm(D)) + return A; + (A) = (CELL *)(D); + (D) = *(A); + if (Unsigned(A) == (D)) + return A; + } while (TRUE); +} #endif /* UNIQUE_TAG_FOR_PAIRS */ /************************************************************ @@ -134,123 +187,148 @@ A contains the address of the variable that is to be trailed *************************************************************/ - -#define RESET_VARIABLE(V) (*(CELL *)(V) = Unsigned(V)) +#define RESET_VARIABLE(V) (*(CELL *)(V) = Unsigned(V)) #ifdef TABLING -#define DO_TRAIL(TERM, VAL) \ - { \ - tr_fr_ptr r; \ - r = TR; \ - TR = r + 1; \ - TrailTerm(r) = (Term) (TERM); \ - TrailVal(r) = (CELL) (VAL); \ -} +#define DO_TRAIL(TERM, VAL) \ + { \ + tr_fr_ptr r; \ + r = TR; \ + TR = r + 1; \ + TrailTerm(r) = (Term)(TERM); \ + TrailVal(r) = (CELL)(VAL); \ + } #ifdef BFZ_TRAIL_SCHEME -#define TRAIL(TERM, VAL) \ - if (OUTSIDE(HBREG,TERM,B) || \ - ((TERM) > (CELL *)B_FZ)) \ - DO_TRAIL(TERM, VAL) +#define TRAIL(TERM, VAL) \ + if (OUTSIDE(HBREG, TERM, B) || ((TERM) > (CELL *)B_FZ)) \ + DO_TRAIL(TERM, VAL) -#define TRAIL_LOCAL(TERM, VAL) \ - if ((TERM) > (CELL *)B || (TERM) > (CELL *)B_FZ) \ - DO_TRAIL(TERM, VAL) +#define TRAIL_LOCAL(TERM, VAL) \ + if ((TERM) > (CELL *)B || (TERM) > (CELL *)B_FZ) \ + DO_TRAIL(TERM, VAL) #else /* BBREG_TRAIL_SCHEME */ - -#define TRAIL(TERM, VAL) \ - if (OUTSIDE(HBREG,TERM,BBREG)) \ - DO_TRAIL(TERM, VAL) -#define TRAIL_LOCAL(TERM, VAL) \ - if ((TERM) > (CELL *)BBREG) DO_TRAIL(TERM, VAL) +#define TRAIL(TERM, VAL) \ + if (OUTSIDE(HBREG, TERM, BBREG)) \ + DO_TRAIL(TERM, VAL) + +#define TRAIL_LOCAL(TERM, VAL) \ + if ((TERM) > (CELL *)BBREG) \ + DO_TRAIL(TERM, VAL) #endif /* TRAIL_SCHEME */ /* ------------------------------------------------------ */ -#define TRAIL_GLOBAL(TERM, VAL) \ - if ((TERM) < HBREG) DO_TRAIL(TERM, VAL) +#define TRAIL_GLOBAL(TERM, VAL) \ + if ((TERM) < HBREG) \ + DO_TRAIL(TERM, VAL) -#define DO_MATRAIL(TERM, OLDVAL, NEWVAL) \ -{ \ - register tr_fr_ptr r = TR; \ - TR = r + 2; \ - TrailVal(r) = (OLDVAL); \ - TrailTerm(r) = TrailTerm(r+1) = AbsAppl((CELL *)(TERM)); \ - TrailVal(r+1) = (NEWVAL); \ -} +#define DO_MATRAIL(TERM, OLDVAL, NEWVAL) \ + { \ + register tr_fr_ptr r = TR; \ + TR = r + 2; \ + TrailVal(r) = (OLDVAL); \ + TrailTerm(r) = TrailTerm(r + 1) = AbsAppl((CELL *)(TERM)); \ + TrailVal(r + 1) = (NEWVAL); \ + } -#define MATRAIL(TERM, OVAL, VAL) \ - if (OUTSIDE(HBREG,TERM,B)) \ - DO_MATRAIL(TERM, OVAL, VAL) +#define MATRAIL(TERM, OVAL, VAL) \ + if (OUTSIDE(HBREG, TERM, B)) \ + DO_MATRAIL(TERM, OVAL, VAL) #else /* TABLING */ #if defined(i386) && !defined(TERM_EXTENSIONS) -#define DO_TRAIL(A,D) \ -{ \ - tr_fr_ptr r; \ - r = TR; \ - TR = r+1; \ - TrailTerm(r) = (CELL)(A); \ -} +#define DO_TRAIL(A, D) \ + { \ + tr_fr_ptr r; \ + r = TR; \ + TR = r + 1; \ + TrailTerm(r) = (CELL)(A); \ + } -#define TRAIL(A,D) if (OUTSIDE(HBREG,A,B)) \ - DO_TRAIL(A,D); +#define TRAIL(A, D) \ + if (OUTSIDE(HBREG, A, B)) \ + DO_TRAIL(A, D); -#define TRAIL_GLOBAL(A,D) if ((A) < HBREG) DO_TRAIL(A,D); - -#define TRAIL_LOCAL(A,D) if ((A) > (CELL *)B) DO_TRAIL(A,D); +#define TRAIL_GLOBAL(A, D) \ + if ((A) < HBREG) \ + DO_TRAIL(A, D); +#define TRAIL_LOCAL(A, D) \ + if ((A) > (CELL *)B) \ + DO_TRAIL(A, D); #elif defined(__alpha) && !defined(TERM_EXTENSIONS) /* alpha machines have a move conditional instruction, which avoids a branch when jumping */ -#define TRAIL(A,D) TrailTerm(TR) = (CELL)(A); \ - if (OUTSIDE(HBREG,A,B)) \ - TR++ +#define TRAIL(A, D) \ + TrailTerm(TR) = (CELL)(A); \ + if (OUTSIDE(HBREG, A, B)) \ + TR++ -#define TRAIL(A,D) TrailTerm(TR) = (CELL)(A); \ - if (!OUTSIDE(HBREG,A,B)) \ - GONext(); +#define TRAIL(A, D) \ + TrailTerm(TR) = (CELL)(A); \ + if (!OUTSIDE(HBREG, A, B)) \ + GONext(); -#define TRAIL_GLOBAL(A,D) TR[0] = (CELL)(A); if ((A) < HBREG) TR++ +#define TRAIL_GLOBAL(A, D) \ + TR[0] = (CELL)(A); \ + if ((A) < HBREG) \ + TR++ -#define TRAIL_LOCAL(A,D) TR[0] = (CELL)(A); if ((A) > ((CELL *)(B))) TR++ +#define TRAIL_LOCAL(A, D) \ + TR[0] = (CELL)(A); \ + if ((A) > ((CELL *)(B))) \ + TR++ #elif !defined(TERM_EXTENSIONS) -#define DO_TRAIL(A,D) TrailTerm(TR++) = (CELL)(A) +#define DO_TRAIL(A, D) TrailTerm(TR++) = (CELL)(A) -#define TRAIL(A,D) if (OUTSIDE(HBREG,A,B)) \ - DO_TRAIL(A,D) +#define TRAIL(A, D) \ + if (OUTSIDE(HBREG, A, B)) \ + DO_TRAIL(A, D) -#define TRAIL_AND_JUMP(A,D) if (IN_BETWEEN(HBREG,A,B)) GONext(); \ - DO_TRAIL(A,D) +#define TRAIL_AND_JUMP(A, D) \ + if (IN_BETWEEN(HBREG, A, B)) \ + GONext(); \ + DO_TRAIL(A, D) -#define TRAIL_GLOBAL(A,D) if ((A) < HBREG) DO_TRAIL(A,D) +#define TRAIL_GLOBAL(A, D) \ + if ((A) < HBREG) \ + DO_TRAIL(A, D) -#define TRAIL_LOCAL(A,D) if ((A) > ((CELL *)B)) DO_TRAIL(A,D) +#define TRAIL_LOCAL(A, D) \ + if ((A) > ((CELL *)B)) \ + DO_TRAIL(A, D) #else -#define DO_TRAIL(A,D) TrailTerm(TR++) = (CELL)(A) +#define DO_TRAIL(A, D) TrailTerm(TR++) = (CELL)(A) -#define TRAIL(A,D) if (OUTSIDE(HBREG,A,B)) \ - DO_TRAIL(A,D) +#define TRAIL(A, D) \ + if (OUTSIDE(HBREG, A, B)) \ + DO_TRAIL(A, D) -#define TrailAndJump(A,D) if (IN_BETWEEN(HBREG,A,B)) \ +#define TrailAndJump(A, D) \ + if (IN_BETWEEN(HBREG, A, B)) \ GONext(); -#define TRAIL_GLOBAL(A,D) if ((A) < HBREG) DO_TRAIL(A,D) +#define TRAIL_GLOBAL(A, D) \ + if ((A) < HBREG) \ + DO_TRAIL(A, D) -#define TRAIL_LOCAL(A,D) if ((A) > ((CELL *)B)) DO_TRAIL(A,D) +#define TRAIL_LOCAL(A, D) \ + if ((A) > ((CELL *)B)) \ + DO_TRAIL(A, D) #endif @@ -260,43 +338,85 @@ Binding Macros for Multiple Assignment Variables. ************************************************************/ -#define DO_MATRAIL(VP, OLDV, D) \ - { TrailTerm(TR+1) = OLDV; \ - TrailTerm(TR) = TrailTerm(TR+2) = AbsAppl(VP); \ - TR += 3; \ - } +#define DO_MATRAIL(VP, OLDV, D) \ + { \ + TrailTerm(TR + 1) = OLDV; \ + TrailTerm(TR) = TrailTerm(TR + 2) = AbsAppl(VP); \ + TR += 3; \ + } -#define MATRAIL(VP,OLDV,D) if (OUTSIDE(HBREG,VP,B)) \ - DO_MATRAIL(VP, OLDV, D) +#define MATRAIL(VP, OLDV, D) \ + if (OUTSIDE(HBREG, VP, B)) \ + DO_MATRAIL(VP, OLDV, D) #endif /* TABLING */ - -#define REF_TO_TRENTRY(REF) AbsPair(((CELL *)&((REF)->Flags))) -#define CLREF_TO_TRENTRY(REF) AbsPair(((CELL *)&((REF)->ClFlags))) +#define REF_TO_TRENTRY(REF) AbsPair(((CELL *)&((REF)->Flags))) +#define CLREF_TO_TRENTRY(REF) AbsPair(((CELL *)&((REF)->ClFlags))) #if FROZEN_STACKS -#define TRAIL_REF(REF) RESET_VARIABLE(&TrailVal(TR)), TrailTerm(TR++) = REF_TO_TRENTRY(REF) -#define TRAIL_CLREF(REF) RESET_VARIABLE(&TrailVal(TR)), TrailTerm(TR++) = CLREF_TO_TRENTRY(REF) -#define TRAIL_LINK(REF) RESET_VARIABLE(&TrailVal(TR)), TrailTerm(TR++) = AbsPair((CELL *)(REF)) +#define TRAIL_REF(REF) \ + RESET_VARIABLE(&TrailVal(TR)), TrailTerm(TR++) = REF_TO_TRENTRY(REF) +#define TRAIL_CLREF(REF) \ + RESET_VARIABLE(&TrailVal(TR)), TrailTerm(TR++) = CLREF_TO_TRENTRY(REF) +#define TRAIL_LINK(REF) \ + RESET_VARIABLE(&TrailVal(TR)), TrailTerm(TR++) = AbsPair((CELL *)(REF)) #else -#define TRAIL_REF(REF) TrailTerm(TR++) = REF_TO_TRENTRY(REF) -#define TRAIL_CLREF(REF) TrailTerm(TR++) = CLREF_TO_TRENTRY(REF) -#define TRAIL_LINK(REF) TrailTerm(TR++) = AbsPair((CELL *)(REF)) +#define TRAIL_REF(REF) TrailTerm(TR++) = REF_TO_TRENTRY(REF) +#define TRAIL_CLREF(REF) TrailTerm(TR++) = CLREF_TO_TRENTRY(REF) +#define TRAIL_LINK(REF) TrailTerm(TR++) = AbsPair((CELL *)(REF)) #endif -#define TRAIL_FRAME(FR) DO_TRAIL(AbsPair((CELL *)(LOCAL_TrailBase)), FR) +#define TRAIL_FRAME(FR) DO_TRAIL(AbsPair((CELL *)(LOCAL_TrailBase)), FR) -extern void Yap_WakeUp(CELL *v); +extern void Yap_WakeUp(CELL *v); -#define Bind_Local(A,D) { TRAIL_LOCAL(A,D); *(A) = (D); } -#define Bind_Global(A,D) { *(A) = (D); if (__builtin_expect(GlobalIsAttVar(A),0)) Yap_WakeUp(A); else TRAIL_GLOBAL(A,D); } -#define YapBind(A,D) { *(A) = (D); if (A < HR) { if (__builtin_expect(GlobalIsAttVar(A),0)) Yap_WakeUp(A); else TRAIL_GLOBAL(A,D); } else { TRAIL_LOCAL(A,D); } } -#define Bind_NonAtt(A,D) { *(A) = (D); TRAIL(A,D); } -#define Bind_Global_NonAtt(A,D) { *(A) = (D); TRAIL_GLOBAL(A,D); } -#define Bind_and_Trail(A,D) { *(A) = (D); DO_TRAIL(A, D); } +#define Bind_Local(A, D) \ + { \ + TRAIL_LOCAL(A, D); \ + *(A) = (D); \ + } +#define Bind_Global(A, D) \ + { \ + *(A) = (D); \ + if (__builtin_expect(GlobalIsAttVar(A), 0)) \ + Yap_WakeUp(A); \ + else \ + TRAIL_GLOBAL(A, D); \ + } +#define YapBind(A, D) \ + { \ + *(A) = (D); \ + if (A < HR) { \ + if (__builtin_expect(GlobalIsAttVar(A), 0)) \ + Yap_WakeUp(A); \ + else \ + TRAIL_GLOBAL(A, D); \ + } else { \ + TRAIL_LOCAL(A, D); \ + } \ + } +#define Bind_NonAtt(A, D) \ + { \ + *(A) = (D); \ + TRAIL(A, D); \ + } +#define Bind_Global_NonAtt(A, D) \ + { \ + *(A) = (D); \ + TRAIL_GLOBAL(A, D); \ + } +#define Bind_and_Trail(A, D) \ + { \ + *(A) = (D); \ + DO_TRAIL(A, D); \ + } // #define Bind(A,D) YapBind(A,D) conflicts with Windows headers -#define MaBind(VP,D) { MATRAIL((VP),*(VP),(D)); *(VP) = (D); } +#define MaBind(VP, D) \ + { \ + MATRAIL((VP), *(VP), (D)); \ + *(VP) = (D); \ + } /************************************************************ @@ -304,12 +424,11 @@ Unification Routines *************************************************************/ -INLINE_ONLY inline EXTERN void reset_trail(tr_fr_ptr TR0); +INLINE_ONLY void reset_trail(tr_fr_ptr TR0); -INLINE_ONLY inline EXTERN void -reset_trail(tr_fr_ptr TR0) { +INLINE_ONLY void reset_trail(tr_fr_ptr TR0) { CACHE_REGS - while(TR != TR0) { + while (TR != TR0) { CELL d1; --TR; d1 = TrailTerm(TR); @@ -321,14 +440,14 @@ reset_trail(tr_fr_ptr TR0) { #ifdef MULTI_ASSIGNMENT_VARIABLES } else { CELL *pt = RepAppl(d1); - /* AbsAppl means */ - /* multi-assignment variable */ - /* so the next cell is the old value */ +/* AbsAppl means */ +/* multi-assignment variable */ +/* so the next cell is the old value */ #ifdef FROZEN_STACKS - pt[0] = TrailVal(TR-1); + pt[0] = TrailVal(TR - 1); TR -= 1; #else - pt[0] = TrailTerm(TR-1); + pt[0] = TrailTerm(TR - 1); TR -= 2; #endif /* FROZEN_STACKS */ } @@ -336,36 +455,36 @@ reset_trail(tr_fr_ptr TR0) { } } -INLINE_ONLY inline EXTERN void reset_attvars(CELL *dvarsmin, CELL *dvarsmax); +INLINE_ONLY void reset_attvars(CELL *dvarsmin, CELL *dvarsmax); -INLINE_ONLY inline EXTERN void -reset_attvars(CELL *dvarsmin, CELL *dvarsmax) { +INLINE_ONLY void reset_attvars(CELL *dvarsmin, CELL *dvarsmax) { if (dvarsmin) { dvarsmin += 1; do { CELL *newv; newv = CellPtr(*dvarsmin); - RESET_VARIABLE(dvarsmin+1); + RESET_VARIABLE(dvarsmin + 1); if (IsUnboundVar(dvarsmin)) - break; + break; RESET_VARIABLE(dvarsmin); dvarsmin = newv; } while (TRUE); } } -INLINE_ONLY inline EXTERN void close_attvar_chain(CELL *dvarsmin, CELL *dvarsmax); +INLINE_ONLY void close_attvar_chain(CELL *dvarsmin, + CELL *dvarsmax); -INLINE_ONLY inline EXTERN void -close_attvar_chain(CELL *dvarsmin, CELL *dvarsmax) { +INLINE_ONLY void close_attvar_chain(CELL *dvarsmin, + CELL *dvarsmax) { CACHE_REGS if (dvarsmin) { dvarsmin += 1; do { CELL *newv; - YapBind(dvarsmin+1, dvarsmin[1]); + YapBind(dvarsmin + 1, dvarsmin[1]); if (IsUnboundVar(dvarsmin)) - break; + break; newv = CellPtr(*dvarsmin); RESET_VARIABLE(dvarsmin); dvarsmin = newv; @@ -373,81 +492,72 @@ close_attvar_chain(CELL *dvarsmin, CELL *dvarsmax) { } } -INLINE_ONLY EXTERN inline -Int Yap_unify(Term t0, Term t1); +INLINE_ONLY bool Yap_unify(Term t0, Term t1); -INLINE_ONLY EXTERN inline -Int Yap_unify(Term t0, Term t1) -{ +INLINE_ONLY bool Yap_unify(Term t0, Term t1) { CACHE_REGS tr_fr_ptr TR0 = TR; - if (Yap_IUnify(t0,t1)) { - return TRUE; + if (Yap_IUnify(t0, t1)) { + return true; } else { reset_trail(TR0); - return FALSE; + return false; } } -INLINE_ONLY EXTERN inline Int Yap_unify_constant(Term a, Term cons); +INLINE_ONLY Int Yap_unify_constant(Term a, Term cons); -INLINE_ONLY EXTERN inline Int -Yap_unify_constant(Term a, Term cons) -{ +INLINE_ONLY Int Yap_unify_constant(Term a, Term cons) { CACHE_REGS CELL *pt; - deref_head(a,unify_cons_unk); - unify_cons_nonvar: - { - if (a == cons) return(TRUE); - else if (IsApplTerm(a)) { - Functor f; - if (!IsApplTerm(cons)) - return(FALSE); - f = FunctorOfTerm(a); - if (f != FunctorOfTerm(cons)) - return(FALSE); - if (IsExtensionFunctor(f)) { - switch((CELL)f) { - case db_ref_e: - return(a == cons); - case long_int_e: - { - CELL d0 = RepAppl(a)[1]; - CELL d1 = RepAppl(cons)[1]; - return d0 == d1; - } - case double_e: - { - Float d0 = FloatOfTerm(a); - Float d1 = FloatOfTerm(cons); - return d0 == d1; - } - case big_int_e: -#ifdef USE_GMP - return (Yap_gmp_tcmp_big_big(a, cons) == 0); -#endif /* USE_GMP */ - default: - return FALSE; - } + deref_head(a, unify_cons_unk); +unify_cons_nonvar : { + if (a == cons) + return (TRUE); + else if (IsApplTerm(a)) { + Functor f; + if (!IsApplTerm(cons)) + return (FALSE); + f = FunctorOfTerm(a); + if (f != FunctorOfTerm(cons)) + return (FALSE); + if (IsExtensionFunctor(f)) { + switch ((CELL)f) { + case db_ref_e: + return (a == cons); + case long_int_e: { + CELL d0 = RepAppl(a)[1]; + CELL d1 = RepAppl(cons)[1]; + return d0 == d1; } - } else - return FALSE; - } - - deref_body(a,pt,unify_cons_unk,unify_cons_nonvar); - YapBind(pt,cons); - return(TRUE); + case double_e: { + Float d0 = FloatOfTerm(a); + Float d1 = FloatOfTerm(cons); + return d0 == d1; + } + case big_int_e: +#ifdef USE_GMP + return (Yap_gmp_tcmp_big_big(a, cons) == 0); +#endif /* USE_GMP */ + default: + return FALSE; + } + } + } else + return FALSE; } + deref_body(a, pt, unify_cons_unk, unify_cons_nonvar); + YapBind(pt, cons); + return (TRUE); +} #define EQ_OK_IN_CMP 1 #define LT_OK_IN_CMP 2 #define GT_OK_IN_CMP 4 -static inline int -do_cut(int i) { +static inline int do_cut(int i) { CACHE_REGS if (POP_CHOICE_POINT(B->cp_b)) { cut_c_pop(); @@ -461,3 +571,4 @@ do_cut(int i) { #define cut_fail() return do_cut(FALSE) +#endif diff --git a/H/arith2.h b/H/arith2.h index fe815f14a..12d78f0c0 100755 --- a/H/arith2.h +++ b/H/arith2.h @@ -24,7 +24,20 @@ inline static int sub_overflow(Int x, Int i, Int j) { } inline static Term sub_int(Int i, Int j USES_REGS) { - Int x = i - j; +#if defined(__clang__ ) || (defined(__GNUC__) && __GNUC__ > 4) + Int k; + if (__builtin_sub_overflow(i,j,&k)) { + return Yap_gmp_sub_ints(i, j); + } + RINT(k); +#elif defined(__GNUC__) && __GNUC__ >4 + Int w; + if (!__builtin_sub_overflow_p(i,j,w)) + RINT(w); + return Yap_gmp_sub_ints(i, j); +#else + Int x = i - j; + #if USE_GMP Int overflow = ((i & ~j & ~x) | (~i & j & x)) < 0; /* Integer overflow, we need to use big integers */ @@ -38,6 +51,7 @@ inline static Term sub_int(Int i, Int j USES_REGS) { #else RINT(x); #endif +#endif } inline static Int SLR(Int i, Int shift) { @@ -50,8 +64,12 @@ inline static int mul_overflow(Int z, Int i1, Int i2) { return (i2 && z / i2 != i1); } -# -#if defined(__GNUC__) && defined(__i386__) +#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ > 4) +#define DO_MULTI() \ + if (__builtin_mul_overflow(i1, i2, &z)) { \ + goto overflow; \ + } +#elif defined(__GNUC__) && defined(__i386__) #define DO_MULTI() \ { \ Int tmp1; \ @@ -75,11 +93,7 @@ inline static int mul_overflow(Int z, Int i1, Int i2) { goto overflow; \ z = i1 * i2; \ } -#elif __clang__ && FALSE /* not in OSX yet */ -#define DO_MULTI() \ - if (__builtin_smul_overflow(i1, i2, &z)) { \ - goto overflow; \ - } + #elif SIZEOF_DOUBLE == 2 * SIZEOF_INT_P #define DO_MULTI() \ { \ diff --git a/H/blobs.h b/H/blobs.h deleted file mode 100644 index 0e0f73803..000000000 --- a/H/blobs.h +++ /dev/null @@ -1,81 +0,0 @@ -// -// blobs.h -// yap -// -// Created by VITOR SANTOS COSTA on 09/05/15. -// Copyright (c) 2015 VITOR SANTOS COSTA. All rights reserved. -// - -// based on the SWI Blob implementation, an extension of atoms for SWI-Prolog - -#ifndef BLOBS_H -#define BLOBS_H - -#if !defined(X_API) && !defined(SWIGYAP) -#if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(PL_KERNEL) -#define X_API __declspec(dllexport) -#else -#define X_API -#endif -#endif - -/******************************* - * BLOBS * - *******************************/ - -#define YAP_BLOB_MAGIC_B 0x75293a00 /* Magic to validate a blob-type */ -#define PL_BLOB_VERSION (YAP_BLOB_MAGIC_B|PL_BLOB_VERSION) - -#define PL_BLOB_UNIQUE 0x01 /* Blob content is unique */ -#define PL_BLOB_TEXT 0x02 /* blob contains text */ -#define PL_BLOB_NOCOPY 0x04 /* do not copy the data */ -#define PL_BLOB_WCHAR 0x08 /* wide character string */ - -typedef struct YAP_blob_t -{ uintptr_t magic; /* YAP_BLOB_MAGIC */ - uintptr_t flags; /* YAP_BLOB_* */ - char * name; /* name of the type */ - int (*release)(Atom a); - int (*compare)(Atom a, Atom b); -#ifdef SIO_MAGIC - int (*write)(FILE *s, Atom a, int flags); -#else - int (*write)(void *s, Atom a, int flags); -#endif - void (*acquire)(Atom a); -#ifdef SIO_MAGIC - int (*save)(Atom a, FILE *s); - Atom (*load)(FILE *s); -#else - int (*save)(Atom a, void*); - Atom (*load)(void *s); -#endif - /* private */ - void * reserved[10]; /* for future extension */ - int registered; /* Already registered? */ - int rank; /* Rank for ordering atoms */ - struct YAP_blob_t * next; /* next in registered type-chain */ - Atom atom_name; /* Name as atom */ -} blob_type_t; - -int Yap_write_blob(AtomEntry *ref, FILE *stream); -char * Yap_blob_to_string(AtomEntry *ref, const char *s, size_t sz); -X_API bool YAP_is_blob(YAP_Term t, blob_type_t **type); -X_API bool YAP_unify_blob(YAP_Term *t, void *blob, size_t len, - blob_type_t *type); -X_API bool YAP_put_blob(YAP_Term *t, void *blob, size_t len, - blob_type_t *type); -X_API bool YAP_get_blob(YAP_Term t, void **blob, size_t *len, - blob_type_t **type); - -X_API void* YAP_blob_data(Atom a, - size_t *len, - struct YAP_blob_t **type); - -X_API void YAP_register_blob_type(blob_type_t *type); -X_API blob_type_t* YAP_find_blob_type(const char* name); -//YAP_blob_type_t* YAP_find_blob_type(Atom at); -X_API bool YAP_unregister_blob_type(blob_type_t *type); - - -#endif diff --git a/H/clause.h b/H/clause.h index 0472868bc..1b2d55903 100644 --- a/H/clause.h +++ b/H/clause.h @@ -24,7 +24,7 @@ /* consulting files */ typedef union CONSULT_OBJ { - const unsigned char *filename; + Atom f_name; int mode; Prop p; UInt c; @@ -91,9 +91,9 @@ typedef struct logic_upd_clause { } LogUpdClause; #include "inline-only.h" -INLINE_ONLY inline EXTERN int VALID_TIMESTAMP(UInt, struct logic_upd_clause *); +INLINE_ONLY int VALID_TIMESTAMP(UInt, struct logic_upd_clause *); -INLINE_ONLY inline EXTERN int VALID_TIMESTAMP(UInt timestamp, +INLINE_ONLY int VALID_TIMESTAMP(UInt timestamp, struct logic_upd_clause *cl) { return IN_BETWEEN(cl->ClTimeStart, timestamp, cl->ClTimeEnd); } @@ -191,36 +191,36 @@ typedef struct index_t { UInt udi_arg; } Index_t; -INLINE_ONLY EXTERN inline BITS32 EXO_ADDRESS_TO_OFFSET(struct index_t *it, +INLINE_ONLY BITS32 EXO_ADDRESS_TO_OFFSET(struct index_t *it, CELL *ptr); -INLINE_ONLY EXTERN inline BITS32 EXO_ADDRESS_TO_OFFSET(struct index_t *it, +INLINE_ONLY BITS32 EXO_ADDRESS_TO_OFFSET(struct index_t *it, CELL *ptr) { return (ptr - it->cls) / it->arity + 1; } -INLINE_ONLY EXTERN inline CELL *EXO_OFFSET_TO_ADDRESS(struct index_t *it, +INLINE_ONLY CELL *EXO_OFFSET_TO_ADDRESS(struct index_t *it, BITS32 off); -INLINE_ONLY EXTERN inline CELL *EXO_OFFSET_TO_ADDRESS(struct index_t *it, +INLINE_ONLY CELL *EXO_OFFSET_TO_ADDRESS(struct index_t *it, BITS32 off) { if (off == 0L) return (CELL *)NULL; return (it->cls) + (off - 1) * it->arity; } -INLINE_ONLY EXTERN inline BITS32 ADDRESS_TO_LINK(struct index_t *it, +INLINE_ONLY BITS32 ADDRESS_TO_LINK(struct index_t *it, BITS32 *ptr); -INLINE_ONLY EXTERN inline BITS32 ADDRESS_TO_LINK(struct index_t *it, +INLINE_ONLY BITS32 ADDRESS_TO_LINK(struct index_t *it, BITS32 *ptr) { return ptr - it->links; } -INLINE_ONLY EXTERN inline BITS32 *LINK_TO_ADDRESS(struct index_t *it, +INLINE_ONLY BITS32 *LINK_TO_ADDRESS(struct index_t *it, BITS32 off); -INLINE_ONLY EXTERN inline BITS32 *LINK_TO_ADDRESS(struct index_t *it, +INLINE_ONLY BITS32 *LINK_TO_ADDRESS(struct index_t *it, BITS32 off) { return it->links + off; } @@ -319,17 +319,17 @@ CELL Yap_NextExo(choiceptr cpt, struct index_t *it); #define OP_HASH_SIZE 2048 -INLINE_ONLY inline EXTERN int rtable_hash_op(OPCODE opc, int hash_mask); +INLINE_ONLY int rtable_hash_op(OPCODE opc, int hash_mask); -INLINE_ONLY inline EXTERN int rtable_hash_op(OPCODE opc, int hash_mask) { +INLINE_ONLY int rtable_hash_op(OPCODE opc, int hash_mask) { return ((((CELL)opc) >> 3) & hash_mask); } -INLINE_ONLY inline EXTERN op_numbers Yap_op_from_opcode(OPCODE opc); +INLINE_ONLY op_numbers Yap_op_from_opcode(OPCODE opc); /* given an opcode find the corresponding opnumber. This should make switches on ops a much easier operation */ -INLINE_ONLY inline EXTERN op_numbers Yap_op_from_opcode(OPCODE opc) { +INLINE_ONLY op_numbers Yap_op_from_opcode(OPCODE opc) { int j = rtable_hash_op(opc, OP_HASH_SIZE - 1); while (OP_RTABLE[j].opc != opc) { @@ -457,12 +457,12 @@ LogUpdClause *Yap_new_ludbe(Term, PredEntry *, UInt); Term Yap_LUInstance(LogUpdClause *, UInt); /* udi.c */ -int Yap_new_udi_clause(PredEntry *, yamop *, Term); -yamop *Yap_udi_search(PredEntry *); +extern int Yap_new_udi_clause(PredEntry *, yamop *, Term); +extern yamop *Yap_udi_search(PredEntry *); -Term Yap_bug_location(yamop *p, yamop *cp, choiceptr b_ptr, CELL *env); -Term Yap_pc_location(yamop *p, choiceptr b_ptr, CELL *env); -Term Yap_env_location(yamop *p, choiceptr b_ptr, CELL *env, Int ignore_first); +extern yap_error_descriptor_t *Yap_bug_location(yap_error_descriptor_t *t, yamop *p, yamop *cp, choiceptr b_ptr, void *env); +extern yap_error_descriptor_t *Yap_pc_add_location(yap_error_descriptor_t *t, void *p, void *b_ptr, void *env); +extern yap_error_descriptor_t * Yap_env_add_location(yap_error_descriptor_t *t, void *p, void *b_ptr, void *env, YAP_Int ignore_first); #if LOW_PROF void Yap_InformOfRemoval(void *); diff --git a/H/cut_c.h b/H/cut_c.h index 690396445..c45655b4b 100644 --- a/H/cut_c.h +++ b/H/cut_c.h @@ -21,48 +21,13 @@ struct cut_c_str { #define CBACK_CUT_ARG(Offset) B->cp_args[(Offset)-1] -#define CUT_C_PUSH(YAMOP, S_YREG) \ - { \ - if ((YAMOP)->y_u.OtapFs.f) { \ - S_YREG = S_YREG - CUT_C_STR_SIZE; \ - cut_c_str_ptr new_top = (cut_c_str_ptr)S_YREG; \ - new_top->try_userc_cut_yamop = YAMOP; \ - cut_c_push(new_top); \ - } \ - } +#define CUT_C_PUSH(YAMOP, S_YREG) -#define POP_CHOICE_POINT(cp) \ - (((CELL *)Yap_REGS.CUT_C_TOP != (CELL *)LOCAL_LocalBase) && \ - ((CELL *)(cp) > (CELL *)Yap_REGS.CUT_C_TOP)) +#define POP_CHOICE_POINT(cp) false +#define POP_EXECUTE() -#define POP_EXECUTE() \ - cut_c_str_ptr TOP = Yap_REGS.CUT_C_TOP; \ - CPredicate func = \ - (CPredicate)((yamop *)TOP->try_userc_cut_yamop)->y_u.OtapFs.f; \ - PredEntry *pred = \ - (PredEntry *)((yamop *)TOP->try_userc_cut_yamop)->y_u.OtapFs.p; \ - YAP_ExecuteOnCut(pred, func, TOP); \ - cut_c_pop(); - -#define POP_FAIL(handler) \ - if (handler) { yamop *oap = handler->cp_ap; \ -handler->cp_ap = NOCODE; \ - P = (yamop *)FAILCODE; \ - choiceptr olB = B; B = handler; \ - HR = handler->cp_h; \ - /* DBTerm *ref = Yap_RefToException(); */ \ - Yap_exec_absmi(true, false); \ - B = olB; handler->cp_ap = oap; } - -#define POP_FAIL_EXECUTE(handler) \ - POP_FAIL(handler); \ - cut_c_str_ptr TOP = Yap_REGS.CUT_C_TOP; \ - CPredicate func = \ - (CPredicate)((yamop *)TOP->try_userc_cut_yamop)->y_u.OtapFs.f; \ - PredEntry *pred = \ - (PredEntry *)((yamop *)TOP->try_userc_cut_yamop)->y_u.OtapFs.p; \ - YAP_ExecuteOnCut(pred, func, TOP); \ - cut_c_pop(); +#define POP_FAIL(handler) +#define POP_FAIL_EXECUTE(handler) /*Initializes CUT_C_TOP*/ void cut_c_initialize(int wid); diff --git a/H/generated/dglobals.h b/H/generated/dglobals.h index 7e4d5f390..084b1127c 100644 --- a/H/generated/dglobals.h +++ b/H/generated/dglobals.h @@ -141,4 +141,5 @@ #define GLOBAL_NOfFileAliases Yap_global->NOfFileAliases_ #define GLOBAL_SzOfFileAliases Yap_global->SzOfFileAliases_ #define GLOBAL_VFS Yap_global->VFS_ +#define GLOBAL_cwd Yap_global->cwd_ diff --git a/H/generated/dhstruct.h b/H/generated/dhstruct.h index 9df73084f..510ebd9a1 100644 --- a/H/generated/dhstruct.h +++ b/H/generated/dhstruct.h @@ -83,7 +83,6 @@ #ifdef EUROTRA #define TermDollarU Yap_heap_regs->TermDollarU_ #endif -#define TermAnswer Yap_heap_regs->TermAnswer_ #define USER_MODULE Yap_heap_regs->USER_MODULE_ #define IDB_MODULE Yap_heap_regs->IDB_MODULE_ @@ -142,6 +141,7 @@ #define PredLogUpdClause Yap_heap_regs->PredLogUpdClause_ #define PredLogUpdClauseErase Yap_heap_regs->PredLogUpdClauseErase_ #define PredLogUpdClause0 Yap_heap_regs->PredLogUpdClause0_ +#define PredCall Yap_heap_regs->PredCall_ #define PredMetaCall Yap_heap_regs->PredMetaCall_ #define PredProtectStack Yap_heap_regs->PredProtectStack_ #define PredRecordedWithKey Yap_heap_regs->PredRecordedWithKey_ @@ -152,6 +152,7 @@ #define PredTraceMetaCall Yap_heap_regs->PredTraceMetaCall_ #define PredCommentHook Yap_heap_regs->PredCommentHook_ #define PredProcedure Yap_heap_regs->PredProcedure_ +#define PredUndefinedQuery Yap_heap_regs->PredUndefinedQuery_ #ifdef LOW_LEVEL_TRACER #define Yap_do_low_level_trace Yap_heap_regs->Yap_do_low_level_trace_ @@ -270,6 +271,8 @@ #define Yap_AttsSize Yap_heap_regs->Yap_AttsSize_ #endif +#define setup_call_catcher_cleanup_tag Yap_heap_regs->setup_call_catcher_cleanup_tag_ + #define OpList Yap_heap_regs->OpList_ #define ForeignCodeLoaded Yap_heap_regs->ForeignCodeLoaded_ diff --git a/H/generated/dlocals.h b/H/generated/dlocals.h deleted file mode 100644 index 0b3f4c025..000000000 --- a/H/generated/dlocals.h +++ /dev/null @@ -1,478 +0,0 @@ - - /* This file, dlocals.h, was generated automatically by "yap -L misc/buildlocalglobal" - please do not update, update H/LOCALS instead */ - - - - -#define LOCAL_c_input_stream LOCAL->c_input_stream_ -#define REMOTE_c_input_stream(wid) REMOTE(wid)->c_input_stream_ -#define LOCAL_c_output_stream LOCAL->c_output_stream_ -#define REMOTE_c_output_stream(wid) REMOTE(wid)->c_output_stream_ -#define LOCAL_c_error_stream LOCAL->c_error_stream_ -#define REMOTE_c_error_stream(wid) REMOTE(wid)->c_error_stream_ -#define LOCAL_sockets_io LOCAL->sockets_io_ -#define REMOTE_sockets_io(wid) REMOTE(wid)->sockets_io_ -#define LOCAL_within_print_message LOCAL->within_print_message_ -#define REMOTE_within_print_message(wid) REMOTE(wid)->within_print_message_ - - - - -#define LOCAL_newline LOCAL->newline_ -#define REMOTE_newline(wid) REMOTE(wid)->newline_ -#define LOCAL_AtPrompt LOCAL->AtPrompt_ -#define REMOTE_AtPrompt(wid) REMOTE(wid)->AtPrompt_ -#define LOCAL_Prompt LOCAL->Prompt_ -#define REMOTE_Prompt(wid) REMOTE(wid)->Prompt_ -#define LOCAL_encoding LOCAL->encoding_ -#define REMOTE_encoding(wid) REMOTE(wid)->encoding_ -#define LOCAL_quasi_quotations LOCAL->quasi_quotations_ -#define REMOTE_quasi_quotations(wid) REMOTE(wid)->quasi_quotations_ -#define LOCAL_default_priority LOCAL->default_priority_ -#define REMOTE_default_priority(wid) REMOTE(wid)->default_priority_ -#define LOCAL_eot_before_eof LOCAL->eot_before_eof_ -#define REMOTE_eot_before_eof(wid) REMOTE(wid)->eot_before_eof_ -#define LOCAL_max_depth LOCAL->max_depth_ -#define REMOTE_max_depth(wid) REMOTE(wid)->max_depth_ -#define LOCAL_max_list LOCAL->max_list_ -#define REMOTE_max_list(wid) REMOTE(wid)->max_list_ -#define LOCAL_max_write_args LOCAL->max_write_args_ -#define REMOTE_max_write_args(wid) REMOTE(wid)->max_write_args_ - -#define LOCAL_OldASP LOCAL->OldASP_ -#define REMOTE_OldASP(wid) REMOTE(wid)->OldASP_ -#define LOCAL_OldLCL0 LOCAL->OldLCL0_ -#define REMOTE_OldLCL0(wid) REMOTE(wid)->OldLCL0_ -#define LOCAL_OldTR LOCAL->OldTR_ -#define REMOTE_OldTR(wid) REMOTE(wid)->OldTR_ -#define LOCAL_OldGlobalBase LOCAL->OldGlobalBase_ -#define REMOTE_OldGlobalBase(wid) REMOTE(wid)->OldGlobalBase_ -#define LOCAL_OldH LOCAL->OldH_ -#define REMOTE_OldH(wid) REMOTE(wid)->OldH_ -#define LOCAL_OldH0 LOCAL->OldH0_ -#define REMOTE_OldH0(wid) REMOTE(wid)->OldH0_ -#define LOCAL_OldTrailBase LOCAL->OldTrailBase_ -#define REMOTE_OldTrailBase(wid) REMOTE(wid)->OldTrailBase_ -#define LOCAL_OldTrailTop LOCAL->OldTrailTop_ -#define REMOTE_OldTrailTop(wid) REMOTE(wid)->OldTrailTop_ -#define LOCAL_OldHeapBase LOCAL->OldHeapBase_ -#define REMOTE_OldHeapBase(wid) REMOTE(wid)->OldHeapBase_ -#define LOCAL_OldHeapTop LOCAL->OldHeapTop_ -#define REMOTE_OldHeapTop(wid) REMOTE(wid)->OldHeapTop_ -#define LOCAL_ClDiff LOCAL->ClDiff_ -#define REMOTE_ClDiff(wid) REMOTE(wid)->ClDiff_ -#define LOCAL_GDiff LOCAL->GDiff_ -#define REMOTE_GDiff(wid) REMOTE(wid)->GDiff_ -#define LOCAL_HDiff LOCAL->HDiff_ -#define REMOTE_HDiff(wid) REMOTE(wid)->HDiff_ -#define LOCAL_GDiff0 LOCAL->GDiff0_ -#define REMOTE_GDiff0(wid) REMOTE(wid)->GDiff0_ -#define LOCAL_GSplit LOCAL->GSplit_ -#define REMOTE_GSplit(wid) REMOTE(wid)->GSplit_ -#define LOCAL_LDiff LOCAL->LDiff_ -#define REMOTE_LDiff(wid) REMOTE(wid)->LDiff_ -#define LOCAL_TrDiff LOCAL->TrDiff_ -#define REMOTE_TrDiff(wid) REMOTE(wid)->TrDiff_ -#define LOCAL_XDiff LOCAL->XDiff_ -#define REMOTE_XDiff(wid) REMOTE(wid)->XDiff_ -#define LOCAL_DelayDiff LOCAL->DelayDiff_ -#define REMOTE_DelayDiff(wid) REMOTE(wid)->DelayDiff_ -#define LOCAL_BaseDiff LOCAL->BaseDiff_ -#define REMOTE_BaseDiff(wid) REMOTE(wid)->BaseDiff_ - -#define LOCAL_ReductionsCounter LOCAL->ReductionsCounter_ -#define REMOTE_ReductionsCounter(wid) REMOTE(wid)->ReductionsCounter_ -#define LOCAL_PredEntriesCounter LOCAL->PredEntriesCounter_ -#define REMOTE_PredEntriesCounter(wid) REMOTE(wid)->PredEntriesCounter_ -#define LOCAL_RetriesCounter LOCAL->RetriesCounter_ -#define REMOTE_RetriesCounter(wid) REMOTE(wid)->RetriesCounter_ -#define LOCAL_ReductionsCounterOn LOCAL->ReductionsCounterOn_ -#define REMOTE_ReductionsCounterOn(wid) REMOTE(wid)->ReductionsCounterOn_ -#define LOCAL_PredEntriesCounterOn LOCAL->PredEntriesCounterOn_ -#define REMOTE_PredEntriesCounterOn(wid) REMOTE(wid)->PredEntriesCounterOn_ -#define LOCAL_RetriesCounterOn LOCAL->RetriesCounterOn_ -#define REMOTE_RetriesCounterOn(wid) REMOTE(wid)->RetriesCounterOn_ - - -#define LOCAL_ConsultSp LOCAL->ConsultSp_ -#define REMOTE_ConsultSp(wid) REMOTE(wid)->ConsultSp_ - -#define LOCAL_ConsultCapacity LOCAL->ConsultCapacity_ -#define REMOTE_ConsultCapacity(wid) REMOTE(wid)->ConsultCapacity_ - -#define LOCAL_ConsultBase LOCAL->ConsultBase_ -#define REMOTE_ConsultBase(wid) REMOTE(wid)->ConsultBase_ - -#define LOCAL_ConsultLow LOCAL->ConsultLow_ -#define REMOTE_ConsultLow(wid) REMOTE(wid)->ConsultLow_ -#define LOCAL_VarNames LOCAL->VarNames_ -#define REMOTE_VarNames(wid) REMOTE(wid)->VarNames_ -#define LOCAL_SourceFileName LOCAL->SourceFileName_ -#define REMOTE_SourceFileName(wid) REMOTE(wid)->SourceFileName_ -#define LOCAL_SourceFileLineno LOCAL->SourceFileLineno_ -#define REMOTE_SourceFileLineno(wid) REMOTE(wid)->SourceFileLineno_ - -#define LOCAL_GlobalArena LOCAL->GlobalArena_ -#define REMOTE_GlobalArena(wid) REMOTE(wid)->GlobalArena_ -#define LOCAL_GlobalArenaOverflows LOCAL->GlobalArenaOverflows_ -#define REMOTE_GlobalArenaOverflows(wid) REMOTE(wid)->GlobalArenaOverflows_ -#define LOCAL_ArenaOverflows LOCAL->ArenaOverflows_ -#define REMOTE_ArenaOverflows(wid) REMOTE(wid)->ArenaOverflows_ -#define LOCAL_DepthArenas LOCAL->DepthArenas_ -#define REMOTE_DepthArenas(wid) REMOTE(wid)->DepthArenas_ -#define LOCAL_LastAssertedPred LOCAL->LastAssertedPred_ -#define REMOTE_LastAssertedPred(wid) REMOTE(wid)->LastAssertedPred_ -#define LOCAL_TmpPred LOCAL->TmpPred_ -#define REMOTE_TmpPred(wid) REMOTE(wid)->TmpPred_ -#define LOCAL_ScannerStack LOCAL->ScannerStack_ -#define REMOTE_ScannerStack(wid) REMOTE(wid)->ScannerStack_ -#define LOCAL_ScannerExtraBlocks LOCAL->ScannerExtraBlocks_ -#define REMOTE_ScannerExtraBlocks(wid) REMOTE(wid)->ScannerExtraBlocks_ - - -#define LOCAL_CBorder LOCAL->CBorder_ -#define REMOTE_CBorder(wid) REMOTE(wid)->CBorder_ - -#define LOCAL_MaxActiveSignals LOCAL->MaxActiveSignals_ -#define REMOTE_MaxActiveSignals(wid) REMOTE(wid)->MaxActiveSignals_ - -#define LOCAL_Signals LOCAL->Signals_ -#define REMOTE_Signals(wid) REMOTE(wid)->Signals_ - -#define LOCAL_IPredArity LOCAL->IPredArity_ -#define REMOTE_IPredArity(wid) REMOTE(wid)->IPredArity_ -#define LOCAL_ProfEnd LOCAL->ProfEnd_ -#define REMOTE_ProfEnd(wid) REMOTE(wid)->ProfEnd_ -#define LOCAL_DoingUndefp LOCAL->DoingUndefp_ -#define REMOTE_DoingUndefp(wid) REMOTE(wid)->DoingUndefp_ -#define LOCAL_StartCharCount LOCAL->StartCharCount_ -#define REMOTE_StartCharCount(wid) REMOTE(wid)->StartCharCount_ -#define LOCAL_StartLineCount LOCAL->StartLineCount_ -#define REMOTE_StartLineCount(wid) REMOTE(wid)->StartLineCount_ -#define LOCAL_StartLinePos LOCAL->StartLinePos_ -#define REMOTE_StartLinePos(wid) REMOTE(wid)->StartLinePos_ -#define LOCAL_ScratchPad LOCAL->ScratchPad_ -#define REMOTE_ScratchPad(wid) REMOTE(wid)->ScratchPad_ -#ifdef COROUTINING -#define LOCAL_WokenGoals LOCAL->WokenGoals_ -#define REMOTE_WokenGoals(wid) REMOTE(wid)->WokenGoals_ -#define LOCAL_AttsMutableList LOCAL->AttsMutableList_ -#define REMOTE_AttsMutableList(wid) REMOTE(wid)->AttsMutableList_ -#endif - -#define LOCAL_GcGeneration LOCAL->GcGeneration_ -#define REMOTE_GcGeneration(wid) REMOTE(wid)->GcGeneration_ -#define LOCAL_GcPhase LOCAL->GcPhase_ -#define REMOTE_GcPhase(wid) REMOTE(wid)->GcPhase_ -#define LOCAL_GcCurrentPhase LOCAL->GcCurrentPhase_ -#define REMOTE_GcCurrentPhase(wid) REMOTE(wid)->GcCurrentPhase_ -#define LOCAL_GcCalls LOCAL->GcCalls_ -#define REMOTE_GcCalls(wid) REMOTE(wid)->GcCalls_ -#define LOCAL_TotGcTime LOCAL->TotGcTime_ -#define REMOTE_TotGcTime(wid) REMOTE(wid)->TotGcTime_ -#define LOCAL_TotGcRecovered LOCAL->TotGcRecovered_ -#define REMOTE_TotGcRecovered(wid) REMOTE(wid)->TotGcRecovered_ -#define LOCAL_LastGcTime LOCAL->LastGcTime_ -#define REMOTE_LastGcTime(wid) REMOTE(wid)->LastGcTime_ -#define LOCAL_LastSSTime LOCAL->LastSSTime_ -#define REMOTE_LastSSTime(wid) REMOTE(wid)->LastSSTime_ -#define LOCAL_OpenArray LOCAL->OpenArray_ -#define REMOTE_OpenArray(wid) REMOTE(wid)->OpenArray_ - -#define LOCAL_total_marked LOCAL->total_marked_ -#define REMOTE_total_marked(wid) REMOTE(wid)->total_marked_ -#define LOCAL_total_oldies LOCAL->total_oldies_ -#define REMOTE_total_oldies(wid) REMOTE(wid)->total_oldies_ -#define LOCAL_current_B LOCAL->current_B_ -#define REMOTE_current_B(wid) REMOTE(wid)->current_B_ -#define LOCAL_prev_HB LOCAL->prev_HB_ -#define REMOTE_prev_HB(wid) REMOTE(wid)->prev_HB_ -#define LOCAL_HGEN LOCAL->HGEN_ -#define REMOTE_HGEN(wid) REMOTE(wid)->HGEN_ -#define LOCAL_iptop LOCAL->iptop_ -#define REMOTE_iptop(wid) REMOTE(wid)->iptop_ -#if defined(GC_NO_TAGS) -#define LOCAL_bp LOCAL->bp_ -#define REMOTE_bp(wid) REMOTE(wid)->bp_ -#endif -#define LOCAL_sTR LOCAL->sTR_ -#define REMOTE_sTR(wid) REMOTE(wid)->sTR_ -#define LOCAL_sTR0 LOCAL->sTR0_ -#define REMOTE_sTR0(wid) REMOTE(wid)->sTR0_ -#define LOCAL_new_TR LOCAL->new_TR_ -#define REMOTE_new_TR(wid) REMOTE(wid)->new_TR_ -#define LOCAL_cont_top0 LOCAL->cont_top0_ -#define REMOTE_cont_top0(wid) REMOTE(wid)->cont_top0_ -#define LOCAL_cont_top LOCAL->cont_top_ -#define REMOTE_cont_top(wid) REMOTE(wid)->cont_top_ -#define LOCAL_discard_trail_entries LOCAL->discard_trail_entries_ -#define REMOTE_discard_trail_entries(wid) REMOTE(wid)->discard_trail_entries_ -#define LOCAL_gc_ma_hash_table LOCAL->gc_ma_hash_table_ -#define REMOTE_gc_ma_hash_table(wid) REMOTE(wid)->gc_ma_hash_table_ -#define LOCAL_gc_ma_h_top LOCAL->gc_ma_h_top_ -#define REMOTE_gc_ma_h_top(wid) REMOTE(wid)->gc_ma_h_top_ -#define LOCAL_gc_ma_h_list LOCAL->gc_ma_h_list_ -#define REMOTE_gc_ma_h_list(wid) REMOTE(wid)->gc_ma_h_list_ -#define LOCAL_gc_timestamp LOCAL->gc_timestamp_ -#define REMOTE_gc_timestamp(wid) REMOTE(wid)->gc_timestamp_ -#define LOCAL_db_vec LOCAL->db_vec_ -#define REMOTE_db_vec(wid) REMOTE(wid)->db_vec_ -#define LOCAL_db_vec0 LOCAL->db_vec0_ -#define REMOTE_db_vec0(wid) REMOTE(wid)->db_vec0_ -#define LOCAL_db_root LOCAL->db_root_ -#define REMOTE_db_root(wid) REMOTE(wid)->db_root_ -#define LOCAL_db_nil LOCAL->db_nil_ -#define REMOTE_db_nil(wid) REMOTE(wid)->db_nil_ -#define LOCAL_gc_restore LOCAL->gc_restore_ -#define REMOTE_gc_restore(wid) REMOTE(wid)->gc_restore_ -#define LOCAL_extra_gc_cells LOCAL->extra_gc_cells_ -#define REMOTE_extra_gc_cells(wid) REMOTE(wid)->extra_gc_cells_ -#define LOCAL_extra_gc_cells_base LOCAL->extra_gc_cells_base_ -#define REMOTE_extra_gc_cells_base(wid) REMOTE(wid)->extra_gc_cells_base_ -#define LOCAL_extra_gc_cells_top LOCAL->extra_gc_cells_top_ -#define REMOTE_extra_gc_cells_top(wid) REMOTE(wid)->extra_gc_cells_top_ -#define LOCAL_extra_gc_cells_size LOCAL->extra_gc_cells_size_ -#define REMOTE_extra_gc_cells_size(wid) REMOTE(wid)->extra_gc_cells_size_ -#define LOCAL_DynamicArrays LOCAL->DynamicArrays_ -#define REMOTE_DynamicArrays(wid) REMOTE(wid)->DynamicArrays_ -#define LOCAL_StaticArrays LOCAL->StaticArrays_ -#define REMOTE_StaticArrays(wid) REMOTE(wid)->StaticArrays_ -#define LOCAL_GlobalVariables LOCAL->GlobalVariables_ -#define REMOTE_GlobalVariables(wid) REMOTE(wid)->GlobalVariables_ -#define LOCAL_AllowRestart LOCAL->AllowRestart_ -#define REMOTE_AllowRestart(wid) REMOTE(wid)->AllowRestart_ - -#define LOCAL_CMemFirstBlock LOCAL->CMemFirstBlock_ -#define REMOTE_CMemFirstBlock(wid) REMOTE(wid)->CMemFirstBlock_ -#define LOCAL_CMemFirstBlockSz LOCAL->CMemFirstBlockSz_ -#define REMOTE_CMemFirstBlockSz(wid) REMOTE(wid)->CMemFirstBlockSz_ - -#define LOCAL_nperm LOCAL->nperm_ -#define REMOTE_nperm(wid) REMOTE(wid)->nperm_ -#define LOCAL_jMP LOCAL->jMP_ -#define REMOTE_jMP(wid) REMOTE(wid)->jMP_ - -#define LOCAL_LabelFirstArray LOCAL->LabelFirstArray_ -#define REMOTE_LabelFirstArray(wid) REMOTE(wid)->LabelFirstArray_ -#define LOCAL_LabelFirstArraySz LOCAL->LabelFirstArraySz_ -#define REMOTE_LabelFirstArraySz(wid) REMOTE(wid)->LabelFirstArraySz_ - - -#ifdef THREADS -#define LOCAL_ThreadHandle LOCAL->ThreadHandle_ -#define REMOTE_ThreadHandle(wid) REMOTE(wid)->ThreadHandle_ -#endif /* THREADS */ -#if defined(YAPOR) || defined(TABLING) -#define LOCAL_optyap_data LOCAL->optyap_data_ -#define REMOTE_optyap_data(wid) REMOTE(wid)->optyap_data_ -#define LOCAL_TabMode LOCAL->TabMode_ -#define REMOTE_TabMode(wid) REMOTE(wid)->TabMode_ -#endif /* YAPOR || TABLING */ -#define LOCAL_InterruptsDisabled LOCAL->InterruptsDisabled_ -#define REMOTE_InterruptsDisabled(wid) REMOTE(wid)->InterruptsDisabled_ -#define LOCAL_execution LOCAL->execution_ -#define REMOTE_execution(wid) REMOTE(wid)->execution_ -#if LOW_LEVEL_TRACER -#define LOCAL_total_choicepoints LOCAL->total_choicepoints_ -#define REMOTE_total_choicepoints(wid) REMOTE(wid)->total_choicepoints_ -#endif -#define LOCAL_consult_level LOCAL->consult_level_ -#define REMOTE_consult_level(wid) REMOTE(wid)->consult_level_ - -#define LOCAL_LocalBase LOCAL->LocalBase_ -#define REMOTE_LocalBase(wid) REMOTE(wid)->LocalBase_ -#define LOCAL_GlobalBase LOCAL->GlobalBase_ -#define REMOTE_GlobalBase(wid) REMOTE(wid)->GlobalBase_ -#define LOCAL_TrailBase LOCAL->TrailBase_ -#define REMOTE_TrailBase(wid) REMOTE(wid)->TrailBase_ -#define LOCAL_TrailTop LOCAL->TrailTop_ -#define REMOTE_TrailTop(wid) REMOTE(wid)->TrailTop_ - -#define LOCAL_ActiveError LOCAL->ActiveError_ -#define REMOTE_ActiveError(wid) REMOTE(wid)->ActiveError_ - -#define LOCAL_IOBotch LOCAL->IOBotch_ -#define REMOTE_IOBotch(wid) REMOTE(wid)->IOBotch_ -#define LOCAL_tokptr LOCAL->tokptr_ -#define REMOTE_tokptr(wid) REMOTE(wid)->tokptr_ -#define LOCAL_toktide LOCAL->toktide_ -#define REMOTE_toktide(wid) REMOTE(wid)->toktide_ -#define LOCAL_VarTable LOCAL->VarTable_ -#define REMOTE_VarTable(wid) REMOTE(wid)->VarTable_ -#define LOCAL_AnonVarTable LOCAL->AnonVarTable_ -#define REMOTE_AnonVarTable(wid) REMOTE(wid)->AnonVarTable_ -#define LOCAL_Comments LOCAL->Comments_ -#define REMOTE_Comments(wid) REMOTE(wid)->Comments_ -#define LOCAL_CommentsTail LOCAL->CommentsTail_ -#define REMOTE_CommentsTail(wid) REMOTE(wid)->CommentsTail_ -#define LOCAL_CommentsNextChar LOCAL->CommentsNextChar_ -#define REMOTE_CommentsNextChar(wid) REMOTE(wid)->CommentsNextChar_ -#define LOCAL_CommentsBuff LOCAL->CommentsBuff_ -#define REMOTE_CommentsBuff(wid) REMOTE(wid)->CommentsBuff_ -#define LOCAL_CommentsBuffPos LOCAL->CommentsBuffPos_ -#define REMOTE_CommentsBuffPos(wid) REMOTE(wid)->CommentsBuffPos_ -#define LOCAL_CommentsBuffLim LOCAL->CommentsBuffLim_ -#define REMOTE_CommentsBuffLim(wid) REMOTE(wid)->CommentsBuffLim_ -#define LOCAL_RestartEnv LOCAL->RestartEnv_ -#define REMOTE_RestartEnv(wid) REMOTE(wid)->RestartEnv_ -#define LOCAL_FileNameBuf LOCAL->FileNameBuf_ -#define REMOTE_FileNameBuf(wid) REMOTE(wid)->FileNameBuf_ -#define LOCAL_FileNameBuf2 LOCAL->FileNameBuf2_ -#define REMOTE_FileNameBuf2(wid) REMOTE(wid)->FileNameBuf2_ -#define LOCAL_TextBuffer LOCAL->TextBuffer_ -#define REMOTE_TextBuffer(wid) REMOTE(wid)->TextBuffer_ - -#define LOCAL_BreakLevel LOCAL->BreakLevel_ -#define REMOTE_BreakLevel(wid) REMOTE(wid)->BreakLevel_ -#define LOCAL_PrologMode LOCAL->PrologMode_ -#define REMOTE_PrologMode(wid) REMOTE(wid)->PrologMode_ -#define LOCAL_CritLocks LOCAL->CritLocks_ -#define REMOTE_CritLocks(wid) REMOTE(wid)->CritLocks_ - -#define LOCAL_Flags LOCAL->Flags_ -#define REMOTE_Flags(wid) REMOTE(wid)->Flags_ -#define LOCAL_flagCount LOCAL->flagCount_ -#define REMOTE_flagCount(wid) REMOTE(wid)->flagCount_ - - -#ifdef ANALYST -#define LOCAL_opcount LOCAL->opcount_ -#define REMOTE_opcount(wid) REMOTE(wid)->opcount_ -#define LOCAL_2opcount LOCAL->2opcount_ -#define REMOTE_2opcount(wid) REMOTE(wid)->2opcount_ -#endif /* ANALYST */ - -#define LOCAL_s_dbg LOCAL->s_dbg_ -#define REMOTE_s_dbg(wid) REMOTE(wid)->s_dbg_ - -#define LOCAL_mathtt LOCAL->mathtt_ -#define REMOTE_mathtt(wid) REMOTE(wid)->mathtt_ -#define LOCAL_mathstring LOCAL->mathstring_ -#define REMOTE_mathstring(wid) REMOTE(wid)->mathstring_ - -#define LOCAL_heap_overflows LOCAL->heap_overflows_ -#define REMOTE_heap_overflows(wid) REMOTE(wid)->heap_overflows_ -#define LOCAL_total_heap_overflow_time LOCAL->total_heap_overflow_time_ -#define REMOTE_total_heap_overflow_time(wid) REMOTE(wid)->total_heap_overflow_time_ -#define LOCAL_stack_overflows LOCAL->stack_overflows_ -#define REMOTE_stack_overflows(wid) REMOTE(wid)->stack_overflows_ -#define LOCAL_total_stack_overflow_time LOCAL->total_stack_overflow_time_ -#define REMOTE_total_stack_overflow_time(wid) REMOTE(wid)->total_stack_overflow_time_ -#define LOCAL_delay_overflows LOCAL->delay_overflows_ -#define REMOTE_delay_overflows(wid) REMOTE(wid)->delay_overflows_ -#define LOCAL_total_delay_overflow_time LOCAL->total_delay_overflow_time_ -#define REMOTE_total_delay_overflow_time(wid) REMOTE(wid)->total_delay_overflow_time_ -#define LOCAL_trail_overflows LOCAL->trail_overflows_ -#define REMOTE_trail_overflows(wid) REMOTE(wid)->trail_overflows_ -#define LOCAL_total_trail_overflow_time LOCAL->total_trail_overflow_time_ -#define REMOTE_total_trail_overflow_time(wid) REMOTE(wid)->total_trail_overflow_time_ -#define LOCAL_atom_table_overflows LOCAL->atom_table_overflows_ -#define REMOTE_atom_table_overflows(wid) REMOTE(wid)->atom_table_overflows_ -#define LOCAL_total_atom_table_overflow_time LOCAL->total_atom_table_overflow_time_ -#define REMOTE_total_atom_table_overflow_time(wid) REMOTE(wid)->total_atom_table_overflow_time_ - -#ifdef LOAD_DYLD -#define LOCAL_dl_errno LOCAL->dl_errno_ -#define REMOTE_dl_errno(wid) REMOTE(wid)->dl_errno_ -#endif - -#ifdef LOW_LEVEL_TRACER -#define LOCAL_do_trace_primitives LOCAL->do_trace_primitives_ -#define REMOTE_do_trace_primitives(wid) REMOTE(wid)->do_trace_primitives_ -#endif - -#define LOCAL_ExportAtomHashChain LOCAL->ExportAtomHashChain_ -#define REMOTE_ExportAtomHashChain(wid) REMOTE(wid)->ExportAtomHashChain_ -#define LOCAL_ExportAtomHashTableSize LOCAL->ExportAtomHashTableSize_ -#define REMOTE_ExportAtomHashTableSize(wid) REMOTE(wid)->ExportAtomHashTableSize_ -#define LOCAL_ExportAtomHashTableNum LOCAL->ExportAtomHashTableNum_ -#define REMOTE_ExportAtomHashTableNum(wid) REMOTE(wid)->ExportAtomHashTableNum_ -#define LOCAL_ExportFunctorHashChain LOCAL->ExportFunctorHashChain_ -#define REMOTE_ExportFunctorHashChain(wid) REMOTE(wid)->ExportFunctorHashChain_ -#define LOCAL_ExportFunctorHashTableSize LOCAL->ExportFunctorHashTableSize_ -#define REMOTE_ExportFunctorHashTableSize(wid) REMOTE(wid)->ExportFunctorHashTableSize_ -#define LOCAL_ExportFunctorHashTableNum LOCAL->ExportFunctorHashTableNum_ -#define REMOTE_ExportFunctorHashTableNum(wid) REMOTE(wid)->ExportFunctorHashTableNum_ -#define LOCAL_ExportPredEntryHashChain LOCAL->ExportPredEntryHashChain_ -#define REMOTE_ExportPredEntryHashChain(wid) REMOTE(wid)->ExportPredEntryHashChain_ -#define LOCAL_ExportPredEntryHashTableSize LOCAL->ExportPredEntryHashTableSize_ -#define REMOTE_ExportPredEntryHashTableSize(wid) REMOTE(wid)->ExportPredEntryHashTableSize_ -#define LOCAL_ExportPredEntryHashTableNum LOCAL->ExportPredEntryHashTableNum_ -#define REMOTE_ExportPredEntryHashTableNum(wid) REMOTE(wid)->ExportPredEntryHashTableNum_ -#define LOCAL_ExportDBRefHashChain LOCAL->ExportDBRefHashChain_ -#define REMOTE_ExportDBRefHashChain(wid) REMOTE(wid)->ExportDBRefHashChain_ -#define LOCAL_ExportDBRefHashTableSize LOCAL->ExportDBRefHashTableSize_ -#define REMOTE_ExportDBRefHashTableSize(wid) REMOTE(wid)->ExportDBRefHashTableSize_ -#define LOCAL_ExportDBRefHashTableNum LOCAL->ExportDBRefHashTableNum_ -#define REMOTE_ExportDBRefHashTableNum(wid) REMOTE(wid)->ExportDBRefHashTableNum_ -#define LOCAL_ImportAtomHashChain LOCAL->ImportAtomHashChain_ -#define REMOTE_ImportAtomHashChain(wid) REMOTE(wid)->ImportAtomHashChain_ -#define LOCAL_ImportAtomHashTableSize LOCAL->ImportAtomHashTableSize_ -#define REMOTE_ImportAtomHashTableSize(wid) REMOTE(wid)->ImportAtomHashTableSize_ -#define LOCAL_ImportAtomHashTableNum LOCAL->ImportAtomHashTableNum_ -#define REMOTE_ImportAtomHashTableNum(wid) REMOTE(wid)->ImportAtomHashTableNum_ -#define LOCAL_ImportFunctorHashChain LOCAL->ImportFunctorHashChain_ -#define REMOTE_ImportFunctorHashChain(wid) REMOTE(wid)->ImportFunctorHashChain_ -#define LOCAL_ImportFunctorHashTableSize LOCAL->ImportFunctorHashTableSize_ -#define REMOTE_ImportFunctorHashTableSize(wid) REMOTE(wid)->ImportFunctorHashTableSize_ -#define LOCAL_ImportFunctorHashTableNum LOCAL->ImportFunctorHashTableNum_ -#define REMOTE_ImportFunctorHashTableNum(wid) REMOTE(wid)->ImportFunctorHashTableNum_ -#define LOCAL_ImportOPCODEHashChain LOCAL->ImportOPCODEHashChain_ -#define REMOTE_ImportOPCODEHashChain(wid) REMOTE(wid)->ImportOPCODEHashChain_ -#define LOCAL_ImportOPCODEHashTableSize LOCAL->ImportOPCODEHashTableSize_ -#define REMOTE_ImportOPCODEHashTableSize(wid) REMOTE(wid)->ImportOPCODEHashTableSize_ -#define LOCAL_ImportPredEntryHashChain LOCAL->ImportPredEntryHashChain_ -#define REMOTE_ImportPredEntryHashChain(wid) REMOTE(wid)->ImportPredEntryHashChain_ -#define LOCAL_ImportPredEntryHashTableSize LOCAL->ImportPredEntryHashTableSize_ -#define REMOTE_ImportPredEntryHashTableSize(wid) REMOTE(wid)->ImportPredEntryHashTableSize_ -#define LOCAL_ImportPredEntryHashTableNum LOCAL->ImportPredEntryHashTableNum_ -#define REMOTE_ImportPredEntryHashTableNum(wid) REMOTE(wid)->ImportPredEntryHashTableNum_ -#define LOCAL_ImportDBRefHashChain LOCAL->ImportDBRefHashChain_ -#define REMOTE_ImportDBRefHashChain(wid) REMOTE(wid)->ImportDBRefHashChain_ -#define LOCAL_ImportDBRefHashTableSize LOCAL->ImportDBRefHashTableSize_ -#define REMOTE_ImportDBRefHashTableSize(wid) REMOTE(wid)->ImportDBRefHashTableSize_ -#define LOCAL_ImportDBRefHashTableNum LOCAL->ImportDBRefHashTableNum_ -#define REMOTE_ImportDBRefHashTableNum(wid) REMOTE(wid)->ImportDBRefHashTableNum_ -#define LOCAL_ImportFAILCODE LOCAL->ImportFAILCODE_ -#define REMOTE_ImportFAILCODE(wid) REMOTE(wid)->ImportFAILCODE_ - -#define LOCAL_ibnds LOCAL->ibnds_ -#define REMOTE_ibnds(wid) REMOTE(wid)->ibnds_ -#define LOCAL_exo_it LOCAL->exo_it_ -#define REMOTE_exo_it(wid) REMOTE(wid)->exo_it_ -#define LOCAL_exo_base LOCAL->exo_base_ -#define REMOTE_exo_base(wid) REMOTE(wid)->exo_base_ -#define LOCAL_exo_arity LOCAL->exo_arity_ -#define REMOTE_exo_arity(wid) REMOTE(wid)->exo_arity_ -#define LOCAL_exo_arg LOCAL->exo_arg_ -#define REMOTE_exo_arg(wid) REMOTE(wid)->exo_arg_ - -#define LOCAL_search_atoms LOCAL->search_atoms_ -#define REMOTE_search_atoms(wid) REMOTE(wid)->search_atoms_ -#define LOCAL_SearchPreds LOCAL->SearchPreds_ -#define REMOTE_SearchPreds(wid) REMOTE(wid)->SearchPreds_ - -#define LOCAL_CurSlot LOCAL->CurSlot_ -#define REMOTE_CurSlot(wid) REMOTE(wid)->CurSlot_ -#define LOCAL_FrozenHandles LOCAL->FrozenHandles_ -#define REMOTE_FrozenHandles(wid) REMOTE(wid)->FrozenHandles_ -#define LOCAL_NSlots LOCAL->NSlots_ -#define REMOTE_NSlots(wid) REMOTE(wid)->NSlots_ -#define LOCAL_SlotBase LOCAL->SlotBase_ -#define REMOTE_SlotBase(wid) REMOTE(wid)->SlotBase_ - -#define LOCAL_Mutexes LOCAL->Mutexes_ -#define REMOTE_Mutexes(wid) REMOTE(wid)->Mutexes_ -#define LOCAL_SourceModule LOCAL->SourceModule_ -#define REMOTE_SourceModule(wid) REMOTE(wid)->SourceModule_ -#define LOCAL_Including LOCAL->Including_ -#define REMOTE_Including(wid) REMOTE(wid)->Including_ -#define LOCAL_MAX_SIZE LOCAL->MAX_SIZE_ -#define REMOTE_MAX_SIZE(wid) REMOTE(wid)->MAX_SIZE_ - -#define LOCAL_LastWTime LOCAL->LastWTime_ -#define REMOTE_LastWTime(wid) REMOTE(wid)->LastWTime_ -#define LOCAL_shared LOCAL->shared_ -#define REMOTE_shared(wid) REMOTE(wid)->shared_ - diff --git a/H/generated/h0globals.h b/H/generated/h0globals.h index bf70ea08b..ed6a749b1 100644 --- a/H/generated/h0globals.h +++ b/H/generated/h0globals.h @@ -100,7 +100,7 @@ EXTERNAL YP_FILE* GLOBAL_logfile; EXTERNAL char GLOBAL_Executable[YAP_FILENAME_MAX]; #endif EXTERNAL int GLOBAL_OpaqueHandlersCount; -EXTERNAL struct opaque_handler_struct* GLOBAL_OpaqueHandlers; +EXTERNAL struct YAP_opaque_handler_struct* GLOBAL_OpaqueHandlers; #if __simplescalar__ EXTERNAL char GLOBAL_pwd[YAP_FILENAME_MAX]; #endif @@ -141,4 +141,5 @@ EXTERNAL struct AliasDescS* GLOBAL_FileAliases; EXTERNAL int GLOBAL_NOfFileAliases; EXTERNAL int GLOBAL_SzOfFileAliases; EXTERNAL struct vfs* GLOBAL_VFS; +EXTERNAL char* GLOBAL_cwd; diff --git a/H/generated/h0struct.h b/H/generated/h0struct.h index d3a8ee61f..b405ecc25 100644 --- a/H/generated/h0struct.h +++ b/H/generated/h0struct.h @@ -87,7 +87,6 @@ EXTERNAL AtomHashEntry *HashChain; #ifdef EUROTRA EXTERNAL Term TermDollarU; #endif -EXTERNAL Term TermAnswer; //modules EXTERNAL Term USER_MODULE; EXTERNAL Term IDB_MODULE; @@ -146,6 +145,7 @@ EXTERNAL struct pred_entry *PredIs; EXTERNAL struct pred_entry *PredLogUpdClause; EXTERNAL struct pred_entry *PredLogUpdClauseErase; EXTERNAL struct pred_entry *PredLogUpdClause0; +EXTERNAL struct pred_entry *PredCall; EXTERNAL struct pred_entry *PredMetaCall; EXTERNAL struct pred_entry *PredProtectStack; EXTERNAL struct pred_entry *PredRecordedWithKey; @@ -156,6 +156,7 @@ EXTERNAL struct pred_entry *PredThrow; EXTERNAL struct pred_entry *PredTraceMetaCall; EXTERNAL struct pred_entry *PredCommentHook; EXTERNAL struct pred_entry *PredProcedure; +EXTERNAL struct pred_entry *PredUndefinedQuery; /* low-level tracer */ #ifdef LOW_LEVEL_TRACER EXTERNAL int Yap_do_low_level_trace; @@ -273,6 +274,8 @@ EXTERNAL int NUM_OF_ATTS; /* initialised by memory allocator */ EXTERNAL UInt Yap_AttsSize; #endif +/** opaque terms used to wake up on cut of call catcher meta-goal */ +EXTERNAL UInt setup_call_catcher_cleanup_tag; /* Operators */ EXTERNAL struct operator_entry *OpList; /* foreign code loaded */ @@ -285,7 +288,7 @@ EXTERNAL struct record_list *Yap_Records; EXTERNAL Atom EmptyWakeups[MAX_EMPTY_WAKEUPS]; EXTERNAL int MaxEmptyWakeups; /* SWI blobs */ -EXTERNAL struct YAP_blob_t *BlobTypes; +EXTERNAL struct _PL_blob_t *BlobTypes; EXTERNAL struct AtomEntryStruct *Blobs; EXTERNAL UInt NOfBlobs; EXTERNAL UInt NOfBlobsMax; diff --git a/H/generated/hglobals.h b/H/generated/hglobals.h index cf351dc14..ef865f02e 100644 --- a/H/generated/hglobals.h +++ b/H/generated/hglobals.h @@ -100,7 +100,7 @@ typedef struct global_data { char Executable_[YAP_FILENAME_MAX]; #endif int OpaqueHandlersCount_; - struct opaque_handler_struct* OpaqueHandlers_; + struct YAP_opaque_handler_struct* OpaqueHandlers_; #if __simplescalar__ char pwd_[YAP_FILENAME_MAX]; #endif @@ -141,4 +141,5 @@ const char* RestoreFile_; int NOfFileAliases_; int SzOfFileAliases_; struct vfs* VFS_; + char* cwd_; } w_shared; diff --git a/H/generated/hlocals.h b/H/generated/hlocals.h index 470a84605..b52562b2e 100644 --- a/H/generated/hlocals.h +++ b/H/generated/hlocals.h @@ -1,272 +1,24 @@ - /* This file, hlocals.h, was generated automatically by "yap -L misc/buildlocalglobal" - please do not update, update H/LOCALS instead */ +#ifndef DLOCALS_H +#define DLOCALS_H -// Stuff that must be considered local to a thread or worker -typedef struct worker_local { -// Streams - int c_input_stream_; - int c_output_stream_; - int c_error_stream_; - bool sockets_io_; - bool within_print_message_; -// -// Used by the prompts to check if they are after a newline, and then a -// prompt should be output, or if we are in the middle of a line. -// - bool newline_; - Atom AtPrompt_; - char Prompt_[MAX_PROMPT+1]; - encoding_t encoding_; - bool quasi_quotations_; - UInt default_priority_; - bool eot_before_eof_; - UInt max_depth_; - UInt max_list_; - UInt max_write_args_; -// Restore info - CELL* OldASP_; - CELL* OldLCL0_; - tr_fr_ptr OldTR_; - CELL* OldGlobalBase_; - CELL* OldH_; - CELL* OldH0_; - ADDR OldTrailBase_; - ADDR OldTrailTop_; - ADDR OldHeapBase_; - ADDR OldHeapTop_; - Int ClDiff_; - Int GDiff_; - Int HDiff_; - Int GDiff0_; - CELL* GSplit_; - Int LDiff_; - Int TrDiff_; - Int XDiff_; - Int DelayDiff_; - Int BaseDiff_; -// Reduction counters - YAP_ULONG_LONG ReductionsCounter_; - YAP_ULONG_LONG PredEntriesCounter_; - YAP_ULONG_LONG RetriesCounter_; - int ReductionsCounterOn_; - int PredEntriesCounterOn_; - int RetriesCounterOn_; -// support for consulting files -/* current consult stack */ - union CONSULT_OBJ* ConsultSp_; -/* current maximum number of cells in consult stack */ - UInt ConsultCapacity_; -/* top of consult stack */ - union CONSULT_OBJ* ConsultBase_; -/* low-water mark for consult */ - union CONSULT_OBJ* ConsultLow_; - Term VarNames_; - Atom SourceFileName_; - UInt SourceFileLineno_; -//global variables - Term GlobalArena_; - UInt GlobalArenaOverflows_; - Int ArenaOverflows_; - Int DepthArenas_; - struct pred_entry* LastAssertedPred_; - struct pred_entry* TmpPred_; - char* ScannerStack_; - struct scanner_extra_alloc* ScannerExtraBlocks_; -/// worker control information -/// stack limit after which the stack is managed by C-code. - Int CBorder_; -/// max number of signals (uint64_t) - UInt MaxActiveSignals_; -/// actual life signals - uint64_t Signals_; -/// indexing help data? - UInt IPredArity_; - yamop* ProfEnd_; - int DoingUndefp_; - Int StartCharCount_; - Int StartLineCount_; - Int StartLinePos_; - scratch_block ScratchPad_; -#ifdef COROUTINING - Term WokenGoals_; - Term AttsMutableList_; -#endif -// gc_stuff - Term GcGeneration_; - Term GcPhase_; - UInt GcCurrentPhase_; - UInt GcCalls_; - Int TotGcTime_; - YAP_ULONG_LONG TotGcRecovered_; - Int LastGcTime_; - Int LastSSTime_; - CELL* OpenArray_; -/* in a single gc */ - Int total_marked_; - Int total_oldies_; - struct choicept* current_B_; - CELL* prev_HB_; - CELL* HGEN_; - CELL** iptop_; -#if defined(GC_NO_TAGS) - char* bp_; -#endif - tr_fr_ptr sTR_; - tr_fr_ptr sTR0_; - tr_fr_ptr new_TR_; - struct gc_mark_continuation* cont_top0_; - struct gc_mark_continuation* cont_top_; - int discard_trail_entries_; - gc_ma_hash_entry gc_ma_hash_table_[GC_MAVARS_HASH_SIZE]; - gc_ma_hash_entry* gc_ma_h_top_; - gc_ma_hash_entry* gc_ma_h_list_; - UInt gc_timestamp_; - ADDR db_vec_; - ADDR db_vec0_; - struct RB_red_blk_node* db_root_; - struct RB_red_blk_node* db_nil_; - sigjmp_buf* gc_restore_; - CELL* extra_gc_cells_; - CELL* extra_gc_cells_base_; - CELL* extra_gc_cells_top_; - UInt extra_gc_cells_size_; - struct array_entry* DynamicArrays_; - struct static_array_entry* StaticArrays_; - struct global_entry* GlobalVariables_; - int AllowRestart_; -// Thread Local Area for Fast Storage of Intermediate Compiled Code - struct mem_blk* CMemFirstBlock_; - UInt CMemFirstBlockSz_; -// Variable used by the compiler to store number of permanent vars in a clause - int nperm_; - int jMP_; -// Thread Local Area for Labels - Int* LabelFirstArray_; - UInt LabelFirstArraySz_; -// Thread Local Area for SWI-Prolog emulation routines. -// struct PL_local_data* PL_local_data_p =Yap_InitThreadIO(wid) -#ifdef THREADS - struct thandle ThreadHandle_; -#endif /* THREADS */ -#if defined(YAPOR) || defined(TABLING) - struct local_optyap_data optyap_data_; - UInt TabMode_; -#endif /* YAPOR || TABLING */ - int InterruptsDisabled_; - struct open_query_struct* execution_; -#if LOW_LEVEL_TRACER - Int total_choicepoints_; -#endif - int consult_level_; -// Variables related to memory allocation - ADDR LocalBase_; - ADDR GlobalBase_; - ADDR TrailBase_; - ADDR TrailTop_; -/* error handling info, designed to be easy to pass to the foreign world */ - yap_error_descriptor_t* ActiveError_; -/// pointer to an exception term, from throw - jmp_buf* IOBotch_; - TokEntry* tokptr_; - TokEntry* toktide_; - VarEntry* VarTable_; - VarEntry* AnonVarTable_; - Term Comments_; - CELL* CommentsTail_; - CELL* CommentsNextChar_; - wchar_t* CommentsBuff_; - size_t CommentsBuffPos_; - size_t CommentsBuffLim_; - sigjmp_buf* RestartEnv_; - char FileNameBuf_[YAP_FILENAME_MAX+1]; - char FileNameBuf2_[YAP_FILENAME_MAX+1]; - struct TextBuffer_manager* TextBuffer_; -// Prolog State - UInt BreakLevel_; - Int PrologMode_; - int CritLocks_; -// Prolog execution and state flags - union flagTerm* Flags_; - UInt flagCount_; -//analyst.c -/* used to find out how many instructions of each kind are executed */ -#ifdef ANALYST - YAP_ULONG_LONG opcount_[_std_top+1]; - YAP_ULONG_LONG 2opcount[_std_top+1][_std_top+1]_; -#endif /* ANALYST */ -//dbase.c - struct db_globs* s_dbg_; -//eval.c - Term mathtt_; - char* mathstring_; -//grow.c - int heap_overflows_; - Int total_heap_overflow_time_; - int stack_overflows_; - Int total_stack_overflow_time_; - int delay_overflows_; - Int total_delay_overflow_time_; - int trail_overflows_; - Int total_trail_overflow_time_; - int atom_table_overflows_; - Int total_atom_table_overflow_time_; -//load_dyld -#ifdef LOAD_DYLD - int dl_errno_; -#endif -//tracer.c -#ifdef LOW_LEVEL_TRACER - int do_trace_primitives_; -#endif -//quick loader - struct export_atom_hash_entry_struct *ExportAtomHashChain_; - UInt ExportAtomHashTableSize_; - UInt ExportAtomHashTableNum_; - struct export_functor_hash_entry_struct *ExportFunctorHashChain_; - UInt ExportFunctorHashTableSize_; - UInt ExportFunctorHashTableNum_; - struct export_pred_entry_hash_entry_struct *ExportPredEntryHashChain_; - UInt ExportPredEntryHashTableSize_; - UInt ExportPredEntryHashTableNum_; - struct export_dbref_hash_entry_struct *ExportDBRefHashChain_; - UInt ExportDBRefHashTableSize_; - UInt ExportDBRefHashTableNum_; - struct import_atom_hash_entry_struct **ImportAtomHashChain_; - UInt ImportAtomHashTableSize_; - UInt ImportAtomHashTableNum_; - struct import_functor_hash_entry_struct **ImportFunctorHashChain_; - UInt ImportFunctorHashTableSize_; - UInt ImportFunctorHashTableNum_; - struct import_opcode_hash_entry_struct **ImportOPCODEHashChain_; - UInt ImportOPCODEHashTableSize_; - struct import_pred_entry_hash_entry_struct **ImportPredEntryHashChain_; - UInt ImportPredEntryHashTableSize_; - UInt ImportPredEntryHashTableNum_; - struct import_dbref_hash_entry_struct **ImportDBRefHashChain_; - UInt ImportDBRefHashTableSize_; - UInt ImportDBRefHashTableNum_; - yamop *ImportFAILCODE_; -// exo indexing - UInt ibnds_[256]; - struct index_t* exo_it_; - CELL* exo_base_; - UInt exo_arity_; - UInt exo_arg_; -// atom completion - struct scan_atoms* search_atoms_; - struct pred_entry* SearchPreds_; -/// Slots Status - yhandle_t CurSlot_; - yhandle_t FrozenHandles_; - yhandle_t NSlots_; - CELL* SlotBase_; -// Mutexes - struct swi_mutex* Mutexes_; - Term SourceModule_; - Term Including_; - size_t MAX_SIZE_; -/* last call to walltime. */ - uint64_t LastWTime_; - void* shared_; +#undef LOCAL +#undef LOCAL_INIT +#undef LOCAL_INITF +#undef LOCAL_INIT_RESTORE +#undef LOCAL_ARRAY +#undef LOCAL_ARRAY_ARRAY + +#define LOCAL(TYPE, NAME) TYPE NAME +#define LOCAL_INIT(TYPE, NAME, INIT) TYPE NAME +#define LOCAL_INITF(TYPE, NAME, INIT) TYPE NAME +#define LOCAL_INIT_RESTORE(TYPE, NAME, INIT, RESTORE) TYPE NAME +#define LOCAL_ARRAY(TYPE, NAME, DIM1) TYPE NAME [ DIM1 ] +#define LOCAL_ARRAY_ARRAY(TYPE, NAME, DIM1, DIM2) TYPE NAME [ DIM1 ][ DIM2 ] + + // Stuff that must be considered local to a thread or worker + typedef struct worker_local { +#include "locals.h" } w_local; + +#endif diff --git a/H/generated/hstruct.h b/H/generated/hstruct.h index 863b7e35e..e62f90698 100755 --- a/H/generated/hstruct.h +++ b/H/generated/hstruct.h @@ -87,7 +87,6 @@ #ifdef EUROTRA Term TermDollarU_; #endif - Term TermAnswer_; //modules Term USER_MODULE_; Term IDB_MODULE_; @@ -146,6 +145,7 @@ struct pred_entry *PredLogUpdClause_; struct pred_entry *PredLogUpdClauseErase_; struct pred_entry *PredLogUpdClause0_; + struct pred_entry *PredCall_; struct pred_entry *PredMetaCall_; struct pred_entry *PredProtectStack_; struct pred_entry *PredRecordedWithKey_; @@ -156,6 +156,7 @@ struct pred_entry *PredTraceMetaCall_; struct pred_entry *PredCommentHook_; struct pred_entry *PredProcedure_; + struct pred_entry *PredUndefinedQuery_; /* low-level tracer */ #ifdef LOW_LEVEL_TRACER int Yap_do_low_level_trace_; @@ -273,6 +274,8 @@ /* initialised by memory allocator */ UInt Yap_AttsSize_; #endif +/** opaque terms used to wake up on cut of call catcher meta-goal */ + UInt setup_call_catcher_cleanup_tag_; /* Operators */ struct operator_entry *OpList_; /* foreign code loaded */ @@ -285,7 +288,7 @@ Atom EmptyWakeups_[MAX_EMPTY_WAKEUPS]; int MaxEmptyWakeups_; /* SWI blobs */ - struct YAP_blob_t *BlobTypes_; + struct _PL_blob_t *BlobTypes_; struct AtomEntryStruct *Blobs_; UInt NOfBlobs_; UInt NOfBlobsMax_; diff --git a/H/generated/iatoms.h b/H/generated/iatoms.h index 180728605..0863a5e7c 100644 --- a/H/generated/iatoms.h +++ b/H/generated/iatoms.h @@ -1,584 +1,602 @@ - - /* This file, iatoms.h, was generated automatically by "yap -L misc/buildatoms" - {lease do not update, update misc/ATOMS instead */ - - Atom3Dots = Yap_LookupAtom("..."); - AtomAbol = Yap_FullLookupAtom("$abol"); TermAbol = MkAtomTerm(AtomAbol); - AtomAccess = Yap_LookupAtom("access"); TermAccess = MkAtomTerm(AtomAccess); - AtomAfInet = Yap_LookupAtom("AF_INET"); TermAfInet = MkAtomTerm(AtomAfInet); - AtomAfLocal = Yap_LookupAtom("AF_LOCAL"); TermAfLocal = MkAtomTerm(AtomAfLocal); - AtomAfUnix = Yap_LookupAtom("AF_UNIX"); TermAfUnix = MkAtomTerm(AtomAfUnix); - AtomAlarm = Yap_FullLookupAtom("$alarm"); TermAlarm = MkAtomTerm(AtomAlarm); - AtomAlias = Yap_LookupAtom("alias"); TermAlias = MkAtomTerm(AtomAlias); - AtomAll = Yap_LookupAtom("all"); TermAll = MkAtomTerm(AtomAll); - AtomAltNot = Yap_LookupAtom("not"); TermAltNot = MkAtomTerm(AtomAltNot); - AtomAnswer = Yap_LookupAtom("answer"); TermAnswer = MkAtomTerm(AtomAnswer); - AtomAny = Yap_LookupAtom("any"); TermAny = MkAtomTerm(AtomAny); - AtomAppend = Yap_LookupAtom("append"); TermAppend = MkAtomTerm(AtomAppend); - AtomArg = Yap_LookupAtom("arg"); TermArg = MkAtomTerm(AtomArg); - AtomArray = Yap_FullLookupAtom("$array"); TermArray = MkAtomTerm(AtomArray); - AtomArrayAccess = Yap_FullLookupAtom("$array_arg"); TermArrayAccess = MkAtomTerm(AtomArrayAccess); - AtomArrayOverflow = Yap_LookupAtom("array_overflow"); TermArrayOverflow = MkAtomTerm(AtomArrayOverflow); - AtomArrayType = Yap_LookupAtom("array_type"); TermArrayType = MkAtomTerm(AtomArrayType); - AtomArrow = Yap_LookupAtom("->"); TermArrow = MkAtomTerm(AtomArrow); - AtomAttributedModule = Yap_LookupAtom("attributes_module"); TermAttributedModule = MkAtomTerm(AtomAttributedModule); - AtomDoubleArrow = Yap_LookupAtom("-->"); TermDoubleArrow = MkAtomTerm(AtomDoubleArrow); - AtomAssert = Yap_LookupAtom(":-"); TermAssert = MkAtomTerm(AtomAssert); - AtomBeginBracket = Yap_LookupAtom("("); TermBeginBracket = MkAtomTerm(AtomBeginBracket); - AtomEndBracket = Yap_LookupAtom(")"); TermEndBracket = MkAtomTerm(AtomEndBracket); - AtomBeginSquareBracket = Yap_LookupAtom("["); TermBeginSquareBracket = MkAtomTerm(AtomBeginSquareBracket); - AtomEndSquareBracket = Yap_LookupAtom("]"); TermEndSquareBracket = MkAtomTerm(AtomEndSquareBracket); - AtomBeginCurlyBracket = Yap_LookupAtom("{"); TermBeginCurlyBracket = MkAtomTerm(AtomBeginCurlyBracket); - AtomEndCurlyBracket = Yap_LookupAtom("}"); TermEndCurlyBracket = MkAtomTerm(AtomEndCurlyBracket); - AtomEmptyBrackets = Yap_LookupAtom("()"); TermEmptyBrackets = MkAtomTerm(AtomEmptyBrackets); - AtomEmptySquareBrackets = Yap_LookupAtom("[]"); TermEmptySquareBrackets = MkAtomTerm(AtomEmptySquareBrackets); - AtomAsserta = Yap_LookupAtom("asserta"); TermAsserta = MkAtomTerm(AtomAsserta); - AtomAssertaStatic = Yap_LookupAtom("asserta_static"); TermAssertaStatic = MkAtomTerm(AtomAssertaStatic); - AtomAssertz = Yap_LookupAtom("assertz"); TermAssertz = MkAtomTerm(AtomAssertz); - AtomAssertzStatic = Yap_LookupAtom("assertz_static"); TermAssertzStatic = MkAtomTerm(AtomAssertzStatic); - AtomAt = Yap_LookupAtom("at"); TermAt = MkAtomTerm(AtomAt); - AtomAtom = Yap_LookupAtom("atom"); TermAtom = MkAtomTerm(AtomAtom); - AtomAtomic = Yap_LookupAtom("atomic"); TermAtomic = MkAtomTerm(AtomAtomic); - AtomAtt = Yap_FullLookupAtom("$att"); TermAtt = MkAtomTerm(AtomAtt); - AtomAtt1 = Yap_LookupAtom("att"); TermAtt1 = MkAtomTerm(AtomAtt1); - AtomAttDo = Yap_FullLookupAtom("$att_do"); TermAttDo = MkAtomTerm(AtomAttDo); - AtomAttributes = Yap_LookupAtom("attributes"); TermAttributes = MkAtomTerm(AtomAttributes); - AtomB = Yap_FullLookupAtom("$last_choice_pt"); TermB = MkAtomTerm(AtomB); - AtomBatched = Yap_LookupAtom("batched"); TermBatched = MkAtomTerm(AtomBatched); - AtomBetween = Yap_LookupAtom("between"); TermBetween = MkAtomTerm(AtomBetween); - AtomBinary = Yap_LookupAtom("binary"); TermBinary = MkAtomTerm(AtomBinary); - AtomBigNum = Yap_LookupAtom("big_num"); TermBigNum = MkAtomTerm(AtomBigNum); - AtomBinaryStream = Yap_LookupAtom("binary_stream"); TermBinaryStream = MkAtomTerm(AtomBinaryStream); - AtomBoolean = Yap_LookupAtom("boolean"); TermBoolean = MkAtomTerm(AtomBoolean); - AtomBraces = Yap_LookupAtom("{}"); TermBraces = MkAtomTerm(AtomBraces); - AtomBreak = Yap_FullLookupAtom("$break"); TermBreak = MkAtomTerm(AtomBreak); - AtomByte = Yap_LookupAtom("byte"); TermByte = MkAtomTerm(AtomByte); - AtomCArith = Yap_FullLookupAtom("$c_arith"); TermCArith = MkAtomTerm(AtomCArith); - AtomCall = Yap_LookupAtom("call"); TermCall = MkAtomTerm(AtomCall); - AtomCallAndRetryCounter = Yap_LookupAtom("call_and_retry_counter"); TermCallAndRetryCounter = MkAtomTerm(AtomCallAndRetryCounter); - AtomCallCounter = Yap_LookupAtom("call_counter"); TermCallCounter = MkAtomTerm(AtomCallCounter); - AtomCallable = Yap_LookupAtom("callable"); TermCallable = MkAtomTerm(AtomCallable); - AtomCatch = Yap_FullLookupAtom("$catch"); TermCatch = MkAtomTerm(AtomCatch); - AtomChangeModule = Yap_FullLookupAtom("$change_module"); TermChangeModule = MkAtomTerm(AtomChangeModule); - AtomChar = Yap_LookupAtom("char"); TermChar = MkAtomTerm(AtomChar); - AtomCharsio = Yap_LookupAtom("charsio"); TermCharsio = MkAtomTerm(AtomCharsio); - AtomCharacter = Yap_LookupAtom("character"); TermCharacter = MkAtomTerm(AtomCharacter); - AtomCharacterCode = Yap_LookupAtom("character_code"); TermCharacterCode = MkAtomTerm(AtomCharacterCode); - AtomChars = Yap_LookupAtom("chars"); TermChars = MkAtomTerm(AtomChars); - AtomCharset = Yap_LookupAtom("charset"); TermCharset = MkAtomTerm(AtomCharset); - AtomChType = Yap_FullLookupAtom("$char_type"); TermChType = MkAtomTerm(AtomChType); - AtomCleanCall = Yap_FullLookupAtom("$clean_call"); TermCleanCall = MkAtomTerm(AtomCleanCall); - AtomClose = Yap_LookupAtom("close"); TermClose = MkAtomTerm(AtomClose); - AtomColon = Yap_LookupAtom(":"); TermColon = MkAtomTerm(AtomColon); - AtomCodeSpace = Yap_LookupAtom("code_space"); TermCodeSpace = MkAtomTerm(AtomCodeSpace); - AtomCodes = Yap_LookupAtom("codes"); TermCodes = MkAtomTerm(AtomCodes); - AtomCoInductive = Yap_LookupAtom("coinductive"); TermCoInductive = MkAtomTerm(AtomCoInductive); - AtomComma = Yap_LookupAtom(","); TermComma = MkAtomTerm(AtomComma); - AtomCommentHook = Yap_LookupAtom("comment_hook"); TermCommentHook = MkAtomTerm(AtomCommentHook); - AtomCompact = Yap_LookupAtom("compact"); TermCompact = MkAtomTerm(AtomCompact); - AtomCompound = Yap_LookupAtom("compound"); TermCompound = MkAtomTerm(AtomCompound); - AtomConsistencyError = Yap_LookupAtom("consistency_error"); TermConsistencyError = MkAtomTerm(AtomConsistencyError); - AtomConsult = Yap_LookupAtom("consult"); TermConsult = MkAtomTerm(AtomConsult); - AtomConsultOnBoot = Yap_FullLookupAtom("$consult_on_boot"); TermConsultOnBoot = MkAtomTerm(AtomConsultOnBoot); - AtomContext = Yap_LookupAtom("context"); TermContext = MkAtomTerm(AtomContext); - AtomCputime = Yap_LookupAtom("cputime"); TermCputime = MkAtomTerm(AtomCputime); - AtomCreate = Yap_LookupAtom("create"); TermCreate = MkAtomTerm(AtomCreate); - AtomCreep = Yap_FullLookupAtom("$creep"); TermCreep = MkAtomTerm(AtomCreep); - AtomCryptAtoms = Yap_LookupAtom("crypt_atoms"); TermCryptAtoms = MkAtomTerm(AtomCryptAtoms); - AtomCurly = Yap_LookupAtom("{}"); TermCurly = MkAtomTerm(AtomCurly); - AtomCsult = Yap_FullLookupAtom("$csult"); TermCsult = MkAtomTerm(AtomCsult); - AtomCurrentModule = Yap_FullLookupAtom("$current_module"); TermCurrentModule = MkAtomTerm(AtomCurrentModule); - AtomCut = Yap_LookupAtom("!"); TermCut = MkAtomTerm(AtomCut); - AtomCutBy = Yap_FullLookupAtom("$cut_by"); TermCutBy = MkAtomTerm(AtomCutBy); - AtomDAbort = Yap_LookupAtom("abort"); TermDAbort = MkAtomTerm(AtomDAbort); - AtomDBLoad = Yap_FullLookupAtom("$db_load"); TermDBLoad = MkAtomTerm(AtomDBLoad); - AtomDBREF = Yap_LookupAtom("DBRef"); TermDBREF = MkAtomTerm(AtomDBREF); - AtomDBReference = Yap_LookupAtom("db_reference"); TermDBReference = MkAtomTerm(AtomDBReference); - AtomDBTerm = Yap_LookupAtom("db_term"); TermDBTerm = MkAtomTerm(AtomDBTerm); - AtomDBref = Yap_FullLookupAtom("$dbref"); TermDBref = MkAtomTerm(AtomDBref); - AtomDInteger = Yap_FullLookupAtom("$integer"); TermDInteger = MkAtomTerm(AtomDInteger); - AtomDebugMeta = Yap_FullLookupAtom("$debug_meta"); TermDebugMeta = MkAtomTerm(AtomDebugMeta); - AtomDebuggerInput = Yap_LookupAtom("debugger_input"); TermDebuggerInput = MkAtomTerm(AtomDebuggerInput); - AtomDec10 = Yap_LookupAtom("dec10"); TermDec10 = MkAtomTerm(AtomDec10); - AtomDefault = Yap_LookupAtom("default"); TermDefault = MkAtomTerm(AtomDefault); - AtomDevNull = Yap_LookupAtom("/dev/null"); TermDevNull = MkAtomTerm(AtomDevNull); - AtomDiff = Yap_LookupAtom("\\="); TermDiff = MkAtomTerm(AtomDiff); - AtomDirectory = Yap_LookupAtom("disrectorys"); TermDirectory = MkAtomTerm(AtomDirectory); - AtomDiscontiguous = Yap_LookupAtom("discontiguous"); TermDiscontiguous = MkAtomTerm(AtomDiscontiguous); - AtomDiscontiguousWarnings = Yap_LookupAtom("discontiguous_warnings"); TermDiscontiguousWarnings = MkAtomTerm(AtomDiscontiguousWarnings); - AtomDollar = Yap_FullLookupAtom("$"); TermDollar = MkAtomTerm(AtomDollar); - AtomDoLogUpdClause = Yap_FullLookupAtom("$do_log_upd_clause"); TermDoLogUpdClause = MkAtomTerm(AtomDoLogUpdClause); - AtomDoLogUpdClause0 = Yap_FullLookupAtom("$do_log_upd_clause0"); TermDoLogUpdClause0 = MkAtomTerm(AtomDoLogUpdClause0); - AtomDoLogUpdClauseErase = Yap_FullLookupAtom("$do_log_upd_clause_erase"); TermDoLogUpdClauseErase = MkAtomTerm(AtomDoLogUpdClauseErase); - AtomDollarU = Yap_FullLookupAtom("$u"); TermDollarU = MkAtomTerm(AtomDollarU); - AtomDollarUndef = Yap_FullLookupAtom("$undef"); TermDollarUndef = MkAtomTerm(AtomDollarUndef); - AtomDomainError = Yap_LookupAtom("domain_error"); TermDomainError = MkAtomTerm(AtomDomainError); - AtomDoStaticClause = Yap_FullLookupAtom("$do_static_clause"); TermDoStaticClause = MkAtomTerm(AtomDoStaticClause); - AtomDots = Yap_LookupAtom("dots"); TermDots = MkAtomTerm(AtomDots); - AtomDOUBLE = Yap_FullLookupAtom("Double"); TermDOUBLE = MkAtomTerm(AtomDOUBLE); - AtomDoubleSlash = Yap_FullLookupAtom("//"); TermDoubleSlash = MkAtomTerm(AtomDoubleSlash); - AtomE = Yap_LookupAtom("e"); TermE = MkAtomTerm(AtomE); - AtomEOFBeforeEOT = Yap_LookupAtom("end_of_file_found_before_end_of_term"); TermEOFBeforeEOT = MkAtomTerm(AtomEOFBeforeEOT); - AtomEQ = Yap_LookupAtom("="); TermEQ = MkAtomTerm(AtomEQ); - AtomEmptyAtom = Yap_LookupAtom(""); TermEmptyAtom = MkAtomTerm(AtomEmptyAtom); - AtomEncoding = Yap_LookupAtom("encoding"); TermEncoding = MkAtomTerm(AtomEncoding); - AtomEndOfStream = Yap_LookupAtom("$end_of_stream"); TermEndOfStream = MkAtomTerm(AtomEndOfStream); - AtomEof = Yap_LookupAtom("end_of_file"); TermEof = MkAtomTerm(AtomEof); - AtomEOfCode = Yap_LookupAtom("eof_code"); TermEOfCode = MkAtomTerm(AtomEOfCode); - AtomEq = Yap_LookupAtom("="); TermEq = MkAtomTerm(AtomEq); - AtomError = Yap_LookupAtom("error"); TermError = MkAtomTerm(AtomError); - AtomException = Yap_LookupAtom("exception"); TermException = MkAtomTerm(AtomException); - AtomExtensions = Yap_LookupAtom("extensions"); TermExtensions = MkAtomTerm(AtomExtensions); - AtomEvaluable = Yap_LookupAtom("evaluable"); TermEvaluable = MkAtomTerm(AtomEvaluable); - AtomEvaluationError = Yap_LookupAtom("evaluation_error"); TermEvaluationError = MkAtomTerm(AtomEvaluationError); - AtomExecutable = Yap_LookupAtom("executable"); TermExecutable = MkAtomTerm(AtomExecutable); - AtomExecute = Yap_LookupAtom("execute"); TermExecute = MkAtomTerm(AtomExecute); - AtomExecAnswers = Yap_LookupAtom("exec_answers"); TermExecAnswers = MkAtomTerm(AtomExecAnswers); - AtomExecuteInMod = Yap_FullLookupAtom("$execute_in_mod"); TermExecuteInMod = MkAtomTerm(AtomExecuteInMod); - AtomExecuteWithin = Yap_FullLookupAtom("$execute_within"); TermExecuteWithin = MkAtomTerm(AtomExecuteWithin); - AtomExecuteWoMod = Yap_FullLookupAtom("$execute_wo_mod"); TermExecuteWoMod = MkAtomTerm(AtomExecuteWoMod); - AtomExist = Yap_LookupAtom("exist"); TermExist = MkAtomTerm(AtomExist); - AtomExists = Yap_LookupAtom("exists"); TermExists = MkAtomTerm(AtomExists); - AtomExit = Yap_LookupAtom("exit"); TermExit = MkAtomTerm(AtomExit); - AtomExistenceError = Yap_LookupAtom("existence_error"); TermExistenceError = MkAtomTerm(AtomExistenceError); - AtomExoClause = Yap_FullLookupAtom("$exo_clause"); TermExoClause = MkAtomTerm(AtomExoClause); - AtomExpectedNumber = Yap_LookupAtom("expected_number_syntax"); TermExpectedNumber = MkAtomTerm(AtomExpectedNumber); - AtomExpand = Yap_LookupAtom("expand"); TermExpand = MkAtomTerm(AtomExpand); - AtomExtendFileSearchPath = Yap_FullLookupAtom("$extend_file_search_path"); TermExtendFileSearchPath = MkAtomTerm(AtomExtendFileSearchPath); - AtomExtendsions = Yap_LookupAtom("extensionh"); TermExtendsions = MkAtomTerm(AtomExtendsions); - AtomFB = Yap_LookupAtom("fb"); TermFB = MkAtomTerm(AtomFB); - AtomFail = Yap_LookupAtom("fail"); TermFail = MkAtomTerm(AtomFail); - AtomFalse = Yap_LookupAtom("false"); TermFalse = MkAtomTerm(AtomFalse); - AtomFast = Yap_FullLookupAtom("$fast"); TermFast = MkAtomTerm(AtomFast); - AtomFastFail = Yap_LookupAtom("fast_fail"); TermFastFail = MkAtomTerm(AtomFastFail); - AtomFileErrors = Yap_LookupAtom("file_errors"); TermFileErrors = MkAtomTerm(AtomFileErrors); - AtomFileerrors = Yap_LookupAtom("fileerrors"); TermFileerrors = MkAtomTerm(AtomFileerrors); - AtomFileType = Yap_LookupAtom("file_type"); TermFileType = MkAtomTerm(AtomFileType); - AtomFirst = Yap_LookupAtom("first"); TermFirst = MkAtomTerm(AtomFirst); - AtomFloat = Yap_LookupAtom("float"); TermFloat = MkAtomTerm(AtomFloat); - AtomFloatFormat = Yap_LookupAtom("\%.15g"); TermFloatFormat = MkAtomTerm(AtomFloatFormat); - AtomFloatOverflow = Yap_LookupAtom("float_overflow"); TermFloatOverflow = MkAtomTerm(AtomFloatOverflow); - AtomFloatUnderflow = Yap_LookupAtom("float_underflow"); TermFloatUnderflow = MkAtomTerm(AtomFloatUnderflow); - AtomFormat = Yap_LookupAtom("format"); TermFormat = MkAtomTerm(AtomFormat); - AtomFormatAt = Yap_FullLookupAtom("$format@"); TermFormatAt = MkAtomTerm(AtomFormatAt); - AtomFull = Yap_LookupAtom("full"); TermFull = MkAtomTerm(AtomFull); - AtomFunctor = Yap_LookupAtom("functor"); TermFunctor = MkAtomTerm(AtomFunctor); - AtomGT = Yap_LookupAtom(">"); TermGT = MkAtomTerm(AtomGT); - AtomGVar = Yap_LookupAtom("var"); TermGVar = MkAtomTerm(AtomGVar); - AtomGc = Yap_FullLookupAtom("$gc"); TermGc = MkAtomTerm(AtomGc); - AtomGcMargin = Yap_FullLookupAtom("$gc_margin"); TermGcMargin = MkAtomTerm(AtomGcMargin); - AtomGcTrace = Yap_FullLookupAtom("$gc_trace"); TermGcTrace = MkAtomTerm(AtomGcTrace); - AtomGcVerbose = Yap_FullLookupAtom("$gc_verbose"); TermGcVerbose = MkAtomTerm(AtomGcVerbose); - AtomGcVeryVerbose = Yap_FullLookupAtom("$gc_very_verbose"); TermGcVeryVerbose = MkAtomTerm(AtomGcVeryVerbose); - AtomGeneratePredInfo = Yap_FullLookupAtom("$generate_pred_info"); TermGeneratePredInfo = MkAtomTerm(AtomGeneratePredInfo); - AtomGetwork = Yap_FullLookupAtom("$getwork"); TermGetwork = MkAtomTerm(AtomGetwork); - AtomGetworkSeq = Yap_FullLookupAtom("$getwork_seq"); TermGetworkSeq = MkAtomTerm(AtomGetworkSeq); - AtomGlob = Yap_LookupAtom("glob"); TermGlob = MkAtomTerm(AtomGlob); - AtomGlobal = Yap_LookupAtom("global"); TermGlobal = MkAtomTerm(AtomGlobal); - AtomGlobalSp = Yap_LookupAtom("global_sp"); TermGlobalSp = MkAtomTerm(AtomGlobalSp); - AtomGlobalTrie = Yap_LookupAtom("global_trie"); TermGlobalTrie = MkAtomTerm(AtomGlobalTrie); - AtomGoalExpansion = Yap_LookupAtom("goal_expansion"); TermGoalExpansion = MkAtomTerm(AtomGoalExpansion); - AtomHat = Yap_LookupAtom("^"); TermHat = MkAtomTerm(AtomHat); - AtomHERE = Yap_LookupAtom("\n <====HERE====> \n"); TermHERE = MkAtomTerm(AtomHERE); - AtomHandleThrow = Yap_FullLookupAtom("$handle_throw"); TermHandleThrow = MkAtomTerm(AtomHandleThrow); - AtomHeap = Yap_LookupAtom("heap"); TermHeap = MkAtomTerm(AtomHeap); - AtomHeapUsed = Yap_LookupAtom("heapused"); TermHeapUsed = MkAtomTerm(AtomHeapUsed); - AtomHugeInt = Yap_LookupAtom("huge_int"); TermHugeInt = MkAtomTerm(AtomHugeInt); - AtomIDB = Yap_LookupAtom("idb"); TermIDB = MkAtomTerm(AtomIDB); - AtomIOMode = Yap_LookupAtom("io_mode"); TermIOMode = MkAtomTerm(AtomIOMode); - AtomI = Yap_LookupAtom("i"); TermI = MkAtomTerm(AtomI); - AtomId = Yap_LookupAtom("id"); TermId = MkAtomTerm(AtomId); - AtomIgnore = Yap_LookupAtom("ignore"); TermIgnore = MkAtomTerm(AtomIgnore); - AtomInf = Yap_LookupAtom("inf"); TermInf = MkAtomTerm(AtomInf); - AtomInfinity = Yap_LookupAtom("infinity"); TermInfinity = MkAtomTerm(AtomInfinity); - AtomInfo = Yap_LookupAtom("info"); TermInfo = MkAtomTerm(AtomInfo); - AtomInitGoal = Yap_FullLookupAtom("$init_goal"); TermInitGoal = MkAtomTerm(AtomInitGoal); - AtomInitProlog = Yap_FullLookupAtom("$init_prolog"); TermInitProlog = MkAtomTerm(AtomInitProlog); - AtomInStackExpansion = Yap_LookupAtom("in stack expansion"); TermInStackExpansion = MkAtomTerm(AtomInStackExpansion); - AtomInput = Yap_LookupAtom("input"); TermInput = MkAtomTerm(AtomInput); - AtomInstantiationError = Yap_LookupAtom("instantiation_error"); TermInstantiationError = MkAtomTerm(AtomInstantiationError); - AtomInt = Yap_LookupAtom("int"); TermInt = MkAtomTerm(AtomInt); - AtomIntOverflow = Yap_LookupAtom("int_overflow"); TermIntOverflow = MkAtomTerm(AtomIntOverflow); - AtomInteger = Yap_LookupAtom("integer"); TermInteger = MkAtomTerm(AtomInteger); - AtomInternalCompilerError = Yap_LookupAtom("internal_compiler_error"); TermInternalCompilerError = MkAtomTerm(AtomInternalCompilerError); - AtomIs = Yap_LookupAtom("is"); TermIs = MkAtomTerm(AtomIs); - AtomJ = Yap_LookupAtom("j"); TermJ = MkAtomTerm(AtomJ); - Atoml = Yap_LookupAtom("l"); Terml = MkAtomTerm(Atoml); - AtomKey = Yap_LookupAtom("key"); TermKey = MkAtomTerm(AtomKey); - AtomLDLibraryPath = Yap_LookupAtom("LD_LIBRARY_PATH"); TermLDLibraryPath = MkAtomTerm(AtomLDLibraryPath); - AtomLONGINT = Yap_LookupAtom("LongInt"); TermLONGINT = MkAtomTerm(AtomLONGINT); - AtomLOOP = Yap_LookupAtom("_LOOP_"); TermLOOP = MkAtomTerm(AtomLOOP); - AtomLoopStream = Yap_LookupAtom("loop_stream"); TermLoopStream = MkAtomTerm(AtomLoopStream); - AtomLT = Yap_LookupAtom("<"); TermLT = MkAtomTerm(AtomLT); - AtomLastExecuteWithin = Yap_FullLookupAtom("$last_execute_within"); TermLastExecuteWithin = MkAtomTerm(AtomLastExecuteWithin); - AtomLeash = Yap_FullLookupAtom("$leash"); TermLeash = MkAtomTerm(AtomLeash); - AtomLeast = Yap_LookupAtom("least"); TermLeast = MkAtomTerm(AtomLeast); - AtomLength = Yap_FullLookupAtom("length"); TermLength = MkAtomTerm(AtomLength); - AtomList = Yap_LookupAtom("list"); TermList = MkAtomTerm(AtomList); - AtomLine = Yap_LookupAtom("line"); TermLine = MkAtomTerm(AtomLine); - AtomLive = Yap_FullLookupAtom("$live"); TermLive = MkAtomTerm(AtomLive); - AtomLoadAnswers = Yap_LookupAtom("load_answers"); TermLoadAnswers = MkAtomTerm(AtomLoadAnswers); - AtomLocal = Yap_LookupAtom("local"); TermLocal = MkAtomTerm(AtomLocal); - AtomLocalSp = Yap_LookupAtom("local_sp"); TermLocalSp = MkAtomTerm(AtomLocalSp); - AtomLocalTrie = Yap_LookupAtom("local_trie"); TermLocalTrie = MkAtomTerm(AtomLocalTrie); - AtomMax = Yap_LookupAtom("max"); TermMax = MkAtomTerm(AtomMax); - AtomMaximum = Yap_LookupAtom("maximum"); TermMaximum = MkAtomTerm(AtomMaximum); - AtomMaxArity = Yap_LookupAtom("max_arity"); TermMaxArity = MkAtomTerm(AtomMaxArity); - AtomMaxFiles = Yap_LookupAtom("max_files"); TermMaxFiles = MkAtomTerm(AtomMaxFiles); - AtomMegaClause = Yap_FullLookupAtom("$mega_clause"); TermMegaClause = MkAtomTerm(AtomMegaClause); - AtomMetaCall = Yap_FullLookupAtom("$call"); TermMetaCall = MkAtomTerm(AtomMetaCall); - AtomMfClause = Yap_FullLookupAtom("$mf_clause"); TermMfClause = MkAtomTerm(AtomMfClause); - AtomMin = Yap_LookupAtom("min"); TermMin = MkAtomTerm(AtomMin); - AtomMinimum = Yap_LookupAtom("minimum"); TermMinimum = MkAtomTerm(AtomMinimum); - AtomMinus = Yap_LookupAtom("-"); TermMinus = MkAtomTerm(AtomMinus); - AtomModify = Yap_LookupAtom("modify"); TermModify = MkAtomTerm(AtomModify); - AtomModule = Yap_LookupAtom("module"); TermModule = MkAtomTerm(AtomModule); - AtomMost = Yap_LookupAtom("most"); TermMost = MkAtomTerm(AtomMost); - AtomMulti = Yap_LookupAtom("multi"); TermMulti = MkAtomTerm(AtomMulti); - AtomMultiFile = Yap_FullLookupAtom("$mf"); TermMultiFile = MkAtomTerm(AtomMultiFile); - AtomMultiple = Yap_FullLookupAtom("multiple"); TermMultiple = MkAtomTerm(AtomMultiple); - AtomMutable = Yap_LookupAtom("mutable"); TermMutable = MkAtomTerm(AtomMutable); - AtomMutableVariable = Yap_FullLookupAtom("$mutable_variable"); TermMutableVariable = MkAtomTerm(AtomMutableVariable); - AtomMutex = Yap_LookupAtom("mutex"); TermMutex = MkAtomTerm(AtomMutex); - AtomMyddasDB = Yap_FullLookupAtom("$myddas_db"); TermMyddasDB = MkAtomTerm(AtomMyddasDB); - AtomMyddasGoal = Yap_FullLookupAtom("$myddas_goal"); TermMyddasGoal = MkAtomTerm(AtomMyddasGoal); - AtomMyddasHost = Yap_FullLookupAtom("$myddas_host"); TermMyddasHost = MkAtomTerm(AtomMyddasHost); - AtomMyddasPass = Yap_FullLookupAtom("$myddas_pass"); TermMyddasPass = MkAtomTerm(AtomMyddasPass); - AtomMyddasUser = Yap_FullLookupAtom("$myddas_user"); TermMyddasUser = MkAtomTerm(AtomMyddasUser); - AtomMyddasVersionName = Yap_FullLookupAtom("$myddas_version_name"); TermMyddasVersionName = MkAtomTerm(AtomMyddasVersionName); - AtomNan = Yap_LookupAtom("nan"); TermNan = MkAtomTerm(AtomNan); - AtomNb = Yap_LookupAtom("nb"); TermNb = MkAtomTerm(AtomNb); - AtomNbTerm = Yap_LookupAtom("nb_term"); TermNbTerm = MkAtomTerm(AtomNbTerm); - AtomNew = Yap_LookupAtom("new"); TermNew = MkAtomTerm(AtomNew); - AtomNewLine = Yap_LookupAtom("nl"); TermNewLine = MkAtomTerm(AtomNewLine); - AtomNl = Yap_LookupAtom("nl"); TermNl = MkAtomTerm(AtomNl); - AtomNoEffect = Yap_LookupAtom("no_effect"); TermNoEffect = MkAtomTerm(AtomNoEffect); - AtomNoMemory = Yap_LookupAtom("no_memory"); TermNoMemory = MkAtomTerm(AtomNoMemory); - AtomNone = Yap_LookupAtom("none"); TermNone = MkAtomTerm(AtomNone); - AtomNonEmptyList = Yap_LookupAtom("non_empty_list"); TermNonEmptyList = MkAtomTerm(AtomNonEmptyList); - AtomNot = Yap_LookupAtom("\\+"); TermNot = MkAtomTerm(AtomNot); - AtomNotImplemented = Yap_LookupAtom("not_implemented"); TermNotImplemented = MkAtomTerm(AtomNotImplemented); - AtomNotLessThanZero = Yap_LookupAtom("not_less_than_zero"); TermNotLessThanZero = MkAtomTerm(AtomNotLessThanZero); - AtomNotNewline = Yap_LookupAtom("not_newline"); TermNotNewline = MkAtomTerm(AtomNotNewline); - AtomNotZero = Yap_LookupAtom("not_zero"); TermNotZero = MkAtomTerm(AtomNotZero); - AtomNumber = Yap_LookupAtom("number"); TermNumber = MkAtomTerm(AtomNumber); - AtomObj = Yap_LookupAtom("o__bj__"); TermObj = MkAtomTerm(AtomObj); - AtomOff = Yap_LookupAtom("off"); TermOff = MkAtomTerm(AtomOff); - AtomOffline = Yap_LookupAtom("offline"); TermOffline = MkAtomTerm(AtomOffline); - AtomOn = Yap_LookupAtom("on"); TermOn = MkAtomTerm(AtomOn); - AtomOnline = Yap_LookupAtom("online"); TermOnline = MkAtomTerm(AtomOnline); - AtomOpen = Yap_LookupAtom("open"); TermOpen = MkAtomTerm(AtomOpen); - AtomOperatingSystemError = Yap_LookupAtom("operating_SYSTEM_ERROR_INTERNAL"); TermOperatingSystemError = MkAtomTerm(AtomOperatingSystemError); - AtomOperatingSystemSupport = Yap_LookupAtom("operating_system_support"); TermOperatingSystemSupport = MkAtomTerm(AtomOperatingSystemSupport); - AtomOperator = Yap_LookupAtom("operator"); TermOperator = MkAtomTerm(AtomOperator); - AtomOperatorPriority = Yap_LookupAtom("operator_priority"); TermOperatorPriority = MkAtomTerm(AtomOperatorPriority); - AtomOperatorSpecifier = Yap_LookupAtom("operator_specifier"); TermOperatorSpecifier = MkAtomTerm(AtomOperatorSpecifier); - AtomOpt = Yap_LookupAtom("opt"); TermOpt = MkAtomTerm(AtomOpt); - AtomOtherwise = Yap_LookupAtom("otherwise"); TermOtherwise = MkAtomTerm(AtomOtherwise); - AtomOutOfAttvarsError = Yap_LookupAtom("out_of_attvars_error"); TermOutOfAttvarsError = MkAtomTerm(AtomOutOfAttvarsError); - AtomOutOfAuxspaceError = Yap_LookupAtom("out_of_auxspace_error"); TermOutOfAuxspaceError = MkAtomTerm(AtomOutOfAuxspaceError); - AtomOutOfHeapError = Yap_LookupAtom("out_of_heap_error"); TermOutOfHeapError = MkAtomTerm(AtomOutOfHeapError); - AtomOutOfRange = Yap_LookupAtom("out_of_range"); TermOutOfRange = MkAtomTerm(AtomOutOfRange); - AtomOutOfStackError = Yap_LookupAtom("out_of_stack_error"); TermOutOfStackError = MkAtomTerm(AtomOutOfStackError); - AtomOutOfTrailError = Yap_LookupAtom("out_of_trail_error"); TermOutOfTrailError = MkAtomTerm(AtomOutOfTrailError); - AtomOutput = Yap_LookupAtom("output"); TermOutput = MkAtomTerm(AtomOutput); - AtomParameter = Yap_LookupAtom("parameter"); TermParameter = MkAtomTerm(AtomParameter); - AtomPrologCommonsDir = Yap_LookupAtom("prolog_commons_directory"); TermPrologCommonsDir = MkAtomTerm(AtomPrologCommonsDir); - AtomPast = Yap_LookupAtom("past"); TermPast = MkAtomTerm(AtomPast); - AtomPastEndOfStream = Yap_LookupAtom("past_end_of_stream"); TermPastEndOfStream = MkAtomTerm(AtomPastEndOfStream); - AtomPermissionError = Yap_LookupAtom("permission_error"); TermPermissionError = MkAtomTerm(AtomPermissionError); - AtomPi = Yap_LookupAtom("pi"); TermPi = MkAtomTerm(AtomPi); - AtomPipe = Yap_LookupAtom("pipe"); TermPipe = MkAtomTerm(AtomPipe); - AtomPriority = Yap_LookupAtom("priority"); TermPriority = MkAtomTerm(AtomPriority); - AtomPlus = Yap_LookupAtom("+"); TermPlus = MkAtomTerm(AtomPlus); - AtomPointer = Yap_LookupAtom("pointer"); TermPointer = MkAtomTerm(AtomPointer); - AtomPortray = Yap_FullLookupAtom("portray"); TermPortray = MkAtomTerm(AtomPortray); - AtomPredicateIndicator = Yap_LookupAtom("predicate_indicator"); TermPredicateIndicator = MkAtomTerm(AtomPredicateIndicator); - AtomPrimitive = Yap_LookupAtom("primitive"); TermPrimitive = MkAtomTerm(AtomPrimitive); - AtomPrintMessage = Yap_LookupAtom("print_message"); TermPrintMessage = MkAtomTerm(AtomPrintMessage); - AtomPrivateProcedure = Yap_LookupAtom("private_procedure"); TermPrivateProcedure = MkAtomTerm(AtomPrivateProcedure); - AtomProcedure = Yap_LookupAtom("procedure"); TermProcedure = MkAtomTerm(AtomProcedure); - AtomProfile = Yap_FullLookupAtom("$profile"); TermProfile = MkAtomTerm(AtomProfile); - AtomProlog = Yap_LookupAtom("prolog"); TermProlog = MkAtomTerm(AtomProlog); - AtomProtectStack = Yap_FullLookupAtom("$protect_stack"); TermProtectStack = MkAtomTerm(AtomProtectStack); - AtomQly = Yap_LookupAtom("qly"); TermQly = MkAtomTerm(AtomQly); - AtomQuery = Yap_LookupAtom("?-"); TermQuery = MkAtomTerm(AtomQuery); - AtomQueue = Yap_LookupAtom("queue"); TermQueue = MkAtomTerm(AtomQueue); - AtomQuiet = Yap_LookupAtom("quiet"); TermQuiet = MkAtomTerm(AtomQuiet); - AtomRadix = Yap_LookupAtom("radix"); TermRadix = MkAtomTerm(AtomRadix); - AtomRandom = Yap_LookupAtom("random"); TermRandom = MkAtomTerm(AtomRandom); - AtomRange = Yap_LookupAtom("range"); TermRange = MkAtomTerm(AtomRange); - AtomRDiv = Yap_LookupAtom("rdiv"); TermRDiv = MkAtomTerm(AtomRDiv); - AtomRead = Yap_LookupAtom("read"); TermRead = MkAtomTerm(AtomRead); - AtomReadOnly = Yap_LookupAtom("read_only"); TermReadOnly = MkAtomTerm(AtomReadOnly); - AtomReadWrite = Yap_LookupAtom("read_write"); TermReadWrite = MkAtomTerm(AtomReadWrite); - AtomReadutil = Yap_LookupAtom("readutil"); TermReadutil = MkAtomTerm(AtomReadutil); - AtomReconsult = Yap_LookupAtom("reconsult"); TermReconsult = MkAtomTerm(AtomReconsult); - AtomRecordedP = Yap_FullLookupAtom("$recordep"); TermRecordedP = MkAtomTerm(AtomRecordedP); - AtomRecordedWithKey = Yap_FullLookupAtom("$recorded_with_key"); TermRecordedWithKey = MkAtomTerm(AtomRecordedWithKey); - AtomRedefineWarnings = Yap_LookupAtom("redefine_warnings"); TermRedefineWarnings = MkAtomTerm(AtomRedefineWarnings); - AtomRedoFreeze = Yap_FullLookupAtom("$redo_freeze"); TermRedoFreeze = MkAtomTerm(AtomRedoFreeze); - AtomRefoundVar = Yap_FullLookupAtom("$I_FOUND_THE_VARIABLE_AGAIN"); TermRefoundVar = MkAtomTerm(AtomRefoundVar); - AtomRelativeTo = Yap_FullLookupAtom("relative_to"); TermRelativeTo = MkAtomTerm(AtomRelativeTo); - AtomRepeat = Yap_LookupAtom("repeat"); TermRepeat = MkAtomTerm(AtomRepeat); - AtomRepeatSpace = Yap_LookupAtom("repeat "); TermRepeatSpace = MkAtomTerm(AtomRepeatSpace); - AtomReposition = Yap_LookupAtom("reposition"); TermReposition = MkAtomTerm(AtomReposition); - AtomRepresentationError = Yap_LookupAtom("representation_error"); TermRepresentationError = MkAtomTerm(AtomRepresentationError); - AtomReset = Yap_LookupAtom("reset"); TermReset = MkAtomTerm(AtomReset); - AtomResize = Yap_LookupAtom("resize"); TermResize = MkAtomTerm(AtomResize); - AtomResourceError = Yap_LookupAtom("resource_error"); TermResourceError = MkAtomTerm(AtomResourceError); - AtomRestoreRegs = Yap_FullLookupAtom("$restore_regs"); TermRestoreRegs = MkAtomTerm(AtomRestoreRegs); - AtomRetry = Yap_LookupAtom("retry"); TermRetry = MkAtomTerm(AtomRetry); - AtomRetryCounter = Yap_LookupAtom("retry_counter"); TermRetryCounter = MkAtomTerm(AtomRetryCounter); - AtomRTree = Yap_LookupAtom("rtree"); TermRTree = MkAtomTerm(AtomRTree); - AtomSafe = Yap_FullLookupAtom("$safe"); TermSafe = MkAtomTerm(AtomSafe); - AtomSafeCallCleanup = Yap_FullLookupAtom("$safe_call_cleanup"); TermSafeCallCleanup = MkAtomTerm(AtomSafeCallCleanup); - AtomSame = Yap_LookupAtom("=="); TermSame = MkAtomTerm(AtomSame); - AtomSemic = Yap_LookupAtom(";"); TermSemic = MkAtomTerm(AtomSemic); - AtomShiftCountOverflow = Yap_LookupAtom("shift_count_overflow"); TermShiftCountOverflow = MkAtomTerm(AtomShiftCountOverflow); - AtomSigAlarm = Yap_LookupAtom("sig_alarm"); TermSigAlarm = MkAtomTerm(AtomSigAlarm); - AtomSigBreak = Yap_LookupAtom("sig_break"); TermSigBreak = MkAtomTerm(AtomSigBreak); - AtomSigCreep = Yap_LookupAtom("sig_creep"); TermSigCreep = MkAtomTerm(AtomSigCreep); - AtomSigDebug = Yap_LookupAtom("sig_debug"); TermSigDebug = MkAtomTerm(AtomSigDebug); - AtomSigDelayCreep = Yap_LookupAtom("sig_delay_creep"); TermSigDelayCreep = MkAtomTerm(AtomSigDelayCreep); - AtomSigFPE = Yap_LookupAtom("sig_fpe"); TermSigFPE = MkAtomTerm(AtomSigFPE); - AtomSigHup = Yap_LookupAtom("sig_hup"); TermSigHup = MkAtomTerm(AtomSigHup); - AtomSigInt = Yap_LookupAtom("sig_int"); TermSigInt = MkAtomTerm(AtomSigInt); - AtomSigIti = Yap_LookupAtom("sig_iti"); TermSigIti = MkAtomTerm(AtomSigIti); - AtomSigPending = Yap_FullLookupAtom("$sig_pending"); TermSigPending = MkAtomTerm(AtomSigPending); - AtomSigPipe = Yap_LookupAtom("sig_pipe"); TermSigPipe = MkAtomTerm(AtomSigPipe); - AtomSigStackDump = Yap_LookupAtom("sig_stack_dump"); TermSigStackDump = MkAtomTerm(AtomSigStackDump); - AtomSigStatistics = Yap_LookupAtom("sig_statistics"); TermSigStatistics = MkAtomTerm(AtomSigStatistics); - AtomSigTrace = Yap_LookupAtom("sig_trace"); TermSigTrace = MkAtomTerm(AtomSigTrace); - AtomSigUsr1 = Yap_LookupAtom("sig_usr1"); TermSigUsr1 = MkAtomTerm(AtomSigUsr1); - AtomSigUsr2 = Yap_LookupAtom("sig_usr2"); TermSigUsr2 = MkAtomTerm(AtomSigUsr2); - AtomSigVTAlarm = Yap_LookupAtom("sig_vtalarm"); TermSigVTAlarm = MkAtomTerm(AtomSigVTAlarm); - AtomSigWakeUp = Yap_LookupAtom("sig_wake_up"); TermSigWakeUp = MkAtomTerm(AtomSigWakeUp); - AtomSilent = Yap_LookupAtom("Silent"); TermSilent = MkAtomTerm(AtomSilent); - AtomSingle = Yap_LookupAtom("single"); TermSingle = MkAtomTerm(AtomSingle); - AtomSingleVarWarnings = Yap_LookupAtom("single_var_warnings"); TermSingleVarWarnings = MkAtomTerm(AtomSingleVarWarnings); - AtomSingleton = Yap_LookupAtom("singleton"); TermSingleton = MkAtomTerm(AtomSingleton); - AtomSlash = Yap_LookupAtom("/"); TermSlash = MkAtomTerm(AtomSlash); - AtomSocket = Yap_LookupAtom("socket"); TermSocket = MkAtomTerm(AtomSocket); - AtomSolutions = Yap_LookupAtom("solutions"); TermSolutions = MkAtomTerm(AtomSolutions); - AtomSource = Yap_LookupAtom("source"); TermSource = MkAtomTerm(AtomSource); - AtomSourceSink = Yap_LookupAtom("source_sink"); TermSourceSink = MkAtomTerm(AtomSourceSink); - AtomSpy = Yap_FullLookupAtom("$spy"); TermSpy = MkAtomTerm(AtomSpy); - AtomStack = Yap_LookupAtom("stack"); TermStack = MkAtomTerm(AtomStack); - AtomStackFree = Yap_LookupAtom("stackfree"); TermStackFree = MkAtomTerm(AtomStackFree); - AtomStartupSavedState = Yap_FullLookupAtom("$startup_saved_state"); TermStartupSavedState = MkAtomTerm(AtomStartupSavedState); - AtomStaticClause = Yap_FullLookupAtom("$static_clause"); TermStaticClause = MkAtomTerm(AtomStaticClause); - AtomStaticProcedure = Yap_LookupAtom("static_procedure"); TermStaticProcedure = MkAtomTerm(AtomStaticProcedure); - AtomStream = Yap_FullLookupAtom("$stream"); TermStream = MkAtomTerm(AtomStream); - AtomSWIStream = Yap_FullLookupAtom(""); TermSWIStream = MkAtomTerm(AtomSWIStream); - AtomVStream = Yap_LookupAtom("stream"); TermVStream = MkAtomTerm(AtomVStream); - AtomStreams = Yap_LookupAtom("streams"); TermStreams = MkAtomTerm(AtomStreams); - AtomStreamOrAlias = Yap_LookupAtom("stream_or_alias"); TermStreamOrAlias = MkAtomTerm(AtomStreamOrAlias); - AtomStreamPos = Yap_FullLookupAtom("$stream_position"); TermStreamPos = MkAtomTerm(AtomStreamPos); - AtomStreamPosition = Yap_LookupAtom("stream_position"); TermStreamPosition = MkAtomTerm(AtomStreamPosition); - AtomString = Yap_LookupAtom("string"); TermString = MkAtomTerm(AtomString); - AtomStyleCheck = Yap_LookupAtom("style_check"); TermStyleCheck = MkAtomTerm(AtomStyleCheck); - AtomSTRING = Yap_FullLookupAtom("String"); TermSTRING = MkAtomTerm(AtomSTRING); - AtomSwi = Yap_LookupAtom("swi"); TermSwi = MkAtomTerm(AtomSwi); - AtomSymbolChar = Yap_LookupAtom("symbol_char"); TermSymbolChar = MkAtomTerm(AtomSymbolChar); - AtomSyntaxError = Yap_LookupAtom("syntax_error"); TermSyntaxError = MkAtomTerm(AtomSyntaxError); - AtomSyntaxErrors = Yap_LookupAtom("syntax_errors"); TermSyntaxErrors = MkAtomTerm(AtomSyntaxErrors); - AtomSyntaxErrorHandler = Yap_LookupAtom("syntax_error_handler"); TermSyntaxErrorHandler = MkAtomTerm(AtomSyntaxErrorHandler); - AtomSystem = Yap_LookupAtom("system"); TermSystem = MkAtomTerm(AtomSystem); - AtomSystemError = Yap_LookupAtom("SYSTEM_ERROR_INTERNAL"); TermSystemError = MkAtomTerm(AtomSystemError); - AtomSystemLibraryDir = Yap_LookupAtom("system_library_directory"); TermSystemLibraryDir = MkAtomTerm(AtomSystemLibraryDir); - AtomT = Yap_LookupAtom("t"); TermT = MkAtomTerm(AtomT); - AtomTerm = Yap_LookupAtom("term"); TermTerm = MkAtomTerm(AtomTerm); - AtomTermExpansion = Yap_LookupAtom("term_expansion"); TermTermExpansion = MkAtomTerm(AtomTermExpansion); - AtomTerms = Yap_LookupAtom("terms"); TermTerms = MkAtomTerm(AtomTerms); - AtomText = Yap_LookupAtom("text"); TermText = MkAtomTerm(AtomText); - AtomTextStream = Yap_LookupAtom("text_stream"); TermTextStream = MkAtomTerm(AtomTextStream); - AtomThread = Yap_LookupAtom("thread"); TermThread = MkAtomTerm(AtomThread); - AtomThreads = Yap_LookupAtom("threads"); TermThreads = MkAtomTerm(AtomThreads); - AtomThrow = Yap_LookupAtom("throw"); TermThrow = MkAtomTerm(AtomThrow); - AtomTimeOutSpec = Yap_LookupAtom("time_out_spec"); TermTimeOutSpec = MkAtomTerm(AtomTimeOutSpec); - AtomTimeoutError = Yap_LookupAtom("timeout_error"); TermTimeoutError = MkAtomTerm(AtomTimeoutError); - AtomTopLevelGoal = Yap_FullLookupAtom("$top_level_goal"); TermTopLevelGoal = MkAtomTerm(AtomTopLevelGoal); - AtomTopThreadGoal = Yap_FullLookupAtom("$top_thread_goal"); TermTopThreadGoal = MkAtomTerm(AtomTopThreadGoal); - AtomTraceMetaCall = Yap_FullLookupAtom("$trace_meta_call"); TermTraceMetaCall = MkAtomTerm(AtomTraceMetaCall); - AtomTrail = Yap_LookupAtom("trail"); - AtomTrue = Yap_LookupAtom("true"); TermTrue = MkAtomTerm(AtomTrue); - AtomTty = Yap_LookupAtom("tty"); TermTty = MkAtomTerm(AtomTty); - AtomTtys = Yap_LookupAtom("ttys"); TermTtys = MkAtomTerm(AtomTtys); - AtomTuple = Yap_LookupAtom("tuple"); TermTuple = MkAtomTerm(AtomTuple); - AtomTxt = Yap_LookupAtom("txt"); TermTxt = MkAtomTerm(AtomTxt); - AtomTypeError = Yap_LookupAtom("type_error"); TermTypeError = MkAtomTerm(AtomTypeError); - AtomUndefined = Yap_LookupAtom("undefined"); TermUndefined = MkAtomTerm(AtomUndefined); - AtomUndefp = Yap_FullLookupAtom("$undefp"); TermUndefp = MkAtomTerm(AtomUndefp); - AtomUndefp0 = Yap_FullLookupAtom("$undefp0"); TermUndefp0 = MkAtomTerm(AtomUndefp0); - AtomUnderflow = Yap_LookupAtom("underflow"); TermUnderflow = MkAtomTerm(AtomUnderflow); - AtomUnificationStack = Yap_LookupAtom("unification_stack"); TermUnificationStack = MkAtomTerm(AtomUnificationStack); - AtomUnique = Yap_LookupAtom("unique"); TermUnique = MkAtomTerm(AtomUnique); - AtomUnsignedByte = Yap_LookupAtom("unsigned_byte"); TermUnsignedByte = MkAtomTerm(AtomUnsignedByte); - AtomUnsignedChar = Yap_LookupAtom("unsigned_char"); TermUnsignedChar = MkAtomTerm(AtomUnsignedChar); - AtomUser = Yap_LookupAtom("user"); TermUser = MkAtomTerm(AtomUser); - AtomUserErr = Yap_LookupAtom("user_error"); TermUserErr = MkAtomTerm(AtomUserErr); - AtomUserIn = Yap_LookupAtom("user_input"); TermUserIn = MkAtomTerm(AtomUserIn); - AtomUserOut = Yap_LookupAtom("user_output"); TermUserOut = MkAtomTerm(AtomUserOut); - AtomDollarVar = Yap_LookupAtom("$VAR"); TermDollarVar = MkAtomTerm(AtomDollarVar); - AtomVBar = Yap_LookupAtom("|"); TermVBar = MkAtomTerm(AtomVBar); - AtomVarBranches = Yap_LookupAtom("var_branches"); TermVarBranches = MkAtomTerm(AtomVarBranches); - AtomVariableNames = Yap_LookupAtom("variable_names"); TermVariableNames = MkAtomTerm(AtomVariableNames); - AtomHiddenVar = Yap_FullLookupAtom("$V"); TermHiddenVar = MkAtomTerm(AtomHiddenVar); - AtomVariable = Yap_LookupAtom("variable"); TermVariable = MkAtomTerm(AtomVariable); - AtomVerbose = Yap_LookupAtom("verbose"); TermVerbose = MkAtomTerm(AtomVerbose); - AtomVerboseFileSearch = Yap_LookupAtom("verbose_file_search"); TermVerboseFileSearch = MkAtomTerm(AtomVerboseFileSearch); - AtomVersionNumber = Yap_FullLookupAtom("$version_name"); TermVersionNumber = MkAtomTerm(AtomVersionNumber); - AtomVeryVerbose = Yap_LookupAtom("very_verbose"); TermVeryVerbose = MkAtomTerm(AtomVeryVerbose); - AtomWakeUpGoal = Yap_FullLookupAtom("$wake_up_goal"); TermWakeUpGoal = MkAtomTerm(AtomWakeUpGoal); - AtomWarning = Yap_LookupAtom("warning"); TermWarning = MkAtomTerm(AtomWarning); - AtomWhen = Yap_FullLookupAtom("$when"); TermWhen = MkAtomTerm(AtomWhen); - AtomWrite = Yap_LookupAtom("write"); TermWrite = MkAtomTerm(AtomWrite); - AtomWriteTerm = Yap_LookupAtom("write_term"); TermWriteTerm = MkAtomTerm(AtomWriteTerm); - AtomXml = Yap_LookupAtom("xml"); TermXml = MkAtomTerm(AtomXml); - AtomYapHacks = Yap_LookupAtom("yap_hacks"); TermYapHacks = MkAtomTerm(AtomYapHacks); - AtomZeroDivisor = Yap_LookupAtom("zero_divisor"); TermZeroDivisor = MkAtomTerm(AtomZeroDivisor); - FunctorAfInet = Yap_MkFunctor(AtomAfInet,2); - FunctorAfLocal = Yap_MkFunctor(AtomAfLocal,1); - FunctorAfUnix = Yap_MkFunctor(AtomAfUnix,1); - FunctorAltNot = Yap_MkFunctor(AtomAltNot,1); - FunctorArg = Yap_MkFunctor(AtomArg,3); - FunctorArrayEntry = Yap_MkFunctor(AtomArrayAccess,3); - FunctorArrow = Yap_MkFunctor(AtomArrow,2); - FunctorDoubleArrow = Yap_MkFunctor(AtomDoubleArrow,2); - FunctorAssert1 = Yap_MkFunctor(AtomAssert,1); - FunctorAssert = Yap_MkFunctor(AtomAssert,2); - FunctorAtFoundOne = Yap_MkFunctor(AtomFoundVar,2); - FunctorAtom = Yap_MkFunctor(AtomAtom,1); - FunctorAtt1 = Yap_MkFunctor(AtomAtt1,3); - FunctorAttGoal = Yap_MkFunctor(AtomAttDo,2); - FunctorBraces = Yap_MkFunctor(AtomBraces,1); - FunctorCall = Yap_MkFunctor(AtomCall,1); - FunctorCatch = Yap_MkFunctor(AtomCatch,3); - FunctorChangeModule = Yap_MkFunctor(AtomChangeModule,1); - FunctorChars = Yap_MkFunctor(AtomChars,2); - FunctorChars1 = Yap_MkFunctor(AtomChars,1); - FunctorCleanCall = Yap_MkFunctor(AtomCleanCall,2); - FunctorClist = Yap_MkFunctor(AtomWhen,4); - FunctorCodes = Yap_MkFunctor(AtomCodes,2); - FunctorCodes1 = Yap_MkFunctor(AtomCodes,1); - FunctorColon = Yap_MkFunctor(AtomColon,2); - FunctorComma = Yap_MkFunctor(AtomComma,2); - FunctorCommentHook = Yap_MkFunctor(AtomCommentHook,3); - FunctorContext2 = Yap_MkFunctor(AtomContext,2); - FunctorConsistencyError = Yap_MkFunctor(AtomConsistencyError,1); - FunctorCreep = Yap_MkFunctor(AtomCreep,1); - FunctorCsult = Yap_MkFunctor(AtomCsult,2); - FunctorCurrentModule = Yap_MkFunctor(AtomCurrentModule,1); - FunctorCutBy = Yap_MkFunctor(AtomCutBy,1); - FunctorDBREF = Yap_MkFunctor(AtomDBREF,1); - FunctorDiff = Yap_MkFunctor(AtomDiff,2); - FunctorDoLogUpdClause = Yap_MkFunctor(AtomDoLogUpdClause,6); - FunctorDoLogUpdClause0 = Yap_MkFunctor(AtomDoLogUpdClause0,6); - FunctorDoLogUpdClauseErase = Yap_MkFunctor(AtomDoLogUpdClauseErase,6); - FunctorDoStaticClause = Yap_MkFunctor(AtomDoStaticClause,5); - FunctorDollar = Yap_MkFunctor(AtomDollar,1); - FunctorDollarVar = Yap_MkFunctor(AtomDollarVar,1); - FunctorDomainError = Yap_MkFunctor(AtomDomainError,2); - FunctorDot = Yap_MkFunctor(AtomDot,2); - FunctorDot10 = Yap_MkFunctor(AtomDot,10); - FunctorDot11 = Yap_MkFunctor(AtomDot,11); - FunctorDot12 = Yap_MkFunctor(AtomDot,12); - FunctorDot2 = Yap_MkFunctor(AtomDot,2); - FunctorDot3 = Yap_MkFunctor(AtomDot,3); - FunctorDot4 = Yap_MkFunctor(AtomDot,4); - FunctorDot5 = Yap_MkFunctor(AtomDot,5); - FunctorDot6 = Yap_MkFunctor(AtomDot,6); - FunctorDot7 = Yap_MkFunctor(AtomDot,7); - FunctorDot8 = Yap_MkFunctor(AtomDot,8); - FunctorDot9 = Yap_MkFunctor(AtomDot,9); - FunctorDoubleArrow = Yap_MkFunctor(AtomDoubleArrow,2); - FunctorDoubleSlash = Yap_MkFunctor(AtomDoubleSlash,2); - FunctorEmptySquareBrackets = Yap_MkFunctor(AtomEmptySquareBrackets,2); - FunctorEq = Yap_MkFunctor(AtomEq,2); - FunctorError = Yap_MkFunctor(AtomError,2); - FunctorEvaluationError = Yap_MkFunctor(AtomEvaluationError,1); - FunctorException = Yap_MkFunctor(AtomException,1); - FunctorExecute2InMod = Yap_MkFunctor(AtomExecuteWoMod,2); - FunctorExecuteInMod = Yap_MkFunctor(AtomExecuteInMod,2); - FunctorExecuteWithin = Yap_MkFunctor(AtomExecuteWithin,1); - FunctorExistenceError = Yap_MkFunctor(AtomExistenceError,2); - FunctorExoClause = Yap_MkFunctor(AtomExoClause,2); - FunctorFunctor = Yap_MkFunctor(AtomFunctor,3); - FunctorGAtom = Yap_MkFunctor(AtomAtom,1); - FunctorGAtomic = Yap_MkFunctor(AtomAtomic,1); - FunctorGCompound = Yap_MkFunctor(AtomCompound,1); - FunctorGFloat = Yap_MkFunctor(AtomFloat,1); - FunctorGFormatAt = Yap_MkFunctor(AtomFormatAt,2); - FunctorGInteger = Yap_MkFunctor(AtomInteger,1); - FunctorGNumber = Yap_MkFunctor(AtomNumber,1); - FunctorGPrimitive = Yap_MkFunctor(AtomPrimitive,1); - FunctorGVar = Yap_MkFunctor(AtomGVar,1); - FunctorGeneratePredInfo = Yap_MkFunctor(AtomGeneratePredInfo,4); - FunctorGoalExpansion2 = Yap_MkFunctor(AtomGoalExpansion,2); - FunctorGoalExpansion = Yap_MkFunctor(AtomGoalExpansion,3); - FunctorHandleThrow = Yap_MkFunctor(AtomHandleThrow,3); - FunctorHat = Yap_MkFunctor(AtomHat,2); - FunctorI = Yap_MkFunctor(AtomI,2); - FunctorId = Yap_MkFunctor(AtomId,1); - FunctorInfo1 = Yap_MkFunctor(AtomInfo,1); - FunctorInfo2 = Yap_MkFunctor(AtomInfo,2); - FunctorInfo3 = Yap_MkFunctor(AtomInfo,3); - FunctorInfo4 = Yap_MkFunctor(AtomInfo,4); - FunctorIs = Yap_MkFunctor(AtomIs,2); - FunctorJ = Yap_MkFunctor(AtomJ,2); - FunctorLastExecuteWithin = Yap_MkFunctor(AtomLastExecuteWithin,1); - FunctorList = Yap_MkFunctor(AtomDot,2); - FunctorLOOP = Yap_MkFunctor(AtomLOOP,1); - FunctorMegaClause = Yap_MkFunctor(AtomMegaClause,2); - FunctorMetaCall = Yap_MkFunctor(AtomMetaCall,4); - FunctorMinus = Yap_MkFunctor(AtomMinus,2); - FunctorModule = Yap_MkFunctor(AtomColon,2); - FunctorMultiFileClause = Yap_MkFunctor(AtomMfClause,5); - FunctorMutable = Yap_MkFunctor(AtomMutableVariable,(sizeof(timed_var)/sizeof(CELL))); - FunctorMutex = Yap_MkFunctor(AtomMutex,2); - FunctorNotImplemented = Yap_MkFunctor(AtomNotImplemented,2); - FunctorNBQueue = Yap_MkFunctor(AtomQueue,4); - FunctorNot = Yap_MkFunctor(AtomNot,1); - FunctorObj = Yap_MkFunctor(AtomObj,1); - FunctorOr = Yap_MkFunctor(AtomSemic,2); - FunctorOutput = Yap_MkFunctor(AtomOutput,1); - FunctorPermissionError = Yap_MkFunctor(AtomPermissionError,3); - FunctorPlus = Yap_MkFunctor(AtomPlus,2); - FunctorPortray = Yap_MkFunctor(AtomPortray,1); - FunctorPrintMessage = Yap_MkFunctor(AtomPrintMessage,2); - FunctorProcedure = Yap_MkFunctor(AtomProcedure,5); - FunctorPriority = Yap_MkFunctor(AtomPriority,1); - FunctorPrologConstraint = Yap_MkFunctor(AtomProlog,2); - FunctorProtectStack = Yap_MkFunctor(AtomProtectStack,4); - FunctorQuery = Yap_MkFunctor(AtomQuery,1); - FunctorRecordedWithKey = Yap_MkFunctor(AtomRecordedWithKey,6); - FunctorRDiv = Yap_MkFunctor(AtomRDiv,2); - FunctorRedoFreeze = Yap_MkFunctor(AtomRedoFreeze,3); - FunctorRepresentationError = Yap_MkFunctor(AtomRepresentationError,1); - FunctorResourceError = Yap_MkFunctor(AtomResourceError,1); - FunctorRestoreRegs = Yap_MkFunctor(AtomRestoreRegs,2); - FunctorRestoreRegs1 = Yap_MkFunctor(AtomRestoreRegs,1); - FunctorSafe = Yap_MkFunctor(AtomSafe,1); - FunctorSafeCallCleanup = Yap_MkFunctor(AtomSafeCallCleanup,4); - FunctorSame = Yap_MkFunctor(AtomSame,2); - FunctorSlash = Yap_MkFunctor(AtomSlash,2); - FunctorStaticClause = Yap_MkFunctor(AtomStaticClause,2); - FunctorStream = Yap_MkFunctor(AtomStream,1); - FunctorStreamEOS = Yap_MkFunctor(AtomEndOfStream,1); - FunctorStreamPos = Yap_MkFunctor(AtomStreamPos,4); - FunctorString1 = Yap_MkFunctor(AtomString,1); - FunctorStyleCheck = Yap_MkFunctor(AtomStyleCheck,4); - FunctorSyntaxError = Yap_MkFunctor(AtomSyntaxError,4); - FunctorShortSyntaxError = Yap_MkFunctor(AtomSyntaxError,1); - FunctorTermExpansion = Yap_MkFunctor(AtomTermExpansion,2); - FunctorThreadRun = Yap_MkFunctor(AtomTopThreadGoal,2); - FunctorThrow = Yap_MkFunctor(AtomThrow,1); - FunctorTimeoutError = Yap_MkFunctor(AtomTimeoutError,2); - FunctorTraceMetaCall = Yap_MkFunctor(AtomTraceMetaCall,3); - FunctorTypeError = Yap_MkFunctor(AtomTypeError,2); - FunctorUMinus = Yap_MkFunctor(AtomMinus,1); - FunctorUPlus = Yap_MkFunctor(AtomPlus,1); - FunctorVBar = Yap_MkFunctor(AtomVBar,2); - FunctorWriteTerm = Yap_MkFunctor(AtomWriteTerm,2); - FunctorHiddenVar = Yap_MkFunctor(AtomHiddenVar,1); + + /* This file, iatoms.h, was generated automatically by "yap -L misc/buildatoms" + {lease do not update, update misc/ATOMS instead */ + + AtomAtSymbol = Yap_LookupAtom("@"); TermAtSymbol = MkAtomTerm(AtomAtSymbol); + Atom3Dots = Yap_LookupAtom("..."); + AtomAbol = Yap_FullLookupAtom("$abol"); TermAbol = MkAtomTerm(AtomAbol); + AtomAccess = Yap_LookupAtom("access"); TermAccess = MkAtomTerm(AtomAccess); + AtomAfInet = Yap_LookupAtom("AF_INET"); TermAfInet = MkAtomTerm(AtomAfInet); + AtomAfLocal = Yap_LookupAtom("AF_LOCAL"); TermAfLocal = MkAtomTerm(AtomAfLocal); + AtomAfUnix = Yap_LookupAtom("AF_UNIX"); TermAfUnix = MkAtomTerm(AtomAfUnix); + AtomAlarm = Yap_FullLookupAtom("$alarm"); TermAlarm = MkAtomTerm(AtomAlarm); + AtomAlias = Yap_LookupAtom("alias"); TermAlias = MkAtomTerm(AtomAlias); + AtomAll = Yap_LookupAtom("all"); TermAll = MkAtomTerm(AtomAll); + AtomAltNot = Yap_LookupAtom("not"); TermAltNot = MkAtomTerm(AtomAltNot); + AtomAnswer = Yap_LookupAtom("answer"); TermAnswer = MkAtomTerm(AtomAnswer); + AtomAny = Yap_LookupAtom("any"); TermAny = MkAtomTerm(AtomAny); + AtomAppend = Yap_LookupAtom("append"); TermAppend = MkAtomTerm(AtomAppend); + AtomArg = Yap_LookupAtom("arg"); TermArg = MkAtomTerm(AtomArg); + AtomArray = Yap_FullLookupAtom("$array"); TermArray = MkAtomTerm(AtomArray); + AtomArrayAccess = Yap_FullLookupAtom("$array_arg"); TermArrayAccess = MkAtomTerm(AtomArrayAccess); + AtomArrayOverflow = Yap_LookupAtom("array_overflow"); TermArrayOverflow = MkAtomTerm(AtomArrayOverflow); + AtomArrayType = Yap_LookupAtom("array_type"); TermArrayType = MkAtomTerm(AtomArrayType); + AtomArrow = Yap_LookupAtom("->"); TermArrow = MkAtomTerm(AtomArrow); + AtomAttributedModule = Yap_LookupAtom("attributes_module"); TermAttributedModule = MkAtomTerm(AtomAttributedModule); + AtomDoubleArrow = Yap_LookupAtom("-->"); TermDoubleArrow = MkAtomTerm(AtomDoubleArrow); + AtomAssert = Yap_LookupAtom(":-"); TermAssert = MkAtomTerm(AtomAssert); + AtomBeginBracket = Yap_LookupAtom("("); TermBeginBracket = MkAtomTerm(AtomBeginBracket); + AtomEndBracket = Yap_LookupAtom(")"); TermEndBracket = MkAtomTerm(AtomEndBracket); + AtomBeginSquareBracket = Yap_LookupAtom("["); TermBeginSquareBracket = MkAtomTerm(AtomBeginSquareBracket); + AtomEndSquareBracket = Yap_LookupAtom("]"); TermEndSquareBracket = MkAtomTerm(AtomEndSquareBracket); + AtomBeginCurlyBracket = Yap_LookupAtom("{"); TermBeginCurlyBracket = MkAtomTerm(AtomBeginCurlyBracket); + AtomEndCurlyBracket = Yap_LookupAtom("}"); TermEndCurlyBracket = MkAtomTerm(AtomEndCurlyBracket); + AtomEmptyBrackets = Yap_LookupAtom("()"); TermEmptyBrackets = MkAtomTerm(AtomEmptyBrackets); + AtomEmptySquareBrackets = Yap_LookupAtom("[]"); TermEmptySquareBrackets = MkAtomTerm(AtomEmptySquareBrackets); + AtomAs = Yap_LookupAtom("as"); TermAs = MkAtomTerm(AtomAs); + AtomAsserta = Yap_LookupAtom("asserta"); TermAsserta = MkAtomTerm(AtomAsserta); + AtomAssertaStatic = Yap_LookupAtom("asserta_static"); TermAssertaStatic = MkAtomTerm(AtomAssertaStatic); + AtomAssertz = Yap_LookupAtom("assertz"); TermAssertz = MkAtomTerm(AtomAssertz); + AtomAssertzStatic = Yap_LookupAtom("assertz_static"); TermAssertzStatic = MkAtomTerm(AtomAssertzStatic); + AtomAt = Yap_LookupAtom("at"); TermAt = MkAtomTerm(AtomAt); + AtomAtom = Yap_LookupAtom("atom"); TermAtom = MkAtomTerm(AtomAtom); + AtomAtomic = Yap_LookupAtom("atomic"); TermAtomic = MkAtomTerm(AtomAtomic); + AtomAtt = Yap_FullLookupAtom("$att"); TermAtt = MkAtomTerm(AtomAtt); + AtomAtt1 = Yap_LookupAtom("att"); TermAtt1 = MkAtomTerm(AtomAtt1); + AtomAttDo = Yap_FullLookupAtom("$att_do"); TermAttDo = MkAtomTerm(AtomAttDo); + AtomAttributes = Yap_LookupAtom("attributes"); TermAttributes = MkAtomTerm(AtomAttributes); + AtomB = Yap_FullLookupAtom("$last_choice_pt"); TermB = MkAtomTerm(AtomB); + AtomBatched = Yap_LookupAtom("batched"); TermBatched = MkAtomTerm(AtomBatched); + AtomBetween = Yap_LookupAtom("between"); TermBetween = MkAtomTerm(AtomBetween); + AtomBinary = Yap_LookupAtom("binary"); TermBinary = MkAtomTerm(AtomBinary); + AtomBigNum = Yap_LookupAtom("big_num"); TermBigNum = MkAtomTerm(AtomBigNum); + AtomBinaryStream = Yap_LookupAtom("binary_stream"); TermBinaryStream = MkAtomTerm(AtomBinaryStream); + AtomBoolean = Yap_LookupAtom("boolean"); TermBoolean = MkAtomTerm(AtomBoolean); + AtomBraces = Yap_LookupAtom("{}"); TermBraces = MkAtomTerm(AtomBraces); + AtomBreak = Yap_FullLookupAtom("$break"); TermBreak = MkAtomTerm(AtomBreak); + AtomByte = Yap_LookupAtom("byte"); TermByte = MkAtomTerm(AtomByte); + AtomCArith = Yap_FullLookupAtom("$c_arith"); TermCArith = MkAtomTerm(AtomCArith); + AtomCall = Yap_LookupAtom("call"); TermCall = MkAtomTerm(AtomCall); + AtomCallAndRetryCounter = Yap_LookupAtom("call_and_retry_counter"); TermCallAndRetryCounter = MkAtomTerm(AtomCallAndRetryCounter); + AtomCallCounter = Yap_LookupAtom("call_counter"); TermCallCounter = MkAtomTerm(AtomCallCounter); + AtomCallable = Yap_LookupAtom("callable"); TermCallable = MkAtomTerm(AtomCallable); + AtomCatch = Yap_FullLookupAtom("$catch"); TermCatch = MkAtomTerm(AtomCatch); + AtomChangeModule = Yap_FullLookupAtom("$change_module"); TermChangeModule = MkAtomTerm(AtomChangeModule); + AtomChar = Yap_LookupAtom("char"); TermChar = MkAtomTerm(AtomChar); + AtomCharsio = Yap_LookupAtom("charsio"); TermCharsio = MkAtomTerm(AtomCharsio); + AtomCharacter = Yap_LookupAtom("character"); TermCharacter = MkAtomTerm(AtomCharacter); + AtomCharacterCode = Yap_LookupAtom("character_code"); TermCharacterCode = MkAtomTerm(AtomCharacterCode); + AtomChars = Yap_LookupAtom("chars"); TermChars = MkAtomTerm(AtomChars); + AtomCharset = Yap_LookupAtom("charset"); TermCharset = MkAtomTerm(AtomCharset); + AtomChType = Yap_FullLookupAtom("$char_type"); TermChType = MkAtomTerm(AtomChType); + AtomCleanCall = Yap_FullLookupAtom("$clean_call"); TermCleanCall = MkAtomTerm(AtomCleanCall); + AtomClose = Yap_LookupAtom("close"); TermClose = MkAtomTerm(AtomClose); + AtomColon = Yap_LookupAtom(":"); TermColon = MkAtomTerm(AtomColon); + AtomCodeSpace = Yap_LookupAtom("code_space"); TermCodeSpace = MkAtomTerm(AtomCodeSpace); + AtomCodes = Yap_LookupAtom("codes"); TermCodes = MkAtomTerm(AtomCodes); + AtomCoInductive = Yap_LookupAtom("coinductive"); TermCoInductive = MkAtomTerm(AtomCoInductive); + AtomComma = Yap_LookupAtom(","); TermComma = MkAtomTerm(AtomComma); + AtomCommentHook = Yap_LookupAtom("comment_hook"); TermCommentHook = MkAtomTerm(AtomCommentHook); + AtomCompact = Yap_LookupAtom("compact"); TermCompact = MkAtomTerm(AtomCompact); + AtomCompound = Yap_LookupAtom("compound"); TermCompound = MkAtomTerm(AtomCompound); + AtomConsistencyError = Yap_LookupAtom("consistency_error"); TermConsistencyError = MkAtomTerm(AtomConsistencyError); + AtomConsult = Yap_LookupAtom("consult"); TermConsult = MkAtomTerm(AtomConsult); + AtomConsultOnBoot = Yap_FullLookupAtom("$consult_on_boot"); TermConsultOnBoot = MkAtomTerm(AtomConsultOnBoot); + AtomContext = Yap_LookupAtom("context"); TermContext = MkAtomTerm(AtomContext); + AtomCputime = Yap_LookupAtom("cputime"); TermCputime = MkAtomTerm(AtomCputime); + AtomCreate = Yap_LookupAtom("create"); TermCreate = MkAtomTerm(AtomCreate); + AtomCreep = Yap_FullLookupAtom("$creep"); TermCreep = MkAtomTerm(AtomCreep); + AtomCryptAtoms = Yap_LookupAtom("crypt_atoms"); TermCryptAtoms = MkAtomTerm(AtomCryptAtoms); + AtomCurly = Yap_LookupAtom("{}"); TermCurly = MkAtomTerm(AtomCurly); + AtomCsult = Yap_FullLookupAtom("$csult"); TermCsult = MkAtomTerm(AtomCsult); + AtomCurrentModule = Yap_FullLookupAtom("$current_module"); TermCurrentModule = MkAtomTerm(AtomCurrentModule); + AtomCut = Yap_LookupAtom("!"); TermCut = MkAtomTerm(AtomCut); + AtomCutBy = Yap_FullLookupAtom("$cut_by"); TermCutBy = MkAtomTerm(AtomCutBy); + AtomDAbort = Yap_LookupAtom("abort"); TermDAbort = MkAtomTerm(AtomDAbort); + AtomDBLoad = Yap_FullLookupAtom("$db_load"); TermDBLoad = MkAtomTerm(AtomDBLoad); + AtomDBREF = Yap_LookupAtom("DBRef"); TermDBREF = MkAtomTerm(AtomDBREF); + AtomDBReference = Yap_LookupAtom("db_reference"); TermDBReference = MkAtomTerm(AtomDBReference); + AtomDBTerm = Yap_LookupAtom("db_term"); TermDBTerm = MkAtomTerm(AtomDBTerm); + AtomDBref = Yap_FullLookupAtom("$dbref"); TermDBref = MkAtomTerm(AtomDBref); + AtomDInteger = Yap_FullLookupAtom("$integer"); TermDInteger = MkAtomTerm(AtomDInteger); + AtomDebugMeta = Yap_FullLookupAtom("$debug_meta"); TermDebugMeta = MkAtomTerm(AtomDebugMeta); + AtomDebuggerInput = Yap_LookupAtom("debugger_input"); TermDebuggerInput = MkAtomTerm(AtomDebuggerInput); + AtomDec10 = Yap_LookupAtom("dec10"); TermDec10 = MkAtomTerm(AtomDec10); + AtomDefault = Yap_LookupAtom("default"); TermDefault = MkAtomTerm(AtomDefault); + AtomDevNull = Yap_LookupAtom("/dev/null"); TermDevNull = MkAtomTerm(AtomDevNull); + AtomDiff = Yap_LookupAtom("\\="); TermDiff = MkAtomTerm(AtomDiff); + AtomDirectory = Yap_LookupAtom("disrectorys"); TermDirectory = MkAtomTerm(AtomDirectory); + AtomDiscontiguous = Yap_LookupAtom("discontiguous"); TermDiscontiguous = MkAtomTerm(AtomDiscontiguous); + AtomDiscontiguousWarnings = Yap_LookupAtom("discontiguous_warnings"); TermDiscontiguousWarnings = MkAtomTerm(AtomDiscontiguousWarnings); + AtomDollar = Yap_FullLookupAtom("$"); TermDollar = MkAtomTerm(AtomDollar); + AtomDoLogUpdClause = Yap_FullLookupAtom("$do_log_upd_clause"); TermDoLogUpdClause = MkAtomTerm(AtomDoLogUpdClause); + AtomDoLogUpdClause0 = Yap_FullLookupAtom("$do_log_upd_clause0"); TermDoLogUpdClause0 = MkAtomTerm(AtomDoLogUpdClause0); + AtomDoLogUpdClauseErase = Yap_FullLookupAtom("$do_log_upd_clause_erase"); TermDoLogUpdClauseErase = MkAtomTerm(AtomDoLogUpdClauseErase); + AtomDollarU = Yap_FullLookupAtom("$u"); TermDollarU = MkAtomTerm(AtomDollarU); + AtomDollarUndef = Yap_FullLookupAtom("$undef"); TermDollarUndef = MkAtomTerm(AtomDollarUndef); + AtomDomainError = Yap_LookupAtom("domain_error"); TermDomainError = MkAtomTerm(AtomDomainError); + AtomDoStaticClause = Yap_FullLookupAtom("$do_static_clause"); TermDoStaticClause = MkAtomTerm(AtomDoStaticClause); + AtomDots = Yap_LookupAtom("dots"); TermDots = MkAtomTerm(AtomDots); + AtomDOUBLE = Yap_FullLookupAtom("Double"); TermDOUBLE = MkAtomTerm(AtomDOUBLE); + AtomDoubleSlash = Yap_FullLookupAtom("//"); TermDoubleSlash = MkAtomTerm(AtomDoubleSlash); + AtomE = Yap_LookupAtom("e"); TermE = MkAtomTerm(AtomE); + AtomEOFBeforeEOT = Yap_LookupAtom("end_of_file_found_before_end_of_term"); TermEOFBeforeEOT = MkAtomTerm(AtomEOFBeforeEOT); + AtomEQ = Yap_LookupAtom("="); TermEQ = MkAtomTerm(AtomEQ); + AtomEmptyAtom = Yap_LookupAtom(""); TermEmptyAtom = MkAtomTerm(AtomEmptyAtom); + AtomEncoding = Yap_LookupAtom("encoding"); TermEncoding = MkAtomTerm(AtomEncoding); + AtomEndOfStream = Yap_LookupAtom("$end_of_stream"); TermEndOfStream = MkAtomTerm(AtomEndOfStream); + AtomEof = Yap_LookupAtom("end_of_file"); TermEof = MkAtomTerm(AtomEof); + AtomEOfCode = Yap_LookupAtom("eof_code"); TermEOfCode = MkAtomTerm(AtomEOfCode); + AtomEq = Yap_LookupAtom("="); TermEq = MkAtomTerm(AtomEq); + AtomError = Yap_LookupAtom("error"); TermError = MkAtomTerm(AtomError); + AtomException = Yap_LookupAtom("exception"); TermException = MkAtomTerm(AtomException); + AtomExtensions = Yap_LookupAtom("extensions"); TermExtensions = MkAtomTerm(AtomExtensions); + AtomExternalException = Yap_LookupAtom("external_exception"); TermExternalException = MkAtomTerm(AtomExternalException); + AtomEvaluable = Yap_LookupAtom("evaluable"); TermEvaluable = MkAtomTerm(AtomEvaluable); + AtomEvaluationError = Yap_LookupAtom("evaluation_error"); TermEvaluationError = MkAtomTerm(AtomEvaluationError); + AtomExecutable = Yap_LookupAtom("executable"); TermExecutable = MkAtomTerm(AtomExecutable); + AtomExecute = Yap_LookupAtom("execute"); TermExecute = MkAtomTerm(AtomExecute); + AtomExecAnswers = Yap_LookupAtom("exec_answers"); TermExecAnswers = MkAtomTerm(AtomExecAnswers); + AtomExecuteInMod = Yap_FullLookupAtom("$execute_in_mod"); TermExecuteInMod = MkAtomTerm(AtomExecuteInMod); + AtomExecuteWithin = Yap_FullLookupAtom("$execute_within"); TermExecuteWithin = MkAtomTerm(AtomExecuteWithin); + AtomExecuteWoMod = Yap_FullLookupAtom("$execute_wo_mod"); TermExecuteWoMod = MkAtomTerm(AtomExecuteWoMod); + AtomExist = Yap_LookupAtom("exist"); TermExist = MkAtomTerm(AtomExist); + AtomExists = Yap_LookupAtom("exists"); TermExists = MkAtomTerm(AtomExists); + AtomExit = Yap_LookupAtom("exit"); TermExit = MkAtomTerm(AtomExit); + AtomExistenceError = Yap_LookupAtom("existence_error"); TermExistenceError = MkAtomTerm(AtomExistenceError); + AtomExoClause = Yap_FullLookupAtom("$exo_clause"); TermExoClause = MkAtomTerm(AtomExoClause); + AtomExpectedNumber = Yap_LookupAtom("expected_number_syntax"); TermExpectedNumber = MkAtomTerm(AtomExpectedNumber); + AtomExpand = Yap_LookupAtom("expand"); TermExpand = MkAtomTerm(AtomExpand); + AtomExtendFileSearchPath = Yap_FullLookupAtom("$extend_file_search_path"); TermExtendFileSearchPath = MkAtomTerm(AtomExtendFileSearchPath); + AtomExtendsions = Yap_LookupAtom("extensionh"); TermExtendsions = MkAtomTerm(AtomExtendsions); + AtomFB = Yap_LookupAtom("fb"); TermFB = MkAtomTerm(AtomFB); + AtomFail = Yap_LookupAtom("fail"); TermFail = MkAtomTerm(AtomFail); + AtomFalse = Yap_LookupAtom("false"); TermFalse = MkAtomTerm(AtomFalse); + AtomFast = Yap_FullLookupAtom("$fast"); TermFast = MkAtomTerm(AtomFast); + AtomFastFail = Yap_LookupAtom("fast_fail"); TermFastFail = MkAtomTerm(AtomFastFail); + AtomFileErrors = Yap_LookupAtom("file_errors"); TermFileErrors = MkAtomTerm(AtomFileErrors); + AtomFileerrors = Yap_LookupAtom("fileerrors"); TermFileerrors = MkAtomTerm(AtomFileerrors); + AtomFileType = Yap_LookupAtom("file_type"); TermFileType = MkAtomTerm(AtomFileType); + AtomFirst = Yap_LookupAtom("first"); TermFirst = MkAtomTerm(AtomFirst); + AtomFloat = Yap_LookupAtom("float"); TermFloat = MkAtomTerm(AtomFloat); + AtomFloatFormat = Yap_LookupAtom("\%.15g"); TermFloatFormat = MkAtomTerm(AtomFloatFormat); + AtomFloatOverflow = Yap_LookupAtom("float_overflow"); TermFloatOverflow = MkAtomTerm(AtomFloatOverflow); + AtomFloatUnderflow = Yap_LookupAtom("float_underflow"); TermFloatUnderflow = MkAtomTerm(AtomFloatUnderflow); + AtomFormat = Yap_LookupAtom("format"); TermFormat = MkAtomTerm(AtomFormat); + AtomFormatAt = Yap_FullLookupAtom("$format@"); TermFormatAt = MkAtomTerm(AtomFormatAt); + AtomFull = Yap_LookupAtom("full"); TermFull = MkAtomTerm(AtomFull); + AtomFunctor = Yap_LookupAtom("functor"); TermFunctor = MkAtomTerm(AtomFunctor); + AtomGT = Yap_LookupAtom(">"); TermGT = MkAtomTerm(AtomGT); + AtomGVar = Yap_LookupAtom("var"); TermGVar = MkAtomTerm(AtomGVar); + Atomg = Yap_LookupAtom("g"); Termg = MkAtomTerm(Atomg); + AtomGc = Yap_FullLookupAtom("$gc"); TermGc = MkAtomTerm(AtomGc); + AtomGcMargin = Yap_FullLookupAtom("$gc_margin"); TermGcMargin = MkAtomTerm(AtomGcMargin); + AtomGcTrace = Yap_FullLookupAtom("$gc_trace"); TermGcTrace = MkAtomTerm(AtomGcTrace); + AtomGcVerbose = Yap_FullLookupAtom("$gc_verbose"); TermGcVerbose = MkAtomTerm(AtomGcVerbose); + AtomGcVeryVerbose = Yap_FullLookupAtom("$gc_very_verbose"); TermGcVeryVerbose = MkAtomTerm(AtomGcVeryVerbose); + AtomGeneratePredInfo = Yap_FullLookupAtom("$generate_pred_info"); TermGeneratePredInfo = MkAtomTerm(AtomGeneratePredInfo); + AtomGetwork = Yap_FullLookupAtom("$getwork"); TermGetwork = MkAtomTerm(AtomGetwork); + AtomGetworkSeq = Yap_FullLookupAtom("$getwork_seq"); TermGetworkSeq = MkAtomTerm(AtomGetworkSeq); + AtomGlob = Yap_LookupAtom("glob"); TermGlob = MkAtomTerm(AtomGlob); + AtomGlobal = Yap_LookupAtom("global"); TermGlobal = MkAtomTerm(AtomGlobal); + AtomGlobalSp = Yap_LookupAtom("global_sp"); TermGlobalSp = MkAtomTerm(AtomGlobalSp); + AtomGlobalTrie = Yap_LookupAtom("global_trie"); TermGlobalTrie = MkAtomTerm(AtomGlobalTrie); + AtomGoalExpansion = Yap_LookupAtom("goal_expansion"); TermGoalExpansion = MkAtomTerm(AtomGoalExpansion); + AtomHat = Yap_LookupAtom("^"); TermHat = MkAtomTerm(AtomHat); + AtomDoubleHat = Yap_LookupAtom("^^"); TermDoubleHat = MkAtomTerm(AtomDoubleHat); + AtomHERE = Yap_LookupAtom("\n <====HERE====> \n"); TermHERE = MkAtomTerm(AtomHERE); + AtomHandleThrow = Yap_FullLookupAtom("$handle_throw"); TermHandleThrow = MkAtomTerm(AtomHandleThrow); + AtomHeap = Yap_LookupAtom("heap"); TermHeap = MkAtomTerm(AtomHeap); + AtomHeapUsed = Yap_LookupAtom("heapused"); TermHeapUsed = MkAtomTerm(AtomHeapUsed); + AtomHugeInt = Yap_LookupAtom("huge_int"); TermHugeInt = MkAtomTerm(AtomHugeInt); + AtomIDB = Yap_LookupAtom("idb"); TermIDB = MkAtomTerm(AtomIDB); + AtomIOMode = Yap_LookupAtom("io_mode"); TermIOMode = MkAtomTerm(AtomIOMode); + AtomI = Yap_LookupAtom("i"); TermI = MkAtomTerm(AtomI); + AtomId = Yap_LookupAtom("id"); TermId = MkAtomTerm(AtomId); + AtomIgnore = Yap_LookupAtom("ignore"); TermIgnore = MkAtomTerm(AtomIgnore); + AtomInf = Yap_LookupAtom("inf"); TermInf = MkAtomTerm(AtomInf); + AtomInfinity = Yap_LookupAtom("infinity"); TermInfinity = MkAtomTerm(AtomInfinity); + AtomInfo = Yap_LookupAtom("info"); TermInfo = MkAtomTerm(AtomInfo); + AtomInitGoal = Yap_FullLookupAtom("$init_goal"); TermInitGoal = MkAtomTerm(AtomInitGoal); + AtomInitProlog = Yap_FullLookupAtom("$init_prolog"); TermInitProlog = MkAtomTerm(AtomInitProlog); + AtomInStackExpansion = Yap_LookupAtom("in stack expansion"); TermInStackExpansion = MkAtomTerm(AtomInStackExpansion); + AtomInput = Yap_LookupAtom("input"); TermInput = MkAtomTerm(AtomInput); + AtomInstantiationError = Yap_LookupAtom("instantiation_error"); TermInstantiationError = MkAtomTerm(AtomInstantiationError); + AtomInt = Yap_LookupAtom("int"); TermInt = MkAtomTerm(AtomInt); + AtomIntOverflow = Yap_LookupAtom("int_overflow"); TermIntOverflow = MkAtomTerm(AtomIntOverflow); + AtomInteger = Yap_LookupAtom("integer"); TermInteger = MkAtomTerm(AtomInteger); + AtomInternalCompilerError = Yap_LookupAtom("internal_compiler_error"); TermInternalCompilerError = MkAtomTerm(AtomInternalCompilerError); + AtomIs = Yap_LookupAtom("is"); TermIs = MkAtomTerm(AtomIs); + AtomJ = Yap_LookupAtom("j"); TermJ = MkAtomTerm(AtomJ); + Atoml = Yap_LookupAtom("l"); Terml = MkAtomTerm(Atoml); + AtomKey = Yap_LookupAtom("key"); TermKey = MkAtomTerm(AtomKey); + AtomLDLibraryPath = Yap_LookupAtom("LD_LIBRARY_PATH"); TermLDLibraryPath = MkAtomTerm(AtomLDLibraryPath); + AtomLONGINT = Yap_LookupAtom("LongInt"); TermLONGINT = MkAtomTerm(AtomLONGINT); + AtomLOOP = Yap_LookupAtom("_LOOP_"); TermLOOP = MkAtomTerm(AtomLOOP); + AtomLoopStream = Yap_LookupAtom("loop_stream"); TermLoopStream = MkAtomTerm(AtomLoopStream); + AtomLT = Yap_LookupAtom("<"); TermLT = MkAtomTerm(AtomLT); + AtomLastExecuteWithin = Yap_FullLookupAtom("$last_execute_within"); TermLastExecuteWithin = MkAtomTerm(AtomLastExecuteWithin); + AtomLeash = Yap_FullLookupAtom("$leash"); TermLeash = MkAtomTerm(AtomLeash); + AtomLeast = Yap_LookupAtom("least"); TermLeast = MkAtomTerm(AtomLeast); + AtomLength = Yap_FullLookupAtom("length"); TermLength = MkAtomTerm(AtomLength); + AtomList = Yap_LookupAtom("list"); TermList = MkAtomTerm(AtomList); + AtomLine = Yap_LookupAtom("line"); TermLine = MkAtomTerm(AtomLine); + AtomLive = Yap_FullLookupAtom("live"); TermLive = MkAtomTerm(AtomLive); + AtomLoadAnswers = Yap_LookupAtom("load_answers"); TermLoadAnswers = MkAtomTerm(AtomLoadAnswers); + AtomLocal = Yap_LookupAtom("local"); TermLocal = MkAtomTerm(AtomLocal); + AtomLocalSp = Yap_LookupAtom("local_sp"); TermLocalSp = MkAtomTerm(AtomLocalSp); + AtomLocalTrie = Yap_LookupAtom("local_trie"); TermLocalTrie = MkAtomTerm(AtomLocalTrie); + AtomMax = Yap_LookupAtom("max"); TermMax = MkAtomTerm(AtomMax); + AtomMaximum = Yap_LookupAtom("maximum"); TermMaximum = MkAtomTerm(AtomMaximum); + AtomMaxArity = Yap_LookupAtom("max_arity"); TermMaxArity = MkAtomTerm(AtomMaxArity); + AtomMaxFiles = Yap_LookupAtom("max_files"); TermMaxFiles = MkAtomTerm(AtomMaxFiles); + AtomMegaClause = Yap_FullLookupAtom("$mega_clause"); TermMegaClause = MkAtomTerm(AtomMegaClause); + AtomMetaCall = Yap_FullLookupAtom("$call"); TermMetaCall = MkAtomTerm(AtomMetaCall); + AtomMfClause = Yap_FullLookupAtom("$mf_clause"); TermMfClause = MkAtomTerm(AtomMfClause); + AtomMin = Yap_LookupAtom("min"); TermMin = MkAtomTerm(AtomMin); + AtomMinimum = Yap_LookupAtom("minimum"); TermMinimum = MkAtomTerm(AtomMinimum); + AtomMinus = Yap_LookupAtom("-"); TermMinus = MkAtomTerm(AtomMinus); + AtomModify = Yap_LookupAtom("modify"); TermModify = MkAtomTerm(AtomModify); + AtomModule = Yap_LookupAtom("module"); TermModule = MkAtomTerm(AtomModule); + AtomMost = Yap_LookupAtom("most"); TermMost = MkAtomTerm(AtomMost); + AtomMulti = Yap_LookupAtom("multi"); TermMulti = MkAtomTerm(AtomMulti); + AtomMultiFile = Yap_FullLookupAtom("$mf"); TermMultiFile = MkAtomTerm(AtomMultiFile); + AtomMultiple = Yap_FullLookupAtom("multiple"); TermMultiple = MkAtomTerm(AtomMultiple); + AtomMutable = Yap_LookupAtom("mutable"); TermMutable = MkAtomTerm(AtomMutable); + AtomMutableVariable = Yap_FullLookupAtom("$mutable_variable"); TermMutableVariable = MkAtomTerm(AtomMutableVariable); + AtomMutex = Yap_LookupAtom("mutex"); TermMutex = MkAtomTerm(AtomMutex); + AtomMyddasDB = Yap_FullLookupAtom("$myddas_db"); TermMyddasDB = MkAtomTerm(AtomMyddasDB); + AtomMyddasGoal = Yap_FullLookupAtom("$myddas_goal"); TermMyddasGoal = MkAtomTerm(AtomMyddasGoal); + AtomMyddasHost = Yap_FullLookupAtom("$myddas_host"); TermMyddasHost = MkAtomTerm(AtomMyddasHost); + AtomMyddasPass = Yap_FullLookupAtom("$myddas_pass"); TermMyddasPass = MkAtomTerm(AtomMyddasPass); + AtomMyddasUser = Yap_FullLookupAtom("$myddas_user"); TermMyddasUser = MkAtomTerm(AtomMyddasUser); + AtomMyddasVersionName = Yap_FullLookupAtom("$myddas_version_name"); TermMyddasVersionName = MkAtomTerm(AtomMyddasVersionName); + AtomNan = Yap_LookupAtom("nan"); TermNan = MkAtomTerm(AtomNan); + AtomNb = Yap_LookupAtom("nb"); TermNb = MkAtomTerm(AtomNb); + AtomNbTerm = Yap_LookupAtom("nb_term"); TermNbTerm = MkAtomTerm(AtomNbTerm); + AtomNew = Yap_LookupAtom("new"); TermNew = MkAtomTerm(AtomNew); + AtomNewLine = Yap_LookupAtom("nl"); TermNewLine = MkAtomTerm(AtomNewLine); + AtomNl = Yap_LookupAtom("nl"); TermNl = MkAtomTerm(AtomNl); + AtomNoEffect = Yap_LookupAtom("no_effect"); TermNoEffect = MkAtomTerm(AtomNoEffect); + AtomNoMemory = Yap_LookupAtom("no_memory"); TermNoMemory = MkAtomTerm(AtomNoMemory); + AtomNone = Yap_LookupAtom("none"); TermNone = MkAtomTerm(AtomNone); + AtomNonEmptyList = Yap_LookupAtom("non_empty_list"); TermNonEmptyList = MkAtomTerm(AtomNonEmptyList); + AtomNot = Yap_LookupAtom("\\+"); TermNot = MkAtomTerm(AtomNot); + AtomNotImplemented = Yap_LookupAtom("not_implemented"); TermNotImplemented = MkAtomTerm(AtomNotImplemented); + AtomNotLessThanZero = Yap_LookupAtom("not_less_than_zero"); TermNotLessThanZero = MkAtomTerm(AtomNotLessThanZero); + AtomNotNewline = Yap_LookupAtom("not_newline"); TermNotNewline = MkAtomTerm(AtomNotNewline); + AtomNotZero = Yap_LookupAtom("not_zero"); TermNotZero = MkAtomTerm(AtomNotZero); + AtomNumber = Yap_LookupAtom("number"); TermNumber = MkAtomTerm(AtomNumber); + AtomObj = Yap_LookupAtom("__obj__"); TermObj = MkAtomTerm(AtomObj); + AtomOff = Yap_LookupAtom("off"); TermOff = MkAtomTerm(AtomOff); + AtomOffline = Yap_LookupAtom("offline"); TermOffline = MkAtomTerm(AtomOffline); + AtomOn = Yap_LookupAtom("on"); TermOn = MkAtomTerm(AtomOn); + AtomOnline = Yap_LookupAtom("online"); TermOnline = MkAtomTerm(AtomOnline); + AtomOpen = Yap_LookupAtom("open"); TermOpen = MkAtomTerm(AtomOpen); + AtomOperatingSystemError = Yap_LookupAtom("operating_SYSTEM_ERROR_INTERNAL"); TermOperatingSystemError = MkAtomTerm(AtomOperatingSystemError); + AtomOperatingSystemSupport = Yap_LookupAtom("operating_system_support"); TermOperatingSystemSupport = MkAtomTerm(AtomOperatingSystemSupport); + AtomOperator = Yap_LookupAtom("operator"); TermOperator = MkAtomTerm(AtomOperator); + AtomOperatorPriority = Yap_LookupAtom("operator_priority"); TermOperatorPriority = MkAtomTerm(AtomOperatorPriority); + AtomOperatorSpecifier = Yap_LookupAtom("operator_specifier"); TermOperatorSpecifier = MkAtomTerm(AtomOperatorSpecifier); + AtomOpt = Yap_LookupAtom("opt"); TermOpt = MkAtomTerm(AtomOpt); + AtomOtherwise = Yap_LookupAtom("otherwise"); TermOtherwise = MkAtomTerm(AtomOtherwise); + AtomOutOfAttvarsError = Yap_LookupAtom("out_of_attvars_error"); TermOutOfAttvarsError = MkAtomTerm(AtomOutOfAttvarsError); + AtomOutOfAuxspaceError = Yap_LookupAtom("out_of_auxspace_error"); TermOutOfAuxspaceError = MkAtomTerm(AtomOutOfAuxspaceError); + AtomOutOfHeapError = Yap_LookupAtom("out_of_heap_error"); TermOutOfHeapError = MkAtomTerm(AtomOutOfHeapError); + AtomOutOfRange = Yap_LookupAtom("out_of_range"); TermOutOfRange = MkAtomTerm(AtomOutOfRange); + AtomOutOfStackError = Yap_LookupAtom("out_of_stack_error"); TermOutOfStackError = MkAtomTerm(AtomOutOfStackError); + AtomOutOfTrailError = Yap_LookupAtom("out_of_trail_error"); TermOutOfTrailError = MkAtomTerm(AtomOutOfTrailError); + AtomOutput = Yap_LookupAtom("output"); TermOutput = MkAtomTerm(AtomOutput); + AtomParameter = Yap_LookupAtom("parameter"); TermParameter = MkAtomTerm(AtomParameter); + AtomPast = Yap_LookupAtom("past"); TermPast = MkAtomTerm(AtomPast); + AtomPastEndOfStream = Yap_LookupAtom("past_end_of_stream"); TermPastEndOfStream = MkAtomTerm(AtomPastEndOfStream); + AtomPermissionError = Yap_LookupAtom("permission_error"); TermPermissionError = MkAtomTerm(AtomPermissionError); + AtomPi = Yap_LookupAtom("pi"); TermPi = MkAtomTerm(AtomPi); + AtomPipe = Yap_LookupAtom("pipe"); TermPipe = MkAtomTerm(AtomPipe); + AtomPriority = Yap_LookupAtom("priority"); TermPriority = MkAtomTerm(AtomPriority); + AtomPlus = Yap_LookupAtom("+"); TermPlus = MkAtomTerm(AtomPlus); + AtomPointer = Yap_LookupAtom("pointer"); TermPointer = MkAtomTerm(AtomPointer); + AtomPopen = Yap_LookupAtom("popen"); TermPopen = MkAtomTerm(AtomPopen); + AtomPortray = Yap_FullLookupAtom("portray"); TermPortray = MkAtomTerm(AtomPortray); + AtomPredicateIndicator = Yap_LookupAtom("predicate_indicator"); TermPredicateIndicator = MkAtomTerm(AtomPredicateIndicator); + AtomPrimitive = Yap_LookupAtom("primitive"); TermPrimitive = MkAtomTerm(AtomPrimitive); + AtomPrintMessage = Yap_LookupAtom("print_message"); TermPrintMessage = MkAtomTerm(AtomPrintMessage); + AtomPrivateProcedure = Yap_LookupAtom("private_procedure"); TermPrivateProcedure = MkAtomTerm(AtomPrivateProcedure); + AtomProcedure = Yap_LookupAtom("procedure"); TermProcedure = MkAtomTerm(AtomProcedure); + AtomProfile = Yap_FullLookupAtom("$profile"); TermProfile = MkAtomTerm(AtomProfile); + AtomProlog = Yap_LookupAtom("prolog"); TermProlog = MkAtomTerm(AtomProlog); + AtomPrologCommonsDir = Yap_LookupAtom("prolog_commons_directory"); TermPrologCommonsDir = MkAtomTerm(AtomPrologCommonsDir); + AtomProtectStack = Yap_FullLookupAtom("$protect_stack"); TermProtectStack = MkAtomTerm(AtomProtectStack); + AtomQly = Yap_LookupAtom("qly"); TermQly = MkAtomTerm(AtomQly); + AtomQuery = Yap_LookupAtom("?-"); TermQuery = MkAtomTerm(AtomQuery); + AtomQueue = Yap_LookupAtom("queue"); TermQueue = MkAtomTerm(AtomQueue); + AtomQuiet = Yap_LookupAtom("quiet"); TermQuiet = MkAtomTerm(AtomQuiet); + AtomRadix = Yap_LookupAtom("radix"); TermRadix = MkAtomTerm(AtomRadix); + AtomRandom = Yap_LookupAtom("random"); TermRandom = MkAtomTerm(AtomRandom); + AtomRange = Yap_LookupAtom("range"); TermRange = MkAtomTerm(AtomRange); + AtomRDiv = Yap_LookupAtom("rdiv"); TermRDiv = MkAtomTerm(AtomRDiv); + AtomRead = Yap_LookupAtom("read"); TermRead = MkAtomTerm(AtomRead); + AtomReadOnly = Yap_LookupAtom("read_only"); TermReadOnly = MkAtomTerm(AtomReadOnly); + AtomReadWrite = Yap_LookupAtom("read_write"); TermReadWrite = MkAtomTerm(AtomReadWrite); + AtomReadutil = Yap_LookupAtom("readutil"); TermReadutil = MkAtomTerm(AtomReadutil); + AtomReconsult = Yap_LookupAtom("reconsult"); TermReconsult = MkAtomTerm(AtomReconsult); + AtomRecordedP = Yap_FullLookupAtom("$recordep"); TermRecordedP = MkAtomTerm(AtomRecordedP); + AtomRecordedWithKey = Yap_FullLookupAtom("$recorded_with_key"); TermRecordedWithKey = MkAtomTerm(AtomRecordedWithKey); + AtomRedefineWarnings = Yap_LookupAtom("redefine_warnings"); TermRedefineWarnings = MkAtomTerm(AtomRedefineWarnings); + AtomRedo = Yap_FullLookupAtom("redo"); TermRedo = MkAtomTerm(AtomRedo); + AtomRedoFreeze = Yap_FullLookupAtom("$redo_freeze"); TermRedoFreeze = MkAtomTerm(AtomRedoFreeze); + AtomRefoundVar = Yap_FullLookupAtom("$I_FOUND_THE_VARIABLE_AGAIN"); TermRefoundVar = MkAtomTerm(AtomRefoundVar); + AtomRelativeTo = Yap_FullLookupAtom("relative_to"); TermRelativeTo = MkAtomTerm(AtomRelativeTo); + AtomRepeat = Yap_LookupAtom("repeat"); TermRepeat = MkAtomTerm(AtomRepeat); + AtomRepeatSpace = Yap_LookupAtom("repeat "); TermRepeatSpace = MkAtomTerm(AtomRepeatSpace); + AtomReposition = Yap_LookupAtom("reposition"); TermReposition = MkAtomTerm(AtomReposition); + AtomRepresentationError = Yap_LookupAtom("representation_error"); TermRepresentationError = MkAtomTerm(AtomRepresentationError); + AtomReset = Yap_LookupAtom("reset"); TermReset = MkAtomTerm(AtomReset); + AtomResize = Yap_LookupAtom("resize"); TermResize = MkAtomTerm(AtomResize); + AtomResourceError = Yap_LookupAtom("resource_error"); TermResourceError = MkAtomTerm(AtomResourceError); + AtomRestoreRegs = Yap_FullLookupAtom("$restore_regs"); TermRestoreRegs = MkAtomTerm(AtomRestoreRegs); + AtomRetry = Yap_LookupAtom("retry"); TermRetry = MkAtomTerm(AtomRetry); + AtomRetryCounter = Yap_LookupAtom("retry_counter"); TermRetryCounter = MkAtomTerm(AtomRetryCounter); + AtomRTree = Yap_LookupAtom("rtree"); TermRTree = MkAtomTerm(AtomRTree); + AtomSafe = Yap_FullLookupAtom("$safe"); TermSafe = MkAtomTerm(AtomSafe); + AtomSafeCallCleanup = Yap_FullLookupAtom("$safe_call_cleanup"); TermSafeCallCleanup = MkAtomTerm(AtomSafeCallCleanup); + AtomSame = Yap_LookupAtom("=="); TermSame = MkAtomTerm(AtomSame); + AtomSemic = Yap_LookupAtom(";"); TermSemic = MkAtomTerm(AtomSemic); + AtomShiftCountOverflow = Yap_LookupAtom("shift_count_overflow"); TermShiftCountOverflow = MkAtomTerm(AtomShiftCountOverflow); + AtomSigAlarm = Yap_LookupAtom("sig_alarm"); TermSigAlarm = MkAtomTerm(AtomSigAlarm); + AtomSigBreak = Yap_LookupAtom("sig_break"); TermSigBreak = MkAtomTerm(AtomSigBreak); + AtomSigCreep = Yap_LookupAtom("sig_creep"); TermSigCreep = MkAtomTerm(AtomSigCreep); + AtomSigDebug = Yap_LookupAtom("sig_debug"); TermSigDebug = MkAtomTerm(AtomSigDebug); + AtomSigDelayCreep = Yap_LookupAtom("sig_delay_creep"); TermSigDelayCreep = MkAtomTerm(AtomSigDelayCreep); + AtomSigFPE = Yap_LookupAtom("sig_fpe"); TermSigFPE = MkAtomTerm(AtomSigFPE); + AtomSigHup = Yap_LookupAtom("sig_hup"); TermSigHup = MkAtomTerm(AtomSigHup); + AtomSigInt = Yap_LookupAtom("sig_int"); TermSigInt = MkAtomTerm(AtomSigInt); + AtomSigIti = Yap_LookupAtom("sig_iti"); TermSigIti = MkAtomTerm(AtomSigIti); + AtomSigPending = Yap_FullLookupAtom("$sig_pending"); TermSigPending = MkAtomTerm(AtomSigPending); + AtomSigPipe = Yap_LookupAtom("sig_pipe"); TermSigPipe = MkAtomTerm(AtomSigPipe); + AtomSigStackDump = Yap_LookupAtom("sig_stack_dump"); TermSigStackDump = MkAtomTerm(AtomSigStackDump); + AtomSigStatistics = Yap_LookupAtom("sig_statistics"); TermSigStatistics = MkAtomTerm(AtomSigStatistics); + AtomSigTrace = Yap_LookupAtom("sig_trace"); TermSigTrace = MkAtomTerm(AtomSigTrace); + AtomSigUsr1 = Yap_LookupAtom("sig_usr1"); TermSigUsr1 = MkAtomTerm(AtomSigUsr1); + AtomSigUsr2 = Yap_LookupAtom("sig_usr2"); TermSigUsr2 = MkAtomTerm(AtomSigUsr2); + AtomSigVTAlarm = Yap_LookupAtom("sig_vtalarm"); TermSigVTAlarm = MkAtomTerm(AtomSigVTAlarm); + AtomSigWakeUp = Yap_LookupAtom("sig_wake_up"); TermSigWakeUp = MkAtomTerm(AtomSigWakeUp); + AtomSilent = Yap_LookupAtom("Silent"); TermSilent = MkAtomTerm(AtomSilent); + AtomSingle = Yap_LookupAtom("single"); TermSingle = MkAtomTerm(AtomSingle); + AtomSingleVarWarnings = Yap_LookupAtom("single_var_warnings"); TermSingleVarWarnings = MkAtomTerm(AtomSingleVarWarnings); + AtomSingleton = Yap_LookupAtom("singleton"); TermSingleton = MkAtomTerm(AtomSingleton); + AtomSlash = Yap_LookupAtom("/"); TermSlash = MkAtomTerm(AtomSlash); + AtomSocket = Yap_LookupAtom("socket"); TermSocket = MkAtomTerm(AtomSocket); + AtomSolutions = Yap_LookupAtom("solutions"); TermSolutions = MkAtomTerm(AtomSolutions); + AtomSource = Yap_LookupAtom("source"); TermSource = MkAtomTerm(AtomSource); + AtomSourceSink = Yap_LookupAtom("source_sink"); TermSourceSink = MkAtomTerm(AtomSourceSink); + AtomSpy = Yap_FullLookupAtom("$spy"); TermSpy = MkAtomTerm(AtomSpy); + AtomStack = Yap_LookupAtom("stack"); TermStack = MkAtomTerm(AtomStack); + AtomStackFree = Yap_LookupAtom("stackfree"); TermStackFree = MkAtomTerm(AtomStackFree); + AtomStartupSavedState = Yap_FullLookupAtom("$startup_saved_state"); TermStartupSavedState = MkAtomTerm(AtomStartupSavedState); + AtomStaticClause = Yap_FullLookupAtom("$static_clause"); TermStaticClause = MkAtomTerm(AtomStaticClause); + AtomStaticProcedure = Yap_LookupAtom("static_procedure"); TermStaticProcedure = MkAtomTerm(AtomStaticProcedure); + AtomStream = Yap_FullLookupAtom("$stream"); TermStream = MkAtomTerm(AtomStream); + AtomSWIStream = Yap_FullLookupAtom(""); TermSWIStream = MkAtomTerm(AtomSWIStream); + AtomVStream = Yap_LookupAtom("stream"); TermVStream = MkAtomTerm(AtomVStream); + AtomStreams = Yap_LookupAtom("streams"); TermStreams = MkAtomTerm(AtomStreams); + AtomStreamOrAlias = Yap_LookupAtom("stream_or_alias"); TermStreamOrAlias = MkAtomTerm(AtomStreamOrAlias); + AtomStreamPos = Yap_FullLookupAtom("$stream_position"); TermStreamPos = MkAtomTerm(AtomStreamPos); + AtomStreamPosition = Yap_LookupAtom("stream_position"); TermStreamPosition = MkAtomTerm(AtomStreamPosition); + AtomString = Yap_LookupAtom("string"); TermString = MkAtomTerm(AtomString); + AtomStyleCheck = Yap_LookupAtom("style_check"); TermStyleCheck = MkAtomTerm(AtomStyleCheck); + AtomSTRING = Yap_FullLookupAtom("String"); TermSTRING = MkAtomTerm(AtomSTRING); + AtomSwi = Yap_LookupAtom("swi"); TermSwi = MkAtomTerm(AtomSwi); + AtomSymbolChar = Yap_LookupAtom("symbol_char"); TermSymbolChar = MkAtomTerm(AtomSymbolChar); + AtomSyntaxError = Yap_LookupAtom("syntax_error"); TermSyntaxError = MkAtomTerm(AtomSyntaxError); + AtomSyntaxErrors = Yap_LookupAtom("syntax_errors"); TermSyntaxErrors = MkAtomTerm(AtomSyntaxErrors); + AtomSyntaxErrorHandler = Yap_LookupAtom("syntax_error_handler"); TermSyntaxErrorHandler = MkAtomTerm(AtomSyntaxErrorHandler); + AtomSystem = Yap_LookupAtom("system"); TermSystem = MkAtomTerm(AtomSystem); + AtomSystemError = Yap_LookupAtom("SYSTEM_ERROR_INTERNAL"); TermSystemError = MkAtomTerm(AtomSystemError); + AtomSystemLibraryDir = Yap_LookupAtom("system_library_directory"); TermSystemLibraryDir = MkAtomTerm(AtomSystemLibraryDir); + AtomT = Yap_LookupAtom("t"); TermT = MkAtomTerm(AtomT); + AtomTerm = Yap_LookupAtom("term"); TermTerm = MkAtomTerm(AtomTerm); + AtomTermExpansion = Yap_LookupAtom("term_expansion"); TermTermExpansion = MkAtomTerm(AtomTermExpansion); + AtomTermPosition = Yap_LookupAtom("term_position"); TermTermPosition = MkAtomTerm(AtomTermPosition); + AtomTerms = Yap_LookupAtom("terms"); TermTerms = MkAtomTerm(AtomTerms); + AtomText = Yap_LookupAtom("text"); TermText = MkAtomTerm(AtomText); + AtomTextStream = Yap_LookupAtom("text_stream"); TermTextStream = MkAtomTerm(AtomTextStream); + AtomThread = Yap_LookupAtom("thread"); TermThread = MkAtomTerm(AtomThread); + AtomThreads = Yap_LookupAtom("threads"); TermThreads = MkAtomTerm(AtomThreads); + AtomThrow = Yap_LookupAtom("throw"); TermThrow = MkAtomTerm(AtomThrow); + AtomTimeOutSpec = Yap_LookupAtom("time_out_spec"); TermTimeOutSpec = MkAtomTerm(AtomTimeOutSpec); + AtomTimeoutError = Yap_LookupAtom("timeout_error"); TermTimeoutError = MkAtomTerm(AtomTimeoutError); + AtomTopLevelGoal = Yap_FullLookupAtom("$top_level_goal"); TermTopLevelGoal = MkAtomTerm(AtomTopLevelGoal); + AtomTopThreadGoal = Yap_FullLookupAtom("$top_thread_goal"); TermTopThreadGoal = MkAtomTerm(AtomTopThreadGoal); + AtomTraceMetaCall = Yap_FullLookupAtom("$trace_meta_call"); TermTraceMetaCall = MkAtomTerm(AtomTraceMetaCall); + AtomTrail = Yap_LookupAtom("trail"); + AtomTrue = Yap_LookupAtom("true"); TermTrue = MkAtomTerm(AtomTrue); + AtomTty = Yap_LookupAtom("tty"); TermTty = MkAtomTerm(AtomTty); + AtomTtys = Yap_LookupAtom("ttys"); TermTtys = MkAtomTerm(AtomTtys); + AtomTuple = Yap_LookupAtom("tuple"); TermTuple = MkAtomTerm(AtomTuple); + AtomTxt = Yap_LookupAtom("txt"); TermTxt = MkAtomTerm(AtomTxt); + AtomTypeError = Yap_LookupAtom("type_error"); TermTypeError = MkAtomTerm(AtomTypeError); + AtomUndefined = Yap_LookupAtom("undefined"); TermUndefined = MkAtomTerm(AtomUndefined); + AtomUndefinedQuery = Yap_LookupAtom("undefined_query"); TermUndefinedQuery = MkAtomTerm(AtomUndefinedQuery); + AtomUndefp = Yap_FullLookupAtom("$undefp"); TermUndefp = MkAtomTerm(AtomUndefp); + AtomUndefp0 = Yap_FullLookupAtom("$undefp0"); TermUndefp0 = MkAtomTerm(AtomUndefp0); + AtomUnderflow = Yap_LookupAtom("underflow"); TermUnderflow = MkAtomTerm(AtomUnderflow); + AtomUnificationStack = Yap_LookupAtom("unification_stack"); TermUnificationStack = MkAtomTerm(AtomUnificationStack); + AtomUnique = Yap_LookupAtom("unique"); TermUnique = MkAtomTerm(AtomUnique); + AtomUnsignedByte = Yap_LookupAtom("unsigned_byte"); TermUnsignedByte = MkAtomTerm(AtomUnsignedByte); + AtomUnsignedChar = Yap_LookupAtom("unsigned_char"); TermUnsignedChar = MkAtomTerm(AtomUnsignedChar); + AtomUser = Yap_LookupAtom("user"); TermUser = MkAtomTerm(AtomUser); + AtomUserErr = Yap_LookupAtom("user_error"); TermUserErr = MkAtomTerm(AtomUserErr); + AtomUserIn = Yap_LookupAtom("user_input"); TermUserIn = MkAtomTerm(AtomUserIn); + AtomUserOut = Yap_LookupAtom("user_output"); TermUserOut = MkAtomTerm(AtomUserOut); + AtomUTF8 = Yap_LookupAtom("utf8"); TermUTF8 = MkAtomTerm(AtomUTF8); + AtomDollarVar = Yap_LookupAtom("$VAR"); TermDollarVar = MkAtomTerm(AtomDollarVar); + AtomVBar = Yap_LookupAtom("|"); TermVBar = MkAtomTerm(AtomVBar); + AtomVarBranches = Yap_LookupAtom("var_branches"); TermVarBranches = MkAtomTerm(AtomVarBranches); + AtomVariableNames = Yap_LookupAtom("variable_names"); TermVariableNames = MkAtomTerm(AtomVariableNames); + AtomHiddenVar = Yap_FullLookupAtom("$V"); TermHiddenVar = MkAtomTerm(AtomHiddenVar); + AtomVariable = Yap_LookupAtom("variable"); TermVariable = MkAtomTerm(AtomVariable); + AtomVerbose = Yap_LookupAtom("verbose"); TermVerbose = MkAtomTerm(AtomVerbose); + AtomVerboseFileSearch = Yap_LookupAtom("verbose_file_search"); TermVerboseFileSearch = MkAtomTerm(AtomVerboseFileSearch); + AtomVersionNumber = Yap_FullLookupAtom("$version_name"); TermVersionNumber = MkAtomTerm(AtomVersionNumber); + AtomVeryVerbose = Yap_LookupAtom("very_verbose"); TermVeryVerbose = MkAtomTerm(AtomVeryVerbose); + AtomWakeUpGoal = Yap_FullLookupAtom("$wake_up_goal"); TermWakeUpGoal = MkAtomTerm(AtomWakeUpGoal); + AtomWarning = Yap_LookupAtom("warning"); TermWarning = MkAtomTerm(AtomWarning); + AtomWhen = Yap_FullLookupAtom("$when"); TermWhen = MkAtomTerm(AtomWhen); + AtomWrite = Yap_LookupAtom("write"); TermWrite = MkAtomTerm(AtomWrite); + AtomWriteTerm = Yap_LookupAtom("write_term"); TermWriteTerm = MkAtomTerm(AtomWriteTerm); + AtomXml = Yap_LookupAtom("xml"); TermXml = MkAtomTerm(AtomXml); + AtomYapHacks = Yap_LookupAtom("yap_hacks"); TermYapHacks = MkAtomTerm(AtomYapHacks); + AtomZeroDivisor = Yap_LookupAtom("zero_divisor"); TermZeroDivisor = MkAtomTerm(AtomZeroDivisor); + FunctorAfInet = Yap_MkFunctor(AtomAfInet,2); + FunctorAfLocal = Yap_MkFunctor(AtomAfLocal,1); + FunctorAfUnix = Yap_MkFunctor(AtomAfUnix,1); + FunctorAltNot = Yap_MkFunctor(AtomAltNot,1); + FunctorArg = Yap_MkFunctor(AtomArg,3); + FunctorArrayEntry = Yap_MkFunctor(AtomArrayAccess,3); + FunctorArrow = Yap_MkFunctor(AtomArrow,2); + FunctorDoubleArrow = Yap_MkFunctor(AtomDoubleArrow,2); + FunctorAs = Yap_MkFunctor(AtomAs,2); + FunctorAssert1 = Yap_MkFunctor(AtomAssert,1); + FunctorAssert = Yap_MkFunctor(AtomAssert,2); + FunctorAt = Yap_MkFunctor(AtomAt,2); + FunctorAtSymbol = Yap_MkFunctor(AtomAtSymbol,2); + FunctorAtFoundOne = Yap_MkFunctor(AtomFoundVar,2); + FunctorAtom = Yap_MkFunctor(AtomAtom,1); + FunctorAtt1 = Yap_MkFunctor(AtomAtt1,3); + FunctorAttGoal = Yap_MkFunctor(AtomAttDo,2); + FunctorBraces = Yap_MkFunctor(AtomBraces,1); + FunctorCall = Yap_MkFunctor(AtomCall,1); + FunctorCatch = Yap_MkFunctor(AtomCatch,3); + FunctorChangeModule = Yap_MkFunctor(AtomChangeModule,1); + FunctorChars = Yap_MkFunctor(AtomChars,2); + FunctorChars1 = Yap_MkFunctor(AtomChars,1); + FunctorCleanCall = Yap_MkFunctor(AtomCleanCall,2); + FunctorClist = Yap_MkFunctor(AtomWhen,4); + FunctorCodes = Yap_MkFunctor(AtomCodes,2); + FunctorCodes1 = Yap_MkFunctor(AtomCodes,1); + FunctorColon = Yap_MkFunctor(AtomColon,2); + FunctorComma = Yap_MkFunctor(AtomComma,2); + FunctorCommentHook = Yap_MkFunctor(AtomCommentHook,3); + FunctorContext2 = Yap_MkFunctor(AtomContext,2); + FunctorConsistencyError = Yap_MkFunctor(AtomConsistencyError,1); + FunctorCreep = Yap_MkFunctor(AtomCreep,1); + FunctorCsult = Yap_MkFunctor(AtomCsult,2); + FunctorCurrentModule = Yap_MkFunctor(AtomCurrentModule,1); + FunctorCutBy = Yap_MkFunctor(AtomCutBy,1); + FunctorDBREF = Yap_MkFunctor(AtomDBREF,1); + FunctorDiff = Yap_MkFunctor(AtomDiff,2); + FunctorDoLogUpdClause = Yap_MkFunctor(AtomDoLogUpdClause,6); + FunctorDoLogUpdClause0 = Yap_MkFunctor(AtomDoLogUpdClause0,6); + FunctorDoLogUpdClauseErase = Yap_MkFunctor(AtomDoLogUpdClauseErase,6); + FunctorDoStaticClause = Yap_MkFunctor(AtomDoStaticClause,5); + FunctorDollar = Yap_MkFunctor(AtomDollar,1); + FunctorDollarVar = Yap_MkFunctor(AtomDollarVar,1); + FunctorDomainError = Yap_MkFunctor(AtomDomainError,2); + FunctorDot = Yap_MkFunctor(AtomDot,2); + FunctorDot10 = Yap_MkFunctor(AtomDot,10); + FunctorDot11 = Yap_MkFunctor(AtomDot,11); + FunctorDot12 = Yap_MkFunctor(AtomDot,12); + FunctorDot2 = Yap_MkFunctor(AtomDot,2); + FunctorDot3 = Yap_MkFunctor(AtomDot,3); + FunctorDot4 = Yap_MkFunctor(AtomDot,4); + FunctorDot5 = Yap_MkFunctor(AtomDot,5); + FunctorDot6 = Yap_MkFunctor(AtomDot,6); + FunctorDot7 = Yap_MkFunctor(AtomDot,7); + FunctorDot8 = Yap_MkFunctor(AtomDot,8); + FunctorDot9 = Yap_MkFunctor(AtomDot,9); + FunctorDoubleArrow = Yap_MkFunctor(AtomDoubleArrow,2); + FunctorDoubleSlash = Yap_MkFunctor(AtomDoubleSlash,2); + FunctorEmptySquareBrackets = Yap_MkFunctor(AtomEmptySquareBrackets,2); + FunctorEncoding = Yap_MkFunctor(AtomEncoding,1); + FunctorEq = Yap_MkFunctor(AtomEq,2); + FunctorError = Yap_MkFunctor(AtomError,2); + FunctorEvaluationError = Yap_MkFunctor(AtomEvaluationError,1); + FunctorException = Yap_MkFunctor(AtomException,1); + FunctorExecute2InMod = Yap_MkFunctor(AtomExecuteWoMod,2); + FunctorExecuteInMod = Yap_MkFunctor(AtomExecuteInMod,2); + FunctorExecuteWithin = Yap_MkFunctor(AtomExecuteWithin,1); + FunctorExistenceError = Yap_MkFunctor(AtomExistenceError,2); + FunctorExoClause = Yap_MkFunctor(AtomExoClause,2); + FunctorExternalException = Yap_MkFunctor(AtomExternalException,1); + FunctorFunctor = Yap_MkFunctor(AtomFunctor,3); + FunctorGAtom = Yap_MkFunctor(AtomAtom,1); + FunctorGAtomic = Yap_MkFunctor(AtomAtomic,1); + FunctorGCompound = Yap_MkFunctor(AtomCompound,1); + FunctorGFloat = Yap_MkFunctor(AtomFloat,1); + FunctorGFormatAt = Yap_MkFunctor(AtomFormatAt,2); + FunctorGInteger = Yap_MkFunctor(AtomInteger,1); + FunctorGNumber = Yap_MkFunctor(AtomNumber,1); + FunctorGPrimitive = Yap_MkFunctor(AtomPrimitive,1); + FunctorGVar = Yap_MkFunctor(AtomGVar,1); + FunctorGeneratePredInfo = Yap_MkFunctor(AtomGeneratePredInfo,4); + FunctorGoalExpansion2 = Yap_MkFunctor(AtomGoalExpansion,2); + FunctorGoalExpansion = Yap_MkFunctor(AtomGoalExpansion,3); + FunctorHandleThrow = Yap_MkFunctor(AtomHandleThrow,3); + FunctorHat = Yap_MkFunctor(AtomHat,2); + FunctorDoubleHat = Yap_MkFunctor(AtomDoubleHat,1); + FunctorI = Yap_MkFunctor(AtomI,2); + FunctorId = Yap_MkFunctor(AtomId,1); + FunctorInfo1 = Yap_MkFunctor(AtomInfo,1); + FunctorInfo2 = Yap_MkFunctor(AtomInfo,2); + FunctorInfo3 = Yap_MkFunctor(AtomInfo,3); + FunctorInfo4 = Yap_MkFunctor(AtomInfo,4); + FunctorIs = Yap_MkFunctor(AtomIs,2); + FunctorJ = Yap_MkFunctor(AtomJ,2); + FunctorLastExecuteWithin = Yap_MkFunctor(AtomLastExecuteWithin,1); + FunctorList = Yap_MkFunctor(AtomDot,2); + FunctorLOOP = Yap_MkFunctor(AtomLOOP,1); + FunctorMegaClause = Yap_MkFunctor(AtomMegaClause,2); + FunctorMetaCall = Yap_MkFunctor(AtomMetaCall,4); + FunctorMinus = Yap_MkFunctor(AtomMinus,2); + FunctorModule = Yap_MkFunctor(AtomColon,2); + FunctorMultiFileClause = Yap_MkFunctor(AtomMfClause,5); + FunctorMutable = Yap_MkFunctor(AtomMutableVariable,(sizeof(timed_var)/sizeof(CELL))); + FunctorMutex = Yap_MkFunctor(AtomMutex,2); + FunctorNotImplemented = Yap_MkFunctor(AtomNotImplemented,2); + FunctorNBQueue = Yap_MkFunctor(AtomQueue,4); + FunctorNot = Yap_MkFunctor(AtomNot,1); + FunctorObj = Yap_MkFunctor(AtomObj,1); + FunctorOr = Yap_MkFunctor(AtomSemic,2); + FunctorOutput = Yap_MkFunctor(AtomOutput,1); + FunctorPermissionError = Yap_MkFunctor(AtomPermissionError,3); + FunctorPlus = Yap_MkFunctor(AtomPlus,2); + FunctorPopen = Yap_MkFunctor(AtomPopen,1); + FunctorPortray = Yap_MkFunctor(AtomPortray,1); + FunctorPrintMessage = Yap_MkFunctor(AtomPrintMessage,2); + FunctorProcedure = Yap_MkFunctor(AtomProcedure,5); + FunctorPriority = Yap_MkFunctor(AtomPriority,1); + FunctorPrologConstraint = Yap_MkFunctor(AtomProlog,2); + FunctorProtectStack = Yap_MkFunctor(AtomProtectStack,4); + FunctorQuery = Yap_MkFunctor(AtomQuery,1); + FunctorRecordedWithKey = Yap_MkFunctor(AtomRecordedWithKey,6); + FunctorRDiv = Yap_MkFunctor(AtomRDiv,2); + FunctorRedoFreeze = Yap_MkFunctor(AtomRedoFreeze,3); + FunctorRepresentationError = Yap_MkFunctor(AtomRepresentationError,1); + FunctorResourceError = Yap_MkFunctor(AtomResourceError,1); + FunctorRestoreRegs = Yap_MkFunctor(AtomRestoreRegs,2); + FunctorRestoreRegs1 = Yap_MkFunctor(AtomRestoreRegs,1); + FunctorSafe = Yap_MkFunctor(AtomSafe,1); + FunctorSafeCallCleanup = Yap_MkFunctor(AtomSafeCallCleanup,4); + FunctorSame = Yap_MkFunctor(AtomSame,2); + FunctorSlash = Yap_MkFunctor(AtomSlash,2); + FunctorStaticClause = Yap_MkFunctor(AtomStaticClause,2); + FunctorStream = Yap_MkFunctor(AtomStream,1); + FunctorStreamEOS = Yap_MkFunctor(AtomEndOfStream,1); + FunctorStreamPos = Yap_MkFunctor(AtomStreamPos,4); + FunctorString1 = Yap_MkFunctor(AtomString,1); + FunctorStyleCheck = Yap_MkFunctor(AtomStyleCheck,4); + FunctorSyntaxError = Yap_MkFunctor(AtomSyntaxError,4); + FunctorShortSyntaxError = Yap_MkFunctor(AtomSyntaxError,1); + FunctorTermExpansion = Yap_MkFunctor(AtomTermExpansion,2); + FunctorThreadRun = Yap_MkFunctor(AtomTopThreadGoal,2); + FunctorThrow = Yap_MkFunctor(AtomThrow,1); + FunctorTimeoutError = Yap_MkFunctor(AtomTimeoutError,2); + FunctorTraceMetaCall = Yap_MkFunctor(AtomTraceMetaCall,3); + FunctorTypeError = Yap_MkFunctor(AtomTypeError,2); + FunctorUMinus = Yap_MkFunctor(AtomMinus,1); + FunctorUndefinedQuery = Yap_MkFunctor(AtomUndefinedQuery,3); + FunctorUPlus = Yap_MkFunctor(AtomPlus,1); + FunctorVBar = Yap_MkFunctor(AtomVBar,2); + FunctorWriteTerm = Yap_MkFunctor(AtomWriteTerm,2); + FunctorHiddenVar = Yap_MkFunctor(AtomHiddenVar,1); diff --git a/H/generated/iglobals.h b/H/generated/iglobals.h index 49481f73f..35a602e42 100644 --- a/H/generated/iglobals.h +++ b/H/generated/iglobals.h @@ -141,4 +141,5 @@ static void InitGlobal(void) { GLOBAL_VFS = Yap_InitAssetManager(); + GLOBAL_cwd = NULL; } diff --git a/H/generated/ihstruct.h b/H/generated/ihstruct.h index 4909f58ab..7ce75d9fa 100644 --- a/H/generated/ihstruct.h +++ b/H/generated/ihstruct.h @@ -83,7 +83,6 @@ #ifdef EUROTRA TermDollarU = MkAtomTerm(AtomDollarU); #endif - TermAnswer = MkAtomTerm(AtomAnswer); USER_MODULE = MkAtomTerm(AtomUser); IDB_MODULE = MkAtomTerm(AtomIDB); @@ -111,7 +110,7 @@ HIDDEN_PREDICATES = NULL; - Yap_InitPlIO(); + Yap_InitPlIO(yapi); GLOBAL_Flags = 0; Yap_InitFlags(true); @@ -125,7 +124,7 @@ #endif CreepCode = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomCreep,1),PROLOG_MODULE)); - UndefCode = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomUndefp0,2),PROLOG_MODULE)); + UndefCode = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomUndefp,2),PROLOG_MODULE)); SpyCode = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomSpy,1),PROLOG_MODULE)); PredFail = RepPredProp(PredPropByAtom(AtomFail,PROLOG_MODULE)); PredTrue = RepPredProp(PredPropByAtom(AtomTrue,PROLOG_MODULE)); @@ -142,6 +141,7 @@ PredLogUpdClause = RepPredProp(PredPropByFunc(FunctorDoLogUpdClause,PROLOG_MODULE)); PredLogUpdClauseErase = RepPredProp(PredPropByFunc(FunctorDoLogUpdClauseErase,PROLOG_MODULE)); PredLogUpdClause0 = RepPredProp(PredPropByFunc(FunctorDoLogUpdClause,PROLOG_MODULE)); + PredCall = RepPredProp(PredPropByFunc(FunctorCall,PROLOG_MODULE)); PredMetaCall = RepPredProp(PredPropByFunc(FunctorMetaCall,PROLOG_MODULE)); PredProtectStack = RepPredProp(PredPropByFunc(FunctorProtectStack,PROLOG_MODULE)); PredRecordedWithKey = RepPredProp(PredPropByFunc(FunctorRecordedWithKey,PROLOG_MODULE)); @@ -152,6 +152,7 @@ PredTraceMetaCall = RepPredProp(PredPropByFunc(FunctorTraceMetaCall,PROLOG_MODULE)); PredCommentHook = RepPredProp(PredPropByFunc(FunctorCommentHook,PROLOG_MODULE)); PredProcedure = Yap_MkLogPred(RepPredProp(PredPropByFunc(FunctorProcedure,PROLOG_MODULE))); + PredUndefinedQuery = RepPredProp(PredPropByFunc(FunctorUndefinedQuery,PROLOG_MODULE)); #ifdef LOW_LEVEL_TRACER Yap_do_low_level_trace = FALSE; @@ -270,6 +271,8 @@ #endif + + OpList = NULL; ForeignCodeLoaded = NULL; diff --git a/H/generated/ilocals.h b/H/generated/ilocals.h index 7da9a5e1c..ba1edfa4f 100755 --- a/H/generated/ilocals.h +++ b/H/generated/ilocals.h @@ -1,272 +1,23 @@ - /* This file, ilocals.h, was generated automatically by "yap -L misc/buildlocalglobal" - please do not update, update H/LOCALS instead */ +#ifndef ILOCALS_H +#define ILOCALS_H +#undef LOCAL +#undef LOCAL_INIT +#undef LOCAL_INITF +#undef LOCAL_INIT_RESTORE +#undef LOCAL_ARRAY +#undef LOCAL_ARRAY_ARRAY -static void InitWorker(int wid) { +#define LOCAL(TYPE, NAME) +#define LOCAL_INIT(TYPE, NAME, INIT) REMOTE_##NAME(wid) = INIT +#define LOCAL_INITF(TYPE, NAME, INIT) INIT +#define LOCAL_INIT_RESTORE(TYPE, NAME, INIT, RESTORE) REMOTE_##NAME(wid) = INIT +#define LOCAL_ARRAY(TYPE, NAME, INIT) +#define LOCAL_ARRAY_ARRAY(TYPE, NAME, DIM1, DIM2) - REMOTE_c_input_stream(wid) = 0; - REMOTE_c_output_stream(wid) = 1; - REMOTE_c_error_stream(wid) = 2; - REMOTE_sockets_io(wid) = false; - REMOTE_within_print_message(wid) = false; +static void InitWorker(int wid){ +#include "locals.h" +} ; - - - - REMOTE_newline(wid) = true; - REMOTE_AtPrompt(wid) = AtomNil; - - REMOTE_encoding(wid) = Yap_DefaultEncoding(); - REMOTE_quasi_quotations(wid) = false; - REMOTE_default_priority(wid) = 1200; - REMOTE_eot_before_eof(wid) = false; - REMOTE_max_depth(wid) = 0; - REMOTE_max_list(wid) = 0; - REMOTE_max_write_args(wid) = 0; - - REMOTE_OldASP(wid) = NULL; - REMOTE_OldLCL0(wid) = NULL; - REMOTE_OldTR(wid) = NULL; - REMOTE_OldGlobalBase(wid) = NULL; - REMOTE_OldH(wid) = NULL; - REMOTE_OldH0(wid) = NULL; - REMOTE_OldTrailBase(wid) = NULL; - REMOTE_OldTrailTop(wid) = NULL; - REMOTE_OldHeapBase(wid) = NULL; - REMOTE_OldHeapTop(wid) = NULL; - REMOTE_ClDiff(wid) = 0L; - REMOTE_GDiff(wid) = 0L; - REMOTE_HDiff(wid) = 0L; - REMOTE_GDiff0(wid) = 0L; - REMOTE_GSplit(wid) = NULL; - REMOTE_LDiff(wid) = 0L; - REMOTE_TrDiff(wid) = 0L; - REMOTE_XDiff(wid) = 0L; - REMOTE_DelayDiff(wid) = 0L; - REMOTE_BaseDiff(wid) = 0L; - - REMOTE_ReductionsCounter(wid) = 0L; - REMOTE_PredEntriesCounter(wid) = 0L; - REMOTE_RetriesCounter(wid) = 0L; - REMOTE_ReductionsCounterOn(wid) = 0L; - REMOTE_PredEntriesCounterOn(wid) = 0L; - REMOTE_RetriesCounterOn(wid) = 0L; - - - REMOTE_ConsultSp(wid) = NULL; - - - - REMOTE_ConsultBase(wid) = NULL; - - REMOTE_ConsultLow(wid) = NULL; - REMOTE_VarNames(wid) = ((Term)0); - REMOTE_SourceFileName(wid) = NULL; - REMOTE_SourceFileLineno(wid) = 0; - - REMOTE_GlobalArena(wid) = 0L; - REMOTE_GlobalArenaOverflows(wid) = 0L; - REMOTE_ArenaOverflows(wid) = 0L; - REMOTE_DepthArenas(wid) = 0; - REMOTE_LastAssertedPred(wid) = NULL; - REMOTE_TmpPred(wid) = NULL; - REMOTE_ScannerStack(wid) = NULL; - REMOTE_ScannerExtraBlocks(wid) = NULL; - - - REMOTE_CBorder(wid) = 0; - - REMOTE_MaxActiveSignals(wid) = 64L; - - REMOTE_Signals(wid) = 0L; - - REMOTE_IPredArity(wid) = 0L; - REMOTE_ProfEnd(wid) = NULL; - REMOTE_DoingUndefp(wid) = FALSE; - REMOTE_StartCharCount(wid) = 0L; - REMOTE_StartLineCount(wid) = 0L; - REMOTE_StartLinePos(wid) = 0L; - InitScratchPad(wid); -#ifdef COROUTINING - REMOTE_WokenGoals(wid) = 0L; - REMOTE_AttsMutableList(wid) = 0L; #endif - - REMOTE_GcGeneration(wid) = 0L; - REMOTE_GcPhase(wid) = 0L; - REMOTE_GcCurrentPhase(wid) = 0L; - REMOTE_GcCalls(wid) = 0L; - REMOTE_TotGcTime(wid) = 0L; - REMOTE_TotGcRecovered(wid) = 0L; - REMOTE_LastGcTime(wid) = 0L; - REMOTE_LastSSTime(wid) = 0L; - REMOTE_OpenArray(wid) = NULL; - - REMOTE_total_marked(wid) = 0L; - REMOTE_total_oldies(wid) = 0L; - REMOTE_current_B(wid) = NULL; - REMOTE_prev_HB(wid) = NULL; - REMOTE_HGEN(wid) = NULL; - REMOTE_iptop(wid) = NULL; -#if defined(GC_NO_TAGS) - REMOTE_bp(wid) = NULL; -#endif - REMOTE_sTR(wid) = NULL; - REMOTE_sTR0(wid) = NULL; - REMOTE_new_TR(wid) = NULL; - REMOTE_cont_top0(wid) = NULL; - REMOTE_cont_top(wid) = NULL; - REMOTE_discard_trail_entries(wid) = 0; - - REMOTE_gc_ma_h_top(wid) = NULL; - REMOTE_gc_ma_h_list(wid) = NULL; - REMOTE_gc_timestamp(wid) = 0L; - REMOTE_db_vec(wid) = NULL; - REMOTE_db_vec0(wid) = NULL; - REMOTE_db_root(wid) = NULL; - REMOTE_db_nil(wid) = NULL; - - - - - REMOTE_extra_gc_cells_size(wid) = 256; - REMOTE_DynamicArrays(wid) = NULL; - REMOTE_StaticArrays(wid) = NULL; - REMOTE_GlobalVariables(wid) = NULL; - REMOTE_AllowRestart(wid) = FALSE; - - REMOTE_CMemFirstBlock(wid) = NULL; - REMOTE_CMemFirstBlockSz(wid) = 0L; - - REMOTE_nperm(wid) = 0; - REMOTE_jMP(wid) = 0; - - REMOTE_LabelFirstArray(wid) = NULL; - REMOTE_LabelFirstArraySz(wid) = 0L; - - -#ifdef THREADS - InitThreadHandle(wid); -#endif /* THREADS */ -#if defined(YAPOR) || defined(TABLING) - Yap_init_local_optyap_data(wid); - REMOTE_TabMode(wid) = 0L; -#endif /* YAPOR || TABLING */ - REMOTE_InterruptsDisabled(wid) = FALSE; - REMOTE_execution(wid) = NULL; -#if LOW_LEVEL_TRACER - REMOTE_total_choicepoints(wid) = 0; -#endif - REMOTE_consult_level(wid) = 0; - - - - - - - REMOTE_ActiveError(wid) = calloc(sizeof(yap_error_descriptor_t),1); - - - - - - - - - - - - - - - - REMOTE_TextBuffer(wid) = Yap_InitTextAllocator(); - - REMOTE_BreakLevel(wid) = 0; - REMOTE_PrologMode(wid) = BootMode; - REMOTE_CritLocks(wid) = 0; - - - - - -#ifdef ANALYST - - -#endif /* ANALYST */ - - - - - REMOTE_mathstring(wid) = NULL; - - REMOTE_heap_overflows(wid) = 0; - REMOTE_total_heap_overflow_time(wid) = 0; - REMOTE_stack_overflows(wid) = 0; - REMOTE_total_stack_overflow_time(wid) = 0; - REMOTE_delay_overflows(wid) = 0; - REMOTE_total_delay_overflow_time(wid) = 0; - REMOTE_trail_overflows(wid) = 0; - REMOTE_total_trail_overflow_time(wid) = 0; - REMOTE_atom_table_overflows(wid) = 0; - REMOTE_total_atom_table_overflow_time(wid) = 0; - -#ifdef LOAD_DYLD - REMOTE_dl_errno(wid) = 0; -#endif - -#ifdef LOW_LEVEL_TRACER - REMOTE_do_trace_primitives(wid) = TRUE; -#endif - - REMOTE_ExportAtomHashChain(wid) = NULL; - REMOTE_ExportAtomHashTableSize(wid) = 0; - REMOTE_ExportAtomHashTableNum(wid) = 0; - REMOTE_ExportFunctorHashChain(wid) = NULL; - REMOTE_ExportFunctorHashTableSize(wid) = 0; - REMOTE_ExportFunctorHashTableNum(wid) = 0; - REMOTE_ExportPredEntryHashChain(wid) = NULL; - REMOTE_ExportPredEntryHashTableSize(wid) = 0; - REMOTE_ExportPredEntryHashTableNum(wid) = 0; - REMOTE_ExportDBRefHashChain(wid) = NULL; - REMOTE_ExportDBRefHashTableSize(wid) = 0; - REMOTE_ExportDBRefHashTableNum(wid) = 0; - REMOTE_ImportAtomHashChain(wid) = NULL; - REMOTE_ImportAtomHashTableSize(wid) = 0; - REMOTE_ImportAtomHashTableNum(wid) = 0; - REMOTE_ImportFunctorHashChain(wid) = NULL; - REMOTE_ImportFunctorHashTableSize(wid) = 0; - REMOTE_ImportFunctorHashTableNum(wid) = 0; - REMOTE_ImportOPCODEHashChain(wid) = NULL; - REMOTE_ImportOPCODEHashTableSize(wid) = 0; - REMOTE_ImportPredEntryHashChain(wid) = NULL; - REMOTE_ImportPredEntryHashTableSize(wid) = 0; - REMOTE_ImportPredEntryHashTableNum(wid) = 0; - REMOTE_ImportDBRefHashChain(wid) = NULL; - REMOTE_ImportDBRefHashTableSize(wid) = 0; - REMOTE_ImportDBRefHashTableNum(wid) = 0; - REMOTE_ImportFAILCODE(wid) = NULL; - - - REMOTE_exo_it(wid) = NULL; - REMOTE_exo_base(wid) = NULL; - REMOTE_exo_arity(wid) = 0; - REMOTE_exo_arg(wid) = 0; - - - - - REMOTE_CurSlot(wid) = 0; - REMOTE_FrozenHandles(wid) = 0; - REMOTE_NSlots(wid) = 0; - REMOTE_SlotBase(wid) = InitHandles(wid); - - REMOTE_Mutexes(wid) = NULL; - REMOTE_SourceModule(wid) = 0; - REMOTE_Including(wid) = TermNil; - REMOTE_MAX_SIZE(wid) = 1024L; - - REMOTE_LastWTime(wid) = 0; - REMOTE_shared(wid) = NULL; -} diff --git a/H/generated/ratoms.h b/H/generated/ratoms.h index 1deb1e028..6f06ebf24 100644 --- a/H/generated/ratoms.h +++ b/H/generated/ratoms.h @@ -1,584 +1,602 @@ - - /* This file, ratoms.h, was generated automatically by "yap -L misc/buildatoms" - {lease do not update, update misc/ATOMS instead */ - - Atom3Dots = AtomAdjust(Atom3Dots); - AtomAbol = AtomAdjust(AtomAbol); TermAbol = MkAtomTerm(AtomAbol); - AtomAccess = AtomAdjust(AtomAccess); TermAccess = MkAtomTerm(AtomAccess); - AtomAfInet = AtomAdjust(AtomAfInet); TermAfInet = MkAtomTerm(AtomAfInet); - AtomAfLocal = AtomAdjust(AtomAfLocal); TermAfLocal = MkAtomTerm(AtomAfLocal); - AtomAfUnix = AtomAdjust(AtomAfUnix); TermAfUnix = MkAtomTerm(AtomAfUnix); - AtomAlarm = AtomAdjust(AtomAlarm); TermAlarm = MkAtomTerm(AtomAlarm); - AtomAlias = AtomAdjust(AtomAlias); TermAlias = MkAtomTerm(AtomAlias); - AtomAll = AtomAdjust(AtomAll); TermAll = MkAtomTerm(AtomAll); - AtomAltNot = AtomAdjust(AtomAltNot); TermAltNot = MkAtomTerm(AtomAltNot); - AtomAnswer = AtomAdjust(AtomAnswer); TermAnswer = MkAtomTerm(AtomAnswer); - AtomAny = AtomAdjust(AtomAny); TermAny = MkAtomTerm(AtomAny); - AtomAppend = AtomAdjust(AtomAppend); TermAppend = MkAtomTerm(AtomAppend); - AtomArg = AtomAdjust(AtomArg); TermArg = MkAtomTerm(AtomArg); - AtomArray = AtomAdjust(AtomArray); TermArray = MkAtomTerm(AtomArray); - AtomArrayAccess = AtomAdjust(AtomArrayAccess); TermArrayAccess = MkAtomTerm(AtomArrayAccess); - AtomArrayOverflow = AtomAdjust(AtomArrayOverflow); TermArrayOverflow = MkAtomTerm(AtomArrayOverflow); - AtomArrayType = AtomAdjust(AtomArrayType); TermArrayType = MkAtomTerm(AtomArrayType); - AtomArrow = AtomAdjust(AtomArrow); TermArrow = MkAtomTerm(AtomArrow); - AtomAttributedModule = AtomAdjust(AtomAttributedModule); TermAttributedModule = MkAtomTerm(AtomAttributedModule); - AtomDoubleArrow = AtomAdjust(AtomDoubleArrow); TermDoubleArrow = MkAtomTerm(AtomDoubleArrow); - AtomAssert = AtomAdjust(AtomAssert); TermAssert = MkAtomTerm(AtomAssert); - AtomBeginBracket = AtomAdjust(AtomBeginBracket); TermBeginBracket = MkAtomTerm(AtomBeginBracket); - AtomEndBracket = AtomAdjust(AtomEndBracket); TermEndBracket = MkAtomTerm(AtomEndBracket); - AtomBeginSquareBracket = AtomAdjust(AtomBeginSquareBracket); TermBeginSquareBracket = MkAtomTerm(AtomBeginSquareBracket); - AtomEndSquareBracket = AtomAdjust(AtomEndSquareBracket); TermEndSquareBracket = MkAtomTerm(AtomEndSquareBracket); - AtomBeginCurlyBracket = AtomAdjust(AtomBeginCurlyBracket); TermBeginCurlyBracket = MkAtomTerm(AtomBeginCurlyBracket); - AtomEndCurlyBracket = AtomAdjust(AtomEndCurlyBracket); TermEndCurlyBracket = MkAtomTerm(AtomEndCurlyBracket); - AtomEmptyBrackets = AtomAdjust(AtomEmptyBrackets); TermEmptyBrackets = MkAtomTerm(AtomEmptyBrackets); - AtomEmptySquareBrackets = AtomAdjust(AtomEmptySquareBrackets); TermEmptySquareBrackets = MkAtomTerm(AtomEmptySquareBrackets); - AtomAsserta = AtomAdjust(AtomAsserta); TermAsserta = MkAtomTerm(AtomAsserta); - AtomAssertaStatic = AtomAdjust(AtomAssertaStatic); TermAssertaStatic = MkAtomTerm(AtomAssertaStatic); - AtomAssertz = AtomAdjust(AtomAssertz); TermAssertz = MkAtomTerm(AtomAssertz); - AtomAssertzStatic = AtomAdjust(AtomAssertzStatic); TermAssertzStatic = MkAtomTerm(AtomAssertzStatic); - AtomAt = AtomAdjust(AtomAt); TermAt = MkAtomTerm(AtomAt); - AtomAtom = AtomAdjust(AtomAtom); TermAtom = MkAtomTerm(AtomAtom); - AtomAtomic = AtomAdjust(AtomAtomic); TermAtomic = MkAtomTerm(AtomAtomic); - AtomAtt = AtomAdjust(AtomAtt); TermAtt = MkAtomTerm(AtomAtt); - AtomAtt1 = AtomAdjust(AtomAtt1); TermAtt1 = MkAtomTerm(AtomAtt1); - AtomAttDo = AtomAdjust(AtomAttDo); TermAttDo = MkAtomTerm(AtomAttDo); - AtomAttributes = AtomAdjust(AtomAttributes); TermAttributes = MkAtomTerm(AtomAttributes); - AtomB = AtomAdjust(AtomB); TermB = MkAtomTerm(AtomB); - AtomBatched = AtomAdjust(AtomBatched); TermBatched = MkAtomTerm(AtomBatched); - AtomBetween = AtomAdjust(AtomBetween); TermBetween = MkAtomTerm(AtomBetween); - AtomBinary = AtomAdjust(AtomBinary); TermBinary = MkAtomTerm(AtomBinary); - AtomBigNum = AtomAdjust(AtomBigNum); TermBigNum = MkAtomTerm(AtomBigNum); - AtomBinaryStream = AtomAdjust(AtomBinaryStream); TermBinaryStream = MkAtomTerm(AtomBinaryStream); - AtomBoolean = AtomAdjust(AtomBoolean); TermBoolean = MkAtomTerm(AtomBoolean); - AtomBraces = AtomAdjust(AtomBraces); TermBraces = MkAtomTerm(AtomBraces); - AtomBreak = AtomAdjust(AtomBreak); TermBreak = MkAtomTerm(AtomBreak); - AtomByte = AtomAdjust(AtomByte); TermByte = MkAtomTerm(AtomByte); - AtomCArith = AtomAdjust(AtomCArith); TermCArith = MkAtomTerm(AtomCArith); - AtomCall = AtomAdjust(AtomCall); TermCall = MkAtomTerm(AtomCall); - AtomCallAndRetryCounter = AtomAdjust(AtomCallAndRetryCounter); TermCallAndRetryCounter = MkAtomTerm(AtomCallAndRetryCounter); - AtomCallCounter = AtomAdjust(AtomCallCounter); TermCallCounter = MkAtomTerm(AtomCallCounter); - AtomCallable = AtomAdjust(AtomCallable); TermCallable = MkAtomTerm(AtomCallable); - AtomCatch = AtomAdjust(AtomCatch); TermCatch = MkAtomTerm(AtomCatch); - AtomChangeModule = AtomAdjust(AtomChangeModule); TermChangeModule = MkAtomTerm(AtomChangeModule); - AtomChar = AtomAdjust(AtomChar); TermChar = MkAtomTerm(AtomChar); - AtomCharsio = AtomAdjust(AtomCharsio); TermCharsio = MkAtomTerm(AtomCharsio); - AtomCharacter = AtomAdjust(AtomCharacter); TermCharacter = MkAtomTerm(AtomCharacter); - AtomCharacterCode = AtomAdjust(AtomCharacterCode); TermCharacterCode = MkAtomTerm(AtomCharacterCode); - AtomChars = AtomAdjust(AtomChars); TermChars = MkAtomTerm(AtomChars); - AtomCharset = AtomAdjust(AtomCharset); TermCharset = MkAtomTerm(AtomCharset); - AtomChType = AtomAdjust(AtomChType); TermChType = MkAtomTerm(AtomChType); - AtomCleanCall = AtomAdjust(AtomCleanCall); TermCleanCall = MkAtomTerm(AtomCleanCall); - AtomClose = AtomAdjust(AtomClose); TermClose = MkAtomTerm(AtomClose); - AtomColon = AtomAdjust(AtomColon); TermColon = MkAtomTerm(AtomColon); - AtomCodeSpace = AtomAdjust(AtomCodeSpace); TermCodeSpace = MkAtomTerm(AtomCodeSpace); - AtomCodes = AtomAdjust(AtomCodes); TermCodes = MkAtomTerm(AtomCodes); - AtomCoInductive = AtomAdjust(AtomCoInductive); TermCoInductive = MkAtomTerm(AtomCoInductive); - AtomComma = AtomAdjust(AtomComma); TermComma = MkAtomTerm(AtomComma); - AtomCommentHook = AtomAdjust(AtomCommentHook); TermCommentHook = MkAtomTerm(AtomCommentHook); - AtomCompact = AtomAdjust(AtomCompact); TermCompact = MkAtomTerm(AtomCompact); - AtomCompound = AtomAdjust(AtomCompound); TermCompound = MkAtomTerm(AtomCompound); - AtomConsistencyError = AtomAdjust(AtomConsistencyError); TermConsistencyError = MkAtomTerm(AtomConsistencyError); - AtomConsult = AtomAdjust(AtomConsult); TermConsult = MkAtomTerm(AtomConsult); - AtomConsultOnBoot = AtomAdjust(AtomConsultOnBoot); TermConsultOnBoot = MkAtomTerm(AtomConsultOnBoot); - AtomContext = AtomAdjust(AtomContext); TermContext = MkAtomTerm(AtomContext); - AtomCputime = AtomAdjust(AtomCputime); TermCputime = MkAtomTerm(AtomCputime); - AtomCreate = AtomAdjust(AtomCreate); TermCreate = MkAtomTerm(AtomCreate); - AtomCreep = AtomAdjust(AtomCreep); TermCreep = MkAtomTerm(AtomCreep); - AtomCryptAtoms = AtomAdjust(AtomCryptAtoms); TermCryptAtoms = MkAtomTerm(AtomCryptAtoms); - AtomCurly = AtomAdjust(AtomCurly); TermCurly = MkAtomTerm(AtomCurly); - AtomCsult = AtomAdjust(AtomCsult); TermCsult = MkAtomTerm(AtomCsult); - AtomCurrentModule = AtomAdjust(AtomCurrentModule); TermCurrentModule = MkAtomTerm(AtomCurrentModule); - AtomCut = AtomAdjust(AtomCut); TermCut = MkAtomTerm(AtomCut); - AtomCutBy = AtomAdjust(AtomCutBy); TermCutBy = MkAtomTerm(AtomCutBy); - AtomDAbort = AtomAdjust(AtomDAbort); TermDAbort = MkAtomTerm(AtomDAbort); - AtomDBLoad = AtomAdjust(AtomDBLoad); TermDBLoad = MkAtomTerm(AtomDBLoad); - AtomDBREF = AtomAdjust(AtomDBREF); TermDBREF = MkAtomTerm(AtomDBREF); - AtomDBReference = AtomAdjust(AtomDBReference); TermDBReference = MkAtomTerm(AtomDBReference); - AtomDBTerm = AtomAdjust(AtomDBTerm); TermDBTerm = MkAtomTerm(AtomDBTerm); - AtomDBref = AtomAdjust(AtomDBref); TermDBref = MkAtomTerm(AtomDBref); - AtomDInteger = AtomAdjust(AtomDInteger); TermDInteger = MkAtomTerm(AtomDInteger); - AtomDebugMeta = AtomAdjust(AtomDebugMeta); TermDebugMeta = MkAtomTerm(AtomDebugMeta); - AtomDebuggerInput = AtomAdjust(AtomDebuggerInput); TermDebuggerInput = MkAtomTerm(AtomDebuggerInput); - AtomDec10 = AtomAdjust(AtomDec10); TermDec10 = MkAtomTerm(AtomDec10); - AtomDefault = AtomAdjust(AtomDefault); TermDefault = MkAtomTerm(AtomDefault); - AtomDevNull = AtomAdjust(AtomDevNull); TermDevNull = MkAtomTerm(AtomDevNull); - AtomDiff = AtomAdjust(AtomDiff); TermDiff = MkAtomTerm(AtomDiff); - AtomDirectory = AtomAdjust(AtomDirectory); TermDirectory = MkAtomTerm(AtomDirectory); - AtomDiscontiguous = AtomAdjust(AtomDiscontiguous); TermDiscontiguous = MkAtomTerm(AtomDiscontiguous); - AtomDiscontiguousWarnings = AtomAdjust(AtomDiscontiguousWarnings); TermDiscontiguousWarnings = MkAtomTerm(AtomDiscontiguousWarnings); - AtomDollar = AtomAdjust(AtomDollar); TermDollar = MkAtomTerm(AtomDollar); - AtomDoLogUpdClause = AtomAdjust(AtomDoLogUpdClause); TermDoLogUpdClause = MkAtomTerm(AtomDoLogUpdClause); - AtomDoLogUpdClause0 = AtomAdjust(AtomDoLogUpdClause0); TermDoLogUpdClause0 = MkAtomTerm(AtomDoLogUpdClause0); - AtomDoLogUpdClauseErase = AtomAdjust(AtomDoLogUpdClauseErase); TermDoLogUpdClauseErase = MkAtomTerm(AtomDoLogUpdClauseErase); - AtomDollarU = AtomAdjust(AtomDollarU); TermDollarU = MkAtomTerm(AtomDollarU); - AtomDollarUndef = AtomAdjust(AtomDollarUndef); TermDollarUndef = MkAtomTerm(AtomDollarUndef); - AtomDomainError = AtomAdjust(AtomDomainError); TermDomainError = MkAtomTerm(AtomDomainError); - AtomDoStaticClause = AtomAdjust(AtomDoStaticClause); TermDoStaticClause = MkAtomTerm(AtomDoStaticClause); - AtomDots = AtomAdjust(AtomDots); TermDots = MkAtomTerm(AtomDots); - AtomDOUBLE = AtomAdjust(AtomDOUBLE); TermDOUBLE = MkAtomTerm(AtomDOUBLE); - AtomDoubleSlash = AtomAdjust(AtomDoubleSlash); TermDoubleSlash = MkAtomTerm(AtomDoubleSlash); - AtomE = AtomAdjust(AtomE); TermE = MkAtomTerm(AtomE); - AtomEOFBeforeEOT = AtomAdjust(AtomEOFBeforeEOT); TermEOFBeforeEOT = MkAtomTerm(AtomEOFBeforeEOT); - AtomEQ = AtomAdjust(AtomEQ); TermEQ = MkAtomTerm(AtomEQ); - AtomEmptyAtom = AtomAdjust(AtomEmptyAtom); TermEmptyAtom = MkAtomTerm(AtomEmptyAtom); - AtomEncoding = AtomAdjust(AtomEncoding); TermEncoding = MkAtomTerm(AtomEncoding); - AtomEndOfStream = AtomAdjust(AtomEndOfStream); TermEndOfStream = MkAtomTerm(AtomEndOfStream); - AtomEof = AtomAdjust(AtomEof); TermEof = MkAtomTerm(AtomEof); - AtomEOfCode = AtomAdjust(AtomEOfCode); TermEOfCode = MkAtomTerm(AtomEOfCode); - AtomEq = AtomAdjust(AtomEq); TermEq = MkAtomTerm(AtomEq); - AtomError = AtomAdjust(AtomError); TermError = MkAtomTerm(AtomError); - AtomException = AtomAdjust(AtomException); TermException = MkAtomTerm(AtomException); - AtomExtensions = AtomAdjust(AtomExtensions); TermExtensions = MkAtomTerm(AtomExtensions); - AtomEvaluable = AtomAdjust(AtomEvaluable); TermEvaluable = MkAtomTerm(AtomEvaluable); - AtomEvaluationError = AtomAdjust(AtomEvaluationError); TermEvaluationError = MkAtomTerm(AtomEvaluationError); - AtomExecutable = AtomAdjust(AtomExecutable); TermExecutable = MkAtomTerm(AtomExecutable); - AtomExecute = AtomAdjust(AtomExecute); TermExecute = MkAtomTerm(AtomExecute); - AtomExecAnswers = AtomAdjust(AtomExecAnswers); TermExecAnswers = MkAtomTerm(AtomExecAnswers); - AtomExecuteInMod = AtomAdjust(AtomExecuteInMod); TermExecuteInMod = MkAtomTerm(AtomExecuteInMod); - AtomExecuteWithin = AtomAdjust(AtomExecuteWithin); TermExecuteWithin = MkAtomTerm(AtomExecuteWithin); - AtomExecuteWoMod = AtomAdjust(AtomExecuteWoMod); TermExecuteWoMod = MkAtomTerm(AtomExecuteWoMod); - AtomExist = AtomAdjust(AtomExist); TermExist = MkAtomTerm(AtomExist); - AtomExists = AtomAdjust(AtomExists); TermExists = MkAtomTerm(AtomExists); - AtomExit = AtomAdjust(AtomExit); TermExit = MkAtomTerm(AtomExit); - AtomExistenceError = AtomAdjust(AtomExistenceError); TermExistenceError = MkAtomTerm(AtomExistenceError); - AtomExoClause = AtomAdjust(AtomExoClause); TermExoClause = MkAtomTerm(AtomExoClause); - AtomExpectedNumber = AtomAdjust(AtomExpectedNumber); TermExpectedNumber = MkAtomTerm(AtomExpectedNumber); - AtomExpand = AtomAdjust(AtomExpand); TermExpand = MkAtomTerm(AtomExpand); - AtomExtendFileSearchPath = AtomAdjust(AtomExtendFileSearchPath); TermExtendFileSearchPath = MkAtomTerm(AtomExtendFileSearchPath); - AtomExtendsions = AtomAdjust(AtomExtendsions); TermExtendsions = MkAtomTerm(AtomExtendsions); - AtomFB = AtomAdjust(AtomFB); TermFB = MkAtomTerm(AtomFB); - AtomFail = AtomAdjust(AtomFail); TermFail = MkAtomTerm(AtomFail); - AtomFalse = AtomAdjust(AtomFalse); TermFalse = MkAtomTerm(AtomFalse); - AtomFast = AtomAdjust(AtomFast); TermFast = MkAtomTerm(AtomFast); - AtomFastFail = AtomAdjust(AtomFastFail); TermFastFail = MkAtomTerm(AtomFastFail); - AtomFileErrors = AtomAdjust(AtomFileErrors); TermFileErrors = MkAtomTerm(AtomFileErrors); - AtomFileerrors = AtomAdjust(AtomFileerrors); TermFileerrors = MkAtomTerm(AtomFileerrors); - AtomFileType = AtomAdjust(AtomFileType); TermFileType = MkAtomTerm(AtomFileType); - AtomFirst = AtomAdjust(AtomFirst); TermFirst = MkAtomTerm(AtomFirst); - AtomFloat = AtomAdjust(AtomFloat); TermFloat = MkAtomTerm(AtomFloat); - AtomFloatFormat = AtomAdjust(AtomFloatFormat); TermFloatFormat = MkAtomTerm(AtomFloatFormat); - AtomFloatOverflow = AtomAdjust(AtomFloatOverflow); TermFloatOverflow = MkAtomTerm(AtomFloatOverflow); - AtomFloatUnderflow = AtomAdjust(AtomFloatUnderflow); TermFloatUnderflow = MkAtomTerm(AtomFloatUnderflow); - AtomFormat = AtomAdjust(AtomFormat); TermFormat = MkAtomTerm(AtomFormat); - AtomFormatAt = AtomAdjust(AtomFormatAt); TermFormatAt = MkAtomTerm(AtomFormatAt); - AtomFull = AtomAdjust(AtomFull); TermFull = MkAtomTerm(AtomFull); - AtomFunctor = AtomAdjust(AtomFunctor); TermFunctor = MkAtomTerm(AtomFunctor); - AtomGT = AtomAdjust(AtomGT); TermGT = MkAtomTerm(AtomGT); - AtomGVar = AtomAdjust(AtomGVar); TermGVar = MkAtomTerm(AtomGVar); - AtomGc = AtomAdjust(AtomGc); TermGc = MkAtomTerm(AtomGc); - AtomGcMargin = AtomAdjust(AtomGcMargin); TermGcMargin = MkAtomTerm(AtomGcMargin); - AtomGcTrace = AtomAdjust(AtomGcTrace); TermGcTrace = MkAtomTerm(AtomGcTrace); - AtomGcVerbose = AtomAdjust(AtomGcVerbose); TermGcVerbose = MkAtomTerm(AtomGcVerbose); - AtomGcVeryVerbose = AtomAdjust(AtomGcVeryVerbose); TermGcVeryVerbose = MkAtomTerm(AtomGcVeryVerbose); - AtomGeneratePredInfo = AtomAdjust(AtomGeneratePredInfo); TermGeneratePredInfo = MkAtomTerm(AtomGeneratePredInfo); - AtomGetwork = AtomAdjust(AtomGetwork); TermGetwork = MkAtomTerm(AtomGetwork); - AtomGetworkSeq = AtomAdjust(AtomGetworkSeq); TermGetworkSeq = MkAtomTerm(AtomGetworkSeq); - AtomGlob = AtomAdjust(AtomGlob); TermGlob = MkAtomTerm(AtomGlob); - AtomGlobal = AtomAdjust(AtomGlobal); TermGlobal = MkAtomTerm(AtomGlobal); - AtomGlobalSp = AtomAdjust(AtomGlobalSp); TermGlobalSp = MkAtomTerm(AtomGlobalSp); - AtomGlobalTrie = AtomAdjust(AtomGlobalTrie); TermGlobalTrie = MkAtomTerm(AtomGlobalTrie); - AtomGoalExpansion = AtomAdjust(AtomGoalExpansion); TermGoalExpansion = MkAtomTerm(AtomGoalExpansion); - AtomHat = AtomAdjust(AtomHat); TermHat = MkAtomTerm(AtomHat); - AtomHERE = AtomAdjust(AtomHERE); TermHERE = MkAtomTerm(AtomHERE); - AtomHandleThrow = AtomAdjust(AtomHandleThrow); TermHandleThrow = MkAtomTerm(AtomHandleThrow); - AtomHeap = AtomAdjust(AtomHeap); TermHeap = MkAtomTerm(AtomHeap); - AtomHeapUsed = AtomAdjust(AtomHeapUsed); TermHeapUsed = MkAtomTerm(AtomHeapUsed); - AtomHugeInt = AtomAdjust(AtomHugeInt); TermHugeInt = MkAtomTerm(AtomHugeInt); - AtomIDB = AtomAdjust(AtomIDB); TermIDB = MkAtomTerm(AtomIDB); - AtomIOMode = AtomAdjust(AtomIOMode); TermIOMode = MkAtomTerm(AtomIOMode); - AtomI = AtomAdjust(AtomI); TermI = MkAtomTerm(AtomI); - AtomId = AtomAdjust(AtomId); TermId = MkAtomTerm(AtomId); - AtomIgnore = AtomAdjust(AtomIgnore); TermIgnore = MkAtomTerm(AtomIgnore); - AtomInf = AtomAdjust(AtomInf); TermInf = MkAtomTerm(AtomInf); - AtomInfinity = AtomAdjust(AtomInfinity); TermInfinity = MkAtomTerm(AtomInfinity); - AtomInfo = AtomAdjust(AtomInfo); TermInfo = MkAtomTerm(AtomInfo); - AtomInitGoal = AtomAdjust(AtomInitGoal); TermInitGoal = MkAtomTerm(AtomInitGoal); - AtomInitProlog = AtomAdjust(AtomInitProlog); TermInitProlog = MkAtomTerm(AtomInitProlog); - AtomInStackExpansion = AtomAdjust(AtomInStackExpansion); TermInStackExpansion = MkAtomTerm(AtomInStackExpansion); - AtomInput = AtomAdjust(AtomInput); TermInput = MkAtomTerm(AtomInput); - AtomInstantiationError = AtomAdjust(AtomInstantiationError); TermInstantiationError = MkAtomTerm(AtomInstantiationError); - AtomInt = AtomAdjust(AtomInt); TermInt = MkAtomTerm(AtomInt); - AtomIntOverflow = AtomAdjust(AtomIntOverflow); TermIntOverflow = MkAtomTerm(AtomIntOverflow); - AtomInteger = AtomAdjust(AtomInteger); TermInteger = MkAtomTerm(AtomInteger); - AtomInternalCompilerError = AtomAdjust(AtomInternalCompilerError); TermInternalCompilerError = MkAtomTerm(AtomInternalCompilerError); - AtomIs = AtomAdjust(AtomIs); TermIs = MkAtomTerm(AtomIs); - AtomJ = AtomAdjust(AtomJ); TermJ = MkAtomTerm(AtomJ); - Atoml = AtomAdjust(Atoml); Terml = MkAtomTerm(Atoml); - AtomKey = AtomAdjust(AtomKey); TermKey = MkAtomTerm(AtomKey); - AtomLDLibraryPath = AtomAdjust(AtomLDLibraryPath); TermLDLibraryPath = MkAtomTerm(AtomLDLibraryPath); - AtomLONGINT = AtomAdjust(AtomLONGINT); TermLONGINT = MkAtomTerm(AtomLONGINT); - AtomLOOP = AtomAdjust(AtomLOOP); TermLOOP = MkAtomTerm(AtomLOOP); - AtomLoopStream = AtomAdjust(AtomLoopStream); TermLoopStream = MkAtomTerm(AtomLoopStream); - AtomLT = AtomAdjust(AtomLT); TermLT = MkAtomTerm(AtomLT); - AtomLastExecuteWithin = AtomAdjust(AtomLastExecuteWithin); TermLastExecuteWithin = MkAtomTerm(AtomLastExecuteWithin); - AtomLeash = AtomAdjust(AtomLeash); TermLeash = MkAtomTerm(AtomLeash); - AtomLeast = AtomAdjust(AtomLeast); TermLeast = MkAtomTerm(AtomLeast); - AtomLength = AtomAdjust(AtomLength); TermLength = MkAtomTerm(AtomLength); - AtomList = AtomAdjust(AtomList); TermList = MkAtomTerm(AtomList); - AtomLine = AtomAdjust(AtomLine); TermLine = MkAtomTerm(AtomLine); - AtomLive = AtomAdjust(AtomLive); TermLive = MkAtomTerm(AtomLive); - AtomLoadAnswers = AtomAdjust(AtomLoadAnswers); TermLoadAnswers = MkAtomTerm(AtomLoadAnswers); - AtomLocal = AtomAdjust(AtomLocal); TermLocal = MkAtomTerm(AtomLocal); - AtomLocalSp = AtomAdjust(AtomLocalSp); TermLocalSp = MkAtomTerm(AtomLocalSp); - AtomLocalTrie = AtomAdjust(AtomLocalTrie); TermLocalTrie = MkAtomTerm(AtomLocalTrie); - AtomMax = AtomAdjust(AtomMax); TermMax = MkAtomTerm(AtomMax); - AtomMaximum = AtomAdjust(AtomMaximum); TermMaximum = MkAtomTerm(AtomMaximum); - AtomMaxArity = AtomAdjust(AtomMaxArity); TermMaxArity = MkAtomTerm(AtomMaxArity); - AtomMaxFiles = AtomAdjust(AtomMaxFiles); TermMaxFiles = MkAtomTerm(AtomMaxFiles); - AtomMegaClause = AtomAdjust(AtomMegaClause); TermMegaClause = MkAtomTerm(AtomMegaClause); - AtomMetaCall = AtomAdjust(AtomMetaCall); TermMetaCall = MkAtomTerm(AtomMetaCall); - AtomMfClause = AtomAdjust(AtomMfClause); TermMfClause = MkAtomTerm(AtomMfClause); - AtomMin = AtomAdjust(AtomMin); TermMin = MkAtomTerm(AtomMin); - AtomMinimum = AtomAdjust(AtomMinimum); TermMinimum = MkAtomTerm(AtomMinimum); - AtomMinus = AtomAdjust(AtomMinus); TermMinus = MkAtomTerm(AtomMinus); - AtomModify = AtomAdjust(AtomModify); TermModify = MkAtomTerm(AtomModify); - AtomModule = AtomAdjust(AtomModule); TermModule = MkAtomTerm(AtomModule); - AtomMost = AtomAdjust(AtomMost); TermMost = MkAtomTerm(AtomMost); - AtomMulti = AtomAdjust(AtomMulti); TermMulti = MkAtomTerm(AtomMulti); - AtomMultiFile = AtomAdjust(AtomMultiFile); TermMultiFile = MkAtomTerm(AtomMultiFile); - AtomMultiple = AtomAdjust(AtomMultiple); TermMultiple = MkAtomTerm(AtomMultiple); - AtomMutable = AtomAdjust(AtomMutable); TermMutable = MkAtomTerm(AtomMutable); - AtomMutableVariable = AtomAdjust(AtomMutableVariable); TermMutableVariable = MkAtomTerm(AtomMutableVariable); - AtomMutex = AtomAdjust(AtomMutex); TermMutex = MkAtomTerm(AtomMutex); - AtomMyddasDB = AtomAdjust(AtomMyddasDB); TermMyddasDB = MkAtomTerm(AtomMyddasDB); - AtomMyddasGoal = AtomAdjust(AtomMyddasGoal); TermMyddasGoal = MkAtomTerm(AtomMyddasGoal); - AtomMyddasHost = AtomAdjust(AtomMyddasHost); TermMyddasHost = MkAtomTerm(AtomMyddasHost); - AtomMyddasPass = AtomAdjust(AtomMyddasPass); TermMyddasPass = MkAtomTerm(AtomMyddasPass); - AtomMyddasUser = AtomAdjust(AtomMyddasUser); TermMyddasUser = MkAtomTerm(AtomMyddasUser); - AtomMyddasVersionName = AtomAdjust(AtomMyddasVersionName); TermMyddasVersionName = MkAtomTerm(AtomMyddasVersionName); - AtomNan = AtomAdjust(AtomNan); TermNan = MkAtomTerm(AtomNan); - AtomNb = AtomAdjust(AtomNb); TermNb = MkAtomTerm(AtomNb); - AtomNbTerm = AtomAdjust(AtomNbTerm); TermNbTerm = MkAtomTerm(AtomNbTerm); - AtomNew = AtomAdjust(AtomNew); TermNew = MkAtomTerm(AtomNew); - AtomNewLine = AtomAdjust(AtomNewLine); TermNewLine = MkAtomTerm(AtomNewLine); - AtomNl = AtomAdjust(AtomNl); TermNl = MkAtomTerm(AtomNl); - AtomNoEffect = AtomAdjust(AtomNoEffect); TermNoEffect = MkAtomTerm(AtomNoEffect); - AtomNoMemory = AtomAdjust(AtomNoMemory); TermNoMemory = MkAtomTerm(AtomNoMemory); - AtomNone = AtomAdjust(AtomNone); TermNone = MkAtomTerm(AtomNone); - AtomNonEmptyList = AtomAdjust(AtomNonEmptyList); TermNonEmptyList = MkAtomTerm(AtomNonEmptyList); - AtomNot = AtomAdjust(AtomNot); TermNot = MkAtomTerm(AtomNot); - AtomNotImplemented = AtomAdjust(AtomNotImplemented); TermNotImplemented = MkAtomTerm(AtomNotImplemented); - AtomNotLessThanZero = AtomAdjust(AtomNotLessThanZero); TermNotLessThanZero = MkAtomTerm(AtomNotLessThanZero); - AtomNotNewline = AtomAdjust(AtomNotNewline); TermNotNewline = MkAtomTerm(AtomNotNewline); - AtomNotZero = AtomAdjust(AtomNotZero); TermNotZero = MkAtomTerm(AtomNotZero); - AtomNumber = AtomAdjust(AtomNumber); TermNumber = MkAtomTerm(AtomNumber); - AtomObj = AtomAdjust(AtomObj); TermObj = MkAtomTerm(AtomObj); - AtomOff = AtomAdjust(AtomOff); TermOff = MkAtomTerm(AtomOff); - AtomOffline = AtomAdjust(AtomOffline); TermOffline = MkAtomTerm(AtomOffline); - AtomOn = AtomAdjust(AtomOn); TermOn = MkAtomTerm(AtomOn); - AtomOnline = AtomAdjust(AtomOnline); TermOnline = MkAtomTerm(AtomOnline); - AtomOpen = AtomAdjust(AtomOpen); TermOpen = MkAtomTerm(AtomOpen); - AtomOperatingSystemError = AtomAdjust(AtomOperatingSystemError); TermOperatingSystemError = MkAtomTerm(AtomOperatingSystemError); - AtomOperatingSystemSupport = AtomAdjust(AtomOperatingSystemSupport); TermOperatingSystemSupport = MkAtomTerm(AtomOperatingSystemSupport); - AtomOperator = AtomAdjust(AtomOperator); TermOperator = MkAtomTerm(AtomOperator); - AtomOperatorPriority = AtomAdjust(AtomOperatorPriority); TermOperatorPriority = MkAtomTerm(AtomOperatorPriority); - AtomOperatorSpecifier = AtomAdjust(AtomOperatorSpecifier); TermOperatorSpecifier = MkAtomTerm(AtomOperatorSpecifier); - AtomOpt = AtomAdjust(AtomOpt); TermOpt = MkAtomTerm(AtomOpt); - AtomOtherwise = AtomAdjust(AtomOtherwise); TermOtherwise = MkAtomTerm(AtomOtherwise); - AtomOutOfAttvarsError = AtomAdjust(AtomOutOfAttvarsError); TermOutOfAttvarsError = MkAtomTerm(AtomOutOfAttvarsError); - AtomOutOfAuxspaceError = AtomAdjust(AtomOutOfAuxspaceError); TermOutOfAuxspaceError = MkAtomTerm(AtomOutOfAuxspaceError); - AtomOutOfHeapError = AtomAdjust(AtomOutOfHeapError); TermOutOfHeapError = MkAtomTerm(AtomOutOfHeapError); - AtomOutOfRange = AtomAdjust(AtomOutOfRange); TermOutOfRange = MkAtomTerm(AtomOutOfRange); - AtomOutOfStackError = AtomAdjust(AtomOutOfStackError); TermOutOfStackError = MkAtomTerm(AtomOutOfStackError); - AtomOutOfTrailError = AtomAdjust(AtomOutOfTrailError); TermOutOfTrailError = MkAtomTerm(AtomOutOfTrailError); - AtomOutput = AtomAdjust(AtomOutput); TermOutput = MkAtomTerm(AtomOutput); - AtomParameter = AtomAdjust(AtomParameter); TermParameter = MkAtomTerm(AtomParameter); - AtomPrologCommonsDir = AtomAdjust(AtomPrologCommonsDir); TermPrologCommonsDir = MkAtomTerm(AtomPrologCommonsDir); - AtomPast = AtomAdjust(AtomPast); TermPast = MkAtomTerm(AtomPast); - AtomPastEndOfStream = AtomAdjust(AtomPastEndOfStream); TermPastEndOfStream = MkAtomTerm(AtomPastEndOfStream); - AtomPermissionError = AtomAdjust(AtomPermissionError); TermPermissionError = MkAtomTerm(AtomPermissionError); - AtomPi = AtomAdjust(AtomPi); TermPi = MkAtomTerm(AtomPi); - AtomPipe = AtomAdjust(AtomPipe); TermPipe = MkAtomTerm(AtomPipe); - AtomPriority = AtomAdjust(AtomPriority); TermPriority = MkAtomTerm(AtomPriority); - AtomPlus = AtomAdjust(AtomPlus); TermPlus = MkAtomTerm(AtomPlus); - AtomPointer = AtomAdjust(AtomPointer); TermPointer = MkAtomTerm(AtomPointer); - AtomPortray = AtomAdjust(AtomPortray); TermPortray = MkAtomTerm(AtomPortray); - AtomPredicateIndicator = AtomAdjust(AtomPredicateIndicator); TermPredicateIndicator = MkAtomTerm(AtomPredicateIndicator); - AtomPrimitive = AtomAdjust(AtomPrimitive); TermPrimitive = MkAtomTerm(AtomPrimitive); - AtomPrintMessage = AtomAdjust(AtomPrintMessage); TermPrintMessage = MkAtomTerm(AtomPrintMessage); - AtomPrivateProcedure = AtomAdjust(AtomPrivateProcedure); TermPrivateProcedure = MkAtomTerm(AtomPrivateProcedure); - AtomProcedure = AtomAdjust(AtomProcedure); TermProcedure = MkAtomTerm(AtomProcedure); - AtomProfile = AtomAdjust(AtomProfile); TermProfile = MkAtomTerm(AtomProfile); - AtomProlog = AtomAdjust(AtomProlog); TermProlog = MkAtomTerm(AtomProlog); - AtomProtectStack = AtomAdjust(AtomProtectStack); TermProtectStack = MkAtomTerm(AtomProtectStack); - AtomQly = AtomAdjust(AtomQly); TermQly = MkAtomTerm(AtomQly); - AtomQuery = AtomAdjust(AtomQuery); TermQuery = MkAtomTerm(AtomQuery); - AtomQueue = AtomAdjust(AtomQueue); TermQueue = MkAtomTerm(AtomQueue); - AtomQuiet = AtomAdjust(AtomQuiet); TermQuiet = MkAtomTerm(AtomQuiet); - AtomRadix = AtomAdjust(AtomRadix); TermRadix = MkAtomTerm(AtomRadix); - AtomRandom = AtomAdjust(AtomRandom); TermRandom = MkAtomTerm(AtomRandom); - AtomRange = AtomAdjust(AtomRange); TermRange = MkAtomTerm(AtomRange); - AtomRDiv = AtomAdjust(AtomRDiv); TermRDiv = MkAtomTerm(AtomRDiv); - AtomRead = AtomAdjust(AtomRead); TermRead = MkAtomTerm(AtomRead); - AtomReadOnly = AtomAdjust(AtomReadOnly); TermReadOnly = MkAtomTerm(AtomReadOnly); - AtomReadWrite = AtomAdjust(AtomReadWrite); TermReadWrite = MkAtomTerm(AtomReadWrite); - AtomReadutil = AtomAdjust(AtomReadutil); TermReadutil = MkAtomTerm(AtomReadutil); - AtomReconsult = AtomAdjust(AtomReconsult); TermReconsult = MkAtomTerm(AtomReconsult); - AtomRecordedP = AtomAdjust(AtomRecordedP); TermRecordedP = MkAtomTerm(AtomRecordedP); - AtomRecordedWithKey = AtomAdjust(AtomRecordedWithKey); TermRecordedWithKey = MkAtomTerm(AtomRecordedWithKey); - AtomRedefineWarnings = AtomAdjust(AtomRedefineWarnings); TermRedefineWarnings = MkAtomTerm(AtomRedefineWarnings); - AtomRedoFreeze = AtomAdjust(AtomRedoFreeze); TermRedoFreeze = MkAtomTerm(AtomRedoFreeze); - AtomRefoundVar = AtomAdjust(AtomRefoundVar); TermRefoundVar = MkAtomTerm(AtomRefoundVar); - AtomRelativeTo = AtomAdjust(AtomRelativeTo); TermRelativeTo = MkAtomTerm(AtomRelativeTo); - AtomRepeat = AtomAdjust(AtomRepeat); TermRepeat = MkAtomTerm(AtomRepeat); - AtomRepeatSpace = AtomAdjust(AtomRepeatSpace); TermRepeatSpace = MkAtomTerm(AtomRepeatSpace); - AtomReposition = AtomAdjust(AtomReposition); TermReposition = MkAtomTerm(AtomReposition); - AtomRepresentationError = AtomAdjust(AtomRepresentationError); TermRepresentationError = MkAtomTerm(AtomRepresentationError); - AtomReset = AtomAdjust(AtomReset); TermReset = MkAtomTerm(AtomReset); - AtomResize = AtomAdjust(AtomResize); TermResize = MkAtomTerm(AtomResize); - AtomResourceError = AtomAdjust(AtomResourceError); TermResourceError = MkAtomTerm(AtomResourceError); - AtomRestoreRegs = AtomAdjust(AtomRestoreRegs); TermRestoreRegs = MkAtomTerm(AtomRestoreRegs); - AtomRetry = AtomAdjust(AtomRetry); TermRetry = MkAtomTerm(AtomRetry); - AtomRetryCounter = AtomAdjust(AtomRetryCounter); TermRetryCounter = MkAtomTerm(AtomRetryCounter); - AtomRTree = AtomAdjust(AtomRTree); TermRTree = MkAtomTerm(AtomRTree); - AtomSafe = AtomAdjust(AtomSafe); TermSafe = MkAtomTerm(AtomSafe); - AtomSafeCallCleanup = AtomAdjust(AtomSafeCallCleanup); TermSafeCallCleanup = MkAtomTerm(AtomSafeCallCleanup); - AtomSame = AtomAdjust(AtomSame); TermSame = MkAtomTerm(AtomSame); - AtomSemic = AtomAdjust(AtomSemic); TermSemic = MkAtomTerm(AtomSemic); - AtomShiftCountOverflow = AtomAdjust(AtomShiftCountOverflow); TermShiftCountOverflow = MkAtomTerm(AtomShiftCountOverflow); - AtomSigAlarm = AtomAdjust(AtomSigAlarm); TermSigAlarm = MkAtomTerm(AtomSigAlarm); - AtomSigBreak = AtomAdjust(AtomSigBreak); TermSigBreak = MkAtomTerm(AtomSigBreak); - AtomSigCreep = AtomAdjust(AtomSigCreep); TermSigCreep = MkAtomTerm(AtomSigCreep); - AtomSigDebug = AtomAdjust(AtomSigDebug); TermSigDebug = MkAtomTerm(AtomSigDebug); - AtomSigDelayCreep = AtomAdjust(AtomSigDelayCreep); TermSigDelayCreep = MkAtomTerm(AtomSigDelayCreep); - AtomSigFPE = AtomAdjust(AtomSigFPE); TermSigFPE = MkAtomTerm(AtomSigFPE); - AtomSigHup = AtomAdjust(AtomSigHup); TermSigHup = MkAtomTerm(AtomSigHup); - AtomSigInt = AtomAdjust(AtomSigInt); TermSigInt = MkAtomTerm(AtomSigInt); - AtomSigIti = AtomAdjust(AtomSigIti); TermSigIti = MkAtomTerm(AtomSigIti); - AtomSigPending = AtomAdjust(AtomSigPending); TermSigPending = MkAtomTerm(AtomSigPending); - AtomSigPipe = AtomAdjust(AtomSigPipe); TermSigPipe = MkAtomTerm(AtomSigPipe); - AtomSigStackDump = AtomAdjust(AtomSigStackDump); TermSigStackDump = MkAtomTerm(AtomSigStackDump); - AtomSigStatistics = AtomAdjust(AtomSigStatistics); TermSigStatistics = MkAtomTerm(AtomSigStatistics); - AtomSigTrace = AtomAdjust(AtomSigTrace); TermSigTrace = MkAtomTerm(AtomSigTrace); - AtomSigUsr1 = AtomAdjust(AtomSigUsr1); TermSigUsr1 = MkAtomTerm(AtomSigUsr1); - AtomSigUsr2 = AtomAdjust(AtomSigUsr2); TermSigUsr2 = MkAtomTerm(AtomSigUsr2); - AtomSigVTAlarm = AtomAdjust(AtomSigVTAlarm); TermSigVTAlarm = MkAtomTerm(AtomSigVTAlarm); - AtomSigWakeUp = AtomAdjust(AtomSigWakeUp); TermSigWakeUp = MkAtomTerm(AtomSigWakeUp); - AtomSilent = AtomAdjust(AtomSilent); TermSilent = MkAtomTerm(AtomSilent); - AtomSingle = AtomAdjust(AtomSingle); TermSingle = MkAtomTerm(AtomSingle); - AtomSingleVarWarnings = AtomAdjust(AtomSingleVarWarnings); TermSingleVarWarnings = MkAtomTerm(AtomSingleVarWarnings); - AtomSingleton = AtomAdjust(AtomSingleton); TermSingleton = MkAtomTerm(AtomSingleton); - AtomSlash = AtomAdjust(AtomSlash); TermSlash = MkAtomTerm(AtomSlash); - AtomSocket = AtomAdjust(AtomSocket); TermSocket = MkAtomTerm(AtomSocket); - AtomSolutions = AtomAdjust(AtomSolutions); TermSolutions = MkAtomTerm(AtomSolutions); - AtomSource = AtomAdjust(AtomSource); TermSource = MkAtomTerm(AtomSource); - AtomSourceSink = AtomAdjust(AtomSourceSink); TermSourceSink = MkAtomTerm(AtomSourceSink); - AtomSpy = AtomAdjust(AtomSpy); TermSpy = MkAtomTerm(AtomSpy); - AtomStack = AtomAdjust(AtomStack); TermStack = MkAtomTerm(AtomStack); - AtomStackFree = AtomAdjust(AtomStackFree); TermStackFree = MkAtomTerm(AtomStackFree); - AtomStartupSavedState = AtomAdjust(AtomStartupSavedState); TermStartupSavedState = MkAtomTerm(AtomStartupSavedState); - AtomStaticClause = AtomAdjust(AtomStaticClause); TermStaticClause = MkAtomTerm(AtomStaticClause); - AtomStaticProcedure = AtomAdjust(AtomStaticProcedure); TermStaticProcedure = MkAtomTerm(AtomStaticProcedure); - AtomStream = AtomAdjust(AtomStream); TermStream = MkAtomTerm(AtomStream); - AtomSWIStream = AtomAdjust(AtomSWIStream); TermSWIStream = MkAtomTerm(AtomSWIStream); - AtomVStream = AtomAdjust(AtomVStream); TermVStream = MkAtomTerm(AtomVStream); - AtomStreams = AtomAdjust(AtomStreams); TermStreams = MkAtomTerm(AtomStreams); - AtomStreamOrAlias = AtomAdjust(AtomStreamOrAlias); TermStreamOrAlias = MkAtomTerm(AtomStreamOrAlias); - AtomStreamPos = AtomAdjust(AtomStreamPos); TermStreamPos = MkAtomTerm(AtomStreamPos); - AtomStreamPosition = AtomAdjust(AtomStreamPosition); TermStreamPosition = MkAtomTerm(AtomStreamPosition); - AtomString = AtomAdjust(AtomString); TermString = MkAtomTerm(AtomString); - AtomStyleCheck = AtomAdjust(AtomStyleCheck); TermStyleCheck = MkAtomTerm(AtomStyleCheck); - AtomSTRING = AtomAdjust(AtomSTRING); TermSTRING = MkAtomTerm(AtomSTRING); - AtomSwi = AtomAdjust(AtomSwi); TermSwi = MkAtomTerm(AtomSwi); - AtomSymbolChar = AtomAdjust(AtomSymbolChar); TermSymbolChar = MkAtomTerm(AtomSymbolChar); - AtomSyntaxError = AtomAdjust(AtomSyntaxError); TermSyntaxError = MkAtomTerm(AtomSyntaxError); - AtomSyntaxErrors = AtomAdjust(AtomSyntaxErrors); TermSyntaxErrors = MkAtomTerm(AtomSyntaxErrors); - AtomSyntaxErrorHandler = AtomAdjust(AtomSyntaxErrorHandler); TermSyntaxErrorHandler = MkAtomTerm(AtomSyntaxErrorHandler); - AtomSystem = AtomAdjust(AtomSystem); TermSystem = MkAtomTerm(AtomSystem); - AtomSystemError = AtomAdjust(AtomSystemError); TermSystemError = MkAtomTerm(AtomSystemError); - AtomSystemLibraryDir = AtomAdjust(AtomSystemLibraryDir); TermSystemLibraryDir = MkAtomTerm(AtomSystemLibraryDir); - AtomT = AtomAdjust(AtomT); TermT = MkAtomTerm(AtomT); - AtomTerm = AtomAdjust(AtomTerm); TermTerm = MkAtomTerm(AtomTerm); - AtomTermExpansion = AtomAdjust(AtomTermExpansion); TermTermExpansion = MkAtomTerm(AtomTermExpansion); - AtomTerms = AtomAdjust(AtomTerms); TermTerms = MkAtomTerm(AtomTerms); - AtomText = AtomAdjust(AtomText); TermText = MkAtomTerm(AtomText); - AtomTextStream = AtomAdjust(AtomTextStream); TermTextStream = MkAtomTerm(AtomTextStream); - AtomThread = AtomAdjust(AtomThread); TermThread = MkAtomTerm(AtomThread); - AtomThreads = AtomAdjust(AtomThreads); TermThreads = MkAtomTerm(AtomThreads); - AtomThrow = AtomAdjust(AtomThrow); TermThrow = MkAtomTerm(AtomThrow); - AtomTimeOutSpec = AtomAdjust(AtomTimeOutSpec); TermTimeOutSpec = MkAtomTerm(AtomTimeOutSpec); - AtomTimeoutError = AtomAdjust(AtomTimeoutError); TermTimeoutError = MkAtomTerm(AtomTimeoutError); - AtomTopLevelGoal = AtomAdjust(AtomTopLevelGoal); TermTopLevelGoal = MkAtomTerm(AtomTopLevelGoal); - AtomTopThreadGoal = AtomAdjust(AtomTopThreadGoal); TermTopThreadGoal = MkAtomTerm(AtomTopThreadGoal); - AtomTraceMetaCall = AtomAdjust(AtomTraceMetaCall); TermTraceMetaCall = MkAtomTerm(AtomTraceMetaCall); - AtomTrail = AtomAdjust(AtomTrail); - AtomTrue = AtomAdjust(AtomTrue); TermTrue = MkAtomTerm(AtomTrue); - AtomTty = AtomAdjust(AtomTty); TermTty = MkAtomTerm(AtomTty); - AtomTtys = AtomAdjust(AtomTtys); TermTtys = MkAtomTerm(AtomTtys); - AtomTuple = AtomAdjust(AtomTuple); TermTuple = MkAtomTerm(AtomTuple); - AtomTxt = AtomAdjust(AtomTxt); TermTxt = MkAtomTerm(AtomTxt); - AtomTypeError = AtomAdjust(AtomTypeError); TermTypeError = MkAtomTerm(AtomTypeError); - AtomUndefined = AtomAdjust(AtomUndefined); TermUndefined = MkAtomTerm(AtomUndefined); - AtomUndefp = AtomAdjust(AtomUndefp); TermUndefp = MkAtomTerm(AtomUndefp); - AtomUndefp0 = AtomAdjust(AtomUndefp0); TermUndefp0 = MkAtomTerm(AtomUndefp0); - AtomUnderflow = AtomAdjust(AtomUnderflow); TermUnderflow = MkAtomTerm(AtomUnderflow); - AtomUnificationStack = AtomAdjust(AtomUnificationStack); TermUnificationStack = MkAtomTerm(AtomUnificationStack); - AtomUnique = AtomAdjust(AtomUnique); TermUnique = MkAtomTerm(AtomUnique); - AtomUnsignedByte = AtomAdjust(AtomUnsignedByte); TermUnsignedByte = MkAtomTerm(AtomUnsignedByte); - AtomUnsignedChar = AtomAdjust(AtomUnsignedChar); TermUnsignedChar = MkAtomTerm(AtomUnsignedChar); - AtomUser = AtomAdjust(AtomUser); TermUser = MkAtomTerm(AtomUser); - AtomUserErr = AtomAdjust(AtomUserErr); TermUserErr = MkAtomTerm(AtomUserErr); - AtomUserIn = AtomAdjust(AtomUserIn); TermUserIn = MkAtomTerm(AtomUserIn); - AtomUserOut = AtomAdjust(AtomUserOut); TermUserOut = MkAtomTerm(AtomUserOut); - AtomDollarVar = AtomAdjust(AtomDollarVar); TermDollarVar = MkAtomTerm(AtomDollarVar); - AtomVBar = AtomAdjust(AtomVBar); TermVBar = MkAtomTerm(AtomVBar); - AtomVarBranches = AtomAdjust(AtomVarBranches); TermVarBranches = MkAtomTerm(AtomVarBranches); - AtomVariableNames = AtomAdjust(AtomVariableNames); TermVariableNames = MkAtomTerm(AtomVariableNames); - AtomHiddenVar = AtomAdjust(AtomHiddenVar); TermHiddenVar = MkAtomTerm(AtomHiddenVar); - AtomVariable = AtomAdjust(AtomVariable); TermVariable = MkAtomTerm(AtomVariable); - AtomVerbose = AtomAdjust(AtomVerbose); TermVerbose = MkAtomTerm(AtomVerbose); - AtomVerboseFileSearch = AtomAdjust(AtomVerboseFileSearch); TermVerboseFileSearch = MkAtomTerm(AtomVerboseFileSearch); - AtomVersionNumber = AtomAdjust(AtomVersionNumber); TermVersionNumber = MkAtomTerm(AtomVersionNumber); - AtomVeryVerbose = AtomAdjust(AtomVeryVerbose); TermVeryVerbose = MkAtomTerm(AtomVeryVerbose); - AtomWakeUpGoal = AtomAdjust(AtomWakeUpGoal); TermWakeUpGoal = MkAtomTerm(AtomWakeUpGoal); - AtomWarning = AtomAdjust(AtomWarning); TermWarning = MkAtomTerm(AtomWarning); - AtomWhen = AtomAdjust(AtomWhen); TermWhen = MkAtomTerm(AtomWhen); - AtomWrite = AtomAdjust(AtomWrite); TermWrite = MkAtomTerm(AtomWrite); - AtomWriteTerm = AtomAdjust(AtomWriteTerm); TermWriteTerm = MkAtomTerm(AtomWriteTerm); - AtomXml = AtomAdjust(AtomXml); TermXml = MkAtomTerm(AtomXml); - AtomYapHacks = AtomAdjust(AtomYapHacks); TermYapHacks = MkAtomTerm(AtomYapHacks); - AtomZeroDivisor = AtomAdjust(AtomZeroDivisor); TermZeroDivisor = MkAtomTerm(AtomZeroDivisor); - FunctorAfInet = FuncAdjust(FunctorAfInet); - FunctorAfLocal = FuncAdjust(FunctorAfLocal); - FunctorAfUnix = FuncAdjust(FunctorAfUnix); - FunctorAltNot = FuncAdjust(FunctorAltNot); - FunctorArg = FuncAdjust(FunctorArg); - FunctorArrayEntry = FuncAdjust(FunctorArrayEntry); - FunctorArrow = FuncAdjust(FunctorArrow); - FunctorDoubleArrow = FuncAdjust(FunctorDoubleArrow); - FunctorAssert1 = FuncAdjust(FunctorAssert1); - FunctorAssert = FuncAdjust(FunctorAssert); - FunctorAtFoundOne = FuncAdjust(FunctorAtFoundOne); - FunctorAtom = FuncAdjust(FunctorAtom); - FunctorAtt1 = FuncAdjust(FunctorAtt1); - FunctorAttGoal = FuncAdjust(FunctorAttGoal); - FunctorBraces = FuncAdjust(FunctorBraces); - FunctorCall = FuncAdjust(FunctorCall); - FunctorCatch = FuncAdjust(FunctorCatch); - FunctorChangeModule = FuncAdjust(FunctorChangeModule); - FunctorChars = FuncAdjust(FunctorChars); - FunctorChars1 = FuncAdjust(FunctorChars1); - FunctorCleanCall = FuncAdjust(FunctorCleanCall); - FunctorClist = FuncAdjust(FunctorClist); - FunctorCodes = FuncAdjust(FunctorCodes); - FunctorCodes1 = FuncAdjust(FunctorCodes1); - FunctorColon = FuncAdjust(FunctorColon); - FunctorComma = FuncAdjust(FunctorComma); - FunctorCommentHook = FuncAdjust(FunctorCommentHook); - FunctorContext2 = FuncAdjust(FunctorContext2); - FunctorConsistencyError = FuncAdjust(FunctorConsistencyError); - FunctorCreep = FuncAdjust(FunctorCreep); - FunctorCsult = FuncAdjust(FunctorCsult); - FunctorCurrentModule = FuncAdjust(FunctorCurrentModule); - FunctorCutBy = FuncAdjust(FunctorCutBy); - FunctorDBREF = FuncAdjust(FunctorDBREF); - FunctorDiff = FuncAdjust(FunctorDiff); - FunctorDoLogUpdClause = FuncAdjust(FunctorDoLogUpdClause); - FunctorDoLogUpdClause0 = FuncAdjust(FunctorDoLogUpdClause0); - FunctorDoLogUpdClauseErase = FuncAdjust(FunctorDoLogUpdClauseErase); - FunctorDoStaticClause = FuncAdjust(FunctorDoStaticClause); - FunctorDollar = FuncAdjust(FunctorDollar); - FunctorDollarVar = FuncAdjust(FunctorDollarVar); - FunctorDomainError = FuncAdjust(FunctorDomainError); - FunctorDot = FuncAdjust(FunctorDot); - FunctorDot10 = FuncAdjust(FunctorDot10); - FunctorDot11 = FuncAdjust(FunctorDot11); - FunctorDot12 = FuncAdjust(FunctorDot12); - FunctorDot2 = FuncAdjust(FunctorDot2); - FunctorDot3 = FuncAdjust(FunctorDot3); - FunctorDot4 = FuncAdjust(FunctorDot4); - FunctorDot5 = FuncAdjust(FunctorDot5); - FunctorDot6 = FuncAdjust(FunctorDot6); - FunctorDot7 = FuncAdjust(FunctorDot7); - FunctorDot8 = FuncAdjust(FunctorDot8); - FunctorDot9 = FuncAdjust(FunctorDot9); - FunctorDoubleArrow = FuncAdjust(FunctorDoubleArrow); - FunctorDoubleSlash = FuncAdjust(FunctorDoubleSlash); - FunctorEmptySquareBrackets = FuncAdjust(FunctorEmptySquareBrackets); - FunctorEq = FuncAdjust(FunctorEq); - FunctorError = FuncAdjust(FunctorError); - FunctorEvaluationError = FuncAdjust(FunctorEvaluationError); - FunctorException = FuncAdjust(FunctorException); - FunctorExecute2InMod = FuncAdjust(FunctorExecute2InMod); - FunctorExecuteInMod = FuncAdjust(FunctorExecuteInMod); - FunctorExecuteWithin = FuncAdjust(FunctorExecuteWithin); - FunctorExistenceError = FuncAdjust(FunctorExistenceError); - FunctorExoClause = FuncAdjust(FunctorExoClause); - FunctorFunctor = FuncAdjust(FunctorFunctor); - FunctorGAtom = FuncAdjust(FunctorGAtom); - FunctorGAtomic = FuncAdjust(FunctorGAtomic); - FunctorGCompound = FuncAdjust(FunctorGCompound); - FunctorGFloat = FuncAdjust(FunctorGFloat); - FunctorGFormatAt = FuncAdjust(FunctorGFormatAt); - FunctorGInteger = FuncAdjust(FunctorGInteger); - FunctorGNumber = FuncAdjust(FunctorGNumber); - FunctorGPrimitive = FuncAdjust(FunctorGPrimitive); - FunctorGVar = FuncAdjust(FunctorGVar); - FunctorGeneratePredInfo = FuncAdjust(FunctorGeneratePredInfo); - FunctorGoalExpansion2 = FuncAdjust(FunctorGoalExpansion2); - FunctorGoalExpansion = FuncAdjust(FunctorGoalExpansion); - FunctorHandleThrow = FuncAdjust(FunctorHandleThrow); - FunctorHat = FuncAdjust(FunctorHat); - FunctorI = FuncAdjust(FunctorI); - FunctorId = FuncAdjust(FunctorId); - FunctorInfo1 = FuncAdjust(FunctorInfo1); - FunctorInfo2 = FuncAdjust(FunctorInfo2); - FunctorInfo3 = FuncAdjust(FunctorInfo3); - FunctorInfo4 = FuncAdjust(FunctorInfo4); - FunctorIs = FuncAdjust(FunctorIs); - FunctorJ = FuncAdjust(FunctorJ); - FunctorLastExecuteWithin = FuncAdjust(FunctorLastExecuteWithin); - FunctorList = FuncAdjust(FunctorList); - FunctorLOOP = FuncAdjust(FunctorLOOP); - FunctorMegaClause = FuncAdjust(FunctorMegaClause); - FunctorMetaCall = FuncAdjust(FunctorMetaCall); - FunctorMinus = FuncAdjust(FunctorMinus); - FunctorModule = FuncAdjust(FunctorModule); - FunctorMultiFileClause = FuncAdjust(FunctorMultiFileClause); - FunctorMutable = FuncAdjust(FunctorMutable); - FunctorMutex = FuncAdjust(FunctorMutex); - FunctorNotImplemented = FuncAdjust(FunctorNotImplemented); - FunctorNBQueue = FuncAdjust(FunctorNBQueue); - FunctorNot = FuncAdjust(FunctorNot); - FunctorObj = FuncAdjust(FunctorObj); - FunctorOr = FuncAdjust(FunctorOr); - FunctorOutput = FuncAdjust(FunctorOutput); - FunctorPermissionError = FuncAdjust(FunctorPermissionError); - FunctorPlus = FuncAdjust(FunctorPlus); - FunctorPortray = FuncAdjust(FunctorPortray); - FunctorPrintMessage = FuncAdjust(FunctorPrintMessage); - FunctorProcedure = FuncAdjust(FunctorProcedure); - FunctorPriority = FuncAdjust(FunctorPriority); - FunctorPrologConstraint = FuncAdjust(FunctorPrologConstraint); - FunctorProtectStack = FuncAdjust(FunctorProtectStack); - FunctorQuery = FuncAdjust(FunctorQuery); - FunctorRecordedWithKey = FuncAdjust(FunctorRecordedWithKey); - FunctorRDiv = FuncAdjust(FunctorRDiv); - FunctorRedoFreeze = FuncAdjust(FunctorRedoFreeze); - FunctorRepresentationError = FuncAdjust(FunctorRepresentationError); - FunctorResourceError = FuncAdjust(FunctorResourceError); - FunctorRestoreRegs = FuncAdjust(FunctorRestoreRegs); - FunctorRestoreRegs1 = FuncAdjust(FunctorRestoreRegs1); - FunctorSafe = FuncAdjust(FunctorSafe); - FunctorSafeCallCleanup = FuncAdjust(FunctorSafeCallCleanup); - FunctorSame = FuncAdjust(FunctorSame); - FunctorSlash = FuncAdjust(FunctorSlash); - FunctorStaticClause = FuncAdjust(FunctorStaticClause); - FunctorStream = FuncAdjust(FunctorStream); - FunctorStreamEOS = FuncAdjust(FunctorStreamEOS); - FunctorStreamPos = FuncAdjust(FunctorStreamPos); - FunctorString1 = FuncAdjust(FunctorString1); - FunctorStyleCheck = FuncAdjust(FunctorStyleCheck); - FunctorSyntaxError = FuncAdjust(FunctorSyntaxError); - FunctorShortSyntaxError = FuncAdjust(FunctorShortSyntaxError); - FunctorTermExpansion = FuncAdjust(FunctorTermExpansion); - FunctorThreadRun = FuncAdjust(FunctorThreadRun); - FunctorThrow = FuncAdjust(FunctorThrow); - FunctorTimeoutError = FuncAdjust(FunctorTimeoutError); - FunctorTraceMetaCall = FuncAdjust(FunctorTraceMetaCall); - FunctorTypeError = FuncAdjust(FunctorTypeError); - FunctorUMinus = FuncAdjust(FunctorUMinus); - FunctorUPlus = FuncAdjust(FunctorUPlus); - FunctorVBar = FuncAdjust(FunctorVBar); - FunctorWriteTerm = FuncAdjust(FunctorWriteTerm); - FunctorHiddenVar = FuncAdjust(FunctorHiddenVar); + + /* This file, ratoms.h, was generated automatically by "yap -L misc/buildatoms" + {lease do not update, update misc/ATOMS instead */ + + AtomAtSymbol = AtomAdjust(AtomAtSymbol); TermAtSymbol = MkAtomTerm(AtomAtSymbol); + Atom3Dots = AtomAdjust(Atom3Dots); + AtomAbol = AtomAdjust(AtomAbol); TermAbol = MkAtomTerm(AtomAbol); + AtomAccess = AtomAdjust(AtomAccess); TermAccess = MkAtomTerm(AtomAccess); + AtomAfInet = AtomAdjust(AtomAfInet); TermAfInet = MkAtomTerm(AtomAfInet); + AtomAfLocal = AtomAdjust(AtomAfLocal); TermAfLocal = MkAtomTerm(AtomAfLocal); + AtomAfUnix = AtomAdjust(AtomAfUnix); TermAfUnix = MkAtomTerm(AtomAfUnix); + AtomAlarm = AtomAdjust(AtomAlarm); TermAlarm = MkAtomTerm(AtomAlarm); + AtomAlias = AtomAdjust(AtomAlias); TermAlias = MkAtomTerm(AtomAlias); + AtomAll = AtomAdjust(AtomAll); TermAll = MkAtomTerm(AtomAll); + AtomAltNot = AtomAdjust(AtomAltNot); TermAltNot = MkAtomTerm(AtomAltNot); + AtomAnswer = AtomAdjust(AtomAnswer); TermAnswer = MkAtomTerm(AtomAnswer); + AtomAny = AtomAdjust(AtomAny); TermAny = MkAtomTerm(AtomAny); + AtomAppend = AtomAdjust(AtomAppend); TermAppend = MkAtomTerm(AtomAppend); + AtomArg = AtomAdjust(AtomArg); TermArg = MkAtomTerm(AtomArg); + AtomArray = AtomAdjust(AtomArray); TermArray = MkAtomTerm(AtomArray); + AtomArrayAccess = AtomAdjust(AtomArrayAccess); TermArrayAccess = MkAtomTerm(AtomArrayAccess); + AtomArrayOverflow = AtomAdjust(AtomArrayOverflow); TermArrayOverflow = MkAtomTerm(AtomArrayOverflow); + AtomArrayType = AtomAdjust(AtomArrayType); TermArrayType = MkAtomTerm(AtomArrayType); + AtomArrow = AtomAdjust(AtomArrow); TermArrow = MkAtomTerm(AtomArrow); + AtomAttributedModule = AtomAdjust(AtomAttributedModule); TermAttributedModule = MkAtomTerm(AtomAttributedModule); + AtomDoubleArrow = AtomAdjust(AtomDoubleArrow); TermDoubleArrow = MkAtomTerm(AtomDoubleArrow); + AtomAssert = AtomAdjust(AtomAssert); TermAssert = MkAtomTerm(AtomAssert); + AtomBeginBracket = AtomAdjust(AtomBeginBracket); TermBeginBracket = MkAtomTerm(AtomBeginBracket); + AtomEndBracket = AtomAdjust(AtomEndBracket); TermEndBracket = MkAtomTerm(AtomEndBracket); + AtomBeginSquareBracket = AtomAdjust(AtomBeginSquareBracket); TermBeginSquareBracket = MkAtomTerm(AtomBeginSquareBracket); + AtomEndSquareBracket = AtomAdjust(AtomEndSquareBracket); TermEndSquareBracket = MkAtomTerm(AtomEndSquareBracket); + AtomBeginCurlyBracket = AtomAdjust(AtomBeginCurlyBracket); TermBeginCurlyBracket = MkAtomTerm(AtomBeginCurlyBracket); + AtomEndCurlyBracket = AtomAdjust(AtomEndCurlyBracket); TermEndCurlyBracket = MkAtomTerm(AtomEndCurlyBracket); + AtomEmptyBrackets = AtomAdjust(AtomEmptyBrackets); TermEmptyBrackets = MkAtomTerm(AtomEmptyBrackets); + AtomEmptySquareBrackets = AtomAdjust(AtomEmptySquareBrackets); TermEmptySquareBrackets = MkAtomTerm(AtomEmptySquareBrackets); + AtomAs = AtomAdjust(AtomAs); TermAs = MkAtomTerm(AtomAs); + AtomAsserta = AtomAdjust(AtomAsserta); TermAsserta = MkAtomTerm(AtomAsserta); + AtomAssertaStatic = AtomAdjust(AtomAssertaStatic); TermAssertaStatic = MkAtomTerm(AtomAssertaStatic); + AtomAssertz = AtomAdjust(AtomAssertz); TermAssertz = MkAtomTerm(AtomAssertz); + AtomAssertzStatic = AtomAdjust(AtomAssertzStatic); TermAssertzStatic = MkAtomTerm(AtomAssertzStatic); + AtomAt = AtomAdjust(AtomAt); TermAt = MkAtomTerm(AtomAt); + AtomAtom = AtomAdjust(AtomAtom); TermAtom = MkAtomTerm(AtomAtom); + AtomAtomic = AtomAdjust(AtomAtomic); TermAtomic = MkAtomTerm(AtomAtomic); + AtomAtt = AtomAdjust(AtomAtt); TermAtt = MkAtomTerm(AtomAtt); + AtomAtt1 = AtomAdjust(AtomAtt1); TermAtt1 = MkAtomTerm(AtomAtt1); + AtomAttDo = AtomAdjust(AtomAttDo); TermAttDo = MkAtomTerm(AtomAttDo); + AtomAttributes = AtomAdjust(AtomAttributes); TermAttributes = MkAtomTerm(AtomAttributes); + AtomB = AtomAdjust(AtomB); TermB = MkAtomTerm(AtomB); + AtomBatched = AtomAdjust(AtomBatched); TermBatched = MkAtomTerm(AtomBatched); + AtomBetween = AtomAdjust(AtomBetween); TermBetween = MkAtomTerm(AtomBetween); + AtomBinary = AtomAdjust(AtomBinary); TermBinary = MkAtomTerm(AtomBinary); + AtomBigNum = AtomAdjust(AtomBigNum); TermBigNum = MkAtomTerm(AtomBigNum); + AtomBinaryStream = AtomAdjust(AtomBinaryStream); TermBinaryStream = MkAtomTerm(AtomBinaryStream); + AtomBoolean = AtomAdjust(AtomBoolean); TermBoolean = MkAtomTerm(AtomBoolean); + AtomBraces = AtomAdjust(AtomBraces); TermBraces = MkAtomTerm(AtomBraces); + AtomBreak = AtomAdjust(AtomBreak); TermBreak = MkAtomTerm(AtomBreak); + AtomByte = AtomAdjust(AtomByte); TermByte = MkAtomTerm(AtomByte); + AtomCArith = AtomAdjust(AtomCArith); TermCArith = MkAtomTerm(AtomCArith); + AtomCall = AtomAdjust(AtomCall); TermCall = MkAtomTerm(AtomCall); + AtomCallAndRetryCounter = AtomAdjust(AtomCallAndRetryCounter); TermCallAndRetryCounter = MkAtomTerm(AtomCallAndRetryCounter); + AtomCallCounter = AtomAdjust(AtomCallCounter); TermCallCounter = MkAtomTerm(AtomCallCounter); + AtomCallable = AtomAdjust(AtomCallable); TermCallable = MkAtomTerm(AtomCallable); + AtomCatch = AtomAdjust(AtomCatch); TermCatch = MkAtomTerm(AtomCatch); + AtomChangeModule = AtomAdjust(AtomChangeModule); TermChangeModule = MkAtomTerm(AtomChangeModule); + AtomChar = AtomAdjust(AtomChar); TermChar = MkAtomTerm(AtomChar); + AtomCharsio = AtomAdjust(AtomCharsio); TermCharsio = MkAtomTerm(AtomCharsio); + AtomCharacter = AtomAdjust(AtomCharacter); TermCharacter = MkAtomTerm(AtomCharacter); + AtomCharacterCode = AtomAdjust(AtomCharacterCode); TermCharacterCode = MkAtomTerm(AtomCharacterCode); + AtomChars = AtomAdjust(AtomChars); TermChars = MkAtomTerm(AtomChars); + AtomCharset = AtomAdjust(AtomCharset); TermCharset = MkAtomTerm(AtomCharset); + AtomChType = AtomAdjust(AtomChType); TermChType = MkAtomTerm(AtomChType); + AtomCleanCall = AtomAdjust(AtomCleanCall); TermCleanCall = MkAtomTerm(AtomCleanCall); + AtomClose = AtomAdjust(AtomClose); TermClose = MkAtomTerm(AtomClose); + AtomColon = AtomAdjust(AtomColon); TermColon = MkAtomTerm(AtomColon); + AtomCodeSpace = AtomAdjust(AtomCodeSpace); TermCodeSpace = MkAtomTerm(AtomCodeSpace); + AtomCodes = AtomAdjust(AtomCodes); TermCodes = MkAtomTerm(AtomCodes); + AtomCoInductive = AtomAdjust(AtomCoInductive); TermCoInductive = MkAtomTerm(AtomCoInductive); + AtomComma = AtomAdjust(AtomComma); TermComma = MkAtomTerm(AtomComma); + AtomCommentHook = AtomAdjust(AtomCommentHook); TermCommentHook = MkAtomTerm(AtomCommentHook); + AtomCompact = AtomAdjust(AtomCompact); TermCompact = MkAtomTerm(AtomCompact); + AtomCompound = AtomAdjust(AtomCompound); TermCompound = MkAtomTerm(AtomCompound); + AtomConsistencyError = AtomAdjust(AtomConsistencyError); TermConsistencyError = MkAtomTerm(AtomConsistencyError); + AtomConsult = AtomAdjust(AtomConsult); TermConsult = MkAtomTerm(AtomConsult); + AtomConsultOnBoot = AtomAdjust(AtomConsultOnBoot); TermConsultOnBoot = MkAtomTerm(AtomConsultOnBoot); + AtomContext = AtomAdjust(AtomContext); TermContext = MkAtomTerm(AtomContext); + AtomCputime = AtomAdjust(AtomCputime); TermCputime = MkAtomTerm(AtomCputime); + AtomCreate = AtomAdjust(AtomCreate); TermCreate = MkAtomTerm(AtomCreate); + AtomCreep = AtomAdjust(AtomCreep); TermCreep = MkAtomTerm(AtomCreep); + AtomCryptAtoms = AtomAdjust(AtomCryptAtoms); TermCryptAtoms = MkAtomTerm(AtomCryptAtoms); + AtomCurly = AtomAdjust(AtomCurly); TermCurly = MkAtomTerm(AtomCurly); + AtomCsult = AtomAdjust(AtomCsult); TermCsult = MkAtomTerm(AtomCsult); + AtomCurrentModule = AtomAdjust(AtomCurrentModule); TermCurrentModule = MkAtomTerm(AtomCurrentModule); + AtomCut = AtomAdjust(AtomCut); TermCut = MkAtomTerm(AtomCut); + AtomCutBy = AtomAdjust(AtomCutBy); TermCutBy = MkAtomTerm(AtomCutBy); + AtomDAbort = AtomAdjust(AtomDAbort); TermDAbort = MkAtomTerm(AtomDAbort); + AtomDBLoad = AtomAdjust(AtomDBLoad); TermDBLoad = MkAtomTerm(AtomDBLoad); + AtomDBREF = AtomAdjust(AtomDBREF); TermDBREF = MkAtomTerm(AtomDBREF); + AtomDBReference = AtomAdjust(AtomDBReference); TermDBReference = MkAtomTerm(AtomDBReference); + AtomDBTerm = AtomAdjust(AtomDBTerm); TermDBTerm = MkAtomTerm(AtomDBTerm); + AtomDBref = AtomAdjust(AtomDBref); TermDBref = MkAtomTerm(AtomDBref); + AtomDInteger = AtomAdjust(AtomDInteger); TermDInteger = MkAtomTerm(AtomDInteger); + AtomDebugMeta = AtomAdjust(AtomDebugMeta); TermDebugMeta = MkAtomTerm(AtomDebugMeta); + AtomDebuggerInput = AtomAdjust(AtomDebuggerInput); TermDebuggerInput = MkAtomTerm(AtomDebuggerInput); + AtomDec10 = AtomAdjust(AtomDec10); TermDec10 = MkAtomTerm(AtomDec10); + AtomDefault = AtomAdjust(AtomDefault); TermDefault = MkAtomTerm(AtomDefault); + AtomDevNull = AtomAdjust(AtomDevNull); TermDevNull = MkAtomTerm(AtomDevNull); + AtomDiff = AtomAdjust(AtomDiff); TermDiff = MkAtomTerm(AtomDiff); + AtomDirectory = AtomAdjust(AtomDirectory); TermDirectory = MkAtomTerm(AtomDirectory); + AtomDiscontiguous = AtomAdjust(AtomDiscontiguous); TermDiscontiguous = MkAtomTerm(AtomDiscontiguous); + AtomDiscontiguousWarnings = AtomAdjust(AtomDiscontiguousWarnings); TermDiscontiguousWarnings = MkAtomTerm(AtomDiscontiguousWarnings); + AtomDollar = AtomAdjust(AtomDollar); TermDollar = MkAtomTerm(AtomDollar); + AtomDoLogUpdClause = AtomAdjust(AtomDoLogUpdClause); TermDoLogUpdClause = MkAtomTerm(AtomDoLogUpdClause); + AtomDoLogUpdClause0 = AtomAdjust(AtomDoLogUpdClause0); TermDoLogUpdClause0 = MkAtomTerm(AtomDoLogUpdClause0); + AtomDoLogUpdClauseErase = AtomAdjust(AtomDoLogUpdClauseErase); TermDoLogUpdClauseErase = MkAtomTerm(AtomDoLogUpdClauseErase); + AtomDollarU = AtomAdjust(AtomDollarU); TermDollarU = MkAtomTerm(AtomDollarU); + AtomDollarUndef = AtomAdjust(AtomDollarUndef); TermDollarUndef = MkAtomTerm(AtomDollarUndef); + AtomDomainError = AtomAdjust(AtomDomainError); TermDomainError = MkAtomTerm(AtomDomainError); + AtomDoStaticClause = AtomAdjust(AtomDoStaticClause); TermDoStaticClause = MkAtomTerm(AtomDoStaticClause); + AtomDots = AtomAdjust(AtomDots); TermDots = MkAtomTerm(AtomDots); + AtomDOUBLE = AtomAdjust(AtomDOUBLE); TermDOUBLE = MkAtomTerm(AtomDOUBLE); + AtomDoubleSlash = AtomAdjust(AtomDoubleSlash); TermDoubleSlash = MkAtomTerm(AtomDoubleSlash); + AtomE = AtomAdjust(AtomE); TermE = MkAtomTerm(AtomE); + AtomEOFBeforeEOT = AtomAdjust(AtomEOFBeforeEOT); TermEOFBeforeEOT = MkAtomTerm(AtomEOFBeforeEOT); + AtomEQ = AtomAdjust(AtomEQ); TermEQ = MkAtomTerm(AtomEQ); + AtomEmptyAtom = AtomAdjust(AtomEmptyAtom); TermEmptyAtom = MkAtomTerm(AtomEmptyAtom); + AtomEncoding = AtomAdjust(AtomEncoding); TermEncoding = MkAtomTerm(AtomEncoding); + AtomEndOfStream = AtomAdjust(AtomEndOfStream); TermEndOfStream = MkAtomTerm(AtomEndOfStream); + AtomEof = AtomAdjust(AtomEof); TermEof = MkAtomTerm(AtomEof); + AtomEOfCode = AtomAdjust(AtomEOfCode); TermEOfCode = MkAtomTerm(AtomEOfCode); + AtomEq = AtomAdjust(AtomEq); TermEq = MkAtomTerm(AtomEq); + AtomError = AtomAdjust(AtomError); TermError = MkAtomTerm(AtomError); + AtomException = AtomAdjust(AtomException); TermException = MkAtomTerm(AtomException); + AtomExtensions = AtomAdjust(AtomExtensions); TermExtensions = MkAtomTerm(AtomExtensions); + AtomExternalException = AtomAdjust(AtomExternalException); TermExternalException = MkAtomTerm(AtomExternalException); + AtomEvaluable = AtomAdjust(AtomEvaluable); TermEvaluable = MkAtomTerm(AtomEvaluable); + AtomEvaluationError = AtomAdjust(AtomEvaluationError); TermEvaluationError = MkAtomTerm(AtomEvaluationError); + AtomExecutable = AtomAdjust(AtomExecutable); TermExecutable = MkAtomTerm(AtomExecutable); + AtomExecute = AtomAdjust(AtomExecute); TermExecute = MkAtomTerm(AtomExecute); + AtomExecAnswers = AtomAdjust(AtomExecAnswers); TermExecAnswers = MkAtomTerm(AtomExecAnswers); + AtomExecuteInMod = AtomAdjust(AtomExecuteInMod); TermExecuteInMod = MkAtomTerm(AtomExecuteInMod); + AtomExecuteWithin = AtomAdjust(AtomExecuteWithin); TermExecuteWithin = MkAtomTerm(AtomExecuteWithin); + AtomExecuteWoMod = AtomAdjust(AtomExecuteWoMod); TermExecuteWoMod = MkAtomTerm(AtomExecuteWoMod); + AtomExist = AtomAdjust(AtomExist); TermExist = MkAtomTerm(AtomExist); + AtomExists = AtomAdjust(AtomExists); TermExists = MkAtomTerm(AtomExists); + AtomExit = AtomAdjust(AtomExit); TermExit = MkAtomTerm(AtomExit); + AtomExistenceError = AtomAdjust(AtomExistenceError); TermExistenceError = MkAtomTerm(AtomExistenceError); + AtomExoClause = AtomAdjust(AtomExoClause); TermExoClause = MkAtomTerm(AtomExoClause); + AtomExpectedNumber = AtomAdjust(AtomExpectedNumber); TermExpectedNumber = MkAtomTerm(AtomExpectedNumber); + AtomExpand = AtomAdjust(AtomExpand); TermExpand = MkAtomTerm(AtomExpand); + AtomExtendFileSearchPath = AtomAdjust(AtomExtendFileSearchPath); TermExtendFileSearchPath = MkAtomTerm(AtomExtendFileSearchPath); + AtomExtendsions = AtomAdjust(AtomExtendsions); TermExtendsions = MkAtomTerm(AtomExtendsions); + AtomFB = AtomAdjust(AtomFB); TermFB = MkAtomTerm(AtomFB); + AtomFail = AtomAdjust(AtomFail); TermFail = MkAtomTerm(AtomFail); + AtomFalse = AtomAdjust(AtomFalse); TermFalse = MkAtomTerm(AtomFalse); + AtomFast = AtomAdjust(AtomFast); TermFast = MkAtomTerm(AtomFast); + AtomFastFail = AtomAdjust(AtomFastFail); TermFastFail = MkAtomTerm(AtomFastFail); + AtomFileErrors = AtomAdjust(AtomFileErrors); TermFileErrors = MkAtomTerm(AtomFileErrors); + AtomFileerrors = AtomAdjust(AtomFileerrors); TermFileerrors = MkAtomTerm(AtomFileerrors); + AtomFileType = AtomAdjust(AtomFileType); TermFileType = MkAtomTerm(AtomFileType); + AtomFirst = AtomAdjust(AtomFirst); TermFirst = MkAtomTerm(AtomFirst); + AtomFloat = AtomAdjust(AtomFloat); TermFloat = MkAtomTerm(AtomFloat); + AtomFloatFormat = AtomAdjust(AtomFloatFormat); TermFloatFormat = MkAtomTerm(AtomFloatFormat); + AtomFloatOverflow = AtomAdjust(AtomFloatOverflow); TermFloatOverflow = MkAtomTerm(AtomFloatOverflow); + AtomFloatUnderflow = AtomAdjust(AtomFloatUnderflow); TermFloatUnderflow = MkAtomTerm(AtomFloatUnderflow); + AtomFormat = AtomAdjust(AtomFormat); TermFormat = MkAtomTerm(AtomFormat); + AtomFormatAt = AtomAdjust(AtomFormatAt); TermFormatAt = MkAtomTerm(AtomFormatAt); + AtomFull = AtomAdjust(AtomFull); TermFull = MkAtomTerm(AtomFull); + AtomFunctor = AtomAdjust(AtomFunctor); TermFunctor = MkAtomTerm(AtomFunctor); + AtomGT = AtomAdjust(AtomGT); TermGT = MkAtomTerm(AtomGT); + AtomGVar = AtomAdjust(AtomGVar); TermGVar = MkAtomTerm(AtomGVar); + Atomg = AtomAdjust(Atomg); Termg = MkAtomTerm(Atomg); + AtomGc = AtomAdjust(AtomGc); TermGc = MkAtomTerm(AtomGc); + AtomGcMargin = AtomAdjust(AtomGcMargin); TermGcMargin = MkAtomTerm(AtomGcMargin); + AtomGcTrace = AtomAdjust(AtomGcTrace); TermGcTrace = MkAtomTerm(AtomGcTrace); + AtomGcVerbose = AtomAdjust(AtomGcVerbose); TermGcVerbose = MkAtomTerm(AtomGcVerbose); + AtomGcVeryVerbose = AtomAdjust(AtomGcVeryVerbose); TermGcVeryVerbose = MkAtomTerm(AtomGcVeryVerbose); + AtomGeneratePredInfo = AtomAdjust(AtomGeneratePredInfo); TermGeneratePredInfo = MkAtomTerm(AtomGeneratePredInfo); + AtomGetwork = AtomAdjust(AtomGetwork); TermGetwork = MkAtomTerm(AtomGetwork); + AtomGetworkSeq = AtomAdjust(AtomGetworkSeq); TermGetworkSeq = MkAtomTerm(AtomGetworkSeq); + AtomGlob = AtomAdjust(AtomGlob); TermGlob = MkAtomTerm(AtomGlob); + AtomGlobal = AtomAdjust(AtomGlobal); TermGlobal = MkAtomTerm(AtomGlobal); + AtomGlobalSp = AtomAdjust(AtomGlobalSp); TermGlobalSp = MkAtomTerm(AtomGlobalSp); + AtomGlobalTrie = AtomAdjust(AtomGlobalTrie); TermGlobalTrie = MkAtomTerm(AtomGlobalTrie); + AtomGoalExpansion = AtomAdjust(AtomGoalExpansion); TermGoalExpansion = MkAtomTerm(AtomGoalExpansion); + AtomHat = AtomAdjust(AtomHat); TermHat = MkAtomTerm(AtomHat); + AtomDoubleHat = AtomAdjust(AtomDoubleHat); TermDoubleHat = MkAtomTerm(AtomDoubleHat); + AtomHERE = AtomAdjust(AtomHERE); TermHERE = MkAtomTerm(AtomHERE); + AtomHandleThrow = AtomAdjust(AtomHandleThrow); TermHandleThrow = MkAtomTerm(AtomHandleThrow); + AtomHeap = AtomAdjust(AtomHeap); TermHeap = MkAtomTerm(AtomHeap); + AtomHeapUsed = AtomAdjust(AtomHeapUsed); TermHeapUsed = MkAtomTerm(AtomHeapUsed); + AtomHugeInt = AtomAdjust(AtomHugeInt); TermHugeInt = MkAtomTerm(AtomHugeInt); + AtomIDB = AtomAdjust(AtomIDB); TermIDB = MkAtomTerm(AtomIDB); + AtomIOMode = AtomAdjust(AtomIOMode); TermIOMode = MkAtomTerm(AtomIOMode); + AtomI = AtomAdjust(AtomI); TermI = MkAtomTerm(AtomI); + AtomId = AtomAdjust(AtomId); TermId = MkAtomTerm(AtomId); + AtomIgnore = AtomAdjust(AtomIgnore); TermIgnore = MkAtomTerm(AtomIgnore); + AtomInf = AtomAdjust(AtomInf); TermInf = MkAtomTerm(AtomInf); + AtomInfinity = AtomAdjust(AtomInfinity); TermInfinity = MkAtomTerm(AtomInfinity); + AtomInfo = AtomAdjust(AtomInfo); TermInfo = MkAtomTerm(AtomInfo); + AtomInitGoal = AtomAdjust(AtomInitGoal); TermInitGoal = MkAtomTerm(AtomInitGoal); + AtomInitProlog = AtomAdjust(AtomInitProlog); TermInitProlog = MkAtomTerm(AtomInitProlog); + AtomInStackExpansion = AtomAdjust(AtomInStackExpansion); TermInStackExpansion = MkAtomTerm(AtomInStackExpansion); + AtomInput = AtomAdjust(AtomInput); TermInput = MkAtomTerm(AtomInput); + AtomInstantiationError = AtomAdjust(AtomInstantiationError); TermInstantiationError = MkAtomTerm(AtomInstantiationError); + AtomInt = AtomAdjust(AtomInt); TermInt = MkAtomTerm(AtomInt); + AtomIntOverflow = AtomAdjust(AtomIntOverflow); TermIntOverflow = MkAtomTerm(AtomIntOverflow); + AtomInteger = AtomAdjust(AtomInteger); TermInteger = MkAtomTerm(AtomInteger); + AtomInternalCompilerError = AtomAdjust(AtomInternalCompilerError); TermInternalCompilerError = MkAtomTerm(AtomInternalCompilerError); + AtomIs = AtomAdjust(AtomIs); TermIs = MkAtomTerm(AtomIs); + AtomJ = AtomAdjust(AtomJ); TermJ = MkAtomTerm(AtomJ); + Atoml = AtomAdjust(Atoml); Terml = MkAtomTerm(Atoml); + AtomKey = AtomAdjust(AtomKey); TermKey = MkAtomTerm(AtomKey); + AtomLDLibraryPath = AtomAdjust(AtomLDLibraryPath); TermLDLibraryPath = MkAtomTerm(AtomLDLibraryPath); + AtomLONGINT = AtomAdjust(AtomLONGINT); TermLONGINT = MkAtomTerm(AtomLONGINT); + AtomLOOP = AtomAdjust(AtomLOOP); TermLOOP = MkAtomTerm(AtomLOOP); + AtomLoopStream = AtomAdjust(AtomLoopStream); TermLoopStream = MkAtomTerm(AtomLoopStream); + AtomLT = AtomAdjust(AtomLT); TermLT = MkAtomTerm(AtomLT); + AtomLastExecuteWithin = AtomAdjust(AtomLastExecuteWithin); TermLastExecuteWithin = MkAtomTerm(AtomLastExecuteWithin); + AtomLeash = AtomAdjust(AtomLeash); TermLeash = MkAtomTerm(AtomLeash); + AtomLeast = AtomAdjust(AtomLeast); TermLeast = MkAtomTerm(AtomLeast); + AtomLength = AtomAdjust(AtomLength); TermLength = MkAtomTerm(AtomLength); + AtomList = AtomAdjust(AtomList); TermList = MkAtomTerm(AtomList); + AtomLine = AtomAdjust(AtomLine); TermLine = MkAtomTerm(AtomLine); + AtomLive = AtomAdjust(AtomLive); TermLive = MkAtomTerm(AtomLive); + AtomLoadAnswers = AtomAdjust(AtomLoadAnswers); TermLoadAnswers = MkAtomTerm(AtomLoadAnswers); + AtomLocal = AtomAdjust(AtomLocal); TermLocal = MkAtomTerm(AtomLocal); + AtomLocalSp = AtomAdjust(AtomLocalSp); TermLocalSp = MkAtomTerm(AtomLocalSp); + AtomLocalTrie = AtomAdjust(AtomLocalTrie); TermLocalTrie = MkAtomTerm(AtomLocalTrie); + AtomMax = AtomAdjust(AtomMax); TermMax = MkAtomTerm(AtomMax); + AtomMaximum = AtomAdjust(AtomMaximum); TermMaximum = MkAtomTerm(AtomMaximum); + AtomMaxArity = AtomAdjust(AtomMaxArity); TermMaxArity = MkAtomTerm(AtomMaxArity); + AtomMaxFiles = AtomAdjust(AtomMaxFiles); TermMaxFiles = MkAtomTerm(AtomMaxFiles); + AtomMegaClause = AtomAdjust(AtomMegaClause); TermMegaClause = MkAtomTerm(AtomMegaClause); + AtomMetaCall = AtomAdjust(AtomMetaCall); TermMetaCall = MkAtomTerm(AtomMetaCall); + AtomMfClause = AtomAdjust(AtomMfClause); TermMfClause = MkAtomTerm(AtomMfClause); + AtomMin = AtomAdjust(AtomMin); TermMin = MkAtomTerm(AtomMin); + AtomMinimum = AtomAdjust(AtomMinimum); TermMinimum = MkAtomTerm(AtomMinimum); + AtomMinus = AtomAdjust(AtomMinus); TermMinus = MkAtomTerm(AtomMinus); + AtomModify = AtomAdjust(AtomModify); TermModify = MkAtomTerm(AtomModify); + AtomModule = AtomAdjust(AtomModule); TermModule = MkAtomTerm(AtomModule); + AtomMost = AtomAdjust(AtomMost); TermMost = MkAtomTerm(AtomMost); + AtomMulti = AtomAdjust(AtomMulti); TermMulti = MkAtomTerm(AtomMulti); + AtomMultiFile = AtomAdjust(AtomMultiFile); TermMultiFile = MkAtomTerm(AtomMultiFile); + AtomMultiple = AtomAdjust(AtomMultiple); TermMultiple = MkAtomTerm(AtomMultiple); + AtomMutable = AtomAdjust(AtomMutable); TermMutable = MkAtomTerm(AtomMutable); + AtomMutableVariable = AtomAdjust(AtomMutableVariable); TermMutableVariable = MkAtomTerm(AtomMutableVariable); + AtomMutex = AtomAdjust(AtomMutex); TermMutex = MkAtomTerm(AtomMutex); + AtomMyddasDB = AtomAdjust(AtomMyddasDB); TermMyddasDB = MkAtomTerm(AtomMyddasDB); + AtomMyddasGoal = AtomAdjust(AtomMyddasGoal); TermMyddasGoal = MkAtomTerm(AtomMyddasGoal); + AtomMyddasHost = AtomAdjust(AtomMyddasHost); TermMyddasHost = MkAtomTerm(AtomMyddasHost); + AtomMyddasPass = AtomAdjust(AtomMyddasPass); TermMyddasPass = MkAtomTerm(AtomMyddasPass); + AtomMyddasUser = AtomAdjust(AtomMyddasUser); TermMyddasUser = MkAtomTerm(AtomMyddasUser); + AtomMyddasVersionName = AtomAdjust(AtomMyddasVersionName); TermMyddasVersionName = MkAtomTerm(AtomMyddasVersionName); + AtomNan = AtomAdjust(AtomNan); TermNan = MkAtomTerm(AtomNan); + AtomNb = AtomAdjust(AtomNb); TermNb = MkAtomTerm(AtomNb); + AtomNbTerm = AtomAdjust(AtomNbTerm); TermNbTerm = MkAtomTerm(AtomNbTerm); + AtomNew = AtomAdjust(AtomNew); TermNew = MkAtomTerm(AtomNew); + AtomNewLine = AtomAdjust(AtomNewLine); TermNewLine = MkAtomTerm(AtomNewLine); + AtomNl = AtomAdjust(AtomNl); TermNl = MkAtomTerm(AtomNl); + AtomNoEffect = AtomAdjust(AtomNoEffect); TermNoEffect = MkAtomTerm(AtomNoEffect); + AtomNoMemory = AtomAdjust(AtomNoMemory); TermNoMemory = MkAtomTerm(AtomNoMemory); + AtomNone = AtomAdjust(AtomNone); TermNone = MkAtomTerm(AtomNone); + AtomNonEmptyList = AtomAdjust(AtomNonEmptyList); TermNonEmptyList = MkAtomTerm(AtomNonEmptyList); + AtomNot = AtomAdjust(AtomNot); TermNot = MkAtomTerm(AtomNot); + AtomNotImplemented = AtomAdjust(AtomNotImplemented); TermNotImplemented = MkAtomTerm(AtomNotImplemented); + AtomNotLessThanZero = AtomAdjust(AtomNotLessThanZero); TermNotLessThanZero = MkAtomTerm(AtomNotLessThanZero); + AtomNotNewline = AtomAdjust(AtomNotNewline); TermNotNewline = MkAtomTerm(AtomNotNewline); + AtomNotZero = AtomAdjust(AtomNotZero); TermNotZero = MkAtomTerm(AtomNotZero); + AtomNumber = AtomAdjust(AtomNumber); TermNumber = MkAtomTerm(AtomNumber); + AtomObj = AtomAdjust(AtomObj); TermObj = MkAtomTerm(AtomObj); + AtomOff = AtomAdjust(AtomOff); TermOff = MkAtomTerm(AtomOff); + AtomOffline = AtomAdjust(AtomOffline); TermOffline = MkAtomTerm(AtomOffline); + AtomOn = AtomAdjust(AtomOn); TermOn = MkAtomTerm(AtomOn); + AtomOnline = AtomAdjust(AtomOnline); TermOnline = MkAtomTerm(AtomOnline); + AtomOpen = AtomAdjust(AtomOpen); TermOpen = MkAtomTerm(AtomOpen); + AtomOperatingSystemError = AtomAdjust(AtomOperatingSystemError); TermOperatingSystemError = MkAtomTerm(AtomOperatingSystemError); + AtomOperatingSystemSupport = AtomAdjust(AtomOperatingSystemSupport); TermOperatingSystemSupport = MkAtomTerm(AtomOperatingSystemSupport); + AtomOperator = AtomAdjust(AtomOperator); TermOperator = MkAtomTerm(AtomOperator); + AtomOperatorPriority = AtomAdjust(AtomOperatorPriority); TermOperatorPriority = MkAtomTerm(AtomOperatorPriority); + AtomOperatorSpecifier = AtomAdjust(AtomOperatorSpecifier); TermOperatorSpecifier = MkAtomTerm(AtomOperatorSpecifier); + AtomOpt = AtomAdjust(AtomOpt); TermOpt = MkAtomTerm(AtomOpt); + AtomOtherwise = AtomAdjust(AtomOtherwise); TermOtherwise = MkAtomTerm(AtomOtherwise); + AtomOutOfAttvarsError = AtomAdjust(AtomOutOfAttvarsError); TermOutOfAttvarsError = MkAtomTerm(AtomOutOfAttvarsError); + AtomOutOfAuxspaceError = AtomAdjust(AtomOutOfAuxspaceError); TermOutOfAuxspaceError = MkAtomTerm(AtomOutOfAuxspaceError); + AtomOutOfHeapError = AtomAdjust(AtomOutOfHeapError); TermOutOfHeapError = MkAtomTerm(AtomOutOfHeapError); + AtomOutOfRange = AtomAdjust(AtomOutOfRange); TermOutOfRange = MkAtomTerm(AtomOutOfRange); + AtomOutOfStackError = AtomAdjust(AtomOutOfStackError); TermOutOfStackError = MkAtomTerm(AtomOutOfStackError); + AtomOutOfTrailError = AtomAdjust(AtomOutOfTrailError); TermOutOfTrailError = MkAtomTerm(AtomOutOfTrailError); + AtomOutput = AtomAdjust(AtomOutput); TermOutput = MkAtomTerm(AtomOutput); + AtomParameter = AtomAdjust(AtomParameter); TermParameter = MkAtomTerm(AtomParameter); + AtomPast = AtomAdjust(AtomPast); TermPast = MkAtomTerm(AtomPast); + AtomPastEndOfStream = AtomAdjust(AtomPastEndOfStream); TermPastEndOfStream = MkAtomTerm(AtomPastEndOfStream); + AtomPermissionError = AtomAdjust(AtomPermissionError); TermPermissionError = MkAtomTerm(AtomPermissionError); + AtomPi = AtomAdjust(AtomPi); TermPi = MkAtomTerm(AtomPi); + AtomPipe = AtomAdjust(AtomPipe); TermPipe = MkAtomTerm(AtomPipe); + AtomPriority = AtomAdjust(AtomPriority); TermPriority = MkAtomTerm(AtomPriority); + AtomPlus = AtomAdjust(AtomPlus); TermPlus = MkAtomTerm(AtomPlus); + AtomPointer = AtomAdjust(AtomPointer); TermPointer = MkAtomTerm(AtomPointer); + AtomPopen = AtomAdjust(AtomPopen); TermPopen = MkAtomTerm(AtomPopen); + AtomPortray = AtomAdjust(AtomPortray); TermPortray = MkAtomTerm(AtomPortray); + AtomPredicateIndicator = AtomAdjust(AtomPredicateIndicator); TermPredicateIndicator = MkAtomTerm(AtomPredicateIndicator); + AtomPrimitive = AtomAdjust(AtomPrimitive); TermPrimitive = MkAtomTerm(AtomPrimitive); + AtomPrintMessage = AtomAdjust(AtomPrintMessage); TermPrintMessage = MkAtomTerm(AtomPrintMessage); + AtomPrivateProcedure = AtomAdjust(AtomPrivateProcedure); TermPrivateProcedure = MkAtomTerm(AtomPrivateProcedure); + AtomProcedure = AtomAdjust(AtomProcedure); TermProcedure = MkAtomTerm(AtomProcedure); + AtomProfile = AtomAdjust(AtomProfile); TermProfile = MkAtomTerm(AtomProfile); + AtomProlog = AtomAdjust(AtomProlog); TermProlog = MkAtomTerm(AtomProlog); + AtomPrologCommonsDir = AtomAdjust(AtomPrologCommonsDir); TermPrologCommonsDir = MkAtomTerm(AtomPrologCommonsDir); + AtomProtectStack = AtomAdjust(AtomProtectStack); TermProtectStack = MkAtomTerm(AtomProtectStack); + AtomQly = AtomAdjust(AtomQly); TermQly = MkAtomTerm(AtomQly); + AtomQuery = AtomAdjust(AtomQuery); TermQuery = MkAtomTerm(AtomQuery); + AtomQueue = AtomAdjust(AtomQueue); TermQueue = MkAtomTerm(AtomQueue); + AtomQuiet = AtomAdjust(AtomQuiet); TermQuiet = MkAtomTerm(AtomQuiet); + AtomRadix = AtomAdjust(AtomRadix); TermRadix = MkAtomTerm(AtomRadix); + AtomRandom = AtomAdjust(AtomRandom); TermRandom = MkAtomTerm(AtomRandom); + AtomRange = AtomAdjust(AtomRange); TermRange = MkAtomTerm(AtomRange); + AtomRDiv = AtomAdjust(AtomRDiv); TermRDiv = MkAtomTerm(AtomRDiv); + AtomRead = AtomAdjust(AtomRead); TermRead = MkAtomTerm(AtomRead); + AtomReadOnly = AtomAdjust(AtomReadOnly); TermReadOnly = MkAtomTerm(AtomReadOnly); + AtomReadWrite = AtomAdjust(AtomReadWrite); TermReadWrite = MkAtomTerm(AtomReadWrite); + AtomReadutil = AtomAdjust(AtomReadutil); TermReadutil = MkAtomTerm(AtomReadutil); + AtomReconsult = AtomAdjust(AtomReconsult); TermReconsult = MkAtomTerm(AtomReconsult); + AtomRecordedP = AtomAdjust(AtomRecordedP); TermRecordedP = MkAtomTerm(AtomRecordedP); + AtomRecordedWithKey = AtomAdjust(AtomRecordedWithKey); TermRecordedWithKey = MkAtomTerm(AtomRecordedWithKey); + AtomRedefineWarnings = AtomAdjust(AtomRedefineWarnings); TermRedefineWarnings = MkAtomTerm(AtomRedefineWarnings); + AtomRedo = AtomAdjust(AtomRedo); TermRedo = MkAtomTerm(AtomRedo); + AtomRedoFreeze = AtomAdjust(AtomRedoFreeze); TermRedoFreeze = MkAtomTerm(AtomRedoFreeze); + AtomRefoundVar = AtomAdjust(AtomRefoundVar); TermRefoundVar = MkAtomTerm(AtomRefoundVar); + AtomRelativeTo = AtomAdjust(AtomRelativeTo); TermRelativeTo = MkAtomTerm(AtomRelativeTo); + AtomRepeat = AtomAdjust(AtomRepeat); TermRepeat = MkAtomTerm(AtomRepeat); + AtomRepeatSpace = AtomAdjust(AtomRepeatSpace); TermRepeatSpace = MkAtomTerm(AtomRepeatSpace); + AtomReposition = AtomAdjust(AtomReposition); TermReposition = MkAtomTerm(AtomReposition); + AtomRepresentationError = AtomAdjust(AtomRepresentationError); TermRepresentationError = MkAtomTerm(AtomRepresentationError); + AtomReset = AtomAdjust(AtomReset); TermReset = MkAtomTerm(AtomReset); + AtomResize = AtomAdjust(AtomResize); TermResize = MkAtomTerm(AtomResize); + AtomResourceError = AtomAdjust(AtomResourceError); TermResourceError = MkAtomTerm(AtomResourceError); + AtomRestoreRegs = AtomAdjust(AtomRestoreRegs); TermRestoreRegs = MkAtomTerm(AtomRestoreRegs); + AtomRetry = AtomAdjust(AtomRetry); TermRetry = MkAtomTerm(AtomRetry); + AtomRetryCounter = AtomAdjust(AtomRetryCounter); TermRetryCounter = MkAtomTerm(AtomRetryCounter); + AtomRTree = AtomAdjust(AtomRTree); TermRTree = MkAtomTerm(AtomRTree); + AtomSafe = AtomAdjust(AtomSafe); TermSafe = MkAtomTerm(AtomSafe); + AtomSafeCallCleanup = AtomAdjust(AtomSafeCallCleanup); TermSafeCallCleanup = MkAtomTerm(AtomSafeCallCleanup); + AtomSame = AtomAdjust(AtomSame); TermSame = MkAtomTerm(AtomSame); + AtomSemic = AtomAdjust(AtomSemic); TermSemic = MkAtomTerm(AtomSemic); + AtomShiftCountOverflow = AtomAdjust(AtomShiftCountOverflow); TermShiftCountOverflow = MkAtomTerm(AtomShiftCountOverflow); + AtomSigAlarm = AtomAdjust(AtomSigAlarm); TermSigAlarm = MkAtomTerm(AtomSigAlarm); + AtomSigBreak = AtomAdjust(AtomSigBreak); TermSigBreak = MkAtomTerm(AtomSigBreak); + AtomSigCreep = AtomAdjust(AtomSigCreep); TermSigCreep = MkAtomTerm(AtomSigCreep); + AtomSigDebug = AtomAdjust(AtomSigDebug); TermSigDebug = MkAtomTerm(AtomSigDebug); + AtomSigDelayCreep = AtomAdjust(AtomSigDelayCreep); TermSigDelayCreep = MkAtomTerm(AtomSigDelayCreep); + AtomSigFPE = AtomAdjust(AtomSigFPE); TermSigFPE = MkAtomTerm(AtomSigFPE); + AtomSigHup = AtomAdjust(AtomSigHup); TermSigHup = MkAtomTerm(AtomSigHup); + AtomSigInt = AtomAdjust(AtomSigInt); TermSigInt = MkAtomTerm(AtomSigInt); + AtomSigIti = AtomAdjust(AtomSigIti); TermSigIti = MkAtomTerm(AtomSigIti); + AtomSigPending = AtomAdjust(AtomSigPending); TermSigPending = MkAtomTerm(AtomSigPending); + AtomSigPipe = AtomAdjust(AtomSigPipe); TermSigPipe = MkAtomTerm(AtomSigPipe); + AtomSigStackDump = AtomAdjust(AtomSigStackDump); TermSigStackDump = MkAtomTerm(AtomSigStackDump); + AtomSigStatistics = AtomAdjust(AtomSigStatistics); TermSigStatistics = MkAtomTerm(AtomSigStatistics); + AtomSigTrace = AtomAdjust(AtomSigTrace); TermSigTrace = MkAtomTerm(AtomSigTrace); + AtomSigUsr1 = AtomAdjust(AtomSigUsr1); TermSigUsr1 = MkAtomTerm(AtomSigUsr1); + AtomSigUsr2 = AtomAdjust(AtomSigUsr2); TermSigUsr2 = MkAtomTerm(AtomSigUsr2); + AtomSigVTAlarm = AtomAdjust(AtomSigVTAlarm); TermSigVTAlarm = MkAtomTerm(AtomSigVTAlarm); + AtomSigWakeUp = AtomAdjust(AtomSigWakeUp); TermSigWakeUp = MkAtomTerm(AtomSigWakeUp); + AtomSilent = AtomAdjust(AtomSilent); TermSilent = MkAtomTerm(AtomSilent); + AtomSingle = AtomAdjust(AtomSingle); TermSingle = MkAtomTerm(AtomSingle); + AtomSingleVarWarnings = AtomAdjust(AtomSingleVarWarnings); TermSingleVarWarnings = MkAtomTerm(AtomSingleVarWarnings); + AtomSingleton = AtomAdjust(AtomSingleton); TermSingleton = MkAtomTerm(AtomSingleton); + AtomSlash = AtomAdjust(AtomSlash); TermSlash = MkAtomTerm(AtomSlash); + AtomSocket = AtomAdjust(AtomSocket); TermSocket = MkAtomTerm(AtomSocket); + AtomSolutions = AtomAdjust(AtomSolutions); TermSolutions = MkAtomTerm(AtomSolutions); + AtomSource = AtomAdjust(AtomSource); TermSource = MkAtomTerm(AtomSource); + AtomSourceSink = AtomAdjust(AtomSourceSink); TermSourceSink = MkAtomTerm(AtomSourceSink); + AtomSpy = AtomAdjust(AtomSpy); TermSpy = MkAtomTerm(AtomSpy); + AtomStack = AtomAdjust(AtomStack); TermStack = MkAtomTerm(AtomStack); + AtomStackFree = AtomAdjust(AtomStackFree); TermStackFree = MkAtomTerm(AtomStackFree); + AtomStartupSavedState = AtomAdjust(AtomStartupSavedState); TermStartupSavedState = MkAtomTerm(AtomStartupSavedState); + AtomStaticClause = AtomAdjust(AtomStaticClause); TermStaticClause = MkAtomTerm(AtomStaticClause); + AtomStaticProcedure = AtomAdjust(AtomStaticProcedure); TermStaticProcedure = MkAtomTerm(AtomStaticProcedure); + AtomStream = AtomAdjust(AtomStream); TermStream = MkAtomTerm(AtomStream); + AtomSWIStream = AtomAdjust(AtomSWIStream); TermSWIStream = MkAtomTerm(AtomSWIStream); + AtomVStream = AtomAdjust(AtomVStream); TermVStream = MkAtomTerm(AtomVStream); + AtomStreams = AtomAdjust(AtomStreams); TermStreams = MkAtomTerm(AtomStreams); + AtomStreamOrAlias = AtomAdjust(AtomStreamOrAlias); TermStreamOrAlias = MkAtomTerm(AtomStreamOrAlias); + AtomStreamPos = AtomAdjust(AtomStreamPos); TermStreamPos = MkAtomTerm(AtomStreamPos); + AtomStreamPosition = AtomAdjust(AtomStreamPosition); TermStreamPosition = MkAtomTerm(AtomStreamPosition); + AtomString = AtomAdjust(AtomString); TermString = MkAtomTerm(AtomString); + AtomStyleCheck = AtomAdjust(AtomStyleCheck); TermStyleCheck = MkAtomTerm(AtomStyleCheck); + AtomSTRING = AtomAdjust(AtomSTRING); TermSTRING = MkAtomTerm(AtomSTRING); + AtomSwi = AtomAdjust(AtomSwi); TermSwi = MkAtomTerm(AtomSwi); + AtomSymbolChar = AtomAdjust(AtomSymbolChar); TermSymbolChar = MkAtomTerm(AtomSymbolChar); + AtomSyntaxError = AtomAdjust(AtomSyntaxError); TermSyntaxError = MkAtomTerm(AtomSyntaxError); + AtomSyntaxErrors = AtomAdjust(AtomSyntaxErrors); TermSyntaxErrors = MkAtomTerm(AtomSyntaxErrors); + AtomSyntaxErrorHandler = AtomAdjust(AtomSyntaxErrorHandler); TermSyntaxErrorHandler = MkAtomTerm(AtomSyntaxErrorHandler); + AtomSystem = AtomAdjust(AtomSystem); TermSystem = MkAtomTerm(AtomSystem); + AtomSystemError = AtomAdjust(AtomSystemError); TermSystemError = MkAtomTerm(AtomSystemError); + AtomSystemLibraryDir = AtomAdjust(AtomSystemLibraryDir); TermSystemLibraryDir = MkAtomTerm(AtomSystemLibraryDir); + AtomT = AtomAdjust(AtomT); TermT = MkAtomTerm(AtomT); + AtomTerm = AtomAdjust(AtomTerm); TermTerm = MkAtomTerm(AtomTerm); + AtomTermExpansion = AtomAdjust(AtomTermExpansion); TermTermExpansion = MkAtomTerm(AtomTermExpansion); + AtomTermPosition = AtomAdjust(AtomTermPosition); TermTermPosition = MkAtomTerm(AtomTermPosition); + AtomTerms = AtomAdjust(AtomTerms); TermTerms = MkAtomTerm(AtomTerms); + AtomText = AtomAdjust(AtomText); TermText = MkAtomTerm(AtomText); + AtomTextStream = AtomAdjust(AtomTextStream); TermTextStream = MkAtomTerm(AtomTextStream); + AtomThread = AtomAdjust(AtomThread); TermThread = MkAtomTerm(AtomThread); + AtomThreads = AtomAdjust(AtomThreads); TermThreads = MkAtomTerm(AtomThreads); + AtomThrow = AtomAdjust(AtomThrow); TermThrow = MkAtomTerm(AtomThrow); + AtomTimeOutSpec = AtomAdjust(AtomTimeOutSpec); TermTimeOutSpec = MkAtomTerm(AtomTimeOutSpec); + AtomTimeoutError = AtomAdjust(AtomTimeoutError); TermTimeoutError = MkAtomTerm(AtomTimeoutError); + AtomTopLevelGoal = AtomAdjust(AtomTopLevelGoal); TermTopLevelGoal = MkAtomTerm(AtomTopLevelGoal); + AtomTopThreadGoal = AtomAdjust(AtomTopThreadGoal); TermTopThreadGoal = MkAtomTerm(AtomTopThreadGoal); + AtomTraceMetaCall = AtomAdjust(AtomTraceMetaCall); TermTraceMetaCall = MkAtomTerm(AtomTraceMetaCall); + AtomTrail = AtomAdjust(AtomTrail); + AtomTrue = AtomAdjust(AtomTrue); TermTrue = MkAtomTerm(AtomTrue); + AtomTty = AtomAdjust(AtomTty); TermTty = MkAtomTerm(AtomTty); + AtomTtys = AtomAdjust(AtomTtys); TermTtys = MkAtomTerm(AtomTtys); + AtomTuple = AtomAdjust(AtomTuple); TermTuple = MkAtomTerm(AtomTuple); + AtomTxt = AtomAdjust(AtomTxt); TermTxt = MkAtomTerm(AtomTxt); + AtomTypeError = AtomAdjust(AtomTypeError); TermTypeError = MkAtomTerm(AtomTypeError); + AtomUndefined = AtomAdjust(AtomUndefined); TermUndefined = MkAtomTerm(AtomUndefined); + AtomUndefinedQuery = AtomAdjust(AtomUndefinedQuery); TermUndefinedQuery = MkAtomTerm(AtomUndefinedQuery); + AtomUndefp = AtomAdjust(AtomUndefp); TermUndefp = MkAtomTerm(AtomUndefp); + AtomUndefp0 = AtomAdjust(AtomUndefp0); TermUndefp0 = MkAtomTerm(AtomUndefp0); + AtomUnderflow = AtomAdjust(AtomUnderflow); TermUnderflow = MkAtomTerm(AtomUnderflow); + AtomUnificationStack = AtomAdjust(AtomUnificationStack); TermUnificationStack = MkAtomTerm(AtomUnificationStack); + AtomUnique = AtomAdjust(AtomUnique); TermUnique = MkAtomTerm(AtomUnique); + AtomUnsignedByte = AtomAdjust(AtomUnsignedByte); TermUnsignedByte = MkAtomTerm(AtomUnsignedByte); + AtomUnsignedChar = AtomAdjust(AtomUnsignedChar); TermUnsignedChar = MkAtomTerm(AtomUnsignedChar); + AtomUser = AtomAdjust(AtomUser); TermUser = MkAtomTerm(AtomUser); + AtomUserErr = AtomAdjust(AtomUserErr); TermUserErr = MkAtomTerm(AtomUserErr); + AtomUserIn = AtomAdjust(AtomUserIn); TermUserIn = MkAtomTerm(AtomUserIn); + AtomUserOut = AtomAdjust(AtomUserOut); TermUserOut = MkAtomTerm(AtomUserOut); + AtomUTF8 = AtomAdjust(AtomUTF8); TermUTF8 = MkAtomTerm(AtomUTF8); + AtomDollarVar = AtomAdjust(AtomDollarVar); TermDollarVar = MkAtomTerm(AtomDollarVar); + AtomVBar = AtomAdjust(AtomVBar); TermVBar = MkAtomTerm(AtomVBar); + AtomVarBranches = AtomAdjust(AtomVarBranches); TermVarBranches = MkAtomTerm(AtomVarBranches); + AtomVariableNames = AtomAdjust(AtomVariableNames); TermVariableNames = MkAtomTerm(AtomVariableNames); + AtomHiddenVar = AtomAdjust(AtomHiddenVar); TermHiddenVar = MkAtomTerm(AtomHiddenVar); + AtomVariable = AtomAdjust(AtomVariable); TermVariable = MkAtomTerm(AtomVariable); + AtomVerbose = AtomAdjust(AtomVerbose); TermVerbose = MkAtomTerm(AtomVerbose); + AtomVerboseFileSearch = AtomAdjust(AtomVerboseFileSearch); TermVerboseFileSearch = MkAtomTerm(AtomVerboseFileSearch); + AtomVersionNumber = AtomAdjust(AtomVersionNumber); TermVersionNumber = MkAtomTerm(AtomVersionNumber); + AtomVeryVerbose = AtomAdjust(AtomVeryVerbose); TermVeryVerbose = MkAtomTerm(AtomVeryVerbose); + AtomWakeUpGoal = AtomAdjust(AtomWakeUpGoal); TermWakeUpGoal = MkAtomTerm(AtomWakeUpGoal); + AtomWarning = AtomAdjust(AtomWarning); TermWarning = MkAtomTerm(AtomWarning); + AtomWhen = AtomAdjust(AtomWhen); TermWhen = MkAtomTerm(AtomWhen); + AtomWrite = AtomAdjust(AtomWrite); TermWrite = MkAtomTerm(AtomWrite); + AtomWriteTerm = AtomAdjust(AtomWriteTerm); TermWriteTerm = MkAtomTerm(AtomWriteTerm); + AtomXml = AtomAdjust(AtomXml); TermXml = MkAtomTerm(AtomXml); + AtomYapHacks = AtomAdjust(AtomYapHacks); TermYapHacks = MkAtomTerm(AtomYapHacks); + AtomZeroDivisor = AtomAdjust(AtomZeroDivisor); TermZeroDivisor = MkAtomTerm(AtomZeroDivisor); + FunctorAfInet = FuncAdjust(FunctorAfInet); + FunctorAfLocal = FuncAdjust(FunctorAfLocal); + FunctorAfUnix = FuncAdjust(FunctorAfUnix); + FunctorAltNot = FuncAdjust(FunctorAltNot); + FunctorArg = FuncAdjust(FunctorArg); + FunctorArrayEntry = FuncAdjust(FunctorArrayEntry); + FunctorArrow = FuncAdjust(FunctorArrow); + FunctorDoubleArrow = FuncAdjust(FunctorDoubleArrow); + FunctorAs = FuncAdjust(FunctorAs); + FunctorAssert1 = FuncAdjust(FunctorAssert1); + FunctorAssert = FuncAdjust(FunctorAssert); + FunctorAt = FuncAdjust(FunctorAt); + FunctorAtSymbol = FuncAdjust(FunctorAtSymbol); + FunctorAtFoundOne = FuncAdjust(FunctorAtFoundOne); + FunctorAtom = FuncAdjust(FunctorAtom); + FunctorAtt1 = FuncAdjust(FunctorAtt1); + FunctorAttGoal = FuncAdjust(FunctorAttGoal); + FunctorBraces = FuncAdjust(FunctorBraces); + FunctorCall = FuncAdjust(FunctorCall); + FunctorCatch = FuncAdjust(FunctorCatch); + FunctorChangeModule = FuncAdjust(FunctorChangeModule); + FunctorChars = FuncAdjust(FunctorChars); + FunctorChars1 = FuncAdjust(FunctorChars1); + FunctorCleanCall = FuncAdjust(FunctorCleanCall); + FunctorClist = FuncAdjust(FunctorClist); + FunctorCodes = FuncAdjust(FunctorCodes); + FunctorCodes1 = FuncAdjust(FunctorCodes1); + FunctorColon = FuncAdjust(FunctorColon); + FunctorComma = FuncAdjust(FunctorComma); + FunctorCommentHook = FuncAdjust(FunctorCommentHook); + FunctorContext2 = FuncAdjust(FunctorContext2); + FunctorConsistencyError = FuncAdjust(FunctorConsistencyError); + FunctorCreep = FuncAdjust(FunctorCreep); + FunctorCsult = FuncAdjust(FunctorCsult); + FunctorCurrentModule = FuncAdjust(FunctorCurrentModule); + FunctorCutBy = FuncAdjust(FunctorCutBy); + FunctorDBREF = FuncAdjust(FunctorDBREF); + FunctorDiff = FuncAdjust(FunctorDiff); + FunctorDoLogUpdClause = FuncAdjust(FunctorDoLogUpdClause); + FunctorDoLogUpdClause0 = FuncAdjust(FunctorDoLogUpdClause0); + FunctorDoLogUpdClauseErase = FuncAdjust(FunctorDoLogUpdClauseErase); + FunctorDoStaticClause = FuncAdjust(FunctorDoStaticClause); + FunctorDollar = FuncAdjust(FunctorDollar); + FunctorDollarVar = FuncAdjust(FunctorDollarVar); + FunctorDomainError = FuncAdjust(FunctorDomainError); + FunctorDot = FuncAdjust(FunctorDot); + FunctorDot10 = FuncAdjust(FunctorDot10); + FunctorDot11 = FuncAdjust(FunctorDot11); + FunctorDot12 = FuncAdjust(FunctorDot12); + FunctorDot2 = FuncAdjust(FunctorDot2); + FunctorDot3 = FuncAdjust(FunctorDot3); + FunctorDot4 = FuncAdjust(FunctorDot4); + FunctorDot5 = FuncAdjust(FunctorDot5); + FunctorDot6 = FuncAdjust(FunctorDot6); + FunctorDot7 = FuncAdjust(FunctorDot7); + FunctorDot8 = FuncAdjust(FunctorDot8); + FunctorDot9 = FuncAdjust(FunctorDot9); + FunctorDoubleArrow = FuncAdjust(FunctorDoubleArrow); + FunctorDoubleSlash = FuncAdjust(FunctorDoubleSlash); + FunctorEmptySquareBrackets = FuncAdjust(FunctorEmptySquareBrackets); + FunctorEncoding = FuncAdjust(FunctorEncoding); + FunctorEq = FuncAdjust(FunctorEq); + FunctorError = FuncAdjust(FunctorError); + FunctorEvaluationError = FuncAdjust(FunctorEvaluationError); + FunctorException = FuncAdjust(FunctorException); + FunctorExecute2InMod = FuncAdjust(FunctorExecute2InMod); + FunctorExecuteInMod = FuncAdjust(FunctorExecuteInMod); + FunctorExecuteWithin = FuncAdjust(FunctorExecuteWithin); + FunctorExistenceError = FuncAdjust(FunctorExistenceError); + FunctorExoClause = FuncAdjust(FunctorExoClause); + FunctorExternalException = FuncAdjust(FunctorExternalException); + FunctorFunctor = FuncAdjust(FunctorFunctor); + FunctorGAtom = FuncAdjust(FunctorGAtom); + FunctorGAtomic = FuncAdjust(FunctorGAtomic); + FunctorGCompound = FuncAdjust(FunctorGCompound); + FunctorGFloat = FuncAdjust(FunctorGFloat); + FunctorGFormatAt = FuncAdjust(FunctorGFormatAt); + FunctorGInteger = FuncAdjust(FunctorGInteger); + FunctorGNumber = FuncAdjust(FunctorGNumber); + FunctorGPrimitive = FuncAdjust(FunctorGPrimitive); + FunctorGVar = FuncAdjust(FunctorGVar); + FunctorGeneratePredInfo = FuncAdjust(FunctorGeneratePredInfo); + FunctorGoalExpansion2 = FuncAdjust(FunctorGoalExpansion2); + FunctorGoalExpansion = FuncAdjust(FunctorGoalExpansion); + FunctorHandleThrow = FuncAdjust(FunctorHandleThrow); + FunctorHat = FuncAdjust(FunctorHat); + FunctorDoubleHat = FuncAdjust(FunctorDoubleHat); + FunctorI = FuncAdjust(FunctorI); + FunctorId = FuncAdjust(FunctorId); + FunctorInfo1 = FuncAdjust(FunctorInfo1); + FunctorInfo2 = FuncAdjust(FunctorInfo2); + FunctorInfo3 = FuncAdjust(FunctorInfo3); + FunctorInfo4 = FuncAdjust(FunctorInfo4); + FunctorIs = FuncAdjust(FunctorIs); + FunctorJ = FuncAdjust(FunctorJ); + FunctorLastExecuteWithin = FuncAdjust(FunctorLastExecuteWithin); + FunctorList = FuncAdjust(FunctorList); + FunctorLOOP = FuncAdjust(FunctorLOOP); + FunctorMegaClause = FuncAdjust(FunctorMegaClause); + FunctorMetaCall = FuncAdjust(FunctorMetaCall); + FunctorMinus = FuncAdjust(FunctorMinus); + FunctorModule = FuncAdjust(FunctorModule); + FunctorMultiFileClause = FuncAdjust(FunctorMultiFileClause); + FunctorMutable = FuncAdjust(FunctorMutable); + FunctorMutex = FuncAdjust(FunctorMutex); + FunctorNotImplemented = FuncAdjust(FunctorNotImplemented); + FunctorNBQueue = FuncAdjust(FunctorNBQueue); + FunctorNot = FuncAdjust(FunctorNot); + FunctorObj = FuncAdjust(FunctorObj); + FunctorOr = FuncAdjust(FunctorOr); + FunctorOutput = FuncAdjust(FunctorOutput); + FunctorPermissionError = FuncAdjust(FunctorPermissionError); + FunctorPlus = FuncAdjust(FunctorPlus); + FunctorPopen = FuncAdjust(FunctorPopen); + FunctorPortray = FuncAdjust(FunctorPortray); + FunctorPrintMessage = FuncAdjust(FunctorPrintMessage); + FunctorProcedure = FuncAdjust(FunctorProcedure); + FunctorPriority = FuncAdjust(FunctorPriority); + FunctorPrologConstraint = FuncAdjust(FunctorPrologConstraint); + FunctorProtectStack = FuncAdjust(FunctorProtectStack); + FunctorQuery = FuncAdjust(FunctorQuery); + FunctorRecordedWithKey = FuncAdjust(FunctorRecordedWithKey); + FunctorRDiv = FuncAdjust(FunctorRDiv); + FunctorRedoFreeze = FuncAdjust(FunctorRedoFreeze); + FunctorRepresentationError = FuncAdjust(FunctorRepresentationError); + FunctorResourceError = FuncAdjust(FunctorResourceError); + FunctorRestoreRegs = FuncAdjust(FunctorRestoreRegs); + FunctorRestoreRegs1 = FuncAdjust(FunctorRestoreRegs1); + FunctorSafe = FuncAdjust(FunctorSafe); + FunctorSafeCallCleanup = FuncAdjust(FunctorSafeCallCleanup); + FunctorSame = FuncAdjust(FunctorSame); + FunctorSlash = FuncAdjust(FunctorSlash); + FunctorStaticClause = FuncAdjust(FunctorStaticClause); + FunctorStream = FuncAdjust(FunctorStream); + FunctorStreamEOS = FuncAdjust(FunctorStreamEOS); + FunctorStreamPos = FuncAdjust(FunctorStreamPos); + FunctorString1 = FuncAdjust(FunctorString1); + FunctorStyleCheck = FuncAdjust(FunctorStyleCheck); + FunctorSyntaxError = FuncAdjust(FunctorSyntaxError); + FunctorShortSyntaxError = FuncAdjust(FunctorShortSyntaxError); + FunctorTermExpansion = FuncAdjust(FunctorTermExpansion); + FunctorThreadRun = FuncAdjust(FunctorThreadRun); + FunctorThrow = FuncAdjust(FunctorThrow); + FunctorTimeoutError = FuncAdjust(FunctorTimeoutError); + FunctorTraceMetaCall = FuncAdjust(FunctorTraceMetaCall); + FunctorTypeError = FuncAdjust(FunctorTypeError); + FunctorUMinus = FuncAdjust(FunctorUMinus); + FunctorUndefinedQuery = FuncAdjust(FunctorUndefinedQuery); + FunctorUPlus = FuncAdjust(FunctorUPlus); + FunctorVBar = FuncAdjust(FunctorVBar); + FunctorWriteTerm = FuncAdjust(FunctorWriteTerm); + FunctorHiddenVar = FuncAdjust(FunctorHiddenVar); diff --git a/H/generated/rhstruct.h b/H/generated/rhstruct.h index 1c8faa7e0..a846b195d 100644 --- a/H/generated/rhstruct.h +++ b/H/generated/rhstruct.h @@ -83,7 +83,6 @@ #ifdef EUROTRA TermDollarU = AtomTermAdjust(TermDollarU); #endif - TermAnswer = AtomTermAdjust(TermAnswer); USER_MODULE = AtomTermAdjust(USER_MODULE); IDB_MODULE = AtomTermAdjust(IDB_MODULE); @@ -142,6 +141,7 @@ PredLogUpdClause = PtoPredAdjust(PredLogUpdClause); PredLogUpdClauseErase = PtoPredAdjust(PredLogUpdClauseErase); PredLogUpdClause0 = PtoPredAdjust(PredLogUpdClause0); + PredCall = PtoPredAdjust(PredCall); PredMetaCall = PtoPredAdjust(PredMetaCall); PredProtectStack = PtoPredAdjust(PredProtectStack); PredRecordedWithKey = PtoPredAdjust(PredRecordedWithKey); @@ -152,6 +152,7 @@ PredTraceMetaCall = PtoPredAdjust(PredTraceMetaCall); PredCommentHook = PtoPredAdjust(PredCommentHook); PredProcedure = PtoPredAdjust(PredProcedure); + PredUndefinedQuery = PtoPredAdjust(PredUndefinedQuery); #ifdef LOW_LEVEL_TRACER @@ -270,6 +271,8 @@ #endif + + OpList = OpListAdjust(OpList); RestoreForeignCode(); diff --git a/H/generated/rlocals.h b/H/generated/rlocals.h index cddc0d9f2..3c73467ac 100644 --- a/H/generated/rlocals.h +++ b/H/generated/rlocals.h @@ -1,272 +1,23 @@ - /* This file, rlocals.h, was generated automatically by "yap -L misc/buildlocalglobal" - please do not update, update H/LOCALS instead */ +#ifndef HLOCALS_H +#define HLOCALS_H +#undef LOCAL +#undef LOCAL_INIT +#undef LOCAL_INITF +#undef LOCAL_INIT_RESTORE +#undef LOCAL_ARRAY +#undef LOCAL_ARRAY_ARRAY + +#define LOCAL(TYPE, NAME) +#define LOCAL_INIT(TYPE, NAME, INIT) +#define LOCAL_INITF(TYPE, NAME, INIT) +#define LOCAL_INIT_RESTORE(TYPE, NAME, INIT, RESTORE) REMOTE_##NAME(wid) = RESTORE( REMOTE_##NAME(wid) ) +#define LOCAL_ARRAY(TYPE, NAME, INIT) +#define LOCAL_ARRAY_ARRAY(TYPE, NAME, DIM1, DIM2) static void RestoreWorker(int wid USES_REGS) { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - REMOTE_GlobalArena(wid) = TermToGlobalOrAtomAdjust(REMOTE_GlobalArena(wid)); - - - - - - - - - - - - - - - - - - - - - - -#ifdef COROUTINING - REMOTE_WokenGoals(wid) = TermToGlobalAdjust(REMOTE_WokenGoals(wid)); - REMOTE_AttsMutableList(wid) = TermToGlobalAdjust(REMOTE_AttsMutableList(wid)); -#endif - - REMOTE_GcGeneration(wid) = TermToGlobalAdjust(REMOTE_GcGeneration(wid)); - REMOTE_GcPhase(wid) = TermToGlobalAdjust(REMOTE_GcPhase(wid)); - - - - - - - - - - - - - - -#if defined(GC_NO_TAGS) - -#endif - - - - - - - - - - - - - - - - - - - - REMOTE_DynamicArrays(wid) = PtoArrayEAdjust(REMOTE_DynamicArrays(wid)); - REMOTE_StaticArrays(wid) = PtoArraySAdjust(REMOTE_StaticArrays(wid)); - REMOTE_GlobalVariables(wid) = PtoGlobalEAdjust(REMOTE_GlobalVariables(wid)); - - - - - - - - - - - - -#ifdef THREADS - -#endif /* THREADS */ -#if defined(YAPOR) || defined(TABLING) - - -#endif /* YAPOR || TABLING */ - - -#if LOW_LEVEL_TRACER - -#endif - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#ifdef ANALYST - - -#endif /* ANALYST */ - - - - - - - - - - - - - - - - - -#ifdef LOAD_DYLD - -#endif - -#ifdef LOW_LEVEL_TRACER - -#endif - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +#include "locals.h" } + +#endif diff --git a/H/generated/tatoms.h b/H/generated/tatoms.h index beee9ff0c..0980f6f4d 100644 --- a/H/generated/tatoms.h +++ b/H/generated/tatoms.h @@ -1,1161 +1,754 @@ - -/* This file, tatoms.h, was generated automatically by "yap -L misc/buildatoms" - {lease do not update, update misc/ATOMS instead */ - -X_API EXTERNAL Atom Atom3Dots; -X_API EXTERNAL Atom AtomAbol; -X_API EXTERNAL Term TermAbol; -X_API EXTERNAL Atom AtomAccess; -X_API EXTERNAL Term TermAccess; -X_API EXTERNAL Atom AtomAfInet; -X_API EXTERNAL Term TermAfInet; -X_API EXTERNAL Atom AtomAfLocal; -X_API EXTERNAL Term TermAfLocal; -X_API EXTERNAL Atom AtomAfUnix; -X_API EXTERNAL Term TermAfUnix; -X_API EXTERNAL Atom AtomAlarm; -X_API EXTERNAL Term TermAlarm; -X_API EXTERNAL Atom AtomAlias; -X_API EXTERNAL Term TermAlias; -X_API EXTERNAL Atom AtomAll; -X_API EXTERNAL Term TermAll; -X_API EXTERNAL Atom AtomAltNot; -X_API EXTERNAL Term TermAltNot; -X_API EXTERNAL Atom AtomAnswer; -X_API EXTERNAL Term TermAnswer; -X_API EXTERNAL Atom AtomAny; -X_API EXTERNAL Term TermAny; -X_API EXTERNAL Atom AtomAppend; -X_API EXTERNAL Term TermAppend; -X_API EXTERNAL Atom AtomArg; -X_API EXTERNAL Term TermArg; -X_API EXTERNAL Atom AtomArray; -X_API EXTERNAL Term TermArray; -X_API EXTERNAL Atom AtomArrayAccess; -X_API EXTERNAL Term TermArrayAccess; -X_API EXTERNAL Atom AtomArrayOverflow; -X_API EXTERNAL Term TermArrayOverflow; -X_API EXTERNAL Atom AtomArrayType; -X_API EXTERNAL Term TermArrayType; -X_API EXTERNAL Atom AtomArrow; -X_API EXTERNAL Term TermArrow; -X_API EXTERNAL Atom AtomAttributedModule; -X_API EXTERNAL Term TermAttributedModule; -X_API EXTERNAL Atom AtomDoubleArrow; -X_API EXTERNAL Term TermDoubleArrow; -X_API EXTERNAL Atom AtomAssert; -X_API EXTERNAL Term TermAssert; -X_API EXTERNAL Atom AtomBeginBracket; -X_API EXTERNAL Term TermBeginBracket; -X_API EXTERNAL Atom AtomEndBracket; -X_API EXTERNAL Term TermEndBracket; -X_API EXTERNAL Atom AtomBeginSquareBracket; -X_API EXTERNAL Term TermBeginSquareBracket; -X_API EXTERNAL Atom AtomEndSquareBracket; -X_API EXTERNAL Term TermEndSquareBracket; -X_API EXTERNAL Atom AtomBeginCurlyBracket; -X_API EXTERNAL Term TermBeginCurlyBracket; -X_API EXTERNAL Atom AtomEndCurlyBracket; -X_API EXTERNAL Term TermEndCurlyBracket; -X_API EXTERNAL Atom AtomEmptyBrackets; -X_API EXTERNAL Term TermEmptyBrackets; -X_API EXTERNAL Atom AtomEmptySquareBrackets; -X_API EXTERNAL Term TermEmptySquareBrackets; -X_API EXTERNAL Atom AtomAsserta; -X_API EXTERNAL Term TermAsserta; -X_API EXTERNAL Atom AtomAssertaStatic; -X_API EXTERNAL Term TermAssertaStatic; -X_API EXTERNAL Atom AtomAssertz; -X_API EXTERNAL Term TermAssertz; -X_API EXTERNAL Atom AtomAssertzStatic; -X_API EXTERNAL Term TermAssertzStatic; -X_API EXTERNAL Atom AtomAt; -X_API EXTERNAL Term TermAt; -X_API EXTERNAL Atom AtomAtom; -X_API EXTERNAL Term TermAtom; -X_API EXTERNAL Atom AtomAtomic; -X_API EXTERNAL Term TermAtomic; -X_API EXTERNAL Atom AtomAtt; -X_API EXTERNAL Term TermAtt; -X_API EXTERNAL Atom AtomAtt1; -X_API EXTERNAL Term TermAtt1; -X_API EXTERNAL Atom AtomAttDo; -X_API EXTERNAL Term TermAttDo; -X_API EXTERNAL Atom AtomAttributes; -X_API EXTERNAL Term TermAttributes; -X_API EXTERNAL Atom AtomB; -X_API EXTERNAL Term TermB; -X_API EXTERNAL Atom AtomBatched; -X_API EXTERNAL Term TermBatched; -X_API EXTERNAL Atom AtomBetween; -X_API EXTERNAL Term TermBetween; -X_API EXTERNAL Atom AtomBinary; -X_API EXTERNAL Term TermBinary; -X_API EXTERNAL Atom AtomBigNum; -X_API EXTERNAL Term TermBigNum; -X_API EXTERNAL Atom AtomBinaryStream; -X_API EXTERNAL Term TermBinaryStream; -X_API EXTERNAL Atom AtomBoolean; -X_API EXTERNAL Term TermBoolean; -X_API EXTERNAL Atom AtomBraces; -X_API EXTERNAL Term TermBraces; -X_API EXTERNAL Atom AtomBreak; -X_API EXTERNAL Term TermBreak; -X_API EXTERNAL Atom AtomByte; -X_API EXTERNAL Term TermByte; -X_API EXTERNAL Atom AtomCArith; -X_API EXTERNAL Term TermCArith; -X_API EXTERNAL Atom AtomCall; -X_API EXTERNAL Term TermCall; -X_API EXTERNAL Atom AtomCallAndRetryCounter; -X_API EXTERNAL Term TermCallAndRetryCounter; -X_API EXTERNAL Atom AtomCallCounter; -X_API EXTERNAL Term TermCallCounter; -X_API EXTERNAL Atom AtomCallable; -X_API EXTERNAL Term TermCallable; -X_API EXTERNAL Atom AtomCatch; -X_API EXTERNAL Term TermCatch; -X_API EXTERNAL Atom AtomChangeModule; -X_API EXTERNAL Term TermChangeModule; -X_API EXTERNAL Atom AtomChar; -X_API EXTERNAL Term TermChar; -X_API EXTERNAL Atom AtomCharsio; -X_API EXTERNAL Term TermCharsio; -X_API EXTERNAL Atom AtomCharacter; -X_API EXTERNAL Term TermCharacter; -X_API EXTERNAL Atom AtomCharacterCode; -X_API EXTERNAL Term TermCharacterCode; -X_API EXTERNAL Atom AtomChars; -X_API EXTERNAL Term TermChars; -X_API EXTERNAL Atom AtomCharset; -X_API EXTERNAL Term TermCharset; -X_API EXTERNAL Atom AtomChType; -X_API EXTERNAL Term TermChType; -X_API EXTERNAL Atom AtomCleanCall; -X_API EXTERNAL Term TermCleanCall; -X_API EXTERNAL Atom AtomClose; -X_API EXTERNAL Term TermClose; -X_API EXTERNAL Atom AtomColon; -X_API EXTERNAL Term TermColon; -X_API EXTERNAL Atom AtomCodeSpace; -X_API EXTERNAL Term TermCodeSpace; -X_API EXTERNAL Atom AtomCodes; -X_API EXTERNAL Term TermCodes; -X_API EXTERNAL Atom AtomCoInductive; -X_API EXTERNAL Term TermCoInductive; -X_API EXTERNAL Atom AtomComma; -X_API EXTERNAL Term TermComma; -X_API EXTERNAL Atom AtomCommentHook; -X_API EXTERNAL Term TermCommentHook; -X_API EXTERNAL Atom AtomCompact; -X_API EXTERNAL Term TermCompact; -X_API EXTERNAL Atom AtomCompound; -X_API EXTERNAL Term TermCompound; -X_API EXTERNAL Atom AtomConsistencyError; -X_API EXTERNAL Term TermConsistencyError; -X_API EXTERNAL Atom AtomConsult; -X_API EXTERNAL Term TermConsult; -X_API EXTERNAL Atom AtomConsultOnBoot; -X_API EXTERNAL Term TermConsultOnBoot; -X_API EXTERNAL Atom AtomContext; -X_API EXTERNAL Term TermContext; -X_API EXTERNAL Atom AtomCputime; -X_API EXTERNAL Term TermCputime; -X_API EXTERNAL Atom AtomCreate; -X_API EXTERNAL Term TermCreate; -X_API EXTERNAL Atom AtomCreep; -X_API EXTERNAL Term TermCreep; -X_API EXTERNAL Atom AtomCryptAtoms; -X_API EXTERNAL Term TermCryptAtoms; -X_API EXTERNAL Atom AtomCurly; -X_API EXTERNAL Term TermCurly; -X_API EXTERNAL Atom AtomCsult; -X_API EXTERNAL Term TermCsult; -X_API EXTERNAL Atom AtomCurrentModule; -X_API EXTERNAL Term TermCurrentModule; -X_API EXTERNAL Atom AtomCut; -X_API EXTERNAL Term TermCut; -X_API EXTERNAL Atom AtomCutBy; -X_API EXTERNAL Term TermCutBy; -X_API EXTERNAL Atom AtomDAbort; -X_API EXTERNAL Term TermDAbort; -X_API EXTERNAL Atom AtomDBLoad; -X_API EXTERNAL Term TermDBLoad; -X_API EXTERNAL Atom AtomDBREF; -X_API EXTERNAL Term TermDBREF; -X_API EXTERNAL Atom AtomDBReference; -X_API EXTERNAL Term TermDBReference; -X_API EXTERNAL Atom AtomDBTerm; -X_API EXTERNAL Term TermDBTerm; -X_API EXTERNAL Atom AtomDBref; -X_API EXTERNAL Term TermDBref; -X_API EXTERNAL Atom AtomDInteger; -X_API EXTERNAL Term TermDInteger; -X_API EXTERNAL Atom AtomDebugMeta; -X_API EXTERNAL Term TermDebugMeta; -X_API EXTERNAL Atom AtomDebuggerInput; -X_API EXTERNAL Term TermDebuggerInput; -X_API EXTERNAL Atom AtomDec10; -X_API EXTERNAL Term TermDec10; -X_API EXTERNAL Atom AtomDefault; -X_API EXTERNAL Term TermDefault; -X_API EXTERNAL Atom AtomDevNull; -X_API EXTERNAL Term TermDevNull; -X_API EXTERNAL Atom AtomDiff; -X_API EXTERNAL Term TermDiff; -X_API EXTERNAL Atom AtomDirectory; -X_API EXTERNAL Term TermDirectory; -X_API EXTERNAL Atom AtomDiscontiguous; -X_API EXTERNAL Term TermDiscontiguous; -X_API EXTERNAL Atom AtomDiscontiguousWarnings; -X_API EXTERNAL Term TermDiscontiguousWarnings; -X_API EXTERNAL Atom AtomDollar; -X_API EXTERNAL Term TermDollar; -X_API EXTERNAL Atom AtomDoLogUpdClause; -X_API EXTERNAL Term TermDoLogUpdClause; -X_API EXTERNAL Atom AtomDoLogUpdClause0; -X_API EXTERNAL Term TermDoLogUpdClause0; -X_API EXTERNAL Atom AtomDoLogUpdClauseErase; -X_API EXTERNAL Term TermDoLogUpdClauseErase; -X_API EXTERNAL Atom AtomDollarU; -X_API EXTERNAL Term TermDollarU; -X_API EXTERNAL Atom AtomDollarUndef; -X_API EXTERNAL Term TermDollarUndef; -X_API EXTERNAL Atom AtomDomainError; -X_API EXTERNAL Term TermDomainError; -X_API EXTERNAL Atom AtomDoStaticClause; -X_API EXTERNAL Term TermDoStaticClause; -X_API EXTERNAL Atom AtomDots; -X_API EXTERNAL Term TermDots; -X_API EXTERNAL Atom AtomDOUBLE; -X_API EXTERNAL Term TermDOUBLE; -X_API EXTERNAL Atom AtomDoubleSlash; -X_API EXTERNAL Term TermDoubleSlash; -X_API EXTERNAL Atom AtomE; -X_API EXTERNAL Term TermE; -X_API EXTERNAL Atom AtomEOFBeforeEOT; -X_API EXTERNAL Term TermEOFBeforeEOT; -X_API EXTERNAL Atom AtomEQ; -X_API EXTERNAL Term TermEQ; -X_API EXTERNAL Atom AtomEmptyAtom; -X_API EXTERNAL Term TermEmptyAtom; -X_API EXTERNAL Atom AtomEncoding; -X_API EXTERNAL Term TermEncoding; -X_API EXTERNAL Atom AtomEndOfStream; -X_API EXTERNAL Term TermEndOfStream; -X_API EXTERNAL Atom AtomEof; -X_API EXTERNAL Term TermEof; -X_API EXTERNAL Atom AtomEOfCode; -X_API EXTERNAL Term TermEOfCode; -X_API EXTERNAL Atom AtomEq; -X_API EXTERNAL Term TermEq; -X_API EXTERNAL Atom AtomError; -X_API EXTERNAL Term TermError; -X_API EXTERNAL Atom AtomException; -X_API EXTERNAL Term TermException; -X_API EXTERNAL Atom AtomExtensions; -X_API EXTERNAL Term TermExtensions; -X_API EXTERNAL Atom AtomEvaluable; -X_API EXTERNAL Term TermEvaluable; -X_API EXTERNAL Atom AtomEvaluationError; -X_API EXTERNAL Term TermEvaluationError; -X_API EXTERNAL Atom AtomExecutable; -X_API EXTERNAL Term TermExecutable; -X_API EXTERNAL Atom AtomExecute; -X_API EXTERNAL Term TermExecute; -X_API EXTERNAL Atom AtomExecAnswers; -X_API EXTERNAL Term TermExecAnswers; -X_API EXTERNAL Atom AtomExecuteInMod; -X_API EXTERNAL Term TermExecuteInMod; -X_API EXTERNAL Atom AtomExecuteWithin; -X_API EXTERNAL Term TermExecuteWithin; -X_API EXTERNAL Atom AtomExecuteWoMod; -X_API EXTERNAL Term TermExecuteWoMod; -X_API EXTERNAL Atom AtomExist; -X_API EXTERNAL Term TermExist; -X_API EXTERNAL Atom AtomExists; -X_API EXTERNAL Term TermExists; -X_API EXTERNAL Atom AtomExit; -X_API EXTERNAL Term TermExit; -X_API EXTERNAL Atom AtomExistenceError; -X_API EXTERNAL Term TermExistenceError; -X_API EXTERNAL Atom AtomExoClause; -X_API EXTERNAL Term TermExoClause; -X_API EXTERNAL Atom AtomExpectedNumber; -X_API EXTERNAL Term TermExpectedNumber; -X_API EXTERNAL Atom AtomExpand; -X_API EXTERNAL Term TermExpand; -X_API EXTERNAL Atom AtomExtendFileSearchPath; -X_API EXTERNAL Term TermExtendFileSearchPath; -X_API EXTERNAL Atom AtomExtendsions; -X_API EXTERNAL Term TermExtendsions; -X_API EXTERNAL Atom AtomFB; -X_API EXTERNAL Term TermFB; -X_API EXTERNAL Atom AtomFail; -X_API EXTERNAL Term TermFail; -X_API EXTERNAL Atom AtomFalse; -X_API EXTERNAL Term TermFalse; -X_API EXTERNAL Atom AtomFast; -X_API EXTERNAL Term TermFast; -X_API EXTERNAL Atom AtomFastFail; -X_API EXTERNAL Term TermFastFail; -X_API EXTERNAL Atom AtomFileErrors; -X_API EXTERNAL Term TermFileErrors; -X_API EXTERNAL Atom AtomFileerrors; -X_API EXTERNAL Term TermFileerrors; -X_API EXTERNAL Atom AtomFileType; -X_API EXTERNAL Term TermFileType; -X_API EXTERNAL Atom AtomFirst; -X_API EXTERNAL Term TermFirst; -X_API EXTERNAL Atom AtomFloat; -X_API EXTERNAL Term TermFloat; -X_API EXTERNAL Atom AtomFloatFormat; -X_API EXTERNAL Term TermFloatFormat; -X_API EXTERNAL Atom AtomFloatOverflow; -X_API EXTERNAL Term TermFloatOverflow; -X_API EXTERNAL Atom AtomFloatUnderflow; -X_API EXTERNAL Term TermFloatUnderflow; -X_API EXTERNAL Atom AtomFormat; -X_API EXTERNAL Term TermFormat; -X_API EXTERNAL Atom AtomFormatAt; -X_API EXTERNAL Term TermFormatAt; -X_API EXTERNAL Atom AtomFull; -X_API EXTERNAL Term TermFull; -X_API EXTERNAL Atom AtomFunctor; -X_API EXTERNAL Term TermFunctor; -X_API EXTERNAL Atom AtomGT; -X_API EXTERNAL Term TermGT; -X_API EXTERNAL Atom AtomGVar; -X_API EXTERNAL Term TermGVar; -X_API EXTERNAL Atom AtomGc; -X_API EXTERNAL Term TermGc; -X_API EXTERNAL Atom AtomGcMargin; -X_API EXTERNAL Term TermGcMargin; -X_API EXTERNAL Atom AtomGcTrace; -X_API EXTERNAL Term TermGcTrace; -X_API EXTERNAL Atom AtomGcVerbose; -X_API EXTERNAL Term TermGcVerbose; -X_API EXTERNAL Atom AtomGcVeryVerbose; -X_API EXTERNAL Term TermGcVeryVerbose; -X_API EXTERNAL Atom AtomGeneratePredInfo; -X_API EXTERNAL Term TermGeneratePredInfo; -X_API EXTERNAL Atom AtomGetwork; -X_API EXTERNAL Term TermGetwork; -X_API EXTERNAL Atom AtomGetworkSeq; -X_API EXTERNAL Term TermGetworkSeq; -X_API EXTERNAL Atom AtomGlob; -X_API EXTERNAL Term TermGlob; -X_API EXTERNAL Atom AtomGlobal; -X_API EXTERNAL Term TermGlobal; -X_API EXTERNAL Atom AtomGlobalSp; -X_API EXTERNAL Term TermGlobalSp; -X_API EXTERNAL Atom AtomGlobalTrie; -X_API EXTERNAL Term TermGlobalTrie; -X_API EXTERNAL Atom AtomGoalExpansion; -X_API EXTERNAL Term TermGoalExpansion; -X_API EXTERNAL Atom AtomHat; -X_API EXTERNAL Term TermHat; -X_API EXTERNAL Atom AtomHERE; -X_API EXTERNAL Term TermHERE; -X_API EXTERNAL Atom AtomHandleThrow; -X_API EXTERNAL Term TermHandleThrow; -X_API EXTERNAL Atom AtomHeap; -X_API EXTERNAL Term TermHeap; -X_API EXTERNAL Atom AtomHeapUsed; -X_API EXTERNAL Term TermHeapUsed; -X_API EXTERNAL Atom AtomHugeInt; -X_API EXTERNAL Term TermHugeInt; -X_API EXTERNAL Atom AtomIDB; -X_API EXTERNAL Term TermIDB; -X_API EXTERNAL Atom AtomIOMode; -X_API EXTERNAL Term TermIOMode; -X_API EXTERNAL Atom AtomI; -X_API EXTERNAL Term TermI; -X_API EXTERNAL Atom AtomId; -X_API EXTERNAL Term TermId; -X_API EXTERNAL Atom AtomIgnore; -X_API EXTERNAL Term TermIgnore; -X_API EXTERNAL Atom AtomInf; -X_API EXTERNAL Term TermInf; -X_API EXTERNAL Atom AtomInfinity; -X_API EXTERNAL Term TermInfinity; -X_API EXTERNAL Atom AtomInfo; -X_API EXTERNAL Term TermInfo; -X_API EXTERNAL Atom AtomInitGoal; -X_API EXTERNAL Term TermInitGoal; -X_API EXTERNAL Atom AtomInitProlog; -X_API EXTERNAL Term TermInitProlog; -X_API EXTERNAL Atom AtomInStackExpansion; -X_API EXTERNAL Term TermInStackExpansion; -X_API EXTERNAL Atom AtomInput; -X_API EXTERNAL Term TermInput; -X_API EXTERNAL Atom AtomInstantiationError; -X_API EXTERNAL Term TermInstantiationError; -X_API EXTERNAL Atom AtomInt; -X_API EXTERNAL Term TermInt; -X_API EXTERNAL Atom AtomIntOverflow; -X_API EXTERNAL Term TermIntOverflow; -X_API EXTERNAL Atom AtomInteger; -X_API EXTERNAL Term TermInteger; -X_API EXTERNAL Atom AtomInternalCompilerError; -X_API EXTERNAL Term TermInternalCompilerError; -X_API EXTERNAL Atom AtomIs; -X_API EXTERNAL Term TermIs; -X_API EXTERNAL Atom AtomJ; -X_API EXTERNAL Term TermJ; -X_API EXTERNAL Atom Atoml; -X_API EXTERNAL Term Terml; -X_API EXTERNAL Atom AtomKey; -X_API EXTERNAL Term TermKey; -X_API EXTERNAL Atom AtomLDLibraryPath; -X_API EXTERNAL Term TermLDLibraryPath; -X_API EXTERNAL Atom AtomLONGINT; -X_API EXTERNAL Term TermLONGINT; -X_API EXTERNAL Atom AtomLOOP; -X_API EXTERNAL Term TermLOOP; -X_API EXTERNAL Atom AtomLoopStream; -X_API EXTERNAL Term TermLoopStream; -X_API EXTERNAL Atom AtomLT; -X_API EXTERNAL Term TermLT; -X_API EXTERNAL Atom AtomLastExecuteWithin; -X_API EXTERNAL Term TermLastExecuteWithin; -X_API EXTERNAL Atom AtomLeash; -X_API EXTERNAL Term TermLeash; -X_API EXTERNAL Atom AtomLeast; -X_API EXTERNAL Term TermLeast; -X_API EXTERNAL Atom AtomLength; -X_API EXTERNAL Term TermLength; -X_API EXTERNAL Atom AtomList; -X_API EXTERNAL Term TermList; -X_API EXTERNAL Atom AtomLine; -X_API EXTERNAL Term TermLine; -X_API EXTERNAL Atom AtomLive; -X_API EXTERNAL Term TermLive; -X_API EXTERNAL Atom AtomLoadAnswers; -X_API EXTERNAL Term TermLoadAnswers; -X_API EXTERNAL Atom AtomLocal; -X_API EXTERNAL Term TermLocal; -X_API EXTERNAL Atom AtomLocalSp; -X_API EXTERNAL Term TermLocalSp; -X_API EXTERNAL Atom AtomLocalTrie; -X_API EXTERNAL Term TermLocalTrie; -X_API EXTERNAL Atom AtomMax; -X_API EXTERNAL Term TermMax; -X_API EXTERNAL Atom AtomMaximum; -X_API EXTERNAL Term TermMaximum; -X_API EXTERNAL Atom AtomMaxArity; -X_API EXTERNAL Term TermMaxArity; -X_API EXTERNAL Atom AtomMaxFiles; -X_API EXTERNAL Term TermMaxFiles; -X_API EXTERNAL Atom AtomMegaClause; -X_API EXTERNAL Term TermMegaClause; -X_API EXTERNAL Atom AtomMetaCall; -X_API EXTERNAL Term TermMetaCall; -X_API EXTERNAL Atom AtomMfClause; -X_API EXTERNAL Term TermMfClause; -X_API EXTERNAL Atom AtomMin; -X_API EXTERNAL Term TermMin; -X_API EXTERNAL Atom AtomMinimum; -X_API EXTERNAL Term TermMinimum; -X_API EXTERNAL Atom AtomMinus; -X_API EXTERNAL Term TermMinus; -X_API EXTERNAL Atom AtomModify; -X_API EXTERNAL Term TermModify; -X_API EXTERNAL Atom AtomModule; -X_API EXTERNAL Term TermModule; -X_API EXTERNAL Atom AtomMost; -X_API EXTERNAL Term TermMost; -X_API EXTERNAL Atom AtomMulti; -X_API EXTERNAL Term TermMulti; -X_API EXTERNAL Atom AtomMultiFile; -X_API EXTERNAL Term TermMultiFile; -X_API EXTERNAL Atom AtomMultiple; -X_API EXTERNAL Term TermMultiple; -X_API EXTERNAL Atom AtomMutable; -X_API EXTERNAL Term TermMutable; -X_API EXTERNAL Atom AtomMutableVariable; -X_API EXTERNAL Term TermMutableVariable; -X_API EXTERNAL Atom AtomMutex; -X_API EXTERNAL Term TermMutex; -X_API EXTERNAL Atom AtomMyddasDB; -X_API EXTERNAL Term TermMyddasDB; -X_API EXTERNAL Atom AtomMyddasGoal; -X_API EXTERNAL Term TermMyddasGoal; -X_API EXTERNAL Atom AtomMyddasHost; -X_API EXTERNAL Term TermMyddasHost; -X_API EXTERNAL Atom AtomMyddasPass; -X_API EXTERNAL Term TermMyddasPass; -X_API EXTERNAL Atom AtomMyddasUser; -X_API EXTERNAL Term TermMyddasUser; -X_API EXTERNAL Atom AtomMyddasVersionName; -X_API EXTERNAL Term TermMyddasVersionName; -X_API EXTERNAL Atom AtomNan; -X_API EXTERNAL Term TermNan; -X_API EXTERNAL Atom AtomNb; -X_API EXTERNAL Term TermNb; -X_API EXTERNAL Atom AtomNbTerm; -X_API EXTERNAL Term TermNbTerm; -X_API EXTERNAL Atom AtomNew; -X_API EXTERNAL Term TermNew; -X_API EXTERNAL Atom AtomNewLine; -X_API EXTERNAL Term TermNewLine; -X_API EXTERNAL Atom AtomNl; -X_API EXTERNAL Term TermNl; -X_API EXTERNAL Atom AtomNoEffect; -X_API EXTERNAL Term TermNoEffect; -X_API EXTERNAL Atom AtomNoMemory; -X_API EXTERNAL Term TermNoMemory; -X_API EXTERNAL Atom AtomNone; -X_API EXTERNAL Term TermNone; -X_API EXTERNAL Atom AtomNonEmptyList; -X_API EXTERNAL Term TermNonEmptyList; -X_API EXTERNAL Atom AtomNot; -X_API EXTERNAL Term TermNot; -X_API EXTERNAL Atom AtomNotImplemented; -X_API EXTERNAL Term TermNotImplemented; -X_API EXTERNAL Atom AtomNotLessThanZero; -X_API EXTERNAL Term TermNotLessThanZero; -X_API EXTERNAL Atom AtomNotNewline; -X_API EXTERNAL Term TermNotNewline; -X_API EXTERNAL Atom AtomNotZero; -X_API EXTERNAL Term TermNotZero; -X_API EXTERNAL Atom AtomNumber; -X_API EXTERNAL Term TermNumber; -X_API EXTERNAL Atom AtomObj; -X_API EXTERNAL Term TermObj; -X_API EXTERNAL Atom AtomOff; -X_API EXTERNAL Term TermOff; -X_API EXTERNAL Atom AtomOffline; -X_API EXTERNAL Term TermOffline; -X_API EXTERNAL Atom AtomOn; -X_API EXTERNAL Term TermOn; -X_API EXTERNAL Atom AtomOnline; -X_API EXTERNAL Term TermOnline; -X_API EXTERNAL Atom AtomOpen; -X_API EXTERNAL Term TermOpen; -X_API EXTERNAL Atom AtomOperatingSystemError; -X_API EXTERNAL Term TermOperatingSystemError; -X_API EXTERNAL Atom AtomOperatingSystemSupport; -X_API EXTERNAL Term TermOperatingSystemSupport; -X_API EXTERNAL Atom AtomOperator; -X_API EXTERNAL Term TermOperator; -X_API EXTERNAL Atom AtomOperatorPriority; -X_API EXTERNAL Term TermOperatorPriority; -X_API EXTERNAL Atom AtomOperatorSpecifier; -X_API EXTERNAL Term TermOperatorSpecifier; -X_API EXTERNAL Atom AtomOpt; -X_API EXTERNAL Term TermOpt; -X_API EXTERNAL Atom AtomOtherwise; -X_API EXTERNAL Term TermOtherwise; -X_API EXTERNAL Atom AtomOutOfAttvarsError; -X_API EXTERNAL Term TermOutOfAttvarsError; -X_API EXTERNAL Atom AtomOutOfAuxspaceError; -X_API EXTERNAL Term TermOutOfAuxspaceError; -X_API EXTERNAL Atom AtomOutOfHeapError; -X_API EXTERNAL Term TermOutOfHeapError; -X_API EXTERNAL Atom AtomOutOfRange; -X_API EXTERNAL Term TermOutOfRange; -X_API EXTERNAL Atom AtomOutOfStackError; -X_API EXTERNAL Term TermOutOfStackError; -X_API EXTERNAL Atom AtomOutOfTrailError; -X_API EXTERNAL Term TermOutOfTrailError; -X_API EXTERNAL Atom AtomOutput; -X_API EXTERNAL Term TermOutput; -X_API EXTERNAL Atom AtomParameter; -X_API EXTERNAL Term TermParameter; -X_API EXTERNAL Atom AtomPrologCommonsDir; -X_API EXTERNAL Term TermPrologCommonsDir; -X_API EXTERNAL Atom AtomPast; -X_API EXTERNAL Term TermPast; -X_API EXTERNAL Atom AtomPastEndOfStream; -X_API EXTERNAL Term TermPastEndOfStream; -X_API EXTERNAL Atom AtomPermissionError; -X_API EXTERNAL Term TermPermissionError; -X_API EXTERNAL Atom AtomPi; -X_API EXTERNAL Term TermPi; -X_API EXTERNAL Atom AtomPipe; -X_API EXTERNAL Term TermPipe; -X_API EXTERNAL Atom AtomPriority; -X_API EXTERNAL Term TermPriority; -X_API EXTERNAL Atom AtomPlus; -X_API EXTERNAL Term TermPlus; -X_API EXTERNAL Atom AtomPointer; -X_API EXTERNAL Term TermPointer; -X_API EXTERNAL Atom AtomPortray; -X_API EXTERNAL Term TermPortray; -X_API EXTERNAL Atom AtomPredicateIndicator; -X_API EXTERNAL Term TermPredicateIndicator; -X_API EXTERNAL Atom AtomPrimitive; -X_API EXTERNAL Term TermPrimitive; -X_API EXTERNAL Atom AtomPrintMessage; -X_API EXTERNAL Term TermPrintMessage; -X_API EXTERNAL Atom AtomPrivateProcedure; -X_API EXTERNAL Term TermPrivateProcedure; -X_API EXTERNAL Atom AtomProcedure; -X_API EXTERNAL Term TermProcedure; -X_API EXTERNAL Atom AtomProfile; -X_API EXTERNAL Term TermProfile; -X_API EXTERNAL Atom AtomProlog; -X_API EXTERNAL Term TermProlog; -X_API EXTERNAL Atom AtomProtectStack; -X_API EXTERNAL Term TermProtectStack; -X_API EXTERNAL Atom AtomQly; -X_API EXTERNAL Term TermQly; -X_API EXTERNAL Atom AtomQuery; -X_API EXTERNAL Term TermQuery; -X_API EXTERNAL Atom AtomQueue; -X_API EXTERNAL Term TermQueue; -X_API EXTERNAL Atom AtomQuiet; -X_API EXTERNAL Term TermQuiet; -X_API EXTERNAL Atom AtomRadix; -X_API EXTERNAL Term TermRadix; -X_API EXTERNAL Atom AtomRandom; -X_API EXTERNAL Term TermRandom; -X_API EXTERNAL Atom AtomRange; -X_API EXTERNAL Term TermRange; -X_API EXTERNAL Atom AtomRDiv; -X_API EXTERNAL Term TermRDiv; -X_API EXTERNAL Atom AtomRead; -X_API EXTERNAL Term TermRead; -X_API EXTERNAL Atom AtomReadOnly; -X_API EXTERNAL Term TermReadOnly; -X_API EXTERNAL Atom AtomReadWrite; -X_API EXTERNAL Term TermReadWrite; -X_API EXTERNAL Atom AtomReadutil; -X_API EXTERNAL Term TermReadutil; -X_API EXTERNAL Atom AtomReconsult; -X_API EXTERNAL Term TermReconsult; -X_API EXTERNAL Atom AtomRecordedP; -X_API EXTERNAL Term TermRecordedP; -X_API EXTERNAL Atom AtomRecordedWithKey; -X_API EXTERNAL Term TermRecordedWithKey; -X_API EXTERNAL Atom AtomRedefineWarnings; -X_API EXTERNAL Term TermRedefineWarnings; -X_API EXTERNAL Atom AtomRedoFreeze; -X_API EXTERNAL Term TermRedoFreeze; -X_API EXTERNAL Atom AtomRefoundVar; -X_API EXTERNAL Term TermRefoundVar; -X_API EXTERNAL Atom AtomRelativeTo; -X_API EXTERNAL Term TermRelativeTo; -X_API EXTERNAL Atom AtomRepeat; -X_API EXTERNAL Term TermRepeat; -X_API EXTERNAL Atom AtomRepeatSpace; -X_API EXTERNAL Term TermRepeatSpace; -X_API EXTERNAL Atom AtomReposition; -X_API EXTERNAL Term TermReposition; -X_API EXTERNAL Atom AtomRepresentationError; -X_API EXTERNAL Term TermRepresentationError; -X_API EXTERNAL Atom AtomReset; -X_API EXTERNAL Term TermReset; -X_API EXTERNAL Atom AtomResize; -X_API EXTERNAL Term TermResize; -X_API EXTERNAL Atom AtomResourceError; -X_API EXTERNAL Term TermResourceError; -X_API EXTERNAL Atom AtomRestoreRegs; -X_API EXTERNAL Term TermRestoreRegs; -X_API EXTERNAL Atom AtomRetry; -X_API EXTERNAL Term TermRetry; -X_API EXTERNAL Atom AtomRetryCounter; -X_API EXTERNAL Term TermRetryCounter; -X_API EXTERNAL Atom AtomRTree; -X_API EXTERNAL Term TermRTree; -X_API EXTERNAL Atom AtomSafe; -X_API EXTERNAL Term TermSafe; -X_API EXTERNAL Atom AtomSafeCallCleanup; -X_API EXTERNAL Term TermSafeCallCleanup; -X_API EXTERNAL Atom AtomSame; -X_API EXTERNAL Term TermSame; -X_API EXTERNAL Atom AtomSemic; -X_API EXTERNAL Term TermSemic; -X_API EXTERNAL Atom AtomShiftCountOverflow; -X_API EXTERNAL Term TermShiftCountOverflow; -X_API EXTERNAL Atom AtomSigAlarm; -X_API EXTERNAL Term TermSigAlarm; -X_API EXTERNAL Atom AtomSigBreak; -X_API EXTERNAL Term TermSigBreak; -X_API EXTERNAL Atom AtomSigCreep; -X_API EXTERNAL Term TermSigCreep; -X_API EXTERNAL Atom AtomSigDebug; -X_API EXTERNAL Term TermSigDebug; -X_API EXTERNAL Atom AtomSigDelayCreep; -X_API EXTERNAL Term TermSigDelayCreep; -X_API EXTERNAL Atom AtomSigFPE; -X_API EXTERNAL Term TermSigFPE; -X_API EXTERNAL Atom AtomSigHup; -X_API EXTERNAL Term TermSigHup; -X_API EXTERNAL Atom AtomSigInt; -X_API EXTERNAL Term TermSigInt; -X_API EXTERNAL Atom AtomSigIti; -X_API EXTERNAL Term TermSigIti; -X_API EXTERNAL Atom AtomSigPending; -X_API EXTERNAL Term TermSigPending; -X_API EXTERNAL Atom AtomSigPipe; -X_API EXTERNAL Term TermSigPipe; -X_API EXTERNAL Atom AtomSigStackDump; -X_API EXTERNAL Term TermSigStackDump; -X_API EXTERNAL Atom AtomSigStatistics; -X_API EXTERNAL Term TermSigStatistics; -X_API EXTERNAL Atom AtomSigTrace; -X_API EXTERNAL Term TermSigTrace; -X_API EXTERNAL Atom AtomSigUsr1; -X_API EXTERNAL Term TermSigUsr1; -X_API EXTERNAL Atom AtomSigUsr2; -X_API EXTERNAL Term TermSigUsr2; -X_API EXTERNAL Atom AtomSigVTAlarm; -X_API EXTERNAL Term TermSigVTAlarm; -X_API EXTERNAL Atom AtomSigWakeUp; -X_API EXTERNAL Term TermSigWakeUp; -X_API EXTERNAL Atom AtomSilent; -X_API EXTERNAL Term TermSilent; -X_API EXTERNAL Atom AtomSingle; -X_API EXTERNAL Term TermSingle; -X_API EXTERNAL Atom AtomSingleVarWarnings; -X_API EXTERNAL Term TermSingleVarWarnings; -X_API EXTERNAL Atom AtomSingleton; -X_API EXTERNAL Term TermSingleton; -X_API EXTERNAL Atom AtomSlash; -X_API EXTERNAL Term TermSlash; -X_API EXTERNAL Atom AtomSocket; -X_API EXTERNAL Term TermSocket; -X_API EXTERNAL Atom AtomSolutions; -X_API EXTERNAL Term TermSolutions; -X_API EXTERNAL Atom AtomSource; -X_API EXTERNAL Term TermSource; -X_API EXTERNAL Atom AtomSourceSink; -X_API EXTERNAL Term TermSourceSink; -X_API EXTERNAL Atom AtomSpy; -X_API EXTERNAL Term TermSpy; -X_API EXTERNAL Atom AtomStack; -X_API EXTERNAL Term TermStack; -X_API EXTERNAL Atom AtomStackFree; -X_API EXTERNAL Term TermStackFree; -X_API EXTERNAL Atom AtomStartupSavedState; -X_API EXTERNAL Term TermStartupSavedState; -X_API EXTERNAL Atom AtomStaticClause; -X_API EXTERNAL Term TermStaticClause; -X_API EXTERNAL Atom AtomStaticProcedure; -X_API EXTERNAL Term TermStaticProcedure; -X_API EXTERNAL Atom AtomStream; -X_API EXTERNAL Term TermStream; -X_API EXTERNAL Atom AtomSWIStream; -X_API EXTERNAL Term TermSWIStream; -X_API EXTERNAL Atom AtomVStream; -X_API EXTERNAL Term TermVStream; -X_API EXTERNAL Atom AtomStreams; -X_API EXTERNAL Term TermStreams; -X_API EXTERNAL Atom AtomStreamOrAlias; -X_API EXTERNAL Term TermStreamOrAlias; -X_API EXTERNAL Atom AtomStreamPos; -X_API EXTERNAL Term TermStreamPos; -X_API EXTERNAL Atom AtomStreamPosition; -X_API EXTERNAL Term TermStreamPosition; -X_API EXTERNAL Atom AtomString; -X_API EXTERNAL Term TermString; -X_API EXTERNAL Atom AtomStyleCheck; -X_API EXTERNAL Term TermStyleCheck; -X_API EXTERNAL Atom AtomSTRING; -X_API EXTERNAL Term TermSTRING; -X_API EXTERNAL Atom AtomSwi; -X_API EXTERNAL Term TermSwi; -X_API EXTERNAL Atom AtomSymbolChar; -X_API EXTERNAL Term TermSymbolChar; -X_API EXTERNAL Atom AtomSyntaxError; -X_API EXTERNAL Term TermSyntaxError; -X_API EXTERNAL Atom AtomSyntaxErrors; -X_API EXTERNAL Term TermSyntaxErrors; -X_API EXTERNAL Atom AtomSyntaxErrorHandler; -X_API EXTERNAL Term TermSyntaxErrorHandler; -X_API EXTERNAL Atom AtomSystem; -X_API EXTERNAL Term TermSystem; -X_API EXTERNAL Atom AtomSystemError; -X_API EXTERNAL Term TermSystemError; -X_API EXTERNAL Atom AtomSystemLibraryDir; -X_API EXTERNAL Term TermSystemLibraryDir; -X_API EXTERNAL Atom AtomT; -X_API EXTERNAL Term TermT; -X_API EXTERNAL Atom AtomTerm; -X_API EXTERNAL Term TermTerm; -X_API EXTERNAL Atom AtomTermExpansion; -X_API EXTERNAL Term TermTermExpansion; -X_API EXTERNAL Atom AtomTerms; -X_API EXTERNAL Term TermTerms; -X_API EXTERNAL Atom AtomText; -X_API EXTERNAL Term TermText; -X_API EXTERNAL Atom AtomTextStream; -X_API EXTERNAL Term TermTextStream; -X_API EXTERNAL Atom AtomThread; -X_API EXTERNAL Term TermThread; -X_API EXTERNAL Atom AtomThreads; -X_API EXTERNAL Term TermThreads; -X_API EXTERNAL Atom AtomThrow; -X_API EXTERNAL Term TermThrow; -X_API EXTERNAL Atom AtomTimeOutSpec; -X_API EXTERNAL Term TermTimeOutSpec; -X_API EXTERNAL Atom AtomTimeoutError; -X_API EXTERNAL Term TermTimeoutError; -X_API EXTERNAL Atom AtomTopLevelGoal; -X_API EXTERNAL Term TermTopLevelGoal; -X_API EXTERNAL Atom AtomTopThreadGoal; -X_API EXTERNAL Term TermTopThreadGoal; -X_API EXTERNAL Atom AtomTraceMetaCall; -X_API EXTERNAL Term TermTraceMetaCall; -X_API EXTERNAL Atom AtomTrail; -X_API EXTERNAL Atom AtomTrue; -X_API EXTERNAL Term TermTrue; -X_API EXTERNAL Atom AtomTty; -X_API EXTERNAL Term TermTty; -X_API EXTERNAL Atom AtomTtys; -X_API EXTERNAL Term TermTtys; -X_API EXTERNAL Atom AtomTuple; -X_API EXTERNAL Term TermTuple; -X_API EXTERNAL Atom AtomTxt; -X_API EXTERNAL Term TermTxt; -X_API EXTERNAL Atom AtomTypeError; -X_API EXTERNAL Term TermTypeError; -X_API EXTERNAL Atom AtomUndefined; -X_API EXTERNAL Term TermUndefined; -X_API EXTERNAL Atom AtomUndefp; -X_API EXTERNAL Term TermUndefp; -X_API EXTERNAL Atom AtomUndefp0; -X_API EXTERNAL Term TermUndefp0; -X_API EXTERNAL Atom AtomUnderflow; -X_API EXTERNAL Term TermUnderflow; -X_API EXTERNAL Atom AtomUnificationStack; -X_API EXTERNAL Term TermUnificationStack; -X_API EXTERNAL Atom AtomUnique; -X_API EXTERNAL Term TermUnique; -X_API EXTERNAL Atom AtomUnsignedByte; -X_API EXTERNAL Term TermUnsignedByte; -X_API EXTERNAL Atom AtomUnsignedChar; -X_API EXTERNAL Term TermUnsignedChar; -X_API EXTERNAL Atom AtomUser; -X_API EXTERNAL Term TermUser; -X_API EXTERNAL Atom AtomUserErr; -X_API EXTERNAL Term TermUserErr; -X_API EXTERNAL Atom AtomUserIn; -X_API EXTERNAL Term TermUserIn; -X_API EXTERNAL Atom AtomUserOut; -X_API EXTERNAL Term TermUserOut; -X_API EXTERNAL Atom AtomDollarVar; -X_API EXTERNAL Term TermDollarVar; -X_API EXTERNAL Atom AtomVBar; -X_API EXTERNAL Term TermVBar; -X_API EXTERNAL Atom AtomVarBranches; -X_API EXTERNAL Term TermVarBranches; -X_API EXTERNAL Atom AtomVariableNames; -X_API EXTERNAL Term TermVariableNames; -X_API EXTERNAL Atom AtomHiddenVar; -X_API EXTERNAL Term TermHiddenVar; -X_API EXTERNAL Atom AtomVariable; -X_API EXTERNAL Term TermVariable; -X_API EXTERNAL Atom AtomVerbose; -X_API EXTERNAL Term TermVerbose; -X_API EXTERNAL Atom AtomVerboseFileSearch; -X_API EXTERNAL Term TermVerboseFileSearch; -X_API EXTERNAL Atom AtomVersionNumber; -X_API EXTERNAL Term TermVersionNumber; -X_API EXTERNAL Atom AtomVeryVerbose; -X_API EXTERNAL Term TermVeryVerbose; -X_API EXTERNAL Atom AtomWakeUpGoal; -X_API EXTERNAL Term TermWakeUpGoal; -X_API EXTERNAL Atom AtomWarning; -X_API EXTERNAL Term TermWarning; -X_API EXTERNAL Atom AtomWhen; -X_API EXTERNAL Term TermWhen; -X_API EXTERNAL Atom AtomWrite; -X_API EXTERNAL Term TermWrite; -X_API EXTERNAL Atom AtomWriteTerm; -X_API EXTERNAL Term TermWriteTerm; -X_API EXTERNAL Atom AtomXml; -X_API EXTERNAL Term TermXml; -X_API EXTERNAL Atom AtomYapHacks; -X_API EXTERNAL Term TermYapHacks; -X_API EXTERNAL Atom AtomZeroDivisor; -X_API EXTERNAL Term TermZeroDivisor; -X_API EXTERNAL Functor FunctorAfInet; - -X_API EXTERNAL Functor FunctorAfLocal; - -X_API EXTERNAL Functor FunctorAfUnix; - -X_API EXTERNAL Functor FunctorAltNot; - -X_API EXTERNAL Functor FunctorArg; - -X_API EXTERNAL Functor FunctorArrayEntry; - -X_API EXTERNAL Functor FunctorArrow; - -X_API EXTERNAL Functor FunctorDoubleArrow; - -X_API EXTERNAL Functor FunctorAssert1; - -X_API EXTERNAL Functor FunctorAssert; - -X_API EXTERNAL Functor FunctorAtFoundOne; - -X_API EXTERNAL Functor FunctorAtom; - -X_API EXTERNAL Functor FunctorAtt1; - -X_API EXTERNAL Functor FunctorAttGoal; - -X_API EXTERNAL Functor FunctorBraces; - -X_API EXTERNAL Functor FunctorCall; - -X_API EXTERNAL Functor FunctorCatch; - -X_API EXTERNAL Functor FunctorChangeModule; - -X_API EXTERNAL Functor FunctorChars; - -X_API EXTERNAL Functor FunctorChars1; - -X_API EXTERNAL Functor FunctorCleanCall; - -X_API EXTERNAL Functor FunctorClist; - -X_API EXTERNAL Functor FunctorCodes; - -X_API EXTERNAL Functor FunctorCodes1; - -X_API EXTERNAL Functor FunctorColon; - -X_API EXTERNAL Functor FunctorComma; - -X_API EXTERNAL Functor FunctorCommentHook; - -X_API EXTERNAL Functor FunctorContext2; - -X_API EXTERNAL Functor FunctorConsistencyError; - -X_API EXTERNAL Functor FunctorCreep; - -X_API EXTERNAL Functor FunctorCsult; - -X_API EXTERNAL Functor FunctorCurrentModule; - -X_API EXTERNAL Functor FunctorCutBy; - -X_API EXTERNAL Functor FunctorDBREF; - -X_API EXTERNAL Functor FunctorDiff; - -X_API EXTERNAL Functor FunctorDoLogUpdClause; - -X_API EXTERNAL Functor FunctorDoLogUpdClause0; - -X_API EXTERNAL Functor FunctorDoLogUpdClauseErase; - -X_API EXTERNAL Functor FunctorDoStaticClause; - -X_API EXTERNAL Functor FunctorDollar; - -X_API EXTERNAL Functor FunctorDollarVar; - -X_API EXTERNAL Functor FunctorDomainError; - -X_API EXTERNAL Functor FunctorDot; - -X_API EXTERNAL Functor FunctorDot10; - -X_API EXTERNAL Functor FunctorDot11; - -X_API EXTERNAL Functor FunctorDot12; - -X_API EXTERNAL Functor FunctorDot2; - -X_API EXTERNAL Functor FunctorDot3; - -X_API EXTERNAL Functor FunctorDot4; - -X_API EXTERNAL Functor FunctorDot5; - -X_API EXTERNAL Functor FunctorDot6; - -X_API EXTERNAL Functor FunctorDot7; - -X_API EXTERNAL Functor FunctorDot8; - -X_API EXTERNAL Functor FunctorDot9; - -X_API EXTERNAL Functor FunctorDoubleArrow; - -X_API EXTERNAL Functor FunctorDoubleSlash; - -X_API EXTERNAL Functor FunctorEmptySquareBrackets; - -X_API EXTERNAL Functor FunctorEq; - -X_API EXTERNAL Functor FunctorError; - -X_API EXTERNAL Functor FunctorEvaluationError; - -X_API EXTERNAL Functor FunctorException; - -X_API EXTERNAL Functor FunctorExecute2InMod; - -X_API EXTERNAL Functor FunctorExecuteInMod; - -X_API EXTERNAL Functor FunctorExecuteWithin; - -X_API EXTERNAL Functor FunctorExistenceError; - -X_API EXTERNAL Functor FunctorExoClause; - -X_API EXTERNAL Functor FunctorFunctor; - -X_API EXTERNAL Functor FunctorGAtom; - -X_API EXTERNAL Functor FunctorGAtomic; - -X_API EXTERNAL Functor FunctorGCompound; - -X_API EXTERNAL Functor FunctorGFloat; - -X_API EXTERNAL Functor FunctorGFormatAt; - -X_API EXTERNAL Functor FunctorGInteger; - -X_API EXTERNAL Functor FunctorGNumber; - -X_API EXTERNAL Functor FunctorGPrimitive; - -X_API EXTERNAL Functor FunctorGVar; - -X_API EXTERNAL Functor FunctorGeneratePredInfo; - -X_API EXTERNAL Functor FunctorGoalExpansion2; - -X_API EXTERNAL Functor FunctorGoalExpansion; - -X_API EXTERNAL Functor FunctorHandleThrow; - -X_API EXTERNAL Functor FunctorHat; - -X_API EXTERNAL Functor FunctorI; - -X_API EXTERNAL Functor FunctorId; - -X_API EXTERNAL Functor FunctorInfo1; - -X_API EXTERNAL Functor FunctorInfo2; - -X_API EXTERNAL Functor FunctorInfo3; - -X_API EXTERNAL Functor FunctorInfo4; - -X_API EXTERNAL Functor FunctorIs; - -X_API EXTERNAL Functor FunctorJ; - -X_API EXTERNAL Functor FunctorLastExecuteWithin; - -X_API EXTERNAL Functor FunctorList; - -X_API EXTERNAL Functor FunctorLOOP; - -X_API EXTERNAL Functor FunctorMegaClause; - -X_API EXTERNAL Functor FunctorMetaCall; - -X_API EXTERNAL Functor FunctorMinus; - -X_API EXTERNAL Functor FunctorModule; - -X_API EXTERNAL Functor FunctorMultiFileClause; - -X_API EXTERNAL Functor FunctorMutable; - -X_API EXTERNAL Functor FunctorMutex; - -X_API EXTERNAL Functor FunctorNotImplemented; - -X_API EXTERNAL Functor FunctorNBQueue; - -X_API EXTERNAL Functor FunctorNot; - -X_API EXTERNAL Functor FunctorObj; - -X_API EXTERNAL Functor FunctorOr; - -X_API EXTERNAL Functor FunctorOutput; - -X_API EXTERNAL Functor FunctorPermissionError; - -X_API EXTERNAL Functor FunctorPlus; - -X_API EXTERNAL Functor FunctorPortray; - -X_API EXTERNAL Functor FunctorPrintMessage; - -X_API EXTERNAL Functor FunctorProcedure; - -X_API EXTERNAL Functor FunctorPriority; - -X_API EXTERNAL Functor FunctorPrologConstraint; - -X_API EXTERNAL Functor FunctorProtectStack; - -X_API EXTERNAL Functor FunctorQuery; - -X_API EXTERNAL Functor FunctorRecordedWithKey; - -X_API EXTERNAL Functor FunctorRDiv; - -X_API EXTERNAL Functor FunctorRedoFreeze; - -X_API EXTERNAL Functor FunctorRepresentationError; - -X_API EXTERNAL Functor FunctorResourceError; - -X_API EXTERNAL Functor FunctorRestoreRegs; - -X_API EXTERNAL Functor FunctorRestoreRegs1; - -X_API EXTERNAL Functor FunctorSafe; - -X_API EXTERNAL Functor FunctorSafeCallCleanup; - -X_API EXTERNAL Functor FunctorSame; - -X_API EXTERNAL Functor FunctorSlash; - -X_API EXTERNAL Functor FunctorStaticClause; - -X_API EXTERNAL Functor FunctorStream; - -X_API EXTERNAL Functor FunctorStreamEOS; - -X_API EXTERNAL Functor FunctorStreamPos; - -X_API EXTERNAL Functor FunctorString1; - -X_API EXTERNAL Functor FunctorStyleCheck; - -X_API EXTERNAL Functor FunctorSyntaxError; - -X_API EXTERNAL Functor FunctorShortSyntaxError; - -X_API EXTERNAL Functor FunctorTermExpansion; - -X_API EXTERNAL Functor FunctorThreadRun; - -X_API EXTERNAL Functor FunctorThrow; - -X_API EXTERNAL Functor FunctorTimeoutError; - -X_API EXTERNAL Functor FunctorTraceMetaCall; - -X_API EXTERNAL Functor FunctorTypeError; - -X_API EXTERNAL Functor FunctorUMinus; - -X_API EXTERNAL Functor FunctorUPlus; - -X_API EXTERNAL Functor FunctorVBar; - -X_API EXTERNAL Functor FunctorWriteTerm; - -X_API EXTERNAL Functor FunctorHiddenVar; + + /* This file, tatoms.h, was generated automatically by "yap -L misc/buildatoms" + {lease do not update, update misc/ATOMS instead */ + +X_API EXTERNAL Atom AtomAtSymbol; X_API EXTERNAL Term TermAtSymbol; +X_API EXTERNAL Atom Atom3Dots; +X_API EXTERNAL Atom AtomAbol; X_API EXTERNAL Term TermAbol; +X_API EXTERNAL Atom AtomAccess; X_API EXTERNAL Term TermAccess; +X_API EXTERNAL Atom AtomAfInet; X_API EXTERNAL Term TermAfInet; +X_API EXTERNAL Atom AtomAfLocal; X_API EXTERNAL Term TermAfLocal; +X_API EXTERNAL Atom AtomAfUnix; X_API EXTERNAL Term TermAfUnix; +X_API EXTERNAL Atom AtomAlarm; X_API EXTERNAL Term TermAlarm; +X_API EXTERNAL Atom AtomAlias; X_API EXTERNAL Term TermAlias; +X_API EXTERNAL Atom AtomAll; X_API EXTERNAL Term TermAll; +X_API EXTERNAL Atom AtomAltNot; X_API EXTERNAL Term TermAltNot; +X_API EXTERNAL Atom AtomAnswer; X_API EXTERNAL Term TermAnswer; +X_API EXTERNAL Atom AtomAny; X_API EXTERNAL Term TermAny; +X_API EXTERNAL Atom AtomAppend; X_API EXTERNAL Term TermAppend; +X_API EXTERNAL Atom AtomArg; X_API EXTERNAL Term TermArg; +X_API EXTERNAL Atom AtomArray; X_API EXTERNAL Term TermArray; +X_API EXTERNAL Atom AtomArrayAccess; X_API EXTERNAL Term TermArrayAccess; +X_API EXTERNAL Atom AtomArrayOverflow; X_API EXTERNAL Term TermArrayOverflow; +X_API EXTERNAL Atom AtomArrayType; X_API EXTERNAL Term TermArrayType; +X_API EXTERNAL Atom AtomArrow; X_API EXTERNAL Term TermArrow; +X_API EXTERNAL Atom AtomAttributedModule; X_API EXTERNAL Term TermAttributedModule; +X_API EXTERNAL Atom AtomDoubleArrow; X_API EXTERNAL Term TermDoubleArrow; +X_API EXTERNAL Atom AtomAssert; X_API EXTERNAL Term TermAssert; +X_API EXTERNAL Atom AtomBeginBracket; X_API EXTERNAL Term TermBeginBracket; +X_API EXTERNAL Atom AtomEndBracket; X_API EXTERNAL Term TermEndBracket; +X_API EXTERNAL Atom AtomBeginSquareBracket; X_API EXTERNAL Term TermBeginSquareBracket; +X_API EXTERNAL Atom AtomEndSquareBracket; X_API EXTERNAL Term TermEndSquareBracket; +X_API EXTERNAL Atom AtomBeginCurlyBracket; X_API EXTERNAL Term TermBeginCurlyBracket; +X_API EXTERNAL Atom AtomEndCurlyBracket; X_API EXTERNAL Term TermEndCurlyBracket; +X_API EXTERNAL Atom AtomEmptyBrackets; X_API EXTERNAL Term TermEmptyBrackets; +X_API EXTERNAL Atom AtomEmptySquareBrackets; X_API EXTERNAL Term TermEmptySquareBrackets; +X_API EXTERNAL Atom AtomAs; X_API EXTERNAL Term TermAs; +X_API EXTERNAL Atom AtomAsserta; X_API EXTERNAL Term TermAsserta; +X_API EXTERNAL Atom AtomAssertaStatic; X_API EXTERNAL Term TermAssertaStatic; +X_API EXTERNAL Atom AtomAssertz; X_API EXTERNAL Term TermAssertz; +X_API EXTERNAL Atom AtomAssertzStatic; X_API EXTERNAL Term TermAssertzStatic; +X_API EXTERNAL Atom AtomAt; X_API EXTERNAL Term TermAt; +X_API EXTERNAL Atom AtomAtom; X_API EXTERNAL Term TermAtom; +X_API EXTERNAL Atom AtomAtomic; X_API EXTERNAL Term TermAtomic; +X_API EXTERNAL Atom AtomAtt; X_API EXTERNAL Term TermAtt; +X_API EXTERNAL Atom AtomAtt1; X_API EXTERNAL Term TermAtt1; +X_API EXTERNAL Atom AtomAttDo; X_API EXTERNAL Term TermAttDo; +X_API EXTERNAL Atom AtomAttributes; X_API EXTERNAL Term TermAttributes; +X_API EXTERNAL Atom AtomB; X_API EXTERNAL Term TermB; +X_API EXTERNAL Atom AtomBatched; X_API EXTERNAL Term TermBatched; +X_API EXTERNAL Atom AtomBetween; X_API EXTERNAL Term TermBetween; +X_API EXTERNAL Atom AtomBinary; X_API EXTERNAL Term TermBinary; +X_API EXTERNAL Atom AtomBigNum; X_API EXTERNAL Term TermBigNum; +X_API EXTERNAL Atom AtomBinaryStream; X_API EXTERNAL Term TermBinaryStream; +X_API EXTERNAL Atom AtomBoolean; X_API EXTERNAL Term TermBoolean; +X_API EXTERNAL Atom AtomBraces; X_API EXTERNAL Term TermBraces; +X_API EXTERNAL Atom AtomBreak; X_API EXTERNAL Term TermBreak; +X_API EXTERNAL Atom AtomByte; X_API EXTERNAL Term TermByte; +X_API EXTERNAL Atom AtomCArith; X_API EXTERNAL Term TermCArith; +X_API EXTERNAL Atom AtomCall; X_API EXTERNAL Term TermCall; +X_API EXTERNAL Atom AtomCallAndRetryCounter; X_API EXTERNAL Term TermCallAndRetryCounter; +X_API EXTERNAL Atom AtomCallCounter; X_API EXTERNAL Term TermCallCounter; +X_API EXTERNAL Atom AtomCallable; X_API EXTERNAL Term TermCallable; +X_API EXTERNAL Atom AtomCatch; X_API EXTERNAL Term TermCatch; +X_API EXTERNAL Atom AtomChangeModule; X_API EXTERNAL Term TermChangeModule; +X_API EXTERNAL Atom AtomChar; X_API EXTERNAL Term TermChar; +X_API EXTERNAL Atom AtomCharsio; X_API EXTERNAL Term TermCharsio; +X_API EXTERNAL Atom AtomCharacter; X_API EXTERNAL Term TermCharacter; +X_API EXTERNAL Atom AtomCharacterCode; X_API EXTERNAL Term TermCharacterCode; +X_API EXTERNAL Atom AtomChars; X_API EXTERNAL Term TermChars; +X_API EXTERNAL Atom AtomCharset; X_API EXTERNAL Term TermCharset; +X_API EXTERNAL Atom AtomChType; X_API EXTERNAL Term TermChType; +X_API EXTERNAL Atom AtomCleanCall; X_API EXTERNAL Term TermCleanCall; +X_API EXTERNAL Atom AtomClose; X_API EXTERNAL Term TermClose; +X_API EXTERNAL Atom AtomColon; X_API EXTERNAL Term TermColon; +X_API EXTERNAL Atom AtomCodeSpace; X_API EXTERNAL Term TermCodeSpace; +X_API EXTERNAL Atom AtomCodes; X_API EXTERNAL Term TermCodes; +X_API EXTERNAL Atom AtomCoInductive; X_API EXTERNAL Term TermCoInductive; +X_API EXTERNAL Atom AtomComma; X_API EXTERNAL Term TermComma; +X_API EXTERNAL Atom AtomCommentHook; X_API EXTERNAL Term TermCommentHook; +X_API EXTERNAL Atom AtomCompact; X_API EXTERNAL Term TermCompact; +X_API EXTERNAL Atom AtomCompound; X_API EXTERNAL Term TermCompound; +X_API EXTERNAL Atom AtomConsistencyError; X_API EXTERNAL Term TermConsistencyError; +X_API EXTERNAL Atom AtomConsult; X_API EXTERNAL Term TermConsult; +X_API EXTERNAL Atom AtomConsultOnBoot; X_API EXTERNAL Term TermConsultOnBoot; +X_API EXTERNAL Atom AtomContext; X_API EXTERNAL Term TermContext; +X_API EXTERNAL Atom AtomCputime; X_API EXTERNAL Term TermCputime; +X_API EXTERNAL Atom AtomCreate; X_API EXTERNAL Term TermCreate; +X_API EXTERNAL Atom AtomCreep; X_API EXTERNAL Term TermCreep; +X_API EXTERNAL Atom AtomCryptAtoms; X_API EXTERNAL Term TermCryptAtoms; +X_API EXTERNAL Atom AtomCurly; X_API EXTERNAL Term TermCurly; +X_API EXTERNAL Atom AtomCsult; X_API EXTERNAL Term TermCsult; +X_API EXTERNAL Atom AtomCurrentModule; X_API EXTERNAL Term TermCurrentModule; +X_API EXTERNAL Atom AtomCut; X_API EXTERNAL Term TermCut; +X_API EXTERNAL Atom AtomCutBy; X_API EXTERNAL Term TermCutBy; +X_API EXTERNAL Atom AtomDAbort; X_API EXTERNAL Term TermDAbort; +X_API EXTERNAL Atom AtomDBLoad; X_API EXTERNAL Term TermDBLoad; +X_API EXTERNAL Atom AtomDBREF; X_API EXTERNAL Term TermDBREF; +X_API EXTERNAL Atom AtomDBReference; X_API EXTERNAL Term TermDBReference; +X_API EXTERNAL Atom AtomDBTerm; X_API EXTERNAL Term TermDBTerm; +X_API EXTERNAL Atom AtomDBref; X_API EXTERNAL Term TermDBref; +X_API EXTERNAL Atom AtomDInteger; X_API EXTERNAL Term TermDInteger; +X_API EXTERNAL Atom AtomDebugMeta; X_API EXTERNAL Term TermDebugMeta; +X_API EXTERNAL Atom AtomDebuggerInput; X_API EXTERNAL Term TermDebuggerInput; +X_API EXTERNAL Atom AtomDec10; X_API EXTERNAL Term TermDec10; +X_API EXTERNAL Atom AtomDefault; X_API EXTERNAL Term TermDefault; +X_API EXTERNAL Atom AtomDevNull; X_API EXTERNAL Term TermDevNull; +X_API EXTERNAL Atom AtomDiff; X_API EXTERNAL Term TermDiff; +X_API EXTERNAL Atom AtomDirectory; X_API EXTERNAL Term TermDirectory; +X_API EXTERNAL Atom AtomDiscontiguous; X_API EXTERNAL Term TermDiscontiguous; +X_API EXTERNAL Atom AtomDiscontiguousWarnings; X_API EXTERNAL Term TermDiscontiguousWarnings; +X_API EXTERNAL Atom AtomDollar; X_API EXTERNAL Term TermDollar; +X_API EXTERNAL Atom AtomDoLogUpdClause; X_API EXTERNAL Term TermDoLogUpdClause; +X_API EXTERNAL Atom AtomDoLogUpdClause0; X_API EXTERNAL Term TermDoLogUpdClause0; +X_API EXTERNAL Atom AtomDoLogUpdClauseErase; X_API EXTERNAL Term TermDoLogUpdClauseErase; +X_API EXTERNAL Atom AtomDollarU; X_API EXTERNAL Term TermDollarU; +X_API EXTERNAL Atom AtomDollarUndef; X_API EXTERNAL Term TermDollarUndef; +X_API EXTERNAL Atom AtomDomainError; X_API EXTERNAL Term TermDomainError; +X_API EXTERNAL Atom AtomDoStaticClause; X_API EXTERNAL Term TermDoStaticClause; +X_API EXTERNAL Atom AtomDots; X_API EXTERNAL Term TermDots; +X_API EXTERNAL Atom AtomDOUBLE; X_API EXTERNAL Term TermDOUBLE; +X_API EXTERNAL Atom AtomDoubleSlash; X_API EXTERNAL Term TermDoubleSlash; +X_API EXTERNAL Atom AtomE; X_API EXTERNAL Term TermE; +X_API EXTERNAL Atom AtomEOFBeforeEOT; X_API EXTERNAL Term TermEOFBeforeEOT; +X_API EXTERNAL Atom AtomEQ; X_API EXTERNAL Term TermEQ; +X_API EXTERNAL Atom AtomEmptyAtom; X_API EXTERNAL Term TermEmptyAtom; +X_API EXTERNAL Atom AtomEncoding; X_API EXTERNAL Term TermEncoding; +X_API EXTERNAL Atom AtomEndOfStream; X_API EXTERNAL Term TermEndOfStream; +X_API EXTERNAL Atom AtomEof; X_API EXTERNAL Term TermEof; +X_API EXTERNAL Atom AtomEOfCode; X_API EXTERNAL Term TermEOfCode; +X_API EXTERNAL Atom AtomEq; X_API EXTERNAL Term TermEq; +X_API EXTERNAL Atom AtomError; X_API EXTERNAL Term TermError; +X_API EXTERNAL Atom AtomException; X_API EXTERNAL Term TermException; +X_API EXTERNAL Atom AtomExtensions; X_API EXTERNAL Term TermExtensions; +X_API EXTERNAL Atom AtomExternalException; X_API EXTERNAL Term TermExternalException; +X_API EXTERNAL Atom AtomEvaluable; X_API EXTERNAL Term TermEvaluable; +X_API EXTERNAL Atom AtomEvaluationError; X_API EXTERNAL Term TermEvaluationError; +X_API EXTERNAL Atom AtomExecutable; X_API EXTERNAL Term TermExecutable; +X_API EXTERNAL Atom AtomExecute; X_API EXTERNAL Term TermExecute; +X_API EXTERNAL Atom AtomExecAnswers; X_API EXTERNAL Term TermExecAnswers; +X_API EXTERNAL Atom AtomExecuteInMod; X_API EXTERNAL Term TermExecuteInMod; +X_API EXTERNAL Atom AtomExecuteWithin; X_API EXTERNAL Term TermExecuteWithin; +X_API EXTERNAL Atom AtomExecuteWoMod; X_API EXTERNAL Term TermExecuteWoMod; +X_API EXTERNAL Atom AtomExist; X_API EXTERNAL Term TermExist; +X_API EXTERNAL Atom AtomExists; X_API EXTERNAL Term TermExists; +X_API EXTERNAL Atom AtomExit; X_API EXTERNAL Term TermExit; +X_API EXTERNAL Atom AtomExistenceError; X_API EXTERNAL Term TermExistenceError; +X_API EXTERNAL Atom AtomExoClause; X_API EXTERNAL Term TermExoClause; +X_API EXTERNAL Atom AtomExpectedNumber; X_API EXTERNAL Term TermExpectedNumber; +X_API EXTERNAL Atom AtomExpand; X_API EXTERNAL Term TermExpand; +X_API EXTERNAL Atom AtomExtendFileSearchPath; X_API EXTERNAL Term TermExtendFileSearchPath; +X_API EXTERNAL Atom AtomExtendsions; X_API EXTERNAL Term TermExtendsions; +X_API EXTERNAL Atom AtomFB; X_API EXTERNAL Term TermFB; +X_API EXTERNAL Atom AtomFail; X_API EXTERNAL Term TermFail; +X_API EXTERNAL Atom AtomFalse; X_API EXTERNAL Term TermFalse; +X_API EXTERNAL Atom AtomFast; X_API EXTERNAL Term TermFast; +X_API EXTERNAL Atom AtomFastFail; X_API EXTERNAL Term TermFastFail; +X_API EXTERNAL Atom AtomFileErrors; X_API EXTERNAL Term TermFileErrors; +X_API EXTERNAL Atom AtomFileerrors; X_API EXTERNAL Term TermFileerrors; +X_API EXTERNAL Atom AtomFileType; X_API EXTERNAL Term TermFileType; +X_API EXTERNAL Atom AtomFirst; X_API EXTERNAL Term TermFirst; +X_API EXTERNAL Atom AtomFloat; X_API EXTERNAL Term TermFloat; +X_API EXTERNAL Atom AtomFloatFormat; X_API EXTERNAL Term TermFloatFormat; +X_API EXTERNAL Atom AtomFloatOverflow; X_API EXTERNAL Term TermFloatOverflow; +X_API EXTERNAL Atom AtomFloatUnderflow; X_API EXTERNAL Term TermFloatUnderflow; +X_API EXTERNAL Atom AtomFormat; X_API EXTERNAL Term TermFormat; +X_API EXTERNAL Atom AtomFormatAt; X_API EXTERNAL Term TermFormatAt; +X_API EXTERNAL Atom AtomFull; X_API EXTERNAL Term TermFull; +X_API EXTERNAL Atom AtomFunctor; X_API EXTERNAL Term TermFunctor; +X_API EXTERNAL Atom AtomGT; X_API EXTERNAL Term TermGT; +X_API EXTERNAL Atom AtomGVar; X_API EXTERNAL Term TermGVar; +X_API EXTERNAL Atom Atomg; X_API EXTERNAL Term Termg; +X_API EXTERNAL Atom AtomGc; X_API EXTERNAL Term TermGc; +X_API EXTERNAL Atom AtomGcMargin; X_API EXTERNAL Term TermGcMargin; +X_API EXTERNAL Atom AtomGcTrace; X_API EXTERNAL Term TermGcTrace; +X_API EXTERNAL Atom AtomGcVerbose; X_API EXTERNAL Term TermGcVerbose; +X_API EXTERNAL Atom AtomGcVeryVerbose; X_API EXTERNAL Term TermGcVeryVerbose; +X_API EXTERNAL Atom AtomGeneratePredInfo; X_API EXTERNAL Term TermGeneratePredInfo; +X_API EXTERNAL Atom AtomGetwork; X_API EXTERNAL Term TermGetwork; +X_API EXTERNAL Atom AtomGetworkSeq; X_API EXTERNAL Term TermGetworkSeq; +X_API EXTERNAL Atom AtomGlob; X_API EXTERNAL Term TermGlob; +X_API EXTERNAL Atom AtomGlobal; X_API EXTERNAL Term TermGlobal; +X_API EXTERNAL Atom AtomGlobalSp; X_API EXTERNAL Term TermGlobalSp; +X_API EXTERNAL Atom AtomGlobalTrie; X_API EXTERNAL Term TermGlobalTrie; +X_API EXTERNAL Atom AtomGoalExpansion; X_API EXTERNAL Term TermGoalExpansion; +X_API EXTERNAL Atom AtomHat; X_API EXTERNAL Term TermHat; +X_API EXTERNAL Atom AtomDoubleHat; X_API EXTERNAL Term TermDoubleHat; +X_API EXTERNAL Atom AtomHERE; X_API EXTERNAL Term TermHERE; +X_API EXTERNAL Atom AtomHandleThrow; X_API EXTERNAL Term TermHandleThrow; +X_API EXTERNAL Atom AtomHeap; X_API EXTERNAL Term TermHeap; +X_API EXTERNAL Atom AtomHeapUsed; X_API EXTERNAL Term TermHeapUsed; +X_API EXTERNAL Atom AtomHugeInt; X_API EXTERNAL Term TermHugeInt; +X_API EXTERNAL Atom AtomIDB; X_API EXTERNAL Term TermIDB; +X_API EXTERNAL Atom AtomIOMode; X_API EXTERNAL Term TermIOMode; +X_API EXTERNAL Atom AtomI; X_API EXTERNAL Term TermI; +X_API EXTERNAL Atom AtomId; X_API EXTERNAL Term TermId; +X_API EXTERNAL Atom AtomIgnore; X_API EXTERNAL Term TermIgnore; +X_API EXTERNAL Atom AtomInf; X_API EXTERNAL Term TermInf; +X_API EXTERNAL Atom AtomInfinity; X_API EXTERNAL Term TermInfinity; +X_API EXTERNAL Atom AtomInfo; X_API EXTERNAL Term TermInfo; +X_API EXTERNAL Atom AtomInitGoal; X_API EXTERNAL Term TermInitGoal; +X_API EXTERNAL Atom AtomInitProlog; X_API EXTERNAL Term TermInitProlog; +X_API EXTERNAL Atom AtomInStackExpansion; X_API EXTERNAL Term TermInStackExpansion; +X_API EXTERNAL Atom AtomInput; X_API EXTERNAL Term TermInput; +X_API EXTERNAL Atom AtomInstantiationError; X_API EXTERNAL Term TermInstantiationError; +X_API EXTERNAL Atom AtomInt; X_API EXTERNAL Term TermInt; +X_API EXTERNAL Atom AtomIntOverflow; X_API EXTERNAL Term TermIntOverflow; +X_API EXTERNAL Atom AtomInteger; X_API EXTERNAL Term TermInteger; +X_API EXTERNAL Atom AtomInternalCompilerError; X_API EXTERNAL Term TermInternalCompilerError; +X_API EXTERNAL Atom AtomIs; X_API EXTERNAL Term TermIs; +X_API EXTERNAL Atom AtomJ; X_API EXTERNAL Term TermJ; +X_API EXTERNAL Atom Atoml; X_API EXTERNAL Term Terml; +X_API EXTERNAL Atom AtomKey; X_API EXTERNAL Term TermKey; +X_API EXTERNAL Atom AtomLDLibraryPath; X_API EXTERNAL Term TermLDLibraryPath; +X_API EXTERNAL Atom AtomLONGINT; X_API EXTERNAL Term TermLONGINT; +X_API EXTERNAL Atom AtomLOOP; X_API EXTERNAL Term TermLOOP; +X_API EXTERNAL Atom AtomLoopStream; X_API EXTERNAL Term TermLoopStream; +X_API EXTERNAL Atom AtomLT; X_API EXTERNAL Term TermLT; +X_API EXTERNAL Atom AtomLastExecuteWithin; X_API EXTERNAL Term TermLastExecuteWithin; +X_API EXTERNAL Atom AtomLeash; X_API EXTERNAL Term TermLeash; +X_API EXTERNAL Atom AtomLeast; X_API EXTERNAL Term TermLeast; +X_API EXTERNAL Atom AtomLength; X_API EXTERNAL Term TermLength; +X_API EXTERNAL Atom AtomList; X_API EXTERNAL Term TermList; +X_API EXTERNAL Atom AtomLine; X_API EXTERNAL Term TermLine; +X_API EXTERNAL Atom AtomLive; X_API EXTERNAL Term TermLive; +X_API EXTERNAL Atom AtomLoadAnswers; X_API EXTERNAL Term TermLoadAnswers; +X_API EXTERNAL Atom AtomLocal; X_API EXTERNAL Term TermLocal; +X_API EXTERNAL Atom AtomLocalSp; X_API EXTERNAL Term TermLocalSp; +X_API EXTERNAL Atom AtomLocalTrie; X_API EXTERNAL Term TermLocalTrie; +X_API EXTERNAL Atom AtomMax; X_API EXTERNAL Term TermMax; +X_API EXTERNAL Atom AtomMaximum; X_API EXTERNAL Term TermMaximum; +X_API EXTERNAL Atom AtomMaxArity; X_API EXTERNAL Term TermMaxArity; +X_API EXTERNAL Atom AtomMaxFiles; X_API EXTERNAL Term TermMaxFiles; +X_API EXTERNAL Atom AtomMegaClause; X_API EXTERNAL Term TermMegaClause; +X_API EXTERNAL Atom AtomMetaCall; X_API EXTERNAL Term TermMetaCall; +X_API EXTERNAL Atom AtomMfClause; X_API EXTERNAL Term TermMfClause; +X_API EXTERNAL Atom AtomMin; X_API EXTERNAL Term TermMin; +X_API EXTERNAL Atom AtomMinimum; X_API EXTERNAL Term TermMinimum; +X_API EXTERNAL Atom AtomMinus; X_API EXTERNAL Term TermMinus; +X_API EXTERNAL Atom AtomModify; X_API EXTERNAL Term TermModify; +X_API EXTERNAL Atom AtomModule; X_API EXTERNAL Term TermModule; +X_API EXTERNAL Atom AtomMost; X_API EXTERNAL Term TermMost; +X_API EXTERNAL Atom AtomMulti; X_API EXTERNAL Term TermMulti; +X_API EXTERNAL Atom AtomMultiFile; X_API EXTERNAL Term TermMultiFile; +X_API EXTERNAL Atom AtomMultiple; X_API EXTERNAL Term TermMultiple; +X_API EXTERNAL Atom AtomMutable; X_API EXTERNAL Term TermMutable; +X_API EXTERNAL Atom AtomMutableVariable; X_API EXTERNAL Term TermMutableVariable; +X_API EXTERNAL Atom AtomMutex; X_API EXTERNAL Term TermMutex; +X_API EXTERNAL Atom AtomMyddasDB; X_API EXTERNAL Term TermMyddasDB; +X_API EXTERNAL Atom AtomMyddasGoal; X_API EXTERNAL Term TermMyddasGoal; +X_API EXTERNAL Atom AtomMyddasHost; X_API EXTERNAL Term TermMyddasHost; +X_API EXTERNAL Atom AtomMyddasPass; X_API EXTERNAL Term TermMyddasPass; +X_API EXTERNAL Atom AtomMyddasUser; X_API EXTERNAL Term TermMyddasUser; +X_API EXTERNAL Atom AtomMyddasVersionName; X_API EXTERNAL Term TermMyddasVersionName; +X_API EXTERNAL Atom AtomNan; X_API EXTERNAL Term TermNan; +X_API EXTERNAL Atom AtomNb; X_API EXTERNAL Term TermNb; +X_API EXTERNAL Atom AtomNbTerm; X_API EXTERNAL Term TermNbTerm; +X_API EXTERNAL Atom AtomNew; X_API EXTERNAL Term TermNew; +X_API EXTERNAL Atom AtomNewLine; X_API EXTERNAL Term TermNewLine; +X_API EXTERNAL Atom AtomNl; X_API EXTERNAL Term TermNl; +X_API EXTERNAL Atom AtomNoEffect; X_API EXTERNAL Term TermNoEffect; +X_API EXTERNAL Atom AtomNoMemory; X_API EXTERNAL Term TermNoMemory; +X_API EXTERNAL Atom AtomNone; X_API EXTERNAL Term TermNone; +X_API EXTERNAL Atom AtomNonEmptyList; X_API EXTERNAL Term TermNonEmptyList; +X_API EXTERNAL Atom AtomNot; X_API EXTERNAL Term TermNot; +X_API EXTERNAL Atom AtomNotImplemented; X_API EXTERNAL Term TermNotImplemented; +X_API EXTERNAL Atom AtomNotLessThanZero; X_API EXTERNAL Term TermNotLessThanZero; +X_API EXTERNAL Atom AtomNotNewline; X_API EXTERNAL Term TermNotNewline; +X_API EXTERNAL Atom AtomNotZero; X_API EXTERNAL Term TermNotZero; +X_API EXTERNAL Atom AtomNumber; X_API EXTERNAL Term TermNumber; +X_API EXTERNAL Atom AtomObj; X_API EXTERNAL Term TermObj; +X_API EXTERNAL Atom AtomOff; X_API EXTERNAL Term TermOff; +X_API EXTERNAL Atom AtomOffline; X_API EXTERNAL Term TermOffline; +X_API EXTERNAL Atom AtomOn; X_API EXTERNAL Term TermOn; +X_API EXTERNAL Atom AtomOnline; X_API EXTERNAL Term TermOnline; +X_API EXTERNAL Atom AtomOpen; X_API EXTERNAL Term TermOpen; +X_API EXTERNAL Atom AtomOperatingSystemError; X_API EXTERNAL Term TermOperatingSystemError; +X_API EXTERNAL Atom AtomOperatingSystemSupport; X_API EXTERNAL Term TermOperatingSystemSupport; +X_API EXTERNAL Atom AtomOperator; X_API EXTERNAL Term TermOperator; +X_API EXTERNAL Atom AtomOperatorPriority; X_API EXTERNAL Term TermOperatorPriority; +X_API EXTERNAL Atom AtomOperatorSpecifier; X_API EXTERNAL Term TermOperatorSpecifier; +X_API EXTERNAL Atom AtomOpt; X_API EXTERNAL Term TermOpt; +X_API EXTERNAL Atom AtomOtherwise; X_API EXTERNAL Term TermOtherwise; +X_API EXTERNAL Atom AtomOutOfAttvarsError; X_API EXTERNAL Term TermOutOfAttvarsError; +X_API EXTERNAL Atom AtomOutOfAuxspaceError; X_API EXTERNAL Term TermOutOfAuxspaceError; +X_API EXTERNAL Atom AtomOutOfHeapError; X_API EXTERNAL Term TermOutOfHeapError; +X_API EXTERNAL Atom AtomOutOfRange; X_API EXTERNAL Term TermOutOfRange; +X_API EXTERNAL Atom AtomOutOfStackError; X_API EXTERNAL Term TermOutOfStackError; +X_API EXTERNAL Atom AtomOutOfTrailError; X_API EXTERNAL Term TermOutOfTrailError; +X_API EXTERNAL Atom AtomOutput; X_API EXTERNAL Term TermOutput; +X_API EXTERNAL Atom AtomParameter; X_API EXTERNAL Term TermParameter; +X_API EXTERNAL Atom AtomPast; X_API EXTERNAL Term TermPast; +X_API EXTERNAL Atom AtomPastEndOfStream; X_API EXTERNAL Term TermPastEndOfStream; +X_API EXTERNAL Atom AtomPermissionError; X_API EXTERNAL Term TermPermissionError; +X_API EXTERNAL Atom AtomPi; X_API EXTERNAL Term TermPi; +X_API EXTERNAL Atom AtomPipe; X_API EXTERNAL Term TermPipe; +X_API EXTERNAL Atom AtomPriority; X_API EXTERNAL Term TermPriority; +X_API EXTERNAL Atom AtomPlus; X_API EXTERNAL Term TermPlus; +X_API EXTERNAL Atom AtomPointer; X_API EXTERNAL Term TermPointer; +X_API EXTERNAL Atom AtomPopen; X_API EXTERNAL Term TermPopen; +X_API EXTERNAL Atom AtomPortray; X_API EXTERNAL Term TermPortray; +X_API EXTERNAL Atom AtomPredicateIndicator; X_API EXTERNAL Term TermPredicateIndicator; +X_API EXTERNAL Atom AtomPrimitive; X_API EXTERNAL Term TermPrimitive; +X_API EXTERNAL Atom AtomPrintMessage; X_API EXTERNAL Term TermPrintMessage; +X_API EXTERNAL Atom AtomPrivateProcedure; X_API EXTERNAL Term TermPrivateProcedure; +X_API EXTERNAL Atom AtomProcedure; X_API EXTERNAL Term TermProcedure; +X_API EXTERNAL Atom AtomProfile; X_API EXTERNAL Term TermProfile; +X_API EXTERNAL Atom AtomProlog; X_API EXTERNAL Term TermProlog; +X_API EXTERNAL Atom AtomPrologCommonsDir; X_API EXTERNAL Term TermPrologCommonsDir; +X_API EXTERNAL Atom AtomProtectStack; X_API EXTERNAL Term TermProtectStack; +X_API EXTERNAL Atom AtomQly; X_API EXTERNAL Term TermQly; +X_API EXTERNAL Atom AtomQuery; X_API EXTERNAL Term TermQuery; +X_API EXTERNAL Atom AtomQueue; X_API EXTERNAL Term TermQueue; +X_API EXTERNAL Atom AtomQuiet; X_API EXTERNAL Term TermQuiet; +X_API EXTERNAL Atom AtomRadix; X_API EXTERNAL Term TermRadix; +X_API EXTERNAL Atom AtomRandom; X_API EXTERNAL Term TermRandom; +X_API EXTERNAL Atom AtomRange; X_API EXTERNAL Term TermRange; +X_API EXTERNAL Atom AtomRDiv; X_API EXTERNAL Term TermRDiv; +X_API EXTERNAL Atom AtomRead; X_API EXTERNAL Term TermRead; +X_API EXTERNAL Atom AtomReadOnly; X_API EXTERNAL Term TermReadOnly; +X_API EXTERNAL Atom AtomReadWrite; X_API EXTERNAL Term TermReadWrite; +X_API EXTERNAL Atom AtomReadutil; X_API EXTERNAL Term TermReadutil; +X_API EXTERNAL Atom AtomReconsult; X_API EXTERNAL Term TermReconsult; +X_API EXTERNAL Atom AtomRecordedP; X_API EXTERNAL Term TermRecordedP; +X_API EXTERNAL Atom AtomRecordedWithKey; X_API EXTERNAL Term TermRecordedWithKey; +X_API EXTERNAL Atom AtomRedefineWarnings; X_API EXTERNAL Term TermRedefineWarnings; +X_API EXTERNAL Atom AtomRedo; X_API EXTERNAL Term TermRedo; +X_API EXTERNAL Atom AtomRedoFreeze; X_API EXTERNAL Term TermRedoFreeze; +X_API EXTERNAL Atom AtomRefoundVar; X_API EXTERNAL Term TermRefoundVar; +X_API EXTERNAL Atom AtomRelativeTo; X_API EXTERNAL Term TermRelativeTo; +X_API EXTERNAL Atom AtomRepeat; X_API EXTERNAL Term TermRepeat; +X_API EXTERNAL Atom AtomRepeatSpace; X_API EXTERNAL Term TermRepeatSpace; +X_API EXTERNAL Atom AtomReposition; X_API EXTERNAL Term TermReposition; +X_API EXTERNAL Atom AtomRepresentationError; X_API EXTERNAL Term TermRepresentationError; +X_API EXTERNAL Atom AtomReset; X_API EXTERNAL Term TermReset; +X_API EXTERNAL Atom AtomResize; X_API EXTERNAL Term TermResize; +X_API EXTERNAL Atom AtomResourceError; X_API EXTERNAL Term TermResourceError; +X_API EXTERNAL Atom AtomRestoreRegs; X_API EXTERNAL Term TermRestoreRegs; +X_API EXTERNAL Atom AtomRetry; X_API EXTERNAL Term TermRetry; +X_API EXTERNAL Atom AtomRetryCounter; X_API EXTERNAL Term TermRetryCounter; +X_API EXTERNAL Atom AtomRTree; X_API EXTERNAL Term TermRTree; +X_API EXTERNAL Atom AtomSafe; X_API EXTERNAL Term TermSafe; +X_API EXTERNAL Atom AtomSafeCallCleanup; X_API EXTERNAL Term TermSafeCallCleanup; +X_API EXTERNAL Atom AtomSame; X_API EXTERNAL Term TermSame; +X_API EXTERNAL Atom AtomSemic; X_API EXTERNAL Term TermSemic; +X_API EXTERNAL Atom AtomShiftCountOverflow; X_API EXTERNAL Term TermShiftCountOverflow; +X_API EXTERNAL Atom AtomSigAlarm; X_API EXTERNAL Term TermSigAlarm; +X_API EXTERNAL Atom AtomSigBreak; X_API EXTERNAL Term TermSigBreak; +X_API EXTERNAL Atom AtomSigCreep; X_API EXTERNAL Term TermSigCreep; +X_API EXTERNAL Atom AtomSigDebug; X_API EXTERNAL Term TermSigDebug; +X_API EXTERNAL Atom AtomSigDelayCreep; X_API EXTERNAL Term TermSigDelayCreep; +X_API EXTERNAL Atom AtomSigFPE; X_API EXTERNAL Term TermSigFPE; +X_API EXTERNAL Atom AtomSigHup; X_API EXTERNAL Term TermSigHup; +X_API EXTERNAL Atom AtomSigInt; X_API EXTERNAL Term TermSigInt; +X_API EXTERNAL Atom AtomSigIti; X_API EXTERNAL Term TermSigIti; +X_API EXTERNAL Atom AtomSigPending; X_API EXTERNAL Term TermSigPending; +X_API EXTERNAL Atom AtomSigPipe; X_API EXTERNAL Term TermSigPipe; +X_API EXTERNAL Atom AtomSigStackDump; X_API EXTERNAL Term TermSigStackDump; +X_API EXTERNAL Atom AtomSigStatistics; X_API EXTERNAL Term TermSigStatistics; +X_API EXTERNAL Atom AtomSigTrace; X_API EXTERNAL Term TermSigTrace; +X_API EXTERNAL Atom AtomSigUsr1; X_API EXTERNAL Term TermSigUsr1; +X_API EXTERNAL Atom AtomSigUsr2; X_API EXTERNAL Term TermSigUsr2; +X_API EXTERNAL Atom AtomSigVTAlarm; X_API EXTERNAL Term TermSigVTAlarm; +X_API EXTERNAL Atom AtomSigWakeUp; X_API EXTERNAL Term TermSigWakeUp; +X_API EXTERNAL Atom AtomSilent; X_API EXTERNAL Term TermSilent; +X_API EXTERNAL Atom AtomSingle; X_API EXTERNAL Term TermSingle; +X_API EXTERNAL Atom AtomSingleVarWarnings; X_API EXTERNAL Term TermSingleVarWarnings; +X_API EXTERNAL Atom AtomSingleton; X_API EXTERNAL Term TermSingleton; +X_API EXTERNAL Atom AtomSlash; X_API EXTERNAL Term TermSlash; +X_API EXTERNAL Atom AtomSocket; X_API EXTERNAL Term TermSocket; +X_API EXTERNAL Atom AtomSolutions; X_API EXTERNAL Term TermSolutions; +X_API EXTERNAL Atom AtomSource; X_API EXTERNAL Term TermSource; +X_API EXTERNAL Atom AtomSourceSink; X_API EXTERNAL Term TermSourceSink; +X_API EXTERNAL Atom AtomSpy; X_API EXTERNAL Term TermSpy; +X_API EXTERNAL Atom AtomStack; X_API EXTERNAL Term TermStack; +X_API EXTERNAL Atom AtomStackFree; X_API EXTERNAL Term TermStackFree; +X_API EXTERNAL Atom AtomStartupSavedState; X_API EXTERNAL Term TermStartupSavedState; +X_API EXTERNAL Atom AtomStaticClause; X_API EXTERNAL Term TermStaticClause; +X_API EXTERNAL Atom AtomStaticProcedure; X_API EXTERNAL Term TermStaticProcedure; +X_API EXTERNAL Atom AtomStream; X_API EXTERNAL Term TermStream; +X_API EXTERNAL Atom AtomSWIStream; X_API EXTERNAL Term TermSWIStream; +X_API EXTERNAL Atom AtomVStream; X_API EXTERNAL Term TermVStream; +X_API EXTERNAL Atom AtomStreams; X_API EXTERNAL Term TermStreams; +X_API EXTERNAL Atom AtomStreamOrAlias; X_API EXTERNAL Term TermStreamOrAlias; +X_API EXTERNAL Atom AtomStreamPos; X_API EXTERNAL Term TermStreamPos; +X_API EXTERNAL Atom AtomStreamPosition; X_API EXTERNAL Term TermStreamPosition; +X_API EXTERNAL Atom AtomString; X_API EXTERNAL Term TermString; +X_API EXTERNAL Atom AtomStyleCheck; X_API EXTERNAL Term TermStyleCheck; +X_API EXTERNAL Atom AtomSTRING; X_API EXTERNAL Term TermSTRING; +X_API EXTERNAL Atom AtomSwi; X_API EXTERNAL Term TermSwi; +X_API EXTERNAL Atom AtomSymbolChar; X_API EXTERNAL Term TermSymbolChar; +X_API EXTERNAL Atom AtomSyntaxError; X_API EXTERNAL Term TermSyntaxError; +X_API EXTERNAL Atom AtomSyntaxErrors; X_API EXTERNAL Term TermSyntaxErrors; +X_API EXTERNAL Atom AtomSyntaxErrorHandler; X_API EXTERNAL Term TermSyntaxErrorHandler; +X_API EXTERNAL Atom AtomSystem; X_API EXTERNAL Term TermSystem; +X_API EXTERNAL Atom AtomSystemError; X_API EXTERNAL Term TermSystemError; +X_API EXTERNAL Atom AtomSystemLibraryDir; X_API EXTERNAL Term TermSystemLibraryDir; +X_API EXTERNAL Atom AtomT; X_API EXTERNAL Term TermT; +X_API EXTERNAL Atom AtomTerm; X_API EXTERNAL Term TermTerm; +X_API EXTERNAL Atom AtomTermExpansion; X_API EXTERNAL Term TermTermExpansion; +X_API EXTERNAL Atom AtomTermPosition; X_API EXTERNAL Term TermTermPosition; +X_API EXTERNAL Atom AtomTerms; X_API EXTERNAL Term TermTerms; +X_API EXTERNAL Atom AtomText; X_API EXTERNAL Term TermText; +X_API EXTERNAL Atom AtomTextStream; X_API EXTERNAL Term TermTextStream; +X_API EXTERNAL Atom AtomThread; X_API EXTERNAL Term TermThread; +X_API EXTERNAL Atom AtomThreads; X_API EXTERNAL Term TermThreads; +X_API EXTERNAL Atom AtomThrow; X_API EXTERNAL Term TermThrow; +X_API EXTERNAL Atom AtomTimeOutSpec; X_API EXTERNAL Term TermTimeOutSpec; +X_API EXTERNAL Atom AtomTimeoutError; X_API EXTERNAL Term TermTimeoutError; +X_API EXTERNAL Atom AtomTopLevelGoal; X_API EXTERNAL Term TermTopLevelGoal; +X_API EXTERNAL Atom AtomTopThreadGoal; X_API EXTERNAL Term TermTopThreadGoal; +X_API EXTERNAL Atom AtomTraceMetaCall; X_API EXTERNAL Term TermTraceMetaCall; +X_API EXTERNAL Atom AtomTrail; +X_API EXTERNAL Atom AtomTrue; X_API EXTERNAL Term TermTrue; +X_API EXTERNAL Atom AtomTty; X_API EXTERNAL Term TermTty; +X_API EXTERNAL Atom AtomTtys; X_API EXTERNAL Term TermTtys; +X_API EXTERNAL Atom AtomTuple; X_API EXTERNAL Term TermTuple; +X_API EXTERNAL Atom AtomTxt; X_API EXTERNAL Term TermTxt; +X_API EXTERNAL Atom AtomTypeError; X_API EXTERNAL Term TermTypeError; +X_API EXTERNAL Atom AtomUndefined; X_API EXTERNAL Term TermUndefined; +X_API EXTERNAL Atom AtomUndefinedQuery; X_API EXTERNAL Term TermUndefinedQuery; +X_API EXTERNAL Atom AtomUndefp; X_API EXTERNAL Term TermUndefp; +X_API EXTERNAL Atom AtomUndefp0; X_API EXTERNAL Term TermUndefp0; +X_API EXTERNAL Atom AtomUnderflow; X_API EXTERNAL Term TermUnderflow; +X_API EXTERNAL Atom AtomUnificationStack; X_API EXTERNAL Term TermUnificationStack; +X_API EXTERNAL Atom AtomUnique; X_API EXTERNAL Term TermUnique; +X_API EXTERNAL Atom AtomUnsignedByte; X_API EXTERNAL Term TermUnsignedByte; +X_API EXTERNAL Atom AtomUnsignedChar; X_API EXTERNAL Term TermUnsignedChar; +X_API EXTERNAL Atom AtomUser; X_API EXTERNAL Term TermUser; +X_API EXTERNAL Atom AtomUserErr; X_API EXTERNAL Term TermUserErr; +X_API EXTERNAL Atom AtomUserIn; X_API EXTERNAL Term TermUserIn; +X_API EXTERNAL Atom AtomUserOut; X_API EXTERNAL Term TermUserOut; +X_API EXTERNAL Atom AtomUTF8; X_API EXTERNAL Term TermUTF8; +X_API EXTERNAL Atom AtomDollarVar; X_API EXTERNAL Term TermDollarVar; +X_API EXTERNAL Atom AtomVBar; X_API EXTERNAL Term TermVBar; +X_API EXTERNAL Atom AtomVarBranches; X_API EXTERNAL Term TermVarBranches; +X_API EXTERNAL Atom AtomVariableNames; X_API EXTERNAL Term TermVariableNames; +X_API EXTERNAL Atom AtomHiddenVar; X_API EXTERNAL Term TermHiddenVar; +X_API EXTERNAL Atom AtomVariable; X_API EXTERNAL Term TermVariable; +X_API EXTERNAL Atom AtomVerbose; X_API EXTERNAL Term TermVerbose; +X_API EXTERNAL Atom AtomVerboseFileSearch; X_API EXTERNAL Term TermVerboseFileSearch; +X_API EXTERNAL Atom AtomVersionNumber; X_API EXTERNAL Term TermVersionNumber; +X_API EXTERNAL Atom AtomVeryVerbose; X_API EXTERNAL Term TermVeryVerbose; +X_API EXTERNAL Atom AtomWakeUpGoal; X_API EXTERNAL Term TermWakeUpGoal; +X_API EXTERNAL Atom AtomWarning; X_API EXTERNAL Term TermWarning; +X_API EXTERNAL Atom AtomWhen; X_API EXTERNAL Term TermWhen; +X_API EXTERNAL Atom AtomWrite; X_API EXTERNAL Term TermWrite; +X_API EXTERNAL Atom AtomWriteTerm; X_API EXTERNAL Term TermWriteTerm; +X_API EXTERNAL Atom AtomXml; X_API EXTERNAL Term TermXml; +X_API EXTERNAL Atom AtomYapHacks; X_API EXTERNAL Term TermYapHacks; +X_API EXTERNAL Atom AtomZeroDivisor; X_API EXTERNAL Term TermZeroDivisor; +X_API EXTERNAL Functor FunctorAfInet; + +X_API EXTERNAL Functor FunctorAfLocal; + +X_API EXTERNAL Functor FunctorAfUnix; + +X_API EXTERNAL Functor FunctorAltNot; + +X_API EXTERNAL Functor FunctorArg; + +X_API EXTERNAL Functor FunctorArrayEntry; + +X_API EXTERNAL Functor FunctorArrow; + +X_API EXTERNAL Functor FunctorDoubleArrow; + +X_API EXTERNAL Functor FunctorAs; + +X_API EXTERNAL Functor FunctorAssert1; + +X_API EXTERNAL Functor FunctorAssert; + +X_API EXTERNAL Functor FunctorAt; + +X_API EXTERNAL Functor FunctorAtSymbol; + +X_API EXTERNAL Functor FunctorAtFoundOne; + +X_API EXTERNAL Functor FunctorAtom; + +X_API EXTERNAL Functor FunctorAtt1; + +X_API EXTERNAL Functor FunctorAttGoal; + +X_API EXTERNAL Functor FunctorBraces; + +X_API EXTERNAL Functor FunctorCall; + +X_API EXTERNAL Functor FunctorCatch; + +X_API EXTERNAL Functor FunctorChangeModule; + +X_API EXTERNAL Functor FunctorChars; + +X_API EXTERNAL Functor FunctorChars1; + +X_API EXTERNAL Functor FunctorCleanCall; + +X_API EXTERNAL Functor FunctorClist; + +X_API EXTERNAL Functor FunctorCodes; + +X_API EXTERNAL Functor FunctorCodes1; + +X_API EXTERNAL Functor FunctorColon; + +X_API EXTERNAL Functor FunctorComma; + +X_API EXTERNAL Functor FunctorCommentHook; + +X_API EXTERNAL Functor FunctorContext2; + +X_API EXTERNAL Functor FunctorConsistencyError; + +X_API EXTERNAL Functor FunctorCreep; + +X_API EXTERNAL Functor FunctorCsult; + +X_API EXTERNAL Functor FunctorCurrentModule; + +X_API EXTERNAL Functor FunctorCutBy; + +X_API EXTERNAL Functor FunctorDBREF; + +X_API EXTERNAL Functor FunctorDiff; + +X_API EXTERNAL Functor FunctorDoLogUpdClause; + +X_API EXTERNAL Functor FunctorDoLogUpdClause0; + +X_API EXTERNAL Functor FunctorDoLogUpdClauseErase; + +X_API EXTERNAL Functor FunctorDoStaticClause; + +X_API EXTERNAL Functor FunctorDollar; + +X_API EXTERNAL Functor FunctorDollarVar; + +X_API EXTERNAL Functor FunctorDomainError; + +X_API EXTERNAL Functor FunctorDot; + +X_API EXTERNAL Functor FunctorDot10; + +X_API EXTERNAL Functor FunctorDot11; + +X_API EXTERNAL Functor FunctorDot12; + +X_API EXTERNAL Functor FunctorDot2; + +X_API EXTERNAL Functor FunctorDot3; + +X_API EXTERNAL Functor FunctorDot4; + +X_API EXTERNAL Functor FunctorDot5; + +X_API EXTERNAL Functor FunctorDot6; + +X_API EXTERNAL Functor FunctorDot7; + +X_API EXTERNAL Functor FunctorDot8; + +X_API EXTERNAL Functor FunctorDot9; + +X_API EXTERNAL Functor FunctorDoubleArrow; + +X_API EXTERNAL Functor FunctorDoubleSlash; + +X_API EXTERNAL Functor FunctorEmptySquareBrackets; + +X_API EXTERNAL Functor FunctorEncoding; + +X_API EXTERNAL Functor FunctorEq; + +X_API EXTERNAL Functor FunctorError; + +X_API EXTERNAL Functor FunctorEvaluationError; + +X_API EXTERNAL Functor FunctorException; + +X_API EXTERNAL Functor FunctorExecute2InMod; + +X_API EXTERNAL Functor FunctorExecuteInMod; + +X_API EXTERNAL Functor FunctorExecuteWithin; + +X_API EXTERNAL Functor FunctorExistenceError; + +X_API EXTERNAL Functor FunctorExoClause; + +X_API EXTERNAL Functor FunctorExternalException; + +X_API EXTERNAL Functor FunctorFunctor; + +X_API EXTERNAL Functor FunctorGAtom; + +X_API EXTERNAL Functor FunctorGAtomic; + +X_API EXTERNAL Functor FunctorGCompound; + +X_API EXTERNAL Functor FunctorGFloat; + +X_API EXTERNAL Functor FunctorGFormatAt; + +X_API EXTERNAL Functor FunctorGInteger; + +X_API EXTERNAL Functor FunctorGNumber; + +X_API EXTERNAL Functor FunctorGPrimitive; + +X_API EXTERNAL Functor FunctorGVar; + +X_API EXTERNAL Functor FunctorGeneratePredInfo; + +X_API EXTERNAL Functor FunctorGoalExpansion2; + +X_API EXTERNAL Functor FunctorGoalExpansion; + +X_API EXTERNAL Functor FunctorHandleThrow; + +X_API EXTERNAL Functor FunctorHat; + +X_API EXTERNAL Functor FunctorDoubleHat; + +X_API EXTERNAL Functor FunctorI; + +X_API EXTERNAL Functor FunctorId; + +X_API EXTERNAL Functor FunctorInfo1; + +X_API EXTERNAL Functor FunctorInfo2; + +X_API EXTERNAL Functor FunctorInfo3; + +X_API EXTERNAL Functor FunctorInfo4; + +X_API EXTERNAL Functor FunctorIs; + +X_API EXTERNAL Functor FunctorJ; + +X_API EXTERNAL Functor FunctorLastExecuteWithin; + +X_API EXTERNAL Functor FunctorList; + +X_API EXTERNAL Functor FunctorLOOP; + +X_API EXTERNAL Functor FunctorMegaClause; + +X_API EXTERNAL Functor FunctorMetaCall; + +X_API EXTERNAL Functor FunctorMinus; + +X_API EXTERNAL Functor FunctorModule; + +X_API EXTERNAL Functor FunctorMultiFileClause; + +X_API EXTERNAL Functor FunctorMutable; + +X_API EXTERNAL Functor FunctorMutex; + +X_API EXTERNAL Functor FunctorNotImplemented; + +X_API EXTERNAL Functor FunctorNBQueue; + +X_API EXTERNAL Functor FunctorNot; + +X_API EXTERNAL Functor FunctorObj; + +X_API EXTERNAL Functor FunctorOr; + +X_API EXTERNAL Functor FunctorOutput; + +X_API EXTERNAL Functor FunctorPermissionError; + +X_API EXTERNAL Functor FunctorPlus; + +X_API EXTERNAL Functor FunctorPopen; + +X_API EXTERNAL Functor FunctorPortray; + +X_API EXTERNAL Functor FunctorPrintMessage; + +X_API EXTERNAL Functor FunctorProcedure; + +X_API EXTERNAL Functor FunctorPriority; + +X_API EXTERNAL Functor FunctorPrologConstraint; + +X_API EXTERNAL Functor FunctorProtectStack; + +X_API EXTERNAL Functor FunctorQuery; + +X_API EXTERNAL Functor FunctorRecordedWithKey; + +X_API EXTERNAL Functor FunctorRDiv; + +X_API EXTERNAL Functor FunctorRedoFreeze; + +X_API EXTERNAL Functor FunctorRepresentationError; + +X_API EXTERNAL Functor FunctorResourceError; + +X_API EXTERNAL Functor FunctorRestoreRegs; + +X_API EXTERNAL Functor FunctorRestoreRegs1; + +X_API EXTERNAL Functor FunctorSafe; + +X_API EXTERNAL Functor FunctorSafeCallCleanup; + +X_API EXTERNAL Functor FunctorSame; + +X_API EXTERNAL Functor FunctorSlash; + +X_API EXTERNAL Functor FunctorStaticClause; + +X_API EXTERNAL Functor FunctorStream; + +X_API EXTERNAL Functor FunctorStreamEOS; + +X_API EXTERNAL Functor FunctorStreamPos; + +X_API EXTERNAL Functor FunctorString1; + +X_API EXTERNAL Functor FunctorStyleCheck; + +X_API EXTERNAL Functor FunctorSyntaxError; + +X_API EXTERNAL Functor FunctorShortSyntaxError; + +X_API EXTERNAL Functor FunctorTermExpansion; + +X_API EXTERNAL Functor FunctorThreadRun; + +X_API EXTERNAL Functor FunctorThrow; + +X_API EXTERNAL Functor FunctorTimeoutError; + +X_API EXTERNAL Functor FunctorTraceMetaCall; + +X_API EXTERNAL Functor FunctorTypeError; + +X_API EXTERNAL Functor FunctorUMinus; + +X_API EXTERNAL Functor FunctorUndefinedQuery; + +X_API EXTERNAL Functor FunctorUPlus; + +X_API EXTERNAL Functor FunctorVBar; + +X_API EXTERNAL Functor FunctorWriteTerm; + +X_API EXTERNAL Functor FunctorHiddenVar; + diff --git a/H/globals.h b/H/globals.h new file mode 100644 index 000000000..cc9a4113b --- /dev/null +++ b/H/globals.h @@ -0,0 +1,173 @@ +// +// File defining fields in the Yap_GLOBAL global structure +// +// these fields used to spread all over the place, because they must be used in +// 3 ways: +// - they must be defined somewhere +// - they have an #ifdef to get a shorter name +// - they must be initialised somewhere +// - they may be of interest to restore +// +// The defs include 3+ components: +// Type +// name in structured / global name +// init code (optional); +// restore code (optional); +// + +// Stuff that must be shared by all threads or workers +// START_GLOBAL_DATA + +// initialization: tell whether the system has been initialised and by whom. +GLOBAL_INIT(int, Initialised, FALSE); +GLOBAL_INIT(int, InitialisedFromPL, FALSE); +GLOBAL_INIT(int, PL_Argc, 0); +GLOBAL_INIT(char **, PL_Argv, NULL); +GLOBAL_INIT(bool, FAST_BOOT_FLAG, false); + +// halt hooks +GLOBAL_INIT(struct halt_hook *, HaltHooks, NULL); +GLOBAL_INIT(fptr_t, JIT_finalizer, NULL); + +// stack overflow expansion/gc control +GLOBAL_INIT(int, AllowLocalExpansion, TRUE); +GLOBAL_INIT(int, AllowGlobalExpansion, TRUE); +GLOBAL_INIT(int, AllowTrailExpansion, TRUE); +GLOBAL_INIT(UInt, SizeOfOverflow, 0); + +// amount of space recovered in all garbage collections +GLOBAL_INIT(UInt, AGcThreshold, 10000); +GLOBAL_INIT(Agc_hook, AGCHook, NULL); + +/* multi-thread support */ +#if THREADS +/* number of threads and processes in system */ +GLOBAL_INIT(UInt, NOfThreads, 1); +/* number of threads created since start */ +GLOBAL_INIT(UInt, NOfThreadsCreated, 1); +/* total run time for dead threads */ +GLOBAL_INIT(UInt, ThreadsTotalTime, 0L); +// Threads Array +GLOBAL_INITF(lockvar, ThreadHandlesLock, MkLock); +#endif + +#if defined(YAPOR) || defined(THREADS); +// protect long critical regions +GLOBAL_INITF(lockvar, BGL, MkLock); +#endif + +#if defined(YAPOR) || defined(TABLING); +GLOBAL(struct global_optyap_data, optyap_data); +#endif /* YAPOR || TABLING */ + +// whether Yap is responsible for signal handling + +GLOBAL(int, PrologShouldHandleInterrupts); + +/* This is the guy who actually started the system, and who has the correct + * registers */ +#if defined(THREADS); +GLOBAL(pthread_t, master_thread); +GLOBAL_INIT(struct thread_mbox *, named_mboxes, NULL); +GLOBAL_INITF(lockvar, mboxq_lock, MkLock); +GLOBAL_INIT(UInt, mbox_count, 0); +GLOBAL(struct swi_mutex *, WithMutex); +#endif /* THREADS */ + +// streams +GLOBAL(struct stream_desc *, Stream); +#if defined(THREADS) || defined(YAPOR); +GLOBAL_INITF(lockvar, StreamDescLock, MkLock); +#endif + +// access to yap initial arguments +GLOBAL(char **, argv); +GLOBAL(int, argc); + +// extensions to Terms +#ifdef COROUTINING +/* array with the ops for your favourite extensions */ +GLOBAL_ARRAY(ext_op, attas, attvars_ext + 1); +#endif + +// agc.c +GLOBAL(int, agc_calls); +GLOBAL(YAP_ULONG_LONG, agc_collected); +/* total time spent in GC */ +GLOBAL_INIT(Int, tot_agc_time, 0); +/* number of heap objects in all garbage collections */ +GLOBAL_INIT(Int, tot_agc_recovered, 0); + +// arrays.c +#if HAVE_MMAP +GLOBAL_INIT(struct MMAP_ARRAY_BLOCK *, mmap_arrays, NULL); +#endif + +#ifdef DEBUG +// computils.c +GLOBAL_ARRAY(char, Option, 20); +GLOBAL(YP_FILE *, logfile); +// init.c +// int output_msg +// =FALSE +#endif + +#if defined(COFF) || defined(A_OUT); +// loada_coff.c && load_aout.c +GLOBAL_ARRAY(char, Executable, YAP_FILENAME_MAX); +#endif + +GLOBAL_INIT(int, OpaqueHandlersCount, 0); +GLOBAL_INIT(struct YAP_opaque_handler_struct *, OpaqueHandlers, NULL); + +#if __simplescalar__ +GLOBAL_ARRAY(char, pwd, YAP_FILENAME_MAX); +#endif + +// udi.c +// struct udi_control_block RtreeCmd void + +GLOBAL(const char *, RestoreFile); + +// gprof.c +GLOBAL(Int, ProfCalls); +GLOBAL(Int, ProfGCs); +GLOBAL(Int, ProfHGrows); +GLOBAL(Int, ProfSGrows); +GLOBAL(Int, ProfMallocs); +GLOBAL(Int, ProfIndexing); +GLOBAL(Int, ProfOn); +GLOBAL(Int, ProfOns); +GLOBAL(struct RB_red_blk_node *, ProfilerRoot); +GLOBAL(struct RB_red_blk_node *, ProfilerNil); +GLOBAL_INIT(char *, DIRNAME, NULL); +#if LOW_PROF +GLOBAL_INIT(int, ProfilerOn, FALSE); +GLOBAL_INIT(FILE *, FProf, NULL); +GLOBAL_INIT(FILE *, FPreds, NULL); +#endif /* LOW_PROF */ + +// Mutexes +#if THREADS +GLOBAL_INIT(struct swi_mutex *, FreeMutexes, NULL); +GLOBAL_INIT(struct swi_mutex *, mutex_backbone, NULL); +GLOBAL_INITF(lockvar, MUT_ACCESS, MkLock); +#endif + +GLOBAL_INIT(char *, Home, NULL); + +/* ISO char conversion: I will make no comments */ +GLOBAL_INIT(char *, CharConversionTable, NULL); +GLOBAL_INIT(char *, CharConversionTable2, NULL); + +/* max priority */ +GLOBAL_INIT(int, MaxPriority, 1200); + +/// alias table access +GLOBAL_INIT(struct AliasDescS *, FileAliases, Yap_InitStandardAliases()); +GLOBAL(int, NOfFileAliases); +GLOBAL(int, SzOfFileAliases); + +GLOBAL_INIT(struct vfs *, VFS, Yap_InitAssetManager()); + +END_GLOBAL_DATA diff --git a/H/headclause.h b/H/headclause.h index d6ef01a0e..7ae2a5920 100644 --- a/H/headclause.h +++ b/H/headclause.h @@ -8,9 +8,9 @@ switch (op) { #ifdef YAP_JIT case _jit_handler: -#endif cl = NEXTOP(cl,J); break; + #endif case _ensure_space: cl = NEXTOP(cl,Osbpa); break; @@ -215,13 +215,13 @@ } else { LogUpdClause *lcl = ClauseCodeToLogUpdClause(cl); Term t = lcl->lusl.ClSource->Entry; - + if (!(lcl->ClFlags & FactMask)) { if (IsVarTerm(t)) { clause->Tag = (CELL)NULL; } else if (IsApplTerm(t)) { CELL *pt = RepAppl(t); - + clause->Tag = AbsAppl((CELL *)pt[0]); if (IsExtensionFunctor(FunctorOfTerm(t))) { clause->ucd.t_ptr = t; @@ -250,13 +250,13 @@ } else { LogUpdClause *lcl = ClauseCodeToLogUpdClause(cl); Term t = lcl->lusl.ClSource->Entry; - + if (!(lcl->ClFlags & FactMask)) { if (IsVarTerm(t)) { clause->Tag = (CELL)NULL; } else if (IsApplTerm(t)) { CELL *pt = RepAppl(t); - + clause->Tag = AbsAppl((CELL *)pt[0]); if (IsExtensionFunctor(FunctorOfTerm(t))) { clause->ucd.t_ptr = t; diff --git a/H/inline-only.h b/H/inline-only.h index be5039198..60819de5c 100644 --- a/H/inline-only.h +++ b/H/inline-only.h @@ -1,11 +1,11 @@ #ifndef _YAP_INLINE_ONLY_H_ #define _YAP_INLINE_ONLY_H_ -#ifdef __GNUC__ -#define INLINE_ONLY __attribute__((gnu_inline,always_inline)) +#if defined(__GNUC__ ) +#define INLINE_ONLY EXTERN inline __attribute__((gnu_inline,always_inline)) //#define INLINE_ONLY #else -#define INLINE_ONLY EXTERN +#define INLINE_ONLY EXTERN inline #endif #endif diff --git a/H/locals.h b/H/locals.h index acdd73cd8..7380c1c5d 100644 --- a/H/locals.h +++ b/H/locals.h @@ -1,319 +1,324 @@ -// Stuff that must be considered local to a thread or worker -// START_WORKER_LOCL +/// Thread Local Variables. This file now follows C syntax. -// Streams -LOCL(struct AliasDescS *, FileAliases, Yap_InitStandardAliases()) -LOC(int, NOfFileAliases) -LOCL(int, SzOfFileAliases, void) - -LOCL(int, c_input_stream, 0) -LOCL(int, c_output_stream, 1) -LOCL(int, c_error_stream, 2) - -LOCL(bool, sockets_io, false) - -LOCL(bool, within_print_message, false) +// Macro support +#ifndef LOCAL +#include "Yap.h" +#include "heap.h" +#define LOCAL(A, B) A B +#define LOCAL_INIT(A, B, C) \ + A B; \ + B = C +#define LOCAL_ARRAY(A, B, C) A B[C] +#define LOCAL_ARRAY_ARRAY(A, B, C,D) A B[C][D] +#define LOCAL_INIT(A, B, C, D) A B[C][D] +#define LOCAL_INITF(A, B, C) \ + A B; \ + C + #define LOCAL_INIT_RESTORE(A,B,C,D) A B; C; D; +#endif +/// Current bindings for std streams, includes default s +LOCAL_INIT(int, c_input_stream, 0); +LOCAL_INIT(int, c_output_stream, 1); +LOCAL_INIT(int, c_error_stream, 2); +LOCAL_INIT(bool, sockets_io, false); +LOCAL_INIT(bool, within_print_message, false); // + // Used by the prompts to check if they are after a newline, and then a // prompt should be output, or if we are in the middle of a line. // -LOCL(bool, newline, true) +LOCAL_INIT(bool, newline, true); -LOCL(Atom, AtPrompt, AtomNil) -LOCN(char, MAX_PROMPT + 1, Prompt) - -LOCL(encoding_t, encoding, Yap_DefaultEncoding()) -LOCL(bool, quasi_quotations, false) -LOCL(UInt, default_priority, 1200) - -LOCL(bool, eot_before_eof, false) -LOCL(UInt, max_depth, 0) -LOCL(UInt, max_list, 0) -LOCL(UInt, max_write_args, 0) +LOCAL_INIT(Atom, AtPrompt, AtomNil); +LOCAL_ARRAY(char, Prompt, MAX_PROMPT + 1); +LOCAL_INITF(encoding_t, encoding, Yap_DefaultEncoding()); +LOCAL_INIT(bool, quasi_quotations, false); +LOCAL_INIT(UInt, default_priority, 1200); +LOCAL_INIT(bool, eot_before_eof, false); +LOCAL_INIT(UInt, max_depth, 0); +LOCAL_INIT(UInt, max_list, 0); +LOCAL_INIT(UInt, max_write_args, 0); // Restore info -LOCL(CELL *, OldASP, NULL) -LOCL(CELL *, OldLCL0, NULL) -LOCL(tr_fr_ptr, OldTR, NULL) -LOCL(CELL *, OldGlobalBase, NULL) -LOCL(CELL *, OldH, NULL) -LOCL(CELL *, OldH0, NULL) -LOCL(ADDR, OldTrailBase, NULL) -LOCL(ADDR, OldTrailTop, NULL) -LOCL(ADDR, OldHeapBase, NULL) -LOCL(ADDR, OldHeapTop, NULL) -LOCL(Int, ClDiff, 0L) -LOCL(Int, GDiff, 0L) -LOCL(Int, HDiff, 0L) -LOCL(Int, GDiff0, 0L) -LOCL(CELL *, GSplit, NULL) -LOCL(Int, LDiff, 0L) -LOCL(Int, TrDiff, 0L) -LOCL(Int, XDiff, 0L) -LOCL(Int, DelayDiff, 0L) -LOCL(Int, BaseDiff, 0L) - +LOCAL_INIT(CELL *, OldASP, NULL); +LOCAL_INIT(CELL *, OldLCL0, NULL); +LOCAL_INIT(tr_fr_ptr, OldTR, NULL); +LOCAL_INIT(CELL *, OldGlobalBase, NULL); +LOCAL_INIT(CELL *, OldH, NULL); +LOCAL_INIT(CELL *, OldH0, NULL); +LOCAL_INIT(ADDR, OldTrailBase, NULL); +LOCAL_INIT(ADDR, OldTrailTop, NULL); +LOCAL_INIT(ADDR, OldHeapBase, NULL); +LOCAL_INIT(ADDR, OldHeapTop, NULL); +LOCAL_INIT(Int, ClDiff, 0L); +LOCAL_INIT(Int, GDiff, 0L); +LOCAL_INIT(Int, HDiff, 0L); +LOCAL_INIT(Int, GDiff0, 0L); +LOCAL_INIT(CELL *, GSplit, NULL); +LOCAL_INIT(Int, LDiff, 0L); +LOCAL_INIT(Int, TrDiff, 0L); +LOCAL_INIT(Int, XDiff, 0L); +LOCAL_INIT(Int, DelayDiff, 0L); +LOCAL_INIT(Int, BaseDiff, 0L); // Reduction counters -LOCL(YAP_ULONG_LONG, ReductionsCounter, 0L) -LOCL(YAP_ULONG_LONG, PredEntriesCounter, 0L) -LOCL(YAP_ULONG_LONG, RetriesCounter, 0L) -LOCL(int, ReductionsCounterOn, 0L) -LOCL(int, PredEntriesCounterOn, 0L) -LOCL(int, RetriesCounterOn, 0L) - +LOCAL_INIT(YAP_ULONG_LONG, ReductionsCounter, 0L); +LOCAL_INIT(YAP_ULONG_LONG, PredEntriesCounter, 0L); +LOCAL_INIT(YAP_ULONG_LONG, RetriesCounter, 0L); +LOCAL_INIT(int, ReductionsCounterOn, 0L); +LOCAL_INIT(int, PredEntriesCounterOn, 0L); +LOCAL_INIT(int, RetriesCounterOn, 0L); // support for consulting files /* current consult stack */ -LOCL(union CONSULT_OBJ *, ConsultSp, NULL) +LOCAL_INIT(union CONSULT_OBJ *, ConsultSp, NULL); /* current maximum number of cells in consult stack */ -LOC(UInt, ConsultCapacity) +LOCAL(UInt, ConsultCapacity); /* top of consult stack */ -LOCL(union CONSULT_OBJ *, ConsultBase, NULL) +LOCAL_INIT(union CONSULT_OBJ *, ConsultBase, NULL); /* low-water mark for consult */ -LOCL(union CONSULT_OBJ *, ConsultLow, NULL) -LOCL(Term, VarNames, ((Term)0)) -LOCL(Atom, SourceFileName, NULL) -LOCL(UInt, SourceFileLineno, 0) - +LOCAL_INIT(union CONSULT_OBJ *, ConsultLow, NULL); +LOCAL_INIT(Term, VarNames, ((Term)0)); +LOCAL_INIT(Atom, SourceFileName, NULL); +LOCAL_INIT(UInt, SourceFileLineno, 0); // global variables - LOCLR(Term, GlobalArena, 0L, TermToGlobalOrAtomAdjust() ) -LOCL(UInt, GlobalArenaOverflows, 0L) -LOCL(Int, ArenaOverflows, 0L) -LOCL(Int, DepthArenas, 0) +LOCAL_INIT_RESTORE(Term, GlobalArena, 0L, TermToGlobalOrAtomAdjust); +LOCAL_INIT(UInt, GlobalArenaOverflows, 0L); +LOCAL_INIT(Int, ArenaOverflows, 0L); +LOCAL_INIT(Int, DepthArenas, 0); +LOCAL_INIT(struct pred_entry *, LastAssertedPred, NULL); +LOCAL_INIT(struct pred_entry *, TmpPred, NULL); +LOCAL_INIT(char *, ScannerStack, NULL); +LOCAL_INIT(struct scanner_extra_alloc *, ScannerExtraBlocks, NULL); -LOCL(int, ArithError, FALSE) -LOCL(struct pred_entry *, LastAssertedPred, NULL) -LOCL(struct pred_entry *, TmpPred, NULL) -LOCL(char *, ScannerStack, NULL) -LOCL(struct scanner_extra_alloc *, ScannerExtraBlocks, NULL) -LOCLR(struct DB_TERM *, BallTerm, NULL, RestoreBallTerm(wid)) -LOCL(UInt, MaxActiveSignals, 64L) -LOCL(uint64_t, Signals, 0L) -LOCL(UInt, IPredArity, 0L) -LOCL(yamop *, ProfEnd, NULL) -LOCL(int, UncaughtThrow, FALSE) -LOCL(int, DoingUndefp, FALSE) -LOCL(Int, StartCharCount, 0L) -LOCL(Int, StartLineCount, 0L) -LOCL(Int, StartLinePos, 0L) -LOCL(scratch_block, ScratchPad, InitScratchPad(wid)) +/// worker control information +/// stack limit after which the stack is managed by C-code. +LOCAL_INIT(Int, CBorder, 0); +/// max number of signals (uint64_t); +LOCAL_INIT(UInt, MaxActiveSignals, 64L); +/// actual life signals +LOCAL_INIT(uint64_t, Signals, 0L); +/// indexing help data? +LOCAL_INIT(UInt, IPredArity, 0L); +LOCAL_INIT(yamop *, ProfEnd, NULL); +LOCAL_INIT(int, DoingUndefp, FALSE); +LOCAL_INIT(Int, StartCharCount, 0L); +LOCAL_INIT(Int, StartLineCount, 0L); +LOCAL_INIT(Int, StartLinePos, 0L); +LOCAL_INITF(scratch_block, ScratchPad, InitScratchPad(wid)); #ifdef COROUTINING - LOCLR(Term, WokenGoals, 0L, TermToGlobalAdjust() ) - LOCLR(Term, AttsMutableList, 0L, TermToGlobalAdjust() ) +LOCAL_INIT_RESTORE(Term, WokenGoals, 0L, TermToGlobalAdjust); +LOCAL_INIT_RESTORE(Term, AttsMutableList, 0L, TermToGlobalAdjust); #endif // gc_stuff -LOCLR(Term, GcGeneration, 0L, TermToGlobalAdjust() ) -LOCLR(Term, GcPhase, 0L, TermToGlobalAdjust() ) -LOCL(UInt, GcCurrentPhase, 0L) -LOCL(UInt, GcCalls, 0L) -LOCL(Int, TotGcTime, 0L) -LOCL(YAP_ULONG_LONG, TotGcRecovered, 0L) -LOCL(Int, LastGcTime, 0L) -LOCL(Int, LastSSTime, 0L) -LOCL(CELL *, OpenArray, NULL) - +LOCAL_INIT_RESTORE(Term, GcGeneration, 0L, TermToGlobalAdjust); +LOCAL_INIT_RESTORE(Term, GcPhase, 0L, TermToGlobalAdjust); +LOCAL_INIT(UInt, GcCurrentPhase, 0L); +LOCAL_INIT(UInt, GcCalls, 0L); +LOCAL_INIT(Int, TotGcTime, 0L); +LOCAL_INIT(YAP_ULONG_LONG, TotGcRecovered, 0L); +LOCAL_INIT(Int, LastGcTime, 0L); +LOCAL_INIT(Int, LastSSTime, 0L); +LOCAL_INIT(CELL *, OpenArray, NULL); /* in a single gc */ -LOCL(Int, total_marked, 0L) -LOCL(Int, total_oldies, 0L) -LOCL(struct choicept *, current_B, NULL) -LOCL(CELL *, prev_HB, NULL) -LOCL(CELL *, HGEN, NULL) -LOCL(CELL **, iptop, NULL) - +LOCAL_INIT(int, MallocDepth, 0L); +LOCAL_INIT(Int, total_marked, 0L); +LOCAL_INIT(Int, total_oldies, 0L); +LOCAL_INIT(struct choicept *, current_B, NULL); +LOCAL_INIT(CELL *, prev_HB, NULL); +LOCAL_INIT(CELL *, HGEN, NULL); +LOCAL_INIT(CELL **, iptop, NULL); #if defined(GC_NO_TAGS) -LOCL(char *, bp, NULL) +LOCAL_INIT(char *, bp, NULL); #endif -LOCL(tr_fr_ptr, sTR, NULL) -LOCL(tr_fr_ptr, sTR0, NULL) -LOCL(tr_fr_ptr, new_TR, NULL) -LOCL(struct gc_mark_continuation *, cont_top0, NULL) -LOCL(struct gc_mark_continuation *, cont_top, NULL) -LOCL(int, discard_trail_entries, 0) -LOCN(gc_ma_hash_entry, GC_MAVARS_HASH_SIZE, gc_ma_hash_table) -LOCL(gc_ma_hash_entry *, gc_ma_h_top, NULL) -LOCL(gc_ma_hash_entry *, gc_ma_h_list, NULL) -LOCL(UInt, gc_timestamp, 0L) -LOCL(ADDR, db_vec, NULL) -LOCL(ADDR, db_vec0, NULL) -LOCL(struct RB_red_blk_node *, db_root, NULL) -LOCL(struct RB_red_blk_node *, db_nil, NULL) +LOCAL_INIT(tr_fr_ptr, sTR, NULL); +LOCAL_INIT(tr_fr_ptr, sTR0, NULL); +LOCAL_INIT(tr_fr_ptr, new_TR, NULL); +LOCAL_INIT(struct gc_mark_continuation *, cont_top0, NULL); +LOCAL_INIT(struct gc_mark_continuation *, cont_top, NULL); +LOCAL_INIT(int, discard_trail_entries, 0); +LOCAL_ARRAY(gc_ma_hash_entry, gc_ma_hash_table, GC_MAVARS_HASH_SIZE); +LOCAL_INIT(gc_ma_hash_entry *, gc_ma_h_top, NULL); +LOCAL_INIT(gc_ma_hash_entry *, gc_ma_h_list, NULL); +LOCAL_INIT(UInt, gc_timestamp, 0L); +LOCAL_INIT(ADDR, db_vec, NULL); +LOCAL_INIT(ADDR, db_vec0, NULL); +LOCAL_INIT(struct RB_red_blk_node *, db_root, NULL); +LOCAL_INIT(struct RB_red_blk_node *, db_nil, NULL); -LOC(sigjmp_buf, gc_restore) -LOC(CELL *, extra_gc_cells) -LOC(CELL *, extra_gc_cells_base) -LOC(CELL *, extra_gc_cells_top) -LOCN(UInt, 256, extra_gc_cells_size) -LOCLR(struct array_entry *, DynamicArrays, NULL, PtoArrayEAdjust) -LOCLR(struct static_array_entry *, StaticArrays, NULL, PtoArraySAdjust) -LOCLR(struct global_entry *, GlobalVariables, NULL, PtoGlobalEAdjust) -LOCL(int, AllowRestart, FALSE) +LOCAL(sigjmp_buf , gc_restore); +LOCAL(CELL *, extra_gc_cells); +LOCAL(CELL *, extra_gc_cells_base); +LOCAL(CELL *, extra_gc_cells_top); +LOCAL_INIT(UInt, extra_gc_cells_size, 256); +LOCAL_INIT_RESTORE(struct array_entry *, DynamicArrays, NULL, PtoArrayEAdjust); +LOCAL_INIT_RESTORE(struct static_array_entry *, StaticArrays, NULL, PtoArraySAdjust); +LOCAL_INIT_RESTORE(struct global_entry *, GlobalVariables, NULL, PtoGlobalEAdjust); +LOCAL_INIT(int, AllowRestart, FALSE); // Thread Local Area for Fast Storage of Intermediate Compiled Code -LOCL(struct mem_blk *, CMemFirstBlock, NULL) -LOCL(UInt, CMemFirstBlockSz, 0L) +LOCAL_INIT(struct mem_blk *, CMemFirstBlock, NULL); +LOCAL_INIT(UInt, CMemFirstBlockSz, 0L); // Variable used by the compiler to store number of permanent vars in a clause -LOCL(int, nperm, 0L) - +LOCAL_INIT(int, nperm, 0); +LOCAL_INIT(int, jMP, 0); // Thread Local Area for Labels -LOCL(Int *, LabelFirstArray, NULL) -LOCL(UInt, LabelFirstArraySz, 0L) +LOCAL_INIT(Int *, LabelFirstArray, NULL); +LOCAL_INIT(UInt, LabelFirstArraySz, 0L); // Thread Local Area for SWI-Prolog emulation routines. -// struct PL_local_data*, PL_local_data_p, Yap_InitThreadIO(wid) - +// struct LOCAL_INIT( PL_local_data*, PL_local_data_p, Yap_InitThreadIO(wid)); #ifdef THREADS -LOCL(struct thandle, ThreadHandle, InitThreadHandle(wid)) +LOCAL_INITF(struct thandle, ThreadHandle, InitThreadHandle(wid)); #endif /* THREADS */ #if defined(YAPOR) || defined(TABLING) -LOCL(struct local_optyap_data, optyap_data, Yap_init_local_optyap_data(wid)) -LOCL(UInt, TabMode, 0L) +LOCAL_INITF(struct local_optyap_data, optyap_data,Yap_init_local_optyap_data(wid)); +LOCAL_INIT(UInt, TabMode, 0L); #endif /* YAPOR || TABLING */ -LOCL(int, InterruptsDisabled, FALSE) +LOCAL_INIT(int, InterruptsDisabled, FALSE); -LOCL(struct open_query_struct *, execution, NULL) +LOCAL_INIT(struct open_query_struct *, execution, NULL); #if LOW_LEVEL_TRACER -LOCL(Int, total_choicepoints, 0) +LOCAL_INIT(Int, total_choicepoints, 0); #endif -LOCL(int, consult_level, 0) +LOCAL_INIT(int, consult_level, 0); // Variables related to memory allocation -LOC(ADDR, LocalBase) -LOC(ADDR, GlobalBase) -LOC(ADDR, TrailBase) -LOC(ADDR, TrailTop) -LOC(char *, ErrorMessage) -LOC(Term, Error_Term) -LOC(yap_error_number, Error_TYPE) -LOC(const char *, Error_File) -LOC(const char *, Error_Function) -LOC(int, Error_Lineno) -LOC(size_t, Error_Size) -LOCN(char, MAX_ERROR_MSG_SIZE, ErrorSay) -LOC(jmp_buf, IOBotch) -LOC(TokEntry *, tokptr) -LOC(TokEntry *, toktide) -LOC(VarEntry *, VarTable) -LOC(VarEntry *, AnonVarTable) -LOC(Term, Comments) -LOC(CELL *, CommentsTail) -LOC(CELL *, CommentsNextChar) -LOC(wchar_t *, CommentsBuff) -LOC(size_t, CommentsBuffPos) -LOC(size_t, CommentsBuffLim) -LOC(sigjmp_buf, RestartEnv) -LOCN(char, YAP_FILENAME_MAX, FileNameBuf) -LOCN(char, YAP_FILENAME_MAX, FileNameBuf2) +LOCAL(ADDR, LocalBase); +LOCAL(ADDR, GlobalBase); +LOCAL(ADDR, TrailBase); +LOCAL(ADDR, TrailTop); + +/* error handling info, designed to be easy to pass to the foreign world */ +LOCAL_INIT(yap_error_descriptor_t *, ActiveError, calloc(sizeof(yap_error_descriptor_t), 1)); +LOCAL_INIT(yap_error_descriptor_t *, CommittedError, NULL); +LOCAL_INIT(bool, delay, false); +/// pointer to an exception term, from throw +LOCAL(jmp_buf, IOBotch); + +/// tokenizer support (should be private to the tokenizer). +LOCAL(TokEntry *, tokptr); +LOCAL(TokEntry *, toktide); +LOCAL(VarEntry *, VarTable); +LOCAL(VarEntry *, AnonVarTable); +LOCAL(Term, Comments); +LOCAL(CELL *, CommentsTail); +LOCAL(CELL *, CommentsNextChar); +LOCAL(wchar_t *, CommentsBuff); +LOCAL(size_t, CommentsBuffPos); +LOCAL(size_t, CommentsBuffLim); +LOCAL_INIT(sigjmp_buf *, RestartEnv, NULL); +LOCAL_ARRAY(char, FileNameBuf, YAP_FILENAME_MAX + 1); +LOCAL_ARRAY(char, FileNameBuf2, YAP_FILENAME_MAX + 1); +LOCAL_INIT(struct TextBuffer_manager *, TextBuffer, Yap_InitTextAllocator()); // Prolog State -LOCL(UInt, BreakLevel, 0) -LOCL(Int, PrologMode, BootMode) -LOCL(int, CritLocks, 0) +LOCAL_INIT(UInt, BreakLevel, 0); +LOCAL_INIT(Int, PrologMode, BootMode); +LOCAL_INIT(int, CritLocks, 0); // Prolog execution and state flags -LOC(union flagTerm *, Flags) -LOC(UInt, flagCount) - +LOCAL(union flagTerm *, Flags); +LOCAL(UInt, flagCount); // analyst.c /* used to find out how many instructions of each kind are executed */ #ifdef ANALYST -LOC(YAP_ULONG_LONG, opcount[_std_top + 1]) -LOC(YAP_ULONG_LONG, 2opcount [_std_top + 1][_std_top + 1]) +LOCAL_ARRAY(YAP_ULONG_LONG, opcount, _std_top + 1); +LOCAL_ARRAY_ARRAY(YAP_ULONG_LONG, 2opcount, _std_top + 1, _std_top + 1); #endif /* ANALYST */ // dbase.c -LOC(struct db_globs *, s_dbg) +LOCAL(struct db_globs *, s_dbg); // eval.c -LOCL(yap_error_number, matherror, YAP_NO_ERROR) -LOCL(Term, mathtt, NULL) -LOCL(char *, mathstring, NULL) -LOCL(yap_error_number, CurrentError, YAP_NO_ERROR) +LOCAL(Term, mathtt); +LOCAL_INIT(char *, mathstring, NULL); +LOCAL_INIT(struct eval_context *, ctx, NULL); + // grow.c -LOCL(int, heap_overflows, 0) -LOCL(Int, total_heap_overflow_time, 0) -LOCL(int, stack_overflows, 0) -LOCL(Int, total_stack_overflow_time, 0) -LOCL(int, delay_overflows, 0) -LOCL(Int, total_delay_overflow_time, 0) -LOCL(int, trail_overflows, 0) -LOCL(Int, total_trail_overflow_time, 0) -LOCL(int, atom_table_overflows, 0) -LOCL(Int, total_atom_table_overflow_time, 0) +LOCAL_INIT(int, heap_overflows, 0); +LOCAL_INIT(Int, total_heap_overflow_time, 0); +LOCAL_INIT(int, stack_overflows, 0); +LOCAL_INIT(Int, total_stack_overflow_time, 0); +LOCAL_INIT(int, delay_overflows, 0); +LOCAL_INIT(Int, total_delay_overflow_time, 0); +LOCAL_INIT(int, trail_overflows, 0); +LOCAL_INIT(Int, total_trail_overflow_time, 0); +LOCAL_INIT(int, atom_table_overflows, 0); +LOCAL_INIT(Int, total_atom_table_overflow_time, 0); // load_dyld #ifdef LOAD_DYLD -LOCL(int, dl_errno, 0) +LOCAL_INIT(int, dl_errno, 0); #endif // tracer.c #ifdef LOW_LEVEL_TRACER -LOCL(int, do_trace_primitives, TRUE) +LOCAL_INIT(int, do_trace_primitives, TRUE); #endif // quick loader -LOCL(struct export_atom_hash_entry_struct *, ExportAtomHashChain, NULL) -LOCL(UInt, ExportAtomHashTableSize, 0) -LOCL(UInt, ExportAtomHashTableNum, 0) -LOCL(struct export_functor_hash_entry_struct *, ExportFunctorHashChain, NULL) -LOCL(UInt, ExportFunctorHashTableSize, 0) -LOCL(UInt, ExportFunctorHashTableNum, 0) -LOCL(struct export_pred_entry_hash_entry_struct *, ExportPredEntryHashChain, - NULL) -LOCL(UInt, ExportPredEntryHashTableSize, 0) -LOCL(UInt, ExportPredEntryHashTableNum, 0) -LOCL(struct export_dbref_hash_entry_struct *, ExportDBRefHashChain, NULL) -LOCL(UInt, ExportDBRefHashTableSize, 0) -LOCL(UInt, ExportDBRefHashTableNum, 0) -LOCL(struct import_atom_hash_entry_struct **, ImportAtomHashChain, NULL) -LOCL(UInt, ImportAtomHashTableSize, 0) -LOCL(UInt, ImportAtomHashTableNum, 0) -LOCL(struct import_functor_hash_entry_struct **, ImportFunctorHashChain, NULL) -LOCL(UInt, ImportFunctorHashTableSize, 0) -LOCL(UInt, ImportFunctorHashTableNum, 0) -LOCL(struct import_opcode_hash_entry_struct **, ImportOPCODEHashChain, NULL) -LOCL(UInt, ImportOPCODEHashTableSize, 0) -LOCL(struct import_pred_entry_hash_entry_struct **, ImportPredEntryHashChain, - NULL) -LOCL(UInt, ImportPredEntryHashTableSize, 0) -LOCL(UInt, ImportPredEntryHashTableNum, 0) -LOCL(struct import_dbref_hash_entry_struct **, ImportDBRefHashChain, NULL) -LOCL(UInt, ImportDBRefHashTableSize, 0) -LOCL(UInt, ImportDBRefHashTableNum, 0) -LOCL(yamop *, ImportFAILCODE, NULL) - -#if __ANDROID__ -// current virtual directory. -LOCL(struct AAssetManager *assetManager, GLOBAL_assetManager) -LOCL(char *, InAssetDir, NULL) -#endif +LOCAL_INIT(struct export_atom_hash_entry_struct *, ExportAtomHashChain, NULL); +LOCAL_INIT(UInt, ExportAtomHashTableSize, 0); +LOCAL_INIT(UInt, ExportAtomHashTableNum, 0); +LOCAL_INIT(struct export_functor_hash_entry_struct *, ExportFunctorHashChain,NULL); +LOCAL_INIT(UInt, ExportFunctorHashTableSize, 0); +LOCAL_INIT(UInt, ExportFunctorHashTableNum, 0); +LOCAL_INIT(struct export_pred_entry_hash_entry_struct *,ExportPredEntryHashChain, NULL); +LOCAL_INIT(UInt, ExportPredEntryHashTableSize, 0); +LOCAL_INIT(UInt, ExportPredEntryHashTableNum, 0); +LOCAL_INIT(struct export_dbref_hash_entry_struct *, ExportDBRefHashChain, NULL); +LOCAL_INIT(UInt, ExportDBRefHashTableSize, 0); +LOCAL_INIT(UInt, ExportDBRefHashTableNum, 0); +LOCAL_INIT(struct import_atom_hash_entry_struct **, ImportAtomHashChain, NULL); +LOCAL_INIT(UInt, ImportAtomHashTableSize, 0); +LOCAL_INIT(UInt, ImportAtomHashTableNum, 0); +LOCAL_INIT(struct import_functor_hash_entry_struct **, ImportFunctorHashChain, NULL); +LOCAL_INIT(UInt, ImportFunctorHashTableSize, 0); +LOCAL_INIT(UInt, ImportFunctorHashTableNum, 0); +LOCAL_INIT(struct import_opcode_hash_entry_struct **, ImportOPCODEHashChain, NULL); +LOCAL_INIT(UInt, ImportOPCODEHashTableSize, 0); +LOCAL_INIT(struct import_pred_entry_hash_entry_struct **, ImportPredEntryHashChain, NULL); +LOCAL_INIT(UInt, ImportPredEntryHashTableSize, 0); +LOCAL_INIT(UInt, ImportPredEntryHashTableNum, 0); +LOCAL_INIT(struct import_dbref_hash_entry_struct **, ImportDBRefHashChain, NULL); +LOCAL_INIT(UInt, ImportDBRefHashTableSize, 0); +LOCAL_INIT(UInt, ImportDBRefHashTableNum, 0); +LOCAL_INIT(yamop *, ImportFAILCODE, NULL); // exo indexing -LOCN(UInt, 256, ibnds) -LOCL(struct index_t *, exo_it, NULL) -LOCL(CELL *, exo_base, NULL) -LOCL(UInt, exo_arity, 0) -LOCL(UInt, exo_arg, 0) +LOCAL_ARRAY(UInt, ibnds, 256); +LOCAL_INIT(struct index_t *, exo_it, NULL); +LOCAL_INIT(CELL *, exo_base, NULL); +LOCAL_INIT(UInt, exo_arity, 0); +LOCAL_INIT(UInt, exo_arg, 0); // atom completion -LOC(struct scan_atoms *, search_atoms) +LOCAL(struct scan_atoms *, search_atoms); +LOCAL(struct pred_entry *, SearchPreds); -// Slots -LOCL(yhandle_t, CurSlot, 0) -LOCL(yhandle_t, NSlots, 0) -LOCL(CELL *, SlotBase, InitHandles(wid)) +/// Slots Status +LOCAL_INIT(yhandle_t, CurSlot, 0); +LOCAL_INIT(yhandle_t, FrozenHandles, 0); +LOCAL_INIT(yhandle_t, NSlots, 0); +LOCAL_INIT(CELL *, SlotBase, InitHandles(wid)); // Mutexes -LOCL(struct swi_mutex *, Mutexes, NULL) +LOCAL_INIT(struct swi_mutex *, Mutexes, NULL); -LOCL(Term, SourceModule, 0) -LOCL(Term, Including, TermNil) +LOCAL_INIT(Term, SourceModule, 0); +LOCAL_INIT(Term, Including, TermNil); -LOCL(size_t, MAX_SIZE, 1024L) +LOCAL_INIT(size_t, MAX_SIZE, 1024L); + +/* last call to walltime. */ +LOCAL_INIT(uint64_t, LastWTime, 0); + +LOCAL_INIT(void *, shared, NULL); diff --git a/H/rclause.h b/H/rclause.h index 986e76d6b..ff11ebb17 100644 --- a/H/rclause.h +++ b/H/rclause.h @@ -78,6 +78,9 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS) case _call: case _call_cpred: case _call_usercpred: + case _dexecute: + case _execute: + case _execute_cpred: case _fcall: case _p_execute2: OrArgAdjust(pc->y_u.Osbpp.or_arg); @@ -255,10 +258,6 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS) case _jump: case _jump_if_var: case _move_back: -#if INLINE_BIG_COMPARISONS - case _p_dif: - case _p_eq: -#endif case _retry2: case _retry3: case _retry4: @@ -483,14 +482,6 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS) pc->y_u.plyys.flags = ConstantAdjust(pc->y_u.plyys.flags); pc = NEXTOP(pc,plyys); break; - /* instructions type pp */ - case _dexecute: - case _execute: - case _execute_cpred: - pc->y_u.pp.p = PtoPredAdjust(pc->y_u.pp.p); - pc->y_u.pp.p0 = PtoPredAdjust(pc->y_u.pp.p0); - pc = NEXTOP(pc,pp); - break; /* instructions type s */ case _cut: case _cut_e: diff --git a/H/rheap.h b/H/rheap.h index d6bf5f0f4..17ec48427 100644 --- a/H/rheap.h +++ b/H/rheap.h @@ -1,243 +1,251 @@ /************************************************************************* -* * -* YAP Prolog * -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * -* * -************************************************************************** -* * -* File: rheap.h * -* comments: walk through heap code * -* * -* Last rev: $Date: 2008-08-07 20:51:23 $,$Author: vsc $ -** -* $Log: not supported by cvs2svn $ -* Revision 1.99 2008/07/22 23:34:49 vsc -* SWI and module fixes -* -* Revision 1.98 2008/05/12 22:31:37 vsc -* fix previous fixes -* -* Revision 1.97 2008/05/12 14:04:23 vsc -* updates to restore -* -* Revision 1.96 2008/04/11 16:58:17 ricroc -* yapor: seq_def initialization -* -* Revision 1.95 2008/04/06 12:06:48 vsc -* more small fixes -* -* Revision 1.94 2008/04/06 11:53:02 vsc -* fix some restore bugs -* -* Revision 1.93 2008/04/04 09:10:02 vsc -* restore was restoring twice -* -* Revision 1.92 2008/04/03 11:34:47 vsc -* fix restorebb in cases entry key is not an atom (obs from Nicos -* Angelopoulos) -* -* Revision 1.91 2008/04/01 15:31:43 vsc -* more saved state fixes -* -* Revision 1.90 2008/04/01 14:09:43 vsc -* improve restore -* -* Revision 1.89 2008/04/01 09:41:05 vsc -* more fixes to restore -* -* Revision 1.88 2008/04/01 08:42:46 vsc -* fix restore and small VISTA thingies -* -* Revision 1.87 2008/03/25 22:03:14 vsc -* fix some icc warnings -* -* Revision 1.86 2008/03/25 16:45:53 vsc -* make or-parallelism compile again -* -* Revision 1.85 2008/02/12 17:03:52 vsc -* SWI-portability changes -* -* Revision 1.84 2008/02/07 21:39:51 vsc -* fix case where predicate is for an integer (DBEntry). -* -* Revision 1.83 2008/01/23 17:57:55 vsc -* valgrind it! -* enable atom garbage collection. -* -* Revision 1.82 2007/12/05 12:17:23 vsc -* improve JT -* fix graph compatibility with SICStus -* re-export declaration. -* -* Revision 1.81 2007/11/26 23:43:09 vsc -* fixes to support threads and assert correctly, even if inefficiently. -* -* Revision 1.80 2007/11/07 09:35:53 vsc -* small fix -* -* Revision 1.79 2007/11/07 09:25:27 vsc -* speedup meta-calls -* -* Revision 1.78 2007/11/06 17:02:12 vsc -* compile ground terms away. -* -* Revision 1.77 2007/10/10 09:44:24 vsc -* some more fixes to make YAP swi compatible -* fix absolute_file_name (again) -* fix setarg -* -* Revision 1.76 2007/09/28 23:18:17 vsc -* handle learning from interpretations. -* -* Revision 1.75 2007/04/10 22:13:21 vsc -* fix max modules limitation -* -* Revision 1.74 2007/03/22 11:12:21 vsc -* make sure that YAP_Restart does not restart a failed goal. -* -* Revision 1.73 2007/02/18 00:26:36 vsc -* fix atom garbage collector (although it is still off by default) -* make valgrind feel better -* -* Revision 1.72 2007/01/08 08:27:19 vsc -* fix restore (Trevor) -* make indexing a bit faster on IDB -* -* Revision 1.71 2006/11/27 17:42:03 vsc -* support for UNICODE, and other bug fixes. -* -* Revision 1.70 2006/08/25 19:50:35 vsc -* global data structures -* -* Revision 1.69 2006/08/22 16:12:46 vsc -* global variables -* -* Revision 1.68 2006/08/02 18:18:30 vsc -* preliminary support for readutil library (SWI compatible). -* -* Revision 1.67 2006/05/17 18:38:11 vsc -* make system library use true file name -* -* Revision 1.66 2006/04/28 15:48:33 vsc -* do locking on streams -* -* Revision 1.65 2006/04/28 13:23:23 vsc -* fix number of overflow bugs affecting threaded version -* make current_op faster. -* -* Revision 1.64 2006/03/22 20:07:28 vsc -* take better care of zombies -* -* Revision 1.63 2006/03/06 14:04:56 vsc -* fixes to garbage collector -* fixes to debugger -* -* Revision 1.62 2006/02/24 14:03:42 vsc -* fix refs to old LogUpd implementation (pre 5). -* -* Revision 1.61 2006/01/02 02:16:18 vsc -* support new interface between YAP and GMP, so that we don't rely on our own -* allocation routines. -* Several big fixes. -* -* Revision 1.60 2005/12/17 03:25:39 vsc -* major changes to support online event-based profiling -* improve error discovery and restart on scanner. -* -* Revision 1.59 2005/12/05 17:16:11 vsc -* write_depth/3 -* overflow handlings and garbage collection -* Several ipdates to CLPBN -* dif/2 could be broken in the presence of attributed variables. -* -* Revision 1.58 2005/11/23 03:01:33 vsc -* fix several bugs in save/restore.b -* -* Revision 1.57 2005/10/28 17:38:50 vsc -* sveral updates -* -* Revision 1.56 2005/10/21 16:09:03 vsc -* SWI compatible module only operators -* -* Revision 1.55 2005/10/19 19:00:48 vsc -* extend arrays with nb_terms so that we can implement nb_ builtins -* correctly. -* -* Revision 1.54 2005/09/09 17:24:39 vsc -* a new and hopefully much better implementation of atts. -* -* Revision 1.53 2005/08/01 15:40:38 ricroc -* TABLING NEW: better support for incomplete tabling -* -* Revision 1.52 2005/07/06 19:34:11 ricroc -* TABLING: answers for completed calls can now be obtained by loading (new -*option) or executing (default) them from the trie data structure. -* -* Revision 1.51 2005/07/06 15:10:15 vsc -* improvements to compiler: merged instructions and fixes for -> -* -* Revision 1.50 2005/06/01 13:53:46 vsc -* improve bb routines to use the DB efficiently -* change interface between DB and BB. -* -* Revision 1.49 2005/05/30 03:26:37 vsc -* add some atom gc fixes -* -* Revision 1.48 2005/01/04 02:50:21 vsc -* - allow MegaClauses with blobs -* - change Diffs to be thread specific -* - include Christian's updates -* -* Revision 1.47 2004/12/02 06:06:47 vsc -* fix threads so that they at least start -* allow error handling to work with threads -* replace heap_base by Yap_heap_base, according to Yap's convention for globals. -* -* Revision 1.46 2004/11/23 21:16:21 vsc -* A few extra fixes for saved states. -* -* Revision 1.45 2004/10/26 20:16:18 vsc -* More bug fixes for overflow handling -* -* Revision 1.44 2004/10/06 16:55:47 vsc -* change configure to support big mem configs -* get rid of extra globals -* fix trouble with multifile preds -* -* Revision 1.43 2004/09/27 20:45:04 vsc -* Mega clauses -* Fixes to sizeof(expand_clauses) which was being overestimated -* Fixes to profiling+indexing -* Fixes to reallocation of memory after restoring -* Make sure all clauses, even for C, end in _Ystop -* Don't reuse space for Streams -* Fix Stream_F on StreaNo+1 -* -* Revision 1.42 2004/06/05 03:37:00 vsc -* coroutining is now a part of attvars. -* some more fixes. -* -* Revision 1.41 2004/04/29 03:45:50 vsc -* fix garbage collection in execute_tail -* -* Revision 1.40 2004/03/31 01:03:10 vsc -* support expand group of clauses -* -* Revision 1.39 2004/03/19 11:35:42 vsc -* trim_trail for default machine -* be more aggressive about try-retry-trust chains. -* - handle cases where block starts with a wait -* - don't use _killed instructions, just let the thing rot by itself. -* * -* * -*************************************************************************/ + * * + * YAP Prolog * + * * + * Yap Prolog was developed at NCCUP - Universidade do Porto * + * * + * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * + * * + ************************************************************************** + * * + * File: rheap.h * + * comments: walk through heap code * + * * + * Last rev: $Date: 2008-08-07 20:51:23 $,$Author: vsc $ + ** + * $Log: not supported by cvs2svn $ + * Revision 1.99 2008/07/22 23:34:49 vsc + * SWI and module fixes + * + * Revision 1.98 2008/05/12 22:31:37 vsc + * fix previous fixes + * + * Revision 1.97 2008/05/12 14:04:23 vsc + * updates to restore + * + * Revision 1.96 2008/04/11 16:58:17 ricroc + * yapor: seq_def initialization + * + * Revision 1.95 2008/04/06 12:06:48 vsc + * more small fixes + * + * Revision 1.94 2008/04/06 11:53:02 vsc + * fix some restore bugs + * + * Revision 1.93 2008/04/04 09:10:02 vsc + * restore was restoring twice + * + * Revision 1.92 2008/04/03 11:34:47 vsc + * fix restorebb in cases entry key is not an atom (obs from Nicos + * Angelopoulos) + * + * Revision 1.91 2008/04/01 15:31:43 vsc + * more saved state fixes + * + * Revision 1.90 2008/04/01 14:09:43 vsc + * improve restore + * + * Revision 1.89 2008/04/01 09:41:05 vsc + * more fixes to restore + * + * Revision 1.88 2008/04/01 08:42:46 vsc + * fix restore and small VISTA thingies + * + * Revision 1.87 2008/03/25 22:03:14 vsc + * fix some icc warnings + * + * Revision 1.86 2008/03/25 16:45:53 vsc + * make or-parallelism compile again + * + * Revision 1.85 2008/02/12 17:03:52 vsc + * SWI-portability changes + * + * Revision 1.84 2008/02/07 21:39:51 vsc + * fix case where predicate is for an integer (DBEntry). + * + * Revision 1.83 2008/01/23 17:57:55 vsc + * valgrind it! + * enable atom garbage collection. + * + * Revision 1.82 2007/12/05 12:17:23 vsc + * improve JT + * fix graph compatibility with SICStus + * re-export declaration. + * + * Revision 1.81 2007/11/26 23:43:09 vsc + * fixes to support threads and assert correctly, even if inefficiently. + * + * Revision 1.80 2007/11/07 09:35:53 vsc + * small fix + * + * Revision 1.79 2007/11/07 09:25:27 vsc + * speedup meta-calls + * + * Revision 1.78 2007/11/06 17:02:12 vsc + * compile ground terms away. + * + * Revision 1.77 2007/10/10 09:44:24 vsc + * some more fixes to make YAP swi compatible + * fix absolute_file_name (again) + * fix setarg + * + * Revision 1.76 2007/09/28 23:18:17 vsc + * handle learning from interpretations. + * + * Revision 1.75 2007/04/10 22:13:21 vsc + * fix max modules limitation + * + * Revision 1.74 2007/03/22 11:12:21 vsc + * make sure that YAP_Restart does not restart a failed goal. + * + * Revision 1.73 2007/02/18 00:26:36 vsc + * fix atom garbage collector (although it is still off by default) + * make valgrind feel better + * + * Revision 1.72 2007/01/08 08:27:19 vsc + * fix restore (Trevor) + * make indexing a bit faster on IDB + * + * Revision 1.71 2006/11/27 17:42:03 vsc + * support for UNICODE, and other bug fixes. + * + * Revision 1.70 2006/08/25 19:50:35 vsc + * global data structures + * + * Revision 1.69 2006/08/22 16:12:46 vsc + * global variables + * + * Revision 1.68 2006/08/02 18:18:30 vsc + * preliminary support for readutil library (SWI compatible). + * + * Revision 1.67 2006/05/17 18:38:11 vsc + * make system library use true file name + * + * Revision 1.66 2006/04/28 15:48:33 vsc + * do locking on streams + * + * Revision 1.65 2006/04/28 13:23:23 vsc + * fix number of overflow bugs affecting threaded version + * make current_op faster. + * + * Revision 1.64 2006/03/22 20:07:28 vsc + * take better care of zombies + * + * Revision 1.63 2006/03/06 14:04:56 vsc + * fixes to garbage collector + * fixes to debugger + * + * Revision 1.62 2006/02/24 14:03:42 vsc + * fix refs to old LogUpd implementation (pre 5). + * + * Revision 1.61 2006/01/02 02:16:18 vsc + * support new interface between YAP and GMP, so that we don't rely on our own + * allocation routines. + * Several big fixes. + * + * Revision 1.60 2005/12/17 03:25:39 vsc + * major changes to support online event-based profiling + * improve error discovery and restart on scanner. + * + * Revision 1.59 2005/12/05 17:16:11 vsc + * write_depth/3 + * overflow handlings and garbage collection + * Several ipdates to CLPBN + * dif/2 could be broken in the presence of attributed variables. + * + * Revision 1.58 2005/11/23 03:01:33 vsc + * fix several bugs in save/restore.b + * + * Revision 1.57 2005/10/28 17:38:50 vsc + * sveral updates + * + * Revision 1.56 2005/10/21 16:09:03 vsc + * SWI compatible module only operators + * + * Revision 1.55 2005/10/19 19:00:48 vsc + * extend arrays with nb_terms so that we can implement nb_ builtins + * correctly. + * + * Revision 1.54 2005/09/09 17:24:39 vsc + * a new and hopefully much better implementation of atts. + * + * Revision 1.53 2005/08/01 15:40:38 ricroc + * TABLING NEW: better support for incomplete tabling + * + * Revision 1.52 2005/07/06 19:34:11 ricroc + * TABLING: answers for completed calls can now be obtained by loading (new + *option) or executing (default) them from the trie data structure. + * + * Revision 1.51 2005/07/06 15:10:15 vsc + * improvements to compiler: merged instructions and fixes for -> + * + * Revision 1.50 2005/06/01 13:53:46 vsc + * improve bb routines to use the DB efficiently + * change interface between DB and BB. + * + * Revision 1.49 2005/05/30 03:26:37 vsc + * add some atom gc fixes + * + * Revision 1.48 2005/01/04 02:50:21 vsc + * - allow MegaClauses with blobs + * - change Diffs to be thread specific + * - include Christian's updates + * + * Revision 1.47 2004/12/02 06:06:47 vsc + * fix threads so that they at least start + * allow error handling to work with threads + * replace heap_base by Yap_heap_base, according to Yap's convention for + *globals. + * + * Revision 1.46 2004/11/23 21:16:21 vsc + * A few extra fixes for saved states. + * + * Revision 1.45 2004/10/26 20:16:18 vsc + * More bug fixes for overflow handling + * + * Revision 1.44 2004/10/06 16:55:47 vsc + * change configure to support big mem configs + * get rid of extra globals + * fix trouble with multifile preds + * + * Revision 1.43 2004/09/27 20:45:04 vsc + * Mega clauses + * Fixes to sizeof(expand_clauses) which was being overestimated + * Fixes to profiling+indexing + * Fixes to reallocation of memory after restoring + * Make sure all clauses, even for C, end in _Ystop + * Don't reuse space for Streams + * Fix Stream_F on StreaNo+1 + * + * Revision 1.42 2004/06/05 03:37:00 vsc + * coroutining is now a part of attvars. + * some more fixes. + * + * Revision 1.41 2004/04/29 03:45:50 vsc + * fix garbage collection in execute_tail + * + * Revision 1.40 2004/03/31 01:03:10 vsc + * support expand group of clauses + * + * Revision 1.39 2004/03/19 11:35:42 vsc + * trim_trail for default machine + * be more aggressive about try-retry-trust chains. + * - handle cases where block starts with a wait + * - don't use _killed instructions, just let the thing rot by itself. + * * + * * + *************************************************************************/ #ifdef SCCS static char SccsId[] = "@(#)rheap.c 1.3 3/15/90"; #endif +#ifndef RHEAP_H +#define RHEAP_H 1 + +#include "YapHeap.h" +#include "absmi.h" +#include "clause.h" + #define Atomics 0 #define Funcs 1 @@ -376,6 +384,7 @@ static void AdjustSwitchTable__(op_numbers op, yamop *table, startcode += 2; } /* adjust fail code */ + startcode[1] = (CELL)CodeAddrAdjust((CODEADDR)startcode[1]); } break; case _if_cons: { @@ -934,18 +943,10 @@ static void RestoreForeignCode__(USES_REGS1) { } } -static void RestoreBallTerm(int wid) { - CACHE_REGS - if (LOCAL_BallTerm) { - LOCAL_BallTerm = DBTermAdjust(LOCAL_BallTerm); - RestoreDBTerm(LOCAL_BallTerm, false, 1 PASS_REGS); - } -} static void RestoreYapRecords__(USES_REGS1) { struct record_list *ptr; - RestoreBallTerm(worker_id); Yap_Records = DBRecordAdjust(Yap_Records); ptr = Yap_Records; while (ptr) { @@ -1494,3 +1495,5 @@ static void RestoreAtom(AtomEntry *at USES_REGS) { if (nat) at->NextOfAE = AbsAtom(AtomEntryAdjust(nat)); } + +#endif diff --git a/H/saveclause.h b/H/saveclause.h index 8df1b2cea..0ed5273b6 100644 --- a/H/saveclause.h +++ b/H/saveclause.h @@ -78,6 +78,9 @@ case _call: case _call_cpred: case _call_usercpred: + case _dexecute: + case _execute: + case _execute_cpred: case _fcall: case _p_execute2: #ifdef YAPOR @@ -273,8 +276,6 @@ case _jump: case _jump_if_var: case _move_back: - case _p_dif: - case _p_eq: case _retry2: case _retry3: case _retry4: @@ -498,14 +499,6 @@ CHECK(save_Constant(stream, pc->y_u.plyys.flags)); pc = NEXTOP(pc,plyys); break; - /* instructions type pp */ - case _dexecute: - case _execute: - case _execute_cpred: - CHECK(save_PtoPred(stream, pc->y_u.pp.p)); - CHECK(save_PtoPred(stream, pc->y_u.pp.p0)); - pc = NEXTOP(pc,pp); - break; /* instructions type s */ case _cut: case _cut_e: diff --git a/H/sshift.h b/H/sshift.h index a64b83f6c..f4ebd2abd 100644 --- a/H/sshift.h +++ b/H/sshift.h @@ -15,9 +15,13 @@ * * *************************************************************************/ +#ifndef SSHIFT_H +#define SSHIFT_H + #define REINIT_LOCK(P) INIT_LOCK(P) #define REINIT_RWLOCK(P) INIT_RWLOCK(P) +#include #define CharP(ptr) ((char *) (ptr)) @@ -119,9 +123,9 @@ #define IsOldTokenTrailPtr(ptr) IsOldTokenTrailPtr__(ptr PASS_REGS) #include "inline-only.h" -INLINE_ONLY inline EXTERN int IsHeapP__ (CELL * CACHE_TYPE); +INLINE_ONLY int IsHeapP__ (CELL * CACHE_TYPE); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int IsHeapP__ (CELL * ptr USES_REGS) { #if USE_SYSTEM_MALLOC @@ -136,9 +140,9 @@ IsHeapP__ (CELL * ptr USES_REGS) /* Adjusting cells and pointers to cells */ -INLINE_ONLY inline EXTERN CELL *PtoGloAdjust__ (CELL * CACHE_TYPE); +INLINE_ONLY CELL *PtoGloAdjust__ (CELL * CACHE_TYPE); -INLINE_ONLY inline EXTERN CELL * +INLINE_ONLY CELL * PtoGloAdjust__ (CELL * ptr USES_REGS) { if (ptr < LOCAL_GSplit) { @@ -153,9 +157,9 @@ PtoGloAdjust__ (CELL * ptr USES_REGS) -INLINE_ONLY inline EXTERN CELL *PtoDelayAdjust__ (CELL * CACHE_TYPE); +INLINE_ONLY CELL *PtoDelayAdjust__ (CELL * CACHE_TYPE); -INLINE_ONLY inline EXTERN CELL * +INLINE_ONLY CELL * PtoDelayAdjust__ (CELL * ptr USES_REGS) { if (!LOCAL_GSplit || ptr < LOCAL_GSplit) @@ -164,9 +168,9 @@ PtoDelayAdjust__ (CELL * ptr USES_REGS) return (CELL *) (((CELL *) (CharP (ptr) + LOCAL_GDiff0))); } -INLINE_ONLY inline EXTERN CELL *PtoBaseAdjust__ (CELL * CACHE_TYPE); +INLINE_ONLY CELL *PtoBaseAdjust__ (CELL * CACHE_TYPE); -INLINE_ONLY inline EXTERN CELL * +INLINE_ONLY CELL * PtoBaseAdjust__ (CELL * ptr USES_REGS) { return (CELL *) (((CELL *) (CharP (ptr) + LOCAL_BaseDiff))); @@ -174,9 +178,9 @@ PtoBaseAdjust__ (CELL * ptr USES_REGS) -INLINE_ONLY inline EXTERN tr_fr_ptr PtoTRAdjust__ (tr_fr_ptr CACHE_TYPE); +INLINE_ONLY tr_fr_ptr PtoTRAdjust__ (tr_fr_ptr CACHE_TYPE); -INLINE_ONLY inline EXTERN tr_fr_ptr +INLINE_ONLY tr_fr_ptr PtoTRAdjust__ (tr_fr_ptr ptr USES_REGS) { return (tr_fr_ptr) (((tr_fr_ptr) (CharP (ptr) + LOCAL_TrDiff))); @@ -184,9 +188,9 @@ PtoTRAdjust__ (tr_fr_ptr ptr USES_REGS) -INLINE_ONLY inline EXTERN CELL *CellPtoTRAdjust__ (CELL * CACHE_TYPE); +INLINE_ONLY CELL *CellPtoTRAdjust__ (CELL * CACHE_TYPE); -INLINE_ONLY inline EXTERN CELL * +INLINE_ONLY CELL * CellPtoTRAdjust__ (CELL * ptr USES_REGS) { return (CELL *) (((CELL *) (CharP (ptr) + LOCAL_TrDiff))); @@ -194,18 +198,18 @@ CellPtoTRAdjust__ (CELL * ptr USES_REGS) -INLINE_ONLY inline EXTERN CELL *PtoLocAdjust__ (CELL * CACHE_TYPE); +INLINE_ONLY CELL *PtoLocAdjust__ (CELL * CACHE_TYPE); -INLINE_ONLY inline EXTERN CELL * +INLINE_ONLY CELL * PtoLocAdjust__ (CELL * ptr USES_REGS) { return (CELL *) (((CELL *) (CharP (ptr) + LOCAL_LDiff))); } -INLINE_ONLY inline EXTERN struct cut_c_str *CutCAdjust__ (struct cut_c_str * CACHE_TYPE); +INLINE_ONLY struct cut_c_str *CutCAdjust__ (struct cut_c_str * CACHE_TYPE); -INLINE_ONLY inline EXTERN struct cut_c_str * +INLINE_ONLY struct cut_c_str * CutCAdjust__ (struct cut_c_str * ptr USES_REGS) { return (struct cut_c_str *) (CharP (ptr) + LOCAL_LDiff); @@ -213,9 +217,9 @@ CutCAdjust__ (struct cut_c_str * ptr USES_REGS) -INLINE_ONLY inline EXTERN choiceptr ChoicePtrAdjust__ (choiceptr CACHE_TYPE); +INLINE_ONLY choiceptr ChoicePtrAdjust__ (choiceptr CACHE_TYPE); -INLINE_ONLY inline EXTERN choiceptr +INLINE_ONLY choiceptr ChoicePtrAdjust__ (choiceptr ptr USES_REGS) { return (choiceptr) (((choiceptr) (CharP (ptr) + LOCAL_LDiff))); @@ -224,9 +228,9 @@ ChoicePtrAdjust__ (choiceptr ptr USES_REGS) #ifdef TABLING -INLINE_ONLY inline EXTERN choiceptr ConsumerChoicePtrAdjust__ (choiceptr CACHE_TYPE); +INLINE_ONLY choiceptr ConsumerChoicePtrAdjust__ (choiceptr CACHE_TYPE); -INLINE_ONLY inline EXTERN choiceptr +INLINE_ONLY choiceptr ConsumerChoicePtrAdjust__ (choiceptr ptr USES_REGS) { return (choiceptr) (((choiceptr) (CharP (ptr) + LOCAL_LDiff))); @@ -234,9 +238,9 @@ ConsumerChoicePtrAdjust__ (choiceptr ptr USES_REGS) -INLINE_ONLY inline EXTERN choiceptr GeneratorChoicePtrAdjust__ (choiceptr CACHE_TYPE); +INLINE_ONLY choiceptr GeneratorChoicePtrAdjust__ (choiceptr CACHE_TYPE); -INLINE_ONLY inline EXTERN choiceptr +INLINE_ONLY choiceptr GeneratorChoicePtrAdjust__ (choiceptr ptr USES_REGS) { return (choiceptr) (((choiceptr) (CharP (ptr) + LOCAL_LDiff))); @@ -246,9 +250,9 @@ GeneratorChoicePtrAdjust__ (choiceptr ptr USES_REGS) #endif /* TABLING */ -INLINE_ONLY inline EXTERN CELL GlobalAdjust__ (CELL CACHE_TYPE); +INLINE_ONLY CELL GlobalAdjust__ (CELL CACHE_TYPE); -INLINE_ONLY inline EXTERN CELL +INLINE_ONLY CELL GlobalAdjust__ (CELL val USES_REGS) { if ((CELL *)val < LOCAL_GSplit) { @@ -263,9 +267,9 @@ GlobalAdjust__ (CELL val USES_REGS) -INLINE_ONLY inline EXTERN CELL DelayAdjust__ (CELL CACHE_TYPE); +INLINE_ONLY CELL DelayAdjust__ (CELL CACHE_TYPE); -INLINE_ONLY inline EXTERN CELL +INLINE_ONLY CELL DelayAdjust__ (CELL val USES_REGS) { if (!LOCAL_GSplit || (CELL *)val < LOCAL_GSplit) @@ -275,9 +279,9 @@ DelayAdjust__ (CELL val USES_REGS) } -INLINE_ONLY inline EXTERN ADDR GlobalAddrAdjust__ (ADDR CACHE_TYPE); +INLINE_ONLY ADDR GlobalAddrAdjust__ (ADDR CACHE_TYPE); -INLINE_ONLY inline EXTERN ADDR +INLINE_ONLY ADDR GlobalAddrAdjust__ (ADDR ptr USES_REGS) { if ((CELL *)ptr < LOCAL_GSplit) { @@ -293,9 +297,9 @@ GlobalAddrAdjust__ (ADDR ptr USES_REGS) -INLINE_ONLY inline EXTERN ADDR DelayAddrAdjust__ (ADDR CACHE_TYPE); +INLINE_ONLY ADDR DelayAddrAdjust__ (ADDR CACHE_TYPE); -INLINE_ONLY inline EXTERN ADDR +INLINE_ONLY ADDR DelayAddrAdjust__ (ADDR ptr USES_REGS) { if (!LOCAL_GSplit || (CELL *)ptr < LOCAL_GSplit) @@ -305,9 +309,9 @@ DelayAddrAdjust__ (ADDR ptr USES_REGS) } -INLINE_ONLY inline EXTERN ADDR BaseAddrAdjust__ (ADDR CACHE_TYPE); +INLINE_ONLY ADDR BaseAddrAdjust__ (ADDR CACHE_TYPE); -INLINE_ONLY inline EXTERN ADDR +INLINE_ONLY ADDR BaseAddrAdjust__ (ADDR ptr USES_REGS) { return (ADDR) ((ptr + LOCAL_BaseDiff)); @@ -315,9 +319,9 @@ BaseAddrAdjust__ (ADDR ptr USES_REGS) -INLINE_ONLY inline EXTERN CELL LocalAdjust__ (CELL CACHE_TYPE); +INLINE_ONLY CELL LocalAdjust__ (CELL CACHE_TYPE); -INLINE_ONLY inline EXTERN CELL +INLINE_ONLY CELL LocalAdjust__ (CELL val USES_REGS) { return (CELL) ((val + LOCAL_LDiff)); @@ -325,9 +329,9 @@ LocalAdjust__ (CELL val USES_REGS) -INLINE_ONLY inline EXTERN ADDR LocalAddrAdjust__ (ADDR CACHE_TYPE); +INLINE_ONLY ADDR LocalAddrAdjust__ (ADDR CACHE_TYPE); -INLINE_ONLY inline EXTERN ADDR +INLINE_ONLY ADDR LocalAddrAdjust__ (ADDR ptr USES_REGS) { return (ADDR) ((ptr + LOCAL_LDiff)); @@ -335,9 +339,9 @@ LocalAddrAdjust__ (ADDR ptr USES_REGS) -INLINE_ONLY inline EXTERN CELL TrailAdjust__ (CELL CACHE_TYPE); +INLINE_ONLY CELL TrailAdjust__ (CELL CACHE_TYPE); -INLINE_ONLY inline EXTERN CELL +INLINE_ONLY CELL TrailAdjust__ (CELL val USES_REGS) { return (CELL) ((val + LOCAL_TrDiff)); @@ -345,9 +349,9 @@ TrailAdjust__ (CELL val USES_REGS) -INLINE_ONLY inline EXTERN ADDR TrailAddrAdjust__ (ADDR CACHE_TYPE); +INLINE_ONLY ADDR TrailAddrAdjust__ (ADDR CACHE_TYPE); -INLINE_ONLY inline EXTERN ADDR +INLINE_ONLY ADDR TrailAddrAdjust__ (ADDR ptr USES_REGS) { return (ADDR) ((ptr + LOCAL_TrDiff)); @@ -355,9 +359,9 @@ TrailAddrAdjust__ (ADDR ptr USES_REGS) -INLINE_ONLY inline EXTERN TokEntry *TokEntryAdjust__ (TokEntry * CACHE_TYPE); +INLINE_ONLY TokEntry *TokEntryAdjust__ (TokEntry * CACHE_TYPE); -INLINE_ONLY inline EXTERN TokEntry * +INLINE_ONLY TokEntry * TokEntryAdjust__ (TokEntry * ptr USES_REGS) { return (TokEntry *) (((CELL) ptr + LOCAL_TrDiff)); @@ -365,9 +369,9 @@ TokEntryAdjust__ (TokEntry * ptr USES_REGS) -INLINE_ONLY inline EXTERN VarEntry *VarEntryAdjust__ (VarEntry * CACHE_TYPE); +INLINE_ONLY VarEntry *VarEntryAdjust__ (VarEntry * CACHE_TYPE); -INLINE_ONLY inline EXTERN VarEntry * +INLINE_ONLY VarEntry * VarEntryAdjust__ (VarEntry * ptr USES_REGS) { return (VarEntry *) (((CELL) ptr + LOCAL_TrDiff)); @@ -376,9 +380,9 @@ VarEntryAdjust__ (VarEntry * ptr USES_REGS) /* heap data structures */ -INLINE_ONLY inline EXTERN Functor FuncAdjust__ (Functor CACHE_TYPE); +INLINE_ONLY Functor FuncAdjust__ (Functor CACHE_TYPE); -INLINE_ONLY inline EXTERN Functor +INLINE_ONLY Functor FuncAdjust__ (Functor f USES_REGS) { if (!IsExtensionFunctor(f)) @@ -386,9 +390,9 @@ FuncAdjust__ (Functor f USES_REGS) return f; } -INLINE_ONLY inline EXTERN CELL *CellPtoHeapAdjust__ (CELL * CACHE_TYPE); +INLINE_ONLY CELL *CellPtoHeapAdjust__ (CELL * CACHE_TYPE); -INLINE_ONLY inline EXTERN CELL * +INLINE_ONLY CELL * CellPtoHeapAdjust__ (CELL * ptr USES_REGS) { if (!ptr) @@ -396,17 +400,17 @@ CellPtoHeapAdjust__ (CELL * ptr USES_REGS) return (CELL *) (((CELL *) (CharP (ptr) + LOCAL_HDiff))); } -INLINE_ONLY inline EXTERN HoldEntry *HoldEntryAdjust__ (HoldEntry * CACHE_TYPE); +INLINE_ONLY HoldEntry *HoldEntryAdjust__ (HoldEntry * CACHE_TYPE); -INLINE_ONLY inline EXTERN HoldEntry * +INLINE_ONLY HoldEntry * HoldEntryAdjust__ (HoldEntry * ptr USES_REGS) { return (HoldEntry *) (((HoldEntry *) (CharP (ptr) + LOCAL_HDiff))); } -INLINE_ONLY inline EXTERN struct record_list *DBRecordAdjust__ (struct record_list * CACHE_TYPE); +INLINE_ONLY struct record_list *DBRecordAdjust__ (struct record_list * CACHE_TYPE); -INLINE_ONLY inline EXTERN struct record_list * +INLINE_ONLY struct record_list * DBRecordAdjust__ (struct record_list * ptr USES_REGS) { if (!ptr) @@ -417,17 +421,17 @@ DBRecordAdjust__ (struct record_list * ptr USES_REGS) #if USE_OFFSETS -INLINE_ONLY inline EXTERN Atom AtomAdjust__ (Atom CACHE_TYPE); +INLINE_ONLY Atom AtomAdjust__ (Atom CACHE_TYPE); -INLINE_ONLY inline EXTERN Atom +INLINE_ONLY Atom AtomAdjust__ (Atom at USES_REGS) { return (Atom) ((at)); } -INLINE_ONLY inline EXTERN Atom NoAGCAtomAdjust__ (Atom CACHE_TYPE); +INLINE_ONLY Atom NoAGCAtomAdjust__ (Atom CACHE_TYPE); -INLINE_ONLY inline EXTERN Atom +INLINE_ONLY Atom NoAGCAtomAdjust__ (Atom at USES_REGS) { return (Atom) ((at)); @@ -435,9 +439,9 @@ NoAGCAtomAdjust__ (Atom at USES_REGS) -INLINE_ONLY inline EXTERN Prop PropAdjust__ (Prop CACHE_TYPE); +INLINE_ONLY Prop PropAdjust__ (Prop CACHE_TYPE); -INLINE_ONLY inline EXTERN Prop +INLINE_ONLY Prop PropAdjust__ (Prop p USES_REGS) { return (Prop) ((p)); @@ -445,27 +449,25 @@ PropAdjust__ (Prop p USES_REGS) #else -INLINE_ONLY inline EXTERN Atom AtomAdjust__ (Atom CACHE_TYPE); +INLINE_ONLY Atom AtomAdjust__ (Atom CACHE_TYPE); -INLINE_ONLY inline EXTERN Atom +INLINE_ONLY Atom AtomAdjust__ (Atom at USES_REGS) { return (Atom) ((at == NULL ? (at) : (Atom) (CharP (at) + LOCAL_HDiff))); } -INLINE_ONLY inline EXTERN Atom NoAGCAtomAdjust__ (Atom CACHE_TYPE); +INLINE_ONLY Atom NoAGCAtomAdjust__ (Atom CACHE_TYPE); -INLINE_ONLY inline EXTERN Atom +INLINE_ONLY Atom NoAGCAtomAdjust__ (Atom at USES_REGS) { return (Atom) ((at == NULL ? (at) : (Atom) (CharP (at) + LOCAL_HDiff))); } +INLINE_ONLY Prop PropAdjust__ (Prop CACHE_TYPE); - -INLINE_ONLY inline EXTERN Prop PropAdjust__ (Prop CACHE_TYPE); - -INLINE_ONLY inline EXTERN Prop +INLINE_ONLY Prop PropAdjust__ (Prop p USES_REGS) { return (Prop) ((p == NULL ? (p) : (Prop) (CharP (p) + LOCAL_HDiff))); @@ -474,49 +476,49 @@ PropAdjust__ (Prop p USES_REGS) #endif -INLINE_ONLY inline EXTERN struct YAP_blob_t *BlobTypeAdjust__ (struct YAP_blob_t *CACHE_TYPE); +INLINE_ONLY YAP_blob_t *BlobTypeAdjust__ (YAP_blob_t *CACHE_TYPE); -INLINE_ONLY inline EXTERN struct YAP_blob_t * -BlobTypeAdjust__ (struct YAP_blob_t *at USES_REGS) +INLINE_ONLY YAP_blob_t * +BlobTypeAdjust__ ( YAP_blob_t *at USES_REGS) { - return (struct YAP_blob_t *) ((at == NULL ? (at) : (struct YAP_blob_t *) (CharP (at) + LOCAL_HDiff))); + return ( YAP_blob_t *) ((at == NULL ? (at) : ( YAP_blob_t *) (CharP (at) + LOCAL_HDiff))); } -INLINE_ONLY inline EXTERN PredEntry *PredEntryAdjust__ (PredEntry * CACHE_TYPE); +INLINE_ONLY PredEntry *PredEntryAdjust__ (PredEntry * CACHE_TYPE); -INLINE_ONLY inline EXTERN PredEntry * +INLINE_ONLY PredEntry * PredEntryAdjust__ (PredEntry *p USES_REGS) { return (PredEntry *) ((p == NULL ? (p) : (PredEntry *) (CharP (p) + LOCAL_HDiff))); } -INLINE_ONLY inline EXTERN struct mod_entry *ModEntryPtrAdjust__ (struct mod_entry * CACHE_TYPE); +INLINE_ONLY struct mod_entry *ModEntryPtrAdjust__ (struct mod_entry * CACHE_TYPE); -INLINE_ONLY inline EXTERN struct mod_entry * +INLINE_ONLY struct mod_entry * ModEntryPtrAdjust__ (struct mod_entry *p USES_REGS) { return (struct mod_entry *) ((p == NULL ? (p) : (struct mod_entry *) (CharP (p) + LOCAL_HDiff))); } -INLINE_ONLY inline EXTERN COUNT ConstantAdjust__ (COUNT CACHE_TYPE); +INLINE_ONLY COUNT ConstantAdjust__ (COUNT CACHE_TYPE); -INLINE_ONLY inline EXTERN COUNT +INLINE_ONLY COUNT ConstantAdjust__ (COUNT val USES_REGS) { return val; } -INLINE_ONLY inline EXTERN Int ArityAdjust__ (Int CACHE_TYPE); +INLINE_ONLY Int ArityAdjust__ (Int CACHE_TYPE); -INLINE_ONLY inline EXTERN Int +INLINE_ONLY Int ArityAdjust__ (Int val USES_REGS) { return val; } -INLINE_ONLY inline EXTERN OPCODE OpcodeAdjust__ (OPCODE CACHE_TYPE); +INLINE_ONLY OPCODE OpcodeAdjust__ (OPCODE CACHE_TYPE); -INLINE_ONLY inline EXTERN OPCODE +INLINE_ONLY OPCODE OpcodeAdjust__ (OPCODE val USES_REGS) { return Yap_opcode(Yap_op_from_opcode(val)); @@ -530,9 +532,9 @@ OpcodeAdjust__ (OPCODE val USES_REGS) #define ExternalFunctionAdjust(D) (D); -INLINE_ONLY inline EXTERN Term AtomTermAdjust__ (Term CACHE_TYPE); +INLINE_ONLY Term AtomTermAdjust__ (Term CACHE_TYPE); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term AtomTermAdjust__ (Term at USES_REGS) { if (at == 0L) @@ -540,17 +542,17 @@ AtomTermAdjust__ (Term at USES_REGS) return (Term)(CharP(at) + LOCAL_HDiff); } -INLINE_ONLY inline EXTERN Term ModuleAdjust__ (Term CACHE_TYPE); +INLINE_ONLY Term ModuleAdjust__ (Term CACHE_TYPE); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term ModuleAdjust__ (Term t USES_REGS) { return AtomTermAdjust(t); } -INLINE_ONLY inline EXTERN Term CodeVarAdjust__ (Term CACHE_TYPE); +INLINE_ONLY Term CodeVarAdjust__ (Term CACHE_TYPE); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term CodeVarAdjust__ (Term var USES_REGS) { if (var == 0L) @@ -561,18 +563,18 @@ CodeVarAdjust__ (Term var USES_REGS) #if TAGS_FAST_OPS -INLINE_ONLY inline EXTERN Term BlobTermInCodeAdjust__ (Term CACHE_TYPE); +INLINE_ONLY Term BlobTermInCodeAdjust__ (Term CACHE_TYPE); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term BlobTermInCodeAdjust__ (Term t USES_REGS) { return (Term) (CharP(t) - LOCAL_HDiff); } -INLINE_ONLY inline EXTERN Term CodeComposedTermAdjust__ (Term CACHE_TYPE); +INLINE_ONLY Term CodeComposedTermAdjust__ (Term CACHE_TYPE); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term CodeComposedTermAdjust__ (Term t USES_REGS) { return (Term) (CharP(t) - LOCAL_HDiff); @@ -581,17 +583,17 @@ CodeComposedTermAdjust__ (Term t USES_REGS) #else -INLINE_ONLY inline EXTERN Term BlobTermInCodeAdjust__ (Term CACHE_TYPE); +INLINE_ONLY Term BlobTermInCodeAdjust__ (Term CACHE_TYPE); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term BlobTermInCodeAdjust__ (Term t USES_REGS) { return (Term) (CharP(t) + LOCAL_HDiff); } -INLINE_ONLY inline EXTERN Term CodeComposedTermAdjust__ (Term CACHE_TYPE); +INLINE_ONLY Term CodeComposedTermAdjust__ (Term CACHE_TYPE); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term CodeComposedTermAdjust__ (Term t USES_REGS) { return (Term) (CharP(t) + LOCAL_HDiff); @@ -600,17 +602,17 @@ CodeComposedTermAdjust__ (Term t USES_REGS) #endif -INLINE_ONLY inline EXTERN AtomEntry *AtomEntryAdjust__ (AtomEntry * CACHE_TYPE); +INLINE_ONLY AtomEntry *AtomEntryAdjust__ (AtomEntry * CACHE_TYPE); -INLINE_ONLY inline EXTERN AtomEntry * +INLINE_ONLY AtomEntry * AtomEntryAdjust__ (AtomEntry * at USES_REGS) { return (AtomEntry *) ((AtomEntry *) (CharP (at) + LOCAL_HDiff)); } -INLINE_ONLY inline EXTERN GlobalEntry *GlobalEntryAdjust__ (GlobalEntry * CACHE_TYPE); +INLINE_ONLY GlobalEntry *GlobalEntryAdjust__ (GlobalEntry * CACHE_TYPE); -INLINE_ONLY inline EXTERN GlobalEntry * +INLINE_ONLY GlobalEntry * GlobalEntryAdjust__ (GlobalEntry * at USES_REGS) { return (GlobalEntry *) ((GlobalEntry *) (CharP (at) + LOCAL_HDiff)); @@ -618,9 +620,9 @@ GlobalEntryAdjust__ (GlobalEntry * at USES_REGS) -INLINE_ONLY inline EXTERN union CONSULT_OBJ *ConsultObjAdjust__ (union CONSULT_OBJ * CACHE_TYPE); +INLINE_ONLY union CONSULT_OBJ *ConsultObjAdjust__ (union CONSULT_OBJ * CACHE_TYPE); -INLINE_ONLY inline EXTERN union CONSULT_OBJ * +INLINE_ONLY union CONSULT_OBJ * ConsultObjAdjust__ (union CONSULT_OBJ *co USES_REGS) { return (union CONSULT_OBJ *) ((union CONSULT_OBJ *) (CharP (co) + LOCAL_HDiff)); @@ -628,9 +630,9 @@ ConsultObjAdjust__ (union CONSULT_OBJ *co USES_REGS) -INLINE_ONLY inline EXTERN DBRef DBRefAdjust__ (DBRef CACHE_TYPE); +INLINE_ONLY DBRef DBRefAdjust__ (DBRef CACHE_TYPE); -INLINE_ONLY inline EXTERN DBRef +INLINE_ONLY DBRef DBRefAdjust__ (DBRef dbr USES_REGS) { return (DBRef) ((DBRef) (CharP (dbr) + LOCAL_HDiff)); @@ -638,9 +640,9 @@ DBRefAdjust__ (DBRef dbr USES_REGS) -INLINE_ONLY inline EXTERN DBRef *DBRefPAdjust__ (DBRef * CACHE_TYPE); +INLINE_ONLY DBRef *DBRefPAdjust__ (DBRef * CACHE_TYPE); -INLINE_ONLY inline EXTERN DBRef * +INLINE_ONLY DBRef * DBRefPAdjust__ (DBRef * dbrp USES_REGS) { return (DBRef *) ((DBRef *) (CharP (dbrp) + LOCAL_HDiff)); @@ -648,9 +650,9 @@ DBRefPAdjust__ (DBRef * dbrp USES_REGS) -INLINE_ONLY inline EXTERN DBTerm *DBTermAdjust__ (DBTerm * CACHE_TYPE); +INLINE_ONLY DBTerm *DBTermAdjust__ (DBTerm * CACHE_TYPE); -INLINE_ONLY inline EXTERN DBTerm * +INLINE_ONLY DBTerm * DBTermAdjust__ (DBTerm * dbtp USES_REGS) { return (DBTerm *) ((DBTerm *) (CharP (dbtp) + LOCAL_HDiff)); @@ -658,9 +660,9 @@ DBTermAdjust__ (DBTerm * dbtp USES_REGS) -INLINE_ONLY inline EXTERN struct static_index *SIndexAdjust__ (struct static_index * CACHE_TYPE); +INLINE_ONLY struct static_index *SIndexAdjust__ (struct static_index * CACHE_TYPE); -INLINE_ONLY inline EXTERN struct static_index * +INLINE_ONLY struct static_index * SIndexAdjust__ (struct static_index *si USES_REGS) { return (struct static_index @@ -669,11 +671,11 @@ SIndexAdjust__ (struct static_index *si USES_REGS) -INLINE_ONLY inline EXTERN +INLINE_ONLY struct logic_upd_index *LUIndexAdjust__ (struct logic_upd_index * CACHE_TYPE); -INLINE_ONLY inline EXTERN struct logic_upd_index * +INLINE_ONLY struct logic_upd_index * LUIndexAdjust__ (struct logic_upd_index *lui USES_REGS) { return (struct logic_upd_index @@ -682,9 +684,9 @@ LUIndexAdjust__ (struct logic_upd_index *lui USES_REGS) -INLINE_ONLY inline EXTERN Term CodeAdjust__ (Term CACHE_TYPE); +INLINE_ONLY Term CodeAdjust__ (Term CACHE_TYPE); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term CodeAdjust__ (Term dbr USES_REGS) { return (Term) (CharP(dbr) + LOCAL_HDiff); @@ -692,9 +694,9 @@ CodeAdjust__ (Term dbr USES_REGS) -INLINE_ONLY inline EXTERN ADDR AddrAdjust__ (ADDR CACHE_TYPE); +INLINE_ONLY ADDR AddrAdjust__ (ADDR CACHE_TYPE); -INLINE_ONLY inline EXTERN ADDR +INLINE_ONLY ADDR AddrAdjust__ (ADDR addr USES_REGS) { return (ADDR) ((ADDR) (CharP (addr) + LOCAL_HDiff)); @@ -702,18 +704,18 @@ AddrAdjust__ (ADDR addr USES_REGS) -INLINE_ONLY inline EXTERN CODEADDR CodeAddrAdjust__ (CODEADDR CACHE_TYPE); +INLINE_ONLY CODEADDR CodeAddrAdjust__ (CODEADDR CACHE_TYPE); -INLINE_ONLY inline EXTERN CODEADDR +INLINE_ONLY CODEADDR CodeAddrAdjust__ (CODEADDR addr USES_REGS) { return (CODEADDR) ((CODEADDR) (CharP (addr) + LOCAL_HDiff)); } -INLINE_ONLY inline EXTERN char * CodeCharPAdjust__ (char * CACHE_TYPE); +INLINE_ONLY char * CodeCharPAdjust__ (char * CACHE_TYPE); -INLINE_ONLY inline EXTERN char * +INLINE_ONLY char * CodeCharPAdjust__ (char * addr USES_REGS) { if (!addr) @@ -721,9 +723,9 @@ CodeCharPAdjust__ (char * addr USES_REGS) return addr + LOCAL_HDiff; } -INLINE_ONLY inline EXTERN const char * CodeConstCharPAdjust__ (const char * CACHE_TYPE); +INLINE_ONLY const char * CodeConstCharPAdjust__ (const char * CACHE_TYPE); -INLINE_ONLY inline EXTERN const char * +INLINE_ONLY const char * CodeConstCharPAdjust__ (const char * addr USES_REGS) { if (!addr) @@ -731,9 +733,9 @@ CodeConstCharPAdjust__ (const char * addr USES_REGS) return addr + LOCAL_HDiff; } -INLINE_ONLY inline EXTERN void * CodeVoidPAdjust__ (void * CACHE_TYPE); +INLINE_ONLY void * CodeVoidPAdjust__ (void * CACHE_TYPE); -INLINE_ONLY inline EXTERN void * +INLINE_ONLY void * CodeVoidPAdjust__ (void * addr USES_REGS) { if (!addr) @@ -741,9 +743,9 @@ CodeVoidPAdjust__ (void * addr USES_REGS) return (void *)((char *)addr + LOCAL_HDiff); } -INLINE_ONLY inline EXTERN struct halt_hook *HaltHookAdjust__ (struct halt_hook * CACHE_TYPE); +INLINE_ONLY struct halt_hook *HaltHookAdjust__ (struct halt_hook * CACHE_TYPE); -INLINE_ONLY inline EXTERN struct halt_hook * +INLINE_ONLY struct halt_hook * HaltHookAdjust__ (struct halt_hook * addr USES_REGS) { if (!addr) @@ -751,17 +753,17 @@ HaltHookAdjust__ (struct halt_hook * addr USES_REGS) return (struct halt_hook *) (CharP (addr) + LOCAL_HDiff); } -INLINE_ONLY inline EXTERN BlockHeader *BlockAdjust__ (BlockHeader * CACHE_TYPE); +INLINE_ONLY BlockHeader *BlockAdjust__ (BlockHeader * CACHE_TYPE); -INLINE_ONLY inline EXTERN BlockHeader * +INLINE_ONLY BlockHeader * BlockAdjust__ (BlockHeader * addr USES_REGS) { return (BlockHeader *) ((BlockHeader *) (CharP (addr) + LOCAL_HDiff)); } -INLINE_ONLY inline EXTERN yamop *PtoOpAdjust__ (yamop * CACHE_TYPE); +INLINE_ONLY yamop *PtoOpAdjust__ (yamop * CACHE_TYPE); -INLINE_ONLY inline EXTERN yamop * +INLINE_ONLY yamop * PtoOpAdjust__ (yamop * ptr USES_REGS) { if (ptr) @@ -769,9 +771,9 @@ PtoOpAdjust__ (yamop * ptr USES_REGS) return ptr; } -INLINE_ONLY inline EXTERN struct operator_entry *OpListAdjust__ (struct operator_entry * CACHE_TYPE); +INLINE_ONLY struct operator_entry *OpListAdjust__ (struct operator_entry * CACHE_TYPE); -INLINE_ONLY inline EXTERN struct operator_entry * +INLINE_ONLY struct operator_entry * OpListAdjust__ (struct operator_entry * ptr USES_REGS) { if (!ptr) @@ -780,17 +782,17 @@ OpListAdjust__ (struct operator_entry * ptr USES_REGS) } -INLINE_ONLY inline EXTERN struct logic_upd_clause *PtoLUClauseAdjust__ (struct logic_upd_clause * CACHE_TYPE); +INLINE_ONLY struct logic_upd_clause *PtoLUClauseAdjust__ (struct logic_upd_clause * CACHE_TYPE); -INLINE_ONLY inline EXTERN struct logic_upd_clause * +INLINE_ONLY struct logic_upd_clause * PtoLUClauseAdjust__ (struct logic_upd_clause * ptr USES_REGS) { return (struct logic_upd_clause *) (CharP (ptr) + LOCAL_HDiff); } -INLINE_ONLY inline EXTERN struct logic_upd_index *PtoLUIndexAdjust__ (struct logic_upd_index * CACHE_TYPE); +INLINE_ONLY struct logic_upd_index *PtoLUIndexAdjust__ (struct logic_upd_index * CACHE_TYPE); -INLINE_ONLY inline EXTERN struct logic_upd_index * +INLINE_ONLY struct logic_upd_index * PtoLUIndexAdjust__ (struct logic_upd_index * ptr USES_REGS) { return (struct logic_upd_index *) (CharP (ptr) + LOCAL_HDiff); @@ -798,25 +800,25 @@ PtoLUIndexAdjust__ (struct logic_upd_index * ptr USES_REGS) -INLINE_ONLY inline EXTERN CELL *PtoHeapCellAdjust__ (CELL * CACHE_TYPE); +INLINE_ONLY CELL *PtoHeapCellAdjust__ (CELL * CACHE_TYPE); -INLINE_ONLY inline EXTERN CELL * +INLINE_ONLY CELL * PtoHeapCellAdjust__ (CELL * ptr USES_REGS) { return (CELL *) (((CELL *) (CharP (ptr) + LOCAL_HDiff))); } -INLINE_ONLY inline EXTERN AtomHashEntry *PtoAtomHashEntryAdjust__ (AtomHashEntry * CACHE_TYPE); +INLINE_ONLY AtomHashEntry *PtoAtomHashEntryAdjust__ (AtomHashEntry * CACHE_TYPE); -INLINE_ONLY inline EXTERN AtomHashEntry * +INLINE_ONLY AtomHashEntry * PtoAtomHashEntryAdjust__ (AtomHashEntry * ptr USES_REGS) { return (AtomHashEntry *) (((AtomHashEntry *) (CharP (ptr) + LOCAL_HDiff))); } -INLINE_ONLY inline EXTERN Term TermToGlobalAdjust__ (Term CACHE_TYPE); +INLINE_ONLY Term TermToGlobalAdjust__ (Term CACHE_TYPE); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term TermToGlobalAdjust__ (Term t USES_REGS) { if (t == 0L) @@ -824,9 +826,9 @@ TermToGlobalAdjust__ (Term t USES_REGS) return AbsAppl(PtoGloAdjust(RepAppl(t))); } -INLINE_ONLY inline EXTERN Term TermToGlobalOrAtomAdjust__ (Term CACHE_TYPE); +INLINE_ONLY Term TermToGlobalOrAtomAdjust__ (Term CACHE_TYPE); -INLINE_ONLY inline EXTERN Term +INLINE_ONLY Term TermToGlobalOrAtomAdjust__ (Term t USES_REGS) { if (t == 0L) @@ -842,9 +844,9 @@ TermToGlobalOrAtomAdjust__ (Term t USES_REGS) #if USE_THREADED_CODE -INLINE_ONLY inline EXTERN op_entry *OpRTableAdjust__ (op_entry * CACHE_TYPE); +INLINE_ONLY op_entry *OpRTableAdjust__ (op_entry * CACHE_TYPE); -INLINE_ONLY inline EXTERN op_entry * +INLINE_ONLY op_entry * OpRTableAdjust__ (op_entry * ptr USES_REGS) { return (op_entry *) (((op_entry *) (CharP (ptr) + LOCAL_HDiff))); @@ -852,25 +854,25 @@ OpRTableAdjust__ (op_entry * ptr USES_REGS) #endif // USE_THREADED_CODE -INLINE_ONLY inline EXTERN OpEntry *OpEntryAdjust__ (OpEntry * CACHE_TYPE); +INLINE_ONLY OpEntry *OpEntryAdjust__ (OpEntry * CACHE_TYPE); -INLINE_ONLY inline EXTERN OpEntry * +INLINE_ONLY OpEntry * OpEntryAdjust__ (OpEntry * ptr USES_REGS) { return (OpEntry *) (((OpEntry *) (CharP (ptr) + LOCAL_HDiff))); } -INLINE_ONLY inline EXTERN PredEntry *PtoPredAdjust__ (PredEntry * CACHE_TYPE); +INLINE_ONLY PredEntry *PtoPredAdjust__ (PredEntry * CACHE_TYPE); -INLINE_ONLY inline EXTERN PredEntry * +INLINE_ONLY PredEntry * PtoPredAdjust__ (PredEntry * ptr USES_REGS) { return (PredEntry *) (((PredEntry *) (CharP (ptr) + LOCAL_HDiff))); } -INLINE_ONLY inline EXTERN PredEntry **PtoPtoPredAdjust__ (PredEntry ** CACHE_TYPE); +INLINE_ONLY PredEntry **PtoPtoPredAdjust__ (PredEntry ** CACHE_TYPE); -INLINE_ONLY inline EXTERN PredEntry ** +INLINE_ONLY PredEntry ** PtoPtoPredAdjust__ (PredEntry **ptr USES_REGS) { if (!ptr) @@ -880,9 +882,9 @@ PtoPtoPredAdjust__ (PredEntry **ptr USES_REGS) -INLINE_ONLY inline EXTERN ArrayEntry *PtoArrayEAdjust__ (ArrayEntry * CACHE_TYPE); +INLINE_ONLY ArrayEntry *PtoArrayEAdjust__ (ArrayEntry * CACHE_TYPE); -INLINE_ONLY inline EXTERN ArrayEntry * +INLINE_ONLY ArrayEntry * PtoArrayEAdjust__ (ArrayEntry * ptr USES_REGS) { if (!ptr) @@ -891,9 +893,9 @@ PtoArrayEAdjust__ (ArrayEntry * ptr USES_REGS) } -INLINE_ONLY inline EXTERN GlobalEntry *PtoGlobalEAdjust__ (GlobalEntry * CACHE_TYPE); +INLINE_ONLY GlobalEntry *PtoGlobalEAdjust__ (GlobalEntry * CACHE_TYPE); -INLINE_ONLY inline EXTERN GlobalEntry * +INLINE_ONLY GlobalEntry * PtoGlobalEAdjust__ (GlobalEntry * ptr USES_REGS) { if (!ptr) @@ -902,9 +904,9 @@ PtoGlobalEAdjust__ (GlobalEntry * ptr USES_REGS) } -INLINE_ONLY inline EXTERN StaticArrayEntry *PtoArraySAdjust__ (StaticArrayEntry * CACHE_TYPE); +INLINE_ONLY StaticArrayEntry *PtoArraySAdjust__ (StaticArrayEntry * CACHE_TYPE); -INLINE_ONLY inline EXTERN StaticArrayEntry * +INLINE_ONLY StaticArrayEntry * PtoArraySAdjust__ (StaticArrayEntry * ptr USES_REGS) { if (!ptr) @@ -914,9 +916,9 @@ PtoArraySAdjust__ (StaticArrayEntry * ptr USES_REGS) -INLINE_ONLY inline EXTERN struct logic_upd_clause *PtoLUCAdjust__ (struct logic_upd_clause* CACHE_TYPE); +INLINE_ONLY struct logic_upd_clause *PtoLUCAdjust__ (struct logic_upd_clause* CACHE_TYPE); -INLINE_ONLY inline EXTERN struct logic_upd_clause * +INLINE_ONLY struct logic_upd_clause * PtoLUCAdjust__ (struct logic_upd_clause *ptr USES_REGS) { return (struct logic_upd_clause @@ -925,9 +927,9 @@ PtoLUCAdjust__ (struct logic_upd_clause *ptr USES_REGS) -INLINE_ONLY inline EXTERN struct static_clause *PtoStCAdjust__ (struct static_clause * CACHE_TYPE); +INLINE_ONLY struct static_clause *PtoStCAdjust__ (struct static_clause * CACHE_TYPE); -INLINE_ONLY inline EXTERN struct static_clause * +INLINE_ONLY struct static_clause * PtoStCAdjust__ (struct static_clause *ptr USES_REGS) { return (struct static_clause @@ -935,9 +937,9 @@ PtoStCAdjust__ (struct static_clause *ptr USES_REGS) } -INLINE_ONLY inline EXTERN struct dbterm_list *PtoDBTLAdjust__ (struct dbterm_list * CACHE_TYPE); +INLINE_ONLY struct dbterm_list *PtoDBTLAdjust__ (struct dbterm_list * CACHE_TYPE); -INLINE_ONLY inline EXTERN struct dbterm_list * +INLINE_ONLY struct dbterm_list * PtoDBTLAdjust__ (struct dbterm_list * addr USES_REGS) { return (struct dbterm_list *) ((ADDR) (CharP (addr) + LOCAL_HDiff)); @@ -946,9 +948,9 @@ PtoDBTLAdjust__ (struct dbterm_list * addr USES_REGS) #if PRECOMPUTE_REGADDRESS -INLINE_ONLY inline EXTERN wamreg XAdjust__ (wamreg CACHE_TYPE); +INLINE_ONLY wamreg XAdjust__ (wamreg CACHE_TYPE); -INLINE_ONLY inline EXTERN wamreg +INLINE_ONLY wamreg XAdjust__ (wamreg reg USES_REGS) { return (wamreg) ((wamreg) ((reg) + LOCAL_XDiff)); @@ -957,9 +959,9 @@ XAdjust__ (wamreg reg USES_REGS) #else -INLINE_ONLY inline EXTERN wamreg XAdjust__ (wamreg CACHE_TYPE); +INLINE_ONLY wamreg XAdjust__ (wamreg CACHE_TYPE); -INLINE_ONLY inline EXTERN wamreg +INLINE_ONLY wamreg XAdjust__ (wamreg reg USES_REGS) { return (wamreg) ((reg)); @@ -968,9 +970,9 @@ XAdjust__ (wamreg reg USES_REGS) #endif -INLINE_ONLY inline EXTERN yslot YAdjust__ (yslot CACHE_TYPE); +INLINE_ONLY yslot YAdjust__ (yslot CACHE_TYPE); -INLINE_ONLY inline EXTERN yslot +INLINE_ONLY yslot YAdjust__ (yslot reg USES_REGS) { return (yslot) ((reg)); @@ -978,9 +980,9 @@ YAdjust__ (yslot reg USES_REGS) -INLINE_ONLY inline EXTERN int IsOldLocal__ (CELL CACHE_TYPE); +INLINE_ONLY int IsOldLocal__ (CELL CACHE_TYPE); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int IsOldLocal__ (CELL reg USES_REGS) { return (int) (IN_BETWEEN (LOCAL_OldASP, reg, LOCAL_OldLCL0)); @@ -988,9 +990,9 @@ IsOldLocal__ (CELL reg USES_REGS) -INLINE_ONLY inline EXTERN int IsOldLocalPtr__ (CELL * CACHE_TYPE); +INLINE_ONLY int IsOldLocalPtr__ (CELL * CACHE_TYPE); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int IsOldLocalPtr__ (CELL * ptr USES_REGS) { return (int) (IN_BETWEEN (LOCAL_OldASP, ptr, LOCAL_OldLCL0)); @@ -1000,9 +1002,9 @@ IsOldLocalPtr__ (CELL * ptr USES_REGS) /* require because the trail might contain dangling pointers */ -INLINE_ONLY inline EXTERN int IsOldLocalInTR__ (CELL CACHE_TYPE); +INLINE_ONLY int IsOldLocalInTR__ (CELL CACHE_TYPE); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int IsOldLocalInTR__ (CELL reg USES_REGS) { return (int) (IN_BETWEEN (LOCAL_OldH, reg, LOCAL_OldLCL0)); @@ -1010,9 +1012,9 @@ IsOldLocalInTR__ (CELL reg USES_REGS) -INLINE_ONLY inline EXTERN int IsOldLocalInTRPtr__ (CELL * CACHE_TYPE); +INLINE_ONLY int IsOldLocalInTRPtr__ (CELL * CACHE_TYPE); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int IsOldLocalInTRPtr__ (CELL * ptr USES_REGS) { return (int) (IN_BETWEEN (LOCAL_OldH, ptr, LOCAL_OldLCL0)); @@ -1021,9 +1023,9 @@ IsOldLocalInTRPtr__ (CELL * ptr USES_REGS) -INLINE_ONLY inline EXTERN int IsOldH__ (CELL CACHE_TYPE); +INLINE_ONLY int IsOldH__ (CELL CACHE_TYPE); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int IsOldH__ (CELL reg USES_REGS) { return (int) ((CharP (reg) == CharP (LOCAL_OldH))); @@ -1033,18 +1035,18 @@ IsOldH__ (CELL reg USES_REGS) -INLINE_ONLY inline EXTERN int IsOldGlobal__ (CELL CACHE_TYPE); +INLINE_ONLY int IsOldGlobal__ (CELL CACHE_TYPE); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int IsOldGlobal__ (CELL reg USES_REGS) { return (int) (IN_BETWEEN (LOCAL_OldGlobalBase, reg, LOCAL_OldH)); } -INLINE_ONLY inline EXTERN int IsOldDelay__ (CELL CACHE_TYPE); +INLINE_ONLY int IsOldDelay__ (CELL CACHE_TYPE); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int IsOldDelay__ (CELL reg USES_REGS) { return (int) (IN_BETWEEN (LOCAL_OldGlobalBase, reg, LOCAL_OldH0)); @@ -1052,9 +1054,9 @@ IsOldDelay__ (CELL reg USES_REGS) -INLINE_ONLY inline EXTERN int IsOldGlobalPtr__ (CELL * CACHE_TYPE); +INLINE_ONLY int IsOldGlobalPtr__ (CELL * CACHE_TYPE); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int IsOldGlobalPtr__ (CELL * ptr USES_REGS) { return (int) (IN_BETWEEN (LOCAL_OldGlobalBase, ptr, LOCAL_OldH)); @@ -1062,9 +1064,9 @@ IsOldGlobalPtr__ (CELL * ptr USES_REGS) -INLINE_ONLY inline EXTERN int IsOldTrail__ (CELL CACHE_TYPE); +INLINE_ONLY int IsOldTrail__ (CELL CACHE_TYPE); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int IsOldTrail__ (CELL reg USES_REGS) { return (int) (IN_BETWEEN (LOCAL_OldTrailBase, reg, LOCAL_OldTR)); @@ -1072,9 +1074,9 @@ IsOldTrail__ (CELL reg USES_REGS) -INLINE_ONLY inline EXTERN int IsOldTrailPtr__ (CELL * CACHE_TYPE); +INLINE_ONLY int IsOldTrailPtr__ (CELL * CACHE_TYPE); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int IsOldTrailPtr__ (CELL * ptr USES_REGS) { return (int) (IN_BETWEEN (LOCAL_OldTrailBase, ptr, LOCAL_OldTR)); @@ -1082,9 +1084,9 @@ IsOldTrailPtr__ (CELL * ptr USES_REGS) -INLINE_ONLY inline EXTERN int IsOldVarTableTrailPtr__ (struct VARSTRUCT * CACHE_TYPE); +INLINE_ONLY int IsOldVarTableTrailPtr__ (struct VARSTRUCT * CACHE_TYPE); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int IsOldVarTableTrailPtr__ (struct VARSTRUCT *ptr USES_REGS) { return (int) (IN_BETWEEN (LOCAL_OldTrailBase, ptr, LOCAL_OldTR)); @@ -1092,9 +1094,9 @@ IsOldVarTableTrailPtr__ (struct VARSTRUCT *ptr USES_REGS) -INLINE_ONLY inline EXTERN int IsOldTokenTrailPtr__ (struct TOKEN * CACHE_TYPE); +INLINE_ONLY int IsOldTokenTrailPtr__ (struct TOKEN * CACHE_TYPE); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int IsOldTokenTrailPtr__ (struct TOKEN *ptr USES_REGS) { return (int) (IN_BETWEEN (LOCAL_OldTrailBase, ptr, LOCAL_OldTR)); @@ -1102,9 +1104,9 @@ IsOldTokenTrailPtr__ (struct TOKEN *ptr USES_REGS) -INLINE_ONLY inline EXTERN int IsOldCode__ (CELL CACHE_TYPE); +INLINE_ONLY int IsOldCode__ (CELL CACHE_TYPE); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int IsOldCode__ (CELL reg USES_REGS) { #if USE_SYSTEM_MALLOC @@ -1116,9 +1118,9 @@ IsOldCode__ (CELL reg USES_REGS) -INLINE_ONLY inline EXTERN int IsOldCodeCellPtr__ (CELL * CACHE_TYPE); +INLINE_ONLY int IsOldCodeCellPtr__ (CELL * CACHE_TYPE); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int IsOldCodeCellPtr__ (CELL * ptr USES_REGS) { return (int) (IN_BETWEEN (LOCAL_OldHeapBase, ptr, LOCAL_OldHeapTop)); @@ -1126,9 +1128,9 @@ IsOldCodeCellPtr__ (CELL * ptr USES_REGS) -INLINE_ONLY inline EXTERN int IsGlobal__ (CELL CACHE_TYPE); +INLINE_ONLY int IsGlobal__ (CELL CACHE_TYPE); -INLINE_ONLY inline EXTERN int +INLINE_ONLY int IsGlobal__ (CELL reg USES_REGS) { return (int) (IN_BETWEEN (LOCAL_GlobalBase, reg, HR)); @@ -1138,3 +1140,4 @@ IsGlobal__ (CELL reg USES_REGS) void Yap_AdjustStacksAndTrail(void); void Yap_AdjustRegs(int); +#endif diff --git a/H/trim_trail.h b/H/trim_trail.h index f83bf943f..1910c20b7 100644 --- a/H/trim_trail.h +++ b/H/trim_trail.h @@ -1,170 +1,183 @@ -#ifdef FROZEN_STACKS - { - tr_fr_ptr pt0, pt1, pbase; - pbase = B->cp_tr; - pt0 = pt1 = TR - 1; - while (pt1 >= pbase) { - BEGD(d1); - d1 = TrailTerm(pt1); - if (IsVarTerm(d1)) { - if (d1 < (CELL)HBREG || d1 > Unsigned(B->cp_b)) { - TrailTerm(pt0) = d1; - TrailVal(pt0) = TrailVal(pt1); - pt0--; - } - pt1--; - } else if (IsPairTerm(d1)) { - CELL *pt = RepPair(d1); +#ifdef FROZEN_STACKS +{ + tr_fr_ptr pt0, pt1, pbase, ptop; + pbase = B->cp_tr, ptop = TR; + pt0 = pt1 = TR - 1; + while (pt1 >= pbase) { + BEGD(d1); + d1 = TrailTerm(pt1); + if (IsVarTerm(d1)) { + if (d1 < (CELL)HBREG || d1 > Unsigned(B->cp_b)) { + TrailTerm(pt0) = d1; + TrailVal(pt0) = TrailVal(pt1); + pt0--; + } + pt1--; + } else if (IsPairTerm(d1)) { + CELL *pt = RepPair(d1); #ifdef LIMIT_TABLING - if ((ADDR) pt == LOCAL_TrailBase) { - sg_fr_ptr sg_fr = (sg_fr_ptr) TrailVal(pt1); - SgFr_state(sg_fr)--; /* complete_in_use --> complete : compiled_in_use --> compiled */ - insert_into_global_sg_fr_list(sg_fr); - } else + if ((ADDR)pt == LOCAL_TrailBase) { + sg_fr_ptr sg_fr = (sg_fr_ptr)TrailVal(pt1); + SgFr_state(sg_fr)--; /* complete_in_use --> complete : compiled_in_use + --> compiled */ + insert_into_global_sg_fr_list(sg_fr); + } else #endif /* LIMIT_TABLING */ - if (IN_BETWEEN(LOCAL_TrailBase, pt, LOCAL_TrailTop)) { - /* skip, this is a problem because we lose information, - namely active references */ - pt1 = (tr_fr_ptr)pt; - } else if (IN_BETWEEN(H0,pt,HR) && IsAttVar(pt)) { - CELL val = Deref(*pt); - if (IsVarTerm(val)) { - YapBind(pt, MkAtomTerm(AtomCut)); - Yap_WakeUp(pt); - } - } else if ((*pt & (LogUpdMask|IndexMask)) == (LogUpdMask|IndexMask)) { - LogUpdIndex *cl = ClauseFlagsToLogUpdIndex(pt); - int erase; + if (IN_BETWEEN(LOCAL_TrailBase, pt, LOCAL_TrailTop)) { + /* skip, this is a problem because we lose information, + namely active references */ + pt1 = (tr_fr_ptr)pt; + } else if (IN_BETWEEN(H0, pt, HR) && IsApplTerm(HeadOfTerm(d1))) { + Term t = HeadOfTerm(d1); + Functor f = FunctorOfTerm(t); + if (f == FunctorBigInt) { + Int tag = Yap_blob_tag(t); + GLOBAL_OpaqueHandlers[tag].cut_handler(d1); + } else { + pt0--; + } + pt1--; + continue; + } else if ((*pt & (LogUpdMask | IndexMask)) == (LogUpdMask | IndexMask)) { + LogUpdIndex *cl = ClauseFlagsToLogUpdIndex(pt); + int erase; #if defined(THREADS) || defined(YAPOR) - PredEntry *ap = cl->ClPred; + PredEntry *ap = cl->ClPred; #endif - - LOCK(ap->PELock); - DEC_CLREF_COUNT(cl); - cl->ClFlags &= ~InUseMask; - erase = (cl->ClFlags & (ErasedMask|DirtyMask)) && !(cl->ClRefCount); - if (erase) { - /* at this point, we are the only ones accessing the clause, - hence we don't need to have a lock it */ - if (cl->ClFlags & ErasedMask) - Yap_ErLogUpdIndex(cl); - else - Yap_CleanUpIndex(cl); - } - UNLOCK(ap->PELock); - } else { - TrailTerm(pt0) = d1; - TrailVal(pt0) = TrailVal(pt1); - pt0--; - } - pt1--; - } else if (IsApplTerm(d1)) { - if (IN_BETWEEN(HBREG,RepAppl(d1),B->cp_b)) { - /* deterministic binding to multi-assignment variable */ - pt1 -= 2; - } else { - TrailVal(pt0) = TrailVal(pt1); - TrailTerm(pt0) = d1; - TrailVal(pt0-1) = TrailVal(pt1-1); - TrailTerm(pt0-1) = TrailTerm(pt1-1); - pt0 -= 2; - pt1 -= 2; - } - } else { - TrailTerm(pt0) = d1; - TrailVal(pt0) = TrailVal(pt1); - pt0--; - pt1--; - } - ENDD(d1); - } - if (pt0 != pt1) { - int size; - pt0++; - size = TR - pt0; - memmove(pbase, pt0, size * sizeof(struct trail_frame)); - TR = pbase + size; - } - } -#else - { - tr_fr_ptr pt1, pt0; - pt1 = pt0 = B->cp_tr; - while (pt1 != TR) { - BEGD(d1); - d1 = TrailTerm(pt1); - if (IsVarTerm(d1)) { - if (d1 < (CELL)HBREG || d1 > Unsigned(B->cp_b)) { -#ifdef FROZEN_STACKS - TrailVal(pt0) = TrailVal(pt1); -#endif /* FROZEN_STACKS */ - TrailTerm(pt0) = d1; - pt0++; - } - pt1++; - } else if (IsApplTerm(d1)) { - if (IN_BETWEEN(HBREG,RepAppl(d1),B->cp_b)) { -#ifdef FROZEN_STACKS - pt1 += 2; -#else - pt1 += 3; -#endif - } else { -#ifdef FROZEN_STACKS - TrailVal(pt0) = TrailVal(pt1); - TrailTerm(pt0) = d1; - TrailVal(pt0+1) = TrailVal(pt1+1); - TrailTerm(pt0+1) = TrailTerm(pt1+1); - pt0 += 2; - pt1 += 2; -#else - TrailTerm(pt0+1) = TrailTerm(pt1+1); - TrailTerm(pt0) = TrailTerm(pt0+2) = d1; - pt0 += 3; - pt1 += 3; -#endif /* FROZEN_STACKS */ - } - } else if (IsPairTerm(d1)) { - CELL *pt = RepPair(d1); - - if (IN_BETWEEN(H0,pt,HR) && IsAttVar(pt)) { - CELL val = Deref(*pt); - if (IsVarTerm(val)) { - YapBind(VarOfTerm(val), MkAtomTerm(AtomCut)); - Yap_WakeUp(pt); - } - } else if ((*pt & (LogUpdMask|IndexMask)) == (LogUpdMask|IndexMask)) { - LogUpdIndex *cl = ClauseFlagsToLogUpdIndex(pt); -#if defined(YAPOR) || defined(THREADS) - PredEntry *ap = cl->ClPred; -#endif - int erase; - LOCK(ap->PELock); - DEC_CLREF_COUNT(cl); - cl->ClFlags &= ~InUseMask; - erase = (cl->ClFlags & (DirtyMask|ErasedMask)) && !(cl->ClRefCount); - if (erase) { - /* at this point, we are the only ones accessing the clause, - hence we don't need to have a lock it */ - if (cl->ClFlags & ErasedMask) - Yap_ErLogUpdIndex(cl); - else - Yap_CleanUpIndex(cl); - } - UNLOCK(ap->PELock); - } else { - TrailTerm(pt0) = d1; - pt0++; - } - pt1++; + LOCK(ap->PELock); + DEC_CLREF_COUNT(cl); + cl->ClFlags &= ~InUseMask; + erase = (cl->ClFlags & (ErasedMask | DirtyMask)) && !(cl->ClRefCount); + if (erase) { + /* at this point, we are the only ones accessing the clause, + hence we don't need to have a lock it */ + if (cl->ClFlags & ErasedMask) + Yap_ErLogUpdIndex(cl); + else + Yap_CleanUpIndex(cl); + } + UNLOCK(ap->PELock); } else { - TrailTerm(pt0) = d1; - pt0++; - pt1++; + TrailTerm(pt0) = d1; + TrailVal(pt0) = TrailVal(pt1); + pt0--; } - ENDD(d1); + pt1--; + } else if (IsApplTerm(d1)) { + if (IN_BETWEEN(HBREG, RepAppl(d1), B->cp_b)) { + /* deterministic binding to multi-assignment variable */ + pt1 -= 2; + } else { + TrailVal(pt0) = TrailVal(pt1); + TrailTerm(pt0) = d1; + TrailVal(pt0 - 1) = TrailVal(pt1 - 1); + TrailTerm(pt0 - 1) = TrailTerm(pt1 - 1); + pt0 -= 2; + pt1 -= 2; + } + } else { + TrailTerm(pt0) = d1; + TrailVal(pt0) = TrailVal(pt1); + pt0--; + pt1--; + } + ENDD(d1); + } + if (pt0 != pt1) { + int size; + pt0++; + size = ptop - pt0; + memmove(pbase, pt0, size * sizeof(struct trail_frame)); + if (ptop != TR) { + memmove(pbase + size, ptop, (TR - ptop) * sizeof(struct trail_frame)); + size += (TR - ptop); + } + TR = pbase + size; + } +} +#else +{ + tr_fr_ptr pt1, pt0; + pt1 = pt0 = B->cp_tr; + while (pt1 != TR) { + BEGD(d1); + d1 = TrailTerm(pt1); + if (IsVarTerm(d1)) { + if (d1 < (CELL)HBREG || d1 > Unsigned(B->cp_b)) { +#ifdef FROZEN_STACKS + TrailVal(pt0) = TrailVal(pt1); +#endif /* FROZEN_STACKS */ + TrailTerm(pt0) = d1; + pt0++; + } + pt1++; + } else if (IsApplTerm(d1)) { + if (IN_BETWEEN(HBREG, RepAppl(d1), B->cp_b)) { +#ifdef FROZEN_STACKS + pt1 += 2; +#else + pt1 += 3; +#endif + } else { +#ifdef FROZEN_STACKS + TrailVal(pt0) = TrailVal(pt1); + TrailTerm(pt0) = d1; + TrailVal(pt0 + 1) = TrailVal(pt1 + 1); + TrailTerm(pt0 + 1) = TrailTerm(pt1 + 1); + pt0 += 2; + pt1 += 2; +#else + TrailTerm(pt0 + 1) = TrailTerm(pt1 + 1); + TrailTerm(pt0) = TrailTerm(pt0 + 2) = d1; + pt0 += 3; + pt1 += 3; +#endif /* FROZEN_STACKS */ + } + } else if (IsPairTerm(d1)) { + CELL *pt = RepPair(d1); + + else if (IN_BETWEEN(H0, pt, HR) && IsApplTerm(HeadOfTerm(d1))) { + Term t = HeadOfTerm(d1); + Functor f = FunctorOfTerm(t); + if (f == FunctorBigInt) { + RESET_VARIABLE(&TrailTerm(pt1)); + Int tag = Yap_blob_tag(t); + GLOBAL_OpaqueHandlers[tag].cut_handler(d1); + } else if ((*pt & (LogUpdMask | IndexMask)) == + (LogUpdMask | IndexMask)) { + LogUpdIndex *cl = ClauseFlagsToLogUpdIndex(pt); +#if defined(YAPOR) || defined(THREADS) + PredEntry *ap = cl->ClPred; +#endif + int erase; + + LOCK(ap->PELock); + DEC_CLREF_COUNT(cl); + cl->ClFlags &= ~InUseMask; + erase = (cl->ClFlags & (DirtyMask | ErasedMask)) && !(cl->ClRefCount); + if (erase) { + /* at this point, we are the only ones accessing the clause, + hence we don't need to have a lock it */ + if (cl->ClFlags & ErasedMask) + Yap_ErLogUpdIndex(cl); + else + Yap_CleanUpIndex(cl); + } + UNLOCK(ap->PELock); + } else { + TrailTerm(pt0) = d1; + pt0++; + } + pt1++; + } + else { + TrailTerm(pt0) = d1; + pt0++; + pt1++; + } + ENDD(d1); } TR = pt0; } diff --git a/H/utarray.h b/H/utarray.h index 0c1e59b5b..415652439 100644 --- a/H/utarray.h +++ b/H/utarray.h @@ -95,7 +95,7 @@ typedef struct { #define utarray_push_back(a,p) do { \ utarray_reserve(a,1); \ if ((a)->icd.copy) { (a)->icd.copy( _utarray_eltptr(a,(a)->i++), p); } \ - else { memcpy(_utarray_eltptr(a,(a)->i++), p, (a)->icd.sz); }; \ + else { memmove(_utarray_eltptr(a,(a)->i++), p, (a)->icd.sz); }; \ } while(0) #define utarray_pop_back(a) do { \ @@ -123,7 +123,7 @@ typedef struct { ((a)->i - (j))*((a)->icd.sz)); \ } \ if ((a)->icd.copy) { (a)->icd.copy( _utarray_eltptr(a,j), p); } \ - else { memcpy(_utarray_eltptr(a,j), p, (a)->icd.sz); }; \ + else { memmove(_utarray_eltptr(a,j), p, (a)->icd.sz); }; \ (a)->i++; \ } while(0) @@ -142,7 +142,7 @@ typedef struct { (a)->icd.copy(_utarray_eltptr(a,j+_ut_i), _utarray_eltptr(w,_ut_i)); \ } \ } else { \ - memcpy(_utarray_eltptr(a,j), _utarray_eltptr(w,0), \ + memmove(_utarray_eltptr(a,j), _utarray_eltptr(w,0), \ utarray_len(w)*((a)->icd.sz)); \ } \ (a)->i += utarray_len(w); \ diff --git a/H/walkclause.h b/H/walkclause.h index 0252df004..8f97eef76 100644 --- a/H/walkclause.h +++ b/H/walkclause.h @@ -1,746 +1,739 @@ -/* This file was generated automatically by "yap -L misc/buildops" + + /* This file was generated automatically by "yap -L misc/buildops" please do not update */ -while (TRUE) { - op_numbers op; - op = Yap_op_from_opcode(pc->opc); - /* C-code, maybe indexing */ - switch (op) { - /* instructions type D */ - case _write_dbterm: - pc = NEXTOP(pc, D); - break; - /* instructions type Illss */ - case _enter_lu_pred: - return walk_got_lu_block(pc->y_u.Illss.I, startp, endp); -/* instructions type J */ + while (TRUE) { + op_numbers op; + + op = Yap_op_from_opcode(pc->opc); + /* C-code, maybe indexing */ + switch (op) { + /* instructions type D */ + case _write_dbterm: + pc = NEXTOP(pc,D); + break; + /* instructions type Illss */ + case _enter_lu_pred: + return walk_got_lu_block(pc->y_u.Illss.I, startp, endp); + /* instructions type J */ #ifdef YAP_JIT - case _jit_handler: + case _jit_handler: #endif - pc = NEXTOP(pc, J); - break; - /* instructions type L */ - case _alloc_for_logical_pred: - return walk_got_lu_clause(pc->y_u.L.ClBase, startp, endp); - /* instructions type N */ - case _write_bigint: - pc = NEXTOP(pc, N); - break; - /* instructions type Osblp */ - case _either: - case _or_else: - clause_code = TRUE; - pp = pc->y_u.Osblp.p0; - pc = NEXTOP(pc, Osblp); - break; - /* instructions type Osbmp */ - case _p_execute: - case _p_execute_tail: - pc = NEXTOP(pc, Osbmp); - break; - /* instructions type Osbpa */ - case _ensure_space: - pc = NEXTOP(pc, Osbpa); - break; - /* instructions type Osbpp */ - case _call_cpred: - pp = pc->y_u.Osbpp.p; - return walk_found_c_pred(pp, startp, endp); - case _call_usercpred: - pp = pc->y_u.Osbpp.p; - return walk_found_c_pred(pp, startp, endp); - case _p_execute2: - return found_meta_call(startp, endp); - case _call: - case _fcall: - clause_code = TRUE; - pp = pc->y_u.Osbpp.p0; - pc = NEXTOP(pc, Osbpp); - break; - /* instructions type OtILl */ - case _count_trust_logical: - case _profiled_trust_logical: - case _trust_logical: - return walk_got_lu_block(pc->y_u.OtILl.block, startp, endp); - /* instructions type OtaLl */ - case _count_retry_logical: - case _profiled_retry_logical: - case _retry_logical: - case _try_logical: - pc = pc->y_u.OtaLl.n; - break; - /* instructions type OtapFs */ - case _cut_c: - case _cut_userc: - case _retry_c: - case _retry_userc: - case _try_c: - case _try_userc: - clause_code = TRUE; - pp = pc->y_u.OtapFs.p; - pc = NEXTOP(pc, OtapFs); - break; - /* instructions type Otapl */ - case _count_retry_and_mark: - case _count_retry_me: - case _count_trust_me: - case _profiled_retry_and_mark: - case _profiled_retry_me: - case _profiled_trust_me: - case _retry: - case _retry_and_mark: - case _retry_me: - case _spy_or_trymark: - case _trust: - case _trust_me: - case _try_and_mark: - case _try_clause: - case _try_me: - clause_code = FALSE; - pp = pc->y_u.Otapl.p; - pc = NEXTOP(pc, Otapl); - break; - /* instructions type c */ - case _write_atom: - pc = NEXTOP(pc, c); - break; - /* instructions type cc */ - case _get_2atoms: - pc = NEXTOP(pc, cc); - break; - /* instructions type ccc */ - case _get_3atoms: - pc = NEXTOP(pc, ccc); - break; - /* instructions type cccc */ - case _get_4atoms: - pc = NEXTOP(pc, cccc); - break; - /* instructions type ccccc */ - case _get_5atoms: - pc = NEXTOP(pc, ccccc); - break; - /* instructions type cccccc */ - case _get_6atoms: - pc = NEXTOP(pc, cccccc); - break; - /* instructions type clll */ - case _if_not_then: - pc = NEXTOP(pc, clll); - break; - /* instructions type d */ - case _write_float: - pc = NEXTOP(pc, d); - break; - /* instructions type e */ - case _Nstop: - return NULL; - case _copy_idb_term: - return found_idb_clause(pc, startp, endp); - case _expand_index: - return found_expand(pc, startp, endp PASS_REGS); - case _index_pred: - return found_owner_op(pc, startp, endp PASS_REGS); - case _lock_pred: - return found_owner_op(pc, startp, endp PASS_REGS); - case _op_fail: - if (codeptr == FAILCODE) - return found_fail(pc, startp, endp PASS_REGS); - pc = NEXTOP(pc, e); - break; - case _spy_pred: - return found_owner_op(pc, startp, endp PASS_REGS); - case _trust_fail: - if (codeptr == TRUSTFAILCODE) - return found_fail(pc, startp, endp PASS_REGS); - pc = NEXTOP(pc, e); - break; - case _undef_p: - return found_owner_op(pc, startp, endp PASS_REGS); - case _unify_idb_term: - return found_idb_clause(pc, startp, endp); - case _allocate: - case _enter_exo: - case _index_blob: - case _index_dbref: - case _index_long: - case _p_equal: - case _p_functor: - case _pop: + pc = NEXTOP(pc,J); + break; + /* instructions type L */ + case _alloc_for_logical_pred: + return walk_got_lu_clause(pc->y_u.L.ClBase, startp, endp); + /* instructions type N */ + case _write_bigint: + pc = NEXTOP(pc,N); + break; + /* instructions type Osblp */ + case _either: + case _or_else: + clause_code = TRUE; + pp = pc->y_u.Osblp.p0; + pc = NEXTOP(pc,Osblp); + break; + /* instructions type Osbmp */ + case _p_execute: + case _p_execute_tail: + pc = NEXTOP(pc,Osbmp); + break; + /* instructions type Osbpa */ + case _ensure_space: + pc = NEXTOP(pc,Osbpa); + break; + /* instructions type Osbpp */ + case _call_cpred: + pp = pc->y_u.Osbpp.p; + return walk_found_c_pred(pp, startp, endp); + case _call_usercpred: + pp = pc->y_u.Osbpp.p; + return walk_found_c_pred(pp, startp, endp); + case _execute_cpred: + pp = pc->y_u.Osbpp.p; + return walk_found_c_pred(pp, startp, endp); + case _p_execute2: + return found_meta_call(startp, endp); + case _call: + case _dexecute: + case _execute: + case _fcall: + clause_code = TRUE; + pp = pc->y_u.Osbpp.p0; + pc = NEXTOP(pc,Osbpp); + break; + /* instructions type OtILl */ + case _count_trust_logical: + case _profiled_trust_logical: + case _trust_logical: + return walk_got_lu_block(pc->y_u.OtILl.block, startp, endp); + /* instructions type OtaLl */ + case _count_retry_logical: + case _profiled_retry_logical: + case _retry_logical: + case _try_logical: + pc = pc->y_u.OtaLl.n; + break; + /* instructions type OtapFs */ + case _cut_c: + case _cut_userc: + case _retry_c: + case _retry_userc: + case _try_c: + case _try_userc: + clause_code = TRUE; + pp = pc->y_u.OtapFs.p; + pc = NEXTOP(pc,OtapFs); + break; + /* instructions type Otapl */ + case _count_retry_and_mark: + case _count_retry_me: + case _count_trust_me: + case _profiled_retry_and_mark: + case _profiled_retry_me: + case _profiled_trust_me: + case _retry: + case _retry_and_mark: + case _retry_me: + case _spy_or_trymark: + case _trust: + case _trust_me: + case _try_and_mark: + case _try_clause: + case _try_me: + clause_code = FALSE; + pp = pc->y_u.Otapl.p; + pc = NEXTOP(pc,Otapl); + break; + /* instructions type c */ + case _write_atom: + pc = NEXTOP(pc,c); + break; + /* instructions type cc */ + case _get_2atoms: + pc = NEXTOP(pc,cc); + break; + /* instructions type ccc */ + case _get_3atoms: + pc = NEXTOP(pc,ccc); + break; + /* instructions type cccc */ + case _get_4atoms: + pc = NEXTOP(pc,cccc); + break; + /* instructions type ccccc */ + case _get_5atoms: + pc = NEXTOP(pc,ccccc); + break; + /* instructions type cccccc */ + case _get_6atoms: + pc = NEXTOP(pc,cccccc); + break; + /* instructions type clll */ + case _if_not_then: + pc = NEXTOP(pc,clll); + break; + /* instructions type d */ + case _write_float: + pc = NEXTOP(pc,d); + break; + /* instructions type e */ + case _Nstop: + return NULL; + case _copy_idb_term: + return found_idb_clause(pc, startp, endp); + case _expand_index: + return found_expand(pc, startp, endp PASS_REGS); + case _index_pred: + return found_owner_op(pc, startp, endp PASS_REGS); + case _lock_pred: + return found_owner_op(pc, startp, endp PASS_REGS); + case _op_fail: + if (codeptr == FAILCODE) + return found_fail(pc, startp, endp PASS_REGS); + pc = NEXTOP(pc,e); + break; + case _spy_pred: + return found_owner_op(pc, startp, endp PASS_REGS); + case _trust_fail: + if (codeptr == TRUSTFAILCODE) + return found_fail(pc, startp, endp PASS_REGS); + pc = NEXTOP(pc,e); + break; + case _undef_p: + return found_owner_op(pc, startp, endp PASS_REGS); + case _unify_idb_term: + return found_idb_clause(pc, startp, endp); + case _allocate: + case _enter_exo: + case _index_blob: + case _index_dbref: + case _index_long: + case _p_equal: + case _p_functor: + case _pop: #ifdef BEAM - case _retry_eam: + case _retry_eam: #endif #ifdef THREADS - case _thread_local: + case _thread_local: #endif - case _unlock_lu: - case _write_l_list: - case _write_list: - case _write_void: - pc = NEXTOP(pc, e); - break; - /* instructions type fa */ - case _write_l_struc: - case _write_struct: - pc = NEXTOP(pc, fa); - break; - /* instructions type i */ - case _write_longint: - pc = NEXTOP(pc, i); - break; - /* instructions type l */ - case _Ystop: - return found_ystop(pc, clause_code, startp, endp, pp PASS_REGS); - case _jump: - case _jump_if_var: - case _move_back: -#if INLINE_BIG_COMPARISONS - case _p_dif: - case _p_eq: -#endif - case _retry2: - case _retry3: - case _retry4: - case _skip: - case _try_clause2: - case _try_clause3: - case _try_clause4: - case _try_in: - pc = NEXTOP(pc, l); - break; - /* instructions type llll */ - case _switch_on_type: - pc = NEXTOP(pc, llll); - break; - /* instructions type lp */ - case _retry_all_exo: - case _retry_exo: - case _retry_exo_udi: - case _try_all_exo: - case _try_exo: - case _try_exo_udi: - case _user_switch: - pc = NEXTOP(pc, lp); - break; - /* instructions type o */ - case _unify_l_list: - case _unify_l_list_write: - case _unify_l_void: - case _unify_l_void_write: - case _unify_list: - case _unify_list_write: - case _unify_void: - case _unify_void_write: - pc = NEXTOP(pc, o); - break; - /* instructions type oD */ - case _unify_dbterm: - case _unify_l_dbterm: - pc = NEXTOP(pc, oD); - break; - /* instructions type oN */ - case _unify_bigint: - case _unify_l_bigint: - pc = NEXTOP(pc, oN); - break; - /* instructions type oc */ - case _unify_atom: - case _unify_atom_write: - case _unify_l_atom: - case _unify_l_atom_write: - pc = NEXTOP(pc, oc); - break; - /* instructions type od */ - case _unify_float: - case _unify_float_write: - case _unify_l_float: - case _unify_l_float_write: - pc = NEXTOP(pc, od); - break; - /* instructions type ofa */ - case _unify_l_struc: - case _unify_l_struc_write: - case _unify_struct: - case _unify_struct_write: - pc = NEXTOP(pc, ofa); - break; - /* instructions type oi */ - case _unify_l_longint: - case _unify_l_longint_write: - case _unify_longint: - case _unify_longint_write: - pc = NEXTOP(pc, oi); - break; - /* instructions type ollll */ - case _switch_list_nl: - pc = NEXTOP(pc, ollll); - break; -/* instructions type os */ + case _unlock_lu: + case _write_l_list: + case _write_list: + case _write_void: + pc = NEXTOP(pc,e); + break; + /* instructions type fa */ + case _write_l_struc: + case _write_struct: + pc = NEXTOP(pc,fa); + break; + /* instructions type i */ + case _write_longint: + pc = NEXTOP(pc,i); + break; + /* instructions type l */ + case _Ystop: + return found_ystop(pc, clause_code, startp, endp, pp PASS_REGS); + case _jump: + case _jump_if_var: + case _move_back: + case _retry2: + case _retry3: + case _retry4: + case _skip: + case _try_clause2: + case _try_clause3: + case _try_clause4: + case _try_in: + pc = NEXTOP(pc,l); + break; + /* instructions type llll */ + case _switch_on_type: + pc = NEXTOP(pc,llll); + break; + /* instructions type lp */ + case _retry_all_exo: + case _retry_exo: + case _retry_exo_udi: + case _try_all_exo: + case _try_exo: + case _try_exo_udi: + case _user_switch: + pc = NEXTOP(pc,lp); + break; + /* instructions type o */ + case _unify_l_list: + case _unify_l_list_write: + case _unify_l_void: + case _unify_l_void_write: + case _unify_list: + case _unify_list_write: + case _unify_void: + case _unify_void_write: + pc = NEXTOP(pc,o); + break; + /* instructions type oD */ + case _unify_dbterm: + case _unify_l_dbterm: + pc = NEXTOP(pc,oD); + break; + /* instructions type oN */ + case _unify_bigint: + case _unify_l_bigint: + pc = NEXTOP(pc,oN); + break; + /* instructions type oc */ + case _unify_atom: + case _unify_atom_write: + case _unify_l_atom: + case _unify_l_atom_write: + pc = NEXTOP(pc,oc); + break; + /* instructions type od */ + case _unify_float: + case _unify_float_write: + case _unify_l_float: + case _unify_l_float_write: + pc = NEXTOP(pc,od); + break; + /* instructions type ofa */ + case _unify_l_struc: + case _unify_l_struc_write: + case _unify_struct: + case _unify_struct_write: + pc = NEXTOP(pc,ofa); + break; + /* instructions type oi */ + case _unify_l_longint: + case _unify_l_longint_write: + case _unify_longint: + case _unify_longint_write: + pc = NEXTOP(pc,oi); + break; + /* instructions type ollll */ + case _switch_list_nl: + pc = NEXTOP(pc,ollll); + break; + /* instructions type os */ #ifdef BEAM - case _run_eam: + case _run_eam: #endif - case _unify_l_n_voids: - case _unify_l_n_voids_write: - case _unify_n_voids: - case _unify_n_voids_write: - pc = NEXTOP(pc, os); - break; - /* instructions type osc */ - case _unify_n_atoms: - case _unify_n_atoms_write: - pc = NEXTOP(pc, osc); - break; - /* instructions type ou */ - case _unify_l_string: - case _unify_string: - pc = NEXTOP(pc, ou); - break; - /* instructions type ox */ - case _save_appl_x: - case _save_appl_x_write: - case _save_pair_x: - case _save_pair_x_write: - case _unify_l_x_loc: - case _unify_l_x_loc_write: - case _unify_l_x_val: - case _unify_l_x_val_write: - case _unify_l_x_var: - case _unify_l_x_var_write: - case _unify_x_loc: - case _unify_x_loc_write: - case _unify_x_val: - case _unify_x_val_write: - case _unify_x_var: - case _unify_x_var_write: - pc = NEXTOP(pc, ox); - break; - /* instructions type oxx */ - case _unify_l_x_var2: - case _unify_l_x_var2_write: - case _unify_x_var2: - case _unify_x_var2_write: - pc = NEXTOP(pc, oxx); - break; - /* instructions type oy */ - case _save_appl_y: - case _save_appl_y_write: - case _save_pair_y: - case _save_pair_y_write: - case _unify_l_y_loc: - case _unify_l_y_loc_write: - case _unify_l_y_val: - case _unify_l_y_val_write: - case _unify_l_y_var: - case _unify_l_y_var_write: - case _unify_y_loc: - case _unify_y_loc_write: - case _unify_y_val: - case _unify_y_val_write: - case _unify_y_var: - case _unify_y_var_write: - pc = NEXTOP(pc, oy); - break; - /* instructions type p */ - case _lock_lu: - case _procceed: - pp = pc->y_u.p.p; - if (pp->PredFlags & MegaClausePredFlag) - return found_mega_clause(pp, startp, endp); - clause_code = TRUE; - pc = NEXTOP(pc, p); - break; - case _count_call: - case _count_retry: - case _deallocate: - case _enter_profiling: - case _retry_profiled: - case _retry_udi: - case _try_udi: - pc = NEXTOP(pc, p); - break; - /* instructions type plxxs */ - case _call_bfunc_xx: - pc = NEXTOP(pc, plxxs); - break; - /* instructions type plxys */ - case _call_bfunc_xy: - case _call_bfunc_yx: - pc = NEXTOP(pc, plxys); - break; - /* instructions type plyys */ - case _call_bfunc_yy: - pc = NEXTOP(pc, plyys); - break; - /* instructions type pp */ - case _execute_cpred: - pp = pc->y_u.pp.p; - return walk_found_c_pred(pp, startp, endp); - case _dexecute: - case _execute: - clause_code = TRUE; - pp = pc->y_u.pp.p0; - pc = NEXTOP(pc, pp); - break; - /* instructions type s */ - case _cut: - case _cut_e: - case _cut_t: - case _pop_n: - case _write_n_voids: - pc = NEXTOP(pc, s); - break; - /* instructions type sc */ - case _write_n_atoms: - pc = NEXTOP(pc, sc); - break; - /* instructions type sllll */ - case _switch_on_sub_arg_type: - pc = NEXTOP(pc, sllll); - break; - /* instructions type slpp */ - case _call_c_wfail: - pp = pc->y_u.slpp.p; - return walk_found_c_pred(pp, startp, endp); - /* instructions type sssl */ - case _go_on_cons: - case _go_on_func: - case _if_cons: - case _if_func: - case _switch_on_cons: - case _switch_on_func: - pc = NEXTOP(pc, sssl); - break; - /* instructions type sssllp */ - case _expand_clauses: - return found_expand_index(pc, startp, endp, codeptr PASS_REGS); - pc = NEXTOP(pc, sssllp); - break; - /* instructions type x */ - case _get_atom_exo: - case _get_list: - case _put_list: - case _save_b_x: - case _write_x_loc: - case _write_x_val: - case _write_x_var: - pc = NEXTOP(pc, x); - break; - /* instructions type xD */ - case _get_dbterm: - case _put_dbterm: - pc = NEXTOP(pc, xD); - break; - /* instructions type xN */ - case _get_bigint: - case _put_bigint: - pc = NEXTOP(pc, xN); - break; - /* instructions type xc */ - case _get_atom: - case _put_atom: - pc = NEXTOP(pc, xc); - break; - /* instructions type xd */ - case _get_float: - case _put_float: - pc = NEXTOP(pc, xd); - break; - /* instructions type xfa */ - case _get_struct: - case _put_struct: - pc = NEXTOP(pc, xfa); - break; - /* instructions type xi */ - case _get_longint: - case _put_longint: - pc = NEXTOP(pc, xi); - break; - /* instructions type xl */ - case _p_atom_x: - case _p_atomic_x: - case _p_compound_x: - case _p_db_ref_x: - case _p_float_x: - case _p_integer_x: - case _p_nonvar_x: - case _p_number_x: - case _p_primitive_x: - case _p_var_x: - pc = NEXTOP(pc, xl); - break; - /* instructions type xll */ - case _jump_if_nonvar: - pc = NEXTOP(pc, xll); - break; - /* instructions type xllll */ - case _switch_on_arg_type: - pc = NEXTOP(pc, xllll); - break; - /* instructions type xps */ - case _commit_b_x: - pc = NEXTOP(pc, xps); - break; - /* instructions type xu */ - case _get_string: - pc = NEXTOP(pc, xu); - break; - /* instructions type xx */ - case _get_x_val: - case _get_x_var: - case _gl_void_valx: - case _gl_void_varx: - case _glist_valx: - case _put_x_val: - case _put_x_var: - pc = NEXTOP(pc, xx); - break; - /* instructions type xxc */ - case _p_func2s_cv: - pc = NEXTOP(pc, xxc); - break; - /* instructions type xxn */ - case _p_and_vc: - case _p_arg_cv: - case _p_div_cv: - case _p_div_vc: - case _p_func2s_vc: - case _p_minus_cv: - case _p_or_vc: - case _p_plus_vc: - case _p_sll_cv: - case _p_sll_vc: - case _p_slr_cv: - case _p_slr_vc: - case _p_times_vc: - pc = NEXTOP(pc, xxn); - break; - /* instructions type xxx */ - case _p_and_vv: - case _p_arg_vv: - case _p_div_vv: - case _p_func2f_xx: - case _p_func2s_vv: - case _p_minus_vv: - case _p_or_vv: - case _p_plus_vv: - case _p_sll_vv: - case _p_slr_vv: - case _p_times_vv: - pc = NEXTOP(pc, xxx); - break; - /* instructions type xxxx */ - case _put_xx_val: - pc = NEXTOP(pc, xxxx); - break; - /* instructions type xxy */ - case _p_func2f_xy: - pc = NEXTOP(pc, xxy); - break; - /* instructions type y */ - case _save_b_y: - case _write_y_loc: - case _write_y_val: - case _write_y_var: - pc = NEXTOP(pc, y); - break; - /* instructions type yl */ - case _p_atom_y: - case _p_atomic_y: - case _p_compound_y: - case _p_db_ref_y: - case _p_float_y: - case _p_integer_y: - case _p_nonvar_y: - case _p_number_y: - case _p_primitive_y: - case _p_var_y: - pc = NEXTOP(pc, yl); - break; - /* instructions type yps */ - case _commit_b_y: - pc = NEXTOP(pc, yps); - break; - /* instructions type yx */ - case _get_y_val: - case _get_y_var: - case _gl_void_valy: - case _gl_void_vary: - case _glist_valy: - case _put_unsafe: - case _put_y_val: - case _put_y_var: - pc = NEXTOP(pc, yx); - break; - /* instructions type yxc */ - case _p_func2s_y_cv: - pc = NEXTOP(pc, yxc); - break; - /* instructions type yxn */ - case _p_and_y_vc: - case _p_arg_y_cv: - case _p_div_y_cv: - case _p_div_y_vc: - case _p_func2s_y_vc: - case _p_minus_y_cv: - case _p_or_y_vc: - case _p_plus_y_vc: - case _p_sll_y_cv: - case _p_sll_y_vc: - case _p_slr_y_cv: - case _p_slr_y_vc: - case _p_times_y_vc: - pc = NEXTOP(pc, yxn); - break; - /* instructions type yxx */ - case _p_and_y_vv: - case _p_arg_y_vv: - case _p_div_y_vv: - case _p_func2f_yx: - case _p_func2s_y_vv: - case _p_minus_y_vv: - case _p_or_y_vv: - case _p_plus_y_vv: - case _p_sll_y_vv: - case _p_slr_y_vv: - case _p_times_y_vv: - pc = NEXTOP(pc, yxx); - break; - /* instructions type yyx */ - case _p_func2f_yy: - pc = NEXTOP(pc, yyx); - break; - /* instructions type yyxx */ - case _get_yy_var: - case _put_y_vals: - pc = NEXTOP(pc, yyxx); - break; + case _unify_l_n_voids: + case _unify_l_n_voids_write: + case _unify_n_voids: + case _unify_n_voids_write: + pc = NEXTOP(pc,os); + break; + /* instructions type osc */ + case _unify_n_atoms: + case _unify_n_atoms_write: + pc = NEXTOP(pc,osc); + break; + /* instructions type ou */ + case _unify_l_string: + case _unify_string: + pc = NEXTOP(pc,ou); + break; + /* instructions type ox */ + case _save_appl_x: + case _save_appl_x_write: + case _save_pair_x: + case _save_pair_x_write: + case _unify_l_x_loc: + case _unify_l_x_loc_write: + case _unify_l_x_val: + case _unify_l_x_val_write: + case _unify_l_x_var: + case _unify_l_x_var_write: + case _unify_x_loc: + case _unify_x_loc_write: + case _unify_x_val: + case _unify_x_val_write: + case _unify_x_var: + case _unify_x_var_write: + pc = NEXTOP(pc,ox); + break; + /* instructions type oxx */ + case _unify_l_x_var2: + case _unify_l_x_var2_write: + case _unify_x_var2: + case _unify_x_var2_write: + pc = NEXTOP(pc,oxx); + break; + /* instructions type oy */ + case _save_appl_y: + case _save_appl_y_write: + case _save_pair_y: + case _save_pair_y_write: + case _unify_l_y_loc: + case _unify_l_y_loc_write: + case _unify_l_y_val: + case _unify_l_y_val_write: + case _unify_l_y_var: + case _unify_l_y_var_write: + case _unify_y_loc: + case _unify_y_loc_write: + case _unify_y_val: + case _unify_y_val_write: + case _unify_y_var: + case _unify_y_var_write: + pc = NEXTOP(pc,oy); + break; + /* instructions type p */ + case _lock_lu: + case _procceed: + pp = pc->y_u.p.p; + if (pp->PredFlags & MegaClausePredFlag) + return found_mega_clause(pp, startp, endp); + clause_code = TRUE; + pc = NEXTOP(pc,p); + break; + case _count_call: + case _count_retry: + case _deallocate: + case _enter_profiling: + case _retry_profiled: + case _retry_udi: + case _try_udi: + pc = NEXTOP(pc,p); + break; + /* instructions type plxxs */ + case _call_bfunc_xx: + pc = NEXTOP(pc,plxxs); + break; + /* instructions type plxys */ + case _call_bfunc_xy: + case _call_bfunc_yx: + pc = NEXTOP(pc,plxys); + break; + /* instructions type plyys */ + case _call_bfunc_yy: + pc = NEXTOP(pc,plyys); + break; + /* instructions type s */ + case _cut: + case _cut_e: + case _cut_t: + case _pop_n: + case _write_n_voids: + pc = NEXTOP(pc,s); + break; + /* instructions type sc */ + case _write_n_atoms: + pc = NEXTOP(pc,sc); + break; + /* instructions type sllll */ + case _switch_on_sub_arg_type: + pc = NEXTOP(pc,sllll); + break; + /* instructions type slpp */ + case _call_c_wfail: + pp = pc->y_u.slpp.p; + return walk_found_c_pred(pp, startp, endp); + /* instructions type sssl */ + case _go_on_cons: + case _go_on_func: + case _if_cons: + case _if_func: + case _switch_on_cons: + case _switch_on_func: + pc = NEXTOP(pc,sssl); + break; + /* instructions type sssllp */ + case _expand_clauses: + return found_expand_index(pc, startp, endp, codeptr PASS_REGS); + pc = NEXTOP(pc,sssllp); + break; + /* instructions type x */ + case _get_atom_exo: + case _get_list: + case _put_list: + case _save_b_x: + case _write_x_loc: + case _write_x_val: + case _write_x_var: + pc = NEXTOP(pc,x); + break; + /* instructions type xD */ + case _get_dbterm: + case _put_dbterm: + pc = NEXTOP(pc,xD); + break; + /* instructions type xN */ + case _get_bigint: + case _put_bigint: + pc = NEXTOP(pc,xN); + break; + /* instructions type xc */ + case _get_atom: + case _put_atom: + pc = NEXTOP(pc,xc); + break; + /* instructions type xd */ + case _get_float: + case _put_float: + pc = NEXTOP(pc,xd); + break; + /* instructions type xfa */ + case _get_struct: + case _put_struct: + pc = NEXTOP(pc,xfa); + break; + /* instructions type xi */ + case _get_longint: + case _put_longint: + pc = NEXTOP(pc,xi); + break; + /* instructions type xl */ + case _p_atom_x: + case _p_atomic_x: + case _p_compound_x: + case _p_db_ref_x: + case _p_float_x: + case _p_integer_x: + case _p_nonvar_x: + case _p_number_x: + case _p_primitive_x: + case _p_var_x: + pc = NEXTOP(pc,xl); + break; + /* instructions type xll */ + case _jump_if_nonvar: + pc = NEXTOP(pc,xll); + break; + /* instructions type xllll */ + case _switch_on_arg_type: + pc = NEXTOP(pc,xllll); + break; + /* instructions type xps */ + case _commit_b_x: + pc = NEXTOP(pc,xps); + break; + /* instructions type xu */ + case _get_string: + pc = NEXTOP(pc,xu); + break; + /* instructions type xx */ + case _get_x_val: + case _get_x_var: + case _gl_void_valx: + case _gl_void_varx: + case _glist_valx: + case _put_x_val: + case _put_x_var: + pc = NEXTOP(pc,xx); + break; + /* instructions type xxc */ + case _p_func2s_cv: + pc = NEXTOP(pc,xxc); + break; + /* instructions type xxn */ + case _p_and_vc: + case _p_arg_cv: + case _p_div_cv: + case _p_div_vc: + case _p_func2s_vc: + case _p_minus_cv: + case _p_or_vc: + case _p_plus_vc: + case _p_sll_cv: + case _p_sll_vc: + case _p_slr_cv: + case _p_slr_vc: + case _p_times_vc: + pc = NEXTOP(pc,xxn); + break; + /* instructions type xxx */ + case _p_and_vv: + case _p_arg_vv: + case _p_div_vv: + case _p_func2f_xx: + case _p_func2s_vv: + case _p_minus_vv: + case _p_or_vv: + case _p_plus_vv: + case _p_sll_vv: + case _p_slr_vv: + case _p_times_vv: + pc = NEXTOP(pc,xxx); + break; + /* instructions type xxxx */ + case _put_xx_val: + pc = NEXTOP(pc,xxxx); + break; + /* instructions type xxy */ + case _p_func2f_xy: + pc = NEXTOP(pc,xxy); + break; + /* instructions type y */ + case _save_b_y: + case _write_y_loc: + case _write_y_val: + case _write_y_var: + pc = NEXTOP(pc,y); + break; + /* instructions type yl */ + case _p_atom_y: + case _p_atomic_y: + case _p_compound_y: + case _p_db_ref_y: + case _p_float_y: + case _p_integer_y: + case _p_nonvar_y: + case _p_number_y: + case _p_primitive_y: + case _p_var_y: + pc = NEXTOP(pc,yl); + break; + /* instructions type yps */ + case _commit_b_y: + pc = NEXTOP(pc,yps); + break; + /* instructions type yx */ + case _get_y_val: + case _get_y_var: + case _gl_void_valy: + case _gl_void_vary: + case _glist_valy: + case _put_unsafe: + case _put_y_val: + case _put_y_var: + pc = NEXTOP(pc,yx); + break; + /* instructions type yxc */ + case _p_func2s_y_cv: + pc = NEXTOP(pc,yxc); + break; + /* instructions type yxn */ + case _p_and_y_vc: + case _p_arg_y_cv: + case _p_div_y_cv: + case _p_div_y_vc: + case _p_func2s_y_vc: + case _p_minus_y_cv: + case _p_or_y_vc: + case _p_plus_y_vc: + case _p_sll_y_cv: + case _p_sll_y_vc: + case _p_slr_y_cv: + case _p_slr_y_vc: + case _p_times_y_vc: + pc = NEXTOP(pc,yxn); + break; + /* instructions type yxx */ + case _p_and_y_vv: + case _p_arg_y_vv: + case _p_div_y_vv: + case _p_func2f_yx: + case _p_func2s_y_vv: + case _p_minus_y_vv: + case _p_or_y_vv: + case _p_plus_y_vv: + case _p_sll_y_vv: + case _p_slr_y_vv: + case _p_times_y_vv: + pc = NEXTOP(pc,yxx); + break; + /* instructions type yyx */ + case _p_func2f_yy: + pc = NEXTOP(pc,yyx); + break; + /* instructions type yyxx */ + case _get_yy_var: + case _put_y_vals: + pc = NEXTOP(pc,yyxx); + break; #ifdef YAPOR - /* instructions type Otapl */ - case _getwork: - case _getwork_seq: - case _sync: - clause_code = FALSE; - pp = pc->y_u.Otapl.p; - pc = NEXTOP(pc, Otapl); - break; - /* instructions type e */ - case _getwork_first_time: - pc = NEXTOP(pc, e); - break; + /* instructions type Otapl */ + case _getwork: + case _getwork_seq: + case _sync: + clause_code = FALSE; + pp = pc->y_u.Otapl.p; + pc = NEXTOP(pc,Otapl); + break; + /* instructions type e */ + case _getwork_first_time: + pc = NEXTOP(pc,e); + break; #endif #ifdef TABLING - /* instructions type Otapl */ - case _table_answer_resolution: + /* instructions type Otapl */ + case _table_answer_resolution: #ifdef THREADS_CONSUMER_SHARING - case _table_answer_resolution_completion: + case _table_answer_resolution_completion: #endif - case _table_completion: - case _table_load_answer: - case _table_retry: - case _table_retry_me: - case _table_trust: - case _table_trust_me: - case _table_try: - case _table_try_answer: - case _table_try_me: - case _table_try_single: - clause_code = FALSE; - pp = pc->y_u.Otapl.p; - pc = NEXTOP(pc, Otapl); - break; -/* instructions type e */ + case _table_completion: + case _table_load_answer: + case _table_retry: + case _table_retry_me: + case _table_trust: + case _table_trust_me: + case _table_try: + case _table_try_answer: + case _table_try_me: + case _table_try_single: + clause_code = FALSE; + pp = pc->y_u.Otapl.p; + pc = NEXTOP(pc,Otapl); + break; + /* instructions type e */ #ifdef TABLING_INNER_CUTS - case _clause_with_cut: + case _clause_with_cut: #endif - pc = NEXTOP(pc, e); - break; - /* instructions type s */ - case _table_new_answer: - pc = NEXTOP(pc, s); - break; - /* instructions type e */ - case _trie_do_appl: - case _trie_do_appl_in_pair: - case _trie_do_atom: - case _trie_do_atom_in_pair: - case _trie_do_bigint: - case _trie_do_double: - case _trie_do_extension: - case _trie_do_gterm: - case _trie_do_longint: - case _trie_do_null: - case _trie_do_null_in_pair: - case _trie_do_pair: - case _trie_do_val: - case _trie_do_val_in_pair: - case _trie_do_var: - case _trie_do_var_in_pair: - case _trie_retry_appl: - case _trie_retry_appl_in_pair: - case _trie_retry_atom: - case _trie_retry_atom_in_pair: - case _trie_retry_bigint: - case _trie_retry_double: - case _trie_retry_extension: - case _trie_retry_gterm: - case _trie_retry_longint: - case _trie_retry_null: - case _trie_retry_null_in_pair: - case _trie_retry_pair: - case _trie_retry_val: - case _trie_retry_val_in_pair: - case _trie_retry_var: - case _trie_retry_var_in_pair: - case _trie_trust_appl: - case _trie_trust_appl_in_pair: - case _trie_trust_atom: - case _trie_trust_atom_in_pair: - case _trie_trust_bigint: - case _trie_trust_double: - case _trie_trust_extension: - case _trie_trust_gterm: - case _trie_trust_longint: - case _trie_trust_null: - case _trie_trust_null_in_pair: - case _trie_trust_pair: - case _trie_trust_val: - case _trie_trust_val_in_pair: - case _trie_trust_var: - case _trie_trust_var_in_pair: - case _trie_try_appl: - case _trie_try_appl_in_pair: - case _trie_try_atom: - case _trie_try_atom_in_pair: - case _trie_try_bigint: - case _trie_try_double: - case _trie_try_extension: - case _trie_try_gterm: - case _trie_try_longint: - case _trie_try_null: - case _trie_try_null_in_pair: - case _trie_try_pair: - case _trie_try_val: - case _trie_try_val_in_pair: - case _trie_try_var: - case _trie_try_var_in_pair: - pc = NEXTOP(pc, e); - break; + pc = NEXTOP(pc,e); + break; + /* instructions type s */ + case _table_new_answer: + pc = NEXTOP(pc,s); + break; + /* instructions type e */ + case _trie_do_appl: + case _trie_do_appl_in_pair: + case _trie_do_atom: + case _trie_do_atom_in_pair: + case _trie_do_bigint: + case _trie_do_double: + case _trie_do_extension: + case _trie_do_gterm: + case _trie_do_longint: + case _trie_do_null: + case _trie_do_null_in_pair: + case _trie_do_pair: + case _trie_do_val: + case _trie_do_val_in_pair: + case _trie_do_var: + case _trie_do_var_in_pair: + case _trie_retry_appl: + case _trie_retry_appl_in_pair: + case _trie_retry_atom: + case _trie_retry_atom_in_pair: + case _trie_retry_bigint: + case _trie_retry_double: + case _trie_retry_extension: + case _trie_retry_gterm: + case _trie_retry_longint: + case _trie_retry_null: + case _trie_retry_null_in_pair: + case _trie_retry_pair: + case _trie_retry_val: + case _trie_retry_val_in_pair: + case _trie_retry_var: + case _trie_retry_var_in_pair: + case _trie_trust_appl: + case _trie_trust_appl_in_pair: + case _trie_trust_atom: + case _trie_trust_atom_in_pair: + case _trie_trust_bigint: + case _trie_trust_double: + case _trie_trust_extension: + case _trie_trust_gterm: + case _trie_trust_longint: + case _trie_trust_null: + case _trie_trust_null_in_pair: + case _trie_trust_pair: + case _trie_trust_val: + case _trie_trust_val_in_pair: + case _trie_trust_var: + case _trie_trust_var_in_pair: + case _trie_try_appl: + case _trie_try_appl_in_pair: + case _trie_try_atom: + case _trie_try_atom_in_pair: + case _trie_try_bigint: + case _trie_try_double: + case _trie_try_extension: + case _trie_try_gterm: + case _trie_try_longint: + case _trie_try_null: + case _trie_try_null_in_pair: + case _trie_try_pair: + case _trie_try_val: + case _trie_try_val_in_pair: + case _trie_try_var: + case _trie_try_var_in_pair: + pc = NEXTOP(pc,e); + break; #endif - /* this instruction is hardwired */ - case _or_last: + /* this instruction is hardwired */ + case _or_last: #ifdef YAPOR - pp = pc->y_u.Osblp.p0; - if (pp->PredFlags & MegaClausePredFlag) - return found_mega_clause(pp, startp, endp); - clause_code = TRUE; - pc = NEXTOP(pc, Osblp); + pp = pc->y_u.Osblp.p0; + if (pp->PredFlags & MegaClausePredFlag) + return found_mega_clause(pp, startp, endp); + clause_code = TRUE; + pc = NEXTOP(pc,Osblp); #else - pp = pc->y_u.p.p; - if (pp->PredFlags & MegaClausePredFlag) - return found_mega_clause(pp, startp, endp); - clause_code = TRUE; - pc = NEXTOP(pc, p); + pp = pc->y_u.p.p; + if (pp->PredFlags & MegaClausePredFlag) + return found_mega_clause(pp, startp, endp); + clause_code = TRUE; + pc = NEXTOP(pc,p); #endif + } } -} diff --git a/JIT/CMakeLists.txt b/JIT/CMakeLists.txt index a2797c26c..183c6cffa 100644 --- a/JIT/CMakeLists.txt +++ b/JIT/CMakeLists.txt @@ -51,8 +51,6 @@ set(LIBJIT_FULL_VERSION # multiples times is the approach recommended in the docs. macro_optional_find_package (LLVM OFF) -macro_log_feature (LLVM_FOUND "LLVM JIT generator" -"The LLVM Compiler Infrastructure" "http://www.llvm.org") set (YAP_JIT ${LLVM_FOUND} SCOPE GLOBAL) @@ -60,7 +58,7 @@ set (POSITION_INDEPENDENT_CODE TRUE) set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${LLVM_CXXFLAGS}) -add_library (libyapjit SHARED +add_lib (libyapjit ${LIBJIT_SOURCES} ${LIBJIT_HEADERS} ) diff --git a/JIT/HPP/JIT_Compiler.hpp b/JIT/HPP/JIT_Compiler.hpp index 596418c88..1fb0d607f 100644 --- a/JIT/HPP/JIT_Compiler.hpp +++ b/JIT/HPP/JIT_Compiler.hpp @@ -110,16 +110,16 @@ typedef struct jit_compiler JIT_Compiler; EXTERN void* (*Yap_JitCall)(JIT_Compiler* jc, yamop* p); -INLINE_ONLY inline EXTERN void* call_JIT_Compiler(JIT_Compiler* jc, yamop* p); +INLINE_ONLY void* call_JIT_Compiler(JIT_Compiler* jc, yamop* p); -INLINE_ONLY inline EXTERN void* call_JIT_Compiler(JIT_Compiler* jc, yamop* p) { +INLINE_ONLY void* call_JIT_Compiler(JIT_Compiler* jc, yamop* p) { return Yap_JitCall (jc,p); } -INLINE_ONLY inline EXTERN void shutdown_llvm(void ) ; +INLINE_ONLY void shutdown_llvm(void ) ; EXTERN void (* Yap_llvmShutdown)(void ) ; -INLINE_ONLY inline EXTERN void shutdown_llvm(void ) { Yap_llvmShutdown (); } +INLINE_ONLY void shutdown_llvm(void ) { Yap_llvmShutdown (); } #endif diff --git a/JIT/HPP/yaam_call_d.h b/JIT/HPP/yaam_call_d.h index b81595cb6..604324869 100644 --- a/JIT/HPP/yaam_call_d.h +++ b/JIT/HPP/yaam_call_d.h @@ -1,379 +1,364 @@ -#define EXECUTE_INSTINIT \ - print_instruction((*_PREG), ON_NATIVE); \ - BLOCKADDRESS = (CELL)(*_PREG); \ - register CELL d0; \ - PredEntry *pt0; \ - register CELL *ENV_YREG = (YREG); \ - pt0 = (*_PREG)->u.pp.p; - +#define EXECUTE_INSTINIT \ + print_instruction((*_PREG), ON_NATIVE); \ + BLOCKADDRESS = (CELL)(*_PREG); \ + register CELL d0; \ + PredEntry *pt0; \ + register CELL *ENV_YREG = (YREG); \ + pt0 = (*_PREG)->u.Osbpp.p; + #ifdef LOW_LEVEL_TRACER -#define EXECUTE_LOW_LEVEL_TRACER \ - low_level_trace(enter_pred,pt0,XREGS+1); +#define EXECUTE_LOW_LEVEL_TRACER low_level_trace(enter_pred, pt0, XREGS + 1); #endif -#define EXECUTE_POST_LOW_LEVEL_TRACER \ - CACHE_A1(); \ - ALWAYS_LOOKAHEAD(pt0->OpcodeOfPred); \ - d0 = (CELL)B; - -#define EXECUTE_POST_NOCHECKING \ - (*_PREG) = pt0->CodeOfPred; \ - save_pc(); \ - ENV_YREG[E_CB] = d0; - +#define EXECUTE_POST_LOW_LEVEL_TRACER \ + CACHE_A1(); \ + ALWAYS_LOOKAHEAD(pt0->OpcodeOfPred); \ + d0 = (CELL)B; + +#define EXECUTE_POST_NOCHECKING \ + (*_PREG) = pt0->CodeOfPred; \ + save_pc(); \ + ENV_YREG[E_CB] = d0; + #ifdef DEPTH_LIMIT -#define EXECUTE_DEPTH_MINOR \ - FAILED = 0; \ - if (pt0->ModuleOfPred) { \ - if (DEPTH == MkIntTerm(0)) { \ - YAAM_FAIL; \ - } \ - else { \ - DEPTH = RESET_DEPTH(); \ - } \ - } - -#define EXECUTE_DEPTH_MOFPRED \ - FAILED = 0; \ - DEPTH -= MkIntConstant(2); +#define EXECUTE_DEPTH_MINOR \ + FAILED = 0; \ + if (pt0->ModuleOfPred) { \ + if (DEPTH == MkIntTerm(0)) { \ + YAAM_FAIL; \ + } else { \ + DEPTH = RESET_DEPTH(); \ + } \ + } -#define EXECUTE_DEPTH_END \ - FAILED = 0; +#define EXECUTE_DEPTH_MOFPRED \ + FAILED = 0; \ + DEPTH -= MkIntConstant(2); + +#define EXECUTE_DEPTH_END FAILED = 0; #endif -#define EXECUTE_END_END \ - BLOCK = (CELL)EXECUTE_END_END; \ - if (!FAILED) { \ - ALWAYS_GONext(); \ - } \ +#define EXECUTE_END_END \ + BLOCK = (CELL)EXECUTE_END_END; \ + if (!FAILED) { \ + ALWAYS_GONext(); \ + } + +#define DEXECUTE_INSTINIT \ + print_instruction((*_PREG), ON_NATIVE); \ + BLOCKADDRESS = (CELL)(*_PREG); -#define DEXECUTE_INSTINIT \ - print_instruction((*_PREG), ON_NATIVE); \ - BLOCKADDRESS = (CELL)(*_PREG); \ - #ifdef LOW_LEVEL_TRACER -#define DEXECUTE_LOW_LEVEL_TRACER \ - low_level_trace(enter_pred,(*_PREG)->u.pp.p,XREGS+1); +#define DEXECUTE_LOW_LEVEL_TRACER \ + low_level_trace(enter_pred, (*_PREG)->u.Osbpp.p, XREGS + 1); #endif -#define DEXECUTE_POST_LOW_LEVEL_TRACER \ - CACHE_Y_AS_ENV(YREG); \ - PredEntry *pt0; \ - CACHE_A1(); \ - pt0 = (*_PREG)->u.pp.p; - +#define DEXECUTE_POST_LOW_LEVEL_TRACER \ + CACHE_Y_AS_ENV(YREG); \ + PredEntry *pt0; \ + CACHE_A1(); \ + pt0 = (*_PREG)->u.Osbpp.p; + #ifdef DEPTH_LIMIT -#define DEXECUTE_DEPTH_MINOR \ - FAILED = 0; \ - if (pt0->ModuleOfPred) { \ - if (DEPTH == MkIntTerm(0)) { \ - YAAM_FAIL; \ - } \ - else { \ - DEPTH = RESET_DEPTH(); \ - } \ - } - -#define DEXECUTE_DEPTH_MOFPRED \ - FAILED = 0; \ - DEPTH -= MkIntConstant(2); - -#define DEXECUTE_DEPTH_END \ - FAILED = 0; +#define DEXECUTE_DEPTH_MINOR \ + FAILED = 0; \ + if (pt0->ModuleOfPred) { \ + if (DEPTH == MkIntTerm(0)) { \ + YAAM_FAIL; \ + } else { \ + DEPTH = RESET_DEPTH(); \ + } \ + } + +#define DEXECUTE_DEPTH_MOFPRED \ + FAILED = 0; \ + DEPTH -= MkIntConstant(2); + +#define DEXECUTE_DEPTH_END FAILED = 0; #endif #ifdef FROZEN_STACKS #ifdef YAPOR_SBA -#define DEXECUTE_END_END \ - BLOCK = (CELL)DEXECUTE_END_END; \ - if (!FAILED) { \ - (*_PREG) = pt0->CodeOfPred; \ - save_pc(); \ - (*_CPREG) = (yamop *) ENV_YREG[E_CP]; \ - ENV_YREG = ENV = (CELL *) ENV_YREG[E_E]; \ - choiceptr top_b = PROTECT_FROZEN_B(B); \ - if (ENV_YREG > (CELL *) top_b || ENV_YREG < HR) { \ - ENV_YREG = (CELL *) top_b; \ - } \ - else { \ - ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size((*_CPREG))); \ - } \ - WRITEBACK_Y_AS_ENV(); \ - ENV_YREG[E_CB] = (CELL) B; \ - ALWAYS_GONext(); \ - } \ - ENDCACHE_Y_AS_ENV(); +#define DEXECUTE_END_END \ + BLOCK = (CELL)DEXECUTE_END_END; \ + if (!FAILED) { \ + (*_PREG) = pt0->CodeOfPred; \ + save_pc(); \ + (*_CPREG) = (yamop *)ENV_YREG[E_CP]; \ + ENV_YREG = ENV = (CELL *)ENV_YREG[E_E]; \ + choiceptr top_b = PROTECT_FROZEN_B(B); \ + if (ENV_YREG > (CELL *)top_b || ENV_YREG < HR) { \ + ENV_YREG = (CELL *)top_b; \ + } else { \ + ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size((*_CPREG))); \ + } \ + WRITEBACK_Y_AS_ENV(); \ + ENV_YREG[E_CB] = (CELL)B; \ + ALWAYS_GONext(); \ + } \ + ENDCACHE_Y_AS_ENV(); #else /* YAPOR_SBA */ -#define DEXECUTE_END_END \ - BLOCK = (CELL)DEXECUTE_END_END; \ - if (!FAILED) { \ - (*_PREG) = pt0->CodeOfPred; \ - save_pc(); \ - (*_CPREG) = (yamop *) ENV_YREG[E_CP]; \ - ENV_YREG = ENV = (CELL *) ENV_YREG[E_E]; \ - choiceptr top_b = PROTECT_FROZEN_B(B); \ - if (ENV_YREG > (CELL *) top_b) { \ - ENV_YREG = (CELL *) top_b; \ - } \ - else { \ - ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size((*_CPREG))); \ - } \ - WRITEBACK_Y_AS_ENV(); \ - ENV_YREG[E_CB] = (CELL) B; \ - ALWAYS_GONext(); \ - } \ - ENDCACHE_Y_AS_ENV(); +#define DEXECUTE_END_END \ + BLOCK = (CELL)DEXECUTE_END_END; \ + if (!FAILED) { \ + (*_PREG) = pt0->CodeOfPred; \ + save_pc(); \ + (*_CPREG) = (yamop *)ENV_YREG[E_CP]; \ + ENV_YREG = ENV = (CELL *)ENV_YREG[E_E]; \ + choiceptr top_b = PROTECT_FROZEN_B(B); \ + if (ENV_YREG > (CELL *)top_b) { \ + ENV_YREG = (CELL *)top_b; \ + } else { \ + ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size((*_CPREG))); \ + } \ + WRITEBACK_Y_AS_ENV(); \ + ENV_YREG[E_CB] = (CELL)B; \ + ALWAYS_GONext(); \ + } \ + ENDCACHE_Y_AS_ENV(); #endif /* YAPOR_SBA */ -#else /* FROZEN_STACKS */ -#define DEXECUTE_END_END \ - BLOCK = (CELL)DEXECUTE_END_END; \ - if (!FAILED) { \ - (*_PREG) = pt0->CodeOfPred; \ - save_pc(); \ - (*_CPREG) = (yamop *) ENV_YREG[E_CP]; \ - ENV_YREG = ENV = (CELL *) ENV_YREG[E_E]; \ - if (ENV_YREG > (CELL *)B) { \ - ENV_YREG = (CELL *)B; \ - } \ - else { \ - ENV_YREG = (CELL *) ((CELL) ENV_YREG + ENV_Size((*_CPREG))); \ - } \ - WRITEBACK_Y_AS_ENV(); \ - ENV_YREG[E_CB] = (CELL) B; \ - ALWAYS_GONext(); \ - } \ - ENDCACHE_Y_AS_ENV(); +#else /* FROZEN_STACKS */ +#define DEXECUTE_END_END \ + BLOCK = (CELL)DEXECUTE_END_END; \ + if (!FAILED) { \ + (*_PREG) = pt0->CodeOfPred; \ + save_pc(); \ + (*_CPREG) = (yamop *)ENV_YREG[E_CP]; \ + ENV_YREG = ENV = (CELL *)ENV_YREG[E_E]; \ + if (ENV_YREG > (CELL *)B) { \ + ENV_YREG = (CELL *)B; \ + } else { \ + ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size((*_CPREG))); \ + } \ + WRITEBACK_Y_AS_ENV(); \ + ENV_YREG[E_CB] = (CELL)B; \ + ALWAYS_GONext(); \ + } \ + ENDCACHE_Y_AS_ENV(); #endif /* FROZEN_STACKS */ #ifdef DEPTH_LIMIT -#define FCALL_INST \ - CACHE_Y_AS_ENV(YREG); \ - ENV_YREG[E_CP] = (CELL) (*_CPREG); \ - ENV_YREG[E_E] = (CELL) ENV; \ - ENV_YREG[E_DEPTH] = DEPTH; \ - ENDCACHE_Y_AS_ENV(); +#define FCALL_INST \ + CACHE_Y_AS_ENV(YREG); \ + ENV_YREG[E_CP] = (CELL)(*_CPREG); \ + ENV_YREG[E_E] = (CELL)ENV; \ + ENV_YREG[E_DEPTH] = DEPTH; \ + ENDCACHE_Y_AS_ENV(); #else /* DEPTH_LIMIT */ -#define FCALL_INST \ - CACHE_Y_AS_ENV(YREG); \ - ENV_YREG[E_CP] = (CELL) (*_CPREG); \ - ENV_YREG[E_E] = (CELL) ENV; \ - ENDCACHE_Y_AS_ENV(); +#define FCALL_INST \ + CACHE_Y_AS_ENV(YREG); \ + ENV_YREG[E_CP] = (CELL)(*_CPREG); \ + ENV_YREG[E_E] = (CELL)ENV; \ + ENDCACHE_Y_AS_ENV(); #endif /* DEPTH_LIMIT */ - -#define CALL_INSTINIT \ - print_instruction((*_PREG), ON_NATIVE); \ - BLOCKADDRESS = (CELL)(*_PREG); \ - if (Yap_op_from_opcode((*_PREG)->opc) == _fcall) { \ - FCALL_INST; \ - } - + +#define CALL_INSTINIT \ + print_instruction((*_PREG), ON_NATIVE); \ + BLOCKADDRESS = (CELL)(*_PREG); \ + if (Yap_op_from_opcode((*_PREG)->opc) == _fcall) { \ + FCALL_INST; \ + } + #ifdef LOW_LEVEL_TRACER -#define CALL_LOW_LEVEL_TRACER \ - low_level_trace(enter_pred,(*_PREG)->u.Osbpp.p,XREGS+1); +#define CALL_LOW_LEVEL_TRACER \ + low_level_trace(enter_pred, (*_PREG)->u.Osbpp.p, XREGS + 1); #endif -#define CALL_POST_LOW_LEVEL_TRACER \ - register CELL *ENV_YREG = (YREG); \ - PredEntry *pt; \ - pt = (*_PREG)->u.Osbpp.p; \ - CACHE_A1(); - -#define CALL_POST_NO_CHECKING \ - ENV = ENV_YREG; \ - ENV_YREG = (CELL *) (((char *) ENV_YREG) + (*_PREG)->u.Osbpp.s); \ - (*_CPREG) = NEXTOP((*_PREG), Osbpp); \ - (*_PREG) = pt->CodeOfPred; \ - save_pc(); \ - +#define CALL_POST_LOW_LEVEL_TRACER \ + register CELL *ENV_YREG = (YREG); \ + PredEntry *pt; \ + pt = (*_PREG)->u.Osbpp.p; \ + CACHE_A1(); + +#define CALL_POST_NO_CHECKING \ + ENV = ENV_YREG; \ + ENV_YREG = (CELL *)(((char *)ENV_YREG) + (*_PREG)->u.Osbpp.s); \ + (*_CPREG) = NEXTOP((*_PREG), Osbpp); \ + (*_PREG) = pt->CodeOfPred; \ + save_pc(); + #ifdef DEPTH_LIMIT -#define CALL_DEPTH_MINOR \ - FAILED = 0; \ - if (pt->ModuleOfPred) { \ - if (DEPTH == MkIntTerm(0)){ \ - YAAM_FAIL; \ - } else { \ - DEPTH = RESET_DEPTH(); \ - } \ - } - -#define CALL_DEPTH_MOFPRED \ - FAILED = 0; \ - DEPTH -= MkIntConstant(2); - -#define CALL_DEPTH_END \ - FAILED = 0; +#define CALL_DEPTH_MINOR \ + FAILED = 0; \ + if (pt->ModuleOfPred) { \ + if (DEPTH == MkIntTerm(0)) { \ + YAAM_FAIL; \ + } else { \ + DEPTH = RESET_DEPTH(); \ + } \ + } + +#define CALL_DEPTH_MOFPRED \ + FAILED = 0; \ + DEPTH -= MkIntConstant(2); + +#define CALL_DEPTH_END FAILED = 0; #endif #ifdef YAPOR #ifdef FROZEN_STACKS #ifdef YAPOR_SBA -#define CALL_END_END \ - BLOCK = (CELL)CALL_END_END; \ - if (!FAILED) { \ - { \ - choiceptr top_b = PROTECT_FROZEN_B(B); \ - if (ENV_YREG > (CELL *) top_b || ENV_YREG < HR) { \ - ENV_YREG = (CELL *) top_b; \ - } \ - } \ - WRITEBACK_Y_AS_ENV(); \ - ENV_YREG[E_CB] = (CELL) B; \ - SCH_check_requests(); \ - ALWAYS_GONext(); \ +#define CALL_END_END \ + BLOCK = (CELL)CALL_END_END; \ + if (!FAILED) { \ + { \ + choiceptr top_b = PROTECT_FROZEN_B(B); \ + if (ENV_YREG > (CELL *)top_b || ENV_YREG < HR) { \ + ENV_YREG = (CELL *)top_b; \ + } \ + } \ + WRITEBACK_Y_AS_ENV(); \ + ENV_YREG[E_CB] = (CELL)B; \ + SCH_check_requests(); \ + ALWAYS_GONext(); \ } #else /* YAPOR_SBA */ -#define CALL_END_END \ - BLOCK = (CELL)CALL_END_END; \ - if (!FAILED) { \ - { \ - choiceptr top_b = PROTECT_FROZEN_B(B); \ - if (ENV_YREG > (CELL *) top_b) { \ - ENV_YREG = (CELL *) top_b; \ - } \ - } \ - WRITEBACK_Y_AS_ENV(); \ - ENV_YREG[E_CB] = (CELL) B; \ - SCH_check_requests(); \ - ALWAYS_GONext(); \ +#define CALL_END_END \ + BLOCK = (CELL)CALL_END_END; \ + if (!FAILED) { \ + { \ + choiceptr top_b = PROTECT_FROZEN_B(B); \ + if (ENV_YREG > (CELL *)top_b) { \ + ENV_YREG = (CELL *)top_b; \ + } \ + } \ + WRITEBACK_Y_AS_ENV(); \ + ENV_YREG[E_CB] = (CELL)B; \ + SCH_check_requests(); \ + ALWAYS_GONext(); \ } #endif /* YAPOR_SBA */ -#else /* FROZEN_STACKS */ -#define CALL_END_END \ - BLOCK = (CELL)CALL_END_END; \ - if (!FAILED) { \ - if (ENV_YREG > (CELL *) B) { \ - ENV_YREG = (CELL *) B; \ - } \ - WRITEBACK_Y_AS_ENV(); \ - ENV_YREG[E_CB] = (CELL) B; \ - SCH_check_requests(); \ - ALWAYS_GONext(); \ +#else /* FROZEN_STACKS */ +#define CALL_END_END \ + BLOCK = (CELL)CALL_END_END; \ + if (!FAILED) { \ + if (ENV_YREG > (CELL *)B) { \ + ENV_YREG = (CELL *)B; \ + } \ + WRITEBACK_Y_AS_ENV(); \ + ENV_YREG[E_CB] = (CELL)B; \ + SCH_check_requests(); \ + ALWAYS_GONext(); \ } #endif /* FROZEN_STACKS */ -#else /* YAPOR */ +#else /* YAPOR */ #ifdef FROZEN_STACKS #ifdef YAPOR_SBA -#define CALL_END_END \ - BLOCK = (CELL)CALL_END_END; \ - if (!FAILED) { \ - { \ - choiceptr top_b = PROTECT_FROZEN_B(B); \ - if (ENV_YREG > (CELL *) top_b || ENV_YREG < HR) { \ - ENV_YREG = (CELL *) top_b; \ - } \ - } \ - WRITEBACK_Y_AS_ENV(); \ - ENV_YREG[E_CB] = (CELL) B; \ - ALWAYS_GONext(); \ +#define CALL_END_END \ + BLOCK = (CELL)CALL_END_END; \ + if (!FAILED) { \ + { \ + choiceptr top_b = PROTECT_FROZEN_B(B); \ + if (ENV_YREG > (CELL *)top_b || ENV_YREG < HR) { \ + ENV_YREG = (CELL *)top_b; \ + } \ + } \ + WRITEBACK_Y_AS_ENV(); \ + ENV_YREG[E_CB] = (CELL)B; \ + ALWAYS_GONext(); \ } #else /* YAPOR_SBA */ -#define CALL_END_END \ - BLOCK = (CELL)CALL_END_END; \ - if (!FAILED) { \ - { \ - choiceptr top_b = PROTECT_FROZEN_B(B); \ - if (ENV_YREG > (CELL *) top_b) { \ - ENV_YREG = (CELL *) top_b; \ - } \ - } \ - WRITEBACK_Y_AS_ENV(); \ - ENV_YREG[E_CB] = (CELL) B; \ - ALWAYS_GONext(); \ +#define CALL_END_END \ + BLOCK = (CELL)CALL_END_END; \ + if (!FAILED) { \ + { \ + choiceptr top_b = PROTECT_FROZEN_B(B); \ + if (ENV_YREG > (CELL *)top_b) { \ + ENV_YREG = (CELL *)top_b; \ + } \ + } \ + WRITEBACK_Y_AS_ENV(); \ + ENV_YREG[E_CB] = (CELL)B; \ + ALWAYS_GONext(); \ } #endif /* YAPOR_SBA */ -#else /* FROZEN_STACKS */ -#define CALL_END_END \ - BLOCK = (CELL)CALL_END_END; \ - if (!FAILED) { \ - if (ENV_YREG > (CELL *) B) { \ - ENV_YREG = (CELL *) B; \ - } \ - WRITEBACK_Y_AS_ENV(); \ - ENV_YREG[E_CB] = (CELL) B; \ - ALWAYS_GONext(); \ +#else /* FROZEN_STACKS */ +#define CALL_END_END \ + BLOCK = (CELL)CALL_END_END; \ + if (!FAILED) { \ + if (ENV_YREG > (CELL *)B) { \ + ENV_YREG = (CELL *)B; \ + } \ + WRITEBACK_Y_AS_ENV(); \ + ENV_YREG[E_CB] = (CELL)B; \ + ALWAYS_GONext(); \ } #endif /* FROZEN_STACKS */ #endif /* YAPOR */ -#define PROCCEED_INSTINIT \ - print_instruction((*_PREG), ON_NATIVE); \ - BLOCKADDRESS = (CELL)(*_PREG); \ - CACHE_Y_AS_ENV(YREG); \ - (*_PREG) = (*_CPREG); \ - save_pc(); \ - ENV_YREG = ENV; - +#define PROCCEED_INSTINIT \ + print_instruction((*_PREG), ON_NATIVE); \ + BLOCKADDRESS = (CELL)(*_PREG); \ + CACHE_Y_AS_ENV(YREG); \ + (*_PREG) = (*_CPREG); \ + save_pc(); \ + ENV_YREG = ENV; + #ifdef DEPTH_LIMIT -#define PROCCEED_DEPTH \ - DEPTH = ENV_YREG[E_DEPTH]; +#define PROCCEED_DEPTH DEPTH = ENV_YREG[E_DEPTH]; #endif -#define PROCCEED_END \ - BLOCK = (CELL)PROCCEED_END; \ - WRITEBACK_Y_AS_ENV(); \ - ENDCACHE_Y_AS_ENV(); \ - ALWAYS_GONext(); +#define PROCCEED_END \ + BLOCK = (CELL)PROCCEED_END; \ + WRITEBACK_Y_AS_ENV(); \ + ENDCACHE_Y_AS_ENV(); \ + ALWAYS_GONext(); + +#define ALLOCATE_INSTINIT \ + print_instruction((*_PREG), ON_NATIVE); \ + CACHE_Y_AS_ENV(YREG); \ + (*_PREG) = NEXTOP((*_PREG), e); \ + ENV_YREG[E_CP] = (CELL)(*_CPREG); \ + ENV_YREG[E_E] = (CELL)ENV; -#define ALLOCATE_INSTINIT \ - print_instruction((*_PREG), ON_NATIVE); \ - CACHE_Y_AS_ENV(YREG); \ - (*_PREG) = NEXTOP((*_PREG), e); \ - ENV_YREG[E_CP] = (CELL) (*_CPREG); \ - ENV_YREG[E_E] = (CELL) ENV; - #ifdef DEPTH_LIMIT -#define ALLOCATE_DEPTH \ - ENV_YREG[E_DEPTH] = DEPTH; +#define ALLOCATE_DEPTH ENV_YREG[E_DEPTH] = DEPTH; #endif -#define ALLOCATE_END \ - ENV = ENV_YREG; \ - ENDCACHE_Y_AS_ENV(); \ - GONext(); +#define ALLOCATE_END \ + ENV = ENV_YREG; \ + ENDCACHE_Y_AS_ENV(); \ + GONext(); -#define DEALLOCATE_INSTINIT \ - print_instruction((*_PREG), ON_NATIVE); \ +#define DEALLOCATE_INSTINIT print_instruction((*_PREG), ON_NATIVE); + +#define DEALLOCATE_POST_CHECK \ + CACHE_Y_AS_ENV(YREG); \ + (*_PREG) = NEXTOP((*_PREG), p); \ + (*_SREG) = YREG; \ + (*_CPREG) = (yamop *)ENV_YREG[E_CP]; \ + ENV = ENV_YREG = (CELL *)ENV_YREG[E_E]; -#define DEALLOCATE_POST_CHECK \ - CACHE_Y_AS_ENV(YREG); \ - (*_PREG) = NEXTOP((*_PREG), p); \ - (*_SREG) = YREG; \ - (*_CPREG) = (yamop *) ENV_YREG[E_CP]; \ - ENV = ENV_YREG = (CELL *) ENV_YREG[E_E]; - #ifdef DEPTH_LIMIT -#define DEALLOCATE_DEPTH \ - DEPTH = ENV_YREG[E_DEPTH]; +#define DEALLOCATE_DEPTH DEPTH = ENV_YREG[E_DEPTH]; #endif #ifdef FROZEN_STACKS #ifdef YAPOR_SBA -#define DEALLOCATE_FROZEN \ - choiceptr top_b = PROTECT_FROZEN_B(B); \ - if (ENV_YREG > (CELL *) top_b || ENV_YREG < HR) \ - ENV_YREG = (CELL *) top_b; \ - else \ - ENV_YREG = (CELL *)((CELL) ENV_YREG + ENV_Size(CPREG)); +#define DEALLOCATE_FROZEN \ + choiceptr top_b = PROTECT_FROZEN_B(B); \ + if (ENV_YREG > (CELL *)top_b || ENV_YREG < HR) \ + ENV_YREG = (CELL *)top_b; \ + else \ + ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size(CPREG)); #else /* YAPOR_SBA */ -#define DEALLOCATE_FROZEN \ - choiceptr top_b = PROTECT_FROZEN_B(B); \ - if (ENV_YREG > (CELL *) top_b) \ - ENV_YREG = (CELL *) top_b; \ - else \ - ENV_YREG = (CELL *)((CELL) ENV_YREG + ENV_Size(CPREG)); +#define DEALLOCATE_FROZEN \ + choiceptr top_b = PROTECT_FROZEN_B(B); \ + if (ENV_YREG > (CELL *)top_b) \ + ENV_YREG = (CELL *)top_b; \ + else \ + ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size(CPREG)); #endif /* YAPOR_SBA */ -#else /* FROZEN_STACKS */ -#define DEALLOCATE_FROZEN \ - if (ENV_YREG > (CELL *) B) \ - ENV_YREG = (CELL *) B; \ - else \ - ENV_YREG = (CELL *) ((CELL) ENV_YREG + ENV_Size(CPREG)); +#else /* FROZEN_STACKS */ +#define DEALLOCATE_FROZEN \ + if (ENV_YREG > (CELL *)B) \ + ENV_YREG = (CELL *)B; \ + else \ + ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size(CPREG)); #endif /* FROZEN_STACKS */ - -#define DEALLOCATE_POST_FROZEN \ - WRITEBACK_Y_AS_ENV(); -#define DEALLOCATE_END \ - ENDCACHE_Y_AS_ENV(); \ - GONext(); +#define DEALLOCATE_POST_FROZEN WRITEBACK_Y_AS_ENV(); +#define DEALLOCATE_END \ + ENDCACHE_Y_AS_ENV(); \ + GONext(); diff --git a/JIT/JIT_interface.cpp b/JIT/JIT_interface.cpp index bf5b5cf58..9a684512e 100644 --- a/JIT/JIT_interface.cpp +++ b/JIT/JIT_interface.cpp @@ -95,7 +95,7 @@ typedef enum{ t_createLowerExpectIntrinsicPass, //Removes llvm.expect intrinsics and creates "block_weights" metadata t_createLowerInvokePass, //Converts invoke and unwind instructions to use sjlj exception handling mechanisms t_createLowerSwitchPass, //Converts SwitchInst instructions into a sequence of chained binary branch instructions - t_createMemCpyOptPass, //Performs optimizations related to eliminating memcpy calls and/or combining multiple stores into memset's + t_createMemCpyOptPass, //Performs optimizations related to eliminating memmove calls and/or combining multiple stores into memset's t_createMergeFunctionsPass, //Discovers identical functions and collapses them t_createObjCARCAPElimPass, //ObjC ARC autorelease pool elimination t_createObjCARCContractPass, //Late ObjC ARC cleanups diff --git a/OPTYap/CMakeLists.txt b/OPTYap/CMakeLists.txt index c3cd06398..175580a3c 100644 --- a/OPTYap/CMakeLists.txt +++ b/OPTYap/CMakeLists.txt @@ -1,22 +1,5 @@ -set (OPTYap_HEADERS - opt.config.h - opt.proto.h - opt.structs.h - opt.macros.h - or.macros.h - or.sba_amiops.h - or.sba_unify.h - tab.structs.h - locks_x86.h - locks_sparc.h - locks_mips.h - locks_mips_funcs.h - locks_alpha.h - locks_alpha_funcs.h - locks_pthread.h - ) set (OPTYap_SOURCES or.memory.c opt.init.c @@ -82,7 +65,7 @@ endif () set (POSITION_INDEPENDENT_CODE TRUE) SET_PROPERTY(DIRECTORY PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1 ) -add_component (libOPTYap +add_component (libOPTYap ${OPTYap_SOURCES} ) diff --git a/OPTYap/opt.preds.c b/OPTYap/opt.preds.c index fa7a69445..8a9db543a 100644 --- a/OPTYap/opt.preds.c +++ b/OPTYap/opt.preds.c @@ -11,6 +11,11 @@ ** ** ************************************************************************/ + +/// @file opt.preds.c +/// +/// @namespace prolog + /************************************ ** Includes & Prototypes ** ************************************/ @@ -236,7 +241,7 @@ void Yap_init_optyap_preds(void) { SafePredFlag | SyncPredFlag); Yap_InitCPred("abolish_all_tables", 0, p_abolish_all_tables, SafePredFlag | SyncPredFlag); - /** @pred abolish_all_tables/0 + /** @pred abolish_all_tables Removes all the entries from the table space for all tabled diff --git a/OPTYap/opt.structs.h b/OPTYap/opt.structs.h index e5b8684fd..f94e8a2f8 100644 --- a/OPTYap/opt.structs.h +++ b/OPTYap/opt.structs.h @@ -531,63 +531,63 @@ struct local_optyap_data { #define LOCAL_ma_h_top (LOCAL_optyap_data.ma_h_top) #define LOCAL_ma_hash_table (LOCAL_optyap_data.ma_hash_table) -#define REMOTE_pages_void(wid) (REMOTE(wid)->optyap_data_.pages.void_pages) -#define REMOTE_pages_tab_ent(wid) (REMOTE(wid)->optyap_data_.pages.table_entry_pages) -#define REMOTE_pages_sg_ent(wid) (REMOTE(wid)->optyap_data_.pages.subgoal_entry_pages) -#define REMOTE_pages_sg_fr(wid) (REMOTE(wid)->optyap_data_.pages.subgoal_frame_pages) -#define REMOTE_pages_dep_fr(wid) (REMOTE(wid)->optyap_data_.pages.dependency_frame_pages) -#define REMOTE_pages_sg_node(wid) (REMOTE(wid)->optyap_data_.pages.subgoal_trie_node_pages) -#define REMOTE_pages_sg_hash(wid) (REMOTE(wid)->optyap_data_.pages.subgoal_trie_hash_pages) -#define REMOTE_pages_ans_node(wid) (REMOTE(wid)->optyap_data_.pages.answer_trie_node_pages) -#define REMOTE_pages_ans_hash(wid) (REMOTE(wid)->optyap_data_.pages.answer_trie_hash_pages) -#define REMOTE_pages_ans_ref_node(wid) (REMOTE(wid)->optyap_data_.pages.answer_ref_node_pages) -#define REMOTE_pages_gt_node(wid) (REMOTE(wid)->optyap_data_.pages.global_trie_node_pages) -#define REMOTE_pages_gt_hash(wid) (REMOTE(wid)->optyap_data_.pages.global_trie_hash_pages) -#define REMOTE_next_free_ans_node(wid) (REMOTE(wid)->optyap_data_.pages.next_free_answer_trie_node) -#define REMOTE_lock(wid) (REMOTE(wid)->optyap_data_.lock) -#define REMOTE_load(wid) (REMOTE(wid)->optyap_data_.load) +#define REMOTE_pages_void(wid) (REMOTE(wid)->optyap_data.pages.void_pages) +#define REMOTE_pages_tab_ent(wid) (REMOTE(wid)->optyap_data.pages.table_entry_pages) +#define REMOTE_pages_sg_ent(wid) (REMOTE(wid)->optyap_data.pages.subgoal_entry_pages) +#define REMOTE_pages_sg_fr(wid) (REMOTE(wid)->optyap_data.pages.subgoal_frame_pages) +#define REMOTE_pages_dep_fr(wid) (REMOTE(wid)->optyap_data.pages.dependency_frame_pages) +#define REMOTE_pages_sg_node(wid) (REMOTE(wid)->optyap_data.pages.subgoal_trie_node_pages) +#define REMOTE_pages_sg_hash(wid) (REMOTE(wid)->optyap_data.pages.subgoal_trie_hash_pages) +#define REMOTE_pages_ans_node(wid) (REMOTE(wid)->optyap_data.pages.answer_trie_node_pages) +#define REMOTE_pages_ans_hash(wid) (REMOTE(wid)->optyap_data.pages.answer_trie_hash_pages) +#define REMOTE_pages_ans_ref_node(wid) (REMOTE(wid)->optyap_data.pages.answer_ref_node_pages) +#define REMOTE_pages_gt_node(wid) (REMOTE(wid)->optyap_data.pages.global_trie_node_pages) +#define REMOTE_pages_gt_hash(wid) (REMOTE(wid)->optyap_data.pages.global_trie_hash_pages) +#define REMOTE_next_free_ans_node(wid) (REMOTE(wid)->optyap_data.pages.next_free_answer_trie_node) +#define REMOTE_lock(wid) (REMOTE(wid)->optyap_data.lock) +#define REMOTE_load(wid) (REMOTE(wid)->optyap_data.load) #ifdef YAPOR_THREADS -#define REMOTE_top_cp(wid) offset_to_cptr(REMOTE(wid)->optyap_data_.top_choice_point_offset) -#define Set_REMOTE_top_cp(wid, bptr) (REMOTE(wid)->optyap_data_.top_choice_point_offset = cptr_to_offset(bptr)) +#define REMOTE_top_cp(wid) offset_to_cptr(REMOTE(wid)->optyap_data.top_choice_point_offset) +#define Set_REMOTE_top_cp(wid, bptr) (REMOTE(wid)->optyap_data.top_choice_point_offset = cptr_to_offset(bptr)) #else -#define REMOTE_top_cp(wid) (REMOTE(wid)->optyap_data_.top_choice_point) -#define Set_REMOTE_top_cp(wid, bptr) (REMOTE(wid)->optyap_data_.top_choice_point = (bptr)) +#define REMOTE_top_cp(wid) (REMOTE(wid)->optyap_data.top_choice_point) +#define Set_REMOTE_top_cp(wid, bptr) (REMOTE(wid)->optyap_data.top_choice_point = (bptr)) #endif /* YAPOR_THREADS */ -#define REMOTE_top_or_fr(wid) (REMOTE(wid)->optyap_data_.top_or_frame) +#define REMOTE_top_or_fr(wid) (REMOTE(wid)->optyap_data.top_or_frame) #ifdef YAPOR_THREADS -#define Get_REMOTE_prune_request(wid) offset_to_cptr_with_null(REMOTE(wid)->optyap_data_.prune_request_offset) -#define Set_REMOTE_prune_request(wid,cp) (REMOTE(wid)->optyap_data_.prune_request_offset = cptr_to_offset_with_null(cp)) +#define Get_REMOTE_prune_request(wid) offset_to_cptr_with_null(REMOTE(wid)->optyap_data.prune_request_offset) +#define Set_REMOTE_prune_request(wid,cp) (REMOTE(wid)->optyap_data.prune_request_offset = cptr_to_offset_with_null(cp)) #else -#define REMOTE_prune_request(wid) (REMOTE(wid)->optyap_data_.prune_request) -#define Get_REMOTE_prune_request(wid) (REMOTE(wid)->optyap_data_.prune_request) -#define Set_REMOTE_prune_request(wid,cp) (REMOTE(wid)->optyap_data_.prune_request = cp) +#define REMOTE_prune_request(wid) (REMOTE(wid)->optyap_data.prune_request) +#define Get_REMOTE_prune_request(wid) (REMOTE(wid)->optyap_data.prune_request) +#define Set_REMOTE_prune_request(wid,cp) (REMOTE(wid)->optyap_data.prune_request = cp) #endif /* YAPOR_THREADS */ -#define REMOTE_share_request(wid) (REMOTE(wid)->optyap_data_.share_request) -#define REMOTE_reply_signal(wid) (REMOTE(wid)->optyap_data_.share_signals.reply_signal) -#define REMOTE_p_fase_signal(wid) (REMOTE(wid)->optyap_data_.share_signals.P_fase) -#define REMOTE_q_fase_signal(wid) (REMOTE(wid)->optyap_data_.share_signals.Q_fase) -#define REMOTE_lock_signals(wid) (REMOTE(wid)->optyap_data_.share_signals.lock) -#define REMOTE_start_global_copy(wid) (REMOTE(wid)->optyap_data_.global_copy.start) -#define REMOTE_end_global_copy(wid) (REMOTE(wid)->optyap_data_.global_copy.end) -#define REMOTE_start_local_copy(wid) (REMOTE(wid)->optyap_data_.local_copy.start) -#define REMOTE_end_local_copy(wid) (REMOTE(wid)->optyap_data_.local_copy.end) -#define REMOTE_start_trail_copy(wid) (REMOTE(wid)->optyap_data_.trail_copy.start) -#define REMOTE_end_trail_copy(wid) (REMOTE(wid)->optyap_data_.trail_copy.end) -#define REMOTE_top_sg_fr(wid) (REMOTE(wid)->optyap_data_.top_subgoal_frame) -#define REMOTE_top_dep_fr(wid) (REMOTE(wid)->optyap_data_.top_dependency_frame) -#define REMOTE_pruning_scope(wid) (REMOTE(wid)->optyap_data_.bottom_pruning_scope) +#define REMOTE_share_request(wid) (REMOTE(wid)->optyap_data.share_request) +#define REMOTE_reply_signal(wid) (REMOTE(wid)->optyap_data.share_signals.reply_signal) +#define REMOTE_p_fase_signal(wid) (REMOTE(wid)->optyap_data.share_signals.P_fase) +#define REMOTE_q_fase_signal(wid) (REMOTE(wid)->optyap_data.share_signals.Q_fase) +#define REMOTE_lock_signals(wid) (REMOTE(wid)->optyap_data.share_signals.lock) +#define REMOTE_start_global_copy(wid) (REMOTE(wid)->optyap_data.global_copy.start) +#define REMOTE_end_global_copy(wid) (REMOTE(wid)->optyap_data.global_copy.end) +#define REMOTE_start_local_copy(wid) (REMOTE(wid)->optyap_data.local_copy.start) +#define REMOTE_end_local_copy(wid) (REMOTE(wid)->optyap_data.local_copy.end) +#define REMOTE_start_trail_copy(wid) (REMOTE(wid)->optyap_data.trail_copy.start) +#define REMOTE_end_trail_copy(wid) (REMOTE(wid)->optyap_data.trail_copy.end) +#define REMOTE_top_sg_fr(wid) (REMOTE(wid)->optyap_data.top_subgoal_frame) +#define REMOTE_top_dep_fr(wid) (REMOTE(wid)->optyap_data.top_dependency_frame) +#define REMOTE_pruning_scope(wid) (REMOTE(wid)->optyap_data.bottom_pruning_scope) #ifdef YAPOR_THREADS -#define REMOTE_top_cp_on_stack(wid) offset_to_cptr(REMOTE(wid)->optyap_data_.top_choice_point_on_stack_offset) -#define Set_REMOTE_top_cp_on_stack(wid, bptr) (REMOTE(wid)->optyap_data_.top_choice_point_on_stack_offset = cptr_to_offset(bptr)) +#define REMOTE_top_cp_on_stack(wid) offset_to_cptr(REMOTE(wid)->optyap_data.top_choice_point_on_stack_offset) +#define Set_REMOTE_top_cp_on_stack(wid, bptr) (REMOTE(wid)->optyap_data.top_choice_point_on_stack_offset = cptr_to_offset(bptr)) #else -#define REMOTE_top_cp_on_stack(wid) (REMOTE(wid)->optyap_data_.top_choice_point_on_stack) -#define Set_REMOTE_top_cp_on_stack(wid, bptr) (REMOTE(wid)->optyap_data_.top_choice_point_on_stack = (bptr)) +#define REMOTE_top_cp_on_stack(wid) (REMOTE(wid)->optyap_data.top_choice_point_on_stack) +#define Set_REMOTE_top_cp_on_stack(wid, bptr) (REMOTE(wid)->optyap_data.top_choice_point_on_stack = (bptr)) #endif /* YAPOR_THREADS */ -#define REMOTE_top_susp_or_fr(wid) (REMOTE(wid)->optyap_data_.top_or_frame_with_suspensions) -#define REMOTE_thread_output(wid) (REMOTE(wid)->optyap_data_.thread_output) -#define REMOTE_ma_timestamp(wid) (REMOTE(wid)->optyap_data_.ma_timestamp) -#define REMOTE_ma_h_top(wid) (REMOTE(wid)->optyap_data_.ma_h_top) -#define REMOTE_ma_hash_table(wid) (REMOTE(wid)->optyap_data_.ma_hash_table) +#define REMOTE_top_susp_or_fr(wid) (REMOTE(wid)->optyap_data.top_or_frame_with_suspensions) +#define REMOTE_thread_output(wid) (REMOTE(wid)->optyap_data.thread_output) +#define REMOTE_ma_timestamp(wid) (REMOTE(wid)->optyap_data.ma_timestamp) +#define REMOTE_ma_h_top(wid) (REMOTE(wid)->optyap_data.ma_h_top) +#define REMOTE_ma_hash_table(wid) (REMOTE(wid)->optyap_data.ma_hash_table) #ifdef YAPOR #include "or.structs.h" diff --git a/OPTYap/or.copy_engine.c b/OPTYap/or.copy_engine.c index a45a68d8a..443aeddca 100644 --- a/OPTYap/or.copy_engine.c +++ b/OPTYap/or.copy_engine.c @@ -66,29 +66,29 @@ static void share_private_nodes(int worker_q); #endif #define P_COPY_GLOBAL_TO(Q) \ - memcpy((void *) (worker_offset(Q) + REMOTE_start_global_copy(Q)), \ + memmove((void *) (worker_offset(Q) + REMOTE_start_global_copy(Q)), \ (void *) REMOTE_start_global_copy(Q), \ (size_t) (REMOTE_end_global_copy(Q) - REMOTE_start_global_copy(Q))) #define Q_COPY_GLOBAL_FROM(P) \ - memcpy((void *) LOCAL_start_global_copy, \ + memmove((void *) LOCAL_start_global_copy, \ (void *) (worker_offset(P) + LOCAL_start_global_copy), \ (size_t) (LOCAL_end_global_copy - LOCAL_start_global_copy)) #define P_COPY_LOCAL_TO(Q) \ - memcpy((void *) (worker_offset(Q) + REMOTE_start_local_copy(Q)), \ + memmove((void *) (worker_offset(Q) + REMOTE_start_local_copy(Q)), \ (void *) REMOTE_start_local_copy(Q), \ (size_t) (REMOTE_end_local_copy(Q) - REMOTE_start_local_copy(Q))) #define Q_COPY_LOCAL_FROM(P) \ - memcpy((void *) LOCAL_start_local_copy, \ + memmove((void *) LOCAL_start_local_copy, \ (void *) (worker_offset(P) + LOCAL_start_local_copy), \ (size_t) (LOCAL_end_local_copy - LOCAL_start_local_copy)) #define P_COPY_TRAIL_TO(Q) \ - memcpy((void *) (worker_offset(Q) + REMOTE_start_trail_copy(Q)), \ + memmove((void *) (worker_offset(Q) + REMOTE_start_trail_copy(Q)), \ (void *) REMOTE_start_trail_copy(Q), \ (size_t) (REMOTE_end_trail_copy(Q) - REMOTE_start_trail_copy(Q))) #define Q_COPY_TRAIL_FROM(P) \ - memcpy((void *) LOCAL_start_trail_copy, \ + memmove((void *) LOCAL_start_trail_copy, \ (void *) (worker_offset(P) + LOCAL_start_trail_copy), \ (size_t) (LOCAL_end_trail_copy - LOCAL_start_trail_copy)) diff --git a/OPTYap/tab.completion.c b/OPTYap/tab.completion.c index c8ad626dd..5dc16a557 100644 --- a/OPTYap/tab.completion.c +++ b/OPTYap/tab.completion.c @@ -409,13 +409,13 @@ void resume_suspension_frame(susp_fr_ptr resume_fr, or_fr_ptr top_or_fr) { sg_fr_ptr sg_frame; /* copy suspended stacks */ - memcpy(SuspFr_global_reg(resume_fr), + memmove(SuspFr_global_reg(resume_fr), SuspFr_global_start(resume_fr), SuspFr_global_size(resume_fr)); - memcpy(SuspFr_local_reg(resume_fr), + memmove(SuspFr_local_reg(resume_fr), SuspFr_local_start(resume_fr), SuspFr_local_size(resume_fr)); - memcpy(SuspFr_trail_reg(resume_fr), + memmove(SuspFr_trail_reg(resume_fr), SuspFr_trail_start(resume_fr), SuspFr_trail_size(resume_fr)); diff --git a/OPTYap/tab.macros.h b/OPTYap/tab.macros.h index 290246e6d..c8ba70d0b 100644 --- a/OPTYap/tab.macros.h +++ b/OPTYap/tab.macros.h @@ -574,9 +574,9 @@ typedef enum { SuspFr_global_size(SUSP_FR) = H_SIZE; \ SuspFr_local_size(SUSP_FR) = B_SIZE; \ SuspFr_trail_size(SUSP_FR) = TR_SIZE; \ - memcpy(SuspFr_global_start(SUSP_FR), SuspFr_global_reg(SUSP_FR), H_SIZE); \ - memcpy(SuspFr_local_start(SUSP_FR), SuspFr_local_reg(SUSP_FR), B_SIZE); \ - memcpy(SuspFr_trail_start(SUSP_FR), SuspFr_trail_reg(SUSP_FR), TR_SIZE) + memmove(SuspFr_global_start(SUSP_FR), SuspFr_global_reg(SUSP_FR), H_SIZE); \ + memmove(SuspFr_local_start(SUSP_FR), SuspFr_local_reg(SUSP_FR), B_SIZE); \ + memmove(SuspFr_trail_start(SUSP_FR), SuspFr_trail_reg(SUSP_FR), TR_SIZE) #define new_subgoal_trie_node(NODE, ENTRY, CHILD, PARENT, NEXT) \ ALLOC_SUBGOAL_TRIE_NODE(NODE); \ diff --git a/OPTYap/tab.tries.c b/OPTYap/tab.tries.c index 9f21e184d..53e19d39a 100644 --- a/OPTYap/tab.tries.c +++ b/OPTYap/tab.tries.c @@ -665,12 +665,12 @@ static void traverse_subgoal_trie(sg_node_ptr current_node, char *str, bucket = Hash_buckets(hash); last_bucket = bucket + Hash_num_buckets(hash); current_arity = (int *)malloc(sizeof(int) * (arity[0] + 1)); - memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1)); + memmove(current_arity, arity, sizeof(int) * (arity[0] + 1)); do { if (*bucket) { traverse_subgoal_trie(*bucket, str, str_index, arity, mode, TRAVERSE_POSITION_FIRST PASS_REGS); - memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1)); + memmove(arity, current_arity, sizeof(int) * (current_arity[0] + 1)); #ifdef TRIE_COMPACT_PAIRS if (arity[arity[0]] == -2 && str[str_index - 1] != '[') str[str_index - 1] = ','; @@ -687,7 +687,7 @@ static void traverse_subgoal_trie(sg_node_ptr current_node, char *str, /* save current state if first sibling node */ if (position == TRAVERSE_POSITION_FIRST) { current_arity = (int *)malloc(sizeof(int) * (arity[0] + 1)); - memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1)); + memmove(current_arity, arity, sizeof(int) * (arity[0] + 1)); current_str_index = str_index; current_mode = mode; } @@ -737,7 +737,7 @@ static void traverse_subgoal_trie(sg_node_ptr current_node, char *str, mode = current_mode; current_node = TrNode_next(current_node); while (current_node) { - memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1)); + memmove(arity, current_arity, sizeof(int) * (current_arity[0] + 1)); #ifdef TRIE_COMPACT_PAIRS if (arity[arity[0]] == -2 && str[str_index - 1] != '[') str[str_index - 1] = ','; @@ -768,12 +768,12 @@ static void traverse_answer_trie(ans_node_ptr current_node, char *str, bucket = Hash_buckets(hash); last_bucket = bucket + Hash_num_buckets(hash); current_arity = (int *)malloc(sizeof(int) * (arity[0] + 1)); - memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1)); + memmove(current_arity, arity, sizeof(int) * (arity[0] + 1)); do { if (*bucket) { traverse_answer_trie(*bucket, str, str_index, arity, var_index, mode, TRAVERSE_POSITION_FIRST PASS_REGS); - memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1)); + memmove(arity, current_arity, sizeof(int) * (current_arity[0] + 1)); #ifdef TRIE_COMPACT_PAIRS if (arity[arity[0]] == -2 && str[str_index - 1] != '[') str[str_index - 1] = ','; @@ -790,7 +790,7 @@ static void traverse_answer_trie(ans_node_ptr current_node, char *str, /* save current state if first sibling node */ if (position == TRAVERSE_POSITION_FIRST) { current_arity = (int *)malloc(sizeof(int) * (arity[0] + 1)); - memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1)); + memmove(current_arity, arity, sizeof(int) * (arity[0] + 1)); current_str_index = str_index; current_var_index = var_index; current_mode = mode; @@ -832,7 +832,7 @@ static void traverse_answer_trie(ans_node_ptr current_node, char *str, mode = current_mode; current_node = TrNode_next(current_node); while (current_node) { - memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1)); + memmove(arity, current_arity, sizeof(int) * (current_arity[0] + 1)); #ifdef TRIE_COMPACT_PAIRS if (arity[arity[0]] == -2 && str[str_index - 1] != '[') str[str_index - 1] = ','; @@ -863,12 +863,12 @@ static void traverse_global_trie(gt_node_ptr current_node, char *str, bucket = Hash_buckets(hash); last_bucket = bucket + Hash_num_buckets(hash); current_arity = (int *)malloc(sizeof(int) * (arity[0] + 1)); - memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1)); + memmove(current_arity, arity, sizeof(int) * (arity[0] + 1)); do { if (*bucket) { traverse_global_trie(*bucket, str, str_index, arity, mode, TRAVERSE_POSITION_FIRST PASS_REGS); - memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1)); + memmove(arity, current_arity, sizeof(int) * (current_arity[0] + 1)); #ifdef TRIE_COMPACT_PAIRS if (arity[arity[0]] == -2 && str[str_index - 1] != '[') str[str_index - 1] = ','; @@ -885,7 +885,7 @@ static void traverse_global_trie(gt_node_ptr current_node, char *str, /* save current state if first sibling node */ if (position == TRAVERSE_POSITION_FIRST) { current_arity = (int *)malloc(sizeof(int) * (arity[0] + 1)); - memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1)); + memmove(current_arity, arity, sizeof(int) * (arity[0] + 1)); current_str_index = str_index; current_mode = mode; } @@ -913,7 +913,7 @@ static void traverse_global_trie(gt_node_ptr current_node, char *str, mode = current_mode; current_node = TrNode_next(current_node); while (current_node) { - memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1)); + memmove(arity, current_arity, sizeof(int) * (current_arity[0] + 1)); #ifdef TRIE_COMPACT_PAIRS if (arity[arity[0]] == -2 && str[str_index - 1] != '[') str[str_index - 1] = ','; @@ -1200,7 +1200,7 @@ sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) { #ifdef MODE_DIRECTED_TABLING if (subs_pos) { ALLOC_BLOCK(mode_directed, subs_pos * sizeof(int), int); - memcpy((void *)mode_directed, (void *)aux_mode_directed, + memmove((void *)mode_directed, (void *)aux_mode_directed, subs_pos * sizeof(int)); } else mode_directed = NULL; diff --git a/OPTYap/tab.tries.insts.h b/OPTYap/tab.tries.insts.h index 55ae5df44..8553fe50c 100644 --- a/OPTYap/tab.tries.insts.h +++ b/OPTYap/tab.tries.insts.h @@ -77,7 +77,7 @@ #define copy_aux_stack() \ { arity_t size = 3 + heap_arity + subs_arity + vars_arity; \ TOP_STACK -= size; \ - memcpy(TOP_STACK, aux_stack, size * sizeof(CELL *)); \ + memmove(TOP_STACK, aux_stack, size * sizeof(CELL *)); \ aux_stack = TOP_STACK; \ }/* macros 'store_trie_node', 'restore_trie_node' and 'pop_trie_node' ** ** do not include 'set_cut' because trie instructions are cut safe */ diff --git a/OPTYap/traced_tab.tries.insts.h b/OPTYap/traced_tab.tries.insts.h index 2c8ac324d..d873bbc18 100644 --- a/OPTYap/traced_tab.tries.insts.h +++ b/OPTYap/traced_tab.tries.insts.h @@ -77,7 +77,7 @@ #define copy_aux_stack() \ { int size = 3 + heap_arity + subs_arity + vars_arity; \ TOP_STACK -= size; \ - memcpy(TOP_STACK, aux_stack, size * sizeof(CELL *)); \ + memmove(TOP_STACK, aux_stack, size * sizeof(CELL *)); \ aux_stack = TOP_STACK; \ }/* macros 'store_trie_node', 'restore_trie_node' and 'pop_trie_node' ** ** do not include 'set_cut' because trie instructions are cut safe */ diff --git a/README.md b/README.md index db6d7cd62..4ad000d6b 100644 --- a/README.md +++ b/README.md @@ -1,92 +1,92 @@ -

- The YAP Logo -

- -NOTE: this version of YAP is still experimental, documentation may be out of date. - -## Introduction - -This document provides User information on version 6.3.4 of -YAP (Yet Another Prolog). The YAP Prolog System is a -high-performance Prolog compiler developed at Universidade do -Porto. YAP supports stream Input/Output, sockets, modules, - exceptions, Prolog debugger, C-interface, dynamic code, internal - database, DCGs, saved states, co-routining, arrays, threads. - -We explicitly allow both commercial and non-commercial use of YAP. - - -YAP is based on the David H. D. Warren's WAM (Warren Abstract Machine), -with several optimizations for better performance. YAP follows the -Edinburgh tradition, and was originally designed to be largely -compatible with DEC-10 Prolog, Quintus Prolog, and especially with -C-Prolog. More recently, we have worked on being compatible with SICStus Prolog and with SWI-Prolog. - -YAP implements most of the ISO-Prolog standard. We are striving at -full compatibility, and the manual describes what is still -missing. -The document is intended neither as an introduction to Prolog nor to the -implementation aspects of the compiler. A good introduction to -programming in Prolog is the book @cite TheArtOfProlog , by -L. Sterling and E. Shapiro, published by "The MIT Press, Cambridge -MA". Other references should include the classical @cite ProgrammingInProlog , by W.F. Clocksin and C.S. Mellish, published by -Springer-Verlag. - -YAP 6.3.4 has been built with the gcc and clang compilers on Linux and OSX machines. We expect to recover support for WIN32 machines and -Android next. - -We are happy to include in YAP several excellent packages developed -under separate licenses. Our thanks to the authors for their kind -authorization to include these packages. - -The overall copyright and permission notice for YAP4.3 can be found in -the Artistic file in this directory. YAP follows the Perl Artistic -license, and it is thus non-copylefted freeware. Some components of YAP have been obtained from SWI Prolog and ciao, and have -different licenses. - -If you have a question about this software, desire to add code, found a -bug, want to request a feature, or wonder how to get further assistance, -please send e-mail to . To -subscribe to the mailing list, visit the page -. - -On-line documentation is available for [YAP](http://www.dcc.fp.pt/~vsc/yap/) - - - -The packages are, in alphabetical order: - -+ The CHR package developed by Tom Schrijvers, -Christian Holzbaur, and Jan Wielemaker. - -+ The CLP(BN) package and Horus toolkit developed by Tiago Gomes, and Vítor Santos Costa. - -+ The CLP(R) package developed by Leslie De Koninck, Bart Demoen, Tom -Schrijvers, and Jan Wielemaker, based on the CLP(Q,R) implementation -by Christian Holzbaur. - -+ The CPLint package developed by Fabrizio Riguzzi's research -laboratory at the [University of Ferrara](http://www.ing.unife.it/Docenti/FabrizioRiguzzi/) - -+ The CUDA interface package developed by Carlos Martínez, Jorge -Buenabad, Inês Dutra and Vítor Santos Costa. - -+ The [GECODE](http://www.gecode.org) interface package developed by Denys Duchier and Vítor Santos Costa. - -+ The [JPL](http://www.swi-prolog.org/packages/jpl/) (Java-Prolog Library) package developed by . - - The minisat SAT solver interface developed by Michael Codish, - Vitaly Lagoon, and Peter J. Stuckey. - -+ The MYDDAS relational data-base interface developed at the - Universidade do Porto by Tiago Soares, Michel Ferreira, and Ricardo Rocha. - -+ The [PRISM](http://rjida.meijo-u.ac.jp/prism/) logic-based -programming system for statistical modeling developed at the Sato -Research Laboratory, TITECH, Japan. - -+ The ProbLog 1 system developed by the [ProbLog](https://dtai.cs.kuleuven.be/problog) team in the -DTAI group of KULeuven. - -+ The [R](http://stoics.org.uk/~nicos/sware/packs/real/) interface package developed by Nicos Angelopoulos, -Vítor Santos Costa, João Azevedo, Jan Wielemaker, and Rui Camacho. +

+ The YAP Logo +

+ +NOTE: this version of YAP is still experimental, documentation may be out of date. + +## Introduction + +This document provides User information on version 6.3.4 of +YAP (Yet Another Prolog). The YAP Prolog System is a +high-performance Prolog compiler developed at Universidade do +Porto. YAP supports stream Input/Output, sockets, modules, + exceptions, Prolog debugger, C-interface, dynamic code, internal + database, DCGs, saved states, co-routining, arrays, threads. + +We explicitly allow both commercial and non-commercial use of YAP. + + +YAP is based on the David H. D. Warren's WAM (Warren Abstract Machine), +with several optimizations for better performance. YAP follows the +Edinburgh tradition, and was originally designed to be largely +compatible with DEC-10 Prolog, Quintus Prolog, and especially with +C-Prolog. More recently, we have worked on being compatible with SICStus Prolog and with SWI-Prolog. + +YAP implements most of the ISO-Prolog standard. We are striving at +full compatibility, and the manual describes what is still +missing. +The document is intended neither as an introduction to Prolog nor to the +implementation aspects of the compiler. A good introduction to +programming in Prolog is the book @cite TheArtOfProlog , by +L. Sterling and E. Shapiro, published by "The MIT Press, Cambridge +MA". Other references should include the classical @cite ProgrammingInProlog , by W.F. Clocksin and C.S. Mellish, published by +Springer-Verlag. + +YAP 6.3.4 has been built with the gcc and clang compilers on Linux and OSX machines. We expect to recover support for WIN32 machines and +Android next. + +We are happy to include in YAP several excellent packages developed +under separate licenses. Our thanks to the authors for their kind +authorization to include these packages. + +The overall copyright and permission notice for YAP4.3 can be found in +the Artistic file in this directory. YAP follows the Perl Artistic +license, and it is thus non-copylefted freeware. Some components of YAP have been obtained from SWI Prolog and ciao, and have +different licenses. + +If you have a question about this software, desire to add code, found a +bug, want to request a feature, or wonder how to get further assistance, +please send e-mail to . To +subscribe to the mailing list, visit the page +. + +On-line documentation is available for [YAP](http://www.dcc.fp.pt/~vsc/yap/) + + + +The packages are, in alphabetical order: + ++ The CHR package developed by Tom Schrijvers, +Christian Holzbaur, and Jan Wielemaker. + ++ The CLP(BN) package and Horus toolkit developed by Tiago Gomes, and Vítor Santos Costa. + ++ The CLP(R) package developed by Leslie De Koninck, Bart Demoen, Tom +Schrijvers, and Jan Wielemaker, based on the CLP(Q,R) implementation +by Christian Holzbaur. + ++ The CPLint package developed by Fabrizio Riguzzi's research +laboratory at the [University of Ferrara](http://www.ing.unife.it/Docenti/FabrizioRiguzzi/) + ++ The CUDA interface package developed by Carlos Martínez, Jorge +Buenabad, Inês Dutra and Vítor Santos Costa. + ++ The [GECODE](http://www.gecode.org) interface package developed by Denys Duchier and Vítor Santos Costa. + ++ The [JPL](http://www.swi-prolog.org/packages/jpl/) (Java-Prolog Library) package developed by . + + The minisat SAT solver interface developed by Michael Codish, + Vitaly Lagoon, and Peter J. Stuckey. + ++ The MYDDAS relational data-base interface developed at the + Universidade do Porto by Tiago Soares, Michel Ferreira, and Ricardo Rocha. + ++ The [PRISM](http://rjida.meijo-u.ac.jp/prism/) logic-based +programming system for statistical modeling developed at the Sato +Research Laboratory, TITECH, Japan. + ++ The ProbLog 1 system developed by the [ProbLog](https://dtai.cs.kuleuven.be/problog) team in the +DTAI group of KULeuven. + ++ The [R](http://stoics.org.uk/~nicos/sware/packs/real/) interface package developed by Nicos Angelopoulos, +Vítor Santos Costa, João Azevedo, Jan Wielemaker, and Rui Camacho. diff --git a/Threads.cmake b/Threads.cmake index 09834117f..180cb6f8c 100644 --- a/Threads.cmake +++ b/Threads.cmake @@ -1,9 +1,7 @@ macro_optional_find_package (Threads OFF) -macro_log_feature (THREADS_FOUND "Threads Support" - "GNU Threads Library (or similar)" - "http://www.gnu.org/software/threads") + if (WITH_Threads) # # CMAKE_THREAD_LIBS_INIT - the thread library diff --git a/YapTermConfig.h.cmake b/YapTermConfig.h.cmake index a76bf41b9..bafde36ba 100644 --- a/YapTermConfig.h.cmake +++ b/YapTermConfig.h.cmake @@ -55,4 +55,6 @@ #endif +#include "YapTerm.h" + #endif diff --git a/autoconf/config.h.in b/autoconf/config.h.in index e947b7598..63aaa0301 100644 --- a/autoconf/config.h.in +++ b/autoconf/config.h.in @@ -496,7 +496,7 @@ /* Define to 1 if you have the `mbsnrtowcs' function. */ #undef HAVE_MBSNRTOWCS -/* Define to 1 if you have the `memcpy' function. */ +/* Define to 1 if you have the `memmove' function. */ #undef HAVE_MEMCPY /* Define to 1 if you have the `memmove' function. */ diff --git a/autoconf/configure.in b/autoconf/configure.in index 90f79ab4f..525de3f88 100755 --- a/autoconf/configure.in +++ b/autoconf/configure.in @@ -1767,7 +1767,7 @@ AC_CHECK_FUNCS(localeconv localtime lstat mallinfo) AC_CHECK_FUNCS(mbscoll) AC_CHECK_FUNCS(mbscasecoll) AC_CHECK_FUNCS(mbsnrtowcs) -AC_CHECK_FUNCS(memcpy memmove mkstemp mktemp) +AC_CHECK_FUNCS(memmove memmove mkstemp mktemp) AC_CHECK_FUNCS(nanosleep mktime opendir) AC_CHECK_FUNCS(putenv rand random drand48) AC_CHECK_FUNCS(readlink realpath regexec) diff --git a/cmake/Config.cmake b/cmake/Config.cmake index 9207c0e71..094d3ce42 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -1,18 +1,4 @@ -# -# Optional Components -# -include(CheckIncludeFileCXX) -include(CheckSymbolExists) -include(CheckFunctionExists) -include(CheckIncludeFiles) -include(CheckFunctionExists) -include(CheckPrototypeExists) -include(CheckLibraryExists) -include(CheckTypeSize) -include(CheckVariableExists) -include(CheckCXXSourceCompiles) -include(TestBigEndian) -include(GetGitRevisionDescription) + # modern systems do this. @@ -112,6 +98,8 @@ check_include_file(winsock2.h HAVE_WINSOCK2_H) check_include_file(winsock.h HAVE_WINSOCK_H) check_include_file(wordexp.h HAVE_WORDEXP_H) +check_include_file(Python.h HAVE_PYTHON_H) + check_type_size("short int" SIZEOF_SHORT_INT) check_type_size("int" SIZEOF_INT) check_type_size("long int" SIZEOF_LONG) @@ -211,7 +199,6 @@ endif (HAVE_LIBLOG) # set(EXTRALIBS ${EXTRALIBS} socket) # endif (HAVE_LIBSOCKET) - find_library(HAVE_LIBPTHREAD pthread) if (HAVE_LIBPTHREAD) target_link_libraries(libYap pthread) @@ -263,8 +250,12 @@ check_function_exists(iswblank HAVE_ISWBLANK) check_function_exists(iswspace HAVE_ISWSPACE) check_symbol_exists(flsl HAVE_FLSL) check_symbol_exists(flsll HAVE_FLSLL) -check_function_exists(fmemopen HAVE_FMEMOPEN) +if (NOT APPLE) + # only recently available + check_function_exists(fmemopen HAVE_FMEMOPEN) +endif() check_function_exists(fpclass HAVE_FPCLASS) +check_function_exists(fpurge HAVE_FPURGE) check_function_exists(ftime HAVE_FTIME) check_function_exists(ftruncate HAVE_FTRUNCATE) check_function_exists(funopen HAVE_FUNOPEN) @@ -300,14 +291,16 @@ check_symbol_exists(mallinfo " malloc.h" HAVE_MALLINFO) check_function_exists(mbscoll HAVE_MBSCOLL) check_function_exists(mbscasecoll HAVE_MBSCASECOLL) check_function_exists(mbsnrtowcs HAVE_MBSNRTOWCS) -check_function_exists(memcpy HAVE_MEMCPY) +check_function_exists(memmove HAVE_MEMCPY) check_function_exists(memmove HAVE_MEMMOVE) check_function_exists(mkstemp HAVE_MKSTEMP) check_function_exists(mktemp HAVE_MKTEMP) check_function_exists(nanosleep HAVE_NANOSLEEP) check_function_exists(mktime HAVE_MKTIME) check_function_exists(opendir HAVE_OPENDIR) -check_function_exists(open_memstream HAVE_OPEN_MEMSTREAM) +if (NOT APPLE) + check_function_exists(open_memstream HAVE_OPEN_MEMSTREAM) + endif() check_function_exists(putenv HAVE_PUTENV) check_function_exists(rand HAVE_RAND) check_function_exists(random HAVE_RANDOM) @@ -399,6 +392,33 @@ git_describe(GIT_DESCRIBE) #Test standard headers (mimics AC_HEADER_STDC) include(TestSTDC) +if (WITH_READLINE) + +check_include_files( "stdio.h;readline/readline.h" HAVE_READLINE_READLINE_H ) +check_include_files( "stdio.h;readline/history.h" HAVE_READLINE_HISTORY_H ) +check_function_exists( add_history HAVE_ADD_HISTORY ) +check_function_exists( rl_begin_undo_group HAVE_RL_BEGIN_UNDO_GROUP) +check_function_exists( rl_clear_pending_input HAVE_RL_CLEAR_PENDING_INPUT) +check_function_exists( rl_discard_argument HAVE_RL_DISCARD_ARGUMENT) +check_symbol_exists( rl_filename_completion_function stdio.h;readline/readline.h HAVE_RL_FILENAME_COMPLETION_FUNCTION) +check_function_exists( rl_free_line_state HAVE_RL_FREE_LINE_STATE ) +check_function_exists( rl_insert_close HAVE_RL_INSERT_CLOSE ) +check_function_exists( rl_reset_after_signal HAVE_RL_RESET_AFTER_SIGNAL ) +check_function_exists( rl_set_keyboard_input_timeout HAVE_RL_SET_KEYBOARD_INPUT_TIMEOUT ) +check_function_exists( rl_set_prompt HAVE_RL_SET_PROMPT) +check_function_exists( rl_set_signals HAVE_RL_SET_SIGNALS) +check_symbol_exists( rl_catch_signals "stdio.h;readline/readline.h" HAVE_DECL_RL_CATCH_SIGNALS ) +check_type_size( rl_completion_func_t RL_COMPLETION_FUNC_T ) +check_symbol_exists( rl_done stdio.h;readline/readline.h HAVE_DECL_RL_DONE ) +CHECK_TYPE_SIZE( rl_hook_func_t RL_HOOK_FUNC_T ) +check_symbol_exists( rl_event_hook stdio.h;readline/readline.h HAVE_DECL_RL_EVENT_HOOK ) +check_symbol_exists( rl_readline_state stdio.h;readline/readline.h HAVE_DECL_RL_READLINE_STATE ) +check_function_exists( add_history HAVE_ADD_HISTORY) +check_function_exists( remove_history HAVE_REMOVE_HISTORY) +check_function_exists( using_history HAVE_USING_HISTORY) +endif() + +configure_file(${CMAKE_SOURCE_DIR}/os/YapIOConfig.h.cmake ${CMAKE_BINARY_DIR}/YapIOConfig.h) configure_file(${CMAKE_CURRENT_LIST_DIR}/../config.h.cmake ${CMAKE_BINARY_DIR}/YapConfig.h) configure_file(${CMAKE_CURRENT_LIST_DIR}/../YapTermConfig.h.cmake @@ -406,5 +426,3 @@ configure_file(${CMAKE_CURRENT_LIST_DIR}/../YapTermConfig.h.cmake configure_file(${CMAKE_CURRENT_LIST_DIR}/../config.h.cmake ${CMAKE_BINARY_DIR}/config.h) configure_file(${CMAKE_CURRENT_LIST_DIR}/../GitSHA1.c.in GitSHA1.c @ONLY) -configure_file(${CMAKE_CURRENT_LIST_DIR}/../os/YapIOConfig.h.cmake ${CMAKE_BINARY_DIR}/os/YapIOConfig.h) - diff --git a/cmake/FindGMP.cmake b/cmake/FindGMP.cmake index 9744b2ff7..e93282749 100644 --- a/cmake/FindGMP.cmake +++ b/cmake/FindGMP.cmake @@ -8,16 +8,31 @@ # GMP_LIBRARY_DLL - library DLL to install. Only available on WIN32. # GMP_LIBRARIES_DIR - the directory the library we link with is found in. + if (ANDROID) -set( GMP_ROOT ${CMAKE_SOURCE_DIR}/../gmp/${ANDROID_ABI} ) - set (GMP_FOUND ON) - set (GMP_INCLUDE_DIRS ${GMP_ROOT}) - set (GMP_LIBRARIES ${GMP_ROOT}/libgmp.so) - set (GMP_LIBRARIES_DIR ${GMP_ROOT}) -else(ANDROID) -if(MSVC) + + set( GMP_ROOT ${CMAKE_SOURCE_DIR}/../gmp/${ANDROID_ABI} ) + if (EXISTS ${GMP_ROOT} ) + message("Looking good for ${GMP_ROOT}") + set(GMP_INCLUDE_DIRS ${GMP_ROOT} CACHE PATH "include search path") + set(GMP_LIBRARIES ${GMP_ROOT}/libgmp.so CACHE FILEPATH "include search path") + set(GMP_LIBRARIES_DIR ${GMP_ROOT} CACHE PATH "include search path") + else() + message("Bad call: ${GMP_ROOT} does not exist") + endif() +find_path(GMP_INCLUDE_DIRS + NAMES gmp.h + HINTS ${GMP_ROOT} + NO_SYSTEM_ENVIRONMENT_PATH) + find_library(GMP_LIBRARIES NAMES gmp + PATHS + ${GMP_ROOT} + NO_SYSTEM_ENVIRONMENT_PATH) + + +elseif(MSVC) find_library(GMP_LIBRARIES NAMES mpir mpird - PATHS + PATHS $ENV{GMP_ROOT} $ENV{GMP_ROOT}/lib ${GMP_ROOT} @@ -26,7 +41,8 @@ if(MSVC) ${CMAKE_SOURCE_DIR}/../tools/mpird/lib ${CMAKE_SOURCE_DIR}/../mpir/lib ${CMAKE_SOURCE_DIR}/../mpird/lib - $ENV{PROGRAMFILES}/mpir/lib + + $ENV{PROGRAMFILES}/mpir/lib $ENV{PROGRAMFILES}/mpird/lib $ENV{HOME}/mpir/lib $ENV{HOME}/mpird/lib @@ -49,28 +65,21 @@ find_file(GMP_LIBRARY_DLL NAMES mpir.dll mpird.dll ${GMP_LIBRARIES_DIR} ) -else(MSVC) +else() #use GMP, notice that there are two cases, everything is the same directory, or everything is in #its proper places -find_path(GMP_INCLUDE_DIRS - NAMES gmp.h - PATHS - . - ${GMP_ROOT} - ${GMP_LIBRARIES_DIR}/../include - ${GMP_LIBRARIES_DIR} - ) - find_library(GMP_LIBRARIES NAMES gmp - PATHS + find_library(GMP_LIBRARIES + NAMES gmp libgmp + HINTS . - ${GMP_ROOT} - ${GMP_ROOT}/lib $ENV{GMP_ROOT} $ENV{GMP_ROOT}/lib + ${GMP_ROOT} + ${GMP_ROOT}/lib /usr/local/opt/gmp/lib /opt/lib /usr/local/lib @@ -78,20 +87,34 @@ find_path(GMP_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/lib ) + + find_path(GMP_INCLUDE_DIRS + NAMES gmp.h + HINTS + . + $ENV{GMP_ROOT} + $ENV{GMP_ROOT}/include + ${GMP_ROOT} + ${GMP_ROOT}/include + ${GMP_LIBRARIES_DIR}/../include + ${GMP_LIBRARIES_DIR} + ) + endif() + get_filename_component(GMP_LIBRARIES_DIR "${GMP_LIBRARIES}" PATH CACHE) -endif(MSVC) -endif(ANDROID) - # handle the QUIET and REQUIRED arguments and set GMP_FOUND to TRUE if # all listed variables are true include(FindPackageHandleStandardArgs) if(MSVC) - find_package_handle_standard_args(GMP DEFAULT_MSG GMP_LIBRARIES GMP_LIBRARIES_DIR GMP_LIBRARY_DLL GMP_INCLUDE_DIRS) -mark_as_advanced(GMP_LIBRARY_DLL) + find_package_handle_standard_args(GMP DEFAULT_MSG GMP_LIBRARIES GMP_LIBRARIES_DIR GMP_LIBRARY_DLL GMP_INCLUDE_DIRS) + mark_as_advanced(GMP_LIBRARY_DLL) else() - find_package_handle_standard_args(GMP DEFAULT_MSG GMP_LIBRARIES GMP_LIBRARIES_DIR GMP_INCLUDE_DIRS) + find_package_handle_standard_args(GMP DEFAULT_MSG GMP_LIBRARIES GMP_LIBRARIES_DIR GMP_INCLUDE_DIRS) endif() + mark_as_advanced(GMP_LIBRARIES GMP_LIBRARIES_DIR GMP_INCLUDE_DIRS) + + diff --git a/cmake/FindGecode.cmake b/cmake/FindGecode.cmake index 402767dee..789f14870 100644 --- a/cmake/FindGecode.cmake +++ b/cmake/FindGecode.cmake @@ -8,16 +8,14 @@ find_file(GECODE_CONFIG gecode/support/config.hpp PATHS ${GECODE_ROOT_DIR}/incl find_library(GECODE_LIBRARY NAMES gecodekernel PATHS ${GECODE_ROOT_DIR}/lib ${CMAKE_INSTALL_PREFIX}/lib /usr/local/lib /opt/local/lib /usr}/lib) find_library(GECODE_SUPPORT_LIBRARY NAMES gecodesupport PATHS ${GECODE_ROOT_DIR}/lib ${CMAKE_INSTALL_PREFIX}/lib /usr/local/lib /opt/local/lib /usr}/include) -if(GECODE_CONFIG) - file(STRINGS ${GECODE_CONFIG} GECODE_LINE_VERSION REGEX "^#define GECODE_VERSION .*") - string(REGEX MATCH "[0-9].[0-9].[0-9]" GECODE_VERSION ${GECODE_LINE_VERSION}) -endif() if(GECODE_INCLUDE_DIR AND GECODE_LIBRARY AND GECODE_SUPPORT_LIBRARY) set(GECODE_FOUND Yes) -endif() -if(GECODE_FOUND) +if( GECODE_CONFIG AND GECODE_INCLUDE_DIR AND GECODE_LIBRARY) + file(STRINGS ${GECODE_CONFIG} GECODE_LINE_VERSION REGEX "^#define GECODE_VERSION .*") + string(REGEX MATCH "[0-9].[0-9].[0-9]" GECODE_VERSION ${GECODE_LINE_VERSION}) +endif() set(GECODE_LIBRARIES ${GECODE_LIBRARY} ${GECODE_SUPPORT_LIBRARY}) set(GECODE_INCLUDE_DIRS ${GECODE_INCLUDE_DIR}) find_library(GECODE_DRIVER_LIBRARY gecodedriver PATHS ${CMAKE_INSTALL_PREFIX}/lib) diff --git a/cmake/FindLLVM.cmake b/cmake/FindLLVM.cmake index 4a364f9ff..a0fbf77d0 100644 --- a/cmake/FindLLVM.cmake +++ b/cmake/FindLLVM.cmake @@ -177,7 +177,7 @@ else() llvm_set(SYSTEM_LIBS system-libs) string(REPLACE "\n" " " LLVM_LDFLAGS "${LLVM_LDFLAGS} ${LLVM_SYSTEM_LIBS}") endif() - llvm_set(LIBRARY_DIRS libdir true) + llvm_set(LIBRARY_DIRS CMAKE_INSTALL_LIBDIR true) llvm_set_libs(LIBRARIES libfiles "${LLVM_LIBRARY_DIRS}") endif() diff --git a/cmake/FindLibR.cmake b/cmake/FindLibR.cmake index d6a05569d..1bdfe994e 100755 --- a/cmake/FindLibR.cmake +++ b/cmake/FindLibR.cmake @@ -1,7 +1,7 @@ # # FindLibR.cmake # -# Copyright (C) 2009-11 by RStudio, Inc. +# Copyright (C) 2009-18 by RStudio, Inc. # # This program is licensed to you under the terms of version 3 of the # GNU Affero General Public License. This program is distributed WITHOUT @@ -21,11 +21,24 @@ if(APPLE) find_library(LIBR_LIBRARIES R) - if(LIBR_LIBRARIES) + + if(LIBR_LIBRARIES MATCHES ".*\\.framework") set(LIBR_HOME "${LIBR_LIBRARIES}/Resources" CACHE PATH "R home directory") set(LIBR_INCLUDE_DIRS "${LIBR_HOME}/include" CACHE PATH "R include directory") set(LIBR_DOC_DIR "${LIBR_HOME}/doc" CACHE PATH "R doc directory") set(LIBR_EXECUTABLE "${LIBR_HOME}/R" CACHE PATH "R executable") + else() + get_filename_component(_LIBR_LIBRARIES "${LIBR_LIBRARIES}" REALPATH) + get_filename_component(_LIBR_LIBRARIES_DIR "${_LIBR_LIBRARIES}" PATH) + set(LIBR_EXECUTABLE "${_LIBR_LIBRARIES_DIR}/../bin/R") + execute_process( + COMMAND ${LIBR_EXECUTABLE} "--slave" "--vanilla" "-e" "cat(R.home())" + OUTPUT_VARIABLE LIBR_HOME + ) + set(LIBR_HOME ${LIBR_HOME} CACHE PATH "R home directory") + set(LIBR_INCLUDE_DIRS "${LIBR_HOME}/include" CACHE PATH "R include directory") + set(LIBR_DOC_DIR "${LIBR_HOME}/doc" CACHE PATH "R doc directory") + set(LIBR_LIB_DIR "${LIBR_HOME}/lib" CACHE PATH "R lib directory") endif() # detection for UNIX & Win32 @@ -103,12 +116,15 @@ else() set(LIBR_INCLUDE_DIRS "${LIBR_HOME}/include" CACHE PATH "R include directory") set(LIBR_DOC_DIR "${LIBR_HOME}/doc" CACHE PATH "R doc directory") - # set library hint path based on whether we are doing a special session 64 build - if(LIBR_FIND_WINDOWS_64BIT) - set(LIBRARY_ARCH_HINT_PATH "${LIBR_HOME}/bin/x64") - else() - set(LIBRARY_ARCH_HINT_PATH "${LIBR_HOME}/bin/i386") - endif() + # set library hint path for 64-bit build + set(LIBR_ARCH "x64") + set(LIBRARY_ARCH_HINT_PATH "${LIBR_HOME}/bin/x64") + + # call dll2lib.R to ensure export files are generated + execute_process( + COMMAND "${LIBR_HOME}/bin/${LIBR_ARCH}/Rscript.exe" "dll2lib.R" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/tools" + RESULT_VARIABLE LIBR_DLL2LIB_RESULT) endif() @@ -173,6 +189,7 @@ find_package_handle_standard_args(LibR DEFAULT_MSG if(LIBR_FOUND) message(STATUS "Found R: ${LIBR_HOME}") + get_filename_component(LIBR_BIN_DIR "${LIBR_EXECUTABLE}" PATH CACHE) endif() # mark low-level variables from FIND_* calls as advanced diff --git a/cmake/FindPostgreSQL.cmake b/cmake/FindPostgreSQL.cmake deleted file mode 100644 index fa972ca8d..000000000 --- a/cmake/FindPostgreSQL.cmake +++ /dev/null @@ -1,192 +0,0 @@ -#.rst: -# FindPostgreSQL -# -------------- -# -# Find the PostgreSQL installation. -# -# This module defines -# -# :: -# -# PostgreSQL_LIBRARIES - the PostgreSQL libraries needed for linking -# PostgreSQL_INCLUDE_DIRS - the directories of the PostgreSQL headers -# PostgreSQL_LIBRARY_DIRS - the link directories for PostgreSQL libraries -# PostgreSQL_VERSION_STRING - the version of PostgreSQL found (since CMake 2.8.8) - -#============================================================================= -# Copyright 2004-2009 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -# ---------------------------------------------------------------------------- -# History: -# This module is derived from the module originally found in the VTK source tree. -# -# ---------------------------------------------------------------------------- -# Note: -# PostgreSQL_ADDITIONAL_VERSIONS is a variable that can be used to set the -# version mumber of the implementation of PostgreSQL. -# In Windows the default installation of PostgreSQL uses that as part of the path. -# E.g C:\Program Files\PostgreSQL\8.4. -# Currently, the following version numbers are known to this module: -# "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0" -# -# To use this variable just do something like this: -# set(PostgreSQL_ADDITIONAL_VERSIONS "9.2" "8.4.4") -# before calling find_package(PostgreSQL) in your CMakeLists.txt file. -# This will mean that the versions you set here will be found first in the order -# specified before the default ones are searched. -# -# ---------------------------------------------------------------------------- -# You may need to manually set: -# PostgreSQL_INCLUDE_DIR - the path to where the PostgreSQL include files are. -# PostgreSQL_LIBRARY_DIR - The path to where the PostgreSQL library files are. -# If FindPostgreSQL.cmake cannot find the include files or the library files. -# -# ---------------------------------------------------------------------------- -# The following variables are set if PostgreSQL is found: -# PostgreSQL_FOUND - Set to true when PostgreSQL is found. -# PostgreSQL_INCLUDE_DIRS - Include directories for PostgreSQL -# PostgreSQL_LIBRARY_DIRS - Link directories for PostgreSQL libraries -# PostgreSQL_LIBRARIES - The PostgreSQL libraries. -# -# ---------------------------------------------------------------------------- -# If you have installed PostgreSQL in a non-standard location. -# (Please note that in the following comments, it is assumed that -# points to the root directory of the include directory of PostgreSQL.) -# Then you have three options. -# 1) After CMake runs, set PostgreSQL_INCLUDE_DIR to /include and -# PostgreSQL_LIBRARY_DIR to wherever the library pq (or libpq in windows) is -# 2) Use CMAKE_INCLUDE_PATH to set a path to /PostgreSQL<-version>. This will allow find_path() -# to locate PostgreSQL_INCLUDE_DIR by utilizing the PATH_SUFFIXES option. e.g. In your CMakeLists.txt file -# set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "/include") -# 3) Set an environment variable called ${PostgreSQL_ROOT} that points to the root of where you have -# installed PostgreSQL, e.g. . -# -# ---------------------------------------------------------------------------- - -set(PostgreSQL_INCLUDE_PATH_DESCRIPTION "top-level directory containing the PostgreSQL include directories. E.g /usr/local/include/PostgreSQL/8.4 or C:/Program Files/PostgreSQL/8.4/include") -set(PostgreSQL_INCLUDE_DIR_MESSAGE "Set the PostgreSQL_INCLUDE_DIR cmake cache entry to the ${PostgreSQL_INCLUDE_PATH_DESCRIPTION}") -set(PostgreSQL_LIBRARY_PATH_DESCRIPTION "top-level directory containing the PostgreSQL libraries.") -set(PostgreSQL_LIBRARY_DIR_MESSAGE "Set the PostgreSQL_LIBRARY_DIR cmake cache entry to the ${PostgreSQL_LIBRARY_PATH_DESCRIPTION}") -set(PostgreSQL_ROOT_DIR_MESSAGE "Set the PostgreSQL_ROOT system variable to where PostgreSQL is found on the machine E.g C:/Program Files/PostgreSQL/8.4") - - -set(PostgreSQL_KNOWN_VERSIONS ${PostgreSQL_ADDITIONAL_VERSIONS} - "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0") - -# Define additional search paths for root directories. -set( PostgreSQL_ROOT_DIRECTORIES - ENV PostgreSQL_ROOT - ${PostgreSQL_ROOT} -) -foreach(suffix ${PostgreSQL_KNOWN_VERSIONS}) - if(WIN32) - list(APPEND PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES - "PostgreSQL/${suffix}/lib") - list(APPEND PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES - "PostgreSQL/${suffix}/include") - list(APPEND PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES - "PostgreSQL/${suffix}/include/server") - endif() - if(UNIX) - list(APPEND PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES - "postgresql/${suffix}/server") - endif() -endforeach() - -# -# Look for an installation. -# -find_path(PostgreSQL_INCLUDE_DIR - NAMES libpq-fe.h - PATHS - # Look in other places. - ${PostgreSQL_ROOT_DIRECTORIES} - PATH_SUFFIXES - pgsql - postgresql - include - ${PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES} - # Help the user find it if we cannot. - DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}" -) - -find_path(PostgreSQL_TYPE_INCLUDE_DIR - NAMES catalog/pg_type.h - PATHS - # Look in other places. - ${PostgreSQL_ROOT_DIRECTORIES} - PATH_SUFFIXES - postgresql - pgsql/server - postgresql/server - include/server - ${PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES} - # Help the user find it if we cannot. - DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}" -) - -# The PostgreSQL library. -set (PostgreSQL_LIBRARY_TO_FIND pq) -# Setting some more prefixes for the library -set (PostgreSQL_LIB_PREFIX "") -if ( WIN32 ) - set (PostgreSQL_LIB_PREFIX ${PostgreSQL_LIB_PREFIX} "lib") - set (PostgreSQL_LIBRARY_TO_FIND ${PostgreSQL_LIB_PREFIX}${PostgreSQL_LIBRARY_TO_FIND}) -endif() - -find_library(PostgreSQL_LIBRARY - NAMES ${PostgreSQL_LIBRARY_TO_FIND} - PATHS - ${PostgreSQL_ROOT_DIRECTORIES} - PATH_SUFFIXES - lib - ${PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES} - # Help the user find it if we cannot. - DOC "The ${PostgreSQL_LIBRARY_DIR_MESSAGE}" -) -get_filename_component(PostgreSQL_LIBRARY_DIR ${PostgreSQL_LIBRARY} PATH) - -if (PostgreSQL_INCLUDE_DIR) - # Some platforms include multiple pg_config.hs for multi-lib configurations - # This is a temporary workaround. A better solution would be to compile - # a dummy c file and extract the value of the symbol. - file(GLOB _PG_CONFIG_HEADERS "${PostgreSQL_INCLUDE_DIR}/pg_config*.h") - foreach(_PG_CONFIG_HEADER ${_PG_CONFIG_HEADERS}) - if(EXISTS "${_PG_CONFIG_HEADER}") - file(STRINGS "${_PG_CONFIG_HEADER}" pgsql_version_str - REGEX "^#define[\t ]+PG_VERSION[\t ]+\".*\"") - if(pgsql_version_str) - string(REGEX REPLACE "^#define[\t ]+PG_VERSION[\t ]+\"([^\"]*)\".*" - "\\1" PostgreSQL_VERSION_STRING "${pgsql_version_str}") - break() - endif() - endif() - endforeach() - unset(pgsql_version_str) -endif() - -# Did we find anything? -#nclude(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -find_package_handle_standard_args(PostgreSQL - REQUIRED_VARS PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR - VERSION_VAR PostgreSQL_VERSION_STRING) -set(PostgreSQL_FOUND ${POSTGRESQL_FOUND}) - -# Now try to get the include and library path. -if(PostgreSQL_FOUND) - set(PostgreSQL_INCLUDE_DIRS ${PostgreSQL_INCLUDE_DIR} ${PostgreSQL_TYPE_INCLUDE_DIR} ) - set(PostgreSQL_LIBRARY_DIRS ${PostgreSQL_LIBRARY_DIR} ) - set(PostgreSQL_LIBRARIES ${PostgreSQL_LIBRARY_TO_FIND}) -endif() - -mark_as_advanced(PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR PostgreSQL_LIBRARY ) diff --git a/cmake/FindR.cmake b/cmake/FindR.cmake new file mode 100644 index 000000000..b64cf144a --- /dev/null +++ b/cmake/FindR.cmake @@ -0,0 +1,77 @@ + +# +# - This module locates an installed R distribution. +# +# Defines the following: +# R_COMMAND - Path to R command +# R_HOME - Path to 'R home', as reported by R +# R_INCLUDE_DIR - Path to R include directory +# R_LIBRARY_BASE - Path to R library +# R_LIBRARY_BLAS - Path to Rblas / blas library +# R_LIBRARY_LAPACK - Path to Rlapack / lapack library +# R_LIBRARY_READLINE - Path to readline library +# R_LIBRARIES - Array of: R_LIBRARY_BASE, R_LIBRARY_BLAS, R_LIBRARY_LAPACK, R_LIBRARY_BASE [, R_LIBRARY_READLINE] +# +# VTK_R_HOME - (deprecated, use R_HOME instead) Path to 'R home', as reported by R +# +# Variable search order: +# 1. Attempt to locate and 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 +# + +set(TEMP_CMAKE_FIND_APPBUNDLE ${CMAKE_FIND_APPBUNDLE}) +set(CMAKE_FIND_APPBUNDLE "NEVER") +find_program(R_COMMAND R DOC "R executable.") +set(CMAKE_FIND_APPBUNDLE ${TEMP_CMAKE_FIND_APPBUNDLE}) + +if(R_COMMAND) + execute_process(WORKING_DIRECTORY . + COMMAND ${R_COMMAND} RHOME + OUTPUT_VARIABLE R_ROOT_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + # deprecated + if(VTK_R_HOME) + set(R_HOME ${VTK_R_HOME} CACHE PATH "R home directory obtained from R RHOME") + else() + set(R_HOME ${R_ROOT_DIR} CACHE PATH "R home directory obtained from R RHOME") + set(VTK_R_HOME ${R_HOME}) + endif() + # /deprecated + # the following command does nothing currently, but will be used when deprecated code is removed + set(R_HOME ${R_ROOT_DIR} CACHE PATH "R home directory obtained from R RHOME") + + find_path(R_INCLUDE_DIR R.h + HINTS ${R_ROOT_DIR} + PATHS /usr/local/lib /usr/local/lib64 /usr/share + PATH_SUFFIXES include R/include + DOC "Path to file R.h") + + find_library(R_LIBRARY_BASE R + HINTS ${R_ROOT_DIR}/lib + DOC "R library (example libR.a, libR.dylib, etc.).") + + find_library(R_LIBRARY_BLAS NAMES Rblas blas + HINTS ${R_ROOT_DIR}/lib + DOC "Rblas library (example libRblas.a, libRblas.dylib, etc.).") + + find_library(R_LIBRARY_LAPACK NAMES Rlapack lapack + HINTS ${R_ROOT_DIR}/lib + DOC "Rlapack library (example libRlapack.a, libRlapack.dylib, etc.).") + + find_library(R_LIBRARY_READLINE readline + DOC "(Optional) system readline library. Only required if the R libraries were built with readline support.") + +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/cmake/FindReadline.cmake b/cmake/FindReadline.cmake index e2ed8f23f..3e74d67d7 100644 --- a/cmake/FindReadline.cmake +++ b/cmake/FindReadline.cmake @@ -7,87 +7,67 @@ # READLINE_readline_LIBRARY, where to find the READLINE library. # READLINE_ncurses_LIBRARY, where to find the ncurses library [might not be defined] - # Apple readline does not support readline hooks # So we look for another one by default # # # try to extract R from readline to avoid collision -IF(APPLE) - FIND_PATH(READLINE_INCLUDE_DIR NAMES readline/readline.h PATHS - ${R_INCLUDE_DIR} - /sw/include - /opt/local/include - /opt/include - /usr/local/opt/readline/include #brew - /usr/local/include - /usr/include/ - NO_DEFAULT_PATH - ) -ENDIF(APPLE) FIND_PATH(READLINE_INCLUDE_DIR NAMES readline/readline.h) +FIND_LIBRARY(READLINE_readline_LIBRARY NAMES readline) + +# Sometimes readline really needs ncurses +FIND_LIBRARY(READLINE_ncurses_LIBRARY NAMES ncurses) + +FIND_LIBRARY(READLINE_ncursesw_LIBRARY NAMES ncursesw) + +# Sometimes ncurses really needs terminfo +FIND_LIBRARY(READLINE_tinfo_LIBRARY NAMES tinfo) + +FIND_LIBRARY(READLINE_tinfow_LIBRARY NAMES tinfow) + + # Apple readline does not support readline hooks # So we look for another one by default -IF(APPLE) - FIND_LIBRARY(READLINE_readline_LIBRARY NAMES readline PATHS - /sw/lib - /opt/local/lib - /usr/local/opt/readline/lib #brew - /opt/lib - /usr/local/lib - /usr/lib - NO_DEFAULT_PATH - ) -ENDIF(APPLE) -FIND_LIBRARY(READLINE_readline_LIBRARY NAMES readline) +if ( READLINE_readline_LIBRARY) + set (HAVE_LIBREADLINE YES CACHE BOOL "ibReadline ACCESS") +endif() -# Sometimes readline really needs ncurses -IF(APPLE) - FIND_LIBRARY(READLINE_ncurses_LIBRARY NAMES ncurses PATHS - /sw/lib - /opt/local/lib - /opt/lib - /usr/local/lib - /usr/lib - NO_DEFAULT_PATH - ) -ENDIF(APPLE) -FIND_LIBRARY(READLINE_ncurses_LIBRARY NAMES ncurses) - -MARK_AS_ADVANCED( - READLINE_INCLUDE_DIR - READLINE_readline_LIBRARY - READLINE_ncurses_LIBRARY - ) - -SET( READLINE_FOUND "NO" ) -IF(READLINE_INCLUDE_DIR) - IF(READLINE_readline_LIBRARY) - SET( READLINE_FOUND "YES" ) - SET( READLINE_LIBRARIES +IF(READLINE_readline_LIBRARY) + set(HAVE_LIBREADLINE CACHE YES BOOL "Readline works." ) + SET( READLINE_LIBRARIES ${READLINE_readline_LIBRARY} ) # some readline libraries depend on ncurses IF(READLINE_ncurses_LIBRARY) - SET(READLINE_LIBRARIES ${READLINE_LIBRARIES} ${READLINE_ncurses_LIBRARY}) - ENDIF(READLINE_ncurses_LIBRARY) + list(APPEND READLINE_LIBRARIES ${READLINE_ncurses_LIBRARY}) + endif () + # some readline libraries depend on ncurses + IF(READLINE_ncursesw_LIBRARY) + list(APPEND READLINE_LIBRARIES ${READLINE_ncursesw_LIBRARY}) + endif () + + # some readline libraries depend on tinfo + IF(READLINE_tinfo_LIBRARY) + list(APPEND READLINE_LIBRARIES ${READLINE_tinfo_LIBRARY}) + endif () + + # some readline libraries depend on tinfo + IF(READLINE_tinfow_LIBRARY) + list(APPEND READLINE_LIBRARIES ${READLINE_tinfow_LIBRARY}) + endif () + + IF(READLINE_INCLUDE_DIR) + SET( READLINE_FOUND "YES" CACHE BOOL "Readline ACCESS.") + ENDIF(READLINE_INCLUDE_DIR) ENDIF(READLINE_readline_LIBRARY) -ENDIF(READLINE_INCLUDE_DIR) - -IF(READLINE_FOUND) - MESSAGE(STATUS "Found readline library") -ELSE(READLINE_FOUND) - IF(READLINE_FIND_REQUIRED) - MESSAGE(SYSTEM_ERROR_FATAL "Could not find readline -- please give some paths to CMake") - ENDIF(READLINE_FIND_REQUIRED) -ENDIF(READLINE_FOUND) - -find_package_handle_standard_args(Readline READLINE_INCLUDE_DIR READLINE_LIBRARIES READLINE_readline_LIBRARY READLINE_ncurses_LIBRARY) -MARK_AS_ADVANCED( - READLINE_FOUND - ) +message(STATUS "readline found: ${READLINE_FOUND}") + +if (READLINE_FOUND) +message(STATUS "readline headers found at ${READLINE_INCLUDE_DIR}") +message(STATUS "readline library found at ${READLINE_LIBRARIES}") +endif() diff --git a/cmake/FindSqlite3.cmake b/cmake/FindSqlite3.cmake deleted file mode 100644 index b505f6810..000000000 --- a/cmake/FindSqlite3.cmake +++ /dev/null @@ -1,101 +0,0 @@ -# - Try to find Sqlite3 -# Once done this will define -# -# SQLITE3_FOUND - system has Sqlite3 -# SQLITE3_INCLUDE_DIRS - the Sqlite3 include directory -# SQLITE3_LIBRARIES - Link these to use Sqlite3 -# SQLITE3_DEFINITIONS - Compiler switches required for using Sqlite3 -# -# Copyright (c) 2008 Andreas Schneider -# -# Redistribution and use is allowed according to the terms of the New -# BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. -# - - -if (SQLITE3_LIBRARIES AND SQLITE3_INCLUDE_DIRS) - # in cache already - set(SQLITE3_FOUND TRUE) -else (SQLITE3_LIBRARIES AND SQLITE3_INCLUDE_DIRS) - # use pkg-config to get the directories and then use these values - # in the FIND_PATH() and FIND_LIBRARY() calls - if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) - include(UsePkgConfig) - pkgconfig(sqlite3 _SQLITE3_INCLUDEDIR _SQLITE3_LIBDIR _SQLITE3_LDFLAGS _SQLITE3_CFLAGS) - else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) - find_package(PkgConfig) - if (PKG_CONFIG_FOUND) - pkg_check_modules(_SQLITE3 sqlite3) - endif (PKG_CONFIG_FOUND) - endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) - find_path(SQLITE3_INCLUDE_DIR - NAMES - sqlite3.h - PATHS - #! brew is better than default - /usr/local/opt/sqlite/include - ${_SQLITE3_INCLUDEDIR} - /usr/include - /usr/local/include - /opt/local/include - /sw/include - NO_DEFAULT_PATH - ) - - find_path(SQLITE3_INCLUDE_DIR - NAMES - sqlite3.h - ) - - find_library(SQLITE3_LIBRARY - NAMES - sqlite3 - PATHS - /usr/local/opt/sqlite/lib - ${_SQLITE3_LIBDIR} - /usr/lib - /usr/local/lib - /opt/local/lib - /sw/lib - NO_DEFAULT_PATH - ) - - find_library(SQLITE3_LIBRARY - NAMES - sqlite3 - ) - - if (SQLITE3_LIBRARY) - set(SQLITE3_FOUND TRUE) - endif (SQLITE3_LIBRARY) - - set(SQLITE3_INCLUDE_DIRS - ${SQLITE3_INCLUDE_DIR} - ) - - if (SQLITE3_FOUND) - set(SQLITE3_LIBRARIES - ${SQLITE3_LIBRARIES} - ${SQLITE3_LIBRARY} - ) - endif (SQLITE3_FOUND) - - if (SQLITE3_INCLUDE_DIRS AND SQLITE3_LIBRARIES) - set(SQLITE3_FOUND TRUE) - endif (SQLITE3_INCLUDE_DIRS AND SQLITE3_LIBRARIES) - - if (SQLITE3_FOUND) - if (NOT Sqlite3_FIND_QUIETLY) - message(STATUS "Found Sqlite3: ${SQLITE3_LIBRARIES}") - endif (NOT Sqlite3_FIND_QUIETLY) - else (SQLITE3_FOUND) - if (Sqlite3_FIND_REQUIRED) - message(SYSTEM_ERROR_FATAL "Could not find Sqlite3") - endif (Sqlite3_FIND_REQUIRED) - endif (SQLITE3_FOUND) - - # show the SQLITE3_INCLUDE_DIRS and SQLITE3_LIBRARIES variables only in the advanced view - mark_as_advanced(SQLITE3_INCLUDE_DIRS SQLITE3_LIBRARIES) - -endif (SQLITE3_LIBRARIES AND SQLITE3_INCLUDE_DIRS) diff --git a/cmake/MacroLogFeature.cmake b/cmake/MacroLogFeature.cmake index 01924ad5e..df50a31fe 100644 --- a/cmake/MacroLogFeature.cmake +++ b/cmake/MacroLogFeature.cmake @@ -1,6 +1,6 @@ # This file defines the Feature Logging macros. # -# MACRO_LOG_FEATURE(VAR FEATURE DESCRIPTION URL [REQUIRED [MIN_VERSION [COMMENTS]]]) +# (VAR FEATURE DESCRIPTION URL [REQUIRED [MIN_VERSION [COMMENTS]]]) # Logs the information so that it can be displayed at the end # of the configure run # VAR : TRUE or FALSE, indicating whether the feature is supported diff --git a/cmake/PackageDocs.cmake b/cmake/PackageDocs.cmake new file mode 100644 index 000000000..d72d36345 --- /dev/null +++ b/cmake/PackageDocs.cmake @@ -0,0 +1,21 @@ + #get package NAME + + get_filename_component( TMPD ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY ) + +get_filename_component( CMAKE_PROJECT_NAME ${TMPD} NAME ) + set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) + +set( DOC_INPUT_FILES ${TMPD} ) +LIST (APPEND DOC_TAGS ${CMAKE_PROJECT_NAME}=${CMAKE_CURRENT_BINARY_DIR}/html/${CMAKE_PROJECT_NAME} PARENT_SCOPE) +LIST (APPEND DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/html/${CMAKE_PROJECT_NAME} PARENT_SCOPE) + + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/html/${CMAKE_PROJECT_NAME} + COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} VERBATIM + DEPENDS ${doxyfile} ${DOCS} + ) + + configure_file(${doxyfile_in} ${doxyfile} @ONLY) + + configure_file(${CMAKE_SOURCE_DIR}/docs/source/conf.py.in source/conf.py) + configure_file(${CMAKE_SOURCE_DIR}/docs/source/index.rst source/index.rst) diff --git a/cmake/Prelims.cmake b/cmake/Prelims.cmake index 5e3bba6fb..a7c4e5290 100644 --- a/cmake/Prelims.cmake +++ b/cmake/Prelims.cmake @@ -164,17 +164,3 @@ set(YAP_ROOTDIR "${prefix}") include (cudd NO-POLICY-SCOPE) include (python NO-POLICY-SCOPE) include (java NO-POLICY-SCOPE) - -set (pl_library "" CACHE INTERNAL "prolog library files" ) -set (pl_os_library "" CACHE INTERNAL "prolog os files" ) -set (pl_boot_library "" CACHE INTERNAL "prolog boot files" ) - -function(add_to_group output list) - set (result "") - foreach (path IN LISTS ${list}) - get_source_file_property(result ${path} LOCATION) - list( APPEND tmp ${result}) - endforeach () - list( APPEND ${output} ${tmp}) - set (${output} ${${output}} CACHE INTERNAL "prolog library files") -endfunction(add_to_group output list ) diff --git a/cmake/Sources.cmake b/cmake/Sources.cmake index 715808c86..dcaea42c8 100644 --- a/cmake/Sources.cmake +++ b/cmake/Sources.cmake @@ -104,65 +104,172 @@ set(C_INTERFACE_SOURCES list(APPEND LIBYAP_SOURCES ${C_INTERFACE_SOURCES} ${ENGINE_SOURCES}) - set (HEADERS - H/Atoms.h - H/sshift.h - H/Yap.h - H/Yatom.h - H/YapHeap.h - H/Regs.h - H/Yapproto.h - H/absmi.h - H/absmi-switch.h - H/absmi-threaded.h - H/absmi-traced.h - H/alloc.h - H/amidefs.h - H/amiops.h - H/arrays.h - H/arith2.h - H/attvar.h - H/blobs.h - H/clause.h - H/YapCompile.h - H/corout.h - H/dlmalloc.h - H/generated/dglobals.h - H/generated/dlocals.h - H/generated/dhstruct.h - H/YapEval.h - H/heapgc.h - H/generated/hglobals.h - H/generated/hlocals.h - H/generated/hstruct.h - H/generated/iglobals.h - H/generated/ihstruct.h - H/generated/ilocals.h - H/index.h - H/inline-only.h - H/qly.h - H/rclause.h - H/generated/rglobals.h - H/generated/rlocals.h - H/rheap.h - H/generated/rhstruct.h - H/threads.h - H/tracer.h - H/trim_trail.h - H/YapSignals.h - H/YapGFlagInfo.h - H/YapFlags.h - H/YapLFlagInfo.h - H/YapText.h - H/cut_c.h - H/generated/iatoms.h - H/generated/ratoms.h - H/generated/tatoms.h - CXX/yapdb.hh - CXX/yapi.hh - BEAM/eam.h BEAM/eamamasm.h +set( BEAM_HEADERS +BEAM/beam.h +) + set (CORE_HEADERS + ${CMAKE_SOURCE_DIR}/H/Atoms.h + ${CMAKE_SOURCE_DIR}/H/Foreign.h + ${CMAKE_SOURCE_DIR}/H/Regs.h + ${CMAKE_SOURCE_DIR}/H/ScannerTypes.h + ${CMAKE_SOURCE_DIR}/H/Tags_24bits.h + ${CMAKE_SOURCE_DIR}/H/Tags_32LowTag.h + ${CMAKE_SOURCE_DIR}/H/Tags_32Ops.h + ${CMAKE_SOURCE_DIR}/H/Tags_32bits.h + ${CMAKE_SOURCE_DIR}/H/Tags_64bits.h + ${CMAKE_SOURCE_DIR}/H/TermExt.h + ${CMAKE_SOURCE_DIR}/H/Yap.h + ${CMAKE_SOURCE_DIR}/H/YapAppliedOpcodes.h + ${CMAKE_SOURCE_DIR}/H/YapCompile.h + ${CMAKE_SOURCE_DIR}/H/YapCompoundTerm.h + ${CMAKE_SOURCE_DIR}/H/YapEval.h + ${CMAKE_SOURCE_DIR}/H/YapFlags.h + ${CMAKE_SOURCE_DIR}/H/YapGFlagInfo.h + ${CMAKE_SOURCE_DIR}/H/YapHandles.h + ${CMAKE_SOURCE_DIR}/H/YapHeap.h + ${CMAKE_SOURCE_DIR}/H/YapLFlagInfo.h + ${CMAKE_SOURCE_DIR}/H/YapOpcodes.h + ${CMAKE_SOURCE_DIR}/H/YapSignals.h + ${CMAKE_SOURCE_DIR}/H/YapTags.h + ${CMAKE_SOURCE_DIR}/H/YapText.h + ${CMAKE_SOURCE_DIR}/H/Yapproto.h + ${CMAKE_SOURCE_DIR}/H/Yatom.h + ${CMAKE_SOURCE_DIR}/H/absmi-interpretrer.h + ${CMAKE_SOURCE_DIR}/H/absmi-switch.h + ${CMAKE_SOURCE_DIR}/H/absmi-threaded.h + ${CMAKE_SOURCE_DIR}/H/absmi-traced.h + ${CMAKE_SOURCE_DIR}/H/absmi.h + ${CMAKE_SOURCE_DIR}/H/alloc.h + ${CMAKE_SOURCE_DIR}/H/amidefs.h + ${CMAKE_SOURCE_DIR}/H/amijit.h + ${CMAKE_SOURCE_DIR}/H/amiops.h + ${CMAKE_SOURCE_DIR}/H/arith2.h + ${CMAKE_SOURCE_DIR}/H/arrays.h + ${CMAKE_SOURCE_DIR}/H/attvar.h + ${CMAKE_SOURCE_DIR}/H/clause.h + ${CMAKE_SOURCE_DIR}/H/corout.h + ${CMAKE_SOURCE_DIR}/H/cut_c.h + ${CMAKE_SOURCE_DIR}/H/dlmalloc.h + ${CMAKE_SOURCE_DIR}/H/fields.h + ${CMAKE_SOURCE_DIR}/H/findclause.h + ${CMAKE_SOURCE_DIR}/H/generated/dglobals.h + ${CMAKE_SOURCE_DIR}/H/generated/dhstruct.h + ${CMAKE_SOURCE_DIR}/H/generated/h0globals.h + ${CMAKE_SOURCE_DIR}/H/generated/h0struct.h + ${CMAKE_SOURCE_DIR}/H/generated/hglobals.h + ${CMAKE_SOURCE_DIR}/H/generated/hlocals.h + ${CMAKE_SOURCE_DIR}/H/generated/hstruct.h + ${CMAKE_SOURCE_DIR}/H/generated/i0globals.h + ${CMAKE_SOURCE_DIR}/H/generated/iatoms.h + ${CMAKE_SOURCE_DIR}/H/generated/iglobals.h + ${CMAKE_SOURCE_DIR}/H/generated/ihstruct.h + ${CMAKE_SOURCE_DIR}/H/generated/ilocals.h + ${CMAKE_SOURCE_DIR}/H/generated/ratoms.h + ${CMAKE_SOURCE_DIR}/H/generated/rglobals.h + ${CMAKE_SOURCE_DIR}/H/generated/rhstruct.h + ${CMAKE_SOURCE_DIR}/H/generated/rlocals.h + ${CMAKE_SOURCE_DIR}/H/generated/tatoms.h + ${CMAKE_SOURCE_DIR}/H/globals.h + ${CMAKE_SOURCE_DIR}/H/headclause.h + ${CMAKE_SOURCE_DIR}/H/heap.h + ${CMAKE_SOURCE_DIR}/H/heapgc.h + ${CMAKE_SOURCE_DIR}/H/index.h + ${CMAKE_SOURCE_DIR}/H/inline-only.h + ${CMAKE_SOURCE_DIR}/H/iswiatoms.h + ${CMAKE_SOURCE_DIR}/H/locals.h + ${CMAKE_SOURCE_DIR}/H/nolocks.h + ${CMAKE_SOURCE_DIR}/H/qly.h + ${CMAKE_SOURCE_DIR}/H/rclause.h + ${CMAKE_SOURCE_DIR}/H/rheap.h + ${CMAKE_SOURCE_DIR}/H/saveclause.h + ${CMAKE_SOURCE_DIR}/H/sig.h + ${CMAKE_SOURCE_DIR}/H/sshift.h + ${CMAKE_SOURCE_DIR}/H/threads.h + ${CMAKE_SOURCE_DIR}/H/tracer.h + ${CMAKE_SOURCE_DIR}/H/trim_trail.h + ${CMAKE_SOURCE_DIR}/H/udi_private.h + ${CMAKE_SOURCE_DIR}/H/utarray.h + ${CMAKE_SOURCE_DIR}/H/uthash.h + ${CMAKE_SOURCE_DIR}/H/walkclause.h + ${CMAKE_SOURCE_DIR}/H/yerror.h ) +set (INCLUDE_HEADERS + ${CMAKE_SOURCE_DIR}/include/GitSHA1.h + ${CMAKE_SOURCE_DIR}/include/SWI-Prolog.h + ${CMAKE_SOURCE_DIR}/include/VFS.h + ${CMAKE_SOURCE_DIR}/include/YapBlobs.h + ${CMAKE_SOURCE_DIR}/include/YapDefs.h + ${CMAKE_SOURCE_DIR}/include/YapError.h + ${CMAKE_SOURCE_DIR}/include/YapErrors.h + ${CMAKE_SOURCE_DIR}/include/YapFormat.h + ${CMAKE_SOURCE_DIR}/include/YapInterface.h + ${CMAKE_SOURCE_DIR}/include/YapRegs.h + ${CMAKE_SOURCE_DIR}/include/YapStreams.h + ${CMAKE_SOURCE_DIR}/include/YapUTF8.h + ${CMAKE_SOURCE_DIR}/include/YapTerm.h + ${CMAKE_SOURCE_DIR}/include/c_interface.h + ${CMAKE_SOURCE_DIR}/include/clause_list.h + ${CMAKE_SOURCE_DIR}/include/pl-types.h + ${CMAKE_SOURCE_DIR}/include/udi.h +) + +set (CONFIGURATION_HEADERS +${CMAKE_BINARY_DIR}/YapConfig.h + ${CMAKE_BINARY_DIR}/YapTermConfig.h + ${CMAKE_BINARY_DIR}/dlocals.h + ${CMAKE_BINARY_DIR}/YapIOConfig.h +) + + +set (CXX_HEADERS + ${CMAKE_SOURCE_DIR}/CXX/yapa.hh + ${CMAKE_SOURCE_DIR}/CXX/yapdb.hh + ${CMAKE_SOURCE_DIR}/CXX/yapi.hh + ${CMAKE_SOURCE_DIR}/CXX/yapie.hh + ${CMAKE_SOURCE_DIR}/CXX/yapq.hh + ${CMAKE_SOURCE_DIR}/CXX/yapt.hh + +) +set (PYTHON_HEADERS ${CMAKE_SOURCE_DIR}/packages/python/py4yap.h) + +set (OPTYap_HEADERS + ${CMAKE_SOURCE_DIR}/OPTYap/opt.config.h + ${CMAKE_SOURCE_DIR}/OPTYap/opt.proto.h + ${CMAKE_SOURCE_DIR}/OPTYap/opt.structs.h + ${CMAKE_SOURCE_DIR}/OPTYap/opt.macros.h + ${CMAKE_SOURCE_DIR}/OPTYap/or.macros.h + ${CMAKE_SOURCE_DIR}/OPTYap/or.sba_amiops.h + ${CMAKE_SOURCE_DIR}/OPTYap/or.sba_unify.h + ${CMAKE_SOURCE_DIR}/OPTYap/tab.structs.h + ${CMAKE_SOURCE_DIR}/OPTYap/locks_x86.h + ${CMAKE_SOURCE_DIR}/OPTYap/locks_sparc.h + ${CMAKE_SOURCE_DIR}/OPTYap/locks_mips.h + ${CMAKE_SOURCE_DIR}/OPTYap/locks_mips_funcs.h + ${CMAKE_SOURCE_DIR}/OPTYap/locks_alpha.h + ${CMAKE_SOURCE_DIR}/OPTYap/locks_alpha_funcs.h + ${CMAKE_SOURCE_DIR}/OPTYap/locks_pthread.h + + ) + +set (YAPOS_HEADERS + ${CMAKE_SOURCE_DIR}/os/encoding.h + ${CMAKE_SOURCE_DIR}/os/fmemopen.h + ${CMAKE_SOURCE_DIR}/os/format.h + ${CMAKE_SOURCE_DIR}/os/getw.h + ${CMAKE_SOURCE_DIR}/os/iopreds.h + ${CMAKE_SOURCE_DIR}/os/sysbits.h + ${CMAKE_SOURCE_DIR}/os/yapio.h +) + +list( APPEND c_headers ${CMAKE_SOURCE_DIR}/utf8proc/utf8proc.h ) +list( APPEND c_headers ${YAPOS_HEADERS} ) +list( APPEND c_headers ${OPTYap_HEADERS} ) +list( APPEND c_headers ${INCLUDE_HEADERS} ) +list( APPEND c_headers ${CORE_HEADERS} ) +list (APPEND c_headers ${PYTHON_HEADERS}) +#list( APPEND c_headers ${CONFIGURATION_HEADERS} ) +list( APPEND cxx_headers ${CXX_HEADERS} ) set(STATIC_SOURCES diff --git a/cmake/Threads.cmake b/cmake/Threads.cmake index 09834117f..84634f2ed 100644 --- a/cmake/Threads.cmake +++ b/cmake/Threads.cmake @@ -1,9 +1,6 @@ macro_optional_find_package (Threads OFF) -macro_log_feature (THREADS_FOUND "Threads Support" - "GNU Threads Library (or similar)" - "http://www.gnu.org/software/threads") if (WITH_Threads) # # CMAKE_THREAD_LIBS_INIT - the thread library diff --git a/cmake/UseSWIG.cmake b/cmake/UseSWIG.cmake new file mode 100644 index 000000000..c8b1cd7c4 --- /dev/null +++ b/cmake/UseSWIG.cmake @@ -0,0 +1,349 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#.rst: +# UseSWIG +# ------- +# +# Defines the following macros for use with SWIG: +# +# :: +# +# SWIG_ADD_LIBRARY( +# [TYPE ] +# LANGUAGE +# SOURCES ... +# ) +# - Define swig module with given name and specified language +# SWIG_LINK_LIBRARIES(name [ libraries ]) +# - Link libraries to swig module +# +# Source files properties on module files can be set before the invocation +# of the SWIG_ADD_LIBRARY macro to specify special behavior of SWIG. +# +# The source file property CPLUSPLUS calls SWIG in c++ mode, e.g.:: +# +# set_property(SOURCE mymod.i PROPERTY CPLUSPLUS ON) +# swig_add_library(mymod LANGUAGE python SOURCES mymod.i) +# +# The source file property SWIG_FLAGS adds custom flags to the SWIG executable. +# +# The source-file property SWIG_MODULE_NAME have to be provided to specify the actual +# import name of the module in the target language if it cannot be scanned automatically +# from source or different from the module file basename.:: +# +# set_property(SOURCE mymod.i PROPERTY SWIG_MODULE_NAME mymod_realname) +# +# To get the name of the swig module target library, use: ${SWIG_MODULE_${name}_REAL_NAME}. +# +# Also some variables can be set to specify special behavior of SWIG. +# +# CMAKE_SWIG_FLAGS can be used to add special flags to all swig calls. +# +# CMAKE_SWIG_OUTDIR allows one to specify where to write +# the language specific files (swig -outdir option). +# +# SWIG_OUTFILE_DIR allows one to specify where to write the output file +# (swig -o option). If not specified, CMAKE_SWIG_OUTDIR is used. +# +# The name-specific variable SWIG_MODULE__EXTRA_DEPS may be used to specify extra +# dependencies for the generated modules. +# +# If the source file generated by swig need some special flag you can use:: +# +# set_source_files_properties( ${swig_generated_file_fullname} +# PROPERTIES COMPILE_FLAGS "-bla") + +set(SWIG_CXX_EXTENSION "cxx") +set(SWIG_EXTRA_LIBRARIES "") + +set(SWIG_PYTHON_EXTRA_FILE_EXTENSIONS ".py") +set(SWIG_JAVA_EXTRA_FILE_EXTENSIONS ".java" "JNI.java") + +# +# For given swig module initialize variables associated with it +# +macro(SWIG_MODULE_INITIALIZE name language) + string(TOUPPER "${language}" swig_uppercase_language) + string(TOLOWER "${language}" swig_lowercase_language) + set(SWIG_MODULE_${name}_LANGUAGE "${swig_uppercase_language}") + set(SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG "${swig_lowercase_language}") + + set(SWIG_MODULE_${name}_REAL_NAME "${name}") + if (";${CMAKE_SWIG_FLAGS};" MATCHES ";-noproxy;") + set (SWIG_MODULE_${name}_NOPROXY TRUE) + endif () + if("x${SWIG_MODULE_${name}_LANGUAGE}" STREQUAL "xUNKNOWN") + message(FATAL_ERROR "SWIG Error: Language \"${language}\" not found") + elseif("x${SWIG_MODULE_${name}_LANGUAGE}" STREQUAL "xPYTHON" AND NOT SWIG_MODULE_${name}_NOPROXY) + # swig will produce a module.py containing an 'import _modulename' statement, + # which implies having a corresponding _modulename.so (*NIX), _modulename.pyd (Win32), + # unless the -noproxy flag is used + set(SWIG_MODULE_${name}_REAL_NAME "_${name}") + elseif("x${SWIG_MODULE_${name}_LANGUAGE}" STREQUAL "xPERL") + set(SWIG_MODULE_${name}_EXTRA_FLAGS "-shadow") + endif() +endmacro() + +# +# For a given language, input file, and output file, determine extra files that +# will be generated. This is internal swig macro. +# + +macro(SWIG_GET_EXTRA_OUTPUT_FILES language outfiles generatedpath infile) + set(${outfiles} "") + get_source_file_property(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename + ${infile} SWIG_MODULE_NAME) + if(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename STREQUAL "NOTFOUND") + + # try to get module name from "%module foo" syntax + if ( EXISTS ${infile} ) + file ( STRINGS ${infile} _MODULE_NAME REGEX "[ ]*%module[ ]*[a-zA-Z0-9_]+.*" ) + endif () + if ( _MODULE_NAME ) + string ( REGEX REPLACE "[ ]*%module[ ]*([a-zA-Z0-9_]+).*" "\\1" _MODULE_NAME "${_MODULE_NAME}" ) + set(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename "${_MODULE_NAME}") + + else () + # try to get module name from "%module (options=...) foo" syntax + if ( EXISTS ${infile} ) + file ( STRINGS ${infile} _MODULE_NAME REGEX "[ ]*%module[ ]*\\(.*\\)[ ]*[a-zA-Z0-9_]+.*" ) + endif () + if ( _MODULE_NAME ) + string ( REGEX REPLACE "[ ]*%module[ ]*\\(.*\\)[ ]*([a-zA-Z0-9_]+).*" "\\1" _MODULE_NAME "${_MODULE_NAME}" ) + set(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename "${_MODULE_NAME}") + + else () + # fallback to file basename + get_filename_component(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename ${infile} NAME_WE) + endif () + endif () + + endif() + foreach(it ${SWIG_${language}_EXTRA_FILE_EXTENSIONS}) + set(extra_file "${generatedpath}/${SWIG_GET_EXTRA_OUTPUT_FILES_module_basename}${it}") + list(APPEND ${outfiles} ${extra_file}) + # Treat extra outputs as plain files regardless of language. + set_property(SOURCE "${extra_file}" PROPERTY LANGUAGE "") + endforeach() +endmacro() + +# +# Take swig (*.i) file and add proper custom commands for it +# +macro(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) + set(swig_full_infile ${infile}) + get_filename_component(swig_source_file_name_we "${infile}" NAME_WE) + get_source_file_property(swig_source_file_generated ${infile} GENERATED) + get_source_file_property(swig_source_file_cplusplus ${infile} CPLUSPLUS) + get_source_file_property(swig_source_file_flags ${infile} SWIG_FLAGS) + if("${swig_source_file_flags}" STREQUAL "NOTFOUND") + set(swig_source_file_flags "") + endif() + get_filename_component(swig_source_file_fullname "${infile}" ABSOLUTE) + + # If CMAKE_SWIG_OUTDIR was specified then pass it to -outdir + if(CMAKE_SWIG_OUTDIR) + set(swig_outdir ${CMAKE_SWIG_OUTDIR}) + else() + set(swig_outdir ${CMAKE_CURRENT_BINARY_DIR}) + endif() + + if(SWIG_OUTFILE_DIR) + set(swig_outfile_dir ${SWIG_OUTFILE_DIR}) + else() + set(swig_outfile_dir ${swig_outdir}) + endif() + + if (NOT SWIG_MODULE_${name}_NOPROXY) + SWIG_GET_EXTRA_OUTPUT_FILES(${SWIG_MODULE_${name}_LANGUAGE} + swig_extra_generated_files + "${swig_outdir}" + "${swig_source_file_fullname}") + endif() + set(swig_generated_file_fullname + "${swig_outfile_dir}/${swig_source_file_name_we}") + # add the language into the name of the file (i.e. TCL_wrap) + # this allows for the same .i file to be wrapped into different languages + string(APPEND swig_generated_file_fullname + "${SWIG_MODULE_${name}_LANGUAGE}_wrap") + + if(swig_source_file_cplusplus) + string(APPEND swig_generated_file_fullname + ".${SWIG_CXX_EXTENSION}") + else() + string(APPEND swig_generated_file_fullname + ".c") + endif() + + #message("Full path to source file: ${swig_source_file_fullname}") + #message("Full path to the output file: ${swig_generated_file_fullname}") + get_directory_property(cmake_include_directories INCLUDE_DIRECTORIES) + list(REMOVE_DUPLICATES cmake_include_directories) + set(swig_include_dirs) + foreach(it ${cmake_include_directories}) + set(swig_include_dirs ${swig_include_dirs} "-I${it}") + endforeach() + + set(swig_special_flags) + # default is c, so add c++ flag if it is c++ + if(swig_source_file_cplusplus) + set(swig_special_flags ${swig_special_flags} "-c++") + endif() + if("x${SWIG_MODULE_${name}_LANGUAGE}" STREQUAL "xCSHARP") + if(NOT ";${swig_source_file_flags};${CMAKE_SWIG_FLAGS};" MATCHES ";-dllimport;") + # This makes sure that the name used in the generated DllImport + # matches the library name created by CMake + set(SWIG_MODULE_${name}_EXTRA_FLAGS "-dllimport;${name}") + endif() + endif() + set(swig_extra_flags) + if(SWIG_MODULE_${name}_EXTRA_FLAGS) + set(swig_extra_flags ${swig_extra_flags} ${SWIG_MODULE_${name}_EXTRA_FLAGS}) + endif() + add_custom_command( + OUTPUT "${swig_generated_file_fullname}" ${swig_extra_generated_files} + # Let's create the ${swig_outdir} at execution time, in case dir contains $(OutDir) + COMMAND ${CMAKE_COMMAND} -E make_directory ${swig_outdir} + COMMAND "${SWIG_EXECUTABLE}" + ARGS "-${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}" + ${swig_source_file_flags} + ${CMAKE_SWIG_FLAGS} + -outdir ${swig_outdir} + ${swig_special_flags} + ${swig_extra_flags} + ${swig_include_dirs} + -o "${swig_generated_file_fullname}" + "${swig_source_file_fullname}" + MAIN_DEPENDENCY "${swig_source_file_fullname}" + DEPENDS ${SWIG_MODULE_${name}_EXTRA_DEPS} + IMPLICIT_DEPENDS CXX "${swig_source_file_fullname}" + COMMENT "Swig source") + set_source_files_properties("${swig_generated_file_fullname}" ${swig_extra_generated_files} + PROPERTIES GENERATED 1) + set(${outfiles} "${swig_generated_file_fullname}" ${swig_extra_generated_files}) +endmacro() + +# +# Create Swig module +# +macro(SWIG_ADD_MODULE name language) + message(DEPRECATION "SWIG_ADD_MODULE is deprecated. Use SWIG_ADD_LIBRARY instead.") + swig_add_library(${name} + LANGUAGE ${language} + TYPE MODULE + SOURCES ${ARGN}) +endmacro() + + +macro(SWIG_ADD_LIBRARY name) + set(options "") + set(oneValueArgs LANGUAGE + TYPE) + set(multiValueArgs SOURCES) + cmake_parse_arguments(_SAM "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(NOT DEFINED _SAM_LANGUAGE) + message(FATAL_ERROR "SWIG_ADD_LIBRARY: Missing LANGUAGE argument") + endif() + + if(NOT DEFINED _SAM_SOURCES) + message(FATAL_ERROR "SWIG_ADD_LIBRARY: Missing SOURCES argument") + endif() + + if(NOT DEFINED _SAM_TYPE) + set(_SAM_TYPE MODULE) + elseif("${_SAM_TYPE}" STREQUAL "USE_BUILD_SHARED_LIBS") + unset(_SAM_TYPE) + endif() + + swig_module_initialize(${name} ${_SAM_LANGUAGE}) + + set(swig_dot_i_sources) + set(swig_other_sources) + foreach(it ${_SAM_SOURCES}) + if(${it} MATCHES "\\.i$") + set(swig_dot_i_sources ${swig_dot_i_sources} "${it}") + else() + set(swig_other_sources ${swig_other_sources} "${it}") + endif() + endforeach() + + set(swig_generated_sources) + foreach(it ${swig_dot_i_sources}) + SWIG_ADD_SOURCE_TO_MODULE(${name} swig_generated_source ${it}) + set(swig_generated_sources ${swig_generated_sources} "${swig_generated_source}") + endforeach() + get_directory_property(swig_extra_clean_files ADDITIONAL_MAKE_CLEAN_FILES) + set_directory_properties(PROPERTIES + ADDITIONAL_MAKE_CLEAN_FILES "${swig_extra_clean_files};${swig_generated_sources}") + add_library(${SWIG_MODULE_${name}_REAL_NAME} + ${_SAM_TYPE} + ${swig_generated_sources} + ${swig_other_sources}) + if("${_SAM_TYPE}" STREQUAL "MODULE") + set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES NO_SONAME ON) + endif() + string(TOLOWER "${_SAM_LANGUAGE}" swig_lowercase_language) + if ("${swig_lowercase_language}" STREQUAL "octave") + set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "") + set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".oct") + elseif ("${swig_lowercase_language}" STREQUAL "go") + set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "") + elseif ("${swig_lowercase_language}" STREQUAL "java") + if (APPLE) + # In java you want: + # System.loadLibrary("LIBRARY"); + # then JNI will look for a library whose name is platform dependent, namely + # MacOS : libLIBRARY.jnilib + # Windows: LIBRARY.dll + # Linux : libLIBRARY.so + set_target_properties (${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".jnilib") + endif () + elseif ("${swig_lowercase_language}" STREQUAL "lua") + if("${_SAM_TYPE}" STREQUAL "MODULE") + set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "") + endif() + elseif ("${swig_lowercase_language}" STREQUAL "python") + # this is only needed for the python case where a _modulename.so is generated + set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "") + # Python extension modules on Windows must have the extension ".pyd" + # instead of ".dll" as of Python 2.5. Older python versions do support + # this suffix. + # http://docs.python.org/whatsnew/ports.html#SECTION0001510000000000000000 + # + # Windows: .dll is no longer supported as a filename extension for extension modules. + # .pyd is now the only filename extension that will be searched for. + # + if(WIN32 AND NOT CYGWIN) + set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".pyd") + endif() + elseif ("${swig_lowercase_language}" STREQUAL "r") + set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "") + elseif ("${swig_lowercase_language}" STREQUAL "ruby") + # In ruby you want: + # require 'LIBRARY' + # then ruby will look for a library whose name is platform dependent, namely + # MacOS : LIBRARY.bundle + # Windows: LIBRARY.dll + # Linux : LIBRARY.so + set_target_properties (${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "") + if (APPLE) + set_target_properties (${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".bundle") + endif () + else() + # assume empty prefix because we expect the module to be dynamically loaded + set_target_properties (${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "") + endif () +endmacro() + +# +# Like TARGET_LINK_LIBRARIES but for swig modules +# +macro(SWIG_LINK_LIBRARIES name) + if(SWIG_MODULE_${name}_REAL_NAME) + target_link_libraries(${SWIG_MODULE_${name}_REAL_NAME} ${ARGN}) + else() + message(SEND_ERROR "Cannot find Swig library \"${name}\".") + endif() +endmacro() diff --git a/cmake/anaconda.cmake b/cmake/anaconda.cmake new file mode 100644 index 000000000..4c2693122 --- /dev/null +++ b/cmake/anaconda.cmake @@ -0,0 +1,73 @@ + set (PYTHONLIBS_FOUND YES CACHE BOOL "MINGW/MSYS2" FORCE ) + set (PYTHON_LIBRARY $ENV{PREFIX}/lib/libpython$ENV{PY_VER}m.$ENV{SHLIB_EXT} CACHE FILEPATH "MINGW/MSYS2" FORCE ) + set (PYTHON_LIBRARIES ${PYTHON_LIBRARY} CACHE FILEPATH "MINGW/MSYS2" FORCE ) + set (PYTHON_INCLUDE_PATH $ENV{PREFIX}/include/python$ENV{PY_VER}m CACHE PATH "MINGW/MSYS2" FORCE ) + set (PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_PATH} CACHE PATH "MINGW/MSYS2" FORCE ) + set (PYTHON_EXECUTABLE $ENV{PREFIX}/bin/python CACHE FILEPATH "MINGW/MSYS2" FORCE ) + set (PYTHONLIBS_VERSION_STRING $ENV{PY_VER} CACHE STRING "MINGW/MSYS2" FORCE ) + + + # # try to extract R from readline to avoid collision + set(READLINE_INCLUDE_DIR $ENV{PREFIX}/include CACHE PATH "readline" FORCE) + + + # Apple readline does not support readline hooks + # So we look for another one by default + set(READLINE_readline_LIBRARY $ENV{PREFIX}/lib/libreadline.$ENV{SHLIB_EXT} CACHE PATH "readline") + + # Sometimes readline really needs ncurses + set(READLINE_ncurses_LIBRARY $ENV{PREFIX}/lib/libncurses.$ENV{SHLIB_EXT} CACHE PATH "readline") + + set(READLINE_ncursesw_LIBRARY $ENV{PREFIX}/lib/libncursesw.$ENV{SHLIB_EXT} CACHE PATH "readline") + + # Sometimes ncurses really needs terminfo + set(READLINE_tinfo_LIBRARY $ENV{PREFIX}/lib/libntinfo.$ENV{SHLIB_EXT} CACHE PATH "readline") + + set(READLINE_tinfow_LIBRARY $ENV{PREFIX}/lib/libntinfow.$ENV{SHLIB_EXT} CACHE PATH "readline") + + SET( READLINE_FOUND "YES" CACHE BOOL "Readline ACCESS.") + + + # Apple readline does not support readline hooks + # So we look for another one by default + if ( READLINE_readline_LIBRARY) + set (HAVE_LIBREADLINE YES CACHE BOOL "ibReadline ACCESS") + endif() + + IF(READLINE_readline_LIBRARY) + set(HAVE_LIBREADLINE CACHE YES BOOL "Readline works." ) + SET( READLINE_LIBRARIES + ${READLINE_readline_LIBRARY} + ) + + # some readline libraries depend on ncurses + IF(READLINE_ncurses_LIBRARY) + list(APPEND READLINE_LIBRARIES ${READLINE_ncurses_LIBRARY}) + endif () + + # some readline libraries depend on ncurses + IF(READLINE_ncursesw_LIBRARY) + list(APPEND READLINE_LIBRARIES ${READLINE_ncursesw_LIBRARY}) + endif () + + # some readline libraries depend on tinfo + IF(READLINE_tinfo_LIBRARY) + list(APPEND READLINE_LIBRARIES ${READLINE_tinfo_LIBRARY}) + endif () + + + # some readline libraries depend on tinfo + IF(READLINE_tinfow_LIBRARY) + list(APPEND READLINE_LIBRARIES ${READLINE_tinfow_LIBRARY}) + endif () + + IF(READLINE_INCLUDE_DIR) + SET( READLINE_FOUND "YES" CACHE BOOL "Readline ACCESS.") + ENDIF(READLINE_INCLUDE_DIR) + ENDIF(READLINE_readline_LIBRARY) + + + set (GMP_INCLUDE_DIRS $ENV{PREFIX}/include) + set (GMP_LIBRARIES $ENV{PREFIX}/lib/libgmp.${SHLIB_EXT}) + set (GMP_FOUND ON) + set (GMP_LIBRARIES_DIR $ENV{PREFIX}/lib) \ No newline at end of file diff --git a/cmake/cudd.cmake b/cmake/cudd.cmake index 5e0768b26..314ba353a 100644 --- a/cmake/cudd.cmake +++ b/cmake/cudd.cmake @@ -10,17 +10,12 @@ find_package(CUDD) # CUDD_LIBRARIES - Link these to use CUDD # CUDD_INCLUDE_DIR - Include directory for using CUDD # -macro_log_feature (CUDD_FOUND "CUDD" - "Use CUDD BDD library" - "http://vlsi.colorado.edu/~fabio/CUDD/" FALSE) if (CUDD_FOUND) set( CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${CUDD_INCLUDE_DIR} ) -check_include_files( "stdio.h;cudd.h" HAVE_CTYPE_HUDD_H ) - -check_include_files( "stdio.h;cuddI.h" HAVE_CUDD_H ) -check_include_files( "cudd.h;cuddInt.h" HAVE_CUDDINT_H ) +check_include_files( "stdio.h;cudd.h" HAVE_CUDD_H ) +check_include_files( "stdio.h;cuddInt.h" HAVE_CUDDINT_H ) check_include_files( "stdio.h;cudd/cudd.h" HAVE_CUDD_CUDD_H ) check_include_files( "stdio.h;cudd/cuddInt.h" HAVE_CUDD_CUDDINT_H ) configure_file (cmake/cudd_config.h.cmake diff --git a/cmake/java.cmake b/cmake/java.cmake index ffc7fa902..e69de29bb 100644 --- a/cmake/java.cmake +++ b/cmake/java.cmake @@ -1,57 +0,0 @@ - -option(WITH_JAVA "Try to use Java (currently Java 6,7,8)" ON) - -if (WITH_JAVA) -#detect java setup, as it is shared between different installations. - -find_package(Java 1.5 COMPONENTS Runtime Development) -# find_package(Java COMPONENTS Development) -# find_package(Java COMPONENTS Runtime) -#find_package(JavaLibs) -macro_log_feature (Java_Development_FOUND "Java" - "Use Java System" - "http://www.java.org" FALSE) - -if (Java_Development_FOUND) - - find_package(JNI) - - if (JNI_FOUND) - - include(UseJava) - - # - # Java_JAVA_EXECUTABLE = the full path to the Java runtime - # Java_JAVAC_EXECUTABLE = the full path to the Java compiler - # Java_JAVAH_EXECUTABLE = the full path to the Java header generator - # Java_JAVADOC_EXECUTABLE = the full path to the Java documention generator - # Java_IDLJ_EXECUTABLE = the full path to the Java idl compiler - # Java_JAR_EXECUTABLE = the full path to the Java archiver - # Java_JARSIGNER_EXECUTABLE = the full path to the Java jar signer - # Java_VERSION_STRING = Version of java found, eg. 1.6.0_12 - # Java_VERSION_MAJOR = The major version of the package found. - # Java_VERSION_MINOR = The minor version of the package found. - # Java_VERSION_PATCH = The patch version of the package found. - # Java_VERSION_TWEAK = The tweak version of the package found (after '_') - # Java_VERSION = This is set to: $major.$minor.$patch(.$tweak) - # - # The Java_ADDITIONAL_VERSIONS variable can be used to specify a list - # of version numbers that should be taken into account when searching - # for Java. You need to set this variable before calling - # find_package(JavaLibs). - # - #macro_optional_find_package(JNI ON) - # JNI_INCLUDE_DIRS = the include dirs to use - # JNI_LIBRARIES = the libraries to use - # JNI_FOUND = TRUE if JNI headers and libraries were found. - # JAVA_AWT_LIBRARY = the path to the jawt library - # JAVA_JVM_LIBRARY = the path to the jvm library - # JAVA_INCLUDE_PATH = the include path to jni.h - # JAVA_INCLUDE_PATH2 = the include path to jni_md.h - # JAVA_AWT_INCLUDE_PATH = the include path to jawt.h -endif (JNI_FOUND) - - -endif (Java_Development_FOUND) -endif(WITH_JAVA) - diff --git a/cmake/os/YapIOConfig.h b/cmake/os/YapIOConfig.h new file mode 100644 index 000000000..6345636f0 --- /dev/null +++ b/cmake/os/YapIOConfig.h @@ -0,0 +1,112 @@ +/* Define if you have libreadline */ +#ifndef HAVE_LIBREADLINE +/* #undef HAVE_LIBREADLINE */ +#endif + +/* Define to 1 if you have the header file. */ +#ifndef HAVE_READLINE_HISTORY_H +/* #undef HAVE_READLINE_HISTORY_H */ +#endif + +/* Define to 1 if you have the header file. */ +#ifndef HAVE_READLINE_READLINE_H +/* #undef HAVE_READLINE_READLINE_H */ +#endif + +#if defined(HAVE_LIBREADLINE) && defined(HAVE_READLINE_READLINE_H) +#define USE_READLINE 1 +#endif + +/* Define to 1 if you have the declaration of `rl_catch_signals ', and to 0 if +you don't. */ +#ifndef HAVE_DECL_RL_CATCH_SIGNALS_ +/* #undef HAVE_DECL_RL_CATCH_SIGNALS */ +#endif + +/* Define to 1 if you have the declaration of `rl_done ', and to 0 if you +don't. */ +#ifndef HAVE_DECL_RL_DONE_ +/* #undef HAVE_DECL_RL_DONE_ */ +#endif + +/* Define to 1 if you have the declaration of `rl_event_hook', and to 0 if you +don't. */ +#ifndef HAVE_DECL_RL_EVENT_HOOK +/* #undef HAVE_DECL_RL_EVENT_HOOK */ +#endif + +/* Define to 1 if you have the declaration of `rl_readline_state', and to 0 if +you don't. */ +#ifndef HAVE_DECL_RL_READLINE_STATE +/* #undef HAVE_DECL_RL_READLINE_STATE */ +#endif + +/* Define to 1 if you have the `rl_begin_undo_group' function. */ +#ifndef HAVE_RL_BEGIN_UNDO_GROUP +/* #undef HAVE_RL_BEGIN_UNDO_GROUP */ +#endif + +/* Define to 1 if you have the `rl_clear_pending_input' function. */ +#ifndef HAVE_RL_CLEAR_PENDING_INPUT +/* #undef HAVE_RL_CLEAR_PENDING_INPUT */ +#endif + +/* Define to 1 if the system has the type `rl_completion_func_t'). */ +#ifndef HAVE_RL_COMPLETION_FUNC_T +/* #undef HAVE_RL_COMPLETION_FUNC_T */ +#endif + +/* Define to 1 if the system has the type `rl_completion_func_t'. */ +#ifndef HAVE_RL_COMPLETION_FUNC_T +/* #undef HAVE_RL_COMPLETION_FUNC_T */ +#endif + +/* Define to 1 if you have the `rl_completion_matches' function. */ +#ifndef HAVE_RL_COMPLETION_MATCHES +/* #undef HAVE_RL_COMPLETION_MATCHES */ +#endif + +/* Define to 1 if you have the `rl_discard_argument' function. */ +#ifndef HAVE_RL_DISCARD_ARGUMENT +/* #undef HAVE_RL_DISCARD_ARGUMENT */ +#endif + +/* Define to 1 if you have the `rl_done' variable. */ +#ifndef HAVE_RL_DONE +#define HAVE_RL_DONE +#endif + +/* Define to 1 if you have the `rl_filename_completion_function' function. */ +#ifndef HAVE_RL_FILENAME_COMPLETION_FUNCTION +#define HAVE_RL_FILENAME_COMPLETION_FUNCTION +#endif + +/* Define to 1 if you have the `rl_free_line_state' function. */ +#ifndef HAVE_RL_FREE_LINE_STATE +/* #undef HAVE_RL_FREE_LINE_STATE */ +#endif + +/* Define to 1 if the system has the type `rl_hook_func_t'. */ +#ifndef HAVE_RL_HOOK_FUNC_T +/* #undef HAVE_RL_HOOK_FUNC_T */ +#endif + +/* Define to 1 if you have the `rl_insert_close' function. */ +#ifndef HAVE_RL_INSERT_CLOSE +/* #undef HAVE_RL_INSERT_CLOSE */ +#endif + +/* Define to 1 if you have the `rl_reset_after_signal' function. */ +#ifndef HAVE_RL_RESET_AFTER_SIGNAL +/* #undef HAVE_RL_RESET_AFTER_SIGNAL */ +#endif + +/* Define to 1 if you have the `rl_set_keyboard_input_timeout' function. */ +#ifndef HAVE_RL_SET_KEYBOARD_INPUT_TIMEOUT +/* #undef HAVE_RL_SET_KEYBOARD_INPUT_TIMEOUT */ +#endif + +/* Define to 1 if you have the `rl_set_prompt' function. */ +#ifndef HAVE_RL_SET_PROMPT +/* #undef HAVE_RL_SET_PROMPT */ +#endif diff --git a/cmake/python.cmake b/cmake/python.cmake index fa88ccce7..0aa6a0a25 100644 --- a/cmake/python.cmake +++ b/cmake/python.cmake @@ -1,77 +1,52 @@ - -option (WITH_PYTHON -"Allow Python->YAP and YAP->Python" ON) +set (Python_ADDITIONAL_VERSIONS 3.7 3.6 ) #3.5 3.6 3.4 ) -# PYTHONLIBS_FOUND - have the Python libs been found +# PYTHONLIBS_FOUND - have the Python libs been found # PYTHON_LIBRARIES - path to the python library # PYTHON_INCLUDE_PATH - path to where Python.h is found (deprecated) # PYTHON_INCLUDE_DIRS - path to where Python.h is found # PYTHON_DEBUG_LIBRARIES - path to the debug library (deprecated) # PYTHONLIBS_VERSION_STRING - version of the Python libs found (since CMake 2.8.8) +## # -# -IF (WITH_PYTHON) - set (Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.6 3.4 3.3) + # ensure the script is in your cmake module path +if (WIN32) + set (PYTHONLIBS_FOUND YES CACHE BOOL "MINGW/MSYS2" FORCE ) + set (PYTHON_LIBRARY C:/msys64/mingw64/lib/libpython3.6m.dll.a CACHE FILEPATH "MINGW/MSYS2" FORCE ) + set (PYTHON_LIBRARIES C:/msys64/mingw64/lib/libpython3.5m.dll.a CACHE FILEPATH "MINGW/MSYS2" FORCE ) + set (PYTHON_INCLUDE_PATH C:/msys64/mingw64/include/python3.5m CACHE PATH "MINGW/MSYS2" FORCE ) + set (PYTHON_INCLUDE_DIRS C:/msys64/mingw64/include/python3.5m CACHE PATH "MINGW/MSYS2" FORCE ) + set (PYTHON_EXECUTABLE C:/msys64/mingw64/bin/python3.exe CACHE FILEPATH "MINGW/MSYS2" FORCE ) + set (PYTHONLIBS_VERSION_STRING 3.5 CACHE STRING "MINGW/MSYS2" FORCE ) + +elseif ($ENV{CONDA_BUILD}x STREQUAL "1x") + + + set (PYTHONLIBS_FOUND YES CACHE BOOL "MINGW/MSYS2" FORCE ) +set( PYTHON_EXECUTABLE $ENV{PYTHON} CACHE FILEPATH "MINGW/MSYS2" FORCE ) +set( PYTHON_LIBRARIES $ENV{PYTHON_LIBRARIES} CACHE FILEPATH "MINGW/MSYS2" FORCE ) +set( PYTHON_INCLUDE_PATH $ENV{PYTHON_INCLUDE_DIRS} CACHE PATH "MINGW/MSYS2" FORCE ) +set( PYTHON_INCLUDE_DIRS $ENV{PYTHON_INCLUDE_DIRS} CACHE PATH "MINGW/MSYS2" FORCE ) + set (PYTHONLIBS_VERSION_STRING $ENV{PY_VER} CACHE STRING "MINGW/MSYS2" FORCE ) + list (APPEND CMAKE_REQUIRED_INCLUDES + ${PYTHON_INCLUDE_PATH}) +else() find_package(PythonInterp) - # find_package(PythonLibs) - - execute_process ( COMMAND ${PYTHON_EXECUTABLE} -c "import sysconfig; print( sysconfig.get_path( 'include' ) )" -OUTPUT_VARIABLE _ABS_PYTHON_INCLUDE_PATH -OUTPUT_STRIP_TRAILING_WHITESPACE ) -get_filename_component ( ABS_PYTHON_INCLUDE_PATH ${_ABS_PYTHON_INCLUDE_PATH} ABSOLUTE ) - - set ( PYTHON_INCLUDE_DIR - ${ABS_PYTHON_INCLUDE_PATH} - CACHE "PATH" "Directory with Python.h " - ) - - set ( PYTHON_INCLUDE_DIRS - ${ABS_PYTHON_INCLUDE_PATH} - CACHE "PATH" "Python.h Dir (Deprecated)" - ) - - execute_process ( COMMAND ${PYTHON_EXECUTABLE} -c "import sysconfig; print( sysconfig.get_path( 'stdlib' ) )" - OUTPUT_VARIABLE _ABS_PYTHON_SYSLIB_PATH - OUTPUT_STRIP_TRAILING_WHITESPACE ) - -get_filename_component ( _ABS_PYTHON_SYSLIB_PATH ${_ABS_PYTHON_SYSLIB_PATH} ABSOLUTE ) -get_filename_component ( _ABS_PYTHON_SYSLIB_PATH ${_ABS_PYTHON_SYSLIB_PATH} DIRECTORY ) - - - find_library( ABS_PYTHON_SYSLIB_PATH - NAMES python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}m - PATHS ${_ABS_PYTHON_SYSLIB_PATH} ${libdir} - ) - - set ( PYTHON_LIBRARY - ${ABS_PYTHON_SYSLIB_PATH} - CACHE "FILEPATH" "Python Library" - ) - set ( PYTHON_LIBRARIES - ${PYTHON_LIBRARY} - CACHE "FILEPATH" "Python Library (Deprecated)" - ) - if ( (EXISTS ${PYTHON_LIBRARY}) AND ( EXISTS ${PYTHON_INCLUDE_DIR}) ) - set ( PYTHONLIBS_FOUND ON ) -# else() - -#find_package(PythonLibs) + find_package(PythonLibs) + execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sysconfig; sysconfig.get_paths()['include']" + OUTPUT_VARIABLE PYTHON_INCLUDE_PATH + OUTPUT_STRIP_TRAILING_WHITESPACE) + list (APPEND CMAKE_REQUIRED_INCLUDES + ${PYTHON_INCLUDE_PATH}) endif() - macro_log_feature (PYTHONLIBS_FOUND "Python" - "Use Python System" - "http://www.python.org" FALSE ) +IF (PYTHONLIBS_FOUND) + add_subDIRECTORY (packages/python) +ENDIF() - include_directories( BEFORE ${PYTHON_INCLUDE_DIR} ) - - LIST( APPEND - CMAKE_REQUIRED_INCLUDES ${PYTHON_INCLUDE_DIR} ${CMAKE_REQUIRED_INCLUDES}) - - check_include_file(Python.h HAVE_PYTHON_H) - - -endif(WITH_PYTHON) +IF (CMAKE_INSTALL_PREFIX MATCHES $ENV{HOME}.* ) + set (PYTHON_USER_INSTALL --user) + ENDIF() \ No newline at end of file diff --git a/cmake/readline.cmake b/cmake/readline.cmake new file mode 100644 index 000000000..b1beb0e2f --- /dev/null +++ b/cmake/readline.cmake @@ -0,0 +1,58 @@ +## after we have all functionality in +# +# ADD_SUBDIRECTORY(console/terminal) + +option (WITH_READLINE "GNU readline console" ON) + + +if (WITH_READLINE) + find_library(READLINE_tinfo_LIBRARY + NAMES tinfo + message(STATUS "tinfo DLL found at ${READLINE_tinfo_LIBRARY}") + HINTS ${READLINE_ROOT_DIR}/lib + ) + find_library(READLINE_tinfow_LIBRARY + NAMES tinfow + HINTS ${READLINE_ROOT_DIR}/lib + ) + find_library(READLINE_ncurses_LIBRARY +essage(STATUS "tinfo DLL found at ${READLINE_tinfo_LIBRARY}") + HINTS ${READLINE_ROOT_DIR}/lib + ) + find_library(READLINE_tinfow_LIBRARY + NAMES tinfow + HINTS ${READLINE_ROOT_DIR}/lib + ) + find_library(READLINE_ncurses_LIBRARY + NAMES ncurses + HINTS ${READLINE_ROOT_DIR}/lib + message(STATUS "readline ncurses DLL found at ${READLINE_ncurses_LIBRARY}") + ) + find_library(READLINE_ncursesw_LIBRARY + NAMES ncursesw + message(STATUS "readline ncursesw DLL found at ${READLINE_ncursesw_LIBRARY}") + HINTS ${READLINE_ROOT_DIR}/lib + ) + + find_path(READLINE_INCLUDE_DIR + NAMES readline/readline.h + HINTS ${READLINE_ROOT_DIR}/include + ) + find_library(READLINE_readline_LIBRARY + NAMES readline + HINTS ${READLINE_INCLUDE_DIR/../lib} ${READLINE_ROOT_DIR}/lib + if (READLINE_readline_LIBRARY) + set (HAVE_LIBREADLINE TRUE) + if (READLINE_INCLUDE_DIR) + set(READLINE_FOUND TRUE CACHE BOOL "readline is installed correctly") + set (READLINE_LIBRARIES ${READLINE_ncursesw_LIBRARY} ${READLINE_tinfow_LIBRARY}$ ${READLINE_tinfo_LIBRARY}$ ${READLINE_ncurses_LIBRARY} ${READLINE_readline_LIBRARY} ) + endif() + message(STATUS "headers found so far at ${READLINE_INCLUDE_DIR}") + message(STATUS "libraries found so far at ${READLINE_readline_LIBRARY} ${READLINE_ncurses_LIBRARY} ${READLINE_tinfo_LIBRARY} ${READLINE_tinfow_LIBRARY} ${READLINE_ncursesw_LIBRARY} ") + else + endif () + set(YAP_SYSTEM_OPTIONS "readline" ${YAP_SYSTEM_OPTIONS} ) + + + set(EXTRALIBS ${EXTRALIBS} readline) +endif () diff --git a/config.h.cmake b/config.h.cmake index 1f70296c0..c72a3dc99 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -1,4 +1,5 @@ + /*-------------------------------------------------------------------------- * This file is autogenerated from config.h.in * during the cmake configuration of your project. If you need to make changes @@ -381,9 +382,14 @@ function. */ #cmakedefine HAVE_FFSL ${HAVE_FFSL} #endif -/* Define to 1 if you have the `ffsll' function. */ -#ifndef HAVE_FFSLL -#cmakedefine HAVE_FFSLL ${HAVE_FFSLL} +/* Define to 1 if you have the `ftell' function. */ + #ifndef HAVE_FTELL + #cmakedefine HAVE_FTELL ${HAVE_FTELL} + #endif + +/* Define to 1 if you have the `ftello' function. */ +#ifndef HAVE_FTELLO +#cmakedefine HAVE_FTELLO ${HAVE_FTELLO} #endif /* Define to 1 if you have the `fgetpos' function. */ @@ -415,12 +421,20 @@ function. */ #ifndef HAVE_FMEMOPEN #cmakedefine HAVE_FMEMOPEN ${HAVE_FMEMOPEN} #endif +#if CONDA_BUILD +#undef HAVE_FMEMOPEN +#endif /* Define to 1 if you have the `fpclass' function. */ #ifndef HAVE_FPCLASS #cmakedefine HAVE_FPCLASS ${HAVE_FPCLASS} #endif +/* Define to 1 if you have the `fpurge' function. */ +#ifndef HAVE_FPURGE +#cmakedefine HAVE_FPURGE ${HAVE_FPURGE} +#endif + /* Define to 1 if you have the header file. */ #ifndef HAVE_FPU_CONTROL_H #cmakedefine HAVE_FPU_CONTROL_H ${HAVE_FPU_CONTROL_H} @@ -883,7 +897,7 @@ function. */ #cmakedefine HAVE_MBSNRTOWCS ${HAVE_MBSNRTOWCS} #endif -/* Define to 1 if you have the `memcpy' function. */ +/* Define to 1 if you have the `memmove' function. */ #ifndef HAVE_MEMCPY #cmakedefine HAVE_MEMCPY ${HAVE_MEMCPY} #endif @@ -972,6 +986,10 @@ function. */ #ifndef HAVE_OPEN_MEMSTREAM #cmakedefine HAVE_OPEN_MEMSTREAM ${HAVE_OPEN_MEMSTREAM} #endif +#if CONDA_BUILD +#undef HAVE_OPEN_MEMSTREAM +#endif + /* Define to 1 if you have the `opendir' function. */ #ifndef HAVE_OPENDIR @@ -1355,6 +1373,11 @@ signal. */ #cmakedefine HAVE_STRNLEN ${HAVE_STRNLEN} #endif +/* Define to 1 if you have the `stpcpy' function. */ +#ifndef HAVE_STPCPY +#cmakedefine HAVE_STPCPY ${HAVE_STPCPY} +#endif + /* Define to 1 if you have the header file. */ #ifndef HAVE_STROPTS_H #cmakedefine HAVE_STROPTS_H ${HAVE_STROPTS_H} @@ -1927,16 +1950,12 @@ significant byte first (like Motorola and SPARC, unlike Intel). */ #define YAP_PL_SRCDIR "${PROJECT_SOURCE_DIR}/pl" #endif -#ifndef YAP_SHAREDIR -#define YAP_SHAREDIR "${YAP_SHAREDIR}" + +/* YAP_IS_MOVABLE */ +#ifndef YAP_IS_MOVABLE +#cmakedefine YAP_IS_MOVABLE "${YAP_IS_MOVABLE}" #endif -/* saved state file */ -#ifndef YAP_STARTUP -#define YAP_STARTUP "${YAP_STARTUP}" -#endif - -/* date of compilation */ #ifndef YAP_TIMESTAMP #define YAP_TIMESTAMP ${YAP_TIMESTAMP} #endif @@ -1956,31 +1975,75 @@ significant byte first (like Motorola and SPARC, unlike Intel). */ #define YAP_COMPILED_AT "${YAP_TIMESTAMP}@${YAP_SITE}" #endif -/* name of YAP library */ -#ifndef YAP_YAPLIB -#define YAP_YAPLIB "${YAP_YAPLIB}" -#endif -/* name of YAP library */ -#ifndef YAP_BINDIR -#define YAP_BINDIR "${bindir}" -#endif -/* name of YAP library */ +/* name of YAP instaii */ #ifndef YAP_ROOTDIR #define YAP_ROOTDIR "${YAP_ROOTDIR}" #endif +/* name of YAP binaries */ +#ifndef YAP_BINDIR +#define YAP_BINDIR "${YAP_BINDIR}" +#endif + +/* name of YAP headers */ +#ifndef YAP_INCLUDEDIR +#define YAP_INCLUDEDIR "${YAP_INCLUDEDIR}" +#endif + /* name of YAP library */ #ifndef YAP_LIBDIR #define YAP_LIBDIR "${YAP_LIBDIR}" #endif +/* name of YAP DLL library */ +#ifndef YAP_DLLDIR +#define YAP_DLLDIR "${YAP_LIBDIR}/Yap" +#endif + +/* run-time boot */ +#ifndef YAP_INPUT_STARTUP +#define YAP_INPUT_STARTUP "${YAP_DLLDIR}/${YAP_STARTUP}" +#endif + +/* init-time boot */ +#ifndef YAP_OUTPUT_STARTUP +#define YAP_OUTPUT_STARTUP "${CMAKE_BINARY_DIR}/${YAP_STARTUP}" +#endif + /* name of YAP JIT library */ #ifndef YAP_YAPJITLIB #define YAP_YAPJITLIB "${YAP_YAPJITLIB}" #endif +#ifndef YAP_SHAREDIR +#define YAP_SHAREDIR "${YAP_DATADIR}" +#endif + +/* name of YAP PL library */ +#ifndef YAP_PLDIR +#define YAP_PLDIR "${YAP_PLDIR}" +#endif + +/* name of Commons library */ +#ifndef YAP_COMMONSDIR +#define YAP COMMONSDIR "${YAP_DATADIR}/PrologCommmons" +#endif + + +/* run-time boot */ +#ifndef YAP_BOOTFILE +#define YAP_BOOTFILE "${YAP_PLDIR}/pl/boot.yap" +#endif + +/* init-time boot */ +#ifndef YAP_BOOTSTRAP +#define YAP_BOOTSTRAP "${CMAKE_SOURCE_DIR}/pl/boot.yap" +#endif + + + /* HP-UX old socket stuff */ #ifndef _XOPEN_SOURCE #cmakedefine _XOPEN_SOURCE "${_XOPEN_SOURCE}" @@ -2049,27 +2112,9 @@ calls it, or to nothing if 'inline' is not supported under any name. */ #ifdef _WIN32 #ifndef __WINDOWS__ #define __WINDOWS__ 1 -#endif +#endif #endif - -/** - * X_API macro - * - * @brief Linux exports all symbols by default, but WIN32 does - * not. cmake can enable exports, using CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS - * - * @param _WIN32 - * - * @return - */ -#if _WIN32 && !defined(YAP_KERNEL) -#define X_API __declspec(dllimport) -#else -#define X_API -#endif -#define O_API - +#include "YapTermConfig.h" #endif - diff --git a/configure b/configure index 992642938..64511cd43 100755 --- a/configure +++ b/configure @@ -165,7 +165,7 @@ print_help() { --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/PROJECT_NAME] - --generato=Generator Specify the tool used to send callss + --generator=GENERATOR Specify the tool used to send callss EOF first=y @@ -220,6 +220,8 @@ EOF exit 0 } + + while [ $# != 0 ]; do case "$1" in "--cmake="*) @@ -292,11 +294,9 @@ while [ $# != 0 ]; do CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_DOCDIR=$(quote "$2")"; shift;; "--generator="*) - GENERATOR="$CMAKE_ARGS -G $(1#*=)";; - - "-G"|"--generator") - GENERATOR="$CMAKE_ARGS -G$(quote "$2")"; - shift;; + CMAKE_ARGS="$CMAKE_ARGS -G ${1#*=}";; + "-G") + CMAKE_ARGS="$CMAKE_ARGS -G $2"; shift;; "CC="*) CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_C_COMPILER=$(quote "${1#*=}")";; diff --git a/console/LGPL/pl-ntmain.c b/console/LGPL/pl-ntmain.c index fed5daa3a..291e3737e 100755 --- a/console/LGPL/pl-ntmain.c +++ b/console/LGPL/pl-ntmain.c @@ -356,7 +356,7 @@ Srlc_write(void *handle, char *buffer, size_t size) { char buf[sizeof(TCHAR)]; /* Pad to TCHAR */ size_t i = sizeof(TCHAR) - (size-n); - memcpy(buf, buffer+n, i); + memmove(buf, buffer+n, i); for(; i ** Copyright (C) 2012 Laszlo Papp @@ -37,29 +37,27 @@ l/**************************************************************************** #include -class Console : public QPlainTextEdit -{ - Q_OBJECT +class Console : public QPlainTextEdit { + Q_OBJECT signals: - void getData(const QString &data); + void getData(const QString &data); public: - explicit Console(QWidget *parent = 0); + explicit Console(QWidget *parent = 0); - void putData(const QString &data); + void putData(const QString &data); - void setLocalEchoEnabled(bool set); + void setLocalEchoEnabled(bool set); protected: - virtual void keyPressEvent(QKeyEvent *e); - virtual void mousePressEvent(QMouseEvent *e); - virtual void mouseDoubleClickEvent(QMouseEvent *e); - virtual void contextMenuEvent(QContextMenuEvent *e); + virtual void keyPressEvent(QKeyEvent *e); + virtual void mousePressEvent(QMouseEvent *e); + virtual void mouseDoubleClickEvent(QMouseEvent *e); + virtual void contextMenuEvent(QContextMenuEvent *e); private: - bool localEchoEnabled; - + bool localEchoEnabled; }; #endif // CONSOLE_H diff --git a/console/terminal/streamer.cpp b/console/terminal/streamer.cpp new file mode 100644 index 000000000..e77efe73e --- /dev/null +++ b/console/terminal/streamer.cpp @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Denis Shienkov +** Copyright (C) 2012 Laszlo Papp +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtSerialPort module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "mainwindow.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + return a.exec(); +} diff --git a/console/yap.c b/console/yap.c index a07ed8571..0e2b58e0a 100755 --- a/console/yap.c +++ b/console/yap.c @@ -58,8 +58,8 @@ #include #endif -static void do_top_goal(YAP_Term Goal); -static void exec_top_level(int BootMode, YAP_init_args *iap); +static bool do_top_goal(YAP_Term Goal); +static bool exec_top_level(int BootMode, YAP_init_args *iap); #ifdef lint /* VARARGS1 */ @@ -69,7 +69,7 @@ static void exec_top_level(int BootMode, YAP_init_args *iap); long _stksize = 32000; #endif -static void do_top_goal(YAP_Term Goal) { YAP_RunGoalOnce(Goal); } +static bool do_top_goal(YAP_Term Goal) { return YAP_RunGoalOnce(Goal); } static int init_standard_system(int argc, char *argv[], YAP_init_args *iap) { @@ -78,7 +78,8 @@ static int init_standard_system(int argc, char *argv[], YAP_init_args *iap) { BootMode = YAP_parse_yap_arguments(argc, argv, iap); iap->Embedded = false; /* init memory */ - iap->boot_file_type = BootMode = YAP_Init(iap); + iap->boot_file_type = BootMode; + YAP_Init(iap); if (iap->ErrorNo) { /* boot failed */ YAP_Error(iap->ErrorNo, 0L, iap->ErrorCause); @@ -86,32 +87,39 @@ static int init_standard_system(int argc, char *argv[], YAP_init_args *iap) { return BootMode; } -static void exec_top_level(int BootMode, YAP_init_args *iap) { +static bool exec_top_level(int BootMode, YAP_init_args *iap) { YAP_Term atomfalse; YAP_Atom livegoal; + if (iap->install) + return true; if (BootMode == YAP_BOOT_FROM_SAVED_STACKS) { /* continue executing from the frozen stacks */ YAP_ContinueGoal(); } - livegoal = YAP_FullLookupAtom("$live"); + livegoal = YAP_FullLookupAtom("live"); /* the top-level is now ready */ /* read it before case someone, that is, Ashwin, hides the atom false away ;-). */ - atomfalse = YAP_MkAtomTerm(YAP_FullLookupAtom("$false")); + atomfalse = YAP_MkAtomTerm(YAP_FullLookupAtom("false")); while (YAP_GetValue(livegoal) != atomfalse) { - YAP_Reset(YAP_FULL_RESET); - do_top_goal(YAP_MkAtomTerm(livegoal)); - livegoal = YAP_FullLookupAtom("$live"); + YAP_Reset(YAP_FULL_RESET, false); + if (!do_top_goal(YAP_MkAtomTerm(livegoal))) { + return false; + }; + livegoal = YAP_FullLookupAtom("live"); + } + return true; + //YAP_Exit(EXIT_SUCCESS); + } - YAP_Exit(EXIT_SUCCESS); -} // FILE *debugf; #ifdef LIGHT + int _main(int argc, char **argv) #else int main(int argc, char **argv) @@ -121,6 +129,7 @@ int main(int argc, char **argv) int i; YAP_init_args init_args; BootMode = init_standard_system(argc, argv, &init_args); + if (BootMode == YAP_BOOT_ERROR) { fprintf(stderr, "[ FATAL ERROR: could not find saved state ]\n"); exit(1); @@ -138,10 +147,11 @@ int main(int argc, char **argv) } } - YAP_Reset(YAP_FULL_RESET); + YAP_Reset(YAP_FULL_RESET, false); /* End preprocessor code */ - exec_top_level(BootMode, &init_args); - - return (0); + bool rc = exec_top_level(BootMode, &init_args); + if (!rc) + return 1; + return 0; } diff --git a/cudd_config.h b/cudd_config.h new file mode 100644 index 000000000..fbee45213 --- /dev/null +++ b/cudd_config.h @@ -0,0 +1,43 @@ +// cmake template file + +/* Define to 1 if you have the header file. */ +#ifndef HAVE_CUDD_H +/* #undef HAVE_CUDD_H */ +#endif + +/* Define to 1 if you have the header file. */ +#ifndef HAVE_CUDD_CUDD_H +#define HAVE_CUDD_CUDD_H 1 +#endif + +/* Define to 1 if you have the header file. */ +#ifndef HAVE_CUDDINT_H +#define HAVE_CUDDINT_H 1 +#endif + +/* Define to 1 if you have the header file. */ +#ifndef HAVE_CUDD_CUDDINT_H +/* #undef HAVE_CUDD_CUDDINT_H */ +#endif + + +/* Define to 1 if you have the header file. */ +#ifndef HAVE_CUDDOBJ_HH +/* #undef HAVE_CUDDOBJ_HH */ +#endif + +/* Define to 1 if you have the header file. */ +#ifndef HAVE_CUDD_CUDDOBJ_HH +/* #undef HAVE_CUDD_CUDDOBJ_HH */ +#endif + + +/* Define to 1 if you have the header file. */ +#ifndef HAVE_DDDMPINT_H +/* #undef HAVE_DDDMPINT_H */ +#endif + +/* Define to 1 if you have the header file. */ +#ifndef HAVE_CUDD_CUDDINT_H +/* #undef HAVE_CUDD_DDDMPINT_H */ +#endif diff --git a/dlocals.h b/dlocals.h new file mode 100644 index 000000000..a99e521c1 --- /dev/null +++ b/dlocals.h @@ -0,0 +1,700 @@ +/// Thread Local Variables. This file now follows C syntax. +// Macro support +#ifndef LOCAL +#include "Yap.h" +#include "heap.h" +#define LOCAL(A, B) A B +#define LOCAL_INIT(A, B, C) A B B = C +#define LOCAL_ARRAY(A, B, C) A B[C] +#define LOCAL_ARRAY_ARRAY(A, B, C,D) A B[C][D] +#define LOCAL_INIT(A, B, C, D) A B[C][D] +#define LOCAL_INITF(A, B, C) A B C + #define LOCAL_INIT_RESTORE(A,B,C,D) A B C D +#endif +/// Current bindings for std streams, includes default s +#define LOCAL_c_input_stream (Yap_local.c_input_stream) +#define REMOTE_c_input_stream(wid) (REMOTE(wid)->c_input_stream) + +#define LOCAL_c_output_stream (Yap_local.c_output_stream) +#define REMOTE_c_output_stream(wid) (REMOTE(wid)->c_output_stream) + +#define LOCAL_c_error_stream (Yap_local.c_error_stream) +#define REMOTE_c_error_stream(wid) (REMOTE(wid)->c_error_stream) + +#define LOCAL_sockets_io (Yap_local.sockets_io) +#define REMOTE_sockets_io(wid) (REMOTE(wid)->sockets_io) + +#define LOCAL_within_print_message (Yap_local.within_print_message) +#define REMOTE_within_print_message(wid) (REMOTE(wid)->within_print_message) + +// +// Used by the prompts to check if they are after a newline, and then a +// prompt should be output, or if we are in the middle of a line. +// +#define LOCAL_newline (Yap_local.newline) +#define REMOTE_newline(wid) (REMOTE(wid)->newline) + +#define LOCAL_AtPrompt (Yap_local.AtPrompt) +#define REMOTE_AtPrompt(wid) (REMOTE(wid)->AtPrompt) + +#define LOCAL_Prompt (Yap_local.Prompt) +#define REMOTE_Prompt(wid) (REMOTE(wid)->Prompt) + +#define LOCAL_encoding (Yap_local.encoding) +#define REMOTE_encoding(wid) (REMOTE(wid)->encoding) + +#define LOCAL_quasi_quotations (Yap_local.quasi_quotations) +#define REMOTE_quasi_quotations(wid) (REMOTE(wid)->quasi_quotations) + +#define LOCAL_default_priority (Yap_local.default_priority) +#define REMOTE_default_priority(wid) (REMOTE(wid)->default_priority) + +#define LOCAL_eot_before_eof (Yap_local.eot_before_eof) +#define REMOTE_eot_before_eof(wid) (REMOTE(wid)->eot_before_eof) + +#define LOCAL_max_depth (Yap_local.max_depth) +#define REMOTE_max_depth(wid) (REMOTE(wid)->max_depth) + +#define LOCAL_max_list (Yap_local.max_list) +#define REMOTE_max_list(wid) (REMOTE(wid)->max_list) + +#define LOCAL_max_write_args (Yap_local.max_write_args) +#define REMOTE_max_write_args(wid) (REMOTE(wid)->max_write_args) + +// Restore info +#define LOCAL_OldASP (Yap_local.OldASP) +#define REMOTE_OldASP(wid) (REMOTE(wid)->OldASP) + +#define LOCAL_OldLCL0 (Yap_local.OldLCL0) +#define REMOTE_OldLCL0(wid) (REMOTE(wid)->OldLCL0) + +#define LOCAL_OldTR (Yap_local.OldTR) +#define REMOTE_OldTR(wid) (REMOTE(wid)->OldTR) + +#define LOCAL_OldGlobalBase (Yap_local.OldGlobalBase) +#define REMOTE_OldGlobalBase(wid) (REMOTE(wid)->OldGlobalBase) + +#define LOCAL_OldH (Yap_local.OldH) +#define REMOTE_OldH(wid) (REMOTE(wid)->OldH) + +#define LOCAL_OldH0 (Yap_local.OldH0) +#define REMOTE_OldH0(wid) (REMOTE(wid)->OldH0) + +#define LOCAL_OldTrailBase (Yap_local.OldTrailBase) +#define REMOTE_OldTrailBase(wid) (REMOTE(wid)->OldTrailBase) + +#define LOCAL_OldTrailTop (Yap_local.OldTrailTop) +#define REMOTE_OldTrailTop(wid) (REMOTE(wid)->OldTrailTop) + +#define LOCAL_OldHeapBase (Yap_local.OldHeapBase) +#define REMOTE_OldHeapBase(wid) (REMOTE(wid)->OldHeapBase) + +#define LOCAL_OldHeapTop (Yap_local.OldHeapTop) +#define REMOTE_OldHeapTop(wid) (REMOTE(wid)->OldHeapTop) + +#define LOCAL_ClDiff (Yap_local.ClDiff) +#define REMOTE_ClDiff(wid) (REMOTE(wid)->ClDiff) + +#define LOCAL_GDiff (Yap_local.GDiff) +#define REMOTE_GDiff(wid) (REMOTE(wid)->GDiff) + +#define LOCAL_HDiff (Yap_local.HDiff) +#define REMOTE_HDiff(wid) (REMOTE(wid)->HDiff) + +#define LOCAL_GDiff0 (Yap_local.GDiff0) +#define REMOTE_GDiff0(wid) (REMOTE(wid)->GDiff0) + +#define LOCAL_GSplit (Yap_local.GSplit) +#define REMOTE_GSplit(wid) (REMOTE(wid)->GSplit) + +#define LOCAL_LDiff (Yap_local.LDiff) +#define REMOTE_LDiff(wid) (REMOTE(wid)->LDiff) + +#define LOCAL_TrDiff (Yap_local.TrDiff) +#define REMOTE_TrDiff(wid) (REMOTE(wid)->TrDiff) + +#define LOCAL_XDiff (Yap_local.XDiff) +#define REMOTE_XDiff(wid) (REMOTE(wid)->XDiff) + +#define LOCAL_DelayDiff (Yap_local.DelayDiff) +#define REMOTE_DelayDiff(wid) (REMOTE(wid)->DelayDiff) + +#define LOCAL_BaseDiff (Yap_local.BaseDiff) +#define REMOTE_BaseDiff(wid) (REMOTE(wid)->BaseDiff) + +// Reduction counters +#define LOCAL_ReductionsCounter (Yap_local.ReductionsCounter) +#define REMOTE_ReductionsCounter(wid) (REMOTE(wid)->ReductionsCounter) + +#define LOCAL_PredEntriesCounter (Yap_local.PredEntriesCounter) +#define REMOTE_PredEntriesCounter(wid) (REMOTE(wid)->PredEntriesCounter) + +#define LOCAL_RetriesCounter (Yap_local.RetriesCounter) +#define REMOTE_RetriesCounter(wid) (REMOTE(wid)->RetriesCounter) + +#define LOCAL_ReductionsCounterOn (Yap_local.ReductionsCounterOn) +#define REMOTE_ReductionsCounterOn(wid) (REMOTE(wid)->ReductionsCounterOn) + +#define LOCAL_PredEntriesCounterOn (Yap_local.PredEntriesCounterOn) +#define REMOTE_PredEntriesCounterOn(wid) (REMOTE(wid)->PredEntriesCounterOn) + +#define LOCAL_RetriesCounterOn (Yap_local.RetriesCounterOn) +#define REMOTE_RetriesCounterOn(wid) (REMOTE(wid)->RetriesCounterOn) + +// support for consulting files +/* current consult stack */ +#define LOCAL_ConsultSp (Yap_local.ConsultSp) +#define REMOTE_ConsultSp(wid) (REMOTE(wid)->ConsultSp) + +/* current maximum number of cells in consult stack */ +#define LOCAL_ConsultCapacity (Yap_local.ConsultCapacity) +#define REMOTE_ConsultCapacity(wid) (REMOTE(wid)->ConsultCapacity) + +/* top of consult stack */ +#define LOCAL_ConsultBase (Yap_local.ConsultBase) +#define REMOTE_ConsultBase(wid) (REMOTE(wid)->ConsultBase) + +/* low-water mark for consult */ +#define LOCAL_ConsultLow (Yap_local.ConsultLow) +#define REMOTE_ConsultLow(wid) (REMOTE(wid)->ConsultLow) + +#define LOCAL_VarNames (Yap_local.VarNames) +#define REMOTE_VarNames(wid) (REMOTE(wid)->VarNames) + +#define LOCAL_SourceFileName (Yap_local.SourceFileName) +#define REMOTE_SourceFileName(wid) (REMOTE(wid)->SourceFileName) + +#define LOCAL_SourceFileLineno (Yap_local.SourceFileLineno) +#define REMOTE_SourceFileLineno(wid) (REMOTE(wid)->SourceFileLineno) + +// global variables +#define LOCAL_GlobalArena (Yap_local.GlobalArena) +#define REMOTE_GlobalArena(wid) (REMOTE(wid)->GlobalArena) + +#define LOCAL_GlobalArenaOverflows (Yap_local.GlobalArenaOverflows) +#define REMOTE_GlobalArenaOverflows(wid) (REMOTE(wid)->GlobalArenaOverflows) + +#define LOCAL_ArenaOverflows (Yap_local.ArenaOverflows) +#define REMOTE_ArenaOverflows(wid) (REMOTE(wid)->ArenaOverflows) + +#define LOCAL_DepthArenas (Yap_local.DepthArenas) +#define REMOTE_DepthArenas(wid) (REMOTE(wid)->DepthArenas) + +#define LOCAL_LastAssertedPred (Yap_local.LastAssertedPred) +#define REMOTE_LastAssertedPred(wid) (REMOTE(wid)->LastAssertedPred) + +#define LOCAL_TmpPred (Yap_local.TmpPred) +#define REMOTE_TmpPred(wid) (REMOTE(wid)->TmpPred) + +#define LOCAL_ScannerStack (Yap_local.ScannerStack) +#define REMOTE_ScannerStack(wid) (REMOTE(wid)->ScannerStack) + +#define LOCAL_ScannerExtraBlocks (Yap_local.ScannerExtraBlocks) +#define REMOTE_ScannerExtraBlocks(wid) (REMOTE(wid)->ScannerExtraBlocks) + +/// worker control information +/// stack limit after which the stack is managed by C-code. +#define LOCAL_CBorder (Yap_local.CBorder) +#define REMOTE_CBorder(wid) (REMOTE(wid)->CBorder) + +/// max number of signals (uint64_t) +#define LOCAL_MaxActiveSignals (Yap_local.MaxActiveSignals) +#define REMOTE_MaxActiveSignals(wid) (REMOTE(wid)->MaxActiveSignals) + +/// actual life signals +#define LOCAL_Signals (Yap_local.Signals) +#define REMOTE_Signals(wid) (REMOTE(wid)->Signals) + +/// indexing help data? +#define LOCAL_IPredArity (Yap_local.IPredArity) +#define REMOTE_IPredArity(wid) (REMOTE(wid)->IPredArity) + +#define LOCAL_ProfEnd (Yap_local.ProfEnd) +#define REMOTE_ProfEnd(wid) (REMOTE(wid)->ProfEnd) + +#define LOCAL_DoingUndefp (Yap_local.DoingUndefp) +#define REMOTE_DoingUndefp(wid) (REMOTE(wid)->DoingUndefp) + +#define LOCAL_StartCharCount (Yap_local.StartCharCount) +#define REMOTE_StartCharCount(wid) (REMOTE(wid)->StartCharCount) + +#define LOCAL_StartLineCount (Yap_local.StartLineCount) +#define REMOTE_StartLineCount(wid) (REMOTE(wid)->StartLineCount) + +#define LOCAL_StartLinePos (Yap_local.StartLinePos) +#define REMOTE_StartLinePos(wid) (REMOTE(wid)->StartLinePos) + +#define LOCAL_ScratchPad (Yap_local.ScratchPad) +#define REMOTE_ScratchPad(wid) (REMOTE(wid)->ScratchPad) + +#ifdef COROUTINING +#define LOCAL_WokenGoals (Yap_local.WokenGoals) +#define REMOTE_WokenGoals(wid) (REMOTE(wid)->WokenGoals) + +#define LOCAL_AttsMutableList (Yap_local.AttsMutableList) +#define REMOTE_AttsMutableList(wid) (REMOTE(wid)->AttsMutableList) + +#endif +// gc_stuff +#define LOCAL_GcGeneration (Yap_local.GcGeneration) +#define REMOTE_GcGeneration(wid) (REMOTE(wid)->GcGeneration) + +#define LOCAL_GcPhase (Yap_local.GcPhase) +#define REMOTE_GcPhase(wid) (REMOTE(wid)->GcPhase) + +#define LOCAL_GcCurrentPhase (Yap_local.GcCurrentPhase) +#define REMOTE_GcCurrentPhase(wid) (REMOTE(wid)->GcCurrentPhase) + +#define LOCAL_GcCalls (Yap_local.GcCalls) +#define REMOTE_GcCalls(wid) (REMOTE(wid)->GcCalls) + +#define LOCAL_TotGcTime (Yap_local.TotGcTime) +#define REMOTE_TotGcTime(wid) (REMOTE(wid)->TotGcTime) + +#define LOCAL_TotGcRecovered (Yap_local.TotGcRecovered) +#define REMOTE_TotGcRecovered(wid) (REMOTE(wid)->TotGcRecovered) + +#define LOCAL_LastGcTime (Yap_local.LastGcTime) +#define REMOTE_LastGcTime(wid) (REMOTE(wid)->LastGcTime) + +#define LOCAL_LastSSTime (Yap_local.LastSSTime) +#define REMOTE_LastSSTime(wid) (REMOTE(wid)->LastSSTime) + +#define LOCAL_OpenArray (Yap_local.OpenArray) +#define REMOTE_OpenArray(wid) (REMOTE(wid)->OpenArray) + +/* in a single gc */ +#define LOCAL_total_marked (Yap_local.total_marked) +#define REMOTE_total_marked(wid) (REMOTE(wid)->total_marked) + +#define LOCAL_total_oldies (Yap_local.total_oldies) +#define REMOTE_total_oldies(wid) (REMOTE(wid)->total_oldies) + +#define LOCAL_current_B (Yap_local.current_B) +#define REMOTE_current_B(wid) (REMOTE(wid)->current_B) + +#define LOCAL_prev_HB (Yap_local.prev_HB) +#define REMOTE_prev_HB(wid) (REMOTE(wid)->prev_HB) + +#define LOCAL_HGEN (Yap_local.HGEN) +#define REMOTE_HGEN(wid) (REMOTE(wid)->HGEN) + +#define LOCAL_iptop (Yap_local.iptop) +#define REMOTE_iptop(wid) (REMOTE(wid)->iptop) + +#if defined(GC_NO_TAGS) +#define LOCAL_bp (Yap_local.bp) +#define REMOTE_bp(wid) (REMOTE(wid)->bp) + +#endif +#define LOCAL_sTR (Yap_local.sTR) +#define REMOTE_sTR(wid) (REMOTE(wid)->sTR) + +#define LOCAL_sTR0 (Yap_local.sTR0) +#define REMOTE_sTR0(wid) (REMOTE(wid)->sTR0) + +#define LOCAL_new_TR (Yap_local.new_TR) +#define REMOTE_new_TR(wid) (REMOTE(wid)->new_TR) + +#define LOCAL_cont_top0 (Yap_local.cont_top0) +#define REMOTE_cont_top0(wid) (REMOTE(wid)->cont_top0) + +#define LOCAL_cont_top (Yap_local.cont_top) +#define REMOTE_cont_top(wid) (REMOTE(wid)->cont_top) + +#define LOCAL_discard_trail_entries (Yap_local.discard_trail_entries) +#define REMOTE_discard_trail_entries(wid) (REMOTE(wid)->discard_trail_entries) + +#define LOCAL_gc_ma_hash_table (Yap_local.gc_ma_hash_table) +#define REMOTE_gc_ma_hash_table(wid) (REMOTE(wid)->gc_ma_hash_table) + +#define LOCAL_gc_ma_h_top (Yap_local.gc_ma_h_top) +#define REMOTE_gc_ma_h_top(wid) (REMOTE(wid)->gc_ma_h_top) + +#define LOCAL_gc_ma_h_list (Yap_local.gc_ma_h_list) +#define REMOTE_gc_ma_h_list(wid) (REMOTE(wid)->gc_ma_h_list) + +#define LOCAL_gc_timestamp (Yap_local.gc_timestamp) +#define REMOTE_gc_timestamp(wid) (REMOTE(wid)->gc_timestamp) + +#define LOCAL_db_vec (Yap_local.db_vec) +#define REMOTE_db_vec(wid) (REMOTE(wid)->db_vec) + +#define LOCAL_db_vec0 (Yap_local.db_vec0) +#define REMOTE_db_vec0(wid) (REMOTE(wid)->db_vec0) + +#define LOCAL_db_root (Yap_local.db_root) +#define REMOTE_db_root(wid) (REMOTE(wid)->db_root) + +#define LOCAL_db_nil (Yap_local.db_nil) +#define REMOTE_db_nil(wid) (REMOTE(wid)->db_nil) + +#define LOCAL_gc_restore (Yap_local.gc_restore) +#define REMOTE_gc_restore(wid) (REMOTE(wid)->gc_restore) + +#define LOCAL_extra_gc_cells (Yap_local.extra_gc_cells) +#define REMOTE_extra_gc_cells(wid) (REMOTE(wid)->extra_gc_cells) + +#define LOCAL_extra_gc_cells_base (Yap_local.extra_gc_cells_base) +#define REMOTE_extra_gc_cells_base(wid) (REMOTE(wid)->extra_gc_cells_base) + +#define LOCAL_extra_gc_cells_top (Yap_local.extra_gc_cells_top) +#define REMOTE_extra_gc_cells_top(wid) (REMOTE(wid)->extra_gc_cells_top) + +#define LOCAL_extra_gc_cells_size (Yap_local.extra_gc_cells_size) +#define REMOTE_extra_gc_cells_size(wid) (REMOTE(wid)->extra_gc_cells_size) + +#define LOCAL_DynamicArrays (Yap_local.DynamicArrays) +#define REMOTE_DynamicArrays(wid) (REMOTE(wid)->DynamicArrays) + +#define LOCAL_StaticArrays (Yap_local.StaticArrays) +#define REMOTE_StaticArrays(wid) (REMOTE(wid)->StaticArrays) + +#define LOCAL_GlobalVariables (Yap_local.GlobalVariables) +#define REMOTE_GlobalVariables(wid) (REMOTE(wid)->GlobalVariables) + +#define LOCAL_AllowRestart (Yap_local.AllowRestart) +#define REMOTE_AllowRestart(wid) (REMOTE(wid)->AllowRestart) + +// Thread Local Area for Fast Storage of Intermediate Compiled Code +#define LOCAL_CMemFirstBlock (Yap_local.CMemFirstBlock) +#define REMOTE_CMemFirstBlock(wid) (REMOTE(wid)->CMemFirstBlock) + +#define LOCAL_CMemFirstBlockSz (Yap_local.CMemFirstBlockSz) +#define REMOTE_CMemFirstBlockSz(wid) (REMOTE(wid)->CMemFirstBlockSz) + +// Variable used by the compiler to store number of permanent vars in a clause +#define LOCAL_nperm (Yap_local.nperm) +#define REMOTE_nperm(wid) (REMOTE(wid)->nperm) + +#define LOCAL_jMP (Yap_local.jMP) +#define REMOTE_jMP(wid) (REMOTE(wid)->jMP) + +// Thread Local Area for Labels +#define LOCAL_LabelFirstArray (Yap_local.LabelFirstArray) +#define REMOTE_LabelFirstArray(wid) (REMOTE(wid)->LabelFirstArray) + +#define LOCAL_LabelFirstArraySz (Yap_local.LabelFirstArraySz) +#define REMOTE_LabelFirstArraySz(wid) (REMOTE(wid)->LabelFirstArraySz) + +// Thread Local Area for SWI-Prolog emulation routines. +// struct LOCAL_INIT( PL_local_data*, PL_local_data_p, Yap_InitThreadIO(wid)) +#ifdef THREADS +#define LOCAL_ThreadHandle (Yap_local.ThreadHandle) +#define REMOTE_ThreadHandle(wid) (REMOTE(wid)->ThreadHandle) + +#endif /* THREADS */ +#if defined(YAPOR) || defined(TABLING) +#define LOCAL_optyap_data (Yap_local.optyap_data) +#define REMOTE_optyap_data(wid) (REMOTE(wid)->optyap_data) + +#define LOCAL_TabMode (Yap_local.TabMode) +#define REMOTE_TabMode(wid) (REMOTE(wid)->TabMode) + +#endif /* YAPOR || TABLING */ +#define LOCAL_InterruptsDisabled (Yap_local.InterruptsDisabled) +#define REMOTE_InterruptsDisabled(wid) (REMOTE(wid)->InterruptsDisabled) + +#define LOCAL_execution (Yap_local.execution) +#define REMOTE_execution(wid) (REMOTE(wid)->execution) + +#if LOW_LEVEL_TRACER +#define LOCAL_total_choicepoints (Yap_local.total_choicepoints) +#define REMOTE_total_choicepoints(wid) (REMOTE(wid)->total_choicepoints) + +#endif +#define LOCAL_consult_level (Yap_local.consult_level) +#define REMOTE_consult_level(wid) (REMOTE(wid)->consult_level) + +// Variables related to memory allocation +#define LOCAL_LocalBase (Yap_local.LocalBase) +#define REMOTE_LocalBase(wid) (REMOTE(wid)->LocalBase) + +#define LOCAL_GlobalBase (Yap_local.GlobalBase) +#define REMOTE_GlobalBase(wid) (REMOTE(wid)->GlobalBase) + +#define LOCAL_TrailBase (Yap_local.TrailBase) +#define REMOTE_TrailBase(wid) (REMOTE(wid)->TrailBase) + +#define LOCAL_TrailTop (Yap_local.TrailTop) +#define REMOTE_TrailTop(wid) (REMOTE(wid)->TrailTop) + +/* error handling info, designed to be easy to pass to the foreign world */ +#define LOCAL_ActiveError (Yap_local.ActiveError) +#define REMOTE_ActiveError(wid) (REMOTE(wid)->ActiveError) + +#define LOCAL_CommittedError (Yap_local.CommittedError) +#define REMOTE_CommittedError(wid) (REMOTE(wid)->CommittedError) + +#define LOCAL_delay (Yap_local.delay) +#define REMOTE_delay(wid) (REMOTE(wid)->delay) + +/// pointer to an exception term, from throw +#define LOCAL_IOBotch (Yap_local.IOBotch) +#define REMOTE_IOBotch(wid) (REMOTE(wid)->IOBotch) + +/// tokenizer support (should be private to the tokenizer). +#define LOCAL_tokptr (Yap_local.tokptr) +#define REMOTE_tokptr(wid) (REMOTE(wid)->tokptr) + +#define LOCAL_toktide (Yap_local.toktide) +#define REMOTE_toktide(wid) (REMOTE(wid)->toktide) + +#define LOCAL_VarTable (Yap_local.VarTable) +#define REMOTE_VarTable(wid) (REMOTE(wid)->VarTable) + +#define LOCAL_AnonVarTable (Yap_local.AnonVarTable) +#define REMOTE_AnonVarTable(wid) (REMOTE(wid)->AnonVarTable) + +#define LOCAL_Comments (Yap_local.Comments) +#define REMOTE_Comments(wid) (REMOTE(wid)->Comments) + +#define LOCAL_CommentsTail (Yap_local.CommentsTail) +#define REMOTE_CommentsTail(wid) (REMOTE(wid)->CommentsTail) + +#define LOCAL_CommentsNextChar (Yap_local.CommentsNextChar) +#define REMOTE_CommentsNextChar(wid) (REMOTE(wid)->CommentsNextChar) + +#define LOCAL_CommentsBuff (Yap_local.CommentsBuff) +#define REMOTE_CommentsBuff(wid) (REMOTE(wid)->CommentsBuff) + +#define LOCAL_CommentsBuffPos (Yap_local.CommentsBuffPos) +#define REMOTE_CommentsBuffPos(wid) (REMOTE(wid)->CommentsBuffPos) + +#define LOCAL_CommentsBuffLim (Yap_local.CommentsBuffLim) +#define REMOTE_CommentsBuffLim(wid) (REMOTE(wid)->CommentsBuffLim) + +#define LOCAL_RestartEnv (Yap_local.RestartEnv) +#define REMOTE_RestartEnv(wid) (REMOTE(wid)->RestartEnv) + +#define LOCAL_FileNameBuf (Yap_local.FileNameBuf) +#define REMOTE_FileNameBuf(wid) (REMOTE(wid)->FileNameBuf) + +#define LOCAL_FileNameBuf2 (Yap_local.FileNameBuf2) +#define REMOTE_FileNameBuf2(wid) (REMOTE(wid)->FileNameBuf2) + +#define LOCAL_TextBuffer (Yap_local.TextBuffer) +#define REMOTE_TextBuffer(wid) (REMOTE(wid)->TextBuffer) + +// Prolog State +#define LOCAL_BreakLevel (Yap_local.BreakLevel) +#define REMOTE_BreakLevel(wid) (REMOTE(wid)->BreakLevel) + +#define LOCAL_PrologMode (Yap_local.PrologMode) +#define REMOTE_PrologMode(wid) (REMOTE(wid)->PrologMode) + +#define LOCAL_CritLocks (Yap_local.CritLocks) +#define REMOTE_CritLocks(wid) (REMOTE(wid)->CritLocks) + +// Prolog execution and state flags +#define LOCAL_Flags (Yap_local.Flags) +#define REMOTE_Flags(wid) (REMOTE(wid)->Flags) + +#define LOCAL_flagCount (Yap_local.flagCount) +#define REMOTE_flagCount(wid) (REMOTE(wid)->flagCount) + +// analyst.c +/* used to find out how many instructions of each kind are executed */ +#ifdef ANALYST +#define LOCAL_opcount (Yap_local.opcount) +#define REMOTE_opcount(wid) (REMOTE(wid)->opcount) + +#define LOCAL_2opcount (Yap_local.2opcount) +#define REMOTE_2opcount(wid) (REMOTE(wid)->2opcount) + +#endif /* ANALYST */ +// dbase.c +#define LOCAL_s_dbg (Yap_local.s_dbg) +#define REMOTE_s_dbg(wid) (REMOTE(wid)->s_dbg) + +// eval.c +#define LOCAL_mathtt (Yap_local.mathtt) +#define REMOTE_mathtt(wid) (REMOTE(wid)->mathtt) + +#define LOCAL_mathstring (Yap_local.mathstring) +#define REMOTE_mathstring(wid) (REMOTE(wid)->mathstring) + +#define LOCAL_ctx (Yap_local.ctx) +#define REMOTE_ctx(wid) (REMOTE(wid)->ctx) + +// grow.c +#define LOCAL_heap_overflows (Yap_local.heap_overflows) +#define REMOTE_heap_overflows(wid) (REMOTE(wid)->heap_overflows) + +#define LOCAL_total_heap_overflow_time (Yap_local.total_heap_overflow_time) +#define REMOTE_total_heap_overflow_time(wid) (REMOTE(wid)->total_heap_overflow_time) + +#define LOCAL_stack_overflows (Yap_local.stack_overflows) +#define REMOTE_stack_overflows(wid) (REMOTE(wid)->stack_overflows) + +#define LOCAL_total_stack_overflow_time (Yap_local.total_stack_overflow_time) +#define REMOTE_total_stack_overflow_time(wid) (REMOTE(wid)->total_stack_overflow_time) + +#define LOCAL_delay_overflows (Yap_local.delay_overflows) +#define REMOTE_delay_overflows(wid) (REMOTE(wid)->delay_overflows) + +#define LOCAL_total_delay_overflow_time (Yap_local.total_delay_overflow_time) +#define REMOTE_total_delay_overflow_time(wid) (REMOTE(wid)->total_delay_overflow_time) + +#define LOCAL_trail_overflows (Yap_local.trail_overflows) +#define REMOTE_trail_overflows(wid) (REMOTE(wid)->trail_overflows) + +#define LOCAL_total_trail_overflow_time (Yap_local.total_trail_overflow_time) +#define REMOTE_total_trail_overflow_time(wid) (REMOTE(wid)->total_trail_overflow_time) + +#define LOCAL_atom_table_overflows (Yap_local.atom_table_overflows) +#define REMOTE_atom_table_overflows(wid) (REMOTE(wid)->atom_table_overflows) + +#define LOCAL_total_atom_table_overflow_time (Yap_local.total_atom_table_overflow_time) +#define REMOTE_total_atom_table_overflow_time(wid) (REMOTE(wid)->total_atom_table_overflow_time) + +// load_dyld +#ifdef LOAD_DYLD +#define LOCAL_dl_errno (Yap_local.dl_errno) +#define REMOTE_dl_errno(wid) (REMOTE(wid)->dl_errno) + +#endif +// tracer.c +#ifdef LOW_LEVEL_TRACER +#define LOCAL_do_trace_primitives (Yap_local.do_trace_primitives) +#define REMOTE_do_trace_primitives(wid) (REMOTE(wid)->do_trace_primitives) + +#endif +// quick loader +#define LOCAL_ExportAtomHashChain (Yap_local.ExportAtomHashChain) +#define REMOTE_ExportAtomHashChain(wid) (REMOTE(wid)->ExportAtomHashChain) + +#define LOCAL_ExportAtomHashTableSize (Yap_local.ExportAtomHashTableSize) +#define REMOTE_ExportAtomHashTableSize(wid) (REMOTE(wid)->ExportAtomHashTableSize) + +#define LOCAL_ExportAtomHashTableNum (Yap_local.ExportAtomHashTableNum) +#define REMOTE_ExportAtomHashTableNum(wid) (REMOTE(wid)->ExportAtomHashTableNum) + +#define LOCAL_ExportFunctorHashChain (Yap_local.ExportFunctorHashChain) +#define REMOTE_ExportFunctorHashChain(wid) (REMOTE(wid)->ExportFunctorHashChain) + +#define LOCAL_ExportFunctorHashTableSize (Yap_local.ExportFunctorHashTableSize) +#define REMOTE_ExportFunctorHashTableSize(wid) (REMOTE(wid)->ExportFunctorHashTableSize) + +#define LOCAL_ExportFunctorHashTableNum (Yap_local.ExportFunctorHashTableNum) +#define REMOTE_ExportFunctorHashTableNum(wid) (REMOTE(wid)->ExportFunctorHashTableNum) + +#define LOCAL_ExportPredEntryHashChain (Yap_local.ExportPredEntryHashChain) +#define REMOTE_ExportPredEntryHashChain(wid) (REMOTE(wid)->ExportPredEntryHashChain) + +#define LOCAL_ExportPredEntryHashTableSize (Yap_local.ExportPredEntryHashTableSize) +#define REMOTE_ExportPredEntryHashTableSize(wid) (REMOTE(wid)->ExportPredEntryHashTableSize) + +#define LOCAL_ExportPredEntryHashTableNum (Yap_local.ExportPredEntryHashTableNum) +#define REMOTE_ExportPredEntryHashTableNum(wid) (REMOTE(wid)->ExportPredEntryHashTableNum) + +#define LOCAL_ExportDBRefHashChain (Yap_local.ExportDBRefHashChain) +#define REMOTE_ExportDBRefHashChain(wid) (REMOTE(wid)->ExportDBRefHashChain) + +#define LOCAL_ExportDBRefHashTableSize (Yap_local.ExportDBRefHashTableSize) +#define REMOTE_ExportDBRefHashTableSize(wid) (REMOTE(wid)->ExportDBRefHashTableSize) + +#define LOCAL_ExportDBRefHashTableNum (Yap_local.ExportDBRefHashTableNum) +#define REMOTE_ExportDBRefHashTableNum(wid) (REMOTE(wid)->ExportDBRefHashTableNum) + +#define LOCAL_ImportAtomHashChain (Yap_local.ImportAtomHashChain) +#define REMOTE_ImportAtomHashChain(wid) (REMOTE(wid)->ImportAtomHashChain) + +#define LOCAL_ImportAtomHashTableSize (Yap_local.ImportAtomHashTableSize) +#define REMOTE_ImportAtomHashTableSize(wid) (REMOTE(wid)->ImportAtomHashTableSize) + +#define LOCAL_ImportAtomHashTableNum (Yap_local.ImportAtomHashTableNum) +#define REMOTE_ImportAtomHashTableNum(wid) (REMOTE(wid)->ImportAtomHashTableNum) + +#define LOCAL_ImportFunctorHashChain (Yap_local.ImportFunctorHashChain) +#define REMOTE_ImportFunctorHashChain(wid) (REMOTE(wid)->ImportFunctorHashChain) + +#define LOCAL_ImportFunctorHashTableSize (Yap_local.ImportFunctorHashTableSize) +#define REMOTE_ImportFunctorHashTableSize(wid) (REMOTE(wid)->ImportFunctorHashTableSize) + +#define LOCAL_ImportFunctorHashTableNum (Yap_local.ImportFunctorHashTableNum) +#define REMOTE_ImportFunctorHashTableNum(wid) (REMOTE(wid)->ImportFunctorHashTableNum) + +#define LOCAL_ImportOPCODEHashChain (Yap_local.ImportOPCODEHashChain) +#define REMOTE_ImportOPCODEHashChain(wid) (REMOTE(wid)->ImportOPCODEHashChain) + +#define LOCAL_ImportOPCODEHashTableSize (Yap_local.ImportOPCODEHashTableSize) +#define REMOTE_ImportOPCODEHashTableSize(wid) (REMOTE(wid)->ImportOPCODEHashTableSize) + +#define LOCAL_ImportPredEntryHashChain (Yap_local.ImportPredEntryHashChain) +#define REMOTE_ImportPredEntryHashChain(wid) (REMOTE(wid)->ImportPredEntryHashChain) + +#define LOCAL_ImportPredEntryHashTableSize (Yap_local.ImportPredEntryHashTableSize) +#define REMOTE_ImportPredEntryHashTableSize(wid) (REMOTE(wid)->ImportPredEntryHashTableSize) + +#define LOCAL_ImportPredEntryHashTableNum (Yap_local.ImportPredEntryHashTableNum) +#define REMOTE_ImportPredEntryHashTableNum(wid) (REMOTE(wid)->ImportPredEntryHashTableNum) + +#define LOCAL_ImportDBRefHashChain (Yap_local.ImportDBRefHashChain) +#define REMOTE_ImportDBRefHashChain(wid) (REMOTE(wid)->ImportDBRefHashChain) + +#define LOCAL_ImportDBRefHashTableSize (Yap_local.ImportDBRefHashTableSize) +#define REMOTE_ImportDBRefHashTableSize(wid) (REMOTE(wid)->ImportDBRefHashTableSize) + +#define LOCAL_ImportDBRefHashTableNum (Yap_local.ImportDBRefHashTableNum) +#define REMOTE_ImportDBRefHashTableNum(wid) (REMOTE(wid)->ImportDBRefHashTableNum) + +#define LOCAL_ImportFAILCODE (Yap_local.ImportFAILCODE) +#define REMOTE_ImportFAILCODE(wid) (REMOTE(wid)->ImportFAILCODE) + +// exo indexing +#define LOCAL_ibnds (Yap_local.ibnds) +#define REMOTE_ibnds(wid) (REMOTE(wid)->ibnds) + +#define LOCAL_exo_it (Yap_local.exo_it) +#define REMOTE_exo_it(wid) (REMOTE(wid)->exo_it) + +#define LOCAL_exo_base (Yap_local.exo_base) +#define REMOTE_exo_base(wid) (REMOTE(wid)->exo_base) + +#define LOCAL_exo_arity (Yap_local.exo_arity) +#define REMOTE_exo_arity(wid) (REMOTE(wid)->exo_arity) + +#define LOCAL_exo_arg (Yap_local.exo_arg) +#define REMOTE_exo_arg(wid) (REMOTE(wid)->exo_arg) + +// atom completion +#define LOCAL_search_atoms (Yap_local.search_atoms) +#define REMOTE_search_atoms(wid) (REMOTE(wid)->search_atoms) + +#define LOCAL_SearchPreds (Yap_local.SearchPreds) +#define REMOTE_SearchPreds(wid) (REMOTE(wid)->SearchPreds) + +/// Slots Status +#define LOCAL_CurSlot (Yap_local.CurSlot) +#define REMOTE_CurSlot(wid) (REMOTE(wid)->CurSlot) + +#define LOCAL_FrozenHandles (Yap_local.FrozenHandles) +#define REMOTE_FrozenHandles(wid) (REMOTE(wid)->FrozenHandles) + +#define LOCAL_NSlots (Yap_local.NSlots) +#define REMOTE_NSlots(wid) (REMOTE(wid)->NSlots) + +#define LOCAL_SlotBase (Yap_local.SlotBase) +#define REMOTE_SlotBase(wid) (REMOTE(wid)->SlotBase) + +// Mutexes +#define LOCAL_Mutexes (Yap_local.Mutexes) +#define REMOTE_Mutexes(wid) (REMOTE(wid)->Mutexes) + +#define LOCAL_SourceModule (Yap_local.SourceModule) +#define REMOTE_SourceModule(wid) (REMOTE(wid)->SourceModule) + +#define LOCAL_Including (Yap_local.Including) +#define REMOTE_Including(wid) (REMOTE(wid)->Including) + +#define LOCAL_MAX_SIZE (Yap_local.MAX_SIZE) +#define REMOTE_MAX_SIZE(wid) (REMOTE(wid)->MAX_SIZE) + +/* last call to walltime. */ +#define LOCAL_LastWTime (Yap_local.LastWTime) +#define REMOTE_LastWTime(wid) (REMOTE(wid)->LastWTime) + +#define LOCAL_shared (Yap_local.shared) +#define REMOTE_shared(wid) (REMOTE(wid)->shared) + diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index d3b15361d..526e72e00 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -1,54 +1,123 @@ -SET (CODES - solarized-light.css - theme.css - yap.css - icons/yap_64x64x32.png - icons/yap_256x256x32.png - icons/yap_128x128x32.png - icons/yap_48x48x32.png - ) -SET (DOCS -builtins.md -chr.md -clpqr.md -download.md -extensions.md -fli.md -install.md -packages.md -run.md -swi.md -syntax.md -yap.md - ) - +if (WITH_DOCS) + + + set (TOP_DIR YES) + +set(DOCS_SOURCE_DIR ${CMAKE_SOURCE_DIR}/docs) + +SET (CMAKE_HTML_EXTRA_) + +SET( EXT + ${DOCS_SOURCE_DIR}/custom/application.js + ${DOCS_SOURCE_DIR}/custom/assets + ${DOCS_SOURCE_DIR}/custom/bootstrap.min.css + ${DOCS_SOURCE_DIR}/custom/bootstrap.min.js + ${DOCS_SOURCE_DIR}/custom/customdoxygen.css + ${DOCS_SOURCE_DIR}/custom/default + ${DOCS_SOURCE_DIR}/custom/doxy-boot.js + ${DOCS_SOURCE_DIR}/custom/font-awesome.min.css + ${DOCS_SOURCE_DIR}/custom/footer.html + ${DOCS_SOURCE_DIR}/custom/header.html + ${DOCS_SOURCE_DIR}/custom/jquery-3.2.1.min.js + ${DOCS_SOURCE_DIR}/custom/offcanvas.css + ${DOCS_SOURCE_DIR}/custom/offcanvas.js + ${DOCS_SOURCE_DIR}/custom/solarized-light.css + ${DOCS_SOURCE_DIR}/custom/theme.css + ${DOCS_SOURCE_DIR}/custom/yap.css + ) + foreach(i ${CMAKE_HTML_EXTRA_}) + string(APPEND CMAKE_HTML_EXTRA ${i} " ") + endforeach(i ${CMAKE_HTML_EXTRA_}) + +set(DOCS_EXCLUDE_ +${CMAKE_SOURCE_DIR}/build +${CMAKE_SOURCE_DIR}/Debug +${CMAKE_SOURCE_DIR}/packages/jpl +${CMAKE_SOURCE_DIR}/packages/swig + ${CMAKE_SOURCE_DIR}/packages/Problog/problog_examples/output + ${CMAKE_SOURCE_DIR}/packages/Problog/problog_examples/queries +${CMAKE_SOURCE_DIR}/packages/myddas/sqlite3/src +${CMAKE_SOURCE_DIR}/packages/gecode/4.4.0 +${CMAKE_SOURCE_DIR}/packages/gecode/4.2.1 +${CMAKE_SOURCE_DIR}/packages/gecode/4.2.0 +${CMAKE_SOURCE_DIR}/packages/gecode/4.0.0 +${CMAKE_SOURCE_DIR}/packages/gecode/3.7.3 +${CMAKE_SOURCE_DIR}/packages/gecode/3.7.2 +${CMAKE_SOURCE_DIR}/packages/gecode/3.7.1 +${CMAKE_SOURCE_DIR}/packages/gecode/3.7.0 +${CMAKE_SOURCE_DIR}/packages/gecode/3.6.0 +${CMAKE_SOURCE_DIR}/packages/problog +${CMAKE_SOURCE_DIR}/packages/gecode/dev +${CMAKE_SOURCE_DIR}/C/traced_absmi_insts.h +${CMAKE_SOURCE_DIR}/H/globals.h +${CMAKE_SOURCE_DIR}/packages/cplint +${CMAKE_SOURCE_DIR}/packages/CLPBN/examples +${CMAKE_SOURCE_DIR}/packages/CLPBN/horus +${CMAKE_SOURCE_DIR}/packages/prosqlite +${CMAKE_SOURCE_DIR}/packages/pyswip +${CMAKE_SOURCE_DIR}/packages/python/yap_kernel +${CMAKE_SOURCE_DIR}/packages/python/swig +${CMAKE_SOURCE_DIR}/packages/yap-lbfgs/liblbfgs-1.10 +${CMAKE_SOURCE_DIR}/library/dialect/swi/os +${CMAKE_SOURCE_DIR}/*/bprolog/* + ${CMAKE_SOURCE_DIR}/*/prism/* + ${CMAKE_SOURCE_DIR}/*/gecodde/[345]* + ${CMAKE_SOURCE_DIR}/packages/gecode/gecode3_yap.cc + ${CMAKE_SOURCE_DIR}/packages/gecode/gecode4_yap.cc + ${CMAKE_SOURCE_DIR}/packages/gecode/gecode5_yap.cc + ${CMAKE_SOURCE_DIR}/packages/gecode/gecode3.yap + ${CMAKE_SOURCE_DIR}/packages/gecode/gecode4.yap + ${CMAKE_SOURCE_DIR}/packages/gecode/gecode5.yap + ${CMAKE_SOURCE_DIR}/packages/gecode/gecode3_yap_hand_written.yap + ${CMAKE_SOURCE_DIR}/packages/gecode/gecode4_yap_hand_written.yap + ${CMAKE_SOURCE_DIR}/packages/gecode/gecode5_yap_hand_written.yap + */CMakeFiles/* *~ */#* +) + + +foreach(i ${DOCS_EXCLUDE_}) + string(APPEND DOCS_EXCLUDE ${i} " ") +endforeach(i ${DOCS_EXCLUDE_}) + # add a target to generate API documentation with Doxygen -find_host_package(Doxygen) -option(WITH_DOCS "Create and install the HTML based API documentation (requires Doxygen)" ${DOXYGEN_FOUND}) + set(doxyfile_in ${CMAKE_SOURCE_DIR}/docs/Doxyfile.in) -if (WITH_DOCS) - if(NOT DOXYGEN_FOUND) - message(FATAL_ERROR "Doxygen is needed to build the documentation.") - endif() + add_subdirectory(../packages/raptor/doc ${CMAKE_BINARY_DIR}/packages/raptor/doc) + + SET(DOC_INPUT_FILES_ + ${CMAKE_SOURCE_DIR}/docs/md + ${CMAKE_SOURCE_DIR}/pl + ${CMAKE_SOURCE_DIR}/CXX + ${CMAKE_SOURCE_DIR}/OPTYap + ${CMAKE_SOURCE_DIR}/C + ${CMAKE_SOURCE_DIR}/H + ${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/os + ${CMAKE_SOURCE_DIR}/library + ${CMAKE_SOURCE_DIR}/swi/library + ${CMAKE_SOURCE_DIR}/packages + ) + +foreach(i ${DOC_INPUT_FILES_}) + + string(APPEND DOC_INPUT_FILES ${i} " ") +endforeach(i ${DOC_INPUT_FILES_}) - set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in) set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) - - configure_file(${doxyfile_in} ${doxyfile} @ONLY) - configure_file(source/conf.py.in source/conf.py) - configure_file(source/index.rst source/index.rst) - add_custom_target(doc - COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Generating API documentation with Doxygen" - VERBATIM) + configure_file(${CMAKE_SOURCE_DIR}/docs/source/conf.py.in source/conf.py) + configure_file(${CMAKE_SOURCE_DIR}/docs/source/index.rst source/index.rst) + +add_custom_target(docs + COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile} + ) + if (EXISTS ${CMAKE_CURRENT_BINARY_DIR}/html) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION ${docdir}) @@ -56,5 +125,5 @@ if (WITH_DOCS) install(FILES ${CODES} DESTINATION ${docdir}) endif() - endif() +endif() diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index a2ba3d457..07622a5d7 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -1,4 +1,4 @@ -# Doxyfile 1.8.11 +# Doxyfile 1.8.14 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. @@ -8,9 +8,9 @@ # # All text after a single hash (#) is considered a comment and will be ignored. # The format is: -# TAG = value [value, file.] +# TAG = value [value, ...] # For lists, items can also be appended using: -# TAG += value [value, file.] +# TAG += value [value, ...] # Values that contain spaces should be placed between quotes (\" \"). #--------------------------------------------------------------------------- @@ -68,7 +68,7 @@ OUTPUT_DIRECTORY = @PROJECT_BINARY_DIR@/docs # performance problems for the file system. # The default value is: NO. -CREATE_SUBDIRS = YES +CREATE_SUBDIRS = NO # If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII # characters to appear in the names of generated files. If set to NO, non-ASCII @@ -98,7 +98,7 @@ OUTPUT_LANGUAGE = English # documentation (similar to Javadoc). Set to NO to disable this. # The default value is: YES. - BRIEF_MEMBER_DESC = YES +BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief # description of a member or function before the detailed description @@ -204,7 +204,7 @@ MULTILINE_CPP_IS_BRIEF = NO # documentation from any documented member that it re-implements. # The default value is: YES. -INHERIT_DOCS = YES +INHERIT_DOCS = NO # If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new # page for each member. If set to NO, the documentation of a member will be part @@ -229,10 +229,15 @@ TAB_SIZE = 4 # "Side Effects:". You can put \n's in the value part of an alias to insert # newlines. -ALIASES = "predicate=@brief" "license=@par License:\n" \ - "doxygen=\if english" "endenglish=\endif" "dutch=\if dutch" \ - "enddutch=\endif" "tbd=@par TBD:\n" "compat=@par Compatibility:\n" \ - "error=@par Error:\n" +ALIASES = "predicate=@brief" \ + "license=@par License:\n" \ + "doxygen=\if english" \ + "endenglish=\endif" \ + "dutch=\if dutch" \ + "enddutch=\endif" \ + "tbd=@par TBD:\n" \ + "compat=@par Compatibility:\n" \ + "error=@par Error:\n" # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding "class=itcl::class" @@ -246,7 +251,7 @@ TCL_SUBST = # members will be omitted, etc. # The default value is: NO. -OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_FOR_C = YES # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or # Python sources only. Doxygen will then generate output that is more tailored @@ -291,7 +296,10 @@ OPTIMIZE_OUTPUT_FOR_PROLOG = YES # Note that for custom extensions you also need to set FILE_PATTERNS otherwise # the files are not read by doxygen. -EXTENSION_MAPPING = md pl=Prolog yap=Prolog ypp=Prolog +EXTENSION_MAPPING = md \ + pl=Prolog \ + yap=Prolog \ + ypp=Prolog # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments # according to the Markdown format, which allows for more readable @@ -303,6 +311,15 @@ EXTENSION_MAPPING = md pl=Prolog yap=Prolog ypp=Prolog MARKDOWN_SUPPORT = YES +# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up +# to that level are automatically included in the table of contents, even if +# they do not have an id attribute. +# Note: This feature currently applies only to Markdown headings. +# Minimum value: 0, maximum value: 99, default value: 0. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +TOC_INCLUDE_HEADINGS = 99 + # When enabled doxygen tries to link words that correspond to documented # classes, or namespaces to their corresponding documentation. Such a link can # be prevented in individual cases by putting a % sign in front of the word or @@ -407,7 +424,7 @@ TYPEDEF_HIDES_STRUCT = NO # code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small # doxygen will become slower. If the cache is too large, memory is wasted. The # cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range -# is 0file9, the default is 0, corresponding to a cache size of 2^16=65536 +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 # symbols. At the end of a run doxygen will report the cache usage and suggest # the optimal cache size from a speed point of view. # Minimum value: 0, maximum value: 9, default value: 0. @@ -636,8 +653,8 @@ GENERATE_BUGLIST = YES GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional documentation -# sections, marked by \if file. \endif and \cond -# file. \endcond blocks. +# sections, marked by \if ... \endif and \cond +# ... \endcond blocks. ENABLED_SECTIONS = @@ -694,7 +711,7 @@ FILE_VERSION_FILTER = # DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE # tag is left empty. -LAYOUT_FILE = +LAYOUT_FILE = @CMAKE_SOURCE_DIR@/docs/custom/DoxygenLayout.xml # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib @@ -728,10 +745,10 @@ WARNINGS = YES # If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate # warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag - # will automatically be disabled. +# will automatically be disabled. # The default value is: YES. -WARN_IF_UNDOCUMENTED = YES +WARN_IF_UNDOCUMENTED = NO # If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some parameters @@ -749,6 +766,12 @@ WARN_IF_DOC_ERROR = YES WARN_NO_PARAMDOC = NO +# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when +# a warning is encountered. +# The default value is: NO. + +WARN_AS_ERROR = NO + # The WARN_FORMAT tag determines the format of the warning messages that doxygen # can produce. The string should contain the $file, $line, and $text tags, which # will be replaced by the file and line number from which the warning originated @@ -775,19 +798,7 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = @PROJECT_SOURCE_DIR@/INSTALL.md \ - @PROJECT_SOURCE_DIR@/pl \ - @PROJECT_SOURCE_DIR@/CXX \ - @PROJECT_SOURCE_DIR@/OPTYap \ - @PROJECT_SOURCE_DIR@/C \ - @PROJECT_SOURCE_DIR@/H \ - @PROJECT_SOURCE_DIR@/include \ - @PROJECT_SOURCE_DIR@/os \ - @PROJECT_SOURCE_DIR@/library \ - @PROJECT_SOURCE_DIR@/packages \ - @PROJECT_SOURCE_DIR@/swi/library \ - @PROJECT_SOURCE_DIR@/docs/md \ - +INPUT = @DOC_INPUT_FILES@ # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses @@ -809,10 +820,56 @@ INPUT_ENCODING = UTF-8 # If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, # *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, # *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, -# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, -# *.vhdl, *.ucf, *.qsf, *.as and *.js. +# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, +# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, *.qsf, *.as, *.js, *.yap, *.ypp, +# *.prolog and *.pl. -FILE_PATTERNS = *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.idl *.ddl *.odl *.h *.h.in *.hh *.hxx *.hpp *.h++ *.cs *.d *.php *.php4 *.php5 *.phtml *.inc *.m *.markdown *.md *.mm *.dox *.py *.f90 *.f *.for *.tcl *.vhd *.vhdl *.ucf *.qsf *.as *.js *.pl *.yap *.ypp +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.idl \ + *.ddl \ + *.odl \ + *.h \ + *.h.in \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.cs \ + *.d \ + *.php \ + *.php4 \ + *.php5 \ + *.phtml \ + *.inc \ + *.m \ + *.markdown \ + *.md \ + *.mm \ + *.dox \ + *.py \ + *.f90 \ + *.f \ + *.for \ + *.tcl \ + *.vhd \ + *.vhdl \ + *.ucf \ + *.qsf \ + *.as \ + *.js \ + *.pl \ + *.yap \ + *.ypp # The RECURSIVE tag can be used to specify whether or not subdirectories should # be searched for input files as well. @@ -827,25 +884,7 @@ RECURSIVE = YES # Note that relative paths are relative to the directory from which doxygen is # run. -EXCLUDE = *pltotex.pl \ -@PROJECT_SOURCE_DIR@/packages/myddas/sqlite3/src \ -@PROJECT_SOURCE_DIR@/packages/gecode/4.4.0 \ -@PROJECT_SOURCE_DIR@/packages/gecode/4.2.1 \ -@PROJECT_SOURCE_DIR@/packages/gecode/4.2.0 \ -@PROJECT_SOURCE_DIR@/packages/gecode/4.0.0 \ -@PROJECT_SOURCE_DIR@/packages/gecode/3.7.3 \ -@PROJECT_SOURCE_DIR@/packages/gecode/3.7.2 \ -@PROJECT_SOURCE_DIR@/packages/gecode/3.7.1 \ -@PROJECT_SOURCE_DIR@/packages/gecode/3.7.0 \ -@PROJECT_SOURCE_DIR@/packages/gecode/3.6.0 \ -@PROJECT_SOURCE_DIR@/packages/gecode/dev \ -@PROJECT_SOURCE_DIR@/C/traced_absmi_insts.h \ -@PROJECT_SOURCE_DIR@/packages/cplint \ -@PROJECT_SOURCE_DIR@/packages/CLPBN/examples \ -@PROJECT_SOURCE_DIR@/packages/prosqlite \ -@PROJECT_SOURCE_DIR@/packages/pyswip \ -@PROJECT_SOURCE_DIR@/library/dialect/swi/os - +EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded @@ -861,13 +900,7 @@ EXCLUDE_SYMLINKS = NO # 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 = \ - @PROJECT_SOURCE_DIR@/packages/gecode/gecode3_yap.cc \ - @PROJECT_SOURCE_DIR@/packages/gecode/gecode4_yap.cc \ - @PROJECT_SOURCE_DIR@/packages/gecode/gecode3.yap \ - @PROJECT_SOURCE_DIR@/packages/gecode/gecode4.yap \ - @PROJECT_SOURCE_DIR@/packages/gecode/gecode3_yap_hand_written.yap \ @PROJECT_SOURCE_DIR@/packages/gecode/gecode4_yap_hand_written.yap - */CMakeFiles/* *~ */\#* \ +EXCLUDE_PATTERNS = @DOCS_EXCLUDE@ # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the @@ -1057,7 +1090,7 @@ VERBATIM_HEADERS = YES # classes, structs, unions or interfaces. # The default value is: YES. -ALPHABETICAL_INDEX = YES +ALPHABETICAL_INDEX = NO # The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in # which the alphabetical index list will be split. @@ -1116,7 +1149,7 @@ HTML_FILE_EXTENSION = .html # of the possible markers and block names see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_HEADER = @CMAKE_SOURCE_DIR@/docs/custom/header.html +HTML_HEADER = @CMAKE_SOURCE_DIR@/docs/custom/header.html # The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each # generated HTML page. If the tag is left blank doxygen will generate a standard @@ -1128,6 +1161,7 @@ HTML_HEADER = @CMAKE_SOURCE_DIR@/docs/custom/header.html HTML_FOOTER = @CMAKE_SOURCE_DIR@/docs/custom/footer.html + # The HTML_STYLESHEET tag can be used to specify a user-defined cascading style # sheet that is used by each HTML page. It can be used to fine-tune the look of # the HTML output. If left blank doxygen will generate a default style sheet. @@ -1140,8 +1174,6 @@ HTML_FOOTER = @CMAKE_SOURCE_DIR@/docs/custom/footer.html HTML_STYLESHEET = -#@CMAKE_SOURCE_DIR@/docs/web/bootstrap/customdoxygen.css - # The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined # cascading style sheets that are included after the standard style sheets # created by doxygen. Using this option one can overrule certain style aspects. @@ -1153,9 +1185,9 @@ HTML_STYLESHEET = # list). For an example see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_EXTRA_STYLESHEET = @CMAKE_SOURCE_DIR@/docs/custom/customdoxygen.css +HTML_EXTRA_STYLESHEET = @CMAKE_SOURCE_DIR@/docs/custom/customdoxygen.css + -# @CMAKE_SOURCE_DIR@/docs/solarized-light.css # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note # that these files will be copied to the base HTML output directory. Use the @@ -1164,7 +1196,7 @@ HTML_EXTRA_STYLESHEET = @CMAKE_SOURCE_DIR@/docs/custom/customdoxygen.css # files will be copied as-is; there are no commands or markers available. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_EXTRA_FILES = @CMAKE_SOURCE_DIR@/docs/custom/doxy-boot.js +HTML_EXTRA_FILES = @CMAKE_SOURCE_DIR@/docs/custom/doxy-boot.js # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the style sheet and background images according to @@ -1205,13 +1237,24 @@ HTML_COLORSTYLE_GAMMA = 80 HTML_TIMESTAMP = NO +# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML +# documentation will contain a main index with vertical navigation menus that +# are dynamically created via Javascript. If disabled, the navigation index will +# consists of multiple levels of tabs that are statically embedded in every HTML +# page. Disable this option to support browsers that do not have Javascript, +# like the Qt help browser. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_MENUS = YES + # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_DYNAMIC_SECTIONS = NO +HTML_DYNAMIC_SECTIONS = YES # With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries # shown in the various tree structured indices initially; the user can expand @@ -1511,7 +1554,7 @@ MATHJAX_FORMAT = HTML-CSS # output directory using the MATHJAX_RELPATH option. The destination directory # should contain the MathJax.js script. For instance, if the mathjax directory # is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be file/mathjax. The default value points to the MathJax +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax # Content Delivery Network so you can quickly see the result without installing # MathJax. However, it is strongly recommended to install a local copy of # MathJax from http://www.mathjax.org before deployment. @@ -1566,7 +1609,7 @@ SEARCHENGINE = YES # The default value is: NO. # This tag requires that the tag SEARCHENGINE is set to YES. -SERVER_BASED_SEARCH = YES +SERVER_BASED_SEARCH = NO # When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP # script for searching. Instead the search results are written to an XML file @@ -1582,7 +1625,7 @@ SERVER_BASED_SEARCH = YES # The default value is: NO. # This tag requires that the tag SEARCHENGINE is set to YES. -EXTERNAL_SEARCH = YAP +EXTERNAL_SEARCH = NO # The SEARCHENGINE_URL should point to a search engine hosted by a web server # which will return the search results when EXTERNAL_SEARCH is enabled. @@ -1628,7 +1671,7 @@ EXTRA_SEARCH_MAPPINGS = # If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output. # The default value is: YES. -GENERATE_LATEX = YES +GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of @@ -1925,7 +1968,7 @@ XML_OUTPUT = xml # The default value is: YES. # This tag requires that the tag GENERATE_XML is set to YES. -XML_PROGRAMLISTING = YES +XML_PROGRAMLISTING = NO #--------------------------------------------------------------------------- # Configuration options related to the DOCBOOK output @@ -2021,7 +2064,7 @@ ENABLE_PREPROCESSING = YES # The default value is: NO. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -MACRO_EXPANSION = NO +MACRO_EXPANSION = YES # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then # the macro expansion is limited to the macros specified with the PREDEFINED and @@ -2044,11 +2087,11 @@ SEARCH_INCLUDES = YES # This tag requires that the tag SEARCH_INCLUDES is set to YES. INCLUDE_PATH = @CMAKE_BINARY_DIR@ \ - @PROJECT_SOURCE_DIR@/H \ - @PROJECT_SOURCE_DIR@/H/generated \ - @PROJECT_SOURCE_DIR@/include \ - @PROJECT_SOURCE_DIR@/os \ - @PROJECT_SOURCE_DIR@/OPTYap \ + @PROJECT_SOURCE_DIR@/H \ + @PROJECT_SOURCE_DIR@/H/generated \ + @PROJECT_SOURCE_DIR@/include \ + @PROJECT_SOURCE_DIR@/os \ + @PROJECT_SOURCE_DIR@/OPTYap # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the @@ -2066,7 +2109,25 @@ 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 = +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;" \ + USES_REGS:="" \ + USES_REGS1:="void" \ + PASS_REGS:="" \ + PASS_REGS1:="" \ + Yap_InitCPred(Name,Arity,CF,Flags):="/// @cpred Name Arity CF" \ + 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 @@ -2096,7 +2157,7 @@ SKIP_FUNCTION_MACROS = YES # a tag file without this location is as follows: # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" file. +# TAGFILES = file1=loc1 "file2 = loc2" ... # where loc1 and loc2 can be relative or absolute paths or URLs. See the # section "Linking to external documentation" for more information about the use # of tag files. @@ -2223,7 +2284,7 @@ DOT_FONTPATH = # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. -CLASS_GRAPH = YES +CLASS_GRAPH = NO # If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a # graph for each documented class showing the direct and indirect implementation @@ -2277,16 +2338,16 @@ TEMPLATE_RELATIONS = NO # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. -INCLUDE_GRAPH = YES +INCLUDE_GRAPH = NO - # If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are +# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are # set to YES then doxygen will generate a graph for each documented file showing # the direct and indirect include dependencies of the file with other documented # files. # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. -INCLUDED_BY_GRAPH = YES +INCLUDED_BY_GRAPH = NO # If the CALL_GRAPH tag is set to YES then doxygen will generate a call # dependency graph for every global function or class method. @@ -2388,6 +2449,11 @@ DIAFILE_DIRS = PLANTUML_JAR_PATH = +# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a +# configuration file for plantuml. + +PLANTUML_CFG_FILE = + # When using plantuml, the specified paths are searched for files specified by # the !include statement in a plantuml block. diff --git a/docs/ERRS b/docs/ERRS deleted file mode 100644 index 2849c71ec..000000000 --- a/docs/ERRS +++ /dev/null @@ -1,2 +0,0 @@ -make[1]: *** No rule to make target `docs/CMakeFiles/doc.dir/rule'. Stop. -make: *** [docs/CMakeFiles/doc.dir/rule] Error 2 diff --git a/docs/application.js b/docs/application.js deleted file mode 100644 index 8ac554a48..000000000 --- a/docs/application.js +++ /dev/null @@ -1,4 +0,0 @@ - -$(function () { - $('a').tooltip(); -}); \ No newline at end of file diff --git a/docs/bootstrap.min.css b/docs/bootstrap.min.css deleted file mode 100644 index c547283bb..000000000 --- a/docs/bootstrap.min.css +++ /dev/null @@ -1,7 +0,0 @@ -/*! - * Bootstrap v3.0.3 (http://getbootstrap.com) - * Copyright 2013 Twitter, Inc. - * Licensed under http://www.apache.org/licenses/LICENSE-2.0 - */ - -/*! normalize.css v2.1.3 | MIT License | git.io/normalize */article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,video{display:inline-block}audio:not([controls]){display:none;height:0}[hidden],template{display:none}html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}a{background:transparent}a:focus{outline:thin dotted}a:active,a:hover{outline:0}h1{margin:.67em 0;font-size:2em}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}hr{height:0;-moz-box-sizing:content-box;box-sizing:content-box}mark{color:#000;background:#ff0}code,kbd,pre,samp{font-family:monospace,serif;font-size:1em}pre{white-space:pre-wrap}q{quotes:"\201C" "\201D" "\2018" "\2019"}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:0}fieldset{padding:.35em .625em .75em;margin:0 2px;border:1px solid #c0c0c0}legend{padding:0;border:0}button,input,select,textarea{margin:0;font-family:inherit;font-size:100%}button,input{line-height:normal}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;-webkit-appearance:button}button[disabled],html input[disabled]{cursor:default}input[type="checkbox"],input[type="radio"]{padding:0;box-sizing:border-box}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}textarea{overflow:auto;vertical-align:top}table{border-collapse:collapse;border-spacing:0}@media print{*{color:#000!important;text-shadow:none!important;background:transparent!important;box-shadow:none!important}a,a:visited{text-decoration:underline}a[href]:after{content:" (" attr(href) ")"}abbr[title]:after{content:" (" attr(title) ")"}a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100%!important}@page{margin:2cm .5cm}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}select{background:#fff!important}.navbar{display:none}.table td,.table th{background-color:#fff!important}.btn>.caret,.dropup>.btn>.caret{border-top-color:#000!important}.label{border:1px solid #000}.table{border-collapse:collapse!important}.table-bordered th,.table-bordered td{border:1px solid #ddd!important}}*,*:before,*:after{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}html{font-size:62.5%;-webkit-tap-highlight-color:rgba(0,0,0,0)}body{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;line-height:1.428571429;color:#333;background-color:#fff}input,button,select,textarea{font-family:inherit;font-size:inherit;line-height:inherit}a{color:#428bca;text-decoration:none}a:hover,a:focus{color:#2a6496;text-decoration:underline}a:focus{outline:thin dotted;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}img{vertical-align:middle}.img-responsive{display:block;height:auto;max-width:100%}.img-rounded{border-radius:6px}.img-thumbnail{display:inline-block;height:auto;max-width:100%;padding:4px;line-height:1.428571429;background-color:#fff;border:1px solid #ddd;border-radius:4px;-webkit-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.img-circle{border-radius:50%}hr{margin-top:20px;margin-bottom:20px;border:0;border-top:1px solid #eee}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}h1,h2,h3,h4,h5,h6,.h1,.h2,.h3,.h4,.h5,.h6{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-weight:500;line-height:1.1;color:inherit}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small,.h1 small,.h2 small,.h3 small,.h4 small,.h5 small,.h6 small,h1 .small,h2 .small,h3 .small,h4 .small,h5 .small,h6 .small,.h1 .small,.h2 .small,.h3 .small,.h4 .small,.h5 .small,.h6 .small{font-weight:normal;line-height:1;color:#999}h1,h2,h3{margin-top:20px;margin-bottom:10px}h1 small,h2 small,h3 small,h1 .small,h2 .small,h3 .small{font-size:65%}h4,h5,h6{margin-top:10px;margin-bottom:10px}h4 small,h5 small,h6 small,h4 .small,h5 .small,h6 .small{font-size:75%}h1,.h1{font-size:36px}h2,.h2{font-size:30px}h3,.h3{font-size:24px}h4,.h4{font-size:18px}h5,.h5{font-size:14px}h6,.h6{font-size:12px}p{margin:0 0 10px}.lead{margin-bottom:20px;font-size:16px;font-weight:200;line-height:1.4}@media(min-width:768px){.lead{font-size:21px}}small,.small{font-size:85%}cite{font-style:normal}.text-muted{color:#999}.text-primary{color:#428bca}.text-primary:hover{color:#3071a9}.text-warning{color:#8a6d3b}.text-warning:hover{color:#66512c}.text-danger{color:#a94442}.text-danger:hover{color:#843534}.text-success{color:#3c763d}.text-success:hover{color:#2b542c}.text-info{color:#31708f}.text-info:hover{color:#245269}.text-left{text-align:left}.text-right{text-align:right}.text-center{text-align:center}.page-header{padding-bottom:9px;margin:40px 0 20px;border-bottom:1px solid #eee}ul,ol{margin-top:0;margin-bottom:10px}ul ul,ol ul,ul ol,ol ol{margin-bottom:0}.list-unstyled{padding-left:0;list-style:none}.list-inline{padding-left:0;list-style:none}.list-inline>li{display:inline-block;padding-right:5px;padding-left:5px}.list-inline>li:first-child{padding-left:0}dl{margin-top:0;margin-bottom:20px}dt,dd{line-height:1.428571429}dt{font-weight:bold}dd{margin-left:0}@media(min-width:768px){.dl-horizontal dt{float:left;width:160px;overflow:hidden;clear:left;text-align:right;text-overflow:ellipsis;white-space:nowrap}.dl-horizontal dd{margin-left:180px}.dl-horizontal dd:before,.dl-horizontal dd:after{display:table;content:" "}.dl-horizontal dd:after{clear:both}.dl-horizontal dd:before,.dl-horizontal dd:after{display:table;content:" "}.dl-horizontal dd:after{clear:both}}abbr[title],abbr[data-original-title]{cursor:help;border-bottom:1px dotted #999}.initialism{font-size:90%;text-transform:uppercase}blockquote{padding:10px 20px;margin:0 0 20px;border-left:5px solid #eee}blockquote p{font-size:17.5px;font-weight:300;line-height:1.25}blockquote p:last-child{margin-bottom:0}blockquote small,blockquote .small{display:block;line-height:1.428571429;color:#999}blockquote small:before,blockquote .small:before{content:'\2014 \00A0'}blockquote.pull-right{padding-right:15px;padding-left:0;border-right:5px solid #eee;border-left:0}blockquote.pull-right p,blockquote.pull-right small,blockquote.pull-right .small{text-align:right}blockquote.pull-right small:before,blockquote.pull-right .small:before{content:''}blockquote.pull-right small:after,blockquote.pull-right .small:after{content:'\00A0 \2014'}blockquote:before,blockquote:after{content:""}address{margin-bottom:20px;font-style:normal;line-height:1.428571429}code,kbd,pre,samp{font-family:Menlo,Monaco,Consolas,"Courier New",monospace}code{padding:2px 4px;font-size:90%;color:#c7254e;white-space:nowrap;background-color:#f9f2f4;border-radius:4px}pre{display:block;padding:9.5px;margin:0 0 10px;font-size:13px;line-height:1.428571429;color:#333;word-break:break-all;word-wrap:break-word;background-color:#f5f5f5;border:1px solid #ccc;border-radius:4px}pre code{padding:0;font-size:inherit;color:inherit;white-space:pre-wrap;background-color:transparent;border-radius:0}.pre-scrollable{max-height:340px;overflow-y:scroll}.container{padding-right:15px;padding-left:15px;margin-right:auto;margin-left:auto}.container:before,.container:after{display:table;content:" "}.container:after{clear:both}.container:before,.container:after{display:table;content:" "}.container:after{clear:both}@media(min-width:768px){.container{width:750px}}@media(min-width:992px){.container{width:970px}}@media(min-width:1200px){.container{width:1170px}}.row{margin-right:-15px;margin-left:-15px}.row:before,.row:after{display:table;content:" "}.row:after{clear:both}.row:before,.row:after{display:table;content:" "}.row:after{clear:both}.col-xs-1,.col-sm-1,.col-md-1,.col-lg-1,.col-xs-2,.col-sm-2,.col-md-2,.col-lg-2,.col-xs-3,.col-sm-3,.col-md-3,.col-lg-3,.col-xs-4,.col-sm-4,.col-md-4,.col-lg-4,.col-xs-5,.col-sm-5,.col-md-5,.col-lg-5,.col-xs-6,.col-sm-6,.col-md-6,.col-lg-6,.col-xs-7,.col-sm-7,.col-md-7,.col-lg-7,.col-xs-8,.col-sm-8,.col-md-8,.col-lg-8,.col-xs-9,.col-sm-9,.col-md-9,.col-lg-9,.col-xs-10,.col-sm-10,.col-md-10,.col-lg-10,.col-xs-11,.col-sm-11,.col-md-11,.col-lg-11,.col-xs-12,.col-sm-12,.col-md-12,.col-lg-12{position:relative;min-height:1px;padding-right:15px;padding-left:15px}.col-xs-1,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9,.col-xs-10,.col-xs-11,.col-xs-12{float:left}.col-xs-12{width:100%}.col-xs-11{width:91.66666666666666%}.col-xs-10{width:83.33333333333334%}.col-xs-9{width:75%}.col-xs-8{width:66.66666666666666%}.col-xs-7{width:58.333333333333336%}.col-xs-6{width:50%}.col-xs-5{width:41.66666666666667%}.col-xs-4{width:33.33333333333333%}.col-xs-3{width:25%}.col-xs-2{width:16.666666666666664%}.col-xs-1{width:8.333333333333332%}.col-xs-pull-12{right:100%}.col-xs-pull-11{right:91.66666666666666%}.col-xs-pull-10{right:83.33333333333334%}.col-xs-pull-9{right:75%}.col-xs-pull-8{right:66.66666666666666%}.col-xs-pull-7{right:58.333333333333336%}.col-xs-pull-6{right:50%}.col-xs-pull-5{right:41.66666666666667%}.col-xs-pull-4{right:33.33333333333333%}.col-xs-pull-3{right:25%}.col-xs-pull-2{right:16.666666666666664%}.col-xs-pull-1{right:8.333333333333332%}.col-xs-pull-0{right:0}.col-xs-push-12{left:100%}.col-xs-push-11{left:91.66666666666666%}.col-xs-push-10{left:83.33333333333334%}.col-xs-push-9{left:75%}.col-xs-push-8{left:66.66666666666666%}.col-xs-push-7{left:58.333333333333336%}.col-xs-push-6{left:50%}.col-xs-push-5{left:41.66666666666667%}.col-xs-push-4{left:33.33333333333333%}.col-xs-push-3{left:25%}.col-xs-push-2{left:16.666666666666664%}.col-xs-push-1{left:8.333333333333332%}.col-xs-push-0{left:0}.col-xs-offset-12{margin-left:100%}.col-xs-offset-11{margin-left:91.66666666666666%}.col-xs-offset-10{margin-left:83.33333333333334%}.col-xs-offset-9{margin-left:75%}.col-xs-offset-8{margin-left:66.66666666666666%}.col-xs-offset-7{margin-left:58.333333333333336%}.col-xs-offset-6{margin-left:50%}.col-xs-offset-5{margin-left:41.66666666666667%}.col-xs-offset-4{margin-left:33.33333333333333%}.col-xs-offset-3{margin-left:25%}.col-xs-offset-2{margin-left:16.666666666666664%}.col-xs-offset-1{margin-left:8.333333333333332%}.col-xs-offset-0{margin-left:0}@media(min-width:768px){.col-sm-1,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9,.col-sm-10,.col-sm-11,.col-sm-12{float:left}.col-sm-12{width:100%}.col-sm-11{width:91.66666666666666%}.col-sm-10{width:83.33333333333334%}.col-sm-9{width:75%}.col-sm-8{width:66.66666666666666%}.col-sm-7{width:58.333333333333336%}.col-sm-6{width:50%}.col-sm-5{width:41.66666666666667%}.col-sm-4{width:33.33333333333333%}.col-sm-3{width:25%}.col-sm-2{width:16.666666666666664%}.col-sm-1{width:8.333333333333332%}.col-sm-pull-12{right:100%}.col-sm-pull-11{right:91.66666666666666%}.col-sm-pull-10{right:83.33333333333334%}.col-sm-pull-9{right:75%}.col-sm-pull-8{right:66.66666666666666%}.col-sm-pull-7{right:58.333333333333336%}.col-sm-pull-6{right:50%}.col-sm-pull-5{right:41.66666666666667%}.col-sm-pull-4{right:33.33333333333333%}.col-sm-pull-3{right:25%}.col-sm-pull-2{right:16.666666666666664%}.col-sm-pull-1{right:8.333333333333332%}.col-sm-pull-0{right:0}.col-sm-push-12{left:100%}.col-sm-push-11{left:91.66666666666666%}.col-sm-push-10{left:83.33333333333334%}.col-sm-push-9{left:75%}.col-sm-push-8{left:66.66666666666666%}.col-sm-push-7{left:58.333333333333336%}.col-sm-push-6{left:50%}.col-sm-push-5{left:41.66666666666667%}.col-sm-push-4{left:33.33333333333333%}.col-sm-push-3{left:25%}.col-sm-push-2{left:16.666666666666664%}.col-sm-push-1{left:8.333333333333332%}.col-sm-push-0{left:0}.col-sm-offset-12{margin-left:100%}.col-sm-offset-11{margin-left:91.66666666666666%}.col-sm-offset-10{margin-left:83.33333333333334%}.col-sm-offset-9{margin-left:75%}.col-sm-offset-8{margin-left:66.66666666666666%}.col-sm-offset-7{margin-left:58.333333333333336%}.col-sm-offset-6{margin-left:50%}.col-sm-offset-5{margin-left:41.66666666666667%}.col-sm-offset-4{margin-left:33.33333333333333%}.col-sm-offset-3{margin-left:25%}.col-sm-offset-2{margin-left:16.666666666666664%}.col-sm-offset-1{margin-left:8.333333333333332%}.col-sm-offset-0{margin-left:0}}@media(min-width:992px){.col-md-1,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9,.col-md-10,.col-md-11,.col-md-12{float:left}.col-md-12{width:100%}.col-md-11{width:91.66666666666666%}.col-md-10{width:83.33333333333334%}.col-md-9{width:75%}.col-md-8{width:66.66666666666666%}.col-md-7{width:58.333333333333336%}.col-md-6{width:50%}.col-md-5{width:41.66666666666667%}.col-md-4{width:33.33333333333333%}.col-md-3{width:25%}.col-md-2{width:16.666666666666664%}.col-md-1{width:8.333333333333332%}.col-md-pull-12{right:100%}.col-md-pull-11{right:91.66666666666666%}.col-md-pull-10{right:83.33333333333334%}.col-md-pull-9{right:75%}.col-md-pull-8{right:66.66666666666666%}.col-md-pull-7{right:58.333333333333336%}.col-md-pull-6{right:50%}.col-md-pull-5{right:41.66666666666667%}.col-md-pull-4{right:33.33333333333333%}.col-md-pull-3{right:25%}.col-md-pull-2{right:16.666666666666664%}.col-md-pull-1{right:8.333333333333332%}.col-md-pull-0{right:0}.col-md-push-12{left:100%}.col-md-push-11{left:91.66666666666666%}.col-md-push-10{left:83.33333333333334%}.col-md-push-9{left:75%}.col-md-push-8{left:66.66666666666666%}.col-md-push-7{left:58.333333333333336%}.col-md-push-6{left:50%}.col-md-push-5{left:41.66666666666667%}.col-md-push-4{left:33.33333333333333%}.col-md-push-3{left:25%}.col-md-push-2{left:16.666666666666664%}.col-md-push-1{left:8.333333333333332%}.col-md-push-0{left:0}.col-md-offset-12{margin-left:100%}.col-md-offset-11{margin-left:91.66666666666666%}.col-md-offset-10{margin-left:83.33333333333334%}.col-md-offset-9{margin-left:75%}.col-md-offset-8{margin-left:66.66666666666666%}.col-md-offset-7{margin-left:58.333333333333336%}.col-md-offset-6{margin-left:50%}.col-md-offset-5{margin-left:41.66666666666667%}.col-md-offset-4{margin-left:33.33333333333333%}.col-md-offset-3{margin-left:25%}.col-md-offset-2{margin-left:16.666666666666664%}.col-md-offset-1{margin-left:8.333333333333332%}.col-md-offset-0{margin-left:0}}@media(min-width:1200px){.col-lg-1,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9,.col-lg-10,.col-lg-11,.col-lg-12{float:left}.col-lg-12{width:100%}.col-lg-11{width:91.66666666666666%}.col-lg-10{width:83.33333333333334%}.col-lg-9{width:75%}.col-lg-8{width:66.66666666666666%}.col-lg-7{width:58.333333333333336%}.col-lg-6{width:50%}.col-lg-5{width:41.66666666666667%}.col-lg-4{width:33.33333333333333%}.col-lg-3{width:25%}.col-lg-2{width:16.666666666666664%}.col-lg-1{width:8.333333333333332%}.col-lg-pull-12{right:100%}.col-lg-pull-11{right:91.66666666666666%}.col-lg-pull-10{right:83.33333333333334%}.col-lg-pull-9{right:75%}.col-lg-pull-8{right:66.66666666666666%}.col-lg-pull-7{right:58.333333333333336%}.col-lg-pull-6{right:50%}.col-lg-pull-5{right:41.66666666666667%}.col-lg-pull-4{right:33.33333333333333%}.col-lg-pull-3{right:25%}.col-lg-pull-2{right:16.666666666666664%}.col-lg-pull-1{right:8.333333333333332%}.col-lg-pull-0{right:0}.col-lg-push-12{left:100%}.col-lg-push-11{left:91.66666666666666%}.col-lg-push-10{left:83.33333333333334%}.col-lg-push-9{left:75%}.col-lg-push-8{left:66.66666666666666%}.col-lg-push-7{left:58.333333333333336%}.col-lg-push-6{left:50%}.col-lg-push-5{left:41.66666666666667%}.col-lg-push-4{left:33.33333333333333%}.col-lg-push-3{left:25%}.col-lg-push-2{left:16.666666666666664%}.col-lg-push-1{left:8.333333333333332%}.col-lg-push-0{left:0}.col-lg-offset-12{margin-left:100%}.col-lg-offset-11{margin-left:91.66666666666666%}.col-lg-offset-10{margin-left:83.33333333333334%}.col-lg-offset-9{margin-left:75%}.col-lg-offset-8{margin-left:66.66666666666666%}.col-lg-offset-7{margin-left:58.333333333333336%}.col-lg-offset-6{margin-left:50%}.col-lg-offset-5{margin-left:41.66666666666667%}.col-lg-offset-4{margin-left:33.33333333333333%}.col-lg-offset-3{margin-left:25%}.col-lg-offset-2{margin-left:16.666666666666664%}.col-lg-offset-1{margin-left:8.333333333333332%}.col-lg-offset-0{margin-left:0}}table{max-width:100%;background-color:transparent}th{text-align:left}.table{width:100%;margin-bottom:20px}.table>thead>tr>th,.table>tbody>tr>th,.table>tfoot>tr>th,.table>thead>tr>td,.table>tbody>tr>td,.table>tfoot>tr>td{padding:8px;line-height:1.428571429;vertical-align:top;border-top:1px solid #ddd}.table>thead>tr>th{vertical-align:bottom;border-bottom:2px solid #ddd}.table>caption+thead>tr:first-child>th,.table>colgroup+thead>tr:first-child>th,.table>thead:first-child>tr:first-child>th,.table>caption+thead>tr:first-child>td,.table>colgroup+thead>tr:first-child>td,.table>thead:first-child>tr:first-child>td{border-top:0}.table>tbody+tbody{border-top:2px solid #ddd}.table .table{background-color:#fff}.table-condensed>thead>tr>th,.table-condensed>tbody>tr>th,.table-condensed>tfoot>tr>th,.table-condensed>thead>tr>td,.table-condensed>tbody>tr>td,.table-condensed>tfoot>tr>td{padding:5px}.table-bordered{border:1px solid #ddd}.table-bordered>thead>tr>th,.table-bordered>tbody>tr>th,.table-bordered>tfoot>tr>th,.table-bordered>thead>tr>td,.table-bordered>tbody>tr>td,.table-bordered>tfoot>tr>td{border:1px solid #ddd}.table-bordered>thead>tr>th,.table-bordered>thead>tr>td{border-bottom-width:2px}.table-striped>tbody>tr:nth-child(odd)>td,.table-striped>tbody>tr:nth-child(odd)>th{background-color:#f9f9f9}.table-hover>tbody>tr:hover>td,.table-hover>tbody>tr:hover>th{background-color:#f5f5f5}table col[class*="col-"]{position:static;display:table-column;float:none}table td[class*="col-"],table th[class*="col-"]{display:table-cell;float:none}.table>thead>tr>.active,.table>tbody>tr>.active,.table>tfoot>tr>.active,.table>thead>.active>td,.table>tbody>.active>td,.table>tfoot>.active>td,.table>thead>.active>th,.table>tbody>.active>th,.table>tfoot>.active>th{background-color:#f5f5f5}.table-hover>tbody>tr>.active:hover,.table-hover>tbody>.active:hover>td,.table-hover>tbody>.active:hover>th{background-color:#e8e8e8}.table>thead>tr>.success,.table>tbody>tr>.success,.table>tfoot>tr>.success,.table>thead>.success>td,.table>tbody>.success>td,.table>tfoot>.success>td,.table>thead>.success>th,.table>tbody>.success>th,.table>tfoot>.success>th{background-color:#dff0d8}.table-hover>tbody>tr>.success:hover,.table-hover>tbody>.success:hover>td,.table-hover>tbody>.success:hover>th{background-color:#d0e9c6}.table>thead>tr>.danger,.table>tbody>tr>.danger,.table>tfoot>tr>.danger,.table>thead>.danger>td,.table>tbody>.danger>td,.table>tfoot>.danger>td,.table>thead>.danger>th,.table>tbody>.danger>th,.table>tfoot>.danger>th{background-color:#f2dede}.table-hover>tbody>tr>.danger:hover,.table-hover>tbody>.danger:hover>td,.table-hover>tbody>.danger:hover>th{background-color:#ebcccc}.table>thead>tr>.warning,.table>tbody>tr>.warning,.table>tfoot>tr>.warning,.table>thead>.warning>td,.table>tbody>.warning>td,.table>tfoot>.warning>td,.table>thead>.warning>th,.table>tbody>.warning>th,.table>tfoot>.warning>th{background-color:#fcf8e3}.table-hover>tbody>tr>.warning:hover,.table-hover>tbody>.warning:hover>td,.table-hover>tbody>.warning:hover>th{background-color:#faf2cc}@media(max-width:767px){.table-responsive{width:100%;margin-bottom:15px;overflow-x:scroll;overflow-y:hidden;border:1px solid #ddd;-ms-overflow-style:-ms-autohiding-scrollbar;-webkit-overflow-scrolling:touch}.table-responsive>.table{margin-bottom:0}.table-responsive>.table>thead>tr>th,.table-responsive>.table>tbody>tr>th,.table-responsive>.table>tfoot>tr>th,.table-responsive>.table>thead>tr>td,.table-responsive>.table>tbody>tr>td,.table-responsive>.table>tfoot>tr>td{white-space:nowrap}.table-responsive>.table-bordered{border:0}.table-responsive>.table-bordered>thead>tr>th:first-child,.table-responsive>.table-bordered>tbody>tr>th:first-child,.table-responsive>.table-bordered>tfoot>tr>th:first-child,.table-responsive>.table-bordered>thead>tr>td:first-child,.table-responsive>.table-bordered>tbody>tr>td:first-child,.table-responsive>.table-bordered>tfoot>tr>td:first-child{border-left:0}.table-responsive>.table-bordered>thead>tr>th:last-child,.table-responsive>.table-bordered>tbody>tr>th:last-child,.table-responsive>.table-bordered>tfoot>tr>th:last-child,.table-responsive>.table-bordered>thead>tr>td:last-child,.table-responsive>.table-bordered>tbody>tr>td:last-child,.table-responsive>.table-bordered>tfoot>tr>td:last-child{border-right:0}.table-responsive>.table-bordered>tbody>tr:last-child>th,.table-responsive>.table-bordered>tfoot>tr:last-child>th,.table-responsive>.table-bordered>tbody>tr:last-child>td,.table-responsive>.table-bordered>tfoot>tr:last-child>td{border-bottom:0}}fieldset{padding:0;margin:0;border:0}legend{display:block;width:100%;padding:0;margin-bottom:20px;font-size:21px;line-height:inherit;color:#333;border:0;border-bottom:1px solid #e5e5e5}label{display:inline-block;margin-bottom:5px;font-weight:bold}input[type="search"]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}input[type="radio"],input[type="checkbox"]{margin:4px 0 0;margin-top:1px \9;line-height:normal}input[type="file"]{display:block}select[multiple],select[size]{height:auto}select optgroup{font-family:inherit;font-size:inherit;font-style:inherit}input[type="file"]:focus,input[type="radio"]:focus,input[type="checkbox"]:focus{outline:thin dotted;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}input[type="number"]::-webkit-outer-spin-button,input[type="number"]::-webkit-inner-spin-button{height:auto}output{display:block;padding-top:7px;font-size:14px;line-height:1.428571429;color:#555;vertical-align:middle}.form-control{display:block;width:100%;height:34px;padding:6px 12px;font-size:14px;line-height:1.428571429;color:#555;vertical-align:middle;background-color:#fff;background-image:none;border:1px solid #ccc;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-webkit-transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s}.form-control:focus{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(102,175,233,0.6);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(102,175,233,0.6)}.form-control:-moz-placeholder{color:#999}.form-control::-moz-placeholder{color:#999;opacity:1}.form-control:-ms-input-placeholder{color:#999}.form-control::-webkit-input-placeholder{color:#999}.form-control[disabled],.form-control[readonly],fieldset[disabled] .form-control{cursor:not-allowed;background-color:#eee}textarea.form-control{height:auto}.form-group{margin-bottom:15px}.radio,.checkbox{display:block;min-height:20px;padding-left:20px;margin-top:10px;margin-bottom:10px;vertical-align:middle}.radio label,.checkbox label{display:inline;margin-bottom:0;font-weight:normal;cursor:pointer}.radio input[type="radio"],.radio-inline input[type="radio"],.checkbox input[type="checkbox"],.checkbox-inline input[type="checkbox"]{float:left;margin-left:-20px}.radio+.radio,.checkbox+.checkbox{margin-top:-5px}.radio-inline,.checkbox-inline{display:inline-block;padding-left:20px;margin-bottom:0;font-weight:normal;vertical-align:middle;cursor:pointer}.radio-inline+.radio-inline,.checkbox-inline+.checkbox-inline{margin-top:0;margin-left:10px}input[type="radio"][disabled],input[type="checkbox"][disabled],.radio[disabled],.radio-inline[disabled],.checkbox[disabled],.checkbox-inline[disabled],fieldset[disabled] input[type="radio"],fieldset[disabled] input[type="checkbox"],fieldset[disabled] .radio,fieldset[disabled] .radio-inline,fieldset[disabled] .checkbox,fieldset[disabled] .checkbox-inline{cursor:not-allowed}.input-sm{height:30px;padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}select.input-sm{height:30px;line-height:30px}textarea.input-sm{height:auto}.input-lg{height:46px;padding:10px 16px;font-size:18px;line-height:1.33;border-radius:6px}select.input-lg{height:46px;line-height:46px}textarea.input-lg{height:auto}.has-warning .help-block,.has-warning .control-label,.has-warning .radio,.has-warning .checkbox,.has-warning .radio-inline,.has-warning .checkbox-inline{color:#8a6d3b}.has-warning .form-control{border-color:#8a6d3b;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.has-warning .form-control:focus{border-color:#66512c;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #c0a16b;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #c0a16b}.has-warning .input-group-addon{color:#8a6d3b;background-color:#fcf8e3;border-color:#8a6d3b}.has-error .help-block,.has-error .control-label,.has-error .radio,.has-error .checkbox,.has-error .radio-inline,.has-error .checkbox-inline{color:#a94442}.has-error .form-control{border-color:#a94442;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.has-error .form-control:focus{border-color:#843534;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #ce8483;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #ce8483}.has-error .input-group-addon{color:#a94442;background-color:#f2dede;border-color:#a94442}.has-success .help-block,.has-success .control-label,.has-success .radio,.has-success .checkbox,.has-success .radio-inline,.has-success .checkbox-inline{color:#3c763d}.has-success .form-control{border-color:#3c763d;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.has-success .form-control:focus{border-color:#2b542c;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #67b168;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #67b168}.has-success .input-group-addon{color:#3c763d;background-color:#dff0d8;border-color:#3c763d}.form-control-static{margin-bottom:0}.help-block{display:block;margin-top:5px;margin-bottom:10px;color:#737373}@media(min-width:768px){.form-inline .form-group{display:inline-block;margin-bottom:0;vertical-align:middle}.form-inline .form-control{display:inline-block}.form-inline select.form-control{width:auto}.form-inline .radio,.form-inline .checkbox{display:inline-block;padding-left:0;margin-top:0;margin-bottom:0}.form-inline .radio input[type="radio"],.form-inline .checkbox input[type="checkbox"]{float:none;margin-left:0}}.form-horizontal .control-label,.form-horizontal .radio,.form-horizontal .checkbox,.form-horizontal .radio-inline,.form-horizontal .checkbox-inline{padding-top:7px;margin-top:0;margin-bottom:0}.form-horizontal .radio,.form-horizontal .checkbox{min-height:27px}.form-horizontal .form-group{margin-right:-15px;margin-left:-15px}.form-horizontal .form-group:before,.form-horizontal .form-group:after{display:table;content:" "}.form-horizontal .form-group:after{clear:both}.form-horizontal .form-group:before,.form-horizontal .form-group:after{display:table;content:" "}.form-horizontal .form-group:after{clear:both}.form-horizontal .form-control-static{padding-top:7px}@media(min-width:768px){.form-horizontal .control-label{text-align:right}}.btn{display:inline-block;padding:6px 12px;margin-bottom:0;font-size:14px;font-weight:normal;line-height:1.428571429;text-align:center;white-space:nowrap;vertical-align:middle;cursor:pointer;background-image:none;border:1px solid transparent;border-radius:4px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}.btn:focus{outline:thin dotted;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn:hover,.btn:focus{color:#333;text-decoration:none}.btn:active,.btn.active{background-image:none;outline:0;-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,0.125);box-shadow:inset 0 3px 5px rgba(0,0,0,0.125)}.btn.disabled,.btn[disabled],fieldset[disabled] .btn{pointer-events:none;cursor:not-allowed;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;box-shadow:none}.btn-default{color:#333;background-color:#fff;border-color:#ccc}.btn-default:hover,.btn-default:focus,.btn-default:active,.btn-default.active,.open .dropdown-toggle.btn-default{color:#333;background-color:#ebebeb;border-color:#adadad}.btn-default:active,.btn-default.active,.open .dropdown-toggle.btn-default{background-image:none}.btn-default.disabled,.btn-default[disabled],fieldset[disabled] .btn-default,.btn-default.disabled:hover,.btn-default[disabled]:hover,fieldset[disabled] .btn-default:hover,.btn-default.disabled:focus,.btn-default[disabled]:focus,fieldset[disabled] .btn-default:focus,.btn-default.disabled:active,.btn-default[disabled]:active,fieldset[disabled] .btn-default:active,.btn-default.disabled.active,.btn-default[disabled].active,fieldset[disabled] .btn-default.active{background-color:#fff;border-color:#ccc}.btn-default .badge{color:#fff;background-color:#fff}.btn-primary{color:#fff;background-color:#428bca;border-color:#357ebd}.btn-primary:hover,.btn-primary:focus,.btn-primary:active,.btn-primary.active,.open .dropdown-toggle.btn-primary{color:#fff;background-color:#3276b1;border-color:#285e8e}.btn-primary:active,.btn-primary.active,.open .dropdown-toggle.btn-primary{background-image:none}.btn-primary.disabled,.btn-primary[disabled],fieldset[disabled] .btn-primary,.btn-primary.disabled:hover,.btn-primary[disabled]:hover,fieldset[disabled] .btn-primary:hover,.btn-primary.disabled:focus,.btn-primary[disabled]:focus,fieldset[disabled] .btn-primary:focus,.btn-primary.disabled:active,.btn-primary[disabled]:active,fieldset[disabled] .btn-primary:active,.btn-primary.disabled.active,.btn-primary[disabled].active,fieldset[disabled] .btn-primary.active{background-color:#428bca;border-color:#357ebd}.btn-primary .badge{color:#428bca;background-color:#fff}.btn-warning{color:#fff;background-color:#f0ad4e;border-color:#eea236}.btn-warning:hover,.btn-warning:focus,.btn-warning:active,.btn-warning.active,.open .dropdown-toggle.btn-warning{color:#fff;background-color:#ed9c28;border-color:#d58512}.btn-warning:active,.btn-warning.active,.open .dropdown-toggle.btn-warning{background-image:none}.btn-warning.disabled,.btn-warning[disabled],fieldset[disabled] .btn-warning,.btn-warning.disabled:hover,.btn-warning[disabled]:hover,fieldset[disabled] .btn-warning:hover,.btn-warning.disabled:focus,.btn-warning[disabled]:focus,fieldset[disabled] .btn-warning:focus,.btn-warning.disabled:active,.btn-warning[disabled]:active,fieldset[disabled] .btn-warning:active,.btn-warning.disabled.active,.btn-warning[disabled].active,fieldset[disabled] .btn-warning.active{background-color:#f0ad4e;border-color:#eea236}.btn-warning .badge{color:#f0ad4e;background-color:#fff}.btn-danger{color:#fff;background-color:#d9534f;border-color:#d43f3a}.btn-danger:hover,.btn-danger:focus,.btn-danger:active,.btn-danger.active,.open .dropdown-toggle.btn-danger{color:#fff;background-color:#d2322d;border-color:#ac2925}.btn-danger:active,.btn-danger.active,.open .dropdown-toggle.btn-danger{background-image:none}.btn-danger.disabled,.btn-danger[disabled],fieldset[disabled] .btn-danger,.btn-danger.disabled:hover,.btn-danger[disabled]:hover,fieldset[disabled] .btn-danger:hover,.btn-danger.disabled:focus,.btn-danger[disabled]:focus,fieldset[disabled] .btn-danger:focus,.btn-danger.disabled:active,.btn-danger[disabled]:active,fieldset[disabled] .btn-danger:active,.btn-danger.disabled.active,.btn-danger[disabled].active,fieldset[disabled] .btn-danger.active{background-color:#d9534f;border-color:#d43f3a}.btn-danger .badge{color:#d9534f;background-color:#fff}.btn-success{color:#fff;background-color:#5cb85c;border-color:#4cae4c}.btn-success:hover,.btn-success:focus,.btn-success:active,.btn-success.active,.open .dropdown-toggle.btn-success{color:#fff;background-color:#47a447;border-color:#398439}.btn-success:active,.btn-success.active,.open .dropdown-toggle.btn-success{background-image:none}.btn-success.disabled,.btn-success[disabled],fieldset[disabled] .btn-success,.btn-success.disabled:hover,.btn-success[disabled]:hover,fieldset[disabled] .btn-success:hover,.btn-success.disabled:focus,.btn-success[disabled]:focus,fieldset[disabled] .btn-success:focus,.btn-success.disabled:active,.btn-success[disabled]:active,fieldset[disabled] .btn-success:active,.btn-success.disabled.active,.btn-success[disabled].active,fieldset[disabled] .btn-success.active{background-color:#5cb85c;border-color:#4cae4c}.btn-success .badge{color:#5cb85c;background-color:#fff}.btn-info{color:#fff;background-color:#5bc0de;border-color:#46b8da}.btn-info:hover,.btn-info:focus,.btn-info:active,.btn-info.active,.open .dropdown-toggle.btn-info{color:#fff;background-color:#39b3d7;border-color:#269abc}.btn-info:active,.btn-info.active,.open .dropdown-toggle.btn-info{background-image:none}.btn-info.disabled,.btn-info[disabled],fieldset[disabled] .btn-info,.btn-info.disabled:hover,.btn-info[disabled]:hover,fieldset[disabled] .btn-info:hover,.btn-info.disabled:focus,.btn-info[disabled]:focus,fieldset[disabled] .btn-info:focus,.btn-info.disabled:active,.btn-info[disabled]:active,fieldset[disabled] .btn-info:active,.btn-info.disabled.active,.btn-info[disabled].active,fieldset[disabled] .btn-info.active{background-color:#5bc0de;border-color:#46b8da}.btn-info .badge{color:#5bc0de;background-color:#fff}.btn-link{font-weight:normal;color:#428bca;cursor:pointer;border-radius:0}.btn-link,.btn-link:active,.btn-link[disabled],fieldset[disabled] .btn-link{background-color:transparent;-webkit-box-shadow:none;box-shadow:none}.btn-link,.btn-link:hover,.btn-link:focus,.btn-link:active{border-color:transparent}.btn-link:hover,.btn-link:focus{color:#2a6496;text-decoration:underline;background-color:transparent}.btn-link[disabled]:hover,fieldset[disabled] .btn-link:hover,.btn-link[disabled]:focus,fieldset[disabled] .btn-link:focus{color:#999;text-decoration:none}.btn-lg{padding:10px 16px;font-size:18px;line-height:1.33;border-radius:6px}.btn-sm{padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}.btn-xs{padding:1px 5px;font-size:12px;line-height:1.5;border-radius:3px}.btn-block{display:block;width:100%;padding-right:0;padding-left:0}.btn-block+.btn-block{margin-top:5px}input[type="submit"].btn-block,input[type="reset"].btn-block,input[type="button"].btn-block{width:100%}.fade{opacity:0;-webkit-transition:opacity .15s linear;transition:opacity .15s linear}.fade.in{opacity:1}.collapse{display:none}.collapse.in{display:block}.collapsing{position:relative;height:0;overflow:hidden;-webkit-transition:height .35s ease;transition:height .35s ease}@font-face{font-family:'Glyphicons Halflings';src:url('../fonts/glyphicons-halflings-regular.eot');src:url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'),url('../fonts/glyphicons-halflings-regular.woff') format('woff'),url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'),url('../fonts/glyphicons-halflings-regular.svg#glyphicons-halflingsregular') format('svg')}.glyphicon{position:relative;top:1px;display:inline-block;font-family:'Glyphicons Halflings';-webkit-font-smoothing:antialiased;font-style:normal;font-weight:normal;line-height:1;-moz-osx-font-smoothing:grayscale}.glyphicon:empty{width:1em}.glyphicon-asterisk:before{content:"\2a"}.glyphicon-plus:before{content:"\2b"}.glyphicon-euro:before{content:"\20ac"}.glyphicon-minus:before{content:"\2212"}.glyphicon-cloud:before{content:"\2601"}.glyphicon-envelope:before{content:"\2709"}.glyphicon-pencil:before{content:"\270f"}.glyphicon-glass:before{content:"\e001"}.glyphicon-music:before{content:"\e002"}.glyphicon-search:before{content:"\e003"}.glyphicon-heart:before{content:"\e005"}.glyphicon-star:before{content:"\e006"}.glyphicon-star-empty:before{content:"\e007"}.glyphicon-user:before{content:"\e008"}.glyphicon-film:before{content:"\e009"}.glyphicon-th-large:before{content:"\e010"}.glyphicon-th:before{content:"\e011"}.glyphicon-th-list:before{content:"\e012"}.glyphicon-ok:before{content:"\e013"}.glyphicon-remove:before{content:"\e014"}.glyphicon-zoom-in:before{content:"\e015"}.glyphicon-zoom-out:before{content:"\e016"}.glyphicon-off:before{content:"\e017"}.glyphicon-signal:before{content:"\e018"}.glyphicon-cog:before{content:"\e019"}.glyphicon-trash:before{content:"\e020"}.glyphicon-home:before{content:"\e021"}.glyphicon-file:before{content:"\e022"}.glyphicon-time:before{content:"\e023"}.glyphicon-road:before{content:"\e024"}.glyphicon-download-alt:before{content:"\e025"}.glyphicon-download:before{content:"\e026"}.glyphicon-upload:before{content:"\e027"}.glyphicon-inbox:before{content:"\e028"}.glyphicon-play-circle:before{content:"\e029"}.glyphicon-repeat:before{content:"\e030"}.glyphicon-refresh:before{content:"\e031"}.glyphicon-list-alt:before{content:"\e032"}.glyphicon-lock:before{content:"\e033"}.glyphicon-flag:before{content:"\e034"}.glyphicon-headphones:before{content:"\e035"}.glyphicon-volume-off:before{content:"\e036"}.glyphicon-volume-down:before{content:"\e037"}.glyphicon-volume-up:before{content:"\e038"}.glyphicon-qrcode:before{content:"\e039"}.glyphicon-barcode:before{content:"\e040"}.glyphicon-tag:before{content:"\e041"}.glyphicon-tags:before{content:"\e042"}.glyphicon-book:before{content:"\e043"}.glyphicon-bookmark:before{content:"\e044"}.glyphicon-print:before{content:"\e045"}.glyphicon-camera:before{content:"\e046"}.glyphicon-font:before{content:"\e047"}.glyphicon-bold:before{content:"\e048"}.glyphicon-italic:before{content:"\e049"}.glyphicon-text-height:before{content:"\e050"}.glyphicon-text-width:before{content:"\e051"}.glyphicon-align-left:before{content:"\e052"}.glyphicon-align-center:before{content:"\e053"}.glyphicon-align-right:before{content:"\e054"}.glyphicon-align-justify:before{content:"\e055"}.glyphicon-list:before{content:"\e056"}.glyphicon-indent-left:before{content:"\e057"}.glyphicon-indent-right:before{content:"\e058"}.glyphicon-facetime-video:before{content:"\e059"}.glyphicon-picture:before{content:"\e060"}.glyphicon-map-marker:before{content:"\e062"}.glyphicon-adjust:before{content:"\e063"}.glyphicon-tint:before{content:"\e064"}.glyphicon-edit:before{content:"\e065"}.glyphicon-share:before{content:"\e066"}.glyphicon-check:before{content:"\e067"}.glyphicon-move:before{content:"\e068"}.glyphicon-step-backward:before{content:"\e069"}.glyphicon-fast-backward:before{content:"\e070"}.glyphicon-backward:before{content:"\e071"}.glyphicon-play:before{content:"\e072"}.glyphicon-pause:before{content:"\e073"}.glyphicon-stop:before{content:"\e074"}.glyphicon-forward:before{content:"\e075"}.glyphicon-fast-forward:before{content:"\e076"}.glyphicon-step-forward:before{content:"\e077"}.glyphicon-eject:before{content:"\e078"}.glyphicon-chevron-left:before{content:"\e079"}.glyphicon-chevron-right:before{content:"\e080"}.glyphicon-plus-sign:before{content:"\e081"}.glyphicon-minus-sign:before{content:"\e082"}.glyphicon-remove-sign:before{content:"\e083"}.glyphicon-ok-sign:before{content:"\e084"}.glyphicon-question-sign:before{content:"\e085"}.glyphicon-info-sign:before{content:"\e086"}.glyphicon-screenshot:before{content:"\e087"}.glyphicon-remove-circle:before{content:"\e088"}.glyphicon-ok-circle:before{content:"\e089"}.glyphicon-ban-circle:before{content:"\e090"}.glyphicon-arrow-left:before{content:"\e091"}.glyphicon-arrow-right:before{content:"\e092"}.glyphicon-arrow-up:before{content:"\e093"}.glyphicon-arrow-down:before{content:"\e094"}.glyphicon-share-alt:before{content:"\e095"}.glyphicon-resize-full:before{content:"\e096"}.glyphicon-resize-small:before{content:"\e097"}.glyphicon-exclamation-sign:before{content:"\e101"}.glyphicon-gift:before{content:"\e102"}.glyphicon-leaf:before{content:"\e103"}.glyphicon-fire:before{content:"\e104"}.glyphicon-eye-open:before{content:"\e105"}.glyphicon-eye-close:before{content:"\e106"}.glyphicon-warning-sign:before{content:"\e107"}.glyphicon-plane:before{content:"\e108"}.glyphicon-calendar:before{content:"\e109"}.glyphicon-random:before{content:"\e110"}.glyphicon-comment:before{content:"\e111"}.glyphicon-magnet:before{content:"\e112"}.glyphicon-chevron-up:before{content:"\e113"}.glyphicon-chevron-down:before{content:"\e114"}.glyphicon-retweet:before{content:"\e115"}.glyphicon-shopping-cart:before{content:"\e116"}.glyphicon-folder-close:before{content:"\e117"}.glyphicon-folder-open:before{content:"\e118"}.glyphicon-resize-vertical:before{content:"\e119"}.glyphicon-resize-horizontal:before{content:"\e120"}.glyphicon-hdd:before{content:"\e121"}.glyphicon-bullhorn:before{content:"\e122"}.glyphicon-bell:before{content:"\e123"}.glyphicon-certificate:before{content:"\e124"}.glyphicon-thumbs-up:before{content:"\e125"}.glyphicon-thumbs-down:before{content:"\e126"}.glyphicon-hand-right:before{content:"\e127"}.glyphicon-hand-left:before{content:"\e128"}.glyphicon-hand-up:before{content:"\e129"}.glyphicon-hand-down:before{content:"\e130"}.glyphicon-circle-arrow-right:before{content:"\e131"}.glyphicon-circle-arrow-left:before{content:"\e132"}.glyphicon-circle-arrow-up:before{content:"\e133"}.glyphicon-circle-arrow-down:before{content:"\e134"}.glyphicon-globe:before{content:"\e135"}.glyphicon-wrench:before{content:"\e136"}.glyphicon-tasks:before{content:"\e137"}.glyphicon-filter:before{content:"\e138"}.glyphicon-briefcase:before{content:"\e139"}.glyphicon-fullscreen:before{content:"\e140"}.glyphicon-dashboard:before{content:"\e141"}.glyphicon-paperclip:before{content:"\e142"}.glyphicon-heart-empty:before{content:"\e143"}.glyphicon-link:before{content:"\e144"}.glyphicon-phone:before{content:"\e145"}.glyphicon-pushpin:before{content:"\e146"}.glyphicon-usd:before{content:"\e148"}.glyphicon-gbp:before{content:"\e149"}.glyphicon-sort:before{content:"\e150"}.glyphicon-sort-by-alphabet:before{content:"\e151"}.glyphicon-sort-by-alphabet-alt:before{content:"\e152"}.glyphicon-sort-by-order:before{content:"\e153"}.glyphicon-sort-by-order-alt:before{content:"\e154"}.glyphicon-sort-by-attributes:before{content:"\e155"}.glyphicon-sort-by-attributes-alt:before{content:"\e156"}.glyphicon-unchecked:before{content:"\e157"}.glyphicon-expand:before{content:"\e158"}.glyphicon-collapse-down:before{content:"\e159"}.glyphicon-collapse-up:before{content:"\e160"}.glyphicon-log-in:before{content:"\e161"}.glyphicon-flash:before{content:"\e162"}.glyphicon-log-out:before{content:"\e163"}.glyphicon-new-window:before{content:"\e164"}.glyphicon-record:before{content:"\e165"}.glyphicon-save:before{content:"\e166"}.glyphicon-open:before{content:"\e167"}.glyphicon-saved:before{content:"\e168"}.glyphicon-import:before{content:"\e169"}.glyphicon-export:before{content:"\e170"}.glyphicon-send:before{content:"\e171"}.glyphicon-floppy-disk:before{content:"\e172"}.glyphicon-floppy-saved:before{content:"\e173"}.glyphicon-floppy-remove:before{content:"\e174"}.glyphicon-floppy-save:before{content:"\e175"}.glyphicon-floppy-open:before{content:"\e176"}.glyphicon-credit-card:before{content:"\e177"}.glyphicon-transfer:before{content:"\e178"}.glyphicon-cutlery:before{content:"\e179"}.glyphicon-header:before{content:"\e180"}.glyphicon-compressed:before{content:"\e181"}.glyphicon-earphone:before{content:"\e182"}.glyphicon-phone-alt:before{content:"\e183"}.glyphicon-tower:before{content:"\e184"}.glyphicon-stats:before{content:"\e185"}.glyphicon-sd-video:before{content:"\e186"}.glyphicon-hd-video:before{content:"\e187"}.glyphicon-subtitles:before{content:"\e188"}.glyphicon-sound-stereo:before{content:"\e189"}.glyphicon-sound-dolby:before{content:"\e190"}.glyphicon-sound-5-1:before{content:"\e191"}.glyphicon-sound-6-1:before{content:"\e192"}.glyphicon-sound-7-1:before{content:"\e193"}.glyphicon-copyright-mark:before{content:"\e194"}.glyphicon-registration-mark:before{content:"\e195"}.glyphicon-cloud-download:before{content:"\e197"}.glyphicon-cloud-upload:before{content:"\e198"}.glyphicon-tree-conifer:before{content:"\e199"}.glyphicon-tree-deciduous:before{content:"\e200"}.caret{display:inline-block;width:0;height:0;margin-left:2px;vertical-align:middle;border-top:4px solid;border-right:4px solid transparent;border-left:4px solid transparent}.dropdown{position:relative}.dropdown-toggle:focus{outline:0}.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:160px;padding:5px 0;margin:2px 0 0;font-size:14px;list-style:none;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.15);border-radius:4px;-webkit-box-shadow:0 6px 12px rgba(0,0,0,0.175);box-shadow:0 6px 12px rgba(0,0,0,0.175);background-clip:padding-box}.dropdown-menu.pull-right{right:0;left:auto}.dropdown-menu .divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5}.dropdown-menu>li>a{display:block;padding:3px 20px;clear:both;font-weight:normal;line-height:1.428571429;color:#333;white-space:nowrap}.dropdown-menu>li>a:hover,.dropdown-menu>li>a:focus{color:#262626;text-decoration:none;background-color:#f5f5f5}.dropdown-menu>.active>a,.dropdown-menu>.active>a:hover,.dropdown-menu>.active>a:focus{color:#fff;text-decoration:none;background-color:#428bca;outline:0}.dropdown-menu>.disabled>a,.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{color:#999}.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{text-decoration:none;cursor:not-allowed;background-color:transparent;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.open>.dropdown-menu{display:block}.open>a{outline:0}.dropdown-header{display:block;padding:3px 20px;font-size:12px;line-height:1.428571429;color:#999}.dropdown-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:990}.pull-right>.dropdown-menu{right:0;left:auto}.dropup .caret,.navbar-fixed-bottom .dropdown .caret{border-top:0;border-bottom:4px solid;content:""}.dropup .dropdown-menu,.navbar-fixed-bottom .dropdown .dropdown-menu{top:auto;bottom:100%;margin-bottom:1px}@media(min-width:768px){.navbar-right .dropdown-menu{right:0;left:auto}}.btn-group,.btn-group-vertical{position:relative;display:inline-block;vertical-align:middle}.btn-group>.btn,.btn-group-vertical>.btn{position:relative;float:left}.btn-group>.btn:hover,.btn-group-vertical>.btn:hover,.btn-group>.btn:focus,.btn-group-vertical>.btn:focus,.btn-group>.btn:active,.btn-group-vertical>.btn:active,.btn-group>.btn.active,.btn-group-vertical>.btn.active{z-index:2}.btn-group>.btn:focus,.btn-group-vertical>.btn:focus{outline:0}.btn-group .btn+.btn,.btn-group .btn+.btn-group,.btn-group .btn-group+.btn,.btn-group .btn-group+.btn-group{margin-left:-1px}.btn-toolbar:before,.btn-toolbar:after{display:table;content:" "}.btn-toolbar:after{clear:both}.btn-toolbar:before,.btn-toolbar:after{display:table;content:" "}.btn-toolbar:after{clear:both}.btn-toolbar .btn-group{float:left}.btn-toolbar>.btn+.btn,.btn-toolbar>.btn-group+.btn,.btn-toolbar>.btn+.btn-group,.btn-toolbar>.btn-group+.btn-group{margin-left:5px}.btn-group>.btn:not(:first-child):not(:last-child):not(.dropdown-toggle){border-radius:0}.btn-group>.btn:first-child{margin-left:0}.btn-group>.btn:first-child:not(:last-child):not(.dropdown-toggle){border-top-right-radius:0;border-bottom-right-radius:0}.btn-group>.btn:last-child:not(:first-child),.btn-group>.dropdown-toggle:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0}.btn-group>.btn-group{float:left}.btn-group>.btn-group:not(:first-child):not(:last-child)>.btn{border-radius:0}.btn-group>.btn-group:first-child>.btn:last-child,.btn-group>.btn-group:first-child>.dropdown-toggle{border-top-right-radius:0;border-bottom-right-radius:0}.btn-group>.btn-group:last-child>.btn:first-child{border-bottom-left-radius:0;border-top-left-radius:0}.btn-group .dropdown-toggle:active,.btn-group.open .dropdown-toggle{outline:0}.btn-group-xs>.btn{padding:1px 5px;font-size:12px;line-height:1.5;border-radius:3px}.btn-group-sm>.btn{padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}.btn-group-lg>.btn{padding:10px 16px;font-size:18px;line-height:1.33;border-radius:6px}.btn-group>.btn+.dropdown-toggle{padding-right:8px;padding-left:8px}.btn-group>.btn-lg+.dropdown-toggle{padding-right:12px;padding-left:12px}.btn-group.open .dropdown-toggle{-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,0.125);box-shadow:inset 0 3px 5px rgba(0,0,0,0.125)}.btn-group.open .dropdown-toggle.btn-link{-webkit-box-shadow:none;box-shadow:none}.btn .caret{margin-left:0}.btn-lg .caret{border-width:5px 5px 0;border-bottom-width:0}.dropup .btn-lg .caret{border-width:0 5px 5px}.btn-group-vertical>.btn,.btn-group-vertical>.btn-group,.btn-group-vertical>.btn-group>.btn{display:block;float:none;width:100%;max-width:100%}.btn-group-vertical>.btn-group:before,.btn-group-vertical>.btn-group:after{display:table;content:" "}.btn-group-vertical>.btn-group:after{clear:both}.btn-group-vertical>.btn-group:before,.btn-group-vertical>.btn-group:after{display:table;content:" "}.btn-group-vertical>.btn-group:after{clear:both}.btn-group-vertical>.btn-group>.btn{float:none}.btn-group-vertical>.btn+.btn,.btn-group-vertical>.btn+.btn-group,.btn-group-vertical>.btn-group+.btn,.btn-group-vertical>.btn-group+.btn-group{margin-top:-1px;margin-left:0}.btn-group-vertical>.btn:not(:first-child):not(:last-child){border-radius:0}.btn-group-vertical>.btn:first-child:not(:last-child){border-top-right-radius:4px;border-bottom-right-radius:0;border-bottom-left-radius:0}.btn-group-vertical>.btn:last-child:not(:first-child){border-top-right-radius:0;border-bottom-left-radius:4px;border-top-left-radius:0}.btn-group-vertical>.btn-group:not(:first-child):not(:last-child)>.btn{border-radius:0}.btn-group-vertical>.btn-group:first-child>.btn:last-child,.btn-group-vertical>.btn-group:first-child>.dropdown-toggle{border-bottom-right-radius:0;border-bottom-left-radius:0}.btn-group-vertical>.btn-group:last-child>.btn:first-child{border-top-right-radius:0;border-top-left-radius:0}.btn-group-justified{display:table;width:100%;border-collapse:separate;table-layout:fixed}.btn-group-justified>.btn,.btn-group-justified>.btn-group{display:table-cell;float:none;width:1%}.btn-group-justified>.btn-group .btn{width:100%}[data-toggle="buttons"]>.btn>input[type="radio"],[data-toggle="buttons"]>.btn>input[type="checkbox"]{display:none}.input-group{position:relative;display:table;border-collapse:separate}.input-group[class*="col-"]{float:none;padding-right:0;padding-left:0}.input-group .form-control{width:100%;margin-bottom:0}.input-group-lg>.form-control,.input-group-lg>.input-group-addon,.input-group-lg>.input-group-btn>.btn{height:46px;padding:10px 16px;font-size:18px;line-height:1.33;border-radius:6px}select.input-group-lg>.form-control,select.input-group-lg>.input-group-addon,select.input-group-lg>.input-group-btn>.btn{height:46px;line-height:46px}textarea.input-group-lg>.form-control,textarea.input-group-lg>.input-group-addon,textarea.input-group-lg>.input-group-btn>.btn{height:auto}.input-group-sm>.form-control,.input-group-sm>.input-group-addon,.input-group-sm>.input-group-btn>.btn{height:30px;padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}select.input-group-sm>.form-control,select.input-group-sm>.input-group-addon,select.input-group-sm>.input-group-btn>.btn{height:30px;line-height:30px}textarea.input-group-sm>.form-control,textarea.input-group-sm>.input-group-addon,textarea.input-group-sm>.input-group-btn>.btn{height:auto}.input-group-addon,.input-group-btn,.input-group .form-control{display:table-cell}.input-group-addon:not(:first-child):not(:last-child),.input-group-btn:not(:first-child):not(:last-child),.input-group .form-control:not(:first-child):not(:last-child){border-radius:0}.input-group-addon,.input-group-btn{width:1%;white-space:nowrap;vertical-align:middle}.input-group-addon{padding:6px 12px;font-size:14px;font-weight:normal;line-height:1;color:#555;text-align:center;background-color:#eee;border:1px solid #ccc;border-radius:4px}.input-group-addon.input-sm{padding:5px 10px;font-size:12px;border-radius:3px}.input-group-addon.input-lg{padding:10px 16px;font-size:18px;border-radius:6px}.input-group-addon input[type="radio"],.input-group-addon input[type="checkbox"]{margin-top:0}.input-group .form-control:first-child,.input-group-addon:first-child,.input-group-btn:first-child>.btn,.input-group-btn:first-child>.dropdown-toggle,.input-group-btn:last-child>.btn:not(:last-child):not(.dropdown-toggle){border-top-right-radius:0;border-bottom-right-radius:0}.input-group-addon:first-child{border-right:0}.input-group .form-control:last-child,.input-group-addon:last-child,.input-group-btn:last-child>.btn,.input-group-btn:last-child>.dropdown-toggle,.input-group-btn:first-child>.btn:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0}.input-group-addon:last-child{border-left:0}.input-group-btn{position:relative;white-space:nowrap}.input-group-btn:first-child>.btn{margin-right:-1px}.input-group-btn:last-child>.btn{margin-left:-1px}.input-group-btn>.btn{position:relative}.input-group-btn>.btn+.btn{margin-left:-4px}.input-group-btn>.btn:hover,.input-group-btn>.btn:active{z-index:2}.nav{padding-left:0;margin-bottom:0;list-style:none}.nav:before,.nav:after{display:table;content:" "}.nav:after{clear:both}.nav:before,.nav:after{display:table;content:" "}.nav:after{clear:both}.nav>li{position:relative;display:block}.nav>li>a{position:relative;display:block;padding:10px 15px}.nav>li>a:hover,.nav>li>a:focus{text-decoration:none;background-color:#eee}.nav>li.disabled>a{color:#999}.nav>li.disabled>a:hover,.nav>li.disabled>a:focus{color:#999;text-decoration:none;cursor:not-allowed;background-color:transparent}.nav .open>a,.nav .open>a:hover,.nav .open>a:focus{background-color:#eee;border-color:#428bca}.nav .nav-divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5}.nav>li>a>img{max-width:none}.nav-tabs{border-bottom:1px solid #ddd}.nav-tabs>li{float:left;margin-bottom:-1px}.nav-tabs>li>a{margin-right:2px;line-height:1.428571429;border:1px solid transparent;border-radius:4px 4px 0 0}.nav-tabs>li>a:hover{border-color:#eee #eee #ddd}.nav-tabs>li.active>a,.nav-tabs>li.active>a:hover,.nav-tabs>li.active>a:focus{color:#555;cursor:default;background-color:#fff;border:1px solid #ddd;border-bottom-color:transparent}.nav-tabs.nav-justified{width:100%;border-bottom:0}.nav-tabs.nav-justified>li{float:none}.nav-tabs.nav-justified>li>a{margin-bottom:5px;text-align:center}.nav-tabs.nav-justified>.dropdown .dropdown-menu{top:auto;left:auto}@media(min-width:768px){.nav-tabs.nav-justified>li{display:table-cell;width:1%}.nav-tabs.nav-justified>li>a{margin-bottom:0}}.nav-tabs.nav-justified>li>a{margin-right:0;border-radius:4px}.nav-tabs.nav-justified>.active>a,.nav-tabs.nav-justified>.active>a:hover,.nav-tabs.nav-justified>.active>a:focus{border:1px solid #ddd}@media(min-width:768px){.nav-tabs.nav-justified>li>a{border-bottom:1px solid #ddd;border-radius:4px 4px 0 0}.nav-tabs.nav-justified>.active>a,.nav-tabs.nav-justified>.active>a:hover,.nav-tabs.nav-justified>.active>a:focus{border-bottom-color:#fff}}.nav-pills>li{float:left}.nav-pills>li>a{border-radius:4px}.nav-pills>li+li{margin-left:2px}.nav-pills>li.active>a,.nav-pills>li.active>a:hover,.nav-pills>li.active>a:focus{color:#fff;background-color:#428bca}.nav-stacked>li{float:none}.nav-stacked>li+li{margin-top:2px;margin-left:0}.nav-justified{width:100%}.nav-justified>li{float:none}.nav-justified>li>a{margin-bottom:5px;text-align:center}.nav-justified>.dropdown .dropdown-menu{top:auto;left:auto}@media(min-width:768px){.nav-justified>li{display:table-cell;width:1%}.nav-justified>li>a{margin-bottom:0}}.nav-tabs-justified{border-bottom:0}.nav-tabs-justified>li>a{margin-right:0;border-radius:4px}.nav-tabs-justified>.active>a,.nav-tabs-justified>.active>a:hover,.nav-tabs-justified>.active>a:focus{border:1px solid #ddd}@media(min-width:768px){.nav-tabs-justified>li>a{border-bottom:1px solid #ddd;border-radius:4px 4px 0 0}.nav-tabs-justified>.active>a,.nav-tabs-justified>.active>a:hover,.nav-tabs-justified>.active>a:focus{border-bottom-color:#fff}}.tab-content>.tab-pane{display:none}.tab-content>.active{display:block}.nav-tabs .dropdown-menu{margin-top:-1px;border-top-right-radius:0;border-top-left-radius:0}.navbar{position:relative;min-height:50px;margin-bottom:20px;border:1px solid transparent}.navbar:before,.navbar:after{display:table;content:" "}.navbar:after{clear:both}.navbar:before,.navbar:after{display:table;content:" "}.navbar:after{clear:both}@media(min-width:768px){.navbar{border-radius:4px}}.navbar-header:before,.navbar-header:after{display:table;content:" "}.navbar-header:after{clear:both}.navbar-header:before,.navbar-header:after{display:table;content:" "}.navbar-header:after{clear:both}@media(min-width:768px){.navbar-header{float:left}}.navbar-collapse{max-height:340px;padding-right:15px;padding-left:15px;overflow-x:visible;border-top:1px solid transparent;box-shadow:inset 0 1px 0 rgba(255,255,255,0.1);-webkit-overflow-scrolling:touch}.navbar-collapse:before,.navbar-collapse:after{display:table;content:" "}.navbar-collapse:after{clear:both}.navbar-collapse:before,.navbar-collapse:after{display:table;content:" "}.navbar-collapse:after{clear:both}.navbar-collapse.in{overflow-y:auto}@media(min-width:768px){.navbar-collapse{width:auto;border-top:0;box-shadow:none}.navbar-collapse.collapse{display:block!important;height:auto!important;padding-bottom:0;overflow:visible!important}.navbar-collapse.in{overflow-y:visible}.navbar-fixed-top .navbar-collapse,.navbar-static-top .navbar-collapse,.navbar-fixed-bottom .navbar-collapse{padding-right:0;padding-left:0}}.container>.navbar-header,.container>.navbar-collapse{margin-right:-15px;margin-left:-15px}@media(min-width:768px){.container>.navbar-header,.container>.navbar-collapse{margin-right:0;margin-left:0}}.navbar-static-top{z-index:1000;border-width:0 0 1px}@media(min-width:768px){.navbar-static-top{border-radius:0}}.navbar-fixed-top,.navbar-fixed-bottom{position:fixed;right:0;left:0;z-index:1030}@media(min-width:768px){.navbar-fixed-top,.navbar-fixed-bottom{border-radius:0}}.navbar-fixed-top{top:0;border-width:0 0 1px}.navbar-fixed-bottom{bottom:0;margin-bottom:0;border-width:1px 0 0}.navbar-brand{float:left;padding:15px 15px;font-size:18px;line-height:20px}.navbar-brand:hover,.navbar-brand:focus{text-decoration:none}@media(min-width:768px){.navbar>.container .navbar-brand{margin-left:-15px}}.navbar-toggle{position:relative;float:right;padding:9px 10px;margin-top:8px;margin-right:15px;margin-bottom:8px;background-color:transparent;background-image:none;border:1px solid transparent;border-radius:4px}.navbar-toggle .icon-bar{display:block;width:22px;height:2px;border-radius:1px}.navbar-toggle .icon-bar+.icon-bar{margin-top:4px}@media(min-width:768px){.navbar-toggle{display:none}}.navbar-nav{margin:7.5px -15px}.navbar-nav>li>a{padding-top:10px;padding-bottom:10px;line-height:20px}@media(max-width:767px){.navbar-nav .open .dropdown-menu{position:static;float:none;width:auto;margin-top:0;background-color:transparent;border:0;box-shadow:none}.navbar-nav .open .dropdown-menu>li>a,.navbar-nav .open .dropdown-menu .dropdown-header{padding:5px 15px 5px 25px}.navbar-nav .open .dropdown-menu>li>a{line-height:20px}.navbar-nav .open .dropdown-menu>li>a:hover,.navbar-nav .open .dropdown-menu>li>a:focus{background-image:none}}@media(min-width:768px){.navbar-nav{float:left;margin:0}.navbar-nav>li{float:left}.navbar-nav>li>a{padding-top:15px;padding-bottom:15px}.navbar-nav.navbar-right:last-child{margin-right:-15px}}@media(min-width:768px){.navbar-left{float:left!important}.navbar-right{float:right!important}}.navbar-form{padding:10px 15px;margin-top:8px;margin-right:-15px;margin-bottom:8px;margin-left:-15px;border-top:1px solid transparent;border-bottom:1px solid transparent;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1);box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1)}@media(min-width:768px){.navbar-form .form-group{display:inline-block;margin-bottom:0;vertical-align:middle}.navbar-form .form-control{display:inline-block}.navbar-form select.form-control{width:auto}.navbar-form .radio,.navbar-form .checkbox{display:inline-block;padding-left:0;margin-top:0;margin-bottom:0}.navbar-form .radio input[type="radio"],.navbar-form .checkbox input[type="checkbox"]{float:none;margin-left:0}}@media(max-width:767px){.navbar-form .form-group{margin-bottom:5px}}@media(min-width:768px){.navbar-form{width:auto;padding-top:0;padding-bottom:0;margin-right:0;margin-left:0;border:0;-webkit-box-shadow:none;box-shadow:none}.navbar-form.navbar-right:last-child{margin-right:-15px}}.navbar-nav>li>.dropdown-menu{margin-top:0;border-top-right-radius:0;border-top-left-radius:0}.navbar-fixed-bottom .navbar-nav>li>.dropdown-menu{border-bottom-right-radius:0;border-bottom-left-radius:0}.navbar-nav.pull-right>li>.dropdown-menu,.navbar-nav>li>.dropdown-menu.pull-right{right:0;left:auto}.navbar-btn{margin-top:8px;margin-bottom:8px}.navbar-btn.btn-sm{margin-top:10px;margin-bottom:10px}.navbar-btn.btn-xs{margin-top:14px;margin-bottom:14px}.navbar-text{margin-top:15px;margin-bottom:15px}@media(min-width:768px){.navbar-text{float:left;margin-right:15px;margin-left:15px}.navbar-text.navbar-right:last-child{margin-right:0}}.navbar-default{background-color:#f8f8f8;border-color:#e7e7e7}.navbar-default .navbar-brand{color:#777}.navbar-default .navbar-brand:hover,.navbar-default .navbar-brand:focus{color:#5e5e5e;background-color:transparent}.navbar-default .navbar-text{color:#777}.navbar-default .navbar-nav>li>a{color:#777}.navbar-default .navbar-nav>li>a:hover,.navbar-default .navbar-nav>li>a:focus{color:#333;background-color:transparent}.navbar-default .navbar-nav>.active>a,.navbar-default .navbar-nav>.active>a:hover,.navbar-default .navbar-nav>.active>a:focus{color:#555;background-color:#e7e7e7}.navbar-default .navbar-nav>.disabled>a,.navbar-default .navbar-nav>.disabled>a:hover,.navbar-default .navbar-nav>.disabled>a:focus{color:#ccc;background-color:transparent}.navbar-default .navbar-toggle{border-color:#ddd}.navbar-default .navbar-toggle:hover,.navbar-default .navbar-toggle:focus{background-color:#ddd}.navbar-default .navbar-toggle .icon-bar{background-color:#ccc}.navbar-default .navbar-collapse,.navbar-default .navbar-form{border-color:#e7e7e7}.navbar-default .navbar-nav>.open>a,.navbar-default .navbar-nav>.open>a:hover,.navbar-default .navbar-nav>.open>a:focus{color:#555;background-color:#e7e7e7}@media(max-width:767px){.navbar-default .navbar-nav .open .dropdown-menu>li>a{color:#777}.navbar-default .navbar-nav .open .dropdown-menu>li>a:hover,.navbar-default .navbar-nav .open .dropdown-menu>li>a:focus{color:#333;background-color:transparent}.navbar-default .navbar-nav .open .dropdown-menu>.active>a,.navbar-default .navbar-nav .open .dropdown-menu>.active>a:hover,.navbar-default .navbar-nav .open .dropdown-menu>.active>a:focus{color:#555;background-color:#e7e7e7}.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a,.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a:hover,.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a:focus{color:#ccc;background-color:transparent}}.navbar-default .navbar-link{color:#777}.navbar-default .navbar-link:hover{color:#333}.navbar-inverse{background-color:#222;border-color:#080808}.navbar-inverse .navbar-brand{color:#999}.navbar-inverse .navbar-brand:hover,.navbar-inverse .navbar-brand:focus{color:#fff;background-color:transparent}.navbar-inverse .navbar-text{color:#999}.navbar-inverse .navbar-nav>li>a{color:#999}.navbar-inverse .navbar-nav>li>a:hover,.navbar-inverse .navbar-nav>li>a:focus{color:#fff;background-color:transparent}.navbar-inverse .navbar-nav>.active>a,.navbar-inverse .navbar-nav>.active>a:hover,.navbar-inverse .navbar-nav>.active>a:focus{color:#fff;background-color:#080808}.navbar-inverse .navbar-nav>.disabled>a,.navbar-inverse .navbar-nav>.disabled>a:hover,.navbar-inverse .navbar-nav>.disabled>a:focus{color:#444;background-color:transparent}.navbar-inverse .navbar-toggle{border-color:#333}.navbar-inverse .navbar-toggle:hover,.navbar-inverse .navbar-toggle:focus{background-color:#333}.navbar-inverse .navbar-toggle .icon-bar{background-color:#fff}.navbar-inverse .navbar-collapse,.navbar-inverse .navbar-form{border-color:#101010}.navbar-inverse .navbar-nav>.open>a,.navbar-inverse .navbar-nav>.open>a:hover,.navbar-inverse .navbar-nav>.open>a:focus{color:#fff;background-color:#080808}@media(max-width:767px){.navbar-inverse .navbar-nav .open .dropdown-menu>.dropdown-header{border-color:#080808}.navbar-inverse .navbar-nav .open .dropdown-menu .divider{background-color:#080808}.navbar-inverse .navbar-nav .open .dropdown-menu>li>a{color:#999}.navbar-inverse .navbar-nav .open .dropdown-menu>li>a:hover,.navbar-inverse .navbar-nav .open .dropdown-menu>li>a:focus{color:#fff;background-color:transparent}.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a,.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a:hover,.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a:focus{color:#fff;background-color:#080808}.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a,.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a:hover,.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a:focus{color:#444;background-color:transparent}}.navbar-inverse .navbar-link{color:#999}.navbar-inverse .navbar-link:hover{color:#fff}.breadcrumb{padding:8px 15px;margin-bottom:20px;list-style:none;background-color:#f5f5f5;border-radius:4px}.breadcrumb>li{display:inline-block}.breadcrumb>li+li:before{padding:0 5px;color:#ccc;content:"/\00a0"}.breadcrumb>.active{color:#999}.pagination{display:inline-block;padding-left:0;margin:20px 0;border-radius:4px}.pagination>li{display:inline}.pagination>li>a,.pagination>li>span{position:relative;float:left;padding:6px 12px;margin-left:-1px;line-height:1.428571429;text-decoration:none;background-color:#fff;border:1px solid #ddd}.pagination>li:first-child>a,.pagination>li:first-child>span{margin-left:0;border-bottom-left-radius:4px;border-top-left-radius:4px}.pagination>li:last-child>a,.pagination>li:last-child>span{border-top-right-radius:4px;border-bottom-right-radius:4px}.pagination>li>a:hover,.pagination>li>span:hover,.pagination>li>a:focus,.pagination>li>span:focus{background-color:#eee}.pagination>.active>a,.pagination>.active>span,.pagination>.active>a:hover,.pagination>.active>span:hover,.pagination>.active>a:focus,.pagination>.active>span:focus{z-index:2;color:#fff;cursor:default;background-color:#428bca;border-color:#428bca}.pagination>.disabled>span,.pagination>.disabled>span:hover,.pagination>.disabled>span:focus,.pagination>.disabled>a,.pagination>.disabled>a:hover,.pagination>.disabled>a:focus{color:#999;cursor:not-allowed;background-color:#fff;border-color:#ddd}.pagination-lg>li>a,.pagination-lg>li>span{padding:10px 16px;font-size:18px}.pagination-lg>li:first-child>a,.pagination-lg>li:first-child>span{border-bottom-left-radius:6px;border-top-left-radius:6px}.pagination-lg>li:last-child>a,.pagination-lg>li:last-child>span{border-top-right-radius:6px;border-bottom-right-radius:6px}.pagination-sm>li>a,.pagination-sm>li>span{padding:5px 10px;font-size:12px}.pagination-sm>li:first-child>a,.pagination-sm>li:first-child>span{border-bottom-left-radius:3px;border-top-left-radius:3px}.pagination-sm>li:last-child>a,.pagination-sm>li:last-child>span{border-top-right-radius:3px;border-bottom-right-radius:3px}.pager{padding-left:0;margin:20px 0;text-align:center;list-style:none}.pager:before,.pager:after{display:table;content:" "}.pager:after{clear:both}.pager:before,.pager:after{display:table;content:" "}.pager:after{clear:both}.pager li{display:inline}.pager li>a,.pager li>span{display:inline-block;padding:5px 14px;background-color:#fff;border:1px solid #ddd;border-radius:15px}.pager li>a:hover,.pager li>a:focus{text-decoration:none;background-color:#eee}.pager .next>a,.pager .next>span{float:right}.pager .previous>a,.pager .previous>span{float:left}.pager .disabled>a,.pager .disabled>a:hover,.pager .disabled>a:focus,.pager .disabled>span{color:#999;cursor:not-allowed;background-color:#fff}.label{display:inline;padding:.2em .6em .3em;font-size:75%;font-weight:bold;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;border-radius:.25em}.label[href]:hover,.label[href]:focus{color:#fff;text-decoration:none;cursor:pointer}.label:empty{display:none}.btn .label{position:relative;top:-1px}.label-default{background-color:#999}.label-default[href]:hover,.label-default[href]:focus{background-color:#808080}.label-primary{background-color:#428bca}.label-primary[href]:hover,.label-primary[href]:focus{background-color:#3071a9}.label-success{background-color:#5cb85c}.label-success[href]:hover,.label-success[href]:focus{background-color:#449d44}.label-info{background-color:#5bc0de}.label-info[href]:hover,.label-info[href]:focus{background-color:#31b0d5}.label-warning{background-color:#f0ad4e}.label-warning[href]:hover,.label-warning[href]:focus{background-color:#ec971f}.label-danger{background-color:#d9534f}.label-danger[href]:hover,.label-danger[href]:focus{background-color:#c9302c}.badge{display:inline-block;min-width:10px;padding:3px 7px;font-size:12px;font-weight:bold;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;background-color:#999;border-radius:10px}.badge:empty{display:none}.btn .badge{position:relative;top:-1px}a.badge:hover,a.badge:focus{color:#fff;text-decoration:none;cursor:pointer}a.list-group-item.active>.badge,.nav-pills>.active>a>.badge{color:#428bca;background-color:#fff}.nav-pills>li>a>.badge{margin-left:3px}.jumbotron{padding:30px;margin-bottom:30px;font-size:21px;font-weight:200;line-height:2.1428571435;color:inherit;background-color:#eee}.jumbotron h1,.jumbotron .h1{line-height:1;color:inherit}.jumbotron p{line-height:1.4}.container .jumbotron{border-radius:6px}.jumbotron .container{max-width:100%}@media screen and (min-width:768px){.jumbotron{padding-top:48px;padding-bottom:48px}.container .jumbotron{padding-right:60px;padding-left:60px}.jumbotron h1,.jumbotron .h1{font-size:63px}}.thumbnail{display:block;padding:4px;margin-bottom:20px;line-height:1.428571429;background-color:#fff;border:1px solid #ddd;border-radius:4px;-webkit-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.thumbnail>img,.thumbnail a>img{display:block;height:auto;max-width:100%;margin-right:auto;margin-left:auto}a.thumbnail:hover,a.thumbnail:focus,a.thumbnail.active{border-color:#428bca}.thumbnail .caption{padding:9px;color:#333}.alert{padding:15px;margin-bottom:20px;border:1px solid transparent;border-radius:4px}.alert h4{margin-top:0;color:inherit}.alert .alert-link{font-weight:bold}.alert>p,.alert>ul{margin-bottom:0}.alert>p+p{margin-top:5px}.alert-dismissable{padding-right:35px}.alert-dismissable .close{position:relative;top:-2px;right:-21px;color:inherit}.alert-success{color:#3c763d;background-color:#dff0d8;border-color:#d6e9c6}.alert-success hr{border-top-color:#c9e2b3}.alert-success .alert-link{color:#2b542c}.alert-info{color:#31708f;background-color:#d9edf7;border-color:#bce8f1}.alert-info hr{border-top-color:#a6e1ec}.alert-info .alert-link{color:#245269}.alert-warning{color:#8a6d3b;background-color:#fcf8e3;border-color:#faebcc}.alert-warning hr{border-top-color:#f7e1b5}.alert-warning .alert-link{color:#66512c}.alert-danger{color:#a94442;background-color:#f2dede;border-color:#ebccd1}.alert-danger hr{border-top-color:#e4b9c0}.alert-danger .alert-link{color:#843534}@-webkit-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}.progress{height:20px;margin-bottom:20px;overflow:hidden;background-color:#f5f5f5;border-radius:4px;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);box-shadow:inset 0 1px 2px rgba(0,0,0,0.1)}.progress-bar{float:left;width:0;height:100%;font-size:12px;line-height:20px;color:#fff;text-align:center;background-color:#428bca;-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);-webkit-transition:width .6s ease;transition:width .6s ease}.progress-striped .progress-bar{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-size:40px 40px}.progress.active .progress-bar{-webkit-animation:progress-bar-stripes 2s linear infinite;animation:progress-bar-stripes 2s linear infinite}.progress-bar-success{background-color:#5cb85c}.progress-striped .progress-bar-success{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-bar-info{background-color:#5bc0de}.progress-striped .progress-bar-info{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-bar-warning{background-color:#f0ad4e}.progress-striped .progress-bar-warning{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-bar-danger{background-color:#d9534f}.progress-striped .progress-bar-danger{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.media,.media-body{overflow:hidden;zoom:1}.media,.media .media{margin-top:15px}.media:first-child{margin-top:0}.media-object{display:block}.media-heading{margin:0 0 5px}.media>.pull-left{margin-right:10px}.media>.pull-right{margin-left:10px}.media-list{padding-left:0;list-style:none}.list-group{padding-left:0;margin-bottom:20px}.list-group-item{position:relative;display:block;padding:10px 15px;margin-bottom:-1px;background-color:#fff;border:1px solid #ddd}.list-group-item:first-child{border-top-right-radius:4px;border-top-left-radius:4px}.list-group-item:last-child{margin-bottom:0;border-bottom-right-radius:4px;border-bottom-left-radius:4px}.list-group-item>.badge{float:right}.list-group-item>.badge+.badge{margin-right:5px}a.list-group-item{color:#555}a.list-group-item .list-group-item-heading{color:#333}a.list-group-item:hover,a.list-group-item:focus{text-decoration:none;background-color:#f5f5f5}a.list-group-item.active,a.list-group-item.active:hover,a.list-group-item.active:focus{z-index:2;color:#fff;background-color:#428bca;border-color:#428bca}a.list-group-item.active .list-group-item-heading,a.list-group-item.active:hover .list-group-item-heading,a.list-group-item.active:focus .list-group-item-heading{color:inherit}a.list-group-item.active .list-group-item-text,a.list-group-item.active:hover .list-group-item-text,a.list-group-item.active:focus .list-group-item-text{color:#e1edf7}.list-group-item-heading{margin-top:0;margin-bottom:5px}.list-group-item-text{margin-bottom:0;line-height:1.3}.panel{margin-bottom:20px;background-color:#fff;border:1px solid transparent;border-radius:4px;-webkit-box-shadow:0 1px 1px rgba(0,0,0,0.05);box-shadow:0 1px 1px rgba(0,0,0,0.05)}.panel-body{padding:15px}.panel-body:before,.panel-body:after{display:table;content:" "}.panel-body:after{clear:both}.panel-body:before,.panel-body:after{display:table;content:" "}.panel-body:after{clear:both}.panel>.list-group{margin-bottom:0}.panel>.list-group .list-group-item{border-width:1px 0}.panel>.list-group .list-group-item:first-child{border-top-right-radius:0;border-top-left-radius:0}.panel>.list-group .list-group-item:last-child{border-bottom:0}.panel-heading+.list-group .list-group-item:first-child{border-top-width:0}.panel>.table,.panel>.table-responsive>.table{margin-bottom:0}.panel>.panel-body+.table,.panel>.panel-body+.table-responsive{border-top:1px solid #ddd}.panel>.table>tbody:first-child th,.panel>.table>tbody:first-child td{border-top:0}.panel>.table-bordered,.panel>.table-responsive>.table-bordered{border:0}.panel>.table-bordered>thead>tr>th:first-child,.panel>.table-responsive>.table-bordered>thead>tr>th:first-child,.panel>.table-bordered>tbody>tr>th:first-child,.panel>.table-responsive>.table-bordered>tbody>tr>th:first-child,.panel>.table-bordered>tfoot>tr>th:first-child,.panel>.table-responsive>.table-bordered>tfoot>tr>th:first-child,.panel>.table-bordered>thead>tr>td:first-child,.panel>.table-responsive>.table-bordered>thead>tr>td:first-child,.panel>.table-bordered>tbody>tr>td:first-child,.panel>.table-responsive>.table-bordered>tbody>tr>td:first-child,.panel>.table-bordered>tfoot>tr>td:first-child,.panel>.table-responsive>.table-bordered>tfoot>tr>td:first-child{border-left:0}.panel>.table-bordered>thead>tr>th:last-child,.panel>.table-responsive>.table-bordered>thead>tr>th:last-child,.panel>.table-bordered>tbody>tr>th:last-child,.panel>.table-responsive>.table-bordered>tbody>tr>th:last-child,.panel>.table-bordered>tfoot>tr>th:last-child,.panel>.table-responsive>.table-bordered>tfoot>tr>th:last-child,.panel>.table-bordered>thead>tr>td:last-child,.panel>.table-responsive>.table-bordered>thead>tr>td:last-child,.panel>.table-bordered>tbody>tr>td:last-child,.panel>.table-responsive>.table-bordered>tbody>tr>td:last-child,.panel>.table-bordered>tfoot>tr>td:last-child,.panel>.table-responsive>.table-bordered>tfoot>tr>td:last-child{border-right:0}.panel>.table-bordered>thead>tr:last-child>th,.panel>.table-responsive>.table-bordered>thead>tr:last-child>th,.panel>.table-bordered>tbody>tr:last-child>th,.panel>.table-responsive>.table-bordered>tbody>tr:last-child>th,.panel>.table-bordered>tfoot>tr:last-child>th,.panel>.table-responsive>.table-bordered>tfoot>tr:last-child>th,.panel>.table-bordered>thead>tr:last-child>td,.panel>.table-responsive>.table-bordered>thead>tr:last-child>td,.panel>.table-bordered>tbody>tr:last-child>td,.panel>.table-responsive>.table-bordered>tbody>tr:last-child>td,.panel>.table-bordered>tfoot>tr:last-child>td,.panel>.table-responsive>.table-bordered>tfoot>tr:last-child>td{border-bottom:0}.panel>.table-responsive{margin-bottom:0;border:0}.panel-heading{padding:10px 15px;border-bottom:1px solid transparent;border-top-right-radius:3px;border-top-left-radius:3px}.panel-heading>.dropdown .dropdown-toggle{color:inherit}.panel-title{margin-top:0;margin-bottom:0;font-size:16px;color:inherit}.panel-title>a{color:inherit}.panel-footer{padding:10px 15px;background-color:#f5f5f5;border-top:1px solid #ddd;border-bottom-right-radius:3px;border-bottom-left-radius:3px}.panel-group .panel{margin-bottom:0;overflow:hidden;border-radius:4px}.panel-group .panel+.panel{margin-top:5px}.panel-group .panel-heading{border-bottom:0}.panel-group .panel-heading+.panel-collapse .panel-body{border-top:1px solid #ddd}.panel-group .panel-footer{border-top:0}.panel-group .panel-footer+.panel-collapse .panel-body{border-bottom:1px solid #ddd}.panel-default{border-color:#ddd}.panel-default>.panel-heading{color:#333;background-color:#f5f5f5;border-color:#ddd}.panel-default>.panel-heading+.panel-collapse .panel-body{border-top-color:#ddd}.panel-default>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#ddd}.panel-primary{border-color:#428bca}.panel-primary>.panel-heading{color:#fff;background-color:#428bca;border-color:#428bca}.panel-primary>.panel-heading+.panel-collapse .panel-body{border-top-color:#428bca}.panel-primary>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#428bca}.panel-success{border-color:#d6e9c6}.panel-success>.panel-heading{color:#3c763d;background-color:#dff0d8;border-color:#d6e9c6}.panel-success>.panel-heading+.panel-collapse .panel-body{border-top-color:#d6e9c6}.panel-success>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#d6e9c6}.panel-warning{border-color:#faebcc}.panel-warning>.panel-heading{color:#8a6d3b;background-color:#fcf8e3;border-color:#faebcc}.panel-warning>.panel-heading+.panel-collapse .panel-body{border-top-color:#faebcc}.panel-warning>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#faebcc}.panel-danger{border-color:#ebccd1}.panel-danger>.panel-heading{color:#a94442;background-color:#f2dede;border-color:#ebccd1}.panel-danger>.panel-heading+.panel-collapse .panel-body{border-top-color:#ebccd1}.panel-danger>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#ebccd1}.panel-info{border-color:#bce8f1}.panel-info>.panel-heading{color:#31708f;background-color:#d9edf7;border-color:#bce8f1}.panel-info>.panel-heading+.panel-collapse .panel-body{border-top-color:#bce8f1}.panel-info>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#bce8f1}.well{min-height:20px;padding:19px;margin-bottom:20px;background-color:#f5f5f5;border:1px solid #e3e3e3;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.05);box-shadow:inset 0 1px 1px rgba(0,0,0,0.05)}.well blockquote{border-color:#ddd;border-color:rgba(0,0,0,0.15)}.well-lg{padding:24px;border-radius:6px}.well-sm{padding:9px;border-radius:3px}.close{float:right;font-size:21px;font-weight:bold;line-height:1;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;filter:alpha(opacity=20)}.close:hover,.close:focus{color:#000;text-decoration:none;cursor:pointer;opacity:.5;filter:alpha(opacity=50)}button.close{padding:0;cursor:pointer;background:transparent;border:0;-webkit-appearance:none}.modal-open{overflow:hidden}.modal{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1040;display:none;overflow:auto;overflow-y:scroll}.modal.fade .modal-dialog{-webkit-transform:translate(0,-25%);-ms-transform:translate(0,-25%);transform:translate(0,-25%);-webkit-transition:-webkit-transform .3s ease-out;-moz-transition:-moz-transform .3s ease-out;-o-transition:-o-transform .3s ease-out;transition:transform .3s ease-out}.modal.in .modal-dialog{-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0)}.modal-dialog{position:relative;z-index:1050;width:auto;margin:10px}.modal-content{position:relative;background-color:#fff;border:1px solid #999;border:1px solid rgba(0,0,0,0.2);border-radius:6px;outline:0;-webkit-box-shadow:0 3px 9px rgba(0,0,0,0.5);box-shadow:0 3px 9px rgba(0,0,0,0.5);background-clip:padding-box}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1030;background-color:#000}.modal-backdrop.fade{opacity:0;filter:alpha(opacity=0)}.modal-backdrop.in{opacity:.5;filter:alpha(opacity=50)}.modal-header{min-height:16.428571429px;padding:15px;border-bottom:1px solid #e5e5e5}.modal-header .close{margin-top:-2px}.modal-title{margin:0;line-height:1.428571429}.modal-body{position:relative;padding:20px}.modal-footer{padding:19px 20px 20px;margin-top:15px;text-align:right;border-top:1px solid #e5e5e5}.modal-footer:before,.modal-footer:after{display:table;content:" "}.modal-footer:after{clear:both}.modal-footer:before,.modal-footer:after{display:table;content:" "}.modal-footer:after{clear:both}.modal-footer .btn+.btn{margin-bottom:0;margin-left:5px}.modal-footer .btn-group .btn+.btn{margin-left:-1px}.modal-footer .btn-block+.btn-block{margin-left:0}@media screen and (min-width:768px){.modal-dialog{width:600px;margin:30px auto}.modal-content{-webkit-box-shadow:0 5px 15px rgba(0,0,0,0.5);box-shadow:0 5px 15px rgba(0,0,0,0.5)}}.tooltip{position:absolute;z-index:1030;display:block;font-size:12px;line-height:1.4;opacity:0;filter:alpha(opacity=0);visibility:visible}.tooltip.in{opacity:.9;filter:alpha(opacity=90)}.tooltip.top{padding:5px 0;margin-top:-3px}.tooltip.right{padding:0 5px;margin-left:3px}.tooltip.bottom{padding:5px 0;margin-top:3px}.tooltip.left{padding:0 5px;margin-left:-3px}.tooltip-inner{max-width:200px;padding:3px 8px;color:#fff;text-align:center;text-decoration:none;background-color:#000;border-radius:4px}.tooltip-arrow{position:absolute;width:0;height:0;border-color:transparent;border-style:solid}.tooltip.top .tooltip-arrow{bottom:0;left:50%;margin-left:-5px;border-top-color:#000;border-width:5px 5px 0}.tooltip.top-left .tooltip-arrow{bottom:0;left:5px;border-top-color:#000;border-width:5px 5px 0}.tooltip.top-right .tooltip-arrow{right:5px;bottom:0;border-top-color:#000;border-width:5px 5px 0}.tooltip.right .tooltip-arrow{top:50%;left:0;margin-top:-5px;border-right-color:#000;border-width:5px 5px 5px 0}.tooltip.left .tooltip-arrow{top:50%;right:0;margin-top:-5px;border-left-color:#000;border-width:5px 0 5px 5px}.tooltip.bottom .tooltip-arrow{top:0;left:50%;margin-left:-5px;border-bottom-color:#000;border-width:0 5px 5px}.tooltip.bottom-left .tooltip-arrow{top:0;left:5px;border-bottom-color:#000;border-width:0 5px 5px}.tooltip.bottom-right .tooltip-arrow{top:0;right:5px;border-bottom-color:#000;border-width:0 5px 5px}.popover{position:absolute;top:0;left:0;z-index:1010;display:none;max-width:276px;padding:1px;text-align:left;white-space:normal;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);box-shadow:0 5px 10px rgba(0,0,0,0.2);background-clip:padding-box}.popover.top{margin-top:-10px}.popover.right{margin-left:10px}.popover.bottom{margin-top:10px}.popover.left{margin-left:-10px}.popover-title{padding:8px 14px;margin:0;font-size:14px;font-weight:normal;line-height:18px;background-color:#f7f7f7;border-bottom:1px solid #ebebeb;border-radius:5px 5px 0 0}.popover-content{padding:9px 14px}.popover .arrow,.popover .arrow:after{position:absolute;display:block;width:0;height:0;border-color:transparent;border-style:solid}.popover .arrow{border-width:11px}.popover .arrow:after{border-width:10px;content:""}.popover.top .arrow{bottom:-11px;left:50%;margin-left:-11px;border-top-color:#999;border-top-color:rgba(0,0,0,0.25);border-bottom-width:0}.popover.top .arrow:after{bottom:1px;margin-left:-10px;border-top-color:#fff;border-bottom-width:0;content:" "}.popover.right .arrow{top:50%;left:-11px;margin-top:-11px;border-right-color:#999;border-right-color:rgba(0,0,0,0.25);border-left-width:0}.popover.right .arrow:after{bottom:-10px;left:1px;border-right-color:#fff;border-left-width:0;content:" "}.popover.bottom .arrow{top:-11px;left:50%;margin-left:-11px;border-bottom-color:#999;border-bottom-color:rgba(0,0,0,0.25);border-top-width:0}.popover.bottom .arrow:after{top:1px;margin-left:-10px;border-bottom-color:#fff;border-top-width:0;content:" "}.popover.left .arrow{top:50%;right:-11px;margin-top:-11px;border-left-color:#999;border-left-color:rgba(0,0,0,0.25);border-right-width:0}.popover.left .arrow:after{right:1px;bottom:-10px;border-left-color:#fff;border-right-width:0;content:" "}.carousel{position:relative}.carousel-inner{position:relative;width:100%;overflow:hidden}.carousel-inner>.item{position:relative;display:none;-webkit-transition:.6s ease-in-out left;transition:.6s ease-in-out left}.carousel-inner>.item>img,.carousel-inner>.item>a>img{display:block;height:auto;max-width:100%;line-height:1}.carousel-inner>.active,.carousel-inner>.next,.carousel-inner>.prev{display:block}.carousel-inner>.active{left:0}.carousel-inner>.next,.carousel-inner>.prev{position:absolute;top:0;width:100%}.carousel-inner>.next{left:100%}.carousel-inner>.prev{left:-100%}.carousel-inner>.next.left,.carousel-inner>.prev.right{left:0}.carousel-inner>.active.left{left:-100%}.carousel-inner>.active.right{left:100%}.carousel-control{position:absolute;top:0;bottom:0;left:0;width:15%;font-size:20px;color:#fff;text-align:center;text-shadow:0 1px 2px rgba(0,0,0,0.6);opacity:.5;filter:alpha(opacity=50)}.carousel-control.left{background-image:-webkit-linear-gradient(left,color-stop(rgba(0,0,0,0.5) 0),color-stop(rgba(0,0,0,0.0001) 100%));background-image:linear-gradient(to right,rgba(0,0,0,0.5) 0,rgba(0,0,0,0.0001) 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#80000000',endColorstr='#00000000',GradientType=1)}.carousel-control.right{right:0;left:auto;background-image:-webkit-linear-gradient(left,color-stop(rgba(0,0,0,0.0001) 0),color-stop(rgba(0,0,0,0.5) 100%));background-image:linear-gradient(to right,rgba(0,0,0,0.0001) 0,rgba(0,0,0,0.5) 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000',endColorstr='#80000000',GradientType=1)}.carousel-control:hover,.carousel-control:focus{color:#fff;text-decoration:none;outline:0;opacity:.9;filter:alpha(opacity=90)}.carousel-control .icon-prev,.carousel-control .icon-next,.carousel-control .glyphicon-chevron-left,.carousel-control .glyphicon-chevron-right{position:absolute;top:50%;z-index:5;display:inline-block}.carousel-control .icon-prev,.carousel-control .glyphicon-chevron-left{left:50%}.carousel-control .icon-next,.carousel-control .glyphicon-chevron-right{right:50%}.carousel-control .icon-prev,.carousel-control .icon-next{width:20px;height:20px;margin-top:-10px;margin-left:-10px;font-family:serif}.carousel-control .icon-prev:before{content:'\2039'}.carousel-control .icon-next:before{content:'\203a'}.carousel-indicators{position:absolute;bottom:10px;left:50%;z-index:15;width:60%;padding-left:0;margin-left:-30%;text-align:center;list-style:none}.carousel-indicators li{display:inline-block;width:10px;height:10px;margin:1px;text-indent:-999px;cursor:pointer;background-color:#000 \9;background-color:rgba(0,0,0,0);border:1px solid #fff;border-radius:10px}.carousel-indicators .active{width:12px;height:12px;margin:0;background-color:#fff}.carousel-caption{position:absolute;right:15%;bottom:20px;left:15%;z-index:10;padding-top:20px;padding-bottom:20px;color:#fff;text-align:center;text-shadow:0 1px 2px rgba(0,0,0,0.6)}.carousel-caption .btn{text-shadow:none}@media screen and (min-width:768px){.carousel-control .glyphicons-chevron-left,.carousel-control .glyphicons-chevron-right,.carousel-control .icon-prev,.carousel-control .icon-next{width:30px;height:30px;margin-top:-15px;margin-left:-15px;font-size:30px}.carousel-caption{right:20%;left:20%;padding-bottom:30px}.carousel-indicators{bottom:20px}}.clearfix:before,.clearfix:after{display:table;content:" "}.clearfix:after{clear:both}.center-block{display:block;margin-right:auto;margin-left:auto}.pull-right{float:right!important}.pull-left{float:left!important}.hide{display:none!important}.show{display:block!important}.invisible{visibility:hidden}.text-hide{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.hidden{display:none!important;visibility:hidden!important}.affix{position:fixed}@-ms-viewport{width:device-width}.visible-xs,tr.visible-xs,th.visible-xs,td.visible-xs{display:none!important}@media(max-width:767px){.visible-xs{display:block!important}table.visible-xs{display:table}tr.visible-xs{display:table-row!important}th.visible-xs,td.visible-xs{display:table-cell!important}}@media(min-width:768px) and (max-width:991px){.visible-xs.visible-sm{display:block!important}table.visible-xs.visible-sm{display:table}tr.visible-xs.visible-sm{display:table-row!important}th.visible-xs.visible-sm,td.visible-xs.visible-sm{display:table-cell!important}}@media(min-width:992px) and (max-width:1199px){.visible-xs.visible-md{display:block!important}table.visible-xs.visible-md{display:table}tr.visible-xs.visible-md{display:table-row!important}th.visible-xs.visible-md,td.visible-xs.visible-md{display:table-cell!important}}@media(min-width:1200px){.visible-xs.visible-lg{display:block!important}table.visible-xs.visible-lg{display:table}tr.visible-xs.visible-lg{display:table-row!important}th.visible-xs.visible-lg,td.visible-xs.visible-lg{display:table-cell!important}}.visible-sm,tr.visible-sm,th.visible-sm,td.visible-sm{display:none!important}@media(max-width:767px){.visible-sm.visible-xs{display:block!important}table.visible-sm.visible-xs{display:table}tr.visible-sm.visible-xs{display:table-row!important}th.visible-sm.visible-xs,td.visible-sm.visible-xs{display:table-cell!important}}@media(min-width:768px) and (max-width:991px){.visible-sm{display:block!important}table.visible-sm{display:table}tr.visible-sm{display:table-row!important}th.visible-sm,td.visible-sm{display:table-cell!important}}@media(min-width:992px) and (max-width:1199px){.visible-sm.visible-md{display:block!important}table.visible-sm.visible-md{display:table}tr.visible-sm.visible-md{display:table-row!important}th.visible-sm.visible-md,td.visible-sm.visible-md{display:table-cell!important}}@media(min-width:1200px){.visible-sm.visible-lg{display:block!important}table.visible-sm.visible-lg{display:table}tr.visible-sm.visible-lg{display:table-row!important}th.visible-sm.visible-lg,td.visible-sm.visible-lg{display:table-cell!important}}.visible-md,tr.visible-md,th.visible-md,td.visible-md{display:none!important}@media(max-width:767px){.visible-md.visible-xs{display:block!important}table.visible-md.visible-xs{display:table}tr.visible-md.visible-xs{display:table-row!important}th.visible-md.visible-xs,td.visible-md.visible-xs{display:table-cell!important}}@media(min-width:768px) and (max-width:991px){.visible-md.visible-sm{display:block!important}table.visible-md.visible-sm{display:table}tr.visible-md.visible-sm{display:table-row!important}th.visible-md.visible-sm,td.visible-md.visible-sm{display:table-cell!important}}@media(min-width:992px) and (max-width:1199px){.visible-md{display:block!important}table.visible-md{display:table}tr.visible-md{display:table-row!important}th.visible-md,td.visible-md{display:table-cell!important}}@media(min-width:1200px){.visible-md.visible-lg{display:block!important}table.visible-md.visible-lg{display:table}tr.visible-md.visible-lg{display:table-row!important}th.visible-md.visible-lg,td.visible-md.visible-lg{display:table-cell!important}}.visible-lg,tr.visible-lg,th.visible-lg,td.visible-lg{display:none!important}@media(max-width:767px){.visible-lg.visible-xs{display:block!important}table.visible-lg.visible-xs{display:table}tr.visible-lg.visible-xs{display:table-row!important}th.visible-lg.visible-xs,td.visible-lg.visible-xs{display:table-cell!important}}@media(min-width:768px) and (max-width:991px){.visible-lg.visible-sm{display:block!important}table.visible-lg.visible-sm{display:table}tr.visible-lg.visible-sm{display:table-row!important}th.visible-lg.visible-sm,td.visible-lg.visible-sm{display:table-cell!important}}@media(min-width:992px) and (max-width:1199px){.visible-lg.visible-md{display:block!important}table.visible-lg.visible-md{display:table}tr.visible-lg.visible-md{display:table-row!important}th.visible-lg.visible-md,td.visible-lg.visible-md{display:table-cell!important}}@media(min-width:1200px){.visible-lg{display:block!important}table.visible-lg{display:table}tr.visible-lg{display:table-row!important}th.visible-lg,td.visible-lg{display:table-cell!important}}.hidden-xs{display:block!important}table.hidden-xs{display:table}tr.hidden-xs{display:table-row!important}th.hidden-xs,td.hidden-xs{display:table-cell!important}@media(max-width:767px){.hidden-xs,tr.hidden-xs,th.hidden-xs,td.hidden-xs{display:none!important}}@media(min-width:768px) and (max-width:991px){.hidden-xs.hidden-sm,tr.hidden-xs.hidden-sm,th.hidden-xs.hidden-sm,td.hidden-xs.hidden-sm{display:none!important}}@media(min-width:992px) and (max-width:1199px){.hidden-xs.hidden-md,tr.hidden-xs.hidden-md,th.hidden-xs.hidden-md,td.hidden-xs.hidden-md{display:none!important}}@media(min-width:1200px){.hidden-xs.hidden-lg,tr.hidden-xs.hidden-lg,th.hidden-xs.hidden-lg,td.hidden-xs.hidden-lg{display:none!important}}.hidden-sm{display:block!important}table.hidden-sm{display:table}tr.hidden-sm{display:table-row!important}th.hidden-sm,td.hidden-sm{display:table-cell!important}@media(max-width:767px){.hidden-sm.hidden-xs,tr.hidden-sm.hidden-xs,th.hidden-sm.hidden-xs,td.hidden-sm.hidden-xs{display:none!important}}@media(min-width:768px) and (max-width:991px){.hidden-sm,tr.hidden-sm,th.hidden-sm,td.hidden-sm{display:none!important}}@media(min-width:992px) and (max-width:1199px){.hidden-sm.hidden-md,tr.hidden-sm.hidden-md,th.hidden-sm.hidden-md,td.hidden-sm.hidden-md{display:none!important}}@media(min-width:1200px){.hidden-sm.hidden-lg,tr.hidden-sm.hidden-lg,th.hidden-sm.hidden-lg,td.hidden-sm.hidden-lg{display:none!important}}.hidden-md{display:block!important}table.hidden-md{display:table}tr.hidden-md{display:table-row!important}th.hidden-md,td.hidden-md{display:table-cell!important}@media(max-width:767px){.hidden-md.hidden-xs,tr.hidden-md.hidden-xs,th.hidden-md.hidden-xs,td.hidden-md.hidden-xs{display:none!important}}@media(min-width:768px) and (max-width:991px){.hidden-md.hidden-sm,tr.hidden-md.hidden-sm,th.hidden-md.hidden-sm,td.hidden-md.hidden-sm{display:none!important}}@media(min-width:992px) and (max-width:1199px){.hidden-md,tr.hidden-md,th.hidden-md,td.hidden-md{display:none!important}}@media(min-width:1200px){.hidden-md.hidden-lg,tr.hidden-md.hidden-lg,th.hidden-md.hidden-lg,td.hidden-md.hidden-lg{display:none!important}}.hidden-lg{display:block!important}table.hidden-lg{display:table}tr.hidden-lg{display:table-row!important}th.hidden-lg,td.hidden-lg{display:table-cell!important}@media(max-width:767px){.hidden-lg.hidden-xs,tr.hidden-lg.hidden-xs,th.hidden-lg.hidden-xs,td.hidden-lg.hidden-xs{display:none!important}}@media(min-width:768px) and (max-width:991px){.hidden-lg.hidden-sm,tr.hidden-lg.hidden-sm,th.hidden-lg.hidden-sm,td.hidden-lg.hidden-sm{display:none!important}}@media(min-width:992px) and (max-width:1199px){.hidden-lg.hidden-md,tr.hidden-lg.hidden-md,th.hidden-lg.hidden-md,td.hidden-lg.hidden-md{display:none!important}}@media(min-width:1200px){.hidden-lg,tr.hidden-lg,th.hidden-lg,td.hidden-lg{display:none!important}}.visible-print,tr.visible-print,th.visible-print,td.visible-print{display:none!important}@media print{.visible-print{display:block!important}table.visible-print{display:table}tr.visible-print{display:table-row!important}th.visible-print,td.visible-print{display:table-cell!important}.hidden-print,tr.hidden-print,th.hidden-print,td.hidden-print{display:none!important}} \ No newline at end of file diff --git a/docs/bootstrap.min.js b/docs/bootstrap.min.js deleted file mode 100644 index 1a6258efc..000000000 --- a/docs/bootstrap.min.js +++ /dev/null @@ -1,7 +0,0 @@ -/*! - * Bootstrap v3.0.3 (http://getbootstrap.com) - * Copyright 2013 Twitter, Inc. - * Licensed under http://www.apache.org/licenses/LICENSE-2.0 - */ - -if("undefined"==typeof jQuery)throw new Error("Bootstrap requires jQuery");+function(a){"use strict";function b(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return{end:b[c]}}a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one(a.support.transition.end,function(){c=!0});var e=function(){c||a(d).trigger(a.support.transition.end)};return setTimeout(e,b),this},a(function(){a.support.transition=b()})}(jQuery),+function(a){"use strict";var b='[data-dismiss="alert"]',c=function(c){a(c).on("click",b,this.close)};c.prototype.close=function(b){function c(){f.trigger("closed.bs.alert").remove()}var d=a(this),e=d.attr("data-target");e||(e=d.attr("href"),e=e&&e.replace(/.*(?=#[^\s]*$)/,""));var f=a(e);b&&b.preventDefault(),f.length||(f=d.hasClass("alert")?d:d.parent()),f.trigger(b=a.Event("close.bs.alert")),b.isDefaultPrevented()||(f.removeClass("in"),a.support.transition&&f.hasClass("fade")?f.one(a.support.transition.end,c).emulateTransitionEnd(150):c())};var d=a.fn.alert;a.fn.alert=function(b){return this.each(function(){var d=a(this),e=d.data("bs.alert");e||d.data("bs.alert",e=new c(this)),"string"==typeof b&&e[b].call(d)})},a.fn.alert.Constructor=c,a.fn.alert.noConflict=function(){return a.fn.alert=d,this},a(document).on("click.bs.alert.data-api",b,c.prototype.close)}(jQuery),+function(a){"use strict";var b=function(c,d){this.$element=a(c),this.options=a.extend({},b.DEFAULTS,d)};b.DEFAULTS={loadingText:"loading..."},b.prototype.setState=function(a){var b="disabled",c=this.$element,d=c.is("input")?"val":"html",e=c.data();a+="Text",e.resetText||c.data("resetText",c[d]()),c[d](e[a]||this.options[a]),setTimeout(function(){"loadingText"==a?c.addClass(b).attr(b,b):c.removeClass(b).removeAttr(b)},0)},b.prototype.toggle=function(){var a=this.$element.closest('[data-toggle="buttons"]'),b=!0;if(a.length){var c=this.$element.find("input");"radio"===c.prop("type")&&(c.prop("checked")&&this.$element.hasClass("active")?b=!1:a.find(".active").removeClass("active")),b&&c.prop("checked",!this.$element.hasClass("active")).trigger("change")}b&&this.$element.toggleClass("active")};var c=a.fn.button;a.fn.button=function(c){return this.each(function(){var d=a(this),e=d.data("bs.button"),f="object"==typeof c&&c;e||d.data("bs.button",e=new b(this,f)),"toggle"==c?e.toggle():c&&e.setState(c)})},a.fn.button.Constructor=b,a.fn.button.noConflict=function(){return a.fn.button=c,this},a(document).on("click.bs.button.data-api","[data-toggle^=button]",function(b){var c=a(b.target);c.hasClass("btn")||(c=c.closest(".btn")),c.button("toggle"),b.preventDefault()})}(jQuery),+function(a){"use strict";var b=function(b,c){this.$element=a(b),this.$indicators=this.$element.find(".carousel-indicators"),this.options=c,this.paused=this.sliding=this.interval=this.$active=this.$items=null,"hover"==this.options.pause&&this.$element.on("mouseenter",a.proxy(this.pause,this)).on("mouseleave",a.proxy(this.cycle,this))};b.DEFAULTS={interval:5e3,pause:"hover",wrap:!0},b.prototype.cycle=function(b){return b||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(a.proxy(this.next,this),this.options.interval)),this},b.prototype.getActiveIndex=function(){return this.$active=this.$element.find(".item.active"),this.$items=this.$active.parent().children(),this.$items.index(this.$active)},b.prototype.to=function(b){var c=this,d=this.getActiveIndex();return b>this.$items.length-1||0>b?void 0:this.sliding?this.$element.one("slid.bs.carousel",function(){c.to(b)}):d==b?this.pause().cycle():this.slide(b>d?"next":"prev",a(this.$items[b]))},b.prototype.pause=function(b){return b||(this.paused=!0),this.$element.find(".next, .prev").length&&a.support.transition.end&&(this.$element.trigger(a.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},b.prototype.next=function(){return this.sliding?void 0:this.slide("next")},b.prototype.prev=function(){return this.sliding?void 0:this.slide("prev")},b.prototype.slide=function(b,c){var d=this.$element.find(".item.active"),e=c||d[b](),f=this.interval,g="next"==b?"left":"right",h="next"==b?"first":"last",i=this;if(!e.length){if(!this.options.wrap)return;e=this.$element.find(".item")[h]()}this.sliding=!0,f&&this.pause();var j=a.Event("slide.bs.carousel",{relatedTarget:e[0],direction:g});if(!e.hasClass("active")){if(this.$indicators.length&&(this.$indicators.find(".active").removeClass("active"),this.$element.one("slid.bs.carousel",function(){var b=a(i.$indicators.children()[i.getActiveIndex()]);b&&b.addClass("active")})),a.support.transition&&this.$element.hasClass("slide")){if(this.$element.trigger(j),j.isDefaultPrevented())return;e.addClass(b),e[0].offsetWidth,d.addClass(g),e.addClass(g),d.one(a.support.transition.end,function(){e.removeClass([b,g].join(" ")).addClass("active"),d.removeClass(["active",g].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger("slid.bs.carousel")},0)}).emulateTransitionEnd(600)}else{if(this.$element.trigger(j),j.isDefaultPrevented())return;d.removeClass("active"),e.addClass("active"),this.sliding=!1,this.$element.trigger("slid.bs.carousel")}return f&&this.cycle(),this}};var c=a.fn.carousel;a.fn.carousel=function(c){return this.each(function(){var d=a(this),e=d.data("bs.carousel"),f=a.extend({},b.DEFAULTS,d.data(),"object"==typeof c&&c),g="string"==typeof c?c:f.slide;e||d.data("bs.carousel",e=new b(this,f)),"number"==typeof c?e.to(c):g?e[g]():f.interval&&e.pause().cycle()})},a.fn.carousel.Constructor=b,a.fn.carousel.noConflict=function(){return a.fn.carousel=c,this},a(document).on("click.bs.carousel.data-api","[data-slide], [data-slide-to]",function(b){var c,d=a(this),e=a(d.attr("data-target")||(c=d.attr("href"))&&c.replace(/.*(?=#[^\s]+$)/,"")),f=a.extend({},e.data(),d.data()),g=d.attr("data-slide-to");g&&(f.interval=!1),e.carousel(f),(g=d.attr("data-slide-to"))&&e.data("bs.carousel").to(g),b.preventDefault()}),a(window).on("load",function(){a('[data-ride="carousel"]').each(function(){var b=a(this);b.carousel(b.data())})})}(jQuery),+function(a){"use strict";var b=function(c,d){this.$element=a(c),this.options=a.extend({},b.DEFAULTS,d),this.transitioning=null,this.options.parent&&(this.$parent=a(this.options.parent)),this.options.toggle&&this.toggle()};b.DEFAULTS={toggle:!0},b.prototype.dimension=function(){var a=this.$element.hasClass("width");return a?"width":"height"},b.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var b=a.Event("show.bs.collapse");if(this.$element.trigger(b),!b.isDefaultPrevented()){var c=this.$parent&&this.$parent.find("> .panel > .in");if(c&&c.length){var d=c.data("bs.collapse");if(d&&d.transitioning)return;c.collapse("hide"),d||c.data("bs.collapse",null)}var e=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[e](0),this.transitioning=1;var f=function(){this.$element.removeClass("collapsing").addClass("in")[e]("auto"),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!a.support.transition)return f.call(this);var g=a.camelCase(["scroll",e].join("-"));this.$element.one(a.support.transition.end,a.proxy(f,this)).emulateTransitionEnd(350)[e](this.$element[0][g])}}},b.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var b=a.Event("hide.bs.collapse");if(this.$element.trigger(b),!b.isDefaultPrevented()){var c=this.dimension();this.$element[c](this.$element[c]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse").removeClass("in"),this.transitioning=1;var d=function(){this.transitioning=0,this.$element.trigger("hidden.bs.collapse").removeClass("collapsing").addClass("collapse")};return a.support.transition?(this.$element[c](0).one(a.support.transition.end,a.proxy(d,this)).emulateTransitionEnd(350),void 0):d.call(this)}}},b.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()};var c=a.fn.collapse;a.fn.collapse=function(c){return this.each(function(){var d=a(this),e=d.data("bs.collapse"),f=a.extend({},b.DEFAULTS,d.data(),"object"==typeof c&&c);e||d.data("bs.collapse",e=new b(this,f)),"string"==typeof c&&e[c]()})},a.fn.collapse.Constructor=b,a.fn.collapse.noConflict=function(){return a.fn.collapse=c,this},a(document).on("click.bs.collapse.data-api","[data-toggle=collapse]",function(b){var c,d=a(this),e=d.attr("data-target")||b.preventDefault()||(c=d.attr("href"))&&c.replace(/.*(?=#[^\s]+$)/,""),f=a(e),g=f.data("bs.collapse"),h=g?"toggle":d.data(),i=d.attr("data-parent"),j=i&&a(i);g&&g.transitioning||(j&&j.find('[data-toggle=collapse][data-parent="'+i+'"]').not(d).addClass("collapsed"),d[f.hasClass("in")?"addClass":"removeClass"]("collapsed")),f.collapse(h)})}(jQuery),+function(a){"use strict";function b(){a(d).remove(),a(e).each(function(b){var d=c(a(this));d.hasClass("open")&&(d.trigger(b=a.Event("hide.bs.dropdown")),b.isDefaultPrevented()||d.removeClass("open").trigger("hidden.bs.dropdown"))})}function c(b){var c=b.attr("data-target");c||(c=b.attr("href"),c=c&&/#/.test(c)&&c.replace(/.*(?=#[^\s]*$)/,""));var d=c&&a(c);return d&&d.length?d:b.parent()}var d=".dropdown-backdrop",e="[data-toggle=dropdown]",f=function(b){a(b).on("click.bs.dropdown",this.toggle)};f.prototype.toggle=function(d){var e=a(this);if(!e.is(".disabled, :disabled")){var f=c(e),g=f.hasClass("open");if(b(),!g){if("ontouchstart"in document.documentElement&&!f.closest(".navbar-nav").length&&a(''}),b.prototype=a.extend({},a.fn.tooltip.Constructor.prototype),b.prototype.constructor=b,b.prototype.getDefaults=function(){return b.DEFAULTS},b.prototype.setContent=function(){var a=this.tip(),b=this.getTitle(),c=this.getContent();a.find(".popover-title")[this.options.html?"html":"text"](b),a.find(".popover-content")[this.options.html?"html":"text"](c),a.removeClass("fade top bottom left right in"),a.find(".popover-title").html()||a.find(".popover-title").hide()},b.prototype.hasContent=function(){return this.getTitle()||this.getContent()},b.prototype.getContent=function(){var a=this.$element,b=this.options;return a.attr("data-content")||("function"==typeof b.content?b.content.call(a[0]):b.content)},b.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")},b.prototype.tip=function(){return this.$tip||(this.$tip=a(this.options.template)),this.$tip};var c=a.fn.popover;a.fn.popover=function(c){return this.each(function(){var d=a(this),e=d.data("bs.popover"),f="object"==typeof c&&c;e||d.data("bs.popover",e=new b(this,f)),"string"==typeof c&&e[c]()})},a.fn.popover.Constructor=b,a.fn.popover.noConflict=function(){return a.fn.popover=c,this}}(jQuery),+function(a){"use strict";function b(c,d){var e,f=a.proxy(this.process,this);this.$element=a(c).is("body")?a(window):a(c),this.$body=a("body"),this.$scrollElement=this.$element.on("scroll.bs.scroll-spy.data-api",f),this.options=a.extend({},b.DEFAULTS,d),this.selector=(this.options.target||(e=a(c).attr("href"))&&e.replace(/.*(?=#[^\s]+$)/,"")||"")+" .nav li > a",this.offsets=a([]),this.targets=a([]),this.activeTarget=null,this.refresh(),this.process()}b.DEFAULTS={offset:10},b.prototype.refresh=function(){var b=this.$element[0]==window?"offset":"position";this.offsets=a([]),this.targets=a([]);var c=this;this.$body.find(this.selector).map(function(){var d=a(this),e=d.data("target")||d.attr("href"),f=/^#\w/.test(e)&&a(e);return f&&f.length&&[[f[b]().top+(!a.isWindow(c.$scrollElement.get(0))&&c.$scrollElement.scrollTop()),e]]||null}).sort(function(a,b){return a[0]-b[0]}).each(function(){c.offsets.push(this[0]),c.targets.push(this[1])})},b.prototype.process=function(){var a,b=this.$scrollElement.scrollTop()+this.options.offset,c=this.$scrollElement[0].scrollHeight||this.$body[0].scrollHeight,d=c-this.$scrollElement.height(),e=this.offsets,f=this.targets,g=this.activeTarget;if(b>=d)return g!=(a=f.last()[0])&&this.activate(a);for(a=e.length;a--;)g!=f[a]&&b>=e[a]&&(!e[a+1]||b<=e[a+1])&&this.activate(f[a])},b.prototype.activate=function(b){this.activeTarget=b,a(this.selector).parents(".active").removeClass("active");var c=this.selector+'[data-target="'+b+'"],'+this.selector+'[href="'+b+'"]',d=a(c).parents("li").addClass("active");d.parent(".dropdown-menu").length&&(d=d.closest("li.dropdown").addClass("active")),d.trigger("activate.bs.scrollspy")};var c=a.fn.scrollspy;a.fn.scrollspy=function(c){return this.each(function(){var d=a(this),e=d.data("bs.scrollspy"),f="object"==typeof c&&c;e||d.data("bs.scrollspy",e=new b(this,f)),"string"==typeof c&&e[c]()})},a.fn.scrollspy.Constructor=b,a.fn.scrollspy.noConflict=function(){return a.fn.scrollspy=c,this},a(window).on("load",function(){a('[data-spy="scroll"]').each(function(){var b=a(this);b.scrollspy(b.data())})})}(jQuery),+function(a){"use strict";var b=function(b){this.element=a(b)};b.prototype.show=function(){var b=this.element,c=b.closest("ul:not(.dropdown-menu)"),d=b.data("target");if(d||(d=b.attr("href"),d=d&&d.replace(/.*(?=#[^\s]*$)/,"")),!b.parent("li").hasClass("active")){var e=c.find(".active:last a")[0],f=a.Event("show.bs.tab",{relatedTarget:e});if(b.trigger(f),!f.isDefaultPrevented()){var g=a(d);this.activate(b.parent("li"),c),this.activate(g,g.parent(),function(){b.trigger({type:"shown.bs.tab",relatedTarget:e})})}}},b.prototype.activate=function(b,c,d){function e(){f.removeClass("active").find("> .dropdown-menu > .active").removeClass("active"),b.addClass("active"),g?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu")&&b.closest("li.dropdown").addClass("active"),d&&d()}var f=c.find("> .active"),g=d&&a.support.transition&&f.hasClass("fade");g?f.one(a.support.transition.end,e).emulateTransitionEnd(150):e(),f.removeClass("in")};var c=a.fn.tab;a.fn.tab=function(c){return this.each(function(){var d=a(this),e=d.data("bs.tab");e||d.data("bs.tab",e=new b(this)),"string"==typeof c&&e[c]()})},a.fn.tab.Constructor=b,a.fn.tab.noConflict=function(){return a.fn.tab=c,this},a(document).on("click.bs.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',function(b){b.preventDefault(),a(this).tab("show")})}(jQuery),+function(a){"use strict";var b=function(c,d){this.options=a.extend({},b.DEFAULTS,d),this.$window=a(window).on("scroll.bs.affix.data-api",a.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",a.proxy(this.checkPositionWithEventLoop,this)),this.$element=a(c),this.affixed=this.unpin=null,this.checkPosition()};b.RESET="affix affix-top affix-bottom",b.DEFAULTS={offset:0},b.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},b.prototype.checkPosition=function(){if(this.$element.is(":visible")){var c=a(document).height(),d=this.$window.scrollTop(),e=this.$element.offset(),f=this.options.offset,g=f.top,h=f.bottom;"object"!=typeof f&&(h=g=f),"function"==typeof g&&(g=f.top()),"function"==typeof h&&(h=f.bottom());var i=null!=this.unpin&&d+this.unpin<=e.top?!1:null!=h&&e.top+this.$element.height()>=c-h?"bottom":null!=g&&g>=d?"top":!1;this.affixed!==i&&(this.unpin&&this.$element.css("top",""),this.affixed=i,this.unpin="bottom"==i?e.top-d:null,this.$element.removeClass(b.RESET).addClass("affix"+(i?"-"+i:"")),"bottom"==i&&this.$element.offset({top:document.body.offsetHeight-h-this.$element.height()}))}};var c=a.fn.affix;a.fn.affix=function(c){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f="object"==typeof c&&c;e||d.data("bs.affix",e=new b(this,f)),"string"==typeof c&&e[c]()})},a.fn.affix.Constructor=b,a.fn.affix.noConflict=function(){return a.fn.affix=c,this},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var b=a(this),c=b.data();c.offset=c.offset||{},c.offsetBottom&&(c.offset.bottom=c.offsetBottom),c.offsetTop&&(c.offset.top=c.offsetTop),b.affix(c)})})}(jQuery); \ No newline at end of file diff --git a/docs/checkpl.yap b/docs/checkpl.yap new file mode 100644 index 000000000..7e4d4970e --- /dev/null +++ b/docs/checkpl.yap @@ -0,0 +1,78 @@ + +:- use_module(library(lists)). +:- use_module(library(lineutils)). +:- use_module(library(system)). + +:- initialization(main). + +:- yap_flag(write_strings,on). + +main :- + S = popen('./get_comments'), + file_filter_with_start_end( S, user_output, add2graph, initgraph, checkgraph). + +initgraph(_,_) :- + retractall(node(_,_,_,_)), + retractall(edge(_,_,_)), + retractall(e_b_n(_,_,_)). + +:- dynamic node/4, edge/3, e_b_n/3. + +checkgraph(_,_) :- + e_b_n(F,KN,_C), + node(_,KF,KN,_), + add_edge(KF, F, KN), + fail. +checkgraph(_,_) :- + listing(node), + listing(edge). + + +add2graph(Line, _Out) :- + writeln(Line), + split( Line, ":@% \t*", [File, Job, Name|_]), + append(Name, R, L), + append( _, L, Line), + !, + dispatch( Name, File, Job, R). + +dispatch( Name, File, "defgroup", Comment):- + atom_codes(KN, Name), + atom_codes(KF, File), + atom_codes(C, Comment), + add_node(KF, KN,C). +dispatch( Name, File, "addtogroup", Comment):- + atom_codes(KN, Name), + atom_codes(KF, File), + atom_codes(C, Comment), + add_node_edge(KF, KN,C). +dispatch( Name, File, "ingroup", Comment):- + atom_codes(KN, Name), + atom_codes(KF, File), + atom_codes(C, Comment), + add_edge(KF, KN,C). +add_node(F, K,_C) :- + node(d,F0,K,_), + !, + throw( repeat(K:F0/F) ). +add_node(F, K,_C) :- + retract(node(d,F1,K,_)), + !, + assert(edge(F,F1,K)), + assert(node(d,F,K,C)). +add_node(F, K,C) :- + assert(node(d,F,K,C)). + + add_node_edge(F, K,_C) :- + node(_,F1,K,_), + !, + assert(edge(F1,F,K)). + add_node_edge(F, K,C) :- + assert(node(a,F,K,C)). + + add_edge(F, K,_C) :- + node(_,F1,K,_), + !, + assert(edge(F1,F,K)). + add_edge(F, K,C) :- + assert(e_b_n(F,K,C)). 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/web/bootstrap/customdoxygen.css b/docs/custom/customdoxygen.css similarity index 67% rename from docs/web/bootstrap/customdoxygen.css rename to docs/custom/customdoxygen.css index 7bf2f5ec1..385656680 100644 --- a/docs/web/bootstrap/customdoxygen.css +++ b/docs/custom/customdoxygen.css @@ -1,98 +1,17 @@ -h1, .h1, h2, .h2, h3, .h3{ - font-weight: 200 !important; -} - +/* Custom Look and feel - Can be edited +----------------------------------- */ #navrow1, #navrow2, #navrow3, #navrow4, #navrow5{ border-bottom: 1px solid #EEEEEE; } .adjust-right { -margin-left: 30px !important; -font-size: 1.15em !important; -} -.navbar{ - border: 0px solid #222 !important; + margin-left: 20px !important; + font-size: 1.00em !important; } - -/* Sticky footer styles --------------------------------------------------- */ -html, -body { - height: 100%; - /* The html and body elements cannot have any padding or margin. */ -} - -/* Wrapper for page content to push down footer */ -#wrap { - min-height: 100%; - height: auto; - /* Negative indent footer by its height */ - margin: 0 auto -60px; - /* Pad bottom by footer height */ - padding: 0 0 60px; -} - -/* Set the fixed height of the footer here */ -#footer { - font-size: 0.9em; - padding: 8px 0px; - background-color: #f5f5f5; -} - -.footer-row { - line-height: 44px; -} - -#footer > .container { - padding-left: 15px; - padding-right: 15px; -} - -.footer-follow-icon { - margin-left: 3px; - text-decoration: none !important; -} - -.footer-follow-icon img { - width: 20px; -} - -.footer-link { - padding-top: 5px; - display: inline-block; - color: #999999; - text-decoration: none; -} - -.footer-copyright { - text-align: center; -} - - -@media (min-width: 992px) { - .footer-row { - text-align: left; - } - - .footer-icons { - text-align: right; - } -} -@media (max-width: 991px) { - .footer-row { - text-align: center; - } - - .footer-icons { - text-align: center; - } -} - -/* DOXYGEN Code Styles +/* DOXYGEN Code Styles - These are from doxygen but can be changed to fit the theme ----------------------------------- */ - a.qindex { font-weight: bold; } diff --git a/docs/doxy-boot.js b/docs/custom/doxy-boot.js similarity index 85% rename from docs/doxy-boot.js rename to docs/custom/doxy-boot.js index 61014d0df..3eba94fe4 100644 --- a/docs/doxy-boot.js +++ b/docs/custom/doxy-boot.js @@ -4,7 +4,7 @@ $( document ).ready(function() { $("div.title").addClass("h1"); $('li > a[href="index.html"] > span').before(" "); - $('li > a[href="index.html"] > span').text("BioGears"); + $('li > a[href="index.html"] > span').text("YAP"); $('li > a[href="modules.html"] > span').before(" "); $('li > a[href="namespaces.html"] > span').before(" "); $('li > a[href="annotated.html"] > span').before(" "); @@ -14,7 +14,7 @@ $( document ).ready(function() { $('li > a[href="functions_func.html"] > span').before(" "); $('li > a[href="functions_vars.html"] > span').before(" "); $('li > a[href="functions_enum.html"] > span').before(" "); - $('li > a[href="functions_YapEval.html"] > span').before(" "); + $('li > a[href="functions_eval.html"] > span').before(" "); $('img[src="ftv2ns.png"]').replaceWith('N '); $('img[src="ftv2cl.png"]').replaceWith('C '); @@ -36,21 +36,22 @@ $( document ).ready(function() { $("div.summary > a").addClass("btn btn-default btn-xs"); $("table.fieldtable").addClass("table"); $(".fragment").addClass("well"); - $(".memitem").addClass("panel panel-default"); - $(".memproto").addClass("panel-heading"); - $(".memdoc").addClass("panel-body"); - $("span.mlabel").addClass("label label-info"); + $(".memitem").addClass("card text-center"); + $(".memproto").addClass("card-title text-center"); + $(".memdoc").addClass("card-body text-right); + // $("span.mlabel").addClass("card-link label-info"); + $("table.memberdecls").addClass("table"); $("[class^=memitem]").addClass("active"); $("div.ah").addClass("btn btn-default"); $("span.mlabels").addClass("pull-right"); - $("table.mlabels").css("width", "100%") + $("span.mlabels").css("width", "100%") $("td.mlabels-right").addClass("pull-right"); $("div.ttc").addClass("panel panel-primary"); - $("div.ttname").addClass("panel-heading"); + //$("div.ttname").addClass("panel-heading"); $("div.ttname a").css("color", 'white'); $("div.ttdef,div.ttdoc,div.ttdeci").addClass("panel-body"); @@ -59,10 +60,10 @@ $( document ).ready(function() { $('div.fragment.well div.line:first').css('margin-top', '15px'); $('div.fragment.well div.line:last').css('margin-bottom', '15px'); - $('table.doxtable').removeClass('doxtable').addClass('table table-striped table-bordered').each(function(){ - $(this).prepend(''); + $('table.doxtable').removeClass('doxtable').addClass('table table-striped table-bordered table-small;').each(function(){ + $(this).prepend('firstLasts'); $(this).find('tbody > tr:first').prependTo($(this).find('thead')); - + $(this).bootstrapTable('remove', {class: 'separator'}); $(this).find('td > span.success').parent().addClass('success'); $(this).find('td > span.warning').parent().addClass('warning'); $(this).find('td > span.danger').parent().addClass('danger'); @@ -93,6 +94,7 @@ $( document ).ready(function() { $(".memitem").removeClass('memitem'); $(".memproto").removeClass('memproto'); + $(".separator").removeClass('separator'); $(".memdoc").removeClass('memdoc'); $("span.mlabel").removeClass('mlabel'); $("table.memberdecls").removeClass('memberdecls'); @@ -118,4 +120,4 @@ $( document ).ready(function() { $(this).siblings('.memItemRight').remove(); } }); -}); \ No newline at end of file +}); diff --git a/docs/custom/footer.html b/docs/custom/footer.html new file mode 100644 index 000000000..152fb77ff --- /dev/null +++ b/docs/custom/footer.html @@ -0,0 +1,21 @@ + + + + + + + + + + diff --git a/docs/custom/header.html b/docs/custom/header.html new file mode 100644 index 000000000..6f76bc496 --- /dev/null +++ b/docs/custom/header.html @@ -0,0 +1,67 @@ + + + + + + + + + + + + + $projectname: $title +$title + + + $search +$mathjax + + + +$extrastylesheet + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $treeview + + diff --git a/docs/font-awesome.min.css b/docs/font-awesome.min.css deleted file mode 100644 index 449d6ac55..000000000 --- a/docs/font-awesome.min.css +++ /dev/null @@ -1,4 +0,0 @@ -/*! - * Font Awesome 4.0.3 by @davegandy - http://fontawesome.io - @fontawesome - * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) - */@font-face{font-family:'FontAwesome';src:url('../fonts/fontawesome-webfont.eot?v=4.0.3');src:url('../fonts/fontawesome-webfont.eot?#iefix&v=4.0.3') format('embedded-opentype'),url('../fonts/fontawesome-webfont.woff?v=4.0.3') format('woff'),url('../fonts/fontawesome-webfont.ttf?v=4.0.3') format('truetype'),url('../fonts/fontawesome-webfont.svg?v=4.0.3#fontawesomeregular') format('svg');font-weight:normal;font-style:normal}.fa{display:inline-block;font-family:FontAwesome;font-style:normal;font-weight:normal;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.fa-lg{font-size:1.3333333333333333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.2857142857142858em;text-align:center}.fa-ul{padding-left:0;margin-left:2.142857142857143em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.142857142857143em;width:2.142857142857143em;top:.14285714285714285em;text-align:center}.fa-li.fa-lg{left:-1.8571428571428572em}.fa-border{padding:.2em .25em .15em;border:solid .08em #eee;border-radius:.1em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:spin 2s infinite linear;-moz-animation:spin 2s infinite linear;-o-animation:spin 2s infinite linear;animation:spin 2s infinite linear}@-moz-keyframes spin{0%{-moz-transform:rotate(0deg)}100%{-moz-transform:rotate(359deg)}}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg)}}@-o-keyframes spin{0%{-o-transform:rotate(0deg)}100%{-o-transform:rotate(359deg)}}@-ms-keyframes spin{0%{-ms-transform:rotate(0deg)}100%{-ms-transform:rotate(359deg)}}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(359deg)}}.fa-rotate-90{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1);-webkit-transform:rotate(90deg);-moz-transform:rotate(90deg);-ms-transform:rotate(90deg);-o-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2);-webkit-transform:rotate(180deg);-moz-transform:rotate(180deg);-ms-transform:rotate(180deg);-o-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);-webkit-transform:rotate(270deg);-moz-transform:rotate(270deg);-ms-transform:rotate(270deg);-o-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=0,mirror=1);-webkit-transform:scale(-1,1);-moz-transform:scale(-1,1);-ms-transform:scale(-1,1);-o-transform:scale(-1,1);transform:scale(-1,1)}.fa-flip-vertical{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2,mirror=1);-webkit-transform:scale(1,-1);-moz-transform:scale(1,-1);-ms-transform:scale(1,-1);-o-transform:scale(1,-1);transform:scale(1,-1)}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-envelope-o:before{content:"\f003"}.fa-heart:before{content:"\f004"}.fa-star:before{content:"\f005"}.fa-star-o:before{content:"\f006"}.fa-user:before{content:"\f007"}.fa-film:before{content:"\f008"}.fa-th-large:before{content:"\f009"}.fa-th:before{content:"\f00a"}.fa-th-list:before{content:"\f00b"}.fa-check:before{content:"\f00c"}.fa-times:before{content:"\f00d"}.fa-search-plus:before{content:"\f00e"}.fa-search-minus:before{content:"\f010"}.fa-power-off:before{content:"\f011"}.fa-signal:before{content:"\f012"}.fa-gear:before,.fa-cog:before{content:"\f013"}.fa-trash-o:before{content:"\f014"}.fa-home:before{content:"\f015"}.fa-file-o:before{content:"\f016"}.fa-clock-o:before{content:"\f017"}.fa-road:before{content:"\f018"}.fa-download:before{content:"\f019"}.fa-arrow-circle-o-down:before{content:"\f01a"}.fa-arrow-circle-o-up:before{content:"\f01b"}.fa-inbox:before{content:"\f01c"}.fa-play-circle-o:before{content:"\f01d"}.fa-rotate-right:before,.fa-repeat:before{content:"\f01e"}.fa-refresh:before{content:"\f021"}.fa-list-alt:before{content:"\f022"}.fa-lock:before{content:"\f023"}.fa-flag:before{content:"\f024"}.fa-headphones:before{content:"\f025"}.fa-volume-off:before{content:"\f026"}.fa-volume-down:before{content:"\f027"}.fa-volume-up:before{content:"\f028"}.fa-qrcode:before{content:"\f029"}.fa-barcode:before{content:"\f02a"}.fa-tag:before{content:"\f02b"}.fa-tags:before{content:"\f02c"}.fa-book:before{content:"\f02d"}.fa-bookmark:before{content:"\f02e"}.fa-print:before{content:"\f02f"}.fa-camera:before{content:"\f030"}.fa-font:before{content:"\f031"}.fa-bold:before{content:"\f032"}.fa-italic:before{content:"\f033"}.fa-text-height:before{content:"\f034"}.fa-text-width:before{content:"\f035"}.fa-align-left:before{content:"\f036"}.fa-align-center:before{content:"\f037"}.fa-align-right:before{content:"\f038"}.fa-align-justify:before{content:"\f039"}.fa-list:before{content:"\f03a"}.fa-dedent:before,.fa-outdent:before{content:"\f03b"}.fa-indent:before{content:"\f03c"}.fa-video-camera:before{content:"\f03d"}.fa-picture-o:before{content:"\f03e"}.fa-pencil:before{content:"\f040"}.fa-map-marker:before{content:"\f041"}.fa-adjust:before{content:"\f042"}.fa-tint:before{content:"\f043"}.fa-edit:before,.fa-pencil-square-o:before{content:"\f044"}.fa-share-square-o:before{content:"\f045"}.fa-check-square-o:before{content:"\f046"}.fa-arrows:before{content:"\f047"}.fa-step-backward:before{content:"\f048"}.fa-fast-backward:before{content:"\f049"}.fa-backward:before{content:"\f04a"}.fa-play:before{content:"\f04b"}.fa-pause:before{content:"\f04c"}.fa-stop:before{content:"\f04d"}.fa-forward:before{content:"\f04e"}.fa-fast-forward:before{content:"\f050"}.fa-step-forward:before{content:"\f051"}.fa-eject:before{content:"\f052"}.fa-chevron-left:before{content:"\f053"}.fa-chevron-right:before{content:"\f054"}.fa-plus-circle:before{content:"\f055"}.fa-minus-circle:before{content:"\f056"}.fa-times-circle:before{content:"\f057"}.fa-check-circle:before{content:"\f058"}.fa-question-circle:before{content:"\f059"}.fa-info-circle:before{content:"\f05a"}.fa-crosshairs:before{content:"\f05b"}.fa-times-circle-o:before{content:"\f05c"}.fa-check-circle-o:before{content:"\f05d"}.fa-ban:before{content:"\f05e"}.fa-arrow-left:before{content:"\f060"}.fa-arrow-right:before{content:"\f061"}.fa-arrow-up:before{content:"\f062"}.fa-arrow-down:before{content:"\f063"}.fa-mail-forward:before,.fa-share:before{content:"\f064"}.fa-expand:before{content:"\f065"}.fa-compress:before{content:"\f066"}.fa-plus:before{content:"\f067"}.fa-minus:before{content:"\f068"}.fa-asterisk:before{content:"\f069"}.fa-exclamation-circle:before{content:"\f06a"}.fa-gift:before{content:"\f06b"}.fa-leaf:before{content:"\f06c"}.fa-fire:before{content:"\f06d"}.fa-eye:before{content:"\f06e"}.fa-eye-slash:before{content:"\f070"}.fa-warning:before,.fa-exclamation-triangle:before{content:"\f071"}.fa-plane:before{content:"\f072"}.fa-calendar:before{content:"\f073"}.fa-random:before{content:"\f074"}.fa-comment:before{content:"\f075"}.fa-magnet:before{content:"\f076"}.fa-chevron-up:before{content:"\f077"}.fa-chevron-down:before{content:"\f078"}.fa-retweet:before{content:"\f079"}.fa-shopping-cart:before{content:"\f07a"}.fa-folder:before{content:"\f07b"}.fa-folder-open:before{content:"\f07c"}.fa-arrows-v:before{content:"\f07d"}.fa-arrows-h:before{content:"\f07e"}.fa-bar-chart-o:before{content:"\f080"}.fa-twitter-square:before{content:"\f081"}.fa-facebook-square:before{content:"\f082"}.fa-camera-retro:before{content:"\f083"}.fa-key:before{content:"\f084"}.fa-gears:before,.fa-cogs:before{content:"\f085"}.fa-comments:before{content:"\f086"}.fa-thumbs-o-up:before{content:"\f087"}.fa-thumbs-o-down:before{content:"\f088"}.fa-star-half:before{content:"\f089"}.fa-heart-o:before{content:"\f08a"}.fa-sign-out:before{content:"\f08b"}.fa-linkedin-square:before{content:"\f08c"}.fa-thumb-tack:before{content:"\f08d"}.fa-external-link:before{content:"\f08e"}.fa-sign-in:before{content:"\f090"}.fa-trophy:before{content:"\f091"}.fa-github-square:before{content:"\f092"}.fa-upload:before{content:"\f093"}.fa-lemon-o:before{content:"\f094"}.fa-phone:before{content:"\f095"}.fa-square-o:before{content:"\f096"}.fa-bookmark-o:before{content:"\f097"}.fa-phone-square:before{content:"\f098"}.fa-twitter:before{content:"\f099"}.fa-facebook:before{content:"\f09a"}.fa-github:before{content:"\f09b"}.fa-unlock:before{content:"\f09c"}.fa-credit-card:before{content:"\f09d"}.fa-rss:before{content:"\f09e"}.fa-hdd-o:before{content:"\f0a0"}.fa-bullhorn:before{content:"\f0a1"}.fa-bell:before{content:"\f0f3"}.fa-certificate:before{content:"\f0a3"}.fa-hand-o-right:before{content:"\f0a4"}.fa-hand-o-left:before{content:"\f0a5"}.fa-hand-o-up:before{content:"\f0a6"}.fa-hand-o-down:before{content:"\f0a7"}.fa-arrow-circle-left:before{content:"\f0a8"}.fa-arrow-circle-right:before{content:"\f0a9"}.fa-arrow-circle-up:before{content:"\f0aa"}.fa-arrow-circle-down:before{content:"\f0ab"}.fa-globe:before{content:"\f0ac"}.fa-wrench:before{content:"\f0ad"}.fa-tasks:before{content:"\f0ae"}.fa-filter:before{content:"\f0b0"}.fa-briefcase:before{content:"\f0b1"}.fa-arrows-alt:before{content:"\f0b2"}.fa-group:before,.fa-users:before{content:"\f0c0"}.fa-chain:before,.fa-link:before{content:"\f0c1"}.fa-cloud:before{content:"\f0c2"}.fa-flask:before{content:"\f0c3"}.fa-cut:before,.fa-scissors:before{content:"\f0c4"}.fa-copy:before,.fa-files-o:before{content:"\f0c5"}.fa-paperclip:before{content:"\f0c6"}.fa-save:before,.fa-floppy-o:before{content:"\f0c7"}.fa-square:before{content:"\f0c8"}.fa-bars:before{content:"\f0c9"}.fa-list-ul:before{content:"\f0ca"}.fa-list-ol:before{content:"\f0cb"}.fa-strikethrough:before{content:"\f0cc"}.fa-underline:before{content:"\f0cd"}.fa-table:before{content:"\f0ce"}.fa-magic:before{content:"\f0d0"}.fa-truck:before{content:"\f0d1"}.fa-pinterest:before{content:"\f0d2"}.fa-pinterest-square:before{content:"\f0d3"}.fa-google-plus-square:before{content:"\f0d4"}.fa-google-plus:before{content:"\f0d5"}.fa-money:before{content:"\f0d6"}.fa-caret-down:before{content:"\f0d7"}.fa-caret-up:before{content:"\f0d8"}.fa-caret-left:before{content:"\f0d9"}.fa-caret-right:before{content:"\f0da"}.fa-columns:before{content:"\f0db"}.fa-unsorted:before,.fa-sort:before{content:"\f0dc"}.fa-sort-down:before,.fa-sort-asc:before{content:"\f0dd"}.fa-sort-up:before,.fa-sort-desc:before{content:"\f0de"}.fa-envelope:before{content:"\f0e0"}.fa-linkedin:before{content:"\f0e1"}.fa-rotate-left:before,.fa-undo:before{content:"\f0e2"}.fa-legal:before,.fa-gavel:before{content:"\f0e3"}.fa-dashboard:before,.fa-tachometer:before{content:"\f0e4"}.fa-comment-o:before{content:"\f0e5"}.fa-comments-o:before{content:"\f0e6"}.fa-flash:before,.fa-bolt:before{content:"\f0e7"}.fa-sitemap:before{content:"\f0e8"}.fa-umbrella:before{content:"\f0e9"}.fa-paste:before,.fa-clipboard:before{content:"\f0ea"}.fa-lightbulb-o:before{content:"\f0eb"}.fa-exchange:before{content:"\f0ec"}.fa-cloud-download:before{content:"\f0ed"}.fa-cloud-upload:before{content:"\f0ee"}.fa-user-md:before{content:"\f0f0"}.fa-stethoscope:before{content:"\f0f1"}.fa-suitcase:before{content:"\f0f2"}.fa-bell-o:before{content:"\f0a2"}.fa-coffee:before{content:"\f0f4"}.fa-cutlery:before{content:"\f0f5"}.fa-file-text-o:before{content:"\f0f6"}.fa-building-o:before{content:"\f0f7"}.fa-hospital-o:before{content:"\f0f8"}.fa-ambulance:before{content:"\f0f9"}.fa-medkit:before{content:"\f0fa"}.fa-fighter-jet:before{content:"\f0fb"}.fa-beer:before{content:"\f0fc"}.fa-h-square:before{content:"\f0fd"}.fa-plus-square:before{content:"\f0fe"}.fa-angle-double-left:before{content:"\f100"}.fa-angle-double-right:before{content:"\f101"}.fa-angle-double-up:before{content:"\f102"}.fa-angle-double-down:before{content:"\f103"}.fa-angle-left:before{content:"\f104"}.fa-angle-right:before{content:"\f105"}.fa-angle-up:before{content:"\f106"}.fa-angle-down:before{content:"\f107"}.fa-desktop:before{content:"\f108"}.fa-laptop:before{content:"\f109"}.fa-tablet:before{content:"\f10a"}.fa-mobile-phone:before,.fa-mobile:before{content:"\f10b"}.fa-circle-o:before{content:"\f10c"}.fa-quote-left:before{content:"\f10d"}.fa-quote-right:before{content:"\f10e"}.fa-spinner:before{content:"\f110"}.fa-circle:before{content:"\f111"}.fa-mail-reply:before,.fa-reply:before{content:"\f112"}.fa-github-alt:before{content:"\f113"}.fa-folder-o:before{content:"\f114"}.fa-folder-open-o:before{content:"\f115"}.fa-smile-o:before{content:"\f118"}.fa-frown-o:before{content:"\f119"}.fa-meh-o:before{content:"\f11a"}.fa-gamepad:before{content:"\f11b"}.fa-keyboard-o:before{content:"\f11c"}.fa-flag-o:before{content:"\f11d"}.fa-flag-checkered:before{content:"\f11e"}.fa-terminal:before{content:"\f120"}.fa-code:before{content:"\f121"}.fa-reply-all:before{content:"\f122"}.fa-mail-reply-all:before{content:"\f122"}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:"\f123"}.fa-location-arrow:before{content:"\f124"}.fa-crop:before{content:"\f125"}.fa-code-fork:before{content:"\f126"}.fa-unlink:before,.fa-chain-broken:before{content:"\f127"}.fa-question:before{content:"\f128"}.fa-info:before{content:"\f129"}.fa-exclamation:before{content:"\f12a"}.fa-superscript:before{content:"\f12b"}.fa-subscript:before{content:"\f12c"}.fa-eraser:before{content:"\f12d"}.fa-puzzle-piece:before{content:"\f12e"}.fa-microphone:before{content:"\f130"}.fa-microphone-slash:before{content:"\f131"}.fa-shield:before{content:"\f132"}.fa-calendar-o:before{content:"\f133"}.fa-fire-extinguisher:before{content:"\f134"}.fa-rocket:before{content:"\f135"}.fa-maxcdn:before{content:"\f136"}.fa-chevron-circle-left:before{content:"\f137"}.fa-chevron-circle-right:before{content:"\f138"}.fa-chevron-circle-up:before{content:"\f139"}.fa-chevron-circle-down:before{content:"\f13a"}.fa-html5:before{content:"\f13b"}.fa-css3:before{content:"\f13c"}.fa-anchor:before{content:"\f13d"}.fa-unlock-alt:before{content:"\f13e"}.fa-bullseye:before{content:"\f140"}.fa-ellipsis-h:before{content:"\f141"}.fa-ellipsis-v:before{content:"\f142"}.fa-rss-square:before{content:"\f143"}.fa-play-circle:before{content:"\f144"}.fa-ticket:before{content:"\f145"}.fa-minus-square:before{content:"\f146"}.fa-minus-square-o:before{content:"\f147"}.fa-level-up:before{content:"\f148"}.fa-level-down:before{content:"\f149"}.fa-check-square:before{content:"\f14a"}.fa-pencil-square:before{content:"\f14b"}.fa-external-link-square:before{content:"\f14c"}.fa-share-square:before{content:"\f14d"}.fa-compass:before{content:"\f14e"}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:"\f150"}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:"\f151"}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:"\f152"}.fa-euro:before,.fa-eur:before{content:"\f153"}.fa-gbp:before{content:"\f154"}.fa-dollar:before,.fa-usd:before{content:"\f155"}.fa-rupee:before,.fa-inr:before{content:"\f156"}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:"\f157"}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:"\f158"}.fa-won:before,.fa-krw:before{content:"\f159"}.fa-bitcoin:before,.fa-btc:before{content:"\f15a"}.fa-file:before{content:"\f15b"}.fa-file-text:before{content:"\f15c"}.fa-sort-alpha-asc:before{content:"\f15d"}.fa-sort-alpha-desc:before{content:"\f15e"}.fa-sort-amount-asc:before{content:"\f160"}.fa-sort-amount-desc:before{content:"\f161"}.fa-sort-numeric-asc:before{content:"\f162"}.fa-sort-numeric-desc:before{content:"\f163"}.fa-thumbs-up:before{content:"\f164"}.fa-thumbs-down:before{content:"\f165"}.fa-youtube-square:before{content:"\f166"}.fa-youtube:before{content:"\f167"}.fa-xing:before{content:"\f168"}.fa-xing-square:before{content:"\f169"}.fa-youtube-play:before{content:"\f16a"}.fa-dropbox:before{content:"\f16b"}.fa-stack-overflow:before{content:"\f16c"}.fa-instagram:before{content:"\f16d"}.fa-flickr:before{content:"\f16e"}.fa-adn:before{content:"\f170"}.fa-bitbucket:before{content:"\f171"}.fa-bitbucket-square:before{content:"\f172"}.fa-tumblr:before{content:"\f173"}.fa-tumblr-square:before{content:"\f174"}.fa-long-arrow-down:before{content:"\f175"}.fa-long-arrow-up:before{content:"\f176"}.fa-long-arrow-left:before{content:"\f177"}.fa-long-arrow-right:before{content:"\f178"}.fa-apple:before{content:"\f179"}.fa-windows:before{content:"\f17a"}.fa-android:before{content:"\f17b"}.fa-linux:before{content:"\f17c"}.fa-dribbble:before{content:"\f17d"}.fa-skype:before{content:"\f17e"}.fa-foursquare:before{content:"\f180"}.fa-trello:before{content:"\f181"}.fa-female:before{content:"\f182"}.fa-male:before{content:"\f183"}.fa-gittip:before{content:"\f184"}.fa-sun-o:before{content:"\f185"}.fa-moon-o:before{content:"\f186"}.fa-archive:before{content:"\f187"}.fa-bug:before{content:"\f188"}.fa-vk:before{content:"\f189"}.fa-weibo:before{content:"\f18a"}.fa-renren:before{content:"\f18b"}.fa-pagelines:before{content:"\f18c"}.fa-stack-exchange:before{content:"\f18d"}.fa-arrow-circle-o-right:before{content:"\f18e"}.fa-arrow-circle-o-left:before{content:"\f190"}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:"\f191"}.fa-dot-circle-o:before{content:"\f192"}.fa-wheelchair:before{content:"\f193"}.fa-vimeo-square:before{content:"\f194"}.fa-turkish-lira:before,.fa-try:before{content:"\f195"}.fa-plus-square-o:before{content:"\f196"} \ No newline at end of file diff --git a/docs/md/INSTALL.md b/docs/md/INSTALL.md index b663e630a..d2042b8d8 100644 --- a/docs/md/INSTALL.md +++ b/docs/md/INSTALL.md @@ -1,18 +1,20 @@ +Downloading and Installing YAP {#INSTALL} +=========================== + +This text includes instructions to download and install YAP. +[TOC] -Installing YAP {#install} -============== - -### Downloading YAP {#download} +## Downloading YAP {#Download} The latest development version of Yap-6 is available source-only through GIT repositories. The main reference repository is at - + [github](https://github.com/vscosta/yap-6.3) ++ development branch: [github](https://github.com/vscosta/yap-6.3) We store an older version of YAP at: - + [sourceforge](http://sourceforge.net/p/yap/yap-6.3) ++ snapshots: [sourceforge](http://sourceforge.net/p/yap/yap-6.3) Please just use `git clone` to obtain the distribution. Ie, to download YAP from the command line please type: @@ -24,36 +26,39 @@ The first argument is the repository, the last argument is the (optional) target There are a variety of graphical interfaces to `git`, including GitHub's own [GitHub Desktop](https://desktop.github.com/) that supports Microsoft Windows and Apple OSX. A list with GUI applications, editor integration, and much more can be found at the [git Wiki](https://git.wiki.kernel.org/index.php/InterfacesFrontendsAndTools), -#### Download Options +### Download Options It may be useful to know: - + If you are have limited bandwith or disk spaceq, consider using - `git clone --depth XX` to only include the last `XX` commits. ++ If you are have limited bandwith or disk spaceq, consider using +~~~~~ +git clone --depth XX +~~~~~ +to only include the last `XX` commits. - + Older versions of YAP were distributed with modules. YAP-6.3.5 is ++ Older versions of YAP were distributed with modules. YAP-6.3.5 is a single package, and it does not need `git submodule`. - + The GitHub site includes a number of companion packages for YAP, ++ The GitHub site includes a number of companion packages for YAP, including [doxygen-yap](https://github.com/vscosta/doxygen-yap), a version of doxygen adapted to Prolog that was used to generate these documents. -### Compiling YAP {#CompilingYAP} -------------- +## CompilingYAP Compiling YAP + YAP-6.3.4 is a [cmake](www.cmake.org) based system. We use `cmake` because it supports mosts popular software, can generate Makefiles, Ninja, Apple's XCode, VisualStudio and ANdroid Studio, and because it includes packaging suppport, The steps required -to install core YAP under `cmake`: +to install core YAP under `cmake` are presented in detail next. -##### `C/C++` compiler +### Compilation The compiler *Status as of early 2017* YAP should compile well under the [GNU-CC](https://gcc.gnu.org/) - and the [C-LANG]https://clang.llvm.org/() families, that are + and the [C-LANG](https://clang.llvm.org/) families, that are available across most configurations. It sshould also compile well undder Intel `icc`. @@ -65,7 +70,7 @@ to install core YAP under `cmake`: YAP compiles cleanly under cross-compilers, and we have used the crosss-compilation system [mxe](http://mxe.cc/) system with good results. -##### `cmake` +### cmake All Linux and BSD distributions include `cmake`, so does [Homebrew](https://brew.sh/) @@ -75,33 +80,33 @@ and [cygwin](http://www.cygwin.org/) for WIN32. Android Studio has native support for `cmake`since 2.1, although we advise to use 2.2. Last, there are excellent plugins for the Visual Codes. In case you need a recent version, consider using pre-compiled binaries at -the [CMake site](https://www.cmake.org). +the [CMake site](https://www.cmake.org). If you have an older Linux you may need to compile from source, available at GitHub. -##### Ensure that you have other necessary packages installed: +### Ensure that you have other necessary packages installed: + YAP requires [gmp]{https://gmplib.org/} for infinite precision integer and rational. Please ensure the development pacakage is installed in Linux: `(lib)gmp-dev(el). In the Mac and WIN32, you can obtain GMPlib from the pakage collections mentioned above. - + The [MPIR]{http://mpir.org} library is compatible with GMPlib, and has good support for VC++. - + + The [readline]() library provides line-editing and command history. In Linux, make sure you have the development package. - + Readline is disabled by default in WIN32. OSX is distributed with a line editing library that includes a subset of readline. We advise against using that library. - + - To use YAP as a library in [Python]() you need the [SWIG]() interface generator and python3-dev. SWIG and Python binaries can be easily obtained for all these platfors - + make sure to install Python-3, and not Python-2, - -##### Compile and Install + + make sure to install Python-3, and not Python-2, + +### Compiling Compile and Install 1: Create a directory, say `Build` and `cd` to the directory (`cd Build`). *YAP should not be compiled at its rootxo directory, some packages do not allow for that. @@ -115,15 +120,14 @@ available at GitHub. 5: If you feel satisfied with the result, do `make install`. * In most systems you will need to be superuser in order to do `make install` and `make info` on the standard directories. -Tuning the Functionality of YAP -------------------------------- +#### Tuning the Functionality of YAP By default, YAP supports tabling, depth first search, and most features found in modern Prologs. In some cases, you may want to suport extra features, or reduce system size. `cmake`provides an graphical interface for doing so. From the commmand line, a typical example could be: ~~~~~ -cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~ /users/vsc/src/yap +Cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~ /users/vsc/src/yap ~~~~~ The first argument says that this is a release, compiled with full optimisation. The second argument says YAP should install under the ~ drectory. In this case, YAP will add the binaries to /users/vsc/bin, include files to `/users/vsc/include/Yap`, Prolog files to `/users/vsc/share/Yap`, and ay DLL to `/users/vsc/lib/Yap`. @@ -177,53 +181,53 @@ You can also use `xcodebuild` from the command line. Bext follow instructions to fully compile YAP: -#### Compilation Notes for OSX/Brew +### Compilation Notes for OSX/Brew Next follows a detailed description of a full install of YAP, including all the packages that YAP can use: - 1. Install the XCode toolkit from the Apple App Store (you may have to register as a developer). + 1. Install the XCode toolkit from the Apple App Store (you may have to register as a developer). - 2. Install a package manager, such as [brew](http://brew.sh), + 2. Install a package manager, such as [brew](http://brew.sh), - 3. You will need `cmake` and `gmp`: both are available in brew. + 3. You will need `cmake` and `gmp`: both are available in brew. - 4. other brew packages you may want to install: `gecode`, `libxml2`, `openssl`, + 4. other brew packages you may want to install: `gecode`, `libxml2`, `openssl`, `mariadb`, `openmpi`, `postgresql`, `raptor`, `sqlite3`, `swig`, `unixodbc`. Note that some of them may be preconditions to other packages. - 5. to install [cudd](http://vlsi.colorado.edu/~fabio/CUDD), a package used by ProbLog and cplint, just use: + 5. to install [cudd](http://vlsi.colorado.edu/~fabio/CUDD), a package used by ProbLog and cplint, just use: ~~~~~ brew tap mht208/formal brew install cudd ~~~~~ - 6. To use [R](https://www.r-project.org), you must download the `R` distribution from one of the many `R` mirrors. + 6. To use [R](https://www.r-project.org), you must download the `R` distribution from one of the many `R` mirrors. - 6. To use [Java](https://www.java.com), you should download the Oracle distributed JDK. + 6. To use [Java](https://www.java.com), you should download the Oracle distributed JDK. - 6. When installing [Python](https://www.python.org), verify which python you + 6. When installing [Python](https://www.python.org), verify which python you are using. - 7. There may be conflict between original OSX and the brew packages (eg, `openssl`, `python`, and `sqlite3`. If you prefer leaning on brew: + 7. There may be conflict between original OSX and the brew packages (eg, `openssl`, `python`, and `sqlite3`. If you prefer leaning on brew: ~~~~~ cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl .. ~~~~~ - #### Compilation Notes for Android +### Compilation Notes for Android Next we present the compilation process for Android. The environment is an OSX, but steps should be similar for Linux machines. We assume you have downloaded both the Android NDK and the Android SDK. - 1. Reserve a directory for compilation: +1. Reserve a directory for compilation: ~~~~~ mkdir android cd android ~~~~~ - 2. Get the [GMP-android](https://github.com/Rupan/gmp) port. +2. Get the [GMP-android](https://github.com/Rupan/gmp) port. - 2. Call `cmake`: +2. Call `cmake`: ~~~~~ export ANDROID_NDK=/Volumes/Transcend/vsc/android-ndk-r11c; \ export ANDROID_SDK=/Volumes/Transcend/vsc/AndroidSDK;\ diff --git a/docs/md/attributes.md b/docs/md/attributes.md new file mode 100644 index 000000000..2d38a970a --- /dev/null +++ b/docs/md/attributes.md @@ -0,0 +1,400 @@ + + +@defgroup AttributedVariables Attributed Variables + +@{ + + +@ingroup extensions + +YAP supports attributed variables, originally developed at OFAI by +Christian Holzbaur. Attributes are a means of declaring that an + arbitrary term is a property for a variable. These properties can be +updated during forward execution. Moreover, the unification algorithm is +aware of attributed variables and will call user defined handlers when + trying to unify these variables. + +Attributed variables provide an elegant abstraction over which one can +extend Prolog systems. Their main application so far has been in +implementing constraint handlers, such as Holzbaur's CLPQR, Fruewirth +and Holzbaur's CHR, and CLP(BN). + +Different Prolog systems implement attributed variables in different +ways. Originally, YAP used the interface designed by SICStus +Prolog. This interface is still +available through the atts library, and is used by CLPBN. + +From YAP-6.0.3 onwards we recommend using the hProlog, SWI style +interface. We believe that this design is easier to understand and +work with. Most packages included in YAP that use attributed +variables, such as CHR, CLP(FD), and CLP(QR), rely on the SWI-Prolog +awi interface. + +@defgroup SICS_attributes SICStus Style attribute declarations. + +@{ +@ingroup AttributedVariables + +The YAP library `atts` implements attribute variables in the style of +SICStus Prolog. Attributed variables work as follows: + ++ Each attribute must be declared beforehand. Attributes are described +as a functor with name and arity and are local to a module. Each +Prolog module declares its own sets of attributes. Different modules +may have attributes with the same name and arity. + ++ The built-in put_atts/2 adds or deletes attributes to a +variable. The variable may be unbound or may be an attributed +variable. In the latter case, YAP discards previous values for the +attributes. + ++ The built-in get_atts/2 can be used to check the values of +an attribute associated with a variable. + ++ The unification algorithm calls the user-defined predicate +verify_attributes/3 before trying to bind an attributed +variable. Unification will resume after this call. + ++ The user-defined predicate +attribute_goal/2 converts from an attribute to a goal. + ++ The user-defined predicate +project_attributes/2 is used from a set of variables into a set of +constraints or goals. One application of project_attributes/2 is in +the top-level, where it is used to output the set of +floundered constraints at the end of a query. + + +Attributes are compound terms associated with a variable. Each attribute +has a name which is private to the module in which the +attribute was defined. Variables may have at most one attribute with a +name. Attribute names are defined through the following declaration: + +~~~~~ +:- attribute AttributeSpec, ..., AttributeSpec. +~~~~~ + +where each _AttributeSpec_ has the form ( _Name_/ _Arity_). +One single such declaration is allowed per module _Module_. + +Although the YAP module system is predicate based, attributes are local +to modules. This is implemented by rewriting all calls to the +built-ins that manipulate attributes so that attribute names are +preprocessed depending on the module. The `user:goal_expansion/3` +mechanism is used for this purpose. + + +The attribute manipulation predicates always work as follows: + ++ The first argument is the unbound variable associated with +attributes, ++ The second argument is a list of attributes. Each attribute will +be a Prolog term or a constant, prefixed with the + and - unary +operators. The prefix + may be dropped for convenience. + +The following three procedures are available to the user. Notice that +these built-ins are rewritten by the system into internal built-ins, and +that the rewriting process depends on the module on which the +built-ins have been invoked. + + +The user-predicate predicate verify_attributes/3 is called when +attempting to unify an attributed variable which might have attributes +in some _Module_. + + +Attributes are usually presented as goals. The following routines are +used by built-in predicates such as call_residue/2 and by the +Prolog top-level to display attributes: + + +Constraint solvers must be able to project a set of constraints to a set +of variables. This is useful when displaying the solution to a goal, but +may also be used to manipulate computations. The user-defined +project_attributes/2 is responsible for implementing this +projection. + + +The following examples are taken from the SICStus Prolog +manual. The sketches the implementation of a simple finite domain +`solver`. Note that an industrial strength solver would have to +provide a wider range of functionality and that it quite likely would +utilize a more efficient representation for the domains proper. The +module exports a single predicate `domain( _-Var_, _?Domain_)` which +associates _Domain_ (a list of terms) with _Var_. A variable can be +queried for its domain by leaving _Domain_ unbound. + +We do not present here a definition for project_attributes/2. +Projecting finite domain constraints happens to be difficult. + +~~~~~ +:- module(domain, [domain/2]). + +:- use_module(library(atts)). +:- use_module(library(ordsets), [ + ord_intersection/3, + ord_intersect/2, + list_to_ord_set/2 + ]). + +:- attribute dom/1. + +verify_attributes(Var, Other, Goals) :- + get_atts(Var, dom(Da)), !, % are we involved? + ( var(Other) -> % must be attributed then + ( get_atts(Other, dom(Db)) -> % has a domain? + ord_intersection(Da, Db, Dc), + Dc = [El|Els], % at least one element + ( Els = [] -> % exactly one element + Goals = [Other=El] % implied binding + ; Goals = [], + put_atts(Other, dom(Dc))% rescue intersection + ) + ; Goals = [], + put_atts(Other, dom(Da)) % rescue the domain + ) + ; Goals = [], + ord_intersect([Other], Da) % value in domain? + ). +verify_attributes(_, _, []). % unification triggered + % because of attributes + % in other modules + +attribute_goal(Var, domain(Var,Dom)) :- % interpretation as goal + get_atts(Var, dom(Dom)). + +domain(X, Dom) :- + var(Dom), !, + get_atts(X, dom(Dom)). +domain(X, List) :- + list_to_ord_set(List, Set), + Set = [El|Els], % at least one element + ( Els = [] -> % exactly one element + X = El % implied binding + ; put_atts(Fresh, dom(Set)), + X = Fresh % may call + % verify_attributes/3 + ). +~~~~~ + +Note that the _implied binding_ `Other=El` was deferred until after +the completion of `verify_attribute/3`. Otherwise, there might be a +danger of recursively invoking `verify_attribute/3`, which might bind +`Var`, which is not allowed inside the scope of `verify_attribute/3`. +Deferring unifications into the third argument of `verify_attribute/3` +effectively serializes the calls to `verify_attribute/3`. + +Assuming that the code resides in the file domain.yap, we +can use it via: + +~~~~~ +| ?- use_module(domain). +~~~~~ + +Let's test it: + +~~~~~ +| ?- domain(X,[5,6,7,1]), domain(Y,[3,4,5,6]), domain(Z,[1,6,7,8]). + +domain(X,[1,5,6,7]), +domain(Y,[3,4,5,6]), +domain(Z,[1,6,7,8]) ? + +yes +| ?- domain(X,[5,6,7,1]), domain(Y,[3,4,5,6]), domain(Z,[1,6,7,8]), + X=Y. + +Y = X, +domain(X,[5,6]), +domain(Z,[1,6,7,8]) ? + +yes +| ?- domain(X,[5,6,7,1]), domain(Y,[3,4,5,6]), domain(Z,[1,6,7,8]), + X=Y, Y=Z. + +X = 6, +Y = 6, +Z = 6 +~~~~~ + +To demonstrate the use of the _Goals_ argument of +verify_attributes/3, we give an implementation of +freeze/2. We have to name it `myfreeze/2` in order to +avoid a name clash with the built-in predicate of the same name. + +~~~~~ +:- module(myfreeze, [myfreeze/2]). + +:- use_module(library(atts)). + +:- attribute frozen/1. + +verify_attributes(Var, Other, Goals) :- + get_atts(Var, frozen(Fa)), !, % are we involved? + ( var(Other) -> % must be attributed then + ( get_atts(Other, frozen(Fb)) % has a pending goal? + -> put_atts(Other, frozen((Fa,Fb))) % rescue conjunction + ; put_atts(Other, frozen(Fa)) % rescue the pending goal + ), + Goals = [] + ; Goals = [Fa] + ). +verify_attributes(_, _, []). + +attribute_goal(Var, Goal) :- % interpretation as goal + get_atts(Var, frozen(Goal)). + +myfreeze(X, Goal) :- put_atts(Fresh, frozen(Goal)), Fresh = X. ~~~~~ + +Assuming that this code lives in file myfreeze.yap, +we would use it via: + +~~~~~ +| ?- use_module(myfreeze). +| ?- myfreeze(X,print(bound(x,X))), X=2. + +bound(x,2) % side effect +X = 2 % bindings +~~~~~ + +The two solvers even work together: + +~~~~~ +| ?- myfreeze(X,print(bound(x,X))), domain(X,[1,2,3]), + domain(Y,[2,10]), X=Y. + +bound(x,2) % side effect +X = 2, % bindings +Y = 2 +~~~~~ + +The two example solvers interact via bindings to shared attributed +variables only. More complicated interactions are likely to be found +in more sophisticated solvers. The corresponding +verify_attributes/3 predicates would typically refer to the +attributes from other known solvers/modules via the module prefix in +Module:get_atts/2`. + +@} + + +@defgroup New_Style_Attribute_Declarations hProlog and SWI-Prolog style Attribute Declarations + +@{ + @ingroup AttributedVariables + + The following documentation is taken from the SWI-Prolog manual. + + Binding an attributed variable schedules a goal to be executed at the + first possible opportunity. In the current implementation the hooks are + executed immediately after a successful unification of the clause-head + or successful completion of a foreign language (built-in) predicate. Each + attribute is associated to a module and the hook attr_unify_hook/2 is + executed in this module. The example below realises a very simple and + incomplete finite domain reasoner. + +~~~~~ +:- module(domain, + [ domain/2 % Var, ?Domain % + ]). +:- use_module(library(ordsets)). + +domain(X, Dom) :- + var(Dom), !, + get_attr(X, domain, Dom). +domain(X, List) :- + list_to_ord_set(List, Domain), + put_attr(Y, domain, Domain), + X = Y. +~~~~~ + + An attributed variable with attribute value Domain has been assigned the value Y. + +~~~~~ + attr_unify_hook(Domain, Y) :- + ( get_attr(Y, domain, Dom2) + -> ord_intersection(Domain, Dom2, NewDomain), + ( NewDomain == [] + -> fail + ; NewDomain = [Value] + -> Y = Value + ; put_attr(Y, domain, NewDomain) + ) + ; var(Y) + -> put_attr( Y, domain, Domain ) + ; ord_memberchk(Y, Domain) + ). +~~~~~ + +Translate attributes from this module to residual goals: + +~~~~~ +attribute_goals(X) --> + { get_attr(X, domain, List) }, + [domain(X, List)]. +~~~~~ + + Before explaining the code we give some example queries: + + The predicate `domain/2` fetches (first clause) or assigns + (second clause) the variable a domain, a set of values it can + be unified with. In the second clause first associates the domain + with a fresh variable and then unifies X to this variable to deal + with the possibility that X already has a domain. The + predicate attr_unify_hook/2 is a hook called after a variable with + a domain is assigned a value. In the simple case where the variable + is bound to a concrete value we simply check whether this value is in + the domain. Otherwise we take the intersection of the domains and either + fail if the intersection is empty (first example), simply assign the + value if there is only one value in the intersection (second example) or + assign the intersection as the new domain of the variable (third + example). The nonterminal `attribute_goals/3` is used to translate + remaining attributes to user-readable goals that, when executed, reinstate + these attributes. + +@} + +@defgroup CohYroutining Co-routining + +@{ + @ingroup AttributedVariables + +Prolog uses a simple left-to-right flow of control. It is sometimes +convenient to change this control so that goals will only execute when +sufficiently instantiated. This may result in a more "data-driven" +execution, or may be necessary to correctly implement extensions such +as negation by failure. + +Initially, YAP used a separate mechanism for co-routining. Nowadays, YAP uses +attributed variables to implement co-routining. + +Two declarations are supported: + ++ block/1 +The argument to `block/1` is a condition on a goal or a conjunction +of conditions, with each element separated by commas. Each condition is +of the form `predname( _C1_,..., _CN_)`, where _N_ is the +arity of the goal, and each _CI_ is of the form `-`, if the +argument must suspend until the first such variable is bound, or +`?`, otherwise. + ++ wait/1 +The argument to `wait/1` is a predicate descriptor or a conjunction +of these predicates. These predicates will suspend until their first +argument is bound. + + +The following primitives can be used: + +- freeze/2 + +- dif/2 + +- when/2 + +- frozen/2 + + +@} + +@} diff --git a/docs/md/builtins.md b/docs/md/builtins.md new file mode 100644 index 000000000..10dd33d6b --- /dev/null +++ b/docs/md/builtins.md @@ -0,0 +1,25 @@ +@defgroup builtins Core Built-ins +@{ + + +@brief This chapter describes the core built-in predicates that control the execution of +Prolog programs, provide fundamental functionality such as termm manipulation or arithmetic, and support interaction with external +resources, + +Many of the predicates described here have been standardised by the International Standard Organization. + The corresponding standartised subset of Prolog also known as ISO-Prolog. + +In the description of the arguments of predicates the following +notation will be used: + ++ a preceding plus sign will denote an argument as an "input + argument" - the argument is read, not written, and it cannot + be a free variable at the time of the call; + ++ a preceding minus sign will denote an "output argument"; + ++ an argument with no preceding symbol can be used in both ways. + +[TOC] + +@} diff --git a/docs/md/extensions.md b/docs/md/extensions.md index 55ca22144..778ff48ed 100644 --- a/docs/md/extensions.md +++ b/docs/md/extensions.md @@ -1,21 +1,11 @@ -Extensions to core Prolog. {#extensions} -======================== + +@defgroup extensions Extensions to core Prolog. + +@{ + YAP includes a number of extensions over the original Prolog -language. +language. Next, we discuss how to use the most important ones. -+ @subpage attributes -+ @ref Rational_Trees - -+ @ref DepthLimited - -+ @ref Tabling - -+ @ref Threads - -+ @ref Profiling - -+ @ref YAPArrays - -+ @ref Parallelism +@} diff --git a/docs/md/fli.md b/docs/md/fli.md index 03f085e8f..453f9bb64 100644 --- a/docs/md/fli.md +++ b/docs/md/fli.md @@ -1,23 +1,23 @@ -The Foreign Code Interface {#fli_c_cxx} -=========================== + +@file fli.md + +@brief Foreign Language Interfaces + +@defgroup fli_c_cxx The Foreign Code Interface + + +@{ YAP provides the user with three facilities for writing predicates in a language other than Prolog. Under Unix systems, most language implementations were linkable to `C`, and the first interface exported the YAP machinery to the C language. YAP also implements most of the SWI-Prolog foreign language interface. This gives portability with a number of SWI-Prolog packages and avoids garnage collection by using @ref slotInterface. Last, a new C++ based interface is being designed to work with the swig (www.swig.orgv) interface compiler. +@} - + The @subpage c-interface - - + The @ref swi-c-interface emulates Jan Wielemaker's SWI foreign language interface. - - + The @ref yap-cplus-interface is desiged to interface with the SWIG package by using Object-Oriented concepts - -+ The @ref LoadForeign handles the setup of foreign files - - - -@page c-interface YAP original C-interface +@defgroup ChYInterface YAP original C-interface +@ingroup fli_c_cxx +@{ Before describing in full detail how to interface to C code, we will examine a brief example. @@ -47,14 +47,12 @@ void init_my_predicates() The commands to compile the above file depend on the operating system. +@} + +@defgroup CallYAP Using the compiler: +@ingroup ChYInterface @{ -*/ - -/** - * - * Using the compiler: - Under Linux you should use: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -125,7 +123,12 @@ init_my_predicates() was passed as the third argument to load_foreign_files/3. The rest of this appendix describes exhaustively how to interface C to YAP. -### Terms {#Manipulating_Terms} + +@} + +@defgroup Manipulating_Terms Terms +@ingroup ChYInterface +@{ This section provides information about the primitives available to the C programmer for manipulating Prolog terms. @@ -497,7 +500,12 @@ You can set _min_ to zero if you do not know how much room you need but you do know you do not need a big chunk at a single go. Usually, the routine would usually be called together with a long-jump to restart the code. Slots can also be used if there is small state. -### Unification {#Unifying_Terms} + +@} + +@defgroup Unifying_Terms Unification +@ingroup ChYInterface +@{ YAP provides a single routine to attempt the unification of two Prolog terms. The routine may succeed or fail: @@ -510,7 +518,13 @@ terms. The routine may succeed or fail: The routine attempts to unify the terms _a_ and _b_ returning `TRUE` if the unification succeeds and `FALSE` otherwise. -### Strings {#Manipulating_Strings} + +@} + +@defgroup CallYAP Using the compiler: +@ingroup Manipulating_Strings Strings +@{ + The YAP C-interface now includes an utility routine to copy a string represented as a list of a character codes to a previously allocated buffer @@ -590,7 +604,13 @@ These C-interface functions are useful when converting Prolog lists to arrays: They return the number of integers scanned, up to a maximum of sz, and -1 on error. -### Memory Allocation {#Memory_Allocation} + +@} + +@defgroup Memory_Allocation Memory Allocation +@ingroup ChYInterface +@{ + The next routine can be used to ask space from the Prolog data-base: @@ -614,7 +634,12 @@ back to YAP by using: The routine releases a buffer allocated from the code area. The system may crash if `buf` is not a valid pointer to a buffer in the code area. -### Controlling YAP Streams from `C` {#Controlling_Streams} + +@} + +@defgroup Controlling_Streams Controlling YAP Streams from `C` +@ingroup ChYInterface +@{ The C-Interface also provides the C-application with a measure of control over the YAP Input/Output system. The first routine allows one @@ -669,7 +694,12 @@ The available flags are `YAP_INPUT_STREAM`, `YAP_BINARY_STREAM`, and `YAP_SEEKABLE_STREAM`. By default, the stream is supposed to be at position 0. The argument _name_ gives the name by which YAP should know the new stream. -### Utility Functions in `C` {#Utility_Functions} + +@} + +@defgroup Utility_Functions Utility Functions in `C +@ingroup ChYInterface +@{ The C-Interface provides the C-application with a a number of utility functions that are useful. @@ -760,7 +790,12 @@ ignore_variables)); The first three arguments follow `term_has/4`. The last argument indicates what to do if we find a variable: if `0` fail, otherwise ignore the variable. -### From `C` back to Prolog {#Calling_YAP_From_C} + +@} + +@defgroup Calling_YAP_From_C From `C` back to Prolog +@ingroup ChYInterface +@{ There are several ways to call Prolog code from C-code. By default, the `YAP_RunGoal()` should be used for this task. It assumes the engine @@ -800,8 +835,6 @@ this is possible, _Goal_ will become invalid after executing if (out == 0) return FALSE; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -@copydoc real - The following functions complement _YAP_RunGoal_:
    @@ -877,8 +910,7 @@ a solution was found. Notice that you cannot create new slots if an YAP_ExnterGoal goal is open. -
  • `YAP_Bool` YAP_RetryGoal(`YAP_dogoalinfo \*` _infop_) @anchor -YAP_RetryGoal +
  • `YAP_Bool` YAP_RetryGoal(`YAP_dogoalinfo \*` _infop_) @anchor YAP_RetryGoal Backtrack to a query created by [YAP_EnterGoal](@ref YAP_EnterGoal). The query @@ -930,7 +962,12 @@ finding the first solution to the goal, but you can call Notice that during execution, garbage collection or stack shifting may have moved the terms -### Module Manipulation in C {#Module_Manipulation_in_C} + +@} + +@defgroup CallYAP Using the compiler: +@ingroup Module_Manipulation_in_C Module Manipulation in C +@{ YAP allows one to create a new module from C-code. To create the new code it is sufficient to call: @@ -956,7 +993,12 @@ possible by using:
Notice that this function returns a term, and not an atom. You can [YAP_AtomOfTerm](@ref YAP_AtomOfTerm) to extract the corresponding Prolog atom. -### Miscellaneous C Functions {#Miscellaneous_ChYFunctions} + +@} + +@defgroup Miscellaneous_ChYFunctions Miscellaneous C Functions +@ingroup ChYInterface +@{
  • `void` YAP_Throw(`YAP_Term exception`) @@ -983,8 +1025,8 @@ collector, the second does the same for the atom garbage collector.`
  • `void \*` YAP_ExternalDataInStackFromTerm(`YAP_Term t`)
  • -
  • `YAP_Bool` YAP_IsExternalDataInStackTerm(`YAP_Term t`) @anchor -YAP_AllocExternalDataInStack +
  • `YAP_Bool` YAP_IsExternalDataInStackTerm(`YAP_Term t`) + @anchor YAP_AllocExternalDataInStack The next routines allow one to store external data in the Prolog @@ -999,8 +1041,8 @@ so it should not be used to store Prolog terms. On the other hand, it may be useful to store arrays in a compact way, or pointers to external objects.
  • -
  • `int` YAP_HaltRegisterHook(`YAP_halt_hook f, void \*closure`) @anchor -YAP_HaltRegisterHook +
  • `int` YAP_HaltRegisterHook(`YAP_halt_hook f, void \*closure`) + @anchor YAP_HaltRegisterHook Register the function _f_ to be called if YAP is halted. The @@ -1017,7 +1059,12 @@ of such arguments.
-### Writing predicates in C {#Writing_C} + +@} + +@defgroup Writing_C Writing predicates in C +@ingroup ChYInterface +@{ We will distinguish two kinds of predicates: @@ -1075,8 +1122,8 @@ the predicate and _arity_ is the predicate's arity.
  • void YAP_UserBackCPredicate(char \* _name_, int \* _init_(), int \* -_cont_(), unsigned long int _arity_, unsigned int _sizeof_) @anchor -YAP_UserBackCPredicate +_cont_(), unsigned long int _arity_, unsigned int _sizeof_) +@anchor YAP_UserBackCPredicate describes a new predicate where _name_ is the name of the predicate, _init_, and _cont_ are the C functions that implement the @@ -1091,8 +1138,8 @@ predicate and _arity_ is the predicate's arity.
  • -
  • void YAP_PRESERVED_DATA_CUT( _ptr_, _type_); @anchor -YAP_PRESERVED_DATA_CUT +
  • void YAP_PRESERVED_DATA_CUT( _ptr_, _type_); + @anchor YAP_PRESERVED_DATA_CUT
  • @@ -1268,7 +1315,12 @@ init_n100(void) } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ in this case no code is executed at cut time. -### Changes to the C-Interface in YAP4 {#YAP4_Notes} + +@} + +@defgroup YAP4_Notes Changes to the C-Interface in YAP4 +@ingroup ChYInterface +@{ YAP4 includes several changes over the previous `load_foreign_files/3` interface. These changes were required to support the new binary code @@ -1304,8 +1356,11 @@ arguments to the backtrackable procedure. +@} + @defgroup YAPAsLibrary Using YAP as a Library -@ingroup c-interface +@ingroup ChYInterface +@{ YAP can be used as a library to be called from other programs. To do so, you must first create the YAP library: @@ -1528,3 +1583,7 @@ the future we plan to split this library into several smaller libraries + You can generate your own saved states. Look at the `boot.yap` and `init.yap` files. + +@} + +@} diff --git a/docs/md/library.md b/docs/md/library.md new file mode 100644 index 000000000..df4c683e2 --- /dev/null +++ b/docs/md/library.md @@ -0,0 +1,11 @@ +@defgroup library YAP Prolog Library + +@{ + + the library_directory path (set by the + `LIBDIR` variable in the Makefile for YAP). Several files in the + library are originally from the public-domain Edinburgh Prolog library. + +[TOC] + +@} diff --git a/docs/md/load_files.md b/docs/md/load_files.md deleted file mode 100644 index c59e60799..000000000 --- a/docs/md/load_files.md +++ /dev/null @@ -1,15 +0,0 @@ -Loading and Organising YAP Programs {#load_files} -=================================== - - Next, we present the main predicates and directives available to load - files and to control the Prolog environment. - - + @subpage YAPModules - - + @ref YAPConsulting - - + @ref QLY - - + @ref YAPBigLoad - - diff --git a/docs/md/modules.md b/docs/md/modules.md deleted file mode 100644 index 2677d8d0e..000000000 --- a/docs/md/modules.md +++ /dev/null @@ -1,346 +0,0 @@ -The YAP Module system {#YAPModules} -===================== - - The YAP module system is based on the Quintus/SISCtus module -system Ëœ\cite quintus . In this design, modules are named collections of predicates, -and all predicates belong to a single module. By default, predicates are only -visible within a module, or _private_ to that module. The module -may also define a list of predicates that are -_exported_, that is, visible to other modules. - -Next, we present: -+ @ref IntroModules -+ @ref ExplicitNaming -+ @ref ModuleBuiltins -+ @ref YAPMetaPredicates - - -### Using Modules in YAP {#IntroModules} - -The main predicates in the module system are: - - * module/2 associates a source file to a module. It has two arguments: the name of the new module, and a list of predicates exported by the module. - - * use_module/1 and use_module/2 can be used to load a module. They take as first argument the source file for the module. Whereas use_module/1 loads all exported predicates, use_module/2 only takes the ones given by the second argument. - -YAP pre-defines a number of modules. Most system predicates belong to - the module `prolog`. Predicates from the module `prolog` are -automatically visible to every module. The `system` module was - introduced for SWI-Prolog compatibility, and in YAP mostly acts as an -alias to `prolog`. The `user` module is also visible to all other modules. - -The YAP engine is always associated to a module, the current source -module or type-in module. By default, all predicates -read-in and all calls to a goal will be made to predicates visible to -the current source module, Initially, the source module for YAP is the -module `user`. Thus Prolog programs that do not define modules will -operate within the `user` module. In this case, all predicates will be -visible to all source files. - -YAP includes a number of libraries and packages, most of them - defining their own modules. Note that there is no system mechanism to - avoid clashes between module names, so it is up to the programmer to - carefully choose the names for her own program modules. - -The main mechanism to change the current type-in module is by using -the module/2 declaration.This declaration sets the source module when - it starts consulting a file, and resets it at the end. One can set -the type-in module permanently by using the built-in `module/1`. - -#### Explicit Naming {#ExplicitNaming} - -The module system allows one to _explicitly_ specify the source mode for -a clause by prefixing a clause with its module, say: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} -user:(a :- b). -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -it is also possible to type - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} - -user:a :- user:b. - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -both formulations describe the same clause, independently of the -current type-in module. - -In fact, it is sufficient to specify the source mode for the clause's -head: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} -user:a :- b. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -if the current type-in module is `m`, the clause could also be written as: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} -user:a :- m:b. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The compiler rewrites the source clauses to ensure that explicit calls -are respected, and that implicit calls are made to the current source -module. - -A goal should refer to a predicate visible within the current type-in -module. Thus, if a goal appears in a text file with a module -declaration, the goal refers to that module's context (but see the -initialization/1 directive for more details). - -Again, one can override this rule by prefixing a goal with a module to -be consulted. The following query: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} -?- nasa:launch(apollo,13). -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - invokes the goal `launch(apollo,13)` as if the current source -module was `nasa`. - -YAP and other Prolog systems allow the module prefix to see all -predicates visible in the module, including predicates private to the -module. This rule allows maximum flexibility, but it also breaks -encapsulation and should be used with care. The ciao language proposes -a different approach to this problem, see \cite DBLP:conf/cl/GrasH00 . - -Modules are not always associated with a source-file. They -may range over several files, by using the -`include`directive. Moreover, they may not be associated to any source -file. As an example, -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} -?- assert( nasa:launch(apollo,13) ). -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -will create a module `nasa`, if does not already exist. In fact it is -sufficient to call a predicate from a module to implicitly create the -module. Hence after this call: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} -?- nasa:launch(apollo,13). -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -there will be a `nasa`module in the system, even if nasa:launch/2 is -not at all defined. - - \pred use_module( +Files ) is directive - loads a module file - -This predicate loads the file specified by _Files_, importing all -their public predicates into the current type-in module. It is -implemented as if by: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} -use_module(F) :- - load_files(F, [if(not_loaded),must_be_module(true)]). -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Notice that _Files_ may be a single file, or a list with a number -files. The _Files_ are loaded in YAP only once, even if they have been -updated meanwhile. YAP should also verify whether the files actually -define modules. Please consult load_files/3 for other options when -loading a file. - -Predicate name clashes between two different modules may arise, either -when trying to import predicates that are also defined in the current -type-in module, or by trying to import the same predicate from two -different modules. - -In the first case, the local predicate is considered to have priority -and use_module/1 simply gives a warning. As an example, if the file -`a.pl` contains: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} -:- module( a, [a/1] ). - -:- use_module(b). - -a(1). -a(X) :- b(X). -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -and the file `b.pl` contains: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} -:- module( b, [a/1,b/1] ). - -a(2). - -b(1). -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -YAP will execute as follows: - - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} -?- [a]. - % consulting .../a.pl... - % consulting .../b.pl... - % consulted .../b.pl in module b, 0 msec 0 bytes - % consulted .../a.pl in module a, 1 msec 0 bytes -true. - ?- a(X). -X = 1 ? ; -X = 1. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The example shows that the query `a(X)`has a single answer, the one -defined in `a.pl`. Calls to `a(X)`succeed in the top-level, because -the module `a` was loaded into `user`. On the other hand, `b(X)`is not -exported by `a.pl`, and is not available to calls, although it can be -accessed as a predicate in the module 'a' by using the `:` operator. - -Next, consider the three files `c.pl`, `d1.pl`, and `d2.pl`: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} -% c.pl -:- module( c, [a/1] ). - -:- use_module([d1, d2]). - -a(X) :- - b(X). -a(X) :- - c(X). -a(X) :- - d(X). - -% d1.pl -:- module( d1, [b/1,c/1] ). - -b(2). -c(3). - - -% d2.pl -:- module( d2, [b/1,d/1] ). - -b(1). -d(4). -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The result is as follows: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} -./yap -l c -YAP 6.3.4 (x86_64-darwin13.3.0): Tue Jul 15 10:42:11 CDT 2014 - - ERROR!! - at line 3 in o/d2.pl, - PERMISSION ERROR- loading .../c.pl: modules d1 and d2 both define b/1 - ?- a(X). -X = 2 ? ; - ERROR!! - EXISTENCE ERROR- procedure c/1 is undefined, called from context prolog:$user_call/2 - Goal was c:c(_131290) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The state of the module system after this error is undefined. - -### BuiltIn predicates {#ModuleBuiltins) - -@\pred module(+ M:atom,+ L:list ) is directive - the current file defines module _M_ with exports _L_. The list may include - - + predicate indicators - - + operator definitions that look like calls to op/3. - -The list _L_ may include predicates imported from other modules. If -you want to fully reexport a module, or a sub-set, also consider reexport/1. - -Similar to module/2, this directive defines the file where it -appears in as a module file; it must be the first declaration in the file. - _M_ must be an atom specifying the module name; _L_ must be a -list containing the module's public predicates specification, in the -form `[predicate_name/arity,...]`. - -The last argument _Options_ must be a list of options, which can be: - + filename - the filename for a module to import into the current module. - - + library( +File ) - a library file to import into the current module. - - + hide( +Opt) - if _Opt_ is `false`, keep source code for current module, if `true`, disable. - - + export(+PredicateIndicator ) - Add predicates to the public list of the context module. This implies - the predicate will be imported into another module if this module - is imported with use_module/1 and use_module/2. - - + export_list(? _Mod_,? _ListOfPredicateIndicator_) - The list _ListOfPredicateIndicator_ contains all predicates - exported by module _Mod_ - -Note that predicates are normally exported using the directive -`module/2`. The `export/1` argumwnt is meant to allow export from -dynamically created modules. The directive argument may also be a list -of predicates. - - @pred use_module(+Files, +Imports) - loads a module file but only imports the named predicates - - -This predicate loads the file specified by _Files_, importing their -public predicates specified by _Imports_ into the current type-in -module. It is implemented as if by: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} -use_module(Files, Imports) :- - load_files(Files, [if(not_loaded),must_be_module(true),imports(Imports)]). -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The _Imports_ argument may be use to specify which predicates one -wants to load. It can also be used to give the predicates a different name. As an example, -the graphs library is implemented on top of the red-black trees library, and some predicates are just aliases: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} -:- use_module(library(rbtrees), [ - rb_min/3 as min_assoc, - rb_max/3 as max_assoc, - - ...]). -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Unfortunately it is still not possible to change argument order. - - -\pred module(+ M:atom,+ L:list ) is directive - the current file defines module _M_ with exports _L_. The list may include - - + predicate indicators - - + operator definitions that look like calls to op/3. - -The list _L_ may include predicates imported from other modules. If -you want to fully reexport a module, or a sub-set, also consider reexport/1. - -Similar to module/2, this directive defines the file where it -appears in as a module file; it must be the first declaration in the file. - _M_ must be an atom specifying the module name; _L_ must be a -list containing the module's public predicates specification, in the -form `[predicate_name/arity,...]`. - -The last argument _Options_ must be a list of options, which can be: - +filename - the filename for a module to import into the current module. - - + library( +File ) - a library file to import into the current module. - - + hide( +Opt) - if _Opt_ is `false`, keep source code for current module, if `true`, disable. - - + export(+PredicateIndicator ) - Add predicates to the public list of the context module. This implies - the predicate will be imported into another module if this module - is imported with use_module/1 and use_module/2. - - + export_list(? _Mod_,? _ListOfPredicateIndicator_) - The list _ListOfPredicateIndicator_ contains all predicates - exported by module _Mod_ - -Note that predicates are normally exported using the directive -`module/2`. The `export/1` argument is meant to allow export from -dynamically created modules. The directive argument may also be a list -of predicates. diff --git a/docs/md/packages.md b/docs/md/packages.md index 39784ee4c..4d4d869ca 100644 --- a/docs/md/packages.md +++ b/docs/md/packages.md @@ -1,19 +1,19 @@ YAP packages {#packages} ============ - + @subpage real + + @ref real - + @subpage BDDs + + @subpage BDDs + @subpage gecode - + @subpage myddas + + @ref myddas + @ref PFL + @subpage ProbLog1 - + @ref Python + + @ref python + @subpage raptor diff --git a/docs/md/programming.md b/docs/md/programming.md new file mode 100644 index 000000000..fab7f501d --- /dev/null +++ b/docs/md/programming.md @@ -0,0 +1,361 @@ +Programming in YAP {#YAPProgramming} +==================== + ++ @ref load_files + ++ @ref YAPSyntax + ++ @ref YAPCompilerSettings + ++ @ref Indexing + ++ @ref Deb_Interaction + + +@defgroup load_files Loading and Organizing YAP Programs +@{ + +We present the main predicates and directives available to load + files and to control the Prolog environment. + +@} + +@defgroup YAPModules The YAP Module system + +@{ + The YAP module system is based on the Quintus/SISCtus module + system @cite quintus . In this design, modules are named collections of predicates, + and all predicates belong to a single module. By default, predicates are only + visible within a module, or _private_ to that module. The module + may also define a list of predicates that are + _exported_, that is, visible to other modules. + + The main predicates in the module system are: + + * module/2 associates a source file to a module. It has two arguments: the name of the new module, and a list of predicates exported by the module. + + * use_module/1 and use_module/2 can be used to load a module. They take as first argument the source file for the module. Whereas use_module/1 loads all exported predicates, use_module/2 only takes the ones given by the second argument. + + YAP pre-defines a number of modules. Most system predicates belong to + the module `prolog`. Predicates from the module `prolog` are + automatically visible to every module. The `system` module was + introduced for SWI-Prolog compatibility, and in YAP mostly acts as an + alias to `prolog`. The `user` module is also visible to all other modules. + + The YAP engine is always associated to a module, the current source + module or type-in module. By default, all predicates + read-in and all calls to a goal will be made to predicates visible to + the current source module, Initially, the source module for YAP is the + module `user`. Thus Prolog programs that do not define modules will + operate within the `user` module. In this case, all predicates will be + visible to all source files. + + YAP includes a number of libraries and packages, most of them + defining their own modules. Note that there is no system mechanism to + avoid clashes between module names, so it is up to the programmer to + carefully choose the names for her own program modules. + + The main mechanism to change the current type-in module is by using + the module/2 declaration.This declaration sets the source module when + it starts consulting a file, and resets it at the end. One can set + the type-in module permanently by using the built-in `module/1`. + + ### Explicit Naming {#ExplicitNaming} + + The module system allows one to _explicitly_ specify the source mode for + a clause by prefixing a clause with its module, say: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} + user:(a :- b). + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + it is also possible to type + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} + + user:a :- user:b. + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + both formulations describe the same clause, independently of the + current type-in module. + + In fact, it is sufficient to specify the source mode for the clause's + head: + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} + user:a :- b. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + if the current type-in module is `m`, the clause could also be written as: + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} + user:a :- m:b. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + The compiler rewrites the source clauses to ensure that explicit calls + are respected, and that implicit calls are made to the current source + module. + + A goal should refer to a predicate visible within the current type-in + module. Thus, if a goal appears in a text file with a module + declaration, the goal refers to that module's context (but see the + initialization/1 directive for more details). + + Again, one can override this rule by prefixing a goal with a module to + be consulted. The following query: + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} + ?- nasa:launch(apollo,13). + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + invokes the goal `launch(apollo,13)` as if the current source + module was `nasa`. + + YAP and other Prolog systems allow the module prefix to see all + predicates visible in the module, including predicates private to the + module. This rule allows maximum flexibility, but it also breaks + encapsulation and should be used with care. The ciao language proposes + a different approach to this problem, see \cite DBLP:conf/cl/GrasH00 . + + Modules are not always associated with a source-file. They + may range over several files, by using the + `include`directive. Moreover, they may not be associated to any source + file. As an example, + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} + ?- assert( nasa:launch(apollo,13) ). + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + will create a module `nasa`, if does not already exist. In fact it is + sufficient to call a predicate from a module to implicitly create the + module. Hence after this call: + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} + ?- nasa:launch(apollo,13). + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + there will be a `nasa`module in the system, even if nasa:launch/2 is + not at all defined. + + \pred use_module( +Files ) is directive + loads a module file + + This predicate loads the file specified by _Files_, importing all + their public predicates into the current type-in module. It is + implemented as if by: + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.yap} + use_module(F) :- + load_files(F, [if(not_loaded),must_be_module(true)]). + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + Notice that _Files_ may be a single file, or a list with a number + files. The _Files_ are loaded in YAP only once, even if they have been + updated meanwhile. YAP should also verify whether the files actually + define modules. Please consult load_files/3 for other options when + loading a file. + + Predicate name clashes between two different modules may arise, either + when trying to import predicates that are also defined in the current + type-in module, or by trying to import the same predicate from two + different modules. + + In the first case, the local predicate is considered to have priority + and use_module/1 simply gives a warning. As an example, if the file + `a.pl` contains: + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} + :- module( a, [a/1] ). + + :- use_module(b). + + a(1). + a(X) :- b(X). + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + and the file `b.pl` contains: + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} + :- module( b, [a/1,b/1] ). + + a(2). + + b(1). + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + YAP will execute as follows: + + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} + ?- [a]. + % consulting .../a.pl... + % consulting .../b.pl... + % consulted .../b.pl in module b, 0 msec 0 bytes + % consulted .../a.pl in module a, 1 msec 0 bytes + true. + ?- a(X). + X = 1 ? ; + X = 1. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + The example shows that the query `a(X)`has a single answer, the one + defined in `a.pl`. Calls to `a(X)`succeed in the top-level, because + the module `a` was loaded into `user`. On the other hand, `b(X)`is not + exported by `a.pl`, and is not available to calls, although it can be + accessed as a predicate in the module 'a' by using the `:` operator. + + Next, consider the three files `c.pl`, `d1.pl`, and `d2.pl`: + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} + % c.pl + :- module( c, [a/1] ). + + :- use_module([d1, d2]). + + a(X) :- + b(X). + a(X) :- + c(X). + a(X) :- + d(X). + + % d1.pl + :- module( d1, [b/1,c/1] ). + + b(2). + c(3). + + + % d2.pl + :- module( d2, [b/1,d/1] ). + + b(1). + d(4). + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + The result is as follows: + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} + ./yap -l c + YAP 6.3.4 (x86_64-darwin13.3.0): Tue Jul 15 10:42:11 CDT 2014 + + ERROR!! + at line 3 in o/d2.pl, + PERMISSION ERROR- loading .../c.pl: modules d1 and d2 both define b/1 + ?- a(X). + X = 2 ? ; + ERROR!! + EXISTENCE ERROR- procedure c/1 is undefined, called from context prolog:$user_call/2 + Goal was c:c(_131290) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + The state of the module system after this error is undefined. + + ### Built-In predicates {#ModuleBuiltins) + + @\pred module(+ M:atom,+ L:list ) is directive + the current file defines module _M_ with exports _L_. The list may include + + + predicate indicators + + + operator definitions that look like calls to op/3. + + The list _L_ may include predicates imported from other modules. If + you want to fully reexport a module, or a sub-set, also consider reexport/1. + + Similar to module/2, this directive defines the file where it + appears in as a module file; it must be the first declaration in the file. + _M_ must be an atom specifying the module name; _L_ must be a + list containing the module's public predicates specification, in the + form `[predicate_name/arity,...]`. + + The last argument _Options_ must be a list of options, which can be: + + filename + the filename for a module to import into the current module. + + + library( +File ) + a library file to import into the current module. + + + hide( +Opt) + if _Opt_ is `false`, keep source code for current module, if `true`, disable. + + + export(+PredicateIndicator ) + Add predicates to the public list of the context module. This implies + the predicate will be imported into another module if this module + is imported with use_module/1 and use_module/2. + + + export_list(? _Mod_,? _ListOfPredicateIndicator_) + The list _ListOfPredicateIndicator_ contains all predicates + exported by module _Mod_ + + Note that predicates are normally exported using the directive + `module/2`. The `export/1` argumwnt is meant to allow export from + dynamically created modules. The directive argument may also be a list + of predicates. + + @pred use_module(+Files, +Imports) + loads a module file but only imports the named predicates + + + This predicate loads the file specified by _Files_, importing their + public predicates specified by _Imports_ into the current type-in + module. It is implemented as if by: + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} + use_module(Files, Imports) :- + load_files(Files, [if(not_loaded),must_be_module(true),imports(Imports)]). + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + The _Imports_ argument may be use to specify which predicates one + wants to load. It can also be used to give the predicates a different name. As an example, + the graphs library is implemented on top of the red-black trees library, and some predicates are just aliases: + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog} + :- use_module(library(rbtrees), [ + rb_min/3 as min_assoc, + rb_max/3 as max_assoc, + + ...]). + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + Unfortunately it is still not possible to change argument order. + + + \pred module(+ M:atom,+ L:list ) is directive + the current file defines module _M_ with exports _L_. The list may include + + + predicate indicators + + + operator definitions that look like calls to op/3. + + The list _L_ may include predicates imported from other modules. If + you want to fully reexport a module, or a sub-set, also consider reexport/1. + + Similar to module/2, this directive defines the file where it + appears in as a module file; it must be the first declaration in the file. + _M_ must be an atom specifying the module name; _L_ must be a + list containing the module's public predicates specification, in the + form `[predicate_name/arity,...]`. + + The last argument _Options_ must be a list of options, which can be: + +filename + the filename for a module to import into the current module. + + + library( +File ) + a library file to import into the current module. + + + hide( +Opt) + if _Opt_ is `false`, keep source code for current module, if `true`, disable. + + + export(+PredicateIndicator ) + Add predicates to the public list of the context module. This implies + the predicate will be imported into another module if this module + is imported with use_module/1 and use_module/2. + + + export_list(? _Mod_,? _ListOfPredicateIndicator_) + The list _ListOfPredicateIndicator_ contains all predicates + exported by module _Mod_ + + Note that predicates are normally exported using the directive + `module/2`. The `export/1` argument is meant to allow export from + dynamically created modules. The directive argument may also be a list + of predicates. + + @} diff --git a/docs/md/run.md b/docs/md/run.md index 09380de09..d382dc6be 100644 --- a/docs/md/run.md +++ b/docs/md/run.md @@ -1,14 +1,14 @@ Running YAP {#run} -=========== +============== We next describe how to invoke YAP in Unix systems. [TOC] -### Running YAP Interactively {#Running_YAP_Interactively} - +Running YAP Interactively {#Running_YAP_Interactively} +-------------------------- Most often you will want to use YAP in interactive mode. Assuming that YAP is in the user's search path, the top-level can be invoked under @@ -54,7 +54,7 @@ boot code is in Prolog file _BOOT_FILE_. The filename must define the predicate `'$live'/0`. + -c IP_HOST port connect standard streams to host IP_HOST at port port -+ filename ++ filename restore state saved in the given file + -f do not consult initial files @@ -67,44 +67,34 @@ through the unix/1 built-in predicate. Note that YAP will output an error message on the following conditions: -+ -a file name was given but the file does not exist or is not a saved ++ a file name was given but the file does not exist or is not a saved YAP state; -+ -the necessary amount of memory could not be allocated; ++ the necessary amount of memory could not be allocated; -+ -the allocated memory is not enough to restore the state. ++ the allocated memory is not enough to restore the state. + When restoring a saved state, YAP will allocate the same amount of memory as that in use when the state was saved, unless a different amount is specified by flags in the command line. By default, YAP restores the file startup.yss from the current directory or from the YAP library. - When restoring a saved state, YAP will allocate the -same amount of memory as that in use when the state was saved, unless a -different amount is specified by flags in the command line. By default, -YAP restores the file startup.yss from the current directory or from -the YAP library. - -+ -YAP usually boots from a saved state. The saved state will use the default ++ YAP usually boots from a saved state. The saved state will use the default installation directory to search for the YAP binary unless you define the environment variable YAPBINDIR. -+ -YAP always tries to find saved states from the current directory - first. If it cannot it will use the environment variable YAPLIBDIR, if ++ YAP always tries to find saved states from the current directory + first. If it cannot it will use the environment variable YAPLIBDIR, + if defined, or search the default library directory. ++ YAP will try to find library files from the YAPSHAREDIR/library directory. -YAP will try to find library files from the YAPSHAREDIR/library -directory. - -### Running Prolog Files {#Running_Prolog_Files} +Running Prolog Files {#Running_Prolog_Files} +-------------------- YAP can also be used to run Prolog files as scripts, at least in Unix-like environments. A simple example is shown next (do not forget that the shell comments are very important): -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~ #!/usr/local/bin/yap -L -- # # Hello World script file using YAP @@ -113,7 +103,7 @@ that the shell comments are very important): :- write('Hello World'), nl. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~ The `#!` characters specify that the script should call the binary file YAP. Notice that many systems will require the complete path to the @@ -147,7 +137,7 @@ Notice that the `--` is required so that the shell passes the extra arguments to YAP. As an example, consider the following script `dump_args`: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~ #!/usr/bin/yap -L -- #. @@ -158,13 +148,13 @@ main( [H|T] ) :- :- unix( argv(AllArgs) ), main( AllArgs ). -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~ If you this run this script with the arguments: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~ ./dump_args -s 10000 -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~ the script will start an YAP process with stack size `10MB`, and the list of arguments to the process will be empty. @@ -172,7 +162,7 @@ Often one wants to run the script as any other program, and for this it is convenient to ignore arguments to YAP. This is possible by using `L --` as in the next version of `dump_args`: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~ #!/usr/bin/yap -L -- main( [] ). @@ -182,13 +172,13 @@ main( [H|T] ) :- :- unix( argv(AllArgs) ), main( AllArgs ). -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~ The `--` indicates the next arguments are not for YAP. Instead, they must be sent directly to the argv built-in. Hence, running -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~ ./dump_args test -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~ will write `test` on the standard output. diff --git a/docs/md/swi.md b/docs/md/swi.md index 60d5163b5..c4d81dcbe 100644 --- a/docs/md/swi.md +++ b/docs/md/swi.md @@ -12,6 +12,7 @@ resulted in Prolog extensions such as the `dialect` feature. YAP currently supports most of the SWI-Prolog foreign interface. The following SWI libraries have been adapted to YAP: +~~~~~ + @ref aggregate + @ref base64 + @ref broadcast @@ -42,6 +43,7 @@ libraries have been adapted to YAP: + @ref utf8 + @ref win_menu + @ref www_browser +~~~~~ Note that in general SWI code may be from an earlier version than the @@ -54,8 +56,8 @@ Please do refer to the SWI-Prolog home page: for more information on SWI-Prolog and the SWI packages. -Compatibility with the C-Prolog interpreter {#ChYProlog} -------------------------------------------- +#### Compatibility with the C-Prolog interpreter {#ChYProlog} + YAP was designed so that most C-Prolog programs should run under YAP without changes. @@ -65,9 +67,9 @@ assert/1, clause/1 and retract/1 are used. First predicates which will change during execution should be declared as `dynamic` by using commands like: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~ :- dynamic f/n. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~ where `f` is the predicate name and n is the arity of the predicate. Note that several such predicates can be declared in a @@ -172,9 +174,7 @@ standard. The following incompatibilities between YAP and the ISO standard are known to still exist (please check Ulrich Neumerkel's page for more details): -
      - -
    • Currently, YAP does not handle overflow errors in integer + + Currently, YAP does not handle overflow errors in integer operations, and handles floating-point errors only in some architectures. Otherwise, YAP follows IEEE arithmetic. diff --git a/docs/md/syntax.md b/docs/md/syntax.md index aaf2ab287..22a0dfe26 100644 --- a/docs/md/syntax.md +++ b/docs/md/syntax.md @@ -1,10 +1,16 @@ +@defgroup YAPSyntax YAP Syntax + +@{ + @ingroup YAPProgrammming We will describe the syntax of YAP at two levels. We first will describe the syntax for Prolog terms. In a second level we describe the tokens from which Prolog terms are built. -### Syntax of Terms {#Formal_Syntax} +@defgroup Formal_Syntax Syntax of Terms +@{ +@ingroup YAPSyntax Below, we describe the syntax of YAP terms from the different classes of tokens defined above. The formalism used will be BNF, @@ -77,17 +83,22 @@ paragraph). When a name consisting of a single dot could be taken for the end of term marker, the ambiguity should be avoided by surrounding the dot with single quotes. +@} +@defgroup Tokens Prolog Tokens - -### Prolog Tokens {#Tokens} +@{ +@ingroup YAPSyntax Prolog tokens are grouped into the following categories: -#### Numbers {#Numbers} +@defgroup Numbers Numbers +@{ +@ingroup Tokens Numbers can be further subdivided into integer and floating-point numbers. -##### @defgroup Integers {#Integers} +@defgroup Integers Integers +@{ @ingroup Numbers Integer numbers @@ -134,8 +145,10 @@ YAP (version 6.3.4) supports integers that can fit the word size of the machine. This is 32 bits in most current machines, but 64 in some others, such as the Alpha running Linux or Digital Unix. The scanner will read larger or smaller integers erroneously. +@} -##### Floats {#Floats} +@defgroup Floats Floats +@} @ingroup Numbers Floating-point numbers are described by: @@ -160,7 +173,10 @@ Examples: Floating-point numbers are represented as a double in the target machine. This is usually a 64-bit number. -#### Strings Character Strings {#Strings} +@} +@} +@defgroup Strings Character Strings +@{ Strings are described by the following rules: @@ -211,7 +227,7 @@ Escape sequences can be used to include the non-printable characters `f` (form feed), `t` (horizontal tabulation), `n` (new line), and `v` (vertical tabulation). Escape sequences also be include the meta-characters `\\`, `"`, `'`, and -```. Last, one can use escape sequences to include the characters +`''`. Last, one can use escape sequences to include the characters either as an octal or hexadecimal number. The next examples demonstrates the use of escape sequences in YAP: @@ -230,7 +246,13 @@ versions of YAP up to 4.2.0. Escape sequences can be disabled by using: :- yap_flag(character_escapes,false). ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -#### Atoms {#Atoms} +@} + +@addtogroup Atoms Atoms + +@} + +@ingroup Tokens Atoms are defined by one of the following rules: @@ -270,7 +292,10 @@ Version `4.2.0` of YAP removed the previous limit of 256 characters on an atom. Size of an atom is now only limited by the space available in the system. -## @addgroup Variables Variables +@} + + @addtogroup Variables Variables +@{ @ingroup Tokens Variables are described by: @@ -291,7 +316,9 @@ variables are known as anonymous variables. Note that different occurrences of `_` on the same term represent different anonymous variables. -## @addgroup Punctuation_Tokens Punctuation Tokens +@} +@addtogroup Punctuation_Tokens Punctuation Tokens +@{ @ingroup Tokens Punctuation tokens consist of one of the following characters: @@ -301,8 +328,10 @@ Punctuation tokens consist of one of the following characters: These characters are used to group terms. -#### Layout {#Layout} - +@} +@defgroup LayoutComents Character Layout +@{ + @ingroup Tokens Any characters with ASCII code less than or equal to 32 appearing before a token are ignored. @@ -314,8 +343,11 @@ layout characters, the YAP parser behaves as if it had found a single blank character. The end of a file also counts as a blank character for this purpose. -#### Wide Character Support {#WideChars} -@ingroup YAP]Syntax +@} +@} +@addtogroup WideChars Encoding Wide Character Support +@{ + @ingroup YAPSyntax YAP now implements a SWI-Prolog compatible interface to wide @@ -346,7 +378,8 @@ other software components using the foreign language interface. In this section we only deal with I/O through streams, which includes file I/O as well as I/O through network sockets. -== @addgroup Stream_Encoding Wide character encodings on streams +@addtogroup Stream_Encoding Wide character encodings on streams +@{ @ingroup WideChars The UCS standard describes all possible characters (or code points, as they include @@ -453,9 +486,11 @@ errors can be controlled using `open/4` or `set_stream/2` (not implemented). Initially the terminal stream write the characters using Prolog escape sequences while other streams generate an I/O exception. +@} - -##### BOM: Byte Order Mark {#BOM} +@addtogroup BOM BOM: Byte Order Mark +@{ +@ingroup WideChars From Stream Encoding, you may have got the impression that text-files are complicated. This section deals with a related topic, @@ -475,7 +510,11 @@ writing, writing a BOM can be requested using the option UTF-32; otherwise the default is not to write a BOM. BOMs are not avaliable for ASCII and ISO-LATIN-1. -### Summary of YAP Predefined Operators {#ops} +@} +@} + @addgroup Operators Summary of YAP Predefined Operators + @{ +@ingroup YapSyntax The Prolog syntax caters for operators of three main kinds: @@ -554,3 +593,4 @@ The following is the list of the declarations of the predefined operators: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @} +@} diff --git a/docs/md/yap.md b/docs/md/yap.md index 5b7cccdd3..85a0ed893 100644 --- a/docs/md/yap.md +++ b/docs/md/yap.md @@ -5,7 +5,7 @@ ![The YAP Logo](docs/icons/yap_128x128x32.png) -NOTE: this version of YAP is still experimental, documentation may be out of date. +NOTE: this version of YAP is still experimental, documentation may be missing or out of date. ## Introduction @@ -17,11 +17,9 @@ Porto. The manual is organised as follows: -+ @subpage install ++ @ref INSTALL -+ @subpage run - -+ @subpage load_files ++ @ref run + @ref builtins @@ -29,11 +27,11 @@ The manual is organised as follows: + @ref library -+ @subpage packages ++ @ref packages -+ @subpage YAPProgramming ++ @ref YAPProgramming -+ @subpage fli_c_cxx ++ @ref fli_c_cxx \author Vitor Santos Costa, @@ -59,50 +57,3 @@ from Jan Wielemaker. We would also like to gratefully acknowledge the contributions from Ashwin Srinivasian. -@defgroup builtins YAP Core Built-ins - -@{} - -This chapter describes the core predicates that control the execution of -Prolog programs, provide fundamental functionality such as termm manipulation or arithmetic, and support interaction with external -resources, Many of the predicates described here have been standardised by the ISO. The standartised subset of Prolog also known as ISO-Prolog. - -In the description of the arguments of predicates the following -notation will be used: - -+ a preceding plus sign will denote an argument as an "input -argument" - it cannot be a free variable at the time of the call; -+ a preceding minus sign will denote an "output argument"; -+ an argument with no preceding symbol can be used in both ways. - -@} - - @defgroup library YAP Library - -@{ - the library_directory path (set by the - `LIBDIR` variable in the Makefile for YAP). Several files in the - library are originally from the public-domain Edinburgh Prolog library. - -@defgroup attributes Attributed Variables and Coroutining -@{ - @subpage atts - @copydoc atts -} - -@} - -@defgroup YAPProgramming Programming in YAP - -@{ - -@defgroup YAPSyntax Prolog Syntax - @subpage syntax - @copydoc syntax -@} - - - -@} - - \ No newline at end of file diff --git a/docs/my.yap b/docs/my.yap deleted file mode 100644 index b47806a37..000000000 --- a/docs/my.yap +++ /dev/null @@ -1,15552 +0,0 @@ -/** - -@defgroup YAPControl Control Predicates -@ingroup YAPBuiltins -@{ - -*/ - - -/** @pred true is iso - - -Succeeds once. - - -*/ - -/** @pred fail is iso - - -Always fails. - - -*/ - -/** @pred false is iso - - -The same as fail. - - -*/ - -/** @pred repeat is iso -Succeeds repeatedly. - -In the next example, `repeat` is used as an efficient way to implement -a loop. The next example reads all terms in a file: -~~~~~~~~~~~~~{.prolog} - a :- repeat, read(X), write(X), nl, X=end_of_file, !. -~~~~~~~~~~~~~ -the loop is effectively terminated by the cut-goal, when the test-goal -`X=end` succeeds. While the test fails, the goals `read(X)`, -`write(X)`, and `nl` are executed repeatedly, because -backtracking is caught by the `repeat` goal. - -The built-in `repeat/0` could be defined in Prolog by: - -~~~~~{.prolog} - repeat. - repeat :- repeat. -~~~~~ - -The predicate between/3 can be used to iterate for a pre-defined -number of steps. - -*/ - -/** @pred call(+ _P_) is iso -Meta-call predicate. - -If _P_ is instantiated to an atom or a compound term, the goal `call( -_P_)` is executed as if the clause was originally written as _P_ -instead as call( _P_ ), except that any "cut" occurring in _P_ only -cuts alternatives in the execution of _P_. - - -*/ - -/** @pred incore(+ _P_) - - -The same as call/1. - - -*/ - -/** @pred call(+ _Closure_,...,? _Ai_,...) is iso - - -Meta-call where _Closure_ is a closure that is converted into a goal by -appending the _Ai_ additional arguments. The number of arguments varies -between 0 and 10. - - -*/ - -/** @pred call_with_args(+ _Name_,...,? _Ai_,...) - - -Meta-call where _Name_ is the name of the procedure to be called and -the _Ai_ are the arguments. The number of arguments varies between 0 -and 10. New code should use `call/N` for better portability. - -If _Name_ is a complex term, then call_with_args/n behaves as -call/n: - -~~~~~{.prolog} -call(p(X1,...,Xm), Y1,...,Yn) :- p(X1,...,Xm,Y1,...,Yn). -~~~~~ - - -*/ - - -/** @pred + _P_ is nondet - -The same as `call( _P_)`. This feature has been kept to provide -compatibility with C-Prolog. When compiling a goal, YAP -generates a `call( _X_)` whenever a variable _X_ is found as -a goal. - -~~~~~{.prolog} - a(X) :- X. -~~~~~ -is converted to: - -~~~~~{.prolog} - a(X) :- call(X). -~~~~~ - - -*/ - -/** @pred if(? _G_,? _H_,? _I_) - -Call goal _H_ once per each solution of goal _H_. If goal - _H_ has no solutions, call goal _I_. - -The built-in `if/3` is similar to `->/3`, with the difference -that it will backtrack over the test goal. Consider the following -small data-base: - -~~~~~{.prolog} -a(1). b(a). c(x). -a(2). b(b). c(y). -~~~~~ - -Execution of an `if/3` query will proceed as follows: - -~~~~~{.prolog} - ?- if(a(X),b(Y),c(Z)). - -X = 1, -Y = a ? ; - -X = 1, -Y = b ? ; - -X = 2, -Y = a ? ; - -X = 2, -Y = b ? ; - -no -~~~~~ - -The system will backtrack over the two solutions for `a/1` and the -two solutions for `b/1`, generating four solutions. - -Cuts are allowed inside the first goal _G_, but they will only prune -over _G_. - -If you want _G_ to be deterministic you should use if-then-else, as -it is both more efficient and more portable. - - -*/ - -/** @pred once(: _G_) is iso - - -Execute the goal _G_ only once. The predicate is defined by: - -~~~~~{.prolog} - once(G) :- call(G), !. -~~~~~ - -Note that cuts inside once/1 can only cut the other goals inside -once/1. - - -*/ - -/** @pred forall(: _Cond_,: _Action_) - - -For all alternative bindings of _Cond_ _Action_ can be -proven. The example verifies that all arithmetic statements in the list - _L_ are correct. It does not say which is wrong if one proves wrong. - -~~~~~{.prolog} -?- forall(member(Result = Formula, [2 = 1 + 1, 4 = 2 * 2]), - Result =:= Formula). -~~~~~ - - -*/ - -/** @pred ignore(: _Goal_) - - -Calls _Goal_ as once/1, but succeeds, regardless of whether -`Goal` succeeded or not. Defined as: - -~~~~~{.prolog} -ignore(Goal) :- - Goal, !. -ignore(_). -~~~~~ - - -*/ - -/** @pred abort - - -Abandons the execution of the current goal and returns to top level. All -break levels (see break/0 below) are terminated. It is mainly -used during debugging or after a serious execution error, to return to -the top-level. - - -*/ - -/** @pred break - - -Suspends the execution of the current goal and creates a new execution -level similar to the top level, displaying the following message: - -~~~~~{.prolog} - [ Break (level ) ] -~~~~~ -telling the depth of the break level just entered. To return to the -previous level just type the end-of-file character or call the -end_of_file predicate. This predicate is especially useful during -debugging. - - -*/ - -/** @pred halt is iso - - -Halts Prolog, and exits to the calling application. In YAP, -halt/0 returns the exit code `0`. - - -*/ - -/** @pred halt(+ _I_) is iso - -Halts Prolog, and exits to the calling application returning the code -given by the integer _I_. - - -*/ - -/** @pred catch( : _Goal_,+ _Exception_,+ _Action_) is iso - - -The goal `catch( _Goal_, _Exception_, _Action_)` tries to -execute goal _Goal_. If during its execution, _Goal_ throws an -exception _E'_ and this exception unifies with _Exception_, the -exception is considered to be caught and _Action_ is executed. If -the exception _E'_ does not unify with _Exception_, control -again throws the exception. - -The top-level of YAP maintains a default exception handler that -is responsible to capture uncaught exceptions. - - -*/ - -/** @pred throw(+ _Ball_) is iso - - -The goal `throw( _Ball_)` throws an exception. Execution is -stopped, and the exception is sent to the ancestor goals until reaching -a matching catch/3, or until reaching top-level. - - -*/ - -/** @pred garbage_collect - - -The goal `garbage_collect` forces a garbage collection. - - -*/ - -/** @pred garbage_collect_atoms - - -The goal `garbage_collect` forces a garbage collection of the atoms -in the data-base. Currently, only atoms are recovered. - - -*/ - -/** @pred gc - - -The goal `gc` enables garbage collection. The same as -`yap_flag(gc,on)`. - - -*/ - -/** @pred nogc - - -The goal `nogc` disables garbage collection. The same as -`yap_flag(gc,off)`. - - -*/ - -/** @pred grow_heap(+ _Size_) -Increase heap size _Size_ kilobytes. - - -*/ - -/** @pred grow_stack(+ _Size_) - - -Increase stack size _Size_ kilobytes - - - */ - -/** @defgroup Undefined_Procedures Handling Undefined Procedures -@ingroup YAPBuiltins -@{ - -A predicate in a module is said to be undefined if there are no clauses -defining the predicate, and if the predicate has not been declared to be -dynamic. What YAP does when trying to execute undefined predicates can -be specified in three different ways: - - -+ By setting an YAP flag, through the yap_flag/2 or -set_prolog_flag/2 built-ins. This solution generalizes the -ISO standard. -+ By using the unknown/2 built-in (this solution is -compatible with previous releases of YAP). -+ By defining clauses for the hook predicate -`user:unknown_predicate_handler/3`. This solution is compatible -with SICStus Prolog. - - -In more detail: - - - -*/ - -/** @pred unknown(- _O_,+ _N_) - - -Specifies an handler to be called is a program tries to call an -undefined static procedure _P_. - -The arity of _N_ may be zero or one. If the arity is `0`, the -new action must be one of `fail`, `warning`, or -`error`. If the arity is `1`, _P_ is an user-defined -handler and at run-time, the argument to the handler _P_ will be -unified with the undefined goal. Note that _N_ must be defined prior -to calling unknown/2, and that the single argument to _N_ must -be unbound. - -In YAP, the default action is to `fail` (note that in the ISO -Prolog standard the default action is `error`). - -After defining `undefined/1` by: - -~~~~~{.prolog} -undefined(A) :- format('Undefined predicate: ~w~n',[A]), fail. -~~~~~ -and executing the goal: - -~~~~~{.prolog} -unknown(U,undefined(X)). -~~~~~ -a call to a predicate for which no clauses were defined will result in -the output of a message of the form: - -~~~~~{.prolog} -Undefined predicate: user:xyz(A1,A2) -~~~~~ -followed by the failure of that call. - - -*/ - -/** @pred yap_flag(unknown,+ _SPEC_) - -Alternatively, one can use yap_flag/2, -current_prolog_flag/2, or set_prolog_flag/2, to set this -functionality. In this case, the first argument for the built-ins should -be `unknown`, and the second argument should be either -`error`, `warning`, `fail`, or a goal. - - -*/ - -/** @pred user:unknown_predicate_handler(+G,+M,?NG) - - -The user may also define clauses for -`user:unknown_predicate_handler/3` hook predicate. This -user-defined procedure is called before any system processing for the -undefined procedure, with the first argument _G_ set to the current -goal, and the second _M_ set to the current module. The predicate - _G_ will be called from within the user module. - -If `user:unknown_predicate_handler/3` succeeds, the system will -execute _NG_. If `user:unknown_predicate_handler/3` fails, the -system will execute default action as specified by unknown/2. - - -*/ - -/** @pred exception(+ _Exception_, + _Context_, - _Action_) - - -Dynamic predicate, normally not defined. Called by the Prolog system on run-time exceptions that can be repaired `just-in-time`. The values for _Exception_ are described below. See also catch/3 and throw/1. -If this hook predicate succeeds it must instantiate the _Action_ argument to the atom `fail` to make the operation fail silently, `retry` to tell Prolog to retry the operation or `error` to make the system generate an exception. The action `retry` only makes sense if this hook modified the environment such that the operation can now succeed without error. - -+ `undefined_predicate` - _Context_ is instantiated to a predicate-indicator ( _Module:Name/Arity_). If the predicate fails Prolog will generate an existence_error exception. The hook is intended to implement alternatives to the SWI built-in autoloader, such as autoloading code from a database. Do not use this hook to suppress existence errors on predicates. See also `unknown`. -+ `undefined_global_variable` - _Context_ is instantiated to the name of the missing global variable. The hook must call nb_setval/2 or b_setval/2 before returning with the action retry. - - - - - - */ - -/** @defgroup Messages Message Handling -@ingroup YAPBuiltins -@{ - -The interaction between YAP and the user relies on YAP's ability to -portray messages. These messages range from prompts to error -information. All message processing is performed through the builtin -print_message/2, in two steps: - -+ The message is processed into a list of commands -+ The commands in the list are sent to the `format/3` builtin -in sequence. - - -The first argument to print_message/2 specifies the importance of -the message. The options are: - -+ `error` -error handling -+ `warning` -compilation and run-time warnings, -+ `informational` -generic informational messages -+ `help` -help messages (not currently implemented in YAP) -+ `query` -query used in query processing (not currently implemented in YAP) -+ `silent` -messages that do not produce output but that can be intercepted by hooks. - - -The next table shows the main predicates and hooks associated to message -handling in YAP: - - -*/ - -/** @pred print_message(+ _Kind_, _Term_) - -The predicate print_message/2 is used to print messages, notably from -exceptions in a human-readable format. _Kind_ is one of -`informational`, `banner`, `warning`, `error`, -`help` or `silent`. A human-readable message is printed to -the stream user_error. - -If the Prolog flag verbose is `silent`, messages with - _Kind_ `informational`, or `banner` are treated as -silent.@c See \cmdlineoption{-q}. - -This predicate first translates the _Term_ into a list of `message -lines` (see print_message_lines/3 for details). Next it will -call the hook message_hook/3 to allow the user intercepting the -message. If message_hook/3 fails it will print the message unless - _Kind_ is silent. - -If you need to report errors from your own predicates, we advise you to -stick to the existing error terms if you can; but should you need to -invent new ones, you can define corresponding error messages by -asserting clauses for `prolog:message/2`. You will need to declare -the predicate as multifile. - - -*/ - -/** @pred print_message_lines(+ _Stream_, + _Prefix_, + _Lines_) - - -Print a message (see print_message/2) that has been translated to -a list of message elements. The elements of this list are: - -+ _Format_-_Args_ -Where _Format_ is an atom and _Args_ is a list -of format argument. Handed to `format/3`. -+ `flush` -If this appears as the last element, _Stream_ is flushed -(see `flush_output/1`) and no final newline is generated. -+ `at_same_line` -If this appears as first element, no prefix is printed for -the first line and the line-position is not forced to 0 -(see `format/1`, `~N`). -+ `` -Handed to `format/3` as `format(Stream, Format, [])`. -+ nl -A new line is started and if the message is not complete -the _Prefix_ is printed too. - - - -*/ - -/** @pred user:message_hook(+ _Term_, + _Kind_, + _Lines_) - - -Hook predicate that may be define in the module `user` to intercept -messages from print_message/2. _Term_ and _Kind_ are the -same as passed to print_message/2. _Lines_ is a list of -format statements as described with print_message_lines/3. - -This predicate should be defined dynamic and multifile to allow other -modules defining clauses for it too. - - -*/ - -/** @pred message_to_string(+ _Term_, - _String_) - - -Translates a message-term into a string object. Primarily intended for SWI-Prolog emulation. - - - - */ - -/** @defgroup Testing_Terms Predicates on terms -@ingroup YAPBuiltins -@{ - - - - -*/ - -/** @pred var( _T_) is iso - - -Succeeds if _T_ is currently a free variable, otherwise fails. - - -*/ - -/** @pred atom( _T_) is iso - - -Succeeds if and only if _T_ is currently instantiated to an atom. - - -*/ - -/** @pred atomic(T) is iso - - -Checks whether _T_ is an atomic symbol (atom or number). - - -*/ - -/** @pred compound( _T_) is iso - - -Checks whether _T_ is a compound term. - - -*/ - -/** @pred db_reference( _T_) - - -Checks whether _T_ is a database reference. - - -*/ - -/** @pred float( _T_) is iso - - -Checks whether _T_ is a floating point number. - - -*/ - -/** @pred rational( _T_) - - -Checks whether `T` is a rational number. - - -*/ - -/** @pred integer( _T_) is iso - - -Succeeds if and only if _T_ is currently instantiated to an integer. - - -*/ - -/** @pred nonvar( _T_) is iso - - -The opposite of `var( _T_)`. - - -*/ - -/** @pred number( _T_) is iso - - -Checks whether `T` is an integer, rational or a float. - - -*/ - -/** @pred primitive( _T_) - - -Checks whether _T_ is an atomic term or a database reference. - - -*/ - -/** @pred simple( _T_) - - -Checks whether _T_ is unbound, an atom, or a number. - - -*/ - -/** @pred callable( _T_) is iso - - -Checks whether _T_ is a callable term, that is, an atom or a -compound term. - - -*/ - -/** @pred numbervars( _T_,+ _N1_,- _Nn_) - - -Instantiates each variable in term _T_ to a term of the form: -`$VAR( _I_)`, with _I_ increasing from _N1_ to _Nn_. - - -*/ - -/** @pred unnumbervars( _T_,+ _NT_) - - -Replace every `$VAR( _I_)` by a free variable. - - -*/ - -/** @pred ground( _T_) is iso - - -Succeeds if there are no free variables in the term _T_. - - -*/ - -/** @pred acyclic_term( _T_) is iso - - -Succeeds if there are loops in the term _T_, that is, it is an infinite term. - - -*/ - -/** @pred arg(+ _N_,+ _T_, _A_) is iso - - -Succeeds if the argument _N_ of the term _T_ unifies with - _A_. The arguments are numbered from 1 to the arity of the term. - -The current version will generate an error if _T_ or _N_ are -unbound, if _T_ is not a compound term, of if _N_ is not a positive -integer. Note that previous versions of YAP would fail silently -under these errors. - - -*/ - -/** @pred functor( _T_, _F_, _N_) is iso - - -The top functor of term _T_ is named _F_ and has arity _N_. - -When _T_ is not instantiated, _F_ and _N_ must be. If - _N_ is 0, _F_ must be an atomic symbol, which will be unified -with _T_. If _N_ is not 0, then _F_ must be an atom and - _T_ becomes instantiated to the most general term having functor - _F_ and arity _N_. If _T_ is instantiated to a term then - _F_ and _N_ are respectively unified with its top functor name -and arity. - -In the current version of YAP the arity _N_ must be an -integer. Previous versions allowed evaluable expressions, as long as the -expression would evaluate to an integer. This feature is not available -in the ISO Prolog standard. - - -*/ - -/** @pred _T_ =.. _L_ is iso - - -The list _L_ is built with the functor and arguments of the term - _T_. If _T_ is instantiated to a variable, then _L_ must be -instantiated either to a list whose head is an atom, or to a list -consisting of just a number. - - -*/ - -/** @pred _X_ = _Y_ is iso - - -Tries to unify terms _X_ and _Y_. - - -*/ - -/** @pred _X_ \= _Y_ is iso - - -Succeeds if terms _X_ and _Y_ are not unifiable. - - -*/ - -/** @pred unify_with_occurs_check(?T1,?T2) is iso - - -Obtain the most general unifier of terms _T1_ and _T2_, if there -is one. - -This predicate implements the full unification algorithm. An example:n - -~~~~~{.prolog} -unify_with_occurs_check(a(X,b,Z),a(X,A,f(B)). -~~~~~ -will succeed with the bindings `A = b` and `Z = f(B)`. On the -other hand: - -~~~~~{.prolog} -unify_with_occurs_check(a(X,b,Z),a(X,A,f(Z)). -~~~~~ -would fail, because `Z` is not unifiable with `f(Z)`. Note that -`(=)/2` would succeed for the previous examples, giving the following -bindings `A = b` and `Z = f(Z)`. - - -*/ - -/** @pred copy_term(? _TI_,- _TF_) is iso - - -Term _TF_ is a variant of the original term _TI_, such that for -each variable _V_ in the term _TI_ there is a new variable _V'_ -in term _TF_. Notice that: - -+ suspended goals and attributes for attributed variables in _TI_ are also duplicated; -+ ground terms are shared between the new and the old term. - -If you do not want any sharing to occur please use -duplicate_term/2. - - -*/ - -/** @pred duplicate_term(? _TI_,- _TF_) - - -Term _TF_ is a variant of the original term _TI_, such that -for each variable _V_ in the term _TI_ there is a new variable - _V'_ in term _TF_, and the two terms do not share any -structure. All suspended goals and attributes for attributed variables -in _TI_ are also duplicated. - -Also refer to copy_term/2. - - -*/ - -/** @pred is_list(+ _List_) - - -True when _List_ is a proper list. That is, _List_ -is bound to the empty list (nil) or a term with functor '.' and arity 2. - - -*/ - -/** @pred subsumes_term(? _Subsumer_, ? _Subsumed_) - - - -Succeed if _Submuser_ subsumes _Subsuned_ but does not bind any -variable in _Subsumer_. - - -*/ - -/** @pred term_subsumer(? _T1_, ? _T2_, ? _Subsumer_) - - - -Succeed if _Subsumer_ unifies with the least general -generalization over _T1_ and - _T2_. - - -*/ - -/** @pred term_variables(? _Term_, - _Variables_) is iso - - - -Unify _Variables_ with the list of all variables of term - _Term_. The variables occur in the order of their first -appearance when traversing the term depth-first, left-to-right. - - -*/ - -/** @pred rational_term_to_tree(? _TI_,- _TF_, ?SubTerms, ?MoreSubterms) - - -The term _TF_ is a forest representation (without cycles and repeated -terms) for the Prolog term _TI_. The term _TF_ is the main term. The -difference list _SubTerms_-_MoreSubterms_ stores terms of the form -_V=T_, where _V_ is a new variable occuring in _TF_, and _T_ is a copy -of a sub-term from _TI_. - - -*/ - -/** @pred term_factorized(? _TI_,- _TF_, ?SubTerms) - - -Similar to rational_term_to_tree/4, but _SubTerms_ is a proper list. - - -*/ - - -/** @defgroup Predicates_on_Atoms Predicates on Atoms -@ingroup YAPBuiltins -@{ - -The following predicates are used to manipulate atoms: - - - -*/ - -/** @pred name( _A_, _L_) - - -The predicate holds when at least one of the arguments is ground -(otherwise, an error message will be displayed). The argument _A_ will -be unified with an atomic symbol and _L_ with the list of the ASCII -codes for the characters of the external representation of _A_. - -~~~~~{.prolog} - name(yap,L). -~~~~~ -will return: - -~~~~~{.prolog} - L = [121,97,112]. -~~~~~ -and - -~~~~~{.prolog} - name(3,L). -~~~~~ -will return: - -~~~~~{.prolog} - L = [51]. -~~~~~ - - -*/ - -/** @pred atom_chars(? _A_,? _L_) is iso - - -The predicate holds when at least one of the arguments is ground -(otherwise, an error message will be displayed). The argument _A_ must -be unifiable with an atom, and the argument _L_ with the list of the -characters of _A_. - - -*/ - -/** @pred atom_codes(? _A_,? _L_) is iso - - -The predicate holds when at least one of the arguments is ground -(otherwise, an error message will be displayed). The argument _A_ will -be unified with an atom and _L_ with the list of the ASCII -codes for the characters of the external representation of _A_. - - -*/ - -/** @pred atom_concat(+ _As_,? _A_) - - -The predicate holds when the first argument is a list of atoms, and the -second unifies with the atom obtained by concatenating all the atoms in -the first list. - - -*/ - -/** @pred atomic_concat(+ _As_,? _A_) - - -The predicate holds when the first argument is a list of atomic terms, and -the second unifies with the atom obtained by concatenating all the -atomic terms in the first list. The first argument thus may contain -atoms or numbers. - - -*/ - -/** @pred atomic_list_concat(+ _As_,? _A_) - - -The predicate holds when the first argument is a list of atomic terms, and -the second unifies with the atom obtained by concatenating all the -atomic terms in the first list. The first argument thus may contain -atoms or numbers. - - -*/ - -/** @pred atomic_list_concat(? _As_,+ _Separator_,? _A_) - -Creates an atom just like atomic_list_concat/2, but inserts - _Separator_ between each pair of atoms. For example: - -~~~~~{.prolog} -?- atomic_list_concat([gnu, gnat], `, `, A). - -A = `gnu, gnat` -~~~~~ - -YAP emulates the SWI-Prolog version of this predicate that can also be -used to split atoms by instantiating _Separator_ and _Atom_ as -shown below. - -~~~~~{.prolog} -?- atomic_list_concat(L, -, 'gnu-gnat'). - -L = [gnu, gnat] -~~~~~ - - -*/ - -/** @pred atom_length(+ _A_,? _I_) is iso - - -The predicate holds when the first argument is an atom, and the second -unifies with the number of characters forming that atom. - - -*/ - -/** @pred atom_concat(? _A1_,? _A2_,? _A12_) is iso - -The predicate holds when the third argument unifies with an atom, and -the first and second unify with atoms such that their representations -concatenated are the representation for _A12_. - -If _A1_ and _A2_ are unbound, the built-in will find all the atoms -that concatenated give _A12_. - - -*/ - -/** @pred number_chars(? _I_,? _L_) is iso - -The predicate holds when at least one of the arguments is ground -(otherwise, an error message will be displayed). The argument _I_ must -be unifiable with a number, and the argument _L_ with the list of the -characters of the external representation of _I_. - - -*/ - -/** @pred number_codes(? _A_,? _L_) is iso - - -The predicate holds when at least one of the arguments is ground -(otherwise, an error message will be displayed). The argument _A_ -will be unified with a number and _L_ with the list of the ASCII -codes for the characters of the external representation of _A_. - - -*/ - -/** @pred atom_number(? _Atom_,? _Number_) - - -The predicate holds when at least one of the arguments is ground -(otherwise, an error message will be displayed). If the argument - _Atom_ is an atom, _Number_ must be the number corresponding -to the characters in _Atom_, otherwise the characters in - _Atom_ must encode a number _Number_. - - -*/ - -/** @pred number_atom(? _I_,? _L_) - - - -The predicate holds when at least one of the arguments is ground -(otherwise, an error message will be displayed). The argument _I_ must -be unifiable with a number, and the argument _L_ must be unifiable -with an atom representing the number. - - -*/ - -/** @pred sub_atom(+ _A_,? _Bef_, ? _Size_, ? _After_, ? _At_out_) is iso - - -True when _A_ and _At_out_ are atoms such that the name of - _At_out_ has size _Size_ and is a sub-string of the name of - _A_, such that _Bef_ is the number of characters before and - _After_ the number of characters afterwards. - -Note that _A_ must always be known, but _At_out_ can be unbound when -calling this built-in. If all the arguments for sub_atom/5 but _A_ -are unbound, the built-in will backtrack through all possible -sub-strings of _A_. - - - - - */ - -/** @defgroup Predicates_on_Characters Predicates on Characters -@ingroup YAPBuiltins -@{ - -The following predicates are used to manipulate characters: - - - -*/ - -/** @pred char_code(? _A_,? _I_) is iso - - -The built-in succeeds with _A_ bound to character represented as an -atom, and _I_ bound to the character code represented as an -integer. At least, one of either _A_ or _I_ must be bound before -the call. - - -*/ - -/** @pred char_type(? _Char_, ? _Type_) - - -Tests or generates alternative _Types_ or _Chars_. The -character-types are inspired by the standard `C` -`` primitives. - -+ `alnum` - _Char_ is a letter (upper- or lowercase) or digit. - -+ `alpha` - _Char_ is a letter (upper- or lowercase). - -+ `csym` - _Char_ is a letter (upper- or lowercase), digit or the underscore (_). These are valid C- and Prolog symbol characters. - -+ `csymf` - _Char_ is a letter (upper- or lowercase) or the underscore (_). These are valid first characters for C- and Prolog symbols - -+ `ascii` - _Char_ is a 7-bits ASCII character (0..127). - -+ `white` - _Char_ is a space or tab. E.i. white space inside a line. - -+ `cntrl` - _Char_ is an ASCII control-character (0..31). - -+ `digit` - _Char_ is a digit. - -+ `digit( _Weight_)` - _Char_ is a digit with value _Weight_. I.e. `char_type(X, digit(6))` yields X = aaasaá'6'. Useful for parsing numbers. - -+ `xdigit( _Weight_)` - _Char_ is a hexa-decimal digit with value _Weight_. I.e. char_type(a, xdigit(X) yields X = '10'. Useful for parsing numbers. - -+ `graph` - _Char_ produces a visible mark on a page when printed. Note that the space is not included! - -+ `lower` - _Char_ is a lower-case letter. - -+ `lower(Upper)` - _Char_ is a lower-case version of _Upper_. Only true if _Char_ is lowercase and _Upper_ uppercase. - -+ `to_lower(Upper)` - _Char_ is a lower-case version of Upper. For non-letters, or letter without case, _Char_ and Lower are the same. See also upcase_atom/2 and downcase_atom/2. - -+ `upper` - _Char_ is an upper-case letter. - -+ `upper(Lower)` - _Char_ is an upper-case version of Lower. Only true if _Char_ is uppercase and Lower lowercase. - -+ `to_upper(Lower)` - _Char_ is an upper-case version of Lower. For non-letters, or letter without case, _Char_ and Lower are the same. See also upcase_atom/2 and downcase_atom/2. - -+ `punct` - _Char_ is a punctuation character. This is a graph character that is not a letter or digit. - -+ `space` - _Char_ is some form of layout character (tab, vertical-tab, newline, etc.). - -+ `end_of_file` - _Char_ is -1. - -+ `end_of_line` - _Char_ ends a line (ASCII: 10..13). - -+ `newline` - _Char_ is a the newline character (10). - -+ `period` - _Char_ counts as the end of a sentence (.,!,?). - -+ `quote` - _Char_ is a quote-character. - -+ `paren(Close)` - _Char_ is an open-parenthesis and Close is the corresponding close-parenthesis. - - -+ `code_type(? _Code_, ? _Type_)` - - -As char_type/2, but uses character-codes rather than -one-character atoms. Please note that both predicates are as -flexible as possible. They handle either representation if the -argument is instantiated and only will instantiate with an integer -code or one-character atom depending of the version used. See also -the prolog-flag double_quotes and the built-in predicates -atom_chars/2 and atom_codes/2. - - - - - */ - -/** @defgroup Comparing_Terms Comparing Terms -@ingroup YAPBuiltins -@{ - -The following predicates are used to compare and order terms, using the -standard ordering: - -+ -variables come before numbers, numbers come before atoms which in turn -come before compound terms, i.e.: variables @< numbers @< atoms @< -compound terms. -+ -Variables are roughly ordered by "age" (the "oldest" variable is put -first); -+ -Floating point numbers are sorted in increasing order; -+ -Rational numbers are sorted in increasing order; -+ -Integers are sorted in increasing order; -+ -Atoms are sorted in lexicographic order; -+ -Compound terms are ordered first by arity of the main functor, then by -the name of the main functor, and finally by their arguments in -left-to-right order. - - - - - -*/ - -/** @pred compare( _C_, _X_, _Y_) is iso - - -As a result of comparing _X_ and _Y_, _C_ may take one of -the following values: - -+ -`=` if _X_ and _Y_ are identical; -+ -`<` if _X_ precedes _Y_ in the defined order; -+ -`>` if _Y_ precedes _X_ in the defined order; - - -+ _X_ == _Y_ is iso - - -Succeeds if terms _X_ and _Y_ are strictly identical. The -difference between this predicate and =/2 is that, if one of the -arguments is a free variable, it only succeeds when they have already -been unified. - -~~~~~{.prolog} -?- X == Y. -~~~~~ -fails, but, - -~~~~~{.prolog} -?- X = Y, X == Y. -~~~~~ -succeeds. - -~~~~~{.prolog} -?- X == 2. -~~~~~ -fails, but, - -~~~~~{.prolog} -?- X = 2, X == 2. -~~~~~ -succeeds. - - -*/ - -/** @pred _X_ \== _Y_ is iso - - -Terms _X_ and _Y_ are not strictly identical. - - -*/ - -/** @pred _X_ @< _Y_ is iso - - -Term _X_ precedes term _Y_ in the standard order. - - -*/ - -/** @pred _X_ @=< _Y_ is iso - - -Term _X_ does not follow term _Y_ in the standard order. - - -*/ - -/** @pred _X_ @> _Y_ is iso - - -Term _X_ follows term _Y_ in the standard order. - - -*/ - -/** @pred _X_ @>= _Y_ is iso - - -Term _X_ does not precede term _Y_ in the standard order. - - -*/ - -/** @pred sort(+ _L_,- _S_) is iso - - -Unifies _S_ with the list obtained by sorting _L_ and merging -identical (in the sense of `==`) elements. - - -*/ - -/** @pred keysort(+ _L_, _S_) is iso - - -Assuming L is a list of the form ` _Key_- _Value_`, -`keysort(+ _L_, _S_)` unifies _S_ with the list obtained -from _L_, by sorting its elements according to the value of - _Key_. - -~~~~~{.prolog} -?- keysort([3-a,1-b,2-c,1-a,1-b],S). -~~~~~ -would return: - -~~~~~{.prolog} -S = [1-b,1-a,1-b,2-c,3-a] -~~~~~ - - -*/ - -/** @pred predsort(+ _Pred_, + _List_, - _Sorted_) - - -Sorts similar to sort/2, but determines the order of two terms by -calling _Pred_(- _Delta_, + _E1_, + _E2_) . This call must -unify _Delta_ with one of `<`, `>` or `=`. If -built-in predicate compare/3 is used, the result is the same as -sort/2. - - -*/ - -/** @pred length(? _L_,? _S_) - - -Unify the well-defined list _L_ with its length. The procedure can -be used to find the length of a pre-defined list, or to build a list -of length _S_. - - - - - */ - -/** @defgroup Arithmetic Arithmetic -@ingroup YAPBuiltins -@{ - -@copydoc arithmetic - - * See @ref arithmetic_preds for the predicates that implement arithment - - * See @ref arithmetic_cmps for the arithmetic comparisons supported in YAP - - * See @ref arithmetic_operators for how to call arithmetic operations in YAP - - - */ - -/** @defgroup InputOutput Input/Output Predicates -@ingroup YAPBuiltins -@{ - -Some of the Input/Output predicates described below will in certain conditions -provide error messages and abort only if the file_errors flag is set. -If this flag is cleared the same predicates will just fail. Details on -setting and clearing this flag are given under 7.7. - - - */ - -/** @defgroup Streams_and_Files Handling Streams and Files -@ingroup YAPBuiltins -@{ - - - - -*/ - -/** @pred open(+ _F_,+ _M_,- _S_) is iso - - -Opens the file with name _F_ in mode _M_ (`read`, `write` or -`append`), returning _S_ unified with the stream name. - -At most, there are 17 streams opened at the same time. Each stream is -either an input or an output stream but not both. There are always 3 -open streams: user_input for reading, user_output for writing -and user_error for writing. If there is no ambiguity, the atoms -user_input and user_output may be referred to as `user`. - -The `file_errors` flag controls whether errors are reported when in -mode `read` or `append` the file _F_ does not exist or is not -readable, and whether in mode `write` or `append` the file is not -writable. - -*/ - -/** @pred open(+ _F_,+ _M_,- _S_,+ _Opts_) is iso - -Opens the file with name _F_ in mode _M_ (`read`, `write` or -`append`), returning _S_ unified with the stream name, and following -these options: - - - -+ `type(+ _T_)` is iso - - Specify whether the stream is a `text` stream (default), or a -`binary` stream. - -+ `reposition(+ _Bool_)` is iso - Specify whether it is possible to reposition the stream (`true`), or -not (`false`). By default, YAP enables repositioning for all -files, except terminal files and sockets. - -+ `eof(+ _Action_)` is iso - - Specify the action to take if attempting to input characters from a -stream where we have previously found an `end_of_file`. The possible -actions are `error`, that raises an error, `reset`, that tries to -reset the stream and is used for `tty` type files, and `eof_code`, -which generates a new `end_of_file` (default for non-tty files). - -+ `alias(+ _Name_)` is iso - - Specify an alias to the stream. The alias Name must be an atom. The -alias can be used instead of the stream descriptor for every operation -concerning the stream. - - The operation will fail and give an error if the alias name is already -in use. YAP allows several aliases for the same file, but only -one is returned by stream_property/2 - -+ `bom(+ _Bool_)` - - If present and `true`, a BOM (Byte Order Mark) was -detected while opening the file for reading or a BOM was written while -opening the stream. See BOM for details. - -+ `encoding(+ _Encoding_)` - -Set the encoding used for text. See Encoding for an overview of -wide character and encoding issues. - -+ `representation_errors(+ _Mode_)` - - Change the behaviour when writing characters to the stream that cannot -be represented by the encoding. The behaviour is one of `error` -(throw and Input/Output error exception), `prolog` (write `\u...\` -escape code or `xml` (write `\&#...;` XML character entity). -The initial mode is `prolog` for the user streams and -`error` for all other streams. See also Encoding. - -+ `expand_filename(+ _Mode_)` - - If _Mode_ is `true` then do filename expansion, then ask Prolog -to do file name expansion before actually trying to opening the file: -this includes processing `~` characters and processing `$` -environment variables at the beginning of the file. Otherwise, just try -to open the file using the given name. - - The default behavior is given by the Prolog flag -open_expands_filename. - - - - -*/ - -/** @pred close(+ _S_) is iso - - -Closes the stream _S_. If _S_ does not stand for a stream -currently opened an error is reported. The streams user_input, -user_output, and user_error can never be closed. - - -*/ - -/** @pred close(+ _S_,+ _O_) is iso - -Closes the stream _S_, following options _O_. - -The only valid options are `force(true)` and `force(false)`. -YAP currently ignores these options. - - -*/ - -/** @pred time_file(+ _File_,- _Time_) - - -Unify the last modification time of _File_ with - _Time_. _Time_ is a floating point number expressing the seconds -elapsed since Jan 1, 1970. - - -*/ - -/** @pred access_file(+ _F_,+ _M_) - -Is the file accessible? - - -*/ - -/** @pred file_base_name(+ _Name_,- _FileName_) - - -Give the path a full path _FullPath_ extract the _FileName_. - - -*/ - -/** @pred file_name_extension(? _Base_,? _Extension_, ? _Name_) - - - -This predicate is used to add, remove or test filename extensions. The -main reason for its introduction is to deal with different filename -properties in a portable manner. If the file system is -case-insensitive, testing for an extension will be done -case-insensitive too. _Extension_ may be specified with or -without a leading dot (.). If an _Extension_ is generated, it -will not have a leading dot. - - -*/ - -/** @pred current_stream( _F_, _M_, _S_) - - -Defines the relation: The stream _S_ is opened on the file _F_ -in mode _M_. It might be used to obtain all open streams (by -backtracking) or to access the stream for a file _F_ in mode - _M_, or to find properties for a stream _S_. Notice that some -streams might not be associated to a file: in this case YAP tries to -return the file number. If that is not available, YAP unifies _F_ -with _S_. - - -*/ - -/** @pred is_stream( _S_) - - -Succeeds if _S_ is a currently open stream. - - -*/ - -/** @pred flush_output is iso - - -Send out all data in the output buffer of the current output stream. - - -*/ - -/** @pred flush_output(+ _S_) is iso - -Send all data in the output buffer for stream _S_. - - -*/ - -/** @pred set_input(+ _S_) is iso - - -Set stream _S_ as the current input stream. Predicates like read/1 -and get/1 will start using stream _S_. - - -*/ - -/** @pred set_output(+ _S_) is iso - - -Set stream _S_ as the current output stream. Predicates like -write/1 and put/1 will start using stream _S_. - - -*/ - -/** @pred stream_select(+ _STREAMS_,+ _TIMEOUT_,- _READSTREAMS_) - - -Given a list of open _STREAMS_ opened in read mode and a _TIMEOUT_ -return a list of streams who are now available for reading. - -If the _TIMEOUT_ is instantiated to `off`, -stream_select/3 will wait indefinitely for a stream to become -open. Otherwise the timeout must be of the form `SECS:USECS` where -`SECS` is an integer gives the number of seconds to wait for a timeout -and `USECS` adds the number of micro-seconds. - -This built-in is only defined if the system call `select` is -available in the system. - - -*/ - -/** @pred current_input(- _S_) is iso - - -Unify _S_ with the current input stream. - - -*/ - -/** @pred current_output(- _S_) is iso - - -Unify _S_ with the current output stream. - - -*/ - -/** @pred at_end_of_stream is iso - - -Succeed if the current stream has stream position end-of-stream or -past-end-of-stream. - - -*/ - -/** @pred at_end_of_stream(+ _S_) is iso - -Succeed if the stream _S_ has stream position end-of-stream or -past-end-of-stream. Note that _S_ must be a readable stream. - - -*/ - -/** @pred set_stream_position(+ _S_, + _POS_) is iso - - -Given a stream position _POS_ for a stream _S_, set the current -stream position for _S_ to be _POS_. - - -*/ - -/** @pred stream_property(? _Stream_,? _Prop_) is iso - - - -Obtain the properties for the open streams. If the first argument is -unbound, the procedure will backtrack through all open -streams. Otherwise, the first argument must be a stream term (you may -use `current_stream` to obtain a current stream given a file name). - -The following properties are recognized: - - - -+ file_name( _P_) -An atom giving the file name for the current stream. The file names are -user_input, user_output, and user_error for the -standard streams. - -+ mode( _P_) -The mode used to open the file. It may be one of `append`, -`read`, or `write`. - -+ input -The stream is readable. - -+ output -The stream is writable. - -+ alias( _A_) -ISO-Prolog primitive for stream aliases. YAP returns one of the -existing aliases for the stream. - -+ position( _P_) -A term describing the position in the stream. - -+ end_of_stream( _E_) -Whether the stream is `at` the end of stream, or it has found the -end of stream and is `past`, or whether it has `not` yet -reached the end of stream. - -+ eof_action( _A_) -The action to take when trying to read after reaching the end of -stream. The action may be one of `error`, generate an error, -`eof_code`, return character code `-1`, or `reset` the -stream. - -+ reposition( _B_) -Whether the stream can be repositioned or not, that is, whether it is -seekable. - -+ type( _T_) -Whether the stream is a `text` stream or a `binary` stream. - -+ bom(+ _Bool_) -If present and `true`, a BOM (Byte Order Mark) was -detected while opening the file for reading or a BOM was written while -opening the stream. See BOM for details. - -+ encoding(+ _Encoding_) -Query the encoding used for text. See Encoding for an -overview of wide character and encoding issues in YAP. - -+ representation_errors(+ _Mode_) -Behaviour when writing characters to the stream that cannot be -represented by the encoding. The behaviour is one of `error` -(throw and Input/Output error exception), `prolog` (write `\u...\` -escape code or `xml` (write `\&#...;` XML character entity). -The initial mode is `prolog` for the user streams and -`error` for all other streams. See also Encoding and -`open/4`. - - - -+ current_line_number(- _LineNumber_) - - -Unify _LineNumber_ with the line number for the current stream. - - -*/ - -/** @pred current_line_number(+ _Stream_,- _LineNumber_) - -Unify _LineNumber_ with the line number for the _Stream_. - - -*/ - -/** @pred line_count(+ _Stream_,- _LineNumber_) - - -Unify _LineNumber_ with the line number for the _Stream_. - - -*/ - -/** @pred character_count(+ _Stream_,- _CharacterCount_) - - -Unify _CharacterCount_ with the number of characters written to or -read to _Stream_. - - -*/ - -/** @pred line_position(+ _Stream_,- _LinePosition_) - - -Unify _LinePosition_ with the position on current text stream - _Stream_. - - -*/ - -/** @pred stream_position(+ _Stream_,- _StreamPosition_) - - -Unify _StreamPosition_ with the packaged information of position on -current stream _Stream_. Use stream_position_data/3 to -retrieve information on character or line count. - - -*/ - -/** @pred stream_position_data(+ _Field_,+ _StreamPosition_,- _Info_) - - -Given the packaged stream position term _StreamPosition_, unify - _Info_ with _Field_ `line_count`, `byte_count`, or -`char_count`. - - - - - */ - -/** @defgroup ChYProlog_File_Handling C-Prolog File Handling -@ingroup YAPBuiltins -@{ - - - - -*/ - -/** @pred tell(+ _S_) - - -If _S_ is a currently opened stream for output, it becomes the -current output stream. If _S_ is an atom it is taken to be a -filename. If there is no output stream currently associated with it, -then it is opened for output, and the new output stream created becomes -the current output stream. If it is not possible to open the file, an -error occurs. If there is a single opened output stream currently -associated with the file, then it becomes the current output stream; if -there are more than one in that condition, one of them is chosen. - -Whenever _S_ is a stream not currently opened for output, an error -may be reported, depending on the state of the file_errors flag. The -predicate just fails, if _S_ is neither a stream nor an atom. - - -*/ - -/** @pred telling(- _S_) - - -The current output stream is unified with _S_. - - -*/ - -/** @pred told - - -Closes the current output stream, and the user's terminal becomes again -the current output stream. It is important to remember to close streams -after having finished using them, as the maximum number of -simultaneously opened streams is 17. - - -*/ - -/** @pred see(+ _S_) - - -If _S_ is a currently opened input stream then it is assumed to be -the current input stream. If _S_ is an atom it is taken as a -filename. If there is no input stream currently associated with it, then -it is opened for input, and the new input stream thus created becomes -the current input stream. If it is not possible to open the file, an -error occurs. If there is a single opened input stream currently -associated with the file, it becomes the current input stream; if there -are more than one in that condition, then one of them is chosen. - -When _S_ is a stream not currently opened for input, an error may be -reported, depending on the state of the `file_errors` flag. If - _S_ is neither a stream nor an atom the predicates just fails. - - -*/ - -/** @pred seeing(- _S_) - - -The current input stream is unified with _S_. - - -*/ - -/** @pred seen - - -Closes the current input stream (see 6.7.). - - - - - */ - -/** @defgroup InputOutput_of_Terms Handling Input/Output of Terms -@ingroup YAPBuiltins -@{ - - - - -*/ - -/** @pred read(- _T_) is iso - - -Reads the next term from the current input stream, and unifies it with - _T_. The term must be followed by a dot (`.`) and any blank-character -as previously defined. The syntax of the term must match the current -declarations for operators (see op). If the end-of-stream is reached, - _T_ is unified with the atom `end_of_file`. Further reads from of -the same stream may cause an error failure (see open/3). - -*/ - -/** @pred read_term(- _T_,+ _Options_) is iso - - -Reads term _T_ from the current input stream with execution -controlled by the following options: - -+ term_position(- _Position_) - -Unify _Position_ with a term describing the position of the stream -at the start of parse. Use stream_position_data/3 to obtain extra -information. - -+ singletons(- _Names_) - -Unify _Names_ with a list of the form _Name=Var_, where - _Name_ is the name of a non-anonymous singleton variable in the -original term, and `Var` is the variable's representation in -YAP. -The variables occur in left-to-right traversal order. - -+ syntax_errors(+ _Val_) - -Control action to be taken after syntax errors. See yap_flag/2 -for detailed information. - -+ variables(- _Names_) - -Unify _Names_ with a list of the form _Name=Var_, where _Name_ is -the name of a non-anonymous variable in the original term, and _Var_ -is the variable's representation in YAP. -The variables occur in left-to-right traversal order. - - -*/ - -/** @pred char_conversion(+ _IN_,+ _OUT_) is iso - - -While reading terms convert unquoted occurrences of the character - _IN_ to the character _OUT_. Both _IN_ and _OUT_ must be -bound to single characters atoms. - -Character conversion only works if the flag `char_conversion` is -on. This is default in the `iso` and `sicstus` language -modes. As an example, character conversion can be used for instance to -convert characters from the ISO-LATIN-1 character set to ASCII. - -If _IN_ is the same character as _OUT_, char_conversion/2 -will remove this conversion from the table. - - -*/ - -/** @pred current_char_conversion(? _IN_,? _OUT_) is iso - - -If _IN_ is unbound give all current character -translations. Otherwise, give the translation for _IN_, if one -exists. - - -*/ - -/** @pred write( _T_) is iso - - -The term _T_ is written to the current output stream according to -the operator declarations in force. - - -*/ - -/** @pred writeln( _T_) is iso - - -Same as write/1 followed by nl/0. - - -*/ - -/** @pred display(+ _T_) - - -Displays term _T_ on the current output stream. All Prolog terms are -written in standard parenthesized prefix notation. - - -*/ - -/** @pred write_canonical(+ _T_) is iso - - -Displays term _T_ on the current output stream. Atoms are quoted -when necessary, and operators are ignored, that is, the term is written -in standard parenthesized prefix notation. - - -*/ - -/** @pred write_term(+ _T_, + _Opts_) is iso - - -Displays term _T_ on the current output stream, according to the -following options: - -+ quoted(+ _Bool_) is iso -If `true`, quote atoms if this would be necessary for the atom to -be recognized as an atom by YAP's parser. The default value is -`false`. - -+ ignore_ops(+ _Bool_) is iso -If `true`, ignore operator declarations when writing the term. The -default value is `false`. - -+ numbervars(+ _Bool_) is iso -If `true`, output terms of the form -`$VAR(N)`, where _N_ is an integer, as a sequence of capital -letters. The default value is `false`. - -+ portrayed(+ _Bool_) -If `true`, use portray/1 to portray bound terms. The default -value is `false`. - -+ portray(+ _Bool_) -If `true`, use portray/1 to portray bound terms. The default -value is `false`. - -+ max_depth(+ _Depth_) -If `Depth` is a positive integer, use Depth as -the maximum depth to portray a term. The default is `0`, that is, -unlimited depth. - -+ priority(+ _Piority_) -If `Priority` is a positive integer smaller than `1200`, -give the context priority. The default is `1200`. - -+ cycles(+ _Bool_) -Do not loop in rational trees (default). - - - -*/ - -/** @pred writeq( _T_) is iso - - -Writes the term _T_, quoting names to make the result acceptable to -the predicate `read` whenever necessary. - - -*/ - -/** @pred print( _T_) - - -Prints the term _T_ to the current output stream using write/1 -unless T is bound and a call to the user-defined predicate -`portray/1` succeeds. To do pretty printing of terms the user should -define suitable clauses for `portray/1` and use print/1. - - -*/ - -/** @pred format(+ _T_,+ _L_) - - -Print formatted output to the current output stream. The arguments in -list _L_ are output according to the string or atom _T_. - -A control sequence is introduced by a `w`. The following control -sequences are available in YAP: - - - -+ `~~` -Print a single tilde. - -+ `~a` -The next argument must be an atom, that will be printed as if by `write`. - -+ `~Nc` -The next argument must be an integer, that will be printed as a -character code. The number _N_ is the number of times to print the -character (default 1). - -+ `~Ne` -+ `~NE` -+ `~Nf` -+ `~Ng` -+ `~NG` -The next argument must be a floating point number. The float _F_, the number - _N_ and the control code `c` will be passed to `printf` as: - -~~~~~{.prolog} - printf("%s.Nc", F) -~~~~~ - -As an example: - -~~~~~{.prolog} -?- format("~8e, ~8E, ~8f, ~8g, ~8G~w", - [3.14,3.14,3.14,3.14,3.14,3.14]). -3.140000e+00, 3.140000E+00, 3.140000, 3.14, 3.143.14 -~~~~~ - -+ `~Nd` -The next argument must be an integer, and _N_ is the number of digits -after the decimal point. If _N_ is `0` no decimal points will be -printed. The default is _N = 0_. - -~~~~~{.prolog} -?- format("~2d, ~d",[15000, 15000]). -150.00, 15000 -~~~~~ - -+ `~ND` -Identical to `~Nd`, except that commas are used to separate groups -of three digits. - -~~~~~{.prolog} -?- format("~2D, ~D",[150000, 150000]). -1,500.00, 150,000 -~~~~~ - -+ `~i` -Ignore the next argument in the list of arguments: - -~~~~~{.prolog} -?- format('The ~i met the boregrove',[mimsy]). -The met the boregrove -~~~~~ - -+ `~k` -Print the next argument with `write_canonical`: - -~~~~~{.prolog} -?- format("Good night ~k",a+[1,2]). -Good night +(a,[1,2]) -~~~~~ - -+ `~Nn` -Print _N_ newlines (where _N_ defaults to 1). - -+ `~NN` -Print _N_ newlines if at the beginning of the line (where _N_ -defaults to 1). - -+ `~Nr` -The next argument must be an integer, and _N_ is interpreted as a -radix, such that `2 <= N <= 36` (the default is 8). - -~~~~~{.prolog} -?- format("~2r, 0x~16r, ~r", - [150000, 150000, 150000]). -100100100111110000, 0x249f0, 444760 -~~~~~ - -Note that the letters `a-z` denote digits larger than 9. - -+ `~NR` -Similar to `~NR`. The next argument must be an integer, and _N_ is -interpreted as a radix, such that `2 <= N <= 36` (the default is 8). - -~~~~~{.prolog} -?- format("~2r, 0x~16r, ~r", - [150000, 150000, 150000]). -100100100111110000, 0x249F0, 444760 -~~~~~ - -The only difference is that letters `A-Z` denote digits larger than 9. - -+ `~p` -Print the next argument with print/1: - -~~~~~{.prolog} -?- format("Good night ~p",a+[1,2]). -Good night a+[1,2] -~~~~~ - -+ `~q` -Print the next argument with writeq/1: - -~~~~~{.prolog} -?- format("Good night ~q",'Hello'+[1,2]). -Good night 'Hello'+[1,2] -~~~~~ - -+ `~Ns` -The next argument must be a list of character codes. The system then -outputs their representation as a string, where _N_ is the maximum -number of characters for the string ( _N_ defaults to the length of the -string). - -~~~~~{.prolog} -?- format("The ~s are ~4s",["woods","lovely"]). -The woods are love -~~~~~ - -+ `~w` -Print the next argument with write/1: - -~~~~~ -?- format("Good night ~w",'Hello'+[1,2]). -Good night Hello+[1,2] -~~~~~ - - -The number of arguments, `N`, may be given as an integer, or it -may be given as an extra argument. The next example shows a small -procedure to write a variable number of `a` characters: - -~~~~~ -write_many_as(N) :- - format("~*c",[N,0'a]). -~~~~~ - -The format/2 built-in also allows for formatted output. One can -specify column boundaries and fill the intermediate space by a padding -character: - -+ `~N|` -Set a column boundary at position _N_, where _N_ defaults to the -current position. - -+ `~N+` -Set a column boundary at _N_ characters past the current position, where - _N_ defaults to `8`. - -+ `~Nt` -Set padding for a column, where _N_ is the fill code (default is -`SPC`). - - - -The next example shows how to align columns and padding. We first show -left-alignment: - -~~~~~ - ?- format("~n*Hello~16+*~n",[]). -*Hello * -~~~~~ - -Note that we reserve 16 characters for the column. - -The following example shows how to do right-alignment: - -~~~~~ - ?- format("*~tHello~16+*~n",[]). -* Hello* - -~~~~~ - -The `~t` escape sequence forces filling before `Hello`. - -We next show how to do centering: - -~~~~~ - ?- format("*~tHello~t~16+*~n",[]). -* Hello * -~~~~~ - -The two `~t` escape sequence force filling both before and after -`Hello`. Space is then evenly divided between the right and the -left sides. - - -*/ - -/** @pred format(+ _T_) - -Print formatted output to the current output stream. - - -*/ - -/** @pred format(+ _S_,+ _T_,+ _L_) - -Print formatted output to stream _S_. - - -*/ - -/** @pred with_output_to(+ _Ouput_,: _Goal_) - - -Run _Goal_ as once/1, while characters written to the current -output are sent to _Output_. The predicate is SWI-Prolog -specific. - -Applications should generally avoid creating atoms by breaking and -concatenating other atoms as the creation of large numbers of -intermediate atoms generally leads to poor performance, even more so in -multi-threaded applications. This predicate supports creating -difference-lists from character data efficiently. The example below -defines the DCG rule `term/3` to insert a term in the output: - -~~~~~ - term(Term, In, Tail) :- - with_output_to(codes(In, Tail), write(Term)). - -?- phrase(term(hello), X). - -X = [104, 101, 108, 108, 111] -~~~~~ - -+ A Stream handle or alias -Temporary switch current output to the given stream. Redirection using with_output_to/2 guarantees the original output is restored, also if Goal fails or raises an exception. See also call_cleanup/2. -+ atom(- _Atom_) -Create an atom from the emitted characters. Please note the remark above. -+ string(- _String_) -Create a string-object (not supported in YAP). -+ codes(- _Codes_) -Create a list of character codes from the emitted characters, similar to atom_codes/2. -+ codes(- _Codes_, - _Tail_) -Create a list of character codes as a difference-list. -+ chars(- _Chars_) -Create a list of one-character-atoms codes from the emitted characters, similar to atom_chars/2. -+ chars(- _Chars_, - _Tail_) -Create a list of one-character-atoms as a difference-list. - - - - - - */ - -/** @defgroup InputOutput_of_Characters Handling Input/Output of Characters -@ingroup YAPBuiltins -@{ - - - - -*/ - -/** @pred put(+ _N_) - - -Outputs to the current output stream the character whose ASCII code is - _N_. The character _N_ must be a legal ASCII character code, an -expression yielding such a code, or a list in which case only the first -element is used. - - -*/ - -/** @pred put_byte(+ _N_) is iso - - -Outputs to the current output stream the character whose code is - _N_. The current output stream must be a binary stream. - - -*/ - -/** @pred put_char(+ _N_) is iso - - -Outputs to the current output stream the character who is used to build -the representation of atom `A`. The current output stream must be a -text stream. - - -*/ - -/** @pred put_code(+ _N_) is iso - - -Outputs to the current output stream the character whose ASCII code is - _N_. The current output stream must be a text stream. The character - _N_ must be a legal ASCII character code, an expression yielding such -a code, or a list in which case only the first element is used. - - -*/ - -/** @pred get(- _C_) - - -The next non-blank character from the current input stream is unified -with _C_. Blank characters are the ones whose ASCII codes are not -greater than 32. If there are no more non-blank characters in the -stream, _C_ is unified with -1. If `end_of_stream` has already -been reached in the previous reading, this call will give an error message. - - -*/ - -/** @pred get0(- _C_) - - -The next character from the current input stream is consumed, and then -unified with _C_. There are no restrictions on the possible -values of the ASCII code for the character, but the character will be -internally converted by YAP. - - -*/ - -/** @pred get_byte(- _C_) is iso - - -If _C_ is unbound, or is a character code, and the current stream is a -binary stream, read the next byte from the current stream and unify its -code with _C_. - - -*/ - -/** @pred get_char(- _C_) is iso - - -If _C_ is unbound, or is an atom representation of a character, and -the current stream is a text stream, read the next character from the -current stream and unify its atom representation with _C_. - - -*/ - -/** @pred get_code(- _C_) is iso - - -If _C_ is unbound, or is the code for a character, and -the current stream is a text stream, read the next character from the -current stream and unify its code with _C_. - - -*/ - -/** @pred peek_byte(- _C_) is iso - - -If _C_ is unbound, or is a character code, and the current stream is a -binary stream, read the next byte from the current stream and unify its -code with _C_, while leaving the current stream position unaltered. - - -*/ - -/** @pred peek_char(- _C_) is iso - - -If _C_ is unbound, or is an atom representation of a character, and -the current stream is a text stream, read the next character from the -current stream and unify its atom representation with _C_, while -leaving the current stream position unaltered. - - -*/ - -/** @pred peek_code(- _C_) is iso - - -If _C_ is unbound, or is the code for a character, and -the current stream is a text stream, read the next character from the -current stream and unify its code with _C_, while -leaving the current stream position unaltered. - - -*/ - -/** @pred skip(+ _N_) - - -Skips input characters until the next occurrence of the character with -ASCII code _N_. The argument to this predicate can take the same forms -as those for `put` (see 6.11). - - -*/ - -/** @pred tab(+ _N_) - - -Outputs _N_ spaces to the current output stream. - - -*/ - -/** @pred nl is iso - - -Outputs a new line to the current output stream. - - - - - */ - -/** @defgroup InputOutput_for_Streams Input/Output Predicates applied to Streams -@ingroup YAPBuiltins -@{ - - - - -*/ - -/** @pred read(+ _S_,- _T_) is iso - -Reads term _T_ from the stream _S_ instead of from the current input -stream. - - -*/ - -/** @pred read_term(+ _S_,- _T_,+ _Options_) is iso - -Reads term _T_ from stream _S_ with execution controlled by the -same options as read_term/2. - - -*/ - -/** @pred write(+ _S_, _T_) is iso - -Writes term _T_ to stream _S_ instead of to the current output -stream. - - -*/ - -/** @pred write_canonical(+ _S_,+ _T_) is iso - -Displays term _T_ on the stream _S_. Atoms are quoted when -necessary, and operators are ignored. - - -*/ - -/** @pred write_term(+ _S_, + _T_, + _Opts_) is iso - -Displays term _T_ on the current output stream, according to the same -options used by `write_term/3`. - - -*/ - -/** @pred writeq(+ _S_, _T_) is iso - -As writeq/1, but the output is sent to the stream _S_. - - -*/ - -/** @pred display(+ _S_, _T_) - -Like display/1, but using stream _S_ to display the term. - - -*/ - -/** @pred print(+ _S_, _T_) - -Prints term _T_ to the stream _S_ instead of to the current output -stream. - - -*/ - -/** @pred put(+ _S_,+ _N_) - -As `put(N)`, but to stream _S_. - - -*/ - -/** @pred put_byte(+ _S_,+ _N_) is iso - -As `put_byte(N)`, but to binary stream _S_. - - -*/ - -/** @pred put_char(+ _S_,+ _A_) is iso - -As `put_char(A)`, but to text stream _S_. - - -*/ - -/** @pred put_code(+ _S_,+ _N_) is iso - -As `put_code(N)`, but to text stream _S_. - - -*/ - -/** @pred get(+ _S_,- _C_) - -The same as `get(C)`, but from stream _S_. - - -*/ - -/** @pred get0(+ _S_,- _C_) - -The same as `get0(C)`, but from stream _S_. - - -*/ - -/** @pred get_byte(+ _S_,- _C_) is iso - -If _C_ is unbound, or is a character code, and the stream _S_ is a -binary stream, read the next byte from that stream and unify its -code with _C_. - - -*/ - -/** @pred get_char(+ _S_,- _C_) is iso - -If _C_ is unbound, or is an atom representation of a character, and -the stream _S_ is a text stream, read the next character from that -stream and unify its representation as an atom with _C_. - - -*/ - -/** @pred get_code(+ _S_,- _C_) is iso - -If _C_ is unbound, or is a character code, and the stream _S_ is a -text stream, read the next character from that stream and unify its -code with _C_. - - -*/ - -/** @pred peek_byte(+ _S_,- _C_) is iso - -If _C_ is unbound, or is a character code, and _S_ is a binary -stream, read the next byte from the current stream and unify its code -with _C_, while leaving the current stream position unaltered. - - -*/ - -/** @pred peek_char(+ _S_,- _C_) is iso - -If _C_ is unbound, or is an atom representation of a character, and -the stream _S_ is a text stream, read the next character from that -stream and unify its representation as an atom with _C_, while leaving -the current stream position unaltered. - - -*/ - -/** @pred peek_code(+ _S_,- _C_) is iso - -If _C_ is unbound, or is an atom representation of a character, and -the stream _S_ is a text stream, read the next character from that -stream and unify its representation as an atom with _C_, while leaving -the current stream position unaltered. - - -*/ - -/** @pred skip(+ _S_,- _C_) - -Like skip/1, but using stream _S_ instead of the current -input stream. - - -*/ - -/** @pred tab(+ _S_,+ _N_) - -The same as tab/1, but using stream _S_. - - -*/ - -/** @pred nl(+ _S_) is iso - -Outputs a new line to stream _S_. - - - - - */ - -/** @defgroup ChYProlog_to_Terminal Compatible C-Prolog predicates for Terminal Input/Output -@ingroup YAPBuiltins -@{ - - - - -*/ - -/** @pred ttyput(+ _N_) - - -As `put(N)` but always to user_output. - - -*/ - -/** @pred ttyget(- _C_) - - -The same as `get(C)`, but from stream user_input. - - -*/ - -/** @pred ttyget0(- _C_) - - -The same as `get0(C)`, but from stream user_input. - - -*/ - -/** @pred ttyskip(- _C_) - - -Like skip/1, but always using stream user_input. -stream. - - -*/ - -/** @pred ttynl - - -Outputs a new line to stream user_output. - - - - - */ - -/** @defgroup InputOutput_Control Controlling Input/Output -@ingroup YAPBuiltins -@{ - - - - -*/ - -/** @pred exists(+ _F_) - - -Checks if file _F_ exists in the current directory. - -*/ - -/** @pred nofileerrors - - -Switches off the file_errors flag, so that the predicates see/1, -tell/1, open/3 and close/1 just fail, instead of producing -an error message and aborting whenever the specified file cannot be -opened or closed. - -*/ - -/** @pred fileerrors - - -Switches on the file_errors flag so that in certain error conditions -Input/Output predicates will produce an appropriated message and abort. - - */ - -/** @defgroup Sockets Using Sockets From YAP -@ingroup YAPBuiltins -@{ - -YAP includes a SICStus Prolog compatible socket interface. In YAP-6.3 -this uses the `clib` package to emulate the old low level interface that -provides direct access to the major socket system calls. These calls -can be used both to open a new connection in the network or connect to -a networked server. Socket connections are described as read/write -streams, and standard Input/Output built-ins can be used to write on or read -from sockets. The following calls are available: - - - - -*/ - -/** @pred socket(+ _DOMAIN_,+ _TYPE_,+ _PROTOCOL_,- _SOCKET_) - - -Corresponds to the BSD system call `socket`. Create a socket for -domain _DOMAIN_ of type _TYPE_ and protocol - _PROTOCOL_. Both _DOMAIN_ and _TYPE_ should be atoms, -whereas _PROTOCOL_ must be an integer. -The new socket object is -accessible through a descriptor bound to the variable _SOCKET_. - -The current implementation of YAP accepts socket -domains `AF_INET` and `AF_UNIX`. -Socket types depend on the -underlying operating system, but at least the following types are -supported: `SOCK_STREAM'` and `SOCK_DGRAM'` (untested in 6.3). - - -*/ - -/** @pred socket(+ _DOMAIN_,- _SOCKET_) - - -Call socket/4 with _TYPE_ bound to `SOCK_STREAM'` and - _PROTOCOL_ bound to `0`. - - -*/ - -/** @pred socket_close(+ _SOCKET_) - - - -Close socket _SOCKET_. Note that sockets used in -`socket_connect` (that is, client sockets) should not be closed with -`socket_close`, as they will be automatically closed when the -corresponding stream is closed with close/1 or `close/2`. - - -*/ - -/** @pred socket_bind(+ _SOCKET_, ? _PORT_) - - - -Interface to system call `bind`, as used for servers: bind socket -to a port. Port information depends on the domain: - -+ 'AF_UNIX'(+ _FILENAME_) (unsupported) -+ 'AF_FILE'(+ _FILENAME_) -use file name _FILENAME_ for UNIX or local sockets. - -+ 'AF_INET'(? _HOST_,?PORT) -If _HOST_ is bound to an atom, bind to host _HOST_, otherwise -if unbound bind to local host ( _HOST_ remains unbound). If port - _PORT_ is bound to an integer, try to bind to the corresponding -port. If variable _PORT_ is unbound allow operating systems to -choose a port number, which is unified with _PORT_. - - - - -*/ - -/** @pred socket_connect(+ _SOCKET_, + _PORT_, - _STREAM_) - - - -Interface to system call `connect`, used for clients: connect -socket _SOCKET_ to _PORT_. The connection results in the -read/write stream _STREAM_. - -Port information depends on the domain: - -+ 'AF_UNIX'(+ _FILENAME_) -+ 'AF_FILE'(+ _FILENAME_) -connect to socket at file _FILENAME_. - -+ 'AF_INET'(+ _HOST_,+ _PORT_) -Connect to socket at host _HOST_ and port _PORT_. - - - -*/ - -/** @pred socket_listen(+ _SOCKET_, + _LENGTH_) - - -Interface to system call `listen`, used for servers to indicate -willingness to wait for connections at socket _SOCKET_. The -integer _LENGTH_ gives the queue limit for incoming connections, -and should be limited to `5` for portable applications. The socket -must be of type `SOCK_STREAM` or `SOCK_SEQPACKET`. - - -*/ - -/** @pred socket_accept(+ _SOCKET_, - _CLIENT_, - _STREAM_) - - -Interface to system call `accept`, used for servers to wait for -connections at socket _SOCKET_. The stream descriptor _STREAM_ -represents the resulting connection. If the socket belongs to the -domain `AF_INET`, _CLIENT_ unifies with an atom containing -the IP address for the client in numbers and dots notation. - - -*/ - -/** @pred socket_accept(+ _SOCKET_, - _STREAM_) - -Accept a connection but do not return client information. - - -*/ - -/** @pred socket_buffering(+ _SOCKET_, - _MODE_, - _OLD_, + _NEW_) - - -Set buffering for _SOCKET_ in `read` or `write` - _MODE_. _OLD_ is unified with the previous status, and _NEW_ -receives the new status which may be one of `unbuf` or -`fullbuf`. - - -*/ - -/** @pred socket_select(+ _SOCKETS_, - _NEWSTREAMS_, + _TIMEOUT_, + _STREAMS_, - _READSTREAMS_) [unsupported in YAP-6.3] - -Interface to system call `select`, used for servers to wait for -connection requests or for data at sockets. The variable - _SOCKETS_ is a list of form _KEY-SOCKET_, where _KEY_ is -an user-defined identifier and _SOCKET_ is a socket descriptor. The -variable _TIMEOUT_ is either `off`, indicating execution will -wait until something is available, or of the form _SEC-USEC_, where - _SEC_ and _USEC_ give the seconds and microseconds before -socket_select/5 returns. The variable _SOCKETS_ is a list of -form _KEY-STREAM_, where _KEY_ is an user-defined identifier -and _STREAM_ is a stream descriptor - -Execution of socket_select/5 unifies _READSTREAMS_ from - _STREAMS_ with readable data, and _NEWSTREAMS_ with a list of -the form _KEY-STREAM_, where _KEY_ was the key for a socket -with pending data, and _STREAM_ the stream descriptor resulting -from accepting the connection. - - -*/ - -/** @pred current_host(? _HOSTNAME_) - -Unify _HOSTNAME_ with an atom representing the fully qualified -hostname for the current host. Also succeeds if _HOSTNAME_ is bound -to the unqualified hostname. - - -*/ - -/** @pred hostname_address(? _HOSTNAME_,? _IP_ADDRESS_) - - _HOSTNAME_ is an host name and _IP_ADDRESS_ its IP -address in number and dots notation. - - - - -*/ - -/** @defgroup Database Using the Clausal Data Base -@ingroup YAPBuiltins -@{ - -Predicates in YAP may be dynamic or static. By default, when -consulting or reconsulting, predicates are assumed to be static: -execution is faster and the code will probably use less space. -Static predicates impose some restrictions: in general there can be no -addition or removal of clauses for a procedure if it is being used in the -current execution. - -Dynamic predicates allow programmers to change the Clausal Data Base with -the same flexibility as in C-Prolog. With dynamic predicates it is -always possible to add or remove clauses during execution and the -semantics will be the same as for C-Prolog. But the programmer should be -aware of the fact that asserting or retracting are still expensive operations, -and therefore he should try to avoid them whenever possible. - - - - -*/ - -/** @pred dynamic( + _P_ ) - - -Declares predicate _P_ or list of predicates [ _P1_,..., _Pn_] -as a dynamic predicate. _P_ must be written as a predicate indicator, that is in form - _Name/Arity_ or _Module:Name/Arity_. - -~~~~~ -:- dynamic god/1. -~~~~~ - - -a more convenient form can be used: - -~~~~~ -:- dynamic son/3, father/2, mother/2. -~~~~~ - -or, equivalently, - -~~~~~ -:- dynamic [son/3, father/2, mother/2]. -~~~~~ - -Note: - -a predicate is assumed to be dynamic when -asserted before being defined. - - -*/ - -/** @pred dynamic_predicate(+ _P_,+ _Semantics_) - - -Declares predicate _P_ or list of predicates [ _P1_,..., _Pn_] -as a dynamic predicate following either `logical` or -`immediate` semantics. - - -*/ - -/** @pred compile_predicates(: _ListOfNameArity_) - - - -Compile a list of specified dynamic predicates (see dynamic/1 and -assert/1 into normal static predicates. This call tells the -Prolog environment the definition will not change anymore and further -calls to assert/1 or retract/1 on the named predicates -raise a permission error. This predicate is designed to deal with parts -of the program that is generated at runtime but does not change during -the remainder of the program execution. - - - - - */ - -/** @defgroup Modifying_the_Database Modification of the Data Base -@ingroup YAPBuiltins -@{ - -These predicates can be used either for static or for dynamic -predicates: - - - - -*/ - -/** @pred assert(+ _C_) - - -Same as assertz/1. Adds clause _C_ to the program. If the predicate is undefined, -declare it as dynamic. New code should use assertz/1 for better portability. - -Most Prolog systems only allow asserting clauses for dynamic -predicates. This is also as specified in the ISO standard. YAP allows -asserting clauses for static predicates, as long as the predicate is not -in use and the language flag is cprolog. Note that this feature is -deprecated, if you want to assert clauses for static procedures you -should use assert_static/1. - - -*/ - -/** @pred asserta(+ _C_) is iso - - -Adds clause _C_ to the beginning of the program. If the predicate is -undefined, declare it as dynamic. - - -*/ - -/** @pred assertz(+ _C_) is iso - - -Adds clause _C_ to the end of the program. If the predicate is -undefined, declare it as dynamic. - -Most Prolog systems only allow asserting clauses for dynamic -predicates. This is also as specified in the ISO standard. YAP allows -asserting clauses for static predicates. The current version of YAP -supports this feature, but this feature is deprecated and support may go -away in future versions. - - -*/ - -/** @pred abolish(+ _PredSpec_) is iso - - -Deletes the predicate given by _PredSpec_ from the database. If - _PredSpec_ is an unbound variable, delete all predicates for the -current module. The -specification must include the name and arity, and it may include module -information. Under iso language mode this built-in will only abolish -dynamic procedures. Under other modes it will abolish any procedures. - - -*/ - -/** @pred abolish(+ _P_,+ _N_) - -Deletes the predicate with name _P_ and arity _N_. It will remove -both static and dynamic predicates. - - -*/ - -/** @pred assert_static(: _C_) - - -Adds clause _C_ to a static procedure. Asserting a static clause -for a predicate while choice-points for the predicate are available has -undefined results. - - -*/ - -/** @pred asserta_static(: _C_) - - -Adds clause _C_ to the beginning of a static procedure. - - -*/ - -/** @pred assertz_static(: _C_) - - -Adds clause _C_ to the end of a static procedure. Asserting a -static clause for a predicate while choice-points for the predicate are -available has undefined results. - - - -The following predicates can be used for dynamic predicates and for -static predicates, if source mode was on when they were compiled: - - - - -*/ - -/** @pred clause(+ _H_, _B_) is iso - - -A clause whose head matches _H_ is searched for in the -program. Its head and body are respectively unified with _H_ and - _B_. If the clause is a unit clause, _B_ is unified with - _true_. - -This predicate is applicable to static procedures compiled with -`source` active, and to all dynamic procedures. - - -*/ - -/** @pred clause(+ _H_, _B_,- _R_) - -The same as clause/2, plus _R_ is unified with the -reference to the clause in the database. You can use instance/2 -to access the reference's value. Note that you may not use -erase/1 on the reference on static procedures. - - -*/ - -/** @pred nth_clause(+ _H_, _I_,- _R_) - - -Find the _I_th clause in the predicate defining _H_, and give -a reference to the clause. Alternatively, if the reference _R_ is -given the head _H_ is unified with a description of the predicate -and _I_ is bound to its position. - - - -The following predicates can only be used for dynamic predicates: - - - - -*/ - -/** @pred retract(+ _C_) is iso - - -Erases the first clause in the program that matches _C_. This -predicate may also be used for the static predicates that have been -compiled when the source mode was `on`. For more information on -source/0 ( (see Setting the Compiler)). - - -*/ - -/** @pred retractall(+ _G_) is iso - - -Retract all the clauses whose head matches the goal _G_. Goal - _G_ must be a call to a dynamic predicate. - - - - - */ - -/** @defgroup Looking_at_the_Database Looking at the Data Base -@ingroup YAPBuiltins -@{ - - - - -*/ - -/** @pred listing - - -Lists in the current output stream all the clauses for which source code -is available (these include all clauses for dynamic predicates and -clauses for static predicates compiled when source mode was `on`). - - -*/ - -/** @pred listing(+ _P_) - -Lists predicate _P_ if its source code is available. - - -*/ - -/** @pred portray_clause(+ _C_) - - -Write clause _C_ as if written by listing/0. - - -*/ - -/** @pred portray_clause(+ _S_,+ _C_) - -Write clause _C_ on stream _S_ as if written by listing/0. - - -*/ - -/** @pred current_atom( _A_) - - -Checks whether _A_ is a currently defined atom. It is used to find all -currently defined atoms by backtracking. - - -*/ - -/** @pred current_predicate( _F_) is iso - - - _F_ is the predicate indicator for a currently defined user or -library predicate. _F_ is of the form _Na/Ar_, where the atom - _Na_ is the name of the predicate, and _Ar_ its arity. - - -*/ - -/** @pred current_predicate( _A_, _P_) - -Defines the relation: _P_ is a currently defined predicate whose -name is the atom _A_. - - -*/ - -/** @pred system_predicate( _A_, _P_) - - -Defines the relation: _P_ is a built-in predicate whose name -is the atom _A_. - - -*/ - -/** @pred predicate_property( _P_, _Prop_) is iso - - -For the predicates obeying the specification _P_ unify _Prop_ -with a property of _P_. These properties may be: - -+ `built_in ` -true for built-in predicates, - -+ `dynamic` -true if the predicate is dynamic - -+ `static ` -true if the predicate is static - -+ `meta_predicate( _M_) ` -true if the predicate has a meta_predicate declaration _M_. - -+ `multifile ` -true if the predicate was declared to be multifile - -+ `imported_from( _Mod_) ` -true if the predicate was imported from module _Mod_. - -+ `exported ` -true if the predicate is exported in the current module. - -+ `public` -true if the predicate is public; note that all dynamic predicates are -public. - -+ `tabled ` -true if the predicate is tabled; note that only static predicates can -be tabled in YAP. - -+ `source (predicate_property flag) ` -true if source for the predicate is available. - -+ `number_of_clauses( _ClauseCount_) ` -Number of clauses in the predicate definition. Always one if external -or built-in. - - - -*/ - -/** @pred predicate_statistics( _P_, _NCls_, _Sz_, _IndexSz_) - - -Given predicate _P_, _NCls_ is the number of clauses for - _P_, _Sz_ is the amount of space taken to store those clauses -(in bytes), and _IndexSz_ is the amount of space required to store -indices to those clauses (in bytes). - - -*/ - -/** @pred predicate_erased_statistics( _P_, _NCls_, _Sz_, _IndexSz_) - - -Given predicate _P_, _NCls_ is the number of erased clauses for - _P_ that could not be discarded yet, _Sz_ is the amount of space -taken to store those clauses (in bytes), and _IndexSz_ is the amount -of space required to store indices to those clauses (in bytes). - - - - - */ - -/** @defgroup Database_References Using Data Base References -@ingroup YAPBuiltins -@{ - -Data Base references are a fast way of accessing terms. The predicates -erase/1 and `instance/1` also apply to these references and may -sometimes be used instead of retract/1 and clause/2. - - - - -*/ - -/** @pred assert(+ _C_,- _R_) - -The same as `assert(C)` ( (see Modifying the Database)) but -unifies _R_ with the database reference that identifies the new -clause, in a one-to-one way. Note that `asserta/2` only works for dynamic -predicates. If the predicate is undefined, it will automatically be -declared dynamic. - - -*/ - -/** @pred asserta(+ _C_,- _R_) - -The same as `asserta(C)` but unifying _R_ with -the database reference that identifies the new clause, in a -one-to-one way. Note that `asserta/2` only works for dynamic -predicates. If the predicate is undefined, it will automatically be -declared dynamic. - - -*/ - -/** @pred assertz(+ _C_,- _R_) - -The same as `assertz(C)` but unifying _R_ with -the database reference that identifies the new clause, in a -one-to-one way. Note that `asserta/2` only works for dynamic -predicates. If the predicate is undefined, it will automatically be -declared dynamic. - - -*/ - -/** @pred retract(+ _C_,- _R_) - -Erases from the program the clause _C_ whose -database reference is _R_. The predicate must be dynamic. - - - - - */ - -/** @defgroup Internal_Database Internal Data Base -@ingroup YAPBuiltins -@{ - -Some programs need global information for, e.g. counting or collecting -data obtained by backtracking. As a rule, to keep this information, the -internal data base should be used instead of asserting and retracting -clauses (as most novice programmers do), . -In YAP (as in some other Prolog systems) the internal data base (i.d.b. -for short) is faster, needs less space and provides a better insulation of -program and data than using asserted/retracted clauses. -The i.d.b. is implemented as a set of terms, accessed by keys that -unlikely what happens in (non-Prolog) data bases are not part of the -term. Under each key a list of terms is kept. References are provided so that -terms can be identified: each term in the i.d.b. has a unique reference -(references are also available for clauses of dynamic predicates). - -There is a strong analogy between the i.d.b. and the way dynamic -predicates are stored. In fact, the main i.d.b. predicates might be -implemented using dynamic predicates: - -~~~~~ -recorda(X,T,R) :- asserta(idb(X,T),R). -recordz(X,T,R) :- assertz(idb(X,T),R). -recorded(X,T,R) :- clause(idb(X,T),R). -~~~~~ -We can take advantage of this, the other way around, as it is quite -easy to write a simple Prolog interpreter, using the i.d.b.: - -~~~~~ -asserta(G) :- recorda(interpreter,G,_). -assertz(G) :- recordz(interpreter,G,_). -retract(G) :- recorded(interpreter,G,R), !, erase(R). -call(V) :- var(V), !, fail. -call((H :- B)) :- !, recorded(interpreter,(H :- B),_), call(B). -call(G) :- recorded(interpreter,G,_). -~~~~~ -In YAP, much attention has been given to the implementation of the -i.d.b., especially to the problem of accelerating the access to terms kept in -a large list under the same key. Besides using the key, YAP uses an internal -lookup function, transparent to the user, to find only the terms that might -unify. For instance, in a data base containing the terms - -~~~~~ -b -b(a) -c(d) -e(g) -b(X) -e(h) -~~~~~ - -stored under the key k/1, when executing the query - -~~~~~ -:- recorded(k(_),c(_),R). -~~~~~ - -`recorded` would proceed directly to the third term, spending almost the -time as if `a(X)` or `b(X)` was being searched. -The lookup function uses the functor of the term, and its first three -arguments (when they exist). So, `recorded(k(_),e(h),_)` would go -directly to the last term, while `recorded(k(_),e(_),_)` would find -first the fourth term, and then, after backtracking, the last one. - -This mechanism may be useful to implement a sort of hierarchy, where -the functors of the terms (and eventually the first arguments) work as -secondary keys. - -In the YAP's i.d.b. an optimized representation is used for -terms without free variables. This results in a faster retrieval of terms -and better space usage. Whenever possible, avoid variables in terms in terms stored in the i.d.b. - - - -*/ - -/** @pred recorda(+ _K_, _T_,- _R_) - - -Makes term _T_ the first record under key _K_ and unifies _R_ -with its reference. - - -*/ - -/** @pred recordz(+ _K_, _T_,- _R_) - - -Makes term _T_ the last record under key _K_ and unifies _R_ -with its reference. - - -*/ - -/** @pred recorda_at(+ _R0_, _T_,- _R_) - - -Makes term _T_ the record preceding record with reference - _R0_, and unifies _R_ with its reference. - - -*/ - -/** @pred recordz_at(+ _R0_, _T_,- _R_) - - -Makes term _T_ the record following record with reference - _R0_, and unifies _R_ with its reference. - - -*/ - -/** @pred recordaifnot(+ _K_, _T_,- _R_) - - -If a term equal to _T_ up to variable renaming is stored under key - _K_ fail. Otherwise, make term _T_ the first record under key - _K_ and unify _R_ with its reference. - - -*/ - -/** @pred recordzifnot(+ _K_, _T_,- _R_) - - -If a term equal to _T_ up to variable renaming is stored under key - _K_ fail. Otherwise, make term _T_ the first record under key - _K_ and unify _R_ with its reference. - -This predicate is YAP specific. - - -*/ - -/** @pred recorded(+ _K_, _T_, _R_) - - -Searches in the internal database under the key _K_, a term that -unifies with _T_ and whose reference matches _R_. This -built-in may be used in one of two ways: - -+ _K_ may be given, in this case the built-in will return all -elements of the internal data-base that match the key. -+ _R_ may be given, if so returning the key and element that -match the reference. - - - -*/ - -/** @pred erase(+ _R_) - - -The term referred to by _R_ is erased from the internal database. If -reference _R_ does not exist in the database, `erase` just fails. - - -*/ - -/** @pred erased(+ _R_) - - -Succeeds if the object whose database reference is _R_ has been -erased. - - -*/ - -/** @pred instance(+ _R_,- _T_) - - -If _R_ refers to a clause or a recorded term, _T_ is unified -with its most general instance. If _R_ refers to an unit clause - _C_, then _T_ is unified with ` _C_ :- true`. When - _R_ is not a reference to an existing clause or to a recorded term, -this goal fails. - - -*/ - -/** @pred eraseall(+ _K_) - - -All terms belonging to the key `K` are erased from the internal -database. The predicate always succeeds. - - -*/ - -/** @pred current_key(? _A_,? _K_) - - -Defines the relation: _K_ is a currently defined database key whose -name is the atom _A_. It can be used to generate all the keys for -the internal data-base. - - -*/ - -/** @pred nth_instance(? _Key_,? _Index_,? _R_) - - -Fetches the _Index_nth entry in the internal database under the key - _Key_. Entries are numbered from one. If the key _Key_ or the - _Index_ are bound, a reference is unified with _R_. Otherwise, -the reference _R_ must be given, and YAP will find -the matching key and index. - - -*/ - -/** @pred nth_instance(? _Key_,? _Index_, _T_,? _R_) - -Fetches the _Index_nth entry in the internal database under the key - _Key_. Entries are numbered from one. If the key _Key_ or the - _Index_ are bound, a reference is unified with _R_. Otherwise, -the reference _R_ must be given, and YAP will find -the matching key and index. - - -*/ - -/** @pred key_statistics(+ _K_,- _Entries_,- _Size_,- _IndexSize_) - - -Returns several statistics for a key _K_. Currently, it says how -many entries we have for that key, _Entries_, what is the -total size spent on entries, _Size_, and what is the amount of -space spent in indices. - - -*/ - -/** @pred key_statistics(+ _K_,- _Entries_,- _TotalSize_) - -Returns several statistics for a key _K_. Currently, it says how -many entries we have for that key, _Entries_, what is the -total size spent on this key. - - -*/ - -/** @pred get_value(+ _A_,- _V_) - - -In YAP, atoms can be associated with constants. If one such -association exists for atom _A_, unify the second argument with the -constant. Otherwise, unify _V_ with `[]`. - -This predicate is YAP specific. - - -*/ - -/** @pred set_value(+ _A_,+ _C_) - - -Associate atom _A_ with constant _C_. - -The `set_value` and `get_value` built-ins give a fast alternative to -the internal data-base. This is a simple form of implementing a global -counter. - -~~~~~ - read_and_increment_counter(Value) :- - get_value(counter, Value), - Value1 is Value+1, - set_value(counter, Value1). -~~~~~ -This predicate is YAP specific. - - - - - -*/ - -/** @defgroup BlackBoard The Blackboard -@ingroup YAPBuiltins -@{ - -YAP implements a blackboard in the style of the SICStus Prolog -blackboard. The blackboard uses the same underlying mechanism as the -internal data-base but has several important differences: - -+ It is module aware, in contrast to the internal data-base. -+ Keys can only be atoms or integers, and not compound terms. -+ A single term can be stored per key. -+ An atomic update operation is provided; this is useful for -parallelism. - - - - -*/ - -/** @pred bb_put(+ _Key_,? _Term_) - - -Store term table _Term_ in the blackboard under key _Key_. If a -previous term was stored under key _Key_ it is simply forgotten. - - -*/ - -/** @pred bb_get(+ _Key_,? _Term_) - - -Unify _Term_ with a term stored in the blackboard under key - _Key_, or fail silently if no such term exists. - - -*/ - -/** @pred bb_delete(+ _Key_,? _Term_) - - -Delete any term stored in the blackboard under key _Key_ and unify -it with _Term_. Fail silently if no such term exists. - - -*/ - -/** @pred bb_update(+ _Key_,? _Term_,? _New_) - - -Atomically unify a term stored in the blackboard under key _Key_ -with _Term_, and if the unification succeeds replace it by - _New_. Fail silently if no such term exists or if unification fails. - - - - - */ - -/** @defgroup Sets Collecting Solutions to a Goal -@ingroup YAPBuiltins -@{ - -When there are several solutions to a goal, if the user wants to collect all -the solutions he may be led to use the data base, because backtracking will -forget previous solutions. - -YAP allows the programmer to choose from several system -predicates instead of writing his own routines. findall/3 gives you -the fastest, but crudest solution. The other built-in predicates -post-process the result of the query in several different ways: - - - - -*/ - -/** @pred findall( _T_,+ _G_,- _L_) is iso - - -Unifies _L_ with a list that contains all the instantiations of the -term _T_ satisfying the goal _G_. - -With the following program: - -~~~~~ -a(2,1). -a(1,1). -a(2,2). -~~~~~ -the answer to the query - -~~~~~ -findall(X,a(X,Y),L). -~~~~~ -would be: - -~~~~~ -X = _32 -Y = _33 -L = [2,1,2]; -no -~~~~~ - - -*/ - -/** @pred findall( _T_,+ _G_,+ _L_,- _L0_) - -Similar to findall/3, but appends all answers to list _L0_. - - -*/ - -/** @pred all( _T_,+ _G_,- _L_) - - -Similar to `findall( _T_, _G_, _L_)` but eliminate -repeated elements. Thus, assuming the same clauses as in the above -example, the reply to the query - -~~~~~ -all(X,a(X,Y),L). -~~~~~ -would be: - -~~~~~ -X = _32 -Y = _33 -L = [2,1]; -no -~~~~~ - -Note that all/3 will fail if no answers are found. - - -*/ - -/** @pred bagof( _T_,+ _G_,- _L_) is iso - - -For each set of possible instances of the free variables occurring in - _G_ but not in _T_, generates the list _L_ of the instances of - _T_ satisfying _G_. Again, assuming the same clauses as in the -examples above, the reply to the query - -~~~~~ -bagof(X,a(X,Y),L). - -would be: -X = _32 -Y = 1 -L = [2,1]; -X = _32 -Y = 2 -L = [2]; -no -~~~~~ - - -*/ - -/** @pred setof( _X_,+ _P_,- _B_) is iso - - -Similar to `bagof( _T_, _G_, _L_)` but sorts list - _L_ and keeping only one copy of each element. Again, assuming the -same clauses as in the examples above, the reply to the query - -~~~~~ -setof(X,a(X,Y),L). -~~~~~ -would be: - -~~~~~ -X = _32 -Y = 1 -L = [1,2]; -X = _32 -Y = 2 -L = [2]; -no -~~~~~ - - - - - */ - -/** @defgroup Grammars Grammar Rules -@ingroup YAPBuiltins -@{ - -Grammar rules in Prolog are both a convenient way to express definite -clause grammars and an extension of the well known context-free grammars. - -A grammar rule is of the form: - -~~~~~ -head --> body -~~~~~ -where both \a head and \a body are sequences of one or more items -linked by the standard conjunction operator `,`. - -Items can be: - -+ -a non-terminal symbol may be either a complex term or an atom. -+ -a terminal symbol may be any Prolog symbol. Terminals are -written as Prolog lists. -+ -an empty body is written as the empty list `[ ]`. -+ -extra conditions may be inserted as Prolog procedure calls, by being -written inside curly brackets `{` and `}`. -+ -the left side of a rule consists of a nonterminal and an optional list -of terminals. -+ -alternatives may be stated in the right-hand side of the rule by using -the disjunction operator `;`. -+ -the cut and conditional symbol (`->`) may be inserted in the -right hand side of a grammar rule - - -Grammar related built-in predicates: - - - - -*/ - -/** @pred expand_term( _T_,- _X_) - - - -This predicate is used by YAP for preprocessing each top level -term read when consulting a file and before asserting or executing it. -It rewrites a term _T_ to a term _X_ according to the following -rules: first try term_expansion/2 in the current module, and then try to use the user defined predicate -`user:term_expansion/2`. If this call fails then the translating process -for DCG rules is applied, together with the arithmetic optimizer -whenever the compilation of arithmetic expressions is in progress. - - -*/ - -/** @pred _CurrentModule_:term_expansion( _T_,- _X_), user:term_expansion( _T_,- _X_) - - -This user-defined predicate is called by `expand_term/3` to -preprocess all terms read when consulting a file. If it succeeds: - -+ -If _X_ is of the form `:- G` or `?- G`, it is processed as -a directive. -+ -If _X_ is of the form `$source_location`( _File_, _Line_): _Clause_` it is processed as if from `File` and line `Line`. - -+ -If _X_ is a list, all terms of the list are asserted or processed -as directives. -+ The term _X_ is asserted instead of _T_. - - - -*/ - -/** @pred _CurrentModule_:goal_expansion(+ _G_,+ _M_,- _NG_), user:goal_expansion(+ _G_,+ _M_,- _NG_) - - -YAP now supports goal_expansion/3. This is an user-defined -procedure that is called after term expansion when compiling or -asserting goals for each sub-goal in a clause. The first argument is -bound to the goal and the second to the module under which the goal - _G_ will execute. If goal_expansion/3 succeeds the new -sub-goal _NG_ will replace _G_ and will be processed in the same -way. If goal_expansion/3 fails the system will use the default -rules. - - -*/ - -/** @pred phrase(+ _P_, _L_, _R_) - - -This predicate succeeds when the difference list ` _L_- _R_` -is a phrase of type _P_. - - -*/ - -/** @pred phrase(+ _P_, _L_) - -This predicate succeeds when _L_ is a phrase of type _P_. The -same as `phrase(P,L,[])`. - -Both this predicate and the previous are used as a convenient way to -start execution of grammar rules. - - -*/ - -/** @pred `C`( _S1_, _T_, _S2_) - - -This predicate is used by the grammar rules compiler and is defined as -`C`([H|T],H,T)`. - - - - - */ - -/** @defgroup OS Access to Operating System Functionality -@ingroup YAPBuiltins -@{ - -The following built-in predicates allow access to underlying -Operating System functionality: - - - - -*/ - -/** @pred cd(+ _D_) - - -Changes the current directory (on UNIX environments). - - -*/ - -/** @pred cd - -Changes the current directory (on UNIX environments) to the user's home directory. - - -*/ - -/** @pred environ(+ _E_,- _S_) - - - - - -Given an environment variable _E_ this predicate unifies the second argument _S_ with its value. - - -*/ - -/** @pred getcwd(- _D_) - - -Unify the current directory, represented as an atom, with the argument - _D_. - - -*/ - -/** @pred pwd - - -Prints the current directory. - - -*/ - -/** @pred ls - - -Prints a list of all files in the current directory. - - -*/ - -/** @pred putenv(+ _E_,+ _S_) - - -Set environment variable _E_ to the value _S_. If the -environment variable _E_ does not exist, create a new one. Both the -environment variable and the value must be atoms. - - -*/ - -/** @pred rename(+ _F_,+ _G_) - - -Renames file _F_ to _G_. - - -*/ - -/** @pred sh - - -Creates a new shell interaction. - - -*/ - -/** @pred system(+ _S_) - - -Passes command _S_ to the Bourne shell (on UNIX environments) or the -current command interpreter in WIN32 environments. - - -*/ - -/** @pred unix(+ _S_) - - -Access to Unix-like functionality: - -+ argv/1 -Return a list of arguments to the program. These are the arguments that -follow a `--`, as in the usual Unix convention. -+ cd/0 -Change to home directory. -+ cd/1 -Change to given directory. Acceptable directory names are strings or -atoms. -+ environ/2 -If the first argument is an atom, unify the second argument with the -value of the corresponding environment variable. -+ getcwd/1 -Unify the first argument with an atom representing the current directory. -+ putenv/2 -Set environment variable _E_ to the value _S_. If the -environment variable _E_ does not exist, create a new one. Both the -environment variable and the value must be atoms. -+ shell/1 -Execute command under current shell. Acceptable commands are strings or -atoms. -+ system/1 -Execute command with `/bin/sh`. Acceptable commands are strings or -atoms. -+ shell/0 -Execute a new shell. - - - -*/ - -/** @pred working_directory(- _CurDir_,? _NextDir_) - - -Fetch the current directory at _CurDir_. If _NextDir_ is bound -to an atom, make its value the current working directory. - - -*/ - -/** @pred alarm(+ _Seconds_,+ _Callable_,+ _OldAlarm_) - - -Arranges for YAP to be interrupted in _Seconds_ seconds, or in -[ _Seconds_| _MicroSeconds_]. When interrupted, YAP will execute - _Callable_ and then return to the previous execution. If - _Seconds_ is `0`, no new alarm is scheduled. In any event, -any previously set alarm is canceled. - -The variable _OldAlarm_ unifies with the number of seconds remaining -until any previously scheduled alarm was due to be delivered, or with -`0` if there was no previously scheduled alarm. - -Note that execution of _Callable_ will wait if YAP is -executing built-in predicates, such as Input/Output operations. - -The next example shows how _alarm/3_ can be used to implement a -simple clock: - -~~~~~ -loop :- loop. - -ticker :- write('.'), flush_output, - get_value(tick, yes), - alarm(1,ticker,_). - -:- set_value(tick, yes), alarm(1,ticker,_), loop. -~~~~~ - -The clock, `ticker`, writes a dot and then checks the flag -`tick` to see whether it can continue ticking. If so, it calls -itself again. Note that there is no guarantee that the each dot -corresponds a second: for instance, if the YAP is waiting for -user input, `ticker` will wait until the user types the entry in. - -The next example shows how alarm/3 can be used to guarantee that -a certain procedure does not take longer than a certain amount of time: - -~~~~~ -loop :- loop. - -:- catch((alarm(10, throw(ball), _),loop), - ball, - format('Quota exhausted.~n',[])). -~~~~~ -In this case after `10` seconds our `loop` is interrupted, -`ball` is thrown, and the handler writes `Quota exhausted`. -Execution then continues from the handler. - -Note that in this case `loop/0` always executes until the alarm is -sent. Often, the code you are executing succeeds or fails before the -alarm is actually delivered. In this case, you probably want to disable -the alarm when you leave the procedure. The next procedure does exactly so: - -~~~~~ -once_with_alarm(Time,Goal,DoOnAlarm) :- - catch(execute_once_with_alarm(Time, Goal), alarm, DoOnAlarm). - -execute_once_with_alarm(Time, Goal) :- - alarm(Time, alarm, _), - ( call(Goal) -> alarm(0, alarm, _) ; alarm(0, alarm, _), fail). -~~~~~ - -The procedure `once_with_alarm/3` has three arguments: -the _Time_ to wait before the alarm is -sent; the _Goal_ to execute; and the goal _DoOnAlarm_ to execute -if the alarm is sent. It uses catch/3 to handle the case the -`alarm` is sent. Then it starts the alarm, calls the goal - _Goal_, and disables the alarm on success or failure. - - -*/ - -/** @pred on_signal(+ _Signal_,? _OldAction_,+ _Callable_) - - -Set the interrupt handler for soft interrupt _Signal_ to be - _Callable_. _OldAction_ is unified with the previous handler. - -Only a subset of the software interrupts (signals) can have their -handlers manipulated through on_signal/3. -Their POSIX names, YAP names and default behavior is given below. -The "YAP name" of the signal is the atom that is associated with -each signal, and should be used as the first argument to -on_signal/3. It is chosen so that it matches the signal's POSIX -name. - -on_signal/3 succeeds, unless when called with an invalid -signal name or one that is not supported on this platform. No checks -are made on the handler provided by the user. - -+ sig_up (Hangup) -SIGHUP in Unix/Linux; Reconsult the initialization files -~/.yaprc, ~/.prologrc and ~/prolog.ini. -+ sig_usr1 and sig_usr2 (User signals) -SIGUSR1 and SIGUSR2 in Unix/Linux; Print a message and halt. - - -A special case is made, where if _Callable_ is bound to -`default`, then the default handler is restored for that signal. - -A call in the form `on_signal( _S_, _H_, _H_)` can be used -to retrieve a signal's current handler without changing it. - -It must be noted that although a signal can be received at all times, -the handler is not executed while YAP is waiting for a query at the -prompt. The signal will be, however, registered and dealt with as soon -as the user makes a query. - -Please also note, that neither POSIX Operating Systems nor YAP guarantee -that the order of delivery and handling is going to correspond with the -order of dispatch. - - - - - */ - -/** @defgroup Term_Modification Term Modification -@ingroup YAPBuiltins -@{ - -It is sometimes useful to change the value of instantiated -variables. Although, this is against the spirit of logic programming, it -is sometimes useful. As in other Prolog systems, YAP has -several primitives that allow updating Prolog terms. Note that these -primitives are also backtrackable. - -The `setarg/3` primitive allows updating any argument of a Prolog -compound terms. The `mutable` family of predicates provides -mutable variables. They should be used instead of `setarg/3`, -as they allow the encapsulation of accesses to updatable -variables. Their implementation can also be more efficient for long -deterministic computations. - - - -*/ - -/** @pred setarg(+ _I_,+ _S_,? _T_) - - -Set the value of the _I_th argument of term _S_ to term _T_. - - -*/ - -/** @pred create_mutable(+ _D_,- _M_) - - -Create new mutable variable _M_ with initial value _D_. - - -*/ - -/** @pred is_mutable(? _D_) - - -Holds if _D_ is a mutable term. - - -*/ - -/** @pred get_mutable(? _D_,+ _M_) - - -Unify the current value of mutable term _M_ with term _D_. - - -*/ - -/** @pred update_mutable(+ _D_,+ _M_) - - -Set the current value of mutable term _M_ to term _D_. - - - - */ - -/** @defgroup Global_Variables Global Variables -@ingroup YAPBuiltins -@{ - -Global variables are associations between names (atoms) and -terms. They differ in various ways from storing information using -assert/1 or recorda/3. - -+ The value lives on the Prolog (global) stack. This implies that -lookup time is independent from the size of the term. This is -particularly interesting for large data structures such as parsed XML -documents or the CHR global constraint store. - -+ They support both global assignment using nb_setval/2 and -backtrackable assignment using b_setval/2. - -+ Only one value (which can be an arbitrary complex Prolog term) -can be associated to a variable at a time. - -+ Their value cannot be shared among threads. Each thread has its own -namespace and values for global variables. - - -Currently global variables are scoped globally. We may consider module -scoping in future versions. Both b_setval/2 and -nb_setval/2 implicitly create a variable if the referenced name -does not already refer to a variable. - -Global variables may be initialised from directives to make them -available during the program lifetime, but some considerations are -necessary for saved-states and threads. Saved-states to not store -global variables, which implies they have to be declared with -initialization/1 to recreate them after loading the saved -state. Each thread has its own set of global variables, starting with -an empty set. Using `thread_initialization/1` to define a global -variable it will be defined, restored after reloading a saved state -and created in all threads that are created after the -registration. Finally, global variables can be initialised using the -exception hook called exception/3. The latter technique is used -by CHR. - - - -*/ - -/** @pred b_setval(+ _Name_, + _Value_) - - -Associate the term _Value_ with the atom _Name_ or replaces -the currently associated value with _Value_. If _Name_ does -not refer to an existing global variable a variable with initial value -[] is created (the empty list). On backtracking the assignment is -reversed. - - -*/ - -/** @pred b_getval(+ _Name_, - _Value_) - - -Get the value associated with the global variable _Name_ and unify -it with _Value_. Note that this unification may further -instantiate the value of the global variable. If this is undesirable -the normal precautions (double negation or copy_term/2) must be -taken. The b_getval/2 predicate generates errors if _Name_ is not -an atom or the requested variable does not exist. - -Notice that for compatibility with other systems _Name_ must be already associated with a term: otherwise the system will generate an error. - - -*/ - -/** @pred nb_setval(+ _Name_, + _Value_) - - -Associates a copy of _Value_ created with duplicate_term/2 with -the atom _Name_. Note that this can be used to set an initial -value other than `[]` prior to backtrackable assignment. - - -*/ - -/** @pred nb_getval(+ _Name_, - _Value_) - - -The nb_getval/2 predicate is a synonym for b_getval/2, -introduced for compatibility and symmetry. As most scenarios will use -a particular global variable either using non-backtrackable or -backtrackable assignment, using nb_getval/2 can be used to -document that the variable is used non-backtrackable. - - -*/ - -/** @pred nb_linkval(+ _Name_, + _Value_) - - -Associates the term _Value_ with the atom _Name_ without -copying it. This is a fast special-purpose variation of nb_setval/2 -intended for expert users only because the semantics on backtracking -to a point before creating the link are poorly defined for compound -terms. The principal term is always left untouched, but backtracking -behaviour on arguments is undone if the original assignment was -trailed and left alone otherwise, which implies that the history that -created the term affects the behaviour on backtracking. Please -consider the following example: - -~~~~~ -demo_nb_linkval :- - T = nice(N), - ( N = world, - nb_linkval(myvar, T), - fail - ; nb_getval(myvar, V), - writeln(V) - ). -~~~~~ - - -*/ - -/** @pred nb_set_shared_val(+ _Name_, + _Value_) - - -Associates the term _Value_ with the atom _Name_, but sharing -non-backtrackable terms. This may be useful if you want to rewrite a -global variable so that the new copy will survive backtracking, but -you want to share structure with the previous term. - -The next example shows the differences between the three built-ins: - -~~~~~ -?- nb_setval(a,a(_)),nb_getval(a,A),nb_setval(b,t(C,A)),nb_getval(b,B). -A = a(_A), -B = t(_B,a(_C)) ? - -?- nb_setval(a,a(_)),nb_getval(a,A),nb_set_shared_val(b,t(C,A)),nb_getval(b,B). - -?- nb_setval(a,a(_)),nb_getval(a,A),nb_linkval(b,t(C,A)),nb_getval(b,B). -A = a(_A), -B = t(C,a(_A)) ? -~~~~~ - - -*/ - -/** @pred nb_setarg(+{Arg], + _Term_, + _Value_) - - - -Assigns the _Arg_-th argument of the compound term _Term_ with -the given _Value_ as setarg/3, but on backtracking the assignment -is not reversed. If _Term_ is not atomic, it is duplicated using -duplicate_term/2. This predicate uses the same technique as -nb_setval/2. We therefore refer to the description of -nb_setval/2 for details on non-backtrackable assignment of -terms. This predicate is compatible to GNU-Prolog -`setarg(A,T,V,false)`, removing the type-restriction on - _Value_. See also nb_linkarg/3. Below is an example for -counting the number of solutions of a goal. Note that this -implementation is thread-safe, reentrant and capable of handling -exceptions. Realising these features with a traditional implementation -based on assert/retract or flag/3 is much more complicated. - -~~~~~ - succeeds_n_times(Goal, Times) :- - Counter = counter(0), - ( Goal, - arg(1, Counter, N0), - N is N0 + 1, - nb_setarg(1, Counter, N), - fail - ; arg(1, Counter, Times) - ). -~~~~~ - - -*/ - -/** @pred nb_set_shared_arg(+ _Arg_, + _Term_, + _Value_) - - - -As nb_setarg/3, but like nb_linkval/2 it does not -duplicate the global sub-terms in _Value_. Use with extreme care -and consult the documentation of nb_linkval/2 before use. - - -*/ - -/** @pred nb_linkarg(+ _Arg_, + _Term_, + _Value_) - - - -As nb_setarg/3, but like nb_linkval/2 it does not -duplicate _Value_. Use with extreme care and consult the -documentation of nb_linkval/2 before use. - - -*/ - -/** @pred nb_current(? _Name_, ? _Value_) - - -Enumerate all defined variables with their value. The order of -enumeration is undefined. - - -*/ - -/** @pred nb_delete(+ _Name_) - - -Delete the named global variable. - - -Global variables have been introduced by various Prolog -implementations recently. We follow the implementation of them in -SWI-Prolog, itself based on hProlog by Bart Demoen. - -GNU-Prolog provides a rich set of global variables, including -arrays. Arrays can be implemented easily in YAP and SWI-Prolog using -functor/3 and `setarg/3` due to the unrestricted arity of -compound terms. - - - */ - -/** @defgroup Profiling Profiling Prolog Programs -@ingroup YAPBuiltins -@{ - -YAP includes two profilers. The count profiler keeps information on the -number of times a predicate was called. This information can be used to -detect what are the most commonly called predicates in the program. The -count profiler can be compiled by setting YAP's flag profiling -to `on`. The time-profiler is a `gprof` profiler, and counts -how many ticks are being spent on specific predicates, or on other -system functions such as internal data-base accesses or garbage collects. - -The YAP profiling sub-system is currently under -development. Functionality for this sub-system will increase with newer -implementation. - - - */ - -/** @defgroup The_Count_Profiler The Count Profiler -@ingroup YAPBuiltins -@{ - - *Notes:* - -The count profiler works by incrementing counters at procedure entry or -backtracking. It provides exact information: - -+ Profiling works for both static and dynamic predicates. -+ Currently only information on entries and retries to a predicate -are maintained. This may change in the future. -+ As an example, the following user-level program gives a list of -the most often called procedures in a program. The procedure -`list_profile` shows all procedures, irrespective of module, and -the procedure `list_profile/1` shows the procedures being used in -a specific module. - -~~~~~ -list_profile :- - % get number of calls for each profiled procedure - setof(D-[M:P|D1],(current_module(M),profile_data(M:P,calls,D),profile_data(M:P,retries,D1)),LP), - % output so that the most often called - % predicates will come last: - write_profile_data(LP). - -list_profile(Module) :- - % get number of calls for each profiled procedure - setof(D-[Module:P|D1],(profile_data(Module:P,calls,D),profile_data(Module:P,retries,D1)),LP), - % output so that the most often called - % predicates will come last: - write_profile_data(LP). - -write_profile_data([]). -write_profile_data([D-[M:P|R]|SLP]) :- - % swap the two calls if you want the most often - % called predicates first. - format('~a:~w: ~32+~t~d~12+~t~d~12+~n', [M,P,D,R]), - write_profile_data(SLP). -~~~~~ - - -These are the current predicates to access and clear profiling data: - - - -*/ - -/** @pred profile_data(? _Na/Ar_, ? _Parameter_, - _Data_) - - -Give current profile data on _Parameter_ for a predicate described -by the predicate indicator _Na/Ar_. If any of _Na/Ar_ or - _Parameter_ are unbound, backtrack through all profiled predicates -or stored parameters. Current parameters are: - -+ calls -Number of times a procedure was called. - -+ retries -Number of times a call to the procedure was backtracked to and retried. - - -+ profile_reset - - -Reset all profiling information. - - - - - */ - -/** @defgroup Tick_Profiler Tick Profiler -@ingroup YAPBuiltins -@{ - -The tick profiler works by interrupting the Prolog code every so often -and checking at each point the code was. The profiler must be able to -retrace the state of the abstract machine at every moment. The major -advantage of this approach is that it gives the actual amount of time -being spent per procedure, or whether garbage collection dominates -execution time. The major drawback is that tracking down the state of -the abstract machine may take significant time, and in the worst case -may slow down the whole execution. - -The following procedures are available: - -+ profinit - - -Initialise the data-structures for the profiler. Unnecessary for -dynamic profiler. - -+ profon - - -Start profiling. - -+ profoff - - -Stop profiling. - - -*/ - -/** @pred showprofres - - -Show profiling info. - - -*/ - -/** @pred showprofres( _N_) - -Show profiling info for the top-most _N_ predicates. - - - -The showprofres/0 and `showprofres/1` predicates call a user-defined multifile hook predicate, `user:prolog_predicate_name/2`, that can be used for converting a possibly explicitly-qualified callable term into an atom that will used when printing the profiling information. - - - */ - -/** @defgroup Call_Counting Counting Calls -@ingroup YAPBuiltins -@{ - -Predicates compiled with YAP's flag call_counting set to -`on` update counters on the numbers of calls and of -retries. Counters are actually decreasing counters, so that they can be -used as timers. Three counters are available: - -+ `calls`: number of predicate calls since execution started or since -system was reset; -+ `retries`: number of retries for predicates called since -execution started or since counters were reset; -+ `calls_and_retries`: count both on predicate calls and -retries. - -These counters can be used to find out how many calls a certain -goal takes to execute. They can also be used as timers. - -The code for the call counters piggybacks on the profiling -code. Therefore, activating the call counters also activates the profiling -counters. - -These are the predicates that access and manipulate the call counters: - - - -*/ - -/** @pred call_count_data(- _Calls_, - _Retries_, - _CallsAndRetries_) - - -Give current call count data. The first argument gives the current value -for the _Calls_ counter, next the _Retries_ counter, and last -the _CallsAndRetries_ counter. - -*/ - -/** @pred call_count_reset - - -Reset call count counters. All timers are also reset. - -*/ - -/** @pred call_count(? _CallsMax_, ? _RetriesMax_, ? _CallsAndRetriesMax_) - - -Set call counters as timers. YAP will generate an exception -if one of the instantiated call counters decreases to 0: - -+ _CallsMax_ - - throw the exception `call_counter` when the -counter `calls` reaches 0; - -+ _RetriesMax_ - - throw the exception `retry_counter` when the -counter `retries` reaches 0; - -+ _CallsAndRetriesMax_ - - throw the exception -`call_and_retry_counter` when the counter `calls_and_retries` -reaches 0. - - YAP will ignore counters that are called with unbound arguments. - -Next, we show a simple example of how to use call counters: - -~~~~~{.prolog} - ?- yap_flag(call_counting,on), [-user]. l :- l. end_of_file. yap_flag(call_counting,off). - -yes - -yes - ?- catch((call_count(10000,_,_),l),call_counter,format("limit_exceeded.~n",[])). - -limit_exceeded. - -yes -~~~~~ -Notice that we first compile the looping predicate `l/0` with -call_counting `on`. Next, we catch/3 to handle an -exception when `l/0` performs more than 10000 reductions. - - - */ - -/** @defgroup Arrays Arrays -@ingroup YAPBuiltins -@{ - -The YAP system includes experimental support for arrays. The -support is enabled with the option `YAP_ARRAYS`. - -There are two very distinct forms of arrays in YAP. The -dynamic arrays are a different way to access compound terms -created during the execution. Like any other terms, any bindings to -these terms and eventually the terms themselves will be destroyed during -backtracking. Our goal in supporting dynamic arrays is twofold. First, -they provide an alternative to the standard arg/3 -built-in. Second, because dynamic arrays may have name that are globally -visible, a dynamic array can be visible from any point in the -program. In more detail, the clause - -~~~~~ -g(X) :- array_element(a,2,X). -~~~~~ -will succeed as long as the programmer has used the built-in array/2 -to create an array term with at least 3 elements in the current -environment, and the array was associated with the name `a`. The -element `X` is a Prolog term, so one can bind it and any such -bindings will be undone when backtracking. Note that dynamic arrays do -not have a type: each element may be any Prolog term. - -The static arrays are an extension of the database. They provide -a compact way for manipulating data-structures formed by characters, -integers, or floats imperatively. They can also be used to provide -two-way communication between YAP and external programs through -shared memory. - -In order to efficiently manage space elements in a static array must -have a type. Currently, elements of static arrays in YAP should -have one of the following predefined types: - -+ `byte`: an 8-bit signed character. -+ `unsigned_byte`: an 8-bit unsigned character. -+ `int`: Prolog integers. Size would be the natural size for -the machine's architecture. -+ `float`: Prolog floating point number. Size would be equivalent -to a double in `C`. -+ `atom`: a Prolog atom. -+ `dbref`: an internal database reference. -+ `term`: a generic Prolog term. Note that this will term will -not be stored in the array itself, but instead will be stored in the -Prolog internal database. - - -Arrays may be named or anonymous. Most arrays will be -named, that is associated with an atom that will be used to find -the array. Anonymous arrays do not have a name, and they are only of -interest if the `TERM_EXTENSIONS` compilation flag is enabled. In -this case, the unification and parser are extended to replace -occurrences of Prolog terms of the form `X[I]` by run-time calls to -array_element/3, so that one can use array references instead of -extra calls to arg/3. As an example: - -~~~~~ -g(X,Y,Z,I,J) :- X[I] is Y[J]+Z[I]. -~~~~~ -should give the same results as: - -~~~~~ -G(X,Y,Z,I,J) :- - array_element(X,I,E1), - array_element(Y,J,E2), - array_element(Z,I,E3), - E1 is E2+E3. -~~~~~ - -Note that the only limitation on array size are the stack size for -dynamic arrays; and, the heap size for static (not memory mapped) -arrays. Memory mapped arrays are limited by available space in the file -system and in the virtual memory space. - -The following predicates manipulate arrays: - - - - -*/ - -/** @pred array(+ _Name_, + _Size_) - - -Creates a new dynamic array. The _Size_ must evaluate to an -integer. The _Name_ may be either an atom (named array) or an -unbound variable (anonymous array). - -Dynamic arrays work as standard compound terms, hence space for the -array is recovered automatically on backtracking. - - -*/ - -/** @pred static_array(+ _Name_, + _Size_, + _Type_) - - -Create a new static array with name _Name_. Note that the _Name_ -must be an atom (named array). The _Size_ must evaluate to an -integer. The _Type_ must be bound to one of types mentioned -previously. - - -*/ - -/** @pred reset_static_array(+ _Name_) - - -Reset static array with name _Name_ to its initial value. - - -*/ - -/** @pred static_array_location(+ _Name_, - _Ptr_) - - -Give the location for a static array with name - _Name_. - - -*/ - -/** @pred static_array_properties(? _Name_, ? _Size_, ? _Type_) - - -Show the properties size and type of a static array with name - _Name_. Can also be used to enumerate all current -static arrays. - -This built-in will silently fail if the there is no static array with -that name. - - -*/ - -/** @pred static_array_to_term(? _Name_, ? _Term_) - - -Convert a static array with name - _Name_ to a compound term of name _Name_. - -This built-in will silently fail if the there is no static array with -that name. - - -*/ - -/** @pred mmapped_array(+ _Name_, + _Size_, + _Type_, + _File_) - - -Similar to static_array/3, but the array is memory mapped to file - _File_. This means that the array is initialized from the file, and -that any changes to the array will also be stored in the file. - -This built-in is only available in operating systems that support the -system call `mmap`. Moreover, mmapped arrays do not store generic -terms (type `term`). - - -*/ - -/** @pred close_static_array(+ _Name_) - - -Close an existing static array of name _Name_. The _Name_ must -be an atom (named array). Space for the array will be recovered and -further accesses to the array will return an error. - - -*/ - -/** @pred resize_static_array(+ _Name_, - _OldSize_, + _NewSize_) - - -Expand or reduce a static array, The _Size_ must evaluate to an -integer. The _Name_ must be an atom (named array). The _Type_ -must be bound to one of `int`, `dbref`, `float` or -`atom`. - -Note that if the array is a mmapped array the size of the mmapped file -will be actually adjusted to correspond to the size of the array. - - -*/ - -/** @pred array_element(+ _Name_, + _Index_, ? _Element_) - - -Unify _Element_ with _Name_[ _Index_]. It works for both -static and dynamic arrays, but it is read-only for static arrays, while -it can be used to unify with an element of a dynamic array. - - -*/ - -/** @pred update_array(+ _Name_, + _Index_, ? _Value_) - - -Attribute value _Value_ to _Name_[ _Index_]. Type -restrictions must be respected for static arrays. This operation is -available for dynamic arrays if `MULTI_ASSIGNMENT_VARIABLES` is -enabled (true by default). Backtracking undoes _update_array/3_ for -dynamic arrays, but not for static arrays. - -Note that update_array/3 actually uses `setarg/3` to update -elements of dynamic arrays, and `setarg/3` spends an extra cell for -every update. For intensive operations we suggest it may be less -expensive to unify each element of the array with a mutable terms and -to use the operations on mutable terms. - - -*/ - -/** @pred add_to_array_element(+ _Name_, + _Index_, + _Number_, ? _NewValue_) - - -Add _Number_ _Name_[ _Index_] and unify _NewValue_ with -the incremented value. Observe that _Name_[ _Index_] must be an -number. If _Name_ is a static array the type of the array must be -`int` or `float`. If the type of the array is `int` you -only may add integers, if it is `float` you may add integers or -floats. If _Name_ corresponds to a dynamic array the array element -must have been previously bound to a number and `Number` can be -any kind of number. - -The `add_to_array_element/3` built-in actually uses -`setarg/3` to update elements of dynamic arrays. For intensive -operations we suggest it may be less expensive to unify each element -of the array with a mutable terms and to use the operations on mutable -terms. - - - - - */ - -/** @defgroup Preds Predicate Information -@ingroup YAPBuiltins -@{ - -Built-ins that return information on the current predicates and modules: - - - - -*/ - -/** @pred current_module( _M_) - - -Succeeds if _M_ are defined modules. A module is defined as soon as some -predicate defined in the module is loaded, as soon as a goal in the -module is called, or as soon as it becomes the current type-in module. - - -*/ - -/** @pred current_module( _M_, _F_) - -Succeeds if _M_ are current modules associated to the file _F_. - - - - - */ - -/** @defgroup Misc Miscellaneous -@ingroup YAPBuiltins -@{ - - - - -*/ - -/** @pred statistics/0 - - -Send to the current user error stream general information on space used and time -spent by the system. - -~~~~~ -?- statistics. -memory (total) 4784124 bytes - program space 3055616 bytes: 1392224 in use, 1663392 free - 2228132 max - stack space 1531904 bytes: 464 in use, 1531440 free - global stack: 96 in use, 616684 max - local stack: 368 in use, 546208 max - trail stack 196604 bytes: 8 in use, 196596 free - - 0.010 sec. for 5 code, 2 stack, and 1 trail space overflows - 0.130 sec. for 3 garbage collections which collected 421000 bytes - 0.000 sec. for 0 atom garbage collections which collected 0 bytes - 0.880 sec. runtime - 1.020 sec. cputime - 25.055 sec. elapsed time - -~~~~~ -The example shows how much memory the system spends. Memory is divided -into Program Space, Stack Space and Trail. In the example we have 3MB -allocated for program spaces, with less than half being actually -used. YAP also shows the maximum amount of heap space having been used -which was over 2MB. - -The stack space is divided into two stacks which grow against each -other. We are in the top level so very little stack is being used. On -the other hand, the system did use a lot of global and local stack -during the previous execution (we refer the reader to a WAM tutorial in -order to understand what are the global and local stacks). - -YAP also shows information on how many memory overflows and garbage -collections the system executed, and statistics on total execution -time. Cputime includes all running time, runtime excludes garbage -collection and stack overflow time. - - -*/ - -/** @pred statistics(? _Param_,- _Info_) - -Gives statistical information on the system parameter given by first -argument: - - - -+ atoms - -`[ _NumberOfAtoms_, _SpaceUsedBy Atoms_]` - - -This gives the total number of atoms `NumberOfAtoms` and how much -space they require in bytes, _SpaceUsedBy Atoms_. - -+ cputime - -`[ _Time since Boot_, _Time From Last Call to Cputime_]` - - -This gives the total cputime in milliseconds spent executing Prolog code, -garbage collection and stack shifts time included. - -+ dynamic_code - -`[ _Clause Size_, _Index Size_, _Tree Index Size_, _Choice Point Instructions Size_, _Expansion Nodes Size_, _Index Switch Size_]` - - -Size of static code in YAP in bytes: _Clause Size_, the number of -bytes allocated for clauses, plus - _Index Size_, the number of bytes spent in the indexing code. The -indexing code is divided into main tree, _Tree Index Size_, -tables that implement choice-point manipulation, _Choice xsPoint Instructions Size_, tables that cache clauses for future expansion of the index -tree, _Expansion Nodes Size_, and -tables such as hash tables that select according to value, _Index Switch Size_. - -+ garbage_collection - -`[ _Number of GCs_, _Total Global Recovered_, _Total Time Spent_]` - - -Number of garbage collections, amount of space recovered in kbytes, and -total time spent doing garbage collection in milliseconds. More detailed -information is available using `yap_flag(gc_trace,verbose)`. - -+ global_stack - -`[ _Global Stack Used_, _Execution Stack Free_]` - - -Space in kbytes currently used in the global stack, and space available for -expansion by the local and global stacks. - -+ local_stack - -`[ _Local Stack Used_, _Execution Stack Free_]` - - -Space in kbytes currently used in the local stack, and space available for -expansion by the local and global stacks. - -+ heap - -`[ _Heap Used_, _Heap Free_]` - - -Total space in kbytes not recoverable -in backtracking. It includes the program code, internal data base, and, -atom symbol table. - -+ program - -`[ _Program Space Used_, _Program Space Free_]` - - -Equivalent to heap. - -+ runtime - -`[ _Time since Boot_, _Time From Last Call to Runtime_]` - - -This gives the total cputime in milliseconds spent executing Prolog -code, not including garbage collections and stack shifts. Note that -until YAP4.1.2 the runtime statistics would return time spent on -garbage collection and stack shifting. - -+ stack_shifts - -`[ _Number of Heap Shifts_, _Number of Stack Shifts_, _Number of Trail Shifts_]` - - -Number of times YAP had to -expand the heap, the stacks, or the trail. More detailed information is -available using `yap_flag(gc_trace,verbose)`. - -+ static_code - -`[ _Clause Size_, _Index Size_, _Tree Index Size_, _Expansion Nodes Size_, _Index Switch Size_]` - - -Size of static code in YAP in bytes: _Clause Size_, the number of -bytes allocated for clauses, plus - _Index Size_, the number of bytes spent in the indexing code. The -indexing code is divided into a main tree, _Tree Index Size_, table that cache clauses for future expansion of the index -tree, _Expansion Nodes Size_, and and -tables such as hash tables that select according to value, _Index Switch Size_. - -+ trail - -`[ _Trail Used_, _Trail Free_]` - - -Space in kbytes currently being used and still available for the trail. - -+ walltime - -`[ _Time since Boot_, _Time From Last Call to Walltime_]` - - -This gives the clock time in milliseconds since starting Prolog. - - - - -*/ - -/** @pred time(: _Goal_) - - -Prints the CPU time and the wall time for the execution of _Goal_. -Possible choice-points of _Goal_ are removed. Based on the SWI-Prolog -definition (minus reporting the number of inferences, which YAP currently -does not support). - - -*/ - -/** @pred yap_flag(? _Param_,? _Value_) - - -Set or read system properties for _Param_: - - -+ `argv ` - - Read-only flag. It unifies with a list of atoms that gives the -arguments to YAP after `--`. - -+ `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. - -+ `associate ` - - Read-write flag telling a suffix for files associated to Prolog -sources. It is `yap` by default. - -+ `bounded is iso ` - - Read-only flag telling whether integers are bounded. The value depends -on whether YAP uses the GMP library or not. - -+ `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. - -+ `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`. - -+ `character_escapes is iso ` - - Writable flag telling whether a character escapes are enables, -`true`, or disabled, `false`. The default value for this flag is -`on`. - -+ `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. - -+ `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. - -+ `dialect ` - - Read-only flag that always returns `yap`. - -+ `discontiguous_warnings ` - - If _Value_ is unbound, tell whether warnings for discontiguous -predicates are `on` or -`off`. If _Value_ is bound to `on` enable these warnings, -and if it is bound to `off` disable them. The default for YAP is -`off`, unless we are in `sicstus` or `iso` mode. - -+ `dollar_as_lower_case ` - - If `off` (default) consider the character `$` a control character, if -`on` consider `$` a lower case character. - -+ `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`. - -+ `executable ` - - Read-only flag. It unifies with an atom that gives the -original program path. - -+ `fast ` - - If `on` allow fast machine code, if `off` (default) disable it. Only -available in experimental implementations. - -+ `fileerrors` - - If `on` `fileerrors` is `on`, if `off` (default) -`fileerrors` is disabled. - -+ `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. - -+ `gc` - - If `on` allow garbage collection (default), if `off` disable it. - -+ `gc_margin ` - - Set or show the minimum free stack before starting garbage -collection. The default depends on total stack size. - -+ `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. - -+ `generate_debugging_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. - -+ `host_type ` - - Return `configure` system information, including the machine-id -for which YAP was compiled and Operating System information. - -+ `index ` - - If `on` allow indexing (default), if `off` disable it, if -`single` allow on first argument only. - -+ `index_sub_term_search_depth ` - - Maximum bound on searching sub-terms for indexing, if `0` (default) no bound. - -+ `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. - -+ `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. - -+ `language ` - - Choose whether YAP is closer to C-Prolog, `cprolog`, 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. - -+ `max_arity is iso ` - - Read-only flag telling the maximum arity of a functor. Takes the value -`unbounded` for the current version of YAP. - -+ `max_integer is iso ` - - Read-only flag telling the maximum integer in the -implementation. Depends on machine and Operating System -architecture, and on whether YAP uses the `GMP` multi-precision -library. If bounded is false, requests for max_integer -will fail. - -+ `max_tagged_integer ` - - Read-only flag telling the maximum integer we can store as a single -word. Depends on machine and Operating System -architecture. It can be used to find the word size of the current machine. - -+ `min_integer is iso ` - - Read-only flag telling the minimum integer in the -implementation. Depends on machine and Operating System architecture, -and on whether YAP uses the `GMP` multi-precision library. If -bounded is false, requests for min_integer will fail. - -+ `min_tagged_integer ` - - Read-only flag telling the minimum integer we can store as a single -word. Depends on machine and Operating System -architecture. - -+ `n_of_integer_keys_in_bb ` - - Read or set the size of the hash table that is used for looking up the -blackboard when the key is an integer. - -+ `occurs_check ` - - Current read-only and set to `false`. - -+ `n_of_integer_keys_in_db ` - - Read or set the size of the hash table that is used for looking up the -internal data-base when the key is an integer. - -+ `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). - -+ `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). - -+ `profiling ` - - If `off` (default) do not compile profiling information for -procedures. If `on` compile predicates so that they will output -profiling information. Profiling data can be read through the -profile_data/3 built-in. - -+ `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. - -+ `redefine_warnings ` - - If _Value_ is unbound, tell whether warnings for procedures defined -in several different files are `on` or -`off`. If _Value_ is bound to `on` enable these warnings, -and if it is bound to `off` disable them. The default for YAP is -`off`, unless we are in `sicstus` or `iso` mode. - -+ `shared_object_search_path ` - - Name of the environment variable used by the system to search for shared -objects. - -+ `shared_object_extension ` - - Suffix associated with loadable code. - -+ `single_var_warnings ` - - If _Value_ is unbound, tell whether warnings for singleton variables -are `on` or `off`. If _Value_ is bound to `on` enable -these warnings, and if it is bound to `off` disable them. The -default for YAP is `off`, unless we are in `sicstus` or -`iso` mode. - -+ `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. - -+ `stack_dump_on_error ` - - If `on` show a stack dump when YAP finds an error. The default is -`off`. - -+ `syntax_errors` - - Control action to be taken after syntax errors while executing read/1, -`read/2`, or `read_term/3`: - + `dec10` -Report the syntax error and retry reading the term. - + `fail` -Report the syntax error and fail (default). - + `error` -Report the syntax error and generate an error. - + `quiet` -Just fail - -+ `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`. - -+ `tabling_mode` - - Sets or reads the tabling mode for all tabled predicates. Please - (see Tabling) for the list of options. - -+ `to_chars_mode ` - - Define whether YAP should follow `quintus`-like -semantics for the `atom_chars/1` or `number_chars/1` built-in, -or whether it should follow the ISO standard (`iso` option). - -+ `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. - -+ `toplevel_print_options ` - - If bound, set the argument to the `write_term/3` options used to write -terms from the top-level. If unbound, show the current options. - -+ `typein_module ` - - If bound, set the current working or type-in module to the argument, -which must be an atom. If unbound, unify the argument with the current -working module. - -+ `unix` - - Read-only Boolean 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`. - -+ `unknown is iso` - - Corresponds to calling the unknown/2 built-in. Possible values -are `error`, `fail`, and `warning`. - -+ `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. - -+ `user_error ` - - If the second argument is bound to a stream, set user_error to -this stream. If the second argument is unbound, unify the argument with -the current user_error stream. -By default, the user_error stream is set to a stream -corresponding to the Unix `stderr` stream. -The next example shows how to use this flag: - -~~~{.prolog} - ?- open( '/dev/null', append, Error, - [alias(mauri_tripa)] ). - - Error = '$stream'(3) ? ; - - no - ?- set_prolog_flag(user_error, mauri_tripa). - - close(mauri_tripa). - - yes - ?- -~~~ - We execute three commands. First, we open a stream in write mode and -give it an alias, in this case `mauri_tripa`. Next, we set -user_error to the stream via the alias. Note that after we did so -prompts from the system were redirected to the stream -`mauri_tripa`. Last, we close the stream. At this point, YAP -automatically redirects the user_error alias to the original -`stderr`. - -+ `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. - -+ `user_input ` - - If the second argument is bound to a stream, set user_input to -this stream. If the second argument is unbound, unify the argument with -the current user_input stream. -By default, the user_input stream is set to a stream -corresponding to the Unix `stdin` stream. - -+ `user_output ` - - If the second argument is bound to a stream, set user_output to -this stream. If the second argument is unbound, unify the argument with -the current user_output stream. -By default, the user_output stream is set to a stream -corresponding to the Unix `stdout` stream. - -+ `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. - -+ `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. - -+ `version ` - - Read-only flag that returns an atom with the current version of -YAP. - -+ `version_data ` - - Read-only flag that reads a term of the form -`yap`( _Major_, _Minor_, _Patch_, _Undefined_), where - _Major_ is the major version, _Minor_ is the minor version, -and _Patch_ is the patch number. - -+ `windows ` - - Read-only boolean flag that unifies with tr `true` if YAP is -running on an Windows machine. - -+ `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`. - -+ `max_workers ` - - Read-only flag telling the maximum number of parallel processes. - -+ `max_threads ` - - Read-only flag telling the maximum number of Prolog threads that can -be created. - - - -*/ - -/** @pred current_prolog_flag(? _Flag_,- _Value_) is iso - -Obtain the value for a YAP Prolog flag. Equivalent to calling -yap_flag/2 with the second argument unbound, and unifying the -returned second argument with _Value_. - - -*/ - -/** @pred prolog_flag(? _Flag_,- _OldValue_,+ _NewValue_) - - - -Obtain the value for a YAP Prolog flag and then set it to a new -value. Equivalent to first calling current_prolog_flag/2 with the -second argument _OldValue_ unbound and then calling -set_prolog_flag/2 with the third argument _NewValue_. - - -*/ - -/** @pred set_prolog_flag(+ _Flag_,+ _Value_) is iso - - - -Set the value for YAP Prolog flag `Flag`. Equivalent to -calling yap_flag/2 with both arguments bound. - - -*/ - -/** @pred create_prolog_flag(+ _Flag_,+ _Value_,+ _Options_) - - - -Create a new YAP Prolog flag. _Options_ include `type(+Type)` and `access(+Access)` with _Access_ -one of `read_only` or `read_write` and _Type_ one of `boolean`, `integer`, `float`, `atom` -and `term` (that is, no type). - - -*/ - -/** @pred op(+ _P_,+ _T_,+ _A_) is iso - - -Defines the operator _A_ or the list of operators _A_ with type - _T_ (which must be one of `xfx`, `xfy`,`yfx`, -`xf`, `yf`, `fx` or `fy`) and precedence _P_ -(see appendix iv for a list of predefined operators). - -Note that if there is a preexisting operator with the same name and -type, this operator will be discarded. Also, `,` may not be defined -as an operator, and it is not allowed to have the same for an infix and -a postfix operator. - - -*/ - -/** @pred current_op( _P_, _T_, _F_) is iso - - -Defines the relation: _P_ is a currently defined operator of type - _T_ and precedence _P_. - - -*/ - -/** @pred prompt(- _A_,+ _B_) - - -Changes YAP input prompt from _A_ to _B_. - - -*/ - -/** @pred initialization - -Execute the goals defined by initialization/1. Only the first answer is -considered. - - -*/ - -/** @pred prolog_initialization( _G_) - - -Add a goal to be executed on system initialization. This is compatible -with SICStus Prolog's initialization/1. - - -*/ - -/** @pred version - -Write YAP's boot message. - - -*/ - -/** @pred version(- _Message_) - -Add a message to be written when yap boots or after aborting. It is not -possible to remove messages. - - -*/ - -/** @pred prolog_load_context(? _Key_, ? _Value_) - - -Obtain information on what is going on in the compilation process. The -following keys are available: - - - -+ directory - - - -Full name for the directory where YAP is currently consulting the -file. - -+ file - - - -Full name for the file currently being consulted. Notice that included -filed are ignored. - -+ module - - - -Current source module. - -+ `source` (prolog_load_context/2 option) - - Full name for the file currently being read in, which may be consulted, -reconsulted, or included. - -+ `stream` - - Stream currently being read in. - -+ `term_position` - - Stream position at the stream currently being read in. For SWI -compatibility, it is a term of the form -'$stream_position'(0,Line,0,0,0). - - -+ `source_location(? _FileName_, ? _Line_)` - - SWI-compatible predicate. If the last term has been read from a physical file (i.e., not from the file user or a string), unify File with an absolute path to the file and Line with the line-number in the file. Please use prolog_load_context/2. - -+ `source_file(? _File_)` - - SWI-compatible predicate. True if _File_ is a loaded Prolog source file. - -+ `source_file(? _ModuleAndPred_,? _File_)` - - SWI-compatible predicate. True if the predicate specified by _ModuleAndPred_ was loaded from file _File_, where _File_ is an absolute path name (see `absolute_file_name/2`). - - - -@section YAPLibrary Library Predicates - -Library files reside in the library_directory path (set by the -`LIBDIR` variable in the Makefile for YAP). Currently, -most files in the library are from the Edinburgh Prolog library. - - - */ - -/** @defgroup Aggregate Aggregate -@ingroup YAPLibrary -@{ - -This is the SWI-Prolog library based on the Quintus and SICStus 4 -library. @c To be done - Analysing the aggregation template. - - -This library provides aggregating operators over the solutions of a -predicate. The operations are a generalisation of the bagof/3, -setof/3 and findall/3 built-in predicates. The defined -aggregation operations are counting, computing the sum, minimum, -maximum, a bag of solutions and a set of solutions. We first give a -simple example, computing the country with the smallest area: - -~~~~~{.prolog} -smallest_country(Name, Area) :- - aggregate(min(A, N), country(N, A), min(Area, Name)). -~~~~~ - -There are four aggregation predicates, distinguished on two properties. - -+ aggregate vs. aggregate_all -The aggregate predicates use setof/3 (aggregate/4) or bagof/3 -(aggregate/3), dealing with existential qualified variables -( _Var_/\ _Goal_) and providing multiple solutions for the -remaining free variables in _Goal_. The aggregate_all/3 -predicate uses findall/3, implicitly qualifying all free variables -and providing exactly one solution, while aggregate_all/4 uses -sort/2 over solutions and Distinguish (see below) generated using -findall/3. -+ The _Distinguish_ argument -The versions with 4 arguments provide a _Distinguish_ argument -that allow for keeping duplicate bindings of a variable in the -result. For example, if we wish to compute the total population of -all countries we do not want to lose results because two countries -have the same population. Therefore we use: - -~~~~~{.prolog} - aggregate(sum(P), Name, country(Name, P), Total) -~~~~~ - - - -All aggregation predicates support the following operators below in - _Template_. In addition, they allow for an arbitrary named compound -term where each of the arguments is a term from the list below. I.e. the -term `r(min(X), max(X))` computes both the minimum and maximum -binding for _X_. - -+ `count` - - Count number of solutions. Same as `sum(1)`. - -+ `sum( _Expr_)` - - Sum of _Expr_ for all solutions. - -+ `min( _Expr_)` - - Minimum of _Expr_ for all solutions. - -+ `min( _Expr_, _Witness_)` - - A term min( _Min_, _Witness_), where _Min_ is the minimal version of _Expr_ - -over all Solution and _Witness_ is any other template applied to -Solution that produced _Min_. If multiple solutions provide the same -minimum, _Witness_ corresponds to the first solution. - -+ `max( _Expr_)` - - Maximum of _Expr_ for all solutions. - -+ `max( _Expr_, _Witness_)` - - As min( _Expr_, _Witness_), but producing the maximum result. - -+ `set( _X_)` - - An ordered set with all solutions for _X_. - -+ `bag( _X_)` - - A list of all solutions for _X_. - - - -The predicates are: - - - - @pred aggregate(+ _Template_, : _Goal_, - _Result_) is nondet - - -Aggregate bindings in _Goal_ according to _Template_. The -aggregate/3 version performs bagof/3 on _Goal_. - -*/ - -/** @pred [nondet]aggregate(+ _Template_, + _Discriminator_, : _Goal_, - _Result_) - -Aggregate bindings in _Goal_ according to _Template_. The -aggregate/3 version performs setof/3 on _Goal_. - -*/ - -/** @pred aggregate_all(+ _Template_, : _Goal_, - _Result_) is semidet - - -Aggregate bindings in _Goal_ according to _Template_. The -aggregate_all/3 version performs findall/3 on _Goal_. - -*/ - -/** @pred aggregate_all(+ _Template_, + _Discriminator_, : _Goal_, - _Result_) is semidet - -Aggregate bindings in _Goal_ according to _Template_. The -aggregate_all/3 version performs findall/3 followed by sort/2 on - _Goal_. - -*/ - -/** @pred foreach(:Generator, : _Goal_) - - -True if the conjunction of instances of _Goal_ using the -bindings from Generator is true. Unlike forall/2, which runs a -failure-driven loop that proves _Goal_ for each solution of -Generator, foreach creates a conjunction. Each member of the -conjunction is a copy of _Goal_, where the variables it shares -with Generator are filled with the values from the corresponding -solution. - -The implementation executes forall/2 if _Goal_ does not contain -any variables that are not shared with Generator. - -Here is an example: - -~~~~~{.prolog} - ?- foreach( between(1,4,X), dif(X,Y)), Y = 5. - Y = 5 - ?- foreach( between(1,4,X), dif(X,Y)), Y = 3. - No -~~~~~ - -Notice that _Goal_ is copied repeatedly, which may cause -problems if attributed variables are involved. - - -*/ - -/** @pred free_variables(:Generator, + _Template_, +VarList0, -VarList) is det - - -In order to handle variables properly, we have to find all the universally quantified variables in the Generator. All variables as yet unbound are universally quantified, unless - -+ they occur in the template -+ they are bound by X/\P, setof, or bagof - -`free_variables(Generator, Template, OldList, NewList)` finds this set, using OldList as an accumulator. - - -The original author of this code was Richard O'Keefe. Jan Wielemaker -made some SWI-Prolog enhancements, sponsored by SecuritEase, -http://www.securitease.com. The code is public domain (from DEC10 library). - - - */ - -/** @defgroup Apply Apply Macros -@ingroup YAPLibrary -@{ - -This library provides a SWI-compatible set of utilities for applying a -predicate to all elements of a list. The library just forwards -definitions from the `maplist` library. - - - */ - -/** @defgroup Association_Lists Association Lists -@ingroup YAPLibrary -@{ - -The following association list manipulation predicates are available -once included with the `use_module(library(assoc))` command. The -original library used Richard O'Keefe's implementation, on top of -unbalanced binary trees. The current code utilises code from the -red-black trees library and emulates the SICStus Prolog interface. - - -*/ - -/** @pred assoc_to_list(+ _Assoc_,? _List_) - - -Given an association list _Assoc_ unify _List_ with a list of -the form _Key-Val_, where the elements _Key_ are in ascending -order. - - -*/ - -/** @pred del_assoc(+ _Key_, + _Assoc_, ? _Val_, ? _NewAssoc_) - - -Succeeds if _NewAssoc_ is an association list, obtained by removing -the element with _Key_ and _Val_ from the list _Assoc_. - - -*/ - -/** @pred del_max_assoc(+ _Assoc_, ? _Key_, ? _Val_, ? _NewAssoc_) - - -Succeeds if _NewAssoc_ is an association list, obtained by removing -the largest element of the list, with _Key_ and _Val_ from the -list _Assoc_. - - -*/ - -/** @pred del_min_assoc(+ _Assoc_, ? _Key_, ? _Val_, ? _NewAssoc_) - - -Succeeds if _NewAssoc_ is an association list, obtained by removing -the smallest element of the list, with _Key_ and _Val_ -from the list _Assoc_. - - -*/ - -/** @pred empty_assoc(+ _Assoc_) - - -Succeeds if association list _Assoc_ is empty. - - -*/ - -/** @pred gen_assoc(+ _Assoc_,? _Key_,? _Value_) - - -Given the association list _Assoc_, unify _Key_ and _Value_ -with two associated elements. It can be used to enumerate all elements -in the association list. - - -*/ - -/** @pred get_assoc(+ _Key_,+ _Assoc_,? _Value_) - - -If _Key_ is one of the elements in the association list _Assoc_, -return the associated value. - - -*/ - -/** @pred get_assoc(+ _Key_,+ _Assoc_,? _Value_,+ _NAssoc_,? _NValue_) - - -If _Key_ is one of the elements in the association list _Assoc_, -return the associated value _Value_ and a new association list - _NAssoc_ where _Key_ is associated with _NValue_. - - -*/ - -/** @pred get_prev_assoc(+ _Key_,+ _Assoc_,? _Next_,? _Value_) - - -If _Key_ is one of the elements in the association list _Assoc_, -return the previous key, _Next_, and its value, _Value_. - - -*/ - -/** @pred get_next_assoc(+ _Key_,+ _Assoc_,? _Next_,? _Value_) - -If _Key_ is one of the elements in the association list _Assoc_, -return the next key, _Next_, and its value, _Value_. - - -*/ - -/** @pred is_assoc(+ _Assoc_) - - -Succeeds if _Assoc_ is an association list, that is, if it is a -red-black tree. - - -*/ - -/** @pred list_to_assoc(+ _List_,? _Assoc_) - - -Given a list _List_ such that each element of _List_ is of the -form _Key-Val_, and all the _Keys_ are unique, _Assoc_ is -the corresponding association list. - - -*/ - -/** @pred map_assoc(+ _Pred_,+ _Assoc_) - - -Succeeds if the unary predicate name _Pred_( _Val_) holds for every -element in the association list. - - -*/ - -/** @pred map_assoc(+ _Pred_,+ _Assoc_,? _New_) - -Given the binary predicate name _Pred_ and the association list - _Assoc_, _New_ in an association list with keys in _Assoc_, -and such that if _Key-Val_ is in _Assoc_, and _Key-Ans_ is in - _New_, then _Pred_( _Val_, _Ans_) holds. - - -*/ - -/** @pred max_assoc(+ _Assoc_,- _Key_,? _Value_) - - -Given the association list - _Assoc_, _Key_ in the largest key in the list, and _Value_ -the associated value. - - -*/ - -/** @pred min_assoc(+ _Assoc_,- _Key_,? _Value_) - - -Given the association list - _Assoc_, _Key_ in the smallest key in the list, and _Value_ -the associated value. - - -*/ - -/** @pred ord_list_to_assoc(+ _List_,? _Assoc_) - - -Given an ordered list _List_ such that each element of _List_ is -of the form _Key-Val_, and all the _Keys_ are unique, _Assoc_ is -the corresponding association list. - - -*/ - -/** @pred put_assoc(+ _Key_,+ _Assoc_,+ _Val_,+ _New_) - - -The association list _New_ includes and element of association - _key_ with _Val_, and all elements of _Assoc_ that did not -have key _Key_. - - - - - */ - -/** @defgroup AVL_Trees AVL Trees -@ingroup YAPLibrary -@{ - -AVL trees are balanced search binary trees. They are named after their -inventors, Adelson-Velskii and Landis, and they were the first -dynamically balanced trees to be proposed. The YAP AVL tree manipulation -predicates library uses code originally written by Martin van Emdem and -published in the Logic Programming Newsletter, Autumn 1981. A bug in -this code was fixed by Philip Vasey, in the Logic Programming -Newsletter, Summer 1982. The library currently only includes routines to -insert and lookup elements in the tree. Please try red-black trees if -you need deletion. - - -*/ - -/** @pred avl_new(+ _T_) - - -Create a new tree. - - -*/ - -/** @pred avl_insert(+ _Key_,? _Value_,+ _T0_,- _TF_) - - -Add an element with key _Key_ and _Value_ to the AVL tree - _T0_ creating a new AVL tree _TF_. Duplicated elements are -allowed. - - -*/ - -/** @pred avl_lookup(+ _Key_,- _Value_,+ _T_) - - -Lookup an element with key _Key_ in the AVL tree - _T_, returning the value _Value_. - - - - - */ - -/** @defgroup Exo_Intervals Exo Intervals -@ingroup YAPLibrary -@{ - -This package assumes you use exo-compilation, that is, that you loaded -the pedicate using the `exo` option to load_files/2, In this -case, YAP includes a package for improved search on intervals of -integers. - -The package is activated by `udi` declarations that state what is -the argument of interest: - -~~~~~{.prolog} -:- udi(diagnoses(exo_interval,?,?)). - -:- load_files(db, [consult(exo)]). -~~~~~ -It is designed to optimise the following type of queries: - -~~~~~{.prolog} -?- max(X, diagnoses(X, 9, Y), X). - -?- min(X, diagnoses(X, 9, 36211117), X). - -?- X #< Y, min(X, diagnoses(X, 9, 36211117), X ), diagnoses(Y, 9, _). -~~~~~ -The first argument gives the time, the second the patient, and the -third the condition code. The first query should find the last time -the patient 9 had any code reported, the second looks for the first -report of code 36211117, and the last searches for reports after this -one. All queries run in constant or log(n) time. - - - */ - -/** @defgroup Gecode Gecode Interface -@ingroup YAPPackages -@{ - - -The gecode library intreface was designed and implemented by Denis -Duchier, with recent work by Vítor Santos Costa to port it to version 4 -of gecode and to have an higher level interface, - - - */ - -/** @defgroup The_Gecode_Interface The Gecode Interface -@ingroup Gecode -@{ - -This text is due to Denys Duchier. The gecode interface requires - -~~~~~{.prolog} -:- use_module(library(gecode)). -~~~~~ -Several example programs are available with the distribution. - -+ CREATING A SPACE - -A space is gecodes data representation for a store of constraints: - -~~~~~{.prolog} - Space := space -~~~~~ - -+ CREATING VARIABLES - -Unlike in Gecode, variable objects are not bound to a specific Space. Each one -actually contains an index with which it is possible to access a Space-bound -Gecode variable. Variables can be created using the following expressions: - -~~~~~{.prolog} - IVar := intvar(Space,SPEC...) - BVar := boolvar(Space) - SVar := setvar(Space,SPEC...) -~~~~~ - -where SPEC... is the same as in Gecode. For creating lists of variables use -the following variants: - -~~~~~{.prolog} - IVars := intvars(Space,N,SPEC...) - BVars := boolvars(Space,N,SPEC...) - SVars := setvars(Space,N,SPEC...) -~~~~~ - -where N is the number of variables to create (just like for XXXVarArray in -Gecode). Sometimes an IntSet is necessary: - -~~~~~{.prolog} - ISet := intset([SPEC...]) -~~~~~ - -where each SPEC is either an integer or a pair (I,J) of integers. An IntSet -describes a set of ints by providing either intervals, or integers (which stand -for an interval of themselves). It might be tempting to simply represent an -IntSet as a list of specs, but this would be ambiguous with IntArgs which, -here, are represented as lists of ints. - -~~~~~{.prolog} - Space += keep(Var) - Space += keep(Vars) -~~~~~ - -Variables can be marked as "kept". In this case, only such variables will be -explicitly copied during search. This could bring substantial benefits in -memory usage. Of course, in a solution, you can then only look at variables -that have been "kept". If no variable is marked as "kept", then they are all -kept. Thus marking variables as "kept" is purely an optimization. - -+ CONSTRAINTS AND BRANCHINGS - -all constraint and branching posting functions are available just like in -Gecode. Wherever a XXXArgs or YYYSharedArray is expected, simply use a list. -At present, there is no support for minimodel-like constraint posting. -Constraints and branchings are added to a space using: - -~~~~~{.prolog} - Space += CONSTRAINT - Space += BRANCHING -~~~~~ - -For example: - -~~~~~{.prolog} - Space += rel(X,'IRT_EQ',Y) -~~~~~ - -arrays of variables are represented by lists of variables, and constants are -represented by atoms with the same name as the Gecode constant -(e.g. 'INT_VAR_SIZE_MIN'). - -+ SEARCHING FOR SOLUTIONS - -~~~~~{.prolog} - SolSpace := search(Space) -~~~~~ - -This is a backtrackable predicate that enumerates all solution spaces -(SolSpace). It may also take options: - -~~~~~{.prolog} - SolSpace := search(Space,Options) -~~~~~ - -Options is a list whose elements maybe: - -+ restart -to select the Restart search engine -+ threads=N -to activate the parallel search engine and control the number of -workers (see Gecode doc) -+ c_d=N -to set the commit distance for recomputation -+ a_d=N -to set the adaptive distance for recomputation - - - -+ EXTRACTING INFO FROM A SOLUTION - -An advantage of non Space-bound variables, is that you can use them both to -post constraints in the original space AND to consult their values in -solutions. Below are methods for looking up information about variables. Each -of these methods can either take a variable as argument, or a list of -variables, and returns resp. either a value, or a list of values: - -~~~~~{.prolog} - Val := assigned(Space,X) - - Val := min(Space,X) - Val := max(Space,X) - Val := med(Space,X) - Val := val(Space,X) - Val := size(Space,X) - Val := width(Space,X) - Val := regret_min(Space,X) - Val := regret_max(Space,X) - - Val := glbSize(Space,V) - Val := lubSize(Space,V) - Val := unknownSize(Space,V) - Val := cardMin(Space,V) - Val := cardMax(Space,V) - Val := lubMin(Space,V) - Val := lubMax(Space,V) - Val := glbMin(Space,V) - Val := glbMax(Space,V) - Val := glb_ranges(Space,V) - Val := lub_ranges(Space,V) - Val := unknown_ranges(Space,V) - Val := glb_values(Space,V) - Val := lub_values(Space,V) - Val := unknown_values(Space,V) -~~~~~ - -+ DISJUNCTORS - -Disjunctors provide support for disjunctions of clauses, where each clause is a -conjunction of constraints: - -~~~~~{.prolog} - C1 or C2 or ... or Cn -~~~~~ - -Each clause is executed "speculatively": this means it does not affect the main -space. When a clause becomes failed, it is discarded. When only one clause -remains, it is committed: this means that it now affects the main space. - -Example: - -Consider the problem where either X=Y=0 or X=Y+(1 or 2) for variable X and Y -that take values in 0..3. - -~~~~~{.prolog} - Space := space, - [X,Y] := intvars(Space,2,0,3), -~~~~~ - -First, we must create a disjunctor as a manager for our 2 clauses: - -~~~~~{.prolog} - Disj := disjunctor(Space), -~~~~~ - -We can now create our first clause: - -~~~~~{.prolog} - C1 := clause(Disj), -~~~~~ - -This clause wants to constrain X and Y to 0. However, since it must be -executed "speculatively", it must operate on new variables X1 and Y1 that -shadow X and Y: - -~~~~~{.prolog} - [X1,Y1] := intvars(C1,2,0,3), - C1 += forward([X,Y],[X1,Y1]), -~~~~~ - -The forward(...) stipulation indicates which global variable is shadowed by -which clause-local variable. Now we can post the speculative clause-local -constraints for X=Y=0: - -~~~~~{.prolog} - C1 += rel(X1,'IRT_EQ',0), - C1 += rel(Y1,'IRT_EQ',0), -~~~~~ - -We now create the second clause which uses X2 and Y2 to shadow X and Y: - -~~~~~{.prolog} - C2 := clause(Disj), - [X2,Y2] := intvars(C2,2,0,3), - C2 += forward([X,Y],[X2,Y2]), -~~~~~ - -However, this clause also needs a clause-local variable Z2 taking values 1 or -2 in order to post the clause-local constraint X2=Y2+Z2: - -~~~~~{.prolog} - Z2 := intvar(C2,1,2), - C2 += linear([-1,1,1],[X2,Y2,Z2],'IRT_EQ',0), -~~~~~ - -Finally, we can branch and search: - -~~~~~{.prolog} - Space += branch([X,Y],'INT_VAR_SIZE_MIN','INT_VAL_MIN'), - SolSpace := search(Space), -~~~~~ - -and lookup values of variables in each solution: - -~~~~~{.prolog} - [X_,Y_] := val(SolSpace,[X,Y]). -~~~~~ - - - - - */ - -/** @defgroup Gecode_and_ClPbBFDbC Programming Finite Domain Constraints in YAP/Gecode -@ingroup Gecode -@{ - -The gecode/clp(fd) interface is designed to use the GECODE functionality -in a more CLP like style. It requires - -~~~~~{.prolog} -:- use_module(library(gecode/clpfd)). -~~~~~ -Several example programs are available with the distribution. - -Integer variables are declared as: - -+ _V_ in _A_.. _B_ -declares an integer variable _V_ with range _A_ to _B_. -+ _Vs_ ins _A_.. _B_ -declares a set of integer variabless _Vs_ with range _A_ to _B_. -+ boolvar( _V_) -declares a boolean variable. -+ boolvars( _Vs_) -declares a set of boolean variable. - - -Constraints supported are: - - -*/ - -/** @pred _X_ #= _Y_ is semidet -equality - -*/ - -/** @pred _X_ #\= _Y_ is semidet -disequality - -*/ - -/** @pred _X_ #> _Y_ is semidet -larger - -*/ - -/** @pred _X_ #>= _Y_ is semidet -larger or equal - -*/ - -/** @pred _X_ #=< _Y_ is semidet -smaller - -*/ - -/** @pred _X_ #< _Y_ is semidet -smaller or equal - -Arguments to this constraint may be an arithmetic expression with +, --, \\*, integer division /, min, max, sum, -count, and -abs. Boolean variables support conjunction (/\), disjunction (\/), -implication (=>), equivalence (<=>), and xor. The sum constraint allows a two argument version using the -`where` conditional, in Zinc style. - -The send more money equation may be written as: - -~~~~~{.prolog} - 1000*S + 100*E + 10*N + D + - 1000*M + 100*O + 10*R + E #= -10000*M + 1000*O + 100*N + 10*E + Y, -~~~~~ - -This example uses `where` to select from -column _I_ the elements that have value under _M_: - -~~~~~{.prolog} -OutFlow[I] #= sum(J in 1..N where D[J,I]count constraint counts the number of elements that match a -certain constant or variable (integer sets are not available). - - -*/ - -/** @pred all_different( _Vs_ ) - -Verifies whether all elements of a list are different. -*/ - -/** @pred all_distinct( _Cs_, _Vs_) - -verifies whether all elements of a list are different. Also tests if -all the sums between a list of constants and a list of variables are -different. - -This is a formulation of the queens problem that uses both versions of `all_different`: - -~~~~~{.prolog} -queens(N, Queens) :- - length(Queens, N), - Queens ins 1..N, - all_distinct(Queens), - foldl(inc, Queens, Inc, 0, _), % [0, 1, 2, .... ] - foldl(dec, Queens, Dec, 0, _), % [0, -1, -2, ... ] - all_distinct(Inc,Queens), - all_distinct(Dec,Queens), - labeling([], Queens). - -inc(_, I0, I0, I) :- - I is I0+1. - -dec(_, I0, I0, I) :- - I is I0-1. -~~~~~ - -The next example uses `all_different/1` and the functionality of the matrix package to verify that all squares in -sudoku have a different value: - -~~~~~{.prolog} - foreach( [I,J] ins 0..2 , - all_different(M[I*3+(0..2),J*3+(0..2)]) ), -~~~~~ - - -*/ - -/** @pred scalar_product(+ _Cs_, + _Vs_, + _Rel_, ? _V_ ) - -The product of constant _Cs_ by _Vs_ must be in relation - _Rel_ with _V_ . - - -*/ - -/** @pred _X_ #= is det -all elements of _X_ must take the same value - -*/ - -/** @pred _X_ #\= is det -not all elements of _X_ take the same value - -*/ - -/** @pred _X_ #> is det -elements of _X_ must be increasing - -*/ - -/** @pred _X_ #>= is det -elements of _X_ must be increasinga or equal - -*/ - -/** @pred _X_ #=< is det -elements of _X_ must be decreasing - -*/ - -/** @pred _X_ #< is det -elements of _X_ must be decreasing or equal - - -*/ - -/** @pred _X_ #<==> _B_ is det -reified equivalence - -*/ - -/** @pred _X_ #==> _B_ is det -Reified implication - -*/ - -/** @pred _X_ #< _B_ is det -reified implication - -As an example. consider finding out the people who wanted to sit -next to a friend and that are are actually sitting together: - -~~~~~{.prolog} -preference_satisfied(X-Y, B) :- - abs(X - Y) #= 1 #<==> B. -~~~~~ -Note that not all constraints may be reifiable. - - -*/ - -/** @pred element( _X_, _Vs_ ) - _X_ is an element of list _Vs_ - - -*/ - -/** @pred clause( _Type_, _Ps_ , _Ns_, _V_ ) -If _Type_ is `and` it is the conjunction of boolean variables - _Ps_ and the negation of boolean variables _Ns_ and must have -result _V_. If _Type_ is `or` it is a disjunction. - -+ DFA -the interface allows creating and manipulation deterministic finite -automata. A DFA has a set of states, represented as integers -and is initialised with an initial state, a set of transitions from the -first to the last argument emitting the middle argument, and a final -state. - -The swedish-drinkers protocol is represented as follows: - -~~~~~{.prolog} - A = [X,Y,Z], - dfa( 0, [t(0,0,0),t(0,1,1),t(1,0,0),t(-1,0,0)], [0], C), - in_dfa( A, C ), -~~~~~ -This code will enumeratae the valid tuples of three emissions. - -+ extensional constraints -Constraints can also be represented as lists of tuples. - -The previous example -would be written as: - -~~~~~{.prolog} - extensional_constraint([[0,0,0],[0,1,0],[1,0,0]], C), - in_relation( A, C ), -~~~~~ - - -*/ - -/** @pred minimum( _X_, _Vs_) - -*/ - -/** @pred min( _X_, _Vs_) -First Argument is the least element of a list. - - -*/ - -/** @pred maximum( _X_, _Vs_) - -*/ - -/** @pred max( _X_, _Vs_) -First Argument is the greatest element of a list. - -+ lex_order( _Vs_) -All elements must be ordered. - - - -The following predicates control search: - - -*/ - -/** @pred labeling( _Opts_, _Xs_) -performs labeling, several variable and value selection options are -available. The defaults are `min` and `min_step`. - -Variable selection options are as follows: - -+ leftmost -choose the first variable -+ min -choose one of the variables with smallest minimum value -+ max -choose one of the variables with greatest maximum value -+ ff -choose one of the most constrained variables, that is, with the smallest -domain. - - -Given that we selected a variable, the values chosen for branching may -be: - -+ min_step -smallest value -+ max_step -largest value -+ bisect -median -+ enum -all value starting from the minimum. - - - -*/ - -/** @pred maximize( _V_) -maximise variable _V_ - - -*/ - -/** @pred minimize(V) -minimise variable _V_ - - - - - */ - -/** @defgroup Heaps Heaps -@ingroup YAPLibrary -@{ - -A heap is a labelled binary tree where the key of each node is less than -or equal to the keys of its sons. The point of a heap is that we can -keep on adding new elements to the heap and we can keep on taking out -the minimum element. If there are N elements total, the total time is -O(NlgN). If you know all the elements in advance, you are better off -doing a merge-sort, but this file is for when you want to do say a -best-first search, and have no idea when you start how many elements -there will be, let alone what they are. - -The following heap manipulation routines are available once included -with the `use_module(library(heaps))` command. - - - - @pred add_to_heap(+ _Heap_,+ _key_,+ _Datum_,- _NewHeap_) - - -Inserts the new _Key-Datum_ pair into the heap. The insertion is not -stable, that is, if you insert several pairs with the same _Key_ it -is not defined which of them will come out first, and it is possible for -any of them to come out first depending on the history of the heap. - - -*/ - -/** @pred empty_heap(? _Heap_) - - -Succeeds if _Heap_ is an empty heap. - - -*/ - -/** @pred get_from_heap(+ _Heap_,- _key_,- _Datum_,- _Heap_) - - -Returns the _Key-Datum_ pair in _OldHeap_ with the smallest - _Key_, and also a _Heap_ which is the _OldHeap_ with that -pair deleted. - - -*/ - -/** @pred heap_size(+ _Heap_, - _Size_) - - -Reports the number of elements currently in the heap. - - -*/ - -/** @pred heap_to_list(+ _Heap_, - _List_) - - -Returns the current set of _Key-Datum_ pairs in the _Heap_ as a - _List_, sorted into ascending order of _Keys_. - - -*/ - -/** @pred list_to_heap(+ _List_, - _Heap_) - - -Takes a list of _Key-Datum_ pairs (such as keysort could be used to sort) -and forms them into a heap. - - -*/ - -/** @pred min_of_heap(+ _Heap_, - _Key_, - _Datum_) - - -Returns the Key-Datum pair at the top of the heap (which is of course -the pair with the smallest Key), but does not remove it from the heap. - - -*/ - -/** @pred min_of_heap(+ _Heap_, - _Key1_, - _Datum1_, -- _Key2_, - _Datum2_) - -Returns the smallest (Key1) and second smallest (Key2) pairs in the -heap, without deleting them. - - - - */ - -/** @defgroup Lists List Manipulation -@ingroup YAPLibrary -@{ - -The following list manipulation routines are available once included -with the `use_module(library(lists))` command. - - - - @pred append(? _Prefix_,? _Suffix_,? _Combined_) - - -True when all three arguments are lists, and the members of - _Combined_ are the members of _Prefix_ followed by the members of _Suffix_. -It may be used to form _Combined_ from a given _Prefix_, _Suffix_ or to take -a given _Combined_ apart. - - -*/ - -/** @pred append(? _Lists_,? _Combined_) - -Holds if the lists of _Lists_ can be concatenated as a - _Combined_ list. - - -*/ - -/** @pred delete(+ _List_, ? _Element_, ? _Residue_) - - -True when _List_ is a list, in which _Element_ may or may not -occur, and _Residue_ is a copy of _List_ with all elements -identical to _Element_ deleted. - - -*/ - -/** @pred flatten(+ _List_, ? _FlattenedList_) - - -Flatten a list of lists _List_ into a single list - _FlattenedList_. - -~~~~~{.prolog} -?- flatten([[1],[2,3],[4,[5,6],7,8]],L). - -L = [1,2,3,4,5,6,7,8] ? ; - -no -~~~~~ - - -*/ - -/** @pred last(+ _List_,? _Last_) - - -True when _List_ is a list and _Last_ is identical to its last element. - - -*/ - -/** @pred list_concat(+ _Lists_,? _List_) - - -True when _Lists_ is a list of lists and _List_ is the -concatenation of _Lists_. - - -*/ - -/** @pred member(? _Element_, ? _Set_) - - -True when _Set_ is a list, and _Element_ occurs in it. It may be used -to test for an element or to enumerate all the elements by backtracking. - - -*/ - -/** @pred memberchk(+ _Element_, + _Set_) - - -As member/2, but may only be used to test whether a known - _Element_ occurs in a known Set. In return for this limited use, it -is more efficient when it is applicable. - - -*/ - -/** @pred nth0(? _N_, ? _List_, ? _Elem_) - - -True when _Elem_ is the Nth member of _List_, -counting the first as element 0. (That is, throw away the first -N elements and unify _Elem_ with the next.) It can only be used to -select a particular element given the list and index. For that -task it is more efficient than member/2 - - -*/ - -/** @pred nth1(? _N_, ? _List_, ? _Elem_) - - -The same as nth0/3, except that it counts from -1, that is `nth(1, [H|_], H)`. - - -*/ - -/** @pred nth(? _N_, ? _List_, ? _Elem_) - - -The same as nth1/3. - - -*/ - -/** @pred nth0(? _N_, ? _List_, ? _Elem_, ? _Rest_) - -Unifies _Elem_ with the Nth element of _List_, -counting from 0, and _Rest_ with the other elements. It can be used -to select the Nth element of _List_ (yielding _Elem_ and _Rest_), or to -insert _Elem_ before the Nth (counting from 1) element of _Rest_, when -it yields _List_, e.g. `nth0(2, List, c, [a,b,d,e])` unifies List with -`[a,b,c,d,e]`. `nth/4` is the same except that it counts from 1. `nth0/4` -can be used to insert _Elem_ after the Nth element of _Rest_. - - -*/ - -/** @pred nth1(? _N_, ? _List_, ? _Elem_, ? _Rest_) - -Unifies _Elem_ with the Nth element of _List_, counting from 1, -and _Rest_ with the other elements. It can be used to select the -Nth element of _List_ (yielding _Elem_ and _Rest_), or to -insert _Elem_ before the Nth (counting from 1) element of - _Rest_, when it yields _List_, e.g. `nth(3, List, c, [a,b,d,e])` unifies List with `[a,b,c,d,e]`. `nth/4` -can be used to insert _Elem_ after the Nth element of _Rest_. - - -*/ - -/** @pred nth(? _N_, ? _List_, ? _Elem_, ? _Rest_) - -Same as `nth1/4`. - - -*/ - -/** @pred permutation(+ _List_,? _Perm_) - - -True when _List_ and _Perm_ are permutations of each other. - - -*/ - -/** @pred remove_duplicates(+ _List_, ? _Pruned_) - - -Removes duplicated elements from _List_. Beware: if the _List_ has -non-ground elements, the result may surprise you. - - -*/ - -/** @pred reverse(+ _List_, ? _Reversed_) - - -True when _List_ and _Reversed_ are lists with the same elements -but in opposite orders. - - -*/ - -/** @pred same_length(? _List1_, ? _List2_) - - -True when _List1_ and _List2_ are both lists and have the same number -of elements. No relation between the values of their elements is -implied. -Modes `same_length(-,+)` and `same_length(+,-)` generate either list given -the other; mode `same_length(-,-)` generates two lists of the same length, -in which case the arguments will be bound to lists of length 0, 1, 2, ... - - -*/ - -/** @pred select(? _Element_, ? _List_, ? _Residue_) - - -True when _Set_ is a list, _Element_ occurs in _List_, and - _Residue_ is everything in _List_ except _Element_ (things -stay in the same order). - - -*/ - -/** @pred selectchk(? _Element_, ? _List_, ? _Residue_) - - -Semi-deterministic selection from a list. Steadfast: defines as - -~~~~~{.prolog} -selectchk(Elem, List, Residue) :- - select(Elem, List, Rest0), !, - Rest = Rest0. -~~~~~ - - -*/ - -/** @pred sublist(? _Sublist_, ? _List_) - - -True when both `append(_,Sublist,S)` and `append(S,_,List)` hold. - - -*/ - -/** @pred suffix(? _Suffix_, ? _List_) - - -Holds when `append(_,Suffix,List)` holds. - - -*/ - -/** @pred sum_list(? _Numbers_, ? _Total_) - - -True when _Numbers_ is a list of numbers, and _Total_ is their sum. - - -*/ - -/** @pred sum_list(? _Numbers_, + _SoFar_, ? _Total_) - -True when _Numbers_ is a list of numbers, and _Total_ is the sum of their total plus _SoFar_. - - -*/ - -/** @pred sumlist(? _Numbers_, ? _Total_) - - -True when _Numbers_ is a list of integers, and _Total_ is their -sum. The same as sum_list/2, please do use sum_list/2 -instead. - - -*/ - -/** @pred max_list(? _Numbers_, ? _Max_) - - -True when _Numbers_ is a list of numbers, and _Max_ is the maximum. - - -*/ - -/** @pred min_list(? _Numbers_, ? _Min_) - - -True when _Numbers_ is a list of numbers, and _Min_ is the minimum. - - -*/ - -/** @pred numlist(+ _Low_, + _High_, + _List_) - - -If _Low_ and _High_ are integers with _Low_ =< - _High_, unify _List_ to a list `[Low, Low+1, ...High]`. See -also between/3. - - -*/ - -/** @pred intersection(+ _Set1_, + _Set2_, + _Set3_) - - -Succeeds if _Set3_ unifies with the intersection of _Set1_ and - _Set2_. _Set1_ and _Set2_ are lists without duplicates. They -need not be ordered. - - -*/ - -/** @pred subtract(+ _Set_, + _Delete_, ? _Result_) - - -Delete all elements from _Set_ that occur in _Delete_ (a set) -and unify the result with _Result_. Deletion is based on -unification using memberchk/2. The complexity is -`|Delete|\*|Set|`. - -See ord_subtract/3. - - - - */ - -/** @defgroup LineUtilities Line Manipulation Utilities -@ingroup YAPLibrary -@{ - -This package provides a set of useful predicates to manipulate -sequences of characters codes, usually first read in as a line. It is -available by loading the library `library(lineutils)`. - - - - @pred search_for(+ _Char_,+ _Line_) - - - -Search for a character _Char_ in the list of codes _Line_. - - -*/ - -/** @pred search_for(+ _Char_,+ _Line_,- _RestOfine_) - - -Search for a character _Char_ in the list of codes _Line_, - _RestOfLine_ has the line to the right. - - -*/ - -/** @pred scan_natural(? _Nat_,+ _Line_,+ _RestOfLine_) - - - -Scan the list of codes _Line_ for a natural number _Nat_, zero -or a positive integer, and unify _RestOfLine_ with the remainder -of the line. - - -*/ - -/** @pred scan_integer(? _Int_,+ _Line_,+ _RestOfLine_) - - - -Scan the list of codes _Line_ for an integer _Nat_, either a -positive, zero, or negative integer, and unify _RestOfLine_ with -the remainder of the line. - - -*/ - -/** @pred split(+ _Line_,+ _Separators_,- _Split_) - - - -Unify _Words_ with a set of strings obtained from _Line_ by -using the character codes in _Separators_ as separators. As an -example, consider: - -~~~~~{.prolog} -?- split("Hello * I am free"," *",S). - -S = ["Hello","I","am","free"] ? - -no -~~~~~ - - -*/ - -/** @pred split(+ _Line_,- _Split_) - - -Unify _Words_ with a set of strings obtained from _Line_ by -using the blank characters as separators. - - -*/ - -/** @pred fields(+ _Line_,+ _Separators_,- _Split_) - - - -Unify _Words_ with a set of strings obtained from _Line_ by -using the character codes in _Separators_ as separators for -fields. If two separators occur in a row, the field is considered -empty. As an example, consider: - -~~~~~{.prolog} -?- fields("Hello I am free"," *",S). - -S = ["Hello","","I","am","","free"] ? -~~~~~ - - -*/ - -/** @pred fields(+ _Line_,- _Split_) - - -Unify _Words_ with a set of strings obtained from _Line_ by -using the blank characters as field separators. - - -*/ - -/** @pred glue(+ _Words_,+ _Separator_,- _Line_) - - - -Unify _Line_ with string obtained by glueing _Words_ with -the character code _Separator_. - - -*/ - -/** @pred copy_line(+ _StreamInput_,+ _StreamOutput_) - - - -Copy a line from _StreamInput_ to _StreamOutput_. - - -*/ - -/** @pred process(+ _StreamInp_, + _Goal_) - - - -For every line _LineIn_ in stream _StreamInp_, call -`call(Goal,LineIn)`. - - -*/ - -/** @pred filter(+ _StreamInp_, + _StreamOut_, + _Goal_) - - - -For every line _LineIn_ in stream _StreamInp_, execute -`call(Goal,LineIn,LineOut)`, and output _LineOut_ to -stream _StreamOut_. - - -*/ - -/** @pred file_filter(+ _FileIn_, + _FileOut_, + _Goal_) - - - -For every line _LineIn_ in file _FileIn_, execute -`call(Goal,LineIn,LineOut)`, and output _LineOut_ to file - _FileOut_. - - -*/ - -/** @pred file_filter_with_initialization(+ _FileIn_, + _FileOut_, + _Goal_, + _FormatCommand_, + _Arguments_) - - -Same as file_filter/3, but before starting the filter execute -`format/3` on the output stream, using _FormatCommand_ and - _Arguments_. - - - - - */ - -/** @defgroup matrix Matrix Library -@ingroup YAPLibrary -@{ - -This package provides a fast implementation of multi-dimensional -matrices of integers and floats. In contrast to dynamic arrays, these -matrices are multi-dimensional and compact. In contrast to static -arrays. these arrays are allocated in the stack. Matrices are available -by loading the library `library(matrix)`. They are multimensional -objects of type: - -+ terms: Prolog terms -+ ints: bounded integers, represented as an opaque term. The -maximum integer depends on hardware, but should be obtained from the -natural size of the machine. -+ floats: floating-poiny numbers, represented as an opaque term. - - -Matrix elements can be accessed through the `matrix_get/2` -predicate or through an R-inspired access notation (that uses the ciao -style extension to `[]`. Examples include: - - -+ Access the second row, third column of matrix X. Indices start from -`0`, -~~~~ - _E_ <== _X_[2,3] -~~~~ - -+ Access all the second row, the output is a list ofe elements. -~~~~ - _L_ <== _X_[2,_] -~~~~ - -+ Access all the second, thrd and fourth rows, the output is a list of elements. -~~~~ - _L_ <== _X_[2..4,_] -~~~~ - -+ Access all the fifth, sixth and eight rows, the output is a list of elements. -~~~~ - _L_ <== _X_[2..4+3,_] -~~~~ - -The matrix library also supports a B-Prolog/ECliPSe inspired `foreach`iterator to iterate over -elements of a matrix: - -+ Copy a vector, element by element. - -~~~~ - foreach(I in 0..N1, X[I] <== Y[I]) -~~~~ - -+ The lower-triangular matrix _Z_ is the difference between the -lower-triangular and upper-triangular parts of _X_. - -~~~~ - foreach([I in 0..N1, J in I..N1], Z[I,J] <== X[I,J] - X[I,J]) -~~~~ - -+ Add all elements of a matrix by using _Sum_ as an accumulator. - -~~~~ - foreach([I in 0..N1, J in 0..N1], plus(X[I,J]), 0, Sum) -~~~~ - - Notice that the library does not support all known matrix operations. Please -contact the YAP maintainers if you require extra functionality. - - - -+ _X_ = array[ _Dim1_,..., _Dimn_] of _Objects_ - The of/2 operator can be used to create a new array of - _Objects_. The objects supported are: - - + `Unbound Variable` - create an array of free variables - + `ints ` - create an array of integers - + `floats ` - create an array of floating-point numbers - + `_I_: _J_` - create an array with integers from _I_ to _J_ - + `[..]` - create an array from the values in a list - -The dimensions can be given as an integer, and the matrix will be -indexed `C`-style from `0..( _Max_-1)`, or can be given -as an interval ` _Base_.. _Limit_`. In the latter case, -matrices of integers and of floating-point numbers should have the same - _Base_ on every dimension. - - -*/ - -/** @pred ?_LHS_ <== ?_RHS_ is semidet - - -General matrix assignment operation. It evaluates the right-hand side -and then acts different according to the -left-hand side and to the matrix: - -+ if _LHS_ is part of an integer or floating-point matrix, -perform non-backtrackable assignment. -+ other unify left-hand side and right-hand size. - - -The right-hand side supports the following operators: - -+ `[]/2` - - written as _M_[ _Offset_]: obtain an element or list of elements -of matrix _M_ at offset _Offset_. - -+ `matrix/1` - - create a vector from a list - -+ `matrix/2` - - create a matrix from a list. Options are: - + dim= -a list of dimensions - + type= -integers, floating-point or terms - + base= -a list of base offsets per dimension (all must be the same for arrays of -integers and floating-points - -+ `matrix/3` - - create matrix giving two options - - + `dim/1` - list with matrix dimensions - - + `nrow/1` - number of rows in bi-dimensional matrix - -+ `ncol/1` - number of columns in bi-dimensional matrix - -+ `length/1` - size of a matrix - -+ `size/1` - size of a matrix - -+ `max/1` - - maximum element of a numeric matrix - -+ `maxarg/1` - - argument of maximum element of a numeric matrix - -+ `min/1` - - minimum element of a numeric matrix - -+ `minarg/1` - - argument of minimum element of a numeric matrix - -+ `list/1` - - represent matrix as a list - -+ `lists/2` - - represent matrix as list of embedded lists - -+ `../2` - - _I_.. _J_ generates a list with all integers from _I_ to - _J_, included. - -+ `+/2` - - add two numbers, add two matrices element-by-element, or add a number to -all elements of a matrix or list. - -+ `-/2 ` - - subtract two numbers, subtract two matrices or lists element-by-element, or subtract a number from -all elements of a matrix or list - -+ `* /2` - - multiply two numbers, multiply two matrices or lists element-by-element, or multiply a number from -all elements of a matrix or list - - + `log/1` - - natural logarithm of a number, matrix or list - -+ `exp/1 ` - - natural exponentiation of a number, matrix or list - -*/ - -/** @pred foreach( _Sequence_, _Goal_) - - -Deterministic iterator. The ranges are given by _Sequence_ that is -either ` _I_ in _M_.. _N_`, or of the form -`[ _I_, _J_] ins _M_.. _N_`, or a list of the above conditions. - -Variables in the goal are assumed to be global, ie, share a single value -in the execution. The exceptions are the iteration indices. Moreover, if -the goal is of the form ` _Locals_^ _G_` all variables -occurring in _Locals_ are marked as local. As an example: - -~~~~~{.prolog} -foreach([I,J] ins 1..N, A^(A <==M[I,J], N[I] <== N[I] + A*A) ) -~~~~~ -the variables _I_, _J_ and _A_ are duplicated for every -call (local), whereas the matrices _M_ and _N_ are shared -throughout the execution (global). - - -*/ - -/** @pred foreach( _Sequence_, _Goal_, _Acc0_, _AccF_) - -Deterministic iterator with accumulator style arguments. - - -*/ - -/** @pred matrix_new(+ _Type_,+ _Dims_,- _Matrix_) - - - -Create a new matrix _Matrix_ of type _Type_, which may be one of -`ints` or `floats`, and with a list of dimensions _Dims_. -The matrix will be initialised to zeros. - -~~~~~ -?- matrix_new(ints,[2,3],Matrix). - -Matrix = {..} -~~~~~ -Notice that currently YAP will always write a matrix of numbers as `{..}`. - - -*/ - -/** @pred matrix_new(+ _Type_,+ _Dims_,+ _List_,- _Matrix_) - - -Create a new matrix _Matrix_ of type _Type_, which may be one of -`ints` or `floats`, with dimensions _Dims_, and -initialised from list _List_. - - -*/ - -/** @pred matrix_new_set(? _Dims_,+ _OldMatrix_,+ _Value_,- _NewMatrix_) - - - -Create a new matrix _NewMatrix_ of type _Type_, with dimensions - _Dims_. The elements of _NewMatrix_ are set to _Value_. - - -*/ - -/** @pred matrix_dims(+ _Matrix_,- _Dims_) - - - -Unify _Dims_ with a list of dimensions for _Matrix_. - - -*/ - -/** @pred matrix_ndims(+ _Matrix_,- _Dims_) - - - -Unify _NDims_ with the number of dimensions for _Matrix_. - - -*/ - -/** @pred matrix_size(+ _Matrix_,- _NElems_) - - - -Unify _NElems_ with the number of elements for _Matrix_. - - -*/ - -/** @pred matrix_type(+ _Matrix_,- _Type_) - - - -Unify _NElems_ with the type of the elements in _Matrix_. - - -*/ - -/** @pred matrix_to_list(+ _Matrix_,- _Elems_) - - - -Unify _Elems_ with the list including all the elements in _Matrix_. - - -*/ - -/** @pred matrix_get(+ _Matrix_,+ _Position_,- _Elem_) - - - -Unify _Elem_ with the element of _Matrix_ at position - _Position_. - - -*/ - -/** @pred matrix_get(+ _Matrix_[+ _Position_],- _Elem_) - - -Unify _Elem_ with the element _Matrix_[ _Position_]. - - -*/ - -/** @pred matrix_set(+ _Matrix_,+ _Position_,+ _Elem_) - - - -Set the element of _Matrix_ at position - _Position_ to _Elem_. - - -*/ - -/** @pred matrix_set(+ _Matrix_[+ _Position_],+ _Elem_) - - -Set the element of _Matrix_[ _Position_] to _Elem_. - - -*/ - -/** @pred matrix_set_all(+ _Matrix_,+ _Elem_) - - - -Set all element of _Matrix_ to _Elem_. - - -*/ - -/** @pred matrix_add(+ _Matrix_,+ _Position_,+ _Operand_) - - - -Add _Operand_ to the element of _Matrix_ at position - _Position_. - - -*/ - -/** @pred matrix_inc(+ _Matrix_,+ _Position_) - - - -Increment the element of _Matrix_ at position _Position_. - - -*/ - -/** @pred matrix_inc(+ _Matrix_,+ _Position_,- _Element_) - - -Increment the element of _Matrix_ at position _Position_ and -unify with _Element_. - - -*/ - -/** @pred matrix_dec(+ _Matrix_,+ _Position_) - - - -Decrement the element of _Matrix_ at position _Position_. - - -*/ - -/** @pred matrix_dec(+ _Matrix_,+ _Position_,- _Element_) - - -Decrement the element of _Matrix_ at position _Position_ and -unify with _Element_. - - -*/ - -/** @pred matrix_arg_to_offset(+ _Matrix_,+ _Position_,- _Offset_) - - - -Given matrix _Matrix_ return what is the numerical _Offset_ of -the element at _Position_. - - -*/ - -/** @pred matrix_offset_to_arg(+ _Matrix_,- _Offset_,+ _Position_) - - - -Given a position _Position _ for matrix _Matrix_ return the -corresponding numerical _Offset_ from the beginning of the matrix. - - -*/ - -/** @pred matrix_max(+ _Matrix_,+ _Max_) - - - -Unify _Max_ with the maximum in matrix _Matrix_. - - -*/ - -/** @pred matrix_maxarg(+ _Matrix_,+ _Maxarg_) - - - -Unify _Max_ with the position of the maximum in matrix _Matrix_. - - -*/ - -/** @pred matrix_min(+ _Matrix_,+ _Min_) - - - -Unify _Min_ with the minimum in matrix _Matrix_. - - -*/ - -/** @pred matrix_minarg(+ _Matrix_,+ _Minarg_) - - - -Unify _Min_ with the position of the minimum in matrix _Matrix_. - - -*/ - -/** @pred matrix_sum(+ _Matrix_,+ _Sum_) - - - -Unify _Sum_ with the sum of all elements in matrix _Matrix_. - - -*/ - -/** @pred matrix_agg_lines(+ _Matrix_,+Operator,+ _Aggregate_) - - - -If _Matrix_ is a n-dimensional matrix, unify _Aggregate_ with -the n-1 dimensional matrix where each element is obtained by adding all -_Matrix_ elements with same last n-1 index. Currently, only addition is supported. - - -*/ - -/** @pred matrix_agg_cols(+ _Matrix_,+Operator,+ _Aggregate_) - - - -If _Matrix_ is a n-dimensional matrix, unify _Aggregate_ with -the one dimensional matrix where each element is obtained by adding all -Matrix elements with same first index. Currently, only addition is supported. - - -*/ - -/** @pred matrix_op(+ _Matrix1_,+ _Matrix2_,+ _Op_,- _Result_) - - - - _Result_ is the result of applying _Op_ to matrix _Matrix1_ -and _Matrix2_. Currently, only addition (`+`) is supported. - - -*/ - -/** @pred matrix_op_to_all(+ _Matrix1_,+ _Op_,+ _Operand_,- _Result_) - - - - _Result_ is the result of applying _Op_ to all elements of - _Matrix1_, with _Operand_ as the second argument. Currently, -only addition (`+`), multiplication (`\*`), and division -(`/`) are supported. - - -*/ - -/** @pred matrix_op_to_lines(+ _Matrix1_,+ _Lines_,+ _Op_,- _Result_) - - - - _Result_ is the result of applying _Op_ to all elements of - _Matrix1_, with the corresponding element in _Lines_ as the -second argument. Currently, only division (`/`) is supported. - - -*/ - -/** @pred matrix_op_to_cols(+ _Matrix1_,+ _Cols_,+ _Op_,- _Result_) - - - - _Result_ is the result of applying _Op_ to all elements of - _Matrix1_, with the corresponding element in _Cols_ as the -second argument. Currently, only addition (`+`) is -supported. Notice that _Cols_ will have n-1 dimensions. - - -*/ - -/** @pred matrix_shuffle(+ _Matrix_,+ _NewOrder_,- _Shuffle_) - - - -Shuffle the dimensions of matrix _Matrix_ according to - _NewOrder_. The list _NewOrder_ must have all the dimensions of - _Matrix_, starting from 0. - - -*/ - -/** @pred matrix_transpose(+ _Matrix_,- _Transpose_) - - - -Transpose matrix _Matrix_ to _Transpose_. Equivalent to: - -~~~~~ -matrix_transpose(Matrix,Transpose) :- - matrix_shuffle(Matrix,[1,0],Transpose). -~~~~~ - - -*/ - -/** @pred matrix_expand(+ _Matrix_,+ _NewDimensions_,- _New_) - - - -Expand _Matrix_ to occupy new dimensions. The elements in - _NewDimensions_ are either 0, for an existing dimension, or a -positive integer with the size of the new dimension. - - -*/ - -/** @pred matrix_select(+ _Matrix_,+ _Dimension_,+ _Index_,- _New_) - - - -Select from _Matrix_ the elements who have _Index_ at - _Dimension_. - - -*/ - -/** @pred matrix_column(+ _Matrix_,+ _Column_,- _NewMatrix_) - - - -Select from _Matrix_ the column matching _Column_ as new matrix _NewMatrix_. _Column_ must have one less dimension than the original matrix. - - - - */ - -/** @defgroup MATLAB MATLAB Package Interface -@ingroup YAPLibrary -@{ - -The MathWorks MATLAB is a widely used package for array -processing. YAP now includes a straightforward interface to MATLAB. To -actually use it, you need to install YAP calling `configure` with -the `--with-matlab=DIR` option, and you need to call -`use_module(library(lists))` command. - -Accessing the matlab dynamic libraries can be complicated. In Linux -machines, to use this interface, you may have to set the environment -variable LD_LIBRARY_PATH. Next, follows an example using bash in a -64-bit Linux PC: - -~~~~~ -export LD_LIBRARY_PATH=''$MATLAB_HOME"/sys/os/glnxa64:''$MATLAB_HOME"/bin/glnxa64:''$LD_LIBRARY_PATH" -~~~~~ -where `MATLAB_HOME` is the directory where matlab is installed -at. Please replace `ax64` for `x86` on a 32-bit PC. - - - - @pred start_matlab(+ _Options_) - - -Start a matlab session. The argument _Options_ may either be the -empty string/atom or the command to call matlab. The command may fail. - - -*/ - -/** @pred close_matlab - - -Stop the current matlab session. - - -*/ - -/** @pred matlab_on - - -Holds if a matlab session is on. - - -*/ - -/** @pred matlab_eval_string(+ _Command_) - - -Holds if matlab evaluated successfully the command _Command_. - - -*/ - -/** @pred matlab_eval_string(+ _Command_, - _Answer_) - -MATLAB will evaluate the command _Command_ and unify _Answer_ -with a string reporting the result. - - -*/ - -/** @pred matlab_cells(+ _Size_, ? _Array_) - - -MATLAB will create an empty vector of cells of size _Size_, and if - _Array_ is bound to an atom, store the array in the matlab -variable with name _Array_. Corresponds to the MATLAB command `cells`. - - -*/ - -/** @pred matlab_cells(+ _SizeX_, + _SizeY_, ? _Array_) - -MATLAB will create an empty array of cells of size _SizeX_ and - _SizeY_, and if _Array_ is bound to an atom, store the array -in the matlab variable with name _Array_. Corresponds to the -MATLAB command `cells`. - - -*/ - -/** @pred matlab_initialized_cells(+ _SizeX_, + _SizeY_, + _List_, ? _Array_) - - -MATLAB will create an array of cells of size _SizeX_ and - _SizeY_, initialized from the list _List_, and if _Array_ -is bound to an atom, store the array in the matlab variable with name - _Array_. - - -*/ - -/** @pred matlab_matrix(+ _SizeX_, + _SizeY_, + _List_, ? _Array_) - - -MATLAB will create an array of floats of size _SizeX_ and _SizeY_, -initialized from the list _List_, and if _Array_ is bound to -an atom, store the array in the matlab variable with name _Array_. - - -*/ - -/** @pred matlab_set(+ _MatVar_, + _X_, + _Y_, + _Value_) - - -Call MATLAB to set element _MatVar_( _X_, _Y_) to - _Value_. Notice that this command uses the MATLAB array access -convention. - - -*/ - -/** @pred matlab_get_variable(+ _MatVar_, - _List_) - - -Unify MATLAB variable _MatVar_ with the List _List_. - - -*/ - -/** @pred matlab_item(+ _MatVar_, + _X_, ? _Val_) - - -Read or set MATLAB _MatVar_( _X_) from/to _Val_. Use -`C` notation for matrix access (ie, starting from 0). - - -*/ - -/** @pred matlab_item(+ _MatVar_, + _X_, + _Y_, ? _Val_) - -Read or set MATLAB _MatVar_( _X_, _Y_) from/to _Val_. Use -`C` notation for matrix access (ie, starting from 0). - - -*/ - -/** @pred matlab_item1(+ _MatVar_, + _X_, ? _Val_) - - -Read or set MATLAB _MatVar_( _X_) from/to _Val_. Use -MATLAB notation for matrix access (ie, starting from 1). - - -*/ - -/** @pred matlab_item1(+ _MatVar_, + _X_, + _Y_, ? _Val_) - -Read or set MATLAB _MatVar_( _X_, _Y_) from/to _Val_. Use -MATLAB notation for matrix access (ie, starting from 1). - - -*/ - -/** @pred matlab_sequence(+ _Min_, + _Max_, ? _Array_) - - -MATLAB will create a sequence going from _Min_ to _Max_, and -if _Array_ is bound to an atom, store the sequence in the matlab -variable with name _Array_. - - -*/ - -/** @pred matlab_vector(+ _Size_, + _List_, ? _Array_) - - -MATLAB will create a vector of floats of size _Size_, initialized -from the list _List_, and if _Array_ is bound to an atom, -store the array in the matlab variable with name _Array_. - - -*/ - -/** @pred matlab_zeros(+ _Size_, ? _Array_) - - -MATLAB will create a vector of zeros of size _Size_, and if - _Array_ is bound to an atom, store the array in the matlab -variable with name _Array_. Corresponds to the MATLAB command -`zeros`. - - -*/ - -/** @pred matlab_zeros(+ _SizeX_, + _SizeY_, ? _Array_) - -MATLAB will create an array of zeros of size _SizeX_ and - _SizeY_, and if _Array_ is bound to an atom, store the array -in the matlab variable with name _Array_. Corresponds to the -MATLAB command `zeros`. - - -*/ - -/** @pred matlab_zeros(+ _SizeX_, + _SizeY_, + _SizeZ_, ? _Array_) - -MATLAB will create an array of zeros of size _SizeX_, _SizeY_, -and _SizeZ_. If _Array_ is bound to an atom, store the array -in the matlab variable with name _Array_. Corresponds to the -MATLAB command `zeros`. - - - - - */ - -/** @defgroup NonhYBacktrackable_Data_Structures Non-Backtrackable Data Structures -@ingroup YAPLibrary -@{ - -The following routines implement well-known data-structures using global -non-backtrackable variables (implemented on the Prolog stack). The -data-structures currently supported are Queues, Heaps, and Beam for Beam -search. They are allowed through `library(nb)`. - - -*/ - -/** @pred nb_queue(- _Queue_) - - -Create a _Queue_. - - -*/ - -/** @pred nb_queue_close(+ _Queue_, - _Head_, ? _Tail_) - - -Unify the queue _Queue_ with a difference list - _Head_- _Tail_. The queue will now be empty and no further -elements can be added. - - -*/ - -/** @pred nb_queue_enqueue(+ _Queue_, + _Element_) - - -Add _Element_ to the front of the queue _Queue_. - - -*/ - -/** @pred nb_queue_dequeue(+ _Queue_, - _Element_) - - -Remove _Element_ from the front of the queue _Queue_. Fail if -the queue is empty. - - -*/ - -/** @pred nb_queue_peek(+ _Queue_, - _Element_) - - - _Element_ is the front of the queue _Queue_. Fail if -the queue is empty. - - -*/ - -/** @pred nb_queue_size(+ _Queue_, - _Size_) - - -Unify _Size_ with the number of elements in the queue _Queue_. - - -*/ - -/** @pred nb_queue_empty(+ _Queue_) - - -Succeeds if _Queue_ is empty. - - -*/ - -/** @pred nb_heap(+ _DefaultSize_,- _Heap_) - - -Create a _Heap_ with default size _DefaultSize_. Note that size -will expand as needed. - - -*/ - -/** @pred nb_heap_close(+ _Heap_) - - -Close the heap _Heap_: no further elements can be added. - - -*/ - -/** @pred nb_heap_add(+ _Heap_, + _Key_, + _Value_) - - -Add _Key_- _Value_ to the heap _Heap_. The key is sorted on - _Key_ only. - - -*/ - -/** @pred nb_heap_del(+ _Heap_, - _Key_, - _Value_) - - -Remove element _Key_- _Value_ with smallest _Value_ in heap - _Heap_. Fail if the heap is empty. - - -*/ - -/** @pred nb_heap_peek(+ _Heap_, - _Key_, - _Value_)) - - - _Key_- _Value_ is the element with smallest _Key_ in the heap - _Heap_. Fail if the heap is empty. - - -*/ - -/** @pred nb_heap_size(+ _Heap_, - _Size_) - - -Unify _Size_ with the number of elements in the heap _Heap_. - - -*/ - -/** @pred nb_heap_empty(+ _Heap_) - - -Succeeds if _Heap_ is empty. - - -*/ - -/** @pred nb_beam(+ _DefaultSize_,- _Beam_) - - -Create a _Beam_ with default size _DefaultSize_. Note that size -is fixed throughout. - - -*/ - -/** @pred nb_beam_close(+ _Beam_) - - -Close the beam _Beam_: no further elements can be added. - - -*/ - -/** @pred nb_beam_add(+ _Beam_, + _Key_, + _Value_) - - -Add _Key_- _Value_ to the beam _Beam_. The key is sorted on - _Key_ only. - - -*/ - -/** @pred nb_beam_del(+ _Beam_, - _Key_, - _Value_) - - -Remove element _Key_- _Value_ with smallest _Value_ in beam - _Beam_. Fail if the beam is empty. - - -*/ - -/** @pred nb_beam_peek(+ _Beam_, - _Key_, - _Value_)) - - - _Key_- _Value_ is the element with smallest _Key_ in the beam - _Beam_. Fail if the beam is empty. - - -*/ - -/** @pred nb_beam_size(+ _Beam_, - _Size_) - - -Unify _Size_ with the number of elements in the beam _Beam_. - - -*/ - -/** @pred nb_beam_empty(+ _Beam_) - - -Succeeds if _Beam_ is empty. - - - - - */ - -/** @defgroup Ordered_Sets Ordered Sets -@ingroup YAPLibrary -@{ - -The following ordered set manipulation routines are available once -included with the `use_module(library(ordsets))` command. An -ordered set is represented by a list having unique and ordered -elements. Output arguments are guaranteed to be ordered sets, if the -relevant inputs are. This is a slightly patched version of Richard -O'Keefe's original library. - - -*/ - -/** @pred list_to_ord_set(+ _List_, ? _Set_) - - -Holds when _Set_ is the ordered representation of the set -represented by the unordered representation _List_. - - -*/ - -/** @pred merge(+ _List1_, + _List2_, - _Merged_) - - -Holds when _Merged_ is the stable merge of the two given lists. - -Notice that merge/3 will not remove duplicates, so merging -ordered sets will not necessarily result in an ordered set. Use -`ord_union/3` instead. - - -*/ - -/** @pred ord_add_element(+ _Set1_, + _Element_, ? _Set2_) - - -Inserting _Element_ in _Set1_ returns _Set2_. It should give -exactly the same result as `merge(Set1, [Element], Set2)`, but a -bit faster, and certainly more clearly. The same as ord_insert/3. - - -*/ - -/** @pred ord_del_element(+ _Set1_, + _Element_, ? _Set2_) - - -Removing _Element_ from _Set1_ returns _Set2_. - - -*/ - -/** @pred ord_disjoint(+ _Set1_, + _Set2_) - - -Holds when the two ordered sets have no element in common. - - -*/ - -/** @pred ord_member(+ _Element_, + _Set_) - - -Holds when _Element_ is a member of _Set_. - - -*/ - -/** @pred ord_insert(+ _Set1_, + _Element_, ? _Set2_) - - -Inserting _Element_ in _Set1_ returns _Set2_. It should give -exactly the same result as `merge(Set1, [Element], Set2)`, but a -bit faster, and certainly more clearly. The same as ord_add_element/3. - - -*/ - -/** @pred ord_intersect(+ _Set1_, + _Set2_) - - -Holds when the two ordered sets have at least one element in common. - - -*/ - -/** @pred ord_intersection(+ _Set1_, + _Set2_, ? _Intersection_) - -Holds when Intersection is the ordered representation of _Set1_ -and _Set2_. - - -*/ - -/** @pred ord_intersection(+ _Set1_, + _Set2_, ? _Intersection_, ? _Diff_) - -Holds when Intersection is the ordered representation of _Set1_ -and _Set2_. _Diff_ is the difference between _Set2_ and _Set1_. - - -*/ - -/** @pred ord_seteq(+ _Set1_, + _Set2_) - - -Holds when the two arguments represent the same set. - - -*/ - -/** @pred ord_setproduct(+ _Set1_, + _Set2_, - _Set_) - - -If Set1 and Set2 are ordered sets, Product will be an ordered -set of x1-x2 pairs. - - -*/ - -/** @pred ord_subset(+ _Set1_, + _Set2_) - - -Holds when every element of the ordered set _Set1_ appears in the -ordered set _Set2_. - - -*/ - -/** @pred ord_subtract(+ _Set1_, + _Set2_, ? _Difference_) - - -Holds when _Difference_ contains all and only the elements of _Set1_ -which are not also in _Set2_. - - -*/ - -/** @pred ord_symdiff(+ _Set1_, + _Set2_, ? _Difference_) - - -Holds when _Difference_ is the symmetric difference of _Set1_ -and _Set2_. - - -*/ - -/** @pred ord_union(+ _Sets_, ? _Union_) - - -Holds when _Union_ is the union of the lists _Sets_. - - -*/ - -/** @pred ord_union(+ _Set1_, + _Set2_, ? _Union_) - -Holds when _Union_ is the union of _Set1_ and _Set2_. - - -*/ - -/** @pred ord_union(+ _Set1_, + _Set2_, ? _Union_, ? _Diff_) - -Holds when _Union_ is the union of _Set1_ and _Set2_ and - _Diff_ is the difference. - - - - - */ - -/** @defgroup Pseudo_Random Pseudo Random Number Integer Generator -@ingroup YAPLibrary -@{ - -The following routines produce random non-negative integers in the range -0 .. 2^(w-1) -1, where w is the word size available for integers, e.g. -32 for Intel machines and 64 for Alpha machines. Note that the numbers -generated by this random number generator are repeatable. This generator -was originally written by Allen Van Gelder and is based on Knuth Vol 2. - - -*/ - -/** @pred rannum(- _I_) - - -Produces a random non-negative integer _I_ whose low bits are not -all that random, so it should be scaled to a smaller range in general. -The integer _I_ is in the range 0 .. 2^(w-1) - 1. You can use: - -~~~~~ -rannum(X) :- yap_flag(max_integer,MI), rannum(R), X is R/MI. -~~~~~ -to obtain a floating point number uniformly distributed between 0 and 1. - - -*/ - -/** @pred ranstart - - -Initialize the random number generator using a built-in seed. The -ranstart/0 built-in is always called by the system when loading -the package. - - -*/ - -/** @pred ranstart(+ _Seed_) - -Initialize the random number generator with user-defined _Seed_. The -same _Seed_ always produces the same sequence of numbers. - - -*/ - -/** @pred ranunif(+ _Range_,- _I_) - - -ranunif/2 produces a uniformly distributed non-negative random -integer _I_ over a caller-specified range _R_. If range is _R_, -the result is in 0 .. _R_-1. - - - - - */ - -/** @defgroup Queues Queues -@ingroup YAPLibrary -@{ - -The following queue manipulation routines are available once -included with the `use_module(library(queues))` command. Queues are -implemented with difference lists. - - - - @pred make_queue(+ _Queue_) - - -Creates a new empty queue. It should only be used to create a new queue. - - -*/ - -/** @pred join_queue(+ _Element_, + _OldQueue_, - _NewQueue_) - - -Adds the new element at the end of the queue. - - -*/ - -/** @pred list_join_queue(+ _List_, + _OldQueue_, - _NewQueue_) - - -Ads the new elements at the end of the queue. - - -*/ - -/** @pred jump_queue(+ _Element_, + _OldQueue_, - _NewQueue_) - - -Adds the new element at the front of the list. - - -*/ - -/** @pred list_jump_queue(+ _List_, + _OldQueue_, + _NewQueue_) - - -Adds all the elements of _List_ at the front of the queue. - - -*/ - -/** @pred head_queue(+ _Queue_, ? _Head_) - - -Unifies Head with the first element of the queue. - - -*/ - -/** @pred serve_queue(+ _OldQueue_, + _Head_, - _NewQueue_) - - -Removes the first element of the queue for service. - - -*/ - -/** @pred empty_queue(+ _Queue_) - - -Tests whether the queue is empty. - - -*/ - -/** @pred length_queue(+ _Queue_, - _Length_) - - -Counts the number of elements currently in the queue. - - -*/ - -/** @pred list_to_queue(+ _List_, - _Queue_) - - -Creates a new queue with the same elements as _List._ - - -*/ - -/** @pred queue_to_list(+ _Queue_, - _List_) - - -Creates a new list with the same elements as _Queue_. - - - - - */ - -/** @defgroup Random Random Number Generator -@ingroup YAPLibrary -@{ - -The following random number operations are included with the -`use_module(library(random))` command. Since YAP-4.3.19 YAP uses -the O'Keefe public-domain algorithm, based on the "Applied Statistics" -algorithm AS183. - - - - @pred getrand(- _Key_) - - -Unify _Key_ with a term of the form `rand(X,Y,Z)` describing the -current state of the random number generator. - - -*/ - -/** @pred random(- _Number_) - - -Unify _Number_ with a floating-point number in the range `[0...1)`. - - -*/ - -/** @pred random(+ _LOW_, + _HIGH_, - _NUMBER_) - -Unify _Number_ with a number in the range -`[LOW...HIGH)`. If both _LOW_ and _HIGH_ are -integers then _NUMBER_ will also be an integer, otherwise - _NUMBER_ will be a floating-point number. - - -*/ - -/** @pred randseq(+ _LENGTH_, + _MAX_, - _Numbers_) - - -Unify _Numbers_ with a list of _LENGTH_ unique random integers -in the range `[1... _MAX_)`. - - -*/ - -/** @pred randset(+ _LENGTH_, + _MAX_, - _Numbers_) - - -Unify _Numbers_ with an ordered list of _LENGTH_ unique random -integers in the range `[1... _MAX_)`. - - -*/ - -/** @pred setrand(+ _Key_) - - -Use a term of the form `rand(X,Y,Z)` to set a new state for the -random number generator. The integer `X` must be in the range -`[1...30269)`, the integer `Y` must be in the range -`[1...30307)`, and the integer `Z` must be in the range -`[1...30323)`. - - - - - */ - -/** @defgroup Read_Utilities Read Utilities -@ingroup YAPLibrary -@{ - -The `readutil` library contains primitives to read lines, files, -multiple terms, etc. - - -*/ - -/** @pred read_line_to_codes(+ _Stream_, - _Codes_) - - - -Read the next line of input from _Stream_ and unify the result with - _Codes_ after the line has been read. A line is ended by a -newline character or end-of-file. Unlike `read_line_to_codes/3`, -this predicate removes trailing newline character. - -On end-of-file the atom `end_of_file` is returned. See also -`at_end_of_stream/[0,1]`. - - -*/ - -/** @pred read_line_to_codes(+ _Stream_, - _Codes_, ? _Tail_) - -Difference-list version to read an input line to a list of character -codes. Reading stops at the newline or end-of-file character, but -unlike read_line_to_codes/2, the newline is retained in the -output. This predicate is especially useful for reading a block of -lines upto some delimiter. The following example reads an HTTP header -ended by a blank line: - -~~~~~ -read_header_data(Stream, Header) :- - read_line_to_codes(Stream, Header, Tail), - read_header_data(Header, Stream, Tail). - -read_header_data("\r\n", _, _) :- !. -read_header_data("\n", _, _) :- !. -read_header_data("", _, _) :- !. -read_header_data(_, Stream, Tail) :- - read_line_to_codes(Stream, Tail, NewTail), - read_header_data(Tail, Stream, NewTail). -~~~~~ - - -*/ - -/** @pred read_stream_to_codes(+ _Stream_, - _Codes_) - - -Read all input until end-of-file and unify the result to _Codes_. - - -*/ - -/** @pred read_stream_to_codes(+ _Stream_, - _Codes_, ? _Tail_) - -Difference-list version of read_stream_to_codes/2. - - -*/ - -/** @pred read_file_to_codes(+ _Spec_, - _Codes_, + _Options_) - - -Read a file to a list of character codes. Currently ignores - _Options_. - - -*/ - -/** @pred read_file_to_terms(+ _Spec_, - _Terms_, + _Options_) - - -Read a file to a list of Prolog terms (see read/1). @c _Spec_ is a - - - - - - - - - - */ - -/** @defgroup RedhYBlack_Trees Red-Black Trees -@ingroup YAPLibrary -@{ - -Red-Black trees are balanced search binary trees. They are named because -nodes can be classified as either red or black. The code we include is -based on "Introduction to Algorithms", second edition, by Cormen, -Leiserson, Rivest and Stein. The library includes routines to insert, -lookup and delete elements in the tree. - - -*/ - -/** @pred rb_new(? _T_) - - -Create a new tree. - - -*/ - -/** @pred rb_empty(? _T_) - - -Succeeds if tree _T_ is empty. - - -*/ - -/** @pred is_rbtree(+ _T_) - - -Check whether _T_ is a valid red-black tree. - - -*/ - -/** @pred rb_insert(+ _T0_,+ _Key_,? _Value_,+ _TF_) - - -Add an element with key _Key_ and _Value_ to the tree - _T0_ creating a new red-black tree _TF_. Duplicated elements are not -allowed. - -Add a new element with key _Key_ and _Value_ to the tree - _T0_ creating a new red-black tree _TF_. Fails is an element -with _Key_ exists in the tree. - - -*/ - -/** @pred rb_lookup(+ _Key_,- _Value_,+ _T_) - - -Backtrack through all elements with key _Key_ in the red-black tree - _T_, returning for each the value _Value_. - - -*/ - -/** @pred rb_lookupall(+ _Key_,- _Value_,+ _T_) - - -Lookup all elements with key _Key_ in the red-black tree - _T_, returning the value _Value_. - - -*/ - -/** @pred rb_delete(+ _T_,+ _Key_,- _TN_) - - -Delete element with key _Key_ from the tree _T_, returning a new -tree _TN_. - - -*/ - -/** @pred rb_delete(+ _T_,+ _Key_,- _Val_,- _TN_) - -Delete element with key _Key_ from the tree _T_, returning the -value _Val_ associated with the key and a new tree _TN_. - - -*/ - -/** @pred rb_del_min(+ _T_,- _Key_,- _Val_,- _TN_) - - -Delete the least element from the tree _T_, returning the key - _Key_, the value _Val_ associated with the key and a new tree - _TN_. - - -*/ - -/** @pred rb_del_max(+ _T_,- _Key_,- _Val_,- _TN_) - - -Delete the largest element from the tree _T_, returning the key - _Key_, the value _Val_ associated with the key and a new tree - _TN_. - - -*/ - -/** @pred rb_update(+ _T_,+ _Key_,+ _NewVal_,- _TN_) - - -Tree _TN_ is tree _T_, but with value for _Key_ associated -with _NewVal_. Fails if it cannot find _Key_ in _T_. - - -*/ - -/** @pred rb_apply(+ _T_,+ _Key_,+ _G_,- _TN_) - - -If the value associated with key _Key_ is _Val0_ in _T_, and -if `call(G,Val0,ValF)` holds, then _TN_ differs from - _T_ only in that _Key_ is associated with value _ValF_ in -tree _TN_. Fails if it cannot find _Key_ in _T_, or if -`call(G,Val0,ValF)` is not satisfiable. - - -*/ - -/** @pred rb_visit(+ _T_,- _Pairs_) - - - _Pairs_ is an infix visit of tree _T_, where each element of - _Pairs_ is of the form _K_- _Val_. - - -*/ - -/** @pred rb_size(+ _T_,- _Size_) - - - _Size_ is the number of elements in _T_. - - -*/ - -/** @pred rb_keys(+ _T_,+ _Keys_) - - - _Keys_ is an infix visit with all keys in tree _T_. Keys will be -sorted, but may be duplicate. - - -*/ - -/** @pred rb_map(+ _T_,+ _G_,- _TN_) - - -For all nodes _Key_ in the tree _T_, if the value associated with -key _Key_ is _Val0_ in tree _T_, and if -`call(G,Val0,ValF)` holds, then the value associated with _Key_ -in _TN_ is _ValF_. Fails if or if `call(G,Val0,ValF)` is not -satisfiable for all _Var0_. - - -*/ - -/** @pred rb_partial_map(+ _T_,+ _Keys_,+ _G_,- _TN_) - - -For all nodes _Key_ in _Keys_, if the value associated with key - _Key_ is _Val0_ in tree _T_, and if `call(G,Val0,ValF)` -holds, then the value associated with _Key_ in _TN_ is - _ValF_. Fails if or if `call(G,Val0,ValF)` is not satisfiable -for all _Var0_. Assumes keys are not repeated. - - -*/ - -/** @pred rb_fold(+ _T_,+ _G_,+ _Acc0_, - _AccF_) - - -For all nodes _Key_ in the tree _T_, if the value -associated with key _Key_ is _V_ in tree _T_, if -`call(G,V,Acc1,Acc2)` holds, then if _VL_ is value of the -previous node in inorder, `call(G,VL,_,Acc0)` must hold, and if - _VR_ is the value of the next node in inorder, -`call(G,VR,Acc1,_)` must hold. - - -*/ - -/** @pred rb_key_fold(+ _T_,+ _G_,+ _Acc0_, - _AccF_) - - -For all nodes _Key_ in the tree _T_, if the value -associated with key _Key_ is _V_ in tree _T_, if -`call(G,Key,V,Acc1,Acc2)` holds, then if _VL_ is value of the -previous node in inorder, `call(G,KeyL,VL,_,Acc0)` must hold, and if - _VR_ is the value of the next node in inorder, -`call(G,KeyR,VR,Acc1,_)` must hold. - - -*/ - -/** @pred rb_clone(+ _T_,+ _NT_,+ _Nodes_) - - -=Clone= the red-back tree into a new tree with the same keys as the -original but with all values set to unbound values. _Nodes_ is a list -containing all new nodes as pairs _K-V_. - - -*/ - -/** @pred rb_min(+ _T_,- _Key_,- _Value_) - - - _Key_ is the minimum key in _T_, and is associated with _Val_. - - -*/ - -/** @pred rb_max(+ _T_,- _Key_,- _Value_) - - - _Key_ is the maximal key in _T_, and is associated with _Val_. - - -*/ - -/** @pred rb_next(+ _T_, + _Key_,- _Next_,- _Value_) - - - _Next_ is the next element after _Key_ in _T_, and is -associated with _Val_. - - -*/ - -/** @pred rb_previous(+ _T_, + _Key_,- _Previous_,- _Value_) - - - _Previous_ is the previous element after _Key_ in _T_, and is -associated with _Val_. - - -*/ - -/** @pred ord_list_to_rbtree(+ _L_, - _T_) - - - _T_ is the red-black tree corresponding to the mapping in ordered -list _L_. - - - - */ - -/** @defgroup RegExp Regular Expressions -@ingroup YAPLibrary -@{ - -This library includes routines to determine whether a regular expression -matches part or all of a string. The routines can also return which -parts parts of the string matched the expression or subexpressions of -it. This library relies on Henry Spencer's `C`-package and is only -available in operating systems that support dynamic loading. The -`C`-code has been obtained from the sources of FreeBSD-4.0 and is -protected by copyright from Henry Spencer and from the Regents of the -University of California (see the file library/regex/COPYRIGHT for -further details). - -Much of the description of regular expressions below is copied verbatim -from Henry Spencer's manual page. - -A regular expression is zero or more branches, separated by ``|`. It -matches anything that matches one of the branches. - -A branch is zero or more pieces, concatenated. It matches a match for -the first, followed by a match for the second, etc. - -A piece is an atom possibly followed by `\*`, `+`, or `?`. An atom -followed by `\*` matches a sequence of 0 or more matches of the atom. -An atom followed by `+` matches a sequence of 1 or more matches of the -atom. An atom followed by `?` matches a match of the atom, or the -null string. - -An atom is a regular expression in parentheses (matching a match for the -regular expression), a range (see below), `.` (matching any single -character), `^` (matching the null string at the beginning of the -input string), `$` (matching the null string at the end of the input -string), a `\` followed by a single character (matching that -character), or a single character with no other significance (matching -that character). - -A range is a sequence of characters enclosed in `[]`. It normally -matches any single character from the sequence. If the sequence begins -with `^`, it matches any single character not from the rest of the -sequence. If two characters in the sequence are separated by `-`, -this is shorthand for the full list of ASCII characters between them -(e.g. `[0-9]` matches any decimal digit). To include a literal `]` -in the sequence, make it the first character (following a possible -`^`). To include a literal `-`, make it the first or last -character. - - - - @pred regexp(+ _RegExp_,+ _String_,+ _Opts_) - - - -Match regular expression _RegExp_ to input string _String_ -according to options _Opts_. The options may be: - -+ `nocase`: Causes upper-case characters in _String_ to -be treated as lower case during the matching process. - - - -*/ - -/** @pred regexp(+ _RegExp_,+ _String_,+ _Opts_,? _SubMatchVars_) - - -Match regular expression _RegExp_ to input string _String_ -according to options _Opts_. The variable _SubMatchVars_ should -be originally unbound or a list of unbound variables all will contain a -sequence of matches, that is, the head of _SubMatchVars_ will -contain the characters in _String_ that matched the leftmost -parenthesized subexpression within _RegExp_, the next head of list -will contain the characters that matched the next parenthesized -subexpression to the right in _RegExp_, and so on. - -The options may be: - -+ `nocase`: Causes upper-case characters in _String_ to -be treated as lower case during the matching process. -+ `indices`: Changes what is stored in - _SubMatchVars_. Instead of storing the matching characters from - _String_, each variable will contain a term of the form _IO-IF_ -giving the indices in _String_ of the first and last characters in -the matching range of characters. - - - -In general there may be more than one way to match a regular expression -to an input string. For example, consider the command - -~~~~~ - regexp("(a*)b*","aabaaabb", [], [X,Y]) -~~~~~ -Considering only the rules given so far, _X_ and _Y_ could end up -with the values `"aabb"` and `"aa"`, `"aaab"` and -`"aaa"`, `"ab"` and `"a"`, or any of several other -combinations. To resolve this potential ambiguity `regexp` chooses among -alternatives using the rule `first then longest`. In other words, it -considers the possible matches in order working from left to right -across the input string and the pattern, and it attempts to match longer -pieces of the input string before shorter ones. More specifically, the -following rules apply in decreasing order of priority: - -+ If a regular expression could match two different parts of an -input string then it will match the one that begins earliest. - -+ If a regular expression contains "|" operators then the leftmost matching sub-expression is chosen. - -+ In \*, +, and ? constructs, longer matches are chosen in preference to shorter ones. - -+ In sequences of expression components the components are considered from left to right. - -In the example above, `"(a\*)b\*"` matches `"aab"`: the -`"(a\*)"` portion of the pattern is matched first and it consumes -the leading `"aa"`; then the `"b\*"` portion of the pattern -consumes the next `"b"`. Or, consider the following example: - -~~~~~ - regexp("(ab|a)(b*)c", "abc", [], [X,Y,Z]) -~~~~~ - -After this command _X_ will be `"abc"`, _Y_ will be -`"ab"`, and _Z_ will be an empty string. Rule 4 specifies that -`"(ab|a)"` gets first shot at the input string and Rule 2 specifies -that the `"ab"` sub-expression is checked before the `"a"` -sub-expression. Thus the `"b"` has already been claimed before the -`"(b\*)"` component is checked and `(b\*)` must match an empty string. - - - - - */ - -/** @defgroup shlib SWI-Prolog's shlib library -@ingroup YAPLibrary -@{ - -This section discusses the functionality of the (autoload) -`library(shlib)`, providing an interface to manage shared -libraries. - -One of the files provides a global function `install_mylib()` that -initialises the module using calls to `PL_register_foreign()`. Here is a -simple example file `mylib.c`, which creates a Windows MessageBox: - -~~~~~{.c} -#include -#include - -static foreign_t -pl_say_hello(term_t to) -{ char *a; - - if ( PL_get_atom_chars(to, &a) ) - { MessageBox(NULL, a, "DLL test", MB_OK|MB_TASKMODAL); - - PL_succeed; - } - - PL_fail; -} - -install_t -install_mylib() -{ PL_register_foreign("say_hello", 1, pl_say_hello, 0); -} -~~~~~ - -Now write a file mylib.pl: - -~~~~~ -:- module(mylib, [ say_hello/1 ]). -:- use_foreign_library(foreign(mylib)). -~~~~~ - -The file mylib.pl can be loaded as a normal Prolog file and provides the predicate defined in C. - - -*/ - -/** @pred load_foreign_library(: _FileSpec_) is det - - - -*/ - -/** @pred load_foreign_library(: _FileSpec_, + _Entry_:atom) is det - -Load a shared object or DLL. After loading the _Entry_ function is -called without arguments. The default entry function is composed -from `install_`, followed by the file base-name. E.g., the -load-call below calls the function `install_mylib()`. If the platform -prefixes extern functions with `_`, this prefix is added before -calling. - -~~~~~ - ... - load_foreign_library(foreign(mylib)), - ... -~~~~~ - - _FileSpec_ is a specification for -absolute_file_name/3. If searching the file fails, the plain -name is passed to the OS to try the default method of the OS for -locating foreign objects. The default definition of -file_search_path/2 searches /lib/Yap. - -See also -`use_foreign_library/1,2` are intended for use in -directives. - - -*/ - -/** @pred use_foreign_library(+ _FileSpec_) is det - use_foreign_library(+ _FileSpec_, + _Entry_:atom) is det - - - -Load and install a foreign library as load_foreign_library/1 -and `load_foreign_library/2` and -register the installation using `initialization/2` with the option -now. This is similar to using: - -~~~~~ - :- initialization(load_foreign_library(foreign(mylib))). -~~~~~ - -but using the initialization/1 wrapper causes the library to -be loaded after loading of the file in which it appears is -completed, while use_foreign_library/1 loads the library -immediately. I.e. the difference is only relevant if the remainder -of the file uses functionality of the `C`-library. - - -*/ - -/** @pred unload_foreign_library(+ _FileSpec_) is det - -*/ - -/** @pred unload_foreign_library(+ _FileSpec_, + _Exit_:atom) is det - - - - -Unload a shared -object or DLL. After calling the _Exit_ function, the shared object is -removed from the process. The default exit function is composed from -`uninstall_`, followed by the file base-name. - - -*/ - -/** @pred current_foreign_library(? _File_, ? _Public_) - - - -Query currently -loaded shared libraries. - - - - - */ - -/** @defgroup Splay_Trees Splay Trees -@ingroup YAPLibrary -@{ - -Splay trees are explained in the paper "Self-adjusting Binary Search -Trees", by D.D. Sleator and R.E. Tarjan, JACM, vol. 32, No.3, July 1985, -p. 668. They are designed to support fast insertions, deletions and -removals in binary search trees without the complexity of traditional -balanced trees. The key idea is to allow the tree to become -unbalanced. To make up for this, whenever we find a node, we move it up -to the top. We use code by Vijay Saraswat originally posted to the Prolog -mailing-list. - - - - @pred splay_access(- _Return_,+ _Key_,? _Val_,+ _Tree_,- _NewTree_) - - -If item _Key_ is in tree _Tree_, return its _Val_ and -unify _Return_ with `true`. Otherwise unify _Return_ with -`null`. The variable _NewTree_ unifies with the new tree. - - -*/ - -/** @pred splay_del(+ _Item_,+ _Tree_,- _NewTree_) - - -Delete item _Key_ from tree _Tree_, assuming that it is present -already. The variable _Val_ unifies with a value for key _Key_, -and the variable _NewTree_ unifies with the new tree. The predicate -will fail if _Key_ is not present. - - -*/ - -/** @pred splay_init(- _NewTree_) - - -Initialize a new splay tree. - - -*/ - -/** @pred splay_insert(+ _Key_,? _Val_,+ _Tree_,- _NewTree_) - - -Insert item _Key_ in tree _Tree_, assuming that it is not -there already. The variable _Val_ unifies with a value for key - _Key_, and the variable _NewTree_ unifies with the new -tree. In our implementation, _Key_ is not inserted if it is -already there: rather it is unified with the item already in the tree. - - -*/ - -/** @pred splay_join(+ _LeftTree_,+ _RighTree_,- _NewTree_) - - -Combine trees _LeftTree_ and _RighTree_ into a single -tree _NewTree_ containing all items from both trees. This operation -assumes that all items in _LeftTree_ are less than all those in - _RighTree_ and destroys both _LeftTree_ and _RighTree_. - - -*/ - -/** @pred splay_split(+ _Key_,? _Val_,+ _Tree_,- _LeftTree_,- _RightTree_) - - -Construct and return two trees _LeftTree_ and _RightTree_, -where _LeftTree_ contains all items in _Tree_ less than - _Key_, and _RightTree_ contains all items in _Tree_ -greater than _Key_. This operations destroys _Tree_. - - - - - */ - -/** @defgroup String_InputOutput Reading From and Writing To Strings -@ingroup YAPLibrary -@{ - -From Version 4.3.2 onwards YAP implements SICStus Prolog compatible -String Input/Output. The library allows users to read from and write to a memory -buffer as if it was a file. The memory buffer is built from or converted -to a string of character codes by the routines in library. Therefore, if -one wants to read from a string the string must be fully instantiated -before the library built-in opens the string for reading. These commands -are available through the `use_module(library(charsio))` command. - - -*/ - -/** @pred format_to_chars(+ _Form_, + _Args_, - _Result_) - - - -Execute the built-in procedure format/2 with form _Form_ and -arguments _Args_ outputting the result to the string of character -codes _Result_. - - -*/ - -/** @pred format_to_chars(+ _Form_, + _Args_, - _Result_, - _Result0_) - - -Execute the built-in procedure format/2 with form _Form_ and -arguments _Args_ outputting the result to the difference list of -character codes _Result-Result0_. - - -*/ - -/** @pred write_to_chars(+ _Term_, - _Result_) - - - -Execute the built-in procedure write/1 with argument _Term_ -outputting the result to the string of character codes _Result_. - - -*/ - -/** @pred write_to_chars(+ _Term_, - _Result0_, - _Result_) - - -Execute the built-in procedure write/1 with argument _Term_ -outputting the result to the difference list of character codes - _Result-Result0_. - - -*/ - -/** @pred atom_to_chars(+ _Atom_, - _Result_) - - - -Convert the atom _Atom_ to the string of character codes - _Result_. - - -*/ - -/** @pred atom_to_chars(+ _Atom_, - _Result0_, - _Result_) - - -Convert the atom _Atom_ to the difference list of character codes - _Result-Result0_. - - -*/ - -/** @pred number_to_chars(+ _Number_, - _Result_) - - - -Convert the number _Number_ to the string of character codes - _Result_. - - -*/ - -/** @pred number_to_chars(+ _Number_, - _Result0_, - _Result_) - - -Convert the atom _Number_ to the difference list of character codes - _Result-Result0_. - - -*/ - -/** @pred atom_to_term(+ _Atom_, - _Term_, - _Bindings_) - - -Use _Atom_ as input to read_term/2 using the option `variable_names` and return the read term in _Term_ and the variable bindings in _Bindings_. _Bindings_ is a list of `Name = Var` couples, thus providing access to the actual variable names. See also read_term/2. If Atom has no valid syntax, a syntax_error exception is raised. - - -*/ - -/** @pred term_to_atom(? _Term_, ? _Atom_) - - -True if _Atom_ describes a term that unifies with _Term_. When - _Atom_ is instantiated _Atom_ is converted and then unified with - _Term_. If _Atom_ has no valid syntax, a syntax_error exception -is raised. Otherwise _Term_ is `written` on _Atom_ using -write_term/2 with the option quoted(true). - - -*/ - -/** @pred read_from_chars(+ _Chars_, - _Term_) - - - -Parse the list of character codes _Chars_ and return the result in -the term _Term_. The character codes to be read must terminate with -a dot character such that either (i) the dot character is followed by -blank characters; or (ii) the dot character is the last character in the -string. - - -*/ - -/** @pred open_chars_stream(+ _Chars_, - _Stream_) - - - -Open the list of character codes _Chars_ as a stream _Stream_. - - -*/ - -/** @pred with_output_to_chars(? _Goal_, - _Chars_) - - - -Execute goal _Goal_ such that its standard output will be sent to a -memory buffer. After successful execution the contents of the memory -buffer will be converted to the list of character codes _Chars_. - - -*/ - -/** @pred with_output_to_chars(? _Goal_, ? _Chars0_, - _Chars_) - - -Execute goal _Goal_ such that its standard output will be sent to a -memory buffer. After successful execution the contents of the memory -buffer will be converted to the difference list of character codes - _Chars-Chars0_. - - -*/ - -/** @pred with_output_to_chars(? _Goal_, - _Stream_, ? _Chars0_, - _Chars_) - - -Execute goal _Goal_ such that its standard output will be sent to a -memory buffer. After successful execution the contents of the memory -buffer will be converted to the difference list of character codes - _Chars-Chars0_ and _Stream_ receives the stream corresponding to -the memory buffer. - - */ - -/** @defgroup System Calling The Operating System from YAP -@ingroup YAPLibrary -@{ - -YAP now provides a library of system utilities compatible with the -SICStus Prolog system library. This library extends and to some point -replaces the functionality of Operating System access routines. The -library includes Unix/Linux and Win32 `C` code. They -are available through the `use_module(library(system))` command. - - - - @pred datime(datime(- _Year_, - _Month_, - _DayOfTheMonth_, - _Hour_, - _Minute_, - _Second_) - -The datime/1 procedure returns the current date and time, with -information on _Year_, _Month_, _DayOfTheMonth_, - _Hour_, _Minute_, and _Second_. The _Hour_ is returned -on local time. This function uses the WIN32 -`GetLocalTime` function or the Unix `localtime` function. - -~~~~~ - ?- datime(X). - -X = datime(2001,5,28,15,29,46) ? -~~~~~ - - -*/ - -/** @pred mktime(+_Datime_, - _Seconds_) - -The `mktime/2` procedure receives a term of the form _datime(+ _Year_, -+ _Month_, + _DayOfTheMonth_, + _Hour_, + _Minute_, + _Second_)_ and -returns the number of _Seconds_ elapsed since 00:00:00 on January 1, -1970, Coordinated Universal Time (UTC). The user provides information -on _Year_, _Month_, _DayOfTheMonth_, _Hour_, _Minute_, and -_Second_. The _Hour_ is given on local time. This function uses the -WIN32 `GetLocalTime` function or the Unix `mktime` function. - -~~~~~ - ?- mktime(datime(2001,5,28,15,29,46),X). - -X = 991081786 ? ; -~~~~~ - - -*/ - -/** @pred delete_file(+ _File_) - - -The delete_file/1 procedure removes file _File_. If - _File_ is a directory, remove the directory and all its subdirectories. - -~~~~~ - ?- delete_file(x). -~~~~~ - - -*/ - -/** @pred delete_file(+ _File_,+ _Opts_) - -The `delete_file/2` procedure removes file _File_ according to -options _Opts_. These options are `directory` if one should -remove directories, `recursive` if one should remove directories -recursively, and `ignore` if errors are not to be reported. - -This example is equivalent to using the delete_file/1 predicate: - -~~~~~ - ?- delete_file(x, [recursive]). -~~~~~ - - -*/ - -/** @pred directory_files(+ _Dir_,+ _List_) - - -Given a directory _Dir_, directory_files/2 procedures a -listing of all files and directories in the directory: - -~~~~~ - ?- directory_files('.',L), writeq(L). -['Makefile.~1~','sys.so','Makefile','sys.o',x,..,'.'] -~~~~~ -The predicates uses the `dirent` family of routines in Unix -environments, and `findfirst` in WIN32. - - -*/ - -/** @pred file_exists(+ _File_) - - -The atom _File_ corresponds to an existing file. - - -*/ - -/** @pred file_exists(+ _File_,+ _Permissions_) - -The atom _File_ corresponds to an existing file with permissions -compatible with _Permissions_. YAP currently only accepts for -permissions to be described as a number. The actual meaning of this -number is Operating System dependent. - - -*/ - -/** @pred file_property(+ _File_,? _Property_) - - -The atom _File_ corresponds to an existing file, and _Property_ -will be unified with a property of this file. The properties are of the -form `type( _Type_)`, which gives whether the file is a regular -file, a directory, a fifo file, or of unknown type; -`size( _Size_)`, with gives the size for a file, and -`mod_time( _Time_)`, which gives the last time a file was -modified according to some Operating System dependent -timestamp; `mode( _mode_)`, gives the permission flags for the -file, and `linkto( _FileName_)`, gives the file pointed to by a -symbolic link. Properties can be obtained through backtracking: - -~~~~~ - ?- file_property('Makefile',P). - -P = type(regular) ? ; - -P = size(2375) ? ; - -P = mod_time(990826911) ? ; - -no -~~~~~ - - -*/ - -/** @pred make_directory(+ _Dir_) - - -Create a directory _Dir_. The name of the directory must be an atom. - - -*/ - -/** @pred rename_file(+ _OldFile_,+ _NewFile_) - - -Create file _OldFile_ to _NewFile_. This predicate uses the -`C` built-in function `rename`. - - -*/ - -/** @pred environ(? _EnvVar_,+ _EnvValue_) - - -Unify environment variable _EnvVar_ with its value _EnvValue_, -if there is one. This predicate is backtrackable in Unix systems, but -not currently in Win32 configurations. - -~~~~~ - ?- environ('HOME',X). - -X = 'C:\\cygwin\\home\\administrator' ? -~~~~~ - - -*/ - -/** @pred host_id(- _Id_) - - - -Unify _Id_ with an identifier of the current host. YAP uses the -`hostid` function when available, - - -*/ - -/** @pred host_name(- _Name_) - - - -Unify _Name_ with a name for the current host. YAP uses the -`hostname` function in Unix systems when available, and the -`GetComputerName` function in WIN32 systems. - - -*/ - -/** @pred kill( _Id_,+ _SIGNAL_) - - - -Send signal _SIGNAL_ to process _Id_. In Unix this predicate is -a direct interface to `kill` so one can send signals to groups of -processes. In WIN32 the predicate is an interface to -`TerminateProcess`, so it kills _Id_ independently of _SIGNAL_. - - -*/ - -/** @pred mktemp( _Spec_,- _File_) - - - -Direct interface to `mktemp`: given a _Spec_, that is a file -name with six _X_ to it, create a file name _File_. Use -tmpnam/1 instead. - - -*/ - -/** @pred pid(- _Id_) - - - -Unify _Id_ with the process identifier for the current -process. An interface to the getpid function. - - -*/ - -/** @pred tmpnam(- _File_) - - - -Interface with _tmpnam_: obtain a new, unique file name _File_. - - -*/ - -/** @pred tmp_file(+_Base_, - _File_) - -Create a name for a temporary file. _Base_ is an user provided -identifier for the category of file. The _TmpName_ is guaranteed to -be unique. If the system halts, it will automatically remove all created -temporary files. - - -*/ - -/** @pred exec(+ _Command_, _StandardStreams_,- _PID_) - - -Execute command _Command_ with its standard streams connected to -the list [_InputStream_, _OutputStream_, _ErrorStream_]. The -process that executes the command is returned as _PID_. The -command is executed by the default shell `bin/sh -c` in Unix. - -The following example demonstrates the use of exec/3 to send a -command and process its output: - -~~~~~ -exec(ls,[std,pipe(S),null],P),repeat, get0(S,C), (C = -1, close(S) ! ; put(C)). -~~~~~ - -The streams may be one of standard stream, `std`, null stream, -`null`, or `pipe(S)`, where _S_ is a pipe stream. Note -that it is up to the user to close the pipe. - - -*/ - -/** @pred popen(+ _Command_, + _TYPE_, - _Stream_) - - -Interface to the popen function. It opens a process by creating a -pipe, forking and invoking _Command_ on the current shell. Since a -pipe is by definition unidirectional the _Type_ argument may be -`read` or `write`, not both. The stream should be closed -using close/1, there is no need for a special `pclose` -command. - -The following example demonstrates the use of popen/3 to process -the output of a command, as exec/3 would do: - -~~~~~{.prolog} - ?- popen(ls,read,X),repeat, get0(X,C), (C = -1, ! ; put(C)). - -X = 'C:\\cygwin\\home\\administrator' ? -~~~~~ - -The WIN32 implementation of popen/3 relies on exec/3. - - -*/ - -/** @pred shell - - -Start a new shell and leave YAP in background until the shell -completes. YAP uses the shell given by the environment variable -`SHELL`. In WIN32 environment YAP will use `COMSPEC` if -`SHELL` is undefined. - - -*/ - -/** @pred shell(+ _Command_) - -Execute command _Command_ under a new shell. YAP will be in -background until the command completes. In Unix environments YAP uses -the shell given by the environment variable `SHELL` with the option -`" -c "`. In WIN32 environment YAP will use `COMSPEC` if -`SHELL` is undefined, in this case with the option `" /c "`. - - -*/ - -/** @pred shell(+ _Command_,- _Status_) - -Execute command _Command_ under a new shell and unify _Status_ -with the exit for the command. YAP will be in background until the -command completes. In Unix environments YAP uses the shell given by the -environment variable `SHELL` with the option `" -c "`. In -WIN32 environment YAP will use `COMSPEC` if `SHELL` is -undefined, in this case with the option `" /c "`. - - -*/ - -/** @pred sleep(+ _Time_) - - -Block the current thread for _Time_ seconds. When YAP is compiled -without multi-threading support, this predicate blocks the YAP process. -The number of seconds must be a positive number, and it may an integer -or a float. The Unix implementation uses `usleep` if the number of -seconds is below one, and `sleep` if it is over a second. The WIN32 -implementation uses `Sleep` for both cases. - - -*/ - -/** @pred system - -Start a new default shell and leave YAP in background until the shell -completes. YAP uses `/bin/sh` in Unix systems and `COMSPEC` in -WIN32. - - -*/ - -/** @pred system(+ _Command_,- _Res_) - -Interface to `system`: execute command _Command_ and unify - _Res_ with the result. - - -*/ - -/** @pred wait(+ _PID_,- _Status_) - - -Wait until process _PID_ terminates, and return its exits _Status_. - - - - - */ - -/** @defgroup Terms Utilities On Terms -@ingroup YAPLibrary -@{ - -The next routines provide a set of commonly used utilities to manipulate -terms. Most of these utilities have been implemented in `C` for -efficiency. They are available through the -`use_module(library(terms))` command. - - - - @pred cyclic_term(? _Term_) - - -Succeed if the argument _Term_ is not a cyclic term. - - -*/ - -/** @pred term_hash(+ _Term_, ? _Hash_) - - - -If _Term_ is ground unify _Hash_ with a positive integer -calculated from the structure of the term. Otherwise the argument - _Hash_ is left unbound. The range of the positive integer is from -`0` to, but not including, `33554432`. - - -*/ - -/** @pred term_hash(+ _Term_, + _Depth_, + _Range_, ? _Hash_) - - -Unify _Hash_ with a positive integer calculated from the structure -of the term. The range of the positive integer is from `0` to, but -not including, _Range_. If _Depth_ is `-1` the whole term -is considered. Otherwise, the term is considered only up to depth -`1`, where the constants and the principal functor have depth -`1`, and an argument of a term with depth _I_ has depth _I+1_. - - -*/ - -/** @pred variables_within_term(+ _Variables_,? _Term_, - _OutputVariables_) - - - -Unify _OutputVariables_ with the subset of the variables _Variables_ that occurs in _Term_. - - -*/ - -/** @pred new_variables_in_term(+ _Variables_,? _Term_, - _OutputVariables_) - - - -Unify _OutputVariables_ with all variables occurring in _Term_ that are not in the list _Variables_. - - -*/ - -/** @pred variant(? _Term1_, ? _Term2_) - - - -Succeed if _Term1_ and _Term2_ are variant terms. - - -*/ - -/** @pred subsumes(? _Term1_, ? _Term2_) - - - -Succeed if _Term1_ subsumes _Term2_. Variables in term - _Term1_ are bound so that the two terms become equal. - - -*/ - -/** @pred subsumes_chk(? _Term1_, ? _Term2_) - - - -Succeed if _Term1_ subsumes _Term2_ but does not bind any -variable in _Term1_. - - -*/ - -/** @pred variable_in_term(? _Term_,? _Var_) - - -Succeed if the second argument _Var_ is a variable and occurs in -term _Term_. - - -*/ - -/** @pred unifiable(? _Term1_, ? _Term2_, - _Bindings_) - - - -Succeed if _Term1_ and _Term2_ are unifiable with substitution - _Bindings_. - - - - - */ - -/** @defgroup Tries Trie DataStructure -@ingroup YAPLibrary -@{ - -The next routines provide a set of utilities to create and manipulate -prefix trees of Prolog terms. Tries were originally proposed to -implement tabling in Logic Programming, but can be used for other -purposes. The tries will be stored in the Prolog database and can seen -as alternative to `assert` and `record` family of -primitives. Most of these utilities have been implemented in `C` -for efficiency. They are available through the -`use_module(library(tries))` command. - - -*/ - -/** @pred trie_open(- _Id_) - - - -Open a new trie with identifier _Id_. - - -*/ - -/** @pred trie_close(+ _Id_) - - - -Close trie with identifier _Id_. - - -*/ - -/** @pred trie_close_all - - - -Close all available tries. - - -*/ - -/** @pred trie_mode(? _Mode_) - - - -Unify _Mode_ with trie operation mode. Allowed values are either -`std` (default) or `rev`. - - -*/ - -/** @pred trie_put_entry(+ _Trie_,+ _Term_,- _Ref_) - - - -Add term _Term_ to trie _Trie_. The handle _Ref_ gives -a reference to the term. - - -*/ - -/** @pred trie_check_entry(+ _Trie_,+ _Term_,- _Ref_) - - - -Succeeds if a variant of term _Term_ is in trie _Trie_. An handle - _Ref_ gives a reference to the term. - - -*/ - -/** @pred trie_get_entry(+ _Ref_,- _Term_) - - -Unify _Term_ with the entry for handle _Ref_. - - -*/ - -/** @pred trie_remove_entry(+ _Ref_) - - - -Remove entry for handle _Ref_. - - -*/ - -/** @pred trie_remove_subtree(+ _Ref_) - - - -Remove subtree rooted at handle _Ref_. - - -*/ - -/** @pred trie_save(+ _Trie_,+ _FileName_) - - -Dump trie _Trie_ into file _FileName_. - - -*/ - -/** @pred trie_load(+ _Trie_,+ _FileName_) - - -Load trie _Trie_ from the contents of file _FileName_. - - -*/ - -/** @pred trie_stats(- _Memory_,- _Tries_,- _Entries_,- _Nodes_) - - -Give generic statistics on tries, including the amount of memory, - _Memory_, the number of tries, _Tries_, the number of entries, - _Entries_, and the total number of nodes, _Nodes_. - - -*/ - -/** @pred trie_max_stats(- _Memory_,- _Tries_,- _Entries_,- _Nodes_) - - -Give maximal statistics on tries, including the amount of memory, - _Memory_, the number of tries, _Tries_, the number of entries, - _Entries_, and the total number of nodes, _Nodes_. - - -*/ - -/** @pred trie_usage(+ _Trie_,- _Entries_,- _Nodes_,- _VirtualNodes_) - - -Give statistics on trie _Trie_, the number of entries, - _Entries_, and the total number of nodes, _Nodes_, and the -number of _VirtualNodes_. - - -*/ - -/** @pred trie_print(+ _Trie_) - - -Print trie _Trie_ on standard output. - - - - - */ - -/** @defgroup Cleanup Call Cleanup -@ingroup YAPLibrary -@{ - -call_cleanup/1 and call_cleanup/2 allow predicates to register -code for execution after the call is finished. Predicates can be -declared to be fragile to ensure that call_cleanup is called -for any Goal which needs it. This library is loaded with the -`use_module(library(cleanup))` command. - - -*/ - -/** @pred :- fragile _P_,....,_Pn_ is directive - - -Declares the predicate _P_=[module:]name/arity as a fragile -predicate, module is optional, default is the current -typein_module. Whenever such a fragile predicate is used in a query -it will be called through call_cleanup/1. - -~~~~~{.prolog} -:- fragile foo/1,bar:baz/2. -~~~~~ - - -*/ - -/** @pred call_cleanup(: _Goal_) - - -Execute goal _Goal_ within a cleanup-context. Called predicates -might register cleanup Goals which are called right after the end of -the call to _Goal_. Cuts and exceptions inside Goal do not prevent the -execution of the cleanup calls. call_cleanup might be nested. - - -*/ - -/** @pred call_cleanup(: _Goal_, : _CleanUpGoal_) - -This is similar to call_cleanup/1 with an additional - _CleanUpGoal_ which gets called after _Goal_ is finished. - - -*/ - -/** @pred setup_call_cleanup(: _Setup_,: _Goal_, : _CleanUpGoal_) - - -Calls `(Setup, Goal)`. For each sucessful execution of _Setup_, calling _Goal_, the -cleanup handler _Cleanup_ is guaranteed to be called exactly once. -This will happen after _Goal_ completes, either through failure, -deterministic success, commit, or an exception. _Setup_ will -contain the goals that need to be protected from asynchronous interrupts -such as the ones received from `call_with_time_limit/2` or thread_signal/2. In -most uses, _Setup_ will perform temporary side-effects required by - _Goal_ that are finally undone by _Cleanup_. - -Success or failure of _Cleanup_ is ignored and choice-points it -created are destroyed (as once/1). If _Cleanup_ throws an exception, -this is executed as normal. - -Typically, this predicate is used to cleanup permanent data storage -required to execute _Goal_, close file-descriptors, etc. The example -below provides a non-deterministic search for a term in a file, closing -the stream as needed. - -~~~~~{.prolog} -term_in_file(Term, File) :- - setup_call_cleanup(open(File, read, In), - term_in_stream(Term, In), - close(In) ). - -term_in_stream(Term, In) :- - repeat, - read(In, T), - ( T == end_of_file - -> !, fail - ; T = Term - ). -~~~~~ - -Note that it is impossible to implement this predicate in Prolog other than -by reading all terms into a list, close the file and call member/2. -Without setup_call_cleanup/3 there is no way to gain control if the -choice-point left by `repeat` is removed by a cut or an exception. - -`setup_call_cleanup/2` can also be used to test determinism of a goal: - -~~~~~ -?- setup_call_cleanup(true,(X=1;X=2), Det=yes). - -X = 1 ; - -X = 2, -Det = yes ; -~~~~~ - -This predicate is under consideration for inclusion into the ISO standard. -For compatibility with other Prolog implementations see `call_cleanup/2`. - - -*/ - -/** @pred setup_call_catcher_cleanup(: _Setup_,: _Goal_, + _Catcher_,: _CleanUpGoal_) - - -Similar to `setup_call_cleanup( _Setup_, _Goal_, _Cleanup_)` with -additional information on the reason of calling _Cleanup_. Prior -to calling _Cleanup_, _Catcher_ unifies with the termination -code. If this unification fails, _Cleanup_ is - *not* called. - - -*/ - -/** @pred on_cleanup(+ _CleanUpGoal_) - - -Any Predicate might registers a _CleanUpGoal_. The - _CleanUpGoal_ is put onto the current cleanup context. All such -CleanUpGoals are executed in reverse order of their registration when -the surrounding cleanup-context ends. This call will throw an exception -if a predicate tries to register a _CleanUpGoal_ outside of any -cleanup-context. - - -*/ - -/** @pred cleanup_all - - -Calls all pending CleanUpGoals and resets the cleanup-system to an -initial state. Should only be used as one of the last calls in the -main program. - - - -There are some private predicates which could be used in special -cases, such as manually setting up cleanup-contexts and registering -CleanUpGoals for other than the current cleanup-context. -Read the Source Luke. - - - */ - -/** @defgroup Timeout Calls With Timeout -@ingroup YAPLibrary -@{ - -The time_out/3 command relies on the alarm/3 built-in to -implement a call with a maximum time of execution. The command is -available with the `use_module(library(timeout))` command. - - - - @pred time_out(+ _Goal_, + _Timeout_, - _Result_) - - -Execute goal _Goal_ with time limited _Timeout_, where - _Timeout_ is measured in milliseconds. If the goal succeeds, unify - _Result_ with success. If the timer expires before the goal -terminates, unify _Result_ with time_out. - -This command is implemented by activating an alarm at procedure -entry. If the timer expires before the goal completes, the alarm will -throw an exception _timeout_. - -One should note that time_out/3 is not reentrant, that is, a goal -called from `time_out` should never itself call -time_out/3. Moreover, time_out/3 will deactivate any previous -alarms set by alarm/3 and vice-versa, hence only one of these -calls should be used in a program. - -Last, even though the timer is set in milliseconds, the current -implementation relies on alarm/3, and therefore can only offer -precision on the scale of seconds. - - - - - */ - -/** @defgroup Trees Updatable Binary Trees -@ingroup YAPLibrary -@{ - -The following queue manipulation routines are available once -included with the `use_module(library(trees))` command. - - - - @pred get_label(+ _Index_, + _Tree_, ? _Label_) - - -Treats the tree as an array of _N_ elements and returns the - _Index_-th. - - -*/ - -/** @pred list_to_tree(+ _List_, - _Tree_) - - -Takes a given _List_ of _N_ elements and constructs a binary - _Tree_. - - -*/ - -/** @pred map_tree(+ _Pred_, + _OldTree_, - _NewTree_) - - -Holds when _OldTree_ and _NewTree_ are binary trees of the same shape -and `Pred(Old,New)` is true for corresponding elements of the two trees. - - -*/ - -/** @pred put_label(+ _Index_, + _OldTree_, + _Label_, - _NewTree_) - - -constructs a new tree the same shape as the old which moreover has the -same elements except that the _Index_-th one is _Label_. - - -*/ - -/** @pred tree_size(+ _Tree_, - _Size_) - - -Calculates the number of elements in the _Tree_. - - -*/ - -/** @pred tree_to_list(+ _Tree_, - _List_) - - -Is the converse operation to list_to_tree. - - - - - */ - -/** @defgroup UGraphs Unweighted Graphs -@ingroup YAPLibrary -@{ - -The following graph manipulation routines are based in code originally -written by Richard O'Keefe. The code was then extended to be compatible -with the SICStus Prolog ugraphs library. The routines assume directed -graphs, undirected graphs may be implemented by using two edges. Graphs -are represented in one of two ways: - -+ The P-representation of a graph is a list of (from-to) vertex -pairs, where the pairs can be in any old order. This form is -convenient for input/output. - -The S-representation of a graph is a list of (vertex-neighbors) -pairs, where the pairs are in standard order (as produced by keysort) -and the neighbors of each vertex are also in standard order (as -produced by sort). This form is convenient for many calculations. - - -These built-ins are available once included with the -`use_module(library(ugraphs))` command. - -*/ - -/** @pred vertices_edges_to_ugraph(+ _Vertices_, + _Edges_, - _Graph_) - - -Given a graph with a set of vertices _Vertices_ and a set of edges - _Edges_, _Graph_ must unify with the corresponding -s-representation. Note that the vertices without edges will appear in - _Vertices_ but not in _Edges_. Moreover, it is sufficient for a -vertex to appear in _Edges_. - -~~~~~{.prolog} -?- vertices_edges_to_ugraph([],[1-3,2-4,4-5,1-5],L). - -L = [1-[3,5],2-[4],3-[],4-[5],5-[]] ? - -~~~~~ -In this case all edges are defined implicitly. The next example shows -three unconnected edges: - -~~~~~{.prolog} -?- vertices_edges_to_ugraph([6,7,8],[1-3,2-4,4-5,1-5],L). - -L = [1-[3,5],2-[4],3-[],4-[5],5-[],6-[],7-[],8-[]] ? - -~~~~~ - - -*/ - -/** @pred vertices(+ _Graph_, - _Vertices_) - - -Unify _Vertices_ with all vertices appearing in graph - _Graph_. In the next example: - -~~~~~{.prolog} -?- vertices([1-[3,5],2-[4],3-[],4-[5],5-[]], V). - -L = [1,2,3,4,5] -~~~~~ - - -*/ - -/** @pred edges(+ _Graph_, - _Edges_) - - -Unify _Edges_ with all edges appearing in graph - _Graph_. In the next example: - -~~~~~{.prolog} -?- vertices([1-[3,5],2-[4],3-[],4-[5],5-[]], V). - -L = [1,2,3,4,5] -~~~~~ - - -*/ - -/** @pred add_vertices(+ _Graph_, + _Vertices_, - _NewGraph_) - - -Unify _NewGraph_ with a new graph obtained by adding the list of -vertices _Vertices_ to the graph _Graph_. In the next example: - -~~~~~{.prolog} -?- add_vertices([1-[3,5],2-[4],3-[],4-[5], - 5-[],6-[],7-[],8-[]], - [0,2,9,10,11], - NG). - -NG = [0-[],1-[3,5],2-[4],3-[],4-[5],5-[], - 6-[],7-[],8-[],9-[],10-[],11-[]] -~~~~~ - - -*/ - -/** @pred del_vertices(+ _Graph_, + _Vertices_, - _NewGraph_) - - -Unify _NewGraph_ with a new graph obtained by deleting the list of -vertices _Vertices_ and all the edges that start from or go to a -vertex in _Vertices_ to the graph _Graph_. In the next example: - -~~~~~{.prolog} -?- del_vertices([2,1],[1-[3,5],2-[4],3-[], - 4-[5],5-[],6-[],7-[2,6],8-[]],NL). - -NL = [3-[],4-[5],5-[],6-[],7-[6],8-[]] -~~~~~ - - -*/ - -/** @pred add_edges(+ _Graph_, + _Edges_, - _NewGraph_) - - -Unify _NewGraph_ with a new graph obtained by adding the list of -edges _Edges_ to the graph _Graph_. In the next example: - -~~~~~{.prolog} -?- add_edges([1-[3,5],2-[4],3-[],4-[5],5-[],6-[], - 7-[],8-[]],[1-6,2-3,3-2,5-7,3-2,4-5],NL). - -NL = [1-[3,5,6],2-[3,4],3-[2],4-[5],5-[7],6-[],7-[],8-[]] -~~~~~ - - -*/ - -/** @pred del_edges(+ _Graph_, + _Edges_, - _NewGraph_) - - -Unify _NewGraph_ with a new graph obtained by removing the list of -edges _Edges_ from the graph _Graph_. Notice that no vertices -are deleted. In the next example: - -~~~~~{.prolog} -?- del_edges([1-[3,5],2-[4],3-[],4-[5],5-[], - 6-[],7-[],8-[]], - [1-6,2-3,3-2,5-7,3-2,4-5,1-3],NL). - -NL = [1-[5],2-[4],3-[],4-[],5-[],6-[],7-[],8-[]] -~~~~~ - - -*/ - -/** @pred transpose(+ _Graph_, - _NewGraph_) - - -Unify _NewGraph_ with a new graph obtained from _Graph_ by -replacing all edges of the form _V1-V2_ by edges of the form - _V2-V1_. The cost is `O(|V|^2)`. In the next example: - -~~~~~{.prolog} -?- transpose([1-[3,5],2-[4],3-[], - 4-[5],5-[],6-[],7-[],8-[]], NL). - -NL = [1-[],2-[],3-[1],4-[2],5-[1,4],6-[],7-[],8-[]] -~~~~~ -Notice that an undirected graph is its own transpose. - - -*/ - -/** @pred neighbors(+ _Vertex_, + _Graph_, - _Vertices_) - - -Unify _Vertices_ with the list of neighbors of vertex _Vertex_ -in _Graph_. If the vertice is not in the graph fail. In the next -example: - -~~~~~{.prolog} -?- neighbors(4,[1-[3,5],2-[4],3-[], - 4-[1,2,7,5],5-[],6-[],7-[],8-[]], - NL). - -NL = [1,2,7,5] -~~~~~ - - -*/ - -/** @pred neighbours(+ _Vertex_, + _Graph_, - _Vertices_) - - -Unify _Vertices_ with the list of neighbours of vertex _Vertex_ -in _Graph_. In the next example: - -~~~~~{.prolog} -?- neighbours(4,[1-[3,5],2-[4],3-[], - 4-[1,2,7,5],5-[],6-[],7-[],8-[]], NL). - -NL = [1,2,7,5] -~~~~~ - - -*/ - -/** @pred complement(+ _Graph_, - _NewGraph_) - - -Unify _NewGraph_ with the graph complementary to _Graph_. -In the next example: - -~~~~~{.prolog} -?- complement([1-[3,5],2-[4],3-[], - 4-[1,2,7,5],5-[],6-[],7-[],8-[]], NL). - -NL = [1-[2,4,6,7,8],2-[1,3,5,6,7,8],3-[1,2,4,5,6,7,8], - 4-[3,5,6,8],5-[1,2,3,4,6,7,8],6-[1,2,3,4,5,7,8], - 7-[1,2,3,4,5,6,8],8-[1,2,3,4,5,6,7]] -~~~~~ - - -*/ - -/** @pred compose(+ _LeftGraph_, + _RightGraph_, - _NewGraph_) - - -Compose the graphs _LeftGraph_ and _RightGraph_ to form _NewGraph_. -In the next example: - -~~~~~{.prolog} -?- compose([1-[2],2-[3]],[2-[4],3-[1,2,4]],L). - -L = [1-[4],2-[1,2,4],3-[]] -~~~~~ - - -*/ - -/** @pred top_sort(+ _Graph_, - _Sort_) - - -Generate the set of nodes _Sort_ as a topological sorting of graph - _Graph_, if one is possible. -In the next example we show how topological sorting works for a linear graph: - -~~~~~{.prolog} -?- top_sort([_138-[_219],_219-[_139], _139-[]],L). - -L = [_138,_219,_139] -~~~~~ - - -*/ - -/** @pred top_sort(+ _Graph_, - _Sort0_, - _Sort_) - -Generate the difference list _Sort_- _Sort0_ as a topological -sorting of graph _Graph_, if one is possible. - - -*/ - -/** @pred transitive_closure(+ _Graph_, + _Closure_) - - -Generate the graph _Closure_ as the transitive closure of graph - _Graph_. -In the next example: - -~~~~~{.prolog} -?- transitive_closure([1-[2,3],2-[4,5],4-[6]],L). - -L = [1-[2,3,4,5,6],2-[4,5,6],4-[6]] -~~~~~ - - -*/ - -/** @pred reachable(+ _Node_, + _Graph_, - _Vertices_) - - -Unify _Vertices_ with the set of all vertices in graph - _Graph_ that are reachable from _Node_. In the next example: - -~~~~~{.prolog} -?- reachable(1,[1-[3,5],2-[4],3-[],4-[5],5-[]],V). - -V = [1,3,5] -~~~~~ - - - - - */ - -/** @defgroup DGraphs Directed Graphs -@ingroup YAPLibrary -@{ - -The following graph manipulation routines use the red-black tree library -to try to avoid linear-time scans of the graph for all graph -operations. Graphs are represented as a red-black tree, where the key is -the vertex, and the associated value is a list of vertices reachable -from that vertex through an edge (ie, a list of edges). - - - - @pred dgraph_new(+ _Graph_) - - -Create a new directed graph. This operation must be performed before -trying to use the graph. - - -*/ - -/** @pred dgraph_vertices(+ _Graph_, - _Vertices_) - - -Unify _Vertices_ with all vertices appearing in graph - _Graph_. - - -*/ - -/** @pred dgraph_edge(+ _N1_, + _N2_, + _Graph_) - - -Edge _N1_- _N2_ is an edge in directed graph _Graph_. - - -*/ - -/** @pred dgraph_edges(+ _Graph_, - _Edges_) - - -Unify _Edges_ with all edges appearing in graph - _Graph_. - - -*/ - -/** @pred dgraph_add_vertices(+ _Graph_, + _Vertex_, - _NewGraph_) - - -Unify _NewGraph_ with a new graph obtained by adding -vertex _Vertex_ to the graph _Graph_. - - -*/ - -/** @pred dgraph_add_vertices(+ _Graph_, + _Vertices_, - _NewGraph_) - - -Unify _NewGraph_ with a new graph obtained by adding the list of -vertices _Vertices_ to the graph _Graph_. - - -*/ - -/** @pred dgraph_del_vertex(+ _Graph_, + _Vertex_, - _NewGraph_) - - -Unify _NewGraph_ with a new graph obtained by deleting vertex - _Vertex_ and all the edges that start from or go to _Vertex_ to -the graph _Graph_. - - -*/ - -/** @pred dgraph_del_vertices(+ _Graph_, + _Vertices_, - _NewGraph_) - - -Unify _NewGraph_ with a new graph obtained by deleting the list of -vertices _Vertices_ and all the edges that start from or go to a -vertex in _Vertices_ to the graph _Graph_. - - -*/ - -/** @pred dgraph_add_edge(+ _Graph_, + _N1_, + _N2_, - _NewGraph_) - - -Unify _NewGraph_ with a new graph obtained by adding the edge - _N1_- _N2_ to the graph _Graph_. - - -*/ - -/** @pred dgraph_add_edges(+ _Graph_, + _Edges_, - _NewGraph_) - - -Unify _NewGraph_ with a new graph obtained by adding the list of -edges _Edges_ to the graph _Graph_. - - -*/ - -/** @pred dgraph_del_edge(+ _Graph_, + _N1_, + _N2_, - _NewGraph_) - - -Succeeds if _NewGraph_ unifies with a new graph obtained by -removing the edge _N1_- _N2_ from the graph _Graph_. Notice -that no vertices are deleted. - - -*/ - -/** @pred dgraph_del_edges(+ _Graph_, + _Edges_, - _NewGraph_) - - -Unify _NewGraph_ with a new graph obtained by removing the list of -edges _Edges_ from the graph _Graph_. Notice that no vertices -are deleted. - - -*/ - -/** @pred dgraph_to_ugraph(+ _Graph_, - _UGraph_) - - -Unify _UGraph_ with the representation used by the _ugraphs_ -unweighted graphs library, that is, a list of the form - _V-Neighbors_, where _V_ is a node and _Neighbors_ the nodes -children. - - -*/ - -/** @pred ugraph_to_dgraph( + _UGraph_, - _Graph_) - - -Unify _Graph_ with the directed graph obtain from _UGraph_, -represented in the form used in the _ugraphs_ unweighted graphs -library. - - -*/ - -/** @pred dgraph_neighbors(+ _Vertex_, + _Graph_, - _Vertices_) - - -Unify _Vertices_ with the list of neighbors of vertex _Vertex_ -in _Graph_. If the vertice is not in the graph fail. - - -*/ - -/** @pred dgraph_neighbours(+ _Vertex_, + _Graph_, - _Vertices_) - - -Unify _Vertices_ with the list of neighbours of vertex _Vertex_ -in _Graph_. - - -*/ - -/** @pred dgraph_complement(+ _Graph_, - _NewGraph_) - - -Unify _NewGraph_ with the graph complementary to _Graph_. - - -*/ - -/** @pred dgraph_transpose(+ _Graph_, - _Transpose_) - - -Unify _NewGraph_ with a new graph obtained from _Graph_ by -replacing all edges of the form _V1-V2_ by edges of the form - _V2-V1_. - - -*/ - -/** @pred dgraph_compose(+ _Graph1_, + _Graph2_, - _ComposedGraph_) - - -Unify _ComposedGraph_ with a new graph obtained by composing - _Graph1_ and _Graph2_, ie, _ComposedGraph_ has an edge - _V1-V2_ iff there is a _V_ such that _V1-V_ in _Graph1_ -and _V-V2_ in _Graph2_. - - -*/ - -/** @pred dgraph_transitive_closure(+ _Graph_, - _Closure_) - - -Unify _Closure_ with the transitive closure of graph _Graph_. - - -*/ - -/** @pred dgraph_symmetric_closure(+ _Graph_, - _Closure_) - - -Unify _Closure_ with the symmetric closure of graph _Graph_, -that is, if _Closure_ contains an edge _U-V_ it must also -contain the edge _V-U_. - - -*/ - -/** @pred dgraph_top_sort(+ _Graph_, - _Vertices_) - - -Unify _Vertices_ with the topological sort of graph _Graph_. - - -*/ - -/** @pred dgraph_top_sort(+ _Graph_, - _Vertices_, ? _Vertices0_) - -Unify the difference list _Vertices_- _Vertices0_ with the -topological sort of graph _Graph_. - - -*/ - -/** @pred dgraph_min_path(+ _V1_, + _V1_, + _Graph_, - _Path_, ? _Costt_) - - -Unify the list _Path_ with the minimal cost path between nodes - _N1_ and _N2_ in graph _Graph_. Path _Path_ has cost - _Cost_. - - -*/ - -/** @pred dgraph_max_path(+ _V1_, + _V1_, + _Graph_, - _Path_, ? _Costt_) - - -Unify the list _Path_ with the maximal cost path between nodes - _N1_ and _N2_ in graph _Graph_. Path _Path_ has cost - _Cost_. - - -*/ - -/** @pred dgraph_min_paths(+ _V1_, + _Graph_, - _Paths_) - - -Unify the list _Paths_ with the minimal cost paths from node - _N1_ to the nodes in graph _Graph_. - - -*/ - -/** @pred dgraph_isomorphic(+ _Vs_, + _NewVs_, + _G0_, - _GF_) - - -Unify the list _GF_ with the graph isomorphic to _G0_ where -vertices in _Vs_ map to vertices in _NewVs_. - - -*/ - -/** @pred dgraph_path(+ _Vertex_, + _Graph_, ? _Path_) - - -The path _Path_ is a path starting at vertex _Vertex_ in graph - _Graph_. - - -*/ - -/** @pred dgraph_path(+ _Vertex_, + _Vertex1_, + _Graph_, ? _Path_) - -The path _Path_ is a path starting at vertex _Vertex_ in graph - _Graph_ and ending at path _Vertex2_. - - -*/ - -/** @pred dgraph_reachable(+ _Vertex_, + _Graph_, ? _Edges_) - - -The path _Path_ is a path starting at vertex _Vertex_ in graph - _Graph_. - - -*/ - -/** @pred dgraph_leaves(+ _Graph_, ? _Vertices_) - - -The vertices _Vertices_ have no outgoing edge in graph - _Graph_. - - - - - */ - -/** @defgroup UnDGraphs Undirected Graphs -@ingroup YAPLibrary -@{ - -The following graph manipulation routines use the red-black tree graph -library to implement undirected graphs. Mostly, this is done by having -two directed edges per undirected edge. - - - - @pred undgraph_new(+ _Graph_) - - -Create a new directed graph. This operation must be performed before -trying to use the graph. - - -*/ - -/** @pred undgraph_vertices(+ _Graph_, - _Vertices_) - - -Unify _Vertices_ with all vertices appearing in graph - _Graph_. - - -*/ - -/** @pred undgraph_edge(+ _N1_, + _N2_, + _Graph_) - - -Edge _N1_- _N2_ is an edge in undirected graph _Graph_. - - -*/ - -/** @pred undgraph_edges(+ _Graph_, - _Edges_) - - -Unify _Edges_ with all edges appearing in graph - _Graph_. - - -*/ - -/** @pred undgraph_add_vertices(+ _Graph_, + _Vertices_, - _NewGraph_) - - -Unify _NewGraph_ with a new graph obtained by adding the list of -vertices _Vertices_ to the graph _Graph_. - - -*/ - -/** @pred undgraph_del_vertices(+ _Graph_, + _Vertices_, - _NewGraph_) - - -Unify _NewGraph_ with a new graph obtained by deleting the list of -vertices _Vertices_ and all the edges that start from or go to a -vertex in _Vertices_ to the graph _Graph_. - - -*/ - -/** @pred undgraph_add_edges(+ _Graph_, + _Edges_, - _NewGraph_) - - -Unify _NewGraph_ with a new graph obtained by adding the list of -edges _Edges_ to the graph _Graph_. - - -*/ - -/** @pred undgraph_del_edges(+ _Graph_, + _Edges_, - _NewGraph_) - - -Unify _NewGraph_ with a new graph obtained by removing the list of -edges _Edges_ from the graph _Graph_. Notice that no vertices -are deleted. - - -*/ - -/** @pred undgraph_neighbors(+ _Vertex_, + _Graph_, - _Vertices_) - - -Unify _Vertices_ with the list of neighbors of vertex _Vertex_ -in _Graph_. If the vertice is not in the graph fail. - - -*/ - -/** @pred undgraph_neighbours(+ _Vertex_, + _Graph_, - _Vertices_) - - -Unify _Vertices_ with the list of neighbours of vertex _Vertex_ -in _Graph_. - - -*/ - -/** @pred undgraph_complement(+ _Graph_, - _NewGraph_) - - -Unify _NewGraph_ with the graph complementary to _Graph_. - - -*/ - -/** @pred dgraph_to_undgraph( + _DGraph_, - _UndGraph_) - - -Unify _UndGraph_ with the undirected graph obtained from the -directed graph _DGraph_. - - - - - */ - -/** @defgroup DBUsage Memory Usage in Prolog Data-Base -@ingroup YAPLibrary -@{ - -This library provides a set of utilities for studying memory usage in YAP. -The following routines are available once included with the -`use_module(library(dbusage))` command. - - -*/ - -/** @pred db_usage - - -Give general overview of data-base usage in the system. - - -*/ - -/** @pred db_static - - -List memory usage for every static predicate. - - -*/ - -/** @pred db_static(+ _Threshold_) - -List memory usage for every static predicate. Predicate must use more -than _Threshold_ bytes. - - -*/ - -/** @pred db_dynamic - - -List memory usage for every dynamic predicate. - - -*/ - -/** @pred db_dynamic(+ _Threshold_) - -List memory usage for every dynamic predicate. Predicate must use more -than _Threshold_ bytes. - - - - - */ - -/** @defgroup Lambda Lambda Expressions -@ingroup YAPLibrary -@{ - -This library, designed and implemented by Ulrich Neumerkel, provides -lambda expressions to simplify higher order programming based on `call/N`. - -Lambda expressions are represented by ordinary Prolog terms. There are -two kinds of lambda expressions: - -~~~~~{.prolog} - Free+\X1^X2^ ..^XN^Goal - - \X1^X2^ ..^XN^Goal -~~~~~ - -The second is a shorthand for` t+\X1^X2^..^XN^Goal`, where `Xi` are the parameters. - - _Goal_ is a goal or continuation (Syntax note: _Operators_ within _Goal_ -require parentheses due to the low precedence of the `^` operator). - -Free contains variables that are valid outside the scope of the lambda -expression. They are thus free variables within. - -All other variables of _Goal_ are considered local variables. They must -not appear outside the lambda expression. This restriction is -currently not checked. Violations may lead to unexpected bindings. - -In the following example the parentheses around `X>3` are necessary. - -~~~~~{.prolog} -?- use_module(library(lambda)). -?- use_module(library(apply)). - -?- maplist(\X^(X>3),[4,5,9]). -true. -~~~~~ - -In the following _X_ is a variable that is shared by both instances -of the lambda expression. The second query illustrates the cooperation -of continuations and lambdas. The lambda expression is in this case a -continuation expecting a further argument. - -~~~~~{.prolog} -?- Xs = [A,B], maplist(X+\Y^dif(X,Y), Xs). -Xs = [A, B], -dif(X, A), -dif(X, B). - -?- Xs = [A,B], maplist(X+\dif(X), Xs). -Xs = [A, B], -dif(X, A), -dif(X, B). - -~~~~~ - -The following queries are all equivalent. To see this, use -the fact `f(x,y)`. - -~~~~~{.prolog} -?- call(f,A1,A2). -?- call(\X^f(X),A1,A2). -?- call(\X^Y^f(X,Y), A1,A2). -?- call(\X^(X+\Y^f(X,Y)), A1,A2). -?- call(call(f, A1),A2). -?- call(f(A1),A2). -?- f(A1,A2). -A1 = x, -A2 = y. -~~~~~ - -Further discussions -at Ulrich Neumerker's page in . - - - */ - -/** @defgroup LAM LAM -@ingroup YAPPackages -@{ - -This library provides a set of utilities for interfacing with LAM MPI. -The following routines are available once included with the -`use_module(library(lam_mpi))` command. The yap should be -invoked using the LAM mpiexec or mpirun commands (see LAM manual for -more details). - - -*/ - -/** @pred mpi_init - - -Sets up the mpi environment. This predicate should be called before any other MPI predicate. - - -*/ - -/** @pred mpi_finalize - - -Terminates the MPI execution environment. Every process must call this predicate before exiting. - - -*/ - -/** @pred mpi_comm_size(- _Size_) - - -Unifies _Size_ with the number of processes in the MPI environment. - - -*/ - -/** @pred mpi_comm_rank(- _Rank_) - - -Unifies _Rank_ with the rank of the current process in the MPI environment. - - -*/ - -/** @pred mpi_version(- _Major_,- _Minor_) - - -Unifies _Major_ and _Minor_ with, respectively, the major and minor version of the MPI. - - -*/ - -/** @pred mpi_send(+ _Data_,+ _Dest_,+ _Tag_) - - - -Blocking communication predicate. The message in _Data_, with tag - _Tag_, is sent immediately to the processor with rank _Dest_. -The predicate succeeds after the message being sent. - - -*/ - -/** @pred mpi_isend(+ _Data_,+ _Dest_,+ _Tag_,- _Handle_) - - - -Non blocking communication predicate. The message in _Data_, with -tag _Tag_, is sent whenever possible to the processor with rank - _Dest_. An _Handle_ to the message is returned to be used to -check for the status of the message, using the `mpi_wait` or -`mpi_test` predicates. Until `mpi_wait` is called, the -memory allocated for the buffer containing the message is not -released. - - -*/ - -/** @pred mpi_recv(? _Source_,? _Tag_,- _Data_) - - - -Blocking communication predicate. The predicate blocks until a message -is received from processor with rank _Source_ and tag _Tag_. -The message is placed in _Data_. - - -*/ - -/** @pred mpi_irecv(? _Source_,? _Tag_,- _Handle_) - - - -Non-blocking communication predicate. The predicate returns an - _Handle_ for a message that will be received from processor with -rank _Source_ and tag _Tag_. Note that the predicate succeeds -immediately, even if no message has been received. The predicate -`mpi_wait_recv` should be used to obtain the data associated to -the handle. - - -*/ - -/** @pred mpi_wait_recv(? _Handle_,- _Status_,- _Data_) - - - -Completes a non-blocking receive operation. The predicate blocks until -a message associated with handle _Hanlde_ is buffered. The -predicate succeeds unifying _Status_ with the status of the -message and _Data_ with the message itself. - - -*/ - -/** @pred mpi_test_recv(? _Handle_,- _Status_,- _Data_) - - - -Provides information regarding a handle. If the message associated -with handle _Hanlde_ is buffered then the predicate succeeds -unifying _Status_ with the status of the message and _Data_ -with the message itself. Otherwise, the predicate fails. - - -*/ - -/** @pred mpi_wait(? _Handle_,- _Status_) - - - -Completes a non-blocking operation. If the operation was a -`mpi_send`, the predicate blocks until the message is buffered -or sent by the runtime system. At this point the send buffer is -released. If the operation was a `mpi_recv`, it waits until the -message is copied to the receive buffer. _Status_ is unified with -the status of the message. - - -*/ - -/** @pred mpi_test(? _Handle_,- _Status_) - - - -Provides information regarding the handle _Handle_, ie., if a -communication operation has been completed. If the operation -associate with _Hanlde_ has been completed the predicate succeeds -with the completion status in _Status_, otherwise it fails. - - -*/ - -/** @pred mpi_barrier - - -Collective communication predicate. Performs a barrier -synchronization among all processes. Note that a collective -communication means that all processes call the same predicate. To be -able to use a regular `mpi_recv` to receive the messages, one -should use `mpi_bcast2`. - - -*/ - -/** @pred mpi_bcast2(+ _Root_, ? _Data_) - - - -Broadcasts the message _Data_ from the process with rank _Root_ -to all other processes. - - -*/ - -/** @pred mpi_bcast3(+ _Root_, + _Data_, + _Tag_) - - -Broadcasts the message _Data_ with tag _Tag_ from the process with rank _Root_ -to all other processes. - - -*/ - -/** @pred mpi_ibcast(+ _Root_, + _Data_, + _Tag_) - - - -Non-blocking operation. Broadcasts the message _Data_ with tag _Tag_ -from the process with rank _Root_ to all other processes. - - -*/ - -/** @pred mpi_default_buffer_size(- _OldBufferSize_, ? _NewBufferSize_) - - - -The _OldBufferSize_ argument unifies with the current size of the -MPI communication buffer size and sets the communication buffer size - _NewBufferSize_. The buffer is used for assynchronous waiting and -for broadcast receivers. Notice that buffer is local at each MPI -process. - - -*/ - -/** @pred mpi_msg_size( _Msg_, - _MsgSize_) - - -Unify _MsgSize_ with the number of bytes YAP would need to send the -message _Msg_. - - -*/ - -/** @pred mpi_gc - - - -Attempts to perform garbage collection with all the open handles -associated with send and non-blocking broadcasts. For each handle it -tests it and the message has been delivered the handle and the buffer -are released. - - - - - */ - -/** @defgroup BDDs Binary Decision Diagrams and Friends -@ingroup YAPPackages -@{ - -This library provides an interface to the BDD package CUDD. It requires -CUDD compiled as a dynamic library. In Linux this is available out of -box in Fedora, but can easily be ported to other Linux -distributions. CUDD is available in the ports OSX package, and in -cygwin. To use it, call `:-use_module(library(bdd))`. - -The following predicates construct a BDD: - - -*/ - -/** @pred bdd_new(? _Exp_, - _BddHandle_) - -create a new BDD from the logical expression _Exp_. The expression -may include: - -+ Logical Variables: -a leaf-node can be a logical variable. -+ Constants 0 and 1 -a leaf-node can also be one of these two constants. -+ or( _X_, _Y_), _X_ \/ _Y_, _X_ + _Y_ -disjunction -+ and( _X_, _Y_), _X_ /\ _Y_, _X_ \* _Y_ -conjunction -+ nand( _X_, _Y_) -negated conjunction@ -+ nor( _X_, _Y_) -negated disjunction -+ xor( _X_, _Y_) -exclusive or -+ not( _X_), - _X_ -negation - - - -*/ - -/** @pred bdd_from_list(? _List_, ?_Vars_, - _BddHandle_) - -Convert a _List_ of logical expressions of the form above, that -includes the set of free variables _Vars_, into a BDD accessible -through _BddHandle_. - - -*/ - -/** @pred mtbdd_new(? _Exp_, - _BddHandle_) - -create a new algebraic decision diagram (ADD) from the logical -expression _Exp_. The expression may include: - -+ Logical Variables: -a leaf-node can be a logical variable, or parameter. -+ Number -a leaf-node can also be any number -+ _X_ \* _Y_ -product -+ _X_ + _Y_ -sum -+ _X_ - _Y_ -subtraction -+ or( _X_, _Y_), _X_ \/ _Y_ -logical or - - - -*/ - -/** @pred bdd_tree(+ _BDDHandle_, _Term_) - -Convert the BDD or ADD represented by _BDDHandle_ to a Prolog term -of the form `bdd( _Dir_, _Nodes_, _Vars_)` or `mtbdd( _Nodes_, _Vars_)`, respectively. The arguments are: - -+ - _Dir_ direction of the BDD, usually 1 -+ - _Nodes_ list of nodes in the BDD or ADD. - -In a BDD nodes may be pp (both terminals are positive) or pn -(right-hand-side is negative), and have four arguments: a logical -variable that will be bound to the value of the node, the logical -variable corresponding to the node, a logical variable, a 0 or a 1 with -the value of the left-hand side, and a logical variable, a 0 or a 1 -with the right-hand side. - -+ - _Vars_ are the free variables in the original BDD, or the parameters of the BDD/ADD. - -As an example, the BDD for the expression `X+(Y+X)\*(-Z)` becomes: - -~~~~~ -bdd(1,[pn(N2,X,1,N1),pp(N1,Y,N0,1),pn(N0,Z,1,1)],vs(X,Y,Z)) -~~~~~ - - -*/ - -/** @pred bdd_eval(+ _BDDHandle_, _Val_) - -Unify _Val_ with the value of the logical expression compiled in - _BDDHandle_ given an assignment to its variables. - -~~~~~ -bdd_new(X+(Y+X)*(-Z), BDD), -[X,Y,Z] = [0,0,0], -bdd_eval(BDD, V), -writeln(V). -~~~~~ -would write 0 in the standard output stream. - -The Prolog code equivalent to bdd_eval/2 is: - -~~~~~ - Tree = bdd(1, T, _Vs), - reverse(T, RT), - foldl(eval_bdd, RT, _, V). - -eval_bdd(pp(P,X,L,R), _, P) :- - P is ( X/\L ) \/ ( (1-X) /\ R ). -eval_bdd(pn(P,X,L,R), _, P) :- - P is ( X/\L ) \/ ( (1-X) /\ (1-R) ). -~~~~~ -First, the nodes are reversed to implement bottom-up evaluation. Then, -we use the `foldl` list manipulation predicate to walk every node, -computing the disjunction of the two cases and binding the output -variable. The top node gives the full expression value. Notice that -`(1- _X_)` implements negation. - - -*/ - -/** @pred bdd_size(+ _BDDHandle_, - _Size_) - -Unify _Size_ with the number of nodes in _BDDHandle_. - - -*/ - -/** @pred bdd_print(+ _BDDHandle_, + _File_) - -Output bdd _BDDHandle_ as a dot file to _File_. - - -*/ - -/** @pred bdd_to_probability_sum_product(+ _BDDHandle_, - _Prob_) - -Each node in a BDD is given a probability _Pi_. The total -probability of a corresponding sum-product network is _Prob_. - - -*/ - -/** @pred bdd_to_probability_sum_product(+ _BDDHandle_, - _Probs_, - _Prob_) -Each node in a BDD is given a probability _Pi_. The total -probability of a corresponding sum-product network is _Prob_, and -the probabilities of the inner nodes are _Probs_. - -In Prolog, this predicate would correspond to computing the value of a -BDD. The input variables will be bound to probabilities, eg -`[ _X_, _Y_, _Z_] = [0.3.0.7,0.1]`, and the previous -`eval_bdd` would operate over real numbers: - -~~~~~ - Tree = bdd(1, T, _Vs), - reverse(T, RT), - foldl(eval_prob, RT, _, V). - -eval_prob(pp(P,X,L,R), _, P) :- - P is X * L + (1-X) * R. -eval_prob(pn(P,X,L,R), _, P) :- - P is X * L + (1-X) * (1-R). -~~~~~ - -*/ - -/** @pred bdd_close( _BDDHandle_) - -close the BDD and release any resources it holds. - - - - - */ - -/** @defgroup Block_Diagram Block Diagram -@ingroup YAPLibrary -@{ - -This library provides a way of visualizing a prolog program using -modules with blocks. To use it use: -`:-use_module(library(block_diagram))`. - - -*/ - -/** @pred make_diagram(+inputfilename, +ouputfilename) - - - -This will crawl the files following the use_module, ensure_loaded directives withing the inputfilename. -The result will be a file in dot format. -You can make a pdf at the shell by asking `dot -Tpdf filename > output.pdf`. - - -*/ - -/** @pred make_diagram(+inputfilename, +ouputfilename, +predicate, +depth, +extension) - - -The same as make_diagram/2 but you can define how many of the imported/exporeted predicates will be shown with predicate, and how deep the crawler is allowed to go with depth. The extension is used if the file use module directives do not include a file extension. - - - -*/ - -/** @page SWIhYProlog_Emulation SWI-Prolog Emulation - -This library provides a number of SWI-Prolog builtins that are not by -default in YAP. This support is loaded with the -`expects_dialect(swi)` command. - - -*/ - -/** @pred append(? _List1_,? _List2_,? _List3_) - - -Succeeds when _List3_ unifies with the concatenation of _List1_ -and _List2_. The predicate can be used with any instantiation -pattern (even three variables). - - -*/ - -/** @pred between(+ _Low_,+ _High_,? _Value_) - - - - _Low_ and _High_ are integers, _High_ less or equal than - _Low_. If _Value_ is an integer, _Low_ less or equal than - _Value_ less or equal than _High_. When _Value_ is a -variable it is successively bound to all integers between _Low_ and - _High_. If _High_ is `inf`, between/3 is true iff - _Value_ less or equal than _Low_, a feature that is particularly -interesting for generating integers from a certain value. - - -*/ - -/** @pred chdir(+ _Dir_) - - - -Compatibility predicate. New code should use working_directory/2. - - -*/ - -/** @pred concat_atom(+ _List_,- _Atom_) - - - - _List_ is a list of atoms, integers or floating point numbers. Succeeds -if _Atom_ can be unified with the concatenated elements of _List_. If - _List_ has exactly 2 elements it is equivalent to `atom_concat/3`, -allowing for variables in the list. - - -*/ - -/** @pred concat_atom(? _List_,+ _Separator_,? _Atom_) - - -Creates an atom just like concat_atom/2, but inserts _Separator_ -between each pair of atoms. For example: - -~~~~~ -?- concat_atom([gnu, gnat], ', ', A). - -A = 'gnu, gnat' -~~~~~ - -(Unimplemented) This predicate can also be used to split atoms by -instantiating _Separator_ and _Atom_: - -~~~~~ -?- concat_atom(L, -, 'gnu-gnat'). - -L = [gnu, gnat] -~~~~~ - - -*/ - -/** @pred nth1(+ _Index_,? _List_,? _Elem_) - - -Succeeds when the _Index_-th element of _List_ unifies with - _Elem_. Counting starts at 1. - -Set environment variable. _Name_ and _Value_ should be -instantiated to atoms or integers. The environment variable will be -passed to `shell/[0-2]` and can be requested using `getenv/2`. -They also influence expand_file_name/2. - - -*/ - -/** @pred setenv(+ _Name_,+ _Value_) - - -Set environment variable. _Name_ and _Value_ should be -instantiated to atoms or integers. The environment variable will be -passed to `shell/[0-2]` and can be requested using `getenv/2`. -They also influence expand_file_name/2. - - -*/ - -/** @pred term_to_atom(? _Term_,? _Atom_) - - -Succeeds if _Atom_ describes a term that unifies with _Term_. When - _Atom_ is instantiated _Atom_ is converted and then unified with - _Term_. If _Atom_ has no valid syntax, a `syntax_error` -exception is raised. Otherwise _Term_ is `written` on _Atom_ -using write/1. - - -*/ - -/** @pred working_directory(- _Old_,+ _New_) - - - -Unify _Old_ with an absolute path to the current working directory -and change working directory to _New_. Use the pattern -`working_directory(CWD, CWD)` to get the current directory. See -also `absolute_file_name/2` and chdir/1. - - -*/ - -/** @pred _Term1_ =@= _Term2_ is semidet - - - -True iff _Term1_ and _Term2_ are structurally equivalent. I.e. if _Term1_ and _Term2_ are variants of each other. - - - - - */ - -/** @defgroup Invoking_Predicates_on_all_Members_of_a_List Invoking Predicates on all Members of a List -@ingroup YAPLibrary -@{ - - -All the predicates in this section call a predicate on all members of a -list or until the predicate called fails. The predicate is called via -`call/[2..]`, which implies common arguments can be put in -front of the arguments obtained from the list(s). For example: - -~~~~~ -?- maplist(plus(1), [0, 1, 2], X). - -X = [1, 2, 3] -~~~~~ - -we will phrase this as ` _Predicate_ is applied on ...` - - - - @pred maplist(+ _Pred_,+ _List_) - - - _Pred_ is applied successively on each element of _List_ until -the end of the list or _Pred_ fails. In the latter case -`maplist/2` fails. - - -*/ - -/** @pred maplist(+ _Pred_,+ _List1_,+ _List2_) - -Apply _Pred_ on all successive pairs of elements from - _List1_ and - _List2_. Fails if _Pred_ can not be applied to a -pair. See the example above. - - -*/ - -/** @pred maplist(+ _Pred_,+ _List1_,+ _List2_,+ _List4_) - -Apply _Pred_ on all successive triples of elements from _List1_, - _List2_ and _List3_. Fails if _Pred_ can not be applied to a -triple. See the example above. - - - - - */ - -/** @defgroup Forall Forall -@ingroup YAPPackages -@{ - - - -*/ - -/** @pred forall(+ _Cond_,+ _Action_) - - - - -For all alternative bindings of _Cond_ _Action_ can be proven. -The next example verifies that all arithmetic statements in the list - _L_ are correct. It does not say which is wrong if one proves wrong. - -~~~~~ -?- forall(member(Result = Formula, [2 = 1 + 1, 4 = 2 * 2]), - Result =:= Formula). -~~~~~ - - - -*/ - -/** @page SWIhYProlog_Global_Variables SWI Global variables - - -SWI-Prolog global variables are associations between names (atoms) and -terms. They differ in various ways from storing information using -assert/1 or recorda/3. - -+ The value lives on the Prolog (global) stack. This implies -that lookup time is independent from the size of the term. -This is particulary interesting for large data structures -such as parsed XML documents or the CHR global constraint -store. - -They support both global assignment using nb_setval/2 and -backtrackable assignment using b_setval/2. - -+ Only one value (which can be an arbitrary complex Prolog -term) can be associated to a variable at a time. - -+ Their value cannot be shared among threads. Each thread -has its own namespace and values for global variables. - -+ Currently global variables are scoped globally. We may -consider module scoping in future versions. - - -Both b_setval/2 and nb_setval/2 implicitly create a variable if the -referenced name does not already refer to a variable. - -Global variables may be initialised from directives to make them -available during the program lifetime, but some considerations are -necessary for saved-states and threads. Saved-states to not store global -variables, which implies they have to be declared with initialization/1 -to recreate them after loading the saved state. Each thread has -its own set of global variables, starting with an empty set. Using -`thread_inititialization/1` to define a global variable it will be -defined, restored after reloading a saved state and created in all -threads that are created after the registration. - - -*/ - -/** @pred b_setval(+ _Name_,+ _Value_) - - -Associate the term _Value_ with the atom _Name_ or replaces -the currently associated value with _Value_. If _Name_ does -not refer to an existing global variable a variable with initial value -`[]` is created (the empty list). On backtracking the -assignment is reversed. - - -*/ - -/** @pred b_getval(+ _Name_,- _Value_) - - -Get the value associated with the global variable _Name_ and unify -it with _Value_. Note that this unification may further instantiate -the value of the global variable. If this is undesirable the normal -precautions (double negation or copy_term/2) must be taken. The -b_getval/2 predicate generates errors if _Name_ is not an atom or -the requested variable does not exist. - - -*/ - -/** @pred nb_setval(+ _Name_,+ _Value_) - - -Associates a copy of _Value_ created with duplicate_term/2 -with the atom _Name_. Note that this can be used to set an -initial value other than `[]` prior to backtrackable assignment. - - -*/ - -/** @pred nb_getval(+ _Name_,- _Value_) - - -The nb_getval/2 predicate is a synonym for b_getval/2, introduced for -compatibility and symmetry. As most scenarios will use a particular -global variable either using non-backtrackable or backtrackable -assignment, using nb_getval/2 can be used to document that the -variable is used non-backtrackable. - - -*/ - -/** @pred nb_current(? _Name_,? _Value_) - - -Enumerate all defined variables with their value. The order of -enumeration is undefined. - - -*/ - -/** @pred nb_delete(? _Name_) - -Delete the named global variable. - - - - */ - -/** @defgroup Compatibility_of_Global_Variables Compatibility of Global Variables -@ingroup YAPPackages -@{ - -Global variables have been introduced by various Prolog -implementations recently. YAP follows their implementation in SWI-Prolog, itself -based on hProlog by Bart Demoen. Jan and Bart -decided that the semantics if hProlog nb_setval/2, which is -equivalent to nb_linkval/2 is not acceptable for normal Prolog -users as the behaviour is influenced by how builtin predicates -constructing terms (read/1, =../2, etc.) are implemented. - -GNU-Prolog provides a rich set of global variables, including arrays. -Arrays can be implemented easily in SWI-Prolog using functor/3 and -`setarg/3` due to the unrestricted arity of compound terms. - -*/ - -/** @page Extensions Extensions to Prolog - -YAP includes a number of extensions over the original Prolog -language. Next, we discuss support to the most important ones. - - - */ - -/** @defgroup Rational_Trees Rational Trees -@ingroup YAPPackages -@{ - -Prolog unification is not a complete implementation. For efficiency -considerations, Prolog systems do not perform occur checks while -unifying terms. As an example, `X = a(X)` will not fail but instead -will create an infinite term of the form `a(a(a(a(a(...)))))`, or -rational tree. - -Rational trees are now supported by default in YAP. In previous -versions, this was not the default and these terms could easily lead -to infinite computation. For example, `X = a(X), X = X` would -enter an infinite loop. - -The `RATIONAL_TREES` flag improves support for these -terms. Internal primitives are now aware that these terms can exist, and -will not enter infinite loops. Hence, the previous unification will -succeed. Another example, `X = a(X), ground(X)` will succeed -instead of looping. Other affected built-ins include the term comparison -primitives, numbervars/3, copy_term/2, and the internal -data base routines. The support does not extend to Input/Output routines -or to assert/1 YAP does not allow directly reading -rational trees, and you need to use `write_depth/2` to avoid -entering an infinite cycle when trying to write an infinite term. - - - */ - -/** @defgroup CohYroutining Co-routining -@ingroup YAPPackages -@{ - -Prolog uses a simple left-to-right flow of control. It is sometimes -convenient to change this control so that goals will only be executed -when conditions are fulfilled. This may result in a more "data-driven" -execution, or may be necessary to correctly implement extensions such as -negation by default. - -The `COROUTINING` flag enables this option. Note that the support for -coroutining will in general slow down execution. - -The following declaration is supported: - -+ block/1 -The argument to `block/1` is a condition on a goal or a conjunction -of conditions, with each element separated by commas. Each condition is -of the form `predname( _C1_,..., _CN_)`, where _N_ is the -arity of the goal, and each _CI_ is of the form `-`, if the -argument must suspend until the first such variable is bound, or -`?`, otherwise. - -+ wait/1 -The argument to `wait/1` is a predicate descriptor or a conjunction -of these predicates. These predicates will suspend until their first -argument is bound. - - -The following primitives are supported: - - -*/ - -/** @pred dif( _X_, _Y_) - - -Succeed if the two arguments do not unify. A call to dif/2 will -suspend if unification may still succeed or fail, and will fail if they -always unify. - - -*/ - -/** @pred freeze(? _X_,: _G_) - - -Delay execution of goal _G_ until the variable _X_ is bound. - - -*/ - -/** @pred frozen( _X_, _G_) - - -Unify _G_ with a conjunction of goals suspended on variable _X_, -or `true` if no goal has suspended. - - -*/ - -/** @pred when(+ _C_,: _G_) - - -Delay execution of goal _G_ until the conditions _C_ are -satisfied. The conditions are of the following form: - -+ _C1_, _C2_ -Delay until both conditions _C1_ and _C2_ are satisfied. -+ _C1_; _C2_ -Delay until either condition _C1_ or condition _C2_ is satisfied. -+ ?=( _V1_, _C2_) -Delay until terms _V1_ and _V1_ have been unified. -+ nonvar( _V_) -Delay until variable _V_ is bound. -+ ground( _V_) -Delay until variable _V_ is ground. - - -Note that when/2 will fail if the conditions fail. - - -*/ - -/** @pred call_residue(: _G_, _L_) - - - -Call goal _G_. If subgoals of _G_ are still blocked, return -a list containing these goals and the variables they are blocked in. The -goals are then considered as unblocked. The next example shows a case -where dif/2 suspends twice, once outside call_residue/2, -and the other inside: - -~~~~~ -?- dif(X,Y), - call_residue((dif(X,Y),(X = f(Z) ; Y = f(Z))), L). - -X = f(Z), -L = [[Y]-dif(f(Z),Y)], -dif(f(Z),Y) ? ; - -Y = f(Z), -L = [[X]-dif(X,f(Z))], -dif(X,f(Z)) ? ; - -no -~~~~~ -The system only reports one invocation of dif/2 as having -suspended. - - -*/ - -/** @pred call_residue_vars(: _G_, _L_) - - - -Call goal _G_ and unify _L_ with a list of all constrained variables created during execution of _G_: - -~~~~~ - ?- dif(X,Z), call_residue_vars(dif(X,Y),L). -dif(X,Z), call_residue_vars(dif(X,Y),L). -L = [Y], -dif(X,Z), -dif(X,Y) ? ; - -no -~~~~~ - - - - - */ - -/** @defgroup Attributed_Variables Attributed Variables -@ingroup YAPPackages -@{ - -YAP supports attributed variables, originally developed at OFAI by -Christian Holzbaur. Attributes are a means of declaring that an -arbitrary term is a property for a variable. These properties can be -updated during forward execution. Moreover, the unification algorithm is -aware of attributed variables and will call user defined handlers when -trying to unify these variables. - -Attributed variables provide an elegant abstraction over which one can -extend Prolog systems. Their main application so far has been in -implementing constraint handlers, such as Holzbaur's CLPQR, Fruewirth -and Holzbaur's CHR, and CLP(BN). - -Different Prolog systems implement attributed variables in different -ways. Traditionally, YAP has used the interface designed by SICStus -Prolog. This interface is still -available in the atts library, but from YAP-6.0.3 we recommend using -the hProlog, SWI style interface. The main reason to do so is that -most packages included in YAP that use attributed variables, such as CHR, CLP(FD), and CLP(QR), -rely on the SWI-Prolog interface. - - - */ - -/** @defgroup New_Style_Attribute_Declarations hProlog and SWI-Prolog style Attribute Declarations -@ingroup YAPPackages -@{ - -The following documentation is taken from the SWI-Prolog manual. - -Binding an attributed variable schedules a goal to be executed at the -first possible opportunity. In the current implementation the hooks are -executed immediately after a successful unification of the clause-head -or successful completion of a foreign language (built-in) predicate. Each -attribute is associated to a module and the hook attr_unify_hook/2 is -executed in this module. The example below realises a very simple and -incomplete finite domain reasoner. - -~~~~~ -:- module(domain, - [ domain/2 % Var, ?Domain - ]). -:- use_module(library(ordsets)). - -domain(X, Dom) :- - var(Dom), !, - get_attr(X, domain, Dom). -domain(X, List) :- - list_to_ord_set(List, Domain), - put_attr(Y, domain, Domain), - X = Y. - -% An attributed variable with attribute value Domain has been -% assigned the value Y - -attr_unify_hook(Domain, Y) :- - ( get_attr(Y, domain, Dom2) - -> ord_intersection(Domain, Dom2, NewDomain), - ( NewDomain == [] - -> fail - ; NewDomain = [Value] - -> Y = Value - ; put_attr(Y, domain, NewDomain) - ) - ; var(Y) - -> put_attr( Y, domain, Domain ) - ; ord_memberchk(Y, Domain) - ). - -% Translate attributes from this module to residual goals - -attribute_goals(X) --> - { get_attr(X, domain, List) }, - [domain(X, List)]. -~~~~~ - -Before explaining the code we give some example queries: - -The predicate `domain/2` fetches (first clause) or assigns -(second clause) the variable a domain, a set of values it can -be unified with. In the second clause first associates the domain -with a fresh variable and then unifies X to this variable to deal -with the possibility that X already has a domain. The -predicate attr_unify_hook/2 is a hook called after a variable with -a domain is assigned a value. In the simple case where the variable -is bound to a concrete value we simply check whether this value is in -the domain. Otherwise we take the intersection of the domains and either -fail if the intersection is empty (first example), simply assign the -value if there is only one value in the intersection (second example) or -assign the intersection as the new domain of the variable (third -example). The nonterminal `attribute_goals/3` is used to translate -remaining attributes to user-readable goals that, when executed, reinstate -these attributes. - - - - @pred put_attr(+ _Var_,+ _Module_,+ _Value_) - - - -If _Var_ is a variable or attributed variable, set the value for the -attribute named _Module_ to _Value_. If an attribute with this -name is already associated with _Var_, the old value is replaced. -Backtracking will restore the old value (i.e., an attribute is a mutable -term. See also `setarg/3`). This predicate raises a representation error if - _Var_ is not a variable and a type error if _Module_ is not an atom. - - -*/ - -/** @pred get_attr(+ _Var_,+ _Module_,- _Value_) - - - -Request the current _value_ for the attribute named _Module_. If - _Var_ is not an attributed variable or the named attribute is not -associated to _Var_ this predicate fails silently. If _Module_ -is not an atom, a type error is raised. - - -*/ - -/** @pred del_attr(+ _Var_,+ _Module_) - - - -Delete the named attribute. If _Var_ loses its last attribute it -is transformed back into a traditional Prolog variable. If _Module_ -is not an atom, a type error is raised. In all other cases this -predicate succeeds regardless whether or not the named attribute is -present. - - -*/ - -/** @pred attr_unify_hook(+ _AttValue_,+ _VarValue_) - - - -Hook that must be defined in the module an attributed variable refers -to. Is is called after the attributed variable has been -unified with a non-var term, possibly another attributed variable. - _AttValue_ is the attribute that was associated to the variable -in this module and _VarValue_ is the new value of the variable. -Normally this predicate fails to veto binding the variable to - _VarValue_, forcing backtracking to undo the binding. If - _VarValue_ is another attributed variable the hook often combines -the two attribute and associates the combined attribute with - _VarValue_ using put_attr/3. - - -*/ - -/** @pred attr_portray_hook(+ _AttValue_,+ _Var_) - - - -Called by write_term/2 and friends for each attribute if the option -`attributes(portray)` is in effect. If the hook succeeds the -attribute is considered printed. Otherwise `Module = ...` is -printed to indicate the existence of a variable. - - -*/ - -/** @pred attribute_goals(+ _Var_,- _Gs_,+ _GsRest_) - - - -This nonterminal, if it is defined in a module, is used by _copy_term/3_ -to project attributes of that module to residual goals. It is also -used by the toplevel to obtain residual goals after executing a query. - - -Normal user code should deal with put_attr/3, get_attr/3 and del_attr/2. -The routines in this section fetch or set the entire attribute list of a -variables. Use of these predicates is anticipated to be restricted to -printing and other special purpose operations. - - - - @pred get_attrs(+ _Var_,- _Attributes_) - - - -Get all attributes of _Var_. _Attributes_ is a term of the form -`att( _Module_, _Value_, _MoreAttributes_)`, where _MoreAttributes_ is -`[]` for the last attribute. - - -*/ - -/** @pred put_attrs(+ _Var_,+ _Attributes_) - - -Set all attributes of _Var_. See get_attrs/2 for a description of - _Attributes_. - - -*/ - -/** @pred del_attrs(+ _Var_) - - -If _Var_ is an attributed variable, delete all its -attributes. In all other cases, this predicate succeeds without -side-effects. - - -*/ - -/** @pred term_attvars(+ _Term_,- _AttVars_) - - - _AttVars_ is a list of all attributed variables in _Term_ and -its attributes. I.e., term_attvars/2 works recursively through -attributes. This predicate is Cycle-safe. - - -*/ - -/** @pred copy_term(? _TI_,- _TF_,- _Goals_) - -Term _TF_ is a variant of the original term _TI_, such that for -each variable _V_ in the term _TI_ there is a new variable _V'_ -in term _TF_ without any attributes attached. Attributed -variables are thus converted to standard variables. _Goals_ is -unified with a list that represents the attributes. The goal -`maplist(call, _Goals_)` can be called to recreate the -attributes. - -Before the actual copying, `copy_term/3` calls -`attribute_goals/1` in the module where the attribute is -defined. - - -*/ - -/** @pred copy_term_nat(? _TI_,- _TF_) - - -As copy_term/2. Attributes however, are not copied but replaced -by fresh variables. - - - - - */ - -/** @defgroup Old_Style_Attribute_Declarations SICStus Prolog style Attribute Declarations -@ingroup YAPLibrary -@{ - -Old style attribute declarations are activated through loading the library atts . The command - -~~~~~ -| ?- use_module(library(atts)). -~~~~~ -enables this form of use of attributed variables. The package provides the -following functionality: - -+ Each attribute must be declared first. Attributes are described by a functor -and are declared per module. Each Prolog module declares its own sets of -attributes. Different modules may have different functors with the same -module. -+ The built-in put_atts/2 adds or deletes attributes to a -variable. The variable may be unbound or may be an attributed -variable. In the latter case, YAP discards previous values for the -attributes. -+ The built-in get_atts/2 can be used to check the values of -an attribute associated with a variable. -+ The unification algorithm calls the user-defined predicate -verify_attributes/3 before trying to bind an attributed -variable. Unification will resume after this call. -+ The user-defined predicate -attribute_goal/2 converts from an attribute to a goal. -+ The user-defined predicate -project_attributes/2 is used from a set of variables into a set of -constraints or goals. One application of project_attributes/2 is in -the top-level, where it is used to output the set of -floundered constraints at the end of a query. - - - - */ - -/** @defgroup Attribute_Declarations Attribute Declarations -@ingroup Old_Style_Attribute_Declarations -@{ - -Attributes are compound terms associated with a variable. Each attribute -has a name which is private to the module in which the -attribute was defined. Variables may have at most one attribute with a -name. Attribute names are defined with the following declaration: - -~~~~~ -:- attribute AttributeSpec, ..., AttributeSpec. -~~~~~ - -where each _AttributeSpec_ has the form ( _Name_/ _Arity_). -One single such declaration is allowed per module _Module_. - -Although the YAP module system is predicate based, attributes are local -to modules. This is implemented by rewriting all calls to the -built-ins that manipulate attributes so that attribute names are -preprocessed depending on the module. The `user:goal_expansion/3` -mechanism is used for this purpose. - - - */ - -/** @defgroup Attribute_Manipulation Attribute Manipulation -@ingroup Old_Style_Attribute_Declarations -@{ - -The attribute manipulation predicates always work as follows: - -+ The first argument is the unbound variable associated with -attributes, -+ The second argument is a list of attributes. Each attribute will -be a Prolog term or a constant, prefixed with the + and - unary -operators. The prefix + may be dropped for convenience. - -The following three procedures are available to the user. Notice that -these built-ins are rewritten by the system into internal built-ins, and -that the rewriting process depends on the module on which the -built-ins have been invoked. - - -*/ - -/** @pred _Module_:get_atts( _-Var_, _?ListOfAttributes_) - - -Unify the list _?ListOfAttributes_ with the attributes for the unbound -variable _Var_. Each member of the list must be a bound term of the -form `+( _Attribute_)`, `-( _Attribute_)` (the kbd -prefix may be dropped). The meaning of + and - is: -+ +( _Attribute_) -Unifies _Attribute_ with a corresponding attribute associated with - _Var_, fails otherwise. - -+ -( _Attribute_) -Succeeds if a corresponding attribute is not associated with - _Var_. The arguments of _Attribute_ are ignored. - - -*/ - -/** @pred _Module_:put_atts( _-Var_, _?ListOfAttributes_) - - -Associate with or remove attributes from a variable _Var_. The -attributes are given in _?ListOfAttributes_, and the action depends -on how they are prefixed: -+ +( _Attribute_) -Associate _Var_ with _Attribute_. A previous value for the -attribute is simply replace (like with `set_mutable/2`). - -+ -( _Attribute_) -Remove the attribute with the same name. If no such attribute existed, -simply succeed. - - - - */ - -/** @defgroup Attributed_Unification Attributed Unification -@ingroup Old_Style_Attribute_Declarations -@{ - -The user-predicate predicate verify_attributes/3 is called when -attempting to unify an attributed variable which might have attributes -in some _Module_. - - -*/ - -/** @pred _Module_:verify_attributes( _-Var_, _+Value_, _-Goals_) - - - -The predicate is called when trying to unify the attributed variable - _Var_ with the Prolog term _Value_. Note that _Value_ may be -itself an attributed variable, or may contain attributed variables. The -goal verify_attributes/3 is actually called before _Var_ is -unified with _Value_. - -It is up to the user to define which actions may be performed by -verify_attributes/3 but the procedure is expected to return in - _Goals_ a list of goals to be called after _Var_ is -unified with _Value_. If verify_attributes/3 fails, the -unification will fail. - -Notice that the verify_attributes/3 may be called even if _Var_< -has no attributes in module Module. In this case the routine should -simply succeed with _Goals_ unified with the empty list. - - -*/ - -/** @pred attvar( _-Var_) - - -Succeed if _Var_ is an attributed variable. - - - - */ - -/** @defgroup Displaying_Attributes Displaying Attributes -@ingroup Old_Style_Attribute_Declarations -@{ - -Attributes are usually presented as goals. The following routines are -used by built-in predicates such as call_residue/2 and by the -Prolog top-level to display attributes: - - -*/ - -/** @pred _Module_:attribute_goal( _-Var_, _-Goal_) -User-defined procedure, called to convert the attributes in _Var_ to -a _Goal_. Should fail when no interpretation is available. - - - - - */ - -/** @defgroup Projecting_Attributes Projecting Attributes -@ingroup Old_Style_Attribute_Declarations -@{ - -Constraint solvers must be able to project a set of constraints to a set -of variables. This is useful when displaying the solution to a goal, but -may also be used to manipulate computations. The user-defined -project_attributes/2 is responsible for implementing this -projection. - - -*/ - -/** @pred _Module_:project_attributes( _+QueryVars_, _+AttrVars_) - - -Given a list of variables _QueryVars_ and list of attributed -variables _AttrVars_, project all attributes in _AttrVars_ to - _QueryVars_. Although projection is constraint system dependent, -typically this will involve expressing all constraints in terms of - _QueryVars_ and considering all remaining variables as existentially -quantified. - - -Projection interacts with attribute_goal/2 at the Prolog top -level. When the query succeeds, the system first calls -project_attributes/2. The system then calls -attribute_goal/2 to get a user-level representation of the -constraints. Typically, attribute_goal/2 will convert from the -original constraints into a set of new constraints on the projection, -and these constraints are the ones that will have an -attribute_goal/2 handler. - - - */ - -/** @defgroup Attribute_Examples Attribute Examples -@ingroup Old_Style_Attribute_Declarations -@{ - -The following two examples example is taken from the SICStus Prolog manual. It -sketches the implementation of a simple finite domain `solver`. Note -that an industrial strength solver would have to provide a wider range -of functionality and that it quite likely would utilize a more efficient -representation for the domains proper. The module exports a single -predicate `domain( _-Var_, _?Domain_)` which associates - _Domain_ (a list of terms) with _Var_. A variable can be -queried for its domain by leaving _Domain_ unbound. - -We do not present here a definition for project_attributes/2. -Projecting finite domain constraints happens to be difficult. - -~~~~~ -:- module(domain, [domain/2]). - -:- use_module(library(atts)). -:- use_module(library(ordsets), [ - ord_intersection/3, - ord_intersect/2, - list_to_ord_set/2 - ]). - -:- attribute dom/1. - -verify_attributes(Var, Other, Goals) :- - get_atts(Var, dom(Da)), !, % are we involved? - ( var(Other) -> % must be attributed then - ( get_atts(Other, dom(Db)) -> % has a domain? - ord_intersection(Da, Db, Dc), - Dc = [El|Els], % at least one element - ( Els = [] -> % exactly one element - Goals = [Other=El] % implied binding - ; Goals = [], - put_atts(Other, dom(Dc))% rescue intersection - ) - ; Goals = [], - put_atts(Other, dom(Da)) % rescue the domain - ) - ; Goals = [], - ord_intersect([Other], Da) % value in domain? - ). -verify_attributes(_, _, []). % unification triggered - % because of attributes - % in other modules - -attribute_goal(Var, domain(Var,Dom)) :- % interpretation as goal - get_atts(Var, dom(Dom)). - -domain(X, Dom) :- - var(Dom), !, - get_atts(X, dom(Dom)). -domain(X, List) :- - list_to_ord_set(List, Set), - Set = [El|Els], % at least one element - ( Els = [] -> % exactly one element - X = El % implied binding - ; put_atts(Fresh, dom(Set)), - X = Fresh % may call - % verify_attributes/3 - ). -~~~~~ - -Note that the _implied binding_ `Other=El` was deferred until after -the completion of `verify_attribute/3`. Otherwise, there might be a -danger of recursively invoking `verify_attribute/3`, which might bind -`Var`, which is not allowed inside the scope of `verify_attribute/3`. -Deferring unifications into the third argument of `verify_attribute/3` -effectively serializes the calls to `verify_attribute/3`. - -Assuming that the code resides in the file domain.yap, we -can use it via: - -~~~~~ -| ?- use_module(domain). -~~~~~ - -Let's test it: - -~~~~~ -| ?- domain(X,[5,6,7,1]), domain(Y,[3,4,5,6]), domain(Z,[1,6,7,8]). - -domain(X,[1,5,6,7]), -domain(Y,[3,4,5,6]), -domain(Z,[1,6,7,8]) ? - -yes -| ?- domain(X,[5,6,7,1]), domain(Y,[3,4,5,6]), domain(Z,[1,6,7,8]), - X=Y. - -Y = X, -domain(X,[5,6]), -domain(Z,[1,6,7,8]) ? - -yes -| ?- domain(X,[5,6,7,1]), domain(Y,[3,4,5,6]), domain(Z,[1,6,7,8]), - X=Y, Y=Z. - -X = 6, -Y = 6, -Z = 6 -~~~~~ - -To demonstrate the use of the _Goals_ argument of -verify_attributes/3, we give an implementation of -freeze/2. We have to name it `myfreeze/2` in order to -avoid a name clash with the built-in predicate of the same name. - -~~~~~ -:- module(myfreeze, [myfreeze/2]). - -:- use_module(library(atts)). - -:- attribute frozen/1. - -verify_attributes(Var, Other, Goals) :- - get_atts(Var, frozen(Fa)), !, % are we involved? - ( var(Other) -> % must be attributed then - ( get_atts(Other, frozen(Fb)) % has a pending goal? - -> put_atts(Other, frozen((Fa,Fb))) % rescue conjunction - ; put_atts(Other, frozen(Fa)) % rescue the pending goal - ), - Goals = [] - ; Goals = [Fa] - ). -verify_attributes(_, _, []). - -attribute_goal(Var, Goal) :- % interpretation as goal - get_atts(Var, frozen(Goal)). - -myfreeze(X, Goal) :- - put_atts(Fresh, frozen(Goal)), - Fresh = X. -~~~~~ - -Assuming that this code lives in file myfreeze.yap, -we would use it via: - -~~~~~ -| ?- use_module(myfreeze). -| ?- myfreeze(X,print(bound(x,X))), X=2. - -bound(x,2) % side effect -X = 2 % bindings -~~~~~ - -The two solvers even work together: - -~~~~~ -| ?- myfreeze(X,print(bound(x,X))), domain(X,[1,2,3]), - domain(Y,[2,10]), X=Y. - -bound(x,2) % side effect -X = 2, % bindings -Y = 2 -~~~~~ - -The two example solvers interact via bindings to shared attributed -variables only. More complicated interactions are likely to be found -in more sophisticated solvers. The corresponding -verify_attributes/3 predicates would typically refer to the -attributes from other known solvers/modules via the module prefix in -` _Module_:get_atts/2`. - - - */ - -/** @defgroup CLPR Constraint Logic Programming over Reals -@ingroup YAPPackages -@{ - -YAP now uses the CLP(R) package developed by Leslie De Koninck, -K.U. Leuven as part of a thesis with supervisor Bart Demoen and daily -advisor Tom Schrijvers, and distributed with SWI-Prolog. - -This CLP(R) system is a port of the CLP(Q,R) system of Sicstus Prolog -and YAP by Christian Holzbaur: Holzbaur C.: OFAI clp(q,r) Manual, -Edition 1.3.3, Austrian Research Institute for Artificial -Intelligence, Vienna, TR-95-09, 1995, - This -port only contains the part concerning real arithmetics. This manual -is roughly based on the manual of the above mentioned *CLP(QR)* -implementation. - -Please note that the clpr library is not an -`autoload` library and therefore this library must be loaded -explicitely before using it: - -~~~~~ -:- use_module(library(clpr)). -~~~~~ - - - */ - -/** @defgroup CLPR_Solver_Predicates Solver Predicates -@ingroup CLPR -@{ - - -The following predicates are provided to work with constraints: - - -*/ - -/** @pred {+ _Constraints_} is det -Adds the constraints given by _Constraints_ to the constraint store. - - -*/ - -/** @pred entailed(+ _Constraint_) -Succeeds if _Constraint_ is necessarily true within the current -constraint store. This means that adding the negation of the constraint -to the store results in failure. - - -*/ - -/** @pred inf(+ _Expression_,- _Inf_) -Computes the infimum of _Expression_ within the current state of the -constraint store and returns that infimum in _Inf_. This predicate -does not change the constraint store. - - -*/ - -/** @pred inf(+ _Expression_,- _Sup_) -Computes the supremum of _Expression_ within the current state of -the constraint store and returns that supremum in _Sup_. This -predicate does not change the constraint store. - - -*/ - -/** @pred min(+ _Expression_) -Minimizes _Expression_ within the current constraint store. This is -the same as computing the infimum and equation the expression to that -infimum. - - -*/ - -/** @pred max(+ _Expression_) -Maximizes _Expression_ within the current constraint store. This is -the same as computing the supremum and equating the expression to that -supremum. - - -*/ - -/** @pred bb_inf(+ _Ints_,+ _Expression_,- _Inf_,- _Vertext_,+ _Eps_) -Computes the infimum of _Expression_ within the current constraint -store, with the additional constraint that in that infimum, all -variables in _Ints_ have integral values. _Vertex_ will contain -the values of _Ints_ in the infimum. _Eps_ denotes how much a -value may differ from an integer to be considered an integer. E.g. when - _Eps_ = 0.001, then X = 4.999 will be considered as an integer (5 in -this case). _Eps_ should be between 0 and 0.5. - - -*/ - -/** @pred bb_inf(+ _Ints_,+ _Expression_,- _Inf_) -The same as bb_inf/5 but without returning the values of the integers -and with an eps of 0.001. - - -*/ - -/** @pred dump(+ _Target_,+ _Newvars_,- _CodedAnswer_) -Returns the constraints on _Target_ in the list _CodedAnswer_ -where all variables of _Target_ have veen replaced by _NewVars_. -This operation does not change the constraint store. E.g. in - -~~~~~ -dump([X,Y,Z],[x,y,z],Cons) -~~~~~ - - _Cons_ will contain the constraints on _X_, _Y_ and - _Z_ where these variables have been replaced by atoms `x`, `y` and `z`. - - - - - */ - -/** @defgroup CLPR_Syntax Syntax of the predicate arguments -@ingroup YAPPackages -@{ - - -The arguments of the predicates defined in the subsection above are -defined in the following table. Failing to meet the syntax rules will -result in an exception. - -~~~~~ - ---> \ single constraint \ - | , \ conjunction \ - | ; \ disjunction \ - - ---> {<} \ less than \ - | {>} \ greater than \ - | {=<} \ less or equal \ - | {<=}(, ) \ less or equal \ - | {>=} \ greater or equal \ - | {=\=} \ not equal \ - | =:= \ equal \ - | = \ equal \ - - ---> \ Prolog variable \ - | \ Prolog number (float, integer) \ - | + \ unary plus \ - | - \ unary minus \ - | + \ addition \ - | - \ substraction \ - | * \ multiplication \ - | / \ division \ - | abs() \ absolute value \ - | sin() \ sine \ - | cos() \ cosine \ - | tan() \ tangent \ - | exp() \ exponent \ - | pow() \ exponent \ - | {^} \ exponent \ - | min(, ) \ minimum \ - | max(, ) \ maximum \ -~~~~~ - - - */ - -/** @defgroup CLPR_Unification Use of unification -@ingroup CLPR -@{ - -Instead of using the `{}/1` predicate, you can also use the standard -unification mechanism to store constraints. The following code samples -are equivalent: - -+ Unification with a variable - -~~~~~ -{X =:= Y} -{X = Y} -X = Y -~~~~~ - -+ Unification with a number - -~~~~~ -{X =:= 5.0} -{X = 5.0} -X = 5.0 -~~~~~ - - - - - */ - -/** @defgroup CLPR_NonhYlinear_Constraints Non-Linear Constraints -@ingroup CLPR -@{ - - -In this version, non-linear constraints do not get solved until certain -conditions are satisfied. We call these conditions the isolation axioms. -They are given in the following table. - -~~~~~ -A = B * C when B or C is ground or // A = 5 * C or A = B * 4 \\ - A and (B or C) are ground // 20 = 5 * C or 20 = B * 4 \\ - -A = B / C when C is ground or // A = B / 3 - A and B are ground // 4 = 12 / C - -X = min(Y,Z) when Y and Z are ground or // X = min(4,3) -X = max(Y,Z) Y and Z are ground // X = max(4,3) -X = abs(Y) Y is ground // X = abs(-7) - -X = pow(Y,Z) when X and Y are ground or // 8 = 2 ^ Z -X = exp(Y,Z) X and Z are ground // 8 = Y ^ 3 -X = Y ^ Z Y and Z are ground // X = 2 ^ 3 - -X = sin(Y) when X is ground or // 1 = sin(Y) -X = cos(Y) Y is ground // X = sin(1.5707) -X = tan(Y) -~~~~~ - -@section CHR CHR: Constraint Handling Rules -@ingroup YAPPackages - -This chapter is written by Tom Schrijvers, K.U. Leuven for the hProlog -system. Adjusted by Jan Wielemaker to fit the SWI-Prolog documentation -infrastructure and remove hProlog specific references. - -The CHR system of SWI-Prolog is the K.U.Leuven CHR system. The runtime -environment is written by Christian Holzbaur and Tom Schrijvers while the -compiler is written by Tom Schrijvers. Both are integrated with SWI-Prolog -and licenced under compatible conditions with permission from the authors. - -The main reference for SWI-Prolog's CHR system is: - -+ T. Schrijvers, and B. Demoen, The K.U.Leuven CHR System: Implementation and Application, First Workshop on Constraint Handling Rules: Selected -Contributions (Fruwirth, T. and Meister, M., eds.), pp. 1--5, 2004. - - - - */ - -/** @defgroup CHR_Introduction Introduction -@ingroup CHR -@{ - - -Constraint Handling Rules (CHR) is a committed-choice bottom-up language -embedded in Prolog. It is designed for writing constraint solvers and is -particularily useful for providing application-specific constraints. -It has been used in many kinds of applications, like scheduling, -model checking, abduction, type checking among many others. - -CHR has previously been implemented in other Prolog systems (SICStus, -Eclipse, Yap), Haskell and Java. This CHR system is based on the -compilation scheme and runtime environment of CHR in SICStus. - -In this documentation we restrict ourselves to giving a short overview -of CHR in general and mainly focus on elements specific to this -implementation. For a more thorough review of CHR we refer the reader to -[Freuhwirth:98]. More background on CHR can be found at the CHR web site. - - - */ - -/** @defgroup CHR_Syntax_and_Semantics Syntax and Semantics -@ingroup YAPPackages -@{ - - - - - */ - -/** @defgroup CHR_Syntax CHR Syntax -Wingroup CHR -@{ - -The syntax of CHR rules in hProlog is the following: - -~~~~~ -rules --> rule, rules. -rules --> []. - -rule --> name, actual_rule, pragma, [atom(`.`)]. - -name --> atom, [atom(`@`)]. -name --> []. - -actual_rule --> simplification_rule. -actual_rule --> propagation_rule. -actual_rule --> simpagation_rule. - -simplification_rule --> constraints, [atom(`<=>`)], guard, body. -propagation_rule --> constraints, [atom(`==>`)], guard, body. -simpagation_rule --> constraints, [atom(`\`)], constraints, [atom(`<=>`)], - guard, body. - -constraints --> constraint, constraint_id. -constraints --> constraint, [atom(`,`)], constraints. - -constraint --> compound_term. - -constraint_id --> []. -constraint_id --> [atom(`#`)], variable. - -guard --> []. -guard --> goal, [atom(`|`)]. - -body --> goal. - -pragma --> []. -pragma --> [atom(`pragma`)], actual_pragmas. - -actual_pragmas --> actual_pragma. -actual_pragmas --> actual_pragma, [atom(`,`)], actual_pragmas. - -actual_pragma --> [atom(`passive(`)], variable, [atom(`)`)]. - -~~~~~ - -Additional syntax-related terminology: - -+ *head:* the constraints in an `actual_rule` before -the arrow (either `<=>` or `==>`) - - - - */ - -/** @defgroup Semantics Semantics -@ingroup CHR -@{ - - -In this subsection the operational semantics of CHR in Prolog are presented -informally. They do not differ essentially from other CHR systems. - -When a constraint is called, it is considered an active constraint and -the system will try to apply the rules to it. Rules are tried and executed -sequentially in the order they are written. - -A rule is conceptually tried for an active constraint in the following -way. The active constraint is matched with a constraint in the head of -the rule. If more constraints appear in the head they are looked for -among the suspended constraints, which are called passive constraints in -this context. If the necessary passive constraints can be found and all -match with the head of the rule and the guard of the rule succeeds, then -the rule is committed and the body of the rule executed. If not all the -necessary passive constraint can be found, the matching fails or the -guard fails, then the body is not executed and the process of trying and -executing simply continues with the following rules. If for a rule, -there are multiple constraints in the head, the active constraint will -try the rule sequentially multiple times, each time trying to match with -another constraint. - -This process ends either when the active constraint disappears, i.e. it -is removed by some rule, or after the last rule has been processed. In -the latter case the active constraint becomes suspended. - -A suspended constraint is eligible as a passive constraint for an active -constraint. The other way it may interact again with the rules, is when -a variable appearing in the constraint becomes bound to either a nonvariable -or another variable involved in one or more constraints. In that case the -constraint is triggered, i.e. it becomes an active constraint and all -the rules are tried. - - - */ - -/** @defgroup Rule_Types -@ingroup CHR -@{ - -There are three different kinds of rules, each with their specific semantics: - -+ simplification -The simplification rule removes the constraints in its head and calls its body. - -+ propagation -The propagation rule calls its body exactly once for the constraints in -its head. - -+ simpagation -The simpagation rule removes the constraints in its head after the -`\` and then calls its body. It is an optimization of -simplification rules of the form: \[constraints_1, constraints_2 <=> -constraints_1, body \] Namely, in the simpagation form: - -~~~~~ -constraints1 \ constraints2 <=> body -~~~~~ - _constraints1_ -constraints are not called in the body. - - - - */ - -/** @defgroup CHR_Rule_Names Rule Names -@ingroup CHR -@{ - -Naming a rule is optional and has no semantical meaning. It only functions -as documentation for the programmer. - - - */ - -/** @defgroup CHRPragmas Pragmas -@ingroup CHR_Rule_Names -@{ - -The semantics of the pragmas are: - -+ passive(Identifier) -The constraint in the head of a rule _Identifier_ can only act as a -passive constraint in that rule. - - -Additional pragmas may be released in the future. - - - */ - -/** @defgroup CHR_Options Options -@ingroup CHR_Rule_Names -@{ - -It is possible to specify options that apply to all the CHR rules in the module. -Options are specified with the `option/2` declaration: - -~~~~~ - option(Option,Value). -~~~~~ - -Available options are: - -+ check_guard_bindings -This option controls whether guards should be checked for illegal -variable bindings or not. Possible values for this option are -`on`, to enable the checks, and `off`, to disable the -checks. - -+ optimize -This is an experimental option controlling the degree of optimization. -Possible values are `full`, to enable all available -optimizations, and `off` (default), to disable all optimizations. -The default is derived from the SWI-Prolog flag `optimise`, where -`true` is mapped to `full`. Therefore the commandline -option `-O` provides full CHR optimization. -If optimization is enabled, debugging should be disabled. - -+ debug -This options enables or disables the possibility to debug the CHR code. -Possible values are `on` (default) and `off`. See -`debugging` for more details on debugging. The default is -derived from the prolog flag `generate_debug_info`, which -is `true` by default. See `-nodebug`. -If debugging is enabled, optimization should be disabled. - -+ mode -This option specifies the mode for a particular constraint. The -value is a term with functor and arity equal to that of a constraint. -The arguments can be one of `-`, `+` or `?`. -The latter is the default. The meaning is the following: - -+ - -The corresponding argument of every occurrence -of the constraint is always unbound. -+ + -The corresponding argument of every occurrence -of the constraint is always ground. -+ ? -The corresponding argument of every occurrence -of the constraint can have any instantiation, which may change -over time. This is the default value. - -The declaration is used by the compiler for various optimizations. -Note that it is up to the user the ensure that the mode declaration -is correct with respect to the use of the constraint. -This option may occur once for each constraint. - -+ type_declaration -This option specifies the argument types for a particular constraint. The -value is a term with functor and arity equal to that of a constraint. -The arguments can be a user-defined type or one of -the built-in types: - -+ int -The corresponding argument of every occurrence -of the constraint is an integer number. -+ float -...{} a floating point number. -+ number -...{} a number. -+ natural -...{} a positive integer. -+ any -The corresponding argument of every occurrence -of the constraint can have any type. This is the default value. - - -Currently, type declarations are only used to improve certain -optimizations (guard simplification, occurrence subsumption, ...{}). - -+ type_definition -This option defines a new user-defined type which can be used in -type declarations. The value is a term of the form -`type(` _name_`,` _list_`)`, where - _name_ is a term and _list_ is a list of alternatives. -Variables can be used to define generic types. Recursive definitions -are allowed. Examples are - -~~~~~ -type(bool,[true,false]). -type(complex_number,[float + float * i]). -type(binary_tree(T),[ leaf(T) | node(binary_tree(T),binary_tree(T)) ]). -type(list(T),[ [] | [T | list(T)]). -~~~~~ - - - -The mode, type_declaration and type_definition options are provided -for backward compatibility. The new syntax is described below. - - - */ - -/** @defgroup CHR_in_YAP_Programs CHR in YAP Programs -@ingroup CHR -@{ - - -The CHR constraints defined in a particulary chr file are -associated with a module. The default module is `user`. One should -never load different chr files with the same CHR module name. - - - */ - -/** @defgroup Constraint_declaration Constraint declaration -@ingroup CHR_in_YAP_Programs -@{ - - -Every constraint used in CHR rules has to be declared. -There are two ways to do this. The old style is as follows: - -~~~~~ -option(type_definition,type(list(T),[ [] , [T|list(T)] ]). -option(mode,foo(+,?)). -option(type_declaration,foo(list(int),float)). -:- constraints foo/2, bar/0. -~~~~~ - -The new style is as follows: - -~~~~~ -:- chr_type list(T) ---> [] ; [T|list(T)]. -:- constraints foo(+list(int),?float), bar. -~~~~~ - - - */ - -/** @defgroup Compilation Compilation - -The@{ - SWI-Prolog CHR compiler exploits term_expansion/2 rules to translate -the constraint handling rules to plain Prolog. These rules are loaded -from the library chr. They are activated if the compiled file -has the chr extension or after finding a declaration of the -format below. - -~~~~~ -:- constraints ... -~~~~~ - -It is adviced to define CHR rules in a module file, where the module -declaration is immediately followed by including the chr -library as examplified below: - -~~~~~ -:- module(zebra, [ zebra/0 ]). -:- use_module(library(chr)). - -:- constraints ... -~~~~~ - -Using this style CHR rules can be defined in ordinary Prolog -pl files and the operator definitions required by CHR do not -leak into modules where they might cause conflicts. - - - */ - -/** @defgroup CHR_Debugging Debugging -@ingroup CHR -@{ - - - -The CHR debugging facilities are currently rather limited. Only tracing -is currently available. To use the CHR debugging facilities for a CHR -file it must be compiled for debugging. Generating debug info is -controlled by the CHR option debug, whose default is derived -from the SWI-Prolog flag `generate_debug_info`. Therefore debug -info is provided unless the `-nodebug` is used. - - - */ - -/** @defgroup Ports Ports -@ingroup CHR -@{ - - -For CHR constraints the four standard ports are defined: - -+ call -A new constraint is called and becomes active. -+ exit -An active constraint exits: it has either been inserted in the store after -trying all rules or has been removed from the constraint store. -+ fail -An active constraint fails. -+ redo -An active constraint starts looking for an alternative solution. - - -In addition to the above ports, CHR constraints have five additional -ports: - -+ wake -A suspended constraint is woken and becomes active. -+ insert -An active constraint has tried all rules and is suspended in -the constraint store. -+ remove -An active or passive constraint is removed from the constraint -store, if it had been inserted. -+ try -An active constraints tries a rule with possibly -some passive constraints. The try port is entered -just before committing to the rule. -+ apply -An active constraints commits to a rule with possibly -some passive constraints. The apply port is entered -just after committing to the rule. - - - - */ - -/** @defgroup Tracing Tracing -@ingroup CHR -@{ - - -Tracing is enabled with the chr_trace/0 predicate -and disabled with the chr_notrace/0 predicate. - -When enabled the tracer will step through the `call`, -`exit`, `fail`, `wake` and `apply` ports, -accepting debug commands, and simply write out the other ports. - -The following debug commans are currently supported: - -~~~~~ - CHR debug options: - - creep c creep - s skip - g ancestors - n nodebug - b break - a abort - f fail - ? help h help -~~~~~ - -Their meaning is: - -+ creep -Step to the next port. -+ skip -Skip to exit port of this call or wake port. -+ ancestors -Print list of ancestor call and wake ports. -+ nodebug -Disable the tracer. -+ break -Enter a recursive Prolog toplevel. See break/0. -+ abort -Exit to the toplevel. See abort/0. -+ fail -Insert failure in execution. -+ help -Print the above available debug options. - - - - */ - -/** @defgroup CHR_Debugging_Predicates CHR Debugging Predicates -@ingroup CHR -@{ - - -The chr module contains several predicates that allow -inspecting and printing the content of the constraint store. - -+ chr_trace -Activate the CHR tracer. By default the CHR tracer is activated and -deactivated automatically by the Prolog predicates trace/0 and -notrace/0. - - -*/ - -/** @pred chr_notrace -De-activate the CHR tracer. By default the CHR tracer is activated and -deactivated automatically by the Prolog predicates trace/0 and -notrace/0. - -+ chr_leash/0 - -Define the set of CHR ports on which the CHR -tracer asks for user intervention (i.e. stops). _Spec_ is either a -list of ports or a predefined `alias`. Defined aliases are: -`full` to stop at all ports, `none` or `off` to never -stop, and `default` to stop at the `call`, `exit`, -`fail`, `wake` and `apply` ports. See also leash/1. - - -*/ - -/** @pred chr_show_store(+ _Mod_) -Prints all suspended constraints of module _Mod_ to the standard -output. This predicate is automatically called by the SWI-Prolog toplevel at -the end of each query for every CHR module currently loaded. The prolog-flag -`chr_toplevel_show_store` controls whether the toplevel shows the -constraint stores. The value `true` enables it. Any other value -disables it. - - - - - */ - -/** @defgroup CHR_Examples Examples -@ingroup CHR -@{ - - - -Here are two example constraint solvers written in CHR. - -+ -The program below defines a solver with one constraint, -`leq/2`, which is a less-than-or-equal constraint. - -~~~~~ -:- module(leq,[cycle/3, leq/2]). -:- use_module(library(chr)). - -:- constraints leq/2. -reflexivity @ leq(X,X) <=> true. -antisymmetry @ leq(X,Y), leq(Y,X) <=> X = Y. -idempotence @ leq(X,Y) \ leq(X,Y) <=> true. -transitivity @ leq(X,Y), leq(Y,Z) ==> leq(X,Z). - -cycle(X,Y,Z):- - leq(X,Y), - leq(Y,Z), - leq(Z,X). -~~~~~ - -+ -The program below implements a simple finite domain -constraint solver. - -~~~~~ -:- module(dom,[dom/2]). -:- use_module(library(chr)). - -:- constraints dom/2. - -dom(X,[]) <=> fail. -dom(X,[Y]) <=> X = Y. -dom(X,L1), dom(X,L2) <=> intersection(L1,L2,L3), dom(X,L3). - -intersection([],_,[]). -intersection([H|T],L2,[H|L3]) :- - member(H,L2), !, - intersection(T,L2,L3). -intersection([_|T],L2,L3) :- - intersection(T,L2,L3). -~~~~~ - - - - - */ - -/** @defgroup CHR_Compatibility Compatibility with SICStus CHR -@ingroup YAPPackages -@{ - - - -There are small differences between CHR in SWI-Prolog and newer -YAPs and SICStus and older versions of YAP. Besides differences in -available options and pragmas, the following differences should be -noted: - -+ [The handler/1 declaration] -In SICStus every CHR module requires a `handler/1` -declaration declaring a unique handler name. This declaration is valid -syntax in SWI-Prolog, but will have no effect. A warning will be given -during compilation. - -+ [The rules/1 declaration] -In SICStus, for every CHR module it is possible to only enable a subset -of the available rules through the `rules/1` declaration. The -declaration is valid syntax in SWI-Prolog, but has no effect. A -warning is given during compilation. - -+ [Sourcefile naming] -SICStus uses a two-step compiler, where chr files are -first translated into pl files. For SWI-Prolog CHR -rules may be defined in a file with any extension. - - - - */ - -/** @defgroup CHR_Guidelines Guidelines -@ingroup YAPPackages -@{ - - - -In this section we cover several guidelines on how to use CHR to write -constraint solvers and how to do so efficiently. - -+ [Set semantics] -The CHR system allows the presence of identical constraints, i.e. -multiple constraints with the same functor, arity and arguments. For -most constraint solvers, this is not desirable: it affects efficiency -and possibly termination. Hence appropriate simpagation rules should be -added of the form: - -~~~~~ -{constraint \ constraint <=> true}. -~~~~~ - -+ [Multi-headed rules] -Multi-headed rules are executed more efficiently when the constraints -share one or more variables. - -+ [Mode and type declarations] -Provide mode and type declarations to get more efficient program execution. -Make sure to disable debug (`-nodebug`) and enable optimization -(`-O`). - - - - */ - -/** @defgroup Logtalk Logtalk -@ingroup YAPPackages -@{ - -The Logtalk object-oriented extension is available after running its -standalone installer by using the `yaplgt` command in POSIX -systems or by using the `Logtalk - YAP` shortcut in the Logtalk -program group in the Start Menu on Windows systems. For more information -please see the URL . - - -\copydoc real - - - */ - -/** @defgroup Threads Threads -@ingroup YAPBuiltins -@{ - -YAP implements a SWI-Prolog compatible multithreading -library. Like in SWI-Prolog, Prolog threads have their own stacks and -only share the Prolog heap: predicates, records, flags and other -global non-backtrackable data. The package is based on the POSIX thread -standard (Butenhof:1997:PPT) used on most popular systems except -for MS-Windows. - - - */ - -/** @defgroup Creating_and_Destroying_Prolog_Threads Creating and Destroying Prolog Threads -@ingroup Threads -@{ - - - - @pred thread_create(: _Goal_, - _Id_, + _Options_) - - - -Create a new Prolog thread (and underlying C-thread) and start it -by executing _Goal_. If the thread is created successfully, the -thread-identifier of the created thread is unified to _Id_. - _Options_ is a list of options. Currently defined options are: - -+ stack -Set the limit in K-Bytes to which the Prolog stacks of -this thread may grow. If omitted, the limit of the calling thread is -used. See also the commandline `-S` option. - -+ trail -Set the limit in K-Bytes to which the trail stack of this thread may -grow. If omitted, the limit of the calling thread is used. See also the -commandline option `-T`. - -+ alias -Associate an alias-name with the thread. This named may be used to -refer to the thread and remains valid until the thread is joined -(see thread_join/2). - -+ at_exit -Define an exit hook for the thread. This hook is called when the thread -terminates, no matter its exit status. - -+ detached -If `false` (default), the thread can be waited for using -thread_join/2. thread_join/2 must be called on this thread -to reclaim the all resources associated to the thread. If `true`, -the system will reclaim all associated resources automatically after the -thread finishes. Please note that thread identifiers are freed for reuse -after a detached thread finishes or a normal thread has been joined. -See also thread_join/2 and thread_detach/1. - - -The _Goal_ argument is copied to the new Prolog engine. -This implies further instantiation of this term in either thread does -not have consequences for the other thread: Prolog threads do not share -data from their stacks. - - -*/ - -/** @pred thread_create(: _Goal_, - _Id_) - - -Create a new Prolog thread using default options. See thread_create/3. - - -*/ - -/** @pred thread_create(: _Goal_) - - -Create a new Prolog detached thread using default options. See thread_create/3. - - -*/ - -/** @pred thread_self(- _Id_) - - -Get the Prolog thread identifier of the running thread. If the thread -has an alias, the alias-name is returned. - - -*/ - -/** @pred thread_join(+ _Id_, - _Status_) - - -Wait for the termination of thread with given _Id_. Then unify the -result-status of the thread with _Status_. After this call, - _Id_ becomes invalid and all resources associated with the thread -are reclaimed. Note that threads with the attribute `detached` -`true` cannot be joined. See also current_thread/2. - -A thread that has been completed without thread_join/2 being -called on it is partly reclaimed: the Prolog stacks are released and the -C-thread is destroyed. A small data-structure representing the -exit-status of the thread is retained until thread_join/2 is called on -the thread. Defined values for _Status_ are: - -+ true -The goal has been proven successfully. - -+ false -The goal has failed. - -+ exception( _Term_) -The thread is terminated on an -exception. See print_message/2 to turn system exceptions into -readable messages. - -+ exited( _Term_) -The thread is terminated on thread_exit/1 using the argument _Term_. - - -+ thread_detach(+ _Id_) - - -Switch thread into detached-state (see `detached` option at -thread_create/3 at runtime. _Id_ is the identifier of the thread -placed in detached state. - -One of the possible applications is to simplify debugging. Threads that -are created as `detached` leave no traces if they crash. For -not-detached threads the status can be inspected using -current_thread/2. Threads nobody is waiting for may be created -normally and detach themselves just before completion. This way they -leave no traces on normal completion and their reason for failure can be -inspected. - - -*/ - -/** @pred thread_yield - - -Voluntarily relinquish the processor. - - -*/ - -/** @pred thread_exit(+ _Term_) - - -Terminates the thread immediately, leaving `exited( _Term_)` as -result-state for thread_join/2. If the thread has the attribute -`detached` `true` it terminates, but its exit status cannot be -retrieved using thread_join/2 making the value of _Term_ -irrelevant. The Prolog stacks and C-thread are reclaimed. - - -*/ - -/** @pred thread_at_exit(: _Term_) - - -Run _Goal_ just before releasing the thread resources. This is to -be compared to `at_halt/1`, but only for the current -thread. These hooks are ran regardless of why the execution of the -thread has been completed. As these hooks are run, the return-code is -already available through thread_property/2 using the result of -thread_self/1 as thread-identifier. If you want to guarantee the -execution of an exit hook no matter how the thread terminates (the thread -can be aborted before reaching the thread_at_exit/1 call), consider -using instead the `at_exit/1` option of thread_create/3. - - -*/ - -/** @pred thread_setconcurrency(+ _Old_, - _New_) - - -Determine the concurrency of the process, which is defined as the -maximum number of concurrently active threads. `Active` here means -they are using CPU time. This option is provided if the -thread-implementation provides -`pthread_setconcurrency()`. Solaris is a typical example of this -family. On other systems this predicate unifies _Old_ to 0 (zero) -and succeeds silently. - - -*/ - -/** @pred thread_sleep(+ _Time_) - - -Make current thread sleep for _Time_ seconds. _Time_ may be an -integer or a floating point number. When time is zero or a negative value -the call succeeds and returns immediately. This call should not be used if -alarms are also being used. - - - - */ - -/** @defgroup Monitoring_Threads Monitoring Threads -@ingroup Threads -@{ - -Normal multi-threaded applications should not need these the predicates -from this section because almost any usage of these predicates is -unsafe. For example checking the existence of a thread before signalling -it is of no use as it may vanish between the two calls. Catching -exceptions using catch/3 is the only safe way to deal with -thread-existence errors. - -These predicates are provided for diagnosis and monitoring tasks. - - -*/ - -/** @pred thread_property(? _Id_, ? _Property_) - - -Enumerates the properties of the specified thread. -Calling thread_property/2 does not influence any thread. See also -thread_join/2. For threads that have an alias-name, this name can -be used in _Id_ instead of the numerical thread identifier. - _Property_ is one of: - -+ status( _Status_) -The thread status of a thread (see below). - -+ alias( _Alias_) -The thread alias, if it exists. - -+ at_exit( _AtExit_) -The thread exit hook, if defined (not available if the thread is already terminated). - -+ detached( _Boolean_) -The detached state of the thread. - -+ stack( _Size_) -The thread stack data-area size. - -+ trail( _Size_) -The thread trail data-area size. - -+ system( _Size_) -The thread system data-area size. - - - -*/ - -/** @pred current_thread(+ _Id_, - _Status_) - - -Enumerates identifiers and status of all currently known threads. -Calling current_thread/2 does not influence any thread. See also -thread_join/2. For threads that have an alias-name, this name is -returned in _Id_ instead of the numerical thread identifier. - _Status_ is one of: - -+ running -The thread is running. This is the initial status of a thread. Please -note that threads waiting for something are considered running too. - -+ false -The _Goal_ of the thread has been completed and failed. - -+ true -The _Goal_ of the thread has been completed and succeeded. - -+ exited( _Term_) -The _Goal_ of the thread has been terminated using thread_exit/1 -with _Term_ as argument. If the underlying native thread has -exited (using pthread_exit()) _Term_ is unbound. - -+ exception( _Term_) -The _Goal_ of the thread has been terminated due to an uncaught -exception (see throw/1 and catch/3). - - - -*/ - -/** @pred thread_statistics(+ _Id_, + _Key_, - _Value_) - - -Obtains statistical information on thread _Id_ as `statistics/2` -does in single-threaded applications. This call returns all keys -of `statistics/2`, although only information statistics about the -stacks and CPU time yield different values for each thread. - -+ mutex_statistics - - -Print usage statistics on internal mutexes and mutexes associated -with dynamic predicates. For each mutex two numbers are printed: -the number of times the mutex was acquired and the number of -collisions: the number times the calling thread has to -wait for the mutex. The collision-count is not available on -Windows as this would break portability to Windows-95/98/ME or -significantly harm performance. Generally collision count is -close to zero on single-CPU hardware. - -+ threads - - -Prints a table of current threads and their status. - - - - */ - -/** @defgroup Thread_Communication Thread communication -@ingroup Threads -@{ - -Prolog threads can exchange data using dynamic predicates, database -records, and other globally shared data. These provide no suitable means -to wait for data or a condition as they can only be checked in an -expensive polling loop. Message queues provide a means for -threads to wait for data or conditions without using the CPU. - -Each thread has a message-queue attached to it that is identified -by the thread. Additional queues are created using -`message_queue_create/2`. - - - - @pred thread_send_message(+ _Term_) - - -Places _Term_ in the message-queue of the thread running the goal. -Any term can be placed in a message queue, but note that the term is -copied to the receiving thread and variable-bindings are thus lost. -This call returns immediately. - - -*/ - -/** @pred thread_send_message(+ _QueueOrThreadId_, + _Term_) - -Place _Term_ in the given queue or default queue of the indicated -thread (which can even be the message queue of itself (see -thread_self/1). Any term can be placed in a message queue, but note that -the term is copied to the receiving thread and variable-bindings are -thus lost. This call returns immediately. - -If more than one thread is waiting for messages on the given queue and -at least one of these is waiting with a partially instantiated - _Term_, the waiting threads are all sent a wakeup signal, -starting a rush for the available messages in the queue. This behaviour -can seriously harm performance with many threads waiting on the same -queue as all-but-the-winner perform a useless scan of the queue. If -there is only one waiting thread or all waiting threads wait with an -unbound variable an arbitrary thread is restarted to scan the queue. - - - - - -*/ - -/** @pred thread_get_message(? _Term_) - - -Examines the thread message-queue and if necessary blocks execution -until a term that unifies to _Term_ arrives in the queue. After -a term from the queue has been unified unified to _Term_, the -term is deleted from the queue and this predicate returns. - -Please note that not-unifying messages remain in the queue. After -the following has been executed, thread 1 has the term `gnu` -in its queue and continues execution using _A_ is `gnat`. - -~~~~~ - - thread_get_message(a(A)), - - - thread_send_message(b(gnu)), - thread_send_message(a(gnat)), -~~~~~ - -See also thread_peek_message/1. - - -*/ - -/** @pred message_queue_create(? _Queue_) - - -If _Queue_ is an atom, create a named queue. To avoid ambiguity -on `thread_send_message/2`, the name of a queue may not be in use -as a thread-name. If _Queue_ is unbound an anonymous queue is -created and _Queue_ is unified to its identifier. - - -*/ - -/** @pred message_queue_destroy(+ _Queue_) - - -Destroy a message queue created with message_queue_create/1. It is -not allows to destroy the queue of a thread. Neither is it -allowed to destroy a queue other threads are waiting for or, for -anonymous message queues, may try to wait for later. - - -*/ - -/** @pred thread_get_message(+ _Queue_, ? _Term_) - -As thread_get_message/1, operating on a given queue. It is allowed to -peek into another thread's message queue, an operation that can be used -to check whether a thread has swallowed a message sent to it. - - -*/ - -/** @pred thread_peek_message(? _Term_) - - -Examines the thread message-queue and compares the queued terms -with _Term_ until one unifies or the end of the queue has been -reached. In the first case the call succeeds (possibly instantiating - _Term_. If no term from the queue unifies this call fails. - - -*/ - -/** @pred thread_peek_message(+ _Queue_, ? _Term_) - -As thread_peek_message/1, operating on a given queue. It is allowed to -peek into another thread's message queue, an operation that can be used -to check whether a thread has swallowed a message sent to it. - - - -Explicit message queues are designed with the worker-pool model -in mind, where multiple threads wait on a single queue and pick up the -first goal to execute. Below is a simple implementation where the -workers execute arbitrary Prolog goals. Note that this example provides -no means to tell when all work is done. This must be realised using -additional synchronisation. - -~~~~~ -% create_workers(+Id, +N) -% -% Create a pool with given Id and number of workers. - -create_workers(Id, N) :- - message_queue_create(Id), - forall(between(1, N, _), - thread_create(do_work(Id), _, [])). - -do_work(Id) :- - repeat, - thread_get_message(Id, Goal), - ( catch(Goal, E, print_message(error, E)) - -> true - ; print_message(error, goal_failed(Goal, worker(Id))) - ), - fail. - -% work(+Id, +Goal) -% -% Post work to be done by the pool - -work(Id, Goal) :- - thread_send_message(Id, Goal). -~~~~~ - - - */ - -/** @defgroup Signalling_Threads Signalling Threads -@ingroup Threadas -@{ - -These predicates provide a mechanism to make another thread execute some -goal as an interrupt. Signalling threads is safe as these -interrupts are only checked at safe points in the virtual machine. -Nevertheless, signalling in multi-threaded environments should be -handled with care as the receiving thread may hold a mutex -(see with_mutex/2). Signalling probably only makes sense to start -debugging threads and to cancel no-longer-needed threads with throw/1, -where the receiving thread should be designed carefully do handle -exceptions at any point. - - -*/ - -/** @pred thread_signal(+ _ThreadId_, : _Goal_) - - -Make thread _ThreadId_ execute _Goal_ at the first -opportunity. In the current implementation, this implies at the first -pass through the Call-port. The predicate thread_signal/2 -itself places _Goal_ into the signalled-thread's signal queue -and returns immediately. - -Signals (interrupts) do not cooperate well with the world of -multi-threading, mainly because the status of mutexes cannot be -guaranteed easily. At the call-port, the Prolog virtual machine -holds no locks and therefore the asynchronous execution is safe. - - _Goal_ can be any valid Prolog goal, including throw/1 to make -the receiving thread generate an exception and trace/0 to start -tracing the receiving thread. - - - - - */ - -/** @defgroup Threads_and_Dynamic_Predicates Threads and Dynamic Predicates -@ingroup Threads -@{ - -Besides queues threads can share and exchange data using dynamic -predicates. The multi-threaded version knows about two types of -dynamic predicates. By default, a predicate declared dynamic -(see dynamic/1) is shared by all threads. Each thread may -assert, retract and run the dynamic predicate. Synchronisation inside -Prolog guarantees the consistency of the predicate. Updates are -logical: visible clauses are not affected by assert/retract -after a query started on the predicate. In many cases primitive from -thread synchronisation should be used to ensure application invariants on -the predicate are maintained. - -Besides shared predicates, dynamic predicates can be declared with the -thread_local/1 directive. Such predicates share their -attributes, but the clause-list is different in each thread. - - -*/ - -/** @pred thread_local( _+Functor/Arity_) - - -related to the dynamic/1 directive. It tells the system that the -predicate may be modified using assert/1, retract/1, -etc, during execution of the program. Unlike normal shared dynamic -data however each thread has its own clause-list for the predicate. -As a thread starts, this clause list is empty. If there are still -clauses as the thread terminates these are automatically reclaimed by -the system. The `thread_local` property implies -the property `dynamic`. - -Thread-local dynamic predicates are intended for maintaining -thread-specific state or intermediate results of a computation. - -It is not recommended to put clauses for a thread-local predicate into -a file as in the example below as the clause is only visible from the -thread that loaded the source-file. All other threads start with an -empty clause-list. - -~~~~~ -:- thread_local - foo/1. - -foo(gnat). -~~~~~ - - - - - */ - -/** @defgroup Thread_Synchronisation Thread Synchronisation - -All@{ - internal Prolog operations are thread-safe. This implies two Prolog -threads can operate on the same dynamic predicate without corrupting the -consistency of the predicate. This section deals with user-level -mutexes (called monitors in ADA or -critical-sections by Microsoft). A mutex is a -MUTual EXclusive device, which implies at most one thread -can hold a mutex. - -Mutexes are used to realise related updates to the Prolog database. -With `related', we refer to the situation where a `transaction' implies -two or more changes to the Prolog database. For example, we have a -predicate `address/2`, representing the address of a person and we want -to change the address by retracting the old and asserting the new -address. Between these two operations the database is invalid: this -person has either no address or two addresses, depending on the -assert/retract order. - -Here is how to realise a correct update: - -~~~~~ -:- initialization - mutex_create(addressbook). - -change_address(Id, Address) :- - mutex_lock(addressbook), - retractall(address(Id, _)), - asserta(address(Id, Address)), - mutex_unlock(addressbook). -~~~~~ - - -*/ - -/** @pred mutex_create(? _MutexId_) - - -Create a mutex. if _MutexId_ is an atom, a named mutex is -created. If it is a variable, an anonymous mutex reference is returned. -There is no limit to the number of mutexes that can be created. - - -*/ - -/** @pred mutex_destroy(+ _MutexId_) - - -Destroy a mutex. After this call, _MutexId_ becomes invalid and -further references yield an `existence_error` exception. - - -*/ - -/** @pred with_mutex(+ _MutexId_, : _Goal_) - - -Execute _Goal_ while holding _MutexId_. If _Goal_ leaves -choicepoints, these are destroyed (as in once/1). The mutex is unlocked -regardless of whether _Goal_ succeeds, fails or raises an exception. -An exception thrown by _Goal_ is re-thrown after the mutex has been -successfully unlocked. See also `mutex_create/2`. - -Although described in the thread-section, this predicate is also -available in the single-threaded version, where it behaves simply as -once/1. - - -*/ - -/** @pred mutex_lock(+ _MutexId_) - - -Lock the mutex. Prolog mutexes are recursive mutexes: they -can be locked multiple times by the same thread. Only after unlocking -it as many times as it is locked, the mutex becomes available for -locking by other threads. If another thread has locked the mutex the -calling thread is suspended until to mutex is unlocked. - -If _MutexId_ is an atom, and there is no current mutex with that -name, the mutex is created automatically using mutex_create/1. This -implies named mutexes need not be declared explicitly. - -Please note that locking and unlocking mutexes should be paired -carefully. Especially make sure to unlock mutexes even if the protected -code fails or raises an exception. For most common cases use -with_mutex/2, which provides a safer way for handling Prolog-level -mutexes. - - -*/ - -/** @pred mutex_trylock(+ _MutexId_) - - -As mutex_lock/1, but if the mutex is held by another thread, this -predicates fails immediately. - - -*/ - -/** @pred mutex_unlock(+ _MutexId_) - - -Unlock the mutex. This can only be called if the mutex is held by the -calling thread. If this is not the case, a `permission_error` -exception is raised. - - -*/ - -/** @pred mutex_unlock_all - - -Unlock all mutexes held by the current thread. This call is especially -useful to handle thread-termination using abort/0 or exceptions. See -also thread_signal/2. - - -*/ - -/** @pred current_mutex(? _MutexId_, ? _ThreadId_, ? _Count_) - - -Enumerates all existing mutexes. If the mutex is held by some thread, - _ThreadId_ is unified with the identifier of the holding thread and - _Count_ with the recursive count of the mutex. Otherwise, - _ThreadId_ is `[]` and _Count_ is 0. - - - - */ - -/** @defgroup Parallelism Parallelism -@ingroup YAPPackages -@{ - -There has been a sizeable amount of work on an or-parallel -implementation for YAP, called *YAPOr*. Most of this work has -been performed by Ricardo Rocha. In this system parallelism is exploited -implicitly by running several alternatives in or-parallel. This option -can be enabled from the `configure` script or by checking the -system's `Makefile`. - - *YAPOr* is still a very experimental system, going through rapid -development. The following restrictions are of note: - -+ *YAPOr* currently only supports the Linux/X86 and SPARC/Solaris -platforms. Porting to other Unix-like platforms should be straightforward. - -+ *YAPOr* does not support parallel updates to the -data-base. - -+ *YAPOr* does not support opening or closing of streams during -parallel execution. - -+ Garbage collection and stack shifting are not supported in - *YAPOr*. - -+ Built-ins that cause side-effects can only be executed when -left-most in the search-tree. There are no primitives to provide -asynchronous or cavalier execution of these built-ins, as in Aurora or -Muse. - -+ YAP does not support voluntary suspension of work. - - -We expect that some of these restrictions will be removed in future -releases. - - - */ - -/** @defgroup Tabling Tabling -@ingroup YAPBuiltins -@{ - - *YAPTab* is the tabling engine that extends YAP's execution -model to support tabled evaluation for definite programs. YAPTab was -implemented by Ricardo Rocha and its implementation is largely based -on the ground-breaking design of the XSB Prolog system, which -implements the SLG-WAM. Tables are implemented using tries and YAPTab -supports the dynamic intermixing of batched scheduling and local -scheduling at the subgoal level. Currently, the following restrictions -are of note: - -+ YAPTab does not handle tabled predicates with loops through negation (undefined behaviour). -+ YAPTab does not handle tabled predicates with cuts (undefined behaviour). -+ YAPTab does not support coroutining (configure error). -+ YAPTab does not support tabling dynamic predicates (permission error). - - -To experiment with YAPTab use `--enable-tabling` in the configure -script or add `-DTABLING` to `YAP_EXTRAS` in the system's -`Makefile`. We next describe the set of built-ins predicates -designed to interact with YAPTab and control tabled execution: - - -*/ - -/** @pred table( + _P_ ) - - -Declares predicate _P_ (or a list of predicates - _P1_,..., _Pn_ or [ _P1_,..., _Pn_]) as a tabled -predicate. _P_ must be written in the form - _name/arity_. Examples: - -~~~~~ -:- table son/3. -:- table father/2. -:- table mother/2. -~~~~~ - or - -~~~~~ -:- table son/3, father/2, mother/2. -~~~~~ - or - -~~~~~ -:- table [son/3, father/2, mother/2]. -~~~~~ - - -*/ - -/** @pred is_tabled(+ _P_) - - -Succeeds if the predicate _P_ (or a list of predicates - _P1_,..., _Pn_ or [ _P1_,..., _Pn_]), of the form - _name/arity_, is a tabled predicate. - - -*/ - -/** @pred tabling_mode(+ _P_,? _Mode_) - - -Sets or reads the default tabling mode for a tabled predicate _P_ -(or a list of predicates _P1_,..., _Pn_ or -[ _P1_,..., _Pn_]). The list of _Mode_ options includes: - -+ `batched` - - Defines that, by default, batched scheduling is the scheduling -strategy to be used to evaluated calls to predicate _P_. - -+ `local` - - Defines that, by default, local scheduling is the scheduling -strategy to be used to evaluated calls to predicate _P_. - -+ `exec_answers` - - Defines that, by default, when a call to predicate _P_ is -already evaluated (completed), answers are obtained by executing -compiled WAM-like code directly from the trie data -structure. This reduces the loading time when backtracking, but -the order in which answers are obtained is undefined. - -+ `load_answers` - - Defines that, by default, when a call to predicate _P_ is -already evaluated (completed), answers are obtained (as a -consumer) by loading them from the trie data structure. This -guarantees that answers are obtained in the same order as they -were found. Somewhat less efficient but creates less choice-points. - -The default tabling mode for a new tabled predicate is `batched` -and `exec_answers`. To set the tabling mode for all predicates at -once you can use the yap_flag/2 predicate as described next. - -*/ - -/** @pred yap_flag(tabling_mode,? _Mode_) -Sets or reads the tabling mode for all tabled predicates. The list of - _Mode_ options includes: - -+ `default` - - Defines that (i) all calls to tabled predicates are evaluated -using the predicate default mode, and that (ii) answers for all -completed calls are obtained by using the predicate default mode. - -+ `batched` - - Defines that all calls to tabled predicates are evaluated using -batched scheduling. This option ignores the default tabling mode -of each predicate. - -+ `local` - - Defines that all calls to tabled predicates are evaluated using -local scheduling. This option ignores the default tabling mode -of each predicate. - -+ `exec_answers` - - Defines that answers for all completed calls are obtained by -executing compiled WAM-like code directly from the trie data -structure. This option ignores the default tabling mode -of each predicate. - -+ `load_answers` - - Defines that answers for all completed calls are obtained by -loading them from the trie data structure. This option ignores -the default tabling mode of each predicate. - - - -*/ - -/** @pred abolish_table(+ _P_) - - -Removes all the entries from the table space for predicate _P_ (or -a list of predicates _P1_,..., _Pn_ or -[ _P1_,..., _Pn_]). The predicate remains as a tabled predicate. - - -*/ - -/** @pred abolish_all_tables/0 - - -Removes all the entries from the table space for all tabled -predicates. The predicates remain as tabled predicates. - - -*/ - -/** @pred show_table(+ _P_) - - -Prints table contents (subgoals and answers) for predicate _P_ -(or a list of predicates _P1_,..., _Pn_ or -[ _P1_,..., _Pn_]). - - -*/ - -/** @pred table_statistics(+ _P_) - - -Prints table statistics (subgoals and answers) for predicate _P_ -(or a list of predicates _P1_,..., _Pn_ or -[ _P1_,..., _Pn_]). - - -*/ - -/** @pred tabling_statistics/0 - - -Prints statistics on space used by all tables. - - - - */ - -/** @defgroup Low_Level_Tracing Tracing at Low Level -@ingroup YAPBuiltins -@{ - -It is possible to follow the flow at abstract machine level if -YAP is compiled with the flag `LOW_LEVEL_TRACER`. Note -that this option is of most interest to implementers, as it quickly generates -an huge amount of information. - -Low level tracing can be toggled from an interrupt handler by using the -option `T`. There are also two built-ins that activate and -deactivate low level tracing: - - -*/ - -/** @pred start_low_level_trace - - -Begin display of messages at procedure entry and retry. - - -*/ - -/** @pred stop_low_level_trace - - -Stop display of messages at procedure entry and retry. - - -Note that this compile-time option will slow down execution. - - - */ - -/** @defgroup Low_Level_Profiling Profiling the Abstract Machine - -Implementors may be interested in detecting on which abstract machine -instructions are executed by a program. The `ANALYST` flag can give -WAM level information. Note that this option slows down execution very -substantially, and is only of interest to developers of the system -internals, or to system debuggers. - - -*/ - -/** @pred wam_profiler_reset_op_counters - - -Reinitialize all counters. - - -*/ - -/** @pred wam_profiler_show_op_counters(+ _A_) - - -Display the current value for the counters, using label _A_. The -label must be an atom. - - -*/ - -/** @pred wam_profiler_show_ops_by_group(+ _A_) - - -Display the current value for the counters, organized by groups, using -label _A_. The label must be an atom. - - - - - */ - -/** @defgroup Debugging Debugging -@ingroup YAPBuiltins -@{ - - - */ - -/** @defgroup Deb_Preds Debugging Predicates - -@{ -The - following predicates are available to control the debugging of -programs: - -+ debug - - Switches the debugger on. - -+ debugging - - - Outputs status information about the debugger which includes the leash -mode and the existing spy-points, when the debugger is on. - -+ nodebug - - - Switches the debugger off. - - -*/ - -/** @pred spy( + _P_ ). - - -Sets spy-points on all the predicates represented by - _P_. _P_ can either be a single specification or a list of -specifications. Each one must be of the form _Name/Arity_ -or _Name_. In the last case all predicates with the name - _Name_ will be spied. As in C-Prolog, system predicates and -predicates written in C, cannot be spied. - - -*/ - -/** @pred nospy( + _P_ ) - - -Removes spy-points from all predicates specified by _P_. -The possible forms for _P_ are the same as in `spy P`. - - -*/ - -/** @pred nospyall - - -Removes all existing spy-points. - - -*/ - -/** @pred leash(+ _M_) - - -Sets leashing mode to _M_. -The mode can be specified as: - -+ `full` -prompt on Call, Exit, Redo and Fail - -+ `tight` -prompt on Call, Redo and Fail - -+ `half` -prompt on Call and Redo - -+ `loose` -prompt on Call - -+ `off` -never prompt - -+ `none` -never prompt, same as `off` - -The initial leashing mode is `full`. - -The user may also specify directly the debugger ports -where he wants to be prompted. If the argument for leash -is a number _N_, each of lower four bits of the number is used to -control prompting at one the ports of the box model. The debugger will -prompt according to the following conditions: - -+ if `N/\ 1 =\= 0` prompt on fail -+ if `N/\ 2 =\= 0` prompt on redo -+ if `N/\ 4 =\= 0` prompt on exit -+ if `N/\ 8 =\= 0` prompt on call - -Therefore, `leash(15)` is equivalent to `leash(full)` and -`leash(0)` is equivalent to `leash(off)`. - -Another way of using `leash` is to give it a list with the names of -the ports where the debugger should stop. For example, -`leash([call,exit,redo,fail])` is the same as `leash(full)` or -`leash(15)` and `leash([fail])` might be used instead of -`leash(1)`. - - -*/ - -/** @pred trace - - -Switches on the debugger and enters tracing mode. - - -*/ - -/** @pred notrace - - -Ends tracing and exits the debugger. This is the same as -nodebug/0. - - - - - */ - -/** @defgroup Deb_Interaction Interacting with the debugger - -Deb@{ -ugging with YAP is similar to debugging with C-Prolog. Both systems -include a procedural debugger, based on Byrd's four port model. In this -model, execution is seen at the procedure level: each activation of a -procedure is seen as a box with control flowing into and out of that -box. - -In the four port model control is caught at four key points: before -entering the procedure, after exiting the procedure (meaning successful -evaluation of all queries activated by the procedure), after backtracking but -before trying new alternative to the procedure and after failing the -procedure. Each one of these points is named a port: - -~~~~~ -@group - *--------------------------------------* - Call | | Exit ----------> + descendant(X,Y) :- offspring(X,Y). + ---------> - | | - | descendant(X,Z) :- | -<--------- + offspring(X,Y), descendant(Y,Z). + <--------- - Fail | | Redo - *--------------------------------------* -~~~~~ - - - -+ `Call` - - The call port is activated before initial invocation of -procedure. Afterwards, execution will try to match the goal with the -head of existing clauses for the procedure. - -+ `Exit` - - This port is activated if the procedure succeeds. -Control will now leave the procedure and return to its ancestor. - -+ `Redo` - - If the goal, or goals, activated after the call port -fail then backtracking will eventually return control to this procedure -through the redo port. - -+ `Fail` - - If all clauses for this predicate fail, then the -invocation fails, and control will try to redo the ancestor of this -invocation. - - -To start debugging, the user will either call `trace` or spy the -relevant procedures, entering debug mode, and start execution of the -program. When finding the first spy-point, YAP's debugger will take -control and show a message of the form: - -~~~~~ -* (1) call: quicksort([1,2,3],_38) ? -~~~~~ - -The debugger message will be shown while creeping, or at spy-points, -and it includes four or five fields: - -+ -The first three characters are used to point out special states of the -debugger. If the port is exit and the first character is '?', the -current call is non-deterministic, that is, it still has alternatives to -be tried. If the second character is a `\*`, execution is at a -spy-point. If the third character is a `>`, execution has returned -either from a skip, a fail or a redo command. -+ -The second field is the activation number, and uniquely identifies the -activation. The number will start from 1 and will be incremented for -each activation found by the debugger. -+ -In the third field, the debugger shows the active port. -+ -The fourth field is the goal. The goal is written by -`write_term/3` on the standard error stream, using the options -given by debugger_print_options. - - -If the active port is leashed, the debugger will prompt the user with a -`?`, and wait for a command. A debugger command is just a -character, followed by a return. By default, only the call and redo -entries are leashed, but the leash/1 predicate can be used in -order to make the debugger stop where needed. - -There are several commands available, but the user only needs to -remember the help command, which is `h`. This command shows all the -available options, which are: - -+ `c` - creep - - this command makes YAP continue execution and stop at the next -leashed port. - -+ `return` - creep - - the same as c - -+ `l` - leap - - YAP will execute until it meets a port for a spied predicate; this mode -keeps all computation history for debugging purposes, so it is more -expensive than standard execution. Use k or z for fast execution. - -+ `k` - quasi-leap - - similar to leap but faster since the computation history is -not kept; useful when leap becomes too slow. - -+ `z` - zip - - - same as k -+ `s` - skip - - YAP will continue execution without showing any messages until -returning to the current activation. Spy-points will be ignored in this -mode. Note that this command keeps all debugging history, use t for fast execution. This command is meaningless, and therefore illegal, in the fail -and exit ports. - -+ `t` - fast-skip - - similar to skip but faster since computation history is not -kept; useful if skip becomes slow. - -+ `f [ _GoalId_]` - fail - - If given no argument, forces YAP to fail the goal, skipping the fail -port and backtracking to the parent. -If f receives a goal number as -the argument, the command fails all the way to the goal. If goal _GoalId_ has completed execution, YAP fails until meeting the first active ancestor. - -+ `r` [ _GoalId_] - retry - - This command forces YAP to jump back call to the port. Note that any -side effects of the goal cannot be undone. This command is not available -at the call port. If f receives a goal number as the argument, the -command retries goal _GoalId_ instead. If goal _GoalId_ has -completed execution, YAP fails until meeting the first active ancestor. - -+ `a` - abort - - execution will be aborted, and the interpreter will return to the -top-level. YAP disactivates debug mode, but spypoints are not removed. - -+ `n` - nodebug - - stop debugging and continue execution. The command will not clear active -spy-points. - -+ `e` - exit - - leave YAP. - -+ `h` - help - - show the debugger commands. - -+ `!` Query - - execute a query. YAP will not show the result of the query. - -+ `b` - break - - break active execution and launch a break level. This is the same as `!break`. - -+ `+` - spy this goal - - start spying the active goal. The same as `! spy G` where _G_ -is the active goal. - -+ `-` - nospy this goal - - stop spying the active goal. The same as `! nospy G` where _G_ is -the active goal. - -+ `p` - print - - shows the active goal using print/1 - -+ `d` - display - - shows the active goal using display/1 - -+ `deterministic programs often -boils down to a recursive loop of the form: - -~~~~~ -loop(Env) :- - do_something(Env,NewEnv), - loop(NewEnv). -~~~~~ - - - - - */ - -/** @defgroup Indexing Indexing - -The@{ - indexation mechanism restricts the set of clauses to be tried in a -procedure by using information about the status of the instantiated -arguments of the goal. These arguments are then used as a key, -selecting a restricted set of a clauses from all the clauses forming the -procedure. - -As an example, the two clauses for concatenate: - -~~~~~ -concatenate([],L,L). -concatenate([H|T],A,[H|NT]) :- concatenate(T,A,NT). -~~~~~ - -If the first argument for the goal is a list, then only the second clause -is of interest. If the first argument is the nil atom, the system needs to -look only for the first clause. The indexation generates instructions that -test the value of the first argument, and then proceed to a selected clause, -or group of clauses. - -Note that if the first argument was a free variable, then both clauses -should be tried. In general, indexation will not be useful if the first -argument is a free variable. - -When activating a predicate, a Prolog system needs to store state -information. This information, stored in a structure known as choice point -or fail point, is necessary when backtracking to other clauses for the -predicate. The operations of creating and using a choice point are very -expensive, both in the terms of space used and time spent. -Creating a choice point is not necessary if there is only a clause for -the predicate as there are no clauses to backtrack to. With indexation, this -situation is extended: in the example, if the first argument was the atom -nil, then only one clause would really be of interest, and it is pointless to -create a choice point. This feature is even more useful if the first argument -is a list: without indexation, execution would try the first clause, creating -a choice point. The clause would fail, the choice point would then be used to -restore the previous state of the computation and the second clause would -be tried. The code generated by the indexation mechanism would behave -much more efficiently: it would test the first argument and see whether it -is a list, and then proceed directly to the second clause. - -An important side effect concerns the use of "cut". In the above -example, some programmers would use a "cut" in the first clause just to -inform the system that the predicate is not backtrackable and force the -removal the choice point just created. As a result, less space is needed but -with a great loss in expressive power: the "cut" would prevent some uses of -the procedure, like generating lists through backtracking. Of course, with -indexation the "cut" becomes useless: the choice point is not even created. - -Indexation is also very important for predicates with a large number -of clauses that are used like tables: - -~~~~~ -logician(aristoteles,greek). -logician(frege,german). -logician(russel,english). -logician(godel,german). -logician(whitehead,english). -~~~~~ - -An interpreter like C-Prolog, trying to answer the query: - -~~~~~ -?- logician(godel,X). -~~~~~ - -would blindly follow the standard Prolog strategy, trying first the -first clause, then the second, the third and finally finding the -relevant clause. Also, as there are some more clauses after the -important one, a choice point has to be created, even if we know the -next clauses will certainly fail. A "cut" would be needed to prevent -some possible uses for the procedure, like generating all logicians. In -this situation, the indexing mechanism generates instructions that -implement a search table. In this table, the value of the first argument -would be used as a key for fast search of possibly matching clauses. For -the query of the last example, the result of the search would be just -the fourth clause, and again there would be no need for a choice point. - -If the first argument is a complex term, indexation will select clauses -just by testing its main functor. However, there is an important -exception: if the first argument of a clause is a list, the algorithm -also uses the list's head if not a variable. For instance, with the -following clauses, - -~~~~~ -rules([],B,B). -rules([n(N)|T],I,O) :- rules_for_noun(N,I,N), rules(T,N,O). -rules([v(V)|T],I,O) :- rules_for_verb(V,I,N), rules(T,N,O). -rules([q(Q)|T],I,O) :- rules_for_qualifier(Q,I,N), rules(T,N,O). -~~~~~ -if the first argument of the goal is a list, its head will be tested, and only -the clauses matching it will be tried during execution. - -Some advice on how to take a good advantage of this mechanism: - - - -+ -Try to make the first argument an input argument. - -+ -Try to keep together all clauses whose first argument is not a -variable, that will decrease the number of tests since the other clauses are -always tried. - -+ -Try to avoid predicates having a lot of clauses with the same key. -For instance, the procedure: - - - -~~~~~ -type(n(mary),person). -type(n(john), person). -type(n(chair),object). -type(v(eat),active). -type(v(rest),passive). -~~~~~ - -becomes more efficient with: - -~~~~~ -type(n(N),T) :- type_of_noun(N,T). -type(v(V),T) :- type_of_verb(V,T). - -type_of_noun(mary,person). -type_of_noun(john,person). -type_of_noun(chair,object). - -type_of_verb(eat,active). -type_of_verb(rest,passive). -~~~~~ - -*/ - -/** @page ChYInterface C Language interface to YAP - -YAP provides the user with three facilities for writing -predicates in a language other than Prolog. Under Unix systems, -most language implementations were linkable to `C`, and the first interface exported the YAP machinery to the C language. YAP also implements most of the SWI-Prolog foreign language interface. -This gives portability with a number of SWI-Prolog packages. Last, a new C++ based interface is -being designed to work with the swig (@url(www.swig.org}) interface compiler. - -+ The @ref c-interface YAP C-interface exports the YAP engine. -+ The @ref swi-c-interface emulates Jan Wielemaker's SWI foreign language interface. -+ The @ref yap-cplus-interface is desiged to interface with Object-Oriented systems. - - - - - */ - -/** @defgroup Loading_Objects Loading Object Files - -The@{ - primitive predicate - - -*/ - -/** @pred load_foreign_files( _Files_, _Libs_, _InitRoutine_) - -should be used, from inside YAP, to load object files produced by the C -compiler. The argument _ObjectFiles_ should be a list of atoms -specifying the object files to load, _Libs_ is a list (possibly -empty) of libraries to be passed to the unix loader (`ld`) and -InitRoutine is the name of the C routine (to be called after the files -are loaded) to perform the necessary declarations to YAP of the -predicates defined in the files. - -YAP will search for _ObjectFiles_ in the current directory first. If -it cannot find them it will search for the files using the environment -variable: - -+ YAPLIBDIR - -if defined, or in the default library. - -YAP also supports the SWI-Prolog interface to loading foreign code: - - -*/ - -/** @pred open_shared_object(+ _File_, - _Handle_) - -File is the name of a shared object file (called dynamic load -library in MS-Windows). This file is attached to the current process -and _Handle_ is unified with a handle to the library. Equivalent to -`open_shared_object(File, [], Handle)`. See also -load_foreign_library/1 and `load_foreign_library/2`. - -On errors, an exception `shared_object`( _Action_, - _Message_) is raised. _Message_ is the return value from -dlerror(). - - -*/ - -/** @pred open_shared_object(+ _File_, - _Handle_, + _Options_) - -As `open_shared_object/2`, but allows for additional flags to -be passed. _Options_ is a list of atoms. `now` implies the -symbols are -resolved immediately rather than lazily (default). `global` implies -symbols of the loaded object are visible while loading other shared -objects (by default they are local). Note that these flags may not -be supported by your operating system. Check the documentation of -`dlopen()` or equivalent on your operating system. Unsupported -flags are silently ignored. - - -*/ - -/** @pred close_shared_object(+ _Handle_) - -Detach the shared object identified by _Handle_. - - -*/ - -/** @pred call_shared_object_function(+ _Handle_, + _Function_) - - -Call the named function in the loaded shared library. The function -is called without arguments and the return-value is -ignored. In SWI-Prolog, normally this function installs foreign -language predicates using calls to `PL_register_foreign()`. - - - - */ - -/** @defgroup SavebQeERest Saving and Restoring - -YAP@{ -4 currently does not support `save` and `restore` for object code -loaded with `load_foreign_files/3`. We plan to support save and restore -in future releases of YAP. - -*/ diff --git a/docs/offcanvas.css b/docs/offcanvas.css deleted file mode 100644 index 2a72199d5..000000000 --- a/docs/offcanvas.css +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Style tweaks - * -------------------------------------------------- - */ -html, -body { - overflow-x: hidden; /* Prevent scroll on narrow devices */ -} -body { - padding-top: 70px; -} -footer { - padding: 30px 0; -} - -/* - * Off Canvas - * -------------------------------------------------- - */ -@media screen and (max-width: 767px) { - .row-offcanvas { - position: relative; - -webkit-transition: all .25s ease-out; - -o-transition: all .25s ease-out; - transition: all .25s ease-out; - } - - .row-offcanvas-right { - right: 0; - } - - .row-offcanvas-left { - left: 0; - } - - .row-offcanvas-right - .sidebar-offcanvas { - right: -50%; /* 6 columns */ - } - - .row-offcanvas-left - .sidebar-offcanvas { - left: -50%; /* 6 columns */ - } - - .row-offcanvas-right.active { - right: 50%; /* 6 columns */ - } - - .row-offcanvas-left.active { - left: 50%; /* 6 columns */ - } - - .sidebar-offcanvas { - position: absolute; - top: 0; - width: 50%; /* 6 columns */ - } -} diff --git a/docs/offcanvas.js b/docs/offcanvas.js deleted file mode 100644 index d2f37f22c..000000000 --- a/docs/offcanvas.js +++ /dev/null @@ -1,5 +0,0 @@ -$(document).ready(function () { - $('[data-toggle="offcanvas"]').click(function () { - $('.row-offcanvas').toggleClass('active') - }); -}); \ No newline at end of file diff --git a/docs/pygments.css b/docs/pygments.css deleted file mode 100644 index 23f82e8e6..000000000 --- a/docs/pygments.css +++ /dev/null @@ -1,62 +0,0 @@ -.hll { background-color: #ffffcc } -.c { color: #0099FF; font-style: italic } /* Comment */ -.err { color: #AA0000; background-color: #FFAAAA } /* Error */ -.k { color: #006699; font-weight: bold } /* Keyword */ -.o { color: #555555 } /* Operator */ -.cm { color: #0099FF; font-style: italic } /* Comment.Multiline */ -.cp { color: #009999 } /* Comment.Preproc */ -.c1 { color: #0099FF; font-style: italic } /* Comment.Single */ -.cs { color: #0099FF; font-weight: bold; font-style: italic } /* Comment.Special */ -.gd { background-color: #FFCCCC; border: 1px solid #CC0000 } /* Generic.Deleted */ -.ge { font-style: italic } /* Generic.Emph */ -.gr { color: #FF0000 } /* Generic.Error */ -.gh { color: #003300; font-weight: bold } /* Generic.Heading */ -.gi { background-color: #CCFFCC; border: 1px solid #00CC00 } /* Generic.Inserted */ -.go { color: #AAAAAA } /* Generic.Output */ -.gp { color: #000099; font-weight: bold } /* Generic.Prompt */ -.gs { font-weight: bold } /* Generic.Strong */ -.gu { color: #003300; font-weight: bold } /* Generic.Subheading */ -.gt { color: #99CC66 } /* Generic.Traceback */ -.kc { color: #006699; font-weight: bold } /* Keyword.Constant */ -.kd { color: #006699; font-weight: bold } /* Keyword.Declaration */ -.kn { color: #006699; font-weight: bold } /* Keyword.Namespace */ -.kp { color: #006699 } /* Keyword.Pseudo */ -.kr { color: #006699; font-weight: bold } /* Keyword.Reserved */ -.kt { color: #007788; font-weight: bold } /* Keyword.Type */ -.m { color: #FF6600 } /* Literal.Number */ -.s { color: #CC3300 } /* Literal.String */ -.na { color: #330099 } /* Name.Attribute */ -.nb { color: #336666 } /* Name.Builtin */ -.nc { color: #00AA88; font-weight: bold } /* Name.Class */ -.no { color: #336600 } /* Name.Constant */ -.nd { color: #9999FF } /* Name.Decorator */ -.ni { color: #999999; font-weight: bold } /* Name.Entity */ -.ne { color: #CC0000; font-weight: bold } /* Name.Exception */ -.nf { color: #CC00FF } /* Name.Function */ -.nl { color: #9999FF } /* Name.Label */ -.nn { color: #00CCFF; font-weight: bold } /* Name.Namespace */ -.nt { color: #330099; font-weight: bold } /* Name.Tag */ -.nv { color: #003333 } /* Name.Variable */ -.ow { color: #000000; font-weight: bold } /* Operator.Word */ -.w { color: #bbbbbb } /* Text.Whitespace */ -.mb { color: #FF6600 } /* Literal.Number.Bin */ -.mf { color: #FF6600 } /* Literal.Number.Float */ -.mh { color: #FF6600 } /* Literal.Number.Hex */ -.mi { color: #FF6600 } /* Literal.Number.Integer */ -.mo { color: #FF6600 } /* Literal.Number.Oct */ -.sb { color: #CC3300 } /* Literal.String.Backtick */ -.sc { color: #CC3300 } /* Literal.String.Char */ -.sd { color: #CC3300; font-style: italic } /* Literal.String.Doc */ -.s2 { color: #CC3300 } /* Literal.String.Double */ -.se { color: #CC3300; font-weight: bold } /* Literal.String.Escape */ -.sh { color: #CC3300 } /* Literal.String.Heredoc */ -.si { color: #AA0000 } /* Literal.String.Interpol */ -.sx { color: #CC3300 } /* Literal.String.Other */ -.sr { color: #33AAAA } /* Literal.String.Regex */ -.s1 { color: #CC3300 } /* Literal.String.Single */ -.ss { color: #FFCC33 } /* Literal.String.Symbol */ -.bp { color: #336666 } /* Name.Builtin.Pseudo */ -.vc { color: #003333 } /* Name.Variable.Class */ -.vg { color: #003333 } /* Name.Variable.Global */ -.vi { color: #003333 } /* Name.Variable.Instance */ -.il { color: #FF6600 } /* Literal.Number.Integer.Long */ diff --git a/docs/solarized-light.css b/docs/solarized-light.css deleted file mode 100644 index d9b00dd1e..000000000 --- a/docs/solarized-light.css +++ /dev/null @@ -1,303 +0,0 @@ -@import url(http://fonts.googleapis.com/css?family=Inconsolata); -@import url(http://fonts.googleapis.com/css?family=PT+Sans); -@import url(http://fonts.googleapis.com/css?family=PT+Sans+Narrow:400,700); -article, -aside, -details, -figcaption, -figure, -footer, -header, -hgroup, -nav, -section, -summary { - display: block; -} -audio, -canvas, -video { - display: inline-block; -} -audio:not([controls]) { - display: none; - height: 0; -} -[hidden] { - display: none; -} -html { - font-family: sans-serif; - -webkit-text-size-adjust: 100%; - -ms-text-size-adjust: 100%; -} -body { - margin: 0; -} -a:focus { - outline: thin dotted; -} -a:active, -a:hover { - outline: 0; -} -h1 { - font-size: 2em; -} -abbr[title] { - border-bottom: 1px dotted; -} -b, -strong { - font-weight: bold; -} -dfn { - font-style: italic; -} -mark { - background: #ff0; - color: #000; -} -code, -kbd, -pre, -samp { - font-family: monospace, serif; - font-size: 1em; -} -pre { - white-space: pre-wrap; - word-wrap: break-word; -} -q { - quotes: "\201C" "\201D" "\2018" "\2019"; -} -small { - font-size: 80%; -} -sub, -sup { - font-size: 75%; - line-height: 0; - position: relative; - vertical-align: baseline; -} -sup { - top: -0.5em; -} -sub { - bottom: -0.25em; -} -img { - border: 0; -} -svg:not(:root) { - overflow: hidden; -} -figure { - margin: 0; -} -fieldset { - border: 1px solid #c0c0c0; - margin: 0 2px; - padding: 0.35em 0.625em 0.75em; -} -legend { - border: 0; - padding: 0; -} -button, -input, -select, -textarea { - font-family: inherit; - font-size: 100%; - margin: 0; -} -button, -input { - line-height: normal; -} -button, -html input[type="button"], -input[type="reset"], -input[type="submit"] { - -webkit-appearance: button; - cursor: pointer; -} -button[disabled], -input[disabled] { - cursor: default; -} -input[type="checkbox"], -input[type="radio"] { - box-sizing: border-box; - padding: 0; -} -input[type="search"] { - -webkit-appearance: textfield; - -moz-box-sizing: content-box; - -webkit-box-sizing: content-box; - box-sizing: content-box; -} -input[type="search"]::-webkit-search-cancel-button, -input[type="search"]::-webkit-search-decoration { - -webkit-appearance: none; -} -button::-moz-focus-inner, -input::-moz-focus-inner { - border: 0; - padding: 0; -} -textarea { - overflow: auto; - vertical-align: top; -} -table { - border-collapse: collapse; - border-spacing: 0; -} -html { - font-family: 'PT Sans', sans-serif; -} -pre, -code { - font-family: 'Inconsolata', sans-serif; -} -h1, -h2, -h3, -h4, -h5, -h6 { - font-family: 'PT Sans Narrow', sans-serif; - font-weight: 700; -} -html { - background-color: #eee8d5; - color: #657b83; - margin: 1em; -} -body { - background-color: #fdf6e3; - margin: 0 auto; - max-width: 23cm; - border: 1pt solid #93a1a1; - padding: 1em; -} -code { - background-color: #eee8d5; - padding: 2px; -} -a { - color: #b58900; -} -a:visited { - color: #cb4b16; -} -a:hover { - color: #cb4b16; -} -h1 { - color: #d33682; -} -h2, -h3, -h4, -h5, -h6 { - color: #859900; -} -pre { - background-color: #fdf6e3; - color: #657b83; - border: 1pt solid #93a1a1; - padding: 1em; - box-shadow: 5pt 5pt 8pt #eee8d5; -} -pre code { - background-color: #fdf6e3; -} -h1 { - font-size: 2.8em; -} -h2 { - font-size: 2.4em; -} -h3 { - font-size: 1.8em; -} -h4 { - font-size: 1.4em; -} -h5 { - font-size: 1.3em; -} -h6 { - font-size: 1.15em; -} -.tag { - background-color: #eee8d5; - color: #d33682; - padding: 0 0.2em; -} -.todo, -.next, -.done { - color: #fdf6e3; - background-color: #dc322f; - padding: 0 0.2em; -} -.tag { - -webkit-border-radius: 0.35em; - -moz-border-radius: 0.35em; - border-radius: 0.35em; -} -.TODO { - -webkit-border-radius: 0.2em; - -moz-border-radius: 0.2em; - border-radius: 0.2em; - background-color: #2aa198; -} -.NEXT { - -webkit-border-radius: 0.2em; - -moz-border-radius: 0.2em; - border-radius: 0.2em; - background-color: #268bd2; -} -.ACTIVE { - -webkit-border-radius: 0.2em; - -moz-border-radius: 0.2em; - border-radius: 0.2em; - background-color: #268bd2; -} -.DONE { - -webkit-border-radius: 0.2em; - -moz-border-radius: 0.2em; - border-radius: 0.2em; - background-color: #859900; -} -.WAITING { - -webkit-border-radius: 0.2em; - -moz-border-radius: 0.2em; - border-radius: 0.2em; - background-color: #cb4b16; -} -.HOLD { - -webkit-border-radius: 0.2em; - -moz-border-radius: 0.2em; - border-radius: 0.2em; - background-color: #d33682; -} -.NOTE { - -webkit-border-radius: 0.2em; - -moz-border-radius: 0.2em; - border-radius: 0.2em; - background-color: #d33682; -} -.CANCELLED { - -webkit-border-radius: 0.2em; - -moz-border-radius: 0.2em; - border-radius: 0.2em; - background-color: #859900; -} diff --git a/docs/source/conf.py b/docs/source/conf.py index cc44b2861..20c97ad64 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -33,18 +33,18 @@ from recommonmark.parser import CommonMarkParser # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = ['sphinx.ext.autodoc', - 'sphinx.ext.doctest', - 'sphinx.ext.intersphinx', - 'sphinx.ext.todo', - 'sphinx.ext.coverage', - 'sphinx.ext.mathjax', - 'sphinx.ext.ifconfig', - 'sphinx.ext.viewcode', + 'sphinx.ext.doctest', + 'sphinx.ext.intersphinx', + 'sphinx.ext.todo', + 'sphinx.ext.coverage', + 'sphinx.ext.mathjax', + 'sphinx.ext.ifconfig', + 'sphinx.ext.viewcode', 'sphinx.ext.githubpages', 'breathe' ] -breathe_projects = { "yap": "${CMAKE_CURRENT_BINARY_DIR" } +breathe_projects = { "yap": "/home/vsc/github/yap-6.3/docs/xml" } breathe_default_project = "yap" # Add any paths that contain templates here, relative to this directory. @@ -92,7 +92,7 @@ pygments_style = 'sphinx' todo_include_todos = True source_parsers = { - '.md': 'recommonmark.parser.CommonMarkParser', + '.md': 'recommonmark.parser.CommonMarkParser', } # -- Options for HTML output ---------------------------------------------- diff --git a/docs/source/union/d2/d77/unionseq__val__t.rst b/docs/source/union/d2/d77/unionseq__val__t.rst new file mode 100644 index 000000000..b3b502e24 --- /dev/null +++ b/docs/source/union/d2/d77/unionseq__val__t.rst @@ -0,0 +1,4 @@ +Union seq_val_t +=============== + +.. doxygenunion:: seq_val_t diff --git a/docs/source/union/d4/da6/unionflag_term.rst b/docs/source/union/d4/da6/unionflag_term.rst new file mode 100644 index 000000000..5fcdd3458 --- /dev/null +++ b/docs/source/union/d4/da6/unionflag_term.rst @@ -0,0 +1,4 @@ +Union flagTerm +============== + +.. doxygenunion:: flagTerm diff --git a/docs/source/union/d5/dc7/union_r_l___node.rst b/docs/source/union/d5/dc7/union_r_l___node.rst new file mode 100644 index 000000000..bc8f661b2 --- /dev/null +++ b/docs/source/union/d5/dc7/union_r_l___node.rst @@ -0,0 +1,4 @@ +Union RL_Node +============= + +.. doxygenunion:: RL_Node diff --git a/docs/source/union/d9/db2/union_u.rst b/docs/source/union/d9/db2/union_u.rst new file mode 100644 index 000000000..5b2dfd943 --- /dev/null +++ b/docs/source/union/d9/db2/union_u.rst @@ -0,0 +1,4 @@ +Union U +======= + +.. doxygenunion:: U diff --git a/docs/source/union/da/ded/union_c_o_n_s_u_l_t___o_b_j.rst b/docs/source/union/da/ded/union_c_o_n_s_u_l_t___o_b_j.rst new file mode 100644 index 000000000..f7119ec5b --- /dev/null +++ b/docs/source/union/da/ded/union_c_o_n_s_u_l_t___o_b_j.rst @@ -0,0 +1,4 @@ +Union CONSULT_OBJ +================= + +.. doxygenunion:: CONSULT_OBJ diff --git a/docs/source/union/db/de7/union_a_i.rst b/docs/source/union/db/de7/union_a_i.rst new file mode 100644 index 000000000..b6ce056a6 --- /dev/null +++ b/docs/source/union/db/de7/union_a_i.rst @@ -0,0 +1,4 @@ +Union AI +======== + +.. doxygenunion:: AI diff --git a/docs/source/union/dd/d52/unionstatarray__elements.rst b/docs/source/union/dd/d52/unionstatarray__elements.rst new file mode 100644 index 000000000..59868d80e --- /dev/null +++ b/docs/source/union/dd/d52/unionstatarray__elements.rst @@ -0,0 +1,4 @@ +Union statarray_elements +======================== + +.. doxygenunion:: statarray_elements diff --git a/docs/source/union/dd/de1/unioncell__size__t.rst b/docs/source/union/dd/de1/unioncell__size__t.rst new file mode 100644 index 000000000..ae7613c19 --- /dev/null +++ b/docs/source/union/dd/de1/unioncell__size__t.rst @@ -0,0 +1,4 @@ +Union cell_size_t +================= + +.. doxygenunion:: cell_size_t diff --git a/docs/source/union/df/d0e/unionclause__ptr.rst b/docs/source/union/df/d0e/unionclause__ptr.rst new file mode 100644 index 000000000..ffe79767b --- /dev/null +++ b/docs/source/union/df/d0e/unionclause__ptr.rst @@ -0,0 +1,4 @@ +Union clause_ptr +================ + +.. doxygenunion:: clause_ptr diff --git a/docs/source/union/df/d1b/unionclause__obj.rst b/docs/source/union/df/d1b/unionclause__obj.rst new file mode 100644 index 000000000..a119fa801 --- /dev/null +++ b/docs/source/union/df/d1b/unionclause__obj.rst @@ -0,0 +1,4 @@ +Union clause_obj +================ + +.. doxygenunion:: clause_obj diff --git a/docs/source/union/df/dfa/unionoptvalue.rst b/docs/source/union/df/dfa/unionoptvalue.rst new file mode 100644 index 000000000..0c0868538 --- /dev/null +++ b/docs/source/union/df/dfa/unionoptvalue.rst @@ -0,0 +1,4 @@ +Union optvalue +============== + +.. doxygenunion:: optvalue diff --git a/docs/sx/conf.py b/docs/sx/conf.py new file mode 100644 index 000000000..5c6a95638 --- /dev/null +++ b/docs/sx/conf.py @@ -0,0 +1,319 @@ +# -*- coding: utf-8 -*- +# +# yap documentation build configuration file, created by +# sphinx-quickstart on Tue Jan 5 11:01:36 2016. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os +import shlex + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) +sys.path.append( "/usr/local/lib/python3.6/site-packages/breathe") + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.doctest', + 'sphinx.ext.intersphinx', + 'sphinx.ext.todo', + 'sphinx.ext.coverage', + 'sphinx.ext.mathjax', + 'sphinx.ext.ifconfig', + 'sphinx.ext.viewcode', + 'sphinx.ext.pngmath', + 'breathe' +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +source_suffix = ['.rst', '.md'] +#source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'yap' +copyright = u'2016, Vitor Santos Costa' +author = u'Vitor Santos Costa' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = u'4.6.3' +# The full version, including alpha/beta/rc tags. +release = u'4.6.3' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = [] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +#keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + +breathe_projects = { "yap": "/Users/vsc/github/yap-6.3/Debug/docs/xml" } + +#Specify a default project: + +breathe_default_project = "yap" + +#Once this is done you may use the the following commands: + +.. doxygenindex:: +.. doxygenfunction:: +.. doxygenstruct:: +.. doxygenenum:: +.. doxygentypedef:: +.. doxygenclass:: + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'alabaster' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +#html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' +#html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# Now only 'ja' uses this config value +#html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +#html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'yapdoc' + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', + +# Latex figure (float) alignment +#'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'yap.tex', u'yap Documentation', + u'Vitor Santos Costa', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'yap', u'yap Documentation', + [author], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'yap', u'yap Documentation', + author, 'yap', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +#texinfo_no_detailmenu = False + + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = {'https://docs.python.org/': None} + +breathe_projects = { "yap": "/Users/vsc/git/yap-6.3/Release/docs/xml/" } +breathe_default_project = "yap" + diff --git a/docs/sx/conf.py.in b/docs/sx/conf.py.in new file mode 100644 index 000000000..ab3a25183 --- /dev/null +++ b/docs/sx/conf.py.in @@ -0,0 +1,10 @@ +extensions = [ +breathe_projects = { "yap": "/Users/vsc/git/yap-6.3/Release/doc/xml/" }i +breathe_default_project = "yap" +.. doxygenindex:: +.. doxygenfunction:: +.. doxygenstruct:: +.. doxygenenum:: +.. doxygentypedef:: +.. doxygenclass:: + diff --git a/docs/sx/conf.pyo b/docs/sx/conf.pyo new file mode 100644 index 000000000..a7438cb93 --- /dev/null +++ b/docs/sx/conf.pyo @@ -0,0 +1,319 @@ +# -*- coding: utf-8 -*- +# +# yap documentation build configuration file, created by +# sphinx-quickstart on Tue Jan 5 11:01:36 2016. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os +import shlex + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) +sys.path.append( "/usr/local/lib/python3.6/site-packages/breathe") + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.doctest', + 'sphinx.ext.intersphinx', + 'sphinx.ext.todo', + 'sphinx.ext.coverage', + 'sphinx.ext.mathjax', + 'sphinx.ext.ifconfig', + 'sphinx.ext.viewcode', + 'sphinx.ext.pngmath', + 'breathe' +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +source_suffix = ['.rst', '.md'] +#source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'yap' +copyright = u'2016, Vitor Santos Costa' +author = u'Vitor Santos Costa' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = u'4.6.3' +# The full version, including alpha/beta/rc tags. +release = u'4.6.3' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = [] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +#keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + +breathe_projects = { "yap": "../../Debug/docs/xml" } + +#Specify a default project: + +breathe_default_project = "yap" + +#Once this is done you may use the the following commands: + +.. doxygenindex:: +.. doxygenfunction:: +.. doxygenstruct:: +.. doxygenenum:: +.. doxygentypedef:: +.. doxygenclass:: + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'alabaster' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +#html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' +#html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# Now only 'ja' uses this config value +#html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +#html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'yapdoc' + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', + +# Latex figure (float) alignment +#'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'yap.tex', u'yap Documentation', + u'Vitor Santos Costa', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'yap', u'yap Documentation', + [author], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'yap', u'yap Documentation', + author, 'yap', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +#texinfo_no_detailmenu = False + + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = {'https://docs.python.org/': None} + +breathe_projects = { "yap": "/Users/vsc/git/yap-6.3/Release/docs/xml/" } +breathe_default_project = "yap" + diff --git a/docs/sx/index.rst0 b/docs/sx/index.rst0 new file mode 100644 index 000000000..2d0dec9f0 --- /dev/null +++ b/docs/sx/index.rst0 @@ -0,0 +1,29 @@ +.. yap documentation master file, created by + sphinx-quickstart on Tue Jan 5 11:01:36 2016. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to yap's documentation! +=============================== + +Contents: + +.. toctree:: + :maxdepth: 2 + +.. doxygenindex:: +.. doxygenfunction:: +.. doxygenstruct:: +.. doxygenenum:: +.. doxygentypedef:: +.. doxygenclass:: + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + diff --git a/docs/sx/make.bat b/docs/sx/make.bat new file mode 100644 index 000000000..efc7c9039 --- /dev/null +++ b/docs/sx/make.bat @@ -0,0 +1,36 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build +set SPHINXPROJ=YAP + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% + +:end +popd diff --git a/docs/theme.css b/docs/theme.css deleted file mode 100644 index b7c8d4cd2..000000000 --- a/docs/theme.css +++ /dev/null @@ -1,18 +0,0 @@ -body { - padding-top: 70px; - padding-bottom: 30px; -} - -.theme-dropdown .dropdown-menu { - position: static; - display: block; - margin-bottom: 20px; -} - -.theme-showcase > p > .btn { - margin: 5px 0; -} - -.theme-showcase .navbar .container { - width: auto; -} diff --git a/docs/web/bootstrap/Doxyfile b/docs/web/bootstrap/Doxyfile deleted file mode 100644 index e813fa48a..000000000 --- a/docs/web/bootstrap/Doxyfile +++ /dev/null @@ -1,2399 +0,0 @@ -# Doxyfile 1.8.8 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project. -# -# All text after a double hash (##) is considered a comment and is placed in -# front of the TAG it is preceding. -# -# All text after a single hash (#) is considered a comment and will be ignored. -# The format is: -# TAG = value [value, ...] -# For lists, items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (\" \"). - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all text -# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv -# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv -# for the list of possible encodings. -# The default value is: UTF-8. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by -# double-quotes, unless you are using Doxywizard) that should identify the -# project for which the documentation is generated. This name is used in the -# title of most generated pages and in a few other places. -# The default value is: My Project. - -PROJECT_NAME = "Test Project" - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. This -# could be handy for archiving the generated documentation or if some version -# control system is used. - -PROJECT_NUMBER = 1.0.0 - -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer a -# quick idea about the purpose of the project. Keep the description short. - -PROJECT_BRIEF = Stufrf - -# With the PROJECT_LOGO tag one can specify an logo or icon that is included in -# the documentation. The maximum height of the logo should not exceed 55 pixels -# and the maximum width should not exceed 200 pixels. Doxygen will copy the logo -# to the output directory. - -PROJECT_LOGO = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path -# into which the generated documentation will be written. If a relative path is -# entered, it will be relative to the location where doxygen was started. If -# left blank the current directory will be used. - -OUTPUT_DIRECTORY = Docs - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub- -# directories (in 2 levels) under the output directory of each output format and -# will distribute the generated files over these directories. Enabling this -# option can be useful when feeding doxygen a huge amount of source files, where -# putting all generated files in the same directory would otherwise causes -# performance problems for the file system. -# The default value is: NO. - -CREATE_SUBDIRS = NO - -# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII -# characters to appear in the names of generated files. If set to NO, non-ASCII -# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode -# U+3044. -# The default value is: NO. - -ALLOW_UNICODE_NAMES = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, -# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), -# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, -# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), -# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, -# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, -# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, -# Ukrainian and Vietnamese. -# The default value is: English. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES doxygen will include brief member -# descriptions after the members that are listed in the file and class -# documentation (similar to Javadoc). Set to NO to disable this. -# The default value is: YES. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES doxygen will prepend the brief -# description of a member or function before the detailed description -# -# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. -# The default value is: YES. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator that is -# used to form the text in various listings. Each string in this list, if found -# as the leading text of the brief description, will be stripped from the text -# and the result, after processing the whole list, is used as the annotated -# text. Otherwise, the brief description is used as-is. If left blank, the -# following values are used ($name is automatically replaced with the name of -# the entity):The $name class, The $name widget, The $name file, is, provides, -# specifies, contains, represents, a, an and the. - -ABBREVIATE_BRIEF = "The $name class" \ - "The $name widget" \ - "The $name file" \ - is \ - provides \ - specifies \ - contains \ - represents \ - a \ - an \ - the - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# doxygen will generate a detailed section even if there is only a brief -# description. -# The default value is: NO. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. -# The default value is: NO. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES doxygen will prepend the full path -# before files name in the file list and in the header files. If set to NO the -# shortest path that makes the file name unique will be used -# The default value is: YES. - -FULL_PATH_NAMES = YES - -# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. -# Stripping is only done if one of the specified strings matches the left-hand -# part of the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the path to -# strip. -# -# Note that you can specify absolute paths here, but also relative paths, which -# will be relative from the directory where doxygen is started. -# This tag requires that the tag FULL_PATH_NAMES is set to YES. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the -# path mentioned in the documentation of a class, which tells the reader which -# header file to include in order to use a class. If left blank only the name of -# the header file containing the class definition is used. Otherwise one should -# specify the list of include paths that are normally passed to the compiler -# using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but -# less readable) file names. This can be useful is your file systems doesn't -# support long names like on DOS, Mac, or CD-ROM. -# The default value is: NO. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the -# first line (until the first dot) of a Javadoc-style comment as the brief -# description. If set to NO, the Javadoc-style will behave just like regular Qt- -# style comments (thus requiring an explicit @brief command for a brief -# description.) -# The default value is: NO. - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first -# line (until the first dot) of a Qt-style comment as the brief description. If -# set to NO, the Qt-style will behave just like regular Qt-style comments (thus -# requiring an explicit \brief command for a brief description.) -# The default value is: NO. - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a -# multi-line C++ special comment block (i.e. a block of //! or /// comments) as -# a brief description. This used to be the default behavior. The new default is -# to treat a multi-line C++ comment block as a detailed description. Set this -# tag to YES if you prefer the old behavior instead. -# -# Note that setting this tag to YES also means that rational rose comments are -# not recognized any more. -# The default value is: NO. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the -# documentation from any documented member that it re-implements. -# The default value is: YES. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce a -# new page for each member. If set to NO, the documentation of a member will be -# part of the file/class/namespace that contains it. -# The default value is: NO. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen -# uses this value to replace tabs by spaces in code fragments. -# Minimum value: 1, maximum value: 16, default value: 4. - -TAB_SIZE = 4 - -# This tag can be used to specify a number of aliases that act as commands in -# the documentation. An alias has the form: -# name=value -# For example adding -# "sideeffect=@par Side Effects:\n" -# will allow you to put the command \sideeffect (or @sideeffect) in the -# documentation, which will result in a user-defined paragraph with heading -# "Side Effects:". You can put \n's in the value part of an alias to insert -# newlines. - -ALIASES = - -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding "class=itcl::class" -# will allow you to use the command class in the itcl::class meaning. - -TCL_SUBST = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources -# only. Doxygen will then generate output that is more tailored for C. For -# instance, some of the names that are used will be different. The list of all -# members will be omitted, etc. -# The default value is: NO. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or -# Python sources only. Doxygen will then generate output that is more tailored -# for that language. For instance, namespaces will be presented as packages, -# qualified scopes will look different, etc. -# The default value is: NO. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources. Doxygen will then generate output that is tailored for Fortran. -# The default value is: NO. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for VHDL. -# The default value is: NO. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given -# extension. Doxygen has a built-in mapping, but you can override or extend it -# using this tag. The format is ext=language, where ext is a file extension, and -# language is one of the parsers supported by doxygen: IDL, Java, Javascript, -# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: -# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: -# Fortran. In the later case the parser tries to guess whether the code is fixed -# or free formatted code, this is the default for Fortran type files), VHDL. For -# instance to make doxygen treat .inc files as Fortran files (default is PHP), -# and .f files as C (default is Fortran), use: inc=Fortran f=C. -# -# Note For files without extension you can use no_extension as a placeholder. -# -# Note that for custom extensions you also need to set FILE_PATTERNS otherwise -# the files are not read by doxygen. - -EXTENSION_MAPPING = - -# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments -# according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. -# The output of markdown processing is further processed by doxygen, so you can -# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in -# case of backward compatibilities issues. -# The default value is: YES. - -MARKDOWN_SUPPORT = YES - -# When enabled doxygen tries to link words that correspond to documented -# classes, or namespaces to their corresponding documentation. Such a link can -# be prevented in individual cases by by putting a % sign in front of the word -# or globally by setting AUTOLINK_SUPPORT to NO. -# The default value is: YES. - -AUTOLINK_SUPPORT = YES - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should set this -# tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); -# versus func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. -# The default value is: NO. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. -# The default value is: NO. - -CPP_CLI_SUPPORT = YES - -# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: -# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen -# will parse them like normal C++ but will assume all classes use public instead -# of private inheritance when no explicit protection keyword is present. -# The default value is: NO. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate -# getter and setter methods for a property. Setting this option to YES will make -# doxygen to replace the get and set methods by a property in the documentation. -# This will only work if the methods are indeed getting or setting a simple -# type. If this is not the case, or you want to show the methods anyway, you -# should set this option to NO. -# The default value is: YES. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. -# The default value is: NO. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES to allow class member groups of the same type -# (for instance a group of public functions) to be put as a subgroup of that -# type (e.g. under the Public Functions section). Set it to NO to prevent -# subgrouping. Alternatively, this can be done per class using the -# \nosubgrouping command. -# The default value is: YES. - -SUBGROUPING = YES - -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions -# are shown inside the group in which they are included (e.g. using \ingroup) -# instead of on a separate page (for HTML and Man pages) or section (for LaTeX -# and RTF). -# -# Note that this feature does not work in combination with -# SEPARATE_MEMBER_PAGES. -# The default value is: NO. - -INLINE_GROUPED_CLASSES = NO - -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions -# with only public data fields or simple typedef fields will be shown inline in -# the documentation of the scope in which they are defined (i.e. file, -# namespace, or group documentation), provided this scope is documented. If set -# to NO, structs, classes, and unions are shown on a separate page (for HTML and -# Man pages) or section (for LaTeX and RTF). -# The default value is: NO. - -INLINE_SIMPLE_STRUCTS = NO - -# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or -# enum is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically be -# useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. -# The default value is: NO. - -TYPEDEF_HIDES_STRUCT = NO - -# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This -# cache is used to resolve symbols given their name and scope. Since this can be -# an expensive process and often the same symbol appears multiple times in the -# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small -# doxygen will become slower. If the cache is too large, memory is wasted. The -# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range -# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 -# symbols. At the end of a run doxygen will report the cache usage and suggest -# the optimal cache size from a speed point of view. -# Minimum value: 0, maximum value: 9, default value: 0. - -LOOKUP_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. Private -# class members and static file members will be hidden unless the -# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. -# Note: This will also disable the warnings about undocumented members that are -# normally produced when WARNINGS is set to YES. -# The default value is: NO. - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class will -# be included in the documentation. -# The default value is: NO. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal -# scope will be included in the documentation. -# The default value is: NO. - -EXTRACT_PACKAGE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file will be -# included in the documentation. -# The default value is: NO. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) defined -# locally in source files will be included in the documentation. If set to NO -# only classes defined in header files are included. Does not have any effect -# for Java sources. -# The default value is: YES. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local methods, -# which are defined in the implementation section but not in the interface are -# included in the documentation. If set to NO only methods in the interface are -# included. -# The default value is: NO. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base name of -# the file that contains the anonymous namespace. By default anonymous namespace -# are hidden. -# The default value is: NO. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all -# undocumented members inside documented classes or files. If set to NO these -# members will be included in the various overviews, but no documentation -# section is generated. This option has no effect if EXTRACT_ALL is enabled. -# The default value is: NO. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. If set -# to NO these classes will be included in the various overviews. This option has -# no effect if EXTRACT_ALL is enabled. -# The default value is: NO. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend -# (class|struct|union) declarations. If set to NO these declarations will be -# included in the documentation. -# The default value is: NO. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any -# documentation blocks found inside the body of a function. If set to NO these -# blocks will be appended to the function's detailed documentation block. -# The default value is: NO. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation that is typed after a -# \internal command is included. If the tag is set to NO then the documentation -# will be excluded. Set it to YES to include the internal documentation. -# The default value is: NO. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file -# names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. -# The default value is: system dependent. - -CASE_SENSE_NAMES = NO - -# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with -# their full class and namespace scopes in the documentation. If set to YES the -# scope will be hidden. -# The default value is: NO. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of -# the files that are included by a file in the documentation of that file. -# The default value is: YES. - -SHOW_INCLUDE_FILES = YES - -# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each -# grouped member an include statement to the documentation, telling the reader -# which file to include in order to use the member. -# The default value is: NO. - -SHOW_GROUPED_MEMB_INC = NO - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include -# files with double quotes in the documentation rather than with sharp brackets. -# The default value is: NO. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the -# documentation for inline members. -# The default value is: YES. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the -# (detailed) documentation of file and class members alphabetically by member -# name. If set to NO the members will appear in declaration order. -# The default value is: YES. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief -# descriptions of file, namespace and class members alphabetically by member -# name. If set to NO the members will appear in declaration order. Note that -# this will also influence the order of the classes in the class list. -# The default value is: NO. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the -# (brief and detailed) documentation of class members so that constructors and -# destructors are listed first. If set to NO the constructors will appear in the -# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. -# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief -# member documentation. -# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting -# detailed member documentation. -# The default value is: NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy -# of group names into alphabetical order. If set to NO the group names will -# appear in their defined order. -# The default value is: NO. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by -# fully-qualified names, including namespaces. If set to NO, the class list will -# be sorted only by class name, not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the alphabetical -# list. -# The default value is: NO. - -SORT_BY_SCOPE_NAME = NO - -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper -# type resolution of all parameters of a function it will reject a match between -# the prototype and the implementation of a member function even if there is -# only one candidate or it is obvious which candidate to choose by doing a -# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still -# accept a match between prototype and implementation in such cases. -# The default value is: NO. - -STRICT_PROTO_MATCHING = NO - -# The GENERATE_TODOLIST tag can be used to enable ( YES) or disable ( NO) the -# todo list. This list is created by putting \todo commands in the -# documentation. -# The default value is: YES. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable ( YES) or disable ( NO) the -# test list. This list is created by putting \test commands in the -# documentation. -# The default value is: YES. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable ( YES) or disable ( NO) the bug -# list. This list is created by putting \bug commands in the documentation. -# The default value is: YES. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable ( YES) or disable ( NO) -# the deprecated list. This list is created by putting \deprecated commands in -# the documentation. -# The default value is: YES. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional documentation -# sections, marked by \if ... \endif and \cond -# ... \endcond blocks. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the -# initial value of a variable or macro / define can have for it to appear in the -# documentation. If the initializer consists of more lines than specified here -# it will be hidden. Use a value of 0 to hide initializers completely. The -# appearance of the value of individual variables and macros / defines can be -# controlled using \showinitializer or \hideinitializer command in the -# documentation regardless of this setting. -# Minimum value: 0, maximum value: 10000, default value: 30. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at -# the bottom of the documentation of classes and structs. If set to YES the list -# will mention the files that were used to generate the documentation. -# The default value is: YES. - -SHOW_USED_FILES = YES - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This -# will remove the Files entry from the Quick Index and from the Folder Tree View -# (if specified). -# The default value is: YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces -# page. This will remove the Namespaces entry from the Quick Index and from the -# Folder Tree View (if specified). -# The default value is: YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command command input-file, where command is the value of the -# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided -# by doxygen. Whatever the program writes to standard output is used as the file -# version. For an example see the documentation. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. To create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. You can -# optionally specify a file name after the option, if omitted DoxygenLayout.xml -# will be used as the name of the layout file. -# -# Note that if you run doxygen from a directory containing a file called -# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE -# tag is left empty. - -LAYOUT_FILE = - -# The CITE_BIB_FILES tag can be used to specify one or more bib files containing -# the reference definitions. This must be a list of .bib files. The .bib -# extension is automatically appended if omitted. This requires the bibtex tool -# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. -# For LaTeX the style of the bibliography can be controlled using -# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the -# search path. See also \cite for info how to create references. - -CITE_BIB_FILES = - -#--------------------------------------------------------------------------- -# Configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated to -# standard output by doxygen. If QUIET is set to YES this implies that the -# messages are off. -# The default value is: NO. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES -# this implies that the warnings are on. -# -# Tip: Turn warnings on while writing the documentation. -# The default value is: YES. - -WARNINGS = YES - -# If the WARN_IF_UNDOCUMENTED tag is set to YES, then doxygen will generate -# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag -# will automatically be disabled. -# The default value is: YES. - -WARN_IF_UNDOCUMENTED = YES - -# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some parameters -# in a documented function, or documenting parameters that don't exist or using -# markup commands wrongly. -# The default value is: YES. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that -# are documented, but have no documentation for their parameters or return -# value. If set to NO doxygen will only warn about wrong or incomplete parameter -# documentation, but not about the absence of documentation. -# The default value is: NO. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that doxygen -# can produce. The string should contain the $file, $line, and $text tags, which -# will be replaced by the file and line number from which the warning originated -# and the warning text. Optionally the format may contain $version, which will -# be replaced by the version of the file (if it could be obtained via -# FILE_VERSION_FILTER) -# The default value is: $file:$line: $text. - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning and error -# messages should be written. If left blank the output is written to standard -# error (stderr). - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# Configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag is used to specify the files and/or directories that contain -# documented source files. You may enter file names like myfile.cpp or -# directories like /usr/src/myproject. Separate the files or directories with -# spaces. -# Note: If this tag is empty the current directory is searched. - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses -# libiconv (or the iconv built into libc) for the transcoding. See the libiconv -# documentation (see: http://www.gnu.org/software/libiconv) for the list of -# possible encodings. -# The default value is: UTF-8. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and -# *.h) to filter out the source-files in the directories. If left blank the -# following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii, -# *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp, -# *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown, -# *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, -# *.qsf, *.as and *.js. - -FILE_PATTERNS = *.c \ - *.cc \ - *.cxx \ - *.cpp \ - *.c++ \ - *.java \ - *.ii \ - *.ixx \ - *.ipp \ - *.i++ \ - *.inl \ - *.idl \ - *.ddl \ - *.odl \ - *.h \ - *.hh \ - *.hxx \ - *.hpp \ - *.h++ \ - *.cs \ - *.d \ - *.php \ - *.php4 \ - *.php5 \ - *.phtml \ - *.inc \ - *.m \ - *.markdown \ - *.md \ - *.mm \ - *.dox \ - *.py \ - *.f90 \ - *.f \ - *.for \ - *.tcl \ - *.vhd \ - *.vhdl \ - *.ucf \ - *.qsf \ - *.as \ - *.js - -# The RECURSIVE tag can be used to specify whether or not subdirectories should -# be searched for input files as well. -# The default value is: NO. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should be -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. -# -# Note that relative paths are relative to the directory from which doxygen is -# run. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded -# from the input. -# 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 = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test -# -# Note that the wildcards are matched against the file with absolute path, so to -# exclude all test directories use the pattern */test/* - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or directories -# that contain example code fragments that are included (see the \include -# command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and -# *.h) to filter out the source-files in the directories. If left blank all -# files are included. - -EXAMPLE_PATTERNS = * - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude commands -# irrespective of the value of the RECURSIVE tag. -# The default value is: NO. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or directories -# that contain images that are to be included in the documentation (see the -# \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command: -# -# -# -# where is the value of the INPUT_FILTER tag, and is the -# name of an input file. Doxygen will then use the output that the filter -# program writes to standard output. If FILTER_PATTERNS is specified, this tag -# will be ignored. -# -# Note that the filter must not add or remove lines; it is applied before the -# code is scanned, but not when the output code is generated. If lines are added -# or removed, the anchors will not be placed correctly. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: pattern=filter -# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how -# filters are used. If the FILTER_PATTERNS tag is empty or if none of the -# patterns match the file name, INPUT_FILTER is applied. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER ) will also be used to filter the input files that are used for -# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). -# The default value is: NO. - -FILTER_SOURCE_FILES = NO - -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and -# it is also possible to disable source filtering for a specific pattern using -# *.ext= (so without naming a filter). -# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. - -FILTER_SOURCE_PATTERNS = - -# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that -# is part of the input, its contents will be placed on the main page -# (index.html). This can be useful if you have a project on for instance GitHub -# and want to reuse the introduction page also for the doxygen output. - -USE_MDFILE_AS_MAINPAGE = - -#--------------------------------------------------------------------------- -# Configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will be -# generated. Documented entities will be cross-referenced with these sources. -# -# Note: To get rid of all source code in the generated output, make sure that -# also VERBATIM_HEADERS is set to NO. -# The default value is: NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body of functions, -# classes and enums directly into the documentation. -# The default value is: NO. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any -# special comment blocks from generated source code fragments. Normal C, C++ and -# Fortran comments will always remain visible. -# The default value is: YES. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES then for each documented -# function all documented functions referencing it will be listed. -# The default value is: NO. - -REFERENCED_BY_RELATION = NO - -# If the REFERENCES_RELATION tag is set to YES then for each documented function -# all documented entities called/used by that function will be listed. -# The default value is: NO. - -REFERENCES_RELATION = NO - -# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set -# to YES, then the hyperlinks from functions in REFERENCES_RELATION and -# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will -# link to the documentation. -# The default value is: YES. - -REFERENCES_LINK_SOURCE = YES - -# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the -# source code will show a tooltip with additional information such as prototype, -# brief description and links to the definition and documentation. Since this -# will make the HTML file larger and loading of large files a bit slower, you -# can opt to disable this feature. -# The default value is: YES. -# This tag requires that the tag SOURCE_BROWSER is set to YES. - -SOURCE_TOOLTIPS = YES - -# If the USE_HTAGS tag is set to YES then the references to source code will -# point to the HTML generated by the htags(1) tool instead of doxygen built-in -# source browser. The htags tool is part of GNU's global source tagging system -# (see http://www.gnu.org/software/global/global.html). You will need version -# 4.8.6 or higher. -# -# To use it do the following: -# - Install the latest version of global -# - Enable SOURCE_BROWSER and USE_HTAGS in the config file -# - Make sure the INPUT points to the root of the source tree -# - Run doxygen as normal -# -# Doxygen will invoke htags (and that will in turn invoke gtags), so these -# tools must be available from the command line (i.e. in the search path). -# -# The result: instead of the source browser generated by doxygen, the links to -# source code will now point to the output of htags. -# The default value is: NO. -# This tag requires that the tag SOURCE_BROWSER is set to YES. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a -# verbatim copy of the header file for each class for which an include is -# specified. Set to NO to disable this. -# See also: Section \class. -# The default value is: YES. - -VERBATIM_HEADERS = YES - -# If the CLANG_ASSISTED_PARSING tag is set to YES, then doxygen will use the -# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the -# cost of reduced performance. This can be particularly helpful with template -# rich C++ code for which doxygen's built-in parser lacks the necessary type -# information. -# Note: The availability of this option depends on whether or not doxygen was -# compiled with the --with-libclang option. -# The default value is: NO. - -CLANG_ASSISTED_PARSING = NO - -# If clang assisted parsing is enabled you can provide the compiler with command -# line options that you would normally use when invoking the compiler. Note that -# the include paths will already be set by doxygen for the files and directories -# specified with INPUT and INCLUDE_PATH. -# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. - -CLANG_OPTIONS = - -#--------------------------------------------------------------------------- -# Configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all -# compounds will be generated. Enable this if the project contains a lot of -# classes, structs, unions or interfaces. -# The default value is: YES. - -ALPHABETICAL_INDEX = YES - -# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in -# which the alphabetical index list will be split. -# Minimum value: 1, maximum value: 20, default value: 5. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all classes will -# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag -# can be used to specify a prefix (or a list of prefixes) that should be ignored -# while generating the index headers. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES doxygen will generate HTML output -# The default value is: YES. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a -# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of -# it. -# The default directory is: html. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each -# generated HTML page (for example: .htm, .php, .asp). -# The default value is: .html. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a user-defined HTML header file for -# each generated HTML page. If the tag is left blank doxygen will generate a -# standard header. -# -# To get valid HTML the header file that includes any scripts and style sheets -# that doxygen needs, which is dependent on the configuration options used (e.g. -# the setting GENERATE_TREEVIEW). It is highly recommended to start with a -# default header using -# doxygen -w html new_header.html new_footer.html new_stylesheet.css -# YourConfigFile -# and then modify the file new_header.html. See also section "Doxygen usage" -# for information on how to generate the default header that doxygen normally -# uses. -# Note: The header is subject to change so you typically have to regenerate the -# default header when upgrading to a newer version of doxygen. For a description -# of the possible markers and block names see the documentation. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_HEADER = header.html - -# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each -# generated HTML page. If the tag is left blank doxygen will generate a standard -# footer. See HTML_HEADER for more information on how to generate a default -# footer and what special commands can be used inside the footer. See also -# section "Doxygen usage" for information on how to generate the default footer -# that doxygen normally uses. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_FOOTER = footer.html - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style -# sheet that is used by each HTML page. It can be used to fine-tune the look of -# the HTML output. If left blank doxygen will generate a default style sheet. -# See also section "Doxygen usage" for information on how to generate the style -# sheet that doxygen normally uses. -# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as -# it is more robust and this tag (HTML_STYLESHEET) will in the future become -# obsolete. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_STYLESHEET = - -# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined -# cascading style sheets that are included after the standard style sheets -# created by doxygen. Using this option one can overrule certain style aspects. -# This is preferred over using HTML_STYLESHEET since it does not replace the -# standard style sheet and is therefor more robust against future updates. -# Doxygen will copy the style sheet files to the output directory. -# Note: The order of the extra stylesheet files is of importance (e.g. the last -# stylesheet in the list overrules the setting of the previous ones in the -# list). For an example see the documentation. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_EXTRA_STYLESHEET = customdoxygen.css - -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that the -# files will be copied as-is; there are no commands or markers available. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_EXTRA_FILES = - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen -# will adjust the colors in the stylesheet and background images according to -# this color. Hue is specified as an angle on a colorwheel, see -# http://en.wikipedia.org/wiki/Hue for more information. For instance the value -# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 -# purple, and 360 is red again. -# Minimum value: 0, maximum value: 359, default value: 220. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors -# in the HTML output. For a value of 0 the output will use grayscales only. A -# value of 255 will produce the most vivid colors. -# Minimum value: 0, maximum value: 255, default value: 100. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_SAT = 100 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the -# luminance component of the colors in the HTML output. Values below 100 -# gradually make the output lighter, whereas values above 100 make the output -# darker. The value divided by 100 is the actual gamma applied, so 80 represents -# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not -# change the gamma. -# Minimum value: 40, maximum value: 240, default value: 80. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting this -# to NO can help when comparing the output of multiple runs. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_TIMESTAMP = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_DYNAMIC_SECTIONS = NO - -# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries -# shown in the various tree structured indices initially; the user can expand -# and collapse entries dynamically later on. Doxygen will expand the tree to -# such a level that at most the specified number of entries are visible (unless -# a fully collapsed tree already exceeds this amount). So setting the number of -# entries 1 will produce a full collapsed tree by default. 0 is a special value -# representing an infinite number of entries and will result in a full expanded -# tree by default. -# Minimum value: 0, maximum value: 9999, default value: 100. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_INDEX_NUM_ENTRIES = 100 - -# If the GENERATE_DOCSET tag is set to YES, additional index files will be -# generated that can be used as input for Apple's Xcode 3 integrated development -# environment (see: http://developer.apple.com/tools/xcode/), introduced with -# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a -# Makefile in the HTML output directory. Running make will produce the docset in -# that directory and running make install will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at -# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_DOCSET = NO - -# This tag determines the name of the docset feed. A documentation feed provides -# an umbrella under which multiple documentation sets from a single provider -# (such as a company or product suite) can be grouped. -# The default value is: Doxygen generated docs. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# This tag specifies a string that should uniquely identify the documentation -# set bundle. This should be a reverse domain-name style string, e.g. -# com.mycompany.MyDocSet. Doxygen will append .docset to the name. -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify -# the documentation publisher. This should be a reverse domain-name style -# string, e.g. com.mycompany.MyDocSet.documentation. -# The default value is: org.doxygen.Publisher. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_PUBLISHER_ID = org.doxygen.Publisher - -# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. -# The default value is: Publisher. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_PUBLISHER_NAME = Publisher - -# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three -# additional HTML index files: index.hhp, index.hhc, and index.hhk. The -# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop -# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on -# Windows. -# -# The HTML Help Workshop contains a compiler that can convert all HTML output -# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML -# files are now used as the Windows 98 help format, and will replace the old -# Windows help format (.hlp) on all Windows platforms in the future. Compressed -# HTML files also contain an index, a table of contents, and you can search for -# words in the documentation. The HTML workshop also contains a viewer for -# compressed HTML files. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_HTMLHELP = NO - -# The CHM_FILE tag can be used to specify the file name of the resulting .chm -# file. You can add a path in front of the file if the result should not be -# written to the html output directory. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -CHM_FILE = - -# The HHC_LOCATION tag can be used to specify the location (absolute path -# including file name) of the HTML help compiler ( hhc.exe). If non-empty -# doxygen will try to run the HTML help compiler on the generated index.hhp. -# The file has to be specified with full path. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -HHC_LOCATION = - -# The GENERATE_CHI flag controls if a separate .chi index file is generated ( -# YES) or that it should be included in the master .chm file ( NO). -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -GENERATE_CHI = NO - -# The CHM_INDEX_ENCODING is used to encode HtmlHelp index ( hhk), content ( hhc) -# and project file content. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -CHM_INDEX_ENCODING = - -# The BINARY_TOC flag controls whether a binary table of contents is generated ( -# YES) or a normal table of contents ( NO) in the .chm file. Furthermore it -# enables the Previous and Next buttons. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members to -# the table of contents of the HTML help documentation and to the tree view. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that -# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help -# (.qch) of the generated HTML documentation. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify -# the file name of the resulting .qch file. The path specified is relative to -# the HTML output folder. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help -# Project output. For more information please see Qt Help Project / Namespace -# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt -# Help Project output. For more information please see Qt Help Project / Virtual -# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- -# folders). -# The default value is: doc. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_VIRTUAL_FOLDER = doc - -# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom -# filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's filter section matches. Qt Help Project / Filter Attributes (see: -# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_SECT_FILTER_ATTRS = - -# The QHG_LOCATION tag can be used to specify the location of Qt's -# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the -# generated .qhp file. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be -# generated, together with the HTML files, they form an Eclipse help plugin. To -# install this plugin and make it available under the help contents menu in -# Eclipse, the contents of the directory containing the HTML and XML files needs -# to be copied into the plugins directory of eclipse. The name of the directory -# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. -# After copying Eclipse needs to be restarted before the help appears. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the Eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have this -# name. Each documentation set should have its own identifier. -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# If you want full control over the layout of the generated HTML pages it might -# be necessary to disable the index and replace it with your own. The -# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top -# of each HTML page. A value of NO enables the index and the value YES disables -# it. Since the tabs in the index contain the same information as the navigation -# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -DISABLE_INDEX = NO - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. If the tag -# value is set to YES, a side panel will be generated containing a tree-like -# index structure (just like the one that is generated for HTML Help). For this -# to work a browser that supports JavaScript, DHTML, CSS and frames is required -# (i.e. any modern browser). Windows users are probably better off using the -# HTML help feature. Via custom stylesheets (see HTML_EXTRA_STYLESHEET) one can -# further fine-tune the look of the index. As an example, the default style -# sheet generated by doxygen has an example that shows how to put an image at -# the root of the tree instead of the PROJECT_NAME. Since the tree basically has -# the same information as the tab index, you could consider setting -# DISABLE_INDEX to YES when enabling this option. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_TREEVIEW = NO - -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that -# doxygen will group on one line in the generated HTML documentation. -# -# Note that a value of 0 will completely suppress the enum values from appearing -# in the overview section. -# Minimum value: 0, maximum value: 20, default value: 4. -# This tag requires that the tag GENERATE_HTML is set to YES. - -ENUM_VALUES_PER_LINE = 4 - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used -# to set the initial width (in pixels) of the frame in which the tree is shown. -# Minimum value: 0, maximum value: 1500, default value: 250. -# This tag requires that the tag GENERATE_HTML is set to YES. - -TREEVIEW_WIDTH = 250 - -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open links to -# external symbols imported via tag files in a separate window. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -EXT_LINKS_IN_WINDOW = NO - -# Use this tag to change the font size of LaTeX formulas included as images in -# the HTML documentation. When you change the font size after a successful -# doxygen run you need to manually remove any form_*.png images from the HTML -# output directory to force them to be regenerated. -# Minimum value: 8, maximum value: 50, default value: 10. -# This tag requires that the tag GENERATE_HTML is set to YES. - -FORMULA_FONTSIZE = 10 - -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are not -# supported properly for IE 6.0, but are supported on all modern browsers. -# -# Note that when changing this option you need to delete any form_*.png files in -# the HTML output directory before the changes have effect. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. - -FORMULA_TRANSPARENT = YES - -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see -# http://www.mathjax.org) which uses client side Javascript for the rendering -# instead of using prerendered bitmaps. Use this if you do not have LaTeX -# installed or if you want to formulas look prettier in the HTML output. When -# enabled you may also need to install MathJax separately and configure the path -# to it using the MATHJAX_RELPATH option. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -USE_MATHJAX = NO - -# When MathJax is enabled you can set the default output format to be used for -# the MathJax output. See the MathJax site (see: -# http://docs.mathjax.org/en/latest/output.html) for more details. -# Possible values are: HTML-CSS (which is slower, but has the best -# compatibility), NativeMML (i.e. MathML) and SVG. -# The default value is: HTML-CSS. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_FORMAT = HTML-CSS - -# When MathJax is enabled you need to specify the location relative to the HTML -# output directory using the MATHJAX_RELPATH option. The destination directory -# should contain the MathJax.js script. For instance, if the mathjax directory -# is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax -# Content Delivery Network so you can quickly see the result without installing -# MathJax. However, it is strongly recommended to install a local copy of -# MathJax from http://www.mathjax.org before deployment. -# The default value is: http://cdn.mathjax.org/mathjax/latest. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest - -# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax -# extension names that should be enabled during MathJax rendering. For example -# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_EXTENSIONS = - -# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces -# of code that will be used on startup of the MathJax code. See the MathJax site -# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an -# example see the documentation. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_CODEFILE = - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box for -# the HTML output. The underlying search engine uses javascript and DHTML and -# should work on any modern browser. Note that when using HTML help -# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) -# there is already a search function so this one should typically be disabled. -# For large projects the javascript based search engine can be slow, then -# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to -# search using the keyboard; to jump to the search box use + S -# (what the is depends on the OS and browser, but it is typically -# , /