error handling
This commit is contained in:
parent
29f0f88025
commit
e4fd6a153a
20
C/args.c
20
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) {
|
||||
free(a);
|
||||
LOCAL_ActiveError->errorNo = e;
|
||||
LOCAL_ActiveError->rawErrorTerm = t;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -49,12 +51,13 @@ xarg *Yap_ArgListToVector(Term listl, const param_t *def, int n) {
|
||||
CACHE_REGS
|
||||
listl = Deref(listl);
|
||||
xarg *a = calloc(n, sizeof(xarg));
|
||||
|
||||
if (IsVarTerm(listl)) {
|
||||
return failed(INSTANTIATION_ERROR, listl, a);
|
||||
}
|
||||
if (IsApplTerm(listl) && FunctorOfTerm(listl) == FunctorModule)
|
||||
listl = ArgOfTerm(2, listl);
|
||||
if (!IsPairTerm(listl) && listl != TermNil) {
|
||||
if (IsVarTerm(listl)) {
|
||||
return failed(INSTANTIATION_ERROR, listl, a);
|
||||
}
|
||||
if (IsAtomTerm(listl)) {
|
||||
xarg *na = matchKey(AtomOfTerm(listl), a, n, def);
|
||||
if (!na) {
|
||||
@ -84,12 +87,11 @@ xarg *Yap_ArgListToVector(Term listl, const param_t *def, int n) {
|
||||
while (IsPairTerm(listl)) {
|
||||
Term hd = HeadOfTerm(listl);
|
||||
listl = TailOfTerm(listl);
|
||||
if (IsVarTerm(hd) || IsVarTerm(listl)) {
|
||||
if (IsVarTerm(hd)) {
|
||||
return failed(INSTANTIATION_ERROR, hd, a);
|
||||
} else {
|
||||
return failed(INSTANTIATION_ERROR, listl, a);
|
||||
}
|
||||
if (IsVarTerm(hd)) {
|
||||
return failed(INSTANTIATION_ERROR, hd, a);
|
||||
}
|
||||
if (IsVarTerm(listl)) {
|
||||
return failed(INSTANTIATION_ERROR, listl, a);
|
||||
}
|
||||
if (IsAtomTerm(hd)) {
|
||||
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_Bool prologConsulting;
|
||||
struct DB_TERM *errorTerm;
|
||||
YAP_Term rawErrorTerm, rawExtraErrorTerm;
|
||||
char *errorMsg;
|
||||
size_t errorMsgLen;
|
||||
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_Size LOCAL_ActiveError->errorMsgLen
|
||||
#define LOCAL_BallTerm LOCAL_ActiveError->errorTerm
|
||||
#define LOCAL_RawTerm LOCAL_ActiveError->errorRawTerm
|
||||
#define LOCAL_ErrorMessage LOCAL_ActiveError->errorMsg
|
||||
|
||||
extern bool Yap_find_prolog_culprit(void);
|
||||
|
Reference in New Issue
Block a user