error handling
This commit is contained in:
parent
53de04c38f
commit
71aed8b870
34
C/errors.c
34
C/errors.c
@ -90,21 +90,23 @@ static bool setErr(const char *q, yap_error_descriptor_t *i, Term t) {
|
|||||||
return i->k ? TermTrue : TermFalse; \
|
return i->k ? TermTrue : TermFalse; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define query_key_i(k, ks, q, i) \
|
#define query_key_i(k, ks, q, i) if (strcmp(ks, q) == 0) { \
|
||||||
if (strcmp(ks, q) == 0) { \
|
|
||||||
return MkIntegerTerm(i->k); \
|
return MkIntegerTerm(i->k); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define query_key_s(k, ks, q, i) \
|
#define query_key_s(k, ks, q, i) \
|
||||||
if (strcmp(ks, q) == 0) { \
|
if (strcmp(ks, q) == 0) { \
|
||||||
return (i->k && i->k[0] ? MkStringTerm(i->k) : TermNil); \
|
return MkAtomTerm(Yap_LookupAtom(i->k)); }
|
||||||
}
|
|
||||||
|
#define query_key_t(k, ks, q, i) \
|
||||||
|
if (strcmp(ks, q) == 0) { \
|
||||||
|
Term t; if((t = Yap_BufferToTerm(i->k, TermNil) ) == 0 ) return TermNil; return t; }
|
||||||
|
|
||||||
static Term queryErr(const char *q, yap_error_descriptor_t *i) {
|
static Term queryErr(const char *q, yap_error_descriptor_t *i) {
|
||||||
query_key_i(errorNo, "errorNo", q, i);
|
query_key_i(errorNo, "errorNo", q, i);
|
||||||
query_key_i(errorClass, "errorClass", q, i);
|
query_key_i(errorClass, "errorClass", q, i);
|
||||||
query_key_s(errorAsText, "errorAsText", q, i);
|
query_key_s(errorAsText, "errorAsText", q, i);
|
||||||
query_key_s(errorGoal, "errorGoal", q, i);
|
query_key_t(errorGoal, "errorGoal", q, i);
|
||||||
query_key_s(classAsText, "classAsText", q, i);
|
query_key_s(classAsText, "classAsText", q, i);
|
||||||
query_key_i(errorLine, "errorLine", q, i);
|
query_key_i(errorLine, "errorLine", q, i);
|
||||||
query_key_s(errorFunction, "errorFunction", q, i);
|
query_key_s(errorFunction, "errorFunction", q, i);
|
||||||
@ -123,7 +125,7 @@ static Term queryErr(const char *q, yap_error_descriptor_t *i) {
|
|||||||
query_key_s(prologParserText, "prologParserText", q, i);
|
query_key_s(prologParserText, "prologParserText", q, i);
|
||||||
query_key_s(prologParserFile, "prologParserFile", q, i);
|
query_key_s(prologParserFile, "prologParserFile", q, i);
|
||||||
query_key_b(prologConsulting, "prologConsulting", q, i);
|
query_key_b(prologConsulting, "prologConsulting", q, i);
|
||||||
query_key_s(culprit, "culprit", q, i);
|
query_key_t(culprit, "culprit", q, i);
|
||||||
query_key_s(errorMsg, "errorMsg", q, i);
|
query_key_s(errorMsg, "errorMsg", q, i);
|
||||||
query_key_i(errorMsgLen, "errorMsgLen", q, i);
|
query_key_i(errorMsgLen, "errorMsgLen", q, i);
|
||||||
return TermNil;
|
return TermNil;
|
||||||
@ -581,23 +583,17 @@ bool Yap_pushErrorContext(bool pass, yap_error_descriptor_t *new_error) {
|
|||||||
/* if (Yap_HasException()) */
|
/* if (Yap_HasException()) */
|
||||||
/* memset(LOCAL_ActiveError, 0, sizeof(*LOCAL_ActiveError)); */
|
/* memset(LOCAL_ActiveError, 0, sizeof(*LOCAL_ActiveError)); */
|
||||||
/* LOCAL_ActiveError->top_error = bf; */
|
/* LOCAL_ActiveError->top_error = bf; */
|
||||||
|
|
||||||
/* } */
|
/* } */
|
||||||
yap_error_descriptor_t *Yap_popErrorContext(bool mdnew, bool pass) {
|
yap_error_descriptor_t *Yap_popErrorContext(bool mdnew, bool pass) {
|
||||||
yap_error_descriptor_t *e = LOCAL_ActiveError;
|
yap_error_descriptor_t *e = LOCAL_ActiveError, *ep = LOCAL_ActiveError->top_error;
|
||||||
// last block
|
// last block
|
||||||
LOCAL_ActiveError = e->top_error;
|
LOCAL_ActiveError = ep;
|
||||||
if (e->errorNo) {
|
if (e->errorNo && !ep->errorNo && pass) {
|
||||||
if (!LOCAL_ActiveError->errorNo && pass) {
|
yap_error_descriptor_t *epp = ep->top_error;
|
||||||
memmove(LOCAL_ActiveError, e, sizeof(*LOCAL_ActiveError));
|
memmove(ep, e, sizeof(*e));
|
||||||
} else {
|
ep->top_error = epp;
|
||||||
return e;
|
|
||||||
}
|
}
|
||||||
} else {
|
return LOCAL_ActiveError;
|
||||||
if (e->errorNo)
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Throw an error directly to the error handler
|
* Throw an error directly to the error handler
|
||||||
|
140
os/readterm.c
140
os/readterm.c
@ -110,11 +110,11 @@ static void clean_vars(VarEntry *p) {
|
|||||||
#ifdef O_QUASIQUOTATIONS
|
#ifdef O_QUASIQUOTATIONS
|
||||||
/** '$qq_open'(+QQRange, -Stream) is det.
|
/** '$qq_open'(+QQRange, -Stream) is det.
|
||||||
|
|
||||||
Opens a quasi-quoted memory range.
|
Opens a quasi-quoted memory range.
|
||||||
|
|
||||||
@arg QQRange is a term '$quasi_quotation'(ReadData, Start, Length)
|
@arg QQRange is a term '$quasi_quotation'(ReadData, Start, Length)
|
||||||
@arg Stream is a UTF-8 encoded string, whose position indication
|
@arg Stream is a UTF-8 encoded string, whose position indication
|
||||||
reflects the location in the real file.
|
reflects the location in the real file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static Int qq_open(USES_REGS1) {
|
static Int qq_open(USES_REGS1) {
|
||||||
@ -284,17 +284,17 @@ static Term scanToList(TokEntry *tok, TokEntry *errtok) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@pred scan_to_list( +Stream, -Tokens )
|
@pred scan_to_list( +Stream, -Tokens )
|
||||||
Generate a list of tokens from a scan of the (input) stream, Tokens are of the
|
Generate a list of tokens from a scan of the (input) stream, Tokens are of the
|
||||||
form:
|
form:
|
||||||
|
|
||||||
+ `atom`(Atom)
|
+ `atom`(Atom)
|
||||||
+ `<QQ>`(Text)
|
+ `<QQ>`(Text)
|
||||||
+ `number`(Number)
|
+ `number`(Number)
|
||||||
+ `var`(VarName)
|
+ `var`(VarName)
|
||||||
+ `string`(String)
|
+ `string`(String)
|
||||||
+ 'EOF''
|
+ 'EOF''
|
||||||
+ symbols, including `(`, `)`, `,`, `;`
|
+ symbols, including `(`, `)`, `,`, `;`
|
||||||
|
|
||||||
*/
|
*/
|
||||||
static Int scan_to_list(USES_REGS1) {
|
static Int scan_to_list(USES_REGS1) {
|
||||||
@ -1008,7 +1008,6 @@ Term Yap_read_term(int sno, Term opts, bool clause) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
yap_error_descriptor_t *new = malloc(sizeof *new);
|
yap_error_descriptor_t *new = malloc(sizeof *new);
|
||||||
|
|
||||||
bool err = Yap_pushErrorContext(true, new);
|
bool err = Yap_pushErrorContext(true, new);
|
||||||
int lvl = push_text_stack();
|
int lvl = push_text_stack();
|
||||||
parser_state_t state = YAP_START_PARSING;
|
parser_state_t state = YAP_START_PARSING;
|
||||||
@ -1051,9 +1050,6 @@ Term Yap_read_term(int sno, Term opts, bool clause) {
|
|||||||
#endif /* EMACS */
|
#endif /* EMACS */
|
||||||
pop_text_stack(lvl);
|
pop_text_stack(lvl);
|
||||||
Yap_popErrorContext(err, true);
|
Yap_popErrorContext(err, true);
|
||||||
if (LOCAL_Error_TYPE != YAP_NO_ERROR) {
|
|
||||||
Yap_Error(LOCAL_Error_TYPE, Yap_MkStream(sno), LOCAL_ErrorMessage);
|
|
||||||
}
|
|
||||||
return fe.t;
|
return fe.t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1064,7 +1060,7 @@ Term Yap_read_term(int sno, Term opts, bool clause) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
read_term2(USES_REGS1) { /* '$read'(+Flag,?Term,?Module,?Vars,-Pos,-Err) */
|
read_term2(USES_REGS1) { /* '$read'(+Flag,?Term,?Module,?Vars,-Pos,-Err) */
|
||||||
return Yap_read_term(LOCAL_c_input_stream, add_output(ARG1, ARG2), false) !=
|
return Yap_read_term(LOCAL_c_input_stream, add_output(ARG1, ARG2), false) !=
|
||||||
0;
|
0;
|
||||||
}
|
}
|
||||||
@ -1261,9 +1257,9 @@ static Int start_mega(USES_REGS1) {
|
|||||||
} else if (IsAtomOrIntTerm(t=*tp)) {
|
} else if (IsAtomOrIntTerm(t=*tp)) {
|
||||||
(IsAtom(tok->Tokt)||IsIntTerm(XREGS+(i+1)))extra[arity]
|
(IsAtom(tok->Tokt)||IsIntTerm(XREGS+(i+1)))extra[arity]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/**
|
/**
|
||||||
* @pred source_location( - _File_ , _Line_ )
|
* @pred source_location( - _File_ , _Line_ )
|
||||||
*
|
*
|
||||||
* unify _File_ and _Line_ wuth the position of the last term read, if the
|
* unify _File_ and _Line_ wuth the position of the last term read, if the
|
||||||
@ -1280,12 +1276,12 @@ static Int start_mega(USES_REGS1) {
|
|||||||
*
|
*
|
||||||
* @note SWI-Prolog built-in.
|
* @note SWI-Prolog built-in.
|
||||||
*/
|
*/
|
||||||
static Int source_location(USES_REGS1) {
|
static Int source_location(USES_REGS1) {
|
||||||
return Yap_unify(ARG1, MkAtomTerm(LOCAL_SourceFileName)) &&
|
return Yap_unify(ARG1, MkAtomTerm(LOCAL_SourceFileName)) &&
|
||||||
Yap_unify(ARG2, MkIntegerTerm(LOCAL_SourceFileLineno));
|
Yap_unify(ARG2, MkIntegerTerm(LOCAL_SourceFileLineno));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @pred read(+ Stream, -Term ) is iso
|
* @pred read(+ Stream, -Term ) is iso
|
||||||
*
|
*
|
||||||
* Reads term _T_ from the stream _S_ instead of from the current input
|
* Reads term _T_ from the stream _S_ instead of from the current input
|
||||||
@ -1295,7 +1291,7 @@ static Int source_location(USES_REGS1) {
|
|||||||
* @param - _Term_
|
* @param - _Term_
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static Int read2(
|
static Int read2(
|
||||||
USES_REGS1) { /* '$read2'(+Flag,?Term,?Module,?Vars,-Pos,-Err,+Stream) */
|
USES_REGS1) { /* '$read2'(+Flag,?Term,?Module,?Vars,-Pos,-Err,+Stream) */
|
||||||
int sno;
|
int sno;
|
||||||
Int out;
|
Int out;
|
||||||
@ -1308,35 +1304,35 @@ static Int read2(
|
|||||||
out = Yap_read_term(sno, add_output(ARG2, TermNil), false);
|
out = Yap_read_term(sno, add_output(ARG2, TermNil), false);
|
||||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @pred read(- T) is iso
|
/** @pred read(- T) is iso
|
||||||
|
|
||||||
Reads the next term from the current input stream, and unifies it with
|
Reads the next term from the current input stream, and unifies it with
|
||||||
_T_. The term must be followed by a dot (`.`) and any blank-character
|
_T_. The term must be followed by a dot (`.`) and any blank-character
|
||||||
as previously defined. The syntax of the term must match the current
|
as previously defined. The syntax of the term must match the current
|
||||||
declarations for operators (see op). If the end-of-stream is reached,
|
declarations for operators (see op). If the end-of-stream is reached,
|
||||||
_T_ is unified with the atom `end_of_file`. Further reads from of
|
_T_ is unified with the atom `end_of_file`. Further reads from of
|
||||||
the same stream may cause an error failure (see open/3).
|
the same stream may cause an error failure (see open/3).
|
||||||
|
|
||||||
*/
|
*/
|
||||||
static Int read1(
|
static Int read1(
|
||||||
USES_REGS1) { /* '$read2'(+Flag,?Term,?Module,?Vars,-Pos,-Err,+Stream) */
|
USES_REGS1) { /* '$read2'(+Flag,?Term,?Module,?Vars,-Pos,-Err,+Stream) */
|
||||||
Term out = Yap_read_term(LOCAL_c_input_stream, add_output(ARG1, TermNil), 1);
|
Term out = Yap_read_term(LOCAL_c_input_stream, add_output(ARG1, TermNil), 1);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @pred fileerrors
|
/** @pred fileerrors
|
||||||
|
|
||||||
Switches on the file_errors flag so that in certain error conditions
|
Switches on the file_errors flag so that in certain error conditions
|
||||||
Input/Output predicates will produce an appropriated message and abort.
|
Input/Output predicates will produce an appropriated message and abort.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
static Int fileerrors(USES_REGS1) {
|
static Int fileerrors(USES_REGS1) {
|
||||||
return setYapFlag(TermFileErrors, TermTrue);
|
return setYapFlag(TermFileErrors, TermTrue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@pred nofileerrors
|
@pred nofileerrors
|
||||||
|
|
||||||
Switches off the `file_errors` flag, so that the predicates see/1,
|
Switches off the `file_errors` flag, so that the predicates see/1,
|
||||||
@ -1344,13 +1340,13 @@ static Int fileerrors(USES_REGS1) {
|
|||||||
an error message and aborting whenever the specified file cannot be
|
an error message and aborting whenever the specified file cannot be
|
||||||
opened or closed.
|
opened or closed.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
static Int nofileerrors(
|
static Int nofileerrors(
|
||||||
USES_REGS1) { /* '$read2'(+Flag,?Term,?Module,?Vars,-Pos,-Err,+Stream) */
|
USES_REGS1) { /* '$read2'(+Flag,?Term,?Module,?Vars,-Pos,-Err,+Stream) */
|
||||||
return setYapFlag(TermFileerrors, TermFalse);
|
return setYapFlag(TermFileerrors, TermFalse);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int style_checker(USES_REGS1) {
|
static Int style_checker(USES_REGS1) {
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
|
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
@ -1392,9 +1388,9 @@ static Int style_checker(USES_REGS1) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Term Yap_BufferToTerm(const char *s, Term opts) {
|
Term Yap_BufferToTerm(const char *s, Term opts) {
|
||||||
Term rval;
|
Term rval;
|
||||||
int sno;
|
int sno;
|
||||||
encoding_t l = ENC_ISO_UTF8;
|
encoding_t l = ENC_ISO_UTF8;
|
||||||
@ -1405,9 +1401,9 @@ Term Yap_BufferToTerm(const char *s, Term opts) {
|
|||||||
rval = Yap_read_term(sno, opts, false);
|
rval = Yap_read_term(sno, opts, false);
|
||||||
Yap_CloseStream(sno);
|
Yap_CloseStream(sno);
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
Term Yap_UBufferToTerm(const unsigned char *s, Term opts) {
|
Term Yap_UBufferToTerm(const unsigned char *s, Term opts) {
|
||||||
Term rval;
|
Term rval;
|
||||||
int sno;
|
int sno;
|
||||||
encoding_t l = ENC_ISO_UTF8;
|
encoding_t l = ENC_ISO_UTF8;
|
||||||
@ -1417,9 +1413,9 @@ Term Yap_UBufferToTerm(const unsigned char *s, Term opts) {
|
|||||||
rval = Yap_read_term(sno, opts, false);
|
rval = Yap_read_term(sno, opts, false);
|
||||||
Yap_CloseStream(sno);
|
Yap_CloseStream(sno);
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
X_API Term Yap_BufferToTermWithPrioBindings(const char *s, Term opts,
|
X_API Term Yap_BufferToTermWithPrioBindings(const char *s, Term opts,
|
||||||
Term bindings, size_t len,
|
Term bindings, size_t len,
|
||||||
int prio) {
|
int prio) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
@ -1433,9 +1429,9 @@ X_API Term Yap_BufferToTermWithPrioBindings(const char *s, Term opts,
|
|||||||
ctl = add_priority(bindings, ctl);
|
ctl = add_priority(bindings, ctl);
|
||||||
}
|
}
|
||||||
return Yap_BufferToTerm(s, ctl);
|
return Yap_BufferToTerm(s, ctl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @pred read_term_from_atom( +Atom , -T , +Options )
|
* @pred read_term_from_atom( +Atom , -T , +Options )
|
||||||
*
|
*
|
||||||
* read a term _T_ stored in constant _Atom_ according to _Options_
|
* read a term _T_ stored in constant _Atom_ according to _Options_
|
||||||
@ -1451,7 +1447,7 @@ X_API Term Yap_BufferToTermWithPrioBindings(const char *s, Term opts,
|
|||||||
*supposed to
|
*supposed to
|
||||||
* use YAP's internal encoding, so please avoid the encoding/1 option.
|
* use YAP's internal encoding, so please avoid the encoding/1 option.
|
||||||
*/
|
*/
|
||||||
static Int read_term_from_atom(USES_REGS1) {
|
static Int read_term_from_atom(USES_REGS1) {
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
Atom at;
|
Atom at;
|
||||||
const unsigned char *s;
|
const unsigned char *s;
|
||||||
@ -1469,9 +1465,9 @@ static Int read_term_from_atom(USES_REGS1) {
|
|||||||
Term ctl = add_output(ARG2, ARG3);
|
Term ctl = add_output(ARG2, ARG3);
|
||||||
|
|
||||||
return Yap_UBufferToTerm(s, ctl);
|
return Yap_UBufferToTerm(s, ctl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @pred read_term_from_atomic( +Atomic , - T , +Options )
|
* @pred read_term_from_atomic( +Atomic , - T , +Options )
|
||||||
*
|
*
|
||||||
* read a term _T_ stored in text _Atomic_ according to _Options_
|
* read a term _T_ stored in text _Atomic_ according to _Options_
|
||||||
@ -1486,7 +1482,7 @@ static Int read_term_from_atom(USES_REGS1) {
|
|||||||
*atom.
|
*atom.
|
||||||
* Encoding is fixed in atoms and strings.
|
* Encoding is fixed in atoms and strings.
|
||||||
*/
|
*/
|
||||||
static Int read_term_from_atomic(USES_REGS1) {
|
static Int read_term_from_atomic(USES_REGS1) {
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
const unsigned char *s;
|
const unsigned char *s;
|
||||||
|
|
||||||
@ -1503,9 +1499,9 @@ static Int read_term_from_atomic(USES_REGS1) {
|
|||||||
Term ctl = add_output(ARG2, ARG3);
|
Term ctl = add_output(ARG2, ARG3);
|
||||||
|
|
||||||
return Yap_UBufferToTerm(s, ctl);
|
return Yap_UBufferToTerm(s, ctl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @pred read_term_from_string( +String , - T , + Options )
|
* @pred read_term_from_string( +String , - T , + Options )
|
||||||
*
|
*
|
||||||
* read a term _T_ stored in constant _String_ according to _Options_
|
* read a term _T_ stored in constant _String_ according to _Options_
|
||||||
@ -1517,10 +1513,11 @@ static Int read_term_from_atomic(USES_REGS1) {
|
|||||||
* Idea from SWI-Prolog, in YAP only works with strings
|
* Idea from SWI-Prolog, in YAP only works with strings
|
||||||
* Check read_term_from_atomic/3 for the general version.
|
* Check read_term_from_atomic/3 for the general version.
|
||||||
*/
|
*/
|
||||||
static Int read_term_from_string(USES_REGS1) {
|
static Int read_term_from_string(USES_REGS1) {
|
||||||
Term t1 = Deref(ARG1), rc;
|
Term t1 = Deref(ARG1), rc;
|
||||||
const unsigned char *s;
|
const unsigned char *s;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
BACKUP_H()
|
||||||
if (IsVarTerm(t1)) {
|
if (IsVarTerm(t1)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, t1, "read_term_from_string/3");
|
Yap_Error(INSTANTIATION_ERROR, t1, "read_term_from_string/3");
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
@ -1537,21 +1534,22 @@ static Int read_term_from_string(USES_REGS1) {
|
|||||||
GLOBAL_Stream[sno].status |= CloseOnException_Stream_f;
|
GLOBAL_Stream[sno].status |= CloseOnException_Stream_f;
|
||||||
rc = Yap_read_term(sno, Deref(ARG3), 3);
|
rc = Yap_read_term(sno, Deref(ARG3), 3);
|
||||||
Yap_CloseStream(sno);
|
Yap_CloseStream(sno);
|
||||||
|
RECOVER_H();
|
||||||
if (!rc)
|
if (!rc)
|
||||||
return false;
|
return false;
|
||||||
return Yap_unify(rc, ARG2);
|
return Yap_unify(rc, ARG2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int atomic_to_term(USES_REGS1) {
|
static Int atomic_to_term(USES_REGS1) {
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
int l = push_text_stack();
|
int l = push_text_stack();
|
||||||
const unsigned char *s = Yap_TextToUTF8Buffer(t1 PASS_REGS);
|
const unsigned char *s = Yap_TextToUTF8Buffer(t1 PASS_REGS);
|
||||||
Int rc = Yap_UBufferToTerm(s, add_output(ARG2, add_names(ARG3, TermNil)));
|
Int rc = Yap_UBufferToTerm(s, add_output(ARG2, add_names(ARG3, TermNil)));
|
||||||
pop_text_stack(l);
|
pop_text_stack(l);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int atom_to_term(USES_REGS1) {
|
static Int atom_to_term(USES_REGS1) {
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
if (IsVarTerm(t1)) {
|
if (IsVarTerm(t1)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, t1, "read_term_from_string/3");
|
Yap_Error(INSTANTIATION_ERROR, t1, "read_term_from_string/3");
|
||||||
@ -1564,9 +1562,9 @@ static Int atom_to_term(USES_REGS1) {
|
|||||||
const unsigned char *us = UStringOfTerm(t);
|
const unsigned char *us = UStringOfTerm(t);
|
||||||
return Yap_UBufferToTerm(us, add_output(ARG2, add_names(ARG3, TermNil)));
|
return Yap_UBufferToTerm(us, add_output(ARG2, add_names(ARG3, TermNil)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int string_to_term(USES_REGS1) {
|
static Int string_to_term(USES_REGS1) {
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
|
|
||||||
if (IsVarTerm(t1)) {
|
if (IsVarTerm(t1)) {
|
||||||
@ -1579,9 +1577,9 @@ static Int string_to_term(USES_REGS1) {
|
|||||||
const unsigned char *us = UStringOfTerm(t1);
|
const unsigned char *us = UStringOfTerm(t1);
|
||||||
return Yap_UBufferToTerm(us, add_output(ARG2, add_names(ARG3, TermNil)));
|
return Yap_UBufferToTerm(us, add_output(ARG2, add_names(ARG3, TermNil)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Yap_InitReadTPreds(void) {
|
void Yap_InitReadTPreds(void) {
|
||||||
Yap_InitCPred("read_term", 2, read_term2, SyncPredFlag);
|
Yap_InitCPred("read_term", 2, read_term2, SyncPredFlag);
|
||||||
Yap_InitCPred("read_term", 3, read_term, SyncPredFlag);
|
Yap_InitCPred("read_term", 3, read_term, SyncPredFlag);
|
||||||
|
|
||||||
@ -1602,4 +1600,4 @@ void Yap_InitReadTPreds(void) {
|
|||||||
Yap_InitCPred("source_location", 2, source_location, SyncPredFlag);
|
Yap_InitCPred("source_location", 2, source_location, SyncPredFlag);
|
||||||
Yap_InitCPred("$style_checker", 1, style_checker,
|
Yap_InitCPred("$style_checker", 1, style_checker,
|
||||||
SyncPredFlag | HiddenPredFlag);
|
SyncPredFlag | HiddenPredFlag);
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ add_definitions(-DSQLITE_ENABLE_JSON1=1 )
|
|||||||
add_definitions(-DSQLITE_ENABLE_RBU=1 )
|
add_definitions(-DSQLITE_ENABLE_RBU=1 )
|
||||||
|
|
||||||
add_definitions(-DSQLITE_ENABLE_RTREE=1 )
|
add_definitions(-DSQLITE_ENABLE_RTREE=1 )
|
||||||
|
|
||||||
add_definitions(-DSQLITE_ENABLE_FTS5=1 )
|
add_definitions(-DSQLITE_ENABLE_FTS5=1 )
|
||||||
|
|
||||||
SET_PROPERTY(DIRECTORY PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1 )
|
SET_PROPERTY(DIRECTORY PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1 )
|
||||||
@ -47,6 +46,8 @@ else()
|
|||||||
add_library( YAPsqlite3 SHARED
|
add_library( YAPsqlite3 SHARED
|
||||||
${YAPSQLITE3_SOURCES})
|
${YAPSQLITE3_SOURCES})
|
||||||
|
|
||||||
|
target_link_libraries(YAPsqlite3 libYap )
|
||||||
|
|
||||||
set_target_properties(YAPsqlite3
|
set_target_properties(YAPsqlite3
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
# RPATH ${libdir} VERSION ${LIBYAPTAI_FULL_VERSION}
|
# RPATH ${libdir} VERSION ${LIBYAPTAI_FULL_VERSION}
|
||||||
|
@ -198,8 +198,7 @@ compose_message( halt, _Level) --> !,
|
|||||||
|
|
||||||
% syntax error.
|
% syntax error.
|
||||||
compose_message(error(E, Exc), Level) -->
|
compose_message(error(E, Exc), Level) -->
|
||||||
{ '$show_consult_level'(LC), '$print_exception'(Exc)
|
{ '$show_consult_level'(LC) },
|
||||||
},
|
|
||||||
location(error(E, Exc), Level, LC),
|
location(error(E, Exc), Level, LC),
|
||||||
main_message(error(E,Exc) , Level, LC ),
|
main_message(error(E,Exc) , Level, LC ),
|
||||||
c_goal( error(E, Exc), Level ),
|
c_goal( error(E, Exc), Level ),
|
||||||
@ -257,6 +256,7 @@ location(style_check(A,LN,FileName,B ), Level , LC) -->
|
|||||||
display_consulting( FileName, Level,style_check(A,LN,FileName,B ), LC ),
|
display_consulting( FileName, Level,style_check(A,LN,FileName,B ), LC ),
|
||||||
[ '~a:~d:0 ~a ' - [FileName,LN,Level] ] .
|
[ '~a:~d:0 ~a ' - [FileName,LN,Level] ] .
|
||||||
location( error(_,Info), Level, LC ) -->
|
location( error(_,Info), Level, LC ) -->
|
||||||
|
|
||||||
{ '$error_descriptor'(Info, Desc) },
|
{ '$error_descriptor'(Info, Desc) },
|
||||||
{
|
{
|
||||||
'$query_exception'(prologPredFile, Desc, File),
|
'$query_exception'(prologPredFile, Desc, File),
|
||||||
@ -267,19 +267,7 @@ location( error(_,Info), Level, LC ) -->
|
|||||||
},
|
},
|
||||||
!,
|
!,
|
||||||
display_consulting( File, Level, Info, LC ),
|
display_consulting( File, Level, Info, LC ),
|
||||||
[ '~s:~d:0 ~a in ~s:~s/~d:'-[File, FilePos,Level,M,Na,Ar] ].
|
[ '~a:~d:0 ~a in ~a:~a/~d:'-[File, FilePos,Level,M,Na,Ar] ].
|
||||||
location( error(_,Info), Level, LC ) -->
|
|
||||||
{ '$error_descriptor'(Info, Desc) },
|
|
||||||
{
|
|
||||||
'$query_exception'(prologPredFile, Desc, File),
|
|
||||||
'$query_exception'(prologPredLine, Desc, FilePos),
|
|
||||||
'$query_exception'(prologPredModule, Desc, M),
|
|
||||||
'$query_exception'(prologPredName, Desc, Na),
|
|
||||||
'$query_exception'(prologPredArity, Desc, Ar)
|
|
||||||
},
|
|
||||||
!,
|
|
||||||
display_consulting( File, Level, Info, LC ),
|
|
||||||
[ '~s:~d:0 ~a in ~s:~s/~d:'-[File, FilePos,Level,M,Na,Ar] ].
|
|
||||||
location( error(_,Info), Level, LC ) -->
|
location( error(_,Info), Level, LC ) -->
|
||||||
{ '$error_descriptor'(Info, Desc) },
|
{ '$error_descriptor'(Info, Desc) },
|
||||||
{
|
{
|
||||||
@ -289,7 +277,7 @@ location( error(_,Info), Level, LC ) -->
|
|||||||
},
|
},
|
||||||
!,
|
!,
|
||||||
display_consulting( File, Level, Info, LC ),
|
display_consulting( File, Level, Info, LC ),
|
||||||
[ '~s:~d:0 ~a in ~s():'-[File, FilePos,Level,F] ].
|
[ '~a:~d:0 ~a in ~a():'-[File, FilePos,Level,F] ].
|
||||||
location( _Ball, _Level, _LC ) --> [].
|
location( _Ball, _Level, _LC ) --> [].
|
||||||
|
|
||||||
|
|
||||||
@ -393,7 +381,7 @@ caller( Info, _) -->
|
|||||||
},
|
},
|
||||||
!,
|
!,
|
||||||
[nl],
|
[nl],
|
||||||
['~*| raised from ~a:~q:~d, ~a:~d:0: '-[10,M,Na,Ar,File, FilePos]],
|
['~*| ~q:~d:0 ~a:~q'-[10,File, FilePos,M,Na,Ar]],
|
||||||
[nl].
|
[nl].
|
||||||
caller( _, _) -->
|
caller( _, _) -->
|
||||||
[].
|
[].
|
||||||
@ -982,8 +970,9 @@ confusing to YAP (who will process the error?). So we write this small
|
|||||||
stub to ensure everything os ok
|
stub to ensure everything os ok
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
:- dynamic in/0.
|
||||||
/*
|
/*
|
||||||
/*:- dynamic in/0.
|
|
||||||
prolog:print_message(Severity, Msg) :-
|
prolog:print_message(Severity, Msg) :-
|
||||||
\+ in,
|
\+ in,
|
||||||
assert(in),
|
assert(in),
|
||||||
@ -991,7 +980,7 @@ prolog:print_message(Severity, Msg) :-
|
|||||||
( prolog:print_message(Severity, Msg), fail;
|
( prolog:print_message(Severity, Msg), fail;
|
||||||
stop_low_level_trace,
|
stop_low_level_trace,
|
||||||
retract(in)
|
retract(in)
|
||||||
).*/
|
).
|
||||||
*/
|
*/
|
||||||
prolog:print_message(Severity, Msg) :-
|
prolog:print_message(Severity, Msg) :-
|
||||||
(
|
(
|
||||||
@ -1044,6 +1033,7 @@ prolog:print_message(Severity, Term) :-
|
|||||||
!.
|
!.
|
||||||
prolog:print_message(Severity, Term) :-
|
prolog:print_message(Severity, Term) :-
|
||||||
translate_message( Term, Severity, Lines0, [ end(Id)]),
|
translate_message( Term, Severity, Lines0, [ end(Id)]),
|
||||||
|
writeln(Lines0),
|
||||||
Lines = [begin(Severity, Id)| Lines0],
|
Lines = [begin(Severity, Id)| Lines0],
|
||||||
(
|
(
|
||||||
user:message_hook(Term, Severity, Lines)
|
user:message_hook(Term, Severity, Lines)
|
||||||
@ -1057,7 +1047,7 @@ prolog:print_message(Severity, Term) :-
|
|||||||
prolog:print_message(_Severity, _Term) :-
|
prolog:print_message(_Severity, _Term) :-
|
||||||
format(user_error,'failed to print ~w: ~w~n' ,[ _Severity, _Term]).
|
format(user_error,'failed to print ~w: ~w~n' ,[ _Severity, _Term]).
|
||||||
|
|
||||||
'$error_descriptor'( error(_,Info), Info ).
|
'$error_descriptor'( exception(Info), Info ).
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user