Merge /Users/vsc/tmp/yap-6.3w
This commit is contained in:
24
C/absmi.c
24
C/absmi.c
@@ -644,7 +644,7 @@ push_live_regs(yamop *pco)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ANALYST) || defined(DEBUG)
|
||||
#if USE_THREADED_CODE && (defined(ANALYST) || defined(DEBUG))
|
||||
|
||||
char *Yap_op_names[] =
|
||||
{
|
||||
@@ -1066,27 +1066,27 @@ static void
|
||||
execute_dealloc( USES_REGS1 )
|
||||
{
|
||||
/* other instructions do depend on S being set by deallocate
|
||||
:-( */
|
||||
CELL *ENV_YREG = YENV;
|
||||
S = ENV_YREG;
|
||||
CP = (yamop *) ENV_YREG[E_CP];
|
||||
ENV = ENV_YREG = (CELL *) ENV_YREG[E_E];
|
||||
*/
|
||||
CELL *ENVYREG = YENV;
|
||||
S = ENVYREG;
|
||||
CP = (yamop *) ENVYREG[E_CP];
|
||||
ENV = ENVYREG = (CELL *) ENVYREG[E_E];
|
||||
#ifdef DEPTH_LIMIT
|
||||
DEPTH = ENV_YREG[E_DEPTH];
|
||||
DEPTH = ENVYREG[E_DEPTH];
|
||||
#endif /* DEPTH_LIMIT */
|
||||
#ifdef FROZEN_STACKS
|
||||
{
|
||||
choiceptr top_b = PROTECT_FROZEN_B(B);
|
||||
#ifdef YAPOR_SBA
|
||||
if (ENV_YREG > (CELL *) top_b || ENV_YREG < HR) ENV_YREG = (CELL *) top_b;
|
||||
if (ENVYREG > (CELL *) top_b || ENVYREG < HR) ENVYREG = (CELL *) top_b;
|
||||
#else
|
||||
if (ENV_YREG > (CELL *) top_b) ENV_YREG = (CELL *) top_b;
|
||||
if (ENVYREG > (CELL *) top_b) ENVYREG = (CELL *) top_b;
|
||||
#endif /* YAPOR_SBA */
|
||||
else ENV_YREG = (CELL *)((CELL) ENV_YREG + ENV_Size(CP));
|
||||
else ENVYREG = (CELL *)((CELL) ENVYREG + ENV_Size(CP));
|
||||
}
|
||||
#else
|
||||
if (ENV_YREG > (CELL *) B)
|
||||
ENV_YREG = (CELL *) B;
|
||||
if (ENVYREG > (CELL *) B)
|
||||
ENVYREG = (CELL *) B;
|
||||
else
|
||||
ENV_YREG = (CELL *) ((CELL) ENV_YREG + ENV_Size(CP));
|
||||
#endif /* FROZEN_STACKS */
|
||||
|
||||
66
C/adtdefs.c
66
C/adtdefs.c
@@ -562,62 +562,62 @@ Yap_OpPropForModule(Atom a,
|
||||
return info;
|
||||
}
|
||||
|
||||
static OpEntry *
|
||||
fetchOpWithModule( PropEntry *pp, Term tmod, op_type type )
|
||||
{
|
||||
OpEntry *
|
||||
Yap_GetOpProp(Atom a,
|
||||
op_type type
|
||||
USES_REGS) { /* look property list of atom a for kind */
|
||||
AtomEntry *ae = RepAtom(a);
|
||||
PropEntry *pp;
|
||||
OpEntry *oinfo = NULL;
|
||||
|
||||
READ_LOCK(ae->ARWLock);
|
||||
pp = RepProp(ae->PropsOfAE);
|
||||
while (!EndOfPAEntr(pp)) {
|
||||
OpEntry *info = NULL;
|
||||
|
||||
if (pp->KindOfPE != OpProperty) {
|
||||
pp = RepProp(pp->NextOfPE);
|
||||
continue;
|
||||
}
|
||||
info = (OpEntry *)pp;
|
||||
if (info->OpModule != tmod) {
|
||||
if (info->OpModule != CurrentModule && info->OpModule != PROLOG_MODULE) {
|
||||
pp = RepProp(pp->NextOfPE);
|
||||
continue;
|
||||
}
|
||||
if (type == INFIX_OP) {
|
||||
if (!info->Infix) {
|
||||
return NULL;
|
||||
pp = RepProp(pp->NextOfPE);
|
||||
continue;
|
||||
}
|
||||
} else if (type == POSFIX_OP) {
|
||||
if (!info->Posfix) {
|
||||
return NULL;
|
||||
pp = RepProp(pp->NextOfPE);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (!info->Prefix) {
|
||||
return NULL;
|
||||
pp = RepProp(pp->NextOfPE);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return info;
|
||||
/* if it is not the latest module */
|
||||
if (info->OpModule == PROLOG_MODULE) {
|
||||
/* cannot commit now */
|
||||
oinfo = info;
|
||||
pp = RepProp(pp->NextOfPE);
|
||||
} else {
|
||||
READ_LOCK(info->OpRWLock);
|
||||
READ_UNLOCK(ae->ARWLock);
|
||||
return info;
|
||||
}
|
||||
}
|
||||
if (oinfo) {
|
||||
READ_LOCK(oinfo->OpRWLock);
|
||||
READ_UNLOCK(ae->ARWLock);
|
||||
return oinfo;
|
||||
}
|
||||
READ_UNLOCK(ae->ARWLock);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
OpEntry *
|
||||
Yap_GetOpProp(Atom a,
|
||||
op_type type,
|
||||
Term tmod
|
||||
USES_REGS) { /* look property list of atom a for kind */
|
||||
AtomEntry *ae = RepAtom(a);
|
||||
PropEntry *pp;
|
||||
OpEntry *info;
|
||||
|
||||
READ_LOCK(ae->ARWLock);
|
||||
pp = RepProp(ae->PropsOfAE);
|
||||
if (( (info = fetchOpWithModule( pp, tmod, type )) != NULL) ||
|
||||
( (info = fetchOpWithModule( pp, USER_MODULE, type )) != NULL) ||
|
||||
( (info = fetchOpWithModule( pp, PROLOG_MODULE, type )) != NULL)
|
||||
) {
|
||||
LOCK(info->OpRWLock);
|
||||
return info;
|
||||
READ_UNLOCK(ae->ARWLock);
|
||||
}
|
||||
READ_UNLOCK(ae->ARWLock);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inline static Prop GetPredPropByAtomHavingLock(AtomEntry *ae, Term cur_mod)
|
||||
/* get predicate entry for ap/arity; create it if neccessary. */
|
||||
|
||||
1792
C/atomic.c
1792
C/atomic.c
File diff suppressed because it is too large
Load Diff
@@ -83,7 +83,7 @@ X_API int YAP_Reset(yap_reset_t mode);
|
||||
#define strncat(X, Y, Z) strcat(X, Y)
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if defined(_WIN32) && !defined(X_API)
|
||||
#define X_API __declspec(dllexport)
|
||||
#endif
|
||||
|
||||
@@ -2345,7 +2345,7 @@ static void construct_init_file(char *boot_file, char *BootFile) {
|
||||
|
||||
#define BOOT_FROM_SAVED_STATE TRUE
|
||||
|
||||
X_API Int YAP_Init(YAP_init_args *yap_init) {
|
||||
Int YAP_Init(YAP_init_args *yap_init) {
|
||||
int restore_result;
|
||||
int do_bootstrap = (yap_init->YapPrologBootFile != NULL);
|
||||
CELL Trail = 0, Stack = 0, Heap = 0, Atts = 0;
|
||||
|
||||
14
C/flags.c
14
C/flags.c
@@ -1018,13 +1018,13 @@ Term Yap_UnknownFlag(Term mod) {
|
||||
mod = TermProlog;
|
||||
|
||||
ModEntry *fv = Yap_GetModuleEntry(mod);
|
||||
if (fv == NULL)
|
||||
fv = Yap_GetModuleEntry(TermUser);
|
||||
if (fv->flags & UNKNOWN_ERROR)
|
||||
return TermError;
|
||||
if (fv->flags & UNKNOWN_WARNING)
|
||||
return TermWarning;
|
||||
return TermFail;
|
||||
if (fv == NULL)
|
||||
fv = Yap_GetModuleEntry(AtomUser);
|
||||
if (fv->flags & UNKNOWN_ERROR)
|
||||
return TermError;
|
||||
if (fv->flags & UNKNOWN_WARNING)
|
||||
return TermWarning;
|
||||
return TermFail;
|
||||
}
|
||||
|
||||
Term getYapFlag(Term tflag) {
|
||||
|
||||
@@ -2035,7 +2035,7 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, bool very_verbose
|
||||
#endif /* TABLING */
|
||||
if (very_verbose) {
|
||||
PredEntry *pe = Yap_PredForChoicePt(gc_B, NULL);
|
||||
#if defined(ANALYST) || DEBUG
|
||||
#if defined(ANALYST) || 0
|
||||
if (pe == NULL) {
|
||||
fprintf(stderr,"%% marked " UInt_FORMAT " (%s)\n", LOCAL_total_marked, Yap_op_names[opnum]);
|
||||
} else if (pe->ArityOfPE) {
|
||||
|
||||
54
C/init.c
54
C/init.c
@@ -196,52 +196,6 @@ int Yap_IsOpType(char *type) {
|
||||
return (i <= 7);
|
||||
}
|
||||
|
||||
static OpEntry *
|
||||
fetchOpForModule(AtomEntry *ae, Term tmod )
|
||||
{
|
||||
OpEntry *oinfo = NULL;
|
||||
PropEntry **prev = &ae->PropsOfAE;
|
||||
PropEntry *pp = ae->PropsOfAE;
|
||||
|
||||
while (!EndOfPAEntr(pp)) {
|
||||
OpEntry *info = RepOpProp(pp);
|
||||
if (!info)
|
||||
return NULL;
|
||||
if (pp->KindOfPE == OpProperty) {
|
||||
if (tmod == PROLOG_MODULE) {
|
||||
if (info->OpModule != PROLOG_MODULE) {
|
||||
info->Infix = info->Prefix = info->Posfix = 0;
|
||||
info->OpModule = tmod;
|
||||
if (oinfo == NULL)
|
||||
oinfo = info;
|
||||
else {
|
||||
pp = RepProp(pp->NextOfPE);
|
||||
*prev = pp;
|
||||
//Yap_FreeCodeSpace( oinfo );
|
||||
continue;
|
||||
}
|
||||
} else{
|
||||
if (oinfo) {
|
||||
// should never happen?
|
||||
oinfo->Infix = info->Infix;
|
||||
oinfo->Prefix = info->Prefix;
|
||||
oinfo->Posfix = info->Posfix;
|
||||
pp = RepProp(pp->NextOfPE);
|
||||
*prev = pp;
|
||||
// Yap_FreeCodeSpace( oinfo );
|
||||
continue;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
} else if (info->OpModule == tmod)
|
||||
return info;
|
||||
}
|
||||
prev = & pp->NextOfPE;
|
||||
pp = RepProp(pp->NextOfPE);
|
||||
}
|
||||
return oinfo;
|
||||
}
|
||||
|
||||
static int OpDec(int p, const char *type, Atom a, Term m) {
|
||||
int i;
|
||||
AtomEntry *ae = RepAtom(a);
|
||||
@@ -249,6 +203,8 @@ static int OpDec(int p, const char *type, Atom a, Term m) {
|
||||
|
||||
if (m == TermProlog)
|
||||
m = PROLOG_MODULE;
|
||||
else if (m == USER_MODULE)
|
||||
m = PROLOG_MODULE;
|
||||
for (i = 1; i <= 7; ++i)
|
||||
if (strcmp(type, optypes[i]) == 0)
|
||||
break;
|
||||
@@ -264,7 +220,7 @@ static int OpDec(int p, const char *type, Atom a, Term m) {
|
||||
p |= DcrrpFlag;
|
||||
}
|
||||
WRITE_LOCK(ae->ARWLock);
|
||||
info = fetchOpForModule(ae, m);
|
||||
info = Yap_GetOpPropForAModuleHavingALock(ae, m);
|
||||
if (EndOfPAEntr(info)) {
|
||||
info = (OpEntry *)Yap_AllocAtomSpace(sizeof(OpEntry));
|
||||
info->KindOfPE = Ord(OpProperty);
|
||||
@@ -283,7 +239,6 @@ static int OpDec(int p, const char *type, Atom a, Term m) {
|
||||
WRITE_LOCK(info->OpRWLock);
|
||||
WRITE_UNLOCK(ae->ARWLock);
|
||||
}
|
||||
|
||||
if (i <= 3) {
|
||||
if (trueGlobalPrologFlag(ISO_FLAG) &&
|
||||
info->Posfix != 0) /* there is a posfix operator */ {
|
||||
@@ -294,6 +249,7 @@ static int OpDec(int p, const char *type, Atom a, Term m) {
|
||||
}
|
||||
info->Infix = p;
|
||||
} else if (i <= 5) {
|
||||
|
||||
if (trueGlobalPrologFlag(ISO_FLAG) &&
|
||||
info->Infix != 0) /* there is an infix operator */ {
|
||||
/* ISO dictates */
|
||||
@@ -441,7 +397,7 @@ static void InitOps(void) {
|
||||
/// @}
|
||||
|
||||
#if DEBUG
|
||||
#ifdef HAVE_ISATTY
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -52,7 +52,6 @@ initMod( AtomEntry *toname, AtomEntry *ae) {
|
||||
n->KindOfPE = ModProperty;
|
||||
n->PredForME = NULL;
|
||||
n->NextME = CurrentModules;
|
||||
n->ParentForME = CurrentModule;
|
||||
CurrentModules = n;
|
||||
n->AtomOfME = ae;
|
||||
n->OwnerFile = Yap_ConsultingFile( PASS_REGS1);
|
||||
@@ -260,6 +259,7 @@ static Int change_module(USES_REGS1) { /* $change_module(N) */
|
||||
Term mod = Deref(ARG1);
|
||||
LookupModule(mod);
|
||||
CurrentModule = mod;
|
||||
LOCAL_SourceModule = mod;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
113
C/parser.c
113
C/parser.c
@@ -164,9 +164,9 @@ 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, Term CACHE_TYPE);
|
||||
static Term ParseList(JMPBUFF *, Term CACHE_TYPE);
|
||||
static Term ParseTerm(int, JMPBUFF *, Term 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);
|
||||
|
||||
@@ -367,12 +367,16 @@ Term Yap_Variables(VarEntry *p, Term l) {
|
||||
return Variables(p, l PASS_REGS);
|
||||
}
|
||||
|
||||
static int IsPrefixOp(Atom op, int *pptr, int *rpptr, Term tmod USES_REGS) {
|
||||
static int IsPrefixOp(Atom op, int *pptr, int *rpptr USES_REGS) {
|
||||
int p;
|
||||
|
||||
OpEntry *opp = Yap_GetOpProp(op, PREFIX_OP, tmod PASS_REGS);
|
||||
OpEntry *opp = Yap_GetOpProp(op, PREFIX_OP PASS_REGS);
|
||||
if (!opp)
|
||||
return FALSE;
|
||||
if (opp->OpModule && opp->OpModule != CurrentModule) {
|
||||
READ_UNLOCK(opp->OpRWLock);
|
||||
return FALSE;
|
||||
}
|
||||
if ((p = opp->Prefix) != 0) {
|
||||
READ_UNLOCK(opp->OpRWLock);
|
||||
*pptr = *rpptr = p &MaskPrio;
|
||||
@@ -385,17 +389,21 @@ static int IsPrefixOp(Atom op, int *pptr, int *rpptr, Term tmod USES_REGS) {
|
||||
}
|
||||
}
|
||||
|
||||
int Yap_IsPrefixOp(Atom op, int *pptr, int *rpptr, Term tmod) {
|
||||
int Yap_IsPrefixOp(Atom op, int *pptr, int *rpptr) {
|
||||
CACHE_REGS
|
||||
return IsPrefixOp(op, pptr, rpptr, tmod PASS_REGS);
|
||||
return IsPrefixOp(op, pptr, rpptr PASS_REGS);
|
||||
}
|
||||
|
||||
static int IsInfixOp(Atom op, int *pptr, int *lpptr, int *rpptr, Term tmod USES_REGS) {
|
||||
static int IsInfixOp(Atom op, int *pptr, int *lpptr, int *rpptr USES_REGS) {
|
||||
int p;
|
||||
|
||||
OpEntry *opp = Yap_GetOpProp(op, INFIX_OP, tmod PASS_REGS);
|
||||
OpEntry *opp = Yap_GetOpProp(op, INFIX_OP PASS_REGS);
|
||||
if (!opp)
|
||||
return FALSE;
|
||||
if (opp->OpModule && opp->OpModule != CurrentModule) {
|
||||
READ_UNLOCK(opp->OpRWLock);
|
||||
return FALSE;
|
||||
}
|
||||
if ((p = opp->Infix) != 0) {
|
||||
READ_UNLOCK(opp->OpRWLock);
|
||||
*pptr = *rpptr = *lpptr = p &MaskPrio;
|
||||
@@ -410,17 +418,21 @@ static int IsInfixOp(Atom op, int *pptr, int *lpptr, int *rpptr, Term tmod USES_
|
||||
}
|
||||
}
|
||||
|
||||
int Yap_IsInfixOp(Atom op, int *pptr, int *lpptr, int *rpptr, Term tmod) {
|
||||
int Yap_IsInfixOp(Atom op, int *pptr, int *lpptr, int *rpptr) {
|
||||
CACHE_REGS
|
||||
return IsInfixOp(op, pptr, lpptr, rpptr, tmod PASS_REGS);
|
||||
return IsInfixOp(op, pptr, lpptr, rpptr PASS_REGS);
|
||||
}
|
||||
|
||||
static int IsPosfixOp(Atom op, int *pptr, int *lpptr, Term tmod USES_REGS) {
|
||||
static int IsPosfixOp(Atom op, int *pptr, int *lpptr USES_REGS) {
|
||||
int p;
|
||||
|
||||
OpEntry *opp = Yap_GetOpProp(op, POSFIX_OP, tmod PASS_REGS);
|
||||
OpEntry *opp = Yap_GetOpProp(op, POSFIX_OP PASS_REGS);
|
||||
if (!opp)
|
||||
return FALSE;
|
||||
if (opp->OpModule && opp->OpModule != CurrentModule) {
|
||||
READ_UNLOCK(opp->OpRWLock);
|
||||
return FALSE;
|
||||
}
|
||||
if ((p = opp->Posfix) != 0) {
|
||||
READ_UNLOCK(opp->OpRWLock);
|
||||
*pptr = *lpptr = p &MaskPrio;
|
||||
@@ -433,9 +445,9 @@ static int IsPosfixOp(Atom op, int *pptr, int *lpptr, Term tmod USES_REGS) {
|
||||
}
|
||||
}
|
||||
|
||||
int Yap_IsPosfixOp(Atom op, int *pptr, int *lpptr, Term tmod) {
|
||||
int Yap_IsPosfixOp(Atom op, int *pptr, int *lpptr) {
|
||||
CACHE_REGS
|
||||
return IsPosfixOp(op, pptr, lpptr, tmod PASS_REGS);
|
||||
return IsPosfixOp(op, pptr, lpptr PASS_REGS);
|
||||
}
|
||||
|
||||
inline static void GNextToken(USES_REGS1) {
|
||||
@@ -460,9 +472,9 @@ inline static void checkfor(wchar_t c, JMPBUFF *FailBuff USES_REGS) {
|
||||
|
||||
#ifdef O_QUASIQUOTATIONS
|
||||
|
||||
static int is_quasi_quotation_syntax(Term goal, Term m, Atom *pat) {
|
||||
static int is_quasi_quotation_syntax(Term goal, Atom *pat) {
|
||||
CACHE_REGS
|
||||
Term t;
|
||||
Term m = CurrentModule, t;
|
||||
Atom at;
|
||||
UInt arity;
|
||||
Functor f;
|
||||
@@ -512,8 +524,8 @@ static int get_quasi_quotation(term_t t, unsigned char **here,
|
||||
}
|
||||
#endif /*O_QUASIQUOTATIONS*/
|
||||
|
||||
static Term ParseArgs(Atom a, wchar_t close, JMPBUFF *FailBuff,
|
||||
Term arg1, Term tmod USES_REGS) {
|
||||
static Term ParseArgs(Atom a, wchar_t close, JMPBUFF *FailBuff,
|
||||
Term arg1 USES_REGS) {
|
||||
int nargs = 0;
|
||||
Term *p, t;
|
||||
Functor func;
|
||||
@@ -550,7 +562,7 @@ static Term ParseArgs(Atom a, wchar_t close, JMPBUFF *FailBuff,
|
||||
syntax_msg("line %d: Trail Overflow",LOCAL_tokptr->TokPos);
|
||||
FAIL;
|
||||
}
|
||||
*tp++ = Unsigned(ParseTerm(999, FailBuff, tmod PASS_REGS));
|
||||
*tp++ = Unsigned(ParseTerm(999, FailBuff PASS_REGS));
|
||||
ParserAuxSp = (char *)tp;
|
||||
++nargs;
|
||||
if (LOCAL_tokptr->Tok != Ord(Ponctuation_tok))
|
||||
@@ -605,14 +617,14 @@ static Term MakeAccessor(Term t, Functor f USES_REGS) {
|
||||
return Yap_MkApplTerm(f, 2, tf);
|
||||
}
|
||||
|
||||
static Term ParseList(JMPBUFF *FailBuff, Term tmod 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, tmod PASS_REGS);
|
||||
to_store[0] = ParseTerm(999, FailBuff PASS_REGS);
|
||||
if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok)) {
|
||||
if (((int)LOCAL_tokptr->TokInfo) == ',') {
|
||||
NextToken;
|
||||
@@ -629,7 +641,7 @@ loop:
|
||||
}
|
||||
} else if (((int)LOCAL_tokptr->TokInfo) == '|') {
|
||||
NextToken;
|
||||
to_store[1] = ParseTerm(999, FailBuff, tmod PASS_REGS);
|
||||
to_store[1] = ParseTerm(999, FailBuff PASS_REGS);
|
||||
} else {
|
||||
to_store[1] = MkAtomTerm(AtomNil);
|
||||
}
|
||||
@@ -641,7 +653,7 @@ loop:
|
||||
return (o);
|
||||
}
|
||||
|
||||
static Term ParseTerm(int prio, JMPBUFF *FailBuff, Term tmod USES_REGS) {
|
||||
static Term ParseTerm(int prio, JMPBUFF *FailBuff USES_REGS) {
|
||||
/* parse term with priority prio */
|
||||
Volatile Term t;
|
||||
Volatile Functor func;
|
||||
@@ -674,7 +686,7 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, Term tmod USES_REGS) {
|
||||
}
|
||||
if ((LOCAL_tokptr->Tok != Ord(Ponctuation_tok) ||
|
||||
Unsigned(LOCAL_tokptr->TokInfo) != 'l') &&
|
||||
IsPrefixOp((Atom)t, &opprio, &oprprio, tmod PASS_REGS)) {
|
||||
IsPrefixOp((Atom)t, &opprio, &oprprio PASS_REGS)) {
|
||||
if (LOCAL_tokptr->Tok == Name_tok) {
|
||||
Atom at = (Atom)LOCAL_tokptr->TokInfo;
|
||||
#ifndef _MSC_VER
|
||||
@@ -709,7 +721,7 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, Term tmod USES_REGS) {
|
||||
syntax_msg("line %d: Heap Overflow",LOCAL_tokptr->TokPos);
|
||||
FAIL;
|
||||
}
|
||||
t = ParseTerm(oprprio, FailBuff, tmod 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) {
|
||||
@@ -721,7 +733,7 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, Term tmod USES_REGS) {
|
||||
}
|
||||
if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok) &&
|
||||
Unsigned(LOCAL_tokptr->TokInfo) == 'l')
|
||||
t = ParseArgs((Atom)t, ')', FailBuff, 0L, tmod PASS_REGS);
|
||||
t = ParseArgs((Atom)t, ')', FailBuff, 0L PASS_REGS);
|
||||
else
|
||||
t = MkAtomTerm((Atom)t);
|
||||
break;
|
||||
@@ -737,7 +749,7 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, Term tmod USES_REGS) {
|
||||
// we may be operating under a syntax error
|
||||
yap_error_number oerr = LOCAL_Error_TYPE;
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
t = Yap_CharsToTDQ(p, tmod, LOCAL_encoding PASS_REGS);
|
||||
t = Yap_CharsToTDQ(p, CurrentModule, LOCAL_encoding PASS_REGS);
|
||||
if (!t) {
|
||||
syntax_msg("line %d: could not convert \"%s\"",LOCAL_tokptr->TokPos, (char *)LOCAL_tokptr->TokInfo);
|
||||
FAIL;
|
||||
@@ -752,7 +764,7 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, Term tmod USES_REGS) {
|
||||
// we may be operating under a syntax error
|
||||
yap_error_number oerr = LOCAL_Error_TYPE;
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
t = Yap_WCharsToTDQ(p, tmod PASS_REGS);
|
||||
t = Yap_WCharsToTDQ(p, CurrentModule PASS_REGS);
|
||||
if (!t) {
|
||||
syntax_msg("line %d: could not convert \'%S\'",LOCAL_tokptr->TokPos, (wchar_t *)LOCAL_tokptr->TokInfo);
|
||||
FAIL;
|
||||
@@ -768,7 +780,7 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, Term tmod USES_REGS) {
|
||||
yap_error_number oerr = LOCAL_Error_TYPE;
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
|
||||
t = Yap_CharsToTBQ(p, tmod, LOCAL_encoding PASS_REGS);
|
||||
t = Yap_CharsToTBQ(p, CurrentModule, LOCAL_encoding PASS_REGS);
|
||||
if (!t) {
|
||||
syntax_msg("line %d: could not convert \'%s\"",LOCAL_tokptr->TokPos, (char *)LOCAL_tokptr->TokInfo);
|
||||
FAIL;
|
||||
@@ -780,7 +792,7 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, Term tmod USES_REGS) {
|
||||
case WBQString_tok: /* build list on the heap */
|
||||
{
|
||||
Volatile wchar_t *p = (wchar_t *)LOCAL_tokptr->TokInfo;
|
||||
t = Yap_WCharsToTBQ(p, tmod PASS_REGS);
|
||||
t = Yap_WCharsToTBQ(p, CurrentModule PASS_REGS);
|
||||
// we may be operating under a syntax error
|
||||
yap_error_number oerr = LOCAL_Error_TYPE;
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
@@ -810,7 +822,7 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, Term tmod USES_REGS) {
|
||||
case '(':
|
||||
case 'l': /* non solo ( */
|
||||
NextToken;
|
||||
t = ParseTerm(GLOBAL_MaxPriority, FailBuff, tmod PASS_REGS);
|
||||
t = ParseTerm(GLOBAL_MaxPriority, FailBuff PASS_REGS);
|
||||
checkfor(')', FailBuff PASS_REGS);
|
||||
break;
|
||||
case '[':
|
||||
@@ -821,7 +833,7 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, Term tmod USES_REGS) {
|
||||
NextToken;
|
||||
break;
|
||||
}
|
||||
t = ParseList(FailBuff, tmod PASS_REGS);
|
||||
t = ParseList(FailBuff PASS_REGS);
|
||||
checkfor(']', FailBuff PASS_REGS);
|
||||
break;
|
||||
case '{':
|
||||
@@ -832,7 +844,7 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, Term tmod USES_REGS) {
|
||||
NextToken;
|
||||
break;
|
||||
}
|
||||
t = ParseTerm(GLOBAL_MaxPriority, FailBuff, tmod PASS_REGS);
|
||||
t = ParseTerm(GLOBAL_MaxPriority, FailBuff PASS_REGS);
|
||||
t = Yap_MkApplTerm(FunctorBraces, 1, &t);
|
||||
/* check for possible overflow against local stack */
|
||||
if (HR > ASP - 4096) {
|
||||
@@ -884,7 +896,7 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, Term tmod USES_REGS) {
|
||||
}
|
||||
|
||||
NextToken;
|
||||
t = ParseTerm(GLOBAL_MaxPriority, FailBuff, tmod PASS_REGS);
|
||||
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));
|
||||
@@ -942,7 +954,7 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, Term tmod USES_REGS) {
|
||||
if (LOCAL_tokptr->Tok == Ord(Name_tok) &&
|
||||
Yap_HasOp((Atom)(LOCAL_tokptr->TokInfo))) {
|
||||
Atom save_opinfo = opinfo = (Atom)(LOCAL_tokptr->TokInfo);
|
||||
if (IsInfixOp(save_opinfo, &opprio, &oplprio, &oprprio, tmod PASS_REGS) &&
|
||||
if (IsInfixOp(save_opinfo, &opprio, &oplprio, &oprprio PASS_REGS) &&
|
||||
opprio <= prio && oplprio >= curprio) {
|
||||
/* try parsing as infix operator */
|
||||
Volatile int oldprio = curprio;
|
||||
@@ -955,7 +967,7 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, Term tmod USES_REGS) {
|
||||
{
|
||||
Term args[2];
|
||||
args[0] = t;
|
||||
args[1] = ParseTerm(oprprio, FailBuff, tmod PASS_REGS);
|
||||
args[1] = ParseTerm(oprprio, FailBuff PASS_REGS);
|
||||
t = Yap_MkApplTerm(func, 2, args);
|
||||
/* check for possible overflow against local stack */
|
||||
if (HR > ASP - 4096) {
|
||||
@@ -967,7 +979,7 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, Term tmod USES_REGS) {
|
||||
opinfo = save_opinfo; continue;, opinfo = save_opinfo;
|
||||
curprio = oldprio;)
|
||||
}
|
||||
if (IsPosfixOp(opinfo, &opprio, &oplprio , tmod PASS_REGS) && opprio <= prio &&
|
||||
if (IsPosfixOp(opinfo, &opprio, &oplprio PASS_REGS) && opprio <= prio &&
|
||||
oplprio >= curprio) {
|
||||
/* parse as posfix operator */
|
||||
Functor func = Yap_MkFunctor((Atom)LOCAL_tokptr->TokInfo, 1);
|
||||
@@ -993,7 +1005,7 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, Term tmod USES_REGS) {
|
||||
Volatile Term args[2];
|
||||
NextToken;
|
||||
args[0] = t;
|
||||
args[1] = ParseTerm(1000, FailBuff, tmod PASS_REGS);
|
||||
args[1] = ParseTerm(1000, FailBuff PASS_REGS);
|
||||
t = Yap_MkApplTerm(FunctorComma, 2, args);
|
||||
/* check for possible overflow against local stack */
|
||||
if (HR > ASP - 4096) {
|
||||
@@ -1003,12 +1015,12 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, Term tmod USES_REGS) {
|
||||
curprio = 1000;
|
||||
continue;
|
||||
} else if (Unsigned(LOCAL_tokptr->TokInfo) == '|' &&
|
||||
IsInfixOp(AtomVBar, &opprio, &oplprio, &oprprio, tmod PASS_REGS) &&
|
||||
IsInfixOp(AtomVBar, &opprio, &oplprio, &oprprio PASS_REGS) &&
|
||||
opprio <= prio && oplprio >= curprio) {
|
||||
Volatile Term args[2];
|
||||
NextToken;
|
||||
args[0] = t;
|
||||
args[1] = ParseTerm(oprprio, FailBuff, tmod PASS_REGS);
|
||||
args[1] = ParseTerm(oprprio, FailBuff PASS_REGS);
|
||||
t = Yap_MkApplTerm(FunctorVBar, 2, args);
|
||||
/* check for possible overflow against local stack */
|
||||
if (HR > ASP - 4096) {
|
||||
@@ -1018,24 +1030,24 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, Term tmod USES_REGS) {
|
||||
curprio = opprio;
|
||||
continue;
|
||||
} else if (Unsigned(LOCAL_tokptr->TokInfo) == '(' &&
|
||||
IsPosfixOp(AtomEmptyBrackets, &opprio, &oplprio, tmod PASS_REGS) &&
|
||||
IsPosfixOp(AtomEmptyBrackets, &opprio, &oplprio PASS_REGS) &&
|
||||
opprio <= prio && oplprio >= curprio) {
|
||||
t = ParseArgs(AtomEmptyBrackets, ')', FailBuff, t, tmod PASS_REGS);
|
||||
t = ParseArgs(AtomEmptyBrackets, ')', FailBuff, t PASS_REGS);
|
||||
curprio = opprio;
|
||||
continue;
|
||||
} else if (Unsigned(LOCAL_tokptr->TokInfo) == '[' &&
|
||||
IsPosfixOp(AtomEmptySquareBrackets, &opprio,
|
||||
&oplprio, tmod PASS_REGS) &&
|
||||
&oplprio PASS_REGS) &&
|
||||
opprio <= prio && oplprio >= curprio) {
|
||||
t = ParseArgs(AtomEmptySquareBrackets, ']', FailBuff, t, tmod PASS_REGS);
|
||||
t = ParseArgs(AtomEmptySquareBrackets, ']', FailBuff, t PASS_REGS);
|
||||
t = MakeAccessor(t, FunctorEmptySquareBrackets PASS_REGS);
|
||||
curprio = opprio;
|
||||
continue;
|
||||
} else if (Unsigned(LOCAL_tokptr->TokInfo) == '{' &&
|
||||
IsPosfixOp(AtomEmptyCurlyBrackets, &opprio,
|
||||
&oplprio, tmod PASS_REGS) &&
|
||||
&oplprio PASS_REGS) &&
|
||||
opprio <= prio && oplprio >= curprio) {
|
||||
t = ParseArgs(AtomEmptyCurlyBrackets, '}', FailBuff, t, tmod PASS_REGS);
|
||||
t = ParseArgs(AtomEmptyCurlyBrackets, '}', FailBuff, t PASS_REGS);
|
||||
t = MakeAccessor(t, FunctorEmptyCurlyBrackets PASS_REGS);
|
||||
curprio = opprio;
|
||||
continue;
|
||||
@@ -1050,7 +1062,7 @@ static Term ParseTerm(int prio, JMPBUFF *FailBuff, Term tmod USES_REGS) {
|
||||
return t;
|
||||
}
|
||||
|
||||
Term Yap_Parse(UInt prio, Term tmod) {
|
||||
Term Yap_Parse(UInt prio) {
|
||||
CACHE_REGS
|
||||
Volatile Term t;
|
||||
JMPBUFF FailBuff;
|
||||
@@ -1058,7 +1070,7 @@ Term Yap_Parse(UInt prio, Term tmod) {
|
||||
|
||||
if (!sigsetjmp(FailBuff.JmpBuff, 0)) {
|
||||
|
||||
t = ParseTerm(prio, &FailBuff, tmod PASS_REGS);
|
||||
t = ParseTerm(prio, &FailBuff PASS_REGS);
|
||||
#if DEBUG
|
||||
if (GLOBAL_Option['p' - 'a' + 1]) {
|
||||
Yap_DebugPutc(stderr, '[');
|
||||
@@ -1071,8 +1083,7 @@ Term Yap_Parse(UInt prio, Term tmod) {
|
||||
}
|
||||
#endif
|
||||
Yap_CloseSlots(sls);
|
||||
if (LOCAL_Error_TYPE == YAP_NO_ERROR &&
|
||||
LOCAL_tokptr != NULL && LOCAL_tokptr->Tok != Ord(eot_tok)) {
|
||||
if (LOCAL_tokptr != NULL && LOCAL_tokptr->Tok != Ord(eot_tok)) {
|
||||
LOCAL_Error_TYPE = SYNTAX_ERROR;
|
||||
LOCAL_ErrorMessage = "term does not end on . ";
|
||||
t = 0;
|
||||
|
||||
6
C/save.c
6
C/save.c
@@ -186,7 +186,7 @@ do_SYSTEM_ERROR_INTERNAL(yap_error_number etype, const char *msg)
|
||||
|
||||
inline static
|
||||
int myread(FILE *fd, char *buffer, Int len) {
|
||||
ssize_t nread;
|
||||
size_t nread;
|
||||
|
||||
while (len > 0) {
|
||||
nread = fread(buffer, 1, (int)len, fd);
|
||||
@@ -202,7 +202,7 @@ int myread(FILE *fd, char *buffer, Int len) {
|
||||
inline static
|
||||
Int
|
||||
mywrite(FILE *fd, char *buff, Int len) {
|
||||
ssize_t nwritten;
|
||||
size_t nwritten;
|
||||
|
||||
while (len > 0) {
|
||||
nwritten = fwrite(buff, 1, (size_t)len, fd);
|
||||
@@ -1440,7 +1440,7 @@ OpenRestore(const char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL
|
||||
CACHE_REGS
|
||||
|
||||
int mode;
|
||||
char fname[PATH_MAX+1];
|
||||
char fname[YAP_FILENAME_MAX +1];
|
||||
|
||||
if (!Yap_findFile( inpf, YAP_STARTUP, YapLibDir, fname, true, YAP_SAVED_STATE, true, true))
|
||||
return false;
|
||||
|
||||
23
C/stdpreds.c
23
C/stdpreds.c
@@ -385,8 +385,7 @@ static Int p_systime(USES_REGS1) {
|
||||
}
|
||||
|
||||
static Int p_walltime(USES_REGS1) {
|
||||
Int now, interval;
|
||||
Yap_walltime_interval(&now, &interval);
|
||||
uint64_t now, interval;
|
||||
return (Yap_unify_constant(ARG1, MkIntegerTerm(now)) &&
|
||||
Yap_unify_constant(ARG2, MkIntegerTerm(interval)));
|
||||
}
|
||||
@@ -984,27 +983,24 @@ int Yap_IsOpMaxPrio(Atom at) {
|
||||
return max;
|
||||
}
|
||||
|
||||
static bool unify_op(OpEntry *op, Term emod USES_REGS) {
|
||||
static Int unify_op(OpEntry *op USES_REGS) {
|
||||
Term tmod = op->OpModule;
|
||||
|
||||
if (tmod != PROLOG_MODULE &&
|
||||
tmod != USER_MODULE &&
|
||||
tmod != emod &&
|
||||
(op->Prefix || op->Infix || op->Posfix))
|
||||
return false;
|
||||
return Yap_unify_constant(ARG3, MkIntegerTerm(op->Prefix)) &&
|
||||
if (tmod == PROLOG_MODULE)
|
||||
tmod = TermProlog;
|
||||
return Yap_unify_constant(ARG2, tmod) &&
|
||||
Yap_unify_constant(ARG3, MkIntegerTerm(op->Prefix)) &&
|
||||
Yap_unify_constant(ARG4, MkIntegerTerm(op->Infix)) &&
|
||||
Yap_unify_constant(ARG5, MkIntegerTerm(op->Posfix));
|
||||
}
|
||||
|
||||
static Int cont_current_op(USES_REGS1) {
|
||||
OpEntry *op = (OpEntry *)IntegerOfTerm(EXTRA_CBACK_ARG(5, 1)), *next;
|
||||
Term emod = Deref(ARG2);
|
||||
|
||||
|
||||
READ_LOCK(op->OpRWLock);
|
||||
next = op->OpNext;
|
||||
if (Yap_unify_constant(ARG1, MkAtomTerm(op->OpName)) &&
|
||||
unify_op(op, emod PASS_REGS)) {
|
||||
unify_op(op PASS_REGS)) {
|
||||
READ_UNLOCK(op->OpRWLock);
|
||||
if (next) {
|
||||
EXTRA_CBACK_ARG(5, 1) = (CELL)MkIntegerTerm((CELL)next);
|
||||
@@ -1017,6 +1013,7 @@ static Int cont_current_op(USES_REGS1) {
|
||||
READ_UNLOCK(op->OpRWLock);
|
||||
if (next) {
|
||||
EXTRA_CBACK_ARG(5, 1) = (CELL)MkIntegerTerm((CELL)next);
|
||||
B->cp_h = HR;
|
||||
return FALSE;
|
||||
} else {
|
||||
cut_fail();
|
||||
@@ -1036,7 +1033,7 @@ static Int cont_current_atom_op(USES_REGS1) {
|
||||
|
||||
READ_LOCK(op->OpRWLock);
|
||||
next = NextOp(RepOpProp(op->NextOfPE) PASS_REGS);
|
||||
if (unify_op(op, CurrentModule PASS_REGS)) {
|
||||
if (unify_op(op PASS_REGS)) {
|
||||
READ_UNLOCK(op->OpRWLock);
|
||||
if (next) {
|
||||
EXTRA_CBACK_ARG(5, 1) = (CELL)MkIntegerTerm((CELL)next);
|
||||
|
||||
4
C/text.c
4
C/text.c
@@ -931,7 +931,7 @@ write_buffer( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng
|
||||
|
||||
|
||||
|
||||
static ssize_t
|
||||
static size_t
|
||||
write_length( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng USES_REGS)
|
||||
{
|
||||
size_t max = -1;
|
||||
@@ -998,7 +998,7 @@ write_Text( void *inp, seq_tv_t *out, encoding_t enc, int minimal, size_t leng U
|
||||
case YAP_STRING_LENGTH:
|
||||
out->val.l =
|
||||
write_length( inp, out, enc, minimal, leng PASS_REGS);
|
||||
return out->val.l != (ssize_t)(-1);
|
||||
return out->val.l != (size_t)(-1);
|
||||
case YAP_STRING_ATOM:
|
||||
out->val.a =
|
||||
write_atom( inp, out, enc, minimal, leng PASS_REGS);
|
||||
|
||||
@@ -30,7 +30,9 @@ static char SccsId[] = "%W% %G%";
|
||||
#include "yapio.h"
|
||||
#include "blobs.h"
|
||||
#include <stdio.h>
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
@@ -1007,7 +1007,7 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!wglb->Ignore_ops && Arity == 1 && Yap_IsPrefixOp(atom, &op, &rp, CurrentModule)) {
|
||||
if (!wglb->Ignore_ops && Arity == 1 && Yap_IsPrefixOp(atom, &op, &rp)) {
|
||||
Term tright = ArgOfTerm(1, t);
|
||||
int bracket_right = !IsVarTerm(tright) && IsAtomTerm(tright) &&
|
||||
Yap_IsOp(AtomOfTerm(tright));
|
||||
@@ -1035,7 +1035,7 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
||||
((atom == AtomEmptyBrackets || atom == AtomEmptyCurlyBrackets ||
|
||||
atom == AtomEmptySquareBrackets) &&
|
||||
Yap_IsListTerm(ArgOfTerm(1, t)))) &&
|
||||
Yap_IsPosfixOp(atom, &op, &lp, CurrentModule)) {
|
||||
Yap_IsPosfixOp(atom, &op, &lp)) {
|
||||
Term tleft = ArgOfTerm(1, t);
|
||||
|
||||
int bracket_left, offset;
|
||||
@@ -1087,7 +1087,7 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
||||
wrclose_bracket(wglb, TRUE);
|
||||
}
|
||||
} else if (!wglb->Ignore_ops && Arity == 2 &&
|
||||
Yap_IsInfixOp(atom, &op, &lp, &rp, CurrentModule)) {
|
||||
Yap_IsInfixOp(atom, &op, &lp, &rp)) {
|
||||
Term tleft = ArgOfTerm(1, t);
|
||||
Term tright = ArgOfTerm(2, t);
|
||||
int bracket_left =
|
||||
|
||||
Reference in New Issue
Block a user