move all error related state to a record
This commit is contained in:
parent
6043125221
commit
124b2e9069
305
C/errors.c
305
C/errors.c
@ -11,7 +11,7 @@
|
||||
* File: errors.c *
|
||||
* Last Rev: *
|
||||
* Mods: *
|
||||
* Comments: Yap'S error handlers *
|
||||
* Comments: Yap's error handlers *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
@ -32,10 +32,9 @@
|
||||
#endif
|
||||
#include "Foreign.h"
|
||||
|
||||
|
||||
bool Yap_Warning(const char *s, ...) {
|
||||
CACHE_REGS
|
||||
va_list ap;
|
||||
va_list ap;
|
||||
PredEntry *pred;
|
||||
bool rc;
|
||||
Term ts[2];
|
||||
@ -62,8 +61,7 @@ bool Yap_Warning(const char *s, ...) {
|
||||
} else
|
||||
return false;
|
||||
va_end(ap);
|
||||
if (pred->OpcodeOfPred == UNDEF_OPCODE||
|
||||
pred->OpcodeOfPred == FAIL_OPCODE) {
|
||||
if (pred->OpcodeOfPred == UNDEF_OPCODE || pred->OpcodeOfPred == FAIL_OPCODE) {
|
||||
fprintf(stderr, "warning message: %s\n", tmpbuf);
|
||||
LOCAL_DoingUndefp = false;
|
||||
LOCAL_within_print_message = false;
|
||||
@ -75,12 +73,27 @@ bool Yap_Warning(const char *s, ...) {
|
||||
rc = Yap_execute_pred(pred, ts, true PASS_REGS);
|
||||
return rc;
|
||||
}
|
||||
void Yap_InitError(yap_error_number e, Term t, const char *msg) {
|
||||
if (LOCAL_ActiveError.status) {
|
||||
Yap_exit(1);
|
||||
}
|
||||
LOCAL_ActiveError.errorNo = e;
|
||||
LOCAL_ActiveError.errorFile = NULL;
|
||||
LOCAL_ActiveError.errorFunction = NULL;
|
||||
LOCAL_ActiveError.errorLine = 0;
|
||||
if (msg) {
|
||||
LOCAL_Error_Size = strlen(msg);
|
||||
strcpy(LOCAL_ActiveError.errorComment, msg);
|
||||
} else {
|
||||
LOCAL_Error_Size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool Yap_PrintWarning(Term twarning) {
|
||||
CACHE_REGS
|
||||
PredEntry *pred = RepPredProp(PredPropByFunc(
|
||||
FunctorPrintMessage, PROLOG_MODULE)); // PROCEDURE_print_message2;
|
||||
Term cmod = ( CurrentModule == PROLOG_MODULE ? TermProlog : CurrentModule );
|
||||
PredEntry *pred = RepPredProp(PredPropByFunc(
|
||||
FunctorPrintMessage, PROLOG_MODULE)); // PROCEDURE_print_message2;
|
||||
Term cmod = (CurrentModule == PROLOG_MODULE ? TermProlog : CurrentModule);
|
||||
bool rc;
|
||||
Term ts[2];
|
||||
|
||||
@ -91,9 +104,7 @@ bool Yap_PrintWarning(Term twarning) {
|
||||
}
|
||||
LOCAL_DoingUndefp = true;
|
||||
LOCAL_within_print_message = true;
|
||||
if (pred->OpcodeOfPred == UNDEF_OPCODE ||
|
||||
pred->OpcodeOfPred == FAIL_OPCODE
|
||||
) {
|
||||
if (pred->OpcodeOfPred == UNDEF_OPCODE || pred->OpcodeOfPred == FAIL_OPCODE) {
|
||||
fprintf(stderr, "warning message:\n");
|
||||
Yap_DebugPlWrite(twarning);
|
||||
fprintf(stderr, "\n");
|
||||
@ -105,19 +116,19 @@ bool Yap_PrintWarning(Term twarning) {
|
||||
ts[1] = twarning;
|
||||
ts[0] = MkAtomTerm(AtomWarning);
|
||||
HB = B->cp_h = HR;
|
||||
B->cp_tr = TR;
|
||||
B->cp_tr = TR;
|
||||
rc = Yap_execute_pred(pred, ts, true PASS_REGS);
|
||||
LOCAL_within_print_message = false;
|
||||
LOCAL_DoingUndefp = false;
|
||||
return rc;
|
||||
}
|
||||
|
||||
bool Yap_HandleError__(const char *file, const char *function, int lineno, const char *s, ...) {
|
||||
bool Yap_HandleError__(const char *file, const char *function, int lineno,
|
||||
const char *s, ...) {
|
||||
CACHE_REGS
|
||||
yap_error_number err = LOCAL_Error_TYPE;
|
||||
yap_error_number err = LOCAL_Error_TYPE;
|
||||
const char *serr;
|
||||
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
if (LOCAL_ErrorMessage) {
|
||||
serr = LOCAL_ErrorMessage;
|
||||
} else {
|
||||
@ -136,7 +147,8 @@ bool Yap_HandleError__(const char *file, const char *function, int lineno, const
|
||||
}
|
||||
if (!Yap_ExpandPreAllocCodeSpace(0, NULL, TRUE)) {
|
||||
/* crash in flames */
|
||||
Yap_Error__(file, function, lineno, RESOURCE_ERROR_AUXILIARY_STACK, ARG1, serr);
|
||||
Yap_Error__(file, function, lineno, RESOURCE_ERROR_AUXILIARY_STACK, ARG1,
|
||||
serr);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -153,10 +165,9 @@ bool Yap_HandleError__(const char *file, const char *function, int lineno, const
|
||||
|
||||
int Yap_SWIHandleError(const char *s, ...) {
|
||||
CACHE_REGS
|
||||
yap_error_number err = LOCAL_Error_TYPE;
|
||||
yap_error_number err = LOCAL_Error_TYPE;
|
||||
char *serr;
|
||||
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
if (LOCAL_ErrorMessage) {
|
||||
serr = LOCAL_ErrorMessage;
|
||||
} else {
|
||||
@ -193,28 +204,27 @@ int Yap_SWIHandleError(const char *s, ...) {
|
||||
void Yap_RestartYap(int flag) {
|
||||
CACHE_REGS
|
||||
#if PUSH_REGS
|
||||
restore_absmi_regs(&Yap_standard_regs);
|
||||
restore_absmi_regs(&Yap_standard_regs);
|
||||
#endif
|
||||
siglongjmp(LOCAL_RestartEnv, 1);
|
||||
}
|
||||
|
||||
static void error_exit_yap(int value) {
|
||||
CACHE_REGS
|
||||
if (!(LOCAL_PrologMode & BootMode)) {
|
||||
if (!(LOCAL_PrologMode & BootMode)) {
|
||||
|
||||
#if DEBUG
|
||||
#endif
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "\n Exiting ....\n");
|
||||
#if HAVE_BACKTRACE
|
||||
void *callstack[256];
|
||||
int i;
|
||||
int frames = backtrace(callstack, 256);
|
||||
char** strs = backtrace_symbols(callstack, frames);
|
||||
char **strs = backtrace_symbols(callstack, frames);
|
||||
fprintf(stderr, "Execution stack:\n");
|
||||
for (i = 0; i < frames; ++i) {
|
||||
fprintf(stderr, " %s\n", strs[i]);
|
||||
|
||||
}
|
||||
free(strs);
|
||||
#endif
|
||||
@ -243,45 +253,45 @@ static char tmpbuf[YAP_BUF_SIZE];
|
||||
#undef E2
|
||||
#undef END_ERRORS
|
||||
|
||||
#define BEGIN_ERROR_CLASSES() \
|
||||
static Term mkerrorct(yap_error_class_number c, Term *ts) { \
|
||||
#define BEGIN_ERROR_CLASSES() \
|
||||
static Term mkerrorct(yap_error_class_number c, Term *ts) { \
|
||||
switch (c) {
|
||||
|
||||
#define ECLASS(CL, A, B) \
|
||||
case CL: \
|
||||
if (A == 0) \
|
||||
return MkAtomTerm(Yap_LookupAtom(A)); \
|
||||
else { \
|
||||
return Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom(A), B), B, ts); \
|
||||
}
|
||||
#define ECLASS(CL, A, B) \
|
||||
case CL: \
|
||||
if (A == 0) \
|
||||
return MkAtomTerm(Yap_LookupAtom(A)); \
|
||||
else { \
|
||||
return Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom(A), B), B, ts); \
|
||||
}
|
||||
|
||||
#define END_ERROR_CLASSES() \
|
||||
} \
|
||||
#define END_ERROR_CLASSES() \
|
||||
} \
|
||||
}
|
||||
|
||||
#define BEGIN_ERRORS() \
|
||||
static Term mkerrort(yap_error_number e, Term *ts) { \
|
||||
#define BEGIN_ERRORS() \
|
||||
static Term mkerrort(yap_error_number e, Term *ts) { \
|
||||
switch (e) {
|
||||
|
||||
#define E0(A, B) \
|
||||
case A: \
|
||||
return mkerrorct(B, ts);
|
||||
#define E0(A, B) \
|
||||
case A: \
|
||||
return mkerrorct(B, ts);
|
||||
|
||||
#define E(A, B, C) \
|
||||
case A: \
|
||||
ts -= 1; \
|
||||
ts[0] = MkAtomTerm(Yap_LookupAtom(C)); \
|
||||
return mkerrorct(B, ts);
|
||||
#define E(A, B, C) \
|
||||
case A: \
|
||||
ts -= 1; \
|
||||
ts[0] = MkAtomTerm(Yap_LookupAtom(C)); \
|
||||
return mkerrorct(B, ts);
|
||||
|
||||
#define E2(A, B, C, D) \
|
||||
case A: \
|
||||
ts -= 2; \
|
||||
ts[0] = MkAtomTerm(Yap_LookupAtom(C)); \
|
||||
ts[1] = MkAtomTerm(Yap_LookupAtom(D)); \
|
||||
return mkerrorct(B, ts);
|
||||
#define E2(A, B, C, D) \
|
||||
case A: \
|
||||
ts -= 2; \
|
||||
ts[0] = MkAtomTerm(Yap_LookupAtom(C)); \
|
||||
ts[1] = MkAtomTerm(Yap_LookupAtom(D)); \
|
||||
return mkerrorct(B, ts);
|
||||
|
||||
#define END_ERRORS() \
|
||||
} \
|
||||
#define END_ERRORS() \
|
||||
} \
|
||||
}
|
||||
|
||||
#include "YapErrors.h"
|
||||
@ -322,10 +332,10 @@ static char tmpbuf[YAP_BUF_SIZE];
|
||||
yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
yap_error_number type, Term where, ...) {
|
||||
CACHE_REGS
|
||||
va_list ap;
|
||||
va_list ap;
|
||||
CELL nt[3];
|
||||
Functor fun;
|
||||
Term error_t;
|
||||
Term error_t;
|
||||
Term comment;
|
||||
char *format;
|
||||
char s[MAXPATHLEN];
|
||||
@ -336,15 +346,21 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
tmpbuf);
|
||||
Yap_RestartYap(1);
|
||||
}
|
||||
LOCAL_ActiveError.errorNo = type;
|
||||
LOCAL_ActiveError.errorClass = Yap_errorClass(LOCAL_ActiveError.errorNo);
|
||||
LOCAL_ActiveError.errorLine = lineno;
|
||||
LOCAL_ActiveError.errorFunction = function;
|
||||
LOCAL_ActiveError.errorFile = file;
|
||||
Yap_find_prolog_culprit(PASS_REGS1);
|
||||
LOCAL_PrologMode |= InErrorMode;
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
Yap_ClearExs();
|
||||
if (where == 0L) {
|
||||
where = TermNil;
|
||||
}
|
||||
// first, obtain current location
|
||||
// sprintf(LOCAL_FileNameBuf, "%s:%d in C-function %s ", file, lineno, function);
|
||||
// tf = MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf));
|
||||
// first, obtain current location
|
||||
// sprintf(LOCAL_FileNameBuf, "%s:%d in C-function %s ", file, lineno,
|
||||
// function);
|
||||
// tf = MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf));
|
||||
#if DEBUG_STRICT
|
||||
if (Yap_heap_regs && !(LOCAL_PrologMode & BootMode))
|
||||
fprintf(stderr, "***** Processing Error %d (%lx,%x) %s***\n", type,
|
||||
@ -416,14 +432,15 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
|
||||
if (LOCAL_PrologMode & BootMode) {
|
||||
/* crash in flames! */
|
||||
fprintf(stderr, "%s:%d:0 YAP Fatal Error %d in function %s:\n %s exiting....\n", file, lineno, type, function, s);
|
||||
fprintf(stderr,
|
||||
"%s:%d:0 YAP Fatal Error %d in function %s:\n %s exiting....\n",
|
||||
file, lineno, type, function, s);
|
||||
error_exit_yap(1);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
// DumpActiveGoals( USES_REGS1 );
|
||||
// DumpActiveGoals( USES_REGS1 );
|
||||
#endif /* DEBUG */
|
||||
if (!IsVarTerm(where) &&
|
||||
IsApplTerm(where) &&
|
||||
if (!IsVarTerm(where) && IsApplTerm(where) &&
|
||||
FunctorOfTerm(where) == FunctorError) {
|
||||
error_t = where;
|
||||
P = (yamop *)FAILCODE;
|
||||
@ -440,16 +457,16 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
} else {
|
||||
Yap_detect_bug_location(P, FIND_PRED_FROM_ANYWHERE, YAP_BUF_SIZE);
|
||||
if (tmpbuf[0]) {
|
||||
fprintf(stderr, "%% Bug found while executing %s\n", tmpbuf);
|
||||
fprintf(stderr, "%% Bug found while executing %s\n", tmpbuf);
|
||||
}
|
||||
#if HAVE_BACKTRACE
|
||||
void *callstack[256];
|
||||
int i;
|
||||
int frames = backtrace(callstack, 256);
|
||||
char** strs = backtrace_symbols(callstack, frames);
|
||||
char **strs = backtrace_symbols(callstack, frames);
|
||||
fprintf(stderr, "Execution stack:\n");
|
||||
for (i = 0; i < frames; ++i) {
|
||||
fprintf(stderr, " %s\n", strs[i]);
|
||||
fprintf(stderr, " %s\n", strs[i]);
|
||||
}
|
||||
free(strs);
|
||||
#endif
|
||||
@ -496,27 +513,24 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
LOCAL_PrologMode &= ~InErrorMode;
|
||||
return (P);
|
||||
default: {
|
||||
LOCAL_PrologMode &= ~InErrorMode;
|
||||
LOCAL_PrologMode &= ~InErrorMode;
|
||||
Term ts[3];
|
||||
ts[2] = where;
|
||||
nt[0] = mkerrort(type, ts + 2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
LOCAL_PrologMode &= ~InErrorMode;
|
||||
LOCAL_PrologMode &= ~InErrorMode;
|
||||
if (type != ABORT_EVENT) {
|
||||
Term location;
|
||||
|
||||
/* This is used by some complex procedures to detect there was an error */
|
||||
if (IsAtomTerm(nt[0])) {
|
||||
strncpy(LOCAL_ErrorSay, (char *) RepAtom(AtomOfTerm(nt[0]))->StrOfAE,
|
||||
strncpy(LOCAL_ErrorSay, (char *)RepAtom(AtomOfTerm(nt[0]))->StrOfAE,
|
||||
MAX_ERROR_MSG_SIZE);
|
||||
LOCAL_ErrorMessage = LOCAL_ErrorSay;
|
||||
} else {
|
||||
strncpy(LOCAL_ErrorSay,
|
||||
(char *) RepAtom(NameOfFunctor(FunctorOfTerm(nt[0])))->StrOfAE,
|
||||
(char *)RepAtom(NameOfFunctor(FunctorOfTerm(nt[0])))->StrOfAE,
|
||||
MAX_ERROR_MSG_SIZE);
|
||||
LOCAL_ErrorMessage = LOCAL_ErrorSay;
|
||||
}
|
||||
@ -526,26 +540,26 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
case RESOURCE_ERROR_STACK:
|
||||
case RESOURCE_ERROR_TRAIL:
|
||||
comment = MkAtomTerm(Yap_LookupAtom(tmpbuf));
|
||||
default:
|
||||
default:
|
||||
if (comment != TermNil)
|
||||
nt[1] = MkPairTerm(MkPairTerm(MkAtomTerm(Yap_LookupAtom("i")), comment),
|
||||
nt[1]);
|
||||
nt[1] = MkPairTerm(MkPairTerm(MkAtomTerm(Yap_LookupAtom("i")), comment),
|
||||
nt[1]);
|
||||
if (file && function) {
|
||||
Term ts[3], t3;
|
||||
ts[0] = MkAtomTerm(Yap_LookupAtom(file));
|
||||
ts[1] = MkIntegerTerm(lineno);
|
||||
ts[2] = MkAtomTerm(Yap_LookupAtom(function));
|
||||
t3 = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("c"), 3), 3, ts);
|
||||
nt[1] =
|
||||
MkPairTerm(MkPairTerm(MkAtomTerm(Yap_LookupAtom("c")), t3), nt[1]);
|
||||
Term ts[3], t3;
|
||||
ts[0] = MkAtomTerm(Yap_LookupAtom(file));
|
||||
ts[1] = MkIntegerTerm(lineno);
|
||||
ts[2] = MkAtomTerm(Yap_LookupAtom(function));
|
||||
t3 = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("c"), 3), 3, ts);
|
||||
nt[1] =
|
||||
MkPairTerm(MkPairTerm(MkAtomTerm(Yap_LookupAtom("c")), t3), nt[1]);
|
||||
}
|
||||
if ((location = Yap_pc_location(P, B, ENV)) != TermNil) {
|
||||
nt[1] = MkPairTerm(MkPairTerm(MkAtomTerm(Yap_LookupAtom("p")), location),
|
||||
nt[1]);
|
||||
nt[1] = MkPairTerm(
|
||||
MkPairTerm(MkAtomTerm(Yap_LookupAtom("p")), location), nt[1]);
|
||||
}
|
||||
if ((location = Yap_env_location(CP, B, ENV, 0)) != TermNil) {
|
||||
nt[1] = MkPairTerm(MkPairTerm(MkAtomTerm(Yap_LookupAtom("e")), location),
|
||||
nt[1]);
|
||||
nt[1] = MkPairTerm(
|
||||
MkPairTerm(MkAtomTerm(Yap_LookupAtom("e")), location), nt[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -553,13 +567,13 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
LOCAL_Signals = 0;
|
||||
CalculateStackGap(PASS_REGS1);
|
||||
#if DEBUG
|
||||
// DumpActiveGoals( PASS_REGS1 );
|
||||
// DumpActiveGoals( PASS_REGS1 );
|
||||
#endif
|
||||
/* wait if we we are in user code,
|
||||
it's up to her to decide */
|
||||
fun = FunctorError;
|
||||
error_t = Yap_MkApplTerm(fun, 2, nt);
|
||||
|
||||
|
||||
if (type == ABORT_EVENT) {
|
||||
error_t = MkAtomTerm(AtomDAbort);
|
||||
} else {
|
||||
@ -567,17 +581,14 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
}
|
||||
Yap_JumpToEnv(error_t);
|
||||
P = (yamop *)FAILCODE;
|
||||
|
||||
|
||||
LOCAL_PrologMode &= ~InErrorMode;
|
||||
return P;
|
||||
}
|
||||
|
||||
static Int
|
||||
is_boolean( USES_REGS1 )
|
||||
{
|
||||
static Int is_boolean(USES_REGS1) {
|
||||
Term t = Deref(ARG1);
|
||||
//Term Context = Deref(ARG2)Yap_Error(INSTANTIATION_ERROR, t, NULL);;
|
||||
// Term Context = Deref(ARG2)Yap_Error(INSTANTIATION_ERROR, t, NULL);;
|
||||
if (IsVarTerm(t)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, t, NULL);
|
||||
return false;
|
||||
@ -585,25 +596,19 @@ is_boolean( USES_REGS1 )
|
||||
return t == TermTrue || t == TermFalse;
|
||||
}
|
||||
|
||||
static Int
|
||||
is_atom( USES_REGS1 )
|
||||
{
|
||||
static Int is_atom(USES_REGS1) {
|
||||
Term t = Deref(ARG1);
|
||||
//Term Context = Deref(ARG2)Yap_Error(INSTANTIATION_ERROR, t, NULL);;
|
||||
// Term Context = Deref(ARG2)Yap_Error(INSTANTIATION_ERROR, t, NULL);;
|
||||
if (IsVarTerm(t)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, t, NULL);
|
||||
return false;
|
||||
}
|
||||
return IsAtomTerm( t );
|
||||
return IsAtomTerm(t);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static Int
|
||||
is_callable( USES_REGS1 )
|
||||
{
|
||||
static Int is_callable(USES_REGS1) {
|
||||
Term G = Deref(ARG1);
|
||||
//Term Context = Deref(ARG2);
|
||||
// Term Context = Deref(ARG2);
|
||||
while (true) {
|
||||
if (IsVarTerm(G)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, G, NULL);
|
||||
@ -615,7 +620,7 @@ is_callable( USES_REGS1 )
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, G, NULL);
|
||||
}
|
||||
if (f == FunctorModule) {
|
||||
Term tm = ArgOfTerm( 1, G);
|
||||
Term tm = ArgOfTerm(1, G);
|
||||
if (IsVarTerm(tm)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, G, NULL);
|
||||
return false;
|
||||
@ -624,7 +629,7 @@ is_callable( USES_REGS1 )
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, G, NULL);
|
||||
return false;
|
||||
}
|
||||
G = ArgOfTerm( 2, G );
|
||||
G = ArgOfTerm(2, G);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
@ -638,11 +643,9 @@ is_callable( USES_REGS1 )
|
||||
return false;
|
||||
}
|
||||
|
||||
static Int
|
||||
is_predicate_indicator( USES_REGS1 )
|
||||
{
|
||||
static Int is_predicate_indicator(USES_REGS1) {
|
||||
Term G = Deref(ARG1);
|
||||
//Term Context = Deref(ARG2);
|
||||
// Term Context = Deref(ARG2);
|
||||
Term mod = CurrentModule;
|
||||
|
||||
G = Yap_YapStripModule(G, &mod);
|
||||
@ -667,13 +670,85 @@ is_predicate_indicator( USES_REGS1 )
|
||||
return false;
|
||||
}
|
||||
|
||||
static Int close_error(USES_REGS1) {
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
Yap_InitErrorPreds( void )
|
||||
{
|
||||
#undef BEGIN_ERROR_CLASSES
|
||||
#undef ECLASS
|
||||
#undef END_ERROR_CLASSES
|
||||
#undef BEGIN_ERRORS
|
||||
#undef E0
|
||||
#undef E
|
||||
#undef E2
|
||||
#undef END_ERRORS
|
||||
|
||||
#define BEGIN_ERROR_CLASSES() typedef enum aux_class {
|
||||
|
||||
#define ECLASS(CL, A, B) CL##__,
|
||||
|
||||
#define END_ERROR_CLASSES() \
|
||||
} \
|
||||
aux_class_t;
|
||||
|
||||
#define BEGIN_ERRORS()
|
||||
#define E0(X, Y)
|
||||
#define E(X, Y, Z)
|
||||
#define E2(X, Y, Z, W)
|
||||
#define END_ERRORS()
|
||||
|
||||
#include <YapErrors.h>
|
||||
|
||||
#undef BEGIN_ERROR_CLASSES
|
||||
#undef ECLASS
|
||||
#undef END_ERROR_CLASSES
|
||||
#undef BEGIN_ERRORS
|
||||
#undef E0
|
||||
#undef E
|
||||
#undef E2
|
||||
#undef END_ERRORS
|
||||
|
||||
#define BEGIN_ERROR_CLASSES() static const char *c_error_class_name[] = {
|
||||
|
||||
#define ECLASS(CL, A, B) A,
|
||||
|
||||
#define END_ERROR_CLASSES() \
|
||||
NULL \
|
||||
}
|
||||
|
||||
typedef struct c_error_info {
|
||||
int class;
|
||||
const char *name;
|
||||
} c_error_t;
|
||||
|
||||
#define BEGIN_ERRORS() static struct c_error_info c_error_list[] = {
|
||||
#define E0(X, Y) {Y##__, ""},
|
||||
#define E(X, Y, Z) {Y##__, Z},
|
||||
#define E2(X, Y, Z, W) {Y##__, Z " " W},
|
||||
#define END_ERRORS() \
|
||||
{ YAPC_NO_ERROR, "" } \
|
||||
} \
|
||||
;
|
||||
|
||||
#include <YapErrors.h>
|
||||
|
||||
yap_error_class_number Yap_errorClass(yap_error_number e) {
|
||||
return c_error_list[e].class;
|
||||
}
|
||||
|
||||
const char *Yap_errorName(yap_error_number e) { return c_error_list[e].name; }
|
||||
|
||||
const char *Yap_errorClassName(yap_error_class_number e) {
|
||||
return c_error_class_name[e];
|
||||
}
|
||||
|
||||
void Yap_InitErrorPreds(void) {
|
||||
CACHE_REGS
|
||||
Yap_InitCPred("is_boolean", 2, is_boolean, TestPredFlag);
|
||||
Yap_InitCPred("$close_error", 0, close_error, HiddenPredFlag);
|
||||
Yap_InitCPred("is_boolean", 2, is_boolean, TestPredFlag);
|
||||
Yap_InitCPred("is_callable", 2, is_callable, TestPredFlag);
|
||||
Yap_InitCPred("is_atom", 2, is_atom, TestPredFlag);
|
||||
Yap_InitCPred("is_predicate_indicator", 2, is_predicate_indicator, TestPredFlag);
|
||||
Yap_InitCPred("is_predicate_indicator", 2, is_predicate_indicator,
|
||||
TestPredFlag);
|
||||
}
|
||||
|
16
H/LOCALS
16
H/LOCALS
@ -86,8 +86,6 @@ char* ScannerStack =NULL
|
||||
struct scanner_extra_alloc* ScannerExtraBlocks =NULL
|
||||
|
||||
/// worker control information
|
||||
/// pointer to an exception term, from throw
|
||||
struct DB_TERM* BallTerm =NULL RestoreBallTerm(wid)
|
||||
/// stack limit after which the stack is managed by C-code.
|
||||
Int CBorder =0
|
||||
|
||||
@ -198,12 +196,12 @@ ADDR TrailBase void
|
||||
ADDR TrailTop void
|
||||
char* ErrorMessage void
|
||||
Term Error_Term void
|
||||
yap_error_number Error_TYPE void
|
||||
const char* Error_File void
|
||||
const char* Error_Function void
|
||||
int Error_Lineno void
|
||||
size_t Error_Size void
|
||||
char ErrorSay[MAX_ERROR_MSG_SIZE] void
|
||||
|
||||
/** error handling info, designed to be easy to pass to the foreign world */
|
||||
struct yap_error_descriptor ActiveError void
|
||||
/// pointer to an exception term, from throw
|
||||
struct DB_TERM* BallTerm =NULL
|
||||
|
||||
jmp_buf IOBotch void
|
||||
TokEntry* tokptr void
|
||||
TokEntry* toktide void
|
||||
@ -307,7 +305,7 @@ UInt exo_arg =0
|
||||
struct scan_atoms* search_atoms void
|
||||
struct pred_entry* SearchPreds void
|
||||
|
||||
// Slots
|
||||
/// Slots Status
|
||||
yhandle_t CurSlot =0
|
||||
yhandle_t FrozenHandles =0
|
||||
yhandle_t NSlots =0
|
||||
|
@ -48,7 +48,7 @@
|
||||
#define HeapLim Yap_heap_regs->HeapLim_
|
||||
#define FreeBlocks Yap_heap_regs->FreeBlocks_
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
#define fFreeBlocksLock Yap_heap_regs->FreeBlocksLock_
|
||||
#define FreeBlocksLock Yap_heap_regs->FreeBlocksLock_
|
||||
#define HeapUsedLock Yap_heap_regs->HeapUsedLock_
|
||||
#define HeapTopLock Yap_heap_regs->HeapTopLock_
|
||||
#define HeapTopOwner Yap_heap_regs->HeapTopOwner_
|
||||
|
@ -133,9 +133,6 @@
|
||||
#define REMOTE_ScannerExtraBlocks(wid) REMOTE(wid)->ScannerExtraBlocks_
|
||||
|
||||
|
||||
#define LOCAL_BallTerm LOCAL->BallTerm_
|
||||
#define REMOTE_BallTerm(wid) REMOTE(wid)->BallTerm_
|
||||
|
||||
#define LOCAL_CBorder LOCAL->CBorder_
|
||||
#define REMOTE_CBorder(wid) REMOTE(wid)->CBorder_
|
||||
|
||||
@ -295,18 +292,12 @@
|
||||
#define REMOTE_ErrorMessage(wid) REMOTE(wid)->ErrorMessage_
|
||||
#define LOCAL_Error_Term LOCAL->Error_Term_
|
||||
#define REMOTE_Error_Term(wid) REMOTE(wid)->Error_Term_
|
||||
#define LOCAL_Error_TYPE LOCAL->Error_TYPE_
|
||||
#define REMOTE_Error_TYPE(wid) REMOTE(wid)->Error_TYPE_
|
||||
#define LOCAL_Error_File LOCAL->Error_File_
|
||||
#define REMOTE_Error_File(wid) REMOTE(wid)->Error_File_
|
||||
#define LOCAL_Error_Function LOCAL->Error_Function_
|
||||
#define REMOTE_Error_Function(wid) REMOTE(wid)->Error_Function_
|
||||
#define LOCAL_Error_Lineno LOCAL->Error_Lineno_
|
||||
#define REMOTE_Error_Lineno(wid) REMOTE(wid)->Error_Lineno_
|
||||
#define LOCAL_Error_Size LOCAL->Error_Size_
|
||||
#define REMOTE_Error_Size(wid) REMOTE(wid)->Error_Size_
|
||||
#define LOCAL_ErrorSay LOCAL->ErrorSay_
|
||||
#define REMOTE_ErrorSay(wid) REMOTE(wid)->ErrorSay_
|
||||
|
||||
#define LOCAL_ActiveError LOCAL->ActiveError_
|
||||
#define REMOTE_ActiveError(wid) REMOTE(wid)->ActiveError_
|
||||
|
||||
#define LOCAL_BallTerm LOCAL->BallTerm_
|
||||
#define REMOTE_BallTerm(wid) REMOTE(wid)->BallTerm_
|
||||
#define LOCAL_IOBotch LOCAL->IOBotch_
|
||||
#define REMOTE_IOBotch(wid) REMOTE(wid)->IOBotch_
|
||||
#define LOCAL_tokptr LOCAL->tokptr_
|
||||
|
@ -1,279 +1,277 @@
|
||||
|
||||
/* This file, hlocals.h, was generated automatically by "yap -L misc/buildlocalglobal"
|
||||
please do not update, update H/LOCALS instead */
|
||||
/* This file, hlocals.h, was generated automatically by "yap -L
|
||||
misc/buildlocalglobal"
|
||||
please do not update, update H/LOCALS instead */
|
||||
|
||||
// Stuff that must be considered local to a thread or worker
|
||||
typedef struct worker_local {
|
||||
// Streams
|
||||
int c_input_stream_;
|
||||
int c_output_stream_;
|
||||
int c_error_stream_;
|
||||
bool sockets_io_;
|
||||
bool within_print_message_;
|
||||
//
|
||||
// Used by the prompts to check if they are after a newline, and then a
|
||||
// prompt should be output, or if we are in the middle of a line.
|
||||
//
|
||||
bool newline_;
|
||||
Atom AtPrompt_;
|
||||
char Prompt_[MAX_PROMPT+1];
|
||||
encoding_t encoding_;
|
||||
bool quasi_quotations_;
|
||||
UInt default_priority_;
|
||||
bool eot_before_eof_;
|
||||
UInt max_depth_;
|
||||
UInt max_list_;
|
||||
UInt max_write_args_;
|
||||
// Restore info
|
||||
CELL* OldASP_;
|
||||
CELL* OldLCL0_;
|
||||
tr_fr_ptr OldTR_;
|
||||
CELL* OldGlobalBase_;
|
||||
CELL* OldH_;
|
||||
CELL* OldH0_;
|
||||
ADDR OldTrailBase_;
|
||||
ADDR OldTrailTop_;
|
||||
ADDR OldHeapBase_;
|
||||
ADDR OldHeapTop_;
|
||||
Int ClDiff_;
|
||||
Int GDiff_;
|
||||
Int HDiff_;
|
||||
Int GDiff0_;
|
||||
CELL* GSplit_;
|
||||
Int LDiff_;
|
||||
Int TrDiff_;
|
||||
Int XDiff_;
|
||||
Int DelayDiff_;
|
||||
Int BaseDiff_;
|
||||
// Reduction counters
|
||||
YAP_ULONG_LONG ReductionsCounter_;
|
||||
YAP_ULONG_LONG PredEntriesCounter_;
|
||||
YAP_ULONG_LONG RetriesCounter_;
|
||||
int ReductionsCounterOn_;
|
||||
int PredEntriesCounterOn_;
|
||||
int RetriesCounterOn_;
|
||||
// support for consulting files
|
||||
/* current consult stack */
|
||||
union CONSULT_OBJ* ConsultSp_;
|
||||
/* current maximum number of cells in consult stack */
|
||||
UInt ConsultCapacity_;
|
||||
/* top of consult stack */
|
||||
union CONSULT_OBJ* ConsultBase_;
|
||||
/* low-water mark for consult */
|
||||
union CONSULT_OBJ* ConsultLow_;
|
||||
Term VarNames_;
|
||||
Atom SourceFileName_;
|
||||
UInt SourceFileLineno_;
|
||||
//global variables
|
||||
Term GlobalArena_;
|
||||
UInt GlobalArenaOverflows_;
|
||||
Int ArenaOverflows_;
|
||||
Int DepthArenas_;
|
||||
int ArithError_;
|
||||
struct pred_entry* LastAssertedPred_;
|
||||
struct pred_entry* TmpPred_;
|
||||
char* ScannerStack_;
|
||||
struct scanner_extra_alloc* ScannerExtraBlocks_;
|
||||
/// worker control information
|
||||
/// pointer to an exception term, from throw
|
||||
struct DB_TERM* BallTerm_;
|
||||
/// stack limit after which the stack is managed by C-code.
|
||||
Int CBorder_;
|
||||
/// max number of signals (uint64_t)
|
||||
UInt MaxActiveSignals_;
|
||||
/// actual life signals
|
||||
uint64_t Signals_;
|
||||
/// indexing help data?
|
||||
UInt IPredArity_;
|
||||
yamop* ProfEnd_;
|
||||
int DoingUndefp_;
|
||||
Int StartCharCount_;
|
||||
Int StartLineCount_;
|
||||
Int StartLinePos_;
|
||||
scratch_block ScratchPad_;
|
||||
#ifdef COROUTINING
|
||||
Term WokenGoals_;
|
||||
Term AttsMutableList_;
|
||||
// Streams
|
||||
int c_input_stream_;
|
||||
int c_output_stream_;
|
||||
int c_error_stream_;
|
||||
bool sockets_io_;
|
||||
bool within_print_message_;
|
||||
//
|
||||
// Used by the prompts to check if they are after a newline, and then a
|
||||
// prompt should be output, or if we are in the middle of a line.
|
||||
//
|
||||
bool newline_;
|
||||
Atom AtPrompt_;
|
||||
char Prompt_[MAX_PROMPT + 1];
|
||||
encoding_t encoding_;
|
||||
bool quasi_quotations_;
|
||||
UInt default_priority_;
|
||||
bool eot_before_eof_;
|
||||
UInt max_depth_;
|
||||
UInt max_list_;
|
||||
UInt max_write_args_;
|
||||
// Restore info
|
||||
CELL *OldASP_;
|
||||
CELL *OldLCL0_;
|
||||
tr_fr_ptr OldTR_;
|
||||
CELL *OldGlobalBase_;
|
||||
CELL *OldH_;
|
||||
CELL *OldH0_;
|
||||
ADDR OldTrailBase_;
|
||||
ADDR OldTrailTop_;
|
||||
ADDR OldHeapBase_;
|
||||
ADDR OldHeapTop_;
|
||||
Int ClDiff_;
|
||||
Int GDiff_;
|
||||
Int HDiff_;
|
||||
Int GDiff0_;
|
||||
CELL *GSplit_;
|
||||
Int LDiff_;
|
||||
Int TrDiff_;
|
||||
Int XDiff_;
|
||||
Int DelayDiff_;
|
||||
Int BaseDiff_;
|
||||
// Reduction counters
|
||||
YAP_ULONG_LONG ReductionsCounter_;
|
||||
YAP_ULONG_LONG PredEntriesCounter_;
|
||||
YAP_ULONG_LONG RetriesCounter_;
|
||||
int ReductionsCounterOn_;
|
||||
int PredEntriesCounterOn_;
|
||||
int RetriesCounterOn_;
|
||||
// support for consulting files
|
||||
/* current consult stack */
|
||||
union CONSULT_OBJ *ConsultSp_;
|
||||
/* current maximum number of cells in consult stack */
|
||||
UInt ConsultCapacity_;
|
||||
/* top of consult stack */
|
||||
union CONSULT_OBJ *ConsultBase_;
|
||||
/* low-water mark for consult */
|
||||
union CONSULT_OBJ *ConsultLow_;
|
||||
Term VarNames_;
|
||||
Atom SourceFileName_;
|
||||
UInt SourceFileLineno_;
|
||||
// global variables
|
||||
Term GlobalArena_;
|
||||
UInt GlobalArenaOverflows_;
|
||||
Int ArenaOverflows_;
|
||||
Int DepthArenas_;
|
||||
int ArithError_;
|
||||
struct pred_entry *LastAssertedPred_;
|
||||
struct pred_entry *TmpPred_;
|
||||
char *ScannerStack_;
|
||||
struct scanner_extra_alloc *ScannerExtraBlocks_;
|
||||
/// worker control information
|
||||
/// stack limit after which the stack is managed by C-code.
|
||||
Int CBorder_;
|
||||
/// max number of signals (uint64_t)
|
||||
UInt MaxActiveSignals_;
|
||||
/// actual life signals
|
||||
uint64_t Signals_;
|
||||
/// indexing help data?
|
||||
UInt IPredArity_;
|
||||
yamop *ProfEnd_;
|
||||
int DoingUndefp_;
|
||||
Int StartCharCount_;
|
||||
Int StartLineCount_;
|
||||
Int StartLinePos_;
|
||||
scratch_block ScratchPad_;
|
||||
#ifdef COROUTINING
|
||||
Term WokenGoals_;
|
||||
Term AttsMutableList_;
|
||||
#endif
|
||||
// gc_stuff
|
||||
Term GcGeneration_;
|
||||
Term GcPhase_;
|
||||
UInt GcCurrentPhase_;
|
||||
UInt GcCalls_;
|
||||
Int TotGcTime_;
|
||||
YAP_ULONG_LONG TotGcRecovered_;
|
||||
Int LastGcTime_;
|
||||
Int LastSSTime_;
|
||||
CELL* OpenArray_;
|
||||
/* in a single gc */
|
||||
Int total_marked_;
|
||||
Int total_oldies_;
|
||||
struct choicept* current_B_;
|
||||
CELL* prev_HB_;
|
||||
CELL* HGEN_;
|
||||
CELL** iptop_;
|
||||
// gc_stuff
|
||||
Term GcGeneration_;
|
||||
Term GcPhase_;
|
||||
UInt GcCurrentPhase_;
|
||||
UInt GcCalls_;
|
||||
Int TotGcTime_;
|
||||
YAP_ULONG_LONG TotGcRecovered_;
|
||||
Int LastGcTime_;
|
||||
Int LastSSTime_;
|
||||
CELL *OpenArray_;
|
||||
/* in a single gc */
|
||||
Int total_marked_;
|
||||
Int total_oldies_;
|
||||
struct choicept *current_B_;
|
||||
CELL *prev_HB_;
|
||||
CELL *HGEN_;
|
||||
CELL **iptop_;
|
||||
#if defined(GC_NO_TAGS)
|
||||
char* bp_;
|
||||
char *bp_;
|
||||
#endif
|
||||
tr_fr_ptr sTR_;
|
||||
tr_fr_ptr sTR0_;
|
||||
tr_fr_ptr new_TR_;
|
||||
struct gc_mark_continuation* cont_top0_;
|
||||
struct gc_mark_continuation* cont_top_;
|
||||
int discard_trail_entries_;
|
||||
gc_ma_hash_entry gc_ma_hash_table_[GC_MAVARS_HASH_SIZE];
|
||||
gc_ma_hash_entry* gc_ma_h_top_;
|
||||
gc_ma_hash_entry* gc_ma_h_list_;
|
||||
UInt gc_timestamp_;
|
||||
ADDR db_vec_;
|
||||
ADDR db_vec0_;
|
||||
struct RB_red_blk_node* db_root_;
|
||||
struct RB_red_blk_node* db_nil_;
|
||||
sigjmp_buf gc_restore_;
|
||||
CELL* extra_gc_cells_;
|
||||
CELL* extra_gc_cells_base_;
|
||||
CELL* extra_gc_cells_top_;
|
||||
UInt extra_gc_cells_size_;
|
||||
struct array_entry* DynamicArrays_;
|
||||
struct static_array_entry* StaticArrays_;
|
||||
struct global_entry* GlobalVariables_;
|
||||
int AllowRestart_;
|
||||
// Thread Local Area for Fast Storage of Intermediate Compiled Code
|
||||
struct mem_blk* CMemFirstBlock_;
|
||||
UInt CMemFirstBlockSz_;
|
||||
// Variable used by the compiler to store number of permanent vars in a clause
|
||||
int nperm_;
|
||||
// Thread Local Area for Labels
|
||||
Int* LabelFirstArray_;
|
||||
UInt LabelFirstArraySz_;
|
||||
tr_fr_ptr sTR_;
|
||||
tr_fr_ptr sTR0_;
|
||||
tr_fr_ptr new_TR_;
|
||||
struct gc_mark_continuation *cont_top0_;
|
||||
struct gc_mark_continuation *cont_top_;
|
||||
int discard_trail_entries_;
|
||||
gc_ma_hash_entry gc_ma_hash_table_[GC_MAVARS_HASH_SIZE];
|
||||
gc_ma_hash_entry *gc_ma_h_top_;
|
||||
gc_ma_hash_entry *gc_ma_h_list_;
|
||||
UInt gc_timestamp_;
|
||||
ADDR db_vec_;
|
||||
ADDR db_vec0_;
|
||||
struct RB_red_blk_node *db_root_;
|
||||
struct RB_red_blk_node *db_nil_;
|
||||
sigjmp_buf gc_restore_;
|
||||
CELL *extra_gc_cells_;
|
||||
CELL *extra_gc_cells_base_;
|
||||
CELL *extra_gc_cells_top_;
|
||||
UInt extra_gc_cells_size_;
|
||||
struct array_entry *DynamicArrays_;
|
||||
struct static_array_entry *StaticArrays_;
|
||||
struct global_entry *GlobalVariables_;
|
||||
int AllowRestart_;
|
||||
// Thread Local Area for Fast Storage of Intermediate Compiled Code
|
||||
struct mem_blk *CMemFirstBlock_;
|
||||
UInt CMemFirstBlockSz_;
|
||||
// Variable used by the compiler to store number of permanent vars in a clause
|
||||
int nperm_;
|
||||
// Thread Local Area for Labels
|
||||
Int *LabelFirstArray_;
|
||||
UInt LabelFirstArraySz_;
|
||||
// Thread Local Area for SWI-Prolog emulation routines.
|
||||
// struct PL_local_data* PL_local_data_p =Yap_InitThreadIO(wid)
|
||||
// struct PL_local_data* PL_local_data_p
|
||||
// =Yap_InitThreadIO(wid)
|
||||
#ifdef THREADS
|
||||
struct thandle ThreadHandle_;
|
||||
struct thandle ThreadHandle_;
|
||||
#endif /* THREADS */
|
||||
#if defined(YAPOR) || defined(TABLING)
|
||||
struct local_optyap_data optyap_data_;
|
||||
UInt TabMode_;
|
||||
struct local_optyap_data optyap_data_;
|
||||
UInt TabMode_;
|
||||
#endif /* YAPOR || TABLING */
|
||||
int InterruptsDisabled_;
|
||||
struct open_query_struct* execution_;
|
||||
int InterruptsDisabled_;
|
||||
struct open_query_struct *execution_;
|
||||
#if LOW_LEVEL_TRACER
|
||||
Int total_choicepoints_;
|
||||
Int total_choicepoints_;
|
||||
#endif
|
||||
int consult_level_;
|
||||
// Variables related to memory allocation
|
||||
ADDR LocalBase_;
|
||||
ADDR GlobalBase_;
|
||||
ADDR TrailBase_;
|
||||
ADDR TrailTop_;
|
||||
char* ErrorMessage_;
|
||||
Term Error_Term_;
|
||||
yap_error_number Error_TYPE_;
|
||||
const char* Error_File_;
|
||||
const char* Error_Function_;
|
||||
int Error_Lineno_;
|
||||
size_t Error_Size_;
|
||||
char ErrorSay_[MAX_ERROR_MSG_SIZE];
|
||||
jmp_buf IOBotch_;
|
||||
TokEntry* tokptr_;
|
||||
TokEntry* toktide_;
|
||||
VarEntry* VarTable_;
|
||||
VarEntry* AnonVarTable_;
|
||||
Term Comments_;
|
||||
CELL* CommentsTail_;
|
||||
CELL* CommentsNextChar_;
|
||||
wchar_t* CommentsBuff_;
|
||||
size_t CommentsBuffPos_;
|
||||
size_t CommentsBuffLim_;
|
||||
sigjmp_buf RestartEnv_;
|
||||
char FileNameBuf_[YAP_FILENAME_MAX];
|
||||
char FileNameBuf2_[YAP_FILENAME_MAX];
|
||||
// Prolog State
|
||||
UInt BreakLevel_;
|
||||
Int PrologMode_;
|
||||
int CritLocks_;
|
||||
// Prolog execution and state flags
|
||||
union flagTerm* Flags_;
|
||||
UInt flagCount_;
|
||||
//analyst.c
|
||||
int consult_level_;
|
||||
// Variables related to memory allocation
|
||||
ADDR LocalBase_;
|
||||
ADDR GlobalBase_;
|
||||
ADDR TrailBase_;
|
||||
ADDR TrailTop_;
|
||||
char *ErrorMessage_;
|
||||
Term Error_Term_;
|
||||
/** error handling info, designed to be easy to pass to the foreign world */
|
||||
struct yap_error_descriptor ActiveError_;
|
||||
/// pointer to an exception term, from throw
|
||||
struct DB_TERM *BallTerm_;
|
||||
jmp_buf IOBotch_;
|
||||
TokEntry *tokptr_;
|
||||
TokEntry *toktide_;
|
||||
VarEntry *VarTable_;
|
||||
VarEntry *AnonVarTable_;
|
||||
Term Comments_;
|
||||
CELL *CommentsTail_;
|
||||
CELL *CommentsNextChar_;
|
||||
wchar_t *CommentsBuff_;
|
||||
size_t CommentsBuffPos_;
|
||||
size_t CommentsBuffLim_;
|
||||
sigjmp_buf RestartEnv_;
|
||||
char FileNameBuf_[YAP_FILENAME_MAX + 1];
|
||||
char FileNameBuf2_[YAP_FILENAME_MAX + 1];
|
||||
// Prolog State
|
||||
UInt BreakLevel_;
|
||||
Int PrologMode_;
|
||||
int CritLocks_;
|
||||
// Prolog execution and state flags
|
||||
union flagTerm *Flags_;
|
||||
UInt flagCount_;
|
||||
// analyst.c
|
||||
/* used to find out how many instructions of each kind are executed */
|
||||
#ifdef ANALYST
|
||||
YAP_ULONG_LONG opcount_[_std_top+1];
|
||||
YAP_ULONG_LONG 2opcount[_std_top+1][_std_top+1]_;
|
||||
YAP_ULONG_LONG opcount_[_std_top + 1];
|
||||
YAP_ULONG_LONG 2opcount [_std_top + 1][_std_top + 1] _;
|
||||
#endif /* ANALYST */
|
||||
//dbase.c
|
||||
struct db_globs* s_dbg_;
|
||||
//eval.c
|
||||
yap_error_number matherror_;
|
||||
Term mathtt_;
|
||||
char* mathstring_;
|
||||
yap_error_number CurrentError_;
|
||||
//grow.c
|
||||
int heap_overflows_;
|
||||
Int total_heap_overflow_time_;
|
||||
int stack_overflows_;
|
||||
Int total_stack_overflow_time_;
|
||||
int delay_overflows_;
|
||||
Int total_delay_overflow_time_;
|
||||
int trail_overflows_;
|
||||
Int total_trail_overflow_time_;
|
||||
int atom_table_overflows_;
|
||||
Int total_atom_table_overflow_time_;
|
||||
//load_dyld
|
||||
// dbase.c
|
||||
struct db_globs *s_dbg_;
|
||||
// eval.c
|
||||
yap_error_number matherror_;
|
||||
Term mathtt_;
|
||||
char *mathstring_;
|
||||
yap_error_number CurrentError_;
|
||||
// grow.c
|
||||
int heap_overflows_;
|
||||
Int total_heap_overflow_time_;
|
||||
int stack_overflows_;
|
||||
Int total_stack_overflow_time_;
|
||||
int delay_overflows_;
|
||||
Int total_delay_overflow_time_;
|
||||
int trail_overflows_;
|
||||
Int total_trail_overflow_time_;
|
||||
int atom_table_overflows_;
|
||||
Int total_atom_table_overflow_time_;
|
||||
// load_dyld
|
||||
#ifdef LOAD_DYLD
|
||||
int dl_errno_;
|
||||
int dl_errno_;
|
||||
#endif
|
||||
//tracer.c
|
||||
// tracer.c
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
int do_trace_primitives_;
|
||||
int do_trace_primitives_;
|
||||
#endif
|
||||
//quick loader
|
||||
struct export_atom_hash_entry_struct *ExportAtomHashChain_;
|
||||
UInt ExportAtomHashTableSize_;
|
||||
UInt ExportAtomHashTableNum_;
|
||||
struct export_functor_hash_entry_struct *ExportFunctorHashChain_;
|
||||
UInt ExportFunctorHashTableSize_;
|
||||
UInt ExportFunctorHashTableNum_;
|
||||
struct export_pred_entry_hash_entry_struct *ExportPredEntryHashChain_;
|
||||
UInt ExportPredEntryHashTableSize_;
|
||||
UInt ExportPredEntryHashTableNum_;
|
||||
struct export_dbref_hash_entry_struct *ExportDBRefHashChain_;
|
||||
UInt ExportDBRefHashTableSize_;
|
||||
UInt ExportDBRefHashTableNum_;
|
||||
struct import_atom_hash_entry_struct **ImportAtomHashChain_;
|
||||
UInt ImportAtomHashTableSize_;
|
||||
UInt ImportAtomHashTableNum_;
|
||||
struct import_functor_hash_entry_struct **ImportFunctorHashChain_;
|
||||
UInt ImportFunctorHashTableSize_;
|
||||
UInt ImportFunctorHashTableNum_;
|
||||
struct import_opcode_hash_entry_struct **ImportOPCODEHashChain_;
|
||||
UInt ImportOPCODEHashTableSize_;
|
||||
struct import_pred_entry_hash_entry_struct **ImportPredEntryHashChain_;
|
||||
UInt ImportPredEntryHashTableSize_;
|
||||
UInt ImportPredEntryHashTableNum_;
|
||||
struct import_dbref_hash_entry_struct **ImportDBRefHashChain_;
|
||||
UInt ImportDBRefHashTableSize_;
|
||||
UInt ImportDBRefHashTableNum_;
|
||||
yamop *ImportFAILCODE_;
|
||||
// exo indexing
|
||||
UInt ibnds_[256];
|
||||
struct index_t* exo_it_;
|
||||
CELL* exo_base_;
|
||||
UInt exo_arity_;
|
||||
UInt exo_arg_;
|
||||
// atom completion
|
||||
struct scan_atoms* search_atoms_;
|
||||
struct pred_entry* SearchPreds_;
|
||||
// Slots
|
||||
yhandle_t CurSlot_;
|
||||
yhandle_t FrozenHandles_;
|
||||
yhandle_t NSlots_;
|
||||
CELL* SlotBase_;
|
||||
// Mutexes
|
||||
struct swi_mutex* Mutexes_;
|
||||
Term SourceModule_;
|
||||
Term Including_;
|
||||
size_t MAX_SIZE_;
|
||||
/* last call to walltime. */
|
||||
uint64_t LastWTime_;
|
||||
// quick loader
|
||||
struct export_atom_hash_entry_struct *ExportAtomHashChain_;
|
||||
UInt ExportAtomHashTableSize_;
|
||||
UInt ExportAtomHashTableNum_;
|
||||
struct export_functor_hash_entry_struct *ExportFunctorHashChain_;
|
||||
UInt ExportFunctorHashTableSize_;
|
||||
UInt ExportFunctorHashTableNum_;
|
||||
struct export_pred_entry_hash_entry_struct *ExportPredEntryHashChain_;
|
||||
UInt ExportPredEntryHashTableSize_;
|
||||
UInt ExportPredEntryHashTableNum_;
|
||||
struct export_dbref_hash_entry_struct *ExportDBRefHashChain_;
|
||||
UInt ExportDBRefHashTableSize_;
|
||||
UInt ExportDBRefHashTableNum_;
|
||||
struct import_atom_hash_entry_struct **ImportAtomHashChain_;
|
||||
UInt ImportAtomHashTableSize_;
|
||||
UInt ImportAtomHashTableNum_;
|
||||
struct import_functor_hash_entry_struct **ImportFunctorHashChain_;
|
||||
UInt ImportFunctorHashTableSize_;
|
||||
UInt ImportFunctorHashTableNum_;
|
||||
struct import_opcode_hash_entry_struct **ImportOPCODEHashChain_;
|
||||
UInt ImportOPCODEHashTableSize_;
|
||||
struct import_pred_entry_hash_entry_struct **ImportPredEntryHashChain_;
|
||||
UInt ImportPredEntryHashTableSize_;
|
||||
UInt ImportPredEntryHashTableNum_;
|
||||
struct import_dbref_hash_entry_struct **ImportDBRefHashChain_;
|
||||
UInt ImportDBRefHashTableSize_;
|
||||
UInt ImportDBRefHashTableNum_;
|
||||
yamop *ImportFAILCODE_;
|
||||
// exo indexing
|
||||
UInt ibnds_[256];
|
||||
struct index_t *exo_it_;
|
||||
CELL *exo_base_;
|
||||
UInt exo_arity_;
|
||||
UInt exo_arg_;
|
||||
// atom completion
|
||||
struct scan_atoms *search_atoms_;
|
||||
struct pred_entry *SearchPreds_;
|
||||
/// Slots Status
|
||||
yhandle_t CurSlot_;
|
||||
yhandle_t FrozenHandles_;
|
||||
yhandle_t NSlots_;
|
||||
CELL *SlotBase_;
|
||||
// Mutexes
|
||||
struct swi_mutex *Mutexes_;
|
||||
Term SourceModule_;
|
||||
Term Including_;
|
||||
size_t MAX_SIZE_;
|
||||
/* last call to walltime. */
|
||||
uint64_t LastWTime_;
|
||||
} w_local;
|
||||
|
@ -76,8 +76,6 @@ static void InitWorker(int wid) {
|
||||
REMOTE_ScannerExtraBlocks(wid) = NULL;
|
||||
|
||||
|
||||
REMOTE_BallTerm(wid) = NULL;
|
||||
|
||||
REMOTE_CBorder(wid) = 0;
|
||||
|
||||
REMOTE_MaxActiveSignals(wid) = 64L;
|
||||
@ -171,9 +169,7 @@ static void InitWorker(int wid) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
REMOTE_BallTerm(wid) = NULL;
|
||||
|
||||
|
||||
|
||||
|
@ -76,8 +76,6 @@ static void RestoreWorker(int wid USES_REGS) {
|
||||
|
||||
|
||||
|
||||
RestoreBallTerm(wid);
|
||||
|
||||
|
||||
|
||||
|
||||
@ -192,8 +190,6 @@ static void RestoreWorker(int wid USES_REGS) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -36,33 +36,40 @@
|
||||
|
||||
#include "YapErrors.h"
|
||||
|
||||
struct yami *Yap_Error__(const char *file, const char *function, int lineno, yap_error_number err,YAP_Term wheret, ...);
|
||||
#define MAX_ERROR_MSG_SIZE 10
|
||||
|
||||
#define Yap_NilError( id, ...) Yap_Error__(__FILE__, __FUNCTION__, __LINE__, id, TermNil, __VA_ARGS__)
|
||||
struct yami *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
yap_error_number err, YAP_Term wheret, ...);
|
||||
|
||||
#define Yap_Error( id, inp, ...) Yap_Error__(__FILE__, __FUNCTION__, __LINE__, id, inp, __VA_ARGS__)
|
||||
#define Yap_NilError(id, ...) \
|
||||
Yap_Error__(__FILE__, __FUNCTION__, __LINE__, id, TermNil, __VA_ARGS__)
|
||||
|
||||
#define Yap_Error(id, inp, ...) \
|
||||
Yap_Error__(__FILE__, __FUNCTION__, __LINE__, id, inp, __VA_ARGS__)
|
||||
|
||||
#ifdef YAP_TERM_H
|
||||
/**
|
||||
* make sure next argument is a bound instance of type
|
||||
/**
|
||||
* make sure next argument is a bound instance of type
|
||||
* atom.
|
||||
*/
|
||||
#define Yap_ensure_atom( T0, TF ) { if ( (TF = Yap_ensure_atom__(__FILE__, __FUNCTION__, __LINE__, T0 ) == 0L ) return false; }
|
||||
#define Yap_ensure_atom(T0, TF) \
|
||||
{ if ( (TF = Yap_ensure_atom__(__FILE__, __FUNCTION__, __LINE__, T0 ) == 0L ) return false; \
|
||||
}
|
||||
|
||||
INLINE_ONLY extern inline Term
|
||||
Yap_ensure_atom__( const char *fu, const char *fi, int line, Term in )
|
||||
{
|
||||
INLINE_ONLY extern inline Term Yap_ensure_atom__(const char *fu, const char *fi,
|
||||
int line, Term in) {
|
||||
Term t = Deref(in);
|
||||
//Term Context = Deref(ARG2);
|
||||
// Term Context = Deref(ARG2);
|
||||
if (!IsVarTerm(t) && IsAtomTerm(t))
|
||||
return t;
|
||||
if (IsVarTerm(t)) {
|
||||
Yap_Error__(fu, fi, line, INSTANTIATION_ERROR, t, NULL);
|
||||
} else {
|
||||
if ( IsAtomTerm(t) ) return t ;
|
||||
Yap_Error__(fu, fi, line, TYPE_ERROR_ATOM, t, NULL);
|
||||
return 0L;
|
||||
}
|
||||
if (IsAtomTerm(t))
|
||||
return t;
|
||||
Yap_Error__(fu, fi, line, TYPE_ERROR_ATOM, t, NULL);
|
||||
return 0L;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -74,7 +81,7 @@ Yap_ensure_atom__( const char *fu, const char *fi, int line, Term in )
|
||||
goto LAB; \
|
||||
}
|
||||
|
||||
#define LOCAL_ERROR(t, v) \
|
||||
#define LOCAL_ERROR(t, v) \
|
||||
if (HR + (v) > ASP - 1024) { \
|
||||
LOCAL_Error_TYPE = RESOURCE_ERROR_STACK; \
|
||||
LOCAL_Error_Term = t; \
|
||||
@ -82,7 +89,7 @@ Yap_ensure_atom__( const char *fu, const char *fi, int line, Term in )
|
||||
return NULL; \
|
||||
}
|
||||
|
||||
#define LOCAL_TERM_ERROR(t, v) \
|
||||
#define LOCAL_TERM_ERROR(t, v) \
|
||||
if (HR + (v) > ASP - 1024) { \
|
||||
LOCAL_Error_TYPE = RESOURCE_ERROR_STACK; \
|
||||
LOCAL_Error_Term = t; \
|
||||
@ -138,4 +145,67 @@ Yap_ensure_atom__( const char *fu, const char *fi, int line, Term in )
|
||||
goto LAB; \
|
||||
}
|
||||
|
||||
/**
|
||||
* Error stages since it was initially processed.
|
||||
*
|
||||
* Notice that some of the stages may be active simultaneouly.
|
||||
*/
|
||||
typedef enum yap_error_status {
|
||||
/// where we like to be
|
||||
YAP_NO_ERROR_STATUS = 0x0,
|
||||
/// Prolog discovered the problem
|
||||
YAP_ERROR_INITIATED_IN_PROLOG = 0x1,
|
||||
/// The problem was found before the system can cope
|
||||
YAP_ERROR_INITIATED_IN_BOOT = 0x2,
|
||||
/// C-helper like must_ found out the problem
|
||||
YAP_ERROR_INITIATED_IN_HELPER = 0x4,
|
||||
/// C-builtin crashed
|
||||
YAP_ERROR_INITIATED_IN_SYSTEM_C = 0x8,
|
||||
/// user code crashed
|
||||
YAP_ERROR_INITIATED_IN_USER_C = 0x10,
|
||||
/// ok, we put a throw to be dispatched
|
||||
YAP_THROW_THROWN = 0x20,
|
||||
/// someone caught it
|
||||
YAP_THROW_CAUGHT = 0x40,
|
||||
/// error became an exception (usually SWIG bridge)
|
||||
YAP_ERROR_EXPORTED_TO_CXX = 0x80,
|
||||
/// handle error in Prolog
|
||||
YAP_ERROR_BEING_PROCESSED_IN_PROLOG = 0x100
|
||||
/// go back t
|
||||
} yap_error_stage_t;
|
||||
|
||||
/// all we need to know about an error/throw
|
||||
typedef struct yap_error_descriptor {
|
||||
enum yap_error_status status;
|
||||
yap_error_class_number errorClass;
|
||||
yap_error_number errorNo;
|
||||
YAP_Int errorLine;
|
||||
const char *errorFunction;
|
||||
const char *errorFile;
|
||||
YAP_Int prologPredCl;
|
||||
YAP_UInt prologPredLine;
|
||||
YAP_UInt prologPredFirstLine;
|
||||
YAP_UInt prologPredLastLine;
|
||||
YAP_Atom prologPredName;
|
||||
YAP_UInt prologPredArity;
|
||||
YAP_Term prologPredModule;
|
||||
YAP_Atom prologPredFile;
|
||||
struct DB_TERM *errorTerm;
|
||||
char errorComment[MAX_ERROR_MSG_SIZE];
|
||||
size_t errorMsgLen;
|
||||
} yap_error_descriptor_t;
|
||||
|
||||
/// compatibility with existing code..
|
||||
#define LOCAL_Error_TYPE LOCAL_ActiveError.errorNo
|
||||
#define LOCAL_Error_File LOCAL_ActiveError.errorFile
|
||||
#define LOCAL_Error_Function LOCAL_ActiveError.errorFunction
|
||||
#define LOCAL_Error_Lineno LOCAL_ActiveError.errorLine
|
||||
#define LOCAL_Error_Size LOCAL_ActiveError.errorMsgLen
|
||||
#define LOCAL_ErrorSay LOCAL_ActiveError.errorComment
|
||||
|
||||
extern bool Yap_find_prolog_culprit();
|
||||
extern yap_error_class_number Yap_errorClass(yap_error_number e);
|
||||
extern const char *Yap_errorName(yap_error_number e);
|
||||
extern const char *Yap_errorClassName(yap_error_class_number e);
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
///
|
||||
/// @file YapErrors.h
|
||||
///
|
||||
/// @adddtogroup YapError
|
||||
/// /// @adddtogroup YapError
|
||||
///
|
||||
/// The file YapErrors.h contains a list with all the error classes known
|
||||
/// internally to the YAP system.
|
||||
|
Reference in New Issue
Block a user