[m-dev.] diff: purity bug-fix and new module post_typecheck.m
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri Jun 5 00:34:23 AEST 1998
On 04-Jun-1998, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> Improve the modularity of the code in purity.m by splitting it into two
> modules and fix a purity-related bug by moving some code from typecheck.m
> into the new module.
It turns out that an additional is needed to make this work:
compiler/mercury_compile.m:
Run purity checking before writing the `.opt' files.
This is necessary because writing out the `.opt' files
requires that code in post_typecheck__finish_pred
(formerly in typecheck.m) has been run.
Index: mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.93
diff -u -u -r1.93 mercury_compile.m
--- mercury_compile.m 1998/05/29 08:50:41 1.93
+++ mercury_compile.m 1998/06/04 14:28:17
@@ -561,6 +561,7 @@
% typecheck would get internal errors
%
globals__io_lookup_bool_option(verbose, Verbose),
+ globals__io_lookup_bool_option(statistics, Stats),
maybe_write_string(Verbose, "% Type-checking...\n"),
( { FoundUndefTypeError = yes } ->
{ HLDS = HLDS1 },
@@ -579,7 +580,7 @@
%
% Next typecheck the clauses.
%
- typecheck(HLDS2, HLDS3, FoundUndefModeError, FoundTypeError), !,
+ typecheck(HLDS2, HLDS3, FoundTypeError), !,
( { FoundTypeError = yes } ->
maybe_write_string(Verbose,
"% Program contains type error(s).\n"),
@@ -590,51 +591,60 @@
mercury_compile__maybe_dump_hlds(HLDS3, "03", "typecheck"),
%
- % Now continue, even if we got a type error,
- % unless `--typecheck-only' was specified.
+ % We can't continue after an undefined inst/mode
+ % error, since propagate_types_into_proc_modes
+ % (in post_typecheck.m -- called by purity.m)
+ % and mode analysis would get internal errors
%
- globals__io_lookup_bool_option(typecheck_only, TypecheckOnly),
- ( { TypecheckOnly = yes } ->
+ ( { FoundUndefModeError = yes } ->
+ { FoundError = yes },
{ HLDS = HLDS3 },
- { bool__or(FoundTypeError, FoundTypeclassError, FoundError) }
+ maybe_write_string(Verbose,
+ "% Program contains undefined inst or undefined mode error(s).\n"),
+ io__set_exit_status(1)
;
- % only write out the `.opt' file if there are no type errors
- globals__io_lookup_bool_option(make_optimization_interface,
- MakeOptInt),
- ( { FoundTypeError = no } ->
- mercury_compile__maybe_write_optfile(MakeOptInt,
- HLDS3, HLDS4), !
- ;
- { HLDS4 = HLDS3 }
- ),
- % if our job was to write out the `.opt' file, then we're done
- ( { MakeOptInt = yes } ->
- { HLDS = HLDS4 },
- { bool__or(FoundTypeError, FoundTypeclassError,
- FoundError) }
- ;
- %
- % We can't continue after an undefined inst/mode
- % error, since mode analysis would get internal errors
- %
- ( { FoundUndefModeError = yes } ->
- { FoundError = yes },
- { HLDS = HLDS4 },
- maybe_write_string(Verbose,
- "% Program contains undefined inst or undefined mode error(s).\n"),
- io__set_exit_status(1)
- ;
+ %
+ % Run purity checking
+ %
+ mercury_compile__puritycheck(HLDS3, Verbose, Stats, HLDS4),
+ mercury_compile__maybe_dump_hlds(HLDS4, "04", "puritycheck"),
+
+ %
+ % Stop here if `--typecheck-only' was specified.
+ %
+ globals__io_lookup_bool_option(typecheck_only, TypecheckOnly),
+ ( { TypecheckOnly = yes } ->
+ { HLDS = HLDS4 },
+ { bool__or(FoundTypeError, FoundTypeclassError,
+ FoundError) }
+ ;
+ % only write out the `.opt' file if there are no type errors
+ globals__io_lookup_bool_option(make_optimization_interface,
+ MakeOptInt),
+ ( { FoundTypeError = no } ->
+ mercury_compile__maybe_write_optfile(MakeOptInt,
+ HLDS4, HLDS5), !
+ ;
+ { HLDS5 = HLDS4 }
+ ),
+ % if our job was to write out the `.opt' file,
+ % then we're done
+ ( { MakeOptInt = yes } ->
+ { HLDS = HLDS5 },
+ { bool__or(FoundTypeError, FoundTypeclassError,
+ FoundError) }
+ ;
%
% Now go ahead and do the rest of mode checking and
% determinism analysis
%
- mercury_compile__frontend_pass_2_by_phases(HLDS4,
+ mercury_compile__frontend_pass_2_by_phases(HLDS5,
HLDS, FoundModeOrDetError),
{ bool__or(FoundTypeError, FoundModeOrDetError,
FoundError0) },
{ bool__or(FoundError0, FoundTypeclassError,
FoundError) }
- )
+ )
)
)
).
@@ -727,12 +737,9 @@
% is det.
:- mode mercury_compile__frontend_pass_2_by_phases(in, out, out, di, uo) is det.
-mercury_compile__frontend_pass_2_by_phases(HLDS3, HLDS20, FoundError) -->
+mercury_compile__frontend_pass_2_by_phases(HLDS4, HLDS20, FoundError) -->
globals__io_lookup_bool_option(verbose, Verbose),
globals__io_lookup_bool_option(statistics, Stats),
-
- mercury_compile__puritycheck(HLDS3, Verbose, Stats, HLDS4),
- mercury_compile__maybe_dump_hlds(HLDS4, "04", "puritycheck"),
mercury_compile__modecheck(HLDS4, Verbose, Stats, HLDS5,
FoundModeError, UnsafeToContinue),
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
More information about the developers
mailing list