mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 09:23:44 +00:00
90387ddc8cb9a0e9b0064ffdab5a3bd68b16dcfa
269 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
bd6e6fca8c |
Diagnose names with non-full qualifications.
compiler/typecheck_errors.m:
When the program refers to a predicate, function or data constructor
from a module with only a use_module declaration, it must do so
using its fully qualified name. If it refers to it with an unqualified
or only partially qualified name, the typechecker won't find it,
because the predicate_table and the cons_table record non-fully-qualified
names only for the entities imported with import_module declarations.
When generating error_specs for such errors, look for matches with
the relevant name among the fully-qualified entries in the predicate
and cons tables. If we find some, add a sentence to the error message
about the modules defining such names being imported with use_module,
not import_module.
compiler/hlds_cons.m:
Add a way to look up the definitions of all the constructors with
a given name.
compiler/pred_table.m:
Add a way to look up the definitions of all the predicates or functions
with a given name.
mdbcomp/sym_name.m:
Add some functionality for use by typecheck_errors.m.
tests/invalid/type_error_use_module.m:
tests/invalid/type_error_use_module_2.m:
tests/invalid/type_error_use_module.err_exp:
A test case for the new functionality.
tests/invalid/Mmakefile:
tests/invalid/Mercury.options:
Enable the new test case. Sort the list of multimodule tests.
tests/invalid/errors2.err_exp:
Expect the new addendum to an existing error message.
|
||
|
|
5d1b995302 |
Replace an O(n^2) algorithm with O(n).
Replace useless info in proc_label printouts with useful info. |
||
|
|
198b307289 |
Use related names for related variables.
Add an XXX about a missing file close operation. |
||
|
|
01f8599e90 | --warn-implicit-stream-calls for all of mdbcomp. | ||
|
|
3c07fc2121 |
Use explicit streams in deep_profiler/*.m.
deep_profiler/analysis_utils.m:
deep_profiler/autopar_find_best_par.m:
deep_profiler/autopar_reports.m:
deep_profiler/autopar_search_callgraph.m:
deep_profiler/autopar_search_goals.m:
deep_profiler/callgraph.m:
deep_profiler/canonical.m:
deep_profiler/cliques.m:
deep_profiler/coverage.m:
deep_profiler/dump.m:
deep_profiler/mdprof_cgi.m:
deep_profiler/mdprof_create_feedback.m:
deep_profiler/mdprof_dump.m:
deep_profiler/mdprof_procrep.m:
deep_profiler/mdprof_report_feedback.m:
deep_profiler/mdprof_test.m:
deep_profiler/profile.m:
deep_profiler/read_profile.m:
deep_profiler/recursion_patterns.m:
deep_profiler/startup.m:
deep_profiler/var_use_analysis.m:
Replace implicit streams with explicit streams.
In some places, simplify some code, often using constructs such as
string.format that either did not exist or were too expensive to use
when the original code was written.
Consistenly use the spelling StdErr over Stderr.
In mdbprof_dump.m, put filename and reason-for-failing-to-open-that-file
in the right order in an error message.
deep_profiler/DEEP_FLAGS.in:
Turn on --warn-implicit-stream-calls for the entire deep_profiler
directory.
mdbcomp/program_representation.m:
mdbcomp/trace_counts.m:
Replace implicit streams with explicit streams. These are the two mdbcomp
modules that (a) used to use implicit streams, and (2) are used by the
deep profiler.
mdbcomp/Mercury.options:
Turn on --warn-implicit-stream-calls for these two modules.
slice/mcov.m:
slice/mtc_union.m:
Conform to the changes in mdbcomp.
|
||
|
|
63dabcfcf8 |
Fix filling in partial terms that use direct_arg tags.
This fix uses the approach discussed on m-dev 2020 nov 16/17 for fixing github issue #72, whose core problem is a need for information flow back to a the caller from a callee when the callee fills in the argument of a function symbol whose representation is a direct_arg tag. In most cases when the callee fills in the value of an argument, the caller can see it because the argument is in a word on the heap, but when the function symbol uses a direct_arg tag, that is not the case. compiler/direct_arg_in_out.m: A new module that implements the transformation proposed on m-dev. It creates a fresh clone variable every time an argument of a direct_arg tag function symbol is (or may be) updated. This can happen several times if a type has more than one function symbol with a direct_arg tag. Since the affected variable can be bound to only one function symbol at the start, its argument can be filled in only once, but the compiler cannot know in advance what function symbol the variable contains, and therefore which of the possibly several fill-in sites (which fill in the arguments of different function symbols) executed in sequence will actually update the variable. The transformation ensures that once a variable is cloned, it is never referred to again. It also ensures that in a branched control structure (if-then-else, disjunction or switch), all branches will use the *same* variable to represent the latest version of each cloned variable at the end, so that following code has a consistent view regardless of through which branch execution has reached it. There are three situations that the transformation cannot and does not handle. 1. Situations in which the mode of an argument is either an inst variable, or an abstract inst. In either case, the pass cannot know whether it should apply its transformation to the argument. 2. Situations where a procedure that has such an argument is exported to C code as a function. In that case, the C signature of the function we would generate would be different from what the user would normally expect. We could modify the documentation of the export pragma, but I don't think there much point due to lack of demand. (The problem cannot arise when targeting any language other than C, because we use direct_arg tags only with the low level data representation, which we only use for C.) 3. Situations where a procedure that has such an argument is defined by foreign_proc. Again, dealing with the problem would require nontrivial changes to the documented interface between code in foreign_procs and the surrounding Mercury code, and I see no demand for code that could benefit from that. In these cases, this module generates error messages. compiler/transform_hlds.m: Include the new module in the transform_hlds package. Delete unnecessary module qualification on some existing inclusions. Put some existing inclusions into a more meaningful order. compiler/notes/compiler_design.html: Document the new pass. Fix some nearby prose. compiler/lambda.m: compiler/simplify_proc.m: Use a predicate exported by direct_arg_in_out.m to test, for each procedure, whether the procedure has any argument positions that are subject to the problem that direct_arg_in_out.m addresses. simplify_proc.m does this for all procedures it processes; lambda.m does this for all the procedures it creates from lambda expressions. Give a predicate in simplify_proc.m a better name. Sort a list of predicate names. compiler/hlds_module.m: Add a field to the module_info that simplify_proc.m and lambda.m can use to tell direct_arg_in_out.m what work (if any) it needs to do. compiler/mercury_compile_middle_passes.m: Invoke direct_arg_in_out.m if the new field in the HLDS indicates that it has some work to do. (In the vast majority of compiler invocations, it won't have any.) compiler/hlds_pred.m: The new code in direct_arg_in_out.m creates a clone of each procedure affected by the problem, before deleting the originals (to make sure that no references to the unfixed versions of now-fixed procedures remain.) Make it possible to create exact clones of both predicates and procedures by adding two pairs of predicates, {pred,proc}_prepare_to_clone and {pred,proc}_create. Add the direct_arg_in_out transformation as a possible source of transformed predicates. library/private_builtin.m: Add a new builtin operation, partial_inst_copy, that the new module generates calls to. configure.ac: Require the installed compiler to recognize partial_inst_copy as a no_type_info builtin. compiler/builtin_ops.m: Recognize the new builtin. (This was committed before the rest; the diff to private_builtin.m can be done only once the change to builtin_ops.m is part of the installed compiler.) compiler/options.m: Add a way to test whether the builtin_ops.m in the installed compiler recognizes the new builtin. compiler/dead_proc_elim.m: Do not delete the new primitive before direct_arg_in_out.m has had a chance to generate calls to it. Add an XXX. compiler/error_util.m: Recognize the new module as a source of error messages. compiler/pred_table.m: Add a pair of utility predicates to be used when looking up builtin predicates, for which the compiler writer knows that there should be exactly one match. These are used in direct_arg_in_out.m. compiler/simplify_goal_call.m: Replace some existing code with calls to the new predicates in pred_table.m. compiler/hlds_goal.m: Add modes to rename_vars_in_goal_expr that express the fact that when an atomic goal_expr has some variables renamed inside it, it does not suddenly become some *other* kind of goal_expr. New code in direct_arg_in_out.m relies on this. compiler/hlds_out_goal.m: When the HLDS we are dumping out is malformed because it contains calls to predicates that have been deleted, the compiler used to abort at such calls. (I ran into this while debugging direct_arg_in_out.m.) Fix this. When such calls are encountered, we now print out as much information we can about the call, and prefix the call with an unmistakable prefix to draw attention to the problem. compiler/inst_util.m: Fix a bug that prevented direct_arg_in_out.m from even being invoked on some test code for it. The bug was in code that we use to unify a headvar's initial inst with its final inst. When the initial inst was a non-ground bound_inst such as the ones used in tests/hard_coded/gh72.m, and the final inst was simply "ground", this code quite properly returned a bound_inst (which, unlike ground, can show the exact set of function symbols that the headvar could be bound to). The problem was that it reused the original bound_inst's test results, including the one that said the final inst is NOT ground, which of course is wrong for any inst unified with ground. Fix two instances of this bug. compiler/modes.m: Make some of the code I had to traverse to find the bug in inst_util.m easier to read and understand. Replace some uses of booleans with bespoke enum types. Change the argument lists of some predicates to put related arguments next to each other. Give some variables more descriptive names. compiler/layout_out.m: Conform to the change in hlds_pred.m. compiler/var_locn.m: Fix a code generation bug. When filling-in the value of the argument of a function symbol represented by a direct_arg tag, the code we generated for it worked only if the direct_arg tag used 0 as its ptag value. In the test cases we initially used for github issue 72, that was the case, but the new tests/hard_coded/gh72.m has direct_tag args that use other ptag values as well. Document the reason why the updated code works. compiler/term_constr_initial.m: Add the new primitive predicate added to private_builtin.m, partial_inst_copy, to a table of builtins that do not take type_infos, even though their signatures contain type variables. Fix a bunch of old bugs: most other such primitives were not listed either. mdbcomp/program_representation.m: Add partial_inst_copy to the master list of builtins that do not take type_infos even though their signatures contain type variables. (Done by an earlier commit.) Document the fact that any updates here require updates to term_constr_initial.m. library/multi_map.m: We have long had multi_map.add and multi_map.set as synonyms, but we only had multi_map.reverse_set. Add multi_map.reverse_add as a synonym for it. Define the "set" versions in terms of the "add" versions, instead of vice versa. NEWS: Document the new predicates in multi_map.m. tests/hard_coded/gh72a.m: Fix typo. tests/hard_coded/gh72.{m,exp}: A new, much more comprehensive test case than gh72a.m. This one tries to tickle github issue 72 in as many forms of code as I can think of. tests/invalid/gh72_errors.{m,err_exp}: A test case for testing the generation of error messages for two out of the three kinds of situations that direct_arg_in_out.m cannot handle. (Proposals for how to test the third category welcome.) tests/hard_coded/Mmakefile: tests/invalid/Mmakefile: Enable the two new test cases, as well as two old ones, gh72[ab].m, that previously we didn't pass. tests/invalid/Mercury.option: Do not compile gh72_error.m with --errorcheck-only, since its errors are reported by a pass that --errorcheck-only does not invoke. |
||
|
|
a93fbc92f6 |
Recognize partial_inst_copy as no_type_info_builtin.
mdbcomp/program_representation.m:
As above.
compiler/options.m:
Make it possible to detect whether the installed compiler
contains the above change.
|
||
|
|
0d3fcbaae3 |
Delete Erlang code from library/mdbcomp/browser directories.
library/*.m:
Delete Erlang foreign code and foreign types.
Delete documentation specific to Erlang targets.
library/deconstruct.m:
Add pragma no_determinism_warning to allow functor_number_cc/3
to compile for now.
library/Mercury.options:
Delete workaround only needed when targetting Erlang.
browser/listing.m:
mdbcomp/rtti_access.m:
Delete Erlang foreign code and foreign types.
|
||
|
|
524f4d72e2 |
Delete references to Erlang backend in makefiles.
Mmake.workspace:
Mmakefile:
*/Mmakefile:
tests/*/Mmakefile:
tests/valid/Mmake.valid.common:
trace/Mmakefile:
As above.
|
||
|
|
c4c840cb7e |
Delete Erlang backend from configure.
configure.ac:
m4/mercury.m4:
Delete --enable-erlang-grade configure option.
Don't search for erlang compiler and interpreter.
Don't substitute @ERLC@ and @ERL@.
Don't add erlang to libgrades.
Don't generate erlang_conf.hrl
library/erlang_conf.hrl.in:
Delete template file.
.dockerignore:
browser/MDB_FLAGS.in:
compiler/COMP_FLAGS.in:
deep_profiler/DEEP_FLAGS.in:
library/.gitignore:
library/Mmakefile:
library/library.m:
mdbcomp/MDBCOMP_FLAGS.in:
mfilterjavac/MFILTERJAVAC_FLAGS.in:
profiler/PROF_FLAGS.in:
scripts/Mercury.config*.in:
scripts/mercury_config.in:
scripts/prepare_install_dir.in:
ssdb/SSDB_FLAGS.in:
tools/bootcheck:
Delete references to Erlang .hrl files.
Delete references to @ERLC@ and @ERL@.
|
||
|
|
b8b845a568 |
Fix mmakefile rules for os,cs,css,javas.
The main objective of this change is to get bootchecks in the csharp
and java grades to actually build the slice, profiler, deep_profiler
and mfilterjavac directories, which (due to the bug this diff fixes)
they weren't doing before.
However, since one side effect of this change is to eliminate
one source of annoying warnings from mmake about references to undefined
variables, a subsidiary objective is to eliminate other sources of such
warnings as well, which mostly come from the rules for making tags files.
browser/Mmakefile:
deep_profiler/Mmakefile:
library/Mmakefile:
mdbcomp/Mmakefile:
profiler/Mmakefile:
slice/Mmakefile:
ssdb/Mmakefile:
When creating stage 3, the bootcheck builds, in each directory,
only the files that it wants to compare against their stage 2 versions.
This means that it wants to build all the .c, .cs or .java files,
which it does via the cs, css and javas mmake targets.
The correct definitions of the rules of these targets depends on
whether mmc --make is being used or not, so we need at least two
sets of definitions: one for mmc --make, and for no mmc --make,
and conditionally selecting the appropriate one. The latter definition
has the problem that it refers to mmake variables that are intended
to be defined in .dv files created by mmc --generate-dependencies,
but until that has been run, those mmake variables are undefined.
Until now, the only directories that had both the mmc --make
and the no mmc --make definitions were the ones needed to build
the compiler. Bootchecks in the csharp and java grades, which
always use --make make, got errors when they tried to build
the directories that bootcheck builds after the compiler:
the slice, profiler, deep_prof and mfilterjavac directories.
This diff ensures that all directories we build in bootcheck
get all both versions of the os, cs, css, and javas targets.
In fact, they get two subversions of the no mmc --make version:
one for use in the presence of .dv files, and one for use in their
absence. The latter just builds the .dv files and invokes mmake
again. This avoids one source of warnings about undefined mmake
variables.
To avoid another source, make the rules for tags files and their
proxies depends on *.m instead of mmake variables such as $(mcov.ms),
since this makes sense even before making dependencies. The only price
is that any untracked Mercury source files in the directory have to
either be given some other suffix, or moved somewhere else.
Where relevant, make the mtags invocation prefer the master versions
of files that are copied from the mdbcomp directory to other directories,
since this is the only writeable version.
Make the os and cs rules consistently NOT build the _init.[co] files.
The way we use those files in bootcheck, we never need them;
when we need them, the right target to give is the executable anyway.
In the slice directory, don't put mcov between mtc_union and mtc_diff.
Eliminate unnecessary duplication, e.g. of sources in rules.
Eliminate double negatives in conditionals.
Fix formatting.
Mmake.common.in:
bindist/Mmakefile:
bytecode/Mmakefile:
compiler/Mmakefile:
doc/Mmakefile:
grade_lib/Mmakefile:
robdd/Mmakefile:
samples/Mmakefile:
scripts/Mmakefile:
tools/Mmakefile:
trace/Mmakefile:
util/Mmakefile:
Add "ft=make" to vim modelines. This is redundant for the files whose
names is Mmakefile, but it is needed for Mmake.common.
|
||
|
|
f87c5efcac |
Avoid floats that are not exact binary fractions.
Such floats are one reason why the generated .cs and .java files
for stages 2 and 3 differ. After this diff, differences such as
- double Var_12 = 0.90000000000000002;
+ double Var_12 = 0.90000000000000000;
should go away.
compiler/make.module_target.m:
library/hash_table.m:
library/version_hash_table.m:
mdbcomp/slice_and_dice.m:
Replace float fractions that are not exact binary fractions with
close by fractions that are exact binary fractions. In none of these cases
was there a strong reason for the actual value originally picked.
|
||
|
|
9789375cc5 |
Make pre-HLDS passes use file-kind-specific parse trees.
Replacing item blocks file-kind-specific kinds of section markers with
file-kind-specific parse trees has several benefits.
- It allows us to encode the structural invariants of each kind of file
we read in within the type of its representation. This makes the detection
of any accidental violations of those invariants trivial.
- Since each file-kind-specific parse tree has separate lists for separate
kinds of items, code that wants to operate on one or a few kinds of items
can just operate on those kinds of items, without having to traverse
item blocks containing many other kinds of items as well. The most
important consequence of this is not the improved efficiency, though
that is nice, but the increased clarity of the code.
- The new design is much more flexible. For example, it should be possible
to record that e.g. an interface file we read in as a indirect dependency
(i.e. a file we read not because its module was imported by the module
we are compiling, but because its module was imported by *another* imported
module) should be used *only* for the purpose it was read in for. This should
avoid situations where deleting an import of A from a module, because it
is not needed anymore, leads the compiler to generate an error message
about a missing import of module B. This can happen if (a) module B
always *should* have been imported, since it is used, but (b) module A's
import of module B lead to module B's interface being available *without*
an import of B.
Specifically, this flexibility should enable us to establish each module's
.int file as the single source of truth about how values of each type
defined in that module should be represented. When compiling each source
file, this approach requires the compiler to read in that module's .int file
but using only the type_repn items from that .int file, and nothing else.
- By recording a single parse tree for each file we have read, instead of
a varying number of item blocks, it should be significantly easier to
derive the contents of .d files directly from the records of those
parse trees, *without* having to maintain a separate set of fields
in the module_and_imports structure for that purpose. We could also
trivially avoid any possibility of inconsistencies between these two
different sources of truth. (We currently fill in the fields used to
drive the generation of .d files using two different pieces of code,
one used for --generate-dependencies and one used for all other invocations,
and these two *definitely* generate inconsistent results, as the significant
differences in .d files between (a) just after an invocation of
--generate-dependencies and (b) just after any other compiler invocation
can witness.)
This change is big and therefore hard to review. Therefore in many files,
this change adds "XXX CLEANUP" comments to draw attention to places that
have issues that should be fixed, but whose fixes should come later, in
separate diffs.
compiler/module_imports.m:
The compiler uses the module_and_imports structure defined here
to go from a raw compilation unit (essentially a module to be compiled)
to an augmented compilation unit (a raw compilation unit together
with all the interface and optimization files its compilation needs).
We used to store the contents of both the source file and of
the interface and optimization files in the module_and_imports structure
as item blocks. This diff replaces all those item blocks with
file-kind-specific parse trees, for the reasons mentioned above.
Separate out the .int0 files of ancestors modules from the .intN
files for N>0 of directly imported modules. (Their item blocks
used to be stored in the same list.)
Maintain a database of the source, interface and optimization files
we have read in so far. We use it to avoid reading in interface files
if we have already read in a file for the same module that contains
strictly more information (either an interface file with a smaller
number as a suffix, or the source file itself).
Shorten some field names.
compiler/prog_item.m:
Define data structures for storing information about include_module,
import_module and use_module declarations, both in a form that allows
the representation of possibly erroneous code in actual source files,
and in checked-and-cleaned-up form which is guaranteed to be free
of the relevant kinds of errors. Add a block comment at the start
of the module about the need for this distinction.
Define parse_tree_module_src, a data structure for representing
the source code of a single module. This is different from the existing
parse_tree_src type, which represents the contents of a single source file
but which may contain *more* than one module, and also different from
a raw_compilation_unit, which is based on item blocks and is thus
unable to express to invariants such as "no clauses in the interface".
Modify the existing parse_tree_intN types to express the distinction
mentioned just above, and to unify them "culturally", i.e. if they
store the same information, make them store it using the same types.
Fix a mistake by allowing promises to appear in .opt files.
I originally ruled them out because the code that generates .opt files
does not have any code to write out promises, but some of the predicates
whose clauses it writes out have goal_type_promise, which means that
they originated as promises, and get written out as promises.
Split the existing pragma item kind into three item kinds, which have
different invariants applying to them.
- The decl (short for declarative) pragmas give the compiler some
information, such as that a predicate is obsolete or that we
want to type specialize some predicate or function, that is in effect
part of the module's interface. Decl pragmas may appear in module
interfaces, and the compiler may put them into interface files;
neither statement is true of the other two kinds of pragmas.
- The impl (short for implementation) pragmas are named so
precisely because they may appear only in implementation sections.
They give the compiler information that is private to that module.
Examples include foreign_decls, foreign_codes, foreign_procs,
and promises of clause equivalence, and requests for inlining,
tabling etc. These will never be put into interface files,
though some of them can affect the compilation of other modules
by being included in .opt files.
- The gen (short for generated) pragmas can never (legally) appear
in source files at all. They record the results of compiler
analyses e.g. about which arguments of a predicate are unused,
or what exceptions a function can throw, and accordingly they
should only ever occur in compiler-generated interface files.
Use the new type differences between the three kinds of pragmas
to encode the above invariants about which kinds of pragmas can appear
where into the various kinds of parse trees.
Make the augmented compilation unit, which is computed from
the final module_and_imports structure, likewise switch from
storing item blocks to storing the whole parse trees of the
files that went into its construction. With each such parse tree,
record *why* we read it, since this controls what permissions
the source module being compiled has for access to the entities
in the parse tree.
Simplify the contains_foreign_code type, since one of three
function symbols was equivalent to one possible use of another
function symbol.
Provide a way to record which method of which class a compiler-generated
predicate is for. (See hlds_pred.m below.)
Move the code of almost all utility operations to item_util.m
(which is imported by many fewer modules than prog_item.m),
keeping just the most "popular" ones.
compiler/item_util.m:
Move most of the previously-existing utility operations here from
prog_item.m, most in a pretty heavily modified form.
Add a whole bunch of other utility operations that are needed
in more than one other module.
compiler/convert_parse_tree.m:
Provide predicates to convert from raw compilation units to
parse_tree_module_srcs, and vice versa (though the reverse
shouldn't be needed much longer).
Update the conversion operations between the general parse_tree_int
and the specific parse_tree_intN forms for the changes in prog_item.m
mentioned above. In doing so, use a consistent approach, based on
new operations in item_util.m, to detect errors such as duplicate
include_module and import/use_module declarations in all kinds
of parse trees.
Enforce the invariants that the types of parse trees of various kinds
can now express in types, generating error messages for their violations.
Delete some utility operations that have been moved to item_util.m
because now they are also needed by other modules.
compiler/grab_modules.m:
Delete code that did tests on raw compilation units that are now done
when that raw compilation unit is converted to a parse_tree_module_src.
Use the results of the checks done during that conversion to decide
which modules are imported/used and in which module section.
Record a single reason for why we reading in each interface and
optimization file. The code of make_hlds_separate_items.m will use
this reason to set up the appropriate permissions for each item
in those files.
Use separate code for handling different kinds of interface and
optimization files. Using generic traversal code was acceptable economy
when we used the same data structure for every kind of interface file,
but now that we *can* express different invariants for different kinds
of interface and optimization file, we want to execute not just different
code for each kind of file, but the data structures we want to work on
are also of different types. Using file-kind-specific code is a bit
longer, but it is significantly simpler and more robust, and it is
*much* easier to read and understand.
Delete the code that separates the parts of the implementation section
that are exported to submodules, and the part that isn't, since that task
is now done in make_hlds_separate_items.m.
Pass a database of the files we have read through the relevant predicates.
Give some predicates more meaningful names.
compiler/notes/interface_files.html:
Note a problem with the current operation of grab_modules.
compiler/get_dependencies.m:
Add operations to gather implicit references to builtin modules
(which have to be made available even without an explicit import_module
or use_module declaration) in all kinds of parse trees. These have
more code overall, but will be at runtime, since we need only look at
the item kinds that may *have* such implicit references.
Add a mechanism to record the result of these gathering operations
in import_and_or_use_maps.
Give some types, function symbols, predicates and variables
more meaningful names.
compiler/make_hlds_separate_items.m:
When we stored the contents of the source module and the
interface and optimization files we read in to augment it
in the module_and_imports structure as a bunch of item blocks,
the job of this module was to separate out the different kinds of items
in the item blocks, returning a single list of each kind of item,
with each such item being packaged up with its status (which encodes
a set of permissions saying what the source module is allowed
to do with it).
Now that the module_and_imports structure stores this info in
file-kind-specific parse trees, all of which have separate lists
for each kind of item and none of which contain item blocks,
the job of this module has changed. Now its job is to convert
the reason why each file was read in into the (one or more) statuses
that apply to the different kinds of items stored in it, wrap up
each item with its status, and return the resulting overall list
of status/item pairs for each kind of item.
compiler/read_modules.m:
Add predicates that, when reading an interface file, return its contents
in the tightest possible file-kind-specific parse tree.
Refine the database of files we have read to allow us to store
more file-kind-specific parse trees.
Don't require that files in the database have associated timestamps,
since in some cases, we read files we can put into the database
*without* getting their timestamps.
Allow the database to record that an attempt to read a file failed.
compiler/split_parse_tree_src.m:
Rearchitect how this module separates out nested submodules from within
the main module in a file.
Another of the jobs of this module is to generate error messages for
when module A includes module B twice, whether via nesting or via
include_module declarations, with one special exception for the case
where A's interface contains nested submodule A.B's interface,
and A's implementation contains nested submodule A.B's implementation.
The problem ironically was that while it reported duplicate include_module
declarations as errors, split_parse_tree_src.m also *generated*
duplicate include_module declarations. Since it replaced each nested
submodule occurrence with an include_module declaration, in the scenario
above, it generated two include_module declarations for A.B. Even worse,
the interface incarnation of submodule A.B could contain
(the interface of) its own nested submodule A.B.C, while its
implementation incarnation could contain (the implementation section of)
A.B.C. Each occurrence of A.B.C would be its only occurrence in the
including part of its parent A.B, which means local tests for duplicates
do not work. (I found this out the hard way.)
The solution we now adopt adds include_module declarations to the
parents of any submodule only once the parse tree of the entire
file has been processed, since only then do we know all the
includer/included relationships among nested modules. Until then,
we just record such relationships in a database as we discover them,
reporting duplicates when needed (e.g. when A includes B twice
*in the same section*), but not reporting duplicates when not needed
(e.g. when A.B includes A.B.C in *different* sections).
compiler/prog_data.m:
Add a new type, pf_sym_name_and_arity, that exactly specifies
a predicate or function. It is a clone of the existing simple_call_id
type, but its name does NOT imply that the predicate or function
is being called.
Add XXXs that call for some other improvements in type names.
compiler/prog_data_foreign.m:
Give a type, and the operations on that type, a more specific name.
compiler/error_util.m:
Add an id field to all error_specs, which by convention should be
filled in with $pred. Print out the value in this field if the compiler
is invoked with the developer-only option --print-error-spec-id.
This allows a person debugging the compiler find out where in the code
an undesired error message is coming from significantly easier
than was previously possible.
Most of the modules that have changes only "to conform to the changes
above" will be for this change. In many cases, the updated code
will also simplify the creation of the affected error_specs.
Fix a bug that looked for a phase in only one kind of error_spec.
Add some utility operations needed by other parts of this change.
Delete a previously internal function that has been moved to
mdbcomp/prim_data.m to make it accessible in other modules as well.
compiler/Mercury.options:
Ask the compiler to warn about dead predicates in every module
touched by this change (at least in one its earlier versions).
compiler/add_foreign_enum.m:
Replace a check for an inappropriately placed foreign_enum declaration
with a sanity check, since with this diff, the error should be caught
earlier.
compiler/add_mutable_aux_preds.m:
Delete a check for an inappropriately placed mutable declaration,
since with this diff, the error should be caught earlier.
compiler/add_pragma.m:
Instead of adding pass2 and pass3 pragmas, add decl and impl and
generated pragmas.
Delete the tests for generated pragma occurring anywhere except
.opt files, since those tests are now done earlier.
Shorten some too-long predicate names.
compiler/comp_unit_interface.m:
Operate on as specific kinds of parse trees as the interface of this
module will allow. (We could operate on more specific parse trees
if we changed the interface, but that is future work).
Use the same predicates for handling duplicate include_module,
import_module and use_module declarations as everywhere else.
Delete the code of an experiment that shouldn't be needed anymore.
compiler/equiv_type.m:
Replace code that operated on item blocks with code that operates
on various kinds of parse trees.
Move a giant block of comments to the front, where it belongs.
compiler/hlds_module.m:
Add a field to the module_info that lets us avoid generating
misleading error messages above missing definitions of predicates
or functions when those definitions were present but were not
added to the HLDS because they had errors.
Give a field and its access predicates a more specific name.
Mark a spot where an existing type cannot express everything
it is supposed to.
compiler/hlds_pred.m:
For predicates which the compiler creates to represent a class method
(the virtual function, in OOP terms), record not just this fact,
but the id of the class and of the method. Using this extra info
in progress messages (with mmc -V) prevents the compiler from printing e.g.
% Checking typeclass constraints on class method
% Checking typeclass constraints on class method
% Checking typeclass constraints on class method
when checking three such predicates.
compiler/make.m:
Provide a slot in the make_info structure to allow the database
of the files we have read in to be passed around.
compiler/make_hlds_error.m:
Delete predicates that are needed in just one other module,
and have therefore been moved there.
compiler/make_hlds_passes.m:
Add decl, impl and generated pragma separately, instead of adding
pass2 and pass3 pragmas separately.
Do not generate error messages for clauses, initialises or finalises
in module interfaces, since with this diff, such errors should be
caught earlier.
compiler/mercury_compile_main.m:
compiler/recompilation.check.m:
Explicitly pass around the expanded database of parse trees
of files that have been read in.
compiler/module_qual.collect_mq_info.m:
compiler/module_qual.m:
compiler/module_qual.qualify_items.m:
Collect module qualification information, and do module qualification
respectively on parse trees of various kinds, not item blocks.
Take information about what the module may do with the contents
of each interface or optimization file from the record of why
we read that file, not from the section markers in item blocks.
Break up some too-large predicates by carving smaller ones out of them.
compiler/options.m:
Add an option to control whether errors and/or warnings detecting
when deciding what should go into a .intN file be printed,
thus (potentially) preventing the creation of that file.
Add commented-out documentation for a previously totally undocumented
option.
doc/user_guide.texi:
Document the new option.
NEWS:
Announce the new option.
Mention that we now generate warnings for unused import_module and
use_module declarations in the interface even if the module has
submodules.
compiler/write_module_interface_files.m:
Let the new option control whether we filter out any messages generated
when deciding what should go into a .intN file.
compiler/parse_item.m:
Delete actually_read_module_opt, since it is no longer needed;
its callers now call actually_read_module_{plain,trans}_opt instead.
Delete unneeded arguments from some predicates.
compiler/parse_module.m:
Delete some long unused predicates.
compiler/parse_pragma.m:
When parsing pragmas, wrap them up in the new decl, impl or generated
pragma kinds.
compiler/parse_tree_out.m:
Add predicates to write out each of the file-kind-specific parse trees.
compiler/parse_tree_out_pragma.m:
Add predicates to write out decl, impl and generated pragmas.
compiler/polymorphism.m:
Add a conditionally-enabled progress message, which can be useful
in tracking down problems.
compiler/prog_item_stats.m:
Conform NOT to the changes above beyond what is needed to let this module
compile. Let that work be done the next time the functionality of
this module is needed, by which time the affected data structures
maybe have changed further.
compiler/typecheck.m:
Fix a performance problem. With intermodule optimization, we read in
.opt files, some of which (e.g. list.opt and int.opt) contain promises.
These promises are read in as predicates with goal_type_promise,
but they do not have declarations of the types of their arguments
(since promises do not have declarations as such). Those argument types
therefore have to be inferred. That inference replaces the original
"I don't know" argument types with their actual types.
The performance problem is that when we change the recorded argument types
of a predicate, we require another loop over all the predicates in the
module, so that any calls to this predicate can be checked against
the updated types. This is as it should be for callable predicates,
but promises are not callable. So if all the *only* predicates whose
recorded argument types change during the first iteration to fixpoint
are promises, then a second iteration is not needed, yet we used to do it.
The fix is to replace the "Have the recorded types of this predicate
changed?" boolean flag with a bespoke enum that says "Did the checking
of this predicate discover a need for another iteration", and not
setting it when processing predicates whose type is goal_type_promise.
compiler/typecheck_errors.m:
Do not generate an error message for a predicate missing its clauses
is the clauses existed but were not added to the HLDS because they were
in the interface section.
When reporting on ambiguities (when a call can match more than one
predicate or function), sort the possible matches before reporting
them.
compiler/accumulator.m:
compiler/add_class.m:
compiler/add_clause.m:
compiler/add_foreign_proc.m:
compiler/add_mode.m:
compiler/add_pragma_tabling.m:
compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/add_type.m:
compiler/canonicalize_interface.m:
compiler/check_for_missing_type_defns.m:
compiler/check_parse_tree_type_defns.m:
compiler/check_promise.m:
compiler/check_raw_comp_unit.m:
compiler/check_typeclass.m:
compiler/common.m:
compiler/compile_target_code.m:
compiler/compiler_util.m:
compiler/dead_proc_elim.m:
compiler/deps_map.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/du_type_layout.m:
compiler/field_access.m:
compiler/find_module.m:
compiler/float_regs.m:
compiler/format_call.m:
compiler/goal_expr_to_goal.m:
compiler/handle_options.m:
compiler/hlds_out_module.m:
compiler/hlds_out_pred.m:
compiler/hlds_out_util.m:
compiler/inst_check.m:
compiler/intermod.m:
compiler/introduce_parallelism.m:
compiler/layout_out.m:
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make_hlds_warn.m:
compiler/mark_tail_calls.m:
compiler/mercury_compile_llds_back_end.m:
compiler/ml_top_gen.m:
compiler/mmakefiles.m:
compiler/mode_errors.m:
compiler/mode_robdd.equiv_vars.m:
compiler/modes.m:
compiler/module_qual.qual_errors.m:
compiler/oisu_check.m:
compiler/old_type_constraints.m:
compiler/options_file.m:
compiler/parse_class.m:
compiler/parse_dcg_goal.m:
compiler/parse_goal.m:
compiler/parse_inst_mode_defn.m:
compiler/parse_inst_mode_name.m:
compiler/parse_mutable.m:
compiler/parse_sym_name.m:
compiler/parse_type_defn.m:
compiler/parse_type_name.m:
compiler/parse_type_repn.m:
compiler/parse_types.m:
compiler/parse_util.m:
compiler/parse_vars.m:
compiler/post_term_analysis.m:
compiler/post_typecheck.m:
compiler/prog_event.m:
compiler/prog_mode.m:
compiler/purity.m:
compiler/qual_info.m:
compiler/recompilation.version.m:
compiler/resolve_unify_functor.m:
compiler/simplify_goal.m:
compiler/simplify_goal_call.m:
compiler/simplify_goal_disj.m:
compiler/simplify_goal_ite.m:
compiler/simplify_proc.m:
compiler/state_var.m:
compiler/stratify.m:
compiler/style_checks.m:
compiler/superhomogeneous.m:
compiler/table_gen.m:
compiler/term_constr_errors.m:
compiler/term_errors.m:
compiler/termination.m:
compiler/trace_params.m:
compiler/unused_args.m:
compiler/unused_imports.m:
compiler/write_deps_file.m:
compiler/xml_documentation.m:
Conform to the changes above.
mdbcomp/prim_data.m:
Move a utility function on pred_or_funcs here from a compiler module,
to make it available to other compiler modules as well.
scripts/compare_s1s2_lib:
A new script that helped debug this diff, and may help debug
similar diffs the future. It can compare (a) .int* files, (b) .*opt
files, (c) .mh/.mih files or (d) .c files between the stage 1 and
stage 2 library directories. The reason for the restriction
to the library directory is that any problems affecting the
generation of any of these kinds of files are likely to manifest
themselves in the library directory, and if they do, the bootcheck
won't go on to compile any of the other stage 2 directories.
tests/debugger/breakpoints.a.m:
tests/debugger/breakpoints.b.m:
Move import_module declarations to the implementation section
when they are not used in the interface. Until now, the compiler
has ignored this, but this diff causes the compiler to generate
a warning for such misplaced import_module declarations even modules
that have submodules. The testing of such warnings is not the point
of the breakpoints test.
tests/invalid/Mercury.options:
Since the missing_interface_import test case tests error messages
generated during an invocation of mmc --make-interface, add the
new option that *allows* that invocation to generate error messages.
tests/invalid/ambiguous_overloading_error.err_exp:
tests/invalid/max_error_line_width.err_exp:
tests/warnings/ambiguous_overloading.exp:
Expect the updated error messages for ambiguity, in which
the possible matches are sorted.
tests/invalid/bad_finalise_decl.m:
tests/invalid/bad_initialise_decl.m:
Fix programming style.
tests/invalid/bad_item_in_interface.err_exp:
Expect an error message for a foreign_export_enum item in the interface,
where it should not be.
tests/invalid/errors.err_exp:
Expect the expanded wording of a warning message.
tests/invalid/foreign_enum_invalid.err_exp:
Expect a different wording for an error message. It is more "standard"
but slightly less informative.
tests/invalid_submodules/children2.m:
Move a badly placed import_module declaration, to avoid having
the message the compiler now generates for it from affecting the test.
tests/submodules/parent2.m:
Move a badly placed import_module declaration, to avoid having
the message the compiler now generates for it from affecting the test.
Update programming style.
|
||
|
|
a618ab31e1 |
Insist that without mmc -f, module a.b.c be in a.b.c.m.
This should fix Mantis bug #489, which shows that without this, the compiler can mistakenly believe that a file with a name such as lexer.m contains a module of the standard library, rather than a submodule named test.lexer. compiler/parse_module.m: Require that :- module declarations specify the expected name. The name may be expected because it exactly matches the filename (as above), or because mmc -f has recorded the actual name as the expectation. Factor report_module_has_unexpected_name out of check_module_has_expected_name, since it is needed on its own. Simplify its code. Simplify the code for doing checks on :- end_module declarations. doc/reference_manual.texi: Document this change in the reference manual.texi. Replace references to "the University of Melbourne Mercury implementation" with just "the Melbourne Mercury implementation". slice/Mmakefile: Run mmc -f *.m before making dependencies, because the modules copied from mdbcomp have non-fully-qualified filenames. */Mmakefile: Delete inappropriate .PHONY directives from Mercury.modules targets. Include Mercury.modules among the files to be deleted by clean_local targets. tests/submodules/ts.tsub.m: Provide the full name of this module in its :- module declaration. tests/submodules/initialise_parent.initialise_child.m: Fix white space. tests/submodules/*.*.m: Move separate submodules to their fully qualified filenames. |
||
|
|
e97b31a5e5 |
Access strerror() via the I/O state.
The result returned by strerror() may be locale dependent. Treating it as a
constant function as the standard library currently does is incorrect. Fix
this by requiring all access to strerror() (or its Windows equivalent) to be
made via the I/O state.
library/io.m:
Change predicates that access strerror() to take an I/O state pair.
library/dir.m:
Conform to the above change.
Delete unnecessary module qualification.
mdbcomp/program_representation.m:
Conform to the above change.
|
||
|
|
999d51f92f |
Use the same default options for grade_lib as for other dirs.
grade_lib/GRADE_LIB_FLAGS.in:
A new file with default options for the grade_lib directory.
configure.ac:
Create GRADE_LIB_FLAGS from GRADE_LIB_FLAGS.in.
grade_lib/Mmakefile:
Make building GRADE_LIB_FLAGS possible.
Require building GRADE_LIB_FLAGS before any Mercury module is compiled.
Use GRADE_LIB_FLAGS as a source of default flags.
Use a directory-specific params file if it exists.
grade_lib/choose_grade.m:
grade_lib/grade_setup.m:
grade_lib/grade_structure.m:
grade_lib/grade_vars.m:
grade_lib/test_grades.m:
grade_lib/try_all_grade_structs.m:
Fix issues revealed by the flags in GRADE_LIB_FLAGS.
mdbcomp/MDBCOMP_FLAGS.in:
browser/Mmakefile:
Fix aesthetics.
|
||
|
|
4e66989587 | Don't clean up a file we never create. | ||
|
|
ae4b736fdd |
Implement warnings for suspicious recursion.
compiler/simplify_goal_call.m:
If the --warn-suspicious-recursion option is set, and if the warning
isn't disabled, generate warnings for two different kinds of suspicious
recursion. They are both related to, but separate from, the warning
we have long generated for infinite recursion, which occurs when
the input args of a recursive call are the same as the corresponding
args in the clause head.
Both kinds suspicious recursion look at the input args of a recursive call
that are NOT the same as the corresponding args in the clause head.
Both require these args to have non-unique modes. (If they have unique
modes, then the depth of the recursion may be controlled by state outside
the view of the Mercury compiler, which means that a warning would be
likely to be misleading.)
The first kind is when all these args use state variable notation.
Most of the time, we use state var notation to denote the data structures
updated by the recursive code; having variables using such notation
*controlling* the recursion is much less common, and much more likely
to be unintended. The motivation for the new option was this infinitely
looping code, which resulted from neglecting to s/[X | Xs]/Xs/ after
cutting-and-pasting the clause head to the recursive call.
p([X | Xs], !S) :-
...,
p([X | Xs], !S).
The other kind of suspicious recursive call we warn about involve
input arguments where the base names of the input arguments (the part
before any numeric suffixes) seem be switched between the clause head
and the recursive call, as here:
q(As0, Bs0, ...) :-
...,
q(Bs1, As, ...).
compiler/mercury_compile_main.m:
Disable style warnings when invoked with --make-optimization-interface
or its transitive variant. Without this, warnings about suspicious
recursion would get reported in such invocations.
Move a test from a callee to a caller to allow the callee to be
less indented.
compiler/options.m:
Export functionality to mercury_compile_main.m to make the above possible.
library/string.m:
Add a predicate to convert a string to *reverse* char list directly.
Note a discrepancy between the documentation and the implementation
of the old predicate the new one is based on (which converts a string
to a forward char list).
NEWS:
Note the new predicate in string.m.
compiler/cse_detection.m:
compiler/ctgc.selector.m:
compiler/dead_proc_elim.m:
compiler/deforest.m:
compiler/dep_par_conj.m:
compiler/det_analysis.m:
compiler/distance_granularity.m:
compiler/frameopt.m:
compiler/inst_util.m:
compiler/lp_rational.m:
compiler/matching.m:
compiler/modes.m:
compiler/old_type_constraints.m:
compiler/rbmm.points_to_analysis.m:
compiler/rbmm.region_arguments.m:
compiler/recompilation.usage.m:
compiler/stratify.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/structure_reuse.indirect.m:
compiler/typeclasses.m:
compiler/use_local_vars.m:
deep_profiler/callgraph.m:
deep_profiler/canonical.m:
library/bit_buffer.read.m:
library/bit_buffer.write.m:
library/calendar.m:
library/diet.m:
library/lexer.m:
library/parser.m:
library/parsing_utils.m:
library/ranges.m:
library/set_ctree234.m:
library/set_tree234.m:
library/string.parse_util.m:
library/tree234.m:
library/varset.m:
mdbcomp/program_representation.m:
mdbcomp/rtti_access.m:
profiler/demangle.m:
Avoid warnings for suspicious recursion. In most cases, do this by
wrapping disable_warning scopes around the affected recursive calls;
in a few cases, do this by changing the code.
tests/warnings/suspicious_recursion.{m,exp}:
A test case for the new warnings.
tests/warnings/Mercury.options:
tests/warnings/Mmakefile:
Enable the new test case.
|
||
|
|
1f8d8aeabf |
Warn about non-contiguous clauses in the Mercury system by default.
configure.ac:
Require the installed compiler to have the recent bug fix to
contiguity warnings, since without that bug fix, we get warnings
for code that is actually perfectly ok.
browser/MDB_FLAGS.in:
compiler/COMP_FLAGS.in:
deep_profiler/DEEP_FLAGS.in:
library/LIB_FLAGS.in:
mdbcomp/MDBCOMP_FLAGS.in:
mfilterjavac/MFILTERJAVAC_FLAGS.in:
profiler/PROF_FLAGS.in:
slice/SLICE_FLAGS.in:
ssdb/SSDB_FLAGS.in:
Specify both --warn-non-contiguous-clauses and
--warn-non-contiguous-foreign-procs as the default in each directory.
library/Mercury.options:
Disable the warnings for exception.m and io.m, which are have not
been cleaned up yet wrt these warnings.
|
||
|
|
c5ac31fdcb |
Enable --warn-suspicious-foreign-code.
Enable the recently added --warn-suspicious-foreign-code warning by default for
the Mercury system.
configure.ac:
Check that --warn-suspicious-foreign-code is supported by the bootstrap
compiler
browser/MDB_FLAGS.in:
compiler/COMP_FLAGS.in:
deep_profiler/DEEP_FLAGS.in:
library/LIB_FLAGS.in:
mdbcomp/MDBCOMP_FLAGS.in:
slice/SLICE_FLAGS.in:
ssdb/SSDB_FLAGS.in:
profiler/PROF_FLAGS.in:
Enable the option.
|
||
|
|
8303b503b6 |
Unify and compare packed args in bulk when possible.
compiler/unify_proc.m:
Try to optimize the code we generate for unification and comparison
predicates when a function symbol's arguments include sub-word-sized
arguments packed together into a word.
For unify predicates, generate code to test whether the two words
at the same offset in the terms being unified are equal. This works
regardless of whether the arguments are signed or unsigned.
For compare predicates, generate code to compare the two words
at the same offset in the terms being compared *if* all the arguments
in the terms being compared are unsigned. This works because we put
the earlier arguments in the more significant bit positions. But if
some of the arguments are signed, then divide the argument word
in sequences of zero or more unsigned arguments separated by signed
arguments. We then generate code that compares any contiguous sequences
of unsigned arguments in bulk, while comparing each signed field
separately.
Do the bulk unification and comparison via foreign_proc goals generated
inline. This works only when we are generating C, but this is ok because
we pack sub-word-sized arguments into a word only when generating C.
We do the comparison of signed sub-word-sized fields (int8, int16 or int32)
via foreign_proc goals generated inline as well. Doing them using unify
goals would work as well, but would be less efficient in general. This is
because having N such arguments in a function symbols requires storing
only one value across calls for each term being compared (the term itself)
when generating foreign_procs, but would require storing N values across
calls (the values of the sub-word-sized signed arguments) when generating
unifications. Generating inline foreign_procs is effectively a manual
application of the optimization implemented by saved_vars.m.
library/private_builtin.m:
Add the builtin predicates that unify_proc.m now generates calls to.
We should never need their bodies, but the compiler does need to know
the declarations of all predicates mentioned in inline foreign_procs.
configure.ac:
runtime/mercury_conf.h.in:
Define either MR_MERCURY_IS_32_BITS or MR_MERCURY_IS_64_BITS depending
on the word size. Make the configured value of MR_BITS_PER_WORD available
to C code.
mdbcomp/program_representation.m:
Register the new builtin predicates as no_typeinfo_builtins, i.e.
builtins whose arguments' types contain type variables, that nevertheless
should *not* be passed the typeinfos of the actual types bound to those
type variables.
compiler/hlds_clauses.m:
Bulk unification of arguments works only when all the arguments involved
are initially ground. The optimized unification clauses we can now generate
are thus appropriate only for <in,in> unifications. (Technically, they
*would* work for unifications for which the function symbol arguments
involved in bulk unify operations are ground even if some other arguments
are initially free, but that distinction is too hard to make, compared
to the extremely small performance gain that would be available
if we *could* make that distinction.)
Provide a way for unify_proc.m to mark a clause as being for use either
in the <in,in> modes of unifications (for the optimized version using bulk
unifications), or as in all other modes of unifications (for a version in
which that optimization has been disabled).
Replace two boolean fields in clauses_infos with bespoke types, for
greater readability and reliability. These are a remnant of a different
way to differentiate <in,in> vs non-<in,in> clauses that I ultimately
decided against. These bespoke types are independent of the main change
in this diff, but there is no reason to undo their use.
compiler/clause_to_proc.m:
When copying clauses to procedure bodies inside type-specific unify
predicates, pay attention to the markers that unify_proc.m put on
those clauses about which are for <in,in> modes and which are for
non-<in,in> modes.
To make this possible, make our callers pass us extra information.
compiler/options.m:
Add a bootstrapping option that governs whether unify_proc.m should
try to apply the new optimization.
Give an option that governs comparisons of function symbols for Erlang
a name that reflects that fact.
compiler/hlds_pred.m:
Fix a misleading predicate name.
compiler/add_class.m:
compiler/add_clause.m:
compiler/add_foreign_proc.m:
compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/dead_proc_elim.m:
compiler/det_report.m:
compiler/erl_code_gen.m:
compiler/handle_options.m:
compiler/higher_order.m:
compiler/hlds_out_module.m:
compiler/hlds_out_pred.m:
compiler/hlds_statistics.m:
compiler/intermod.m:
compiler/mercury_compile_front_end.m:
compiler/ml_proc_gen.m:
compiler/modecheck_unify.m:
compiler/proc_gen.m:
compiler/proc_requests.m:
compiler/purity.m:
compiler/resolve_unify_functor.m:
compiler/structure_reuse.indirect.m:
compiler/structure_sharing.analysis.m:
compiler/tabling_analysis.m:
compiler/type_constraints.m:
compiler/typecheck.m:
compiler/unused_args.m:
Conform to the changes above.
|
||
|
|
2d02046650 | Simplify the code of a predicate. | ||
|
|
72f174b4e2 |
Don't print value of errno in MR_fatal_error.
The majority of calls to MR_fatal_error do not follow an operation that sets errno, so printing out an error message unrelated to the reason for the fatal error will lead to confusion. It can also cause test failures if errno happens to be set to non-zero some time prior to an expected call to MR_fatal_error. Fixes bug #464. runtime/mercury_misc.c: Don't print value of errno in MR_fatal_error. runtime/mercury_context.c: runtime/mercury_thread.c: Pass strerror strings to MR_fatal_error where appropriate. runtime/mercury_memory_zones.c: runtime/mercury_memory_zones.h: Pass strerror strings to MR_fatal_error following failures of MR_protect_pages. Document that this assumes MR_protect_pages sets errno on error. Skip unnecessary call to sprintf before MR_fatal_error. runtime/mercury_deep_profiling.c: Skip unnecessary call to sprintf before MR_fatal_error. Reduce size of some buffers. runtime/mercury_overflow.c: runtime/mercury_stack_trace.c: Pass a fixed format string to MR_fatal_error just in case the message string may contain percentage signs. runtime/mercury_tabling.c: Skip unnecessary call to sprintf before MR_fatal_error. deep_profiler/timeout.m: library/thread.m: mdbcomp/shared_utilities.m: Pass strerror strings to MR_fatal_error where appropriate. trace/mercury_trace.c: Skip unnecessary call to sprintf before MR_fatal_error. trace/mercury_trace_external.c: Pass a fixed format string to MR_fatal_error just in case. |
||
|
|
7a14e6d7bd |
Fix missing whitespace.
library/getopt_io.m:
mdbcomp/rtti_access.m:
As above.
|
||
|
|
2bfe4d402c | Compile everything with --halt-at-warn-if-possible. | ||
|
|
83d1ce637e |
Delete private_builtin.store_at_ref.
It was deprecated in favour of store_at_ref_impure ten years ago.
library/private_builtin.m:
Delete the predicate's declaration.
compiler/builtin_ops.m:
Delete the predicate's definition as a builtin.
compiler/add_pred.m:
compiler/lco.m:
compiler/term_constr_initial.m:
mdbcomp/program_representation.m:
Delete references to the predicate.
|
||
|
|
46fbdba449 |
Workaround limitations of the Roslyn C# compiler on non-Windows systems.
Signing assemblies with a strong name does not work with the Rosyln C# compiler on non-Windows systems. Delay sign assemblies on non-Windows system instead when using this compiler. (This is what the Mono documentation currently recommends.) configure.ac: browser/MDB_FLAGS.in: library/LIB_FLAGS.in: mdbcomp/MDBCOMP_FLAGS.in: ssdb/SSDB_FLAGS.in: As above. |
||
|
|
006b29bd20 |
Fix strncpy() string truncation warning.
mdbcomp/rtti_access.m:
Fix gcc -Wstringop-truncation warning for call to strncpy().
|
||
|
|
d465fa53cb |
Update the COPYING.LIB file and references to it.
Discussion of these changes can be found on the Mercury developers
mailing list archives from June 2018.
COPYING.LIB:
Add a special linking exception to the LGPL.
*:
Update references to COPYING.LIB.
Clean up some minor errors that have accumulated in copyright
messages.
|
||
|
|
f519e26173 |
Add builtin 64-bit integer types -- Part 1.
Add the new builtin types: int64 and uint64.
Support for these new types will need to be bootstrapped over several changes.
This is the first such change and does the following:
- Extends the compiler to recognise 'int64' and 'uint64' as builtin types.
- Extends the set of builtin arithmetic, bitwise and relational operators
to cover the new types.
- Adds the new internal option '--unboxed-int64s' to the compiler; this will be
used to control whether 64-bit integer types are boxed or not.
- Extends all of the code generators to handle the new types.
- Extends the runtimes to support the new types.
- Adds new modules to the standard library intend to contain basic operations
on the new types. (These are currently empty and not documented.)
There are bunch of limitations marks with "XXX INT64"; these will be lifted in
part 2 of this change. Also, 64-bit integer types are currently always boxed,
again this limitation will be lifted in later changes.
compiler/options.m:
Add the new option --unboxed-int64s.
compiler/prog_type.m:
compiler/prog_data.m:
compiler/builtin_lib_types.m:
Recognise int64 and uint64 as builtin types.
compiler/builtin_ops.m:
Add builtin operations for the new types.
compiler/hlds_data.m:
Add new tag types for the new types.
compiler/ctgc.selector.m:
compiler/dead_proc_elim.m:
compiler/export.m:
compiler/foreign.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/hlds_code_util.m:
compiler/hlds_dependency_graph.m:
compiler/hlds_out_pred.m:
compiler/hlds_out_util.m:
compiler/implementation_defined_literals.m:
compiler/inst_check.m:
compiler/mercury_to_mercury.m:
compiler/mode_util.m:
compiler/module_qual.qualify_items.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/parse_tree_to_term.m:
compiler/parse_type_name.m:
compiler/polymorphism.m:
compiler/prog_out.m:
compiler/prog_util.m:
compiler/rbmm.execution_path.m:
compiler/rtti.m:
compiler/table_gen.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/unify_gen.m:
compiler/unify_proc.m:
compiler/unused_imports.m:
compiler/xml_documentation.m:
Conform to the above changes to the parse tree and HLDS.
compiler/c_util.m:
Support writing out constants of the new types.
compiler/llds.m:
Add a representation for constants of the new types to the LLDS.
compiler/stack_layout.m:
Add a new field to the stack layout params that records whether
64-bit integers are boxed or not.
compiler/call_gen.:m
compiler/code_info.m:
compiler/disj_gen.m:
compiler/dupproc.m:
compiler/exprn_aux.m:
compiler/global_data.m:
compiler/jumpopt.m:
compiler/llds_out_data.m:
compiler/llds_out_instr.m:
compiler/lookup_switch.m:
compiler/mercury_compile_llds_back_end.m:
compiler/prog_rep.m:
compiler/prog_rep_tables.m:
compiler/var_locn.m b/compiler/var_locn.m:
Support the new types in the LLDS code generator.
compiler/mlds.m:
Support constants of the new types in the MLDS.
compiler/ml_call_gen.m:
compiler/ml_code_util.m:
compiler/ml_global_data.m:
compiler/ml_rename_classes.m:
compiler/ml_top_gen.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
compiler/mlds_to_target_util.m:
compiler/rtti_to_mlds.m:
Conform to the above changes to the MLDS.
compiler/mlds_to_c.m:
compiler/mlds_to_cs.m:
compiler/mlds_to_java.m:
Generate the appropriate target code for constants of the new types
and operations involving them.
compiler/bytecode.m:
compiler/bytecode_gen.m:
Handle the new types in the bytecode generator; we just abort if we
encounter them for now.
compiler/elds.m:
compiler/elds_to_erlang.m:
compiler/erl_call_gen.m:
compiler/erl_code_util.m:
compiler/erl_unify_gen.m:
Handle the new types in the Erlang code generator.
library/private_builtin.m:
Add placeholders for the builtin unify and compare operations for
the new types. Since the bootstrapping compiler will not recognise
the new types we give them polymorphic arguments. These can be
replaced after this change has bootstrapped.
Update the Java list of TypeCtorRep constants here.
library/int64.m:
library/uint64.m:
New modules that will eventually contain builtin operations on the new
types.
library/library.m:
library/MODULES_UNDOC:
Do not include the above modules in the library documentation for now.
library/construct.m:
library/erlang_rtti_implementation.m:
library/rtti_implementation.m:
library/table_statistics.m:
deep_profiler/program_representation_utils.m:
mdbcomp/program_representation.m:
Handle the new types.
configure.ac:
runtime/mercury_conf.h.in:
Define the macro MR_BOXED_INT64S. For now it is always defined, support for
unboxed 64-bit integers will be enabled in a later change.
runtime/mercury_dotnet.cs.in:
java/runtime/TypeCtorRep.java:
runtime/mercury_type_info.h:
Update the list of type_ctor reps.
runtime/mercury.h:
runtime/mercury_int.[ch]:
Add macros for int64 / uint64 -> MR_Word conversion, boxing and
unboxing.
Add functions for hashing 64-bit integer types suitable for use
with the tabling mechanism.
runtime/mercury_tabling.[ch]:
Add additional HashTableSlot structs for 64-bit integer types.
Omit the '%' character from the conversion specifiers we pass via
the 'key_format' argument to the macros that generate the table lookup
function. This is so we can use the C99 exact size integer conversion
specifiers (e.g. PRIu64 etc.) directly here.
runtime/mercury_hash_lookup_or_add_body.h:
Add the '%' character that was omitted above to the call to debug_key_msg.
runtime/mercury_memory.h:
Add new builtin allocation sites for boxed 64-bit integer types.
runtime/mercury_builtin_types.[ch]:
runtime/mercury_builitn_types_proc_layouts.h:
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_ml_expand_body.h:
runtime/mercury_table_type_body.h:
runtime/mercury_tabling_macros.h:
runtime/mercury_tabling_preds.h:
runtime/mercury_term_size.c:
runtime/mercury_unify_compare_body.h:
Add the new builtin types and handle them throughout the runtime.
runtime/Mmakefile:
Add mercury_int.c to the list of .c files.
doc/reference_manual.texi:
Add the new types to the list of reserved type names.
Add the mapping from the new types to their target language types.
These are commented out for now.
|
||
|
|
014ca2144b |
Enable --warn-insts-with-functors-without-type.
configure.ac:
Require that the installed compiler support this option (which I added
about two weeks ago).
browser/MDB_FLAGS.in:
compiler/COMP_FLAGS.in:
deep_profiler/DEEP_FLAGS.in:
library/LIB_FLAGS.in:
mdbcomp/MDBCOMP_FLAGS.in:
mfilterjavac/MFILTERJAVAC_FLAGS.in:
profiler/PROF_FLAGS.in:
slice/SLICE_FLAGS.in:
ssdb/SSDB_FLAGS.in:
Specify this option by default for every directory that contains
Mercury code.
|
||
|
|
d9e576a2b2 |
Specify the type for inst definitions.
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
library/*.m:
mdbcomp/*.m:
ssdb/*.m:
Specify the type constructor for every inst definition that lists
the functors that values of that type may be bound to.
In library/maybe.m, delete the inst maybe_errors/1, because
(a) its name is misleading, since it is for the maybe_error/1 type (no s),
and (b) there is already an inst with the non-misleading name maybe_error
which had an identical definition.
In compiler/dep_par_conj.m, delete two insts that were duplicates
of insts defined in hlds_goal.m, and replace references to them
accordingly.
|
||
|
|
ba24a880fe |
Add targets for building stage 3 C# source files.
browser/Mmakefile:
compiler/Mmakefile:
deep_profiler/Mmakefile:
library/Mmakefile:
mdbcomp/Mmakefile:
profiler/Mmakefile:
slice/Mmakefile:
ssdb/Mmakefile:
Add the 'css' target for building the C# source files.
|
||
|
|
345bdfff55 |
Add targets for building the Java source files only.
browser/Mmakefile:
compiler/Mmakefile:
deep_profiler/Mmakefile:
mdbcomp/mdbcmp/Mmakefile:
profiler/Mmakefile:
slice/Mmakefile:
ssdb/Mmakefile:
As above (required for stage 3).
Delete residual references to the IL backend.
|
||
|
|
8a240ba3f0 |
Add builtin 8, 16 and 32 bit integer types -- Part 1.
Add the new builtin types: int8, uint8, int16, uint16, int32 and uint32.
Support for these new types will need to be bootstrapped over several changes.
This is the first such change and does the following:
- Extends the compiler to recognise 'int8', 'uint8', 'int16', 'uint16', 'int32'
and 'uint32' as builtin types.
- Extends the set of builtin arithmetic, bitwise and relational operators to
cover the new types.
- Extends all of the code generators to handle new types. There currently lots
of limitations and placeholders marked by 'XXX FIXED SIZE INT'. These will
be lifted in later changes.
- Extends the runtimes to support the new types.
- Adds new modules to the standard library intended to hold the basic
operations on the new types. (These are currently empty and not documented.)
This change does not introduce the two 64-bit types, 'int64' and 'uint64'.
Their implementation is more complicated and is best left to a separate change.
compiler/prog_type.m:
compiler/prog_data.m:
compiler/builtin_lib_types.m:
Recognise int8, uint8, int16, uint16, int32 and uint32 as builtin types.
Add new type, int_type/0,that enumerates all the possible integer types.
Extend the cons_id/0 type to cover the new types.
compiler/builtin_ops.m:
Parameterize the integer operations in the unary_op/0 and binary_op/0
types by the new int_type/0 type.
Add builtin operations for all the new types.
compiler/hlds_data.m:
Add new tag types for the new types.
compiler/hlds_pred.m:
Parameterize integers in the table_trie_step/0 type.
compiler/ctgc.selector.m:
compiler/dead_proc_elim.m:
compiler/export.m:
compiler/foreign.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/hlds_code_util.m:
compiler/hlds_dependency_graph.m:
compiler/hlds_out_pred.m:
compiler/hlds_out_util.m:
compiler/implementation_defined_literals.m:
compiler/inst_check.m:
compiler/mercury_to_mercury.m:
compiler/mode_util.m:
compiler/module_qual.qualify_items.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/parse_tree_out_info.m:
compiler/parse_tree_to_term.m:
compiler/parse_type_name.m:
compiler/polymorphism.m:
compiler/prog_out.m:
compiler/prog_rep.m:
compiler/prog_rep_tables.m:
compiler/prog_util.m:
compiler/rbmm.exection_path.m:
compiler/rtti.m:
compiler/rtti_to_mlds.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/type_constraints.m:
compiler/type_ctor_info.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/unify_gen.m:
compiler/unify_proc.m:
compiler/unused_imports.m:
compiler/xml_documentation.m:
Conform to the above changes to the parse tree and HLDS.
compiler/c_util.m:
Support generating the builtin operations for the new types.
doc/reference_manual.texi:
Add the new types to the list of reserved type names.
Add the mapping from the new types to their target language types.
These are commented out for now.
compiler/llds.m:
Replace the lt_integer/0 and lt_unsigned functors of the llds_type/0,
with a single lt_int/1 functor that is parameterized by the int_type/0
type.
Add a representations for constants of the new types to the LLDS.
compiler/call_gen.m:
compiler/dupproc.m:
compiler/exprn_aux.m:
compiler/global_data.m:
compiler/jumpopt.m:
compiler/llds_out_data.m:
compiler/llds_out_global.m:
compiler/llds_out_instr.m:
compiler/lookup_switch.m:
compiler/middle_rec.m:
compiler/peephole.m:
compiler/pragma_c_gen.m:
compiler/stack_layout.m:
compiler/string_switch.m:
compiler/switch_gen.m:
compiler/tag_switch.m:
compiler/trace_gen.m:
compiler/transform_llds.m:
Support the new types in the LLDS code generator.
compiler/mlds.m:
Support constants of the new types in the MLDS.
compiler/ml_accurate_gc.m:
compiler/ml_call_gen.m:
compiler/ml_code_util.m:
compiler/ml_disj_gen.m:
compiler/ml_foreign_proc_gen.m:
compiler/ml_global_data.m:
compiler/ml_lookup_switch.m:
compiler/ml_simplify_switch.m:
compiler/ml_string_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
compiler/mlds_to_target_util.m:
Conform to the above changes to the MLDS.
compiler/mlds_to_c.m:
compiler/mlds_to_cs.m:
compiler/mlds_to_java.m:
Generate the appropriate target code for constants of the new
types and operations involving them.
compiler/bytecode.m:
compiler/bytecode_gen.m:
Handle the new types in the bytecode generator; we just abort if we
encounter them for now.
compiler/elds.m:
compiler/elds_to_erlang.m:
compiler/erl_call_gen.m:
compiler/erl_code_util.m:
compiler/erl_rtti.m:
compiler/erl_unify_gen.m:
Handle the new types in the Erlang code generator.
library/private_builtin.m:
Add placeholders for the builtin unify and compare operations for
the new types. Since the bootstrapping compiler will not recognise
the new types we give the polymorphic arguments. These can be
replaced after this change has bootstrapped.
Update the Java list of TypeCtorRep constants.
library/int8.m:
library/int16.m:
library/int32.m:
library/uint8.m:
library/uint16.m:
library/uint32.m:
New modules that will eventually contain builtin operations
on the new types.
library/library.m:
library/MODULES_UNDOC:
Do not include the above modules in the library documentation
for now.
library/construct.m:
library/erlang_rtti_implementation.m:
library/rtti_implementation.m:
deep_profiler/program_representation_utils.m:
mdbcomp/program_representation.m:
Handle the new types.
runtime/mercury_dotnet.cs.in:
java/runtime/TypeCtorRep.java:
runtime/mercury_type_info.h:
Update the list of TypeCtorReps.
configure.ac:
runtime/mercury_conf.h.in:
Check for the header stdint.h.
runtime/mercury_std.h:
Include stdint.h; abort if that header is no present.
runtime/mercury_builtin_types.[ch]:
runtime/mercury_builtin_types_proc_layouts.h:
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_ml_expand_body.h
runtime/mercury_table_type_body.h:
runtime/mercury_tabling_macros.h:
runtime/mercury_tabling_preds.h:
runtime/mercury_term_size.c:
runtime/mercury_unify_compare_body.h:
Add the new builtin types and handle them throughout the runtime.
|
||
|
|
1a778114db |
Fix more warnings from --warn-inconsistent-pred-order-clauses.
mdbcomp/builtin_modules.m:
mdbcomp/feedback.automatic_parallelism.m:
mdbcomp/feedback.m:
mdbcomp/mdbcomp.goal_path.m:
mdbcomp/mer_mdbcomp.m:
mdbcomp/prim_data.m:
mdbcomp/program_representation.m:
mdbcomp/rtti_access.m:
mdbcomp/slice_and_dice.m:
mdbcomp/sym_name.m:
mdbcomp/trace_counts.m:
Fix inconsistencies between (a) the order in which functions and predicates
are declared, and (b) the order in which they are defined.
In most modules, either the order of the declarations or the order
of the definitions made sense, and I changed the other to match.
In some modules, neither made sense, so I changed *both* to an order
that *does* make sense (i.e. it has related predicates together).
Move one predicate that is needed in two modules from one of them
to a third module (prim_data.m), since that is the one that defines
the type for which the predicate is a utility predicate.
In some places, put dividers between groups of related
functions/predicates, to make the groups themselves more visible.
In some places, fix comments or programming style.
mdbcomp/MDBCOMP_FLAGS.in:
Since all the modules in this directory are now free from any warnings
generated by --warn-inconsistent-pred-order-clauses, specify that option
by default in this directory to keep it that way.
|
||
|
|
a56c4f5708 |
Merge integer tokens in lexer.
library/lexer.m:
Merge the 'integer' and 'big_integer' tokens and extend them to include
signedness and size information. This conforms to recent changes to
the rest of the system and is another step towards supporting additional
types of integer literal.
library/parser.m:
mdbcomp/trace_counts.m:
Conform to the above change.
tests/hard_coded/impl_def_lex.exp:
tests/hard_coded/impl_def_lex_string.exp:
tests/hard_coded/lexer_bigint.exp:
tests/hard_coded/lexer_zero.exp*:
tests/hard_coded/parse_number_from_string.exp*:
Update these expected outputs.
|
||
|
|
e6e295a3cc |
Generalise the representation of integers in the term module.
In preparation for supporting uint literals and literals for the fixed size
integer types, generalise the representation of integers in the term module, so
that for every integer literal we record its base, value (as an arbitrary
precision integer), signedness and size (the latter two based on the literal's
suffix or lack thereof).
Have the lexer attach information about the integer base to machine sized ints;
we already did this for the 'big_integer' alternative but not the normal one.
In conjunction with the first change, this fixes a problem where the compiler
was accepting non-decimal integers in like arity specifications. (The
resulting error messages could be improved, but that's a separate change.)
Support uints in more places; mark other places which require further work with
XXX UINT.
library/term.m:
Generalise the representation of integer terms so that we can store
the base, signedness and size of a integer along with its value.
In the new design the value is always stored as an arbitrary precision
integer so we no longer require the big_integer/2 alternative; delete it.
Add some utility predicates that make it easier to work with integer terms.
library/term_conversion.m:
library/term_io.m:
Conform to the above changes,
Add missing handling for uints in some spots; add XXX UINT comments
in others -- these will be addressed later.
library/lexer.m:
Record the base of word sized integer literals.
library/parser.m:
compiler/analysis_file.m:
compiler/fact_table.m:
compiler/get_dependencies.m:
compiler/hlds_out_goal.m:
compiler/hlds_out_util.m:
compiler/intermod.m:
compiler/make.module_dep_file.m:
compiler/parse_class.m:
compiler/parse_inst_mode_name.m:
compiler/parse_item.m:
compiler/parse_pragma.m:
compiler/parse_sym_name.m:
compiler/parse_tree_out_term.m:
compiler/parse_tree_to_term.m:
compiler/parse_type_defn.m:
compiler/parse_util.m:
compiler/prog_ctgc.m:
compiler/prog_util.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
compiler/superhomogeneous.m:
mdbcomp/trace_counts.m:
samples/calculator2.m:
extras/moose/moose.m:
Conform to the above changes.
tests/hard_coded/impl_def_lex.exp:
tests/hard_coded/impl_def_lex_string.exp:
tests/hard_coded/lexer_bigint.exp*:
tests/hard_coded/lexer_zero.exp*:
tests/hard_coded/parse_number_from_string.exp*:
tests/hard_coded/term_to_unit_test.exp:
Update these expected outputs.
|
||
|
|
baddfd37cd |
Make --warn-unused-imports the default for the Mercury system.
browser/MDB_FLAGS.in:
compiler/COMP_FLAGS.in:
deep_profiler/DEEP_FLAGS.in:
library/LIB_FLAGS.in:
mdbcomp/MDBCOMP_FLAGS.in:
mfilterjavac/MFILTERJAVAC_FLAGS.in:
profiler/PROF_FLAGS.in:
slice/SLICE_FLAGS.in:
ssdb/SSDB_FLAGS.in:
Add --warn-unused-imports to the list of default compiler flags
for each directory.
compiler/ml_tailcall.m:
library/io.m:
Delete some unused imports.
|
||
|
|
092e175f45 |
Add a builtin unsigned word sized integer type -- Part 1.
Add a new builtin type: uint, which is an unsigned word sized integer type.
Support for this new type will need be bootstrapped over several changes.
This is the first such change and does the following:
- Extends the compiler to recognize 'uint' as a builtin type.
- Extends the set of builtin operations to include relational and (some)
arithmetic operations on uints.
- Extends all of the code generators to handle the above. There are some
limitations currently marked by 'XXX UINT'. These will be lifted once
the compiler recognised uint and additional library support becomes
available.
- Extends the runtime to support uints.
compiler/prog_type.m:
compiler/prog_data.m:
compiler/builtin_lib_types.m:
Recognize uint as a builtin type.
Add a new alternative to the cons_id/0 type corresponding to the uint type
-- for bootstrapping purposes its argument is currently an int.
compiler/builtin_ops.m:
Add builtin relational and arithmetic operations on uints. Note that the
existing 'unsigned_le' operation is actually intended for use with signed
values. Rather than attempt to modify its meaning, I have just added new
operations specific to the uint type.
compiler/hlds_data.m:
Add a new tag type for uints.
compiler/type_ctor_info.m:
Recognise uint as a builtin.
Bump the RTTI version number here.
compiler/ctgc.selector.m:
compiler/dead_proc_elim.m:
compiler/dependency_graph.m:
compiler/export.m:
compiler/foreign.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/hlds_code_util.m:
compiler/hlds_out_pred.m:
compiler/hlds_out_util.m:
compiler/hlds_pred.m:
compiler/implementation_defined_literals.m:
compiler/inst_check.m:
compiler/mercury_to_mercury.m:
compiler/mode_util.m:
compiler/module_qual.qualify_items.m:
compiler/parse_tree_to_term.m:
compiler/parse_type_name.m:
compiler/polymorphism.m:
compiler/prog_out.m:
compiler/prog_rep.m:
compiler/prog_rep_tables.m:
compiler/prog_util.m:
compiler/rbmm.execution_path.m:
compiler/rtti.m:
compiler/special_pred.m:
compiler/switch_gen.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/type_constraints.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/unify_gen.m:
compiler/unify_proc.m:
compiler/unused_imports.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
Conform to the above changes to the parse tree and HLDS.
compiler/c_util.m:
Support generating builtin operations for uints.
compiler/llds.m:
Add a representation for uint constants to the LLDS.
Map uints onto MR_Unsigned.
compiler/call_gen.m:
compiler/dupproc.m:
compiler/exprn_aux.m:
compiler/global_data.m:
compiler/jumpopt.m:
compiler/llds_out_data.m:
compiler/llds_out_instr.m:
compiler/opt_debug.m:
compiler/opt_util.m:
Support uints in the LLDS code generator.
compiler/mlds.m:
Support uint constants in the MLDS.
compiler/ml_accurate_gc.m:
compiler/ml_call_gen.m:
compiler/ml_global_data.m:
compiler/ml_simplify_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
compiler/rtti_to_mlds.m:
Conform to the above change to the MLDS.
compiler/mlds_to_c.m:
compiler/mlds_to_java.m:
compiler/mlds_to_cs.m:
Generate the appropriate target code for uint constants and uint
relational operations.
compiler/bytecode.m:
compiler/bytecode_gen.m:
Handle uints in the bytecode generator: we just abort if we
encounter them for now.
compiler/elds.m:
compiler/elds_to_erlang.m:
compiler/erl_call_gen.m:
compiler/erl_code_util.m:
compiler/erl_rtti.m:
compiler/erl_unify_gen.m:
Handle uints in the Erlang code generator.
library/private_builtin.m:
Add placeholders for builtin_{unify,compare}_uint. Since the
bootstrapping compiler will not recognize uint as a type, we
give them polymorphic arguments. These can be replaced after
this change has bootstrapped.
Update the Java list of TypeCtorRep constants, which for some
reason is defined here.
library/uint.m:
New module that will eventually contain operations on uints.
library/MODULES_DOCS:
library/library.m:
Add the uint module.
library/construct.m:
library/erlang_rtti_implementation.m:
library/rtti_implementation.m:
mdbcomp/program_representation.m:
Handle uints.
deep_profiler/program_representation_utils.m:
Conform to the above change.
runtime/mercury_dotnet.cs.in:
Update the list of TypeCtorReps for C#
java/runtime/TypeCtorRep.java:
Update this, although the actual TypeCtorRep constants
are defined the library.
runtime/mercury_type_info.h:
Bump the RTTI version number.
Add an alternative for uints to the tyepctor rep enum.
runtime/mercury_builtin_types.{h,c}:
runtime/mercury_builtin_types_proc_layouts.h:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_table_type_body.h:
runtime/mercury_tabling.h:
runtime/mercury_tabling_macros.h:
runtime/mercury_unify_compare_body.h:
Add uint as a builtin type and handle it throughout the runtime.
runtime/mercury_grade.h:
Bump the binary compatibility version.
runtime/mercury_term_size.c:
runtime/mercury_ml_expand_body.h:
Handle uint and fix probable bugs with the handling of ints on
64-bit Windows.
|
||
|
|
20748974b1 |
Reduce use of foreign-exported procs in dir.m.
library/io.m:
Note that io.system_error sometimes takes on Win32 error values.
Remove I/O state arguments on `make_err_msg' and
`make_maybe_win32_err_msg'.
Remove `was_error' argument from `ML_maybe_make_err_msg' and
`ML_maybe_make_win32_err_msg' macros, and rename the macros.
Simplify the macros using `MR_allocate_aligned_string_msg' instead of
`MR_offset_incr_hp_atomic_msg'.
Add `is_maybe_win32_error'.
Write `is_error' and `is_maybe_win32_error' in terms of `make_err_msg'
and `make_maybe_win32_err_msg'.
Add `thread_safe' attributes to some `make_err_msg' implementations.
Delete obsolete foreign exported predicates.
library/dir.m:
Simplify `current_directory' implementations. Avoid calling back
into Mercury from foreign code.
Separate out a code path `make_directory_including_parents' from
`make_directory', for C# and Java backends to override instead of
overriding `make_directory' directly. Avoid calling back into Mercury
from foreign code.
Delete the Erlang override of `make_directory'; just use the generic
implementation.
Simplify `make_single_directory'. Avoid calling back into Mercury
from foreign code.
Reduce use of bare ints between Mercury and foreign procs.
Fix `read_entry' using outdated Dir0 variable instead of Dir.
Catch exceptions in Java `read_entry_2'.
Delete many obsolete foreign exported predicates.
mdbcomp/program_representation.m:
Conform to change.
fixup read_entry
|
||
|
|
13bd996453 |
Only pass -install_name option on Darwin.
The -install_name option broke building with mmake --use-mmake-make on
other operating systems.
browser/Mmakefile:
library/Mmakefile:
mdbcomp/Mmakefile:
ssdb/Mmakefile:
As above.
|
||
|
|
700a855efd |
Do not include mdbcomp modules in coverage reports by default.
slice/mcov.m:
Filter trace counts from mdbcomp modules by default. Add a
a new developer-only option, --no-ignore-mdbcomp, that causes
them to be included -- doing so may be useful for those working
on the Mercury compiler itself.
Update copyright messages.
mdbcomp/mdbcomp.m:
mdbcomp/builtin_modules.m:
Add predicates for testing whether a module is part of the mdbcomp
library.
|
||
|
|
39da4409ec |
Add .dep_err files to .gitignore
browser/.gitignore:
compiler/.gitignore:
deep_profiler/.gitignore:
library/.gitignore:
mdbcomp/.gitignore:
mfilterjavac/.gitignore:
profiler/.gitignore:
slice/.gitignore:
ssdb/.gitignore:
As above.
|
||
|
|
be553f9b16 | Turn off lcmc for modules that it doesn't help. | ||
|
|
b3139ba6c2 | Replace references to `:- external' in comments. | ||
|
|
a0760327b6 |
Do stricter checking of mode and determinism declarations.
Specifically, we now do three new checks:
BAD_DETISM: We now generate error messages for predicate declarations
that specify a determinism without also specifying argument modes.
BAD_PREDMODE: We now generate error messages for standalone mode declarations
for predicates whose predicate declaration includes modes for the arguments.
BAD_MODE_SECTION: We now generate error messages for standalone mode
declarations that are not in the same section as the predicate's (or
function's) type declaration.
compiler/hlds_pred.m:
Add a slot to the pred_sub_info. If the predicate is explicitly defined by
the user in the current module, this contains the id of the section that
contains its predicate declaration (for the BAD_MODE_SECTION check)
and whether that predicate declaration also had modes for the arguments
(for the BAD_PREDMODE check).
compiler/add_pred.m:
When adding adding new predicate declarations, perform the BAD_DETISM
check, and record the info needed for the BAD_PREDMODE and BAD_MODE_SECTION
checks.
When adding adding new mode declarations, perform the BAD_PREDMODE
and BAD_MODE_SECTION checks.
compiler/add_class.m:
compiler/add_mutable_aux_preds.m:
compiler/add_pragma_tabling.m:
compiler/add_pragma_type_spec.m:
compiler/add_solver.m:
compiler/add_special_pred.m:
compiler/check_typeclass.m:
compiler/dep_par_conj.m:
compiler/higher_order.m:
compiler/make_hlds_passes.m:
compiler/table_gen.m:
compiler/unused_args.m:
Conform to the changes above.
mdbcomp/builtin_modules.m:
Add a utility predicate for use by new code in add_pred.m.
compiler/comp_unit_interface.m:
compiler/goal_util.m:
compiler/prog_rename.m:
compiler/quantification.m:
deep_profiler/program_representation_utils.m:
library/calendar.m:
library/mutvar.m:
library/pretty_printer.m:
library/random.m:
library/set_ctree234.m:
library/solutions.m:
library/stream.string_writer.m:
profiler/globals.m:
tests/accumulator/nonrec.m:
tests/accumulator/out_to_in.m:
tests/declarative_debugging/library_forwarding.m:
tests/dppd/applast_impl.m:
tests/dppd/grammar_impl.m:
tests/dppd/regexp.m:
tests/dppd/transpose_impl.m:
tests/hard_coded/copy_pred.m:
tests/hard_coded/ho_func_default_inst.m:
tests/recompilation/unchanged_pred_nr_2.m.1:
tests/recompilation/unchanged_pred_nr_2.m.2:
tests/valid/det_switch.m:
tests/valid/inlining_bug.m:
Delete determinism declarations from predicate and function declarations
that have no argument mode information, since the BAD_DETISM check
now makes these errors.
tests/valid/two_pragma_c_codes.m:
Move some mode declarations to the right section, since the
BAD_MODE_SECTION check now generates an error for the old code.
tests/invalid/typeclass_bad_method_mode.{m,err_exp}:
New test case to test for the BAD_PREDMODE check.
tests/invalid/mode_decl_in_wrong_section.{m,err_exp}:
New test case to test for the BAD_MODE_SECTION check.
tests/invalid/bad_detism.err_exp:
Add an expected output for this old, but never enabled test case,
which tests for new check BAD_DETISM.
tests/invalid/Mmakefile:
Enable the new test cases.
tests/invalid/typeclass_dup_method_mode.m:
This test case used to have two bugs. One is now by itself in the new
typeclass_bad_method_mode.m test case, so modify it to contain only
the other (indistinguishable modes).
tests/invalid/func_errors.err_exp:
tests/invalid/tc_err1.err_exp:
tests/invalid/undef_lambda_mode.err_exp:
tests/invalid/undef_type_mode_qual.err_exp:
Expect an extra error message from the BAD_DETISM check.
|
||
|
|
5649f36c80 |
Handle "use_module in interface, import_module in implementation".
If a module m1 imports module m2 using a use_module declaration in its
interface section but also imports it using an import_module declaration
in its implementation section, then references to entities defined in m2
in the interface of m1 must be module qualified, but similar references
in the implementation of m1 need NOT be module qualified.
The Mercury compiler has long had a bug that allowed entities imported
in the implementation of module m1 to be used in the interface of m1,
against the rules of the language. When I fixed that bug on 2015 nov 11,
the compiler became unable to properly process the situation described
in the paragraph above, because it still had another bug, which was that
it had a single setting for module qualification requirements: either it
was required *everywhere* in m1, or it was required *nowhere* in m1.
This diff fixes that bug (mantis bug 401) by allowing different requirements
in this respect in the interface of m1 versus its implementation.
It also changes the de-facto meaning of what exactly a use_module declaration
requires. The reference manual says only:
Uses of entities imported using @code{use_module} declarations
@emph{must} be explicitly module qualified.
This WAS unambiguous when it was written in june 1997, a few months before
submodules were added to the language. With a flat module system, there were
no nested module names, so either the module name was present, or it wasn't.
In the presence of nested modules, though, it IS ambiguous: HOW MUCH of
the module name must be present? The reference manual is silent on this.
At the moment, in the presence of a use_module for module ma.mb.mc,
a predicate p1 in ma.mb.mc may of course be referred to as ma.mb.mc.p1,
but may also be referred to as mb.mc.p1, or even just mc.p1. The specification
of mc is always required, but exactly WHICH of the previous module name
components are required depends on whether e.g. ma or ma.mb were themselves
imported via use_module or import_module declarations. The code implementing
the check (find_matches_in_permissions_map in module_qual.id_set.m) is itself
not too clear.
This diff changes the rules so that all references to anything imported
via a use_module declarations have to be fully qualified. This is stricter
than the existing rule, but it is MUCH simpler, and it better matches
the original intent of use_module declarations, which is the avoidance
of ALL POSSIBILITY of ambiguity.
NEWS:
doc/reference_manual.texi:
Document this change to the language.
compiler/prog_item.m:
Change the representation of sections in .int* files. Previously,
we recorded whether the interface file that the section was from
was read for an `import_module' or a `use_module' declaration.
We now allow the recording of the fact that it had both declarations,
a use_module in the interface and an import_module in the implementation.
compiler/modules.m:
Treat modules that have both a `use_module' declaration in interface
and an `import_module' declaration in the implementation as being of this
new internal section kind.
Add some infrastructure for debugging similar problems in the future.
compiler/module_qual.id_set.m:
Change the permissions system. Instead of recording *independently*
whether (a) an entity may be used in the interface and (b) whether
references to it must be qualified, record *separately* whether
(a) it may be used in the interface, and if so with what qualification
requirements, and (b) what its qualification requirements are in the
implementation. Unlike the old permission setup, the new one allows us
to express the "use_module in interface, import_module in implementation"
situation.
Implement the change to the language, by requiring full module
qualification of entities imported via use_module declarations.
This allows us to use a single parameterized piece of code to handle
both unqualified and qualified references, whereas before we used
separate pieces of code for them.
Change the way we handle errors in module qualification. Instead of
looking only for precise matches only, and looking for the possible causes
of errors only if we find either no matches or two or more matches, we now
return the near-miss matches as well, the ones that we need to decide
on what error message we want to generate. While this is slightly slower,
it is *much* simpler, since it allows us to avoid duplicating the search
code: once for precise matches only, once for no-match errors, and once
for multiple-match errors.
compiler/module_qual.collect_mq_info.m:
Set permissions for symbol access according to the new permissions system.
Code that previously triggered the bug will use the new interface file
section kind, and can now have its permissions record correctly.
compiler/module_qual.qual_errors.m:
Use a single predicate to generate error messages for all situations
in which there is not a single precise match for a module qualification.
This allows us to diagnose multiple potential problems with a single
lookup.
Change the wording of an existing error message to avoid a possibly-untrue
implication.
compiler/hlds_data.m:
Rename a field of the type_defn type to better document its meaning.
compiler/make_hlds.m:
Document the meaning of the need_qualifier field in sec_infos.
compiler/add_type.m:
compiler/make_hlds_separate_items.m:
compiler/module_qual.m:
compiler/pred_table.m:
compiler/parse_tree_out.m:
compiler/prog_item_stats.m:
Conform to the above changes.
mdbcomp/sym_name.m:
Add a utility predicate for use in looking for near-miss matches
in module qualification.
Make the documentation of a related predicate more precise.
tests/invalid/bad_instance.m:
tests/submodules/class.m:
tests/submodules/nested.m:
tests/submodules/nested3.m:
tests/submodules/parent.m:
Make names fully module qualified where the language rules now require it.
tests/submodules/deeply_nested.m:
Comment out a part of the test that tested the partially qualified names,
since these are now not allowed.
tests/invalid/errors.err_exp:
Expect a now-improved error message.
tests/invalid/test_nested.err_exp:
tests/invalid/transitive_import.err_exp:
tests/invalid/undef_type.err_exp:
Expect a now less-likely-to-mislead error message.
tests/valid_seq/int_impl_imports.m:
tests/valid_seq/int_impl_imports_2.m:
The test case for mantis bug 401.
tests/valid_seq/Mmakefile:
Enable the new test case.
|
||
|
|
1b17ed4d6c |
Fix a problem on OS X when building using --use-mmc-make.
The install names for Mercury shared libraries in the system were not being set
when building using --use-mmc-make. The existing code in the Mmakefiles that
does this only works for mmake, not mmc --make.
browser/Mmakefile:
library/Mmakefile:
mdbcomp/Mmakefile:
ssdb/Mmakefile:
When using --use-mmc-make set up the options to set the dylib install
names in such a way that mmc --make can see them.
Don't hardcode the library names in the definitions that set the
library install names.
|
||
|
|
30643165a6 | Delete unused predicates. |