library/io.m:
Add a version of io.write_line_cc that takes an explicit stream argument.
NEWS:
Announce the addition.
browser/interactive_query.m:
Use the new predicate.
profiler/call_graph.m:
profiler/generate_output.m:
profiler/mercury_profile.m:
profiler/options.m:
profiler/output.m:
profiler/process_file.m:
profiler/read.m:
profiler/snapshots.m:
Replace implicit streams with explicit streams.
profiler/PROF_FLAGS.in:
Specify --warn-implicit-stream-calls for all modules in this directory.
deep_profiler/analysis_utils.m:
deep_profiler/autopar_find_best_par.m:
deep_profiler/autopar_reports.m:
deep_profiler/autopar_search_callgraph.m:
deep_profiler/autopar_search_goals.m:
deep_profiler/callgraph.m:
deep_profiler/canonical.m:
deep_profiler/cliques.m:
deep_profiler/coverage.m:
deep_profiler/dump.m:
deep_profiler/mdprof_cgi.m:
deep_profiler/mdprof_create_feedback.m:
deep_profiler/mdprof_dump.m:
deep_profiler/mdprof_procrep.m:
deep_profiler/mdprof_report_feedback.m:
deep_profiler/mdprof_test.m:
deep_profiler/profile.m:
deep_profiler/read_profile.m:
deep_profiler/recursion_patterns.m:
deep_profiler/startup.m:
deep_profiler/var_use_analysis.m:
Replace implicit streams with explicit streams.
In some places, simplify some code, often using constructs such as
string.format that either did not exist or were too expensive to use
when the original code was written.
Consistenly use the spelling StdErr over Stderr.
In mdbprof_dump.m, put filename and reason-for-failing-to-open-that-file
in the right order in an error message.
deep_profiler/DEEP_FLAGS.in:
Turn on --warn-implicit-stream-calls for the entire deep_profiler
directory.
mdbcomp/program_representation.m:
mdbcomp/trace_counts.m:
Replace implicit streams with explicit streams. These are the two mdbcomp
modules that (a) used to use implicit streams, and (2) are used by the
deep profiler.
mdbcomp/Mercury.options:
Turn on --warn-implicit-stream-calls for these two modules.
slice/mcov.m:
slice/mtc_union.m:
Conform to the changes in mdbcomp.
browser/browse.m:
browser/browser_info.m:
browser/collect_lib.m:
browser/declarative_debugger.m:
browser/declarative_oracle.m:
browser/declarative_user.m:
browser/diff.m:
browser/help.m:
browser/interactive_query.m:
browser/parse.m:
browser/util.m:
Replace implicit streams with explicit streams.
Shorten lines longer than 79 chars.
In some places, simplify some code, often using constructs such as
string.format that either did not exist or were too expensive to use
when the original code was written.
In some places, change predicate names that were not meaningful
without module qualification by *including* the module qualification
in the name (e.g. init -> browser_info_init).
In some places, add XXXs.
In browser_info.m, make the output stream *part* of the debugger type,
because without this, having the debugger type belong to the stream
typeclass does NOT make sense. (The typeclass instance for debugger
used to always write to the current output stream, which this diff
is replacing with the use of explicitly specified streams.)
In browse.m, consistently put stream arguments before other arguments.
In browse.m, when exporting Mercury predicates to C, export them
under names with the standard ML_BROWSE_ prefix, NOT under the name
of a *different* predicate with that prefix.
In diff.m, eliminate an unnecessary difference between what we print
when the difference between two terms is at the root, vs what we print
when the difference between two terms is lower down.
In interactive_query.m, when trying to write a program out to a file,
do NOT write the program to the current output stream if we cannot open
the file, since that would accomplish nothing useful.
Also in interactive_query.m, cleanup .dylib instead of .so on MacOS.
In util.m, delete some unused predicates.
In collect_lib.m, document why some code is not worth updating.
In declarative_oracle.m, rename predicates with previously-ambiguous
names.
browser/MDBFLAGS.in:
Specify --warn-implicit-stream-calls for all Mercury modules
in the browser directory from now.
trace/mercury_trace_browse.c:
trace/mercury_trace_cmd_browsing.c:
ssdb/ssdb.m:
Conform to the changes in browser/*.m.
tests/debugger/queens.{exp,exp2}:
Expect the extra output from browser/diff.m.
compiler/make.module_dep_file.m:
Write foreign included file names to the .module_dep stream
instead of the implicit output stream. The bug was introduced in
commit 5f50259d16.
tests/mmc_make/Mmakefile:
mmc --make does not set a non-zero exit status even if there were
problems reading a .module_dep file. Explicitly grep for "error" in
the mmc --make output in the include_file test that should have
caught the preceding bug (assuming the workspace is built with
--use-subdirs).
grep for "error" in another test case.
compiler/prog_data.m:
As above.
compiler/mercury_to_mercury.m:
When generating debugging output, generate different output
for tuple_cons cons_ids than for the initial representation
of the tuple constructor, cons(unqualified("{}"), ...).
To make this possible, take an argument that specifies whether
we are generating debugging output.
compiler/error_msg_inst.m:
compiler/hlds_out_mode.m:
compiler/hlds_out_module.m:
compiler/inst_check.m:
compiler/mode_errors.m:
compiler/parse_tree_out_inst.m:
compiler/prog_ctgc.m:
Pass the language (debug or not) to mercury_to_mercury.m
when printing cons_ids.
library/hash_table.m:
library/stream.string_writer.m:
Fix code where a mode specialization (i.e. the specification of
a particular input function symbol for an argument) was applied
to the wrong argument.
compiler/type_util.m:
compiler/inst_util.m:
Move two predicates that operate on types but are used only by code
that manipulates insts from type_util.m to inst_util.m. The reason
is that both predicates lose higher order inst information, and fixing
that will require them to operate on insts as well. Moving them now
should make the diff with the fix easier to review.
compiler/inst_match.m:
compiler/inst_test.m:
Conform to the moves above.
compiler/mode_info.m:
Add a new field to the debug flags we set up when --debug-modes is enabled.
This field specifies whether the debug output is from mode checking,
or from *unique* mode checking. Without this, the two are far too easy
to confuse, as I found out the hard way.
compiler/mode_debug.m:
Use the new field to add visually distinguish mode checkpoints from
the two passes. For example. where mode checking would output
"Enter unify", unique mode checking will output "Enter unique unify".
compiler/unique_modes.m:
Delete a marker on mode checkpoints for conjunctions that also baffled me.
compiler/inst_match.m:
Change the predicates that compare two insts to make the nested switch
(first on one inst, then the other), make the nesting explicit.
Give a predicate a more meaningful name.
Add XXXs on dodgy code.
compiler/inst_match.m:
Replace a bool and a maybe with bespoke types, so that during a debugging
session, there is no need to waste time on trying to remember what e.g.
a "no" stands for.
compiler/modes.m:
Put the code that checks each arg's final inst into its own predicate,
to make the result easier to observe in mdb.
Don't thread a goal through the code that checks final insts,
since the code never updated or even looked at the goals.
Delete this pair of goals from the argument lists of the ancestors
of this predicate whenever possible, including an exported predicate.
compiler/modecheck_unify.m:
Put a piece of code making a tricky decision into its own predicate,
to allow breakpoints on that predicate to show the result of the decision.
Conform to the change in modes.m.
compiler/modecheck_call.m:
This fixes a bug in my fix for Mantis bug #529.
compiler/options.m:
Allow configure to test whether the bug is fixed, so we can delete
any now-redundant explicit higher order insts in mode declarations.
compiler/modecheck_call.m:
As above. This fixes Mantis bug #529.
compiler/options.m:
Allow configure to test whether the bug is fixed, so we can delete
any now-redundant explicit higher order insts in mode declarations.
tests/hard_coded/exist_cons_ho_arg.{m,exp}:
A test case for the bug. This is a strengthened version of the
Mantis test case.
tests/hard_coded/Mmakefile:
Enable the new test case.
compiler/mode_errors.m:
As above.
Delete predicates that (a) do not belong here, but (b) do belong
in some other module.
compiler/mode_info.m:
Move mode_context_init here from mode_errors.m, since the mode_context
type is defined here.
compiler/modes.m:
Move two predicates, maybe_report_error_no_modes and
+report_mode_inference_messages_for_preds here from mode_errors.m,
since their only callers are here.
compiler/post_typecheck.m:
Move +report_indistinguishable_modes_error here from mode_errors.m,
since its only caller is here.
compiler/mode_errors.m:
Give the function symbols representing the various kinds of mode errors
more meaningful names. (Some fix misleading implications, such as when
a function symbol name includes "pred", but the error applies to functions
as well.) Do the same for other function symbols in this module.
Where arguments are lists that should never be empty, change their type
to one_or_more to encode this invariant.
In one case (var_multimode_pred_error), the same data items were packaged
in two different ways in two different places. Remove this unnecessary
difference.
In some cases, put arguments in a more logical order.
Improve the comments on most of these function symbols, fixing errors,
fixing omissions, documenting arguments. Add XXXs where warranted.
Put the types used in the various kinds of mode errors below the
mode_error type itself. Put them into meaningful groups.
The current order of the mode_error function symbols is totally
haphazard. Propose a new order for them, but do not implement it yet,
in order to make this diff easier to review.
Make the representation of the error that says "calling an implied mode
for this predicate or function is not implemented" say *why* it is
not implemented. Include this info in the error message we generate.
This error message is not exercised by any existing test case, which is
why there are no changes to test cases in this diff.
Improve the explanation for why you cannot unify two functions or
two predicates. Since this explanation occurs only in verbose output,
no test case is affected by this change either.
Improve variable names.
compiler/mode_info.m:
Conform to the changes in mode_errors.m.
If --debug-modes is specified, print each error message as it is added
to the mode_info. This helped me track down a bug in this change.
compiler/instmap.m:
compiler/modecheck_call.m:
compiler/modecheck_conj.m:
compiler/modecheck_goal.m:
compiler/modecheck_unify.m:
compiler/modecheck_util.m:
compiler/modes.m:
Conform to the changes in mode_errors.m and/or mode_info.m.
Add XXXs in some places. One marks one possible cause of Mantis bug #529.
library/random.system_rng.m:
Shift most of the #includes into a local foreign_decl pragma
so that they do not get included in the .mh file.
Position the C# and Java foreign code pragmas to the end of the file,
with the C one.
library/random.system_rng.m:
Document what sources of randomness are used by the C backends.
library/MODULES_DOC:
library/MODULES_UNDOC:
Include random.system_rng module in the library documentation.
NEWS:
Announce the random.system_rng module.
Ensure it is not possible to use a system RNG handle after it has been closed
with the arc4random() and rand_s() based implementations.
library/random.system_rng.m:
As above.
Ensure it is not possible to use a system RNG handle after it has been closed
in the C# and Java grades. This brings the implementation for these backends
into line with the /dev/urandom implementation on C. (The other C implementation
will be made to conform in a separate change.)
library/random.system_rng.m:
Add wrapper classes around the C# and Java system RNGs that allow
us to track if they have already been closed.
On Windows we implement the system RNG by calling the CRT's rand_s() function.
library/random.system_rng.m:
Implement the system RNG on Windows using rand_s().
runtime/mercury_std.h:
On Windows define the macro _CRT_RAND_S before the initial
inclusion of stdlib.h -- we must do this otherwise the declaration
of rand_s() will not be visible.
library/random.system_rng.m:
As above.
Use the arc4random() based implementation on FreeBSD >= 12.0
and macOS >= 10.12, falling back to the urandom approach on earlier
versions.
Always use the arc4random() approach on NetBSD and OpenBSD,
both of which have used ChaCha20 in their implementation
of arc4random() since 2014.
Add a system RNG implementation for the C backends that works by
reading random bits from /dev/urandom. We use this on Linux,
AIX and Solaris.
library/random.system_rng.m:
Add two implementations of the system RNG for the C backends, one that
reads from /dev/urandom and one that just aborts. The former is used
on Linux and the latter is used everywhere else (for now).
This fixes Mantis bug #528.
compiler/error_msg_inst.m:
Since an inst_name IN may be used nested inside itself, as in
IN(..., IN(...), ...), do not insist that both occurrences of IN
in such cases lead to the insertion of a new entry in the inst name
expansion map.
tests/invalid/html.{m,err_exp}:
The Mantis test case.
tests/invalid/Mmakefile:
Enable the Mantis test case.
This is work-in-progress, currently only the C# and Java backends
are supported. Support for the C backends will be added separately.
library/random.system_rng.m:
A new submodule containing the system RNG.
library/random.m:
library/library.m:
Include the new submodule.
library/MODULES_UNDOC:
Do not generate documentation for the new submodule.
compiler/c_util.m:
Add missing stream argument.
compiler/Mercury.options:
Fix misspelt filename that prevented the problem in c_util.m
from being automatically diagnosed.
Normally, foreign_procs are assumed to be type correct, because they
have to be: a Mercury compiler cannot check foreign code. However,
in one case, we can get type errors for foreign_procs That case is when
a predicate has
- an existentially typed argument, and
- two or more modes implemented by foreign procs.
The compiler has never been able to correctly handle more than one clause
defining the type_info of an existentially typed argument. When those clauses
were Mercury clauses, it generated an error; when those "clauses" were
foreign_procs, it *tried* to generate an error, but the code that did that
crashed the compiler.
compiler/typecheck_errors.m:
Fix the compiler abort, letting the error message be generated.
tests/invalid/foreign_procs_exist_type.{m,err_exp}:
Add a test case for this fix.
tests/invalid/Mmakefile:
Enable the new test case.
Delete the `' quotes around predicate names, since these confuse vim's
syntax highlighting.
Put each argument of a foreign_proc on its own line, since putting
all the args on one line often causes vim to regard the line
as excessively long, highlighting all characters after column #80.
benchmarks/progs/tree234/tree234x.m:
benchmarks/progs/pic/mercury/utils.m:
Replace uses of is a synonym for unification.
benchmarks/progs/training_cars/*.m:
Delete implementation imports that shadow those in the interface.