fix catch and throw: make sure we have an environment.

use $notrace consistently: note that it only matters if ran from the
debugger, otherwise it is just a meta-call.
This commit is contained in:
Vítor Santos Costa 2008-09-24 00:13:02 +01:00
parent 6747cb21de
commit 139f591458
5 changed files with 19 additions and 31 deletions

View File

@ -849,7 +849,7 @@ not(G) :- \+ '$execute'(G).
'$call'(G, CP, G0, CurMod) :- '$call'(G, CP, G0, CurMod) :-
( '$is_expand_goal_or_meta_predicate'(G,CurMod) -> ( '$is_expand_goal_or_meta_predicate'(G,CurMod) ->
( (
'$oncenotrace'(user:goal_expansion(G, CurMod, NG)) -> '$notrace'(user:goal_expansion(G, CurMod, NG)) ->
'$call'(NG, CP, G0,CurMod) '$call'(NG, CP, G0,CurMod)
; ;
% repeat other code. % repeat other code.
@ -1076,7 +1076,7 @@ access_file(F,Mode) :-
expand_term(Term,Expanded) :- expand_term(Term,Expanded) :-
( \+ '$undefined'(term_expansion(_,_), user), ( \+ '$undefined'(term_expansion(_,_), user),
once(user:term_expansion(Term,Expanded)) '$notrace'(user:term_expansion(Term,Expanded))
; ;
'$expand_term_grammar'(Term,Expanded) '$expand_term_grammar'(Term,Expanded)
), ),
@ -1116,7 +1116,11 @@ expand_term(Term,Expanded) :-
% where was the previous catch % where was the previous catch
catch(G, C, A) :- catch(G, C, A) :-
'$catch'(C,A,_), '$catch'(C,A,_),
'$execute'(G). '$execute'(G),
'$true'.
% makes sure we have an environment.
'$true'.
% system_catch is like catch, but it avoids the overhead of a full % system_catch is like catch, but it avoids the overhead of a full
@ -1127,7 +1131,8 @@ catch(G, C, A) :-
'$system_catch'(G, M, C, A) :- '$system_catch'(G, M, C, A) :-
% check current trail % check current trail
'$catch'(C,A,_), '$catch'(C,A,_),
'$execute_nonstop'(G, M). '$execute_nonstop'(G, M),
'$true'.
% %
% throw has to be *exactly* after system catch! % throw has to be *exactly* after system catch!
@ -1164,8 +1169,11 @@ throw(Ball) :-
'$exit_system_mode' :- '$exit_system_mode' :-
nb_setval('$system_mode',off), nb_setval('$system_mode',off),
( nb_getval('$trace',on) -> '$creep' ; true). ( nb_getval('$trace',on) -> '$creep' ; true).
'$donotrace'(G) :- %
% just leave this around to show the debugger.
%
'$notrace'(G) :-
'$execute'(G). '$execute'(G).
'$oncenotrace'(G) :- '$oncenotrace'(G) :-

View File

@ -778,7 +778,7 @@ absolute_file_name(File,Opts,TrueFileName) :-
'$extend_path_directory'(Name, D, File, Opts, NewFile, Call) :- '$extend_path_directory'(Name, D, File, Opts, NewFile, Call) :-
user:file_search_path(Name, Dir), '$notrace'(user:file_search_path(Name, Dir)),
'$extend_pathd'(Dir, D, File, Opts, NewFile, Call). '$extend_pathd'(Dir, D, File, Opts, NewFile, Call).
'$extend_pathd'(Dir, A, File, Opts, NewFile, Call) :- '$extend_pathd'(Dir, A, File, Opts, NewFile, Call) :-

View File

@ -240,16 +240,16 @@ print_message(Severity, Msg) :-
print_message(Severity, Term) :- print_message(Severity, Term) :-
( (
( (
'$notrace'(user:generate_message_hook(Term, [], Lines)) -> '$oncenotrace'(user:generate_message_hook(Term, [], Lines)) ->
true true
; ;
'$notrace'(prolog:message(Term, Lines, [])) -> '$oncenotrace'(prolog:message(Term, Lines, [])) ->
true true
; ;
'$message':generate_message(Term, Lines, []) '$message':generate_message(Term, Lines, [])
) )
-> ( nonvar(Term), -> ( nonvar(Term),
'$notrace'(user:message_hook(Term, Severity, Lines)) '$oncenotrace'(user:message_hook(Term, Severity, Lines))
-> ! -> !
; !, '$print_system_message'(Term, Severity, Lines) ; !, '$print_system_message'(Term, Severity, Lines)
) )

View File

@ -964,26 +964,6 @@ current_key(A,K) :-
% do nothing for now. % do nothing for now.
'$noprofile'(_, _). '$noprofile'(_, _).
'$notrace'(G) :-
var(G), !,
'$do_error'(instantiation_error,G).
'$notrace'(G) :- number(G), !,
'$do_error'(type_error(callable,G),G).
'$notrace'(G) :- db_reference(G), !,
'$do_error'(type_error(callable,G),G).
'$notrace'(M:G) :-
\+ atom(M),
'$do_error'(type_error(atom,Na), Msg).
'$notrace'(M:G) :- !,
'$notrace'(G, M).
'$notrace'(G) :- !,
'$notrace'(G, prolog).
'$notrace'(G, Mod) :-
\+ '$undefined'(G, Mod),
'$donotrace'(Mod:G).
'$ifunctor'(Pred,Na,Ar) :- '$ifunctor'(Pred,Na,Ar) :-
(Ar > 0 -> (Ar > 0 ->
functor(Pred, Na, Ar) functor(Pred, Na, Ar)

View File

@ -99,7 +99,7 @@
'$execute_nonstop'('$call'(G, CP, G0, M),M0). '$execute_nonstop'('$call'(G, CP, G0, M),M0).
% donotrace: means do not trace! So, % donotrace: means do not trace! So,
% ignore and then put creep back for the continuation. % ignore and then put creep back for the continuation.
'$start_creep'([M0|'$donotrace'(G)]) :- '$start_creep'([M0|'$notrace'(G)]) :-
!, !,
( (
CP0 is '$last_choice_pt', CP0 is '$last_choice_pt',