Estimated hours taken: 10
Fix the remaining bugs with the handling of partial qualifiers
for nested modules.
compiler/module_qual.m:
Define a new abstract type partial_qualifier_info, and a predicate
mq_info_get_partial_qualifier_info to get this type from the mq_info.
Define a new predicate get_partial_qualifiers/3 in module_qual.m
which is like the old get_partial_qualifiers/2 predicate from
modules.m except that it takes a partial_qualifier_info and
uses the information in this to return only the partial qualifiers
for modules which are visible, rather than returning all partial
qualifier regardless of whether the modules that they refer to
are in scope or not.
compiler/prog_util.m:
Export the `insert_module_qualifier' predicate, for use in the
definition of get_partial_qualifiers/3.
compiler/hlds_module.m:
compiler/make_hlds.m:
Change the code for make_hlds__ctors_add and
hlds_module__pred_table_insert/5 so that they handles partial
qualifiers properly, computing the partial qualifiers by
calling get_partial_qualifiers/3 rather than by checking the
NeedQual variable and calling get_partial_qualifiers/2.
compiler/modules.m:
Delete the old get_partial_qualifiers/2 predicate.
compiler/hlds_module.m:
Add a new field to the HLDS containing the partial_qualifier_info.
Add a partial_qualifier_info parameter to pred_table_insert/5.
compiler/check_typeclass.m:
compiler/make_hlds.m:
When calling pred_table_insert/5, get the partial_qualifier_info
from the HLDS and pass it as an extra argument.
tests/hard_coded/sub-modules/nested.m:
tests/hard_coded/sub-modules/nested3.m:
tests/hard_coded/sub-modules/parent.m:
tests/hard_coded/sub-modules/nested.exp:
tests/hard_coded/sub-modules/nested3.exp:
tests/hard_coded/sub-modules/parent.exp:
Uncomment parts of these test cases which were previously
commented out because they were not yet supported.
doc/reference_manual.texi:
Delete the description of this bug.
Estimated hours taken: 2
More changes to reduce the complexity of the intermodule dependencies.
compiler/module_qual.m:
Some minor changes to avoid the need to import hlds*.m.
This module acts on the parse tree, not the HLDS, so we
shouldn't import hlds*.m here.
compiler/modules.m:
compiler/prog_io.m:
compiler/det_analysis.m:
Delete some unnecessary imports.
compiler/equiv_type.m:
compiler/dependency_graph.m:
Add some XXX comments about unwanted intermodule dependencies.
Estimated hours taken: 1
Add two new mmake targets, clean_local and realclean_local, which
are the same as clean and realclean except that the former retain their
original meanings if rules are added to the latter. This is useful
if users want to add rules for a recursive mmake clean.
compiler/modules.m:
Output `clean_local: module.clean' to generated .dep files
instead of `clean: module.clean'. Same for `realclean'.
scripts/Mmake.rules:
Add dependencies to implement the original targets in terms of
the new targets.
Estimated hours taken: 0.2
compiler/modules.m:
Do not put line numbers into the generated interface files,
even if the --line-numbers option is on. If we do, then even
a change to a source file that does not materially affect the
module's interface may cause other modules to be recompiled,
because the line numbers in the interface file may change.
Estimated hours taken: 60
User-guided type specialization.
compiler/prog_data.m:
compiler/prog_io_pragma.m:
compiler/modules.m:
compiler/module_qual.m:
compiler/mercury_to_mercury.m:
Handle `:- pragma type_spec'.
compiler/prog_io_pragma.m:
Factor out some common code to parse predicate names with arguments.
compiler/hlds_module.m:
Added a field to the module_sub_info to hold information about
user-requested type specializations, filled in by make_hlds.m
and not used by anything after higher_order.m.
compiler/make_hlds.m:
For each `:- pragma type_spec' declaration, introduce a new predicate
which just calls the predicate to be specialized with the
specified argument types. This forces higher_order.m to produce
the specialized versions.
compiler/higher_order.m:
Process the user-requested type specializations first to ensure
that they get the correct names.
Allow partial matches against user-specified versions, e.g.
map__lookup(map(int, list(int)), int, list(int)) matches
map__lookup(map(int, V), int, V).
Perform specialization where a typeclass constraint matches a
known instance, but the construction of the typeclass_info is
done in the calling module.
Give slightly more informative progress messages.
compiler/dead_proc_elim.m:
Remove specializations for dead procedures.
compiler/prog_io_util.m:
Change the definition of the `maybe1' and `maybe_functor' types
to avoid the need for copying to convert between `maybe1'
and `maybe1(generic)'.
Changed the interface of `make_pred_name_with_context' to allow
creation of predicate names for type specializations which describe
the type substitution.
compiler/make_hlds.m:
compiler/prog_io_pragma.m:
Make the specification of pragma declarations in error
messages consistent. (There are probably some more to
be fixed elsewhere for termination and tabling).
compiler/intermod.m:
Write type specialization pragmas for predicates declared
in `.opt' files.
compiler/mercury_to_mercury.m:
Export `mercury_output_item' for use by intermod.m.
compiler/options.m:
Add an option `--user-guided-type-specialization' enabled
with `-O2' or higher.
compiler/handle_options.m:
`--type-specialization' implies `--user-guided-type-specialization'.
compiler/hlds_goal.m:
Add predicates to construct constants. These are duplicated
in several other places, I'll fix that as a separate change.
compiler/type_util.m:
Added functions `int_type/0', `string_type/0', `float_type/0'
and `char_type/0' which return the builtin types.
These are duplicated in several other places,
I'll fix that as a separate change.
library/private_builtin.m:
Added `instance_constraint_from_typeclass_info/3' to extract
the typeclass_infos for a constraint on an instance declaration.
This is useful for specializing class method calls.
Added `thread_safe' to various `:- pragma c_code's.
Added `:- pragma inline' declarations for `builtin_compare_*', which
are important for user-guided type specialization. (`builtin_unify_*'
are simple enough to go in the `.opt' files automatically).
compiler/polymorphism.m:
`instance_constraint_from_typeclass_info/3' does not need type_infos.
Add `instance_constraint_from_typeclass_info/3' to the
list of `typeclass_info_manipulator's which higher_order.m
can interpret.
NEWS:
doc/reference_manual.texi:
doc/user_guide.texi
Document the new pragma and option.
tests/invalid/Mmakefile:
tests/invalid/type_spec.m:
tests/invalid/type_spec.err_exp:
Test error reporting for invalid type specializations.
tests/hard_coded/Mmakefile:
tests/invalid/type_spec.m:
tests/invalid/type_spec.exp:
Test type specialization.
Estimated hours taken: 1
compiler/modules.m:
Fix a bug with the arguments passed to c2init by the generated `.dep'
file when using fact tables: it should not pass the fact table `.c'
files to c2init, because the fact table `.c' files do not have
(or need) any initialization function.
Estimated hours taken: 1200
Aditi compilation.
compiler/options.m:
The documentation for these is commented out because the Aditi
system is not currently useful to the general public.
--aditi: enable Aditi compilation.
--dump-rl: write the intermediate RL to `<module>.rl_dump'.
--dump-rl-bytecode: write a text version of the bytecodes
to `<module>.rla'
--aditi-only: don't produce a `.c' file.
--filenames-from-stdin: accept a list of filenames to compile
from stdin. This is used by the query shell.
--optimize-rl, --optimize-rl-cse, --optimize-rl-invariants,
--optimize-rl-index, --detect-rl-streams:
Options to control RL optimization passes.
--aditi-user:
Default owner of any Aditi procedures,
defaults to $USER or "guest".
--generate-schemas:
write schemas for base relations to `<module>'.base_schema
and schemas for derived relations to `<module>'.derived_schema.
This is used by the query shell.
compiler/handle_options.m:
Handle the default for --aditi-user.
compiler/hlds_pred.m:
compiler/prog_data.m:
compiler/prog_io_pragma.m:
compiler/make_hlds.m:
Add some Aditi pragma declarations - `aditi', `supp_magic', `context',
`naive', `psn' (predicate semi-naive), `aditi_memo', `aditi_no_memo',
`base_relation', `owner' and `index'.
Separate out code to parse a predicate name and arity.
compiler/hlds_pred.m:
Add predicates to identify Aditi procedures.
Added markers `generate_inline' and `aditi_interface', which
are used internally for Aditi code generation.
Add an `owner' field to pred_infos, which is used for database
security checks.
Add a field to pred_infos to hold the list of indexes for a base
relation.
compiler/make_hlds.m:
Some pragmas must be exported if the corresponding predicates
are exported, check this.
Make sure stratification of Aditi procedures is checked.
Predicates with a mode declaration but no type declaration
are no longer assumed to be local.
Set the `do_aditi_compilation' field of the module_info if there
are any local Aditi procedures or base relations.
Check that `--aditi' is set if Aditi compilation is required.
compiler/post_typecheck.m:
Check that every Aditi predicate has an `aditi__state' argument,
which is used to ensure sequencing of updates and that Aditi
procedures are only called within transactions.
compiler/dnf.m:
Changed the definition of disjunctive normal form slightly
so that a call followed by some atomic goals not including
any database calls is considered atomic. magic.m can handle
this kind of goal, and it results in more efficient RL code.
compiler/hlds_module.m:
compiler/dependency_graph.m:
Added dependency_graph__get_scc_entry_points which finds
the procedures in an SCC which could be called from outside.
Added a new field to the dependency_info, the
aditi_dependency_ordering. This contains all Aditi SCCs of
the original program, with multiple SCCs merged where
possible to improve the effectiveness of differential evaluation
and the low level RL optimizations.
compiler/hlds_module.m:
Add a field to record whether there are any local Aditi procedures
in the current module.
Added versions of module_info_pred_proc_info and
module_info_set_pred_proc_info which take a pred_proc_id,
not a separate pred_id and proc_id.
compiler/polymorphism.m:
compiler/lambda.m:
Make sure that predicates created for closures in Aditi procedures
have the correct markers.
compiler/goal_util.m:
Added goal_util__switch_to_disjunction,
goal_util__case_to_disjunct (factored out from simplify.m)
and goal_util__if_then_else_to_disjunction. These are
require because supplementary magic sets can't handle
if-then-elses or switches.
compiler/type_util.m:
Added type_is_aditi_state/1.
compiler/mode_util.m:
Added partition_args/5 which partitions a list of arguments
into inputs and others.
compiler/inlining.m:
Don't inline memoed procedures.
Don't inline Aditi procedures into non-Aditi procedures.
compiler/intermod.m:
Handle Aditi markers.
Clean up handling of markers which should not appear in `.opt' files.
compiler/simplify.m:
Export a slightly different interface for use by magic.m.
Remove explicit quantifications where possible.
Merge multiple nested quantifications.
Don't report infinite recursion warnings for Aditi procedures.
compiler/prog_out.m:
Generalised the code to output a module list to write any list.
compiler/code_gen.m:
compiler/arg_info.m:
Don't process Aditi procedures.
compiler/mercury_compile.m:
Call magic.m and rl_gen.m.
Don't perform the low-level annotation passes on Aditi procedures.
Remove calls to constraint.m - sometime soon a rewritten version
will be called directly from deforestation.
compiler/passes_aux.m:
Add predicates to process only non-Aditi procedures.
compiler/llds.m:
compiler/llds_out.m:
Added new `code_addr' enum members, do_{det,semidet,nondet}_aditi_call,
which are defined in extras/aditi/aditi.m.
compiler/call_gen.m:
Handle generation of do_*_aditi_call.
compiler/llds_out.m:
Write the RL code for the module as a constant char array
in the `.c' file.
compiler/term_errors.m:
compiler/error_util.m:
Move code to describe predicates into error_util.m
Allow the caller to explicitly add line breaks.
Added error_util:list_to_pieces to format a list of
strings.
Reordered some arguments for currying.
compiler/hlds_out.m:
Don't try to print clauses if there are none.
runtime/mercury_init.h:
util/mkinit.c:
scripts/c2init.in:
Added a function `mercury__load_aditi_rl_code()' to the generated
`<module>_init.c' file which throws all the RL code for the program
at the database. This should be called at connection time by
`aditi__connect'.
Added an option `--aditi' which controls the output
`mercury__load_aditi_rl_code()'.
compiler/notes/compiler_design.html:
Document the new files.
Mmakefile:
bindist/Mmakefile:
Don't distribute extras/aditi yet.
New files:
compiler/magic.m:
compiler/magic_util.m:
Supplementary magic sets transformation. Report errors
for constructs that Aditi can't handle.
compiler/context.m:
Supplementary context transformation.
compiler/rl_gen.m:
compiler/rl_relops.m:
Aditi code generation.
compiler/rl_info.m:
Code generator state.
compiler/rl.m:
Intermediate RL representation.
compiler/rl_util:
Predicates to collect information about RL instructions.
compiler/rl_dump.m:
Print out the representation in rl.m.
compiler/rl_opt.m:
Control low-level RL optimizations.
compiler/rl_block.m:
Break a procedure into basic blocks.
compiler/rl_analyse.m:
Generic dataflow analysis for RL procedures.
compiler/rl_liveness.m:
Make sure all relations are initialised before used, clear
references to relations that are no longer required.
compiler/rl_loop.m:
Loop invariant removal.
compiler/rl_block_opt.m:
CSE and instruction merging on basic blocks.
compiler/rl_key.m:
Detect upper/lower bounds for which a goal could succeed.
compiler/rl_sort.m:
Use indexing for joins and projections.
Optimize away unnecessary sorting and indexing.
compiler/rl_stream.m:
Detect relations which don't need to be materialised.
compiler/rl_code.m:
RL bytecode definitions. Automatically generated from the Aditi
header files.
compiler/rl_out.m:
compiler/rl_file.m:
Output the RL bytecodes in binary to <module>.rlo (for use by Aditi)
and in text to <module>.rla (for use by the RL interpreter).
Also output the schema information if --generate-schemas is set.
compiler/rl_exprn.m:
Generate bytecodes for join conditions.
extras/aditi/Mmakefile:
extras/aditi/aditi.m:
Definitions of some Aditi library predicates and the
interfacing and transaction processing code.
Estimated hours taken: 20
These changes make `var' and `term' polymorphic. This allows us to make
variables and terms representing types of a different type to those
representing program terms and those representing insts.
These changes do not *fix* any existing problems (for instance
there was a messy conflation of program variables and inst variables,
and where necessary I've just called varset__init(InstVarSet) with
an XXX comment).
NEWS:
Mention the changes to the standard library.
library/term.m:
Make term, var and var_supply polymorphic.
Add new predicates:
term__generic_term/1
term__coerce/2
term__coerce_var/2
term__coerce_var_supply/2
library/varset.m:
Make varset polymorphic.
Add the new predicate:
varset__coerce/2
compiler/prog_data.m:
Introduce type equivalences for the different kinds of
vars, terms, and varsets that we use (tvar and tvarset
were already there but have been changed to use the
polymorphic var and term).
Also change the various kinds of items to use the appropriate
kinds of var/varset.
compiler/*.m:
Thousands of boring changes to make the compiler type correct
with the different types for type, program and inst vars and
varsets.
Estimated hours taken: 20
Fix a bug with intermodule optimization of nested modules.
Previously, the compiler used to just label any
predicates defined in a module containing sub-modules
as `exported', since they may be needed by the separately-compiled
sub-modules. However, this is a little bit of a lie,
and it turns out that it doesn't work. The fix is
to use a new status `exported_to_submodules' for this case.
compiler/prog_data.m:
Add a new pseudo-declaration ":- private_interface",
used to mark items in an ":- implementation" section
that will be exported to submodules.
compiler/modules.m:
Put declarations from modules containing sub-modules into
`private_interface' sections rather than into `interface' sections.
compiler/hlds_pred.m:
Add a new alternative `exported_to_submodules' to the
`import_status' data type. Add several new procedures
for testing particular aspects of this type.
compiler/module_qual.m:
Set the import_status of items in a `private_interface'
section to `exported_to_submodules'.
compiler/intermod.m:
Handle procedures with status `exported_to_submodules'
specially. Also reorganize the code here a bit to make
it more maintainable.
compiler/base_type_info.m:
compiler/base_type_info.m:
compiler/base_typeclass_info.m:
compiler/code_util.m:
compiler/dead_proc_elim.m:
compiler/hlds_out.m:
compiler/make_hlds.m:
compiler/termination.m:
compiler/unused_args.m:
Minor changes to reflect the above changes to data-structures;
in particular, use the new procedures defined in hlds_pred.m
instead of hard-coded tests. In termination.m, the changes
included deleting some error-checking code that didn't make
much sense anymore when using the new procedures rather than
using hard-coded tests.
tests/hard_coded/Mmakefile:
tests/hard_coded/nested_intermod.m:
tests/hard_coded/nested_intermod_main.m:
tests/hard_coded/nested_intermod_main.exp:
Add a regression test for the bug mentioned above.
Estimated hours taken: 0.5
Fix a bug reported by Renaud Paquay <rpa@miscrit.be>.
compiler/modules.m:
scripts/Mmake.rules:
When invoking Mmake recursively, pass down the values of
MC and ALL_MCFLAGS, in case their values were overridden
on the command line.
Estimated hours taken: 1
Minor improvements to some compiler error messages.
compiler/modules.m:
Fix a missing close-quote in an error message.
Also improve the wording of the message slightly.
compiler/check_typeclass.m:
compiler/typecheck.m:
Add quotes (`...') in a couple of places
tests/invalid/sub*.err_exp:
tests/invalid/typeclass_test*.err_exp:
Update to reflect the new error messages.
tests/invalid/Mmakefile:
Delete an obsolete comment about a poor error message.
Estimated hours taken: 1
compiler/modules.m:
compiler/mercury_compile.m:
Warn about modules with no exports when compiling,
not just when making interfaces. Previous it would
only issue this warning when doing `mmc --make-int',
not when doing `mmc --compile-to-c'.
tests/invalid/Mmakefile:
tests/invalid/no_exports.err_exp:
Enable the already-existing test case for this.
Estimated hours taken: 10
Introduce two new directories, trace and browser, containing libraries
holding the C and Mercury code of the debugger respectively. (Although
the browser directory does not have a browser in it yet, the browser
should soon become its biggest component.) Take the opportunity to
rename the existing libraries, for consistency.
After this change, the linking order becomes:
the object of the auto-generated init file
program object files
trace library (libmer_trace.a)
browser library (libmer_browser.a)
standard library (libmer_std.a)
runtime library (libmer_rt.a)
Boehm collector (libgc.a)
To avoid circularities, libraries cannot contain direct calls to
any routines that are defined in libraries (or object files) that
occur earlier in the above list. Any such calls must be made into
indirect calls via function pointers.
In particular, there was a circularity caused by the library calling
MR_trace() which invokes the tracer which in turn invokes the
library. This circularity was broken by having MR_trace(),
which is defined in the runtime, call the tracer indirectly via
a global variable named MR_trace_func_ptr. This global variable
is initialized by the auto-generated *_init.c file.
To avoid linking in the tracer even when it is not being used,
this global variable is only set to point to MR_trace_real()
if you're using a debugging grade or if c2init was invoked
with the `-t' flag. Otherwise it is set to MR_trace_fake()
which just prints an error message telling the user to
rebuild the executable with debugging enabled.
Makefile.DLLs:
Reserve random locations for the two new libraries. Whether they work
will be decided by testing on Windows.
Mmake.common.in:
Add variables naming the new directories, and create variables
naming the libraries.
Mmakefile:
Add targets for the new directories, and modify existing rules
as appropriate.
browser/Mmakefile:
Mmakefile for the new directory, modelled on library/Mmakefile.
browser/browser_library.m:
Umbrella file for the new directory, modelled on library/library.m.
{browser,library}/debugger_interface.m:
Moved this file from library to browser without change.
browser/help.m:
A new module for the help system of the debugger. Not yet used.
compiler/Mmakefile:
Update to refer to the new directories and libraries where
appropriate.
compiler/mercury_compile.m:
If we are doing tracing, then pass -t instead of -i to c2init.
compiler/modules.m:
When generating the .dep file, get the grade flags passed to c2init.
doc/Mmakefile:
Remove the special treatment of library/debugger_interface.m.
library/Mmakefile:
Update to refer to the new directories and libraries where
appropriate, and to conform to the new name of the library.
library/library.m:
Do not import debugger_interface.
profiler/Mmakefile:
Update to refer to the new directories and libraries where
appropriate.
runtime/Mmakefile:
Update to refer to the new directories and libraries where
appropriate, and to conform to the new name of the library.
Remove references to files being moved to the trace directory.
runtime/mercury_init.h:
Refer to the automatically generated dll header file by its new name
(renamed because the runtime library is renamed).
Add declarations to support the new global variable MR_trace_func_ptr.
runtime/mercury_memory_handlers.c:
runtime/mercury_memory_zones.c:
runtime/mercury_misc.c:
Remove inappropriate #includes of "mercury_trace.h", and substitute
a #include of "mercury_trace_base.h" if necessary.
{runtime,trace}/mercury_trace.[ch]:
{runtime,trace}/mercury_trace_external.[ch]:
{runtime,trace}/mercury_trace_internal.[ch]:
Move these files from the runtime to the trace directory.
The only changes are the removal from mercury_trace.h of declarations
added to runtime/mercury_trace_base.h, and the change from MR_trace
to MR_trace_real.
runtime/mercury_trace_base.[ch]:
Define MR_trace(), which does an indirect call through
MR_trace_func_ptr if the event should be traced.
Define MR_trace_fake, which just prints an error message.
Its address will be assigned to MR_trace_func_ptr if tracing
is not enabled.
Define the types needed by the signature of MR_trace.
Fix an old bug: s/MERCURY_TRACE_PERMANENT_H/MERCURY_TRACE_BASE_H/.
runtime/mercury_wrapper.[ch]:
Add the new global variable MR_trace_func_ptr.
scripts/c2init.in:
Add a new option, -t/--trace, which enables tracing by causing the
address of MR_trace_real to be assigned to MR_trace_func_ptr.
Have this option be implied by the grade. Also have the old option
-i (need initialization code) be implied by the grade, as well as by
-t.
scripts/ml.in:
Include the new libraries in the link command.
tests/debugger/Mmakefile:
Include -t instead of -i in the list of c2init options. (-t implies
-i.)
tools/bootcheck:
Copy and build the new directories as appropriate. The trace directory
is treated like the runtime, the browser directory is treated like the
library.
trace/Mmakefile:
Mmakefile for the new directory, modelled on runtime/Mmakefile.
util/mkinit.c:
Add the new option -t, as discussed above.
Mmakefile for the new directory, modelled on runtime/Mmakefile.
util/Mmakefile:
Specify -O0, since with the default optimization level, gcc on
cyclone ignores the assignment of TRUE to need_tracing when -t is
given (!!!).
Estimated hours taken: 3.5
Fix a bug reported by Warwick Harvey <wharvey@cs.monash.edu.au>
where importing a nested module without first importing the
parent module resulted in a software error when building the
dependencies.
compiler/modules.m:
Change a call to `map__det_insert' into `map__set',
to avoid a `map__det_insert failed' error,
and add some detailed comments explaining why.
tests/invalid/Mmakefile:
tests/invalid/sub_a.m:
tests/invalid/sub_b.m:
tests/invalid/sub_b.err_exp:
tests/invalid/sub_c.m:
tests/invalid/sub_c.err_exp:
Add a couple of test cases.
Estimated hours taken: 0.5
This is a logically a part of my recent changes to Mmake...
I just forgot about this part.
compiler/modules.m:
Use the new `$(ALL_*)' Mmake variables in the generated
`.d' and `.dep' files.
Estimated hours taken: 5
Implement some parts of the support for nested modules that I had
forgotten about.
compiler/modules.m:
Allow the `:- interface' and `:- implementation' parts of
nested modules to be separated.
Check that `:- implementation' declarations for nested
modules don't occur in the interface section of the parent module.
tests/hard_coded/nested3.m:
tests/hard_coded/nested3.exp:
tests/invalid/nested_impl_in_int.m:
tests/invalid/nested_impl_in_int.err_exp:
Test cases for the above-mentioned feature.
tests/hard_coded/Mmakefile:
Add `RM_C=:', so that the nested modules tests work with
parallel makes, and then enable those tests.
Estimated hours taken: 4
compiler/modules.m:
Fix a couple of bugs in the computation of dependencies
for the `--generate-dependencies' option:
(1) it wasn't handling the case where the top-level file named
on the command line contained nested modules
(2) it wasn't including the parent module's dependencies in the
dependencies for child modules.
Estimated hours taken: 2.5
Add an option --use-opt-files, which causes the compiler
to use any `.opt' files which are available when the
dependencies are made, but not make any more `.opt' files.
This is useful for using just the `.opt' files for the library
without building them for the compiler.
compiler/modules.m:
When searching for available `.opt' files, don't look for
`.m' files which could be used to build the `.opt' files
if --use-opt-files is set.
compiler/handle_options.m:
compiler/options.m:
doc/user_guide.texi:
Handle and document --use-opt-files.
Estimated hours taken: 2
compiler/modules.m:
Fix a bug: `read_dependency_file_get_modules' was not handling
the case where the dependencies were generated with the
`--use-subdirs' option enabled.
Estimated hours taken: 2
Fix bugs in `io__make_temp', and improve error messages
in cases of I/O failures.
library/io.m:
Fix two bugs in `io__make_temp':
- it was calling open() but not calling close()
- it was passing a value of type `long' to printf()
with a specified of `%X' instead of `%lX'
Improve the error messages for I/O failures in all the
predicates that open files, read bytes or characters, etc.
compiler/modules.m:
compiler/termination.m:
compiler/unused_args.m:
If file opens fail, print out the error message returned by
io.m. Previously the code didn't print that out because
io.m didn't return anything useful.
compiler/trans_opt.m:
Fix a minor mistake in an error message: s/'/`/
Estimated hours taken: 3
Fix race condition problems with io__tmpnam.
library/io.m:
Add io__make_temp, which is like io__tmpnam except that it
actually creates the file rather than just choosing its name.
This avoids a race condition where some other process could
create a file with the same name in between the call to
io__tmpnam and the call to io__open_output.
Add `pragma obsolete' declarations for io__tmpnam (both versions)
and document that their use is deprecated.
Reimplement io__tmpnam by calling io__make_temp and then
io__remove_file.
Also, add `num_tries' rather than `1' to the counter each time;
this should hopefully reduce contention.
The race condition was being triggered when you started up
multiple processes each of which created multiple temp files
(e.g. when doing `mmake -j2 depend' in the various `tests'
subdirectories).
compiler/modules.m:
compiler/fact_table.m:
s/io__make_temp/io__tmpnam/
Estimated hours taken: 1
Fix a bug which caused link errors in some grades for some test cases
where the module name wasn't the same as the file name, and which
probably would have caused runtime errors in some grades for test
cases using nested modules.
compiler/modules.m:
Call $(C2INIT) with $(foo.cs) instead of $(foo.ms).
This is necessary now that a single .m file can get compiled
to multiple .c files, if it contains nested modules,
or to a .c file whose name reflects the module name rather
than the source file name.
util/mkinit.c:
scripts/c2init.in:
For efficiency, change c2init and mkinit so that when c2init's
arguments are `.c' files, it computes the init function based
on the filename (like it used to do with `.m' files), rather
than by reading the file contents and searching for "** INIT"
comments. Add a new option `-x' (`--extra-inits') which keeps
the old behaviour.
compiler/modules.m:
scripts/Mmake.rules:
Instead of deleting the `_init.c' file every time we recreate
the `.dep' file, just tell make that the `_init.c' file depends on
the `.dep' file, so that make will remake it if the `.dep' file
changes. (I don't know why I didn't do it that way in the
first place.)
Estimated hours taken: 1
compiler/modules.m:
Put library files and `.init' files in the current directory,
rather than in Mercury/libs and Mercury/inits subdirectories,
even if `--use-subdirs' is enabled.
Without this change, the instructions on "Using libraries"
in the Mercury user's guide did not work in conjunction with
`--use-subdirs', and they, as well as a lot of Mmakefiles that
were defined based on them, would need to be changed.
Estimated hours taken: 12
Allow modules to be put in source files whose names do not directly match
their the module names. When looking for the source for a module such
as `foo:bar:baz', search for it first in `foo.bar.baz.m', then in `bar.baz.m',
and finally in `baz.m'.
compiler/prog_io.m:
Change prog_io__read_module so that it returns the name of
the module read, as determined by the `:- module' declaration.
Add predicate `check_module_has_expected_name', for checking
that this name matches what was expected.
compiler/modules.m:
Add read_mod_from_file, for reading a module given the file name,
and generated_file_dependencies, for generating the dependencies
of a module given the file name. (As opposed to the module name.)
Change read_mod and read_mod_ignore_errors so that they
search for `.m' files as described above, and return the name
of the source file read.
Also improve the efficiency of read_dependencies slightly:
when reading in `.int' files, there's no need to call
split_into_submodules, because we generate a seperate
`.int' file for each submodule anyway.
compiler/mercury_compile.m:
Change the handling of command-line arguments.
Arguments ending with `.m' are assumed to be file names,
and other arguments are assumed to be module names.
For file names, call read_mod_from_file instead of read_mod.
compiler/handle_options.m:
Change help message to reflect the above change to the semantics
of command-line arguments.
compiler/intermod.m:
compiler/trans_opt.m:
Fix a bug: call prog_io__read_opt_file instead of prog_io__read_module.
doc/user_guide.texi:
Document the above change to the semantics of command-line arguments.
Update the "libraries" chapter to reflect our support for nested
modules.
tests/*/*.m:
tests/*/*.exp:
Fix a few incorrect module names in `:- module' declarations.
Estimated hours taken: 6
Add Mmake support for nested sub-modules.
compiler/mercury_compile.m:
compiler/modules.m:
compiler/intermod.m:
Pass down the source file name to various places.
Store the source file name in the module_imports data structure.
In various places, use this source file name instead of assuming
that the source file name can be obtained from the module name.
compiler/modules.m:
Change the generated .d and .dep files to use the source file names.
Add hard-coded rules in the .d files if the source file name does not
match the form expected by the pattern rules in scripts/Mmake.rules.
XXX unfortunately the rules don't work right for parallel makes of
nested modules
scripts/Mmake.rules:
Add a comment saying that any changes here might need to
be duplicated in compiler/modules.m.
tests/hard_coded/Mmakefile:
tests/hard_coded/nested.m:
tests/hard_coded/nested2.m:
tests/hard_coded/nested.exp:
tests/hard_coded/nested2.exp:
Add a couple of test cases for nested modules (XXX not enabled,
due to the above-mentioned problem with parallel makes).
doc/reference_manual.texi:
Update the "implementation bugs and limitations" section.
NEWS:
Update the news about nested modules.
Estimated hours taken: 5
Implement compiler support for nested sub-modules.
(Mmake support is still missing, so you have to compile by hand.
Also you must use `ml' to link rather `mmc', because
`mmc' doesn't link all the object files that it generates.)
compiler/prog_io.m:
Fix a couple of bugs in the parsing of `module' and `end_module'
declarations.
compiler/mercury_to_mercury.m:
Handle output of `:- module' and `:- end_module' declarations.
compiler/modules.m:
Add predicate split_into_submodules, which takes the item_list
for a module and splits it into a list of item_lists for each
submodule.
compiler/mercury_compile.m:
Change the code for creating interface files and generating
LLDS fragments so that it calls split_into_submodules and then
iterates over each submodule.
That means that we now generate a seperate HLDS for each submodule, and
compile that to a seperate LLDS and a seperate C file. It would be
more efficient to combine the LLDS fragments for each submodule after
code generation, generate a single C file, and thus only invoke the C
compiler once. In view of this goal, I have done some cleaning up of
the HLDS/LLDS distinction, so that we don't need to pass the HLDS to
the various LLDS output routines. (However, I haven't actually gotten
as far as combining the LLDS code fragments.)
compiler/llds.m:
Add type `c_interface_info' which contains information from the
HLDS that is used during the LLDS output pass.
compiler/mercury_compile.m:
Add a predicate `get_c_interface_info' which gets the relevant
info from the HLDS that is needed for LLDS output.
compiler/export.m:
Add `export__get_c_export_decls', and rename
`export__get_pragma_exported_procs' as `export__get_c_export_defns'.
Change export__produce_header_file so that it takes a `c_export_decls'
(part of the `c_interface_info') instead of an HLDS.
Estimated hours taken: 6
Fix various invasions of the user's namespace by `mercury_builtin.m',
by splitting mercury_builtin.m into two modules, called builtin.m and
private_builtin.m, and ensuring that the latter is imported as if
by `:- use_module' rather than `:- import_module'.
library/builtin.m:
library/private_builtin.m:
Split mercury_builtin.m into two modules, builtin.m,
which contains stuff intended to be public,
and private_builtin.m, which contains implementation
details that are not supposed to be public.
library/mercury_builtin.m:
Add a comment saying that this module is no longer used, and
should eventually be removed. I have not removed it yet, since
that would prevent bootstrapping with the current compiler. It
will be removed as a seperate change later, once all the
changes have propagated.
compiler/prog_util.m:
Change the definition of mercury_private_builtin_module/1 and
mercury_public_builtin_module so that instead of automatically
importing mercury_builtin.m as if by `import_module', the
copiler will now automatically import builtin.m as if by
`import_module' and private_builtin.m as if by `use_module'.
compiler/polymorphism.m:
Change a call to mercury_private_builtin_module/1 for
unsafe_promise_unique to instead call mercury_public_builtin_module/1.
compiler/unify_proc.m:
Avoid hard-coding "mercury_builtin" by instead
calling one of mercury_{private,public}_builtin_module/1.
runtime/mercury_type_info.[ch]:
library/term.m:
library/std_util.m:
compiler/code_util.m:
Change a few hard-coded instances of "mercury_builtin"
to "builtin" or "private_builtin" as appropriate.
runtime/mercury_trace_util.c:
runtime/mercury_trace_internal.c:
library/prolog.m:
compiler/*.m:
Update comments that refer to "mercury_builtin" to instead
refer to either "builtin" or "private_builtin".
doc/Mmakefile:
Don't include the interface to private_builtin.m in the
library reference manual.
tools/bootcheck:
Add `-p'/`--copy-profiler' option. This is needed to get
the above changes to bootstrap.
tools/test_mercury:
Pass `-p' to tools/bootcheck.
tests/term/*.trans_opt_exp:
s/mercury_builtin/builtin/g
Estimated hours taken: 0.01
Fix bug in generation of dependencies for files containing a pragma
`fact_table' declaration. There was an extra .o appended to the end
of the object files that the fact table depended on, this caused Mmake to
fail.
compiler/modules.m :
Remove extraneous ".o" being output to dependency file.
Estimated hours taken: 250
Add support for tabling.
This change allows for model_det, model_semidet and model_non memoing,
minimal model and loop detection tabling.
compiler/base_type_layout.m:
Update comments to reflect new runtime naming standard.
compiler/det_analysis.m:
Allow tabling to change the result of det analysis. This is
necessary in the case of minimal model tabling which can
turn a det procedure into a semidet one.
compiler/det_report.m:
compiler/hlds_data.m:
Add code to report error messages for various non compatible
tabling methods and determinism.
compiler/hlds_out.m:
compiler/modules.m:
Remove reference to the old memo marker.
compiler/hlds_pred.m:
Create new type (eval_method) to define which of the available
evaluation methods should be used each procedure.
Add new field to the proc_info structure.
Add several new predicates relating to the new eval_method type.
compiler/inlining.m:
compiler/intermod.m:
Make sure only procedures with normal evaluation are inlined.
compiler/make_hlds.m:
Add code to process new tabling pragmas.
compiler/mercury_compile.m:
Call the tabling transformation code.
compiler/modes.m:
Make sure that all procedures with non normal evaluation have
no unique/partially instantiated modes. Produce error messages
if they do. Support for partially instantiated modes is currently
missing as it represents a large amount of work for a case that
is currently not used.
compiler/module_qual.m:
compile/prog_data.m:
compiler/prog_io_pragma.m:
Add three new pragma types:
`memo'
`loop_check'
`minimal_model'
and code to support them.
compiler/simplify.m:
Don't report infinite recursion warning if a procedure has
minimal model evaluation.
compiler/stratify.m:
Change the stratification analyser so that it reports cases of
definite non-stratification. Rather than reporting warnings for
any code that is not definitely stratified.
Remove reference to the old memo marker.
compiler/switch_detection.m:
Fix a small bug where goal were being placed in reverse order.
Call list__reverse on the list of goals.
compiler/table_gen.m:
New module to do the actual tabling transformation.
compiler/notes/compiler_design.html:
Document addition of new tabling pass to the compiler.
doc/reference_manual.texi:
Fix mistake in example.
library/mercury_builtin.m:
Add many new predicates for support of tabling.
library/std_util.m:
library/store.m:
Move the functions :
ML_compare_type_info
ML_collapse_equivalences
ML_create_type_info
to the runtime.
runtime/mercury_deep_copy.c:
runtime/mercury_type_info.h:
runtime/mercury_type_info.c:
Move the make_type_info function into the mercury_type_info module
and make it public.
runtime/Mmakefile:
runtime/mercury_imp.h:
Add references to new files added for tabling support.
runtime/mercury_string.h:
Change hash macro so it does not cause a name clash with any
variable called "hash".
runtime/mercury_type_info.c:
runtime/mercury_type_info.h:
Add three new functions taken from the library :
MR_compare_type_info
MR_collapse_equivalences
MR_create_type_info.
runtime/mercury_table_any.c:
runtime/mercury_table_any.h:
runtime/mercury_table_enum.c:
runtime/mercury_table_enum.h:
runtime/mercury_table_int_float_string.c:
runtime/mercury_table_int_float_string.h:
runtime/mercury_table_type_info.c:
runtime/mercury_table_type_info.h:
runtime/mercury_tabling.h:
New modules for the support of tabling.
Estimated hours taken: 0.5
Fix the handling of dependencies on $(MLOBJS) and $(MLPICOBJS)
so that we don't reinvoke the linker for every make, even when
the executable(s) are already up-to-date.
scripts/Mmake.rules:
Delete the MLOBJS and MLPICOBJS targets.
Add `$(MLOBJS_DEPS) : $(MLOBJS)', and likewise for $(MLPICOBJS).
compiler/modules.m:
When generating the `.dep' files, instead of using the MLOBJS
and MLPICOBJS phony targets, record dependencies of files on
$(MLOBJS) by adding those files to $(MLOBJS_DEPS),
and likewise for $(MLPICOBJS).
Estimated hours taken: 0.5
Improve the efficiency of `--use-subdirs' slightly by reducing
the size of the generated `.dep' files.
compiler/modules.m:
When generating the .dep file with `--use-subdirs' enabled,
don't disable compact dependency lists, instead use the
$(cs_subdir), $(os_subdir) etc. variables to make them work.
Estimated hours taken: 6
Fix some problems with the `--use-subdirs' option.
The compiler itself now compiles and bootstraps fine with --use-subdirs.
compiler/modules.m:
Put `.h' files in the source directory, rather than
in the `Mercury/hs' subdirectory.
compiler/mercury_compile.m:
scripts/Mmake.rules:
If `--use-subdirs' is enabled, pass `-I.' to the C compiler,
so that #include statements work relative to the source directory
rather than relative to the `Mercury/cs' subdirectory.
scripts/Mmake.vars.in:
Define $(cs_subdir), $(os_subdir) etc. variables;
these are set to the directory to use for .c, .o, etc. files,
(including the trailing `/'), or to the empty string,
if --use-subdirs is not set.
scripts/Mmake.rules:
Use $(cs_subdir), $(os_subdir) etc. to avoid the code
duplication created by my previous change to handle
--use-subdirs.
Also add lots of comments, and reorder the code
in a more logical order.
Mmakefile:
library/Mmakefile:
compiler/Mmakefile:
profiler/Mmakefile:
tests/term/Mmakefile:
tests/valid/Mmakefile:
Use $(cs_subdir), $(os_subdir) etc. to fix a few hard-coded
file-names (e.g. *.dep, *_init.[co], tree234.o) that were
used in some of the rules.
library/Mmakefile:
Add `rm -f tags' to the rule for `mmake realclean'.
tools/bootcheck:
Add `--use-subdirs' option (defaults to setting of the
MMAKE_USE_SUBDIRS environment variable).
Change the code which compares the stage2 & stage3 C files
to use the appropriate location for them based on the
setting of this option.
Estimated hours taken: 4
Fix a limitation of the current nested module support:
ensure that we check for attempts to import inaccessible modules.
compiler/modules.m:
Check for attempts to import inaccessible modules
(modules whose parent has not been imported,
or for which there is no `include_module'
declaration in the parent's interface).
compiler/intermod.m:
Modify the way we import `.opt' files. The previous method
temporarily set the items field of the module_imports
structure to [], but check_module_accessibility relies
on the assumption that the items field contains the
items for all modules previously read in.
tests/invalid/Mmakefile:
tests/invalid/test_nested.m:
tests/invalid/test_nested.err_exp:
tests/invalid/parent.m:
tests/invalid/parent.private_child.m:
tests/invalid/parent.public_child.m:
tests/invalid/parent.undeclared_child.m:
tests/invalid/parent.undeclared_child.err_exp:
tests/invalid/parent2.m:
tests/invalid/parent2.child.m:
Add some tests for the above change.
doc/reference_manual.texi:
Update the "bugs and limitations" sub-section of the modules
chapter to reflect the new status quo.
Estimated hours taken: 11
Finish off the centralization of the file name handling code, and
add support for generating intermediate files in subdirectories.
scripts/mmake.in:
Add a new boolean option `--use-subdirs';
if enabled, it just sets the environment variable MMAKE_USE_SUBDIRS
to `yes' before invoking Make.
Also add negative versions of the various options
(`--no-use-subdirs', `--no-verbose', `--no-save-makefile').
scripts/Mmake.rules:
Add code to handle generating intermediate file names
in subdirectories. If MMAKE_USE_SUBDIRS=yes, we add
`--use-subdirs' to MCFLAGS, and most of the pattern rules
are changed to use subdirectories.
Note that getting this to work required a bit of a hack:
due to what seem to be bugs in GNU Make, `mmake depend'
needs to do `mmc --make-short-interface *.m' to get things
started. But once the int3s are there, the dependencies
seem to work OK.
compiler/options.m:
Add a new boolean option `--use-subdirs'.
compiler/modules.m:
Add new predicate `fact_table_file_name'.
Add an extra argument to `module_name_to_file_name',
specifying whether or not to create any directories
needed for the file name.
Change all the file-name-creating predicates here
to go through a single new predicate `choose_file_name',
and add code in that predicate to handle the `--use-subdirs'
option.
Also if the `--use-subdirs' option is set, don't use the
compact dependencies format, since it can't work in that case.
compiler/fact_table.m:
Call `fact_table_file_name' rather than using `string__append'.
compiler/mercury_compile.m:
Change `link_module_list' and `join_module_list'
so that they create file names by calling `module_name_to_file_name'.
compiler/export.m:
compiler/intermod.m:
compiler/llds_out.m:
compiler/mercury_compile.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/termination.m:
compiler/trans_opt.m:
compiler/unused_args.m:
Change all calls to `module_name_to_file_name' to pass
the extra argument specifying whether or not to make
any directories needed for the file name.
library/Mmakefile:
Change the rule for `mmake install_ints' so that it
creates a `Mercury' subdirectory with symbolic links
`ints', `int2s', `int3s', `opts', and `trans_opts'
which just point to `..'. This is needed for the
`--use-subdirs' option to work, because Mmake currently
does not support mixing libraries compiled with and
without `--use-subdirs'.
doc/user_guide.texi:
Document the above changes.
Estimated hours taken: 4.5
Change things so that almost all the places which create file names
do so via just a few predicates (such as module_name_to_file_name)
in modules.m. Centralising the file handling in this way
will make future changes to the file naming convention simpler.
(The one place which still creates file names other than via the predicates
declared at the start of modules.m is mercury_compile__link_module_list.
It creates them based on the value of the `-o <filename>' option.
I didn't change that because I am not yet sure what the semantics of
the `-o <filename>' option ought to be.)
compiler/modules.m:
Add three extra arguments to module_name_to_file_name/2:
the file extension, and an io__state pair.
Add new predicates module_name_to_lib_file_name/6,
module_name_to_split_c_file_name/6, and
module_name_to_make_var_name/2.
compiler/export.m:
compiler/intermod.m:
compiler/llds_out.m:
compiler/mercury_compile.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/termination.m:
compiler/trans_opt.m:
compiler/unused_args.m:
Change all calls to module_name_to_file_name/2 to instead
call one of the above-mentioned predicates in modules.m.
compiler/llds_out.m:
Add new predicate llds_out__make_init_name/2 which returns
the name of the initialization function for a module,
for use by modules.m.
compiler/modules.m:
A few minor changes to the generated .dep files:
- add a new phony target `foo.trans_opt',
to match `foo.opt';
- change the generated rule for `change_clean'
so that it removes `.pic_o' files;
- add `.PHONY' declarations for phony targets;
- change the generated rule for making `foo.init'
so that it used the names returned by
llds_out__make_init_name/2, rather than
using "mercury__`basename foo.m .m`__init";
- fix a bug in the generated rule for making `libfoo.a':
it had `rm -f foo.a' instead of `rm -f libfoo.a'.
Estimated hours taken: 0.5
Fix a bug that I introduced in modules.m.
The log message for my previous change was:
- generate_dependencies was using the transitive implementation
dependencies rather than the transitive interface dependencies
to compute the `.int3' dependencies when writing `.d' files
(this bug was introduced during crs's changes to support
`.trans_opt' files)
Unfortunately using the transitive interface dependencies is not quite
right either. You need to take the composition of the implementation
dependencies and the transitive interface dependencies.
For the moment I'll just back out this change, since the impact of the
previous bug was much less than the impact of the one I replaced it with.
Estimated hours taken: 3
Fix bugs in how MLOBJS works.
Because mmake puts the contents of the .dep file before the Mmakefile
when generating a makefile for gmake, the scheme of using
MLOBJS=foo.o bar.o
in the Mmakefile won't work.
The dependencies in the .dep file such as
libxyz.a: ..... $(MLOBJS)
are expanded when read, but the variable MLOBJS is not set until later.
This means MLOBJS won't be generated from the .c files, and the linker
will abort, complaining that files are missing.
So the solution is to output
libxyz.a: ..... MLOBJS
where MLOBJS is a target, and is defined in Mmake.rules (which is seen
by make after the contents of Mmakefile).
MLOBJS: $(MLOBJS).
(In fact, it gets more complicated: to support different MLOBJS variables
for different programs/libraries, so we use MLOBJS-xyz as the target,
and a pattern matching rule in Mmake.rules).
This must also be done for MLPICOBJS.
compiler/modules.m:
Output the targets instead of the variables.
scripts/Mmake.rules:
Pattern match MLOBJS-% and MLPICOBJS-% dependencies, and make
them depend on the corresponding variables.
Estimated hours taken: 8
Add support for the use of partial module qualifiers,
e.g. using `child:foo' to refer to `parent🧒foo'.
Previously we only allowed names to be fully-qualified
or completely unqualified.
Note that we still don't yet keep track of which modules are visible,
so this change does not properly handle the distinction between
`import_module' and `use_module' declarations for parent modules.
It basically assumes that `child:foo' is allowed iff plain `foo'
would be allowed (i.e. iff `parent:child' has been imported)
whereas it ought to be allowed iff `parent' has been imported.
compiler/modules.m:
Add get_partial_qualifiers/2, for use by make_hlds.m
and hlds_module.m.
compiler/make_hlds.m:
Insert partially-qualified symbols into the cons_table.
compiler/hlds_module.m:
Insert partially-qualified symbols into the pred_table.
compiler/module_qual.m:
When searching the symbol tables used for types, insts, modes,
and typeclasses, search for partially-qualified symbols.
compiler/modecheck_unify.m:
When module-qualifying cons_ids, make sure that we fully module
qualify them even if they're already partially qualified.
tests/hard_coded/parent.m:
tests/hard_coded/parent.child.m:
tests/hard_coded/parent.child2.m:
tests/hard_coded/parent.exp:
tests/hard_coded/parent2.m:
tests/hard_coded/parent2.child.m:
tests/hard_coded/parent2.exp:
Uncomment the previously-failed test of using partially-qualified
symbol names. Add a new child module, `parent.child2', and import it
using `use_module', so that we test `use_module' as well as
`import_module'. Add code to test importing of types and
constructors.
Estimated hours taken: 50
Add support for nested modules.
- module names may themselves be module-qualified
- modules may contain `:- include_module' declarations
which name sub-modules
- a sub-module has access to all the declarations in the
parent module (including its implementation section).
This support is not yet complete; see the BUGS and LIMITATIONS below.
LIMITATIONS
- source file names must match module names
(just as they did previously)
- mmc doesn't allow path names on the command line any more
(e.g. `mmc --make-int ../library/foo.m').
- import_module declarations must use the fully-qualified module name
- module qualifiers must use the fully-qualified module name
- no support for root-qualified module names
(e.g. `:parent:child' instead of `parent:child').
- modules may not be physically nested (only logical nesting, via
`include_module').
BUGS
- doesn't check that the parent module is imported/used before allowing
import/use of its sub-modules.
- doesn't check that there is an include_module declaration in the
parent for each module claiming to be a child of that parent
- privacy of private modules is not enforced
-------------------
NEWS:
Mention that we support nested modules.
library/ops.m:
library/nc_builtin.nl:
library/sp_builtin.nl:
compiler/mercury_to_mercury.m:
Add `include_module' as a new prefix operator.
Change the associativity of `:' from xfy to yfx
(since this made parsing module qualifiers slightly easier).
compiler/prog_data.m:
Add new `include_module' declaration.
Change the `module_name' and `module_specifier' types
from strings to sym_names, so that module names can
themselves be module qualified.
compiler/modules.m:
Add predicates module_name_to_file_name/2 and
file_name_to_module_name/2.
Lots of changes to handle parent module dependencies,
to create parent interface (`.int0') files, to read them in,
to output correct dependencies information for them to the
`.d' and `.dep' files, etc.
Rewrite a lot of the code to improve the readability
(add comments, use subroutines, better variable names).
Also fix a couple of bugs:
- generate_dependencies was using the transitive implementation
dependencies rather than the transitive interface dependencies
to compute the `.int3' dependencies when writing `.d' files
(this bug was introduced during crs's changes to support
`.trans_opt' files)
- when creating the `.int' file, it was reading in the
interfaces for modules imported in the implementation section,
not just those in the interface section.
This meant that the compiler missed a lot of errors.
library/graph.m:
library/lexer.m:
library/term.m:
library/term_io.m:
library/varset.m:
compiler/*.m:
Add `:- import_module' declarations to the interface needed
by declarations in the interface. (The previous version
of the compiler did not detect these missing interface imports,
due to the above-mentioned bug in modules.m.)
compiler/mercury_compile.m:
compiler/intermod.m:
Change mercury_compile__maybe_grab_optfiles and
intermod__grab_optfiles so that they grab the opt files for
parent modules as well as the ones for imported modules.
compiler/mercury_compile.m:
Minor changes to handle parent module dependencies.
(Also improve the wording of the warning about trans-opt
dependencies.)
compiler/make_hlds.m:
compiler/module_qual.m:
Ignore `:- include_module' declarations.
compiler/module_qual.m:
A couple of small changes to handle nested module names.
compiler/prog_out.m:
compiler/prog_util.m:
Add new predicates string_to_sym_name/3 (prog_util.m) and
sym_name_to_string/{2,3} (prog_out.m).
compiler/*.m:
Replace many occurrences of `string' with `module_name'.
Change code that prints out module names or converts
them to strings or filenames to handle the fact that
module names are now sym_names intead of strings.
Also change a few places (e.g. in intermod.m, hlds_module.m)
where the code assumed that any qualified symbol was
fully-qualified.
compiler/prog_io.m:
compiler/prog_io_goal.m:
Move sym_name_and_args/3, parse_qualified_term/4 and
parse_qualified_term/5 preds from prog_io_goal.m to prog_io.m,
since they are very similar to the parse_symbol_name/2 predicate
already in prog_io.m. Rewrite these predicates, both
to improve maintainability, and to handle the newly
allowed syntax (module-qualified module names).
Rename parse_qualified_term/5 as `parse_implicit_qualified_term'.
compiler/prog_io.m:
Rewrite the handling of `:- module' and `:- end_module'
declarations, so that it can handle nested modules.
Add code to parse `include_module' declarations.
compiler/prog_util.m:
compiler/*.m:
Add new predicates mercury_public_builtin_module/1 and
mercury_private_builtin_module/1 in prog_util.m.
Change most of the hard-coded occurrences of "mercury_builtin"
to call mercury_private_builtin_module/1 or
mercury_public_builtin_module/1 or both.
compiler/llds_out.m:
Add llds_out__sym_name_mangle/2, for mangling module names.
compiler/special_pred.m:
compiler/mode_util.m:
compiler/clause_to_proc.m:
compiler/prog_io_goal.m:
compiler/lambda.m:
compiler/polymorphism.m:
Move the predicates in_mode/1, out_mode/1, and uo_mode/1
from special_pred.m to mode_util.m, and change various
hard-coded definitions to instead call these predicates.
compiler/polymorphism.m:
Ensure that the type names `type_info' and `typeclass_info' are
module-qualified in the generated code. This avoids a problem
where the code generated by polymorphism.m was not considered
type-correct, due to the type `type_info' not matching
`mercury_builtin:type_info'.
compiler/check_typeclass.m:
Simplify the code for check_instance_pred and
get_matching_instance_pred_ids.
compiler/mercury_compile.m:
compiler/modules.m:
Disallow directory names in command-line arguments.
compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
compiler/modules.m:
Add a `--make-private-interface' option.
The private interface file `<module>.int0' contains
all the declarations in the module; it is used for
compiling sub-modules.
scripts/Mmake.rules:
scripts/Mmake.vars.in:
Add support for creating `.int0' and `.date0' files
by invoking mmc with `--make-private-interface'.
doc/user_guide.texi:
Document `--make-private-interface' and the `.int0'
and `.date0' file extensions.
doc/reference_manual.texi:
Document nested modules.
util/mdemangle.c:
profiler/demangle.m:
Demangle names with multiple module qualifiers.
tests/general/Mmakefile:
tests/general/string_format_test.m:
tests/general/string_format_test.exp:
tests/general/string__format_test.m:
tests/general/string__format_test.exp:
tests/general/.cvsignore:
Change the `:- module string__format_test' declaration in
`string__format_test.m' to `:- module string_format_test',
because with the original declaration the `__' was taken
as a module qualifier, which lead to an error message.
Hence rename the file accordingly, to avoid the warning
about file name not matching module name.
tests/invalid/Mmakefile:
tests/invalid/missing_interface_import.m:
tests/invalid/missing_interface_import.err_exp:
Regression test to check that the compiler reports
errors for missing `import_module' in the interface section.
tests/invalid/*.err_exp:
tests/warnings/unused_args_test.exp:
tests/warnings/unused_import.exp:
Update the expected diagnostics output for the test cases to
reflect a few minor changes to the warning messages.
tests/hard_coded/Mmakefile:
tests/hard_coded/parent.m:
tests/hard_coded/parent.child.m:
tests/hard_coded/parent.exp:
tests/hard_coded/parent2.m:
tests/hard_coded/parent2.child.m:
tests/hard_coded/parent2.exp:
Two simple tests case for the use of nested modules with
separate compilation.
Estimated hours taken: 0.75
compiler/modules.m:
Fix a bug with parallel makes where the `.d' files were being
stuffed up because two different invocations of the Mercury
compiler were writing to them at the same time.
The problem occurs because the `.d' file is written out
both when creating the `.c' file and when creating the
`.trans_opt' file, and these steps might happen in parallel.
The fix is to write the dependency file to a unique temporary
file name and then rename it to the desired `.d' file name when
we're done. This ensures that the update to the `.d' file is atomic.
[In theory this is not a 100% portable solution, because
rename() might not be atomic, but in practice it should be
fine, because rename() is atomic on all the platforms of
interest (i.e. all the ones that support parallel GNU make).]
An alternative fix would be to not write out the `.d' files
when creating `.trans_opt' files. This would also be more
efficient. However, the danger is that the `.d' files might
not be updated often enough. I'm not really sure exactly
how often they need to be updated, but the fix using
renaming seems safer. Also the same problem could occur
when doing `mmake foo.depend bar.depend -j2': if modules
`foo' and `bar' both import another module `baz', then
the two processes may attempt to write `baz.d' simultaneously.
(This happened with printlist.d in the tests/benchmarks directory.)
So I think the fix using renaming is the right one.
Estimated hours taken: 0.5
Fix a bug reported by Tomas By which caused multiple
definition errors when two modules used a third
module, and one of the modules imported the other.
compiler/modules.m
Delay processing of short interfaces until all long
interfaces have been read to avoid reading both
the long and short interface for a module.
tests/valid/module_*.m
Add a test case.
Estimated hours taken: 1
Print out a warning for clauses (etc.) in module interfaces.
This was already done when creating the interface files,
but invalid code could slip past without a warning if
it occured in the topmost module (whose interface is not used,
and hence not created).
compiler/make_hlds.m:
Print out a warning for clauses or certain pragmas (e.g.
`pragma c_code') in module interfaces.
Also inprove the maintainability of the code a little,
by moving some code out into subroutines.
compiler/modules.m:
Export pragma_allowed_in_interface/2, for use by make_hlds.m.
Estimated hours taken: 2
Add support to Mmake for new variables MLOBJS and MLPICOBJS,
since simply listing object files in MLLIBS doesn't do the
right thing in the case when you're building a library package
rather than a program.
scripts/Mmake.vars.in:
Add definitions of MLOBJS and MLPICOBJS.
compiler/modules.m:
Add code to use the $(MLOBJS) and $(MLPICOBJS) variables
to the rules for building programs and libraries that are
output in the generated `.dep' files.
doc/user_guide.texi:
Document the use of MLOBJS and MLPICOBJS.
Estimated hours taken: 1
compiler/modules.m:
Fix a bug where read_dependency_file_find_start was getting some
false hits. It was supposed to be looking for the first line of
foo.trans_opt : \
bar.trans_opt \
baz.trans_opt
but because the test was a bit too loose, it was matching
foo.trans_opt foo.opt ... : \
bar.int \
baz.int2
The effect was that the --warn-missing-trans-opt-deps option
didn't work.
Also make the output a bit more consistent by inserting and
deleting a spaces in a few places.
Estimated hours taken: 0.25
compiler/modules.m:
Add a command to the rule for `mmake clean' int the
generated `.dep' files to remove the `.pic_o' files.