tests/accumulator/*.m:
tests/analysis_*/*.m:
tests/benchmarks*/*.m:
tests/debugger*/*.{m,exp,inp}:
tests/declarative_debugger*/*.{m,exp,inp}:
tests/dppd*/*.m:
tests/exceptions*/*.m:
tests/general*/*.m:
tests/grade_subdirs*/*.m:
tests/hard_coded*/*.m:
Make these tests use four-space indentation, and ensure that
each module is imported on its own line. (I intend to use the latter
to figure out which subdirectories' tests can be executed in parallel.)
These changes usually move code to different lines. For the debugger tests,
specify the new line numbers in .inp files and expect them in .exp files.
Estimated hours taken: 0
Branches: main
tests/hard_coded/mutable_decl.exp:
tests/hard_coded/mutable_decl.m:
tests/hard_coded/pure_mutable.exp:
tests/hard_coded/pure_mutable.m:
tests/invalid/bad_mutable.err_exp:
tests/invalid/bad_mutable.m:
Add some thread-local mutables to these test cases.
(Forgot to commit them earlier.)
Estimated hours taken: 1
Branches: main, release
Get rid of the `thread_safe' mutable attribute, since this doesn't actually
make access to a mutable thread safe (in fact it makes them less thread
safe than the `not_thread_safe' version).
By extension this also removes support for the `not_thread_safe' mutable
attribute.
compiler/prog_io.m:
compiler/prog_item.m:
compiler/prog_mutable.m:
Remove support for the `thread_safe' mutable attribute.
compiler/make_hlds_passes.m:
Remove support for the `thread_safe' mutable attribute.
Mark the foreign clauses for `get' predicates for constant
mutables as thread safe.
doc/reference_manual.texi:
Delete the documentation for the `thread_safe' mutable attribute.
tests/hard_coded/mutable_decl.m:
tests/hard_coded/pure_mutable.m:
tests/hard_coded/trace_goal_env_1.m:
tests/hard_coded/trace_goal_env_2.m:
tests/hard_coded/unusual_name_mutable.m:
tests/hard_coded/sub-modules/mutable_child.m:
tests/hard_coded/sub-modules/mutable_grandchild.m:
tests/hard_coded/sub-modules/mutable_parent.m:
tests/invalid/bad_mutable.{err_exp,m}:
tests/invalid/not_in_interface.m:
Conform to the above change.
Estimated hours taken: 24
Branches: main
Add `:- mutable' directives to the language, providing modules with private
mutable variables. A directives
:- mutable(x, int, 0, ground, [thread_safe]).
leads to the compiler generating the following:
:- semipure pred get_x(int::out(ground)) is det.
:- impure pred set_x(int::in(ground)) is det.
:- pred initialise_mutable_x(io::di, io::uo) is det.
:- initialise initialise_mutable_x/2.
initialise_mutable_x(!IO) :-
promise_pure(
impure set_x(0)
).
:- pragma foreign_decl("C", "MR_Word mutable_variable_x;").
:- pragma foreign_proc("C", get_x(X::out(ground)),
[thread_safe, promise_semipure],
"MR_trail_current_value(&mutable_variable_x); X = mutable_variable_x;").
:- pragma foreign_proc("C", set_x(X::in(ground)),
[thread_safe],
"mutable_variable_x = X;").
Possible attributes for a mutable variable are `thread_safe' and
`untrailed'.
NEWS:
Mention the new language feature.
compiler/make_hlds_passes.m:
Handle the new mutable/5 item.
Pass 1 expands a mutable directives into the pred
declaration items.
Pass 2 expands a mutable directives into the initialise
and foreign_decl declaration items.
Pass 3 expands a mutable directives into the initialise
declaration and the clauses for the preds.
compiler/mercury_to_mercury.m:
compiler/mercury_qual.m:
compiler/modules.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
Cover the new mutable/5 item.
compiler/prog_data.m:
Add a new mutable/5 program item.
compiler/prog_io.m:
Parse `:- mutable' directives.
compiler/prog_io_typeclass.m:
compiler/prog_io_util.m:
Move list_term_to_term_list from prog_io_typeclass to prog_io_util
(it's a generally useful predicate).
doc/reference_manual.texi:
Document the new `:- mutable' directive.
tests/hard_coded/Mmakefile:
tests/hard_coded/mutable_decl.m:
tests/hard_coded/mutable_decl.exp:
Added a test case that only runs in trailing grades.