mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-24 05:43:53 +00:00
4b052d46dd8b0dd5b9ca449bde12cd12fae76fc2
10 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
56b636886a |
Avoid a compiler abort on empty submodules.
This fixes Mantis bug 437.
compiler/split_parse_tree_src.m:
Add empty submodules to the submodules map, since the abort
was caused absence of such an entry.
Warn about the duplication if a submodule is later defined
with the same name.
tests/valid/empty_submodule.m:
Add this regression test for the bug.
tests/valid/Mmakefile:
Enable the new test case.
|
||
|
|
c88a777501 |
Delete some dead predicates.
compiler/*.m:
Delete dead predicates that don't look likely to be used in the future
in their current form.
For dead predicates that may be needed in the future, shut up warnings
about them by adding a consider_used pragma for them.
In intermod.m, delete two unused fields in a structure.
|
||
|
|
7b82c59c40 |
Remove unneeded module qualifications from error messages.
This should make error messages easier to read by removing clutter.
compiler/error_util.m:
Split each of the sym_name and sym_name_and_arity error pieces into two;
one which prints any module qualification present in the given sym_name,
and one which does not. This forces people who use these pieces
to think about whether they want the sym_name module qualified
in the error message or not.
compiler/add_class.m:
compiler/add_clause.m:
compiler/add_foreign_enum.m:
compiler/add_foreign_proc.m:
compiler/add_mode.m:
compiler/add_mutable_aux_preds.m:
compiler/add_pragma.m:
compiler/add_pragma_tabling.m:
compiler/add_pred.m:
compiler/add_type.m:
compiler/check_for_missing_type_defns.m:
compiler/check_promise.m:
compiler/check_raw_comp_unit.m:
compiler/check_typeclass.m:
compiler/det_report.m:
compiler/equiv_type.m:
compiler/format_call.m:
compiler/hlds_error_util.m:
compiler/inst_check.m:
compiler/introduce_parallelism.m:
compiler/make_hlds_error.m:
compiler/make_hlds_passes.m:
compiler/make_tags.m:
compiler/mercury_compile_main.m:
compiler/mode_errors.m:
compiler/modes.m:
compiler/module_qual.qual_errors.m:
compiler/modules.m:
compiler/oisu_check.m:
compiler/parse_inst_mode_defn.m:
compiler/parse_item.m:
compiler/parse_module.m:
compiler/parse_pragma.m:
compiler/parse_type_defn.m:
compiler/polymorphism.m:
compiler/post_term_analysis.m:
compiler/prog_out.m:
compiler/recompilation.check.m:
compiler/resolve_unify_functor.m:
compiler/split_parse_tree_src.m:
compiler/type_constraints.m:
compiler/typecheck_errors.m:
compiler/unused_args.m:
compiler/unused_imports.m:
Conform to the change above. For sym_name references for which
the module qualifier is obvious (usually because it *has* to be
the module being compiled), change the reference to the variant
that omits that qualifier; otherwise, keep the qualifier.
In a few places, improve the wording of an error message.
tests/invalid/bad_instance.err_exp:
tests/invalid/bug17.err_exp:
tests/invalid/builtin_int.err_exp:
tests/invalid/foreign_purity_mismatch.err_exp:
tests/invalid/foreign_type_visibility.err_exp:
tests/invalid/fp_dup_bug.err_exp:
tests/invalid/fundeps_vars.err_exp:
tests/invalid/impl_def_literal_syntax.err_exp:
tests/invalid/inline_conflict.err_exp:
tests/invalid/inst_list_dup.err_exp:
tests/invalid/instance_no_type.err_exp:
tests/invalid/invalid_typeclass.err_exp:
tests/invalid/missing_interface_import.err_exp:
tests/invalid/missing_interface_import2.err_exp:
tests/invalid/oisu_check_semantic_errors.err_exp:
tests/invalid/tc_err1.err_exp:
tests/invalid/tc_err2.err_exp:
tests/invalid/transitive_import.err_exp:
tests/invalid/type_with_no_defn.err_exp:
tests/invalid/typeclass_bogus_method.err_exp:
tests/invalid/typeclass_missing_mode_2.err_exp:
tests/invalid/typeclass_test_10.err_exp:
tests/invalid/typeclass_test_3.err_exp:
tests/invalid/typeclass_test_4.err_exp:
tests/invalid/typeclass_test_5.err_exp:
tests/invalid/typeclass_test_9.err_exp:
tests/invalid/types2.err_exp:
tests/invalid/undef_inst.err_exp:
tests/invalid/undef_mode.err_exp:
tests/invalid/undef_mode_and_no_clauses.err_exp:
tests/invalid/undef_type.err_exp:
tests/invalid/undef_type_mod_qual.err_exp:
tests/invalid/uu_type.err_exp:
tests/invalid/where_direct_arg.err_exp:
tests/invalid/where_direct_arg2.err_exp:
tests/invalid/wrong_type_arity.err_exp:
tests/recompilation/add_type_re.err_exp.2:
tests/recompilation/field_r.err_exp.2:
tests/recompilation/remove_type_re.err_exp.2:
tests/warnings/inst_with_no_type.exp:
Expect the updated versions of error messages.
|
||
|
|
94535ec121 |
Fix spelling and formatting throughout the system.
configure.ac: browser/*.m: compiler/*.m: deep_profiler/*.m: library/*.m: ssdb/*.m: runtime/mercury_conf.h.in: runtime/*.[ch]: scripts/Mmake.vars.in: trace/*.[ch]: util/*.c: Fix spelling and doubled-up words. Delete trailing whitespace. Convert tabs into spaces (where appropriate). |
||
|
|
ea094b5bb7 |
Make the import_status type part of the HLDS.
The import_status type was defined in parse_tree.status.m, but it is
not actually used in the parse_tree package. It is used, extensively,
in the hlds package.
compiler/status.m:
compiler/prog_item.m:
compiler/prog_data.m:
Move the parts of status.m that *are* needed in the parse_tree package
to modules in that package. The section markers and the import_locn type
are moved to prog_item.m, while the need_qualifier type is moved to
prog_data.m.
compiler/parse_tree.m:
compiler/hlds.m:
Switch the status.m module from being in the parse_tree package
to being in the hlds package.
compiler/notes/compiler_design.html:
Document the switch.
compiler/*.m:
Update import_module declarations as needed after the above change.
In some places, import parse_tree.prog_item as well as hlds.status,
even if we are only intested in statuses, because the import_locn type,
which part of some statuses, *is* used in the parse_tree package,
and must therefore be defined there. These undesirable dependencies
will go away when we implement the proposal for purpose-specific status
types.
|
||
|
|
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.)
|
||
|
|
c6521f9ec5 |
Store version number info separately from items.
We used to store such information in md_version_number module_defns
in the item list. This did not enforce the invariants we want for
version number records, which are that
- they can appear only in interface files, not source or optimization
files;
- only one such record can appear in each interface file; and
- there cannot be more than one such record for any given module
in any augmented compilation unit (which can contain information from
many interface files).
This change removes the md_version_number module_defn, and replaces it
with (a) a slot in the parse tree of interface files that may contain
the version number record of that module, and (b) a slot in augmented
compilation units that maps module names to the version number record
for the named module.
compiler/prog_item.m:
Make the change above.
compiler/recompilation.m:
Provide a type for mapping module names to the named module's version
number record.
compiler/prog_io_item.m:
Parse version number records not as items, but as a new kind of marker.
compiler/prog_io.m:
Process this new marker. Record the first one in interface files.
Generate error messages for any later records in any given interface file,
or for any such records at all in any file of any other kind.
Since the contents of interface files are automatically generated,
users should never see the first of these kinds of messages.
They should never see the second of these kinds of messages either,
unless they hand-write a version number record, which is actually
pretty hard to do, not least since the format is undocumented :-(
compiler/make_hlds_passes.m:
Process the version number records separately from the items, since
they are now stored separately.
compiler/module_imports.m:
Provide a mechanism for collecting version number information
as interface files are read in.
compiler/modules.m:
Use that mechanism, and collect version number information
as interface files are read in.
compiler/recompilation.check.m:
compiler/recompilation.version.m:
Get the version number information these modules work with from the
new slot in parse_tree_ints.
compiler/comp_unit_interface.m:
compiler/deps_map.m:
compiler/equiv_type.m:
compiler/get_dependencies.m:
compiler/hlds_module.m:
compiler/make.module_dep_file.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/read_modules.m:
compiler/split_parse_tree_src.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
Conform to the changes above.
|
||
|
|
2856408ab0 |
Separate the different kinds of sections in aug_comp_units.
When we create augmented compilation units, the item blocks in that
augmented unit come from five sources:
- the original raw compilation unit, containing the source code of a module;
- the interface files of the modules directly imported by that module;
- the interface files of the modules indirectly imported by that module;
- the optimization files needed by that module; and
- the interface files needed by those optimization files.
Change the representation of augmented compilation units so that instead of
containing one list of item blocks, each of which had a general section type,
it now has five lists of item blocks, one for each category above, with
a section type specialized to the category.
After this change, the compiler can process just the item blocks it wants
to process, instead of having to process all the item blocks, all the while
filtering out the irrelevant blocks. This filtering used to be order dependent,
with the ams_transitively_imported section marker, which derived from the old
md_transitively_imported module_defn, marking the dividing line between
the first and second categories on the one hand and the third, fourth and fifth
categories on the other hand. That marker is now gone, and the item blocks
in each category have no need to be in a specific order.
compiler/prog_item.m:
Make the above change in the representation of the augmented compilation
unit.
compiler/module_imports.m:
Instead of recording one list of item blocks for the augmented compilation
unit being built, record five.
compiler/modules.m:
Instead of always adding new item blocks to the one list, add it to the
relevant list. For modules.m, this will be one of the three item block
lists for interface files.
Provide a mechanism for getting back the augmented compilation unit
whole, once its building has finished.
compiler/intermod.m:
compiler/trans_opt.m:
Instead of always adding new item blocks to the one list, add it to the
relevant list. For intermod.m and trans_opt, this will be the item block
list for optimization files.
compiler/status.m:
Change the section types to account for the new kinds of sections
in augmented compilation units (from source, interface and optimization
files respectively).
Besides recording which module the item blocks in interface and
optimization sections came from, record the int_file_kind or opt_file_kind
as well. The compiler does not use this extra information (yet); I am
adding it so that I can look for further invariants.
compiler/file_kind.m:
A new module carved out of prog_item.m, containing the types that define
kinds of source, interface and optimization files, and the predicates that
operate on them. This needs to be a new module, because (a) status.m now
needs access to file kinds, (b) status.m should not import prog_item.m,
since that would lead to circular imports, and (c) the file kinds
don't belong with statuses.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Mention the new module.
compiler/equiv_type.m:
Conform to the changes above.
Replace the eqv_type_location type with the maybe_record_sym_name_use type,
since the location (in this module's interface, in this module's
implementation, in some other module) matters only for recording the uses
of sym_names.
compiler/make_hlds_passes.m:
Process all five lists of item blocks in each of the three passes.
Note cases where this may not be needed.
compiler/module_qual.m:
Conform to the changes above. Module qualify only the items in this
module, not the items we got from other modules.
compiler/comp_unit_interface.m:
compiler/deps_map.m:
compiler/hlds_module.m:
compiler/make.module_dep_file.m:
compiler/mercury_compile.m:
compiler/mercury_to_mercury.m:
compiler/split_parse_tree_src.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
Conform to the changes above.
|
||
|
|
850d461c40 |
Make `:- external' a pragma inside the compiler and out.
We used to have only the first of these three forms, we now have all three:
:- external(low_level_backend, a/2).
% declared pred a/2 and func a/2 to be external on llds
:- pragma external_pred(a/2, [low_level_backend]).
% declared pred a/2 (and NOT func a/2) to be external on llds
:- pragma external_func(a/2, [low_level_backend]).
% declared func a/2 (and NOT pred a/2) to be external on llds
The new forms allow for more precise control of what is declared to be
external. The difference in syntax (the options coming after the name,
and the options being in a list, even though this pragma allows only
one option at present) are to fit in with the style of the other pragmas.
Of course, the backend does not have to be specified, so these are
also allowed:
:- pragma external_pred(a/2).
:- pragma external_func(a/2, []).
Using `:- external' declarations is for implementors only, since using it
requires writing target language code by hand in a way that conforms to all
the compiler's conventions for e.g. symbol naming and parameter passing.
It is not a documented part of Mercury. Therefore the new external_{func,pred}
pragmas are not documented either.
compiler/prog_item.m:
Change the representation of the `:- external' declaration from being
a module_defn to being a pragma. Generalize it to allow the new pragmas,
by allowing the recording of an option pred_or_func indication.
Add a function that returns a description of a pragma for use as a context
in error messages. We need this to avoid confusing users by having an
error message refer to a `:- external' declaration when they wrote e.g.
`:- pragma external_pred', or vice versa.
compiler/add_pragma.m:
Move the code for handling external declarations from make_hlds_passes
(which handles module_defns) to this module (which handles pragmas),
and update it.
Execute this code in pass 2, not pass 1, since we need to record
the "external" flag in the pred_info, and that is created in pass 1.
(I think this worked in the past ONLY if the declaration of the affected
predicate or function came textually before the `:- external' declaration.)
compiler/make_hlds_passes.m:
Remove the code that is now in add_pragma.m (in adapted form).
compiler/prog_io_item.m:
Change the code for parsing old-style `:- external' declarations to
generate the new pragma internally.
compiler/prog_io_pragma.m:
Add code for parsing the new pragmas.
compiler/equiv_type.m:
compiler/item_util.m:
compiler/mercury_to_mercury.m:
compiler/module_imports.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/recompilation.version.m:
compiler/write_module_interface_files.m:
Conform to the changes above.
compiler/make_hlds_error.m:
Improve a variable name.
compiler/pred_table.m:
Improve the documentation of several predicates.
tests/hard_coded/backend_external.m:
Improve the documetation of this old test case, which tests the
handling of backend-specific `:- external' declarations.
tests/hard_coded/backend_external_{func,pred}.m:
Two copies of the old backend_external.m test case, which test the
handling of backend-specific `:- pragma external_func' and
`:- pragma external_pred' declarations respectively.
tests/hard_coded/backend_external_func.exp:
tests/hard_coded/backend_external_pred.{exp,exp2}:
The expected outputs of the new test cases.
tests/hard_coded/Mmakefile:
Enable the new test cases.
tests/invalid/type_spec.err_exp:
Expect an error message for a `:- external' declaration in the interface
of type_spec.m. Since declaring a procedure to be external is in essence
a representation of the implementation of that procedure, the previous
absence of an error message for this implementation detail in the interface
was a bug.
tests/invalid/external.err_exp:
We always generated an error for a `:- external' declaration that
did not specify an arity, but the text of the error message used to say
"warning", not "error" (even though the severity level was "error").
Expect the corrected error message.
tests/invalid/not_in_interface.err_exp:
Expect the updated, more precise form of an error message.
vim/syntax/mercury.vim:
Add the two new keywords.
|
||
|
|
982d7d69fe |
Carve split_parse_tree_src.m out of modules.m.
modules.m used to contain six only loosely-related parts. Move the last part,
which splits up a parse_tree_src into a list of raw_comp_units, one for the
main module of the source file and one for each module nested within it,
into the new module split_parse_tree_src.m.
compiler/split_parse_tree_src.m:
The new module. Its code is unchanged.
compiler/modules.m:
Remove the code that is now in split_parse_tree_src.m.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Mention the new module.
compiler/deps_map.m:
compiler/make.module_dep_file.m:
Import split_parse_tree_src.m instead of modules.m.
compiler/mercury_compile.m.
Import split_parse_tree_src.m as well as modules.m.
|