error handling
This commit is contained in:
parent
29f0f88025
commit
e4fd6a153a
14
C/args.c
14
C/args.c
@ -42,6 +42,8 @@ int Yap_ArgKey(Atom key, const param_t *def, int n) {
|
|||||||
|
|
||||||
static xarg *failed__(yap_error_number e, Term t, xarg *a USES_REGS) {
|
static xarg *failed__(yap_error_number e, Term t, xarg *a USES_REGS) {
|
||||||
free(a);
|
free(a);
|
||||||
|
LOCAL_ActiveError->errorNo = e;
|
||||||
|
LOCAL_ActiveError->rawErrorTerm = t;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,12 +51,13 @@ xarg *Yap_ArgListToVector(Term listl, const param_t *def, int n) {
|
|||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
listl = Deref(listl);
|
listl = Deref(listl);
|
||||||
xarg *a = calloc(n, sizeof(xarg));
|
xarg *a = calloc(n, sizeof(xarg));
|
||||||
if (IsApplTerm(listl) && FunctorOfTerm(listl) == FunctorModule)
|
|
||||||
listl = ArgOfTerm(2, listl);
|
|
||||||
if (!IsPairTerm(listl) && listl != TermNil) {
|
|
||||||
if (IsVarTerm(listl)) {
|
if (IsVarTerm(listl)) {
|
||||||
return failed(INSTANTIATION_ERROR, listl, a);
|
return failed(INSTANTIATION_ERROR, listl, a);
|
||||||
}
|
}
|
||||||
|
if (IsApplTerm(listl) && FunctorOfTerm(listl) == FunctorModule)
|
||||||
|
listl = ArgOfTerm(2, listl);
|
||||||
|
if (!IsPairTerm(listl) && listl != TermNil) {
|
||||||
if (IsAtomTerm(listl)) {
|
if (IsAtomTerm(listl)) {
|
||||||
xarg *na = matchKey(AtomOfTerm(listl), a, n, def);
|
xarg *na = matchKey(AtomOfTerm(listl), a, n, def);
|
||||||
if (!na) {
|
if (!na) {
|
||||||
@ -84,12 +87,11 @@ xarg *Yap_ArgListToVector(Term listl, const param_t *def, int n) {
|
|||||||
while (IsPairTerm(listl)) {
|
while (IsPairTerm(listl)) {
|
||||||
Term hd = HeadOfTerm(listl);
|
Term hd = HeadOfTerm(listl);
|
||||||
listl = TailOfTerm(listl);
|
listl = TailOfTerm(listl);
|
||||||
if (IsVarTerm(hd) || IsVarTerm(listl)) {
|
|
||||||
if (IsVarTerm(hd)) {
|
if (IsVarTerm(hd)) {
|
||||||
return failed(INSTANTIATION_ERROR, hd, a);
|
return failed(INSTANTIATION_ERROR, hd, a);
|
||||||
} else {
|
|
||||||
return failed(INSTANTIATION_ERROR, listl, a);
|
|
||||||
}
|
}
|
||||||
|
if (IsVarTerm(listl)) {
|
||||||
|
return failed(INSTANTIATION_ERROR, listl, a);
|
||||||
}
|
}
|
||||||
if (IsAtomTerm(hd)) {
|
if (IsAtomTerm(hd)) {
|
||||||
xarg *na = matchKey(AtomOfTerm(hd), a, n, def);
|
xarg *na = matchKey(AtomOfTerm(hd), a, n, def);
|
||||||
|
@ -217,6 +217,7 @@ INLINE_ONLY extern inline Term Yap_ensure_atom__(const char *fu, const char *fi,
|
|||||||
YAP_Atom prologParserFile;
|
YAP_Atom prologParserFile;
|
||||||
YAP_Bool prologConsulting;
|
YAP_Bool prologConsulting;
|
||||||
struct DB_TERM *errorTerm;
|
struct DB_TERM *errorTerm;
|
||||||
|
YAP_Term rawErrorTerm, rawExtraErrorTerm;
|
||||||
char *errorMsg;
|
char *errorMsg;
|
||||||
size_t errorMsgLen;
|
size_t errorMsgLen;
|
||||||
struct yap_error_descriptor *top_error;
|
struct yap_error_descriptor *top_error;
|
||||||
@ -229,6 +230,7 @@ INLINE_ONLY extern inline Term Yap_ensure_atom__(const char *fu, const char *fi,
|
|||||||
#define LOCAL_Error_Lineno LOCAL_ActiveError->errorLine
|
#define LOCAL_Error_Lineno LOCAL_ActiveError->errorLine
|
||||||
#define LOCAL_Error_Size LOCAL_ActiveError->errorMsgLen
|
#define LOCAL_Error_Size LOCAL_ActiveError->errorMsgLen
|
||||||
#define LOCAL_BallTerm LOCAL_ActiveError->errorTerm
|
#define LOCAL_BallTerm LOCAL_ActiveError->errorTerm
|
||||||
|
#define LOCAL_RawTerm LOCAL_ActiveError->errorRawTerm
|
||||||
#define LOCAL_ErrorMessage LOCAL_ActiveError->errorMsg
|
#define LOCAL_ErrorMessage LOCAL_ActiveError->errorMsg
|
||||||
|
|
||||||
extern bool Yap_find_prolog_culprit(void);
|
extern bool Yap_find_prolog_culprit(void);
|
||||||
|
Reference in New Issue
Block a user