boot
This commit is contained in:
parent
f7ed109d1c
commit
c1dc6b7fb2
@ -2202,7 +2202,15 @@ X_API Term YAP_ReadFromStream(int sno) {
|
||||
Term o;
|
||||
|
||||
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);
|
||||
}
|
||||
RECOVER_MACHINE_REGS();
|
||||
return o;
|
||||
}
|
||||
|
@ -363,6 +363,7 @@ bool Yap_PrintWarning(Term twarning) {
|
||||
LOCAL_within_print_message = false;
|
||||
LOCAL_PrologMode &= ~InErrorMode;
|
||||
return rc;
|
||||
|
||||
}
|
||||
|
||||
bool Yap_HandleError__(const char *file, const char *function, int lineno,
|
||||
@ -415,7 +416,7 @@ bool Yap_HandleError__(const char *file, const char *function, int lineno,
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
|
||||
|
||||
if (LOCAL_PrologMode == UserMode)
|
||||
Yap_ThrowError__(file, function, lineno, err, LOCAL_RawTerm, serr);
|
||||
else
|
||||
|
9
C/exec.c
9
C/exec.c
@ -1712,6 +1712,11 @@ bool Yap_execute_pred(PredEntry *ppe, CELL *pt, bool pass_ex USES_REGS) {
|
||||
// should we catch the exception or pass it through?
|
||||
// We'll pass it through
|
||||
if (pass_ex && Yap_HasException()) {
|
||||
if ((LOCAL_PrologMode & BootMode) || !CurrentModule ) {
|
||||
Yap_ResetException(LOCAL_ActiveError);
|
||||
return false;
|
||||
}
|
||||
|
||||
Yap_RaiseException();
|
||||
return false;
|
||||
}
|
||||
@ -1734,6 +1739,10 @@ bool Yap_execute_pred(PredEntry *ppe, CELL *pt, bool pass_ex USES_REGS) {
|
||||
// should we catch the exception or pass it through?
|
||||
// We'll pass it through
|
||||
if (pass_ex) {
|
||||
if ((LOCAL_PrologMode & BootMode) || !CurrentModule ) {
|
||||
Yap_ResetException(LOCAL_ActiveError);
|
||||
return false;
|
||||
}
|
||||
Yap_RaiseException();
|
||||
}
|
||||
return false;
|
||||
|
@ -166,6 +166,7 @@ static bool load_file(const char *b_file USES_REGS) {
|
||||
|
||||
/* consult in C */
|
||||
int lvl = push_text_stack();
|
||||
|
||||
char *full;
|
||||
/* the consult mode does not matter here, really */
|
||||
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_StartSlots();
|
||||
Term vs = MkVarTerm(), pos = MkVarTerm();
|
||||
|
||||
t = YAP_ReadClauseFromStream(c_stream, vs, pos);
|
||||
// Yap_GetNèwSlot(t);
|
||||
if (t == TermEof || t == TermNil) {
|
||||
|
@ -117,9 +117,9 @@ Just fail
|
||||
/**<
|
||||
|
||||
If `true` allow printing of informational messages when
|
||||
searching for file names. If `false` disable printing these messages. It
|
||||
is `false` by default except if YAP is booted with the `-L`
|
||||
flag.
|
||||
searching for file names. If `false` disable printing these
|
||||
messages. It is `false` by default except if YAP is booted with
|
||||
the `-L` flag.
|
||||
*/
|
||||
YAP_FLAG(VERBOSE_FILE_SEARCH_FLAG, "verbose_file_search", true, booleanFlag,
|
||||
"false", NULL),
|
||||
|
11
pl/absf.yap
11
pl/absf.yap
@ -30,14 +30,13 @@
|
||||
add_to_path/1,
|
||||
add_to_path/2,
|
||||
path/1,
|
||||
remove_from_path/1]).
|
||||
remove_from_path/1], []).
|
||||
|
||||
|
||||
absolute_file_name__(File,LOpts,TrueFileName) :-
|
||||
% must_be_of_type( atom, File ),
|
||||
% look for solutions
|
||||
gated_call(
|
||||
|
||||
'$enter_absf'( File, LOpts, Opts, HasSol, OldF, PreviousFileErrors, PreviousVerbose, Expand, Verbose, TakeFirst, FileErrors ),
|
||||
'$find_in_path'(File, Opts,TrueFileName, HasSol, TakeFirst),
|
||||
Port,
|
||||
@ -91,12 +90,12 @@ absolute_file_name__(File,LOpts,TrueFileName) :-
|
||||
'$absf_port'(fail, File, TrueFileName, HasSol, OldF, PreviousFileErrors, PreviousVerbose, Expand, Verbose, TakeFirst, FileErrors ).
|
||||
|
||||
|
||||
|
||||
core_file_name(Name, Opts) -->
|
||||
:- start_low_level_trace.
|
||||
prolog:core_file_name(Name, Opts) -->
|
||||
'$file_name'(Name, Opts, E),
|
||||
'$suffix'(E, Opts),
|
||||
'$glob'(Opts).
|
||||
|
||||
:- stop_low_level_trace.
|
||||
%
|
||||
% 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( expand, Opts, Expand ),
|
||||
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]),
|
||||
'$variable_expansion'(CorePath, Opts,ExpandedPath),
|
||||
absf_trace(' after environment variable expansion: ~s', [ExpandedPath]),
|
||||
|
72
pl/boot.yap
72
pl/boot.yap
@ -37,23 +37,17 @@
|
||||
*/
|
||||
system_module(Mod, SysExps) :-
|
||||
system_module(Mod, SysExps, []).
|
||||
|
||||
|
||||
use_system_module(_Module, _SysExps).
|
||||
|
||||
system_module(_Mod, SysExps, _Decls) :-
|
||||
% '$new_system_predicates'(SysExps),
|
||||
'$new_system_predicates'(SysExps),
|
||||
!,
|
||||
fail.
|
||||
system_module(_Mod, _SysExps, _Decls) :-
|
||||
(
|
||||
stream_property(loop_stream,file_name(File))
|
||||
->
|
||||
recordz(system_file, File, _ )
|
||||
;
|
||||
recordz(system_file, loop_stream, _ )
|
||||
).
|
||||
|
||||
private(_).
|
||||
system_module(_Mod, _SysExps, _Decls) :-
|
||||
stream_property(loop_stream,[file_name(File)]),
|
||||
!,
|
||||
recordz(system_file, File, _ ).
|
||||
system_module(_Mod, _SysExps, _Decls) :-
|
||||
recordz(system_file, loop_stream, _ ).
|
||||
|
||||
'$new_system_predicates'([]).
|
||||
'$new_system_predicates'([N/Ar|_Ps]) :-
|
||||
@ -61,6 +55,10 @@ private(_).
|
||||
'$new_system_predicates'([_P|Ps]) :-
|
||||
'$new_system_predicates'(Ps).
|
||||
|
||||
use_system_module(_Module, _SysExps).
|
||||
|
||||
private(_).
|
||||
|
||||
%
|
||||
% boootstrap predicates.
|
||||
%
|
||||
@ -82,22 +80,38 @@ private(_).
|
||||
|
||||
% be careful here not to generate an undefined exception..
|
||||
|
||||
print_message(L,E) :-
|
||||
(L = informational
|
||||
->
|
||||
'$query_exception'(prologPredFile, Desc, File),
|
||||
'$query_exception'(prologPredLine, Desc, FilePos),
|
||||
format(user_error,'~a:~d: error:', [File,FilePos])
|
||||
;
|
||||
|
||||
%throw(error(error, print_message(['while calling goal = ~w'-E,nl]))).
|
||||
print_message(informational,_) :-
|
||||
yap_flag(verbose, silent),
|
||||
!.
|
||||
print_message(informational,E) :-
|
||||
format('informational message ~q.~n',[E]),
|
||||
!.
|
||||
%%
|
||||
% boot:print_message( Type, Error )
|
||||
%
|
||||
print_message(Type,error(_,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'(prologPredLine, Desc, FilePos),
|
||||
format(user_error,'~a:~d: error:', [File,FilePos]),
|
||||
'$print_exception'(Desc),
|
||||
format( user_error, '~w from bootstrap: got ~w~n',[L,E])
|
||||
).
|
||||
format(user_error,'~a:~d: ~a: ~q~n', [File,FilePos,Type,Error]).
|
||||
print_boot_message(Type,Error,Desc) :-
|
||||
'$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) :-
|
||||
functor(G,N,A),
|
||||
@ -141,7 +155,7 @@ print_message(L,E) :-
|
||||
goal_expansion/3,
|
||||
otherwise/0,
|
||||
term_expansion/2,
|
||||
version/2,
|
||||
version/2],
|
||||
[
|
||||
'$do_log_upd_clause'/6,
|
||||
'$do_log_upd_clause0'/6,
|
||||
@ -249,7 +263,7 @@ initialize_prolog :-
|
||||
:- c_compile( 'preds.yap' ).
|
||||
:- c_compile( 'modules.yap' ).
|
||||
:- c_compile( 'grammar.yap' ).
|
||||
%:- c_compile( 'protect.yap' ).
|
||||
:- c_compile( 'protect.yap' ).
|
||||
|
||||
:- ['absf.yap'].
|
||||
|
||||
|
11
pl/top.yap
11
pl/top.yap
@ -177,11 +177,11 @@ live :-
|
||||
catch( '$expand_term0'(T,Con,O), _,( '$disable_debugging', fail) ),
|
||||
!.
|
||||
|
||||
'$expand_term0'(T,consult,O) :-
|
||||
expand_term( T, O).
|
||||
'$expand_term0'(T,reconsult,O) :-
|
||||
expand_term( T, O).
|
||||
'$expand_term0'(T,top,O) :-
|
||||
'$expand_term0'(T,consult,O) :-
|
||||
expand_term( T, O).
|
||||
'$expand_term0'(T,reconsult,O) :-
|
||||
expand_term( T, O).
|
||||
'$expand_term0'(T,top,O) :-
|
||||
expand_term( T, T1),
|
||||
!,
|
||||
'$expand_term1'(T1,O).
|
||||
@ -243,6 +243,7 @@ live :-
|
||||
functor(NH,N,Ar),
|
||||
print_message(warning,redefine_imported(Mod,NM,Mod:N/Ar)),
|
||||
erase(RI),
|
||||
clause(Mod:H,_,R), erase(R),
|
||||
fail.
|
||||
'$init_pred'(H, Mod, Where ) :-
|
||||
'$init_as_dynamic'(Where),
|
||||
|
Reference in New Issue
Block a user