small
- do not call goal expansion on meta-calls (that is done by undef). - docs updates - fix init code
This commit is contained in:
parent
14459cce03
commit
15404b3835
16
.gitignore
vendored
16
.gitignore
vendored
@ -78,6 +78,7 @@ yap
|
||||
*cmake_files
|
||||
C/pl-yap.c
|
||||
GitSHA1.c
|
||||
.vscode
|
||||
CMakeLists.txt.*
|
||||
FindPackageLog.txt
|
||||
GitSHA1.c
|
||||
@ -112,10 +113,13 @@ packages/real/rconfig.h
|
||||
|
||||
packages/ProbLog/problog/#completion.yap#
|
||||
|
||||
packages/ProbLog/problog_examples/output/out.dat
|
||||
packages/ProbLog/problog_examples/output
|
||||
packages/ProbLog/problog_examples/queries
|
||||
packages/swig/java/*.java
|
||||
packages/swig/java/*.class
|
||||
packages/swig/java/*.jar
|
||||
packages/swig/java/*wrap*
|
||||
*jnilib
|
||||
*.jar
|
||||
|
||||
packages/ProbLog/problog_examples/output/,_query_1_cluster_1.dot
|
||||
|
||||
packages/ProbLog/problog_examples/output/out.dat
|
||||
|
||||
packages/ProbLog/problog_examples/output/,_query_1_cluster_1
|
||||
packages/cplint/approx/simplecuddLPADs/LPADBDD
|
||||
|
23
C/adtdefs.c
23
C/adtdefs.c
@ -795,12 +795,6 @@ Prop Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod) {
|
||||
p->beamTable = NULL;
|
||||
#endif /* BEAM */
|
||||
/* careful that they don't cross MkFunctor */
|
||||
if (PRED_GOAL_EXPANSION_FUNC) {
|
||||
if (fe->PropsOfFE &&
|
||||
(RepPredProp(fe->PropsOfFE)->PredFlags & GoalExPredFlag)) {
|
||||
p->PredFlags |= GoalExPredFlag;
|
||||
}
|
||||
}
|
||||
if (!trueGlobalPrologFlag(DEBUG_INFO_FLAG)) {
|
||||
p->PredFlags |= NoTracePredFlag;
|
||||
}
|
||||
@ -918,7 +912,7 @@ Prop Yap_NewPredPropByAtom(AtomEntry *ae, Term cur_mod) {
|
||||
p->cs.p_code.FirstClause = p->cs.p_code.LastClause = NULL;
|
||||
p->cs.p_code.NOfClauses = 0;
|
||||
p->PredFlags = 0L;
|
||||
p->src.OwnerFile = AtomNil;
|
||||
p->src.OwnerFile = LOCAL_SourceFileName;
|
||||
p->OpcodeOfPred = UNDEF_OPCODE;
|
||||
p->cs.p_code.ExpandCode = EXPAND_OP_CODE;
|
||||
p->CodeOfPred = p->cs.p_code.TrueCodeOfPred = (yamop *)(&(p->OpcodeOfPred));
|
||||
@ -936,21 +930,6 @@ Prop Yap_NewPredPropByAtom(AtomEntry *ae, Term cur_mod) {
|
||||
p->beamTable = NULL;
|
||||
#endif
|
||||
/* careful that they don't cross MkFunctor */
|
||||
if (PRED_GOAL_EXPANSION_FUNC) {
|
||||
Prop p1 = ae->PropsOfAE;
|
||||
|
||||
while (p1) {
|
||||
PredEntry *pe = RepPredProp(p1);
|
||||
|
||||
if (pe->KindOfPE == PEProp) {
|
||||
if (pe->PredFlags & GoalExPredFlag) {
|
||||
p->PredFlags |= GoalExPredFlag;
|
||||
}
|
||||
break;
|
||||
}
|
||||
p1 = pe->NextOfPE;
|
||||
}
|
||||
}
|
||||
AddPropToAtom(ae, (PropEntry *)p);
|
||||
p0 = AbsPredProp(p);
|
||||
p->FunctorOfPred = (Functor)AbsAtom(ae);
|
||||
|
@ -3875,7 +3875,7 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
|
||||
cl->ClSize = osize;
|
||||
cip->code_addr = (yamop *)cl;
|
||||
} else if (mode == ASSEMBLING_CLAUSE &&
|
||||
(ap->PredFlags & SourcePredFlag ||
|
||||
(ap->PredFlags & (SourcePredFlag|MultiFileFlag) ||
|
||||
trueGlobalPrologFlag(SOURCE_FLAG ) ) &&
|
||||
!is_fact) {
|
||||
DBTerm *x;
|
||||
|
@ -1153,7 +1153,8 @@ atomic_concat2( USES_REGS1 )
|
||||
seq_tv_t *inpv = (seq_tv_t *)malloc(n*sizeof(seq_tv_t)), out;
|
||||
int i = 0;
|
||||
Atom at;
|
||||
|
||||
|
||||
if (n == 1) return Yap_unify(ARG2, HeadOfTerm(t1));
|
||||
if (!inpv) {
|
||||
LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP;
|
||||
free(inpv);
|
||||
|
@ -2394,6 +2394,7 @@ X_API void YAP_ClearExceptions(void) {
|
||||
}
|
||||
|
||||
X_API int YAP_InitConsult(int mode, const char *filename, int *osnop) {
|
||||
CACHE_REGS
|
||||
FILE *f;
|
||||
int sno;
|
||||
BACKUP_MACHINE_REGS();
|
||||
@ -2403,7 +2404,7 @@ X_API int YAP_InitConsult(int mode, const char *filename, int *osnop) {
|
||||
}
|
||||
bool consulted = (mode == YAP_CONSULT_MODE);
|
||||
Yap_init_consult(consulted, filename);
|
||||
f = fopen(filename, "r");
|
||||
f = fopen(Yap_AbsoluteFile(filename, LOCAL_FileNameBuf, FILENAME_MAX-1), "r");
|
||||
if (!f)
|
||||
return -1;
|
||||
sno = Yap_OpenStream(f, NULL, TermNil, Input_Stream_f);
|
||||
@ -2717,7 +2718,7 @@ X_API Int YAP_Init(YAP_init_args *yap_init) {
|
||||
setBooleanGlobalPrologFlag(HALT_AFTER_CONSULT_FLAG,
|
||||
yap_init->HaltAfterConsult);
|
||||
}
|
||||
/* tell the system who should cope with interrupts */
|
||||
/* tell the scystem who should cope with interrupts */
|
||||
Yap_ExecutionMode = yap_init->ExecutionMode;
|
||||
if (do_bootstrap) {
|
||||
restore_result = YAP_BOOT_FROM_PROLOG;
|
||||
@ -3326,7 +3327,6 @@ X_API int YAP_FileNoFromStream(Term t) {
|
||||
if (IsVarTerm(t))
|
||||
return -1;
|
||||
return Yap_StreamToFileNo(t);
|
||||
return -1;
|
||||
}
|
||||
|
||||
X_API void *YAP_FileDescriptorFromStream(Term t) {
|
||||
@ -3335,7 +3335,6 @@ X_API void *YAP_FileDescriptorFromStream(Term t) {
|
||||
if (IsVarTerm(t))
|
||||
return NULL;
|
||||
return Yap_FileDescriptorFromStream(t);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
X_API void *YAP_Record(Term t) {
|
||||
@ -3588,7 +3587,6 @@ Term YAP_BPROLOG_curr_toam_status;
|
||||
* @return a positive number with the size, or 0.
|
||||
*/
|
||||
size_t YAP_UTF8_TextLength(Term t) {
|
||||
Term *aux;
|
||||
utf8proc_uint8_t dst[8];
|
||||
size_t sz = 0;
|
||||
|
||||
|
368
C/cdmgr.c
368
C/cdmgr.c
@ -212,7 +212,7 @@
|
||||
* fix several bugs in save/restore.b
|
||||
*
|
||||
* Revision 1.171 2005/10/29 01:28:37 vsc
|
||||
* make undefined more ISO compatible.
|
||||
* make undefinedore ISO compatible.
|
||||
*
|
||||
* Revision 1.170 2005/10/18 17:04:43 vsc
|
||||
* 5.1:
|
||||
@ -493,7 +493,6 @@ static int not_was_reconsulted(PredEntry *, Term, int);
|
||||
static int RemoveIndexation(PredEntry *);
|
||||
static Int p_number_of_clauses(USES_REGS1);
|
||||
static Int p_compile(USES_REGS1);
|
||||
static Int p_compile_dynamic(USES_REGS1);
|
||||
static Int p_purge_clauses(USES_REGS1);
|
||||
static Int p_setspy(USES_REGS1);
|
||||
static Int p_rmspy(USES_REGS1);
|
||||
@ -1477,12 +1476,6 @@ static void add_first_static(PredEntry *p, yamop *cp, int spy_flag) {
|
||||
CACHE_REGS
|
||||
yamop *pt = cp;
|
||||
|
||||
if (is_logupd(p)) {
|
||||
if (p == PredGoalExpansion || p->FunctorOfPred == FunctorGoalExpansion2) {
|
||||
PRED_GOAL_EXPANSION_ON = TRUE;
|
||||
Yap_InitComma();
|
||||
}
|
||||
} else {
|
||||
#ifdef TABLING
|
||||
if (is_tabled(p)) {
|
||||
p->OpcodeOfPred = INDEX_OPCODE;
|
||||
@ -1490,7 +1483,6 @@ static void add_first_static(PredEntry *p, yamop *cp, int spy_flag) {
|
||||
(yamop *)(&(p->OpcodeOfPred));
|
||||
}
|
||||
#endif /* TABLING */
|
||||
}
|
||||
p->cs.p_code.TrueCodeOfPred = pt;
|
||||
p->cs.p_code.FirstClause = p->cs.p_code.LastClause = cp;
|
||||
p->OpcodeOfPred = pt->opc;
|
||||
@ -1531,10 +1523,7 @@ static void add_first_dynamic(PredEntry *p, yamop *cp, int spy_flag) {
|
||||
CACHE_REGS
|
||||
yamop *ncp = ((DynamicClause *)NULL)->ClCode;
|
||||
DynamicClause *cl;
|
||||
if (p == PredGoalExpansion || p->FunctorOfPred == FunctorGoalExpansion2) {
|
||||
PRED_GOAL_EXPANSION_ON = TRUE;
|
||||
Yap_InitComma();
|
||||
}
|
||||
|
||||
if (PROFILING) {
|
||||
p->PredFlags |= ProfiledPredFlag;
|
||||
spy_flag = TRUE;
|
||||
@ -1615,8 +1604,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 */
|
||||
@ -1851,7 +1840,7 @@ static int not_was_reconsulted(PredEntry *p, Term t, int mode) {
|
||||
!(p->PredFlags & MultiFileFlag)) /* we are in reconsult mode */ {
|
||||
retract_all(p, Yap_static_in_use(p, TRUE));
|
||||
}
|
||||
p->src.OwnerFile = Yap_ConsultingFile(PASS_REGS1);
|
||||
//p->src.OwnerFile = Yap_ConsultingFile(PASS_REGS1);
|
||||
}
|
||||
LOCAL_LastAssertedPred = p;
|
||||
return TRUE; /* careful */
|
||||
@ -1948,7 +1937,7 @@ bool Yap_multiple(PredEntry *ap, int mode USES_REGS) {
|
||||
register consult_obj *fp;
|
||||
|
||||
if ((ap->PredFlags & (MultiFileFlag | LogUpdatePredFlag | DynamicPredFlag)) ||
|
||||
mode == consult)
|
||||
mode == TermConsult)
|
||||
return false;
|
||||
if (LOCAL_consult_level == 0)
|
||||
return false;
|
||||
@ -1974,126 +1963,6 @@ static int is_fact(Term t) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void mark_preds_with_this_func(Functor f, Prop p0) {
|
||||
PredEntry *pe = RepPredProp(p0);
|
||||
|
||||
pe->PredFlags |= GoalExPredFlag;
|
||||
Prop p = f->PropsOfFE;
|
||||
|
||||
while (p) {
|
||||
Prop nextp = p->NextOfPE;
|
||||
pe = RepPredProp(p);
|
||||
|
||||
pe->PredFlags |= GoalExPredFlag;
|
||||
p = nextp;
|
||||
}
|
||||
}
|
||||
|
||||
static void mark_preds_with_this_atom(Prop p) {
|
||||
while (p) {
|
||||
Prop nextp = p->NextOfPE;
|
||||
if (p->KindOfPE == PEProp)
|
||||
RepPredProp(p)->PredFlags |= GoalExPredFlag;
|
||||
p = nextp;
|
||||
}
|
||||
}
|
||||
|
||||
static void goal_expansion_support(PredEntry *p, Term tf) {
|
||||
if (p == PredGoalExpansion) {
|
||||
Term tg = ArgOfTerm(1, tf);
|
||||
Term tm = ArgOfTerm(2, tf);
|
||||
|
||||
if (IsVarTerm(tg) || IsVarTerm(tm)) {
|
||||
if (!IsVarTerm(tg)) {
|
||||
/* this is the complicated case, first I need to inform
|
||||
predicates for this functor */
|
||||
PRED_GOAL_EXPANSION_FUNC = TRUE;
|
||||
if (IsAtomTerm(tg)) {
|
||||
AtomEntry *ae = RepAtom(AtomOfTerm(tg));
|
||||
Prop p0 = ae->PropsOfAE;
|
||||
int found = FALSE;
|
||||
|
||||
while (p0) {
|
||||
PredEntry *pe = RepPredProp(p0);
|
||||
if (pe->KindOfPE == PEProp) {
|
||||
pe->PredFlags |= GoalExPredFlag;
|
||||
found = TRUE;
|
||||
}
|
||||
p0 = pe->NextOfPE;
|
||||
}
|
||||
if (!found) {
|
||||
PredEntry *npe =
|
||||
RepPredProp(PredPropByAtom(AtomOfTerm(tg), IDB_MODULE));
|
||||
npe->PredFlags |= GoalExPredFlag;
|
||||
}
|
||||
} else if (IsApplTerm(tg)) {
|
||||
FunctorEntry *fe = (FunctorEntry *)FunctorOfTerm(tg);
|
||||
Prop p0;
|
||||
|
||||
p0 = fe->PropsOfFE;
|
||||
if (p0) {
|
||||
mark_preds_with_this_func(FunctorOfTerm(tg), p0);
|
||||
} else {
|
||||
CACHE_REGS
|
||||
Term mod = CurrentModule;
|
||||
PredEntry *npe;
|
||||
if (CurrentModule == PROLOG_MODULE)
|
||||
mod = IDB_MODULE;
|
||||
npe = RepPredProp(PredPropByFunc(fe, mod));
|
||||
npe->PredFlags |= GoalExPredFlag;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
PRED_GOAL_EXPANSION_ALL = TRUE;
|
||||
}
|
||||
} else {
|
||||
if (IsAtomTerm(tm)) {
|
||||
if (IsAtomTerm(tg)) {
|
||||
PredEntry *p = RepPredProp(PredPropByAtom(AtomOfTerm(tg), tm));
|
||||
p->PredFlags |= GoalExPredFlag;
|
||||
} else if (IsApplTerm(tg)) {
|
||||
PredEntry *p = RepPredProp(PredPropByFunc(FunctorOfTerm(tg), tm));
|
||||
p->PredFlags |= GoalExPredFlag;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (p->FunctorOfPred == FunctorGoalExpansion2) {
|
||||
Term tg = ArgOfTerm(1, tf);
|
||||
|
||||
if (IsVarTerm(tg)) {
|
||||
PRED_GOAL_EXPANSION_ALL = TRUE;
|
||||
} else if (IsApplTerm(tg)) {
|
||||
FunctorEntry *fe = (FunctorEntry *)FunctorOfTerm(tg);
|
||||
Prop p0;
|
||||
PredEntry *npe;
|
||||
|
||||
p0 = fe->PropsOfFE;
|
||||
if (p0 && (p->ModuleOfPred == PROLOG_MODULE ||
|
||||
p->ModuleOfPred == SYSTEM_MODULE ||
|
||||
p->ModuleOfPred == USER_MODULE)) {
|
||||
mark_preds_with_this_func(fe, p0);
|
||||
PRED_GOAL_EXPANSION_FUNC = TRUE;
|
||||
}
|
||||
npe = RepPredProp(PredPropByFunc(fe, p->ModuleOfPred));
|
||||
npe->PredFlags |= GoalExPredFlag;
|
||||
} else if (IsAtomTerm(tg)) {
|
||||
Atom at = AtomOfTerm(tg);
|
||||
Prop p0;
|
||||
PredEntry *npe;
|
||||
|
||||
p0 = RepAtom(at)->PropsOfAE;
|
||||
if (p0 && (p->ModuleOfPred == PROLOG_MODULE ||
|
||||
p->ModuleOfPred == SYSTEM_MODULE ||
|
||||
p->ModuleOfPred == USER_MODULE)) {
|
||||
mark_preds_with_this_atom(p0);
|
||||
PRED_GOAL_EXPANSION_FUNC = TRUE;
|
||||
}
|
||||
npe = RepPredProp(PredPropByAtom(at, p->ModuleOfPred));
|
||||
npe->PredFlags |= GoalExPredFlag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Int Yap_source_line_no(void) {
|
||||
CACHE_REGS
|
||||
return LOCAL_SourceFileLineno;
|
||||
@ -2104,6 +1973,40 @@ Atom Yap_source_file_name(void) {
|
||||
return LOCAL_SourceFileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief we cannot add clauses to the proceduree
|
||||
*
|
||||
* @param p predicate
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
bool Yap_constPred( PredEntry *p)
|
||||
{
|
||||
pred_flags_t pflags;
|
||||
pflags = p->PredFlags;
|
||||
|
||||
|
||||
if (pflags & ((UserCPredFlag | CArgsPredFlag | NumberDBPredFlag | AtomDBPredFlag |
|
||||
TestPredFlag | AsmPredFlag | CPredFlag | BinaryPredFlag) ) )
|
||||
return true;
|
||||
|
||||
if (p->PredFlags & (SysExportPredFlag|MultiFileFlag|DynamicPredFlag))
|
||||
return false;
|
||||
|
||||
if (Yap_isSystemModule(p->ModuleOfPred)){
|
||||
if (p->cs.p_code.NOfClauses == 0) {
|
||||
p->src.OwnerFile = LOCAL_SourceFileName;
|
||||
return false;
|
||||
}
|
||||
if ( p->src.OwnerFile == LOCAL_SourceFileName ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static int addclause(Term t, yamop *cp, int mode, Term mod, Term *t4ref)
|
||||
/*
|
||||
*
|
||||
@ -2137,19 +2040,13 @@ static int addclause(Term t, yamop *cp, int mode, Term mod, Term *t4ref)
|
||||
}
|
||||
Yap_PutValue(AtomAbol, TermNil);
|
||||
PELOCK(20, p);
|
||||
pflags = p->PredFlags;
|
||||
/* we are redefining a prolog module predicate */
|
||||
if (!(p->PredFlags & SysExportPredFlag) &&
|
||||
((pflags &
|
||||
(UserCPredFlag | CArgsPredFlag | NumberDBPredFlag | AtomDBPredFlag |
|
||||
TestPredFlag | AsmPredFlag | CPredFlag | BinaryPredFlag)) ||
|
||||
(p->ModuleOfPred == PROLOG_MODULE && mod != TermProlog && mod))) {
|
||||
// printf("p=%p p->PredFlags=%lx %lx p->cs.p_code.NOfClauses=%ld\n", p,
|
||||
// p->PredFlags,SysExportPredFlag , p->cs.p_code.NOfClauses);
|
||||
if (Yap_constPred(p)) {
|
||||
addcl_permission_error(RepAtom(at), Arity, FALSE);
|
||||
UNLOCKPE(30, p);
|
||||
return TermNil;
|
||||
}
|
||||
pflags = p->PredFlags;
|
||||
/* we are redefining a prolog module predicate */
|
||||
if (pflags & MegaClausePredFlag) {
|
||||
split_megaclause(p);
|
||||
@ -2162,13 +2059,13 @@ static int addclause(Term t, yamop *cp, int mode, Term mod, Term *t4ref)
|
||||
}
|
||||
if (pflags & (SpiedPredFlag | CountPredFlag | ProfiledPredFlag))
|
||||
spy_flag = TRUE;
|
||||
goal_expansion_support(p, tf);
|
||||
if (Yap_discontiguous(p PASS_REGS)) {
|
||||
if (mode == consult &&
|
||||
Yap_discontiguous(p PASS_REGS)) {
|
||||
Term disc[3], sc[4];
|
||||
if (p->ArityOfPE) {
|
||||
disc[0] = MkAtomTerm(NameOfFunctor(p->FunctorOfPred));
|
||||
} else {
|
||||
disc[1] = MkAtomTerm((Atom)(p->FunctorOfPred));
|
||||
disc[0] = MkAtomTerm((Atom)(p->FunctorOfPred));
|
||||
}
|
||||
disc[1] = MkIntTerm(p->ArityOfPE);
|
||||
disc[2] = Yap_Module_Name(p);
|
||||
@ -2181,11 +2078,11 @@ static int addclause(Term t, yamop *cp, int mode, Term mod, Term *t4ref)
|
||||
sc[1] = MkAtomTerm(AtomWarning);
|
||||
Yap_PrintWarning(Yap_MkApplTerm(Yap_MkFunctor(AtomError,2), 2, sc));
|
||||
} else if (Yap_multiple(p, mode PASS_REGS)) {
|
||||
Term disc[4], sc[4];
|
||||
Term disc[4], sc[4];
|
||||
if (p->ArityOfPE) {
|
||||
disc[0] = MkAtomTerm(NameOfFunctor(p->FunctorOfPred));
|
||||
} else {
|
||||
disc[1] = MkAtomTerm((Atom)(p->FunctorOfPred));
|
||||
disc[0] = MkAtomTerm((Atom)(p->FunctorOfPred));
|
||||
}
|
||||
disc[1] = MkIntTerm(p->ArityOfPE);
|
||||
disc[2] = Yap_Module_Name(p);
|
||||
@ -2426,36 +2323,8 @@ void Yap_add_logupd_clause(PredEntry *pe, LogUpdClause *cl, int mode) {
|
||||
}
|
||||
}
|
||||
|
||||
static Int p_compile(USES_REGS1) { /* '$compile'(+C,+Flags, Mod) */
|
||||
Term t = Deref(ARG1);
|
||||
Term t1 = Deref(ARG2);
|
||||
Term mod = Deref(ARG4);
|
||||
Term tn = TermNil;
|
||||
yamop *codeadr;
|
||||
|
||||
if (IsVarTerm(t1) || !IsIntTerm(t1))
|
||||
return (FALSE);
|
||||
if (IsVarTerm(mod) || !IsAtomTerm(mod))
|
||||
return (FALSE);
|
||||
|
||||
YAPEnterCriticalSection();
|
||||
codeadr =
|
||||
Yap_cclause(t, 4, mod, Deref(ARG3)); /* vsc: give the number of arguments
|
||||
to cclause in case there is overflow */
|
||||
t = Deref(ARG1); /* just in case there was an heap overflow */
|
||||
if (!LOCAL_ErrorMessage)
|
||||
addclause(t, codeadr, (int)(IntOfTerm(t1) & 3), mod, &tn);
|
||||
YAPLeaveCriticalSection();
|
||||
if (LOCAL_ErrorMessage) {
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Int
|
||||
p_compile_dynamic(USES_REGS1) { /* '$compile_dynamic'(+C,+Flags,Mod,-Ref) */
|
||||
p_compile(USES_REGS1) { /* '$compile'(+C,+Flags,+C0,-Ref) */
|
||||
Term t = Deref(ARG1);
|
||||
Term t1 = Deref(ARG2);
|
||||
Term mod = Deref(ARG4);
|
||||
@ -2466,19 +2335,24 @@ static Int
|
||||
return FALSE;
|
||||
if (IsVarTerm(mod) || !IsAtomTerm(mod))
|
||||
return FALSE;
|
||||
if (IsAtomTerm(t1)) {
|
||||
if (RepAtom(AtomOfTerm(t1))->StrOfAE[0] == 'f')
|
||||
if (t1 == TermConsult) {
|
||||
mode = consult;
|
||||
} else if (t1 == TermReconsult) {
|
||||
mode = consult;
|
||||
} else if (t1 == TermAsserta) {
|
||||
mode = asserta;
|
||||
else
|
||||
} else if (t1 == TermAssertz) {
|
||||
mode = assertz;
|
||||
} else
|
||||
mode = IntegerOfTerm(t1);
|
||||
} else if (t1 == TermAssertaStatic) {
|
||||
mode = asserta;
|
||||
} else if (t1 == TermAssertzStatic) {
|
||||
mode = assertz;
|
||||
}
|
||||
/* separate assert in current file from reconsult
|
||||
if (mode == assertz && LOCAL_consult_level && mod == CurrentModule)
|
||||
mode = consult;
|
||||
*/
|
||||
old_optimize = optimizer_on;
|
||||
optimizer_on = FALSE;
|
||||
YAPEnterCriticalSection();
|
||||
code_adr = Yap_cclause(t, 5, mod,
|
||||
Deref(ARG3)); /* vsc: give the number of arguments to
|
||||
@ -2497,7 +2371,7 @@ static Int
|
||||
return FALSE;
|
||||
}
|
||||
YAPLeaveCriticalSection();
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
Atom Yap_ConsultingFile(USES_REGS1) {
|
||||
@ -2507,6 +2381,9 @@ Atom Yap_ConsultingFile(USES_REGS1) {
|
||||
// return(AtomUserIn);
|
||||
return StreamFullName(sno);
|
||||
}
|
||||
if (LOCAL_SourceFileName != NULL) {
|
||||
return LOCAL_SourceFileName;
|
||||
}
|
||||
if (LOCAL_consult_level == 0) {
|
||||
return (AtomUser);
|
||||
} else {
|
||||
@ -2883,6 +2760,23 @@ static Int p_new_multifile(USES_REGS1) { /* '$new_multifile'(+N,+Ar,+Mod) */
|
||||
else
|
||||
pe = RepPredProp(PredPropByFunc(Yap_MkFunctor(at, arity), mod));
|
||||
PELOCK(26, pe);
|
||||
if (pe->PredFlags & (UserCPredFlag | CArgsPredFlag |
|
||||
NumberDBPredFlag | AtomDBPredFlag |
|
||||
TestPredFlag | AsmPredFlag |
|
||||
CPredFlag | BinaryPredFlag)) {
|
||||
UNLOCKPE(26, pe);
|
||||
addcl_permission_error(RepAtom(at), arity, FALSE);
|
||||
return false;
|
||||
}
|
||||
if (pe->PredFlags & MultiFileFlag) {
|
||||
UNLOCKPE(26, pe);
|
||||
return true;
|
||||
}
|
||||
if (pe->cs.p_code.NOfClauses) {
|
||||
UNLOCKPE(26, pe);
|
||||
addcl_permission_error(RepAtom(at), arity, FALSE);
|
||||
return false;
|
||||
}
|
||||
pe->PredFlags |= MultiFileFlag;
|
||||
/* mutifile-predicates are weird, they do not seat really on the default
|
||||
* module */
|
||||
@ -2894,7 +2788,7 @@ static Int p_new_multifile(USES_REGS1) { /* '$new_multifile'(+N,+Ar,+Mod) */
|
||||
}
|
||||
pe->src.OwnerFile = Yap_ConsultingFile(PASS_REGS1);
|
||||
UNLOCKPE(43, pe);
|
||||
return (TRUE);
|
||||
return true;
|
||||
}
|
||||
|
||||
static Int p_is_multifile(USES_REGS1) { /* '$is_multifile'(+S,+Mod) */
|
||||
@ -2949,7 +2843,7 @@ static Int p_is_discontiguous(USES_REGS1) { /* '$is_multifile'(+S,+Mod) */
|
||||
PredEntry *pe;
|
||||
bool out;
|
||||
|
||||
pe = get_pred(Deref(ARG1), Deref(ARG2), "discontigus");
|
||||
pe = get_pred(Deref(ARG1), Deref(ARG2), "discontiguous");
|
||||
if (EndOfPAEntr(pe))
|
||||
return FALSE;
|
||||
PELOCK(27, pe);
|
||||
@ -3099,68 +2993,6 @@ static Int p_is_metapredicate(USES_REGS1) { /* '$is_metapredicate'(+P) */
|
||||
return out;
|
||||
}
|
||||
|
||||
static Int p_is_expandgoalormetapredicate(
|
||||
USES_REGS1) { /* '$is_expand_goal_predicate'(+P) */
|
||||
PredEntry *pe;
|
||||
Term t = Deref(ARG1);
|
||||
Term mod = Deref(ARG2);
|
||||
bool out;
|
||||
|
||||
if (PRED_GOAL_EXPANSION_ALL)
|
||||
return TRUE;
|
||||
if (IsVarTerm(t)) {
|
||||
return (FALSE);
|
||||
} else if (IsAtomTerm(t)) {
|
||||
Atom at = AtomOfTerm(t);
|
||||
pe = RepPredProp(Yap_GetPredPropByAtom(at, mod));
|
||||
if (EndOfPAEntr(pe)) {
|
||||
if (PRED_GOAL_EXPANSION_FUNC) {
|
||||
Prop p1 = RepAtom(at)->PropsOfAE;
|
||||
|
||||
while (p1) {
|
||||
PredEntry *pe = RepPredProp(p1);
|
||||
|
||||
if (pe->KindOfPE == PEProp) {
|
||||
if (pe->PredFlags & GoalExPredFlag) {
|
||||
PredPropByAtom(at, mod);
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
p1 = pe->NextOfPE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor fun = FunctorOfTerm(t);
|
||||
|
||||
if (IsExtensionFunctor(fun)) {
|
||||
return FALSE;
|
||||
}
|
||||
pe = RepPredProp(Yap_GetPredPropByFunc(fun, mod));
|
||||
if (EndOfPAEntr(pe)) {
|
||||
if (PRED_GOAL_EXPANSION_FUNC) {
|
||||
FunctorEntry *fe = (FunctorEntry *)fun;
|
||||
if (fe->PropsOfFE &&
|
||||
(RepPredProp(fe->PropsOfFE)->PredFlags & GoalExPredFlag)) {
|
||||
PredPropByFunc(fun, mod);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
PELOCK(33, pe);
|
||||
out = (pe->PredFlags & (GoalExPredFlag | MetaPredFlag));
|
||||
UNLOCKPE(53, pe);
|
||||
return (out);
|
||||
}
|
||||
|
||||
static Int p_pred_exists(USES_REGS1) { /* '$pred_exists'(+P,+M) */
|
||||
PredEntry *pe;
|
||||
bool out;
|
||||
@ -3265,7 +3097,7 @@ static Int p_kill_dynamic(USES_REGS1) { /* '$kill_dynamic'(P,M) */
|
||||
pe->OpcodeOfPred = UNDEF_OPCODE;
|
||||
pe->cs.p_code.TrueCodeOfPred = pe->CodeOfPred =
|
||||
(yamop *)(&(pe->OpcodeOfPred));
|
||||
pe->PredFlags = pe->PredFlags & GoalExPredFlag;
|
||||
pe->PredFlags = 0;
|
||||
UNLOCKPE(62, pe);
|
||||
return (TRUE);
|
||||
}
|
||||
@ -3475,6 +3307,34 @@ static Int p_clean_up_dead_clauses(USES_REGS1) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Int /* $ml_system_predicate(P) */
|
||||
p_mk_system_pred(USES_REGS1) {
|
||||
PredEntry *pe;
|
||||
|
||||
Term t1 = Deref(ARG1);
|
||||
Term tm = Deref(ARG2);
|
||||
if (IsVarTerm(t1))
|
||||
return FALSE;
|
||||
if (IsAtomTerm(t1)) {
|
||||
pe = RepPredProp(PredPropByAtom(AtomOfTerm(t1), tm));
|
||||
pe->ModuleOfPred = PROLOG_MODULE;
|
||||
return true;
|
||||
} else if (IsApplTerm(t1)) {
|
||||
Functor funt = FunctorOfTerm(t1);
|
||||
if (IsExtensionFunctor(funt)) {
|
||||
return FALSE;
|
||||
}
|
||||
pe = RepPredProp(PredPropByFunc(funt, tm));
|
||||
pe->ModuleOfPred = PROLOG_MODULE;
|
||||
return true;
|
||||
} else if (IsPairTerm(t1)) {
|
||||
pe = RepPredProp(PredPropByFunc(FunctorDot, tm));
|
||||
pe->ModuleOfPred = PROLOG_MODULE;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static Int /* $system_predicate(P) */
|
||||
p_system_pred(USES_REGS1) {
|
||||
PredEntry *pe;
|
||||
@ -5166,15 +5026,12 @@ void Yap_InitCdMgr(void) {
|
||||
/* gc() may happen during compilation, hence these predicates are
|
||||
now unsafe */
|
||||
Yap_InitCPred("$predicate_flags", 4, predicate_flags, SyncPredFlag);
|
||||
Yap_InitCPred("$compile", 4, p_compile, SyncPredFlag);
|
||||
Yap_InitCPred("$compile_dynamic", 5, p_compile_dynamic, SyncPredFlag);
|
||||
Yap_InitCPred("$compile", 5, p_compile, SyncPredFlag);
|
||||
Yap_InitCPred("$purge_clauses", 2, p_purge_clauses,
|
||||
SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("$is_dynamic", 2, p_is_dynamic, TestPredFlag | SafePredFlag);
|
||||
Yap_InitCPred("$is_metapredicate", 2, p_is_metapredicate,
|
||||
TestPredFlag | SafePredFlag);
|
||||
Yap_InitCPred("$is_expand_goal_or_meta_predicate", 2,
|
||||
p_is_expandgoalormetapredicate, TestPredFlag | SafePredFlag);
|
||||
Yap_InitCPred("$is_log_updatable", 2, p_is_log_updatable,
|
||||
TestPredFlag | SafePredFlag);
|
||||
Yap_InitCPred("$is_thread_local", 2, p_is_thread_local,
|
||||
@ -5223,6 +5080,7 @@ void Yap_InitCdMgr(void) {
|
||||
SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("$set_pred_module", 2, p_set_pred_module, SafePredFlag);
|
||||
Yap_InitCPred("$set_pred_owner", 2, p_set_pred_owner, SafePredFlag);
|
||||
Yap_InitCPred("$mk_system_predicate", 2, p_mk_system_pred, SafePredFlag);
|
||||
Yap_InitCPred("$system_predicate", 2, p_system_pred, SafePredFlag);
|
||||
Yap_InitCPred("$all_system_predicate", 3, p_all_system_pred, SafePredFlag);
|
||||
Yap_InitCPred("$hide_predicate", 2, p_hide_predicate, SafePredFlag);
|
||||
|
64
C/errors.c
64
C/errors.c
@ -602,3 +602,67 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
LOCAL_PrologMode &= ~InErrorMode;
|
||||
return P;
|
||||
}
|
||||
|
||||
static Int
|
||||
is_boolean( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
//Term Context = Deref(ARG2);
|
||||
if (IsVarTerm(t)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, t, NULL);
|
||||
return false;
|
||||
}
|
||||
return t == TermTrue || t == TermFalse;
|
||||
}
|
||||
|
||||
|
||||
static Int
|
||||
is_callable( USES_REGS1 )
|
||||
{
|
||||
Term G = Deref(ARG1);
|
||||
//Term Context = Deref(ARG2);
|
||||
while (true) {
|
||||
if (IsVarTerm(G)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, G, NULL);
|
||||
return false;
|
||||
}
|
||||
if (IsApplTerm(G)) {
|
||||
Functor f = FunctorOfTerm(G);
|
||||
if (IsExtensionFunctor(f)) {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, G, NULL);
|
||||
}
|
||||
if (f == FunctorModule) {
|
||||
Term tm = ArgOfTerm( 1, G);
|
||||
if (IsVarTerm(tm)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, G, NULL);
|
||||
return false;
|
||||
}
|
||||
if (!IsAtomTerm(tm)) {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, G, NULL);
|
||||
return false;
|
||||
}
|
||||
G = ArgOfTerm( 2, G );
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else if (IsPairTerm(G) || IsAtomTerm(G)) {
|
||||
return true;
|
||||
} else {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, G, NULL);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Yap_InitErrorPreds( void )
|
||||
{
|
||||
CACHE_REGS
|
||||
Term cm = CurrentModule;
|
||||
CurrentModule = ERROR_MODULE;
|
||||
Yap_InitCPred("is_boolean", 2, is_boolean, 0L);
|
||||
Yap_InitCPred("is_callable", 2, is_callable, 0L);
|
||||
CurrentModule = cm;
|
||||
}
|
||||
|
65
C/exec.c
65
C/exec.c
@ -192,13 +192,7 @@ inline static Int do_execute(Term t, Term mod USES_REGS) {
|
||||
Term t0 = t;
|
||||
/* first do predicate expansion, even before you process signals.
|
||||
This way you don't get to spy goal_expansion(). */
|
||||
if (PRED_GOAL_EXPANSION_ALL) {
|
||||
/* disable creeping when we do goal expansion */
|
||||
if (!LOCAL_InterruptsDisabled && Yap_get_signal(YAP_CREEP_SIGNAL)) {
|
||||
CalculateStackGap(PASS_REGS1);
|
||||
}
|
||||
return CallMetaCall(ARG1, mod PASS_REGS);
|
||||
} else if (Yap_has_a_signal() && !LOCAL_InterruptsDisabled &&
|
||||
if (Yap_has_a_signal() && !LOCAL_InterruptsDisabled &&
|
||||
!(LOCAL_PrologMode & (AbortMode | InterruptMode | SystemMode))) {
|
||||
return EnterCreepMode(t, mod PASS_REGS);
|
||||
}
|
||||
@ -222,7 +216,7 @@ restart_exec:
|
||||
pen = RepPredProp(PredPropByFunc(f, mod));
|
||||
/* You thought we would be over by now */
|
||||
/* but no meta calls require special preprocessing */
|
||||
if (pen->PredFlags & (GoalExPredFlag | MetaPredFlag)) {
|
||||
if (pen->PredFlags & MetaPredFlag) {
|
||||
if (f == FunctorModule) {
|
||||
Term tmod = ArgOfTerm(1, t);
|
||||
if (!IsVarTerm(tmod) && IsAtomTerm(tmod)) {
|
||||
@ -359,14 +353,7 @@ restart_exec:
|
||||
if (IsExtensionFunctor(f)) {
|
||||
return CallError(TYPE_ERROR_CALLABLE, t, mod PASS_REGS);
|
||||
}
|
||||
if (PRED_GOAL_EXPANSION_ALL) {
|
||||
/* disable creeping when we do goal expansion */
|
||||
if (Yap_get_signal(YAP_CREEP_SIGNAL) && !LOCAL_InterruptsDisabled) {
|
||||
CalculateStackGap(PASS_REGS1);
|
||||
}
|
||||
t = copy_execn_to_heap(f, pt, n, arity, mod PASS_REGS);
|
||||
return CallMetaCall(t, mod PASS_REGS);
|
||||
} else if (Yap_has_a_signal() && !LOCAL_InterruptsDisabled) {
|
||||
if (Yap_has_a_signal() && !LOCAL_InterruptsDisabled) {
|
||||
return EnterCreepMode(
|
||||
copy_execn_to_heap(f, pt, n, arity, CurrentModule PASS_REGS),
|
||||
mod PASS_REGS);
|
||||
@ -377,7 +364,7 @@ restart_exec:
|
||||
pen = RepPredProp(PredPropByFunc(f, mod));
|
||||
/* You thought we would be over by now */
|
||||
/* but no meta calls require special preprocessing */
|
||||
if (pen->PredFlags & (GoalExPredFlag | MetaPredFlag)) {
|
||||
if (pen->PredFlags & MetaPredFlag) {
|
||||
Term t = copy_execn_to_heap(f, pt, n, arity, mod PASS_REGS);
|
||||
return (CallMetaCall(t, mod PASS_REGS));
|
||||
}
|
||||
@ -650,33 +637,39 @@ static Int execute_in_mod(USES_REGS1) { /* '$execute'(Goal) */
|
||||
return (do_execute(Deref(ARG1), Deref(ARG2) PASS_REGS));
|
||||
}
|
||||
|
||||
static Int do_goal_expansion(USES_REGS1) {
|
||||
static Int _user_expand_goal(USES_REGS1) {
|
||||
Int creeping = Yap_get_signal(YAP_CREEP_SIGNAL);
|
||||
Int out = FALSE;
|
||||
PredEntry *pe;
|
||||
Term cmod = Deref(ARG2);
|
||||
|
||||
ARG2 = ARG3;
|
||||
|
||||
Term cmod = CurrentModule, omod = cmod;
|
||||
Term mg_args[2], mg;
|
||||
Term g = Yap_YapStripModule( ARG1, &cmod);
|
||||
yhandle_t h1 = Yap_InitSlot( ARG1), h2 = Yap_InitSlot( ARG2);
|
||||
|
||||
/* CurMod:goal_expansion(A,B) */
|
||||
ARG1 = g;
|
||||
if ((pe = RepPredProp(Yap_GetPredPropByFunc(FunctorGoalExpansion2, cmod))) &&
|
||||
pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE &&
|
||||
pe->OpcodeOfPred != FAIL_OPCODE &&
|
||||
pe->OpcodeOfPred != UNDEF_OPCODE &&
|
||||
Yap_execute_pred(pe, NULL, false PASS_REGS)) {
|
||||
out = TRUE;
|
||||
ARG3 = ARG2;
|
||||
out = true;
|
||||
goto complete;
|
||||
}
|
||||
/* system:goal_expansion(A,B) */
|
||||
mg_args[0] = cmod;
|
||||
mg_args[1] = Yap_GetFromSlot(h1);
|
||||
ARG1 = Yap_MkApplTerm( FunctorModule, 2, mg_args );
|
||||
ARG2 = Yap_GetFromSlot(h2);
|
||||
if ((pe = RepPredProp(
|
||||
Yap_GetPredPropByFunc(FunctorGoalExpansion2, SYSTEM_MODULE))) &&
|
||||
pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE &&
|
||||
Yap_execute_pred(pe, NULL, false PASS_REGS)) {
|
||||
out = TRUE;
|
||||
ARG3 = ARG2;
|
||||
out = true;
|
||||
goto complete;
|
||||
}
|
||||
ARG3 = ARG2;
|
||||
ARG1 = Yap_GetFromSlot(h1);
|
||||
ARG2 = cmod;
|
||||
ARG3 = Yap_GetFromSlot(h2);
|
||||
/* user:goal_expansion(A,CurMod,B) */
|
||||
if ((pe = RepPredProp(
|
||||
Yap_GetPredPropByFunc(FunctorGoalExpansion, USER_MODULE))) &&
|
||||
@ -685,7 +678,10 @@ static Int do_goal_expansion(USES_REGS1) {
|
||||
out = TRUE;
|
||||
goto complete;
|
||||
}
|
||||
ARG2 = ARG3;
|
||||
mg_args[0] = cmod;
|
||||
mg_args[1] = Yap_GetFromSlot(h1);
|
||||
ARG1 = Yap_MkApplTerm( FunctorModule, 2, mg_args );
|
||||
ARG2 = Yap_GetFromSlot(h2);
|
||||
/* user:goal_expansion(A,B) */
|
||||
if (cmod != USER_MODULE && /* we have tried this before */
|
||||
(pe = RepPredProp(
|
||||
@ -699,6 +695,7 @@ complete:
|
||||
if (creeping) {
|
||||
Yap_signal(YAP_CREEP_SIGNAL);
|
||||
}
|
||||
CurrentModule = omod;
|
||||
return out;
|
||||
}
|
||||
|
||||
@ -1006,12 +1003,6 @@ static Int execute_depth_limit(USES_REGS1) {
|
||||
}
|
||||
#endif
|
||||
|
||||
static Int pred_goal_expansion_on(USES_REGS1) {
|
||||
/* a goal needs expansion if we have goal_expansion defined or
|
||||
if the goal is a meta-call */
|
||||
return PRED_GOAL_EXPANSION_ON;
|
||||
}
|
||||
|
||||
static Int exec_absmi(bool top, yap_reset_t reset_mode USES_REGS) {
|
||||
int lval, out;
|
||||
|
||||
@ -1892,8 +1883,6 @@ void Yap_InitExecFs(void) {
|
||||
Yap_InitCPred("trail_suspension_marker", 1, trail_suspension_marker, 0);
|
||||
Yap_InitCPred("cut_at", 1, clean_ifcp, SafePredFlag);
|
||||
CurrentModule = cm;
|
||||
Yap_InitCPred("$pred_goal_expansion_on", 0, pred_goal_expansion_on,
|
||||
SafePredFlag);
|
||||
Yap_InitCPred("$restore_regs", 1, restore_regs,
|
||||
NoTracePredFlag | SafePredFlag);
|
||||
Yap_InitCPred("$restore_regs", 2, restore_regs2,
|
||||
@ -1905,7 +1894,7 @@ void Yap_InitExecFs(void) {
|
||||
Yap_InitCPred("$generate_pred_info", 4, generate_pred_info, 0);
|
||||
Yap_InitCPred("$uncaught_throw", 0, uncaught_throw, 0);
|
||||
Yap_InitCPred("$reset_exception", 1, reset_exception, 0);
|
||||
Yap_InitCPred("$do_goal_expansion", 3, do_goal_expansion, 0);
|
||||
Yap_InitCPred("_user_expand_goal", 2, _user_expand_goal, 0);
|
||||
Yap_InitCPred("$do_term_expansion", 2, do_term_expansion, 0);
|
||||
Yap_InitCPred("$get_exception", 1, get_exception, 0);
|
||||
}
|
||||
|
@ -4267,6 +4267,7 @@ Yap_locked_gc(Int predarity, CELL *current_env, yamop *nextop)
|
||||
CACHE_REGS
|
||||
int res;
|
||||
#if YAPOR_COPY
|
||||
|
||||
fprintf(stderr, "\n\n***** Trying to call the garbage collector in YAPOR/copying ****\n\n\n");
|
||||
exit( 1 );
|
||||
#endif
|
||||
|
2
C/init.c
2
C/init.c
@ -979,7 +979,7 @@ InitStdPreds(void)
|
||||
Yap_InitCPreds();
|
||||
Yap_InitBackCPreds();
|
||||
BACKUP_MACHINE_REGS();
|
||||
Yap_InitPlIO();
|
||||
Yap_InitPlIO();
|
||||
Yap_InitFlags(false);
|
||||
#if HAVE_MPE
|
||||
Yap_InitMPE ();
|
||||
|
@ -106,9 +106,6 @@
|
||||
}
|
||||
#endif /* FROZEN_STACKS */
|
||||
d0 = ARG1;
|
||||
if (PRED_GOAL_EXPANSION_ALL) {
|
||||
goto execute_metacall;
|
||||
}
|
||||
restart_execute:
|
||||
deref_head(d0, execute_unk);
|
||||
execute_nvar:
|
||||
@ -119,7 +116,7 @@
|
||||
}
|
||||
pen = RepPredProp(PredPropByFunc(f, mod));
|
||||
execute_pred_f:
|
||||
if (pen->PredFlags & (MetaPredFlag|GoalExPredFlag)) {
|
||||
if (pen->PredFlags & MetaPredFlag) {
|
||||
/* just strip all of M:G */
|
||||
if (f == FunctorModule) {
|
||||
Term tmod = ArgOfTerm(1,d0);
|
||||
|
122
C/modules.c
122
C/modules.c
@ -25,6 +25,7 @@ static char SccsId[] = "%W% %G%";
|
||||
static Int current_module(USES_REGS1);
|
||||
static Int current_module1(USES_REGS1);
|
||||
static ModEntry *LookupModule(Term a);
|
||||
static ModEntry *LookupSystemModule(Term a);
|
||||
|
||||
static ModEntry *FetchModuleEntry(Atom at)
|
||||
/* get predicate entry for ap/arity; create it if neccessary. */
|
||||
@ -89,6 +90,17 @@ Term Yap_getUnknownModule(ModEntry *m) {
|
||||
}
|
||||
}
|
||||
|
||||
bool Yap_getUnknown ( Term mod) {
|
||||
ModEntry *m = LookupModule( mod );
|
||||
if (m && m->flags & UNKNOWN_ERROR) {
|
||||
return TermError;
|
||||
} else if (m && m->flags & UNKNOWN_WARNING) {
|
||||
return TermWarning;
|
||||
} else {
|
||||
return TermFail;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Yap_CharacterEscapes(Term mt) {
|
||||
if (mt == PROLOG_MODULE) mt = TermProlog;
|
||||
@ -118,6 +130,20 @@ Term Yap_Module_Name(PredEntry *ap) {
|
||||
|
||||
}
|
||||
|
||||
static ModEntry *LookupSystemModule(Term a) {
|
||||
Atom at;
|
||||
ModEntry *me;
|
||||
|
||||
/* prolog module */
|
||||
if (a == 0) {
|
||||
return GetModuleEntry(AtomProlog);
|
||||
}
|
||||
at = AtomOfTerm(a);
|
||||
me = GetModuleEntry(at);
|
||||
me->flags |= M_SYSTEM;
|
||||
return me;}
|
||||
|
||||
|
||||
static ModEntry *LookupModule(Term a) {
|
||||
Atom at;
|
||||
ModEntry *me;
|
||||
@ -131,6 +157,13 @@ static ModEntry *LookupModule(Term a) {
|
||||
return me;
|
||||
}
|
||||
|
||||
bool Yap_isSystemModule(Term a) {
|
||||
ModEntry *me = LookupModule(a);
|
||||
return
|
||||
me != NULL &&
|
||||
me->flags & M_SYSTEM;
|
||||
}
|
||||
|
||||
Term Yap_Module(Term tmod) {
|
||||
LookupModule(tmod);
|
||||
return tmod;
|
||||
@ -141,6 +174,7 @@ ModEntry *Yap_GetModuleEntry(Term mod) {
|
||||
if (!(me = LookupModule(mod)))
|
||||
return NULL;
|
||||
return me;
|
||||
|
||||
}
|
||||
|
||||
Term Yap_GetModuleFromEntry(ModEntry *me) {
|
||||
@ -191,13 +225,6 @@ static Int
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Int current_module1(USES_REGS1) { /* $current_module(Old)
|
||||
*/
|
||||
if (CurrentModule)
|
||||
return Yap_unify_constant(ARG1, CurrentModule);
|
||||
return Yap_unify_constant(ARG1, TermProlog);
|
||||
}
|
||||
|
||||
static Int change_module(USES_REGS1) { /* $change_module(New) */
|
||||
Term mod = Deref(ARG1);
|
||||
LookupModule(mod);
|
||||
@ -206,6 +233,14 @@ static Int change_module(USES_REGS1) { /* $change_module(New) */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Int current_module1(USES_REGS1) { /* $current_module(Old)
|
||||
*/
|
||||
if (CurrentModule)
|
||||
return Yap_unify_constant(ARG1, CurrentModule);
|
||||
return Yap_unify_constant(ARG1, TermProlog);
|
||||
}
|
||||
|
||||
|
||||
static Int cont_current_module(USES_REGS1) {
|
||||
ModEntry *imod = AddressOfTerm(EXTRA_CBACK_ARG(1, 1)), *next;
|
||||
Term t = MkAtomTerm(imod->AtomOfME);
|
||||
@ -280,6 +315,42 @@ static Int init_ground_module(USES_REGS1) {
|
||||
return cont_ground_module(PASS_REGS1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @pred is_system_module( + _Mod_)
|
||||
*
|
||||
* @param module
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
static Int is_system_module( USES_REGS1 )
|
||||
{
|
||||
Term t;
|
||||
if (IsVarTerm(t = Deref (ARG1))) {
|
||||
return false;
|
||||
}
|
||||
if (!IsAtomTerm(t)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM, t, "load_files/2");
|
||||
return false;
|
||||
}
|
||||
return Yap_isSystemModule( t );
|
||||
}
|
||||
|
||||
static Int system_module( USES_REGS1 )
|
||||
{
|
||||
ModEntry *me;
|
||||
Term t;
|
||||
if (IsVarTerm(t = Deref (ARG1))) {
|
||||
Yap_Error( INSTANTIATION_ERROR, t, NULL);
|
||||
return false;
|
||||
}
|
||||
if (!IsAtomTerm(t)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM, t, NULL);
|
||||
return false;
|
||||
}
|
||||
me = LookupSystemModule( t );
|
||||
return me != NULL;
|
||||
}
|
||||
|
||||
static Int strip_module(USES_REGS1) {
|
||||
Term t1 = Deref(ARG1), tmod = CurrentModule;
|
||||
if (tmod == PROLOG_MODULE) {
|
||||
@ -359,9 +430,23 @@ static Int context_module(USES_REGS1) {
|
||||
return Yap_unify(ARG1, CurrentModule);
|
||||
}
|
||||
|
||||
/**
|
||||
* @pred source_module(-Mod)
|
||||
*
|
||||
* @param Mod is the current text source module.
|
||||
*
|
||||
* : _Mod_ is the current read-in or source module.
|
||||
*/
|
||||
static Int source_module(USES_REGS1) {
|
||||
if (LOCAL_SourceModule == PROLOG_MODULE) {
|
||||
return Yap_unify(ARG1, TermProlog);
|
||||
}
|
||||
return Yap_unify(ARG1, LOCAL_SourceModule);
|
||||
}
|
||||
|
||||
Term Yap_StripModule(Term t, Term *modp) {
|
||||
CACHE_REGS
|
||||
Term tmod;
|
||||
Term tmod;
|
||||
|
||||
if (modp)
|
||||
tmod = *modp;
|
||||
@ -406,9 +491,12 @@ void Yap_InitModulesC(void) {
|
||||
Yap_InitCPred("$change_module", 1, change_module,
|
||||
SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("strip_module", 3, strip_module, SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("source_module", 1, source_module, SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("$yap_strip_module", 3, yap_strip_module,
|
||||
SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("context_module", 1, context_module, 0);
|
||||
Yap_InitCPred("system_module", 1, system_module, SafePredFlag);
|
||||
Yap_InitCPred("is_system_module", 1, is_system_module, SafePredFlag);
|
||||
Yap_InitCPredBack("$all_current_modules", 1, 1, init_current_module,
|
||||
cont_current_module, SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPredBack("$ground_module", 3, 1, init_ground_module,
|
||||
@ -417,19 +505,19 @@ void Yap_InitModulesC(void) {
|
||||
|
||||
void Yap_InitModules(void) {
|
||||
CACHE_REGS
|
||||
LookupModule(MkAtomTerm(AtomProlog));
|
||||
LookupSystemModule(MkAtomTerm(AtomProlog));
|
||||
LOCAL_SourceModule = MkAtomTerm(AtomProlog);
|
||||
LookupModule(USER_MODULE);
|
||||
LookupModule(IDB_MODULE);
|
||||
LookupModule(ATTRIBUTES_MODULE);
|
||||
LookupModule(CHARSIO_MODULE);
|
||||
LookupModule(TERMS_MODULE);
|
||||
LookupModule(SYSTEM_MODULE);
|
||||
LookupModule(READUTIL_MODULE);
|
||||
LookupModule(HACKS_MODULE);
|
||||
LookupSystemModule(CHARSIO_MODULE);
|
||||
LookupSystemModule(TERMS_MODULE);
|
||||
LookupSystemModule(SYSTEM_MODULE);
|
||||
LookupSystemModule(READUTIL_MODULE);
|
||||
LookupSystemModule(HACKS_MODULE);
|
||||
LookupModule(ARG_MODULE);
|
||||
LookupModule(GLOBALS_MODULE);
|
||||
LookupModule(DBLOAD_MODULE);
|
||||
LookupModule(RANGE_MODULE);
|
||||
LookupSystemModule(GLOBALS_MODULE);
|
||||
LookupSystemModule(DBLOAD_MODULE);
|
||||
LookupSystemModule(RANGE_MODULE);
|
||||
CurrentModule = PROLOG_MODULE;
|
||||
}
|
||||
|
284
C/parser.c
284
C/parser.c
@ -39,7 +39,8 @@ extended where necessary with attributes denoting integer precedence or
|
||||
operator type.
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
term ----> subterm(1200) end_of_term_marker
|
||||
term
|
||||
----> subterm(1200) end_of_term_marker
|
||||
|
||||
subterm(N) ----> term(M) [M <= N]
|
||||
|
||||
@ -163,21 +164,19 @@ typedef struct jmp_buff_struct { sigjmp_buf JmpBuff; } JMPBUFF;
|
||||
|
||||
static void GNextToken(CACHE_TYPE1);
|
||||
static void checkfor(wchar_t, JMPBUFF *CACHE_TYPE);
|
||||
static Term ParseArgs( Atom, wchar_t, JMPBUFF *, Term CACHE_TYPE);
|
||||
static Term ParseList( JMPBUFF *CACHE_TYPE);
|
||||
static Term ParseTerm( int, JMPBUFF *CACHE_TYPE);
|
||||
static Term ParseArgs(Atom, wchar_t, JMPBUFF *, Term CACHE_TYPE);
|
||||
static Term ParseList(JMPBUFF *CACHE_TYPE);
|
||||
static Term ParseTerm(int, JMPBUFF *CACHE_TYPE);
|
||||
|
||||
const char *Yap_tokRep(TokEntry *tokptr);
|
||||
|
||||
static void
|
||||
syntax_msg( const char *msg, ...)
|
||||
{
|
||||
static void syntax_msg(const char *msg, ...) {
|
||||
CACHE_REGS
|
||||
va_list ap;
|
||||
|
||||
if (LOCAL_toktide == LOCAL_tokptr) {
|
||||
va_start(ap, msg);
|
||||
vsnprintf( LOCAL_FileNameBuf2, YAP_FILENAME_MAX-1, msg, ap );
|
||||
vsnprintf(LOCAL_FileNameBuf2, YAP_FILENAME_MAX - 1, msg, ap);
|
||||
LOCAL_ErrorMessage = LOCAL_FileNameBuf2;
|
||||
LOCAL_Error_TYPE = SYNTAX_ERROR;
|
||||
va_end(ap);
|
||||
@ -225,7 +224,8 @@ syntax_msg( const char *msg, ...)
|
||||
|
||||
#define FAIL siglongjmp(FailBuff->JmpBuff, 1)
|
||||
|
||||
VarEntry *Yap_LookupVar(const char *var) /* lookup variable in variables table */
|
||||
VarEntry *
|
||||
Yap_LookupVar(const char *var) /* lookup variable in variables table */
|
||||
{
|
||||
CACHE_REGS
|
||||
VarEntry *p;
|
||||
@ -291,7 +291,7 @@ static Term VarNames(VarEntry *p, Term l USES_REGS) {
|
||||
|
||||
t[0] = MkAtomTerm(Yap_LookupAtom(p->VarRep));
|
||||
if (!IsVarTerm(p->VarAdr))
|
||||
p->VarAdr = MkVarTerm();
|
||||
p->VarAdr = MkVarTerm();
|
||||
t[1] = p->VarAdr;
|
||||
o = Yap_MkApplTerm(FunctorEq, 2, t);
|
||||
o = MkPairTerm(o, VarNames(p->VarRight,
|
||||
@ -316,7 +316,7 @@ Term Yap_VarNames(VarEntry *p, Term l) {
|
||||
|
||||
static Term Singletons(VarEntry *p, Term l USES_REGS) {
|
||||
if (p != NULL) {
|
||||
if ( p->VarRep[0] != '_' && p->refs == 1) {
|
||||
if (p->VarRep[0] != '_' && p->refs == 1) {
|
||||
Term t[2];
|
||||
Term o;
|
||||
|
||||
@ -378,7 +378,7 @@ static int IsPrefixOp(Atom op, int *pptr, int *rpptr USES_REGS) {
|
||||
}
|
||||
if ((p = opp->Prefix) != 0) {
|
||||
READ_UNLOCK(opp->OpRWLock);
|
||||
*pptr = *rpptr = p & MaskPrio;
|
||||
*pptr = *rpptr = p &MaskPrio;
|
||||
if (p & DcrrpFlag)
|
||||
--*rpptr;
|
||||
return TRUE;
|
||||
@ -405,7 +405,7 @@ static int IsInfixOp(Atom op, int *pptr, int *lpptr, int *rpptr USES_REGS) {
|
||||
}
|
||||
if ((p = opp->Infix) != 0) {
|
||||
READ_UNLOCK(opp->OpRWLock);
|
||||
*pptr = *rpptr = *lpptr = p & MaskPrio;
|
||||
*pptr = *rpptr = *lpptr = p &MaskPrio;
|
||||
if (p & DcrrpFlag)
|
||||
--*rpptr;
|
||||
if (p & DcrlpFlag)
|
||||
@ -434,7 +434,7 @@ static int IsPosfixOp(Atom op, int *pptr, int *lpptr USES_REGS) {
|
||||
}
|
||||
if ((p = opp->Posfix) != 0) {
|
||||
READ_UNLOCK(opp->OpRWLock);
|
||||
*pptr = *lpptr = p & MaskPrio;
|
||||
*pptr = *lpptr = p &MaskPrio;
|
||||
if (p & DcrlpFlag)
|
||||
--*lpptr;
|
||||
return (TRUE);
|
||||
@ -462,7 +462,7 @@ inline static void checkfor(wchar_t c, JMPBUFF *FailBuff USES_REGS) {
|
||||
if (LOCAL_tokptr->Tok != Ord(Ponctuation_tok) ||
|
||||
LOCAL_tokptr->TokInfo != (Term)c) {
|
||||
char s[1024];
|
||||
strncpy(s, Yap_tokRep(LOCAL_tokptr), 1023 );
|
||||
strncpy(s, Yap_tokRep(LOCAL_tokptr), 1023);
|
||||
syntax_msg("expected to find \'%c\', found %s", c, s);
|
||||
FAIL;
|
||||
}
|
||||
@ -523,7 +523,7 @@ static int get_quasi_quotation(term_t t, unsigned char **here,
|
||||
}
|
||||
#endif /*O_QUASIQUOTATIONS*/
|
||||
|
||||
static Term ParseArgs( Atom a, wchar_t close, JMPBUFF *FailBuff,
|
||||
static Term ParseArgs(Atom a, wchar_t close, JMPBUFF *FailBuff,
|
||||
Term arg1 USES_REGS) {
|
||||
int nargs = 0;
|
||||
Term *p, t;
|
||||
@ -543,12 +543,12 @@ static Term ParseArgs( Atom a, wchar_t close, JMPBUFF *FailBuff,
|
||||
|
||||
func = Yap_MkFunctor(a, 1);
|
||||
if (func == NULL) {
|
||||
syntax_msg("Heap Overflow");
|
||||
syntax_msg("Heap Overflow");
|
||||
FAIL;
|
||||
}
|
||||
t = Yap_MkApplTerm(func, nargs, p);
|
||||
if (HR > ASP - 4096) {
|
||||
syntax_msg("Stack Overflow");
|
||||
syntax_msg("Stack Overflow");
|
||||
return TermNil;
|
||||
}
|
||||
NextToken;
|
||||
@ -561,7 +561,7 @@ static Term ParseArgs( Atom a, wchar_t close, JMPBUFF *FailBuff,
|
||||
syntax_msg("Trail Overflow");
|
||||
FAIL;
|
||||
}
|
||||
*tp++ = Unsigned(ParseTerm( 999, FailBuff PASS_REGS));
|
||||
*tp++ = Unsigned(ParseTerm(999, FailBuff PASS_REGS));
|
||||
ParserAuxSp = (char *)tp;
|
||||
++nargs;
|
||||
if (LOCAL_tokptr->Tok != Ord(Ponctuation_tok))
|
||||
@ -576,7 +576,7 @@ static Term ParseArgs( Atom a, wchar_t close, JMPBUFF *FailBuff,
|
||||
* order
|
||||
*/
|
||||
if (HR > ASP - (nargs + 1)) {
|
||||
syntax_msg("Stack Overflow");
|
||||
syntax_msg("Stack Overflow");
|
||||
FAIL;
|
||||
}
|
||||
func = Yap_MkFunctor(a, nargs);
|
||||
@ -596,7 +596,7 @@ static Term ParseArgs( Atom a, wchar_t close, JMPBUFF *FailBuff,
|
||||
t = Yap_MkApplTerm(func, nargs, p);
|
||||
#endif
|
||||
if (HR > ASP - 4096) {
|
||||
syntax_msg("Stack Overflow");
|
||||
syntax_msg("Stack Overflow");
|
||||
return TermNil;
|
||||
}
|
||||
/* check for possible overflow against local stack */
|
||||
@ -616,26 +616,22 @@ static Term MakeAccessor(Term t, Functor f USES_REGS) {
|
||||
return Yap_MkApplTerm(f, 2, tf);
|
||||
}
|
||||
|
||||
static Term ParseList( JMPBUFF *FailBuff USES_REGS) {
|
||||
static Term ParseList(JMPBUFF *FailBuff USES_REGS) {
|
||||
Term o;
|
||||
CELL *to_store;
|
||||
o = AbsPair(HR);
|
||||
loop:
|
||||
to_store = HR;
|
||||
HR += 2;
|
||||
to_store[0] = ParseTerm( 999, FailBuff PASS_REGS);
|
||||
to_store[0] = ParseTerm(999, FailBuff PASS_REGS);
|
||||
if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok)) {
|
||||
if (((int)LOCAL_tokptr->TokInfo) == ',') {
|
||||
NextToken;
|
||||
if (LOCAL_tokptr->Tok == Ord(Name_tok) &&
|
||||
strcmp((char *)RepAtom((Atom)(LOCAL_tokptr->TokInfo))->StrOfAE, "..") == 0) {
|
||||
NextToken;
|
||||
to_store[1] = ParseTerm( 999, FailBuff PASS_REGS);
|
||||
} else {
|
||||
{
|
||||
/* check for possible overflow against local stack */
|
||||
if (HR > ASP - 4096) {
|
||||
to_store[1] = TermNil;
|
||||
syntax_msg("Stack Overflow");
|
||||
syntax_msg("Stack Overflow");
|
||||
FAIL;
|
||||
} else {
|
||||
to_store[1] = AbsPair(HR);
|
||||
@ -644,18 +640,19 @@ loop:
|
||||
}
|
||||
} else if (((int)LOCAL_tokptr->TokInfo) == '|') {
|
||||
NextToken;
|
||||
to_store[1] = ParseTerm( 999, FailBuff PASS_REGS);
|
||||
to_store[1] = ParseTerm(999, FailBuff PASS_REGS);
|
||||
} else {
|
||||
to_store[1] = MkAtomTerm(AtomNil);
|
||||
}
|
||||
} else {
|
||||
syntax_msg("looking for symbol ',','|' got symbol '%s'", Yap_tokRep(LOCAL_tokptr) );
|
||||
FAIL;
|
||||
syntax_msg("looking for symbol ',','|' got symbol '%s'",
|
||||
Yap_tokRep(LOCAL_tokptr));
|
||||
FAIL;
|
||||
}
|
||||
return (o);
|
||||
}
|
||||
|
||||
static Term ParseTerm( int prio, JMPBUFF *FailBuff USES_REGS) {
|
||||
static Term ParseTerm(int prio, JMPBUFF *FailBuff USES_REGS) {
|
||||
/* parse term with priority prio */
|
||||
Volatile Term t;
|
||||
Volatile Functor func;
|
||||
@ -719,15 +716,15 @@ static Term ParseTerm( int prio, JMPBUFF *FailBuff USES_REGS) {
|
||||
/* try to parse as a prefix operator */
|
||||
TRY(
|
||||
/* build appl on the heap */
|
||||
func = Yap_MkFunctor((Atom)t, 1);
|
||||
if (func == NULL) {
|
||||
syntax_msg( "Heap Overflow" );
|
||||
func = Yap_MkFunctor((Atom)t, 1); if (func == NULL) {
|
||||
syntax_msg("Heap Overflow");
|
||||
FAIL;
|
||||
} t = ParseTerm( oprprio, FailBuff PASS_REGS);
|
||||
}
|
||||
t = ParseTerm(oprprio, FailBuff PASS_REGS);
|
||||
t = Yap_MkApplTerm(func, 1, &t);
|
||||
/* check for possible overflow against local stack */
|
||||
if (HR > ASP - 4096) {
|
||||
syntax_msg( "Stack Overflow" );
|
||||
syntax_msg("Stack Overflow");
|
||||
FAIL;
|
||||
} curprio = opprio;
|
||||
, break;)
|
||||
@ -735,7 +732,7 @@ static Term ParseTerm( int prio, JMPBUFF *FailBuff USES_REGS) {
|
||||
}
|
||||
if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok) &&
|
||||
Unsigned(LOCAL_tokptr->TokInfo) == 'l')
|
||||
t = ParseArgs( (Atom)t, ')', FailBuff, 0L PASS_REGS);
|
||||
t = ParseArgs((Atom)t, ')', FailBuff, 0L PASS_REGS);
|
||||
else
|
||||
t = MkAtomTerm((Atom)t);
|
||||
break;
|
||||
@ -745,52 +742,52 @@ static Term ParseTerm( int prio, JMPBUFF *FailBuff USES_REGS) {
|
||||
NextToken;
|
||||
break;
|
||||
|
||||
case String_tok: /* build list on the heap */
|
||||
{
|
||||
Volatile char *p = (char *)LOCAL_tokptr->TokInfo;
|
||||
t = Yap_CharsToTDQ(p, CurrentModule, ENC_ISO_LATIN1 PASS_REGS);
|
||||
if (!t) {
|
||||
syntax_msg( "could not convert \'%s\'", (char *)LOCAL_tokptr->TokInfo );
|
||||
FAIL;
|
||||
}
|
||||
NextToken;
|
||||
} break;
|
||||
|
||||
case WString_tok: /* build list on the heap */
|
||||
{
|
||||
Volatile wchar_t *p = (wchar_t *)LOCAL_tokptr->TokInfo;
|
||||
t = Yap_WCharsToTDQ(p, CurrentModule PASS_REGS);
|
||||
if (!t) {
|
||||
syntax_msg( "could not convert \'%S\'", (wchar_t *)LOCAL_tokptr->TokInfo );
|
||||
FAIL;
|
||||
}
|
||||
NextToken;
|
||||
} break;
|
||||
|
||||
case BQString_tok: /* build list on the heap */
|
||||
{
|
||||
Volatile char *p = (char *)LOCAL_tokptr->TokInfo;
|
||||
case String_tok: /* build list on the heap */
|
||||
{
|
||||
Volatile char *p = (char *)LOCAL_tokptr->TokInfo;
|
||||
t = Yap_CharsToTDQ(p, CurrentModule, LOCAL_encoding PASS_REGS);
|
||||
if (!t) {
|
||||
syntax_msg("could not convert \"%s\"", (char *)LOCAL_tokptr->TokInfo);
|
||||
FAIL;
|
||||
}
|
||||
NextToken;
|
||||
} break;
|
||||
|
||||
t = Yap_CharsToTBQ(p, CurrentModule, ENC_ISO_LATIN1 PASS_REGS);
|
||||
if (!t) {
|
||||
syntax_msg( "could not convert \'%s\"", (char *)LOCAL_tokptr->TokInfo );
|
||||
FAIL;
|
||||
}
|
||||
NextToken;
|
||||
} break;
|
||||
|
||||
case WBQString_tok: /* build list on the heap */
|
||||
{
|
||||
Volatile wchar_t *p = (wchar_t *)LOCAL_tokptr->TokInfo;
|
||||
t = Yap_WCharsToTBQ(p, CurrentModule PASS_REGS);
|
||||
if (!t) {
|
||||
syntax_msg( "could not convert \"%S\"", (wchar_t *)LOCAL_tokptr->TokInfo );
|
||||
FAIL;
|
||||
}
|
||||
NextToken;
|
||||
} break;
|
||||
|
||||
case Var_tok:
|
||||
case WString_tok: /* build list on the heap */
|
||||
{
|
||||
Volatile wchar_t *p = (wchar_t *)LOCAL_tokptr->TokInfo;
|
||||
t = Yap_WCharsToTDQ(p, CurrentModule PASS_REGS);
|
||||
if (!t) {
|
||||
syntax_msg("could not convert \'%S\'", (wchar_t *)LOCAL_tokptr->TokInfo);
|
||||
FAIL;
|
||||
}
|
||||
NextToken;
|
||||
} break;
|
||||
|
||||
case BQString_tok: /* build list on the heap */
|
||||
{
|
||||
Volatile char *p = (char *)LOCAL_tokptr->TokInfo;
|
||||
|
||||
t = Yap_CharsToTBQ(p, CurrentModule, LOCAL_encoding PASS_REGS);
|
||||
if (!t) {
|
||||
syntax_msg("could not convert \'%s\"", (char *)LOCAL_tokptr->TokInfo);
|
||||
FAIL;
|
||||
}
|
||||
NextToken;
|
||||
} break;
|
||||
|
||||
case WBQString_tok: /* build list on the heap */
|
||||
{
|
||||
Volatile wchar_t *p = (wchar_t *)LOCAL_tokptr->TokInfo;
|
||||
t = Yap_WCharsToTBQ(p, CurrentModule PASS_REGS);
|
||||
if (!t) {
|
||||
syntax_msg("could not convert \"%S\"", (wchar_t *)LOCAL_tokptr->TokInfo);
|
||||
FAIL;
|
||||
}
|
||||
NextToken;
|
||||
} break;
|
||||
|
||||
case Var_tok:
|
||||
varinfo = (VarEntry *)(LOCAL_tokptr->TokInfo);
|
||||
if ((t = varinfo->VarAdr) == TermNil) {
|
||||
t = varinfo->VarAdr = MkVarTerm();
|
||||
@ -799,7 +796,7 @@ case Var_tok:
|
||||
break;
|
||||
|
||||
case Error_tok:
|
||||
syntax_msg( "found ill-formed \"%s\"", Yap_tokRep(LOCAL_tokptr) );
|
||||
syntax_msg("found ill-formed \"%s\"", Yap_tokRep(LOCAL_tokptr));
|
||||
FAIL;
|
||||
|
||||
case Ponctuation_tok:
|
||||
@ -819,7 +816,7 @@ case Var_tok:
|
||||
NextToken;
|
||||
break;
|
||||
}
|
||||
t = ParseList( FailBuff PASS_REGS);
|
||||
t = ParseList(FailBuff PASS_REGS);
|
||||
checkfor(']', FailBuff PASS_REGS);
|
||||
break;
|
||||
case '{':
|
||||
@ -834,7 +831,7 @@ case Var_tok:
|
||||
t = Yap_MkApplTerm(FunctorBraces, 1, &t);
|
||||
/* check for possible overflow against local stack */
|
||||
if (HR > ASP - 4096) {
|
||||
syntax_msg("Stack Overflow");
|
||||
syntax_msg("Stack Overflow");
|
||||
FAIL;
|
||||
}
|
||||
checkfor('}', FailBuff PASS_REGS);
|
||||
@ -884,43 +881,46 @@ case Var_tok:
|
||||
NextToken;
|
||||
t = ParseTerm(GLOBAL_MaxPriority, FailBuff PASS_REGS);
|
||||
if (LOCAL_tokptr->Tok != QuasiQuotes_tok) {
|
||||
syntax_msg( "expected to find quasi quotes, got \"%s\"", , Yap_tokRep(LOCAL_tokptr) );
|
||||
syntax_msg("expected to find quasi quotes, got \"%s\"", ,
|
||||
Yap_tokRep(LOCAL_tokptr));
|
||||
FAIL;
|
||||
}
|
||||
if (!(is_quasi_quotation_syntax(t, &at))) {
|
||||
syntax_msg( "bad quasi quotation syntax, at \"%s\"", Yap_tokRep(LOCAL_tokptr) );
|
||||
syntax_msg("bad quasi quotation syntax, at \"%s\"",
|
||||
Yap_tokRep(LOCAL_tokptr));
|
||||
FAIL;
|
||||
}
|
||||
/* Arg 2: the content */
|
||||
tn = Yap_MkNewApplTerm(SWIFunctorToFunctor(FUNCTOR_quasi_quotation4), 4);
|
||||
tnp = RepAppl(tn) + 1;
|
||||
tnp[0] = MkAtomTerm(at);
|
||||
if (!get_quasi_quotation(Yap_InitSlot(ArgOfTerm(2, tn)),
|
||||
&qq->text,
|
||||
if (!get_quasi_quotation(Yap_InitSlot(ArgOfTerm(2, tn)), &qq->text,
|
||||
qq->text + strlen((const char *)qq->text))) {
|
||||
syntax_msg( "could not get quasi quotation, at \"%s\"", Yap_tokRep(LOCAL_tokptr) );
|
||||
FAIL;
|
||||
syntax_msg("could not get quasi quotation, at \"%s\"",
|
||||
Yap_tokRep(LOCAL_tokptr));
|
||||
FAIL;
|
||||
}
|
||||
if (positions) {
|
||||
intptr_t qqend = qq->end.charno;
|
||||
|
||||
// set_range_position(positions, -1, qqend PASS_LD);
|
||||
if (!PL_unify_term(Yap_InitSlot(ArgOfTerm(2, t) ), PL_FUNCTOR,
|
||||
if (!PL_unify_term(Yap_InitSlot(ArgOfTerm(2, t)), PL_FUNCTOR,
|
||||
FUNCTOR_minus2, PL_INTPTR,
|
||||
qq->mid.charno + 2, /* end of | token */
|
||||
PL_INTPTR, qqend - 2)) /* end minus "|}" */
|
||||
syntax_msg( "failed to unify quasi quotation, at \"%s\"", Yap_tokRep(LOCAL_tokptr) );
|
||||
FAIL;
|
||||
syntax_msg("failed to unify quasi quotation, at \"%s\"",
|
||||
Yap_tokRep(LOCAL_tokptr));
|
||||
FAIL;
|
||||
}
|
||||
|
||||
tnp[2] =
|
||||
Yap_GetFromSlot(LOCAL_varnames); /* Arg 3: the var dictionary */
|
||||
tnp[2] = Yap_GetFromSlot(LOCAL_varnames); /* Arg 3: the var dictionary */
|
||||
/* Arg 4: the result */
|
||||
t = ArgOfTerm(4, tn);
|
||||
if (!(to = PL_new_term_ref()) ||
|
||||
!PL_unify_list(LOCAL_qq_tail, to, LOCAL_qq_tail) ||
|
||||
!PL_unify(to, Yap_InitSlot(tn ))) {
|
||||
syntax_msg( "failed to unify quasi quotation, at \"%s\"", Yap_tokRep(LOCAL_tokptr) );
|
||||
!PL_unify(to, Yap_InitSlot(tn))) {
|
||||
syntax_msg("failed to unify quasi quotation, at \"%s\"",
|
||||
Yap_tokRep(LOCAL_tokptr));
|
||||
FAIL;
|
||||
}
|
||||
}
|
||||
@ -928,7 +928,7 @@ case Var_tok:
|
||||
NextToken;
|
||||
break;
|
||||
default:
|
||||
syntax_msg( "expected operator, got \'%s\'", Yap_tokRep(LOCAL_tokptr) );
|
||||
syntax_msg("expected operator, got \'%s\'", Yap_tokRep(LOCAL_tokptr));
|
||||
FAIL;
|
||||
}
|
||||
|
||||
@ -941,38 +941,39 @@ case Var_tok:
|
||||
opprio <= prio && oplprio >= curprio) {
|
||||
/* try parsing as infix operator */
|
||||
Volatile int oldprio = curprio;
|
||||
TRY3(func = Yap_MkFunctor((Atom)LOCAL_tokptr->TokInfo, 2);
|
||||
if (func == NULL) {
|
||||
syntax_msg("Heap Overflow");
|
||||
FAIL;
|
||||
} NextToken;
|
||||
{
|
||||
Term args[2];
|
||||
args[0] = t;
|
||||
args[1] = ParseTerm(oprprio, FailBuff PASS_REGS);
|
||||
t = Yap_MkApplTerm(func, 2, args);
|
||||
/* check for possible overflow against local stack */
|
||||
if (HR > ASP - 4096) {
|
||||
syntax_msg("Stack Overflow");
|
||||
FAIL;
|
||||
}
|
||||
},
|
||||
curprio = opprio;
|
||||
opinfo = save_opinfo; continue;, opinfo = save_opinfo;
|
||||
curprio = oldprio;)
|
||||
TRY3(
|
||||
func = Yap_MkFunctor((Atom)LOCAL_tokptr->TokInfo, 2);
|
||||
if (func == NULL) {
|
||||
syntax_msg("Heap Overflow");
|
||||
FAIL;
|
||||
} NextToken;
|
||||
{
|
||||
Term args[2];
|
||||
args[0] = t;
|
||||
args[1] = ParseTerm(oprprio, FailBuff PASS_REGS);
|
||||
t = Yap_MkApplTerm(func, 2, args);
|
||||
/* check for possible overflow against local stack */
|
||||
if (HR > ASP - 4096) {
|
||||
syntax_msg("Stack Overflow");
|
||||
FAIL;
|
||||
}
|
||||
},
|
||||
curprio = opprio;
|
||||
opinfo = save_opinfo; continue;, opinfo = save_opinfo;
|
||||
curprio = oldprio;)
|
||||
}
|
||||
if (IsPosfixOp(opinfo, &opprio, &oplprio PASS_REGS) && opprio <= prio &&
|
||||
oplprio >= curprio) {
|
||||
/* parse as posfix operator */
|
||||
Functor func = Yap_MkFunctor((Atom)LOCAL_tokptr->TokInfo, 1);
|
||||
if (func == NULL) {
|
||||
syntax_msg("Heap Overflow");
|
||||
syntax_msg("Heap Overflow");
|
||||
FAIL;
|
||||
}
|
||||
t = Yap_MkApplTerm(func, 1, &t);
|
||||
/* check for possible overflow against local stack */
|
||||
if (HR > ASP - 4096) {
|
||||
syntax_msg("Stack Overflow");
|
||||
syntax_msg("Stack Overflow");
|
||||
FAIL;
|
||||
}
|
||||
curprio = opprio;
|
||||
@ -991,7 +992,7 @@ case Var_tok:
|
||||
t = Yap_MkApplTerm(FunctorComma, 2, args);
|
||||
/* check for possible overflow against local stack */
|
||||
if (HR > ASP - 4096) {
|
||||
syntax_msg("Stack Overflow");
|
||||
syntax_msg("Stack Overflow");
|
||||
FAIL;
|
||||
}
|
||||
curprio = 1000;
|
||||
@ -1006,7 +1007,7 @@ case Var_tok:
|
||||
t = Yap_MkApplTerm(FunctorVBar, 2, args);
|
||||
/* check for possible overflow against local stack */
|
||||
if (HR > ASP - 4096) {
|
||||
syntax_msg("Stack Overflow");
|
||||
syntax_msg("Stack Overflow");
|
||||
FAIL;
|
||||
}
|
||||
curprio = opprio;
|
||||
@ -1021,7 +1022,7 @@ case Var_tok:
|
||||
IsPosfixOp(AtomEmptySquareBrackets, &opprio,
|
||||
&oplprio PASS_REGS) &&
|
||||
opprio <= prio && oplprio >= curprio) {
|
||||
t = ParseArgs( AtomEmptySquareBrackets, ']', FailBuff, t PASS_REGS);
|
||||
t = ParseArgs(AtomEmptySquareBrackets, ']', FailBuff, t PASS_REGS);
|
||||
t = MakeAccessor(t, FunctorEmptySquareBrackets PASS_REGS);
|
||||
curprio = opprio;
|
||||
continue;
|
||||
@ -1029,14 +1030,14 @@ case Var_tok:
|
||||
IsPosfixOp(AtomEmptyCurlyBrackets, &opprio,
|
||||
&oplprio PASS_REGS) &&
|
||||
opprio <= prio && oplprio >= curprio) {
|
||||
t = ParseArgs( AtomEmptyCurlyBrackets, '}', FailBuff, t PASS_REGS);
|
||||
t = ParseArgs(AtomEmptyCurlyBrackets, '}', FailBuff, t PASS_REGS);
|
||||
t = MakeAccessor(t, FunctorEmptyCurlyBrackets PASS_REGS);
|
||||
curprio = opprio;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (LOCAL_tokptr->Tok <= Ord(WString_tok)) {
|
||||
syntax_msg( "expected operator, got \'%s\'", Yap_tokRep(LOCAL_tokptr) );
|
||||
syntax_msg("expected operator, got \'%s\'", Yap_tokRep(LOCAL_tokptr));
|
||||
FAIL;
|
||||
}
|
||||
break;
|
||||
@ -1048,28 +1049,27 @@ Term Yap_Parse(UInt prio) {
|
||||
CACHE_REGS
|
||||
Volatile Term t;
|
||||
JMPBUFF FailBuff;
|
||||
yhandle_t sls = Yap_StartSlots();
|
||||
yhandle_t sls = Yap_StartSlots();
|
||||
|
||||
if (!sigsetjmp(FailBuff.JmpBuff, 0)) {
|
||||
|
||||
t = ParseTerm(prio, &FailBuff PASS_REGS);
|
||||
#if DEBUG
|
||||
if (GLOBAL_Option['p' - 'a' + 1]) {
|
||||
Yap_DebugPutc(stderr, '[');
|
||||
if (t==0) Yap_DebugPlWrite(MkIntTerm(0));
|
||||
else Yap_DebugPlWrite(t);
|
||||
Yap_DebugPutc(stderr, ']');
|
||||
Yap_DebugPutc(stderr, '\n');
|
||||
}
|
||||
if (GLOBAL_Option['p' - 'a' + 1]) {
|
||||
Yap_DebugPutc(stderr, '[');
|
||||
if (t == 0)
|
||||
Yap_DebugPlWrite(MkIntTerm(0));
|
||||
else
|
||||
Yap_DebugPlWrite(t);
|
||||
Yap_DebugPutc(stderr, ']');
|
||||
Yap_DebugPutc(stderr, '\n');
|
||||
}
|
||||
#endif
|
||||
Yap_CloseSlots( sls );
|
||||
if (LOCAL_tokptr != NULL &&
|
||||
LOCAL_tokptr->Tok != Ord(eot_tok)
|
||||
) {
|
||||
Yap_CloseSlots(sls);
|
||||
if (LOCAL_tokptr != NULL && LOCAL_tokptr->Tok != Ord(eot_tok)) {
|
||||
t = 0;
|
||||
}
|
||||
if (t != 0 &&
|
||||
LOCAL_Error_TYPE == SYNTAX_ERROR) {
|
||||
if (t != 0 && LOCAL_Error_TYPE == SYNTAX_ERROR) {
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
LOCAL_ErrorMessage = NULL;
|
||||
}
|
||||
@ -1077,7 +1077,7 @@ Term Yap_Parse(UInt prio) {
|
||||
// return (0L);
|
||||
return t;
|
||||
}
|
||||
Yap_CloseSlots( sls );
|
||||
Yap_CloseSlots(sls);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
13
C/scanner.c
13
C/scanner.c
@ -1735,17 +1735,16 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments,
|
||||
case SY:
|
||||
if (ch == '`')
|
||||
goto quoted_string;
|
||||
if (ch == '.') {
|
||||
int nch = Yap_peek(inp_stream - GLOBAL_Stream);
|
||||
if (chtype(nch) == BS || chtype(nch) == EF || nch == '%') {
|
||||
och = ch;
|
||||
ch = getchr(inp_stream);
|
||||
if (och == '.') {
|
||||
if (chtype(ch) == BS || chtype(ch) == EF || ch == '%') {
|
||||
t->Tok = Ord(kind = eot_tok);
|
||||
if (chtype(ch) == EF)
|
||||
mark_eof(inp_stream);
|
||||
return l;
|
||||
}
|
||||
}
|
||||
och = ch;
|
||||
ch = getchr(inp_stream);
|
||||
if (och == '/' && ch == '*') {
|
||||
if (store_comments) {
|
||||
CHECK_SPACE();
|
||||
@ -1830,9 +1829,9 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments,
|
||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
t->Tok = Ord(kind = Name_tok);
|
||||
if (ch == '(')
|
||||
solo_flag = FALSE;
|
||||
solo_flag = false;
|
||||
else
|
||||
solo_flag = TRUE;
|
||||
solo_flag = true;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1588,7 +1588,7 @@ static Int p_unlock_system(USES_REGS1) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Int p_enterundefp(USES_REGS1) {
|
||||
static Int enter_undefp(USES_REGS1) {
|
||||
if (LOCAL_DoingUndefp) {
|
||||
return FALSE;
|
||||
}
|
||||
@ -1596,7 +1596,7 @@ static Int p_enterundefp(USES_REGS1) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Int p_exitundefp(USES_REGS1) {
|
||||
static Int exit_undefp(USES_REGS1) {
|
||||
if (LOCAL_DoingUndefp) {
|
||||
LOCAL_DoingUndefp = FALSE;
|
||||
return TRUE;
|
||||
@ -1745,8 +1745,8 @@ void Yap_InitCPreds(void) {
|
||||
Yap_InitCPred("$halt", 1, p_halt, SyncPredFlag);
|
||||
Yap_InitCPred("$lock_system", 0, p_lock_system, SafePredFlag);
|
||||
Yap_InitCPred("$unlock_system", 0, p_unlock_system, SafePredFlag);
|
||||
Yap_InitCPred("$enter_undefp", 0, p_enterundefp, SafePredFlag);
|
||||
Yap_InitCPred("$exit_undefp", 0, p_exitundefp, SafePredFlag);
|
||||
Yap_InitCPred("$enter_undefp", 0, enter_undefp, SafePredFlag);
|
||||
Yap_InitCPred("$exit_undefp", 0, exit_undefp, SafePredFlag);
|
||||
|
||||
#ifdef YAP_JIT
|
||||
Yap_InitCPred("$jit_init", 1, p_jit, SafePredFlag | SyncPredFlag);
|
||||
@ -1772,6 +1772,7 @@ void Yap_InitCPreds(void) {
|
||||
Yap_InitCmpPreds();
|
||||
Yap_InitCoroutPreds();
|
||||
Yap_InitDBPreds();
|
||||
Yap_InitErrorPreds();
|
||||
Yap_InitExecFs();
|
||||
Yap_InitGlobals();
|
||||
Yap_InitInlines();
|
||||
|
@ -14334,10 +14334,7 @@ S_SREG = RepAppl(d0);
|
||||
}
|
||||
#endif /* FROZEN_STACKS */
|
||||
d0 = ARG1;
|
||||
if (PRED_GOAL_EXPANSION_ALL) {
|
||||
goto execute_metacall;
|
||||
}
|
||||
restart_execute:
|
||||
restart_execute:
|
||||
deref_head(d0, execute_unk);
|
||||
execute_nvar:
|
||||
if (IsApplTerm(d0)) {
|
||||
|
18
C/write.c
18
C/write.c
@ -445,7 +445,7 @@ static int legalAtom(unsigned char *s) /* Is this a legal atom ? */
|
||||
} else if (Yap_chtype[ch] == SL) {
|
||||
return (!s[1]);
|
||||
} else if ((ch == ',' || ch == '.') && !s[1]) {
|
||||
return FALSE;
|
||||
return false;
|
||||
} else {
|
||||
if (ch == '/') {
|
||||
if (s[1] == '*')
|
||||
@ -470,7 +470,9 @@ static wtype
|
||||
AtomIsSymbols(unsigned char *s) /* Is this atom just formed by symbols ? */
|
||||
{
|
||||
int ch;
|
||||
if (Yap_chtype[(int)s[0]] == SL && s[1] == '\0')
|
||||
if ( Yap_chtype[(int)s[0]] == SL &&
|
||||
s[1] == '\0'
|
||||
)
|
||||
return (separator);
|
||||
while ((ch = *s++) != '\0') {
|
||||
if (Yap_chtype[ch] != SY)
|
||||
@ -840,6 +842,9 @@ static void write_list(Term t, int direction, int depth,
|
||||
do_jump = (direction >= 0);
|
||||
}
|
||||
if (wglb->MaxDepth != 0 && depth > wglb->MaxDepth) {
|
||||
if (lastw == symbol || lastw == separator) {
|
||||
wrputc(' ', wglb->stream);
|
||||
}
|
||||
wrputc('|', wglb->stream);
|
||||
putAtom(Atom3Dots, wglb->Quote_illegal, wglb);
|
||||
return;
|
||||
@ -856,6 +861,9 @@ static void write_list(Term t, int direction, int depth,
|
||||
Term nt = from_pointer(RepPair(t) + 1, &nrwt, wglb);
|
||||
/* we found an infinite loop */
|
||||
if (IsAtomTerm(nt)) {
|
||||
if (lastw == symbol || lastw == separator) {
|
||||
wrputc(' ', wglb->stream);
|
||||
}
|
||||
wrputc('|', wglb->stream);
|
||||
writeTerm(nt, 999, depth, FALSE, wglb, rwt);
|
||||
} else {
|
||||
@ -865,6 +873,9 @@ static void write_list(Term t, int direction, int depth,
|
||||
}
|
||||
restore_from_write(&nrwt, wglb);
|
||||
} else if (ti != MkAtomTerm(AtomNil)) {
|
||||
if (lastw == symbol || lastw == separator) {
|
||||
wrputc(' ', wglb->stream);
|
||||
}
|
||||
wrputc('|', wglb->stream);
|
||||
lastw = separator;
|
||||
writeTerm(from_pointer(RepPair(t) + 1, &nrwt, wglb), 999, depth, FALSE,
|
||||
@ -1101,6 +1112,9 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
||||
wrputc(',', wglb->stream);
|
||||
lastw = separator;
|
||||
} else if (!strcmp((char *)RepAtom(atom)->StrOfAE, "|")) {
|
||||
if (lastw == symbol || lastw == separator) {
|
||||
wrputc(' ', wglb->stream);
|
||||
}
|
||||
wrputc('|', wglb->stream);
|
||||
lastw = separator;
|
||||
} else
|
||||
|
674
H/TermExt.h
674
H/TermExt.h
@ -17,108 +17,90 @@
|
||||
|
||||
@file TermExt.h
|
||||
|
||||
@page Extensions Extensions to Prolog
|
||||
|
||||
YAP includes a number of extensions over the original Prolog
|
||||
language. Next, we discuss support to the most important ones.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifdef USE_SYSTEM_MALLOC
|
||||
#define SF_STORE (&(Yap_heap_regs->funcs))
|
||||
#define SF_STORE (&(Yap_heap_regs->funcs))
|
||||
#else
|
||||
#define SF_STORE ((special_functors *)HEAP_INIT_BASE)
|
||||
#define SF_STORE ((special_functors *)HEAP_INIT_BASE)
|
||||
#endif
|
||||
|
||||
#if defined(USE_OFFSETS)
|
||||
#define AtomFoundVar ((Atom)(&(((special_functors *)(NULL))->AtFoundVar)))
|
||||
#define AtomFreeTerm ((Atom)(&(((special_functors *)(NULL))->AtFreeTerm)))
|
||||
#define AtomNil ((Atom)(&(((special_functors *)(NULL))->AtNil)))
|
||||
#define AtomDot ((Atom)(&(((special_functors *)(NULL))->AtDot)))
|
||||
#define AtomFoundVar ((Atom)(&(((special_functors *)(NULL))->AtFoundVar)))
|
||||
#define AtomFreeTerm ((Atom)(&(((special_functors *)(NULL))->AtFreeTerm)))
|
||||
#define AtomNil ((Atom)(&(((special_functors *)(NULL))->AtNil)))
|
||||
#define AtomDot ((Atom)(&(((special_functors *)(NULL))->AtDot)))
|
||||
#elif OLD_STYLE_INITIAL_ATOMS
|
||||
#define AtomFoundVar AbsAtom((AtomEntry *)&(SF_STORE->AtFoundVar))
|
||||
#define AtomFreeTerm AbsAtom((AtomEntry *)&(SF_STORE->AtFreeTerm))
|
||||
#define AtomNil AbsAtom((AtomEntry *)&(SF_STORE->AtNil))
|
||||
#define AtomDot AbsAtom((AtomEntry *)&(SF_STORE->AtDot))
|
||||
#define AtomFoundVar AbsAtom((AtomEntry *)&(SF_STORE->AtFoundVar))
|
||||
#define AtomFreeTerm AbsAtom((AtomEntry *)&(SF_STORE->AtFreeTerm))
|
||||
#define AtomNil AbsAtom((AtomEntry *)&(SF_STORE->AtNil))
|
||||
#define AtomDot AbsAtom((AtomEntry *)&(SF_STORE->AtDot))
|
||||
#else
|
||||
#define AtomFoundVar AbsAtom(SF_STORE->AtFoundVar)
|
||||
#define AtomFreeTerm AbsAtom(SF_STORE->AtFreeTerm)
|
||||
#define AtomNil AbsAtom(SF_STORE->AtNil)
|
||||
#define AtomDot AbsAtom(SF_STORE->AtDot)
|
||||
#define AtomFoundVar AbsAtom(SF_STORE->AtFoundVar)
|
||||
#define AtomFreeTerm AbsAtom(SF_STORE->AtFreeTerm)
|
||||
#define AtomNil AbsAtom(SF_STORE->AtNil)
|
||||
#define AtomDot AbsAtom(SF_STORE->AtDot)
|
||||
#endif
|
||||
|
||||
#define TermFoundVar MkAtomTerm(AtomFoundVar)
|
||||
#define TermFreeTerm MkAtomTerm(AtomFreeTerm)
|
||||
#define TermNil MkAtomTerm(AtomNil)
|
||||
#define TermDot MkAtomTerm(AtomDot)
|
||||
#define TermFoundVar MkAtomTerm(AtomFoundVar)
|
||||
#define TermFreeTerm MkAtomTerm(AtomFreeTerm)
|
||||
#define TermNil MkAtomTerm(AtomNil)
|
||||
#define TermDot MkAtomTerm(AtomDot)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
db_ref_e = sizeof (Functor *),
|
||||
attvar_e = 2*sizeof (Functor *),
|
||||
double_e = 3 * sizeof (Functor *),
|
||||
long_int_e = 4 * sizeof (Functor *),
|
||||
big_int_e = 5 * sizeof (Functor *),
|
||||
string_e = 6 * sizeof (Functor *)
|
||||
}
|
||||
blob_type;
|
||||
typedef enum {
|
||||
db_ref_e = sizeof(Functor *),
|
||||
attvar_e = 2 * sizeof(Functor *),
|
||||
double_e = 3 * sizeof(Functor *),
|
||||
long_int_e = 4 * sizeof(Functor *),
|
||||
big_int_e = 5 * sizeof(Functor *),
|
||||
string_e = 6 * sizeof(Functor *)
|
||||
} blob_type;
|
||||
|
||||
#define FunctorDBRef ((Functor)(db_ref_e))
|
||||
#define FunctorAttVar ((Functor)(attvar_e))
|
||||
#define FunctorDouble ((Functor)(double_e))
|
||||
#define FunctorLongInt ((Functor)(long_int_e))
|
||||
#define FunctorBigInt ((Functor)(big_int_e))
|
||||
#define FunctorString ((Functor)(string_e))
|
||||
#define EndSpecials (string_e+sizeof(Functor *))
|
||||
#define FunctorDBRef ((Functor)(db_ref_e))
|
||||
#define FunctorAttVar ((Functor)(attvar_e))
|
||||
#define FunctorDouble ((Functor)(double_e))
|
||||
#define FunctorLongInt ((Functor)(long_int_e))
|
||||
#define FunctorBigInt ((Functor)(big_int_e))
|
||||
#define FunctorString ((Functor)(string_e))
|
||||
#define EndSpecials (string_e + sizeof(Functor *))
|
||||
|
||||
#include "inline-only.h"
|
||||
|
||||
#define IsAttVar(pt) __IsAttVar((pt) PASS_REGS)
|
||||
#define IsAttVar(pt) __IsAttVar((pt)PASS_REGS)
|
||||
|
||||
INLINE_ONLY inline EXTERN int __IsAttVar (CELL *pt USES_REGS);
|
||||
INLINE_ONLY inline EXTERN int __IsAttVar(CELL *pt USES_REGS);
|
||||
|
||||
INLINE_ONLY inline EXTERN int
|
||||
__IsAttVar (CELL *pt USES_REGS)
|
||||
{
|
||||
INLINE_ONLY inline EXTERN int __IsAttVar(CELL *pt USES_REGS) {
|
||||
#ifdef YAP_H
|
||||
return (pt)[-1] == (CELL)attvar_e
|
||||
&& pt < HR;
|
||||
return (pt)[-1] == (CELL)attvar_e && pt < HR;
|
||||
#else
|
||||
return (pt)[-1] == (CELL)attvar_e;
|
||||
#endif
|
||||
}
|
||||
|
||||
INLINE_ONLY inline EXTERN int GlobalIsAttVar (CELL *pt);
|
||||
INLINE_ONLY inline EXTERN int GlobalIsAttVar(CELL *pt);
|
||||
|
||||
INLINE_ONLY inline EXTERN int
|
||||
GlobalIsAttVar (CELL *pt)
|
||||
{
|
||||
INLINE_ONLY inline EXTERN int GlobalIsAttVar(CELL *pt) {
|
||||
return (pt)[-1] == (CELL)attvar_e;
|
||||
}
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BIG_INT = 0x01,
|
||||
BIG_RATIONAL = 0x02,
|
||||
BIG_FLOAT = 0x04,
|
||||
EMPTY_ARENA = 0x10,
|
||||
ARRAY_INT = 0x21,
|
||||
ARRAY_FLOAT = 0x22,
|
||||
CLAUSE_LIST = 0x40,
|
||||
EXTERNAL_BLOB = 0x100, /* generic data */
|
||||
USER_BLOB_START = 0x1000, /* user defined blob */
|
||||
USER_BLOB_END = 0x1100 /* end of user defined blob */
|
||||
}
|
||||
big_blob_type;
|
||||
typedef enum {
|
||||
BIG_INT = 0x01,
|
||||
BIG_RATIONAL = 0x02,
|
||||
BIG_FLOAT = 0x04,
|
||||
EMPTY_ARENA = 0x10,
|
||||
ARRAY_INT = 0x21,
|
||||
ARRAY_FLOAT = 0x22,
|
||||
CLAUSE_LIST = 0x40,
|
||||
EXTERNAL_BLOB = 0x100, /* generic data */
|
||||
USER_BLOB_START = 0x1000, /* user defined blob */
|
||||
USER_BLOB_END = 0x1100 /* end of user defined blob */
|
||||
} big_blob_type;
|
||||
|
||||
INLINE_ONLY inline EXTERN blob_type BlobOfFunctor (Functor f);
|
||||
INLINE_ONLY inline EXTERN blob_type BlobOfFunctor(Functor f);
|
||||
|
||||
INLINE_ONLY inline EXTERN blob_type
|
||||
BlobOfFunctor (Functor f)
|
||||
{
|
||||
return (blob_type) ((CELL)f);
|
||||
INLINE_ONLY inline EXTERN blob_type BlobOfFunctor(Functor f) {
|
||||
return (blob_type)((CELL)f);
|
||||
}
|
||||
|
||||
typedef struct cp_frame {
|
||||
@ -131,44 +113,35 @@ typedef struct cp_frame {
|
||||
#endif
|
||||
} copy_frame;
|
||||
|
||||
|
||||
#ifdef COROUTINING
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
/* what to do when someone tries to bind our term to someone else
|
||||
in some predefined context */
|
||||
void (*bind_op) (Term *, Term CACHE_TYPE);
|
||||
void (*bind_op)(Term *, Term CACHE_TYPE);
|
||||
/* what to do if someone wants to copy our constraint */
|
||||
int (*copy_term_op) (CELL *, struct cp_frame **, CELL * CACHE_TYPE);
|
||||
int (*copy_term_op)(CELL *, struct cp_frame **, CELL *CACHE_TYPE);
|
||||
/* copy the constraint into a term and back */
|
||||
Term (*to_term_op) (CELL *);
|
||||
int (*term_to_op) (Term, Term CACHE_TYPE);
|
||||
Term (*to_term_op)(CELL *);
|
||||
int (*term_to_op)(Term, Term CACHE_TYPE);
|
||||
/* op called to do marking in GC */
|
||||
void (*mark_op) (CELL *);
|
||||
void (*mark_op)(CELL *);
|
||||
} ext_op;
|
||||
|
||||
/* known delays */
|
||||
typedef enum
|
||||
{
|
||||
empty_ext = 0 * sizeof (ext_op), /* default op, this should never be called */
|
||||
attvars_ext = 1 * sizeof (ext_op) /* support for attributed variables */
|
||||
/* add your own extensions here */
|
||||
/* keep this one */
|
||||
}
|
||||
exts;
|
||||
|
||||
|
||||
|
||||
typedef enum {
|
||||
empty_ext = 0 * sizeof(ext_op), /* default op, this should never be called */
|
||||
attvars_ext = 1 * sizeof(ext_op) /* support for attributed variables */
|
||||
/* add your own extensions here */
|
||||
/* keep this one */
|
||||
} exts;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(YAP_H)
|
||||
/* make sure that these data structures are the first thing to be allocated
|
||||
in the heap when we start the system */
|
||||
typedef struct special_functors_struct
|
||||
{
|
||||
typedef struct special_functors_struct {
|
||||
|
||||
#if 0
|
||||
struct ExtraAtomEntryStruct AtFoundVar;
|
||||
@ -181,57 +154,43 @@ typedef struct special_functors_struct
|
||||
struct AtomEntryStruct *AtNil;
|
||||
struct AtomEntryStruct *AtDot;
|
||||
#endif
|
||||
}
|
||||
special_functors;
|
||||
} special_functors;
|
||||
#endif /* YAP_H */
|
||||
|
||||
INLINE_ONLY inline EXTERN Float CpFloatUnaligned(CELL *ptr);
|
||||
|
||||
#define MkFloatTerm(fl) __MkFloatTerm((fl) PASS_REGS)
|
||||
#define MkFloatTerm(fl) __MkFloatTerm((fl)PASS_REGS)
|
||||
|
||||
INLINE_ONLY inline EXTERN Term __MkFloatTerm (Float USES_REGS);
|
||||
INLINE_ONLY inline EXTERN Term __MkFloatTerm(Float USES_REGS);
|
||||
|
||||
INLINE_ONLY inline EXTERN Float FloatOfTerm (Term t);
|
||||
INLINE_ONLY inline EXTERN Float FloatOfTerm(Term t);
|
||||
|
||||
#if SIZEOF_DOUBLE == SIZEOF_INT_P
|
||||
|
||||
INLINE_ONLY inline EXTERN Term
|
||||
__MkFloatTerm (Float dbl USES_REGS)
|
||||
{
|
||||
return (Term) ((HR[0] = (CELL) FunctorDouble, *(Float *) (HR + 1) =
|
||||
dbl, HR[2] = EndSpecials, HR +=
|
||||
3, AbsAppl (HR - 3)));
|
||||
INLINE_ONLY inline EXTERN Term __MkFloatTerm(Float dbl USES_REGS) {
|
||||
return (Term)((HR[0] = (CELL)FunctorDouble, *(Float *)(HR + 1) = dbl,
|
||||
HR[2] = EndSpecials, HR += 3, AbsAppl(HR - 3)));
|
||||
}
|
||||
|
||||
|
||||
INLINE_ONLY inline EXTERN Float
|
||||
FloatOfTerm (Term t)
|
||||
{
|
||||
return (Float) (*(Float *) (RepAppl (t) + 1));
|
||||
INLINE_ONLY inline EXTERN Float FloatOfTerm(Term t) {
|
||||
return (Float)(*(Float *)(RepAppl(t) + 1));
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define InitUnalignedFloat()
|
||||
|
||||
INLINE_ONLY inline EXTERN Float
|
||||
CpFloatUnaligned(CELL *ptr)
|
||||
{
|
||||
INLINE_ONLY inline EXTERN Float CpFloatUnaligned(CELL *ptr) {
|
||||
return *((Float *)ptr);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#if SIZEOF_DOUBLE == 2*SIZEOF_INT_P
|
||||
#if SIZEOF_DOUBLE == 2 * SIZEOF_INT_P
|
||||
|
||||
#define DOUBLE_ALIGNED(ADDR) ((CELL)(ADDR) & 0x4)
|
||||
#define DOUBLE_ALIGNED(ADDR) ((CELL)(ADDR)&0x4)
|
||||
|
||||
INLINE_ONLY EXTERN inline void
|
||||
AlignGlobalForDouble( USES_REGS1 );
|
||||
INLINE_ONLY EXTERN inline void AlignGlobalForDouble(USES_REGS1);
|
||||
|
||||
INLINE_ONLY EXTERN inline void
|
||||
AlignGlobalForDouble( USES_REGS1 )
|
||||
{
|
||||
INLINE_ONLY EXTERN inline void AlignGlobalForDouble(USES_REGS1) {
|
||||
/* Force Alignment for floats. Note that garbage collector may
|
||||
break the alignment; */
|
||||
if (!DOUBLE_ALIGNED(HR)) {
|
||||
@ -241,19 +200,14 @@ AlignGlobalForDouble( USES_REGS1 )
|
||||
}
|
||||
|
||||
#ifdef i386
|
||||
INLINE_ONLY inline EXTERN Float
|
||||
CpFloatUnaligned (CELL * ptr)
|
||||
{
|
||||
return *((Float *) (ptr + 1));
|
||||
INLINE_ONLY inline EXTERN Float CpFloatUnaligned(CELL *ptr) {
|
||||
return *((Float *)(ptr + 1));
|
||||
}
|
||||
|
||||
#else
|
||||
/* first, need to address the alignment problem */
|
||||
INLINE_ONLY inline EXTERN Float
|
||||
CpFloatUnaligned (CELL * ptr)
|
||||
{
|
||||
union
|
||||
{
|
||||
INLINE_ONLY inline EXTERN Float CpFloatUnaligned(CELL *ptr) {
|
||||
union {
|
||||
Float f;
|
||||
CELL d[2];
|
||||
} u;
|
||||
@ -264,28 +218,21 @@ CpFloatUnaligned (CELL * ptr)
|
||||
|
||||
#endif
|
||||
|
||||
INLINE_ONLY inline EXTERN Term
|
||||
__MkFloatTerm (Float dbl USES_REGS)
|
||||
{
|
||||
return (Term) ((AlignGlobalForDouble ( PASS_REGS1 ), HR[0] =
|
||||
(CELL) FunctorDouble, *(Float *) (HR + 1) = dbl, HR[3] =
|
||||
EndSpecials, HR +=
|
||||
4, AbsAppl (HR - 4)));
|
||||
INLINE_ONLY inline EXTERN Term __MkFloatTerm(Float dbl USES_REGS) {
|
||||
return (Term)((AlignGlobalForDouble(PASS_REGS1), HR[0] = (CELL)FunctorDouble,
|
||||
*(Float *)(HR + 1) = dbl, HR[3] = EndSpecials, HR += 4,
|
||||
AbsAppl(HR - 4)));
|
||||
}
|
||||
|
||||
|
||||
INLINE_ONLY inline EXTERN Float
|
||||
FloatOfTerm (Term t)
|
||||
{
|
||||
return (Float) ((DOUBLE_ALIGNED (RepAppl (t)) ? *(Float *) (RepAppl (t) + 1)
|
||||
: CpFloatUnaligned (RepAppl (t))));
|
||||
INLINE_ONLY inline EXTERN Float FloatOfTerm(Term t) {
|
||||
return (Float)((DOUBLE_ALIGNED(RepAppl(t)) ? *(Float *)(RepAppl(t) + 1)
|
||||
: CpFloatUnaligned(RepAppl(t))));
|
||||
}
|
||||
|
||||
|
||||
/* no alignment problems for 64 bit machines */
|
||||
#else
|
||||
/* OOPS, YAP only understands Floats that are as large as cells or that
|
||||
take two cells!!! */
|
||||
/* OOPS, YAP only understands Floats that are as large as cells or that
|
||||
take two cells!!! */
|
||||
|
||||
OOPS
|
||||
|
||||
@ -296,52 +243,38 @@ OOPS
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
|
||||
INLINE_ONLY inline EXTERN int IsFloatTerm(Term);
|
||||
|
||||
INLINE_ONLY inline EXTERN int IsFloatTerm (Term);
|
||||
|
||||
INLINE_ONLY inline EXTERN int
|
||||
IsFloatTerm (Term t)
|
||||
{
|
||||
return (int) (IsApplTerm (t) && FunctorOfTerm (t) == FunctorDouble);
|
||||
INLINE_ONLY inline EXTERN int IsFloatTerm(Term t) {
|
||||
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorDouble);
|
||||
}
|
||||
|
||||
|
||||
/* extern Functor FunctorLongInt; */
|
||||
|
||||
#define MkLongIntTerm(i) __MkLongIntTerm((i) PASS_REGS)
|
||||
#define MkLongIntTerm(i) __MkLongIntTerm((i)PASS_REGS)
|
||||
|
||||
INLINE_ONLY inline EXTERN Term __MkLongIntTerm (Int USES_REGS);
|
||||
INLINE_ONLY inline EXTERN Term __MkLongIntTerm(Int USES_REGS);
|
||||
|
||||
INLINE_ONLY inline EXTERN Term
|
||||
__MkLongIntTerm (Int i USES_REGS)
|
||||
{
|
||||
HR[0] = (CELL) FunctorLongInt;
|
||||
HR[1] = (CELL) (i);
|
||||
HR[2] = EndSpecials;
|
||||
INLINE_ONLY inline EXTERN Term __MkLongIntTerm(Int i USES_REGS) {
|
||||
HR[0] = (CELL)FunctorLongInt;
|
||||
HR[1] = (CELL)(i);
|
||||
HR[2] = EndSpecials;
|
||||
HR += 3;
|
||||
return AbsAppl(HR - 3);
|
||||
}
|
||||
|
||||
INLINE_ONLY inline EXTERN Int LongIntOfTerm(Term t);
|
||||
|
||||
INLINE_ONLY inline EXTERN Int LongIntOfTerm (Term t);
|
||||
|
||||
INLINE_ONLY inline EXTERN Int
|
||||
LongIntOfTerm (Term t)
|
||||
{
|
||||
return (Int) (RepAppl (t)[1]);
|
||||
INLINE_ONLY inline EXTERN Int LongIntOfTerm(Term t) {
|
||||
return (Int)(RepAppl(t)[1]);
|
||||
}
|
||||
|
||||
INLINE_ONLY inline EXTERN int IsLongIntTerm(Term);
|
||||
|
||||
|
||||
INLINE_ONLY inline EXTERN int IsLongIntTerm (Term);
|
||||
|
||||
INLINE_ONLY inline EXTERN int
|
||||
IsLongIntTerm (Term t)
|
||||
{
|
||||
return (int) (IsApplTerm (t) && FunctorOfTerm (t) == FunctorLongInt);
|
||||
INLINE_ONLY inline EXTERN int IsLongIntTerm(Term t) {
|
||||
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorLongInt);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************/
|
||||
|
||||
/*********** strings, coded as UTF-8 ****************/
|
||||
@ -350,67 +283,54 @@ IsLongIntTerm (Term t)
|
||||
|
||||
/* extern Functor FunctorString; */
|
||||
|
||||
#define MkStringTerm(i) __MkStringTerm((i) PASS_REGS)
|
||||
#define MkStringTerm(i) __MkStringTerm((i)PASS_REGS)
|
||||
|
||||
INLINE_ONLY inline EXTERN Term __MkStringTerm (const char *s USES_REGS);
|
||||
INLINE_ONLY inline EXTERN Term __MkStringTerm(const char *s USES_REGS);
|
||||
|
||||
INLINE_ONLY inline EXTERN Term
|
||||
__MkStringTerm (const char *s USES_REGS)
|
||||
{
|
||||
INLINE_ONLY inline EXTERN Term __MkStringTerm(const char *s USES_REGS) {
|
||||
Term t = AbsAppl(HR);
|
||||
size_t sz = ALIGN_BY_TYPE(strlen((char *)s)+1,CELL);
|
||||
HR[0] = (CELL) FunctorString;
|
||||
HR[1] = (CELL) sz;
|
||||
strcpy((char *)(HR+2), (const char *)s);
|
||||
HR[2+sz] = EndSpecials;
|
||||
HR += 3+sz;
|
||||
size_t sz = ALIGN_BY_TYPE(strlen((char *)s) + 1, CELL);
|
||||
HR[0] = (CELL)FunctorString;
|
||||
HR[1] = (CELL)sz;
|
||||
strcpy((char *)(HR + 2), (const char *)s);
|
||||
HR[2 + sz] = EndSpecials;
|
||||
HR += 3 + sz;
|
||||
return t;
|
||||
}
|
||||
|
||||
INLINE_ONLY inline EXTERN Term __MkUStringTerm (const unsigned char *s USES_REGS);
|
||||
INLINE_ONLY inline EXTERN Term
|
||||
__MkUStringTerm(const unsigned char *s USES_REGS);
|
||||
|
||||
INLINE_ONLY inline EXTERN Term
|
||||
__MkUStringTerm (const unsigned char *s USES_REGS)
|
||||
{
|
||||
__MkUStringTerm(const unsigned char *s USES_REGS) {
|
||||
Term t = AbsAppl(HR);
|
||||
size_t sz = ALIGN_BY_TYPE(strlen((char *)s)+1,CELL);
|
||||
HR[0] = (CELL) FunctorString;
|
||||
HR[1] = (CELL) sz;
|
||||
strcpy((char *)(HR+2), (const char *)s);
|
||||
HR[2+sz] = EndSpecials;
|
||||
HR += 3+sz;
|
||||
size_t sz = ALIGN_BY_TYPE(strlen((char *)s) + 1, CELL);
|
||||
HR[0] = (CELL)FunctorString;
|
||||
HR[1] = (CELL)sz;
|
||||
strcpy((char *)(HR + 2), (const char *)s);
|
||||
HR[2 + sz] = EndSpecials;
|
||||
HR += 3 + sz;
|
||||
return t;
|
||||
}
|
||||
|
||||
INLINE_ONLY inline EXTERN const unsigned char *UStringOfTerm(Term t);
|
||||
|
||||
INLINE_ONLY inline EXTERN const unsigned char *UStringOfTerm (Term t);
|
||||
|
||||
INLINE_ONLY inline EXTERN const unsigned char *
|
||||
UStringOfTerm (Term t)
|
||||
{
|
||||
return (const unsigned char *) (RepAppl (t)+2);
|
||||
INLINE_ONLY inline EXTERN const unsigned char *UStringOfTerm(Term t) {
|
||||
return (const unsigned char *)(RepAppl(t) + 2);
|
||||
}
|
||||
|
||||
INLINE_ONLY inline EXTERN const char *StringOfTerm (Term t);
|
||||
INLINE_ONLY inline EXTERN const char *StringOfTerm(Term t);
|
||||
|
||||
INLINE_ONLY inline EXTERN const char *
|
||||
StringOfTerm (Term t)
|
||||
{
|
||||
return (const char *) (RepAppl (t)+2);
|
||||
INLINE_ONLY inline EXTERN const char *StringOfTerm(Term t) {
|
||||
return (const char *)(RepAppl(t) + 2);
|
||||
}
|
||||
|
||||
INLINE_ONLY inline EXTERN int IsStringTerm(Term);
|
||||
|
||||
|
||||
INLINE_ONLY inline EXTERN int IsStringTerm (Term);
|
||||
|
||||
INLINE_ONLY inline EXTERN int
|
||||
IsStringTerm (Term t)
|
||||
{
|
||||
return (int) (IsApplTerm (t) && FunctorOfTerm (t) == FunctorString);
|
||||
INLINE_ONLY inline EXTERN int IsStringTerm(Term t) {
|
||||
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorString);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************************/
|
||||
|
||||
#ifdef USE_GMP
|
||||
@ -422,7 +342,7 @@ IsStringTerm (Term t)
|
||||
#undef __cplusplus
|
||||
#include <gmp.h>
|
||||
#define __cplusplus OCXX
|
||||
#elif !defined( __GMP_H__ )
|
||||
#elif !defined(__GMP_H__)
|
||||
#include <gmp.h>
|
||||
#endif
|
||||
|
||||
@ -442,12 +362,10 @@ typedef struct {
|
||||
|
||||
#endif
|
||||
|
||||
INLINE_ONLY inline EXTERN int IsBigIntTerm (Term);
|
||||
INLINE_ONLY inline EXTERN int IsBigIntTerm(Term);
|
||||
|
||||
INLINE_ONLY inline EXTERN int
|
||||
IsBigIntTerm (Term t)
|
||||
{
|
||||
return (int) (IsApplTerm (t) && FunctorOfTerm (t) == FunctorBigInt);
|
||||
INLINE_ONLY inline EXTERN int IsBigIntTerm(Term t) {
|
||||
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorBigInt);
|
||||
}
|
||||
|
||||
#ifdef USE_GMP
|
||||
@ -458,237 +376,154 @@ MP_INT *Yap_BigIntOfTerm(Term);
|
||||
Term Yap_MkBigRatTerm(MP_RAT *);
|
||||
MP_RAT *Yap_BigRatOfTerm(Term);
|
||||
|
||||
INLINE_ONLY inline EXTERN void MPZ_SET (mpz_t, MP_INT *);
|
||||
INLINE_ONLY inline EXTERN void MPZ_SET(mpz_t, MP_INT *);
|
||||
|
||||
INLINE_ONLY inline EXTERN void
|
||||
MPZ_SET (mpz_t dest, MP_INT *src)
|
||||
{
|
||||
INLINE_ONLY inline EXTERN void MPZ_SET(mpz_t dest, MP_INT *src) {
|
||||
dest->_mp_size = src->_mp_size;
|
||||
dest->_mp_alloc = src->_mp_alloc;
|
||||
dest->_mp_d = src->_mp_d;
|
||||
}
|
||||
|
||||
INLINE_ONLY inline EXTERN int IsLargeIntTerm (Term);
|
||||
INLINE_ONLY inline EXTERN int IsLargeIntTerm(Term);
|
||||
|
||||
INLINE_ONLY inline EXTERN int
|
||||
IsLargeIntTerm (Term t)
|
||||
{
|
||||
return (int) (IsApplTerm (t)
|
||||
&& ((FunctorOfTerm (t) <= FunctorBigInt)
|
||||
&& (FunctorOfTerm (t) >= FunctorLongInt)));
|
||||
INLINE_ONLY inline EXTERN int IsLargeIntTerm(Term t) {
|
||||
return (int)(IsApplTerm(t) && ((FunctorOfTerm(t) <= FunctorBigInt) &&
|
||||
(FunctorOfTerm(t) >= FunctorLongInt)));
|
||||
}
|
||||
|
||||
INLINE_ONLY inline EXTERN UInt Yap_SizeOfBigInt(Term);
|
||||
|
||||
INLINE_ONLY inline EXTERN UInt Yap_SizeOfBigInt (Term);
|
||||
|
||||
INLINE_ONLY inline EXTERN UInt
|
||||
Yap_SizeOfBigInt (Term t)
|
||||
{
|
||||
CELL *pt = RepAppl(t)+1;
|
||||
return 2+(sizeof(MP_INT)+
|
||||
(((MP_INT *)pt)->_mp_alloc*sizeof(mp_limb_t)))/sizeof(CELL);
|
||||
INLINE_ONLY inline EXTERN UInt Yap_SizeOfBigInt(Term t) {
|
||||
CELL *pt = RepAppl(t) + 1;
|
||||
return 2 +
|
||||
(sizeof(MP_INT) + (((MP_INT *)pt)->_mp_alloc * sizeof(mp_limb_t))) /
|
||||
sizeof(CELL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#else
|
||||
|
||||
INLINE_ONLY inline EXTERN int IsLargeIntTerm(Term);
|
||||
|
||||
|
||||
INLINE_ONLY inline EXTERN int IsLargeIntTerm (Term);
|
||||
|
||||
INLINE_ONLY inline EXTERN int
|
||||
IsLargeIntTerm (Term t)
|
||||
{
|
||||
return (int) (IsApplTerm (t) && FunctorOfTerm (t) == FunctorLongInt);
|
||||
INLINE_ONLY inline EXTERN int IsLargeIntTerm(Term t) {
|
||||
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorLongInt);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/* extern Functor FunctorLongInt; */
|
||||
|
||||
INLINE_ONLY inline EXTERN int IsLargeNumTerm (Term);
|
||||
INLINE_ONLY inline EXTERN int IsLargeNumTerm(Term);
|
||||
|
||||
INLINE_ONLY inline EXTERN int
|
||||
IsLargeNumTerm (Term t)
|
||||
{
|
||||
return (int) (IsApplTerm (t)
|
||||
&& ((FunctorOfTerm (t) <= FunctorBigInt)
|
||||
&& (FunctorOfTerm (t) >= FunctorDouble)));
|
||||
INLINE_ONLY inline EXTERN int IsLargeNumTerm(Term t) {
|
||||
return (int)(IsApplTerm(t) && ((FunctorOfTerm(t) <= FunctorBigInt) &&
|
||||
(FunctorOfTerm(t) >= FunctorDouble)));
|
||||
}
|
||||
|
||||
INLINE_ONLY inline EXTERN int IsExternalBlobTerm (Term, CELL);
|
||||
INLINE_ONLY inline EXTERN int IsExternalBlobTerm(Term, CELL);
|
||||
|
||||
INLINE_ONLY inline EXTERN int
|
||||
IsExternalBlobTerm (Term t, CELL tag)
|
||||
{
|
||||
return (int) (IsApplTerm (t) &&
|
||||
FunctorOfTerm (t) == FunctorBigInt &&
|
||||
RepAppl(t)[1] == tag);
|
||||
INLINE_ONLY inline EXTERN int IsExternalBlobTerm(Term t, CELL tag) {
|
||||
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorBigInt &&
|
||||
RepAppl(t)[1] == tag);
|
||||
}
|
||||
|
||||
INLINE_ONLY inline EXTERN void *ExternalBlobFromTerm (Term);
|
||||
INLINE_ONLY inline EXTERN void *ExternalBlobFromTerm(Term);
|
||||
|
||||
INLINE_ONLY inline EXTERN void *
|
||||
ExternalBlobFromTerm (Term t)
|
||||
{
|
||||
MP_INT *base = (MP_INT *)(RepAppl(t)+2);
|
||||
return (void *) (base+1);
|
||||
INLINE_ONLY inline EXTERN void *ExternalBlobFromTerm(Term t) {
|
||||
MP_INT *base = (MP_INT *)(RepAppl(t) + 2);
|
||||
return (void *)(base + 1);
|
||||
}
|
||||
|
||||
INLINE_ONLY inline EXTERN int IsNumTerm(Term);
|
||||
|
||||
|
||||
|
||||
INLINE_ONLY inline EXTERN int IsNumTerm (Term);
|
||||
|
||||
INLINE_ONLY inline EXTERN int
|
||||
IsNumTerm (Term t)
|
||||
{
|
||||
return (int) ((IsIntTerm (t) || IsLargeNumTerm (t)));
|
||||
INLINE_ONLY inline EXTERN int IsNumTerm(Term t) {
|
||||
return (int)((IsIntTerm(t) || IsLargeNumTerm(t)));
|
||||
}
|
||||
|
||||
INLINE_ONLY inline EXTERN Int IsAtomicTerm(Term);
|
||||
|
||||
|
||||
|
||||
INLINE_ONLY inline EXTERN Int IsAtomicTerm (Term);
|
||||
|
||||
INLINE_ONLY inline EXTERN Int
|
||||
IsAtomicTerm (Term t)
|
||||
{
|
||||
return (Int) (IsAtomOrIntTerm (t) || IsLargeNumTerm (t) || IsStringTerm(t));
|
||||
INLINE_ONLY inline EXTERN Int IsAtomicTerm(Term t) {
|
||||
return (Int)(IsAtomOrIntTerm(t) || IsLargeNumTerm(t) || IsStringTerm(t));
|
||||
}
|
||||
|
||||
INLINE_ONLY inline EXTERN Int IsExtensionFunctor(Functor);
|
||||
|
||||
|
||||
|
||||
INLINE_ONLY inline EXTERN Int IsExtensionFunctor (Functor);
|
||||
|
||||
INLINE_ONLY inline EXTERN Int
|
||||
IsExtensionFunctor (Functor f)
|
||||
{
|
||||
return (Int) (f <= FunctorString);
|
||||
INLINE_ONLY inline EXTERN Int IsExtensionFunctor(Functor f) {
|
||||
return (Int)(f <= FunctorString);
|
||||
}
|
||||
|
||||
INLINE_ONLY inline EXTERN Int IsBlobFunctor(Functor);
|
||||
|
||||
|
||||
INLINE_ONLY inline EXTERN Int IsBlobFunctor (Functor);
|
||||
|
||||
INLINE_ONLY inline EXTERN Int
|
||||
IsBlobFunctor (Functor f)
|
||||
{
|
||||
return (Int) ((f <= FunctorString && f >= FunctorDBRef));
|
||||
INLINE_ONLY inline EXTERN Int IsBlobFunctor(Functor f) {
|
||||
return (Int)((f <= FunctorString && f >= FunctorDBRef));
|
||||
}
|
||||
|
||||
INLINE_ONLY inline EXTERN Int IsPrimitiveTerm(Term);
|
||||
|
||||
|
||||
INLINE_ONLY inline EXTERN Int IsPrimitiveTerm (Term);
|
||||
|
||||
INLINE_ONLY inline EXTERN Int
|
||||
IsPrimitiveTerm (Term t)
|
||||
{
|
||||
return (Int) ((IsAtomOrIntTerm (t)
|
||||
|| (IsApplTerm (t) && IsBlobFunctor (FunctorOfTerm (t)))));
|
||||
INLINE_ONLY inline EXTERN Int IsPrimitiveTerm(Term t) {
|
||||
return (Int)((IsAtomOrIntTerm(t) ||
|
||||
(IsApplTerm(t) && IsBlobFunctor(FunctorOfTerm(t)))));
|
||||
}
|
||||
|
||||
#ifdef TERM_EXTENSIONS
|
||||
|
||||
INLINE_ONLY inline EXTERN Int IsAttachFunc(Functor);
|
||||
|
||||
INLINE_ONLY inline EXTERN Int IsAttachFunc (Functor);
|
||||
|
||||
INLINE_ONLY inline EXTERN Int
|
||||
IsAttachFunc (Functor f)
|
||||
{
|
||||
return (Int) (FALSE);
|
||||
}
|
||||
|
||||
|
||||
INLINE_ONLY inline EXTERN Int IsAttachFunc(Functor f) { return (Int)(FALSE); }
|
||||
|
||||
#define IsAttachedTerm(t) __IsAttachedTerm(t PASS_REGS)
|
||||
|
||||
INLINE_ONLY inline EXTERN Int __IsAttachedTerm (Term USES_REGS);
|
||||
INLINE_ONLY inline EXTERN Int __IsAttachedTerm(Term USES_REGS);
|
||||
|
||||
INLINE_ONLY inline EXTERN Int
|
||||
__IsAttachedTerm (Term t USES_REGS)
|
||||
{
|
||||
return (Int) ((IsVarTerm (t) && IsAttVar(VarOfTerm(t))));
|
||||
INLINE_ONLY inline EXTERN Int __IsAttachedTerm(Term t USES_REGS) {
|
||||
return (Int)((IsVarTerm(t) && IsAttVar(VarOfTerm(t))));
|
||||
}
|
||||
|
||||
INLINE_ONLY inline EXTERN Int GlobalIsAttachedTerm (Term);
|
||||
INLINE_ONLY inline EXTERN Int GlobalIsAttachedTerm(Term);
|
||||
|
||||
INLINE_ONLY inline EXTERN Int
|
||||
GlobalIsAttachedTerm (Term t)
|
||||
{
|
||||
return (Int) ((IsVarTerm (t) && GlobalIsAttVar(VarOfTerm(t))));
|
||||
INLINE_ONLY inline EXTERN Int GlobalIsAttachedTerm(Term t) {
|
||||
return (Int)((IsVarTerm(t) && GlobalIsAttVar(VarOfTerm(t))));
|
||||
}
|
||||
|
||||
#define SafeIsAttachedTerm(t) __SafeIsAttachedTerm((t) PASS_REGS)
|
||||
#define SafeIsAttachedTerm(t) __SafeIsAttachedTerm((t)PASS_REGS)
|
||||
|
||||
INLINE_ONLY inline EXTERN Int __SafeIsAttachedTerm (Term USES_REGS);
|
||||
INLINE_ONLY inline EXTERN Int __SafeIsAttachedTerm(Term USES_REGS);
|
||||
|
||||
INLINE_ONLY inline EXTERN Int
|
||||
__SafeIsAttachedTerm (Term t USES_REGS)
|
||||
{
|
||||
return (Int) (IsVarTerm (t) && IsAttVar(VarOfTerm(t)));
|
||||
}
|
||||
|
||||
INLINE_ONLY inline EXTERN exts ExtFromCell (CELL *);
|
||||
|
||||
INLINE_ONLY inline EXTERN exts
|
||||
ExtFromCell (CELL * pt)
|
||||
{
|
||||
return attvars_ext;
|
||||
INLINE_ONLY inline EXTERN Int __SafeIsAttachedTerm(Term t USES_REGS) {
|
||||
return (Int)(IsVarTerm(t) && IsAttVar(VarOfTerm(t)));
|
||||
}
|
||||
|
||||
INLINE_ONLY inline EXTERN exts ExtFromCell(CELL *);
|
||||
|
||||
INLINE_ONLY inline EXTERN exts ExtFromCell(CELL *pt) { return attvars_ext; }
|
||||
|
||||
#else
|
||||
|
||||
INLINE_ONLY inline EXTERN Int IsAttachFunc(Functor);
|
||||
|
||||
INLINE_ONLY inline EXTERN Int IsAttachFunc (Functor);
|
||||
|
||||
INLINE_ONLY inline EXTERN Int
|
||||
IsAttachFunc (Functor f)
|
||||
{
|
||||
return (Int) (FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
INLINE_ONLY inline EXTERN Int IsAttachedTerm (Term);
|
||||
|
||||
INLINE_ONLY inline EXTERN Int
|
||||
IsAttachedTerm (Term t)
|
||||
{
|
||||
return (Int) (FALSE);
|
||||
}
|
||||
|
||||
INLINE_ONLY inline EXTERN Int IsAttachFunc(Functor f) { return (Int)(FALSE); }
|
||||
|
||||
INLINE_ONLY inline EXTERN Int IsAttachedTerm(Term);
|
||||
|
||||
INLINE_ONLY inline EXTERN Int IsAttachedTerm(Term t) { return (Int)(FALSE); }
|
||||
|
||||
#endif
|
||||
|
||||
INLINE_ONLY inline EXTERN Int Yap_BlobTag(Term t);
|
||||
|
||||
INLINE_ONLY inline EXTERN Int Yap_BlobTag(Term t)
|
||||
{
|
||||
INLINE_ONLY inline EXTERN Int Yap_BlobTag(Term t) {
|
||||
CELL *pt = RepAppl(t);
|
||||
|
||||
return pt[1];
|
||||
}
|
||||
|
||||
|
||||
INLINE_ONLY inline EXTERN void *Yap_BlobInfo(Term t);
|
||||
|
||||
INLINE_ONLY inline EXTERN void *Yap_BlobInfo(Term t)
|
||||
{
|
||||
INLINE_ONLY inline EXTERN void *Yap_BlobInfo(Term t) {
|
||||
MP_INT *blobp;
|
||||
CELL *pt = RepAppl(t);
|
||||
|
||||
blobp = (MP_INT *)(pt+2);
|
||||
return (void *)(blobp+1);
|
||||
blobp = (MP_INT *)(pt + 2);
|
||||
return (void *)(blobp + 1);
|
||||
}
|
||||
|
||||
#ifdef YAP_H
|
||||
@ -697,92 +532,75 @@ INLINE_ONLY inline EXTERN int unify_extension(Functor, CELL, CELL *, CELL);
|
||||
|
||||
EXTERN int unify_extension(Functor, CELL, CELL *, CELL);
|
||||
|
||||
int Yap_gmp_tcmp_big_big(Term, Term);
|
||||
int Yap_gmp_tcmp_big_big(Term, Term);
|
||||
|
||||
INLINE_ONLY inline EXTERN int
|
||||
unify_extension (Functor f, CELL d0, CELL * pt0, CELL d1)
|
||||
{
|
||||
switch (BlobOfFunctor (f))
|
||||
{
|
||||
case db_ref_e:
|
||||
return (d0 == d1);
|
||||
case attvar_e:
|
||||
return (d0 == d1);
|
||||
case long_int_e:
|
||||
return (pt0[1] == RepAppl (d1)[1]);
|
||||
case string_e:
|
||||
return strcmp( (char *)(pt0+2), (char *)(RepAppl (d1)+2) ) == 0;
|
||||
case big_int_e:
|
||||
INLINE_ONLY inline EXTERN int unify_extension(Functor f, CELL d0, CELL *pt0,
|
||||
CELL d1) {
|
||||
switch (BlobOfFunctor(f)) {
|
||||
case db_ref_e:
|
||||
return (d0 == d1);
|
||||
case attvar_e:
|
||||
return (d0 == d1);
|
||||
case long_int_e:
|
||||
return (pt0[1] == RepAppl(d1)[1]);
|
||||
case string_e:
|
||||
return strcmp((char *)(pt0 + 2), (char *)(RepAppl(d1) + 2)) == 0;
|
||||
case big_int_e:
|
||||
#ifdef USE_GMP
|
||||
return (Yap_gmp_tcmp_big_big(d0,d1) == 0);
|
||||
return (Yap_gmp_tcmp_big_big(d0, d1) == 0);
|
||||
#else
|
||||
return d0 == d1;
|
||||
return d0 == d1;
|
||||
#endif /* USE_GMP */
|
||||
case double_e:
|
||||
{
|
||||
CELL *pt1 = RepAppl (d1);
|
||||
return (pt0[1] == pt1[1]
|
||||
#if SIZEOF_DOUBLE == 2*SIZEOF_INT_P
|
||||
&& pt0[2] == pt1[2]
|
||||
case double_e: {
|
||||
CELL *pt1 = RepAppl(d1);
|
||||
return (pt0[1] == pt1[1]
|
||||
#if SIZEOF_DOUBLE == 2 * SIZEOF_INT_P
|
||||
&& pt0[2] == pt1[2]
|
||||
#endif
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
static inline
|
||||
CELL Yap_IntP_key(CELL *pt)
|
||||
{
|
||||
static inline CELL Yap_IntP_key(CELL *pt) {
|
||||
#ifdef USE_GMP
|
||||
if (((Functor)pt[-1] == FunctorBigInt)) {
|
||||
MP_INT *b1 = Yap_BigIntOfTerm(AbsAppl(pt-1));
|
||||
MP_INT *b1 = Yap_BigIntOfTerm(AbsAppl(pt - 1));
|
||||
/* first cell in program */
|
||||
CELL val = ((CELL *)(b1+1))[0];
|
||||
return MkIntTerm(val & (MAX_ABS_INT-1));
|
||||
CELL val = ((CELL *)(b1 + 1))[0];
|
||||
return MkIntTerm(val & (MAX_ABS_INT - 1));
|
||||
}
|
||||
#endif
|
||||
return MkIntTerm(pt[0] & (MAX_ABS_INT-1));
|
||||
return MkIntTerm(pt[0] & (MAX_ABS_INT - 1));
|
||||
}
|
||||
|
||||
static inline
|
||||
CELL Yap_Int_key(Term t)
|
||||
{
|
||||
return Yap_IntP_key(RepAppl(t)+1);
|
||||
}
|
||||
static inline CELL Yap_Int_key(Term t) { return Yap_IntP_key(RepAppl(t) + 1); }
|
||||
|
||||
static inline
|
||||
CELL Yap_DoubleP_key(CELL *pt)
|
||||
{
|
||||
#if SIZEOF_DOUBLE1 == 2*SIZEOF_INT_P
|
||||
CELL val = pt[0]^pt[1];
|
||||
static inline CELL Yap_DoubleP_key(CELL *pt) {
|
||||
#if SIZEOF_DOUBLE1 == 2 * SIZEOF_INT_P
|
||||
CELL val = pt[0] ^ pt[1];
|
||||
#else
|
||||
CELL val = pt[0];
|
||||
#endif
|
||||
return MkIntTerm(val & (MAX_ABS_INT-1));
|
||||
return MkIntTerm(val & (MAX_ABS_INT - 1));
|
||||
}
|
||||
|
||||
static inline
|
||||
CELL Yap_Double_key(Term t)
|
||||
{
|
||||
return Yap_DoubleP_key(RepAppl(t)+1);
|
||||
static inline CELL Yap_Double_key(Term t) {
|
||||
return Yap_DoubleP_key(RepAppl(t) + 1);
|
||||
}
|
||||
|
||||
static inline
|
||||
CELL Yap_StringP_key(CELL *pt)
|
||||
{
|
||||
static inline CELL Yap_StringP_key(CELL *pt) {
|
||||
UInt n = pt[1], i;
|
||||
CELL val = pt[2];
|
||||
for (i=1; i<n; i++) {
|
||||
val ^= pt[i+1];
|
||||
for (i = 1; i < n; i++) {
|
||||
val ^= pt[i + 1];
|
||||
}
|
||||
return MkIntTerm(val & (MAX_ABS_INT-1));
|
||||
return MkIntTerm(val & (MAX_ABS_INT - 1));
|
||||
}
|
||||
|
||||
static inline
|
||||
CELL Yap_String_key(Term t)
|
||||
{
|
||||
return Yap_StringP_key(RepAppl(t)+1);
|
||||
static inline CELL Yap_String_key(Term t) {
|
||||
return Yap_StringP_key(RepAppl(t) + 1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -442,10 +442,10 @@ follows immediate semantics.
|
||||
library.
|
||||
*/
|
||||
YAP_FLAG(UNKNOWN_FLAG, "unknown", true, isatom, "error",
|
||||
NULL), /**< `unknown is iso`
|
||||
Yap_unknown), /**< `unknown is iso`
|
||||
|
||||
Corresponds to calling the unknown/2 built-in. Possible values
|
||||
are `error`, `fail`, and `warning`.
|
||||
Corresponds to calling the unknown/2 built-in. Possible ISO values
|
||||
are `error`, `fail`, and `warning`. Yap includes the following extensions: `fast_fail` does not invoke any handler.
|
||||
*/
|
||||
YAP_FLAG(VARIABLE_NAMES_MAY_END_WITH_QUOTES_FLAG,
|
||||
"variable_names_may_end_with_quotes", true, boolean, "false",
|
||||
|
@ -135,6 +135,7 @@ void Yap_ResetConsultStack(void);
|
||||
void Yap_AssertzClause(struct pred_entry *, yamop *);
|
||||
void Yap_HidePred(struct pred_entry *pe);
|
||||
int Yap_SetNoTrace(char *name, UInt arity, Term tmod);
|
||||
bool Yap_unknown(Term tflagvalue);
|
||||
|
||||
/* cmppreds.c */
|
||||
Int Yap_compare_terms(Term, Term);
|
||||
@ -176,6 +177,7 @@ bool Yap_Warning(const char *s, ...);
|
||||
bool Yap_PrintWarning(Term t);
|
||||
int Yap_HandleError(const char *msg, ...);
|
||||
int Yap_SWIHandleError(const char *, ...);
|
||||
void Yap_InitErrorPreds(void);
|
||||
|
||||
/* eval.c */
|
||||
void Yap_InitEval(void);
|
||||
@ -317,6 +319,8 @@ void Yap_InitModulesC(void);
|
||||
struct mod_entry *Yap_GetModuleEntry(Term tmod);
|
||||
Term Yap_GetModuleFromEntry(struct mod_entry *me);
|
||||
bool Yap_CharacterEscapes(Term mt);
|
||||
bool Yap_constPred( struct pred_entry *pt);
|
||||
bool Yap_isSystemModule(Term mod);
|
||||
|
||||
#if HAVE_MPI
|
||||
/* mpi.c */
|
||||
|
@ -437,7 +437,10 @@ IsModProperty (int flags)
|
||||
#define UNKNOWN_FAIL (0x0400) /* module */
|
||||
#define UNKNOWN_WARNING (0x0800) /* module */
|
||||
#define UNKNOWN_ERROR (0x1000) /* module */
|
||||
#define UNKNOWN_MASK (UNKNOWN_ERROR|UNKNOWN_WARNING|UNKNOWN_FAIL)
|
||||
#define UNKNOWN_FAST_FAIL (0x2000) /* module */
|
||||
#define UNKNOWN_ABORT (0x4000) /* module */
|
||||
#define UNKNOWN_HALT (0x8000) /* module */
|
||||
#define UNKNOWN_MASK (UNKNOWN_ERROR|UNKNOWN_WARNING|UNKNOWN_FAIL|UNKNOWN_FAST_FAIL|UNKNOWN_ABORT|UNKNOWN_HALT )
|
||||
|
||||
Term Yap_getUnknownModule(ModEntry *m);
|
||||
void Yap_setModuleFlags(ModEntry *n, ModEntry *o);
|
||||
@ -688,7 +691,7 @@ don't forget to also add in qly.h
|
||||
#define SyncPredFlag ((pred_flags_t)0x00100000) /* has to synch before it can execute */
|
||||
#define NumberDBPredFlag ((pred_flags_t)0x00080000) /* entry for a number key */
|
||||
#define AtomDBPredFlag ((pred_flags_t)0x00040000) /* entry for an atom key */
|
||||
#define GoalExPredFlag ((pred_flags_t)0x00020000) /* predicate that is called by goal_expand */
|
||||
// #define GoalExPredFlag ((pred_flags_t)0x00020000) /* predicate that is called by goal_expand */
|
||||
#define TestPredFlag ((pred_flags_t)0x00010000) /* is a test (optim. comit) */
|
||||
#define AsmPredFlag ((pred_flags_t)0x00008000) /* inline */
|
||||
#define StandardPredFlag ((pred_flags_t)0x00004000) /* system predicate */
|
||||
|
@ -142,3 +142,5 @@
|
||||
|
||||
#define GLOBAL_LastWTimePtr Yap_global->LastWTimePtr_
|
||||
|
||||
#define GLOBAL_MaxPriority Yap_global->MaxPriority_
|
||||
|
||||
|
@ -101,6 +101,7 @@
|
||||
#define SWI_MODULE Yap_heap_regs->swi_module
|
||||
#define DBLOAD_MODULE Yap_heap_regs->dbload_module
|
||||
#define RANGE_MODULE Yap_heap_regs->range_module
|
||||
#define ERROR_MODULE Yap_heap_regs->error_module
|
||||
|
||||
|
||||
|
||||
@ -207,9 +208,6 @@
|
||||
|
||||
#define PROFILING Yap_heap_regs->system_profiling
|
||||
#define CALL_COUNTING Yap_heap_regs->system_call_counting
|
||||
#define PRED_GOAL_EXPANSION_ALL Yap_heap_regs->system_pred_goal_expansion_all
|
||||
#define PRED_GOAL_EXPANSION_FUNC Yap_heap_regs->system_pred_goal_expansion_func
|
||||
#define PRED_GOAL_EXPANSION_ON Yap_heap_regs->system_pred_goal_expansion_on
|
||||
#define optimizer_on Yap_heap_regs->compiler_optimizer_on
|
||||
#define compile_mode Yap_heap_regs->compiler_compile_mode
|
||||
#define profiling Yap_heap_regs->compiler_profiling
|
||||
|
@ -453,8 +453,6 @@
|
||||
#define REMOTE_ImportDBRefHashTableNum(wid) REMOTE(wid)->ImportDBRefHashTableNum_
|
||||
#define LOCAL_ImportFAILCODE LOCAL->ImportFAILCODE_
|
||||
#define REMOTE_ImportFAILCODE(wid) REMOTE(wid)->ImportFAILCODE_
|
||||
#define LOCAL_FunctorVar LOCAL->FunctorVar_
|
||||
#define REMOTE_FunctorVar(wid) REMOTE(wid)->FunctorVar_
|
||||
#if __ANDROID__
|
||||
|
||||
#define LOCAL_assetManager LOCAL->assetManager_
|
||||
|
@ -141,4 +141,6 @@ typedef struct global_data {
|
||||
char* CharConversionTable2_;
|
||||
|
||||
void* LastWTimePtr_;
|
||||
|
||||
int MaxPriority_;
|
||||
} w_shared;
|
||||
|
@ -252,7 +252,6 @@ const char* Error_Function_;
|
||||
UInt ImportDBRefHashTableSize_;
|
||||
UInt ImportDBRefHashTableNum_;
|
||||
yamop *ImportFAILCODE_;
|
||||
Functor FunctorVar_;
|
||||
#if __ANDROID__
|
||||
|
||||
struct AAssetManager* assetManager_;
|
||||
|
@ -101,6 +101,7 @@
|
||||
Term swi_module;
|
||||
Term dbload_module;
|
||||
Term range_module;
|
||||
Term error_module;
|
||||
|
||||
|
||||
|
||||
@ -207,9 +208,6 @@
|
||||
|
||||
int system_profiling;
|
||||
int system_call_counting;
|
||||
int system_pred_goal_expansion_all;
|
||||
int system_pred_goal_expansion_func;
|
||||
int system_pred_goal_expansion_on;
|
||||
int compiler_optimizer_on;
|
||||
int compiler_compile_mode;
|
||||
int compiler_profiling;
|
||||
|
@ -25,6 +25,10 @@
|
||||
AtomEmptyBrackets = Yap_LookupAtom("()");
|
||||
AtomEmptySquareBrackets = Yap_LookupAtom("[]");
|
||||
AtomEmptyCurlyBrackets = Yap_LookupAtom("{}");
|
||||
AtomAsserta = Yap_LookupAtom("asserta");
|
||||
AtomAssertaStatic = Yap_LookupAtom("asserta_static");
|
||||
AtomAssertz = Yap_LookupAtom("assertz");
|
||||
AtomAssertzStatic = Yap_LookupAtom("assertz_static");
|
||||
AtomAt = Yap_LookupAtom("at");
|
||||
AtomAtom = Yap_LookupAtom("atom");
|
||||
AtomAtomic = Yap_LookupAtom("atomic");
|
||||
@ -66,6 +70,7 @@
|
||||
AtomCompact = Yap_LookupAtom("compact");
|
||||
AtomCompound = Yap_LookupAtom("compound");
|
||||
AtomConsistencyError = Yap_LookupAtom("consistency_error");
|
||||
AtomConsult = Yap_LookupAtom("consult");
|
||||
AtomConsultOnBoot = Yap_FullLookupAtom("$consult_on_boot");
|
||||
AtomContext = Yap_LookupAtom("context");
|
||||
AtomCputime = Yap_LookupAtom("cputime");
|
||||
@ -133,6 +138,7 @@
|
||||
AtomFail = Yap_LookupAtom("fail");
|
||||
AtomFalse = Yap_LookupAtom("false");
|
||||
AtomFast = Yap_FullLookupAtom("$fast");
|
||||
AtomFastFail = Yap_LookupAtom("fast_fail");
|
||||
AtomFileErrors = Yap_LookupAtom("file_errors");
|
||||
AtomFileerrors = Yap_LookupAtom("fileerrors");
|
||||
AtomFileType = Yap_LookupAtom("file_type");
|
||||
@ -288,6 +294,7 @@
|
||||
AtomReadOnly = Yap_LookupAtom("read_only");
|
||||
AtomReadWrite = Yap_LookupAtom("read_write");
|
||||
AtomReadutil = Yap_LookupAtom("readutil");
|
||||
AtomReconsult = Yap_LookupAtom("reconsult");
|
||||
AtomRecordedP = Yap_FullLookupAtom("$recordep");
|
||||
AtomRecordedWithKey = Yap_FullLookupAtom("$recorded_with_key");
|
||||
AtomRedefineWarnings = Yap_LookupAtom("redefine_warnings");
|
||||
|
@ -141,4 +141,6 @@ static void InitGlobal(void) {
|
||||
GLOBAL_CharConversionTable2 = NULL;
|
||||
|
||||
GLOBAL_LastWTimePtr = NULL;
|
||||
|
||||
GLOBAL_MaxPriority = 1200;
|
||||
}
|
||||
|
@ -101,6 +101,7 @@
|
||||
SWI_MODULE = MkAtomTerm(AtomSwi);
|
||||
DBLOAD_MODULE = MkAtomTerm(AtomDBLoad);
|
||||
RANGE_MODULE = MkAtomTerm(AtomRange);
|
||||
ERROR_MODULE = MkAtomTerm(AtomError);
|
||||
|
||||
|
||||
|
||||
@ -207,9 +208,6 @@
|
||||
|
||||
PROFILING = FALSE;
|
||||
CALL_COUNTING = FALSE;
|
||||
PRED_GOAL_EXPANSION_ALL = FALSE;
|
||||
PRED_GOAL_EXPANSION_FUNC = FALSE;
|
||||
PRED_GOAL_EXPANSION_ON = FALSE;
|
||||
optimizer_on = TRUE;
|
||||
compile_mode = 0;
|
||||
profiling = FALSE;
|
||||
|
@ -252,7 +252,6 @@ static void InitWorker(int wid) {
|
||||
REMOTE_ImportDBRefHashTableSize(wid) = 0;
|
||||
REMOTE_ImportDBRefHashTableNum(wid) = 0;
|
||||
REMOTE_ImportFAILCODE(wid) = NULL;
|
||||
REMOTE_FunctorVar(wid) = FunctorVar;
|
||||
#if __ANDROID__
|
||||
|
||||
REMOTE_assetManager(wid) = GLOBAL_assetManager;
|
||||
|
@ -25,6 +25,10 @@
|
||||
AtomEmptyBrackets = AtomAdjust(AtomEmptyBrackets);
|
||||
AtomEmptySquareBrackets = AtomAdjust(AtomEmptySquareBrackets);
|
||||
AtomEmptyCurlyBrackets = AtomAdjust(AtomEmptyCurlyBrackets);
|
||||
AtomAsserta = AtomAdjust(AtomAsserta);
|
||||
AtomAssertaStatic = AtomAdjust(AtomAssertaStatic);
|
||||
AtomAssertz = AtomAdjust(AtomAssertz);
|
||||
AtomAssertzStatic = AtomAdjust(AtomAssertzStatic);
|
||||
AtomAt = AtomAdjust(AtomAt);
|
||||
AtomAtom = AtomAdjust(AtomAtom);
|
||||
AtomAtomic = AtomAdjust(AtomAtomic);
|
||||
@ -66,6 +70,7 @@
|
||||
AtomCompact = AtomAdjust(AtomCompact);
|
||||
AtomCompound = AtomAdjust(AtomCompound);
|
||||
AtomConsistencyError = AtomAdjust(AtomConsistencyError);
|
||||
AtomConsult = AtomAdjust(AtomConsult);
|
||||
AtomConsultOnBoot = AtomAdjust(AtomConsultOnBoot);
|
||||
AtomContext = AtomAdjust(AtomContext);
|
||||
AtomCputime = AtomAdjust(AtomCputime);
|
||||
@ -289,6 +294,7 @@
|
||||
AtomReadOnly = AtomAdjust(AtomReadOnly);
|
||||
AtomReadWrite = AtomAdjust(AtomReadWrite);
|
||||
AtomReadutil = AtomAdjust(AtomReadutil);
|
||||
AtomReconsult = AtomAdjust(AtomReconsult);
|
||||
AtomRecordedP = AtomAdjust(AtomRecordedP);
|
||||
AtomRecordedWithKey = AtomAdjust(AtomRecordedWithKey);
|
||||
AtomRedefineWarnings = AtomAdjust(AtomRedefineWarnings);
|
||||
|
@ -141,4 +141,6 @@ static void RestoreGlobal(void) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -101,6 +101,7 @@
|
||||
SWI_MODULE = AtomTermAdjust(SWI_MODULE);
|
||||
DBLOAD_MODULE = AtomTermAdjust(DBLOAD_MODULE);
|
||||
RANGE_MODULE = AtomTermAdjust(RANGE_MODULE);
|
||||
ERROR_MODULE = AtomTermAdjust(ERROR_MODULE);
|
||||
|
||||
|
||||
|
||||
@ -214,9 +215,6 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
REINIT_LOCK(DBTermsListLock);
|
||||
#endif
|
||||
|
@ -250,7 +250,6 @@ static void RestoreWorker(int wid USES_REGS) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if __ANDROID__
|
||||
|
21
H/tatoms.h
21
H/tatoms.h
@ -71,6 +71,18 @@
|
||||
Atom AtomEmptyCurlyBrackets_;
|
||||
#define AtomEmptyCurlyBrackets Yap_heap_regs->AtomEmptyCurlyBrackets_
|
||||
#define TermEmptyCurlyBrackets MkAtomTerm( Yap_heap_regs->AtomEmptyCurlyBrackets_ )
|
||||
Atom AtomAsserta_;
|
||||
#define AtomAsserta Yap_heap_regs->AtomAsserta_
|
||||
#define TermAsserta MkAtomTerm( Yap_heap_regs->AtomAsserta_ )
|
||||
Atom AtomAssertaStatic_;
|
||||
#define AtomAssertaStatic Yap_heap_regs->AtomAssertaStatic_
|
||||
#define TermAssertaStatic MkAtomTerm( Yap_heap_regs->AtomAssertaStatic_ )
|
||||
Atom AtomAssertz_;
|
||||
#define AtomAssertz Yap_heap_regs->AtomAssertz_
|
||||
#define TermAssertz MkAtomTerm( Yap_heap_regs->AtomAssertz_ )
|
||||
Atom AtomAssertzStatic_;
|
||||
#define AtomAssertzStatic Yap_heap_regs->AtomAssertzStatic_
|
||||
#define TermAssertzStatic MkAtomTerm( Yap_heap_regs->AtomAssertzStatic_ )
|
||||
Atom AtomAt_;
|
||||
#define AtomAt Yap_heap_regs->AtomAt_
|
||||
#define TermAt MkAtomTerm( Yap_heap_regs->AtomAt_ )
|
||||
@ -194,6 +206,9 @@
|
||||
Atom AtomConsistencyError_;
|
||||
#define AtomConsistencyError Yap_heap_regs->AtomConsistencyError_
|
||||
#define TermConsistencyError MkAtomTerm( Yap_heap_regs->AtomConsistencyError_ )
|
||||
Atom AtomConsult_;
|
||||
#define AtomConsult Yap_heap_regs->AtomConsult_
|
||||
#define TermConsult MkAtomTerm( Yap_heap_regs->AtomConsult_ )
|
||||
Atom AtomConsultOnBoot_;
|
||||
#define AtomConsultOnBoot Yap_heap_regs->AtomConsultOnBoot_
|
||||
#define TermConsultOnBoot MkAtomTerm( Yap_heap_regs->AtomConsultOnBoot_ )
|
||||
@ -395,6 +410,9 @@
|
||||
Atom AtomFast_;
|
||||
#define AtomFast Yap_heap_regs->AtomFast_
|
||||
#define TermFast MkAtomTerm( Yap_heap_regs->AtomFast_ )
|
||||
Atom AtomFastFail_;
|
||||
#define AtomFastFail Yap_heap_regs->AtomFastFail_
|
||||
#define TermFastFail MkAtomTerm( Yap_heap_regs->AtomFastFail_ )
|
||||
Atom AtomFileErrors_;
|
||||
#define AtomFileErrors Yap_heap_regs->AtomFileErrors_
|
||||
#define TermFileErrors MkAtomTerm( Yap_heap_regs->AtomFileErrors_ )
|
||||
@ -860,6 +878,9 @@
|
||||
Atom AtomReadutil_;
|
||||
#define AtomReadutil Yap_heap_regs->AtomReadutil_
|
||||
#define TermReadutil MkAtomTerm( Yap_heap_regs->AtomReadutil_ )
|
||||
Atom AtomReconsult_;
|
||||
#define AtomReconsult Yap_heap_regs->AtomReconsult_
|
||||
#define TermReconsult MkAtomTerm( Yap_heap_regs->AtomReconsult_ )
|
||||
Atom AtomRecordedP_;
|
||||
#define AtomRecordedP Yap_heap_regs->AtomRecordedP_
|
||||
#define TermRecordedP MkAtomTerm( Yap_heap_regs->AtomRecordedP_ )
|
||||
|
@ -1,23 +1,11 @@
|
||||
SET (CODES
|
||||
web/bootstrap/doxy-boot.js
|
||||
web/bootstrap/footer.html
|
||||
web/bootstrap/header.html
|
||||
web/bootstrap/customdoxygen.css
|
||||
offcanvas.css
|
||||
offcanvas.js
|
||||
solarized-light.css
|
||||
theme.css
|
||||
yap.css
|
||||
bootstrap.min.css
|
||||
bootstrap.min.js
|
||||
font-awesome.min.css
|
||||
jquery-2.0.3.min.js
|
||||
application.js
|
||||
pygments.css
|
||||
misc/icons/yap_64x64x32.png
|
||||
misc/icons/yap_256x256x32.png
|
||||
misc/icons/yap_128x128x32.png
|
||||
misc/icons/yap_48x48x32.png
|
||||
icons/yap_64x64x32.png
|
||||
icons/yap_256x256x32.png
|
||||
icons/yap_128x128x32.png
|
||||
icons/yap_48x48x32.png
|
||||
)
|
||||
|
||||
SET (DOCS
|
||||
|
@ -51,7 +51,7 @@ PROJECT_BRIEF = "The YAP Prolog Compiler Manual"
|
||||
# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
|
||||
# the logo to the output directory.
|
||||
|
||||
PROJECT_LOGO = @CMAKE_SOURCE_DIR@/misc/icons/yap_96x96x32.png
|
||||
PROJECT_LOGO = @CMAKE_SOURCE_DIR@/docs/icons/yap_96x96x32.png
|
||||
|
||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
|
||||
# into which the generated documentation will be written. If a relative path is
|
||||
@ -384,7 +384,7 @@ INLINE_GROUPED_CLASSES = NO
|
||||
# with only public data fields or simple typedef fields will be shown inline in
|
||||
# the documentation of the scope in which they are defined (i.e. file,
|
||||
# namespace, or group documentation), provided this scope is documented. If set
|
||||
# to NO, structs, classes, and unions are shown on a separate page (for HTML and
|
||||
v# to NO, structs, classes, and unions are shown on a separate page (for HTML and
|
||||
# Man pages) or section (for LaTeX and RTF).
|
||||
# The default value is: NO.
|
||||
|
||||
@ -728,7 +728,7 @@ WARNINGS = YES
|
||||
|
||||
# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate
|
||||
# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag
|
||||
# will automatically be disabled.
|
||||
# will automatically be disabled.
|
||||
# The default value is: YES.
|
||||
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
@ -776,15 +776,15 @@ WARN_LOGFILE =
|
||||
# Note: If this tag is empty the current directory is searched.
|
||||
|
||||
INPUT = @PROJECT_SOURCE_DIR@/pl \
|
||||
@PROJECT_SOURCE_DIR@/swi \
|
||||
@PROJECT_SOURCE_DIR@/CXX \
|
||||
@PROJECT_SOURCE_DIR@/OPTYap \
|
||||
@PROJECT_SOURCE_DIR@/C \
|
||||
@PROJECT_SOURCE_DIR@/H \
|
||||
@PROJECT_SOURCE_DIR@/include \
|
||||
@PROJECT_SOURCE_DIR@/os \
|
||||
@PROJECT_SOURCE_DIR@/packages \
|
||||
@PROJECT_SOURCE_DIR@/library \
|
||||
@PROJECT_SOURCE_DIR@/packages \
|
||||
@PROJECT_SOURCE_DIR@/swi/library \
|
||||
@PROJECT_SOURCE_DIR@/docs/yap.md \
|
||||
@PROJECT_SOURCE_DIR@/docs/chr.md \
|
||||
@PROJECT_SOURCE_DIR@/docs/clpqr.md \
|
||||
@ -828,7 +828,7 @@ RECURSIVE = YES
|
||||
# Note that relative paths are relative to the directory from which doxygen is
|
||||
# run.
|
||||
|
||||
EXCLUDE = *pltotex.pl packages/swig/android packages/chr packages/RDF packages/pyswip
|
||||
EXCLUDE = *pltotex.pl
|
||||
|
||||
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
|
||||
# directories that are symbolic links (a Unix file system feature) are excluded
|
||||
@ -844,7 +844,7 @@ EXCLUDE_SYMLINKS = NO
|
||||
# Note that the wildcards are matched against the file with absolute path, so to
|
||||
# exclude all test directories for example use the pattern */test/*
|
||||
|
||||
EXCLUDE_PATTERNS =
|
||||
EXCLUDE_PATTERNS = */CMakeFiles/* *~
|
||||
|
||||
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
|
||||
# (namespaces, classes, functions, etc.) that should be excluded from the
|
||||
@ -881,7 +881,7 @@ EXAMPLE_RECURSIVE = NO
|
||||
# that contain images that are to be included in the documentation (see the
|
||||
# \image command).
|
||||
|
||||
IMAGE_PATH = @CMAKE_SOURCE_DIR@/misc/icons
|
||||
IMAGE_PATH = @CMAKE_SOURCE_DIR@/docs/icons
|
||||
|
||||
# The INPUT_FILTER tag can be used to specify a program that doxygen should
|
||||
# invoke to filter for each input file. Doxygen will invoke the filter program
|
||||
@ -1105,7 +1105,7 @@ HTML_HEADER =
|
||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||
|
||||
HTML_FOOTER =
|
||||
@CMAKE_SOURCE_DIR@/docs/web/bootstrap/footer.html
|
||||
#@CMAKE_SOURCE_DIR@/docs/web/bootstrap/footer.html
|
||||
|
||||
# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style
|
||||
# sheet that is used by each HTML page. It can be used to fine-tune the look of
|
||||
|
4
docs/application.js
Normal file
4
docs/application.js
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
$(function () {
|
||||
$('a').tooltip();
|
||||
});
|
7
docs/bootstrap.min.css
vendored
Normal file
7
docs/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
7
docs/bootstrap.min.js
vendored
Normal file
7
docs/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
0
docs/builtins.md
Normal file
0
docs/builtins.md
Normal file
32
docs/chr.md
32
docs/chr.md
@ -2,6 +2,8 @@
|
||||
CHR: Constraint Handling Rules {#chr}
|
||||
==============================
|
||||
|
||||
@ingroup packages
|
||||
|
||||
This chapter is written by Tom Schrijvers, K.U. Leuven for the hProlog
|
||||
system. Adjusted by Jan Wielemaker to fit the SWI-Prolog documentation
|
||||
infrastructure and remove hProlog specific references.
|
||||
@ -59,7 +61,7 @@ actual_rule --> simpagation_rule.
|
||||
|
||||
simplification_rule --> constraints, [atom(`<=>`)], guard, body.
|
||||
propagation_rule --> constraints, [atom(`==>`)], guard, body.
|
||||
simpagation_rule --> constraints, [atom(`\`)], constraints, [atom(`<=>`)],
|
||||
simpagation_rule --> constraints, [atom(`\`)], constraints, [atom(`<=>`)],
|
||||
guard, body.
|
||||
|
||||
constraints --> constraint, constraint_id.
|
||||
@ -98,7 +100,7 @@ informally. They do not differ essentially from other CHR systems.
|
||||
|
||||
When a constraint is called, it is considered an active constraint and
|
||||
the system will try to apply the rules to it. Rules are tried and executed
|
||||
sequentially in the order they are written.
|
||||
sequentially in the order they are written.
|
||||
|
||||
A rule is conceptually tried for an active constraint in the following
|
||||
way. The active constraint is matched with a constraint in the head of
|
||||
@ -140,7 +142,7 @@ its head.
|
||||
The simpagation rule removes the constraints in its head after the
|
||||
`\` and then calls its body. It is an optimization of
|
||||
simplification rules of the form: \[constraints_1, constraints_2 <=>
|
||||
constraints_1, body \] Namely, in the simpagation form:
|
||||
constraints_1, body \] Namely, in the simpagation form:
|
||||
|
||||
~~~~~
|
||||
constraints1 \ constraints2 <=> body
|
||||
@ -186,7 +188,7 @@ checks.
|
||||
+ optimize
|
||||
This is an experimental option controlling the degree of optimization.
|
||||
Possible values are `full`, to enable all available
|
||||
optimizations, and `off` (default), to disable all optimizations.
|
||||
optimizations, and `off` (default), to disable all optimizations.
|
||||
The default is derived from the SWI-Prolog flag `optimise`, where
|
||||
`true` is mapped to `full`. Therefore the commandline
|
||||
option `-O` provides full CHR optimization.
|
||||
@ -209,7 +211,7 @@ The latter is the default. The meaning is the following:
|
||||
+ -
|
||||
The corresponding argument of every occurrence
|
||||
of the constraint is always unbound.
|
||||
+ +
|
||||
+ +
|
||||
The corresponding argument of every occurrence
|
||||
of the constraint is always ground.
|
||||
+ ?
|
||||
@ -217,7 +219,7 @@ The corresponding argument of every occurrence
|
||||
of the constraint can have any instantiation, which may change
|
||||
over time. This is the default value.
|
||||
|
||||
The declaration is used by the compiler for various optimizations.
|
||||
The declaration is used by the compiler for various optimizations.
|
||||
Note that it is up to the user the ensure that the mode declaration
|
||||
is correct with respect to the use of the constraint.
|
||||
This option may occur once for each constraint.
|
||||
@ -251,7 +253,7 @@ type declarations. The value is a term of the form
|
||||
`type(` _name_`,` _list_`)`, where
|
||||
_name_ is a term and _list_ is a list of alternatives.
|
||||
Variables can be used to define generic types. Recursive definitions
|
||||
are allowed. Examples are
|
||||
are allowed. Examples are
|
||||
|
||||
~~~~~
|
||||
type(bool,[true,false]).
|
||||
@ -266,8 +268,8 @@ The mode, type_declaration and type_definition options are provided
|
||||
for backward compatibility. The new syntax is described below.
|
||||
|
||||
|
||||
|
||||
### CHR in Prolog Programs
|
||||
|
||||
### CHR in Prolog Programs
|
||||
|
||||
|
||||
The CHR constraints defined in a particulary chr file are
|
||||
@ -295,7 +297,7 @@ The new style is as follows:
|
||||
:- chr_type list(T) ---> [] ; [T|list(T)].
|
||||
:- constraints foo(+list(int),?float), bar.
|
||||
~~~~~
|
||||
|
||||
|
||||
|
||||
|
||||
#### Compilation
|
||||
@ -327,7 +329,7 @@ pl files and the operator definitions required by CHR do not
|
||||
leak into modules where they might cause conflicts.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### CHR Debugging
|
||||
@ -433,8 +435,8 @@ notrace/0.
|
||||
|
||||
Here are two example constraint solvers written in CHR.
|
||||
|
||||
+
|
||||
The program below defines a solver with one constraint,
|
||||
+
|
||||
The program below defines a solver with one constraint,
|
||||
`leq/2`, which is a less-than-or-equal constraint.
|
||||
|
||||
~~~~~
|
||||
@ -453,7 +455,7 @@ cycle(X,Y,Z):-
|
||||
leq(Z,X).
|
||||
~~~~~
|
||||
|
||||
+
|
||||
+
|
||||
The program below implements a simple finite domain
|
||||
constraint solver.
|
||||
|
||||
@ -461,7 +463,7 @@ constraint solver.
|
||||
:- module(dom,[dom/2]).
|
||||
:- use_module(library(chr)).
|
||||
|
||||
:- constraints dom/2.
|
||||
:- constraints dom/2.
|
||||
|
||||
dom(X,[]) <=> fail.
|
||||
dom(X,[Y]) <=> X = Y.
|
||||
|
@ -1,6 +1,7 @@
|
||||
Constraint Logic Programming over Rationals and Reals {#clpqr}
|
||||
=====================================================
|
||||
|
||||
@ingroup paackages
|
||||
|
||||
YAP now uses the CLP(R) package developed by <em>Leslie De Koninck</em>,
|
||||
K.U. Leuven as part of a thesis with supervisor Bart Demoen and daily
|
||||
@ -27,7 +28,7 @@ explicitely before using it:
|
||||
|
||||
The following predicates are provided to work with constraints:
|
||||
|
||||
|
||||
|
||||
### Syntax of the predicate arguments {#CLPQR_Syntax}
|
||||
|
||||
|
||||
@ -103,19 +104,19 @@ They are given in the following table.
|
||||
A = B * C when B or C is ground or // A = 5 * C or A = B * 4 \\
|
||||
A and (B or C) are ground // 20 = 5 * C or 20 = B * 4 \\
|
||||
|
||||
A = B / C when C is ground or // A = B / 3
|
||||
A and B are ground // 4 = 12 / C
|
||||
A = B / C when C is ground or // A = B / 3
|
||||
A and B are ground // 4 = 12 / C
|
||||
|
||||
X = min(Y,Z) when Y and Z are ground or // X = min(4,3)
|
||||
X = max(Y,Z) Y and Z are ground // X = max(4,3)
|
||||
X = abs(Y) Y is ground // X = abs(-7)
|
||||
X = min(Y,Z) when Y and Z are ground or // X = min(4,3)
|
||||
X = max(Y,Z) Y and Z are ground // X = max(4,3)
|
||||
X = abs(Y) Y is ground // X = abs(-7)
|
||||
|
||||
X = pow(Y,Z) when X and Y are ground or // 8 = 2 ^ Z
|
||||
X = exp(Y,Z) X and Z are ground // 8 = Y ^ 3
|
||||
X = Y ^ Z Y and Z are ground // X = 2 ^ 3
|
||||
X = pow(Y,Z) when X and Y are ground or // 8 = 2 ^ Z
|
||||
X = exp(Y,Z) X and Z are ground // 8 = Y ^ 3
|
||||
X = Y ^ Z Y and Z are ground // X = 2 ^ 3
|
||||
|
||||
X = sin(Y) when X is ground or // 1 = sin(Y)
|
||||
X = cos(Y) Y is ground // X = sin(1.5707)
|
||||
X = sin(Y) when X is ground or // 1 = sin(Y)
|
||||
X = cos(Y) Y is ground // X = sin(1.5707)
|
||||
X = tan(Y)
|
||||
~~~~~
|
||||
|
||||
|
0
docs/download.md
Normal file
0
docs/download.md
Normal file
121
docs/doxy-boot.js
Normal file
121
docs/doxy-boot.js
Normal file
@ -0,0 +1,121 @@
|
||||
$( document ).ready(function() {
|
||||
|
||||
$("div.headertitle").addClass("page-header");
|
||||
$("div.title").addClass("h1");
|
||||
|
||||
$('li > a[href="index.html"] > span').before("<i class='fa fa-cog'></i> ");
|
||||
$('li > a[href="index.html"] > span').text("BioGears");
|
||||
$('li > a[href="modules.html"] > span').before("<i class='fa fa-square'></i> ");
|
||||
$('li > a[href="namespaces.html"] > span').before("<i class='fa fa-bars'></i> ");
|
||||
$('li > a[href="annotated.html"] > span').before("<i class='fa fa-list-ul'></i> ");
|
||||
$('li > a[href="classes.html"] > span').before("<i class='fa fa-book'></i> ");
|
||||
$('li > a[href="inherits.html"] > span').before("<i class='fa fa-sitemap'></i> ");
|
||||
$('li > a[href="functions.html"] > span').before("<i class='fa fa-list'></i> ");
|
||||
$('li > a[href="functions_func.html"] > span').before("<i class='fa fa-list'></i> ");
|
||||
$('li > a[href="functions_vars.html"] > span').before("<i class='fa fa-list'></i> ");
|
||||
$('li > a[href="functions_enum.html"] > span').before("<i class='fa fa-list'></i> ");
|
||||
$('li > a[href="functions_eval.html"] > span').before("<i class='fa fa-list'></i> ");
|
||||
$('img[src="ftv2ns.png"]').replaceWith('<span class="label label-danger">N</span> ');
|
||||
$('img[src="ftv2cl.png"]').replaceWith('<span class="label label-danger">C</span> ');
|
||||
|
||||
$("ul.tablist").addClass("nav nav-pills nav-justified");
|
||||
$("ul.tablist").css("margin-top", "0.5em");
|
||||
$("ul.tablist").css("margin-bottom", "0.5em");
|
||||
$("li.current").addClass("active");
|
||||
$("iframe").attr("scrolling", "yes");
|
||||
|
||||
$("#nav-path > ul").addClass("breadcrumb");
|
||||
|
||||
$("table.params").addClass("table");
|
||||
$("div.ingroups").wrapInner("<small></small>");
|
||||
$("div.levels").css("margin", "0.5em");
|
||||
$("div.levels > span").addClass("btn btn-default btn-xs");
|
||||
$("div.levels > span").css("margin-right", "0.25em");
|
||||
|
||||
$("table.directory").addClass("table table-striped");
|
||||
$("div.summary > a").addClass("btn btn-default btn-xs");
|
||||
$("table.fieldtable").addClass("table");
|
||||
$(".fragment").addClass("well");
|
||||
$(".memitem").addClass("panel panel-default");
|
||||
$(".memproto").addClass("panel-heading");
|
||||
$(".memdoc").addClass("panel-body");
|
||||
$("span.mlabel").addClass("label label-info");
|
||||
|
||||
$("table.memberdecls").addClass("table");
|
||||
$("[class^=memitem]").addClass("active");
|
||||
|
||||
$("div.ah").addClass("btn btn-default");
|
||||
$("span.mlabels").addClass("pull-right");
|
||||
$("table.mlabels").css("width", "100%")
|
||||
$("td.mlabels-right").addClass("pull-right");
|
||||
|
||||
$("div.ttc").addClass("panel panel-primary");
|
||||
$("div.ttname").addClass("panel-heading");
|
||||
$("div.ttname a").css("color", 'white');
|
||||
$("div.ttdef,div.ttdoc,div.ttdeci").addClass("panel-body");
|
||||
|
||||
$('#MSearchBox').parent().remove();
|
||||
|
||||
$('div.fragment.well div.line:first').css('margin-top', '15px');
|
||||
$('div.fragment.well div.line:last').css('margin-bottom', '15px');
|
||||
|
||||
$('table.doxtable').removeClass('doxtable').addClass('table table-striped table-bordered').each(function(){
|
||||
$(this).prepend('<thead></thead>');
|
||||
$(this).find('tbody > tr:first').prependTo($(this).find('thead'));
|
||||
|
||||
$(this).find('td > span.success').parent().addClass('success');
|
||||
$(this).find('td > span.warning').parent().addClass('warning');
|
||||
$(this).find('td > span.danger').parent().addClass('danger');
|
||||
});
|
||||
|
||||
|
||||
|
||||
if($('div.fragment.well div.ttc').length > 0)
|
||||
{
|
||||
$('div.fragment.well div.line:first').parent().removeClass('fragment well');
|
||||
}
|
||||
|
||||
$('table.memberdecls').find('.memItemRight').each(function(){
|
||||
$(this).contents().appendTo($(this).siblings('.memItemLeft'));
|
||||
$(this).siblings('.memItemLeft').attr('align', 'left');
|
||||
});
|
||||
|
||||
function getOriginalWidthOfImg(img_element) {
|
||||
var t = new Image();
|
||||
t.src = (img_element.getAttribute ? img_element.getAttribute("src") : false) || img_element.src;
|
||||
return t.width;
|
||||
}
|
||||
|
||||
$('div.dyncontent').find('img').each(function(){
|
||||
if(getOriginalWidthOfImg($(this)[0]) > $('#content>div.container').width())
|
||||
$(this).css('width', '100%');
|
||||
});
|
||||
|
||||
$(".memitem").removeClass('memitem');
|
||||
$(".memproto").removeClass('memproto');
|
||||
$(".memdoc").removeClass('memdoc');
|
||||
$("span.mlabel").removeClass('mlabel');
|
||||
$("table.memberdecls").removeClass('memberdecls');
|
||||
$("[class^=memitem]").removeClass('memitem');
|
||||
$("span.mlabels").removeClass('mlabels');
|
||||
$("table.mlabels").removeClass('mlabels');
|
||||
$("td.mlabels-right").removeClass('mlabels-right');
|
||||
$(".navpath").removeClass('navpath');
|
||||
$("li.navelem").removeClass('navelem');
|
||||
$("a.el").removeClass('el');
|
||||
$("div.ah").removeClass('ah');
|
||||
$("div.header").removeClass("header");
|
||||
|
||||
$('.mdescLeft').each(function(){
|
||||
if($(this).html()==" ") {
|
||||
$(this).siblings('.mdescRight').attr('colspan', 2);
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
$('td.memItemLeft').each(function(){
|
||||
if($(this).siblings('.memItemRight').html()=="") {
|
||||
$(this).attr('colspan', 2);
|
||||
$(this).siblings('.memItemRight').remove();
|
||||
}
|
||||
});
|
||||
});
|
0
docs/extensions.md
Normal file
0
docs/extensions.md
Normal file
0
docs/fli.md
Normal file
0
docs/fli.md
Normal file
4
docs/font-awesome.min.css
vendored
Normal file
4
docs/font-awesome.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
0
docs/install.md
Normal file
0
docs/install.md
Normal file
6
docs/jquery-2.0.3.min.js
vendored
Normal file
6
docs/jquery-2.0.3.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
59
docs/offcanvas.css
Normal file
59
docs/offcanvas.css
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Style tweaks
|
||||
* --------------------------------------------------
|
||||
*/
|
||||
html,
|
||||
body {
|
||||
overflow-x: hidden; /* Prevent scroll on narrow devices */
|
||||
}
|
||||
body {
|
||||
padding-top: 70px;
|
||||
}
|
||||
footer {
|
||||
padding: 30px 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Off Canvas
|
||||
* --------------------------------------------------
|
||||
*/
|
||||
@media screen and (max-width: 767px) {
|
||||
.row-offcanvas {
|
||||
position: relative;
|
||||
-webkit-transition: all .25s ease-out;
|
||||
-o-transition: all .25s ease-out;
|
||||
transition: all .25s ease-out;
|
||||
}
|
||||
|
||||
.row-offcanvas-right {
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.row-offcanvas-left {
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.row-offcanvas-right
|
||||
.sidebar-offcanvas {
|
||||
right: -50%; /* 6 columns */
|
||||
}
|
||||
|
||||
.row-offcanvas-left
|
||||
.sidebar-offcanvas {
|
||||
left: -50%; /* 6 columns */
|
||||
}
|
||||
|
||||
.row-offcanvas-right.active {
|
||||
right: 50%; /* 6 columns */
|
||||
}
|
||||
|
||||
.row-offcanvas-left.active {
|
||||
left: 50%; /* 6 columns */
|
||||
}
|
||||
|
||||
.sidebar-offcanvas {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
width: 50%; /* 6 columns */
|
||||
}
|
||||
}
|
5
docs/offcanvas.js
Normal file
5
docs/offcanvas.js
Normal file
@ -0,0 +1,5 @@
|
||||
$(document).ready(function () {
|
||||
$('[data-toggle="offcanvas"]').click(function () {
|
||||
$('.row-offcanvas').toggleClass('active')
|
||||
});
|
||||
});
|
62
docs/pygments.css
Normal file
62
docs/pygments.css
Normal file
@ -0,0 +1,62 @@
|
||||
.hll { background-color: #ffffcc }
|
||||
.c { color: #0099FF; font-style: italic } /* Comment */
|
||||
.err { color: #AA0000; background-color: #FFAAAA } /* Error */
|
||||
.k { color: #006699; font-weight: bold } /* Keyword */
|
||||
.o { color: #555555 } /* Operator */
|
||||
.cm { color: #0099FF; font-style: italic } /* Comment.Multiline */
|
||||
.cp { color: #009999 } /* Comment.Preproc */
|
||||
.c1 { color: #0099FF; font-style: italic } /* Comment.Single */
|
||||
.cs { color: #0099FF; font-weight: bold; font-style: italic } /* Comment.Special */
|
||||
.gd { background-color: #FFCCCC; border: 1px solid #CC0000 } /* Generic.Deleted */
|
||||
.ge { font-style: italic } /* Generic.Emph */
|
||||
.gr { color: #FF0000 } /* Generic.Error */
|
||||
.gh { color: #003300; font-weight: bold } /* Generic.Heading */
|
||||
.gi { background-color: #CCFFCC; border: 1px solid #00CC00 } /* Generic.Inserted */
|
||||
.go { color: #AAAAAA } /* Generic.Output */
|
||||
.gp { color: #000099; font-weight: bold } /* Generic.Prompt */
|
||||
.gs { font-weight: bold } /* Generic.Strong */
|
||||
.gu { color: #003300; font-weight: bold } /* Generic.Subheading */
|
||||
.gt { color: #99CC66 } /* Generic.Traceback */
|
||||
.kc { color: #006699; font-weight: bold } /* Keyword.Constant */
|
||||
.kd { color: #006699; font-weight: bold } /* Keyword.Declaration */
|
||||
.kn { color: #006699; font-weight: bold } /* Keyword.Namespace */
|
||||
.kp { color: #006699 } /* Keyword.Pseudo */
|
||||
.kr { color: #006699; font-weight: bold } /* Keyword.Reserved */
|
||||
.kt { color: #007788; font-weight: bold } /* Keyword.Type */
|
||||
.m { color: #FF6600 } /* Literal.Number */
|
||||
.s { color: #CC3300 } /* Literal.String */
|
||||
.na { color: #330099 } /* Name.Attribute */
|
||||
.nb { color: #336666 } /* Name.Builtin */
|
||||
.nc { color: #00AA88; font-weight: bold } /* Name.Class */
|
||||
.no { color: #336600 } /* Name.Constant */
|
||||
.nd { color: #9999FF } /* Name.Decorator */
|
||||
.ni { color: #999999; font-weight: bold } /* Name.Entity */
|
||||
.ne { color: #CC0000; font-weight: bold } /* Name.Exception */
|
||||
.nf { color: #CC00FF } /* Name.Function */
|
||||
.nl { color: #9999FF } /* Name.Label */
|
||||
.nn { color: #00CCFF; font-weight: bold } /* Name.Namespace */
|
||||
.nt { color: #330099; font-weight: bold } /* Name.Tag */
|
||||
.nv { color: #003333 } /* Name.Variable */
|
||||
.ow { color: #000000; font-weight: bold } /* Operator.Word */
|
||||
.w { color: #bbbbbb } /* Text.Whitespace */
|
||||
.mb { color: #FF6600 } /* Literal.Number.Bin */
|
||||
.mf { color: #FF6600 } /* Literal.Number.Float */
|
||||
.mh { color: #FF6600 } /* Literal.Number.Hex */
|
||||
.mi { color: #FF6600 } /* Literal.Number.Integer */
|
||||
.mo { color: #FF6600 } /* Literal.Number.Oct */
|
||||
.sb { color: #CC3300 } /* Literal.String.Backtick */
|
||||
.sc { color: #CC3300 } /* Literal.String.Char */
|
||||
.sd { color: #CC3300; font-style: italic } /* Literal.String.Doc */
|
||||
.s2 { color: #CC3300 } /* Literal.String.Double */
|
||||
.se { color: #CC3300; font-weight: bold } /* Literal.String.Escape */
|
||||
.sh { color: #CC3300 } /* Literal.String.Heredoc */
|
||||
.si { color: #AA0000 } /* Literal.String.Interpol */
|
||||
.sx { color: #CC3300 } /* Literal.String.Other */
|
||||
.sr { color: #33AAAA } /* Literal.String.Regex */
|
||||
.s1 { color: #CC3300 } /* Literal.String.Single */
|
||||
.ss { color: #FFCC33 } /* Literal.String.Symbol */
|
||||
.bp { color: #336666 } /* Name.Builtin.Pseudo */
|
||||
.vc { color: #003333 } /* Name.Variable.Class */
|
||||
.vg { color: #003333 } /* Name.Variable.Global */
|
||||
.vi { color: #003333 } /* Name.Variable.Instance */
|
||||
.il { color: #FF6600 } /* Literal.Number.Integer.Long */
|
2399
docs/web/bootstrap/Doxyfile
Normal file
2399
docs/web/bootstrap/Doxyfile
Normal file
File diff suppressed because it is too large
Load Diff
202
docs/web/bootstrap/LICENSE
Normal file
202
docs/web/bootstrap/LICENSE
Normal file
@ -0,0 +1,202 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
16
docs/web/bootstrap/README.md
Normal file
16
docs/web/bootstrap/README.md
Normal file
@ -0,0 +1,16 @@
|
||||
# How to Integrate
|
||||
|
||||
This is easy to integrate into your own doxyfile. Simply tell your doxyfile to use these 3 files in the HTML section:
|
||||
|
||||
* HTML_HEADER=header.html
|
||||
* Adds a simple Bootstrap navbar for the title
|
||||
* Wraps the content in a Bootstrap container/row combo
|
||||
* HTML_FOOTER=footer.html
|
||||
* Simply closes the extra divs opened in the header.html
|
||||
* HTML_EXTRA_STYLESHEET=customdoxygen.css
|
||||
|
||||
You should also copy `doxy-boot.js` into your `html` directory, else it won't be found.
|
||||
|
||||
## Note
|
||||
|
||||
This hasn't been tested with the search box functionality or with the Doxygen sidebar.
|
255
docs/web/bootstrap/customdoxygen.css
Normal file
255
docs/web/bootstrap/customdoxygen.css
Normal file
@ -0,0 +1,255 @@
|
||||
h1, .h1, h2, .h2, h3, .h3{
|
||||
font-weight: 200 !important;
|
||||
}
|
||||
|
||||
#navrow1, #navrow2, #navrow3, #navrow4, #navrow5{
|
||||
border-bottom: 1px solid #EEEEEE;
|
||||
}
|
||||
|
||||
.adjust-right {
|
||||
margin-left: 30px !important;
|
||||
font-size: 1.15em !important;
|
||||
}
|
||||
.navbar{
|
||||
border: 0px solid #222 !important;
|
||||
}
|
||||
|
||||
|
||||
/* Sticky footer styles
|
||||
-------------------------------------------------- */
|
||||
html,
|
||||
body {
|
||||
height: 100%;
|
||||
/* The html and body elements cannot have any padding or margin. */
|
||||
}
|
||||
|
||||
/* Wrapper for page content to push down footer */
|
||||
#wrap {
|
||||
min-height: 100%;
|
||||
height: auto;
|
||||
/* Negative indent footer by its height */
|
||||
margin: 0 auto -60px;
|
||||
/* Pad bottom by footer height */
|
||||
padding: 0 0 60px;
|
||||
}
|
||||
|
||||
/* Set the fixed height of the footer here */
|
||||
#footer {
|
||||
font-size: 0.9em;
|
||||
padding: 8px 0px;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.footer-row {
|
||||
line-height: 44px;
|
||||
}
|
||||
|
||||
#footer > .container {
|
||||
padding-left: 15px;
|
||||
padding-right: 15px;
|
||||
}
|
||||
|
||||
.footer-follow-icon {
|
||||
margin-left: 3px;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
.footer-follow-icon img {
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
.footer-link {
|
||||
padding-top: 5px;
|
||||
display: inline-block;
|
||||
color: #999999;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.footer-copyright {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
@media (min-width: 992px) {
|
||||
.footer-row {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.footer-icons {
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
@media (max-width: 991px) {
|
||||
.footer-row {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.footer-icons {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
/* DOXYGEN Code Styles
|
||||
----------------------------------- */
|
||||
|
||||
|
||||
a.qindex {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
a.qindexHL {
|
||||
font-weight: bold;
|
||||
background-color: #9CAFD4;
|
||||
color: #ffffff;
|
||||
border: 1px double #869DCA;
|
||||
}
|
||||
|
||||
.contents a.qindexHL:visited {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
a.code, a.code:visited, a.line, a.line:visited {
|
||||
color: #4665A2;
|
||||
}
|
||||
|
||||
a.codeRef, a.codeRef:visited, a.lineRef, a.lineRef:visited {
|
||||
color: #4665A2;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
dl.el {
|
||||
margin-left: -1cm;
|
||||
}
|
||||
|
||||
pre.fragment {
|
||||
border: 1px solid #C4CFE5;
|
||||
background-color: #FBFCFD;
|
||||
padding: 4px 6px;
|
||||
margin: 4px 8px 4px 2px;
|
||||
overflow: auto;
|
||||
word-wrap: break-word;
|
||||
font-size: 9pt;
|
||||
line-height: 125%;
|
||||
font-family: monospace, fixed;
|
||||
font-size: 105%;
|
||||
}
|
||||
|
||||
div.fragment {
|
||||
padding: 4px 6px;
|
||||
margin: 4px 8px 4px 2px;
|
||||
border: 1px solid #C4CFE5;
|
||||
}
|
||||
|
||||
div.line {
|
||||
font-family: monospace, fixed;
|
||||
font-size: 13px;
|
||||
min-height: 13px;
|
||||
line-height: 1.0;
|
||||
text-wrap: unrestricted;
|
||||
white-space: -moz-pre-wrap; /* Moz */
|
||||
white-space: -pre-wrap; /* Opera 4-6 */
|
||||
white-space: -o-pre-wrap; /* Opera 7 */
|
||||
white-space: pre-wrap; /* CSS3 */
|
||||
word-wrap: break-word; /* IE 5.5+ */
|
||||
text-indent: -53px;
|
||||
padding-left: 53px;
|
||||
padding-bottom: 0px;
|
||||
margin: 0px;
|
||||
-webkit-transition-property: background-color, box-shadow;
|
||||
-webkit-transition-duration: 0.5s;
|
||||
-moz-transition-property: background-color, box-shadow;
|
||||
-moz-transition-duration: 0.5s;
|
||||
-ms-transition-property: background-color, box-shadow;
|
||||
-ms-transition-duration: 0.5s;
|
||||
-o-transition-property: background-color, box-shadow;
|
||||
-o-transition-duration: 0.5s;
|
||||
transition-property: background-color, box-shadow;
|
||||
transition-duration: 0.5s;
|
||||
}
|
||||
|
||||
div.line.glow {
|
||||
background-color: cyan;
|
||||
box-shadow: 0 0 10px cyan;
|
||||
}
|
||||
|
||||
|
||||
span.lineno {
|
||||
padding-right: 4px;
|
||||
text-align: right;
|
||||
border-right: 2px solid #0F0;
|
||||
background-color: #E8E8E8;
|
||||
white-space: pre;
|
||||
}
|
||||
span.lineno a {
|
||||
background-color: #D8D8D8;
|
||||
}
|
||||
|
||||
span.lineno a:hover {
|
||||
background-color: #C8C8C8;
|
||||
}
|
||||
|
||||
div.groupHeader {
|
||||
margin-left: 16px;
|
||||
margin-top: 12px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.groupText {
|
||||
margin-left: 16px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* @group Code Colorization */
|
||||
|
||||
span.keyword {
|
||||
color: #008000
|
||||
}
|
||||
|
||||
span.keywordtype {
|
||||
color: #604020
|
||||
}
|
||||
|
||||
span.keywordflow {
|
||||
color: #e08000
|
||||
}
|
||||
|
||||
span.comment {
|
||||
color: #800000
|
||||
}
|
||||
|
||||
span.preprocessor {
|
||||
color: #806020
|
||||
}
|
||||
|
||||
span.stringliteral {
|
||||
color: #002080
|
||||
}
|
||||
|
||||
span.charliteral {
|
||||
color: #008080
|
||||
}
|
||||
|
||||
span.vhdldigit {
|
||||
color: #ff00ff
|
||||
}
|
||||
|
||||
span.vhdlchar {
|
||||
color: #000000
|
||||
}
|
||||
|
||||
span.vhdlkeyword {
|
||||
color: #700070
|
||||
}
|
||||
|
||||
span.vhdllogic {
|
||||
color: #ff0000
|
||||
}
|
||||
|
||||
blockquote {
|
||||
background-color: #F7F8FB;
|
||||
border-left: 2px solid #9CAFD4;
|
||||
margin: 0 24px 0 4px;
|
||||
padding: 0 12px 0 16px;
|
||||
}
|
||||
|
121
docs/web/bootstrap/doxy-boot.js
Normal file
121
docs/web/bootstrap/doxy-boot.js
Normal file
@ -0,0 +1,121 @@
|
||||
$( document ).ready(function() {
|
||||
|
||||
$("div.headertitle").addClass("page-header");
|
||||
$("div.title").addClass("h1");
|
||||
|
||||
$('li > a[href="index.html"] > span').before("<i class='fa fa-cog'></i> ");
|
||||
$('li > a[href="index.html"] > span').text("BioGears");
|
||||
$('li > a[href="modules.html"] > span').before("<i class='fa fa-square'></i> ");
|
||||
$('li > a[href="namespaces.html"] > span').before("<i class='fa fa-bars'></i> ");
|
||||
$('li > a[href="annotated.html"] > span').before("<i class='fa fa-list-ul'></i> ");
|
||||
$('li > a[href="classes.html"] > span').before("<i class='fa fa-book'></i> ");
|
||||
$('li > a[href="inherits.html"] > span').before("<i class='fa fa-sitemap'></i> ");
|
||||
$('li > a[href="functions.html"] > span').before("<i class='fa fa-list'></i> ");
|
||||
$('li > a[href="functions_func.html"] > span').before("<i class='fa fa-list'></i> ");
|
||||
$('li > a[href="functions_vars.html"] > span').before("<i class='fa fa-list'></i> ");
|
||||
$('li > a[href="functions_enum.html"] > span').before("<i class='fa fa-list'></i> ");
|
||||
$('li > a[href="functions_eval.html"] > span').before("<i class='fa fa-list'></i> ");
|
||||
$('img[src="ftv2ns.png"]').replaceWith('<span class="label label-danger">N</span> ');
|
||||
$('img[src="ftv2cl.png"]').replaceWith('<span class="label label-danger">C</span> ');
|
||||
|
||||
$("ul.tablist").addClass("nav nav-pills nav-justified");
|
||||
$("ul.tablist").css("margin-top", "0.5em");
|
||||
$("ul.tablist").css("margin-bottom", "0.5em");
|
||||
$("li.current").addClass("active");
|
||||
$("iframe").attr("scrolling", "yes");
|
||||
|
||||
$("#nav-path > ul").addClass("breadcrumb");
|
||||
|
||||
$("table.params").addClass("table");
|
||||
$("div.ingroups").wrapInner("<small></small>");
|
||||
$("div.levels").css("margin", "0.5em");
|
||||
$("div.levels > span").addClass("btn btn-default btn-xs");
|
||||
$("div.levels > span").css("margin-right", "0.25em");
|
||||
|
||||
$("table.directory").addClass("table table-striped");
|
||||
$("div.summary > a").addClass("btn btn-default btn-xs");
|
||||
$("table.fieldtable").addClass("table");
|
||||
$(".fragment").addClass("well");
|
||||
$(".memitem").addClass("panel panel-default");
|
||||
$(".memproto").addClass("panel-heading");
|
||||
$(".memdoc").addClass("panel-body");
|
||||
$("span.mlabel").addClass("label label-info");
|
||||
|
||||
$("table.memberdecls").addClass("table");
|
||||
$("[class^=memitem]").addClass("active");
|
||||
|
||||
$("div.ah").addClass("btn btn-default");
|
||||
$("span.mlabels").addClass("pull-right");
|
||||
$("table.mlabels").css("width", "100%")
|
||||
$("td.mlabels-right").addClass("pull-right");
|
||||
|
||||
$("div.ttc").addClass("panel panel-primary");
|
||||
$("div.ttname").addClass("panel-heading");
|
||||
$("div.ttname a").css("color", 'white');
|
||||
$("div.ttdef,div.ttdoc,div.ttdeci").addClass("panel-body");
|
||||
|
||||
$('#MSearchBox').parent().remove();
|
||||
|
||||
$('div.fragment.well div.line:first').css('margin-top', '15px');
|
||||
$('div.fragment.well div.line:last').css('margin-bottom', '15px');
|
||||
|
||||
$('table.doxtable').removeClass('doxtable').addClass('table table-striped table-bordered').each(function(){
|
||||
$(this).prepend('<thead></thead>');
|
||||
$(this).find('tbody > tr:first').prependTo($(this).find('thead'));
|
||||
|
||||
$(this).find('td > span.success').parent().addClass('success');
|
||||
$(this).find('td > span.warning').parent().addClass('warning');
|
||||
$(this).find('td > span.danger').parent().addClass('danger');
|
||||
});
|
||||
|
||||
|
||||
|
||||
if($('div.fragment.well div.ttc').length > 0)
|
||||
{
|
||||
$('div.fragment.well div.line:first').parent().removeClass('fragment well');
|
||||
}
|
||||
|
||||
$('table.memberdecls').find('.memItemRight').each(function(){
|
||||
$(this).contents().appendTo($(this).siblings('.memItemLeft'));
|
||||
$(this).siblings('.memItemLeft').attr('align', 'left');
|
||||
});
|
||||
|
||||
function getOriginalWidthOfImg(img_element) {
|
||||
var t = new Image();
|
||||
t.src = (img_element.getAttribute ? img_element.getAttribute("src") : false) || img_element.src;
|
||||
return t.width;
|
||||
}
|
||||
|
||||
$('div.dyncontent').find('img').each(function(){
|
||||
if(getOriginalWidthOfImg($(this)[0]) > $('#content>div.container').width())
|
||||
$(this).css('width', '100%');
|
||||
});
|
||||
|
||||
$(".memitem").removeClass('memitem');
|
||||
$(".memproto").removeClass('memproto');
|
||||
$(".memdoc").removeClass('memdoc');
|
||||
$("span.mlabel").removeClass('mlabel');
|
||||
$("table.memberdecls").removeClass('memberdecls');
|
||||
$("[class^=memitem]").removeClass('memitem');
|
||||
$("span.mlabels").removeClass('mlabels');
|
||||
$("table.mlabels").removeClass('mlabels');
|
||||
$("td.mlabels-right").removeClass('mlabels-right');
|
||||
$(".navpath").removeClass('navpath');
|
||||
$("li.navelem").removeClass('navelem');
|
||||
$("a.el").removeClass('el');
|
||||
$("div.ah").removeClass('ah');
|
||||
$("div.header").removeClass("header");
|
||||
|
||||
$('.mdescLeft').each(function(){
|
||||
if($(this).html()==" ") {
|
||||
$(this).siblings('.mdescRight').attr('colspan', 2);
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
$('td.memItemLeft').each(function(){
|
||||
if($(this).siblings('.memItemRight').html()=="") {
|
||||
$(this).attr('colspan', 2);
|
||||
$(this).siblings('.memItemRight').remove();
|
||||
}
|
||||
});
|
||||
});
|
7
docs/web/bootstrap/index.md
Normal file
7
docs/web/bootstrap/index.md
Normal file
@ -0,0 +1,7 @@
|
||||
# Testing {#index}
|
||||
|
||||
Hello world!
|
||||
|
||||
~~~{.xml}
|
||||
<test />
|
||||
~~~
|
9
docs/yap.css
Normal file
9
docs/yap.css
Normal file
@ -0,0 +1,9 @@
|
||||
body { padding-top: 100px; }
|
||||
|
||||
/* set a max-width for horizontal fluid layout and make it centered */
|
||||
.container-fluid {
|
||||
margin-right: auto;
|
||||
margin-left: auto;
|
||||
max-width: 1600px; /* or 950px */
|
||||
}
|
||||
|
@ -357,7 +357,7 @@ typedef enum stream_f {
|
||||
Eof_Error_Stream_f = 0x000200, /**< Stream should generate error on trying to read after EOF */
|
||||
Reset_Eof_Stream_f = 0x000400, /**< Stream should be reset on findind an EO (C-D and console.*/
|
||||
Past_Eof_Stream_f = 0x000800, /**< Read EOF from stream */
|
||||
Push_Eof_Stream_f = 0x001000, /**< keep on sennding EOFs */
|
||||
Push_Eof_Stream_f = 0x001000, /**< keep on sending EOFs */
|
||||
Seekable_Stream_f = 0x002000, /**< we can jump around the stream (std regular files) */
|
||||
Promptable_Stream_f = 0x004000, /**< Interactive line-by-line stream */
|
||||
Client_Socket_Stream_f= 0x008000, /**< socket in client mode */
|
||||
@ -369,7 +369,8 @@ typedef enum stream_f {
|
||||
HAS_BOM_f = 0x200000, /**< media for streamhas a BOM mar. */
|
||||
RepError_Prolog_f = 0x400000, /**< handle representation error as Prolog terms */
|
||||
RepError_Xml_f = 0x800000, /**< handle representation error as XML objects */
|
||||
DoNotCloseOnAbort_Stream_f= 0x1000000 /**< do not close the stream after an abort event */
|
||||
DoNotCloseOnAbort_Stream_f= 0x1000000, /**< do not close the stream after an abort event */
|
||||
Readline_Stream_f= 0x2000000 /**< the stream is a readline stream */
|
||||
} estream_f;
|
||||
|
||||
typedef uint64_t stream_flags_t;
|
||||
|
@ -13,6 +13,7 @@ set (LIBRARY_PL
|
||||
dbqueues.yap
|
||||
dbusage.yap
|
||||
dgraphs.yap
|
||||
error.yap
|
||||
exo_interval.yap
|
||||
expand_macros.yap
|
||||
gensym.yap
|
||||
@ -54,7 +55,8 @@ set (LIBRARY_PL
|
||||
wundgraphs.yap
|
||||
lam_mpi.yap
|
||||
ypp.yap
|
||||
c_alarms.yap
|
||||
ytest.yap
|
||||
c_alarms.yap
|
||||
flags.yap
|
||||
block_diagram.yap
|
||||
)
|
||||
|
@ -14,10 +14,10 @@
|
||||
/**
|
||||
* @file apply.yap
|
||||
* @defgroup apply_stub Apply Predicates
|
||||
|
||||
*
|
||||
* @ingroup library
|
||||
|
||||
@{
|
||||
*
|
||||
* @{
|
||||
|
||||
This library provides a SWI-compatible set of utilities for applying a
|
||||
predicate to all elements of a list.
|
||||
@ -34,8 +34,6 @@ The apply library is a _stub_, it just forwards definitions to the
|
||||
- partition/4,
|
||||
- partition/5
|
||||
|
||||
@}
|
||||
|
||||
*/
|
||||
|
||||
:- reexport(library(maplist),
|
||||
@ -50,3 +48,5 @@ The apply library is a _stub_, it just forwards definitions to the
|
||||
]).
|
||||
|
||||
|
||||
%% @}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
/% File : apply_macros.yap
|
||||
% Author : E. Alphonse from code by Joachim Schimpf
|
||||
% Updated: 15 June 2002
|
||||
@ -25,7 +26,6 @@ definitions to the @ref maplist library, these include:
|
||||
- partition/4,
|
||||
- partition/5
|
||||
|
||||
@}
|
||||
|
||||
*/
|
||||
|
||||
@ -33,4 +33,4 @@ definitions to the @ref maplist library, these include:
|
||||
|
||||
:- reexport(mapargs).
|
||||
|
||||
|
||||
%% @}
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
@ingroup @library
|
||||
|
||||
@{
|
||||
|
||||
Extends arg/3 by including backtracking through arguments and access
|
||||
to sub-arguments,
|
||||
|
||||
@ -158,3 +160,6 @@ path_arg([], Term, Term).
|
||||
path_arg([Index|Indices], Term, SubTerm) :-
|
||||
genarg(Index, Term, Arg),
|
||||
path_arg(Indices, Arg, SubTerm).
|
||||
|
||||
%%@}
|
||||
|
||||
|
@ -11,9 +11,6 @@
|
||||
* Note: the keys should be bound, the associated values need not be.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
*/
|
||||
:- module(assoc, [
|
||||
empty_assoc/1,
|
||||
assoc_to_list/2,
|
||||
|
@ -17,12 +17,12 @@
|
||||
|
||||
:- module(attributes, [op(1150, fx, attribute)]).
|
||||
|
||||
%% @{
|
||||
%% @{
|
||||
|
||||
/**
|
||||
@ingroup Old_Style_Attribute_Declarations
|
||||
@addtogroup attributes
|
||||
|
||||
|
||||
|
||||
SICStus style attribute declarations are activated through loading the
|
||||
library <tt>atts</tt>. The command
|
||||
|
||||
@ -92,45 +92,44 @@ store_new_module(Mod,Ar,ArgPosition) :-
|
||||
ArgPosition is Position+1,
|
||||
( Ar == 0 -> NOfAtts is Position+1 ; NOfAtts is Position+Ar),
|
||||
functor(AccessTerm,Mod,NOfAtts),
|
||||
assertz(attributed_module(Mod,NOfAtts,AccessTerm)).
|
||||
|
||||
assertz(attributed_module(Mod,NOfAtts,AccessTerm)).
|
||||
|
||||
:- user_defined_directive(attribute(G), attributes:new_attribute(G)).
|
||||
|
||||
/** @pred Module:get_atts( _-Var_, _?ListOfAttributes_)
|
||||
/** @pred Module:get_atts( _-Var_, _?ListOfAttributes_)
|
||||
|
||||
|
||||
Unify the list _?ListOfAttributes_ with the attributes for the unbound
|
||||
variable _Var_. Each member of the list must be a bound term of the
|
||||
form `+( _Attribute_)`, `-( _Attribute_)` (the <tt>kbd</tt>
|
||||
prefix may be dropped). The meaning of <tt>+</tt> and <tt>-</tt> is:
|
||||
+ +( _Attribute_)
|
||||
Unifies _Attribute_ with a corresponding attribute associated with
|
||||
_Var_, fails otherwise.
|
||||
+ +( _Attribute_)
|
||||
Unifies _Attribute_ with a corresponding attribute associated with
|
||||
_Var_, fails otherwise.
|
||||
|
||||
+ -( _Attribute_)
|
||||
Succeeds if a corresponding attribute is not associated with
|
||||
_Var_. The arguments of _Attribute_ are ignored.
|
||||
|
||||
+ -( _Attribute_)
|
||||
Succeeds if a corresponding attribute is not associated with
|
||||
_Var_. The arguments of _Attribute_ are ignored.
|
||||
|
||||
|
||||
*/
|
||||
user:goal_expansion(get_atts(Var,AccessSpec), Mod, Goal) :-
|
||||
expand_get_attributes(AccessSpec,Mod,Var,Goal).
|
||||
|
||||
/** @pred Module:put_atts( _-Var_, _?ListOfAttributes_)
|
||||
/** @pred Module:put_atts( _-Var_, _?ListOfAttributes_)
|
||||
|
||||
|
||||
Associate with or remove attributes from a variable _Var_. The
|
||||
attributes are given in _?ListOfAttributes_, and the action depends
|
||||
on how they are prefixed:
|
||||
+ +( _Attribute_)
|
||||
Associate _Var_ with _Attribute_. A previous value for the
|
||||
attribute is simply replace (like with `set_mutable/2`).
|
||||
|
||||
+ -( _Attribute_)
|
||||
Remove the attribute with the same name. If no such attribute existed,
|
||||
simply succeed.
|
||||
|
||||
+ +( _Attribute_ )
|
||||
Associate _Var_ with _Attribute_. A previous value for the
|
||||
attribute is simply replace (like with `set_mutable/2`).
|
||||
|
||||
+ -( _Attribute_ )
|
||||
Remove the attribute with the same name. If no such attribute existed,
|
||||
simply succeed.
|
||||
|
||||
*/
|
||||
user:goal_expansion(put_atts(Var,AccessSpec), Mod, Goal) :-
|
||||
@ -154,7 +153,7 @@ expand_get_attributes(Atts,Mod,Var,attributes:get_module_atts(Var,AccessTerm)) :
|
||||
sort(LAtts,SortedLAtts),
|
||||
free_term(Free),
|
||||
build_att_term(1,NOfAtts,SortedLAtts,Free,AccessTerm).
|
||||
expand_get_attributes(Att,Mod,Var,Goal) :-
|
||||
expand_get_attributes(Att,Mod,Var,Goal) :-
|
||||
expand_get_attributes([Att],Mod,Var,Goal).
|
||||
|
||||
build_att_term(NOfAtts,NOfAtts,[],_,_) :- !.
|
||||
@ -183,7 +182,7 @@ cvt_atts([-Att|Atts],Mod,Void,[Pos-LVoids|Read]) :- !,
|
||||
;
|
||||
Att =..[_|LAtts],
|
||||
void_vars(LAtts,Void,LVoids)
|
||||
),
|
||||
),
|
||||
cvt_atts(Atts,Mod,Void,Read).
|
||||
cvt_atts([Att|Atts],Mod,Void,[Pos-LAtts|Read]) :- !,
|
||||
existing_attribute(Att,Mod,_,Pos),
|
||||
@ -219,7 +218,7 @@ expand_put_attributes(Atts,Mod,Var,attributes:put_module_atts(Var,AccessTerm)) :
|
||||
sort(LAtts,SortedLAtts),
|
||||
free_term(Free),
|
||||
build_att_term(1,NOfAtts,SortedLAtts,Free,AccessTerm).
|
||||
expand_put_attributes(Att,Mod,Var,Goal) :-
|
||||
expand_put_attributes(Att,Mod,Var,Goal) :-
|
||||
expand_put_attributes([Att],Mod,Var,Goal).
|
||||
|
||||
woken_att_do(AttVar, Binding, NGoals, DoNotBind) :-
|
||||
@ -243,7 +242,7 @@ find_used([M|Mods],Mods0,L0,Lf) :-
|
||||
find_used([_|Mods],Mods0,L0,Lf) :-
|
||||
find_used(Mods,Mods0,L0,Lf).
|
||||
|
||||
/** @pred Module:verify_attributes( _-Var_, _+Value_, _-Goals_)
|
||||
/** @pred Module:verify_attributes( _-Var_, _+Value_, _-Goals_)
|
||||
|
||||
The predicate is called when trying to unify the attributed variable
|
||||
_Var_ with the Prolog term _Value_. Note that _Value_ may be
|
||||
@ -261,7 +260,7 @@ Notice that the <tt>verify_attributes/3</tt> may be called even if _Var_<
|
||||
has no attributes in module <tt>Module</tt>. In this case the routine should
|
||||
simply succeed with _Goals_ unified with the empty list.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
do_verify_attributes([], _, _, []).
|
||||
do_verify_attributes([Mod|Mods], AttVar, Binding, [Mod:Goal|Goals]) :-
|
||||
@ -271,6 +270,13 @@ do_verify_attributes([Mod|Mods], AttVar, Binding, [Mod:Goal|Goals]) :-
|
||||
do_verify_attributes([_|Mods], AttVar, Binding, Goals) :-
|
||||
do_verify_attributes(Mods, AttVar, Binding, Goals).
|
||||
|
||||
has_modules_with_attributes(LMods) :-
|
||||
modules_with_attributes(LMods).
|
||||
|
||||
module_has_attributes(Mod) :-
|
||||
attributed_module(Mod, _, _), !.
|
||||
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
@ -34,6 +34,8 @@
|
||||
* @defgroup bhash Backtrackable Hash Tables
|
||||
* @ingroup library
|
||||
|
||||
@{
|
||||
|
||||
This library implements hash-arrays.
|
||||
It requires the hash key to be a ground term. The library can
|
||||
be loaded as
|
||||
@ -326,4 +328,5 @@ mklistvals(K.Vals, KK.NVals) :-
|
||||
mklistvals(Vals, NVals).
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
* @brief Graph the program structure.
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
@ -473,3 +473,5 @@ write_explicit.
|
||||
atom_concat([InModule, ' -> DYNAMIC [label="DYNAMIC",style=dashed]'], NodeConnection),
|
||||
write(NodeConnection), nl.
|
||||
*/
|
||||
|
||||
%% @}
|
||||
|
@ -21,7 +21,7 @@
|
||||
* @date Tue Nov 17 01:17:33 2015
|
||||
*
|
||||
* @brief Several operations on text.
|
||||
*
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
conj2list/2,
|
||||
clauselength/2]).
|
||||
|
||||
%%! @{
|
||||
%% @{
|
||||
|
||||
/**
|
||||
* @defgroup clauses Clause Manipulation
|
||||
@ -31,26 +31,42 @@
|
||||
|
||||
It is often easier to apply operations on lists than on clauses
|
||||
*/
|
||||
conj2list( M:Conj, List ) :-
|
||||
conj2list_( Conj, M, List, [] ).
|
||||
|
||||
conj2list( Conj, List ) :-
|
||||
conj2list( Conj, List, [] ).
|
||||
conj2list_( Conj, List, [] ).
|
||||
|
||||
|
||||
conj2list( C ) -->
|
||||
conj2list_( C ) -->
|
||||
{ var(C) },
|
||||
!,
|
||||
[C].
|
||||
conj2list( true ) --> !.
|
||||
conj2list( (C1, C2) ) -->
|
||||
conj2list_( true ) --> !.
|
||||
conj2list_( (C1, C2) ) -->
|
||||
!,
|
||||
conj2list( C1 ),
|
||||
conj2list( C2 ).
|
||||
conj2list( C ) -->
|
||||
conj2list_( C1 ),
|
||||
conj2list_( C2 ).
|
||||
conj2list_( C ) -->
|
||||
[C].
|
||||
|
||||
/** conj2list( +List, -Conj) is det
|
||||
conj2list_( C, M ) -->
|
||||
{ var(C) },
|
||||
!,
|
||||
[M: C].
|
||||
conj2list_( true , _) --> !.
|
||||
conj2list_( (C1, C2), M ) -->
|
||||
!,
|
||||
conj2list_( C1, M ),
|
||||
conj2list_( C2, M ).
|
||||
conj2list_( C, M ) -->
|
||||
{ strip_module(M:C, NM, NC) },
|
||||
[NM:NC].
|
||||
|
||||
/** list2conj( +List, -Conj) is det
|
||||
Generate a conjunction from a list of literals.
|
||||
|
||||
Notice that this relies on indexing within the list to avoid creating
|
||||
Notice Mthat this relies on indexing within the list to avoid creating
|
||||
choice-points.
|
||||
*/
|
||||
list2conj([], true).
|
||||
@ -77,3 +93,4 @@ clauselength( (C1, C2), I2, I ) :- !,
|
||||
clauselength( _C, I1, I ) :-
|
||||
I1 is I+1.
|
||||
|
||||
%%@}
|
||||
|
@ -17,7 +17,7 @@
|
||||
/**
|
||||
*
|
||||
* @{
|
||||
* @file blobs.c
|
||||
* @file swi/fli/blobs.c
|
||||
*
|
||||
* @addtogroup swi-c-interface
|
||||
*
|
||||
|
2
library/error.yap
Normal file
2
library/error.yap
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
%:- include('pl/error').
|
@ -1,7 +1,7 @@
|
||||
%%% -*- Mode: Prolog; -*-
|
||||
|
||||
/**
|
||||
* @file flags.yap
|
||||
* @file library/flags.yap
|
||||
* @author Theofrastos Mantadelis, Bernd Gutmann, Paulo Moura
|
||||
* @date Tue Nov 17 15:18:02 2015
|
||||
*
|
||||
@ -235,6 +235,7 @@
|
||||
*
|
||||
* Routines to manipulate flags: they allow defining, set,
|
||||
* resetting.
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
@ -585,4 +586,4 @@ defined_flag(FlagName, FlagGroup, FlagType, DefaultValue, Description, Access, H
|
||||
nonvar(FlagName), nonvar(FlagGroup),
|
||||
'$defined_flag$'(FlagName, FlagGroup, FlagType, DefaultValue, Description, Access, Handler).
|
||||
|
||||
|
||||
%%@}
|
||||
|
@ -21,6 +21,7 @@
|
||||
enable_interrupts/0,
|
||||
disable_interrupts/0,
|
||||
virtual_alarm/3,
|
||||
fully_strip_module/3,
|
||||
context_variables/1
|
||||
]).
|
||||
|
||||
@ -65,3 +66,7 @@ virtual_alarm(Interval.USecs, Goal, Left.LUSecs) :-
|
||||
on_signal(sig_vtalarm, _, Goal),
|
||||
virtual_alarm(Interval, USecs, Left, LUSecs).
|
||||
|
||||
fully_strip_module(T,M,S) :-
|
||||
'$hacks':fully_strip_module(T,M,S).
|
||||
|
||||
|
||||
|
@ -257,8 +257,7 @@ the pair with the smallest Key), but does not remove it from the heap.
|
||||
min_of_heap(t(_,_,t(Key,Datum,_,_)), Key, Datum).
|
||||
|
||||
|
||||
%% @pred @pred min_of_heap(+ _Heap_, - _Key1_, - _Datum1_,
|
||||
- _Key2_, - _Datum2_)
|
||||
%% @pred @pred min_of_heap(+ _Heap_, - _Key1_, - _Datum1_, -_Key2_, - _Datum2_)
|
||||
%
|
||||
% returns the smallest (Key1) and second smallest (Key2) pairs in
|
||||
% the heap, without deleting them. It fails if the heap does not
|
||||
|
@ -18,6 +18,7 @@
|
||||
blank/3,
|
||||
split/2,
|
||||
split/3,
|
||||
split_unquoted/3,
|
||||
fields/2,
|
||||
fields/3,
|
||||
glue/3,
|
||||
@ -199,6 +200,58 @@ split(SplitCodes, [C|New], Set) -->
|
||||
split(SplitCodes, New, Set).
|
||||
split(_, [], []) --> [].
|
||||
|
||||
/** @pred split_unquoted(+ _Line_,+ _Separators_,- _Split_)
|
||||
|
||||
|
||||
|
||||
Unify _Words_ with a set of strings obtained from _Line_ by
|
||||
using the character codes in _Separators_ as separators, but treat text within double quotes as a single unit. As an
|
||||
example, consider:
|
||||
|
||||
~~~~~{.prolog}
|
||||
?- split("Hello * I \"am free\""," *",S).
|
||||
|
||||
S = ["Hello","I","am free"] ?
|
||||
|
||||
no
|
||||
~~~~~
|
||||
|
||||
*/
|
||||
split_unquoted(String, SplitCodes, Strings) :-
|
||||
split_unquoted_at_blank(SplitCodes, Strings, String, []).
|
||||
|
||||
split_unquoted_at_blank(SplitCodes, [[0'"|New]|More]) --> %0'"
|
||||
"\"",
|
||||
split_quoted(New, More),
|
||||
split_unquoted_at_blank(SplitCodes, More).
|
||||
split_unquoted_at_blank(SplitCodes, More) -->
|
||||
[C],
|
||||
{ member(C, SplitCodes) }, !,
|
||||
split_unquoted_at_blank(SplitCodes, More).
|
||||
split_unquoted_at_blank(SplitCodes, [[C|New]| More]) -->
|
||||
[C], !,
|
||||
split_unquoted(SplitCodes, New, More).
|
||||
split_unquoted_at_blank(_, []) --> [].
|
||||
|
||||
split_unquoted(SplitCodes, [], More) -->
|
||||
[C],
|
||||
{ member(C, SplitCodes) }, !,
|
||||
split_unquoted_at_blank(SplitCodes, More).
|
||||
split_unquoted(SplitCodes, [C|New], Set) -->
|
||||
[C], !,
|
||||
split_unquoted(SplitCodes, New, Set).
|
||||
split_unquoted(_, [], []) --> [].
|
||||
|
||||
split_quoted( [0'"], More) --> %0'"
|
||||
"\"".
|
||||
split_quoted( [0'\\ ,C|New], More) --> %0'"
|
||||
"\\",
|
||||
[C],
|
||||
split_quoted(New, More).
|
||||
split_quoted( [C|New], More) --> %0'"
|
||||
[C],
|
||||
split_quoted(New, More).
|
||||
|
||||
/** @pred fields(+ _Line_,- _Split_)
|
||||
|
||||
Unify _Words_ with a set of strings obtained from _Line_ by
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file lists.yap
|
||||
* @file library/lists.yap
|
||||
* @author Bob Welham, Lawrence Byrd, and R. A. O'Keefe. Contributions from Vitor Santos Costa, Jan Wielemaker and others.
|
||||
* @date 1999
|
||||
*
|
||||
@ -212,6 +212,7 @@ append_([L1,L2|[L3|LL]], L) :-
|
||||
|
||||
True when _List_ is a list and _Last_ is identical to its last element.
|
||||
d(_, [X], L).
|
||||
*/
|
||||
|
||||
last([H|List], Last) :-
|
||||
last(List, H, Last).
|
||||
@ -623,3 +624,4 @@ close_list([_|T]) :-
|
||||
close_list(T).
|
||||
|
||||
|
||||
%% @}
|
@ -34,7 +34,7 @@
|
||||
ord_memberchk/2 % Element X Set
|
||||
]).
|
||||
|
||||
/** @defgroup Ordered_Sets Ordered Sets
|
||||
/** @defgroup ordsets Ordered Sets
|
||||
* @ingroup library
|
||||
* @{
|
||||
|
||||
|
@ -19,10 +19,10 @@
|
||||
* @file readutil.yap
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP.lan>
|
||||
* @date Wed Nov 18 00:16:15 2015
|
||||
*
|
||||
*
|
||||
* @brief Read full lines and a full file in a single call.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
:- module(readutil, [
|
||||
@ -42,7 +42,7 @@
|
||||
* @ingroup library
|
||||
*
|
||||
* Read full lines and a full file in a single call.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@ -55,7 +55,6 @@ read_file_to_codes(File, Codes, _) :-
|
||||
close(Stream).
|
||||
|
||||
read_file_to_codes(File, Codes) :-
|
||||
v
|
||||
open(File, read, Stream),
|
||||
read_stream_to_codes(Stream, Codes, []),
|
||||
close(Stream).
|
||||
@ -79,5 +78,3 @@ prolog_read_stream_to_terms(Stream, Terms, Terms0) :-
|
||||
Terms = [Term|TermsI],
|
||||
prolog_read_stream_to_terms(Stream, TermsI, Terms0)
|
||||
).
|
||||
|
||||
|
||||
|
@ -19,16 +19,17 @@
|
||||
* @file system.yap
|
||||
* @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.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
:- module operating_system_support,
|
||||
:- module( operating_system_support,
|
||||
[
|
||||
datime/1,
|
||||
delete_file/1,
|
||||
delete_file/2,
|
||||
directory_files/2,
|
||||
@ -56,8 +57,8 @@
|
||||
mktime/2,
|
||||
tmpnam/1,
|
||||
tmp_file/2,
|
||||
tmpdir/1,
|
||||
wait/2,
|
||||
tmpdir/1,
|
||||
wait/2,
|
||||
working_directory/2
|
||||
]).
|
||||
|
||||
@ -86,14 +87,14 @@ on local time. This function uses the WIN32
|
||||
~~~~~
|
||||
?- datime(X).
|
||||
|
||||
X = datime(2001,5,28,15,29,46) ?
|
||||
X = datime(2001,5,28,15,29,46) ?
|
||||
~~~~~
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/** @pred environ(+ _E_,- _S_)
|
||||
/** @pred environ(+ _E_,- _S_)
|
||||
|
||||
|
||||
|
||||
@ -101,25 +102,25 @@ X = datime(2001,5,28,15,29,46) ?
|
||||
|
||||
Given an environment variable _E_ this predicate unifies the second argument _S_ with its value.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred system(+ _S_)
|
||||
/** @pred system(+ _S_)
|
||||
|
||||
|
||||
Passes command _S_ to the Bourne shell (on UNIX environments) or the
|
||||
current command interpreter in WIN32 environments.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred working_directory(- _CurDir_,? _NextDir_)
|
||||
/** @pred working_directory(- _CurDir_,? _NextDir_)
|
||||
|
||||
|
||||
Fetch the current directory at _CurDir_. If _NextDir_ is bound
|
||||
to an atom, make its value the current working directory.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred delete_file(+ _File_)
|
||||
/** @pred delete_file(+ _File_)
|
||||
|
||||
|
||||
The delete_file/1 procedure removes file _File_. If
|
||||
@ -129,7 +130,7 @@ The delete_file/1 procedure removes file _File_. If
|
||||
?- delete_file(x).
|
||||
~~~~~
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred delete_file(+ _File_,+ _Opts_)
|
||||
|
||||
@ -144,9 +145,9 @@ This example is equivalent to using the delete_file/1 predicate:
|
||||
?- delete_file(x, [recursive]).
|
||||
~~~~~
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred directory_files(+ _Dir_,+ _List_)
|
||||
/** @pred directory_files(+ _Dir_,+ _List_)
|
||||
|
||||
|
||||
Given a directory _Dir_, directory_files/2 procedures a
|
||||
@ -159,9 +160,9 @@ listing of all files and directories in the directory:
|
||||
The predicates uses the `dirent` family of routines in Unix
|
||||
environments, and `findfirst` in WIN32.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred environ(? _EnvVar_,+ _EnvValue_)
|
||||
/** @pred environ(? _EnvVar_,+ _EnvValue_)
|
||||
|
||||
|
||||
Unify environment variable _EnvVar_ with its value _EnvValue_,
|
||||
@ -174,9 +175,9 @@ not currently in Win32 configurations.
|
||||
X = 'C:\\cygwin\\home\\administrator' ?
|
||||
~~~~~
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred exec(+ _Command_, _StandardStreams_,- _PID_)
|
||||
/** @pred exec(+ _Command_, _StandardStreams_,- _PID_)
|
||||
|
||||
|
||||
Execute command _Command_ with its standard streams connected to
|
||||
@ -195,14 +196,14 @@ The streams may be one of standard stream, `std`, null stream,
|
||||
`null`, or `pipe(S)`, where _S_ is a pipe stream. Note
|
||||
that it is up to the user to close the pipe.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred file_exists(+ _File_)
|
||||
/** @pred file_exists(+ _File_)
|
||||
|
||||
|
||||
The atom _File_ corresponds to an existing file.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred file_exists(+ _File_,+ _Permissions_)
|
||||
|
||||
@ -211,9 +212,9 @@ compatible with _Permissions_. YAP currently only accepts for
|
||||
permissions to be described as a number. The actual meaning of this
|
||||
number is Operating System dependent.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred file_property(+ _File_,? _Property_)
|
||||
/** @pred file_property(+ _File_,? _Property_)
|
||||
|
||||
|
||||
The atom _File_ corresponds to an existing file, and _Property_
|
||||
@ -239,28 +240,28 @@ P = mod_time(990826911) ? ;
|
||||
no
|
||||
~~~~~
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred host_id(- _Id_)
|
||||
/** @pred host_id(- _Id_)
|
||||
|
||||
|
||||
|
||||
Unify _Id_ with an identifier of the current host. YAP uses the
|
||||
`hostid` function when available,
|
||||
`hostid` function when available,
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred host_name(- _Name_)
|
||||
/** @pred host_name(- _Name_)
|
||||
|
||||
|
||||
|
||||
Unify _Name_ with a name for the current host. YAP uses the
|
||||
`hostname` function in Unix systems when available, and the
|
||||
`GetComputerName` function in WIN32 systems.
|
||||
`GetComputerName` function in WIN32 systems.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred mktemp( _Spec_,- _File_)
|
||||
/** @pred mktemp( _Spec_,- _File_)
|
||||
|
||||
|
||||
|
||||
@ -268,7 +269,7 @@ Direct interface to `mktemp`: given a _Spec_, that is a file
|
||||
name with six _X_ to it, create a file name _File_. Use
|
||||
tmpnam/1 instead.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred mktime(+_Datime_, - _Seconds_)
|
||||
|
||||
@ -286,18 +287,18 @@ WIN32 `GetLocalTime` function or the Unix `mktime` function.
|
||||
X = 991081786 ? ;
|
||||
~~~~~
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred pid(- _Id_)
|
||||
/** @pred pid(- _Id_)
|
||||
|
||||
|
||||
|
||||
Unify _Id_ with the process identifier for the current
|
||||
process. An interface to the <tt>getpid</tt> function.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred popen(+ _Command_, + _TYPE_, - _Stream_)
|
||||
/** @pred popen(+ _Command_, + _TYPE_, - _Stream_)
|
||||
|
||||
|
||||
Interface to the <tt>popen</tt> function. It opens a process by creating a
|
||||
@ -318,17 +319,17 @@ X = 'C:\\cygwin\\home\\administrator' ?
|
||||
|
||||
The WIN32 implementation of popen/3 relies on exec/3.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred rename_file(+ _OldFile_,+ _NewFile_)
|
||||
/** @pred rename_file(+ _OldFile_,+ _NewFile_)
|
||||
|
||||
|
||||
Create file _OldFile_ to _NewFile_. This predicate uses the
|
||||
`C` built-in function `rename`.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred shell
|
||||
/** @pred shell
|
||||
|
||||
|
||||
Start a new shell and leave YAP in background until the shell
|
||||
@ -336,7 +337,7 @@ completes. YAP uses the shell given by the environment variable
|
||||
`SHELL`. In WIN32 environment YAP will use `COMSPEC` if
|
||||
`SHELL` is undefined.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred shell(+ _Command_)
|
||||
|
||||
@ -346,7 +347,7 @@ the shell given by the environment variable `SHELL` with the option
|
||||
`" -c "`. In WIN32 environment YAP will use `COMSPEC` if
|
||||
`SHELL` is undefined, in this case with the option `" /c "`.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred shell(+ _Command_,- _Status_)
|
||||
|
||||
@ -357,19 +358,19 @@ environment variable `SHELL` with the option `" -c "`. In
|
||||
WIN32 environment YAP will use `COMSPEC` if `SHELL` is
|
||||
undefined, in this case with the option `" /c "`.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred sleep(+ _Time_)
|
||||
/** @pred sleep(+ _Time_)
|
||||
|
||||
|
||||
Block the current thread for _Time_ seconds. When YAP is compiled
|
||||
without multi-threading support, this predicate blocks the YAP process.
|
||||
The number of seconds must be a positive number, and it may an integer
|
||||
or a float. The Unix implementation uses `usleep` if the number of
|
||||
seconds is below one, and `sleep` if it is over a second. The WIN32
|
||||
Block the current thread for _Time_ seconds. When YAP is compiled
|
||||
without multi-threading support, this predicate blocks the YAP process.
|
||||
The number of seconds must be a positive number, and it may an integer
|
||||
or a float. The Unix implementation uses `usleep` if the number of
|
||||
seconds is below one, and `sleep` if it is over a second. The WIN32
|
||||
implementation uses `Sleep` for both cases.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred system
|
||||
|
||||
@ -377,33 +378,33 @@ Start a new default shell and leave YAP in background until the shell
|
||||
completes. YAP uses `/bin/sh` in Unix systems and `COMSPEC` in
|
||||
WIN32.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred system(+ _Command_,- _Res_)
|
||||
|
||||
Interface to `system`: execute command _Command_ and unify
|
||||
_Res_ with the result.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred tmp_file(+_Base_, - _File_)
|
||||
/** @pred tmp_file(+_Base_, - _File_)
|
||||
|
||||
Create a name for a temporary file. _Base_ is an user provided
|
||||
identifier for the category of file. The _TmpName_ is guaranteed to
|
||||
be unique. If the system halts, it will automatically remove all created
|
||||
temporary files.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred tmpnam(- _File_)
|
||||
/** @pred tmpnam(- _File_)
|
||||
|
||||
|
||||
|
||||
Interface with _tmpnam_: obtain a new, unique file name _File_.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred working_directory(- _Old_,+ _New_)
|
||||
/** @pred working_directory(- _Old_,+ _New_)
|
||||
|
||||
|
||||
|
||||
@ -412,7 +413,7 @@ 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]).
|
||||
@ -426,7 +427,7 @@ also `absolute_file_name/2` and chdir/1.
|
||||
datime(X) :-
|
||||
datime(X, Error),
|
||||
handle_system_internal(Error, off, datime(X)).
|
||||
|
||||
|
||||
mktime(V, A) :- var(V), !,
|
||||
throw(error(instantiation_error,mktime(V,A))).
|
||||
mktime(In,Out) :-
|
||||
@ -434,7 +435,7 @@ mktime(In,Out) :-
|
||||
In = datime(Y,Mo,D,H,Mi,S),
|
||||
mktime(Y, Mo, D, H, Mi, S, Out, Error),
|
||||
handle_system_internal(Error, off, mktime(In,Out)).
|
||||
|
||||
|
||||
check_mktime_inp(V, Inp) :- var(V), !,
|
||||
throw(error(instantiation_error,Inp)).
|
||||
check_mktime_inp(datime(Y,Mo,D,H,Mi,S), Inp) :- !,
|
||||
@ -446,7 +447,7 @@ check_mktime_inp(datime(Y,Mo,D,H,Mi,S), Inp) :- !,
|
||||
check_int(S, Inp).
|
||||
check_mktime_inp(T, Inp) :-
|
||||
throw(error(domain_error(mktime,T),Inp)).
|
||||
|
||||
|
||||
check_int(I, _) :- integer(I), !.
|
||||
check_int(I, Inp) :- var(I),
|
||||
throw(error(instantiation_error,Inp)).
|
||||
@ -524,7 +525,7 @@ delete_dirfiles([F|Fs], File, Ignore) :-
|
||||
|
||||
directory_files(File, FileList) :-
|
||||
directory_files(File, FileList, on).
|
||||
|
||||
|
||||
directory_files(File, FileList, Ignore) :-
|
||||
list_directory(File, FileList, Error),
|
||||
handle_system_internal(Error, Ignore, directory_files(File, FileList)).
|
||||
@ -627,7 +628,7 @@ environ_split([C|S],[C|SNa],SVal) :-
|
||||
%
|
||||
exec(Command, [StdIn, StdOut, StdErr], PID) :-
|
||||
G = exec(Command, [StdIn, StdOut, StdErr], PID),
|
||||
check_command_with_default_shell(Command, TrueCommand, G),
|
||||
check_command_with_default_shell(Command, TrueCommand, G),
|
||||
process_inp_stream_for_exec(StdIn, In, G, [], L1),
|
||||
process_out_stream_for_exec(StdOut, Out, G, L1, L2),
|
||||
process_err_stream_for_exec(StdErr, Err, G, L2, L3),
|
||||
@ -673,7 +674,7 @@ process_err_stream_for_exec(Stream, Stream, _, L, L) :-
|
||||
stream_property(Stream, output).
|
||||
|
||||
close_temp_streams([]).
|
||||
close_temp_streams([S|Ss]) :-
|
||||
close_temp_streams([S|Ss]) :-
|
||||
close(S),
|
||||
close_temp_streams(Ss).
|
||||
|
||||
@ -749,7 +750,7 @@ get_shell(Shell, '/c') :-
|
||||
win, !,
|
||||
getenv('COMSPEC', Shell).
|
||||
get_shell('/bin/sh','-c').
|
||||
|
||||
|
||||
system :-
|
||||
default_shell(Command),
|
||||
do_system(Command, _Status, Error),
|
||||
@ -758,7 +759,7 @@ system :-
|
||||
default_shell(Shell) :- win, !,
|
||||
getenv('COMSPEC', Shell).
|
||||
default_shell('/bin/sh').
|
||||
|
||||
|
||||
|
||||
system(Command, Status) :-
|
||||
G = system(Command, Status),
|
||||
@ -831,4 +832,3 @@ tmpdir(TmpDir):-
|
||||
path_separator('\\'):-
|
||||
win, !.
|
||||
path_separator('/').
|
||||
|
||||
|
@ -2,10 +2,10 @@
|
||||
* @file wdgraphs.yap
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP.lan>
|
||||
* @date 2006
|
||||
*
|
||||
*
|
||||
* @brief Weighted Directed Graph Processing Utilities.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
:- module( wdgraphs,
|
||||
@ -35,8 +35,6 @@
|
||||
wdgraph_path/3,
|
||||
wdgraph_reachable/3]).
|
||||
|
||||
/Weighted Directed Graph Processing Utilities.
|
||||
|
||||
:- module( wdgraphs,
|
||||
[
|
||||
wdgraph_new/1,
|
||||
@ -95,11 +93,11 @@
|
||||
wdgraph_reachable/3]).
|
||||
|
||||
/**
|
||||
* @defgroup wdgraphs
|
||||
* @defgroup wdgraphs
|
||||
/**
|
||||
* @defgroup wdgraphs Weighted Directed Graph Processing Utilities.
|
||||
* @ingroup library
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@ -112,7 +110,7 @@
|
||||
|
||||
|
||||
:- use_module(library(dgraphs),
|
||||
[
|
||||
[
|
||||
dgraph_top_sort/2,
|
||||
dgraph_path/3
|
||||
]
|
||||
@ -149,12 +147,12 @@ wdgraph_new(Vertices) :-
|
||||
wdgraph_add_vertices_and_edges(Vs0,Vertices,Edges,Vs2) :-
|
||||
wdgraph_add_vertices(Vs0, Vertices, Vs1),
|
||||
wdgraph_add_edges(Vs1, Edges, Vs2).
|
||||
|
||||
|
||||
|
||||
wdgraph_add_edge(Vs0,V1,V2,Weight,Vs2) :-
|
||||
wdgraph_new_edge(V1,V2,Weight,Vs0,Vs1),
|
||||
dgraph_add_vertex(Vs1,V2,Vs2).
|
||||
|
||||
|
||||
wdgraph_add_edges(V0, Edges, VF) :-
|
||||
rb_empty(V0), !,
|
||||
sort(Edges,SortedEdges),
|
||||
@ -239,7 +237,7 @@ wdgraph_edge(N1, N2, W, G) :-
|
||||
find_edge(N2-W, Ns).
|
||||
|
||||
find_edge(N-W,[N1-W|_]) :- N == N1, !.
|
||||
find_edge(El,[_|Edges]) :-
|
||||
find_edge(El,[_|Edges]) :-
|
||||
find_edge(El,Edges).
|
||||
|
||||
wdgraph_del_edge(Vs0, V1, V2, W, Vs) :-
|
||||
@ -474,7 +472,7 @@ continue_dijkstra(H1, V2, WGraph, Status0, Path0, PathF, D, V0, V, W) :-
|
||||
rb_lookup(V, Edges, WGraph),
|
||||
queue_edges(Edges, V, D, H1, H2),
|
||||
dijkstra(H2, V2, WGraph, Status, [e(V0,V,W)|Path0], PathF).
|
||||
|
||||
|
||||
|
||||
backtrace([], _, Path, Path, Cost, Cost).
|
||||
backtrace([e(V0,V,C)|EPath], V1, Path0, Path, Cost0, Cost) :-
|
||||
@ -510,7 +508,7 @@ continue_dijkstra(H1, WGraph, Status0, Path0, PathF, D, V0, V, W) :-
|
||||
rb_lookup(V, Edges, WGraph),
|
||||
queue_edges(Edges, V, D, H1, H2),
|
||||
dijkstra(H2, WGraph, Status, [V0-(V-W)|Path0], PathF).
|
||||
|
||||
|
||||
wdgraph_path(V, WG, P) :-
|
||||
wdgraph_to_dgraph(WG, G),
|
||||
dgraph_path(V, G, P).
|
||||
|
150
library/ytest.yap
Normal file
150
library/ytest.yap
Normal file
@ -0,0 +1,150 @@
|
||||
|
||||
:- module( ytest, [run_test/1,
|
||||
run_tests/0,
|
||||
test_mode/0,
|
||||
op(1150, fx, test),
|
||||
op(999, xfx, returns)] ).
|
||||
|
||||
:- use_module( clauses ).
|
||||
|
||||
:- multifile test/1.
|
||||
|
||||
:- dynamic error/3, failed/3.
|
||||
|
||||
test_mode.
|
||||
|
||||
user:term_expansion( test( (A, B) ), ytest:test( Lab, Cond, Done ) ) :-
|
||||
info((A,B), Lab, Cond , Done ).
|
||||
|
||||
run_tests :-
|
||||
run_test(_Lab),
|
||||
fail.
|
||||
run_tests :-
|
||||
show_bad.
|
||||
|
||||
run_test(Lab) :-
|
||||
current_module(M,M),
|
||||
test(Lab, (G returns Sols ), Done),
|
||||
ground( Done),
|
||||
format('~w : ',[ Lab ]),
|
||||
reset( Streams ),
|
||||
conj2list( Sols, LSols ),
|
||||
% trace,
|
||||
catch( do_returns(M:G, LSols, Lab), Ball, end( Ball ) ),
|
||||
shutdown( Streams ).
|
||||
|
||||
info((A,B), Lab, Cl, G) :- !,
|
||||
info(A, Lab, Cl, G),
|
||||
info(B, Lab, Cl, G).
|
||||
info(A, _, _, _) :- var(A), !.
|
||||
info(A returns B, _, (A returns B), g(_,ok)) :- !.
|
||||
info(A, A, _, g(ok,_)) :- primitive(A), !.
|
||||
info(_A, _, _, _).
|
||||
|
||||
do_returns(G0 , Sols0, Lab ) :-
|
||||
counter(I),
|
||||
fetch(I, Sols0, Pattern0, Next),
|
||||
Pattern0 = ( V0 =@= Target0),
|
||||
copy_term(G0-V0, G-VGF),
|
||||
catch( answer(G, VGF, Target0, Lab, Sol) , Error, Sol = error(G, Error) ),
|
||||
step( _I, Sols, G0, Sol, Lab ),
|
||||
!.
|
||||
|
||||
answer(G, V, Target0, Lab, answer(G)) :-
|
||||
call(G),
|
||||
( V =@= Target0
|
||||
->
|
||||
success(Lab, V)
|
||||
;
|
||||
failure(V, Target0, Lab)
|
||||
).
|
||||
|
||||
step( I, Sols , G0, Sol, Lab ) :-
|
||||
inc(I),
|
||||
fetch(I, Sols, Pattern, Next),
|
||||
( Sol = answer(_)
|
||||
->
|
||||
true
|
||||
;
|
||||
Sol = error(_, Error)
|
||||
->
|
||||
(
|
||||
nonvar(Pattern ) ,
|
||||
Pattern = ( Error -> G),
|
||||
G
|
||||
->
|
||||
success
|
||||
;
|
||||
error(I, G0, Error, Pattern, Lab )
|
||||
)
|
||||
),
|
||||
(
|
||||
Next == ... -> throw( done )
|
||||
;
|
||||
Next == [] -> throw( done )
|
||||
).
|
||||
% fail
|
||||
|
||||
success( _, _) :-
|
||||
write('.'),
|
||||
flush_output.
|
||||
|
||||
error(_, G, E, _ , Lab) :-
|
||||
write('X'),
|
||||
flush_output,
|
||||
assert( error(Lab,E,G) ).
|
||||
|
||||
failure( G, Pattern, Lab) :-
|
||||
write('X'),
|
||||
flush_output,
|
||||
assert(failed(Lab, G, Pattern)).
|
||||
|
||||
|
||||
reset( _ ) :-
|
||||
nb_setval( counter,( 0 ) ).
|
||||
|
||||
inc( I ) :-
|
||||
nb_getval( counter,( I ) ),
|
||||
I1 is I+1,
|
||||
nb_setval( counter,( I1 ) ).
|
||||
|
||||
counter( I ) :-
|
||||
nb_getval( counter,( I ) ).
|
||||
|
||||
|
||||
shutdown( _Streams ) :-
|
||||
% close_io( Streams ).
|
||||
true.
|
||||
|
||||
test_error( Ball, e( Ball ) ).
|
||||
|
||||
fetch( 0, [ A ], A, []) :-
|
||||
!.
|
||||
fetch( 0, [ A, B | _ ], A, B) :-
|
||||
!.
|
||||
fetch( I0, [ _ | L ] , A, B) :-
|
||||
I0 > 0,
|
||||
I is I0-1,
|
||||
fetch( I, L, A, B ).
|
||||
|
||||
show_bad :-
|
||||
error( Lab, E , B),
|
||||
numbervars(E, 1, _),
|
||||
format( '~n~n~w: error, error ~w.~n', [Lab, E] ),
|
||||
writeln( error: E: B ),
|
||||
fail.
|
||||
show_bad :-
|
||||
failed( Lab, V, P ),
|
||||
numbervars(V, 1, _),
|
||||
numbervars(P, 1, _),
|
||||
format( '~n~n~w: failed, ~w =\\@= ~w.~n', [Lab, V, P] ),
|
||||
fail.
|
||||
show_bad.
|
||||
|
||||
end(done) :-
|
||||
!,
|
||||
nl,
|
||||
fail.
|
||||
end(Ball) :-
|
||||
writeln( bad:Ball ).
|
||||
|
90
library/ytest/preds.yap
Normal file
90
library/ytest/preds.yap
Normal file
@ -0,0 +1,90 @@
|
||||
'$predicate_flags'(P, M, Flags0, Flags1) :-
|
||||
var(Flags0),
|
||||
Flags0 == Flags1,
|
||||
!,
|
||||
(
|
||||
predicate_property(M:P, meta_predicate(_))
|
||||
->
|
||||
Flags1 = 0x200000
|
||||
).
|
||||
'$predicate_flags'(P, M, Flags0, Flags1) :-
|
||||
( Flags1 /\ 0x200000 =\= 0,
|
||||
Flags0 /\ 0x200000 =:= 0
|
||||
->
|
||||
true
|
||||
;
|
||||
Flags1 /\ 0x200000 =\= 0,
|
||||
Flags0 /\ 0x200000 =\= 0
|
||||
).
|
||||
|
||||
'$get_undefined_pred'(G,M,G,M0) :-
|
||||
predicate_property(M:G, imported_from(M0)), !.
|
||||
'$get_undefined_pred'(G,M,G,OM) :-
|
||||
functor(G,F,N),
|
||||
( system_predicate(F/N), OM = prolog ; current_predicate(user:F/N), OM= user), !.
|
||||
'$get_undefined_pred'(G,M,G,M0) :-
|
||||
predicate_property(M:G, imported_from(M0)), !.
|
||||
'$get_undefined_pred'(G,M,G,M).
|
||||
|
||||
'$is_metapredicate'( call(_), _M) :- !.
|
||||
'$is_metapredicate'( call(_,_), _M) :- !.
|
||||
'$is_metapredicate'( G, M) :-
|
||||
predicate_property(M:G, meta_predicate(_)).
|
||||
|
||||
'$imported_predicate'(G,M,G,M0) :-
|
||||
predicate_property(M:G, imported_from(M0)).
|
||||
|
||||
'$system_predicate'( call(_), _M) :- !.
|
||||
'$system_predicate'( call(_,_), _M) :- !.
|
||||
'$system_predicate'(G,M) :-
|
||||
predicate_property(M:G, built_in).
|
||||
|
||||
'$is_multifile'(G,M) :-
|
||||
predicate_property(M:G, multifile).
|
||||
|
||||
'$module_transparent'(_,_,_,_) :- fail.
|
||||
|
||||
'$meta_predicate'(call,_M,1,call(0)) :- !.
|
||||
'$meta_predicate'(call,_M,2,call(1,?)) :- !.
|
||||
'$meta_predicate'(F,M,N,P) :-
|
||||
functor(G, F, N),
|
||||
predicate_property(M:G, meta_predicate(P)).
|
||||
|
||||
user:term_expansion( ( :- '$meta_predicate'( _ ) ), [] ).
|
||||
|
||||
user:goal_expansion(_:'_user_expand_goal'(A, M, B), user:user_expand_goal(A, M, B) ).
|
||||
|
||||
|
||||
|
||||
user_expand_goal(A, M, B) :-
|
||||
(
|
||||
current_predicate(M:goal_expansion/2),
|
||||
M:goal_expansion(A,B) -> true ;
|
||||
system:goal_expansion(A,B) -> true ;
|
||||
user:goal_expansion(A,M,B) -> true ;
|
||||
user:goal_expansion(A,B) -> true
|
||||
).
|
||||
|
||||
user:goal_expansion(prolog:'$meta_predicate'(N,M,A,D) , user:mt( N, M, A, D) ).
|
||||
|
||||
mt(N,M,A,D) :-
|
||||
functor(D,N,A),
|
||||
predicate_property(M:D, meta_predicate(D)).
|
||||
|
||||
|
||||
'$full_clause_optimisation'(_H, _M, B, B).
|
||||
|
||||
'$c_built_in'(G, _SM, _H, G).
|
||||
|
||||
|
||||
'$head_and_body'((H:-B),H,B) :- !.
|
||||
'$head_and_body'(H,H,true).
|
||||
|
||||
'$yap_strip_module'(T,M,S) :-
|
||||
fully_strip_module(T,M,S).
|
||||
|
||||
:- hide( expand_goal ).
|
||||
|
||||
:- include('pl/meta').
|
||||
|
||||
|
10
misc/ATOMS
10
misc/ATOMS
@ -30,6 +30,10 @@ A Assert N ":-"
|
||||
A EmptyBrackets N "()"
|
||||
A EmptySquareBrackets N "[]"
|
||||
A EmptyCurlyBrackets N "{}"
|
||||
A Asserta N "asserta"
|
||||
A AssertaStatic N "asserta_static"
|
||||
A Assertz N "assertz"
|
||||
A AssertzStatic N "assertz_static"
|
||||
A At N "at"
|
||||
A Atom N "atom"
|
||||
A Atomic N "atomic"
|
||||
@ -71,6 +75,7 @@ A CommentHook N "comment_hook"
|
||||
A Compact N "compact"
|
||||
A Compound N "compound"
|
||||
A ConsistencyError N "consistency_error"
|
||||
A Consult N "consult"
|
||||
A ConsultOnBoot F "$consult_on_boot"
|
||||
A Context N "context"
|
||||
A Cputime N "cputime"
|
||||
@ -138,6 +143,7 @@ A FB N "fb"
|
||||
A Fail N "fail"
|
||||
A False N "false"
|
||||
A Fast F "$fast"
|
||||
A FastFail N "fast_fail"
|
||||
A FileErrors N "file_errors"
|
||||
A Fileerrors N "fileerrors"
|
||||
A FileType N "file_type"
|
||||
@ -293,6 +299,7 @@ A Read N "read"
|
||||
A ReadOnly N "read_only"
|
||||
A ReadWrite N "read_write"
|
||||
A Readutil N "readutil"
|
||||
A Reconsult N "reconsult"
|
||||
A RecordedP F "$recordep"
|
||||
A RecordedWithKey F "$recorded_with_key"
|
||||
A RedefineWarnings N "redefine_warnings"
|
||||
@ -395,6 +402,7 @@ A User N "user"
|
||||
A UserErr N "user_error"
|
||||
A UserIn N "user_input"
|
||||
A UserOut N "user_output"
|
||||
A DollarVar N "$VAR"
|
||||
A VBar N "|"
|
||||
A VarBranches N "var_branches"
|
||||
A VariableNames N "variable_names"
|
||||
@ -413,7 +421,7 @@ F AfInet AfInet 2
|
||||
F AfLocal AfLocal 1
|
||||
F AfUnix AfUnix 1
|
||||
F AltNot AltNot 1
|
||||
F Arg Arg 3
|
||||
F Arg Arg 3
|
||||
F ArrayEntry ArrayAccess 3
|
||||
F Arrow Arrow 2
|
||||
F DoubleArrow DoubleArrow 2
|
||||
|
@ -104,6 +104,7 @@ Term globals_module GLOBALS_MODULE MkAT AtomNb
|
||||
Term swi_module SWI_MODULE MkAT AtomSwi
|
||||
Term dbload_module DBLOAD_MODULE MkAT AtomDBLoad
|
||||
Term range_module RANGE_MODULE MkAT AtomRange
|
||||
Term error_module ERROR_MODULE MkAT AtomError
|
||||
|
||||
//
|
||||
// Module list
|
||||
@ -227,9 +228,6 @@ yamop *retry_recorded_k_code RETRY_C_RECORDED_K_CODE =NULL PtoOpAdjust
|
||||
/* compiler flags */
|
||||
int system_profiling PROFILING =FALSE void
|
||||
int system_call_counting CALL_COUNTING =FALSE void
|
||||
int system_pred_goal_expansion_all PRED_GOAL_EXPANSION_ALL =FALSE void
|
||||
int system_pred_goal_expansion_func PRED_GOAL_EXPANSION_FUNC =FALSE void
|
||||
int system_pred_goal_expansion_on PRED_GOAL_EXPANSION_ON =FALSE void
|
||||
int compiler_optimizer_on optimizer_on =TRUE void
|
||||
int compiler_compile_mode compile_mode =0 void
|
||||
int compiler_profiling profiling =FALSE void
|
||||
|
@ -288,8 +288,6 @@ UInt ImportDBRefHashTableNum =0
|
||||
yamop *ImportFAILCODE =NULL
|
||||
|
||||
|
||||
Functor FunctorVar =FunctorVar
|
||||
|
||||
#if __ANDROID__
|
||||
// current virtual directory.
|
||||
struct AAssetManager* assetManager =GLOBAL_assetManager
|
||||
|
@ -1,7 +1,8 @@
|
||||
|
||||
:- use_module(library(lineutils),
|
||||
[file_filter_with_init/5,
|
||||
split/3]).
|
||||
file_filter_with_initialization/5,
|
||||
split_unquoted/3]).
|
||||
|
||||
:- use_module(library(lists),
|
||||
[append/2]).
|
||||
@ -19,47 +20,47 @@ main :-
|
||||
warning('~n /* This file, ~a, was generated automatically by \"yap -L misc/buildatoms\"~n please do not update, update misc/ATOMS instead */~n~n').
|
||||
|
||||
gen_fields(Inp,Out) :-
|
||||
split(Inp," ",["A",Atom,_,_]), !,
|
||||
split_unquoted(Inp," ",["A",Atom,_,_]), !,
|
||||
append([" Atom Atom",Atom,"_;\n#define Atom",Atom," Yap_heap_regs->Atom",Atom,"_\n",
|
||||
"#define Term",Atom," MkAtomTerm( Yap_heap_regs->Atom",Atom,"_ )"],Out).
|
||||
%gen_fields(Inp,Out) :-
|
||||
% split(Inp," ",["A",Atom,_]), !,
|
||||
% split_unquoted(Inp," ",["A",Atom,_]), !,
|
||||
% append([" Atom Atom_",Atom,"_;\n#define Atom_",Atom," Yap_heap_regs->Atom_",Atom,"_"],Out).
|
||||
gen_fields(Inp,Out) :-
|
||||
split(Inp," ",["F",Name,_,_]), !,
|
||||
split_unquoted(Inp," ",["F",Name,_,_]), !,
|
||||
append([" Functor Functor",Name,"_;\n#define Functor",Name," Yap_heap_regs->Functor",Name,"_"],Out).
|
||||
%gen_fields(Inp,Out) :-
|
||||
% split(Inp," ",["F",Name,Arity]), !,
|
||||
% split_unquoted(Inp," ",["F",Name,Arity]), !,
|
||||
% append([" Functor Functor_",Name,Arity,"_;\n#define Functor_",Name,Arity," Yap_heap_regs->Functor_",Name,Arity,"_"],Out).
|
||||
|
||||
gen_rcov(Inp,Out) :-
|
||||
split(Inp," ",["A",Atom,_,_]), !,
|
||||
split_unquoted(Inp," ",["A",Atom,_,_]), !,
|
||||
append([" Atom",Atom," = AtomAdjust(Atom",Atom,");"],Out).
|
||||
%gen_rcov(Inp,Out) :-
|
||||
% split(Inp," ",["A",Atom,_]), !,
|
||||
% split_unquoted(Inp," ",["A",Atom,_]), !,
|
||||
% append([" Atom_",Atom," = AtomAdjust(Atom_",Atom,");"],Out).
|
||||
gen_rcov(Inp,Out) :-
|
||||
split(Inp," ",["F",Functor,_,_]), !,
|
||||
split_unquoted(Inp," ",["F",Functor,_,_]), !,
|
||||
append([" Functor",Functor," = FuncAdjust(Functor",Functor,");"],Out).
|
||||
%gen_rcov(Inp,Out) :-
|
||||
% split(Inp," ",["F",Functor,Arity]), !,
|
||||
% split_unquoted(Inp," ",["F",Functor,Arity]), !,
|
||||
% append([" Functor_",Functor,Arity," = FuncAdjust(Functor_",Functor,Arity,");"],Out).
|
||||
|
||||
gen_decl(Inp,Out) :-
|
||||
split(Inp," ",["A",Atom,"N",String]), !,
|
||||
split_unquoted(Inp," ",["A",Atom,"N",String]), !,
|
||||
append([" Atom",Atom," = Yap_LookupAtom(",String,");"],Out).
|
||||
gen_decl(Inp,Out) :-
|
||||
split(Inp," ",["A",Atom,"F",String]), !,
|
||||
split_unquoted(Inp," ",["A",Atom,"F",String]), !,
|
||||
append([" Atom",Atom," = Yap_FullLookupAtom(",String,");"],Out).
|
||||
%gen_decl(Inp,Out) :-
|
||||
% split(Inp," ",["A",Atom,String]), String = [0'",0'$|_], !,
|
||||
% split_unquoted(Inp," ",["A",Atom,String]), String = [0'",0'$|_], !,
|
||||
% append([" Atom_",Atom," = Yap_FullLookupAtom(",String,");"],Out).
|
||||
%gen_decl(Inp,Out) :-
|
||||
% split(Inp," ",["A",Atom,String]), !,
|
||||
% split_unquoted(Inp," ",["A",Atom,String]), !,
|
||||
% append([" Atom_",Atom," = Yap_LookupAtom(",String,");"],Out).
|
||||
gen_decl(Inp,Out) :-
|
||||
split(Inp," ",["F",Name,Atom,Arity]), !,
|
||||
split_unquoted(Inp," ",["F",Name,Atom,Arity]), !,
|
||||
append([" Functor",Name," = Yap_MkFunctor(Atom",Atom,",",Arity,");"],Out).
|
||||
%gen_decl(Inp,Out) :-
|
||||
% split(Inp," ",["F",Name,Arity]), !,
|
||||
% split_unquoted(Inp," ",["F",Name,Arity]), !,
|
||||
% append([" Functor_",Name,Arity," = Yap_MkFunctor(Atom_",Name,",",Arity,");"],Out).
|
||||
|
@ -16,18 +16,18 @@
|
||||
:- initialization main.
|
||||
|
||||
main :-
|
||||
unix( argv(L) ),
|
||||
unix( argv(L0 ) ),
|
||||
(L0 == [] -> L = [.] ; L = L0 ),
|
||||
member( Lib, L ),
|
||||
absolute_file_name( Lib, NL, [glob('*.pl *.yap'),file_type(prolog), file_errors(fail), solutions(all)] ),
|
||||
% current_module(M), writeln(M:NL),
|
||||
catch( ensure_loaded(library( NL )) , _, (writeln(crash:NL), module(user))),
|
||||
%current_module(M), writeln(M:x:NL),
|
||||
catch( ensure_loaded( NL ) , Error, (format('crash ~w in ~a~n',[Error,NL]), module(user) ) ),
|
||||
fail.
|
||||
|
||||
main :-
|
||||
unix( argv(L) ),
|
||||
member( Lib, L ),
|
||||
absolute_file_name( Lib, NL, [glob('*.pl *.yap'),file_type(prolog), file_errors(fail), solutions(all)] ),
|
||||
writeln( NL ),
|
||||
module_property( Mod, file( NL )),
|
||||
module_property( Mod, exports( Preds )),
|
||||
file_base_name( NL, NameF),
|
||||
@ -39,4 +39,3 @@ main :-
|
||||
main.
|
||||
|
||||
out(N/A) :- format(' - ~q~n', [N/A]).
|
||||
|
||||
|
@ -17,8 +17,23 @@
|
||||
#ifdef SCCS
|
||||
static char SccsId[] = "%W% %G%";
|
||||
#endif
|
||||
/**
|
||||
* @file chartypes.c
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP.lan>
|
||||
* @date Thu Nov 19 12:05:14 2015
|
||||
*
|
||||
* @brief Character Properties
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
///{@
|
||||
|
||||
|
||||
/// @addtogroup CharProps
|
||||
|
||||
/*
|
||||
* This file includes the definition of a pipe related IO.
|
||||
* This file includes the definition of a character properties.
|
||||
*
|
||||
*/
|
||||
|
||||
@ -98,7 +113,12 @@ static enc_map_t ematches[] = {
|
||||
{"Windows-1252", ENC_ISO_LATIN1}, // almost, but not quite
|
||||
{"CP-1252", ENC_ISO_LATIN1},
|
||||
{"C", ENC_ISO_ASCII},
|
||||
{NULL, ENC_OCTET}};
|
||||
#ifdef _WIN32
|
||||
{NULL, ENC_UTF16_LE}
|
||||
#else
|
||||
{NULL, ENC_ISO_UTF8}
|
||||
#endif
|
||||
};
|
||||
|
||||
static encoding_t DefaultEncoding(void) {
|
||||
encoding_t rc;
|
||||
@ -134,7 +154,7 @@ static encoding_t DefaultEncoding(void) {
|
||||
int j = 0;
|
||||
while (rc != ematches[j].e)
|
||||
j++;
|
||||
Yap_Warning("YAP will use default encoding %s", ematches[j].s);
|
||||
// Yap_Warning("YAP will use default encoding %s", ematches[j].s);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
@ -822,7 +842,7 @@ static Int p_all_char_conversions(USES_REGS1) {
|
||||
|
||||
void Yap_InitChtypes(void) {
|
||||
CACHE_REGS
|
||||
DefaultEncoding();
|
||||
LOCAL_encoding = DefaultEncoding();
|
||||
Yap_InitCPred("$change_type_of_char", 2, p_change_type_of_char,
|
||||
SafePredFlag | SyncPredFlag | HiddenPredFlag);
|
||||
Yap_InitCPred("toupper", 2, toupper2, SafePredFlag);
|
||||
|
@ -66,12 +66,12 @@ console_post_process_read_char(int ch, StreamDesc *s)
|
||||
++s->linecount;
|
||||
++s->charcount;
|
||||
s->linepos = 0;
|
||||
LOCAL_newline = TRUE;
|
||||
LOCAL_newline = true;
|
||||
} else {
|
||||
CACHE_REGS
|
||||
++s->charcount;
|
||||
++s->linepos;
|
||||
LOCAL_newline = FALSE;
|
||||
LOCAL_newline = false;
|
||||
}
|
||||
return ch;
|
||||
}
|
||||
@ -122,6 +122,7 @@ ConsolePutc (int sno, int ch)
|
||||
if (ch == 10)
|
||||
{
|
||||
putc ('\n', s->file);
|
||||
LOCAL_newline = true;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*************************************************************************
|
||||
/*************************************************************************
|
||||
* *
|
||||
* YAP Prolog *
|
||||
* *
|
||||
@ -166,6 +166,7 @@ bool Yap_ReadlineOps(StreamDesc *s) {
|
||||
is_same_tty(s->file, GLOBAL_Stream[0].file))
|
||||
s->stream_putc = ReadlinePutc;
|
||||
s->stream_getc = ReadlineGetc;
|
||||
s->status |= Readline_Stream_f;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -231,11 +232,11 @@ static bool getLine(int inp, int out) {
|
||||
/* window of vulnerability opened */
|
||||
LOCAL_PrologMode |= ConsoleGetcMode;
|
||||
|
||||
if (GLOBAL_Stream[out].linepos == 0) { // no output so far
|
||||
fflush(NULL);
|
||||
fflush(NULL);
|
||||
LOCAL_PrologMode |= ConsoleGetcMode;
|
||||
if (LOCAL_newline) { // no output so far
|
||||
myrl_line = readline(LOCAL_Prompt);
|
||||
} else {
|
||||
LOCAL_PrologMode |= ConsoleGetcMode;
|
||||
myrl_line = readline(NULL);
|
||||
}
|
||||
/* Do it the gnu way */
|
||||
@ -277,9 +278,11 @@ static int ReadlinePutc(int sno, int ch) {
|
||||
return ((int)ch);
|
||||
}
|
||||
|
||||
/*
|
||||
reading from the console is complicated because we need to
|
||||
/**
|
||||
@brief reading from the console is complicated because we need to
|
||||
know whether to prompt and so on...
|
||||
|
||||
EOF must be handled by resetting the file.
|
||||
*/
|
||||
static int ReadlineGetc(int sno) {
|
||||
StreamDesc *s = &GLOBAL_Stream[sno];
|
||||
|
@ -351,6 +351,12 @@ Term Yap_syntax_error(TokEntry *errtok, int sno) {
|
||||
tn[0] = Yap_MkApplTerm(FunctorShortSyntaxError, 1, &terr);
|
||||
tn[1] = TermNil;
|
||||
terr = Yap_MkApplTerm(FunctorError, 2, tn);
|
||||
#if DEBUG
|
||||
if (Yap_ExecutionMode == YAP_BOOT_MODE) {
|
||||
fprintf(stderr, "SYNTAX ERROR while booting: ");
|
||||
Yap_DebugPlWriteln( terr );
|
||||
}
|
||||
#endif
|
||||
return terr;
|
||||
}
|
||||
|
||||
@ -365,6 +371,7 @@ typedef struct FEnv {
|
||||
xarg *args; /// input args
|
||||
bool reading_clause; /// read_clause
|
||||
size_t nargs; /// arity of current procedure
|
||||
encoding_t enc; /// encoding of the stream being read
|
||||
} FEnv;
|
||||
|
||||
typedef struct renv {
|
||||
@ -388,6 +395,7 @@ static xarg *setReadEnv(Term opts, FEnv *fe, struct renv *re, int inp_stream) {
|
||||
LOCAL_VarTable = NULL;
|
||||
LOCAL_AnonVarTable = NULL;
|
||||
re->cm = CurrentModule;
|
||||
fe->enc = GLOBAL_Stream[inp_stream].encoding;
|
||||
xarg *args = Yap_ArgListToVector(opts, read_defs, READ_END);
|
||||
if (args == NULL) {
|
||||
return NULL;
|
||||
@ -651,7 +659,8 @@ static parser_state_t scan(REnv *re, FEnv *fe, int inp_stream) {
|
||||
/* preserve value of H after scanning: otherwise we may lose strings
|
||||
and floats */
|
||||
LOCAL_tokptr = LOCAL_toktide =
|
||||
Yap_tokenizer(GLOBAL_Stream + inp_stream, false, &fe->tpos);
|
||||
|
||||
Yap_tokenizer(GLOBAL_Stream + inp_stream, false, &fe->tpos);
|
||||
if (LOCAL_ErrorMessage)
|
||||
return YAP_SCANNING_ERROR;
|
||||
if (LOCAL_tokptr->Tok != Ord(eot_tok)) {
|
||||
@ -737,8 +746,10 @@ static parser_state_t parseError(REnv *re, FEnv *fe, int inp_stream) {
|
||||
static parser_state_t parse(REnv *re, FEnv *fe, int inp_stream) {
|
||||
CACHE_REGS
|
||||
TokEntry *tokstart = LOCAL_tokptr;
|
||||
|
||||
encoding_t e = LOCAL_encoding;
|
||||
LOCAL_encoding = fe->enc;
|
||||
fe->t = Yap_Parse(re->prio);
|
||||
LOCAL_encoding = e;
|
||||
fe->toklast = LOCAL_tokptr;
|
||||
LOCAL_tokptr = tokstart;
|
||||
TR = (tr_fr_ptr)tokstart;
|
||||
|
2
os/sig.c
2
os/sig.c
@ -902,7 +902,7 @@ MSCHandleSignal(DWORD dwCtrlType) {
|
||||
" stb %g0, [%g1 + 3]\n"
|
||||
" retl\n"
|
||||
" mov %g4, %o7\n"
|
||||
);
|
||||
);
|
||||
}
|
||||
#endif /* sparc */
|
||||
|
||||
|
35
os/sysbits.c
35
os/sysbits.c
@ -587,11 +587,12 @@ PrologExpandVars(const char *spec, char *tmp0, bool ok_to)
|
||||
{
|
||||
tmp=expandVars(spec,tmp,YAP_FILENAME_MAX);
|
||||
}
|
||||
else
|
||||
else {
|
||||
if (tmp != tmp0) {
|
||||
free(tmp);
|
||||
tmp = (char *)spec;
|
||||
}
|
||||
tmp = (char *)spec;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
@ -751,8 +752,9 @@ do_expand_file_name(Term t1, Term opts USES_REGS)
|
||||
}
|
||||
tmpe = expandVars( spec, tmpe, YAP_FILENAME_MAX);
|
||||
#ifdef GLOB_BRACE
|
||||
flags = GLOB_BRACE;
|
||||
flags = GLOB_BRACE|GLOB_TILDE;
|
||||
#endif
|
||||
flags |= GLOB_NOCHECK;
|
||||
spec = tmpe;
|
||||
} else if (t == TermTrue) {
|
||||
use_glob = false;
|
||||
@ -810,10 +812,17 @@ do_expand_file_name(Term t1, Term opts USES_REGS)
|
||||
case 0: /* Successful. */
|
||||
ss = gresult.gl_pathv;
|
||||
pathcount = gresult.gl_pathc;
|
||||
break;
|
||||
if (pathcount) {
|
||||
break;
|
||||
}
|
||||
case GLOB_NOMATCH:
|
||||
globfree(&gresult);
|
||||
return Yap_unify_constant(TermNil, ARG2);
|
||||
{
|
||||
Term t;
|
||||
char *out = LOCAL_FileNameBuf;
|
||||
t = MkAtomTerm( Yap_LookupAtom( expandVars(spec, out, YAP_FILENAME_MAX-1) ));
|
||||
return MkPairTerm( t, TermNil );
|
||||
}
|
||||
case GLOB_ABORTED:
|
||||
PlIOError(SYSTEM_ERROR_OPERATING_SYSTEM, ARG1, "glob aborted: %sn", strerror(errno));
|
||||
globfree (&gresult);
|
||||
@ -836,7 +845,15 @@ do_expand_file_name(Term t1, Term opts USES_REGS)
|
||||
case 0: /* Successful. */
|
||||
ss = wresult.we_wordv;
|
||||
pathcount = wresult.we_wordc;
|
||||
break;
|
||||
if (pathcount) {
|
||||
break;
|
||||
} else {
|
||||
Term t;
|
||||
char *out = LOCAL_FileNameBuf;
|
||||
t = MkAtomTerm( Yap_LookupAtom( expandVars(spec, out, YAP_FILENAME_MAX-1) ) );
|
||||
wordfree (&wresult);
|
||||
return MkPairTerm( t, TermNil );
|
||||
}
|
||||
case WRDE_NOSPACE:
|
||||
/* If the error was WRDE_NOSPACE,
|
||||
then perhaps part of the result was allocated. */
|
||||
@ -844,7 +861,7 @@ do_expand_file_name(Term t1, Term opts USES_REGS)
|
||||
wordfree (&wresult);
|
||||
return TermNil;
|
||||
default: /* Some other error. */
|
||||
PlIOError(SYSTEM_ERROR_OPERATING_SYSTEM, ARG1, "wordexp failed: %s", strerror(errno));
|
||||
; PlIOError(SYSTEM_ERROR_OPERATING_SYSTEM, ARG1, "wordexp failed: %s", strerror(errno));
|
||||
wordfree (&wresult);
|
||||
return TermNil;
|
||||
}
|
||||
@ -856,8 +873,8 @@ do_expand_file_name(Term t1, Term opts USES_REGS)
|
||||
#if HAVE_REALPATH
|
||||
s = myrealpath(s, tmp);
|
||||
#endif
|
||||
if (!exists(s))
|
||||
continue;
|
||||
//if (!exists(s))
|
||||
// continue;
|
||||
Atom a = Yap_LookupAtom(s);
|
||||
tf = MkPairTerm(MkAtomTerm( a ),tf);
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ all_tuples(Constraints, Tuple, Tuples) :-
|
||||
|
||||
|
||||
run([]).
|
||||
run(Goal.Constraints) :-
|
||||
run([Goal|Constraints]) :-
|
||||
user:Goal,
|
||||
run(Constraints).
|
||||
|
||||
|
@ -291,7 +291,7 @@ propagate_evidence(InterpretationID,Query_Type) :-
|
||||
% iterate over all evidence atoms
|
||||
forall(user:known(InterpretationID,Atom,Value),
|
||||
(
|
||||
catch( rounder_compute_reachable_atoms(Atom,InterpretationID,Success), _, fail),
|
||||
catch( grounder_compute_reachable_atoms(Atom,InterpretationID,Success), _, fail),
|
||||
(
|
||||
(Success==true; Value==false)
|
||||
->
|
||||
@ -385,7 +385,6 @@ propagate_evidence(InterpretationID,Query_Type) :-
|
||||
print_script_per_cluster([],_,_,Seen_Atoms,Seen_Atoms,Cluster_IDs,Cluster_IDs).
|
||||
print_script_per_cluster([Refs|T],InterpretationID,Cluster_ID,Old_Seen_Atoms,Seen_Atoms,Old_Cluster_IDs,Cluster_IDs) :-
|
||||
create_bdd_file_name(InterpretationID,Cluster_ID,File_Name),
|
||||
%trace,
|
||||
once(print_simplecudd_script(Refs,File_Name,This_Seen_Atoms)),
|
||||
New_Seen_Atoms is Old_Seen_Atoms+This_Seen_Atoms,
|
||||
Next_Cluster_ID is Cluster_ID+1,
|
||||
|
@ -261,7 +261,6 @@
|
||||
:- style_check(all).
|
||||
:- yap_flag(unknown,error).
|
||||
|
||||
|
||||
% this is a test to determine whether YAP provides the needed trie library
|
||||
:- initialization(
|
||||
( predicate_property(trie_disable_hash, imported_from(tries)) ->
|
||||
|
@ -730,8 +730,8 @@ update_query(QueryID,Symbol,What_To_Update) :-
|
||||
problog_flag(sigmoid_slope,Slope),
|
||||
problog_dir(PD),
|
||||
((What_To_Update=all;query_is_similar(_,QueryID)) -> Method='g' ; Method='l'),
|
||||
atomic_concat([PD,
|
||||
'/problogbdd',
|
||||
convert_filename_to_problog_path('problogbdd', ProblogBDD),
|
||||
atomic_concat([ProblogBDD,
|
||||
' -i "', Probabilities_File, '"',
|
||||
' -l "', Query_Directory,'/query_',QueryID, '"',
|
||||
' -m ', Method,
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user