This commit is contained in:
Vitor Santos Costa 2018-12-14 14:53:39 +00:00
parent 890f77d698
commit 3fa4bfbcb2
6 changed files with 48 additions and 33 deletions

View File

@ -211,7 +211,7 @@ static bool load_file(const char *b_file USES_REGS) {
YAP_CompileClause(t);
}
yap_error_descriptor_t *errd;
if ((errd = Yap_GetException(LOCAL_ActiveError))) {
if ((errd = Yap_GetException(LOCAL_ActiveError)) && (errd->errorNo != YAP_NO_ERROR)) {
fprintf(stderr, "%s:%ld:0: Error %s %s Found\n", errd->errorFile,
(long int)errd->errorLine, errd->classAsText, errd->errorAsText);
}
@ -327,7 +327,6 @@ static void Yap_set_locations(YAP_init_args *iap) {
// --_not useful in Android, WIN32;
/// -- DESTDIR/ in Anaconda
/// -- /usr/locall in most Unix style systems
#if 0
Yap_ROOTDIR = sel( is_dir, NULL,
iap->ROOTDIR,
getenv("YAPROOTDIR"),
@ -427,7 +426,6 @@ const char * Yap_PLBOOTDIR = sel( is_dir, Yap_PLDIR,
join(Yap_PLBOOTDIR, "/boot.yap"),
#endif
EOLIST);
#endif
/// STARTUP: where we can find the core Prolog bootstrap file
Yap_OUTPUT_STARTUP =
sel( is_wfile, Yap_AbsoluteFile(".",false), iap->OUTPUT_STARTUP,
@ -440,14 +438,16 @@ EOLIST,
EOLIST);
Yap_INPUT_STARTUP =
sel( is_wfile, Yap_DLLDIR, iap->INPUT_STARTUP,
sel( is_file, Yap_DLLDIR, iap->INPUT_STARTUP,
"startup.yss",
#if __ANDROID__
EOLIST,
#else
join(getenv("DESTDIR"), YAP_INPUT_STARTUP),
#endif
"startup.yss",
join(Yap_DLLDIR, "/startup.yss"),
"/usr/local/lib/Yap/startup.yss",
"/usr/lib/Yap/startup.yss",
EOLIST);
if (Yap_ROOTDIR)

View File

@ -13,9 +13,13 @@ set(MYDDAS_DRIVERS
)
set(MYDDAS_DBMS sqlite3 postgres odbc)
if (ANDROID)
set (MYDDAS_PL_OUTDIR ${YAP_APP_DIR}/src/generated/assets/Yap )
else()
set (MYDDAS_PL_OUTDIR ${CMAKE_CURRENT_BINARY_DIR})
endif()
get_property(MYDDAS_FLAGS GLOBAL PROPERTY COMPILE_DEFINITIONS)
foreach (filename in ${MYDDAS_YPP})
foreach (filename ${MYDDAS_YPP})
get_filename_component(base ${filename} NAME_WE)
set(base_abs ${MYDDAS_PL_OUTDIR}/${base})
set(outfile ${base_abs}.yap)
@ -24,7 +28,7 @@ foreach (filename in ${MYDDAS_YPP})
)
set_source_files_properties(outfile PROPERTIES GENERATED TRUE)
endforeach ()
foreach (dbms in ${MYDDAS_DBMS} )
foreach (dbms ${MYDDAS_DBMS} )
set(outfile ${MYDDAS_PL_OUTDIR}/myddas_${dbms}.yap)
execute_process(
COMMAND ${CMAKE_C_COMPILER} -D${dbms} -x c -E -P -w ${CMAKE_CURRENT_SOURCE_DIR}/myddas_driver.ypp -o ${outfile}
@ -35,6 +39,6 @@ foreach (dbms in ${MYDDAS_DBMS} )
endforeach()
set( MYDDAS_YAP ${CMAKE_CURRENT_SOURCE_DIR}/../sqlite3/sqlitest.yap ${CMAKE_CURRENT_SOURCE_DIR}/../sqlite3/chinook.db)
#add_to_group(MYDDAS_YAP pl_library )
add_to_group(MYDDAS_YAP pl_library )
file(INSTALL ${MYDDAS_YAP}
DESTINATION ${MYDDAS_PL_OUTDIR} )

View File

@ -42,7 +42,7 @@ jupyter_cell(Caller, _, Line ) :-
catch(
python_query(Query,Line),
error(A,B),
system_error(A,B)
(writeln(A,B),system_error(A,B))
).
restreams(call) :-

View File

@ -165,7 +165,7 @@ prolog:copy_term(Term, Copy, Gs) :-
-> Gs = [],
copy_term(Term, Copy)
; findall(Term-Gs,
'$attributes':residuals_and_delete_attributes(Vs, Gs, Term),
attributes:residuals_and_delete_attributes(Vs, Gs, Term),
[Copy-Gs])
).

View File

@ -494,6 +494,7 @@ write_query_answer( Bindings ) :-
'$write_goal_output'(G1, First, NG, Next, IG),
'$write_vars_and_goals'(LG, Next, IG).
'$write_goal_output'(var([V|VL]), First, [var([V|VL])|L], next, L) :- !,
( First = first -> true ; format(user_error,',~n',[]) ),
format(user_error,'~a',[V]),
@ -513,13 +514,12 @@ write_query_answer( Bindings ) :-
G = [_|_], !,
% dump on string first so that we can check whether we actually
% had any output from the solver.
term_to_string( G, String),
format(string(String),Format,G),
( String == `` ->
% we didn't
IG = NG, First = Next
;
% we did
( First = first -> true ; format(user_error,',~n',[]) ),
format(user_error, '~N~s', [String]),
NG = [G|IG]
).

View File

@ -103,28 +103,39 @@ undefined_query(G0, M0, Cut) :-
'$pred_exists'(unknown_predicate_handler(_,_,_,_), user),
'$yap_strip_module'(M0:G0, EM0, GM0),
user:unknown_predicate_handler(GM0,EM0,M1:G1),
!,
expand_goal(M1:G1, MG).
'$undefp_search'(MG, FMG) :-
expand_goal(MG, FMG).
!.
'$undefp_search'(M0:G0, M:G) :-
'$get_undefined_predicates'(G, M0, G0, M), !.
:- abolish('$undefp'/2).
% undef handler
'$undefp'([M0|G0], Action) :-
'$undefp'([M0|G0],_) :-
% make sure we do not loop on undefined predicates
yap_flag( unknown, Action, fail),
'$stop_creeping'(Current),
% yap_flag( debug, Debug, false),
(
'$undefp_search'(M0:G0, NM:NG),
( M0 \== NM -> true ; G0 \== NG ),
NG \= fail
->
yap_flag( unknown, _, Action),
% yap_flag( debug, _, Debug),
setup_and_call_cleanup(
´$undef_set'(MG,Action,Debug,Current),
´$search_def'(M0,G0,MG),
Port,
´$undef_reset'(Port,Mo:GO,MG,Action,Debug,Current)
).
'$undef_set'(MG,Action,Debug,Current) :-
yap_flag( unknown, Action, fail),
yap_flag( debug, Debug, false),
'$stop_creeping'(Current).
'$search_def'(M0,G0,NG:NM) :-
'$undefp_search'(M0:G0, NM:NG),
!,
'$pred_exists'(NG,NM).
´$undef_reset'(exit,_G0,NG:NM,Action,Debug,Current) :-
yap_flag( unknown, _, Action),
yap_flag( debug, _, Debug),
nonvar(NG)
(
Current == true
->
@ -132,13 +143,13 @@ undefined_query(G0, M0, Cut) :-
'$start_creep'([NM|NG], creep)
;
'$execute0'(NG, NM)
)
;
yap_flag( unknown, _, Action),
'$handle_error'(Action,G0,M0)
).
).
´$undef_reset'(_,M0:G0,_NG,Action,Debug,_Current) :-
yap_flag( unknown, _, Action),
yap_flag( debug, _, Debug),
'$handle_error'(Action,G0,M0).
:- '$undefp_handler'('$undefp'(_,_), prolog).
:- '$undefp_handler'('$undefp'(_), prolog).
/** @pred unknown(- _O_,+ _N_)