From 9b89e6fd9225e12fa909c4ad7a7003e788b0fb33 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Tue, 26 Apr 2016 15:33:16 +0100 Subject: [PATCH] fix scripts --- C/arrays.c | 2046 ++++++++++++++++++--------------------- C/flags.c | 57 +- H/ATOMS | 570 +++++++++++ {misc => H}/GLOBALS | 0 {misc => H}/HEAPFIELDS | 2 +- {misc => H}/LOCALS | 0 H/generated/dglobals.h | 2 +- H/generated/dhstruct.h | 2 +- H/generated/dlocals.h | 2 +- H/generated/h0globals.h | 2 +- H/generated/h0struct.h | 2 +- H/generated/hglobals.h | 2 +- H/generated/hlocals.h | 2 +- H/generated/hstruct.h | 2 +- H/generated/iatoms.h | 15 +- H/generated/iglobals.h | 2 +- H/generated/ihstruct.h | 2 +- H/generated/ilocals.h | 2 +- H/generated/ratoms.h | 13 +- H/generated/rhstruct.h | 2 +- H/generated/rlocals.h | 2 +- H/generated/tatoms.h | 18 +- H/hstruct.h | 303 ------ misc/ATOMS | 20 +- misc/buildatoms | 6 +- misc/buildheap | 343 ------- misc/buildlocalglobal | 36 +- 27 files changed, 1654 insertions(+), 1801 deletions(-) create mode 100644 H/ATOMS rename {misc => H}/GLOBALS (100%) rename {misc => H}/HEAPFIELDS (99%) rename {misc => H}/LOCALS (100%) delete mode 100644 H/hstruct.h delete mode 100644 misc/buildheap diff --git a/C/arrays.c b/C/arrays.c index cf8385f26..d5bff5a46 100644 --- a/C/arrays.c +++ b/C/arrays.c @@ -15,7 +15,6 @@ * * *************************************************************************/ - /** @defgroup YAPArrays Named Arrays @ingroup extensions @{ @@ -83,8 +82,8 @@ 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), + array_element(Y,J,E2), + array_element(Z,I,E3), E1 is E2+E3. ~~~~~ @@ -97,9 +96,8 @@ The following predicates manipulate arrays: - -*/ +*/ #include "Yap.h" #include "Yatom.h" @@ -121,85 +119,85 @@ extern int errno; #endif #endif -static Int compile_array_refs( USES_REGS1 ); -static Int array_refs_compiled( USES_REGS1 ); -static Int sync_mmapped_arrays( USES_REGS1 ); +static Int compile_array_refs(USES_REGS1); +static Int array_refs_compiled(USES_REGS1); +static Int sync_mmapped_arrays(USES_REGS1); /** * === Implementation Notes - * + * * This file works together with pl/arrays.yap and arrays.h. - * + * * YAP supports a very simple notion of arrays. Arrays may be * allocated dynamically or statically: - * + * * o anonymous arrays are created during execution and allocated * in the heap. They have the lifetime of any other other heap * object. Any term can be an argument to a dynamic array. - * + * * Dynamic arrays are named as a free variable and are * initialized with free variables. - * + * * o named arrays are created during execution but allocated * in the code space. They have the lifetime of an heap * object. Any term can be an argument to a dynamic array. - * + * * Named arrays are named with atoms and are initialized with * free variables. - * + * * + static arrays are allocated in the heap. Their space is * never recovered unless explicitly said so by the * program. Arguments to these arrays must have fixed size, * and can only be atomic (at least for now). - * + * * Static arrays can be named through an atom. They are * initialized with []. - * + * * Users create arrays by a declaration X array Arity. If X is an atom * A, then this it is a static array and A's the array name, otherwise * X refers to a dynamic array. - * + * * As in C, arrays start counting from 0. - * + * * Users access arrays by a token X[I] or a[I], this token can appear * anywhere within the computation, so a[2] = X[3*4] means that the * second element of global array a should unify with the 12th element * of array X. The mechanism used to implement this is the same * mechanism used to implement suspension variables. - * + * * ==== Representation: - * + * * Dynamic Arrays are represented as a compound term of arity N, where * N is the size of the array. Even so, I will not include array bound * checking for now. - * + * * ~~~~ * |--------------------------------------------------------------| * | $ARRAY/N|.... * |______________________________________________________________ * ~~~~ - * + * * Unbound Var is used as a place to point to. - * + * * Static Arrays are represented as a special property for an atom, - * with field size and - * + * with field size and + * * A term of the form X[I] is represented as a Reference pointing to * the compound term: - * + * * []([I],X) - * + * */ -static Int create_array( USES_REGS1 ); -static Int create_mmapped_array( USES_REGS1 ); -static Int array_references( USES_REGS1 ); -static Int create_static_array( USES_REGS1 ); -static Int resize_static_array( USES_REGS1 ); -static Int close_static_array( USES_REGS1 ); -static Int access_array( USES_REGS1 ); -static Int assign_static( USES_REGS1 ); -static Int assign_dynamic( USES_REGS1 ); +static Int create_array(USES_REGS1); +static Int create_mmapped_array(USES_REGS1); +static Int array_references(USES_REGS1); +static Int create_static_array(USES_REGS1); +static Int resize_static_array(USES_REGS1); +static Int close_static_array(USES_REGS1); +static Int access_array(USES_REGS1); +static Int assign_static(USES_REGS1); +static Int assign_dynamic(USES_REGS1); #if HAVE_MMAP @@ -221,16 +219,13 @@ static Int assign_dynamic( USES_REGS1 ); typedef struct MMAP_ARRAY_BLOCK { Atom name; void *start; - size_t size; + size_t size; Int items; - int fd; + int fd; struct MMAP_ARRAY_BLOCK *next; } mmap_array_block; - -static Int -CloseMmappedArray(StaticArrayEntry *pp, void *area USES_REGS) -{ +static Int CloseMmappedArray(StaticArrayEntry *pp, void *area USES_REGS) { mmap_array_block *ptr = GLOBAL_mmap_arrays, *optr = GLOBAL_mmap_arrays; while (ptr != NULL && ptr->start != area) { @@ -239,30 +234,32 @@ CloseMmappedArray(StaticArrayEntry *pp, void *area USES_REGS) } if (ptr == NULL) { #if !defined(USE_SYSTEM_MALLOC) - Yap_Error(SYSTEM_ERROR_INTERNAL,ARG1,"close_mmapped_array (array chain incoherent)", strerror(errno)); + Yap_Error(SYSTEM_ERROR_INTERNAL, ARG1, + "close_mmapped_array (array chain incoherent)", strerror(errno)); #endif return FALSE; } if (munmap(ptr->start, ptr->size) == -1) { - Yap_Error(SYSTEM_ERROR_INTERNAL,ARG1,"close_mmapped_array (munmap: %s)", strerror(errno)); - return(FALSE); + Yap_Error(SYSTEM_ERROR_INTERNAL, ARG1, "close_mmapped_array (munmap: %s)", + strerror(errno)); + return (FALSE); } optr->next = ptr->next; pp->ValueOfVE.ints = NULL; pp->ArrayEArity = 0; if (close(ptr->fd) < 0) { - Yap_Error(SYSTEM_ERROR_INTERNAL,ARG1,"close_mmapped_array (close: %s)", strerror(errno)); - return(FALSE); + Yap_Error(SYSTEM_ERROR_INTERNAL, ARG1, "close_mmapped_array (close: %s)", + strerror(errno)); + return (FALSE); } Yap_FreeAtomSpace((char *)ptr); - return(TRUE); + return (TRUE); } -static void -ResizeMmappedArray(StaticArrayEntry *pp, Int dim, void *area USES_REGS) -{ +static void ResizeMmappedArray(StaticArrayEntry *pp, Int dim, + void *area USES_REGS) { mmap_array_block *ptr = GLOBAL_mmap_arrays; - size_t total_size; + size_t total_size; while (ptr != NULL && ptr->start != area) { ptr = ptr->next; } @@ -274,24 +271,30 @@ ResizeMmappedArray(StaticArrayEntry *pp, Int dim, void *area USES_REGS) and last we initialize again */ if (munmap(ptr->start, ptr->size) == -1) { - Yap_Error(SYSTEM_ERROR_INTERNAL,ARG1,"resize_mmapped_array (munmap: %s)", strerror(errno)); - return; - } - total_size = (ptr->size / ptr->items)*dim; - if (ftruncate(ptr->fd, total_size) < 0) { - Yap_Error(SYSTEM_ERROR_INTERNAL,ARG1,"resize_mmapped_array (ftruncate: %s)", strerror(errno)); + Yap_Error(SYSTEM_ERROR_INTERNAL, ARG1, "resize_mmapped_array (munmap: %s)", + strerror(errno)); return; } - if (lseek(ptr->fd, total_size-1, SEEK_SET) < 0) { - Yap_Error(SYSTEM_ERROR_INTERNAL,ARG1,"resize_mmapped_array (lseek: %s)", strerror(errno)); + total_size = (ptr->size / ptr->items) * dim; + if (ftruncate(ptr->fd, total_size) < 0) { + Yap_Error(SYSTEM_ERROR_INTERNAL, ARG1, + "resize_mmapped_array (ftruncate: %s)", strerror(errno)); + return; + } + if (lseek(ptr->fd, total_size - 1, SEEK_SET) < 0) { + Yap_Error(SYSTEM_ERROR_INTERNAL, ARG1, "resize_mmapped_array (lseek: %s)", + strerror(errno)); return; } if (write(ptr->fd, "", 1) < 0) { - Yap_Error(SYSTEM_ERROR_INTERNAL,ARG1,"resize_mmapped_array (write: %s)", strerror(errno)); + Yap_Error(SYSTEM_ERROR_INTERNAL, ARG1, "resize_mmapped_array (write: %s)", + strerror(errno)); return; } - if ((ptr->start = (void *)mmap(0, (size_t) total_size, PROT_READ | PROT_WRITE, MAP_SHARED, ptr->fd, 0)) == (void *) - 1) { - Yap_Error(SYSTEM_ERROR_INTERNAL,ARG1,"resize_mmapped_array (mmap: %s)", strerror(errno)); + if ((ptr->start = (void *)mmap(0, (size_t)total_size, PROT_READ | PROT_WRITE, + MAP_SHARED, ptr->fd, 0)) == (void *)-1) { + Yap_Error(SYSTEM_ERROR_INTERNAL, ARG1, "resize_mmapped_array (mmap: %s)", + strerror(errno)); return; } ptr->size = total_size; @@ -301,25 +304,24 @@ ResizeMmappedArray(StaticArrayEntry *pp, Int dim, void *area USES_REGS) #endif -static Term -GetTermFromArray(DBTerm *ref USES_REGS) -{ +static Term GetTermFromArray(DBTerm *ref USES_REGS) { if (ref != NULL) { Term TRef; while ((TRef = Yap_FetchTermFromDB(ref)) == 0L) { if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { - LOCAL_Error_TYPE = YAP_NO_ERROR; - if (!Yap_growglobal(NULL)) { - Yap_Error(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, TermNil, LOCAL_ErrorMessage); - return TermNil; - } + LOCAL_Error_TYPE = YAP_NO_ERROR; + if (!Yap_growglobal(NULL)) { + Yap_Error(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, TermNil, + LOCAL_ErrorMessage); + return TermNil; + } } else { - LOCAL_Error_TYPE = YAP_NO_ERROR; - if (!Yap_gcl(LOCAL_Error_Size, 3, ENV, Yap_gcP())) { - Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); - return TermNil; - } + LOCAL_Error_TYPE = YAP_NO_ERROR; + if (!Yap_gcl(LOCAL_Error_Size, 3, ENV, Yap_gcP())) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); + return TermNil; + } } } return TRef; @@ -329,9 +331,7 @@ GetTermFromArray(DBTerm *ref USES_REGS) } } -static Term -GetNBTerm(live_term *ar, Int indx USES_REGS) -{ +static Term GetNBTerm(live_term *ar, Int indx USES_REGS) { /* The object is now in use */ Term livet = ar[indx].tlive; @@ -356,7 +356,7 @@ GetNBTerm(live_term *ar, Int indx USES_REGS) } else { DBTerm *ref = (DBTerm *)RepAppl(termt); if ((livet = GetTermFromArray(ref PASS_REGS)) == TermNil) { - return TermNil; + return TermNil; } } YapBind(&(ar[indx].tlive), livet); @@ -364,169 +364,151 @@ GetNBTerm(live_term *ar, Int indx USES_REGS) } } -static ArrayEntry * -GetArrayEntry( Atom at, int owner ) -{ - CACHE_REGS +static ArrayEntry *GetArrayEntry(Atom at, int owner) { + CACHE_REGS ArrayEntry *pp; AtomEntry *ae = RepAtom(at); - + READ_LOCK(ae->ARWLock); pp = RepArrayProp(ae->PropsOfAE); - while (!EndOfPAEntr(pp) && - pp->KindOfPE != ArrayProperty + while (!EndOfPAEntr(pp) && pp->KindOfPE != ArrayProperty #if THREADS - && pp->owner_id != worker_id + && pp->owner_id != worker_id #endif - ) + ) pp = RepArrayProp(pp->NextOfPE); READ_UNLOCK(ae->ARWLock); return pp; } +static Term AccessNamedArray(Atom a, Int indx USES_REGS) { + ArrayEntry *pp; + AtomEntry *ae = RepAtom(a); -static Term -AccessNamedArray(Atom a, Int indx USES_REGS) -{ - ArrayEntry *pp; - AtomEntry *ae = RepAtom(a); - - pp = GetArrayEntry( ae , worker_id ); + pp = GetArrayEntry(ae, worker_id); if (!EndOfPAEntr(pp)) { if (ArrayIsDynamic(pp)) { Term out; READ_LOCK(pp->ArRWLock); - if (IsVarTerm(pp->ValueOfVE) || - pp->ArrayEArity <= indx || - indx < 0) { - READ_UNLOCK(pp->ArRWLock); - P = (yamop *)FAILCODE; - return(MkAtomTerm(AtomFoundVar)); + if (IsVarTerm(pp->ValueOfVE) || pp->ArrayEArity <= indx || indx < 0) { + READ_UNLOCK(pp->ArRWLock); + P = (yamop *)FAILCODE; + return (MkAtomTerm(AtomFoundVar)); } - out = RepAppl(pp->ValueOfVE)[indx+1]; + out = RepAppl(pp->ValueOfVE)[indx + 1]; READ_UNLOCK(pp->ArRWLock); - return(out); + return (out); } else { StaticArrayEntry *ptr = (StaticArrayEntry *)pp; READ_LOCK(ptr->ArRWLock); if (pp->ArrayEArity <= indx || indx < 0) { - /* Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW, MkIntegerTerm(indx), "access_array");*/ - READ_UNLOCK(ptr->ArRWLock); - P = (yamop *)FAILCODE; - return(MkAtomTerm(AtomFoundVar)); + /* Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW, MkIntegerTerm(indx), + * "access_array");*/ + READ_UNLOCK(ptr->ArRWLock); + P = (yamop *)FAILCODE; + return (MkAtomTerm(AtomFoundVar)); } switch (ptr->ArrayType) { - case array_of_ints: - { - Term out; - out = MkIntegerTerm(ptr->ValueOfVE.ints[indx]); - READ_UNLOCK(ptr->ArRWLock); - return out; - } - case array_of_doubles: - { - Term out; - out = MkEvalFl(ptr->ValueOfVE.floats[indx]); - READ_UNLOCK(ptr->ArRWLock); - return out; - } - case array_of_ptrs: - { - Term out; - out = MkIntegerTerm((Int)(ptr->ValueOfVE.ptrs[indx])); - READ_UNLOCK(ptr->ArRWLock); - return out; - } - case array_of_atoms: - { - Term out; - out = ptr->ValueOfVE.atoms[indx]; - READ_UNLOCK(ptr->ArRWLock); - if (out == 0L) - return TermNil; - else - return out; - } - /* just return the atom */ - case array_of_chars: - { - Term out; - out = MkIntegerTerm((Int)(ptr->ValueOfVE.chars[indx])); - READ_UNLOCK(ptr->ArRWLock); - return out; - } - case array_of_uchars: - { - Term out; - out = MkIntegerTerm((Int)(ptr->ValueOfVE.uchars[indx])); - READ_UNLOCK(ptr->ArRWLock); - return out; - } - case array_of_dbrefs: - { - /* The object is now in use */ - Term TRef = ptr->ValueOfVE.dbrefs[indx]; + case array_of_ints: { + Term out; + out = MkIntegerTerm(ptr->ValueOfVE.ints[indx]); + READ_UNLOCK(ptr->ArRWLock); + return out; + } + case array_of_doubles: { + Term out; + out = MkEvalFl(ptr->ValueOfVE.floats[indx]); + READ_UNLOCK(ptr->ArRWLock); + return out; + } + case array_of_ptrs: { + Term out; + out = MkIntegerTerm((Int)(ptr->ValueOfVE.ptrs[indx])); + READ_UNLOCK(ptr->ArRWLock); + return out; + } + case array_of_atoms: { + Term out; + out = ptr->ValueOfVE.atoms[indx]; + READ_UNLOCK(ptr->ArRWLock); + if (out == 0L) + return TermNil; + else + return out; + } + /* just return the atom */ + case array_of_chars: { + Term out; + out = MkIntegerTerm((Int)(ptr->ValueOfVE.chars[indx])); + READ_UNLOCK(ptr->ArRWLock); + return out; + } + case array_of_uchars: { + Term out; + out = MkIntegerTerm((Int)(ptr->ValueOfVE.uchars[indx])); + READ_UNLOCK(ptr->ArRWLock); + return out; + } + case array_of_dbrefs: { + /* The object is now in use */ + Term TRef = ptr->ValueOfVE.dbrefs[indx]; - READ_UNLOCK(ptr->ArRWLock); - if (TRef != 0L) { - DBRef ref = DBRefOfTerm(TRef); + READ_UNLOCK(ptr->ArRWLock); + if (TRef != 0L) { + DBRef ref = DBRefOfTerm(TRef); #if MULTIPLE_STACKS - LOCK(ref->lock); - INC_DBREF_COUNT(ref); - TRAIL_REF(ref); /* So that fail will erase it */ - UNLOCK(ref->lock); + LOCK(ref->lock); + INC_DBREF_COUNT(ref); + TRAIL_REF(ref); /* So that fail will erase it */ + UNLOCK(ref->lock); #else - if (ref->Flags & LogUpdMask) { - LogUpdClause *cl = (LogUpdClause *)ref; + if (ref->Flags & LogUpdMask) { + LogUpdClause *cl = (LogUpdClause *)ref; - if (!(cl->ClFlags & InUseMask)) { - cl->ClFlags |= InUseMask; - TRAIL_CLREF(cl); - } - } else { - if (!(ref->Flags & InUseMask)) { - ref->Flags |= InUseMask; - TRAIL_REF(ref); /* So that fail will erase it */ - } - } + if (!(cl->ClFlags & InUseMask)) { + cl->ClFlags |= InUseMask; + TRAIL_CLREF(cl); + } + } else { + if (!(ref->Flags & InUseMask)) { + ref->Flags |= InUseMask; + TRAIL_REF(ref); /* So that fail will erase it */ + } + } #endif - } else { - P = (yamop *)FAILCODE; - TRef = TermNil; - } - return TRef; - } - case array_of_nb_terms: - { - /* The object is now in use */ - Term out = GetNBTerm(ptr->ValueOfVE.lterms, indx PASS_REGS); - - READ_UNLOCK(ptr->ArRWLock); - return out; - } - case array_of_terms: - { - /* The object is now in use */ - DBTerm *ref = ptr->ValueOfVE.terms[indx]; - - READ_UNLOCK(ptr->ArRWLock); - return GetTermFromArray(ref PASS_REGS); - } - default: - READ_UNLOCK(ptr->ArRWLock); - return TermNil; + } else { + P = (yamop *)FAILCODE; + TRef = TermNil; + } + return TRef; } - } - } - else { - Yap_Error(EXISTENCE_ERROR_ARRAY,MkAtomTerm(a),"named array"); + case array_of_nb_terms: { + /* The object is now in use */ + Term out = GetNBTerm(ptr->ValueOfVE.lterms, indx PASS_REGS); + + READ_UNLOCK(ptr->ArRWLock); + return out; + } + case array_of_terms: { + /* The object is now in use */ + DBTerm *ref = ptr->ValueOfVE.terms[indx]; + + READ_UNLOCK(ptr->ArRWLock); + return GetTermFromArray(ref PASS_REGS); + } + default: + READ_UNLOCK(ptr->ArRWLock); + return TermNil; + } + } + } else { + Yap_Error(EXISTENCE_ERROR_ARRAY, MkAtomTerm(a), "named array"); return (TermNil); } - } /** @pred array_element(+ _Name_, + _Index_, ? _Element_) @@ -540,9 +522,7 @@ it can be used to unify with an element of a dynamic array. */ /// @memberof array_element/3 -static Int -access_array( USES_REGS1 ) -{ +static Int access_array(USES_REGS1) { Term t = Deref(ARG1); Term ti = Deref(ARG2); Term tf; @@ -550,59 +530,56 @@ access_array( USES_REGS1 ) if (IsNonVarTerm(ti)) { Term nti; - if (IsIntegerTerm(nti=Yap_Eval(ti))) + if (IsIntegerTerm(nti = Yap_Eval(ti))) indx = IntegerOfTerm(nti); else { - Yap_Error(TYPE_ERROR_INTEGER,ti,"access_array"); + Yap_Error(TYPE_ERROR_INTEGER, ti, "access_array"); return (FALSE); } - } - else { - Yap_Error(INSTANTIATION_ERROR,ti,"access_array"); + } else { + Yap_Error(INSTANTIATION_ERROR, ti, "access_array"); return (TermNil); } if (IsNonVarTerm(t)) { if (IsApplTerm(t)) { if (indx >= ArityOfFunctor(FunctorOfTerm(t)) || indx < 0) { - /* Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW, MkIntegerTerm(indx), "access_array");*/ - P = (yamop *)FAILCODE; - return(FALSE); + /* Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW, MkIntegerTerm(indx), + * "access_array");*/ + P = (yamop *)FAILCODE; + return (FALSE); } tf = (RepAppl(t))[indx + 1]; } else if (IsAtomTerm(t)) { tf = AccessNamedArray(AtomOfTerm(t), indx PASS_REGS); if (tf == MkAtomTerm(AtomFoundVar)) { - return(FALSE); + return (FALSE); } } else { - Yap_Error(TYPE_ERROR_ARRAY,t,"access_array"); - return(FALSE); - } + Yap_Error(TYPE_ERROR_ARRAY, t, "access_array"); + return (FALSE); + } } else { - Yap_Error(INSTANTIATION_ERROR,t,"access_array"); - return(FALSE); + Yap_Error(INSTANTIATION_ERROR, t, "access_array"); + return (FALSE); } return Yap_unify(tf, ARG3); } -static Int -array_arg( USES_REGS1 ) -{ +static Int array_arg(USES_REGS1) { register Term ti = Deref(ARG3), t; register Int indx; if (IsNonVarTerm(ti)) { Term nti; - if (IsIntegerTerm(nti=Yap_Eval(ti))) + if (IsIntegerTerm(nti = Yap_Eval(ti))) indx = IntegerOfTerm(nti); else { - Yap_Error(TYPE_ERROR_INTEGER,ti,"access_array"); + Yap_Error(TYPE_ERROR_INTEGER, ti, "access_array"); return (FALSE); } - } - else { - Yap_Error(INSTANTIATION_ERROR,ti,"array_arg"); + } else { + Yap_Error(INSTANTIATION_ERROR, ti, "array_arg"); return (FALSE); } @@ -610,40 +587,34 @@ array_arg( USES_REGS1 ) if (IsNonVarTerm(t)) { if (IsApplTerm(t)) { return (Yap_unify(((RepAppl(t))[indx + 1]), ARG1)); - } - else if (IsAtomTerm(t)) { + } else if (IsAtomTerm(t)) { Term tf = AccessNamedArray(AtomOfTerm(t), indx PASS_REGS); if (tf == MkAtomTerm(AtomFoundVar)) { - return(FALSE); + return (FALSE); } return (Yap_unify(tf, ARG1)); - } - else - Yap_Error(TYPE_ERROR_ARRAY,t,"array_arg"); - } - else - Yap_Error(INSTANTIATION_ERROR,t,"array_arg"); + } else + Yap_Error(TYPE_ERROR_ARRAY, t, "array_arg"); + } else + Yap_Error(INSTANTIATION_ERROR, t, "array_arg"); return (FALSE); - } -static void -InitNamedArray(ArrayEntry * p, Int dim USES_REGS) -{ +static void InitNamedArray(ArrayEntry *p, Int dim USES_REGS) { Term *tp; WRITE_LOCK(p->ArRWLock); /* Leave a pointer so that we can reclaim array space when * we backtrack or when we abort */ /* place terms in reverse order */ - Bind_Global(&(p->ValueOfVE),AbsAppl(HR)); + Bind_Global(&(p->ValueOfVE), AbsAppl(HR)); tp = HR; - tp[0] = (CELL)Yap_MkFunctor(AtomArray, dim); + tp[0] = (CELL)Yap_MkFunctor(AtomArray, dim); tp++; p->ArrayEArity = dim; /* Initialize the array as a set of variables */ - HR = tp+dim; + HR = tp + dim; for (; tp < HR; tp++) { RESET_VARIABLE(tp); } @@ -651,12 +622,10 @@ InitNamedArray(ArrayEntry * p, Int dim USES_REGS) } /* we assume the atom ae is already locked */ -static void -CreateNamedArray(PropEntry * pp, Int dim, AtomEntry *ae USES_REGS) -{ +static void CreateNamedArray(PropEntry *pp, Int dim, AtomEntry *ae USES_REGS) { ArrayEntry *p; - p = (ArrayEntry *) Yap_AllocAtomSpace(sizeof(*p)); + p = (ArrayEntry *)Yap_AllocAtomSpace(sizeof(*p)); p->KindOfPE = ArrayProperty; p->TypeOfAE = DYNAMIC_ARRAY; AddPropToAtom(ae, (PropEntry *)p); @@ -667,53 +636,53 @@ CreateNamedArray(PropEntry * pp, Int dim, AtomEntry *ae USES_REGS) p->NextAE = LOCAL_DynamicArrays; LOCAL_DynamicArrays = p; InitNamedArray(p, dim PASS_REGS); - } -static void -AllocateStaticArraySpace(StaticArrayEntry *p, static_array_types atype, void *old, size_t array_size USES_REGS) -{ +static void AllocateStaticArraySpace(StaticArrayEntry *p, + static_array_types atype, void *old, + size_t array_size USES_REGS) { size_t asize = 0; switch (atype) { case array_of_doubles: - asize = array_size*sizeof(Float); + asize = array_size * sizeof(Float); break; case array_of_ints: - asize = array_size*sizeof(Int); + asize = array_size * sizeof(Int); break; case array_of_chars: - asize = array_size*sizeof(char); + asize = array_size * sizeof(char); break; case array_of_uchars: - asize = array_size*sizeof(unsigned char); + asize = array_size * sizeof(unsigned char); break; case array_of_ptrs: - asize = array_size*sizeof(AtomEntry *); + asize = array_size * sizeof(AtomEntry *); break; case array_of_atoms: case array_of_terms: case array_of_nb_terms: - asize = array_size*sizeof(live_term); + asize = array_size * sizeof(live_term); break; case array_of_dbrefs: - asize = array_size*sizeof(DBRef); + asize = array_size * sizeof(DBRef); break; } if (old == NULL) { - while ((p->ValueOfVE.floats = (Float *) Yap_AllocCodeSpace(asize) ) == NULL) { + while ((p->ValueOfVE.floats = (Float *)Yap_AllocCodeSpace(asize)) == NULL) { YAPLeaveCriticalSection(); if (!Yap_growheap(FALSE, asize, NULL)) { - Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); - return; + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); + return; } YAPEnterCriticalSection(); } } else { - while ((p->ValueOfVE.floats = (Float *) Yap_ReallocCodeSpace(old, asize) ) == NULL) { + while ((p->ValueOfVE.floats = (Float *)Yap_ReallocCodeSpace(old, asize)) == + NULL) { YAPLeaveCriticalSection(); if (!Yap_growheap(FALSE, asize, NULL)) { - Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); - return; + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); + return; } YAPEnterCriticalSection(); } @@ -721,14 +690,15 @@ AllocateStaticArraySpace(StaticArrayEntry *p, static_array_types atype, void *ol } /* ae and p are assumed to be locked, if they exist */ -static StaticArrayEntry * -CreateStaticArray(AtomEntry *ae, size_t dim, static_array_types type, CODEADDR start_addr, StaticArrayEntry *p USES_REGS) -{ +static StaticArrayEntry *CreateStaticArray(AtomEntry *ae, size_t dim, + static_array_types type, + CODEADDR start_addr, + StaticArrayEntry *p USES_REGS) { if (EndOfPAEntr(p)) { - while ((p = (StaticArrayEntry *) Yap_AllocCodeSpace(sizeof(*p))) == NULL) { + while ((p = (StaticArrayEntry *)Yap_AllocCodeSpace(sizeof(*p))) == NULL) { if (!Yap_growheap(FALSE, sizeof(*p), NULL)) { - Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); - return NULL; + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); + return NULL; } } p->KindOfPE = ArrayProperty; @@ -742,46 +712,46 @@ CreateStaticArray(AtomEntry *ae, size_t dim, static_array_types type, CODEADDR s p->ArrayType = type; p->TypeOfAE = STATIC_ARRAY; if (start_addr == NULL) { - size_t i; + size_t i; AllocateStaticArraySpace(p, type, NULL, dim PASS_REGS); if (p->ValueOfVE.ints == NULL) { WRITE_UNLOCK(p->ArRWLock); return p; } - switch(type) { + switch (type) { case array_of_ints: for (i = 0; i < dim; i++) - p->ValueOfVE.ints[i] = 0; + p->ValueOfVE.ints[i] = 0; break; case array_of_chars: for (i = 0; i < dim; i++) - p->ValueOfVE.chars[i] = '\0'; + p->ValueOfVE.chars[i] = '\0'; break; case array_of_uchars: for (i = 0; i < dim; i++) - p->ValueOfVE.uchars[i] = '\0'; + p->ValueOfVE.uchars[i] = '\0'; break; case array_of_doubles: for (i = 0; i < dim; i++) - p->ValueOfVE.floats[i] = 0.0; + p->ValueOfVE.floats[i] = 0.0; break; case array_of_ptrs: for (i = 0; i < dim; i++) - p->ValueOfVE.ptrs[i] = NULL; + p->ValueOfVE.ptrs[i] = NULL; break; case array_of_atoms: case array_of_dbrefs: for (i = 0; i < dim; i++) - p->ValueOfVE.atoms[i] = 0L; + p->ValueOfVE.atoms[i] = 0L; break; case array_of_terms: for (i = 0; i < dim; i++) - p->ValueOfVE.terms[i] = NULL; + p->ValueOfVE.terms[i] = NULL; break; case array_of_nb_terms: for (i = 0; i < dim; i++) { - RESET_VARIABLE(&(p->ValueOfVE.lterms[i].tlive)); - p->ValueOfVE.lterms[i].tstore = TermNil; + RESET_VARIABLE(&(p->ValueOfVE.lterms[i].tlive)); + p->ValueOfVE.lterms[i].tstore = TermNil; } break; } @@ -795,79 +765,76 @@ CreateStaticArray(AtomEntry *ae, size_t dim, static_array_types type, CODEADDR s } /* ae and p are assumed to be locked, if they exist */ -StaticArrayEntry * -Yap_StaticArray(Atom na, size_t dim, static_array_types type, CODEADDR start_addr, StaticArrayEntry *p) -{ - CACHE_REGS +StaticArrayEntry *Yap_StaticArray(Atom na, size_t dim, static_array_types type, + CODEADDR start_addr, StaticArrayEntry *p) { + CACHE_REGS StaticArrayEntry *e; - ArrayEntry *e0 = GetArrayEntry( RepAtom(na), worker_id ); - if (e0 && ArrayIsDynamic( e0 )) { + ArrayEntry *e0 = GetArrayEntry(RepAtom(na), worker_id); + if (e0 && ArrayIsDynamic(e0)) { e = NULL; } else { // initial version for e - e = RepStaticArrayProp( AbsArrayProp( e0 ) ); + e = RepStaticArrayProp(AbsArrayProp(e0)); } - e = CreateStaticArray( RepAtom(na), dim, type, NULL, e PASS_REGS); + e = CreateStaticArray(RepAtom(na), dim, type, NULL, e PASS_REGS); return e; } -static void -ResizeStaticArray(StaticArrayEntry *pp, size_t dim USES_REGS) -{ +static void ResizeStaticArray(StaticArrayEntry *pp, size_t dim USES_REGS) { statarray_elements old_v = pp->ValueOfVE; static_array_types type = pp->ArrayType; size_t old_dim = pp->ArrayEArity; size_t mindim = (dim < old_dim ? dim : old_dim), i; /* change official size */ - if (pp->ArrayEArity == 0){ + if (pp->ArrayEArity == 0) { return; } WRITE_LOCK(pp->ArRWLock); pp->ArrayEArity = dim; #if HAVE_MMAP if (pp->TypeOfAE & MMAP_ARRAY) { - ResizeMmappedArray(pp, dim, (void *)(pp->ValueOfVE.chars) PASS_REGS); + ResizeMmappedArray(pp, dim, (void *)(pp->ValueOfVE.chars)PASS_REGS); WRITE_UNLOCK(pp->ArRWLock); return; } #endif AllocateStaticArraySpace(pp, type, old_v.chars, dim PASS_REGS); - switch(type) { + switch (type) { case array_of_ints: - for (i = mindim; iValueOfVE.ints[i] = 0; break; case array_of_chars: - for (i = mindim; iValueOfVE.chars[i] = '\0'; break; case array_of_uchars: - for (i = mindim; iValueOfVE.uchars[i] = '\0'; break; case array_of_doubles: - for (i = mindim; iValueOfVE.floats[i] = 0.0; break; case array_of_ptrs: - for (i = mindim; iValueOfVE.ptrs[i] = NULL; break; case array_of_atoms: - for (i = mindim; iValueOfVE.atoms[i] = TermNil; break; case array_of_dbrefs: - for (i = mindim; iValueOfVE.dbrefs[i] = 0L; break; case array_of_terms: - for (i = mindim; iValueOfVE.terms[i] = NULL; break; case array_of_nb_terms: - for (i = mindim; i ValueOfVE.lterms[i].tlive)); pp->ValueOfVE.lterms[i].tstore = TermNil; } @@ -876,64 +843,60 @@ ResizeStaticArray(StaticArrayEntry *pp, size_t dim USES_REGS) WRITE_UNLOCK(pp->ArRWLock); } -static void -ClearStaticArray(StaticArrayEntry *pp) -{ +static void ClearStaticArray(StaticArrayEntry *pp) { statarray_elements old_v = pp->ValueOfVE; static_array_types type = pp->ArrayType; Int dim = pp->ArrayEArity, i; /* change official size */ - if (pp->ArrayEArity == 0){ + if (pp->ArrayEArity == 0) { return; } WRITE_LOCK(pp->ArRWLock); - switch(type) { + switch (type) { case array_of_ints: - memset((void *)pp->ValueOfVE.ints,0,sizeof(Int)*dim); + memset((void *)pp->ValueOfVE.ints, 0, sizeof(Int) * dim); break; case array_of_chars: - memset((void *)pp->ValueOfVE.chars,0,sizeof(char)*dim); + memset((void *)pp->ValueOfVE.chars, 0, sizeof(char) * dim); break; case array_of_uchars: - memset((void *)pp->ValueOfVE.uchars,0,sizeof(unsigned char)*dim); + memset((void *)pp->ValueOfVE.uchars, 0, sizeof(unsigned char) * dim); break; case array_of_doubles: - memset((void *)pp->ValueOfVE.floats,0,sizeof(double)*dim); + memset((void *)pp->ValueOfVE.floats, 0, sizeof(double) * dim); break; case array_of_ptrs: - memset((void *)pp->ValueOfVE.ptrs,0,sizeof(void *)*dim); + memset((void *)pp->ValueOfVE.ptrs, 0, sizeof(void *) * dim); break; case array_of_atoms: - for (i = 0; i< dim; i++) + for (i = 0; i < dim; i++) pp->ValueOfVE.atoms[i] = TermNil; break; case array_of_dbrefs: for (i = 0; i < dim; i++) { Term t0 = pp->ValueOfVE.dbrefs[i]; if (t0 != 0L) { - DBRef ptr = DBRefOfTerm(t0); + DBRef ptr = DBRefOfTerm(t0); - if (ptr->Flags & LogUpdMask) { - LogUpdClause *lup = (LogUpdClause *)ptr; - // LOCK(lup->ClLock); - lup->ClRefCount--; - if (lup->ClRefCount == 0 && - (lup->ClFlags & ErasedMask) && - !(lup->ClFlags & InUseMask)) { - // UNLOCK(lup->ClLock); - Yap_ErLogUpdCl(lup); - } else { - // UNLOCK(lup->ClLock); - } - } else { - ptr->NOfRefsTo--; - if (ptr->NOfRefsTo == 0 && - (ptr->Flags & ErasedMask) && - !(ptr->Flags & InUseMask)) { - Yap_ErDBE(ptr); - } - } + if (ptr->Flags & LogUpdMask) { + LogUpdClause *lup = (LogUpdClause *)ptr; + // LOCK(lup->ClLock); + lup->ClRefCount--; + if (lup->ClRefCount == 0 && (lup->ClFlags & ErasedMask) && + !(lup->ClFlags & InUseMask)) { + // UNLOCK(lup->ClLock); + Yap_ErLogUpdCl(lup); + } else { + // UNLOCK(lup->ClLock); + } + } else { + ptr->NOfRefsTo--; + if (ptr->NOfRefsTo == 0 && (ptr->Flags & ErasedMask) && + !(ptr->Flags & InUseMask)) { + Yap_ErDBE(ptr); + } + } } pp->ValueOfVE.dbrefs[i] = 0L; } @@ -943,7 +906,7 @@ ClearStaticArray(StaticArrayEntry *pp) DBTerm *ref = pp->ValueOfVE.terms[i]; if (ref != NULL) { - Yap_ReleaseTermFromDB(ref); + Yap_ReleaseTermFromDB(ref); } pp->ValueOfVE.terms[i] = NULL; } @@ -956,7 +919,7 @@ ClearStaticArray(StaticArrayEntry *pp) RESET_VARIABLE(livep); /* recover space */ if (IsApplTerm(told)) { - Yap_ReleaseTermFromDB((DBTerm *)RepAppl(told)); + Yap_ReleaseTermFromDB((DBTerm *)RepAppl(told)); } pp->ValueOfVE.lterms[i].tstore = old_v.lterms[i].tstore; } @@ -966,26 +929,24 @@ ClearStaticArray(StaticArrayEntry *pp) } /* create an array (?Name, + Size) */ -static Int -create_array( USES_REGS1 ) -{ +static Int create_array(USES_REGS1) { Term ti; Term t; Int size; - restart: +restart: ti = Deref(ARG2); t = Deref(ARG1); { Term nti; if (IsVarTerm(ti)) { - Yap_Error(INSTANTIATION_ERROR,ti,"create_array"); + Yap_Error(INSTANTIATION_ERROR, ti, "create_array"); return (FALSE); } - if (IsIntegerTerm(nti=Yap_Eval(ti))) + if (IsIntegerTerm(nti = Yap_Eval(ti))) size = IntegerOfTerm(nti); else { - Yap_Error(TYPE_ERROR_INTEGER,ti,"create_array"); + Yap_Error(TYPE_ERROR_INTEGER, ti, "create_array"); return (FALSE); } } @@ -995,74 +956,71 @@ create_array( USES_REGS1 ) Functor farray; farray = Yap_MkFunctor(AtomArray, size); - if (HR+1+size > ASP-1024) { - if (!Yap_gcl((1+size)*sizeof(CELL), 2, ENV, Yap_gcP())) { - Yap_Error(RESOURCE_ERROR_STACK,TermNil,LOCAL_ErrorMessage); - return(FALSE); + if (HR + 1 + size > ASP - 1024) { + if (!Yap_gcl((1 + size) * sizeof(CELL), 2, ENV, Yap_gcP())) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); + return (FALSE); } else { - if (HR+1+size > ASP-1024) { - if (!Yap_growstack( sizeof(CELL) * (size+1-(HR-ASP-1024)))) { - Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); - return FALSE; - } - } + if (HR + 1 + size > ASP - 1024) { + if (!Yap_growstack(sizeof(CELL) * (size + 1 - (HR - ASP - 1024)))) { + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); + return FALSE; + } + } } goto restart; } t = AbsAppl(HR); - *HR++ = (CELL) farray; + *HR++ = (CELL)farray; for (; size >= 0; size--) { RESET_VARIABLE(HR); HR++; } return (Yap_unify(t, ARG1)); - } - else if (IsAtomTerm(t)) { + } else if (IsAtomTerm(t)) { /* Create a named array */ AtomEntry *ae = RepAtom(AtomOfTerm(t)); PropEntry *pp; WRITE_LOCK(ae->ARWLock); pp = RepProp(ae->PropsOfAE); - while (!EndOfPAEntr(pp) && - pp->KindOfPE != ArrayProperty + while (!EndOfPAEntr(pp) && pp->KindOfPE != ArrayProperty #if THREADS - && ((ArrayEntry *)pp)->owner_id != worker_id -#endif - ) + && ((ArrayEntry *)pp)->owner_id != worker_id +#endif + ) pp = RepProp(pp->NextOfPE); if (EndOfPAEntr(pp)) { - if (HR+1+size > ASP-1024) { - WRITE_UNLOCK(ae->ARWLock); - if (!Yap_gcl((1+size)*sizeof(CELL), 2, ENV, gc_P(P,CP))) { - Yap_Error(RESOURCE_ERROR_STACK,TermNil,LOCAL_ErrorMessage); - return(FALSE); - } else - goto restart; + if (HR + 1 + size > ASP - 1024) { + WRITE_UNLOCK(ae->ARWLock); + if (!Yap_gcl((1 + size) * sizeof(CELL), 2, ENV, gc_P(P, CP))) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); + return (FALSE); + } else + goto restart; } CreateNamedArray(pp, size, ae PASS_REGS); WRITE_UNLOCK(ae->ARWLock); return (TRUE); } else { - ArrayEntry *app = (ArrayEntry *) pp; + ArrayEntry *app = (ArrayEntry *)pp; WRITE_UNLOCK(ae->ARWLock); - if (!IsVarTerm(app->ValueOfVE) - || !IsUnboundVar(&app->ValueOfVE)) { - if (size == app->ArrayEArity) - return TRUE; - Yap_Error(PERMISSION_ERROR_CREATE_ARRAY,t,"create_array", - ae->StrOfAE); + if (!IsVarTerm(app->ValueOfVE) || !IsUnboundVar(&app->ValueOfVE)) { + if (size == app->ArrayEArity) + return TRUE; + Yap_Error(PERMISSION_ERROR_CREATE_ARRAY, t, "create_array", + ae->StrOfAE); } else { - if (HR+1+size > ASP-1024) { - if (!Yap_gcl((1+size)*sizeof(CELL), 2, ENV, gc_P(P,CP))) { - Yap_Error(RESOURCE_ERROR_STACK,TermNil,LOCAL_ErrorMessage); - return(FALSE); - } else - goto restart; - } - InitNamedArray(app, size PASS_REGS); - return (TRUE); + if (HR + 1 + size > ASP - 1024) { + if (!Yap_gcl((1 + size) * sizeof(CELL), 2, ENV, gc_P(P, CP))) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); + return (FALSE); + } else + goto restart; + } + InitNamedArray(app, size PASS_REGS); + return (TRUE); } } } @@ -1070,17 +1028,16 @@ create_array( USES_REGS1 ) } /* create an array (+Name, + Size, +Props) */ -static Int -/** @pred static_array(+ _Name_, + _Size_, + _Type_) +static Int + /** @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. + */ + create_static_array(USES_REGS1) { Term ti = Deref(ARG2); Term t = Deref(ARG1); Term tprops = Deref(ARG3); @@ -1088,21 +1045,21 @@ create_static_array( USES_REGS1 ) static_array_types props; if (IsVarTerm(ti)) { - Yap_Error(INSTANTIATION_ERROR,ti,"create static array"); + Yap_Error(INSTANTIATION_ERROR, ti, "create static array"); return (FALSE); } else { Term nti; - if (IsIntegerTerm(nti=Yap_Eval(ti))) + if (IsIntegerTerm(nti = Yap_Eval(ti))) size = IntegerOfTerm(nti); else { - Yap_Error(TYPE_ERROR_INTEGER,ti,"create static array"); + Yap_Error(TYPE_ERROR_INTEGER, ti, "create static array"); return (FALSE); } } if (IsVarTerm(tprops)) { - Yap_Error(INSTANTIATION_ERROR,tprops,"create static array"); + Yap_Error(INSTANTIATION_ERROR, tprops, "create static array"); return (FALSE); } else if (IsAtomTerm(tprops)) { char *atname = (char *)RepAtom(AtomOfTerm(tprops))->StrOfAE; @@ -1125,19 +1082,18 @@ create_static_array( USES_REGS1 ) else if (!strcmp(atname, "nb_term")) props = array_of_nb_terms; else { - Yap_Error(DOMAIN_ERROR_ARRAY_TYPE,tprops,"create static array"); - return(FALSE); + Yap_Error(DOMAIN_ERROR_ARRAY_TYPE, tprops, "create static array"); + return (FALSE); } } else { - Yap_Error(TYPE_ERROR_ATOM,tprops,"create static array"); + Yap_Error(TYPE_ERROR_ATOM, tprops, "create static array"); return (FALSE); } if (IsVarTerm(t)) { - Yap_Error(INSTANTIATION_ERROR,t,"create static array"); + Yap_Error(INSTANTIATION_ERROR, t, "create static array"); return (FALSE); - } - else if (IsAtomTerm(t)) { + } else if (IsAtomTerm(t)) { /* Create a named array */ AtomEntry *ae = RepAtom(AtomOfTerm(t)); StaticArrayEntry *pp; @@ -1148,52 +1104,53 @@ create_static_array( USES_REGS1 ) while (!EndOfPAEntr(pp) && pp->KindOfPE != ArrayProperty) pp = RepStaticArrayProp(pp->NextOfPE); - app = (ArrayEntry *) pp; + app = (ArrayEntry *)pp; if (EndOfPAEntr(pp) || pp->ValueOfVE.ints == NULL) { pp = CreateStaticArray(ae, size, props, NULL, pp PASS_REGS); if (pp == NULL || pp->ValueOfVE.ints == NULL) { - WRITE_UNLOCK(ae->ARWLock); - return FALSE; + WRITE_UNLOCK(ae->ARWLock); + return FALSE; } 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; + 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; + 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->ArrayEArity == size && pp->ArrayType == props) { + WRITE_UNLOCK(ae->ARWLock); + return true; } Yap_FreeCodeSpace(pp->ValueOfVE.floats); WRITE_UNLOCK(ae->ARWLock); return true; } } - Yap_Error(TYPE_ERROR_ATOM,t,"create static array"); + 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 onr -StaticArrayEntry * -Yap_StaticVector( Atom Name, size_t size, static_array_types props ) -{ - CACHE_REGS - AtomEntry *ae = RepAtom( Name ); - +/// create a new vectir in a given name Name. If one exists, destroy prrexisting +/// onr +StaticArrayEntry *Yap_StaticVector(Atom Name, size_t size, + static_array_types props) { + CACHE_REGS + AtomEntry *ae = RepAtom(Name); + WRITE_LOCK(ae->ARWLock); - StaticArrayEntry *pp = RepStaticArrayProp( AbsArrayProp(GetArrayEntry( ae, worker_id ) ) ); + StaticArrayEntry *pp = + RepStaticArrayProp(AbsArrayProp(GetArrayEntry(ae, worker_id))); if (EndOfPAEntr(pp) || pp->ValueOfVE.ints == NULL) { pp = CreateStaticArray(ae, size, props, NULL, pp PASS_REGS); if (pp == NULL || pp->ValueOfVE.ints == NULL) { @@ -1205,17 +1162,14 @@ Yap_StaticVector( Atom Name, size_t size, static_array_types props ) } return NULL; } - + /* has a static array associated (+Name) */ -static Int -static_array_properties( USES_REGS1 ) -{ +static Int static_array_properties(USES_REGS1) { Term t = Deref(ARG1); if (IsVarTerm(t)) { return (FALSE); - } - else if (IsAtomTerm(t)) { + } else if (IsAtomTerm(t)) { /* Create a named array */ AtomEntry *ae = RepAtom(AtomOfTerm(t)); StaticArrayEntry *pp; @@ -1232,27 +1186,27 @@ static_array_properties( USES_REGS1 ) Int dim = pp->ArrayEArity; READ_UNLOCK(ae->ARWLock); - if (dim <= 0 || !Yap_unify(ARG2,MkIntegerTerm(dim))) - return(FALSE); - switch(tp) { + if (dim <= 0 || !Yap_unify(ARG2, MkIntegerTerm(dim))) + return (FALSE); + switch (tp) { case array_of_ints: - return(Yap_unify(ARG3,MkAtomTerm(AtomInt))); + return (Yap_unify(ARG3, MkAtomTerm(AtomInt))); case array_of_dbrefs: - return(Yap_unify(ARG3,MkAtomTerm(AtomDBref))); + return (Yap_unify(ARG3, MkAtomTerm(AtomDBref))); case array_of_doubles: - return(Yap_unify(ARG3,MkAtomTerm(AtomFloat))); + return (Yap_unify(ARG3, MkAtomTerm(AtomFloat))); case array_of_ptrs: - return(Yap_unify(ARG3,TermPointer)); + return (Yap_unify(ARG3, TermPointer)); case array_of_chars: - return(Yap_unify(ARG3,MkAtomTerm(AtomChar))); + return (Yap_unify(ARG3, MkAtomTerm(AtomChar))); case array_of_uchars: - return(Yap_unify(ARG3,MkAtomTerm(AtomUnsignedChar))); + return (Yap_unify(ARG3, MkAtomTerm(AtomUnsignedChar))); case array_of_terms: - return(Yap_unify(ARG3,MkAtomTerm(AtomTerm))); + return (Yap_unify(ARG3, TermTerm)); case array_of_nb_terms: - return(Yap_unify(ARG3,MkAtomTerm(AtomNbTerm))); + return (Yap_unify(ARG3, TermTerm)); case array_of_atoms: - return(Yap_unify(ARG3,MkAtomTerm(AtomAtom))); + return (Yap_unify(ARG3, MkAtomTerm(AtomAtom))); } } } @@ -1261,32 +1215,29 @@ static_array_properties( USES_REGS1 ) /* resize a static array (+Name, + Size, +Props) */ /* does not work for mmap arrays yet */ -static Int -resize_static_array( USES_REGS1 ) -{ +static Int resize_static_array(USES_REGS1) { Term ti = Deref(ARG3); Term t = Deref(ARG1); Int size; if (IsVarTerm(ti)) { - Yap_Error(INSTANTIATION_ERROR,ti,"resize a static array"); + Yap_Error(INSTANTIATION_ERROR, ti, "resize a static array"); return (FALSE); } else { Term nti; - if (IsIntegerTerm(nti=Yap_Eval(ti))) + if (IsIntegerTerm(nti = Yap_Eval(ti))) size = IntegerOfTerm(nti); else { - Yap_Error(TYPE_ERROR_INTEGER,ti,"resize a static array"); + Yap_Error(TYPE_ERROR_INTEGER, ti, "resize a static array"); return (FALSE); } } if (IsVarTerm(t)) { - Yap_Error(INSTANTIATION_ERROR,t,"resize a static array"); + Yap_Error(INSTANTIATION_ERROR, t, "resize a static array"); return (FALSE); - } - else if (IsAtomTerm(t)) { + } else if (IsAtomTerm(t)) { /* resize a named array */ Atom a = AtomOfTerm(t); StaticArrayEntry *pp = RepStaticArrayProp(RepAtom(a)->PropsOfAE); @@ -1294,15 +1245,15 @@ resize_static_array( USES_REGS1 ) while (!EndOfPAEntr(pp) && pp->KindOfPE != ArrayProperty) pp = RepStaticArrayProp(pp->NextOfPE); if (EndOfPAEntr(pp) || pp->ValueOfVE.ints == NULL) { - Yap_Error(PERMISSION_ERROR_RESIZE_ARRAY,t,"resize a static array"); - return(FALSE); + Yap_Error(PERMISSION_ERROR_RESIZE_ARRAY, t, "resize a static array"); + return (FALSE); } else { - size_t osize = pp->ArrayEArity; + size_t osize = pp->ArrayEArity; ResizeStaticArray(pp, size PASS_REGS); - return(Yap_unify(ARG2,MkIntegerTerm(osize))); + return (Yap_unify(ARG2, MkIntegerTerm(osize))); } } else { - Yap_Error(TYPE_ERROR_ATOM,t,"resize a static array"); + Yap_Error(TYPE_ERROR_ATOM, t, "resize a static array"); return (FALSE); } } @@ -1316,16 +1267,13 @@ Reset static array with name _Name_ to its initial value. */ -static Int -clear_static_array( USES_REGS1 ) -{ +static Int clear_static_array(USES_REGS1) { Term t = Deref(ARG1); if (IsVarTerm(t)) { - Yap_Error(INSTANTIATION_ERROR,t,"clear a static array"); + Yap_Error(INSTANTIATION_ERROR, t, "clear a static array"); return FALSE; - } - else if (IsAtomTerm(t)) { + } else if (IsAtomTerm(t)) { /* resize a named array */ Atom a = AtomOfTerm(t); StaticArrayEntry *pp = RepStaticArrayProp(RepAtom(a)->PropsOfAE); @@ -1333,14 +1281,14 @@ clear_static_array( USES_REGS1 ) while (!EndOfPAEntr(pp) && pp->KindOfPE != ArrayProperty) pp = RepStaticArrayProp(pp->NextOfPE); if (EndOfPAEntr(pp) || pp->ValueOfVE.ints == NULL) { - Yap_Error(PERMISSION_ERROR_RESIZE_ARRAY,t,"clear a static array"); + Yap_Error(PERMISSION_ERROR_RESIZE_ARRAY, t, "clear a static array"); return FALSE; } else { ClearStaticArray(pp); return TRUE; } } else { - Yap_Error(TYPE_ERROR_ATOM,t,"clear a static array"); + Yap_Error(TYPE_ERROR_ATOM, t, "clear a static array"); return FALSE; } } @@ -1355,17 +1303,14 @@ further accesses to the array will return an error. */ -static Int -close_static_array( USES_REGS1 ) -{ -/* does not work for mmap arrays yet */ +static Int close_static_array(USES_REGS1) { + /* does not work for mmap arrays yet */ Term t = Deref(ARG1); if (IsVarTerm(t)) { - Yap_Error(INSTANTIATION_ERROR,t,"close static array"); + Yap_Error(INSTANTIATION_ERROR, t, "close static array"); return (FALSE); - } - else if (IsAtomTerm(t)) { + } else if (IsAtomTerm(t)) { /* Create a named array */ AtomEntry *ae = RepAtom(AtomOfTerm(t)); PropEntry *pp; @@ -1381,25 +1326,26 @@ close_static_array( USES_REGS1 ) StaticArrayEntry *ptr = (StaticArrayEntry *)pp; if (ptr->ValueOfVE.ints != NULL) { #if HAVE_MMAP - Int val = CloseMmappedArray(ptr, (void *)ptr->ValueOfVE.chars PASS_REGS); + Int val = + CloseMmappedArray(ptr, (void *)ptr->ValueOfVE.chars PASS_REGS); #if USE_SYSTEM_MALLOC - if (val) { + if (val) { #endif - return(val); + return (val); #if USE_SYSTEM_MALLOC - } + } #endif #endif - Yap_FreeAtomSpace((char *)(ptr->ValueOfVE.ints)); - ptr->ValueOfVE.ints = NULL; - ptr->ArrayEArity = 0; - return(TRUE); + Yap_FreeAtomSpace((char *)(ptr->ValueOfVE.ints)); + ptr->ValueOfVE.ints = NULL; + ptr->ArrayEArity = 0; + return (TRUE); } else { - return(FALSE); + return (FALSE); } } } else { - Yap_Error(TYPE_ERROR_ATOM,t,"close static array"); + Yap_Error(TYPE_ERROR_ATOM, t, "close static array"); return (FALSE); } } @@ -1417,9 +1363,7 @@ terms (type `term`). */ -static Int -create_mmapped_array( USES_REGS1 ) -{ +static Int create_mmapped_array(USES_REGS1) { #ifdef HAVE_MMAP Term ti = Deref(ARG2); Term t = Deref(ARG1); @@ -1432,86 +1376,90 @@ create_mmapped_array( USES_REGS1 ) int fd; if (IsVarTerm(ti)) { - Yap_Error(INSTANTIATION_ERROR,ti,"create_mmapped_array"); + Yap_Error(INSTANTIATION_ERROR, ti, "create_mmapped_array"); return (FALSE); } else { Term nti; - if (IsIntegerTerm(nti=Yap_Eval(ti))) + if (IsIntegerTerm(nti = Yap_Eval(ti))) size = IntegerOfTerm(nti); else { - Yap_Error(TYPE_ERROR_INTEGER,ti,"create_mmapped_array"); + Yap_Error(TYPE_ERROR_INTEGER, ti, "create_mmapped_array"); return (FALSE); } } if (IsVarTerm(tprops)) { - Yap_Error(INSTANTIATION_ERROR,tprops,"create_mmapped_array"); + Yap_Error(INSTANTIATION_ERROR, tprops, "create_mmapped_array"); return (FALSE); } else if (IsAtomTerm(tprops)) { char *atname = RepAtom(AtomOfTerm(tprops))->StrOfAE; if (!strcmp(atname, "int")) { props = array_of_ints; - total_size = size*sizeof(Int); + total_size = size * sizeof(Int); } else if (!strcmp(atname, "dbref")) { props = array_of_dbrefs; - total_size = size*sizeof(Int); + total_size = size * sizeof(Int); } else if (!strcmp(atname, "float")) { props = array_of_doubles; - total_size = size*sizeof(Float); + total_size = size * sizeof(Float); } else if (!strcmp(atname, "ptr")) { props = array_of_ptrs; - total_size = size*sizeof(AtomEntry *); + total_size = size * sizeof(AtomEntry *); } else if (!strcmp(atname, "atom")) { props = array_of_atoms; - total_size = size*sizeof(Term); + total_size = size * sizeof(Term); } else if (!strcmp(atname, "char")) { props = array_of_chars; - total_size = size*sizeof(char); + total_size = size * sizeof(char); } else if (!strcmp(atname, "unsigned_char")) { props = array_of_uchars; - total_size = size*sizeof(unsigned char); + total_size = size * sizeof(unsigned char); } else { - Yap_Error(DOMAIN_ERROR_ARRAY_TYPE,tprops,"create_mmapped_array"); - return(FALSE); + Yap_Error(DOMAIN_ERROR_ARRAY_TYPE, tprops, "create_mmapped_array"); + return (FALSE); } } else { - Yap_Error(TYPE_ERROR_ATOM,tprops,"create_mmapped_array"); + Yap_Error(TYPE_ERROR_ATOM, tprops, "create_mmapped_array"); return (FALSE); } if (IsVarTerm(tfile)) { - Yap_Error(INSTANTIATION_ERROR,tfile,"create_mmapped_array"); + Yap_Error(INSTANTIATION_ERROR, tfile, "create_mmapped_array"); return (FALSE); } else if (IsAtomTerm(tfile)) { char *filename = RepAtom(AtomOfTerm(tfile))->StrOfAE; - - fd = open(filename, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR); + fd = open(filename, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); if (fd == -1) { - Yap_Error(SYSTEM_ERROR_INTERNAL,ARG1,"create_mmapped_array (open: %s)", strerror(errno)); - return(FALSE); + Yap_Error(SYSTEM_ERROR_INTERNAL, ARG1, "create_mmapped_array (open: %s)", + strerror(errno)); + return (FALSE); } - if (lseek(fd, total_size-1, SEEK_SET) < 0) - Yap_Error(SYSTEM_ERROR_INTERNAL,tfile,"create_mmapped_array (lseek: %s)", strerror(errno)); + if (lseek(fd, total_size - 1, SEEK_SET) < 0) + Yap_Error(SYSTEM_ERROR_INTERNAL, tfile, + "create_mmapped_array (lseek: %s)", strerror(errno)); if (write(fd, "", 1) < 0) - Yap_Error(SYSTEM_ERROR_INTERNAL,tfile,"create_mmapped_array (write: %s)", strerror(errno)); + Yap_Error(SYSTEM_ERROR_INTERNAL, tfile, + "create_mmapped_array (write: %s)", strerror(errno)); /* if (ftruncate(fd, total_size) < 0) Yap_Error(SYSTEM_ERROR_INTERNAL,tfile,"create_mmapped_array"); */ - if ((array_addr = (CODEADDR)mmap(0, (size_t) total_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == (CODEADDR) - 1) - Yap_Error(SYSTEM_ERROR_INTERNAL,tfile,"create_mmapped_array (mmap: %s)", strerror(errno)); + if ((array_addr = + (CODEADDR)mmap(0, (size_t)total_size, PROT_READ | PROT_WRITE, + MAP_SHARED, fd, 0)) == (CODEADDR)-1) + Yap_Error(SYSTEM_ERROR_INTERNAL, tfile, "create_mmapped_array (mmap: %s)", + strerror(errno)); } else { - Yap_Error(TYPE_ERROR_ATOM,tfile,"create_mmapped_array"); + Yap_Error(TYPE_ERROR_ATOM, tfile, "create_mmapped_array"); return (FALSE); } if (IsVarTerm(t)) { - Yap_Error(INSTANTIATION_ERROR,t,"create_mmapped_array"); + Yap_Error(INSTANTIATION_ERROR, t, "create_mmapped_array"); return (FALSE); - } - else if (IsAtomTerm(t)) { + } else if (IsAtomTerm(t)) { /* Create a named array */ AtomEntry *ae = RepAtom(AtomOfTerm(t)); StaticArrayEntry *pp; @@ -1524,10 +1472,10 @@ create_mmapped_array( USES_REGS1 ) mmap_array_block *ptr; if (EndOfPAEntr(pp)) { - WRITE_UNLOCK(ae->ARWLock); - return FALSE; + WRITE_UNLOCK(ae->ARWLock); + return FALSE; } else { - WRITE_LOCK(pp->ArRWLock); + WRITE_LOCK(pp->ArRWLock); } CreateStaticArray(ae, size, props, array_addr, pp PASS_REGS); ptr = (mmap_array_block *)Yap_AllocAtomSpace(sizeof(mmap_array_block)); @@ -1543,28 +1491,27 @@ create_mmapped_array( USES_REGS1 ) return TRUE; } else { WRITE_UNLOCK(ae->ARWLock); - Yap_Error(DOMAIN_ERROR_ARRAY_TYPE,t,"create_mmapped_array", ae->StrOfAE); - return(FALSE); + Yap_Error(DOMAIN_ERROR_ARRAY_TYPE, t, "create_mmapped_array", + ae->StrOfAE); + return (FALSE); } } else { - Yap_Error(TYPE_ERROR_ATOM,t,"create_mmapped_array"); + Yap_Error(TYPE_ERROR_ATOM, t, "create_mmapped_array"); return FALSE; } #else - Yap_Error(SYSTEM_ERROR_INTERNAL,ARG1,"create_mmapped_array (mmap)"); + Yap_Error(SYSTEM_ERROR_INTERNAL, ARG1, "create_mmapped_array (mmap)"); return (FALSE); #endif } /* This routine removes array references from complex terms? */ -static void -replace_array_references_complex(register CELL *pt0, - register CELL *pt0_end, - register CELL *ptn, - Term Var USES_REGS) -{ +static void replace_array_references_complex(register CELL *pt0, + register CELL *pt0_end, + register CELL *ptn, + Term Var USES_REGS) { - register CELL **to_visit = (CELL **) Yap_PreAllocCodeSpace(); + register CELL **to_visit = (CELL **)Yap_PreAllocCodeSpace(); CELL **to_visit_base = to_visit; loop: @@ -1575,8 +1522,7 @@ loop: d0 = Derefa(pt0); if (IsVarTerm(d0)) { *ptn++ = d0; - } - else if (IsPairTerm(d0)) { + } else if (IsPairTerm(d0)) { /* store the terms to visit */ *ptn++ = AbsPair(HR); #ifdef RATIONAL_TREES @@ -1588,10 +1534,10 @@ loop: *pt0 = TermNil; #else if (pt0 < pt0_end) { - to_visit[0] = pt0; - to_visit[1] = pt0_end; - to_visit[2] = ptn; - to_visit += 3; + to_visit[0] = pt0; + to_visit[1] = pt0_end; + to_visit[2] = ptn; + to_visit += 3; } #endif pt0 = RepPair(d0) - 1; @@ -1599,20 +1545,19 @@ loop: /* write the head and tail of the list */ ptn = HR; HR += 2; - } - else if (IsApplTerm(d0)) { + } else if (IsApplTerm(d0)) { register Functor f; f = FunctorOfTerm(d0); /* store the terms to visit */ if (IsExtensionFunctor(f)) { - { - *ptn++ = d0; - continue; - } + { + *ptn++ = d0; + continue; + } } *ptn++ = AbsAppl(HR); - /* store the terms to visit */ +/* store the terms to visit */ #ifdef RATIONAL_TREES to_visit[0] = pt0; to_visit[1] = pt0_end; @@ -1622,10 +1567,10 @@ loop: *pt0 = TermNil; #else if (pt0 < pt0_end) { - to_visit[0] = pt0; - to_visit[1] = pt0_end; - to_visit[2] = ptn; - to_visit += 3; + to_visit[0] = pt0; + to_visit[1] = pt0_end; + to_visit[2] = ptn; + to_visit += 3; } #endif pt0 = RepAppl(d0); @@ -1633,17 +1578,16 @@ loop: pt0_end = pt0 + d0; /* start writing the compound term */ ptn = HR; - *ptn++ = (CELL) f; + *ptn++ = (CELL)f; HR += d0 + 1; - } - else { /* AtomOrInt */ + } else { /* AtomOrInt */ *ptn++ = d0; } /* just continue the loop */ } /* Do we still have compound terms to visit */ - if (to_visit > (CELL **) to_visit_base) { + if (to_visit > (CELL **)to_visit_base) { #ifdef RATIONAL_TREES to_visit -= 4; pt0 = to_visit[0]; @@ -1664,15 +1608,13 @@ loop: } /* - * + * * Given a term t0, build a new term tf of the form ta+tb, where ta is * obtained by replacing the array references in t0 by empty * variables, and tb is a list of array references and corresponding * variables. */ -static Term -replace_array_references(Term t0 USES_REGS) -{ +static Term replace_array_references(Term t0 USES_REGS) { Term t; t = Deref(t0); @@ -1687,25 +1629,23 @@ replace_array_references(Term t0 USES_REGS) HR += 2; replace_array_references_complex(RepPair(t) - 1, RepPair(t) + 1, h0, - VList PASS_REGS); + VList PASS_REGS); return MkPairTerm(AbsPair(h0), VList); } else { Term VList = MkVarTerm(); CELL *h0 = HR; Functor f = FunctorOfTerm(t); - *HR++ = (CELL) (f); + *HR++ = (CELL)(f); HR += ArityOfFunctor(f); - replace_array_references_complex(RepAppl(t), - RepAppl(t) + ArityOfFunctor(FunctorOfTerm(t)), h0 + 1, - VList PASS_REGS); + replace_array_references_complex( + RepAppl(t), RepAppl(t) + ArityOfFunctor(FunctorOfTerm(t)), h0 + 1, + VList PASS_REGS); return (MkPairTerm(AbsAppl(h0), VList)); } } -static Int -array_references( USES_REGS1 ) -{ +static Int array_references(USES_REGS1) { Term t = replace_array_references(ARG1 PASS_REGS); Term t1 = HeadOfTerm(t); Term t2 = TailOfTerm(t); @@ -1730,9 +1670,7 @@ to use the operations on mutable terms. */ -static Int -assign_static( USES_REGS1 ) -{ +static Int assign_static(USES_REGS1) { Term t1, t2, t3; StaticArrayEntry *ptr; Int indx; @@ -1741,22 +1679,22 @@ assign_static( USES_REGS1 ) if (IsNonVarTerm(t2)) { Term nti; - if (IsIntegerTerm(nti=Yap_Eval(t2))) + if (IsIntegerTerm(nti = Yap_Eval(t2))) indx = IntegerOfTerm(nti); else { - Yap_Error(TYPE_ERROR_INTEGER,t2,"update_array"); + Yap_Error(TYPE_ERROR_INTEGER, t2, "update_array"); return (FALSE); } } else { - Yap_Error(INSTANTIATION_ERROR,t2,"update_array"); + Yap_Error(INSTANTIATION_ERROR, t2, "update_array"); return (FALSE); } t3 = Deref(ARG3); t1 = Deref(ARG1); if (IsVarTerm(t1)) { - Yap_Error(INSTANTIATION_ERROR,t1,"update_array"); - return(FALSE); + Yap_Error(INSTANTIATION_ERROR, t1, "update_array"); + return (FALSE); } if (!IsAtomTerm(t1)) { if (IsApplTerm(t1)) { @@ -1764,50 +1702,51 @@ assign_static( USES_REGS1 ) Functor f = FunctorOfTerm(t1); /* store the terms to visit */ if (IsExtensionFunctor(f)) { - Yap_Error(TYPE_ERROR_ARRAY,t1,"update_array"); - return(FALSE); + Yap_Error(TYPE_ERROR_ARRAY, t1, "update_array"); + return (FALSE); } if (indx > 0 && indx > ArityOfFunctor(f)) { - Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW,t2,"update_array"); - return(FALSE); + Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW, t2, "update_array"); + return (FALSE); } - ptr = RepAppl(t1)+indx+1; + ptr = RepAppl(t1) + indx + 1; #ifdef MULTI_ASSIGNMENT_VARIABLES MaBind(ptr, t3); - return(TRUE); + return (TRUE); #else - Yap_Error(SYSTEM_ERROR_INTERNAL,t2,"update_array"); - return(FALSE); + Yap_Error(SYSTEM_ERROR_INTERNAL, t2, "update_array"); + return (FALSE); #endif } else { - Yap_Error(TYPE_ERROR_ATOM,t1,"update_array"); - return(FALSE); + Yap_Error(TYPE_ERROR_ATOM, t1, "update_array"); + return (FALSE); } } { AtomEntry *ae = RepAtom(AtomOfTerm(t1)); READ_LOCK(ae->ARWLock); - ptr = RepStaticArrayProp(ae->PropsOfAE); + ptr = RepStaticArrayProp(ae->PropsOfAE); while (!EndOfPAEntr(ptr) && ptr->KindOfPE != ArrayProperty) ptr = RepStaticArrayProp(ptr->NextOfPE); if (EndOfPAEntr(ptr)) { READ_UNLOCK(ae->ARWLock); - Yap_Error(EXISTENCE_ERROR_ARRAY,t1,"assign_static %s", RepAtom(AtomOfTerm(t1))->StrOfAE); + Yap_Error(EXISTENCE_ERROR_ARRAY, t1, "assign_static %s", + RepAtom(AtomOfTerm(t1))->StrOfAE); return FALSE; } if (ArrayIsDynamic((ArrayEntry *)ptr)) { ArrayEntry *pp = (ArrayEntry *)ptr; CELL *pt; - + WRITE_LOCK(pp->ArRWLock); READ_UNLOCK(ae->ARWLock); if (indx < 0 || indx >= pp->ArrayEArity) { - Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW,t2,"assign_static"); - WRITE_UNLOCK(pp->ArRWLock); - return FALSE; + Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW, t2, "assign_static"); + WRITE_UNLOCK(pp->ArRWLock); + return FALSE; } pt = RepAppl(pp->ValueOfVE) + indx + 1; WRITE_UNLOCK(pp->ArRWLock); @@ -1816,7 +1755,7 @@ assign_static( USES_REGS1 ) MaBind(pt, t3); return TRUE; #else - Yap_Error(SYSTEM_ERROR_INTERNAL,t2,"update_array"); + Yap_Error(SYSTEM_ERROR_INTERNAL, t2, "update_array"); return FALSE; #endif } @@ -1826,246 +1765,224 @@ assign_static( USES_REGS1 ) /* a static array */ if (indx < 0 || indx >= ptr->ArrayEArity) { WRITE_UNLOCK(ptr->ArRWLock); - Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW,t2,"assign_static"); + Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW, t2, "assign_static"); return FALSE; } switch (ptr->ArrayType) { - case array_of_ints: - { - Int i; - Term nti; - - if (IsVarTerm(t3)) { - WRITE_UNLOCK(ptr->ArRWLock); - Yap_Error(INSTANTIATION_ERROR,t3,"assign_static"); - return FALSE; - } + case array_of_ints: { + Int i; + Term nti; - if (IsIntegerTerm(nti=Yap_Eval(t3))) - i = IntegerOfTerm(nti); - else { - WRITE_UNLOCK(ptr->ArRWLock); - Yap_Error(TYPE_ERROR_INTEGER,t3,"assign_static"); - return (FALSE); - } - ptr-> - ValueOfVE.ints[indx]= i; + if (IsVarTerm(t3)) { + WRITE_UNLOCK(ptr->ArRWLock); + Yap_Error(INSTANTIATION_ERROR, t3, "assign_static"); + return FALSE; } - break; - case array_of_chars: - { - Int i; - Term nti; - - if (IsVarTerm(t3)) { - WRITE_UNLOCK(ptr->ArRWLock); - Yap_Error(INSTANTIATION_ERROR,t3,"assign_static"); - return FALSE; - } - if (IsIntegerTerm(nti=Yap_Eval(t3))) - i = IntegerOfTerm(nti); - else { - Yap_Error(TYPE_ERROR_INTEGER,t3,"assign_static"); - return (FALSE); - } - if (i > 127 || i < -128) { - WRITE_UNLOCK(ptr->ArRWLock); - Yap_Error(TYPE_ERROR_CHAR,t3,"assign_static"); - return FALSE; - } - ptr->ValueOfVE.chars[indx]= i; + if (IsIntegerTerm(nti = Yap_Eval(t3))) + i = IntegerOfTerm(nti); + else { + WRITE_UNLOCK(ptr->ArRWLock); + Yap_Error(TYPE_ERROR_INTEGER, t3, "assign_static"); + return (FALSE); } - break; + ptr->ValueOfVE.ints[indx] = i; + } break; - case array_of_uchars: - { - Int i; - Term nti; - - if (IsVarTerm(t3)) { - WRITE_UNLOCK(ptr->ArRWLock); - Yap_Error(INSTANTIATION_ERROR,t3,"assign_static"); - return FALSE; - } - if (IsIntegerTerm(nti=Yap_Eval(t3))) - i = IntegerOfTerm(nti); - else { - WRITE_UNLOCK(ptr->ArRWLock); - Yap_Error(TYPE_ERROR_INTEGER,t3,"assign_static"); - return FALSE; - } - if (i > 255 || i < 0) { - WRITE_UNLOCK(ptr->ArRWLock); - Yap_Error(TYPE_ERROR_UCHAR,t3,"assign_static"); - return FALSE; - } - ptr->ValueOfVE.chars[indx]= i; + case array_of_chars: { + Int i; + Term nti; + + if (IsVarTerm(t3)) { + WRITE_UNLOCK(ptr->ArRWLock); + Yap_Error(INSTANTIATION_ERROR, t3, "assign_static"); + return FALSE; } - break; - - case array_of_doubles: - { - Float f; - Term nti; - - if (IsVarTerm(t3)) { - WRITE_UNLOCK(ptr->ArRWLock); - Yap_Error(INSTANTIATION_ERROR,t3,"assign_static"); - return FALSE; - } - if (IsFloatTerm(nti=Yap_Eval(t3))) - f = FloatOfTerm(nti); - else if (IsIntegerTerm(nti)) - f = IntegerOfTerm(nti); - else { - WRITE_UNLOCK(ptr->ArRWLock); - Yap_Error(TYPE_ERROR_FLOAT,t3,"assign_static"); - return FALSE; - } - ptr->ValueOfVE.floats[indx]= f; + if (IsIntegerTerm(nti = Yap_Eval(t3))) + i = IntegerOfTerm(nti); + else { + Yap_Error(TYPE_ERROR_INTEGER, t3, "assign_static"); + return (FALSE); } - break; - - case array_of_ptrs: - { - Int r; - - if (IsVarTerm(t3)) { - WRITE_UNLOCK(ptr->ArRWLock); - Yap_Error(INSTANTIATION_ERROR,t3,"assign_static"); - return FALSE; - } - if (IsIntegerTerm(t3)) - r = IntegerOfTerm(t3); - else { - WRITE_UNLOCK(ptr->ArRWLock); - Yap_Error(TYPE_ERROR_PTR,t3,"assign_static"); - return FALSE; - } - ptr->ValueOfVE.ptrs[indx]= (AtomEntry *)r; + if (i > 127 || i < -128) { + WRITE_UNLOCK(ptr->ArRWLock); + Yap_Error(TYPE_ERROR_CHAR, t3, "assign_static"); + return FALSE; } - break; + ptr->ValueOfVE.chars[indx] = i; + } break; - case array_of_atoms: - { - if (IsVarTerm(t3)) { - WRITE_UNLOCK(ptr->ArRWLock); - Yap_Error(INSTANTIATION_ERROR,t3,"assign_static"); - return FALSE; - } - if (!IsAtomTerm(t3)) { - WRITE_UNLOCK(ptr->ArRWLock); - Yap_Error(TYPE_ERROR_ATOM,t3,"assign_static"); - return FALSE; - } - ptr->ValueOfVE.atoms[indx]= t3; + case array_of_uchars: { + Int i; + Term nti; + + if (IsVarTerm(t3)) { + WRITE_UNLOCK(ptr->ArRWLock); + Yap_Error(INSTANTIATION_ERROR, t3, "assign_static"); + return FALSE; } - break; - - case array_of_dbrefs: - { - - Term t0 = ptr->ValueOfVE.dbrefs[indx]; - DBRef p = DBRefOfTerm(t3); - - if (IsVarTerm(t3)) { - WRITE_UNLOCK(ptr->ArRWLock); - Yap_Error(INSTANTIATION_ERROR,t3,"assign_static"); - return FALSE; - } - if (!IsDBRefTerm(t3)) { - WRITE_UNLOCK(ptr->ArRWLock); - Yap_Error(TYPE_ERROR_DBREF,t3,"assign_static"); - return FALSE; - } - ptr->ValueOfVE.dbrefs[indx]= t3; - if (t0 != 0L) { - DBRef ptr = DBRefOfTerm(t0); - - if (ptr->Flags & LogUpdMask) { - LogUpdClause *lup = (LogUpdClause *)ptr; - // LOCK(lup->ClLock); - lup->ClRefCount--; - if (lup->ClRefCount == 0 && - (lup->ClFlags & ErasedMask) && - !(lup->ClFlags & InUseMask)) { - // UNLOCK(lup->ClLock); - Yap_ErLogUpdCl(lup); - } else { - // UNLOCK(lup->ClLock); - } - } else { - ptr->NOfRefsTo--; - if (ptr->NOfRefsTo == 0 && - (ptr->Flags & ErasedMask) && - !(ptr->Flags & InUseMask)) { - Yap_ErDBE(ptr); - } - } - } - - if (p->Flags & LogUpdMask) { - LogUpdClause *lup = (LogUpdClause *)p; - // LOCK(lup->ClLock); - lup->ClRefCount++; - // UNLOCK(lup->ClLock); - } else { - p->NOfRefsTo++; - } + if (IsIntegerTerm(nti = Yap_Eval(t3))) + i = IntegerOfTerm(nti); + else { + WRITE_UNLOCK(ptr->ArRWLock); + Yap_Error(TYPE_ERROR_INTEGER, t3, "assign_static"); + return FALSE; } - break; + if (i > 255 || i < 0) { + WRITE_UNLOCK(ptr->ArRWLock); + Yap_Error(TYPE_ERROR_UCHAR, t3, "assign_static"); + return FALSE; + } + ptr->ValueOfVE.chars[indx] = i; + } break; + + case array_of_doubles: { + Float f; + Term nti; + + if (IsVarTerm(t3)) { + WRITE_UNLOCK(ptr->ArRWLock); + Yap_Error(INSTANTIATION_ERROR, t3, "assign_static"); + return FALSE; + } + if (IsFloatTerm(nti = Yap_Eval(t3))) + f = FloatOfTerm(nti); + else if (IsIntegerTerm(nti)) + f = IntegerOfTerm(nti); + else { + WRITE_UNLOCK(ptr->ArRWLock); + Yap_Error(TYPE_ERROR_FLOAT, t3, "assign_static"); + return FALSE; + } + ptr->ValueOfVE.floats[indx] = f; + } break; + + case array_of_ptrs: { + Int r; + + if (IsVarTerm(t3)) { + WRITE_UNLOCK(ptr->ArRWLock); + Yap_Error(INSTANTIATION_ERROR, t3, "assign_static"); + return FALSE; + } + if (IsIntegerTerm(t3)) + r = IntegerOfTerm(t3); + else { + WRITE_UNLOCK(ptr->ArRWLock); + Yap_Error(TYPE_ERROR_PTR, t3, "assign_static"); + return FALSE; + } + ptr->ValueOfVE.ptrs[indx] = (AtomEntry *)r; + } break; + + case array_of_atoms: { + if (IsVarTerm(t3)) { + WRITE_UNLOCK(ptr->ArRWLock); + Yap_Error(INSTANTIATION_ERROR, t3, "assign_static"); + return FALSE; + } + if (!IsAtomTerm(t3)) { + WRITE_UNLOCK(ptr->ArRWLock); + Yap_Error(TYPE_ERROR_ATOM, t3, "assign_static"); + return FALSE; + } + ptr->ValueOfVE.atoms[indx] = t3; + } break; + + case array_of_dbrefs: { + + Term t0 = ptr->ValueOfVE.dbrefs[indx]; + DBRef p = DBRefOfTerm(t3); + + if (IsVarTerm(t3)) { + WRITE_UNLOCK(ptr->ArRWLock); + Yap_Error(INSTANTIATION_ERROR, t3, "assign_static"); + return FALSE; + } + if (!IsDBRefTerm(t3)) { + WRITE_UNLOCK(ptr->ArRWLock); + Yap_Error(TYPE_ERROR_DBREF, t3, "assign_static"); + return FALSE; + } + ptr->ValueOfVE.dbrefs[indx] = t3; + if (t0 != 0L) { + DBRef ptr = DBRefOfTerm(t0); + + if (ptr->Flags & LogUpdMask) { + LogUpdClause *lup = (LogUpdClause *)ptr; + // LOCK(lup->ClLock); + lup->ClRefCount--; + if (lup->ClRefCount == 0 && (lup->ClFlags & ErasedMask) && + !(lup->ClFlags & InUseMask)) { + // UNLOCK(lup->ClLock); + Yap_ErLogUpdCl(lup); + } else { + // UNLOCK(lup->ClLock); + } + } else { + ptr->NOfRefsTo--; + if (ptr->NOfRefsTo == 0 && (ptr->Flags & ErasedMask) && + !(ptr->Flags & InUseMask)) { + Yap_ErDBE(ptr); + } + } + } + + if (p->Flags & LogUpdMask) { + LogUpdClause *lup = (LogUpdClause *)p; + // LOCK(lup->ClLock); + lup->ClRefCount++; + // UNLOCK(lup->ClLock); + } else { + p->NOfRefsTo++; + } + } break; case array_of_nb_terms: - { - Term told = ptr->ValueOfVE.lterms[indx].tstore; + { + Term told = ptr->ValueOfVE.lterms[indx].tstore; - CELL *livep = &(ptr->ValueOfVE.lterms[indx].tlive); - RESET_VARIABLE(livep); - /* recover space */ - if (IsApplTerm(told)) { - Yap_ReleaseTermFromDB((DBTerm *)RepAppl(told)); - } - if (IsVarTerm(t3)) { - RESET_VARIABLE(&(ptr->ValueOfVE.lterms[indx].tstore)); - } else if (IsAtomicTerm(t3)) { - ptr->ValueOfVE.lterms[indx].tstore = t3; - } else { - DBTerm *new = Yap_StoreTermInDB(t3,3); - if (!new) { - WRITE_UNLOCK(ptr->ArRWLock); - return FALSE; - } - ptr->ValueOfVE.lterms[indx].tstore = AbsAppl((CELL *)new); - } + CELL *livep = &(ptr->ValueOfVE.lterms[indx].tlive); + RESET_VARIABLE(livep); + /* recover space */ + if (IsApplTerm(told)) { + Yap_ReleaseTermFromDB((DBTerm *)RepAppl(told)); } - break; - - case array_of_terms: - { - - DBTerm *ref = ptr->ValueOfVE.terms[indx]; - - if (ref != NULL) { - Yap_ReleaseTermFromDB(ref); - } - ptr->ValueOfVE.terms[indx] = Yap_StoreTermInDB(t3,3); - if (ptr->ValueOfVE.terms[indx] == NULL){ - WRITE_UNLOCK(ptr->ArRWLock); - return FALSE; - } + if (IsVarTerm(t3)) { + RESET_VARIABLE(&(ptr->ValueOfVE.lterms[indx].tstore)); + } else if (IsAtomicTerm(t3)) { + ptr->ValueOfVE.lterms[indx].tstore = t3; + } else { + DBTerm *new = Yap_StoreTermInDB(t3, 3); + if (!new) { + WRITE_UNLOCK(ptr->ArRWLock); + return FALSE; + } + ptr->ValueOfVE.lterms[indx].tstore = AbsAppl((CELL *)new); } - break; + } break; + + case array_of_terms: { + + DBTerm *ref = ptr->ValueOfVE.terms[indx]; + + if (ref != NULL) { + Yap_ReleaseTermFromDB(ref); + } + ptr->ValueOfVE.terms[indx] = Yap_StoreTermInDB(t3, 3); + if (ptr->ValueOfVE.terms[indx] == NULL) { + WRITE_UNLOCK(ptr->ArRWLock); + return FALSE; + } + } break; } WRITE_UNLOCK(ptr->ArRWLock); return TRUE; } } -static Int -assign_dynamic( USES_REGS1 ) -{ +static Int assign_dynamic(USES_REGS1) { Term t1, t2, t3; StaticArrayEntry *ptr; Int indx; @@ -2073,22 +1990,22 @@ assign_dynamic( USES_REGS1 ) t2 = Deref(ARG2); if (IsNonVarTerm(t2)) { Term nti; - if (IsIntegerTerm(nti=Yap_Eval(t2))) { + if (IsIntegerTerm(nti = Yap_Eval(t2))) { indx = IntegerOfTerm(nti); } else { - Yap_Error(TYPE_ERROR_INTEGER,t2,"update_array"); + Yap_Error(TYPE_ERROR_INTEGER, t2, "update_array"); return (FALSE); } } else { - Yap_Error(INSTANTIATION_ERROR,t2,"update_array"); + Yap_Error(INSTANTIATION_ERROR, t2, "update_array"); return (FALSE); } t3 = Deref(ARG3); t1 = Deref(ARG1); if (IsVarTerm(t1)) { - Yap_Error(INSTANTIATION_ERROR,t1,"update_array"); - return(FALSE); + Yap_Error(INSTANTIATION_ERROR, t1, "update_array"); + return (FALSE); } if (!IsAtomTerm(t1)) { if (IsApplTerm(t1)) { @@ -2096,39 +2013,40 @@ assign_dynamic( USES_REGS1 ) Functor f = FunctorOfTerm(t1); /* store the terms to visit */ if (IsExtensionFunctor(f)) { - Yap_Error(TYPE_ERROR_ARRAY,t1,"update_array"); - return(FALSE); + Yap_Error(TYPE_ERROR_ARRAY, t1, "update_array"); + return (FALSE); } if (indx > 0 && indx > ArityOfFunctor(f)) { - Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW,t2,"update_array"); - return(FALSE); + Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW, t2, "update_array"); + return (FALSE); } - ptr = RepAppl(t1)+indx+1; + ptr = RepAppl(t1) + indx + 1; #ifdef MULTI_ASSIGNMENT_VARIABLES MaBind(ptr, t3); - return(TRUE); + return (TRUE); #else - Yap_Error(SYSTEM_ERROR_INTERNAL,t2,"update_array"); - return(FALSE); + Yap_Error(SYSTEM_ERROR_INTERNAL, t2, "update_array"); + return (FALSE); #endif } else { - Yap_Error(TYPE_ERROR_ATOM,t1,"update_array"); - return(FALSE); + Yap_Error(TYPE_ERROR_ATOM, t1, "update_array"); + return (FALSE); } } { AtomEntry *ae = RepAtom(AtomOfTerm(t1)); READ_LOCK(ae->ARWLock); - ptr = RepStaticArrayProp(ae->PropsOfAE); + ptr = RepStaticArrayProp(ae->PropsOfAE); while (!EndOfPAEntr(ptr) && ptr->KindOfPE != ArrayProperty) ptr = RepStaticArrayProp(ptr->NextOfPE); READ_UNLOCK(ae->ARWLock); } if (EndOfPAEntr(ptr)) { - Yap_Error(EXISTENCE_ERROR_ARRAY,t1,"assign_static %s", RepAtom(AtomOfTerm(t1))->StrOfAE); - return(FALSE); + Yap_Error(EXISTENCE_ERROR_ARRAY, t1, "assign_static %s", + RepAtom(AtomOfTerm(t1))->StrOfAE); + return (FALSE); } if (ArrayIsDynamic((ArrayEntry *)ptr)) { @@ -2136,9 +2054,9 @@ assign_dynamic( USES_REGS1 ) CELL *pt; WRITE_LOCK(pp->ArRWLock); if (indx < 0 || indx >= pp->ArrayEArity) { - Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW,t2,"assign_static"); + Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW, t2, "assign_static"); WRITE_UNLOCK(pp->ArRWLock); - return(FALSE); + return (FALSE); } pt = RepAppl(pp->ValueOfVE) + indx + 1; WRITE_UNLOCK(pp->ArRWLock); @@ -2147,7 +2065,7 @@ assign_dynamic( USES_REGS1 ) MaBind(pt, t3); return TRUE; #else - Yap_Error(SYSTEM_ERROR_INTERNAL,t2,"update_array"); + Yap_Error(SYSTEM_ERROR_INTERNAL, t2, "update_array"); return FALSE; #endif } @@ -2156,7 +2074,7 @@ assign_dynamic( USES_REGS1 ) /* a static array */ if (indx < 0 || indx >= ptr->ArrayEArity) { WRITE_UNLOCK(ptr->ArRWLock); - Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW,t2,"assign_static"); + Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW, t2, "assign_static"); return FALSE; } switch (ptr->ArrayType) { @@ -2174,30 +2092,28 @@ assign_dynamic( USES_REGS1 ) case array_of_nb_terms: #ifdef MULTI_ASSIGNMENT_VARIABLES - { - Term t = ptr->ValueOfVE.lterms[indx].tlive; - Functor f; - /* we have a mutable term there */ + { + Term t = ptr->ValueOfVE.lterms[indx].tlive; + Functor f; + /* we have a mutable term there */ - if (IsVarTerm(t) || - !IsApplTerm(t) || - (f = FunctorOfTerm(t)) != FunctorAtFoundOne) { - Term tn = Yap_NewTimedVar(t3); - CELL *sp = RepAppl(tn); - *sp = (CELL)FunctorAtFoundOne; - YapBind(&(ptr->ValueOfVE.lterms[indx].tlive),tn); - } else { - Yap_UpdateTimedVar(t, t3); - } + if (IsVarTerm(t) || !IsApplTerm(t) || + (f = FunctorOfTerm(t)) != FunctorAtFoundOne) { + Term tn = Yap_NewTimedVar(t3); + CELL *sp = RepAppl(tn); + *sp = (CELL)FunctorAtFoundOne; + YapBind(&(ptr->ValueOfVE.lterms[indx].tlive), tn); + } else { + Yap_UpdateTimedVar(t, t3); } + } WRITE_UNLOCK(ptr->ArRWLock); return TRUE; #else WRITE_UNLOCK(ptr->ArRWLock); - Yap_Error(SYSTEM_ERROR_INTERNAL,t2,"update_array"); + Yap_Error(SYSTEM_ERROR_INTERNAL, t2, "update_array"); return FALSE; #endif - } WRITE_UNLOCK(ptr->ArRWLock); return TRUE; @@ -2226,9 +2142,7 @@ terms. */ -static Int -add_to_array_element( USES_REGS1 ) -{ +static Int add_to_array_element(USES_REGS1) { Term t1, t2, t3; StaticArrayEntry *ptr; Int indx; @@ -2236,26 +2150,26 @@ add_to_array_element( USES_REGS1 ) t2 = Deref(ARG2); if (IsNonVarTerm(t2)) { Term nti; - if (IsIntegerTerm(nti=Yap_Eval(t2))) { + if (IsIntegerTerm(nti = Yap_Eval(t2))) { indx = IntegerOfTerm(nti); } else { - Yap_Error(TYPE_ERROR_INTEGER,t2,"add_to_array_element"); + Yap_Error(TYPE_ERROR_INTEGER, t2, "add_to_array_element"); return (FALSE); } } else { - Yap_Error(INSTANTIATION_ERROR,t2,"add_to_array_element"); + Yap_Error(INSTANTIATION_ERROR, t2, "add_to_array_element"); return (FALSE); } t1 = Deref(ARG1); if (IsVarTerm(t1)) { - Yap_Error(INSTANTIATION_ERROR,t1,"add_to_array_element"); - return(FALSE); + Yap_Error(INSTANTIATION_ERROR, t1, "add_to_array_element"); + return (FALSE); } t3 = Deref(ARG3); if (IsVarTerm(t3)) { - Yap_Error(INSTANTIATION_ERROR,t3,"add_to_array_element"); - return(FALSE); + Yap_Error(INSTANTIATION_ERROR, t3, "add_to_array_element"); + return (FALSE); } if (!IsAtomTerm(t1)) { if (IsApplTerm(t1)) { @@ -2265,62 +2179,63 @@ add_to_array_element( USES_REGS1 ) /* store the terms to visit */ if (IsExtensionFunctor(f)) { - Yap_Error(TYPE_ERROR_ARRAY,t1,"add_to_array_element"); - return(FALSE); + Yap_Error(TYPE_ERROR_ARRAY, t1, "add_to_array_element"); + return (FALSE); } if (indx > 0 && indx > ArityOfFunctor(f)) { - Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW,t2,"add_to_array_element"); - return(FALSE); + Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW, t2, "add_to_array_element"); + return (FALSE); } - ptr = RepAppl(t1)+indx+1; - ta = RepAppl(t1)[indx+1]; + ptr = RepAppl(t1) + indx + 1; + ta = RepAppl(t1)[indx + 1]; if (IsIntegerTerm(ta)) { - if (IsIntegerTerm(t3)) { - ta = MkIntegerTerm(IntegerOfTerm(ta)+IntegerOfTerm(t3)); - } else if (IsFloatTerm(t3)) { - ta = MkFloatTerm(IntegerOfTerm(ta)+FloatOfTerm(t3)); - } else { - Yap_Error(TYPE_ERROR_NUMBER,t3,"add_to_array_element"); - return(FALSE); - } + if (IsIntegerTerm(t3)) { + ta = MkIntegerTerm(IntegerOfTerm(ta) + IntegerOfTerm(t3)); + } else if (IsFloatTerm(t3)) { + ta = MkFloatTerm(IntegerOfTerm(ta) + FloatOfTerm(t3)); + } else { + Yap_Error(TYPE_ERROR_NUMBER, t3, "add_to_array_element"); + return (FALSE); + } } else if (IsFloatTerm(ta)) { - if (IsFloatTerm(t3)) { - ta = MkFloatTerm(FloatOfTerm(ta)+IntegerOfTerm(t3)); - } else if (IsFloatTerm(t3)) { - ta = MkFloatTerm(FloatOfTerm(ta)+FloatOfTerm(t3)); - } else { - Yap_Error(TYPE_ERROR_NUMBER,t3,"add_to_array_element"); - return(FALSE); - } + if (IsFloatTerm(t3)) { + ta = MkFloatTerm(FloatOfTerm(ta) + IntegerOfTerm(t3)); + } else if (IsFloatTerm(t3)) { + ta = MkFloatTerm(FloatOfTerm(ta) + FloatOfTerm(t3)); + } else { + Yap_Error(TYPE_ERROR_NUMBER, t3, "add_to_array_element"); + return (FALSE); + } } else { - Yap_Error(TYPE_ERROR_NUMBER,ta,"add_to_array_element"); - return(FALSE); + Yap_Error(TYPE_ERROR_NUMBER, ta, "add_to_array_element"); + return (FALSE); } #ifdef MULTI_ASSIGNMENT_VARIABLES MaBind(ptr, ta); - return(Yap_unify(ARG4,ta)); + return (Yap_unify(ARG4, ta)); #else - Yap_Error(SYSTEM_ERROR_INTERNAL,t2,"add_to_array_element"); - return(FALSE); + Yap_Error(SYSTEM_ERROR_INTERNAL, t2, "add_to_array_element"); + return (FALSE); #endif } else { - Yap_Error(TYPE_ERROR_ATOM,t1,"add_to_array_element"); - return(FALSE); + Yap_Error(TYPE_ERROR_ATOM, t1, "add_to_array_element"); + return (FALSE); } } { AtomEntry *ae = RepAtom(AtomOfTerm(t1)); READ_LOCK(ae->ARWLock); - ptr = RepStaticArrayProp(ae->PropsOfAE); + ptr = RepStaticArrayProp(ae->PropsOfAE); while (!EndOfPAEntr(ptr) && ptr->KindOfPE != ArrayProperty) ptr = RepStaticArrayProp(ptr->NextOfPE); READ_UNLOCK(ae->ARWLock); } if (EndOfPAEntr(ptr)) { - Yap_Error(EXISTENCE_ERROR_ARRAY,t1,"add_to_array_element %s", RepAtom(AtomOfTerm(t1))->StrOfAE); - return(FALSE); + Yap_Error(EXISTENCE_ERROR_ARRAY, t1, "add_to_array_element %s", + RepAtom(AtomOfTerm(t1))->StrOfAE); + return (FALSE); } if (ArrayIsDynamic((ArrayEntry *)ptr)) { @@ -2330,106 +2245,94 @@ add_to_array_element( USES_REGS1 ) WRITE_LOCK(pp->ArRWLock); if (indx < 0 || indx >= pp->ArrayEArity) { - Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW,t2,"add_to_array_element"); + Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW, t2, "add_to_array_element"); READ_UNLOCK(pp->ArRWLock); return FALSE; } pt = RepAppl(pp->ValueOfVE) + indx + 1; - ta = RepAppl(pp->ValueOfVE)[indx+1]; + ta = RepAppl(pp->ValueOfVE)[indx + 1]; if (IsIntegerTerm(ta)) { if (IsIntegerTerm(t3)) { - ta = MkIntegerTerm(IntegerOfTerm(ta)+IntegerOfTerm(t3)); + ta = MkIntegerTerm(IntegerOfTerm(ta) + IntegerOfTerm(t3)); } else if (IsFloatTerm(t3)) { - ta = MkFloatTerm(IntegerOfTerm(ta)+FloatOfTerm(t3)); + ta = MkFloatTerm(IntegerOfTerm(ta) + FloatOfTerm(t3)); } else { - WRITE_UNLOCK(pp->ArRWLock); - Yap_Error(TYPE_ERROR_NUMBER,t3,"add_to_array_element"); - return FALSE; + WRITE_UNLOCK(pp->ArRWLock); + Yap_Error(TYPE_ERROR_NUMBER, t3, "add_to_array_element"); + return FALSE; } } else if (IsFloatTerm(ta)) { if (IsFloatTerm(t3)) { - ta = MkFloatTerm(FloatOfTerm(ta)+IntegerOfTerm(t3)); + ta = MkFloatTerm(FloatOfTerm(ta) + IntegerOfTerm(t3)); } else if (IsFloatTerm(t3)) { - ta = MkFloatTerm(FloatOfTerm(ta)+FloatOfTerm(t3)); + ta = MkFloatTerm(FloatOfTerm(ta) + FloatOfTerm(t3)); } else { - WRITE_UNLOCK(pp->ArRWLock); - Yap_Error(TYPE_ERROR_NUMBER,t3,"add_to_array_element"); - return FALSE; + WRITE_UNLOCK(pp->ArRWLock); + Yap_Error(TYPE_ERROR_NUMBER, t3, "add_to_array_element"); + return FALSE; } } else { WRITE_UNLOCK(pp->ArRWLock); - Yap_Error(TYPE_ERROR_NUMBER,ta,"add_to_array_element"); + Yap_Error(TYPE_ERROR_NUMBER, ta, "add_to_array_element"); return FALSE; } /* the evil deed is to be done now */ MaBind(pt, ta); WRITE_UNLOCK(pp->ArRWLock); - return Yap_unify(ARG4,t3); + return Yap_unify(ARG4, t3); } WRITE_LOCK(ptr->ArRWLock); /* a static array */ if (indx < 0 || indx >= ptr->ArrayEArity) { WRITE_UNLOCK(ptr->ArRWLock); - Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW,t2,"add_to_array_element"); + Yap_Error(DOMAIN_ERROR_ARRAY_OVERFLOW, t2, "add_to_array_element"); return FALSE; } switch (ptr->ArrayType) { - case array_of_ints: - { - Int i = ptr->ValueOfVE.ints[indx]; - if (!IsIntegerTerm(t3)) { - WRITE_UNLOCK(ptr->ArRWLock); - Yap_Error(TYPE_ERROR_INTEGER,t3,"add_to_array_element"); - return FALSE; - } - i += IntegerOfTerm(t3); - ptr->ValueOfVE.ints[indx] = i; + case array_of_ints: { + Int i = ptr->ValueOfVE.ints[indx]; + if (!IsIntegerTerm(t3)) { WRITE_UNLOCK(ptr->ArRWLock); - return Yap_unify(ARG4,MkIntegerTerm(i)); + Yap_Error(TYPE_ERROR_INTEGER, t3, "add_to_array_element"); + return FALSE; } - break; - case array_of_doubles: - { - Float fl = ptr->ValueOfVE.floats[indx]; + i += IntegerOfTerm(t3); + ptr->ValueOfVE.ints[indx] = i; + WRITE_UNLOCK(ptr->ArRWLock); + return Yap_unify(ARG4, MkIntegerTerm(i)); + } break; + case array_of_doubles: { + Float fl = ptr->ValueOfVE.floats[indx]; - if (IsFloatTerm(t3)) { - fl += FloatOfTerm(t3); - } else if (IsIntegerTerm(t3)) { - fl += IntegerOfTerm(t3); - } else { - WRITE_UNLOCK(ptr->ArRWLock); - Yap_Error(TYPE_ERROR_NUMBER,t3,"add_to_array_element"); - return FALSE; - } - ptr->ValueOfVE.floats[indx] = fl; + if (IsFloatTerm(t3)) { + fl += FloatOfTerm(t3); + } else if (IsIntegerTerm(t3)) { + fl += IntegerOfTerm(t3); + } else { WRITE_UNLOCK(ptr->ArRWLock); - return Yap_unify(ARG4,MkFloatTerm(fl)); + Yap_Error(TYPE_ERROR_NUMBER, t3, "add_to_array_element"); + return FALSE; } - break; + ptr->ValueOfVE.floats[indx] = fl; + WRITE_UNLOCK(ptr->ArRWLock); + return Yap_unify(ARG4, MkFloatTerm(fl)); + } break; default: WRITE_UNLOCK(ptr->ArRWLock); - Yap_Error(TYPE_ERROR_NUMBER,t2,"add_to_array_element"); + Yap_Error(TYPE_ERROR_NUMBER, t2, "add_to_array_element"); return FALSE; } } -static Int -compile_array_refs( USES_REGS1 ) -{ +static Int compile_array_refs(USES_REGS1) { compile_arrays = TRUE; return (TRUE); } -static Int -array_refs_compiled( USES_REGS1 ) -{ - return compile_arrays; -} +static Int array_refs_compiled(USES_REGS1) { return compile_arrays; } -static Int -sync_mmapped_arrays( USES_REGS1 ) -{ +static Int sync_mmapped_arrays(USES_REGS1) { #ifdef HAVE_MMAP mmap_array_block *ptr = GLOBAL_mmap_arrays; while (ptr != NULL) { @@ -2437,7 +2340,7 @@ sync_mmapped_arrays( USES_REGS1 ) ptr = ptr->next; } #endif - return(TRUE); + return (TRUE); } /** @pred static_array_to_term(? _Name_, ? _Term_) @@ -2451,9 +2354,7 @@ that name. */ -static Int -static_array_to_term( USES_REGS1 ) -{ +static Int static_array_to_term(USES_REGS1) { Term t = Deref(ARG1); if (IsVarTerm(t)) { @@ -2475,144 +2376,130 @@ static_array_to_term( USES_REGS1 ) Int dim = pp->ArrayEArity, indx; CELL *base; - while (HR+1+dim > ASP-1024) { - if (!Yap_gcl((1+dim)*sizeof(CELL), 2, ENV, gc_P(P,CP))) { - Yap_Error(RESOURCE_ERROR_STACK,TermNil,LOCAL_ErrorMessage); - return(FALSE); - } else { - if (HR+1+dim > ASP-1024) { - if (!Yap_growstack( sizeof(CELL) * (dim+1-(HR-ASP-1024)))) { - Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); - return FALSE; - } - } - } + while (HR + 1 + dim > ASP - 1024) { + if (!Yap_gcl((1 + dim) * sizeof(CELL), 2, ENV, gc_P(P, CP))) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); + return (FALSE); + } else { + if (HR + 1 + dim > ASP - 1024) { + if (!Yap_growstack(sizeof(CELL) * (dim + 1 - (HR - ASP - 1024)))) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); + return FALSE; + } + } + } } READ_LOCK(pp->ArRWLock); READ_UNLOCK(ae->ARWLock); base = HR; - *HR++ = (CELL)Yap_MkFunctor(AbsAtom(ae),dim); - switch(tp) { - case array_of_ints: - { - CELL *sptr = HR; - HR += dim; - for (indx=0; indx < dim; indx++) { - *sptr++ = MkIntegerTerm(pp->ValueOfVE.ints[indx]); - } - } - break; + *HR++ = (CELL)Yap_MkFunctor(AbsAtom(ae), dim); + switch (tp) { + case array_of_ints: { + CELL *sptr = HR; + HR += dim; + for (indx = 0; indx < dim; indx++) { + *sptr++ = MkIntegerTerm(pp->ValueOfVE.ints[indx]); + } + } break; case array_of_dbrefs: - for (indx=0; indx < dim; indx++) { - /* The object is now in use */ - Term TRef = pp->ValueOfVE.dbrefs[indx]; + for (indx = 0; indx < dim; indx++) { + /* The object is now in use */ + Term TRef = pp->ValueOfVE.dbrefs[indx]; - if (TRef != 0L) { - DBRef ref = DBRefOfTerm(TRef); - LOCK(ref->lock); + if (TRef != 0L) { + DBRef ref = DBRefOfTerm(TRef); + LOCK(ref->lock); #if MULTIPLE_STACKS - INC_DBREF_COUNT(ref); - TRAIL_REF(ref); /* So that fail will erase it */ + INC_DBREF_COUNT(ref); + TRAIL_REF(ref); /* So that fail will erase it */ #else - if (!(ref->Flags & InUseMask)) { - ref->Flags |= InUseMask; - TRAIL_REF(ref); /* So that fail will erase it */ - } + if (!(ref->Flags & InUseMask)) { + ref->Flags |= InUseMask; + TRAIL_REF(ref); /* So that fail will erase it */ + } #endif - UNLOCK(ref->lock); - } else { - TRef = TermNil; - } - *HR++ = TRef; - } - break; - case array_of_doubles: - { - CELL *sptr = HR; - HR += dim; - for (indx=0; indx < dim; indx++) { - *sptr++ = MkEvalFl(pp->ValueOfVE.floats[indx]); - } - } - break; - case array_of_ptrs: - { - CELL *sptr = HR; - HR += dim; - for (indx=0; indx < dim; indx++) { - *sptr++ = MkAddressTerm(pp->ValueOfVE.ptrs[indx]); - } - } - break; - case array_of_chars: - { - CACHE_REGS - CELL *sptr = HR; - HR += dim; - for (indx=0; indx < dim; indx++) { - *sptr++ = MkIntTerm(pp->ValueOfVE.chars[indx]); - } - } - break; - case array_of_uchars: - { - CACHE_REGS - CELL *sptr = HR; - HR += dim; - for (indx=0; indx < dim; indx++) { - *sptr++ = MkIntTerm(pp->ValueOfVE.uchars[indx]); - } - } - break; - case array_of_terms: - { - CELL *sptr = HR; - HR += dim; - for (indx=0; indx < dim; indx++) { - /* The object is now in use */ - DBTerm *ref = pp->ValueOfVE.terms[indx]; + UNLOCK(ref->lock); + } else { + TRef = TermNil; + } + *HR++ = TRef; + } + break; + case array_of_doubles: { + CELL *sptr = HR; + HR += dim; + for (indx = 0; indx < dim; indx++) { + *sptr++ = MkEvalFl(pp->ValueOfVE.floats[indx]); + } + } break; + case array_of_ptrs: { + CELL *sptr = HR; + HR += dim; + for (indx = 0; indx < dim; indx++) { + *sptr++ = MkAddressTerm(pp->ValueOfVE.ptrs[indx]); + } + } break; + case array_of_chars: { + CACHE_REGS + CELL *sptr = HR; + HR += dim; + for (indx = 0; indx < dim; indx++) { + *sptr++ = MkIntTerm(pp->ValueOfVE.chars[indx]); + } + } break; + case array_of_uchars: { + CACHE_REGS + CELL *sptr = HR; + HR += dim; + for (indx = 0; indx < dim; indx++) { + *sptr++ = MkIntTerm(pp->ValueOfVE.uchars[indx]); + } + } break; + case array_of_terms: { + CELL *sptr = HR; + HR += dim; + for (indx = 0; indx < dim; indx++) { + /* The object is now in use */ + DBTerm *ref = pp->ValueOfVE.terms[indx]; - Term TRef = GetTermFromArray(ref PASS_REGS); + Term TRef = GetTermFromArray(ref PASS_REGS); - if (P == FAILCODE) { - return FALSE; - } + if (P == FAILCODE) { + return FALSE; + } - *sptr++ = TRef; - } - } - break; - case array_of_nb_terms: - { - CELL *sptr = HR; - HR += dim; - for (indx=0; indx < dim; indx++) { - /* The object is now in use */ - Term To = GetNBTerm(pp->ValueOfVE.lterms, indx PASS_REGS); + *sptr++ = TRef; + } + } break; + case array_of_nb_terms: { + CELL *sptr = HR; + HR += dim; + for (indx = 0; indx < dim; indx++) { + /* The object is now in use */ + Term To = GetNBTerm(pp->ValueOfVE.lterms, indx PASS_REGS); - if (P == FAILCODE) { - return FALSE; - } + if (P == FAILCODE) { + return FALSE; + } - *sptr++ = To; - } - } - break; + *sptr++ = To; + } + } break; case array_of_atoms: - for (indx=0; indx < dim; indx++) { - Term out; - out = pp->ValueOfVE.atoms[indx]; - if (out == 0L) - out = TermNil; - *HR++ = out; - } - break; + for (indx = 0; indx < dim; indx++) { + Term out; + out = pp->ValueOfVE.atoms[indx]; + if (out == 0L) + out = TermNil; + *HR++ = out; + } + break; } READ_UNLOCK(pp->ArRWLock); - return Yap_unify(AbsAppl(base),ARG2); + return Yap_unify(AbsAppl(base), ARG2); } } - Yap_Error(TYPE_ERROR_ATOM,t,"add_to_array_element"); + Yap_Error(TYPE_ERROR_ATOM, t, "add_to_array_element"); return FALSE; } @@ -2622,9 +2509,7 @@ static_array_to_term( USES_REGS1 ) Give the location or memory address for a static array with name _Name_. The result is observed as an integer. */ -static Int -static_array_location( USES_REGS1 ) -{ +static Int static_array_location(USES_REGS1) { Term t = Deref(ARG1); Int *ptr; @@ -2643,23 +2528,24 @@ static_array_location( USES_REGS1 ) READ_UNLOCK(ae->ARWLock); return FALSE; } else { - ptr = pp->ValueOfVE.ints; + ptr = pp->ValueOfVE.ints; READ_UNLOCK(ae->ARWLock); } - return Yap_unify(ARG2,MkAddressTerm(ptr)); + return Yap_unify(ARG2, MkAddressTerm(ptr)); } return FALSE; } -void -Yap_InitArrayPreds( void ) -{ +void Yap_InitArrayPreds(void) { Yap_InitCPred("$create_array", 2, create_array, SyncPredFlag); Yap_InitCPred("$array_references", 3, array_references, SafePredFlag); Yap_InitCPred("$array_arg", 3, array_arg, SafePredFlag); - Yap_InitCPred("static_array", 3, create_static_array, SafePredFlag|SyncPredFlag); - Yap_InitCPred("resize_static_array", 3, resize_static_array, SafePredFlag|SyncPredFlag); - Yap_InitCPred("mmapped_array", 4, create_mmapped_array, SafePredFlag|SyncPredFlag); + Yap_InitCPred("static_array", 3, create_static_array, + SafePredFlag | SyncPredFlag); + Yap_InitCPred("resize_static_array", 3, resize_static_array, + SafePredFlag | SyncPredFlag); + Yap_InitCPred("mmapped_array", 4, create_mmapped_array, + SafePredFlag | SyncPredFlag); Yap_InitCPred("update_array", 3, assign_static, SafePredFlag); Yap_InitCPred("dynamic_update_array", 3, assign_dynamic, SafePredFlag); Yap_InitCPred("add_to_array_element", 4, add_to_array_element, SafePredFlag); @@ -2669,12 +2555,12 @@ Yap_InitArrayPreds( void ) Yap_InitCPred("$sync_mmapped_arrays", 0, sync_mmapped_arrays, SafePredFlag); Yap_InitCPred("$compile_array_refs", 0, compile_array_refs, SafePredFlag); Yap_InitCPred("$array_refs_compiled", 0, array_refs_compiled, SafePredFlag); - Yap_InitCPred("$static_array_properties", 3, static_array_properties, SafePredFlag); + Yap_InitCPred("$static_array_properties", 3, static_array_properties, + SafePredFlag); Yap_InitCPred("static_array_to_term", 2, static_array_to_term, 0L); Yap_InitCPred("static_array_location", 2, static_array_location, 0L); } - /** @} */ diff --git a/C/flags.c b/C/flags.c index 98d37776d..067dc963d 100644 --- a/C/flags.c +++ b/C/flags.c @@ -51,8 +51,8 @@ static Int current_prolog_flag(USES_REGS1); static Int set_prolog_flag(USES_REGS1); #include "Yatom.h" -#include "yapio.h" #include "eval.h" +#include "yapio.h" #define YAP_FLAG(ID, NAME, WRITABLE, DEF, INIT, HELPER) \ { NAME, WRITABLE, DEF, INIT, HELPER } @@ -199,7 +199,7 @@ static bool getenc(Term inp) { Yap_Error(TYPE_ERROR_ATOM, inp, "get_encoding"); return false; } - return Yap_unify(inp, MkAtomTerm(Yap_LookupAtom(enc_name(LOCAL_encoding)))); + return Yap_unify(inp, MkAtomTerm(Yap_LookupAtom(enc_name(LOCAL_encoding)))); } /* @@ -585,10 +585,10 @@ static void initFlag(flag_info *f, int fnum, bool global) { static bool executable(Term inp) { CACHE_REGS - if (GLOBAL_argv && GLOBAL_argv[0]) { - if (!Yap_AbsoluteFile(GLOBAL_argv[0], LOCAL_FileNameBuf,true)) - return false; - } else + if (GLOBAL_argv && GLOBAL_argv[0]) { + if (!Yap_AbsoluteFile(GLOBAL_argv[0], LOCAL_FileNameBuf, true)) + return false; + } else strncpy(LOCAL_FileNameBuf, Yap_FindExecutable(), YAP_FILENAME_MAX - 1); return Yap_unify(MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)), inp); @@ -1012,19 +1012,18 @@ bool setYapFlag(Term tflag, Term t2) { return true; } - Term Yap_UnknownFlag(Term mod) { - if (mod == PROLOG_MODULE) - mod = TermProlog; + if (mod == PROLOG_MODULE) + mod = TermProlog; - ModEntry *fv = Yap_GetModuleEntry(mod); + ModEntry *fv = Yap_GetModuleEntry(mod); if (fv == NULL) - fv = Yap_GetModuleEntry(TermUser); - if (fv->flags & UNKNOWN_ERROR) - return TermError; - if (fv->flags & UNKNOWN_WARNING) - return TermWarning; - return TermFail; + fv = Yap_GetModuleEntry(TermUser); + if (fv->flags & UNKNOWN_ERROR) + return TermError; + if (fv->flags & UNKNOWN_WARNING) + return TermWarning; + return TermFail; } Term getYapFlag(Term tflag) { @@ -1254,10 +1253,10 @@ static bool setInitialValue(bool bootstrap, flag_func f, const char *s, if (bootstrap) { return false; } - CACHE_REGS - encoding_t encoding = ENC_ISO_UTF8; - t0 = Yap_StringToTerm(s, strlen(s) + 1, &encoding, GLOBAL_MaxPriority, - NULL); + CACHE_REGS + encoding_t encoding = ENC_ISO_UTF8; + t0 = + Yap_StringToTerm(s, strlen(s) + 1, &encoding, GLOBAL_MaxPriority, NULL); if (!t0) return false; if (IsAtomTerm(t0) || IsIntTerm(t0)) { @@ -1275,10 +1274,10 @@ static bool setInitialValue(bool bootstrap, flag_func f, const char *s, } #define PROLOG_FLAG_PROPERTY_DEFS() \ - PAR("access", isaccess, PROLOG_FLAG_PROPERTY_ACCESS, "read_write"), \ - PAR("type", isground, PROLOG_FLAG_PROPERTY_TYPE, "term"), \ + PAR("access", isaccess, PROLOG_FLAG_PROPERTY_ACCESS, "read_write") \ + , PAR("type", isground, PROLOG_FLAG_PROPERTY_TYPE, "term"), \ PAR("scope", flagscope, PROLOG_FLAG_PROPERTY_SCOPE, "global"), \ - PAR("keep", booleanFlag, PROLOG_FLAG_PROPERTY_KEEP, "false"), \ + PAR("keep", booleanFlag, PROLOG_FLAG_PROPERTY_KEEP, "false"), \ PAR(NULL, ok, PROLOG_FLAG_PROPERTY_END, 0) #define PAR(x, y, z, w) z @@ -1306,7 +1305,7 @@ do_prolog_flag_property(Term tflag, args = Yap_ArgList2ToVector(opts, prolog_flag_property_defs, PROLOG_FLAG_PROPERTY_END); if (args == NULL) { - Yap_Error( LOCAL_Error_TYPE, LOCAL_Error_Term, NULL ); + Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, NULL); return false; } if (!IsAtomTerm(tflag)) { @@ -1345,8 +1344,8 @@ do_prolog_flag_property(Term tflag, rc = rc && Yap_unify(TermFloat, args[PROLOG_FLAG_PROPERTY_TYPE].tvalue); else - rc = - rc && Yap_unify(TermTerm, args[PROLOG_FLAG_PROPERTY_TYPE].tvalue); + rc = rc && + Yap_unify(TermTerm, args[PROLOG_FLAG_PROPERTY_TYPE].tvalue); break; case PROLOG_FLAG_PROPERTY_KEEP: rc = rc && false; @@ -1467,8 +1466,8 @@ static Int do_create_prolog_flag(USES_REGS1) { args = Yap_ArgList2ToVector(opts, prolog_flag_property_defs, PROLOG_FLAG_PROPERTY_END); - if (args == NULL) { - Yap_Error( LOCAL_Error_TYPE, LOCAL_Error_Term, NULL ); + if (args == NULL) { + Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, NULL); return false; } fv = GetFlagProp(AtomOfTerm(tflag)); @@ -1542,7 +1541,7 @@ void Yap_InitFlags(bool bootstrap) { } GLOBAL_flagCount++; f++; - } + } LOCAL_flagCount = 0; int nflags = sizeof(local_flags_setup) / sizeof(flag_info); if (bootstrap) diff --git a/H/ATOMS b/H/ATOMS new file mode 100644 index 000000000..62391d6c8 --- /dev/null +++ b/H/ATOMS @@ -0,0 +1,570 @@ +// +// Fields are TAB spaced +// Atoms are of the form A Name Normal,FullLookup String +// Functors are of the form F Name Atom Arity +// Terms are of the form T FullName Atom +// +// This is supported by YAP directly +// A Dot N "." +// +A 3Dots N "..." +A Abol F "$abol" +A Access N "access" +A AfInet N "AF_INET" +A AfLocal N "AF_LOCAL" +A AfUnix N "AF_UNIX" +A Alarm F "$alarm" +A Alias N "alias" +A All N "all" +A AltNot N "not" +A Answer N "answer" +A Any N "any" +A Append N "append" +A Arg N "arg" +A Array F "$array" +A ArrayAccess F "$array_arg" +A ArrayOverflow N "array_overflow" +A ArrayType N "array_type" +A Arrow N "->" +A AttributedModule N "attributes_module" +A DoubleArrow N "-->" +A Assert N ":-" +A EmptyBrackets N "()" +A EmptySquareBrackets N "[]" +A EmptyCurlyBrackets N "{}" +A Asserta N "asserta" +A AssertaStatic N "asserta_static" +A Assertz N "assertz" +A AssertzStatic N "assertz_static" +A At N "at" +A Atom N "atom" +A Atomic N "atomic" +A Att F "$att" +A Att1 N "att" +A AttDo F "$att_do" +A Attributes N "attributes" +A B F "$last_choice_pt" +A Batched N "batched" +A Between N "between" +A Binary N "binary" +A BigNum N "big_num" +A BinaryStream N "binary_stream" +A Boolean N "boolean" +A Braces N "{}" +A Break F "$break" +A Byte N "byte" +A CArith F "$c_arith" +A Call N "call" +A CallAndRetryCounter N "call_and_retry_counter" +A CallCounter N "call_counter" +A Callable N "callable" +A Catch F "$catch" +A ChangeModule F "$change_module" +A Char N "char" +A Charsio N "charsio" +A Character N "character" +A CharacterCode N "character_code" +A Chars N "chars" +A Charset N "charset" +A ChType F "$char_type" +A CleanCall F "$clean_call" +A Colon N ":" +A CodeSpace N "code_space" +A Codes N "codes" +A CoInductive N "coinductive" +A Comma N "," +A CommentHook N "comment_hook" +A Compact N "compact" +A Compound N "compound" +A ConsistencyError N "consistency_error" +A Consult N "consult" +A ConsultOnBoot F "$consult_on_boot" +A Context N "context" +A Cputime N "cputime" +A Create N "create" +A Creep F "$creep" +A CryptAtoms N "crypt_atoms" +A Curly N "{}" +A Csult F "$csult" +A CurrentModule F "$current_module" +A Cut N "!" +A CutBy F "$cut_by" +A DAbort F "$abort" +A DBLoad F "$db_load" +A DBREF N "DBRef" +A DBReference N "db_reference" +A DBTerm N "db_term" +A DBref F "$dbref" +A DInteger F "$integer" +A DebugMeta F "$debug_meta" +A DebuggerInput N "debugger_input" +A Dec10 N "dec10" +A Default N "default" +A DevNull N "/dev/null" +A Diff N "\\=" +A Directory N "disrectorys" +A Discontiguous N "discontiguous" +A DiscontiguousWarnings N "discontiguous_warnings" +A Dollar F "$" +A DoLogUpdClause F "$do_log_upd_clause" +A DoLogUpdClause0 F "$do_log_upd_clause0" +A DoLogUpdClauseErase F "$do_log_upd_clause_erase" +A DollarU F "$u" +A DollarUndef F "$undef" +A DomainError N "domain_error" +A DoStaticClause F "$do_static_clause" +A Dots N "dots" +A DOUBLE F "Double" +A DoubleSlash F "//" +A E N "e" +A EOFBeforeEOT N "end_of_file_found_before_end_of_term" +A EQ N "=" +A EmptyAtom N "" +A Encoding N "encoding" +A EndOfStream N "$end_of_stream" +A Eof N "end_of_file" +A EOfCode N "eof_code" +A Eq N "=" +A Error N "error" +A Exception N "exception" +A Extensions N "extensions" +A Evaluable N "evaluable" +A EvaluationError N "evaluation_error" +A Executable N "executable" +A Execute N "execute" +A ExecAnswers N "exec_answers" +A ExecuteInMod F "$execute_in_mod" +A ExecuteWithin F "$execute_within" +A ExecuteWoMod F "$execute_wo_mod" +A Exist N "exist" +A Exit N "exit" +A ExistenceError N "existence_error" +A ExoClause F "$exo_clause" +A ExpectedNumber N "expected_number_syntax" +A Expand N "expand" +A ExtendFileSearchPath F "$extend_file_search_path" +A Extendsions N "extensionh" +A FB N "fb" +A Fail N "fail" +A False N "false" +A Fast F "$fast" +A FastFail N "fast_fail" +A FileErrors N "file_errors" +A Fileerrors N "fileerrors" +A FileType N "file_type" +A First N "first" +A Float N "float" +A FloatFormat N "\%.15g" +A FloatOverflow N "float_overflow" +A FloatUnderflow N "float_underflow" +A Format N "format" +A FormatAt F "$format@" +A Full N "full" +A Functor N "functor" +A GT N ">" +A GVar N "var" +A Gc F "$gc" +A GcMargin F "$gc_margin" +A GcTrace F "$gc_trace" +A GcVerbose F "$gc_verbose" +A GcVeryVerbose F "$gc_very_verbose" +A GeneratePredInfo F "$generate_pred_info" +A Getwork F "$getwork" +A GetworkSeq F "$getwork_seq" +A Glob N "glob" +A Global N "global" +A GlobalSp N "global_sp" +A GlobalTrie N "global_trie" +A GoalExpansion N "goal_expansion" +A Hat N "^" +A HERE N "\n <====HERE====> \n" +A HandleThrow F "$handle_throw" +A Heap N "heap" +A HeapUsed N "heapused" +A HugeInt N "huge_int" +A IDB N "idb" +A IOMode N "io_mode" +A I N "i" +A Id N "id" +A Ignore N "ignore" +A Inf N "inf" +A Infinity N "infinity" +A InitGoal F "$init_goal" +A InitProlog F "$init_prolog" +A InStackExpansion N "in stack expansion" +A Input N "input" +A InstantiationError N "instantiation_error" +A Int N "int" +A IntOverflow N "int_overflow" +A Integer N "integer" +A InternalCompilerError N "internal_compiler_error" +A Is N "is" +A J N "j" +A Key N "key" +A LDLibraryPath N "LD_LIBRARY_PATH" +A LONGINT N "LongInt" +A LOOP N "_LOOP_" +A LoopStream N "loop_stream" +A LT N "<" +A LastExecuteWithin F "$last_execute_within" +A Leash F "$leash" +A Least N "least" +A Length F "length" +A List N "list" +A Line N "line" +A Live F "$live" +A LoadAnswers N "load_answers" +A Local N "local" +A LocalSp N "local_sp" +A LocalTrie N "local_trie" +A Max N "max" +A Maximum N "maximum" +A MaxArity N "max_arity" +A MaxFiles N "max_files" +A MegaClause F "$mega_clause" +A MetaCall F "$call" +A MfClause F "$mf_clause" +A Min N "min" +A Minimum N "minimum" +A Minus N "-" +A Modify N "modify" +A Module N "module" +A Most N "most" +A Multi N "multi" +A MultiFile F "$mf" +A Multiple F "multiple" +A Mutable N "mutable" +A MutableVariable F "$mutable_variable" +A Mutex N "mutex" +A MyddasDB F "$myddas_db" +A MyddasGoal F "$myddas_goal" +A MyddasHost F "$myddas_host" +A MyddasPass F "$myddas_pass" +A MyddasUser F "$myddas_user" +A MyddasVersionName F "$myddas_version_name" +A Nan N "nan" +A Nb N "nb" +A NbTerm N "nb_term" +A New N "new" +A NewLine N "nl" +A Nl N "nl" +A NoEffect N "no_effect" +A NoMemory N "no_memory" +A None N "none" +A NonEmptyList N "non_empty_list" +A Not N "\\+" +A NotImplemented N "not_implemented" +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 Off N "off" +A Offline N "offline" +A On N "on" +A Online N "online" +A Open N "open" +A OperatingSystemError N "operating_SYSTEM_ERROR_INTERNAL" +A OperatingSystemSupport N "operating_system_support" +A Operator N "operator" +A OperatorPriority N "operator_priority" +A OperatorSpecifier N "operator_specifier" +A Opt N "opt" +A Otherwise N "otherwise" +A OutOfAttvarsError N "out_of_attvars_error" +A OutOfAuxspaceError N "out_of_auxspace_error" +A OutOfHeapError N "out_of_heap_error" +A OutOfRange N "out_of_range" +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 Plus N "+" +A Pointer N "pointer" +A Portray F "portray" +A PredicateIndicator N "predicate_indicator" +A Primitive N "primitive" +A PrintMessage N "print_message" +A PrivateProcedure N "private_procedure" +A Procedure N "procedure" +A Profile F "$profile" +A Prolog N "prolog" +A ProtectStack F "$protect_stack" +A Qly N "qly" +A Query N "?-" +A Queue N "queue" +A Quiet N "quiet" +A Radix N "radix" +A Random N "random" +A Range N "range" +A RDiv N "rdiv" +A Read N "read" +A ReadOnly N "read_only" +A ReadWrite N "read_write" +A Readutil N "readutil" +A Reconsult N "reconsult" +A RecordedP F "$recordep" +A RecordedWithKey F "$recorded_with_key" +A RedefineWarnings N "redefine_warnings" +A RedoFreeze F "$redo_freeze" +A RefoundVar F "$I_FOUND_THE_VARIABLE_AGAIN" +A RelativeTo F "relative_to" +A Repeat N "repeat" +A RepeatSpace N "repeat " +A Reposition N "reposition" +A RepresentationError N "representation_error" +A Reset N "reset" +A Resize N "resize" +A ResourceError N "resource_error" +A RestoreRegs F "$restore_regs" +A Retry N "retry" +A RetryCounter N "retry_counter" +A RTree N "rtree" +A Safe F "$safe" +A SafeCallCleanup F "$safe_call_cleanup" +A Same N "==" +A Semic N ";" +A ShiftCountOverflow N "shift_count_overflow" +A SigAlarm N "sig_alarm" +A SigBreak N "sig_break" +A SigCreep N "sig_creep" +A SigDebug N "sig_debug" +A SigDelayCreep N "sig_delay_creep" +A SigFPE N "sig_fpe" +A SigHup N "sig_hup" +A SigInt N "sig_int" +A SigIti N "sig_iti" +A SigPending F "$sig_pending" +A SigPipe N "sig_pipe" +A SigStackDump N "sig_stack_dump" +A SigStatistics N "sig_statistics" +A SigTrace N "sig_trace" +A SigUsr1 N "sig_usr1" +A SigUsr2 N "sig_usr2" +A SigVTAlarm N "sig_vtalarm" +A SigWakeUp N "sig_wake_up" +A Silent N "Silent" +A Single N "single" +A SingleVarWarnings N "single_var_warnings" +A Singleton N "singleton" +A Slash N "/" +A Socket N "socket" +A Solutions N "solutions" +A Source N "source" +A SourceSink N "source_sink" +A Spy F "$spy" +A Stack N "stack" +A StackFree N "stackfree" +A StartupSavedState F "$startup_saved_state" +A StaticClause F "$static_clause" +A StaticProcedure N "static_procedure" +A Stream F "$stream" +A SWIStream F "" +A VStream N "stream" +A Streams N "streams" +A StreamOrAlias N "stream_or_alias" +A StreamPos F "$stream_position" +A StreamPosition N "stream_position" +A String N "string" +A StyleCheck N "style_check" +A STRING F "String" +A Swi N "swi" +A SymbolChar N "symbol_char" +A SyntaxError N "syntax_error" +A SyntaxErrors N "syntax_errors" +A SyntaxErrorHandler N "syntax_error_handler" +A System N "system" +A SystemError N "SYSTEM_ERROR_INTERNAL" +A SystemLibraryDir N "system_library_directory" +A T N "t" +A Term N "term" +A TermExpansion N "term_expansion" +A Terms N "terms" +A Text N "text" +A TextStream N "text_stream" +A Thread N "thread" +A Threads N "threads" +A Throw N "throw" +A TimeOutSpec N "time_out_spec" +A TimeoutError N "timeout_error" +A TopLevelGoal F "$top_level_goal" +A TopThreadGoal F "$top_thread_goal" +A TraceMetaCall F "$trace_meta_call" +A Trail N "trail" +A True N "true" +A Tty N "tty" +A Ttys N "ttys" +A Tuple N "tuple" +A Txt N "txt" +A TypeError N "type_error" +A Undefined N "undefined" +A Undefp F "$undefp" +A Underflow N "underflow" +A UnificationStack N "unification_stack" +A Unique N "unique" +A UnsignedByte N "unsigned_byte" +A UnsignedChar N "unsigned_char" +A User N "user" +A UserErr N "user_error" +A UserIn N "user_input" +A UserOut N "user_output" +A DollarVar N "$VAR" +A VBar N "|" +A VarBranches N "var_branches" +A VariableNames N "variable_names" +A HiddenVar F "$V" +A Variable N "variable" +A Verbose N "verbose" +A VerboseFileSearch N "verbose_file_search" +A VersionNumber F "$version_name" +A VeryVerbose N "very_verbose" +A WakeUpGoal F "$wake_up_goal" +A Warning N "warning" +A When F "$when" +A Write N "write" +A Xml N "xml" +A YapHacks N "yap_hacks" +A ZeroDivisor N "zero_divisor" +F AfInet AfInet 2 +F AfLocal AfLocal 1 +F AfUnix AfUnix 1 +F AltNot AltNot 1 +F Arg Arg 3 +F ArrayEntry ArrayAccess 3 +F Arrow Arrow 2 +F DoubleArrow DoubleArrow 2 +F Assert1 Assert 1 +F Assert Assert 2 +F AtFoundOne FoundVar 2 +F Atom Atom 1 +F Att1 Att1 3 +F AttGoal AttDo 2 +F Braces Braces 1 +F Call Call 1 +F Catch Catch 3 +F ChangeModule ChangeModule 1 +F Chars Chars 2 +F Chars1 Chars 1 +F CleanCall CleanCall 2 +F Clist When 4 +F Codes Codes 2 +F Codes1 Codes 1 +F Colon Colon 2 +F Comma Comma 2 +F CommentHook CommentHook 3 +F Context2 Context 2 +F ConsistencyError ConsistencyError 1 +F Creep Creep 1 +F Csult Csult 2 +F CurrentModule CurrentModule 1 +F CutBy CutBy 1 +F DBREF DBREF 1 +F Diff Diff 2 +F DoLogUpdClause DoLogUpdClause 6 +F DoLogUpdClause0 DoLogUpdClause0 6 +F DoLogUpdClauseErase DoLogUpdClauseErase 6 +F DoStaticClause DoStaticClause 5 +F Dollar Dollar 1 +F DollarVar DollarVar 1 +F DomainError DomainError 2 +F Dot Dot 2 +F Dot10 Dot 10 +F Dot11 Dot 11 +F Dot12 Dot 12 +F Dot2 Dot 2 +F Dot3 Dot 3 +F Dot4 Dot 4 +F Dot5 Dot 5 +F Dot6 Dot 6 +F Dot7 Dot 7 +F Dot8 Dot 8 +F Dot9 Dot 9 +F DoubleSlash DoubleSlash 2 +F EmptySquareBrackets EmptySquareBrackets 2 +F EmptyCurlyBrackets EmptyCurlyBrackets 2 +F Eq Eq 2 +F Error Error 2 +F EvaluationError EvaluationError 1 +F Exception Exception 1 +F Execute2InMod ExecuteWoMod 2 +F ExecuteInMod ExecuteInMod 2 +F ExecuteWithin ExecuteWithin 1 +F ExistenceError ExistenceError 2 +F ExoClause ExoClause 2 +F Functor Functor 3 +F GAtom Atom 1 +F GAtomic Atomic 1 +F GCompound Compound 1 +F GFloat Float 1 +F GFormatAt FormatAt 2 +F GInteger Integer 1 +F GNumber Number 1 +F GPrimitive Primitive 1 +F GVar GVar 1 +F GeneratePredInfo GeneratePredInfo 4 +F GoalExpansion2 GoalExpansion 2 +F GoalExpansion GoalExpansion 3 +F HandleThrow HandleThrow 3 +F Hat Hat 2 +F I I 2 +F Id Id 1 +F Is Is 2 +F J J 2 +F LastExecuteWithin LastExecuteWithin 1 +F List Dot 2 +F LOOP LOOP 1 +F MegaClause MegaClause 2 +F MetaCall MetaCall 4 +F Minus Minus 2 +F Module Colon 2 +F MultiFileClause MfClause 5 +F Mutable MutableVariable (sizeof(timed_var)/sizeof(CELL)) +F Mutex Mutex 2 +F NotImplemented NotImplemented 2 +F NBQueue Queue 4 +F Not Not 1 +F Obj Obj 1 +F Or Semic 2 +F PermissionError PermissionError 3 +F Plus Plus 2 +F Portray Portray 1 +F PrintMessage PrintMessage 2 +F Procedure Procedure 5 +F PrologConstraint Prolog 2 +F ProtectStack ProtectStack 4 +F Query Query 1 +F RecordedWithKey RecordedWithKey 6 +F RDiv RDiv 2 +F RedoFreeze RedoFreeze 3 +F RepresentationError RepresentationError 1 +F ResourceError ResourceError 1 +F RestoreRegs RestoreRegs 2 +F RestoreRegs1 RestoreRegs 1 +F Safe Safe 1 +F SafeCallCleanup SafeCallCleanup 4 +F Same Same 2 +F Slash Slash 2 +F StaticClause StaticClause 2 +F Stream Stream 1 +F StreamEOS EndOfStream 1 +F StreamPos StreamPos 4 +F String1 String 1 +F StyleCheck StyleCheck 4 +F SyntaxError SyntaxError 4 +F ShortSyntaxError SyntaxError 1 +F TermExpansion TermExpansion 2 +F ThreadRun TopThreadGoal 2 +F Throw Throw 1 +F TimeoutError TimeoutError 2 +F TraceMetaCall TraceMetaCall 3 +F TypeError TypeError 2 +F UMinus Minus 1 +F UPlus Plus 1 +F VBar VBar 2 +F HiddenVar HiddenVar 1 diff --git a/misc/GLOBALS b/H/GLOBALS similarity index 100% rename from misc/GLOBALS rename to H/GLOBALS diff --git a/misc/HEAPFIELDS b/H/HEAPFIELDS similarity index 99% rename from misc/HEAPFIELDS rename to H/HEAPFIELDS index 9c853199f..4aca1c345 100644 --- a/misc/HEAPFIELDS +++ b/H/HEAPFIELDS @@ -91,7 +91,7 @@ ATOMS Term TermDollarU MkAT AtomDollarU #endif Term TermAnswer MkAT AtomAnswer -z + //modules Term USER_MODULE MkAT AtomUser Term IDB_MODULE MkAT AtomIDB diff --git a/misc/LOCALS b/H/LOCALS similarity index 100% rename from misc/LOCALS rename to H/LOCALS diff --git a/H/generated/dglobals.h b/H/generated/dglobals.h index 03c212ceb..490aa16ed 100644 --- a/H/generated/dglobals.h +++ b/H/generated/dglobals.h @@ -1,6 +1,6 @@ /* This file, dglobals.h, was generated automatically by "yap -L misc/buildlocalglobal" - please do not update, update misc/GLOBALS instead */ + please do not update, update H/GLOBALS instead */ diff --git a/H/generated/dhstruct.h b/H/generated/dhstruct.h index 39c872ca4..fead49e0b 100644 --- a/H/generated/dhstruct.h +++ b/H/generated/dhstruct.h @@ -1,6 +1,6 @@ /* This file, dhstruct.h, was generated automatically by "yap -L misc/buildlocalglobal" - please do not update, update misc/HEAPFIELDS instead */ + please do not update, update H/HEAPFIELDS instead */ diff --git a/H/generated/dlocals.h b/H/generated/dlocals.h index 6bb794ccc..cb9c76e32 100644 --- a/H/generated/dlocals.h +++ b/H/generated/dlocals.h @@ -1,6 +1,6 @@ /* This file, dlocals.h, was generated automatically by "yap -L misc/buildlocalglobal" - please do not update, update misc/LOCALS instead */ + please do not update, update H/LOCALS instead */ diff --git a/H/generated/h0globals.h b/H/generated/h0globals.h index 39d0cb38b..79e9cf9be 100644 --- a/H/generated/h0globals.h +++ b/H/generated/h0globals.h @@ -1,6 +1,6 @@ /* This file, hglobals.h, was generated automatically by "yap -L misc/buildlocalglobal" - please do not update, update misc/GLOBALS instead */ + please do not update, update H/GLOBALS instead */ // // File defining fields in the Yap_GLOBAL global structure diff --git a/H/generated/h0struct.h b/H/generated/h0struct.h index 9eeed2949..e3172dd1d 100644 --- a/H/generated/h0struct.h +++ b/H/generated/h0struct.h @@ -1,6 +1,6 @@ /* This file, d0hstruct.h, was generated automatically by "yap -L misc/buildlocalglobal" - please do not update, update misc/HEAPFIELDS instead */ + please do not update, update H/HEAPFIELDS instead */ // // File defining fields in the Yap_heap_codes global structure diff --git a/H/generated/hglobals.h b/H/generated/hglobals.h index 555731e1f..b2b7643f4 100644 --- a/H/generated/hglobals.h +++ b/H/generated/hglobals.h @@ -1,6 +1,6 @@ /* This file, hglobals.h, was generated automatically by "yap -L misc/buildlocalglobal" - please do not update, update misc/GLOBALS instead */ + please do not update, update H/GLOBALS instead */ // // File defining fields in the Yap_GLOBAL global structure diff --git a/H/generated/hlocals.h b/H/generated/hlocals.h index 0190cca28..e3b5ac788 100644 --- a/H/generated/hlocals.h +++ b/H/generated/hlocals.h @@ -1,6 +1,6 @@ /* This file, hlocals.h, was generated automatically by "yap -L misc/buildlocalglobal" - please do not update, update misc/LOCALS instead */ + please do not update, update H/LOCALS instead */ // Stuff that must be considered local to a thread or worker typedef struct worker_local { diff --git a/H/generated/hstruct.h b/H/generated/hstruct.h index 40c139d8b..98b6101dc 100755 --- a/H/generated/hstruct.h +++ b/H/generated/hstruct.h @@ -1,6 +1,6 @@ /* This file, hstruct.h, was generated automatically by "yap -L misc/buildlocalglobal" - please do not update, update misc/HEAPFIELDS instead */ + please do not update, update H/HEAPFIELDS instead */ // // File defining fields in the Yap_heap_codes global structure diff --git a/H/generated/iatoms.h b/H/generated/iatoms.h index a1b5d1ea0..120356855 100644 --- a/H/generated/iatoms.h +++ b/H/generated/iatoms.h @@ -63,7 +63,7 @@ AtomCharset = Yap_LookupAtom("charset"); TermCharset = MkAtomTerm(AtomCharset); AtomChType = Yap_FullLookupAtom("$char_type"); TermChType = MkAtomTerm(AtomChType); AtomCleanCall = Yap_FullLookupAtom("$clean_call"); TermCleanCall = MkAtomTerm(AtomCleanCall); - AtomColomn = Yap_LookupAtom(":"); TermColomn = MkAtomTerm(AtomColomn); + 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); @@ -79,6 +79,7 @@ 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); @@ -178,6 +179,7 @@ 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); @@ -192,6 +194,7 @@ 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); AtomKey = Yap_LookupAtom("key"); TermKey = MkAtomTerm(AtomKey); AtomLDLibraryPath = Yap_LookupAtom("LD_LIBRARY_PATH"); TermLDLibraryPath = MkAtomTerm(AtomLDLibraryPath); AtomLONGINT = Yap_LookupAtom("LongInt"); TermLONGINT = MkAtomTerm(AtomLONGINT); @@ -250,6 +253,7 @@ 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); @@ -374,8 +378,8 @@ AtomSystemError = Yap_LookupAtom("SYSTEM_ERROR_INTERNAL"); TermSystemError = MkAtomTerm(AtomSystemError); AtomSystemLibraryDir = Yap_LookupAtom("system_library_directory"); TermSystemLibraryDir = MkAtomTerm(AtomSystemLibraryDir); AtomTerm = Yap_LookupAtom("term"); TermTerm = MkAtomTerm(AtomTerm); - AtomTerms = Yap_LookupAtom("terms"); TermTerms = MkAtomTerm(AtomTerms); 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); @@ -444,6 +448,7 @@ 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); @@ -458,6 +463,7 @@ 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); @@ -499,21 +505,24 @@ 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); 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(AtomColomn,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); FunctorPermissionError = Yap_MkFunctor(AtomPermissionError,3); FunctorPlus = Yap_MkFunctor(AtomPlus,2); diff --git a/H/generated/iglobals.h b/H/generated/iglobals.h index 96f0d39f1..a408c77ce 100644 --- a/H/generated/iglobals.h +++ b/H/generated/iglobals.h @@ -1,6 +1,6 @@ /* This file, iglobals.h, was generated automatically by "yap -L misc/buildlocalglobal" - please do not update, update misc/GLOBALS instead */ + please do not update, update H/GLOBALS instead */ diff --git a/H/generated/ihstruct.h b/H/generated/ihstruct.h index 33e55ac29..3e99a75ad 100644 --- a/H/generated/ihstruct.h +++ b/H/generated/ihstruct.h @@ -1,6 +1,6 @@ /* This file, ihstruct.h, was generated automatically by "yap -L misc/buildlocalglobal" - please do not update, update misc/HEAPFIELDS instead */ + please do not update, update H/HEAPFIELDS instead */ diff --git a/H/generated/ilocals.h b/H/generated/ilocals.h index 77b869946..577a2187f 100755 --- a/H/generated/ilocals.h +++ b/H/generated/ilocals.h @@ -1,6 +1,6 @@ /* This file, ilocals.h, was generated automatically by "yap -L misc/buildlocalglobal" - please do not update, update misc/LOCALS instead */ + please do not update, update H/LOCALS instead */ static void InitWorker(int wid) { diff --git a/H/generated/ratoms.h b/H/generated/ratoms.h index c61b8b958..21ed856ca 100644 --- a/H/generated/ratoms.h +++ b/H/generated/ratoms.h @@ -63,7 +63,7 @@ AtomCharset = AtomAdjust(AtomCharset); TermCharset = MkAtomTerm(AtomCharset); AtomChType = AtomAdjust(AtomChType); TermChType = MkAtomTerm(AtomChType); AtomCleanCall = AtomAdjust(AtomCleanCall); TermCleanCall = MkAtomTerm(AtomCleanCall); - AtomColomn = AtomAdjust(AtomColomn); TermColomn = MkAtomTerm(AtomColomn); + AtomColon = AtomAdjust(AtomColon); TermColon = MkAtomTerm(AtomColon); AtomCodeSpace = AtomAdjust(AtomCodeSpace); TermCodeSpace = MkAtomTerm(AtomCodeSpace); AtomCodes = AtomAdjust(AtomCodes); TermCodes = MkAtomTerm(AtomCodes); AtomCoInductive = AtomAdjust(AtomCoInductive); TermCoInductive = MkAtomTerm(AtomCoInductive); @@ -79,6 +79,7 @@ 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); @@ -178,6 +179,7 @@ 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); @@ -192,6 +194,7 @@ AtomInteger = AtomAdjust(AtomInteger); TermInteger = MkAtomTerm(AtomInteger); AtomInternalCompilerError = AtomAdjust(AtomInternalCompilerError); TermInternalCompilerError = MkAtomTerm(AtomInternalCompilerError); AtomIs = AtomAdjust(AtomIs); TermIs = MkAtomTerm(AtomIs); + AtomJ = AtomAdjust(AtomJ); TermJ = MkAtomTerm(AtomJ); AtomKey = AtomAdjust(AtomKey); TermKey = MkAtomTerm(AtomKey); AtomLDLibraryPath = AtomAdjust(AtomLDLibraryPath); TermLDLibraryPath = MkAtomTerm(AtomLDLibraryPath); AtomLONGINT = AtomAdjust(AtomLONGINT); TermLONGINT = MkAtomTerm(AtomLONGINT); @@ -250,6 +253,7 @@ 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); @@ -374,8 +378,8 @@ AtomSystemError = AtomAdjust(AtomSystemError); TermSystemError = MkAtomTerm(AtomSystemError); AtomSystemLibraryDir = AtomAdjust(AtomSystemLibraryDir); TermSystemLibraryDir = MkAtomTerm(AtomSystemLibraryDir); AtomTerm = AtomAdjust(AtomTerm); TermTerm = MkAtomTerm(AtomTerm); - AtomTerms = AtomAdjust(AtomTerms); TermTerms = MkAtomTerm(AtomTerms); 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); @@ -444,6 +448,7 @@ FunctorClist = FuncAdjust(FunctorClist); FunctorCodes = FuncAdjust(FunctorCodes); FunctorCodes1 = FuncAdjust(FunctorCodes1); + FunctorColon = FuncAdjust(FunctorColon); FunctorComma = FuncAdjust(FunctorComma); FunctorCommentHook = FuncAdjust(FunctorCommentHook); FunctorContext2 = FuncAdjust(FunctorContext2); @@ -458,6 +463,7 @@ FunctorDoLogUpdClause0 = FuncAdjust(FunctorDoLogUpdClause0); FunctorDoLogUpdClauseErase = FuncAdjust(FunctorDoLogUpdClauseErase); FunctorDoStaticClause = FuncAdjust(FunctorDoStaticClause); + FunctorDollar = FuncAdjust(FunctorDollar); FunctorDollarVar = FuncAdjust(FunctorDollarVar); FunctorDomainError = FuncAdjust(FunctorDomainError); FunctorDot = FuncAdjust(FunctorDot); @@ -499,8 +505,10 @@ FunctorGoalExpansion = FuncAdjust(FunctorGoalExpansion); FunctorHandleThrow = FuncAdjust(FunctorHandleThrow); FunctorHat = FuncAdjust(FunctorHat); + FunctorI = FuncAdjust(FunctorI); FunctorId = FuncAdjust(FunctorId); FunctorIs = FuncAdjust(FunctorIs); + FunctorJ = FuncAdjust(FunctorJ); FunctorLastExecuteWithin = FuncAdjust(FunctorLastExecuteWithin); FunctorList = FuncAdjust(FunctorList); FunctorLOOP = FuncAdjust(FunctorLOOP); @@ -514,6 +522,7 @@ FunctorNotImplemented = FuncAdjust(FunctorNotImplemented); FunctorNBQueue = FuncAdjust(FunctorNBQueue); FunctorNot = FuncAdjust(FunctorNot); + FunctorObj = FuncAdjust(FunctorObj); FunctorOr = FuncAdjust(FunctorOr); FunctorPermissionError = FuncAdjust(FunctorPermissionError); FunctorPlus = FuncAdjust(FunctorPlus); diff --git a/H/generated/rhstruct.h b/H/generated/rhstruct.h index 2efa87471..eabdc9284 100644 --- a/H/generated/rhstruct.h +++ b/H/generated/rhstruct.h @@ -1,6 +1,6 @@ /* This file, rhstruct.h, was generated automatically by "yap -L misc/buildlocalglobal" - please do not update, update misc/HEAPFIELDS instead */ + please do not update, update H/HEAPFIELDS instead */ diff --git a/H/generated/rlocals.h b/H/generated/rlocals.h index 6538410f2..3125c81e8 100644 --- a/H/generated/rlocals.h +++ b/H/generated/rlocals.h @@ -1,6 +1,6 @@ /* This file, rlocals.h, was generated automatically by "yap -L misc/buildlocalglobal" - please do not update, update misc/LOCALS instead */ + please do not update, update H/LOCALS instead */ static void RestoreWorker(int wid USES_REGS) { diff --git a/H/generated/tatoms.h b/H/generated/tatoms.h index 754a03a2d..ca19f0125 100644 --- a/H/generated/tatoms.h +++ b/H/generated/tatoms.h @@ -63,7 +63,7 @@ Atom AtomChars; Term TermChars; Atom AtomCharset; Term TermCharset; Atom AtomChType; Term TermChType; Atom AtomCleanCall; Term TermCleanCall; -Atom AtomColomn; Term TermColomn; +Atom AtomColon; Term TermColon; Atom AtomCodeSpace; Term TermCodeSpace; Atom AtomCodes; Term TermCodes; Atom AtomCoInductive; Term TermCoInductive; @@ -79,6 +79,7 @@ Atom AtomCputime; Term TermCputime; Atom AtomCreate; Term TermCreate; Atom AtomCreep; Term TermCreep; Atom AtomCryptAtoms; Term TermCryptAtoms; +Atom AtomCurly; Term TermCurly; Atom AtomCsult; Term TermCsult; Atom AtomCurrentModule; Term TermCurrentModule; Atom AtomCut; Term TermCut; @@ -178,6 +179,7 @@ Atom AtomHeapUsed; Term TermHeapUsed; Atom AtomHugeInt; Term TermHugeInt; Atom AtomIDB; Term TermIDB; Atom AtomIOMode; Term TermIOMode; +Atom AtomI; Term TermI; Atom AtomId; Term TermId; Atom AtomIgnore; Term TermIgnore; Atom AtomInf; Term TermInf; @@ -192,6 +194,7 @@ Atom AtomIntOverflow; Term TermIntOverflow; Atom AtomInteger; Term TermInteger; Atom AtomInternalCompilerError; Term TermInternalCompilerError; Atom AtomIs; Term TermIs; +Atom AtomJ; Term TermJ; Atom AtomKey; Term TermKey; Atom AtomLDLibraryPath; Term TermLDLibraryPath; Atom AtomLONGINT; Term TermLONGINT; @@ -250,6 +253,7 @@ Atom AtomNotLessThanZero; Term TermNotLessThanZero; Atom AtomNotNewline; Term TermNotNewline; Atom AtomNotZero; Term TermNotZero; Atom AtomNumber; Term TermNumber; +Atom AtomObj; Term TermObj; Atom AtomOff; Term TermOff; Atom AtomOffline; Term TermOffline; Atom AtomOn; Term TermOn; @@ -374,8 +378,8 @@ Atom AtomSystem; Term TermSystem; Atom AtomSystemError; Term TermSystemError; Atom AtomSystemLibraryDir; Term TermSystemLibraryDir; Atom AtomTerm; Term TermTerm; -Atom AtomTerms; Term TermTerms; Atom AtomTermExpansion; Term TermTermExpansion; +Atom AtomTerms; Term TermTerms; Atom AtomText; Term TermText; Atom AtomTextStream; Term TermTextStream; Atom AtomThread; Term TermThread; @@ -468,6 +472,8 @@ Atom AtomZeroDivisor; Term TermZeroDivisor; Functor FunctorCodes1; + Functor FunctorColon; + Functor FunctorComma; Functor FunctorCommentHook; @@ -496,6 +502,8 @@ Atom AtomZeroDivisor; Term TermZeroDivisor; Functor FunctorDoStaticClause; + Functor FunctorDollar; + Functor FunctorDollarVar; Functor FunctorDomainError; @@ -578,10 +586,14 @@ Atom AtomZeroDivisor; Term TermZeroDivisor; Functor FunctorHat; + Functor FunctorI; + Functor FunctorId; Functor FunctorIs; + Functor FunctorJ; + Functor FunctorLastExecuteWithin; Functor FunctorList; @@ -608,6 +620,8 @@ Atom AtomZeroDivisor; Term TermZeroDivisor; Functor FunctorNot; + Functor FunctorObj; + Functor FunctorOr; Functor FunctorPermissionError; diff --git a/H/hstruct.h b/H/hstruct.h deleted file mode 100644 index d14c1b714..000000000 --- a/H/hstruct.h +++ /dev/null @@ -1,303 +0,0 @@ - - /* This file, hstruct.h, was generated automatically by "yap -L misc/buildheap" - please do not update, update misc/HEAPFIELDS instead */ - - - - - - - - - - - - - - - - - - - - - - - - - - - -typedef struct worker_local { - - UInt Yap_HoleSize; - struct malloc_state *Yap_av; -#if USE_DL_MALLOC - struct Yap_MemoryHoles[MAX_DLMALLOC_HOLES] void; - UInt Yap_NOfMemoryHoles; -#if defined(YAPOR) || defined(THREADS) - lockvar DLMallocLock; -#endif -#endif -#if USE_DL_MALLOC || (USE_SYSTEM_MALLOC && HAVE_MALLINFO) -#ifndef HeapUsed -#define HeapUsed Yap_givemallinfo() -#endif - Int NotHeapUsed; -#else - Int HeapUsed; -#endif - Int HeapMax; - ADDR HeapTop; - ADDR HeapLim; - struct FREEB *FreeBlocks; -#if defined(YAPOR) || defined(THREADS) - lockvar FreeBlocksLock; - lockvar HeapUsedLock; - lockvar HeapTopLock; - int HeapTopOwner; -#endif - UInt MaxStack; - UInt MaxTrail; - - -#if USE_THREADED_CODE - op_entry *OP_RTABLE; -#endif - - OPCODE EXECUTE_CPRED_OP_CODE; - OPCODE EXPAND_OP_CODE; - OPCODE FAIL_OPCODE; - OPCODE INDEX_OPCODE; - OPCODE LOCKPRED_OPCODE; - OPCODE ORLAST_OPCODE; - OPCODE UNDEF_OPCODE; - OPCODE RETRY_USERC_OPCODE; - OPCODE EXECUTE_CPRED_OPCODE; - - UInt NOfAtoms; - UInt AtomHashTableSize; - UInt WideAtomHashTableSize; - UInt NOfWideAtoms; - AtomHashEntry INVISIBLECHAIN; - AtomHashEntry *WideHashChain; - AtomHashEntry *HashChain; - -#include "tatoms.h" -#ifdef EUROTRA - Term TermDollarU; -#endif - - Term USER_MODULE; - Term IDB_MODULE; - Term ATTRIBUTES_MODULE; - Term CHARSIO_MODULE; - Term CHTYPE_MODULE; - Term TERMS_MODULE; - Term SYSTEM_MODULE; - Term READUTIL_MODULE; - Term HACKS_MODULE; - Term ARG_MODULE; - Term GLOBALS_MODULE; - Term SWI_MODULE; - Term DBLOAD_MODULE; - Term RANGE_MODULE; - Term ERROR_MODULE; - - - - struct mod_entry *CurrentModules; - - - - - Prop HIDDEN_PREDICATES; - - - - union flagTerm* GLOBAL_Flags; - UInt GLOBAL_flagCount; - - yap_exec_mode Yap_ExecutionMode; - - UInt PredsInHashTable; - uint64_t PredHashTableSize; - struct pred_entry **PredHash; -#if defined(YAPOR) || defined(THREADS) - rwlock_t PredHashRWLock; -#endif - - struct pred_entry *CreepCode; - struct pred_entry *UndefCode; - struct pred_entry *SpyCode; - struct pred_entry *PredFail; - struct pred_entry *PredTrue; -#ifdef COROUTINING - struct pred_entry *WakeUpCode; -#endif - struct pred_entry *PredGoalExpansion; - struct pred_entry *PredMetaCall; - struct pred_entry *PredTraceMetaCall; - struct pred_entry *PredDollarCatch; - struct pred_entry *PredRecordedWithKey; - struct pred_entry *PredLogUpdClause; - struct pred_entry *PredLogUpdClauseErase; - struct pred_entry *PredLogUpdClause0; - struct pred_entry *PredStaticClause; - struct pred_entry *PredThrow; - struct pred_entry *PredHandleThrow; - struct pred_entry *PredIs; - struct pred_entry *PredSafeCallCleanup; - struct pred_entry *PredRestoreRegs; - struct pred_entry *PredCommentHook; -#ifdef YAPOR - struct pred_entry *PredGetwork; -#endif /* YAPOR */ - struct pred_entry *PredProcedure; - -#ifdef LOW_LEVEL_TRACER - int Yap_do_low_level_trace; -#if defined(YAPOR) || defined(THREADS) - lockvar Yap_low_level_trace_lock; -#endif -#endif - - UInt Yap_ClauseSpace; - UInt Yap_IndexSpace_Tree; - UInt Yap_IndexSpace_EXT; - UInt Yap_IndexSpace_SW; - UInt Yap_LUClauseSpace; - UInt Yap_LUIndexSpace_Tree; - UInt Yap_LUIndexSpace_CP; - UInt Yap_LUIndexSpace_EXT; - UInt Yap_LUIndexSpace_SW; - - yamop COMMA_CODE[5]; - yamop DUMMYCODE[1]; - yamop FAILCODE[1]; - yamop NOCODE[1]; - yamop ENV_FOR_TRUSTFAIL[2]; - yamop *TRUSTFAILCODE; - yamop ENV_FOR_YESCODE[2]; - yamop *YESCODE; - yamop RTRYCODE[1]; -#ifdef BEAM - yamop BEAM_RETRY_CODE[1]; -#endif /* BEAM */ -#ifdef YAPOR - yamop GETWORK[1]; - yamop GETWORK_SEQ[1]; - yamop GETWORK_FIRST_TIME[1]; -#endif /* YAPOR */ -#ifdef TABLING - yamop LOAD_ANSWER[1]; - yamop TRY_ANSWER[1]; - yamop ANSWER_RESOLUTION[1]; - yamop COMPLETION[1]; -#ifdef THREADS_CONSUMER_SHARING - yamop ANSWER_RESOLUTION_COMPLETION[1]; -#endif /* THREADS_CONSUMER_SHARING */ -#endif /* TABLING */ - - - - - yamop *P_before_spy; - - yamop *RETRY_C_RECORDEDP_CODE; - yamop *RETRY_C_RECORDED_K_CODE; - - int PROFILING; - int CALL_COUNTING; - int optimizer_on; - int compile_mode; - int profiling; - int call_counting; - - int compile_arrays; - -#if defined(YAPOR) || defined(THREADS) - lockvar DBTermsListLock; -#endif - struct dbterm_list *DBTermsList; - - yamop *ExpandClausesFirst; - yamop *ExpandClausesLast; - UInt Yap_ExpandClauses; -#if defined(YAPOR) || defined(THREADS) - lockvar ExpandClausesListLock; - lockvar OpListLock; -#endif - -#ifdef DEBUG - UInt Yap_NewCps; - UInt Yap_LiveCps; - UInt Yap_DirtyCps; - UInt Yap_FreedCps; -#endif - UInt Yap_expand_clauses_sz; - - struct udi_info *UdiControlBlocks; - - - Int STATIC_PREDICATES_MARKED; - - Prop *INT_KEYS; - Prop *INT_LU_KEYS; - Prop *INT_BB_KEYS; - - UInt INT_KEYS_SIZE; - UInt INT_KEYS_TIMESTAMP; - UInt INT_BB_KEYS_SIZE; - - int UPDATE_MODE; - - struct DB_STRUCT *DBErasedMarker; - struct logic_upd_clause *LogDBErasedMarker; - - struct static_clause *DeadStaticClauses; - struct static_mega_clause *DeadMegaClauses; - struct static_index *DeadStaticIndices; - struct logic_upd_clause *DBErasedList; - struct logic_upd_index *DBErasedIList; -#if defined(YAPOR) || defined(THREADS) - lockvar DeadStaticClausesLock; - lockvar DeadMegaClausesLock; - lockvar DeadStaticIndicesLock; -#endif -#ifdef COROUTINING - - int NUM_OF_ATTS; - - UInt Yap_AttsSize; -#endif - - struct operator_entry *OpList; - - struct ForeignLoadItem *ForeignCodeLoaded; - ADDR ForeignCodeBase; - ADDR ForeignCodeTop; - ADDR ForeignCodeMax; - - struct record_list *Yap_Records; - - Atom *SWI_Atoms; - Functor *SWI_Functors; - swi_rev_hash SWI_ReverseHash[N_SWI_HASH]; - - Int AtomTranslations; - Int MaxAtomTranslations; - - Int FunctorTranslations; - Int MaxFunctorTranslations; - Atom EmptyWakeups[MAX_EMPTY_WAKEUPS]; - int MaxEmptyWakeups; - - struct YAP_blob_t *BlobTypes; - struct AtomEntryStruct *Blobs; - UInt NOfBlobs; - UInt NOfBlobsMax; -#if defined(YAPOR) || defined(THREADS) - lockvar Blobs_Lock; -#endif -} w_local; diff --git a/misc/ATOMS b/misc/ATOMS index ed734c645..db0024e0f 100644 --- a/misc/ATOMS +++ b/misc/ATOMS @@ -68,7 +68,7 @@ A Chars N "chars" A Charset N "charset" A ChType F "$char_type" A CleanCall F "$clean_call" -A Colomn N ":" +A Colon N ":" A CodeSpace N "code_space" A Codes N "codes" A CoInductive N "coinductive" @@ -84,6 +84,7 @@ A Cputime N "cputime" A Create N "create" A Creep F "$creep" A CryptAtoms N "crypt_atoms" +A Curly N "{}" A Csult F "$csult" A CurrentModule F "$current_module" A Cut N "!" @@ -183,6 +184,7 @@ A HeapUsed N "heapused" A HugeInt N "huge_int" A IDB N "idb" A IOMode N "io_mode" +A I N "i" A Id N "id" A Ignore N "ignore" A Inf N "inf" @@ -197,6 +199,7 @@ A IntOverflow N "int_overflow" A Integer N "integer" A InternalCompilerError N "internal_compiler_error" A Is N "is" +A J N "j" A Key N "key" A LDLibraryPath N "LD_LIBRARY_PATH" A LONGINT N "LongInt" @@ -255,6 +258,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 Off N "off" A Offline N "offline" A On N "on" @@ -378,9 +382,10 @@ A SyntaxErrorHandler N "syntax_error_handler" A System N "system" A SystemError N "SYSTEM_ERROR_INTERNAL" A SystemLibraryDir N "system_library_directory" -A Term N "term" -A Terms N "terms" +A T N "t" +A Term N "term" A TermExpansion N "term_expansion" +A Terms N "terms" A Text N "text" A TextStream N "text_stream" A Thread N "thread" @@ -395,6 +400,7 @@ A Trail N "trail" A True N "true" A Tty N "tty" A Ttys N "ttys" +A Tuple N "tuple" A Txt N "txt" A TypeError N "type_error" A Undefined N "undefined" @@ -449,6 +455,7 @@ F CleanCall CleanCall 2 F Clist When 4 F Codes Codes 2 F Codes1 Codes 1 +F Colon Colon 2 F Comma Comma 2 F CommentHook CommentHook 3 F Context2 Context 2 @@ -457,12 +464,14 @@ F Creep Creep 1 F Csult Csult 2 F CurrentModule CurrentModule 1 F CutBy CutBy 1 +F Curly Curly 1 F DBREF DBREF 1 F Diff Diff 2 F DoLogUpdClause DoLogUpdClause 6 F DoLogUpdClause0 DoLogUpdClause0 6 F DoLogUpdClauseErase DoLogUpdClauseErase 6 F DoStaticClause DoStaticClause 5 +F Dollar Dollar 1 F DollarVar DollarVar 1 F DomainError DomainError 2 F Dot Dot 2 @@ -504,21 +513,24 @@ F GoalExpansion2 GoalExpansion 2 F GoalExpansion GoalExpansion 3 F HandleThrow HandleThrow 3 F Hat Hat 2 +F I I 2 F Id Id 1 F Is Is 2 +F J J 2 F LastExecuteWithin LastExecuteWithin 1 F List Dot 2 F LOOP LOOP 1 F MegaClause MegaClause 2 F MetaCall MetaCall 4 F Minus Minus 2 -F Module Colomn 2 +F Module Colon 2 F MultiFileClause MfClause 5 F Mutable MutableVariable (sizeof(timed_var)/sizeof(CELL)) F Mutex Mutex 2 F NotImplemented NotImplemented 2 F NBQueue Queue 4 F Not Not 1 +F Obj Obj 1 F Or Semic 2 F PermissionError PermissionError 3 F Plus Plus 2 diff --git a/misc/buildatoms b/misc/buildatoms index e21914062..e6dfe5334 100644 --- a/misc/buildatoms +++ b/misc/buildatoms @@ -13,9 +13,9 @@ main :- warning(Warning), - file_filter_with_init('misc/ATOMS','H/generated/tatoms.h',gen_fields, Warning, ['tatoms.h']), - file_filter_with_init('misc/ATOMS','H/generated/iatoms.h',gen_decl, Warning, ['iatoms.h']), - file_filter_with_init('misc/ATOMS','H/generated/ratoms.h',gen_rcov, Warning, ['ratoms.h']). + file_filter_with_init('H/ATOMS','H/generated/tatoms.h',gen_fields, Warning, ['tatoms.h']), + file_filter_with_init('H/ATOMS','H/generated/iatoms.h',gen_decl, Warning, ['iatoms.h']), + file_filter_with_init('H/ATOMS','H/generated/ratoms.h',gen_rcov, Warning, ['ratoms.h']). warning('~n /* This file, ~a, was generated automatically by \"yap -L misc/buildatoms\"~n {lease do not update, update misc/ATOMS instead */~n~n'). diff --git a/misc/buildheap b/misc/buildheap deleted file mode 100644 index fa2d306cc..000000000 --- a/misc/buildheap +++ /dev/null @@ -1,343 +0,0 @@ - -:- use_module(library(lineutils), - [file_filter_with_initialization/5, - split/3, - glue/3]). - -:- use_module(library(lists), - [append/2, - append/3]). - -:- initialization(main). - -:- dynamic globals/1. - -:- yap_flag(write_strings,on). - -:- style_check(all). - -main :- - warning(Warning), - file_filter_with_initialization('misc/HEAPFIELDS','H/hstruct.h',gen_struct,Warning,['hstruct.h','HEAPFIELDS']), - file_filter_with_initialization('misc/HEAPFIELDS','H/dhstruct.h',gen_dstruct,Warning,['dhstruct.h','HEAPFIELDS']), - file_filter_with_initialization('misc/HEAPFIELDS','H/rhstruct.h',gen_hstruct,Warning,['rhstruct.h','HEAPFIELDS']), - file_filter_with_initialization('misc/HEAPFIELDS','H/ihstruct.h',gen_init,Warning,['ihstruct.h','HEAPFIELDS']). - %file_filter_with_initialization('misc/GLOBALS','H/hglobals.h',gen_struct,Warning,['hglobals.h','GLOBALS']), - %file_filter_with_initialization('misc/GLOBALS','H/dglobals.h',gen_dstruct,Warning,['dglobals.h','GLOBALS']), - %file_filter_with_initialization('misc/GLOBALS','H/rglobals.h',gen_hstruct,Warning,['rglobals.h','GLOBALS']), - %file_filter_with_initialization('misc/GLOBALS','H/iglobals.h',gen_init,Warning,['iglobals.h','GLOBALS']), - %file_filter_with_initialization('misc/LOCALS','H/hlocals.h',gen_struct,Warning,['hlocals.h','LOCALS']), - %file_filter_with_initialization('misc/LOCALS','H/dlocals.h',gen_dstruct,Warning,['dlocals.h','LOCALS']), - %file_filter_with_initialization('misc/LOCALS','H/rlocals.h',gen_hstruct,Warning,['rlocals.h','LOCALS']), - %file_filter_with_initialization('misc/LOCALS','H/ilocals.h',gen_init,Warning,['ilocals.h','LOCALS']). - -warning('~n /* This file, ~a, was generated automatically by \"yap -L misc/buildheap\"~n please do not update, update misc/~a instead */~n~n'). - -/* define the field */ -gen_struct(Inp,"") :- - Inp = [0'/,0'/|_], !. -gen_struct(Inp,"") :- - Inp = [0'/,0'*|_], !. -gen_struct(Inp, Out) :- - Inp = [0'#|_], !, Out = Inp. % ' -gen_struct(Inp,"") :- - Inp = [0'.|_], !. %' -gen_struct(Inp,Out) :- - Inp = "START_WORKER_LOCAL", !, - Out = "typedef struct worker_local {". -gen_struct(Inp,Out) :- - Inp = "END_WORKER_LOCAL", !, - Out = "} w_local;". -gen_struct(Inp,Out) :- - Inp = "START_HEAP", !, - Out = "typedef struct worker_local {". -gen_struct(Inp,Out) :- - Inp = "END_HEAP", !, - Out = "} w_local;". -gen_struct(Inp,Out) :- - Inp = "START_GLOBAL_DATA", !, - Out = "typedef struct global_data {". -gen_struct(Inp,Out) :- - Inp = "END_GLOBAL_DATA", !, - Out = "} w_shared;". -gen_struct(Inp,Out) :- - Inp = "ATOMS", !, - Out = "#include \"tatoms.h\"". -gen_struct(Inp,Out) :- - split(Inp," ",["struct",Type, Field|_]), !, - append([" struct ",Type," ",Field,";"], Out). -gen_struct(Inp,Out) :- - split(Inp," ",["union",Type, Field|_]), !, - append([" union ",Type," ",Field,";"], Out). -gen_struct(Inp,Out) :- - split(Inp," ",["const",Type, Field|_]), !, - append([" const ",Type," ",Field,";"], Out). -gen_struct(Inp,"") :- - split(Inp," ",["void","void"|_]), !. -gen_struct(Inp,Out) :- - split(Inp," ",[Type, Field|_]), !, - append([" ",Type," ",Field,";"], Out). -gen_struct(Inp,_) :- - split(Inp," ",[_, _, _| _]), - format(user_error,"OOPS: could not gen_struct for ~s~n",[Inp]). - -gen_dstruct(Inp,"") :- - Inp = [0'/,0'/|_], !. -gen_dstruct(Inp,"") :- - Inp = [0'/,0'*|_], !. -gen_dstruct(Inp, Out) :- - Inp = [0'#|_], !, Out = Inp. % ' -gen_dstruct(Inp,"") :- - Inp = "START_WORKER_LOCAL", !, - assert(globals(worker)). -gen_dstruct(Inp,"") :- - Inp = "END_WORKER_LOCAL", !, - retract(globals(worker)). -gen_dstruct(Inp,"") :- - Inp = "START_GLOBAL_DATA", !, - assert(globals(all)). -gen_dstruct(Inp,"") :- - Inp = "END_GLOBAL_DATA", !, - retract(globals(all)). -gen_dstruct(Inp,Out) :- - Inp = "ATOMS", !, - Out = "". -gen_dstruct(Inp,"") :- - split(Inp," ",["void","void"|_]), !. -gen_dstruct(Inp,Out) :- - split(Inp," ",["struct"|Inp2]), !, - glue(Inp2, " ", Inp3), - gen_dstruct(Inp3, Out). -gen_dstruct(Inp,Out) :- - split(Inp," ",["union"|Inp2]), !, - glue(Inp2, " ", Inp3), - gen_dstruct(Inp3, Out). -gen_dstruct(Inp,Out) :- - split(Inp," ",["const"|Inp2]), !, - glue(Inp2, " ", Inp3), - gen_dstruct(Inp3, Out). -gen_dstruct(Inp,Out) :- - split(Inp," ",[_, Field, Name|_]), !, - cut_c_stuff(Field, RField), - fetch_name(Global), - append(["#define ",Name," ",Global,RField], Out). -gen_dstruct(Inp,_) :- - split(Inp," ",[_, _, _| _]), - format(user_error,"OOPS: could not gen_dstruct for ~s~n",[Inp]). - -fetch_name(Global) :- - globals(all), !, - Global = "Yap_global->". -fetch_name(Global) :- - globals(worker), !, - Global = "LOCAL->". -fetch_name(Global) :- - globals(worker_init), !, - Global = "REMOTE(wid)->". -fetch_name(Global) :- - Global = "Yap_heap_regs->". - -fetch_name(Global,RField,_) :- - globals(worker_init), !, - append("REMOTE(wid)->",RField,Global). -fetch_name(Global,_,Global). - -% handle *field[4] -cut_c_stuff([0'*|Name], RName) :- !, % 'cut * - cut_c_stuff(Name, RName). -cut_c_stuff(Name, RName) :- - cut_mat(Name, RName). - -cut_mat([], []). -cut_mat([0'[|_], []) :- !. %' -cut_mat([H|Name], [H|RName]) :- - cut_mat(Name, RName). - -gen_hstruct(Inp,"") :- - Inp = [0'/,0'/|_], !. -gen_hstruct(Inp,"") :- - Inp = [0'.|_], !. %' -gen_hstruct(Inp,"") :- - Inp = [0'/,0'*|_], !. -gen_hstruct(Inp,Out) :- - Inp = "ATOMS", !, - Out = "#include \"ratoms.h\"". -gen_hstruct(Inp,Out) :- - Inp = "START_WORKER_LOCAL", !, - Out = "static void RestoreWorker(int wid USES_REGS) {", - assert(globals(worker_init)). -gen_hstruct(Inp,Out) :- - Inp = "END_WORKER_LOCAL", !, - Out = "}", - retract(globals(worker_init)). -gen_hstruct(Inp,Out) :- - Inp = "START_GLOBAL_DATA", !, - Out = "static void RestoreGlobal(void) {", - assert(globals(all)). -gen_hstruct(Inp,Out) :- - Inp = "END_GLOBAL_DATA", !, - Out = "}", - retract(globals(all)). -gen_hstruct(Inp, Out) :- - Inp = [0'#|_], !, Out = Inp. % ' -gen_hstruct(Inp,Out) :- - split(Inp," ",["struct"|Inp2]), !, - glue(Inp2, " ", Inp3), - gen_hstruct(Inp3,Out). -gen_hstruct(Inp,Out) :- - split(Inp," ",["union"|Inp2]), !, - glue(Inp2, " ", Inp3), - gen_hstruct(Inp3,Out). -gen_hstruct(Inp,Out) :- - split(Inp," ",["const"|Inp2]), !, - glue(Inp2, " ", Inp3), - gen_hstruct(Inp3,Out). -gen_hstruct(Inp,Out) :- - split(Inp," ",[_, Field, MacroName, "MkAT", _]), !, - fetch_name(Global,Field,MacroName), - append([" ",Global," = AtomTermAdjust(",Global,");"], Out). -gen_hstruct(Inp,Out) :- - split(Inp," ",[_, Field, MacroName, "MkPred"| _]), !, - cut_c_stuff(Field, RField), - fetch_name(Global,RField,MacroName), - append([" ",Global," = PtoPredAdjust(",Global,");"], Out). -gen_hstruct(Inp,Out) :- - split(Inp," ",[_, Field, MacroName, "MkOp", Name]), !, - fetch_name(Global,Field,MacroName), - append([" ",Global," = Yap_opcode(",Name,");"], Out). -gen_hstruct(Inp,Out) :- - split(Inp," ",[_, Field, MacroName, "MkLock"]), !, - fetch_name(Global,Field,MacroName), - append([" REINIT_LOCK(",Global,");"], Out). -gen_hstruct(Inp,Out) :- - split(Inp," ",[_, Field, MacroName, "MkRWLock"]), !, - fetch_name(Global,Field,MacroName), - append([" REINIT_RWLOCK(",Global,");"], Out). -gen_hstruct(Inp,Out) :- - split(Inp," ",[_, Field, MacroName, "MkInstE",OP]), !, - cut_c_stuff(Field, RField), - fetch_name(Global,RField,MacroName), - append([" ",Global,"->opc = Yap_opcode(",OP,");"], Out). -gen_hstruct(Inp,"") :- - split(Inp," ",[_, _, _, _]), !. -gen_hstruct(Inp,"") :- - split(Inp," ",[_, _, _, _, "void"]), !. -gen_hstruct(Inp,Restore) :- - split(Inp," ",[_, _, _, _, Restore0]), - append("Restore",_,Restore0), !, - append([" ",Restore0,";"],Restore). %' -gen_hstruct(Inp,Out) :- - split(Inp," ",[_, Field, MacroName, _, Adjust]), - append(Adjust,"Adjust",_), !, - cut_c_stuff(Field, RField), - fetch_name(Global,RField,MacroName), - append([" ",Global," = ",Adjust,"(",Global,");"], Out). -gen_hstruct(Inp,_) :- - split(Inp," ",[_, _, _| _]), - format(user_error,"OOPS: could not gen_hstruct for ~s~n",[Inp]). - -gen_init(Inp,"") :- - Inp = [0'/,0'*|_], !. -gen_init(Inp,"") :- - Inp = [0'/,0'/|_], !. -gen_init(Inp, Out) :- - Inp = [0'#|_], !, Out = Inp. % ' -gen_init(Inp,Out) :- - Inp = "ATOMS", !, - Out = "#include \"iatoms.h\"". -gen_init(Inp,Out) :- - Inp = "START_WORKER_LOCAL", !, - Out = "static void InitWorker(int wid) {", - assert(globals(worker_init)). -gen_init(Inp,Out) :- - Inp = "END_WORKER_LOCAL", !, - Out = "}", - retract(globals(worker_init)). -gen_init(Inp,Out) :- - Inp = "START_GLOBAL_DATA", !, - Out = "static void InitGlobal(void) {", - assert(globals(all)). -gen_init(Inp,Out) :- - Inp = "END_GLOBAL_DATA", !, - Out = "}", - retract(globals(all)). -gen_init(Inp,Out) :- - Inp = "START_HEAP", !, - Out = "static void InitGlobal(void) {", - assert(globals(heap)). -gen_init(Inp,Out) :- - Inp = "END_HEAP", !, - Out = "}", - retract(globals(heap)). -gen_init(Inp,Out) :- - split(Inp," ",["struct"|Inp2]), !, - glue(Inp2, " ", Inp3), - gen_init(Inp3, Out). -gen_init(Inp,Out) :- - split(Inp," ",["union"|Inp2]), !, - glue(Inp2, " ", Inp3), - gen_init(Inp3, Out). -gen_init(Inp,Out) :- - split(Inp," ",["const"|Inp2]), !, - glue(Inp2, " ", Inp3), - gen_init(Inp3, Out). -gen_init(Inp,"") :- - split(Inp," ",[_, _, _, "void"|_]), !. -gen_init(Inp,Init) :- - split(Inp," ",[_, _, _, Init0| _]), - append("Init",_,Init0), !, - append([" ",Init0,";"],Init). -gen_init(Inp,Init) :- - split(Inp," ",[_, _, _, Init0| _]), - append("Yap_Init",_,Init0), !, - append([" ",Init0,";"],Init). -gen_init(Inp,Init) :- - split(Inp," ",[_, _, _, Init0| _]), - append("Yap_init",_,Init0), !, - append([" ",Init0,";"],Init). -gen_init(Inp,Out) :- - split(Inp," ",[_, Field, MacroName, "MkAT", AtomName]), !, - cut_c_stuff(Field, RField), - fetch_name(Global,RField,MacroName), - append([" ",Global," = MkAtomTerm(",AtomName,");"], Out). -gen_init(Inp,Out) :- - split(Inp," ",[_, Field, MacroName, "MkOp", Name]), !, - fetch_name(Global,Field,MacroName), - append([" ",Global," = Yap_opcode(",Name,");"], Out). -gen_init(Inp,Out) :- - split(Inp," ",[_, Field, MacroName, "MkLock"]), !, - fetch_name(Global,Field,MacroName), - append([" INIT_LOCK(",Global,");"], Out). -gen_init(Inp,Out) :- - split(Inp," ",[_, Field, MacroName, "MkRWLock"]), !, - fetch_name(Global,Field,MacroName), - append([" INIT_RWLOCK(",Global,");"], Out). -gen_init(Inp,Out) :- - split(Inp," ",[_, Field, MacroName, "MkInstE",OP]), !, - cut_c_stuff(Field, RField), - fetch_name(Global,RField,MacroName), - append([" ",Global,"->opc = Yap_opcode(",OP,");"], Out). -gen_init(Inp,Out) :- - split(Inp," ",[_, Field, MacroName, "MkLogPred", Atom, "0", Module]), !, - cut_c_stuff(Field, RField), - fetch_name(Global,RField,MacroName), - append([" ",Global," = Yap_MkLogPred(RepPredProp(PredPropByAtom(",Atom,",",Module,")));"], Out). -gen_init(Inp,Out) :- - split(Inp," ",[_, Field, MacroName, "MkLogPred", Atom, Arity, Module]), !, - cut_c_stuff(Field, RField), - fetch_name(Global,RField,MacroName), - append([" ",Global," = Yap_MkLogPred(RepPredProp(PredPropByFunc(Yap_MkFunctor(",Atom,",",Arity,"),",Module,")));"], Out). -gen_init(Inp,Out) :- - split(Inp," ",[_, Field, MacroName, "MkLogPred", Fun, Module]), !, - cut_c_stuff(Field, RField), - fetch_name(Global,RField,MacroName), - append([" ",Global," = Yap_MkLogPred(RepPredProp(PredPropByFunc(",Fun,",",Module,")));"], Out). -gen_init(Inp,Out) :- - split(Inp," ",[_, Field, MacroName, F0|_]), - append("=",F,F0), !, - cut_c_stuff(Field, RField), - fetch_name(Global,RField,MacroName), - append([" ",Global," = ",F,";"], Out). -gen_init(Inp,_) :- - split(Inp," ",[_, _, _| _]), - format(user_error,"OOPS: could not gen_init for ~s~n",[Inp]). diff --git a/misc/buildlocalglobal b/misc/buildlocalglobal index 529c9d314..311fee27d 100644 --- a/misc/buildlocalglobal +++ b/misc/buildlocalglobal @@ -21,22 +21,22 @@ file_filter_with_initialization(A,B,C,D,E) :- main :- warning(Warning), - file_filter_with_initialization('misc/HEAPFIELDS','H/generated/hstruct.h',gen_struct,Warning,['hstruct.h','HEAPFIELDS']), - file_filter_with_initialization('misc/HEAPFIELDS','H/generated/dhstruct.h',gen_dstruct,Warning,['dhstruct.h','HEAPFIELDS']), - file_filter_with_initialization('misc/HEAPFIELDS','H/generated/h0struct.h',gen_0struct,Warning,['d0hstruct.h','HEAPFIELDS']), - file_filter_with_initialization('misc/HEAPFIELDS','H/generated/rhstruct.h',gen_hstruct,Warning,['rhstruct.h','HEAPFIELDS']), - file_filter_with_initialization('misc/HEAPFIELDS','H/generated/ihstruct.h',gen_init,Warning,['ihstruct.h','HEAPFIELDS']), - file_filter_with_initialization('misc/GLOBALS','H/generated/h0globals.h',gen_0struct,Warning,['hglobals.h','GLOBALS']), - file_filter_with_initialization('misc/GLOBALS','H/generated/hglobals.h',gen_struct,Warning,['hglobals.h','GLOBALS']), - file_filter_with_initialization('misc/GLOBALS','H/generated/dglobals.h',gen_dstruct,Warning,['dglobals.h','GLOBALS']), - file_filter_with_initialization('misc/GLOBALS','H/generated/iglobals.h',gen_init,Warning,['iglobals.h','GLOBALS']), -%% file_filter_with_initialization('misc/GLOBALS','H/generated/i0globals.h',gen_0init,Warning,['iglobals.h','GLOBALS']), - file_filter_with_initialization('misc/LOCALS','H/generated/hlocals.h',gen_struct,Warning,['hlocals.h','LOCALS']), - file_filter_with_initialization('misc/LOCALS','H/generated/dlocals.h',gen_dstruct,Warning,['dlocals.h','LOCALS']), - file_filter_with_initialization('misc/LOCALS','H/generated/rlocals.h',gen_hstruct,Warning,['rlocals.h','LOCALS']), - file_filter_with_initialization('misc/LOCALS','H/generated/ilocals.h',gen_init,Warning,['ilocals.h','LOCALS']). + file_filter_with_initialization('H/HEAPFIELDS','H/generated/hstruct.h',gen_struct,Warning,['hstruct.h','HEAPFIELDS']), + file_filter_with_initialization('H/HEAPFIELDS','H/generated/dhstruct.h',gen_dstruct,Warning,['dhstruct.h','HEAPFIELDS']), + file_filter_with_initialization('H/HEAPFIELDS','H/generated/h0struct.h',gen_0struct,Warning,['d0hstruct.h','HEAPFIELDS']), + file_filter_with_initialization('H/HEAPFIELDS','H/generated/rhstruct.h',gen_hstruct,Warning,['rhstruct.h','HEAPFIELDS']), + file_filter_with_initialization('H/HEAPFIELDS','H/generated/ihstruct.h',gen_init,Warning,['ihstruct.h','HEAPFIELDS']), + file_filter_with_initialization('H/GLOBALS','H/generated/h0globals.h',gen_0struct,Warning,['hglobals.h','GLOBALS']), + file_filter_with_initialization('H/GLOBALS','H/generated/hglobals.h',gen_struct,Warning,['hglobals.h','GLOBALS']), + file_filter_with_initialization('H/GLOBALS','H/generated/dglobals.h',gen_dstruct,Warning,['dglobals.h','GLOBALS']), + file_filter_with_initialization('H/GLOBALS','H/generated/iglobals.h',gen_init,Warning,['iglobals.h','GLOBALS']), +%% file_filter_with_initialization('H/GLOBALS','H/generated/i0globals.h',gen_0init,Warning,['iglobals.h','GLOBALS']), + file_filter_with_initialization('H/LOCALS','H/generated/hlocals.h',gen_struct,Warning,['hlocals.h','LOCALS']), + file_filter_with_initialization('H/LOCALS','H/generated/dlocals.h',gen_dstruct,Warning,['dlocals.h','LOCALS']), + file_filter_with_initialization('H/LOCALS','H/generated/rlocals.h',gen_hstruct,Warning,['rlocals.h','LOCALS']), + file_filter_with_initialization('H/LOCALS','H/generated/ilocals.h',gen_init,Warning,['ilocals.h','LOCALS']). -warning('~n /* This file, ~a, was generated automatically by \"yap -L misc/buildlocalglobal\"~n please do not update, update misc/~a instead */~n~n'). +warning('~n /* This file, ~a, was generated automatically by \"yap -L misc/buildlocalglobal\"~n please do not update, update H/~a instead */~n~n'). @@ -121,19 +121,19 @@ gen_0struct(Inp,Out) :- Inp = "ATOMS", !, Out = "#include \"tatoms.h\"". gen_0struct(Inp,Out) :- - split(Inp," ",["struct",Type, Field|L]), !, + split(Inp," ",["struct",_Type, _Field|_L]), !, extract("struct", Inp, NInp), gen_0struct( NInp, NOut ), extract("EXTERNAL", NOut, IOut), append("EXTERNAL struct ", IOut, Out). gen_0struct(Inp,Out) :- - split(Inp," ",["const",Type, Field|L]), !, + split(Inp," ",["const",_Type, _Field|_L]), !, extract("const", Inp, NInp), gen_0struct( NInp, NOut ), extract("EXTERNAL", NOut, IOut), append("EXTERNAL const ", IOut, Out). gen_0struct(Inp,Out) :- - split(Inp," ",["union",Type, Field|L]), !, + split(Inp," ",["union",_Type, _Field|_L]), !, extract("union", Inp, NInp), gen_0struct( NInp, NOut ), extract("EXTERNAL", NOut, IOut),