Merge branch 'master' of ssh://ssh.dcc.fc.up.pt:31064/home/vsc/yap

This commit is contained in:
Vitor Santos Costa 2019-01-31 12:08:28 +00:00
commit f6b16ca505
8 changed files with 71 additions and 38 deletions

View File

@ -2202,7 +2202,15 @@ X_API Term YAP_ReadFromStream(int sno) {
Term o; Term o;
BACKUP_MACHINE_REGS(); BACKUP_MACHINE_REGS();
sigjmp_buf signew;
if (sigsetjmp(signew, 0)) {
Yap_syntax_error(LOCAL_toktide, sno, "ReadFromStream");
RECOVER_MACHINE_REGS();
return 0;
} else {
o = Yap_read_term(sno, TermNil, false); o = Yap_read_term(sno, TermNil, false);
}
RECOVER_MACHINE_REGS(); RECOVER_MACHINE_REGS();
return o; return o;
} }

View File

@ -363,6 +363,7 @@ bool Yap_PrintWarning(Term twarning) {
LOCAL_within_print_message = false; LOCAL_within_print_message = false;
LOCAL_PrologMode &= ~InErrorMode; LOCAL_PrologMode &= ~InErrorMode;
return rc; return rc;
} }
bool Yap_HandleError__(const char *file, const char *function, int lineno, bool Yap_HandleError__(const char *file, const char *function, int lineno,

View File

@ -1734,6 +1734,11 @@ bool Yap_execute_pred(PredEntry *ppe, CELL *pt, bool pass_ex USES_REGS) {
// should we catch the exception or pass it through? // should we catch the exception or pass it through?
// We'll pass it through // We'll pass it through
if (pass_ex && Yap_HasException()) { if (pass_ex && Yap_HasException()) {
if ((LOCAL_PrologMode & BootMode) || !CurrentModule ) {
Yap_ResetException(LOCAL_ActiveError);
return false;
}
Yap_RaiseException(); Yap_RaiseException();
return false; return false;
} }
@ -1756,6 +1761,10 @@ bool Yap_execute_pred(PredEntry *ppe, CELL *pt, bool pass_ex USES_REGS) {
// should we catch the exception or pass it through? // should we catch the exception or pass it through?
// We'll pass it through // We'll pass it through
if (pass_ex) { if (pass_ex) {
if ((LOCAL_PrologMode & BootMode) || !CurrentModule ) {
Yap_ResetException(LOCAL_ActiveError);
return false;
}
Yap_RaiseException(); Yap_RaiseException();
} }
return false; return false;

View File

@ -166,6 +166,7 @@ static bool load_file(const char *b_file USES_REGS) {
/* consult in C */ /* consult in C */
int lvl = push_text_stack(); int lvl = push_text_stack();
char *full; char *full;
/* the consult mode does not matter here, really */ /* the consult mode does not matter here, really */
if ((osno = Yap_CheckAlias(AtomLoopStream)) < 0) { if ((osno = Yap_CheckAlias(AtomLoopStream)) < 0) {
@ -191,6 +192,7 @@ static bool load_file(const char *b_file USES_REGS) {
YAP_Reset(YAP_FULL_RESET, false); YAP_Reset(YAP_FULL_RESET, false);
Yap_StartSlots(); Yap_StartSlots();
Term vs = MkVarTerm(), pos = MkVarTerm(); Term vs = MkVarTerm(), pos = MkVarTerm();
t = YAP_ReadClauseFromStream(c_stream, vs, pos); t = YAP_ReadClauseFromStream(c_stream, vs, pos);
// Yap_GetNèwSlot(t); // Yap_GetNèwSlot(t);
if (t == TermEof || t == TermNil) { if (t == TermEof || t == TermNil) {

View File

@ -117,9 +117,9 @@ Just fail
/**< /**<
If `true` allow printing of informational messages when If `true` allow printing of informational messages when
searching for file names. If `false` disable printing these messages. It searching for file names. If `false` disable printing these
is `false` by default except if YAP is booted with the `-L` messages. It is `false` by default except if YAP is booted with
flag. the `-L` flag.
*/ */
YAP_FLAG(VERBOSE_FILE_SEARCH_FLAG, "verbose_file_search", true, booleanFlag, YAP_FLAG(VERBOSE_FILE_SEARCH_FLAG, "verbose_file_search", true, booleanFlag,
"false", NULL), "false", NULL),

View File

@ -30,14 +30,13 @@
add_to_path/1, add_to_path/1,
add_to_path/2, add_to_path/2,
path/1, path/1,
remove_from_path/1]). remove_from_path/1], []).
absolute_file_name__(File,LOpts,TrueFileName) :- absolute_file_name__(File,LOpts,TrueFileName) :-
% must_be_of_type( atom, File ), % must_be_of_type( atom, File ),
% look for solutions % look for solutions
gated_call( gated_call(
'$enter_absf'( File, LOpts, Opts, HasSol, OldF, PreviousFileErrors, PreviousVerbose, Expand, Verbose, TakeFirst, FileErrors ), '$enter_absf'( File, LOpts, Opts, HasSol, OldF, PreviousFileErrors, PreviousVerbose, Expand, Verbose, TakeFirst, FileErrors ),
'$find_in_path'(File, Opts,TrueFileName, HasSol, TakeFirst), '$find_in_path'(File, Opts,TrueFileName, HasSol, TakeFirst),
Port, Port,
@ -91,12 +90,12 @@ absolute_file_name__(File,LOpts,TrueFileName) :-
'$absf_port'(fail, File, TrueFileName, HasSol, OldF, PreviousFileErrors, PreviousVerbose, Expand, Verbose, TakeFirst, FileErrors ). '$absf_port'(fail, File, TrueFileName, HasSol, OldF, PreviousFileErrors, PreviousVerbose, Expand, Verbose, TakeFirst, FileErrors ).
:- start_low_level_trace.
core_file_name(Name, Opts) --> prolog:core_file_name(Name, Opts) -->
'$file_name'(Name, Opts, E), '$file_name'(Name, Opts, E),
'$suffix'(E, Opts), '$suffix'(E, Opts),
'$glob'(Opts). '$glob'(Opts).
:- stop_low_level_trace.
% %
% handle library(lists) or foreign(jpl) % handle library(lists) or foreign(jpl)
% %
@ -416,7 +415,7 @@ remove_from_path(New) :- '$check_path'(New,Path),
get_abs_file_parameter( access, Opts, Access ), get_abs_file_parameter( access, Opts, Access ),
get_abs_file_parameter( expand, Opts, Expand ), get_abs_file_parameter( expand, Opts, Expand ),
absf_trace('start with ~w', [Name]), absf_trace('start with ~w', [Name]),
core_file_name(Name, Opts, CorePath, []), prolog:core_file_name(Name, Opts, CorePath, []),
absf_trace(' after name/library unfolding: ~w', [Name]), absf_trace(' after name/library unfolding: ~w', [Name]),
'$variable_expansion'(CorePath, Opts,ExpandedPath), '$variable_expansion'(CorePath, Opts,ExpandedPath),
absf_trace(' after environment variable expansion: ~s', [ExpandedPath]), absf_trace(' after environment variable expansion: ~s', [ExpandedPath]),

View File

@ -38,22 +38,15 @@
system_module(Mod, SysExps) :- system_module(Mod, SysExps) :-
system_module(Mod, SysExps, []). system_module(Mod, SysExps, []).
use_system_module(_Module, _SysExps).
system_module(_Mod, _SysExps, _Decls) :- system_module(_Mod, _SysExps, _Decls) :-
% '$new_system_predicates'(SysExps), % '$new_system_predicates'(SysExps),
fail. fail.
system_module(_Mod, _SysExps, _Decls) :- system_module(_Mod, _SysExps, _Decls) :-
( stream_property(loop_stream,[file_name(File)]),
stream_property(loop_stream,file_name(File)) !,
-> recordz(system_file, File, _ ).
recordz(system_file, File, _ ) system_module(_Mod, _SysExps, _Decls) :-
; recordz(system_file, loop_stream, _ ).
recordz(system_file, loop_stream, _ )
).
private(_).
'$new_system_predicates'([]). '$new_system_predicates'([]).
'$new_system_predicates'([N/Ar|_Ps]) :- '$new_system_predicates'([N/Ar|_Ps]) :-
@ -61,6 +54,10 @@ private(_).
'$new_system_predicates'([_P|Ps]) :- '$new_system_predicates'([_P|Ps]) :-
'$new_system_predicates'(Ps). '$new_system_predicates'(Ps).
use_system_module(_Module, _SysExps).
private(_).
% %
% boootstrap predicates. % boootstrap predicates.
% %
@ -82,22 +79,38 @@ private(_).
% be careful here not to generate an undefined exception.. % be careful here not to generate an undefined exception..
print_message(L,E) :- print_message(informational,_) :-
(L = informational yap_flag(verbose, silent),
-> !.
'$query_exception'(prologPredFile, Desc, File), print_message(informational,E) :-
'$query_exception'(prologPredLine, Desc, FilePos), format('informational message ~q.~n',[E]),
format(user_error,'~a:~d: error:', [File,FilePos]) !.
; %%
% boot:print_message( Type, Error )
%throw(error(error, print_message(['while calling goal = ~w'-E,nl]))). %
print_message(Type,error(_,exception(Desc))) :-
'$get_exception'(Desc), '$get_exception'(Desc),
print_boot_message(Type,Error,Desc),
'$print_exception'(Desc),
!.
print_message(Type,Error) :-
format( user_error, '~w while bootstraping: event is ~q~n',[Type,Error]).
print_boot_message(Type,Error,Desc) :-
'$query_exception'(parserFile, Desc, File),
'$query_exception'(parserLine, Desc, FilePos),
!,
format(user_error,'~a:~d: ~a: ~q~n', [File,FilePos,Type,Error]).
print_boot_message(Type,Error,Desc) :-
'$query_exception'(prologPredFile, Desc, File), '$query_exception'(prologPredFile, Desc, File),
'$query_exception'(prologPredLine, Desc, FilePos), '$query_exception'(prologPredLine, Desc, FilePos),
format(user_error,'~a:~d: error:', [File,FilePos]), format(user_error,'~a:~d: ~a: ~q~n', [File,FilePos,Type,Error]).
'$print_exception'(Desc), print_boot_message(Type,Error,Desc) :-
format( user_error, '~w from bootstrap: got ~w~n',[L,E]) '$query_exception'(errorFile, Desc, File),
). '$query_exception'(errorLine, Desc, FilePos),
format(user_error,'~a:~d: ~a: ~q~n', [File,FilePos,Type,Error]).
'$undefp0'([M|G], _Action) :- '$undefp0'([M|G], _Action) :-
functor(G,N,A), functor(G,N,A),
@ -141,7 +154,7 @@ print_message(L,E) :-
goal_expansion/3, goal_expansion/3,
otherwise/0, otherwise/0,
term_expansion/2, term_expansion/2,
version/2, version/2],
[ [
'$do_log_upd_clause'/6, '$do_log_upd_clause'/6,
'$do_log_upd_clause0'/6, '$do_log_upd_clause0'/6,
@ -249,7 +262,7 @@ initialize_prolog :-
:- c_compile( 'preds.yap' ). :- c_compile( 'preds.yap' ).
:- c_compile( 'modules.yap' ). :- c_compile( 'modules.yap' ).
:- c_compile( 'grammar.yap' ). :- c_compile( 'grammar.yap' ).
%:- c_compile( 'protect.yap' ). :- c_compile( 'protect.yap' ).
:- ['absf.yap']. :- ['absf.yap'].

View File

@ -243,6 +243,7 @@ live :-
functor(NH,N,Ar), functor(NH,N,Ar),
print_message(warning,redefine_imported(Mod,NM,Mod:N/Ar)), print_message(warning,redefine_imported(Mod,NM,Mod:N/Ar)),
erase(RI), erase(RI),
clause(Mod:H,_,R), erase(R),
fail. fail.
'$init_pred'(H, Mod, Where ) :- '$init_pred'(H, Mod, Where ) :-
'$init_as_dynamic'(Where), '$init_as_dynamic'(Where),