fix prolog_load_context position detection to be SWI compatible (obs from Paulo Moura).wq

This commit is contained in:
Vítor Santos Costa 2011-04-30 10:57:00 +01:00
parent d041ca7a9a
commit 49daa4ab0b
2 changed files with 8 additions and 4 deletions

View File

@ -8505,7 +8505,9 @@ Stream currently being read in.
@item term_position @item term_position
@findex file (prolog_load_context/2 option) @findex file (prolog_load_context/2 option)
@* @*
Stream position at the stream currently being read in. Stream position at the stream currently being read in. For SWI
compatibility, it is a term of the form
@code{'$stream_position'(0,Line,0,0,0)}.
@end table @end table
@item source_location(?@var{FileName}, ?@var{Line}) @item source_location(?@var{FileName}, ?@var{Line})

View File

@ -495,9 +495,11 @@ 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'). '$fetch_stream_alias'(Stream,'$loop_stream').
prolog_load_context(term_position, Position) :- % return this term for SWI compatibility.
'$fetch_stream_alias'(Stream,'$loop_stream'), prolog_load_context(term_position, '$stream_position'(0,Line,0,0,0)) :-
stream_position(Stream, Position). '$fetch_stream_alias'(Stream,'$loop_stream'), !,
stream_property(Stream, position(Position)),
stream_position_data(line_count, Position, Line).
% if the file exports a module, then we can % if the file exports a module, then we can