Merge branch 'master' of ssh://git.dcc.fc.up.pt/yap-6.3
31
.gitignore
vendored
@ -24,7 +24,6 @@ tmtags*
|
|||||||
.zedstate
|
.zedstate
|
||||||
config.h
|
config.h
|
||||||
Yap.h
|
Yap.h
|
||||||
*Makefile
|
|
||||||
YapConfig.h
|
YapConfig.h
|
||||||
YapTermConfig.h
|
YapTermConfig.h
|
||||||
.graffiti
|
.graffiti
|
||||||
@ -48,7 +47,6 @@ groups
|
|||||||
.Rhistory
|
.Rhistory
|
||||||
.zedstate
|
.zedstate
|
||||||
.graffiti
|
.graffiti
|
||||||
*Makefile
|
|
||||||
.kateproject
|
.kateproject
|
||||||
autom4te.cache
|
autom4te.cache
|
||||||
*rej
|
*rej
|
||||||
@ -61,7 +59,6 @@ JIT/HPP/bkp
|
|||||||
cmake_install.cmake
|
cmake_install.cmake
|
||||||
cmake_clean.cmake
|
cmake_clean.cmake
|
||||||
*.build
|
*.build
|
||||||
Makefile
|
|
||||||
C/myabsmi.c
|
C/myabsmi.c
|
||||||
*.ctags#
|
*.ctags#
|
||||||
*.hs
|
*.hs
|
||||||
@ -78,6 +75,7 @@ yap
|
|||||||
*cmake_files
|
*cmake_files
|
||||||
C/pl-yap.c
|
C/pl-yap.c
|
||||||
GitSHA1.c
|
GitSHA1.c
|
||||||
|
.vscode
|
||||||
CMakeLists.txt.*
|
CMakeLists.txt.*
|
||||||
FindPackageLog.txt
|
FindPackageLog.txt
|
||||||
GitSHA1.c
|
GitSHA1.c
|
||||||
@ -112,10 +110,29 @@ packages/real/rconfig.h
|
|||||||
|
|
||||||
packages/ProbLog/problog/#completion.yap#
|
packages/ProbLog/problog/#completion.yap#
|
||||||
|
|
||||||
packages/ProbLog/problog_examples/output/out.dat
|
packages/ProbLog/problog_examples/output
|
||||||
|
packages/ProbLog/problog_examples/queries
|
||||||
|
packages/swig/java/*.java
|
||||||
|
packages/swig/java/*.class
|
||||||
|
packages/swig/java/*.jar
|
||||||
|
packages/swig/java/*wrap*
|
||||||
|
*jnilib
|
||||||
|
*.jar
|
||||||
|
|
||||||
packages/ProbLog/problog_examples/output/,_query_1_cluster_1.dot
|
packages/cplint/approx/simplecuddLPADs/LPADBDD
|
||||||
|
|
||||||
packages/ProbLog/problog_examples/output/out.dat
|
packages/swi-minisat2/˜:ilp
|
||||||
|
|
||||||
packages/ProbLog/problog_examples/output/,_query_1_cluster_1
|
packages/cplint/L
|
||||||
|
|
||||||
|
packages/CLPBN/horus/hcli
|
||||||
|
|
||||||
|
packages/bdd/simplecudd/problogbdd
|
||||||
|
|
||||||
|
packages/bdd/cudd_config.h
|
||||||
|
Makefile
|
||||||
|
build
|
||||||
|
Debug
|
||||||
|
debug
|
||||||
|
Release
|
||||||
|
Build
|
@ -2512,7 +2512,7 @@ break_debug(contador);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Yap_plwrite ((Term) beam_X[1], NULL, 0, 1200);
|
Yap_plwrite ((Term) beam_X[1], NULL, 0, GLOBAL_MaxPriority);
|
||||||
#else
|
#else
|
||||||
extern int beam_write (void);
|
extern int beam_write (void);
|
||||||
beam_write();
|
beam_write();
|
||||||
|
@ -742,10 +742,10 @@ void ShowCode_new2(int op, int new1,CELL new4)
|
|||||||
switch (ch = *f++)
|
switch (ch = *f++)
|
||||||
{
|
{
|
||||||
case '1':
|
case '1':
|
||||||
Yap_plwrite(MkIntTerm(new1), NULL, 30, 0, 1200);
|
Yap_plwrite(MkIntTerm(new1), NULL, 30, 0, GLOBAL_MaxPriority);
|
||||||
break;
|
break;
|
||||||
case '4':
|
case '4':
|
||||||
Yap_plwrite(MkIntTerm(new4), NULL, 20, 0, 1200);
|
Yap_plwrite(MkIntTerm(new4), NULL, 20, 0, GLOBAL_MaxPriority);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Yap_DebugPutc (LOCAL_c_error_stream,'%');
|
Yap_DebugPutc (LOCAL_c_error_stream,'%');
|
||||||
|
@ -1109,7 +1109,7 @@ interrupt_deallocate( USES_REGS1 )
|
|||||||
}
|
}
|
||||||
return interrupt_handler( pe PASS_REGS );
|
return interrupt_handler( pe PASS_REGS );
|
||||||
}
|
}
|
||||||
if (!Yap_locked_gc(0, ENV, CP)) {
|
if (!Yap_locked_gc(0, ENV, YESCODE)) {
|
||||||
Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage);
|
Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage);
|
||||||
}
|
}
|
||||||
S = ASP;
|
S = ASP;
|
||||||
|
77
C/adtdefs.c
@ -28,12 +28,42 @@ static char SccsId[] = "%W% %G%";
|
|||||||
#include "Yap.h"
|
#include "Yap.h"
|
||||||
#include "Yatom.h"
|
#include "Yatom.h"
|
||||||
#include "yapio.h"
|
#include "yapio.h"
|
||||||
|
#include "clause.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#if HAVE_STRING_H
|
#if HAVE_STRING_Hq
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
uint64_t HashFunction(const unsigned char *CHP) {
|
||||||
|
/* djb2 */
|
||||||
|
uint64_t hash = 5381;
|
||||||
|
uint64_t c;
|
||||||
|
|
||||||
|
while ((c = (uint64_t)(*CHP++)) != '\0') {
|
||||||
|
/* hash = ((hash << 5) + hash) + c; hash * 33 + c */
|
||||||
|
hash = hash * (uint64_t)33 + c;
|
||||||
|
}
|
||||||
|
return hash;
|
||||||
|
/*
|
||||||
|
UInt OUT=0, i = 1;
|
||||||
|
while(*CHP != '\0') { OUT += (UInt)(*CHP++); }
|
||||||
|
return OUT;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t WideHashFunction(wchar_t *CHP) {
|
||||||
|
UInt hash = 5381;
|
||||||
|
|
||||||
|
UInt c;
|
||||||
|
|
||||||
|
while ((c = *CHP++) != '\0') {
|
||||||
|
hash = hash * 33 ^ c;
|
||||||
|
}
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* this routine must be run at least having a read lock on ae */
|
/* this routine must be run at least having a read lock on ae */
|
||||||
static Prop
|
static Prop
|
||||||
GetFunctorProp(AtomEntry *ae,
|
GetFunctorProp(AtomEntry *ae,
|
||||||
@ -142,14 +172,17 @@ static inline Atom SearchWideAtom(const wchar_t *p, Atom a) {
|
|||||||
|
|
||||||
static Atom
|
static Atom
|
||||||
LookupAtom(const unsigned char *atom) { /* lookup atom in atom table */
|
LookupAtom(const unsigned char *atom) { /* lookup atom in atom table */
|
||||||
UInt hash;
|
uint64_t hash;
|
||||||
const unsigned char *p;
|
const unsigned char *p;
|
||||||
Atom a, na;
|
Atom a, na;
|
||||||
AtomEntry *ae;
|
AtomEntry *ae;
|
||||||
|
size_t sz = AtomHashTableSize;
|
||||||
|
|
||||||
/* compute hash */
|
/* compute hash */
|
||||||
p = atom;
|
p = atom;
|
||||||
hash = HashFunction(p) % AtomHashTableSize;
|
|
||||||
|
hash = HashFunction(p);
|
||||||
|
hash = hash % sz ;
|
||||||
|
|
||||||
/* we'll start by holding a read lock in order to avoid contention */
|
/* we'll start by holding a read lock in order to avoid contention */
|
||||||
READ_LOCK(HashChain[hash].AERWLock);
|
READ_LOCK(HashChain[hash].AERWLock);
|
||||||
@ -754,29 +787,24 @@ static int ExpandPredHash(void) {
|
|||||||
|
|
||||||
/* fe is supposed to be locked */
|
/* fe is supposed to be locked */
|
||||||
Prop Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod) {
|
Prop Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod) {
|
||||||
CACHE_REGS
|
|
||||||
PredEntry *p = (PredEntry *)Yap_AllocAtomSpace(sizeof(*p));
|
PredEntry *p = (PredEntry *)Yap_AllocAtomSpace(sizeof(*p));
|
||||||
|
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
WRITE_UNLOCK(fe->FRWLock);
|
WRITE_UNLOCK(fe->FRWLock);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (cur_mod == TermProlog)
|
if (cur_mod == TermProlog || cur_mod == 0L) {
|
||||||
p->ModuleOfPred = 0L;
|
p->ModuleOfPred = 0L;
|
||||||
else
|
} else
|
||||||
p->ModuleOfPred = cur_mod;
|
p->ModuleOfPred = cur_mod;
|
||||||
// TRUE_FUNC_WRITE_LOCK(fe);
|
// TRUE_FUNC_WRITE_LOCK(fe);
|
||||||
#if DEBUG_NEW_FUNCTOR
|
|
||||||
if (!strcmp(fe->NameOfFE->StrOfAE, "library_directory"))
|
|
||||||
jmp_deb(1);
|
|
||||||
#endif
|
|
||||||
INIT_LOCK(p->PELock);
|
INIT_LOCK(p->PELock);
|
||||||
p->KindOfPE = PEProp;
|
p->KindOfPE = PEProp;
|
||||||
p->ArityOfPE = fe->ArityOfFE;
|
p->ArityOfPE = fe->ArityOfFE;
|
||||||
p->cs.p_code.FirstClause = p->cs.p_code.LastClause = NULL;
|
p->cs.p_code.FirstClause = p->cs.p_code.LastClause = NULL;
|
||||||
p->cs.p_code.NOfClauses = 0;
|
p->cs.p_code.NOfClauses = 0;
|
||||||
p->PredFlags = 0L;
|
p->PredFlags = 0L;
|
||||||
p->src.OwnerFile = LOCAL_SourceFileName;
|
p->src.OwnerFile = Yap_source_file_name();
|
||||||
p->OpcodeOfPred = UNDEF_OPCODE;
|
p->OpcodeOfPred = UNDEF_OPCODE;
|
||||||
p->CodeOfPred = p->cs.p_code.TrueCodeOfPred = (yamop *)(&(p->OpcodeOfPred));
|
p->CodeOfPred = p->cs.p_code.TrueCodeOfPred = (yamop *)(&(p->OpcodeOfPred));
|
||||||
p->cs.p_code.ExpandCode = EXPAND_OP_CODE;
|
p->cs.p_code.ExpandCode = EXPAND_OP_CODE;
|
||||||
@ -795,12 +823,6 @@ Prop Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod) {
|
|||||||
p->beamTable = NULL;
|
p->beamTable = NULL;
|
||||||
#endif /* BEAM */
|
#endif /* BEAM */
|
||||||
/* careful that they don't cross MkFunctor */
|
/* careful that they don't cross MkFunctor */
|
||||||
if (PRED_GOAL_EXPANSION_FUNC) {
|
|
||||||
if (fe->PropsOfFE &&
|
|
||||||
(RepPredProp(fe->PropsOfFE)->PredFlags & GoalExPredFlag)) {
|
|
||||||
p->PredFlags |= GoalExPredFlag;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!trueGlobalPrologFlag(DEBUG_INFO_FLAG)) {
|
if (!trueGlobalPrologFlag(DEBUG_INFO_FLAG)) {
|
||||||
p->PredFlags |= NoTracePredFlag;
|
p->PredFlags |= NoTracePredFlag;
|
||||||
}
|
}
|
||||||
@ -904,7 +926,7 @@ Prop Yap_NewThreadPred(PredEntry *ap USES_REGS) {
|
|||||||
Prop Yap_NewPredPropByAtom(AtomEntry *ae, Term cur_mod) {
|
Prop Yap_NewPredPropByAtom(AtomEntry *ae, Term cur_mod) {
|
||||||
Prop p0;
|
Prop p0;
|
||||||
PredEntry *p = (PredEntry *)Yap_AllocAtomSpace(sizeof(*p));
|
PredEntry *p = (PredEntry *)Yap_AllocAtomSpace(sizeof(*p));
|
||||||
|
CACHE_REGS
|
||||||
/* Printf("entering %s:%s/0\n", RepAtom(AtomOfTerm(cur_mod))->StrOfAE,
|
/* Printf("entering %s:%s/0\n", RepAtom(AtomOfTerm(cur_mod))->StrOfAE,
|
||||||
* ae->StrOfAE); */
|
* ae->StrOfAE); */
|
||||||
|
|
||||||
@ -918,7 +940,7 @@ Prop Yap_NewPredPropByAtom(AtomEntry *ae, Term cur_mod) {
|
|||||||
p->cs.p_code.FirstClause = p->cs.p_code.LastClause = NULL;
|
p->cs.p_code.FirstClause = p->cs.p_code.LastClause = NULL;
|
||||||
p->cs.p_code.NOfClauses = 0;
|
p->cs.p_code.NOfClauses = 0;
|
||||||
p->PredFlags = 0L;
|
p->PredFlags = 0L;
|
||||||
p->src.OwnerFile = AtomNil;
|
p->src.OwnerFile = Yap_source_file_name();
|
||||||
p->OpcodeOfPred = UNDEF_OPCODE;
|
p->OpcodeOfPred = UNDEF_OPCODE;
|
||||||
p->cs.p_code.ExpandCode = EXPAND_OP_CODE;
|
p->cs.p_code.ExpandCode = EXPAND_OP_CODE;
|
||||||
p->CodeOfPred = p->cs.p_code.TrueCodeOfPred = (yamop *)(&(p->OpcodeOfPred));
|
p->CodeOfPred = p->cs.p_code.TrueCodeOfPred = (yamop *)(&(p->OpcodeOfPred));
|
||||||
@ -936,27 +958,14 @@ Prop Yap_NewPredPropByAtom(AtomEntry *ae, Term cur_mod) {
|
|||||||
p->beamTable = NULL;
|
p->beamTable = NULL;
|
||||||
#endif
|
#endif
|
||||||
/* careful that they don't cross MkFunctor */
|
/* careful that they don't cross MkFunctor */
|
||||||
if (PRED_GOAL_EXPANSION_FUNC) {
|
|
||||||
Prop p1 = ae->PropsOfAE;
|
|
||||||
|
|
||||||
while (p1) {
|
|
||||||
PredEntry *pe = RepPredProp(p1);
|
|
||||||
|
|
||||||
if (pe->KindOfPE == PEProp) {
|
|
||||||
if (pe->PredFlags & GoalExPredFlag) {
|
|
||||||
p->PredFlags |= GoalExPredFlag;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
p1 = pe->NextOfPE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AddPropToAtom(ae, (PropEntry *)p);
|
AddPropToAtom(ae, (PropEntry *)p);
|
||||||
p0 = AbsPredProp(p);
|
p0 = AbsPredProp(p);
|
||||||
p->FunctorOfPred = (Functor)AbsAtom(ae);
|
p->FunctorOfPred = (Functor)AbsAtom(ae);
|
||||||
if (!trueGlobalPrologFlag(DEBUG_INFO_FLAG)) {
|
if (!trueGlobalPrologFlag(DEBUG_INFO_FLAG)) {
|
||||||
p->PredFlags |= (NoTracePredFlag | NoSpyPredFlag);
|
p->PredFlags |= (NoTracePredFlag | NoSpyPredFlag);
|
||||||
}
|
}
|
||||||
|
if (Yap_isSystemModule(CurrentModule))
|
||||||
|
p->PredFlags |= StandardPredFlag;
|
||||||
WRITE_UNLOCK(ae->ARWLock);
|
WRITE_UNLOCK(ae->ARWLock);
|
||||||
{
|
{
|
||||||
Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred) + 1, p,
|
Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred) + 1, p,
|
||||||
|
@ -3875,7 +3875,7 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
|
|||||||
cl->ClSize = osize;
|
cl->ClSize = osize;
|
||||||
cip->code_addr = (yamop *)cl;
|
cip->code_addr = (yamop *)cl;
|
||||||
} else if (mode == ASSEMBLING_CLAUSE &&
|
} else if (mode == ASSEMBLING_CLAUSE &&
|
||||||
(ap->PredFlags & SourcePredFlag ||
|
(ap->PredFlags & (SourcePredFlag|MultiFileFlag) ||
|
||||||
trueGlobalPrologFlag(SOURCE_FLAG ) ) &&
|
trueGlobalPrologFlag(SOURCE_FLAG ) ) &&
|
||||||
!is_fact) {
|
!is_fact) {
|
||||||
DBTerm *x;
|
DBTerm *x;
|
||||||
@ -3911,8 +3911,10 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
|
|||||||
((LogUpdClause *)(cip->code_addr))->ClSize = size;
|
((LogUpdClause *)(cip->code_addr))->ClSize = size;
|
||||||
Yap_LUClauseSpace += size;
|
Yap_LUClauseSpace += size;
|
||||||
} else {
|
} else {
|
||||||
((StaticClause *)(cip->code_addr))->ClSize = size;
|
StaticClause *cl = ((StaticClause *)(cip->code_addr));
|
||||||
((StaticClause *)(cip->code_addr))->ClFlags = 0;
|
cl->usc.ClSource = NULL;
|
||||||
|
cl->ClSize = size;
|
||||||
|
cl->ClFlags = 0;
|
||||||
Yap_ClauseSpace += size;
|
Yap_ClauseSpace += size;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
39
C/atomic.c
@ -65,9 +65,9 @@ static Int number_codes( USES_REGS1 );
|
|||||||
static Int current_atom( USES_REGS1 );
|
static Int current_atom( USES_REGS1 );
|
||||||
static Int cont_current_atom( USES_REGS1 );
|
static Int cont_current_atom( USES_REGS1 );
|
||||||
static int AlreadyHidden(unsigned char *);
|
static int AlreadyHidden(unsigned char *);
|
||||||
static Int hide( USES_REGS1 );
|
static Int hide_atom( USES_REGS1 );
|
||||||
static Int hidden( USES_REGS1 );
|
static Int hidden_atom( USES_REGS1 );
|
||||||
static Int unhide( USES_REGS1 );
|
static Int unhide_atom( USES_REGS1 );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ AlreadyHidden(unsigned char *name)
|
|||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @pred hide(+ _Atom_)
|
/** @pred hide_atom(+ _Atom_)
|
||||||
Make atom _Atom_ invisible.
|
Make atom _Atom_ invisible.
|
||||||
|
|
||||||
Notice that defining a new atom with the same characters will
|
Notice that defining a new atom with the same characters will
|
||||||
@ -94,17 +94,17 @@ AlreadyHidden(unsigned char *name)
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
static Int
|
static Int
|
||||||
hide( USES_REGS1 )
|
hide_atom( USES_REGS1 )
|
||||||
{ /* hide(+Atom) */
|
{ /* hide(+Atom) */
|
||||||
Atom atomToInclude;
|
Atom atomToInclude;
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
|
|
||||||
if (IsVarTerm(t1)) {
|
if (IsVarTerm(t1)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR,t1,"hide/1");
|
Yap_Error(INSTANTIATION_ERROR,t1,"hide_atom/1");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
if (!IsAtomTerm(t1)) {
|
if (!IsAtomTerm(t1)) {
|
||||||
Yap_Error(TYPE_ERROR_ATOM,t1,"hide/1");
|
Yap_Error(TYPE_ERROR_ATOM,t1,"hide_atom/1");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
atomToInclude = AtomOfTerm(t1);
|
atomToInclude = AtomOfTerm(t1);
|
||||||
@ -123,13 +123,13 @@ hide( USES_REGS1 )
|
|||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @pred hidden( +Atom )
|
/** @pred hidden_atom( +Atom )
|
||||||
Is the atom _Ãtom_ visible to Prolog?
|
Is the atom _Ãtom_ visible to Prolog?
|
||||||
|
|
||||||
**/
|
**/
|
||||||
static Int
|
static Int
|
||||||
hidden( USES_REGS1 )
|
hidden_atom( USES_REGS1 )
|
||||||
{ /* '$hidden'(+F) */
|
{ /* '$hidden_atom'(+F) */
|
||||||
Atom at;
|
Atom at;
|
||||||
AtomEntry *chain;
|
AtomEntry *chain;
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
@ -153,30 +153,30 @@ hidden( USES_REGS1 )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** @pred unhide(+ _Atom_)
|
/** @pred unhide_atom(+ _Atom_)
|
||||||
Make hidden atom _Atom_ visible
|
Make hidden atom _Atom_ visible
|
||||||
|
|
||||||
Note that the operation fails if another atom with name _Atom_ was defined since.
|
Note that the operation fails if another atom with name _Atom_ was defined since.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
static Int
|
static Int
|
||||||
unhide( USES_REGS1 )
|
unhide_atom( USES_REGS1 )
|
||||||
{ /* unhide(+Atom) */
|
{ /* unhide_atom(+Atom) */
|
||||||
AtomEntry *atom, *old, *chain;
|
AtomEntry *atom, *old, *chain;
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
|
|
||||||
if (IsVarTerm(t1)) {
|
if (IsVarTerm(t1)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR,t1,"unhide/1");
|
Yap_Error(INSTANTIATION_ERROR,t1,"unhide_atom/1");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
if (!IsAtomTerm(t1)) {
|
if (!IsAtomTerm(t1)) {
|
||||||
Yap_Error(TYPE_ERROR_ATOM,t1,"unhide/1");
|
Yap_Error(TYPE_ERROR_ATOM,t1,"unhide_atom/1");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
atom = RepAtom(AtomOfTerm(t1));
|
atom = RepAtom(AtomOfTerm(t1));
|
||||||
WRITE_LOCK(atom->ARWLock);
|
WRITE_LOCK(atom->ARWLock);
|
||||||
if (atom->PropsOfAE != NIL) {
|
if (atom->PropsOfAE != NIL) {
|
||||||
Yap_Error(SYSTEM_ERROR_INTERNAL,t1,"cannot unhide an atom in use");
|
Yap_Error(SYSTEM_ERROR_INTERNAL,t1,"cannot unhide_atom an atom in use");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
WRITE_LOCK(INVISIBLECHAIN.AERWLock);
|
WRITE_LOCK(INVISIBLECHAIN.AERWLock);
|
||||||
@ -1154,6 +1154,7 @@ atomic_concat2( USES_REGS1 )
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
Atom at;
|
Atom at;
|
||||||
|
|
||||||
|
if (n == 1) return Yap_unify(ARG2, HeadOfTerm(t1));
|
||||||
if (!inpv) {
|
if (!inpv) {
|
||||||
LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP;
|
LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP;
|
||||||
free(inpv);
|
free(inpv);
|
||||||
@ -2405,9 +2406,9 @@ atoms or numbers.
|
|||||||
Yap_InitCPred("atomics_to_string", 3, atomics_to_string3, 0);
|
Yap_InitCPred("atomics_to_string", 3, atomics_to_string3, 0);
|
||||||
Yap_InitCPred("get_string_code", 3, get_string_code3, 0);
|
Yap_InitCPred("get_string_code", 3, get_string_code3, 0);
|
||||||
/* hiding and unhiding some predicates */
|
/* hiding and unhiding some predicates */
|
||||||
Yap_InitCPred("hide", 1, hide, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("hide_atom", 1, hide_atom, SafePredFlag|SyncPredFlag);
|
||||||
Yap_InitCPred("unhide", 1, unhide, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("unhide_atom", 1, unhide_atom, SafePredFlag|SyncPredFlag);
|
||||||
Yap_InitCPred("$hidden", 1, hidden, HiddenPredFlag|SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("$hidden_atom", 1, hidden_atom, HiddenPredFlag|SafePredFlag|SyncPredFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -806,7 +806,7 @@ X_API Term YAP_MkPairTerm(Term t1, Term t2) {
|
|||||||
BACKUP_H();
|
BACKUP_H();
|
||||||
t1 = Yap_GetFromSlot(sl1);
|
t1 = Yap_GetFromSlot(sl1);
|
||||||
t2 = Yap_GetFromSlot(sl2);
|
t2 = Yap_GetFromSlot(sl2);
|
||||||
Yap_RecoverSlots(2, sl2 PASS_REGS);
|
Yap_RecoverSlots(2, sl2);
|
||||||
}
|
}
|
||||||
t = MkPairTerm(t1, t2);
|
t = MkPairTerm(t1, t2);
|
||||||
RECOVER_H();
|
RECOVER_H();
|
||||||
@ -828,7 +828,7 @@ X_API Term YAP_MkListFromTerms(Term *ta, Int sz) {
|
|||||||
}
|
}
|
||||||
BACKUP_H();
|
BACKUP_H();
|
||||||
ta = (CELL *)Yap_GetFromSlot(sl1);
|
ta = (CELL *)Yap_GetFromSlot(sl1);
|
||||||
Yap_RecoverSlots(1, sl1 PASS_REGS);
|
Yap_RecoverSlots(1, sl1);
|
||||||
}
|
}
|
||||||
h = HR;
|
h = HR;
|
||||||
t = AbsPair(h);
|
t = AbsPair(h);
|
||||||
@ -1063,7 +1063,7 @@ X_API Int YAP_TermHash(Term t, Int sz, Int depth, int variant) {
|
|||||||
|
|
||||||
X_API Int YAP_CurrentSlot(void) {
|
X_API Int YAP_CurrentSlot(void) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
return Yap_CurrentSlot(PASS_REGS1);
|
return Yap_CurrentSlot();
|
||||||
}
|
}
|
||||||
|
|
||||||
X_API Int YAP_NewSlots(int n) {
|
X_API Int YAP_NewSlots(int n) {
|
||||||
@ -1078,7 +1078,7 @@ X_API Int YAP_InitSlot(Term t) {
|
|||||||
|
|
||||||
X_API int YAP_RecoverSlots(int n, Int top_slot) {
|
X_API int YAP_RecoverSlots(int n, Int top_slot) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
return Yap_RecoverSlots(n, top_slot PASS_REGS);
|
return Yap_RecoverSlots(n, top_slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
X_API Term YAP_GetFromSlot(Int slot) {
|
X_API Term YAP_GetFromSlot(Int slot) {
|
||||||
@ -1109,7 +1109,7 @@ restart:
|
|||||||
|
|
||||||
X_API void YAP_PutInSlot(Int slot, Term t) {
|
X_API void YAP_PutInSlot(Int slot, Term t) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
Yap_PutInSlot(slot, t PASS_REGS);
|
Yap_PutInSlot(slot, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef Int (*CPredicate0)(void);
|
typedef Int (*CPredicate0)(void);
|
||||||
@ -1723,7 +1723,7 @@ X_API Term YAP_ReadBuffer(const char *s, Term *tp) {
|
|||||||
BACKUP_H();
|
BACKUP_H();
|
||||||
|
|
||||||
LOCAL_ErrorMessage = NULL;
|
LOCAL_ErrorMessage = NULL;
|
||||||
while (!(t = Yap_StringToTerm(s, strlen(s) + 1, &LOCAL_encoding, 1200, tp))) {
|
while (!(t = Yap_StringToTerm(s, strlen(s) + 1, &LOCAL_encoding, GLOBAL_MaxPriority, tp))) {
|
||||||
if (LOCAL_ErrorMessage) {
|
if (LOCAL_ErrorMessage) {
|
||||||
if (!strcmp(LOCAL_ErrorMessage, "Stack Overflow")) {
|
if (!strcmp(LOCAL_ErrorMessage, "Stack Overflow")) {
|
||||||
if (!Yap_dogc(0, NULL PASS_REGS)) {
|
if (!Yap_dogc(0, NULL PASS_REGS)) {
|
||||||
@ -2394,6 +2394,7 @@ X_API void YAP_ClearExceptions(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
X_API int YAP_InitConsult(int mode, const char *filename, int *osnop) {
|
X_API int YAP_InitConsult(int mode, const char *filename, int *osnop) {
|
||||||
|
CACHE_REGS
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int sno;
|
int sno;
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
@ -2403,7 +2404,7 @@ X_API int YAP_InitConsult(int mode, const char *filename, int *osnop) {
|
|||||||
}
|
}
|
||||||
bool consulted = (mode == YAP_CONSULT_MODE);
|
bool consulted = (mode == YAP_CONSULT_MODE);
|
||||||
Yap_init_consult(consulted, filename);
|
Yap_init_consult(consulted, filename);
|
||||||
f = fopen(filename, "r");
|
f = fopen(Yap_AbsoluteFile(filename, LOCAL_FileNameBuf, FILENAME_MAX-1), "r");
|
||||||
if (!f)
|
if (!f)
|
||||||
return -1;
|
return -1;
|
||||||
sno = Yap_OpenStream(f, NULL, TermNil, Input_Stream_f);
|
sno = Yap_OpenStream(f, NULL, TermNil, Input_Stream_f);
|
||||||
@ -2467,7 +2468,7 @@ X_API void YAP_Write(Term t, FILE *f, int flags) {
|
|||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
int sno = Yap_OpenStream(f, NULL, TermNil, Output_Stream_f);
|
int sno = Yap_OpenStream(f, NULL, TermNil, Output_Stream_f);
|
||||||
|
|
||||||
Yap_plwrite(t, GLOBAL_Stream + sno, 0, flags, 1200);
|
Yap_plwrite(t, GLOBAL_Stream + sno, 0, flags, GLOBAL_MaxPriority);
|
||||||
Yap_ReleaseStream(sno);
|
Yap_ReleaseStream(sno);
|
||||||
|
|
||||||
RECOVER_MACHINE_REGS();
|
RECOVER_MACHINE_REGS();
|
||||||
@ -2717,7 +2718,7 @@ X_API Int YAP_Init(YAP_init_args *yap_init) {
|
|||||||
setBooleanGlobalPrologFlag(HALT_AFTER_CONSULT_FLAG,
|
setBooleanGlobalPrologFlag(HALT_AFTER_CONSULT_FLAG,
|
||||||
yap_init->HaltAfterConsult);
|
yap_init->HaltAfterConsult);
|
||||||
}
|
}
|
||||||
/* tell the system who should cope with interrupts */
|
/* tell the scystem who should cope with interrupts */
|
||||||
Yap_ExecutionMode = yap_init->ExecutionMode;
|
Yap_ExecutionMode = yap_init->ExecutionMode;
|
||||||
if (do_bootstrap) {
|
if (do_bootstrap) {
|
||||||
restore_result = YAP_BOOT_FROM_PROLOG;
|
restore_result = YAP_BOOT_FROM_PROLOG;
|
||||||
@ -3326,7 +3327,6 @@ X_API int YAP_FileNoFromStream(Term t) {
|
|||||||
if (IsVarTerm(t))
|
if (IsVarTerm(t))
|
||||||
return -1;
|
return -1;
|
||||||
return Yap_StreamToFileNo(t);
|
return Yap_StreamToFileNo(t);
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
X_API void *YAP_FileDescriptorFromStream(Term t) {
|
X_API void *YAP_FileDescriptorFromStream(Term t) {
|
||||||
@ -3335,7 +3335,6 @@ X_API void *YAP_FileDescriptorFromStream(Term t) {
|
|||||||
if (IsVarTerm(t))
|
if (IsVarTerm(t))
|
||||||
return NULL;
|
return NULL;
|
||||||
return Yap_FileDescriptorFromStream(t);
|
return Yap_FileDescriptorFromStream(t);
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
X_API void *YAP_Record(Term t) {
|
X_API void *YAP_Record(Term t) {
|
||||||
@ -3588,7 +3587,6 @@ Term YAP_BPROLOG_curr_toam_status;
|
|||||||
* @return a positive number with the size, or 0.
|
* @return a positive number with the size, or 0.
|
||||||
*/
|
*/
|
||||||
size_t YAP_UTF8_TextLength(Term t) {
|
size_t YAP_UTF8_TextLength(Term t) {
|
||||||
Term *aux;
|
|
||||||
utf8proc_uint8_t dst[8];
|
utf8proc_uint8_t dst[8];
|
||||||
size_t sz = 0;
|
size_t sz = 0;
|
||||||
|
|
||||||
@ -3652,7 +3650,7 @@ Term YAP_UnNumberVars(Term t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int YAP_IsNumberedVariable(Term t) {
|
int YAP_IsNumberedVariable(Term t) {
|
||||||
return IsApplTerm(t) && FunctorOfTerm(t) == FunctorVar &&
|
return IsApplTerm(t) && FunctorOfTerm(t) == FunctorDollarVar &&
|
||||||
IsIntegerTerm(ArgOfTerm(1, t));
|
IsIntegerTerm(ArgOfTerm(1, t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
17
C/cmppreds.c
@ -556,13 +556,28 @@ p_compare( USES_REGS1 )
|
|||||||
{ /* compare(?Op,?T1,?T2) */
|
{ /* compare(?Op,?T1,?T2) */
|
||||||
Int r = compare(Deref(ARG2), Deref(ARG3));
|
Int r = compare(Deref(ARG2), Deref(ARG3));
|
||||||
Atom p;
|
Atom p;
|
||||||
|
Term t = Deref(ARG1);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
p = AtomLT;
|
p = AtomLT;
|
||||||
else if (r > 0)
|
else if (r > 0)
|
||||||
p = AtomGT;
|
p = AtomGT;
|
||||||
else
|
else
|
||||||
p = AtomEQ;
|
p = AtomEQ;
|
||||||
|
if (!IsVarTerm(t)) {
|
||||||
|
if (IsAtomTerm(t)) {
|
||||||
|
Atom a = AtomOfTerm(t);
|
||||||
|
if (a == p)
|
||||||
|
return true;
|
||||||
|
if (a != AtomLT &&
|
||||||
|
a != AtomGT &&
|
||||||
|
a != AtomEq)
|
||||||
|
Yap_Error(DOMAIN_ERROR_ORDER, ARG1, NULL);
|
||||||
|
} else {
|
||||||
|
Yap_Error(TYPE_ERROR_ATOM, ARG1, NULL);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return Yap_unify_constant(ARG1, MkAtomTerm(p));
|
return Yap_unify_constant(ARG1, MkAtomTerm(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,6 +426,10 @@
|
|||||||
Op(deallocate, p);
|
Op(deallocate, p);
|
||||||
CACHE_Y_AS_ENV(YREG);
|
CACHE_Y_AS_ENV(YREG);
|
||||||
check_trail(TR);
|
check_trail(TR);
|
||||||
|
#ifndef NO_CHECKING
|
||||||
|
/* check stacks */
|
||||||
|
check_stack(NoStackDeallocate, HR);
|
||||||
|
#endif
|
||||||
PREG = NEXTOP(PREG, p);
|
PREG = NEXTOP(PREG, p);
|
||||||
/* other instructions do depend on S being set by deallocate
|
/* other instructions do depend on S being set by deallocate
|
||||||
:-( */
|
:-( */
|
||||||
@ -452,24 +456,23 @@
|
|||||||
ENV_YREG = (CELL *) ((CELL) ENV_YREG + ENV_Size(CPREG));
|
ENV_YREG = (CELL *) ((CELL) ENV_YREG + ENV_Size(CPREG));
|
||||||
#endif /* FROZEN_STACKS */
|
#endif /* FROZEN_STACKS */
|
||||||
WRITEBACK_Y_AS_ENV();
|
WRITEBACK_Y_AS_ENV();
|
||||||
#ifndef NO_CHECKING
|
|
||||||
/* check stacks */
|
|
||||||
check_stack(NoStackDeallocate, HR);
|
|
||||||
#endif
|
|
||||||
ENDCACHE_Y_AS_ENV();
|
ENDCACHE_Y_AS_ENV();
|
||||||
GONext();
|
GONext();
|
||||||
|
|
||||||
NoStackDeallocate:
|
NoStackDeallocate:
|
||||||
BEGD(d0);
|
BEGD(d0);
|
||||||
#ifdef SHADOW_S
|
#ifdef SHADOW_S
|
||||||
Yap_REGS.S_ = SREG;
|
Yap_REGS.S_ = YREG;
|
||||||
#endif
|
#endif
|
||||||
|
PREG = NEXTOP(PREG,p);
|
||||||
saveregs();
|
saveregs();
|
||||||
d0 = interrupt_deallocate( PASS_REGS1 );
|
d0 = interrupt_deallocate( PASS_REGS1 );
|
||||||
setregs();
|
setregs();
|
||||||
|
PREG = PREVOP(PREG,p);
|
||||||
#ifdef SHADOW_S
|
#ifdef SHADOW_S
|
||||||
SREG = Yap_REGS.S_;
|
SREG = Yap_REGS.S_;
|
||||||
#endif
|
#endif
|
||||||
|
// return to original deallocate
|
||||||
if (!d0) FAIL();
|
if (!d0) FAIL();
|
||||||
JMPNext();
|
JMPNext();
|
||||||
ENDD(d0);
|
ENDD(d0);
|
||||||
|
27
C/dbase.c
@ -5106,6 +5106,7 @@ static Int p_dequeue(USES_REGS1) {
|
|||||||
db_queue *father_key;
|
db_queue *father_key;
|
||||||
QueueEntry *cur_instance;
|
QueueEntry *cur_instance;
|
||||||
Term Father = Deref(ARG1);
|
Term Father = Deref(ARG1);
|
||||||
|
Int rc;
|
||||||
|
|
||||||
if (IsVarTerm(Father)) {
|
if (IsVarTerm(Father)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, Father, "dequeue");
|
Yap_Error(INSTANTIATION_ERROR, Father, "dequeue");
|
||||||
@ -5120,16 +5121,11 @@ static Int p_dequeue(USES_REGS1) {
|
|||||||
/* an empty queue automatically goes away */
|
/* an empty queue automatically goes away */
|
||||||
WRITE_UNLOCK(father_key->QRWLock);
|
WRITE_UNLOCK(father_key->QRWLock);
|
||||||
FreeDBSpace((char *)father_key);
|
FreeDBSpace((char *)father_key);
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
if (!Yap_dequeue_tqueue(father_key, ARG2, true, true PASS_REGS))
|
rc = Yap_dequeue_tqueue(father_key, ARG2, true, true PASS_REGS);
|
||||||
return FALSE;
|
|
||||||
if (cur_instance == father_key->LastInQueue)
|
|
||||||
father_key->FirstInQueue = father_key->LastInQueue = NULL;
|
|
||||||
else
|
|
||||||
father_key->FirstInQueue = cur_instance->next;
|
|
||||||
WRITE_UNLOCK(father_key->QRWLock);
|
WRITE_UNLOCK(father_key->QRWLock);
|
||||||
return TRUE;
|
return rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5151,13 +5147,7 @@ static Int p_dequeue_unlocked(USES_REGS1) {
|
|||||||
FreeDBSpace((char *)father_key);
|
FreeDBSpace((char *)father_key);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!Yap_dequeue_tqueue(father_key, ARG2, true, true PASS_REGS))
|
return Yap_dequeue_tqueue(father_key, ARG2, true, true PASS_REGS);
|
||||||
return FALSE;
|
|
||||||
if (cur_instance == father_key->LastInQueue)
|
|
||||||
father_key->FirstInQueue = father_key->LastInQueue = NULL;
|
|
||||||
else
|
|
||||||
father_key->FirstInQueue = cur_instance->next;
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5206,9 +5196,6 @@ static Int p_slu(USES_REGS1) {
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check current status for logical updates */
|
|
||||||
static Int p_lu(USES_REGS1) { return Yap_unify(ARG1, MkIntTerm(UPDATE_MODE)); }
|
|
||||||
|
|
||||||
/* get a hold over the index table for logical update predicates */
|
/* get a hold over the index table for logical update predicates */
|
||||||
static Int p_hold_index(USES_REGS1) {
|
static Int p_hold_index(USES_REGS1) {
|
||||||
Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "hold_index in debugger");
|
Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "hold_index in debugger");
|
||||||
@ -5320,7 +5307,7 @@ static Int p_install_thread_local(USES_REGS1) { /* '$is_dynamic'(+P) */
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Yap_InitDBPreds(void) {
|
void Yap_InitDBPreds(void) {
|
||||||
Yap_InitCPred("recorded", 3, p_recorded, SyncPredFlag);
|
Yap_InitCPred("$set_pred_flags", 2, p_rcdz, SyncPredFlag);
|
||||||
/** @pred recorded(+ _K_, _T_, _R_)
|
/** @pred recorded(+ _K_, _T_, _R_)
|
||||||
|
|
||||||
|
|
||||||
@ -5336,6 +5323,7 @@ void Yap_InitDBPreds(void) {
|
|||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
Yap_InitCPred("recorded", 3, p_recorded, SyncPredFlag);
|
||||||
Yap_InitCPred("recorda", 3, p_rcda, SyncPredFlag);
|
Yap_InitCPred("recorda", 3, p_rcda, SyncPredFlag);
|
||||||
/** @pred recorda(+ _K_, _T_,- _R_)
|
/** @pred recorda(+ _K_, _T_,- _R_)
|
||||||
|
|
||||||
@ -5382,7 +5370,6 @@ void Yap_InitDBPreds(void) {
|
|||||||
Yap_InitCPred("$db_peek_queue", 2, p_peek_queue, SyncPredFlag);
|
Yap_InitCPred("$db_peek_queue", 2, p_peek_queue, SyncPredFlag);
|
||||||
Yap_InitCPred("$db_clean_queues", 1, p_clean_queues, SyncPredFlag);
|
Yap_InitCPred("$db_clean_queues", 1, p_clean_queues, SyncPredFlag);
|
||||||
Yap_InitCPred("$switch_log_upd", 1, p_slu, SafePredFlag | SyncPredFlag);
|
Yap_InitCPred("$switch_log_upd", 1, p_slu, SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred("$log_upd", 1, p_lu, SafePredFlag | SyncPredFlag);
|
|
||||||
Yap_InitCPred("$hold_index", 3, p_hold_index, SafePredFlag | SyncPredFlag);
|
Yap_InitCPred("$hold_index", 3, p_hold_index, SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred("$fetch_reference_from_index", 3, p_fetch_reference_from_index,
|
Yap_InitCPred("$fetch_reference_from_index", 3, p_fetch_reference_from_index,
|
||||||
SafePredFlag | SyncPredFlag);
|
SafePredFlag | SyncPredFlag);
|
||||||
|
118
C/errors.c
@ -104,15 +104,6 @@ bool Yap_Warning(const char *s, ...) {
|
|||||||
LOCAL_within_print_message = true;
|
LOCAL_within_print_message = true;
|
||||||
pred = RepPredProp(PredPropByFunc(FunctorPrintMessage,
|
pred = RepPredProp(PredPropByFunc(FunctorPrintMessage,
|
||||||
PROLOG_MODULE)); // PROCEDURE_print_message2
|
PROLOG_MODULE)); // PROCEDURE_print_message2
|
||||||
if (pred->OpcodeOfPred == UNDEF_OPCODE) {
|
|
||||||
// fprintf(stderr, "warning message:\n");
|
|
||||||
// Yap_DebugPlWrite(twarning);
|
|
||||||
// fprintf(stderr, "\n");
|
|
||||||
LOCAL_DoingUndefp = false;
|
|
||||||
LOCAL_within_print_message = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
va_start(ap, s);
|
va_start(ap, s);
|
||||||
format = va_arg(ap, char *);
|
format = va_arg(ap, char *);
|
||||||
if (format != NULL) {
|
if (format != NULL) {
|
||||||
@ -124,6 +115,13 @@ bool Yap_Warning(const char *s, ...) {
|
|||||||
} else
|
} else
|
||||||
return false;
|
return false;
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
if (pred->OpcodeOfPred == UNDEF_OPCODE) {
|
||||||
|
fprintf(stderr, "warning message: %s\n", tmpbuf);
|
||||||
|
LOCAL_DoingUndefp = false;
|
||||||
|
LOCAL_within_print_message = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
ts[1] = MkAtomTerm(AtomWarning);
|
ts[1] = MkAtomTerm(AtomWarning);
|
||||||
ts[0] = MkAtomTerm(Yap_LookupAtom(tmpbuf));
|
ts[0] = MkAtomTerm(Yap_LookupAtom(tmpbuf));
|
||||||
rc = Yap_execute_pred(pred, ts, true PASS_REGS);
|
rc = Yap_execute_pred(pred, ts, true PASS_REGS);
|
||||||
@ -146,9 +144,9 @@ bool Yap_PrintWarning(Term twarning) {
|
|||||||
LOCAL_DoingUndefp = true;
|
LOCAL_DoingUndefp = true;
|
||||||
LOCAL_within_print_message = true;
|
LOCAL_within_print_message = true;
|
||||||
if (pred->OpcodeOfPred == UNDEF_OPCODE) {
|
if (pred->OpcodeOfPred == UNDEF_OPCODE) {
|
||||||
// fprintf(stderr, "warning message:\n");
|
fprintf(stderr, "warning message:\n");
|
||||||
// Yap_DebugPlWrite(twarning);
|
Yap_DebugPlWrite(twarning);
|
||||||
// fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
LOCAL_DoingUndefp = false;
|
LOCAL_DoingUndefp = false;
|
||||||
LOCAL_within_print_message = false;
|
LOCAL_within_print_message = false;
|
||||||
return true;
|
return true;
|
||||||
@ -489,7 +487,7 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
|||||||
}
|
}
|
||||||
case ABORT_EVENT:
|
case ABORT_EVENT:
|
||||||
nt[0] = MkAtomTerm(AtomDAbort);
|
nt[0] = MkAtomTerm(AtomDAbort);
|
||||||
fun = FunctorVar;
|
fun = FunctorDollarVar;
|
||||||
serious = TRUE;
|
serious = TRUE;
|
||||||
break;
|
break;
|
||||||
case CALL_COUNTER_UNDERFLOW_EVENT:
|
case CALL_COUNTER_UNDERFLOW_EVENT:
|
||||||
@ -604,3 +602,97 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
|||||||
LOCAL_PrologMode &= ~InErrorMode;
|
LOCAL_PrologMode &= ~InErrorMode;
|
||||||
return P;
|
return P;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Int
|
||||||
|
is_boolean( USES_REGS1 )
|
||||||
|
{
|
||||||
|
Term t = Deref(ARG1);
|
||||||
|
//Term Context = Deref(ARG2);
|
||||||
|
if (IsVarTerm(t)) {
|
||||||
|
Yap_Error(INSTANTIATION_ERROR, t, NULL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return t == TermTrue || t == TermFalse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static Int
|
||||||
|
is_callable( USES_REGS1 )
|
||||||
|
{
|
||||||
|
Term G = Deref(ARG1);
|
||||||
|
//Term Context = Deref(ARG2);
|
||||||
|
while (true) {
|
||||||
|
if (IsVarTerm(G)) {
|
||||||
|
Yap_Error(INSTANTIATION_ERROR, G, NULL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (IsApplTerm(G)) {
|
||||||
|
Functor f = FunctorOfTerm(G);
|
||||||
|
if (IsExtensionFunctor(f)) {
|
||||||
|
Yap_Error(TYPE_ERROR_CALLABLE, G, NULL);
|
||||||
|
}
|
||||||
|
if (f == FunctorModule) {
|
||||||
|
Term tm = ArgOfTerm( 1, G);
|
||||||
|
if (IsVarTerm(tm)) {
|
||||||
|
Yap_Error(INSTANTIATION_ERROR, G, NULL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!IsAtomTerm(tm)) {
|
||||||
|
Yap_Error(TYPE_ERROR_CALLABLE, G, NULL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
G = ArgOfTerm( 2, G );
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (IsPairTerm(G) || IsAtomTerm(G)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
Yap_Error(TYPE_ERROR_CALLABLE, G, NULL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Int
|
||||||
|
is_predicate_indicator( USES_REGS1 )
|
||||||
|
{
|
||||||
|
Term G = Deref(ARG1);
|
||||||
|
//Term Context = Deref(ARG2);
|
||||||
|
Term mod = CurrentModule;
|
||||||
|
|
||||||
|
G = Yap_YapStripModule(G, &mod);
|
||||||
|
if (IsVarTerm(G)) {
|
||||||
|
Yap_Error(INSTANTIATION_ERROR, G, NULL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!IsVarTerm(mod) && !IsAtomTerm(mod)) {
|
||||||
|
Yap_Error(TYPE_ERROR_ATOM, G, NULL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (IsApplTerm(G)) {
|
||||||
|
Functor f = FunctorOfTerm(G);
|
||||||
|
if (IsExtensionFunctor(f)) {
|
||||||
|
Yap_Error(TYPE_ERROR_PREDICATE_INDICATOR, G, NULL);
|
||||||
|
}
|
||||||
|
if (f == FunctorSlash || f == FunctorDoubleSlash) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Yap_Error(TYPE_ERROR_PREDICATE_INDICATOR, G, NULL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Yap_InitErrorPreds( void )
|
||||||
|
{
|
||||||
|
CACHE_REGS
|
||||||
|
Term cm = CurrentModule;
|
||||||
|
CurrentModule = ERROR_MODULE;
|
||||||
|
Yap_InitCPred("is_boolean", 2, is_boolean, TestPredFlag);
|
||||||
|
Yap_InitCPred("is_callable", 2, is_callable, TestPredFlag);
|
||||||
|
Yap_InitCPred("is_predicate_indicator", 2, is_predicate_indicator, TestPredFlag);
|
||||||
|
CurrentModule = cm;
|
||||||
|
}
|
||||||
|
130
C/exec.c
@ -54,7 +54,7 @@ static inline Int CallPredicate(PredEntry *pen, choiceptr cut_pt,
|
|||||||
if (pen->ModuleOfPred) {
|
if (pen->ModuleOfPred) {
|
||||||
if (DEPTH == MkIntTerm(0)) {
|
if (DEPTH == MkIntTerm(0)) {
|
||||||
UNLOCK(pen->PELock);
|
UNLOCK(pen->PELock);
|
||||||
return FALSE;
|
return false;
|
||||||
} else
|
} else
|
||||||
DEPTH = RESET_DEPTH();
|
DEPTH = RESET_DEPTH();
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ static inline Int CallPredicate(PredEntry *pen, choiceptr cut_pt,
|
|||||||
/* make sure we have access to the user given cut */
|
/* make sure we have access to the user given cut */
|
||||||
YENV[E_CB] = (CELL)cut_pt;
|
YENV[E_CB] = (CELL)cut_pt;
|
||||||
P = code;
|
P = code;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static Int CallMetaCall(Term t, Term mod USES_REGS) {
|
inline static Int CallMetaCall(Term t, Term mod USES_REGS) {
|
||||||
@ -192,13 +192,7 @@ inline static Int do_execute(Term t, Term mod USES_REGS) {
|
|||||||
Term t0 = t;
|
Term t0 = t;
|
||||||
/* first do predicate expansion, even before you process signals.
|
/* first do predicate expansion, even before you process signals.
|
||||||
This way you don't get to spy goal_expansion(). */
|
This way you don't get to spy goal_expansion(). */
|
||||||
if (PRED_GOAL_EXPANSION_ALL) {
|
if (Yap_has_a_signal() && !LOCAL_InterruptsDisabled &&
|
||||||
/* disable creeping when we do goal expansion */
|
|
||||||
if (!LOCAL_InterruptsDisabled && Yap_get_signal(YAP_CREEP_SIGNAL)) {
|
|
||||||
CalculateStackGap(PASS_REGS1);
|
|
||||||
}
|
|
||||||
return CallMetaCall(ARG1, mod PASS_REGS);
|
|
||||||
} else if (Yap_has_a_signal() && !LOCAL_InterruptsDisabled &&
|
|
||||||
!(LOCAL_PrologMode & (AbortMode | InterruptMode | SystemMode))) {
|
!(LOCAL_PrologMode & (AbortMode | InterruptMode | SystemMode))) {
|
||||||
return EnterCreepMode(t, mod PASS_REGS);
|
return EnterCreepMode(t, mod PASS_REGS);
|
||||||
}
|
}
|
||||||
@ -222,7 +216,7 @@ restart_exec:
|
|||||||
pen = RepPredProp(PredPropByFunc(f, mod));
|
pen = RepPredProp(PredPropByFunc(f, mod));
|
||||||
/* You thought we would be over by now */
|
/* You thought we would be over by now */
|
||||||
/* but no meta calls require special preprocessing */
|
/* but no meta calls require special preprocessing */
|
||||||
if (pen->PredFlags & (GoalExPredFlag | MetaPredFlag)) {
|
if (pen->PredFlags & MetaPredFlag) {
|
||||||
if (f == FunctorModule) {
|
if (f == FunctorModule) {
|
||||||
Term tmod = ArgOfTerm(1, t);
|
Term tmod = ArgOfTerm(1, t);
|
||||||
if (!IsVarTerm(tmod) && IsAtomTerm(tmod)) {
|
if (!IsVarTerm(tmod) && IsAtomTerm(tmod)) {
|
||||||
@ -359,14 +353,7 @@ restart_exec:
|
|||||||
if (IsExtensionFunctor(f)) {
|
if (IsExtensionFunctor(f)) {
|
||||||
return CallError(TYPE_ERROR_CALLABLE, t, mod PASS_REGS);
|
return CallError(TYPE_ERROR_CALLABLE, t, mod PASS_REGS);
|
||||||
}
|
}
|
||||||
if (PRED_GOAL_EXPANSION_ALL) {
|
if (Yap_has_a_signal() && !LOCAL_InterruptsDisabled) {
|
||||||
/* disable creeping when we do goal expansion */
|
|
||||||
if (Yap_get_signal(YAP_CREEP_SIGNAL) && !LOCAL_InterruptsDisabled) {
|
|
||||||
CalculateStackGap(PASS_REGS1);
|
|
||||||
}
|
|
||||||
t = copy_execn_to_heap(f, pt, n, arity, mod PASS_REGS);
|
|
||||||
return CallMetaCall(t, mod PASS_REGS);
|
|
||||||
} else if (Yap_has_a_signal() && !LOCAL_InterruptsDisabled) {
|
|
||||||
return EnterCreepMode(
|
return EnterCreepMode(
|
||||||
copy_execn_to_heap(f, pt, n, arity, CurrentModule PASS_REGS),
|
copy_execn_to_heap(f, pt, n, arity, CurrentModule PASS_REGS),
|
||||||
mod PASS_REGS);
|
mod PASS_REGS);
|
||||||
@ -377,7 +364,7 @@ restart_exec:
|
|||||||
pen = RepPredProp(PredPropByFunc(f, mod));
|
pen = RepPredProp(PredPropByFunc(f, mod));
|
||||||
/* You thought we would be over by now */
|
/* You thought we would be over by now */
|
||||||
/* but no meta calls require special preprocessing */
|
/* but no meta calls require special preprocessing */
|
||||||
if (pen->PredFlags & (GoalExPredFlag | MetaPredFlag)) {
|
if (pen->PredFlags & MetaPredFlag) {
|
||||||
Term t = copy_execn_to_heap(f, pt, n, arity, mod PASS_REGS);
|
Term t = copy_execn_to_heap(f, pt, n, arity, mod PASS_REGS);
|
||||||
return (CallMetaCall(t, mod PASS_REGS));
|
return (CallMetaCall(t, mod PASS_REGS));
|
||||||
}
|
}
|
||||||
@ -565,6 +552,7 @@ static Int execute11(USES_REGS1) { /* '$execute'(Goal) */
|
|||||||
|
|
||||||
static Int execute12(USES_REGS1) { /* '$execute'(Goal) */
|
static Int execute12(USES_REGS1) { /* '$execute'(Goal) */
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
|
|
||||||
heap_store(Deref(ARG2) PASS_REGS);
|
heap_store(Deref(ARG2) PASS_REGS);
|
||||||
heap_store(Deref(ARG3) PASS_REGS);
|
heap_store(Deref(ARG3) PASS_REGS);
|
||||||
heap_store(Deref(ARG4) PASS_REGS);
|
heap_store(Deref(ARG4) PASS_REGS);
|
||||||
@ -647,97 +635,105 @@ restart_exec:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int execute_in_mod(USES_REGS1) { /* '$execute'(Goal) */
|
static Int execute_in_mod(USES_REGS1) { /* '$execute'(Goal) */
|
||||||
return (do_execute(Deref(ARG1), Deref(ARG2) PASS_REGS));
|
return do_execute(Deref(ARG1), Deref(ARG2) PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int do_goal_expansion(USES_REGS1) {
|
static bool complete_ge(bool out, Term omod, yhandle_t sl, bool creeping) {
|
||||||
Int creeping = Yap_get_signal(YAP_CREEP_SIGNAL);
|
CACHE_REGS
|
||||||
Int out = FALSE;
|
if (creeping) {
|
||||||
PredEntry *pe;
|
Yap_signal(YAP_CREEP_SIGNAL);
|
||||||
Term cmod = Deref(ARG2);
|
}
|
||||||
|
CurrentModule = omod;
|
||||||
|
Yap_CloseSlots(sl);
|
||||||
|
if (out) {
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
ARG2 = ARG3;
|
|
||||||
|
static Int _user_expand_goal(USES_REGS1) {
|
||||||
|
yhandle_t sl = Yap_StartSlots();
|
||||||
|
Int creeping = Yap_get_signal(YAP_CREEP_SIGNAL);
|
||||||
|
PredEntry *pe;
|
||||||
|
Term cmod = CurrentModule, omod = cmod;
|
||||||
|
Term mg_args[2];
|
||||||
|
Term g = Yap_YapStripModule(ARG1, &cmod);
|
||||||
|
yhandle_t h1 = Yap_InitSlot(g), h2 = Yap_InitSlot(ARG2);
|
||||||
|
|
||||||
/* CurMod:goal_expansion(A,B) */
|
/* CurMod:goal_expansion(A,B) */
|
||||||
|
ARG1 = g;
|
||||||
if ((pe = RepPredProp(Yap_GetPredPropByFunc(FunctorGoalExpansion2, cmod))) &&
|
if ((pe = RepPredProp(Yap_GetPredPropByFunc(FunctorGoalExpansion2, cmod))) &&
|
||||||
pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE &&
|
pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE &&
|
||||||
Yap_execute_pred(pe, NULL, false PASS_REGS)) {
|
Yap_execute_pred(pe, NULL, false PASS_REGS)) {
|
||||||
out = TRUE;
|
return complete_ge(true, omod, sl, creeping);
|
||||||
ARG3 = ARG2;
|
|
||||||
goto complete;
|
|
||||||
}
|
}
|
||||||
/* system:goal_expansion(A,B) */
|
/* system:goal_expansion(A,B) */
|
||||||
|
mg_args[0] = cmod;
|
||||||
|
mg_args[1] = Yap_GetFromSlot(h1);
|
||||||
|
ARG1 = Yap_MkApplTerm(FunctorModule, 2, mg_args);
|
||||||
|
ARG2 = Yap_GetFromSlot(h2);
|
||||||
if ((pe = RepPredProp(
|
if ((pe = RepPredProp(
|
||||||
Yap_GetPredPropByFunc(FunctorGoalExpansion2, SYSTEM_MODULE))) &&
|
Yap_GetPredPropByFunc(FunctorGoalExpansion2, SYSTEM_MODULE))) &&
|
||||||
pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE &&
|
pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE &&
|
||||||
Yap_execute_pred(pe, NULL, false PASS_REGS)) {
|
Yap_execute_pred(pe, NULL, false PASS_REGS)) {
|
||||||
out = TRUE;
|
return complete_ge(true, omod, sl, creeping);
|
||||||
ARG3 = ARG2;
|
|
||||||
goto complete;
|
|
||||||
}
|
}
|
||||||
ARG3 = ARG2;
|
ARG1 = Yap_GetFromSlot(h1);
|
||||||
ARG2 = cmod;
|
ARG2 = cmod;
|
||||||
|
ARG3 = Yap_GetFromSlot(h2);
|
||||||
/* user:goal_expansion(A,CurMod,B) */
|
/* user:goal_expansion(A,CurMod,B) */
|
||||||
if ((pe = RepPredProp(
|
if ((pe = RepPredProp(
|
||||||
Yap_GetPredPropByFunc(FunctorGoalExpansion, USER_MODULE))) &&
|
Yap_GetPredPropByFunc(FunctorGoalExpansion, USER_MODULE))) &&
|
||||||
pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE &&
|
pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE &&
|
||||||
Yap_execute_pred(pe, NULL PASS_REGS, false)) {
|
Yap_execute_pred(pe, NULL PASS_REGS, false)) {
|
||||||
out = TRUE;
|
return complete_ge(true, omod, sl, creeping);
|
||||||
goto complete;
|
|
||||||
}
|
}
|
||||||
ARG2 = ARG3;
|
mg_args[0] = cmod;
|
||||||
|
mg_args[1] = Yap_GetFromSlot(h1);
|
||||||
|
ARG1 = Yap_MkApplTerm(FunctorModule, 2, mg_args);
|
||||||
|
ARG2 = Yap_GetFromSlot(h2);
|
||||||
/* user:goal_expansion(A,B) */
|
/* user:goal_expansion(A,B) */
|
||||||
if (cmod != USER_MODULE && /* we have tried this before */
|
if (cmod != USER_MODULE && /* we have tried this before */
|
||||||
(pe = RepPredProp(
|
(pe = RepPredProp(
|
||||||
Yap_GetPredPropByFunc(FunctorGoalExpansion2, USER_MODULE))) &&
|
Yap_GetPredPropByFunc(FunctorGoalExpansion2, USER_MODULE))) &&
|
||||||
pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE &&
|
pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE &&
|
||||||
Yap_execute_pred(pe, NULL PASS_REGS, false)) {
|
Yap_execute_pred(pe, NULL PASS_REGS, false)) {
|
||||||
ARG3 = ARG2;
|
return complete_ge(true, omod, sl, creeping);
|
||||||
out = TRUE;
|
|
||||||
}
|
}
|
||||||
complete:
|
return complete_ge(false, omod, sl, creeping);
|
||||||
if (creeping) {
|
|
||||||
Yap_signal(YAP_CREEP_SIGNAL);
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int do_term_expansion(USES_REGS1) {
|
static Int do_term_expansion(USES_REGS1) {
|
||||||
|
yhandle_t sl = Yap_StartSlots();
|
||||||
Int creeping = Yap_get_signal(YAP_CREEP_SIGNAL);
|
Int creeping = Yap_get_signal(YAP_CREEP_SIGNAL);
|
||||||
Int out = FALSE;
|
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
Term cmod = CurrentModule;
|
Term cmod = CurrentModule, omod = cmod;
|
||||||
|
Term mg_args[2];
|
||||||
|
Term g = Yap_YapStripModule(ARG1, &cmod);
|
||||||
|
yhandle_t h1 = Yap_InitSlot(g), h2 = Yap_InitSlot(ARG2);
|
||||||
|
|
||||||
/* CurMod:term_expansion(A,B) */
|
/* CurMod:term_expansion(A,B) */
|
||||||
|
ARG1 = g;
|
||||||
if ((pe = RepPredProp(Yap_GetPredPropByFunc(FunctorTermExpansion, cmod))) &&
|
if ((pe = RepPredProp(Yap_GetPredPropByFunc(FunctorTermExpansion, cmod))) &&
|
||||||
pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE &&
|
pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE &&
|
||||||
Yap_execute_pred(pe, NULL, false PASS_REGS)) {
|
Yap_execute_pred(pe, NULL, false PASS_REGS)) {
|
||||||
out = TRUE;
|
return complete_ge(true, omod, sl, creeping);
|
||||||
goto complete;
|
|
||||||
}
|
}
|
||||||
/* system:term_expansion(A,B) */
|
/* system:term_expansion(A,B) */
|
||||||
|
mg_args[0] = cmod;
|
||||||
|
mg_args[1] = Yap_GetFromSlot(h1);
|
||||||
|
ARG1 = Yap_MkApplTerm(FunctorModule, 2, mg_args);
|
||||||
|
ARG2 = Yap_GetFromSlot(h2);
|
||||||
if ((pe = RepPredProp(
|
if ((pe = RepPredProp(
|
||||||
Yap_GetPredPropByFunc(FunctorTermExpansion, SYSTEM_MODULE))) &&
|
Yap_GetPredPropByFunc(FunctorTermExpansion, SYSTEM_MODULE))) &&
|
||||||
pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE &&
|
pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE &&
|
||||||
Yap_execute_pred(pe, NULL, false PASS_REGS)) {
|
Yap_execute_pred(pe, NULL, false PASS_REGS)) {
|
||||||
out = TRUE;
|
return complete_ge(true, omod, sl, creeping);
|
||||||
goto complete;
|
|
||||||
}
|
}
|
||||||
/* user:term_expansion(A,B) */
|
return complete_ge(false, omod, sl, creeping);
|
||||||
if (cmod != USER_MODULE && /* we have tried this before */
|
|
||||||
(pe = RepPredProp(
|
|
||||||
Yap_GetPredPropByFunc(FunctorTermExpansion, USER_MODULE))) &&
|
|
||||||
pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE &&
|
|
||||||
Yap_execute_pred(pe, NULL, false PASS_REGS)) {
|
|
||||||
out = TRUE;
|
|
||||||
}
|
|
||||||
complete:
|
|
||||||
if (creeping) {
|
|
||||||
Yap_signal(YAP_CREEP_SIGNAL);
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int execute0(USES_REGS1) { /* '$execute0'(Goal,Mod) */
|
static Int execute0(USES_REGS1) { /* '$execute0'(Goal,Mod) */
|
||||||
Term t = Deref(ARG1), t0 = t;
|
Term t = Deref(ARG1), t0 = t;
|
||||||
Term mod = Deref(ARG2);
|
Term mod = Deref(ARG2);
|
||||||
@ -1006,12 +1002,6 @@ static Int execute_depth_limit(USES_REGS1) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Int pred_goal_expansion_on(USES_REGS1) {
|
|
||||||
/* a goal needs expansion if we have goal_expansion defined or
|
|
||||||
if the goal is a meta-call */
|
|
||||||
return PRED_GOAL_EXPANSION_ON;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Int exec_absmi(bool top, yap_reset_t reset_mode USES_REGS) {
|
static Int exec_absmi(bool top, yap_reset_t reset_mode USES_REGS) {
|
||||||
int lval, out;
|
int lval, out;
|
||||||
|
|
||||||
@ -1892,8 +1882,6 @@ void Yap_InitExecFs(void) {
|
|||||||
Yap_InitCPred("trail_suspension_marker", 1, trail_suspension_marker, 0);
|
Yap_InitCPred("trail_suspension_marker", 1, trail_suspension_marker, 0);
|
||||||
Yap_InitCPred("cut_at", 1, clean_ifcp, SafePredFlag);
|
Yap_InitCPred("cut_at", 1, clean_ifcp, SafePredFlag);
|
||||||
CurrentModule = cm;
|
CurrentModule = cm;
|
||||||
Yap_InitCPred("$pred_goal_expansion_on", 0, pred_goal_expansion_on,
|
|
||||||
SafePredFlag);
|
|
||||||
Yap_InitCPred("$restore_regs", 1, restore_regs,
|
Yap_InitCPred("$restore_regs", 1, restore_regs,
|
||||||
NoTracePredFlag | SafePredFlag);
|
NoTracePredFlag | SafePredFlag);
|
||||||
Yap_InitCPred("$restore_regs", 2, restore_regs2,
|
Yap_InitCPred("$restore_regs", 2, restore_regs2,
|
||||||
@ -1905,7 +1893,7 @@ void Yap_InitExecFs(void) {
|
|||||||
Yap_InitCPred("$generate_pred_info", 4, generate_pred_info, 0);
|
Yap_InitCPred("$generate_pred_info", 4, generate_pred_info, 0);
|
||||||
Yap_InitCPred("$uncaught_throw", 0, uncaught_throw, 0);
|
Yap_InitCPred("$uncaught_throw", 0, uncaught_throw, 0);
|
||||||
Yap_InitCPred("$reset_exception", 1, reset_exception, 0);
|
Yap_InitCPred("$reset_exception", 1, reset_exception, 0);
|
||||||
Yap_InitCPred("$do_goal_expansion", 3, do_goal_expansion, 0);
|
Yap_InitCPred("_user_expand_goal", 2, _user_expand_goal, 0);
|
||||||
Yap_InitCPred("$do_term_expansion", 2, do_term_expansion, 0);
|
Yap_InitCPred("$do_term_expansion", 2, do_term_expansion, 0);
|
||||||
Yap_InitCPred("$get_exception", 1, get_exception, 0);
|
Yap_InitCPred("$get_exception", 1, get_exception, 0);
|
||||||
}
|
}
|
||||||
|
469
C/flags.c
@ -15,14 +15,12 @@
|
|||||||
* *
|
* *
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/** @file C/flags.c
|
/** @file C/flags.c
|
||||||
|
|
||||||
@ingroup Flags
|
@ingroup Flags
|
||||||
@{
|
@{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// this is where we define flags
|
// this is where we define flags
|
||||||
#define INIT_FLAGS 1
|
#define INIT_FLAGS 1
|
||||||
|
|
||||||
@ -56,35 +54,34 @@ static Int set_prolog_flag(USES_REGS1);
|
|||||||
#include "yapio.h"
|
#include "yapio.h"
|
||||||
#include "eval.h"
|
#include "eval.h"
|
||||||
|
|
||||||
#define YAP_FLAG( ID, NAME, WRITABLE, DEF, INIT, HELPER ) { NAME, WRITABLE, DEF, INIT, HELPER }
|
#define YAP_FLAG(ID, NAME, WRITABLE, DEF, INIT, HELPER) \
|
||||||
|
{ NAME, WRITABLE, DEF, INIT, HELPER }
|
||||||
|
|
||||||
#define GZERO_FLAG { NULL, false, NULL, NULL, NULL }
|
#define GZERO_FLAG \
|
||||||
#define LZERO_FLAG { NULL, false, NULL, NULL, NULL }
|
{ NULL, false, NULL, NULL, NULL }
|
||||||
|
#define LZERO_FLAG \
|
||||||
|
{ NULL, false, NULL, NULL, NULL }
|
||||||
|
|
||||||
static flag_info global_flags_setup[] = {
|
static flag_info global_flags_setup[] = {
|
||||||
#include "YapGFlagInfo.h"
|
#include "YapGFlagInfo.h"
|
||||||
GZERO_FLAG
|
GZERO_FLAG};
|
||||||
};
|
|
||||||
|
|
||||||
static flag_info local_flags_setup[] = {
|
static flag_info local_flags_setup[] = {
|
||||||
#include "YapLFlagInfo.h"
|
#include "YapLFlagInfo.h"
|
||||||
LZERO_FLAG
|
LZERO_FLAG};
|
||||||
};
|
|
||||||
|
|
||||||
static bool indexer(Term inp) {
|
static bool indexer(Term inp) {
|
||||||
if (inp == TermOff ||
|
if (inp == TermOff || inp == TermSingle || inp == TermCompact ||
|
||||||
inp == TermSingle||
|
inp == TermMulti || inp == TermOn || inp == TermMax)
|
||||||
inp == TermCompact||
|
|
||||||
inp == TermMulti||
|
|
||||||
inp == TermOn||
|
|
||||||
inp == TermMax )
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (IsAtomTerm(inp)) {
|
if (IsAtomTerm(inp)) {
|
||||||
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, inp, "set_prolog_flag index in {off,single,compact,multi,on,max}");
|
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, inp,
|
||||||
|
"set_prolog_flag index in {off,single,compact,multi,on,max}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag in {dec10,error,fail,quiet}");
|
Yap_Error(TYPE_ERROR_ATOM, inp,
|
||||||
|
"set_prolog_flag in {dec10,error,fail,quiet}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,10 +102,15 @@ static bool dqf1( ModEntry *new, Term t2 USES_REGS ) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/* bad argument, but still an atom */
|
/* bad argument, but still an atom */
|
||||||
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, t2, "bad option %s for backquoted string flag, use one string, arom, codes or chars", RepAtom(AtomOfTerm(t2))->StrOfAE);
|
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, t2, "bad option %s for backquoted "
|
||||||
|
"string flag, use one string, "
|
||||||
|
"arom, codes or chars",
|
||||||
|
RepAtom(AtomOfTerm(t2))->StrOfAE);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
Yap_Error(TYPE_ERROR_ATOM, t2, "set_prolog_flag(double_quotes, %s), should be {string,atom,codes,chars}", RepAtom(AtomOfTerm(t2))->StrOfAE);
|
Yap_Error(TYPE_ERROR_ATOM, t2, "set_prolog_flag(double_quotes, %s), should "
|
||||||
|
"be {string,atom,codes,chars}",
|
||||||
|
RepAtom(AtomOfTerm(t2))->StrOfAE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,8 +121,6 @@ static bool dqf1( ModEntry *new, Term t2 USES_REGS ) {
|
|||||||
return dqf1(new, t2 PASS_REGS);
|
return dqf1(new, t2 PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static bool bqf1(ModEntry *new, Term t2 USES_REGS) {
|
static bool bqf1(ModEntry *new, Term t2 USES_REGS) {
|
||||||
new->flags &= ~(BCKQ_CHARS | BCKQ_CODES | BCKQ_ATOM | BCKQ_STRING);
|
new->flags &= ~(BCKQ_CHARS | BCKQ_CODES | BCKQ_ATOM | BCKQ_STRING);
|
||||||
if (IsAtomTerm(t2)) {
|
if (IsAtomTerm(t2)) {
|
||||||
@ -137,47 +137,48 @@ static bool bqf1( ModEntry *new, Term t2 USES_REGS ) {
|
|||||||
new->flags |= BCKQ_CHARS;
|
new->flags |= BCKQ_CHARS;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, t2, "bad option %s for backquoted string flag, use one string, arom, codes or chars", RepAtom(AtomOfTerm(t2))->StrOfAE);
|
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, t2, "bad option %s for backquoted "
|
||||||
|
"string flag, use one string, "
|
||||||
|
"arom, codes or chars",
|
||||||
|
RepAtom(AtomOfTerm(t2))->StrOfAE);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
Yap_Error(TYPE_ERROR_ATOM, t2, "flag %s is not module-scoped", RepAtom(AtomOfTerm(t2))->StrOfAE);
|
Yap_Error(TYPE_ERROR_ATOM, t2, "flag %s is not module-scoped",
|
||||||
|
RepAtom(AtomOfTerm(t2))->StrOfAE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isaccess(Term inp) {
|
static bool isaccess(Term inp) {
|
||||||
if (inp == TermReadWrite ||
|
if (inp == TermReadWrite || inp == TermReadOnly)
|
||||||
inp == TermReadOnly )
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (IsAtomTerm(inp)) {
|
if (IsAtomTerm(inp)) {
|
||||||
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, inp, "set_prolog_flag access in {read_write,read_only}");
|
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, inp,
|
||||||
|
"set_prolog_flag access in {read_write,read_only}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag access in {read_write,read_only}");
|
Yap_Error(TYPE_ERROR_ATOM, inp,
|
||||||
|
"set_prolog_flag access in {read_write,read_only}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isground( Term inp ) {
|
static bool isground(Term inp) { return Yap_IsGroundTerm(inp); }
|
||||||
return Yap_IsGroundTerm( inp );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static bool flagscope(Term inp) {
|
static bool flagscope(Term inp) {
|
||||||
if (inp == TermGlobal ||
|
if (inp == TermGlobal || inp == TermThread || inp == TermModule)
|
||||||
inp == TermThread ||
|
|
||||||
inp == TermModule)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (IsAtomTerm(inp)) {
|
if (IsAtomTerm(inp)) {
|
||||||
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, inp, "set_prolog_flag access in {global,module,thread}");
|
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, inp,
|
||||||
|
"set_prolog_flag access in {global,module,thread}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag access in {global,module,thread}");
|
Yap_Error(TYPE_ERROR_ATOM, inp,
|
||||||
|
"set_prolog_flag access in {global,module,thread}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool mkprompt(Term inp) {
|
static bool mkprompt(Term inp) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
if (IsVarTerm(inp)) {
|
if (IsVarTerm(inp)) {
|
||||||
@ -187,7 +188,8 @@ static bool mkprompt( Term inp ) {
|
|||||||
Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag");
|
Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
strncpy( LOCAL_Prompt, (const char *)RepAtom( AtomOfTerm( inp ) )->StrOfAE, MAX_PROMPT );
|
strncpy(LOCAL_Prompt, (const char *)RepAtom(AtomOfTerm(inp))->StrOfAE,
|
||||||
|
MAX_PROMPT);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +210,8 @@ static bool getenc( Term inp ) {
|
|||||||
static bool enablerl( Term inp ) {
|
static bool enablerl( Term inp ) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
if (IsVarTerm(inp)) {
|
if (IsVarTerm(inp)) {
|
||||||
return Yap_unify( inp, MkAtomTerm( Yap_LookupAtom( enc_name(LOCAL_encoding) )) );
|
return Yap_unify( inp, MkAtomTerm( Yap_LookupAtom( enc_name(LOCAL_encoding)
|
||||||
|
)) );
|
||||||
}
|
}
|
||||||
if (!IsAtomTerm(inp) ) {
|
if (!IsAtomTerm(inp) ) {
|
||||||
Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag");
|
Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag");
|
||||||
@ -232,7 +235,8 @@ static bool typein( Term inp ) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CurrentModule = inp;
|
CurrentModule = inp;
|
||||||
if (inp == TermProlog) CurrentModule = PROLOG_MODULE;
|
if (inp == TermProlog)
|
||||||
|
CurrentModule = PROLOG_MODULE;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,7 +392,6 @@ static bool list_atom( Term inp ) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static bool list_option(Term inp) {
|
static bool list_option(Term inp) {
|
||||||
if (IsVarTerm(inp)) {
|
if (IsVarTerm(inp)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag in \"...\"");
|
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag in \"...\"");
|
||||||
@ -404,8 +407,7 @@ static bool list_option( Term inp ) {
|
|||||||
}
|
}
|
||||||
if (IsApplTerm(hd)) {
|
if (IsApplTerm(hd)) {
|
||||||
Functor f = FunctorOfTerm(hd);
|
Functor f = FunctorOfTerm(hd);
|
||||||
if (!IsExtensionFunctor(f) &&
|
if (!IsExtensionFunctor(f) && ArityOfFunctor(f) == 1 &&
|
||||||
ArityOfFunctor(f) == 1 &&
|
|
||||||
Yap_IsGroundTerm(hd)) {
|
Yap_IsGroundTerm(hd)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -424,13 +426,11 @@ static bool list_option( Term inp ) {
|
|||||||
return true;
|
return true;
|
||||||
} else if (IsApplTerm(inp)) {
|
} else if (IsApplTerm(inp)) {
|
||||||
Functor f = FunctorOfTerm(inp);
|
Functor f = FunctorOfTerm(inp);
|
||||||
if (!IsExtensionFunctor(f) &&
|
if (!IsExtensionFunctor(f) && ArityOfFunctor(f) == 1 &&
|
||||||
ArityOfFunctor(f) == 1 &&
|
|
||||||
Yap_IsGroundTerm(ArgOfTerm(1, inp))) {
|
Yap_IsGroundTerm(ArgOfTerm(1, inp))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -548,12 +548,8 @@ static bool os_argv(Term inp) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static FlagEntry *
|
static FlagEntry *
|
||||||
GetFlagProp(Atom a )
|
GetFlagProp(Atom a) { /* look property list of atom a for kind */
|
||||||
{ /* look property list of atom a for kind */
|
|
||||||
AtomEntry *ae = RepAtom(a);
|
AtomEntry *ae = RepAtom(a);
|
||||||
FlagEntry *pp;
|
FlagEntry *pp;
|
||||||
|
|
||||||
@ -567,9 +563,7 @@ GetFlagProp(Atom a )
|
|||||||
return pp;
|
return pp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void initFlag(flag_info *f, int fnum, bool global) {
|
||||||
initFlag(flag_info *f, int fnum, bool global)
|
|
||||||
{
|
|
||||||
Atom name = Yap_LookupAtom(f->name);
|
Atom name = Yap_LookupAtom(f->name);
|
||||||
AtomEntry *ae = RepAtom(name);
|
AtomEntry *ae = RepAtom(name);
|
||||||
WRITE_LOCK(ae->ARWLock);
|
WRITE_LOCK(ae->ARWLock);
|
||||||
@ -578,7 +572,9 @@ initFlag(flag_info *f, int fnum, bool global)
|
|||||||
fprop = (FlagEntry *)Yap_AllocAtomSpace(sizeof(FlagEntry));
|
fprop = (FlagEntry *)Yap_AllocAtomSpace(sizeof(FlagEntry));
|
||||||
if (fprop == NULL) {
|
if (fprop == NULL) {
|
||||||
WRITE_UNLOCK(ae->ARWLock);
|
WRITE_UNLOCK(ae->ARWLock);
|
||||||
Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"not enough space for new Flag %s", ae->StrOfAE); return;
|
Yap_Error(RESOURCE_ERROR_HEAP, TermNil,
|
||||||
|
"not enough space for new Flag %s", ae->StrOfAE);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
fprop->KindOfPE = FlagProperty;
|
fprop->KindOfPE = FlagProperty;
|
||||||
fprop->FlagOfVE = fnum;
|
fprop->FlagOfVE = fnum;
|
||||||
@ -601,8 +597,7 @@ static bool executable(Term inp) {
|
|||||||
return Yap_unify(MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)), inp);
|
return Yap_unify(MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)), inp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool sys_thread_id(Term inp)
|
static bool sys_thread_id(Term inp) {
|
||||||
{
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
int pid;
|
int pid;
|
||||||
#ifdef HAVE_GETTID_SYSCALL
|
#ifdef HAVE_GETTID_SYSCALL
|
||||||
@ -618,9 +613,7 @@ static bool sys_thread_id(Term inp)
|
|||||||
return Yap_unify(MkIntegerTerm(pid), inp);
|
return Yap_unify(MkIntegerTerm(pid), inp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool setYapFlagInModule(Term tflag, Term t2, Term mod) {
|
||||||
static bool setYapFlagInModule( Term tflag, Term t2, Term mod )
|
|
||||||
{
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
FlagEntry *fv;
|
FlagEntry *fv;
|
||||||
ModEntry *new = Yap_GetModuleEntry(mod);
|
ModEntry *new = Yap_GetModuleEntry(mod);
|
||||||
@ -628,29 +621,47 @@ static bool setYapFlagInModule( Term tflag, Term t2, Term mod )
|
|||||||
return false;
|
return false;
|
||||||
fv = GetFlagProp(AtomOfTerm(tflag));
|
fv = GetFlagProp(AtomOfTerm(tflag));
|
||||||
if (!fv && !fv->global) {
|
if (!fv && !fv->global) {
|
||||||
Yap_Error(DOMAIN_ERROR_PROLOG_FLAG, tflag, "trying to set unknown module flag");
|
Yap_Error(DOMAIN_ERROR_PROLOG_FLAG, tflag,
|
||||||
|
"trying to set unknown module flag");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (mod == USER_MODULE && !setYapFlag( tflag, t2) )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
|
if (mod == USER_MODULE) {
|
||||||
|
flag_term *tarr = GLOBAL_Flags;
|
||||||
|
if (!(fv->type(t2)))
|
||||||
|
return false;
|
||||||
|
if (fv->helper && !(fv->helper(t2)))
|
||||||
|
return false;
|
||||||
|
Term tout = tarr[fv->FlagOfVE].at;
|
||||||
|
if (IsVarTerm(tout))
|
||||||
|
Yap_PopTermFromDB(tarr[fv->FlagOfVE].DBT);
|
||||||
|
if (IsAtomOrIntTerm(t2))
|
||||||
|
tarr[fv->FlagOfVE].at = t2;
|
||||||
|
else {
|
||||||
|
tarr[fv->FlagOfVE].DBT = Yap_StoreTermInDB(t2, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
// module specific stuff now
|
// module specific stuff now
|
||||||
|
|
||||||
if (fv->FlagOfVE == UNKNOWN_FLAG) {
|
if (fv->FlagOfVE == UNKNOWN_FLAG) {
|
||||||
|
new->flags &= ~(UNKNOWN_MASK);
|
||||||
if (t2 == TermError) {
|
if (t2 == TermError) {
|
||||||
new->flags &= ~(UNKNOWN_FAIL|UNKNOWN_WARNING);
|
|
||||||
new->flags |= (UNKNOWN_ERROR);
|
new->flags |= (UNKNOWN_ERROR);
|
||||||
return true;
|
return true;
|
||||||
} else if (t2 == TermFail) {
|
} else if (t2 == TermFail) {
|
||||||
new->flags &= ~(UNKNOWN_ERROR|UNKNOWN_WARNING);
|
|
||||||
new->flags |= (UNKNOWN_FAIL);
|
new->flags |= (UNKNOWN_FAIL);
|
||||||
return true;
|
return true;
|
||||||
} else if (t2 == TermWarning) {
|
} else if (t2 == TermWarning) {
|
||||||
new->flags &= ~(UNKNOWN_ERROR|UNKNOWN_FAIL);
|
|
||||||
new->flags |= (UNKNOWN_WARNING);
|
new->flags |= (UNKNOWN_WARNING);
|
||||||
return true;
|
return true;
|
||||||
|
} else if (t2 == TermFastFail) {
|
||||||
|
new->flags |= (UNKNOWN_FAST_FAIL);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, t2, "bad option %s for unknown flag, use one of error, fail or warning.", RepAtom(AtomOfTerm(tflag))->StrOfAE);
|
Yap_Error(
|
||||||
|
DOMAIN_ERROR_OUT_OF_RANGE, t2,
|
||||||
|
"bad option %s for unknown flag, use one of error, fail or warning.",
|
||||||
|
RepAtom(AtomOfTerm(tflag))->StrOfAE);
|
||||||
return false;
|
return false;
|
||||||
} else if (fv->FlagOfVE == DOUBLE_QUOTES_FLAG) {
|
} else if (fv->FlagOfVE == DOUBLE_QUOTES_FLAG) {
|
||||||
return dqf1(new, t2 PASS_REGS);
|
return dqf1(new, t2 PASS_REGS);
|
||||||
@ -662,17 +673,19 @@ static bool setYapFlagInModule( Term tflag, Term t2, Term mod )
|
|||||||
new->flags &= ~(M_CHARESCAPE);
|
new->flags &= ~(M_CHARESCAPE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, t2, "bad option %s for character_escapes flag, use true or false", RepAtom(AtomOfTerm(tflag))->StrOfAE);
|
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, t2,
|
||||||
|
"bad option %s for character_escapes flag, use true or false",
|
||||||
|
RepAtom(AtomOfTerm(tflag))->StrOfAE);
|
||||||
return false;
|
return false;
|
||||||
} else if (fv->FlagOfVE == BACKQUOTED_STRING_FLAG) {
|
} else if (fv->FlagOfVE == BACKQUOTED_STRING_FLAG) {
|
||||||
return bqf1( new, t2 PASS_REGS );;
|
return bqf1(new, t2 PASS_REGS);
|
||||||
|
;
|
||||||
}
|
}
|
||||||
// bad key?
|
// bad key?
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Term getYapFlagInModule( Term tflag, Term mod )
|
static Term getYapFlagInModule(Term tflag, Term mod) {
|
||||||
{
|
|
||||||
FlagEntry *fv;
|
FlagEntry *fv;
|
||||||
ModEntry *new = Yap_GetModuleEntry(mod);
|
ModEntry *new = Yap_GetModuleEntry(mod);
|
||||||
if (!mod)
|
if (!mod)
|
||||||
@ -710,7 +723,8 @@ static Term getYapFlagInModule( Term tflag, Term mod )
|
|||||||
return TermAtom;
|
return TermAtom;
|
||||||
return TermString;
|
return TermString;
|
||||||
}
|
}
|
||||||
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, tflag, "flag %s is not module-scoped", RepAtom(AtomOfTerm(tflag))->StrOfAE);
|
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, tflag, "flag %s is not module-scoped",
|
||||||
|
RepAtom(AtomOfTerm(tflag))->StrOfAE);
|
||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -724,11 +738,11 @@ static Int cont_yap_flag( USES_REGS1) {
|
|||||||
if (IsApplTerm(tflag) && FunctorOfTerm(tflag) == FunctorModule) {
|
if (IsApplTerm(tflag) && FunctorOfTerm(tflag) == FunctorModule) {
|
||||||
Term modt = CurrentModule;
|
Term modt = CurrentModule;
|
||||||
tflag = Yap_StripModule(tflag, &modt);
|
tflag = Yap_StripModule(tflag, &modt);
|
||||||
while (i != gmax &&
|
while (i != gmax && i != UNKNOWN_FLAG && i != CHARACTER_ESCAPES_FLAG &&
|
||||||
i != UNKNOWN_FLAG &&
|
i != BACKQUOTED_STRING_FLAG)
|
||||||
i != CHARACTER_ESCAPES_FLAG &&
|
i++;
|
||||||
i != BACKQUOTED_STRING_FLAG) i++;
|
if (i == gmax)
|
||||||
if (i == gmax) cut_fail();
|
cut_fail();
|
||||||
EXTRA_CBACK_ARG(2, 1) = MkIntTerm(i + 1);
|
EXTRA_CBACK_ARG(2, 1) = MkIntTerm(i + 1);
|
||||||
{
|
{
|
||||||
Term lab = MkAtomTerm(Yap_LookupAtom(global_flags_setup[i].name));
|
Term lab = MkAtomTerm(Yap_LookupAtom(global_flags_setup[i].name));
|
||||||
@ -748,7 +762,8 @@ static Int cont_yap_flag( USES_REGS1) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (i >= gmax) {
|
if (i >= gmax) {
|
||||||
Yap_unify( ARG1, MkAtomTerm( Yap_LookupAtom(local_flags_setup[i-gmax].name ) ) );
|
Yap_unify(ARG1,
|
||||||
|
MkAtomTerm(Yap_LookupAtom(local_flags_setup[i - gmax].name)));
|
||||||
if (i == gmax + lmax - 1)
|
if (i == gmax + lmax - 1)
|
||||||
do_cut(0);
|
do_cut(0);
|
||||||
} else {
|
} else {
|
||||||
@ -773,8 +788,10 @@ static Int yap_flag(USES_REGS1) {
|
|||||||
}
|
}
|
||||||
do_cut(0);
|
do_cut(0);
|
||||||
|
|
||||||
if (!isatom(tflag)) return false;
|
if (!isatom(tflag))
|
||||||
if (!isatom(modt)) return false;
|
return false;
|
||||||
|
if (!isatom(modt))
|
||||||
|
return false;
|
||||||
if (IsVarTerm(Deref(ARG2))) {
|
if (IsVarTerm(Deref(ARG2))) {
|
||||||
Term flag = getYapFlagInModule(tflag, modt);
|
Term flag = getYapFlagInModule(tflag, modt);
|
||||||
if (flag == 0)
|
if (flag == 0)
|
||||||
@ -806,9 +823,11 @@ static Int cont_prolog_flag(USES_REGS1) {
|
|||||||
if (i >= gmax + lmax) {
|
if (i >= gmax + lmax) {
|
||||||
cut_fail();
|
cut_fail();
|
||||||
} else if (i >= gmax) {
|
} else if (i >= gmax) {
|
||||||
Yap_unify( ARG1, ( f = MkAtomTerm( Yap_LookupAtom(local_flags_setup[i-gmax].name ) ) ));
|
Yap_unify(ARG1, (f = MkAtomTerm(
|
||||||
|
Yap_LookupAtom(local_flags_setup[i - gmax].name))));
|
||||||
} else {
|
} else {
|
||||||
Yap_unify( ARG1, (f = MkAtomTerm( Yap_LookupAtom( global_flags_setup[i].name ) ) ) );
|
Yap_unify(ARG1,
|
||||||
|
(f = MkAtomTerm(Yap_LookupAtom(global_flags_setup[i].name))));
|
||||||
}
|
}
|
||||||
EXTRA_CBACK_ARG(3, 1) = MkIntTerm(++i);
|
EXTRA_CBACK_ARG(3, 1) = MkIntTerm(++i);
|
||||||
flag = getYapFlag(f);
|
flag = getYapFlag(f);
|
||||||
@ -834,7 +853,7 @@ static Int prolog_flag(USES_REGS1) {
|
|||||||
return cont_prolog_flag(PASS_REGS1);
|
return cont_prolog_flag(PASS_REGS1);
|
||||||
}
|
}
|
||||||
do_cut(0);
|
do_cut(0);
|
||||||
if (IsVarTerm( Deref(ARG2) ) ) {
|
if (IsVarTerm(Deref(ARG3))) {
|
||||||
Term flag = getYapFlag(Deref(ARG1));
|
Term flag = getYapFlag(Deref(ARG1));
|
||||||
if (flag == 0)
|
if (flag == 0)
|
||||||
return false;
|
return false;
|
||||||
@ -843,6 +862,41 @@ static Int prolog_flag(USES_REGS1) {
|
|||||||
return setYapFlag(Deref(ARG1), Deref(ARG3));
|
return setYapFlag(Deref(ARG1), Deref(ARG3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Int cont_current_prolog_flag(USES_REGS1) {
|
||||||
|
int i = IntOfTerm(EXTRA_CBACK_ARG(2, 1));
|
||||||
|
while (i < GLOBAL_flagCount + LOCAL_flagCount) {
|
||||||
|
int gmax = GLOBAL_flagCount;
|
||||||
|
int lmax = LOCAL_flagCount;
|
||||||
|
Term flag, f;
|
||||||
|
|
||||||
|
if (i >= gmax + lmax) {
|
||||||
|
cut_fail();
|
||||||
|
} else if (i >= gmax) {
|
||||||
|
Yap_unify(ARG1, (f = MkAtomTerm(
|
||||||
|
Yap_LookupAtom(local_flags_setup[i - gmax].name))));
|
||||||
|
} else {
|
||||||
|
Yap_unify(ARG1,
|
||||||
|
(f = MkAtomTerm(Yap_LookupAtom(global_flags_setup[i].name))));
|
||||||
|
}
|
||||||
|
EXTRA_CBACK_ARG(2, 1) = MkIntTerm(++i);
|
||||||
|
flag = getYapFlag(f);
|
||||||
|
if (!Yap_unify(f, ARG2))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
cut_fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Int current_prolog_flag(USES_REGS1) {
|
||||||
|
if (IsVarTerm(Deref(ARG1))) {
|
||||||
|
EXTRA_CBACK_ARG(3, 1) = MkIntTerm(0);
|
||||||
|
return cont_current_prolog_flag(PASS_REGS1);
|
||||||
|
}
|
||||||
|
do_cut(0);
|
||||||
|
Term flag = getYapFlag(Deref(ARG1));
|
||||||
|
if (flag == 0)
|
||||||
|
return false;
|
||||||
|
return Yap_unify(flag, ARG2);
|
||||||
|
}
|
||||||
|
|
||||||
/** @pred current_prolog_flag(? _Flag_,- _Value_) is iso
|
/** @pred current_prolog_flag(? _Flag_,- _Value_) is iso
|
||||||
|
|
||||||
@ -851,7 +905,7 @@ yap_flag/2 with the second argument unbound, and unifying the
|
|||||||
returned second argument with _Value_.
|
returned second argument with _Value_.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
static Int current_prolog_flag( USES_REGS1 ) {
|
static Int current_prolog_flag2(USES_REGS1) {
|
||||||
Term tflag = Deref(ARG1);
|
Term tflag = Deref(ARG1);
|
||||||
Term tout = 0;
|
Term tout = 0;
|
||||||
FlagEntry *fv;
|
FlagEntry *fv;
|
||||||
@ -881,27 +935,24 @@ static Int current_prolog_flag( USES_REGS1 ) {
|
|||||||
return (Yap_unify(ARG2, tout));
|
return (Yap_unify(ARG2, tout));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Yap_setModuleFlags(ModEntry *new, ModEntry *cme)
|
void Yap_setModuleFlags(ModEntry *new, ModEntry *cme) {
|
||||||
{
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
|
|
||||||
Atom at = new->AtomOfME;
|
Atom at = new->AtomOfME;
|
||||||
if (at == AtomProlog || CurrentModule == PROLOG_MODULE) {
|
if (at == AtomProlog || CurrentModule == PROLOG_MODULE) {
|
||||||
new->flags = M_SYSTEM | UNKNOWN_ERROR |M_CHARESCAPE | DBLQ_CODES | BCKQ_STRING;
|
new->flags =
|
||||||
|
M_SYSTEM | UNKNOWN_ERROR | M_CHARESCAPE | DBLQ_CODES | BCKQ_STRING;
|
||||||
if (at == AtomUser)
|
if (at == AtomUser)
|
||||||
new->flags = UNKNOWN_ERROR | M_CHARESCAPE | DBLQ_CODES | BCKQ_STRING;
|
new->flags = UNKNOWN_ERROR | M_CHARESCAPE | DBLQ_CODES | BCKQ_STRING;
|
||||||
} else if (cme &&
|
} else if (cme && cme->flags && cme != new) {
|
||||||
cme->flags && cme != new) {
|
|
||||||
new->flags = cme->flags;
|
new->flags = cme->flags;
|
||||||
} else {
|
} else {
|
||||||
new->flags = ( UNKNOWN_ERROR | M_CHARESCAPE | DBLQ_CODES | BCKQ_STRING
|
new->flags = (UNKNOWN_ERROR | M_CHARESCAPE | DBLQ_CODES | BCKQ_STRING);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
// printf("cme=%s new=%s flags=%x\n",cme,at->StrOfAE,new->flags);
|
// printf("cme=%s new=%s flags=%x\n",cme,at->StrOfAE,new->flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool setYapFlag( Term tflag, Term t2 )
|
bool setYapFlag(Term tflag, Term t2) {
|
||||||
{
|
|
||||||
FlagEntry *fv;
|
FlagEntry *fv;
|
||||||
flag_term *tarr;
|
flag_term *tarr;
|
||||||
if (IsVarTerm(tflag)) {
|
if (IsVarTerm(tflag)) {
|
||||||
@ -911,8 +962,10 @@ bool setYapFlag( Term tflag, Term t2 )
|
|||||||
if (IsApplTerm(tflag) && FunctorOfTerm(tflag) == FunctorModule) {
|
if (IsApplTerm(tflag) && FunctorOfTerm(tflag) == FunctorModule) {
|
||||||
Term modt;
|
Term modt;
|
||||||
tflag = Yap_StripModule(tflag, &modt);
|
tflag = Yap_StripModule(tflag, &modt);
|
||||||
if (!isatom(tflag)) return false;
|
if (!isatom(tflag))
|
||||||
if (!isatom(modt)) return false;
|
return false;
|
||||||
|
if (!isatom(modt))
|
||||||
|
return false;
|
||||||
return setYapFlagInModule(tflag, t2, modt);
|
return setYapFlagInModule(tflag, t2, modt);
|
||||||
}
|
}
|
||||||
if (!IsAtomTerm(tflag)) {
|
if (!IsAtomTerm(tflag)) {
|
||||||
@ -929,13 +982,22 @@ bool setYapFlag( Term tflag, Term t2 )
|
|||||||
} else if (fl == TermWarning) {
|
} else if (fl == TermWarning) {
|
||||||
Yap_Warning("Flag %s does not exist", RepAtom(AtomOfTerm(fl))->StrOfAE);
|
Yap_Warning("Flag %s does not exist", RepAtom(AtomOfTerm(fl))->StrOfAE);
|
||||||
} else {
|
} else {
|
||||||
Yap_Error(DOMAIN_ERROR_PROLOG_FLAG, fl, "trying to set unknown flag ~s", AtomName(AtomOfTerm(fl)));
|
Yap_Error(DOMAIN_ERROR_PROLOG_FLAG, fl, "trying to set unknown flag ~s",
|
||||||
|
AtomName(AtomOfTerm(fl)));
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (fv->global)
|
if (fv->global) {
|
||||||
|
CACHE_REGS
|
||||||
|
switch (fv->FlagOfVE) {
|
||||||
|
case UNKNOWN_FLAG:
|
||||||
|
case CHARACTER_ESCAPES_FLAG:
|
||||||
|
case BACKQUOTED_STRING_FLAG:
|
||||||
|
return setYapFlagInModule(tflag, t2, CurrentModule);
|
||||||
|
default:
|
||||||
tarr = GLOBAL_Flags;
|
tarr = GLOBAL_Flags;
|
||||||
else {
|
}
|
||||||
|
} else {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
tarr = LOCAL_Flags;
|
tarr = LOCAL_Flags;
|
||||||
}
|
}
|
||||||
@ -954,8 +1016,7 @@ bool setYapFlag( Term tflag, Term t2 )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Term getYapFlag( Term tflag )
|
Term getYapFlag(Term tflag) {
|
||||||
{
|
|
||||||
FlagEntry *fv;
|
FlagEntry *fv;
|
||||||
flag_term *tarr;
|
flag_term *tarr;
|
||||||
if (IsVarTerm(tflag)) {
|
if (IsVarTerm(tflag)) {
|
||||||
@ -965,8 +1026,10 @@ Term getYapFlag( Term tflag )
|
|||||||
if (IsApplTerm(tflag) && FunctorOfTerm(tflag) == FunctorModule) {
|
if (IsApplTerm(tflag) && FunctorOfTerm(tflag) == FunctorModule) {
|
||||||
Term modt;
|
Term modt;
|
||||||
tflag = Yap_StripModule(tflag, &modt);
|
tflag = Yap_StripModule(tflag, &modt);
|
||||||
if (!isatom(tflag)) return false;
|
if (!isatom(tflag))
|
||||||
if (!isatom(modt)) return false;
|
return false;
|
||||||
|
if (!isatom(modt))
|
||||||
|
return false;
|
||||||
return getYapFlagInModule(tflag, modt);
|
return getYapFlagInModule(tflag, modt);
|
||||||
}
|
}
|
||||||
if (!IsAtomTerm(tflag)) {
|
if (!IsAtomTerm(tflag)) {
|
||||||
@ -1036,7 +1099,6 @@ static Int no_source(USES_REGS1) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@pred source_mode(- _O_,+ _N_)
|
@pred source_mode(- _O_,+ _N_)
|
||||||
|
|
||||||
@ -1046,9 +1108,7 @@ database. _O_ is unified with the previous state and the mode is set
|
|||||||
according to _N_.
|
according to _N_.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
static Int
|
static Int source_mode(USES_REGS1) {
|
||||||
source_mode( USES_REGS1 )
|
|
||||||
{
|
|
||||||
Term targ;
|
Term targ;
|
||||||
bool current = trueGlobalPrologFlag(SOURCE_FLAG);
|
bool current = trueGlobalPrologFlag(SOURCE_FLAG);
|
||||||
if (current && !Yap_unify_constant(ARG1, TermTrue))
|
if (current && !Yap_unify_constant(ARG1, TermTrue))
|
||||||
@ -1060,14 +1120,14 @@ source_mode( USES_REGS1 )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool setInitialValue(bool bootstrap, flag_func f, const char *s,
|
||||||
static bool
|
flag_term *tarr) {
|
||||||
setInitialValue( bool bootstrap, flag_func f, const char *s,flag_term *tarr )
|
|
||||||
{
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
if (f == boolean) {
|
if (f == boolean) {
|
||||||
if (!bootstrap) { return 0; }
|
if (!bootstrap) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (!strcmp(s, "true")) {
|
if (!strcmp(s, "true")) {
|
||||||
tarr->at = TermTrue;
|
tarr->at = TermTrue;
|
||||||
return true;
|
return true;
|
||||||
@ -1084,14 +1144,18 @@ setInitialValue( bool bootstrap, flag_func f, const char *s,flag_term *tarr )
|
|||||||
tarr->at = TermFalse;
|
tarr->at = TermFalse;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, TermNil, "~s should be either true (on) or false (off)", s);
|
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, TermNil,
|
||||||
|
"~s should be either true (on) or false (off)", s);
|
||||||
return false;
|
return false;
|
||||||
} else if (f == nat) {
|
} else if (f == nat) {
|
||||||
if (!bootstrap) { return 0; }
|
if (!bootstrap) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
UInt r = strtoul(s, NULL, 10);
|
UInt r = strtoul(s, NULL, 10);
|
||||||
Term t;
|
Term t;
|
||||||
if (errno) {
|
if (errno) {
|
||||||
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, TermNil, "~s should be a positive integer)", s);
|
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, TermNil,
|
||||||
|
"~s should be a positive integer)", s);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
@ -1103,7 +1167,9 @@ setInitialValue( bool bootstrap, flag_func f, const char *s,flag_term *tarr )
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (f == at2n) {
|
} else if (f == at2n) {
|
||||||
if (!bootstrap) { return 0; }
|
if (!bootstrap) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (!strcmp(s, "INT_MAX")) {
|
if (!strcmp(s, "INT_MAX")) {
|
||||||
tarr->at = MkIntTerm(Int_MAX);
|
tarr->at = MkIntTerm(Int_MAX);
|
||||||
return true;
|
return true;
|
||||||
@ -1128,22 +1194,58 @@ setInitialValue( bool bootstrap, flag_func f, const char *s,flag_term *tarr )
|
|||||||
tarr->at = MkIntTerm(atol(YAP_NUMERIC_VERSION));
|
tarr->at = MkIntTerm(atol(YAP_NUMERIC_VERSION));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, TermNil, "~s should be either true (on) or false (off)", s);
|
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, TermNil,
|
||||||
|
"~s should be either true (on) or false (off)", s);
|
||||||
return false;
|
return false;
|
||||||
} else if (f == isatom) {
|
} else if (f == isatom) {
|
||||||
if (!bootstrap) { return false; }
|
if (!bootstrap) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Atom r = Yap_LookupAtom(s);
|
Atom r = Yap_LookupAtom(s);
|
||||||
if (errno) {
|
if (errno) {
|
||||||
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, TermNil, "~s should be a positive integer)", s);
|
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, TermNil,
|
||||||
|
"~s should be a positive integer)", s);
|
||||||
tarr->at = TermNil;
|
tarr->at = TermNil;
|
||||||
}
|
}
|
||||||
tarr->at = MkAtomTerm(r);
|
tarr->at = MkAtomTerm(r);
|
||||||
return true;
|
return true;
|
||||||
|
} else if (f == options) {
|
||||||
|
CACHE_REGS
|
||||||
|
char tmp[512];
|
||||||
|
Term t0;
|
||||||
|
if (bootstrap) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
t0 = AbsPair(HR);
|
||||||
|
while (true) {
|
||||||
|
int i = 0, ch = s[0];
|
||||||
|
while (ch != '\0' && ch != ';') {
|
||||||
|
if (ch != ' ')
|
||||||
|
tmp[i++] = ch;
|
||||||
|
s++;
|
||||||
|
ch = *s;
|
||||||
|
}
|
||||||
|
tmp[i] = '\0';
|
||||||
|
HR += 2;
|
||||||
|
HR[-2] = MkAtomTerm(Yap_LookupAtom(tmp));
|
||||||
|
if (ch) {
|
||||||
|
HR[-1] = AbsPair(HR);
|
||||||
|
s++;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
HR[-1] = TermNil;
|
||||||
|
tarr->DBT = Yap_StoreTermInDB(t0, 2);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Term t0;
|
Term t0;
|
||||||
if (bootstrap) { return false; }
|
if (bootstrap) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
t0 = Yap_StringToTerm(s, strlen(s)+1, &LOCAL_encoding, 1200, NULL);
|
t0 = Yap_StringToTerm(s, strlen(s) + 1, &LOCAL_encoding, GLOBAL_MaxPriority,
|
||||||
|
NULL);
|
||||||
if (!t0)
|
if (!t0)
|
||||||
return false;
|
return false;
|
||||||
if (IsAtomTerm(t0) || IsIntTerm(t0)) {
|
if (IsAtomTerm(t0) || IsIntTerm(t0)) {
|
||||||
@ -1169,32 +1271,28 @@ setInitialValue( bool bootstrap, flag_func f, const char *s,flag_term *tarr )
|
|||||||
|
|
||||||
#define PAR(x, y, z, w) z
|
#define PAR(x, y, z, w) z
|
||||||
|
|
||||||
typedef enum prolog_flag_property_enum_choices
|
typedef enum prolog_flag_property_enum_choices {
|
||||||
{
|
|
||||||
PROLOG_FLAG_PROPERTY_DEFS()
|
PROLOG_FLAG_PROPERTY_DEFS()
|
||||||
} prolog_flag_property_choices_t;
|
} prolog_flag_property_choices_t;
|
||||||
|
|
||||||
#undef PAR
|
#undef PAR
|
||||||
|
|
||||||
#define PAR(x,y,z, w) { x , y, z, w }
|
#define PAR(x, y, z, w) \
|
||||||
|
{ x, y, z, w }
|
||||||
|
|
||||||
|
static const param2_t prolog_flag_property_defs[] = {
|
||||||
static const param2_t prolog_flag_property_defs[] =
|
PROLOG_FLAG_PROPERTY_DEFS()};
|
||||||
{
|
|
||||||
PROLOG_FLAG_PROPERTY_DEFS()
|
|
||||||
};
|
|
||||||
#undef PAR
|
#undef PAR
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
do_prolog_flag_property (Term tflag, Term opts USES_REGS)
|
do_prolog_flag_property(Term tflag,
|
||||||
{ /* Init current_prolog_flag */
|
Term opts USES_REGS) { /* Init current_prolog_flag */
|
||||||
FlagEntry *fv;
|
FlagEntry *fv;
|
||||||
xarg *args;
|
xarg *args;
|
||||||
prolog_flag_property_choices_t i;
|
prolog_flag_property_choices_t i;
|
||||||
bool rc = true;
|
bool rc = true;
|
||||||
args = Yap_ArgList2ToVector ( opts, prolog_flag_property_defs, PROLOG_FLAG_PROPERTY_END );
|
args = Yap_ArgList2ToVector(opts, prolog_flag_property_defs,
|
||||||
|
PROLOG_FLAG_PROPERTY_END);
|
||||||
if (args == NULL) {
|
if (args == NULL) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -1213,19 +1311,19 @@ do_prolog_flag_property (Term tflag, Term opts USES_REGS)
|
|||||||
switch (i) {
|
switch (i) {
|
||||||
case PROLOG_FLAG_PROPERTY_ACCESS:
|
case PROLOG_FLAG_PROPERTY_ACCESS:
|
||||||
if (fv->rw)
|
if (fv->rw)
|
||||||
rc = rc &&
|
rc = rc && Yap_unify(TermReadWrite,
|
||||||
Yap_unify(TermReadWrite, args[PROLOG_FLAG_PROPERTY_ACCESS].tvalue);
|
args[PROLOG_FLAG_PROPERTY_ACCESS].tvalue);
|
||||||
else
|
else
|
||||||
rc = rc &&
|
rc = rc && Yap_unify(TermReadOnly,
|
||||||
Yap_unify(TermReadOnly, args[PROLOG_FLAG_PROPERTY_ACCESS].tvalue);
|
args[PROLOG_FLAG_PROPERTY_ACCESS].tvalue);
|
||||||
break;
|
break;
|
||||||
case PROLOG_FLAG_PROPERTY_TYPE:
|
case PROLOG_FLAG_PROPERTY_TYPE:
|
||||||
if (fv->type == boolean)
|
if (fv->type == boolean)
|
||||||
rc = rc &&
|
rc = rc &&
|
||||||
Yap_unify(TermBoolean, args[PROLOG_FLAG_PROPERTY_TYPE].tvalue);
|
Yap_unify(TermBoolean, args[PROLOG_FLAG_PROPERTY_TYPE].tvalue);
|
||||||
else if (fv->type == isatom)
|
else if (fv->type == isatom)
|
||||||
rc = rc &&
|
rc =
|
||||||
Yap_unify(TermAtom, args[PROLOG_FLAG_PROPERTY_TYPE].tvalue);
|
rc && Yap_unify(TermAtom, args[PROLOG_FLAG_PROPERTY_TYPE].tvalue);
|
||||||
else if (fv->type == nat)
|
else if (fv->type == nat)
|
||||||
rc = rc &&
|
rc = rc &&
|
||||||
|
|
||||||
@ -1234,8 +1332,8 @@ do_prolog_flag_property (Term tflag, Term opts USES_REGS)
|
|||||||
rc = rc &&
|
rc = rc &&
|
||||||
Yap_unify(TermFloat, args[PROLOG_FLAG_PROPERTY_TYPE].tvalue);
|
Yap_unify(TermFloat, args[PROLOG_FLAG_PROPERTY_TYPE].tvalue);
|
||||||
else
|
else
|
||||||
rc = rc &&
|
rc =
|
||||||
Yap_unify(TermTerm, args[PROLOG_FLAG_PROPERTY_TYPE].tvalue);
|
rc && Yap_unify(TermTerm, args[PROLOG_FLAG_PROPERTY_TYPE].tvalue);
|
||||||
break;
|
break;
|
||||||
case PROLOG_FLAG_PROPERTY_KEEP:
|
case PROLOG_FLAG_PROPERTY_KEEP:
|
||||||
rc = rc && false;
|
rc = rc && false;
|
||||||
@ -1262,9 +1360,7 @@ do_prolog_flag_property (Term tflag, Term opts USES_REGS)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int cont_prolog_flag_property(USES_REGS1) { /* current_prolog_flag */
|
||||||
cont_prolog_flag_property (USES_REGS1)
|
|
||||||
{ /* current_prolog_flag */
|
|
||||||
int i = IntOfTerm(EXTRA_CBACK_ARG(2, 1));
|
int i = IntOfTerm(EXTRA_CBACK_ARG(2, 1));
|
||||||
|
|
||||||
while (i < GLOBAL_flagCount + LOCAL_flagCount) {
|
while (i < GLOBAL_flagCount + LOCAL_flagCount) {
|
||||||
@ -1277,8 +1373,7 @@ cont_prolog_flag_property (USES_REGS1)
|
|||||||
} else if (i >= gmax) {
|
} else if (i >= gmax) {
|
||||||
lab = MkAtomTerm(Yap_LookupAtom(local_flags_setup[i - gmax].name));
|
lab = MkAtomTerm(Yap_LookupAtom(local_flags_setup[i - gmax].name));
|
||||||
} else {
|
} else {
|
||||||
if (i == UNKNOWN_FLAG ||
|
if (i == UNKNOWN_FLAG || i == CHARACTER_ESCAPES_FLAG ||
|
||||||
i == CHARACTER_ESCAPES_FLAG ||
|
|
||||||
i == BACKQUOTED_STRING_FLAG) {
|
i == BACKQUOTED_STRING_FLAG) {
|
||||||
Term labs[2];
|
Term labs[2];
|
||||||
labs[0] = MkVarTerm();
|
labs[0] = MkVarTerm();
|
||||||
@ -1304,12 +1399,11 @@ and `term` (that is, any ground term)
|
|||||||
|
|
||||||
* `access(+_Access_)` with _Access_ one of `read_only` or `read_write`
|
* `access(+_Access_)` with _Access_ one of `read_only` or `read_write`
|
||||||
|
|
||||||
* `scope(+_Scope_) the flag aplies to a `thread`, to a `module`, or is `global` to the system.
|
* `scope(+_Scope_) the flag aplies to a `thread`, to a `module`, or is
|
||||||
|
`global` to the system.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
static Int
|
static Int prolog_flag_property(USES_REGS1) { /* Init current_prolog_flag */
|
||||||
prolog_flag_property (USES_REGS1)
|
|
||||||
{ /* Init current_prolog_flag */
|
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
/* make valgrind happy by always filling in memory */
|
/* make valgrind happy by always filling in memory */
|
||||||
EXTRA_CBACK_ARG(2, 1) = MkIntTerm(0);
|
EXTRA_CBACK_ARG(2, 1) = MkIntTerm(0);
|
||||||
@ -1335,10 +1429,7 @@ prolog_flag_property (USES_REGS1)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void newFlag(Term fl, Term val) {
|
||||||
static void
|
|
||||||
newFlag( Term fl, Term val )
|
|
||||||
{
|
|
||||||
flag_info f;
|
flag_info f;
|
||||||
int i = GLOBAL_flagCount;
|
int i = GLOBAL_flagCount;
|
||||||
|
|
||||||
@ -1355,21 +1446,21 @@ newFlag( Term fl, Term val )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int do_create_prolog_flag(USES_REGS1) {
|
||||||
do_create_prolog_flag( USES_REGS1 )
|
|
||||||
{
|
|
||||||
FlagEntry *fv;
|
FlagEntry *fv;
|
||||||
xarg *args;
|
xarg *args;
|
||||||
prolog_flag_property_choices_t i;
|
prolog_flag_property_choices_t i;
|
||||||
Term tflag = Deref(ARG1), tval = Deref(ARG2), opts = Deref(ARG3);
|
Term tflag = Deref(ARG1), tval = Deref(ARG2), opts = Deref(ARG3);
|
||||||
|
|
||||||
args = Yap_ArgList2ToVector ( opts, prolog_flag_property_defs, PROLOG_FLAG_PROPERTY_END );
|
args = Yap_ArgList2ToVector(opts, prolog_flag_property_defs,
|
||||||
|
PROLOG_FLAG_PROPERTY_END);
|
||||||
if (args == NULL) {
|
if (args == NULL) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
fv = GetFlagProp(AtomOfTerm(tflag));
|
fv = GetFlagProp(AtomOfTerm(tflag));
|
||||||
if (fv) {
|
if (fv) {
|
||||||
if (args[PROLOG_FLAG_PROPERTY_KEEP].used && args[PROLOG_FLAG_PROPERTY_KEEP].tvalue == TermTrue)
|
if (args[PROLOG_FLAG_PROPERTY_KEEP].used &&
|
||||||
|
args[PROLOG_FLAG_PROPERTY_KEEP].tvalue == TermTrue)
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
newFlag(tflag, tval);
|
newFlag(tflag, tval);
|
||||||
@ -1386,8 +1477,7 @@ do_create_prolog_flag( USES_REGS1 )
|
|||||||
else
|
else
|
||||||
fv->rw = false;
|
fv->rw = false;
|
||||||
break;
|
break;
|
||||||
case PROLOG_FLAG_PROPERTY_TYPE:
|
case PROLOG_FLAG_PROPERTY_TYPE: {
|
||||||
{
|
|
||||||
Term ttype = args[PROLOG_FLAG_PROPERTY_TYPE].tvalue;
|
Term ttype = args[PROLOG_FLAG_PROPERTY_TYPE].tvalue;
|
||||||
if (ttype == TermBoolean)
|
if (ttype == TermBoolean)
|
||||||
fv->type = boolean;
|
fv->type = boolean;
|
||||||
@ -1397,11 +1487,9 @@ do_create_prolog_flag( USES_REGS1 )
|
|||||||
fv->type = isfloat;
|
fv->type = isfloat;
|
||||||
else
|
else
|
||||||
fv->type = isground;
|
fv->type = isground;
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case PROLOG_FLAG_PROPERTY_SCOPE:
|
case PROLOG_FLAG_PROPERTY_SCOPE:
|
||||||
return
|
return false;
|
||||||
false;
|
|
||||||
case PROLOG_FLAG_PROPERTY_END:
|
case PROLOG_FLAG_PROPERTY_END:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1409,30 +1497,32 @@ do_create_prolog_flag( USES_REGS1 )
|
|||||||
}
|
}
|
||||||
// UNLOCK(GLOBAL_Prolog_Flag[sno].prolog_flaglock);
|
// UNLOCK(GLOBAL_Prolog_Flag[sno].prolog_flaglock);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init System Prolog flags. This is done in two phases:
|
* Init System Prolog flags. This is done in two phases:
|
||||||
* early on, it takes care of the atomic flags that are required by other modules;
|
* early on, it takes care of the atomic flags that are required by other
|
||||||
|
*modules;
|
||||||
* later, it looks at flags that are structured terms
|
* later, it looks at flags that are structured terms
|
||||||
*
|
*
|
||||||
* @param bootstrap: wether this is done before stack initialization, or afterwards.
|
* @param bootstrap: wether this is done before stack initialization, or
|
||||||
|
*afterwards.
|
||||||
* Complex terms can only be built in the second step.
|
* Complex terms can only be built in the second step.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void Yap_InitFlags(bool bootstrap) {
|
||||||
Yap_InitFlags( bool bootstrap) {
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
tr_fr_ptr tr0 = TR;
|
tr_fr_ptr tr0 = TR;
|
||||||
flag_info *f =
|
flag_info *f = global_flags_setup;
|
||||||
global_flags_setup;
|
|
||||||
GLOBAL_flagCount = 0;
|
GLOBAL_flagCount = 0;
|
||||||
if (bootstrap) {
|
if (bootstrap) {
|
||||||
GLOBAL_Flags = (union flagTerm *)Yap_AllocCodeSpace(sizeof(union flagTerm)*(2*sizeof(global_flags_setup)/sizeof(flag_info)));
|
GLOBAL_Flags = (union flagTerm *)Yap_AllocCodeSpace(
|
||||||
|
sizeof(union flagTerm) *
|
||||||
|
(2 * sizeof(global_flags_setup) / sizeof(flag_info)));
|
||||||
}
|
}
|
||||||
while (f->name != NULL) {
|
while (f->name != NULL) {
|
||||||
bool itf = setInitialValue( bootstrap, f->def, f->init, GLOBAL_Flags+GLOBAL_flagCount );
|
bool itf = setInitialValue(bootstrap, f->def, f->init,
|
||||||
|
GLOBAL_Flags + GLOBAL_flagCount);
|
||||||
if (itf) {
|
if (itf) {
|
||||||
initFlag(f, GLOBAL_flagCount, true);
|
initFlag(f, GLOBAL_flagCount, true);
|
||||||
}
|
}
|
||||||
@ -1442,12 +1532,14 @@ Yap_InitFlags( bool bootstrap) {
|
|||||||
LOCAL_flagCount = 0;
|
LOCAL_flagCount = 0;
|
||||||
int nflags = sizeof(local_flags_setup) / sizeof(flag_info);
|
int nflags = sizeof(local_flags_setup) / sizeof(flag_info);
|
||||||
if (bootstrap)
|
if (bootstrap)
|
||||||
LOCAL_Flags = (union flagTerm *)Yap_AllocCodeSpace(sizeof(union flagTerm)*nflags);
|
LOCAL_Flags =
|
||||||
f =
|
(union flagTerm *)Yap_AllocCodeSpace(sizeof(union flagTerm) * nflags);
|
||||||
local_flags_setup;
|
f = local_flags_setup;
|
||||||
while (f->name != NULL) {
|
while (f->name != NULL) {
|
||||||
bool itf = setInitialValue( bootstrap, f->def, f->init, LOCAL_Flags+LOCAL_flagCount );
|
bool itf = setInitialValue(bootstrap, f->def, f->init,
|
||||||
// Term itf = Yap_StringToTerm(f->init, strlen(f->init)+1, LOCAL_encoding, 1200, &tp);
|
LOCAL_Flags + LOCAL_flagCount);
|
||||||
|
// Term itf = Yap_StringToTerm(f->init, strlen(f->init)+1,
|
||||||
|
// LOCAL_encoding, GLOBAL_MaxPriority, &tp);
|
||||||
if (itf) {
|
if (itf) {
|
||||||
initFlag(f, LOCAL_flagCount, false);
|
initFlag(f, LOCAL_flagCount, false);
|
||||||
}
|
}
|
||||||
@ -1455,23 +1547,30 @@ Yap_InitFlags( bool bootstrap) {
|
|||||||
f++;
|
f++;
|
||||||
}
|
}
|
||||||
if (!bootstrap) {
|
if (!bootstrap) {
|
||||||
Yap_InitCPredBack("current_prolog_flag", 2, 1, current_prolog_flag, cont_yap_flag, 0);
|
Yap_InitCPredBack("current_prolog_flag", 2, 1, current_prolog_flag,
|
||||||
|
cont_yap_flag, 0);
|
||||||
TR = tr0;
|
TR = tr0;
|
||||||
/** @pred prolog_flag(? _Flag_,- _Value__)
|
/** @pred prolog_flag(? _Flag_,- _Value__)
|
||||||
|
|
||||||
Obtain the value for a YAP Prolog flag, same as current_prolog_flag/2_.
|
Obtain the value for a YAP Prolog flag, same as current_prolog_flag/2_.
|
||||||
*/
|
*/
|
||||||
Yap_InitCPredBack("prolog_flag", 3, 1, prolog_flag, cont_yap_flag, 0);
|
Yap_InitCPredBack("prolog_flag", 3, 1, current_prolog_flag, cont_yap_flag,
|
||||||
Yap_InitCPredBack("prolog_flag", 2, 1, prolog_flag, cont_yap_flag, 0);
|
0);
|
||||||
|
Yap_InitCPredBack("yap_flag", 3, 1, prolog_flag, cont_yap_flag, 0);
|
||||||
|
Yap_InitCPredBack("prolog_flag", 2, 1, current_prolog_flag2,
|
||||||
|
cont_current_prolog_flag, 0);
|
||||||
|
Yap_InitCPredBack("current_prolog_flag", 2, 1, current_prolog_flag2,
|
||||||
|
cont_current_prolog_flag, 0);
|
||||||
Yap_InitCPred("set_prolog_flag", 2, set_prolog_flag, SyncPredFlag);
|
Yap_InitCPred("set_prolog_flag", 2, set_prolog_flag, SyncPredFlag);
|
||||||
Yap_InitCPred("$create_prolog_flag", 3, do_create_prolog_flag, SyncPredFlag);
|
Yap_InitCPred("$create_prolog_flag", 3, do_create_prolog_flag,
|
||||||
|
SyncPredFlag);
|
||||||
Yap_InitCPredBack("yap_flag", 2, 1, yap_flag, cont_yap_flag, 0);
|
Yap_InitCPredBack("yap_flag", 2, 1, yap_flag, cont_yap_flag, 0);
|
||||||
Yap_InitCPredBack("prolog_flag_property", 2, 1, prolog_flag_property,cont_prolog_flag_property, 0);
|
Yap_InitCPredBack("prolog_flag_property", 2, 1, prolog_flag_property,
|
||||||
|
cont_prolog_flag_property, 0);
|
||||||
Yap_InitCPred("source", 0, source, SyncPredFlag);
|
Yap_InitCPred("source", 0, source, SyncPredFlag);
|
||||||
Yap_InitCPred("no_source", 0, no_source, SyncPredFlag);
|
Yap_InitCPred("no_source", 0, no_source, SyncPredFlag);
|
||||||
Yap_InitCPred("source_mode", 2, source_mode, SyncPredFlag);
|
Yap_InitCPred("source_mode", 2, source_mode, SyncPredFlag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Accessing and changing the flags for a predicate */
|
/* Accessing and changing the flags for a predicate */
|
||||||
|
39
C/heapgc.c
@ -1,4 +1,4 @@
|
|||||||
/*************************************************************************
|
/**************************************************************************
|
||||||
* *
|
* *
|
||||||
* YAP Prolog *
|
* YAP Prolog *
|
||||||
* *
|
* *
|
||||||
@ -45,15 +45,15 @@ static void mark_db_fixed(CELL * CACHE_TYPE);
|
|||||||
static void mark_regs(tr_fr_ptr CACHE_TYPE);
|
static void mark_regs(tr_fr_ptr CACHE_TYPE);
|
||||||
static void mark_trail(tr_fr_ptr, tr_fr_ptr, CELL *, choiceptr CACHE_TYPE);
|
static void mark_trail(tr_fr_ptr, tr_fr_ptr, CELL *, choiceptr CACHE_TYPE);
|
||||||
static void mark_environments(CELL *, size_t, CELL * CACHE_TYPE);
|
static void mark_environments(CELL *, size_t, CELL * CACHE_TYPE);
|
||||||
static void mark_choicepoints(choiceptr, tr_fr_ptr, int CACHE_TYPE);
|
static void mark_choicepoints(choiceptr, tr_fr_ptr, bool CACHE_TYPE);
|
||||||
static void into_relocation_chain(CELL *, CELL * CACHE_TYPE);
|
static void into_relocation_chain(CELL *, CELL * CACHE_TYPE);
|
||||||
static void sweep_trail(choiceptr, tr_fr_ptr CACHE_TYPE);
|
static void sweep_trail(choiceptr, tr_fr_ptr CACHE_TYPE);
|
||||||
static void sweep_environments(CELL *, size_t, CELL * CACHE_TYPE);
|
static void sweep_environments(CELL *, size_t, CELL * CACHE_TYPE);
|
||||||
static void sweep_choicepoints(choiceptr CACHE_TYPE);
|
static void sweep_choicepoints(choiceptr CACHE_TYPE);
|
||||||
static void compact_heap( CACHE_TYPE1 );
|
static void compact_heap( CACHE_TYPE1 );
|
||||||
static void update_relocation_chain(CELL *, CELL * CACHE_TYPE);
|
static void update_relocation_chain(CELL *, CELL * CACHE_TYPE);
|
||||||
static int is_gc_verbose(void);
|
static bool is_gc_verbose(void);
|
||||||
static int is_gc_very_verbose(void);
|
static bool is_gc_very_verbose(void);
|
||||||
static void LeaveGCMode( CACHE_TYPE1 );
|
static void LeaveGCMode( CACHE_TYPE1 );
|
||||||
#ifdef EASY_SHUNTING
|
#ifdef EASY_SHUNTING
|
||||||
static void set_conditionals(tr_fr_ptr CACHE_TYPE);
|
static void set_conditionals(tr_fr_ptr CACHE_TYPE);
|
||||||
@ -1971,7 +1971,7 @@ youngest_cp(choiceptr gc_B, dep_fr_ptr *depfrp)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose USES_REGS)
|
mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, bool very_verbose USES_REGS)
|
||||||
{
|
{
|
||||||
OPCODE
|
OPCODE
|
||||||
trust_lu = Yap_opcode(_trust_logical),
|
trust_lu = Yap_opcode(_trust_logical),
|
||||||
@ -3908,7 +3908,7 @@ compaction_phase(tr_fr_ptr old_TR, CELL *current_env, yamop *curp USES_REGS)
|
|||||||
if (CurrentH0) {
|
if (CurrentH0) {
|
||||||
H0 = CurrentH0;
|
H0 = CurrentH0;
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
/* make sure that we have the correct H_FZ if we're not tabling */
|
/* make sure that we havce the correct H_FZ if we're not tabling */
|
||||||
if (B_FZ == (choiceptr)LCL0)
|
if (B_FZ == (choiceptr)LCL0)
|
||||||
H_FZ = H0;
|
H_FZ = H0;
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
@ -3923,7 +3923,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop USES_REGS)
|
|||||||
volatile tr_fr_ptr old_TR = NULL;
|
volatile tr_fr_ptr old_TR = NULL;
|
||||||
UInt m_time, c_time, time_start, gc_time;
|
UInt m_time, c_time, time_start, gc_time;
|
||||||
Int effectiveness, tot;
|
Int effectiveness, tot;
|
||||||
int gc_trace;
|
bool gc_trace;
|
||||||
UInt gc_phase;
|
UInt gc_phase;
|
||||||
UInt alloc_sz;
|
UInt alloc_sz;
|
||||||
int jmp_res;
|
int jmp_res;
|
||||||
@ -3931,7 +3931,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop USES_REGS)
|
|||||||
heap_cells = HR-H0;
|
heap_cells = HR-H0;
|
||||||
gc_verbose = is_gc_verbose();
|
gc_verbose = is_gc_verbose();
|
||||||
effectiveness = 0;
|
effectiveness = 0;
|
||||||
gc_trace = FALSE;
|
gc_trace = false;
|
||||||
LOCAL_GcCalls++;
|
LOCAL_GcCalls++;
|
||||||
#ifdef INSTRUMENT_GC
|
#ifdef INSTRUMENT_GC
|
||||||
{
|
{
|
||||||
@ -3956,8 +3956,8 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop USES_REGS)
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
check_global();
|
check_global();
|
||||||
#endif
|
#endif
|
||||||
if (Yap_GetValue(AtomGcTrace) != TermNil)
|
if (gcTrace() != TermOff)
|
||||||
gc_trace = 1;
|
gc_trace = true;
|
||||||
if (gc_trace) {
|
if (gc_trace) {
|
||||||
fprintf(stderr, "%% gc\n");
|
fprintf(stderr, "%% gc\n");
|
||||||
} else if (gc_verbose) {
|
} else if (gc_verbose) {
|
||||||
@ -4130,34 +4130,34 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop USES_REGS)
|
|||||||
return effectiveness;
|
return effectiveness;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static bool
|
||||||
is_gc_verbose(void)
|
is_gc_verbose(void)
|
||||||
{
|
{
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
if (LOCAL_PrologMode == BootMode)
|
if (LOCAL_PrologMode == BootMode)
|
||||||
return FALSE;
|
return false;
|
||||||
#ifdef INSTRUMENT_GC
|
#ifdef INSTRUMENT_GC
|
||||||
/* always give info when we are debugging gc */
|
/* always give info when we are debugging gc */
|
||||||
return(TRUE);
|
return true;
|
||||||
#else
|
#else
|
||||||
return(Yap_GetValue(AtomGcVerbose) != TermNil ||
|
Term t = gcTrace();
|
||||||
Yap_GetValue(AtomGcVeryVerbose) != TermNil);
|
return t == TermVerbose || t == TermVeryVerbose;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
bool
|
||||||
Yap_is_gc_verbose(void)
|
Yap_is_gc_verbose(void)
|
||||||
{
|
{
|
||||||
return is_gc_verbose();
|
return is_gc_verbose();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static bool
|
||||||
is_gc_very_verbose(void)
|
is_gc_very_verbose(void)
|
||||||
{
|
{
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
if (LOCAL_PrologMode == BootMode)
|
if (LOCAL_PrologMode == BootMode)
|
||||||
return FALSE;
|
return false;
|
||||||
return Yap_GetValue(AtomGcVeryVerbose) != TermNil;
|
return gcTrace() == TermVeryVerbose;
|
||||||
}
|
}
|
||||||
|
|
||||||
Int
|
Int
|
||||||
@ -4267,6 +4267,7 @@ Yap_locked_gc(Int predarity, CELL *current_env, yamop *nextop)
|
|||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
int res;
|
int res;
|
||||||
#if YAPOR_COPY
|
#if YAPOR_COPY
|
||||||
|
|
||||||
fprintf(stderr, "\n\n***** Trying to call the garbage collector in YAPOR/copying ****\n\n\n");
|
fprintf(stderr, "\n\n***** Trying to call the garbage collector in YAPOR/copying ****\n\n\n");
|
||||||
exit( 1 );
|
exit( 1 );
|
||||||
#endif
|
#endif
|
||||||
|
352
C/init.c
@ -23,6 +23,8 @@ static char SccsId[] = "%W% %G%";
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define __INIT_C__ 1
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "Yap.h"
|
#include "Yap.h"
|
||||||
#include "clause.h"
|
#include "clause.h"
|
||||||
@ -74,15 +76,13 @@ static void InitVersion(void);
|
|||||||
void exit(int);
|
void exit(int);
|
||||||
static void InitWorker(int wid);
|
static void InitWorker(int wid);
|
||||||
|
|
||||||
|
|
||||||
/************** YAP PROLOG GLOBAL VARIABLES *************************/
|
/************** YAP PROLOG GLOBAL VARIABLES *************************/
|
||||||
|
|
||||||
/************* variables related to memory allocation ***************/
|
/************* variables related to memory allocation ***************/
|
||||||
ADDR Yap_HeapBase;
|
ADDR Yap_HeapBase;
|
||||||
|
|
||||||
/************** declarations local to init.c ************************/
|
/************** declarations local to init.c ************************/
|
||||||
static char *optypes[] =
|
static char *optypes[] = {"", "xfx", "xfy", "yfx", "xf", "yf", "fx", "fy"};
|
||||||
{"", "xfx", "xfy", "yfx", "xf", "yf", "fx", "fy"};
|
|
||||||
|
|
||||||
/* OS page size for memory allocation */
|
/* OS page size for memory allocation */
|
||||||
size_t Yap_page_size;
|
size_t Yap_page_size;
|
||||||
@ -93,7 +93,6 @@ int Yap_Portray_delays = FALSE;
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
@defgroup Operators Summary of YAP Predefined Operators
|
@defgroup Operators Summary of YAP Predefined Operators
|
||||||
@ -188,9 +187,7 @@ The following is the list of the declarations of the predefined operators:
|
|||||||
#define fx 6
|
#define fx 6
|
||||||
#define fy 7
|
#define fy 7
|
||||||
|
|
||||||
int
|
int Yap_IsOpType(char *type) {
|
||||||
Yap_IsOpType(char *type)
|
|
||||||
{
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 1; i <= 7; ++i)
|
for (i = 1; i <= 7; ++i)
|
||||||
@ -199,9 +196,7 @@ Yap_IsOpType(char *type)
|
|||||||
return (i <= 7);
|
return (i <= 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int OpDec(int p, const char *type, Atom a, Term m) {
|
||||||
OpDec(int p, const char *type, Atom a, Term m)
|
|
||||||
{
|
|
||||||
int i;
|
int i;
|
||||||
AtomEntry *ae = RepAtom(a);
|
AtomEntry *ae = RepAtom(a);
|
||||||
OpEntry *info;
|
OpEntry *info;
|
||||||
@ -214,7 +209,8 @@ OpDec(int p, const char *type, Atom a, Term m)
|
|||||||
if (strcmp(type, optypes[i]) == 0)
|
if (strcmp(type, optypes[i]) == 0)
|
||||||
break;
|
break;
|
||||||
if (i > 7) {
|
if (i > 7) {
|
||||||
Yap_Error(DOMAIN_ERROR_OPERATOR_SPECIFIER,MkAtomTerm(Yap_LookupAtom(type)),"op/3");
|
Yap_Error(DOMAIN_ERROR_OPERATOR_SPECIFIER, MkAtomTerm(Yap_LookupAtom(type)),
|
||||||
|
"op/3");
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
if (p) {
|
if (p) {
|
||||||
@ -269,15 +265,11 @@ OpDec(int p, const char *type, Atom a, Term m)
|
|||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int Yap_OpDec(int p, char *type, Atom a, Term m) {
|
||||||
Yap_OpDec(int p, char *type, Atom a, Term m)
|
|
||||||
{
|
|
||||||
return (OpDec(p, type, a, m));
|
return (OpDec(p, type, a, m));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void SetOp(int p, int type, char *at, Term m) {
|
||||||
SetOp(int p, int type, char *at, Term m)
|
|
||||||
{
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if (GLOBAL_Option[5])
|
if (GLOBAL_Option[5])
|
||||||
fprintf(stderr, "[setop %d %s %s]\n", p, optypes[type], at);
|
fprintf(stderr, "[setop %d %s %s]\n", p, optypes[type], at);
|
||||||
@ -286,9 +278,7 @@ SetOp(int p, int type, char *at, Term m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Gets the info about an operator in a prop */
|
/* Gets the info about an operator in a prop */
|
||||||
Atom
|
Atom Yap_GetOp(OpEntry *pp, int *prio, int fix) {
|
||||||
Yap_GetOp(OpEntry *pp, int *prio, int fix)
|
|
||||||
{
|
|
||||||
int n;
|
int n;
|
||||||
SMALLUNSGN p;
|
SMALLUNSGN p;
|
||||||
|
|
||||||
@ -323,8 +313,7 @@ typedef struct OPSTRUCT {
|
|||||||
short int opType, opPrio;
|
short int opType, opPrio;
|
||||||
} Opdef;
|
} Opdef;
|
||||||
|
|
||||||
static Opdef Ops[] = {
|
static Opdef Ops[] = {{":-", xfx, 1200},
|
||||||
{":-", xfx, 1200},
|
|
||||||
{"-->", xfx, 1200},
|
{"-->", xfx, 1200},
|
||||||
{"?-", fx, 1200},
|
{"?-", fx, 1200},
|
||||||
{":-", fx, 1200},
|
{":-", fx, 1200},
|
||||||
@ -397,12 +386,9 @@ static Opdef Ops[] = {
|
|||||||
{"\\", fy, 200},
|
{"\\", fy, 200},
|
||||||
{"//", yfx, 400},
|
{"//", yfx, 400},
|
||||||
{"**", xfx, 200},
|
{"**", xfx, 200},
|
||||||
{"^", xfy, 200}
|
{"^", xfy, 200}};
|
||||||
};
|
|
||||||
|
|
||||||
static void
|
static void InitOps(void) {
|
||||||
InitOps(void)
|
|
||||||
{
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
for (i = 0; i < sizeof(Ops) / sizeof(*Ops); ++i)
|
for (i = 0; i < sizeof(Ops) / sizeof(*Ops); ++i)
|
||||||
SetOp(Ops[i].opPrio, Ops[i].opType, Ops[i].opName, PROLOG_MODULE);
|
SetOp(Ops[i].opPrio, Ops[i].opType, Ops[i].opName, PROLOG_MODULE);
|
||||||
@ -416,9 +402,7 @@ InitOps(void)
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static void InitDebug(void) {
|
||||||
InitDebug(void)
|
|
||||||
{
|
|
||||||
Atom At;
|
Atom At;
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
int i;
|
int i;
|
||||||
@ -462,9 +446,7 @@ InitDebug(void)
|
|||||||
Yap_PutValue(At, MkIntTerm(15));
|
Yap_PutValue(At, MkIntTerm(15));
|
||||||
}
|
}
|
||||||
|
|
||||||
static UInt
|
static UInt update_flags_from_prolog(UInt flags, PredEntry *pe) {
|
||||||
update_flags_from_prolog(UInt flags, PredEntry *pe)
|
|
||||||
{
|
|
||||||
if (pe->PredFlags & MetaPredFlag)
|
if (pe->PredFlags & MetaPredFlag)
|
||||||
flags |= MetaPredFlag;
|
flags |= MetaPredFlag;
|
||||||
if (pe->PredFlags & SourcePredFlag)
|
if (pe->PredFlags & SourcePredFlag)
|
||||||
@ -480,9 +462,8 @@ update_flags_from_prolog(UInt flags, PredEntry *pe)
|
|||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void Yap_InitCPred(const char *Name, UInt Arity, CPredicate code,
|
||||||
Yap_InitCPred(const char *Name, UInt Arity, CPredicate code, pred_flags_t flags)
|
pred_flags_t flags) {
|
||||||
{
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
Atom atom = NIL;
|
Atom atom = NIL;
|
||||||
PredEntry *pe = NULL;
|
PredEntry *pe = NULL;
|
||||||
@ -536,7 +517,8 @@ Yap_InitCPred(const char *Name, UInt Arity, CPredicate code, pred_flags_t flags)
|
|||||||
if (flags & SafePredFlag) {
|
if (flags & SafePredFlag) {
|
||||||
sz = (CELL)NEXTOP(NEXTOP(NEXTOP(p_code, Osbpp), p), l);
|
sz = (CELL)NEXTOP(NEXTOP(NEXTOP(p_code, Osbpp), p), l);
|
||||||
} else {
|
} else {
|
||||||
sz = (CELL)NEXTOP(NEXTOP(NEXTOP(NEXTOP(NEXTOP(p_code,e),p),Osbpp),p),l);
|
sz = (CELL)NEXTOP(NEXTOP(NEXTOP(NEXTOP(NEXTOP(p_code, e), p), Osbpp), p),
|
||||||
|
l);
|
||||||
}
|
}
|
||||||
cl = (StaticClause *)Yap_AllocCodeSpace(sz);
|
cl = (StaticClause *)Yap_AllocCodeSpace(sz);
|
||||||
if (!cl) {
|
if (!cl) {
|
||||||
@ -567,9 +549,7 @@ Yap_InitCPred(const char *Name, UInt Arity, CPredicate code, pred_flags_t flags)
|
|||||||
p_code->opc = Yap_opcode(_call_cpred);
|
p_code->opc = Yap_opcode(_call_cpred);
|
||||||
p_code->y_u.Osbpp.bmap = NULL;
|
p_code->y_u.Osbpp.bmap = NULL;
|
||||||
p_code->y_u.Osbpp.s = -Signed(RealEnvSize);
|
p_code->y_u.Osbpp.s = -Signed(RealEnvSize);
|
||||||
p_code->y_u.Osbpp.p =
|
p_code->y_u.Osbpp.p = p_code->y_u.Osbpp.p0 = pe;
|
||||||
p_code->y_u.Osbpp.p0 =
|
|
||||||
pe;
|
|
||||||
p_code = NEXTOP(p_code, Osbpp);
|
p_code = NEXTOP(p_code, Osbpp);
|
||||||
if (!(flags & SafePredFlag)) {
|
if (!(flags & SafePredFlag)) {
|
||||||
p_code->opc = Yap_opcode(_deallocate);
|
p_code->opc = Yap_opcode(_deallocate);
|
||||||
@ -584,9 +564,7 @@ Yap_InitCPred(const char *Name, UInt Arity, CPredicate code, pred_flags_t flags)
|
|||||||
pe->OpcodeOfPred = pe->CodeOfPred->opc;
|
pe->OpcodeOfPred = pe->CodeOfPred->opc;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool Yap_AddCallToFli(PredEntry *pe, CPredicate call) {
|
||||||
Yap_AddCallToFli( PredEntry *pe, CPredicate call )
|
|
||||||
{
|
|
||||||
yamop *p_code;
|
yamop *p_code;
|
||||||
|
|
||||||
if (pe->PredFlags & BackCPredFlag) {
|
if (pe->PredFlags & BackCPredFlag) {
|
||||||
@ -601,9 +579,7 @@ Yap_AddCallToFli( PredEntry *pe, CPredicate call )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool Yap_AddRetryToFli(PredEntry *pe, CPredicate re) {
|
||||||
Yap_AddRetryToFli( PredEntry *pe, CPredicate re )
|
|
||||||
{
|
|
||||||
yamop *p_code;
|
yamop *p_code;
|
||||||
|
|
||||||
if (pe->PredFlags & BackCPredFlag) {
|
if (pe->PredFlags & BackCPredFlag) {
|
||||||
@ -616,9 +592,7 @@ Yap_AddRetryToFli( PredEntry *pe, CPredicate re )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool Yap_AddCutToFli(PredEntry *pe, CPredicate CUT) {
|
||||||
Yap_AddCutToFli( PredEntry *pe, CPredicate CUT )
|
|
||||||
{
|
|
||||||
yamop *p_code;
|
yamop *p_code;
|
||||||
|
|
||||||
if (pe->PredFlags & BackCPredFlag) {
|
if (pe->PredFlags & BackCPredFlag) {
|
||||||
@ -632,9 +606,8 @@ Yap_AddCutToFli( PredEntry *pe, CPredicate CUT )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void Yap_InitCmpPred(const char *Name, UInt Arity, CmpPredicate cmp_code,
|
||||||
Yap_InitCmpPred(const char *Name, UInt Arity, CmpPredicate cmp_code, pred_flags_t flags)
|
pred_flags_t flags) {
|
||||||
{
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
Atom atom = NIL;
|
Atom atom = NIL;
|
||||||
PredEntry *pe = NULL;
|
PredEntry *pe = NULL;
|
||||||
@ -674,11 +647,13 @@ Yap_InitCmpPred(const char *Name, UInt Arity, CmpPredicate cmp_code, pred_flags_
|
|||||||
/* already exists */
|
/* already exists */
|
||||||
} else {
|
} else {
|
||||||
while (!cl) {
|
while (!cl) {
|
||||||
UInt sz = sizeof(StaticClause)+(CELL)NEXTOP(NEXTOP(NEXTOP(((yamop *)NULL),plxxs),p),l);
|
UInt sz = sizeof(StaticClause) +
|
||||||
|
(CELL)NEXTOP(NEXTOP(NEXTOP(((yamop *)NULL), plxxs), p), l);
|
||||||
cl = (StaticClause *)Yap_AllocCodeSpace(sz);
|
cl = (StaticClause *)Yap_AllocCodeSpace(sz);
|
||||||
if (!cl) {
|
if (!cl) {
|
||||||
if (!Yap_growheap(FALSE, sz, NULL)) {
|
if (!Yap_growheap(FALSE, sz, NULL)) {
|
||||||
Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"while initializing %s", Name);
|
Yap_Error(RESOURCE_ERROR_HEAP, TermNil, "while initializing %s",
|
||||||
|
Name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -710,9 +685,8 @@ Yap_InitCmpPred(const char *Name, UInt Arity, CmpPredicate cmp_code, pred_flags_
|
|||||||
p_code->y_u.l.l = cl->ClCode;
|
p_code->y_u.l.l = cl->ClCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void Yap_InitAsmPred(const char *Name, UInt Arity, int code, CPredicate def,
|
||||||
Yap_InitAsmPred(const char *Name, UInt Arity, int code, CPredicate def, pred_flags_t flags)
|
pred_flags_t flags) {
|
||||||
{
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
Atom atom = NIL;
|
Atom atom = NIL;
|
||||||
PredEntry *pe = NULL;
|
PredEntry *pe = NULL;
|
||||||
@ -758,15 +732,19 @@ Yap_InitAsmPred(const char *Name, UInt Arity, int code, CPredicate def, pred_fl
|
|||||||
|
|
||||||
if (pe->CodeOfPred == (yamop *)(&(pe->OpcodeOfPred))) {
|
if (pe->CodeOfPred == (yamop *)(&(pe->OpcodeOfPred))) {
|
||||||
if (flags & SafePredFlag) {
|
if (flags & SafePredFlag) {
|
||||||
cl = (StaticClause *)Yap_AllocCodeSpace((CELL)NEXTOP(NEXTOP(NEXTOP(((yamop *)p_code),Osbpp),p),l));
|
cl = (StaticClause *)Yap_AllocCodeSpace(
|
||||||
|
(CELL)NEXTOP(NEXTOP(NEXTOP(((yamop *)p_code), Osbpp), p), l));
|
||||||
} else {
|
} else {
|
||||||
cl = (StaticClause *)Yap_AllocCodeSpace((CELL)NEXTOP(NEXTOP(NEXTOP(NEXTOP(NEXTOP(((yamop *)p_code),e),Osbpp),p),p),l));
|
cl = (StaticClause *)Yap_AllocCodeSpace((CELL)NEXTOP(
|
||||||
|
NEXTOP(NEXTOP(NEXTOP(NEXTOP(((yamop *)p_code), e), Osbpp), p), p),
|
||||||
|
l));
|
||||||
}
|
}
|
||||||
if (!cl) {
|
if (!cl) {
|
||||||
Yap_Error(RESOURCE_ERROR_HEAP, TermNil, "No Heap Space in InitAsmPred");
|
Yap_Error(RESOURCE_ERROR_HEAP, TermNil, "No Heap Space in InitAsmPred");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Yap_ClauseSpace += (CELL)NEXTOP(NEXTOP(NEXTOP(((yamop *)p_code),Osbpp),p),l);
|
Yap_ClauseSpace +=
|
||||||
|
(CELL)NEXTOP(NEXTOP(NEXTOP(((yamop *)p_code), Osbpp), p), l);
|
||||||
} else {
|
} else {
|
||||||
cl = ClauseCodeToStaticClause(pe->CodeOfPred);
|
cl = ClauseCodeToStaticClause(pe->CodeOfPred);
|
||||||
}
|
}
|
||||||
@ -775,7 +753,8 @@ Yap_InitAsmPred(const char *Name, UInt Arity, int code, CPredicate def, pred_fl
|
|||||||
if (flags & SafePredFlag) {
|
if (flags & SafePredFlag) {
|
||||||
cl->ClSize = (CELL)NEXTOP(NEXTOP(NEXTOP(((yamop *)p_code), Osbpp), e), e);
|
cl->ClSize = (CELL)NEXTOP(NEXTOP(NEXTOP(((yamop *)p_code), Osbpp), e), e);
|
||||||
} else {
|
} else {
|
||||||
cl->ClSize = (CELL)NEXTOP(NEXTOP(NEXTOP(NEXTOP(NEXTOP(((yamop *)p_code),e),Osbpp),p),e),e);
|
cl->ClSize = (CELL)NEXTOP(
|
||||||
|
NEXTOP(NEXTOP(NEXTOP(NEXTOP(((yamop *)p_code), e), Osbpp), p), e), e);
|
||||||
}
|
}
|
||||||
cl->usc.ClLine = Yap_source_line_no();
|
cl->usc.ClLine = Yap_source_line_no();
|
||||||
p_code = cl->ClCode;
|
p_code = cl->ClCode;
|
||||||
@ -806,10 +785,8 @@ Yap_InitAsmPred(const char *Name, UInt Arity, int code, CPredicate def, pred_fl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void CleanBack(PredEntry *pe, CPredicate Start, CPredicate Cont,
|
||||||
static void
|
CPredicate Cut) {
|
||||||
CleanBack(PredEntry *pe, CPredicate Start, CPredicate Cont, CPredicate Cut)
|
|
||||||
{
|
|
||||||
yamop *code;
|
yamop *code;
|
||||||
if (pe->cs.p_code.FirstClause != pe->cs.p_code.LastClause ||
|
if (pe->cs.p_code.FirstClause != pe->cs.p_code.LastClause ||
|
||||||
pe->cs.p_code.TrueCodeOfPred != pe->cs.p_code.FirstClause ||
|
pe->cs.p_code.TrueCodeOfPred != pe->cs.p_code.FirstClause ||
|
||||||
@ -848,25 +825,20 @@ CleanBack(PredEntry *pe, CPredicate Start, CPredicate Cont, CPredicate Cut)
|
|||||||
code->y_u.OtapFs.f = Cut;
|
code->y_u.OtapFs.f = Cut;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void Yap_InitCPredBack(const char *Name, UInt Arity, unsigned int Extra,
|
||||||
Yap_InitCPredBack(const char *Name, UInt Arity,
|
CPredicate Start, CPredicate Cont, pred_flags_t flags) {
|
||||||
unsigned int Extra, CPredicate Start,
|
|
||||||
CPredicate Cont, pred_flags_t flags){
|
|
||||||
Yap_InitCPredBack_(Name, Arity, Extra, Start, Cont, NULL, flags);
|
Yap_InitCPredBack_(Name, Arity, Extra, Start, Cont, NULL, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void Yap_InitCPredBackCut(const char *Name, UInt Arity, unsigned int Extra,
|
||||||
Yap_InitCPredBackCut(const char *Name, UInt Arity,
|
CPredicate Start, CPredicate Cont, CPredicate Cut,
|
||||||
unsigned int Extra, CPredicate Start,
|
pred_flags_t flags) {
|
||||||
CPredicate Cont,CPredicate Cut, pred_flags_t flags){
|
|
||||||
Yap_InitCPredBack_(Name, Arity, Extra, Start, Cont, Cut, flags);
|
Yap_InitCPredBack_(Name, Arity, Extra, Start, Cont, Cut, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void Yap_InitCPredBack_(const char *Name, UInt Arity, unsigned int Extra,
|
||||||
Yap_InitCPredBack_(const char *Name, UInt Arity,
|
CPredicate Start, CPredicate Cont, CPredicate Cut,
|
||||||
unsigned int Extra, CPredicate Start,
|
pred_flags_t flags) {
|
||||||
CPredicate Cont, CPredicate Cut, pred_flags_t flags)
|
|
||||||
{
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
PredEntry *pe = NULL;
|
PredEntry *pe = NULL;
|
||||||
Atom atom = NIL;
|
Atom atom = NIL;
|
||||||
@ -898,15 +870,14 @@ Yap_InitCPredBack_(const char *Name, UInt Arity,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pe->cs.p_code.FirstClause != NIL)
|
if (pe->cs.p_code.FirstClause != NIL) {
|
||||||
{
|
|
||||||
flags = update_flags_from_prolog(flags, pe);
|
flags = update_flags_from_prolog(flags, pe);
|
||||||
CleanBack(pe, Start, Cont, Cut);
|
CleanBack(pe, Start, Cont, Cut);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
StaticClause *cl;
|
StaticClause *cl;
|
||||||
yamop *code = ((StaticClause *)NULL)->ClCode;
|
yamop *code = ((StaticClause *)NULL)->ClCode;
|
||||||
UInt sz = (CELL)NEXTOP(NEXTOP(NEXTOP(NEXTOP(code,OtapFs),OtapFs),OtapFs),l);
|
UInt sz =
|
||||||
|
(CELL)NEXTOP(NEXTOP(NEXTOP(NEXTOP(code, OtapFs), OtapFs), OtapFs), l);
|
||||||
if (flags & UserCPredFlag)
|
if (flags & UserCPredFlag)
|
||||||
pe->PredFlags = UserCPredFlag | BackCPredFlag | CompiledPredFlag | flags;
|
pe->PredFlags = UserCPredFlag | BackCPredFlag | CompiledPredFlag | flags;
|
||||||
else
|
else
|
||||||
@ -930,8 +901,8 @@ Yap_InitCPredBack_(const char *Name, UInt Arity,
|
|||||||
cl->usc.ClLine = Yap_source_line_no();
|
cl->usc.ClLine = Yap_source_line_no();
|
||||||
|
|
||||||
code = cl->ClCode;
|
code = cl->ClCode;
|
||||||
pe->cs.p_code.TrueCodeOfPred = pe->CodeOfPred =
|
pe->cs.p_code.TrueCodeOfPred = pe->CodeOfPred = pe->cs.p_code.FirstClause =
|
||||||
pe->cs.p_code.FirstClause = pe->cs.p_code.LastClause = code;
|
pe->cs.p_code.LastClause = code;
|
||||||
if (flags & UserCPredFlag)
|
if (flags & UserCPredFlag)
|
||||||
pe->OpcodeOfPred = code->opc = Yap_opcode(_try_userc);
|
pe->OpcodeOfPred = code->opc = Yap_opcode(_try_userc);
|
||||||
else
|
else
|
||||||
@ -972,10 +943,7 @@ Yap_InitCPredBack_(const char *Name, UInt Arity,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void InitStdPreds(void) {
|
||||||
static void
|
|
||||||
InitStdPreds(void)
|
|
||||||
{
|
|
||||||
Yap_InitCPreds();
|
Yap_InitCPreds();
|
||||||
Yap_InitBackCPreds();
|
Yap_InitBackCPreds();
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
@ -986,16 +954,15 @@ InitStdPreds(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void InitPredHash(void) {
|
||||||
static void
|
|
||||||
InitPredHash(void)
|
|
||||||
{
|
|
||||||
UInt i;
|
UInt i;
|
||||||
|
|
||||||
PredHash = (PredEntry **)Yap_AllocAtomSpace(sizeof(PredEntry **) * PredHashInitialSize);
|
PredHash = (PredEntry **)Yap_AllocAtomSpace(sizeof(PredEntry **) *
|
||||||
|
PredHashInitialSize);
|
||||||
PredHashTableSize = PredHashInitialSize;
|
PredHashTableSize = PredHashInitialSize;
|
||||||
if (PredHash == NULL) {
|
if (PredHash == NULL) {
|
||||||
Yap_Error(SYSTEM_ERROR_FATAL,MkIntTerm(0),"allocating initial predicate hash table");
|
Yap_Error(SYSTEM_ERROR_FATAL, MkIntTerm(0),
|
||||||
|
"allocating initial predicate hash table");
|
||||||
}
|
}
|
||||||
for (i = 0; i < PredHashTableSize; ++i) {
|
for (i = 0; i < PredHashTableSize; ++i) {
|
||||||
PredHash[i] = NULL;
|
PredHash[i] = NULL;
|
||||||
@ -1003,9 +970,8 @@ InitPredHash(void)
|
|||||||
INIT_RWLOCK(PredHashRWLock);
|
INIT_RWLOCK(PredHashRWLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void InitEnvInst(yamop start[2], yamop **instp, op_numbers opc,
|
||||||
InitEnvInst(yamop start[2], yamop **instp, op_numbers opc, PredEntry *pred)
|
PredEntry *pred) {
|
||||||
{
|
|
||||||
yamop *ipc = start;
|
yamop *ipc = start;
|
||||||
|
|
||||||
/* make it look like the instruction is preceeded by a call instruction */
|
/* make it look like the instruction is preceeded by a call instruction */
|
||||||
@ -1019,9 +985,7 @@ InitEnvInst(yamop start[2], yamop **instp, op_numbers opc, PredEntry *pred)
|
|||||||
*instp = ipc;
|
*instp = ipc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void InitOtaplInst(yamop start[1], OPCODE opc, PredEntry *pe) {
|
||||||
InitOtaplInst(yamop start[1], OPCODE opc, PredEntry *pe)
|
|
||||||
{
|
|
||||||
yamop *ipc = start;
|
yamop *ipc = start;
|
||||||
|
|
||||||
/* this is a place holder, it should not really be used */
|
/* this is a place holder, it should not really be used */
|
||||||
@ -1037,59 +1001,50 @@ InitOtaplInst(yamop start[1], OPCODE opc, PredEntry *pe)
|
|||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void InitDBErasedMarker(void) {
|
||||||
InitDBErasedMarker(void)
|
DBErasedMarker = (DBRef)Yap_AllocCodeSpace(sizeof(DBStruct));
|
||||||
{
|
|
||||||
Yap_heap_regs->db_erased_marker =
|
|
||||||
(DBRef)Yap_AllocCodeSpace(sizeof(DBStruct));
|
|
||||||
Yap_LUClauseSpace += sizeof(DBStruct);
|
Yap_LUClauseSpace += sizeof(DBStruct);
|
||||||
Yap_heap_regs->db_erased_marker->id = FunctorDBRef;
|
DBErasedMarker->id = FunctorDBRef;
|
||||||
Yap_heap_regs->db_erased_marker->Flags = ErasedMask;
|
DBErasedMarker->Flags = ErasedMask;
|
||||||
Yap_heap_regs->db_erased_marker->Code = NULL;
|
DBErasedMarker->Code = NULL;
|
||||||
Yap_heap_regs->db_erased_marker->DBT.DBRefs = NULL;
|
DBErasedMarker->DBT.DBRefs = NULL;
|
||||||
Yap_heap_regs->db_erased_marker->Parent = NULL;
|
DBErasedMarker->Parent = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void InitLogDBErasedMarker(void) {
|
||||||
InitLogDBErasedMarker(void)
|
LogDBErasedMarker = (LogUpdClause *)Yap_AllocCodeSpace(
|
||||||
{
|
sizeof(LogUpdClause) + (UInt)NEXTOP((yamop *)NULL, e));
|
||||||
Yap_heap_regs->logdb_erased_marker =
|
|
||||||
(LogUpdClause *)Yap_AllocCodeSpace(sizeof(LogUpdClause)+(UInt)NEXTOP((yamop*)NULL,e));
|
|
||||||
Yap_LUClauseSpace += sizeof(LogUpdClause) + (UInt)NEXTOP((yamop *)NULL, e);
|
Yap_LUClauseSpace += sizeof(LogUpdClause) + (UInt)NEXTOP((yamop *)NULL, e);
|
||||||
Yap_heap_regs->logdb_erased_marker->Id = FunctorDBRef;
|
LogDBErasedMarker->Id = FunctorDBRef;
|
||||||
Yap_heap_regs->logdb_erased_marker->ClFlags = ErasedMask|LogUpdMask;
|
LogDBErasedMarker->ClFlags = ErasedMask | LogUpdMask;
|
||||||
Yap_heap_regs->logdb_erased_marker->lusl.ClSource = NULL;
|
LogDBErasedMarker->lusl.ClSource = NULL;
|
||||||
Yap_heap_regs->logdb_erased_marker->ClRefCount = 0;
|
LogDBErasedMarker->ClRefCount = 0;
|
||||||
Yap_heap_regs->logdb_erased_marker->ClExt = NULL;
|
LogDBErasedMarker->ClExt = NULL;
|
||||||
Yap_heap_regs->logdb_erased_marker->ClPrev = NULL;
|
LogDBErasedMarker->ClPrev = NULL;
|
||||||
Yap_heap_regs->logdb_erased_marker->ClNext = NULL;
|
LogDBErasedMarker->ClNext = NULL;
|
||||||
Yap_heap_regs->logdb_erased_marker->ClSize = (UInt)NEXTOP(((LogUpdClause *)NULL)->ClCode,e);
|
LogDBErasedMarker->ClSize =
|
||||||
Yap_heap_regs->logdb_erased_marker->ClCode->opc = Yap_opcode(_op_fail);
|
(UInt)NEXTOP(((LogUpdClause *)NULL)->ClCode, e);
|
||||||
INIT_CLREF_COUNT(Yap_heap_regs->logdb_erased_marker);
|
LogDBErasedMarker->ClCode->opc = Yap_opcode(_op_fail);
|
||||||
|
INIT_CLREF_COUNT(LogDBErasedMarker);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void InitSWIAtoms(void) {
|
||||||
InitSWIAtoms(void)
|
|
||||||
{
|
|
||||||
MaxAtomTranslations = N_SWI_ATOMS;
|
MaxAtomTranslations = N_SWI_ATOMS;
|
||||||
MaxFunctorTranslations = N_SWI_FUNCTORS;
|
MaxFunctorTranslations = N_SWI_FUNCTORS;
|
||||||
SWI_Atoms = (Atom *)malloc(sizeof(Atom) * MaxAtomTranslations);
|
SWI_Atoms = (Atom *)malloc(sizeof(Atom) * MaxAtomTranslations);
|
||||||
SWI_Functors = (Functor *)malloc(sizeof(Functor) * 2 * N_SWI_ATOMS);
|
SWI_Functors = (Functor *)malloc(sizeof(Functor) * 2 * N_SWI_ATOMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void InitEmptyWakeups(void) {}
|
||||||
InitEmptyWakeups(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void InitAtoms(void) {
|
||||||
InitAtoms(void)
|
|
||||||
{
|
|
||||||
int i;
|
int i;
|
||||||
AtomHashTableSize = MaxHash;
|
AtomHashTableSize = MaxHash;
|
||||||
HashChain = (AtomHashEntry *)Yap_AllocAtomSpace(sizeof(AtomHashEntry) * MaxHash);
|
HashChain =
|
||||||
|
(AtomHashEntry *)Yap_AllocAtomSpace(sizeof(AtomHashEntry) * MaxHash);
|
||||||
if (HashChain == NULL) {
|
if (HashChain == NULL) {
|
||||||
Yap_Error(SYSTEM_ERROR_FATAL,MkIntTerm(0),"allocating initial atom table");
|
Yap_Error(SYSTEM_ERROR_FATAL, MkIntTerm(0),
|
||||||
|
"allocating initial atom table");
|
||||||
}
|
}
|
||||||
for (i = 0; i < MaxHash; ++i) {
|
for (i = 0; i < MaxHash; ++i) {
|
||||||
INIT_RWLOCK(HashChain[i].AERWLock);
|
INIT_RWLOCK(HashChain[i].AERWLock);
|
||||||
@ -1113,13 +1068,12 @@ InitAtoms(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void InitWideAtoms(void) {
|
||||||
InitWideAtoms(void)
|
|
||||||
{
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
WideAtomHashTableSize = MaxWideHash;
|
WideAtomHashTableSize = MaxWideHash;
|
||||||
WideHashChain = (AtomHashEntry *)Yap_AllocAtomSpace(sizeof(AtomHashEntry) * MaxWideHash);
|
WideHashChain =
|
||||||
|
(AtomHashEntry *)Yap_AllocAtomSpace(sizeof(AtomHashEntry) * MaxWideHash);
|
||||||
if (WideHashChain == NULL) {
|
if (WideHashChain == NULL) {
|
||||||
Yap_Error(SYSTEM_ERROR_FATAL, MkIntTerm(0), "allocating wide atom table");
|
Yap_Error(SYSTEM_ERROR_FATAL, MkIntTerm(0), "allocating wide atom table");
|
||||||
}
|
}
|
||||||
@ -1130,15 +1084,12 @@ InitWideAtoms(void)
|
|||||||
NOfWideAtoms = 0;
|
NOfWideAtoms = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void InitInvisibleAtoms(void) {
|
||||||
InitInvisibleAtoms(void)
|
|
||||||
{
|
|
||||||
/* initialize invisible chain */
|
/* initialize invisible chain */
|
||||||
Yap_heap_regs->invisiblechain.Entry = NIL;
|
INVISIBLECHAIN.Entry = NIL;
|
||||||
INIT_RWLOCK(Yap_heap_regs->invisiblechain.AERWLock);
|
INIT_RWLOCK(INVISIBLECHAIN.AERWLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
void Yap_init_yapor_workers(void) {
|
void Yap_init_yapor_workers(void) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
@ -1152,9 +1103,11 @@ void Yap_init_yapor_workers(void) {
|
|||||||
int son;
|
int son;
|
||||||
son = fork();
|
son = fork();
|
||||||
if (son == -1)
|
if (son == -1)
|
||||||
Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "fork error (Yap_init_yapor_workers)");
|
Yap_Error(SYSTEM_ERROR_FATAL, TermNil,
|
||||||
|
"fork error (Yap_init_yapor_workers)");
|
||||||
if (son > 0) {
|
if (son > 0) {
|
||||||
/* I am the father, I must stay here and wait for my children to all die */
|
/* I am the father, I must stay here and wait for my children to all die
|
||||||
|
*/
|
||||||
struct sigaction sigact;
|
struct sigaction sigact;
|
||||||
sigact.sa_handler = SIG_DFL;
|
sigact.sa_handler = SIG_DFL;
|
||||||
sigemptyset(&sigact.sa_mask);
|
sigemptyset(&sigact.sa_mask);
|
||||||
@ -1170,7 +1123,8 @@ void Yap_init_yapor_workers(void) {
|
|||||||
int son;
|
int son;
|
||||||
son = fork();
|
son = fork();
|
||||||
if (son == -1)
|
if (son == -1)
|
||||||
Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "fork error (Yap_init_yapor_workers)");
|
Yap_Error(SYSTEM_ERROR_FATAL, TermNil,
|
||||||
|
"fork error (Yap_init_yapor_workers)");
|
||||||
if (son == 0) {
|
if (son == 0) {
|
||||||
/* new worker */
|
/* new worker */
|
||||||
worker_id = proc;
|
worker_id = proc;
|
||||||
@ -1185,11 +1139,8 @@ void Yap_init_yapor_workers(void) {
|
|||||||
}
|
}
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
|
|
||||||
|
|
||||||
#ifdef THREADS
|
#ifdef THREADS
|
||||||
static void
|
static void InitThreadHandle(int wid) {
|
||||||
InitThreadHandle(int wid)
|
|
||||||
{
|
|
||||||
REMOTE_ThreadHandle(wid).in_use = FALSE;
|
REMOTE_ThreadHandle(wid).in_use = FALSE;
|
||||||
REMOTE_ThreadHandle(wid).zombie = FALSE;
|
REMOTE_ThreadHandle(wid).zombie = FALSE;
|
||||||
REMOTE_ThreadHandle(wid).local_preds = NULL;
|
REMOTE_ThreadHandle(wid).local_preds = NULL;
|
||||||
@ -1217,15 +1168,13 @@ InitThreadHandle(int wid)
|
|||||||
mboxp->open = true;
|
mboxp->open = true;
|
||||||
Yap_init_tqueue(msgsp);
|
Yap_init_tqueue(msgsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int Yap_InitThread(int new_id) {
|
||||||
Yap_InitThread(int new_id)
|
|
||||||
{
|
|
||||||
struct worker_local *new_s;
|
struct worker_local *new_s;
|
||||||
if (new_id) {
|
if (new_id) {
|
||||||
if (!(new_s = (struct worker_local *)calloc(sizeof(struct worker_local), 1)))
|
if (!(new_s =
|
||||||
|
(struct worker_local *)calloc(sizeof(struct worker_local), 1)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
Yap_local[new_id] = new_s;
|
Yap_local[new_id] = new_s;
|
||||||
if (!((REGSTORE *)pthread_getspecific(Yap_yaamregs_key))) {
|
if (!((REGSTORE *)pthread_getspecific(Yap_yaamregs_key))) {
|
||||||
@ -1242,16 +1191,13 @@ Yap_InitThread(int new_id)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static void InitScratchPad(int wid) {
|
||||||
InitScratchPad(int wid)
|
|
||||||
{
|
|
||||||
REMOTE_ScratchPad(wid).ptr = NULL;
|
REMOTE_ScratchPad(wid).ptr = NULL;
|
||||||
REMOTE_ScratchPad(wid).sz = SCRATCH_START_SIZE;
|
REMOTE_ScratchPad(wid).sz = SCRATCH_START_SIZE;
|
||||||
REMOTE_ScratchPad(wid).msz = SCRATCH_START_SIZE;
|
REMOTE_ScratchPad(wid).msz = SCRATCH_START_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CELL *
|
static CELL *InitHandles(int wid) {
|
||||||
InitHandles(int wid) {
|
|
||||||
size_t initial_slots = 1024;
|
size_t initial_slots = 1024;
|
||||||
CELL *handles;
|
CELL *handles;
|
||||||
|
|
||||||
@ -1260,31 +1206,29 @@ InitHandles(int wid) {
|
|||||||
handles = calloc(initial_slots, sizeof(CELL));
|
handles = calloc(initial_slots, sizeof(CELL));
|
||||||
|
|
||||||
if (handles == NULL) {
|
if (handles == NULL) {
|
||||||
Yap_Error(SYSTEM_ERROR_INTERNAL, 0 /* TermNil */, "No space for handles at " __FILE__ " : %d", __LINE__);
|
Yap_Error(SYSTEM_ERROR_INTERNAL, 0 /* TermNil */,
|
||||||
|
"No space for handles at " __FILE__ " : %d", __LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
RESET_VARIABLE(handles);
|
RESET_VARIABLE(handles);
|
||||||
return handles;
|
return handles;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void Yap_CloseScratchPad(void) {
|
||||||
Yap_CloseScratchPad(void)
|
|
||||||
{
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
Yap_FreeCodeSpace(LOCAL_ScratchPad.ptr);
|
Yap_FreeCodeSpace(LOCAL_ScratchPad.ptr);
|
||||||
LOCAL_ScratchPad.sz = SCRATCH_START_SIZE;
|
LOCAL_ScratchPad.sz = SCRATCH_START_SIZE;
|
||||||
LOCAL_ScratchPad.msz = SCRATCH_START_SIZE;
|
LOCAL_ScratchPad.msz = SCRATCH_START_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "iglobals.h"
|
#include "heap/iglobals.h"
|
||||||
#include "ilocals.h"
|
|
||||||
|
|
||||||
|
#include "heap/ilocals.h"
|
||||||
|
|
||||||
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
|
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
|
||||||
struct global_data *Yap_global;
|
struct global_data *Yap_global;
|
||||||
long Yap_worker_area_size;
|
long Yap_worker_area_size;
|
||||||
#else
|
|
||||||
struct global_data Yap_Global;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(THREADS)
|
#if defined(THREADS)
|
||||||
@ -1295,9 +1239,7 @@ struct worker_local *Yap_local;
|
|||||||
struct worker_local Yap_local;
|
struct worker_local Yap_local;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static void InitCodes(void) {
|
||||||
InitCodes(void)
|
|
||||||
{
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
#if THREADS
|
#if THREADS
|
||||||
int wid;
|
int wid;
|
||||||
@ -1305,7 +1247,7 @@ InitCodes(void)
|
|||||||
Yap_local[wid] = NULL;
|
Yap_local[wid] = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#include "ihstruct.h"
|
#include "heap/ihstruct.h"
|
||||||
#if THREADS
|
#if THREADS
|
||||||
Yap_InitThread(0);
|
Yap_InitThread(0);
|
||||||
#endif /* THREADS */
|
#endif /* THREADS */
|
||||||
@ -1328,30 +1270,27 @@ InitCodes(void)
|
|||||||
modp->PredFlags |= MetaPredFlag;
|
modp->PredFlags |= MetaPredFlag;
|
||||||
}
|
}
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
Yap_heap_regs->getwork_code->y_u.Otapl.p = RepPredProp(PredPropByAtom(AtomGetwork, PROLOG_MODULE));
|
Yap_heap_regs->getwork_code->y_u.Otapl.p =
|
||||||
Yap_heap_regs->getwork_seq_code->y_u.Otapl.p = RepPredProp(PredPropByAtom(AtomGetworkSeq, PROLOG_MODULE));
|
RepPredProp(PredPropByAtom(AtomGetwork, PROLOG_MODULE));
|
||||||
|
Yap_heap_regs->getwork_seq_code->y_u.Otapl.p =
|
||||||
|
RepPredProp(PredPropByAtom(AtomGetworkSeq, PROLOG_MODULE));
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void InitVersion(void) {
|
||||||
static void
|
Yap_PutValue(AtomVersionNumber, MkAtomTerm(Yap_LookupAtom(YAP_FULL_VERSION)));
|
||||||
InitVersion(void)
|
|
||||||
{
|
|
||||||
Yap_PutValue(AtomVersionNumber,
|
|
||||||
MkAtomTerm(Yap_LookupAtom(YAP_FULL_VERSION)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts,
|
||||||
Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_size,
|
UInt max_table_size, int n_workers, int sch_loop,
|
||||||
int n_workers, int sch_loop, int delay_load)
|
int delay_load) {
|
||||||
{
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
|
|
||||||
/* initialize system stuff */
|
/* initialize system stuff */
|
||||||
#if PUSH_REGS
|
#if PUSH_REGS
|
||||||
#ifdef THREADS
|
#ifdef THREADS
|
||||||
if (!(Yap_local[0] = (struct worker_local *)calloc(sizeof(struct worker_local), 1)))
|
if (!(Yap_local[0] =
|
||||||
|
(struct worker_local *)calloc(sizeof(struct worker_local), 1)))
|
||||||
return;
|
return;
|
||||||
pthread_key_create(&Yap_yaamregs_key, NULL);
|
pthread_key_create(&Yap_yaamregs_key, NULL);
|
||||||
pthread_setspecific(Yap_yaamregs_key, (const void *)&Yap_standard_regs);
|
pthread_setspecific(Yap_yaamregs_key, (const void *)&Yap_standard_regs);
|
||||||
@ -1396,13 +1335,17 @@ Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_s
|
|||||||
if (n_workers > MAX_WORKERS)
|
if (n_workers > MAX_WORKERS)
|
||||||
Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "excessive number of workers");
|
Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "excessive number of workers");
|
||||||
#ifdef YAPOR_COPY
|
#ifdef YAPOR_COPY
|
||||||
INFORMATION_MESSAGE("YapOr: copy model with %d worker%s", n_workers, n_workers == 1 ? "":"s");
|
INFORMATION_MESSAGE("YapOr: copy model with %d worker%s", n_workers,
|
||||||
|
n_workers == 1 ? "" : "s");
|
||||||
#elif YAPOR_COW
|
#elif YAPOR_COW
|
||||||
INFORMATION_MESSAGE("YapOr: acow model with %d worker%s", n_workers, n_workers == 1 ? "":"s");
|
INFORMATION_MESSAGE("YapOr: acow model with %d worker%s", n_workers,
|
||||||
|
n_workers == 1 ? "" : "s");
|
||||||
#elif YAPOR_SBA
|
#elif YAPOR_SBA
|
||||||
INFORMATION_MESSAGE("YapOr: sba model with %d worker%s", n_workers, n_workers == 1 ? "":"s");
|
INFORMATION_MESSAGE("YapOr: sba model with %d worker%s", n_workers,
|
||||||
|
n_workers == 1 ? "" : "s");
|
||||||
#elif YAPOR_THREADS
|
#elif YAPOR_THREADS
|
||||||
INFORMATION_MESSAGE("YapOr: threads model with %d worker%s", n_workers, n_workers == 1 ? "":"s");
|
INFORMATION_MESSAGE("YapOr: threads model with %d worker%s", n_workers,
|
||||||
|
n_workers == 1 ? "" : "s");
|
||||||
#endif /* YAPOR_COPY - YAPOR_COW - YAPOR_SBA - YAPOR_THREADS */
|
#endif /* YAPOR_COPY - YAPOR_COW - YAPOR_SBA - YAPOR_THREADS */
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
|
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
|
||||||
@ -1437,7 +1380,8 @@ Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_s
|
|||||||
if (Stack < MinStackSpace)
|
if (Stack < MinStackSpace)
|
||||||
Stack = MinStackSpace;
|
Stack = MinStackSpace;
|
||||||
if (!(LOCAL_GlobalBase = (ADDR)malloc((Trail + Stack) * 1024))) {
|
if (!(LOCAL_GlobalBase = (ADDR)malloc((Trail + Stack) * 1024))) {
|
||||||
Yap_Error(RESOURCE_ERROR_HEAP, 0, "could not allocate stack space for main thread");
|
Yap_Error(RESOURCE_ERROR_HEAP, 0,
|
||||||
|
"could not allocate stack space for main thread");
|
||||||
Yap_exit(1);
|
Yap_exit(1);
|
||||||
}
|
}
|
||||||
#if THREADS
|
#if THREADS
|
||||||
@ -1454,14 +1398,10 @@ Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_s
|
|||||||
Yap_InitYaamRegs(0);
|
Yap_InitYaamRegs(0);
|
||||||
InitStdPreds();
|
InitStdPreds();
|
||||||
/* make sure tmp area is available */
|
/* make sure tmp area is available */
|
||||||
{
|
{ Yap_ReleasePreAllocCodeSpace(Yap_PreAllocCodeSpace()); }
|
||||||
Yap_ReleasePreAllocCodeSpace(Yap_PreAllocCodeSpace());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int Yap_HaltRegisterHook(HaltHookFunc f, void *env) {
|
||||||
Yap_HaltRegisterHook (HaltHookFunc f, void * env)
|
|
||||||
{
|
|
||||||
struct halt_hook *h;
|
struct halt_hook *h;
|
||||||
|
|
||||||
if (!(h = (struct halt_hook *)Yap_AllocCodeSpace(sizeof(struct halt_hook))))
|
if (!(h = (struct halt_hook *)Yap_AllocCodeSpace(sizeof(struct halt_hook))))
|
||||||
@ -1475,9 +1415,7 @@ Yap_HaltRegisterHook (HaltHookFunc f, void * env)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void run_halt_hooks(int code) {
|
||||||
run_halt_hooks(int code)
|
|
||||||
{
|
|
||||||
struct halt_hook *hooke = GLOBAL_HaltHooks;
|
struct halt_hook *hooke = GLOBAL_HaltHooks;
|
||||||
|
|
||||||
while (hooke) {
|
while (hooke) {
|
||||||
@ -1486,9 +1424,7 @@ run_halt_hooks(int code)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void Yap_exit(int value) {
|
||||||
Yap_exit (int value)
|
|
||||||
{
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
void closeFiles(int all);
|
void closeFiles(int all);
|
||||||
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
|
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
|
||||||
|
@ -106,9 +106,6 @@
|
|||||||
}
|
}
|
||||||
#endif /* FROZEN_STACKS */
|
#endif /* FROZEN_STACKS */
|
||||||
d0 = ARG1;
|
d0 = ARG1;
|
||||||
if (PRED_GOAL_EXPANSION_ALL) {
|
|
||||||
goto execute_metacall;
|
|
||||||
}
|
|
||||||
restart_execute:
|
restart_execute:
|
||||||
deref_head(d0, execute_unk);
|
deref_head(d0, execute_unk);
|
||||||
execute_nvar:
|
execute_nvar:
|
||||||
@ -119,7 +116,7 @@
|
|||||||
}
|
}
|
||||||
pen = RepPredProp(PredPropByFunc(f, mod));
|
pen = RepPredProp(PredPropByFunc(f, mod));
|
||||||
execute_pred_f:
|
execute_pred_f:
|
||||||
if (pen->PredFlags & (MetaPredFlag|GoalExPredFlag)) {
|
if (pen->PredFlags & MetaPredFlag) {
|
||||||
/* just strip all of M:G */
|
/* just strip all of M:G */
|
||||||
if (f == FunctorModule) {
|
if (f == FunctorModule) {
|
||||||
Term tmod = ArgOfTerm(1,d0);
|
Term tmod = ArgOfTerm(1,d0);
|
||||||
|
121
C/modules.c
@ -25,6 +25,7 @@ static char SccsId[] = "%W% %G%";
|
|||||||
static Int current_module(USES_REGS1);
|
static Int current_module(USES_REGS1);
|
||||||
static Int current_module1(USES_REGS1);
|
static Int current_module1(USES_REGS1);
|
||||||
static ModEntry *LookupModule(Term a);
|
static ModEntry *LookupModule(Term a);
|
||||||
|
static ModEntry *LookupSystemModule(Term a);
|
||||||
|
|
||||||
static ModEntry *FetchModuleEntry(Atom at)
|
static ModEntry *FetchModuleEntry(Atom at)
|
||||||
/* get predicate entry for ap/arity; create it if neccessary. */
|
/* get predicate entry for ap/arity; create it if neccessary. */
|
||||||
@ -69,6 +70,7 @@ inline static ModEntry *GetModuleEntry(Atom at)
|
|||||||
new->NextME = CurrentModules;
|
new->NextME = CurrentModules;
|
||||||
CurrentModules = new;
|
CurrentModules = new;
|
||||||
new->AtomOfME = ae;
|
new->AtomOfME = ae;
|
||||||
|
new->OwnerFile = Yap_ConsultingFile( PASS_REGS1);
|
||||||
AddPropToAtom(ae, (PropEntry *)new);
|
AddPropToAtom(ae, (PropEntry *)new);
|
||||||
if (CurrentModule == 0L || (oat = GetModuleEntry(AtomOfTerm(CurrentModule))) == new) {
|
if (CurrentModule == 0L || (oat = GetModuleEntry(AtomOfTerm(CurrentModule))) == new) {
|
||||||
Yap_setModuleFlags(new, NULL);
|
Yap_setModuleFlags(new, NULL);
|
||||||
@ -84,11 +86,18 @@ Term Yap_getUnknownModule(ModEntry *m) {
|
|||||||
return TermError;
|
return TermError;
|
||||||
} else if (m && m->flags & UNKNOWN_WARNING) {
|
} else if (m && m->flags & UNKNOWN_WARNING) {
|
||||||
return TermWarning;
|
return TermWarning;
|
||||||
|
} else if (m && m->flags & UNKNOWN_FAST_FAIL) {
|
||||||
|
return TermFastFail;
|
||||||
} else {
|
} else {
|
||||||
return TermFail;
|
return TermFail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Yap_getUnknown ( Term mod) {
|
||||||
|
ModEntry *m = LookupModule( mod );
|
||||||
|
return Yap_getUnknownModule( m );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Yap_CharacterEscapes(Term mt) {
|
bool Yap_CharacterEscapes(Term mt) {
|
||||||
if (mt == PROLOG_MODULE) mt = TermProlog;
|
if (mt == PROLOG_MODULE) mt = TermProlog;
|
||||||
@ -118,6 +127,23 @@ Term Yap_Module_Name(PredEntry *ap) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ModEntry *LookupSystemModule(Term a) {
|
||||||
|
CACHE_REGS
|
||||||
|
Atom at;
|
||||||
|
ModEntry *me;
|
||||||
|
|
||||||
|
|
||||||
|
/* prolog module */
|
||||||
|
if (a == 0) {
|
||||||
|
return GetModuleEntry(AtomProlog);
|
||||||
|
}
|
||||||
|
at = AtomOfTerm(a);
|
||||||
|
me = GetModuleEntry(at);
|
||||||
|
me->flags |= M_SYSTEM;
|
||||||
|
me->OwnerFile = Yap_ConsultingFile( PASS_REGS1 );
|
||||||
|
return me;}
|
||||||
|
|
||||||
|
|
||||||
static ModEntry *LookupModule(Term a) {
|
static ModEntry *LookupModule(Term a) {
|
||||||
Atom at;
|
Atom at;
|
||||||
ModEntry *me;
|
ModEntry *me;
|
||||||
@ -131,6 +157,13 @@ static ModEntry *LookupModule(Term a) {
|
|||||||
return me;
|
return me;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Yap_isSystemModule(Term a) {
|
||||||
|
ModEntry *me = LookupModule(a);
|
||||||
|
return
|
||||||
|
me != NULL &&
|
||||||
|
me->flags & M_SYSTEM;
|
||||||
|
}
|
||||||
|
|
||||||
Term Yap_Module(Term tmod) {
|
Term Yap_Module(Term tmod) {
|
||||||
LookupModule(tmod);
|
LookupModule(tmod);
|
||||||
return tmod;
|
return tmod;
|
||||||
@ -141,6 +174,7 @@ ModEntry *Yap_GetModuleEntry(Term mod) {
|
|||||||
if (!(me = LookupModule(mod)))
|
if (!(me = LookupModule(mod)))
|
||||||
return NULL;
|
return NULL;
|
||||||
return me;
|
return me;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Term Yap_GetModuleFromEntry(ModEntry *me) {
|
Term Yap_GetModuleFromEntry(ModEntry *me) {
|
||||||
@ -191,13 +225,6 @@ static Int
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int current_module1(USES_REGS1) { /* $current_module(Old)
|
|
||||||
*/
|
|
||||||
if (CurrentModule)
|
|
||||||
return Yap_unify_constant(ARG1, CurrentModule);
|
|
||||||
return Yap_unify_constant(ARG1, TermProlog);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Int change_module(USES_REGS1) { /* $change_module(New) */
|
static Int change_module(USES_REGS1) { /* $change_module(New) */
|
||||||
Term mod = Deref(ARG1);
|
Term mod = Deref(ARG1);
|
||||||
LookupModule(mod);
|
LookupModule(mod);
|
||||||
@ -206,6 +233,14 @@ static Int change_module(USES_REGS1) { /* $change_module(New) */
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Int current_module1(USES_REGS1) { /* $current_module(Old)
|
||||||
|
*/
|
||||||
|
if (CurrentModule)
|
||||||
|
return Yap_unify_constant(ARG1, CurrentModule);
|
||||||
|
return Yap_unify_constant(ARG1, TermProlog);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int cont_current_module(USES_REGS1) {
|
static Int cont_current_module(USES_REGS1) {
|
||||||
ModEntry *imod = AddressOfTerm(EXTRA_CBACK_ARG(1, 1)), *next;
|
ModEntry *imod = AddressOfTerm(EXTRA_CBACK_ARG(1, 1)), *next;
|
||||||
Term t = MkAtomTerm(imod->AtomOfME);
|
Term t = MkAtomTerm(imod->AtomOfME);
|
||||||
@ -280,6 +315,43 @@ static Int init_ground_module(USES_REGS1) {
|
|||||||
return cont_ground_module(PASS_REGS1);
|
return cont_ground_module(PASS_REGS1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @pred system_module( + _Mod_)
|
||||||
|
*
|
||||||
|
* @param module
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
static Int is_system_module( USES_REGS1 )
|
||||||
|
{
|
||||||
|
Term t;
|
||||||
|
if (IsVarTerm(t = Deref (ARG1))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!IsAtomTerm(t)) {
|
||||||
|
Yap_Error(TYPE_ERROR_ATOM, t, "load_files/2");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return Yap_isSystemModule( t );
|
||||||
|
}
|
||||||
|
|
||||||
|
static Int new_system_module( USES_REGS1 )
|
||||||
|
{
|
||||||
|
ModEntry *me;
|
||||||
|
Term t;
|
||||||
|
if (IsVarTerm(t = Deref (ARG1))) {
|
||||||
|
Yap_Error( INSTANTIATION_ERROR, t, NULL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!IsAtomTerm(t)) {
|
||||||
|
Yap_Error(TYPE_ERROR_ATOM, t, NULL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
me = LookupSystemModule( t );
|
||||||
|
me->OwnerFile = Yap_ConsultingFile( PASS_REGS1);
|
||||||
|
return me != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static Int strip_module(USES_REGS1) {
|
static Int strip_module(USES_REGS1) {
|
||||||
Term t1 = Deref(ARG1), tmod = CurrentModule;
|
Term t1 = Deref(ARG1), tmod = CurrentModule;
|
||||||
if (tmod == PROLOG_MODULE) {
|
if (tmod == PROLOG_MODULE) {
|
||||||
@ -359,6 +431,20 @@ static Int context_module(USES_REGS1) {
|
|||||||
return Yap_unify(ARG1, CurrentModule);
|
return Yap_unify(ARG1, CurrentModule);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @pred source_module(-Mod)
|
||||||
|
*
|
||||||
|
* @param Mod is the current text source module.
|
||||||
|
*
|
||||||
|
* : _Mod_ is the current read-in or source module.
|
||||||
|
*/
|
||||||
|
static Int source_module(USES_REGS1) {
|
||||||
|
if (LOCAL_SourceModule == PROLOG_MODULE) {
|
||||||
|
return Yap_unify(ARG1, TermProlog);
|
||||||
|
}
|
||||||
|
return Yap_unify(ARG1, LOCAL_SourceModule);
|
||||||
|
}
|
||||||
|
|
||||||
Term Yap_StripModule(Term t, Term *modp) {
|
Term Yap_StripModule(Term t, Term *modp) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
Term tmod;
|
Term tmod;
|
||||||
@ -406,9 +492,12 @@ void Yap_InitModulesC(void) {
|
|||||||
Yap_InitCPred("$change_module", 1, change_module,
|
Yap_InitCPred("$change_module", 1, change_module,
|
||||||
SafePredFlag | SyncPredFlag);
|
SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred("strip_module", 3, strip_module, SafePredFlag | SyncPredFlag);
|
Yap_InitCPred("strip_module", 3, strip_module, SafePredFlag | SyncPredFlag);
|
||||||
|
Yap_InitCPred("source_module", 1, source_module, SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred("$yap_strip_module", 3, yap_strip_module,
|
Yap_InitCPred("$yap_strip_module", 3, yap_strip_module,
|
||||||
SafePredFlag | SyncPredFlag);
|
SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred("context_module", 1, context_module, 0);
|
Yap_InitCPred("context_module", 1, context_module, 0);
|
||||||
|
Yap_InitCPred("$is_system_module", 1, is_system_module, SafePredFlag);
|
||||||
|
Yap_InitCPred("new_system_module", 1, new_system_module, SafePredFlag);
|
||||||
Yap_InitCPredBack("$all_current_modules", 1, 1, init_current_module,
|
Yap_InitCPredBack("$all_current_modules", 1, 1, init_current_module,
|
||||||
cont_current_module, SafePredFlag | SyncPredFlag);
|
cont_current_module, SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPredBack("$ground_module", 3, 1, init_ground_module,
|
Yap_InitCPredBack("$ground_module", 3, 1, init_ground_module,
|
||||||
@ -417,19 +506,19 @@ void Yap_InitModulesC(void) {
|
|||||||
|
|
||||||
void Yap_InitModules(void) {
|
void Yap_InitModules(void) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
LookupModule(MkAtomTerm(AtomProlog));
|
LookupSystemModule(MkAtomTerm(AtomProlog));
|
||||||
LOCAL_SourceModule = MkAtomTerm(AtomProlog);
|
LOCAL_SourceModule = MkAtomTerm(AtomProlog);
|
||||||
LookupModule(USER_MODULE);
|
LookupModule(USER_MODULE);
|
||||||
LookupModule(IDB_MODULE);
|
LookupModule(IDB_MODULE);
|
||||||
LookupModule(ATTRIBUTES_MODULE);
|
LookupModule(ATTRIBUTES_MODULE);
|
||||||
LookupModule(CHARSIO_MODULE);
|
LookupSystemModule(CHARSIO_MODULE);
|
||||||
LookupModule(TERMS_MODULE);
|
LookupSystemModule(TERMS_MODULE);
|
||||||
LookupModule(SYSTEM_MODULE);
|
LookupSystemModule(SYSTEM_MODULE);
|
||||||
LookupModule(READUTIL_MODULE);
|
LookupSystemModule(READUTIL_MODULE);
|
||||||
LookupModule(HACKS_MODULE);
|
LookupSystemModule(HACKS_MODULE);
|
||||||
LookupModule(ARG_MODULE);
|
LookupModule(ARG_MODULE);
|
||||||
LookupModule(GLOBALS_MODULE);
|
LookupSystemModule(GLOBALS_MODULE);
|
||||||
LookupModule(DBLOAD_MODULE);
|
LookupSystemModule(DBLOAD_MODULE);
|
||||||
LookupModule(RANGE_MODULE);
|
LookupSystemModule(RANGE_MODULE);
|
||||||
CurrentModule = PROLOG_MODULE;
|
CurrentModule = PROLOG_MODULE;
|
||||||
}
|
}
|
||||||
|
90
C/parser.c
@ -39,7 +39,8 @@ extended where necessary with attributes denoting integer precedence or
|
|||||||
operator type.
|
operator type.
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
term ----> subterm(1200) end_of_term_marker
|
term
|
||||||
|
----> subterm(1200) end_of_term_marker
|
||||||
|
|
||||||
subterm(N) ----> term(M) [M <= N]
|
subterm(N) ----> term(M) [M <= N]
|
||||||
|
|
||||||
@ -169,9 +170,7 @@ static Term ParseTerm( int, JMPBUFF *CACHE_TYPE);
|
|||||||
|
|
||||||
const char *Yap_tokRep(TokEntry *tokptr);
|
const char *Yap_tokRep(TokEntry *tokptr);
|
||||||
|
|
||||||
static void
|
static void syntax_msg(const char *msg, ...) {
|
||||||
syntax_msg( const char *msg, ...)
|
|
||||||
{
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
@ -225,7 +224,8 @@ syntax_msg( const char *msg, ...)
|
|||||||
|
|
||||||
#define FAIL siglongjmp(FailBuff->JmpBuff, 1)
|
#define FAIL siglongjmp(FailBuff->JmpBuff, 1)
|
||||||
|
|
||||||
VarEntry *Yap_LookupVar(const char *var) /* lookup variable in variables table */
|
VarEntry *
|
||||||
|
Yap_LookupVar(const char *var) /* lookup variable in variables table */
|
||||||
{
|
{
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
VarEntry *p;
|
VarEntry *p;
|
||||||
@ -627,11 +627,7 @@ loop:
|
|||||||
if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok)) {
|
if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok)) {
|
||||||
if (((int)LOCAL_tokptr->TokInfo) == ',') {
|
if (((int)LOCAL_tokptr->TokInfo) == ',') {
|
||||||
NextToken;
|
NextToken;
|
||||||
if (LOCAL_tokptr->Tok == Ord(Name_tok) &&
|
{
|
||||||
strcmp((char *)RepAtom((Atom)(LOCAL_tokptr->TokInfo))->StrOfAE, "..") == 0) {
|
|
||||||
NextToken;
|
|
||||||
to_store[1] = ParseTerm( 999, FailBuff PASS_REGS);
|
|
||||||
} else {
|
|
||||||
/* check for possible overflow against local stack */
|
/* check for possible overflow against local stack */
|
||||||
if (HR > ASP - 4096) {
|
if (HR > ASP - 4096) {
|
||||||
to_store[1] = TermNil;
|
to_store[1] = TermNil;
|
||||||
@ -649,7 +645,8 @@ loop:
|
|||||||
to_store[1] = MkAtomTerm(AtomNil);
|
to_store[1] = MkAtomTerm(AtomNil);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
syntax_msg("looking for symbol ',','|' got symbol '%s'", Yap_tokRep(LOCAL_tokptr) );
|
syntax_msg("looking for symbol ',','|' got symbol '%s'",
|
||||||
|
Yap_tokRep(LOCAL_tokptr));
|
||||||
FAIL;
|
FAIL;
|
||||||
}
|
}
|
||||||
return (o);
|
return (o);
|
||||||
@ -719,11 +716,11 @@ static Term ParseTerm( int prio, JMPBUFF *FailBuff USES_REGS) {
|
|||||||
/* try to parse as a prefix operator */
|
/* try to parse as a prefix operator */
|
||||||
TRY(
|
TRY(
|
||||||
/* build appl on the heap */
|
/* build appl on the heap */
|
||||||
func = Yap_MkFunctor((Atom)t, 1);
|
func = Yap_MkFunctor((Atom)t, 1); if (func == NULL) {
|
||||||
if (func == NULL) {
|
|
||||||
syntax_msg("Heap Overflow");
|
syntax_msg("Heap Overflow");
|
||||||
FAIL;
|
FAIL;
|
||||||
} t = ParseTerm( oprprio, FailBuff PASS_REGS);
|
}
|
||||||
|
t = ParseTerm(oprprio, FailBuff PASS_REGS);
|
||||||
t = Yap_MkApplTerm(func, 1, &t);
|
t = Yap_MkApplTerm(func, 1, &t);
|
||||||
/* check for possible overflow against local stack */
|
/* check for possible overflow against local stack */
|
||||||
if (HR > ASP - 4096) {
|
if (HR > ASP - 4096) {
|
||||||
@ -748,34 +745,46 @@ static Term ParseTerm( int prio, JMPBUFF *FailBuff USES_REGS) {
|
|||||||
case String_tok: /* build list on the heap */
|
case String_tok: /* build list on the heap */
|
||||||
{
|
{
|
||||||
Volatile char *p = (char *)LOCAL_tokptr->TokInfo;
|
Volatile char *p = (char *)LOCAL_tokptr->TokInfo;
|
||||||
t = Yap_CharsToTDQ(p, CurrentModule, ENC_ISO_LATIN1 PASS_REGS);
|
// we may be operating under a syntax error
|
||||||
|
yap_error_number oerr = LOCAL_Error_TYPE;
|
||||||
|
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||||
|
t = Yap_CharsToTDQ(p, CurrentModule, LOCAL_encoding PASS_REGS);
|
||||||
if (!t) {
|
if (!t) {
|
||||||
syntax_msg( "could not convert \'%s\'", (char *)LOCAL_tokptr->TokInfo );
|
syntax_msg("could not convert \"%s\"", (char *)LOCAL_tokptr->TokInfo);
|
||||||
FAIL;
|
FAIL;
|
||||||
}
|
}
|
||||||
|
LOCAL_Error_TYPE = oerr;
|
||||||
NextToken;
|
NextToken;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case WString_tok: /* build list on the heap */
|
case WString_tok: /* build list on the heap */
|
||||||
{
|
{
|
||||||
Volatile wchar_t *p = (wchar_t *)LOCAL_tokptr->TokInfo;
|
Volatile wchar_t *p = (wchar_t *)LOCAL_tokptr->TokInfo;
|
||||||
|
// we may be operating under a syntax error
|
||||||
|
yap_error_number oerr = LOCAL_Error_TYPE;
|
||||||
|
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||||
t = Yap_WCharsToTDQ(p, CurrentModule PASS_REGS);
|
t = Yap_WCharsToTDQ(p, CurrentModule PASS_REGS);
|
||||||
if (!t) {
|
if (!t) {
|
||||||
syntax_msg("could not convert \'%S\'", (wchar_t *)LOCAL_tokptr->TokInfo);
|
syntax_msg("could not convert \'%S\'", (wchar_t *)LOCAL_tokptr->TokInfo);
|
||||||
FAIL;
|
FAIL;
|
||||||
}
|
}
|
||||||
|
LOCAL_Error_TYPE = oerr;
|
||||||
NextToken;
|
NextToken;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case BQString_tok: /* build list on the heap */
|
case BQString_tok: /* build list on the heap */
|
||||||
{
|
{
|
||||||
Volatile char *p = (char *)LOCAL_tokptr->TokInfo;
|
Volatile char *p = (char *)LOCAL_tokptr->TokInfo;
|
||||||
|
// we may be operating under a syntax error
|
||||||
|
yap_error_number oerr = LOCAL_Error_TYPE;
|
||||||
|
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||||
|
|
||||||
t = Yap_CharsToTBQ(p, CurrentModule, ENC_ISO_LATIN1 PASS_REGS);
|
t = Yap_CharsToTBQ(p, CurrentModule, LOCAL_encoding PASS_REGS);
|
||||||
if (!t) {
|
if (!t) {
|
||||||
syntax_msg("could not convert \'%s\"", (char *)LOCAL_tokptr->TokInfo);
|
syntax_msg("could not convert \'%s\"", (char *)LOCAL_tokptr->TokInfo);
|
||||||
FAIL;
|
FAIL;
|
||||||
}
|
}
|
||||||
|
LOCAL_Error_TYPE = oerr;
|
||||||
NextToken;
|
NextToken;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@ -783,10 +792,14 @@ static Term ParseTerm( int prio, JMPBUFF *FailBuff USES_REGS) {
|
|||||||
{
|
{
|
||||||
Volatile wchar_t *p = (wchar_t *)LOCAL_tokptr->TokInfo;
|
Volatile wchar_t *p = (wchar_t *)LOCAL_tokptr->TokInfo;
|
||||||
t = Yap_WCharsToTBQ(p, CurrentModule PASS_REGS);
|
t = Yap_WCharsToTBQ(p, CurrentModule PASS_REGS);
|
||||||
|
// we may be operating under a syntax error
|
||||||
|
yap_error_number oerr = LOCAL_Error_TYPE;
|
||||||
|
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||||
if (!t) {
|
if (!t) {
|
||||||
syntax_msg("could not convert \"%S\"", (wchar_t *)LOCAL_tokptr->TokInfo);
|
syntax_msg("could not convert \"%S\"", (wchar_t *)LOCAL_tokptr->TokInfo);
|
||||||
FAIL;
|
FAIL;
|
||||||
}
|
}
|
||||||
|
LOCAL_Error_TYPE = oerr;
|
||||||
NextToken;
|
NextToken;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@ -808,7 +821,7 @@ case Var_tok:
|
|||||||
case '(':
|
case '(':
|
||||||
case 'l': /* non solo ( */
|
case 'l': /* non solo ( */
|
||||||
NextToken;
|
NextToken;
|
||||||
t = ParseTerm( 1200, FailBuff PASS_REGS);
|
t = ParseTerm(GLOBAL_MaxPriority, FailBuff PASS_REGS);
|
||||||
checkfor(')', FailBuff PASS_REGS);
|
checkfor(')', FailBuff PASS_REGS);
|
||||||
break;
|
break;
|
||||||
case '[':
|
case '[':
|
||||||
@ -830,7 +843,7 @@ case Var_tok:
|
|||||||
NextToken;
|
NextToken;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
t = ParseTerm( 1200, FailBuff PASS_REGS);
|
t = ParseTerm(GLOBAL_MaxPriority, FailBuff PASS_REGS);
|
||||||
t = Yap_MkApplTerm(FunctorBraces, 1, &t);
|
t = Yap_MkApplTerm(FunctorBraces, 1, &t);
|
||||||
/* check for possible overflow against local stack */
|
/* check for possible overflow against local stack */
|
||||||
if (HR > ASP - 4096) {
|
if (HR > ASP - 4096) {
|
||||||
@ -882,23 +895,25 @@ case Var_tok:
|
|||||||
}
|
}
|
||||||
|
|
||||||
NextToken;
|
NextToken;
|
||||||
t = ParseTerm( 1200, FailBuff PASS_REGS);
|
t = ParseTerm(GLOBAL_MaxPriority, FailBuff PASS_REGS);
|
||||||
if (LOCAL_tokptr->Tok != QuasiQuotes_tok) {
|
if (LOCAL_tokptr->Tok != QuasiQuotes_tok) {
|
||||||
syntax_msg( "expected to find quasi quotes, got \"%s\"", , Yap_tokRep(LOCAL_tokptr) );
|
syntax_msg("expected to find quasi quotes, got \"%s\"", ,
|
||||||
|
Yap_tokRep(LOCAL_tokptr));
|
||||||
FAIL;
|
FAIL;
|
||||||
}
|
}
|
||||||
if (!(is_quasi_quotation_syntax(t, &at))) {
|
if (!(is_quasi_quotation_syntax(t, &at))) {
|
||||||
syntax_msg( "bad quasi quotation syntax, at \"%s\"", Yap_tokRep(LOCAL_tokptr) );
|
syntax_msg("bad quasi quotation syntax, at \"%s\"",
|
||||||
|
Yap_tokRep(LOCAL_tokptr));
|
||||||
FAIL;
|
FAIL;
|
||||||
}
|
}
|
||||||
/* Arg 2: the content */
|
/* Arg 2: the content */
|
||||||
tn = Yap_MkNewApplTerm(SWIFunctorToFunctor(FUNCTOR_quasi_quotation4), 4);
|
tn = Yap_MkNewApplTerm(SWIFunctorToFunctor(FUNCTOR_quasi_quotation4), 4);
|
||||||
tnp = RepAppl(tn) + 1;
|
tnp = RepAppl(tn) + 1;
|
||||||
tnp[0] = MkAtomTerm(at);
|
tnp[0] = MkAtomTerm(at);
|
||||||
if (!get_quasi_quotation(Yap_InitSlot(ArgOfTerm(2, tn)),
|
if (!get_quasi_quotation(Yap_InitSlot(ArgOfTerm(2, tn)), &qq->text,
|
||||||
&qq->text,
|
|
||||||
qq->text + strlen((const char *)qq->text))) {
|
qq->text + strlen((const char *)qq->text))) {
|
||||||
syntax_msg( "could not get quasi quotation, at \"%s\"", Yap_tokRep(LOCAL_tokptr) );
|
syntax_msg("could not get quasi quotation, at \"%s\"",
|
||||||
|
Yap_tokRep(LOCAL_tokptr));
|
||||||
FAIL;
|
FAIL;
|
||||||
}
|
}
|
||||||
if (positions) {
|
if (positions) {
|
||||||
@ -909,18 +924,19 @@ case Var_tok:
|
|||||||
FUNCTOR_minus2, PL_INTPTR,
|
FUNCTOR_minus2, PL_INTPTR,
|
||||||
qq->mid.charno + 2, /* end of | token */
|
qq->mid.charno + 2, /* end of | token */
|
||||||
PL_INTPTR, qqend - 2)) /* end minus "|}" */
|
PL_INTPTR, qqend - 2)) /* end minus "|}" */
|
||||||
syntax_msg( "failed to unify quasi quotation, at \"%s\"", Yap_tokRep(LOCAL_tokptr) );
|
syntax_msg("failed to unify quasi quotation, at \"%s\"",
|
||||||
|
Yap_tokRep(LOCAL_tokptr));
|
||||||
FAIL;
|
FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
tnp[2] =
|
tnp[2] = Yap_GetFromSlot(LOCAL_varnames); /* Arg 3: the var dictionary */
|
||||||
Yap_GetFromSlot(LOCAL_varnames); /* Arg 3: the var dictionary */
|
|
||||||
/* Arg 4: the result */
|
/* Arg 4: the result */
|
||||||
t = ArgOfTerm(4, tn);
|
t = ArgOfTerm(4, tn);
|
||||||
if (!(to = PL_new_term_ref()) ||
|
if (!(to = PL_new_term_ref()) ||
|
||||||
!PL_unify_list(LOCAL_qq_tail, to, LOCAL_qq_tail) ||
|
!PL_unify_list(LOCAL_qq_tail, to, LOCAL_qq_tail) ||
|
||||||
!PL_unify(to, Yap_InitSlot(tn))) {
|
!PL_unify(to, Yap_InitSlot(tn))) {
|
||||||
syntax_msg( "failed to unify quasi quotation, at \"%s\"", Yap_tokRep(LOCAL_tokptr) );
|
syntax_msg("failed to unify quasi quotation, at \"%s\"",
|
||||||
|
Yap_tokRep(LOCAL_tokptr));
|
||||||
FAIL;
|
FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -941,7 +957,8 @@ case Var_tok:
|
|||||||
opprio <= prio && oplprio >= curprio) {
|
opprio <= prio && oplprio >= curprio) {
|
||||||
/* try parsing as infix operator */
|
/* try parsing as infix operator */
|
||||||
Volatile int oldprio = curprio;
|
Volatile int oldprio = curprio;
|
||||||
TRY3(func = Yap_MkFunctor((Atom)LOCAL_tokptr->TokInfo, 2);
|
TRY3(
|
||||||
|
func = Yap_MkFunctor((Atom)LOCAL_tokptr->TokInfo, 2);
|
||||||
if (func == NULL) {
|
if (func == NULL) {
|
||||||
syntax_msg("Heap Overflow");
|
syntax_msg("Heap Overflow");
|
||||||
FAIL;
|
FAIL;
|
||||||
@ -1056,20 +1073,19 @@ Term Yap_Parse(UInt prio) {
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
if (GLOBAL_Option['p' - 'a' + 1]) {
|
if (GLOBAL_Option['p' - 'a' + 1]) {
|
||||||
Yap_DebugPutc(stderr, '[');
|
Yap_DebugPutc(stderr, '[');
|
||||||
if (t==0) Yap_DebugPlWrite(MkIntTerm(0));
|
if (t == 0)
|
||||||
else Yap_DebugPlWrite(t);
|
Yap_DebugPlWrite(MkIntTerm(0));
|
||||||
|
else
|
||||||
|
Yap_DebugPlWrite(t);
|
||||||
Yap_DebugPutc(stderr, ']');
|
Yap_DebugPutc(stderr, ']');
|
||||||
Yap_DebugPutc(stderr, '\n');
|
Yap_DebugPutc(stderr, '\n');
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
Yap_CloseSlots(sls);
|
Yap_CloseSlots(sls);
|
||||||
if (LOCAL_tokptr != NULL &&
|
if (LOCAL_tokptr != NULL && LOCAL_tokptr->Tok != Ord(eot_tok)) {
|
||||||
LOCAL_tokptr->Tok != Ord(eot_tok)
|
|
||||||
) {
|
|
||||||
t = 0;
|
t = 0;
|
||||||
}
|
}
|
||||||
if (t != 0 &&
|
if (t != 0 && LOCAL_Error_TYPE == SYNTAX_ERROR) {
|
||||||
LOCAL_Error_TYPE == SYNTAX_ERROR) {
|
|
||||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||||
LOCAL_ErrorMessage = NULL;
|
LOCAL_ErrorMessage = NULL;
|
||||||
}
|
}
|
||||||
|
41
C/qlyr.c
@ -698,7 +698,7 @@ read_tag(FILE *stream)
|
|||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
static UInt
|
static pred_flags_t
|
||||||
read_predFlags(FILE *stream)
|
read_predFlags(FILE *stream)
|
||||||
{
|
{
|
||||||
pred_flags_t v;
|
pred_flags_t v;
|
||||||
@ -1018,23 +1018,30 @@ read_pred(FILE *stream, Term mod) {
|
|||||||
|
|
||||||
ap = LookupPredEntry((PredEntry *)read_UInt(stream));
|
ap = LookupPredEntry((PredEntry *)read_UInt(stream));
|
||||||
flags = read_predFlags(stream);
|
flags = read_predFlags(stream);
|
||||||
|
#if 0
|
||||||
|
if (ap->ArityOfPE && ap->ModuleOfPred != IDB_MODULE)
|
||||||
|
// __android_log_print(ANDROID_LOG_INFO, "YAP ", " %s/%ld %llx %llx\n", NameOfFunctor(ap->FunctorOfPred)->StrOfAE, ap->ArityOfPE, ap->PredFlags, flags);
|
||||||
|
printf(" %s/%ld %llx %llx\n", NameOfFunctor(ap->FunctorOfPred)->StrOfAE, ap->ArityOfPE, ap->PredFlags, flags);
|
||||||
|
else if (ap->ModuleOfPred != IDB_MODULE)
|
||||||
|
//__android_log_print(ANDROID_LOG_INFO, "YAP "," %s/%ld %llx %llx\n", ((Atom)(ap->FunctorOfPred))->StrOfAE, ap->ArityOfPE, flags);
|
||||||
|
printf(" %s/%ld %llx %llx\n", ((Atom)(ap->FunctorOfPred))->StrOfAE, ap->ArityOfPE, ap->PredFlags, flags);
|
||||||
|
//else
|
||||||
|
// __android_log_print(ANDROID_LOG_INFO, "YAP "," number\n");
|
||||||
|
#endif
|
||||||
|
if (flags & ForeignPredFlags) {
|
||||||
|
if (!(ap->PredFlags & ForeignPredFlags))
|
||||||
|
QLYR_ERROR(INCONSISTENT_CPRED);
|
||||||
|
if (flags & MetaPredFlag)
|
||||||
|
ap->PredFlags |= MetaPredFlag;
|
||||||
|
return;
|
||||||
|
}
|
||||||
nclauses = read_UInt(stream);
|
nclauses = read_UInt(stream);
|
||||||
if (ap->PredFlags & IndexedPredFlag) {
|
if (ap->PredFlags & IndexedPredFlag) {
|
||||||
Yap_RemoveIndexation(ap);
|
Yap_RemoveIndexation(ap);
|
||||||
}
|
}
|
||||||
#if 0
|
//fl1 = flags & ((pred_flags_t)STATIC_PRED_FLAGS|(UInt)EXTRA_PRED_FLAGS);
|
||||||
if (ap->ArityOfPE && ap->ModuleOfPred != IDB_MODULE)
|
//ap->PredFlags &= ~((UInt)STATIC_PRED_FLAGS|(UInt)EXTRA_PRED_FLAGS);
|
||||||
__android_log_print(ANDROID_LOG_INFO, "YAP ", " %s/%ld %lx\n", NameOfFunctor(ap->FunctorOfPred)->StrOfAE, ap->ArityOfPE, flags);
|
ap->PredFlags = flags & ~StatePredFlags;
|
||||||
/* printf(" %s/%ld %lx\n", NameOfFunctor(ap->FunctorOfPred)->StrOfAE, ap->ArityOfPE, flags); */
|
|
||||||
else if (ap->ModuleOfPred != IDB_MODULE)
|
|
||||||
__android_log_print(ANDROID_LOG_INFO, "YAP "," %s/%ld %lx\n", ((Atom)(ap->FunctorOfPred))->StrOfAE, ap->ArityOfPE, flags);
|
|
||||||
/* printf(" %s/%ld %lx\n", ((Atom)(ap->FunctorOfPred))->StrOfAE, ap->ArityOfPE, flags); */
|
|
||||||
else
|
|
||||||
__android_log_print(ANDROID_LOG_INFO, "YAP "," number\n");
|
|
||||||
#endif
|
|
||||||
fl1 = flags & ((pred_flags_t)STATIC_PRED_FLAGS|(UInt)EXTRA_PRED_FLAGS);
|
|
||||||
ap->PredFlags &= ~((UInt)STATIC_PRED_FLAGS|(UInt)EXTRA_PRED_FLAGS);
|
|
||||||
ap->PredFlags |= fl1;
|
|
||||||
if (flags & NumberDBPredFlag) {
|
if (flags & NumberDBPredFlag) {
|
||||||
ap->src.IndxId = read_UInt(stream);
|
ap->src.IndxId = read_UInt(stream);
|
||||||
} else {
|
} else {
|
||||||
@ -1046,9 +1053,9 @@ read_pred(FILE *stream, Term mod) {
|
|||||||
}
|
}
|
||||||
ap->TimeStampOfPred = read_UInt(stream);
|
ap->TimeStampOfPred = read_UInt(stream);
|
||||||
/* multifile predicates cannot reside in module 0 */
|
/* multifile predicates cannot reside in module 0 */
|
||||||
if (flags & MultiFileFlag && ap->ModuleOfPred == PROLOG_MODULE) {
|
// if (flags & MultiFileFlag && ap->ModuleOfPred == PROLOG_MODULE) {
|
||||||
ap->ModuleOfPred = TermProlog;
|
// ap->ModuleOfPred = TermProlog;
|
||||||
}
|
// }
|
||||||
if (nclauses)
|
if (nclauses)
|
||||||
read_clauses(stream, ap, nclauses, flags);
|
read_clauses(stream, ap, nclauses, flags);
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
9
C/qlyw.c
@ -698,6 +698,8 @@ static size_t
|
|||||||
save_pred(FILE *stream, PredEntry *ap) {
|
save_pred(FILE *stream, PredEntry *ap) {
|
||||||
CHECK(save_UInt(stream, (UInt)ap));
|
CHECK(save_UInt(stream, (UInt)ap));
|
||||||
CHECK(save_predFlags(stream, ap->PredFlags));
|
CHECK(save_predFlags(stream, ap->PredFlags));
|
||||||
|
if (ap->PredFlags & ForeignPredFlags)
|
||||||
|
return 1;
|
||||||
CHECK(save_UInt(stream, ap->cs.p_code.NOfClauses));
|
CHECK(save_UInt(stream, ap->cs.p_code.NOfClauses));
|
||||||
CHECK(save_UInt(stream, ap->src.IndxId));
|
CHECK(save_UInt(stream, ap->src.IndxId));
|
||||||
CHECK(save_UInt(stream, ap->TimeStampOfPred));
|
CHECK(save_UInt(stream, ap->TimeStampOfPred));
|
||||||
@ -706,11 +708,8 @@ save_pred(FILE *stream, PredEntry *ap) {
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
clean_pred(PredEntry *pp USES_REGS) {
|
clean_pred(PredEntry *pp USES_REGS) {
|
||||||
if (pp->PredFlags & (AsmPredFlag|CPredFlag)) {
|
if (pp->PredFlags & ForeignPredFlags) {
|
||||||
/* assembly */
|
return true;
|
||||||
if (pp->CodeOfPred) {
|
|
||||||
CleanClauses(pp->CodeOfPred, pp->CodeOfPred, pp PASS_REGS);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
CleanClauses(pp->cs.p_code.FirstClause, pp->cs.p_code.LastClause, pp PASS_REGS);
|
CleanClauses(pp->cs.p_code.FirstClause, pp->cs.p_code.LastClause, pp PASS_REGS);
|
||||||
}
|
}
|
||||||
|
6
C/save.c
@ -455,7 +455,7 @@ save_regs(int mode USES_REGS)
|
|||||||
if (putcellptr(CellPtr(HeapTop)) < 0)
|
if (putcellptr(CellPtr(HeapTop)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
/* and the space it ocuppies */
|
/* and the space it ocuppies */
|
||||||
if (putout(Unsigned(Yap_heap_regs->heap_used)) < 0)
|
if (putout(Unsigned(HeapUsed)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
/* Then the start of the free code */
|
/* Then the start of the free code */
|
||||||
if (putcellptr(CellPtr(FreeBlocks)) < 0)
|
if (putcellptr(CellPtr(FreeBlocks)) < 0)
|
||||||
@ -1035,6 +1035,8 @@ get_coded(int flag, OPCODE old_ops[] USES_REGS)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* restore some heap registers */
|
/* restore some heap registers */
|
||||||
static void
|
static void
|
||||||
restore_heap_regs( USES_REGS1 )
|
restore_heap_regs( USES_REGS1 )
|
||||||
@ -1043,7 +1045,7 @@ restore_heap_regs( USES_REGS1 )
|
|||||||
HeapTop = AddrAdjust(HeapTop);
|
HeapTop = AddrAdjust(HeapTop);
|
||||||
*((YAP_SEG_SIZE *) HeapTop) = InUseFlag;
|
*((YAP_SEG_SIZE *) HeapTop) = InUseFlag;
|
||||||
}
|
}
|
||||||
HeapMax = Yap_heap_regs->heap_used = OldHeapUsed;
|
HeapMax = HeapUsed = OldHeapUsed;
|
||||||
HeapLim = LOCAL_GlobalBase;
|
HeapLim = LOCAL_GlobalBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
13
C/scanner.c
@ -1735,17 +1735,16 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments,
|
|||||||
case SY:
|
case SY:
|
||||||
if (ch == '`')
|
if (ch == '`')
|
||||||
goto quoted_string;
|
goto quoted_string;
|
||||||
if (ch == '.') {
|
och = ch;
|
||||||
int nch = Yap_peek(inp_stream - GLOBAL_Stream);
|
ch = getchr(inp_stream);
|
||||||
if (chtype(nch) == BS || chtype(nch) == EF || nch == '%') {
|
if (och == '.') {
|
||||||
|
if (chtype(ch) == BS || chtype(ch) == EF || ch == '%') {
|
||||||
t->Tok = Ord(kind = eot_tok);
|
t->Tok = Ord(kind = eot_tok);
|
||||||
if (chtype(ch) == EF)
|
if (chtype(ch) == EF)
|
||||||
mark_eof(inp_stream);
|
mark_eof(inp_stream);
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
och = ch;
|
|
||||||
ch = getchr(inp_stream);
|
|
||||||
if (och == '/' && ch == '*') {
|
if (och == '/' && ch == '*') {
|
||||||
if (store_comments) {
|
if (store_comments) {
|
||||||
CHECK_SPACE();
|
CHECK_SPACE();
|
||||||
@ -1830,9 +1829,9 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments,
|
|||||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||||
t->Tok = Ord(kind = Name_tok);
|
t->Tok = Ord(kind = Name_tok);
|
||||||
if (ch == '(')
|
if (ch == '(')
|
||||||
solo_flag = FALSE;
|
solo_flag = false;
|
||||||
else
|
else
|
||||||
solo_flag = TRUE;
|
solo_flag = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
120
C/signals.c
@ -51,13 +51,12 @@ static char SccsId[] = "%W% %G%";
|
|||||||
#include <tracer.h>
|
#include <tracer.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The InteractSIGINT function is called after a normal interrupt had been caught.
|
* The InteractSIGINT function is called after a normal interrupt had been
|
||||||
|
* caught.
|
||||||
* It allows 6 possibilities: abort, continue, trace, debug, help, exit.
|
* It allows 6 possibilities: abort, continue, trace, debug, help, exit.
|
||||||
*/
|
*/
|
||||||
static yap_signals
|
static yap_signals InteractSIGINT(int ch) {
|
||||||
InteractSIGINT(int ch) {
|
|
||||||
#ifdef HAVE_SETBUF
|
#ifdef HAVE_SETBUF
|
||||||
/* make sure we are not waiting for the end of line */
|
/* make sure we are not waiting for the end of line */
|
||||||
setbuf(stdin, NULL);
|
setbuf(stdin, NULL);
|
||||||
@ -101,7 +100,8 @@ InteractSIGINT(int ch) {
|
|||||||
/* show an helpful message */
|
/* show an helpful message */
|
||||||
fprintf(stderr, "Please press one of:\n");
|
fprintf(stderr, "Please press one of:\n");
|
||||||
fprintf(stderr, " a for abort\n c for continue\n d for debug\n");
|
fprintf(stderr, " a for abort\n c for continue\n d for debug\n");
|
||||||
fprintf(stderr, " e for exit\n g for stack dump\n s for statistics\n t for trace\n");
|
fprintf(stderr, " e for exit\n g for stack dump\n s for statistics\n t "
|
||||||
|
"for trace\n");
|
||||||
fprintf(stderr, " b for break\n");
|
fprintf(stderr, " b for break\n");
|
||||||
return YAP_NO_SIGNAL;
|
return YAP_NO_SIGNAL;
|
||||||
}
|
}
|
||||||
@ -111,9 +111,7 @@ InteractSIGINT(int ch) {
|
|||||||
This function talks to the user about a signal. We assume we are in
|
This function talks to the user about a signal. We assume we are in
|
||||||
the context of the main Prolog thread (trivial in Unix, but hard in WIN32)
|
the context of the main Prolog thread (trivial in Unix, but hard in WIN32)
|
||||||
*/
|
*/
|
||||||
static yap_signals
|
static yap_signals ProcessSIGINT(void) {
|
||||||
ProcessSIGINT(void)
|
|
||||||
{
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
int ch, out;
|
int ch, out;
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
@ -133,9 +131,7 @@ ProcessSIGINT(void)
|
|||||||
return (out);
|
return (out);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static void
|
inline static void do_signal(int wid, yap_signals sig USES_REGS) {
|
||||||
do_signal(int wid, yap_signals sig USES_REGS)
|
|
||||||
{
|
|
||||||
#if THREADS
|
#if THREADS
|
||||||
__sync_fetch_and_or(&REMOTE(wid)->Signals_, SIGNAL_TO_BIT(sig));
|
__sync_fetch_and_or(&REMOTE(wid)->Signals_, SIGNAL_TO_BIT(sig));
|
||||||
if (!REMOTE_InterruptsDisabled(wid)) {
|
if (!REMOTE_InterruptsDisabled(wid)) {
|
||||||
@ -145,17 +141,12 @@ do_signal(int wid, yap_signals sig USES_REGS)
|
|||||||
#else
|
#else
|
||||||
LOCAL_Signals |= SIGNAL_TO_BIT(sig);
|
LOCAL_Signals |= SIGNAL_TO_BIT(sig);
|
||||||
if (!LOCAL_InterruptsDisabled) {
|
if (!LOCAL_InterruptsDisabled) {
|
||||||
CreepFlag =
|
CreepFlag = Unsigned(LCL0);
|
||||||
Unsigned(LCL0);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline static bool get_signal(yap_signals sig USES_REGS) {
|
||||||
|
|
||||||
inline static int
|
|
||||||
get_signal(yap_signals sig USES_REGS)
|
|
||||||
{
|
|
||||||
#if THREADS
|
#if THREADS
|
||||||
uint64_t old;
|
uint64_t old;
|
||||||
|
|
||||||
@ -195,9 +186,7 @@ get_signal(yap_signals sig USES_REGS)
|
|||||||
/**
|
/**
|
||||||
Function called to handle delayed interrupts.
|
Function called to handle delayed interrupts.
|
||||||
*/
|
*/
|
||||||
int
|
int Yap_HandleInterrupts(void) {
|
||||||
Yap_HandleInterrupts( void )
|
|
||||||
{
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
yap_signals sig;
|
yap_signals sig;
|
||||||
|
|
||||||
@ -210,9 +199,7 @@ Yap_HandleInterrupts( void )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int p_creep(USES_REGS1) {
|
||||||
p_creep( USES_REGS1 )
|
|
||||||
{
|
|
||||||
Atom at;
|
Atom at;
|
||||||
PredEntry *pred;
|
PredEntry *pred;
|
||||||
|
|
||||||
@ -223,9 +210,7 @@ p_creep( USES_REGS1 )
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int p_creep_fail(USES_REGS1) {
|
||||||
p_creep_fail( USES_REGS1 )
|
|
||||||
{
|
|
||||||
Atom at;
|
Atom at;
|
||||||
PredEntry *pred;
|
PredEntry *pred;
|
||||||
|
|
||||||
@ -236,15 +221,19 @@ p_creep_fail( USES_REGS1 )
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int stop_creeping( USES_REGS1 )
|
static Int stop_creeping(USES_REGS1) {
|
||||||
{
|
if (get_signal(YAP_CREEP_SIGNAL PASS_REGS)) {
|
||||||
|
return Yap_unify(ARG1, TermTrue);
|
||||||
|
}
|
||||||
|
return Yap_unify(ARG1, TermFalse);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Int disable_debugging(USES_REGS1) {
|
||||||
get_signal(YAP_CREEP_SIGNAL PASS_REGS);
|
get_signal(YAP_CREEP_SIGNAL PASS_REGS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int creep_allowed(USES_REGS1) {
|
||||||
creep_allowed( USES_REGS1 )
|
|
||||||
{
|
|
||||||
if (PP != NULL) {
|
if (PP != NULL) {
|
||||||
get_signal(YAP_CREEP_SIGNAL PASS_REGS);
|
get_signal(YAP_CREEP_SIGNAL PASS_REGS);
|
||||||
return true;
|
return true;
|
||||||
@ -252,21 +241,16 @@ creep_allowed( USES_REGS1 )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void Yap_signal(yap_signals sig) {
|
||||||
Yap_signal(yap_signals sig)
|
|
||||||
{
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
do_signal(worker_id, sig PASS_REGS);
|
do_signal(worker_id, sig PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
static Int
|
static Int p_debug(USES_REGS1);
|
||||||
p_debug( USES_REGS1 );
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void Yap_external_signal(int wid, yap_signals sig) {
|
||||||
Yap_external_signal(int wid, yap_signals sig)
|
|
||||||
{
|
|
||||||
#if THREADS
|
#if THREADS
|
||||||
REGSTORE *regcache = REMOTE_ThreadHandle(wid).current_yaam_regs;
|
REGSTORE *regcache = REMOTE_ThreadHandle(wid).current_yaam_regs;
|
||||||
#endif
|
#endif
|
||||||
@ -274,23 +258,16 @@ Yap_external_signal(int wid, yap_signals sig)
|
|||||||
LOCAL_PrologMode &= ~InterruptMode;
|
LOCAL_PrologMode &= ~InterruptMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int Yap_get_signal__(yap_signals sig USES_REGS) {
|
||||||
Yap_get_signal__(yap_signals sig USES_REGS)
|
|
||||||
{
|
|
||||||
return get_signal(sig PASS_REGS);
|
return get_signal(sig PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// the caller holds the lock.
|
// the caller holds the lock.
|
||||||
int
|
int Yap_has_signals__(yap_signals sig1, yap_signals sig2 USES_REGS) {
|
||||||
Yap_has_signals__(yap_signals sig1, yap_signals sig2 USES_REGS)
|
|
||||||
{
|
|
||||||
return LOCAL_Signals & (SIGNAL_TO_BIT(sig1) | SIGNAL_TO_BIT(sig2));
|
return LOCAL_Signals & (SIGNAL_TO_BIT(sig1) | SIGNAL_TO_BIT(sig2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Yap_only_has_signals__(yap_signals sig1, yap_signals sig2 USES_REGS) {
|
||||||
int
|
|
||||||
Yap_only_has_signals__(yap_signals sig1, yap_signals sig2 USES_REGS)
|
|
||||||
{
|
|
||||||
uint64_t sigs = LOCAL_Signals;
|
uint64_t sigs = LOCAL_Signals;
|
||||||
return sigs & (SIGNAL_TO_BIT(sig1) | SIGNAL_TO_BIT(sig2)) &&
|
return sigs & (SIGNAL_TO_BIT(sig1) | SIGNAL_TO_BIT(sig2)) &&
|
||||||
!(sigs & ~(SIGNAL_TO_BIT(sig1) | SIGNAL_TO_BIT(sig2)));
|
!(sigs & ~(SIGNAL_TO_BIT(sig1) | SIGNAL_TO_BIT(sig2)));
|
||||||
@ -300,33 +277,26 @@ Yap_only_has_signals__(yap_signals sig1, yap_signals sig2 USES_REGS)
|
|||||||
|
|
||||||
volatile int volat = 0;
|
volatile int volat = 0;
|
||||||
|
|
||||||
static Int
|
static Int p_debug(USES_REGS1) { /* $debug(+Flag) */
|
||||||
p_debug( USES_REGS1 )
|
|
||||||
{ /* $debug(+Flag) */
|
|
||||||
int i = IntOfTerm(Deref(ARG1));
|
int i = IntOfTerm(Deref(ARG1));
|
||||||
while (volat == 0) {
|
while (volat == 0) {
|
||||||
}
|
}
|
||||||
if (i >= 'a' && i <= 'z')
|
if (i >= 'a' && i <= 'z')
|
||||||
GLOBAL_Option[i - 96] = !GLOBAL_Option[i - 96];
|
GLOBAL_Option[i - 96] = !GLOBAL_Option[i - 96];
|
||||||
return (1);
|
return 1;
|
||||||
}
|
}
|
||||||
void Yap_loop(void);
|
void Yap_loop(void);
|
||||||
void Yap_debug_end_loop(void);
|
void Yap_debug_end_loop(void);
|
||||||
|
|
||||||
void Yap_loop(void)
|
void Yap_loop(void) {
|
||||||
{
|
while (volat == 0)
|
||||||
while (volat == 0);
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Yap_debug_end_loop(void)
|
void Yap_debug_end_loop(void) { volat = 1; }
|
||||||
{
|
|
||||||
volat = 1;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Int
|
static Int first_signal(USES_REGS1) {
|
||||||
first_signal( USES_REGS1 )
|
|
||||||
{
|
|
||||||
Atom at;
|
Atom at;
|
||||||
yap_signals sig;
|
yap_signals sig;
|
||||||
|
|
||||||
@ -439,30 +409,26 @@ first_signal( USES_REGS1 )
|
|||||||
return Yap_unify(ARG1, MkAtomTerm(at));
|
return Yap_unify(ARG1, MkAtomTerm(at));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int continue_signals(USES_REGS1) { return first_signal(PASS_REGS1); }
|
||||||
continue_signals( USES_REGS1 )
|
|
||||||
{
|
|
||||||
return first_signal( PASS_REGS1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void Yap_InitSignalCPreds(void) {
|
||||||
Yap_InitSignalCPreds(void)
|
|
||||||
{
|
|
||||||
/* Basic predicates for the debugger */
|
/* Basic predicates for the debugger */
|
||||||
Yap_InitCPred("$creep", 0, p_creep, SafePredFlag);
|
Yap_InitCPred("$creep", 0, p_creep, SafePredFlag);
|
||||||
Yap_InitCPred("$creep_fail", 0, p_creep_fail, SafePredFlag);
|
Yap_InitCPred("$creep_fail", 0, p_creep_fail, SafePredFlag);
|
||||||
Yap_InitCPred("$stop_creeping", 0, stop_creeping, NoTracePredFlag|HiddenPredFlag|SafePredFlag);
|
Yap_InitCPred("$stop_creeping", 1, stop_creeping,
|
||||||
Yap_InitCPred("$disable_debugging", 0, stop_creeping, NoTracePredFlag|HiddenPredFlag|SafePredFlag);
|
NoTracePredFlag | HiddenPredFlag | SafePredFlag);
|
||||||
|
Yap_InitCPred("$disable_debugging", 0, disable_debugging,
|
||||||
|
NoTracePredFlag | HiddenPredFlag | SafePredFlag);
|
||||||
Yap_InitCPred("$first_signal", 1, first_signal, SafePredFlag | SyncPredFlag);
|
Yap_InitCPred("$first_signal", 1, first_signal, SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred ("$continue_signals", 0, continue_signals, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("$continue_signals", 0, continue_signals,
|
||||||
|
SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred("creep_allowed", 0, creep_allowed, 0);
|
Yap_InitCPred("creep_allowed", 0, creep_allowed, 0);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Yap_InitCPred("sys_debug", 1, p_debug, SafePredFlag | SyncPredFlag);
|
Yap_InitCPred("sys_debug", 1, p_debug, SafePredFlag | SyncPredFlag);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void *Yap_InitSignals(int wid)
|
void *Yap_InitSignals(int wid) {
|
||||||
{
|
|
||||||
void *ptr = (void *)malloc(sizeof(UInt) * REMOTE_MaxActiveSignals(wid));
|
void *ptr = (void *)malloc(sizeof(UInt) * REMOTE_MaxActiveSignals(wid));
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
21
C/stack.c
@ -1768,8 +1768,7 @@ void DumpActiveGoals(USES_REGS1) {
|
|||||||
if (mod == PROLOG_MODULE)
|
if (mod == PROLOG_MODULE)
|
||||||
mod = TermProlog;
|
mod = TermProlog;
|
||||||
Term t = Yap_MkNewApplTerm(f, pe->ArityOfPE);
|
Term t = Yap_MkNewApplTerm(f, pe->ArityOfPE);
|
||||||
Yap_plwrite(Yap_PredicateIndicator(t,mod),GLOBAL_Stream+2, 0, 0, 1200);
|
Yap_plwrite(Yap_PredicateIndicator(t,mod),GLOBAL_Stream+2, 0, 0, GLOBAL_MaxPriority);
|
||||||
|
|
||||||
fputc( '\n', stderr );
|
fputc( '\n', stderr );
|
||||||
} else {
|
} else {
|
||||||
UNLOCK(pe->PELock);
|
UNLOCK(pe->PELock);
|
||||||
@ -1798,23 +1797,23 @@ void DumpActiveGoals(USES_REGS1) {
|
|||||||
else
|
else
|
||||||
mod = TermProlog;
|
mod = TermProlog;
|
||||||
if (mod != TermProlog && mod != MkAtomTerm(AtomUser)) {
|
if (mod != TermProlog && mod != MkAtomTerm(AtomUser)) {
|
||||||
Yap_plwrite(mod,GLOBAL_Stream+2, 0, 0, 1200);
|
Yap_plwrite(mod,GLOBAL_Stream+2, 0, 0, GLOBAL_MaxPriority);
|
||||||
fputc( ':', stderr );
|
fputc( ':', stderr );
|
||||||
}
|
}
|
||||||
if (mod == IDB_MODULE) {
|
if (mod == IDB_MODULE) {
|
||||||
if (pe->PredFlags & NumberDBPredFlag) {
|
if (pe->PredFlags & NumberDBPredFlag) {
|
||||||
Int id = pe->src.IndxId;
|
Int id = pe->src.IndxId;
|
||||||
Yap_plwrite(MkIntegerTerm(id),GLOBAL_Stream+2, 0, 0, 1200);
|
Yap_plwrite(MkIntegerTerm(id),GLOBAL_Stream+2, 0, 0, GLOBAL_MaxPriority);
|
||||||
} else if (pe->PredFlags & AtomDBPredFlag) {
|
} else if (pe->PredFlags & AtomDBPredFlag) {
|
||||||
Atom At = (Atom)pe->FunctorOfPred;
|
Atom At = (Atom)pe->FunctorOfPred;
|
||||||
Yap_plwrite(MkAtomTerm(At),GLOBAL_Stream+2, 0, 0, 1200);
|
Yap_plwrite(MkAtomTerm(At),GLOBAL_Stream+2, 0, 0, GLOBAL_MaxPriority);
|
||||||
} else {
|
} else {
|
||||||
Functor f = pe->FunctorOfPred;
|
Functor f = pe->FunctorOfPred;
|
||||||
Atom At = NameOfFunctor(f);
|
Atom At = NameOfFunctor(f);
|
||||||
arity_t arity = ArityOfFunctor(f);
|
arity_t arity = ArityOfFunctor(f);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
Yap_plwrite(MkAtomTerm(At),GLOBAL_Stream+2, 0, 0, 1200);
|
Yap_plwrite(MkAtomTerm(At),GLOBAL_Stream+2, 0, 0, GLOBAL_MaxPriority);
|
||||||
fputc( '(', stderr );
|
fputc( '(', stderr );
|
||||||
for (i = 0; i < arity; i++) {
|
for (i = 0; i < arity; i++) {
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
@ -1824,14 +1823,14 @@ void DumpActiveGoals(USES_REGS1) {
|
|||||||
fputc( ')', stderr );
|
fputc( ')', stderr );
|
||||||
}
|
}
|
||||||
fputc( '(', stderr );
|
fputc( '(', stderr );
|
||||||
Yap_plwrite(b_ptr->cp_a2,GLOBAL_Stream+2, 0, 0, 1200);
|
Yap_plwrite(b_ptr->cp_a2,GLOBAL_Stream+2, 0, 0, GLOBAL_MaxPriority);
|
||||||
fputc( ')', stderr );
|
fputc( ')', stderr );
|
||||||
} else if (pe->ArityOfPE == 0) {
|
} else if (pe->ArityOfPE == 0) {
|
||||||
Yap_plwrite(MkAtomTerm((Atom)f),GLOBAL_Stream+2, 0, 0, 1200);
|
Yap_plwrite(MkAtomTerm((Atom)f),GLOBAL_Stream+2, 0, 0, GLOBAL_MaxPriority);
|
||||||
} else {
|
} else {
|
||||||
Int i = 0, arity = pe->ArityOfPE;
|
Int i = 0, arity = pe->ArityOfPE;
|
||||||
if (opnum == _or_last || opnum == _or_else) {
|
if (opnum == _or_last || opnum == _or_else) {
|
||||||
Yap_plwrite(MkAtomTerm(NameOfFunctor(f)),GLOBAL_Stream+2, 0, 0, 1200);
|
Yap_plwrite(MkAtomTerm(NameOfFunctor(f)),GLOBAL_Stream+2, 0, 0, GLOBAL_MaxPriority);
|
||||||
fputc( '(', stderr );
|
fputc( '(', stderr );
|
||||||
for (i = 0; i < arity; i++) {
|
for (i = 0; i < arity; i++) {
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
@ -1841,12 +1840,12 @@ void DumpActiveGoals(USES_REGS1) {
|
|||||||
fputs(") :- ... ( _ ; _ ", stderr);
|
fputs(") :- ... ( _ ; _ ", stderr);
|
||||||
} else {
|
} else {
|
||||||
Term *args = &(b_ptr->cp_a1);
|
Term *args = &(b_ptr->cp_a1);
|
||||||
Yap_plwrite(MkAtomTerm(NameOfFunctor(f)),GLOBAL_Stream+2, 0, 0, 1200);
|
Yap_plwrite(MkAtomTerm(NameOfFunctor(f)),GLOBAL_Stream+2, 0, 0, GLOBAL_MaxPriority);
|
||||||
fputc( '(', stderr );
|
fputc( '(', stderr );
|
||||||
for (i = 0; i < arity; i++) {
|
for (i = 0; i < arity; i++) {
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
fputc( ',', stderr );
|
fputc( ',', stderr );
|
||||||
Yap_plwrite(args[i],GLOBAL_Stream+2, 0, 0, 1200);
|
Yap_plwrite(args[i],GLOBAL_Stream+2, 0, 0, GLOBAL_MaxPriority);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fputc( ')', stderr );
|
fputc( ')', stderr );
|
||||||
|
57
C/stdpreds.c
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* *
|
* *
|
||||||
* YAP Prolog *
|
* YAP Prolog *
|
||||||
@ -922,7 +923,8 @@ static PropEntry *nextPredForAtom(PropEntry *p, Term task) {
|
|||||||
if (p == NIL)
|
if (p == NIL)
|
||||||
return NIL;
|
return NIL;
|
||||||
pe = RepPredProp(p);
|
pe = RepPredProp(p);
|
||||||
if (pe->ArityOfPE == 0) {
|
if (pe->ArityOfPE == 0 ||
|
||||||
|
(pe->PredFlags & (NumberDBPredFlag |AtomDBPredFlag) ) ) {
|
||||||
// if atom prop, search atom list
|
// if atom prop, search atom list
|
||||||
return followLinkedListOfProps(p->NextOfPE, task);
|
return followLinkedListOfProps(p->NextOfPE, task);
|
||||||
} else {
|
} else {
|
||||||
@ -981,15 +983,7 @@ static PredEntry *firstModulePred(PredEntry *npp, Term task) {
|
|||||||
return npp;
|
return npp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PredEntry *firstModulesPred(PredEntry *npp, Term task) {
|
static PredEntry *firstModulesPred(PredEntry *npp, ModEntry *m, Term task) {
|
||||||
ModEntry *m;
|
|
||||||
if (npp) {
|
|
||||||
m = Yap_GetModuleEntry(npp->ModuleOfPred);
|
|
||||||
npp = npp->NextPredOfModule;
|
|
||||||
} else {
|
|
||||||
m = CurrentModules;
|
|
||||||
npp = m->PredForME;
|
|
||||||
}
|
|
||||||
do {
|
do {
|
||||||
while (npp && !valid_prop(AbsPredProp(npp), task))
|
while (npp && !valid_prop(AbsPredProp(npp), task))
|
||||||
npp = npp->NextPredOfModule;
|
npp = npp->NextPredOfModule;
|
||||||
@ -998,7 +992,8 @@ static PredEntry *firstModulesPred(PredEntry *npp, Term task) {
|
|||||||
m = m->NextME;
|
m = m->NextME;
|
||||||
if (m) {
|
if (m) {
|
||||||
npp = m->PredForME;
|
npp = m->PredForME;
|
||||||
}
|
} else
|
||||||
|
return NULL;
|
||||||
} while (npp || m);
|
} while (npp || m);
|
||||||
return npp;
|
return npp;
|
||||||
}
|
}
|
||||||
@ -1022,16 +1017,14 @@ static Int cont_current_predicate(USES_REGS1) {
|
|||||||
// module and functor known, should be easy
|
// module and functor known, should be easy
|
||||||
if (IsAtomTerm(t2)) {
|
if (IsAtomTerm(t2)) {
|
||||||
if ((p = Yap_GetPredPropByAtom(AtomOfTerm(t3), t2)) &&
|
if ((p = Yap_GetPredPropByAtom(AtomOfTerm(t3), t2)) &&
|
||||||
valid_prop(p, task)
|
valid_prop(p, task)) {
|
||||||
) {
|
|
||||||
cut_succeed();
|
cut_succeed();
|
||||||
} else {
|
} else {
|
||||||
cut_fail();
|
cut_fail();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((p = Yap_GetPredPropByFunc(FunctorOfTerm(t3), t2)) &&
|
if ((p = Yap_GetPredPropByFunc(FunctorOfTerm(t3), t2)) &&
|
||||||
valid_prop(p, task)
|
valid_prop(p, task)) {
|
||||||
) {
|
|
||||||
cut_succeed();
|
cut_succeed();
|
||||||
} else {
|
} else {
|
||||||
cut_fail();
|
cut_fail();
|
||||||
@ -1057,8 +1050,10 @@ static Int cont_current_predicate(USES_REGS1) {
|
|||||||
mod = TermProlog;
|
mod = TermProlog;
|
||||||
bool b = Yap_unify(t2, mod);
|
bool b = Yap_unify(t2, mod);
|
||||||
if (!np) {
|
if (!np) {
|
||||||
if (b) cut_succeed();
|
if (b)
|
||||||
else cut_fail();
|
cut_succeed();
|
||||||
|
else
|
||||||
|
cut_fail();
|
||||||
} else {
|
} else {
|
||||||
EXTRA_CBACK_ARG(4, 1) = MkAddressTerm(RepPredProp(np));
|
EXTRA_CBACK_ARG(4, 1) = MkAddressTerm(RepPredProp(np));
|
||||||
B->cp_h = HR;
|
B->cp_h = HR;
|
||||||
@ -1080,6 +1075,7 @@ static Int cont_current_predicate(USES_REGS1) {
|
|||||||
p = getPredProp(RepAtom(at)->PropsOfAE, task);
|
p = getPredProp(RepAtom(at)->PropsOfAE, task);
|
||||||
} else {
|
} else {
|
||||||
Yap_Error(TYPE_ERROR_CALLABLE, t1, "current_predicate/2");
|
Yap_Error(TYPE_ERROR_CALLABLE, t1, "current_predicate/2");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if (!p)
|
if (!p)
|
||||||
cut_fail();
|
cut_fail();
|
||||||
@ -1117,18 +1113,22 @@ static Int cont_current_predicate(USES_REGS1) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// operating across all modules.
|
// operating across all modules.
|
||||||
PredEntry *npp;
|
PredEntry *npp = pp;
|
||||||
|
ModEntry *me;
|
||||||
|
|
||||||
if (!pp) {
|
if (!pp) {
|
||||||
pp = firstModulesPred(CurrentModules->PredForME, task);
|
pp = firstModulesPred(CurrentModules->PredForME, CurrentModules, task);
|
||||||
|
}
|
||||||
if (!pp)
|
if (!pp)
|
||||||
cut_fail();
|
cut_fail();
|
||||||
}
|
if (pp->ModuleOfPred == PROLOG_MODULE)
|
||||||
npp = firstModulesPred(pp, task);
|
me = Yap_GetModuleEntry(TermProlog);
|
||||||
|
else
|
||||||
|
me = Yap_GetModuleEntry(pp->ModuleOfPred);
|
||||||
|
npp = firstModulesPred(pp->NextPredOfModule, me, task);
|
||||||
if (!npp)
|
if (!npp)
|
||||||
will_cut = true;
|
will_cut = true;
|
||||||
// just try next one
|
// just try next module.
|
||||||
else {
|
else {
|
||||||
EXTRA_CBACK_ARG(4, 1) = MkAddressTerm(npp);
|
EXTRA_CBACK_ARG(4, 1) = MkAddressTerm(npp);
|
||||||
B->cp_h = HR;
|
B->cp_h = HR;
|
||||||
@ -1588,7 +1588,7 @@ static Int p_unlock_system(USES_REGS1) {
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int p_enterundefp(USES_REGS1) {
|
static Int enter_undefp(USES_REGS1) {
|
||||||
if (LOCAL_DoingUndefp) {
|
if (LOCAL_DoingUndefp) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -1596,7 +1596,7 @@ static Int p_enterundefp(USES_REGS1) {
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int p_exitundefp(USES_REGS1) {
|
static Int exit_undefp(USES_REGS1) {
|
||||||
if (LOCAL_DoingUndefp) {
|
if (LOCAL_DoingUndefp) {
|
||||||
LOCAL_DoingUndefp = FALSE;
|
LOCAL_DoingUndefp = FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -1745,8 +1745,8 @@ void Yap_InitCPreds(void) {
|
|||||||
Yap_InitCPred("$halt", 1, p_halt, SyncPredFlag);
|
Yap_InitCPred("$halt", 1, p_halt, SyncPredFlag);
|
||||||
Yap_InitCPred("$lock_system", 0, p_lock_system, SafePredFlag);
|
Yap_InitCPred("$lock_system", 0, p_lock_system, SafePredFlag);
|
||||||
Yap_InitCPred("$unlock_system", 0, p_unlock_system, SafePredFlag);
|
Yap_InitCPred("$unlock_system", 0, p_unlock_system, SafePredFlag);
|
||||||
Yap_InitCPred("$enter_undefp", 0, p_enterundefp, SafePredFlag);
|
Yap_InitCPred("$enter_undefp", 0, enter_undefp, SafePredFlag);
|
||||||
Yap_InitCPred("$exit_undefp", 0, p_exitundefp, SafePredFlag);
|
Yap_InitCPred("$exit_undefp", 0, exit_undefp, SafePredFlag);
|
||||||
|
|
||||||
#ifdef YAP_JIT
|
#ifdef YAP_JIT
|
||||||
Yap_InitCPred("$jit_init", 1, p_jit, SafePredFlag | SyncPredFlag);
|
Yap_InitCPred("$jit_init", 1, p_jit, SafePredFlag | SyncPredFlag);
|
||||||
@ -1772,6 +1772,7 @@ void Yap_InitCPreds(void) {
|
|||||||
Yap_InitCmpPreds();
|
Yap_InitCmpPreds();
|
||||||
Yap_InitCoroutPreds();
|
Yap_InitCoroutPreds();
|
||||||
Yap_InitDBPreds();
|
Yap_InitDBPreds();
|
||||||
|
Yap_InitErrorPreds();
|
||||||
Yap_InitExecFs();
|
Yap_InitExecFs();
|
||||||
Yap_InitGlobals();
|
Yap_InitGlobals();
|
||||||
Yap_InitInlines();
|
Yap_InitInlines();
|
||||||
@ -1799,9 +1800,7 @@ void Yap_InitCPreds(void) {
|
|||||||
#ifdef ANALYST
|
#ifdef ANALYST
|
||||||
Yap_InitAnalystPreds();
|
Yap_InitAnalystPreds();
|
||||||
#endif
|
#endif
|
||||||
#ifdef LOW_LEVEL_TRACER
|
|
||||||
Yap_InitLowLevelTrace();
|
Yap_InitLowLevelTrace();
|
||||||
#endif
|
|
||||||
Yap_InitEval();
|
Yap_InitEval();
|
||||||
Yap_InitGrowPreds();
|
Yap_InitGrowPreds();
|
||||||
Yap_InitLowProf();
|
Yap_InitLowProf();
|
||||||
|
4
C/text.c
@ -969,9 +969,7 @@ write_number( void *s0, seq_tv_t *out, encoding_t enc, int minimal, int size USE
|
|||||||
static Term
|
static Term
|
||||||
string_to_term( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng USES_REGS)
|
string_to_term( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng USES_REGS)
|
||||||
{
|
{
|
||||||
printf("TR0=%p\n", TR);
|
Term o = out->val.t = Yap_StringToTerm(s0, strlen(s0)+1, &enc, GLOBAL_MaxPriority, NULL);
|
||||||
Term o = out->val.t = Yap_StringToTerm(s0, strlen(s0)+1, &enc, 1200, NULL);
|
|
||||||
printf("TRF=%p\n", TR);
|
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ static char SccsId[] = "%W% %G%";
|
|||||||
#include "yapio.h"
|
#include "yapio.h"
|
||||||
#include "blobs.h"
|
#include "blobs.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
#if HAVE_STRING_H
|
#if HAVE_STRING_H
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
#endif
|
||||||
@ -1565,7 +1566,9 @@ p_thread_unlock( USES_REGS1 )
|
|||||||
intptr_t
|
intptr_t
|
||||||
system_thread_id(void)
|
system_thread_id(void)
|
||||||
{
|
{
|
||||||
#if HAVE_SYS_GETTID
|
#if defined(__APPLE__)
|
||||||
|
return syscall(SYS_thread_selfid);
|
||||||
|
#elif HAVE_SYS_GETTID || defined(__APPLE__)
|
||||||
return syscall( SYS_GETTID );
|
return syscall( SYS_GETTID );
|
||||||
#elif HAVE_GETTID_SYSCALL
|
#elif HAVE_GETTID_SYSCALL
|
||||||
return syscall(__NR_gettid);
|
return syscall(__NR_gettid);
|
||||||
|
@ -14334,9 +14334,6 @@ S_SREG = RepAppl(d0);
|
|||||||
}
|
}
|
||||||
#endif /* FROZEN_STACKS */
|
#endif /* FROZEN_STACKS */
|
||||||
d0 = ARG1;
|
d0 = ARG1;
|
||||||
if (PRED_GOAL_EXPANSION_ALL) {
|
|
||||||
goto execute_metacall;
|
|
||||||
}
|
|
||||||
restart_execute:
|
restart_execute:
|
||||||
deref_head(d0, execute_unk);
|
deref_head(d0, execute_unk);
|
||||||
execute_nvar:
|
execute_nvar:
|
||||||
|
26
C/tracer.c
@ -50,7 +50,8 @@ static void send_tracer_message(char *start, char *name, Int arity, char *mname,
|
|||||||
for (i = 0; i < arity; i++) {
|
for (i = 0; i < arity; i++) {
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
fprintf(stderr, ",");
|
fprintf(stderr, ",");
|
||||||
Yap_plwrite(args[i], NULL, 15, Handle_vars_f | AttVar_Portray_f, 1200);
|
Yap_plwrite(args[i], NULL, 15, Handle_vars_f | AttVar_Portray_f,
|
||||||
|
GLOBAL_MaxPriority);
|
||||||
}
|
}
|
||||||
if (arity) {
|
if (arity) {
|
||||||
fprintf(stderr, ")");
|
fprintf(stderr, ")");
|
||||||
@ -172,7 +173,7 @@ void low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// if (!worker_id) return;
|
// if (!worker_id) return;
|
||||||
LOCK(Yap_heap_regs->low_level_trace_lock);
|
LOCK(Yap_low_level_trace_lock);
|
||||||
sc = Yap_heap_regs;
|
sc = Yap_heap_regs;
|
||||||
// if (vsc_count == 161862) jmp_deb(1);
|
// if (vsc_count == 161862) jmp_deb(1);
|
||||||
#ifdef THREADS
|
#ifdef THREADS
|
||||||
@ -319,17 +320,17 @@ void low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) {
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
fprintf(stderr, "%lld ", vsc_count);
|
fprintf(stderr, "%lld %ld ", vsc_count, LCL0 - (CELL *)B);
|
||||||
#if defined(THREADS) || defined(YAPOR)
|
#if defined(THREADS) || defined(YAPOR)
|
||||||
fprintf(stderr, "(%d)", worker_id);
|
fprintf(stderr, "(%d)", worker_id);
|
||||||
#endif
|
#endif
|
||||||
/* check_trail_consistency(); */
|
/* check_trail_consistency(); */
|
||||||
if (pred == NULL) {
|
if (pred == NULL) {
|
||||||
UNLOCK(Yap_heap_regs->low_level_trace_lock);
|
UNLOCK(Yap_low_level_trace_lock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pred->ModuleOfPred == 0 && !LOCAL_do_trace_primitives) {
|
if (pred->ModuleOfPred == 0 && !LOCAL_do_trace_primitives) {
|
||||||
UNLOCK(Yap_heap_regs->low_level_trace_lock);
|
UNLOCK(Yap_low_level_trace_lock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (port) {
|
switch (port) {
|
||||||
@ -405,7 +406,7 @@ void low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fflush(NULL);
|
fflush(NULL);
|
||||||
UNLOCK(Yap_heap_regs->low_level_trace_lock);
|
UNLOCK(Yap_low_level_trace_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggle_low_level_trace(void) {
|
void toggle_low_level_trace(void) {
|
||||||
@ -475,6 +476,8 @@ static Int vsc_go(USES_REGS1) {
|
|||||||
void Yap_InitLowLevelTrace(void) {
|
void Yap_InitLowLevelTrace(void) {
|
||||||
Yap_InitCPred("start_low_level_trace", 0, start_low_level_trace,
|
Yap_InitCPred("start_low_level_trace", 0, start_low_level_trace,
|
||||||
SafePredFlag);
|
SafePredFlag);
|
||||||
|
Yap_InitCPred("$start_low_level_trace", 0, start_low_level_trace,
|
||||||
|
SafePredFlag);
|
||||||
/** @pred start_low_level_trace
|
/** @pred start_low_level_trace
|
||||||
|
|
||||||
|
|
||||||
@ -488,6 +491,7 @@ Begin display of messages at procedure entry and retry.
|
|||||||
#endif
|
#endif
|
||||||
Yap_InitCPred("stop_low_level_trace", 0, stop_low_level_trace, SafePredFlag);
|
Yap_InitCPred("stop_low_level_trace", 0, stop_low_level_trace, SafePredFlag);
|
||||||
Yap_InitCPred("show_low_level_trace", 0, show_low_level_trace, SafePredFlag);
|
Yap_InitCPred("show_low_level_trace", 0, show_low_level_trace, SafePredFlag);
|
||||||
|
Yap_InitCPred("$stop_low_level_trace", 0, stop_low_level_trace, SafePredFlag);
|
||||||
Yap_InitCPred("total_choicepoints", 1, total_choicepoints, SafePredFlag);
|
Yap_InitCPred("total_choicepoints", 1, total_choicepoints, SafePredFlag);
|
||||||
Yap_InitCPred("reset_total_choicepoints", 0, reset_total_choicepoints,
|
Yap_InitCPred("reset_total_choicepoints", 0, reset_total_choicepoints,
|
||||||
SafePredFlag);
|
SafePredFlag);
|
||||||
@ -495,4 +499,14 @@ Begin display of messages at procedure entry and retry.
|
|||||||
Yap_InitCPred("vsc_go", 0, vsc_go, SafePredFlag);
|
Yap_InitCPred("vsc_go", 0, vsc_go, SafePredFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
static null(USES_REGS1) { return true; }
|
||||||
|
|
||||||
|
void Yap_InitLowLevelTrace(void) {
|
||||||
|
Yap_InitCPred("$start_low_level_trace", 0, null,
|
||||||
|
SafePredFlag | HiddenPredFlag);
|
||||||
|
Yap_InitCPred("$stop_low_level_trace", 0, null,
|
||||||
|
SafePredFlag | HiddenPredFlag);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -558,7 +558,7 @@ static int p_grab_tokens() {
|
|||||||
char ch, IdChars[256], *chp;
|
char ch, IdChars[256], *chp;
|
||||||
|
|
||||||
IdFunctor = FunctorId;
|
IdFunctor = FunctorId;
|
||||||
VarFunctor = FunctorVar;
|
VarFunctor = FunctorDollarVar;
|
||||||
p0 = p;
|
p0 = p;
|
||||||
ch = Yap_PlGetchar();
|
ch = Yap_PlGetchar();
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -1683,6 +1683,14 @@ static Term attvars_in_complex_term(register CELL *pt0, register CELL *pt0_end,
|
|||||||
if (to_visit + 1024 >= (CELL **)AuxSp) {
|
if (to_visit + 1024 >= (CELL **)AuxSp) {
|
||||||
goto aux_overflow;
|
goto aux_overflow;
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
CELL *npt0 = RepPair(d0);
|
||||||
|
if(IsAtomicTerm(Deref(npt0[0]))) {
|
||||||
|
pt0 = npt0;
|
||||||
|
pt0_end = pt0 + 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
#ifdef RATIONAL_TREES
|
#ifdef RATIONAL_TREES
|
||||||
to_visit[0] = pt0;
|
to_visit[0] = pt0;
|
||||||
to_visit[1] = pt0_end;
|
to_visit[1] = pt0_end;
|
||||||
@ -1697,7 +1705,7 @@ static Term attvars_in_complex_term(register CELL *pt0, register CELL *pt0_end,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
pt0 = RepPair(d0) - 1;
|
pt0 = RepPair(d0) - 1;
|
||||||
pt0_end = RepPair(d0) + 1;
|
pt0_end = pt0+2;
|
||||||
} else if (IsApplTerm(d0)) {
|
} else if (IsApplTerm(d0)) {
|
||||||
register Functor f;
|
register Functor f;
|
||||||
register CELL *ap2;
|
register CELL *ap2;
|
||||||
@ -4584,7 +4592,7 @@ numbervar(Int id USES_REGS)
|
|||||||
{
|
{
|
||||||
Term ts[1];
|
Term ts[1];
|
||||||
ts[0] = MkIntegerTerm(id);
|
ts[0] = MkIntegerTerm(id);
|
||||||
return Yap_MkApplTerm(LOCAL_FunctorVar, 1, ts);
|
return Yap_MkApplTerm(FunctorDollarVar, 1, ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
@ -4592,7 +4600,7 @@ numbervar_singleton(USES_REGS1)
|
|||||||
{
|
{
|
||||||
Term ts[1];
|
Term ts[1];
|
||||||
ts[0] = MkIntegerTerm(-1);
|
ts[0] = MkIntegerTerm(-1);
|
||||||
return Yap_MkApplTerm(LOCAL_FunctorVar, 1, ts);
|
return Yap_MkApplTerm(FunctorDollarVar, 1, ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -4904,7 +4912,7 @@ unnumber_complex_term(CELL *pt0, CELL *pt0_end, CELL *ptf, CELL *HLow, int share
|
|||||||
*ptf++ = d0; /* you can just unnumber other extensions. */
|
*ptf++ = d0; /* you can just unnumber other extensions. */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (f == FunctorVar) {
|
if (f == FunctorDollarVar) {
|
||||||
Int id = IntegerOfTerm(ap2[1]);
|
Int id = IntegerOfTerm(ap2[1]);
|
||||||
ground = FALSE;
|
ground = FALSE;
|
||||||
if (id < -1) {
|
if (id < -1) {
|
||||||
|
53
C/write.c
@ -444,33 +444,37 @@ static int legalAtom(unsigned char *s) /* Is this a legal atom ? */
|
|||||||
return (s[1] == '}' && !s[2]);
|
return (s[1] == '}' && !s[2]);
|
||||||
} else if (Yap_chtype[ch] == SL) {
|
} else if (Yap_chtype[ch] == SL) {
|
||||||
return (!s[1]);
|
return (!s[1]);
|
||||||
|
} else if (ch == '`') {
|
||||||
|
return false;
|
||||||
} else if ((ch == ',' || ch == '.') && !s[1]) {
|
} else if ((ch == ',' || ch == '.') && !s[1]) {
|
||||||
return FALSE;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (ch == '/') {
|
if (ch == '/') {
|
||||||
if (s[1] == '*')
|
if (s[1] == '*')
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
while (ch) {
|
while (ch) {
|
||||||
if (Yap_chtype[ch] != SY) {
|
if (Yap_chtype[ch] != SY) {
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
ch = *++s;
|
ch = *++s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return true;
|
||||||
} else
|
} else
|
||||||
while ((ch = *++s) != 0)
|
while ((ch = *++s) != 0)
|
||||||
if (Yap_chtype[ch] > NU)
|
if (Yap_chtype[ch] > NU)
|
||||||
return FALSE;
|
return false;
|
||||||
return (TRUE);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static wtype
|
static wtype
|
||||||
AtomIsSymbols(unsigned char *s) /* Is this atom just formed by symbols ? */
|
AtomIsSymbols(unsigned char *s) /* Is this atom just formed by symbols ? */
|
||||||
{
|
{
|
||||||
int ch;
|
int ch;
|
||||||
if (Yap_chtype[(int)s[0]] == SL && s[1] == '\0')
|
if ( Yap_chtype[(int)s[0]] == SL &&
|
||||||
|
s[1] == '\0'
|
||||||
|
)
|
||||||
return (separator);
|
return (separator);
|
||||||
while ((ch = *s++) != '\0') {
|
while ((ch = *s++) != '\0') {
|
||||||
if (Yap_chtype[ch] != SY)
|
if (Yap_chtype[ch] != SY)
|
||||||
@ -707,7 +711,7 @@ static Term from_pointer(CELL *ptr0, struct rewind_term *rwt,
|
|||||||
|
|
||||||
if (!IsAtomicTerm(t) && !IsVarTerm(t)) {
|
if (!IsAtomicTerm(t) && !IsVarTerm(t)) {
|
||||||
while (x) {
|
while (x) {
|
||||||
if (Yap_GetDerefedFromSlot(x->u_sd.s.old PASS_REGS) == t)
|
if (Yap_GetDerefedFromSlot(x->u_sd.s.old) == t)
|
||||||
return TermFoundVar;
|
return TermFoundVar;
|
||||||
x = x->parent;
|
x = x->parent;
|
||||||
}
|
}
|
||||||
@ -734,8 +738,8 @@ static CELL *restore_from_write(struct rewind_term *rwt,
|
|||||||
CELL *ptr;
|
CELL *ptr;
|
||||||
|
|
||||||
if (wglb->Keep_terms) {
|
if (wglb->Keep_terms) {
|
||||||
ptr = (CELL *)Yap_GetPtrFromSlot(rwt->u_sd.s.ptr PASS_REGS);
|
ptr = Yap_GetPtrFromSlot(rwt->u_sd.s.ptr );
|
||||||
Yap_RecoverSlots(2, rwt->u_sd.s.old PASS_REGS);
|
Yap_RecoverSlots(2, rwt->u_sd.s.old );
|
||||||
// printf("leak=%d %d\n", LOCALCurSlot,rwt->u_sd.s.old) ;
|
// printf("leak=%d %d\n", LOCALCurSlot,rwt->u_sd.s.old) ;
|
||||||
} else {
|
} else {
|
||||||
ptr = rwt->u_sd.d.ptr;
|
ptr = rwt->u_sd.d.ptr;
|
||||||
@ -840,6 +844,9 @@ static void write_list(Term t, int direction, int depth,
|
|||||||
do_jump = (direction >= 0);
|
do_jump = (direction >= 0);
|
||||||
}
|
}
|
||||||
if (wglb->MaxDepth != 0 && depth > wglb->MaxDepth) {
|
if (wglb->MaxDepth != 0 && depth > wglb->MaxDepth) {
|
||||||
|
if (lastw == symbol || lastw == separator) {
|
||||||
|
wrputc(' ', wglb->stream);
|
||||||
|
}
|
||||||
wrputc('|', wglb->stream);
|
wrputc('|', wglb->stream);
|
||||||
putAtom(Atom3Dots, wglb->Quote_illegal, wglb);
|
putAtom(Atom3Dots, wglb->Quote_illegal, wglb);
|
||||||
return;
|
return;
|
||||||
@ -856,6 +863,9 @@ static void write_list(Term t, int direction, int depth,
|
|||||||
Term nt = from_pointer(RepPair(t) + 1, &nrwt, wglb);
|
Term nt = from_pointer(RepPair(t) + 1, &nrwt, wglb);
|
||||||
/* we found an infinite loop */
|
/* we found an infinite loop */
|
||||||
if (IsAtomTerm(nt)) {
|
if (IsAtomTerm(nt)) {
|
||||||
|
if (lastw == symbol || lastw == separator) {
|
||||||
|
wrputc(' ', wglb->stream);
|
||||||
|
}
|
||||||
wrputc('|', wglb->stream);
|
wrputc('|', wglb->stream);
|
||||||
writeTerm(nt, 999, depth, FALSE, wglb, rwt);
|
writeTerm(nt, 999, depth, FALSE, wglb, rwt);
|
||||||
} else {
|
} else {
|
||||||
@ -865,6 +875,9 @@ static void write_list(Term t, int direction, int depth,
|
|||||||
}
|
}
|
||||||
restore_from_write(&nrwt, wglb);
|
restore_from_write(&nrwt, wglb);
|
||||||
} else if (ti != MkAtomTerm(AtomNil)) {
|
} else if (ti != MkAtomTerm(AtomNil)) {
|
||||||
|
if (lastw == symbol || lastw == separator) {
|
||||||
|
wrputc(' ', wglb->stream);
|
||||||
|
}
|
||||||
wrputc('|', wglb->stream);
|
wrputc('|', wglb->stream);
|
||||||
lastw = separator;
|
lastw = separator;
|
||||||
writeTerm(from_pointer(RepPair(t) + 1, &nrwt, wglb), 999, depth, FALSE,
|
writeTerm(from_pointer(RepPair(t) + 1, &nrwt, wglb), 999, depth, FALSE,
|
||||||
@ -1101,6 +1114,9 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
|||||||
wrputc(',', wglb->stream);
|
wrputc(',', wglb->stream);
|
||||||
lastw = separator;
|
lastw = separator;
|
||||||
} else if (!strcmp((char *)RepAtom(atom)->StrOfAE, "|")) {
|
} else if (!strcmp((char *)RepAtom(atom)->StrOfAE, "|")) {
|
||||||
|
if (lastw == symbol || lastw == separator) {
|
||||||
|
wrputc(' ', wglb->stream);
|
||||||
|
}
|
||||||
wrputc('|', wglb->stream);
|
wrputc('|', wglb->stream);
|
||||||
lastw = separator;
|
lastw = separator;
|
||||||
} else
|
} else
|
||||||
@ -1117,14 +1133,17 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
|||||||
if (op > p) {
|
if (op > p) {
|
||||||
wrclose_bracket(wglb, TRUE);
|
wrclose_bracket(wglb, TRUE);
|
||||||
}
|
}
|
||||||
} else if (wglb->Handle_vars && functor == LOCAL_FunctorVar) {
|
} else if ( functor == FunctorDollarVar) {
|
||||||
Term ti = ArgOfTerm(1, t);
|
Term ti = ArgOfTerm(1, t);
|
||||||
if (lastw == alphanum) {
|
if (lastw == alphanum) {
|
||||||
wrputc(' ', wglb->stream);
|
wrputc(' ', wglb->stream);
|
||||||
}
|
}
|
||||||
if (!IsVarTerm(ti) &&
|
if (wglb->Handle_vars &&
|
||||||
(IsIntTerm(ti) || IsCodesTerm(ti) ||
|
!IsVarTerm(ti) &&
|
||||||
IsAtomTerm(ti) || IsStringTerm(ti) )) {
|
(IsIntTerm(ti) ||
|
||||||
|
IsCodesTerm(ti) ||
|
||||||
|
IsAtomTerm(ti) ||
|
||||||
|
IsStringTerm(ti) )) {
|
||||||
if (IsIntTerm(ti)) {
|
if (IsIntTerm(ti)) {
|
||||||
Int k = IntOfTerm(ti);
|
Int k = IntOfTerm(ti);
|
||||||
if (k == -1) {
|
if (k == -1) {
|
||||||
@ -1158,7 +1177,7 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
|||||||
} else if (!wglb->Ignore_ops && functor == FunctorBraces) {
|
} else if (!wglb->Ignore_ops && functor == FunctorBraces) {
|
||||||
wrputc('{', wglb->stream);
|
wrputc('{', wglb->stream);
|
||||||
lastw = separator;
|
lastw = separator;
|
||||||
writeTerm(from_pointer(RepAppl(t) + 1, &nrwt, wglb), 1200, depth + 1,
|
writeTerm(from_pointer(RepAppl(t) + 1, &nrwt, wglb), GLOBAL_MaxPriority, depth + 1,
|
||||||
FALSE, wglb, &nrwt);
|
FALSE, wglb, &nrwt);
|
||||||
restore_from_write(&nrwt, wglb);
|
restore_from_write(&nrwt, wglb);
|
||||||
wrputc('}', wglb->stream);
|
wrputc('}', wglb->stream);
|
||||||
@ -1215,7 +1234,7 @@ void Yap_plwrite(Term t, StreamDesc *mywrite, int max_depth, int flags,
|
|||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
struct write_globs wglb;
|
struct write_globs wglb;
|
||||||
struct rewind_term rwt;
|
struct rewind_term rwt;
|
||||||
yhandle_t sls = Yap_CurrentSlot(PASS_REGS1);
|
yhandle_t sls = Yap_CurrentSlot();
|
||||||
|
|
||||||
if (!mywrite) {
|
if (!mywrite) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
@ -1269,7 +1288,7 @@ char *Yap_TermToString(Term t, char *s, size_t sz, size_t *length,
|
|||||||
GLOBAL_Stream[sno].encoding = *encp;
|
GLOBAL_Stream[sno].encoding = *encp;
|
||||||
else
|
else
|
||||||
GLOBAL_Stream[sno].encoding = LOCAL_encoding;
|
GLOBAL_Stream[sno].encoding = LOCAL_encoding;
|
||||||
Yap_plwrite(t, GLOBAL_Stream + sno, 0, flags, 1200);
|
Yap_plwrite(t, GLOBAL_Stream + sno, 0, flags, GLOBAL_MaxPriority);
|
||||||
s = Yap_MemExportStreamPtr(sno);
|
s = Yap_MemExportStreamPtr(sno);
|
||||||
Yap_CloseStream(sno);
|
Yap_CloseStream(sno);
|
||||||
LOCAL_c_output_stream = old_output_stream;
|
LOCAL_c_output_stream = old_output_stream;
|
||||||
|
@ -12,6 +12,8 @@ cmake_minimum_required(VERSION 2.8)
|
|||||||
# set path to additional CMake modules
|
# set path to additional CMake modules
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
|
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set(CMAKE_BUILD_TYPE Debug)
|
# set(CMAKE_BUILD_TYPE Debug)
|
||||||
|
|
||||||
set (MACOSX_RPATH ON)
|
set (MACOSX_RPATH ON)
|
||||||
@ -28,14 +30,18 @@ set(YAP_MAJOR_VERSION 6)
|
|||||||
set(YAP_MINOR_VERSION 3)
|
set(YAP_MINOR_VERSION 3)
|
||||||
set(YAP_PATCH_VERSION 4)
|
set(YAP_PATCH_VERSION 4)
|
||||||
|
|
||||||
|
set(YAP_SYSTEM_OPTIONS "attributed_variables" )
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
set (YAP_ARCH $ENV{PROCESSOR_ARCHITECTURE})
|
set (YAP_ARCH $ENV{PROCESSOR_ARCHITECTURE})
|
||||||
|
set(YAP_SYSTEM_OPTIONS "windows " ${YAP_SYSTEM_OPTIONS})
|
||||||
endif()
|
endif()
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
find_program (UNAME uname)
|
find_program (UNAME uname)
|
||||||
execute_process (
|
execute_process (
|
||||||
COMMAND ${UNAME} -m
|
COMMAND ${UNAME} -m
|
||||||
OUTPUT_VARIABLE YAP_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE )
|
OUTPUT_VARIABLE YAP_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE )
|
||||||
|
set(YAP_SYSTEM_OPTIONS "unix " ${YAP_SYSTEM_OPTIONS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(YAP_FULL_VERSION
|
set(YAP_FULL_VERSION
|
||||||
@ -92,13 +98,14 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|||||||
#cmake_policy( NO_POLICY_SCOPE )
|
#cmake_policy( NO_POLICY_SCOPE )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set (BUILD_SHARED_LIBS ON)
|
||||||
|
|
||||||
## define system
|
## define system
|
||||||
|
|
||||||
include (Sources)
|
include (Sources)
|
||||||
|
|
||||||
|
|
||||||
add_library(libYap SHARED
|
add_library(libYap
|
||||||
${ENGINE_SOURCES}
|
${ENGINE_SOURCES}
|
||||||
${C_INTERFACE_SOURCES}
|
${C_INTERFACE_SOURCES}
|
||||||
${STATIC_SOURCES}
|
${STATIC_SOURCES}
|
||||||
@ -106,7 +113,7 @@ add_library(libYap SHARED
|
|||||||
${HEADERS}
|
${HEADERS}
|
||||||
$<TARGET_OBJECTS:libYAPOs>
|
$<TARGET_OBJECTS:libYAPOs>
|
||||||
$<TARGET_OBJECTS:libOPTYap>
|
$<TARGET_OBJECTS:libOPTYap>
|
||||||
# $<TARGET_OBJECTS:myddas>
|
$<TARGET_OBJECTS:myddas>
|
||||||
)
|
)
|
||||||
|
|
||||||
set_property(DIRECTORY PROPERTY CXX_STANDARD 11)
|
set_property(DIRECTORY PROPERTY CXX_STANDARD 11)
|
||||||
@ -232,7 +239,11 @@ endif()
|
|||||||
# Model Specific
|
# Model Specific
|
||||||
if (HAVE_GCC)
|
if (HAVE_GCC)
|
||||||
set_property( DIRECTORY APPEND PROPERTY COMPILE_OPTIONS -Wall )
|
set_property( DIRECTORY APPEND PROPERTY COMPILE_OPTIONS -Wall )
|
||||||
|
if ( ${C_COMPILER} MATCHES "GNU")
|
||||||
set_property( DIRECTORY APPEND PROPERTY COMPILE_OPTIONS $<$<CONFIG:Release>:-O3;-fomit-frame-pointer;-fstrict-aliasing;-freorder-blocks;-fsched-interblock> )
|
set_property( DIRECTORY APPEND PROPERTY COMPILE_OPTIONS $<$<CONFIG:Release>:-O3;-fomit-frame-pointer;-fstrict-aliasing;-freorder-blocks;-fsched-interblock> )
|
||||||
|
else()
|
||||||
|
set_property( DIRECTORY APPEND PROPERTY COMPILE_OPTIONS $<$<CONFIG:Release>:-O3;-fstrict-aliasing;-freorder-blocks;-fsched-interblock> )
|
||||||
|
endif()
|
||||||
set_property( DIRECTORY APPEND PROPERTY COMPILE_OPTIONS -fexceptions )
|
set_property( DIRECTORY APPEND PROPERTY COMPILE_OPTIONS -fexceptions )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -249,14 +260,13 @@ if (HAVE_GCC)
|
|||||||
endif (HAVE_GCC)
|
endif (HAVE_GCC)
|
||||||
|
|
||||||
#
|
#
|
||||||
set (BUILD_SHARED_LIBS ON)
|
|
||||||
|
|
||||||
#option (YAP_SWI_IO ON)
|
#option (YAP_SWI_IO ON)
|
||||||
|
|
||||||
OPTION (WITH_CALL_TRACER
|
OPTION (WITH_CALL_TRACER
|
||||||
"support for procedure-call tracing" ON)
|
"support for procedure-call tracing" ON)
|
||||||
#TODO:
|
#TODO:
|
||||||
if (WITH_CALL_TRACER)
|
if (WITH_CALL_TRACER)
|
||||||
|
set(YAP_SYSTEM_OPTIONS "call_tracer " ${YAP_SYSTEM_OPTIONS})
|
||||||
set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:LOW_LEVEL_TRACER=1> )
|
set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:LOW_LEVEL_TRACER=1> )
|
||||||
endif (WITH_CALL_TRACER)
|
endif (WITH_CALL_TRACER)
|
||||||
|
|
||||||
@ -275,6 +285,7 @@ macro_log_feature (GMP_FOUND
|
|||||||
"libgmp"
|
"libgmp"
|
||||||
"GNU big integers and rationals"
|
"GNU big integers and rationals"
|
||||||
"http://gmplib.org")
|
"http://gmplib.org")
|
||||||
|
set(YAP_SYSTEM_OPTIONS "big_numbers " ${YAP_SYSTEM_OPTIONS})
|
||||||
if (GMP_FOUND)
|
if (GMP_FOUND)
|
||||||
include_directories (${GMP_INCLUDE_DIR})
|
include_directories (${GMP_INCLUDE_DIR})
|
||||||
#add_executable(test ${SOURCES})
|
#add_executable(test ${SOURCES})
|
||||||
@ -323,6 +334,7 @@ if (WITH_Threads)
|
|||||||
check_function_exists( pthread_mutexattr_settype HAVE_PTHREAD_MUTEXATTR_SETTYPE )
|
check_function_exists( pthread_mutexattr_settype HAVE_PTHREAD_MUTEXATTR_SETTYPE )
|
||||||
check_function_exists( pthread_setconcurrency HAVE_PTHREAD_SETCONCURRENCY )
|
check_function_exists( pthread_setconcurrency HAVE_PTHREAD_SETCONCURRENCY )
|
||||||
endif (CMAKE_USE_PTHREADS_INIT)
|
endif (CMAKE_USE_PTHREADS_INIT)
|
||||||
|
set(YAP_SYSTEM_OPTIONS "threads " ${YAP_SYSTEM_OPTIONS})
|
||||||
set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS THREADS=1)
|
set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS THREADS=1)
|
||||||
#
|
#
|
||||||
# Please note that the compiler flag can only be used with the imported
|
# Please note that the compiler flag can only be used with the imported
|
||||||
@ -344,7 +356,6 @@ IF(WITH_Pthread_Lockin)
|
|||||||
set_DIRECTORY_properties(PROPERTIES APPEND COMPILE_DEFINITIONS USE_PTHREAD_LOCKING=1)
|
set_DIRECTORY_properties(PROPERTIES APPEND COMPILE_DEFINITIONS USE_PTHREAD_LOCKING=1)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# include OS and I/o stuff
|
# include OS and I/o stuff
|
||||||
#
|
#
|
||||||
@ -353,7 +364,7 @@ ENDIF()
|
|||||||
#
|
#
|
||||||
add_subDIRECTORY (OPTYap)
|
add_subDIRECTORY (OPTYap)
|
||||||
|
|
||||||
#add_subDIRECTORY (packages/myddas)
|
add_subDIRECTORY (packages/myddas)
|
||||||
|
|
||||||
|
|
||||||
add_subDIRECTORY (os)
|
add_subDIRECTORY (os)
|
||||||
@ -369,6 +380,7 @@ ADD_SUBDIRECTORY(swi/library)
|
|||||||
# ADD_SUBDIRECTORY(os)
|
# ADD_SUBDIRECTORY(os)
|
||||||
# ADD_SUBDIRECTORY(packages)
|
# ADD_SUBDIRECTORY(packages)
|
||||||
|
|
||||||
|
|
||||||
option (WITH_JIT
|
option (WITH_JIT
|
||||||
"just in Time Clause Compilation" OFF)
|
"just in Time Clause Compilation" OFF)
|
||||||
if (WITH_JIT)
|
if (WITH_JIT)
|
||||||
@ -397,6 +409,8 @@ add_subDIRECTORY (packages/cplint)
|
|||||||
|
|
||||||
add_subDIRECTORY (packages/raptor)
|
add_subDIRECTORY (packages/raptor)
|
||||||
|
|
||||||
|
add_subDIRECTORY (packages/xml)
|
||||||
|
|
||||||
add_subDIRECTORY (docs)
|
add_subDIRECTORY (docs)
|
||||||
|
|
||||||
# add_subDIRECTORY (packages/cuda)
|
# add_subDIRECTORY (packages/cuda)
|
||||||
|
@ -428,7 +428,7 @@ YAPQuery::initQuery( YAPTerm ts[], arity_t arity )
|
|||||||
if (arity) {
|
if (arity) {
|
||||||
q_g = Yap_NewSlots( arity );
|
q_g = Yap_NewSlots( arity );
|
||||||
for (arity_t i=0; i < arity; i++) {
|
for (arity_t i=0; i < arity; i++) {
|
||||||
Yap_PutInSlot(q_g+i, ts[i].term() PASS_REGS);
|
Yap_PutInSlot(q_g+i, ts[i].term());
|
||||||
}
|
}
|
||||||
Term t = Yap_MkApplTerm(ap->FunctorOfPred, ap->ArityOfPE, Yap_AddressFromSlot(q_g));
|
Term t = Yap_MkApplTerm(ap->FunctorOfPred, ap->ArityOfPE, Yap_AddressFromSlot(q_g));
|
||||||
goal = YAPTerm( t );
|
goal = YAPTerm( t );
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
#define GIT_SHA1 "036876299f12a4761f8d1de2dfba9709d5c91739"
|
#define GIT_SHA1 "713e9dc9d83c385f5bdd57c8cfa4c7771a6cdb12"
|
||||||
const char g_GIT_SHA1[] = GIT_SHA1;
|
const char g_GIT_SHA1[] = GIT_SHA1;
|
||||||
|
344
H/TermExt.h
@ -17,15 +17,8 @@
|
|||||||
|
|
||||||
@file TermExt.h
|
@file TermExt.h
|
||||||
|
|
||||||
@page Extensions Extensions to Prolog
|
|
||||||
|
|
||||||
YAP includes a number of extensions over the original Prolog
|
|
||||||
language. Next, we discuss support to the most important ones.
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_SYSTEM_MALLOC
|
#ifdef USE_SYSTEM_MALLOC
|
||||||
#define SF_STORE (&(Yap_heap_regs->funcs))
|
#define SF_STORE (&(Yap_heap_regs->funcs))
|
||||||
#else
|
#else
|
||||||
@ -54,16 +47,14 @@ language. Next, we discuss support to the most important ones.
|
|||||||
#define TermNil MkAtomTerm(AtomNil)
|
#define TermNil MkAtomTerm(AtomNil)
|
||||||
#define TermDot MkAtomTerm(AtomDot)
|
#define TermDot MkAtomTerm(AtomDot)
|
||||||
|
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
db_ref_e = sizeof(Functor *),
|
db_ref_e = sizeof(Functor *),
|
||||||
attvar_e = 2 * sizeof(Functor *),
|
attvar_e = 2 * sizeof(Functor *),
|
||||||
double_e = 3 * sizeof(Functor *),
|
double_e = 3 * sizeof(Functor *),
|
||||||
long_int_e = 4 * sizeof(Functor *),
|
long_int_e = 4 * sizeof(Functor *),
|
||||||
big_int_e = 5 * sizeof(Functor *),
|
big_int_e = 5 * sizeof(Functor *),
|
||||||
string_e = 6 * sizeof(Functor *)
|
string_e = 6 * sizeof(Functor *)
|
||||||
}
|
} blob_type;
|
||||||
blob_type;
|
|
||||||
|
|
||||||
#define FunctorDBRef ((Functor)(db_ref_e))
|
#define FunctorDBRef ((Functor)(db_ref_e))
|
||||||
#define FunctorAttVar ((Functor)(attvar_e))
|
#define FunctorAttVar ((Functor)(attvar_e))
|
||||||
@ -79,12 +70,9 @@ blob_type;
|
|||||||
|
|
||||||
INLINE_ONLY inline EXTERN int __IsAttVar(CELL *pt USES_REGS);
|
INLINE_ONLY inline EXTERN int __IsAttVar(CELL *pt USES_REGS);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int
|
INLINE_ONLY inline EXTERN int __IsAttVar(CELL *pt USES_REGS) {
|
||||||
__IsAttVar (CELL *pt USES_REGS)
|
|
||||||
{
|
|
||||||
#ifdef YAP_H
|
#ifdef YAP_H
|
||||||
return (pt)[-1] == (CELL)attvar_e
|
return (pt)[-1] == (CELL)attvar_e && pt < HR;
|
||||||
&& pt < HR;
|
|
||||||
#else
|
#else
|
||||||
return (pt)[-1] == (CELL)attvar_e;
|
return (pt)[-1] == (CELL)attvar_e;
|
||||||
#endif
|
#endif
|
||||||
@ -92,14 +80,11 @@ __IsAttVar (CELL *pt USES_REGS)
|
|||||||
|
|
||||||
INLINE_ONLY inline EXTERN int GlobalIsAttVar(CELL *pt);
|
INLINE_ONLY inline EXTERN int GlobalIsAttVar(CELL *pt);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int
|
INLINE_ONLY inline EXTERN int GlobalIsAttVar(CELL *pt) {
|
||||||
GlobalIsAttVar (CELL *pt)
|
|
||||||
{
|
|
||||||
return (pt)[-1] == (CELL)attvar_e;
|
return (pt)[-1] == (CELL)attvar_e;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
BIG_INT = 0x01,
|
BIG_INT = 0x01,
|
||||||
BIG_RATIONAL = 0x02,
|
BIG_RATIONAL = 0x02,
|
||||||
BIG_FLOAT = 0x04,
|
BIG_FLOAT = 0x04,
|
||||||
@ -110,14 +95,11 @@ typedef enum
|
|||||||
EXTERNAL_BLOB = 0x100, /* generic data */
|
EXTERNAL_BLOB = 0x100, /* generic data */
|
||||||
USER_BLOB_START = 0x1000, /* user defined blob */
|
USER_BLOB_START = 0x1000, /* user defined blob */
|
||||||
USER_BLOB_END = 0x1100 /* end of user defined blob */
|
USER_BLOB_END = 0x1100 /* end of user defined blob */
|
||||||
}
|
} big_blob_type;
|
||||||
big_blob_type;
|
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN blob_type BlobOfFunctor(Functor f);
|
INLINE_ONLY inline EXTERN blob_type BlobOfFunctor(Functor f);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN blob_type
|
INLINE_ONLY inline EXTERN blob_type BlobOfFunctor(Functor f) {
|
||||||
BlobOfFunctor (Functor f)
|
|
||||||
{
|
|
||||||
return (blob_type)((CELL)f);
|
return (blob_type)((CELL)f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,11 +113,9 @@ typedef struct cp_frame {
|
|||||||
#endif
|
#endif
|
||||||
} copy_frame;
|
} copy_frame;
|
||||||
|
|
||||||
|
|
||||||
#ifdef COROUTINING
|
#ifdef COROUTINING
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
/* what to do when someone tries to bind our term to someone else
|
/* what to do when someone tries to bind our term to someone else
|
||||||
in some predefined context */
|
in some predefined context */
|
||||||
void (*bind_op)(Term *, Term CACHE_TYPE);
|
void (*bind_op)(Term *, Term CACHE_TYPE);
|
||||||
@ -149,26 +129,19 @@ typedef struct
|
|||||||
} ext_op;
|
} ext_op;
|
||||||
|
|
||||||
/* known delays */
|
/* known delays */
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
empty_ext = 0 * sizeof(ext_op), /* default op, this should never be called */
|
empty_ext = 0 * sizeof(ext_op), /* default op, this should never be called */
|
||||||
attvars_ext = 1 * sizeof(ext_op) /* support for attributed variables */
|
attvars_ext = 1 * sizeof(ext_op) /* support for attributed variables */
|
||||||
/* add your own extensions here */
|
/* add your own extensions here */
|
||||||
/* keep this one */
|
/* keep this one */
|
||||||
}
|
} exts;
|
||||||
exts;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(YAP_H)
|
#if defined(YAP_H)
|
||||||
/* make sure that these data structures are the first thing to be allocated
|
/* make sure that these data structures are the first thing to be allocated
|
||||||
in the heap when we start the system */
|
in the heap when we start the system */
|
||||||
typedef struct special_functors_struct
|
typedef struct special_functors_struct {
|
||||||
{
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
struct ExtraAtomEntryStruct AtFoundVar;
|
struct ExtraAtomEntryStruct AtFoundVar;
|
||||||
@ -181,8 +154,7 @@ typedef struct special_functors_struct
|
|||||||
struct AtomEntryStruct *AtNil;
|
struct AtomEntryStruct *AtNil;
|
||||||
struct AtomEntryStruct *AtDot;
|
struct AtomEntryStruct *AtDot;
|
||||||
#endif
|
#endif
|
||||||
}
|
} special_functors;
|
||||||
special_functors;
|
|
||||||
#endif /* YAP_H */
|
#endif /* YAP_H */
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Float CpFloatUnaligned(CELL *ptr);
|
INLINE_ONLY inline EXTERN Float CpFloatUnaligned(CELL *ptr);
|
||||||
@ -195,28 +167,18 @@ INLINE_ONLY inline EXTERN Float FloatOfTerm (Term t);
|
|||||||
|
|
||||||
#if SIZEOF_DOUBLE == SIZEOF_INT_P
|
#if SIZEOF_DOUBLE == SIZEOF_INT_P
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Term
|
INLINE_ONLY inline EXTERN Term __MkFloatTerm(Float dbl USES_REGS) {
|
||||||
__MkFloatTerm (Float dbl USES_REGS)
|
return (Term)((HR[0] = (CELL)FunctorDouble, *(Float *)(HR + 1) = dbl,
|
||||||
{
|
HR[2] = EndSpecials, HR += 3, AbsAppl(HR - 3)));
|
||||||
return (Term) ((HR[0] = (CELL) FunctorDouble, *(Float *) (HR + 1) =
|
|
||||||
dbl, HR[2] = EndSpecials, HR +=
|
|
||||||
3, AbsAppl (HR - 3)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INLINE_ONLY inline EXTERN Float FloatOfTerm(Term t) {
|
||||||
INLINE_ONLY inline EXTERN Float
|
|
||||||
FloatOfTerm (Term t)
|
|
||||||
{
|
|
||||||
return (Float)(*(Float *)(RepAppl(t) + 1));
|
return (Float)(*(Float *)(RepAppl(t) + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define InitUnalignedFloat()
|
#define InitUnalignedFloat()
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Float
|
INLINE_ONLY inline EXTERN Float CpFloatUnaligned(CELL *ptr) {
|
||||||
CpFloatUnaligned(CELL *ptr)
|
|
||||||
{
|
|
||||||
return *((Float *)ptr);
|
return *((Float *)ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,12 +188,9 @@ CpFloatUnaligned(CELL *ptr)
|
|||||||
|
|
||||||
#define DOUBLE_ALIGNED(ADDR) ((CELL)(ADDR)&0x4)
|
#define DOUBLE_ALIGNED(ADDR) ((CELL)(ADDR)&0x4)
|
||||||
|
|
||||||
INLINE_ONLY EXTERN inline void
|
INLINE_ONLY EXTERN inline void AlignGlobalForDouble(USES_REGS1);
|
||||||
AlignGlobalForDouble( USES_REGS1 );
|
|
||||||
|
|
||||||
INLINE_ONLY EXTERN inline void
|
INLINE_ONLY EXTERN inline void AlignGlobalForDouble(USES_REGS1) {
|
||||||
AlignGlobalForDouble( USES_REGS1 )
|
|
||||||
{
|
|
||||||
/* Force Alignment for floats. Note that garbage collector may
|
/* Force Alignment for floats. Note that garbage collector may
|
||||||
break the alignment; */
|
break the alignment; */
|
||||||
if (!DOUBLE_ALIGNED(HR)) {
|
if (!DOUBLE_ALIGNED(HR)) {
|
||||||
@ -241,19 +200,14 @@ AlignGlobalForDouble( USES_REGS1 )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef i386
|
#ifdef i386
|
||||||
INLINE_ONLY inline EXTERN Float
|
INLINE_ONLY inline EXTERN Float CpFloatUnaligned(CELL *ptr) {
|
||||||
CpFloatUnaligned (CELL * ptr)
|
|
||||||
{
|
|
||||||
return *((Float *)(ptr + 1));
|
return *((Float *)(ptr + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
/* first, need to address the alignment problem */
|
/* first, need to address the alignment problem */
|
||||||
INLINE_ONLY inline EXTERN Float
|
INLINE_ONLY inline EXTERN Float CpFloatUnaligned(CELL *ptr) {
|
||||||
CpFloatUnaligned (CELL * ptr)
|
union {
|
||||||
{
|
|
||||||
union
|
|
||||||
{
|
|
||||||
Float f;
|
Float f;
|
||||||
CELL d[2];
|
CELL d[2];
|
||||||
} u;
|
} u;
|
||||||
@ -264,24 +218,17 @@ CpFloatUnaligned (CELL * ptr)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Term
|
INLINE_ONLY inline EXTERN Term __MkFloatTerm(Float dbl USES_REGS) {
|
||||||
__MkFloatTerm (Float dbl USES_REGS)
|
return (Term)((AlignGlobalForDouble(PASS_REGS1), HR[0] = (CELL)FunctorDouble,
|
||||||
{
|
*(Float *)(HR + 1) = dbl, HR[3] = EndSpecials, HR += 4,
|
||||||
return (Term) ((AlignGlobalForDouble ( PASS_REGS1 ), HR[0] =
|
AbsAppl(HR - 4)));
|
||||||
(CELL) FunctorDouble, *(Float *) (HR + 1) = dbl, HR[3] =
|
|
||||||
EndSpecials, HR +=
|
|
||||||
4, AbsAppl (HR - 4)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INLINE_ONLY inline EXTERN Float FloatOfTerm(Term t) {
|
||||||
INLINE_ONLY inline EXTERN Float
|
|
||||||
FloatOfTerm (Term t)
|
|
||||||
{
|
|
||||||
return (Float)((DOUBLE_ALIGNED(RepAppl(t)) ? *(Float *)(RepAppl(t) + 1)
|
return (Float)((DOUBLE_ALIGNED(RepAppl(t)) ? *(Float *)(RepAppl(t) + 1)
|
||||||
: CpFloatUnaligned(RepAppl(t))));
|
: CpFloatUnaligned(RepAppl(t))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* no alignment problems for 64 bit machines */
|
/* no alignment problems for 64 bit machines */
|
||||||
#else
|
#else
|
||||||
/* OOPS, YAP only understands Floats that are as large as cells or that
|
/* OOPS, YAP only understands Floats that are as large as cells or that
|
||||||
@ -296,25 +243,19 @@ OOPS
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsFloatTerm(Term);
|
INLINE_ONLY inline EXTERN int IsFloatTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int
|
INLINE_ONLY inline EXTERN int IsFloatTerm(Term t) {
|
||||||
IsFloatTerm (Term t)
|
|
||||||
{
|
|
||||||
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorDouble);
|
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorDouble);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* extern Functor FunctorLongInt; */
|
/* extern Functor FunctorLongInt; */
|
||||||
|
|
||||||
#define MkLongIntTerm(i) __MkLongIntTerm((i)PASS_REGS)
|
#define MkLongIntTerm(i) __MkLongIntTerm((i)PASS_REGS)
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Term __MkLongIntTerm(Int USES_REGS);
|
INLINE_ONLY inline EXTERN Term __MkLongIntTerm(Int USES_REGS);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Term
|
INLINE_ONLY inline EXTERN Term __MkLongIntTerm(Int i USES_REGS) {
|
||||||
__MkLongIntTerm (Int i USES_REGS)
|
|
||||||
{
|
|
||||||
HR[0] = (CELL)FunctorLongInt;
|
HR[0] = (CELL)FunctorLongInt;
|
||||||
HR[1] = (CELL)(i);
|
HR[1] = (CELL)(i);
|
||||||
HR[2] = EndSpecials;
|
HR[2] = EndSpecials;
|
||||||
@ -322,26 +263,18 @@ __MkLongIntTerm (Int i USES_REGS)
|
|||||||
return AbsAppl(HR - 3);
|
return AbsAppl(HR - 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int LongIntOfTerm(Term t);
|
INLINE_ONLY inline EXTERN Int LongIntOfTerm(Term t);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int
|
INLINE_ONLY inline EXTERN Int LongIntOfTerm(Term t) {
|
||||||
LongIntOfTerm (Term t)
|
|
||||||
{
|
|
||||||
return (Int)(RepAppl(t)[1]);
|
return (Int)(RepAppl(t)[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsLongIntTerm(Term);
|
INLINE_ONLY inline EXTERN int IsLongIntTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int
|
INLINE_ONLY inline EXTERN int IsLongIntTerm(Term t) {
|
||||||
IsLongIntTerm (Term t)
|
|
||||||
{
|
|
||||||
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorLongInt);
|
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorLongInt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************************************/
|
/****************************************************/
|
||||||
|
|
||||||
/*********** strings, coded as UTF-8 ****************/
|
/*********** strings, coded as UTF-8 ****************/
|
||||||
@ -354,9 +287,7 @@ IsLongIntTerm (Term t)
|
|||||||
|
|
||||||
INLINE_ONLY inline EXTERN Term __MkStringTerm(const char *s USES_REGS);
|
INLINE_ONLY inline EXTERN Term __MkStringTerm(const char *s USES_REGS);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Term
|
INLINE_ONLY inline EXTERN Term __MkStringTerm(const char *s USES_REGS) {
|
||||||
__MkStringTerm (const char *s USES_REGS)
|
|
||||||
{
|
|
||||||
Term t = AbsAppl(HR);
|
Term t = AbsAppl(HR);
|
||||||
size_t sz = ALIGN_BY_TYPE(strlen((char *)s) + 1, CELL);
|
size_t sz = ALIGN_BY_TYPE(strlen((char *)s) + 1, CELL);
|
||||||
HR[0] = (CELL)FunctorString;
|
HR[0] = (CELL)FunctorString;
|
||||||
@ -367,11 +298,11 @@ __MkStringTerm (const char *s USES_REGS)
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Term __MkUStringTerm (const unsigned char *s USES_REGS);
|
INLINE_ONLY inline EXTERN Term
|
||||||
|
__MkUStringTerm(const unsigned char *s USES_REGS);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Term
|
INLINE_ONLY inline EXTERN Term
|
||||||
__MkUStringTerm (const unsigned char *s USES_REGS)
|
__MkUStringTerm(const unsigned char *s USES_REGS) {
|
||||||
{
|
|
||||||
Term t = AbsAppl(HR);
|
Term t = AbsAppl(HR);
|
||||||
size_t sz = ALIGN_BY_TYPE(strlen((char *)s) + 1, CELL);
|
size_t sz = ALIGN_BY_TYPE(strlen((char *)s) + 1, CELL);
|
||||||
HR[0] = (CELL)FunctorString;
|
HR[0] = (CELL)FunctorString;
|
||||||
@ -382,35 +313,24 @@ __MkUStringTerm (const unsigned char *s USES_REGS)
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN const unsigned char *UStringOfTerm(Term t);
|
INLINE_ONLY inline EXTERN const unsigned char *UStringOfTerm(Term t);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN const unsigned char *
|
INLINE_ONLY inline EXTERN const unsigned char *UStringOfTerm(Term t) {
|
||||||
UStringOfTerm (Term t)
|
|
||||||
{
|
|
||||||
return (const unsigned char *)(RepAppl(t) + 2);
|
return (const unsigned char *)(RepAppl(t) + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN const char *StringOfTerm(Term t);
|
INLINE_ONLY inline EXTERN const char *StringOfTerm(Term t);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN const char *
|
INLINE_ONLY inline EXTERN const char *StringOfTerm(Term t) {
|
||||||
StringOfTerm (Term t)
|
|
||||||
{
|
|
||||||
return (const char *)(RepAppl(t) + 2);
|
return (const char *)(RepAppl(t) + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsStringTerm(Term);
|
INLINE_ONLY inline EXTERN int IsStringTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int
|
INLINE_ONLY inline EXTERN int IsStringTerm(Term t) {
|
||||||
IsStringTerm (Term t)
|
|
||||||
{
|
|
||||||
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorString);
|
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************/
|
/****************************************************/
|
||||||
|
|
||||||
#ifdef USE_GMP
|
#ifdef USE_GMP
|
||||||
@ -444,9 +364,7 @@ typedef struct {
|
|||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsBigIntTerm(Term);
|
INLINE_ONLY inline EXTERN int IsBigIntTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int
|
INLINE_ONLY inline EXTERN int IsBigIntTerm(Term t) {
|
||||||
IsBigIntTerm (Term t)
|
|
||||||
{
|
|
||||||
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorBigInt);
|
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorBigInt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -460,9 +378,7 @@ MP_RAT *Yap_BigRatOfTerm(Term);
|
|||||||
|
|
||||||
INLINE_ONLY inline EXTERN void MPZ_SET(mpz_t, MP_INT *);
|
INLINE_ONLY inline EXTERN void MPZ_SET(mpz_t, MP_INT *);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN void
|
INLINE_ONLY inline EXTERN void MPZ_SET(mpz_t dest, MP_INT *src) {
|
||||||
MPZ_SET (mpz_t dest, MP_INT *src)
|
|
||||||
{
|
|
||||||
dest->_mp_size = src->_mp_size;
|
dest->_mp_size = src->_mp_size;
|
||||||
dest->_mp_alloc = src->_mp_alloc;
|
dest->_mp_alloc = src->_mp_alloc;
|
||||||
dest->_mp_d = src->_mp_d;
|
dest->_mp_d = src->_mp_d;
|
||||||
@ -470,156 +386,101 @@ MPZ_SET (mpz_t dest, MP_INT *src)
|
|||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsLargeIntTerm(Term);
|
INLINE_ONLY inline EXTERN int IsLargeIntTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int
|
INLINE_ONLY inline EXTERN int IsLargeIntTerm(Term t) {
|
||||||
IsLargeIntTerm (Term t)
|
return (int)(IsApplTerm(t) && ((FunctorOfTerm(t) <= FunctorBigInt) &&
|
||||||
{
|
(FunctorOfTerm(t) >= FunctorLongInt)));
|
||||||
return (int) (IsApplTerm (t)
|
|
||||||
&& ((FunctorOfTerm (t) <= FunctorBigInt)
|
|
||||||
&& (FunctorOfTerm (t) >= FunctorLongInt)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN UInt Yap_SizeOfBigInt(Term);
|
INLINE_ONLY inline EXTERN UInt Yap_SizeOfBigInt(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN UInt
|
INLINE_ONLY inline EXTERN UInt Yap_SizeOfBigInt(Term t) {
|
||||||
Yap_SizeOfBigInt (Term t)
|
|
||||||
{
|
|
||||||
CELL *pt = RepAppl(t) + 1;
|
CELL *pt = RepAppl(t) + 1;
|
||||||
return 2+(sizeof(MP_INT)+
|
return 2 +
|
||||||
(((MP_INT *)pt)->_mp_alloc*sizeof(mp_limb_t)))/sizeof(CELL);
|
(sizeof(MP_INT) + (((MP_INT *)pt)->_mp_alloc * sizeof(mp_limb_t))) /
|
||||||
|
sizeof(CELL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsLargeIntTerm(Term);
|
INLINE_ONLY inline EXTERN int IsLargeIntTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int
|
INLINE_ONLY inline EXTERN int IsLargeIntTerm(Term t) {
|
||||||
IsLargeIntTerm (Term t)
|
|
||||||
{
|
|
||||||
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorLongInt);
|
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorLongInt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* extern Functor FunctorLongInt; */
|
/* extern Functor FunctorLongInt; */
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsLargeNumTerm(Term);
|
INLINE_ONLY inline EXTERN int IsLargeNumTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int
|
INLINE_ONLY inline EXTERN int IsLargeNumTerm(Term t) {
|
||||||
IsLargeNumTerm (Term t)
|
return (int)(IsApplTerm(t) && ((FunctorOfTerm(t) <= FunctorBigInt) &&
|
||||||
{
|
(FunctorOfTerm(t) >= FunctorDouble)));
|
||||||
return (int) (IsApplTerm (t)
|
|
||||||
&& ((FunctorOfTerm (t) <= FunctorBigInt)
|
|
||||||
&& (FunctorOfTerm (t) >= FunctorDouble)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsExternalBlobTerm(Term, CELL);
|
INLINE_ONLY inline EXTERN int IsExternalBlobTerm(Term, CELL);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int
|
INLINE_ONLY inline EXTERN int IsExternalBlobTerm(Term t, CELL tag) {
|
||||||
IsExternalBlobTerm (Term t, CELL tag)
|
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorBigInt &&
|
||||||
{
|
|
||||||
return (int) (IsApplTerm (t) &&
|
|
||||||
FunctorOfTerm (t) == FunctorBigInt &&
|
|
||||||
RepAppl(t)[1] == tag);
|
RepAppl(t)[1] == tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN void *ExternalBlobFromTerm(Term);
|
INLINE_ONLY inline EXTERN void *ExternalBlobFromTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN void *
|
INLINE_ONLY inline EXTERN void *ExternalBlobFromTerm(Term t) {
|
||||||
ExternalBlobFromTerm (Term t)
|
|
||||||
{
|
|
||||||
MP_INT *base = (MP_INT *)(RepAppl(t) + 2);
|
MP_INT *base = (MP_INT *)(RepAppl(t) + 2);
|
||||||
return (void *)(base + 1);
|
return (void *)(base + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int IsNumTerm(Term);
|
INLINE_ONLY inline EXTERN int IsNumTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int
|
INLINE_ONLY inline EXTERN int IsNumTerm(Term t) {
|
||||||
IsNumTerm (Term t)
|
|
||||||
{
|
|
||||||
return (int)((IsIntTerm(t) || IsLargeNumTerm(t)));
|
return (int)((IsIntTerm(t) || IsLargeNumTerm(t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int IsAtomicTerm(Term);
|
INLINE_ONLY inline EXTERN Int IsAtomicTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int
|
INLINE_ONLY inline EXTERN Int IsAtomicTerm(Term t) {
|
||||||
IsAtomicTerm (Term t)
|
|
||||||
{
|
|
||||||
return (Int)(IsAtomOrIntTerm(t) || IsLargeNumTerm(t) || IsStringTerm(t));
|
return (Int)(IsAtomOrIntTerm(t) || IsLargeNumTerm(t) || IsStringTerm(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int IsExtensionFunctor(Functor);
|
INLINE_ONLY inline EXTERN Int IsExtensionFunctor(Functor);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int
|
INLINE_ONLY inline EXTERN Int IsExtensionFunctor(Functor f) {
|
||||||
IsExtensionFunctor (Functor f)
|
|
||||||
{
|
|
||||||
return (Int)(f <= FunctorString);
|
return (Int)(f <= FunctorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int IsBlobFunctor(Functor);
|
INLINE_ONLY inline EXTERN Int IsBlobFunctor(Functor);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int
|
INLINE_ONLY inline EXTERN Int IsBlobFunctor(Functor f) {
|
||||||
IsBlobFunctor (Functor f)
|
|
||||||
{
|
|
||||||
return (Int)((f <= FunctorString && f >= FunctorDBRef));
|
return (Int)((f <= FunctorString && f >= FunctorDBRef));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int IsPrimitiveTerm(Term);
|
INLINE_ONLY inline EXTERN Int IsPrimitiveTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int
|
INLINE_ONLY inline EXTERN Int IsPrimitiveTerm(Term t) {
|
||||||
IsPrimitiveTerm (Term t)
|
return (Int)((IsAtomOrIntTerm(t) ||
|
||||||
{
|
(IsApplTerm(t) && IsBlobFunctor(FunctorOfTerm(t)))));
|
||||||
return (Int) ((IsAtomOrIntTerm (t)
|
|
||||||
|| (IsApplTerm (t) && IsBlobFunctor (FunctorOfTerm (t)))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TERM_EXTENSIONS
|
#ifdef TERM_EXTENSIONS
|
||||||
|
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int IsAttachFunc(Functor);
|
INLINE_ONLY inline EXTERN Int IsAttachFunc(Functor);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int
|
INLINE_ONLY inline EXTERN Int IsAttachFunc(Functor f) { return (Int)(FALSE); }
|
||||||
IsAttachFunc (Functor f)
|
|
||||||
{
|
|
||||||
return (Int) (FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define IsAttachedTerm(t) __IsAttachedTerm(t PASS_REGS)
|
#define IsAttachedTerm(t) __IsAttachedTerm(t PASS_REGS)
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int __IsAttachedTerm(Term USES_REGS);
|
INLINE_ONLY inline EXTERN Int __IsAttachedTerm(Term USES_REGS);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int
|
INLINE_ONLY inline EXTERN Int __IsAttachedTerm(Term t USES_REGS) {
|
||||||
__IsAttachedTerm (Term t USES_REGS)
|
|
||||||
{
|
|
||||||
return (Int)((IsVarTerm(t) && IsAttVar(VarOfTerm(t))));
|
return (Int)((IsVarTerm(t) && IsAttVar(VarOfTerm(t))));
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int GlobalIsAttachedTerm(Term);
|
INLINE_ONLY inline EXTERN Int GlobalIsAttachedTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int
|
INLINE_ONLY inline EXTERN Int GlobalIsAttachedTerm(Term t) {
|
||||||
GlobalIsAttachedTerm (Term t)
|
|
||||||
{
|
|
||||||
return (Int)((IsVarTerm(t) && GlobalIsAttVar(VarOfTerm(t))));
|
return (Int)((IsVarTerm(t) && GlobalIsAttVar(VarOfTerm(t))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -627,63 +488,37 @@ GlobalIsAttachedTerm (Term t)
|
|||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int __SafeIsAttachedTerm(Term USES_REGS);
|
INLINE_ONLY inline EXTERN Int __SafeIsAttachedTerm(Term USES_REGS);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int
|
INLINE_ONLY inline EXTERN Int __SafeIsAttachedTerm(Term t USES_REGS) {
|
||||||
__SafeIsAttachedTerm (Term t USES_REGS)
|
|
||||||
{
|
|
||||||
return (Int)(IsVarTerm(t) && IsAttVar(VarOfTerm(t)));
|
return (Int)(IsVarTerm(t) && IsAttVar(VarOfTerm(t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN exts ExtFromCell(CELL *);
|
INLINE_ONLY inline EXTERN exts ExtFromCell(CELL *);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN exts
|
INLINE_ONLY inline EXTERN exts ExtFromCell(CELL *pt) { return attvars_ext; }
|
||||||
ExtFromCell (CELL * pt)
|
|
||||||
{
|
|
||||||
return attvars_ext;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int IsAttachFunc(Functor);
|
INLINE_ONLY inline EXTERN Int IsAttachFunc(Functor);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int
|
INLINE_ONLY inline EXTERN Int IsAttachFunc(Functor f) { return (Int)(FALSE); }
|
||||||
IsAttachFunc (Functor f)
|
|
||||||
{
|
|
||||||
return (Int) (FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int IsAttachedTerm(Term);
|
INLINE_ONLY inline EXTERN Int IsAttachedTerm(Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int
|
INLINE_ONLY inline EXTERN Int IsAttachedTerm(Term t) { return (Int)(FALSE); }
|
||||||
IsAttachedTerm (Term t)
|
|
||||||
{
|
|
||||||
return (Int) (FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int Yap_BlobTag(Term t);
|
INLINE_ONLY inline EXTERN Int Yap_BlobTag(Term t);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Int Yap_BlobTag(Term t)
|
INLINE_ONLY inline EXTERN Int Yap_BlobTag(Term t) {
|
||||||
{
|
|
||||||
CELL *pt = RepAppl(t);
|
CELL *pt = RepAppl(t);
|
||||||
|
|
||||||
return pt[1];
|
return pt[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN void *Yap_BlobInfo(Term t);
|
INLINE_ONLY inline EXTERN void *Yap_BlobInfo(Term t);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN void *Yap_BlobInfo(Term t)
|
INLINE_ONLY inline EXTERN void *Yap_BlobInfo(Term t) {
|
||||||
{
|
|
||||||
MP_INT *blobp;
|
MP_INT *blobp;
|
||||||
CELL *pt = RepAppl(t);
|
CELL *pt = RepAppl(t);
|
||||||
|
|
||||||
@ -699,11 +534,9 @@ EXTERN int unify_extension(Functor, CELL, CELL *, CELL);
|
|||||||
|
|
||||||
int Yap_gmp_tcmp_big_big(Term, Term);
|
int Yap_gmp_tcmp_big_big(Term, Term);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int
|
INLINE_ONLY inline EXTERN int unify_extension(Functor f, CELL d0, CELL *pt0,
|
||||||
unify_extension (Functor f, CELL d0, CELL * pt0, CELL d1)
|
CELL d1) {
|
||||||
{
|
switch (BlobOfFunctor(f)) {
|
||||||
switch (BlobOfFunctor (f))
|
|
||||||
{
|
|
||||||
case db_ref_e:
|
case db_ref_e:
|
||||||
return (d0 == d1);
|
return (d0 == d1);
|
||||||
case attvar_e:
|
case attvar_e:
|
||||||
@ -718,8 +551,7 @@ unify_extension (Functor f, CELL d0, CELL * pt0, CELL d1)
|
|||||||
#else
|
#else
|
||||||
return d0 == d1;
|
return d0 == d1;
|
||||||
#endif /* USE_GMP */
|
#endif /* USE_GMP */
|
||||||
case double_e:
|
case double_e: {
|
||||||
{
|
|
||||||
CELL *pt1 = RepAppl(d1);
|
CELL *pt1 = RepAppl(d1);
|
||||||
return (pt0[1] == pt1[1]
|
return (pt0[1] == pt1[1]
|
||||||
#if SIZEOF_DOUBLE == 2 * SIZEOF_INT_P
|
#if SIZEOF_DOUBLE == 2 * SIZEOF_INT_P
|
||||||
@ -731,9 +563,7 @@ unify_extension (Functor f, CELL d0, CELL * pt0, CELL d1)
|
|||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
static inline CELL Yap_IntP_key(CELL *pt) {
|
||||||
CELL Yap_IntP_key(CELL *pt)
|
|
||||||
{
|
|
||||||
#ifdef USE_GMP
|
#ifdef USE_GMP
|
||||||
if (((Functor)pt[-1] == FunctorBigInt)) {
|
if (((Functor)pt[-1] == FunctorBigInt)) {
|
||||||
MP_INT *b1 = Yap_BigIntOfTerm(AbsAppl(pt - 1));
|
MP_INT *b1 = Yap_BigIntOfTerm(AbsAppl(pt - 1));
|
||||||
@ -745,15 +575,9 @@ CELL Yap_IntP_key(CELL *pt)
|
|||||||
return MkIntTerm(pt[0] & (MAX_ABS_INT - 1));
|
return MkIntTerm(pt[0] & (MAX_ABS_INT - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
static inline CELL Yap_Int_key(Term t) { return Yap_IntP_key(RepAppl(t) + 1); }
|
||||||
CELL Yap_Int_key(Term t)
|
|
||||||
{
|
|
||||||
return Yap_IntP_key(RepAppl(t)+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline
|
static inline CELL Yap_DoubleP_key(CELL *pt) {
|
||||||
CELL Yap_DoubleP_key(CELL *pt)
|
|
||||||
{
|
|
||||||
#if SIZEOF_DOUBLE1 == 2 * SIZEOF_INT_P
|
#if SIZEOF_DOUBLE1 == 2 * SIZEOF_INT_P
|
||||||
CELL val = pt[0] ^ pt[1];
|
CELL val = pt[0] ^ pt[1];
|
||||||
#else
|
#else
|
||||||
@ -762,15 +586,11 @@ CELL Yap_DoubleP_key(CELL *pt)
|
|||||||
return MkIntTerm(val & (MAX_ABS_INT - 1));
|
return MkIntTerm(val & (MAX_ABS_INT - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
static inline CELL Yap_Double_key(Term t) {
|
||||||
CELL Yap_Double_key(Term t)
|
|
||||||
{
|
|
||||||
return Yap_DoubleP_key(RepAppl(t) + 1);
|
return Yap_DoubleP_key(RepAppl(t) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
static inline CELL Yap_StringP_key(CELL *pt) {
|
||||||
CELL Yap_StringP_key(CELL *pt)
|
|
||||||
{
|
|
||||||
UInt n = pt[1], i;
|
UInt n = pt[1], i;
|
||||||
CELL val = pt[2];
|
CELL val = pt[2];
|
||||||
for (i = 1; i < n; i++) {
|
for (i = 1; i < n; i++) {
|
||||||
@ -779,9 +599,7 @@ CELL Yap_StringP_key(CELL *pt)
|
|||||||
return MkIntTerm(val & (MAX_ABS_INT - 1));
|
return MkIntTerm(val & (MAX_ABS_INT - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
static inline CELL Yap_String_key(Term t) {
|
||||||
CELL Yap_String_key(Term t)
|
|
||||||
{
|
|
||||||
return Yap_StringP_key(RepAppl(t) + 1);
|
return Yap_StringP_key(RepAppl(t) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
28
H/Yap.h
@ -376,6 +376,17 @@ typedef volatile int lockvar;
|
|||||||
|
|
||||||
#include "Regs.h"
|
#include "Regs.h"
|
||||||
|
|
||||||
|
/*************************************************************************************************
|
||||||
|
OPTYAP includes
|
||||||
|
*************************************************************************************************/
|
||||||
|
|
||||||
|
#if defined(YAPOR) || defined(TABLING)
|
||||||
|
#include "opt.structs.h"
|
||||||
|
#include "opt.proto.h"
|
||||||
|
#include "opt.macros.h"
|
||||||
|
#endif /* YAPOR || TABLING */
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************************************
|
/*************************************************************************************************
|
||||||
variables concerned with Error Handling
|
variables concerned with Error Handling
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
@ -733,17 +744,6 @@ typedef struct scratch_block_struct {
|
|||||||
/* scanner types */
|
/* scanner types */
|
||||||
#include "ScannerTypes.h"
|
#include "ScannerTypes.h"
|
||||||
|
|
||||||
/*************************************************************************************************
|
|
||||||
OPTYAP includes
|
|
||||||
*************************************************************************************************/
|
|
||||||
|
|
||||||
#if defined(YAPOR) || defined(TABLING)
|
|
||||||
#include "opt.structs.h"
|
|
||||||
#include "opt.proto.h"
|
|
||||||
#include "opt.macros.h"
|
|
||||||
#endif /* YAPOR || TABLING */
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************************************
|
/*************************************************************************************************
|
||||||
GLOBAL and LOCAL variables
|
GLOBAL and LOCAL variables
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
@ -771,10 +771,8 @@ extern struct worker_local Yap_local;
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#define YP_FILE FILE
|
#define YP_FILE FILE
|
||||||
#include "hglobals.h"
|
|
||||||
#include "dglobals.h"
|
#include <YapHeap.h>
|
||||||
#include "hlocals.h"
|
|
||||||
#include "dlocals.h"
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************************************
|
/*************************************************************************************************
|
||||||
|
65
H/YapFlags.h
@ -25,37 +25,66 @@
|
|||||||
|
|
||||||
// INLINE_ONLY inline EXTERN bool nat( Term inp );
|
// INLINE_ONLY inline EXTERN bool nat( Term inp );
|
||||||
|
|
||||||
|
#define SYSTEM_OPTION_0 "attributed_variables,rational_trees]"
|
||||||
|
#if THREADS
|
||||||
|
#define SYSTEM_OPTION_1 "threads,"
|
||||||
|
#endif
|
||||||
|
#if USE_GMP
|
||||||
|
#define SYSTEM_OPTION_3 "big_numbers,"
|
||||||
|
#endif
|
||||||
|
#if DEPTH_LIMIT
|
||||||
|
#define SYSTEM_OPTION_4 "depth_limit,"
|
||||||
|
#endif
|
||||||
|
#if LOW_LEVEL_TRACE
|
||||||
|
#define SYSTEM_OPTION_5 "low_level_tracer,"
|
||||||
|
#endif
|
||||||
|
#if YAPOR
|
||||||
|
#define SYSTEM_OPTION_6 "or_parallelism,"
|
||||||
|
#endif
|
||||||
|
#if USE_READLINE
|
||||||
|
#define SYSTEM_OPTION_7 "readline,"
|
||||||
|
#endif
|
||||||
|
#if TABLING
|
||||||
|
#define SYSTEM_OPTION_8 "tabling,"
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline bool nat(Term inp) {
|
static inline bool nat(Term inp) {
|
||||||
if (IsVarTerm(inp)) {
|
if (IsVarTerm(inp)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag: value must be %s", "bound");
|
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag: value must be %s",
|
||||||
|
"bound");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (IsIntTerm(inp)) {
|
if (IsIntTerm(inp)) {
|
||||||
Int i = IntOfTerm(inp);
|
Int i = IntOfTerm(inp);
|
||||||
if (i >= 0)
|
if (i >= 0)
|
||||||
return true;
|
return true;
|
||||||
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, inp, "set_prolog_flag: value must be %s", ">= 0");
|
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, inp,
|
||||||
|
"set_prolog_flag: value must be %s", ">= 0");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Yap_Error(TYPE_ERROR_INTEGER, inp, "set_prolog_flag: value must be %s", "integer");
|
Yap_Error(TYPE_ERROR_INTEGER, inp, "set_prolog_flag: value must be %s",
|
||||||
|
"integer");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool at2n(Term inp) {
|
static inline bool at2n(Term inp) {
|
||||||
Yap_Error(PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag %s", "flag is read-only");
|
Yap_Error(PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag %s",
|
||||||
|
"flag is read-only");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool isfloat(Term inp) {
|
static inline bool isfloat(Term inp) {
|
||||||
if (IsVarTerm(inp)) {
|
if (IsVarTerm(inp)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag: value must be %s", "integer");
|
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag: value must be %s",
|
||||||
|
"integer");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (IsFloatTerm(inp)) {
|
if (IsFloatTerm(inp)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Yap_Error(TYPE_ERROR_FLOAT, inp, "set_prolog_flag: value must be %s", "floating-point");
|
Yap_Error(TYPE_ERROR_FLOAT, inp, "set_prolog_flag: value must be %s",
|
||||||
|
"floating-point");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,20 +92,24 @@ INLINE_ONLY inline EXTERN bool ro(Term inp);
|
|||||||
|
|
||||||
INLINE_ONLY inline EXTERN bool ro(Term inp) {
|
INLINE_ONLY inline EXTERN bool ro(Term inp) {
|
||||||
if (IsVarTerm(inp)) {
|
if (IsVarTerm(inp)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag: value must be %s", "bound");
|
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag: value must be %s",
|
||||||
|
"bound");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Yap_Error(PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag %s", "flag is read-only");
|
Yap_Error(PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag %s",
|
||||||
|
"flag is read-only");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN bool aro(Term inp) {
|
INLINE_ONLY inline EXTERN bool aro(Term inp) {
|
||||||
if (IsVarTerm(inp)) {
|
if (IsVarTerm(inp)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag %s", "value must be bound");
|
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag %s",
|
||||||
|
"value must be bound");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Yap_Error(PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag %s", "flag is read-only");
|
Yap_Error(PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag %s",
|
||||||
|
"flag is read-only");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -87,7 +120,8 @@ static inline bool boolean(Term inp) {
|
|||||||
if (inp == TermTrue || inp == TermFalse || inp == TermOn || inp == TermOff)
|
if (inp == TermTrue || inp == TermFalse || inp == TermOn || inp == TermOff)
|
||||||
return true;
|
return true;
|
||||||
if (IsVarTerm(inp)) {
|
if (IsVarTerm(inp)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag %s", "value must be bound");
|
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag %s",
|
||||||
|
"value must be bound");
|
||||||
;
|
;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -134,7 +168,8 @@ static bool bqs(Term inp) {
|
|||||||
|
|
||||||
static inline bool isatom(Term inp) {
|
static inline bool isatom(Term inp) {
|
||||||
if (IsVarTerm(inp)) {
|
if (IsVarTerm(inp)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag %s", "value must be bound");
|
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag %s",
|
||||||
|
"value must be bound");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (IsAtomTerm(inp))
|
if (IsAtomTerm(inp))
|
||||||
@ -143,6 +178,8 @@ static inline bool isatom(Term inp) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool options(Term inp) { return Yap_IsGroundTerm(inp); }
|
||||||
|
|
||||||
// INLINE_ONLY inline EXTERN bool ok( Term inp );
|
// INLINE_ONLY inline EXTERN bool ok( Term inp );
|
||||||
|
|
||||||
static inline bool ok(Term inp) { return true; }
|
static inline bool ok(Term inp) { return true; }
|
||||||
@ -305,6 +342,10 @@ static inline size_t indexingDepth(void) {
|
|||||||
return IntOfTerm(GLOBAL_Flags[INDEX_SUB_TERM_SEARCH_DEPTH_FLAG].at);
|
return IntOfTerm(GLOBAL_Flags[INDEX_SUB_TERM_SEARCH_DEPTH_FLAG].at);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline Term gcTrace(void) {
|
||||||
|
return GLOBAL_Flags[GC_TRACE_FLAG].at;
|
||||||
|
}
|
||||||
|
|
||||||
bool rmdot(Term inp);
|
bool rmdot(Term inp);
|
||||||
|
|
||||||
xarg *Yap_ArgListToVector(Term listl, const param_t *def, int n);
|
xarg *Yap_ArgListToVector(Term listl, const param_t *def, int n);
|
||||||
|
@ -63,7 +63,7 @@ Prolog exceptions. If enabled:
|
|||||||
~~~~
|
~~~~
|
||||||
?- X is 2/0.
|
?- X is 2/0.
|
||||||
ERROR!!
|
ERROR!!
|
||||||
ZERO DIVISOR ERROR- X is Exp
|
ZERO DIVISO]]R ERROR- X is Exp
|
||||||
~~~~
|
~~~~
|
||||||
|
|
||||||
If disabled:
|
If disabled:
|
||||||
@ -364,7 +364,7 @@ bound to `off` disable strict mode, and keep the current language
|
|||||||
mode. The default for YAP is `off`.
|
mode. The default for YAP is `off`.
|
||||||
Under strict ISO Prolog mode all calls to non-ISO built-ins generate an
|
Under strict ISO Prolog mode all calls to non-ISO built-ins generate an
|
||||||
error. Compilation of clauses that would call non-ISO built-ins will
|
error. Compilation of clauses that would call non-ISO built-ins will
|
||||||
§§also generate errors. Pre-processing for grammar rules is also
|
also generate errors. Pre-processing for grammar rules is also
|
||||||
disabled. Module expansion is still performed.
|
disabled. Module expansion is still performed.
|
||||||
Arguably, ISO Prolog does not provide all the functionality required
|
Arguably, ISO Prolog does not provide all the functionality required
|
||||||
from a modern Prolog system. Moreover, because most Prolog
|
from a modern Prolog system. Moreover, because most Prolog
|
||||||
@ -377,9 +377,8 @@ believe this mode is mostly useful when investigating how a program
|
|||||||
depends on a Prolog's platform specific features.
|
depends on a Prolog's platform specific features.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
YAP_FLAG(SYSTEM_OPTIONS_FLAG, "system_options", false, ro,
|
YAP_FLAG(SYSTEM_OPTIONS_FLAG, "system_options", false, options,
|
||||||
"[big_numbers,coroutining,depth_limit,low_level_tracer,rational_"
|
SYSTEM_OPTIONS,
|
||||||
"trees,threads,tabling]",
|
|
||||||
NULL), /**< `system_options `
|
NULL), /**< `system_options `
|
||||||
|
|
||||||
This read only flag tells which options were used to compile
|
This read only flag tells which options were used to compile
|
||||||
@ -411,8 +410,8 @@ presented. Only the first solution is considered and the goal is not
|
|||||||
backtracked into.
|
backtracked into.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
YAP_FLAG(TOPLEVEL_PROMPT_FLAG, "toplevel_prompt", true, isatom,
|
YAP_FLAG(TOPLEVEL_PROMPT_FLAG, "toplevel_prompt", true, isatom, "?- ",
|
||||||
"?- ", mkprompt),
|
mkprompt),
|
||||||
YAP_FLAG(TTY_CONTROL_FLAG, "tty_control", true, boolean, "true", NULL),
|
YAP_FLAG(TTY_CONTROL_FLAG, "tty_control", true, boolean, "true", NULL),
|
||||||
YAP_FLAG(UNIX_FLAG, "unix", false, ro, "true", NULL), /**< `unix`
|
YAP_FLAG(UNIX_FLAG, "unix", false, ro, "true", NULL), /**< `unix`
|
||||||
|
|
||||||
@ -442,10 +441,11 @@ follows immediate semantics.
|
|||||||
library.
|
library.
|
||||||
*/
|
*/
|
||||||
YAP_FLAG(UNKNOWN_FLAG, "unknown", true, isatom, "error",
|
YAP_FLAG(UNKNOWN_FLAG, "unknown", true, isatom, "error",
|
||||||
NULL), /**< `unknown is iso`
|
Yap_unknown), /**< `unknown is iso`
|
||||||
|
|
||||||
Corresponds to calling the unknown/2 built-in. Possible values
|
Corresponds to calling the unknown/2 built-in. Possible ISO values
|
||||||
are `error`, `fail`, and `warning`.
|
are `error`, `fail`, and `warning`. Yap includes the following extensions:
|
||||||
|
`fast_fail` does not invoke any handler.
|
||||||
*/
|
*/
|
||||||
YAP_FLAG(VARIABLE_NAMES_MAY_END_WITH_QUOTES_FLAG,
|
YAP_FLAG(VARIABLE_NAMES_MAY_END_WITH_QUOTES_FLAG,
|
||||||
"variable_names_may_end_with_quotes", true, boolean, "false",
|
"variable_names_may_end_with_quotes", true, boolean, "false",
|
||||||
|
@ -61,67 +61,86 @@ functions are then exported through corresponding FLI C-functions
|
|||||||
#define Yap_RebootSlots(wid) Yap_RebootSlots__(wid PASS_REGS)
|
#define Yap_RebootSlots(wid) Yap_RebootSlots__(wid PASS_REGS)
|
||||||
|
|
||||||
static inline void Yap_RebootSlots__(int wid USES_REGS) {
|
static inline void Yap_RebootSlots__(int wid USES_REGS) {
|
||||||
// // fprintf(stderr, " StartSlots = %ld", LOCAL_CurSlot);
|
// fprintf(stderr, " StartSlots = %ld", LOCAL_CurSlot);
|
||||||
REMOTE_CurSlot(wid) = 1;
|
REMOTE_CurSlot(wid) = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief declares a new set of slots.
|
/// @brief declares a new set of slots.
|
||||||
/// Used to tell how many slots we had when we entered a segment of code.
|
/// Used to tell how many slots we had when we entered a segment of code.
|
||||||
//#define Yap_StartSlots() ( printf("[<<<%s,%s,%d-%ld\n",__FILE__,__FUNCTION__,__LINE__,LOCAL_CurSlot)?Yap_StartSlots__(PASS_REGS1): -1)
|
//#define Yap_StartSlots() (
|
||||||
|
// printf("[<<<%s,%s,%d-%ld\n",__FILE__,__FUNCTION__,__LINE__,LOCAL_CurSlot)?Yap_StartSlots__(PASS_REGS1):
|
||||||
|
//-1)
|
||||||
#define Yap_StartSlots() Yap_StartSlots__(PASS_REGS1)
|
#define Yap_StartSlots() Yap_StartSlots__(PASS_REGS1)
|
||||||
|
|
||||||
static inline yhandle_t Yap_StartSlots__(USES_REGS1) {
|
INLINE_ONLY inline EXTERN yhandle_t Yap_StartSlots__(USES_REGS1);
|
||||||
|
INLINE_ONLY inline EXTERN yhandle_t Yap_StartSlots__(USES_REGS1) {
|
||||||
// // fprintf(stderr, " StartSlots = %ld", LOCAL_CurSlot);
|
// // fprintf(stderr, " StartSlots = %ld", LOCAL_CurSlot);
|
||||||
// fprintf(stderr,"SS %s:%d\n", __FUNCTION__, __LINE__);;
|
// fprintf(stderr,"SS %s:%d\n", __FILE__, __LINE__);;
|
||||||
if (LOCAL_CurSlot < 0) {
|
if (LOCAL_CurSlot < 0) {
|
||||||
Yap_Error(SYSTEM_ERROR_INTERNAL, 0L, " StartSlots = %ld", LOCAL_CurSlot);
|
Yap_Error(SYSTEM_ERROR_INTERNAL, 0L, " StartSlots = %ld", LOCAL_CurSlot);
|
||||||
}
|
}
|
||||||
return LOCAL_CurSlot;
|
return LOCAL_CurSlot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// @brief reset slots to a well-known position in the stack
|
/// @brief reset slots to a well-known position in the stack
|
||||||
//#define Yap_CloseSlots(slot) ( printf("- %s,%s,%d %ld>>>]\n",__FILE__,__FUNCTION__,__LINE__, slot)?Yap_CloseSlots__(slot PASS_REGS):-1)
|
//#define Yap_CloseSlots(slot) ( printf("- %s,%s,%d
|
||||||
|
//%ld>>>]\n",__FILE__,__FUNCTION__,__LINE__, slot)?Yap_CloseSlots__(slot
|
||||||
|
// PASS_REGS):-1)
|
||||||
#define Yap_CloseSlots(slot) Yap_CloseSlots__(slot PASS_REGS)
|
#define Yap_CloseSlots(slot) Yap_CloseSlots__(slot PASS_REGS)
|
||||||
|
|
||||||
static inline void Yap_CloseSlots__(yhandle_t slot USES_REGS) {
|
INLINE_ONLY inline EXTERN void Yap_CloseSlots__(yhandle_t slot USES_REGS);
|
||||||
// fprintf(stderr,"CS %s:%d\n", __FUNCTION__, __LINE__);;
|
INLINE_ONLY inline EXTERN void Yap_CloseSlots__(yhandle_t slot USES_REGS) {
|
||||||
|
// fprintf(stderr,"CS %s:%d\n", __FILE__, __LINE__);;
|
||||||
LOCAL_CurSlot = slot;
|
LOCAL_CurSlot = slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define Yap_CurrentSlot() Yap_CurrentSlot__(PASS_REGS1)
|
||||||
/// @brief report the current position of the slots, assuming that they occupy
|
/// @brief report the current position of the slots, assuming that they occupy
|
||||||
/// the top of the stack.
|
/// the top of the stack.
|
||||||
static inline yhandle_t Yap_CurrentSlot(USES_REGS1) { return LOCAL_CurSlot; }
|
INLINE_ONLY inline EXTERN yhandle_t Yap_CurrentSlot__(USES_REGS1);
|
||||||
|
INLINE_ONLY inline EXTERN yhandle_t Yap_CurrentSlot__(USES_REGS1) {
|
||||||
|
return LOCAL_CurSlot;
|
||||||
|
}
|
||||||
|
|
||||||
#define Yap_GetFromSlot(slot) Yap_GetFromSlot__(slot PASS_REGS)
|
#define Yap_GetFromSlot(slot) Yap_GetFromSlot__(slot PASS_REGS)
|
||||||
/// @brief read from a slot.
|
/// @brief read from a slot.
|
||||||
static inline Term Yap_GetFromSlot__(yhandle_t slot USES_REGS) {
|
INLINE_ONLY inline EXTERN Term Yap_GetFromSlot__(yhandle_t slot USES_REGS);
|
||||||
// fprintf(stderr,"GS %s:%d\n", __FUNCTION__, __LINE__);;
|
INLINE_ONLY inline EXTERN Term Yap_GetFromSlot__(yhandle_t slot USES_REGS) {
|
||||||
return (Deref(LOCAL_SlotBase[slot]));
|
// fprintf(stderr, "GS %s:%d\n", __FILE__, __LINE__);
|
||||||
|
return Deref(LOCAL_SlotBase[slot]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define Yap_GetDerefedFromSlot( slot ) Yap_GetDerefedFromSlot__(slot PASS_REGS)
|
||||||
/// @brief read from a slot. but does not try to dereference the slot.
|
/// @brief read from a slot. but does not try to dereference the slot.
|
||||||
static inline Term Yap_GetDerefedFromSlot(yhandle_t slot USES_REGS) {
|
INLINE_ONLY inline EXTERN Term Yap_GetDerefedFromSlot__(yhandle_t slot USES_REGS);
|
||||||
// fprintf(stderr,"GDS %s:%d\n", __FUNCTION__, __LINE__);
|
INLINE_ONLY inline EXTERN Term Yap_GetDerefedFromSlot__(yhandle_t slot USES_REGS) {
|
||||||
|
// fprintf(stderr,"GDS %s:%d\n", __FILE__, __LINE__);
|
||||||
return LOCAL_SlotBase[slot];
|
return LOCAL_SlotBase[slot];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define Yap_GetPtrFromSlot( slot ) Yap_GetPtrFromSlot__(slot PASS_REGS)
|
||||||
|
|
||||||
/// @brief read the object in a slot. but do not try to dereference the slot.
|
/// @brief read the object in a slot. but do not try to dereference the slot.
|
||||||
static inline Term Yap_GetPtrFromSlot(yhandle_t slot USES_REGS) {
|
INLINE_ONLY inline EXTERN Term *Yap_GetPtrFromSlot__(yhandle_t slot USES_REGS);
|
||||||
// fprintf(stderr,"GPS %s:%d\n", __FUNCTION__, __LINE__);
|
INLINE_ONLY inline EXTERN Term *Yap_GetPtrFromSlot__(yhandle_t slot USES_REGS) {
|
||||||
return LOCAL_SlotBase[slot];
|
// fprintf(stderr,"GPS %s:%d\n", __FILE__, __LINE__);
|
||||||
|
return (Term *)LOCAL_SlotBase[slot];
|
||||||
}
|
}
|
||||||
|
|
||||||
#define Yap_AddressFromSlot(slot) Yap_AddressFromSlot__(slot PASS_REGS)
|
#define Yap_AddressFromSlot(slot) Yap_AddressFromSlot__(slot PASS_REGS)
|
||||||
|
|
||||||
|
INLINE_ONLY inline EXTERN CELL *Yap_AddressFromSlot__(yhandle_t slot USES_REGS);
|
||||||
|
INLINE_ONLY inline EXTERN CELL *Yap_AddressFromSlot__(yhandle_t slot USES_REGS) {
|
||||||
/// @brief get the memory address of a slot
|
/// @brief get the memory address of a slot
|
||||||
static inline Term *Yap_AddressFromSlot__(yhandle_t slot USES_REGS) {
|
|
||||||
return LOCAL_SlotBase + slot;
|
return LOCAL_SlotBase + slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define Yap_PutInSlot(slot, t) Yap_PutInSlot__(slot, t PASS_REGS)
|
||||||
/// @brief store term in a slot
|
/// @brief store term in a slot
|
||||||
static inline void Yap_PutInSlot(yhandle_t slot, Term t USES_REGS) {
|
INLINE_ONLY inline EXTERN void Yap_PutInSlot__(yhandle_t slot, Term t USES_REGS);
|
||||||
// fprintf(stderr,"PS %s:%d\n", __FUNCTION__, __LINE__);
|
INLINE_ONLY inline EXTERN void Yap_PutInSlot__(yhandle_t slot, Term t USES_REGS) {
|
||||||
|
// fprintf(stderr,"PS %s:%d\n", __FILE__, __LINE__);
|
||||||
LOCAL_SlotBase[slot] = t;
|
LOCAL_SlotBase[slot] = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +148,7 @@ static inline void Yap_PutInSlot(yhandle_t slot, Term t USES_REGS) {
|
|||||||
#define max(X, Y) (X > Y ? X : Y)
|
#define max(X, Y) (X > Y ? X : Y)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline void ensure_slots(int N USES_REGS) {
|
INLINE_ONLY inline EXTERN void ensure_slots(int N USES_REGS) {
|
||||||
if (LOCAL_CurSlot + N >= LOCAL_NSlots) {
|
if (LOCAL_CurSlot + N >= LOCAL_NSlots) {
|
||||||
size_t inc = max(16 * 1024, LOCAL_NSlots / 2); // measured in cells
|
size_t inc = max(16 * 1024, LOCAL_NSlots / 2); // measured in cells
|
||||||
inc = max(inc, N + 16); // measured in cells
|
inc = max(inc, N + 16); // measured in cells
|
||||||
@ -147,12 +166,15 @@ static inline void ensure_slots(int N USES_REGS) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @brief create a new slot with term t
|
/// @brief create a new slot with term t
|
||||||
//#define Yap_InitSlot(t) ( printf("+%d %s,%s,%d>>>]\n",1,__FILE__,__FUNCTION__,__LINE__)?Yap_InitSlot__(t PASS_REGS):-1)
|
// #define Yap_InitSlot(t)
|
||||||
|
// (printf("+%d %ld %s,%s,%d>>>]\n", 1, LOCAL_CurSlot,__FILE__, __FUNCTION__, __LINE__)
|
||||||
|
// ? Yap_InitSlot__(t PASS_REGS)
|
||||||
|
// : -1)
|
||||||
#define Yap_InitSlot(t) Yap_InitSlot__(t PASS_REGS)
|
#define Yap_InitSlot(t) Yap_InitSlot__(t PASS_REGS)
|
||||||
|
|
||||||
static inline yhandle_t Yap_InitSlot__(Term t USES_REGS) {
|
INLINE_ONLY inline EXTERN yhandle_t Yap_InitSlot__(Term t USES_REGS);
|
||||||
|
INLINE_ONLY inline EXTERN yhandle_t Yap_InitSlot__(Term t USES_REGS) {
|
||||||
yhandle_t old_slots = LOCAL_CurSlot;
|
yhandle_t old_slots = LOCAL_CurSlot;
|
||||||
// fprintf(stderr,"IS %s:%d\n", __FUNCTION__, __LINE__);
|
|
||||||
|
|
||||||
ensure_slots(1 PASS_REGS);
|
ensure_slots(1 PASS_REGS);
|
||||||
LOCAL_SlotBase[old_slots] = t;
|
LOCAL_SlotBase[old_slots] = t;
|
||||||
@ -160,14 +182,14 @@ static inline yhandle_t Yap_InitSlot__(Term t USES_REGS) {
|
|||||||
return old_slots;
|
return old_slots;
|
||||||
}
|
}
|
||||||
|
|
||||||
//#define Yap_NewSlots(n) ( printf("+%d %s,%s,%d>>>]\n",n,__FILE__,__FUNCTION__,__LINE__)?Yap_NewSlots__(n PASS_REGS):-1)
|
//#define Yap_NewSlots(n) ( printf("+%d %ld %s,%s,%d>>>]\n",n,LOCAL_CurSlot,__FILE__,__FUNCTION__,__LINE__) ?Yap_NewSlots__(n PASS_REGS):-1)
|
||||||
#define Yap_NewSlots(n) Yap_NewSlots__(n PASS_REGS)
|
#define Yap_NewSlots(n) Yap_NewSlots__(n PASS_REGS)
|
||||||
|
|
||||||
/// @brief allocate n empty new slots
|
INLINE_ONLY inline EXTERN yhandle_t Yap_NewSlots__(int n USES_REGS);
|
||||||
static inline yhandle_t Yap_NewSlots__(int n USES_REGS) {
|
INLINE_ONLY inline EXTERN yhandle_t Yap_NewSlots__(int n USES_REGS) {
|
||||||
yhandle_t old_slots = LOCAL_CurSlot;
|
yhandle_t old_slots = LOCAL_CurSlot;
|
||||||
int i;
|
int i;
|
||||||
// fprintf(stderr,"NS %s:%d\n", __FUNCTION__, __LINE__);
|
//fprintf(stderr, "NS %s:%d\n", __FILE__, __LINE__);
|
||||||
|
|
||||||
ensure_slots(n PASS_REGS);
|
ensure_slots(n PASS_REGS);
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
@ -177,15 +199,17 @@ static inline yhandle_t Yap_NewSlots__(int n USES_REGS) {
|
|||||||
return old_slots;
|
return old_slots;
|
||||||
}
|
}
|
||||||
|
|
||||||
//#define Yap_InitSlots(n, ts) ( printf("+%d %s,%s,%d>>>]\n",n,__FILE__,__FUNCTION__,__LINE__)?Yap_InitSlots__(n, ts PASS_REGS):-1)
|
//#define Yap_InitSlots(n, ts)
|
||||||
|
// (printf("+%d %d %s,%s,%d>>>]\n", n, LOCAL_CurSlot, __FILE__, __FUNCTION__, __LINE__)
|
||||||
|
// ? Yap_InitSlots__(n, ts PASS_REGS)
|
||||||
|
// : -1)
|
||||||
#define Yap_InitSlots(n, ts) Yap_InitSlots__(n, ts PASS_REGS)
|
#define Yap_InitSlots(n, ts) Yap_InitSlots__(n, ts PASS_REGS)
|
||||||
|
|
||||||
/// @brief create n new slots with terms ts[]
|
/// @brief create n new slots with terms ts[]
|
||||||
static inline yhandle_t Yap_InitSlots__(int n, Term *ts USES_REGS) {
|
INLINE_ONLY inline EXTERN yhandle_t Yap_InitSlots__(int n, Term *ts USES_REGS);
|
||||||
|
INLINE_ONLY inline EXTERN yhandle_t Yap_InitSlots__(int n, Term *ts USES_REGS) {
|
||||||
yhandle_t old_slots = LOCAL_CurSlot;
|
yhandle_t old_slots = LOCAL_CurSlot;
|
||||||
int i;
|
int i;
|
||||||
// fprintf(stderr,"1S %s:%d\n", __FUNCTION__, __LINE__);
|
|
||||||
|
|
||||||
ensure_slots(n PASS_REGS);
|
ensure_slots(n PASS_REGS);
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
LOCAL_SlotBase[old_slots + i] = ts[i];
|
LOCAL_SlotBase[old_slots + i] = ts[i];
|
||||||
@ -193,19 +217,23 @@ static inline yhandle_t Yap_InitSlots__(int n, Term *ts USES_REGS) {
|
|||||||
return old_slots;
|
return old_slots;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define Yap_RecoverSlots(n, ts) Yap_RecoverSlots__(n, ts PASS_REGS)
|
||||||
|
|
||||||
/// @brief Succeeds if it is to recover the space allocated for $n$ contiguos
|
/// @brief Succeeds if it is to recover the space allocated for $n$ contiguos
|
||||||
/// slots starting at topSlot.
|
/// slots starting at topSlot.
|
||||||
static inline bool Yap_RecoverSlots(int n, yhandle_t topSlot USES_REGS) {
|
static inline bool Yap_RecoverSlots__(int n, yhandle_t topSlot USES_REGS);
|
||||||
|
static inline bool Yap_RecoverSlots__(int n, yhandle_t topSlot USES_REGS) {
|
||||||
if (topSlot + n < LOCAL_CurSlot)
|
if (topSlot + n < LOCAL_CurSlot)
|
||||||
return false;
|
return false;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (n > LOCAL_CurSlot) {
|
if (n > LOCAL_CurSlot) {
|
||||||
Yap_Error(SYSTEM_ERROR_INTERNAL, 0 , "Inconsistent slot state in Yap_RecoverSlots.", 0);
|
Yap_Error(SYSTEM_ERROR_INTERNAL, 0,
|
||||||
|
"Inconsistent slot state in Yap_RecoverSlots.", 0);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
LOCAL_CurSlot -= n;
|
LOCAL_CurSlot -= n;
|
||||||
// fprintf(stderr,"RS %s:%d\n", __FUNCTION__, __LINE__);
|
//fprintf(stderr,"RS %ld %s:%d\n", LOCAL_CurSlot, __FILE__, __LINE__);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
68
H/YapHeap.h
@ -156,16 +156,46 @@ typedef struct thandle {
|
|||||||
/*******************
|
/*******************
|
||||||
this is the data base: everything here should be possible to restore
|
this is the data base: everything here should be possible to restore
|
||||||
********************/
|
********************/
|
||||||
|
#if YAPOR
|
||||||
typedef struct various_codes {
|
typedef struct various_codes {
|
||||||
/* memory allocation and management */
|
/* memory allocation and management */
|
||||||
special_functors funcs;
|
special_functors funcs;
|
||||||
|
|
||||||
#include "hstruct.h"
|
#include "heap/hstruct.h"
|
||||||
|
|
||||||
} all_heap_codes;
|
} all_heap_codes;
|
||||||
|
|
||||||
//#include "hglobals.h"
|
#include "heap/hglobals.h"
|
||||||
//#include "hlocals.h"
|
|
||||||
|
#include "heap/dhstruct.h"
|
||||||
|
#include "heap/dglobals.h"
|
||||||
|
#else
|
||||||
|
typedef struct various_codes {
|
||||||
|
/* memory allocation and management */
|
||||||
|
special_functors funcs;
|
||||||
|
|
||||||
|
#include "tatoms.h"
|
||||||
|
|
||||||
|
} all_heap_codes;
|
||||||
|
|
||||||
|
#if __INIT_C__
|
||||||
|
#define EXTERNAL
|
||||||
|
#else
|
||||||
|
#define EXTERNAL extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "heap/h0struct.h"
|
||||||
|
|
||||||
|
#include "heap/h0globals.h"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "heap/hlocals.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include "heap/dlocals.h"
|
||||||
|
|
||||||
|
|
||||||
/* ricardo
|
/* ricardo
|
||||||
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
|
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
|
||||||
@ -194,22 +224,14 @@ extern struct various_codes *Yap_heap_regs;
|
|||||||
#define Yap_heap_regs ((all_heap_codes *)HEAP_INIT_BASE)
|
#define Yap_heap_regs ((all_heap_codes *)HEAP_INIT_BASE)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "dhstruct.h"
|
|
||||||
//#include "dglobals.h"
|
|
||||||
//#include "dlocals.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gc-P: how to start-up the grbage collector in C-code
|
* gc-P: how to start-up the grbage collector in C-code
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static inline
|
static inline yamop *gc_P(yamop *p, yamop *cp) {
|
||||||
yamop *
|
return (p && p->opc == EXECUTE_CPRED_OPCODE ? cp : p);
|
||||||
gc_P(yamop *p, yamop *cp)
|
|
||||||
{
|
|
||||||
return (p->opc == EXECUTE_CPRED_OPCODE ? cp : p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Yap_CurrentModule: access the current module for looking
|
Yap_CurrentModule: access the current module for looking
|
||||||
up predicates
|
up predicates
|
||||||
@ -219,15 +241,12 @@ gc_P(yamop *p, yamop *cp)
|
|||||||
|
|
||||||
INLINE_ONLY inline EXTERN Term Yap_CurrentModule__(USES_REGS1);
|
INLINE_ONLY inline EXTERN Term Yap_CurrentModule__(USES_REGS1);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Term
|
INLINE_ONLY inline EXTERN Term Yap_CurrentModule__(USES_REGS1) {
|
||||||
Yap_CurrentModule__ (USES_REGS1)
|
if (CurrentModule)
|
||||||
{
|
return CurrentModule;
|
||||||
if (CurrentModule) return CurrentModule;
|
|
||||||
return TermProlog;
|
return TermProlog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************
|
/*******************
|
||||||
these are the global variables: they need not be restored...
|
these are the global variables: they need not be restored...
|
||||||
********************/
|
********************/
|
||||||
@ -236,14 +255,10 @@ Yap_CurrentModule__ (USES_REGS1)
|
|||||||
#define UPDATE_MODE_LOGICAL 1
|
#define UPDATE_MODE_LOGICAL 1
|
||||||
#define UPDATE_MODE_LOGICAL_ASSERT 2
|
#define UPDATE_MODE_LOGICAL_ASSERT 2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* initially allow for files with up to 1024 predicates. This number
|
/* initially allow for files with up to 1024 predicates. This number
|
||||||
is extended whenever needed */
|
is extended whenever needed */
|
||||||
#define InitialConsultCapacity 1024
|
#define InitialConsultCapacity 1024
|
||||||
|
|
||||||
|
|
||||||
#if (defined(USE_SYSTEM_MALLOC) && HAVE_MALLINFO) || USE_DL_MALLOC
|
#if (defined(USE_SYSTEM_MALLOC) && HAVE_MALLINFO) || USE_DL_MALLOC
|
||||||
UInt Yap_givemallinfo(void);
|
UInt Yap_givemallinfo(void);
|
||||||
#endif
|
#endif
|
||||||
@ -253,12 +268,9 @@ ADDR Yap_ExpandPreAllocCodeSpace(UInt, void *, int);
|
|||||||
ADDR Yap_InitPreAllocCodeSpace(int);
|
ADDR Yap_InitPreAllocCodeSpace(int);
|
||||||
|
|
||||||
#include "inline-only.h"
|
#include "inline-only.h"
|
||||||
INLINE_ONLY EXTERN inline ADDR
|
INLINE_ONLY EXTERN inline ADDR Yap_PreAllocCodeSpace(void);
|
||||||
Yap_PreAllocCodeSpace(void);
|
|
||||||
|
|
||||||
INLINE_ONLY EXTERN inline ADDR
|
INLINE_ONLY EXTERN inline ADDR Yap_PreAllocCodeSpace(void) {
|
||||||
Yap_PreAllocCodeSpace(void)
|
|
||||||
{
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
return AuxBase;
|
return AuxBase;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
YAP_FLAG( AUTOLOAD_FLAG, "autoload", true, boolean, "false" , NULL ),
|
YAP_FLAG( AUTOLOAD_FLAG, "autoload", true, boolean, "false" , NULL ),
|
||||||
YAP_FLAG( BREAK_LEVEL_FLAG, "break_level", true, nat, "0" , NULL ),
|
YAP_FLAG( BREAK_LEVEL_FLAG, "break_level", true, nat, "0" , NULL ),
|
||||||
YAP_FLAG( ENCODING_FLAG, "encoding", true, isatom, "text" , getenc ),
|
YAP_FLAG( ENCODING_FLAG, "encoding", true, isatom, "utf-8" , getenc ),
|
||||||
YAP_FLAG( FILEERRORS_FLAG, "fileerrors", true, boolean, "true" , NULL ), /**< `fileerrors`
|
YAP_FLAG( FILEERRORS_FLAG, "fileerrors", true, boolean, "true" , NULL ), /**< `fileerrors`
|
||||||
|
|
||||||
If `on` `fileerrors` is `on`, if `off` (default)
|
If `on` `fileerrors` is `on`, if `off` (default)
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Yap.h"
|
#include "Yap.h"
|
||||||
#include "utf8proc.h"
|
#include "../utf8proc/utf8proc.h"
|
||||||
|
|
||||||
/* Character types for tokenizer and write.c */
|
/* Character types for tokenizer and write.c */
|
||||||
|
|
||||||
@ -483,8 +483,7 @@ static inline Term Yap_AtomToNumber(Term t0 USES_REGS) {
|
|||||||
inp.val.t = t0;
|
inp.val.t = t0;
|
||||||
inp.type = YAP_STRING_ATOM;
|
inp.type = YAP_STRING_ATOM;
|
||||||
out.val.uc = NULL;
|
out.val.uc = NULL;
|
||||||
out.type =
|
out.type = YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG;
|
||||||
YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG;
|
|
||||||
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
||||||
return 0L;
|
return 0L;
|
||||||
return out.val.t;
|
return out.val.t;
|
||||||
@ -1216,8 +1215,6 @@ static inline Term Yap_UTF8ToString(const char *s USES_REGS) {
|
|||||||
return MkStringTerm(s);
|
return MkStringTerm(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static inline Term Yap_WCharsToListOfCodes(const wchar_t *s USES_REGS) {
|
static inline Term Yap_WCharsToListOfCodes(const wchar_t *s USES_REGS) {
|
||||||
seq_tv_t inp, out;
|
seq_tv_t inp, out;
|
||||||
inp.val.w0 = s;
|
inp.val.w0 = s;
|
||||||
|
@ -124,7 +124,7 @@ Atom Yap_ConsultingFile(USES_REGS1);
|
|||||||
struct pred_entry *Yap_PredForChoicePt(choiceptr bptr, op_numbers *op);
|
struct pred_entry *Yap_PredForChoicePt(choiceptr bptr, op_numbers *op);
|
||||||
void Yap_InitCdMgr(void);
|
void Yap_InitCdMgr(void);
|
||||||
struct pred_entry *Yap_PredFromClause(Term t USES_REGS);
|
struct pred_entry *Yap_PredFromClause(Term t USES_REGS);
|
||||||
bool Yap_discontiguous(struct pred_entry *ap USES_REGS);
|
bool Yap_discontiguous(struct pred_entry *ap, Term mode USES_REGS);
|
||||||
bool Yap_multiple(struct pred_entry *ap, int mode USES_REGS);
|
bool Yap_multiple(struct pred_entry *ap, int mode USES_REGS);
|
||||||
void Yap_init_consult(int, const char *);
|
void Yap_init_consult(int, const char *);
|
||||||
void Yap_end_consult(void);
|
void Yap_end_consult(void);
|
||||||
@ -135,6 +135,8 @@ void Yap_ResetConsultStack(void);
|
|||||||
void Yap_AssertzClause(struct pred_entry *, yamop *);
|
void Yap_AssertzClause(struct pred_entry *, yamop *);
|
||||||
void Yap_HidePred(struct pred_entry *pe);
|
void Yap_HidePred(struct pred_entry *pe);
|
||||||
int Yap_SetNoTrace(char *name, UInt arity, Term tmod);
|
int Yap_SetNoTrace(char *name, UInt arity, Term tmod);
|
||||||
|
bool Yap_unknown(Term tflagvalue);
|
||||||
|
struct pred_entry *Yap_MkLogPred(struct pred_entry *pe);
|
||||||
|
|
||||||
/* cmppreds.c */
|
/* cmppreds.c */
|
||||||
Int Yap_compare_terms(Term, Term);
|
Int Yap_compare_terms(Term, Term);
|
||||||
@ -176,6 +178,7 @@ bool Yap_Warning(const char *s, ...);
|
|||||||
bool Yap_PrintWarning(Term t);
|
bool Yap_PrintWarning(Term t);
|
||||||
int Yap_HandleError(const char *msg, ...);
|
int Yap_HandleError(const char *msg, ...);
|
||||||
int Yap_SWIHandleError(const char *, ...);
|
int Yap_SWIHandleError(const char *, ...);
|
||||||
|
void Yap_InitErrorPreds(void);
|
||||||
|
|
||||||
/* eval.c */
|
/* eval.c */
|
||||||
void Yap_InitEval(void);
|
void Yap_InitEval(void);
|
||||||
@ -251,7 +254,7 @@ void Yap_CopyThreadStacks(int, int, int);
|
|||||||
/* heapgc.c */
|
/* heapgc.c */
|
||||||
Int Yap_total_gc_time(void);
|
Int Yap_total_gc_time(void);
|
||||||
void Yap_init_gc(void);
|
void Yap_init_gc(void);
|
||||||
int Yap_is_gc_verbose(void);
|
bool Yap_is_gc_verbose(void);
|
||||||
int Yap_gc(Int, CELL *, yamop *);
|
int Yap_gc(Int, CELL *, yamop *);
|
||||||
int Yap_locked_gc(Int, CELL *, yamop *);
|
int Yap_locked_gc(Int, CELL *, yamop *);
|
||||||
int Yap_gcl(UInt, Int, CELL *, yamop *);
|
int Yap_gcl(UInt, Int, CELL *, yamop *);
|
||||||
@ -317,6 +320,8 @@ void Yap_InitModulesC(void);
|
|||||||
struct mod_entry *Yap_GetModuleEntry(Term tmod);
|
struct mod_entry *Yap_GetModuleEntry(Term tmod);
|
||||||
Term Yap_GetModuleFromEntry(struct mod_entry *me);
|
Term Yap_GetModuleFromEntry(struct mod_entry *me);
|
||||||
bool Yap_CharacterEscapes(Term mt);
|
bool Yap_CharacterEscapes(Term mt);
|
||||||
|
bool Yap_constPred(struct pred_entry *pt);
|
||||||
|
bool Yap_isSystemModule(Term mod);
|
||||||
|
|
||||||
#if HAVE_MPI
|
#if HAVE_MPI
|
||||||
/* mpi.c */
|
/* mpi.c */
|
||||||
|
125
H/clause.h
@ -92,9 +92,8 @@ typedef struct logic_upd_clause {
|
|||||||
#include "inline-only.h"
|
#include "inline-only.h"
|
||||||
INLINE_ONLY inline EXTERN int VALID_TIMESTAMP(UInt, struct logic_upd_clause *);
|
INLINE_ONLY inline EXTERN int VALID_TIMESTAMP(UInt, struct logic_upd_clause *);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int
|
INLINE_ONLY inline EXTERN int VALID_TIMESTAMP(UInt timestamp,
|
||||||
VALID_TIMESTAMP(UInt timestamp, struct logic_upd_clause *cl)
|
struct logic_upd_clause *cl) {
|
||||||
{
|
|
||||||
return IN_BETWEEN(cl->ClTimeStart, timestamp, cl->ClTimeEnd);
|
return IN_BETWEEN(cl->ClTimeStart, timestamp, cl->ClTimeEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,37 +190,37 @@ typedef struct index_t {
|
|||||||
UInt udi_arg;
|
UInt udi_arg;
|
||||||
} Index_t;
|
} Index_t;
|
||||||
|
|
||||||
INLINE_ONLY EXTERN inline BITS32 EXO_ADDRESS_TO_OFFSET(struct index_t *it, CELL *ptr);
|
INLINE_ONLY EXTERN inline BITS32 EXO_ADDRESS_TO_OFFSET(struct index_t *it,
|
||||||
|
CELL *ptr);
|
||||||
|
|
||||||
INLINE_ONLY EXTERN inline BITS32
|
INLINE_ONLY EXTERN inline BITS32 EXO_ADDRESS_TO_OFFSET(struct index_t *it,
|
||||||
EXO_ADDRESS_TO_OFFSET(struct index_t *it, CELL* ptr)
|
CELL *ptr) {
|
||||||
{
|
|
||||||
return (ptr - it->cls) / it->arity + 1;
|
return (ptr - it->cls) / it->arity + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY EXTERN inline CELL *EXO_OFFSET_TO_ADDRESS(struct index_t *it, BITS32 off);
|
INLINE_ONLY EXTERN inline CELL *EXO_OFFSET_TO_ADDRESS(struct index_t *it,
|
||||||
|
BITS32 off);
|
||||||
|
|
||||||
INLINE_ONLY EXTERN inline CELL *
|
INLINE_ONLY EXTERN inline CELL *EXO_OFFSET_TO_ADDRESS(struct index_t *it,
|
||||||
EXO_OFFSET_TO_ADDRESS(struct index_t *it, BITS32 off)
|
BITS32 off) {
|
||||||
{
|
|
||||||
if (off == 0L)
|
if (off == 0L)
|
||||||
return (CELL *)NULL;
|
return (CELL *)NULL;
|
||||||
return (it->cls) + (off - 1) * it->arity;
|
return (it->cls) + (off - 1) * it->arity;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY EXTERN inline BITS32 ADDRESS_TO_LINK(struct index_t *it, BITS32 *ptr);
|
INLINE_ONLY EXTERN inline BITS32 ADDRESS_TO_LINK(struct index_t *it,
|
||||||
|
BITS32 *ptr);
|
||||||
|
|
||||||
INLINE_ONLY EXTERN inline BITS32
|
INLINE_ONLY EXTERN inline BITS32 ADDRESS_TO_LINK(struct index_t *it,
|
||||||
ADDRESS_TO_LINK(struct index_t *it, BITS32* ptr)
|
BITS32 *ptr) {
|
||||||
{
|
|
||||||
return ptr - it->links;
|
return ptr - it->links;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY EXTERN inline BITS32 *LINK_TO_ADDRESS(struct index_t *it, BITS32 off);
|
INLINE_ONLY EXTERN inline BITS32 *LINK_TO_ADDRESS(struct index_t *it,
|
||||||
|
BITS32 off);
|
||||||
|
|
||||||
INLINE_ONLY EXTERN inline BITS32 *
|
INLINE_ONLY EXTERN inline BITS32 *LINK_TO_ADDRESS(struct index_t *it,
|
||||||
LINK_TO_ADDRESS(struct index_t *it, BITS32 off)
|
BITS32 off) {
|
||||||
{
|
|
||||||
return it->links + off;
|
return it->links + off;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,16 +236,24 @@ typedef struct dbterm_list {
|
|||||||
struct dbterm_list *next_dbl;
|
struct dbterm_list *next_dbl;
|
||||||
} DBTermList;
|
} DBTermList;
|
||||||
|
|
||||||
#define ClauseCodeToDynamicClause(p) ((DynamicClause *)((CODEADDR)(p)-(CELL)(((DynamicClause *)NULL)->ClCode)))
|
#define ClauseCodeToDynamicClause(p) \
|
||||||
#define ClauseCodeToStaticClause(p) ((StaticClause *)((CODEADDR)(p)-(CELL)(((StaticClause *)NULL)->ClCode)))
|
((DynamicClause *)((CODEADDR)(p) - (CELL)(((DynamicClause *)NULL)->ClCode)))
|
||||||
#define ClauseCodeToLogUpdClause(p) ((LogUpdClause *)((CODEADDR)(p)-(CELL)(((LogUpdClause *)NULL)->ClCode)))
|
#define ClauseCodeToStaticClause(p) \
|
||||||
#define ClauseCodeToMegaClause(p) ((MegaClause *)((CODEADDR)(p)-(CELL)(((MegaClause *)NULL)->ClCode)))
|
((StaticClause *)((CODEADDR)(p) - (CELL)(((StaticClause *)NULL)->ClCode)))
|
||||||
#define ClauseCodeToLogUpdIndex(p) ((LogUpdIndex *)((CODEADDR)(p)-(CELL)(((LogUpdIndex *)NULL)->ClCode)))
|
#define ClauseCodeToLogUpdClause(p) \
|
||||||
#define ClauseCodeToStaticIndex(p) ((StaticIndex *)((CODEADDR)(p)-(CELL)(((StaticIndex *)NULL)->ClCode)))
|
((LogUpdClause *)((CODEADDR)(p) - (CELL)(((LogUpdClause *)NULL)->ClCode)))
|
||||||
|
#define ClauseCodeToMegaClause(p) \
|
||||||
|
((MegaClause *)((CODEADDR)(p) - (CELL)(((MegaClause *)NULL)->ClCode)))
|
||||||
|
#define ClauseCodeToLogUpdIndex(p) \
|
||||||
|
((LogUpdIndex *)((CODEADDR)(p) - (CELL)(((LogUpdIndex *)NULL)->ClCode)))
|
||||||
|
#define ClauseCodeToStaticIndex(p) \
|
||||||
|
((StaticIndex *)((CODEADDR)(p) - (CELL)(((StaticIndex *)NULL)->ClCode)))
|
||||||
|
|
||||||
#define ClauseFlagsToDynamicClause(p) ((DynamicClause *)(p))
|
#define ClauseFlagsToDynamicClause(p) ((DynamicClause *)(p))
|
||||||
#define ClauseFlagsToLogUpdClause(p) ((LogUpdClause *)((CODEADDR)(p)-(CELL)(&(((LogUpdClause *)NULL)->ClFlags))))
|
#define ClauseFlagsToLogUpdClause(p) \
|
||||||
#define ClauseFlagsToLogUpdIndex(p) ((LogUpdIndex *)((CODEADDR)(p)-(CELL)(&(((LogUpdIndex *)NULL)->ClFlags))))
|
((LogUpdClause *)((CODEADDR)(p) - (CELL)(&(((LogUpdClause *)NULL)->ClFlags))))
|
||||||
|
#define ClauseFlagsToLogUpdIndex(p) \
|
||||||
|
((LogUpdIndex *)((CODEADDR)(p) - (CELL)(&(((LogUpdIndex *)NULL)->ClFlags))))
|
||||||
#define ClauseFlagsToStaticClause(p) ((StaticClause *)(p))
|
#define ClauseFlagsToStaticClause(p) ((StaticClause *)(p))
|
||||||
|
|
||||||
#define DynamicFlags(X) (ClauseCodeToDynamicClause(X)->ClFlags)
|
#define DynamicFlags(X) (ClauseCodeToDynamicClause(X)->ClFlags)
|
||||||
@ -273,7 +280,7 @@ void Yap_InitComma(void);
|
|||||||
|
|
||||||
/* cdmgr.c */
|
/* cdmgr.c */
|
||||||
void Yap_IPred(PredEntry *, UInt, yamop *);
|
void Yap_IPred(PredEntry *, UInt, yamop *);
|
||||||
int Yap_addclause(Term,yamop *,int,Term,Term*);
|
bool Yap_addclause(Term, yamop *, int, Term, Term *);
|
||||||
void Yap_add_logupd_clause(PredEntry *, LogUpdClause *, int);
|
void Yap_add_logupd_clause(PredEntry *, LogUpdClause *, int);
|
||||||
void Yap_kill_iblock(ClauseUnion *, ClauseUnion *, PredEntry *);
|
void Yap_kill_iblock(ClauseUnion *, ClauseUnion *, PredEntry *);
|
||||||
void Yap_EraseStaticClause(StaticClause *, PredEntry *, Term);
|
void Yap_EraseStaticClause(StaticClause *, PredEntry *, Term);
|
||||||
@ -298,7 +305,8 @@ void Yap_CleanKids(struct logic_upd_index *);
|
|||||||
void Yap_AddClauseToIndex(PredEntry *, yamop *, int);
|
void Yap_AddClauseToIndex(PredEntry *, yamop *, int);
|
||||||
void Yap_RemoveClauseFromIndex(PredEntry *, yamop *);
|
void Yap_RemoveClauseFromIndex(PredEntry *, yamop *);
|
||||||
LogUpdClause *Yap_NthClause(PredEntry *, Int);
|
LogUpdClause *Yap_NthClause(PredEntry *, Int);
|
||||||
LogUpdClause *Yap_FollowIndexingCode(PredEntry *,yamop *, Term *, yamop *,yamop *);
|
LogUpdClause *Yap_FollowIndexingCode(PredEntry *, yamop *, Term *, yamop *,
|
||||||
|
yamop *);
|
||||||
|
|
||||||
/* exo.c */
|
/* exo.c */
|
||||||
yamop *Yap_ExoLookup(PredEntry *ap USES_REGS);
|
yamop *Yap_ExoLookup(PredEntry *ap USES_REGS);
|
||||||
@ -311,8 +319,7 @@ CELL Yap_NextExo(choiceptr cpt, struct index_t *it);
|
|||||||
|
|
||||||
INLINE_ONLY inline EXTERN int rtable_hash_op(OPCODE opc, int hash_mask);
|
INLINE_ONLY inline EXTERN int rtable_hash_op(OPCODE opc, int hash_mask);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN int
|
INLINE_ONLY inline EXTERN int rtable_hash_op(OPCODE opc, int hash_mask) {
|
||||||
rtable_hash_op(OPCODE opc, int hash_mask) {
|
|
||||||
return ((((CELL)opc) >> 3) & hash_mask);
|
return ((((CELL)opc) >> 3) & hash_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,9 +327,7 @@ INLINE_ONLY inline EXTERN op_numbers Yap_op_from_opcode(OPCODE opc);
|
|||||||
|
|
||||||
/* given an opcode find the corresponding opnumber. This should make
|
/* given an opcode find the corresponding opnumber. This should make
|
||||||
switches on ops a much easier operation */
|
switches on ops a much easier operation */
|
||||||
INLINE_ONLY inline EXTERN op_numbers
|
INLINE_ONLY inline EXTERN op_numbers Yap_op_from_opcode(OPCODE opc) {
|
||||||
Yap_op_from_opcode(OPCODE opc)
|
|
||||||
{
|
|
||||||
int j = rtable_hash_op(opc, OP_HASH_SIZE - 1);
|
int j = rtable_hash_op(opc, OP_HASH_SIZE - 1);
|
||||||
|
|
||||||
while (OP_RTABLE[j].opc != opc) {
|
while (OP_RTABLE[j].opc != opc) {
|
||||||
@ -337,9 +342,7 @@ Yap_op_from_opcode(OPCODE opc)
|
|||||||
return OP_RTABLE[j].opnum;
|
return OP_RTABLE[j].opnum;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static inline op_numbers
|
static inline op_numbers Yap_op_from_opcode(OPCODE opc) {
|
||||||
Yap_op_from_opcode(OPCODE opc)
|
|
||||||
{
|
|
||||||
return ((op_numbers)opc);
|
return ((op_numbers)opc);
|
||||||
}
|
}
|
||||||
#endif /* USE_THREADED_CODE */
|
#endif /* USE_THREADED_CODE */
|
||||||
@ -347,16 +350,15 @@ Yap_op_from_opcode(OPCODE opc)
|
|||||||
#if defined(YAPOR) || defined(THREADS)
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
static inline int same_lu_block(yamop **, yamop *);
|
static inline int same_lu_block(yamop **, yamop *);
|
||||||
|
|
||||||
static inline int
|
static inline int same_lu_block(yamop **paddr, yamop *p) {
|
||||||
same_lu_block(yamop **paddr, yamop *p)
|
|
||||||
{
|
|
||||||
yamop *np = *paddr;
|
yamop *np = *paddr;
|
||||||
if (np != p) {
|
if (np != p) {
|
||||||
OPCODE jmp_op = Yap_opcode(_jump_if_nonvar);
|
OPCODE jmp_op = Yap_opcode(_jump_if_nonvar);
|
||||||
|
|
||||||
while (np->opc == jmp_op) {
|
while (np->opc == jmp_op) {
|
||||||
np = NEXTOP(np, xll);
|
np = NEXTOP(np, xll);
|
||||||
if (np == p) return TRUE;
|
if (np == p)
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else {
|
} else {
|
||||||
@ -367,64 +369,49 @@ same_lu_block(yamop **paddr, yamop *p)
|
|||||||
|
|
||||||
#define Yap_MkStaticRefTerm(cp, ap) __Yap_MkStaticRefTerm((cp), (ap)PASS_REGS)
|
#define Yap_MkStaticRefTerm(cp, ap) __Yap_MkStaticRefTerm((cp), (ap)PASS_REGS)
|
||||||
|
|
||||||
static inline Term
|
static inline Term __Yap_MkStaticRefTerm(StaticClause *cp,
|
||||||
__Yap_MkStaticRefTerm(StaticClause *cp, PredEntry *ap USES_REGS)
|
PredEntry *ap USES_REGS) {
|
||||||
{
|
|
||||||
Term t[2];
|
Term t[2];
|
||||||
t[0] = MkIntegerTerm((Int)cp);
|
t[0] = MkIntegerTerm((Int)cp);
|
||||||
t[1] = MkIntegerTerm((Int)ap);
|
t[1] = MkIntegerTerm((Int)ap);
|
||||||
return Yap_MkApplTerm(FunctorStaticClause, 2, t);
|
return Yap_MkApplTerm(FunctorStaticClause, 2, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline StaticClause *
|
static inline StaticClause *Yap_ClauseFromTerm(Term t) {
|
||||||
Yap_ClauseFromTerm(Term t)
|
|
||||||
{
|
|
||||||
return (StaticClause *)IntegerOfTerm(ArgOfTerm(1, t));
|
return (StaticClause *)IntegerOfTerm(ArgOfTerm(1, t));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define Yap_MkMegaRefTerm(ap, ipc) __Yap_MkMegaRefTerm((ap), (ipc)PASS_REGS)
|
#define Yap_MkMegaRefTerm(ap, ipc) __Yap_MkMegaRefTerm((ap), (ipc)PASS_REGS)
|
||||||
|
|
||||||
static inline Term
|
static inline Term __Yap_MkMegaRefTerm(PredEntry *ap, yamop *ipc USES_REGS) {
|
||||||
__Yap_MkMegaRefTerm(PredEntry *ap,yamop *ipc USES_REGS)
|
|
||||||
{
|
|
||||||
Term t[2];
|
Term t[2];
|
||||||
t[0] = MkIntegerTerm((Int)ap);
|
t[0] = MkIntegerTerm((Int)ap);
|
||||||
t[1] = MkIntegerTerm((Int)ipc);
|
t[1] = MkIntegerTerm((Int)ipc);
|
||||||
return Yap_MkApplTerm(FunctorMegaClause, 2, t);
|
return Yap_MkApplTerm(FunctorMegaClause, 2, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline yamop *
|
static inline yamop *Yap_MegaClauseFromTerm(Term t) {
|
||||||
Yap_MegaClauseFromTerm(Term t)
|
|
||||||
{
|
|
||||||
return (yamop *)IntegerOfTerm(ArgOfTerm(2, t));
|
return (yamop *)IntegerOfTerm(ArgOfTerm(2, t));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline PredEntry *
|
static inline PredEntry *Yap_MegaClausePredicateFromTerm(Term t) {
|
||||||
Yap_MegaClausePredicateFromTerm(Term t)
|
|
||||||
{
|
|
||||||
return (PredEntry *)IntegerOfTerm(ArgOfTerm(1, t));
|
return (PredEntry *)IntegerOfTerm(ArgOfTerm(1, t));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define Yap_MkExoRefTerm(ap, i) __Yap_MkExoRefTerm((ap), (i)PASS_REGS)
|
#define Yap_MkExoRefTerm(ap, i) __Yap_MkExoRefTerm((ap), (i)PASS_REGS)
|
||||||
|
|
||||||
static inline Term
|
static inline Term __Yap_MkExoRefTerm(PredEntry *ap, Int i USES_REGS) {
|
||||||
__Yap_MkExoRefTerm(PredEntry *ap,Int i USES_REGS)
|
|
||||||
{
|
|
||||||
Term t[2];
|
Term t[2];
|
||||||
t[0] = MkIntegerTerm((Int)ap);
|
t[0] = MkIntegerTerm((Int)ap);
|
||||||
t[1] = MkIntegerTerm((Int)i);
|
t[1] = MkIntegerTerm((Int)i);
|
||||||
return Yap_MkApplTerm(FunctorExoClause, 2, t);
|
return Yap_MkApplTerm(FunctorExoClause, 2, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Int
|
static inline Int Yap_ExoClauseFromTerm(Term t) {
|
||||||
Yap_ExoClauseFromTerm(Term t)
|
|
||||||
{
|
|
||||||
return IntegerOfTerm(ArgOfTerm(2, t));
|
return IntegerOfTerm(ArgOfTerm(2, t));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline PredEntry *
|
static inline PredEntry *Yap_ExoClausePredicateFromTerm(Term t) {
|
||||||
Yap_ExoClausePredicateFromTerm(Term t)
|
|
||||||
{
|
|
||||||
return (PredEntry *)IntegerOfTerm(ArgOfTerm(1, t));
|
return (PredEntry *)IntegerOfTerm(ArgOfTerm(1, t));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -434,12 +421,10 @@ Yap_ExoClausePredicateFromTerm(Term t)
|
|||||||
|
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
|
|
||||||
bool
|
bool Yap_search_for_static_predicate_in_use(PredEntry *p,
|
||||||
Yap_search_for_static_predicate_in_use(PredEntry *p, bool check_everything);
|
bool check_everything);
|
||||||
|
|
||||||
static inline bool
|
static inline bool Yap_static_in_use(PredEntry *p, bool check_everything) {
|
||||||
Yap_static_in_use(PredEntry *p, bool check_everything)
|
|
||||||
{
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
#else
|
#else
|
||||||
|
303
H/dhstruct.h
@ -1,303 +0,0 @@
|
|||||||
|
|
||||||
/* This file, dhstruct.h, was generated automatically by "yap -L misc/buildheap"
|
|
||||||
please do not update, update misc/HEAPFIELDS instead */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define Yap_HoleSize Yap_heap_regs->hole_size
|
|
||||||
#define Yap_av Yap_heap_regs->av_
|
|
||||||
#if USE_DL_MALLOC
|
|
||||||
#define Yap_MemoryHoles Yap_heap_regs->memory_holes
|
|
||||||
#define Yap_NOfMemoryHoles Yap_heap_regs->nof_memory_holes
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
#define DLMallocLock Yap_heap_regs->dlmalloc_lock
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if USE_DL_MALLOC || (USE_SYSTEM_MALLOC && HAVE_MALLINFO)
|
|
||||||
#ifndef HeapUsed
|
|
||||||
#define HeapUsed Yap_givemallinfo()
|
|
||||||
#endif
|
|
||||||
#define NotHeapUsed Yap_heap_regs->heap_used
|
|
||||||
#else
|
|
||||||
#define HeapUsed Yap_heap_regs->heap_used
|
|
||||||
#endif
|
|
||||||
#define HeapMax Yap_heap_regs->heap_max
|
|
||||||
#define HeapTop Yap_heap_regs->heap_top
|
|
||||||
#define HeapLim Yap_heap_regs->heap_lim
|
|
||||||
#define FreeBlocks Yap_heap_regs->free_blocks
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
#define FreeBlocksLock Yap_heap_regs->free_blocks_lock
|
|
||||||
#define HeapUsedLock Yap_heap_regs->heap_used_lock
|
|
||||||
#define HeapTopLock Yap_heap_regs->heap_top_lock
|
|
||||||
#define HeapTopOwner Yap_heap_regs->heap_top_owner
|
|
||||||
#endif
|
|
||||||
#define MaxStack Yap_heap_regs->MaxStack_
|
|
||||||
#define MaxTrail Yap_heap_regs->MaxTrail_
|
|
||||||
|
|
||||||
|
|
||||||
#if USE_THREADED_CODE
|
|
||||||
#define OP_RTABLE Yap_heap_regs->op_rtable
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define EXECUTE_CPRED_OP_CODE Yap_heap_regs->execute_cpred_op_code
|
|
||||||
#define EXPAND_OP_CODE Yap_heap_regs->expand_op_code
|
|
||||||
#define FAIL_OPCODE Yap_heap_regs->fail_op
|
|
||||||
#define INDEX_OPCODE Yap_heap_regs->index_op
|
|
||||||
#define LOCKPRED_OPCODE Yap_heap_regs->lockpred_op
|
|
||||||
#define ORLAST_OPCODE Yap_heap_regs->orlast_op
|
|
||||||
#define UNDEF_OPCODE Yap_heap_regs->undef_op
|
|
||||||
#define RETRY_USERC_OPCODE Yap_heap_regs->retry_userc_op
|
|
||||||
#define EXECUTE_CPRED_OPCODE Yap_heap_regs->execute_cpred_op
|
|
||||||
|
|
||||||
#define NOfAtoms Yap_heap_regs->n_of_atoms
|
|
||||||
#define AtomHashTableSize Yap_heap_regs->atom_hash_table_size
|
|
||||||
#define WideAtomHashTableSize Yap_heap_regs->wide_atom_hash_table_size
|
|
||||||
#define NOfWideAtoms Yap_heap_regs->n_of_wide_atoms
|
|
||||||
#define INVISIBLECHAIN Yap_heap_regs->invisiblechain
|
|
||||||
#define WideHashChain Yap_heap_regs->wide_hash_chain
|
|
||||||
#define HashChain Yap_heap_regs->hash_chain
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef EUROTRA
|
|
||||||
#define TermDollarU Yap_heap_regs->term_dollar_u
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define USER_MODULE Yap_heap_regs->user_module
|
|
||||||
#define IDB_MODULE Yap_heap_regs->idb_module
|
|
||||||
#define ATTRIBUTES_MODULE Yap_heap_regs->attributes_module
|
|
||||||
#define CHARSIO_MODULE Yap_heap_regs->charsio_module
|
|
||||||
#define CHTYPE_MODULE Yap_heap_regs->chtype_module
|
|
||||||
#define TERMS_MODULE Yap_heap_regs->terms_module
|
|
||||||
#define SYSTEM_MODULE Yap_heap_regs->system_module
|
|
||||||
#define READUTIL_MODULE Yap_heap_regs->readutil_module
|
|
||||||
#define HACKS_MODULE Yap_heap_regs->hacks_module
|
|
||||||
#define ARG_MODULE Yap_heap_regs->arg_module
|
|
||||||
#define GLOBALS_MODULE Yap_heap_regs->globals_module
|
|
||||||
#define SWI_MODULE Yap_heap_regs->swi_module
|
|
||||||
#define DBLOAD_MODULE Yap_heap_regs->dbload_module
|
|
||||||
#define RANGE_MODULE Yap_heap_regs->range_module
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define CurrentModules Yap_heap_regs->current_modules
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define HIDDEN_PREDICATES Yap_heap_regs->hidden_predicates
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define GLOBAL_Flags Yap_heap_regs->GLOBAL_Flags_
|
|
||||||
#define GLOBAL_flagCount Yap_heap_regs->GLOBAL_flagCount_
|
|
||||||
|
|
||||||
#define Yap_ExecutionMode Yap_heap_regs->execution_mode
|
|
||||||
|
|
||||||
#define PredHash Yap_heap_regs->pred_hash
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
#define PredHashRWLock Yap_heap_regs->pred_hash_rw_lock
|
|
||||||
#endif
|
|
||||||
#define PredsInHashTable Yap_heap_regs->preds_in_hash_table
|
|
||||||
#define PredHashTableSize Yap_heap_regs->pred_hash_table_size
|
|
||||||
|
|
||||||
#define CreepCode Yap_heap_regs->creep_code
|
|
||||||
#define UndefCode Yap_heap_regs->undef_code
|
|
||||||
#define SpyCode Yap_heap_regs->spy_code
|
|
||||||
#define PredFail Yap_heap_regs->pred_fail
|
|
||||||
#define PredTrue Yap_heap_regs->pred_true
|
|
||||||
#ifdef COROUTINING
|
|
||||||
#define WakeUpCode Yap_heap_regs->wake_up_code
|
|
||||||
#endif
|
|
||||||
#define PredGoalExpansion Yap_heap_regs->pred_goal_expansion
|
|
||||||
#define PredMetaCall Yap_heap_regs->pred_meta_call
|
|
||||||
#define PredTraceMetaCall Yap_heap_regs->pred_trace_meta_call
|
|
||||||
#define PredDollarCatch Yap_heap_regs->pred_dollar_catch
|
|
||||||
#define PredRecordedWithKey Yap_heap_regs->pred_recorded_with_key
|
|
||||||
#define PredLogUpdClause Yap_heap_regs->pred_log_upd_clause
|
|
||||||
#define PredLogUpdClauseErase Yap_heap_regs->pred_log_upd_clause_erase
|
|
||||||
#define PredLogUpdClause0 Yap_heap_regs->pred_log_upd_clause0
|
|
||||||
#define PredStaticClause Yap_heap_regs->pred_static_clause
|
|
||||||
#define PredThrow Yap_heap_regs->pred_throw
|
|
||||||
#define PredHandleThrow Yap_heap_regs->pred_handle_throw
|
|
||||||
#define PredIs Yap_heap_regs->pred_is
|
|
||||||
#define PredSafeCallCleanup Yap_heap_regs->pred_safe_call_cleanup
|
|
||||||
#define PredRestoreRegs Yap_heap_regs->pred_restore_regs
|
|
||||||
#define PredCommentHook Yap_heap_regs->pred_comment_hook
|
|
||||||
#ifdef YAPOR
|
|
||||||
#define PredGetwork Yap_heap_regs->pred_getwork
|
|
||||||
#define PredGetworkSeq Yap_heap_regs->pred_getwork_seq
|
|
||||||
#endif /* YAPOR */
|
|
||||||
|
|
||||||
#ifdef LOW_LEVEL_TRACER
|
|
||||||
#define Yap_do_low_level_trace Yap_heap_regs->yap_do_low_level_trace
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
#define Yap_low_level_trace_lock Yap_heap_regs->low_level_trace_lock
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define Yap_ClauseSpace Yap_heap_regs->clause_space
|
|
||||||
#define Yap_IndexSpace_Tree Yap_heap_regs->index_space_Tree
|
|
||||||
#define Yap_IndexSpace_EXT Yap_heap_regs->index_space_EXT
|
|
||||||
#define Yap_IndexSpace_SW Yap_heap_regs->index_space_SW
|
|
||||||
#define Yap_LUClauseSpace Yap_heap_regs->lu_clause_space
|
|
||||||
#define Yap_LUIndexSpace_Tree Yap_heap_regs->lu_index_space_Tree
|
|
||||||
#define Yap_LUIndexSpace_CP Yap_heap_regs->lu_index_space_CP
|
|
||||||
#define Yap_LUIndexSpace_EXT Yap_heap_regs->lu_index_space_EXT
|
|
||||||
#define Yap_LUIndexSpace_SW Yap_heap_regs->lu_index_space_SW
|
|
||||||
|
|
||||||
#define COMMA_CODE Yap_heap_regs->comma_code
|
|
||||||
#define DUMMYCODE Yap_heap_regs->dummycode
|
|
||||||
#define FAILCODE Yap_heap_regs->failcode
|
|
||||||
#define NOCODE Yap_heap_regs->nocode
|
|
||||||
#define ENV_FOR_TRUSTFAIL Yap_heap_regs->env_for_trustfail
|
|
||||||
#define TRUSTFAILCODE Yap_heap_regs->trustfailcode
|
|
||||||
#define ENV_FOR_YESCODE Yap_heap_regs->env_for_yescode
|
|
||||||
#define YESCODE Yap_heap_regs->yescode
|
|
||||||
#define RTRYCODE Yap_heap_regs->rtrycode
|
|
||||||
#ifdef BEAM
|
|
||||||
#define BEAM_RETRY_CODE Yap_heap_regs->beam_retry_code
|
|
||||||
#endif /* BEAM */
|
|
||||||
#ifdef YAPOR
|
|
||||||
#define GETWORK Yap_heap_regs->getwork_code
|
|
||||||
#define GETWORK_SEQ Yap_heap_regs->getwork_seq_code
|
|
||||||
#define GETWORK_FIRST_TIME Yap_heap_regs->getwork_first_time
|
|
||||||
#endif /* YAPOR */
|
|
||||||
#ifdef TABLING
|
|
||||||
#define LOAD_ANSWER Yap_heap_regs->table_load_answer_code
|
|
||||||
#define TRY_ANSWER Yap_heap_regs->table_try_answer_code
|
|
||||||
#define ANSWER_RESOLUTION Yap_heap_regs->table_answer_resolution_code
|
|
||||||
#define COMPLETION Yap_heap_regs->table_completion_code
|
|
||||||
#ifdef THREADS_CONSUMER_SHARING
|
|
||||||
#define ANSWER_RESOLUTION_COMPLETION Yap_heap_regs->table_answer_resolution_completion_code
|
|
||||||
#endif /* THREADS_CONSUMER_SHARING */
|
|
||||||
#endif /* TABLING */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define P_before_spy Yap_heap_regs->debugger_p_before_spy
|
|
||||||
|
|
||||||
#define RETRY_C_RECORDEDP_CODE Yap_heap_regs->retry_recordedp_code
|
|
||||||
#define RETRY_C_RECORDED_K_CODE Yap_heap_regs->retry_recorded_k_code
|
|
||||||
|
|
||||||
#define PROFILING Yap_heap_regs->system_profiling
|
|
||||||
#define CALL_COUNTING Yap_heap_regs->system_call_counting
|
|
||||||
#define PRED_GOAL_EXPANSION_ALL Yap_heap_regs->system_pred_goal_expansion_all
|
|
||||||
#define PRED_GOAL_EXPANSION_FUNC Yap_heap_regs->system_pred_goal_expansion_func
|
|
||||||
#define PRED_GOAL_EXPANSION_ON Yap_heap_regs->system_pred_goal_expansion_on
|
|
||||||
#define optimizer_on Yap_heap_regs->compiler_optimizer_on
|
|
||||||
#define compile_mode Yap_heap_regs->compiler_compile_mode
|
|
||||||
#define profiling Yap_heap_regs->compiler_profiling
|
|
||||||
#define call_counting Yap_heap_regs->compiler_call_counting
|
|
||||||
|
|
||||||
#define compile_arrays Yap_heap_regs->compiler_compile_arrays
|
|
||||||
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
#define DBTermsListLock Yap_heap_regs->dbterms_list_lock
|
|
||||||
#endif
|
|
||||||
#define DBTermsList Yap_heap_regs->dbterms_list
|
|
||||||
|
|
||||||
#define ExpandClausesFirst Yap_heap_regs->expand_clauses_first
|
|
||||||
#define ExpandClausesLast Yap_heap_regs->expand_clauses_last
|
|
||||||
#define Yap_ExpandClauses Yap_heap_regs->expand_clauses
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
#define ExpandClausesListLock Yap_heap_regs->expand_clauses_list_lock
|
|
||||||
#define OpListLock Yap_heap_regs->op_list_lock
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
#define Yap_NewCps Yap_heap_regs->new_cps
|
|
||||||
#define Yap_LiveCps Yap_heap_regs->live_cps
|
|
||||||
#define Yap_DirtyCps Yap_heap_regs->dirty_cps
|
|
||||||
#define Yap_FreedCps Yap_heap_regs->freed_cps
|
|
||||||
#endif
|
|
||||||
#define Yap_expand_clauses_sz Yap_heap_regs->expand_clauses_sz
|
|
||||||
|
|
||||||
#define UdiControlBlocks Yap_heap_regs->udi_control_blocks
|
|
||||||
|
|
||||||
|
|
||||||
#define STATIC_PREDICATES_MARKED Yap_heap_regs->static_predicates_marked
|
|
||||||
|
|
||||||
#define INT_KEYS Yap_heap_regs->IntKeys
|
|
||||||
#define INT_LU_KEYS Yap_heap_regs->IntLUKeys
|
|
||||||
#define INT_BB_KEYS Yap_heap_regs->IntBBKeys
|
|
||||||
|
|
||||||
#define INT_KEYS_SIZE Yap_heap_regs->int_keys_size
|
|
||||||
#define INT_KEYS_TIMESTAMP Yap_heap_regs->int_keys_timestamp
|
|
||||||
#define INT_BB_KEYS_SIZE Yap_heap_regs->int_bb_keys_size
|
|
||||||
|
|
||||||
#define UPDATE_MODE Yap_heap_regs->update_mode
|
|
||||||
|
|
||||||
#define DBErasedMarker Yap_heap_regs->db_erased_marker
|
|
||||||
#define LogDBErasedMarker Yap_heap_regs->logdb_erased_marker
|
|
||||||
|
|
||||||
#define DeadStaticClauses Yap_heap_regs->dead_static_clauses
|
|
||||||
#define DeadMegaClauses Yap_heap_regs->dead_mega_clauses
|
|
||||||
#define DeadStaticIndices Yap_heap_regs->dead_static_indices
|
|
||||||
#define DBErasedList Yap_heap_regs->db_erased_list
|
|
||||||
#define DBErasedIList Yap_heap_regs->db_erased_ilist
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
#define DeadStaticClausesLock Yap_heap_regs->dead_static_clauses_lock
|
|
||||||
#define DeadMegaClausesLock Yap_heap_regs->dead_mega_clauses_lock
|
|
||||||
#define DeadStaticIndicesLock Yap_heap_regs->dead_static_indices_lock
|
|
||||||
#endif
|
|
||||||
#ifdef COROUTINING
|
|
||||||
|
|
||||||
#define NUM_OF_ATTS Yap_heap_regs->num_of_atts
|
|
||||||
|
|
||||||
#define Yap_AttsSize Yap_heap_regs->atts_size
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define OpList Yap_heap_regs->op_list
|
|
||||||
|
|
||||||
#define ForeignCodeLoaded Yap_heap_regs->foreign_code_loaded
|
|
||||||
#define ForeignCodeBase Yap_heap_regs->foreign_code_base
|
|
||||||
#define ForeignCodeTop Yap_heap_regs->foreign_code_top
|
|
||||||
#define ForeignCodeMax Yap_heap_regs->foreign_code_max
|
|
||||||
|
|
||||||
#define Yap_Records Yap_heap_regs->yap_records
|
|
||||||
|
|
||||||
#define SWI_Atoms Yap_heap_regs->swi_atoms
|
|
||||||
#define SWI_Functors Yap_heap_regs->swi_functors
|
|
||||||
#define SWI_ReverseHash Yap_heap_regs->swi_reverse_hash
|
|
||||||
|
|
||||||
#define AtomTranslations Yap_heap_regs->atom_translations
|
|
||||||
#define MaxAtomTranslations Yap_heap_regs->max_atom_translations
|
|
||||||
|
|
||||||
#define FunctorTranslations Yap_heap_regs->functor_translations
|
|
||||||
#define MaxFunctorTranslations Yap_heap_regs->max_functor_translations
|
|
||||||
#define EmptyWakeups Yap_heap_regs->empty_wakeups
|
|
||||||
#define MaxEmptyWakeups Yap_heap_regs->max_empty_wakeups
|
|
||||||
|
|
||||||
#define BlobTypes Yap_heap_regs->swi_blob_types
|
|
||||||
#define Blobs Yap_heap_regs->swi_blobs
|
|
||||||
#define NOfBlobs Yap_heap_regs->nofblobs
|
|
||||||
#define NOfBlobsMax Yap_heap_regs->nofblobsmax
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
#define Blobs_Lock Yap_heap_regs->blobs_lock
|
|
||||||
#endif
|
|
@ -142,3 +142,5 @@
|
|||||||
|
|
||||||
#define GLOBAL_LastWTimePtr Yap_global->LastWTimePtr_
|
#define GLOBAL_LastWTimePtr Yap_global->LastWTimePtr_
|
||||||
|
|
||||||
|
#define GLOBAL_MaxPriority Yap_global->MaxPriority_
|
||||||
|
|
303
H/heap/dhstruct.h
Normal file
@ -0,0 +1,303 @@
|
|||||||
|
|
||||||
|
/* This file, dhstruct.h, was generated automatically by "yap -L misc/buildlocalglobal"
|
||||||
|
please do not update, update misc/HEAPFIELDS instead */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define Yap_HoleSize Yap_heap_regs->Yap_HoleSize_
|
||||||
|
#define Yap_av Yap_heap_regs->Yap_av_
|
||||||
|
#if USE_DL_MALLOC
|
||||||
|
#define void Yap_heap_regs->void_
|
||||||
|
#define Yap_NOfMemoryHoles Yap_heap_regs->Yap_NOfMemoryHoles_
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
#define DLMallocLock Yap_heap_regs->DLMallocLock_
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if USE_DL_MALLOC || (USE_SYSTEM_MALLOC && HAVE_MALLINFO)
|
||||||
|
#ifndef HeapUsed
|
||||||
|
#define HeapUsed Yap_givemallinfo()
|
||||||
|
#endif
|
||||||
|
#define NotHeapUsed Yap_heap_regs->NotHeapUsed_
|
||||||
|
#else
|
||||||
|
#define HeapUsed Yap_heap_regs->HeapUsed_
|
||||||
|
#endif
|
||||||
|
#define HeapMax Yap_heap_regs->HeapMax_
|
||||||
|
#define HeapTop Yap_heap_regs->HeapTop_
|
||||||
|
#define HeapLim Yap_heap_regs->HeapLim_
|
||||||
|
#define FreeBlocks Yap_heap_regs->FreeBlocks_
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
#define FreeBlocksLock Yap_heap_regs->FreeBlocksLock_
|
||||||
|
#define HeapUsedLock Yap_heap_regs->HeapUsedLock_
|
||||||
|
#define HeapTopLock Yap_heap_regs->HeapTopLock_
|
||||||
|
#define HeapTopOwner Yap_heap_regs->HeapTopOwner_
|
||||||
|
#endif
|
||||||
|
#define MaxStack Yap_heap_regs->MaxStack_
|
||||||
|
#define MaxTrail Yap_heap_regs->MaxTrail_
|
||||||
|
|
||||||
|
|
||||||
|
#if USE_THREADED_CODE
|
||||||
|
#define OP_RTABLE Yap_heap_regs->OP_RTABLE_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define EXECUTE_CPRED_OP_CODE Yap_heap_regs->EXECUTE_CPRED_OP_CODE_
|
||||||
|
#define EXPAND_OP_CODE Yap_heap_regs->EXPAND_OP_CODE_
|
||||||
|
#define FAIL_OPCODE Yap_heap_regs->FAIL_OPCODE_
|
||||||
|
#define INDEX_OPCODE Yap_heap_regs->INDEX_OPCODE_
|
||||||
|
#define LOCKPRED_OPCODE Yap_heap_regs->LOCKPRED_OPCODE_
|
||||||
|
#define ORLAST_OPCODE Yap_heap_regs->ORLAST_OPCODE_
|
||||||
|
#define UNDEF_OPCODE Yap_heap_regs->UNDEF_OPCODE_
|
||||||
|
#define RETRY_USERC_OPCODE Yap_heap_regs->RETRY_USERC_OPCODE_
|
||||||
|
#define EXECUTE_CPRED_OPCODE Yap_heap_regs->EXECUTE_CPRED_OPCODE_
|
||||||
|
|
||||||
|
#define NOfAtoms Yap_heap_regs->NOfAtoms_
|
||||||
|
#define AtomHashTableSize Yap_heap_regs->AtomHashTableSize_
|
||||||
|
#define WideAtomHashTableSize Yap_heap_regs->WideAtomHashTableSize_
|
||||||
|
#define NOfWideAtoms Yap_heap_regs->NOfWideAtoms_
|
||||||
|
#define INVISIBLECHAIN Yap_heap_regs->INVISIBLECHAIN_
|
||||||
|
#define WideHashChain Yap_heap_regs->WideHashChain_
|
||||||
|
#define HashChain Yap_heap_regs->HashChain_
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef EUROTRA
|
||||||
|
#define TermDollarU Yap_heap_regs->TermDollarU_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define USER_MODULE Yap_heap_regs->USER_MODULE_
|
||||||
|
#define IDB_MODULE Yap_heap_regs->IDB_MODULE_
|
||||||
|
#define ATTRIBUTES_MODULE Yap_heap_regs->ATTRIBUTES_MODULE_
|
||||||
|
#define CHARSIO_MODULE Yap_heap_regs->CHARSIO_MODULE_
|
||||||
|
#define CHTYPE_MODULE Yap_heap_regs->CHTYPE_MODULE_
|
||||||
|
#define TERMS_MODULE Yap_heap_regs->TERMS_MODULE_
|
||||||
|
#define SYSTEM_MODULE Yap_heap_regs->SYSTEM_MODULE_
|
||||||
|
#define READUTIL_MODULE Yap_heap_regs->READUTIL_MODULE_
|
||||||
|
#define HACKS_MODULE Yap_heap_regs->HACKS_MODULE_
|
||||||
|
#define ARG_MODULE Yap_heap_regs->ARG_MODULE_
|
||||||
|
#define GLOBALS_MODULE Yap_heap_regs->GLOBALS_MODULE_
|
||||||
|
#define SWI_MODULE Yap_heap_regs->SWI_MODULE_
|
||||||
|
#define DBLOAD_MODULE Yap_heap_regs->DBLOAD_MODULE_
|
||||||
|
#define RANGE_MODULE Yap_heap_regs->RANGE_MODULE_
|
||||||
|
#define ERROR_MODULE Yap_heap_regs->ERROR_MODULE_
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define CurrentModules Yap_heap_regs->CurrentModules_
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define HIDDEN_PREDICATES Yap_heap_regs->HIDDEN_PREDICATES_
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define GLOBAL_Flags Yap_heap_regs->GLOBAL_Flags_
|
||||||
|
#define GLOBAL_flagCount Yap_heap_regs->GLOBAL_flagCount_
|
||||||
|
|
||||||
|
#define Yap_ExecutionMode Yap_heap_regs->Yap_ExecutionMode_
|
||||||
|
|
||||||
|
#define PredHash Yap_heap_regs->PredHash_
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
#define PredHashRWLock Yap_heap_regs->PredHashRWLock_
|
||||||
|
#endif
|
||||||
|
#define PredsInHashTable Yap_heap_regs->PredsInHashTable_
|
||||||
|
#define PredHashTableSize Yap_heap_regs->PredHashTableSize_
|
||||||
|
|
||||||
|
#define CreepCode Yap_heap_regs->CreepCode_
|
||||||
|
#define UndefCode Yap_heap_regs->UndefCode_
|
||||||
|
#define SpyCode Yap_heap_regs->SpyCode_
|
||||||
|
#define PredFail Yap_heap_regs->PredFail_
|
||||||
|
#define PredTrue Yap_heap_regs->PredTrue_
|
||||||
|
#ifdef COROUTINING
|
||||||
|
#define WakeUpCode Yap_heap_regs->WakeUpCode_
|
||||||
|
#endif
|
||||||
|
#define PredGoalExpansion Yap_heap_regs->PredGoalExpansion_
|
||||||
|
#define PredMetaCall Yap_heap_regs->PredMetaCall_
|
||||||
|
#define PredTraceMetaCall Yap_heap_regs->PredTraceMetaCall_
|
||||||
|
#define PredDollarCatch Yap_heap_regs->PredDollarCatch_
|
||||||
|
#define PredRecordedWithKey Yap_heap_regs->PredRecordedWithKey_
|
||||||
|
#define PredLogUpdClause Yap_heap_regs->PredLogUpdClause_
|
||||||
|
#define PredLogUpdClauseErase Yap_heap_regs->PredLogUpdClauseErase_
|
||||||
|
#define PredLogUpdClause0 Yap_heap_regs->PredLogUpdClause0_
|
||||||
|
#define PredStaticClause Yap_heap_regs->PredStaticClause_
|
||||||
|
#define PredThrow Yap_heap_regs->PredThrow_
|
||||||
|
#define PredHandleThrow Yap_heap_regs->PredHandleThrow_
|
||||||
|
#define PredIs Yap_heap_regs->PredIs_
|
||||||
|
#define PredSafeCallCleanup Yap_heap_regs->PredSafeCallCleanup_
|
||||||
|
#define PredRestoreRegs Yap_heap_regs->PredRestoreRegs_
|
||||||
|
#define PredCommentHook Yap_heap_regs->PredCommentHook_
|
||||||
|
#ifdef YAPOR
|
||||||
|
#define PredGetwork Yap_heap_regs->PredGetwork_
|
||||||
|
#endif /* YAPOR */
|
||||||
|
#define PredProcedure Yap_heap_regs->PredProcedure_
|
||||||
|
|
||||||
|
#ifdef LOW_LEVEL_TRACER
|
||||||
|
#define Yap_do_low_level_trace Yap_heap_regs->Yap_do_low_level_trace_
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
#define Yap_low_level_trace_lock Yap_heap_regs->Yap_low_level_trace_lock_
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define Yap_ClauseSpace Yap_heap_regs->Yap_ClauseSpace_
|
||||||
|
#define Yap_IndexSpace_Tree Yap_heap_regs->Yap_IndexSpace_Tree_
|
||||||
|
#define Yap_IndexSpace_EXT Yap_heap_regs->Yap_IndexSpace_EXT_
|
||||||
|
#define Yap_IndexSpace_SW Yap_heap_regs->Yap_IndexSpace_SW_
|
||||||
|
#define Yap_LUClauseSpace Yap_heap_regs->Yap_LUClauseSpace_
|
||||||
|
#define Yap_LUIndexSpace_Tree Yap_heap_regs->Yap_LUIndexSpace_Tree_
|
||||||
|
#define Yap_LUIndexSpace_CP Yap_heap_regs->Yap_LUIndexSpace_CP_
|
||||||
|
#define Yap_LUIndexSpace_EXT Yap_heap_regs->Yap_LUIndexSpace_EXT_
|
||||||
|
#define Yap_LUIndexSpace_SW Yap_heap_regs->Yap_LUIndexSpace_SW_
|
||||||
|
|
||||||
|
#define COMMA_CODE Yap_heap_regs->COMMA_CODE_
|
||||||
|
#define DUMMYCODE Yap_heap_regs->DUMMYCODE_
|
||||||
|
#define FAILCODE Yap_heap_regs->FAILCODE_
|
||||||
|
#define NOCODE Yap_heap_regs->NOCODE_
|
||||||
|
#define ENV_FOR_TRUSTFAIL Yap_heap_regs->ENV_FOR_TRUSTFAIL_
|
||||||
|
#define TRUSTFAILCODE Yap_heap_regs->TRUSTFAILCODE_
|
||||||
|
#define ENV_FOR_YESCODE Yap_heap_regs->ENV_FOR_YESCODE_
|
||||||
|
#define YESCODE Yap_heap_regs->YESCODE_
|
||||||
|
#define RTRYCODE Yap_heap_regs->RTRYCODE_
|
||||||
|
#ifdef BEAM
|
||||||
|
#define BEAM_RETRY_CODE Yap_heap_regs->BEAM_RETRY_CODE_
|
||||||
|
#endif /* BEAM */
|
||||||
|
#ifdef YAPOR
|
||||||
|
#define GETWORK Yap_heap_regs->GETWORK_
|
||||||
|
#define GETWORK_SEQ Yap_heap_regs->GETWORK_SEQ_
|
||||||
|
#define GETWORK_FIRST_TIME Yap_heap_regs->GETWORK_FIRST_TIME_
|
||||||
|
#endif /* YAPOR */
|
||||||
|
#ifdef TABLING
|
||||||
|
#define LOAD_ANSWER Yap_heap_regs->LOAD_ANSWER_
|
||||||
|
#define TRY_ANSWER Yap_heap_regs->TRY_ANSWER_
|
||||||
|
#define ANSWER_RESOLUTION Yap_heap_regs->ANSWER_RESOLUTION_
|
||||||
|
#define COMPLETION Yap_heap_regs->COMPLETION_
|
||||||
|
#ifdef THREADS_CONSUMER_SHARING
|
||||||
|
#define ANSWER_RESOLUTION_COMPLETION Yap_heap_regs->ANSWER_RESOLUTION_COMPLETION_
|
||||||
|
#endif /* THREADS_CONSUMER_SHARING */
|
||||||
|
#endif /* TABLING */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define P_before_spy Yap_heap_regs->P_before_spy_
|
||||||
|
|
||||||
|
#define RETRY_C_RECORDEDP_CODE Yap_heap_regs->RETRY_C_RECORDEDP_CODE_
|
||||||
|
#define RETRY_C_RECORDED_K_CODE Yap_heap_regs->RETRY_C_RECORDED_K_CODE_
|
||||||
|
|
||||||
|
#define PROFILING Yap_heap_regs->PROFILING_
|
||||||
|
#define CALL_COUNTING Yap_heap_regs->CALL_COUNTING_
|
||||||
|
#define optimizer_on Yap_heap_regs->optimizer_on_
|
||||||
|
#define compile_mode Yap_heap_regs->compile_mode_
|
||||||
|
#define profiling Yap_heap_regs->profiling_
|
||||||
|
#define call_counting Yap_heap_regs->call_counting_
|
||||||
|
|
||||||
|
#define compile_arrays Yap_heap_regs->compile_arrays_
|
||||||
|
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
#define DBTermsListLock Yap_heap_regs->DBTermsListLock_
|
||||||
|
#endif
|
||||||
|
#define DBTermsList Yap_heap_regs->DBTermsList_
|
||||||
|
|
||||||
|
#define ExpandClausesFirst Yap_heap_regs->ExpandClausesFirst_
|
||||||
|
#define ExpandClausesLast Yap_heap_regs->ExpandClausesLast_
|
||||||
|
#define Yap_ExpandClauses Yap_heap_regs->Yap_ExpandClauses_
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
#define ExpandClausesListLock Yap_heap_regs->ExpandClausesListLock_
|
||||||
|
#define OpListLock Yap_heap_regs->OpListLock_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
#define Yap_NewCps Yap_heap_regs->Yap_NewCps_
|
||||||
|
#define Yap_LiveCps Yap_heap_regs->Yap_LiveCps_
|
||||||
|
#define Yap_DirtyCps Yap_heap_regs->Yap_DirtyCps_
|
||||||
|
#define Yap_FreedCps Yap_heap_regs->Yap_FreedCps_
|
||||||
|
#endif
|
||||||
|
#define Yap_expand_clauses_sz Yap_heap_regs->Yap_expand_clauses_sz_
|
||||||
|
|
||||||
|
#define UdiControlBlocks Yap_heap_regs->UdiControlBlocks_
|
||||||
|
|
||||||
|
|
||||||
|
#define STATIC_PREDICATES_MARKED Yap_heap_regs->STATIC_PREDICATES_MARKED_
|
||||||
|
|
||||||
|
#define INT_KEYS Yap_heap_regs->INT_KEYS_
|
||||||
|
#define INT_LU_KEYS Yap_heap_regs->INT_LU_KEYS_
|
||||||
|
#define INT_BB_KEYS Yap_heap_regs->INT_BB_KEYS_
|
||||||
|
|
||||||
|
#define INT_KEYS_SIZE Yap_heap_regs->INT_KEYS_SIZE_
|
||||||
|
#define INT_KEYS_TIMESTAMP Yap_heap_regs->INT_KEYS_TIMESTAMP_
|
||||||
|
#define INT_BB_KEYS_SIZE Yap_heap_regs->INT_BB_KEYS_SIZE_
|
||||||
|
|
||||||
|
#define UPDATE_MODE Yap_heap_regs->UPDATE_MODE_
|
||||||
|
|
||||||
|
#define DBErasedMarker Yap_heap_regs->DBErasedMarker_
|
||||||
|
#define LogDBErasedMarker Yap_heap_regs->LogDBErasedMarker_
|
||||||
|
|
||||||
|
#define DeadStaticClauses Yap_heap_regs->DeadStaticClauses_
|
||||||
|
#define DeadMegaClauses Yap_heap_regs->DeadMegaClauses_
|
||||||
|
#define DeadStaticIndices Yap_heap_regs->DeadStaticIndices_
|
||||||
|
#define DBErasedList Yap_heap_regs->DBErasedList_
|
||||||
|
#define DBErasedIList Yap_heap_regs->DBErasedIList_
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
#define DeadStaticClausesLock Yap_heap_regs->DeadStaticClausesLock_
|
||||||
|
#define DeadMegaClausesLock Yap_heap_regs->DeadMegaClausesLock_
|
||||||
|
#define DeadStaticIndicesLock Yap_heap_regs->DeadStaticIndicesLock_
|
||||||
|
#endif
|
||||||
|
#ifdef COROUTINING
|
||||||
|
|
||||||
|
#define NUM_OF_ATTS Yap_heap_regs->NUM_OF_ATTS_
|
||||||
|
|
||||||
|
#define Yap_AttsSize Yap_heap_regs->Yap_AttsSize_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define OpList Yap_heap_regs->OpList_
|
||||||
|
|
||||||
|
#define ForeignCodeLoaded Yap_heap_regs->ForeignCodeLoaded_
|
||||||
|
#define ForeignCodeBase Yap_heap_regs->ForeignCodeBase_
|
||||||
|
#define ForeignCodeTop Yap_heap_regs->ForeignCodeTop_
|
||||||
|
#define ForeignCodeMax Yap_heap_regs->ForeignCodeMax_
|
||||||
|
|
||||||
|
#define Yap_Records Yap_heap_regs->Yap_Records_
|
||||||
|
|
||||||
|
#define SWI_Atoms Yap_heap_regs->SWI_Atoms_
|
||||||
|
#define SWI_Functors Yap_heap_regs->SWI_Functors_
|
||||||
|
#define SWI_ReverseHash Yap_heap_regs->SWI_ReverseHash_
|
||||||
|
|
||||||
|
#define AtomTranslations Yap_heap_regs->AtomTranslations_
|
||||||
|
#define MaxAtomTranslations Yap_heap_regs->MaxAtomTranslations_
|
||||||
|
|
||||||
|
#define FunctorTranslations Yap_heap_regs->FunctorTranslations_
|
||||||
|
#define MaxFunctorTranslations Yap_heap_regs->MaxFunctorTranslations_
|
||||||
|
#define EmptyWakeups Yap_heap_regs->EmptyWakeups_
|
||||||
|
#define MaxEmptyWakeups Yap_heap_regs->MaxEmptyWakeups_
|
||||||
|
|
||||||
|
#define BlobTypes Yap_heap_regs->BlobTypes_
|
||||||
|
#define Blobs Yap_heap_regs->Blobs_
|
||||||
|
#define NOfBlobs Yap_heap_regs->NOfBlobs_
|
||||||
|
#define NOfBlobsMax Yap_heap_regs->NOfBlobsMax_
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
#define Blobs_Lock Yap_heap_regs->Blobs_Lock_
|
||||||
|
#endif
|
||||||
|
|
@ -453,8 +453,6 @@
|
|||||||
#define REMOTE_ImportDBRefHashTableNum(wid) REMOTE(wid)->ImportDBRefHashTableNum_
|
#define REMOTE_ImportDBRefHashTableNum(wid) REMOTE(wid)->ImportDBRefHashTableNum_
|
||||||
#define LOCAL_ImportFAILCODE LOCAL->ImportFAILCODE_
|
#define LOCAL_ImportFAILCODE LOCAL->ImportFAILCODE_
|
||||||
#define REMOTE_ImportFAILCODE(wid) REMOTE(wid)->ImportFAILCODE_
|
#define REMOTE_ImportFAILCODE(wid) REMOTE(wid)->ImportFAILCODE_
|
||||||
#define LOCAL_FunctorVar LOCAL->FunctorVar_
|
|
||||||
#define REMOTE_FunctorVar(wid) REMOTE(wid)->FunctorVar_
|
|
||||||
#if __ANDROID__
|
#if __ANDROID__
|
||||||
|
|
||||||
#define LOCAL_assetManager LOCAL->assetManager_
|
#define LOCAL_assetManager LOCAL->assetManager_
|
146
H/heap/h0globals.h
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
|
||||||
|
/* This file, hglobals.h, was generated automatically by "yap -L misc/buildlocalglobal"
|
||||||
|
please do not update, update misc/GLOBALS instead */
|
||||||
|
|
||||||
|
//
|
||||||
|
// File defining fields in the Yap_GLOBAL global structure
|
||||||
|
//
|
||||||
|
// these fields used to spread all over the place, because they must be used in 3 ways:
|
||||||
|
// - they must be defined somewhere
|
||||||
|
// - they have an #ifdef to get a shorter name
|
||||||
|
// - they must be initialised somewhere
|
||||||
|
// - they may be of interest to restore
|
||||||
|
//
|
||||||
|
// The defs include 3+ components:
|
||||||
|
// Type
|
||||||
|
// name in structured / global name
|
||||||
|
// init code (optional)
|
||||||
|
// restore code (optional)
|
||||||
|
//
|
||||||
|
// Stuff that must be shared by all threads or workers
|
||||||
|
|
||||||
|
// initialization: tell whether the system has been initialised and by whom.
|
||||||
|
EXTERNAL int GLOBAL_Initialised;
|
||||||
|
EXTERNAL int GLOBAL_InitialisedFromPL;
|
||||||
|
EXTERNAL int GLOBAL_PL_Argc;
|
||||||
|
EXTERNAL char** GLOBAL_PL_Argv;
|
||||||
|
EXTERNAL bool GLOBAL_FAST_BOOT_FLAG;
|
||||||
|
// halt hooks
|
||||||
|
EXTERNAL struct halt_hook* GLOBAL_HaltHooks;
|
||||||
|
EXTERNAL fptr_t GLOBAL_JIT_finalizer;
|
||||||
|
// stack overflow expansion/gc control
|
||||||
|
EXTERNAL int GLOBAL_AllowLocalExpansion;
|
||||||
|
EXTERNAL int GLOBAL_AllowGlobalExpansion;
|
||||||
|
EXTERNAL int GLOBAL_AllowTrailExpansion;
|
||||||
|
EXTERNAL UInt GLOBAL_SizeOfOverflow;
|
||||||
|
// amount of space recovered in all garbage collections
|
||||||
|
EXTERNAL UInt GLOBAL_AGcThreshold;
|
||||||
|
EXTERNAL Agc_hook GLOBAL_AGCHook;
|
||||||
|
#if __ANDROID__
|
||||||
|
// no need to perform initialization, it is done before we start the Prolog engine.
|
||||||
|
EXTERNAL struct AAssetManager* GLOBAL_assetManager;
|
||||||
|
EXTERNAL char* GLOBAL_AssetsWD;
|
||||||
|
#endif
|
||||||
|
/* multi-thread support */
|
||||||
|
#if THREADS
|
||||||
|
/* number of threads and processes in system */
|
||||||
|
EXTERNAL UInt GLOBAL_NOfThreads;
|
||||||
|
/* number of threads created since start */
|
||||||
|
EXTERNAL UInt GLOBAL_NOfThreadsCreated;
|
||||||
|
/* total run time for dead threads */
|
||||||
|
EXTERNAL UInt GLOBAL_ThreadsTotalTime;
|
||||||
|
// Threads Array
|
||||||
|
EXTERNAL lockvar GLOBAL_ThreadHandlesLock;
|
||||||
|
#endif
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
// protect long critical regions
|
||||||
|
EXTERNAL lockvar GLOBAL_BGL;
|
||||||
|
#endif
|
||||||
|
#if defined(YAPOR) || defined(TABLING)
|
||||||
|
EXTERNAL struct global_optyap_data GLOBAL_optyap_data;
|
||||||
|
#endif /* YAPOR || TABLING */
|
||||||
|
// whether Yap is responsible for signal handling
|
||||||
|
EXTERNAL int GLOBAL_PrologShouldHandleInterrupts;
|
||||||
|
/* This is the guy who actually started the system, and who has the correct registers */
|
||||||
|
#if defined(THREADS)
|
||||||
|
EXTERNAL pthread_t GLOBAL_master_thread;
|
||||||
|
EXTERNAL struct thread_mbox* GLOBAL_named_mboxes;
|
||||||
|
EXTERNAL lockvar GLOBAL_mboxq_lock;
|
||||||
|
EXTERNAL UInt GLOBAL_mbox_count;
|
||||||
|
EXTERNAL struct swi_mutex* GLOBAL_WithMutex;
|
||||||
|
#endif /* THREADS */
|
||||||
|
// streams
|
||||||
|
EXTERNAL struct stream_desc* GLOBAL_Stream;
|
||||||
|
#if defined(THREADS)||defined(YAPOR)
|
||||||
|
EXTERNAL lockvar GLOBAL_StreamDescLock;
|
||||||
|
#endif
|
||||||
|
// access to yap initial arguments
|
||||||
|
EXTERNAL char** GLOBAL_argv;
|
||||||
|
EXTERNAL int GLOBAL_argc;
|
||||||
|
// extensions to Terms
|
||||||
|
#ifdef COROUTINING
|
||||||
|
/* array with the ops for your favourite extensions */
|
||||||
|
EXTERNAL ext_op GLOBAL_attas[attvars_ext+1];
|
||||||
|
#endif
|
||||||
|
// agc.c
|
||||||
|
EXTERNAL int GLOBAL_agc_calls;
|
||||||
|
EXTERNAL YAP_ULONG_LONG GLOBAL_agc_collected;
|
||||||
|
/* total time spent in GC */
|
||||||
|
EXTERNAL Int GLOBAL_tot_agc_time;
|
||||||
|
/* number of heap objects in all garbage collections */
|
||||||
|
EXTERNAL Int GLOBAL_tot_agc_recovered;
|
||||||
|
//arrays.c
|
||||||
|
#if HAVE_MMAP
|
||||||
|
EXTERNAL struct MMAP_ARRAY_BLOCK* GLOBAL_mmap_arrays;
|
||||||
|
#endif
|
||||||
|
#ifdef DEBUG
|
||||||
|
//computils.c
|
||||||
|
EXTERNAL char GLOBAL_Option[20];
|
||||||
|
EXTERNAL YP_FILE* GLOBAL_logfile;
|
||||||
|
//init.c
|
||||||
|
//int output_msg =FALSE
|
||||||
|
#endif
|
||||||
|
#if defined(COFF) || defined(A_OUT)
|
||||||
|
// loada_coff.c && load_aout.c
|
||||||
|
EXTERNAL char GLOBAL_Executable[YAP_FILENAME_MAX];
|
||||||
|
#endif
|
||||||
|
EXTERNAL int GLOBAL_OpaqueHandlersCount;
|
||||||
|
EXTERNAL struct opaque_handler_struct* GLOBAL_OpaqueHandlers;
|
||||||
|
#if __simplescalar__
|
||||||
|
EXTERNAL char GLOBAL_pwd[YAP_FILENAME_MAX];
|
||||||
|
#endif
|
||||||
|
//udi.c
|
||||||
|
//struct udi_control_block RtreeCmd void
|
||||||
|
EXTERNAL char* GLOBAL_RestoreFile;
|
||||||
|
//gprof.c
|
||||||
|
EXTERNAL Int GLOBAL_ProfCalls;
|
||||||
|
EXTERNAL Int GLOBAL_ProfGCs;
|
||||||
|
EXTERNAL Int GLOBAL_ProfHGrows;
|
||||||
|
EXTERNAL Int GLOBAL_ProfSGrows;
|
||||||
|
EXTERNAL Int GLOBAL_ProfMallocs;
|
||||||
|
EXTERNAL Int GLOBAL_ProfIndexing;
|
||||||
|
EXTERNAL Int GLOBAL_ProfOn;
|
||||||
|
EXTERNAL Int GLOBAL_ProfOns;
|
||||||
|
EXTERNAL struct RB_red_blk_node* GLOBAL_ProfilerRoot;
|
||||||
|
EXTERNAL struct RB_red_blk_node* GLOBAL_ProfilerNil;
|
||||||
|
EXTERNAL char* GLOBAL_DIRNAME;
|
||||||
|
#if LOW_PROF
|
||||||
|
EXTERNAL int GLOBAL_ProfilerOn;
|
||||||
|
EXTERNAL FILE* GLOBAL_FProf;
|
||||||
|
EXTERNAL FILE* GLOBAL_FPreds;
|
||||||
|
#endif /* LOW_PROF */
|
||||||
|
// Mutexes
|
||||||
|
#if THREADS
|
||||||
|
EXTERNAL struct swi_mutex* GLOBAL_FreeMutexes;
|
||||||
|
EXTERNAL struct swi_mutex* GLOBAL_mutex_backbone;
|
||||||
|
EXTERNAL lockvar GLOBAL_MUT_ACCESS;
|
||||||
|
#endif
|
||||||
|
EXTERNAL char* GLOBAL_Home;
|
||||||
|
/* ISO char conversion: I will make no comments */
|
||||||
|
EXTERNAL char* GLOBAL_CharConversionTable;
|
||||||
|
EXTERNAL char* GLOBAL_CharConversionTable2;
|
||||||
|
/* time */
|
||||||
|
EXTERNAL void* GLOBAL_LastWTimePtr;
|
||||||
|
/* max priority */
|
||||||
|
EXTERNAL int GLOBAL_MaxPriority;
|
||||||
|
|
303
H/heap/h0struct.h
Normal file
@ -0,0 +1,303 @@
|
|||||||
|
|
||||||
|
/* This file, d0hstruct.h, was generated automatically by "yap -L misc/buildlocalglobal"
|
||||||
|
please do not update, update misc/HEAPFIELDS instead */
|
||||||
|
|
||||||
|
//
|
||||||
|
// File defining fields in the Yap_heap_codes global structure
|
||||||
|
//
|
||||||
|
// these fields used to spread all over the place, because they must be used in 4 ways:
|
||||||
|
// - they must be defined somewhere
|
||||||
|
// - they have an #ifdef to get a shorter name
|
||||||
|
// - they must be initialised somewhere
|
||||||
|
// - they must be restorable and collectable (from the atom gc).
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// The defs include 4+ components:
|
||||||
|
// Type
|
||||||
|
// name in structured
|
||||||
|
// global name
|
||||||
|
// init code and restore code (optional)
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// MkAT (MkAtomTerm) cvts from a predefined atom to a term
|
||||||
|
// MkPred constructs a pred_entry
|
||||||
|
// MkOp gets an opcode
|
||||||
|
// void does nothing
|
||||||
|
// =VALUE inits as VALUE
|
||||||
|
// Init... sets up call to InitFunc
|
||||||
|
// Restore... sets up call to RestoreFunc
|
||||||
|
//
|
||||||
|
|
||||||
|
/* memory management */
|
||||||
|
EXTERNAL UInt Yap_HoleSize;
|
||||||
|
EXTERNAL struct malloc_state *Yap_av;
|
||||||
|
#if USE_DL_MALLOC
|
||||||
|
EXTERNAL struct Yap_MemoryHoles[MAX_DLMALLOC_HOLES] void;
|
||||||
|
EXTERNAL UInt Yap_NOfMemoryHoles;
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
EXTERNAL lockvar DLMallocLock;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if USE_DL_MALLOC || (USE_SYSTEM_MALLOC && HAVE_MALLINFO)
|
||||||
|
#ifndef HeapUsed
|
||||||
|
#define HeapUsed Yap_givemallinfo()
|
||||||
|
#endif
|
||||||
|
EXTERNAL Int NotHeapUsed;
|
||||||
|
#else
|
||||||
|
EXTERNAL Int HeapUsed;
|
||||||
|
#endif
|
||||||
|
EXTERNAL Int HeapMax;
|
||||||
|
EXTERNAL ADDR HeapTop;
|
||||||
|
EXTERNAL ADDR HeapLim;
|
||||||
|
EXTERNAL struct FREEB *FreeBlocks;
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
EXTERNAL lockvar FreeBlocksLock;
|
||||||
|
EXTERNAL lockvar HeapUsedLock;
|
||||||
|
EXTERNAL lockvar HeapTopLock;
|
||||||
|
EXTERNAL int HeapTopOwner;
|
||||||
|
#endif
|
||||||
|
EXTERNAL UInt MaxStack;
|
||||||
|
EXTERNAL UInt MaxTrail;
|
||||||
|
/* execution info */
|
||||||
|
/* OPCODE REVERSE TABLE, needed to recover op tables */
|
||||||
|
#if USE_THREADED_CODE
|
||||||
|
EXTERNAL op_entry *OP_RTABLE;
|
||||||
|
#endif
|
||||||
|
/* popular opcodes */
|
||||||
|
EXTERNAL OPCODE EXECUTE_CPRED_OP_CODE;
|
||||||
|
EXTERNAL OPCODE EXPAND_OP_CODE;
|
||||||
|
EXTERNAL OPCODE FAIL_OPCODE;
|
||||||
|
EXTERNAL OPCODE INDEX_OPCODE;
|
||||||
|
EXTERNAL OPCODE LOCKPRED_OPCODE;
|
||||||
|
EXTERNAL OPCODE ORLAST_OPCODE;
|
||||||
|
EXTERNAL OPCODE UNDEF_OPCODE;
|
||||||
|
EXTERNAL OPCODE RETRY_USERC_OPCODE;
|
||||||
|
EXTERNAL OPCODE EXECUTE_CPRED_OPCODE;
|
||||||
|
/* atom tables */
|
||||||
|
EXTERNAL UInt NOfAtoms;
|
||||||
|
EXTERNAL UInt AtomHashTableSize;
|
||||||
|
EXTERNAL UInt WideAtomHashTableSize;
|
||||||
|
EXTERNAL UInt NOfWideAtoms;
|
||||||
|
EXTERNAL AtomHashEntry INVISIBLECHAIN;
|
||||||
|
EXTERNAL AtomHashEntry *WideHashChain;
|
||||||
|
EXTERNAL AtomHashEntry *HashChain;
|
||||||
|
/* use atom defs here */
|
||||||
|
#include "tatoms.h"
|
||||||
|
#ifdef EUROTRA
|
||||||
|
EXTERNAL Term TermDollarU;
|
||||||
|
#endif
|
||||||
|
//modules
|
||||||
|
EXTERNAL Term USER_MODULE;
|
||||||
|
EXTERNAL Term IDB_MODULE;
|
||||||
|
EXTERNAL Term ATTRIBUTES_MODULE;
|
||||||
|
EXTERNAL Term CHARSIO_MODULE;
|
||||||
|
EXTERNAL Term CHTYPE_MODULE;
|
||||||
|
EXTERNAL Term TERMS_MODULE;
|
||||||
|
EXTERNAL Term SYSTEM_MODULE;
|
||||||
|
EXTERNAL Term READUTIL_MODULE;
|
||||||
|
EXTERNAL Term HACKS_MODULE;
|
||||||
|
EXTERNAL Term ARG_MODULE;
|
||||||
|
EXTERNAL Term GLOBALS_MODULE;
|
||||||
|
EXTERNAL Term SWI_MODULE;
|
||||||
|
EXTERNAL Term DBLOAD_MODULE;
|
||||||
|
EXTERNAL Term RANGE_MODULE;
|
||||||
|
EXTERNAL Term ERROR_MODULE;
|
||||||
|
//
|
||||||
|
// Module list
|
||||||
|
//
|
||||||
|
EXTERNAL struct mod_entry *CurrentModules;
|
||||||
|
// make sure we have the modules set at this point.
|
||||||
|
// don't actually want to define a field
|
||||||
|
|
||||||
|
// hidden predicates
|
||||||
|
EXTERNAL Prop HIDDEN_PREDICATES;
|
||||||
|
// make sure we have the streams set at this point.
|
||||||
|
// don't actually want to define a field
|
||||||
|
|
||||||
|
EXTERNAL union flagTerm* GLOBAL_Flags;
|
||||||
|
EXTERNAL UInt GLOBAL_flagCount;
|
||||||
|
/* Anderson's JIT */
|
||||||
|
EXTERNAL yap_exec_mode Yap_ExecutionMode;
|
||||||
|
/* The Predicate Hash Table: fast access to predicates. */
|
||||||
|
EXTERNAL struct pred_entry **PredHash;
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
EXTERNAL rwlock_t PredHashRWLock;
|
||||||
|
#endif
|
||||||
|
EXTERNAL UInt PredsInHashTable;
|
||||||
|
EXTERNAL UInt PredHashTableSize;
|
||||||
|
/* Well-Known Predicates */
|
||||||
|
EXTERNAL struct pred_entry *CreepCode;
|
||||||
|
EXTERNAL struct pred_entry *UndefCode;
|
||||||
|
EXTERNAL struct pred_entry *SpyCode;
|
||||||
|
EXTERNAL struct pred_entry *PredFail;
|
||||||
|
EXTERNAL struct pred_entry *PredTrue;
|
||||||
|
#ifdef COROUTINING
|
||||||
|
EXTERNAL struct pred_entry *WakeUpCode;
|
||||||
|
#endif
|
||||||
|
EXTERNAL struct pred_entry *PredGoalExpansion;
|
||||||
|
EXTERNAL struct pred_entry *PredMetaCall;
|
||||||
|
EXTERNAL struct pred_entry *PredTraceMetaCall;
|
||||||
|
EXTERNAL struct pred_entry *PredDollarCatch;
|
||||||
|
EXTERNAL struct pred_entry *PredRecordedWithKey;
|
||||||
|
EXTERNAL struct pred_entry *PredLogUpdClause;
|
||||||
|
EXTERNAL struct pred_entry *PredLogUpdClauseErase;
|
||||||
|
EXTERNAL struct pred_entry *PredLogUpdClause0;
|
||||||
|
EXTERNAL struct pred_entry *PredStaticClause;
|
||||||
|
EXTERNAL struct pred_entry *PredThrow;
|
||||||
|
EXTERNAL struct pred_entry *PredHandleThrow;
|
||||||
|
EXTERNAL struct pred_entry *PredIs;
|
||||||
|
EXTERNAL struct pred_entry *PredSafeCallCleanup;
|
||||||
|
EXTERNAL struct pred_entry *PredRestoreRegs;
|
||||||
|
EXTERNAL struct pred_entry *PredCommentHook;
|
||||||
|
#ifdef YAPOR
|
||||||
|
EXTERNAL struct pred_entry *PredGetwork;
|
||||||
|
#endif /* YAPOR */
|
||||||
|
EXTERNAL struct pred_entry *PredProcedure;
|
||||||
|
/* low-level tracer */
|
||||||
|
#ifdef LOW_LEVEL_TRACER
|
||||||
|
EXTERNAL int Yap_do_low_level_trace;
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
EXTERNAL lockvar Yap_low_level_trace_lock;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
/* code management info */
|
||||||
|
EXTERNAL UInt Yap_ClauseSpace;
|
||||||
|
EXTERNAL UInt Yap_IndexSpace_Tree;
|
||||||
|
EXTERNAL UInt Yap_IndexSpace_EXT;
|
||||||
|
EXTERNAL UInt Yap_IndexSpace_SW;
|
||||||
|
EXTERNAL UInt Yap_LUClauseSpace;
|
||||||
|
EXTERNAL UInt Yap_LUIndexSpace_Tree;
|
||||||
|
EXTERNAL UInt Yap_LUIndexSpace_CP;
|
||||||
|
EXTERNAL UInt Yap_LUIndexSpace_EXT;
|
||||||
|
EXTERNAL UInt Yap_LUIndexSpace_SW;
|
||||||
|
/* static code: may be shared by many predicate or may be used for meta-execution */
|
||||||
|
EXTERNAL yamop COMMA_CODE[5];
|
||||||
|
EXTERNAL yamop DUMMYCODE[1];
|
||||||
|
EXTERNAL yamop FAILCODE[1];
|
||||||
|
EXTERNAL yamop NOCODE[1];
|
||||||
|
EXTERNAL yamop ENV_FOR_TRUSTFAIL[2];
|
||||||
|
EXTERNAL yamop *TRUSTFAILCODE;
|
||||||
|
EXTERNAL yamop ENV_FOR_YESCODE[2];
|
||||||
|
EXTERNAL yamop *YESCODE;
|
||||||
|
EXTERNAL yamop RTRYCODE[1];
|
||||||
|
#ifdef BEAM
|
||||||
|
EXTERNAL yamop BEAM_RETRY_CODE[1];
|
||||||
|
#endif /* BEAM */
|
||||||
|
#ifdef YAPOR
|
||||||
|
EXTERNAL yamop GETWORK[1];
|
||||||
|
EXTERNAL yamop GETWORK_SEQ[1];
|
||||||
|
EXTERNAL yamop GETWORK_FIRST_TIME[1];
|
||||||
|
#endif /* YAPOR */
|
||||||
|
#ifdef TABLING
|
||||||
|
EXTERNAL yamop LOAD_ANSWER[1];
|
||||||
|
EXTERNAL yamop TRY_ANSWER[1];
|
||||||
|
EXTERNAL yamop ANSWER_RESOLUTION[1];
|
||||||
|
EXTERNAL yamop COMPLETION[1];
|
||||||
|
#ifdef THREADS_CONSUMER_SHARING
|
||||||
|
EXTERNAL yamop ANSWER_RESOLUTION_COMPLETION[1];
|
||||||
|
#endif /* THREADS_CONSUMER_SHARING */
|
||||||
|
#endif /* TABLING */
|
||||||
|
/* */
|
||||||
|
/* PREG just before we enter $spy. We use that to find out the clause which */
|
||||||
|
/* was calling the debugged goal. */
|
||||||
|
/* */
|
||||||
|
EXTERNAL yamop *P_before_spy;
|
||||||
|
/* support recorded_k */
|
||||||
|
EXTERNAL yamop *RETRY_C_RECORDEDP_CODE;
|
||||||
|
EXTERNAL yamop *RETRY_C_RECORDED_K_CODE;
|
||||||
|
/* compiler flags */
|
||||||
|
EXTERNAL int PROFILING;
|
||||||
|
EXTERNAL int CALL_COUNTING;
|
||||||
|
EXTERNAL int optimizer_on;
|
||||||
|
EXTERNAL int compile_mode;
|
||||||
|
EXTERNAL int profiling;
|
||||||
|
EXTERNAL int call_counting;
|
||||||
|
/********* whether we should try to compile array references ******************/
|
||||||
|
EXTERNAL int compile_arrays;
|
||||||
|
/* DBTerms: pre-compiled ground terms */
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
EXTERNAL lockvar DBTermsListLock;
|
||||||
|
#endif
|
||||||
|
EXTERNAL struct dbterm_list *DBTermsList;
|
||||||
|
/* JITI support */
|
||||||
|
EXTERNAL yamop *ExpandClausesFirst;
|
||||||
|
EXTERNAL yamop *ExpandClausesLast;
|
||||||
|
EXTERNAL UInt Yap_ExpandClauses;
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
EXTERNAL lockvar ExpandClausesListLock;
|
||||||
|
EXTERNAL lockvar OpListLock;
|
||||||
|
#endif
|
||||||
|
/* instrumentation */
|
||||||
|
#ifdef DEBUG
|
||||||
|
EXTERNAL UInt Yap_NewCps;
|
||||||
|
EXTERNAL UInt Yap_LiveCps;
|
||||||
|
EXTERNAL UInt Yap_DirtyCps;
|
||||||
|
EXTERNAL UInt Yap_FreedCps;
|
||||||
|
#endif
|
||||||
|
EXTERNAL UInt Yap_expand_clauses_sz;
|
||||||
|
/* UDI support */
|
||||||
|
EXTERNAL struct udi_info *UdiControlBlocks;
|
||||||
|
/* data-base statistics */
|
||||||
|
/* system boots in compile mode */
|
||||||
|
EXTERNAL Int STATIC_PREDICATES_MARKED;
|
||||||
|
/* Internal Database */
|
||||||
|
EXTERNAL Prop *INT_KEYS;
|
||||||
|
EXTERNAL Prop *INT_LU_KEYS;
|
||||||
|
EXTERNAL Prop *INT_BB_KEYS;
|
||||||
|
/* Internal Database Statistics */
|
||||||
|
EXTERNAL UInt INT_KEYS_SIZE;
|
||||||
|
EXTERNAL UInt INT_KEYS_TIMESTAMP;
|
||||||
|
EXTERNAL UInt INT_BB_KEYS_SIZE;
|
||||||
|
/* Internal Data-Base Control */
|
||||||
|
EXTERNAL int UPDATE_MODE;
|
||||||
|
/* nasty IDB stuff */
|
||||||
|
EXTERNAL struct DB_STRUCT *DBErasedMarker;
|
||||||
|
EXTERNAL struct logic_upd_clause *LogDBErasedMarker;
|
||||||
|
/* Dead clauses and IDB entries */
|
||||||
|
EXTERNAL struct static_clause *DeadStaticClauses;
|
||||||
|
EXTERNAL struct static_mega_clause *DeadMegaClauses;
|
||||||
|
EXTERNAL struct static_index *DeadStaticIndices;
|
||||||
|
EXTERNAL struct logic_upd_clause *DBErasedList;
|
||||||
|
EXTERNAL struct logic_upd_index *DBErasedIList;
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
EXTERNAL lockvar DeadStaticClausesLock;
|
||||||
|
EXTERNAL lockvar DeadMegaClausesLock;
|
||||||
|
EXTERNAL lockvar DeadStaticIndicesLock;
|
||||||
|
#endif
|
||||||
|
#ifdef COROUTINING
|
||||||
|
/* number of attribute modules */
|
||||||
|
EXTERNAL int NUM_OF_ATTS;
|
||||||
|
/* initialised by memory allocator */
|
||||||
|
EXTERNAL UInt Yap_AttsSize;
|
||||||
|
#endif
|
||||||
|
/* Operators */
|
||||||
|
EXTERNAL struct operator_entry *OpList;
|
||||||
|
/* foreign code loaded */
|
||||||
|
EXTERNAL struct ForeignLoadItem *ForeignCodeLoaded;
|
||||||
|
EXTERNAL ADDR ForeignCodeBase;
|
||||||
|
EXTERNAL ADDR ForeignCodeTop;
|
||||||
|
EXTERNAL ADDR ForeignCodeMax;
|
||||||
|
/* recorded terms */
|
||||||
|
EXTERNAL struct record_list *Yap_Records;
|
||||||
|
/* SWI atoms and functors */
|
||||||
|
EXTERNAL Atom *SWI_Atoms;
|
||||||
|
EXTERNAL Functor *SWI_Functors;
|
||||||
|
EXTERNAL swi_rev_hash SWI_ReverseHash[N_SWI_HASH];
|
||||||
|
/* integer access to atoms */
|
||||||
|
EXTERNAL Int AtomTranslations;
|
||||||
|
EXTERNAL Int MaxAtomTranslations;
|
||||||
|
/* integer access to functors */
|
||||||
|
EXTERNAL Int FunctorTranslations;
|
||||||
|
EXTERNAL Int MaxFunctorTranslations;
|
||||||
|
EXTERNAL Atom EmptyWakeups[MAX_EMPTY_WAKEUPS];
|
||||||
|
EXTERNAL int MaxEmptyWakeups;
|
||||||
|
/* SWI blobs */
|
||||||
|
EXTERNAL struct YAP_blob_t *BlobTypes;
|
||||||
|
EXTERNAL struct AtomEntryStruct *Blobs;
|
||||||
|
EXTERNAL UInt NOfBlobs;
|
||||||
|
EXTERNAL UInt NOfBlobsMax;
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
EXTERNAL lockvar Blobs_Lock;
|
||||||
|
#endif
|
||||||
|
|
@ -2,66 +2,66 @@
|
|||||||
/* This file, hglobals.h, was generated automatically by "yap -L misc/buildlocalglobal"
|
/* 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 misc/GLOBALS instead */
|
||||||
|
|
||||||
|
//
|
||||||
|
// File defining fields in the Yap_GLOBAL global structure
|
||||||
|
//
|
||||||
|
// these fields used to spread all over the place, because they must be used in 3 ways:
|
||||||
|
// - they must be defined somewhere
|
||||||
|
// - they have an #ifdef to get a shorter name
|
||||||
|
// - they must be initialised somewhere
|
||||||
|
// - they may be of interest to restore
|
||||||
|
//
|
||||||
|
// The defs include 3+ components:
|
||||||
|
// Type
|
||||||
|
// name in structured / global name
|
||||||
|
// init code (optional)
|
||||||
|
// restore code (optional)
|
||||||
|
//
|
||||||
|
// Stuff that must be shared by all threads or workers
|
||||||
typedef struct global_data {
|
typedef struct global_data {
|
||||||
|
// initialization: tell whether the system has been initialised and by whom.
|
||||||
int Initialised_;
|
int Initialised_;
|
||||||
int InitialisedFromPL_;
|
int InitialisedFromPL_;
|
||||||
int PL_Argc_;
|
int PL_Argc_;
|
||||||
char** PL_Argv_;
|
char** PL_Argv_;
|
||||||
bool FAST_BOOT_FLAG_;
|
bool FAST_BOOT_FLAG_;
|
||||||
|
// halt hooks
|
||||||
struct halt_hook* HaltHooks_;
|
struct halt_hook* HaltHooks_;
|
||||||
fptr_t JIT_finalizer_;
|
fptr_t JIT_finalizer_;
|
||||||
|
// stack overflow expansion/gc control
|
||||||
int AllowLocalExpansion_;
|
int AllowLocalExpansion_;
|
||||||
int AllowGlobalExpansion_;
|
int AllowGlobalExpansion_;
|
||||||
int AllowTrailExpansion_;
|
int AllowTrailExpansion_;
|
||||||
UInt SizeOfOverflow_;
|
UInt SizeOfOverflow_;
|
||||||
|
// amount of space recovered in all garbage collections
|
||||||
UInt AGcThreshold_;
|
UInt AGcThreshold_;
|
||||||
Agc_hook AGCHook_;
|
Agc_hook AGCHook_;
|
||||||
#if __ANDROID__
|
#if __ANDROID__
|
||||||
|
// no need to perform initialization, it is done before we start the Prolog engine.
|
||||||
struct AAssetManager* assetManager_;
|
struct AAssetManager* assetManager_;
|
||||||
char* AssetsWD_;
|
char* AssetsWD_;
|
||||||
#endif
|
#endif
|
||||||
|
/* multi-thread support */
|
||||||
#if THREADS
|
#if THREADS
|
||||||
|
/* number of threads and processes in system */
|
||||||
UInt NOfThreads_;
|
UInt NOfThreads_;
|
||||||
|
/* number of threads created since start */
|
||||||
UInt NOfThreadsCreated_;
|
UInt NOfThreadsCreated_;
|
||||||
|
/* total run time for dead threads */
|
||||||
UInt ThreadsTotalTime_;
|
UInt ThreadsTotalTime_;
|
||||||
|
// Threads Array
|
||||||
lockvar ThreadHandlesLock_;
|
lockvar ThreadHandlesLock_;
|
||||||
#endif
|
#endif
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
// protect long critical regions
|
||||||
lockvar BGL_;
|
lockvar BGL_;
|
||||||
#endif
|
#endif
|
||||||
#if defined(YAPOR) || defined(TABLING)
|
#if defined(YAPOR) || defined(TABLING)
|
||||||
struct global_optyap_data optyap_data_;
|
struct global_optyap_data optyap_data_;
|
||||||
#endif /* YAPOR || TABLING */
|
#endif /* YAPOR || TABLING */
|
||||||
|
// whether Yap is responsible for signal handling
|
||||||
int PrologShouldHandleInterrupts_;
|
int PrologShouldHandleInterrupts_;
|
||||||
|
/* This is the guy who actually started the system, and who has the correct registers */
|
||||||
#if defined(THREADS)
|
#if defined(THREADS)
|
||||||
pthread_t master_thread_;
|
pthread_t master_thread_;
|
||||||
struct thread_mbox* named_mboxes_;
|
struct thread_mbox* named_mboxes_;
|
||||||
@ -69,39 +69,39 @@ typedef struct global_data {
|
|||||||
UInt mbox_count_;
|
UInt mbox_count_;
|
||||||
struct swi_mutex* WithMutex_;
|
struct swi_mutex* WithMutex_;
|
||||||
#endif /* THREADS */
|
#endif /* THREADS */
|
||||||
|
// streams
|
||||||
struct stream_desc* Stream_;
|
struct stream_desc* Stream_;
|
||||||
#if defined(THREADS)||defined(YAPOR)
|
#if defined(THREADS)||defined(YAPOR)
|
||||||
lockvar StreamDescLock_;
|
lockvar StreamDescLock_;
|
||||||
#endif
|
#endif
|
||||||
|
// access to yap initial arguments
|
||||||
char** argv_;
|
char** argv_;
|
||||||
int argc_;
|
int argc_;
|
||||||
|
// extensions to Terms
|
||||||
#ifdef COROUTINING
|
#ifdef COROUTINING
|
||||||
|
/* array with the ops for your favourite extensions */
|
||||||
ext_op attas_[attvars_ext+1];
|
ext_op attas_[attvars_ext+1];
|
||||||
#endif
|
#endif
|
||||||
|
// agc.c
|
||||||
int agc_calls_;
|
int agc_calls_;
|
||||||
YAP_ULONG_LONG agc_collected_;
|
YAP_ULONG_LONG agc_collected_;
|
||||||
|
/* total time spent in GC */
|
||||||
Int tot_agc_time_;
|
Int tot_agc_time_;
|
||||||
|
/* number of heap objects in all garbage collections */
|
||||||
Int tot_agc_recovered_;
|
Int tot_agc_recovered_;
|
||||||
|
//arrays.c
|
||||||
#if HAVE_MMAP
|
#if HAVE_MMAP
|
||||||
struct MMAP_ARRAY_BLOCK* mmap_arrays_;
|
struct MMAP_ARRAY_BLOCK* mmap_arrays_;
|
||||||
#endif
|
#endif
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
//computils.c
|
||||||
char Option_[20];
|
char Option_[20];
|
||||||
YP_FILE* logfile_;
|
YP_FILE* logfile_;
|
||||||
|
//init.c
|
||||||
|
//int output_msg =FALSE
|
||||||
#endif
|
#endif
|
||||||
#if defined(COFF) || defined(A_OUT)
|
#if defined(COFF) || defined(A_OUT)
|
||||||
|
// loada_coff.c && load_aout.c
|
||||||
char Executable_[YAP_FILENAME_MAX];
|
char Executable_[YAP_FILENAME_MAX];
|
||||||
#endif
|
#endif
|
||||||
int OpaqueHandlersCount_;
|
int OpaqueHandlersCount_;
|
||||||
@ -109,10 +109,10 @@ typedef struct global_data {
|
|||||||
#if __simplescalar__
|
#if __simplescalar__
|
||||||
char pwd_[YAP_FILENAME_MAX];
|
char pwd_[YAP_FILENAME_MAX];
|
||||||
#endif
|
#endif
|
||||||
|
//udi.c
|
||||||
|
//struct udi_control_block RtreeCmd void
|
||||||
char* RestoreFile_;
|
char* RestoreFile_;
|
||||||
|
//gprof.c
|
||||||
Int ProfCalls_;
|
Int ProfCalls_;
|
||||||
Int ProfGCs_;
|
Int ProfGCs_;
|
||||||
Int ProfHGrows_;
|
Int ProfHGrows_;
|
||||||
@ -129,16 +129,18 @@ typedef struct global_data {
|
|||||||
FILE* FProf_;
|
FILE* FProf_;
|
||||||
FILE* FPreds_;
|
FILE* FPreds_;
|
||||||
#endif /* LOW_PROF */
|
#endif /* LOW_PROF */
|
||||||
|
// Mutexes
|
||||||
#if THREADS
|
#if THREADS
|
||||||
struct swi_mutex* FreeMutexes_;
|
struct swi_mutex* FreeMutexes_;
|
||||||
struct swi_mutex* mutex_backbone_;
|
struct swi_mutex* mutex_backbone_;
|
||||||
lockvar MUT_ACCESS_;
|
lockvar MUT_ACCESS_;
|
||||||
#endif
|
#endif
|
||||||
char* Home_;
|
char* Home_;
|
||||||
|
/* ISO char conversion: I will make no comments */
|
||||||
char* CharConversionTable_;
|
char* CharConversionTable_;
|
||||||
char* CharConversionTable2_;
|
char* CharConversionTable2_;
|
||||||
|
/* time */
|
||||||
void* LastWTimePtr_;
|
void* LastWTimePtr_;
|
||||||
|
/* max priority */
|
||||||
|
int MaxPriority_;
|
||||||
} w_shared;
|
} w_shared;
|
@ -2,9 +2,9 @@
|
|||||||
/* This file, hlocals.h, was generated automatically by "yap -L misc/buildlocalglobal"
|
/* 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 misc/LOCALS instead */
|
||||||
|
|
||||||
|
// Stuff that must be considered local to a thread or worker
|
||||||
typedef struct worker_local {
|
typedef struct worker_local {
|
||||||
|
// Streams
|
||||||
struct AliasDescS* FileAliases_;
|
struct AliasDescS* FileAliases_;
|
||||||
int NOfFileAliases_;
|
int NOfFileAliases_;
|
||||||
int SzOfFileAliases_;
|
int SzOfFileAliases_;
|
||||||
@ -13,10 +13,10 @@ typedef struct worker_local {
|
|||||||
int c_error_stream_;
|
int c_error_stream_;
|
||||||
bool sockets_io_;
|
bool sockets_io_;
|
||||||
bool within_print_message_;
|
bool within_print_message_;
|
||||||
|
//
|
||||||
|
// Used by the prompts to check if they are after a newline, and then a
|
||||||
|
// prompt should be output, or if we are in the middle of a line.
|
||||||
|
//
|
||||||
bool newline_;
|
bool newline_;
|
||||||
Atom AtPrompt_;
|
Atom AtPrompt_;
|
||||||
char Prompt_[MAX_PROMPT+1];
|
char Prompt_[MAX_PROMPT+1];
|
||||||
@ -27,7 +27,7 @@ typedef struct worker_local {
|
|||||||
UInt max_depth_;
|
UInt max_depth_;
|
||||||
UInt max_list_;
|
UInt max_list_;
|
||||||
UInt max_write_args_;
|
UInt max_write_args_;
|
||||||
|
// Restore info
|
||||||
CELL* OldASP_;
|
CELL* OldASP_;
|
||||||
CELL* OldLCL0_;
|
CELL* OldLCL0_;
|
||||||
tr_fr_ptr OldTR_;
|
tr_fr_ptr OldTR_;
|
||||||
@ -48,26 +48,26 @@ typedef struct worker_local {
|
|||||||
Int XDiff_;
|
Int XDiff_;
|
||||||
Int DelayDiff_;
|
Int DelayDiff_;
|
||||||
Int BaseDiff_;
|
Int BaseDiff_;
|
||||||
|
// Reduction counters
|
||||||
YAP_ULONG_LONG ReductionsCounter_;
|
YAP_ULONG_LONG ReductionsCounter_;
|
||||||
YAP_ULONG_LONG PredEntriesCounter_;
|
YAP_ULONG_LONG PredEntriesCounter_;
|
||||||
YAP_ULONG_LONG RetriesCounter_;
|
YAP_ULONG_LONG RetriesCounter_;
|
||||||
int ReductionsCounterOn_;
|
int ReductionsCounterOn_;
|
||||||
int PredEntriesCounterOn_;
|
int PredEntriesCounterOn_;
|
||||||
int RetriesCounterOn_;
|
int RetriesCounterOn_;
|
||||||
|
// support for consulting files
|
||||||
|
/* current consult stack */
|
||||||
union CONSULT_OBJ* ConsultSp_;
|
union CONSULT_OBJ* ConsultSp_;
|
||||||
|
/* current maximum number of cells in consult stack */
|
||||||
UInt ConsultCapacity_;
|
UInt ConsultCapacity_;
|
||||||
|
/* top of consult stack */
|
||||||
union CONSULT_OBJ* ConsultBase_;
|
union CONSULT_OBJ* ConsultBase_;
|
||||||
|
/* low-water mark for consult */
|
||||||
union CONSULT_OBJ* ConsultLow_;
|
union CONSULT_OBJ* ConsultLow_;
|
||||||
Term VarNames_;
|
Term VarNames_;
|
||||||
Atom SourceFileName_;
|
Atom SourceFileName_;
|
||||||
UInt SourceFileLineno_;
|
UInt SourceFileLineno_;
|
||||||
|
//global variables
|
||||||
Term GlobalArena_;
|
Term GlobalArena_;
|
||||||
UInt GlobalArenaOverflows_;
|
UInt GlobalArenaOverflows_;
|
||||||
Int ArenaOverflows_;
|
Int ArenaOverflows_;
|
||||||
@ -92,7 +92,7 @@ typedef struct worker_local {
|
|||||||
Term WokenGoals_;
|
Term WokenGoals_;
|
||||||
Term AttsMutableList_;
|
Term AttsMutableList_;
|
||||||
#endif
|
#endif
|
||||||
|
// gc_stuff
|
||||||
Term GcGeneration_;
|
Term GcGeneration_;
|
||||||
Term GcPhase_;
|
Term GcPhase_;
|
||||||
UInt GcCurrentPhase_;
|
UInt GcCurrentPhase_;
|
||||||
@ -102,7 +102,7 @@ typedef struct worker_local {
|
|||||||
Int LastGcTime_;
|
Int LastGcTime_;
|
||||||
Int LastSSTime_;
|
Int LastSSTime_;
|
||||||
CELL* OpenArray_;
|
CELL* OpenArray_;
|
||||||
|
/* in a single gc */
|
||||||
Int total_marked_;
|
Int total_marked_;
|
||||||
Int total_oldies_;
|
Int total_oldies_;
|
||||||
struct choicept* current_B_;
|
struct choicept* current_B_;
|
||||||
@ -135,16 +135,16 @@ typedef struct worker_local {
|
|||||||
struct static_array_entry* StaticArrays_;
|
struct static_array_entry* StaticArrays_;
|
||||||
struct global_entry* GlobalVariables_;
|
struct global_entry* GlobalVariables_;
|
||||||
int AllowRestart_;
|
int AllowRestart_;
|
||||||
|
// Thread Local Area for Fast Storage of Intermediate Compiled Code
|
||||||
struct mem_blk* CMemFirstBlock_;
|
struct mem_blk* CMemFirstBlock_;
|
||||||
UInt CMemFirstBlockSz_;
|
UInt CMemFirstBlockSz_;
|
||||||
|
// Variable used by the compiler to store number of permanent vars in a clause
|
||||||
int nperm_;
|
int nperm_;
|
||||||
|
// Thread Local Area for Labels
|
||||||
Int* LabelFirstArray_;
|
Int* LabelFirstArray_;
|
||||||
UInt LabelFirstArraySz_;
|
UInt LabelFirstArraySz_;
|
||||||
|
// Thread Local Area for SWI-Prolog emulation routines.
|
||||||
|
// struct PL_local_data* PL_local_data_p =Yap_InitThreadIO(wid)
|
||||||
#ifdef THREADS
|
#ifdef THREADS
|
||||||
struct thandle ThreadHandle_;
|
struct thandle ThreadHandle_;
|
||||||
#endif /* THREADS */
|
#endif /* THREADS */
|
||||||
@ -158,7 +158,7 @@ typedef struct worker_local {
|
|||||||
Int total_choicepoints_;
|
Int total_choicepoints_;
|
||||||
#endif
|
#endif
|
||||||
int consult_level_;
|
int consult_level_;
|
||||||
|
// Variables related to memory allocation
|
||||||
ADDR LocalBase_;
|
ADDR LocalBase_;
|
||||||
ADDR GlobalBase_;
|
ADDR GlobalBase_;
|
||||||
ADDR TrailBase_;
|
ADDR TrailBase_;
|
||||||
@ -185,27 +185,27 @@ const char* Error_Function_;
|
|||||||
sigjmp_buf RestartEnv_;
|
sigjmp_buf RestartEnv_;
|
||||||
char FileNameBuf_[YAP_FILENAME_MAX];
|
char FileNameBuf_[YAP_FILENAME_MAX];
|
||||||
char FileNameBuf2_[YAP_FILENAME_MAX];
|
char FileNameBuf2_[YAP_FILENAME_MAX];
|
||||||
|
// Prolog State
|
||||||
UInt BreakLevel_;
|
UInt BreakLevel_;
|
||||||
Int PrologMode_;
|
Int PrologMode_;
|
||||||
int CritLocks_;
|
int CritLocks_;
|
||||||
|
// Prolog execution and state flags
|
||||||
union flagTerm* Flags_;
|
union flagTerm* Flags_;
|
||||||
UInt flagCount_;
|
UInt flagCount_;
|
||||||
|
//analyst.c
|
||||||
|
/* used to find out how many instructions of each kind are executed */
|
||||||
#ifdef ANALYST
|
#ifdef ANALYST
|
||||||
YAP_ULONG_LONG opcount_[_std_top+1];
|
YAP_ULONG_LONG opcount_[_std_top+1];
|
||||||
YAP_ULONG_LONG 2opcount[_std_top+1][_std_top+1]_;
|
YAP_ULONG_LONG 2opcount[_std_top+1][_std_top+1]_;
|
||||||
#endif /* ANALYST */
|
#endif /* ANALYST */
|
||||||
|
//dbase.c
|
||||||
struct db_globs* s_dbg_;
|
struct db_globs* s_dbg_;
|
||||||
|
//eval.c
|
||||||
yap_error_number matherror_;
|
yap_error_number matherror_;
|
||||||
Term mathtt_;
|
Term mathtt_;
|
||||||
char* mathstring_;
|
char* mathstring_;
|
||||||
yap_error_number CurrentError_;
|
yap_error_number CurrentError_;
|
||||||
|
//grow.c
|
||||||
int heap_overflows_;
|
int heap_overflows_;
|
||||||
Int total_heap_overflow_time_;
|
Int total_heap_overflow_time_;
|
||||||
int stack_overflows_;
|
int stack_overflows_;
|
||||||
@ -216,15 +216,15 @@ const char* Error_Function_;
|
|||||||
Int total_trail_overflow_time_;
|
Int total_trail_overflow_time_;
|
||||||
int atom_table_overflows_;
|
int atom_table_overflows_;
|
||||||
Int total_atom_table_overflow_time_;
|
Int total_atom_table_overflow_time_;
|
||||||
|
//load_dyld
|
||||||
#ifdef LOAD_DYLD
|
#ifdef LOAD_DYLD
|
||||||
int dl_errno_;
|
int dl_errno_;
|
||||||
#endif
|
#endif
|
||||||
|
//tracer.c
|
||||||
#ifdef LOW_LEVEL_TRACER
|
#ifdef LOW_LEVEL_TRACER
|
||||||
int do_trace_primitives_;
|
int do_trace_primitives_;
|
||||||
#endif
|
#endif
|
||||||
|
//quick loader
|
||||||
struct export_atom_hash_entry_struct *ExportAtomHashChain_;
|
struct export_atom_hash_entry_struct *ExportAtomHashChain_;
|
||||||
UInt ExportAtomHashTableSize_;
|
UInt ExportAtomHashTableSize_;
|
||||||
UInt ExportAtomHashTableNum_;
|
UInt ExportAtomHashTableNum_;
|
||||||
@ -252,25 +252,24 @@ const char* Error_Function_;
|
|||||||
UInt ImportDBRefHashTableSize_;
|
UInt ImportDBRefHashTableSize_;
|
||||||
UInt ImportDBRefHashTableNum_;
|
UInt ImportDBRefHashTableNum_;
|
||||||
yamop *ImportFAILCODE_;
|
yamop *ImportFAILCODE_;
|
||||||
Functor FunctorVar_;
|
|
||||||
#if __ANDROID__
|
#if __ANDROID__
|
||||||
|
// current virtual directory.
|
||||||
struct AAssetManager* assetManager_;
|
struct AAssetManager* assetManager_;
|
||||||
char* InAssetDir_;
|
char* InAssetDir_;
|
||||||
#endif
|
#endif
|
||||||
|
// exo indexing
|
||||||
UInt ibnds_[256];
|
UInt ibnds_[256];
|
||||||
struct index_t* exo_it_;
|
struct index_t* exo_it_;
|
||||||
CELL* exo_base_;
|
CELL* exo_base_;
|
||||||
UInt exo_arity_;
|
UInt exo_arity_;
|
||||||
UInt exo_arg_;
|
UInt exo_arg_;
|
||||||
|
// atom completion
|
||||||
struct scan_atoms* search_atoms_;
|
struct scan_atoms* search_atoms_;
|
||||||
|
// Slots
|
||||||
yhandle_t CurSlot_;
|
yhandle_t CurSlot_;
|
||||||
yhandle_t NSlots_;
|
yhandle_t NSlots_;
|
||||||
CELL* SlotBase_;
|
CELL* SlotBase_;
|
||||||
|
// Mutexes
|
||||||
struct swi_mutex* Mutexes_;
|
struct swi_mutex* Mutexes_;
|
||||||
Term SourceModule_;
|
Term SourceModule_;
|
||||||
Term Including_;
|
Term Including_;
|
303
H/heap/hstruct.h
Executable file
@ -0,0 +1,303 @@
|
|||||||
|
|
||||||
|
/* This file, hstruct.h, was generated automatically by "yap -L misc/buildlocalglobal"
|
||||||
|
please do not update, update misc/HEAPFIELDS instead */
|
||||||
|
|
||||||
|
//
|
||||||
|
// File defining fields in the Yap_heap_codes global structure
|
||||||
|
//
|
||||||
|
// these fields used to spread all over the place, because they must be used in 4 ways:
|
||||||
|
// - they must be defined somewhere
|
||||||
|
// - they have an #ifdef to get a shorter name
|
||||||
|
// - they must be initialised somewhere
|
||||||
|
// - they must be restorable and collectable (from the atom gc).
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// The defs include 4+ components:
|
||||||
|
// Type
|
||||||
|
// name in structured
|
||||||
|
// global name
|
||||||
|
// init code and restore code (optional)
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// MkAT (MkAtomTerm) cvts from a predefined atom to a term
|
||||||
|
// MkPred constructs a pred_entry
|
||||||
|
// MkOp gets an opcode
|
||||||
|
// void does nothing
|
||||||
|
// =VALUE inits as VALUE
|
||||||
|
// Init... sets up call to InitFunc
|
||||||
|
// Restore... sets up call to RestoreFunc
|
||||||
|
//
|
||||||
|
|
||||||
|
/* memory management */
|
||||||
|
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_;
|
||||||
|
/* execution info */
|
||||||
|
/* OPCODE REVERSE TABLE, needed to recover op tables */
|
||||||
|
#if USE_THREADED_CODE
|
||||||
|
op_entry *OP_RTABLE_;
|
||||||
|
#endif
|
||||||
|
/* popular opcodes */
|
||||||
|
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_;
|
||||||
|
/* atom tables */
|
||||||
|
UInt NOfAtoms_;
|
||||||
|
UInt AtomHashTableSize_;
|
||||||
|
UInt WideAtomHashTableSize_;
|
||||||
|
UInt NOfWideAtoms_;
|
||||||
|
AtomHashEntry INVISIBLECHAIN_;
|
||||||
|
AtomHashEntry *WideHashChain_;
|
||||||
|
AtomHashEntry *HashChain_;
|
||||||
|
/* use atom defs here */
|
||||||
|
#include "tatoms.h"
|
||||||
|
#ifdef EUROTRA
|
||||||
|
Term TermDollarU_;
|
||||||
|
#endif
|
||||||
|
//modules
|
||||||
|
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_;
|
||||||
|
//
|
||||||
|
// Module list
|
||||||
|
//
|
||||||
|
struct mod_entry *CurrentModules_;
|
||||||
|
// make sure we have the modules set at this point.
|
||||||
|
// don't actually want to define a field
|
||||||
|
|
||||||
|
// hidden predicates
|
||||||
|
Prop HIDDEN_PREDICATES_;
|
||||||
|
// make sure we have the streams set at this point.
|
||||||
|
// don't actually want to define a field
|
||||||
|
|
||||||
|
union flagTerm* GLOBAL_Flags_;
|
||||||
|
UInt GLOBAL_flagCount_;
|
||||||
|
/* Anderson's JIT */
|
||||||
|
yap_exec_mode Yap_ExecutionMode_;
|
||||||
|
/* The Predicate Hash Table: fast access to predicates. */
|
||||||
|
struct pred_entry **PredHash_;
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
rwlock_t PredHashRWLock_;
|
||||||
|
#endif
|
||||||
|
UInt PredsInHashTable_;
|
||||||
|
UInt PredHashTableSize_;
|
||||||
|
/* Well-Known Predicates */
|
||||||
|
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_;
|
||||||
|
/* low-level tracer */
|
||||||
|
#ifdef LOW_LEVEL_TRACER
|
||||||
|
int Yap_do_low_level_trace_;
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
lockvar Yap_low_level_trace_lock_;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
/* code management info */
|
||||||
|
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_;
|
||||||
|
/* static code: may be shared by many predicate or may be used for meta-execution */
|
||||||
|
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 */
|
||||||
|
/* */
|
||||||
|
/* PREG just before we enter $spy. We use that to find out the clause which */
|
||||||
|
/* was calling the debugged goal. */
|
||||||
|
/* */
|
||||||
|
yamop *P_before_spy_;
|
||||||
|
/* support recorded_k */
|
||||||
|
yamop *RETRY_C_RECORDEDP_CODE_;
|
||||||
|
yamop *RETRY_C_RECORDED_K_CODE_;
|
||||||
|
/* compiler flags */
|
||||||
|
int PROFILING_;
|
||||||
|
int CALL_COUNTING_;
|
||||||
|
int optimizer_on_;
|
||||||
|
int compile_mode_;
|
||||||
|
int profiling_;
|
||||||
|
int call_counting_;
|
||||||
|
/********* whether we should try to compile array references ******************/
|
||||||
|
int compile_arrays_;
|
||||||
|
/* DBTerms: pre-compiled ground terms */
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
lockvar DBTermsListLock_;
|
||||||
|
#endif
|
||||||
|
struct dbterm_list *DBTermsList_;
|
||||||
|
/* JITI support */
|
||||||
|
yamop *ExpandClausesFirst_;
|
||||||
|
yamop *ExpandClausesLast_;
|
||||||
|
UInt Yap_ExpandClauses_;
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
lockvar ExpandClausesListLock_;
|
||||||
|
lockvar OpListLock_;
|
||||||
|
#endif
|
||||||
|
/* instrumentation */
|
||||||
|
#ifdef DEBUG
|
||||||
|
UInt Yap_NewCps_;
|
||||||
|
UInt Yap_LiveCps_;
|
||||||
|
UInt Yap_DirtyCps_;
|
||||||
|
UInt Yap_FreedCps_;
|
||||||
|
#endif
|
||||||
|
UInt Yap_expand_clauses_sz_;
|
||||||
|
/* UDI support */
|
||||||
|
struct udi_info *UdiControlBlocks_;
|
||||||
|
/* data-base statistics */
|
||||||
|
/* system boots in compile mode */
|
||||||
|
Int STATIC_PREDICATES_MARKED_;
|
||||||
|
/* Internal Database */
|
||||||
|
Prop *INT_KEYS_;
|
||||||
|
Prop *INT_LU_KEYS_;
|
||||||
|
Prop *INT_BB_KEYS_;
|
||||||
|
/* Internal Database Statistics */
|
||||||
|
UInt INT_KEYS_SIZE_;
|
||||||
|
UInt INT_KEYS_TIMESTAMP_;
|
||||||
|
UInt INT_BB_KEYS_SIZE_;
|
||||||
|
/* Internal Data-Base Control */
|
||||||
|
int UPDATE_MODE_;
|
||||||
|
/* nasty IDB stuff */
|
||||||
|
struct DB_STRUCT *DBErasedMarker_;
|
||||||
|
struct logic_upd_clause *LogDBErasedMarker_;
|
||||||
|
/* Dead clauses and IDB entries */
|
||||||
|
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
|
||||||
|
/* number of attribute modules */
|
||||||
|
int NUM_OF_ATTS_;
|
||||||
|
/* initialised by memory allocator */
|
||||||
|
UInt Yap_AttsSize_;
|
||||||
|
#endif
|
||||||
|
/* Operators */
|
||||||
|
struct operator_entry *OpList_;
|
||||||
|
/* foreign code loaded */
|
||||||
|
struct ForeignLoadItem *ForeignCodeLoaded_;
|
||||||
|
ADDR ForeignCodeBase_;
|
||||||
|
ADDR ForeignCodeTop_;
|
||||||
|
ADDR ForeignCodeMax_;
|
||||||
|
/* recorded terms */
|
||||||
|
struct record_list *Yap_Records_;
|
||||||
|
/* SWI atoms and functors */
|
||||||
|
Atom *SWI_Atoms_;
|
||||||
|
Functor *SWI_Functors_;
|
||||||
|
swi_rev_hash SWI_ReverseHash_[N_SWI_HASH];
|
||||||
|
/* integer access to atoms */
|
||||||
|
Int AtomTranslations_;
|
||||||
|
Int MaxAtomTranslations_;
|
||||||
|
/* integer access to functors */
|
||||||
|
Int FunctorTranslations_;
|
||||||
|
Int MaxFunctorTranslations_;
|
||||||
|
Atom EmptyWakeups_[MAX_EMPTY_WAKEUPS];
|
||||||
|
int MaxEmptyWakeups_;
|
||||||
|
/* SWI blobs */
|
||||||
|
struct YAP_blob_t *BlobTypes_;
|
||||||
|
struct AtomEntryStruct *Blobs_;
|
||||||
|
UInt NOfBlobs_;
|
||||||
|
UInt NOfBlobsMax_;
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
lockvar Blobs_Lock_;
|
||||||
|
#endif
|
||||||
|
|
@ -141,4 +141,6 @@ static void InitGlobal(void) {
|
|||||||
GLOBAL_CharConversionTable2 = NULL;
|
GLOBAL_CharConversionTable2 = NULL;
|
||||||
|
|
||||||
GLOBAL_LastWTimePtr = NULL;
|
GLOBAL_LastWTimePtr = NULL;
|
||||||
|
|
||||||
|
GLOBAL_MaxPriority = 1200;
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
/* This file, ihstruct.h, was generated automatically by "yap -L misc/buildheap"
|
/* 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 misc/HEAPFIELDS instead */
|
||||||
|
|
||||||
|
|
||||||
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if USE_DL_MALLOC
|
#if USE_DL_MALLOC
|
||||||
@ -101,6 +102,7 @@
|
|||||||
SWI_MODULE = MkAtomTerm(AtomSwi);
|
SWI_MODULE = MkAtomTerm(AtomSwi);
|
||||||
DBLOAD_MODULE = MkAtomTerm(AtomDBLoad);
|
DBLOAD_MODULE = MkAtomTerm(AtomDBLoad);
|
||||||
RANGE_MODULE = MkAtomTerm(AtomRange);
|
RANGE_MODULE = MkAtomTerm(AtomRange);
|
||||||
|
ERROR_MODULE = MkAtomTerm(AtomError);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -150,8 +152,8 @@
|
|||||||
PredCommentHook = RepPredProp(PredPropByFunc(FunctorCommentHook,PROLOG_MODULE));
|
PredCommentHook = RepPredProp(PredPropByFunc(FunctorCommentHook,PROLOG_MODULE));
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
PredGetwork = RepPredProp(PredPropByAtom(AtomGetwork,PROLOG_MODULE));
|
PredGetwork = RepPredProp(PredPropByAtom(AtomGetwork,PROLOG_MODULE));
|
||||||
PredGetworkSeq = RepPredProp(PredPropByAtom(AtomGetworkSeq,PROLOG_MODULE));
|
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
|
PredProcedure = Yap_MkLogPred(RepPredProp(PredPropByFunc(FunctorProcedure,PROLOG_MODULE)));
|
||||||
|
|
||||||
#ifdef LOW_LEVEL_TRACER
|
#ifdef LOW_LEVEL_TRACER
|
||||||
Yap_do_low_level_trace = FALSE;
|
Yap_do_low_level_trace = FALSE;
|
||||||
@ -207,9 +209,6 @@
|
|||||||
|
|
||||||
PROFILING = FALSE;
|
PROFILING = FALSE;
|
||||||
CALL_COUNTING = FALSE;
|
CALL_COUNTING = FALSE;
|
||||||
PRED_GOAL_EXPANSION_ALL = FALSE;
|
|
||||||
PRED_GOAL_EXPANSION_FUNC = FALSE;
|
|
||||||
PRED_GOAL_EXPANSION_ON = FALSE;
|
|
||||||
optimizer_on = TRUE;
|
optimizer_on = TRUE;
|
||||||
compile_mode = 0;
|
compile_mode = 0;
|
||||||
profiling = FALSE;
|
profiling = FALSE;
|
||||||
@ -301,3 +300,4 @@
|
|||||||
#if defined(YAPOR) || defined(THREADS)
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
INIT_LOCK(Blobs_Lock);
|
INIT_LOCK(Blobs_Lock);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -252,7 +252,6 @@ static void InitWorker(int wid) {
|
|||||||
REMOTE_ImportDBRefHashTableSize(wid) = 0;
|
REMOTE_ImportDBRefHashTableSize(wid) = 0;
|
||||||
REMOTE_ImportDBRefHashTableNum(wid) = 0;
|
REMOTE_ImportDBRefHashTableNum(wid) = 0;
|
||||||
REMOTE_ImportFAILCODE(wid) = NULL;
|
REMOTE_ImportFAILCODE(wid) = NULL;
|
||||||
REMOTE_FunctorVar(wid) = FunctorVar;
|
|
||||||
#if __ANDROID__
|
#if __ANDROID__
|
||||||
|
|
||||||
REMOTE_assetManager(wid) = GLOBAL_assetManager;
|
REMOTE_assetManager(wid) = GLOBAL_assetManager;
|
@ -141,4 +141,6 @@ static void RestoreGlobal(void) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
/* This file, rhstruct.h, was generated automatically by "yap -L misc/buildheap"
|
/* 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 misc/HEAPFIELDS instead */
|
||||||
|
|
||||||
|
|
||||||
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if USE_DL_MALLOC
|
#if USE_DL_MALLOC
|
||||||
@ -101,6 +102,7 @@
|
|||||||
SWI_MODULE = AtomTermAdjust(SWI_MODULE);
|
SWI_MODULE = AtomTermAdjust(SWI_MODULE);
|
||||||
DBLOAD_MODULE = AtomTermAdjust(DBLOAD_MODULE);
|
DBLOAD_MODULE = AtomTermAdjust(DBLOAD_MODULE);
|
||||||
RANGE_MODULE = AtomTermAdjust(RANGE_MODULE);
|
RANGE_MODULE = AtomTermAdjust(RANGE_MODULE);
|
||||||
|
ERROR_MODULE = AtomTermAdjust(ERROR_MODULE);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -150,8 +152,8 @@
|
|||||||
PredCommentHook = PtoPredAdjust(PredCommentHook);
|
PredCommentHook = PtoPredAdjust(PredCommentHook);
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
PredGetwork = PtoPredAdjust(PredGetwork);
|
PredGetwork = PtoPredAdjust(PredGetwork);
|
||||||
PredGetworkSeq = PtoPredAdjust(PredGetworkSeq);
|
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
|
PredProcedure = PtoPredAdjust(PredProcedure);
|
||||||
|
|
||||||
#ifdef LOW_LEVEL_TRACER
|
#ifdef LOW_LEVEL_TRACER
|
||||||
|
|
||||||
@ -214,9 +216,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
REINIT_LOCK(DBTermsListLock);
|
REINIT_LOCK(DBTermsListLock);
|
||||||
#endif
|
#endif
|
||||||
@ -301,3 +300,4 @@
|
|||||||
#if defined(YAPOR) || defined(THREADS)
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
REINIT_LOCK(Blobs_Lock);
|
REINIT_LOCK(Blobs_Lock);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -250,7 +250,6 @@ static void RestoreWorker(int wid USES_REGS) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if __ANDROID__
|
#if __ANDROID__
|
303
H/hstruct.h
@ -1,303 +0,0 @@
|
|||||||
|
|
||||||
/* This file, hstruct.h, was generated automatically by "yap -L misc/buildheap"
|
|
||||||
please do not update, update misc/HEAPFIELDS instead */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
UInt hole_size;
|
|
||||||
struct malloc_state *av_;
|
|
||||||
#if USE_DL_MALLOC
|
|
||||||
struct memory_hole memory_holes[MAX_DLMALLOC_HOLES];
|
|
||||||
UInt nof_memory_holes;
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
lockvar dlmalloc_lock;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if USE_DL_MALLOC || (USE_SYSTEM_MALLOC && HAVE_MALLINFO)
|
|
||||||
#ifndef HeapUsed
|
|
||||||
#define HeapUsed Yap_givemallinfo()
|
|
||||||
#endif
|
|
||||||
Int heap_used;
|
|
||||||
#else
|
|
||||||
Int heap_used;
|
|
||||||
#endif
|
|
||||||
Int heap_max;
|
|
||||||
ADDR heap_top;
|
|
||||||
ADDR heap_lim;
|
|
||||||
struct FREEB *free_blocks;
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
lockvar free_blocks_lock;
|
|
||||||
lockvar heap_used_lock;
|
|
||||||
lockvar heap_top_lock;
|
|
||||||
int heap_top_owner;
|
|
||||||
#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_op;
|
|
||||||
OPCODE index_op;
|
|
||||||
OPCODE lockpred_op;
|
|
||||||
OPCODE orlast_op;
|
|
||||||
OPCODE undef_op;
|
|
||||||
OPCODE retry_userc_op;
|
|
||||||
OPCODE execute_cpred_op;
|
|
||||||
|
|
||||||
UInt n_of_atoms;
|
|
||||||
UInt atom_hash_table_size;
|
|
||||||
UInt wide_atom_hash_table_size;
|
|
||||||
UInt n_of_wide_atoms;
|
|
||||||
AtomHashEntry invisiblechain;
|
|
||||||
AtomHashEntry *wide_hash_chain;
|
|
||||||
AtomHashEntry *hash_chain;
|
|
||||||
|
|
||||||
#include "tatoms.h"
|
|
||||||
#ifdef EUROTRA
|
|
||||||
Term term_dollar_u;
|
|
||||||
#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;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct mod_entry *current_modules;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Prop hidden_predicates;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
union flagTerm* GLOBAL_Flags_;
|
|
||||||
UInt GLOBAL_flagCount_;
|
|
||||||
|
|
||||||
yap_exec_mode execution_mode;
|
|
||||||
|
|
||||||
struct pred_entry **pred_hash;
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
rwlock_t pred_hash_rw_lock;
|
|
||||||
#endif
|
|
||||||
UInt preds_in_hash_table;
|
|
||||||
UInt pred_hash_table_size;
|
|
||||||
|
|
||||||
struct pred_entry *creep_code;
|
|
||||||
struct pred_entry *undef_code;
|
|
||||||
struct pred_entry *spy_code;
|
|
||||||
struct pred_entry *pred_fail;
|
|
||||||
struct pred_entry *pred_true;
|
|
||||||
#ifdef COROUTINING
|
|
||||||
struct pred_entry *wake_up_code;
|
|
||||||
#endif
|
|
||||||
struct pred_entry *pred_goal_expansion;
|
|
||||||
struct pred_entry *pred_meta_call;
|
|
||||||
struct pred_entry *pred_trace_meta_call;
|
|
||||||
struct pred_entry *pred_dollar_catch;
|
|
||||||
struct pred_entry *pred_recorded_with_key;
|
|
||||||
struct pred_entry *pred_log_upd_clause;
|
|
||||||
struct pred_entry *pred_log_upd_clause_erase;
|
|
||||||
struct pred_entry *pred_log_upd_clause0;
|
|
||||||
struct pred_entry *pred_static_clause;
|
|
||||||
struct pred_entry *pred_throw;
|
|
||||||
struct pred_entry *pred_handle_throw;
|
|
||||||
struct pred_entry *pred_is;
|
|
||||||
struct pred_entry *pred_safe_call_cleanup;
|
|
||||||
struct pred_entry *pred_restore_regs;
|
|
||||||
struct pred_entry *pred_comment_hook;
|
|
||||||
#ifdef YAPOR
|
|
||||||
struct pred_entry *pred_getwork;
|
|
||||||
struct pred_entry *pred_getwork_seq;
|
|
||||||
#endif /* YAPOR */
|
|
||||||
|
|
||||||
#ifdef LOW_LEVEL_TRACER
|
|
||||||
int yap_do_low_level_trace;
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
lockvar low_level_trace_lock;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
UInt clause_space;
|
|
||||||
UInt index_space_Tree;
|
|
||||||
UInt index_space_EXT;
|
|
||||||
UInt index_space_SW;
|
|
||||||
UInt lu_clause_space;
|
|
||||||
UInt lu_index_space_Tree;
|
|
||||||
UInt lu_index_space_CP;
|
|
||||||
UInt lu_index_space_EXT;
|
|
||||||
UInt lu_index_space_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_code[1];
|
|
||||||
yamop getwork_seq_code[1];
|
|
||||||
yamop getwork_first_time[1];
|
|
||||||
#endif /* YAPOR */
|
|
||||||
#ifdef TABLING
|
|
||||||
yamop table_load_answer_code[1];
|
|
||||||
yamop table_try_answer_code[1];
|
|
||||||
yamop table_answer_resolution_code[1];
|
|
||||||
yamop table_completion_code[1];
|
|
||||||
#ifdef THREADS_CONSUMER_SHARING
|
|
||||||
yamop table_answer_resolution_completion_code[1];
|
|
||||||
#endif /* THREADS_CONSUMER_SHARING */
|
|
||||||
#endif /* TABLING */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
yamop *debugger_p_before_spy;
|
|
||||||
|
|
||||||
yamop *retry_recordedp_code;
|
|
||||||
yamop *retry_recorded_k_code;
|
|
||||||
|
|
||||||
int system_profiling;
|
|
||||||
int system_call_counting;
|
|
||||||
int system_pred_goal_expansion_all;
|
|
||||||
int system_pred_goal_expansion_func;
|
|
||||||
int system_pred_goal_expansion_on;
|
|
||||||
int compiler_optimizer_on;
|
|
||||||
int compiler_compile_mode;
|
|
||||||
int compiler_profiling;
|
|
||||||
int compiler_call_counting;
|
|
||||||
|
|
||||||
int compiler_compile_arrays;
|
|
||||||
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
lockvar dbterms_list_lock;
|
|
||||||
#endif
|
|
||||||
struct dbterm_list *dbterms_list;
|
|
||||||
|
|
||||||
yamop *expand_clauses_first;
|
|
||||||
yamop *expand_clauses_last;
|
|
||||||
UInt expand_clauses;
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
lockvar expand_clauses_list_lock;
|
|
||||||
lockvar op_list_lock;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
UInt new_cps;
|
|
||||||
UInt live_cps;
|
|
||||||
UInt dirty_cps;
|
|
||||||
UInt freed_cps;
|
|
||||||
#endif
|
|
||||||
UInt expand_clauses_sz;
|
|
||||||
|
|
||||||
struct udi_info *udi_control_blocks;
|
|
||||||
|
|
||||||
|
|
||||||
Int static_predicates_marked;
|
|
||||||
|
|
||||||
Prop *IntKeys;
|
|
||||||
Prop *IntLUKeys;
|
|
||||||
Prop *IntBBKeys;
|
|
||||||
|
|
||||||
UInt int_keys_size;
|
|
||||||
UInt int_keys_timestamp;
|
|
||||||
UInt int_bb_keys_size;
|
|
||||||
|
|
||||||
int update_mode;
|
|
||||||
|
|
||||||
struct DB_STRUCT *db_erased_marker;
|
|
||||||
struct logic_upd_clause *logdb_erased_marker;
|
|
||||||
|
|
||||||
struct static_clause *dead_static_clauses;
|
|
||||||
struct static_mega_clause *dead_mega_clauses;
|
|
||||||
struct static_index *dead_static_indices;
|
|
||||||
struct logic_upd_clause *db_erased_list;
|
|
||||||
struct logic_upd_index *db_erased_ilist;
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
lockvar dead_static_clauses_lock;
|
|
||||||
lockvar dead_mega_clauses_lock;
|
|
||||||
lockvar dead_static_indices_lock;
|
|
||||||
#endif
|
|
||||||
#ifdef COROUTINING
|
|
||||||
|
|
||||||
int num_of_atts;
|
|
||||||
|
|
||||||
UInt atts_size;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct operator_entry *op_list;
|
|
||||||
|
|
||||||
struct ForeignLoadItem *foreign_code_loaded;
|
|
||||||
ADDR foreign_code_base;
|
|
||||||
ADDR foreign_code_top;
|
|
||||||
ADDR foreign_code_max;
|
|
||||||
|
|
||||||
struct record_list *yap_records;
|
|
||||||
|
|
||||||
Atom *swi_atoms;
|
|
||||||
Functor *swi_functors;
|
|
||||||
struct swi_reverse_hash swi_reverse_hash[N_SWI_HASH];
|
|
||||||
|
|
||||||
Int atom_translations;
|
|
||||||
Int max_atom_translations;
|
|
||||||
|
|
||||||
Int functor_translations;
|
|
||||||
Int max_functor_translations;
|
|
||||||
Atom empty_wakeups[MAX_EMPTY_WAKEUPS];
|
|
||||||
int max_empty_wakeups;
|
|
||||||
|
|
||||||
struct YAP_blob_t *swi_blob_types;
|
|
||||||
struct AtomEntryStruct *swi_blobs;
|
|
||||||
UInt nofblobs;
|
|
||||||
UInt nofblobsmax;
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
lockvar blobs_lock;
|
|
||||||
#endif
|
|
17
H/iatoms.h
@ -20,11 +20,16 @@
|
|||||||
AtomArrayOverflow = Yap_LookupAtom("array_overflow");
|
AtomArrayOverflow = Yap_LookupAtom("array_overflow");
|
||||||
AtomArrayType = Yap_LookupAtom("array_type");
|
AtomArrayType = Yap_LookupAtom("array_type");
|
||||||
AtomArrow = Yap_LookupAtom("->");
|
AtomArrow = Yap_LookupAtom("->");
|
||||||
|
AtomAttributedModule = Yap_LookupAtom("attributes_module");
|
||||||
AtomDoubleArrow = Yap_LookupAtom("-->");
|
AtomDoubleArrow = Yap_LookupAtom("-->");
|
||||||
AtomAssert = Yap_LookupAtom(":-");
|
AtomAssert = Yap_LookupAtom(":-");
|
||||||
AtomEmptyBrackets = Yap_LookupAtom("()");
|
AtomEmptyBrackets = Yap_LookupAtom("()");
|
||||||
AtomEmptySquareBrackets = Yap_LookupAtom("[]");
|
AtomEmptySquareBrackets = Yap_LookupAtom("[]");
|
||||||
AtomEmptyCurlyBrackets = Yap_LookupAtom("{}");
|
AtomEmptyCurlyBrackets = Yap_LookupAtom("{}");
|
||||||
|
AtomAsserta = Yap_LookupAtom("asserta");
|
||||||
|
AtomAssertaStatic = Yap_LookupAtom("asserta_static");
|
||||||
|
AtomAssertz = Yap_LookupAtom("assertz");
|
||||||
|
AtomAssertzStatic = Yap_LookupAtom("assertz_static");
|
||||||
AtomAt = Yap_LookupAtom("at");
|
AtomAt = Yap_LookupAtom("at");
|
||||||
AtomAtom = Yap_LookupAtom("atom");
|
AtomAtom = Yap_LookupAtom("atom");
|
||||||
AtomAtomic = Yap_LookupAtom("atomic");
|
AtomAtomic = Yap_LookupAtom("atomic");
|
||||||
@ -66,6 +71,7 @@
|
|||||||
AtomCompact = Yap_LookupAtom("compact");
|
AtomCompact = Yap_LookupAtom("compact");
|
||||||
AtomCompound = Yap_LookupAtom("compound");
|
AtomCompound = Yap_LookupAtom("compound");
|
||||||
AtomConsistencyError = Yap_LookupAtom("consistency_error");
|
AtomConsistencyError = Yap_LookupAtom("consistency_error");
|
||||||
|
AtomConsult = Yap_LookupAtom("consult");
|
||||||
AtomConsultOnBoot = Yap_FullLookupAtom("$consult_on_boot");
|
AtomConsultOnBoot = Yap_FullLookupAtom("$consult_on_boot");
|
||||||
AtomContext = Yap_LookupAtom("context");
|
AtomContext = Yap_LookupAtom("context");
|
||||||
AtomCputime = Yap_LookupAtom("cputime");
|
AtomCputime = Yap_LookupAtom("cputime");
|
||||||
@ -102,6 +108,7 @@
|
|||||||
AtomDoStaticClause = Yap_FullLookupAtom("$do_static_clause");
|
AtomDoStaticClause = Yap_FullLookupAtom("$do_static_clause");
|
||||||
AtomDots = Yap_LookupAtom("dots");
|
AtomDots = Yap_LookupAtom("dots");
|
||||||
AtomDOUBLE = Yap_FullLookupAtom("Double");
|
AtomDOUBLE = Yap_FullLookupAtom("Double");
|
||||||
|
AtomDoubleSlash = Yap_FullLookupAtom("//");
|
||||||
AtomE = Yap_LookupAtom("e");
|
AtomE = Yap_LookupAtom("e");
|
||||||
AtomEOFBeforeEOT = Yap_LookupAtom("end_of_file_found_before_end_of_term");
|
AtomEOFBeforeEOT = Yap_LookupAtom("end_of_file_found_before_end_of_term");
|
||||||
AtomEQ = Yap_LookupAtom("=");
|
AtomEQ = Yap_LookupAtom("=");
|
||||||
@ -133,6 +140,7 @@
|
|||||||
AtomFail = Yap_LookupAtom("fail");
|
AtomFail = Yap_LookupAtom("fail");
|
||||||
AtomFalse = Yap_LookupAtom("false");
|
AtomFalse = Yap_LookupAtom("false");
|
||||||
AtomFast = Yap_FullLookupAtom("$fast");
|
AtomFast = Yap_FullLookupAtom("$fast");
|
||||||
|
AtomFastFail = Yap_LookupAtom("fast_fail");
|
||||||
AtomFileErrors = Yap_LookupAtom("file_errors");
|
AtomFileErrors = Yap_LookupAtom("file_errors");
|
||||||
AtomFileerrors = Yap_LookupAtom("fileerrors");
|
AtomFileerrors = Yap_LookupAtom("fileerrors");
|
||||||
AtomFileType = Yap_LookupAtom("file_type");
|
AtomFileType = Yap_LookupAtom("file_type");
|
||||||
@ -288,6 +296,7 @@
|
|||||||
AtomReadOnly = Yap_LookupAtom("read_only");
|
AtomReadOnly = Yap_LookupAtom("read_only");
|
||||||
AtomReadWrite = Yap_LookupAtom("read_write");
|
AtomReadWrite = Yap_LookupAtom("read_write");
|
||||||
AtomReadutil = Yap_LookupAtom("readutil");
|
AtomReadutil = Yap_LookupAtom("readutil");
|
||||||
|
AtomReconsult = Yap_LookupAtom("reconsult");
|
||||||
AtomRecordedP = Yap_FullLookupAtom("$recordep");
|
AtomRecordedP = Yap_FullLookupAtom("$recordep");
|
||||||
AtomRecordedWithKey = Yap_FullLookupAtom("$recorded_with_key");
|
AtomRecordedWithKey = Yap_FullLookupAtom("$recorded_with_key");
|
||||||
AtomRedefineWarnings = Yap_LookupAtom("redefine_warnings");
|
AtomRedefineWarnings = Yap_LookupAtom("redefine_warnings");
|
||||||
@ -390,14 +399,16 @@
|
|||||||
AtomUserErr = Yap_LookupAtom("user_error");
|
AtomUserErr = Yap_LookupAtom("user_error");
|
||||||
AtomUserIn = Yap_LookupAtom("user_input");
|
AtomUserIn = Yap_LookupAtom("user_input");
|
||||||
AtomUserOut = Yap_LookupAtom("user_output");
|
AtomUserOut = Yap_LookupAtom("user_output");
|
||||||
|
AtomDollarVar = Yap_LookupAtom("$VAR");
|
||||||
AtomVBar = Yap_LookupAtom("|");
|
AtomVBar = Yap_LookupAtom("|");
|
||||||
AtomVar = Yap_FullLookupAtom("$VAR");
|
|
||||||
AtomVarBranches = Yap_LookupAtom("var_branches");
|
AtomVarBranches = Yap_LookupAtom("var_branches");
|
||||||
AtomVariableNames = Yap_LookupAtom("variable_names");
|
AtomVariableNames = Yap_LookupAtom("variable_names");
|
||||||
AtomHiddenVar = Yap_FullLookupAtom("$V");
|
AtomHiddenVar = Yap_FullLookupAtom("$V");
|
||||||
AtomVariable = Yap_LookupAtom("variable");
|
AtomVariable = Yap_LookupAtom("variable");
|
||||||
|
AtomVerbose = Yap_LookupAtom("verbose");
|
||||||
AtomVerboseFileSearch = Yap_LookupAtom("verbose_file_search");
|
AtomVerboseFileSearch = Yap_LookupAtom("verbose_file_search");
|
||||||
AtomVersionNumber = Yap_FullLookupAtom("$version_name");
|
AtomVersionNumber = Yap_FullLookupAtom("$version_name");
|
||||||
|
AtomVeryVerbose = Yap_LookupAtom("very_verbose");
|
||||||
AtomWakeUpGoal = Yap_FullLookupAtom("$wake_up_goal");
|
AtomWakeUpGoal = Yap_FullLookupAtom("$wake_up_goal");
|
||||||
AtomWarning = Yap_LookupAtom("warning");
|
AtomWarning = Yap_LookupAtom("warning");
|
||||||
AtomWhen = Yap_FullLookupAtom("$when");
|
AtomWhen = Yap_FullLookupAtom("$when");
|
||||||
@ -443,6 +454,7 @@
|
|||||||
FunctorDoLogUpdClause0 = Yap_MkFunctor(AtomDoLogUpdClause0,6);
|
FunctorDoLogUpdClause0 = Yap_MkFunctor(AtomDoLogUpdClause0,6);
|
||||||
FunctorDoLogUpdClauseErase = Yap_MkFunctor(AtomDoLogUpdClauseErase,6);
|
FunctorDoLogUpdClauseErase = Yap_MkFunctor(AtomDoLogUpdClauseErase,6);
|
||||||
FunctorDoStaticClause = Yap_MkFunctor(AtomDoStaticClause,5);
|
FunctorDoStaticClause = Yap_MkFunctor(AtomDoStaticClause,5);
|
||||||
|
FunctorDollarVar = Yap_MkFunctor(AtomDollarVar,1);
|
||||||
FunctorDomainError = Yap_MkFunctor(AtomDomainError,2);
|
FunctorDomainError = Yap_MkFunctor(AtomDomainError,2);
|
||||||
FunctorDot = Yap_MkFunctor(AtomDot,2);
|
FunctorDot = Yap_MkFunctor(AtomDot,2);
|
||||||
FunctorDot10 = Yap_MkFunctor(AtomDot,10);
|
FunctorDot10 = Yap_MkFunctor(AtomDot,10);
|
||||||
@ -456,6 +468,7 @@
|
|||||||
FunctorDot7 = Yap_MkFunctor(AtomDot,7);
|
FunctorDot7 = Yap_MkFunctor(AtomDot,7);
|
||||||
FunctorDot8 = Yap_MkFunctor(AtomDot,8);
|
FunctorDot8 = Yap_MkFunctor(AtomDot,8);
|
||||||
FunctorDot9 = Yap_MkFunctor(AtomDot,9);
|
FunctorDot9 = Yap_MkFunctor(AtomDot,9);
|
||||||
|
FunctorDoubleSlash = Yap_MkFunctor(AtomDoubleSlash,2);
|
||||||
FunctorEmptySquareBrackets = Yap_MkFunctor(AtomEmptySquareBrackets,2);
|
FunctorEmptySquareBrackets = Yap_MkFunctor(AtomEmptySquareBrackets,2);
|
||||||
FunctorEmptyCurlyBrackets = Yap_MkFunctor(AtomEmptyCurlyBrackets,2);
|
FunctorEmptyCurlyBrackets = Yap_MkFunctor(AtomEmptyCurlyBrackets,2);
|
||||||
FunctorEq = Yap_MkFunctor(AtomEq,2);
|
FunctorEq = Yap_MkFunctor(AtomEq,2);
|
||||||
@ -501,6 +514,7 @@
|
|||||||
FunctorPlus = Yap_MkFunctor(AtomPlus,2);
|
FunctorPlus = Yap_MkFunctor(AtomPlus,2);
|
||||||
FunctorPortray = Yap_MkFunctor(AtomPortray,1);
|
FunctorPortray = Yap_MkFunctor(AtomPortray,1);
|
||||||
FunctorPrintMessage = Yap_MkFunctor(AtomPrintMessage,2);
|
FunctorPrintMessage = Yap_MkFunctor(AtomPrintMessage,2);
|
||||||
|
FunctorProcedure = Yap_MkFunctor(AtomProcedure,5);
|
||||||
FunctorPrologConstraint = Yap_MkFunctor(AtomProlog,2);
|
FunctorPrologConstraint = Yap_MkFunctor(AtomProlog,2);
|
||||||
FunctorQuery = Yap_MkFunctor(AtomQuery,1);
|
FunctorQuery = Yap_MkFunctor(AtomQuery,1);
|
||||||
FunctorRecordedWithKey = Yap_MkFunctor(AtomRecordedWithKey,6);
|
FunctorRecordedWithKey = Yap_MkFunctor(AtomRecordedWithKey,6);
|
||||||
@ -531,5 +545,4 @@
|
|||||||
FunctorUMinus = Yap_MkFunctor(AtomMinus,1);
|
FunctorUMinus = Yap_MkFunctor(AtomMinus,1);
|
||||||
FunctorUPlus = Yap_MkFunctor(AtomPlus,1);
|
FunctorUPlus = Yap_MkFunctor(AtomPlus,1);
|
||||||
FunctorVBar = Yap_MkFunctor(AtomVBar,2);
|
FunctorVBar = Yap_MkFunctor(AtomVBar,2);
|
||||||
FunctorVar = Yap_MkFunctor(AtomVar,1);
|
|
||||||
FunctorHiddenVar = Yap_MkFunctor(AtomHiddenVar,1);
|
FunctorHiddenVar = Yap_MkFunctor(AtomHiddenVar,1);
|
||||||
|
2
H/qly.h
@ -104,7 +104,7 @@ typedef enum {
|
|||||||
#define STATIC_PRED_FLAGS (SourcePredFlag|DynamicPredFlag|LogUpdatePredFlag|CompiledPredFlag|MultiFileFlag|TabledPredFlag|MegaClausePredFlag|CountPredFlag|ProfiledPredFlag|ThreadLocalPredFlag|AtomDBPredFlag|ModuleTransparentPredFlag|NumberDBPredFlag|MetaPredFlag|SyncPredFlag|BackCPredFlag)
|
#define STATIC_PRED_FLAGS (SourcePredFlag|DynamicPredFlag|LogUpdatePredFlag|CompiledPredFlag|MultiFileFlag|TabledPredFlag|MegaClausePredFlag|CountPredFlag|ProfiledPredFlag|ThreadLocalPredFlag|AtomDBPredFlag|ModuleTransparentPredFlag|NumberDBPredFlag|MetaPredFlag|SyncPredFlag|BackCPredFlag)
|
||||||
#define EXTRA_PRED_FLAGS (QuasiQuotationPredFlag|NoTracePredFlag|NoSpyPredFlag)
|
#define EXTRA_PRED_FLAGS (QuasiQuotationPredFlag|NoTracePredFlag|NoSpyPredFlag)
|
||||||
|
|
||||||
#define SYSTEM_PRED_FLAGS (BackCPredFlag|UserCPredFlag|CArgsPredFlag|AsmPredFlag|CPredFlag|BinaryPredFlag|StandardPredFlag)
|
#define SYSTEM_PRED_FLAGS (BackCPredFlag|UserCPredFlag|CArgsPredFlag|AsmPredFlag|CPredFlag|BinaryPredFlag)
|
||||||
|
|
||||||
#define CHECK(F) { size_t r = (F); if (!r) return r; }
|
#define CHECK(F) { size_t r = (F); if (!r) return r; }
|
||||||
#define RCHECK(F) if(!(F)) { QLYR_ERROR(MISMATCH); return; }
|
#define RCHECK(F) if(!(F)) { QLYR_ERROR(MISMATCH); return; }
|
||||||
|
17
H/ratoms.h
@ -20,11 +20,16 @@
|
|||||||
AtomArrayOverflow = AtomAdjust(AtomArrayOverflow);
|
AtomArrayOverflow = AtomAdjust(AtomArrayOverflow);
|
||||||
AtomArrayType = AtomAdjust(AtomArrayType);
|
AtomArrayType = AtomAdjust(AtomArrayType);
|
||||||
AtomArrow = AtomAdjust(AtomArrow);
|
AtomArrow = AtomAdjust(AtomArrow);
|
||||||
|
AtomAttributedModule = AtomAdjust(AtomAttributedModule);
|
||||||
AtomDoubleArrow = AtomAdjust(AtomDoubleArrow);
|
AtomDoubleArrow = AtomAdjust(AtomDoubleArrow);
|
||||||
AtomAssert = AtomAdjust(AtomAssert);
|
AtomAssert = AtomAdjust(AtomAssert);
|
||||||
AtomEmptyBrackets = AtomAdjust(AtomEmptyBrackets);
|
AtomEmptyBrackets = AtomAdjust(AtomEmptyBrackets);
|
||||||
AtomEmptySquareBrackets = AtomAdjust(AtomEmptySquareBrackets);
|
AtomEmptySquareBrackets = AtomAdjust(AtomEmptySquareBrackets);
|
||||||
AtomEmptyCurlyBrackets = AtomAdjust(AtomEmptyCurlyBrackets);
|
AtomEmptyCurlyBrackets = AtomAdjust(AtomEmptyCurlyBrackets);
|
||||||
|
AtomAsserta = AtomAdjust(AtomAsserta);
|
||||||
|
AtomAssertaStatic = AtomAdjust(AtomAssertaStatic);
|
||||||
|
AtomAssertz = AtomAdjust(AtomAssertz);
|
||||||
|
AtomAssertzStatic = AtomAdjust(AtomAssertzStatic);
|
||||||
AtomAt = AtomAdjust(AtomAt);
|
AtomAt = AtomAdjust(AtomAt);
|
||||||
AtomAtom = AtomAdjust(AtomAtom);
|
AtomAtom = AtomAdjust(AtomAtom);
|
||||||
AtomAtomic = AtomAdjust(AtomAtomic);
|
AtomAtomic = AtomAdjust(AtomAtomic);
|
||||||
@ -66,6 +71,7 @@
|
|||||||
AtomCompact = AtomAdjust(AtomCompact);
|
AtomCompact = AtomAdjust(AtomCompact);
|
||||||
AtomCompound = AtomAdjust(AtomCompound);
|
AtomCompound = AtomAdjust(AtomCompound);
|
||||||
AtomConsistencyError = AtomAdjust(AtomConsistencyError);
|
AtomConsistencyError = AtomAdjust(AtomConsistencyError);
|
||||||
|
AtomConsult = AtomAdjust(AtomConsult);
|
||||||
AtomConsultOnBoot = AtomAdjust(AtomConsultOnBoot);
|
AtomConsultOnBoot = AtomAdjust(AtomConsultOnBoot);
|
||||||
AtomContext = AtomAdjust(AtomContext);
|
AtomContext = AtomAdjust(AtomContext);
|
||||||
AtomCputime = AtomAdjust(AtomCputime);
|
AtomCputime = AtomAdjust(AtomCputime);
|
||||||
@ -102,6 +108,7 @@
|
|||||||
AtomDoStaticClause = AtomAdjust(AtomDoStaticClause);
|
AtomDoStaticClause = AtomAdjust(AtomDoStaticClause);
|
||||||
AtomDots = AtomAdjust(AtomDots);
|
AtomDots = AtomAdjust(AtomDots);
|
||||||
AtomDOUBLE = AtomAdjust(AtomDOUBLE);
|
AtomDOUBLE = AtomAdjust(AtomDOUBLE);
|
||||||
|
AtomDoubleSlash = AtomAdjust(AtomDoubleSlash);
|
||||||
AtomE = AtomAdjust(AtomE);
|
AtomE = AtomAdjust(AtomE);
|
||||||
AtomEOFBeforeEOT = AtomAdjust(AtomEOFBeforeEOT);
|
AtomEOFBeforeEOT = AtomAdjust(AtomEOFBeforeEOT);
|
||||||
AtomEQ = AtomAdjust(AtomEQ);
|
AtomEQ = AtomAdjust(AtomEQ);
|
||||||
@ -133,6 +140,7 @@
|
|||||||
AtomFail = AtomAdjust(AtomFail);
|
AtomFail = AtomAdjust(AtomFail);
|
||||||
AtomFalse = AtomAdjust(AtomFalse);
|
AtomFalse = AtomAdjust(AtomFalse);
|
||||||
AtomFast = AtomAdjust(AtomFast);
|
AtomFast = AtomAdjust(AtomFast);
|
||||||
|
AtomFastFail = AtomAdjust(AtomFastFail);
|
||||||
AtomFileErrors = AtomAdjust(AtomFileErrors);
|
AtomFileErrors = AtomAdjust(AtomFileErrors);
|
||||||
AtomFileerrors = AtomAdjust(AtomFileerrors);
|
AtomFileerrors = AtomAdjust(AtomFileerrors);
|
||||||
AtomFileType = AtomAdjust(AtomFileType);
|
AtomFileType = AtomAdjust(AtomFileType);
|
||||||
@ -288,6 +296,7 @@
|
|||||||
AtomReadOnly = AtomAdjust(AtomReadOnly);
|
AtomReadOnly = AtomAdjust(AtomReadOnly);
|
||||||
AtomReadWrite = AtomAdjust(AtomReadWrite);
|
AtomReadWrite = AtomAdjust(AtomReadWrite);
|
||||||
AtomReadutil = AtomAdjust(AtomReadutil);
|
AtomReadutil = AtomAdjust(AtomReadutil);
|
||||||
|
AtomReconsult = AtomAdjust(AtomReconsult);
|
||||||
AtomRecordedP = AtomAdjust(AtomRecordedP);
|
AtomRecordedP = AtomAdjust(AtomRecordedP);
|
||||||
AtomRecordedWithKey = AtomAdjust(AtomRecordedWithKey);
|
AtomRecordedWithKey = AtomAdjust(AtomRecordedWithKey);
|
||||||
AtomRedefineWarnings = AtomAdjust(AtomRedefineWarnings);
|
AtomRedefineWarnings = AtomAdjust(AtomRedefineWarnings);
|
||||||
@ -390,14 +399,16 @@
|
|||||||
AtomUserErr = AtomAdjust(AtomUserErr);
|
AtomUserErr = AtomAdjust(AtomUserErr);
|
||||||
AtomUserIn = AtomAdjust(AtomUserIn);
|
AtomUserIn = AtomAdjust(AtomUserIn);
|
||||||
AtomUserOut = AtomAdjust(AtomUserOut);
|
AtomUserOut = AtomAdjust(AtomUserOut);
|
||||||
|
AtomDollarVar = AtomAdjust(AtomDollarVar);
|
||||||
AtomVBar = AtomAdjust(AtomVBar);
|
AtomVBar = AtomAdjust(AtomVBar);
|
||||||
AtomVar = AtomAdjust(AtomVar);
|
|
||||||
AtomVarBranches = AtomAdjust(AtomVarBranches);
|
AtomVarBranches = AtomAdjust(AtomVarBranches);
|
||||||
AtomVariableNames = AtomAdjust(AtomVariableNames);
|
AtomVariableNames = AtomAdjust(AtomVariableNames);
|
||||||
AtomHiddenVar = AtomAdjust(AtomHiddenVar);
|
AtomHiddenVar = AtomAdjust(AtomHiddenVar);
|
||||||
AtomVariable = AtomAdjust(AtomVariable);
|
AtomVariable = AtomAdjust(AtomVariable);
|
||||||
|
AtomVerbose = AtomAdjust(AtomVerbose);
|
||||||
AtomVerboseFileSearch = AtomAdjust(AtomVerboseFileSearch);
|
AtomVerboseFileSearch = AtomAdjust(AtomVerboseFileSearch);
|
||||||
AtomVersionNumber = AtomAdjust(AtomVersionNumber);
|
AtomVersionNumber = AtomAdjust(AtomVersionNumber);
|
||||||
|
AtomVeryVerbose = AtomAdjust(AtomVeryVerbose);
|
||||||
AtomWakeUpGoal = AtomAdjust(AtomWakeUpGoal);
|
AtomWakeUpGoal = AtomAdjust(AtomWakeUpGoal);
|
||||||
AtomWarning = AtomAdjust(AtomWarning);
|
AtomWarning = AtomAdjust(AtomWarning);
|
||||||
AtomWhen = AtomAdjust(AtomWhen);
|
AtomWhen = AtomAdjust(AtomWhen);
|
||||||
@ -443,6 +454,7 @@
|
|||||||
FunctorDoLogUpdClause0 = FuncAdjust(FunctorDoLogUpdClause0);
|
FunctorDoLogUpdClause0 = FuncAdjust(FunctorDoLogUpdClause0);
|
||||||
FunctorDoLogUpdClauseErase = FuncAdjust(FunctorDoLogUpdClauseErase);
|
FunctorDoLogUpdClauseErase = FuncAdjust(FunctorDoLogUpdClauseErase);
|
||||||
FunctorDoStaticClause = FuncAdjust(FunctorDoStaticClause);
|
FunctorDoStaticClause = FuncAdjust(FunctorDoStaticClause);
|
||||||
|
FunctorDollarVar = FuncAdjust(FunctorDollarVar);
|
||||||
FunctorDomainError = FuncAdjust(FunctorDomainError);
|
FunctorDomainError = FuncAdjust(FunctorDomainError);
|
||||||
FunctorDot = FuncAdjust(FunctorDot);
|
FunctorDot = FuncAdjust(FunctorDot);
|
||||||
FunctorDot10 = FuncAdjust(FunctorDot10);
|
FunctorDot10 = FuncAdjust(FunctorDot10);
|
||||||
@ -456,6 +468,7 @@
|
|||||||
FunctorDot7 = FuncAdjust(FunctorDot7);
|
FunctorDot7 = FuncAdjust(FunctorDot7);
|
||||||
FunctorDot8 = FuncAdjust(FunctorDot8);
|
FunctorDot8 = FuncAdjust(FunctorDot8);
|
||||||
FunctorDot9 = FuncAdjust(FunctorDot9);
|
FunctorDot9 = FuncAdjust(FunctorDot9);
|
||||||
|
FunctorDoubleSlash = FuncAdjust(FunctorDoubleSlash);
|
||||||
FunctorEmptySquareBrackets = FuncAdjust(FunctorEmptySquareBrackets);
|
FunctorEmptySquareBrackets = FuncAdjust(FunctorEmptySquareBrackets);
|
||||||
FunctorEmptyCurlyBrackets = FuncAdjust(FunctorEmptyCurlyBrackets);
|
FunctorEmptyCurlyBrackets = FuncAdjust(FunctorEmptyCurlyBrackets);
|
||||||
FunctorEq = FuncAdjust(FunctorEq);
|
FunctorEq = FuncAdjust(FunctorEq);
|
||||||
@ -501,6 +514,7 @@
|
|||||||
FunctorPlus = FuncAdjust(FunctorPlus);
|
FunctorPlus = FuncAdjust(FunctorPlus);
|
||||||
FunctorPortray = FuncAdjust(FunctorPortray);
|
FunctorPortray = FuncAdjust(FunctorPortray);
|
||||||
FunctorPrintMessage = FuncAdjust(FunctorPrintMessage);
|
FunctorPrintMessage = FuncAdjust(FunctorPrintMessage);
|
||||||
|
FunctorProcedure = FuncAdjust(FunctorProcedure);
|
||||||
FunctorPrologConstraint = FuncAdjust(FunctorPrologConstraint);
|
FunctorPrologConstraint = FuncAdjust(FunctorPrologConstraint);
|
||||||
FunctorQuery = FuncAdjust(FunctorQuery);
|
FunctorQuery = FuncAdjust(FunctorQuery);
|
||||||
FunctorRecordedWithKey = FuncAdjust(FunctorRecordedWithKey);
|
FunctorRecordedWithKey = FuncAdjust(FunctorRecordedWithKey);
|
||||||
@ -531,5 +545,4 @@
|
|||||||
FunctorUMinus = FuncAdjust(FunctorUMinus);
|
FunctorUMinus = FuncAdjust(FunctorUMinus);
|
||||||
FunctorUPlus = FuncAdjust(FunctorUPlus);
|
FunctorUPlus = FuncAdjust(FunctorUPlus);
|
||||||
FunctorVBar = FuncAdjust(FunctorVBar);
|
FunctorVBar = FuncAdjust(FunctorVBar);
|
||||||
FunctorVar = FuncAdjust(FunctorVar);
|
|
||||||
FunctorHiddenVar = FuncAdjust(FunctorHiddenVar);
|
FunctorHiddenVar = FuncAdjust(FunctorHiddenVar);
|
||||||
|
47
H/tatoms.h
@ -56,6 +56,9 @@
|
|||||||
Atom AtomArrow_;
|
Atom AtomArrow_;
|
||||||
#define AtomArrow Yap_heap_regs->AtomArrow_
|
#define AtomArrow Yap_heap_regs->AtomArrow_
|
||||||
#define TermArrow MkAtomTerm( Yap_heap_regs->AtomArrow_ )
|
#define TermArrow MkAtomTerm( Yap_heap_regs->AtomArrow_ )
|
||||||
|
Atom AtomAttributedModule_;
|
||||||
|
#define AtomAttributedModule Yap_heap_regs->AtomAttributedModule_
|
||||||
|
#define TermAttributedModule MkAtomTerm( Yap_heap_regs->AtomAttributedModule_ )
|
||||||
Atom AtomDoubleArrow_;
|
Atom AtomDoubleArrow_;
|
||||||
#define AtomDoubleArrow Yap_heap_regs->AtomDoubleArrow_
|
#define AtomDoubleArrow Yap_heap_regs->AtomDoubleArrow_
|
||||||
#define TermDoubleArrow MkAtomTerm( Yap_heap_regs->AtomDoubleArrow_ )
|
#define TermDoubleArrow MkAtomTerm( Yap_heap_regs->AtomDoubleArrow_ )
|
||||||
@ -71,6 +74,18 @@
|
|||||||
Atom AtomEmptyCurlyBrackets_;
|
Atom AtomEmptyCurlyBrackets_;
|
||||||
#define AtomEmptyCurlyBrackets Yap_heap_regs->AtomEmptyCurlyBrackets_
|
#define AtomEmptyCurlyBrackets Yap_heap_regs->AtomEmptyCurlyBrackets_
|
||||||
#define TermEmptyCurlyBrackets MkAtomTerm( Yap_heap_regs->AtomEmptyCurlyBrackets_ )
|
#define TermEmptyCurlyBrackets MkAtomTerm( Yap_heap_regs->AtomEmptyCurlyBrackets_ )
|
||||||
|
Atom AtomAsserta_;
|
||||||
|
#define AtomAsserta Yap_heap_regs->AtomAsserta_
|
||||||
|
#define TermAsserta MkAtomTerm( Yap_heap_regs->AtomAsserta_ )
|
||||||
|
Atom AtomAssertaStatic_;
|
||||||
|
#define AtomAssertaStatic Yap_heap_regs->AtomAssertaStatic_
|
||||||
|
#define TermAssertaStatic MkAtomTerm( Yap_heap_regs->AtomAssertaStatic_ )
|
||||||
|
Atom AtomAssertz_;
|
||||||
|
#define AtomAssertz Yap_heap_regs->AtomAssertz_
|
||||||
|
#define TermAssertz MkAtomTerm( Yap_heap_regs->AtomAssertz_ )
|
||||||
|
Atom AtomAssertzStatic_;
|
||||||
|
#define AtomAssertzStatic Yap_heap_regs->AtomAssertzStatic_
|
||||||
|
#define TermAssertzStatic MkAtomTerm( Yap_heap_regs->AtomAssertzStatic_ )
|
||||||
Atom AtomAt_;
|
Atom AtomAt_;
|
||||||
#define AtomAt Yap_heap_regs->AtomAt_
|
#define AtomAt Yap_heap_regs->AtomAt_
|
||||||
#define TermAt MkAtomTerm( Yap_heap_regs->AtomAt_ )
|
#define TermAt MkAtomTerm( Yap_heap_regs->AtomAt_ )
|
||||||
@ -194,6 +209,9 @@
|
|||||||
Atom AtomConsistencyError_;
|
Atom AtomConsistencyError_;
|
||||||
#define AtomConsistencyError Yap_heap_regs->AtomConsistencyError_
|
#define AtomConsistencyError Yap_heap_regs->AtomConsistencyError_
|
||||||
#define TermConsistencyError MkAtomTerm( Yap_heap_regs->AtomConsistencyError_ )
|
#define TermConsistencyError MkAtomTerm( Yap_heap_regs->AtomConsistencyError_ )
|
||||||
|
Atom AtomConsult_;
|
||||||
|
#define AtomConsult Yap_heap_regs->AtomConsult_
|
||||||
|
#define TermConsult MkAtomTerm( Yap_heap_regs->AtomConsult_ )
|
||||||
Atom AtomConsultOnBoot_;
|
Atom AtomConsultOnBoot_;
|
||||||
#define AtomConsultOnBoot Yap_heap_regs->AtomConsultOnBoot_
|
#define AtomConsultOnBoot Yap_heap_regs->AtomConsultOnBoot_
|
||||||
#define TermConsultOnBoot MkAtomTerm( Yap_heap_regs->AtomConsultOnBoot_ )
|
#define TermConsultOnBoot MkAtomTerm( Yap_heap_regs->AtomConsultOnBoot_ )
|
||||||
@ -302,6 +320,9 @@
|
|||||||
Atom AtomDOUBLE_;
|
Atom AtomDOUBLE_;
|
||||||
#define AtomDOUBLE Yap_heap_regs->AtomDOUBLE_
|
#define AtomDOUBLE Yap_heap_regs->AtomDOUBLE_
|
||||||
#define TermDOUBLE MkAtomTerm( Yap_heap_regs->AtomDOUBLE_ )
|
#define TermDOUBLE MkAtomTerm( Yap_heap_regs->AtomDOUBLE_ )
|
||||||
|
Atom AtomDoubleSlash_;
|
||||||
|
#define AtomDoubleSlash Yap_heap_regs->AtomDoubleSlash_
|
||||||
|
#define TermDoubleSlash MkAtomTerm( Yap_heap_regs->AtomDoubleSlash_ )
|
||||||
Atom AtomE_;
|
Atom AtomE_;
|
||||||
#define AtomE Yap_heap_regs->AtomE_
|
#define AtomE Yap_heap_regs->AtomE_
|
||||||
#define TermE MkAtomTerm( Yap_heap_regs->AtomE_ )
|
#define TermE MkAtomTerm( Yap_heap_regs->AtomE_ )
|
||||||
@ -395,6 +416,9 @@
|
|||||||
Atom AtomFast_;
|
Atom AtomFast_;
|
||||||
#define AtomFast Yap_heap_regs->AtomFast_
|
#define AtomFast Yap_heap_regs->AtomFast_
|
||||||
#define TermFast MkAtomTerm( Yap_heap_regs->AtomFast_ )
|
#define TermFast MkAtomTerm( Yap_heap_regs->AtomFast_ )
|
||||||
|
Atom AtomFastFail_;
|
||||||
|
#define AtomFastFail Yap_heap_regs->AtomFastFail_
|
||||||
|
#define TermFastFail MkAtomTerm( Yap_heap_regs->AtomFastFail_ )
|
||||||
Atom AtomFileErrors_;
|
Atom AtomFileErrors_;
|
||||||
#define AtomFileErrors Yap_heap_regs->AtomFileErrors_
|
#define AtomFileErrors Yap_heap_regs->AtomFileErrors_
|
||||||
#define TermFileErrors MkAtomTerm( Yap_heap_regs->AtomFileErrors_ )
|
#define TermFileErrors MkAtomTerm( Yap_heap_regs->AtomFileErrors_ )
|
||||||
@ -860,6 +884,9 @@
|
|||||||
Atom AtomReadutil_;
|
Atom AtomReadutil_;
|
||||||
#define AtomReadutil Yap_heap_regs->AtomReadutil_
|
#define AtomReadutil Yap_heap_regs->AtomReadutil_
|
||||||
#define TermReadutil MkAtomTerm( Yap_heap_regs->AtomReadutil_ )
|
#define TermReadutil MkAtomTerm( Yap_heap_regs->AtomReadutil_ )
|
||||||
|
Atom AtomReconsult_;
|
||||||
|
#define AtomReconsult Yap_heap_regs->AtomReconsult_
|
||||||
|
#define TermReconsult MkAtomTerm( Yap_heap_regs->AtomReconsult_ )
|
||||||
Atom AtomRecordedP_;
|
Atom AtomRecordedP_;
|
||||||
#define AtomRecordedP Yap_heap_regs->AtomRecordedP_
|
#define AtomRecordedP Yap_heap_regs->AtomRecordedP_
|
||||||
#define TermRecordedP MkAtomTerm( Yap_heap_regs->AtomRecordedP_ )
|
#define TermRecordedP MkAtomTerm( Yap_heap_regs->AtomRecordedP_ )
|
||||||
@ -1166,12 +1193,12 @@
|
|||||||
Atom AtomUserOut_;
|
Atom AtomUserOut_;
|
||||||
#define AtomUserOut Yap_heap_regs->AtomUserOut_
|
#define AtomUserOut Yap_heap_regs->AtomUserOut_
|
||||||
#define TermUserOut MkAtomTerm( Yap_heap_regs->AtomUserOut_ )
|
#define TermUserOut MkAtomTerm( Yap_heap_regs->AtomUserOut_ )
|
||||||
|
Atom AtomDollarVar_;
|
||||||
|
#define AtomDollarVar Yap_heap_regs->AtomDollarVar_
|
||||||
|
#define TermDollarVar MkAtomTerm( Yap_heap_regs->AtomDollarVar_ )
|
||||||
Atom AtomVBar_;
|
Atom AtomVBar_;
|
||||||
#define AtomVBar Yap_heap_regs->AtomVBar_
|
#define AtomVBar Yap_heap_regs->AtomVBar_
|
||||||
#define TermVBar MkAtomTerm( Yap_heap_regs->AtomVBar_ )
|
#define TermVBar MkAtomTerm( Yap_heap_regs->AtomVBar_ )
|
||||||
Atom AtomVar_;
|
|
||||||
#define AtomVar Yap_heap_regs->AtomVar_
|
|
||||||
#define TermVar MkAtomTerm( Yap_heap_regs->AtomVar_ )
|
|
||||||
Atom AtomVarBranches_;
|
Atom AtomVarBranches_;
|
||||||
#define AtomVarBranches Yap_heap_regs->AtomVarBranches_
|
#define AtomVarBranches Yap_heap_regs->AtomVarBranches_
|
||||||
#define TermVarBranches MkAtomTerm( Yap_heap_regs->AtomVarBranches_ )
|
#define TermVarBranches MkAtomTerm( Yap_heap_regs->AtomVarBranches_ )
|
||||||
@ -1184,12 +1211,18 @@
|
|||||||
Atom AtomVariable_;
|
Atom AtomVariable_;
|
||||||
#define AtomVariable Yap_heap_regs->AtomVariable_
|
#define AtomVariable Yap_heap_regs->AtomVariable_
|
||||||
#define TermVariable MkAtomTerm( Yap_heap_regs->AtomVariable_ )
|
#define TermVariable MkAtomTerm( Yap_heap_regs->AtomVariable_ )
|
||||||
|
Atom AtomVerbose_;
|
||||||
|
#define AtomVerbose Yap_heap_regs->AtomVerbose_
|
||||||
|
#define TermVerbose MkAtomTerm( Yap_heap_regs->AtomVerbose_ )
|
||||||
Atom AtomVerboseFileSearch_;
|
Atom AtomVerboseFileSearch_;
|
||||||
#define AtomVerboseFileSearch Yap_heap_regs->AtomVerboseFileSearch_
|
#define AtomVerboseFileSearch Yap_heap_regs->AtomVerboseFileSearch_
|
||||||
#define TermVerboseFileSearch MkAtomTerm( Yap_heap_regs->AtomVerboseFileSearch_ )
|
#define TermVerboseFileSearch MkAtomTerm( Yap_heap_regs->AtomVerboseFileSearch_ )
|
||||||
Atom AtomVersionNumber_;
|
Atom AtomVersionNumber_;
|
||||||
#define AtomVersionNumber Yap_heap_regs->AtomVersionNumber_
|
#define AtomVersionNumber Yap_heap_regs->AtomVersionNumber_
|
||||||
#define TermVersionNumber MkAtomTerm( Yap_heap_regs->AtomVersionNumber_ )
|
#define TermVersionNumber MkAtomTerm( Yap_heap_regs->AtomVersionNumber_ )
|
||||||
|
Atom AtomVeryVerbose_;
|
||||||
|
#define AtomVeryVerbose Yap_heap_regs->AtomVeryVerbose_
|
||||||
|
#define TermVeryVerbose MkAtomTerm( Yap_heap_regs->AtomVeryVerbose_ )
|
||||||
Atom AtomWakeUpGoal_;
|
Atom AtomWakeUpGoal_;
|
||||||
#define AtomWakeUpGoal Yap_heap_regs->AtomWakeUpGoal_
|
#define AtomWakeUpGoal Yap_heap_regs->AtomWakeUpGoal_
|
||||||
#define TermWakeUpGoal MkAtomTerm( Yap_heap_regs->AtomWakeUpGoal_ )
|
#define TermWakeUpGoal MkAtomTerm( Yap_heap_regs->AtomWakeUpGoal_ )
|
||||||
@ -1287,6 +1320,8 @@
|
|||||||
#define FunctorDoLogUpdClauseErase Yap_heap_regs->FunctorDoLogUpdClauseErase_
|
#define FunctorDoLogUpdClauseErase Yap_heap_regs->FunctorDoLogUpdClauseErase_
|
||||||
Functor FunctorDoStaticClause_;
|
Functor FunctorDoStaticClause_;
|
||||||
#define FunctorDoStaticClause Yap_heap_regs->FunctorDoStaticClause_
|
#define FunctorDoStaticClause Yap_heap_regs->FunctorDoStaticClause_
|
||||||
|
Functor FunctorDollarVar_;
|
||||||
|
#define FunctorDollarVar Yap_heap_regs->FunctorDollarVar_
|
||||||
Functor FunctorDomainError_;
|
Functor FunctorDomainError_;
|
||||||
#define FunctorDomainError Yap_heap_regs->FunctorDomainError_
|
#define FunctorDomainError Yap_heap_regs->FunctorDomainError_
|
||||||
Functor FunctorDot_;
|
Functor FunctorDot_;
|
||||||
@ -1313,6 +1348,8 @@
|
|||||||
#define FunctorDot8 Yap_heap_regs->FunctorDot8_
|
#define FunctorDot8 Yap_heap_regs->FunctorDot8_
|
||||||
Functor FunctorDot9_;
|
Functor FunctorDot9_;
|
||||||
#define FunctorDot9 Yap_heap_regs->FunctorDot9_
|
#define FunctorDot9 Yap_heap_regs->FunctorDot9_
|
||||||
|
Functor FunctorDoubleSlash_;
|
||||||
|
#define FunctorDoubleSlash Yap_heap_regs->FunctorDoubleSlash_
|
||||||
Functor FunctorEmptySquareBrackets_;
|
Functor FunctorEmptySquareBrackets_;
|
||||||
#define FunctorEmptySquareBrackets Yap_heap_regs->FunctorEmptySquareBrackets_
|
#define FunctorEmptySquareBrackets Yap_heap_regs->FunctorEmptySquareBrackets_
|
||||||
Functor FunctorEmptyCurlyBrackets_;
|
Functor FunctorEmptyCurlyBrackets_;
|
||||||
@ -1403,6 +1440,8 @@
|
|||||||
#define FunctorPortray Yap_heap_regs->FunctorPortray_
|
#define FunctorPortray Yap_heap_regs->FunctorPortray_
|
||||||
Functor FunctorPrintMessage_;
|
Functor FunctorPrintMessage_;
|
||||||
#define FunctorPrintMessage Yap_heap_regs->FunctorPrintMessage_
|
#define FunctorPrintMessage Yap_heap_regs->FunctorPrintMessage_
|
||||||
|
Functor FunctorProcedure_;
|
||||||
|
#define FunctorProcedure Yap_heap_regs->FunctorProcedure_
|
||||||
Functor FunctorPrologConstraint_;
|
Functor FunctorPrologConstraint_;
|
||||||
#define FunctorPrologConstraint Yap_heap_regs->FunctorPrologConstraint_
|
#define FunctorPrologConstraint Yap_heap_regs->FunctorPrologConstraint_
|
||||||
Functor FunctorQuery_;
|
Functor FunctorQuery_;
|
||||||
@ -1463,7 +1502,5 @@
|
|||||||
#define FunctorUPlus Yap_heap_regs->FunctorUPlus_
|
#define FunctorUPlus Yap_heap_regs->FunctorUPlus_
|
||||||
Functor FunctorVBar_;
|
Functor FunctorVBar_;
|
||||||
#define FunctorVBar Yap_heap_regs->FunctorVBar_
|
#define FunctorVBar Yap_heap_regs->FunctorVBar_
|
||||||
Functor FunctorVar_;
|
|
||||||
#define FunctorVar Yap_heap_regs->FunctorVar_
|
|
||||||
Functor FunctorHiddenVar_;
|
Functor FunctorHiddenVar_;
|
||||||
#define FunctorHiddenVar Yap_heap_regs->FunctorHiddenVar_
|
#define FunctorHiddenVar Yap_heap_regs->FunctorHiddenVar_
|
||||||
|
@ -36,6 +36,7 @@ if (WITH_TABLING)
|
|||||||
#and it is used across several files outside OPTYap
|
#and it is used across several files outside OPTYap
|
||||||
set_property(DIRECTORY .. APPEND PROPERTY COMPILE_DEFINITIONS TABLING=1)
|
set_property(DIRECTORY .. APPEND PROPERTY COMPILE_DEFINITIONS TABLING=1)
|
||||||
include_directories (OPTYap )
|
include_directories (OPTYap )
|
||||||
|
set(YAP_SYSTEM_OPTIONS "tabling " ${YAP_SYSTEM_OPTIONS} PARENT_SCOPE)
|
||||||
endif(WITH_TABLING)
|
endif(WITH_TABLING)
|
||||||
|
|
||||||
option (WITH_YAPOR "Experimental Support for Or-parallelism" OFF)
|
option (WITH_YAPOR "Experimental Support for Or-parallelism" OFF)
|
||||||
@ -44,24 +45,28 @@ OPTION (WITH_YAPOR_COPY "Copy-based Or-parallelism" OFF)
|
|||||||
if (WITH_YAPOR_COPY)
|
if (WITH_YAPOR_COPY)
|
||||||
set_property(DIRECTORY .. APPEND PROPERTY COMPILE_DEFINITIONS YAPOR_COPY=1;USE_DL_MALLOC=1)
|
set_property(DIRECTORY .. APPEND PROPERTY COMPILE_DEFINITIONS YAPOR_COPY=1;USE_DL_MALLOC=1)
|
||||||
set(WITH_YAPOR ON)
|
set(WITH_YAPOR ON)
|
||||||
|
set(YAP_SYSTEM_OPTIONS "or_parallelism " ${YAP_SYSTEM_OPTIONS} PARENT_SCOPE)
|
||||||
endif (WITH_YAPOR_COPY)
|
endif (WITH_YAPOR_COPY)
|
||||||
|
|
||||||
OPTION (WITH_YAPOR_THOR "Thread-based Or-parallelism" OFF)
|
OPTION (WITH_YAPOR_THOR "Thread-based Or-parallelism" OFF)
|
||||||
if (WITH_YAPOR_THOR)
|
if (WITH_YAPOR_THOR)
|
||||||
set_property(DIRECTORY .. APPEND PROPERTY COMPILE_DEFINITIONS YAPOR_THREADS=1;USE_SYSTEM_MALLOC=1)
|
set_property(DIRECTORY .. APPEND PROPERTY COMPILE_DEFINITIONS YAPOR_THREADS=1;USE_SYSTEM_MALLOC=1)
|
||||||
set(WITH_YAPOR ON)
|
set(WITH_YAPOR ON)
|
||||||
|
set(YAP_SYSTEM_OPTIONS "or_parallelism " ${YAP_SYSTEM_OPTIONS} PARENT_SCOPE)
|
||||||
endif (WITH_YAPOR_THOR)
|
endif (WITH_YAPOR_THOR)
|
||||||
|
|
||||||
OPTION (WITH_YAPOR_ACOW "Process-based Copy-On-Write Or-parallelism" OFF)
|
OPTION (WITH_YAPOR_ACOW "Process-based Copy-On-Write Or-parallelism" OFF)
|
||||||
if (WITH_YAPOR_ACOW)
|
if (WITH_YAPOR_ACOW)
|
||||||
set_property(DIRECTORY .. APPEND PROPERTY COMPILE_DEFINITIONS YAPOR_COW=1;USE_SYSTEM_MALLOC=1)
|
set_property(DIRECTORY .. APPEND PROPERTY COMPILE_DEFINITIONS YAPOR_COW=1;USE_SYSTEM_MALLOC=1)
|
||||||
set(WITH_YAPOR ON)
|
set(WITH_YAPOR ON)
|
||||||
|
set(YAP_SYSTEM_OPTIONS "or_parallelism " ${YAP_SYSTEM_OPTIONS} PARENT_SCOPE)
|
||||||
endif (WITH_YAPOR_ACOW)
|
endif (WITH_YAPOR_ACOW)
|
||||||
|
|
||||||
OPTION (WITH_YAPOR_SBA "Sparse Bind Array-based Or-parallelism" OFF)
|
OPTION (WITH_YAPOR_SBA "Sparse Bind Array-based Or-parallelism" OFF)
|
||||||
if (WITH_YAPOR_SBA)
|
if (WITH_YAPOR_SBA)
|
||||||
set_property(DIRECTORY .. APPEND PROPERTY COMPILE_DEFINITIONS YAPOR_SBA=1;USE_SYSTEM_MALLOC=1)
|
set_property(DIRECTORY .. APPEND PROPERTY COMPILE_DEFINITIONS YAPOR_SBA=1;USE_SYSTEM_MALLOC=1)
|
||||||
set(WITH_YAPOR ON)
|
set(WITH_YAPOR ON)
|
||||||
|
set(YAP_SYSTEM_OPTIONS "or_parallelism, " ${YAP_SYSTEM_OPTIONS} PARENT_SCOPE)
|
||||||
endif (WITH_YAPOR_SBA)
|
endif (WITH_YAPOR_SBA)
|
||||||
|
|
||||||
|
|
||||||
@ -79,6 +84,7 @@ set (POSITION_INDEPENDENT_CODE TRUE)
|
|||||||
add_library (libOPTYap OBJECT
|
add_library (libOPTYap OBJECT
|
||||||
${OPTYap_SOURCES} )
|
${OPTYap_SOURCES} )
|
||||||
|
|
||||||
|
|
||||||
set_target_properties(libOPTYap
|
set_target_properties(libOPTYap
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
# RPATH ${libdir} VERSION ${LIBYAPTAI_FULL_VERSION}
|
# RPATH ${libdir} VERSION ${LIBYAPTAI_FULL_VERSION}
|
||||||
|
@ -34,14 +34,14 @@
|
|||||||
#include "sys/wait.h"
|
#include "sys/wait.h"
|
||||||
#endif /* YAPOR_COW */
|
#endif /* YAPOR_COW */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
** Macros **
|
** Macros **
|
||||||
*********************/
|
*********************/
|
||||||
|
|
||||||
#ifdef USE_PAGES_MALLOC
|
#ifdef USE_PAGES_MALLOC
|
||||||
#define STRUCTS_PER_PAGE(STR_TYPE) ((Yap_page_size - ADJUST_SIZE(sizeof(struct page_header))) / ADJUST_SIZE(sizeof(STR_TYPE)))
|
#define STRUCTS_PER_PAGE(STR_TYPE) \
|
||||||
|
((Yap_page_size - ADJUST_SIZE(sizeof(struct page_header))) / \
|
||||||
|
ADJUST_SIZE(sizeof(STR_TYPE)))
|
||||||
|
|
||||||
#define INIT_GLOBAL_PAGE_ENTRY(PG, STR_TYPE) \
|
#define INIT_GLOBAL_PAGE_ENTRY(PG, STR_TYPE) \
|
||||||
INIT_LOCK(PgEnt_lock(PG)); \
|
INIT_LOCK(PgEnt_lock(PG)); \
|
||||||
@ -61,13 +61,12 @@
|
|||||||
#define INIT_LOCAL_PAGE_ENTRY(PG, STR_TYPE) PgEnt_strs_in_use(PG) = 0
|
#define INIT_LOCAL_PAGE_ENTRY(PG, STR_TYPE) PgEnt_strs_in_use(PG) = 0
|
||||||
#endif /* USE_PAGES_MALLOC */
|
#endif /* USE_PAGES_MALLOC */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************
|
/*******************************
|
||||||
** Global functions **
|
** Global functions **
|
||||||
*******************************/
|
*******************************/
|
||||||
|
|
||||||
void Yap_init_global_optyap_data(int max_table_size, int n_workers, int sch_loop, int delay_load) {
|
void Yap_init_global_optyap_data(int max_table_size, int n_workers,
|
||||||
|
int sch_loop, int delay_load) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* global data related to memory management */
|
/* global data related to memory management */
|
||||||
@ -94,14 +93,18 @@ void Yap_init_global_optyap_data(int max_table_size, int n_workers, int sch_loop
|
|||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_or_fr, struct or_frame);
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_or_fr, struct or_frame);
|
||||||
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_qg_sol_fr, struct query_goal_solution_frame);
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_qg_sol_fr,
|
||||||
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_qg_ans_fr, struct query_goal_answer_frame);
|
struct query_goal_solution_frame);
|
||||||
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_qg_ans_fr,
|
||||||
|
struct query_goal_answer_frame);
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_susp_fr, struct suspension_frame);
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_susp_fr, struct suspension_frame);
|
||||||
#endif
|
#endif
|
||||||
#ifdef TABLING_INNER_CUTS
|
#ifdef TABLING_INNER_CUTS
|
||||||
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_tg_sol_fr, struct table_subgoal_solution_frame);
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_tg_sol_fr,
|
||||||
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_tg_ans_fr, struct table_subgoal_answer_frame);
|
struct table_subgoal_solution_frame);
|
||||||
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_tg_ans_fr,
|
||||||
|
struct table_subgoal_answer_frame);
|
||||||
#endif
|
#endif
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
|
|
||||||
@ -109,7 +112,8 @@ void Yap_init_global_optyap_data(int max_table_size, int n_workers, int sch_loop
|
|||||||
/* global static data */
|
/* global static data */
|
||||||
GLOBAL_number_workers = n_workers;
|
GLOBAL_number_workers = n_workers;
|
||||||
GLOBAL_worker_pid(0) = getpid();
|
GLOBAL_worker_pid(0) = getpid();
|
||||||
for (i = 1; i < GLOBAL_number_workers; i++) GLOBAL_worker_pid(i) = 0;
|
for (i = 1; i < GLOBAL_number_workers; i++)
|
||||||
|
GLOBAL_worker_pid(i) = 0;
|
||||||
GLOBAL_scheduler_loop = sch_loop;
|
GLOBAL_scheduler_loop = sch_loop;
|
||||||
GLOBAL_delayed_release_load = delay_load;
|
GLOBAL_delayed_release_load = delay_load;
|
||||||
|
|
||||||
@ -146,7 +150,8 @@ void Yap_init_global_optyap_data(int max_table_size, int n_workers, int sch_loop
|
|||||||
GLOBAL_root_tab_ent = NULL;
|
GLOBAL_root_tab_ent = NULL;
|
||||||
#ifdef LIMIT_TABLING
|
#ifdef LIMIT_TABLING
|
||||||
if (max_table_size)
|
if (max_table_size)
|
||||||
GLOBAL_max_pages = ((max_table_size - 1) * 1024 * 1024 / SHMMAX + 1) * SHMMAX / Yap_page_size;
|
GLOBAL_max_pages = ((max_table_size - 1) * 1024 * 1024 / SHMMAX + 1) *
|
||||||
|
SHMMAX / Yap_page_size;
|
||||||
else
|
else
|
||||||
GLOBAL_max_pages = -1;
|
GLOBAL_max_pages = -1;
|
||||||
GLOBAL_first_sg_fr = NULL;
|
GLOBAL_first_sg_fr = NULL;
|
||||||
@ -154,7 +159,8 @@ void Yap_init_global_optyap_data(int max_table_size, int n_workers, int sch_loop
|
|||||||
GLOBAL_check_sg_fr = NULL;
|
GLOBAL_check_sg_fr = NULL;
|
||||||
#endif /* LIMIT_TABLING */
|
#endif /* LIMIT_TABLING */
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
new_dependency_frame(GLOBAL_root_dep_fr, FALSE, NULL, NULL, NULL, NULL, FALSE, NULL);
|
new_dependency_frame(GLOBAL_root_dep_fr, FALSE, NULL, NULL, NULL, NULL, FALSE,
|
||||||
|
NULL);
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
for (i = 0; i < MAX_TABLE_VARS; i++) {
|
for (i = 0; i < MAX_TABLE_VARS; i++) {
|
||||||
CELL *pt = GLOBAL_table_var_enumerator_addr(i);
|
CELL *pt = GLOBAL_table_var_enumerator_addr(i);
|
||||||
@ -169,7 +175,6 @@ void Yap_init_global_optyap_data(int max_table_size, int n_workers, int sch_loop
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Yap_init_local_optyap_data(int wid) {
|
void Yap_init_local_optyap_data(int wid) {
|
||||||
#if defined(YAPOR_THREADS) || defined(THREADS_CONSUMER_SHARING)
|
#if defined(YAPOR_THREADS) || defined(THREADS_CONSUMER_SHARING)
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
@ -234,7 +239,6 @@ void Yap_init_local_optyap_data(int wid) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Yap_init_root_frames(void) {
|
void Yap_init_root_frames(void) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
|
|
||||||
@ -267,18 +271,21 @@ void Yap_init_root_frames(void) {
|
|||||||
new_global_trie_node(GLOBAL_root_gt, 0, NULL, NULL, NULL);
|
new_global_trie_node(GLOBAL_root_gt, 0, NULL, NULL, NULL);
|
||||||
/* root dependency frame */
|
/* root dependency frame */
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
DepFr_cons_cp(GLOBAL_root_dep_fr) = B; /* with YAPOR, at that point, LOCAL_top_dep_fr shouldn't be the same as GLOBAL_root_dep_fr ? */
|
DepFr_cons_cp(GLOBAL_root_dep_fr) = B; /* with YAPOR, at that point,
|
||||||
|
LOCAL_top_dep_fr shouldn't be the
|
||||||
|
same as GLOBAL_root_dep_fr ? */
|
||||||
#else
|
#else
|
||||||
new_dependency_frame(LOCAL_top_dep_fr, FALSE, NULL, NULL, B, NULL, FALSE, NULL);
|
new_dependency_frame(LOCAL_top_dep_fr, FALSE, NULL, NULL, B, NULL, FALSE,
|
||||||
|
NULL);
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void itos(int i, char *s) {
|
void itos(int i, char *s) {
|
||||||
int n, r, j;
|
int n, r, j;
|
||||||
n = 10;
|
n = 10;
|
||||||
while (n <= i) n *= 10;
|
while (n <= i)
|
||||||
|
n *= 10;
|
||||||
j = 0;
|
j = 0;
|
||||||
while (n > 1) {
|
while (n > 1) {
|
||||||
n = n / 10;
|
n = n / 10;
|
||||||
|
@ -75,32 +75,43 @@ static inline struct page_statistics show_statistics_table_entries(FILE *out);
|
|||||||
static inline struct page_statistics show_statistics_subgoal_entries(FILE *out);
|
static inline struct page_statistics show_statistics_subgoal_entries(FILE *out);
|
||||||
#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
|
#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
|
||||||
static inline struct page_statistics show_statistics_subgoal_frames(FILE *out);
|
static inline struct page_statistics show_statistics_subgoal_frames(FILE *out);
|
||||||
static inline struct page_statistics show_statistics_dependency_frames(FILE *out);
|
static inline struct page_statistics
|
||||||
static inline struct page_statistics show_statistics_subgoal_trie_nodes(FILE *out);
|
show_statistics_dependency_frames(FILE *out);
|
||||||
static inline struct page_statistics show_statistics_subgoal_trie_hashes(FILE *out);
|
static inline struct page_statistics
|
||||||
static inline struct page_statistics show_statistics_answer_trie_nodes(FILE *out);
|
show_statistics_subgoal_trie_nodes(FILE *out);
|
||||||
static inline struct page_statistics show_statistics_answer_trie_hashes(FILE *out);
|
static inline struct page_statistics
|
||||||
|
show_statistics_subgoal_trie_hashes(FILE *out);
|
||||||
|
static inline struct page_statistics
|
||||||
|
show_statistics_answer_trie_nodes(FILE *out);
|
||||||
|
static inline struct page_statistics
|
||||||
|
show_statistics_answer_trie_hashes(FILE *out);
|
||||||
#if defined(THREADS_FULL_SHARING)
|
#if defined(THREADS_FULL_SHARING)
|
||||||
static inline struct page_statistics show_statistics_answer_ref_nodes(FILE *out);
|
static inline struct page_statistics
|
||||||
|
show_statistics_answer_ref_nodes(FILE *out);
|
||||||
#endif /* THREADS_FULL_SHARING */
|
#endif /* THREADS_FULL_SHARING */
|
||||||
static inline struct page_statistics show_statistics_global_trie_nodes(FILE *out);
|
static inline struct page_statistics
|
||||||
static inline struct page_statistics show_statistics_global_trie_hashes(FILE *out);
|
show_statistics_global_trie_nodes(FILE *out);
|
||||||
|
static inline struct page_statistics
|
||||||
|
show_statistics_global_trie_hashes(FILE *out);
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
static inline struct page_statistics show_statistics_or_frames(FILE *out);
|
static inline struct page_statistics show_statistics_or_frames(FILE *out);
|
||||||
static inline struct page_statistics show_statistics_query_goal_solution_frames(FILE *out);
|
static inline struct page_statistics
|
||||||
static inline struct page_statistics show_statistics_query_goal_answer_frames(FILE *out);
|
show_statistics_query_goal_solution_frames(FILE *out);
|
||||||
|
static inline struct page_statistics
|
||||||
|
show_statistics_query_goal_answer_frames(FILE *out);
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
#if defined(YAPOR) && defined(TABLING)
|
#if defined(YAPOR) && defined(TABLING)
|
||||||
static inline struct page_statistics show_statistics_suspension_frames(FILE *out);
|
static inline struct page_statistics
|
||||||
|
show_statistics_suspension_frames(FILE *out);
|
||||||
#ifdef TABLING_INNER_CUTS
|
#ifdef TABLING_INNER_CUTS
|
||||||
static inline struct page_statistics show_statistics_table_subgoal_solution_frames(FILE *out);
|
static inline struct page_statistics
|
||||||
static inline struct page_statistics show_statistics_table_subgoal_answer_frames(FILE *out);
|
show_statistics_table_subgoal_solution_frames(FILE *out);
|
||||||
|
static inline struct page_statistics
|
||||||
|
show_statistics_table_subgoal_answer_frames(FILE *out);
|
||||||
#endif /* TABLING_INNER_CUTS */
|
#endif /* TABLING_INNER_CUTS */
|
||||||
#endif /* YAPOR && TABLING */
|
#endif /* YAPOR && TABLING */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/************************************
|
/************************************
|
||||||
** Macros & Declarations **
|
** Macros & Declarations **
|
||||||
************************************/
|
************************************/
|
||||||
@ -118,7 +129,8 @@ struct page_statistics {
|
|||||||
#ifdef USE_PAGES_MALLOC
|
#ifdef USE_PAGES_MALLOC
|
||||||
#ifdef DEBUG_TABLING
|
#ifdef DEBUG_TABLING
|
||||||
#define CHECK_PAGE_FREE_STRUCTS(STR_TYPE, PAGE) \
|
#define CHECK_PAGE_FREE_STRUCTS(STR_TYPE, PAGE) \
|
||||||
{ pg_hd_ptr pg_hd; \
|
{ \
|
||||||
|
pg_hd_ptr pg_hd; \
|
||||||
STR_TYPE *aux_ptr; \
|
STR_TYPE *aux_ptr; \
|
||||||
long cont = 0; \
|
long cont = 0; \
|
||||||
pg_hd = PgEnt_first(PAGE); \
|
pg_hd = PgEnt_first(PAGE); \
|
||||||
@ -130,7 +142,8 @@ struct page_statistics {
|
|||||||
} \
|
} \
|
||||||
pg_hd = PgHd_next(pg_hd); \
|
pg_hd = PgHd_next(pg_hd); \
|
||||||
} \
|
} \
|
||||||
TABLING_ERROR_CHECKING(CHECK_PAGE_FREE_STRUCTS, PgEnt_strs_free(PAGE) != cont); \
|
TABLING_ERROR_CHECKING(CHECK_PAGE_FREE_STRUCTS, \
|
||||||
|
PgEnt_strs_free(PAGE) != cont); \
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define CHECK_PAGE_FREE_STRUCTS(STR_TYPE, PAGE)
|
#define CHECK_PAGE_FREE_STRUCTS(STR_TYPE, PAGE)
|
||||||
@ -144,27 +157,31 @@ struct page_statistics {
|
|||||||
#define INCREMENT_AUX_STATS(STATS, BYTES, PAGES) \
|
#define INCREMENT_AUX_STATS(STATS, BYTES, PAGES) \
|
||||||
BYTES += PgEnt_bytes_in_use(STATS); \
|
BYTES += PgEnt_bytes_in_use(STATS); \
|
||||||
PAGES += PgEnt_pages_in_use(STATS)
|
PAGES += PgEnt_pages_in_use(STATS)
|
||||||
#define SHOW_PAGE_STATS_MSG(STR_NAME) " " STR_NAME " %10ld bytes (%ld pages and %ld structs in use)\n"
|
#define SHOW_PAGE_STATS_MSG(STR_NAME) \
|
||||||
#define SHOW_PAGE_STATS_ARGS(STATS, STR_TYPE) PgEnt_strs_in_use(STATS) * sizeof(STR_TYPE), PgEnt_pages_in_use(STATS), PgEnt_strs_in_use(STATS)
|
" " STR_NAME " %10ld bytes (%ld pages and %ld structs in use)\n"
|
||||||
|
#define SHOW_PAGE_STATS_ARGS(STATS, STR_TYPE) \
|
||||||
|
PgEnt_strs_in_use(STATS) * sizeof(STR_TYPE), PgEnt_pages_in_use(STATS), \
|
||||||
|
PgEnt_strs_in_use(STATS)
|
||||||
#else /* !USE_PAGES_MALLOC */
|
#else /* !USE_PAGES_MALLOC */
|
||||||
#define CHECK_PAGE_FREE_STRUCTS(STR_TYPE, PAGE)
|
#define CHECK_PAGE_FREE_STRUCTS(STR_TYPE, PAGE)
|
||||||
#define INIT_PAGE_STATS(STATS) \
|
#define INIT_PAGE_STATS(STATS) PgEnt_strs_in_use(STATS) = 0
|
||||||
PgEnt_strs_in_use(STATS) = 0
|
|
||||||
#define INCREMENT_PAGE_STATS(STATS, PAGE) \
|
#define INCREMENT_PAGE_STATS(STATS, PAGE) \
|
||||||
PgEnt_strs_in_use(STATS) += PgEnt_strs_in_use(PAGE)
|
PgEnt_strs_in_use(STATS) += PgEnt_strs_in_use(PAGE)
|
||||||
#define INCREMENT_AUX_STATS(STATS, BYTES, PAGES) \
|
#define INCREMENT_AUX_STATS(STATS, BYTES, PAGES) \
|
||||||
BYTES += PgEnt_bytes_in_use(STATS)
|
BYTES += PgEnt_bytes_in_use(STATS)
|
||||||
#define SHOW_PAGE_STATS_MSG(STR_NAME) " " STR_NAME " %10ld bytes (%ld structs in use)\n"
|
#define SHOW_PAGE_STATS_MSG(STR_NAME) \
|
||||||
#define SHOW_PAGE_STATS_ARGS(STATS, STR_TYPE) PgEnt_strs_in_use(STATS) * sizeof(STR_TYPE), PgEnt_strs_in_use(STATS)
|
" " STR_NAME " %10ld bytes (%ld structs in use)\n"
|
||||||
|
#define SHOW_PAGE_STATS_ARGS(STATS, STR_TYPE) \
|
||||||
|
PgEnt_strs_in_use(STATS) * sizeof(STR_TYPE), PgEnt_strs_in_use(STATS)
|
||||||
#endif /* USE_PAGES_MALLOC */
|
#endif /* USE_PAGES_MALLOC */
|
||||||
|
|
||||||
|
|
||||||
#if defined(THREADS) && defined(TABLING)
|
#if defined(THREADS) && defined(TABLING)
|
||||||
#define GET_ALL_PAGE_STATS(STATS, STR_TYPE, _PAGES) \
|
#define GET_ALL_PAGE_STATS(STATS, STR_TYPE, _PAGES) \
|
||||||
LOCK(GLOBAL_ThreadHandlesLock); \
|
LOCK(GLOBAL_ThreadHandlesLock); \
|
||||||
CHECK_PAGE_FREE_STRUCTS(STR_TYPE, GLOBAL##_PAGES); \
|
CHECK_PAGE_FREE_STRUCTS(STR_TYPE, GLOBAL##_PAGES); \
|
||||||
INCREMENT_PAGE_STATS(STATS, GLOBAL##_PAGES); \
|
INCREMENT_PAGE_STATS(STATS, GLOBAL##_PAGES); \
|
||||||
{ int wid; \
|
{ \
|
||||||
|
int wid; \
|
||||||
for (wid = 0; wid < MAX_THREADS; wid++) { \
|
for (wid = 0; wid < MAX_THREADS; wid++) { \
|
||||||
if (!Yap_local[wid]) \
|
if (!Yap_local[wid]) \
|
||||||
break; \
|
break; \
|
||||||
@ -186,29 +203,39 @@ struct page_statistics {
|
|||||||
GET_ALL_PAGE_STATS(STATS, STR_TYPE, _PAGES); \
|
GET_ALL_PAGE_STATS(STATS, STR_TYPE, _PAGES); \
|
||||||
PgEnt_bytes_in_use(STATS) = PgEnt_strs_in_use(STATS) * sizeof(STR_TYPE)
|
PgEnt_bytes_in_use(STATS) = PgEnt_strs_in_use(STATS) * sizeof(STR_TYPE)
|
||||||
#define SHOW_PAGE_STATS(OUT_STREAM, STR_TYPE, _PAGES, STR_NAME) \
|
#define SHOW_PAGE_STATS(OUT_STREAM, STR_TYPE, _PAGES, STR_NAME) \
|
||||||
{ struct page_statistics stats; \
|
{ \
|
||||||
|
struct page_statistics stats; \
|
||||||
GET_PAGE_STATS(stats, STR_TYPE, _PAGES); \
|
GET_PAGE_STATS(stats, STR_TYPE, _PAGES); \
|
||||||
fprintf(OUT_STREAM, SHOW_PAGE_STATS_MSG(STR_NAME), SHOW_PAGE_STATS_ARGS(stats, STR_TYPE)); \
|
fprintf(OUT_STREAM, SHOW_PAGE_STATS_MSG(STR_NAME), \
|
||||||
|
SHOW_PAGE_STATS_ARGS(stats, STR_TYPE)); \
|
||||||
return stats; \
|
return stats; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************
|
/*******************************
|
||||||
** Global functions **
|
** Global functions **
|
||||||
*******************************/
|
*******************************/
|
||||||
|
|
||||||
void Yap_init_optyap_preds(void) {
|
void Yap_init_optyap_preds(void) {
|
||||||
Yap_InitCPred("$c_yapor_workers", 1, p_yapor_workers, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("$c_yapor_workers", 1, p_yapor_workers,
|
||||||
|
SafePredFlag | SyncPredFlag);
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
Yap_InitCPred("freeze_choice_point", 1, p_freeze_choice_point, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("freeze_choice_point", 1, p_freeze_choice_point,
|
||||||
Yap_InitCPred("wake_choice_point", 1, p_wake_choice_point, SafePredFlag|SyncPredFlag);
|
SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred("abolish_frozen_choice_points", 1, p_abolish_frozen_choice_points_until, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("wake_choice_point", 1, p_wake_choice_point,
|
||||||
Yap_InitCPred("abolish_frozen_choice_points", 0, p_abolish_frozen_choice_points_all, SafePredFlag|SyncPredFlag);
|
SafePredFlag | SyncPredFlag);
|
||||||
|
Yap_InitCPred("abolish_frozen_choice_points", 1,
|
||||||
|
p_abolish_frozen_choice_points_until,
|
||||||
|
SafePredFlag | SyncPredFlag);
|
||||||
|
Yap_InitCPred("abolish_frozen_choice_points", 0,
|
||||||
|
p_abolish_frozen_choice_points_all,
|
||||||
|
SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred("$c_table", 3, p_table, SafePredFlag | SyncPredFlag);
|
Yap_InitCPred("$c_table", 3, p_table, SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred("$c_tabling_mode", 3, p_tabling_mode, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("$c_tabling_mode", 3, p_tabling_mode,
|
||||||
Yap_InitCPred("$c_abolish_table", 2, p_abolish_table, SafePredFlag|SyncPredFlag);
|
SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred("abolish_all_tables", 0, p_abolish_all_tables, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("$c_abolish_table", 2, p_abolish_table,
|
||||||
|
SafePredFlag | SyncPredFlag);
|
||||||
|
Yap_InitCPred("abolish_all_tables", 0, p_abolish_all_tables,
|
||||||
|
SafePredFlag | SyncPredFlag);
|
||||||
/** @pred abolish_all_tables/0
|
/** @pred abolish_all_tables/0
|
||||||
|
|
||||||
|
|
||||||
@ -217,29 +244,41 @@ predicates. The predicates remain as tabled predicates.
|
|||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
Yap_InitCPred("show_tabled_predicates", 1, p_show_tabled_predicates, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("show_tabled_predicates", 1, p_show_tabled_predicates,
|
||||||
|
SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred("$c_show_table", 3, p_show_table, SafePredFlag | SyncPredFlag);
|
Yap_InitCPred("$c_show_table", 3, p_show_table, SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred("show_all_tables", 1, p_show_all_tables, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("show_all_tables", 1, p_show_all_tables,
|
||||||
Yap_InitCPred("show_global_trie", 1, p_show_global_trie, SafePredFlag|SyncPredFlag);
|
SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred("$c_table_statistics", 3, p_show_statistics_table, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("show_global_trie", 1, p_show_global_trie,
|
||||||
Yap_InitCPred("tabling_statistics", 1, p_show_statistics_tabling, SafePredFlag|SyncPredFlag);
|
SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred("global_trie_statistics", 1, p_show_statistics_global_trie, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("$c_table_statistics", 3, p_show_statistics_table,
|
||||||
|
SafePredFlag | SyncPredFlag);
|
||||||
|
Yap_InitCPred("tabling_statistics", 1, p_show_statistics_tabling,
|
||||||
|
SafePredFlag | SyncPredFlag);
|
||||||
|
Yap_InitCPred("global_trie_statistics", 1, p_show_statistics_global_trie,
|
||||||
|
SafePredFlag | SyncPredFlag);
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
Yap_InitCPred("parallel_mode", 1, p_parallel_mode, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("parallel_mode", 1, p_parallel_mode,
|
||||||
Yap_InitCPred("$c_yapor_start", 0, p_yapor_start, SafePredFlag|SyncPredFlag);
|
SafePredFlag | SyncPredFlag);
|
||||||
|
Yap_InitCPred("$c_yapor_start", 0, p_yapor_start,
|
||||||
|
SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred("$c_worker", 0, p_worker, SafePredFlag | SyncPredFlag);
|
Yap_InitCPred("$c_worker", 0, p_worker, SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred("$c_parallel_new_answer", 1, p_parallel_new_answer, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("$c_parallel_new_answer", 1, p_parallel_new_answer,
|
||||||
Yap_InitCPred("$c_parallel_get_answers", 1, p_parallel_get_answers, SafePredFlag|SyncPredFlag);
|
SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred("or_statistics", 1, p_show_statistics_or, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("$c_parallel_get_answers", 1, p_parallel_get_answers,
|
||||||
|
SafePredFlag | SyncPredFlag);
|
||||||
|
Yap_InitCPred("or_statistics", 1, p_show_statistics_or,
|
||||||
|
SafePredFlag | SyncPredFlag);
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
#if defined(YAPOR) && defined(TABLING)
|
#if defined(YAPOR) && defined(TABLING)
|
||||||
Yap_InitCPred("opt_statistics", 1, p_show_statistics_opt, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("opt_statistics", 1, p_show_statistics_opt,
|
||||||
|
SafePredFlag | SyncPredFlag);
|
||||||
#endif /* YAPOR && TABLING */
|
#endif /* YAPOR && TABLING */
|
||||||
Yap_InitCPred("$c_get_optyap_statistics", 3, p_get_optyap_statistics, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("$c_get_optyap_statistics", 3, p_get_optyap_statistics,
|
||||||
|
SafePredFlag | SyncPredFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
void finish_yapor(void) {
|
void finish_yapor(void) {
|
||||||
GLOBAL_execution_time = current_time() - GLOBAL_execution_time;
|
GLOBAL_execution_time = current_time() - GLOBAL_execution_time;
|
||||||
@ -248,8 +287,6 @@ void finish_yapor(void) {
|
|||||||
}
|
}
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************
|
/***********************************
|
||||||
** Tabling C Predicates **
|
** Tabling C Predicates **
|
||||||
***********************************/
|
***********************************/
|
||||||
@ -263,7 +300,6 @@ static Int p_freeze_choice_point( USES_REGS1 ) {
|
|||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int p_wake_choice_point(USES_REGS1) {
|
static Int p_wake_choice_point(USES_REGS1) {
|
||||||
Term term_offset = Deref(ARG1);
|
Term term_offset = Deref(ARG1);
|
||||||
if (IsIntegerTerm(term_offset))
|
if (IsIntegerTerm(term_offset))
|
||||||
@ -271,7 +307,6 @@ static Int p_wake_choice_point( USES_REGS1 ) {
|
|||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int p_abolish_frozen_choice_points_until(USES_REGS1) {
|
static Int p_abolish_frozen_choice_points_until(USES_REGS1) {
|
||||||
Term term_offset = Deref(ARG1);
|
Term term_offset = Deref(ARG1);
|
||||||
if (IsIntegerTerm(term_offset))
|
if (IsIntegerTerm(term_offset))
|
||||||
@ -279,13 +314,11 @@ static Int p_abolish_frozen_choice_points_until( USES_REGS1 ) {
|
|||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int p_abolish_frozen_choice_points_all(USES_REGS1) {
|
static Int p_abolish_frozen_choice_points_all(USES_REGS1) {
|
||||||
abolish_frozen_cps_all();
|
abolish_frozen_cps_all();
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int p_table(USES_REGS1) {
|
static Int p_table(USES_REGS1) {
|
||||||
Term mod, t, list;
|
Term mod, t, list;
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
@ -312,13 +345,17 @@ static Int p_table( USES_REGS1 ) {
|
|||||||
return (FALSE);
|
return (FALSE);
|
||||||
if (list != TermNil) { /* non-empty list */
|
if (list != TermNil) { /* non-empty list */
|
||||||
#ifndef MODE_DIRECTED_TABLING
|
#ifndef MODE_DIRECTED_TABLING
|
||||||
Yap_Error(SYSTEM_ERROR_COMPILER, TermNil, "invalid tabling declaration for %s/%d (mode directed tabling not enabled)", AtomName(at), arity);
|
Yap_Error(SYSTEM_ERROR_COMPILER, TermNil, "invalid tabling declaration for "
|
||||||
|
"%s/%d (mode directed tabling "
|
||||||
|
"not enabled)",
|
||||||
|
AtomName(at), arity);
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
#else
|
#else
|
||||||
/*************************************************************************************
|
/*************************************************************************************
|
||||||
The mode operator declaration is reordered as follows:
|
The mode operator declaration is reordered as follows:
|
||||||
1. arguments with mode 'index' (any number)
|
1. arguments with mode 'index' (any number)
|
||||||
2. arguments with mode 'min' and 'max' (any number, following the original order)
|
2. arguments with mode 'min' and 'max' (any number, following the
|
||||||
|
original order)
|
||||||
3. arguments with mode 'all' (any number)
|
3. arguments with mode 'all' (any number)
|
||||||
4. arguments with mode 'sum' or 'last' (only one of the two is allowed)
|
4. arguments with mode 'sum' or 'last' (only one of the two is allowed)
|
||||||
5. arguments with mode 'first' (any number)
|
5. arguments with mode 'first' (any number)
|
||||||
@ -343,7 +380,10 @@ static Int p_table( USES_REGS1 ) {
|
|||||||
else if (mode == MODE_DIRECTED_SUM || mode == MODE_DIRECTED_LAST) {
|
else if (mode == MODE_DIRECTED_SUM || mode == MODE_DIRECTED_LAST) {
|
||||||
if (pos_sum_last) {
|
if (pos_sum_last) {
|
||||||
free(aux_mode_directed);
|
free(aux_mode_directed);
|
||||||
Yap_Error(SYSTEM_ERROR_COMPILER, TermNil, "invalid tabling declaration for %s/%d (more than one argument with modes 'sum' and/or 'last')", AtomName(at), arity);
|
Yap_Error(SYSTEM_ERROR_COMPILER, TermNil,
|
||||||
|
"invalid tabling declaration for %s/%d (more than one "
|
||||||
|
"argument with modes 'sum' and/or 'last')",
|
||||||
|
AtomName(at), arity);
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
} else
|
} else
|
||||||
pos_sum_last = 1;
|
pos_sum_last = 1;
|
||||||
@ -361,11 +401,13 @@ static Int p_table( USES_REGS1 ) {
|
|||||||
int aux_pos = 0;
|
int aux_pos = 0;
|
||||||
if (aux_mode_directed[i] == MODE_DIRECTED_INDEX)
|
if (aux_mode_directed[i] == MODE_DIRECTED_INDEX)
|
||||||
aux_pos = pos_index++;
|
aux_pos = pos_index++;
|
||||||
else if (aux_mode_directed[i] == MODE_DIRECTED_MIN || aux_mode_directed[i] == MODE_DIRECTED_MAX)
|
else if (aux_mode_directed[i] == MODE_DIRECTED_MIN ||
|
||||||
|
aux_mode_directed[i] == MODE_DIRECTED_MAX)
|
||||||
aux_pos = pos_min_max++;
|
aux_pos = pos_min_max++;
|
||||||
else if (aux_mode_directed[i] == MODE_DIRECTED_ALL)
|
else if (aux_mode_directed[i] == MODE_DIRECTED_ALL)
|
||||||
aux_pos = pos_all++;
|
aux_pos = pos_all++;
|
||||||
else if (aux_mode_directed[i] == MODE_DIRECTED_SUM || aux_mode_directed[i] == MODE_DIRECTED_LAST)
|
else if (aux_mode_directed[i] == MODE_DIRECTED_SUM ||
|
||||||
|
aux_mode_directed[i] == MODE_DIRECTED_LAST)
|
||||||
aux_pos = pos_sum_last++;
|
aux_pos = pos_sum_last++;
|
||||||
else if (aux_mode_directed[i] == MODE_DIRECTED_FIRST)
|
else if (aux_mode_directed[i] == MODE_DIRECTED_FIRST)
|
||||||
aux_pos = pos_first++;
|
aux_pos = pos_first++;
|
||||||
@ -386,7 +428,6 @@ static Int p_table( USES_REGS1 ) {
|
|||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int p_tabling_mode(USES_REGS1) {
|
static Int p_tabling_mode(USES_REGS1) {
|
||||||
Term mod, t, tvalue;
|
Term mod, t, tvalue;
|
||||||
tab_ent_ptr tab_ent;
|
tab_ent_ptr tab_ent;
|
||||||
@ -470,7 +511,8 @@ static Int p_tabling_mode( USES_REGS1 ) {
|
|||||||
SetMode_GlobalTrie(TabEnt_mode(tab_ent));
|
SetMode_GlobalTrie(TabEnt_mode(tab_ent));
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
} else if (value == 7) { /* coinductive */ //only affect the predicate flag. Also it cant be unset
|
} else if (value == 7) {
|
||||||
|
/* coinductive */ // only affect the predicate flag. Also it cant be unset
|
||||||
SetMode_CoInductive(TabEnt_flags(tab_ent));
|
SetMode_CoInductive(TabEnt_flags(tab_ent));
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
@ -478,7 +520,6 @@ static Int p_tabling_mode( USES_REGS1 ) {
|
|||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int p_abolish_table(USES_REGS1) {
|
static Int p_abolish_table(USES_REGS1) {
|
||||||
Term mod, t;
|
Term mod, t;
|
||||||
tab_ent_ptr tab_ent;
|
tab_ent_ptr tab_ent;
|
||||||
@ -495,7 +536,6 @@ static Int p_abolish_table( USES_REGS1 ) {
|
|||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int p_abolish_all_tables(USES_REGS1) {
|
static Int p_abolish_all_tables(USES_REGS1) {
|
||||||
tab_ent_ptr tab_ent;
|
tab_ent_ptr tab_ent;
|
||||||
|
|
||||||
@ -507,7 +547,6 @@ static Int p_abolish_all_tables( USES_REGS1 ) {
|
|||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int p_show_tabled_predicates(USES_REGS1) {
|
static Int p_show_tabled_predicates(USES_REGS1) {
|
||||||
FILE *out;
|
FILE *out;
|
||||||
tab_ent_ptr tab_ent;
|
tab_ent_ptr tab_ent;
|
||||||
@ -521,15 +560,16 @@ static Int p_show_tabled_predicates( USES_REGS1 ) {
|
|||||||
fprintf(out, "Tabled predicates\n");
|
fprintf(out, "Tabled predicates\n");
|
||||||
if (tab_ent == NULL)
|
if (tab_ent == NULL)
|
||||||
fprintf(out, " NONE\n");
|
fprintf(out, " NONE\n");
|
||||||
else while(tab_ent) {
|
else
|
||||||
fprintf(out, " %s/%d\n", AtomName(TabEnt_atom(tab_ent)), TabEnt_arity(tab_ent));
|
while (tab_ent) {
|
||||||
|
fprintf(out, " %s/%d\n", AtomName(TabEnt_atom(tab_ent)),
|
||||||
|
TabEnt_arity(tab_ent));
|
||||||
tab_ent = TabEnt_next(tab_ent);
|
tab_ent = TabEnt_next(tab_ent);
|
||||||
}
|
}
|
||||||
// PL_release_stream(out);
|
// PL_release_stream(out);
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int p_show_table(USES_REGS1) {
|
static Int p_show_table(USES_REGS1) {
|
||||||
Term mod, t;
|
Term mod, t;
|
||||||
tab_ent_ptr tab_ent;
|
tab_ent_ptr tab_ent;
|
||||||
@ -553,7 +593,6 @@ static Int p_show_table( USES_REGS1 ) {
|
|||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int p_show_all_tables(USES_REGS1) {
|
static Int p_show_all_tables(USES_REGS1) {
|
||||||
tab_ent_ptr tab_ent;
|
tab_ent_ptr tab_ent;
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
@ -571,7 +610,6 @@ static Int p_show_all_tables( USES_REGS1 ) {
|
|||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int p_show_global_trie(USES_REGS1) {
|
static Int p_show_global_trie(USES_REGS1) {
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
FILE *out;
|
FILE *out;
|
||||||
@ -584,7 +622,6 @@ static Int p_show_global_trie( USES_REGS1 ) {
|
|||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int p_show_statistics_table(USES_REGS1) {
|
static Int p_show_statistics_table(USES_REGS1) {
|
||||||
Term mod, t;
|
Term mod, t;
|
||||||
tab_ent_ptr tab_ent;
|
tab_ent_ptr tab_ent;
|
||||||
@ -609,7 +646,6 @@ static Int p_show_statistics_table( USES_REGS1 ) {
|
|||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int p_show_statistics_tabling(USES_REGS1) {
|
static Int p_show_statistics_tabling(USES_REGS1) {
|
||||||
struct page_statistics stats;
|
struct page_statistics stats;
|
||||||
long bytes, total_bytes = 0;
|
long bytes, total_bytes = 0;
|
||||||
@ -662,10 +698,14 @@ static Int p_show_statistics_tabling( USES_REGS1 ) {
|
|||||||
fprintf(out, " Memory in use (III): %10ld bytes\n\n", bytes);
|
fprintf(out, " Memory in use (III): %10ld bytes\n\n", bytes);
|
||||||
total_bytes += bytes;
|
total_bytes += bytes;
|
||||||
#ifdef USE_PAGES_MALLOC
|
#ifdef USE_PAGES_MALLOC
|
||||||
fprintf(out, "Total memory in use (I+II+III): %10ld bytes (%ld pages in use)\n",
|
fprintf(out,
|
||||||
|
"Total memory in use (I+II+III): %10ld bytes (%ld pages in use)\n",
|
||||||
total_bytes, total_pages);
|
total_bytes, total_pages);
|
||||||
fprintf(out, "Total memory allocated: %10ld bytes (%ld pages in total)\n",
|
fprintf(
|
||||||
PgEnt_pages_in_use(GLOBAL_pages_alloc) * Yap_page_size, PgEnt_pages_in_use(GLOBAL_pages_alloc));
|
out,
|
||||||
|
"Total memory allocated: %10ld bytes (%ld pages in total)\n",
|
||||||
|
PgEnt_pages_in_use(GLOBAL_pages_alloc) * Yap_page_size,
|
||||||
|
PgEnt_pages_in_use(GLOBAL_pages_alloc));
|
||||||
#else
|
#else
|
||||||
fprintf(out, "Total memory in use (I+II+III): %10ld bytes\n", total_bytes);
|
fprintf(out, "Total memory in use (I+II+III): %10ld bytes\n", total_bytes);
|
||||||
#endif /* USE_PAGES_MALLOC */
|
#endif /* USE_PAGES_MALLOC */
|
||||||
@ -673,7 +713,6 @@ static Int p_show_statistics_tabling( USES_REGS1 ) {
|
|||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int p_show_statistics_global_trie(USES_REGS1) {
|
static Int p_show_statistics_global_trie(USES_REGS1) {
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
FILE *out;
|
FILE *out;
|
||||||
@ -687,8 +726,6 @@ static Int p_show_statistics_global_trie( USES_REGS1 ) {
|
|||||||
}
|
}
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************
|
/*********************************
|
||||||
** YapOr C Predicates **
|
** YapOr C Predicates **
|
||||||
*********************************/
|
*********************************/
|
||||||
@ -724,7 +761,6 @@ static Int p_parallel_mode( USES_REGS1 ) {
|
|||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int p_yapor_start(USES_REGS1) {
|
static Int p_yapor_start(USES_REGS1) {
|
||||||
#ifdef TIMESTAMP_CHECK
|
#ifdef TIMESTAMP_CHECK
|
||||||
GLOBAL_timestamp = 0;
|
GLOBAL_timestamp = 0;
|
||||||
@ -742,7 +778,6 @@ static Int p_yapor_start( USES_REGS1 ) {
|
|||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int p_yapor_workers(USES_REGS1) {
|
static Int p_yapor_workers(USES_REGS1) {
|
||||||
#ifdef YAPOR_THREADS
|
#ifdef YAPOR_THREADS
|
||||||
return Yap_unify(MkIntegerTerm(GLOBAL_number_workers), ARG1);
|
return Yap_unify(MkIntegerTerm(GLOBAL_number_workers), ARG1);
|
||||||
@ -751,14 +786,12 @@ static Int p_yapor_workers( USES_REGS1 ) {
|
|||||||
#endif /* YAPOR_THREADS */
|
#endif /* YAPOR_THREADS */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int p_worker(USES_REGS1) {
|
static Int p_worker(USES_REGS1) {
|
||||||
CurrentModule = USER_MODULE;
|
CurrentModule = USER_MODULE;
|
||||||
P = GETWORK_FIRST_TIME;
|
P = GETWORK_FIRST_TIME;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int p_parallel_new_answer(USES_REGS1) {
|
static Int p_parallel_new_answer(USES_REGS1) {
|
||||||
qg_ans_fr_ptr actual_answer;
|
qg_ans_fr_ptr actual_answer;
|
||||||
or_fr_ptr leftmost_or_fr;
|
or_fr_ptr leftmost_or_fr;
|
||||||
@ -778,7 +811,6 @@ static Int p_parallel_new_answer( USES_REGS1 ) {
|
|||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int p_parallel_get_answers(USES_REGS1) {
|
static Int p_parallel_get_answers(USES_REGS1) {
|
||||||
Term t = TermNil;
|
Term t = TermNil;
|
||||||
|
|
||||||
@ -798,7 +830,6 @@ static Int p_parallel_get_answers( USES_REGS1 ){
|
|||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int p_show_statistics_or(USES_REGS1) {
|
static Int p_show_statistics_or(USES_REGS1) {
|
||||||
struct page_statistics stats;
|
struct page_statistics stats;
|
||||||
long bytes, total_bytes = 0;
|
long bytes, total_bytes = 0;
|
||||||
@ -809,7 +840,8 @@ static Int p_show_statistics_or( USES_REGS1 ) {
|
|||||||
|
|
||||||
if (!IsStreamTerm(t))
|
if (!IsStreamTerm(t))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ bytes = 0;
|
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ bytes =
|
||||||
|
0;
|
||||||
fprintf(out, "Execution data structures\n");
|
fprintf(out, "Execution data structures\n");
|
||||||
stats = show_statistics_or_frames(out);
|
stats = show_statistics_or_frames(out);
|
||||||
INCREMENT_AUX_STATS(stats, bytes, total_pages);
|
INCREMENT_AUX_STATS(stats, bytes, total_pages);
|
||||||
@ -824,10 +856,14 @@ static Int p_show_statistics_or( USES_REGS1 ) {
|
|||||||
fprintf(out, " Memory in use (II): %10ld bytes\n\n", bytes);
|
fprintf(out, " Memory in use (II): %10ld bytes\n\n", bytes);
|
||||||
total_bytes += bytes;
|
total_bytes += bytes;
|
||||||
#ifdef USE_PAGES_MALLOC
|
#ifdef USE_PAGES_MALLOC
|
||||||
fprintf(out, "Total memory in use (I+II): %10ld bytes (%ld pages in use)\n",
|
fprintf(out,
|
||||||
|
"Total memory in use (I+II): %10ld bytes (%ld pages in use)\n",
|
||||||
total_bytes, total_pages);
|
total_bytes, total_pages);
|
||||||
fprintf(out, "Total memory allocated: %10ld bytes (%ld pages in total)\n",
|
fprintf(
|
||||||
PgEnt_pages_in_use(GLOBAL_pages_alloc) * Yap_page_size, PgEnt_pages_in_use(GLOBAL_pages_alloc));
|
out,
|
||||||
|
"Total memory allocated: %10ld bytes (%ld pages in total)\n",
|
||||||
|
PgEnt_pages_in_use(GLOBAL_pages_alloc) * Yap_page_size,
|
||||||
|
PgEnt_pages_in_use(GLOBAL_pages_alloc));
|
||||||
#else
|
#else
|
||||||
fprintf(out, "Total memory in use (I+II): %10ld bytes\n", total_bytes);
|
fprintf(out, "Total memory in use (I+II): %10ld bytes\n", total_bytes);
|
||||||
#endif /* USE_PAGES_MALLOC */
|
#endif /* USE_PAGES_MALLOC */
|
||||||
@ -837,13 +873,9 @@ static Int p_show_statistics_or( USES_REGS1 ) {
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
static Int p_yapor_workers( USES_REGS1 ) {
|
static Int p_yapor_workers(USES_REGS1) { return FALSE; }
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************
|
/**********************************
|
||||||
** OPTYap C Predicates **
|
** OPTYap C Predicates **
|
||||||
**********************************/
|
**********************************/
|
||||||
@ -919,10 +951,14 @@ static Int p_show_statistics_opt( USES_REGS1 ) {
|
|||||||
fprintf(out, " Memory in use (IV): %10ld bytes\n\n", bytes);
|
fprintf(out, " Memory in use (IV): %10ld bytes\n\n", bytes);
|
||||||
total_bytes += bytes;
|
total_bytes += bytes;
|
||||||
#ifdef USE_PAGES_MALLOC
|
#ifdef USE_PAGES_MALLOC
|
||||||
fprintf(out, "Total memory in use (I+II+III+IV): %10ld bytes (%ld pages in use)\n",
|
fprintf(out,
|
||||||
|
"Total memory in use (I+II+III+IV): %10ld bytes (%ld pages in use)\n",
|
||||||
total_bytes, total_pages);
|
total_bytes, total_pages);
|
||||||
fprintf(out, "Total memory allocated: %10ld bytes (%ld pages in total)\n",
|
fprintf(
|
||||||
PgEnt_pages_in_use(GLOBAL_pages_alloc) * Yap_page_size, PgEnt_pages_in_use(GLOBAL_pages_alloc));
|
out,
|
||||||
|
"Total memory allocated: %10ld bytes (%ld pages in total)\n",
|
||||||
|
PgEnt_pages_in_use(GLOBAL_pages_alloc) * Yap_page_size,
|
||||||
|
PgEnt_pages_in_use(GLOBAL_pages_alloc));
|
||||||
#else
|
#else
|
||||||
fprintf(out, "Total memory in use (I+II+III+IV): %10ld bytes\n", total_bytes);
|
fprintf(out, "Total memory in use (I+II+III+IV): %10ld bytes\n", total_bytes);
|
||||||
#endif /* USE_PAGES_MALLOC */
|
#endif /* USE_PAGES_MALLOC */
|
||||||
@ -931,7 +967,6 @@ static Int p_show_statistics_opt( USES_REGS1 ) {
|
|||||||
}
|
}
|
||||||
#endif /* YAPOR && TABLING */
|
#endif /* YAPOR && TABLING */
|
||||||
|
|
||||||
|
|
||||||
static Int p_get_optyap_statistics(USES_REGS1) {
|
static Int p_get_optyap_statistics(USES_REGS1) {
|
||||||
struct page_statistics stats;
|
struct page_statistics stats;
|
||||||
Int value, bytes = 0, structs = -1;
|
Int value, bytes = 0, structs = -1;
|
||||||
@ -942,96 +977,114 @@ static Int p_get_optyap_statistics( USES_REGS1 ) {
|
|||||||
if (value == 0 || value == 1) { /* table_entries */
|
if (value == 0 || value == 1) { /* table_entries */
|
||||||
GET_PAGE_STATS(stats, struct table_entry, _pages_tab_ent);
|
GET_PAGE_STATS(stats, struct table_entry, _pages_tab_ent);
|
||||||
bytes += PgEnt_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
if (value != 0)
|
||||||
|
structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
||||||
if (value == 0 || value == 16) { /* subgoal_entries */
|
if (value == 0 || value == 16) { /* subgoal_entries */
|
||||||
GET_PAGE_STATS(stats, struct subgoal_entry, _pages_sg_ent);
|
GET_PAGE_STATS(stats, struct subgoal_entry, _pages_sg_ent);
|
||||||
bytes += PgEnt_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
if (value != 0)
|
||||||
|
structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (value == 0 || value == 2) { /* subgoal_frames */
|
if (value == 0 || value == 2) { /* subgoal_frames */
|
||||||
GET_PAGE_STATS(stats, struct subgoal_frame, _pages_sg_fr);
|
GET_PAGE_STATS(stats, struct subgoal_frame, _pages_sg_fr);
|
||||||
bytes += PgEnt_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
if (value != 0)
|
||||||
|
structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
if (value == 0 || value == 3) { /* dependency_frames */
|
if (value == 0 || value == 3) { /* dependency_frames */
|
||||||
GET_PAGE_STATS(stats, struct dependency_frame, _pages_dep_fr);
|
GET_PAGE_STATS(stats, struct dependency_frame, _pages_dep_fr);
|
||||||
bytes += PgEnt_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
if (value != 0)
|
||||||
|
structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
if (value == 0 || value == 6) { /* subgoal_trie_nodes */
|
if (value == 0 || value == 6) { /* subgoal_trie_nodes */
|
||||||
GET_PAGE_STATS(stats, struct subgoal_trie_node, _pages_sg_node);
|
GET_PAGE_STATS(stats, struct subgoal_trie_node, _pages_sg_node);
|
||||||
bytes += PgEnt_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
if (value != 0)
|
||||||
|
structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
if (value == 0 || value == 8) { /* subgoal_trie_hashes */
|
if (value == 0 || value == 8) { /* subgoal_trie_hashes */
|
||||||
GET_PAGE_STATS(stats, struct subgoal_trie_hash, _pages_sg_hash);
|
GET_PAGE_STATS(stats, struct subgoal_trie_hash, _pages_sg_hash);
|
||||||
bytes += PgEnt_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
if (value != 0)
|
||||||
|
structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
if (value == 0 || value == 7) { /* answer_trie_nodes */
|
if (value == 0 || value == 7) { /* answer_trie_nodes */
|
||||||
GET_PAGE_STATS(stats, struct answer_trie_node, _pages_ans_node);
|
GET_PAGE_STATS(stats, struct answer_trie_node, _pages_ans_node);
|
||||||
bytes += PgEnt_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
if (value != 0)
|
||||||
|
structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
if (value == 0 || value == 9) { /* answer_trie_hashes */
|
if (value == 0 || value == 9) { /* answer_trie_hashes */
|
||||||
GET_PAGE_STATS(stats, struct answer_trie_hash, _pages_ans_hash);
|
GET_PAGE_STATS(stats, struct answer_trie_hash, _pages_ans_hash);
|
||||||
bytes += PgEnt_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
if (value != 0)
|
||||||
|
structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
#if defined(THREADS_FULL_SHARING)
|
#if defined(THREADS_FULL_SHARING)
|
||||||
if (value == 0 || value == 17) { /* answer_ref_nodes */
|
if (value == 0 || value == 17) { /* answer_ref_nodes */
|
||||||
GET_PAGE_STATS(stats, struct answer_ref_node, _pages_ans_ref_node);
|
GET_PAGE_STATS(stats, struct answer_ref_node, _pages_ans_ref_node);
|
||||||
bytes += PgEnt_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
if (value != 0)
|
||||||
|
structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (value == 0 || value == 10) { /* global_trie_nodes */
|
if (value == 0 || value == 10) { /* global_trie_nodes */
|
||||||
GET_PAGE_STATS(stats, struct global_trie_node, _pages_gt_node);
|
GET_PAGE_STATS(stats, struct global_trie_node, _pages_gt_node);
|
||||||
bytes += PgEnt_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
if (value != 0)
|
||||||
|
structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
if (value == 0 || value == 11) { /* global_trie_hashes */
|
if (value == 0 || value == 11) { /* global_trie_hashes */
|
||||||
GET_PAGE_STATS(stats, struct global_trie_hash, _pages_gt_hash);
|
GET_PAGE_STATS(stats, struct global_trie_hash, _pages_gt_hash);
|
||||||
bytes += PgEnt_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
if (value != 0)
|
||||||
|
structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
if (value == 0 || value == 4) { /* or_frames */
|
if (value == 0 || value == 4) { /* or_frames */
|
||||||
GET_PAGE_STATS(stats, struct or_frame, _pages_or_fr);
|
GET_PAGE_STATS(stats, struct or_frame, _pages_or_fr);
|
||||||
bytes += PgEnt_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
if (value != 0)
|
||||||
|
structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
if (value == 0 || value == 12) { /* query_goal_solution_frames */
|
if (value == 0 || value == 12) { /* query_goal_solution_frames */
|
||||||
GET_PAGE_STATS(stats, struct query_goal_solution_frame, _pages_qg_sol_fr);
|
GET_PAGE_STATS(stats, struct query_goal_solution_frame, _pages_qg_sol_fr);
|
||||||
bytes += PgEnt_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
if (value != 0)
|
||||||
|
structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
if (value == 0 || value == 13) { /* query_goal_answer_frames */
|
if (value == 0 || value == 13) { /* query_goal_answer_frames */
|
||||||
GET_PAGE_STATS(stats, struct query_goal_answer_frame, _pages_qg_ans_fr);
|
GET_PAGE_STATS(stats, struct query_goal_answer_frame, _pages_qg_ans_fr);
|
||||||
bytes += PgEnt_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
if (value != 0)
|
||||||
|
structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
#if defined(YAPOR) && defined(TABLING)
|
#if defined(YAPOR) && defined(TABLING)
|
||||||
if (value == 0 || value == 5) { /* suspension_frames */
|
if (value == 0 || value == 5) { /* suspension_frames */
|
||||||
GET_PAGE_STATS(stats, struct suspension_frame, _pages_susp_fr);
|
GET_PAGE_STATS(stats, struct suspension_frame, _pages_susp_fr);
|
||||||
bytes += PgEnt_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
if (value != 0)
|
||||||
|
structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
#ifdef TABLING_INNER_CUTS
|
#ifdef TABLING_INNER_CUTS
|
||||||
if (value == 0 || value == 14) { /* table_subgoal_solution_frames */
|
if (value == 0 || value == 14) { /* table_subgoal_solution_frames */
|
||||||
GET_PAGE_STATS(stats, struct table_subgoal_solution_frame, _pages_tg_sol_fr);
|
GET_PAGE_STATS(stats, struct table_subgoal_solution_frame,
|
||||||
|
_pages_tg_sol_fr);
|
||||||
bytes += PgEnt_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
if (value != 0)
|
||||||
|
structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
if (value == 0 || value == 15) { /* table_subgoal_answer_frames */
|
if (value == 0 || value == 15) { /* table_subgoal_answer_frames */
|
||||||
GET_PAGE_STATS(stats, struct table_subgoal_answer_frame, _pages_tg_ans_fr);
|
GET_PAGE_STATS(stats, struct table_subgoal_answer_frame, _pages_tg_ans_fr);
|
||||||
bytes += PgEnt_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
if (value != 0)
|
||||||
|
structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
#endif /* TABLING_INNER_CUTS */
|
#endif /* TABLING_INNER_CUTS */
|
||||||
#endif /* YAPOR && TABLING */
|
#endif /* YAPOR && TABLING */
|
||||||
@ -1058,8 +1111,6 @@ static Int p_get_optyap_statistics( USES_REGS1 ) {
|
|||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/******************************
|
/******************************
|
||||||
** Local functions **
|
** Local functions **
|
||||||
******************************/
|
******************************/
|
||||||
@ -1079,99 +1130,113 @@ static inline realtime current_time(void) {
|
|||||||
}
|
}
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
|
|
||||||
|
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
static inline struct page_statistics show_statistics_table_entries(FILE *out) {
|
static inline struct page_statistics show_statistics_table_entries(FILE *out) {
|
||||||
SHOW_PAGE_STATS(out, struct table_entry, _pages_tab_ent, "Table entries: ");
|
SHOW_PAGE_STATS(out, struct table_entry, _pages_tab_ent,
|
||||||
|
"Table entries: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
||||||
static inline struct page_statistics show_statistics_subgoal_entries(FILE *out) {
|
static inline struct page_statistics
|
||||||
SHOW_PAGE_STATS(out, struct subgoal_entry, _pages_sg_ent, "Subgoal entries: ");
|
show_statistics_subgoal_entries(FILE *out) {
|
||||||
|
SHOW_PAGE_STATS(out, struct subgoal_entry, _pages_sg_ent,
|
||||||
|
"Subgoal entries: ");
|
||||||
}
|
}
|
||||||
#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
|
#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
|
||||||
|
|
||||||
|
|
||||||
static inline struct page_statistics show_statistics_subgoal_frames(FILE *out) {
|
static inline struct page_statistics show_statistics_subgoal_frames(FILE *out) {
|
||||||
SHOW_PAGE_STATS(out, struct subgoal_frame, _pages_sg_fr, "Subgoal frames: ");
|
SHOW_PAGE_STATS(out, struct subgoal_frame, _pages_sg_fr,
|
||||||
|
"Subgoal frames: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct page_statistics
|
||||||
static inline struct page_statistics show_statistics_dependency_frames(FILE *out) {
|
show_statistics_dependency_frames(FILE *out) {
|
||||||
SHOW_PAGE_STATS(out, struct dependency_frame, _pages_dep_fr, "Dependency frames: ");
|
SHOW_PAGE_STATS(out, struct dependency_frame, _pages_dep_fr,
|
||||||
|
"Dependency frames: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct page_statistics
|
||||||
static inline struct page_statistics show_statistics_subgoal_trie_nodes(FILE *out) {
|
show_statistics_subgoal_trie_nodes(FILE *out) {
|
||||||
SHOW_PAGE_STATS(out, struct subgoal_trie_node, _pages_sg_node, "Subgoal trie nodes: ");
|
SHOW_PAGE_STATS(out, struct subgoal_trie_node, _pages_sg_node,
|
||||||
|
"Subgoal trie nodes: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct page_statistics
|
||||||
static inline struct page_statistics show_statistics_subgoal_trie_hashes(FILE *out) {
|
show_statistics_subgoal_trie_hashes(FILE *out) {
|
||||||
SHOW_PAGE_STATS(out, struct subgoal_trie_hash, _pages_sg_hash, "Subgoal trie hashes: ");
|
SHOW_PAGE_STATS(out, struct subgoal_trie_hash, _pages_sg_hash,
|
||||||
|
"Subgoal trie hashes: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct page_statistics
|
||||||
static inline struct page_statistics show_statistics_answer_trie_nodes(FILE *out) {
|
show_statistics_answer_trie_nodes(FILE *out) {
|
||||||
SHOW_PAGE_STATS(out, struct answer_trie_node, _pages_ans_node, "Answer trie nodes: ");
|
SHOW_PAGE_STATS(out, struct answer_trie_node, _pages_ans_node,
|
||||||
|
"Answer trie nodes: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct page_statistics
|
||||||
static inline struct page_statistics show_statistics_answer_trie_hashes(FILE *out) {
|
show_statistics_answer_trie_hashes(FILE *out) {
|
||||||
SHOW_PAGE_STATS(out, struct answer_trie_hash, _pages_ans_hash, "Answer trie hashes: ");
|
SHOW_PAGE_STATS(out, struct answer_trie_hash, _pages_ans_hash,
|
||||||
|
"Answer trie hashes: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(THREADS_FULL_SHARING)
|
#if defined(THREADS_FULL_SHARING)
|
||||||
static inline struct page_statistics show_statistics_answer_ref_nodes(FILE *out) {
|
static inline struct page_statistics
|
||||||
SHOW_PAGE_STATS(out, struct answer_ref_node, _pages_ans_ref_node, "Answer ref nodes: ");
|
show_statistics_answer_ref_nodes(FILE *out) {
|
||||||
|
SHOW_PAGE_STATS(out, struct answer_ref_node, _pages_ans_ref_node,
|
||||||
|
"Answer ref nodes: ");
|
||||||
}
|
}
|
||||||
#endif /* THREADS_FULL_SHARING */
|
#endif /* THREADS_FULL_SHARING */
|
||||||
|
|
||||||
|
static inline struct page_statistics
|
||||||
static inline struct page_statistics show_statistics_global_trie_nodes(FILE *out) {
|
show_statistics_global_trie_nodes(FILE *out) {
|
||||||
SHOW_PAGE_STATS(out, struct global_trie_node, _pages_gt_node, "Global trie nodes: ");
|
SHOW_PAGE_STATS(out, struct global_trie_node, _pages_gt_node,
|
||||||
|
"Global trie nodes: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct page_statistics
|
||||||
static inline struct page_statistics show_statistics_global_trie_hashes(FILE *out) {
|
show_statistics_global_trie_hashes(FILE *out) {
|
||||||
SHOW_PAGE_STATS(out, struct global_trie_hash, _pages_gt_hash, "Global trie hashes: ");
|
SHOW_PAGE_STATS(out, struct global_trie_hash, _pages_gt_hash,
|
||||||
|
"Global trie hashes: ");
|
||||||
}
|
}
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
|
|
||||||
|
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
static inline struct page_statistics show_statistics_or_frames(FILE *out) {
|
static inline struct page_statistics show_statistics_or_frames(FILE *out) {
|
||||||
SHOW_PAGE_STATS(out, struct or_frame, _pages_or_fr, "Or-frames: ");
|
SHOW_PAGE_STATS(out, struct or_frame, _pages_or_fr,
|
||||||
|
"Or-frames: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct page_statistics
|
||||||
static inline struct page_statistics show_statistics_query_goal_solution_frames(FILE *out) {
|
show_statistics_query_goal_solution_frames(FILE *out) {
|
||||||
SHOW_PAGE_STATS(out, struct query_goal_solution_frame, _pages_qg_sol_fr, "Query goal solution frames: ");
|
SHOW_PAGE_STATS(out, struct query_goal_solution_frame, _pages_qg_sol_fr,
|
||||||
|
"Query goal solution frames: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct page_statistics
|
||||||
static inline struct page_statistics show_statistics_query_goal_answer_frames(FILE *out) {
|
show_statistics_query_goal_answer_frames(FILE *out) {
|
||||||
SHOW_PAGE_STATS(out, struct query_goal_answer_frame, _pages_qg_ans_fr, "Query goal answer frames: ");
|
SHOW_PAGE_STATS(out, struct query_goal_answer_frame, _pages_qg_ans_fr,
|
||||||
|
"Query goal answer frames: ");
|
||||||
}
|
}
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
|
|
||||||
|
|
||||||
#if defined(YAPOR) && defined(TABLING)
|
#if defined(YAPOR) && defined(TABLING)
|
||||||
static inline struct page_statistics show_statistics_suspension_frames(FILE *out) {
|
static inline struct page_statistics
|
||||||
SHOW_PAGE_STATS(out, struct suspension_frame, _pages_susp_fr, "Suspension frames: ");
|
show_statistics_suspension_frames(FILE *out) {
|
||||||
|
SHOW_PAGE_STATS(out, struct suspension_frame, _pages_susp_fr,
|
||||||
|
"Suspension frames: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef TABLING_INNER_CUTS
|
#ifdef TABLING_INNER_CUTS
|
||||||
static inline struct page_statistics show_statistics_table_subgoal_solution_frames(FILE *out) {
|
static inline struct page_statistics
|
||||||
SHOW_PAGE_STATS(out, struct table_subgoal_solution_frame, _pages_tg_sol_fr, "Table subgoal solution frames:");
|
show_statistics_table_subgoal_solution_frames(FILE *out) {
|
||||||
|
SHOW_PAGE_STATS(out, struct table_subgoal_solution_frame, _pages_tg_sol_fr,
|
||||||
|
"Table subgoal solution frames:");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct page_statistics
|
||||||
static inline struct page_statistics show_statistics_table_subgoal_answer_frames(FILE *out) {
|
show_statistics_table_subgoal_answer_frames(FILE *out) {
|
||||||
SHOW_PAGE_STATS(out, struct table_subgoal_answer_frame, _pages_tg_ans_fr, "Table subgoal answer frames: ");
|
SHOW_PAGE_STATS(out, struct table_subgoal_answer_frame, _pages_tg_ans_fr,
|
||||||
|
"Table subgoal answer frames: ");
|
||||||
}
|
}
|
||||||
#endif /* TABLING_INNER_CUTS */
|
#endif /* TABLING_INNER_CUTS */
|
||||||
#endif /* YAPOR && TABLING */
|
#endif /* YAPOR && TABLING */
|
||||||
|
@ -22,31 +22,48 @@
|
|||||||
#include "eval.h"
|
#include "eval.h"
|
||||||
#include "tab.macros.h"
|
#include "tab.macros.h"
|
||||||
|
|
||||||
static inline sg_node_ptr subgoal_trie_check_insert_entry(tab_ent_ptr, sg_node_ptr, Term USES_REGS);
|
static inline sg_node_ptr
|
||||||
static inline sg_node_ptr subgoal_trie_check_insert_gt_entry(tab_ent_ptr, sg_node_ptr, Term USES_REGS);
|
subgoal_trie_check_insert_entry(tab_ent_ptr, sg_node_ptr, Term USES_REGS);
|
||||||
static inline ans_node_ptr answer_trie_check_insert_entry(sg_fr_ptr, ans_node_ptr, Term, int USES_REGS);
|
static inline sg_node_ptr
|
||||||
static inline ans_node_ptr answer_trie_check_insert_gt_entry(sg_fr_ptr, ans_node_ptr, Term, int USES_REGS);
|
subgoal_trie_check_insert_gt_entry(tab_ent_ptr, sg_node_ptr, Term USES_REGS);
|
||||||
static inline gt_node_ptr global_trie_check_insert_entry(gt_node_ptr, Term USES_REGS);
|
static inline ans_node_ptr
|
||||||
|
answer_trie_check_insert_entry(sg_fr_ptr, ans_node_ptr, Term, int USES_REGS);
|
||||||
|
static inline ans_node_ptr
|
||||||
|
answer_trie_check_insert_gt_entry(sg_fr_ptr, ans_node_ptr, Term, int USES_REGS);
|
||||||
|
static inline gt_node_ptr global_trie_check_insert_entry(gt_node_ptr,
|
||||||
|
Term USES_REGS);
|
||||||
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
||||||
static inline gt_node_ptr global_trie_check_insert_gt_entry(gt_node_ptr, Term USES_REGS);
|
static inline gt_node_ptr global_trie_check_insert_gt_entry(gt_node_ptr,
|
||||||
|
Term USES_REGS);
|
||||||
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
||||||
static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr, sg_node_ptr, Term, int *, CELL ** USES_REGS);
|
static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr, sg_node_ptr, Term,
|
||||||
static inline sg_node_ptr subgoal_search_terms_loop(tab_ent_ptr, sg_node_ptr, Term, int *, CELL ** USES_REGS);
|
int *, CELL **USES_REGS);
|
||||||
static inline ans_node_ptr answer_search_loop(sg_fr_ptr, ans_node_ptr, Term, int * USES_REGS);
|
static inline sg_node_ptr subgoal_search_terms_loop(tab_ent_ptr, sg_node_ptr,
|
||||||
static inline ans_node_ptr answer_search_terms_loop(sg_fr_ptr, ans_node_ptr, Term, int * USES_REGS);
|
Term, int *,
|
||||||
|
CELL **USES_REGS);
|
||||||
|
static inline ans_node_ptr answer_search_loop(sg_fr_ptr, ans_node_ptr, Term,
|
||||||
|
int *USES_REGS);
|
||||||
|
static inline ans_node_ptr answer_search_terms_loop(sg_fr_ptr, ans_node_ptr,
|
||||||
|
Term, int *USES_REGS);
|
||||||
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
||||||
static inline gt_node_ptr subgoal_search_global_trie_terms_loop(Term, int *, CELL **, CELL * USES_REGS);
|
static inline gt_node_ptr
|
||||||
static inline gt_node_ptr answer_search_global_trie_terms_loop(Term, int *, CELL * USES_REGS);
|
subgoal_search_global_trie_terms_loop(Term, int *, CELL **, CELL *USES_REGS);
|
||||||
|
static inline gt_node_ptr answer_search_global_trie_terms_loop(Term, int *,
|
||||||
|
CELL *USES_REGS);
|
||||||
#else
|
#else
|
||||||
static inline gt_node_ptr subgoal_search_global_trie_loop(Term, int *, CELL ** USES_REGS);
|
static inline gt_node_ptr subgoal_search_global_trie_loop(Term, int *,
|
||||||
|
CELL **USES_REGS);
|
||||||
static inline gt_node_ptr answer_search_global_trie_loop(Term, int *USES_REGS);
|
static inline gt_node_ptr answer_search_global_trie_loop(Term, int *USES_REGS);
|
||||||
#endif /* GLOBAL_TRIE_MODE */
|
#endif /* GLOBAL_TRIE_MODE */
|
||||||
static inline CELL *load_answer_loop(ans_node_ptr USES_REGS);
|
static inline CELL *load_answer_loop(ans_node_ptr USES_REGS);
|
||||||
static inline CELL *load_substitution_loop(gt_node_ptr, int *, CELL *USES_REGS);
|
static inline CELL *load_substitution_loop(gt_node_ptr, int *, CELL *USES_REGS);
|
||||||
static inline CELL *exec_substitution_loop(gt_node_ptr, CELL **, CELL * USES_REGS);
|
static inline CELL *exec_substitution_loop(gt_node_ptr, CELL **,
|
||||||
|
CELL *USES_REGS);
|
||||||
#ifdef MODE_DIRECTED_TABLING
|
#ifdef MODE_DIRECTED_TABLING
|
||||||
static inline ans_node_ptr answer_search_min_max(sg_fr_ptr, ans_node_ptr, Term, int USES_REGS);
|
static inline ans_node_ptr answer_search_min_max(sg_fr_ptr, ans_node_ptr, Term,
|
||||||
static inline ans_node_ptr answer_search_sum(sg_fr_ptr, ans_node_ptr, Term USES_REGS);
|
int USES_REGS);
|
||||||
|
static inline ans_node_ptr answer_search_sum(sg_fr_ptr, ans_node_ptr,
|
||||||
|
Term USES_REGS);
|
||||||
static void invalidate_answer_trie(ans_node_ptr, sg_fr_ptr, int USES_REGS);
|
static void invalidate_answer_trie(ans_node_ptr, sg_fr_ptr, int USES_REGS);
|
||||||
#endif /* MODE_DIRECTED_TABLING */
|
#endif /* MODE_DIRECTED_TABLING */
|
||||||
|
|
||||||
@ -64,15 +81,18 @@ static void free_global_trie_branch(gt_node_ptr, int USES_REGS);
|
|||||||
#else
|
#else
|
||||||
static void free_global_trie_branch(gt_node_ptr USES_REGS);
|
static void free_global_trie_branch(gt_node_ptr USES_REGS);
|
||||||
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
||||||
static void traverse_subgoal_trie(sg_node_ptr, char *, int, int *, int, int USES_REGS);
|
static void traverse_subgoal_trie(sg_node_ptr, char *, int, int *, int,
|
||||||
static void traverse_answer_trie(ans_node_ptr, char *, int, int *, int, int, int USES_REGS);
|
int USES_REGS);
|
||||||
static void traverse_global_trie(gt_node_ptr, char *, int, int *, int, int USES_REGS);
|
static void traverse_answer_trie(ans_node_ptr, char *, int, int *, int, int,
|
||||||
static void traverse_global_trie_for_term(gt_node_ptr, char *, int *, int *, int *, int USES_REGS);
|
int USES_REGS);
|
||||||
static inline void traverse_trie_node(Term, char *, int *, int *, int *, int USES_REGS);
|
static void traverse_global_trie(gt_node_ptr, char *, int, int *, int,
|
||||||
|
int USES_REGS);
|
||||||
|
static void traverse_global_trie_for_term(gt_node_ptr, char *, int *, int *,
|
||||||
|
int *, int USES_REGS);
|
||||||
|
static inline void traverse_trie_node(Term, char *, int *, int *, int *,
|
||||||
|
int USES_REGS);
|
||||||
static inline void traverse_update_arity(char *, int *, int *);
|
static inline void traverse_update_arity(char *, int *, int *);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************
|
/*******************************
|
||||||
** Structs & Macros **
|
** Structs & Macros **
|
||||||
*******************************/
|
*******************************/
|
||||||
@ -128,14 +148,18 @@ static struct trie_statistics{
|
|||||||
#define TrStat_gt_refs trie_stats.global_trie_references
|
#define TrStat_gt_refs trie_stats.global_trie_references
|
||||||
#endif /*THREADS */
|
#endif /*THREADS */
|
||||||
|
|
||||||
#if defined(THREADS_SUBGOAL_SHARING) || defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
#if defined(THREADS_SUBGOAL_SHARING) || defined(THREADS_FULL_SHARING) || \
|
||||||
#define IF_ABOLISH_SUBGOAL_TRIE_SHARED_DATA_STRUCTURES if (GLOBAL_NOfThreads == 1)
|
defined(THREADS_CONSUMER_SHARING)
|
||||||
|
#define IF_ABOLISH_SUBGOAL_TRIE_SHARED_DATA_STRUCTURES \
|
||||||
|
if (GLOBAL_NOfThreads == 1)
|
||||||
#else
|
#else
|
||||||
#define IF_ABOLISH_SUBGOAL_TRIE_SHARED_DATA_STRUCTURES
|
#define IF_ABOLISH_SUBGOAL_TRIE_SHARED_DATA_STRUCTURES
|
||||||
#endif /* THREADS_SUBGOAL_SHARING || THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
|
#endif /* THREADS_SUBGOAL_SHARING || THREADS_FULL_SHARING || \
|
||||||
|
THREADS_CONSUMER_SHARING */
|
||||||
|
|
||||||
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
||||||
#define IF_ABOLISH_ANSWER_TRIE_SHARED_DATA_STRUCTURES if (GLOBAL_NOfThreads == 1)
|
#define IF_ABOLISH_ANSWER_TRIE_SHARED_DATA_STRUCTURES \
|
||||||
|
if (GLOBAL_NOfThreads == 1)
|
||||||
#else
|
#else
|
||||||
#define IF_ABOLISH_ANSWER_TRIE_SHARED_DATA_STRUCTURES
|
#define IF_ABOLISH_ANSWER_TRIE_SHARED_DATA_STRUCTURES
|
||||||
#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
|
#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
|
||||||
@ -147,9 +171,11 @@ static struct trie_statistics{
|
|||||||
fprintf(TrStat_out, MESG, ##ARGS)
|
fprintf(TrStat_out, MESG, ##ARGS)
|
||||||
|
|
||||||
#define CHECK_DECREMENT_GLOBAL_TRIE_REFERENCE(REF, MODE) \
|
#define CHECK_DECREMENT_GLOBAL_TRIE_REFERENCE(REF, MODE) \
|
||||||
if (MODE == TRAVERSE_MODE_NORMAL && IsVarTerm(REF) && REF > VarIndexOfTableTerm(MAX_TABLE_VARS)) { \
|
if (MODE == TRAVERSE_MODE_NORMAL && IsVarTerm(REF) && \
|
||||||
|
REF > VarIndexOfTableTerm(MAX_TABLE_VARS)) { \
|
||||||
register gt_node_ptr gt_node = (gt_node_ptr)(REF); \
|
register gt_node_ptr gt_node = (gt_node_ptr)(REF); \
|
||||||
TrNode_child(gt_node) = (gt_node_ptr) ((uintptr_t) TrNode_child(gt_node) - 1); \
|
TrNode_child(gt_node) = \
|
||||||
|
(gt_node_ptr)((uintptr_t)TrNode_child(gt_node) - 1); \
|
||||||
if (TrNode_child(gt_node) == 0) \
|
if (TrNode_child(gt_node) == 0) \
|
||||||
FREE_GLOBAL_TRIE_BRANCH(gt_node, TRAVERSE_MODE_NORMAL); \
|
FREE_GLOBAL_TRIE_BRANCH(gt_node, TRAVERSE_MODE_NORMAL); \
|
||||||
}
|
}
|
||||||
@ -171,12 +197,12 @@ static struct trie_statistics{
|
|||||||
#include "tab.rational.h"
|
#include "tab.rational.h"
|
||||||
#endif /* RATIONAL TERM SUPPORT FOR TRIES */
|
#endif /* RATIONAL TERM SUPPORT FOR TRIES */
|
||||||
|
|
||||||
|
|
||||||
/******************************
|
/******************************
|
||||||
** Local functions **
|
** Local functions **
|
||||||
******************************/
|
******************************/
|
||||||
|
|
||||||
#define INCLUDE_SUBGOAL_TRIE_CHECK_INSERT /* subgoal_trie_check_insert_entry */
|
#define INCLUDE_SUBGOAL_TRIE_CHECK_INSERT /* subgoal_trie_check_insert_entry \
|
||||||
|
*/
|
||||||
#define INCLUDE_ANSWER_TRIE_CHECK_INSERT /* answer_trie_check_insert_entry */
|
#define INCLUDE_ANSWER_TRIE_CHECK_INSERT /* answer_trie_check_insert_entry */
|
||||||
#define INCLUDE_GLOBAL_TRIE_CHECK_INSERT /* global_trie_check_insert_entry */
|
#define INCLUDE_GLOBAL_TRIE_CHECK_INSERT /* global_trie_check_insert_entry */
|
||||||
#include "tab.tries.h"
|
#include "tab.tries.h"
|
||||||
@ -185,10 +211,13 @@ static struct trie_statistics{
|
|||||||
#undef INCLUDE_SUBGOAL_TRIE_CHECK_INSERT
|
#undef INCLUDE_SUBGOAL_TRIE_CHECK_INSERT
|
||||||
|
|
||||||
#define MODE_GLOBAL_TRIE_ENTRY
|
#define MODE_GLOBAL_TRIE_ENTRY
|
||||||
#define INCLUDE_SUBGOAL_TRIE_CHECK_INSERT /* subgoal_trie_check_insert_gt_entry */
|
#define INCLUDE_SUBGOAL_TRIE_CHECK_INSERT /* subgoal_trie_check_insert_gt_entry \
|
||||||
#define INCLUDE_ANSWER_TRIE_CHECK_INSERT /* answer_trie_check_insert_gt_entry */
|
*/
|
||||||
|
#define INCLUDE_ANSWER_TRIE_CHECK_INSERT /* answer_trie_check_insert_gt_entry \
|
||||||
|
*/
|
||||||
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
||||||
#define INCLUDE_GLOBAL_TRIE_CHECK_INSERT /* global_trie_check_insert_gt_entry */
|
#define INCLUDE_GLOBAL_TRIE_CHECK_INSERT /* global_trie_check_insert_gt_entry \
|
||||||
|
*/
|
||||||
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
||||||
#include "tab.tries.h"
|
#include "tab.tries.h"
|
||||||
#undef INCLUDE_GLOBAL_TRIE_CHECK_INSERT
|
#undef INCLUDE_GLOBAL_TRIE_CHECK_INSERT
|
||||||
@ -219,8 +248,10 @@ static struct trie_statistics{
|
|||||||
#undef MODE_TERMS_LOOP
|
#undef MODE_TERMS_LOOP
|
||||||
|
|
||||||
#define MODE_GLOBAL_TRIE_LOOP
|
#define MODE_GLOBAL_TRIE_LOOP
|
||||||
#define INCLUDE_SUBGOAL_SEARCH_LOOP /* subgoal_search_global_trie_(terms)_loop */
|
#define INCLUDE_SUBGOAL_SEARCH_LOOP /* subgoal_search_global_trie_(terms)_loop \
|
||||||
#define INCLUDE_ANSWER_SEARCH_LOOP /* answer_search_global_trie_(terms)_loop */
|
*/
|
||||||
|
#define INCLUDE_ANSWER_SEARCH_LOOP /* answer_search_global_trie_(terms)_loop \
|
||||||
|
*/
|
||||||
#define INCLUDE_LOAD_ANSWER_LOOP /* load_substitution_loop */
|
#define INCLUDE_LOAD_ANSWER_LOOP /* load_substitution_loop */
|
||||||
#ifdef TRIE_RATIONAL_TERMS
|
#ifdef TRIE_RATIONAL_TERMS
|
||||||
#undef TRIE_RATIONAL_TERMS
|
#undef TRIE_RATIONAL_TERMS
|
||||||
@ -240,9 +271,9 @@ static struct trie_statistics{
|
|||||||
#undef INCLUDE_ANSWER_SEARCH_MODE_DIRECTED
|
#undef INCLUDE_ANSWER_SEARCH_MODE_DIRECTED
|
||||||
#endif /* MODE_DIRECTED_TABLING */
|
#endif /* MODE_DIRECTED_TABLING */
|
||||||
|
|
||||||
|
static inline CELL *exec_substitution_loop(gt_node_ptr current_node,
|
||||||
|
CELL **stack_vars_ptr,
|
||||||
static inline CELL *exec_substitution_loop(gt_node_ptr current_node, CELL **stack_vars_ptr, CELL *stack_terms USES_REGS) {
|
CELL *stack_terms USES_REGS) {
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
===========
|
===========
|
||||||
| |
|
| |
|
||||||
@ -274,7 +305,8 @@ static inline CELL *exec_substitution_loop(gt_node_ptr current_node, CELL **stac
|
|||||||
| TERM_N | <-- stack_terms
|
| TERM_N | <-- stack_terms
|
||||||
----------| *
|
----------| *
|
||||||
| ... | /|\
|
| ... | /|\
|
||||||
----------| | stack_terms_pair_offset (TRIE_COMPACT_PAIRS)
|
----------| | stack_terms_pair_offset
|
||||||
|
(TRIE_COMPACT_PAIRS)
|
||||||
| TERM_1 | \|/
|
| TERM_1 | \|/
|
||||||
=========== *
|
=========== *
|
||||||
LOCAL_TrailTop --> | | <-- stack_terms_base (TRIE_COMPACT_PAIRS)
|
LOCAL_TrailTop --> | | <-- stack_terms_base (TRIE_COMPACT_PAIRS)
|
||||||
@ -293,7 +325,8 @@ static inline CELL *exec_substitution_loop(gt_node_ptr current_node, CELL **stac
|
|||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
||||||
if (t > VarIndexOfTableTerm(MAX_TABLE_VARS)) {
|
if (t > VarIndexOfTableTerm(MAX_TABLE_VARS)) {
|
||||||
stack_terms = exec_substitution_loop((gt_node_ptr) t, &stack_vars, stack_terms PASS_REGS);
|
stack_terms = exec_substitution_loop((gt_node_ptr)t, &stack_vars,
|
||||||
|
stack_terms PASS_REGS);
|
||||||
} else
|
} else
|
||||||
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
||||||
{
|
{
|
||||||
@ -415,10 +448,10 @@ static inline CELL *exec_substitution_loop(gt_node_ptr current_node, CELL **stac
|
|||||||
#endif /* TRIE_COMPACT_PAIRS */
|
#endif /* TRIE_COMPACT_PAIRS */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
#ifdef TABLING_INNER_CUTS
|
#ifdef TABLING_INNER_CUTS
|
||||||
static int update_answer_trie_branch(ans_node_ptr previous_node, ans_node_ptr current_node) {
|
static int update_answer_trie_branch(ans_node_ptr previous_node,
|
||||||
|
ans_node_ptr current_node) {
|
||||||
int ltt;
|
int ltt;
|
||||||
if (!IS_ANSWER_LEAF_NODE(current_node)) {
|
if (!IS_ANSWER_LEAF_NODE(current_node)) {
|
||||||
if (TrNode_child(current_node)) {
|
if (TrNode_child(current_node)) {
|
||||||
@ -432,7 +465,8 @@ static int update_answer_trie_branch(ans_node_ptr previous_node, ans_node_ptr cu
|
|||||||
TrNode_next(previous_node) = TrNode_next(current_node);
|
TrNode_next(previous_node) = TrNode_next(current_node);
|
||||||
FREE_ANSWER_TRIE_NODE(current_node);
|
FREE_ANSWER_TRIE_NODE(current_node);
|
||||||
if (TrNode_next(previous_node)) {
|
if (TrNode_next(previous_node)) {
|
||||||
return update_answer_trie_branch(previous_node, TrNode_next(previous_node));
|
return update_answer_trie_branch(previous_node,
|
||||||
|
TrNode_next(previous_node));
|
||||||
} else {
|
} else {
|
||||||
TrNode_instr(previous_node) -= 2; /* retry --> trust : try --> do */
|
TrNode_instr(previous_node) -= 2; /* retry --> trust : try --> do */
|
||||||
return 0;
|
return 0;
|
||||||
@ -449,7 +483,8 @@ static int update_answer_trie_branch(ans_node_ptr previous_node, ans_node_ptr cu
|
|||||||
}
|
}
|
||||||
update_next_trie_branch:
|
update_next_trie_branch:
|
||||||
if (TrNode_next(current_node)) {
|
if (TrNode_next(current_node)) {
|
||||||
ltt = 1 + update_answer_trie_branch(current_node, TrNode_next(current_node));
|
ltt =
|
||||||
|
1 + update_answer_trie_branch(current_node, TrNode_next(current_node));
|
||||||
} else {
|
} else {
|
||||||
TrNode_instr(current_node) -= 2; /* retry --> trust : try --> do */
|
TrNode_instr(current_node) -= 2; /* retry --> trust : try --> do */
|
||||||
ltt = 1;
|
ltt = 1;
|
||||||
@ -480,27 +515,31 @@ static int update_answer_trie_branch(ans_node_ptr current_node) {
|
|||||||
#else /* ! YAPOR */
|
#else /* ! YAPOR */
|
||||||
static void update_answer_trie_branch(ans_node_ptr current_node, int position) {
|
static void update_answer_trie_branch(ans_node_ptr current_node, int position) {
|
||||||
if (!IS_ANSWER_LEAF_NODE(current_node))
|
if (!IS_ANSWER_LEAF_NODE(current_node))
|
||||||
update_answer_trie_branch(TrNode_child(current_node), TRAVERSE_POSITION_FIRST); /* retry --> try */
|
update_answer_trie_branch(TrNode_child(current_node),
|
||||||
|
TRAVERSE_POSITION_FIRST); /* retry --> try */
|
||||||
if (position == TRAVERSE_POSITION_FIRST) {
|
if (position == TRAVERSE_POSITION_FIRST) {
|
||||||
ans_node_ptr next = TrNode_next(current_node);
|
ans_node_ptr next = TrNode_next(current_node);
|
||||||
if (next) {
|
if (next) {
|
||||||
while (TrNode_next(next)) {
|
while (TrNode_next(next)) {
|
||||||
update_answer_trie_branch(next, TRAVERSE_POSITION_NEXT); /* retry --> retry */
|
update_answer_trie_branch(next,
|
||||||
|
TRAVERSE_POSITION_NEXT); /* retry --> retry */
|
||||||
next = TrNode_next(next);
|
next = TrNode_next(next);
|
||||||
}
|
}
|
||||||
update_answer_trie_branch(next, TRAVERSE_POSITION_LAST); /* retry --> trust */
|
update_answer_trie_branch(next,
|
||||||
|
TRAVERSE_POSITION_LAST); /* retry --> trust */
|
||||||
} else
|
} else
|
||||||
position += TRAVERSE_POSITION_LAST; /* try --> do */
|
position += TRAVERSE_POSITION_LAST; /* try --> do */
|
||||||
}
|
}
|
||||||
TrNode_instr(current_node) = Yap_opcode(TrNode_instr(current_node) - position);
|
TrNode_instr(current_node) =
|
||||||
|
Yap_opcode(TrNode_instr(current_node) - position);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
|
|
||||||
|
|
||||||
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
||||||
static void free_global_trie_branch(gt_node_ptr current_node, int mode USES_REGS) {
|
static void free_global_trie_branch(gt_node_ptr current_node,
|
||||||
|
int mode USES_REGS) {
|
||||||
Term t = TrNode_entry(current_node);
|
Term t = TrNode_entry(current_node);
|
||||||
#else
|
#else
|
||||||
static void free_global_trie_branch(gt_node_ptr current_node USES_REGS) {
|
static void free_global_trie_branch(gt_node_ptr current_node USES_REGS) {
|
||||||
@ -511,7 +550,9 @@ static void free_global_trie_branch(gt_node_ptr current_node USES_REGS) {
|
|||||||
child_node = TrNode_child(parent_node);
|
child_node = TrNode_child(parent_node);
|
||||||
if (IS_GLOBAL_TRIE_HASH(child_node)) {
|
if (IS_GLOBAL_TRIE_HASH(child_node)) {
|
||||||
gt_hash_ptr hash = (gt_hash_ptr)child_node;
|
gt_hash_ptr hash = (gt_hash_ptr)child_node;
|
||||||
gt_node_ptr *bucket = Hash_buckets(hash) + HASH_ENTRY(TrNode_entry(current_node), Hash_num_buckets(hash));
|
gt_node_ptr *bucket =
|
||||||
|
Hash_buckets(hash) +
|
||||||
|
HASH_ENTRY(TrNode_entry(current_node), Hash_num_buckets(hash));
|
||||||
int num_nodes = --Hash_num_nodes(hash);
|
int num_nodes = --Hash_num_nodes(hash);
|
||||||
child_node = *bucket;
|
child_node = *bucket;
|
||||||
if (child_node != current_node) {
|
if (child_node != current_node) {
|
||||||
@ -560,13 +601,15 @@ static void free_global_trie_branch(gt_node_ptr current_node USES_REGS) {
|
|||||||
TrNode_child(parent_node) = NULL;
|
TrNode_child(parent_node) = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (child_node != current_node) {
|
}
|
||||||
|
else if (child_node != current_node) {
|
||||||
while (TrNode_next(child_node) != current_node)
|
while (TrNode_next(child_node) != current_node)
|
||||||
child_node = TrNode_next(child_node);
|
child_node = TrNode_next(child_node);
|
||||||
TrNode_next(child_node) = TrNode_next(current_node);
|
TrNode_next(child_node) = TrNode_next(current_node);
|
||||||
CHECK_DECREMENT_GLOBAL_TRIE_FOR_SUBTERMS_REFERENCE(t, mode);
|
CHECK_DECREMENT_GLOBAL_TRIE_FOR_SUBTERMS_REFERENCE(t, mode);
|
||||||
FREE_GLOBAL_TRIE_NODE(current_node);
|
FREE_GLOBAL_TRIE_NODE(current_node);
|
||||||
} else if (TrNode_next(current_node) == NULL) {
|
}
|
||||||
|
else if (TrNode_next(current_node) == NULL) {
|
||||||
CHECK_DECREMENT_GLOBAL_TRIE_FOR_SUBTERMS_REFERENCE(t, mode);
|
CHECK_DECREMENT_GLOBAL_TRIE_FOR_SUBTERMS_REFERENCE(t, mode);
|
||||||
FREE_GLOBAL_TRIE_NODE(current_node);
|
FREE_GLOBAL_TRIE_NODE(current_node);
|
||||||
if (parent_node != GLOBAL_root_gt) {
|
if (parent_node != GLOBAL_root_gt) {
|
||||||
@ -600,7 +643,8 @@ static void free_global_trie_branch(gt_node_ptr current_node USES_REGS) {
|
|||||||
FREE_GLOBAL_TRIE_BRANCH(parent_node, mode);
|
FREE_GLOBAL_TRIE_BRANCH(parent_node, mode);
|
||||||
} else
|
} else
|
||||||
TrNode_child(parent_node) = NULL;
|
TrNode_child(parent_node) = NULL;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
TrNode_child(parent_node) = TrNode_next(current_node);
|
TrNode_child(parent_node) = TrNode_next(current_node);
|
||||||
CHECK_DECREMENT_GLOBAL_TRIE_FOR_SUBTERMS_REFERENCE(t, mode);
|
CHECK_DECREMENT_GLOBAL_TRIE_FOR_SUBTERMS_REFERENCE(t, mode);
|
||||||
FREE_GLOBAL_TRIE_NODE(current_node);
|
FREE_GLOBAL_TRIE_NODE(current_node);
|
||||||
@ -608,8 +652,9 @@ static void free_global_trie_branch(gt_node_ptr current_node USES_REGS) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void traverse_subgoal_trie(sg_node_ptr current_node, char *str,
|
||||||
static void traverse_subgoal_trie(sg_node_ptr current_node, char *str, int str_index, int *arity, int mode, int position USES_REGS) {
|
int str_index, int *arity, int mode,
|
||||||
|
int position USES_REGS) {
|
||||||
int *current_arity = NULL, current_str_index = 0, current_mode = 0;
|
int *current_arity = NULL, current_str_index = 0, current_mode = 0;
|
||||||
|
|
||||||
/* test if hashing */
|
/* test if hashing */
|
||||||
@ -623,7 +668,8 @@ static void traverse_subgoal_trie(sg_node_ptr current_node, char *str, int str_i
|
|||||||
memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1));
|
memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1));
|
||||||
do {
|
do {
|
||||||
if (*bucket) {
|
if (*bucket) {
|
||||||
traverse_subgoal_trie(*bucket, str, str_index, arity, mode, TRAVERSE_POSITION_FIRST PASS_REGS);
|
traverse_subgoal_trie(*bucket, str, str_index, arity, mode,
|
||||||
|
TRAVERSE_POSITION_FIRST PASS_REGS);
|
||||||
memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
|
memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
|
||||||
#ifdef TRIE_COMPACT_PAIRS
|
#ifdef TRIE_COMPACT_PAIRS
|
||||||
if (arity[arity[0]] == -2 && str[str_index - 1] != '[')
|
if (arity[arity[0]] == -2 && str[str_index - 1] != '[')
|
||||||
@ -648,7 +694,8 @@ static void traverse_subgoal_trie(sg_node_ptr current_node, char *str, int str_i
|
|||||||
|
|
||||||
/* process current trie node */
|
/* process current trie node */
|
||||||
TrStat_sg_nodes++;
|
TrStat_sg_nodes++;
|
||||||
traverse_trie_node(TrNode_entry(current_node), str, &str_index, arity, &mode, TRAVERSE_TYPE_SUBGOAL PASS_REGS);
|
traverse_trie_node(TrNode_entry(current_node), str, &str_index, arity, &mode,
|
||||||
|
TRAVERSE_TYPE_SUBGOAL PASS_REGS);
|
||||||
|
|
||||||
/* show answers ... */
|
/* show answers ... */
|
||||||
if (IS_SUBGOAL_LEAF_NODE(current_node)) {
|
if (IS_SUBGOAL_LEAF_NODE(current_node)) {
|
||||||
@ -671,7 +718,9 @@ static void traverse_subgoal_trie(sg_node_ptr current_node, char *str, int str_i
|
|||||||
SHOW_TABLE_STRUCTURE(" TRUE\n");
|
SHOW_TABLE_STRUCTURE(" TRUE\n");
|
||||||
} else {
|
} else {
|
||||||
arity[0] = 0;
|
arity[0] = 0;
|
||||||
traverse_answer_trie(TrNode_child(SgFr_answer_trie(sg_fr)), &str[str_index], 0, arity, 0, TRAVERSE_MODE_NORMAL, TRAVERSE_POSITION_FIRST PASS_REGS);
|
traverse_answer_trie(TrNode_child(SgFr_answer_trie(sg_fr)),
|
||||||
|
&str[str_index], 0, arity, 0, TRAVERSE_MODE_NORMAL,
|
||||||
|
TRAVERSE_POSITION_FIRST PASS_REGS);
|
||||||
if (SgFr_state(sg_fr) < complete) {
|
if (SgFr_state(sg_fr) < complete) {
|
||||||
TrStat_sg_incomplete++;
|
TrStat_sg_incomplete++;
|
||||||
SHOW_TABLE_STRUCTURE(" ---> INCOMPLETE\n");
|
SHOW_TABLE_STRUCTURE(" ---> INCOMPLETE\n");
|
||||||
@ -680,7 +729,8 @@ static void traverse_subgoal_trie(sg_node_ptr current_node, char *str, int str_i
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
/* ... or continue with child node */
|
/* ... or continue with child node */
|
||||||
traverse_subgoal_trie(TrNode_child(current_node), str, str_index, arity, mode, TRAVERSE_POSITION_FIRST PASS_REGS);
|
traverse_subgoal_trie(TrNode_child(current_node), str, str_index, arity,
|
||||||
|
mode, TRAVERSE_POSITION_FIRST PASS_REGS);
|
||||||
/* restore the initial state and continue with sibling nodes */
|
/* restore the initial state and continue with sibling nodes */
|
||||||
if (position == TRAVERSE_POSITION_FIRST) {
|
if (position == TRAVERSE_POSITION_FIRST) {
|
||||||
str_index = current_str_index;
|
str_index = current_str_index;
|
||||||
@ -695,7 +745,8 @@ static void traverse_subgoal_trie(sg_node_ptr current_node, char *str, int str_i
|
|||||||
if (arity[arity[0]] == -1)
|
if (arity[arity[0]] == -1)
|
||||||
str[str_index - 1] = '|';
|
str[str_index - 1] = '|';
|
||||||
#endif /* TRIE_COMPACT_PAIRS */
|
#endif /* TRIE_COMPACT_PAIRS */
|
||||||
traverse_subgoal_trie(current_node, str, str_index, arity, mode, TRAVERSE_POSITION_NEXT PASS_REGS);
|
traverse_subgoal_trie(current_node, str, str_index, arity, mode,
|
||||||
|
TRAVERSE_POSITION_NEXT PASS_REGS);
|
||||||
current_node = TrNode_next(current_node);
|
current_node = TrNode_next(current_node);
|
||||||
}
|
}
|
||||||
free(current_arity);
|
free(current_arity);
|
||||||
@ -703,9 +754,11 @@ static void traverse_subgoal_trie(sg_node_ptr current_node, char *str, int str_i
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void traverse_answer_trie(ans_node_ptr current_node, char *str,
|
||||||
static void traverse_answer_trie(ans_node_ptr current_node, char *str, int str_index, int *arity, int var_index, int mode, int position USES_REGS) {
|
int str_index, int *arity, int var_index,
|
||||||
int *current_arity = NULL, current_str_index = 0, current_var_index = 0, current_mode = 0;
|
int mode, int position USES_REGS) {
|
||||||
|
int *current_arity = NULL, current_str_index = 0, current_var_index = 0,
|
||||||
|
current_mode = 0;
|
||||||
|
|
||||||
/* test if hashing */
|
/* test if hashing */
|
||||||
if (IS_ANSWER_TRIE_HASH(current_node)) {
|
if (IS_ANSWER_TRIE_HASH(current_node)) {
|
||||||
@ -718,7 +771,8 @@ static void traverse_answer_trie(ans_node_ptr current_node, char *str, int str_i
|
|||||||
memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1));
|
memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1));
|
||||||
do {
|
do {
|
||||||
if (*bucket) {
|
if (*bucket) {
|
||||||
traverse_answer_trie(*bucket, str, str_index, arity, var_index, mode, TRAVERSE_POSITION_FIRST PASS_REGS);
|
traverse_answer_trie(*bucket, str, str_index, arity, var_index, mode,
|
||||||
|
TRAVERSE_POSITION_FIRST PASS_REGS);
|
||||||
memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
|
memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
|
||||||
#ifdef TRIE_COMPACT_PAIRS
|
#ifdef TRIE_COMPACT_PAIRS
|
||||||
if (arity[arity[0]] == -2 && str[str_index - 1] != '[')
|
if (arity[arity[0]] == -2 && str[str_index - 1] != '[')
|
||||||
@ -750,7 +804,8 @@ static void traverse_answer_trie(ans_node_ptr current_node, char *str, int str_i
|
|||||||
|
|
||||||
/* process current trie node */
|
/* process current trie node */
|
||||||
TrStat_ans_nodes++;
|
TrStat_ans_nodes++;
|
||||||
traverse_trie_node(TrNode_entry(current_node), str, &str_index, arity, &mode, TRAVERSE_TYPE_ANSWER PASS_REGS);
|
traverse_trie_node(TrNode_entry(current_node), str, &str_index, arity, &mode,
|
||||||
|
TRAVERSE_TYPE_ANSWER PASS_REGS);
|
||||||
|
|
||||||
/* show answer .... */
|
/* show answer .... */
|
||||||
if (IS_ANSWER_LEAF_NODE(current_node)) {
|
if (IS_ANSWER_LEAF_NODE(current_node)) {
|
||||||
@ -767,7 +822,8 @@ static void traverse_answer_trie(ans_node_ptr current_node, char *str, int str_i
|
|||||||
#endif /* TABLING_INNER_CUTS */
|
#endif /* TABLING_INNER_CUTS */
|
||||||
/* ... or continue with child node */
|
/* ... or continue with child node */
|
||||||
else
|
else
|
||||||
traverse_answer_trie(TrNode_child(current_node), str, str_index, arity, var_index, mode, TRAVERSE_POSITION_FIRST PASS_REGS);
|
traverse_answer_trie(TrNode_child(current_node), str, str_index, arity,
|
||||||
|
var_index, mode, TRAVERSE_POSITION_FIRST PASS_REGS);
|
||||||
|
|
||||||
/* restore the initial state and continue with sibling nodes */
|
/* restore the initial state and continue with sibling nodes */
|
||||||
if (position == TRAVERSE_POSITION_FIRST) {
|
if (position == TRAVERSE_POSITION_FIRST) {
|
||||||
@ -784,7 +840,8 @@ static void traverse_answer_trie(ans_node_ptr current_node, char *str, int str_i
|
|||||||
if (arity[arity[0]] == -1)
|
if (arity[arity[0]] == -1)
|
||||||
str[str_index - 1] = '|';
|
str[str_index - 1] = '|';
|
||||||
#endif /* TRIE_COMPACT_PAIRS */
|
#endif /* TRIE_COMPACT_PAIRS */
|
||||||
traverse_answer_trie(current_node, str, str_index, arity, var_index, mode, TRAVERSE_POSITION_NEXT PASS_REGS);
|
traverse_answer_trie(current_node, str, str_index, arity, var_index, mode,
|
||||||
|
TRAVERSE_POSITION_NEXT PASS_REGS);
|
||||||
current_node = TrNode_next(current_node);
|
current_node = TrNode_next(current_node);
|
||||||
}
|
}
|
||||||
free(current_arity);
|
free(current_arity);
|
||||||
@ -793,8 +850,9 @@ static void traverse_answer_trie(ans_node_ptr current_node, char *str, int str_i
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void traverse_global_trie(gt_node_ptr current_node, char *str,
|
||||||
static void traverse_global_trie(gt_node_ptr current_node, char *str, int str_index, int *arity, int mode, int position USES_REGS) {
|
int str_index, int *arity, int mode,
|
||||||
|
int position USES_REGS) {
|
||||||
int *current_arity = NULL, current_str_index = 0, current_mode = 0;
|
int *current_arity = NULL, current_str_index = 0, current_mode = 0;
|
||||||
|
|
||||||
/* test if hashing */
|
/* test if hashing */
|
||||||
@ -808,7 +866,8 @@ static void traverse_global_trie(gt_node_ptr current_node, char *str, int str_in
|
|||||||
memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1));
|
memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1));
|
||||||
do {
|
do {
|
||||||
if (*bucket) {
|
if (*bucket) {
|
||||||
traverse_global_trie(*bucket, str, str_index, arity, mode, TRAVERSE_POSITION_FIRST PASS_REGS);
|
traverse_global_trie(*bucket, str, str_index, arity, mode,
|
||||||
|
TRAVERSE_POSITION_FIRST PASS_REGS);
|
||||||
memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
|
memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
|
||||||
#ifdef TRIE_COMPACT_PAIRS
|
#ifdef TRIE_COMPACT_PAIRS
|
||||||
if (arity[arity[0]] == -2 && str[str_index - 1] != '[')
|
if (arity[arity[0]] == -2 && str[str_index - 1] != '[')
|
||||||
@ -833,16 +892,19 @@ static void traverse_global_trie(gt_node_ptr current_node, char *str, int str_in
|
|||||||
|
|
||||||
/* process current trie node */
|
/* process current trie node */
|
||||||
TrStat_gt_nodes++;
|
TrStat_gt_nodes++;
|
||||||
traverse_trie_node(TrNode_entry(current_node), str, &str_index, arity, &mode, TRAVERSE_TYPE_GT_SUBGOAL PASS_REGS);
|
traverse_trie_node(TrNode_entry(current_node), str, &str_index, arity, &mode,
|
||||||
|
TRAVERSE_TYPE_GT_SUBGOAL PASS_REGS);
|
||||||
|
|
||||||
/* continue with child node ... */
|
/* continue with child node ... */
|
||||||
if (arity[0] != 0 || mode != TRAVERSE_MODE_NORMAL)
|
if (arity[0] != 0 || mode != TRAVERSE_MODE_NORMAL)
|
||||||
traverse_global_trie(TrNode_child(current_node), str, str_index, arity, mode, TRAVERSE_POSITION_FIRST PASS_REGS);
|
traverse_global_trie(TrNode_child(current_node), str, str_index, arity,
|
||||||
|
mode, TRAVERSE_POSITION_FIRST PASS_REGS);
|
||||||
/* ... or show term */
|
/* ... or show term */
|
||||||
else {
|
else {
|
||||||
TrStat_gt_terms++;
|
TrStat_gt_terms++;
|
||||||
str[str_index] = 0;
|
str[str_index] = 0;
|
||||||
SHOW_TABLE_STRUCTURE(" TERMx" UInt_FORMAT ": %s\n", (CELL) TrNode_child(current_node), str);
|
SHOW_TABLE_STRUCTURE(" TERMx" UInt_FORMAT ": %s\n",
|
||||||
|
(CELL)TrNode_child(current_node), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* restore the initial state and continue with sibling nodes */
|
/* restore the initial state and continue with sibling nodes */
|
||||||
@ -859,7 +921,8 @@ static void traverse_global_trie(gt_node_ptr current_node, char *str, int str_in
|
|||||||
if (arity[arity[0]] == -1)
|
if (arity[arity[0]] == -1)
|
||||||
str[str_index - 1] = '|';
|
str[str_index - 1] = '|';
|
||||||
#endif /* TRIE_COMPACT_PAIRS */
|
#endif /* TRIE_COMPACT_PAIRS */
|
||||||
traverse_global_trie(current_node, str, str_index, arity, mode, TRAVERSE_POSITION_NEXT PASS_REGS);
|
traverse_global_trie(current_node, str, str_index, arity, mode,
|
||||||
|
TRAVERSE_POSITION_NEXT PASS_REGS);
|
||||||
current_node = TrNode_next(current_node);
|
current_node = TrNode_next(current_node);
|
||||||
}
|
}
|
||||||
free(current_arity);
|
free(current_arity);
|
||||||
@ -868,16 +931,20 @@ static void traverse_global_trie(gt_node_ptr current_node, char *str, int str_in
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void traverse_global_trie_for_term(gt_node_ptr current_node, char *str,
|
||||||
static void traverse_global_trie_for_term(gt_node_ptr current_node, char *str, int *str_index, int *arity, int *mode, int type USES_REGS) {
|
int *str_index, int *arity, int *mode,
|
||||||
|
int type USES_REGS) {
|
||||||
if (TrNode_parent(current_node) != GLOBAL_root_gt)
|
if (TrNode_parent(current_node) != GLOBAL_root_gt)
|
||||||
traverse_global_trie_for_term(TrNode_parent(current_node), str, str_index, arity, mode, type PASS_REGS);
|
traverse_global_trie_for_term(TrNode_parent(current_node), str, str_index,
|
||||||
traverse_trie_node(TrNode_entry(current_node), str, str_index, arity, mode, type PASS_REGS);
|
arity, mode, type PASS_REGS);
|
||||||
|
traverse_trie_node(TrNode_entry(current_node), str, str_index, arity, mode,
|
||||||
|
type PASS_REGS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void traverse_trie_node(Term t, char *str, int *str_index_ptr,
|
||||||
static inline void traverse_trie_node(Term t, char *str, int *str_index_ptr, int *arity, int *mode_ptr, int type USES_REGS) {
|
int *arity, int *mode_ptr,
|
||||||
|
int type USES_REGS) {
|
||||||
int mode = *mode_ptr;
|
int mode = *mode_ptr;
|
||||||
int str_index = *str_index_ptr;
|
int str_index = *str_index_ptr;
|
||||||
|
|
||||||
@ -907,7 +974,8 @@ static inline void traverse_trie_node(Term t, char *str, int *str_index_ptr, int
|
|||||||
traverse_update_arity(str, &str_index, arity);
|
traverse_update_arity(str, &str_index, arity);
|
||||||
if (type == TRAVERSE_TYPE_SUBGOAL)
|
if (type == TRAVERSE_TYPE_SUBGOAL)
|
||||||
mode = TRAVERSE_MODE_NORMAL;
|
mode = TRAVERSE_MODE_NORMAL;
|
||||||
else /* TRAVERSE_TYPE_ANSWER || TRAVERSE_TYPE_GT_SUBGOAL || TRAVERSE_TYPE_GT_ANSWER */
|
else /* TRAVERSE_TYPE_ANSWER || TRAVERSE_TYPE_GT_SUBGOAL ||
|
||||||
|
TRAVERSE_TYPE_GT_ANSWER */
|
||||||
mode = TRAVERSE_MODE_DOUBLE_END;
|
mode = TRAVERSE_MODE_DOUBLE_END;
|
||||||
} else if (mode == TRAVERSE_MODE_DOUBLE_END) {
|
} else if (mode == TRAVERSE_MODE_DOUBLE_END) {
|
||||||
mode = TRAVERSE_MODE_NORMAL;
|
mode = TRAVERSE_MODE_NORMAL;
|
||||||
@ -917,7 +985,8 @@ static inline void traverse_trie_node(Term t, char *str, int *str_index_ptr, int
|
|||||||
traverse_update_arity(str, &str_index, arity);
|
traverse_update_arity(str, &str_index, arity);
|
||||||
if (type == TRAVERSE_TYPE_SUBGOAL)
|
if (type == TRAVERSE_TYPE_SUBGOAL)
|
||||||
mode = TRAVERSE_MODE_NORMAL;
|
mode = TRAVERSE_MODE_NORMAL;
|
||||||
else /* TRAVERSE_TYPE_ANSWER || TRAVERSE_TYPE_GT_SUBGOAL || TRAVERSE_TYPE_GT_ANSWER */
|
else /* TRAVERSE_TYPE_ANSWER || TRAVERSE_TYPE_GT_SUBGOAL ||
|
||||||
|
TRAVERSE_TYPE_GT_ANSWER */
|
||||||
mode = TRAVERSE_MODE_LONGINT_END;
|
mode = TRAVERSE_MODE_LONGINT_END;
|
||||||
} else if (mode == TRAVERSE_MODE_LONGINT_END) {
|
} else if (mode == TRAVERSE_MODE_LONGINT_END) {
|
||||||
mode = TRAVERSE_MODE_NORMAL;
|
mode = TRAVERSE_MODE_NORMAL;
|
||||||
@ -926,13 +995,17 @@ static inline void traverse_trie_node(Term t, char *str, int *str_index_ptr, int
|
|||||||
traverse_update_arity(str, &str_index, arity);
|
traverse_update_arity(str, &str_index, arity);
|
||||||
if (type == TRAVERSE_TYPE_SUBGOAL)
|
if (type == TRAVERSE_TYPE_SUBGOAL)
|
||||||
mode = TRAVERSE_MODE_NORMAL;
|
mode = TRAVERSE_MODE_NORMAL;
|
||||||
else /* TRAVERSE_TYPE_ANSWER || TRAVERSE_TYPE_GT_SUBGOAL || TRAVERSE_TYPE_GT_ANSWER */
|
else /* TRAVERSE_TYPE_ANSWER || TRAVERSE_TYPE_GT_SUBGOAL ||
|
||||||
|
TRAVERSE_TYPE_GT_ANSWER */
|
||||||
mode = TRAVERSE_MODE_BIGINT_OR_STRING_END;
|
mode = TRAVERSE_MODE_BIGINT_OR_STRING_END;
|
||||||
} else if (mode == TRAVERSE_MODE_BIGINT_OR_STRING_END) {
|
} else if (mode == TRAVERSE_MODE_BIGINT_OR_STRING_END) {
|
||||||
mode = TRAVERSE_MODE_NORMAL;
|
mode = TRAVERSE_MODE_NORMAL;
|
||||||
} else if (IsVarTerm(t)) {
|
} else if (IsVarTerm(t)) {
|
||||||
#ifdef TRIE_RATIONAL_TERMS
|
#ifdef TRIE_RATIONAL_TERMS
|
||||||
if (t > VarIndexOfTableTerm(MAX_TABLE_VARS) && TrNode_child((gt_node_ptr) t) != (gt_node_ptr)1) { //TODO: substitute the != 1 test to something more appropriate
|
if (t > VarIndexOfTableTerm(MAX_TABLE_VARS) &&
|
||||||
|
TrNode_child((gt_node_ptr)t) !=
|
||||||
|
(gt_node_ptr)1) { // TODO: substitute the != 1 test to something
|
||||||
|
// more appropriate
|
||||||
/* Rational term */
|
/* Rational term */
|
||||||
str_index += sprintf(&str[str_index], "**");
|
str_index += sprintf(&str[str_index], "**");
|
||||||
traverse_update_arity(str, &str_index, arity);
|
traverse_update_arity(str, &str_index, arity);
|
||||||
@ -942,12 +1015,14 @@ static inline void traverse_trie_node(Term t, char *str, int *str_index_ptr, int
|
|||||||
TrStat_gt_refs++;
|
TrStat_gt_refs++;
|
||||||
/* (type % 2 + 2): TRAVERSE_TYPE_ANSWER --> TRAVERSE_TYPE_GT_ANSWER */
|
/* (type % 2 + 2): TRAVERSE_TYPE_ANSWER --> TRAVERSE_TYPE_GT_ANSWER */
|
||||||
/* (type % 2 + 2): TRAVERSE_TYPE_SUBGOAL --> TRAVERSE_TYPE_GT_SUBGOAL */
|
/* (type % 2 + 2): TRAVERSE_TYPE_SUBGOAL --> TRAVERSE_TYPE_GT_SUBGOAL */
|
||||||
traverse_global_trie_for_term((gt_node_ptr) t, str, &str_index, arity, &mode, type % 2 + 2 PASS_REGS);
|
traverse_global_trie_for_term((gt_node_ptr)t, str, &str_index, arity,
|
||||||
|
&mode, type % 2 + 2 PASS_REGS);
|
||||||
} else {
|
} else {
|
||||||
if (type == TRAVERSE_TYPE_SUBGOAL || type == TRAVERSE_TYPE_GT_SUBGOAL)
|
if (type == TRAVERSE_TYPE_SUBGOAL || type == TRAVERSE_TYPE_GT_SUBGOAL)
|
||||||
str_index += sprintf(&str[str_index], "VAR%d", VarIndexOfTableTerm(t));
|
str_index += sprintf(&str[str_index], "VAR%d", VarIndexOfTableTerm(t));
|
||||||
else /* TRAVERSE_TYPE_ANSWER || TRAVERSE_TYPE_GT_ANSWER */
|
else /* TRAVERSE_TYPE_ANSWER || TRAVERSE_TYPE_GT_ANSWER */
|
||||||
str_index += sprintf(& str[str_index], "ANSVAR%d", VarIndexOfTableTerm(t));
|
str_index +=
|
||||||
|
sprintf(&str[str_index], "ANSVAR%d", VarIndexOfTableTerm(t));
|
||||||
traverse_update_arity(str, &str_index, arity);
|
traverse_update_arity(str, &str_index, arity);
|
||||||
}
|
}
|
||||||
} else if (IsIntTerm(t)) {
|
} else if (IsIntTerm(t)) {
|
||||||
@ -1005,8 +1080,8 @@ static inline void traverse_trie_node(Term t, char *str, int *str_index_ptr, int
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void traverse_update_arity(char *str, int *str_index_ptr,
|
||||||
static inline void traverse_update_arity(char *str, int *str_index_ptr, int *arity) {
|
int *arity) {
|
||||||
int str_index = *str_index_ptr;
|
int str_index = *str_index_ptr;
|
||||||
while (arity[0]) {
|
while (arity[0]) {
|
||||||
if (arity[arity[0]] > 0) {
|
if (arity[arity[0]] > 0) {
|
||||||
@ -1043,8 +1118,6 @@ static inline void traverse_update_arity(char *str, int *str_index_ptr, int *ari
|
|||||||
*str_index_ptr = str_index;
|
*str_index_ptr = str_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************
|
/*******************************
|
||||||
** Global functions **
|
** Global functions **
|
||||||
*******************************/
|
*******************************/
|
||||||
@ -1074,14 +1147,22 @@ sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) {
|
|||||||
int old_subs_arity = subs_arity;
|
int old_subs_arity = subs_arity;
|
||||||
for (i = 1; i <= pred_arity; i++) {
|
for (i = 1; i <= pred_arity; i++) {
|
||||||
int j = MODE_DIRECTED_GET_ARG(mode_directed[i - 1]) + 1;
|
int j = MODE_DIRECTED_GET_ARG(mode_directed[i - 1]) + 1;
|
||||||
current_sg_node = subgoal_search_loop(tab_ent, current_sg_node, Deref(XREGS[j]), &subs_arity, &stack_vars PASS_REGS);
|
current_sg_node =
|
||||||
|
subgoal_search_loop(tab_ent, current_sg_node, Deref(XREGS[j]),
|
||||||
|
&subs_arity, &stack_vars PASS_REGS);
|
||||||
if (subs_arity != old_subs_arity) {
|
if (subs_arity != old_subs_arity) {
|
||||||
if (subs_pos && MODE_DIRECTED_GET_MODE(aux_mode_directed[subs_pos-1]) == MODE_DIRECTED_GET_MODE(mode_directed[i-1])) {
|
if (subs_pos &&
|
||||||
/* same mode as before -> use the current entry in the aux_mode_directed[] array */
|
MODE_DIRECTED_GET_MODE(aux_mode_directed[subs_pos - 1]) ==
|
||||||
aux_mode_directed[subs_pos-1] += MODE_DIRECTED_SET(subs_arity - old_subs_arity, 0);
|
MODE_DIRECTED_GET_MODE(mode_directed[i - 1])) {
|
||||||
|
/* same mode as before -> use the current entry in the
|
||||||
|
* aux_mode_directed[] array */
|
||||||
|
aux_mode_directed[subs_pos - 1] +=
|
||||||
|
MODE_DIRECTED_SET(subs_arity - old_subs_arity, 0);
|
||||||
} else {
|
} else {
|
||||||
/* new mode -> init a new entry in the aux_mode_directed[] array */
|
/* new mode -> init a new entry in the aux_mode_directed[] array */
|
||||||
aux_mode_directed[subs_pos] = MODE_DIRECTED_SET(subs_arity - old_subs_arity, MODE_DIRECTED_GET_MODE(mode_directed[i-1]));
|
aux_mode_directed[subs_pos] =
|
||||||
|
MODE_DIRECTED_SET(subs_arity - old_subs_arity,
|
||||||
|
MODE_DIRECTED_GET_MODE(mode_directed[i - 1]));
|
||||||
subs_pos++;
|
subs_pos++;
|
||||||
}
|
}
|
||||||
old_subs_arity = subs_arity;
|
old_subs_arity = subs_arity;
|
||||||
@ -1091,10 +1172,14 @@ sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) {
|
|||||||
#endif /* MODE_DIRECTED_TABLING */
|
#endif /* MODE_DIRECTED_TABLING */
|
||||||
if (IsMode_GlobalTrie(TabEnt_mode(tab_ent))) {
|
if (IsMode_GlobalTrie(TabEnt_mode(tab_ent))) {
|
||||||
for (i = 1; i <= pred_arity; i++)
|
for (i = 1; i <= pred_arity; i++)
|
||||||
current_sg_node = subgoal_search_terms_loop(tab_ent, current_sg_node, Deref(XREGS[i]), &subs_arity, &stack_vars PASS_REGS);
|
current_sg_node =
|
||||||
|
subgoal_search_terms_loop(tab_ent, current_sg_node, Deref(XREGS[i]),
|
||||||
|
&subs_arity, &stack_vars PASS_REGS);
|
||||||
} else {
|
} else {
|
||||||
for (i = 1; i <= pred_arity; i++)
|
for (i = 1; i <= pred_arity; i++)
|
||||||
current_sg_node = subgoal_search_loop(tab_ent, current_sg_node, Deref(XREGS[i]), &subs_arity, &stack_vars PASS_REGS);
|
current_sg_node =
|
||||||
|
subgoal_search_loop(tab_ent, current_sg_node, Deref(XREGS[i]),
|
||||||
|
&subs_arity, &stack_vars PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
STACK_PUSH_UP(subs_arity, stack_vars);
|
STACK_PUSH_UP(subs_arity, stack_vars);
|
||||||
@ -1105,7 +1190,8 @@ sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) {
|
|||||||
RESET_VARIABLE(t);
|
RESET_VARIABLE(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
sg_fr_ptr *sg_fr_end = get_insert_subgoal_frame_addr(current_sg_node PASS_REGS);
|
sg_fr_ptr *sg_fr_end =
|
||||||
|
get_insert_subgoal_frame_addr(current_sg_node PASS_REGS);
|
||||||
#ifndef THREADS
|
#ifndef THREADS
|
||||||
LOCK_SUBGOAL_NODE(current_sg_node);
|
LOCK_SUBGOAL_NODE(current_sg_node);
|
||||||
#endif /* !THREADS */
|
#endif /* !THREADS */
|
||||||
@ -1114,7 +1200,8 @@ sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) {
|
|||||||
#ifdef MODE_DIRECTED_TABLING
|
#ifdef MODE_DIRECTED_TABLING
|
||||||
if (subs_pos) {
|
if (subs_pos) {
|
||||||
ALLOC_BLOCK(mode_directed, subs_pos * sizeof(int), int);
|
ALLOC_BLOCK(mode_directed, subs_pos * sizeof(int), int);
|
||||||
memcpy((void *)mode_directed, (void *)aux_mode_directed, subs_pos*sizeof(int));
|
memcpy((void *)mode_directed, (void *)aux_mode_directed,
|
||||||
|
subs_pos * sizeof(int));
|
||||||
} else
|
} else
|
||||||
mode_directed = NULL;
|
mode_directed = NULL;
|
||||||
#endif /* MODE_DIRECTED_TABLING */
|
#endif /* MODE_DIRECTED_TABLING */
|
||||||
@ -1125,7 +1212,8 @@ sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) {
|
|||||||
TAG_AS_SUBGOAL_LEAF_NODE(current_sg_node);
|
TAG_AS_SUBGOAL_LEAF_NODE(current_sg_node);
|
||||||
UNLOCK_SUBGOAL_NODE(current_sg_node);
|
UNLOCK_SUBGOAL_NODE(current_sg_node);
|
||||||
#else /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
|
#else /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
|
||||||
sg_ent_ptr sg_ent = (sg_ent_ptr) UNTAG_SUBGOAL_NODE(TrNode_sg_ent(current_sg_node));
|
sg_ent_ptr sg_ent =
|
||||||
|
(sg_ent_ptr)UNTAG_SUBGOAL_NODE(TrNode_sg_ent(current_sg_node));
|
||||||
new_subgoal_frame(sg_fr, sg_ent);
|
new_subgoal_frame(sg_fr, sg_ent);
|
||||||
#ifdef THREADS_CONSUMER_SHARING
|
#ifdef THREADS_CONSUMER_SHARING
|
||||||
SgFr_state(sg_fr) = ready_external;
|
SgFr_state(sg_fr) = ready_external;
|
||||||
@ -1163,7 +1251,6 @@ sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) {
|
|||||||
return sg_fr;
|
return sg_fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ans_node_ptr answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
|
ans_node_ptr answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
|
||||||
#define subs_arity *subs_ptr
|
#define subs_arity *subs_ptr
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
@ -1177,12 +1264,14 @@ ans_node_ptr answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
|
|||||||
if (IsMode_GlobalTrie(TabEnt_mode(SgFr_tab_ent(sg_fr)))) {
|
if (IsMode_GlobalTrie(TabEnt_mode(SgFr_tab_ent(sg_fr)))) {
|
||||||
for (i = subs_arity; i >= 1; i--) {
|
for (i = subs_arity; i >= 1; i--) {
|
||||||
TABLING_ERROR_CHECKING(answer_search, IsNonVarTerm(subs_ptr[i]));
|
TABLING_ERROR_CHECKING(answer_search, IsNonVarTerm(subs_ptr[i]));
|
||||||
current_ans_node = answer_search_terms_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
|
current_ans_node = answer_search_terms_loop(
|
||||||
|
sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = subs_arity; i >= 1; i--) {
|
for (i = subs_arity; i >= 1; i--) {
|
||||||
TABLING_ERROR_CHECKING(answer_search, IsNonVarTerm(subs_ptr[i]));
|
TABLING_ERROR_CHECKING(answer_search, IsNonVarTerm(subs_ptr[i]));
|
||||||
current_ans_node = answer_search_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
|
current_ans_node = answer_search_loop(
|
||||||
|
sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1197,7 +1286,6 @@ ans_node_ptr answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
|
|||||||
#undef subs_arity
|
#undef subs_arity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef MODE_DIRECTED_TABLING
|
#ifdef MODE_DIRECTED_TABLING
|
||||||
ans_node_ptr mode_directed_answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
|
ans_node_ptr mode_directed_answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
|
||||||
#define subs_arity *subs_ptr
|
#define subs_arity *subs_ptr
|
||||||
@ -1219,51 +1307,69 @@ ans_node_ptr mode_directed_answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
|
|||||||
do {
|
do {
|
||||||
TABLING_ERROR_CHECKING(answer_search, IsNonVarTerm(subs_ptr[i]));
|
TABLING_ERROR_CHECKING(answer_search, IsNonVarTerm(subs_ptr[i]));
|
||||||
if (mode == MODE_DIRECTED_INDEX || mode == MODE_DIRECTED_ALL) {
|
if (mode == MODE_DIRECTED_INDEX || mode == MODE_DIRECTED_ALL) {
|
||||||
current_ans_node = answer_search_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
|
current_ans_node = answer_search_loop(
|
||||||
|
sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
|
||||||
} else {
|
} else {
|
||||||
LOCK_ANSWER_NODE(current_ans_node);
|
LOCK_ANSWER_NODE(current_ans_node);
|
||||||
if (TrNode_child(current_ans_node) == NULL) {
|
if (TrNode_child(current_ans_node) == NULL) {
|
||||||
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
||||||
struct answer_trie_node virtual_ans_node; /* necessary because the answer_search_loop() procedure also locks the parent node */
|
struct answer_trie_node
|
||||||
|
virtual_ans_node; /* necessary because the answer_search_loop()
|
||||||
|
procedure also locks the parent node */
|
||||||
ans_node_ptr parent_ans_node = current_ans_node;
|
ans_node_ptr parent_ans_node = current_ans_node;
|
||||||
AnsNode_init_lock_field(&virtual_ans_node);
|
AnsNode_init_lock_field(&virtual_ans_node);
|
||||||
TrNode_parent(&virtual_ans_node) = NULL;
|
TrNode_parent(&virtual_ans_node) = NULL;
|
||||||
TrNode_child(&virtual_ans_node) = NULL;
|
TrNode_child(&virtual_ans_node) = NULL;
|
||||||
current_ans_node = answer_search_loop(sg_fr, &virtual_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
|
current_ans_node =
|
||||||
|
answer_search_loop(sg_fr, &virtual_ans_node, Deref(subs_ptr[i]),
|
||||||
|
&vars_arity PASS_REGS);
|
||||||
TrNode_child(parent_ans_node) = TrNode_child(&virtual_ans_node);
|
TrNode_child(parent_ans_node) = TrNode_child(&virtual_ans_node);
|
||||||
TrNode_parent(TrNode_child(&virtual_ans_node)) = parent_ans_node;
|
TrNode_parent(TrNode_child(&virtual_ans_node)) = parent_ans_node;
|
||||||
#else
|
#else
|
||||||
current_ans_node = answer_search_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
|
current_ans_node =
|
||||||
|
answer_search_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]),
|
||||||
|
&vars_arity PASS_REGS);
|
||||||
#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
|
#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
|
||||||
} else if (mode == MODE_DIRECTED_MIN || mode == MODE_DIRECTED_MAX) {
|
} else if (mode == MODE_DIRECTED_MIN || mode == MODE_DIRECTED_MAX) {
|
||||||
ans_node_ptr parent_ans_node = current_ans_node;
|
ans_node_ptr parent_ans_node = current_ans_node;
|
||||||
invalid_ans_node = TrNode_child(parent_ans_node); /* by default, assume a better answer */
|
invalid_ans_node = TrNode_child(
|
||||||
current_ans_node = answer_search_min_max(sg_fr, current_ans_node, Deref(subs_ptr[i]), mode PASS_REGS);
|
parent_ans_node); /* by default, assume a better answer */
|
||||||
if (invalid_ans_node == TrNode_child(parent_ans_node)) /* worse or equal answer */
|
current_ans_node = answer_search_min_max(
|
||||||
|
sg_fr, current_ans_node, Deref(subs_ptr[i]), mode PASS_REGS);
|
||||||
|
if (invalid_ans_node ==
|
||||||
|
TrNode_child(parent_ans_node)) /* worse or equal answer */
|
||||||
invalid_ans_node = NULL;
|
invalid_ans_node = NULL;
|
||||||
} else if (mode == MODE_DIRECTED_SUM) {
|
} else if (mode == MODE_DIRECTED_SUM) {
|
||||||
invalid_ans_node = TrNode_child(current_ans_node);
|
invalid_ans_node = TrNode_child(current_ans_node);
|
||||||
current_ans_node = answer_search_sum(sg_fr, current_ans_node, Deref(subs_ptr[i]) PASS_REGS);
|
current_ans_node = answer_search_sum(sg_fr, current_ans_node,
|
||||||
|
Deref(subs_ptr[i]) PASS_REGS);
|
||||||
} else if (mode == MODE_DIRECTED_LAST) {
|
} else if (mode == MODE_DIRECTED_LAST) {
|
||||||
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
||||||
struct answer_trie_node virtual_ans_node; /* necessary because the answer_search_loop() procedure also locks the parent node */
|
struct answer_trie_node
|
||||||
|
virtual_ans_node; /* necessary because the answer_search_loop()
|
||||||
|
procedure also locks the parent node */
|
||||||
ans_node_ptr parent_ans_node = current_ans_node;
|
ans_node_ptr parent_ans_node = current_ans_node;
|
||||||
invalid_ans_node = TrNode_child(parent_ans_node);
|
invalid_ans_node = TrNode_child(parent_ans_node);
|
||||||
AnsNode_init_lock_field(&virtual_ans_node);
|
AnsNode_init_lock_field(&virtual_ans_node);
|
||||||
TrNode_parent(&virtual_ans_node) = NULL;
|
TrNode_parent(&virtual_ans_node) = NULL;
|
||||||
TrNode_child(&virtual_ans_node) = NULL;
|
TrNode_child(&virtual_ans_node) = NULL;
|
||||||
current_ans_node = answer_search_loop(sg_fr, &virtual_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
|
current_ans_node =
|
||||||
|
answer_search_loop(sg_fr, &virtual_ans_node, Deref(subs_ptr[i]),
|
||||||
|
&vars_arity PASS_REGS);
|
||||||
TrNode_child(parent_ans_node) = TrNode_child(&virtual_ans_node);
|
TrNode_child(parent_ans_node) = TrNode_child(&virtual_ans_node);
|
||||||
TrNode_parent(TrNode_child(&virtual_ans_node)) = parent_ans_node;
|
TrNode_parent(TrNode_child(&virtual_ans_node)) = parent_ans_node;
|
||||||
#else
|
#else
|
||||||
invalid_ans_node = TrNode_child(current_ans_node);
|
invalid_ans_node = TrNode_child(current_ans_node);
|
||||||
TrNode_child(current_ans_node) = NULL;
|
TrNode_child(current_ans_node) = NULL;
|
||||||
current_ans_node = answer_search_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
|
current_ans_node =
|
||||||
|
answer_search_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]),
|
||||||
|
&vars_arity PASS_REGS);
|
||||||
#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
|
#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
|
||||||
} else if (mode == MODE_DIRECTED_FIRST) {
|
} else if (mode == MODE_DIRECTED_FIRST) {
|
||||||
current_ans_node = NULL;
|
current_ans_node = NULL;
|
||||||
} else
|
} else
|
||||||
Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "mode_directed_answer_search: unknown mode");
|
Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
|
||||||
|
"mode_directed_answer_search: unknown mode");
|
||||||
UNLOCK_ANSWER_NODE(current_ans_node);
|
UNLOCK_ANSWER_NODE(current_ans_node);
|
||||||
}
|
}
|
||||||
n_subs--;
|
n_subs--;
|
||||||
@ -1274,7 +1380,8 @@ ans_node_ptr mode_directed_answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
|
|||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
if (invalid_ans_node)
|
if (invalid_ans_node)
|
||||||
invalidate_answer_trie(invalid_ans_node, sg_fr, TRAVERSE_POSITION_FIRST PASS_REGS);
|
invalidate_answer_trie(invalid_ans_node, sg_fr,
|
||||||
|
TRAVERSE_POSITION_FIRST PASS_REGS);
|
||||||
|
|
||||||
/* reset variables */
|
/* reset variables */
|
||||||
stack_vars = (CELL *)TR;
|
stack_vars = (CELL *)TR;
|
||||||
@ -1288,7 +1395,6 @@ ans_node_ptr mode_directed_answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
|
|||||||
}
|
}
|
||||||
#endif /* MODE_DIRECTED_TABLING */
|
#endif /* MODE_DIRECTED_TABLING */
|
||||||
|
|
||||||
|
|
||||||
void load_answer(ans_node_ptr current_ans_node, CELL *subs_ptr) {
|
void load_answer(ans_node_ptr current_ans_node, CELL *subs_ptr) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
#define subs_arity *subs_ptr
|
#define subs_arity *subs_ptr
|
||||||
@ -1311,7 +1417,6 @@ void load_answer(ans_node_ptr current_ans_node, CELL *subs_ptr) {
|
|||||||
#undef subs_arity
|
#undef subs_arity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CELL *exec_substitution(gt_node_ptr current_node, CELL *aux_stack) {
|
CELL *exec_substitution(gt_node_ptr current_node, CELL *aux_stack) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
#define subs_arity *subs_ptr
|
#define subs_arity *subs_ptr
|
||||||
@ -1319,32 +1424,35 @@ CELL *exec_substitution(gt_node_ptr current_node, CELL *aux_stack) {
|
|||||||
Term t;
|
Term t;
|
||||||
|
|
||||||
++aux_stack; /* skip the heap_arity entry */
|
++aux_stack; /* skip the heap_arity entry */
|
||||||
stack_terms = exec_substitution_loop(current_node, &aux_stack, (CELL *) LOCAL_TrailTop PASS_REGS);
|
stack_terms = exec_substitution_loop(current_node, &aux_stack,
|
||||||
|
(CELL *)LOCAL_TrailTop PASS_REGS);
|
||||||
*--aux_stack = 0; /* restore the heap_arity entry */
|
*--aux_stack = 0; /* restore the heap_arity entry */
|
||||||
|
|
||||||
subs_ptr = aux_stack + aux_stack[1] + 2;
|
subs_ptr = aux_stack + aux_stack[1] + 2;
|
||||||
t = STACK_POP_DOWN(stack_terms);
|
t = STACK_POP_DOWN(stack_terms);
|
||||||
YapBind((CELL *)subs_ptr[subs_arity], t);
|
YapBind((CELL *)subs_ptr[subs_arity], t);
|
||||||
TABLING_ERROR_CHECKING(exec_substitution, stack_terms != (CELL *)LOCAL_TrailTop);
|
TABLING_ERROR_CHECKING(exec_substitution,
|
||||||
|
stack_terms != (CELL *)LOCAL_TrailTop);
|
||||||
*subs_ptr = subs_arity - 1;
|
*subs_ptr = subs_arity - 1;
|
||||||
|
|
||||||
return aux_stack;
|
return aux_stack;
|
||||||
#undef subs_arity
|
#undef subs_arity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void update_answer_trie(sg_fr_ptr sg_fr) {
|
void update_answer_trie(sg_fr_ptr sg_fr) {
|
||||||
ans_node_ptr current_node;
|
ans_node_ptr current_node;
|
||||||
|
|
||||||
free_answer_hash_chain(SgFr_hash_chain(sg_fr));
|
free_answer_hash_chain(SgFr_hash_chain(sg_fr));
|
||||||
SgFr_hash_chain(sg_fr) = NULL;
|
SgFr_hash_chain(sg_fr) = NULL;
|
||||||
SgFr_state(sg_fr) += 2; /* complete --> compiled : complete_in_use --> compiled_in_use */
|
SgFr_state(sg_fr) +=
|
||||||
|
2; /* complete --> compiled : complete_in_use --> compiled_in_use */
|
||||||
|
|
||||||
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
||||||
SgFr_sg_ent_state(sg_fr) += 2; /* complete --> compiled */
|
SgFr_sg_ent_state(sg_fr) += 2; /* complete --> compiled */
|
||||||
#ifdef THREADS_FULL_SHARING
|
#ifdef THREADS_FULL_SHARING
|
||||||
if (IsMode_Batched(TabEnt_mode(SgFr_tab_ent(sg_fr)))) {
|
if (IsMode_Batched(TabEnt_mode(SgFr_tab_ent(sg_fr)))) {
|
||||||
/* cleaning bits used by batched mode and shifting the instruction back to the original place */
|
/* cleaning bits used by batched mode and shifting the instruction back to
|
||||||
|
* the original place */
|
||||||
ans_node_ptr leaf_ans_trie_node = SgFr_first_answer(sg_fr);
|
ans_node_ptr leaf_ans_trie_node = SgFr_first_answer(sg_fr);
|
||||||
while (TrNode_child(leaf_ans_trie_node) != NULL) {
|
while (TrNode_child(leaf_ans_trie_node) != NULL) {
|
||||||
ANSWER_LEAF_NODE_INSTR_ABSOLUTE(leaf_ans_trie_node);
|
ANSWER_LEAF_NODE_INSTR_ABSOLUTE(leaf_ans_trie_node);
|
||||||
@ -1370,7 +1478,6 @@ void update_answer_trie(sg_fr_ptr sg_fr) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void free_subgoal_trie(sg_node_ptr current_node, int mode, int position) {
|
void free_subgoal_trie(sg_node_ptr current_node, int mode, int position) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
|
|
||||||
@ -1426,7 +1533,8 @@ void free_subgoal_trie(sg_node_ptr current_node, int mode, int position) {
|
|||||||
} else {
|
} else {
|
||||||
child_mode = TRAVERSE_MODE_NORMAL;
|
child_mode = TRAVERSE_MODE_NORMAL;
|
||||||
}
|
}
|
||||||
free_subgoal_trie(TrNode_child(current_node), child_mode, TRAVERSE_POSITION_FIRST);
|
free_subgoal_trie(TrNode_child(current_node), child_mode,
|
||||||
|
TRAVERSE_POSITION_FIRST);
|
||||||
} else {
|
} else {
|
||||||
sg_fr_ptr sg_fr = get_subgoal_frame_for_abolish(current_node PASS_REGS);
|
sg_fr_ptr sg_fr = get_subgoal_frame_for_abolish(current_node PASS_REGS);
|
||||||
if (sg_fr) {
|
if (sg_fr) {
|
||||||
@ -1434,7 +1542,8 @@ void free_subgoal_trie(sg_node_ptr current_node, int mode, int position) {
|
|||||||
free_answer_hash_chain(SgFr_hash_chain(sg_fr));
|
free_answer_hash_chain(SgFr_hash_chain(sg_fr));
|
||||||
ans_node = SgFr_answer_trie(sg_fr);
|
ans_node = SgFr_answer_trie(sg_fr);
|
||||||
if (TrNode_child(ans_node))
|
if (TrNode_child(ans_node))
|
||||||
free_answer_trie(TrNode_child(ans_node), TRAVERSE_MODE_NORMAL, TRAVERSE_POSITION_FIRST);
|
free_answer_trie(TrNode_child(ans_node), TRAVERSE_MODE_NORMAL,
|
||||||
|
TRAVERSE_POSITION_FIRST);
|
||||||
IF_ABOLISH_ANSWER_TRIE_SHARED_DATA_STRUCTURES {
|
IF_ABOLISH_ANSWER_TRIE_SHARED_DATA_STRUCTURES {
|
||||||
FREE_ANSWER_TRIE_NODE(ans_node);
|
FREE_ANSWER_TRIE_NODE(ans_node);
|
||||||
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
||||||
@ -1459,10 +1568,12 @@ void free_subgoal_trie(sg_node_ptr current_node, int mode, int position) {
|
|||||||
#ifdef LIMIT_TABLING
|
#ifdef LIMIT_TABLING
|
||||||
remove_from_global_sg_fr_list(sg_fr);
|
remove_from_global_sg_fr_list(sg_fr);
|
||||||
#endif /* LIMIT_TABLING */
|
#endif /* LIMIT_TABLING */
|
||||||
#if defined(MODE_DIRECTED_TABLING) && !defined(THREADS_FULL_SHARING) && !defined(THREADS_CONSUMER_SHARING)
|
#if defined(MODE_DIRECTED_TABLING) && !defined(THREADS_FULL_SHARING) && \
|
||||||
|
!defined(THREADS_CONSUMER_SHARING)
|
||||||
if (SgFr_mode_directed(sg_fr))
|
if (SgFr_mode_directed(sg_fr))
|
||||||
FREE_BLOCK(SgFr_mode_directed(sg_fr));
|
FREE_BLOCK(SgFr_mode_directed(sg_fr));
|
||||||
#endif /* MODE_DIRECTED_TABLING && !THREADS_FULL_SHARING && !THREADS_CONSUMER_SHARING */
|
#endif /* MODE_DIRECTED_TABLING && !THREADS_FULL_SHARING && \
|
||||||
|
!THREADS_CONSUMER_SHARING */
|
||||||
FREE_SUBGOAL_FRAME(sg_fr);
|
FREE_SUBGOAL_FRAME(sg_fr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1486,7 +1597,6 @@ void free_subgoal_trie(sg_node_ptr current_node, int mode, int position) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void free_answer_trie(ans_node_ptr current_node, int mode, int position) {
|
void free_answer_trie(ans_node_ptr current_node, int mode, int position) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
|
|
||||||
@ -1524,7 +1634,8 @@ void free_answer_trie(ans_node_ptr current_node, int mode, int position) {
|
|||||||
} else {
|
} else {
|
||||||
child_mode = TRAVERSE_MODE_NORMAL;
|
child_mode = TRAVERSE_MODE_NORMAL;
|
||||||
}
|
}
|
||||||
free_answer_trie(TrNode_child(current_node), child_mode, TRAVERSE_POSITION_FIRST);
|
free_answer_trie(TrNode_child(current_node), child_mode,
|
||||||
|
TRAVERSE_POSITION_FIRST);
|
||||||
}
|
}
|
||||||
if (position == TRAVERSE_POSITION_FIRST) {
|
if (position == TRAVERSE_POSITION_FIRST) {
|
||||||
ans_node_ptr next_node = TrNode_next(current_node);
|
ans_node_ptr next_node = TrNode_next(current_node);
|
||||||
@ -1546,7 +1657,6 @@ void free_answer_trie(ans_node_ptr current_node, int mode, int position) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void free_answer_hash_chain(ans_hash_ptr hash) {
|
void free_answer_hash_chain(ans_hash_ptr hash) {
|
||||||
#if defined(THREADS_NO_SHARING) || defined(THREADS_SUBGOAL_SHARING)
|
#if defined(THREADS_NO_SHARING) || defined(THREADS_SUBGOAL_SHARING)
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
@ -1561,7 +1671,8 @@ void free_answer_hash_chain(ans_hash_ptr hash) {
|
|||||||
while (!*bucket)
|
while (!*bucket)
|
||||||
bucket++;
|
bucket++;
|
||||||
chain_node = *bucket;
|
chain_node = *bucket;
|
||||||
TrNode_child((ans_node_ptr) UNTAG_ANSWER_NODE(TrNode_parent(chain_node))) = chain_node;
|
TrNode_child((ans_node_ptr)UNTAG_ANSWER_NODE(TrNode_parent(chain_node))) =
|
||||||
|
chain_node;
|
||||||
while (++bucket != last_bucket) {
|
while (++bucket != last_bucket) {
|
||||||
if (*bucket) {
|
if (*bucket) {
|
||||||
while (TrNode_next(chain_node))
|
while (TrNode_next(chain_node))
|
||||||
@ -1578,10 +1689,11 @@ void free_answer_hash_chain(ans_hash_ptr hash) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************************
|
/*****************************************************************************************
|
||||||
** all threads abolish their local data structures, and the main thread also abolishes **
|
** all threads abolish their local data structures, and the main thread also
|
||||||
** all shared data structures, if no other thread is running (GLOBAL_NOfThreads == 1). **
|
*abolishes **
|
||||||
|
** all shared data structures, if no other thread is running (GLOBAL_NOfThreads
|
||||||
|
*== 1). **
|
||||||
*****************************************************************************************/
|
*****************************************************************************************/
|
||||||
void abolish_table(tab_ent_ptr tab_ent) {
|
void abolish_table(tab_ent_ptr tab_ent) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
@ -1610,7 +1722,8 @@ void abolish_table(tab_ent_ptr tab_ent) {
|
|||||||
if (sg_node) {
|
if (sg_node) {
|
||||||
if (TrNode_child(sg_node)) {
|
if (TrNode_child(sg_node)) {
|
||||||
if (TabEnt_arity(tab_ent)) {
|
if (TabEnt_arity(tab_ent)) {
|
||||||
free_subgoal_trie(TrNode_child(sg_node), TRAVERSE_MODE_NORMAL, TRAVERSE_POSITION_FIRST);
|
free_subgoal_trie(TrNode_child(sg_node), TRAVERSE_MODE_NORMAL,
|
||||||
|
TRAVERSE_POSITION_FIRST);
|
||||||
} else {
|
} else {
|
||||||
sg_fr_ptr sg_fr = get_subgoal_frame_for_abolish(sg_node PASS_REGS);
|
sg_fr_ptr sg_fr = get_subgoal_frame_for_abolish(sg_node PASS_REGS);
|
||||||
if (sg_fr) {
|
if (sg_fr) {
|
||||||
@ -1636,7 +1749,6 @@ void abolish_table(tab_ent_ptr tab_ent) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void showTable(tab_ent_ptr tab_ent, int show_mode, FILE *out) {
|
void showTable(tab_ent_ptr tab_ent, int show_mode, FILE *out) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
sg_node_ptr sg_node;
|
sg_node_ptr sg_node;
|
||||||
@ -1655,9 +1767,11 @@ void showTable(tab_ent_ptr tab_ent, int show_mode, FILE *out) {
|
|||||||
TrStat_ans_nodes = 0;
|
TrStat_ans_nodes = 0;
|
||||||
TrStat_gt_refs = 0;
|
TrStat_gt_refs = 0;
|
||||||
if (show_mode == SHOW_MODE_STATISTICS)
|
if (show_mode == SHOW_MODE_STATISTICS)
|
||||||
fprintf(TrStat_out, "Table statistics for predicate '%s", AtomName(TabEnt_atom(tab_ent)));
|
fprintf(TrStat_out, "Table statistics for predicate '%s",
|
||||||
|
AtomName(TabEnt_atom(tab_ent)));
|
||||||
else /* SHOW_MODE_STRUCTURE */
|
else /* SHOW_MODE_STRUCTURE */
|
||||||
fprintf(TrStat_out, "Table structure for predicate '%s", AtomName(TabEnt_atom(tab_ent)));
|
fprintf(TrStat_out, "Table structure for predicate '%s",
|
||||||
|
AtomName(TabEnt_atom(tab_ent)));
|
||||||
#ifdef MODE_DIRECTED_TABLING
|
#ifdef MODE_DIRECTED_TABLING
|
||||||
if (TabEnt_mode_directed(tab_ent)) {
|
if (TabEnt_mode_directed(tab_ent)) {
|
||||||
int i, *mode_directed = TabEnt_mode_directed(tab_ent);
|
int i, *mode_directed = TabEnt_mode_directed(tab_ent);
|
||||||
@ -1681,7 +1795,8 @@ void showTable(tab_ent_ptr tab_ent, int show_mode, FILE *out) {
|
|||||||
} else
|
} else
|
||||||
Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "show_table: unknown mode");
|
Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "show_table: unknown mode");
|
||||||
if (i != MODE_DIRECTED_GET_ARG(mode_directed[i]))
|
if (i != MODE_DIRECTED_GET_ARG(mode_directed[i]))
|
||||||
fprintf(TrStat_out, "(ARG%d)", MODE_DIRECTED_GET_ARG(mode_directed[i]) + 1);
|
fprintf(TrStat_out, "(ARG%d)",
|
||||||
|
MODE_DIRECTED_GET_ARG(mode_directed[i]) + 1);
|
||||||
if (i + 1 != TabEnt_arity(tab_ent))
|
if (i + 1 != TabEnt_arity(tab_ent))
|
||||||
fprintf(TrStat_out, ",");
|
fprintf(TrStat_out, ",");
|
||||||
}
|
}
|
||||||
@ -1697,8 +1812,11 @@ void showTable(tab_ent_ptr tab_ent, int show_mode, FILE *out) {
|
|||||||
int *arity = (int *)malloc(sizeof(int) * SHOW_TABLE_ARITY_ARRAY_SIZE);
|
int *arity = (int *)malloc(sizeof(int) * SHOW_TABLE_ARITY_ARRAY_SIZE);
|
||||||
arity[0] = 1;
|
arity[0] = 1;
|
||||||
arity[1] = TabEnt_arity(tab_ent);
|
arity[1] = TabEnt_arity(tab_ent);
|
||||||
int str_index = sprintf(str, " ?- %s(", AtomName(TabEnt_atom(tab_ent)));
|
int str_index =
|
||||||
traverse_subgoal_trie(TrNode_child(sg_node), str, str_index, arity, TRAVERSE_MODE_NORMAL, TRAVERSE_POSITION_FIRST PASS_REGS);
|
sprintf(str, " ?- %s(", AtomName(TabEnt_atom(tab_ent)));
|
||||||
|
traverse_subgoal_trie(TrNode_child(sg_node), str, str_index, arity,
|
||||||
|
TRAVERSE_MODE_NORMAL,
|
||||||
|
TRAVERSE_POSITION_FIRST PASS_REGS);
|
||||||
free(str);
|
free(str);
|
||||||
free(arity);
|
free(arity);
|
||||||
} else {
|
} else {
|
||||||
@ -1727,11 +1845,13 @@ void showTable(tab_ent_ptr tab_ent, int show_mode, FILE *out) {
|
|||||||
SHOW_TABLE_STRUCTURE(" EMPTY\n");
|
SHOW_TABLE_STRUCTURE(" EMPTY\n");
|
||||||
if (show_mode == SHOW_MODE_STATISTICS) {
|
if (show_mode == SHOW_MODE_STATISTICS) {
|
||||||
fprintf(TrStat_out, " Subgoal trie structure\n");
|
fprintf(TrStat_out, " Subgoal trie structure\n");
|
||||||
fprintf(TrStat_out, " Subgoals: %ld (%ld incomplete)\n", TrStat_subgoals, TrStat_sg_incomplete);
|
fprintf(TrStat_out, " Subgoals: %ld (%ld incomplete)\n", TrStat_subgoals,
|
||||||
|
TrStat_sg_incomplete);
|
||||||
fprintf(TrStat_out, " Subgoal trie nodes: %ld\n", TrStat_sg_nodes);
|
fprintf(TrStat_out, " Subgoal trie nodes: %ld\n", TrStat_sg_nodes);
|
||||||
fprintf(TrStat_out, " Answer trie structure(s)\n");
|
fprintf(TrStat_out, " Answer trie structure(s)\n");
|
||||||
#ifdef TABLING_INNER_CUTS
|
#ifdef TABLING_INNER_CUTS
|
||||||
fprintf(TrStat_out, " Answers: %ld (%ld pruned)\n", TrStat_answers, TrStat_answers_pruned);
|
fprintf(TrStat_out, " Answers: %ld (%ld pruned)\n", TrStat_answers,
|
||||||
|
TrStat_answers_pruned);
|
||||||
#else
|
#else
|
||||||
fprintf(TrStat_out, " Answers: %ld\n", TrStat_answers);
|
fprintf(TrStat_out, " Answers: %ld\n", TrStat_answers);
|
||||||
#endif /* TABLING_INNER_CUTS */
|
#endif /* TABLING_INNER_CUTS */
|
||||||
@ -1743,7 +1863,6 @@ void showTable(tab_ent_ptr tab_ent, int show_mode, FILE *out) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void showGlobalTrie(int show_mode, FILE *out) {
|
void showGlobalTrie(int show_mode, FILE *out) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
|
|
||||||
@ -1760,7 +1879,9 @@ void showGlobalTrie(int show_mode, FILE *out) {
|
|||||||
char *str = (char *)malloc(sizeof(char) * SHOW_TABLE_STR_ARRAY_SIZE);
|
char *str = (char *)malloc(sizeof(char) * SHOW_TABLE_STR_ARRAY_SIZE);
|
||||||
int *arity = (int *)malloc(sizeof(int) * SHOW_TABLE_ARITY_ARRAY_SIZE);
|
int *arity = (int *)malloc(sizeof(int) * SHOW_TABLE_ARITY_ARRAY_SIZE);
|
||||||
arity[0] = 0;
|
arity[0] = 0;
|
||||||
traverse_global_trie(TrNode_child(GLOBAL_root_gt), str, 0, arity, TRAVERSE_MODE_NORMAL, TRAVERSE_POSITION_FIRST PASS_REGS);
|
traverse_global_trie(TrNode_child(GLOBAL_root_gt), str, 0, arity,
|
||||||
|
TRAVERSE_MODE_NORMAL,
|
||||||
|
TRAVERSE_POSITION_FIRST PASS_REGS);
|
||||||
free(str);
|
free(str);
|
||||||
free(arity);
|
free(arity);
|
||||||
} else
|
} else
|
||||||
|
@ -13,13 +13,14 @@ ENDIF (MYSQL_INCLUDE_DIR)
|
|||||||
FIND_PATH(MYSQL_INCLUDE_DIR mysql.h
|
FIND_PATH(MYSQL_INCLUDE_DIR mysql.h
|
||||||
/usr/local/include/mysql
|
/usr/local/include/mysql
|
||||||
/usr/include/mysql
|
/usr/include/mysql
|
||||||
|
/usr/include/mariadb
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(MYSQL_NAMES mysqlclient mysqlclient_r)
|
SET(MYSQL_NAMES mysqlclient mysqlclient_r mariadb )
|
||||||
FIND_LIBRARY(MYSQL_LIBRARY
|
FIND_LIBRARY(MYSQL_LIBRARY
|
||||||
NAMES ${MYSQL_NAMES}
|
NAMES ${MYSQL_NAMES}
|
||||||
PATHS /usr/lib /usr/local/lib
|
PATHS /usr/lib /usr/local/lib
|
||||||
PATH_SUFFIXES mysql
|
PATH_SUFFIXES mysql mariadb
|
||||||
)
|
)
|
||||||
|
|
||||||
IF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
|
IF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
|
||||||
|
192
cmake/FindPostgreSQL.cmake
Normal file
@ -0,0 +1,192 @@
|
|||||||
|
#.rst:
|
||||||
|
# FindPostgreSQL
|
||||||
|
# --------------
|
||||||
|
#
|
||||||
|
# Find the PostgreSQL installation.
|
||||||
|
#
|
||||||
|
# This module defines
|
||||||
|
#
|
||||||
|
# ::
|
||||||
|
#
|
||||||
|
# PostgreSQL_LIBRARIES - the PostgreSQL libraries needed for linking
|
||||||
|
# PostgreSQL_INCLUDE_DIRS - the directories of the PostgreSQL headers
|
||||||
|
# PostgreSQL_LIBRARY_DIRS - the link directories for PostgreSQL libraries
|
||||||
|
# PostgreSQL_VERSION_STRING - the version of PostgreSQL found (since CMake 2.8.8)
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# Copyright 2004-2009 Kitware, Inc.
|
||||||
|
#
|
||||||
|
# Distributed under the OSI-approved BSD License (the "License");
|
||||||
|
# see accompanying file Copyright.txt for details.
|
||||||
|
#
|
||||||
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||||
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
# See the License for more information.
|
||||||
|
#=============================================================================
|
||||||
|
# (To distribute this file outside of CMake, substitute the full
|
||||||
|
# License text for the above reference.)
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# History:
|
||||||
|
# This module is derived from the module originally found in the VTK source tree.
|
||||||
|
#
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# Note:
|
||||||
|
# PostgreSQL_ADDITIONAL_VERSIONS is a variable that can be used to set the
|
||||||
|
# version mumber of the implementation of PostgreSQL.
|
||||||
|
# In Windows the default installation of PostgreSQL uses that as part of the path.
|
||||||
|
# E.g C:\Program Files\PostgreSQL\8.4.
|
||||||
|
# Currently, the following version numbers are known to this module:
|
||||||
|
# "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0"
|
||||||
|
#
|
||||||
|
# To use this variable just do something like this:
|
||||||
|
# set(PostgreSQL_ADDITIONAL_VERSIONS "9.2" "8.4.4")
|
||||||
|
# before calling find_package(PostgreSQL) in your CMakeLists.txt file.
|
||||||
|
# This will mean that the versions you set here will be found first in the order
|
||||||
|
# specified before the default ones are searched.
|
||||||
|
#
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# You may need to manually set:
|
||||||
|
# PostgreSQL_INCLUDE_DIR - the path to where the PostgreSQL include files are.
|
||||||
|
# PostgreSQL_LIBRARY_DIR - The path to where the PostgreSQL library files are.
|
||||||
|
# If FindPostgreSQL.cmake cannot find the include files or the library files.
|
||||||
|
#
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# The following variables are set if PostgreSQL is found:
|
||||||
|
# PostgreSQL_FOUND - Set to true when PostgreSQL is found.
|
||||||
|
# PostgreSQL_INCLUDE_DIRS - Include directories for PostgreSQL
|
||||||
|
# PostgreSQL_LIBRARY_DIRS - Link directories for PostgreSQL libraries
|
||||||
|
# PostgreSQL_LIBRARIES - The PostgreSQL libraries.
|
||||||
|
#
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# If you have installed PostgreSQL in a non-standard location.
|
||||||
|
# (Please note that in the following comments, it is assumed that <Your Path>
|
||||||
|
# points to the root directory of the include directory of PostgreSQL.)
|
||||||
|
# Then you have three options.
|
||||||
|
# 1) After CMake runs, set PostgreSQL_INCLUDE_DIR to <Your Path>/include and
|
||||||
|
# PostgreSQL_LIBRARY_DIR to wherever the library pq (or libpq in windows) is
|
||||||
|
# 2) Use CMAKE_INCLUDE_PATH to set a path to <Your Path>/PostgreSQL<-version>. This will allow find_path()
|
||||||
|
# to locate PostgreSQL_INCLUDE_DIR by utilizing the PATH_SUFFIXES option. e.g. In your CMakeLists.txt file
|
||||||
|
# set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "<Your Path>/include")
|
||||||
|
# 3) Set an environment variable called ${PostgreSQL_ROOT} that points to the root of where you have
|
||||||
|
# installed PostgreSQL, e.g. <Your Path>.
|
||||||
|
#
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
set(PostgreSQL_INCLUDE_PATH_DESCRIPTION "top-level directory containing the PostgreSQL include directories. E.g /usr/local/include/PostgreSQL/8.4 or C:/Program Files/PostgreSQL/8.4/include")
|
||||||
|
set(PostgreSQL_INCLUDE_DIR_MESSAGE "Set the PostgreSQL_INCLUDE_DIR cmake cache entry to the ${PostgreSQL_INCLUDE_PATH_DESCRIPTION}")
|
||||||
|
set(PostgreSQL_LIBRARY_PATH_DESCRIPTION "top-level directory containing the PostgreSQL libraries.")
|
||||||
|
set(PostgreSQL_LIBRARY_DIR_MESSAGE "Set the PostgreSQL_LIBRARY_DIR cmake cache entry to the ${PostgreSQL_LIBRARY_PATH_DESCRIPTION}")
|
||||||
|
set(PostgreSQL_ROOT_DIR_MESSAGE "Set the PostgreSQL_ROOT system variable to where PostgreSQL is found on the machine E.g C:/Program Files/PostgreSQL/8.4")
|
||||||
|
|
||||||
|
|
||||||
|
set(PostgreSQL_KNOWN_VERSIONS ${PostgreSQL_ADDITIONAL_VERSIONS}
|
||||||
|
"9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0")
|
||||||
|
|
||||||
|
# Define additional search paths for root directories.
|
||||||
|
set( PostgreSQL_ROOT_DIRECTORIES
|
||||||
|
ENV PostgreSQL_ROOT
|
||||||
|
${PostgreSQL_ROOT}
|
||||||
|
)
|
||||||
|
foreach(suffix ${PostgreSQL_KNOWN_VERSIONS})
|
||||||
|
if(WIN32)
|
||||||
|
list(APPEND PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES
|
||||||
|
"PostgreSQL/${suffix}/lib")
|
||||||
|
list(APPEND PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES
|
||||||
|
"PostgreSQL/${suffix}/include")
|
||||||
|
list(APPEND PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES
|
||||||
|
"PostgreSQL/${suffix}/include/server")
|
||||||
|
endif()
|
||||||
|
if(UNIX)
|
||||||
|
list(APPEND PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES
|
||||||
|
"postgresql/${suffix}/server")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Look for an installation.
|
||||||
|
#
|
||||||
|
find_path(PostgreSQL_INCLUDE_DIR
|
||||||
|
NAMES libpq-fe.h
|
||||||
|
PATHS
|
||||||
|
# Look in other places.
|
||||||
|
${PostgreSQL_ROOT_DIRECTORIES}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
pgsql
|
||||||
|
postgresql
|
||||||
|
include
|
||||||
|
${PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES}
|
||||||
|
# Help the user find it if we cannot.
|
||||||
|
DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}"
|
||||||
|
)
|
||||||
|
|
||||||
|
find_path(PostgreSQL_TYPE_INCLUDE_DIR
|
||||||
|
NAMES catalog/pg_type.h
|
||||||
|
PATHS
|
||||||
|
# Look in other places.
|
||||||
|
${PostgreSQL_ROOT_DIRECTORIES}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
postgresql
|
||||||
|
pgsql/server
|
||||||
|
postgresql/server
|
||||||
|
include/server
|
||||||
|
${PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES}
|
||||||
|
# Help the user find it if we cannot.
|
||||||
|
DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}"
|
||||||
|
)
|
||||||
|
|
||||||
|
# The PostgreSQL library.
|
||||||
|
set (PostgreSQL_LIBRARY_TO_FIND pq)
|
||||||
|
# Setting some more prefixes for the library
|
||||||
|
set (PostgreSQL_LIB_PREFIX "")
|
||||||
|
if ( WIN32 )
|
||||||
|
set (PostgreSQL_LIB_PREFIX ${PostgreSQL_LIB_PREFIX} "lib")
|
||||||
|
set (PostgreSQL_LIBRARY_TO_FIND ${PostgreSQL_LIB_PREFIX}${PostgreSQL_LIBRARY_TO_FIND})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_library(PostgreSQL_LIBRARY
|
||||||
|
NAMES ${PostgreSQL_LIBRARY_TO_FIND}
|
||||||
|
PATHS
|
||||||
|
${PostgreSQL_ROOT_DIRECTORIES}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
lib
|
||||||
|
${PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES}
|
||||||
|
# Help the user find it if we cannot.
|
||||||
|
DOC "The ${PostgreSQL_LIBRARY_DIR_MESSAGE}"
|
||||||
|
)
|
||||||
|
get_filename_component(PostgreSQL_LIBRARY_DIR ${PostgreSQL_LIBRARY} PATH)
|
||||||
|
|
||||||
|
if (PostgreSQL_INCLUDE_DIR)
|
||||||
|
# Some platforms include multiple pg_config.hs for multi-lib configurations
|
||||||
|
# This is a temporary workaround. A better solution would be to compile
|
||||||
|
# a dummy c file and extract the value of the symbol.
|
||||||
|
file(GLOB _PG_CONFIG_HEADERS "${PostgreSQL_INCLUDE_DIR}/pg_config*.h")
|
||||||
|
foreach(_PG_CONFIG_HEADER ${_PG_CONFIG_HEADERS})
|
||||||
|
if(EXISTS "${_PG_CONFIG_HEADER}")
|
||||||
|
file(STRINGS "${_PG_CONFIG_HEADER}" pgsql_version_str
|
||||||
|
REGEX "^#define[\t ]+PG_VERSION[\t ]+\".*\"")
|
||||||
|
if(pgsql_version_str)
|
||||||
|
string(REGEX REPLACE "^#define[\t ]+PG_VERSION[\t ]+\"([^\"]*)\".*"
|
||||||
|
"\\1" PostgreSQL_VERSION_STRING "${pgsql_version_str}")
|
||||||
|
break()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
unset(pgsql_version_str)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Did we find anything?
|
||||||
|
#nclude(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
||||||
|
find_package_handle_standard_args(PostgreSQL
|
||||||
|
REQUIRED_VARS PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR
|
||||||
|
VERSION_VAR PostgreSQL_VERSION_STRING)
|
||||||
|
set(PostgreSQL_FOUND ${POSTGRESQL_FOUND})
|
||||||
|
|
||||||
|
# Now try to get the include and library path.
|
||||||
|
if(PostgreSQL_FOUND)
|
||||||
|
set(PostgreSQL_INCLUDE_DIRS ${PostgreSQL_INCLUDE_DIR} ${PostgreSQL_TYPE_INCLUDE_DIR} )
|
||||||
|
set(PostgreSQL_LIBRARY_DIRS ${PostgreSQL_LIBRARY_DIR} )
|
||||||
|
set(PostgreSQL_LIBRARIES ${PostgreSQL_LIBRARY_TO_FIND})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mark_as_advanced(PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR PostgreSQL_LIBRARY )
|
@ -128,26 +128,26 @@ set(C_INTERFACE_SOURCES
|
|||||||
H/compile.h
|
H/compile.h
|
||||||
H/corout.h
|
H/corout.h
|
||||||
H/dlmalloc.h
|
H/dlmalloc.h
|
||||||
H/dglobals.h
|
H/heap/dglobals.h
|
||||||
H/dlocals.h
|
H/heap/dlocals.h
|
||||||
H/dhstruct.h
|
H/heap/dhstruct.h
|
||||||
H/eval.h
|
H/eval.h
|
||||||
H/heapgc.h
|
H/heapgc.h
|
||||||
H/hglobals.h
|
H/heap/hglobals.h
|
||||||
H/hlocals.h
|
H/heap/hlocals.h
|
||||||
H/hstruct.h
|
H/heap/hstruct.h
|
||||||
H/iglobals.h
|
H/heap/iglobals.h
|
||||||
H/ihstruct.h
|
H/heap/ihstruct.h
|
||||||
H/ilocals.h
|
H/heap/ilocals.h
|
||||||
H/index.h
|
H/index.h
|
||||||
H/inline-only.h
|
H/inline-only.h
|
||||||
H/iswiatoms.h
|
H/iswiatoms.h
|
||||||
H/qly.h
|
H/qly.h
|
||||||
H/rclause.h
|
H/rclause.h
|
||||||
H/rglobals.h
|
H/heap/rglobals.h
|
||||||
H/rlocals.h
|
H/heap/rlocals.h
|
||||||
H/rheap.h
|
H/rheap.h
|
||||||
H/rhstruct.h
|
H/heap/rhstruct.h
|
||||||
H/threads.h
|
H/threads.h
|
||||||
H/tracer.h
|
H/tracer.h
|
||||||
H/trim_trail.h
|
H/trim_trail.h
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#define CONFIG_H
|
#define CONFIG_H
|
||||||
|
|
||||||
/* config.h.in. Generated from configure.in by autoheader. */
|
/* config.h.in. Generated from configure.in by autoheader. */
|
||||||
|
#define SYSTEM_OPTIONS "${YAP_SYSTEM_OPTIONS}"
|
||||||
|
|
||||||
/* Define if building universal (internal helper macro) */
|
/* Define if building universal (internal helper macro) */
|
||||||
#ifndef AC_APPLE_UNIVERSAL_BUILD
|
#ifndef AC_APPLE_UNIVERSAL_BUILD
|
||||||
|
@ -1,23 +1,11 @@
|
|||||||
SET (CODES
|
SET (CODES
|
||||||
web/bootstrap/doxy-boot.js
|
|
||||||
web/bootstrap/footer.html
|
|
||||||
web/bootstrap/header.html
|
|
||||||
web/bootstrap/customdoxygen.css
|
|
||||||
offcanvas.css
|
|
||||||
offcanvas.js
|
|
||||||
solarized-light.css
|
solarized-light.css
|
||||||
theme.css
|
theme.css
|
||||||
yap.css
|
yap.css
|
||||||
bootstrap.min.css
|
icons/yap_64x64x32.png
|
||||||
bootstrap.min.js
|
icons/yap_256x256x32.png
|
||||||
font-awesome.min.css
|
icons/yap_128x128x32.png
|
||||||
jquery-2.0.3.min.js
|
icons/yap_48x48x32.png
|
||||||
application.js
|
|
||||||
pygments.css
|
|
||||||
misc/icons/yap_64x64x32.png
|
|
||||||
misc/icons/yap_256x256x32.png
|
|
||||||
misc/icons/yap_128x128x32.png
|
|
||||||
misc/icons/yap_48x48x32.png
|
|
||||||
)
|
)
|
||||||
|
|
||||||
SET (DOCS
|
SET (DOCS
|
||||||
@ -42,6 +30,7 @@ yap.md
|
|||||||
find_package(Doxygen)
|
find_package(Doxygen)
|
||||||
option(WITH_DOCUMENTATION "Create and install the HTML based API documentation (requires Doxygen)" ${DOXYGEN_FOUND})
|
option(WITH_DOCUMENTATION "Create and install the HTML based API documentation (requires Doxygen)" ${DOXYGEN_FOUND})
|
||||||
|
|
||||||
|
|
||||||
if(WITH_DOCUMENTATION)
|
if(WITH_DOCUMENTATION)
|
||||||
if(NOT DOXYGEN_FOUND)
|
if(NOT DOXYGEN_FOUND)
|
||||||
message(FATAL_ERROR "Doxygen is needed to build the documentation.")
|
message(FATAL_ERROR "Doxygen is needed to build the documentation.")
|
||||||
|
2427
docs/Doxyfile
Normal file
@ -8,9 +8,9 @@
|
|||||||
#
|
#
|
||||||
# All text after a single hash (#) is considered a comment and will be ignored.
|
# All text after a single hash (#) is considered a comment and will be ignored.
|
||||||
# The format is:
|
# The format is:
|
||||||
# TAG = value [value, ...]
|
# TAG = value [value, file.]
|
||||||
# For lists, items can also be appended using:
|
# For lists, items can also be appended using:
|
||||||
# TAG += value [value, ...]
|
# TAG += value [value, file.]
|
||||||
# Values that contain spaces should be placed between quotes (\" \").
|
# Values that contain spaces should be placed between quotes (\" \").
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
@ -51,7 +51,7 @@ PROJECT_BRIEF = "The YAP Prolog Compiler Manual"
|
|||||||
# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
|
# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
|
||||||
# the logo to the output directory.
|
# the logo to the output directory.
|
||||||
|
|
||||||
PROJECT_LOGO = @CMAKE_SOURCE_DIR@/misc/icons/yap_96x96x32.png
|
PROJECT_LOGO = @CMAKE_SOURCE_DIR@/docs/icons/yap_96x96x32.png
|
||||||
|
|
||||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
|
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
|
||||||
# into which the generated documentation will be written. If a relative path is
|
# into which the generated documentation will be written. If a relative path is
|
||||||
@ -384,7 +384,7 @@ INLINE_GROUPED_CLASSES = NO
|
|||||||
# with only public data fields or simple typedef fields will be shown inline in
|
# with only public data fields or simple typedef fields will be shown inline in
|
||||||
# the documentation of the scope in which they are defined (i.e. file,
|
# the documentation of the scope in which they are defined (i.e. file,
|
||||||
# namespace, or group documentation), provided this scope is documented. If set
|
# namespace, or group documentation), provided this scope is documented. If set
|
||||||
# to NO, structs, classes, and unions are shown on a separate page (for HTML and
|
v# to NO, structs, classes, and unions are shown on a separate page (for HTML and
|
||||||
# Man pages) or section (for LaTeX and RTF).
|
# Man pages) or section (for LaTeX and RTF).
|
||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
|
|
||||||
@ -407,7 +407,7 @@ TYPEDEF_HIDES_STRUCT = NO
|
|||||||
# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small
|
# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small
|
||||||
# doxygen will become slower. If the cache is too large, memory is wasted. The
|
# doxygen will become slower. If the cache is too large, memory is wasted. The
|
||||||
# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range
|
# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range
|
||||||
# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536
|
# is 0file9, the default is 0, corresponding to a cache size of 2^16=65536
|
||||||
# symbols. At the end of a run doxygen will report the cache usage and suggest
|
# symbols. At the end of a run doxygen will report the cache usage and suggest
|
||||||
# the optimal cache size from a speed point of view.
|
# the optimal cache size from a speed point of view.
|
||||||
# Minimum value: 0, maximum value: 9, default value: 0.
|
# Minimum value: 0, maximum value: 9, default value: 0.
|
||||||
@ -636,8 +636,8 @@ GENERATE_BUGLIST = YES
|
|||||||
GENERATE_DEPRECATEDLIST= YES
|
GENERATE_DEPRECATEDLIST= YES
|
||||||
|
|
||||||
# The ENABLED_SECTIONS tag can be used to enable conditional documentation
|
# The ENABLED_SECTIONS tag can be used to enable conditional documentation
|
||||||
# sections, marked by \if <section_label> ... \endif and \cond <section_label>
|
# sections, marked by \if <section_label> file. \endif and \cond <section_label>
|
||||||
# ... \endcond blocks.
|
# file. \endcond blocks.
|
||||||
|
|
||||||
ENABLED_SECTIONS =
|
ENABLED_SECTIONS =
|
||||||
|
|
||||||
@ -776,15 +776,15 @@ WARN_LOGFILE =
|
|||||||
# Note: If this tag is empty the current directory is searched.
|
# Note: If this tag is empty the current directory is searched.
|
||||||
|
|
||||||
INPUT = @PROJECT_SOURCE_DIR@/pl \
|
INPUT = @PROJECT_SOURCE_DIR@/pl \
|
||||||
@PROJECT_SOURCE_DIR@/swi \
|
|
||||||
@PROJECT_SOURCE_DIR@/CXX \
|
@PROJECT_SOURCE_DIR@/CXX \
|
||||||
@PROJECT_SOURCE_DIR@/OPTYap \
|
@PROJECT_SOURCE_DIR@/OPTYap \
|
||||||
@PROJECT_SOURCE_DIR@/C \
|
@PROJECT_SOURCE_DIR@/C \
|
||||||
@PROJECT_SOURCE_DIR@/H \
|
@PROJECT_SOURCE_DIR@/H \
|
||||||
@PROJECT_SOURCE_DIR@/include \
|
@PROJECT_SOURCE_DIR@/include \
|
||||||
@PROJECT_SOURCE_DIR@/os \
|
@PROJECT_SOURCE_DIR@/os \
|
||||||
@PROJECT_SOURCE_DIR@/packages \
|
|
||||||
@PROJECT_SOURCE_DIR@/library \
|
@PROJECT_SOURCE_DIR@/library \
|
||||||
|
@PROJECT_SOURCE_DIR@/packages \
|
||||||
|
@PROJECT_SOURCE_DIR@/swi/library \
|
||||||
@PROJECT_SOURCE_DIR@/docs/yap.md \
|
@PROJECT_SOURCE_DIR@/docs/yap.md \
|
||||||
@PROJECT_SOURCE_DIR@/docs/chr.md \
|
@PROJECT_SOURCE_DIR@/docs/chr.md \
|
||||||
@PROJECT_SOURCE_DIR@/docs/clpqr.md \
|
@PROJECT_SOURCE_DIR@/docs/clpqr.md \
|
||||||
@ -828,7 +828,7 @@ RECURSIVE = YES
|
|||||||
# Note that relative paths are relative to the directory from which doxygen is
|
# Note that relative paths are relative to the directory from which doxygen is
|
||||||
# run.
|
# run.
|
||||||
|
|
||||||
EXCLUDE = *pltotex.pl packages/swig/android packages/chr packages/RDF packages/pyswip
|
EXCLUDE = *pltotex.pl
|
||||||
|
|
||||||
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
|
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
|
||||||
# directories that are symbolic links (a Unix file system feature) are excluded
|
# directories that are symbolic links (a Unix file system feature) are excluded
|
||||||
@ -844,7 +844,7 @@ EXCLUDE_SYMLINKS = NO
|
|||||||
# Note that the wildcards are matched against the file with absolute path, so to
|
# Note that the wildcards are matched against the file with absolute path, so to
|
||||||
# exclude all test directories for example use the pattern */test/*
|
# exclude all test directories for example use the pattern */test/*
|
||||||
|
|
||||||
EXCLUDE_PATTERNS =
|
EXCLUDE_PATTERNS = */CMakeFiles/* *~
|
||||||
|
|
||||||
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
|
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
|
||||||
# (namespaces, classes, functions, etc.) that should be excluded from the
|
# (namespaces, classes, functions, etc.) that should be excluded from the
|
||||||
@ -881,7 +881,7 @@ EXAMPLE_RECURSIVE = NO
|
|||||||
# that contain images that are to be included in the documentation (see the
|
# that contain images that are to be included in the documentation (see the
|
||||||
# \image command).
|
# \image command).
|
||||||
|
|
||||||
IMAGE_PATH = @CMAKE_SOURCE_DIR@/misc/icons
|
IMAGE_PATH = @CMAKE_SOURCE_DIR@/docs/icons
|
||||||
|
|
||||||
# The INPUT_FILTER tag can be used to specify a program that doxygen should
|
# The INPUT_FILTER tag can be used to specify a program that doxygen should
|
||||||
# invoke to filter for each input file. Doxygen will invoke the filter program
|
# invoke to filter for each input file. Doxygen will invoke the filter program
|
||||||
@ -1094,6 +1094,7 @@ HTML_FILE_EXTENSION = .html
|
|||||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||||
|
|
||||||
HTML_HEADER =
|
HTML_HEADER =
|
||||||
|
|
||||||
#@CMAKE_SOURCE_DIR@/docs/web/bootstrap/header.html
|
#@CMAKE_SOURCE_DIR@/docs/web/bootstrap/header.html
|
||||||
|
|
||||||
# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
|
# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
|
||||||
@ -1105,7 +1106,8 @@ HTML_HEADER =
|
|||||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||||
|
|
||||||
HTML_FOOTER =
|
HTML_FOOTER =
|
||||||
@CMAKE_SOURCE_DIR@/docs/web/bootstrap/footer.html
|
|
||||||
|
#@CMAKE_SOURCE_DIR@/docs/web/bootstrap/footer.html
|
||||||
|
|
||||||
# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style
|
# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style
|
||||||
# sheet that is used by each HTML page. It can be used to fine-tune the look of
|
# sheet that is used by each HTML page. It can be used to fine-tune the look of
|
||||||
@ -1118,6 +1120,7 @@ HTML_FOOTER =
|
|||||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||||
|
|
||||||
HTML_STYLESHEET =
|
HTML_STYLESHEET =
|
||||||
|
|
||||||
#@CMAKE_SOURCE_DIR@/docs/web/bootstrap/customdoxygen.css
|
#@CMAKE_SOURCE_DIR@/docs/web/bootstrap/customdoxygen.css
|
||||||
|
|
||||||
# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined
|
# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined
|
||||||
@ -1131,7 +1134,9 @@ HTML_STYLESHEET =
|
|||||||
# list). For an example see the documentation.
|
# list). For an example see the documentation.
|
||||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||||
|
|
||||||
HTML_EXTRA_STYLESHEET = @CMAKE_SOURCE_DIR@/docs/solarized-light.css
|
HTML_EXTRA_STYLESHEET =
|
||||||
|
|
||||||
|
# @CMAKE_SOURCE_DIR@/docs/solarized-light.css
|
||||||
|
|
||||||
# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
|
# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
|
||||||
# other source files which should be copied to the HTML output directory. Note
|
# other source files which should be copied to the HTML output directory. Note
|
||||||
@ -1142,6 +1147,7 @@ HTML_EXTRA_STYLESHEET = @CMAKE_SOURCE_DIR@/docs/solarized-light.css
|
|||||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||||
|
|
||||||
HTML_EXTRA_FILES =
|
HTML_EXTRA_FILES =
|
||||||
|
|
||||||
#@CMAKE_SOURCE_DIR@/docs/web/bootstrap/doxy-boot.js
|
#@CMAKE_SOURCE_DIR@/docs/web/bootstrap/doxy-boot.js
|
||||||
|
|
||||||
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
|
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
|
||||||
@ -1489,7 +1495,7 @@ MATHJAX_FORMAT = HTML-CSS
|
|||||||
# output directory using the MATHJAX_RELPATH option. The destination directory
|
# output directory using the MATHJAX_RELPATH option. The destination directory
|
||||||
# should contain the MathJax.js script. For instance, if the mathjax directory
|
# should contain the MathJax.js script. For instance, if the mathjax directory
|
||||||
# is located at the same level as the HTML output directory, then
|
# is located at the same level as the HTML output directory, then
|
||||||
# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax
|
# MATHJAX_RELPATH should be file/mathjax. The default value points to the MathJax
|
||||||
# Content Delivery Network so you can quickly see the result without installing
|
# Content Delivery Network so you can quickly see the result without installing
|
||||||
# MathJax. However, it is strongly recommended to install a local copy of
|
# MathJax. However, it is strongly recommended to install a local copy of
|
||||||
# MathJax from http://www.mathjax.org before deployment.
|
# MathJax from http://www.mathjax.org before deployment.
|
||||||
@ -1886,7 +1892,7 @@ MAN_LINKS = NO
|
|||||||
# captures the structure of the code including all documentation.
|
# captures the structure of the code including all documentation.
|
||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
|
|
||||||
GENERATE_XML = NO
|
GENERATE_XML = YES
|
||||||
|
|
||||||
# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a
|
# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a
|
||||||
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
|
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
|
||||||
@ -2069,7 +2075,7 @@ SKIP_FUNCTION_MACROS = YES
|
|||||||
# a tag file without this location is as follows:
|
# a tag file without this location is as follows:
|
||||||
# TAGFILES = file1 file2 ...
|
# TAGFILES = file1 file2 ...
|
||||||
# Adding location for the tag files is done as follows:
|
# Adding location for the tag files is done as follows:
|
||||||
# TAGFILES = file1=loc1 "file2 = loc2" ...
|
# TAGFILES = file1=loc1 "file2 = loc2" file.
|
||||||
# where loc1 and loc2 can be relative or absolute paths or URLs. See the
|
# where loc1 and loc2 can be relative or absolute paths or URLs. See the
|
||||||
# section "Linking to external documentation" for more information about the use
|
# section "Linking to external documentation" for more information about the use
|
||||||
# of tag files.
|
# of tag files.
|
||||||
|
4
docs/application.js
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
$(function () {
|
||||||
|
$('a').tooltip();
|
||||||
|
});
|
7
docs/bootstrap.min.css
vendored
Normal file
7
docs/bootstrap.min.js
vendored
Normal file
0
docs/builtins.md
Normal file
@ -2,6 +2,8 @@
|
|||||||
CHR: Constraint Handling Rules {#chr}
|
CHR: Constraint Handling Rules {#chr}
|
||||||
==============================
|
==============================
|
||||||
|
|
||||||
|
@ingroup packages
|
||||||
|
|
||||||
This chapter is written by Tom Schrijvers, K.U. Leuven for the hProlog
|
This chapter is written by Tom Schrijvers, K.U. Leuven for the hProlog
|
||||||
system. Adjusted by Jan Wielemaker to fit the SWI-Prolog documentation
|
system. Adjusted by Jan Wielemaker to fit the SWI-Prolog documentation
|
||||||
infrastructure and remove hProlog specific references.
|
infrastructure and remove hProlog specific references.
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
Constraint Logic Programming over Rationals and Reals {#clpqr}
|
Constraint Logic Programming over Rationals and Reals {#clpqr}
|
||||||
=====================================================
|
=====================================================
|
||||||
|
|
||||||
|
@ingroup paackages
|
||||||
|
|
||||||
YAP now uses the CLP(R) package developed by <em>Leslie De Koninck</em>,
|
YAP now uses the CLP(R) package developed by <em>Leslie De Koninck</em>,
|
||||||
K.U. Leuven as part of a thesis with supervisor Bart Demoen and daily
|
K.U. Leuven as part of a thesis with supervisor Bart Demoen and daily
|
||||||
|
0
docs/download.md
Normal file
121
docs/doxy-boot.js
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
$( document ).ready(function() {
|
||||||
|
|
||||||
|
$("div.headertitle").addClass("page-header");
|
||||||
|
$("div.title").addClass("h1");
|
||||||
|
|
||||||
|
$('li > a[href="index.html"] > span').before("<i class='fa fa-cog'></i> ");
|
||||||
|
$('li > a[href="index.html"] > span').text("BioGears");
|
||||||
|
$('li > a[href="modules.html"] > span').before("<i class='fa fa-square'></i> ");
|
||||||
|
$('li > a[href="namespaces.html"] > span').before("<i class='fa fa-bars'></i> ");
|
||||||
|
$('li > a[href="annotated.html"] > span').before("<i class='fa fa-list-ul'></i> ");
|
||||||
|
$('li > a[href="classes.html"] > span').before("<i class='fa fa-book'></i> ");
|
||||||
|
$('li > a[href="inherits.html"] > span').before("<i class='fa fa-sitemap'></i> ");
|
||||||
|
$('li > a[href="functions.html"] > span').before("<i class='fa fa-list'></i> ");
|
||||||
|
$('li > a[href="functions_func.html"] > span').before("<i class='fa fa-list'></i> ");
|
||||||
|
$('li > a[href="functions_vars.html"] > span').before("<i class='fa fa-list'></i> ");
|
||||||
|
$('li > a[href="functions_enum.html"] > span').before("<i class='fa fa-list'></i> ");
|
||||||
|
$('li > a[href="functions_eval.html"] > span').before("<i class='fa fa-list'></i> ");
|
||||||
|
$('img[src="ftv2ns.png"]').replaceWith('<span class="label label-danger">N</span> ');
|
||||||
|
$('img[src="ftv2cl.png"]').replaceWith('<span class="label label-danger">C</span> ');
|
||||||
|
|
||||||
|
$("ul.tablist").addClass("nav nav-pills nav-justified");
|
||||||
|
$("ul.tablist").css("margin-top", "0.5em");
|
||||||
|
$("ul.tablist").css("margin-bottom", "0.5em");
|
||||||
|
$("li.current").addClass("active");
|
||||||
|
$("iframe").attr("scrolling", "yes");
|
||||||
|
|
||||||
|
$("#nav-path > ul").addClass("breadcrumb");
|
||||||
|
|
||||||
|
$("table.params").addClass("table");
|
||||||
|
$("div.ingroups").wrapInner("<small></small>");
|
||||||
|
$("div.levels").css("margin", "0.5em");
|
||||||
|
$("div.levels > span").addClass("btn btn-default btn-xs");
|
||||||
|
$("div.levels > span").css("margin-right", "0.25em");
|
||||||
|
|
||||||
|
$("table.directory").addClass("table table-striped");
|
||||||
|
$("div.summary > a").addClass("btn btn-default btn-xs");
|
||||||
|
$("table.fieldtable").addClass("table");
|
||||||
|
$(".fragment").addClass("well");
|
||||||
|
$(".memitem").addClass("panel panel-default");
|
||||||
|
$(".memproto").addClass("panel-heading");
|
||||||
|
$(".memdoc").addClass("panel-body");
|
||||||
|
$("span.mlabel").addClass("label label-info");
|
||||||
|
|
||||||
|
$("table.memberdecls").addClass("table");
|
||||||
|
$("[class^=memitem]").addClass("active");
|
||||||
|
|
||||||
|
$("div.ah").addClass("btn btn-default");
|
||||||
|
$("span.mlabels").addClass("pull-right");
|
||||||
|
$("table.mlabels").css("width", "100%")
|
||||||
|
$("td.mlabels-right").addClass("pull-right");
|
||||||
|
|
||||||
|
$("div.ttc").addClass("panel panel-primary");
|
||||||
|
$("div.ttname").addClass("panel-heading");
|
||||||
|
$("div.ttname a").css("color", 'white');
|
||||||
|
$("div.ttdef,div.ttdoc,div.ttdeci").addClass("panel-body");
|
||||||
|
|
||||||
|
$('#MSearchBox').parent().remove();
|
||||||
|
|
||||||
|
$('div.fragment.well div.line:first').css('margin-top', '15px');
|
||||||
|
$('div.fragment.well div.line:last').css('margin-bottom', '15px');
|
||||||
|
|
||||||
|
$('table.doxtable').removeClass('doxtable').addClass('table table-striped table-bordered').each(function(){
|
||||||
|
$(this).prepend('<thead></thead>');
|
||||||
|
$(this).find('tbody > tr:first').prependTo($(this).find('thead'));
|
||||||
|
|
||||||
|
$(this).find('td > span.success').parent().addClass('success');
|
||||||
|
$(this).find('td > span.warning').parent().addClass('warning');
|
||||||
|
$(this).find('td > span.danger').parent().addClass('danger');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if($('div.fragment.well div.ttc').length > 0)
|
||||||
|
{
|
||||||
|
$('div.fragment.well div.line:first').parent().removeClass('fragment well');
|
||||||
|
}
|
||||||
|
|
||||||
|
$('table.memberdecls').find('.memItemRight').each(function(){
|
||||||
|
$(this).contents().appendTo($(this).siblings('.memItemLeft'));
|
||||||
|
$(this).siblings('.memItemLeft').attr('align', 'left');
|
||||||
|
});
|
||||||
|
|
||||||
|
function getOriginalWidthOfImg(img_element) {
|
||||||
|
var t = new Image();
|
||||||
|
t.src = (img_element.getAttribute ? img_element.getAttribute("src") : false) || img_element.src;
|
||||||
|
return t.width;
|
||||||
|
}
|
||||||
|
|
||||||
|
$('div.dyncontent').find('img').each(function(){
|
||||||
|
if(getOriginalWidthOfImg($(this)[0]) > $('#content>div.container').width())
|
||||||
|
$(this).css('width', '100%');
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".memitem").removeClass('memitem');
|
||||||
|
$(".memproto").removeClass('memproto');
|
||||||
|
$(".memdoc").removeClass('memdoc');
|
||||||
|
$("span.mlabel").removeClass('mlabel');
|
||||||
|
$("table.memberdecls").removeClass('memberdecls');
|
||||||
|
$("[class^=memitem]").removeClass('memitem');
|
||||||
|
$("span.mlabels").removeClass('mlabels');
|
||||||
|
$("table.mlabels").removeClass('mlabels');
|
||||||
|
$("td.mlabels-right").removeClass('mlabels-right');
|
||||||
|
$(".navpath").removeClass('navpath');
|
||||||
|
$("li.navelem").removeClass('navelem');
|
||||||
|
$("a.el").removeClass('el');
|
||||||
|
$("div.ah").removeClass('ah');
|
||||||
|
$("div.header").removeClass("header");
|
||||||
|
|
||||||
|
$('.mdescLeft').each(function(){
|
||||||
|
if($(this).html()==" ") {
|
||||||
|
$(this).siblings('.mdescRight').attr('colspan', 2);
|
||||||
|
$(this).remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('td.memItemLeft').each(function(){
|
||||||
|
if($(this).siblings('.memItemRight').html()=="") {
|
||||||
|
$(this).attr('colspan', 2);
|
||||||
|
$(this).siblings('.memItemRight').remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
0
docs/extensions.md
Normal file
0
docs/fli.md
Normal file
4
docs/font-awesome.min.css
vendored
Normal file
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 274 KiB After Width: | Height: | Size: 274 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 755 B After Width: | Height: | Size: 755 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |