Call the parser with explicit streams.

compiler/analysis.file.m:
compiler/make.module_dep_file.m:
compiler/parse_module.m:
compiler/recompilation.check.m:
    When calling the parser, explicitly specify the stream to read
    the term from; don't touch the current input stream.

compiler/find_module.m:
    Pass the stream to read from explicitly to parse_module.m.
This commit is contained in:
Zoltan Somogyi
2016-10-07 12:50:17 +11:00
parent 3f2436c68a
commit d7022606d4
5 changed files with 188 additions and 189 deletions

View File

@@ -246,8 +246,7 @@ find_source_error(ModuleName, Dirs, MaybeBetterMatch) = Msg :-
find_module_name(Globals, FileName, MaybeModuleName, !IO) :-
io.open_input(FileName, OpenRes, !IO),
(
OpenRes = ok(InputStream),
io.set_input_stream(InputStream, OldInputStream, !IO),
OpenRes = ok(FileStream),
( if string.remove_suffix(FileName, ".m", PartialFileName0) then
PartialFileName = PartialFileName0
else
@@ -259,14 +258,14 @@ find_module_name(Globals, FileName, MaybeModuleName, !IO) :-
BaseName = ""
),
file_name_to_module_name(BaseName, DefaultModuleName),
peek_at_file(DefaultModuleName, FileName, ModuleName, Specs, !IO),
peek_at_file(FileStream, DefaultModuleName, FileName, ModuleName,
Specs, !IO),
io.close_input(FileStream, !IO),
MaybeModuleName = yes(ModuleName),
% XXX We don't check whether ModuleName was actually read
% from the named file; it could just be DefaultModuleName.
% XXX _NumErrors
write_error_specs(Specs, Globals, 0, _NumWarnings, 0, _NumErrors, !IO),
io.set_input_stream(OldInputStream, _, !IO),
io.close_input(InputStream, !IO)
write_error_specs(Specs, Globals, 0, _NumWarnings, 0, _NumErrors, !IO)
;
OpenRes = error(Error),
ErrorMsg = io.error_message(Error),