Commit Graph

132 Commits

Author SHA1 Message Date
Zoltan Somogyi
08d84a144d Put the op_mode in the globals.
compiler/globals.m:
    Put the op_mode into the globals structure.

compiler/handle_options.m:
    Invoke the code that computes the op_mode *before* creating the globals.
    Delete the code duplication concerning the computation of the Link flag.

compiler/op_mode.m:
    New module containing the definition of the op_mode type,
    and the predicate that figures out the op_mode from the values of options.
    These are taken from mercury_compile.m, and the latter is adapted
    to work on the option_table, not the globals, since it is now invoked
    as *part* of the code to build up the globals.

compiler/libs.m:
compiler/notes/compiler_design.html:
    Include the new module.

    Do not include the atsort.m module in the libs package, since it
    hasn't been used in a long time, and its inclusion adds to the bulk
    of the compiler executable without any compensating gain.

compiler/mercury_compile.m:
    Delete the code now in op_mode.m.

    Conform to the changes above.

compiler/make.m:
compiler/make.program_target.m:
compiler/make.util.m:
    Conform to the changes above.

compiler/mercury_compile_erl_back_end.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_compile_mlds_back_end.m:
    Standardise dividing lines.
2015-10-14 03:06:46 +11:00
Zoltan Somogyi
0768cc0832 Have handle_options.m return errors as error_specs, not strings.
compiler/handle_options.m:
    As above.

    Generate warnings the same way as we generate errors, since unlike strings,
    error_specs can support the distinction.

    Use more consistent phraseology in error messages.

    Use auxiliary predicates to lookup up bool, int, string and accumulating
    options, thus factoring out some old common code.

compiler/error_util.m:
    Add a way to assign a phase to errors discovered during option processing.

compiler/make.program_target.m:
compiler/make.util.m:
compiler/mercury_compile.m:
    Conform to the changes in handle_options.m.

compiler/make.m:
    Fix white space.
2015-10-13 18:26:53 +11:00
Zoltan Somogyi
baa889df53 Improve the style of the make package.
Convert (C->T;E) to (if C then T else E).

Avoid the use of DCGs.

Rename some predicates to avoid ambiguities.

Delete some unused predicate arguments.

Replace several lambdas with named predicates.

Avoid the use of solutions.m.
2015-10-13 03:24:49 +11:00
Zoltan Somogyi
c2473a20f3 Delete unused imports. 2015-09-21 18:16:24 +10:00
Julien Fischer
3dd02876a5 Delete the MLDS->IL backend.
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_managed.m:
compiler/il_peephole.m:
compiler/ilasm.m:
compiler/ilds.m:
    Delete the modules making up the MLDS->IL code generator.

compiler/globals.m:
compiler/prog_data.m:
    Delete IL as a target and foreign language.

compiler/prog_io_pragma.m:
    Delete the max_stack_size/1 foreign proc attribute.  This was only
    ever required by the IL backend.

compiler/options.m
    Delete options used for the IL backend.

compiler/write_deps_file.m:
    Don't generate mmake targets for .il files etc.

compiler/*.m:
    Conform to the above changes.

compiler/notes/compiler_design.html
compiler/notes/work_in_progress.html
    Conform to the above changes.

library/*.m:
    Delete IL foreign_proc and foreign_export pragmas.

README.DotNet:
    Delete this file.

browser/Mmakefile:
compiler/Mmakefile:
deep_profiler/Mmakefile:
mdbcomp/Mmakefile:
mfilterjavac/Mmakefile:
profiler/Mmakefile:
runtime/Mmakefile:
slice/Mmakefile:
    Conform the above changes.

configure.ac:
    Don't check that IL is a supported foreign language when performing the
    up-to-date check.

    Delete the '--enable-dotnet-grades' option.

scripts/Mmake.vars.in:
    Delete variables used for the IL backend (and in on case by the Aditi
    backend).

scripts/Mercury.config.bootstrap.in:
scripts/Mercury.config.in:
scripts/Mmake.rules:
scripts/canonical_grade.sh-subr:
tools/bootcheck:
    Delete stuff related to the 'il' and 'ilc' grades.

doc/reference_manual.texi:
     Delete the documentation of the 'max_stack_size' option.

doc/user_guide.texi:
     Delete stuff related to the IL backend.

tests/hard_coded/csharp_test.{m,exp}:
tests/invalid/foreign_type_missing.{m,err_exp}:
tests/valid/csharp_hello.m:
	Delete these tests: they are no longer relevant.

tests/hard_coded/equality_pred_which_requires_boxing.m:
tests/hard_coded/foreign_import_module.m:
tests/hard_coded/foreign_import_module_2.m:
tests/hard_coded/foreign_type.m:
tests/hard_coded/foreign_type2.m:
tests/hard_coded/foreign_type3.m:
tests/hard_coded/intermod_foreign_type2.m:
tests/hard_coded/lp.m:
tests/hard_coded/user_compare.m:
tests/invalid/foreign_type_2.m:
tests/invalid/foreign_type_missing.{m,err_exp}:
tests/invalid/foreign_type_visibility.m:
tests/invalid/illtyped_compare.{m,err_exp}:
tests/submodules/external_unification_pred.m
tests/valid/big_foreign_type.m
tests/valid/solver_type_bug.m
tests/valid_seq/foreign_type_spec.m
tests/valid_seq/intermod_impure2.m
    Delete IL foreign_procs where necessary.

tests/hard_coded/Mmakefile
tests/invalid/Mercury.options
tests/invalid/Mmakefile
tests/submodules/Mmakefile
tests/valid/Mercury.options
tests/valid/Mmake.valid.common
tests/valid/Mmakefile
tests/valid_seq/Mmakefile
tests/valid_seq/Mercury.options
    Conform to the above changes.
2015-09-21 11:34:46 +10:00
Zoltan Somogyi
ef44f50bee Eliminate the old module_defn item.
After my earlier changes to the item list, we used module_defns for only
two things: recording when one module includes another, and recording
when one module imports or uses another. After this diff, both those
pieces of information are stored separately in each item block.
This has two benefits.

The first benefit is that it allows us to use the type system to enforce
structural invariants about where include_module, import_module and use_module
declarations may appear. The one invariant that we now enforce is that
optimization files may not contain either include_module or import_module
declarations, though they may contain use_module declarations. I suspect that
there are also similar invariants about interface files, but finding them
requires something like this change.

The second benefit is that it allows traversals of item blocks to scan
only the part of the item block that may contain the object of interest.
While reading in interface and optimization files, we used to scan the
full item list several times to find included and imported modules; those
scans can now look at just the relevant information. Since the item lists
that need to be processed usually include all the declarations in a
substantial number of other modules, including some (such as list.m) that
have LOTS of declarations, the speedup can be substantial. On tools/speedtest,
the speedup is 1.5%.

compiler/prog_item.m:
    Make the change described above.

    Provide utility predicates on the new types representing include_module,
    import_module and use_module declarations.

    Move an old utility predicate from here to prog_io.m, since only prog_io.m
    uses it.

compiler/module_imports.m:
    Several fields of the module_imports type contained sets of module names,
    but stored them as lists. Change these to actual sets, to distinguish them
    from the lists whose order is actually important. (Basically, the order
    of processing .trans_opt files is important, but the order in which
    we read in .int0, .int3, .int2, .int and .opt files isn't.) In several
    places, this also avoids the need for conversions of lists to sets
    for set operations, and then back to lists.

compiler/modules.m:
    This module had several predicates that processed list of module names.
    Make these operate on sets of module names instead, and break each of them
    into two predicates: one that decides whether there is a next module name,
    and if yes whether it has been processed already, and one to do the actual
    processing if needed. This avoid the need for excessive indentation.

    The code that discovers what other modules' interface files may need
    to be read is now simpler due to the updated item_block structure.

    Remove the submodule whose job it was to discover what modules are included
    in items or item blocks, since that task has now become trivial, and is
    now done by a utility predicate in prog_item.m. Since this was the second
    last submodule (of the original eight), the last submodule is now the
    whole module. Therefore this module now has significantly greater cohesion
    than it had before.

compiler/write_module_interface_files.m:

compiler/prog_io_item.m:
    Parse include_module, import_module and use_module declarations as
    markers, not as items.

compiler/prog_io.m:
    Expect include_module, import_module and use_module declarations as
    markers, not as items.

compiler/split_parse_tree_src.m:
    Discover included submodules more simply with the updated item_block
    structure.

compiler/compile_target_code.m:
    Put the arguments of the predicates in this module in a more standard
    order.

compiler/recompilation.version.m:
    Conform to the above changes. Note a possible bug.

    Use a bespoke type to replace some bools.

compiler/check_raw_comp_unit.m:
compiler/comp_unit_interface.m:
compiler/deps_map.m:
compiler/equiv_type.m:
compiler/generate_dep_d_files.m:
compiler/get_dependencies.m:
compiler/hlds_module.m:
compiler/intermod.m:
compiler/item_util.m:
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make_hlds_passes.m:
compiler/mercury_compile.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_to_mercury.m:
compiler/module_deps_graph.m:
compiler/module_qual.m:
compiler/prog_io_find.m:
compiler/read_modules.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/trans_opt.m:
compiler/write_deps_file.m:
    Conform to the above changes.

mdbcomp/sym_name.m:
    Provide a utility predicate to get the set of ancestors of a module
    as a set as well as a list.

tests/invalid/exported_unify3.err_exp:
tests/invalid/ii_parent.ii_child.err_exp:
    Update the expected error messages, which refer to line numbers in
    .int0 files, which have now changed, as we now put all import_module
    declarations before ordinary items.

    (Error messages shouldn't refer to automatically generated files,
    but that is a separate concern.)
2015-08-11 21:56:01 +10:00
Zoltan Somogyi
f91bad4579 Carve generate_dep_d_file.m out of modules.m.
The predicates in modules.m that generate .dep and .d files are independent
of the rest of that module, so moving them out into a new module improves
both modules' cohesion.

compiler/generate_dep_d_file.m:
    New module containing the code moved out of modules.m, as well as
    some code moved here from module_deps_graph.m, since it was called
    only from here.

    Give some predicates more descrriptive names.

compiler/parse_tree.m:
compiler/notes/compiler_design.html:
    Mention the new module.

compiler/modules.m:
    Remove the stuff moved to generate_dep_d_file.m.

compiler/make.program_target.m:
    Move here a predicate from module_deps_graph.m, since it was only called
    from here.

compiler/write_deps_file.m:
    Move here a predicate from module_deps_graph.m, since it was only called
    from here.

compiler/module_deps_graph.m:
    Remove the stuff moved to generate_dep_d_file.m, make.program_target.m
    or write_deps_file.m. What is left does only one job, and it is needed
    by both generate_dep_d_file.m and make.program_target.m.

compiler/mercury_compile.m:
    Conform to the changes above.
2015-08-02 07:16:53 +10:00
Julien Fischer
9acc9db555 Generate executables in the Java grade as JARs.
When building an executable in the Java grade, the Mercury compiler generates
all the class files in the Mercury subdirectory and then generates a wrapper
script or batch file that points towards these class files.  This makes
deploying executables built in the Java grade rather awkward.  This change
makes the Mercury compiler package up all the class files for an executable
into a JAR file and modifies the wrapper scripts to point to this JAR file.

NOTE: the JAR file we generate cannot be executed with 'java -jar ...'.  This
is because in that mode of operation the Java interpreter ignores all user
classpath settings, such as those that tell the interpreter where the Mercury
standard library is.  (We could support this mode of operation by setting any
required library classpath directories in the archive's manifest, but that
would mean either hardcoding installation specific directories in the manifest
or copying any required .jars to a known location relative to the executable's
class files.  Generating such self-contained archives may be useful in some
cases, but it is not something this change addresses.)

compiler/compile_target_code.m:
        Rename the link target type for Java executables.

        Add a predicate for creating Java "executables": this involves generating
        an archive (as we do for libraries) and then generating the wrapper script
        or batch file.

        Simplify some code that generates an error message.

compiler/module_cmds.m:
        Change the wrapper scripts for Java executables to point towards
        the .jar file generated instead of the class files in the Mercury
        subdirectory.

        Ditto for the wrapper batch files.

compiler/make.m:
compiler/make.program_target.m:
compiler/make.util.m:
        Conform to the above changes.

README.Java:
        Mention that class files for the executable are packaged up in
        an archive.

NEWS:
        Announce this change.
2015-04-17 11:27:54 +10:00
Julien Fischer
325e9ff66b Add two new options for querying the compiler.
Add two new options for querying the compiler.  The first new option,
--output-target-arch, prints the target architecture.  This is useful in
situations where you are working directly with the contents of the Mercury
subdirectory and --use-grade-subdirs is enabled.  (The directory names
generated by --use-grade-subdirs include the target architecture.) The second
new option, --output-class-dir, deals with a more specific instance of the
above.  It prints out the name of the directory in which the Mercury compiler
places generated Java class files.

Replace the use of 'fullarch' by 'target_arch' throughout the compiler.
(We still currently support '--fullarch' as a synonym for '--target-arch'
but that too will eventually be dropped.)

compiler/options.m:
	Add the new options.

compiler/mercury_compile.m:
	Implement the new options.

	s/fullarch/target_arch/

	Add an XXX comment about an inaccurate error message.

compiler/handle_options.m:
compiler/compile_target_code.m:
compiler/file_names.m:
compiler/make.program_target.m:
	Conform to the above changes.

doc/user_guide.texi:
	Document the new options.
2014-11-13 11:16:32 +11:00
Zoltan Somogyi
10732f58da Improve the cohesion of modules.m.
Once upon a time, modules.m contained all the code in the compiler that dealt
with interface files, and it was by far the biggest module in the compiler
(almost 9000 lines). Once before, I moved cohesive bunches of functionality
out of modules.m into new modules, such as file_util.m and module_cmds.m.
This diff does likewise, creating three new modules.

Besides that main task, it has two minor algorithmic changes that should
have no overall effect on correctness. First, it merges some traversals of
the item list, which should yield a very minor speedup, and second,
in order to avoid the need for an undesirable module import, it eliminates
an unnecessary sorting of the item list that we used to do when reading
in interface files. (The sorting makes sense only when *creating* interface
files).

This diff also gives more meaningful names to some predicates.

compiler/module_deps_graph.m:
    This new module defines the module dependency graph, and provides
    predicates for building it and using it.

compiler/write_module_iterface_files.m:
    This new module does what its name says it does.

compiler/item_util.m:
    This new module contains utility predicates that deal with items that are
    now needed in more than one module.

compiler/parse_tree.m:
compiler/notes/compiler_design.html:
    Include the new modules.

compiler/write_deps_file.m:
    Move some predicates here from modules.m, since they belong here.
    E.g. one prints .d files, and related code to print .dv and .dep files
    was already here.

compiler/mercury_compile.m:
    Move a predicate here from modules.m, since it was only called from here,
    and related code is also here.

compiler/prog_item.m:
    Move a predicate here from modules.m, since it is a utility predicate
    for a type that is defined here.

compiler/prog_type.m:
    Move a predicate here from modules.m, since it is a utility predicate
    for types, like all the other predicates in this module.

compiler/modules.m:
    Remove the code that is now in other modules. Impose some structure
    on the remaining code. (It used to be too jumbled up to make much sense of,
    which was one reason why working with this code was unnecessarily hard).

compiler/deps_map.m:
    Note the relationship to the new module module_deps_graph.m.

compiler/*.m:
    Import the new modules as well as (or instead of) modules.m, and/or conform
    to new names for predicates.
2014-10-23 19:20:33 +11:00
Julien Fischer
c3c4ec7772 Delete the LLDS->x86_64 asm backend.
No progress has been made on the LLDS->x86_64 backend since the initial work on
it and it is now more have a maintenance headache then anything else.

compiler/llds_to_x86_64.m:
compiler/llds_to_x86_64_out.m:
compiler/x86_64_instrs.m:
compiler/x86_64_out.m:
compiler/x86_64_regs.m:
	Delete these modules.

compiler/globals.m:
	Delete the x86_64 target type.

compiler/*.m:
	Conform to the above changes.
2014-07-30 17:04:29 +10:00
Julien Fischer
55283561ed Fix another problem with --detect-libgrades and --make.
Uses of --no-libgrade and --libgrade in Mercury.options files should override
any detected library grades.  For example, in a directory with a Mercury.options
file that contains

   MCFLAGS = --no-libgrade

we should expect "mmc --output-libgrades" to print nothing.  This was not the case.

compiler/mercury_compile.m:
	Do not combine the detected library grade flags with the ones from
	the command line options.  We need to keep them separate because
	they must be injected into the overall set of command line options
	before any flags from Mercury.options files.

	Add a note about a theoretical problem with DEFAULT_MCFLAGS and
	detected library grades.  It is not a problem in practice because
	the entire point of detected library grades was to avoid passing
	any information about library grades via DEFAULT_MCFLAGS.

	Thread the set of flags from detected grades down to places where
	they are needed.

	If the library grade set is empty, don't print out a single newline
	with --output-libgrades.

compiler/make.m:
compiler/make.program_target.m:
compiler/make.util.m:
	Pass the set of detected grade flags to where they are needed.
2013-09-13 18:11:22 +10:00
Julien Fischer
dd1ff6ac5e Automatically decide the value of --install-command (part 1).
Allow the possibility of the compiler automatically deciding what command(s) to
use to install files and directories instead of using the value of
--install-command (which defaults to "cp").  The eventual intention (NYI) is
that in the absence of a value for --install-command, the compiler will choose
an appropriate command based on the setting of --host-env-type (and possibly
some other stuff, for the example the OS version).

The rationale for all this to try to improve the current situation on Windows
(in the absence of Cygwin or MSYS) where file copying is a bit of a mess.  It
should also mean that the same Mercury installation can be more easily used
from both MSYS and cmd.exe.

NOTE: for the moment --install-command is still specified in Mercury.config.
This will be removed in a later change and the compiler will default to
choosing automatically.

compiler/globals.m:
	Add a type whose values describe how we should install files and
	directories.

	Add a field of that type, file_install_cmd, to the globals structure.

	Add access predicates.

compiler/handle_options.m:
	Set the new field in the globals.

compiler/file_util.m:
	Provide functions for constructing a command line for installing files
	and directories based on the value of the file_install_cmd field in
	the globals.

compiler/make.program_target.m:
compiler/module_cmds.m:
	Use the new functions in file_util.m.
2013-07-30 13:17:15 +10:00
Julien Fischer
f6bdd99a80 Delete the MLDS->GCC (assembler) backend.
As discussed in the recent Mercury meeting, remove support for the GCC backend.
It was very much out of date and supporting it proprerly would means having to
track changes to GCC's internals.  Furthermore, its presence complicates
building the compiler.

The main thing this change does not address is the fact that we invoke
the compiler through C code, e.g. main.c in the top-level of the source
tree.  This was required by the GCC backend and can now be removed, but
I will do that as a separate change.

configure.ac:
Mmake.common.in:
scripts/Mmake.rules:
compiler/Mercury.options:
compiler/Mmakefile:

compiler/gcc.m:
compiler/maybe_mlds_to_gcc.pp:
compiler/mlds_to_gcc.m:
    Delete the files containing the GCC backend.

compiler/options.m:
compiler/handle_options.m:
    Delete support for `--target asm' and `--pic'.
    (The latter was only used by the GCC backend.)

compiler/*.m:
doc/user_guide.texi:
compiler/notes/comiler_design.html:
compiler/notes/work_in_progress.m:
    Conform to the above change.

README.gcc-backend.m:
    Delete this file.
2013-01-16 15:31:10 +11:00
Zoltan Somogyi
16bd4acd2f Shorten lines longer than 79 characters.
Estimated hours taken: 2
Branches: main

compiler/*.m:
	Shorten lines longer than 79 characters.
2012-10-24 05:49:47 +00:00
Peter Wang
d2e304c7a8 Prevent interleaved error message output when using parallel `mmc --make'.
Branches: main

Prevent interleaved error message output when using parallel `mmc --make'.

compiler/make.m:
	Add a field to `make_info' to hold an inter-process lock.

compiler/make.util.m:
	Reuse the `job_ctl' type as the stdout lock.  Add predicates to acquire
	and release the lock.

	Make `foldl2_maybe_stop_at_error_parallel_processes' set the stdout
	lock in `make_info' for child processes to see.

	Acquire and release the stdout lock in various predicates that write
	errors messages.

compiler/make.module_target.m:
compiler/make.program_target.m:
	Conform to changes.
2012-05-11 03:56:48 +00:00
Julien Fischer
6e23455ad7 Fix bug #252: support parallel builds for the various build_all targets with
Branches: main, 11.07

Fix bug #252: support parallel builds for the various build_all targets with
mmc --make.

compiler/make.program_target.m:
	As above.
2012-02-10 06:20:28 +00:00
Peter Wang
339b153efe Fix problems with nested sub-modules and parallel mmc --make.
Branches: main, 11.07

Fix problems with nested sub-modules and parallel mmc --make.

The interface and intermediate target files for nested sub-modules
are built as part of their parent modules.  In sequential mode, there is
no harm in trying to build those files separately, but with parallel
make, two processes may try to create the files from the same parent
module simultaneously.

compiler/make.dependencies.m:
	Add a predicate to remove nested modules from a list.

compiler/make.program_target.m:
	Remove nested modules from the list of intermediate targets to
	create.

	Remove nested modules from the list of interface files to create.
2011-09-02 05:53:09 +00:00
Zoltan Somogyi
295415090e Convert almost all remaining modules in the compiler to use
Estimated hours taken: 6
Branches: main

compiler/*.m:
	Convert almost all remaining modules in the compiler to use
	"$module, $pred" instead of "this_file" in error messages.

	In a few cases, the old error message was misleading, since it
	contained an incorrect, out-of-date or cut-and-pasted predicate name.

tests/invalid/unresolved_overloading.err_exp:
	Update an expected output containing an updated error message.
2011-05-23 05:08:24 +00:00
Julien Fischer
8523c4ddcc Improve consistency amongst the standard library modules.
Branches: main

Improve consistency amongst the standard library modules.

library/array2d.m:
library/bitmap.m:
library/hash_table.m:
library/store.m:
library/thread.semaphore.m:
library/version_array.m:
library/version_array2d.m:
library/version_bitmap.m:
library/version_hash_table.m:
library/version_store.m:
	Use the name "init" for predicates and functions that create new empty
	data structures instead of the name "new".  (The majority of standard
	library modules already use the former.)

	Mark the "new" versions as obsolete.

library/bit_buffer.read.m:
library/bit_buffer.write.m:
library/io.m:
library/thread.mvar.m:
browser/declarative_execution.m:
compiler/make.m:
compiler/make.program_target.m:
ssdb/ssdb.m:
	Conform to the above changes.

NEWS:
	Announce the above changes.
2011-05-08 16:02:23 +00:00
Julien Fischer
78b0bf3c7f Use state variable field update syntax in more places.
Branches: main

Use state variable field update syntax in more places.

browser/*.m:
compiler/*.m:
deep_profiler/*.m:
	As above.
2011-05-05 07:11:52 +00:00
Julien Fischer
9f68c330f0 Change the argument order of many of the predicates in the map, bimap, and
Branches: main

Change the argument order of many of the predicates in the map, bimap, and
multi_map modules so they are more conducive to the use of state variable
notation, i.e. make the order the same as in the sv* modules.

Prepare for the deprecation of the sv{bimap,map,multi_map} modules by
removing their use throughout the system.

library/bimap.m:
library/map.m:
library/multi_map.m:
	As above.
NEWS:
	Announce the change.

	Separate out the "highlights" from the "detailed listing" for
	the post-11.01 NEWS.

	Reorganise the announcement of the Unicode support.

benchmarks/*/*.m:
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
extras/*/*.m:
mdbcomp/*.m:
profiler/*.m:
tests/*/*.m:
ssdb/*.m:
samples/*/*.m
slice/*.m:
	Conform to the above change.

	Remove any dependencies on the sv{bimap,map,multi_map} modules.
2011-05-03 04:35:04 +00:00
Zoltan Somogyi
1c3bc03415 Make the system compiler with --warn-unused-imports.
Estimated hours taken: 2
Branches: main, release

Make the system compiler with --warn-unused-imports.

browser/*.m:
library/*.m:
compiler/*.m:
	Remove unnecesary imports as flagged by --warn-unused-imports.

	In some files, do some minor cleanup along the way.
2010-12-30 11:18:04 +00:00
Zoltan Somogyi
8a28e40c9b Add the predicates sorry, unexpected and expect to library/error.m.
Estimated hours taken: 2
Branches: main

Add the predicates sorry, unexpected and expect to library/error.m.

compiler/compiler_util.m:
library/error.m:
	Move the predicates sorry, unexpected and expect from compiler_util
	to error.

	Put the predicates in error.m into the same order as their
	declarations.

compiler/*.m:
	Change imports as needed.

compiler/lp.m:
compiler/lp_rational.m:
	Change imports as needed, and some minor cleanups.

deep_profiler/*.m:
	Switch to using the new library predicates, instead of calling error
	directly. Some other minor cleanups.

NEWS:
	Mention the new predicates in the standard library.
2010-12-15 06:30:36 +00:00
Peter Wang
fd76da59ff Add support for the csharp' grade to mmc --make', and make it possible to
Branches: main

Add support for the `csharp' grade to `mmc --make', and make it possible to
install the `csharp' grade with `mmake install'.

Also some miscellaneous fixes.


configure.in:
        Require a recent enough bootstrap compiler that recognises C# as a
        language for `pragma foreign_type'.

Mmakefile:
        Use `mmc --make' to install the standard library in csharp grade.

aclocal.m4:
        Search for the Mono C# compiler `gmcs', which is required for generics
        at this time.  Prefer it over the DotGNU C# compiler, which I have not
        tested.

        Search for `mono'.  If found, it will be used in shell scripts to
        launch executables generated via the csharp backend.

        Remove "MS_" prefixes on the variables MS_CSC and MS_ILASM, which are
        not Microsoft-specific.  More importantly, it should be less likely to
        make the mistake of adding an extra underscore to CSCFLAGS and
        ILASMFLAGS.

README.DotNet:
        Conform to variable renamings.

compiler/compile_target_code.m:
        Add new linked target types `csharp_executable', `java_launcher' and
        `erlang_launcher', instead of overloading `executable'.

        Link with `mer_std.dll' and other libraries when generating C#
        executables.  There is no `mer_rt.dll'.

        Pass "/debug" to the C# compiler if `--target-debug' is set.

        Create a shell script to launch the executable if necessary.

        Delete an unused predicate `standard_library_directory_option'.

compiler/file_names.m:
        `.cs' and `.cs_date' are grade-dependent.

compiler/handle_options.m:
        Force `.exe' as the executable file extension in csharp grades.

        Make the `erlang' grade component imply the same options as MLDS
        grades.

compiler/make.m:
        Classify executable target types based on the compilation target.

compiler/make.module_target.m:
        Handle `mmc --grade csharp --make <target>.dll'.

compiler/make.program_target.m:
        Install library DLLs in csharp grades.

        Make clean targets remove files for csharp grades.

        Conform to changes.

compiler/make.util.m:
        Add a stub foreign type.

        Conform to changes.

compiler/module_cmds.m:
        Factor out code to generate the shell scripts which launch programs
        compiled in Java, Erlang and C# grades.

compiler/options.m:
        Add `cli_interpreter' option to remember the name of the program which
        should be used to run CLI (.NET) programs.

        Add C#-related options to the help message.

compiler/options_file.m:
        Remove "MS_" prefixes on MS_ILASM_FLAGS and MS_CSC_FLAGS, and remove
        the extra underscore before "FLAGS".  In all uses of the variables,
        they were spelt without the extra underscore.

doc/user_guide.texi:
        Document options and file types related to the C# grade.

library/Mmakefile:
        Pass `mercury_dotnet.cs' to the C# compiler when building the standard
        library.  Suppress some warnings.

        Allow stubs in this directory for csharp grade.

        Conform to variable renamings.

library/builtin.m:
        Uncomment foreign language pragmas for C#.

        Handle null values in C# implementation of `deep_copy'.

library/private_builtin.m:
library/string.m:
        Compare strings by ordinals in C#, instead of culture-specific rules.
        Although the latter is allowed according to the documentation, it is
        likely to slower, and cause confusion when porting between backends.

        Handle negative index in string.set_char.

library/rtti_implementation.m:
        Uncomment foreign language pragmas for C#.

        `System.Type.GetType' only searches the current executing assembly or
        in mscorlib for a type.  As we have to be able to find types in other
        assemblies (e.g. mer_std.dll or user DLLs), explicitly search through
        a list of assemblies.

library/thread.semaphore.m:
        Uncomment foreign language pragmas for C#.

        Fix missing class qualification.

library/array.m:
library/bitmap.m:
library/bool.m:
library/dir.m:
library/exception.m:
library/io.m:
library/mutvar.m:
library/par_builtin.m:
library/region_builtin.m:
library/store.m:
library/thread.m:
library/time.m:
library/univ.m:
library/version_array.m:
        Uncomment foreign language pragmas for C#.

mdbcomp/rtti_access.m:
        Add type and procedure stubs.

runtime/mercury_dotnet.cs.in:
        Override `Equals(object)' methods in `TypeCtorInfo_Struct' and
        `TypeInfo_Struct' classes.  This requires we override `GetHashCode' as
        well.

        Handle nulls arguments to `Equals' methods as is the expected behaviour.

        Override `ToString' in `TypeCtorInfo_Struct' to produce more useful
        output during debugging.

scripts/Mercury.config.in:
        Record the configured CLI_INTERPRETER and pass that to the compiler as
        a flag.

        Conform to variable renamings.

scripts/Mmake.vars.in:
        Pass value of CSCFLAGS from Mmake through to `mmc --make'.

        Conform to variable renamings.

scripts/Mercury.config.bootstrap.in:
scripts/Mmake.rules:
        Conform to variable renaming.

scripts/canonical_grade.sh-subr:
scripts/final_grade_options.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
        Canonicalise high-level code, high-level-data, C# target code to the
        `csharp' grade.

        Handle erlang grades like other grades.

scripts/prepare_install_dir.in:
        Copy `.cs' files from the runtime directory when preparing an install
        directory.

browser/Mmakefile:
compiler/Mmakefile:
deep_profiler/Mmakefile:
mdbcomp/Mmakefile:
profiler/Mmakefile:
runtime/Mmakefile:
slice/Mmakefile:
ssdb/Mmakefile:
trace/Mmakefile:
        Do as other non-C grades in this directory.

        Conform to variable renamings.

tests/hard_coded/foreign_enum_dummy.m:
tests/hard_coded/sub-modules/non_word_mutable.m:
tests/hard_coded/sub-modules/sm_exp_bug.m:
        Make these tests work in C#.

tests/mmc_make/Mmakefile:
        Update a regular expression to account for `mmc --make' writing
        "Making rebuild.exe" on platforms where the .exe suffix is not normally
        used.

tests/mmc_make/complex_test.exp2:
        Add alternative output (minor difference in floating point precision).

tests/debugger/Mmakefile:
tests/debugger/declarative/Mmakefile:
tests/general/structure_reuse/Mmakefile:
tests/hard_coded/Mmakefile:
tests/hard_coded/sub-modules/Mmakefile:
tests/par_conj/Mmakefile:
tests/stm/Mmakefile:
        Disable some tests in the csharp grade.

tests/invalid/Mmakefile:
        Disable some tests in the csharp grade.

        Enable a test which should work in java grades.

tests/valid/Mmakefile:
        Do as other non-C grades in this directory.

        When testing the csharp grade in this directory, produce only the C#
        target files for now.

tests/run_one_test:
        Don't compress a failing test case executable when the executable is
        actually only a shell script.
2010-09-30 07:23:36 +00:00
Peter Wang
57f9013259 Start a C# backend, adapted from mlds_to_java.m.
Branches: main

Start a C# backend, adapted from mlds_to_java.m.

Some `pragma foreign_*' declarations are commented out in this change because
no bootstrap compiler will yet accept "C#" in the language specification.

The compiler already supported C# foreign_procs for the IL backend, but the IL
backend and this new backend do not agree on naming and calling conventions so
the changes to the existing C# foreign_procs will further break the IL backend.
Nobody cares.

Only tested so far with Mono on Linux.

compiler/mlds_to_cs.m:
        New module.  In the CVS Attic there exists an obsolete file named
        mlds_to_csharp.m (replaced by mlds_to_managed.m) which we don't want to
        conflict with.

        For C# we need to know if a `pragma foreign_type' is a value or
        reference type.  Currently this is done by accepting a fake keyword
        `valuetype' before the type name, like for IL.

compiler/ml_backend.m:
compiler/mercury_compile.m:
compiler/mercury_compile_mlds_back_end.m:
        Hook up the C# backend.

compiler/globals.m:
        Add `target_csharp' as a target language.

compiler/options.m:
        Add `--csharp' and `--csharp-only' options and their synonyms.

compiler/handle_options.m:
        Handle `target_csharp' like `target_java', except for features which
        are still to be implemented.

compiler/add_pragma.m:
        Allow C# as a `pragma foreign_export' language.

        Allow C# for `pragma foreign_export_enum'.

        Conform to changes.

compiler/hlds_data.m:
compiler/prog_data.m:
compiler/prog_io_pragma.m:
        Accept C# as a language for `pragma foreign_type'.

        Accept `csharp' as the name of a grade in trace parameters.

compiler/make_hlds_passes.m:
        Reuse most of the code for implementing mutables on Java for C#.

compiler/mlds.m:
        Add a new MLDS target language, `ml_target_csharp'.

        Conform to changes.

compiler/ml_foreign_proc_gen.m:
        Generate foreign_procs for C#.

compiler/foreign.m:
        Update predicates to support C# targets.

compiler/c_util.m:
        Make `quote_string' use hexadecimal escapes in C# string literals.

compiler/parse_tree.m:
compiler/java_names.m:
        Add C# equivalents for predicates in this module.  `java_names' is a
        misleading module name, but the predicates for C# and Java share some
        code and may possibly be combined in the future.

compiler/rtti.m:
        Add predicates to return the names of RTTI structures in C#.

compiler/simplify.m:
        Handle the trace parameter `grade(csharp)'.

compiler/compile_target_code.m:
compiler/make.dependencies.m:
compiler/make.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
        Add some support for building of executables and libraries with
        `--target csharp'.

compiler/ml_global_data.m:
compiler/ml_optimize.m:
compiler/ml_proc_gen.m:
compiler/ml_switch_gen.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/add_pred.m:
compiler/add_type.m:
compiler/granularity.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/lambda.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_to_mercury.m:
compiler/ml_code_util.m:
compiler/ml_disj_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/modules.m:
compiler/pragma_c_gen.m:
compiler/prog_foreign.m:
compiler/special_pred.m:
compiler/write_deps_file.m:
        Conform to changes.

library/builtin.m:
library/rtti_implementation.m:
library/type_desc.m:
        Implement RTTI procedures for the new backend, which uses a high-level
        data representation (like the Java backend).  The existing C# code was
        designed for the IL backend, which used a low-level representation of
        the RTTI data structures.

        Most (if not all) of the the "new" code is exactly the same as the Java
        versions, with only syntactic changes.

        Rename the C# class `void_0' to `Void_0' to match the naming convention
        used by mlds_to_cs.m.

library/array.m:
        Update the existing C# code to work with the new backend.

        Use `object[]' as the type of all array of non-primitive types.
        The problem is one we encountered on the Java backend: when creating a
        new array based on the type of a single element, we don't know whether
        the new array should contain elements of the class or superclass.

library/bool.m:
        Export `bool' constants to C#.

library/exception.m:
        Update the existing C# code to work with the new backend.

        Move the `mercury.runtime.Exception' C# class to mercury_dotnet.cs.

library/float.m:
        Add C# implementations of `is_nan' and `is_inf'.

library/list.m:
        Add methods for manipulating lists from hand-written C# code.

library/string.m:
        Add C# implementations of string procedures which were missing.

library/dir.m:
library/io.m:
library/library.m:
        Update the existing C# code to work with the new backend.

library/private_builtin.m:
        Update the existing C# code to work with the new backend.

        Delete the static constants which are duplicated in mercury_dotnet.cs.
        The mlds_to_cs.m will emit references to the constants in the latter
        only.

library/backjump.m:
library/bitmap.m:
library/mutvar.m:
library/par_builtin.m:
library/region_builtin.m:
library/store.m:
library/thread.m:
library/thread.semaphore.m:
library/time.m:
library/univ.m:
        Make these modules compile with the C# backend.

runtime/mercury_dotnet.cs.in:
        Add RTTI classes to the `mercury.runtime' namespace, equivalent to
        those on the Java backend.

        Use enumerations `MR_TYPECTOR_REP_*' and `MR_SECTAG_*' constants so we
        can switch on them.

        Add the `UnreachableDefault' exception class.

        Hide old classes which are unused with the new backend behind
        #ifdef !MR_HIGHLEVEL_DATA.
2010-09-16 00:39:12 +00:00
Peter Wang
75acc7b514 Lift some assumptions that the only Java and Erlang grades are `java' and
Branches: main, 10.04

Lift some assumptions that the only Java and Erlang grades are `java' and
`erlang'.

Finally use `--force-disable-ssdebug' instead of `--no-ssdb' to disable the
source-to-source debugging tranformation where required.  The latter is
incorrect as it changes the grade, which disrupts the install path with `mmc
--make'.

library/Mmakefile:
scripts/Mercury.config.in:
scripts/Mmake.vars.in:
        Remove the variable `INSTALL_JAVA_LIBRARY_DIR' as it assumes only one
        Java grade is possible.

        Don't use default `--java-classpath' options to add Mercury standard
        libraries to the Java class path, for the same reason.

compiler/module_cmds.m:
        Add a predicate to return the Mercury standard libraries needed for a
        Java program as they are no longer listed in Mercury.config.

        Add the Mercury standard libraries when creating the shell script to
        launch Java programs.

compiler/compile_target_code.m:
        Add the Mercury standard libraries when calling the Java compiler.

compiler/make.program_target.m:
        Don't hard code `java' and `erlang' grades when installing library
        grade files.

browser/MDB_FLAGS.in:
library/LIB_FLAGS.in:
mdbcomp/MDBCOMP_FLAGS.in:
ssdb/SSDB_FLAGS.in:
        Use `--force-disable-ssdebug' to disable the transform.

compiler/module_imports.m:
        Don't implicitly import the `ssdb' module if `--force-disable-ssdebug'
        is enabled.

compiler/handle_options.m:
        Reset the `source_to_source_debug' option on encountering a `--grade'
        option.
2010-05-17 01:09:22 +00:00
Peter Wang
d6b8295412 Add an option for `mmc --make' to compile more recently edited source files
Branches: main

Add an option for `mmc --make' to compile more recently edited source files
first, instead of in alphabetical order.  The intention is to catch errors
in modified files more quickly.

Note this does not affect "build_all" targets (e.g. foo.cs).

compiler/options.m:
doc/user_guide.texi:
NEWS:
        Add the option `--order-make-by-timestamp'.

compiler/make.program_target.m:
        Sort modules by timestamp when making a linked target, if the option is
        set.
2010-01-28 04:05:07 +00:00
Julien Fischer
0b339fbae6 Delete an extra space from an error message.
compiler/make.program_target.m:
	Delete an extra space from an error message.
2009-10-16 09:04:07 +00:00
Zoltan Somogyi
4ebe3d0d7e Stop storing globals in the I/O state, and divide mercury_compile.m
Estimated hours taken: 60
Branches: main

Stop storing globals in the I/O state, and divide mercury_compile.m
into smaller, more cohesive modules. (This diff started out as doing
only the latter, but it became clear that this was effectively impossible
without the former, and the former ended up accounting for the bulk of the
changes.)

Taking the globals out of the I/O state required figuring out how globals
data flowed between pieces of code that were often widely separated.
Such flows were invisible when globals could be hidden in the I/O state,
but now they are visible, because the affected code now passes around
globals structures explicitly.

In some cases, the old flow looked buggy, as when one job invoked by
mmc --make could affect the globals value of its parent or the globals value
passed to the next job. I tried to fix such problems when I saw them. I am
not 100% sure I succeeded in every case (I may have replaced old bugs with
new ones), but at least now the flow is out in the open, and any bugs
should be much easier to track down and fix.

In most cases, changes the globals after the initial setup are intended to be
in effect only during the invocation of a few calls. This used to be done
by remembering the initial values of the to-be-changed options, changing their
values in the globals in the I/O state, making the calls, and restoring the old
values of the options. We now simply create a new version of the globals
structure, pass it to the calls to be affected, and then discard it.

In two cases, when discovering reasons why (1) smart recompilation should
not be done or (2) item version numbers should not be generated, the record
of the discovery needs to survive this discarding. This is why in those cases,
we record the discovery by setting a mutable attached to the I/O state.
We use pure code (with I/O states) both to read and to write the mutables,
so this is no worse semantically than storing the information in the globals
structure inside the I/O state. (Also, we were already using such a mutable
for recording whether -E could add more information.)

In many modules, the globals information had to be threaded through
several predicates in the module. In some places, this was made more
difficult by predicates being defined by many clauses. In those cases,
this diff converts those predicates to using explicit disjunctions.

compiler/globals.m:
	Stop storing the globals structure in the I/O state, and remove
	the predicates that accessed it there.

	Move a mutable and its access predicate here from handle_options.m,
	since here is when the mutables treated the same way are.

	In a couple of cases, the value of an option is available in a mutable
	for speed of access from inside performance-critical code. Set the
	values of those mutables from the option when the processing of option
	values is finished, not when it is starting, since otherwise the copies
	of each option could end up inconsistent.

	Validate the reuse strategy option here, since doing it during ctgc
	analysis (a) is too late, and (b) would require an update to the
	globals to be done at an otherwise inconvenient place in the code.
	Put the reuse strategy into the globals structure.

	Two fields in the globals structure were unused. One
	(have_printed_usage) was made redundant when the one predicate
	that used it itself became unused; the other (source_file_map)
	was effectively replaced by a mutable some time ago. Delete
	these fields from the globals.

	Give the fields of the globals structure a distinguishing prefix.

	Put the type declarations, predicate declarations and predicate
	definitions in a consistent order.

compiler/source_file_map.m:
	Record this module's results only in the mutable (it serves as a
	cache), not in globals structure. Use explicitly passed globals
	structure for other purposes.

compiler/handle_options.m:
	Rename handle_options as handle_given_options, since it does not
	process THE options to the program, but the options it is given,
	and even during the processing of a single module, it can be invoked
	up the three times in a row, each time being given different options.
	(It was up to four times in a row before this diff.)

	Make handle_given_options explicitly return the globals structure it
	creates. Since it does not take an old global structure as input
	and globals are not stored in the I/O state, it is now clear that
	the globals structure it returns is affected only by the default values
	of the options and the options it processes. Before this diff,
	in the presence of errors in the options, handle_options *could*
	return (implicitly, in the I/O state) the globals structure that
	happened to be in the I/O state when it was invoked.

	Provide a separate predicate for generating a dummy globals based only
	on the default values of options. This allows by mercury_compile.m
	to stop abusing a more general-purpose predicate from handle_options.m,
	which we no longer export.

	Remove the mutable and access predicate moved to globals.m.

compiler/options.m:
	Document the fact that two options, smart_recompilation and
	generate_item_version_numbers, should not be used without seeing
	whether the functionalities they call for have been disabled.

compiler/mercury_compile_front_end.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mercury_compile_erl_back_end.m:
	New modules carved out of the old mercury_compile.m. They each cover
	exactly the areas suggested by their names.

	Each of the modules is more cohesive than the old mercury_compile.m.
	Their code is also arranged in a more logical order, with predicates
	representing compiler passes being defined in the order of their
	invocation.

	Some of these modules export predicates for use by their siblings,
	showing the dependencies between the groups of passes.

compiler/top_level.m:
compiler/notes/compiler_design.html:
	Add the new modules.

compiler/mark_static_terms.m:
	Move this module from the ml_backend package to the hlds package,
	since (a) it does not depend on the MLDS in any way, and (b) it is
	also needed by a compiler pass (loop invariants) in the middle passes.

compiler/hlds.m:
compiler/ml_backend.m:
compiler/notes/compiler_design.html:
	Reflect mark_static_terms.m's change of package.

compiler/passes_aux.m:
	Move the predicates for dumping out the hLDS here from
	mercury_compile.m, since the new modules also need them.

	Look up globals in the HLDS, not the I/O state.

compiler/hlds_module.m:
	Store the prefix (common part) of HLDS dump file names in the HLDS
	itself, so that the code moved to passes_aux.m can figure out the
	file name for a HLDS dump without doing system calls.

	Give the field names of some structures prefixes to avoid ambiguity.

compiler/mercury_compile.m:
	Remove the code moved to the other modules. This module now looks
	after only option handling (such as deciding whether to generate .int3
	files, .int files, .opt files etc), and the compilation passes
	up to and including the creation of the first version of the HLDS.
	Everything after that is subcontracted to the new modules.

	Simplify and make explicit the flow of globals information.
	When invoking predicates that could disable smart recompilation,
	check whether they have done so, and if yes, update the globals
	accordingly.

	When compiling via gcc, we need to link into the executable
	the object files of any separate C files we generate for C code
	foreign_procs, which we cannot translate into gcc's internal
	structures without becoming a C compiler as well as a Mercury compiler.
	Instead of adding such files to the accumulating option for extra
	object files in the globals structure, we return their names using
	the already existing mechanism we have always used to link the object
	files of fact tables into the executable.

	Give several predicates more descriptive names. Put predicates
	in a more logical order.

compiler/make.m:
compiler/make.dependencies.m:
compiler/make.module_target.m:
compiler/make.module_dep_file.m:
compiler/make.program_target.m:
compiler/make.util.m:
	Require callers to supply globals structures explicitly, not via the
	I/O state. Afterward pass them around explicitly, passing modified
	versions to mercury_compile.m when invoking it with module- and/or
	task-specific options.

	Due the extensive use of partial application for higher order code
	in these modules, passing around the globals structures explicitly
	is quite tricky here. There may be cases where a predicate uses
	an old globals structure it got from a closure instead of the updated
	module- and/or task-specific globals it should be using, or vice versa.
	However, it is just as likely that, this diff fixes old problems
	by preventing the implicit flow of updated-only-for-one-invocation
	globals structures back to the original invoking context.

	Although I have tried to be careful about this, it is also possible
	that in some places, the code is using an updated-for-an-invocation
	globals structure in some but not all of the places where it
	SHOULD be used.

compiler/c_util.m:
compiler/compile_target_code.m:
compiler/compiler_util.m:
compiler/error_util.m:
compiler/file_names.m:
compiler/file_util.m:
compiler/ilasm.m:
compiler/ml_optimize.m:
compiler/mlds_to_managed.m:
compiler/module_cmds.m:
compiler/modules.m:
compiler/options_file.m:
compiler/pd_debug.m:
compiler/prog_io.m:
compiler/transform_llds.m:
compiler/write_deps_file.m:
	Require callers to supply globals structures explicitly, not via the
	I/O state.

	In some cases, the explicit globals structure argument allows
	a predicate to dispense with the I/O states previously passed to it.

	In some modules, rename some predicates, types and/or function symbols
	to avoid ambiguity.

compiler/read_modules.m:
	Require callers to supply globals structures explicitly, not via the
	I/O state.

	Record when smart recompilation and the generation of item version
	numbers should be disabled.

compiler/opt_debug.m:
compiler/process_util.m:
	Require callers to supply the needed options explicitly, not via the
	globals in the I/O state.

compiler/analysis.m:
compiler/analysis.file.m:
compiler/mmc_analysis.m:
	Make the analysis framework's methods take their global structures
	as explicit arguments, not as implicit data stored in the I/O state.

	Stop using `with_type` and `with_inst` declarations unnecessarily.

	Rename some predicates to avoid ambiguity.

compiler/hlds_out.m:
compiler/llds_out.m:
compiler/mercury_to_mercury.m:
compiler/mlds_to_c.m:
compiler/mlds_to_java.m:
compiler/optimize.m:
	Make these modules stop accessing the globals from the I/O state.
	Do this by requiring the callers of their top predicates to explicitly
	supply a globals structure. To compensate for the cost of having to
	pass around a representation of the options, look up the values of the
	options of interest just once, to make further access much faster.

	(In the case of mlds_to_c.m, the code already did much of this,
	but it still had a few accesses to globals in the I/O state that
	this diff eliminates.)

	If the module exports a predicate that needs these pre-looked-up
	options, then export the type of this data structure and its
	initialization function.

compiler/frameopt.m:
	Since this module needs only one option from the globals, pass that
	option instead of the globals.

compiler/accumulator.m:
compiler/add_clause.m:
compiler/closure_analysis.m:
compiler/complexity.m:
compiler/deforest.m:
compiler/delay_construct.m:
compiler/elds_to_erlang.m:
compiler/exception_analysis.m:
compiler/fact_table.m:
compiler/intermod.m:
compiler/mode_constraints.m:
compiler/mode_errors.m:
compiler/pd_util.m:
compiler/post_term_analysis.m:
compiler/recompilation.usage.m:
compiler/size_prof.usage.m:
compiler/structure_reuse.analysis.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/structure_reuse.direct.m:
compiler/structure_sharing.analysis.m:
compiler/tabling_analysis.m:
compiler/term_constr_errors.m:
compiler/term_constr_fixpoint.m:
compiler/term_constr_initial.m:
compiler/term_constr_main.m:
compiler/term_constr_util.m:
compiler/trailing_analysis.m:
compiler/trans_opt.m:
compiler/typecheck_info.m:
	Look up globals information from the HLDS, not the I/O state.

	Conform to the changes above.

compiler/gcc.m:
compiler/maybe_mlds_to_gcc.pp:
compiler/mlds_to_gcc.m:
	Look up globals information from the HLDS, not the I/O state.

	Conform to the changes above.

	Convert these modules to our current programming style.

compiler/termination.m:
	Look up globals information from the HLDS, not the I/O state.

	Conform to the changes above.

	Report some warnings with error_specs, instead of immediately
	printing them out.

compiler/export.m:
compiler/il_peephole.m:
compiler/layout_out.m:
compiler/rtti_out.m:
compiler/liveness.m:
compiler/make_hlds.m:
compiler/make_hlds_passes.m:
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
compiler/recompilation.check.m:
compiler/stack_opt.m:
compiler/superhomogeneous.m:
compiler/tupling..m:
compiler/unneeded_code.m:
compiler/unused_args.m:
compiler/unused_import.m:
compiler/xml_documentation.m:
	Conform to the changes above.

compiler/equiv_type_hlds.m:
	Give the field names of a structure prefixes to avoid ambiguity.

	Stop using `with_type` and `with_inst` declarations unnecessarily.

compiler/loop_inv.m:
compiler/pd_info.m:
compiler/stack_layout.m:
	Give the field names of some structures prefixes to avoid ambiguity.

compiler/add_pragma.m:
	Add notes.

compiler/string.m:
NEWS:
	Add a det version of remove_suffix, for use by new code above.
2009-10-14 05:28:53 +00:00
Zoltan Somogyi
cc1711071e Make all the pre-HLDS and front-end passes of the compiler gather up
Estimated hours taken: 50
Branches: main

Make all the pre-HLDS and front-end passes of the compiler gather up
all their error messages and print them all at once, in sorted order,
unless the user asked for progress messages, in which case we print all the
errors accumulated so far just before each printing each progress message.

This should make error message output significantly easier to interpret.

compiler/module_imports.m:
	Add a new field to the module_imports structure (the main pre-HLDS
	representation of the parse tree) to hold the list of error messages
	generated so far.

	Rename the module_imports structure as the module_and_imports
	structure, since it holds the module's items as well as information
	about its imports.

	Update the access predicates to encourage getting the items, the error
	messages and the error indication all at once.

	Add mechanisms for updating the error indication and the error
	messages.

	Add a distinguishing prefix to the field names of the structure.

compiler/error_util.m:
compiler/hlds_error_util.m:
	Add facilities for printing error messages in batches.

	In error_util.m, delete an unused argument from several predicates.

compiler/mercury_compile.m:
compiler/intermod.m:
	Gather up error messages to print in batches.

	In the parts of the code affected by the above, explicitly pass
	around a globals structure, instead of having all the predicates
	get it of the I/O state. Since some code (e.g. the start recompilation
	system) still uses the copy in the I/O state, we ensure that this copy
	is kept in sync with the explicitly passed around copy.

	Rename some predicates to avoid ambiguities.

compiler/modules.m:
	Return errors in the module_and_imports structure, not separately.

	Gather up error messages to print in batches.

	Explicitly pass around globals structures.

compiler/read_modules.m:
	Rename the read_modules type to have_read_module_map, since this is
	more explicit.

	For each module we have already read, remember not just the items we
	read from it, but also the error messages we generated during the
	reading. This is so these error messages can be printed together with
	other errors from other sources.

	Explicitly pass around globals structures.

compiler/prog_io.m:
compiler/purity.m:
compiler/stratify.m:
	Rename several predicates to avoid ambiguities.

compiler/modes.m:
	Change the interface of the main predicate to avoid the need for a
	lambda expression in mercury_compile.m.

compiler/recompilation.check.m:
	Add a distinguishing prefix to the field names of a structure.

	Fix a wrong definition of this_file.

	Conform to the changes above.

compiler/compiler_target_code.m:
compiler/deps_map.m:
compiler/make.m:
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/make_hlds.m:
compiler/make_hlds_passes.m:
compiler/trans_opt.m:
compiler/write_deps_file.m:
	Conform to the changes above.

compiler/add_clause.m:
compiler/add_pragma.m:
compiler/state_var.m:
	Add an import of io, since their parent make_hlds.m does not import io
	anymore.

	In add_pragma, update an error message that did not mention trseg as
	well as tr as indicating a trailing grade.

tests/hard_coded/Mmakefile:
	Move two tests that cannot pass in debug grades due to the lack of tail
	recursion to the list containing the other tests with this property.

tests/invalid/test_feature_set.err_exp:
	Update the expected output of this test to expect the updated error
	message from add_pragma.

tests/invalid/test_feature_set.err_exp2:
	Add this file as the expected output for trailing grades.

tests/invalid/*.err_exp:
tests/warnings/*.err_exp:
	Update the expected output for many tests to expect the error messages
	in sorted order.
2009-08-14 20:37:57 +00:00
Peter Wang
fc95b27671 Add search_for_file_mod_time which returns the last modification time
Branches: main

compiler/file_util.m:
        Add search_for_file_mod_time which returns the last modification time
        of the found file.

        Add parameters to search_for_file and search_for_file_returning_dir
        that chooses whether the found file should be left open as the input
        stream on success.

        Avoid dir.make_path_name where possible as it is slow.

compiler/make.util.m:
        Use search_for_file_mod_time instead of something complicated.

compiler/file_names.m:
        Make file_is_arch_or_grade_dependent not consider further clauses after
        stripping the ".tmp" suffix off a filename.

compiler/compile_target_code.m:
compiler/make.module_dep_file.m:
compiler/make.program_target.m:
compiler/mercury_compile.m:
compiler/mmc_analysis.m:
compiler/module_cmds.m:
compiler/options_file.m:
compiler/prog_io.m:
compiler/read_modules.m:
compiler/write_deps_file.m:
        Conform to changes.
2009-07-31 05:32:08 +00:00
Peter Wang
ac5dba7f18 Allow parallel mmc --make to build long interface files (.int) and optimisation
Branches: main

Allow parallel mmc --make to build long interface files (.int) and optimisation
interface files (.opt) in parallel.

compiler/make.program_target.m:
        Build private interface files for all modules with sub-modules, then
        long interface files and optimisation interface files can be built in
        parallel.

compiler/make.m:
        Correct a typo.

compiler/make.util.m:
        Update attribution for parallel mmc --make.
2009-07-31 02:36:47 +00:00
Peter Wang
9761cead58 Fix a problem with mmc --grade java --rebuild <target> where after making all
Branches: main

Fix a problem with mmc --grade java --rebuild <target> where after making all
the Java .class files for the target in a single step, the .class files would
be made again individually.

compiler/make.program_target.m:
        As above.
2009-06-17 07:07:42 +00:00
Peter Wang
c7f4dca5c1 Support generating Java archives (.jar) with `mmc --make'.
Branches: main

Support generating Java archives (.jar) with `mmc --make'.

compiler/make.program_target.m:
compiler/compile_target_code.m:
        Make `build_linked_target_2' call `compile_target_code.link' instead of
        `create_java_shell_script' so that jar targets don't produce shell
        scripts.

        Make `compile_target_code.link' call `create_java_shell_script' so
        that Java executable targets don't try to produce native executables.

compiler/module_cmds.m:
        Rename `list_class_files_for_jar' to `list_class_files_for_jar_mmake'.

        Add a version of `list_class_files_for_jar' where we are given the
        actual list of .class files.  The old version was given only a mmake
        variable reference so generated a shell expression that relied on `sed'
        to strip `Mercury/classs' prefixes off paths.

compiler/write_deps_file.m:
        Conform to renaming.

library/string.m:
NEWS:
        Add string.remove_prefix_if_present/2.
2009-05-11 05:24:08 +00:00
Peter Wang
bc57025e69 Make `mmc --make' support submodules when compiling to Java.
Branches: main

Make `mmc --make' support submodules when compiling to Java.  Java files must
be placed in subdirectories named after the package that each class belongs to.

compiler/java_names.m
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
        Add a new module in the parse_tree package to contain code related to
        name mangling for Java.

compiler/mlds.m:
compiler/java_util.m:
        Move predicates to java_names.m.

compiler/mlds_to_java.m:
        Move predicates to java_names.m.

        Delete an unused predicate.

compiler/file_names.m:
        Rename `erlang_module_name' as it is now also used for Java.

        Make `module_name_to_file_name_general' return file names for `.java'
        and `.class' files that include package subdirectories.

compiler/make.program_target.m:
        Clean `.class' files on make clean.

compiler/mlds_to_il.m:
mdbcomp/prim_data.m:
        Move `sym_name_to_list' to mdbcomp.prim_data.

compiler/compile_target_code.m:
compiler/elds_to_erlang.m:
        Conform to changes.

library/Mmakefile:
        Delete hacks that work around Mercury not writing submodule .java files
        in subdirectories.
2009-05-11 04:56:46 +00:00
Peter Wang
f733c2c50e With mmc --make, invoke `javac' once only for a linked target, passing it all
Branches: main

With mmc --make, invoke `javac' once only for a linked target, passing it all
the .java files which need compiling.  This is how the Java compiler is meant
to be used, and is much quicker.

compiler/make.program_target.m:
        As above.

        Clear cached timestamps of all `.class' files afterwards.

compiler/compile_target_code.m:
        Change `compile_java_file' to accept multiple Java files.

compiler/make.dependencies.m:
        Fix a bug. `.class' files should depend on the `.java' file only.

compiler/make.module_target.m:
compiler/mercury_compile.m:
        Conform to changes.
2009-05-05 05:53:15 +00:00
Peter Wang
6f699e9d3e Make `mmc --make' work for Java grade.
Branches: main

Make `mmc --make' work for Java grade.

compiler/make.dependencies.m:
compiler/make.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
        Make `mmc --make' know to generate `.class' files.

compiler/compile_target_code.m:
        Pass "-sourcepath Mercury/javas" to javac when using subdirectories.

compiler/module_cmds.m:
        Make the shell script we generate to invoke `java' pass command line
        arguments through to the user program.  `exec' the java process.

library/Mmakefile:
        Use $(ALL_JAVACFLAGS) when compiling standard library modules so
        $(EXTRA_JAVACFLAGS) has its effect.
2009-04-30 04:37:27 +00:00
Peter Wang
3085aa8f6d Add mmc --make --track-flags:
Branches: main

Add mmc --make --track-flags:

    --track-flags
	With `--make', keep track of the options used when compiling
	each module.  If an option for a module is added or removed,
	`mmc --make' will then know to recompile the module even if the
	timestamp on the file itself has not changed.  Warning and
	verbosity options are not tracked.

The motivation was to be able to set the execution trace level on selected
modules by editing Mercury.options, without needing to manually touch the
affected files afterwards to force recompilation.  It's probably useful for
anyone that's worried about consistent builds.

The implementation works by recording a hash of the option table which is the
product of the options set for each particular module in .track_flags files,
not a hash of the actual options passed by the user, which might be reordered
or redundant, etc.  Hashes are used as they are much quicker to compare and
take less space (the full options tables are quite big).

compiler/options.m:
	Add the new option.

	Add a predicate to return options that shouldn't be tracked
	(e.g. adding -v shouldn't cause everything to recompile).

compiler/make.m:
	When --track-flags is enabled, write `.track_flags' files which need
	to be changed.

compiler/make.dependencies.m:
	When --track-flags is enabled, make compiled code files depend on the
	`.track_flags' files.

compiler/make.program_target.m:
	Delete .track_flags files on realclean.

compiler/make.module_target.m:
compiler/make.util.m:
	Conform to changes above.

compiler/libs.m:
compiler/md4.m:
	Add an implementation of the MD4 digest function to libs.

doc/user_guide.texi:
NEWS:
	Document the new option.

	Recommend `mmc --make' instead of `mmake' in the user guide.

library/term_io.m:
	Avoid unnecessary memory allocation in should_atom_be_quoted.
2009-04-16 01:45:09 +00:00
Peter Wang
eeec14a8b1 Replace the implementations of (version) hash tables by separate chaining hash
Branches: main

Replace the implementations of (version) hash tables by separate chaining hash
tables.  The old open addressing scheme was broken in the presence of deletes.
Fixes bug #68.

library/hash_table.m:
library/version_hash_table.m:
	As above.

	We no longer use double hashing in case of a hash collision, so hash
	predicates only need to return one value now.

	Add fold with predicate arguments.

library/array.m:
	Add array.foldl for a predicate argument.

	Add array.foldl2 with a unique state pair.

library/version_array.m:
	Add version_array.foldl for a predicate argument.

compiler/make.m:
compiler/make.program_target.m:
compiler/make.util.m:
library/robdd.m:
	Conform to change in hashing predicates.

deep_profiler/dense_bitset.m:
	Add module qualifier to avoid ambiguity.

tests/hard_coded/Mmakefile:
tests/hard_coded/hash_table_delete.exp:
tests/hard_coded/hash_table_delete.m:
tests/hard_coded/hash_table_test.exp:
tests/hard_coded/hash_table_test.m:
tests/hard_coded/version_hash_table_delete.exp:
tests/hard_coded/version_hash_table_delete.m:
tests/hard_coded/version_hash_table_test2.exp:
tests/hard_coded/version_hash_table_test2.m:
	Add new test cases.

tests/hard_coded/hash_bug.m:
tests/hard_coded/hash_init_bug.m:
tests/hard_coded/version_hash_table_test.m:
	Conform to change in hashing predicates.

NEWS:
	Document additions.
2009-03-26 06:32:19 +00:00
Julien Fischer
b6aa63de3e Fix a bug with mmc --make on Mac OS X.
compiler/file_util.m:
	Quote the directory passed to the C compiler's
	-install-name option in case it contains spaces.

compiler/make.program_target.m:
	Update a comment.
2008-12-11 13:03:07 +00:00
Julien Fischer
211a542aa3 Add a mechanism that allows extra C header files to be installed as part
Estimated hours taken: 1
Branches: main

Add a mechanism that allows extra C header files to be installed as part
of a Mercury library, in the same location as the header files generated
by the Mercury compiler.  This is useful when writing Mercury bindings
to C++ libraries since these often require an interface from C++ to C to
be written (at least where one does not already exist) and this usually
involves one or more header files that are then referenced from foreign_decl
pragmas on the Mercury side of things.

compiler/options.m:
	Add a new option, --extra-library-header, that specifies extra
	header files to install.

compiler/make.program_target.m:
	When installing a library installing any extra header files.

doc/user_guide.texi:
	Document the new option.
2008-09-02 09:44:08 +00:00
Peter Wang
c3fcb07f78 Add a caching feature for `mmc --make' so as to avoid reparsing the same
Branches: main

Add a caching feature for `mmc --make' so as to avoid reparsing the same
`.analysis' files repeatedly when many modules in the program or library
import similar sets of modules.

An `.analysis_cache' file contains a binary representation of the parsed
information in its corresponding `.analysis' file.  These can be faster to
load, under certain conditions.  Cache files are stored in
`Mercury/analysis_cache' or `Mercury/<grade>/<arch>/Mercury/analysis_cache'
for the duration of a single make target.  Afterwards the directory is
deleted.  This avoids stale cache files lying around which are incompatible
between different versions of the compiler, host platform, etc.

compiler/libs.m:
compiler/pickle.m:
	Add a module in libs to un/serialise arbitrary data structures.

compiler/options.m:
	Add `--analysis-file-cache' and `--analysis-file-cache-dir <dir>'
	(internal option).

compiler/analysis.file.m:
	Read and write analysis cache files if the cache directory is set.
	Cache files are written after `.analysis' files are written (if
	changed) or after an `.analysis' file is read (if it didn't exist).

compiler/make.program_target.m:
	For certain targets, set up the analysis cache directory before
	running the build procedure, and remove it afterwards.

compiler/module_cmds.m:
	Add a version of update_interface that returns whether the
	interface file changed.

doc/user_guide.texi:
	Add commented out documentation for `--analysis-file-cache'.
2008-07-25 00:47:57 +00:00
Zoltan Somogyi
a00596c283 The file modules.m contains lots of different kinds of functionality.
Estimated hours taken: 16
Branches: main

The file modules.m contains lots of different kinds of functionality.
While much of it belongs together, much of it does not. This diff moves
most of the functionality that does not belong with the rest to several
new modules:

	libs.file_util
	parse_tree.deps_map
	parse_tree.file_names
	parse_tree.module_cmds
	parse_tree.module_imports
	parse_tree.read_module
	parse_tree.write_deps_file

To make them coherent, move some predicates from hlds.passes_aux,
parse_tree.prog_io and parse_tree.prog_out to the new modules, making them
more accessible, reducing the required access from the hlds package to
parse_tree, or from the parse_tree package to libs.

In the same spirit, this diff also moves some simple predicates and functions
dealing with sym_names from prog_util.m to mdbcomp/prim_data.m. This allows
several modules to avoid depending on parse_tree.prog_util.

Rename some of the moved predicates and function symbols where this avoids
ambiguity. (There were several that differed from other predicates or function
symbols only in arity.)

Replace several uses of bools with purpose-specific types. This makes some
of the code significantly easier to read.

This diff moves modules.m from being by far the largest module, to being
only the seventh largest, from 8900+ lines to just 4200+. It also reduces
the number of modules that import parse_tree.modules considerably; most
modules that imported it now import only one or two of the new modules instead.

Despite the size of the diff, there should be no algorithmic changes.

compiler/modules.m:
compiler/passes_aux.m:
compiler/prog_io.m:
compiler/prog_out.m:
	Delete the moved functionality.

compiler/file_util.m:
	New module in the libs package. Its predicates search for files
	and do simple error or progress reporting.

compiler/file_names.m:
	New module in the parse_tree package. It contains predicates for
	converting module names to file names.

compiler/module_cmds.m:
	New module in the parse_tree package. Its predicates handle the
	commands for manipulating interface files of various kinds.

compiler/module_import.m:
	New module in the parse_tree package. It contains the module_imports
	type and its access predicates, and the predicates that compute
	various sorts of direct dependencies (those caused by imports)
	between modules.

compiler/deps_map.m:
	New module in the parse_tree package. It contains the data structure
	for recording indirect dependencies between modules, and the predicates
	for creating it.

compiler/read_module.m:
	New module in the parse_tree package. Its job is reading in modules,
	both human-written and machine-written (such as interface and
	optimization files).

compiler/write_deps_file.m:
	New module in the parse_tree package. Its job is writing out
	makefile fragments.

compiler/libs.m:
compiler/parse_tree.m:
	Include the new modules.

compiler/notes/compiler_design.m:
	Document the new modules.

mdbcomp/prim_data.m:
compiler/prog_util.m:
	Move the predicates that operate on nothing but sym_names from
	prog_util to prim_data.

	Move get_ancestors from modules to prim_data.

compiler/prog_item.m:
	Move stuff that looks for foreign code in a list of items here from
	modules.m.

compiler/source_file_map.m:
	Note why this module needs to be in the parse_tree package.

compiler/add_pred.m:
compiler/add_special_pred.m:
compiler/analysis.file.m:
compiler/analysis.m:
compiler/assertion.m:
compiler/check_typeclass.m:
compiler/compile_target_code.m:
compiler/cse_detection.m:
compiler/det_analysis.m:
compiler/elds_to_erlang.m:
compiler/exception_analysis.m:
compiler/export.m:
compiler/fact_table.m:
compiler/higher_order.m:
compiler/hlds_module.m:
compiler/hlds_pred.m:
compiler/intermod.m:
compiler/llds_out.m:
compiler/make.dependencies.m:
compiler/make.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/make_hlds_passes.m:
compiler/maybe_mlds_to_gcc.pp:
compiler/mercury_compile.m:
compiler/mlds.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_java.m:
compiler/mmc_analysis.m:
compiler/mode_constraints.m:
compiler/mode_debug.m:
compiler/modes.m:
compiler/module_qual.m:
compiler/optimize.m:
compiler/passes_aux.m:
compiler/proc_gen.m:
compiler/prog_foreign.m:
compiler/prog_io.m:
compiler/prog_io_util.m:
compiler/prog_mutable.m:
compiler/prog_out.m:
compiler/pseudo_type_info.m:
compiler/purity.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/simplify.m:
compiler/structure_reuse.analysis.m:
compiler/structure_reuse.direct.detect_garbage.m:
compiler/structure_reuse.direct.m:
compiler/structure_sharing.analysis.m:
compiler/tabling_analysis.m:
compiler/term_constr_main.m:
compiler/termination.m:
compiler/trailing_analysis.m:
compiler/trans_opt.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/typecheck_info.m:
compiler/unify_proc.m:
compiler/unused_args.m:
compiler/unused_imports.m:
compiler/xml_documentation.m:
	Minor changes to conform to the changes above.
2008-07-21 03:10:29 +00:00
Peter Wang
464901e028 Restore mmc --make speedup change. The abort was due to an off-by-one bug
Branches: main

Restore mmc --make speedup change.  The abort was due to an off-by-one bug
in version_hash_table.fold, now fixed.

compiler/make.dependencies.m:
compiler/make.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
	As above.

	version_hash_table.delete was also found to be buggy.  Until it is
	fixed, don't use it in a spot.
2008-07-14 02:09:37 +00:00
Peter Wang
c9a1e1622f Revert `mmc --make' speedup changes. They were causing a compiler aborts when
Branches: main

Revert `mmc --make' speedup changes.  They were causing a compiler aborts when
installing libgrade libraries.

compiler/make.dependencies.m:
compiler/make.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
	As above.
2008-07-09 06:48:59 +00:00
Peter Wang
12ca97a314 Speed up dependency computation in `mmc --make'.
Estimated hours taken: 15
Branches: main

Speed up dependency computation in `mmc --make'.  It was spending the majority
of its time taking unions of sets.  Therefore change to a set representation
which is fast for unions, sparse_bitset.  To make use of bitsets, maintain a
mapping between module_names and integers, and dependency_files and integers.
Use version_hash_tables and version_arrays to hold the forward and reverse
mappings.  (We don't really need version types.)

Also cache the results of `non_intermod_direct_imports',
`find_module_foreign_imports' and `get_file_name'.

In one workspace, the time for `mmc --make' to check that all the .c files in
the `compiler' directory were up-to-date dropped from ~120 seconds to ~20
seconds after these changes.

compiler/make.m:
	Add fields to the `make_info' structure to hold the module_name- and
	dependency_file-to-index mappings.

	Change the dependency_status map from a tree234 map to a
	version_hash_table.

	Add fields to cache results for `get_file_name' and
	`non_intermod_direct_imports'.

compiler/make.dependencies.m:
	Add the equivalence type `deps_set(T)' to make it easier to try
	different set representations in the future.  Change the set
	representation as above.

	Add procedures to convert between indices and the real values, and
	index sets and the real sets.

	Conform to the data representation changes.

	Add caching to `non_intermod_direct_imports' and
	`find_module_foreign_imports'.

	Replace two generate-and-test sites with deterministic code.

	Make `deps_result' a discriminated union.  Delete
	the `transitive_deps_result' type which is not useful.

compiler/make.util.m:
	Add hash functions for `module_name' and `dependency_file' values.

	Add caching to `get_file_name' (when Search = yes).

	Delete an unused predicate.

compiler/make.module_target.m:
compiler/make.program_target.m:
	Conform to changes.

	Minor cleanups.
2008-07-07 04:49:08 +00:00
Peter Wang
2159c0a7af Don't try to build .analysis' files in parallel with mmc --make'.
Branches: main

compiler/make.program_target.m:
	Don't try to build `.analysis' files in parallel with `mmc --make'.
	It doesn't and can't work without more extensive changes.
2008-07-01 01:40:15 +00:00
Peter Wang
0d60ca704c The --intermodule-analysis' option was broken in that touching a .m' file
Branches: main

The `--intermodule-analysis' option was broken in that touching a `.m' file
would cause its `.analysis' file to be remade (correct) but then all the
target code files which depend on that `.analysis' file would be remade,
even if the `.analysis' file should be unchanged.

Fix that by making analysis files work like other interface files: the
timestamp on the `.analysis' file reflects the last time it was changed, and
the `.analysis_date' file reflects the last time the module was analysed.

To that end we need to move the module status out of the `.analysis' file into
a corresponding `.analysis_status' file.  Then analysing other modules will
only touch the `.analysis_status' file.  `.analysis_status' are not installed.

compiler/analysis.m:
compiler/analysis.file.m:
	Separate predicates for reading/writing the module status from the
	module analysis results proper.

	Use the usual technique of writing analysis results to `.analysis.tmp'
	and only updating the `.analysis' file if its changed.

	Write analysis results for a single function-id in sorted order to
	remove spurious differences.

	Use some standard interface file handling predicates.

compiler/make.util.m:
	Simplify the special treatment of timestamps for `.analysis' files.

compiler/make.module_target.m:
compiler/make.program_target.m:
	Conform to interface changes.
2008-05-29 04:41:54 +00:00
Julien Fischer
b058b62dd5 Add a check to `mmc --make' that causes it to check that any libraries
Estimated hours taken: 4
Branches: main

Add a check to `mmc --make' that causes it to check that any libraries
(including the standard library) required for building an executable or
library target are installed and accessible in the compilation grade.  Emit an
error message where they are not.  (The compiler's current behaviour varies
from reporting .mih files are missing through to linker errors.)

The check is implemented by searching for a library's .init file, which works
since every library has a .init file and the .init file is grade dependent.

The check is currently only performed when compiling in a C grade.

compiler/options.m:
	Add a new option `--libgrade-install-check' to control the new check.

compiler/handle_options.m:
	Only enable --libgrade-intall-check if --make is enabled.

compiler/make.program_target.m:
	Implement the new check.

	When building a linked target, i.e. an executable or library,
	first check that all required libraries are available in the
	compilation grade.

doc/user_guide.texi:
	Document the new option.
2008-05-16 08:10:52 +00:00