From 50c04116c8f8f50a1220c5f2951cc744f05be953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Fri, 6 Nov 2015 18:22:31 +0000 Subject: [PATCH] moved from H --- .ctags | 31 +- .gitignore | 36 + C/attvar.c | 743 ++++++++---------- GitSHA1.c | 2 +- misc/analysis/load.yap | 2 +- os/YapIOConfig.h | 108 --- os/stream_wget_to_utf8 | 264 ------- .../ProbLog/problog_examples/output/out.dat | 26 - pl/arithpreds.yap | 9 + 9 files changed, 399 insertions(+), 822 deletions(-) delete mode 100644 os/YapIOConfig.h delete mode 100644 os/stream_wget_to_utf8 delete mode 100644 packages/ProbLog/problog_examples/output/out.dat diff --git a/.ctags b/.ctags index b74b5f268..f9386905e 100644 --- a/.ctags +++ b/.ctags @@ -1,10 +1,21 @@ ---exclude=*ggtags* ---exclude=*TAGS* ---exclude=HPP ---exclude=tags ---exclude=osx* ---exclude=build ---exclude=cscope* ---exclude=bin ---exclude=lib ---exclude=share +--langdef=Prolog +--langmap=Prolog:.pl.yap.ypp.prolog.pro +--regex-Prolog=/^([a-z][A-Za-z0-9_]*:)?([a-z][A-Za-z0-9_]*)\(.*\)[ \t]*(:-|-->)[ \t]*.*/\2/p,predicate,predicate definition/ +--regex-Prolog=/^([a-z][A-Za-z0-9_]*:)?\'(.*)\'\(.*\)[ \t]*(:-|-->)[ \t]*.*/\2/p,predicate,predicate definition/ +--regex-Prolog=/^([a-z][A-Za-z0-9_]*:)?([a-z][A-Za-z0-9_]*)\(.*\)\.[ \t]*.*/\2/p,predicate,predicate definition/ +--regex-Prolog=/^([a-z][A-Za-z0-9_]*:)?\'(.*)\'\(.*\)\.[ \t]*.*/\2/p,predicate,predicate definition/ +--regex-Prolog=/^:-[ \t]+(discontiguous|dynamic|multifile|table|thread_local)[ \t]+([a-z][_a-zA-Z0-9]*:)?([a-z0-9_][_a-zA-Z0-9]*)/\1/p,predicate,predicate metadata/ +--regex-Prolog=/^[ \t]*Yap_InitCPred[ \t]*\"(\$?[A-Za-z0-9_]*)\"([ \t]*).*/\1/p,predicate,predicate definition/ +--exclude=\._* +--exclude=*\.bak +--exclude=\.svn +--exclude=\.git +--exclude=CVS +--exclude=.*tags.* +--exclude=.*TAGS.* +--exclude=\.\#.* +--exclude=_darcs +--exclude=*~ +--exclude=\#.* +--exclude=(.)\#* +--exclude=*.dylib diff --git a/.gitignore b/.gitignore index 71d57ffdc..d9775c798 100644 --- a/.gitignore +++ b/.gitignore @@ -83,3 +83,39 @@ FindPackageLog.txt GitSHA1.c GitSHA1.c + +os/YapIOConfig.h + +os/YapIOConfig.h + +os/YapIOConfig.h + +os/readterm.c.cpp + +os/readterm.c.cpp + +packages/ProbLog/problog_examples/output/,_query_1_cluster_1.dot + +packages/ProbLog/#problog_lbdd.yap# + +packages/ProbLog/problog_examples/output/,_query_1_cluster_1.dot + +packages/ProbLog/problog_examples/output/out.dat + +packages/ProbLog/problog_examples/outputvalues.pl + +packages/ProbLog/problogbdd + +packages/raptor/raptor_config.h + +packages/real/rconfig.h + +packages/ProbLog/problog/#completion.yap# + +packages/ProbLog/problog_examples/output/out.dat + +packages/ProbLog/problog_examples/output/,_query_1_cluster_1.dot + +packages/ProbLog/problog_examples/output/out.dat + +packages/ProbLog/problog_examples/output/,_query_1_cluster_1 diff --git a/C/attvar.c b/C/attvar.c index 5e5137e57..976fe5cf5 100644 --- a/C/attvar.c +++ b/C/attvar.c @@ -15,7 +15,7 @@ * * *************************************************************************/ #ifdef SCCS -static char SccsId[]="%W% %G%"; +static char SccsId[] = "%W% %G%"; #endif #include "Yap.h" @@ -30,7 +30,8 @@ static char SccsId[]="%W% %G%"; /** @{ */ -/** @defgroup Attribute_Variables_Builtins Implementation of Attribute Declarations +/** @defgroup Attribute_Variables_Builtins Implementation of Attribute + Declarations @ingroup Attributed_Variables */ @@ -38,13 +39,11 @@ static char SccsId[]="%W% %G%"; #define TermVoidAtt TermFoundVar -static CELL * -AddToQueue(attvar_record *attv USES_REGS) -{ +static CELL *AddToQueue(attvar_record *attv USES_REGS) { Term t[2]; Term WGs, ng; - t[0] = (CELL)&(attv->Done); + t[0] = (CELL) & (attv->Done); t[1] = attv->Value; /* follow the chain */ WGs = Yap_ReadTimedVar(LOCAL_WokenGoals); @@ -55,12 +54,10 @@ AddToQueue(attvar_record *attv USES_REGS) /* from now on, we have to start waking up goals */ Yap_signal(YAP_WAKEUP_SIGNAL); } - return(RepAppl(ng)+2); + return (RepAppl(ng) + 2); } -static void -AddFailToQueue( USES_REGS1 ) -{ +static void AddFailToQueue(USES_REGS1) { Term WGs; /* follow the chain */ @@ -73,14 +70,12 @@ AddFailToQueue( USES_REGS1 ) } } -static attvar_record * -BuildNewAttVar( USES_REGS1 ) -{ +static attvar_record *BuildNewAttVar(USES_REGS1) { attvar_record *newv; /* add a new attributed variable */ newv = (attvar_record *)HR; - HR = (CELL *)(newv+1); + HR = (CELL *)(newv + 1); newv->AttFunc = FunctorAttVar; RESET_VARIABLE(&(newv->Value)); RESET_VARIABLE(&(newv->Done)); @@ -88,19 +83,17 @@ BuildNewAttVar( USES_REGS1 ) return newv; } -static int -CopyAttVar(CELL *orig, struct cp_frame **to_visit_ptr, CELL *res USES_REGS) -{ +static int CopyAttVar(CELL *orig, struct cp_frame **to_visit_ptr, + CELL *res USES_REGS) { register attvar_record *attv = RepAttVar(orig); register attvar_record *newv; struct cp_frame *to_visit = *to_visit_ptr; CELL *vt; - - if (!(newv = BuildNewAttVar( PASS_REGS1 ))) + if (!(newv = BuildNewAttVar(PASS_REGS1))) return FALSE; vt = &(attv->Atts); - to_visit->start_cp = vt-1; + to_visit->start_cp = vt - 1; to_visit->end_cp = vt; if (IsVarTerm(attv->Atts)) { Bind_Global_NonAtt(&newv->Atts, (CELL)HR); @@ -111,44 +104,37 @@ CopyAttVar(CELL *orig, struct cp_frame **to_visit_ptr, CELL *res USES_REGS) } to_visit->oldv = vt[-1]; to_visit->ground = FALSE; - *to_visit_ptr = to_visit+1; - *res = (CELL)&(newv->Done); + *to_visit_ptr = to_visit + 1; + *res = (CELL) & (newv->Done); return TRUE; } -static Term -AttVarToTerm(CELL *orig) -{ +static Term AttVarToTerm(CELL *orig) { attvar_record *attv = RepAttVar(orig); return attv->Atts; } -static int -IsEmptyWakeUp(Term atts) -{ +static int IsEmptyWakeUp(Term atts) { Atom name = NameOfFunctor(FunctorOfTerm(atts)); Atom *pt = EmptyWakeups; int i = 0; while (i < MaxEmptyWakeups) { - if (pt[i++] == name) return TRUE; + if (pt[i++] == name) + return TRUE; } return FALSE; } -void -Yap_MkEmptyWakeUp(Atom mod) -{ +void Yap_MkEmptyWakeUp(Atom mod) { if (MaxEmptyWakeups == MAX_EMPTY_WAKEUPS) - Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "too many modules that do not wake up"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, + "too many modules that do not wake up"); EmptyWakeups[MaxEmptyWakeups++] = mod; } - -static int -TermToAttVar(Term attvar, Term to USES_REGS) -{ - attvar_record *attv = BuildNewAttVar( PASS_REGS1 ); +static int TermToAttVar(Term attvar, Term to USES_REGS) { + attvar_record *attv = BuildNewAttVar(PASS_REGS1); if (!attv) return FALSE; Bind_Global_NonAtt(&attv->Atts, attvar); @@ -156,10 +142,8 @@ TermToAttVar(Term attvar, Term to USES_REGS) return TRUE; } -static void -WakeAttVar(CELL* pt1, CELL reg2 USES_REGS) -{ - +static void WakeAttVar(CELL *pt1, CELL reg2 USES_REGS) { + /* if bound to someone else, follow until we find the last one */ attvar_record *attv = RepAttVar(pt1); CELL *myH = HR; @@ -177,15 +161,15 @@ WakeAttVar(CELL* pt1, CELL reg2 USES_REGS) /* binding two suspended variables, be careful */ if (susp2 >= attv) { - if (!IsVarTerm(susp2->Value) || !IsUnboundVar(&susp2->Value)) { - /* oops, our goal is on the queue to be woken */ - if (!Yap_unify(susp2->Value, (CELL)pt1)) { - AddFailToQueue( PASS_REGS1 ); - } - } - Bind_Global_NonAtt(&(susp2->Value), (CELL)pt1); - AddToQueue(susp2 PASS_REGS); - return; + if (!IsVarTerm(susp2->Value) || !IsUnboundVar(&susp2->Value)) { + /* oops, our goal is on the queue to be woken */ + if (!Yap_unify(susp2->Value, (CELL)pt1)) { + AddFailToQueue(PASS_REGS1); + } + } + Bind_Global_NonAtt(&(susp2->Value), (CELL)pt1); + AddToQueue(susp2 PASS_REGS); + return; } } else { Bind_NonAtt(VarOfTerm(reg2), (CELL)pt1); @@ -200,7 +184,7 @@ WakeAttVar(CELL* pt1, CELL reg2 USES_REGS) if (!IsVarTerm(attv->Value) || !IsUnboundVar(&attv->Value)) { /* oops, our goal is on the queue to be woken */ if (!Yap_unify(attv->Value, reg2)) { - AddFailToQueue( PASS_REGS1 ); + AddFailToQueue(PASS_REGS1); } return; } @@ -215,76 +199,61 @@ WakeAttVar(CELL* pt1, CELL reg2 USES_REGS) Bind_Global_NonAtt(&(attv->Value), reg2); } -void -Yap_WakeUp(CELL *pt0) { +void Yap_WakeUp(CELL *pt0) { CACHE_REGS CELL d0 = *pt0; RESET_VARIABLE(pt0); WakeAttVar(pt0, d0 PASS_REGS); } +static void mark_attvar(CELL *orig) { return; } -static void -mark_attvar(CELL *orig) -{ - return; -} - -static Term -BuildAttTerm(Functor mfun, UInt ar USES_REGS) -{ +static Term BuildAttTerm(Functor mfun, UInt ar USES_REGS) { CELL *h0 = HR; UInt i; - if (HR+(1024+ar) > ASP) { - LOCAL_Error_Size=ar*sizeof(CELL); + if (HR + (1024 + ar) > ASP) { + LOCAL_Error_Size = ar * sizeof(CELL); return 0L; } HR[0] = (CELL)mfun; - RESET_VARIABLE(HR+1); + RESET_VARIABLE(HR + 1); HR += 2; - for (i = 1; i< ar; i++) { + for (i = 1; i < ar; i++) { *HR = TermVoidAtt; HR++; } return AbsAppl(h0); } -static Term -SearchAttsForModule(Term start, Functor mfun) -{ +static Term SearchAttsForModule(Term start, Functor mfun) { do { - if (IsVarTerm(start) || - FunctorOfTerm(start) == mfun) + if (IsVarTerm(start) || FunctorOfTerm(start) == mfun) return start; - start = ArgOfTerm(1,start); + start = ArgOfTerm(1, start); } while (TRUE); } -static Term -SearchAttsForModuleName(Term start, Atom mname) -{ +static Term SearchAttsForModuleName(Term start, Atom mname) { do { - if (IsVarTerm(start) || - NameOfFunctor(FunctorOfTerm(start)) == mname) + if (IsVarTerm(start) || NameOfFunctor(FunctorOfTerm(start)) == mname) return start; - start = ArgOfTerm(1,start); + start = ArgOfTerm(1, start); } while (TRUE); } -static void -AddNewModule(attvar_record *attv, Term t, int new, int do_it USES_REGS) -{ - CELL *newp = RepAppl(t)+2; +static void AddNewModule(attvar_record *attv, Term t, int new, + int do_it USES_REGS) { + CELL *newp = RepAppl(t) + 2; UInt i, ar = ArityOfFunctor((Functor)newp[-2]); - for (i=1; i< ar; i++) { + for (i = 1; i < ar; i++) { Term n = Deref(*newp); if (n == TermFreeTerm) { *newp = TermVoidAtt; } else { if (n != TermVoidAtt) - do_it = TRUE; + do_it = TRUE; } newp++; } @@ -293,46 +262,44 @@ AddNewModule(attvar_record *attv, Term t, int new, int do_it USES_REGS) if (new) { attv->Atts = t; } else if (IsVarTerm(attv->Atts)) { - MaBind(&(attv->Atts),t); + MaBind(&(attv->Atts), t); } else { Term *wherep = &attv->Atts; do { if (IsVarTerm(*wherep)) { - Bind_Global_NonAtt(wherep,t); - return; + Bind_Global_NonAtt(wherep, t); + return; } else { - wherep = RepAppl(Deref(*wherep))+1; + wherep = RepAppl(Deref(*wherep)) + 1; } } while (TRUE); } } -static void -ReplaceAtts(attvar_record *attv, Term oatt, Term att USES_REGS) -{ +static void ReplaceAtts(attvar_record *attv, Term oatt, Term att USES_REGS) { UInt ar = ArityOfFunctor(FunctorOfTerm(oatt)), i; - CELL *oldp = RepAppl(oatt)+1; + CELL *oldp = RepAppl(oatt) + 1; CELL *newp; if (oldp > HB) { oldp++; - newp = RepAppl(att)+2; + newp = RepAppl(att) + 2; /* if deterministic */ - for (i=1; i< ar; i++) { + for (i = 1; i < ar; i++) { Term n = Deref(*newp); if (n != TermFreeTerm) { - *oldp = n; + *oldp = n; } oldp++; newp++; } return; } - newp = RepAppl(att)+1; + newp = RepAppl(att) + 1; *newp++ = *oldp++; - for (i=1; i< ar; i++) { + for (i = 1; i < ar; i++) { Term n = Deref(*newp); if (n == TermFreeTerm) { @@ -351,25 +318,21 @@ ReplaceAtts(attvar_record *attv, Term oatt, Term att USES_REGS) do { if (*wherep == oatt) { - MaBind(wherep, att); - return; + MaBind(wherep, att); + return; } else { - wherep = RepAppl(Deref(*wherep))+1; + wherep = RepAppl(Deref(*wherep)) + 1; } } while (TRUE); } } -static void -DelAllAtts(attvar_record *attv USES_REGS) -{ +static void DelAllAtts(attvar_record *attv USES_REGS) { MaBind(&(attv->Done), attv->Value); } -static void -DelAtts(attvar_record *attv, Term oatt USES_REGS) -{ - Term t = ArgOfTerm(1,oatt); +static void DelAtts(attvar_record *attv, Term oatt USES_REGS) { + Term t = ArgOfTerm(1, oatt); if (attv->Atts == oatt) { if (IsVarTerm(t)) { DelAllAtts(attv PASS_REGS); @@ -384,29 +347,26 @@ DelAtts(attvar_record *attv, Term oatt USES_REGS) do { if (*wherep == oatt) { - MaBind(wherep, t); - return; + MaBind(wherep, t); + return; } else { - wherep = RepAppl(Deref(*wherep))+1; + wherep = RepAppl(Deref(*wherep)) + 1; } } while (TRUE); } } -static void -PutAtt(Int pos, Term atts, Term att USES_REGS) -{ +static void PutAtt(Int pos, Term atts, Term att USES_REGS) { if (IsVarTerm(att) && VarOfTerm(att) > HR && VarOfTerm(att) < LCL0) { /* globalise locals */ Term tnew = MkVarTerm(); Bind_NonAtt(VarOfTerm(att), tnew); att = tnew; } - MaBind(RepAppl(atts)+pos, att); + MaBind(RepAppl(atts) + pos, att); } -static Int -BindAttVar(attvar_record *attv USES_REGS) { +static Int BindAttVar(attvar_record *attv USES_REGS) { if (IsVarTerm(attv->Done) && IsUnboundVar(&attv->Done)) { /* make sure we are not trying to bind a variable against itself */ if (!IsVarTerm(attv->Value)) { @@ -414,42 +374,41 @@ BindAttVar(attvar_record *attv USES_REGS) { } else if (IsVarTerm(attv->Value)) { Term t = Deref(attv->Value); if (IsVarTerm(t)) { - if (IsAttachedTerm(t)) { - attvar_record *attv2 = RepAttVar(VarOfTerm(t)); - if (attv2 < attv) { - Bind_Global_NonAtt(&(attv->Done), t); - } else { - Bind_Global_NonAtt(&(attv2->Done), AbsAttVar(attv)); - } - } else { - Yap_Error(SYSTEM_ERROR_INTERNAL,(CELL)&(attv->Done),"attvar was bound when unset"); - return(FALSE); - } + if (IsAttachedTerm(t)) { + attvar_record *attv2 = RepAttVar(VarOfTerm(t)); + if (attv2 < attv) { + Bind_Global_NonAtt(&(attv->Done), t); + } else { + Bind_Global_NonAtt(&(attv2->Done), AbsAttVar(attv)); + } + } else { + Yap_Error(SYSTEM_ERROR_INTERNAL, (CELL) & (attv->Done), + "attvar was bound when unset"); + return (FALSE); + } } else { - Bind_Global_NonAtt(&(attv->Done), t); + Bind_Global_NonAtt(&(attv->Done), t); } } - return(TRUE); + return (TRUE); } else { - Yap_Error(SYSTEM_ERROR_INTERNAL,(CELL)&(attv->Done),"attvar was bound when set"); - return(FALSE); + Yap_Error(SYSTEM_ERROR_INTERNAL, (CELL) & (attv->Done), + "attvar was bound when set"); + return (FALSE); } } -static Int -UnBindAttVar(attvar_record *attv) { +static Int UnBindAttVar(attvar_record *attv) { RESET_VARIABLE(&(attv->Value)); - return(TRUE); + return (TRUE); } -static Term -GetAllAtts(attvar_record *attv) { +static Term GetAllAtts(attvar_record *attv) { /* check if we are already there */ return attv->Atts; } -static Int -p_put_att( USES_REGS1 ) { +static Int p_put_att(USES_REGS1) { /* receive a variable in ARG1 */ Term inp = Deref(ARG1); /* if this is unbound, ok */ @@ -464,40 +423,40 @@ p_put_att( USES_REGS1 ) { if (IsAttachedTerm(inp)) { attv = RepAttVar(VarOfTerm(inp)); } else { - while (!(attv = BuildNewAttVar( PASS_REGS1 ))) { - LOCAL_Error_Size = sizeof(attvar_record); - if (!Yap_gcl(LOCAL_Error_Size, 5, ENV, gc_P(P,CP))) { - Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); - return FALSE; - } + while (!(attv = BuildNewAttVar(PASS_REGS1))) { + LOCAL_Error_Size = sizeof(attvar_record); + if (!Yap_gcl(LOCAL_Error_Size, 5, ENV, gc_P(P, CP))) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); + return FALSE; + } } new = TRUE; } - mfun= Yap_MkFunctor(modname,ar); - if (IsVarTerm(tatts = SearchAttsForModule(attv->Atts,mfun))) { - while (!(tatts = BuildAttTerm(mfun,ar PASS_REGS))) { - if (!Yap_gcl(LOCAL_Error_Size, 5, ENV, gc_P(P,CP))) { - Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); - return FALSE; - } + mfun = Yap_MkFunctor(modname, ar); + if (IsVarTerm(tatts = SearchAttsForModule(attv->Atts, mfun))) { + while (!(tatts = BuildAttTerm(mfun, ar PASS_REGS))) { + if (!Yap_gcl(LOCAL_Error_Size, 5, ENV, gc_P(P, CP))) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); + return FALSE; + } } { - CELL *ptr = VarOfTerm(Deref(ARG1)); - CELL d0 = AbsAttVar(attv); - Bind_NonAtt(ptr, d0); + CELL *ptr = VarOfTerm(Deref(ARG1)); + CELL d0 = AbsAttVar(attv); + Bind_NonAtt(ptr, d0); } AddNewModule(attv, tatts, new, TRUE PASS_REGS); } PutAtt(IntegerOfTerm(Deref(ARG4)), tatts, Deref(ARG5) PASS_REGS); return TRUE; } else { - Yap_Error(REPRESENTATION_ERROR_VARIABLE,inp,"first argument of put_attributes/2"); + Yap_Error(REPRESENTATION_ERROR_VARIABLE, inp, + "first argument of put_attributes/2"); return FALSE; } } -static Int -p_put_att_term( USES_REGS1 ) { +static Int p_put_att_term(USES_REGS1) { /* receive a variable in ARG1 */ Term inp = Deref(ARG1); /* if this is unbound, ok */ @@ -508,26 +467,26 @@ p_put_att_term( USES_REGS1 ) { attv = RepAttVar(VarOfTerm(inp)); MaBind(&(attv->Atts), Deref(ARG2)); } else { - while (!(attv = BuildNewAttVar( PASS_REGS1 ))) { - LOCAL_Error_Size = sizeof(attvar_record); - if (!Yap_gcl(LOCAL_Error_Size, 5, ENV, gc_P(P,CP))) { - Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); - return FALSE; - } - inp = Deref(ARG1); + while (!(attv = BuildNewAttVar(PASS_REGS1))) { + LOCAL_Error_Size = sizeof(attvar_record); + if (!Yap_gcl(LOCAL_Error_Size, 5, ENV, gc_P(P, CP))) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); + return FALSE; + } + inp = Deref(ARG1); } Bind_NonAtt(VarOfTerm(inp), AbsAttVar(attv)); attv->Atts = Deref(ARG2); } return TRUE; } else { - Yap_Error(REPRESENTATION_ERROR_VARIABLE,inp,"first argument of put_att_term/2"); - return(FALSE); + Yap_Error(REPRESENTATION_ERROR_VARIABLE, inp, + "first argument of put_att_term/2"); + return (FALSE); } } -static Int -p_rm_att( USES_REGS1 ) { +static Int p_rm_att(USES_REGS1) { /* receive a variable in ARG1 */ Term inp = Deref(ARG1); /* if this is unbound, ok */ @@ -542,37 +501,36 @@ p_rm_att( USES_REGS1 ) { if (IsAttachedTerm(inp)) { attv = RepAttVar(VarOfTerm(inp)); } else { - while (!(attv = BuildNewAttVar( PASS_REGS1 ))) { - LOCAL_Error_Size = sizeof(attvar_record); - if (!Yap_gcl(LOCAL_Error_Size, 5, ENV, gc_P(P,CP))) { - Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); - return FALSE; - } + while (!(attv = BuildNewAttVar(PASS_REGS1))) { + LOCAL_Error_Size = sizeof(attvar_record); + if (!Yap_gcl(LOCAL_Error_Size, 5, ENV, gc_P(P, CP))) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); + return FALSE; + } } new = TRUE; Yap_unify(ARG1, AbsAttVar(attv)); } - mfun= Yap_MkFunctor(modname,ar); - if (IsVarTerm(tatts = SearchAttsForModule(attv->Atts,mfun))) { + mfun = Yap_MkFunctor(modname, ar); + if (IsVarTerm(tatts = SearchAttsForModule(attv->Atts, mfun))) { while (!(tatts = BuildAttTerm(mfun, ar PASS_REGS))) { - if (!Yap_gcl(LOCAL_Error_Size, 4, ENV, gc_P(P,CP))) { - Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); - return FALSE; - } + if (!Yap_gcl(LOCAL_Error_Size, 4, ENV, gc_P(P, CP))) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); + return FALSE; + } } - AddNewModule(attv,tatts,new, FALSE PASS_REGS); + AddNewModule(attv, tatts, new, FALSE PASS_REGS); } else { PutAtt(IntegerOfTerm(Deref(ARG4)), tatts, TermVoidAtt PASS_REGS); } return TRUE; } else { - Yap_Error(REPRESENTATION_ERROR_VARIABLE,inp,"first argument of rm_att/2"); - return(FALSE); + Yap_Error(REPRESENTATION_ERROR_VARIABLE, inp, "first argument of rm_att/2"); + return (FALSE); } } -static Int -p_put_atts( USES_REGS1 ) { +static Int p_put_atts(USES_REGS1) { /* receive a variable in ARG1 */ Term inp = Deref(ARG1); @@ -587,39 +545,39 @@ p_put_atts( USES_REGS1 ) { if (IsAttachedTerm(inp)) { attv = RepAttVar(VarOfTerm(inp)); } else { - while (!(attv = BuildNewAttVar( PASS_REGS1 ))) { - LOCAL_Error_Size = sizeof(attvar_record); - if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, gc_P(P,CP))) { - Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); - return FALSE; - } + while (!(attv = BuildNewAttVar(PASS_REGS1))) { + LOCAL_Error_Size = sizeof(attvar_record); + if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, gc_P(P, CP))) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); + return FALSE; + } } new = TRUE; Yap_unify(ARG1, AbsAttVar(attv)); } - /* we may have a stack shift meanwhile!! */ + /* we may have a stack shift meanwhile!! */ tatts = Deref(ARG2); if (IsVarTerm(tatts)) { - Yap_Error(INSTANTIATION_ERROR,tatts,"second argument of put_att/2"); + Yap_Error(INSTANTIATION_ERROR, tatts, "second argument of put_att/2"); return FALSE; } else if (!IsApplTerm(tatts)) { - Yap_Error(TYPE_ERROR_COMPOUND,tatts,"second argument of put_att/2"); + Yap_Error(TYPE_ERROR_COMPOUND, tatts, "second argument of put_att/2"); return FALSE; } - if (IsVarTerm(otatts = SearchAttsForModule(attv->Atts,mfun))) { + if (IsVarTerm(otatts = SearchAttsForModule(attv->Atts, mfun))) { AddNewModule(attv, tatts, new, FALSE PASS_REGS); } else { ReplaceAtts(attv, otatts, tatts PASS_REGS); } return TRUE; } else { - Yap_Error(REPRESENTATION_ERROR_VARIABLE,inp,"first argument of put_att/2"); + Yap_Error(REPRESENTATION_ERROR_VARIABLE, inp, + "first argument of put_att/2"); return FALSE; } } -static Int -p_del_atts( USES_REGS1 ) { +static Int p_del_atts(USES_REGS1) { /* receive a variable in ARG1 */ Term inp = Deref(ARG1); Term otatts; @@ -635,7 +593,7 @@ p_del_atts( USES_REGS1 ) { } else { return TRUE; } - if (IsVarTerm(otatts = SearchAttsForModule(attv->Atts,mfun))) { + if (IsVarTerm(otatts = SearchAttsForModule(attv->Atts, mfun))) { return TRUE; } else { DelAtts(attv, otatts PASS_REGS); @@ -646,23 +604,21 @@ p_del_atts( USES_REGS1 ) { } } -static Int -p_del_all_atts( USES_REGS1 ) { +static Int p_del_all_atts(USES_REGS1) { /* receive a variable in ARG1 */ Term inp = Deref(ARG1); /* if this is unbound, ok */ if (IsVarTerm(inp) && IsAttachedTerm(inp)) { attvar_record *attv; - + attv = RepAttVar(VarOfTerm(inp)); DelAllAtts(attv PASS_REGS); - } + } return TRUE; } -static Int -p_get_att( USES_REGS1 ) { +static Int p_get_att(USES_REGS1) { /* receive a variable in ARG1 */ Term inp = Deref(ARG1); /* if this is unbound, ok */ @@ -674,23 +630,24 @@ p_get_att( USES_REGS1 ) { Term tout, tatts; attv = RepAttVar(VarOfTerm(inp)); - if (IsVarTerm(tatts = SearchAttsForModuleName(attv->Atts,modname))) - return FALSE; - tout = ArgOfTerm(IntegerOfTerm(Deref(ARG3)),tatts); - if (tout == TermVoidAtt) return FALSE; - return Yap_unify(tout, ARG4); + if (IsVarTerm(tatts = SearchAttsForModuleName(attv->Atts, modname))) + return FALSE; + tout = ArgOfTerm(IntegerOfTerm(Deref(ARG3)), tatts); + if (tout == TermVoidAtt) + return FALSE; + return Yap_unify(tout, ARG4); } else { /* Yap_Error(INSTANTIATION_ERROR,inp,"get_att/2"); */ return FALSE; } } else { - Yap_Error(REPRESENTATION_ERROR_VARIABLE,inp,"first argument of get_att/2"); - return(FALSE); + Yap_Error(REPRESENTATION_ERROR_VARIABLE, inp, + "first argument of get_att/2"); + return (FALSE); } } -static Int -p_free_att( USES_REGS1 ) { +static Int p_free_att(USES_REGS1) { /* receive a variable in ARG1 */ Term inp = Deref(ARG1); /* if this is unbound, ok */ @@ -702,22 +659,22 @@ p_free_att( USES_REGS1 ) { Term tout, tatts; attv = RepAttVar(VarOfTerm(inp)); - if (IsVarTerm(tatts = SearchAttsForModuleName(attv->Atts,modname))) - return TRUE; - tout = ArgOfTerm(IntegerOfTerm(Deref(ARG3)),tatts); + if (IsVarTerm(tatts = SearchAttsForModuleName(attv->Atts, modname))) + return TRUE; + tout = ArgOfTerm(IntegerOfTerm(Deref(ARG3)), tatts); return (tout == TermVoidAtt); } else { /* Yap_Error(INSTANTIATION_ERROR,inp,"get_att/2"); */ return TRUE; } } else { - Yap_Error(REPRESENTATION_ERROR_VARIABLE,inp,"first argument of free_att/2"); - return(FALSE); + Yap_Error(REPRESENTATION_ERROR_VARIABLE, inp, + "first argument of free_att/2"); + return (FALSE); } } -static Int -p_get_atts( USES_REGS1 ) { +static Int p_get_atts(USES_REGS1) { /* receive a variable in ARG1 */ Term inp = Deref(ARG1); /* if this is unbound, ok */ @@ -731,20 +688,21 @@ p_get_atts( USES_REGS1 ) { CELL *old, *new; attv = RepAttVar(VarOfTerm(inp)); - if (IsVarTerm(tatts = SearchAttsForModule(attv->Atts,mfun))) - return FALSE; - + if (IsVarTerm(tatts = SearchAttsForModule(attv->Atts, mfun))) + return FALSE; + ar = ArityOfFunctor(mfun); - new = RepAppl(access)+2; - old = RepAppl(tatts)+2; - for (i = 1; i < ar; i++,new++,old++) { - if (*new != TermFreeTerm) { - if (*old == TermVoidAtt && *new != TermVoidAtt) - return FALSE; - if (*new == TermVoidAtt && *old != TermVoidAtt) - return FALSE; - if (!Yap_unify(*new,*old)) return FALSE; - } + new = RepAppl(access) + 2; + old = RepAppl(tatts) + 2; + for (i = 1; i < ar; i++, new ++, old++) { + if (*new != TermFreeTerm) { + if (*old == TermVoidAtt && *new != TermVoidAtt) + return FALSE; + if (*new == TermVoidAtt &&*old != TermVoidAtt) + return FALSE; + if (!Yap_unify(*new, *old)) + return FALSE; + } } return TRUE; } else { @@ -752,12 +710,11 @@ p_get_atts( USES_REGS1 ) { return FALSE; } } else { - return(FALSE); + return (FALSE); } } -static Int -p_has_atts( USES_REGS1 ) { +static Int p_has_atts(USES_REGS1) { /* receive a variable in ARG1 */ Term inp = Deref(ARG1); /* if this is unbound, ok */ @@ -769,72 +726,71 @@ p_has_atts( USES_REGS1 ) { Functor mfun = FunctorOfTerm(access); attv = RepAttVar(VarOfTerm(inp)); - return !IsVarTerm(tatts = SearchAttsForModule(attv->Atts,mfun)); + return !IsVarTerm(tatts = SearchAttsForModule(attv->Atts, mfun)); } else { /* Yap_Error(INSTANTIATION_ERROR,inp,"get_att/2"); */ return FALSE; } } else { - Yap_Error(REPRESENTATION_ERROR_VARIABLE,inp,"first argument of has_atts/2"); - return(FALSE); + Yap_Error(REPRESENTATION_ERROR_VARIABLE, inp, + "first argument of has_atts/2"); + return (FALSE); } } -static Int -p_bind_attvar( USES_REGS1 ) { - /* receive a variable in ARG1 */ - Term inp = Deref(ARG1); - /* if this is unbound, ok */ - if (IsVarTerm(inp)) { - if (IsAttachedTerm(inp)) { - attvar_record *attv = RepAttVar(VarOfTerm(inp)); - return(BindAttVar(attv PASS_REGS)); - } - return(TRUE); - } else { - Yap_Error(REPRESENTATION_ERROR_VARIABLE,inp,"first argument of bind_attvar/2"); - return(FALSE); - } -} - -static Int -p_unbind_attvar( USES_REGS1 ) { - /* receive a variable in ARG1 */ - Term inp = Deref(ARG1); - /* if this is unbound, ok */ - if (IsVarTerm(inp)) { - if (IsAttachedTerm(inp)) { - attvar_record *attv = RepAttVar(VarOfTerm(inp)); - return(UnBindAttVar(attv)); - } - return(TRUE); - } else { - Yap_Error(REPRESENTATION_ERROR_VARIABLE,inp,"first argument of bind_attvar/2"); - return(FALSE); - } -} - -static Int -p_get_all_atts( USES_REGS1 ) { +static Int p_bind_attvar(USES_REGS1) { /* receive a variable in ARG1 */ Term inp = Deref(ARG1); /* if this is unbound, ok */ if (IsVarTerm(inp)) { if (IsAttachedTerm(inp)) { attvar_record *attv = RepAttVar(VarOfTerm(inp)); - return Yap_unify(ARG2,GetAllAtts(attv)); + return (BindAttVar(attv PASS_REGS)); + } + return (true); + } else { + Yap_Error(REPRESENTATION_ERROR_VARIABLE, inp, + "first argument of bind_attvar/2"); + return (false); + } +} + +static Int p_unbind_attvar(USES_REGS1) { + /* receive a variable in ARG1 */ + Term inp = Deref(ARG1); + /* if this is unbound, ok */ + if (IsVarTerm(inp)) { + if (IsAttachedTerm(inp)) { + attvar_record *attv = RepAttVar(VarOfTerm(inp)); + return (UnBindAttVar(attv)); + } + return (TRUE); + } else { + Yap_Error(REPRESENTATION_ERROR_VARIABLE, inp, + "first argument of bind_attvar/2"); + return (FALSE); + } +} + +static Int p_get_all_atts(USES_REGS1) { + /* receive a variable in ARG1 */ + Term inp = Deref(ARG1); + /* if this is unbound, ok */ + if (IsVarTerm(inp)) { + if (IsAttachedTerm(inp)) { + attvar_record *attv = RepAttVar(VarOfTerm(inp)); + return Yap_unify(ARG2, GetAllAtts(attv)); } return TRUE; } else { - Yap_Error(REPRESENTATION_ERROR_VARIABLE,inp,"first argument of get_all_atts/2"); + Yap_Error(REPRESENTATION_ERROR_VARIABLE, inp, + "first argument of get_all_atts/2"); return FALSE; } } -static int -ActiveAtt(Term tatt, UInt ar) -{ - CELL *cp = RepAppl(tatt)+1; +static int ActiveAtt(Term tatt, UInt ar) { + CELL *cp = RepAppl(tatt) + 1; UInt i; for (i = 1; i < ar; i++) { @@ -844,8 +800,7 @@ ActiveAtt(Term tatt, UInt ar) return FALSE; } -static Int -p_modules_with_atts( USES_REGS1 ) { +static Int p_modules_with_atts(USES_REGS1) { /* receive a variable in ARG1 */ Term inp = Deref(ARG1); /* if this is unbound, ok */ @@ -856,31 +811,31 @@ p_modules_with_atts( USES_REGS1 ) { Term tatt; if (IsVarTerm(tatt = attv->Atts)) - return Yap_unify(ARG2,TermNil); + return Yap_unify(ARG2, TermNil); while (!IsVarTerm(tatt)) { - Functor f = FunctorOfTerm(tatt); - if (HR != h0) - HR[-1] = AbsPair(HR); - if (ActiveAtt(tatt, ArityOfFunctor(f))) { - *HR = MkAtomTerm(NameOfFunctor(f)); - HR+=2; - } - tatt = ArgOfTerm(1,tatt); + Functor f = FunctorOfTerm(tatt); + if (HR != h0) + HR[-1] = AbsPair(HR); + if (ActiveAtt(tatt, ArityOfFunctor(f))) { + *HR = MkAtomTerm(NameOfFunctor(f)); + HR += 2; + } + tatt = ArgOfTerm(1, tatt); } if (h0 != HR) { - HR[-1] = TermNil; - return Yap_unify(ARG2,AbsPair(h0)); + HR[-1] = TermNil; + return Yap_unify(ARG2, AbsPair(h0)); } } - return Yap_unify(ARG2,TermNil); + return Yap_unify(ARG2, TermNil); } else { - Yap_Error(REPRESENTATION_ERROR_VARIABLE,inp,"first argument of modules_with_attributes/2"); + Yap_Error(REPRESENTATION_ERROR_VARIABLE, inp, + "first argument of modules_with_attributes/2"); return FALSE; } } -static Int -p_swi_all_atts( USES_REGS1 ) { +static Int p_swi_all_atts(USES_REGS1) { /* receive a variable in ARG1 */ Term inp = Deref(ARG1); Functor attf = FunctorAtt1; @@ -893,77 +848,75 @@ p_swi_all_atts( USES_REGS1 ) { Term tatt; if (IsVarTerm(tatt = attv->Atts)) - return Yap_unify(ARG2,TermNil); + return Yap_unify(ARG2, TermNil); while (!IsVarTerm(tatt)) { - Functor f = FunctorOfTerm(tatt); - UInt ar = ArityOfFunctor(f); + Functor f = FunctorOfTerm(tatt); + UInt ar = ArityOfFunctor(f); - if (HR != h0) - HR[-1] = AbsAppl(HR); - HR[0] = (CELL) attf; - HR[1] = MkAtomTerm(NameOfFunctor(f)); - /* SWI */ - if (ar == 2) - HR[2] = ArgOfTerm(2,tatt); - else - HR[2] = tatt; - HR += 4; - HR[-1] = AbsAppl(HR); - tatt = ArgOfTerm(1,tatt); + if (HR != h0) + HR[-1] = AbsAppl(HR); + HR[0] = (CELL)attf; + HR[1] = MkAtomTerm(NameOfFunctor(f)); + /* SWI */ + if (ar == 2) + HR[2] = ArgOfTerm(2, tatt); + else + HR[2] = tatt; + HR += 4; + HR[-1] = AbsAppl(HR); + tatt = ArgOfTerm(1, tatt); } if (h0 != HR) { - HR[-1] = TermNil; - return Yap_unify(ARG2,AbsAppl(h0)); + HR[-1] = TermNil; + return Yap_unify(ARG2, AbsAppl(h0)); } } - return Yap_unify(ARG2,TermNil); + return Yap_unify(ARG2, TermNil); } else { - Yap_Error(REPRESENTATION_ERROR_VARIABLE,inp,"first argument of get_all_swi_atts/2"); + Yap_Error(REPRESENTATION_ERROR_VARIABLE, inp, + "first argument of get_all_swi_atts/2"); return FALSE; } } - -static Term -AllAttVars( USES_REGS1 ) { +static Term AllAttVars(USES_REGS1) { CELL *pt = H0; CELL *myH = HR; - + while (pt < myH) { - switch(*pt) { - case (CELL)FunctorAttVar: - if (IsUnboundVar(pt+1)) { - if (ASP - myH < 1024) { - LOCAL_Error_Size = (ASP-HR)*sizeof(CELL); - return 0L; - } - if (myH != HR) { - myH[-1] = AbsPair(myH); - } - myH[0] = AbsAttVar((attvar_record *)pt); - myH += 2; + switch (*pt) { + case (CELL) FunctorAttVar: + if (IsUnboundVar(pt + 1)) { + if (ASP - myH < 1024) { + LOCAL_Error_Size = (ASP - HR) * sizeof(CELL); + return 0L; + } + if (myH != HR) { + myH[-1] = AbsPair(myH); + } + myH[0] = AbsAttVar((attvar_record *)pt); + myH += 2; } - pt += (1+ATT_RECORD_ARITY); + pt += (1 + ATT_RECORD_ARITY); break; - case (CELL)FunctorDouble: -#if SIZEOF_DOUBLE == 2*SIZEOF_INT_P + case (CELL) FunctorDouble: +#if SIZEOF_DOUBLE == 2 * SIZEOF_INT_P pt += 4; #else pt += 3; #endif break; - case (CELL)FunctorString: - pt += 3+pt[1]; + case (CELL) FunctorString: + pt += 3 + pt[1]; break; - case (CELL)FunctorBigInt: - { - Int sz = 3 + - (sizeof(MP_INT)+ - (((MP_INT *)(pt+2))->_mp_alloc*sizeof(mp_limb_t)))/sizeof(CELL); - pt += sz; - } - break; - case (CELL)FunctorLongInt: + case (CELL) FunctorBigInt: { + Int sz = 3 + + (sizeof(MP_INT) + + (((MP_INT *)(pt + 2))->_mp_alloc * sizeof(mp_limb_t))) / + sizeof(CELL); + pt += sz; + } break; + case (CELL) FunctorLongInt: pt += 3; break; default: @@ -979,25 +932,23 @@ AllAttVars( USES_REGS1 ) { return TermNil; } } - -static Int -p_all_attvars( USES_REGS1 ) -{ + +static Int p_all_attvars(USES_REGS1) { do { Term out; - if (!(out = AllAttVars( PASS_REGS1 ))) { - if (!Yap_gcl(LOCAL_Error_Size, 1, ENV, gc_P(P,CP))) { - Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); - return FALSE; - } + if (!(out = AllAttVars(PASS_REGS1))) { + if (!Yap_gcl(LOCAL_Error_Size, 1, ENV, gc_P(P, CP))) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); + return FALSE; + } } else { - return Yap_unify(ARG1,out); + return Yap_unify(ARG1, out); } } while (TRUE); } -/** @pred attvar( _-Var_) +/** @pred attvar( _-Var_) Succeed if _Var_ is an attributed variable. @@ -1005,40 +956,23 @@ p_all_attvars( USES_REGS1 ) */ -static Int -p_is_attvar( USES_REGS1 ) -{ +static Int p_is_attvar(USES_REGS1) { Term t = Deref(ARG1); - return(IsVarTerm(t) && - IsAttVar(VarOfTerm(t))); + return (IsVarTerm(t) && IsAttVar(VarOfTerm(t))); } /* check if we are not redoing effort */ -static Int -p_attvar_bound( USES_REGS1 ) -{ +static Int p_attvar_bound(USES_REGS1) { Term t = Deref(ARG1); - return - IsVarTerm(t) && - IsAttachedTerm(t) && - !IsUnboundVar(&(RepAttVar(VarOfTerm(t))->Done)); + return IsVarTerm(t) && IsAttachedTerm(t) && + !IsUnboundVar(&(RepAttVar(VarOfTerm(t))->Done)); } -static Int -p_void_term( USES_REGS1 ) -{ - return Yap_unify(ARG1,TermVoidAtt); -} +static Int p_void_term(USES_REGS1) { return Yap_unify(ARG1, TermVoidAtt); } -static Int -p_free_term( USES_REGS1 ) -{ - return Yap_unify(ARG1,TermFreeTerm); -} +static Int p_free_term(USES_REGS1) { return Yap_unify(ARG1, TermFreeTerm); } -static Int -p_fast_unify( USES_REGS1 ) -{ +static Int p_fast_unify(USES_REGS1) { /* Case we want to unify two variables, but we do not think there is a point in waking them up @@ -1051,38 +985,25 @@ p_fast_unify( USES_REGS1 ) return FALSE; a = VarOfTerm(t1); b = VarOfTerm(t2); - if(a > b) { - Bind_Global_NonAtt(a,t2); - } else if((a) < (b)){ - Bind_Global_NonAtt(b,t1); + if (a > b) { + Bind_Global_NonAtt(a, t2); + } else if ((a) < (b)) { + Bind_Global_NonAtt(b, t1); } return TRUE; } #else -static Int -p_all_attvars( USES_REGS1 ) -{ - return FALSE; -} +static Int p_all_attvars(USES_REGS1) { return FALSE; } -static Int -p_is_attvar( USES_REGS1 ) -{ - return FALSE; -} +static Int p_is_attvar(USES_REGS1) { return FALSE; } -static Int -p_attvar_bound( USES_REGS1 ) -{ - return FALSE; -} +static Int p_attvar_bound(USES_REGS1) { return FALSE; } #endif /* COROUTINING */ -void Yap_InitAttVarPreds(void) -{ +void Yap_InitAttVarPreds(void) { CACHE_REGS Term OldCurrentModule = CurrentModule; CurrentModule = ATTRIBUTES_MODULE; @@ -1106,18 +1027,16 @@ void Yap_InitAttVarPreds(void) Yap_InitCPred("rm_att", 4, p_rm_att, 0); Yap_InitCPred("bind_attvar", 1, p_bind_attvar, SafePredFlag); Yap_InitCPred("unbind_attvar", 1, p_unbind_attvar, SafePredFlag); - Yap_InitCPred("modules_with_attributes", 2, p_modules_with_atts, SafePredFlag); + Yap_InitCPred("modules_with_attributes", 2, p_modules_with_atts, + SafePredFlag); Yap_InitCPred("void_term", 1, p_void_term, SafePredFlag); Yap_InitCPred("free_term", 1, p_free_term, SafePredFlag); Yap_InitCPred("fast_unify_attributed", 2, p_fast_unify, 0); #endif /* COROUTINING */ Yap_InitCPred("all_attvars", 1, p_all_attvars, 0); CurrentModule = OldCurrentModule; - Yap_InitCPred("attvar", 1, p_is_attvar, SafePredFlag|TestPredFlag); - Yap_InitCPred("$att_bound", 1, p_attvar_bound, SafePredFlag|TestPredFlag); + Yap_InitCPred("attvar", 1, p_is_attvar, SafePredFlag | TestPredFlag); + Yap_InitCPred("$att_bound", 1, p_attvar_bound, SafePredFlag | TestPredFlag); } - - /** @} */ - diff --git a/GitSHA1.c b/GitSHA1.c index 4182afe7d..fba88e3c2 100644 --- a/GitSHA1.c +++ b/GitSHA1.c @@ -1,2 +1,2 @@ -#define GIT_SHA1 "fa586f8769671bdf084b01dfe51728a5420a793a" +#define GIT_SHA1 "036876299f12a4761f8d1de2dfba9709d5c91739" const char g_GIT_SHA1[] = GIT_SHA1; diff --git a/misc/analysis/load.yap b/misc/analysis/load.yap index 844fa56f0..10a331bf7 100644 --- a/misc/analysis/load.yap +++ b/misc/analysis/load.yap @@ -213,7 +213,7 @@ system_mod("ARG_MODULE", _, arg, sys ). system_mod("PROLOG_MODULE", _ , prolog, sys ). system_mod("RANGE_MODULE", _, range, user ). system_mod("SWI_MODULE", _, swi, sys ). -system_mod("OPERATING_SYSTEM_MODULE", _, operating_system_support , sys ). +system_mod("OPERATING_SYSTEM_MODULE", _, system , sys ). system_mod("TERMS_MODULE", _, terms , sys). system_mod("SYSTEM_MODULE", _, system, sys ). system_mod("IDB_MODULE", _, idb, user ). diff --git a/os/YapIOConfig.h b/os/YapIOConfig.h deleted file mode 100644 index b1e3b24c5..000000000 --- a/os/YapIOConfig.h +++ /dev/null @@ -1,108 +0,0 @@ -/* Define if you have libreadline */ -#ifndef HAVE_LIBREADLINE -#define HAVE_LIBREADLINE 1 -#endif - -/* Define to 1 if you have the header file. */ -#ifndef HAVE_READLINE_HISTORY_H -#define HAVE_READLINE_HISTORY_H 1 -#endif - -/* Define to 1 if you have the header file. */ -#ifndef HAVE_READLINE_READLINE_H -#define HAVE_READLINE_READLINE_H 1 -#endif - -/* Define to 1 if you have the declaration of `rl_catch_signals ', and to 0 if -you don't. */ -#ifndef HAVE_DECL_RL_CATCH_SIGNALS_ -/* #undef HAVE_DECL_RL_CATCH_SIGNALS */ -#endif - -/* Define to 1 if you have the declaration of `rl_done ', and to 0 if you -don't. */ -#ifndef HAVE_DECL_RL_DONE_ -/* #undef HAVE_DECL_RL_DONE_ */ -#endif - -/* Define to 1 if you have the declaration of `rl_event_hook', and to 0 if you -don't. */ -#ifndef HAVE_DECL_RL_EVENT_HOOK -/* #undef HAVE_DECL_RL_EVENT_HOOK */ -#endif - -/* Define to 1 if you have the declaration of `rl_readline_state', and to 0 if -you don't. */ -#ifndef HAVE_DECL_RL_READLINE_STATE -/* #undef HAVE_DECL_RL_READLINE_STATE */ -#endif - -/* Define to 1 if you have the `rl_begin_undo_group' function. */ -#ifndef HAVE_RL_BEGIN_UNDO_GROUP -#define HAVE_RL_BEGIN_UNDO_GROUP 1 -#endif - -/* Define to 1 if you have the `rl_clear_pending_input' function. */ -#ifndef HAVE_RL_CLEAR_PENDING_INPUT -#define HAVE_RL_CLEAR_PENDING_INPUT 1 -#endif - -/* Define to 1 if the system has the type `rl_completion_func_t'). */ -#ifndef HAVE_RL_COMPLETION_FUNC_T -/* #undef HAVE_RL_COMPLETION_FUNC_T */ -#endif - -/* Define to 1 if the system has the type `rl_completion_func_t'. */ -#ifndef HAVE_RL_COMPLETION_FUNC_T -/* #undef HAVE_RL_COMPLETION_FUNC_T */ -#endif - -/* Define to 1 if you have the `rl_completion_matches' function. */ -#ifndef HAVE_RL_COMPLETION_MATCHES -/* #undef HAVE_RL_COMPLETION_MATCHES */ -#endif - -/* Define to 1 if you have the `rl_discard_argument' function. */ -#ifndef HAVE_RL_DISCARD_ARGUMENT -#define HAVE_RL_DISCARD_ARGUMENT 1 -#endif - -/* Define to 1 if you have the `rl_done' variable. */ -#ifndef HAVE_RL_DONE -#define HAVE_RL_DONE -#endif - -/* Define to 1 if you have the `rl_filename_completion_function' function. */ -#ifndef HAVE_RL_FILENAME_COMPLETION_FUNCTION -#define HAVE_RL_FILENAME_COMPLETION_FUNCTION 1 -#endif - -/* Define to 1 if you have the `rl_free_line_state' function. */ -#ifndef HAVE_RL_FREE_LINE_STATE -#define HAVE_RL_FREE_LINE_STATE 1 -#endif - -/* Define to 1 if the system has the type `rl_hook_func_t'. */ -#ifndef HAVE_RL_HOOK_FUNC_T -/* #undef HAVE_RL_HOOK_FUNC_T */ -#endif - -/* Define to 1 if you have the `rl_insert_close' function. */ -#ifndef HAVE_RL_INSERT_CLOSE -#define HAVE_RL_INSERT_CLOSE 1 -#endif - -/* Define to 1 if you have the `rl_reset_after_signal' function. */ -#ifndef HAVE_RL_RESET_AFTER_SIGNAL -#define HAVE_RL_RESET_AFTER_SIGNAL 1 -#endif - -/* Define to 1 if you have the `rl_set_keyboard_input_timeout' function. */ -#ifndef HAVE_RL_SET_KEYBOARD_INPUT_TIMEOUT -#define HAVE_RL_SET_KEYBOARD_INPUT_TIMEOUT 1 -#endif - -/* Define to 1 if you have the `rl_set_prompt' function. */ -#ifndef HAVE_RL_SET_PROMPT -#define HAVE_RL_SET_PROMPT 1 -#endif diff --git a/os/stream_wget_to_utf8 b/os/stream_wget_to_utf8 deleted file mode 100644 index 064af1eeb..000000000 --- a/os/stream_wget_to_utf8 +++ /dev/null @@ -1,264 +0,0 @@ -alias.c:271: LOCAL_NOfFileAliases--; -alias.c:373: LOCAL_NOfFileAliases--; -charsio.c:760: ocharcount = s->charcount; -charsio.c:761: olinecount = s->linecount; -charsio.c:762: olinepos = s->linepos; -charsio.c:764: s->charcount = ocharcount; -charsio.c:765: s->linecount = olinecount; -charsio.c:766: s->linepos = olinepos; -charsio.c:768: s->och = ch; -charsio.c:770: s->stream_getc = PlUnGetc; -charsio.c:771: s->stream_wgetc = get_wchar; -charsio.c:772: s->stream_gets = DefaultGets; -charsio.c:774: s->stream_wgetc_for_read = ISOWGetc; -charsio.c:776: s->stream_wgetc_for_read = s->stream_wgetc; -charsio.c:777: if (s->encoding == ENC_ISO_UTF8) -charsio.c:778: s->stream_getc_for_utf8 = s->stream_getc; -charsio.c:780: s->stream_getc_for_utf8 = GetUTF8; -chartypes.c:113: { "Windows-1252", ENC_ISO_LATIN1 }, // almost, but not quite -console.c:66: ++s->linecount; -console.c:67: ++s->charcount; -console.c:68: s->linepos = 0; -console.c:72: ++s->charcount; -console.c:73: ++s->linepos; -console.c:107: s->stream_putc = ConsolePutc; -console.c:111: s->stream_getc = ConsoleGetc; -console.c:123: putc ('\n', s->file); -console.c:127: putc (ch, s->file); -console.c:160: ch = fgetc(s->file); -format.c:106: while (fg->padders--) { -format.c:601: repeats--; -format.c:605: repeats--; -format.c:782: while (repeats--) { -iopreds.c:175: if (s->status & InMemory_Stream_f) { -iopreds.c:176: s->status |= Seekable_Stream_f; -iopreds.c:183: _isatty(_fileno(s->u.file.file)) -iopreds.c:185: s->status |= Tty_Stream_f|Reset_Eof_Stream_f|Promptable_Stream_f; -iopreds.c:187: setvbuf(s->u.file.file, NULL, _IONBF, 0); -iopreds.c:192: else if (StdErrStream == s-Stream) { -iopreds.c:193: setvbuf(s->u.file.file, NULL, _IONBF, 0); -iopreds.c:196: s->status |= Seekable_Stream_f; -iopreds.c:204: if (s-Stream < 3) { -iopreds.c:205: s->name = AtomTty; -iopreds.c:206: s->status |= Tty_Stream_f|Reset_Eof_Stream_f|Promptable_Stream_f; -iopreds.c:211: if (!s->file) { -iopreds.c:212: s->name = AtomNil; -iopreds.c:215: filedes = fileno (s->file); -iopreds.c:220: s->name = AtomTty; -iopreds.c:222: s->name = AtomTtys; -iopreds.c:224: s->name = AtomTty; -iopreds.c:226: s->status |= Tty_Stream_f|Reset_Eof_Stream_f|Promptable_Stream_f; -iopreds.c:233: s->status |= Seekable_Stream_f; -iopreds.c:248: s->stream_gets = PlGetsFunc(); -iopreds.c:249: if (s->status & Socket_Stream_f) { -iopreds.c:252: s->stream_wputc = put_wchar; -iopreds.c:253: } else if (s->status & Pipe_Stream_f) { -iopreds.c:256: s->stream_wputc = put_wchar; -iopreds.c:257: } else if (s->status & InMemory_Stream_f) { -iopreds.c:259: s->stream_wputc = put_wchar; -iopreds.c:262: if (s->status & (Promptable_Stream_f)) { -iopreds.c:266: s->stream_putc = FilePutc; -iopreds.c:267: s->stream_wputc = put_wchar; -iopreds.c:268: s->stream_getc = PlGetc; -iopreds.c:269: s->stream_gets = PlGetsFunc(); -iopreds.c:272: s->stream_wputc = put_wchar; -iopreds.c:273: s->stream_wgetc = get_wchar; -iopreds.c:282: s->file = file; -iopreds.c:283: s->status = flags; -iopreds.c:284: s->linepos = 0; -iopreds.c:285: s->linecount = 1; -iopreds.c:286: s->charcount = 0.; -iopreds.c:287: s->encoding = ENC_ISO_UTF8; -iopreds.c:288: INIT_LOCK(s->streamlock); -iopreds.c:296: s->name=AtomUserIn; -iopreds.c:299: s->name=AtomUserOut; -iopreds.c:302: s->name=AtomUserErr; -iopreds.c:305: s->user_name = MkAtomTerm (s->name); -iopreds.c:307: s->stream_wgetc_for_read = ISOWGetc; -iopreds.c:309: s->stream_wgetc_for_read = s->stream_wgetc; -iopreds.c:310: if (s->encoding == ENC_ISO_UTF8) -iopreds.c:311: s->stream_getc_for_utf8 = s->stream_getc; -iopreds.c:313: s->stream_getc_for_utf8 = GetUTF8; -iopreds.c:315: s->status |= Tty_Stream_f|Promptable_Stream_f; -iopreds.c:318: if (s->status & Tty_Stream_f && -iopreds.c:333: if (s->user_name != 0L) { -iopreds.c:334: return (s->user_name); -iopreds.c:507: putc(ch, s->file); -iopreds.c:511: fflush(s->file); -iopreds.c:534: if (s->status & Eof_Error_Stream_f) { -iopreds.c:535: Yap_Error(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM,MkAtomTerm(s->name), -iopreds.c:538: } else if (s->status & Reset_Eof_Stream_f) { -iopreds.c:540: if (feof (s->file)) -iopreds.c:541: clearerr (s->file); -iopreds.c:544: if (s->status & Socket_Stream_f) { -iopreds.c:545: if (s->status & Promptable_Stream_f) -iopreds.c:549: s->stream_wputc = put_wchar; -iopreds.c:552: if (s->status & Pipe_Stream_f) { -iopreds.c:553: if (s->status & Promptable_Stream_f) -iopreds.c:557: } else if (s->status & InMemory_Stream_f) { -iopreds.c:559: } else if (s->status & Promptable_Stream_f) { -iopreds.c:562: s->stream_getc = PlGetc; -iopreds.c:563: s->stream_gets = PlGetsFunc(); -iopreds.c:565: s->stream_wgetc = get_wchar; -iopreds.c:566: s->stream_wputc = put_wchar; -iopreds.c:568: s->stream_wgetc_for_read = ISOWGetc; -iopreds.c:570: s->stream_wgetc_for_read = s->stream_wgetc; -iopreds.c:571: if (s->encoding == ENC_ISO_UTF8) -iopreds.c:572: s->stream_getc_for_utf8 = s->stream_getc; -iopreds.c:574: s->stream_getc_for_utf8 = GetUTF8; -iopreds.c:576: s->status &= ~Eof_Stream_f; -iopreds.c:580: s->status |= Past_Eof_Stream_f; -iopreds.c:591: if (s->status & Push_Eof_Stream_f) { -iopreds.c:593: s->status &= ~Push_Eof_Stream_f; -iopreds.c:597: return(s->stream_getc(sno)); -iopreds.c:607: s->stream_getc = EOFGetc; -iopreds.c:608: s->stream_wgetc = get_wchar; -iopreds.c:610: s->stream_wgetc_for_read = ISOWGetc; -iopreds.c:612: s->stream_wgetc_for_read = s->stream_wgetc; -iopreds.c:613: if (s->encoding == ENC_ISO_UTF8) -iopreds.c:614: s->stream_getc_for_utf8 = s->stream_getc; -iopreds.c:616: s->stream_getc_for_utf8 = GetUTF8; -iopreds.c:625: ++s->charcount; -iopreds.c:626: ++s->linepos; -iopreds.c:628: ++s->linecount; -iopreds.c:629: s->linepos = 0; -iopreds.c:631: if (!(s->status & Binary_Stream_f)) -iopreds.c:641: s->status |= Eof_Stream_f; -iopreds.c:642: s->stream_getc = EOFGetc; -iopreds.c:643: s->stream_wgetc = get_wchar; -iopreds.c:645: s->stream_wgetc_for_read = ISOWGetc; -iopreds.c:647: s->stream_wgetc_for_read = s->stream_wgetc; -iopreds.c:648: if (s->encoding == ENC_ISO_UTF8) -iopreds.c:649: s->stream_getc_for_utf8 = s->stream_getc; -iopreds.c:651: s->stream_getc_for_utf8 = GetUTF8; -iopreds.c:664: ch = getc (s->file); -iopreds.c:680: if (fgets (buf, size, s->file) == NULL) { -iopreds.c:684: s->charcount += len-1; -iopreds.c:702: while((ch = *buf++ = s->stream_getc(sno)) != -iopreds.c:712: uint64_t bufi = s->utf8_buf; -iopreds.c:735: if (s->stream_getc != PlUnGetc) -iopreds.c:736: return(s->stream_getc(sno)); -iopreds.c:737: ch = s->och; -iopreds.c:738: if (s->status & InMemory_Stream_f) { -iopreds.c:740: s->stream_wputc = put_wchar; -iopreds.c:741: } else if (s->status & Socket_Stream_f) { -iopreds.c:743: s->stream_wputc = put_wchar; -iopreds.c:744: } else if (s->status & Promptable_Stream_f) { -iopreds.c:746: s->stream_wputc = put_wchar; -iopreds.c:748: s->stream_getc = PlGetc; -iopreds.c:749: s->stream_gets = PlGetsFunc(); -iopreds.c:761: if (s->stream_getc != PlUnGetc376) -iopreds.c:762: return(s->stream_getc(sno)); -iopreds.c:763: s->stream_getc = PlUnGetc; -iopreds.c:764: ch = s->och; -iopreds.c:765: s->och = 0xFE; -iopreds.c:776: if (s->stream_getc != PlUnGetc00) -iopreds.c:777: return(s->stream_getc(sno)); -iopreds.c:778: s->stream_getc = PlUnGetc; -iopreds.c:779: ch = s->och; -iopreds.c:780: s->och = 0x00; -iopreds.c:791: if (s->stream_getc != PlUnGetc377) -iopreds.c:792: return(s->stream_getc(sno)); -iopreds.c:793: s->stream_getc = PlUnGetc; -iopreds.c:794: ch = s->och; -iopreds.c:795: s->och = 0xFF; -iopreds.c:806: if (s->stream_getc != PlUnGetc357) -iopreds.c:807: return(s->stream_getc(sno)); -iopreds.c:808: s->stream_getc = PlUnGetc; -iopreds.c:809: ch = s->och; -iopreds.c:810: s->och = 0xEF; -iopreds.c:821: if (s->stream_getc != PlUnGetc357273) -iopreds.c:822: return(s->stream_getc(sno)); -iopreds.c:823: s->stream_getc = PlUnGetc357; -iopreds.c:824: ch = s->och; -iopreds.c:825: s->och = 0xBB; -iopreds.c:836: if (s->stream_getc != PlUnGetc0000) -iopreds.c:837: return(s->stream_getc(sno)); -iopreds.c:838: s->stream_getc = PlUnGetc00; -iopreds.c:839: ch = s->och; -iopreds.c:840: s->och = 0x00; -iopreds.c:851: if (s->stream_getc != PlUnGetc0000fe) -iopreds.c:852: return(s->stream_getc(sno)); -iopreds.c:853: s->stream_getc = PlUnGetc0000; -iopreds.c:854: ch = s->och; -iopreds.c:855: s->och = 0xfe; -iopreds.c:866: if (s->stream_getc != PlUnGetc377376) -iopreds.c:867: return(s->stream_getc(sno)); -iopreds.c:868: s->stream_getc = PlUnGetc377; -iopreds.c:869: ch = s->och; -iopreds.c:870: s->och = 0xFE; -iopreds.c:881: if (s->stream_getc != PlUnGetc37737600) -iopreds.c:882: return(s->stream_getc(sno)); -iopreds.c:883: s->stream_getc = PlUnGetc377376; -iopreds.c:884: ch = s->och; -iopreds.c:885: s->och = 0x00; -iopreds.c:1830: s->status |= Promptable_Stream_f; -iopreds.c:1832: if (s->status & Socket_Stream_f) { -iopreds.c:1836: if (s->status & Pipe_Stream_f) { -mem.c:78: spos = s->u.mem_string.pos; -mem.c:79: if (spos == s->u.mem_string.max_size) { -mem.c:82: ch = s->u.mem_string.buf[spos]; -mem.c:83: s->u.mem_string.pos = ++spos; -mem.c:103: s->u.mem_string.buf[s->u.mem_string.pos++] = ch; -mem.c:104: if (s->u.mem_string.pos >= s->u.mem_string.max_size -8) { -mem.c:105: int old_src = s->u.mem_string.src, new_src; -mem.c:108: Int new_max_size = s->u.mem_string.max_size + Yap_page_size; -mem.c:115: memmove((void *)newbuf, (void *)s->u.mem_string.buf, (size_t)((s->u.mem_string.pos)*sizeof(char))); -mem.c:118: Int n = s->u.mem_string.pos; -mem.c:120: char *from = s->u.mem_string.buf; -mem.c:126: Yap_FreeAtomSpace(s->u.mem_string.buf); -mem.c:128: } else if ((newbuf = (ADDR)realloc(s->u.mem_string.buf, new_max_size*sizeof(char))) != NULL) { -mem.c:144: s->u.mem_string.buf = newbuf; -mem.c:145: s->u.mem_string.max_size = new_max_size; -mem.c:146: s->u.mem_string.src = new_src; -pipes.c:72: if (WriteFile(s->u.pipe.hdl, &c, sizeof(c), &written, NULL) == FALSE) { -pipes.c:81: out = write(s->u.pipe.fd, &c, sizeof(c)); -pipes.c:110: if (WriteFile(s->u.pipe.hdl, &c, sizeof(c), &written, NULL) == FALSE) { -pipes.c:119: out = write(s->u.pipe.fd, &c, sizeof(c)); -pipes.c:163: if (ReadFile(s->u.pipe.hdl, &c, sizeof(c), &count, NULL) == FALSE) { -pipes.c:172: count = read(s->u.pipe.fd, &c, sizeof(char)); -pipes.c:197: if (ReadFile(s->u.pipe.hdl, &c, sizeof(c), &count, NULL) == FALSE) { -pipes.c:203: count = read(s->u.pipe.fd, &c, sizeof(char)); -readline.c:163: if (s->status & Tty_Stream_f) { -readline.c:164: s->stream_getc = ReadlineGetc; -readline.c:166: s->name == GLOBAL_Stream[0].name) -readline.c:167: s->stream_putc = ReadlinePutc; -readline.c:176: if (s->status & Tty_Stream_f) { -readline.c:178: is_same_tty(s->file,GLOBAL_Stream[0].file)) -readline.c:179: s->stream_putc = ReadlinePutc; -readline.c:180: s->stream_getc = ReadlineGetc; -readline.c:247: if (!(s->status & Tty_Stream_f)) -readline.c:280: s->u.irl.ptr = s->u.irl.buf = myrl_line; -readline.c:291: putc ('\n', s->file); -readline.c:295: putc (ch, s->file); -readline.c:314: bool fetch = (s->u.irl.buf == NULL); -readline.c:317: const char *ttyptr = s->u.irl.ptr++, *myrl_line = s->u.irl.buf; -readline.c:322: s->u.irl.ptr = s->u.irl.buf = NULL; -readline.c:336: const char *myrl_line = s->u.irl.buf; -sockets.c:77: s->file == NULL) -sockets.c:79: s->status |= Socket_Stream_f; -sockets.c:80: s->u.socket.domain = af_inet; -sockets.c:81: s->u.socket.flags = client_socket; -sockets.c:82: s->u.socket.fd = 0; -sockets.c:100: count = recv(s->u.socket.fd, &c, sizeof(char), 0); -sockets.c:102: count = read(s->u.socket.fd, &c, sizeof(char)); -sockets.c:105: s->u.socket.flags = closed_socket; -sockets.c:148: count = recv(s->u.socket.fd, (void *)&c, sizeof(char), 0); -sockets.c:150: count = read(s->u.socket.fd, &c, sizeof(char)); -sockets.c:177: send(s->u.socket.fd, &c, sizeof(c), 0); -sockets.c:179: if (write(s->u.socket.fd, &c, sizeof(c)) < 0) { -sockets.c:203: send(s->u.socket.fd, &c, sizeof(c), 0); -sockets.c:208: out = write(s->u.socket.fd, &c, sizeof(c)); -streams.c:164: s->status |= User_Stream_f|Input_Stream_f; -streams.c:165: s->charcount = 0; -streams.c:166: s->linecount = 1; -streams.c:167: s->linepos = 0; -streams.c:168: s->stream_wgetc = get_wchar; -streams.c:169: s->stream_wputc = put_wchar; -streams.c:170: s->encoding = LOCAL_encoding; -streams.c:172: s->stream_wgetc_for_read = ISOWGetc; -streams.c:174: s->stream_wgetc_for_read = s->stream_wgetc; -streams.c:175: if (s->encoding == ENC_ISO_UTF8) -streams.c:176: s->stream_getc_for_utf8 = s->stream_getc; -streams.c:178: s->stream_getc_for_utf8 = GetUTF8; -streams.c:179: UNLOCK(s->streamlock); diff --git a/packages/ProbLog/problog_examples/output/out.dat b/packages/ProbLog/problog_examples/output/out.dat deleted file mode 100644 index a7a2da4e7..000000000 --- a/packages/ProbLog/problog_examples/output/out.dat +++ /dev/null @@ -1,26 +0,0 @@ -##################################################################### -# Pos Type Name -##################################################################### -# 1 int iteration -# 2 time duration -# 3 float llh_training_set -# 4 float llh_test_set -# 5 time bdd_evaluation -# 6 float ground_truth_diff -# 7 float ground_truth_mindiff -# 8 float ground_truth_maxdiff -# 9 time train_bdd_script_generation -# 10 time train_bdd_script_generation_grounding -# 11 time train_bdd_script_generation_completion -# 12 time train_bdd_script_generation_propagation -# 13 time train_bdd_script_generation_splitting -# 14 int train_bdd_script_generation_active_ground_atoms -# 15 int train_bdd_script_generation_propagated_ground_atoms -# 16 time test_bdd_script_generation -# 17 time test_bdd_script_generation_grounding -# 18 time test_bdd_script_generation_completion -# 19 time test_bdd_script_generation_propagation -# 20 time test_bdd_script_generation_splitting -# 21 int test_bdd_script_generation_active_ground_atoms -# 22 int test_bdd_script_generation_propagated_ground_atoms -##################################################################### diff --git a/pl/arithpreds.yap b/pl/arithpreds.yap index 9f95e0f1f..26f5ec9d4 100644 --- a/pl/arithpreds.yap +++ b/pl/arithpreds.yap @@ -32,6 +32,15 @@ :- use_system_module( '$_errors', ['$do_error'/2]). +a :- + a, + b, + z, + za. + + + + /** @pred succ(? _Int1_:int, ? _Int2_:int) is det *