try to make top level writing more SWI compatible.

This commit is contained in:
Vitor Santos Costa 2010-03-27 11:34:10 +00:00
parent 6d52fa371e
commit c468d8431e
2 changed files with 23 additions and 19 deletions

View File

@ -16,7 +16,7 @@
*************************************************************************/ *************************************************************************/
:- module('$attributes', [ :- module('$attributes', [
project_delayed_goals/2 delayed_goals/4
]). ]).
prolog:get_attr(Var, Mod, Att) :- prolog:get_attr(Var, Mod, Att) :-
@ -242,6 +242,11 @@ prolog:call_residue(Goal,Residue) :-
call_residue(Goal,Module,Residue) :- call_residue(Goal,Module,Residue) :-
call(Module:Goal). call(Module:Goal).
delayed_goals(G, Vs, NVs, Gs) :-
project_delayed_goals(G),
copy_term(G.Vs, _.NVs, Gs).
project_delayed_goals(G) :- project_delayed_goals(G) :-
'$undefined'(modules_with_attributes(_),attributes), !. '$undefined'(modules_with_attributes(_),attributes), !.
project_delayed_goals(G) :- project_delayed_goals(G) :-

View File

@ -514,8 +514,8 @@ true :- true.
'$execute'(G), '$execute'(G),
yap_hacks:current_choice_point(NCP), yap_hacks:current_choice_point(NCP),
( '$enter_system_mode' ; '$exit_system_mode', fail), ( '$enter_system_mode' ; '$exit_system_mode', fail),
'$output_frozen'(G, V, LGs), '$delayed_goals'(G, V, NV, LGs),
'$write_answer'(V, LGs, Written), '$write_answer'(NV, LGs, Written),
'$write_query_answer_true'(Written), '$write_query_answer_true'(Written),
( (
'$prompt_alternatives_on'(determinism), CP = NCP -> '$prompt_alternatives_on'(determinism), CP = NCP ->
@ -534,8 +534,8 @@ true :- true.
'$yes_no'(G,C) :- '$yes_no'(G,C) :-
'$current_module'(M), '$current_module'(M),
'$do_yes_no'(G,M), '$do_yes_no'(G,M),
'$output_frozen'(G, [], LGs), '$delayed_goals'(G, [], NV, LGs),
'$write_answer'([], LGs, Written), '$write_answer'(NV, LGs, Written),
( Written = [] -> ( Written = [] ->
!,'$present_answer'(C, yes); !,'$present_answer'(C, yes);
'$another', ! '$another', !
@ -547,6 +547,11 @@ true :- true.
'$add_env_and_fail' :- fail. '$add_env_and_fail' :- fail.
'$delayed_goals'(G, V, NV, LGs) :-
'$attributes':delayed_goals(G, V, NV, LGs), !.
'$delayed_goals'(_, V, NV, []) :-
copy_term_nat(V, NV).
'$out_neg_answer' :- '$out_neg_answer' :-
( '$undefined'(print_message(_,_),prolog) -> ( '$undefined'(print_message(_,_),prolog) ->
'$present_answer'(user_error,"no~n", []) '$present_answer'(user_error,"no~n", [])
@ -565,11 +570,6 @@ true :- true.
format(user_error,'~ntrue',[]). format(user_error,'~ntrue',[]).
'$write_query_answer_true'(_). '$write_query_answer_true'(_).
'$output_frozen'(_,V,LGs) :-
\+ '$undefined'(bindings_message(_,_,_), swi),
swi:bindings_message(V, LGs, []), !.
'$output_frozen'(G,V,LGs) :-
'$attributes':project_delayed_goals(G,LGs).
% %
% present_answer has three components. First it flushes the streams, % present_answer has three components. First it flushes the streams,
@ -735,11 +735,10 @@ true :- true.
format(user_error,'~w',[G]) format(user_error,'~w',[G])
). ).
'$name_vars_in_goals'(G, VL0, NG) :- '$name_vars_in_goals'(G, VL0, G) :-
copy_term_nat(G+VL0, NG+NVL0), '$name_well_known_vars'(VL0),
'$name_well_known_vars'(NVL0), '$variables_in_term'(G, [], GVL),
'$variables_in_term'(NG, [], NGVL), '$name_vars_in_goals1'(GVL, 0, _).
'$name_vars_in_goals1'(NGVL, 0, _).
'$name_well_known_vars'([]). '$name_well_known_vars'([]).
'$name_well_known_vars'([[Name|V]|NVL0]) :- '$name_well_known_vars'([[Name|V]|NVL0]) :-