all global symbols should now start with _YAP

global functions should not be called from within file (bug in
binutils/WIN32).


git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@675 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc
2002-11-11 17:38:10 +00:00
parent 932a850d5e
commit 7b2c4dc6ff
89 changed files with 8506 additions and 8901 deletions

View File

@@ -79,7 +79,7 @@ static JMPBUFF FailBuff;
#define TRY(S,P) \
{ Volatile JMPBUFF saveenv;\
Volatile TokEntry *saveT=tokptr; \
Volatile TokEntry *saveT=_YAP_tokptr; \
Volatile CELL *saveH=H;\
Volatile int savecurprio=curprio;\
saveenv=FailBuff;\
@@ -91,42 +91,39 @@ static JMPBUFF FailBuff;
else { FailBuff=saveenv; \
H=saveH; \
curprio = savecurprio; \
tokptr=saveT; \
_YAP_tokptr=saveT; \
}\
}\
#define TRY3(S,P,F) \
{ Volatile JMPBUFF saveenv;\
Volatile TokEntry *saveT=tokptr; Volatile CELL *saveH=H;\
Volatile TokEntry *saveT=_YAP_tokptr; Volatile CELL *saveH=H;\
saveenv=FailBuff;\
if(!setjmp(FailBuff.JmpBuff)) {\
S;\
FailBuff=saveenv;\
P;\
}\
else { FailBuff=saveenv; H=saveH; tokptr=saveT; F }\
else { FailBuff=saveenv; H=saveH; _YAP_tokptr=saveT; F }\
}\
#define FAIL longjmp(FailBuff.JmpBuff,1)
TokEntry *tokptr, *toktide;
VarEntry *VarTable, *AnonVarTable;
VarEntry *
LookupVar(char *var) /* lookup variable in variables table */
_YAP_LookupVar(char *var) /* lookup variable in variables table */
{
VarEntry *p;
#ifdef DEBUG
if (Option[4])
YP_fprintf(YP_stderr,"[LookupVar %s]", var);
if (_YAP_Option[4])
fprintf(_YAP_stderr,"[LookupVar %s]", var);
#endif
if (var[0] != '_' || var[1] != '\0') {
VarEntry **op = &VarTable;
VarEntry **op = &_YAP_VarTable;
unsigned char *vp = (unsigned char *)var;
CELL hv;
p = VarTable;
p = _YAP_VarTable;
HashFunction(vp, hv);
while (p != NULL) {
CELL hpv = p->hv;
@@ -149,16 +146,16 @@ LookupVar(char *var) /* lookup variable in variables table */
p = p->VarRight;
}
}
p = (VarEntry *) AllocScannerMemory(strlen(var) + sizeof(VarEntry));
p = (VarEntry *) _YAP_AllocScannerMemory(strlen(var) + sizeof(VarEntry));
*op = p;
p->VarLeft = p->VarRight = NULL;
p->hv = hv;
strcpy(p->VarRep, var);
} else {
/* anon var */
p = (VarEntry *) AllocScannerMemory(sizeof(VarEntry) + 2);
p->VarLeft = AnonVarTable;
AnonVarTable = p;
p = (VarEntry *) _YAP_AllocScannerMemory(sizeof(VarEntry) + 2);
p->VarLeft = _YAP_AnonVarTable;
_YAP_AnonVarTable = p;
p->VarRight = NULL;
p->hv = 0L;
p->VarRep[0] = '_';
@@ -168,16 +165,16 @@ LookupVar(char *var) /* lookup variable in variables table */
return (p);
}
Term
static Term
VarNames(VarEntry *p,Term l)
{
if (p != NULL) {
if (strcmp(p->VarRep, "_") != 0) {
Term o = MkPairTerm(MkPairTerm(StringToList(p->VarRep), p->VarAdr),
Term o = MkPairTerm(MkPairTerm(_YAP_StringToList(p->VarRep), p->VarAdr),
VarNames(p->VarRight,
VarNames(p->VarLeft,l)));
if (H > ASP-4096) {
longjmp(IOBotch,1);
longjmp(_YAP_IOBotch,1);
}
return(o);
} else {
@@ -188,7 +185,13 @@ VarNames(VarEntry *p,Term l)
}
}
int
Term
_YAP_VarNames(VarEntry *p,Term l)
{
return VarNames(p,l);
}
static int
IsPrefixOp(Prop opinfo,int *pptr, int *rpptr)
{
int p;
@@ -207,6 +210,12 @@ IsPrefixOp(Prop opinfo,int *pptr, int *rpptr)
}
int
_YAP_IsPrefixOp(Prop opinfo,int *pptr, int *rpptr)
{
return IsPrefixOp(opinfo,pptr,rpptr);
}
static int
IsInfixOp(Prop opinfo, int *pptr, int *lpptr, int *rpptr)
{
int p;
@@ -227,6 +236,12 @@ IsInfixOp(Prop opinfo, int *pptr, int *lpptr, int *rpptr)
}
int
_YAP_IsInfixOp(Prop opinfo, int *pptr, int *lpptr, int *rpptr)
{
return IsInfixOp(opinfo, pptr, lpptr, rpptr);
}
static int
IsPosfixOp(Prop opinfo, int *pptr, int *lpptr)
{
int p;
@@ -243,27 +258,33 @@ IsPosfixOp(Prop opinfo, int *pptr, int *lpptr)
}
}
int
_YAP_IsPosfixOp(Prop opinfo, int *pptr, int *lpptr)
{
return IsPosfixOp(opinfo, pptr, lpptr);
}
inline static void
GNextToken(void)
{
if (tokptr->Tok == Ord(eot_tok))
if (_YAP_tokptr->Tok == Ord(eot_tok))
return;
#ifdef EMACS
if ((tokptr = tokptr->TokNext)->TokPos > toktide->TokPos)
toktide = tokptr;
if ((_YAP_tokptr = _YAP_tokptr->TokNext)->TokPos > _YAP_toktide->TokPos)
_YAP_toktide = _YAP_tokptr;
#else
if (tokptr == toktide)
toktide = tokptr = tokptr->TokNext;
if (_YAP_tokptr == _YAP_toktide)
_YAP_toktide = _YAP_tokptr = _YAP_tokptr->TokNext;
else
tokptr = tokptr->TokNext;
_YAP_tokptr = _YAP_tokptr->TokNext;
#endif
}
inline static void
checkfor(Term c)
{
if (tokptr->Tok != Ord(Ponctuation_tok)
|| tokptr->TokInfo != c)
if (_YAP_tokptr->Tok != Ord(Ponctuation_tok)
|| _YAP_tokptr->TokInfo != c)
FAIL;
NextToken;
}
@@ -274,7 +295,7 @@ ParseArgs(Atom a)
int nargs = 0;
Term *p, t;
#ifdef SFUNC
SFEntry *pe = (SFEntry *) GetAProp(a, SFProperty);
SFEntry *pe = (SFEntry *) _YAP_GetAProp(a, SFProperty);
#endif
NextToken;
@@ -284,9 +305,9 @@ ParseArgs(Atom a)
*tp++ = Unsigned(ParseTerm(999));
ParserAuxSp = (tr_fr_ptr)tp;
++nargs;
if (tokptr->Tok != Ord(Ponctuation_tok))
if (_YAP_tokptr->Tok != Ord(Ponctuation_tok))
break;
if (((int) tokptr->TokInfo) != ',')
if (((int) _YAP_tokptr->TokInfo) != ',')
break;
NextToken;
}
@@ -296,16 +317,16 @@ ParseArgs(Atom a)
* order
*/
if (H > ASP-(nargs+1)) {
ErrorMessage = "Stack Overflow";
_YAP_ErrorMessage = "Stack Overflow";
FAIL;
}
#ifdef SFUNC
if (pe)
t = MkSFTerm(MkFunctor(a, SFArity), nargs, p, pe->NilValue);
t = MkSFTerm(_YAP_MkFunctor(a, SFArity), nargs, p, pe->NilValue);
else
t = MkApplTerm(MkFunctor(a, nargs), nargs, p);
t = _YAP_MkApplTerm(_YAP_MkFunctor(a, nargs), nargs, p);
#else
t = MkApplTerm(MkFunctor(a, nargs), nargs, p);
t = _YAP_MkApplTerm(_YAP_MkFunctor(a, nargs), nargs, p);
#endif
/* check for possible overflow against local stack */
checkfor((Term) ')');
@@ -316,32 +337,32 @@ ParseArgs(Atom a)
static Term
ParseList(void)
{
Term t, s, o;
Term o;
CELL *to_store;
o = AbsPair(H);
loop:
to_store = H;
H+=2;
to_store[0] = ParseTerm(999);
if (tokptr->Tok == Ord(Ponctuation_tok)) {
if (((int) tokptr->TokInfo) == ',') {
if (_YAP_tokptr->Tok == Ord(Ponctuation_tok)) {
if (((int) _YAP_tokptr->TokInfo) == ',') {
NextToken;
if (tokptr->Tok == Ord(Name_tok)
&& strcmp(RepAtom((Atom)(tokptr->TokInfo))->StrOfAE, "..") == 0) {
if (_YAP_tokptr->Tok == Ord(Name_tok)
&& strcmp(RepAtom((Atom)(_YAP_tokptr->TokInfo))->StrOfAE, "..") == 0) {
NextToken;
to_store[1] = ParseTerm(999);
} else {
/* check for possible overflow against local stack */
if (H > ASP-4096) {
to_store[1] = TermNil;
ErrorMessage = "Stack Overflow";
_YAP_ErrorMessage = "Stack Overflow";
FAIL;
} else {
to_store[1] = AbsPair(H);
goto loop;
}
}
} else if (((int) tokptr->TokInfo) == '|') {
} else if (((int) _YAP_tokptr->TokInfo) == '|') {
NextToken;
to_store[1] = ParseTerm(999);
} else {
@@ -370,29 +391,29 @@ ParseTerm(int prio)
Volatile VarEntry *varinfo;
Volatile int curprio = 0, opprio, oplprio, oprprio;
switch (tokptr->Tok) {
switch (_YAP_tokptr->Tok) {
case Name_tok:
t = tokptr->TokInfo;
t = _YAP_tokptr->TokInfo;
NextToken;
if ((tokptr->Tok != Ord(Ponctuation_tok)
|| Unsigned(tokptr->TokInfo) != 'l')
&& (opinfo = GetAProp((Atom) t, OpProperty))
if ((_YAP_tokptr->Tok != Ord(Ponctuation_tok)
|| Unsigned(_YAP_tokptr->TokInfo) != 'l')
&& (opinfo = _YAP_GetAProp((Atom) t, OpProperty))
&& IsPrefixOp(opinfo, &opprio, &oprprio)
) {
/* special rules apply for +1, -2.3, etc... */
if (tokptr->Tok == Number_tok) {
if (_YAP_tokptr->Tok == Number_tok) {
if ((Atom)t == AtomMinus) {
t = tokptr->TokInfo;
t = _YAP_tokptr->TokInfo;
if (IsIntTerm(t))
t = MkIntTerm(-IntOfTerm(t));
else if (IsFloatTerm(t))
t = MkFloatTerm(-FloatOfTerm(t));
#ifdef USE_GMP
else if (IsBigIntTerm(t)) {
MP_INT *new = PreAllocBigNum();
MP_INT *new = _YAP_PreAllocBigNum();
mpz_neg(new, BigIntOfTerm(t));
t = MkBigIntTerm(new);
mpz_neg(new, _YAP_BigIntOfTerm(t));
t = _YAP_MkBigIntTerm(new);
}
#endif
else
@@ -400,12 +421,12 @@ ParseTerm(int prio)
NextToken;
break;
} else if ((Atom)t == AtomPlus) {
t = tokptr->TokInfo;
t = _YAP_tokptr->TokInfo;
NextToken;
break;
}
} else if (tokptr->Tok == Name_tok) {
Atom at = (Atom)tokptr->TokInfo;
} else if (_YAP_tokptr->Tok == Name_tok) {
Atom at = (Atom)_YAP_tokptr->TokInfo;
#ifndef _MSC_VER
if ((Atom)t == AtomPlus) {
if (at == AtomInf) {
@@ -434,12 +455,12 @@ ParseTerm(int prio)
/* try to parse as a prefix operator */
TRY(
/* build appl on the heap */
func = MkFunctor((Atom) t, 1);
func = _YAP_MkFunctor((Atom) t, 1);
t = ParseTerm(oprprio);
t = MkApplTerm(func, 1, &t);
t = _YAP_MkApplTerm(func, 1, &t);
/* check for possible overflow against local stack */
if (H > ASP-4096) {
ErrorMessage = "Stack Overflow";
_YAP_ErrorMessage = "Stack Overflow";
FAIL;
}
curprio = opprio;
@@ -448,35 +469,35 @@ ParseTerm(int prio)
)
}
}
if (tokptr->Tok == Ord(Ponctuation_tok)
&& Unsigned(tokptr->TokInfo) == 'l')
if (_YAP_tokptr->Tok == Ord(Ponctuation_tok)
&& Unsigned(_YAP_tokptr->TokInfo) == 'l')
t = ParseArgs((Atom) t);
else
t = MkAtomTerm((Atom)t);
break;
case Number_tok:
t = tokptr->TokInfo;
t = _YAP_tokptr->TokInfo;
NextToken;
break;
case String_tok: /* build list on the heap */
{
Volatile char *p = (char *) tokptr->TokInfo;
Volatile char *p = (char *) _YAP_tokptr->TokInfo;
if (*p == 0)
t = MkAtomTerm(AtomNil);
else if (yap_flags[YAP_DOUBLE_QUOTES_FLAG] == STRING_AS_CHARS)
t = StringToListOfAtoms(p);
t = _YAP_StringToListOfAtoms(p);
else if (yap_flags[YAP_DOUBLE_QUOTES_FLAG] == STRING_AS_ATOM)
t = MkAtomTerm(LookupAtom(p));
t = MkAtomTerm(_YAP_LookupAtom(p));
else
t = StringToList(p);
t = _YAP_StringToList(p);
NextToken;
}
break;
case Var_tok:
varinfo = (VarEntry *) (tokptr->TokInfo);
varinfo = (VarEntry *) (_YAP_tokptr->TokInfo);
if ((t = varinfo->VarAdr) == TermNil) {
t = varinfo->VarAdr = MkVarTerm();
}
@@ -484,7 +505,7 @@ ParseTerm(int prio)
break;
case Ponctuation_tok:
switch ((int) tokptr->TokInfo) {
switch ((int) _YAP_tokptr->TokInfo) {
case '(':
case 'l': /* non solo ( */
NextToken;
@@ -498,16 +519,16 @@ ParseTerm(int prio)
break;
case '{':
NextToken;
if (tokptr->Tok == Ord(Ponctuation_tok) &&
Unsigned(tokptr->TokInfo) == '}') {
if (_YAP_tokptr->Tok == Ord(Ponctuation_tok) &&
Unsigned(_YAP_tokptr->TokInfo) == '}') {
t = MkAtomTerm(NameOfFunctor(FunctorBraces));
NextToken;
} else {
t = ParseTerm(1200);
t = MkApplTerm(FunctorBraces, 1, &t);
t = _YAP_MkApplTerm(FunctorBraces, 1, &t);
/* check for possible overflow against local stack */
if (H > ASP-4096) {
ErrorMessage = "Stack Overflow";
_YAP_ErrorMessage = "Stack Overflow";
FAIL;
}
checkfor((Term) '}');
@@ -525,24 +546,24 @@ ParseTerm(int prio)
/* main loop to parse infix and posfix operators starts here */
while (TRUE) {
if (tokptr->Tok == Ord(Name_tok)
&& (opinfo = GetAProp((Atom)(tokptr->TokInfo), OpProperty))) {
if (_YAP_tokptr->Tok == Ord(Name_tok)
&& (opinfo = _YAP_GetAProp((Atom)(_YAP_tokptr->TokInfo), OpProperty))) {
Prop save_opinfo = opinfo;
if (IsInfixOp(opinfo, &opprio, &oplprio, &oprprio)
&& opprio <= prio && oplprio >= curprio) {
/* try parsing as infix operator */
Volatile int oldprio = curprio;
TRY3(
func = MkFunctor((Atom) tokptr->TokInfo, 2);
func = _YAP_MkFunctor((Atom) _YAP_tokptr->TokInfo, 2);
NextToken;
{
Term args[2];
args[0] = t;
args[1] = ParseTerm(oprprio);
t = MkApplTerm(func, 2, args);
t = _YAP_MkApplTerm(func, 2, args);
/* check for possible overflow against local stack */
if (H > ASP-4096) {
ErrorMessage = "Stack Overflow";
_YAP_ErrorMessage = "Stack Overflow";
FAIL;
}
},
@@ -557,10 +578,10 @@ ParseTerm(int prio)
if (IsPosfixOp(opinfo, &opprio, &oplprio)
&& opprio <= prio && oplprio >= curprio) {
/* parse as posfix operator */
t = MkApplTerm(MkFunctor((Atom) tokptr->TokInfo, 1), 1, &t);
t = _YAP_MkApplTerm(_YAP_MkFunctor((Atom) _YAP_tokptr->TokInfo, 1), 1, &t);
/* check for possible overflow against local stack */
if (H > ASP-4096) {
ErrorMessage = "Stack Overflow";
_YAP_ErrorMessage = "Stack Overflow";
FAIL;
}
curprio = opprio;
@@ -569,38 +590,38 @@ ParseTerm(int prio)
}
break;
}
if (tokptr->Tok == Ord(Ponctuation_tok)) {
if (Unsigned(tokptr->TokInfo) == ',' &&
if (_YAP_tokptr->Tok == Ord(Ponctuation_tok)) {
if (Unsigned(_YAP_tokptr->TokInfo) == ',' &&
prio >= 1000 && curprio <= 999) {
Volatile Term args[2];
NextToken;
args[0] = t;
args[1] = ParseTerm(1000);
t = MkApplTerm(MkFunctor(AtomComma, 2), 2, args);
t = _YAP_MkApplTerm(_YAP_MkFunctor(AtomComma, 2), 2, args);
/* check for possible overflow against local stack */
if (H > ASP-4096) {
ErrorMessage = "Stack Overflow";
_YAP_ErrorMessage = "Stack Overflow";
FAIL;
}
curprio = 1000;
continue;
} else if (Unsigned(tokptr->TokInfo) == '|' && prio >= 1100 &&
} else if (Unsigned(_YAP_tokptr->TokInfo) == '|' && prio >= 1100 &&
curprio <= 1099) {
Volatile Term args[2];
NextToken;
args[0] = t;
args[1] = ParseTerm(1100);
t = MkApplTerm(FunctorVBar, 2, args);
t = _YAP_MkApplTerm(FunctorVBar, 2, args);
/* check for possible overflow against local stack */
if (H > ASP-4096) {
ErrorMessage = "Stack Overflow";
_YAP_ErrorMessage = "Stack Overflow";
FAIL;
}
curprio = 1100;
continue;
}
}
if (tokptr->Tok <= Ord(String_tok))
if (_YAP_tokptr->Tok <= Ord(String_tok))
FAIL;
break;
}
@@ -609,12 +630,12 @@ ParseTerm(int prio)
Term
Parse(void)
_YAP_Parse(void)
{
Volatile Term t;
if (!setjmp(FailBuff.JmpBuff)) {
t = ParseTerm(1200);
if (tokptr->Tok != Ord(eot_tok))
if (_YAP_tokptr->Tok != Ord(eot_tok))
return (0L);
return (t);
} else