first pass at a decent implementation of PL_error (#95)
- basically copy SWI code.
This commit is contained in:
parent
f61aee4a83
commit
d6ed058157
@ -47,6 +47,7 @@
|
||||
AtomCompound = Yap_LookupAtom("compound");
|
||||
AtomConsistencyError = Yap_LookupAtom("consistency_error");
|
||||
AtomConsultOnBoot = Yap_FullLookupAtom("$consult_on_boot");
|
||||
AtomContext = Yap_LookupAtom("context");
|
||||
AtomCputime = Yap_LookupAtom("cputime");
|
||||
AtomCreate = Yap_LookupAtom("create");
|
||||
AtomCreep = Yap_FullLookupAtom("$creep");
|
||||
@ -140,6 +141,7 @@
|
||||
AtomLocal = Yap_LookupAtom("local_sp");
|
||||
AtomLocalA = Yap_LookupAtom("local");
|
||||
AtomMaxArity = Yap_LookupAtom("max_arity");
|
||||
AtomMaxFiles = Yap_LookupAtom("max_files");
|
||||
AtomMegaClause = Yap_FullLookupAtom("$mega_clause");
|
||||
AtomMetaCall = Yap_FullLookupAtom("$call");
|
||||
AtomMfClause = Yap_FullLookupAtom("$mf_clause");
|
||||
@ -158,8 +160,10 @@
|
||||
AtomNb = Yap_LookupAtom("nb");
|
||||
AtomNbTerm = Yap_LookupAtom("nb_term");
|
||||
AtomNew = Yap_LookupAtom("new");
|
||||
AtomNoMemory = Yap_LookupAtom("no_memory");
|
||||
AtomNonEmptyList = Yap_LookupAtom("non_empty_list");
|
||||
AtomNot = Yap_LookupAtom("\\+");
|
||||
AtomNotImplemented = Yap_LookupAtom("not_implemented");
|
||||
AtomNotLessThanZero = Yap_LookupAtom("not_less_than_zero");
|
||||
AtomNotNewline = Yap_LookupAtom("not_newline");
|
||||
AtomNotZero = Yap_LookupAtom("not_zero");
|
||||
@ -192,6 +196,7 @@
|
||||
AtomPredicateIndicator = Yap_LookupAtom("predicate_indicator");
|
||||
AtomPrimitive = Yap_LookupAtom("primitive");
|
||||
AtomPrivateProcedure = Yap_LookupAtom("private_procedure");
|
||||
AtomProcedure = Yap_LookupAtom("procedure");
|
||||
AtomProfile = Yap_FullLookupAtom("$profile");
|
||||
AtomProlog = Yap_LookupAtom("prolog");
|
||||
AtomPtr = Yap_LookupAtom("ptr");
|
||||
@ -260,6 +265,7 @@
|
||||
AtomThreads = Yap_LookupAtom("threads");
|
||||
AtomThrow = Yap_LookupAtom("throw");
|
||||
AtomTimeOutSpec = Yap_LookupAtom("time_out_spec");
|
||||
AtomTimeoutError = Yap_LookupAtom("timeout_error");
|
||||
AtomTopLevelGoal = Yap_FullLookupAtom("$top_level_goal");
|
||||
AtomTopThreadGoal = Yap_FullLookupAtom("$top_thread_goal");
|
||||
AtomTrail = Yap_LookupAtom("trail");
|
||||
@ -304,6 +310,7 @@
|
||||
FunctorChangeModule = Yap_MkFunctor(AtomChangeModule,1);
|
||||
FunctorClist = Yap_MkFunctor(AtomWhen,4);
|
||||
FunctorComma = Yap_MkFunctor(AtomComma,2);
|
||||
FunctorContext2 = Yap_MkFunctor(AtomContext,2);
|
||||
FunctorConsistencyError = Yap_MkFunctor(AtomConsistencyError,1);
|
||||
FunctorCreep = Yap_MkFunctor(AtomCreep,1);
|
||||
FunctorCsult = Yap_MkFunctor(AtomCsult,1);
|
||||
@ -357,6 +364,7 @@
|
||||
FunctorModule = Yap_MkFunctor(AtomColomn,2);
|
||||
FunctorMultiFileClause = Yap_MkFunctor(AtomMfClause,5);
|
||||
FunctorMutable = Yap_MkFunctor(AtomMutableVariable,(sizeof(timed_var)/sizeof(CELL)));
|
||||
FunctorNotImplemented = Yap_MkFunctor(AtomNotImplemented,2);
|
||||
FunctorNBQueue = Yap_MkFunctor(AtomQueue,5);
|
||||
FunctorNot = Yap_MkFunctor(AtomNot,1);
|
||||
FunctorOr = Yap_MkFunctor(AtomSemic,2);
|
||||
@ -378,6 +386,7 @@
|
||||
FunctorSyntaxError = Yap_MkFunctor(AtomSyntaxError,7);
|
||||
FunctorThreadRun = Yap_MkFunctor(AtomTopThreadGoal,2);
|
||||
FunctorThrow = Yap_MkFunctor(AtomThrow,1);
|
||||
FunctorTimeoutError = Yap_MkFunctor(AtomTimeoutError,2);
|
||||
FunctorTypeError = Yap_MkFunctor(AtomTypeError,2);
|
||||
FunctorUMinus = Yap_MkFunctor(AtomMinus,1);
|
||||
FunctorUPlus = Yap_MkFunctor(AtomPlus,1);
|
||||
|
@ -47,6 +47,7 @@
|
||||
AtomCompound = AtomAdjust(AtomCompound);
|
||||
AtomConsistencyError = AtomAdjust(AtomConsistencyError);
|
||||
AtomConsultOnBoot = AtomAdjust(AtomConsultOnBoot);
|
||||
AtomContext = AtomAdjust(AtomContext);
|
||||
AtomCputime = AtomAdjust(AtomCputime);
|
||||
AtomCreate = AtomAdjust(AtomCreate);
|
||||
AtomCreep = AtomAdjust(AtomCreep);
|
||||
@ -142,6 +143,7 @@
|
||||
AtomLocal = AtomAdjust(AtomLocal);
|
||||
AtomLocalA = AtomAdjust(AtomLocalA);
|
||||
AtomMaxArity = AtomAdjust(AtomMaxArity);
|
||||
AtomMaxFiles = AtomAdjust(AtomMaxFiles);
|
||||
AtomMegaClause = AtomAdjust(AtomMegaClause);
|
||||
AtomMetaCall = AtomAdjust(AtomMetaCall);
|
||||
AtomMfClause = AtomAdjust(AtomMfClause);
|
||||
@ -160,8 +162,10 @@
|
||||
AtomNb = AtomAdjust(AtomNb);
|
||||
AtomNbTerm = AtomAdjust(AtomNbTerm);
|
||||
AtomNew = AtomAdjust(AtomNew);
|
||||
AtomNoMemory = AtomAdjust(AtomNoMemory);
|
||||
AtomNonEmptyList = AtomAdjust(AtomNonEmptyList);
|
||||
AtomNot = AtomAdjust(AtomNot);
|
||||
AtomNotImplemented = AtomAdjust(AtomNotImplemented);
|
||||
AtomNotLessThanZero = AtomAdjust(AtomNotLessThanZero);
|
||||
AtomNotNewline = AtomAdjust(AtomNotNewline);
|
||||
AtomNotZero = AtomAdjust(AtomNotZero);
|
||||
@ -194,6 +198,7 @@
|
||||
AtomPredicateIndicator = AtomAdjust(AtomPredicateIndicator);
|
||||
AtomPrimitive = AtomAdjust(AtomPrimitive);
|
||||
AtomPrivateProcedure = AtomAdjust(AtomPrivateProcedure);
|
||||
AtomProcedure = AtomAdjust(AtomProcedure);
|
||||
AtomProfile = AtomAdjust(AtomProfile);
|
||||
AtomProlog = AtomAdjust(AtomProlog);
|
||||
AtomPtr = AtomAdjust(AtomPtr);
|
||||
@ -262,6 +267,7 @@
|
||||
AtomThreads = AtomAdjust(AtomThreads);
|
||||
AtomThrow = AtomAdjust(AtomThrow);
|
||||
AtomTimeOutSpec = AtomAdjust(AtomTimeOutSpec);
|
||||
AtomTimeoutError = AtomAdjust(AtomTimeoutError);
|
||||
AtomTopLevelGoal = AtomAdjust(AtomTopLevelGoal);
|
||||
AtomTopThreadGoal = AtomAdjust(AtomTopThreadGoal);
|
||||
AtomTrail = AtomAdjust(AtomTrail);
|
||||
@ -306,6 +312,7 @@
|
||||
FunctorChangeModule = FuncAdjust(FunctorChangeModule);
|
||||
FunctorClist = FuncAdjust(FunctorClist);
|
||||
FunctorComma = FuncAdjust(FunctorComma);
|
||||
FunctorContext2 = FuncAdjust(FunctorContext2);
|
||||
FunctorConsistencyError = FuncAdjust(FunctorConsistencyError);
|
||||
FunctorCreep = FuncAdjust(FunctorCreep);
|
||||
FunctorCsult = FuncAdjust(FunctorCsult);
|
||||
@ -359,6 +366,7 @@
|
||||
FunctorModule = FuncAdjust(FunctorModule);
|
||||
FunctorMultiFileClause = FuncAdjust(FunctorMultiFileClause);
|
||||
FunctorMutable = FuncAdjust(FunctorMutable);
|
||||
FunctorNotImplemented = FuncAdjust(FunctorNotImplemented);
|
||||
FunctorNBQueue = FuncAdjust(FunctorNBQueue);
|
||||
FunctorNot = FuncAdjust(FunctorNot);
|
||||
FunctorOr = FuncAdjust(FunctorOr);
|
||||
@ -380,6 +388,7 @@
|
||||
FunctorSyntaxError = FuncAdjust(FunctorSyntaxError);
|
||||
FunctorThreadRun = FuncAdjust(FunctorThreadRun);
|
||||
FunctorThrow = FuncAdjust(FunctorThrow);
|
||||
FunctorTimeoutError = FuncAdjust(FunctorTimeoutError);
|
||||
FunctorTypeError = FuncAdjust(FunctorTypeError);
|
||||
FunctorUMinus = FuncAdjust(FunctorUMinus);
|
||||
FunctorUPlus = FuncAdjust(FunctorUPlus);
|
||||
|
18
H/tatoms.h
18
H/tatoms.h
@ -96,6 +96,8 @@
|
||||
#define AtomConsistencyError Yap_heap_regs->AtomConsistencyError_
|
||||
Atom AtomConsultOnBoot_;
|
||||
#define AtomConsultOnBoot Yap_heap_regs->AtomConsultOnBoot_
|
||||
Atom AtomContext_;
|
||||
#define AtomContext Yap_heap_regs->AtomContext_
|
||||
Atom AtomCputime_;
|
||||
#define AtomCputime Yap_heap_regs->AtomCputime_
|
||||
Atom AtomCreate_;
|
||||
@ -286,6 +288,8 @@
|
||||
#define AtomLocalA Yap_heap_regs->AtomLocalA_
|
||||
Atom AtomMaxArity_;
|
||||
#define AtomMaxArity Yap_heap_regs->AtomMaxArity_
|
||||
Atom AtomMaxFiles_;
|
||||
#define AtomMaxFiles Yap_heap_regs->AtomMaxFiles_
|
||||
Atom AtomMegaClause_;
|
||||
#define AtomMegaClause Yap_heap_regs->AtomMegaClause_
|
||||
Atom AtomMetaCall_;
|
||||
@ -322,10 +326,14 @@
|
||||
#define AtomNbTerm Yap_heap_regs->AtomNbTerm_
|
||||
Atom AtomNew_;
|
||||
#define AtomNew Yap_heap_regs->AtomNew_
|
||||
Atom AtomNoMemory_;
|
||||
#define AtomNoMemory Yap_heap_regs->AtomNoMemory_
|
||||
Atom AtomNonEmptyList_;
|
||||
#define AtomNonEmptyList Yap_heap_regs->AtomNonEmptyList_
|
||||
Atom AtomNot_;
|
||||
#define AtomNot Yap_heap_regs->AtomNot_
|
||||
Atom AtomNotImplemented_;
|
||||
#define AtomNotImplemented Yap_heap_regs->AtomNotImplemented_
|
||||
Atom AtomNotLessThanZero_;
|
||||
#define AtomNotLessThanZero Yap_heap_regs->AtomNotLessThanZero_
|
||||
Atom AtomNotNewline_;
|
||||
@ -390,6 +398,8 @@
|
||||
#define AtomPrimitive Yap_heap_regs->AtomPrimitive_
|
||||
Atom AtomPrivateProcedure_;
|
||||
#define AtomPrivateProcedure Yap_heap_regs->AtomPrivateProcedure_
|
||||
Atom AtomProcedure_;
|
||||
#define AtomProcedure Yap_heap_regs->AtomProcedure_
|
||||
Atom AtomProfile_;
|
||||
#define AtomProfile Yap_heap_regs->AtomProfile_
|
||||
Atom AtomProlog_;
|
||||
@ -526,6 +536,8 @@
|
||||
#define AtomThrow Yap_heap_regs->AtomThrow_
|
||||
Atom AtomTimeOutSpec_;
|
||||
#define AtomTimeOutSpec Yap_heap_regs->AtomTimeOutSpec_
|
||||
Atom AtomTimeoutError_;
|
||||
#define AtomTimeoutError Yap_heap_regs->AtomTimeoutError_
|
||||
Atom AtomTopLevelGoal_;
|
||||
#define AtomTopLevelGoal Yap_heap_regs->AtomTopLevelGoal_
|
||||
Atom AtomTopThreadGoal_;
|
||||
@ -614,6 +626,8 @@
|
||||
#define FunctorClist Yap_heap_regs->FunctorClist_
|
||||
Functor FunctorComma_;
|
||||
#define FunctorComma Yap_heap_regs->FunctorComma_
|
||||
Functor FunctorContext2_;
|
||||
#define FunctorContext2 Yap_heap_regs->FunctorContext2_
|
||||
Functor FunctorConsistencyError_;
|
||||
#define FunctorConsistencyError Yap_heap_regs->FunctorConsistencyError_
|
||||
Functor FunctorCreep_;
|
||||
@ -720,6 +734,8 @@
|
||||
#define FunctorMultiFileClause Yap_heap_regs->FunctorMultiFileClause_
|
||||
Functor FunctorMutable_;
|
||||
#define FunctorMutable Yap_heap_regs->FunctorMutable_
|
||||
Functor FunctorNotImplemented_;
|
||||
#define FunctorNotImplemented Yap_heap_regs->FunctorNotImplemented_
|
||||
Functor FunctorNBQueue_;
|
||||
#define FunctorNBQueue Yap_heap_regs->FunctorNBQueue_
|
||||
Functor FunctorNot_;
|
||||
@ -762,6 +778,8 @@
|
||||
#define FunctorThreadRun Yap_heap_regs->FunctorThreadRun_
|
||||
Functor FunctorThrow_;
|
||||
#define FunctorThrow Yap_heap_regs->FunctorThrow_
|
||||
Functor FunctorTimeoutError_;
|
||||
#define FunctorTimeoutError Yap_heap_regs->FunctorTimeoutError_
|
||||
Functor FunctorTypeError_;
|
||||
#define FunctorTypeError Yap_heap_regs->FunctorTypeError_
|
||||
Functor FunctorUMinus_;
|
||||
|
@ -463,6 +463,46 @@ extern X_API const char *PL_cwd(void);
|
||||
|
||||
void swi_install(void);
|
||||
|
||||
#define ERR_NO_ERROR 0
|
||||
#define ERR_INSTANTIATION 1 /* void */
|
||||
#define ERR_TYPE 2 /* atom_t expected, term_t value */
|
||||
#define ERR_DOMAIN 3 /* atom_t domain, term_t value */
|
||||
#define ERR_REPRESENTATION 4 /* atom_t what */
|
||||
#define ERR_MODIFY_STATIC_PROC 5 /* predicate_t proc */
|
||||
#define ERR_EVALUATION 6 /* atom_t what */
|
||||
#define ERR_AR_TYPE 7 /* atom_t expected, Number value */
|
||||
#define ERR_NOT_EVALUABLE 8 /* functor_t func */
|
||||
#define ERR_DIV_BY_ZERO 9 /* void */
|
||||
#define ERR_FAILED 10 /* predicate_t proc */
|
||||
#define ERR_FILE_OPERATION 11 /* atom_t action, atom_t type, term_t */
|
||||
#define ERR_PERMISSION 12 /* atom_t type, atom_t op, term_t obj*/
|
||||
#define ERR_NOT_IMPLEMENTED 13 /* const char *what */
|
||||
#define ERR_EXISTENCE 14 /* atom_t type, term_t obj */
|
||||
#define ERR_STREAM_OP 15 /* atom_t action, term_t obj */
|
||||
#define ERR_RESOURCE 16 /* atom_t resource */
|
||||
#define ERR_NOMEM 17 /* void */
|
||||
#define ERR_SYSCALL 18 /* void */
|
||||
#define ERR_SHELL_FAILED 19 /* term_t command */
|
||||
#define ERR_SHELL_SIGNALLED 20 /* term_t command, int signal */
|
||||
#define ERR_AR_UNDEF 21 /* void */
|
||||
#define ERR_AR_OVERFLOW 22 /* void */
|
||||
#define ERR_AR_UNDERFLOW 23 /* void */
|
||||
#define ERR_UNDEFINED_PROC 24 /* Definition def */
|
||||
#define ERR_SIGNALLED 25 /* int sig, char *name */
|
||||
#define ERR_CLOSED_STREAM 26 /* IOSTREAM * */
|
||||
#define ERR_BUSY 27 /* mutexes */
|
||||
#define ERR_PERMISSION_PROC 28 /* op, type, Definition */
|
||||
#define ERR_DDE_OP 29 /* op, error */
|
||||
#define ERR_SYNTAX 30 /* what */
|
||||
#define ERR_SHARED_OBJECT_OP 31 /* op, error */
|
||||
#define ERR_TIMEOUT 32 /* op, object */
|
||||
#define ERR_NOT_IMPLEMENTED_PROC 33 /* name, arity */
|
||||
#define ERR_FORMAT 34 /* message */
|
||||
#define ERR_FORMAT_ARG 35 /* seq, term */
|
||||
#define ERR_OCCURS_CHECK 36 /* Word, Word */
|
||||
#define ERR_CHARS_TYPE 37 /* char *, term */
|
||||
#define ERR_MUST_BE_VAR 38 /* int argn, term_t term */
|
||||
|
||||
X_API int PL_error(const char *pred, int arity, const char *msg, int id, ...);
|
||||
|
||||
|
||||
|
@ -23,6 +23,9 @@
|
||||
#if HAVE_MATH_H
|
||||
#include <math.h>
|
||||
#endif
|
||||
#if HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#define PL_KERNEL 1
|
||||
|
||||
@ -890,10 +893,217 @@ X_API int PL_raise_exception(term_t exception)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define ATOM_instantiation_error AtomToSWIAtom(AtomInstantiationError)
|
||||
#define ATOM_max_files AtomToSWIAtom(AtomMaxFiles)
|
||||
#define ATOM_no_memory AtomToSWIAtom(AtomNoMemory)
|
||||
#define ATOM_procedure AtomToSWIAtom(AtomProcedure)
|
||||
#define ATOM_system_error AtomToSWIAtom(AtomSystemError)
|
||||
#define ATOM_variable AtomToSWIAtom(AtomVariable)
|
||||
#define FUNCTOR_error2 FunctorToSWIFunctor(FunctorError)
|
||||
#define FUNCTOR_context2 FunctorToSWIFunctor(FunctorContext2)
|
||||
#define FUNCTOR_divide2 FunctorToSWIFunctor(FunctorSlash)
|
||||
#define FUNCTOR_domain_error2 FunctorToSWIFunctor(FunctorDomainError)
|
||||
#define FUNCTOR_existence_error2 FunctorToSWIFunctor(FunctorExistenceError)
|
||||
#define FUNCTOR_evaluation_error1 FunctorToSWIFunctor(FunctorEvaluationError)
|
||||
#define FUNCTOR_not_implemented2 FunctorToSWIFunctor(FunctorNotImplemented)
|
||||
#define FUNCTOR_permission_error3 FunctorToSWIFunctor(FunctorPermissionError)
|
||||
#define FUNCTOR_representation_error1 FunctorToSWIFunctor(FunctorRepresentationError)
|
||||
#define FUNCTOR_resource_error1 FunctorToSWIFunctor(FunctorResourceError)
|
||||
#define FUNCTOR_timeout_error2 FunctorToSWIFunctor(FunctorTimeoutError)
|
||||
#define FUNCTOR_type_error2 FunctorToSWIFunctor(FunctorTypeError)
|
||||
|
||||
X_API int PL_error(const char *pred, int arity, const char *msg, int id, ...)
|
||||
{
|
||||
Yap_Error(id,TermNil,NULL);
|
||||
return 0;
|
||||
term_t formal, swi, predterm, msgterm, except;
|
||||
va_list args;
|
||||
|
||||
formal = PL_new_term_ref();
|
||||
swi = PL_new_term_ref();
|
||||
predterm = PL_new_term_ref();
|
||||
msgterm = PL_new_term_ref();
|
||||
except = PL_new_term_ref();
|
||||
|
||||
/* This would really require having pl-error.c, but we'll make do so as */
|
||||
va_start(args, id);
|
||||
switch(id) {
|
||||
case ERR_INSTANTIATION:
|
||||
err_instantiation:
|
||||
PL_unify_atom(formal, ATOM_instantiation_error);
|
||||
break;
|
||||
case ERR_TYPE: /* ERR_INSTANTIATION if var(actual) */
|
||||
{ atom_t expected = va_arg(args, atom_t);
|
||||
term_t actual = va_arg(args, term_t);
|
||||
|
||||
if ( PL_is_variable(actual) && expected != ATOM_variable )
|
||||
goto err_instantiation;
|
||||
|
||||
PL_unify_term(formal,
|
||||
PL_FUNCTOR, FUNCTOR_type_error2,
|
||||
PL_ATOM, expected,
|
||||
PL_TERM, actual);
|
||||
break;
|
||||
}
|
||||
case ERR_DOMAIN: /* ERR_INSTANTIATION if var(arg) */
|
||||
{ atom_t domain = va_arg(args, atom_t);
|
||||
term_t arg = va_arg(args, term_t);
|
||||
|
||||
if ( PL_is_variable(arg) )
|
||||
goto err_instantiation;
|
||||
|
||||
PL_unify_term(formal,
|
||||
PL_FUNCTOR, FUNCTOR_domain_error2,
|
||||
PL_ATOM, domain,
|
||||
PL_TERM, arg);
|
||||
break;
|
||||
}
|
||||
case ERR_REPRESENTATION:
|
||||
{ atom_t what = va_arg(args, atom_t);
|
||||
|
||||
PL_unify_term(formal,
|
||||
PL_FUNCTOR, FUNCTOR_representation_error1,
|
||||
PL_ATOM, what);
|
||||
break;
|
||||
}
|
||||
case ERR_NOT_IMPLEMENTED_PROC:
|
||||
{ const char *name = va_arg(args, const char *);
|
||||
int arity = va_arg(args, int);
|
||||
|
||||
PL_unify_term(formal,
|
||||
PL_FUNCTOR, FUNCTOR_not_implemented2,
|
||||
PL_ATOM, ATOM_procedure,
|
||||
PL_FUNCTOR, FUNCTOR_divide2,
|
||||
PL_CHARS, name,
|
||||
PL_INT, arity);
|
||||
break;
|
||||
}
|
||||
case ERR_EXISTENCE:
|
||||
{ atom_t type = va_arg(args, atom_t);
|
||||
term_t obj = va_arg(args, term_t);
|
||||
|
||||
PL_unify_term(formal,
|
||||
PL_FUNCTOR, FUNCTOR_existence_error2,
|
||||
PL_ATOM, type,
|
||||
PL_TERM, obj);
|
||||
|
||||
break;
|
||||
}
|
||||
case ERR_PERMISSION:
|
||||
{ atom_t type = va_arg(args, atom_t);
|
||||
atom_t op = va_arg(args, atom_t);
|
||||
term_t obj = va_arg(args, term_t);
|
||||
|
||||
PL_unify_term(formal,
|
||||
PL_FUNCTOR, FUNCTOR_permission_error3,
|
||||
PL_ATOM, type,
|
||||
PL_ATOM, op,
|
||||
PL_TERM, obj);
|
||||
|
||||
break;
|
||||
}
|
||||
case ERR_SYSCALL:
|
||||
{ const char *op = va_arg(args, const char *);
|
||||
|
||||
if ( !msg )
|
||||
msg = op;
|
||||
|
||||
switch(errno)
|
||||
{ case ENOMEM:
|
||||
PL_unify_term(formal,
|
||||
PL_FUNCTOR, FUNCTOR_resource_error1,
|
||||
PL_ATOM, ATOM_no_memory);
|
||||
break;
|
||||
default:
|
||||
PL_unify_atom(formal, ATOM_system_error);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ERR_TIMEOUT:
|
||||
{ atom_t op = va_arg(args, atom_t);
|
||||
term_t obj = va_arg(args, term_t);
|
||||
|
||||
PL_unify_term(formal,
|
||||
PL_FUNCTOR, FUNCTOR_timeout_error2,
|
||||
PL_ATOM, op,
|
||||
PL_TERM, obj);
|
||||
|
||||
break;
|
||||
}
|
||||
case ERR_FILE_OPERATION:
|
||||
{ atom_t action = va_arg(args, atom_t);
|
||||
atom_t type = va_arg(args, atom_t);
|
||||
term_t file = va_arg(args, term_t);
|
||||
|
||||
switch(errno)
|
||||
{ case EACCES:
|
||||
PL_unify_term(formal,
|
||||
PL_FUNCTOR, FUNCTOR_permission_error3,
|
||||
PL_ATOM, action,
|
||||
PL_ATOM, type,
|
||||
PL_TERM, file);
|
||||
break;
|
||||
case EMFILE:
|
||||
case ENFILE:
|
||||
PL_unify_term(formal,
|
||||
PL_FUNCTOR, FUNCTOR_resource_error1,
|
||||
PL_ATOM, ATOM_max_files);
|
||||
break;
|
||||
#ifdef EPIPE
|
||||
case EPIPE:
|
||||
if ( !msg )
|
||||
msg = "Broken pipe";
|
||||
/*FALLTHROUGH*/
|
||||
#endif
|
||||
default: /* what about the other cases? */
|
||||
PL_unify_term(formal,
|
||||
PL_FUNCTOR, FUNCTOR_existence_error2,
|
||||
PL_ATOM, type,
|
||||
PL_TERM, file);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ERR_NOMEM:
|
||||
{ PL_unify_term(formal,
|
||||
PL_FUNCTOR, FUNCTOR_resource_error1,
|
||||
PL_ATOM, ATOM_no_memory);
|
||||
|
||||
break;
|
||||
}
|
||||
case ERR_EVALUATION:
|
||||
{ atom_t what = va_arg(args, atom_t);
|
||||
|
||||
PL_unify_term(formal,
|
||||
PL_FUNCTOR, FUNCTOR_evaluation_error1,
|
||||
PL_ATOM, what);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "unimplemented SWI error %d\n",id);
|
||||
goto err_instantiation;
|
||||
}
|
||||
va_end(args);
|
||||
if ( pred )
|
||||
{ PL_unify_term(predterm,
|
||||
PL_FUNCTOR, FUNCTOR_divide2,
|
||||
PL_CHARS, pred,
|
||||
PL_INT, arity);
|
||||
}
|
||||
if ( msg )
|
||||
{
|
||||
PL_put_atom_chars(msgterm, msg);
|
||||
}
|
||||
PL_unify_term(swi,
|
||||
PL_FUNCTOR, FUNCTOR_context2,
|
||||
PL_TERM, predterm,
|
||||
PL_TERM, msgterm);
|
||||
PL_unify_term(except,
|
||||
PL_FUNCTOR, FUNCTOR_error2,
|
||||
PL_TERM, formal,
|
||||
PL_TERM, swi);
|
||||
return PL_raise_exception(except);
|
||||
}
|
||||
|
||||
/* begin PL_unify_* functions =============================*/
|
||||
|
@ -56,6 +56,7 @@ A Comma N ","
|
||||
A Compound N "compound"
|
||||
A ConsistencyError N "consistency_error"
|
||||
A ConsultOnBoot F "$consult_on_boot"
|
||||
A Context N "context"
|
||||
A Cputime N "cputime"
|
||||
A Create N "create"
|
||||
A Creep F "$creep"
|
||||
@ -151,6 +152,7 @@ A LoadAnswers N "load_answers"
|
||||
A Local N "local_sp"
|
||||
A LocalA N "local"
|
||||
A MaxArity N "max_arity"
|
||||
A MaxFiles N "max_files"
|
||||
A MegaClause F "$mega_clause"
|
||||
A MetaCall F "$call"
|
||||
A MfClause F "$mf_clause"
|
||||
@ -169,8 +171,10 @@ A Nan N "nan"
|
||||
A Nb N "nb"
|
||||
A NbTerm N "nb_term"
|
||||
A New N "new"
|
||||
A NoMemory N "no_memory"
|
||||
A NonEmptyList N "non_empty_list"
|
||||
A Not N "\\+"
|
||||
A NotImplemented N "not_implemented"
|
||||
A NotLessThanZero N "not_less_than_zero"
|
||||
A NotNewline N "not_newline"
|
||||
A NotZero N "not_zero"
|
||||
@ -203,6 +207,7 @@ A Portray F "$portray"
|
||||
A PredicateIndicator N "predicate_indicator"
|
||||
A Primitive N "primitive"
|
||||
A PrivateProcedure N "private_procedure"
|
||||
A Procedure N "procedure"
|
||||
A Profile F "$profile"
|
||||
A Prolog N "prolog"
|
||||
A Ptr N "ptr"
|
||||
@ -271,6 +276,7 @@ A TextStream N "text_stream"
|
||||
A Threads N "threads"
|
||||
A Throw N "throw"
|
||||
A TimeOutSpec N "time_out_spec"
|
||||
A TimeoutError N "timeout_error"
|
||||
A TopLevelGoal F "$top_level_goal"
|
||||
A TopThreadGoal F "$top_thread_goal"
|
||||
A Trail N "trail"
|
||||
@ -315,6 +321,7 @@ F Catch Catch 3
|
||||
F ChangeModule ChangeModule 1
|
||||
F Clist When 4
|
||||
F Comma Comma 2
|
||||
F Context2 Context 2
|
||||
F ConsistencyError ConsistencyError 1
|
||||
F Creep Creep 1
|
||||
F Csult Csult 1
|
||||
@ -368,6 +375,7 @@ F Minus Minus 2
|
||||
F Module Colomn 2
|
||||
F MultiFileClause MfClause 5
|
||||
F Mutable MutableVariable (sizeof(timed_var)/sizeof(CELL))
|
||||
F NotImplemented NotImplemented 2
|
||||
F NBQueue Queue 5
|
||||
F Not Not 1
|
||||
F Or Semic 2
|
||||
@ -389,6 +397,7 @@ F StreamPos StreamPos 5
|
||||
F SyntaxError SyntaxError 7
|
||||
F ThreadRun TopThreadGoal 2
|
||||
F Throw Throw 1
|
||||
F TimeoutError TimeoutError 2
|
||||
F TypeError TypeError 2
|
||||
F UMinus Minus 1
|
||||
F UPlus Plus 1
|
||||
|
@ -179,6 +179,8 @@ system_message(error(evaluation_error(zero_divisor), Where)) -->
|
||||
[ 'ZERO DIVISOR ERROR- ~w' - [Where] ].
|
||||
system_message(error(instantiation_error, Where)) -->
|
||||
[ 'INSTANTIATION ERROR- ~w: expected bound value' - [Where] ].
|
||||
system_message(error(not_implemented(Type, What), Where)) -->
|
||||
[ '~w not implemented- ~w' - [Type, What] ].
|
||||
system_message(error(operating_system_error, Where)) -->
|
||||
[ 'OPERATING SYSTEM ERROR- ~w' - [Where] ].
|
||||
system_message(error(out_of_heap_error, Where)) -->
|
||||
@ -275,6 +277,8 @@ system_message(error(internal_compiler_error, Where)) -->
|
||||
[ 'INTERNAL COMPILER ERROR- ~w' - [Where] ].
|
||||
system_message(error(system_error(Message), Where)) -->
|
||||
[ 'SYSTEM ERROR- ~w at ~w]' - [Message,Where] ].
|
||||
system_message(error(timeout_error(T,Obj), _Where)) -->
|
||||
[ 'TIMEOUT ERROR- operation ~w on object ~w' - [T,Obj] ].
|
||||
system_message(error(type_error(T,_,Err,M), _Where)) -->
|
||||
[ 'TYPE ERROR- ~w: expected ~w, got ~w' - [T,Err,M] ].
|
||||
system_message(error(type_error(TE,W), Where)) -->
|
||||
|
Reference in New Issue
Block a user