Merge /home/vsc/yap
This commit is contained in:
commit
81e37d5ce0
@ -12,11 +12,15 @@ WITH_VARS="swig|yes|WITH_SWIG \
|
||||
mpi|yes|WITH_MPI \
|
||||
gecode|yes|WITH_GECODE \
|
||||
docs|yes|WITH_DOCS \
|
||||
r|yes|WITH_REAL \
|
||||
r|yes|WITH_R \
|
||||
myddas|yes|WITH_MYDDAS \
|
||||
cudd|yes|WITH_CUDD \
|
||||
xml2|yes|WITH_XML2 \
|
||||
raptor|yes|WITH_RAPTOR \
|
||||
python|yes|WITH_PYTHON \
|
||||
openssl|yes|WITH_OPENSSL\
|
||||
java|yes|WITH_JAVA
|
||||
lbfgs|yes|WITH_LBFGS
|
||||
extensions|yes|WITH_EXTENSIONS
|
||||
readline|yes|WITH_READLINE \
|
||||
gmp|yes|WITH_GMP"
|
||||
|
29
C/absmi.c
29
C/absmi.c
@ -224,7 +224,7 @@ static int stack_overflow(PredEntry *pe, CELL *env, yamop *cp,
|
||||
Yap_get_signal(YAP_STOVF_SIGNAL)) {
|
||||
S = (CELL *)pe;
|
||||
if (!Yap_locked_gc(nargs, env, cp)) {
|
||||
Yap_NilError(RESOURCE_ERROR_STACK, LOCAL_ErrorMessage);
|
||||
Yap_NilError(RESOURCE_ERROR_STACK, "stack overflow: gc failed");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@ -239,7 +239,7 @@ static int code_overflow(CELL *yenv USES_REGS) {
|
||||
/* do a garbage collection first to check if we can recover memory */
|
||||
if (!Yap_locked_growheap(false, 0, NULL)) {
|
||||
Yap_NilError(RESOURCE_ERROR_HEAP, "YAP failed to grow heap: %s",
|
||||
LOCAL_ErrorMessage);
|
||||
"malloc/mmap failed");
|
||||
return 0;
|
||||
}
|
||||
CACHE_A1();
|
||||
@ -689,7 +689,7 @@ static int interrupt_deallocate(USES_REGS1) {
|
||||
return rc;
|
||||
}
|
||||
if (!Yap_locked_gc(0, ENV, YESCODE)) {
|
||||
Yap_NilError(RESOURCE_ERROR_STACK, LOCAL_ErrorMessage);
|
||||
Yap_NilError(RESOURCE_ERROR_STACK, "stack overflow: gc failed");
|
||||
}
|
||||
S = ASP;
|
||||
S[E_CB] = (CELL)(LCL0 - cut_b);
|
||||
@ -751,7 +751,7 @@ static int interrupt_cut_e(USES_REGS1) {
|
||||
if ((v = check_alarm_fail_int(2 PASS_REGS)) >= 0) {
|
||||
return v;
|
||||
}
|
||||
if (!Yap_only_has_signals(YAP_CDOVF_SIGNAL, YAP_CREEP_SIGNAL)) {
|
||||
if (Yap_only_has_signals(YAP_CDOVF_SIGNAL, YAP_CREEP_SIGNAL)) {
|
||||
return 2;
|
||||
}
|
||||
/* find something to fool S */
|
||||
@ -957,35 +957,32 @@ static void undef_goal(USES_REGS1) {
|
||||
} else {
|
||||
d0 = AbsAppl(HR);
|
||||
*HR++ = (CELL)pe->FunctorOfPred;
|
||||
CELL *ip=HR, *imax = HR+pe->ArityOfPE;
|
||||
HR = imax;
|
||||
BEGP(pt1);
|
||||
pt1 = XREGS + 1;
|
||||
for (; ip < imax; ip++) {
|
||||
CELL *ip=HR;
|
||||
UInt imax = pe->ArityOfPE;
|
||||
HR += imax;
|
||||
UInt i = 1;
|
||||
for (; i <= imax; ip++, i++) {
|
||||
BEGD(d1);
|
||||
BEGP(pt0);
|
||||
pt0 = pt1++;
|
||||
d1 = *pt0;
|
||||
d1 = XREGS[i];
|
||||
deref_head(d1, undef_unk);
|
||||
undef_nonvar:
|
||||
/* just copy it to the heap */
|
||||
*ip = d1;
|
||||
continue;
|
||||
|
||||
derefa_body(d1, pt0, undef_unk, undef_nonvar);
|
||||
if (pt0 <= HR) {
|
||||
deref_body(d1, pt0, undef_unk, undef_nonvar);
|
||||
if (pt0 < HR) {
|
||||
/* variable is safe */
|
||||
*ip = (CELL)pt0;
|
||||
} else {
|
||||
/* bind it, in case it is a local variable */
|
||||
d1 = Unsigned(ip);
|
||||
RESET_VARIABLE(ip);
|
||||
Bind_Local(pt0, d1);
|
||||
Bind_Local(pt0, Unsigned(ip));
|
||||
}
|
||||
ENDP(pt0);
|
||||
ENDD(d1);
|
||||
}
|
||||
ENDP(pt1);
|
||||
}
|
||||
ARG1 = AbsPair(HR);
|
||||
HR[1] = d0;
|
||||
|
@ -1102,7 +1102,7 @@
|
||||
PP = NULL;
|
||||
#endif
|
||||
if (!Yap_gc(3, ENV, CP)) {
|
||||
Yap_NilError(RESOURCE_ERROR_STACK, LOCAL_ErrorMessage);
|
||||
Yap_NilError(RESOURCE_ERROR_STACK, "stack overflow: gc failed");
|
||||
FAIL();
|
||||
}
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
@ -1226,7 +1226,7 @@
|
||||
PREG = NEXTOP(PREG,Osbpa);
|
||||
saveregs();
|
||||
if (!Yap_gcl(sz, arity, YENV, PREG)) {
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage);
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,"stack overflow: gc failed");
|
||||
setregs();
|
||||
FAIL();
|
||||
} else {
|
||||
@ -10927,7 +10927,7 @@
|
||||
/* make sure we have something to show for our trouble */
|
||||
saveregs();
|
||||
if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,xxx),Osbpp))) {
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage);
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,"stack overflow: gc failed");
|
||||
setregs();
|
||||
JMPNext();
|
||||
} else {
|
||||
@ -11044,7 +11044,7 @@
|
||||
/* make sure we have something to show for our trouble */
|
||||
saveregs();
|
||||
if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,xxc),Osbpp))) {
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage);
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,"stack overflow: gc failed");
|
||||
setregs();
|
||||
JMPNext();
|
||||
} else {
|
||||
@ -11154,7 +11154,7 @@
|
||||
/* make sure we have something to show for our trouble */
|
||||
saveregs();
|
||||
if (!Yap_gc(0, YREG, NEXTOP(NEXTOP(PREG,xxn),Osbpp))) {
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage);
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,"stack overflow: gc failed");
|
||||
setregs();
|
||||
JMPNext();
|
||||
} else {
|
||||
@ -11261,7 +11261,7 @@
|
||||
/* make sure we have something to show for our trouble */
|
||||
saveregs();
|
||||
if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,yxx),Osbpp))) {
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage);
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,"stack overflow: gc failed");
|
||||
setregs();
|
||||
JMPNext();
|
||||
} else {
|
||||
@ -11388,7 +11388,7 @@
|
||||
/* make sure we have something to show for our trouble */
|
||||
saveregs();
|
||||
if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,yxc),Osbpp))) {
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage);
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,"stack overflow: gc failed");
|
||||
setregs();
|
||||
JMPNext();
|
||||
} else {
|
||||
@ -11516,7 +11516,7 @@
|
||||
/* make sure we have something to show for our trouble */
|
||||
saveregs();
|
||||
if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,yxn),Osbpp))) {
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage);
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,"stack overflow: gc failed");
|
||||
setregs();
|
||||
JMPNext();
|
||||
} else {
|
||||
@ -11892,7 +11892,7 @@
|
||||
/* make sure we have something to show for our trouble */
|
||||
saveregs();
|
||||
if (!Yap_gcl((1+d1)*sizeof(CELL), 3, YREG, NEXTOP(NEXTOP(PREG,e),Osbmp))) {
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage);
|
||||
Yap_NilError(RESOURCE_ERROR_STACK,"stack overflow: gc failed" );
|
||||
setregs();
|
||||
JMPNext();
|
||||
} else {
|
||||
|
13
C/arith0.c
13
C/arith0.c
@ -186,18 +186,6 @@ eval0(Int fi) {
|
||||
RINT((Int)ASP);
|
||||
#else
|
||||
RINT(LCL0 - ASP);
|
||||
#endif
|
||||
case op_b:
|
||||
/// - $b
|
||||
/// current choicepoint
|
||||
///
|
||||
#if YAPOR_SBA
|
||||
RINT((Int)B);
|
||||
#else
|
||||
if (B)
|
||||
RINT(LCL0 - (CELL *)B);
|
||||
else
|
||||
RINT(0);
|
||||
#endif
|
||||
case op_env:
|
||||
/// - $env
|
||||
@ -257,7 +245,6 @@ static InitConstEntry InitConstTab[] = {
|
||||
{"heapused", op_heapused},
|
||||
{"local_sp", op_localsp},
|
||||
{"global_sp", op_globalsp},
|
||||
{"$last_choice_pt", op_b},
|
||||
{"$env", op_env},
|
||||
{"$tr", op_tr},
|
||||
{"stackfree", op_stackfree},
|
||||
|
@ -218,6 +218,11 @@ X_API YAP_Term YAP_A(int i) {
|
||||
return (Deref(XREGS[i]));
|
||||
}
|
||||
|
||||
X_API YAP_Term YAP_SetA(int i, YAP_Term t) {
|
||||
CACHE_REGS
|
||||
return (Deref(XREGS[i]));
|
||||
}
|
||||
|
||||
X_API YAP_Bool YAP_IsIntTerm(YAP_Term t) { return IsIntegerTerm(t); }
|
||||
|
||||
X_API YAP_Bool YAP_IsNumberTerm(YAP_Term t) {
|
||||
@ -1352,8 +1357,8 @@ X_API void YAP_FreeSpaceFromYap(void *ptr) { Yap_FreeCodeSpace(ptr); }
|
||||
* @param bufsize bu
|
||||
*
|
||||
* @return
|
||||
*/ X_API char *
|
||||
YAP_StringToBuffer(Term t, char *buf, unsigned int bufsize) {
|
||||
*/
|
||||
X_API char *YAP_StringToBuffer(Term t, char *buf, unsigned int bufsize) {
|
||||
CACHE_REGS
|
||||
BACKUP_MACHINE_REGS();
|
||||
seq_tv_t inp, out;
|
||||
@ -1464,7 +1469,8 @@ X_API Term YAP_ReadBuffer(const char *s, Term *tp) {
|
||||
else
|
||||
tv = (Term)0;
|
||||
LOCAL_ErrorMessage = NULL;
|
||||
while (!(t = Yap_BufferToTermWithPrioBindings(s, TermNil, tv, strlen(s) + 1, GLOBAL_MaxPriority))) {
|
||||
while (!(t = Yap_BufferToTermWithPrioBindings(s, TermNil, tv, strlen(s) + 1,
|
||||
GLOBAL_MaxPriority))) {
|
||||
if (LOCAL_ErrorMessage) {
|
||||
if (!strcmp(LOCAL_ErrorMessage, "Stack Overflow")) {
|
||||
if (!Yap_dogc(0, NULL PASS_REGS)) {
|
||||
@ -1731,7 +1737,9 @@ X_API bool YAP_EnterGoal(YAP_PredEntryPtr ape, CELL *ptr, YAP_dogoalinfo *dgi) {
|
||||
CACHE_REGS
|
||||
PredEntry *pe = ape;
|
||||
bool out;
|
||||
// fprintf(stderr,"EnterGoal: H=%d ENV=%p B=%d TR=%d P=%p CP=%p Slots=%d\n",HR-H0,LCL0-ENV,LCL0-(CELL*)B,(CELL*)TR-LCL0, P, CP, LOCAL_CurSlot);
|
||||
// fprintf(stderr,"EnterGoal: H=%d ENV=%p B=%d TR=%d P=%p CP=%p
|
||||
// Slots=%d\n",HR-H0,LCL0-ENV,LCL0-(CELL*)B,(CELL*)TR-LCL0, P, CP,
|
||||
// LOCAL_CurSlot);
|
||||
|
||||
BACKUP_MACHINE_REGS();
|
||||
LOCAL_ActiveError->errorNo = YAP_NO_ERROR;
|
||||
@ -1753,7 +1761,9 @@ X_API bool YAP_EnterGoal(YAP_PredEntryPtr ape, CELL *ptr, YAP_dogoalinfo *dgi) {
|
||||
// fprintf(stderr,"PrepGoal: H=%d ENV=%p B=%d TR=%d P=%p CP=%p Slots=%d\n",
|
||||
// HR-H0,LCL0-ENV,LCL0-(CELL*)B,(CELL*)TR-LCL0, P, CP, LOCAL_CurSlot);
|
||||
out = Yap_exec_absmi(true, false);
|
||||
// fprintf(stderr,"EnterGoal success=%d: H=%d ENV=%p B=%d TR=%d P=%p CP=%p Slots=%d\n", out,HR-H0,LCL0-ENV,LCL0-(CELL*)B,(CELL*)TR-LCL0, P, CP, LOCAL_CurSlot);
|
||||
// fprintf(stderr,"EnterGoal success=%d: H=%d ENV=%p B=%d TR=%d P=%p CP=%p
|
||||
// Slots=%d\n", out,HR-H0,LCL0-ENV,LCL0-(CELL*)B,(CELL*)TR-LCL0, P, CP,
|
||||
// LOCAL_CurSlot);
|
||||
dgi->b = LCL0 - (CELL *)B;
|
||||
if (out) {
|
||||
dgi->EndSlot = LOCAL_CurSlot;
|
||||
@ -1801,46 +1811,24 @@ X_API bool YAP_RetryGoal(YAP_dogoalinfo *dgi) {
|
||||
return out;
|
||||
}
|
||||
|
||||
static void completeInnerCall( bool on_cut, yamop *old_CP, yamop *old_P)
|
||||
{
|
||||
if (on_cut) {
|
||||
P = old_P;
|
||||
ENV = (CELL *)ENV[E_E];
|
||||
CP = old_CP;
|
||||
LOCAL_AllowRestart = TRUE;
|
||||
// we are back to user code again, need slots */
|
||||
} else {
|
||||
P = old_P;
|
||||
ENV = B->cp_env;
|
||||
ENV = (CELL *)ENV[E_E];
|
||||
CP = old_CP;
|
||||
HR = B->cp_h;
|
||||
TR = B->cp_tr;
|
||||
B = B->cp_b;
|
||||
LOCAL_AllowRestart = FALSE;
|
||||
SET_ASP(ENV, E_CB * sizeof(CELL));
|
||||
// make sure the slots are ok.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
X_API bool YAP_LeaveGoal(bool successful, YAP_dogoalinfo *dgi) {
|
||||
CACHE_REGS
|
||||
choiceptr myB, handler;
|
||||
|
||||
// fprintf(stderr,"LeaveGoal success=%d: H=%d ENV=%p B=%ld myB=%ld TR=%d P=%p CP=%p Slots=%d\n", successful,HR-H0,LCL0-ENV,LCL0-(CELL*)B,dgi->b0,(CELL*)TR-LCL0, P, CP, LOCAL_CurSlot);
|
||||
// fprintf(stderr,"LeaveGoal success=%d: H=%d ENV=%p B=%ld myB=%ld TR=%d
|
||||
// P=%p CP=%p Slots=%d\n",
|
||||
// successful,HR-H0,LCL0-ENV,LCL0-(CELL*)B,dgi->b0,(CELL*)TR-LCL0, P, CP,
|
||||
// LOCAL_CurSlot);
|
||||
BACKUP_MACHINE_REGS();
|
||||
myB = (choiceptr)(LCL0 - dgi->b);
|
||||
if (LOCAL_PrologMode & AsyncIntMode) {
|
||||
Yap_signal(YAP_FAIL_SIGNAL);
|
||||
}
|
||||
handler = B;
|
||||
while (handler
|
||||
&& LCL0-LOCAL_CBorder > (CELL *)handler
|
||||
while (handler &&
|
||||
LCL0 - LOCAL_CBorder > (CELL *)handler
|
||||
//&& handler->cp_ap != NOCODE
|
||||
&& handler->cp_b != NULL
|
||||
&& handler != myB
|
||||
) {
|
||||
&& handler->cp_b != NULL && handler != myB) {
|
||||
if (handler < myB) {
|
||||
handler->cp_ap = TRUSTFAILCODE;
|
||||
}
|
||||
@ -1859,7 +1847,9 @@ X_API bool YAP_LeaveGoal(bool successful, YAP_dogoalinfo *dgi) {
|
||||
P = dgi->p;
|
||||
CP = dgi->cp;
|
||||
RECOVER_MACHINE_REGS();
|
||||
// fprintf(stderr,"LeftGoal success=%d: H=%d ENV=%p B=%d TR=%d P=%p CP=%p Slots=%d\n", successful,HR-H0,LCL0-ENV,LCL0-(CELL*)B,(CELL*)TR-LCL0, P, CP, LOCAL_CurSlot);
|
||||
// fprintf(stderr,"LeftGoal success=%d: H=%d ENV=%p B=%d TR=%d P=%p CP=%p
|
||||
// Slots=%d\n", successful,HR-H0,LCL0-ENV,LCL0-(CELL*)B,(CELL*)TR-LCL0, P,
|
||||
// CP, LOCAL_CurSlot);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -2114,14 +2104,16 @@ X_API void YAP_ClearExceptions(void) {
|
||||
Yap_ResetException(worker_id);
|
||||
}
|
||||
|
||||
X_API int YAP_InitConsult(int mode, const char *fname, char **full, int *osnop) {
|
||||
X_API int YAP_InitConsult(int mode, const char *fname, char **full,
|
||||
int *osnop) {
|
||||
CACHE_REGS
|
||||
int sno;
|
||||
BACKUP_MACHINE_REGS();
|
||||
const char *fl = NULL;
|
||||
int lvl = push_text_stack();
|
||||
if (mode == YAP_BOOT_MODE) {
|
||||
mode = YAP_CONSULT_MODE; }
|
||||
mode = YAP_CONSULT_MODE;
|
||||
}
|
||||
if (fname == NULL || fname[0] == '\0') {
|
||||
fl = Yap_BOOTFILE;
|
||||
}
|
||||
@ -2143,13 +2135,14 @@ X_API int YAP_InitConsult(int mode, const char *fname, char **full, int *osnop)
|
||||
strcpy(d, fl);
|
||||
bool consulted = (mode == YAP_CONSULT_MODE);
|
||||
Term tat = MkAtomTerm(Yap_LookupAtom(d));
|
||||
sno = Yap_OpenStream(tat, "r", MkAtomTerm(Yap_LookupAtom(fname)), LOCAL_encoding);
|
||||
if (sno < 0 ||
|
||||
!Yap_ChDir(dirname((char *)d))) {
|
||||
sno = Yap_OpenStream(tat, "r", MkAtomTerm(Yap_LookupAtom(fname)),
|
||||
LOCAL_encoding);
|
||||
if (sno < 0 || !Yap_ChDir(dirname((char *)d))) {
|
||||
pop_text_stack(lvl);
|
||||
*full = NULL;
|
||||
return -1;
|
||||
} LOCAL_PrologMode = UserMode;
|
||||
}
|
||||
LOCAL_PrologMode = UserMode;
|
||||
|
||||
Yap_init_consult(consulted, pop_output_text_stack__(lvl, fl));
|
||||
RECOVER_MACHINE_REGS();
|
||||
@ -2186,7 +2179,10 @@ X_API void YAP_EndConsult(int sno, int *osnop, const char *full) {
|
||||
Yap_AddAlias(AtomLoopStream, *osnop);
|
||||
Yap_end_consult();
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid ", " closing %s:%s(%d), %d",
|
||||
CurrentModule == 0? "prolog": RepAtom(AtomOfTerm(CurrentModule))->StrOfAE, full, *osnop, sno);
|
||||
CurrentModule == 0
|
||||
? "prolog"
|
||||
: RepAtom(AtomOfTerm(CurrentModule))->StrOfAE,
|
||||
full, *osnop, sno);
|
||||
// LOCAL_CurSlot);
|
||||
pop_text_stack(lvl);
|
||||
RECOVER_MACHINE_REGS();
|
||||
@ -2215,7 +2211,13 @@ X_API Term YAP_ReadFromStream(int sno) {
|
||||
X_API Term YAP_ReadClauseFromStream(int sno, Term vs, Term pos) {
|
||||
|
||||
BACKUP_MACHINE_REGS();
|
||||
Term t = Yap_read_term(sno,MkPairTerm(Yap_MkApplTerm(Yap_MkFunctor(AtomVariableNames,1),1,&vs), MkPairTerm(Yap_MkApplTerm(Yap_MkFunctor(AtomTermPosition,1),1,&pos), TermNil)), true);
|
||||
Term t = Yap_read_term(
|
||||
sno,
|
||||
MkPairTerm(Yap_MkApplTerm(Yap_MkFunctor(AtomVariableNames, 1), 1, &vs),
|
||||
MkPairTerm(Yap_MkApplTerm(Yap_MkFunctor(AtomTermPosition, 1),
|
||||
1, &pos),
|
||||
TermNil)),
|
||||
true);
|
||||
RECOVER_MACHINE_REGS();
|
||||
return t;
|
||||
}
|
||||
|
31
C/cdmgr.c
31
C/cdmgr.c
@ -94,20 +94,32 @@ void Yap_ResetConsultStack(void) {
|
||||
LOCAL_ConsultCapacity = InitialConsultCapacity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Are we compiling a file?
|
||||
*
|
||||
*/
|
||||
bool Yap_Consulting(USES_REGS1) {
|
||||
return LOCAL_ConsultBase != NULL
|
||||
&& LOCAL_ConsultSp != LOCAL_ConsultLow+LOCAL_ConsultCapacity;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
|
||||
ADDING AND REMOVE INFO TO A PROCEDURE
|
||||
|
||||
******************************************************************/
|
||||
|
||||
/*
|
||||
* we have three kinds of predicates: dynamic DynamicPredFlag
|
||||
* static CompiledPredFlag fast FastPredFlag all the
|
||||
/**
|
||||
* we have three kinds of predicates:
|
||||
* + dynamic DynamicPredFlag
|
||||
* + static CompiledPredFlag fast
|
||||
* + fast FastPredFlag.
|
||||
*
|
||||
* all the
|
||||
* database predicates are supported for dynamic predicates only abolish and
|
||||
* assertz are supported for static predicates no database predicates are
|
||||
* supportted for fast predicates
|
||||
*/
|
||||
|
||||
PredEntry *Yap_get_pred(Term t, Term tmod, const char *pname) {
|
||||
Term t0 = t;
|
||||
|
||||
@ -1207,8 +1219,8 @@ static void add_first_dynamic(PredEntry *p, yamop *cp, int spy_flag) {
|
||||
ncp = NEXTOP(ncp, e);
|
||||
ncp->opc = Yap_opcode(_Ystop);
|
||||
ncp->y_u.l.l = cl->ClCode;
|
||||
// if (!(p->PredFlags & MultiFileFlag) && p->src.OwnerFile == AtomNil)
|
||||
// p->src.OwnerFile = Yap_ConsultingFile(PASS_REGS1);
|
||||
if (!(p->PredFlags & MultiFileFlag) && p->src.OwnerFile == AtomNil)
|
||||
p->src.OwnerFile = Yap_ConsultingFile(PASS_REGS1);
|
||||
}
|
||||
|
||||
/* p is already locked */
|
||||
@ -2417,7 +2429,7 @@ static Int
|
||||
}
|
||||
|
||||
/* @pred '$new_multifile'(+G,+Mod)
|
||||
* sets the multi-file flag
|
||||
* declares rgi/////// the multi-file flag
|
||||
* */
|
||||
static Int new_multifile(USES_REGS1) {
|
||||
PredEntry *pe;
|
||||
@ -3169,15 +3181,14 @@ stash_predicate(USES_REGS1) {
|
||||
char ns[1024];
|
||||
const char *s = (pe->ModuleOfPred == PROLOG_MODULE ?
|
||||
"__prolog__stash__" :
|
||||
snprintf(sn,1023,"__%s__".RepAtom(AtomOfTerm( pe->ModuleOfPred ))));
|
||||
pe->ModuleOfPred = MkAtomTerm(Yap_LookupAtom(s));
|
||||
snprintf(sn,1023,"__%s__".RepAtom(AtomOfTerm(
|
||||
pe->ModuleOfPred )))); pe->ModuleOfPred = MkAtomTerm(Yap_LookupAtom(s));
|
||||
*/
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static Int /* $hidden_predicate(P) */
|
||||
hidden_predicate(USES_REGS1) {
|
||||
PredEntry *pe =
|
||||
|
@ -427,6 +427,8 @@ ructions *
|
||||
|
||||
Op(deallocate, p);
|
||||
CACHE_Y_AS_ENV(YREG);
|
||||
// do this before checking
|
||||
SREG = YREG;
|
||||
check_trail(TR);
|
||||
#ifndef NO_CHECKING
|
||||
/* check stacks */
|
||||
@ -435,7 +437,6 @@ ructions *
|
||||
PREG = NEXTOP(PREG, p);
|
||||
/* other instructions do depend on S being set by deallocate
|
||||
:-( */
|
||||
SREG = YREG;
|
||||
CPREG = (yamop *) ENV_YREG[E_CP];
|
||||
ENV = ENV_YREG = (CELL *) ENV_YREG[E_E];
|
||||
#ifdef DEPTH_LIMIT
|
||||
|
156
C/dbase.c
156
C/dbase.c
@ -25,90 +25,86 @@ static char SccsId[] = "%W% %G%";
|
||||
*
|
||||
* @brief record and other forms of storing terms.
|
||||
*
|
||||
* @namespace prolog
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup Internal_Database Internal Data Base
|
||||
|
||||
@ingroup builtins
|
||||
@{
|
||||
|
||||
Some programs need global information for, e.g. counting or collecting
|
||||
data obtained by backtracking. As a rule, to keep this information, the
|
||||
internal data base should be used instead of asserting and retracting
|
||||
clauses (as most novice programmers do), .
|
||||
In YAP (as in some other Prolog systems) the internal data base (i.d.b.
|
||||
for short) is faster, needs less space and provides a better insulation of
|
||||
program and data than using asserted/retracted clauses.
|
||||
The i.d.b. is implemented as a set of terms, accessed by keys that
|
||||
unlikely what happens in (non-Prolog) data bases are not part of the
|
||||
term. Under each key a list of terms is kept. References are provided so that
|
||||
terms can be identified: each term in the i.d.b. has a unique reference
|
||||
(references are also available for clauses of dynamic predicates).
|
||||
|
||||
There is a strong analogy between the i.d.b. and the way dynamic
|
||||
predicates are stored. In fact, the main i.d.b. predicates might be
|
||||
implemented using dynamic predicates:
|
||||
|
||||
~~~~~
|
||||
recorda(X,T,R) :- asserta(idb(X,T),R).
|
||||
recordz(X,T,R) :- assertz(idb(X,T),R).
|
||||
recorded(X,T,R) :- clause(idb(X,T),R).
|
||||
~~~~~
|
||||
We can take advantage of this, the other way around, as it is quite
|
||||
easy to write a simple Prolog interpreter, using the i.d.b.:
|
||||
|
||||
~~~~~
|
||||
asserta(G) :- recorda(interpreter,G,_).
|
||||
assertz(G) :- recordz(interpreter,G,_).
|
||||
retract(G) :- recorded(interpreter,G,R), !, erase(R).
|
||||
call(V) :- var(V), !, fail.
|
||||
call((H :- B)) :- !, recorded(interpreter,(H :- B),_), call(B).
|
||||
call(G) :- recorded(interpreter,G,_).
|
||||
~~~~~
|
||||
In YAP, much attention has been given to the implementation of the
|
||||
i.d.b., especially to the problem of accelerating the access to terms kept in
|
||||
a large list under the same key. Besides using the key, YAP uses an internal
|
||||
lookup function, transparent to the user, to find only the terms that might
|
||||
unify. For instance, in a data base containing the terms
|
||||
|
||||
~~~~~
|
||||
b
|
||||
b(a)
|
||||
c(d)
|
||||
e(g)
|
||||
b(X)
|
||||
e(h)
|
||||
~~~~~
|
||||
|
||||
stored under the key k/1, when executing the query
|
||||
|
||||
~~~~~
|
||||
:- recorded(k(_),c(_),R).
|
||||
~~~~~
|
||||
|
||||
`recorded` would proceed directly to the third term, spending almost the
|
||||
time as if `a(X)` or `b(X)` was being searched.
|
||||
The lookup function uses the functor of the term, and its first three
|
||||
arguments (when they exist). So, `recorded(k(_),e(h),_)` would go
|
||||
directly to the last term, while `recorded(k(_),e(_),_)` would find
|
||||
first the fourth term, and then, after backtracking, the last one.
|
||||
|
||||
This mechanism may be useful to implement a sort of hierarchy, where
|
||||
the functors of the terms (and eventually the first arguments) work as
|
||||
secondary keys.
|
||||
|
||||
In the YAP's i.d.b. an optimized representation is used for
|
||||
terms without free variables. This results in a faster retrieval of terms
|
||||
and better space usage. Whenever possible, avoid variables in terms in terms
|
||||
stored in the i.d.b.
|
||||
|
||||
|
||||
|
||||
*
|
||||
* @ingroup builtins
|
||||
* @{
|
||||
*
|
||||
* Some programs need global information for, e.g. counting or collecting
|
||||
* data obtained by backtracking. As a rule, to keep this information, the
|
||||
* internal data base should be used instead of asserting and retracting
|
||||
* clauses (as most novice programmers do), .
|
||||
* In YAP (as in some other Prolog systems) the internal data base (i.d.b.
|
||||
* for short) is faster, needs less space and provides a better insulation of
|
||||
* program and data than using asserted/retracted clauses.
|
||||
* The i.d.b. is implemented as a set of terms, accessed by keys that
|
||||
* unlikely what happens in (non-Prolog) data bases are not part of the
|
||||
* term. Under each key a list of terms is kept. References are provided so that
|
||||
* terms can be identified: each term in the i.d.b. has a unique reference
|
||||
* (references are also available for clauses of dynamic predicates).
|
||||
*
|
||||
* There is a strong analogy between the i.d.b. and the way dynamic
|
||||
* predicates are stored. In fact, the main i.d.b. predicates might be
|
||||
* implemented using dynamic predicates:
|
||||
*
|
||||
* ~~~~~
|
||||
* recorda(X,T,R) :- asserta(idb(X,T),R).
|
||||
* recordz(X,T,R) :- assertz(idb(X,T),R).
|
||||
* recorded(X,T,R) :- clause(idb(X,T),R).
|
||||
* ~~~~~
|
||||
* We can take advantage of this, the other way around, as it is quite
|
||||
* easy to write a simple Prolog interpreter, using the i.d.b.:
|
||||
*
|
||||
* ~~~~~
|
||||
* asserta(G) :- recorda(interpreter,G,_).
|
||||
* assertz(G) :- recordz(interpreter,G,_).
|
||||
* retract(G) :- recorded(interpreter,G,R), !, erase(R).
|
||||
* call(V) :- var(V), !, fail.
|
||||
* call((H :- B)) :- !, recorded(interpreter,(H :- B),_), call(B).
|
||||
* call(G) :- recorded(interpreter,G,_).
|
||||
* ~~~~~
|
||||
* In YAP, much attention has been given to the implementation of the
|
||||
* i.d.b., especially to the problem of accelerating the access to terms kept in
|
||||
* a large list under the same key. Besides using the key, YAP uses an internal
|
||||
* lookup function, transparent to the user, to find only the terms that might
|
||||
* unify. For instance, in a data base containing the terms
|
||||
*
|
||||
* ~~~~~
|
||||
* b
|
||||
* b(a)
|
||||
* c(d)
|
||||
* e(g)
|
||||
* b(X)
|
||||
* e(h)
|
||||
* ~~~~~
|
||||
*
|
||||
* stored under the key k/1, when executing the query
|
||||
*
|
||||
* ~~~~~
|
||||
* :- recorded(k(_),c(_),R).
|
||||
* ~~~~~
|
||||
*
|
||||
* `recorded` would proceed directly to the third term, spending almost the
|
||||
* time as if `a(X)` or `b(X)` was being searched.
|
||||
* The lookup function uses the functor of the term, and its first three
|
||||
* arguments (when they exist). So, `recorded(k(_),e(h),_)` would go
|
||||
* directly to the last term, while `recorded(k(_),e(_),_)` would find
|
||||
* first the fourth term, and then, after backtracking, the last one.
|
||||
*
|
||||
* This mechanism may be useful to implement a sort of hierarchy, where
|
||||
* the functors of the terms (and eventually the first arguments) work as
|
||||
* secondary keys.
|
||||
*
|
||||
* In the YAP's i.d.b. an optimized representation is used for
|
||||
* terms without free variables. This results in a faster retrieval of terms
|
||||
* and better space usage. Whenever possible, avoid variables in terms in terms
|
||||
* stored in the i.d.b.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Yap.h"
|
||||
|
159
C/errors.c
159
C/errors.c
@ -35,7 +35,7 @@
|
||||
|
||||
#define set_key_b(k, ks, q, i, t) \
|
||||
if (strcmp(ks, q) == 0) { \
|
||||
i->k = t == TermTrue ? true : false; \
|
||||
i->k = ( t == TermTrue ? true : false); \
|
||||
return i->k || t == TermFalse; \
|
||||
}
|
||||
|
||||
@ -67,20 +67,21 @@ static bool setErr(const char *q, yap_error_descriptor_t *i, Term t) {
|
||||
set_key_s(errorFunction, "errorFunction", q, i, t);
|
||||
set_key_s(errorFile, "errorFile", q, i, t);
|
||||
set_key_i(prologPredLine, "prologPredLine", q, i, t);
|
||||
set_key_i(prologPredFirstLine, "prologPredFirstLine", q, i, t);
|
||||
set_key_i(prologPredLastLine, "prologPredLastLine", q, i, t);
|
||||
set_key_s(prologPredName, "prologPredName", q, i, t);
|
||||
set_key_i(prologPredArity, "prologPredArity", q, i, t);
|
||||
set_key_s(prologPredModule, "prologPredModule", q, i, t);
|
||||
set_key_s(prologPredFile, "prologPredFile", q, i, t);
|
||||
set_key_i(prologParserPos, "prologParserPos", q, i, t);
|
||||
set_key_i(prologParserLine, "prologParserLine", q, i, t);
|
||||
set_key_i(prologParserFirstLine, "prologParserFirstLine", q, i, t);
|
||||
set_key_i(prologParserLastLine, "prologParserLastLine", q, i, t);
|
||||
set_key_s(prologParserText, "prologParserText", q, i, t);
|
||||
set_key_s(prologParserFile, "prologParserFile", q, i, t);
|
||||
set_key_i(parserPos, "parserPos", q, i, t);
|
||||
set_key_i(parserLine, "parserLine", q, i, t);
|
||||
set_key_i(parserFirstLine, "parserFirstLine", q, i, t);
|
||||
set_key_i(parserLastLine, "parserLastLine", q, i, t);
|
||||
set_key_s(parserTextA, "parserTextA", q, i, t);
|
||||
set_key_s(parserTextB, "parserTextB", q, i, t);
|
||||
set_key_s(parserFile, "parserFile", q, i, t);
|
||||
set_key_b(parserReadingCode, "parserReadingcode", q, i, t);
|
||||
set_key_b(prologConsulting, "prologConsulting", q, i, t);
|
||||
set_key_s(culprit, "culprit", q, i, t);
|
||||
set_key_s(prologStack, "prologStack", q, i, t);
|
||||
set_key_s(errorMsg, "errorMsg", q, i, t);
|
||||
set_key_i(errorMsgLen, "errorMsgLen", q, i, t);
|
||||
return false;
|
||||
@ -116,20 +117,21 @@ static Term queryErr(const char *q, yap_error_descriptor_t *i) {
|
||||
query_key_s(errorFunction, "errorFunction", q, i);
|
||||
query_key_s(errorFile, "errorFile", q, i);
|
||||
query_key_i(prologPredLine, "prologPredLine", q, i);
|
||||
query_key_i(prologPredFirstLine, "prologPredFirstLine", q, i);
|
||||
query_key_i(prologPredLastLine, "prologPredLastLine", q, i);
|
||||
query_key_s(prologPredName, "prologPredName", q, i);
|
||||
query_key_i(prologPredArity, "prologPredArity", q, i);
|
||||
query_key_s(prologPredModule, "prologPredModule", q, i);
|
||||
query_key_s(prologPredFile, "prologPredFile", q, i);
|
||||
query_key_i(prologParserPos, "prologParserPos", q, i);
|
||||
query_key_i(prologParserLine, "prologParserLine", q, i);
|
||||
query_key_i(prologParserFirstLine, "prologParserFirstLine", q, i);
|
||||
query_key_i(prologParserLastLine, "prologParserLastLine", q, i);
|
||||
query_key_s(prologParserText, "prologParserText", q, i);
|
||||
query_key_s(prologParserFile, "prologParserFile", q, i);
|
||||
query_key_i(parserPos, "parserPos", q, i);
|
||||
query_key_i(parserLine, "parserLine", q, i);
|
||||
query_key_i(parserFirstLine, "parserFirstLine", q, i);
|
||||
query_key_i(parserLastLine, "parserLastLine", q, i);
|
||||
query_key_s(parserTextA, "parserTextA", q, i);
|
||||
query_key_s(parserTextB, "parserTextB", q, i);
|
||||
query_key_s(parserFile, "parserFile", q, i);
|
||||
query_key_b(parserReadingCode, "parserReadingCode", q, i);
|
||||
query_key_b(prologConsulting, "prologConsulting", q, i);
|
||||
query_key_t(culprit, "culprit", q, i);
|
||||
query_key_s(prologStack, "prologStack", q, i);
|
||||
query_key_s(culprit, "culprit", q, i);
|
||||
query_key_s(errorMsg, "errorMsg", q, i);
|
||||
query_key_i(errorMsgLen, "errorMsgLen", q, i);
|
||||
return TermNil;
|
||||
@ -162,20 +164,21 @@ static void printErr(yap_error_descriptor_t *i) {
|
||||
print_key_s("errorFunction", i->errorFunction);
|
||||
print_key_s("errorFile", i->errorFile);
|
||||
print_key_i("prologPredLine", i->prologPredLine);
|
||||
print_key_i("prologPredFirstLine", i->prologPredFirstLine);
|
||||
print_key_i("prologPredLastLine", i->prologPredLastLine);
|
||||
print_key_s("prologPredName", i->prologPredName);
|
||||
print_key_i("prologPredArity", i->prologPredArity);
|
||||
print_key_s("prologPredModule", i->prologPredModule);
|
||||
print_key_s("prologPredFile", i->prologPredFile);
|
||||
print_key_i("prologParserPos", i->prologParserPos);
|
||||
print_key_i("prologParserLine", i->prologParserLine);
|
||||
print_key_i("prologParserFirstLine", i->prologParserFirstLine);
|
||||
print_key_i("prologParserLastLine", i->prologParserLastLine);
|
||||
print_key_s("prologParserText", i->prologParserText);
|
||||
print_key_s("prologParserFile", i->prologParserFile);
|
||||
print_key_i("parserPos", i->parserPos);
|
||||
print_key_i("parserLine", i->parserLine);
|
||||
print_key_i("parserFirstLine", i->parserFirstLine);
|
||||
print_key_i("parserLastLine", i->parserLastLine);
|
||||
print_key_s("parserTextA", i->parserTextA);
|
||||
print_key_s("parserTextB", i->parserTextB);
|
||||
print_key_s("parserFile", i->parserFile);
|
||||
print_key_b("parserReadingCode", i->parserReadingCode);
|
||||
print_key_b("prologConsulting", i->prologConsulting);
|
||||
print_key_s("culprit", i->culprit);
|
||||
print_key_s("prologStack", i->prologStack);
|
||||
if (i->errorMsgLen) {
|
||||
print_key_s("errorMsg", i->errorMsg);
|
||||
print_key_i("errorMsgLen", i->errorMsgLen);
|
||||
@ -220,20 +223,21 @@ static Term err2list(yap_error_descriptor_t *i) {
|
||||
o = add_key_s("errorFunction", i->errorFunction, o);
|
||||
o = add_key_s("errorFile", i->errorFile, o);
|
||||
o = add_key_i("prologPredLine", i->prologPredLine, o);
|
||||
o = add_key_i("prologPredFirstLine", i->prologPredFirstLine, o);
|
||||
o = add_key_i("prologPredLastLine", i->prologPredLastLine, o);
|
||||
o = add_key_s("prologPredName", i->prologPredName, o);
|
||||
o = add_key_i("prologPredArity", i->prologPredArity, o);
|
||||
o = add_key_s("prologPredModule", i->prologPredModule, o);
|
||||
o = add_key_s("prologPredFile", i->prologPredFile, o);
|
||||
o = add_key_i("prologParserPos", i->prologParserPos, o);
|
||||
o = add_key_i("prologParserLine", i->prologParserLine, o);
|
||||
o = add_key_i("prologParserFirstLine", i->prologParserFirstLine, o);
|
||||
o = add_key_i("prologParserLastLine", i->prologParserLastLine, o);
|
||||
o = add_key_s("prologParserText", i->prologParserText, o);
|
||||
o = add_key_s("prologParserFile", i->prologParserFile, o);
|
||||
o = add_key_i("parserPos", i->parserPos, o);
|
||||
o = add_key_i("parserLine", i->parserLine, o);
|
||||
o = add_key_i("parserFirstLine", i->parserFirstLine, o);
|
||||
o = add_key_i("parserLastLine", i->parserLastLine, o);
|
||||
o = add_key_s("parserTextA", i->parserTextA, o);
|
||||
o = add_key_s("parserTextB", i->parserTextB, o);
|
||||
o = add_key_s("parserFile", i->parserFile, o);
|
||||
o = add_key_b("parserReadingCode", i->parserReadingCode, o);
|
||||
o = add_key_b("prologConsulting", i->prologConsulting, o);
|
||||
o = add_key_s("culprit", i->culprit, o);
|
||||
o = add_key_s("prologStack", i->prologStack, o);
|
||||
if (i->errorMsgLen) {
|
||||
o = add_key_s("errorMsg", i->errorMsg, o);
|
||||
o = add_key_i("errorMsgLen", i->errorMsgLen, o);
|
||||
@ -317,7 +321,7 @@ void Yap_InitError__(const char *file, const char *function, int lineno,
|
||||
if (fmt) {
|
||||
LOCAL_Error_Size = strlen(tmpbuf);
|
||||
LOCAL_ActiveError->errorMsg = malloc(LOCAL_Error_Size + 1);
|
||||
strcpy(LOCAL_ActiveError->errorMsg, tmpbuf);
|
||||
strcpy((char *)LOCAL_ActiveError->errorMsg, tmpbuf);
|
||||
} else {
|
||||
LOCAL_Error_Size = 0;
|
||||
}
|
||||
@ -328,12 +332,13 @@ bool Yap_PrintWarning(Term twarning) {
|
||||
PredEntry *pred = RepPredProp(PredPropByFunc(
|
||||
FunctorPrintMessage, PROLOG_MODULE)); // PROCEDURE_print_message2;
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid ", " warning(%s)",
|
||||
Yap_TermToBuffer(twarning, Quote_illegal_f | Ignore_ops_f | Unfold_cyclics_f));
|
||||
Yap_TermToBuffer(twarning, Quote_illegal_f | Ignore_ops_f | Ignore_cyclics_f));
|
||||
Term cmod = (CurrentModule == PROLOG_MODULE ? TermProlog : CurrentModule);
|
||||
bool rc;
|
||||
Term ts[2], err;
|
||||
|
||||
if (LOCAL_PrologMode & InErrorMode && LOCAL_ActiveError &&
|
||||
LOCAL_ActiveError->errorClass != WARNING &&
|
||||
(err = LOCAL_ActiveError->errorNo)) {
|
||||
fprintf(stderr, "%% Warning %s while processing error: %s %s\n",
|
||||
Yap_TermToBuffer(twarning,
|
||||
@ -343,9 +348,10 @@ bool Yap_PrintWarning(Term twarning) {
|
||||
}
|
||||
LOCAL_PrologMode |= InErrorMode;
|
||||
if (pred->OpcodeOfPred == UNDEF_OPCODE || pred->OpcodeOfPred == FAIL_OPCODE) {
|
||||
fprintf(stderr, "warning message:\n");
|
||||
Yap_DebugPlWrite(twarning);
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "%s:%ld/* d:%d warning */:\n",
|
||||
LOCAL_ActiveError->errorFile,
|
||||
LOCAL_ActiveError->errorLine, 0 );
|
||||
Yap_DebugPlWriteln(twarning);
|
||||
LOCAL_DoingUndefp = false;
|
||||
LOCAL_PrologMode &= ~InErrorMode;
|
||||
CurrentModule = cmod;
|
||||
@ -423,9 +429,7 @@ int Yap_SWIHandleError(const char *s, ...) {
|
||||
yap_error_number err = LOCAL_Error_TYPE;
|
||||
char *serr;
|
||||
|
||||
if (LOCAL_ErrorMessage) {
|
||||
serr = LOCAL_ErrorMessage;
|
||||
} else {
|
||||
if (s) {
|
||||
serr = (char *)s;
|
||||
}
|
||||
switch (err) {
|
||||
@ -524,6 +528,7 @@ static char tmpbuf[YAP_BUF_SIZE];
|
||||
|
||||
#define BEGIN_ERRORS() \
|
||||
static Term mkerrort(yap_error_number e, Term culprit, Term info) { \
|
||||
if (!e || !info) return TermNil; \
|
||||
switch (e) {
|
||||
|
||||
#define E0(A, B) \
|
||||
@ -574,8 +579,11 @@ static char tmpbuf[YAP_BUF_SIZE];
|
||||
|
||||
#include "YapErrors.h"
|
||||
|
||||
bool Yap_pushErrorContext(bool pass, yap_error_descriptor_t *new_error) {
|
||||
/// add a new error descriptor, either to the top of the stack,
|
||||
/// or replacing the top;
|
||||
bool Yap_pushErrorContext(bool link , yap_error_descriptor_t *new_error) {
|
||||
memset(new_error, 0, sizeof(yap_error_descriptor_t));
|
||||
if (link)
|
||||
new_error->top_error = LOCAL_ActiveError;
|
||||
LOCAL_ActiveError = new_error;
|
||||
return true;
|
||||
@ -625,7 +633,7 @@ void Yap_ThrowError__(const char *file, const char *function, int lineno,
|
||||
// fprintf(stderr, "warning: ");
|
||||
Yap_Error__(true, file, function, lineno, type, where, tmpbuf);
|
||||
} else {
|
||||
Yap_Error__(true, file, function, lineno, type, where);
|
||||
Yap_Error__(true, file, function, lineno, type, where, NULL);
|
||||
}
|
||||
if (LOCAL_RestartEnv && !LOCAL_delay) {
|
||||
Yap_RestartYap(5);
|
||||
@ -644,6 +652,16 @@ void Yap_ThrowExistingError(void) {
|
||||
Yap_exit(5);
|
||||
}
|
||||
|
||||
Term Yap_MkFullError(void)
|
||||
{
|
||||
yap_error_descriptor_t *i = Yap_local.ActiveError;
|
||||
i->errorAsText = Yap_errorName( i->errorNo );
|
||||
i->errorClass = Yap_errorClass( i-> errorNo );
|
||||
i->classAsText = Yap_errorClassName(i->errorClass);
|
||||
return mkerrort(i->errorNo, TermNil , MkSysError(i) );
|
||||
}
|
||||
|
||||
|
||||
bool Yap_MkErrorRecord(yap_error_descriptor_t *r, const char *file,
|
||||
const char *function, int lineno, yap_error_number type,
|
||||
Term where, const char *s) {
|
||||
@ -655,9 +673,9 @@ bool Yap_MkErrorRecord(yap_error_descriptor_t *r, const char *file,
|
||||
r->culprit = Yap_TermToBuffer(
|
||||
where, Quote_illegal_f | Ignore_ops_f);
|
||||
}
|
||||
if (LOCAL_consult_level > 0) {
|
||||
r->prologParserFile = Yap_ConsultingFile(PASS_REGS1)->StrOfAE;
|
||||
r->prologParserLine = Yap_source_line_no();
|
||||
if (type != SYNTAX_ERROR && LOCAL_consult_level > 0) {
|
||||
r->parserFile = Yap_ConsultingFile(PASS_REGS1)->StrOfAE;
|
||||
r->parserLine = Yap_source_line_no();
|
||||
}
|
||||
r->errorNo = type;
|
||||
r->errorAsText = Yap_errorName(type);
|
||||
@ -666,9 +684,11 @@ bool Yap_MkErrorRecord(yap_error_descriptor_t *r, const char *file,
|
||||
r->errorLine = lineno;
|
||||
r->errorFunction = function;
|
||||
r->errorFile = file;
|
||||
r->prologConsulting = Yap_Consulting();
|
||||
LOCAL_PrologMode |= InErrorMode;
|
||||
Yap_ClearExs();
|
||||
// first, obtain current location
|
||||
|
||||
// sprintf(LOCAL_FileNameBuf, "%s:%d in C-function %s ", file, lineno,
|
||||
// function);
|
||||
// tf = MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf));
|
||||
@ -693,13 +713,11 @@ bool Yap_MkErrorRecord(yap_error_descriptor_t *r, const char *file,
|
||||
}
|
||||
// fprintf(stderr, "warning: ");
|
||||
if (s && s[0]) {
|
||||
char *ns;
|
||||
r->errorMsgLen = strlen(s) + 1;
|
||||
r->errorMsg = malloc(r->errorMsgLen);
|
||||
strcpy(r->errorMsg, s);
|
||||
} else if (LOCAL_ErrorMessage && LOCAL_ErrorMessage[0]) {
|
||||
r->errorMsgLen = strlen(LOCAL_ErrorMessage) + 1;
|
||||
r->errorMsg = malloc(r->errorMsgLen);
|
||||
strcpy(r->errorMsg, LOCAL_ErrorMessage);
|
||||
ns = malloc(r->errorMsgLen);
|
||||
strcpy(ns, s);
|
||||
r->errorMsg = ns;
|
||||
} else {
|
||||
r->errorMsgLen = 0;
|
||||
r->errorMsg = 0;
|
||||
@ -845,7 +863,8 @@ yamop *Yap_Error__(bool throw, const char *file, const char *function,
|
||||
#ifdef DEBUG
|
||||
// DumpActiveGoals( USES_REGS1 );
|
||||
#endif /* DEBUG */
|
||||
|
||||
if (LOCAL_ActiveError->errorNo!= SYNTAX_ERROR)
|
||||
LOCAL_ActiveError->prologStack=Yap_dump_stack();
|
||||
CalculateStackGap(PASS_REGS1);
|
||||
#if DEBUG
|
||||
// DumpActiveGoals( PASS_REGS1 );
|
||||
@ -1022,7 +1041,27 @@ static Int print_exception(USES_REGS1) {
|
||||
|
||||
|
||||
static Int query_exception(USES_REGS1) {
|
||||
const char *query;
|
||||
const char *query = NULL;
|
||||
Term t;
|
||||
|
||||
if (IsAtomTerm((t = Deref(ARG1))))
|
||||
query = RepAtom(AtomOfTerm(t))->StrOfAE;
|
||||
if (IsStringTerm(t))
|
||||
query = StringOfTerm(t);
|
||||
if (!IsAddressTerm(Deref(ARG2)))
|
||||
return false;
|
||||
yap_error_descriptor_t *y = AddressOfTerm(Deref(ARG2));
|
||||
// if (IsVarTerm(t3)) {
|
||||
Term rc = queryErr(query, y);
|
||||
// Yap_DebugPlWriteln(rc);
|
||||
return Yap_unify(ARG3, rc);
|
||||
// } else {
|
||||
// return setErr(query, y, t3);
|
||||
// }
|
||||
}
|
||||
|
||||
static Int set_exception(USES_REGS1) {
|
||||
const char *query = NULL;
|
||||
Term t;
|
||||
|
||||
if (IsAtomTerm((t = Deref(ARG1))))
|
||||
@ -1034,15 +1073,14 @@ static Int query_exception(USES_REGS1) {
|
||||
yap_error_descriptor_t *y = AddressOfTerm(Deref(ARG2));
|
||||
Term t3 = Deref(ARG3);
|
||||
if (IsVarTerm(t3)) {
|
||||
Term rc = queryErr(query, y);
|
||||
// Yap_DebugPlWriteln(rc);
|
||||
return Yap_unify(ARG3, rc);
|
||||
return false;
|
||||
} else {
|
||||
return setErr(query, y, t3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static Int drop_exception(USES_REGS1) {
|
||||
yap_error_descriptor_t *t = AddressOfTerm(Deref(ARG1));
|
||||
free(t);
|
||||
@ -1066,7 +1104,9 @@ static Int get_exception(USES_REGS1) {
|
||||
(i->errorClass == EVENT || i->errorNo == SYNTAX_ERROR)) {
|
||||
t = i->errorRawTerm;
|
||||
} else if (i->culprit != NULL) {
|
||||
t = mkerrort(i->errorNo, Yap_BufferToTerm(i->culprit, TermNil),
|
||||
Term culprit = Yap_BufferToTerm(i->culprit, TermNil);
|
||||
if (culprit == 0) culprit = TermNil;
|
||||
t = mkerrort(i->errorNo,culprit ,
|
||||
MkSysError(i));
|
||||
} else {
|
||||
t = mkerrort(i->errorNo, TermNil, MkSysError(i));
|
||||
@ -1251,6 +1291,7 @@ void Yap_InitErrorPreds(void) {
|
||||
Yap_InitCPred("$reset_exception", 1, reset_exception, 0);
|
||||
Yap_InitCPred("$new_exception", 1, new_exception, 0);
|
||||
Yap_InitCPred("$get_exception", 1, get_exception, 0);
|
||||
Yap_InitCPred("$set_exception", 3, set_exception, 0);
|
||||
Yap_InitCPred("$read_exception", 2, read_exception, 0);
|
||||
Yap_InitCPred("$query_exception", 3, query_exception, 0);
|
||||
Yap_InitCPred("$drop_exception", 1, drop_exception, 0);
|
||||
|
2
C/exec.c
2
C/exec.c
@ -327,7 +327,7 @@ inline static bool do_execute(Term t, Term mod USES_REGS) {
|
||||
/* I cannot use the standard macro here because
|
||||
otherwise I would dereference the argument and
|
||||
might skip a svar */
|
||||
if (pen->PredFlags & (MetaPredFlag | UndefPredFlag)) {
|
||||
if (pen->PredFlags & (MetaPredFlag | UndefPredFlag | SpiedPredFlag)) {
|
||||
return CallMetaCall(t0, mod0 PASS_REGS);
|
||||
}
|
||||
pt = RepAppl(t) + 1;
|
||||
|
15
C/flags.c
15
C/flags.c
@ -25,10 +25,12 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
@{
|
||||
@defgroup YAPFlags_Impl C-code to handle Prolog flags.
|
||||
|
||||
@defgroup YAPFlags C-code to handle Prolog flags.
|
||||
@ingroup YAPFlags
|
||||
|
||||
@{
|
||||
|
||||
@brief Low-level code to support flags.
|
||||
|
||||
Prolog Flags can be:
|
||||
@ -1208,6 +1210,7 @@ Term Yap_UnknownFlag(Term mod) {
|
||||
Term getYapFlag(Term tflag) {
|
||||
FlagEntry *fv;
|
||||
flag_term *tarr;
|
||||
tflag = Deref(tflag);
|
||||
if (IsVarTerm(tflag)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, tflag, "yap_flag/2");
|
||||
return (FALSE);
|
||||
@ -1234,6 +1237,10 @@ Term getYapFlag(Term tflag) {
|
||||
Yap_Error(TYPE_ERROR_ATOM, tflag, "yap_flag/2");
|
||||
return (FALSE);
|
||||
}
|
||||
if (tflag == TermSilent)
|
||||
{
|
||||
Yap_DebugPlWriteln(TermSilent);
|
||||
}
|
||||
fv = GetFlagProp(AtomOfTerm(tflag));
|
||||
if (!fv) {
|
||||
Term fl = GLOBAL_Flags[USER_FLAGS_FLAG].at;
|
||||
@ -1792,10 +1799,6 @@ void Yap_InitFlags(bool bootstrap) {
|
||||
Yap_InitCPredBack("current_prolog_flag", 2, 1, current_prolog_flag,
|
||||
cont_yap_flag, 0);
|
||||
TR = tr0;
|
||||
/** @pred prolog_flag( ?Flag, - Value)
|
||||
|
||||
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("yap_flag", 3, 1, yap_flag, cont_yap_flag, 0);
|
||||
|
@ -623,6 +623,10 @@
|
||||
|
||||
BOp(undef_p, e);
|
||||
/* save S for module name */
|
||||
if (LOCAL_DoingUndefp) {
|
||||
PREG=FAILCODE;
|
||||
JMPNext();
|
||||
}
|
||||
LOCAL_DoingUndefp = true;
|
||||
saveregs();
|
||||
undef_goal(PASS_REGS1);
|
||||
|
76
C/gprof.c
76
C/gprof.c
@ -35,7 +35,7 @@
|
||||
* Revision 1.3 2006/01/17 14:10:40 vsc
|
||||
* YENV may be an HW register (breaks some tabling code)
|
||||
* All YAAM instructions are now brackedted, so Op introduced an { and EndOp introduces an }. This is because Ricardo assumes that.
|
||||
* Fix attvars when COROUTING is undefined.
|
||||
* Fix attvars
|
||||
*
|
||||
* Revision 1.2 2005/12/23 00:20:13 vsc
|
||||
* updates to gprof
|
||||
@ -47,39 +47,39 @@
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/// @file gprof.c
|
||||
|
||||
/** @defgroup Tick_Profiler Tick Profiler
|
||||
@ingroup Profiling
|
||||
@{
|
||||
|
||||
The tick profiler works by interrupting the Prolog code every so often
|
||||
and checking at each point the code was. The profiler must be able to
|
||||
retrace the state of the abstract machine at every moment. The major
|
||||
advantage of this approach is that it gives the actual amount of time
|
||||
being spent per procedure, or whether garbage collection dominates
|
||||
execution time. The major drawback is that tracking down the state of
|
||||
the abstract machine may take significant time, and in the worst case
|
||||
may slow down the whole execution.
|
||||
|
||||
The following procedures are available:
|
||||
|
||||
+ profinit
|
||||
|
||||
|
||||
Initialise the data-structures for the profiler. Unnecessary for
|
||||
dynamic profiler.
|
||||
|
||||
+ profon
|
||||
|
||||
|
||||
Start profiling.
|
||||
|
||||
+ profoff
|
||||
|
||||
|
||||
Stop profiling.
|
||||
|
||||
|
||||
/** @addtogroup Tick_Profiler
|
||||
* @ingroup Profiling@{
|
||||
*
|
||||
* The tick profiler works by interrupting the Prolog code every so often
|
||||
* and checking at each point the code was. The pro/filer must be able to
|
||||
* retrace the state of the abstract machine at every moment. The major
|
||||
* advantage of this approach is that it gives the actual amount of time
|
||||
* being spent per procedure, or whether garbage collection dominates
|
||||
* execution time. The major drawback is that tracking down the state of
|
||||
* the abstract machine may take significant time, and in the worst case
|
||||
* may slow down the whole execution.
|
||||
*
|
||||
* The following procedures are available:
|
||||
*
|
||||
* + profinit/0
|
||||
* Initialise the data-structures for the profiler. Unnecessary for
|
||||
* dynamic profiler.
|
||||
*
|
||||
* + profon/0
|
||||
* Start profiling.
|
||||
*
|
||||
* + profoff/0
|
||||
* Stop profiling.
|
||||
*
|
||||
* + profoff/0
|
||||
* Stop profiling.
|
||||
*
|
||||
* + showprofres/0 and showprofres/1
|
||||
* Stop tick counts per predicate.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef SCCS
|
||||
@ -728,20 +728,18 @@ return GLOBAL_DIRNAME;
|
||||
|
||||
char *profile_names(int);
|
||||
char *profile_names(int k) {
|
||||
static char *FNAME=NULL;
|
||||
char *FNAME=NULL;
|
||||
int size=200;
|
||||
|
||||
if (GLOBAL_DIRNAME==NULL) set_profile_dir(NULL);
|
||||
size=strlen(GLOBAL_DIRNAME)+40;
|
||||
if (FNAME!=NULL) free(FNAME);
|
||||
FNAME=malloc(size);
|
||||
if (FNAME==NULL) { printf("Profiler Out of Mem\n"); exit(1); }
|
||||
strcpy(FNAME,GLOBAL_DIRNAME);
|
||||
|
||||
if (k==PROFILING_FILE) {
|
||||
sprintf(FNAME,"%s/PROFILING_%d",FNAME,getpid());
|
||||
sprintf(FNAME,"%s/PROFILING_%d",GLOBAL_DIRNAME,getpid());
|
||||
} else {
|
||||
sprintf(FNAME,"%s/PROFPREDS_%d",FNAME,getpid());
|
||||
sprintf(FNAME,"%s/PROFPREDS_%d",GLOBAL_DIRNAME,getpid());
|
||||
}
|
||||
|
||||
// printf("%s\n",FNAME);
|
||||
@ -841,7 +839,7 @@ static void RemoveCode(CODEADDR clau)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
static Int
|
||||
showprofres( USES_REGS1 ) {
|
||||
buf_ptr buf;
|
||||
|
||||
|
19
C/parser.c
19
C/parser.c
@ -60,12 +60,12 @@ static void syntax_msg(const char *msg, ...) {
|
||||
va_list ap;
|
||||
if (!LOCAL_ErrorMessage ||
|
||||
(LOCAL_Error_TYPE == SYNTAX_ERROR &&
|
||||
LOCAL_tokptr->TokPos < LOCAL_ActiveError->prologParserPos)) {
|
||||
LOCAL_tokptr->TokPos < LOCAL_ActiveError->parserPos)) {
|
||||
if (!LOCAL_ErrorMessage) {
|
||||
LOCAL_ErrorMessage = malloc(MAX_ERROR_MSG_SIZE + 1);
|
||||
}
|
||||
LOCAL_ActiveError->prologParserLine = LOCAL_tokptr->TokLine;
|
||||
LOCAL_ActiveError->prologParserPos = LOCAL_tokptr->TokPos;
|
||||
LOCAL_ActiveError->parserLine = LOCAL_tokptr->TokLine;
|
||||
LOCAL_ActiveError->parserPos = LOCAL_tokptr->TokPos;
|
||||
va_start(ap, msg);
|
||||
vsnprintf(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, msg, ap);
|
||||
va_end(ap);
|
||||
@ -911,12 +911,17 @@ Term Yap_Parse(UInt prio, encoding_t enc, Term cmod) {
|
||||
CACHE_REGS
|
||||
// ensure that if we throw an exception
|
||||
// t will be 0.
|
||||
LOCAL_ActiveError->errorMsg=NULL;
|
||||
LOCAL_ActiveError->errorMsgLen=0;
|
||||
Volatile Term t = 0;
|
||||
JMPBUFF FailBuff;
|
||||
yhandle_t sls = Yap_StartSlots();
|
||||
LOCAL_ErrorMessage = NULL;
|
||||
LOCAL_toktide = LOCAL_tokptr;
|
||||
|
||||
if (!sigsetjmp(FailBuff.JmpBuff, 0)) {
|
||||
LOCAL_ActiveError->errorMsg=NULL;
|
||||
LOCAL_ActiveError->errorMsgLen=0;
|
||||
|
||||
t = ParseTerm(prio, &FailBuff, enc, cmod PASS_REGS);
|
||||
#if DEBUG
|
||||
@ -936,9 +941,13 @@ Term Yap_Parse(UInt prio, encoding_t enc, Term cmod) {
|
||||
if (LOCAL_tokptr != NULL && LOCAL_tokptr->Tok != Ord(eot_tok)) {
|
||||
LOCAL_Error_TYPE = SYNTAX_ERROR;
|
||||
if (LOCAL_tokptr->TokNext) {
|
||||
LOCAL_ErrorMessage = "bracket or operator expected.";
|
||||
size_t sz = strlen("bracket or operator expected.");
|
||||
LOCAL_ErrorMessage =malloc(sz+1);
|
||||
strncpy(LOCAL_ErrorMessage, "bracket or operator expected.", sz );
|
||||
} else {
|
||||
LOCAL_ErrorMessage = "term must end with . or EOF.";
|
||||
size_t sz = strlen("term must end with . or EOF.");
|
||||
LOCAL_ErrorMessage =malloc(sz+1);
|
||||
strncpy(LOCAL_ErrorMessage,"term must end with . or EOF.", sz );
|
||||
}
|
||||
t = 0;
|
||||
}
|
||||
|
1
C/save.c
1
C/save.c
@ -1469,6 +1469,7 @@ int Yap_SavedInfo(const char *FileName, CELL *ATrail,
|
||||
mode = OpenRestore(FileName, &MyState, &MyTrail, &MyStack, &MyHeap,
|
||||
NULL);
|
||||
if (mode == FAIL_RESTORE) {
|
||||
fprintf(stderr, "restore failed to open %s as a valid state\n", FileName);
|
||||
return -1;
|
||||
}
|
||||
close_file();
|
||||
|
13
C/scanner.c
13
C/scanner.c
@ -1340,7 +1340,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *st, bool store_comments,
|
||||
TokEntry *t, *l, *p;
|
||||
enum TokenKinds kind;
|
||||
int solo_flag = TRUE;
|
||||
int32_t ch, och;
|
||||
int32_t ch, och = ' ';
|
||||
struct qq_struct_t *cur_qq = NULL;
|
||||
int sign = 1;
|
||||
|
||||
@ -1423,12 +1423,13 @@ TokEntry *Yap_tokenizer(struct stream_desc *st, bool store_comments,
|
||||
|
||||
case UC:
|
||||
case UL:
|
||||
case LC: {
|
||||
int32_t och = ch;
|
||||
case LC:
|
||||
och = ch;
|
||||
ch = getchr(st);
|
||||
size_t sz = 512;
|
||||
TokImage = Malloc(sz PASS_REGS);
|
||||
scan_name:
|
||||
{
|
||||
size_t sz = 1024;
|
||||
TokImage = Malloc(sz PASS_REGS);
|
||||
charp = (unsigned char *)TokImage;
|
||||
isvar = (chtype(och) != LC);
|
||||
add_ch_to_buff(och);
|
||||
@ -1514,7 +1515,6 @@ TokEntry *Yap_tokenizer(struct stream_desc *st, bool store_comments,
|
||||
case 'e':
|
||||
case 'E':
|
||||
och = cherr;
|
||||
TokImage = Malloc(1024 PASS_REGS);
|
||||
goto scan_name;
|
||||
break;
|
||||
case '=':
|
||||
@ -1981,6 +1981,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *st, bool store_comments,
|
||||
return l;
|
||||
|
||||
default: {
|
||||
kind = Error_tok;
|
||||
char err[1024];
|
||||
snprintf(err, 1023, "\n++++ token: unrecognised char %c (%d), type %c\n",
|
||||
ch, ch, chtype(ch));
|
||||
|
224
C/stack.c
224
C/stack.c
@ -105,6 +105,8 @@ restart:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
extern char * Yap_output_bug_location(yamop *yap_pc, int where_from, int psize);
|
||||
|
||||
static PredEntry *PredForChoicePt(yamop *p_code, op_numbers *opn) {
|
||||
while (TRUE) {
|
||||
op_numbers opnum;
|
||||
@ -885,7 +887,7 @@ static PredEntry *ClauseInfoForCode(yamop *codeptr, void **startp,
|
||||
if (codeptr >= COMMA_CODE && codeptr < FAILCODE) {
|
||||
pp = RepPredProp(Yap_GetPredPropByFunc(FunctorComma, CurrentModule));
|
||||
*startp = (CODEADDR)COMMA_CODE;
|
||||
*endp = (CODEADDR)(FAILCODE - 1);
|
||||
*endp = (CODEADDR)(FAILCODE);
|
||||
return pp;
|
||||
}
|
||||
pc = codeptr;
|
||||
@ -1124,7 +1126,7 @@ static Term clause_info(yamop *codeptr, PredEntry *pp) {
|
||||
yap_error_descriptor_t *set_clause_info(yap_error_descriptor_t *t,
|
||||
yamop *codeptr, PredEntry *pp) {
|
||||
CACHE_REGS
|
||||
Term ts[2];
|
||||
|
||||
void *begin;
|
||||
if (pp->ArityOfPE == 0) {
|
||||
t->prologPredName = AtomName((Atom)pp->FunctorOfPred);
|
||||
@ -1138,36 +1140,18 @@ yap_error_descriptor_t *set_clause_info(yap_error_descriptor_t *t,
|
||||
: "prolog");
|
||||
t->prologPredFile = RepAtom(pp->src.OwnerFile)->StrOfAE;
|
||||
if (codeptr->opc == UNDEF_OPCODE) {
|
||||
t->prologPredFirstLine = 0;
|
||||
t->prologPredLine = 0;
|
||||
t->prologPredLastLine = 0;
|
||||
return t;
|
||||
} else if (pp->cs.p_code.NOfClauses) {
|
||||
if ((t->prologPredCl = find_code_in_clause(pp, codeptr, &begin, NULL)) <=
|
||||
if ((t->prologPredLine = find_code_in_clause(pp, codeptr, &begin, NULL)) <=
|
||||
0) {
|
||||
t->prologPredLine = 0;
|
||||
} else {
|
||||
t->prologPredLine = IntegerOfTerm(clause_loc(begin, pp));
|
||||
}
|
||||
if (pp->PredFlags & LogUpdatePredFlag) {
|
||||
t->prologPredFirstLine =
|
||||
clause_loc(ClauseCodeToLogUpdClause(pp->cs.p_code.FirstClause), pp);
|
||||
t->prologPredLastLine =
|
||||
clause_loc(ClauseCodeToLogUpdClause(pp->cs.p_code.LastClause), pp);
|
||||
|
||||
} else {
|
||||
t->prologPredFirstLine = IntegerOfTerm(
|
||||
ts[0] = clause_loc(
|
||||
ClauseCodeToStaticClause(pp->cs.p_code.FirstClause), pp));
|
||||
t->prologPredLastLine = IntegerOfTerm(
|
||||
ts[1] = clause_loc(ClauseCodeToStaticClause(pp->cs.p_code.LastClause),
|
||||
pp));
|
||||
}
|
||||
return t;
|
||||
} else {
|
||||
t->prologPredFirstLine = 0;
|
||||
t->prologPredLine = t->errorLine;
|
||||
t->prologPredLastLine = 0;
|
||||
t->prologPredFile = t->errorFile;
|
||||
return t;
|
||||
}
|
||||
@ -1720,8 +1704,6 @@ parent_pred(USES_REGS1) {
|
||||
Yap_unify(ARG2, MkAtomTerm(at)) && Yap_unify(ARG3, MkIntTerm(arity));
|
||||
}
|
||||
|
||||
void Yap_dump_stack(void);
|
||||
|
||||
void DumpActiveGoals(CACHE_TYPE1);
|
||||
|
||||
static int hidden(Atom);
|
||||
@ -1763,6 +1745,7 @@ static int legal_env(CELL *ep USES_REGS) {
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static bool handled_exception(USES_REGS1) {
|
||||
yamop *pos = NEXTOP(PredDollarCatch->cs.p_code.TrueCodeOfPred, l);
|
||||
bool found_handler = false;
|
||||
@ -1785,173 +1768,193 @@ static bool handled_exception(USES_REGS1) {
|
||||
return !found_handler;
|
||||
}
|
||||
|
||||
void Yap_dump_stack(void) {
|
||||
#endif
|
||||
|
||||
#define ADDBUF( CMD ) { \
|
||||
while (true) { \
|
||||
size_t sz = CMD; \
|
||||
if (sz < lbufsz-256) { \
|
||||
lbuf += sz; \
|
||||
lbufsz -= sz; \
|
||||
break; \
|
||||
} \
|
||||
char *nbuf = Realloc(buf, bufsize += 1024); \
|
||||
lbuf = nbuf + (lbuf-buf); \
|
||||
buf = nbuf; \
|
||||
lbufsz += 1024; \
|
||||
} \
|
||||
}
|
||||
|
||||
const char *Yap_dump_stack(void) {
|
||||
CACHE_REGS
|
||||
choiceptr b_ptr = B;
|
||||
CELL *env_ptr = ENV;
|
||||
char tp[256];
|
||||
char *tp;
|
||||
yamop *ipc = CP;
|
||||
int max_count = 200;
|
||||
|
||||
int lvl = push_text_stack();
|
||||
char *buf = Malloc(4096), *lbuf = buf;
|
||||
size_t bufsize = 4096, lbufsz = bufsize-256;
|
||||
/* check if handled */
|
||||
if (handled_exception(PASS_REGS1))
|
||||
return;
|
||||
#if DEBU
|
||||
fprintf(stderr, "%% YAP regs: P=%p, CP=%p, ASP=%p, H=%p, TR=%p, HeapTop=%p\n",
|
||||
P, CP, ASP, HR, TR, HeapTop);
|
||||
#endif
|
||||
// if (handled_exception(PASS_REGS1))
|
||||
// return;
|
||||
#if DEBUG
|
||||
ADDBUF(snprintf(lbuf, lbufsz ,
|
||||
"%% YAP regs: P=%p, CP=%p, ASP=%p, H=%p, TR=%p, HeapTop=%p~n", P,
|
||||
CP, ASP, HR, TR, HeapTop));
|
||||
|
||||
fprintf(stderr, "%% \n%% =====================================\n%%\n");
|
||||
fprintf(stderr, "%% \n%% YAP Status:\n");
|
||||
fprintf(stderr, "%% \n%% -------------------------------------\n%%\n");
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% ~n%% =====================================~n%%~n"));
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% ~n%% YAP Status:~n"));
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% ~n%% -------------------------------------~n%%~n"));
|
||||
yap_error_number errnbr = LOCAL_Error_TYPE;
|
||||
yap_error_class_number classno = Yap_errorClass(errnbr);
|
||||
|
||||
fprintf(stderr, "%% Error STATUS: %s/%s\n\n", Yap_errorName(errnbr),
|
||||
Yap_errorClassName(classno));
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% Error STATUS: %s/%s~n~n", Yap_errorName(errnbr),
|
||||
Yap_errorClassName(classno)));
|
||||
|
||||
fprintf(stderr, "%% Execution mode\n");
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% Execution mode~n"));
|
||||
if (LOCAL_PrologMode & BootMode)
|
||||
fprintf(stderr, "%% Bootstrap\n");
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% Bootstrap~n"));
|
||||
if (LOCAL_PrologMode & UserMode)
|
||||
fprintf(stderr, "%% User Prolo\n");
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% User Prolo~n"));
|
||||
if (LOCAL_PrologMode & CritMode)
|
||||
fprintf(stderr, "%% Exclusive Access Mode\n");
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% Exclusive Access Mode~n"));
|
||||
if (LOCAL_PrologMode & AbortMode)
|
||||
fprintf(stderr, "%% Abort\n");
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% Abort~n"));
|
||||
if (LOCAL_PrologMode & InterruptMode)
|
||||
fprintf(stderr, "%% Interrupt\n");
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% Interrupt~n"));
|
||||
if (LOCAL_PrologMode & InErrorMode)
|
||||
fprintf(stderr, "%% Error\n");
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% Error~n"));
|
||||
if (LOCAL_PrologMode & ConsoleGetcMode)
|
||||
fprintf(stderr, "%% Prompt Console\n");
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% Prompt Console~n"));
|
||||
if (LOCAL_PrologMode & ExtendStackMode)
|
||||
fprintf(stderr, "%% Stack expansion \n");
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% Stack expansion ~n"));
|
||||
if (LOCAL_PrologMode & GrowHeapMode)
|
||||
fprintf(stderr, "%% Data Base Expansion\n");
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% Data Base Expansion~n"));
|
||||
if (LOCAL_PrologMode & GrowStackMode)
|
||||
fprintf(stderr, "%% User Prolog\n");
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% User Prolog~n"));
|
||||
if (LOCAL_PrologMode & GCMode)
|
||||
fprintf(stderr, "%% Garbage Collection\n");
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% Garbage Collection~n"));
|
||||
if (LOCAL_PrologMode & ErrorHandlingMode)
|
||||
fprintf(stderr, "%% Error handler\n");
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% Error handler~n"));
|
||||
if (LOCAL_PrologMode & CCallMode)
|
||||
fprintf(stderr, "%% System Foreign Code\n");
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% System Foreign Code~n"));
|
||||
if (LOCAL_PrologMode & UnifyMode)
|
||||
fprintf(stderr, "%% Off-line Foreign Code\n");
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% Off-line Foreign Code~n"));
|
||||
if (LOCAL_PrologMode & UserCCallMode)
|
||||
fprintf(stderr, "%% User Foreig C\n");
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% User Foreig C~n"));
|
||||
if (LOCAL_PrologMode & MallocMode)
|
||||
fprintf(stderr, "%% Heap Allocaror\n");
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% Heap Allocaror~n"));
|
||||
if (LOCAL_PrologMode & SystemMode)
|
||||
fprintf(stderr, "%% Prolog Internals\n");
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% Prolog Internals~n"));
|
||||
if (LOCAL_PrologMode & AsyncIntMode)
|
||||
fprintf(stderr, "%% Async Interruot mode\n");
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% Async Interruot mode~n"));
|
||||
if (LOCAL_PrologMode & InReadlineMode)
|
||||
fprintf(stderr, "%% Readline Console\n");
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% Readline Console~n"));
|
||||
if (LOCAL_PrologMode & TopGoalMode)
|
||||
fprintf(stderr, "%% Creating new query\n");
|
||||
fprintf(stderr, "%% \n%% -------------------------------------\n%%\n");
|
||||
fprintf(stderr, "%% \n%% YAP Program:\n");
|
||||
fprintf(stderr, "%% \n%% -------------------------------------\n%%\n");
|
||||
fprintf(stderr, "%% Program Position: %s\n\n", Yap_errorName(errno) );
|
||||
fprintf(stderr, "%% PC: %s\n", (char *)HR);
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% Creating new query~n"));
|
||||
#endif
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% ~n%% -------------------------------------~n%%~n"));
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% ~n%% YAP Program:~n"));
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% ~n%% -------------------------------------~n%%~n"));
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% Program Position: %s~n~n", Yap_errorName(errno)));
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% PC: %s~n", (char *)HR));
|
||||
Yap_output_bug_location(CP, FIND_PRED_FROM_ANYWHERE, 256);
|
||||
fprintf(stderr, "%% Continuation: %s\n", (char *)HR);
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% Continuation: %s~n", (char *)HR));
|
||||
Yap_output_bug_location(B->cp_ap, FIND_PRED_FROM_ANYWHERE, 256);
|
||||
fprintf(stderr, "%% Alternative: %s\n", (char *)HR);
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% Alternative: %s~n", (char *)HR));
|
||||
|
||||
fprintf(stderr, "%% \n%% -------------------------------------\n%%\n");
|
||||
fprintf(stderr, "%% \n%% YAP Stack Usage:\n");
|
||||
fprintf(stderr, "%% \n%% -------------------------------------\n%%\n");
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% ~n%% -------------------------------------~n%%~n"));
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% ~n%% YAP Stack Usage:~n"));
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% ~n%% -------------------------------------~n%%~n"));
|
||||
if (HR > ASP || HR > LCL0) {
|
||||
fprintf(stderr, "%% YAP ERROR: Global Collided against Local (%p--%p)\n",
|
||||
HR, ASP);
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% YAP ERROR: Global Collided against Local (%p--%p)~n",
|
||||
HR, ASP));
|
||||
} else if (HeapTop > (ADDR)LOCAL_GlobalBase) {
|
||||
fprintf(stderr,
|
||||
"%% YAP ERROR: Code Space Collided against Global (%p--%p)\n",
|
||||
HeapTop, LOCAL_GlobalBase);
|
||||
ADDBUF(snprintf(lbuf, lbufsz ,
|
||||
"%% YAP ERROR: Code Space Collided against Global (%p--%p)~n",
|
||||
HeapTop, LOCAL_GlobalBase));
|
||||
} else {
|
||||
#if !USE_SYSTEM_MALLOC
|
||||
fprintf(stderr, "%%ldKB of Code Space (%p--%p)\n",
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%%ldKB of Code Space (%p--%p)~n",
|
||||
(long int)((CELL)HeapTop - (CELL)Yap_HeapBase) / 1024, Yap_HeapBase,
|
||||
HeapTop);
|
||||
HeapTop));
|
||||
#if USE_DL_MALLOC
|
||||
if (Yap_NOfMemoryHoles) {
|
||||
UInt i;
|
||||
|
||||
for (i = 0; i < Yap_NOfMemoryHoles; i++)
|
||||
fprintf(stderr, " Current hole: %p--%p\n", Yap_MemoryHoles[i].start,
|
||||
Yap_MemoryHoles[i].end);
|
||||
ADDBUF(snprintf(lbuf, lbufsz , " Current hole: %p--%p~n", Yap_MemoryHoles[i].start,
|
||||
Yap_MemoryHoles[i].end));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
fprintf(stderr, "%% %luKB of Global Stack (%p--%p)\n",
|
||||
(unsigned long int)(sizeof(CELL) * (HR - H0)) / 1024, H0, HR);
|
||||
fprintf(stderr, "%% %luKB of Local Stack (%p--%p)\n",
|
||||
(unsigned long int)(sizeof(CELL) * (LCL0 - ASP)) / 1024, ASP, LCL0);
|
||||
fprintf(stderr, "%% %luKB of Trail (%p--%p)\n",
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% %luKB of Global Stack (%p--%p)~n",
|
||||
(unsigned long int)(sizeof(CELL) * (HR - H0)) / 1024, H0, HR));
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% %luKB of Local Stack (%p--%p)~n",
|
||||
(unsigned long int)(sizeof(CELL) * (LCL0 - ASP)) / 1024, ASP, LCL0));
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% %luKB of Trail (%p--%p)~n",
|
||||
(unsigned long int)((ADDR)TR - LOCAL_TrailBase) / 1024,
|
||||
LOCAL_TrailBase, TR);
|
||||
fprintf(stderr, "%% Performed %ld garbage collections\n",
|
||||
(unsigned long int)LOCAL_GcCalls);
|
||||
LOCAL_TrailBase, TR));
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% Performed %ld garbage collections~n",
|
||||
(unsigned long int)LOCAL_GcCalls));
|
||||
#if LOW_LEVEL_TRACER
|
||||
{
|
||||
extern long long vsc_count;
|
||||
|
||||
if (vsc_count) {
|
||||
#if _WIN32
|
||||
fprintf(stderr, "Trace Counter at %I64d\n", vsc_count);
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "Trace Counter at %I64d~n", vsc_count));
|
||||
#else
|
||||
fprintf(stderr, "Trace Counter at %lld\n", vsc_count);
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "Trace Counter at %lld~n", vsc_count));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
fprintf(stderr, "%% \n%% -------------------------------------\n%%\n");
|
||||
fprintf(stderr, "%% \n%% YAP Stack:\n");
|
||||
fprintf(stderr, "%% \n%% -------------------------------------\n%%\n");
|
||||
fprintf(stderr, "%% All Active Calls and\n");
|
||||
fprintf(stderr, "%% Goals With Alternatives Open (Global In "
|
||||
"Use--Local In Use)\n%%\n");
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% ~n%% -------------------------------------~n%%~n"));
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% ~n%% YAP Stack:~n"));
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% ~n%% -------------------------------------~n%%~n"));
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% All Active Calls and~n"));
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% Goals With Alternatives Open (Global In "
|
||||
"Use--Local In Use)~n%%~n"));
|
||||
while (b_ptr != NULL) {
|
||||
while (env_ptr && env_ptr <= (CELL *)b_ptr) {
|
||||
Yap_output_bug_location(ipc, FIND_PRED_FROM_ENV, 256);
|
||||
tp = Yap_output_bug_location(ipc, FIND_PRED_FROM_ENV, 256);
|
||||
if (env_ptr == (CELL *)b_ptr && (choiceptr)env_ptr[E_CB] > b_ptr) {
|
||||
b_ptr = b_ptr->cp_b;
|
||||
fprintf(stderr, "%% %s\n", tp);
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% %s~n", tp));
|
||||
} else {
|
||||
fprintf(stderr, "%% %s\n", tp);
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% %s~n", tp));
|
||||
}
|
||||
if (!max_count--) {
|
||||
fprintf(stderr, "%% .....\n");
|
||||
return;
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% .....~n"));
|
||||
return pop_output_text_stack(lvl, buf);
|
||||
}
|
||||
ipc = (yamop *)(env_ptr[E_CP]);
|
||||
env_ptr = (CELL *)(env_ptr[E_E]);
|
||||
}
|
||||
if (b_ptr) {
|
||||
if (!max_count--) {
|
||||
fprintf(stderr, "// .....\n");
|
||||
return;
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "// .....~n"));
|
||||
return pop_output_text_stack(lvl, buf);
|
||||
}
|
||||
if (b_ptr->cp_ap && /* tabling */
|
||||
b_ptr->cp_ap->opc != Yap_opcode(_or_else) &&
|
||||
b_ptr->cp_ap->opc != Yap_opcode(_or_last) &&
|
||||
b_ptr->cp_ap->opc != Yap_opcode(_Nstop)) {
|
||||
/* we can safely ignore ; because there is always an upper env */
|
||||
Yap_output_bug_location(b_ptr->cp_ap, FIND_PRED_FROM_CP, 256);
|
||||
fprintf(stderr, "%% %s (%luKB--%luKB)\n", tp,
|
||||
tp = Yap_output_bug_location(b_ptr->cp_ap, FIND_PRED_FROM_CP, 256);
|
||||
ADDBUF(snprintf(lbuf, lbufsz , "%% %s (%luKB--%luKB)~n", tp,
|
||||
(unsigned long int)((b_ptr->cp_h - H0) * sizeof(CELL) / 1024),
|
||||
(unsigned long int)((ADDR)LCL0 - (ADDR)b_ptr) / 1024);
|
||||
(unsigned long int)((ADDR)LCL0 - (ADDR)b_ptr) / 1024));
|
||||
}
|
||||
b_ptr = b_ptr->cp_b;
|
||||
}
|
||||
}
|
||||
}
|
||||
return pop_output_text_stack(lvl, buf);
|
||||
}
|
||||
|
||||
|
||||
void DumpActiveGoals(USES_REGS1) {
|
||||
/* try to dump active goals */
|
||||
CELL *ep = YENV; /* and current environment */
|
||||
@ -2086,33 +2089,34 @@ void DumpActiveGoals(USES_REGS1) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used for debugging.
|
||||
*
|
||||
*/
|
||||
void Yap_output_bug_location(yamop *yap_pc, int where_from, int psize) {
|
||||
char * Yap_output_bug_location(yamop *yap_pc, int where_from, int psize) {
|
||||
Atom pred_name;
|
||||
UInt pred_arity;
|
||||
Term pred_module;
|
||||
Int cl;
|
||||
|
||||
char *o = Malloc(256);
|
||||
if ((cl = Yap_PredForCode(yap_pc, where_from, &pred_name, &pred_arity,
|
||||
&pred_module)) == 0) {
|
||||
/* system predicate */
|
||||
fprintf(stderr, "%% %s", "meta-call");
|
||||
snprintf(o, 255, "%% %s", "meta-call");
|
||||
} else if (pred_module == 0) {
|
||||
fprintf(stderr, "in prolog:%s/%lu", RepAtom(pred_name)->StrOfAE,
|
||||
snprintf(o, 255, "in prolog:%s/%lu", RepAtom(pred_name)->StrOfAE,
|
||||
(unsigned long int)pred_arity);
|
||||
} else if (cl < 0) {
|
||||
fprintf(stderr, "%% %s:%s/%lu", RepAtom(AtomOfTerm(pred_module))->StrOfAE,
|
||||
snprintf(o, 255, "%% %s:%s/%lu", RepAtom(AtomOfTerm(pred_module))->StrOfAE,
|
||||
RepAtom(pred_name)->StrOfAE, (unsigned long int)pred_arity);
|
||||
} else {
|
||||
fprintf(stderr, "%% %s:%s/%lu at clause %lu",
|
||||
snprintf(o, 255, "%% %s:%s/%lu at clause %lu",
|
||||
RepAtom(AtomOfTerm(pred_module))->StrOfAE,
|
||||
RepAtom(pred_name)->StrOfAE, (unsigned long int)pred_arity,
|
||||
(unsigned long int)cl);
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
static yap_error_descriptor_t *add_bug_location(yap_error_descriptor_t *p,
|
||||
|
121
C/text.c
121
C/text.c
@ -59,54 +59,6 @@ typedef struct TextBuffer_manager {
|
||||
} text_buffer_t;
|
||||
|
||||
int AllocLevel(void) { return LOCAL_TextBuffer->lvl; }
|
||||
int push_text_stack__(USES_REGS1) {
|
||||
int i = LOCAL_TextBuffer->lvl;
|
||||
i++;
|
||||
LOCAL_TextBuffer->lvl = i;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
int pop_text_stack__(int i) {
|
||||
int lvl = LOCAL_TextBuffer->lvl;
|
||||
while (lvl >= i) {
|
||||
struct mblock *p = LOCAL_TextBuffer->first[lvl];
|
||||
while (p) {
|
||||
struct mblock *np = p->next;
|
||||
free(p);
|
||||
p = np;
|
||||
}
|
||||
LOCAL_TextBuffer->first[lvl] = NULL;
|
||||
LOCAL_TextBuffer->last[lvl] = NULL;
|
||||
lvl--;
|
||||
}
|
||||
LOCAL_TextBuffer->lvl = lvl;
|
||||
return lvl;
|
||||
}
|
||||
|
||||
void *pop_output_text_stack__(int i, const void *export) {
|
||||
int lvl = LOCAL_TextBuffer->lvl;
|
||||
while (lvl >= i) {
|
||||
struct mblock *p = LOCAL_TextBuffer->first[lvl];
|
||||
while (p) {
|
||||
struct mblock *np = p->next;
|
||||
if (p + 1 == export) {
|
||||
size_t sz = p->sz - sizeof(struct mblock);
|
||||
memmove(p, p + 1, sz);
|
||||
export = p;
|
||||
} else {
|
||||
free(p);
|
||||
}
|
||||
p = np;
|
||||
}
|
||||
LOCAL_TextBuffer->first[lvl] = NULL;
|
||||
LOCAL_TextBuffer->last[lvl] = NULL;
|
||||
lvl--;
|
||||
}
|
||||
LOCAL_TextBuffer->lvl = lvl;
|
||||
return (void *)export;
|
||||
}
|
||||
|
||||
// void pop_text_stack(int i) { LOCAL_TextBuffer->lvl = i; }
|
||||
void insert_block(struct mblock *o) {
|
||||
int lvl = o->lvl;
|
||||
@ -138,6 +90,68 @@ void release_block(struct mblock *o) {
|
||||
o->next->prev = o->prev;
|
||||
}
|
||||
|
||||
int push_text_stack__(USES_REGS1) {
|
||||
int i = LOCAL_TextBuffer->lvl;
|
||||
i++;
|
||||
LOCAL_TextBuffer->lvl = i;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
int pop_text_stack__(int i) {
|
||||
int lvl = LOCAL_TextBuffer->lvl;
|
||||
while (lvl >= i) {
|
||||
struct mblock *p = LOCAL_TextBuffer->first[lvl];
|
||||
while (p) {
|
||||
struct mblock *np = p->next;
|
||||
free(p);
|
||||
p = np;
|
||||
}
|
||||
LOCAL_TextBuffer->first[lvl] = NULL;
|
||||
LOCAL_TextBuffer->last[lvl] = NULL;
|
||||
lvl--;
|
||||
}
|
||||
LOCAL_TextBuffer->lvl = lvl;
|
||||
return lvl;
|
||||
}
|
||||
|
||||
void *pop_output_text_stack__(int i, const void *export) {
|
||||
int lvl = LOCAL_TextBuffer->lvl;
|
||||
bool found = false;
|
||||
while (lvl >= i) {
|
||||
struct mblock *p = LOCAL_TextBuffer->first[lvl];
|
||||
while (p) {
|
||||
struct mblock *np = p->next;
|
||||
if (p + 1 == export) {
|
||||
found = true;
|
||||
} else {
|
||||
free(p);
|
||||
}
|
||||
p = np;
|
||||
}
|
||||
LOCAL_TextBuffer->first[lvl] = NULL;
|
||||
LOCAL_TextBuffer->last[lvl] = NULL;
|
||||
lvl--;
|
||||
}
|
||||
LOCAL_TextBuffer->lvl = lvl;
|
||||
if (found) {
|
||||
if (lvl) {
|
||||
struct mblock *o = (struct mblock *)export-1;
|
||||
o->lvl = lvl;
|
||||
o->prev = o->next = 0;
|
||||
insert_block(o);
|
||||
|
||||
} else {
|
||||
struct mblock *p = (struct mblock *)export-1;
|
||||
size_t sz = p->sz - sizeof(struct mblock);
|
||||
memmove(p, p + 1, sz);
|
||||
export = p;
|
||||
|
||||
}
|
||||
}
|
||||
return (void *)export;
|
||||
}
|
||||
|
||||
void *Malloc(size_t sz USES_REGS) {
|
||||
int lvl = LOCAL_TextBuffer->lvl;
|
||||
if (sz == 0)
|
||||
@ -976,7 +990,7 @@ bool Yap_CVT_Text(seq_tv_t *inp, seq_tv_t *out USES_REGS) {
|
||||
else
|
||||
fprintf(stderr, "%s", out->val.c);
|
||||
fprintf(stderr, "\n]\n"); */
|
||||
pop_text_stack(l);
|
||||
out->val.uc = pop_output_text_stack(l,out->val.uc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -1027,10 +1041,11 @@ bool Yap_Concat_Text(int tot, seq_tv_t inp[], seq_tv_t *out USES_REGS) {
|
||||
void **bufv;
|
||||
unsigned char *buf;
|
||||
int i, j;
|
||||
// int lvl = push_text_stack();
|
||||
|
||||
int lvl = push_text_stack();
|
||||
bufv = Malloc(tot * sizeof(unsigned char *));
|
||||
if (!bufv) {
|
||||
// pop_text_stack(lvl);
|
||||
pop_text_stack(lvl);
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0, j = 0; i < tot; i++) {
|
||||
@ -1038,7 +1053,7 @@ bool Yap_Concat_Text(int tot, seq_tv_t inp[], seq_tv_t *out USES_REGS) {
|
||||
unsigned char *nbuf = Yap_readText(inp + i PASS_REGS);
|
||||
|
||||
if (!nbuf) {
|
||||
// pop_text_stack(lvl);
|
||||
pop_text_stack(lvl);
|
||||
return NULL;
|
||||
}
|
||||
// if (!nbuf[0])
|
||||
@ -1054,7 +1069,7 @@ bool Yap_Concat_Text(int tot, seq_tv_t inp[], seq_tv_t *out USES_REGS) {
|
||||
buf = concat(tot, bufv PASS_REGS);
|
||||
}
|
||||
bool rc = write_Text(buf, out PASS_REGS);
|
||||
// pop_text_stack( lvl );
|
||||
pop_text_stack( lvl );
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
@ -98,11 +98,9 @@ static char *send_tracer_message(char *start, char *name, arity_t arity,
|
||||
if (max <= sz) {
|
||||
min = sz + 1024;
|
||||
expand = true;
|
||||
free((void*)sn);
|
||||
continue;
|
||||
}
|
||||
strcpy(s, sn);
|
||||
free((void*)sn);
|
||||
sn = NULL;
|
||||
s += sz;
|
||||
max -= sz;
|
||||
|
@ -103,7 +103,6 @@ copy_complex_term(CELL *pt0, CELL *pt0_end, int share, int newattvs, CELL *ptf,
|
||||
}
|
||||
*ptf = AbsPair(HR);
|
||||
ptf++;
|
||||
#ifdef RATIONAL_TREES
|
||||
if (to_visit+1 >= (struct cp_frame *)AuxSp) {
|
||||
goto heap_overflow;
|
||||
}
|
||||
@ -115,18 +114,6 @@ copy_complex_term(CELL *pt0, CELL *pt0_end, int share, int newattvs, CELL *ptf,
|
||||
/* fool the system into thinking we had a variable there */
|
||||
*pt0 = AbsPair(HR);
|
||||
to_visit ++;
|
||||
#else
|
||||
if (pt0 < pt0_end) {
|
||||
if (to_visit+1 >= (struct cp_frame *)AuxSp) {
|
||||
goto heap_overflow;
|
||||
}
|
||||
to_visit->start_cp = pt0;
|
||||
to_visit->end_cp = pt0_end;
|
||||
to_visit->to = ptf;
|
||||
to_visit->ground = ground;
|
||||
to_visit ++;
|
||||
}
|
||||
#endif
|
||||
ground = TRUE;
|
||||
pt0 = ap2 - 1;
|
||||
pt0_end = ap2 + 1;
|
||||
@ -192,7 +179,6 @@ copy_complex_term(CELL *pt0, CELL *pt0_end, int share, int newattvs, CELL *ptf,
|
||||
*ptf = AbsAppl(HR);
|
||||
ptf++;
|
||||
/* store the terms to visit */
|
||||
#ifdef RATIONAL_TREES
|
||||
if (to_visit+1 >= (struct cp_frame *)AuxSp) {
|
||||
goto heap_overflow;
|
||||
}
|
||||
@ -204,18 +190,6 @@ copy_complex_term(CELL *pt0, CELL *pt0_end, int share, int newattvs, CELL *ptf,
|
||||
/* fool the system into thinking we had a variable there */
|
||||
*pt0 = AbsAppl(HR);
|
||||
to_visit ++;
|
||||
#else
|
||||
if (pt0 < pt0_end) {
|
||||
if (to_visit+1 >= (struct cp_frame *)AuxSp) {
|
||||
goto heap_overflow;
|
||||
}
|
||||
to_visit->start_cp = pt0;
|
||||
to_visit->end_cp = pt0_end;
|
||||
to_visit->to = ptf;
|
||||
to_visit->ground = ground;
|
||||
to_visit ++;
|
||||
}
|
||||
#endif
|
||||
ground = (f != FunctorMutable);
|
||||
d0 = ArityOfFunctor(f);
|
||||
pt0 = ap2;
|
||||
@ -267,9 +241,7 @@ copy_complex_term(CELL *pt0, CELL *pt0_end, int share, int newattvs, CELL *ptf,
|
||||
}
|
||||
Bind_NonAtt(ptd0, (CELL)ptf);
|
||||
ptf++;
|
||||
#ifdef COROUTINING
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/* Do we still have compound terms to visit */
|
||||
if (to_visit > to_visit0) {
|
||||
@ -288,9 +260,7 @@ copy_complex_term(CELL *pt0, CELL *pt0_end, int share, int newattvs, CELL *ptf,
|
||||
pt0 = to_visit->start_cp;
|
||||
pt0_end = to_visit->end_cp;
|
||||
ptf = to_visit->to;
|
||||
#ifdef RATIONAL_TREES
|
||||
*pt0 = to_visit->oldv;
|
||||
#endif
|
||||
ground = (ground && to_visit->ground);
|
||||
goto loop;
|
||||
}
|
||||
@ -306,7 +276,6 @@ copy_complex_term(CELL *pt0, CELL *pt0_end, int share, int newattvs, CELL *ptf,
|
||||
/* we've done it */
|
||||
/* restore our nice, friendly, term to its original state */
|
||||
HB = HB0;
|
||||
#ifdef RATIONAL_TREES
|
||||
while (to_visit > to_visit0) {
|
||||
to_visit --;
|
||||
pt0 = to_visit->start_cp;
|
||||
@ -314,7 +283,6 @@ copy_complex_term(CELL *pt0, CELL *pt0_end, int share, int newattvs, CELL *ptf,
|
||||
ptf = to_visit->to;
|
||||
*pt0 = to_visit->oldv;
|
||||
}
|
||||
#endif
|
||||
reset_trail(TR0);
|
||||
/* follow chain of multi-assigned variables */
|
||||
return -1;
|
||||
@ -325,7 +293,6 @@ trail_overflow:
|
||||
/* we've done it */
|
||||
/* restore our nice, friendly, term to its original state */
|
||||
HB = HB0;
|
||||
#ifdef RATIONAL_TREES
|
||||
while (to_visit > to_visit0) {
|
||||
to_visit --;
|
||||
pt0 = to_visit->start_cp;
|
||||
@ -333,7 +300,6 @@ trail_overflow:
|
||||
ptf = to_visit->to;
|
||||
*pt0 = to_visit->oldv;
|
||||
}
|
||||
#endif
|
||||
{
|
||||
tr_fr_ptr oTR = TR;
|
||||
reset_trail(TR0);
|
||||
@ -349,7 +315,6 @@ trail_overflow:
|
||||
/* we've done it */
|
||||
/* restore our nice, friendly, term to its original state */
|
||||
HB = HB0;
|
||||
#ifdef RATIONAL_TREES
|
||||
while (to_visit > to_visit0) {
|
||||
to_visit --;
|
||||
pt0 = to_visit->start_cp;
|
||||
@ -357,7 +322,6 @@ trail_overflow:
|
||||
ptf = to_visit->to;
|
||||
*pt0 = to_visit->oldv;
|
||||
}
|
||||
#endif
|
||||
reset_trail(TR0);
|
||||
LOCAL_Error_Size = (ADDR)AuxSp-(ADDR)to_visit0;
|
||||
return -3;
|
||||
@ -2679,7 +2643,7 @@ static Term free_vars_in_complex_term(register CELL *pt0, register CELL *pt0_end
|
||||
|
||||
clean_tr(TR0 PASS_REGS);
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0);
|
||||
if (HR != InitialH+1) {
|
||||
if (HR != InitialH) {
|
||||
InitialH[0] = (CELL)Yap_MkFunctor(AtomDollar, (HR-InitialH)-1);
|
||||
return AbsAppl(InitialH);
|
||||
} else {
|
||||
@ -3002,9 +2966,9 @@ static Term non_singletons_in_complex_term(register CELL *pt0, register CELL *pt
|
||||
CELL *pt2 = pt0;
|
||||
while(IsVarTerm(*pt2))
|
||||
pt2 = (CELL *)(*pt2);
|
||||
HR[1] = AbsPair(HR+2);
|
||||
HR[0] = AbsPair(HR+2);
|
||||
HR += 2;
|
||||
HR[-2] = (CELL)pt2;
|
||||
HR[-1] = (CELL)pt2;
|
||||
*pt2 = TermRefoundVar;
|
||||
}
|
||||
continue;
|
||||
@ -3019,24 +2983,28 @@ static Term non_singletons_in_complex_term(register CELL *pt0, register CELL *pt
|
||||
}
|
||||
/* Do we still have compound terms to visit */
|
||||
if (to_visit > to_visit0) {
|
||||
#ifdef RATIONAL_TREES
|
||||
to_visit -= 3;
|
||||
pt0 = to_visit[0];
|
||||
pt0_end = to_visit[1];
|
||||
*pt0 = (CELL)to_visit[2];
|
||||
#else
|
||||
to_visit -= 2;
|
||||
pt0 = to_visit[0];
|
||||
pt0_end = to_visit[1];
|
||||
#endif
|
||||
goto loop;
|
||||
}
|
||||
|
||||
clean_tr(TR0 PASS_REGS);
|
||||
if (HR != InitialH) {
|
||||
CELL *pt0 = InitialH, *pt1 = pt0;
|
||||
while (pt0 < InitialH) {
|
||||
if(Deref(pt0[0]) == TermFoundVar) {
|
||||
pt1[0] = pt0[0];
|
||||
pt1[1] = AbsAppl(pt1+2);
|
||||
pt1 += 2;
|
||||
}
|
||||
pt0 += 2;
|
||||
}
|
||||
}
|
||||
if (HR != InitialH) {
|
||||
/* close the list */
|
||||
RESET_VARIABLE(HR-1);
|
||||
Yap_unify((CELL)(HR-1),ARG2);
|
||||
HR[-1] = Deref(ARG2);
|
||||
return output;
|
||||
} else {
|
||||
return ARG2;
|
||||
@ -3067,7 +3035,7 @@ p_non_singletons_in_term( USES_REGS1 ) /* non_singletons in term t */
|
||||
while (TRUE) {
|
||||
t = Deref(ARG1);
|
||||
if (IsVarTerm(t)) {
|
||||
out = MkPairTerm(t,ARG2);
|
||||
out = ARG2;
|
||||
} else if (IsPrimitiveTerm(t)) {
|
||||
out = ARG2;
|
||||
} else if (IsPairTerm(t)) {
|
||||
@ -4874,19 +4842,11 @@ loop:
|
||||
if (to_visit + 32 >= to_visit_max) {
|
||||
goto aux_overflow;
|
||||
}
|
||||
#ifdef RATIONAL_TREES
|
||||
to_visit->beg = pt0;
|
||||
to_visit->end = pt0_end;
|
||||
to_visit->oval = *pt0;
|
||||
to_visit ++;
|
||||
*pt0 = TermNil;
|
||||
#else
|
||||
if (pt0 < pt0_end) {
|
||||
to_visit[0] = pt0;
|
||||
to_visit[1] = pt0_end;
|
||||
to_visit += 2;
|
||||
}
|
||||
#endif
|
||||
pt0 = RepPair(d0) - 1;
|
||||
pt0_end = RepPair(d0) + 1;
|
||||
} else if (IsApplTerm(d0)) {
|
||||
@ -4906,14 +4866,11 @@ loop:
|
||||
if (to_visit + 32 >= to_visit_max) {
|
||||
goto aux_overflow;
|
||||
}
|
||||
#ifdef RATIONAL_TREES
|
||||
#else
|
||||
to_visit->beg = pt0;
|
||||
to_visit->end = pt0_end;
|
||||
to_visit->oval = *pt0;
|
||||
to_visit ++;
|
||||
*pt0 = TermNil;
|
||||
#endif
|
||||
d0 = ArityOfFunctor(f);
|
||||
pt0 = ap2;
|
||||
pt0_end = ap2 + d0;
|
||||
|
57
C/write.c
57
C/write.c
@ -100,7 +100,8 @@ static bool callPortray(Term t, int sno USES_REGS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#define PROTECT(t,F) { \
|
||||
#define PROTECT(t, F) \
|
||||
{ \
|
||||
yhandle_t yt = Yap_InitHandle(t); \
|
||||
F; \
|
||||
t = Yap_PopHandle(yt); \
|
||||
@ -717,7 +718,6 @@ static void write_var(CELL *t, struct write_globs *wglb,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void write_list(Term t, int direction, int depth,
|
||||
struct write_globs *wglb, struct rewind_term *rwt) {
|
||||
Term ti;
|
||||
@ -729,8 +729,7 @@ static void write_list(Term t, int direction, int depth,
|
||||
int ndirection;
|
||||
int do_jump;
|
||||
|
||||
PROTECT(t,writeTerm(HeadOfTerm(t), 999, depth + 1, FALSE,
|
||||
wglb, &nrwt));
|
||||
PROTECT(t, writeTerm(HeadOfTerm(t), 999, depth + 1, FALSE, wglb, &nrwt));
|
||||
ti = TailOfTerm(t);
|
||||
if (IsVarTerm(ti))
|
||||
break;
|
||||
@ -775,8 +774,7 @@ static void write_list(Term t, int direction, int depth,
|
||||
}
|
||||
wrputc('|', wglb->stream);
|
||||
lastw = separator;
|
||||
writeTerm(ti, 999, depth, FALSE,
|
||||
wglb, &nrwt);
|
||||
writeTerm(ti, 999, depth, FALSE, wglb, &nrwt);
|
||||
}
|
||||
}
|
||||
|
||||
@ -807,11 +805,9 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
||||
wrputs("'.'(", wglb->stream);
|
||||
lastw = separator;
|
||||
|
||||
PROTECT( t, writeTerm(HeadOfTerm(t), 999, depth + 1, FALSE,
|
||||
wglb, &nrwt));
|
||||
PROTECT(t, writeTerm(HeadOfTerm(t), 999, depth + 1, FALSE, wglb, &nrwt));
|
||||
wrputs(",", wglb->stream);
|
||||
writeTerm(TailOfTerm(t), 999, depth + 1,
|
||||
FALSE, wglb, &nrwt);
|
||||
writeTerm(TailOfTerm(t), 999, depth + 1, FALSE, wglb, &nrwt);
|
||||
wrclose_bracket(wglb, TRUE);
|
||||
return;
|
||||
}
|
||||
@ -877,8 +873,7 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
||||
*p++;
|
||||
lastw = separator;
|
||||
/* cannot use the term directly with the SBA */
|
||||
PROTECT( t, writeTerm(*p, 999, depth + 1, FALSE, wglb,
|
||||
&nrwt) );
|
||||
PROTECT(t, writeTerm(*p, 999, depth + 1, FALSE, wglb, &nrwt));
|
||||
if (*p)
|
||||
wrputc(',', wglb->stream);
|
||||
argno++;
|
||||
@ -906,8 +901,7 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
||||
} else if (atom == AtomMinus) {
|
||||
last_minus = TRUE;
|
||||
}
|
||||
writeTerm(tright, rp, depth + 1, TRUE,
|
||||
wglb, &nrwt);
|
||||
writeTerm(tright, rp, depth + 1, TRUE, wglb, &nrwt);
|
||||
if (bracket_right) {
|
||||
wrclose_bracket(wglb, TRUE);
|
||||
}
|
||||
@ -940,8 +934,7 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
||||
if (bracket_left) {
|
||||
wropen_bracket(wglb, TRUE);
|
||||
}
|
||||
writeTerm(ArgOfTerm(offset,t), lp, depth + 1,
|
||||
rinfixarg, wglb, &nrwt);
|
||||
writeTerm(ArgOfTerm(offset, t), lp, depth + 1, rinfixarg, wglb, &nrwt);
|
||||
if (bracket_left) {
|
||||
wrclose_bracket(wglb, TRUE);
|
||||
}
|
||||
@ -986,8 +979,8 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
||||
if (bracket_left) {
|
||||
wropen_bracket(wglb, TRUE);
|
||||
}
|
||||
PROTECT(t,writeTerm(ArgOfTerm(1,t), lp, depth + 1,
|
||||
rinfixarg, wglb, &nrwt));
|
||||
PROTECT(
|
||||
t, writeTerm(ArgOfTerm(1, t), lp, depth + 1, rinfixarg, wglb, &nrwt));
|
||||
if (bracket_left) {
|
||||
wrclose_bracket(wglb, TRUE);
|
||||
}
|
||||
@ -1006,8 +999,7 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
||||
if (bracket_right) {
|
||||
wropen_bracket(wglb, TRUE);
|
||||
}
|
||||
writeTerm(ArgOfTerm(2,t), rp, depth + 1, TRUE,
|
||||
wglb, &nrwt);
|
||||
writeTerm(ArgOfTerm(2, t), rp, depth + 1, TRUE, wglb, &nrwt);
|
||||
if (bracket_right) {
|
||||
wrclose_bracket(wglb, TRUE);
|
||||
}
|
||||
@ -1047,15 +1039,14 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
||||
} else {
|
||||
wrputs("'$VAR'(", wglb->stream);
|
||||
lastw = separator;
|
||||
writeTerm(ArgOfTerm(1, t), 999, depth + 1,
|
||||
FALSE, wglb, &nrwt);
|
||||
writeTerm(ArgOfTerm(1, t), 999, depth + 1, FALSE, wglb, &nrwt);
|
||||
wrclose_bracket(wglb, TRUE);
|
||||
}
|
||||
} else if (!wglb->Ignore_ops && functor == FunctorBraces) {
|
||||
wrputc('{', wglb->stream);
|
||||
lastw = separator;
|
||||
writeTerm(ArgOfTerm(1, t), GLOBAL_MaxPriority,
|
||||
depth + 1, FALSE, wglb, &nrwt);
|
||||
writeTerm(ArgOfTerm(1, t), GLOBAL_MaxPriority, depth + 1, FALSE, wglb,
|
||||
&nrwt);
|
||||
wrputc('}', wglb->stream);
|
||||
lastw = separator;
|
||||
} else if (atom == AtomArray) {
|
||||
@ -1066,17 +1057,15 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
||||
wrputs("...", wglb->stream);
|
||||
break;
|
||||
}
|
||||
writeTerm(ArgOfTerm(op, t), 999, depth + 1,
|
||||
FALSE, wglb, &nrwt);
|
||||
writeTerm(ArgOfTerm(op, t), 999, depth + 1, FALSE, wglb, &nrwt);
|
||||
if (op != Arity) {
|
||||
PROTECT(t, writeTerm(ArgOfTerm(op, t), 999, depth + 1,
|
||||
FALSE, wglb, &nrwt));
|
||||
PROTECT(t, writeTerm(ArgOfTerm(op, t), 999, depth + 1, FALSE, wglb,
|
||||
&nrwt));
|
||||
wrputc(',', wglb->stream);
|
||||
lastw = separator;
|
||||
}
|
||||
}
|
||||
writeTerm(ArgOfTerm(op, t), 999, depth + 1,
|
||||
FALSE, wglb, &nrwt);
|
||||
writeTerm(ArgOfTerm(op, t), 999, depth + 1, FALSE, wglb, &nrwt);
|
||||
wrputc('}', wglb->stream);
|
||||
lastw = separator;
|
||||
} else {
|
||||
@ -1090,13 +1079,12 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
||||
wrputc('.', wglb->stream);
|
||||
break;
|
||||
}
|
||||
PROTECT(t,writeTerm(ArgOfTerm(op, t), 999, depth + 1,
|
||||
FALSE, wglb, &nrwt));
|
||||
PROTECT(
|
||||
t, writeTerm(ArgOfTerm(op, t), 999, depth + 1, FALSE, wglb, &nrwt));
|
||||
wrputc(',', wglb->stream);
|
||||
lastw = separator;
|
||||
}
|
||||
writeTerm(ArgOfTerm(op, t), 999, depth + 1,
|
||||
FALSE, wglb, &nrwt);
|
||||
writeTerm(ArgOfTerm(op, t), 999, depth + 1, FALSE, wglb, &nrwt);
|
||||
wrclose_bracket(wglb, TRUE);
|
||||
}
|
||||
}
|
||||
@ -1164,4 +1152,3 @@ void Yap_plwrite(Term t, StreamDesc *mywrite, int max_depth, int flags,
|
||||
Yap_CloseSlots(sls);
|
||||
pop_text_stack(lvl);
|
||||
}
|
||||
|
||||
|
@ -198,6 +198,7 @@ static bool consult(const char *b_file USES_REGS) {
|
||||
t = ArgOfTerm(1, t);
|
||||
if (IsApplTerm(t) && FunctorOfTerm(t) == functor_compile2) {
|
||||
consult(RepAtom(AtomOfTerm(ArgOfTerm(1, t)))->StrOfAE);
|
||||
Yap_ResetException(LOCAL_ActiveError);
|
||||
} else {
|
||||
YAP_RunGoalOnce(t);
|
||||
}
|
||||
@ -1052,6 +1053,9 @@ X_API void YAP_Init(YAP_init_args *yap_init) {
|
||||
MkAtomTerm(Yap_LookupAtom(Yap_BOOTFILE)));
|
||||
setBooleanGlobalPrologFlag(SAVED_PROGRAM_FLAG, false);
|
||||
} else {
|
||||
if (yap_init->QuietMode) {
|
||||
setVerbosity(TermSilent);
|
||||
}
|
||||
Yap_Restore(Yap_INPUT_STARTUP);
|
||||
init_globals(yap_init);
|
||||
|
||||
|
304
CMakeLists.txt
Normal file → Executable file
304
CMakeLists.txt
Normal file → Executable file
@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.4)
|
||||
|
||||
# Sets the version of CMake required to build the native
|
||||
# library. You should either keep the default value or pass a
|
||||
# value of 3.4.0 or lower.
|
||||
# value of 3.4.0 or lower.fg
|
||||
include(CMakeToolsHelpers OPTIONAL)
|
||||
|
||||
include(FeatureSummary)
|
||||
@ -67,7 +67,92 @@ if (POLICY CMP0068)
|
||||
cmake_policy(SET CMP0068 NEW)
|
||||
endif ()
|
||||
|
||||
## options: compilation flags
|
||||
option(BUILD_SHARED_LIBS "Build shared library" ON)
|
||||
CMAKE_DEPENDENT_OPTION(WITH_SYSTEM_MMAP "Use MMAP for shared memory allocation" ON "NOT WITH_YAPOR_THOR" OFF)
|
||||
CMAKE_DEPENDENT_OPTION(WITH_SYSTEM_SHM "Use SHM for shared memory allocation" ON "NOT WITH_YAPOR_THOR; NOT WITH_SYSTEM_MMAP" OFF)
|
||||
OPTION(WITH_CALL_TRACER "support for procedure-call tracing" ${DEBUG})
|
||||
option(WITH_YAP_DLL "compile YAP as a DLL" ON)
|
||||
option(WITH_YAP_STATIC "compile YAP statically" OFF)
|
||||
option(WITH_YAP_CONDOR "allow YAP to be used from condor" OFF)
|
||||
option(WITH_YAP_DLL "compile YAP as a DLL" ON)
|
||||
if (WITH_YAP_CONDOR)
|
||||
set(WITH_YAP_STATIC ON)
|
||||
set(WITH_YAP_DLL OFF)
|
||||
endif ()
|
||||
|
||||
## options: libraries
|
||||
option(WITH_THREADED_CODE "threaded code" ON)
|
||||
option(WITH_MPI "Interface to OpenMPI/MPICH" ON)
|
||||
option(WITH_READLINE "use readline or libedit" ON)
|
||||
option(WITH_JIT "just in Time Clause Compilation" OFF)
|
||||
|
||||
if (APPLE)
|
||||
set(MACOSX_RPATH ON)
|
||||
|
||||
option(WITH_BREW "brew" ON)
|
||||
if (WITH_BREW)
|
||||
EXECUTE_PROCESS(COMMAND brew --prefix RESULT_VARIABLE DETECT_BREW OUTPUT_VARIABLE BREW_PREFIX ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
IF (${DETECT_BREW} EQUAL 0)
|
||||
|
||||
# "/opt/local" is where MacPorts lives, add `/lib` suffix and link
|
||||
LINK_DIRECTORIES( ${BREW_PREFIX}/lib)
|
||||
|
||||
list(INSERT CMAKE_PREFIX_PATH pos
|
||||
${BREW_PREFIX}/opt/gmp
|
||||
${BREW_PREFIX}/opt/libxml2
|
||||
${BREW_PREFIX}/opt/openmpi
|
||||
${BREW_PREFIX}/opt/openssl
|
||||
${BREW_PREFIX}/opt/postgresql
|
||||
${BREW_PREFIX}/opt/python3
|
||||
${BREW_PREFIX}/opt/readline
|
||||
${BREW_PREFIX}/opt/swig
|
||||
)
|
||||
else()
|
||||
option(WITH_MACPORTS "mac-ports" ON)
|
||||
if (WITH_MACPORTS)
|
||||
# Add MacPorts
|
||||
# Detect if the "port" command is valid on this system; if so, return full path
|
||||
EXECUTE_PROCESS(COMMAND which port RESULT_VARIABLE DETECT_MACPORTS OUTPUT_VARIABLE MACPORTS_PREFIX ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
IF (${DETECT_MACPORTS} EQUAL 0)
|
||||
# "/opt/local/bin/port" doesn't have libs, so we get the parent directory
|
||||
GET_FILENAME_COMPONENT(MACPORTS_PREFIX ${MACPORTS_PREFIX} DIRECTORY)
|
||||
|
||||
# "/opt/local/bin" doesn't have libs, so we get the parent directory
|
||||
GET_FILENAME_COMPONENT(MACPORTS_PREFIX ${MACPORTS_PREFIX} DIRECTORY)
|
||||
|
||||
# "/opt/local" is where MacPorts lives, add `/lib` suffix and link
|
||||
LINK_DIRECTORIES(${LINK DIRECTORIES} ${MACPORTS_PREFIX}/lib)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
option (WITH_PACKAGES "packages and liaries that add value to YAP" ON)
|
||||
|
||||
OPTION(WITH_MYDDAS " Enable MYDDAS driver" ${WITH_PACKAGES})
|
||||
OPTION(WITH_SQLITE3 " Enable MYDDAS SQLITE3 driver" ${WITH_MYDDAS})
|
||||
OPTION(WITH_MYSQL " Enable MYDDAS MYSQL driver" ${WITH_MYDDAS})
|
||||
OPTION(WITH_ODBC " Enable MYDDAS ODBC driver" ${WITH_MYDDAS})
|
||||
OPTION(WITH_POSTGRES " Enable MYDDAS POSTGRES driver" ${WITH_MYDDAS})
|
||||
OPTION(WITH_SQLITE3 " Enable MYDDAS SQLITE3 driver" ${WITH_MYDDAS})
|
||||
OPTION(WITH_SWIG " Enable SWIG interfaces to foreign languages" ${WITH_PACKAGES})
|
||||
OPTION(WITH_RAPTOR " Enable the RAPTOR RDF library" ${WITH_PACKAGES})
|
||||
OPTION(WITH_XML2 " Enable the RAPTOR XML2 library" ${WITH_PACKAGES})
|
||||
OPTION(WITH_XML " Enable the Prolog XML library" ${WITH_PACKAGES})
|
||||
OPTION(WITH_CLPBN" Enable the CLPBN and PFL probabilistic languages" ${WITH_PACKAGES})
|
||||
OPTION(WITH_HORUS " Enable the HORUS inference libraray for CLPBN and PFL" ${WITH_CLPBN})
|
||||
option(WITH_PROBLOG "include Problog-I." ${WITH_PACKAGES})
|
||||
OPTION(WITH_CPLINT " Enable the cplint probabilistic language" ${WITH_PACKAGES})
|
||||
option(WITH_GECODE "interface gecode constraint solver" ${WITH_PACKAGES})
|
||||
option(WITH_LBFGS "interface with lbfgs" ${WITH_PACKAGES})
|
||||
option(WITH_PRISM "use PRISM system in YAP" ${WITH_PACKAGES})
|
||||
option(WITH_PYTHON "Allow Python->YAP and YAP->Python" ${WITH_PACKAGES})
|
||||
option(WITH_R "Use R Interface" ${WITH_PACKAGES})
|
||||
option(WITH_JAVA "Try to use Java (currently Java 6,7,8)" ${WITH_PACKAGES})
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
|
||||
@ -225,79 +310,11 @@ endif()
|
||||
ADD_CUSTOM_TARGET(run_install COMMAND ${CMAKE_MAKE_PROGRAM} install)
|
||||
|
||||
|
||||
if (APPLE)
|
||||
set(MACOSX_RPATH ON)
|
||||
|
||||
if (NOT $ENV{CONDA_BUILD}x STREQUAL "1x")
|
||||
|
||||
set(PATH $ENV{PATH})
|
||||
|
||||
option(WITH_BREW "brew" ON)
|
||||
if (WITH_MACPORTS)
|
||||
# Add MacPorts
|
||||
# Detect if the "port" command is valid on this system; if so, return full path
|
||||
EXECUTE_PROCESS(COMMAND which port RESULT_VARIABLE DETECT_MACPORTS OUTPUT_VARIABLE MACPORTS_PREFIX ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
IF (${DETECT_MACPORTS} EQUAL 0)
|
||||
# "/opt/local/bin/port" doesn't have libs, so we get the parent directory
|
||||
GET_FILENAME_COMPONENT(MACPORTS_PREFIX ${MACPORTS_PREFIX} DIRECTORY)
|
||||
|
||||
# "/opt/local/bin" doesn't have libs, so we get the parent directory
|
||||
GET_FILENAME_COMPONENT(MACPORTS_PREFIX ${MACPORTS_PREFIX} DIRECTORY)
|
||||
|
||||
# "/opt/local" is where MacPorts lives, add `/lib` suffix and link
|
||||
LINK_DIRECTORIES(${LINK DIRECTORIES} ${MACPORTS_PREFIX}/lib)
|
||||
|
||||
MESSAGE("WINNING!: ${MACPORTS_PREFIX}/lib")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
option(WITH_BREW "brew" ON)
|
||||
|
||||
if (WITH_BREW)
|
||||
EXECUTE_PROCESS(COMMAND brew --prefix RESULT_VARIABLE DETECT_BREW OUTPUT_VARIABLE BREW_PREFIX ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
IF (${DETECT_BREW} EQUAL 0)
|
||||
|
||||
# "/opt/local" is where MacPorts lives, add `/lib` suffix and link
|
||||
LINK_DIRECTORIES( ${BREW_PREFIX}/lib)
|
||||
|
||||
MESSAGE("BREW!: ${BREW_PREFIX}/lib")
|
||||
ENDIF()
|
||||
|
||||
|
||||
list(INSERT CMAKE_PREFIX_PATH pos
|
||||
${BREW_PREFIX}/opt/gmp
|
||||
${BREW_PREFIX}/opt/libxml2
|
||||
${BREW_PREFIX}/opt/openmpi
|
||||
${BREW_PREFIX}/opt/openssl
|
||||
${BREW_PREFIX}/opt/postgresql
|
||||
${BREW_PREFIX}/opt/python3
|
||||
${BREW_PREFIX}/opt/readline
|
||||
${BREW_PREFIX}/opt/swig
|
||||
)
|
||||
endif ()
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
|
||||
set(prefix ${CMAKE_INSTALL_PREFIX}) #BINDIR})
|
||||
set(bindir ${CMAKE_INSTALL_PREFIX}/bin) #BINDIR})
|
||||
set(includedir ${CMAKE_INSTALL_PREFIX}/include) #INCLUDEDIR})
|
||||
set(libdir ${CMAKE_INSTALL_PREFIX}/lib) #LIBDIR})
|
||||
set(exec_prefix ${CMAKE_INSTALL_PREFIX}/libexec) #LIBEXECDIR})
|
||||
set(datarootdir ${CMAKE_INSTALL_PREFIX}/share) #DATAROOTDIR})
|
||||
if (ANDROID)
|
||||
set(datarootdir ${YAP_APP_DIR}/src/generated/assets)
|
||||
endif ()
|
||||
set(datadir ${CMAKE_INSTALL_PREFIX}/share) #DATADIR})
|
||||
set(mandir ${CMAKE_INSTALL_PREFIX}/share/man) #MANDIR})
|
||||
set(docdir ${CMAKE_INSTALL_PREFIX}/share/docs) #MANDIR})
|
||||
|
||||
set(libpl ${datadir}/Yap)
|
||||
|
||||
set(dlls ${libdir}/Yap)
|
||||
|
||||
set(YAP_ROOTDIR ${prefix})
|
||||
# erootdir -> rootdir
|
||||
# libdir defined above
|
||||
@ -307,10 +324,9 @@ set(YAP_LIBDIR ${CMAKE_INSTALL_FULL_LIBDIR})
|
||||
set(YAP_DLLDIR ${CMAKE_INSTALL_FULL_LIBDIR}/Yap)
|
||||
set(YAP_PLDIR ${CMAKE_INSTALL_FULL_DATADIR}/Yap)
|
||||
|
||||
set(YAP_INSTALL_DLLDIR ${CMAKE_INSTALL_LIBDIR}/Yap)
|
||||
set(YAP_INSTALL_PLDIR ${CMAKE_INSTALL_DATADIR}/Yap)
|
||||
|
||||
set(libpl ${YAP_INSTALL_PLDIR})
|
||||
set(YAP_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}/Yap)
|
||||
set(YAP_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR}/Yap)
|
||||
set(YAP_INSTALL_DATADIR ${CMAKE_INSTALL_DATADIR}/Yap)
|
||||
|
||||
#
|
||||
#
|
||||
@ -334,12 +350,12 @@ find_package(GMP)
|
||||
list(APPEND YAP_SYSTEM_OPTIONS big_numbers)
|
||||
|
||||
|
||||
if (GMP_FOUND)
|
||||
|
||||
if (GMP_INCLUDE_DIRS)
|
||||
#config.h needs this (TODO: change in code latter)
|
||||
include_directories(${GMP_INCLUDE_DIRS})
|
||||
endif (GMP_FOUND)
|
||||
endif ()
|
||||
|
||||
option(WITH_READLINE "use readline or libedit" ON)
|
||||
|
||||
if (WITH_READLINE)
|
||||
include(FindReadline)
|
||||
@ -416,7 +432,7 @@ set(DEF_TRAILSPACE 0)
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS DEPTH_LIMIT=1;COROUTINING=1;RATIONAL_TREES=1)
|
||||
|
||||
# inform we are compiling YAP
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "_YAP_NOT_INSTALLED_=1;HAVE_CONFIG_H=1;_GNU_SOURCE")
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "_YAP_NOT_INSTALLED_=1;HAVE_CONFIG_H=1;_GNU_SOURCE=1")
|
||||
|
||||
# Compilation model
|
||||
# target_compile_definitions(libYap PUBLIC _XOPEN_SOURCE=700 )
|
||||
@ -464,9 +480,9 @@ endif ()
|
||||
#
|
||||
#
|
||||
## the RPATH to be used when installing, but only if it's not a system directory
|
||||
#LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${libdir}" isSystemDir)
|
||||
#LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${YAP_INSTALL_LIBDIR}" isSystemDir)
|
||||
# IF("${isSystemDir}" STREQUAL "-1")
|
||||
# SET(CMAKE_INSTALL_RPATH ${libdir})
|
||||
# SET(CMAKE_INSTALL_RPATH ${YAP_INSTALL_LIBDIR})
|
||||
#ENDIF("${isSystemDir}" STREQUAL "-1")
|
||||
#
|
||||
IF(NOT WIN32 AND NOT APPLE)
|
||||
@ -485,7 +501,7 @@ ENDIF()
|
||||
if (HAVE_GCC)
|
||||
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-poinkter;-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 ()
|
||||
@ -495,7 +511,6 @@ endif ()
|
||||
# set_property( DIRECTORY APPEND_STRING PROPERTY -fsanitize=memory;-fsanitize-memory-track-origins=2)
|
||||
if (HAVE_GCC)
|
||||
# replace instructions codes by the address of their code
|
||||
option(WITH_THREADED_CODE "threaded code" ON)
|
||||
if (WITH_THREADED_CODE)
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS THREADED_CODE=1)
|
||||
endif (WITH_THREADED_CODE)
|
||||
@ -504,8 +519,6 @@ endif (HAVE_GCC)
|
||||
#
|
||||
#option (YAP_SWI_IO ON)
|
||||
|
||||
OPTION(WITH_CALL_TRACER
|
||||
"support for procedure-call tracing" ON)
|
||||
#TODO:
|
||||
if (WITH_CALL_TRACER)
|
||||
list(APPEND YAP_SYSTEM_OPTIONS "call_tracer " ${YAP_SYSTEM_OPTIONS})
|
||||
@ -518,11 +531,13 @@ include_directories(utf8proc packages/myddas packages/myddas/sqlite3/src )
|
||||
|
||||
set_property(SOURCE ${LIBYAP_SOURCES} APPEND PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1)
|
||||
|
||||
add_definitions(-DUSE_MYDDAS=1 -DMYDDAS_SQLITE3=1)
|
||||
|
||||
IF (WITH_MYDDAS)
|
||||
if (ANDROID)
|
||||
else()
|
||||
|
||||
add_definitions(-DUSE_MYDDAS=1 -DMYDDAS_SQLITE3=1)
|
||||
|
||||
if (MYSQL_FOUND)
|
||||
add_definitions(= -DMYDDAS_MYSQL=1)
|
||||
endif ()
|
||||
@ -534,9 +549,9 @@ endif ()
|
||||
if (MYSQL_POSTGRES)
|
||||
add_definitions(= -DMYDDAS_POSTGRES=1)
|
||||
endif ()
|
||||
endif()
|
||||
endif(ANDROID)
|
||||
endif(WITH_MYDDAS)
|
||||
|
||||
OPTION(WITH_SWIG " Enable SWIG interfaces to foreign languages" ON)
|
||||
|
||||
IF (WITH_SWIG)
|
||||
find_host_package(SWIG)
|
||||
@ -546,15 +561,11 @@ IF (WITH_SWIG)
|
||||
ENDIF (WITH_SWIG)
|
||||
|
||||
|
||||
option(WITH_PYTHON
|
||||
"Allow Python->YAP and YAP->Python" ON)
|
||||
|
||||
IF (WITH_PYTHON)
|
||||
include(python )
|
||||
ENDIF (WITH_PYTHON)
|
||||
|
||||
option(WITH_R
|
||||
"Use R Interface" ON)
|
||||
|
||||
IF (WITH_R)
|
||||
find_host_package(LibR)
|
||||
@ -568,12 +579,12 @@ List(APPEND YLIBS $<TARGET_OBJECTS:utf8proc>)
|
||||
List(APPEND YLIBS $<TARGET_OBJECTS:myddas>)
|
||||
List(APPEND YLIBS $<TARGET_OBJECTS:libswi>)
|
||||
if (WIN32 OR ANDROID)
|
||||
List(APPEND YLIBS $<TARGET_OBJECTS:YAPsqlite3>)
|
||||
List(APPEND YLIBS $<TARGET_OBJECTS:YAP++>)
|
||||
if (WIN32 AND WITH_PYTHON)
|
||||
List(APPEND YLIBS $<TARGET_OBJECTS:Py4YAP>)
|
||||
endif ()
|
||||
if (ANDROID)
|
||||
List(APPEND YLIBS $<TARGET_OBJECTS:YAPsqlite3>)
|
||||
List(APPEND YLIBS $<TARGET_OBJECTS:YAPJava>)
|
||||
endif ()
|
||||
endif ()
|
||||
@ -606,7 +617,7 @@ endif ()
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(libYap ${WINDLLS})
|
||||
if (PYTHON_INCLUDE_DIRS AND PYTHON_LIBRARIES)
|
||||
if (WITH_PYTHON AND PYTHON_INCLUDE_DIRS AND PYTHON_LIBRARIES)
|
||||
target_link_libraries(libYap ${PYTHON_LIBRARIES})
|
||||
endif ()
|
||||
endif (WIN32)
|
||||
@ -687,7 +698,7 @@ set_target_properties(libYap
|
||||
|
||||
# file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/packages/python/swig/yap4py)
|
||||
|
||||
if (PYTHONLIBS_FOUND AND SWIG_FOUND)
|
||||
if (WITH_PYTHON AND PYTHONLIBS_FOUND AND SWIG_FOUND)
|
||||
set( ENV{PYTHONPATH} ${CMAKE_BINARY_DIR}/packages/python/swig:${CMAKE_BINARY_DIR}/packages/python/yap_kernel:. )
|
||||
add_subdirectory(packages/python/swig)
|
||||
|
||||
@ -728,26 +739,24 @@ if (NOT WIN32)
|
||||
endif ()
|
||||
|
||||
|
||||
option(WITH_JIT
|
||||
"just in Time Clause Compilation" OFF)
|
||||
if (WITH_JIT)
|
||||
add_subDIRECTORY(JIT)
|
||||
endif (WITH_JIT)
|
||||
|
||||
|
||||
if (WITH_XML2 OR WITH_RAPTOR)
|
||||
|
||||
add_subDIRECTORY(packages/raptor)
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
if (WITH_XML)
|
||||
|
||||
add_subDIRECTORY(packages/xml)
|
||||
|
||||
endif ()
|
||||
|
||||
OPTION(WITH_CLPBN " Enable the CLPBN and PFL probabilistic languages" ON)
|
||||
|
||||
OPTION(WITH_CPLINT " Enable the cplint probabilistic language" ON)
|
||||
|
||||
OPTION(WITH_HORUS " Enable the CLPBN and PFL probabilistic languages" ON)
|
||||
|
||||
find_host_package(Doxygen)
|
||||
|
||||
option(WITH_DOCS "Create and install the HTML based API documentation (requires Doxygen)" ${DOXYGEN_FOUND})
|
||||
|
||||
IF (WITH_CLPBN)
|
||||
add_subDIRECTORY(packages/CLPBN)
|
||||
@ -757,37 +766,29 @@ IF (WITH_CPLINT)
|
||||
add_subDIRECTORY(packages/cplint)
|
||||
ENDIF (WITH_CPLINT)
|
||||
|
||||
# please install doxygen for prolog first
|
||||
# git clone http://www.github.com/vscosta/doxygen-yap
|
||||
# cd doxygen-yap
|
||||
# mkdir -p build
|
||||
# cd build
|
||||
# make; sudo make install
|
||||
option(WITH_DOCS
|
||||
"generate YAP docs" OFF)
|
||||
|
||||
IF (WITH_DOCS)
|
||||
get_target_property(YAP_SOURCES libYap SOURCES)
|
||||
|
||||
add_subDIRECTORY(docs)
|
||||
|
||||
|
||||
find_host_package(Doxygen)
|
||||
|
||||
ENDIF (WITH_DOCS)
|
||||
|
||||
# add_subDIRECTORY (packages/cuda)
|
||||
|
||||
option(WITH_GECODE
|
||||
"interface gecode constraint solver" ON)
|
||||
if (WITH_GECODE)
|
||||
add_subDIRECTORY(packages/gecode)
|
||||
endif ()
|
||||
|
||||
option(WITH_LBFGS
|
||||
"interface with lbfgs" ON)
|
||||
|
||||
if (WITH_LBFGS)
|
||||
add_subDIRECTORY(packages/yap-lbfgs)
|
||||
endif ()
|
||||
|
||||
|
||||
|
||||
option(WITH_JAVA "Try to use Java (currently Java 6,7,8)" ON)
|
||||
|
||||
if (WITH_JAVA)
|
||||
#detect java setup, as it is shared between different installations.
|
||||
@ -846,22 +847,52 @@ get_filename_component(JAVA_HOME ${JAVA_INCLUDE_PATH} DIRECTORY)
|
||||
# JAVA_AWT_INCLUDE_PATH = the include path to jawt.h
|
||||
|
||||
|
||||
|
||||
get_filename_component ( JAVA_AWT_DIR ${JAVA_AWT_LIBRARY} DIRECTORY)
|
||||
get_filename_component ( JAVA_JNI_DIR ${JAVA_JVM_LIBRARY} DIRECTORY)
|
||||
list(APPEND CMAKE_INSTALL_RPATH ${JAVA_AWT_DIR};${JAVA_JNI_DIR})
|
||||
if (APPLE)
|
||||
set(CMAKE_MACOSX_RPATH 1)
|
||||
find_library (JLI jli ${JAVA_AWT_DIR}/jli)
|
||||
find_library (JAL JavaApplicationLauncher FRAMEWORK ONLY PATH /System/Library/PrivateFrameworks)
|
||||
find_library (JL JavaLaunching FRAMEWORK ONLY PATH /System/Library/PrivateFrameworks)
|
||||
list(APPEND CMAKE_INSTALL_RPATH ${JAVA_AWT_DIR}/jli)
|
||||
list(APPEND JNI_LIBRARIES ${JLI};${JAL};${JL})
|
||||
endif()
|
||||
|
||||
endif (JNI_FOUND)
|
||||
|
||||
|
||||
endif (Java_Development_FOUND)
|
||||
endif(WITH_JAVA)
|
||||
|
||||
add_subDIRECTORY(packages/jpl)
|
||||
|
||||
endif(WITH_JAVA)
|
||||
|
||||
if (WITH_CUDD)
|
||||
|
||||
add_subDIRECTORY(packages/bdd)
|
||||
|
||||
endif()
|
||||
|
||||
if (WITH_PROBLOG)
|
||||
|
||||
add_subDIRECTORY(packages/ProbLog)
|
||||
|
||||
endif()
|
||||
|
||||
if (WITH_MINISAT)
|
||||
|
||||
add_subDIRECTORY(packages/swi-minisat2)
|
||||
|
||||
endif()
|
||||
|
||||
if (WITH_CLPQR)
|
||||
|
||||
add_subDIRECTORY(packages/clpqr)
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
#todo: use cmake target builds
|
||||
# option (USE_MAXPERFORMANCE
|
||||
@ -879,28 +910,9 @@ add_subDIRECTORY(packages/clpqr)
|
||||
# option (USE_CYGWIN
|
||||
# "use cygwin library in WIN32" OFF)
|
||||
|
||||
option(WITH_PRISM
|
||||
"use PRISM system in YAP" ON)
|
||||
#TODO:
|
||||
|
||||
|
||||
option(WITH_YAP_DLL
|
||||
"compile YAP as a DLL" ON)
|
||||
#TODO:
|
||||
|
||||
option(WITH_YAP_STATIC
|
||||
"compile YAP statically" OFF)
|
||||
#TODO:
|
||||
|
||||
option(WITH_YAP_CONDOR
|
||||
"allow YAP to be used from condor" OFF)
|
||||
|
||||
if (WITH_YAP_CONDOR)
|
||||
# use default allocator
|
||||
set(YAP_STATIC ON)
|
||||
set(YAP_DLL OFF)
|
||||
endif ()
|
||||
|
||||
#TODO: detect arch before allow this option
|
||||
# OPTION(WIN64
|
||||
# "compile YAP for win64" OFF)
|
||||
@ -927,7 +939,7 @@ if (WIN32)
|
||||
set(MSVC_RUNTIME "dynamic")
|
||||
ENDIF (MSVC)
|
||||
|
||||
target_link_libraries(libYap wsock32 ws2_32 Shlwapi)
|
||||
target_link_libraries(libYap wsock32 ws2_32 shlwapi)
|
||||
|
||||
endif (WIN32)
|
||||
|
||||
@ -945,20 +957,12 @@ install(TARGETS libYap yap-bin
|
||||
)
|
||||
|
||||
|
||||
CMAKE_DEPENDENT_OPTION(WITH_SYSTEM_MMAP "Use MMAP for shared memory allocation" ON
|
||||
"NOT WITH_YAPOR_THOR" OFF)
|
||||
|
||||
CMAKE_DEPENDENT_OPTION(WITH_SYSTEM_SHM "Use SHM for shared memory allocation" ON
|
||||
"NOT WITH_YAPOR_THOR; NOT WITH_SYSTEM_MMAP" OFF)
|
||||
|
||||
if (NOT ANDROID)
|
||||
if (WITH_MPI)
|
||||
|
||||
add_subDIRECTORY(library/lammpi)
|
||||
|
||||
if (MPI_C_FOUND)
|
||||
|
||||
CMAKE_DEPENDENT_OPTION(WITH_MPI ON "Interface to OpenMPI/MPICH"
|
||||
"MPI_C_FOUND" OFF)
|
||||
macro_optional_add_subDIRECTORY(library/mpi)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MPI_C_COMPILE_FLAGS} ")
|
||||
include_directories(${MPI_C_INCLUDE_PATH})
|
||||
@ -974,13 +978,13 @@ if (MPI_C_FOUND)
|
||||
endif ()
|
||||
endif (MPI_C_FOUND)
|
||||
|
||||
endif(NOT ANDROID)
|
||||
endif(WITH_MPI)
|
||||
|
||||
## add_subDIRECTORY(utils)
|
||||
|
||||
#
|
||||
|
||||
install(FILES ${INCLUDE_HEADERS} ${CONFIGURATION_HEADERS} DESTINATION ${includedir}/Yap )
|
||||
install(FILES ${INCLUDE_HEADERS} ${CONFIGURATION_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/Yap )
|
||||
|
||||
|
||||
|
||||
|
@ -23,7 +23,7 @@ else()
|
||||
|
||||
MY_install(TARGETS YAP++
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
endif()
|
||||
|
@ -1,7 +1,10 @@
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
#include "inline-only.h"
|
||||
#define _EXPORT_KERNEL 1
|
||||
}
|
||||
|
||||
#include "yapi.hh"
|
||||
|
||||
@ -19,6 +22,8 @@ extern "C" {
|
||||
#include "YapInterface.h"
|
||||
#include "iopreds.h"
|
||||
|
||||
#include "YapInit.h"
|
||||
|
||||
X_API char *Yap_TermToBuffer(Term t, int flags);
|
||||
|
||||
X_API void YAP_UserCPredicate(const char *, YAP_UserCPred, arity_t arity);
|
||||
@ -975,7 +980,7 @@ PredEntry *YAPPredicate::getPred(Term &t, Term &m, CELL *&out) {
|
||||
} else {
|
||||
ap = RepPredProp(PredPropByFunc(f, m));
|
||||
if (out)
|
||||
memmove(out, RepAppl(t) + 1, ap->ArityOfPE * sizeof(CELL));
|
||||
memmove(out, (const CELL *)RepAppl(t) + 1, ap->ArityOfPE * sizeof(CELL));
|
||||
else
|
||||
out = RepAppl(t) + 1;
|
||||
}
|
||||
|
33
CXX/yapi.hh
Normal file → Executable file
33
CXX/yapi.hh
Normal file → Executable file
@ -8,17 +8,27 @@
|
||||
|
||||
#define YAP_CPP_INTERFACE 1
|
||||
|
||||
#include <gmpxx.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
extern "C" {
|
||||
|
||||
#include "YapConfig.h"
|
||||
|
||||
}
|
||||
|
||||
#include <gmpxx.h>
|
||||
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
*
|
||||
* @ingroup fli_c_cxx
|
||||
* @defgroup yap-cplus-interface An object oriented interface for YAP.
|
||||
*
|
||||
* @{
|
||||
1 * @{
|
||||
*
|
||||
*
|
||||
* @brief C++ wrapper to terms, predicates and queries
|
||||
@ -32,17 +42,14 @@
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
// Bad export from Python
|
||||
|
||||
#include <config.h>
|
||||
#include <YapConfig.h>
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
#if YAP_PYTHON
|
||||
|
||||
#include <Python.h>
|
||||
@ -93,22 +100,19 @@ X_API extern void YAP_UserCPredicate(const char *, YAP_UserCPred,
|
||||
X_API extern void YAP_UserCPredicateWithArgs(const char *, YAP_UserCPred,
|
||||
YAP_Arity, YAP_Term);
|
||||
|
||||
X_API extern void YAP_UserBackCPredicate(const char *name,
|
||||
YAP_UserCPred init,
|
||||
YAP_UserCPred cont,
|
||||
YAP_Arity arity, YAP_Arity extra);
|
||||
X_API extern void YAP_UserBackCPredicate(const char *name, YAP_UserCPred init,
|
||||
YAP_UserCPred cont, YAP_Arity arity,
|
||||
YAP_Arity extra);
|
||||
|
||||
X_API extern void YAP_UserBackCutCPredicate(const char *name,
|
||||
YAP_UserCPred init,
|
||||
YAP_UserCPred cont,
|
||||
YAP_UserCPred cut,
|
||||
YAP_Arity arity, YAP_Arity extra);
|
||||
YAP_UserCPred cut, YAP_Arity arity,
|
||||
YAP_Arity extra);
|
||||
|
||||
X_API extern YAP_Term YAP_ReadBuffer(const char *s, YAP_Term *tp);
|
||||
|
||||
extern YAP_Term YAP_MkcharPTerm(char *s);
|
||||
|
||||
|
||||
}
|
||||
|
||||
class YAPEngine;
|
||||
@ -121,7 +125,6 @@ class YAPModule;
|
||||
class YAPError;
|
||||
class YAPPredicate;
|
||||
|
||||
|
||||
#include "yapa.hh"
|
||||
|
||||
#include "yapie.hh"
|
||||
|
@ -29,7 +29,7 @@ class X_API YAPPPredicate;
|
||||
|
||||
/// take information on a Prolog error:
|
||||
class X_API YAPError {
|
||||
int swigcode;
|
||||
//int swigcode;
|
||||
yap_error_descriptor_t *info;
|
||||
|
||||
public:
|
||||
|
@ -525,8 +525,9 @@ public:
|
||||
mk(t);
|
||||
}
|
||||
}
|
||||
/// type check for unbound
|
||||
bool unbound() { return IsUnboundVar(VarOfTerm(gt())); }
|
||||
inline bool isVar() { return true; } /// type check for unbound
|
||||
inline bool isVar() { return true; }
|
||||
inline bool isAtom() { return false; } /// type check for atom
|
||||
inline bool isInteger() { return false; } /// type check for integer
|
||||
inline bool isFloat() { return false; } /// type check for floating-point
|
||||
|
1
H/ATOMS
1
H/ATOMS
@ -106,6 +106,7 @@ A DBref F "$dbref"
|
||||
A DInteger F "$integer"
|
||||
A DebugMeta F "$debug_meta"
|
||||
A DebuggerInput N "debugger_input"
|
||||
A DebuggerOutput N "debugger_output"
|
||||
A Dec10 N "dec10"
|
||||
A Default N "default"
|
||||
A DevNull N "/dev/null"
|
||||
|
@ -19,3 +19,5 @@ add_custom_command( OUTPUT ${CMAKE_TOP_BINARY_DIR}/dlocals.h
|
||||
DEPENDS locals.h )
|
||||
|
||||
|
||||
|
||||
install(FILES ${INCLUDE_HEADERS} ${CORE_HEADERS} ${OPTYap_HEADERS} ${YAPOS_HEADERS} ${CONFIGURATION_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/Yap )
|
||||
|
28
H/TermExt.h
28
H/TermExt.h
@ -388,26 +388,6 @@ INLINE_ONLY bool IsStringTerm(Term t) {
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if !defined(__cplusplus)
|
||||
#include <gmp.h>
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
typedef UInt mp_limb_t;
|
||||
|
||||
typedef struct {
|
||||
Int _mp_size, _mp_alloc;
|
||||
mp_limb_t *_mp_d;
|
||||
} MP_INT;
|
||||
|
||||
typedef struct {
|
||||
MP_INT _mp_num;
|
||||
MP_INT _mp_den;
|
||||
} MP_RAT;
|
||||
|
||||
#endif
|
||||
|
||||
INLINE_ONLY bool IsBigIntTerm(Term);
|
||||
|
||||
INLINE_ONLY bool IsBigIntTerm(Term t) {
|
||||
@ -415,7 +395,13 @@ INLINE_ONLY bool IsBigIntTerm(Term t) {
|
||||
FunctorOfTerm(t) == FunctorBigInt;
|
||||
}
|
||||
|
||||
#ifdef USE_GMP
|
||||
|
||||
#if !defined(__cplusplus)
|
||||
#include <gmp.h>
|
||||
#else
|
||||
#include <gmpxx.h>
|
||||
#endif
|
||||
|
||||
|
||||
Term Yap_MkBigIntTerm(MP_INT *);
|
||||
MP_INT *Yap_BigIntOfTerm(Term);
|
||||
|
26
H/Yap.h
26
H/Yap.h
@ -50,7 +50,7 @@
|
||||
#endif /* THREADS && (YAPOR_COW || YAPOR_SBA || YAPOR_COPY) */
|
||||
|
||||
// Bad export from Python
|
||||
#include "config.h"
|
||||
#include "YapConfig.h"
|
||||
|
||||
#ifndef COROUTINING
|
||||
#define COROUTINING 1
|
||||
@ -74,6 +74,28 @@
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
typedef YAP_Int Int;
|
||||
typedef YAP_UInt UInt;
|
||||
typedef YAP_Short Short;
|
||||
typedef YAP_UShort UShort;
|
||||
|
||||
typedef uint16_t BITS16;
|
||||
typedef int16_t SBITS16;
|
||||
typedef uint32_t BITS32;
|
||||
|
||||
typedef YAP_CELL CELL;
|
||||
|
||||
typedef YAP_Term Term;
|
||||
|
||||
#define WordSize sizeof(BITS16)
|
||||
#define CellSize sizeof(CELL)
|
||||
#define SmallSize sizeof(SMALLUNSGN)
|
||||
|
||||
typedef YAP_Int Int;
|
||||
typedef YAP_Float Float;
|
||||
typedef YAP_handle_t yhandle_t;
|
||||
|
||||
#define TermZERO ((Term)0)
|
||||
/*
|
||||
|
||||
#define RATIONAL_TREES 1
|
||||
@ -754,7 +776,7 @@ extern struct worker_local Yap_local;
|
||||
#define REMOTE(wid) (&Yap_local)
|
||||
#endif
|
||||
|
||||
#include "encoding.h"
|
||||
#include "YapEncoding.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#define YP_FILE FILE
|
||||
|
5
H/YapEval.h
Normal file → Executable file
5
H/YapEval.h
Normal file → Executable file
@ -205,7 +205,6 @@ typedef enum {
|
||||
op_heapused,
|
||||
op_localsp,
|
||||
op_globalsp,
|
||||
op_b,
|
||||
op_env,
|
||||
op_tr,
|
||||
op_stackfree
|
||||
@ -632,13 +631,13 @@ __Yap_Mk64IntegerTerm(YAP_LONG_LONG i USES_REGS) {
|
||||
}
|
||||
|
||||
inline static Term add_int(Int i, Int j USES_REGS) {
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ > 4)
|
||||
Int w;
|
||||
if (!__builtin_add_overflow(i, j, &w))
|
||||
RINT(w);
|
||||
return Yap_gmp_add_ints(i, j);
|
||||
;
|
||||
#elif defined(__GNUC__)
|
||||
#elif defined(__GNUC__) && __GNUC__ > 4
|
||||
Int w;
|
||||
if (!__builtin_add_overflow_p(i, j, w))
|
||||
RINT(w);
|
||||
|
@ -354,8 +354,11 @@ static inline bool verboseMode(void) {
|
||||
return GLOBAL_Flags[VERBOSE_FLAG].at != TermSilent;
|
||||
}
|
||||
|
||||
|
||||
static inline void setVerbosity(Term val) {
|
||||
GLOBAL_Flags[VERBOSE_FLAG].at = val;
|
||||
if (val == TermSilent)
|
||||
GLOBAL_Flags[VERBOSE_LOAD_FLAG].at = TermFalse;
|
||||
}
|
||||
|
||||
static inline bool setSyntaxErrorsFlag(Term val) {
|
||||
|
320
H/YapGFlagInfo.h
320
H/YapGFlagInfo.h
@ -22,30 +22,38 @@
|
||||
@brief global flags and their values.
|
||||
*/
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#define IN_ANDROID "true"
|
||||
#else
|
||||
#define IN_ANDROID "false"
|
||||
#endif
|
||||
|
||||
|
||||
START_GLOBAL_FLAGS
|
||||
|
||||
YAP_FLAG(ADDRESS_BITS_FLAG, "address_bits", false, nat, BITNESS, NULL), /**<
|
||||
/**<
|
||||
Number of address bits in the machine, either 64 or 32 bits.
|
||||
*/
|
||||
YAP_FLAG(ADDRESS_BITS_FLAG, "address_bits", false, nat, BITNESS, NULL),
|
||||
|
||||
YAP_FLAG(AGC_MARGIN_FLAG, "agc_margin", true, nat, "10000",
|
||||
agc_threshold), /**<
|
||||
/**<
|
||||
|
||||
An integer: if this amount of atoms has been created since the last
|
||||
atom-garbage collection, perform atom garbage collection at the first
|
||||
opportunity. Initial value is 10,000. May be changed. A value of 0
|
||||
(zero) disables atom garbage collection.
|
||||
*/
|
||||
YAP_FLAG(AGC_MARGIN_FLAG, "agc_margin", true, nat, "10000",
|
||||
agc_threshold),
|
||||
|
||||
YAP_FLAG(ALLOW_ASSERT_FOR_STATIC_PREDICATES,
|
||||
"allow_assert_for_static_predicates", true, booleanFlag, "true",
|
||||
NULL), /**<
|
||||
/**<
|
||||
boolean: allow asserting and retracting clauses of static
|
||||
predicates. */
|
||||
YAP_FLAG(ALLOW_ASSERT_FOR_STATIC_PREDICATES,
|
||||
"allow_assert_for_static_predicates", true, booleanFlag, "true",
|
||||
NULL),
|
||||
|
||||
YAP_FLAG(ALLOW_VARIABLE_NAME_AS_FUNCTOR_FLAG,
|
||||
"allow_variable_name_as_functor", false, booleanFlag, "false",
|
||||
NULL), /**<
|
||||
/**<
|
||||
|
||||
boolean flag allows syntax such
|
||||
as
|
||||
@ -55,26 +63,31 @@ opportunity. Initial value is 10,000. May be changed. A value of 0
|
||||
Tree(R).
|
||||
~~~
|
||||
*/
|
||||
YAP_FLAG(ALLOW_VARIABLE_NAME_AS_FUNCTOR_FLAG,
|
||||
"allow_variable_name_as_functor", false, booleanFlag, "false",
|
||||
NULL),
|
||||
|
||||
|
||||
YAP_FLAG(ANSWER_FORMAT_FLAG, "answer_format", true, isatom, "~p", NULL),
|
||||
/**< how to present answers, default is `~p`. */
|
||||
#if __ANDROID__
|
||||
YAP_FLAG(ANDROID_FLAG, "android", false, booleanFlag, "true", NULL), /**<
|
||||
YAP_FLAG(ANSWER_FORMAT_FLAG, "answer_format", true, isatom, "~p", NULL),
|
||||
/**<
|
||||
read-only boolean, a machine running an Google's Android version of the
|
||||
Linux Operating System */
|
||||
#endif
|
||||
YAP_FLAG(ANDROID_FLAG, "android", false, booleanFlag, IN_ANDROID, NULL),
|
||||
|
||||
#if __APPLE__
|
||||
YAP_FLAG(APPLE_FLAG, "apple", false, booleanFlag, "true", NULL), /**<
|
||||
/**<
|
||||
read-only boolean, a machine running an Apple Operating System */
|
||||
YAP_FLAG(APPLE_FLAG, "apple", false, booleanFlag, "true", NULL),
|
||||
#else
|
||||
YAP_FLAG(APPLE_FLAG, "apple", false, booleanFlag, "false", NULL),
|
||||
#endif
|
||||
YAP_FLAG(ARCH_FLAG, "arch", false, isatom, YAP_ARCH, NULL), /**<
|
||||
/**<
|
||||
read-only atom, it describes the ISA used in this version of YAP.
|
||||
Available from YAP_ARCH.
|
||||
*/
|
||||
YAP_FLAG(ARCH_FLAG, "arch", false, isatom, YAP_ARCH, NULL),
|
||||
YAP_FLAG(ARGV_FLAG, "argv", false, argv, "@boot", NULL),
|
||||
YAP_FLAG(ARITHMETIC_EXCEPTIONS_FLAG, "arithmetic_exceptions", true,
|
||||
booleanFlag, "true", NULL),
|
||||
/**<
|
||||
|
||||
Read-write flag telling whether arithmetic exceptions generate
|
||||
@ -95,71 +108,79 @@ opportunity. Initial value is 10,000. May be changed. A value of 0
|
||||
It is `true` by default, but it is disabled by packages like CLP(BN) and
|
||||
ProbLog.
|
||||
*/
|
||||
YAP_FLAG(BACK_QUOTES_FLAG, "back_quotes", true, isatom, "true", bqs),
|
||||
YAP_FLAG(ARITHMETIC_EXCEPTIONS_FLAG, "arithmetic_exceptions", true,
|
||||
booleanFlag, "true", NULL),
|
||||
|
||||
/**<
|
||||
If _Value_ is unbound, tell whether a back quoted list of characters
|
||||
token is converted to a list of atoms, `chars`, to a list of integers,
|
||||
`codes`, or to a single atom, `atom`. If _Value_ is bound, set to
|
||||
the corresponding behavior. The default value is `string`
|
||||
*/
|
||||
YAP_FLAG(BOUNDED_FLAG, "bounded", false, booleanFlag, "false", NULL),
|
||||
/**< `bounded` is iso
|
||||
YAP_FLAG(BACK_QUOTES_FLAG, "back_quotes", true, isatom, "true", bqs),
|
||||
|
||||
/**<
|
||||
|
||||
Read-only flag telling whether integers are bounded. The value depends
|
||||
on whether YAP uses the GMP library or not.
|
||||
*/
|
||||
YAP_FLAG(BOUNDED_FLAG, "bounded", false, booleanFlag, "false", NULL),
|
||||
|
||||
|
||||
YAP_FLAG(C_CC_FLAG, "c_cc", false, isatom, C_CC, NULL),
|
||||
YAP_FLAG(C_CFLAGS_FLAG, "c_cflags", false, isatom, C_CFLAGS, NULL),
|
||||
YAP_FLAG(C_LDFLAGS_FLAG, "c_ldflags", false, isatom, C_LDFLAGS, NULL),
|
||||
YAP_FLAG(C_LIBPLSO_FLAG, "c_libplso", false, isatom, C_LIBPLSO, NULL),
|
||||
YAP_FLAG(C_LIBS_FLAG, "c_libs", false, isatom, C_LIBS, NULL),
|
||||
YAP_FLAG(CHAR_CONVERSION_FLAG, "char_conversion", true, booleanFlag,
|
||||
"false", NULL),
|
||||
/**< `char_conversion is iso`
|
||||
|
||||
Writable flag telling whether a character conversion table is used when
|
||||
reading terms. The default value for this flag is `off` except in
|
||||
`sicstus` and `iso` language modes, where it is `on`.
|
||||
*/
|
||||
YAP_FLAG(CHARACTER_ESCAPES_FLAG, "character_escapes", true, booleanFlag,
|
||||
"true", NULL),
|
||||
YAP_FLAG(CHAR_CONVERSION_FLAG, "char_conversion", true, booleanFlag,
|
||||
"false", NULL),
|
||||
|
||||
/**< `
|
||||
|
||||
Writable flag telling whether a character escapes are enabled,
|
||||
`true`, or disabled, `false`. The default value for this flag is
|
||||
`true`. */
|
||||
YAP_FLAG(COLON_SETS_CALLING_CONTEXT_FLAG, "colon_sets_calling_context",
|
||||
true, booleanFlag, "true", NULL),
|
||||
YAP_FLAG(CHARACTER_ESCAPES_FLAG, "character_escapes", true, booleanFlag,
|
||||
"true", NULL),
|
||||
|
||||
/**< `compiled_at `
|
||||
|
||||
Read-only flag that gives the time when the main YAP binary was compiled.
|
||||
It is obtained staight from the __TIME__ macro, as defined in the C99.
|
||||
*/
|
||||
YAP_FLAG(COLON_SETS_CALLING_CONTEXT_FLAG, "colon_sets_calling_context",
|
||||
true, booleanFlag, "true", NULL),
|
||||
|
||||
YAP_FLAG(COMPILED_AT_FLAG, "compiled_at", false, isatom, YAP_COMPILED_AT,
|
||||
NULL),
|
||||
YAP_FLAG(DEBUG_FLAG, "debug", true, booleanFlag, "false", NULL),
|
||||
/**<
|
||||
|
||||
If _Value_ is unbound, tell whether debugging is `true` or
|
||||
`false`. If _Value_ is bound to `true` enable debugging, and if
|
||||
it is bound to `false` disable debugging.
|
||||
*/
|
||||
YAP_FLAG(DEBUG_FLAG, "debug", true, booleanFlag, "false", NULL),
|
||||
|
||||
YAP_FLAG(DEBUG_INFO_FLAG, "debug_info", true, booleanFlag, "true", NULL),
|
||||
YAP_FLAG(DEBUG_ON_ERROR_FLAG, "debug_on_error", true, booleanFlag, "true",
|
||||
NULL),
|
||||
/**<
|
||||
If bound, set the argument to the `write_term/3` options the
|
||||
debugger uses to write terms. If unbound, show the current options.
|
||||
*/
|
||||
YAP_FLAG(DEBUG_ON_ERROR_FLAG, "debug_on_error", true, booleanFlag, "true",
|
||||
NULL),
|
||||
|
||||
YAP_FLAG(DEBUGGER_PRINT_OPTIONS_FLAG, "debugger_print_options", true,
|
||||
list_option,
|
||||
"[quoted(true),numbervars(true),portrayed(true),max_depth(10)]",
|
||||
NULL),
|
||||
YAP_FLAG(DEBUGGER_SHOW_CONTEXT_FLAG, "debugger_show_context", true,
|
||||
booleanFlag, "false", NULL),
|
||||
YAP_FLAG(DEFAULT_PARENT_MODULE_FLAG, "default_parent_module", true, isatom,
|
||||
"user", NULL),
|
||||
/**<
|
||||
* A module to be inherited by all other modules. Default is user that
|
||||
* reexports prolog.
|
||||
@ -167,13 +188,15 @@ opportunity. Initial value is 10,000. May be changed. A value of 0
|
||||
* Set it to `prolog` for SICStus Prolog like resolution, to `user` for
|
||||
* SWI-like.
|
||||
*/
|
||||
YAP_FLAG(DIALECT_FLAG, "dialect", false, ro, "yap", NULL),
|
||||
YAP_FLAG(DEFAULT_PARENT_MODULE_FLAG, "default_parent_module", true, isatom,
|
||||
"user", NULL),
|
||||
|
||||
/**<
|
||||
|
||||
Read-only flag that always returns `yap`.
|
||||
*/
|
||||
YAP_FLAG(DISCONTIGUOUS_WARNINGS_FLAG, "discontiguous_warnings", true,
|
||||
booleanFlag, "true", NULL),
|
||||
YAP_FLAG(DIALECT_FLAG, "dialect", false, ro, "yap", NULL),
|
||||
|
||||
/**<
|
||||
|
||||
If `true` (default `true`) YAP checks for definitions of the same predicate
|
||||
@ -184,35 +207,41 @@ opportunity. Initial value is 10,000. May be changed. A value of 0
|
||||
predicates.
|
||||
|
||||
*/
|
||||
YAP_FLAG(DOLLAR_AS_LOWER_CASE_FLAG, "dollar_as_lower_case", true,
|
||||
booleanFlag, "false", NULL),
|
||||
YAP_FLAG(DISCONTIGUOUS_WARNINGS_FLAG, "discontiguous_warnings", true,
|
||||
booleanFlag, "true", NULL),
|
||||
|
||||
/**<
|
||||
If `off` (default) consider the character `$` a control character, if
|
||||
vxu `on` consider `$` a lower case character.
|
||||
*/
|
||||
YAP_FLAG(DOUBLE_QUOTES_FLAG, "double_quotes", true, isatom, "codes", dqs),
|
||||
YAP_FLAG(DOLLAR_AS_LOWER_CASE_FLAG, "dollar_as_lower_case", true,
|
||||
booleanFlag, "false", NULL),
|
||||
|
||||
/**< iso
|
||||
|
||||
If _Value_ is unbound, tell whether a double quoted list of characters
|
||||
token is converted to a list of atoms, `chars`, to a list of integers,
|
||||
`codes`, or to a single atom, `atom`. If _Value_ is bound, set to
|
||||
the corresponding behavior. The default value is `codes`. */
|
||||
YAP_FLAG(DOUBLE_QUOTES_FLAG, "double_quotes", true, isatom, "codes", dqs),
|
||||
|
||||
YAP_FLAG(EDITOR_FLAG, "editor", true, isatom, "$EDITOR", NULL),
|
||||
YAP_FLAG(EXECUTABLE_FLAG, "executable", false, executable, "@boot", NULL),
|
||||
/**<
|
||||
|
||||
Read-only flag. It unifies with an atom that gives the
|
||||
original program path.
|
||||
*/
|
||||
YAP_FLAG(FAST_FLAG, "fast", true, booleanFlag, "false", NULL),
|
||||
YAP_FLAG(EXECUTABLE_FLAG, "executable", false, executable, "@boot", NULL),
|
||||
|
||||
/**<
|
||||
|
||||
If `on` allow fast machine code, if `off` (default) disable it. Only
|
||||
available in experimental implementations.
|
||||
*/
|
||||
YAP_FLAG(FAST_FLAG, "fast", true, booleanFlag, "false", NULL),
|
||||
|
||||
YAP_FLAG(FILE_NAME_VARIABLES_FLAG, "file_name_variables", true, booleanFlag,
|
||||
"true", NULL),
|
||||
YAP_FLAG(FLOAT_FORMAT_FLAG, "float_format", true, isatom, "%.16f", NULL),
|
||||
/**<
|
||||
|
||||
C-library `printf()` format specification used by write/1 and
|
||||
@ -222,19 +251,22 @@ vxu `on` consider `$` a lower case character.
|
||||
printed, `%g` will print all floats using 6 digits instead of the
|
||||
default 15.
|
||||
*/
|
||||
YAP_FLAG(GC_FLAG, "gc", true, booleanFlag, "on", NULL),
|
||||
YAP_FLAG(FLOAT_FORMAT_FLAG, "float_format", true, isatom, "%.16f", NULL),
|
||||
|
||||
/**< `gc`
|
||||
|
||||
If `on` allow garbage collection (default), if `off` disable it.
|
||||
*/
|
||||
YAP_FLAG(GC_MARGIN_FLAG, "gc_margin", true, nat, "0", gc_margin),
|
||||
YAP_FLAG(GC_FLAG, "gc", true, booleanFlag, "on", NULL),
|
||||
|
||||
/**< `gc_margin `
|
||||
|
||||
Set or show the minimum free stack before starting garbage
|
||||
collection. The default depends on total stack size.
|
||||
|
||||
*/
|
||||
YAP_FLAG(GC_TRACE_FLAG, "gc_trace", true, isatom, "off", NULL),
|
||||
YAP_FLAG(GC_MARGIN_FLAG, "gc_margin", true, nat, "0", gc_margin),
|
||||
|
||||
/**<
|
||||
*
|
||||
If `off` (default) do not show information on garbage collection
|
||||
@ -244,8 +276,8 @@ vxu `on` consider `$` a lower case character.
|
||||
information on data-structures found during the garbage collection
|
||||
process, namely, on choice-points.
|
||||
*/
|
||||
YAP_FLAG(GENERATE_DEBUGGING_INFO_FLAG, "generate_debug_info", true,
|
||||
booleanFlag, "true", NULL),
|
||||
YAP_FLAG(GC_TRACE_FLAG, "gc_trace", true, isatom, "off", NULL),
|
||||
|
||||
/**< `
|
||||
|
||||
If `true` (default) generate debugging information for
|
||||
@ -254,36 +286,41 @@ vxu `on` consider `$` a lower case character.
|
||||
source mode is disabled.
|
||||
|
||||
*/
|
||||
YAP_FLAG(GENERATE_DEBUGGING_INFO_FLAG, "generate_debug_info", true,
|
||||
booleanFlag, "true", NULL),
|
||||
|
||||
YAP_FLAG(GMP_VERSION_FLAG, "gmp_version", false, isatom, "4.8.12", NULL),
|
||||
YAP_FLAG(HALT_AFTER_CONSULT_FLAG, "halt_after_consult", false, booleanFlag,
|
||||
"false", NULL),
|
||||
YAP_FLAG(HOME_FLAG, "home", false, isatom, YAP_ROOTDIR, NULL),
|
||||
/**< home `
|
||||
|
||||
the root of the YAP installation, by default `/usr/local` in Unix or
|
||||
`c:\Yap` in Windows system. Can only be set at configure time
|
||||
*/
|
||||
YAP_FLAG(HOST_TYPE_FLAG, "host_type", false, isatom, HOST_ALIAS, NULL),
|
||||
YAP_FLAG(HOME_FLAG, "home", false, isatom, YAP_ROOTDIR, NULL),
|
||||
|
||||
/**< host_type `
|
||||
|
||||
Return `configure` system information, including the machine-id
|
||||
for which YAP was compiled and Operating System information.
|
||||
*/
|
||||
YAP_FLAG(INDEX_FLAG, "index", true, indexer, "multi", NULL),
|
||||
YAP_FLAG(HOST_TYPE_FLAG, "host_type", false, isatom, HOST_ALIAS, NULL),
|
||||
|
||||
/**< `index `
|
||||
|
||||
If `on` allow indexing (default), if `off` disable it, if
|
||||
`single` allow on first argument only.
|
||||
*/
|
||||
YAP_FLAG(INDEX_SUB_TERM_SEARCH_DEPTH_FLAG, "index_sub_term_search_depth",
|
||||
true, nat, "0", NULL),
|
||||
YAP_FLAG(INDEX_FLAG, "index", true, indexer, "multi", NULL),
|
||||
|
||||
/**< `Index_sub_term_search_depth `
|
||||
|
||||
Maximum bound on searching sub-terms for indexing, if `0` (default) no
|
||||
bound.
|
||||
*/
|
||||
YAP_FLAG(INFORMATIONAL_MESSAGES_FLAG, "informational_messages", true,
|
||||
isatom, "normal", NULL),
|
||||
YAP_FLAG(INDEX_SUB_TERM_SEARCH_DEPTH_FLAG, "index_sub_term_search_depth",
|
||||
true, nat, "0", NULL),
|
||||
|
||||
/**< `informational_messages `
|
||||
|
||||
If `on` allow printing of informational messages, such as the ones
|
||||
@ -291,17 +328,21 @@ vxu `on` consider `$` a lower case character.
|
||||
these messages. It is `on` by default except if YAP is booted with
|
||||
the `-L` flag.
|
||||
*/
|
||||
YAP_FLAG(INTEGER_ROUNDING_FUNCTION_FLAG, "integer_rounding_function", true,
|
||||
isatom, "toward_zero", NULL),
|
||||
YAP_FLAG(INFORMATIONAL_MESSAGES_FLAG, "informational_messages", true,
|
||||
isatom, "normal", NULL),
|
||||
|
||||
/**< `integer_rounding_function is iso `
|
||||
|
||||
Read-only flag telling the rounding function used for integers. Takes the
|
||||
value `toward_zero` for the current version of YAP.
|
||||
*/
|
||||
YAP_FLAG(INTEGER_ROUNDING_FUNCTION_FLAG, "integer_rounding_function", true,
|
||||
isatom, "toward_zero", NULL),
|
||||
|
||||
YAP_FLAG(ISO_FLAG, "iso", true, booleanFlag, "false", NULL),
|
||||
YAP_FLAG(JUPYTER_FLAG, "jupyter", false, booleanFlag, "true", NULL), /**<
|
||||
/**<
|
||||
read-only boolean, a machine running Jupyter */
|
||||
YAP_FLAG(LANGUAGE_FLAG, "language", true, isatom, "yap", NULL),
|
||||
YAP_FLAG(JUPYTER_FLAG, "jupyter", false, booleanFlag, "true", NULL),
|
||||
/**< `language `
|
||||
|
||||
Choose whether YAP follows native, closer to C-Prolog, `yap`, iso-prolog,
|
||||
@ -311,21 +352,26 @@ vxu `on` consider `$` a lower case character.
|
||||
are interpreted, when to use dynamic, character escapes, and how files
|
||||
are consulted. Also check the `dialect` option.
|
||||
*/
|
||||
YAP_FLAG(PROLOG_LIBRARY_DIRECTORY_FLAG, "prolog_library_directory", true,
|
||||
isatom, "", NULL),
|
||||
YAP_FLAG(LANGUAGE_FLAG, "language", true, isatom, "yap", NULL),
|
||||
|
||||
/**< if defined, first location where YAP expects to find the YAP Prolog
|
||||
library. Takes precedence over library_directory */
|
||||
YAP_FLAG(PROLOG_FOREIGN_DIRECTORY_FLAG, "prolog_foreign_directory", true,
|
||||
YAP_FLAG(PROLOG_LIBRARY_DIRECTORY_FLAG, "prolog_library_directory", true,
|
||||
isatom, "", NULL),
|
||||
|
||||
/**< if defined, first location where YAP expects to find the YAP Prolog
|
||||
shared libraries (DLLS). Takes precedence over executable_directory/2. */
|
||||
|
||||
/**< `max_arity is iso `
|
||||
YAP_FLAG(MAX_ARITY_FLAG, "max_arity", false, isatom, "unbounded", NULL),
|
||||
|
||||
Read-only flag telling the maximum arity of a functor. Takes the value
|
||||
`unbounded` for the current version of YAP.
|
||||
*/
|
||||
YAP_FLAG(PROLOG_FOREIGN_DIRECTORY_FLAG, "prolog_foreign_directory", true,
|
||||
isatom, "", NULL),
|
||||
|
||||
|
||||
|
||||
YAP_FLAG(MAX_TAGGED_INTEGER_FLAG, "max_tagged_integer", false, at2n,
|
||||
"INT_MAX", NULL),
|
||||
YAP_FLAG(MAX_THREADS_FLAG, "max_threads", false, at2n, "MAX_THREADS", NULL),
|
||||
@ -336,16 +382,15 @@ vxu `on` consider `$` a lower case character.
|
||||
"256", NULL),
|
||||
YAP_FLAG(OCCURS_CHECK_FLAG, "occurs_check", true, booleanFlag, "false",
|
||||
NULL),
|
||||
YAP_FLAG(OPEN_EXPANDS_FILENAME_FLAG, "open_expands_filename", true,
|
||||
booleanFlag, "false", NULL),
|
||||
/**< `open_expands_filename `
|
||||
|
||||
If `true` the open/3 builtin performs filename-expansion
|
||||
before opening a file (SICStus Prolog like). If `false` it does not
|
||||
(SWI-Prolog like).
|
||||
*/
|
||||
YAP_FLAG(OPEN_SHARED_OBJECT_FLAG, "open_shared_object", true, booleanFlag,
|
||||
"true", NULL),
|
||||
YAP_FLAG(OPEN_EXPANDS_FILENAME_FLAG, "open_expands_filename", true,
|
||||
booleanFlag, "false", NULL),
|
||||
|
||||
/**< `open_shared_object `
|
||||
|
||||
If true, `open_shared_object/2` and friends are implemented,
|
||||
@ -358,6 +403,10 @@ vxu `on` consider `$` a lower case character.
|
||||
program. This is for compatibility with old software that
|
||||
might expect module-independent operators.
|
||||
*/
|
||||
YAP_FLAG(OPEN_SHARED_OBJECT_FLAG, "open_shared_object", true, booleanFlag,
|
||||
"true", NULL),
|
||||
|
||||
|
||||
YAP_FLAG(MODULE_INDEPENDENT_OPERATORS_FLAG, "module_independent_operators",
|
||||
true, booleanFlag, "false", NULL),
|
||||
|
||||
@ -365,7 +414,6 @@ vxu `on` consider `$` a lower case character.
|
||||
YAP_FLAG(OS_ARGV_FLAG, "os_argv", false, os_argv, "@boot", NULL),
|
||||
YAP_FLAG(PID_FLAG, "pid", false, sys_pid, "@boot", NULL),
|
||||
YAP_FLAG(PIPE_FLAG, "pipe", true, booleanFlag, "true", NULL),
|
||||
YAP_FLAG(PROFILING_FLAG, "profiling", true, booleanFlag, "false", NULL),
|
||||
/**< `profiling `
|
||||
|
||||
If `off` (default) do not compile call counting information for
|
||||
@ -373,8 +421,8 @@ vxu `on` consider `$` a lower case character.
|
||||
retries to the predicate may be counted. Profiling data can be read through
|
||||
the call_count_data/3 built-in.
|
||||
*/
|
||||
YAP_FLAG(PROMPT_ALTERNATIVES_ON_FLAG, "prompt_alternatives_on", true,
|
||||
isatom, "determinism", NULL),
|
||||
YAP_FLAG(PROFILING_FLAG, "profiling", true, booleanFlag, "false", NULL),
|
||||
|
||||
/**< `prompt_alternatives_on(atom,
|
||||
changeable) `
|
||||
|
||||
@ -383,17 +431,20 @@ vxu `on` consider `$` a lower case character.
|
||||
and only if the query contains variables. The alternative, default in
|
||||
SWI-Prolog is <tt>determinism</tt> which implies the system prompts for
|
||||
alternatives if the goal succeeded while leaving choicepoints. */
|
||||
YAP_FLAG(PROMPT_ALTERNATIVES_ON_FLAG, "prompt_alternatives_on", true,
|
||||
isatom, "determinism", NULL),
|
||||
|
||||
YAP_FLAG(QUASI_QUOTATIONS_FLAG, "quasi_quotations", true, booleanFlag,
|
||||
"true", NULL),
|
||||
YAP_FLAG(READLINE_FLAG, "readline", true, booleanFlag, "false",
|
||||
Yap_InitReadline),
|
||||
/**< `readline(boolean, changeable)`
|
||||
}
|
||||
|
||||
enable the use of the readline library for console interactions, true by
|
||||
default if readline was found. */
|
||||
YAP_FLAG(REDEFINE_WARNINGS_FLAG, "redefine_warnings", true, booleanFlag,
|
||||
"true", NULL), /**<
|
||||
YAP_FLAG(READLINE_FLAG, "readline", true, booleanFlag, "false",
|
||||
Yap_InitReadline),
|
||||
|
||||
/**<
|
||||
|
||||
If _Value_ is unbound, tell whether warnings for procedures defined
|
||||
in several different files are `on` or
|
||||
@ -401,43 +452,50 @@ in several different files are `on` or
|
||||
and if it is bound to `off` disable them. The default for YAP is
|
||||
`off`, unless we are in `sicstus` or `iso` mode.
|
||||
*/
|
||||
YAP_FLAG(REDEFINE_WARNINGS_FLAG, "redefine_warnings", true, booleanFlag,
|
||||
"true", NULL),
|
||||
YAP_FLAG(REPORT_ERROR_FLAG, "report_error", true, booleanFlag, "true",
|
||||
NULL),
|
||||
YAP_FLAG(RESOURCE_DATABASE_FLAG, "resource_database", false, isatom,
|
||||
YAP_BOOTSTRAP, NULL),
|
||||
|
||||
/**<`resource_database`
|
||||
Name of the resource file (saved-state or Prolog file) used to construct
|
||||
the YAP
|
||||
run-time environment.
|
||||
*/
|
||||
YAP_FLAG(SAVED_PROGRAM_FLAG, "saved_program", false, booleanFlag, "false",
|
||||
NULL),
|
||||
YAP_FLAG(RESOURCE_DATABASE_FLAG, "resource_database", false, isatom,
|
||||
|
||||
YAP_BOOTSTRAP, NULL),
|
||||
|
||||
|
||||
/**<`saved_program`
|
||||
if `true` YAP booted from a `yss` file, usually `startup.yss'. If
|
||||
`false`, YAP booted from a Prolog file, by default `boot.yap`.
|
||||
*/
|
||||
YAP_FLAG(SHARED_OBJECT_EXTENSION_FLAG, "shared_object_extension", false,
|
||||
isatom, SO_EXT, NULL),
|
||||
YAP_FLAG(SAVED_PROGRAM_FLAG, "saved_program", false, booleanFlag, "false",
|
||||
NULL),
|
||||
|
||||
/**< `shared_object_extension `
|
||||
|
||||
Suffix associated with loadable code.
|
||||
*/
|
||||
YAP_FLAG(SHARED_OBJECT_SEARCH_PATH_FLAG, "shared_object_search_path", true,
|
||||
isatom, SO_PATH, NULL),
|
||||
/**< `shared_object_search_path `
|
||||
YAP_FLAG(SHARED_OBJECT_EXTENSION_FLAG, "shared_object_extension", false,
|
||||
isatom, SO_EXT, NULL),
|
||||
|
||||
|
||||
/**<
|
||||
|
||||
Name of the environment variable used by the system to search for shared
|
||||
objects.
|
||||
|
||||
*/
|
||||
YAP_FLAG(SINGLE_QUOTES_FLAG, "single_quotes", true, isatom, "atom", sqf),
|
||||
/**< `single_quoted text is usuallly interpreted as atoms. This flagTerm
|
||||
allows other inerpretations such as strings_contains_strings */
|
||||
YAP_FLAG(SHARED_OBJECT_SEARCH_PATH_FLAG, "shared_object_search_path", true,
|
||||
isatom, SO_PATH, NULL),
|
||||
|
||||
YAP_FLAG(SINGLE_VAR_WARNINGS_FLAG, "single_var_warnings", true, booleanFlag,
|
||||
"true", NULL), /**<
|
||||
/**< single_quoted text is usuallly interpreted as atoms. This flag
|
||||
allows other interpretations such as strings */
|
||||
YAP_FLAG(SINGLE_QUOTES_FLAG, "single_quotes", true, isatom, "atom", sqf),
|
||||
|
||||
|
||||
/**<
|
||||
If `true` (default `true`) YAP checks for singleton
|
||||
variables when loading files. A singleton variable is a
|
||||
variable that appears ony once in a clause. The name
|
||||
@ -445,21 +503,24 @@ and if it is bound to `off` disable them. The default for YAP is
|
||||
starts with underscore are never considered singleton.
|
||||
|
||||
*/
|
||||
YAP_FLAG(SIGNALS_FLAG, "signals", true, booleanFlag, "true", NULL),
|
||||
/**< `signals`
|
||||
YAP_FLAG(SINGLE_VAR_WARNINGS_FLAG, "single_var_warnings", true, booleanFlag,
|
||||
"true", NULL),
|
||||
/**<
|
||||
|
||||
If `true` (default) YAP handles Signals such as `^C`
|
||||
(`SIGINT`).
|
||||
|
||||
*/
|
||||
YAP_FLAG(SOURCE_FLAG, "source", true, booleanFlag, "true", NULL),
|
||||
/**< `source`
|
||||
YAP_FLAG(SIGNALS_FLAG, "signals", true, booleanFlag, "true", NULL),
|
||||
|
||||
/**<
|
||||
|
||||
If `true` maintain the source for all clauses. Notice that this is trivially
|
||||
supported for facts, and always supported for dynamic code.
|
||||
|
||||
*/
|
||||
YAP_FLAG(STRICT_ISO_FLAG, "strict_iso", true, booleanFlag, "false", NULL),
|
||||
YAP_FLAG(SOURCE_FLAG, "source", true, booleanFlag, "true", NULL),
|
||||
|
||||
/**< `strict_iso `
|
||||
|
||||
If _Value_ is unbound, tell whether strict ISO compatibility mode
|
||||
@ -482,8 +543,8 @@ and if it is bound to `off` disable them. The default for YAP is
|
||||
depends on a Prolog's platform specific features.
|
||||
|
||||
*/
|
||||
YAP_FLAG(SYSTEM_OPTIONS_FLAG, "system_options", false, options,
|
||||
SYSTEM_OPTIONS, NULL),
|
||||
YAP_FLAG(STRICT_ISO_FLAG, "strict_iso", true, booleanFlag, "false", NULL),
|
||||
|
||||
/**< `system_options `
|
||||
|
||||
This read only flag tells which options were used to compile
|
||||
@ -492,19 +553,21 @@ and if it is bound to `off` disable them. The default for YAP is
|
||||
`or-parallelism`, `rational_trees`, `readline`, `tabling`,
|
||||
`threads`, or the `wam_profiler`.
|
||||
*/
|
||||
YAP_FLAG(SYSTEM_OPTIONS_FLAG, "system_options", false, options,
|
||||
SYSTEM_OPTIONS, NULL),
|
||||
|
||||
YAP_FLAG(SYSTEM_THREAD_ID_FLAG, "system_thread_id", false, sys_thread_id,
|
||||
"@boot", NULL),
|
||||
YAP_FLAG(TABLING_MODE_FLAG, "tabling_mode", true, isatom, "[]", NULL),
|
||||
/**< `tabling_mode`
|
||||
|
||||
Sets or reads the tabling mode for all tabled predicates. Please
|
||||
(see Tabling) for the list of options.
|
||||
|
||||
*/
|
||||
YAP_FLAG(TABLING_MODE_FLAG, "tabling_mode", true, isatom, "[]", NULL),
|
||||
|
||||
YAP_FLAG(THREADS_FLAG, "threads", false, ro, "MAX_THREADS", NULL),
|
||||
YAP_FLAG(TIMEZONE_FLAG, "timezone", false, ro, "18000", NULL),
|
||||
YAP_FLAG(TOPLEVEL_HOOK_FLAG, "toplevel_hook", true, booleanFlag, "true",
|
||||
NULL),
|
||||
/**< `toplevel_hook `
|
||||
|
||||
If bound, set the argument to a goal to be executed before entering the
|
||||
@ -513,6 +576,9 @@ and if it is bound to `off` disable them. The default for YAP is
|
||||
backtracked into.
|
||||
|
||||
*/
|
||||
YAP_FLAG(TOPLEVEL_HOOK_FLAG, "toplevel_hook", true, booleanFlag, "true",
|
||||
NULL),
|
||||
|
||||
YAP_FLAG(TOPLEVEL_PRINT_ANON_FLAG, "toplevel_print_anon", true, booleanFlag,
|
||||
"true", NULL),
|
||||
YAP_FLAG(TOPLEVEL_PRINT_OPTIONS_FLAG, "toplevel_print_options", true,
|
||||
@ -521,7 +587,6 @@ and if it is bound to `off` disable them. The default for YAP is
|
||||
YAP_FLAG(TOPLEVEL_PROMPT_FLAG, "toplevel_prompt", true, isatom, "?- ",
|
||||
mkprompt),
|
||||
YAP_FLAG(TTY_CONTROL_FLAG, "tty_control", true, booleanFlag, "true", NULL),
|
||||
YAP_FLAG(UNIX_FLAG, "unix", false, ro, "true", NULL),
|
||||
/**< `unix`
|
||||
|
||||
Read-only BooleanFlag flag that unifies with `true` if YAP is
|
||||
@ -537,9 +602,11 @@ and if it is bound to `off` disable them. The default for YAP is
|
||||
procedures follow logical semantics but the internal data base still
|
||||
follows immediate semantics.
|
||||
*/
|
||||
YAP_FLAG(UNIX_FLAG, "unix", false, ro, "true", NULL),
|
||||
|
||||
|
||||
YAP_FLAG(UPDATE_SEMANTICS_FLAG, "update_semantics", true, isatom, "logical",
|
||||
NULL),
|
||||
YAP_FLAG(USER_FLAGS_FLAG, "user_flags", true, isatom, "error", NULL),
|
||||
/**<
|
||||
`user_flags `
|
||||
|
||||
@ -551,18 +618,20 @@ and if it is bound to `off` disable them. The default for YAP is
|
||||
developers are encouraged to use `create_prolog_flag/3` to create flags for
|
||||
their library.
|
||||
*/
|
||||
YAP_FLAG(UNKNOWN_FLAG, "unknown", true, isatom, "error", Yap_unknown),
|
||||
YAP_FLAG(USER_FLAGS_FLAG, "user_flags", true, isatom, "error", NULL),
|
||||
|
||||
/**< `unknown is iso`
|
||||
|
||||
Corresponds to calling the unknown/2 built-in. Possible ISO values
|
||||
are `error`, `fail`, and `warning`. Yap includes the following extensions:
|
||||
`fast_fail` does not invoke any handler.
|
||||
*/
|
||||
YAP_FLAG(UNKNOWN_FLAG, "unknown", true, isatom, "error", Yap_unknown),
|
||||
|
||||
YAP_FLAG(VARIABLE_NAMES_MAY_END_WITH_QUOTES_FLAG,
|
||||
"variable_names_may_end_with_quotes", true, booleanFlag, "false",
|
||||
NULL),
|
||||
YAP_FLAG(VERBOSE_FLAG, "verbose", true, isatom, "normal", NULL),
|
||||
/**< `verbose `
|
||||
/**<
|
||||
|
||||
If `normal` allow printing of informational and banner messages,
|
||||
such as the ones that are printed when consulting. If `silent`
|
||||
@ -570,66 +639,75 @@ and if it is bound to `off` disable them. The default for YAP is
|
||||
YAP is booted with the `-q` or `-L` flag.
|
||||
|
||||
*/
|
||||
YAP_FLAG(VERBOSE_FILE_SEARCH_FLAG, "verbose_file_search", true, booleanFlag,
|
||||
"false", NULL),
|
||||
/**< `verbose_file_search `
|
||||
YAP_FLAG(VERBOSE_FLAG, "verbose", true, isatom, "normal", NULL),
|
||||
|
||||
/**<
|
||||
|
||||
If `true` allow printing of informational messages when
|
||||
searching for file names. If `false` disable printing these messages. It
|
||||
is `false` by default except if YAP is booted with the `-L`
|
||||
flag.
|
||||
*/
|
||||
YAP_FLAG(VERBOSE_LOAD_FLAG, "verbose_load", true, isatom, "normal", NULL),
|
||||
/**< `verbose_load `
|
||||
YAP_FLAG(VERBOSE_FILE_SEARCH_FLAG, "verbose_file_search", true, booleanFlag,
|
||||
"false", NULL),
|
||||
|
||||
/**<
|
||||
|
||||
If `true` allow printing of informational messages when
|
||||
consulting files. If `false` disable printing these messages. It
|
||||
is `normal` by default except if YAP is booted with the `-L`
|
||||
is `true` by default except if YAP is booted with the `-L`
|
||||
flag.
|
||||
*/
|
||||
YAP_FLAG(VERSION_FLAG, "version", false, nat, YAP_NUMERIC_VERSION, NULL),
|
||||
YAP_FLAG(VERBOSE_LOAD_FLAG, "verbose_load", true, booleanFlag, "true", NULL),
|
||||
|
||||
/**<
|
||||
`version ` Read-only flag that returns a compound term with the
|
||||
Read-only flag that returns a compound term with the
|
||||
current version of YAP. The term will have the name `yap` and arity 4, the
|
||||
first argument will be the major version, the second the minor version, the
|
||||
third the patch number, and the last one is reserved.
|
||||
|
||||
*/
|
||||
YAP_FLAG(VERSION_DATA_FLAG, "version_data", false, ro, YAP_TVERSION, NULL),
|
||||
/**< `version_data `
|
||||
YAP_FLAG(VERSION_FLAG, "version", false, nat, YAP_NUMERIC_VERSION, NULL),
|
||||
|
||||
/**<
|
||||
|
||||
Read-only flag that unifies with a number of the form
|
||||
`_Major_ * 100000 + _Minor_ *100 + _Patch_`, where
|
||||
_Major_ is the major version, _Minor_ is the minor version,
|
||||
and _Patch_ is the patch number.
|
||||
*/
|
||||
YAP_FLAG(VERSION_GIT_FLAG, "version_git", false, isatom, YAP_GIT_HEAD,
|
||||
NULL),
|
||||
/**< `version_git `
|
||||
YAP_FLAG(VERSION_DATA_FLAG, "version_data", false, ro, YAP_TVERSION, NULL),
|
||||
|
||||
/**<
|
||||
`
|
||||
this is the unique identifier for the last commit of the current GIT HEAD,
|
||||
it xan be used to identify versions that differ on small (or large) updates.
|
||||
*/
|
||||
YAP_FLAG(WRITE_ATTRIBUTES_FLAG, "write_attributes", true, isatom, "ignore",
|
||||
YAP_FLAG(VERSION_GIT_FLAG, "version_git", false, isatom, YAP_GIT_HEAD,
|
||||
NULL),
|
||||
#if __WINDOWS__
|
||||
/**< `windows`
|
||||
|
||||
/**<
|
||||
|
||||
Read-only booleanFlag flag that unifies with `true` if YAP is
|
||||
running on an Windows machine.
|
||||
*/
|
||||
YAP_FLAG(WRITE_ATTRIBUTES_FLAG, "write_attributes", true, isatom, "ignore",
|
||||
NULL),
|
||||
#if __WINDOWS__
|
||||
|
||||
YAP_FLAG(WINDOWS_FLAG, "windows", false, ro, "true", NULL),
|
||||
#endif
|
||||
YAP_FLAG(WRITE_STRINGS_FLAG, "write_strings", true, booleanFlag, "false",
|
||||
NULL),
|
||||
|
||||
/**< `write_strings `
|
||||
/**<
|
||||
|
||||
Writable flag telling whether the system should write lists of
|
||||
integers that are writable character codes using the list notation. It
|
||||
is `on` if enables or `off` if disabled. The default value for
|
||||
this flag is `off`.
|
||||
*/
|
||||
YAP_FLAG(WRITE_STRINGS_FLAG, "write_strings", true, booleanFlag, "false",
|
||||
NULL),
|
||||
|
||||
|
||||
END_GLOBAL_FLAGS
|
||||
|
||||
//! @}
|
||||
|
@ -218,9 +218,9 @@ INLINE_ONLY yhandle_t Yap_InitHandle__(Term t USES_REGS) {
|
||||
ensure_slots(1 PASS_REGS);
|
||||
if (t==0) {
|
||||
t = MkVarTerm();
|
||||
} else if (IsVarTerm(t) ) {
|
||||
} else if (IsVarTerm(t) && VarOfTerm(t) > HR ) {
|
||||
Term tg = MkVarTerm();
|
||||
Bind_Global( VarOfTerm(t), tg);
|
||||
Bind_Local(VarOfTerm(t), tg);
|
||||
}
|
||||
LOCAL_HandleBase[old_slots] = t;
|
||||
LOCAL_CurHandle++;
|
||||
|
@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* YAP Prolog *
|
||||
@ -28,13 +26,13 @@
|
||||
|
||||
START_LOCAL_FLAGS
|
||||
|
||||
/** + `autoload`: set the system to look for undefined procedures */
|
||||
/**< set the system to look for undefined procedures */
|
||||
YAP_FLAG(AUTOLOAD_FLAG, "autoload", true, booleanFlag, "false", NULL),
|
||||
/** + `read-only flag, that tells if Prolog is in an inner top-level */
|
||||
YAP_FLAG(BREAK_LEVEL_FLAG, "break_level", true, nat, "0", NULL),
|
||||
YAP_FLAG(CALL_COUNTING_FLAG, "call_counting", true, booleanFlag, "true",
|
||||
NULL), /** + `call_counting`
|
||||
|
||||
/**<`read-only flag, that tells if Prolog is in an inner top-level */
|
||||
YAP_FLAG(BREAK_LEVEL_FLAG, "break_level", true, nat, "0", NULL),
|
||||
|
||||
/**<
|
||||
Predicates compiled with this flag set maintain a counter
|
||||
on the numbers of proceduree calls and of retries. These counters
|
||||
are decreasing counters, and they can be used as timers. Three
|
||||
@ -51,28 +49,36 @@ YAP_FLAG(AUTOLOAD_FLAG, "autoload", true, booleanFlag, "false", NULL),
|
||||
If `on` `fileerrors` is `on`, if `off` (default)
|
||||
`fileerrors` is disabled.
|
||||
*/
|
||||
YAP_FLAG(ENCODING_FLAG, "encoding", true, isatom, "utf-8", getenc),
|
||||
YAP_FLAG(FILEERRORS_FLAG, "fileerrors", true, booleanFlag, "true",
|
||||
NULL), /** + `fileerrors`
|
||||
YAP_FLAG(CALL_COUNTING_FLAG, "call_counting", true, booleanFlag, "true",
|
||||
NULL),
|
||||
|
||||
If `on` `fileerrors` is `on`, if `off` (default)
|
||||
`fileerrors` is disabled.
|
||||
/**< support for coding systens, YAP relies on UTF-8 internally.
|
||||
*/
|
||||
YAP_FLAG(ENCODING_FLAG, "encoding", true, isatom, "utf-8", getenc),
|
||||
|
||||
/** + what to do if opening a file fails.
|
||||
|
||||
*/
|
||||
YAP_FLAG(FILEERRORS_FLAG, "fileerrors", true, booleanFlag, "true",
|
||||
NULL),
|
||||
|
||||
/**<
|
||||
|
||||
whether native mode or trying to emulate a different
|
||||
Prolog.
|
||||
*/
|
||||
YAP_FLAG(LANGUAGE_MODE_FLAG, "language_mode", true, isatom, "yap",
|
||||
NULL), /** + `language_mode`
|
||||
|
||||
wweter native mode or trying to emulate a different Prolog.
|
||||
*/
|
||||
NULL),
|
||||
YAP_FLAG(STACK_DUMP_ON_ERROR_FLAG, "stack_dump_on_error", true, booleanFlag,
|
||||
"true", NULL), /** + `stack_dump_on_error `
|
||||
"true", NULL),
|
||||
/**<`
|
||||
|
||||
If `true` show a stack dump when YAP finds an error. The default is
|
||||
`off`.
|
||||
*/
|
||||
YAP_FLAG(STREAM_TYPE_CHECK_FLAG, "stream_type_check", true, isatom, "loose",
|
||||
NULL),
|
||||
YAP_FLAG(SYNTAX_ERRORS_FLAG, "syntax_errors", true, synerr, "error",
|
||||
NULL), /** + `syntax_errors`
|
||||
/** + `syntax_errors`
|
||||
|
||||
Control action to be taken after syntax errors while executing read/1,
|
||||
`read/2`, or `read_term/3`:
|
||||
@ -85,16 +91,17 @@ Report the syntax error and generate an error (default).
|
||||
+ `quiet`
|
||||
Just fail
|
||||
*/
|
||||
YAP_FLAG(TYPEIN_MODULE_FLAG, "typein_module", true, isatom, "user",
|
||||
typein), /** + `typein_module `
|
||||
|
||||
YAP_FLAG(SYNTAX_ERRORS_FLAG, "syntax_errors", true, synerr, "error",
|
||||
NULL),
|
||||
/**<
|
||||
If bound, set the current working or type-in module to the argument,
|
||||
which must be an atom. If unbound, unify the argument with the current
|
||||
working module.
|
||||
|
||||
*/
|
||||
YAP_FLAG(USER_ERROR_FLAG, "user_error", true, stream, "user_error",
|
||||
set_error_stream), /** + `user_error1`
|
||||
YAP_FLAG(TYPEIN_MODULE_FLAG, "typein_module", true, isatom, "user",
|
||||
typein),
|
||||
/**<
|
||||
|
||||
If the second argument is bound to a stream, set user_error to
|
||||
this stream. If the second argument is unbound, unify the argument with
|
||||
@ -125,6 +132,8 @@ prompts from the system were redirected to the stream
|
||||
automatically redirects the user_error alias to the original
|
||||
`stderr`.
|
||||
*/
|
||||
YAP_FLAG(USER_ERROR_FLAG, "user_error", true, stream, "user_error",
|
||||
set_error_stream),
|
||||
YAP_FLAG(USER_INPUT_FLAG, "user_input", true, stream, "user_input",
|
||||
set_input_stream),
|
||||
YAP_FLAG(USER_OUTPUT_FLAG, "user_output", true, stream, "user_output",
|
||||
|
116
H/YapTerm.h
116
H/YapTerm.h
@ -1,116 +0,0 @@
|
||||
/*************************************************************************
|
||||
* *
|
||||
* YAP Prolog %W% %G% *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
* *
|
||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: Yap.h *
|
||||
* mods: *
|
||||
* comments: abstract type definitions for YAP *
|
||||
* version: $Id: Yap.h,v 1.38 2008-06-18 10:02:27 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef YAP_H
|
||||
#include "YapTermConfig.h"
|
||||
#include "config.h"
|
||||
|
||||
typedef void *Functor;
|
||||
typedef void *Atom;
|
||||
|
||||
#endif
|
||||
|
||||
#if HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#if HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#define ALIGN_BY_TYPE(X, TYPE) \
|
||||
(((CELL)(X) + (sizeof(TYPE) - 1)) & ~(sizeof(TYPE) - 1))
|
||||
|
||||
#ifndef EXTERN
|
||||
#ifdef MSC_VER
|
||||
#define EXTERN
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* defines integer types Int and UInt (unsigned) with the same size as a ptr
|
||||
** and integer types Short and UShort with half the size of a ptr */
|
||||
|
||||
#if defined(PRIdPTR)
|
||||
|
||||
typedef intptr_t Int;
|
||||
typedef uintptr_t UInt;
|
||||
|
||||
#elif defined(_WIN64)
|
||||
|
||||
|
||||
typedef int64_t Int;
|
||||
typedef uint64_t UInt;
|
||||
|
||||
#elif defined(_WIN32)
|
||||
|
||||
typedef int32_t Int;
|
||||
typedef uint32_t UInt;
|
||||
|
||||
#elif SIZEOF_LONG_INT == SIZEOF_INT_P
|
||||
|
||||
typedef long int Int;
|
||||
typedef unsigned long int UInt;
|
||||
|
||||
#elif SIZEOF_INT == SIZEOF_INT_P
|
||||
|
||||
typedef int Int;
|
||||
typedef unsigned int UInt;
|
||||
|
||||
#else
|
||||
#error Yap require integer types of the same size as a pointer
|
||||
#endif
|
||||
|
||||
/* */ typedef short int Short;
|
||||
/* */ typedef unsigned short int UShort;
|
||||
|
||||
typedef UInt CELL;
|
||||
|
||||
typedef uint16_t BITS16;
|
||||
typedef int16_t SBITS16;
|
||||
typedef uint32_t BITS32;
|
||||
|
||||
#define WordSize sizeof(BITS16)
|
||||
#define CellSize sizeof(CELL)
|
||||
#define SmallSize sizeof(SMALLUNSGN)
|
||||
|
||||
#include "YapFormat.h"
|
||||
|
||||
/*************************************************************************************************
|
||||
type casting macros
|
||||
*************************************************************************************************/
|
||||
|
||||
typedef UInt Term;
|
||||
|
||||
typedef Int yhandle_t;
|
||||
|
||||
typedef double Float;
|
||||
|
||||
#if SIZEOF_INT < SIZEOF_INT_P
|
||||
#define SHORT_INTS 1
|
||||
#else
|
||||
#define SHORT_INTS 0
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
typedef long long int YAP_LONG_LONG;
|
||||
typedef unsigned long long int YAP_ULONG_LONG;
|
||||
#else
|
||||
typedef long int YAP_LONG_LONG;
|
||||
typedef unsigned long int YAP_ULONG_LONG;
|
||||
#endif
|
||||
|
||||
#define Unsigned(V) ((CELL)(V))
|
||||
#define Signed(V) ((Int)(V))
|
@ -175,7 +175,10 @@ INLINE_ONLY char_kind_t chtype(Int ch) {
|
||||
#endif
|
||||
|
||||
extern const char *Yap_tokText(void *tokptr);
|
||||
extern Term Yap_tokRep(void *tokptr);
|
||||
/// represent token *_tokptr_ in string s, maxlength is sz-1
|
||||
///
|
||||
/// conversion is based on token type.
|
||||
extern Term Yap_tokRep(void *tokptrXS);
|
||||
|
||||
// standard strings
|
||||
|
||||
|
@ -128,6 +128,7 @@ extern X_API Int YAP_RunGoalOnce(Term);
|
||||
/* cdmgr.c */
|
||||
extern Term Yap_all_calls(void);
|
||||
extern Atom Yap_ConsultingFile(USES_REGS1);
|
||||
extern bool Yap_Consulting(USES_REGS1);
|
||||
extern struct pred_entry *Yap_PredForChoicePt(choiceptr bptr, op_numbers *op);
|
||||
extern void Yap_InitCdMgr(void);
|
||||
extern struct pred_entry *Yap_PredFromClause(Term t USES_REGS);
|
||||
@ -390,8 +391,7 @@ extern void Yap_InitSortPreds(void);
|
||||
|
||||
/* stack.c */
|
||||
extern void Yap_InitStInfo(void);
|
||||
extern void Yap_dump_stack(void);
|
||||
extern void Yap_output_bug_location(yamop *yap_pc, int where_from, int psize);
|
||||
extern char *Yap_output_bug_location(yamop *yap_pc, int where_from, int psize);
|
||||
|
||||
#if !defined(YAPOR) && !defined(THREADS)
|
||||
extern bool Yap_search_for_static_predicate_in_use(struct pred_entry *, bool);
|
||||
@ -470,7 +470,7 @@ extern void Yap_InitAbsmi(void);
|
||||
extern void Yap_InitUnify(void);
|
||||
extern void Yap_TrimTrail(void);
|
||||
extern int Yap_Unifiable(Term d0, Term d1);
|
||||
extern int Yap_IUnify(register CELL d0, register CELL d1);
|
||||
extern int Yap_IUnify( CELL d0, CELL d1);
|
||||
|
||||
/* userpreds.c */
|
||||
extern void Yap_InitUserCPreds(void);
|
||||
|
@ -1529,6 +1529,11 @@ extern bool Yap_HasException(void);
|
||||
extern yap_error_descriptor_t *Yap_GetException();
|
||||
extern void Yap_PrintException(yap_error_descriptor_t *i);
|
||||
INLINE_ONLY bool Yap_HasException(void) {
|
||||
extern yap_error_number Yap_MathException__(USES_REGS1);
|
||||
yap_error_number me;
|
||||
if ((me = Yap_MathException__(PASS_REGS1)) && LOCAL_ActiveError->errorNo != YAP_NO_ERROR) {
|
||||
LOCAL_ActiveError->errorNo = me;
|
||||
}
|
||||
return LOCAL_ActiveError->errorNo != YAP_NO_ERROR;
|
||||
}
|
||||
|
||||
|
@ -24,13 +24,13 @@ inline static int sub_overflow(Int x, Int i, Int j) {
|
||||
}
|
||||
|
||||
inline static Term sub_int(Int i, Int j USES_REGS) {
|
||||
#if defined(__clang__ ) || defined(__GNUC__)
|
||||
#if defined(__clang__ ) || (defined(__GNUC__) && __GNUC__ > 4)
|
||||
Int k;
|
||||
if (__builtin_sub_overflow(i,j,&k)) {
|
||||
return Yap_gmp_sub_ints(i, j);
|
||||
}
|
||||
RINT(k);
|
||||
#elif defined(__GNUC__)
|
||||
#elif defined(__GNUC__) && __GNUC__ >4
|
||||
Int w;
|
||||
if (!__builtin_sub_overflow_p(i,j,w))
|
||||
RINT(w);
|
||||
@ -64,7 +64,7 @@ inline static int mul_overflow(Int z, Int i1, Int i2) {
|
||||
return (i2 && z / i2 != i1);
|
||||
}
|
||||
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ > 4)
|
||||
#define DO_MULTI() \
|
||||
if (__builtin_mul_overflow(i1, i2, &z)) { \
|
||||
goto overflow; \
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "config.h"
|
||||
#include "YapConfig.h"
|
||||
#include "udi.h"
|
||||
#include "utarray.h"
|
||||
#include "uthash.h"
|
||||
@ -19,8 +19,7 @@ UT_icd cl_icd = {sizeof(yamop *), NULL, NULL, NULL };
|
||||
* All the info we need to enter user indexed code
|
||||
* stored in a uthash
|
||||
*/
|
||||
struct udi_info
|
||||
{
|
||||
struct udi_info {
|
||||
PredEntry *p; // predicate (need to identify asserts)
|
||||
UT_array *clauselist; // clause list used on returns
|
||||
UT_array *args; // indexed args
|
||||
@ -44,18 +43,15 @@ static YAP_Int p_udi_args_init(Term spec, int arity, UdiInfo blk);
|
||||
|
||||
/* single indexing helpers (no intersection needed just create clauselist) */
|
||||
#include "clause_list.h"
|
||||
struct si_callback_h
|
||||
{
|
||||
struct si_callback_h {
|
||||
clause_list_t cl;
|
||||
UT_array *clauselist;
|
||||
void *pred;
|
||||
};
|
||||
typedef struct si_callback_h *si_callback_h_t;
|
||||
|
||||
static inline int si_callback(void *key, void *data, void *arg)
|
||||
{
|
||||
static inline int si_callback(void *key, void *data, void *arg) {
|
||||
si_callback_h_t c = (si_callback_h_t)arg;
|
||||
yamop **cl = (yamop **)utarray_eltptr(c->clauselist, ((YAP_Int)data) - 1);
|
||||
return Yap_ClauseListExtend(c->cl, *cl, c->pred);
|
||||
}
|
||||
|
||||
|
@ -65,12 +65,11 @@ add_lib (libyapjit
|
||||
|
||||
set_target_properties(libyapjit
|
||||
PROPERTIES
|
||||
# RPATH ${libdir} VERSION ${LIBJIT_FULL_VERSION}
|
||||
SOVERSION ${LIBJIT_MAJOR_VERSION}.${LIBJIT_MINOR_VERSION}
|
||||
POSITION_INDEPENDENT_CODE TRUE
|
||||
OUTPUT_NAME YapJIT
|
||||
)
|
||||
|
||||
target_link_libraries(libyapjit libYap ${LLVM_LIBRARIES} z)
|
||||
target_link_libraries(libyapjit libYap ${LLVM_LIBRARIES})
|
||||
|
||||
set ( YAP_YAPJITLIB $<TARGET_FILE_NAME:libyapjit> )
|
||||
|
@ -71,7 +71,7 @@ add_component (libOPTYap
|
||||
|
||||
My_set_target_properties(libOPTYap
|
||||
PROPERTIES
|
||||
# RPATH ${libdir} VERSION ${LIBYAPTAI_FULL_VERSION}
|
||||
# RPATH ${CMAKE_INSTALL_LIBDIR} VERSION ${LIBYAPTAI_FULL_VERSION}
|
||||
# SOVERSION ${LIBYAPTAI_MAJOR_VERSION}.${LIBYAPTAI_MINOR_VERSION}
|
||||
POSITION_INDEPENDENT_CODE TRUE
|
||||
OUTPUT_NAME OPTYap
|
||||
|
@ -159,8 +159,8 @@ target_link_libraries(yap-bin libYap )
|
||||
|
||||
install(TARGETS libYap yap-bin
|
||||
RUNTIME DESTINATION ${bindir}
|
||||
LIBRARY DESTINATION ${libdir}
|
||||
ARCHIVE DESTINATION ${libdir}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
``
|
||||
<center>
|
||||
![The YAP Logo](docs/icons/yap_128x128x32.png)
|
||||
</center>
|
||||
<p align="center">
|
||||
<img src="./docs/icons/yap_128x128x32.png" alt="The YAP Logo"/>
|
||||
</p>
|
||||
|
||||
NOTE: this version of YAP is still experimental, documentation may be out of date.
|
||||
|
||||
|
@ -55,4 +55,6 @@
|
||||
#endif
|
||||
|
||||
|
||||
#include "YapTerm.h"
|
||||
|
||||
#endif
|
||||
|
@ -137,10 +137,8 @@ endif()
|
||||
set ( libpl ${datarootdir}/Yap)
|
||||
set ( includedir "${prefix}/include")
|
||||
set ( exec_prefix "${prefix}")
|
||||
set ( libdir "${exec_prefix}/lib")
|
||||
set ( datadir "${datarootdir}")
|
||||
set ( mandir "${datarootdir}/man")
|
||||
set ( bindir "${exec_prefix}/bin")
|
||||
set ( docdir "${datarootdir}/doc/Yap")
|
||||
set ( dlls "${exec_prefix}/lib/Yap")
|
||||
|
||||
@ -149,10 +147,10 @@ set(YAP_ROOTDIR ${prefix})
|
||||
# erootdir -> rootdir
|
||||
# bindir defined above
|
||||
# libdir defined above
|
||||
set(YAP_LIBDIR "${dlls}")
|
||||
set(YAP_LIBDIR "${YAP_INSTALL_LIBDIR}")
|
||||
set(YAP_SHAREDIR "${datarootdir}")
|
||||
set(YAP_BINDIR "${bindir}")
|
||||
set(YAP_INCLUDEDIR "${includedir}")
|
||||
set(YAP_BINDIR "${CMAKE_INSTALL_BINDIR}")
|
||||
set(YAP_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
set(YAP_ROOTDIR "${prefix}")
|
||||
|
||||
#
|
||||
|
@ -253,8 +253,6 @@ set (OPTYap_HEADERS
|
||||
)
|
||||
|
||||
set (YAPOS_HEADERS
|
||||
${CMAKE_SOURCE_DIR}/os/encoding.h
|
||||
${CMAKE_SOURCE_DIR}/os/fmemopen.h
|
||||
${CMAKE_SOURCE_DIR}/os/format.h
|
||||
${CMAKE_SOURCE_DIR}/os/getw.h
|
||||
${CMAKE_SOURCE_DIR}/os/iopreds.h
|
||||
|
@ -1884,7 +1884,9 @@ signal. */
|
||||
#endif
|
||||
|
||||
/* use bignums/rationals in YAP code. */
|
||||
#ifndef USE_GMP
|
||||
#if defined( __ANDROID__ ) && !defined(USE_GMP)
|
||||
#define USE_GMP 1
|
||||
#elif !defined(USE_GMP)
|
||||
#define USE_GMP ${GMP_FOUND}
|
||||
#endif
|
||||
|
||||
@ -2115,4 +2117,6 @@ calls it, or to nothing if 'inline' is not supported under any name. */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "YapTermConfig.h"
|
||||
|
||||
#endif
|
||||
|
12
configure
vendored
12
configure
vendored
@ -165,7 +165,7 @@ print_help() {
|
||||
--mandir=DIR man documentation [DATAROOTDIR/man]
|
||||
--docdir=DIR documentation root [DATAROOTDIR/doc/PROJECT_NAME]
|
||||
|
||||
--generator=Generator Specify the tool used to send callss
|
||||
--generator=GENERATOR Specify the tool used to send callss
|
||||
EOF
|
||||
|
||||
first=y
|
||||
@ -220,6 +220,8 @@ EOF
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
while [ $# != 0 ]; do
|
||||
case "$1" in
|
||||
"--cmake="*)
|
||||
@ -291,10 +293,10 @@ while [ $# != 0 ]; do
|
||||
"--docdir")
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_DOCDIR=$(quote "$2")"; shift;;
|
||||
|
||||
"-G="|"--generator="*)
|
||||
CMAKE_ARGS+="-G"${1#*=};;
|
||||
"-G"|"--generator")
|
||||
CMAKE_ARGS+="-G$"$2; shift;;
|
||||
"--generator="*)
|
||||
CMAKE_ARGS="$CMAKE_ARGS -G ${1#*=}";;
|
||||
"-G")
|
||||
CMAKE_ARGS="$CMAKE_ARGS -G $2"; shift;;
|
||||
|
||||
"CC="*)
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_C_COMPILER=$(quote "${1#*=}")";;
|
||||
|
@ -8,16 +8,14 @@
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: Yap.C *
|
||||
* Last Rev: *
|
||||
* Mods: *
|
||||
* Comments: Yap's Main File *
|
||||
* File: Yap.C * Last Rev:
|
||||
** Mods: * Comments: Yap's Main File *
|
||||
* *
|
||||
*************************************************************************/
|
||||
/* static char SccsId[] = "X 4.3.3"; */
|
||||
|
||||
#include "YapConfig.h"
|
||||
#include "YapInterface.h"
|
||||
#include "config.h"
|
||||
|
||||
#include "cut_c.h"
|
||||
|
||||
@ -113,7 +111,6 @@ static bool exec_top_level(int BootMode, YAP_init_args *iap) {
|
||||
}
|
||||
return true;
|
||||
// YAP_Exit(EXIT_SUCCESS);
|
||||
|
||||
}
|
||||
|
||||
// FILE *debugf;
|
||||
|
@ -264,6 +264,9 @@
|
||||
#define REMOTE_OpenArray(wid) (REMOTE(wid)->OpenArray)
|
||||
|
||||
/* in a single gc */
|
||||
#define LOCAL_MallocDepth (Yap_local.MallocDepth)
|
||||
#define REMOTE_MallocDepth(wid) (REMOTE(wid)->MallocDepth)
|
||||
|
||||
#define LOCAL_total_marked (Yap_local.total_marked)
|
||||
#define REMOTE_total_marked(wid) (REMOTE(wid)->total_marked)
|
||||
|
||||
|
@ -27,7 +27,6 @@ SET( EXT
|
||||
${DOCS_SOURCE_DIR}/custom/yap.css
|
||||
)
|
||||
|
||||
|
||||
foreach(i ${CMAKE_HTML_EXTRA_})
|
||||
string(APPEND CMAKE_HTML_EXTRA ${i} " ")
|
||||
endforeach(i ${CMAKE_HTML_EXTRA_})
|
||||
@ -88,15 +87,11 @@ endforeach(i ${DOCS_EXCLUDE_})
|
||||
|
||||
set(doxyfile_in ${CMAKE_SOURCE_DIR}/docs/Doxyfile.in)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
add_subdirectory(../packages/raptor/doc ${CMAKE_BINARY_DIR}/packages/raptor/doc)
|
||||
|
||||
SET(DOC_INPUT_FILES_
|
||||
${CMAKE_SOURCE_DIR}/pl
|
||||
${CMAKE_SOURCE_DIR}/docs/md
|
||||
${CMAKE_SOURCE_DIR}/pl
|
||||
${CMAKE_SOURCE_DIR}/CXX
|
||||
${CMAKE_SOURCE_DIR}/OPTYap
|
||||
${CMAKE_SOURCE_DIR}/C
|
||||
|
@ -146,20 +146,6 @@
|
||||
<files visible="yes" title=""/>
|
||||
<namespaces visible="yes" title=""/>
|
||||
<classes visible="no" title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<enumvalues title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<signals title=""/>
|
||||
<publicslots title=""/>
|
||||
<protectedslots title=""/>
|
||||
<privateslots title=""/>
|
||||
<events title=""/>
|
||||
<properties title=""/>
|
||||
<friends title=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<memberdef>
|
||||
<pagedocs/>
|
||||
@ -177,7 +163,23 @@
|
||||
<events title=""/>
|
||||
<properties title=""/>
|
||||
<friends title=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdef>
|
||||
<memberdecl>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<enumvalues title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<signals title=""/>
|
||||
<publicslots title=""/>
|
||||
<protectedslots title=""/>
|
||||
<privateslots title=""/>
|
||||
<events title=""/>
|
||||
<properties title=""/>
|
||||
<friends title=""/>
|
||||
</memberdecl>
|
||||
<authorsection visible="yes"/>
|
||||
</group>
|
||||
|
||||
|
@ -20,4 +20,6 @@ notation will be used:
|
||||
|
||||
+ an argument with no preceding symbol can be used in both ways.
|
||||
|
||||
@{
|
||||
[TOC]
|
||||
|
||||
@}
|
||||
|
@ -13,11 +13,11 @@ predicates in a language other than Prolog. Under Unix systems,
|
||||
most language implementations were linkable to `C`, and the first interface exported the YAP machinery to the C language. YAP also implements most of the SWI-Prolog foreign language interface.
|
||||
This gives portability with a number of SWI-Prolog packages and avoids garnage collection by using @ref slotInterface. Last, a new C++ based interface is
|
||||
being designed to work with the swig (www.swig.orgv) interface compiler.
|
||||
|
||||
@}
|
||||
|
||||
@defgroup ChYInterface YAP original C-interface
|
||||
@{
|
||||
@ingroup fli_c_cxx
|
||||
@{
|
||||
|
||||
Before describing in full detail how to interface to C code, we will examine
|
||||
a brief example.
|
||||
@ -50,8 +50,8 @@ system.
|
||||
@}
|
||||
|
||||
@defgroup CallYAP Using the compiler:
|
||||
@{
|
||||
@ingroup ChYInterface
|
||||
@{
|
||||
|
||||
Under Linux you should use:
|
||||
|
||||
@ -127,8 +127,8 @@ The rest of this appendix describes exhaustively how to interface C to YAP.
|
||||
@}
|
||||
|
||||
@defgroup Manipulating_Terms Terms
|
||||
@{
|
||||
@ingroup ChYInterface
|
||||
@{
|
||||
|
||||
This section provides information about the primitives available to the C
|
||||
programmer for manipulating Prolog terms.
|
||||
@ -504,8 +504,8 @@ code. Slots can also be used if there is small state.
|
||||
@}
|
||||
|
||||
@defgroup Unifying_Terms Unification
|
||||
@{
|
||||
@ingroup ChYInterface
|
||||
@{
|
||||
|
||||
YAP provides a single routine to attempt the unification of two Prolog
|
||||
terms. The routine may succeed or fail:
|
||||
@ -522,8 +522,8 @@ otherwise.
|
||||
@}
|
||||
|
||||
@defgroup CallYAP Using the compiler:
|
||||
@{
|
||||
@ingroup Manipulating_Strings Strings
|
||||
@{
|
||||
|
||||
|
||||
The YAP C-interface now includes an utility routine to copy a string
|
||||
@ -608,8 +608,8 @@ and <tt>-1</tt> on error.
|
||||
@}
|
||||
|
||||
@defgroup Memory_Allocation Memory Allocation
|
||||
@{
|
||||
@ingroup ChYInterface
|
||||
@{
|
||||
|
||||
|
||||
The next routine can be used to ask space from the Prolog data-base:
|
||||
@ -638,8 +638,8 @@ area.
|
||||
@}
|
||||
|
||||
@defgroup Controlling_Streams Controlling YAP Streams from `C`
|
||||
@{
|
||||
@ingroup ChYInterface
|
||||
@{
|
||||
|
||||
The C-Interface also provides the C-application with a measure of
|
||||
control over the YAP Input/Output system. The first routine allows one
|
||||
@ -698,8 +698,8 @@ the name by which YAP should know the new stream.
|
||||
@}
|
||||
|
||||
@defgroup Utility_Functions Utility Functions in `C
|
||||
@{
|
||||
@ingroup ChYInterface
|
||||
@{
|
||||
|
||||
The C-Interface provides the C-application with a a number of utility
|
||||
functions that are useful.
|
||||
@ -794,9 +794,8 @@ ignore the variable.
|
||||
@}
|
||||
|
||||
@defgroup Calling_YAP_From_C From `C` back to Prolog
|
||||
@{
|
||||
@ingroup ChYInterface
|
||||
### From `C` back to Prolog {#Calling_YAP_From_C}
|
||||
@{
|
||||
|
||||
There are several ways to call Prolog code from C-code. By default, the
|
||||
`YAP_RunGoal()` should be used for this task. It assumes the engine
|
||||
@ -967,8 +966,8 @@ have moved the terms
|
||||
@}
|
||||
|
||||
@defgroup CallYAP Using the compiler:
|
||||
@{
|
||||
@ingroup Module_Manipulation_in_C Module Manipulation in C
|
||||
@{
|
||||
|
||||
YAP allows one to create a new module from C-code. To create the new
|
||||
code it is sufficient to call:
|
||||
@ -998,8 +997,8 @@ Notice that this function returns a term, and not an atom. You can
|
||||
@}
|
||||
|
||||
@defgroup Miscellaneous_ChYFunctions Miscellaneous C Functions
|
||||
@{
|
||||
@ingroup ChYInterface
|
||||
@{
|
||||
|
||||
<ul>
|
||||
<li>`void` YAP_Throw(`YAP_Term exception`)
|
||||
@ -1064,9 +1063,8 @@ of such arguments.
|
||||
@}
|
||||
|
||||
@defgroup Writing_C Writing predicates in C
|
||||
@{
|
||||
@ingroup ChYInterface
|
||||
### Writing predicates in C {#Writing_C}
|
||||
@{
|
||||
|
||||
We will distinguish two kinds of predicates:
|
||||
|
||||
@ -1321,8 +1319,8 @@ in this case no code is executed at cut time.
|
||||
@}
|
||||
|
||||
@defgroup YAP4_Notes Changes to the C-Interface in YAP4
|
||||
@{
|
||||
@ingroup ChYInterface
|
||||
@{
|
||||
|
||||
YAP4 includes several changes over the previous `load_foreign_files/3`
|
||||
interface. These changes were required to support the new binary code
|
||||
@ -1361,8 +1359,8 @@ arguments to the backtrackable procedure.
|
||||
@}
|
||||
|
||||
@defgroup YAPAsLibrary Using YAP as a Library
|
||||
@{
|
||||
@ingroup ChYInterface
|
||||
@{
|
||||
|
||||
YAP can be used as a library to be called from other
|
||||
programs. To do so, you must first create the YAP library:
|
||||
|
@ -1,9 +1,15 @@
|
||||
|
||||
@file LIBRARY.md
|
||||
|
||||
@defgroup library YAP Prolog Library
|
||||
|
||||
@{
|
||||
|
||||
YAP supports
|
||||
the library_directory path (set by the
|
||||
`LIBDIR` variable in the Makefile for YAP). Several files in the
|
||||
library are originally from the public-domain Edinburgh Prolog library.
|
||||
|
||||
[TOC]
|
||||
|
||||
@}
|
@ -1,23 +1,20 @@
|
||||
Programming in YAP {#YAPProgramming}
|
||||
====================
|
||||
@defgroup YAPProgramming Programming in YAP
|
||||
|
||||
+ @ref load_files
|
||||
@{
|
||||
|
||||
+ @ref YAPSyntax
|
||||
|
||||
+ @ref YAPCompilerSettings
|
||||
|
||||
+ @ref Indexing
|
||||
|
||||
+ @ref Deb_Interaction
|
||||
[TOC]
|
||||
|
||||
@}
|
||||
|
||||
@defgroup load_files Loading and Organizing YAP Programs
|
||||
|
||||
@{
|
||||
|
||||
We present the main predicates and directives available to load
|
||||
files and to control the Prolog environment.
|
||||
|
||||
[TOC]
|
||||
|
||||
@}
|
||||
|
||||
@defgroup YAPModules The YAP Module system
|
||||
@ -141,7 +138,7 @@ We present the main predicates and directives available to load
|
||||
their public predicates into the current type-in module. It is
|
||||
implemented as if by:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.yap}
|
||||
use_module(F) :-
|
||||
load_files(F, [if(not_loaded),must_be_module(true)]).
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -1,3 +1,9 @@
|
||||
2:- use_module( library(lineutils) ).
|
||||
3
|
||||
4main :-
|
||||
5 unix(argv[Dir,Out]),
|
||||
6 open(Out,write,O),
|
||||
|
||||
:- module( prolog, [] ).
|
||||
7 go(Dir,O).
|
||||
9go(Dir,O) :-
|
||||
|
||||
|
@ -19,7 +19,7 @@ extern "C" {
|
||||
|
||||
//=== includes ===============================================================
|
||||
#ifdef YAP_KERNEL
|
||||
#include "config.h"
|
||||
#include "YapConfig.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
@ -40,8 +40,8 @@ extern "C" {
|
||||
#include "YapInterface.h"
|
||||
#else
|
||||
#if _YAP_NOT_INSTALLED_
|
||||
#include <YapConfig.h>
|
||||
#include <YapInterface.h>
|
||||
#include <config.h>
|
||||
#else
|
||||
#include <Yap/YapInterface.h>
|
||||
#endif
|
||||
|
@ -31,7 +31,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <encoding.h>
|
||||
#include <YapEncoding.h>
|
||||
|
||||
typedef struct {
|
||||
dev_t st_dev; /* ID of device containing file */
|
||||
@ -85,9 +85,11 @@ typedef struct vfs {
|
||||
/// in this space, usual w,r,a,b flags plus B (store in a buffer)
|
||||
bool (*close)(int sno); /// close the object
|
||||
int (*get_char)(int sno); /// get an octet from the stream
|
||||
int (*get_wchar)(int sno); /// get an octet from the stream
|
||||
int (*peek_char)(int sno); /// unget an octet from the stream
|
||||
int (*peek_wchar)(int sno); /// unget an octet from the stream
|
||||
int (*put_char)(int sno, int ch); /// output an octet to the stream
|
||||
int (*put_wchar)(int sno, int ch); /// output a character to the stream
|
||||
void (*flush)(int sno); /// flush a stream
|
||||
int64_t (*seek)(int sno, int64_t offset,
|
||||
int whence); /// jump around the stream
|
||||
|
@ -50,35 +50,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* The YAP main types */
|
||||
#include "YapTerm.h"
|
||||
|
||||
#if HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#if HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
FALSE and TRUE are the pre-standard versions,
|
||||
still widely used.
|
||||
*/
|
||||
#ifndef TRUE
|
||||
#define TRUE true
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define FALSE false
|
||||
#endif
|
||||
#ifndef YAP_Bool
|
||||
typedef bool YAP_Bool;
|
||||
#endif
|
||||
|
||||
/**
|
||||
This term can never be constructed as a valid term, so it is
|
||||
used as a "BAD" term
|
||||
*/
|
||||
#define TermZERO ((Term)0)
|
||||
|
||||
#include "YapConfig.h"
|
||||
|
||||
@ -98,7 +69,7 @@ typedef int (*YAP_agc_hook)(void *_Atom);
|
||||
|
||||
#include "YapError.h"
|
||||
|
||||
#include "../os/encoding.h"
|
||||
#include "YapEncoding.h"
|
||||
|
||||
typedef encoding_t YAP_encoding_t;
|
||||
|
||||
@ -152,10 +123,6 @@ typedef enum {
|
||||
YAP_TAG_ARRAY = 0x4000
|
||||
} YAP_tag_t;
|
||||
|
||||
#define YAP_BOOT_FROM_SAVED_CODE 1
|
||||
#define YAP_BOOT_FROM_SAVED_STACKS 2
|
||||
#define YAP_BOOT_ERROR -1
|
||||
|
||||
#define YAP_WRITE_QUOTED 1
|
||||
#define YAP_WRITE_IGNORE_OPS 2
|
||||
#define YAP_WRITE_HANDLE_VARS 4
|
||||
@ -167,130 +134,7 @@ typedef enum {
|
||||
#define YAP_WRITE_ATTVAR_PORTRAY 0x400
|
||||
#define YAP_WRITE_BLOB_PORTRAY 0x800
|
||||
|
||||
#define YAP_CONSULT_MODE 0
|
||||
#define YAP_RECONSULT_MODE 1
|
||||
#define YAP_BOOT_MODE 2
|
||||
|
||||
X_API YAP_file_type_t Yap_InitDefaults(void *init_args, char saved_state[],
|
||||
int Argc, char *Argv[]);
|
||||
|
||||
typedef struct yap_boot_params {
|
||||
//> boot type as suggested by the user
|
||||
YAP_file_type_t boot_file_type;
|
||||
//> how files are organised: NULL is GNU/Linux way
|
||||
// const char *directory_structure;
|
||||
//> if NON-NULL, set value for Yap_ROOTDIR
|
||||
const char *ROOTDIR;
|
||||
//> if NON-NULL, location of yaap, sets Yap_BINDIR
|
||||
const char *BINDIR;
|
||||
//> if NON-NULL, location of libYap, sets Yap_LIBDIR
|
||||
const char *LIBDIR;
|
||||
//> if NON-NULL, architecture independent files, sets Yap_SHAREDIR
|
||||
const char *SHAREDIR;
|
||||
//> if NON-NULL, include files, sets Yap_INCLUDEDIR
|
||||
const char *INCLUDEDIR;
|
||||
//> if NON-NULL, Prolog DLL location, sets Yap_DLLDIR
|
||||
const char *DLLDIR;
|
||||
//> if NON-NULL, Prolog library, sets Yap_DLLDIR
|
||||
const char *PLDIR;
|
||||
//> if NON-NULL, Prolog library, sets Yap_COMMONSDIR
|
||||
const char *COMMONSDIR;
|
||||
//> if NON-NULL, name for a Prolog file to use when booting at run-time
|
||||
const char *BOOTFILE;
|
||||
//> if NON-NULL, name for a Prolog file to use when booting at compile-time
|
||||
const char *BOOTSTRAP;
|
||||
//> if NON-NULL, path where we can find the saved state
|
||||
const char *INPUT_STARTUP;
|
||||
//> bootstrapping mode: YAP is not properly installed
|
||||
bool install;
|
||||
//> jupyter mode: YAP is in space
|
||||
bool jupyter;
|
||||
//> generats a saved space at this path
|
||||
const char *OUTPUT_STARTUP;
|
||||
//> if NON-0, minimal size for Heap or Code Area
|
||||
size_t HeapSize;
|
||||
//> if NON-0, maximal size for Heap or Code Area
|
||||
size_t MaxHeapSize;
|
||||
//> if NON-0, minimal size for Local+Global Stack
|
||||
size_t StackSize;
|
||||
//> if NON-0, maximal size for Local+Global Stack
|
||||
size_t MaxStackSize;
|
||||
//*> deprecated
|
||||
size_t MaxGlobalSize;
|
||||
//> if NON-0, minimal size for Trail
|
||||
size_t TrailSize;
|
||||
//> if NON-0, maximal size for Trail
|
||||
size_t MaxTrailSize;
|
||||
//> if NON-0, minimal size for AttributeVarStack
|
||||
size_t AttsSize;
|
||||
//> if NON-0, maximal size for AttributeVarStack
|
||||
size_t MaxAttsSize;
|
||||
//> if NON-NULL, name for a Prolog file to use when initializing
|
||||
const char *YapPrologInitGoal;
|
||||
//> if NON-NULL, name for a Prolog file to consult before entering top-level
|
||||
const char *PrologRCFile;
|
||||
//> if NON-NULL, a goal to run before top-level
|
||||
const char *PrologGoal;
|
||||
//> if NON-NULL, a goal to run as top-level
|
||||
const char *PrologTopLevelGoal;
|
||||
//> if NON-NULL, a path to extend file-search-path
|
||||
const char *PrologAddPath;
|
||||
//> if previous NON-NULL and TRUE, halt after consulting that file
|
||||
bool HaltAfterBoot;
|
||||
//> ignore .yaprc, .prolog.ini, etc. files.
|
||||
bool FastBoot;
|
||||
//> the next field only interest YAPTAB
|
||||
//> if NON-0, maximum size for Table Space
|
||||
size_t MaxTableSpaceSize;
|
||||
/* the next three fields only interest YAPOR, but we keep them so that
|
||||
users don't need to recompile DLL in order to use YAPOR */
|
||||
//> if NON-0, number of workers we want to have (default=1)
|
||||
unsigned long int NumberWorkers;
|
||||
//> if NON-0, manage the inner scheduler loop (default = 10)
|
||||
unsigned long int SchedulerLoop;
|
||||
//> if NON-0, say how long to keep nodes (default = 3)
|
||||
unsigned long int DelayedReleaseLoad;
|
||||
//> end of YAPOR fields
|
||||
/* whether Prolog should handle interrupts. Note that
|
||||
interrupts will always be disabled in embedded mode. */
|
||||
bool PrologCannotHandleInterrupts;
|
||||
//> flag for JIT mode
|
||||
int ExecutionMode;
|
||||
//> number of arguments that Prolog will see
|
||||
int Argc;
|
||||
//> array of arguments as seen by Prolog
|
||||
char **Argv;
|
||||
//> embedded in some other system: no signals, readline, etc
|
||||
bool Embedded;
|
||||
//> QuietMode
|
||||
int QuietMode;
|
||||
//> 0, maintain default, > 0 use fd-1, < 0 close
|
||||
int inp, out, err;
|
||||
#if __ANDROID__
|
||||
//> android asset support
|
||||
AAssetManager *assetManager;
|
||||
#endif
|
||||
/* support nf's ypp preprocessor code */
|
||||
#define YAP_MAX_YPP_DEFS 100
|
||||
char *def_var[YAP_MAX_YPP_DEFS];
|
||||
char *def_value[YAP_MAX_YPP_DEFS];
|
||||
int def_c;
|
||||
/* End preprocessor code */
|
||||
|
||||
#ifdef MYDDAS_MYSQL
|
||||
//> If any myddas option was given
|
||||
short myddas;
|
||||
//> MYDDAS Fields
|
||||
char *myddas_user;
|
||||
char *myddas_pass;
|
||||
char *myddas_db;
|
||||
char *myddas_host;
|
||||
#endif
|
||||
/* errornumber */
|
||||
int ErrorNo;
|
||||
//> errorstring
|
||||
char *ErrorCause;
|
||||
} YAP_init_args;
|
||||
#include "YapInit.h"
|
||||
|
||||
/* this should be opaque to the user */
|
||||
typedef struct {
|
||||
|
@ -200,31 +200,51 @@ INLINE_ONLY Term Yap_ensure_atom__(const char *fu, const char *fi, int line,
|
||||
|
||||
/// all we need to know about an error/throw
|
||||
typedef struct s_yap_error_descriptor {
|
||||
/// error identifier
|
||||
yap_error_number errorNo;
|
||||
/// kind of error: derived from errorNo;
|
||||
yap_error_class_number errorClass;
|
||||
/// if non-NULL: goal who caused error;
|
||||
const char *errorGoal;
|
||||
/// errorNo as text
|
||||
const char *errorAsText;
|
||||
/// errorClass as text
|
||||
const char *classAsText;
|
||||
/// c-code that generated the error
|
||||
/// C-line
|
||||
intptr_t errorLine;
|
||||
/// C-function
|
||||
const char *errorFunction;
|
||||
/// C-file
|
||||
const char *errorFile;
|
||||
// struct error_prolog_source *errorSource;
|
||||
intptr_t prologPredCl;
|
||||
uintptr_t prologPredLine;
|
||||
uintptr_t prologPredFirstLine;
|
||||
uintptr_t prologPredLastLine;
|
||||
/// Prolog predicate that caused the error: name
|
||||
const char *prologPredName;
|
||||
/// Prolog predicate that caused the error:arity
|
||||
uintptr_t prologPredArity;
|
||||
/// Prolog predicate that caused the error:module
|
||||
const char *prologPredModule;
|
||||
/// Prolog predicate that caused the error:line
|
||||
const char *prologPredFile;
|
||||
uintptr_t prologParserPos;
|
||||
uintptr_t prologParserLine;
|
||||
uintptr_t prologParserFirstLine;
|
||||
uintptr_t prologParserLastLine;
|
||||
const char *prologParserText;
|
||||
const char *prologParserFile;
|
||||
/// line where error clause defined
|
||||
uintptr_t prologPredLine;
|
||||
/// syntax and other parsing errors
|
||||
uintptr_t parserPos;
|
||||
uintptr_t parserFirstPos;
|
||||
uintptr_t parserLastPos;
|
||||
uintptr_t parserLine;
|
||||
uintptr_t parserFirstLine;
|
||||
uintptr_t parserLastLine;
|
||||
const char *parserTextA;
|
||||
const char *parserTextB;
|
||||
const char *parserFile;
|
||||
/// reading a clause, or called from read?
|
||||
bool parserReadingCode;
|
||||
/// whether we are consulting
|
||||
bool prologConsulting;
|
||||
const char *culprit;
|
||||
/// Prolog stack at the time
|
||||
const char *prologStack;
|
||||
YAP_Term errorRawTerm, rawExtraErrorTerm;
|
||||
char *errorMsg;
|
||||
size_t errorMsgLen;
|
||||
@ -242,6 +262,7 @@ INLINE_ONLY Term Yap_ensure_atom__(const char *fu, const char *fi, int line,
|
||||
|
||||
extern void Yap_CatchError(void);
|
||||
extern void Yap_ThrowExistingError(void);
|
||||
extern YAP_Term Yap_MkFullError(void);
|
||||
extern bool Yap_MkErrorRecord(
|
||||
yap_error_descriptor_t * r, const char *file, const char *function,
|
||||
int lineno, yap_error_number type, YAP_Term where, const char *msg);
|
||||
@ -252,6 +273,8 @@ INLINE_ONLY Term Yap_ensure_atom__(const char *fu, const char *fi, int line,
|
||||
yap_error_descriptor_t * t, void *cp0, void *b_ptr0, void *env0,
|
||||
YAP_Int ignore_first);
|
||||
|
||||
extern const char *Yap_dump_stack(void);
|
||||
|
||||
extern yap_error_descriptor_t *Yap_prolog_add_culprit(yap_error_descriptor_t *
|
||||
t);
|
||||
extern yap_error_class_number Yap_errorClass(yap_error_number e);
|
||||
|
@ -27,13 +27,15 @@ ECLASS(RESOURCE_ERROR, "resource_error", 2)
|
||||
/// bad text
|
||||
ECLASS(SYNTAX_ERROR_CLASS, "syntax_error", 1)
|
||||
/// OS or internal
|
||||
ECLASS(SYSTEM_ERROR_CLASS, "system_error", 2)
|
||||
ECLASS(SYSTEM_ERROR_CLASS, "system_error", 1)
|
||||
/// bad typing
|
||||
ECLASS(TYPE_ERROR, "type_error", 2)
|
||||
/// should be unbound
|
||||
ECLASS(UNINSTANTIATION_ERROR_CLASS, "uninstantiation_error", 1)
|
||||
/// escape hatch
|
||||
ECLASS(EVENT, "event", 2)
|
||||
/// not quite an error, but almost
|
||||
ECLASS(WARNING, "warning", 1)
|
||||
/// user defined escape hatch
|
||||
ECLASS(EVENT, "event", 1)
|
||||
|
||||
END_ERROR_CLASSES();
|
||||
|
||||
@ -88,6 +90,7 @@ E(DOMAIN_ERROR_WRITE_OPTION, DOMAIN_ERROR, "write_option")
|
||||
E(EVALUATION_ERROR_FLOAT_OVERFLOW, EVALUATION_ERROR, "float_overflow")
|
||||
E(EVALUATION_ERROR_FLOAT_UNDERFLOW, EVALUATION_ERROR, "float_underflow")
|
||||
E(EVALUATION_ERROR_INT_OVERFLOW, EVALUATION_ERROR, "int_overflow")
|
||||
E(EVALUATION_ERROR_READ_STREAM, EVALUATION_ERROR, "read_from_stream")
|
||||
E(EVALUATION_ERROR_UNDEFINED, EVALUATION_ERROR, "undefined")
|
||||
E(EVALUATION_ERROR_UNDERFLOW, EVALUATION_ERROR, "underflow")
|
||||
E(EVALUATION_ERROR_ZERO_DIVISOR, EVALUATION_ERROR, "zero_divisor")
|
||||
@ -196,7 +199,11 @@ E(TYPE_ERROR_REFERENCE, TYPE_ERROR, "reference")
|
||||
E(TYPE_ERROR_STRING, TYPE_ERROR, "string")
|
||||
E(TYPE_ERROR_TEXT, TYPE_ERROR, "text")
|
||||
E(TYPE_ERROR_UBYTE, TYPE_ERROR, "ubyte")
|
||||
E(TYPE_ERROR_UCHAR, TYPE_ERROR, "uchar")
|
||||
E(TYPE_ERROR_UCHAR, TYPE_ERROR, "unsigned char")
|
||||
|
||||
E(WARNING_DISCONTIGUOUS, WARNING, "discontiguous")
|
||||
E(WARNING_SINGLETONS, WARNING, "singletons")
|
||||
E(WARNING_SYNTAX_ERROR, WARNING, "syntax_error")
|
||||
|
||||
E1(UNINSTANTIATION_ERROR, UNINSTANTIATION_ERROR_CLASS, "uninstantiation_error")
|
||||
|
||||
|
140
include/YapInit.h
Normal file
140
include/YapInit.h
Normal file
@ -0,0 +1,140 @@
|
||||
/**
|
||||
*
|
||||
* @file YapInit.h
|
||||
*
|
||||
* * Utilities for Booting YAP
|
||||
*/
|
||||
|
||||
#ifndef YAPINIT_H
|
||||
#define YAPINIT_H
|
||||
|
||||
#define YAP_BOOT_FROM_SAVED_CODE 1
|
||||
#define YAP_BOOT_FROM_SAVED_STACKS 2
|
||||
#define YAP_BOOT_ERROR -1
|
||||
|
||||
#define YAP_CONSULT_MODE 0
|
||||
#define YAP_RECONSULT_MODE 1
|
||||
#define YAP_BOOT_MODE 2
|
||||
|
||||
X_API YAP_file_type_t Yap_InitDefaults(void *init_args, char saved_state[],
|
||||
int Argc, char *Argv[]);
|
||||
|
||||
typedef struct yap_boot_params {
|
||||
//> boot type as suggested by the user
|
||||
YAP_file_type_t boot_file_type;
|
||||
//> how files are organised: NULL is GNU/Linux way
|
||||
// const char *directory_structure;
|
||||
//> if NON-NULL, set value for Yap_ROOTDIR
|
||||
const char *ROOTDIR;
|
||||
//> if NON-NULL, location of yaap, sets Yap_BINDIR
|
||||
const char *BINDIR;
|
||||
//> if NON-NULL, location of libYap, sets Yap_LIBDIR
|
||||
const char *LIBDIR;
|
||||
//> if NON-NULL, architecture independent files, sets Yap_SHAREDIR
|
||||
const char *SHAREDIR;
|
||||
//> if NON-NULL, include files, sets Yap_INCLUDEDIR
|
||||
const char *INCLUDEDIR;
|
||||
//> if NON-NULL, Prolog DLL location, sets Yap_DLLDIR
|
||||
const char *DLLDIR;
|
||||
//> if NON-NULL, Prolog library, sets Yap_DLLDIR
|
||||
const char *PLDIR;
|
||||
//> if NON-NULL, Prolog library, sets Yap_COMMONSDIR
|
||||
const char *COMMONSDIR;
|
||||
//> if NON-NULL, name for a Prolog file to use when booting at run-time
|
||||
const char *BOOTFILE;
|
||||
//> if NON-NULL, name for a Prolog file to use when booting at compile-time
|
||||
const char *BOOTSTRAP;
|
||||
//> if NON-NULL, path where we can find the saved state
|
||||
const char *INPUT_STARTUP;
|
||||
//> bootstrapping mode: YAP is not properly installed
|
||||
bool install;
|
||||
//> jupyter mode: YAP is in space
|
||||
bool jupyter;
|
||||
//> generats a saved space at this path
|
||||
const char *OUTPUT_STARTUP;
|
||||
//> if NON-0, minimal size for Heap or Code Area
|
||||
size_t HeapSize;
|
||||
//> if NON-0, maximal size for Heap or Code Area
|
||||
size_t MaxHeapSize;
|
||||
//> if NON-0, minimal size for Local+Global Stack
|
||||
size_t StackSize;
|
||||
//> if NON-0, maximal size for Local+Global Stack
|
||||
size_t MaxStackSize;
|
||||
//*> deprecated
|
||||
size_t MaxGlobalSize;
|
||||
//> if NON-0, minimal size for Trail
|
||||
size_t TrailSize;
|
||||
//> if NON-0, maximal size for Trail
|
||||
size_t MaxTrailSize;
|
||||
//> if NON-0, minimal size for AttributeVarStack
|
||||
size_t AttsSize;
|
||||
//> if NON-0, maximal size for AttributeVarStack
|
||||
size_t MaxAttsSize;
|
||||
//> if NON-NULL, name for a Prolog file to use when initializing
|
||||
const char *YapPrologInitGoal;
|
||||
//> if NON-NULL, name for a Prolog file to consult before entering top-level
|
||||
const char *PrologRCFile;
|
||||
//> if NON-NULL, a goal to run before top-level
|
||||
const char *PrologGoal;
|
||||
//> if NON-NULL, a goal to run as top-level
|
||||
const char *PrologTopLevelGoal;
|
||||
//> if NON-NULL, a path to extend file-search-path
|
||||
const char *PrologAddPath;
|
||||
//> if previous NON-NULL and TRUE, halt after consulting that file
|
||||
bool HaltAfterBoot;
|
||||
//> ignore .yaprc, .prolog.ini, etc. files.
|
||||
bool FastBoot;
|
||||
//> the next field only interest YAPTAB
|
||||
//> if NON-0, maximum size for Table Space
|
||||
size_t MaxTableSpaceSize;
|
||||
/* the next three fields only interest YAPOR, but we keep them so that
|
||||
users don't need to recompile DLL in order to use YAPOR */
|
||||
//> if NON-0, number of workers we want to have (default=1)
|
||||
unsigned long int NumberWorkers;
|
||||
//> if NON-0, manage the inner scheduler loop (default = 10)
|
||||
unsigned long int SchedulerLoop;
|
||||
//> if NON-0, say how long to keep nodes (default = 3)
|
||||
unsigned long int DelayedReleaseLoad;
|
||||
//> end of YAPOR fields
|
||||
/* whether Prolog should handle interrupts. Note that
|
||||
interrupts will always be disabled in embedded mode. */
|
||||
bool PrologCannotHandleInterrupts;
|
||||
//> flag for JIT mode
|
||||
int ExecutionMode;
|
||||
//> number of arguments that Prolog will see
|
||||
int Argc;
|
||||
//> array of arguments as seen by Prolog
|
||||
char **Argv;
|
||||
//> embedded in some other system: no signals, readline, etc
|
||||
bool Embedded;
|
||||
//> QuietMode
|
||||
int QuietMode;
|
||||
//> 0, maintain default, > 0 use fd-1, < 0 close
|
||||
int inp, out, err;
|
||||
#if __ANDROID__
|
||||
//> android asset support
|
||||
AAssetManager *assetManager;
|
||||
#endif
|
||||
/* support nf's ypp preprocessor code */
|
||||
#define YAP_MAX_YPP_DEFS 100
|
||||
char *def_var[YAP_MAX_YPP_DEFS];
|
||||
char *def_value[YAP_MAX_YPP_DEFS];
|
||||
int def_c;
|
||||
/* End preprocessor code */
|
||||
|
||||
#ifdef MYDDAS_MYSQL
|
||||
//> If any myddas option was given
|
||||
short myddas;
|
||||
//> MYDDAS Fields
|
||||
char *myddas_user;
|
||||
char *myddas_pass;
|
||||
char *myddas_db;
|
||||
char *myddas_host;
|
||||
#endif
|
||||
/* errornumber */
|
||||
int ErrorNo;
|
||||
//> errorstring
|
||||
char *ErrorCause;
|
||||
} YAP_init_args;
|
||||
|
||||
#endif
|
@ -31,6 +31,8 @@ The following routines export the YAP internals and architecture.
|
||||
|
||||
#define _yap_c_interface_h 1
|
||||
|
||||
#include "YapConfig.h"
|
||||
|
||||
#define __YAP_PROLOG__ 1
|
||||
|
||||
#ifndef YAPVERSION
|
||||
@ -102,6 +104,9 @@ extern YAP_Term YAP_A(int);
|
||||
#define YAP_ARG15 YAP_A(15)
|
||||
#define YAP_ARG16 YAP_A(16)
|
||||
|
||||
X_API
|
||||
extern YAP_Term YAP_SetA(int, YAP_Term);
|
||||
|
||||
/* YAP_Bool IsVarTerm(YAP_Term) */
|
||||
extern X_API YAP_Bool YAP_IsVarTerm(YAP_Term);
|
||||
|
||||
@ -268,7 +273,6 @@ extern X_API void YAP_UserCPredicateWithArgs(const char *, YAP_UserCPred,
|
||||
extern X_API void YAP_UserBackCPredicate(const char *, YAP_UserCPred,
|
||||
YAP_UserCPred, YAP_Arity, YAP_Arity);
|
||||
|
||||
|
||||
/* void UserBackCPredicate(char *name, int *init(), int *cont(), int *cut(),
|
||||
int
|
||||
arity, int extra) */
|
||||
@ -383,8 +387,7 @@ extern X_API int YAP_AssertTuples(YAP_PredEntryPtr pred, const YAP_Term *ts,
|
||||
extern X_API void YAP_Init(YAP_init_args *);
|
||||
|
||||
/* int YAP_FastInit(const char *) */
|
||||
extern X_API void YAP_FastInit(char saved_state[], int argc,
|
||||
char *argv[]);
|
||||
extern X_API void YAP_FastInit(char saved_state[], int argc, char *argv[]);
|
||||
|
||||
#ifndef _PL_STREAM_H
|
||||
// if we don't know what a stream is, just don't assume nothing about the
|
||||
@ -402,7 +405,8 @@ extern X_API YAP_Term YAP_ReadFromStream(int s);
|
||||
|
||||
/// read a Prolog clause from a Prolog opened stream $s$. Similar to
|
||||
/// YAP_ReadFromStream() but takes /// default options from read_clause/3.
|
||||
extern X_API YAP_Term YAP_ReadClauseFromStream(int s, YAP_Term varNames, YAP_Term);
|
||||
extern X_API YAP_Term YAP_ReadClauseFromStream(int s, YAP_Term varNames,
|
||||
YAP_Term);
|
||||
|
||||
extern X_API void YAP_Write(YAP_Term t, FILE *s, int);
|
||||
|
||||
@ -411,7 +415,8 @@ extern X_API FILE *YAP_TermToStream(YAP_Term t);
|
||||
extern X_API int YAP_InitConsult(int mode, const char *filename, char **buf,
|
||||
int *previous_sno);
|
||||
|
||||
extern X_API void YAP_EndConsult(int s, int *previous_sno, const char *previous_cwd);
|
||||
extern X_API void YAP_EndConsult(int s, int *previous_sno,
|
||||
const char *previous_cwd);
|
||||
|
||||
extern X_API void YAP_Exit(int);
|
||||
|
||||
@ -477,7 +482,6 @@ extern X_API void YAP_SetOutputMessage(void);
|
||||
|
||||
extern X_API int YAP_StreamToFileNo(YAP_Term);
|
||||
|
||||
|
||||
/**
|
||||
* Utility routine to Obtain a pointer to the YAP representation of a stream.
|
||||
*
|
||||
@ -486,7 +490,6 @@ extern X_API int YAP_StreamToFileNo(YAP_Term);
|
||||
*/
|
||||
extern X_API void *YAP_RepStreamFromId(int sno);
|
||||
|
||||
|
||||
extern X_API void YAP_CloseAllOpenStreams(void);
|
||||
|
||||
extern X_API void YAP_FlushAllStreams(void);
|
||||
|
@ -13,17 +13,11 @@
|
||||
* version: $Id: Yap.h,v 1.38 2008-06-18 10:02:27 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef YAP_H
|
||||
#include "YapTermConfig.h"
|
||||
#include "config.h"
|
||||
#include <stddef.h>
|
||||
|
||||
#endif
|
||||
|
||||
#if HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#if HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#if HAVE_STDTYPES_H
|
||||
#include <stdtypes.h>
|
||||
#endif
|
||||
|
||||
/* truth-values */
|
||||
@ -41,6 +35,13 @@ typedef int _Bool;
|
||||
#endif
|
||||
#endif /* HAVE_STDBOOL_H */
|
||||
|
||||
#if HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#define ALIGN_BY_TYPE(X, TYPE) \
|
||||
(((CELL)(X) + (sizeof(TYPE) - 1)) & ~(sizeof(TYPE) - 1))
|
||||
@ -99,10 +100,10 @@ typedef YAP_UInt YAP_Term;
|
||||
#define TRUE true
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define FALSE false
|
||||
#endif
|
||||
|
||||
typedef bool YAP_Bool;
|
||||
#define FALSE false
|
||||
|
||||
typedef YAP_Int YAP_handle_t;
|
||||
|
||||
@ -113,34 +114,9 @@ typedef void *YAP_Atom;
|
||||
|
||||
typedef void *YAP_Functor;
|
||||
|
||||
#ifdef YAP_H
|
||||
|
||||
typedef YAP_Int Int;
|
||||
typedef YAP_UInt UInt;
|
||||
typedef YAP_Short Short;
|
||||
typedef YAP_UShort UShort;
|
||||
|
||||
typedef uint16_t BITS16;
|
||||
typedef int16_t SBITS16;
|
||||
typedef uint32_t BITS32;
|
||||
|
||||
typedef YAP_CELL CELL;
|
||||
|
||||
typedef YAP_Term Term;
|
||||
|
||||
#define WordSize sizeof(BITS16)
|
||||
#define CellSize sizeof(CELL)
|
||||
#define SmallSize sizeof(SMALLUNSGN)
|
||||
|
||||
typedef YAP_Int Int;
|
||||
typedef YAP_Float Float;
|
||||
typedef YAP_handle_t yhandle_t;
|
||||
|
||||
#endif
|
||||
|
||||
#include "YapError.h"
|
||||
|
||||
#include "../os/encoding.h"
|
||||
#include "YapEncoding.h"
|
||||
|
||||
typedef encoding_t YAP_encoding_t;
|
||||
|
||||
|
@ -28,7 +28,7 @@ SET(CMAKE_SKIP_BUILD_RPATH FALSE)
|
||||
# (but later on when installing)
|
||||
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
||||
|
||||
SET(CMAKE_INSTALL_RPATH "${libdir};${dlls}:")
|
||||
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR};${YAP_INSTALL_LIBDIR}:")
|
||||
|
||||
# add the automatically determined parts of the RPATH
|
||||
# which point to directories outside the build tree to the install RPATH
|
||||
@ -47,9 +47,9 @@ set_target_properties(libYap
|
||||
endif()
|
||||
|
||||
# the RPATH to be used when installing, but only if it's not a system directory
|
||||
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${libdir};${dlls}" isSystemDir)
|
||||
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_LIBDIR};${YAP_INSTALL_LIBDIR}" isSystemDir)
|
||||
IF("${isSystemDir}" STREQUAL "-1")
|
||||
SET(CMAKE_INSTALL_RPATH "${libdir};${dlls}")
|
||||
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR};${YAP_INSTALL_LIBDIR}")
|
||||
ENDIF("${isSystemDir}" STREQUAL "-1")
|
||||
|
||||
|
||||
|
@ -76,10 +76,10 @@ MY_add_subdirectory(ytest)
|
||||
|
||||
add_to_group( LIBRARY_PL pl_library)
|
||||
|
||||
install(FILES ${LIBRARY_PL} DESTINATION ${libpl})
|
||||
install(FILES ${LIBRARY_PL} DESTINATION ${YAP_INSTALL_DATADIR})
|
||||
|
||||
if (ANDROID)
|
||||
file( INSTALL ${LIBRARY_PL} DESTINATION ${libpl} )
|
||||
file( INSTALL ${LIBRARY_PL} DESTINATION ${YAP_INSTALL_DATADIR} )
|
||||
endif()
|
||||
|
||||
include_directories("dialect/swi")
|
||||
|
@ -23,28 +23,30 @@
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@defgroup args Term Argument Manipulation.
|
||||
|
||||
@ingroup @library
|
||||
|
||||
@{
|
||||
|
||||
Extends arg/3 by including backtracking through arguments and access
|
||||
to sub-arguments,
|
||||
|
||||
- arg0/3
|
||||
- args/3
|
||||
- args0/3
|
||||
- genarg/3
|
||||
- genarg0/3
|
||||
- path_arg/3
|
||||
|
||||
|
||||
It is based on the Quintus Prolog arg library. Except for project, all
|
||||
predicates use the arg/3 argument pattern.
|
||||
This file has been included in the YAP library by Vitor Santos Costa, 2008. No error checking is actuallly performed within the package: this left to the C-code thaat implements arg``/3 and
|
||||
genarg/3.
|
||||
*
|
||||
* @defgroup args Term Argument Manipulation.
|
||||
*
|
||||
* @ingroup library
|
||||
*
|
||||
* @{
|
||||
*
|
||||
*This library extends arg/3 by supporting backtracking through
|
||||
*arguments and access to sub-arguments,
|
||||
*
|
||||
* - arg0/3
|
||||
* - args/3
|
||||
* - args0/3
|
||||
* - genarg/3
|
||||
* - genarg0/3
|
||||
* - path_arg/3
|
||||
*
|
||||
*
|
||||
*It is based on the Quintus Prolog public domain library. Except for
|
||||
*project, all predicates use the arg/3 argument pattern. This file has
|
||||
*been included in the YAP library by Vitor Santos Costa, 2008.
|
||||
*
|
||||
* No error checking is actuallly performed within the package: this
|
||||
*left to the C-code that implements arg/3 and genarg/3.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,7 @@ set (LIBRARY_PL_VLP
|
||||
)
|
||||
|
||||
install(FILES ${LIBRARY_PL_CLP}
|
||||
DESTINATION ${libpl}
|
||||
DESTINATION ${YAP_INSTALL_DATADIR}
|
||||
)
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@ set (LIBRARY_PL_CLP
|
||||
add_to_group( LIBRARY_PL_CLP pl_library )
|
||||
|
||||
install(FILES ${LIBRARY_PL_CLP}
|
||||
DESTINATION ${libpl}
|
||||
DESTINATION ${YAP_INSTALL_DATADIR}
|
||||
)
|
||||
|
||||
|
||||
|
@ -14,5 +14,5 @@ COMMAND ${CMAKE_COMMAND} -E touch visited
|
||||
DEPENDS ${DIALECTS_PL} ) # WORKING_DIRECTORY ${CMAKE_BINARY_DIR} )
|
||||
|
||||
install(FILES ${DIALECTS_PL}
|
||||
DESTINATION ${libpl}/dialect
|
||||
DESTINATION ${YAP_INSTALL_DATADIR}/dialect
|
||||
)
|
||||
|
@ -7,5 +7,5 @@ set (SDIALECTS_PL
|
||||
add_SubDirectory( fli )
|
||||
|
||||
install(FILES ${SDIALECTS_PL}
|
||||
DESTINATION ${libpl}/dialect/swi
|
||||
DESTINATION ${YAP_INSTALL_DATADIR}/dialect/swi
|
||||
)
|
||||
|
@ -8,7 +8,7 @@ add_component (libswi
|
||||
|
||||
MY_set_target_properties(libswi
|
||||
PROPERTIES
|
||||
# RPATH ${libdir} VERSION ${LIBYAPTAI_FULL_VERSION}
|
||||
# RPATH ${CMAKE_INSTALL_LIBDIR} VERSION ${LIBYAPTAI_FULL_VERSION}
|
||||
# SOVERSION ${LIBYAPTAI_MAJOR_VERSION}.${LIBYAPTAI_MINOR_VERSION}
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
)
|
||||
|
@ -58,7 +58,7 @@ add_component (libswi_os
|
||||
|
||||
set_target_properties(libswi_os
|
||||
PROPERTIES
|
||||
# RPATH ${libdir} VERSION ${LIBSWI_OS_FULL_VERSION}
|
||||
# RPATH ${CMAKE_INSTALL_LIBDIR} VERSION ${LIBSWI_OS_FULL_VERSION}
|
||||
# SOVERSION ${LIBSWI_OS_MAJOR_VERSION}.${LIBSWI_OS_MINOR_VERSION}
|
||||
POSITION_INDEPENDENT_CODE TRUE
|
||||
OUTPUT_NAME swi_os
|
||||
|
@ -45,7 +45,7 @@ add_library (libyaptai OBJECT
|
||||
|
||||
set_target_properties(libyaptai
|
||||
PROPERTIES
|
||||
# RPATH ${libdir} VERSION ${LIBYAPTAI_FULL_VERSION}
|
||||
# RPATH ${CMAKE_INSTALL_LIBDIR} VERSION ${LIBYAPTAI_FULL_VERSION}
|
||||
# SOVERSION ${LIBYAPTAI_MAJOR_VERSION}.${LIBYAPTAI_MINOR_VERSION}
|
||||
POSITION_INDEPENDENT_CODE TRUE
|
||||
OUTPUT_NAME yaptai
|
||||
|
@ -28,21 +28,20 @@
|
||||
:- dynamic gensym_key/2.
|
||||
|
||||
init_gensym(Key) :-
|
||||
assert(gensym_key(Atom,0) ).
|
||||
retractall(gensym_key(Key,_)),
|
||||
assert(gensym_key(Key,0) ).
|
||||
|
||||
gensym(Atom, New) :-
|
||||
retract(gensym_key(Atom,Id)), !,
|
||||
atomic_concat(Atom,Id,New),
|
||||
gensym(Key, New) :-
|
||||
retract(gensym_key(Key,Id)), !,
|
||||
atomic_concat(Key,Id,New),
|
||||
NId is Id+1,
|
||||
assert(gensym_key(Atom,NId)).
|
||||
assert(gensym_key(Key,NId)).
|
||||
gensym(Atom, New) :-
|
||||
atomic_concat(Atom,1,New),
|
||||
assert(gensym_key(Atom,2)).
|
||||
atomic_concat(Atom,0,New),
|
||||
assert(gensym_key(Atom,1)).
|
||||
|
||||
reset_gensym(Atom) :-
|
||||
retract(gensym_key(Atom,_)).
|
||||
|
||||
reset_gensym :-
|
||||
retractall(gensym_key(_,_)).
|
||||
|
||||
|
||||
|
@ -78,9 +78,9 @@ set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS HAVE_MPI_H=1)
|
||||
PUBLIC ${MPI_C_COMPILE_FLAGS})
|
||||
|
||||
install(TARGETS yap_mpi
|
||||
RUNTIME DESTINATION ${bindir}
|
||||
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${YAP_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${YAP_INSTALL_LIBDIR}
|
||||
)
|
||||
|
||||
endif (MPI_C_FOUND)
|
||||
|
@ -31,20 +31,3 @@
|
||||
portray_clause/2, % +Stream, +Clause
|
||||
portray_clause/3 % +Stream, +Clause, +Options
|
||||
]).
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
* @defgroup swi_listing SWI Prolog listing emulation
|
||||
* @ingroup library
|
||||
|
||||
emulates listing.pl, but just the interface for now.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
:- meta_predicate portray_clause( +, + , : ).
|
||||
|
||||
portray_clause(Stream, Term, M:Options) :-
|
||||
portray_clause( Stream, Term ).
|
||||
|
@ -57,7 +57,7 @@
|
||||
with the `use_module(library(lists))` command.
|
||||
*/
|
||||
|
||||
:- include(pl/bootlists).
|
||||
%:- include(pl/bootlists).
|
||||
|
||||
/** @pred list_concat(+ _Lists_,? _List_)
|
||||
|
||||
|
@ -65,7 +65,7 @@
|
||||
sumnodes_body(3,+,+,-,+,+),
|
||||
include(1,+,-),
|
||||
exclude(1,+,-),
|
||||
partition(2,+,-,-),
|
||||
partition(1,+,-,-),
|
||||
partition(2,+,-,-,-),
|
||||
foldl(3, +, +, -),
|
||||
foldl2(5, +, +, -, +, -),
|
||||
|
@ -77,7 +77,7 @@ aux_args([Arg|Args], MVars, [Arg|PArgs], PVars, [Arg|ProtoArgs]) :-
|
||||
aux_args([Arg|Args], [Arg|MVars], [PVar|PArgs], [PVar|PVars], ['_'|ProtoArgs]) :-
|
||||
aux_args(Args, MVars, PArgs, PVars, ProtoArgs).
|
||||
|
||||
pred_name(Macro, Arity, _ , Name) :-
|
||||
pred_name(Macro, Arity, P , Name) :-
|
||||
prolog_load_context(file, FullFileName),
|
||||
file_base_name( FullFileName, File ),
|
||||
prolog_load_context(term_position, Pos),
|
||||
|
@ -15,8 +15,8 @@ if (MATLAB_FOUND)
|
||||
target_link_libraries(matlab libYap $(MATLAB_LIBRARIES) )
|
||||
|
||||
install(TARGETS matlab
|
||||
RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR} )
|
||||
RUNTIME DESTINATION ${YAP_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${YAP_INSTALL_LIBDIR} )
|
||||
|
||||
endif (MATLAB_FOUND)
|
||||
|
||||
|
@ -775,6 +775,9 @@ rhs(log(RHS), Logs ) :- !,
|
||||
rhs(exp(RHS), Logs ) :- !,
|
||||
rhs(RHS, X1),
|
||||
matrix_to_exps( X1, Logs ).
|
||||
rhs(sum(RHS), Logs ) :- !,
|
||||
rhs(RHS, X1),
|
||||
matrix_sum( X1, Logs ).
|
||||
rhs(S, NS) :-
|
||||
rhs_opaque( S ), !,
|
||||
S = NS.
|
||||
|
@ -6,8 +6,8 @@ target_link_libraries(matrix libYap)
|
||||
set_target_properties (matrix PROPERTIES PREFIX "")
|
||||
|
||||
install(TARGETS matrix
|
||||
RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||
RUNTIME DESTINATION ${YAP_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${YAP_INSTALL_LIBDIR}
|
||||
LIBRARY DESTINATION ${YAP_INSTALL_LIBDIR}
|
||||
)
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -10,5 +10,5 @@ set_target_properties (yap_random PROPERTIES PREFIX "")
|
||||
endif()
|
||||
|
||||
MY_install(TARGETS yap_random
|
||||
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR} )
|
||||
LIBRARY DESTINATION ${YAP_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${YAP_INSTALL_LIBDIR} )
|
||||
|
@ -8,14 +8,11 @@
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: random.c *
|
||||
* Last rev: *
|
||||
* mods: *
|
||||
* comments: regular expression interpreter *
|
||||
* File: random.c * Last rev:
|
||||
** mods: * comments: regular expression interpreter *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "YapInterface.h"
|
||||
#include <math.h>
|
||||
#if defined(__MINGW32__) || _MSC_VER
|
||||
@ -26,9 +23,7 @@ X_API void init_random( void );
|
||||
|
||||
static short a1 = 27314, b1 = 9213, c1 = 17773;
|
||||
|
||||
static YAP_Bool
|
||||
p_random(void)
|
||||
{
|
||||
static YAP_Bool p_random(void) {
|
||||
double fli;
|
||||
long int t1, t2, t3;
|
||||
|
||||
@ -42,26 +37,20 @@ p_random(void)
|
||||
return (YAP_Unify(YAP_ARG1, YAP_MkFloatTerm(fli - (int)(fli))));
|
||||
}
|
||||
|
||||
static YAP_Bool
|
||||
p_setrand(void)
|
||||
{
|
||||
static YAP_Bool p_setrand(void) {
|
||||
a1 = YAP_IntOfTerm(YAP_ARG1);
|
||||
b1 = YAP_IntOfTerm(YAP_ARG2);
|
||||
c1 = YAP_IntOfTerm(YAP_ARG3);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
static YAP_Bool
|
||||
p_getrand(void)
|
||||
{
|
||||
static YAP_Bool p_getrand(void) {
|
||||
return (YAP_Unify(YAP_ARG1, YAP_MkIntTerm(a1)) &&
|
||||
YAP_Unify(YAP_ARG2, YAP_MkIntTerm(b1)) &&
|
||||
YAP_Unify(YAP_ARG3, YAP_MkIntTerm(c1)));
|
||||
}
|
||||
|
||||
X_API void
|
||||
init_random(void)
|
||||
{
|
||||
X_API void init_random(void) {
|
||||
YAP_UserCPredicate("random", p_random, 1);
|
||||
YAP_UserCPredicate("setrand", p_setrand, 3);
|
||||
YAP_UserCPredicate("getrand", p_getrand, 3);
|
||||
@ -71,10 +60,8 @@ init_random(void)
|
||||
|
||||
int WINAPI win_random(HANDLE, DWORD, LPVOID);
|
||||
|
||||
int WINAPI win_random(HANDLE hinst, DWORD reason, LPVOID reserved)
|
||||
{
|
||||
switch (reason)
|
||||
{
|
||||
int WINAPI win_random(HANDLE hinst, DWORD reason, LPVOID reserved) {
|
||||
switch (reason) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
|
@ -26,6 +26,6 @@ TARGET_INCLUDE_DIRECTORIES (regexp PUBLIC BEFORE
|
||||
${CMAKE_TOP_SOURCE_DIR}/include;${CMAKE_CURRENT_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR} )
|
||||
|
||||
install(TARGETS regexp
|
||||
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||
RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR} )
|
||||
LIBRARY DESTINATION ${YAP_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${YAP_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${YAP_INSTALL_LIBDIR} )
|
||||
|
@ -50,7 +50,7 @@ static char sccsid[] = "@(#)regcomp.c 8.5 (Berkeley) 3/20/94";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "YapInterface.h"
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
@ -48,11 +48,10 @@ static char sccsid[] = "@(#)regexec.c 8.3 (Berkeley) 3/20/94";
|
||||
* macros that code uses. This lets the same code operate on two different
|
||||
* representations for state sets.
|
||||
*/
|
||||
#include "config.h"
|
||||
#include "YapInterface.h"
|
||||
|
||||
#ifndef HAVE_REGEXEC
|
||||
|
||||
#include "YapInterface.h"
|
||||
#if HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
@ -68,8 +67,8 @@ static char sccsid[] = "@(#)regexec.c 8.3 (Berkeley) 3/20/94";
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#include "utils.h"
|
||||
#include "regex2.h"
|
||||
#include "utils.h"
|
||||
#include "yapregex.h"
|
||||
|
||||
#if used
|
||||
|
@ -22,7 +22,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#if HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
@ -40,6 +40,8 @@
|
||||
#ifndef _REGEX_H_
|
||||
#define _REGEX_H_
|
||||
|
||||
#include "YapInterface.h"
|
||||
|
||||
/* types */
|
||||
typedef int regoff_t;
|
||||
|
||||
|
@ -11,6 +11,6 @@ target_link_libraries(yap_rl libYap)
|
||||
set_target_properties (yap_rl PROPERTIES PREFIX "")
|
||||
|
||||
install(TARGETS yap_rl
|
||||
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR} )
|
||||
LIBRARY DESTINATION ${YAP_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${YAP_INSTALL_LIBDIR} )
|
||||
|
||||
|
@ -20,8 +20,6 @@
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP.lan>
|
||||
* @date Wed Nov 18 01:23:45 2015
|
||||
*
|
||||
* @brief interaction with the OS, be it Unix, Linux, or Windows.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
@ -33,6 +31,7 @@
|
||||
delete_file/1,
|
||||
delete_file/2,
|
||||
directory_files/2,
|
||||
directory_map/2,
|
||||
environ/2,
|
||||
exec/3,
|
||||
file_exists/2,
|
||||
@ -61,7 +60,11 @@
|
||||
working_directory/2
|
||||
]).
|
||||
|
||||
/** @defgroup operating_system_support, Operating System Functionality
|
||||
|
||||
|
||||
/** @defgroup operating_system_support Operating System Functionality
|
||||
* @brief Portable Interaction with the OS, be it Unix, Linux, OSX, or Windows.
|
||||
*
|
||||
@ingroup library
|
||||
@{
|
||||
|
||||
@ -74,13 +77,6 @@ are available through the `use_module(library(system))` command.
|
||||
*/
|
||||
|
||||
|
||||
/** @pred file_exists(+ _File_)
|
||||
|
||||
|
||||
The atom _File_ corresponds to an existing file.
|
||||
|
||||
|
||||
*/
|
||||
/** @pred file_property(+ _File_,? _Property_)
|
||||
|
||||
|
||||
@ -212,13 +208,6 @@ completes. YAP uses `/bin/sh` in Unix systems and `COMSPEC` in
|
||||
WIN32.
|
||||
|
||||
|
||||
*/
|
||||
/** @pred system(+ _Command_,- _Res_)
|
||||
|
||||
Interface to `system`: execute command _Command_ and unify
|
||||
_Res_ with the result.
|
||||
|
||||
|
||||
*/
|
||||
/** @pred tmp_file(+_Base_, - _File_)
|
||||
|
||||
@ -236,21 +225,6 @@ temporary files.
|
||||
Interface with _tmpnam_: obtain a new, unique file name _File_.
|
||||
|
||||
|
||||
*/
|
||||
/** @pred working_directory(- _Old_,+ _New_)
|
||||
|
||||
/** @pred working_directory(- _CurDir_,? _NextDir_)
|
||||
|
||||
|
||||
Fetch the current directory at _CurDir_. If _NextDir_ is bound
|
||||
to an atom, make its value the current working directory.
|
||||
|
||||
Unifies _Old_ with an absolute path to the current working directory
|
||||
and change working directory to _New_. Use the pattern
|
||||
`working_directory(CWD, CWD)` to get the current directory. See
|
||||
also `absolute_file_name/2` and chdir/1.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
:- use_module(library(lists), [append/3]).
|
||||
@ -451,15 +425,11 @@ if there is one. This predicate is backtrackable in Unix systems, but
|
||||
not currently in Win32 configurations.
|
||||
|
||||
~~~~~
|
||||
?- environ('HOME',X).
|
||||
?- environ('HOME',V).
|
||||
|
||||
X = 'C:\\cygwin\\home\\administrator' ?
|
||||
V = 'C:\\cygwin\\home\\administrator' ?
|
||||
~~~~~
|
||||
*/
|
||||
/** @pred environ(+E, -S)
|
||||
|
||||
Given an environment variable _E_ this predicate unifies the second
|
||||
argument _S_ with its value. _E_ may be bound to an atom, or just be
|
||||
_EnvVar_ may be bound to an atom, or just be
|
||||
unbound. In the latter case environ/2 will enumerate over all
|
||||
environment variables.
|
||||
|
||||
@ -666,6 +636,19 @@ get_shell(Shell, '/c') :-
|
||||
getenv('COMSPEC', Shell).
|
||||
get_shell('/bin/sh','-c').
|
||||
|
||||
/**
|
||||
* @pred system(+ _S_)
|
||||
|
||||
Passes command _S_ to the Bourne shell (on UNIX environments) or the
|
||||
current command interpreter in WIN32 environments.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @pred system
|
||||
|
||||
Passes command _S_ to the Bourne shell (on UNIX environments) or the
|
||||
current command interpreter in WIN32 environments.
|
||||
*/
|
||||
system :-
|
||||
default_shell(Command),
|
||||
do_system(Command, _Status, Error),
|
||||
@ -676,6 +659,13 @@ default_shell(Shell) :- win, !,
|
||||
default_shell('/bin/sh').
|
||||
|
||||
|
||||
/** @pred system(+ _Command_,- _Res_)
|
||||
|
||||
Interface to `system`: execute command _Command_ and unify
|
||||
_Res_ with the result.
|
||||
|
||||
|
||||
n*/
|
||||
system(Command, Status) :-
|
||||
G = system(Command, Status),
|
||||
check_command(Command, G),
|
||||
@ -764,13 +754,6 @@ rename_file(F0, F) :-
|
||||
rename_file(F0, F, Error),
|
||||
handle_system_internal(Error, off, rename_file(F0, F)).
|
||||
|
||||
/**
|
||||
* @pred system(+ _S_)
|
||||
|
||||
Passes command _S_ to the Bourne shell (on UNIX environments) or the
|
||||
current command interpreter in WIN32 environments.
|
||||
*/
|
||||
|
||||
/** @pred directory_files(+ _Dir_,+ _List_)
|
||||
|
||||
|
||||
@ -788,4 +771,46 @@ environments, and `findfirst` in WIN32 through the system_library buil
|
||||
directory_files(X,Y) :-
|
||||
list_directory(X,Y).
|
||||
|
||||
:- meta_predicate directory_map(+,1,-),
|
||||
rb_apply(+,+,2,-).
|
||||
|
||||
/** @pred directory_map(+ _Dir_, 1:_P_)
|
||||
|
||||
|
||||
Given a directory _Dir_, directory_map/2 visits all files in _Dir_,
|
||||
and verifies whether `P(F)` holds, where _F_ is the file's absolute
|
||||
path.
|
||||
|
||||
~~~~~
|
||||
?- directory_map('.', process).
|
||||
~~~~~
|
||||
|
||||
The predicates performs a left-recursive traversal. It does not protect against file system errors and it does not check for symbolic links.
|
||||
|
||||
*/
|
||||
directory_map(D, P) :-
|
||||
working_directory(_, D),
|
||||
list_directory(D,L),
|
||||
d_map(L,D, P).
|
||||
|
||||
d_map([],_,_).
|
||||
d_map(['.'|Fs],D, P) :-
|
||||
!,
|
||||
d_map(Fs,D, P).
|
||||
d_map(['..'|Fs],D, P) :-
|
||||
!,
|
||||
d_map(Fs, D, P).
|
||||
d_map([F|Fs], D, P) :-
|
||||
absolute_file_name( F, File, [prefix(D)] ),
|
||||
f_map(File, P),
|
||||
d_map(Fs, D, P).
|
||||
|
||||
f_map(File, P) :-
|
||||
catch( file_property( File, type(directory) ), _, fail ),
|
||||
directory_map( File, P).
|
||||
f_map(File, P) :-
|
||||
call(P,File).
|
||||
|
||||
|
||||
|
||||
/** @} */
|
||||
|
@ -39,8 +39,8 @@ set_target_properties (sys PROPERTIES PREFIX "")
|
||||
endif()
|
||||
|
||||
MY_install(TARGETS sys
|
||||
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||
RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR} )
|
||||
LIBRARY DESTINATION ${YAP_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${YAP_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${YAP_INSTALL_LIBDIR} )
|
||||
|
||||
configure_file ("sys_config.h.cmake" "sys_config.h" )
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user