get rid of loop alias.

This commit is contained in:
ubu32 2011-07-11 07:40:58 -07:00
parent e379928239
commit d488984753
2 changed files with 21 additions and 8 deletions

View File

@ -36,7 +36,6 @@ true :- true.
'$system_catch'('$enter_top_level',Module,Error,user:'$Error'(Error)). '$system_catch'('$enter_top_level',Module,Error,user:'$Error'(Error)).
'$init_system' :- '$init_system' :-
set_stream(user_input,alias('$loop_stream')),
% do catch as early as possible % do catch as early as possible
( (
'$access_yap_flags'(15, 0), '$access_yap_flags'(15, 0),
@ -1068,7 +1067,6 @@ break :-
nb_setval('$if_level',0), nb_setval('$if_level',0),
get_value('$lf_verbose',OldSilent), get_value('$lf_verbose',OldSilent),
set_value('$lf_verbose',silent), set_value('$lf_verbose',silent),
set_stream(user_input,alias('$loop_stream')),
bootstrap(F), bootstrap(F),
% -p option must be processed after initializing the system % -p option must be processed after initializing the system
'$init_path_extensions', '$init_path_extensions',

View File

@ -248,8 +248,7 @@ use_module(M,F,Is) :-
'$set_consulting_file'(Stream), '$set_consulting_file'(Stream),
H0 is heapused, '$cputime'(T0,_), H0 is heapused, '$cputime'(T0,_),
'$file_name'(Stream,File), '$file_name'(Stream,File),
'$fetch_stream_alias'(OldStream,'$loop_stream'), '$set_current_loop_stream'(OldStream, Stream),
set_stream(Stream,alias('$loop_stream')),
nb_getval('$consulting',Old), nb_getval('$consulting',Old),
nb_setval('$consulting',false), nb_setval('$consulting',false),
'$access_yap_flags'(18,GenerateDebug), '$access_yap_flags'(18,GenerateDebug),
@ -285,7 +284,7 @@ use_module(M,F,Is) :-
; ;
true true
), ),
set_stream(OldStream,alias('$loop_stream')), '$set_current_loop_stream'(_, OldStream),
'$set_yap_flags'(18,GenerateDebug), '$set_yap_flags'(18,GenerateDebug),
'$comp_mode'(CompMode, OldCompMode), '$comp_mode'(CompMode, OldCompMode),
nb_setval('$consulting',Old), nb_setval('$consulting',Old),
@ -494,10 +493,10 @@ prolog_load_context(module, X) :-
prolog_load_context(source, FileName) :- prolog_load_context(source, FileName) :-
nb_getval('$consulting_file',FileName). nb_getval('$consulting_file',FileName).
prolog_load_context(stream, Stream) :- prolog_load_context(stream, Stream) :-
'$fetch_stream_alias'(Stream,'$loop_stream'). '$current_loop_stream'(Stream).
% return this term for SWI compatibility. % return this term for SWI compatibility.
prolog_load_context(term_position, '$stream_position'(0,Line,0,0,0)) :- prolog_load_context(term_position, '$stream_position'(0,Line,0,0,0)) :-
'$fetch_stream_alias'(Stream,'$loop_stream'), !, '$current_loop_stream'(Stream),
stream_property(Stream, position(Position)), stream_property(Stream, position(Position)),
stream_position_data(line_count, Position, Line). stream_position_data(line_count, Position, Line).
@ -660,7 +659,7 @@ remove_from_path(New) :- '$check_path'(New,Path),
'$do_error'(instantiation_error, encoding(V)). '$do_error'(instantiation_error, encoding(V)).
'$set_encoding'(EncAtom) :- '$set_encoding'(EncAtom) :-
'$valid_encoding'(EncAtom, Enc), !, '$valid_encoding'(EncAtom, Enc), !,
'$fetch_stream_alias'(Stream,'$loop_stream'), '$current_loop_stream'(Stream),
'$encoding'(Stream, Enc). '$encoding'(Stream, Enc).
'$set_encoding'(EncAtom) :- '$set_encoding'(EncAtom) :-
atom(EncAtom), !, atom(EncAtom), !,
@ -1067,3 +1066,19 @@ make.
assert_static(Clause). assert_static(Clause).
'$set_current_loop_stream'(OldStream, Stream) :-
'$current_loop_stream'(OldStream), !,
'$new_loop_stream'(Stream).
'$set_current_loop_stream'(OldStream, Stream) :-
'$new_loop_stream'(Stream).
'$new_loop_stream'(Stream) :-
(var(Stream) ->
nb_delete('$loop_stream')
;
nb_setval('$loop_stream',Stream)
).
'$current_loop_stream'(Stream) :-
catch(nb_getval('$loop_stream',Stream), _, fail).