move error handling to early on so as to get feedback on errors since bootstrap.
This commit is contained in:
parent
d5862139c8
commit
f017f38dee
62
pl/boot.yap
62
pl/boot.yap
@ -171,7 +171,7 @@ list, since backtracking could not "pass through" the cut.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
system_module(Mod, _SysExps, _Decls) :- ! .
|
system_module(_Mod, _SysExps, _Decls) :- ! .
|
||||||
% new_system_module(Mod).
|
% new_system_module(Mod).
|
||||||
|
|
||||||
use_system_module(_init, _SysExps) :- !.
|
use_system_module(_init, _SysExps) :- !.
|
||||||
@ -252,6 +252,55 @@ private(_).
|
|||||||
:- use_system_module( '$_strict_iso', ['$check_iso_strict_clause'/1,
|
:- use_system_module( '$_strict_iso', ['$check_iso_strict_clause'/1,
|
||||||
'$iso_check_goal'/2]).
|
'$iso_check_goal'/2]).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'$early_print_message'(_, absolute_file_path(X, Y)) :- !,
|
||||||
|
format(user_error, X, Y), nl(user_error).
|
||||||
|
'$early_print_message'(_, loading( C, F)) :- !,
|
||||||
|
'$show_consult_level'(LC),
|
||||||
|
format(user_error, '~*|% ~a ~w...~n', [LC,C,F]).
|
||||||
|
'$early_print_message'(_, loaded(F,C,M,T,H)) :- !,
|
||||||
|
'$show_consult_level'(LC),
|
||||||
|
format(user_error, '~*|% ~a:~w ~a ~d bytes in ~d seconds...~n', [LC, M, F ,C, H, T]).
|
||||||
|
'$early_print_message'(Level, Msg) :-
|
||||||
|
source_location(F0, L),
|
||||||
|
!,
|
||||||
|
format(user_error, '~a:~d:0: unprocessed ~a ~w ~n', [F0, L,Level,Msg]).
|
||||||
|
'$early_print_message'(Level, Msg) :-
|
||||||
|
format(user_error, 'unprocessed ~a ~w ~n', [Level,Msg]).
|
||||||
|
|
||||||
|
'$exceptional_cases'(_:print_message(Context, Msg)) :-
|
||||||
|
'$early_print_message'(Context, Msg).
|
||||||
|
|
||||||
|
'$undefp'([M0|G0], Action) :-
|
||||||
|
% make sure we do not loop on undefined predicates
|
||||||
|
'$stop_creeping'(Current),
|
||||||
|
yap_flag( unknown, _, fail),
|
||||||
|
% yap_flag( debug, Debug, false),
|
||||||
|
(
|
||||||
|
'$exceptional_cases'(M0:G0),
|
||||||
|
'$undefp_search'(M0:G0, NM:NG),
|
||||||
|
( M0 \== NM -> true ; G0 \== NG ),
|
||||||
|
NG \= fail,
|
||||||
|
'$pred_exists'(NG,NM)
|
||||||
|
->
|
||||||
|
yap_flag( unknown, _, Action),
|
||||||
|
% yap_flag( debug, _, Debug),
|
||||||
|
(
|
||||||
|
Current == true
|
||||||
|
->
|
||||||
|
% carry on signal processing
|
||||||
|
'$start_creep'([NM|NG], creep)
|
||||||
|
;
|
||||||
|
'$execute0'(NG, NM)
|
||||||
|
)
|
||||||
|
;
|
||||||
|
yap_flag( unknown, _, Action),
|
||||||
|
% yap_flag( debug, _, Debug),
|
||||||
|
'$pred_exists'('$handle_error'(Action,G0,M0), prolog),
|
||||||
|
'$handle_error'(Action,G0,M0)
|
||||||
|
).
|
||||||
|
|
||||||
/*
|
/*
|
||||||
'$undefp'([M0|G0], Default) :-
|
'$undefp'([M0|G0], Default) :-
|
||||||
G0 \= '$imported_predicate'(_,_,_,_),
|
G0 \= '$imported_predicate'(_,_,_,_),
|
||||||
@ -281,11 +330,13 @@ private(_).
|
|||||||
'$prepare_goals'(A,NA,Any).
|
'$prepare_goals'(A,NA,Any).
|
||||||
'$prepare_goals'('$do_error'(Error,Goal),
|
'$prepare_goals'('$do_error'(Error,Goal),
|
||||||
(clause_location(Call, Caller),
|
(clause_location(Call, Caller),
|
||||||
|
source_module(M),
|
||||||
strip_module(M:Goal,M1,NGoal),
|
strip_module(M:Goal,M1,NGoal),
|
||||||
throw(error(Error, [[g|g(M1:NGoal)],[p|Call],[e|Caller],[h|g(Head)]]))
|
throw(error(Error, [[g|g(M1:NGoal)],[p|Call],[e|Caller],[h|g(Head)]]))
|
||||||
),
|
),
|
||||||
true) :-
|
true) :-
|
||||||
!.
|
!,
|
||||||
|
'$head_and_body'(NGoal,Head,_Body).
|
||||||
'$prepare_goals'(X is AOB,
|
'$prepare_goals'(X is AOB,
|
||||||
is(X, IOp, A, B ),
|
is(X, IOp, A, B ),
|
||||||
true) :-
|
true) :-
|
||||||
@ -741,7 +792,7 @@ number of steps.
|
|||||||
recorded('$import','$import'(NM,Mod,NH,H,_,_),RI),
|
recorded('$import','$import'(NM,Mod,NH,H,_,_),RI),
|
||||||
% NM \= Mod,
|
% NM \= Mod,
|
||||||
functor(NH,N,Ar),
|
functor(NH,N,Ar),
|
||||||
'$early_print'(warning,redefine_imported(Mod,NM,M:N/Ar)),
|
'$early_print'(warning,redefine_imported(Mod,NM,Mod:N/Ar)),
|
||||||
erase(RI),
|
erase(RI),
|
||||||
fail.
|
fail.
|
||||||
'$init_pred'(H, Mod, Where ) :-
|
'$init_pred'(H, Mod, Where ) :-
|
||||||
@ -1432,7 +1483,7 @@ bootstrap(F) :-
|
|||||||
current_prolog_flag(strict_iso, true) /* strict_iso on */
|
current_prolog_flag(strict_iso, true) /* strict_iso on */
|
||||||
->
|
->
|
||||||
Expanded = ExpandedI,
|
Expanded = ExpandedI,
|
||||||
'$check_iso_strict_clause'(Expanded0)
|
'$check_iso_strict_clause'(ExpandedUser)
|
||||||
;
|
;
|
||||||
'$expand_array_accesses_in_term'(ExpandedI,Expanded)
|
'$expand_array_accesses_in_term'(ExpandedI,Expanded)
|
||||||
-> true
|
-> true
|
||||||
@ -1651,7 +1702,8 @@ log_event( String, Args ) :-
|
|||||||
yap_flag(toplevel_prompt, P),
|
yap_flag(toplevel_prompt, P),
|
||||||
atomic_concat(LF, PF),
|
atomic_concat(LF, PF),
|
||||||
prompt1(PF),
|
prompt1(PF),
|
||||||
prompt(_,' ').
|
prompt(_,' '),
|
||||||
|
'$ensure_prompting'.
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,16 +90,6 @@ system_error(Type,Goal,Culprit) :-
|
|||||||
[p|Call],
|
[p|Call],
|
||||||
[e|Caller]])).
|
[e|Caller]])).
|
||||||
|
|
||||||
|
|
||||||
'$do_error'(Type,Goal) :-
|
|
||||||
% format('~w~n', [Type]),
|
|
||||||
ancestor_location(Call, Caller),
|
|
||||||
throw(error(Type, [
|
|
||||||
[g|g(Goal)],
|
|
||||||
[p|Call],
|
|
||||||
[e|Caller]])).
|
|
||||||
|
|
||||||
|
|
||||||
'$do_pi_error'(type_error(callable,Name/0),Message) :- !,
|
'$do_pi_error'(type_error(callable,Name/0),Message) :- !,
|
||||||
'$do_error'(type_error(callable,Name),Message).
|
'$do_error'(type_error(callable,Name),Message).
|
||||||
'$do_pi_error'(Error,Message) :- !,
|
'$do_pi_error'(Error,Message) :- !,
|
||||||
|
24
pl/init.yap
24
pl/init.yap
@ -110,30 +110,6 @@ otherwise.
|
|||||||
|
|
||||||
:- '$all_current_modules'(M), yap_flag(M:unknown, error) ; true.
|
:- '$all_current_modules'(M), yap_flag(M:unknown, error) ; true.
|
||||||
|
|
||||||
'$early_print_message'(_, absolute_file_path(X, Y)) :- !,
|
|
||||||
format(user_error, X, Y), nl(user_error).
|
|
||||||
'$early_print_message'(_, loading( C, F)) :- !,
|
|
||||||
'$show_consult_level'(LC),
|
|
||||||
format(user_error, '~*|% ~a ~w...~n', [LC,C,F]).
|
|
||||||
'$early_print_message'(_, loaded(F,C,M,T,H)) :- !,
|
|
||||||
'$show_consult_level'(LC),
|
|
||||||
format(user_error, '~*|% ~a:~w ~a ~d bytes in ~d seconds...~n', [LC, M, F ,C, H, T]).
|
|
||||||
'$early_print_message'(Level, Msg) :-
|
|
||||||
source_location(F0, L),
|
|
||||||
!,
|
|
||||||
format(user_error, '~a:~d:0: unprocessed ~a ~w ~n', [F0, L,Level,Msg]).
|
|
||||||
'$early_print_message'(Level, Msg) :-
|
|
||||||
format(user_error, 'unprocessed ~a ~w ~n', [Level,Msg]).
|
|
||||||
|
|
||||||
|
|
||||||
print_message(Severity, Term) :-
|
|
||||||
'$pred_exists'(execute_print_message(_,_), '$messages'),
|
|
||||||
'$messages':execute_print_message(Severity, Term),
|
|
||||||
!.
|
|
||||||
print_message(Level, Msg) :-
|
|
||||||
source_location(F0, L),
|
|
||||||
'$early_print_message'(Level, Msg).
|
|
||||||
|
|
||||||
|
|
||||||
:- bootstrap('arith.yap').
|
:- bootstrap('arith.yap').
|
||||||
|
|
||||||
|
@ -857,51 +857,6 @@ prolog:print_message_lines(S, Prefix0, Lines) :-
|
|||||||
print_lines(S, [Prefix], Key, [Prefix|Msg], [])
|
print_lines(S, [Prefix], Key, [Prefix|Msg], [])
|
||||||
).
|
).
|
||||||
|
|
||||||
execute_print_message(_, _Msg) :-
|
|
||||||
% first step at hook processi --ng
|
|
||||||
'$nb_getval'('$if_skip_mode',skip,fail),
|
|
||||||
!.
|
|
||||||
execute_print_message(silent, _Msg) :-
|
|
||||||
!.
|
|
||||||
execute_print_message(informational, _Msg) :-
|
|
||||||
current_prolog_flag(verbose, silent),
|
|
||||||
!.
|
|
||||||
execute_print_message(banner, _Msg) :-
|
|
||||||
current_prolog_flag(verbose, silent),
|
|
||||||
!.
|
|
||||||
execute_print_message(Severity, Msg) :-
|
|
||||||
(
|
|
||||||
var(Severity)
|
|
||||||
->
|
|
||||||
!,
|
|
||||||
format(user_error, 'malformed message ~q: message level is unbound~n', [Msg])
|
|
||||||
;
|
|
||||||
var(Msg)
|
|
||||||
->
|
|
||||||
!,
|
|
||||||
format(user_error, 'uninstantiated message~n', [])
|
|
||||||
;
|
|
||||||
user:portray_message(Severity, Msg)
|
|
||||||
),
|
|
||||||
!.
|
|
||||||
execute_print_message(force(_Severity), Msg) :- !,
|
|
||||||
print(user_error,Msg).
|
|
||||||
% This predicate has more hooks than a pirate ship!
|
|
||||||
execute_print_message(Severity, Term) :-
|
|
||||||
translate_message( Term, Severity, Lines0, [ end(Id)]),
|
|
||||||
Lines = [begin(Severity, Id)| Lines0],
|
|
||||||
(
|
|
||||||
user:message_hook(Term, Severity, Lines)
|
|
||||||
->
|
|
||||||
true
|
|
||||||
;
|
|
||||||
prefix( Severity, Prefix ),
|
|
||||||
prolog:print_message_lines(user_error, Prefix, Lines)
|
|
||||||
),
|
|
||||||
!.
|
|
||||||
execute_print_message(Severity, _Term) :-
|
|
||||||
format('No handler for ~a message ~q,~n',[Severity, _Term]).
|
|
||||||
|
|
||||||
/** @pred prolog:print_message(+ Severity, +Term)
|
/** @pred prolog:print_message(+ Severity, +Term)
|
||||||
|
|
||||||
The predicate print_message/2 is used to print messages, notably from
|
The predicate print_message/2 is used to print messages, notably from
|
||||||
@ -930,6 +885,52 @@ stub to ensure everything os ok
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
prolog:print_message(_, _Msg) :-
|
||||||
|
% first step at hook processi --ng
|
||||||
|
'$nb_getval'('$if_skip_mode',skip,fail),
|
||||||
|
!.
|
||||||
|
prolog:print_message(silent, _Msg) :-
|
||||||
|
!.
|
||||||
|
prolog:print_message(informational, _Msg) :-
|
||||||
|
current_prolog_flag(verbose, silent),
|
||||||
|
!.
|
||||||
|
prolog:print_message(banner, _Msg) :-
|
||||||
|
current_prolog_flag(verbose, silent),
|
||||||
|
!.
|
||||||
|
prolog:print_message(Severity, Msg) :-
|
||||||
|
(
|
||||||
|
var(Severity)
|
||||||
|
->
|
||||||
|
!,
|
||||||
|
format(user_error, 'malformed message ~q: message level is unbound~n', [Msg])
|
||||||
|
;
|
||||||
|
var(Msg)
|
||||||
|
->
|
||||||
|
!,
|
||||||
|
format(user_error, 'uninstantiated message~n', [])
|
||||||
|
;
|
||||||
|
user:portray_message(Severity, Msg)
|
||||||
|
),
|
||||||
|
!.
|
||||||
|
prolog:print_message(force(_Severity), Msg) :- !,
|
||||||
|
print(user_error,Msg).
|
||||||
|
% This predicate has more hooks than a pirate ship!
|
||||||
|
prolog:print_message(Severity, Term) :-
|
||||||
|
translate_message( Term, Severity, Lines0, [ end(Id)]),
|
||||||
|
Lines = [begin(Severity, Id)| Lines0],
|
||||||
|
(
|
||||||
|
user:message_hook(Term, Severity, Lines)
|
||||||
|
->
|
||||||
|
true
|
||||||
|
;
|
||||||
|
prefix( Severity, Prefix ),
|
||||||
|
prolog:print_message_lines(user_error, Prefix, Lines)
|
||||||
|
),
|
||||||
|
!.
|
||||||
|
prolog:print_message(Severity, _Term) :-
|
||||||
|
format('No handler for ~a message ~q,~n',[Severity, _Term]).
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@}
|
@}
|
||||||
*/
|
*/
|
||||||
|
@ -104,32 +104,6 @@ Z * @pred '$undefp_expand'(+ M0:G0, -MG)
|
|||||||
'$undefp_search'(MG, FMG) :-
|
'$undefp_search'(MG, FMG) :-
|
||||||
expand_goal(MG, FMG).
|
expand_goal(MG, FMG).
|
||||||
|
|
||||||
'$undefp'([M0|G0], Action) :-
|
|
||||||
% make sure we do not loop on undefined predicates
|
|
||||||
'$stop_creeping'(Current),
|
|
||||||
yap_flag( unknown, _, fail),
|
|
||||||
% yap_flag( debug, Debug, false),
|
|
||||||
(
|
|
||||||
'$undefp_search'(M0:G0, NM:NG),
|
|
||||||
( M0 \== NM -> true ; G0 \== NG ),
|
|
||||||
NG \= fail,
|
|
||||||
'$pred_exists'(NG,NM)
|
|
||||||
->
|
|
||||||
yap_flag( unknown, _, Action),
|
|
||||||
% yap_flag( debug, _, Debug),
|
|
||||||
(
|
|
||||||
Current == true
|
|
||||||
->
|
|
||||||
% carry on signal processing
|
|
||||||
'$start_creep'([NM|NG], creep)
|
|
||||||
;
|
|
||||||
'$execute0'(NG, NM)
|
|
||||||
)
|
|
||||||
;
|
|
||||||
yap_flag( unknown, _, Action),
|
|
||||||
% yap_flag( debug, _, Debug),
|
|
||||||
'$handle_error'(Action,G0,M0)
|
|
||||||
).
|
|
||||||
|
|
||||||
/** @pred unknown(- _O_,+ _N_)
|
/** @pred unknown(- _O_,+ _N_)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user