:more db stuff

This commit is contained in:
Vitor Santos Costa 2018-06-28 12:48:29 +01:00
parent d3370ee141
commit 6c1d3d1a95
18 changed files with 122 additions and 71 deletions

View File

@ -1001,6 +1001,15 @@ static Int read_exception(USES_REGS1) {
return Yap_unify(ARG2, rc); return Yap_unify(ARG2, rc);
} }
static Int print_exception(USES_REGS1) {
yap_error_descriptor_t *t = AddressOfTerm(Deref(ARG1));
printErr(t);
// Yap_DebugPlWriteln(rc);
return true;
}
static Int query_exception(USES_REGS1) { static Int query_exception(USES_REGS1) {
const char *query; const char *query;
Term t; Term t;
@ -1022,6 +1031,7 @@ static Int query_exception(USES_REGS1) {
} }
} }
static Int drop_exception(USES_REGS1) { static Int drop_exception(USES_REGS1) {
yap_error_descriptor_t *t = AddressOfTerm(Deref(ARG1)); yap_error_descriptor_t *t = AddressOfTerm(Deref(ARG1));
free(t); free(t);
@ -1226,6 +1236,7 @@ static Int is_predicate_indicator(USES_REGS1) {
void Yap_InitErrorPreds(void) { void Yap_InitErrorPreds(void) {
CACHE_REGS CACHE_REGS
Yap_InitCPred("$print_exception", 1, print_exception, 0);
Yap_InitCPred("$reset_exception", 1, reset_exception, 0); Yap_InitCPred("$reset_exception", 1, reset_exception, 0);
Yap_InitCPred("$new_exception", 1, new_exception, 0); Yap_InitCPred("$new_exception", 1, new_exception, 0);
Yap_InitCPred("$get_exception", 1, get_exception, 0); Yap_InitCPred("$get_exception", 1, get_exception, 0);

View File

@ -437,12 +437,15 @@ unsigned char *Yap_readText(seq_tv_t *inp USES_REGS) {
LOCAL_Error_TYPE = TYPE_ERROR_TEXT; LOCAL_Error_TYPE = TYPE_ERROR_TEXT;
} }
} }
LOCAL_ActiveError->errorRawTerm = MkUStringTerm(inp->val.uc);
}
if (LOCAL_Error_TYPE != YAP_NO_ERROR) { if (LOCAL_Error_TYPE != YAP_NO_ERROR) {
if (inp->val.uc != NULL) {
LOCAL_ActiveError->errorRawTerm = MkUStringTerm(inp->val.uc);
}
Yap_ThrowError(LOCAL_Error_TYPE, LOCAL_ActiveError->errorRawTerm, "Converting to text from term "); Yap_ThrowError(LOCAL_Error_TYPE, LOCAL_ActiveError->errorRawTerm, "Converting to text from term ");
return NULL; return NULL;
} }
}
if (IsAtomTerm(inp->val.t) && inp->type & YAP_STRING_ATOM) { if (IsAtomTerm(inp->val.t) && inp->type & YAP_STRING_ATOM) {
// this is a term, extract to a buffer, and representation is wide // this is a term, extract to a buffer, and representation is wide

View File

@ -726,9 +726,6 @@ if (!result) {
} }
PredEntry *YAPQuery::rewriteUndefQuery() { PredEntry *YAPQuery::rewriteUndefQuery() {
Term ts[2];
ts[0] = CurrentModule;
ts[1] = goal;
ARG1 = goal = Yap_SaveTerm(Yap_MkApplTerm(FunctorCall ARG1 = goal = Yap_SaveTerm(Yap_MkApplTerm(FunctorCall
, 1, &goal)); , 1, &goal));
return ap = PredCall; return ap = PredCall;

View File

@ -294,11 +294,19 @@ INLINE_ONLY Term __MkStringTerm(const char *s USES_REGS);
INLINE_ONLY Term __MkStringTerm(const char *s USES_REGS) { INLINE_ONLY Term __MkStringTerm(const char *s USES_REGS) {
Term t = AbsAppl(HR); Term t = AbsAppl(HR);
size_t sz = ALIGN_BY_TYPE(strlen((char *)s) + 1, CELL); size_t sz;
HR[0] = (CELL)FunctorString; if ((s[0] == '\0')) {
HR[1] = (CELL)sz; sz = sizeof(CELL);
strcpy((char *)(HR + 2), (const char *)s); HR[0] = (CELL)FunctorString;
HR[2 + sz] = EndSpecials; HR[1] = (CELL)sz;
HR[2] = 0;
} else {
sz = ALIGN_BY_TYPE(strlen((char *)s) + 1, CELL);
HR[0] = (CELL)FunctorString;
HR[1] = (CELL)sz;
strcpy((char *)(HR + 2), (const char *)s);
}
HR[2 + sz] = EndSpecials;
HR += 3 + sz; HR += 3 + sz;
return t; return t;
} }
@ -311,11 +319,19 @@ __MkUStringTerm(const unsigned char *s USES_REGS);
INLINE_ONLY Term INLINE_ONLY Term
__MkUStringTerm(const unsigned char *s USES_REGS) { __MkUStringTerm(const unsigned char *s USES_REGS) {
Term t = AbsAppl(HR); Term t = AbsAppl(HR);
size_t sz = ALIGN_BY_TYPE(strlen((char *)s) + 1, CELL); size_t sz;
HR[0] = (CELL)FunctorString; if ((s[0] == '\0')) {
HR[1] = (CELL)sz; sz = sizeof(CELL);
strcpy((char *)(HR + 2), (const char *)s); HR[0] = (CELL)FunctorString;
HR[2 + sz] = EndSpecials; HR[1] = (CELL)sz;
HR[2] = 0;
} else {
sz = ALIGN_BY_TYPE(strlen((char *)s) + 1, CELL);
HR[0] = (CELL)FunctorString;
HR[1] = (CELL)sz;
strcpy((char *)(HR + 2), (const char *)s);
}
HR[2 + sz] = EndSpecials;
HR += 3 + sz; HR += 3 + sz;
return t; return t;
} }

View File

@ -8,6 +8,7 @@
* *
*/ */
:- module(gensym, [ :- module(gensym, [
init_gensym/1,
gensym/2, gensym/2,
reset_gensym/1, reset_gensym/1,
reset_gensym/0 reset_gensym/0
@ -26,6 +27,9 @@
:- dynamic gensym_key/2. :- dynamic gensym_key/2.
init_gensym(Key) :-
assert(gensym_key(Atom,0) ).
gensym(Atom, New) :- gensym(Atom, New) :-
retract(gensym_key(Atom,Id)), !, retract(gensym_key(Atom,Id)), !,
atomic_concat(Atom,Id,New), atomic_concat(Atom,Id,New),

View File

@ -473,7 +473,7 @@ static void InitStdStreams(void) {
#if USE_READLINE #if USE_READLINE
if (GLOBAL_Stream[StdInStream].status & Tty_Stream_f && if (GLOBAL_Stream[StdInStream].status & Tty_Stream_f &&
GLOBAL_Stream[StdOutStream].status & Tty_Stream_f && GLOBAL_Stream[StdOutStream].status & Tty_Stream_f &&
GLOBAL_Stream[StdErrStream].status & Tty_Stream_f && !Yap_embedded) { GLOBAL_Stream[StdErrStream].status & Tty_Stream_f && !Yap_Embedded) {
Yap_InitReadline(TermTrue); Yap_InitReadline(TermTrue);
} }
#endif #endif

View File

@ -280,7 +280,7 @@ bool Yap_ReadlineOps(StreamDesc *s) {
bool Yap_InitReadline(Term enable) { bool Yap_InitReadline(Term enable) {
// don't call readline within emacs // don't call readline within emacs
if (Yap_embedded) if (Yap_Embedded)
return false; return false;
if (!(GLOBAL_Stream[StdInStream].status & Tty_Stream_f) || if (!(GLOBAL_Stream[StdInStream].status & Tty_Stream_f) ||
getenv("INSIDE_EMACS") || enable != TermTrue) { getenv("INSIDE_EMACS") || enable != TermTrue) {
@ -450,7 +450,7 @@ int Yap_ReadlineForSIGINT(void) {
static Int has_readline(USES_REGS1) { static Int has_readline(USES_REGS1) {
#if USE_READLINE #if USE_READLINE
if (!Yap_embedded) { if (!Yap_Embedded) {
return true; return true;
} }
return false; return false;

View File

@ -20,18 +20,18 @@
set_property(GLOBAL set_property(GLOBAL
APPEND PROPERTY COMPILE_DEFINITIONS -DMYDDAS_MYSQL=1) APPEND PROPERTY COMPILE_DEFINITIONS -DMYDDAS_MYSQL=1)
if (WIN32) if (WIN32)
add_library(Yapmysql OBJECT ${MYSQL_SOURCES}) add_library(YAPmysql OBJECT ${MYSQL_SOURCES})
else() else()
add_lib(Yapmysql ${MYSQL_SOURCES}) add_lib(YAPmysql ${MYSQL_SOURCES})
target_link_libraries(Yapmysql ${MYSQL_LIBRARIES} libYap) target_link_libraries(YAPmysql ${MYSQL_LIBRARIES} libYap)
install(TARGETS Yapmysql install(TARGETS YAPmysql
RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR} RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR}
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR} ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR}
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR} LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}
) )
endif() endif()
include_directories(${MYSQL_INCLUDE_DIR} ..) include_directories(${MYSQL_INCLUDE_DIR} ..)
set_target_properties(Yapmysql PROPERTIES set_target_properties(YAPmysql PROPERTIES
POSITION_INDEPENDENT_CODE ON POSITION_INDEPENDENT_CODE ON
PREFIX "" PREFIX ""
) )

View File

@ -13,11 +13,11 @@ if (ODBC_FOUND)
# ODBC_INCLUDE_DIRECTORIES, where to find sql.h # ODBC_INCLUDE_DIRECTORIES, where to find sql.h
# ODBC_LIBRARIES, the libraries to link against to use ODBC # ODBC_LIBRARIES, the libraries to link against to use ODBC
# ODBC_FOUND. If false, you cannot build anything that requires Odbc. # ODBC_FOUND. If false, you cannot build anything that requires Odbc.
add_lib(Yapodbc ${YAPODBC_SOURCES}) add_lib(YAPodbc ${YAPODBC_SOURCES})
target_link_libraries(Yapodbc libYap ${ODBC_LIBRARIES}) target_link_libraries(YAPodbc libYap ${ODBC_LIBRARIES})
include_directories (${ODBC_INCLUDE_DIRECTORIES} ..) include_directories (${ODBC_INCLUDE_DIRECTORIES} ..)
set_target_properties (Yapodbc PROPERTIES set_target_properties (YAPodbc PROPERTIES
POSITION_INDEPENDENT_CODE ON POSITION_INDEPENDENT_CODE ON
PREFIX "" PREFIX ""
) )
@ -28,7 +28,7 @@ set_target_properties (Yapodbc PROPERTIES
-DMYDDAS_ODBC=1) -DMYDDAS_ODBC=1)
install(TARGETS Yapodbc install(TARGETS YAPodbc
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR} LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}
RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR} RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR}
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR} ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR}

View File

@ -18,23 +18,23 @@
#undef sqlite3 #undef sqlite3
#define DBMS(x) sqlite3_##x #define DBMS(x) sqlite3_##x
#define c_DBMS(x) c_sqlite3_##x #define c_DBMS(x) c_sqlite3_##x
#define NAME() 'libYapsqlite3' #define NAME() 'YAPsqlite3'
#define MODULE() user #define MODULE() user
#define INIT() init_sqlite3 #define INIT() init_sqlite3
#elif defined( odbc ) #elif defined( odbc )
#undef odbc #undef odbc
#define DBMS(x) odbc_##x #define DBMS(x) odbc_##x
#define c_DBMS(x) c_odbc_##x #define c_DBMS(x) c_odbc_##x
#define NAME() 'libYapodbc' #define NAME() 'YAPodbc'
#define MODULE() user #define MODULE() user
#define INIT() init_odbc #define INIT() init_odbc
#elif defined( postgres ) #elif defined( postgres )
#undef postgres #undef postgres
#define DBMS(x) postgres_##x #define DBMS(x) postgres_##x
#define c_DBMS(x) c_postgres_##x #define c_DBMS(x) c_postgres_##x
#define NAME() 'libYappostgres' #define NAME() 'YAPpostgres'
#define MODULE() user #define MODULE() user
#define INIT() init_odbc #define INIT() init_postgres
#endif #endif
#if defined(DBMS) #if defined(DBMS)
@ -71,7 +71,9 @@
'$make_a_list'/2, '$make_a_list'/2,
'$write_or_not'/1 '$write_or_not'/1
]). ]).
% :- load_foreign_files( [NAME()], [], INIT()). #ifndef __ANDROID__
:- load_foreign_files( [NAME()], [], INIT()).
#endif
%-------------------------------------------------------- %--------------------------------------------------------
% Public Predicates % Public Predicates

View File

@ -55,7 +55,7 @@
]). ]).
:- load_foreign_files( ['Yapmysql'], [], init_mysql). :- load_foreign_files( ['YAPmysql'], [], init_mysql).
%-------------------------------------------------------- %--------------------------------------------------------
@ -248,4 +248,4 @@ db_my_sql_mode(Connection,SQLMode):-
#endif /* MYDDAS_MYSQL*/ #endif /* MYDDAS_MYSQL*/

View File

@ -38,17 +38,19 @@
% -------------------------------------------------------------------------------------- % --------------------------------------------------------------------------------------
:- use_module(lists,[
append/3,
member/2
]).
:- module(myddas_prolog2sql,[ :- module(myddas_prolog2sql,[
translate/3, translate/3,
queries_atom/2 queries_atom/2
]). ]).
:- use_module(library(lists),[
append/3,
member/2
]).
:- use_module(library(gensym)).
:- use_module(myddas_prolog2sql_optimizer,[ :- use_module(myddas_prolog2sql_optimizer,[
optimize_sql/2 optimize_sql/2
@ -1225,7 +1227,7 @@ column_atom(Number,List,Diff) :-
append(X1,Diff,List). append(X1,Diff,List).
#if SEPIA
% --- gensym(Root,Symbol) ---------------------------------------------------- % --- gensym(Root,Symbol) ----------------------------------------------------
% %
% SEPIA 3.2. version - other Prolog implementations provide gensym/2 % SEPIA 3.2. version - other Prolog implementations provide gensym/2
@ -1246,7 +1248,7 @@ gensym(Atom,Var) :-
char_code(Var,NewCode), char_code(Var,NewCode),
set_value(Atom,Var). set_value(Atom,Var).
#endif
% --- auxiliary predicates (some of them may be built-in... -------------------- % --- auxiliary predicates (some of them may be built-in... --------------------

View File

@ -14,10 +14,10 @@ if (PostgreSQL_FOUND)
# PostgreSQL_INCLUDE_DIRS - Include directories for PostgreSQL # PostgreSQL_INCLUDE_DIRS - Include directories for PostgreSQL
# PostgreSQL_LIBRARY_DIRS - Link directories for PostgreSQL libraries # PostgreSQL_LIBRARY_DIRS - Link directories for PostgreSQL libraries
# PostgreSQL_LIBRARIES - The PostgreSQL libraries. # PostgreSQL_LIBRARIES - The PostgreSQL libraries.
add_lib(Yappostgres ${YAPPOSTGRES_SOURCES}) add_lib(YAPpostgres ${YAPPOSTGRES_SOURCES})
target_link_libraries(Yappostgres libYap ${PostgreSQL_LIBRARIES}) target_link_libraries(YAPpostgres libYap ${PostgreSQL_LIBRARIES})
include_directories (${PostgreSQL_INCLUDE_DIRS} ..) include_directories (${PostgreSQL_INCLUDE_DIRS} ..)
set_target_properties (Yappostgres PROPERTIES set_target_properties (YAPpostgres PROPERTIES
POSITION_INDEPENDENT_CODE ON POSITION_INDEPENDENT_CODE ON
PREFIX "" PREFIX ""
) )
@ -27,7 +27,7 @@ set (MYDDAS_FLAGS ${MYDDAS_FLAGS} ON PARENT_SCOPE)
set_property(GLOBAL APPEND PROPERTY COMPILE_DEFINITIONS set_property(GLOBAL APPEND PROPERTY COMPILE_DEFINITIONS
-DMYDDAS_POSTGRES=1) -DMYDDAS_POSTGRES=1)
install(TARGETS Yappostgres install(TARGETS YAPpostgres
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR} LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}
RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR} RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR}
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR} ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR}

View File

@ -1,4 +1,4 @@
message( " * Sqlite3 Data-Base (http://www.sqlite3ql.org), distributed with MYDDAS" ) message( " * Sqlite3 Data-Base (http://www.sqlite3.org), distributed with MYDDAS" )
set (SQLITE_EXTRA set (SQLITE_EXTRA
chinook.db chinook.db
@ -35,23 +35,27 @@ add_definitions(-DSQLITE_ENABLE_FTS5=1 )
SET_PROPERTY(DIRECTORY PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1 ) SET_PROPERTY(DIRECTORY PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1 )
add_library( Yapsqlite3 OBJECT if (ANDROID)
add_library( YAPsqlite3 OBJECT
${YAPSQLITE3_SOURCES} ) ${YAPSQLITE3_SOURCES} )
else()
if (NOT ANDROID) list(APPEND YAPSQLITE3_SOURCES src/sqlite3.c)
add_library( sqlite4YAP SHARED
src/sqlite3.c)
set_target_properties(sqlite4YAP
add_library( YAPsqlite3 SHARED
${YAPSQLITE3_SOURCES})
set_target_properties(YAPsqlite3
PROPERTIES PROPERTIES
# RPATH ${libdir} VERSION ${LIBYAPTAI_FULL_VERSION} # RPATH ${libdir} VERSION ${LIBYAPTAI_FULL_VERSION}
# SOVERSION ${LIBYAPTAI_MAJOR_VERSION}.${LIBYAPTAI_MINOR_VERSION} # SOVERSION ${LIBYAPTAI_MAJOR_VERSION}.${LIBYAPTAI_MINOR_VERSION}
POSITION_INDEPENDENT_CODE TRUE POSITION_INDEPENDENT_CODE ON
) PREFIX ""
)
install(TARGETS YAPsqlite3
install(TARGETS sqlite4YAP
RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR} RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR}
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR} ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR}
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR} LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}

View File

@ -36,7 +36,7 @@
int i; \ int i; \
i = sqlite3_##f; \ i = sqlite3_##f; \
if (i != SQLITE_OK) { \ if (i != SQLITE_OK) { \
Yap_Error(EVALUATION_ERROR_DBMS, t, "%s failed with status %d: %s\n", \ Yap_ThrowError(EVALUATION_ERROR_DBMS, MkStringTerm(#f), "%s failed with status %d: %s\n", \
#f, i, sqlite3_errmsg(db)); \ #f, i, sqlite3_errmsg(db)); \
} \ } \
} }
@ -46,7 +46,7 @@
int i; \ int i; \
i = sqlite3_##f; \ i = sqlite3_##f; \
if (i != SQLITE_##x) { \ if (i != SQLITE_##x) { \
fprintf(stderr, "%s failed with status %d: %s\n", #f, i, \ Yap_ThrowError(EVALUATION_ERROR_DBMS, MkStringTerm(#f), "%s failed with status %d: %s\n", #f, i, \
sqlite3_errmsg(db)); \ sqlite3_errmsg(db)); \
exit(1); \ exit(1); \
} \ } \
@ -489,7 +489,7 @@ static Int c_sqlite3_row_terminate(USES_REGS1) {
struct result_set *res_set = rs->res_set; struct result_set *res_set = rs->res_set;
sqlite3 *db = res_set->db; sqlite3 *db = res_set->db;
// no more data // no more data
CALL_SQLITE(ARG1, finalize(res_set->stmt)); CALL_SQLITE(Deref(ARG1), finalize(res_set->stmt));
free(res_set); free(res_set);
free(rs); free(rs);
return true; return true;
@ -667,7 +667,7 @@ static void Yap_InitBackMYDDAS_SQLITE3Preds(void) {
// Yap_InitCPredBack("c_sqlite3_row", 3, 0, c_sqlite3_row_initialise, // Yap_InitCPredBack("c_sqlite3_row", 3, 0, c_sqlite3_row_initialise,
// c_sqlite3_row, c_sqlite3_row_terminate); // c_sqlite3_row, c_sqlite3_row_terminate);
Yap_InitCPred("c_sqlite3_row_initialise", 2, c_sqlite3_row_initialise, 0); Yap_InitCPred("c_sqlite3_row_initialise", 2, c_sqlite3_row_initialise, 0);
Yap_InitCPred("c_sqlite3_row_terminate", 1, c_sqlite3_row_terminate, 0); Yap_InitCPred("c_sqlite3_row_terminate", 2, c_sqlite3_row_terminate, 0);
Yap_InitCPredBack("c_sqlite3_row_get", 4, 0, c_sqlite3_row, c_sqlite3_row, 0); Yap_InitCPredBack("c_sqlite3_row_get", 4, 0, c_sqlite3_row, c_sqlite3_row, 0);
} }

View File

@ -12,7 +12,8 @@ main_ :-
main_ . main_ .
init :- init :-
db_open(sqlite3, '/data/user/0/pt.up.yap.yapdroid/files/Yap/chinook.db', _, _), % db_open(sqlite3, '/data/user/0/pt.up.yap.yapdroid/files/Yap/chinook.db', _, _),
db_open(sqlite3, 'chinook.db', _, _),
writeln('chinook has landed'). writeln('chinook has landed').
go :- go :-
@ -75,7 +76,6 @@ go :-
writeln(X:Y). writeln(X:Y).
go_cut0 :- go_cut0 :-
start_low_level_trace,
artists(X,Y), artists(X,Y),
writeln(X:Y), writeln(X:Y),
!. !.

View File

@ -198,12 +198,13 @@ compose_message( halt, _Level) --> !,
% syntax error. % syntax error.
compose_message(error(E, Exc), Level) --> compose_message(error(E, Exc), Level) -->
{ '$show_consult_level'(LC) }, { '$show_consult_level'(LC), '$print_exception'(Exc)
},
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( Exc, Level ), c_goal( error(E, Exc), Level ),
caller( Exc, Level ), caller( error(E, Exc), Level ),
extra_info( Exc, Level ), extra_info( error(E, Exc), Level ),
!, !,
[nl,nl]. [nl,nl].
compose_message( false, _Level) --> !, compose_message( false, _Level) --> !,
@ -367,7 +368,7 @@ display_consulting( F, Level, _, LC) -->
display_consulting(_F, _, _, _LC) --> display_consulting(_F, _, _, _LC) -->
[]. [].
caller( error(_,Info), _) --> caller( Info, _) -->
{ '$error_descriptor'(Info, Desc) }, { '$error_descriptor'(Info, Desc) },
({ '$query_exception'(errorGoal, Desc, Call), ({ '$query_exception'(errorGoal, Desc, Call),
Call = M:(H :- G) Call = M:(H :- G)
@ -381,7 +382,7 @@ caller( error(_,Info), _) -->
-> ->
['~*|by ~w' - [10,Call]] ['~*|by ~w' - [10,Call]]
; ;
true []
), ),
{ '$query_exception'(prologPredFile, Desc, File), { '$query_exception'(prologPredFile, Desc, File),
File \= [], File \= [],
@ -397,7 +398,7 @@ caller( error(_,Info), _) -->
caller( _, _) --> caller( _, _) -->
[]. [].
c_goal( error(_,Info), Level ) --> c_goal( Info, Level ) -->
{ '$error_descriptor'(Info, Desc) }, { '$error_descriptor'(Info, Desc) },
{ '$query_exception'(errorFile, Desc, File), { '$query_exception'(errorFile, Desc, File),
Func \= [], Func \= [],
@ -980,6 +981,17 @@ Note: errors in the implementation of print_message/2 are very
confusing to YAP (who will process the error?). So we write this small 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.
prolog:print_message(Severity, Msg) :-
\+ in,
assert(in),
start_low_level_trace,
( prolog:print_message(Severity, Msg), fail;
stop_low_level_trace,
retract(in)
).*/
*/ */
prolog:print_message(Severity, Msg) :- prolog:print_message(Severity, Msg) :-
( (
@ -995,7 +1007,7 @@ prolog:print_message(Severity, Msg) :-
; ;
Severity == silent Severity == silent
-> ->
true []
; ;
'$pred_exists'(portray_message(_,_),user), '$pred_exists'(portray_message(_,_),user),
user:portray_message(Severity, Msg) user:portray_message(Severity, Msg)
@ -1045,7 +1057,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'( Info, Info ). '$error_descriptor'( error(_,Info), Info ).
/** /**

View File

@ -138,7 +138,7 @@ undefined_query(G0, M0, Cut) :-
'$handle_error'(Action,G0,M0) '$handle_error'(Action,G0,M0)
). ).
%:- '$undefp_handler'('$undefp'(_,_), prolog). :- '$undefp_handler'('$undefp'(_,_), prolog).
/** @pred unknown(- _O_,+ _N_) /** @pred unknown(- _O_,+ _N_)