mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-14 21:35:49 +00:00
77a1261d3bd0900b09d06f6d2061da9f72bf22f9
55 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
f4b091cb5b |
When printing messages about errors involving overloaded types, print each
Estimated hours taken: 14
Branches: main
When printing messages about errors involving overloaded types, print each
type only once.
compiler/typecheck.m:
Detect and eliminate duplicate type names in error messages about
overloaded types.
When a variable has more than one type, print each type on a line of
its own, to make the output easier to read. (Since type names currently
have too many parentheses, further improvements are still possible.)
compiler/mercury_to_mercury.m:
Provide a mechanism to turn a type into a string without printing it,
so that it can be checked againt the representations of other types.
This required changing many of the predicates in this module so that
instead of doing I/O directly, they go through a typeclass interface
which has two implementations: one does I/O while the other gathers
output in a string.
The performance impact of this change should be acceptable, since I/O
is slow compared to computation anyway.
compiler/purity.m:
Provide a predicate that returns a purity prefix as a string, to
accompany another that prints it out.
compiler/check_typeclass.m:
compiler/prog_util.m:
Minor changes to conform to the naming scheme now used in
mercury_to_mercury.m, in particular to the fact the operations of the
form x_to_string are now functions, not predicates.
The functionality of prog_util should be unaffected. In check_typeclass
we may now print more detailed error messages than before.
library/string.m:
Declare the outputs append, append_list and join_list to be unique.
Their implementations already return unique strings; declaring them to
be unique help avoid redundant copying in mercury_to_mercury.m.
library/term_io.m:
Add alternative versions of some output predicates that return their
"output" in a string instead.
Factor out some common code.
tests/invalid/overloading.{m,exp}:
A test exercising the error message affected by the change.
tests/invalid/Mmakefile:
Enable the new test.
NEWS:
Announce the changes in the library.
|
||
|
|
30fc64c5b1 |
Place sub-modules in the same assembly as their parent on the IL
Estimated hours taken: 8
Branches: main
Place sub-modules in the same assembly as their parent on the IL
backend.
This allowes the user to decide how their application should be
packaged. If the user wishes their application to be deployed as one
assembly then they should use sub modules.
This also simplifies management, as it allows such things as strong keys
(which apply to one assembly) to be used more easily.
README.DotNet:
Discuss how the mercury compiler decides which assembly to place a
Mercury module in.
compiler/ilasm.m:
Add the '.file' and '.module extern' declarations.
Modify output_structured_name so that it outputs
[.module <sub-module>.dll] or [<assembly>] as the assembly reference
as necessary.
compiler/ilds.m:
Change the assembly_name type so that it records both the assembly
and sub-module name for sub-modules.
compiler/mlds_to_il.m:
Use the new assembly_name type when generating assembly_names.
Factor out some duplicate code in class_name.
Modify generate_extern_assembly so that it outputs `.file' and
`.module extern' declarations in the top level module of nested
modules.
compiler/modules.m:
Add the dependency that the top level dll of a nested module
hierachy depends on all of it sub-modules dlls, as they are
referenced from inside the top level dll.
Change the top level make rule from
<main> : <main>.exe $(<main>.dlls)
to
<main> : <main>.exe
<main>.exe : $(<main>.dlls)
so that all the dlls are built before building the exe, as the exe
may contain references to sub-module dlls.
compiler/prog_util.m:
Add the utility predicate outermost_qualifier which retrieves the
top level qualifier from a sym_name.
|
||
|
|
9dd11b2fc6 |
Smart recompilation. Record version numbers for each item
Estimated hours taken: 400
Smart recompilation. Record version numbers for each item
in interface files. Record which items are used in each compilation.
Only recompile a module if the output file does not exist or
nothing has changed.
There is still some work to do on this:
- it doesn't work with inter-module optimization.
- it doesn't work when the module name doesn't match the file name.
(this problem will go away when mmake functionality is moved into
the compiler.
I'll hold off documenting this change in the NEWS file and
on the web page for a month or so, until I've had a bit more
experience using it.
compiler/options.m:
compiler/handle_options.m:
doc/user_guide.texi:
Add an option `--smart-recompilation', currently off by default.
Add an internal option `--generate-version-numbers' to control
whether version numbers are written to the interface files. If
`--smart-recompilation' is disabled because the module
is being compiled with `--intermodule-optimization' (e.g. in the
standard library), we still want to write the version numbers
to the interface files.
Add an option `--verbose-recompilation' (default off)
to write messages describing why recompilation is needed.
Add an option `--warn-smart-recompilation' (default on)
to control warnings relating to the smart recompilation
system. Warn if smart recompilation will not work with
the output and inter-module optimization options given.
compiler/recompilation.m:
Type declarations for smart recompilation.
Predicates to record program items used by compilation.
compiler/recompilation_version.m:
Compute version numbers for program items in interface files.
compiler/recompilation_usage.m:
Find all items used by a compilation.
compiler/recompilation_check.m:
Check whether recompilation is necessary.
compiler/timestamp.m:
Timestamp ADT for smart recompilation.
compiler/mercury_compile.m:
Invoke the smart recompilation passes.
compiler/modules.m:
compiler/prog_io.m:
Return timestamps for modules read.
When reading a module make sure the current input stream
is reset to its old value, not stdin.
Handle version number items in interface files.
compiler/module_qual.m:
compiler/unify_proc.m:
compiler/make_hlds.m:
Record all items used by local items.
compiler/make_hlds.m:
Process `:- pragma type_spec' declarations in
add_item_list_clauses. The qual_info is needed
when processing `:- pragma type_spec' declarations
so that any equivalence types used by the declaration
can be recorded as used by the predicate or function to
which the `:- pragma type_spec' applies.
compiler/equiv_type.m:
For each imported item, record which equivalence types
are used by that item.
compiler/hlds_module.m:
Add a field to the module_info to store information about
items used during compilation of a module.
compiler/check_typeclass.m:
Make sure any items used in clauses for typeclass method
implementations are recorded in the `.used' file.
compiler/prog_data.m:
compiler/*.m:
Factor out some duplicated code by combining the
pred and func, and pred_mode and func_mode items.
Make it easier to extract the name of a type, inst or mode
from its declaration.
Add an item type to hold the version numbers for an interface file.
Allow warnings to be reported for `nothing' items (used for
reporting when version numbers are written using an
obsolete format).
compiler/prog_io.m:
compiler/prog_io_util.m:
compiler/typecheck.m:
compiler/type_util.m:
compiler/*.m:
Strip contexts from all types, not just those in class constraints.
This makes it possible to use ordinary unification to check
whether items have changed (with the exception of clauses).
Remove code to create types with contexts in typechecking.
Remove code scattered through the compiler to remove contexts
from types in class constraints.
compiler/hlds_pred.m:
compiler/prog_util.m:
Move hlds_pred__adjust_func_arity to prog_util, so that it
can be used by the pre-hlds passes.
compiler/typecheck.m:
compiler/hlds_module.m:
Move typecheck__visible_modules to hlds_module.m, so it can
be used by recompilation_usage.m.
compiler/typecheck.m:
Add a comment telling where updates may be required if the
code to typecheck a var-functor unification changes.
compiler/error_util.m:
Allow writing messages without contexts (used for the verbose
recompilation messages).
Add functions to format sym_name and sym_name_and_arity,
and to add punctuation to the end of an error message
without unwanted line breaks before the punctuation.
scripts/Mmake.rules:
compiler/modules.m:
Don't remove the output file before running the compiler. We need
to leave the old output file intact if smart recompilation detects
that recompilation is not needed.
compiler/notes/compiler_design.html:
Document the new modules.
library/io.m:
NEWS:
Add predicates to find the modification time of files
and input_streams.
library/set.m:
NEWS:
Add a predicate version of set__fold
Don't sort the output of set__filter, it's already sorted.
library/std_util.m:
NEWS:
Add a predicate `std_util__map_maybe/3' and a function
`std_util__map_maybe/2' to apply a predicate or a function to
a value stored in a term of type `std_util__maybe'.
configure.in:
runtime/mercury_conf.h.in:
runtime/RESERVED_MACRO_NAMES:
When checking whether the compiler is recent enough, check for
the --warn-smart-recompilation option.
Check for stat().
library/Mmakefile:
Disable warnings about smart recompilation not working with
`--intermodule-optimization'.
browser/Mmakefile:
Disable warnings about smart recompilation not working when
the module name doesn't match the file name.
runtime/mercury_string.h:
Add a macro MR_make_string_const() which automates computation
of the length of string argument to MR_string_const().
tests/recompilation/Mmakefile:
tests/recompilation/runtests:
tests/recompilation/test_functions:
tests/recompilation/TESTS:
tests/recompilation/README:
A framework for testing smart recompilation.
The option currently only works for the recompilation directory.
tests/recompilation/TEST.m.{1,2}:
tests/recompilation/TEST_2.m.{1,2}:
tests/recompilation/TEST.exp.{1,2}:
tests/recompilation/TEST.err_exp.2:
Test cases, where TEST is one of add_constructor_r, add_instance_r,
add_instance_2_r, add_type_nr, change_class_r, change_instance_r,
change_mode_r, field_r, func_overloading_nr, func_overloading_r,
lambda_mode_r, nested_module_r, no_version_numbers_r,
pragma_type_spec_r, pred_ctor_ambiguity_r, pred_overloading_r,
add_type_re, remove_type_re, type_qual_re.
tests/handle_options:
Add an option `-e' to generate any missing expected output files.
|
||
|
|
04e614485d |
Implement deep profiling; merge the changes on the deep2 branch back
Estimated hours taken: 500 Branches: main Implement deep profiling; merge the changes on the deep2 branch back onto the trunk. The main documentation on the general architecture of the deep profiler is the deep profiling paper. doc/user_guide.texi: Document how to use the deep profiler. deep_profiler: deep_profiler/Mmakefile: A new directory holding the deep profiler and its mmakefile. Mmakefile: Add targets for the new directory. Add support for removing inappropriate files from directories. deep_profiler/interface.m: The deep profiler consists of two programs: mdprof_cgi.m, which acts as a CGI "script", and mdprof_server.m, which implements the server process that the CGI script talks to. Interface.m defines the interface between them. script/mdprof.in: A shell script template. ../configure uses it to generate mdprof, which is a wrapper around mdprof_cgi that tells it how to find mdprof_server. deep_profiler/mdprof_cgi.m: The CGI "script" program. deep_profiler/mdprof_server.m: The top level predicates of the server. deep_profiler/profile.m: The main data structures of the server and their operations. deep_profiler/read_profile.m: Code for reading in profiling data files. deep_profiler/startup.m: Code for post-processing the information in profiling data files, propagating costs from procedures to their ancestors and performing various kinds of summaries. deep_profiler/server.m: Code for responding to requests from the CGI script. deep_profiler/cliques.m: Code to find cliques in graphs. deep_profiler/array_util.m: deep_profiler/util.m: Utility predicates. deep_profiler/dense_bitset.m: An implementation of (part of) the set ADT with dense bit vectors. deep_profiler/measurements.m: Operations on profiling measurements. deep_profiler/timeout.m: An implementation of a timeout facility. deep_profiler/conf.m: Functions that depend on autoconfigured settings. configure.in: Find out what command to use to find the name of the local host. Install deep profiling versions of the standard library along with the other profiling versions. runtime/mercury_conf.h.in: Add some macros for deep_profiler/conf.m to use. library/profiling_builtin.m: runtime/mercury_deep_call_port_body.h: runtime/mercury_deep_leave_port_body.h: runtime/mercury_deep_redo_port_body.h: A new library module that implements deep profiling primitives. Some of these primitives have many versions, whose common code is factor is factored out in three new include files in the runtime. compiler/deep_profiling.m: New module to perform the program transformations described in the paper. compiler/notes/compiler_design.html: Document the new compiler module. compiler/mercury_compiler.m: Invoke the new module in deep profiling grades. Allow global static data to be generated by deep_profiling.m. compiler/options.m: Add options to turn on deep profiling and (for benchmarking purposes) control its implementation. Add an optiooption disable tailcall optimization in the LLDS backend, to help benchmarking deep profiling. compiler/jumpopt.m: compiler/optimize.m: Obey the option to disable tailcalls. compiler/handle_options.m: Handle the implications of deep profiling. compiler/modules.m: In deep profiling grades, automatically import profiling_builtin.m. compiler/prog_util.m: doc/Makefile: library/library.m: Handle the new builtin module. compiler/export.m: In deep profiling grades, wrap deep profiling code around exported procedures to handle the "unscheduled call" aspects of callbacks to Mercury from the foreign language. compiler/higher_order.m: profiler/demangle.m: util/demangle.c: When creating a name for a higher-order-specialized predicate, include the mode number in the name. compiler/add_trail_ops.m: compiler/type_util.m: Move c_pointer_type from add_trail_ops to type_util, so it can also be used by deep_profiling.m. compiler/hlds_goal.m: Add a new goal feature that marks a tail call, for use by deep_profiling.m. compiler/hlds_pred.m: Add a new field to proc_info structures for use by deep_profiling.m. Add a mechanism for getting proc_ids for procedure clones. Remove next_proc_id, an obsolete and unused predicate. compiler/hlds_data.m: Add a new cons_id to refer to the proc_static structure of a procedure. compiler/bytecode_gen.m: compiler/code_util.m: compiler/dependency_graph.m: compiler/hlds_out.m: compiler/mercury_to_mercury.m: compiler/ml_unify_gen.m: compiler/opt_debug.m: compiler/prog_rep.m: compiler/rl_exprn.m: compiler/switch_util.m: compiler/unify_gen.m: Trivial changes to handle the new cons_id, goal feature and/or proc_info argument. compiler/rtti.m: Add a utility predicate for extracting pred_id and proc_id from an rtti_proc_label, for use by hlds_out.m compiler/layout.m: compiler/layout_out.m: compiler/llds.m: compiler/llds_common.m: Add support for proc_static and call_site_static structures. compiler/layout_out.m: compiler/llds_out.m: Add code for the output of proc_static structures. compiler/code_util.m: Make code_util__make_proc_label_from_rtti a function, and export it. util/mkinit.c: compiler/llds_out.m: compiler/layout.m: compiler/modules.m: Add support for a fourth per-module C function, for writing out proc_static structures (and the call_site_static structures they contains). Since proc_static structures can be referred to from LLDS code (and not just from other static structures and compiler-generated C code), reorganize the declarations of static structures slightly. Change the schema for the name of the first per-module C function slightly, to make it the addition of the fourth function easier. The scheme now is: mercury__<modulename>__init mercury__<modulename>__init_type_tables mercury__<modulename>__init_debugger mercury__<modulename>__write_out_proc_statics Improve formatting of the generated C code. library/*.m: runtime/mercury.c: runtime/mercury_context.c: runtime/mercury_engine.c: runtime/mercury_ho_call.c: runtime/mercury_tabling.c: runtime/mercury_trace_base.c: runtime/mercury_wrapper.c: trace/mercrury_trace.[ch]: trace/mercrury_trace_declarative.c: trace/mercrury_trace_external.c: trace/mercrury_trace_internal.c: Conform to the new scheme for initialization functions for hand-written modules. compiler/mercury_compile.m: library/benchmarking.m: runtime/mercury_conf_param.h: runtime/mercury.h: runtime/mercury_engine.c: runtime/mercury_goto.c: runtime/mercury_grade.h: runtime/mercury_ho_call.c: runtime/mercury_label.[ch]: runtime/mercury_prof.[ch]: Add an MR_MPROF_ prefix in front of the C macros used to control the old profiler. compiler/handle_options.m: runtime/mercury_grade.h: scripts/canonical_grade.sh-subr: scripts/init_grade_options.sh-subr: scripts/parse_grade_options.sh-subr: Make deep profiling completely separate from the old profiling system, by making the deep profiling grade independent of MR_MPROF_PROFILE_TIME and the compiler option --profile-time. library/array.m: library/builtin.m: library/std_util.m: runtime/mercury_hand_unify_body.h: runtime/mercury_hand_compare_body.h: In deep profiling grades, wrap the deep profiling call, exit, fail and redo codes around the bodies of hand-written unification and comparison procedures. Make the reporting of array bounds violations switchable between making them fatal errors, as we currently, and reporting them by throwing an exception. Throwing an exception makes debugging code using arrays easier, but since exceptions aren't (yet) propagated across engine boundaries, we keep the old behaviour as the default; the new behaviour is for implementors. runtime/mercury_deep_profiling_hand.h: New file that defines macros for use in Mercury predicates whose definition is in hand-written C code. library/exception.m: runtime/mercury_exception_catch_body.h: runtime/mercury_stacks.h: In deep profiling grades, wrap the deep profiling call, exit, fail and redo codes around the bodies of the various modes of builtin_catch. Provide a function that C code can use to throw exceptions. library/benchmarking.m: library/exception.m: library/gc.m: library/std_util.m: runtime/mercury_context.[ch]: runtime/mercury_engine.[ch]: runtime/mercury_debug.c: runtime/mercury_deep_copy.c: runtime/mercury_overflow.h: runtime/mercury_regs.h: runtime/mercury_stacks.h: runtime/mercury_thread.c: runtime/mercury_wrapper.c: Add prefixes to the names of the fields in the engine and context structures, to make code using them easier to understand and modify. runtime/mercury_deep_profiling.[ch]: New module containing support functions for deep profiling and functions for writing out a deep profiling data file at the end of execution. runtime/mercury_debug.[ch]: Add support for debugging deep profiling. Add support for watching the value at a given address. Make the buffered/unbuffered nature of debugging output controllable via the -du option. Print register contents only if -dr is specified. runtime/mercury_goto.h: runtime/mercury_std.h: Use the macros in mercury_std.h instead of defining local variants. runtime/mercury_goto.h: runtime/mercury_stack_layout.h: runtime/mercury_stack_trace.c: runtime/mercury_tabling.c: trace/mercury_trace.c: trace/mercury_trace_declarative.c: trace/mercury_trace_external.c: trace/mercury_trace_vars.c: Standardize some of the macro names with those used in the debugger paper. runtime/mercury_heap.h: Add support for memory profiling with the deep profiler. runtime/mercury_prof.[ch]: runtime/mercury_prof_time.[ch]: Move the functionality that both the old profiler and the deep profiler need into the new module mercury_prof_time. Leave mercury_prof containing stuff that is only relevant to the old profiler. runtime/mercury_prof.[ch]: runtime/mercury_strerror.[ch]: Move the definition of strerror from mercury_prof to its own file. runtime/mercury_wrapper.[ch]: Add support for deep profiling. Add suppory for controlling whether debugging output is buffered or not. Add support for watching the value at a given address. runtime/Mmakefile: Mention all the added files. scripts/mgnuc.in: Add an option for turning on deep profiling. Add options for controlling the details of deep profiling. These are not documented because they are intended only for benchmarking the deep profiler itself, for the paper; they are not for general use. tools/bootcheck: Compile the deep_profiler directory as well as the other directories containing Mercury code. Turn off the creation of deep profiling data files during bootcheck, since all but one of these in each directory will be overwritten anyway. Add support for turning on --keep-objs by default in a workspace. tools/speedtest: Preserve any deep profiling data files created by the tests. trace/mercury_trace.c: Trap attempts to perform retries in deep profiling grades, since they would lead to core dumps otherwise. util/Mmakefile: Avoid compile-time warnings when compiling getopt. tests/*/Mmakefile: tests/*/*/Mmakefile: In deep profiling grades, switch off the tests that test features that don't work with deep profiling, either by design or because the combination hasn't been implemented yet. |
||
|
|
b45be10117 |
(a) Move the tabling builtins, which are currently in private_builtin.m,
Estimated hours taken: 4
(a) Move the tabling builtins, which are currently in private_builtin.m,
into a different module which is only imported if the source contains
a tabling pragma.
(b) Improve the infrastructure for automatically importing modules to
make it easy to automatically import a module only if a certain option
is set. The idea is to eventually use this to put the simplified HLDS
representation used for declarative debugging in a module which is
only imported if the appropriate declarative debugging option is
enabled.
compiler/modules.m:
Change add_implicit_imports so that it takes the list of
items, for (a) above, and an io__state pair, for (b) above.
Change its callers to pass the new parameters.
Add a new predicate get_implicit_dependencies
(implemented using add_implicit_imports).
compiler/hlds_module.m:
compiler/module_qual.m:
Call get_implicit_dependencies rather than duplicating the code.
compiler/make_hlds.m:
compiler/hlds_module.m:
Pass the item_list to module_info_init, since it's needed by
get_implicit_dependencies.
compiler/prog_util.m:
Add new predicates mercury_table_builtin_module/1 (which
returns the name of the "table_builtin" module) and
any_mercury_builtin_module (which checks whether any of
mercury_{table,public,private}_builtin_module hold).
compiler/termination.m:
Call any_mercury_builtin_module rather than checking
for mercury_{public,private}_builtin_module.
compiler/table_gen.m:
Change the module for tabling builtins from private_builtin to
table_builtin.
compiler/hlds_pred.m:
Add table_builtin to the builtin_mod enumeration,
and change the module for tabling builtins from
private_builtin to table_builtin.
compiler/dead_proc_elim.m:
Add a comment about the treatment of builtin modules.
compiler/mode_util.m:
When stripping out builtin module qualifiers, only strip
qualifiers from "builtin:", not from "private_builtin:".
library/table_builtin.m:
library/private_builtin.m:
Move the tabling builtins from private_builtin.m
into a new module table_builtin.m.
library/library.m:
Add table_builtin.m to the list of imported modules.
(Likewise for builtin.m and private_builtin.m; it's not
strictly necessary for those, since they're implicitly
imported anyway, but importing them explicitly is clearer.)
library/io.m:
Change private_builtin to table_builtin in the call to
private_builtin__report_tabling_stats.
doc/Mmakefile:
Don't include the documentation for table_builtin.m
in the library reference manual.
|
||
|
|
79d75acdb0 |
Add impure functions to Mercury, clean up the purity module somewhat,
Estimated hours taken: 30 Add impure functions to Mercury, clean up the purity module somewhat, fix some bugs in purity, update and expand the purity documentation, and re-organize the purity checks. Impure functions can be declared just like impure preds. However, they can only be called in an explicit unification preceeded by a purity level: impure X = some_impure_func(Y, Z) The bug fixed was the fact that closures of impure predicates were only being detected when using lambda syntax. Purity information was discarded and impure closures could be created like this: Pred = some_impure_pred You could then use this predicate anywhere you like without any purity declarations. compiler/hlds_module.m: Add get_pred_id pred which will return the pred_id of a predicate matching a given type. This is like get_pred_and_proc_id, but only gets the information we are interested in, and is semidet. We need a semidet version to handle cases where type inference cannot infer a type before the limit is reached, but we try to purity check this code. (The bug mentioned above was stopping us from purity checking the test case for this before). compiler/make_hlds.m: Check for "impure" unifications with expressions that are not function calls and issue appropriate error messages. When unravelling impure function call unifications, put the input parameter unifications (if any) before the actual call. Only mark the goal_info for the function call as impure. compiler/mercury_to_goedel.m: compiler/mercury_to_mercury.m: compiler/module_qual.m: compiler/prog_data.m: compiler/prog_io.m: compiler/prog_io_dcg.m: compiler/prog_io_goal.m: compiler/prog_util.m: Add purity information to unify goals. Don't assume unify goals are pure. compiler/purity.m: Allow impure functions. Check unification goals for purity (not just lambda unification). Check unifications that are transformed into calls to make sure the call is purity correct. Put purity checking logic into separate predicates. Use an enum to return different errors and warnings. (The last two changes make it much easier to see the similarities between checking goals and checking predicates for purity correctness). Give different error messages for impure functions (highlight that you need to use them in an explicit unification). Handle unknown predicate lookups (can occur when unifying with a higher order term whose type could not be inferred). Add a few comments delineating where changes might need to be made to make foreign code impure by default in future. compiler/notes/authors.html: Add Peter Schachte to the authors list. doc/reference_manual.texi: Document impure functions. Expand more on what impure predicates/functions can do. Explain the concept of worst purity, and use it to explain the "inferred purity"/"declared purity" concepts. Make it more explicit that only impure goals obey strict-sequential like semantics. tests/invalid/type_inf_loop.err_exp2: Fix this test case to reflect the new error message new that we check the purity of this code correctly (or rather, we correctly fail to be able to purity check this code). tests/hard_coded/Mmakefile: tests/hard_coded/purity.exp: tests/hard_coded/purity.m: tests/hard_coded/purity/Mmakefile: tests/hard_coded/purity/impure_func_t1.m: tests/hard_coded/purity/purity.m: tests/hard_coded/purity/runtests: Remove purity tests from the hard_coded directory, give it a sub-directory of its own. tests/invalid/Mmakefile: tests/invalid/purity.err_exp: tests/invalid/purity.m: tests/invalid/purity_nonsense.err_exp: tests/invalid/purity_nonsense.m: tests/invalid/purity/Mmakefile: tests/invalid/purity/impure_func_t2.err_exp: tests/invalid/purity/impure_func_t2.m: tests/invalid/purity/impure_func_t3.err_exp: tests/invalid/purity/impure_func_t3.m: tests/invalid/purity/impure_func_t4.err_exp: tests/invalid/purity/impure_func_t4.m: tests/invalid/purity/impure_func_t5.err_exp: tests/invalid/purity/impure_func_t5.m: tests/invalid/purity/impure_pred_t1.err_exp: tests/invalid/purity/impure_pred_t1.m: tests/invalid/purity/impure_pred_t2.err_exp: tests/invalid/purity/impure_pred_t2.m: tests/invalid/purity/purity.err_exp: tests/invalid/purity/purity.m: tests/invalid/purity/purity_nonsense.err_exp: tests/invalid/purity/purity_nonsense.m: tests/invalid/purity/runtests: Remove purity tests from the invalid directory, give it a sub-directory of its own. |
||
|
|
f9b942b30e |
Allow functions to be declared by supplying the determinism but not the
Estimated hours taken: 12 Allow functions to be declared by supplying the determinism but not the modes (we assume the default modes). compiler/make_hlds.m: Assume default modes if determinism is declared without modes in the :- func declaration. compiler/prog_io.m: Don't give an error message for determinism without modes for function. compiler/prog_io_goal.m: Update documentation to reflect default mode syntax. Assume default modes if determinism is declared without modes in lambda expressions. compiler/prog_util.m: Mention that declaring modes for some but not all of the arguments of a function will be noticed in prog_io, so shouldn't be a concern in this code. doc/reference_manual.texi: Document the new syntax. tests/valid/Mmakefile: tests/valid/func_default_modes.m: A test case for the new syntax. |
||
|
|
5940825cdb |
Implement syntax for getting and setting fields of constructors.
Estimated hours taken: 70 Implement syntax for getting and setting fields of constructors. compiler/make_hlds.m: Add information about field definitions to the module_info. Check that user-defined field access functions for exported fields are also exported, otherwise predicates in other modules could use a different method to access a field than predicates in module defining the field. Add a `predicate preds_add_implicit_report_error' to allow that check to be performed for functions which are added to the module_info by some means other than a `:- func' declaration. Parse field access goals and expressions. Add predicates `insert_arg_unifications_with_supplied_contexts', and `append_arg_unification', which allow more control over the contexts given to the added unifications. These are useful because the field value for an update is really an argument of the inner-most update function call, while the input term is an argument of the outer-most function call. compiler/prog_io_dcg.m: Allow DCG goals of the form `:=(DCGArg)', which unifies `DCGArg' with the output DCG argument, ignoring the input DCG argument. The rationale for this change is that if we have convenient syntax for updating parts of a DCG argument, we should also have convenient syntax for updating the whole DCG argument. compiler/typecheck.m: Add a default clause for field access functions for which the user has supplied type and mode declarations but no clauses. Typecheck field access function calls. Use `io__write_list' to remove some duplication of code to write out comma separated lists of error descriptions. compiler/post_typecheck.m: Expand field accessor goals into the equivalent unifications. They are expanded inline rather than generating new get and set predicates for field name to avoid having to work out how to mode the generated predicates. Remove an unnecessary goal traversal to qualify function calls and constructors. That code is now called from purity.m. compiler/prog_data.m: compiler/prog_io.m: compiler/mercury_to_goedel.m: compiler/mercury_to_mercury.m: Store field names as `sym_name's rather than strings. Use a `maybe' type rather than an empty string to designate an unlabelled field. compiler/hlds_data.m: Define data structures to hold information about the field names visible in a module. compiler/hlds_module.m: Add a field to type module_info to hold information about the fields visible in a module. compiler/hlds_pred.m: Add predicates to identify field access function names, and to handle the arguments of field access functions. compiler/make_hlds.m: compiler/hlds_goal.m: compiler/modecheck_call.m: compiler/higher_order.m: compiler/purity.m: compiler/polymorphism.m: compiler/dnf.m: compiler/cse_detection.m: compiler/lambda.m: Move `create_atomic_unification' from make_hlds.m to hlds_goal.m because it is used by several other modules. compiler/hlds_goal.m: Add a version of goal_info_init which takes the context of the goal, for use by make_hlds.m. compiler/type_util.m: Add a predicate `type_util__get_type_and_cons_defn' to get the hlds_type_defn and hlds_cons_defn for a user-defined constructor. compiler/prog_util.m: Add predicates to add and remove prefixes or suffixes from the unqualified part of a sym_name. compiler/prog_out.m: Add a predicate to convert a `sym_name/arity' to a string. compiler/hlds_out.m: Add `hlds_out__simple_call_id_to_string' to convert a `pred_or_func - sym_name/arity' to a string for use in error messages. compiler/purity.m: Thread through the pred_info so that the expansion of field accessor goals can add new variables. compiler/mercury_to_mercury.m: library/ops.m: Reduce precedence of `^/2' for use as a field name separator. Add operator `^'/1 to designate which side of the `:=' is the field name in a DCG field access goal. Add operator `:=/2' for field update expressions. doc/reference_manual.texi: Document the new syntax. doc/transition_guide.texi: Document the new operators. tests/hard_coded/Mmakefile: tests/hard_coded/record_syntax.m: tests/hard_coded/record_syntax.exp: tests/invalid/Mmakefile: tests/invalid/record_syntax_errors.m: tests/invalid/record_syntax_errors.err_exp: Test cases. |
||
|
|
d8cfbaf07a |
Fix the remaining bugs with the handling of partial qualifiers
Estimated hours taken: 10 Fix the remaining bugs with the handling of partial qualifiers for nested modules. compiler/module_qual.m: Define a new abstract type partial_qualifier_info, and a predicate mq_info_get_partial_qualifier_info to get this type from the mq_info. Define a new predicate get_partial_qualifiers/3 in module_qual.m which is like the old get_partial_qualifiers/2 predicate from modules.m except that it takes a partial_qualifier_info and uses the information in this to return only the partial qualifiers for modules which are visible, rather than returning all partial qualifier regardless of whether the modules that they refer to are in scope or not. compiler/prog_util.m: Export the `insert_module_qualifier' predicate, for use in the definition of get_partial_qualifiers/3. compiler/hlds_module.m: compiler/make_hlds.m: Change the code for make_hlds__ctors_add and hlds_module__pred_table_insert/5 so that they handles partial qualifiers properly, computing the partial qualifiers by calling get_partial_qualifiers/3 rather than by checking the NeedQual variable and calling get_partial_qualifiers/2. compiler/modules.m: Delete the old get_partial_qualifiers/2 predicate. compiler/hlds_module.m: Add a new field to the HLDS containing the partial_qualifier_info. Add a partial_qualifier_info parameter to pred_table_insert/5. compiler/check_typeclass.m: compiler/make_hlds.m: When calling pred_table_insert/5, get the partial_qualifier_info from the HLDS and pass it as an extra argument. tests/hard_coded/sub-modules/nested.m: tests/hard_coded/sub-modules/nested3.m: tests/hard_coded/sub-modules/parent.m: tests/hard_coded/sub-modules/nested.exp: tests/hard_coded/sub-modules/nested3.exp: tests/hard_coded/sub-modules/parent.exp: Uncomment parts of these test cases which were previously commented out because they were not yet supported. doc/reference_manual.texi: Delete the description of this bug. |
||
|
|
6af76f74ea |
Move some declarations around and make some other minor changes in order
Estimated hours taken: 4
Move some declarations around and make some other minor changes in order
to reduce the number and complexity of the intermodule dependencies.
In particular, ensure that prog_data.m does not need to import
hlds*.m, purity.m, rl.m, or term_util.m.
Since we expect to have only one input language, but potentially many
different target languages, the general design principle that we have adopted
in order to minimize the number of dependencies, particularly cyclic ones,
is that modules which belong to an earlier stage of compilation should
not depend on modules which belong to a later stage of compilation.
However, that design principle has not been adhered to in many cases.
This change reduces the number of such cases.
compiler/prog_data.m:
compiler/hlds_pred.m:
Move definition of the types `eval_method' and `pred_or_func'
from hlds_pred.m to prog_data.m.
Add new type `mode_num' to prog_data.m, defined by
`type mode_num == int', and change the proc_id argument of
the `unused_args' pragma to instead use this type instead of proc_id.
Delete the import of module hlds_pred from prog_data.m.
compiler/prog_data.m:
compiler/hlds_data.m:
Move the definition of the type `determinism' from hlds_data.m to
prog_data.m. Delete the import of module hlds_data from prog_data.m.
compiler/prog_data.m:
compiler/purity.m:
Move the definition of the type `purity' from purity.m to prog_data.m.
Add import of module prog_data to purity.m.
Delete the import of module purity from prog_data.m.
This is needed because purity.m imports hlds*.m and so by
importing purity.m, prog_data.m was indirectly importing hlds*.m.
(An possible alternative here would be to split purity.m into two
parts, called say purity.m and check_purity.m; of these, only the
second would import hlds*.m. But that would be a significantly
more complicated change.)
compiler/prog_data.m:
compiler/rl.m:
Move the definition of the `index_spec' and `index_type' types from
rl.m to prog_data.m. Delete the import of module rl from prog_data.m.
compiler/prog_data.m:
Add new types `pragma_arg_size_info' and `pragma_termination_info'
to prog_data.m. These are similar to the existing types
`arg_size_info' and `termination_info' defined in term_util.m,
except that they correspond more directly to what is actually
used in `pragma termination_info' declarations.
compiler/term_util.m:
Add new predicates `add_context_to_arg_size_info' and
`add_context_to_pragma_termination_info' for converting
the prog_data types to their corresponding term_util types.
compiler/make_hlds.m:
compiler/mercury_to_mercury.m:
compiler/prog_io_pragma.m:
compiler/unused_args.m:
Minor modifications to handle the change in the type of the
mode number argument in `unused_args' pragmas, and in the types
of the arg_size_info and termination_info arguments in
`termination_info' pragmas.
compiler/mercury_to_mercury.m:
compiler/prog_io_pragma.m:
compiler/inst.m:
compiler/make_hlds.m:
compiler/call_gen.m:
compiler/common.m:
compiler/continuation_info.m:
compiler/det_report.m:
compiler/hlds_pred.m:
compiler/lambda.m:
compiler/magic_util.m:
compiler/modecheck_call.m:
compiler/prog_io_goal.m:
compiler/prog_io_util.m:
compiler/prog_util.m:
compiler/termination.m:
Delete imports of modules purity, rl, and hlds_pred, or
move them from the interface section to the implementation section.
compiler/inst.m:
compiler/prog_io_util.m:
Add an XXX comment explaining why we need to import hlds_data.m.
|
||
|
|
8deee71425 |
Undo the part of my previous change to make_pred_name_with_context
Estimated hours taken: 0.25 compiler/prog_util.m: Undo the part of my previous change to make_pred_name_with_context which reordered some elements of the generated name. |
||
|
|
79dcbbef15 |
User-guided type specialization.
Estimated hours taken: 60 User-guided type specialization. compiler/prog_data.m: compiler/prog_io_pragma.m: compiler/modules.m: compiler/module_qual.m: compiler/mercury_to_mercury.m: Handle `:- pragma type_spec'. compiler/prog_io_pragma.m: Factor out some common code to parse predicate names with arguments. compiler/hlds_module.m: Added a field to the module_sub_info to hold information about user-requested type specializations, filled in by make_hlds.m and not used by anything after higher_order.m. compiler/make_hlds.m: For each `:- pragma type_spec' declaration, introduce a new predicate which just calls the predicate to be specialized with the specified argument types. This forces higher_order.m to produce the specialized versions. compiler/higher_order.m: Process the user-requested type specializations first to ensure that they get the correct names. Allow partial matches against user-specified versions, e.g. map__lookup(map(int, list(int)), int, list(int)) matches map__lookup(map(int, V), int, V). Perform specialization where a typeclass constraint matches a known instance, but the construction of the typeclass_info is done in the calling module. Give slightly more informative progress messages. compiler/dead_proc_elim.m: Remove specializations for dead procedures. compiler/prog_io_util.m: Change the definition of the `maybe1' and `maybe_functor' types to avoid the need for copying to convert between `maybe1' and `maybe1(generic)'. Changed the interface of `make_pred_name_with_context' to allow creation of predicate names for type specializations which describe the type substitution. compiler/make_hlds.m: compiler/prog_io_pragma.m: Make the specification of pragma declarations in error messages consistent. (There are probably some more to be fixed elsewhere for termination and tabling). compiler/intermod.m: Write type specialization pragmas for predicates declared in `.opt' files. compiler/mercury_to_mercury.m: Export `mercury_output_item' for use by intermod.m. compiler/options.m: Add an option `--user-guided-type-specialization' enabled with `-O2' or higher. compiler/handle_options.m: `--type-specialization' implies `--user-guided-type-specialization'. compiler/hlds_goal.m: Add predicates to construct constants. These are duplicated in several other places, I'll fix that as a separate change. compiler/type_util.m: Added functions `int_type/0', `string_type/0', `float_type/0' and `char_type/0' which return the builtin types. These are duplicated in several other places, I'll fix that as a separate change. library/private_builtin.m: Added `instance_constraint_from_typeclass_info/3' to extract the typeclass_infos for a constraint on an instance declaration. This is useful for specializing class method calls. Added `thread_safe' to various `:- pragma c_code's. Added `:- pragma inline' declarations for `builtin_compare_*', which are important for user-guided type specialization. (`builtin_unify_*' are simple enough to go in the `.opt' files automatically). compiler/polymorphism.m: `instance_constraint_from_typeclass_info/3' does not need type_infos. Add `instance_constraint_from_typeclass_info/3' to the list of `typeclass_info_manipulator's which higher_order.m can interpret. NEWS: doc/reference_manual.texi: doc/user_guide.texi Document the new pragma and option. tests/invalid/Mmakefile: tests/invalid/type_spec.m: tests/invalid/type_spec.err_exp: Test error reporting for invalid type specializations. tests/hard_coded/Mmakefile: tests/invalid/type_spec.m: tests/invalid/type_spec.exp: Test type specialization. |
||
|
|
5c955626f2 |
These changes make var' and term' polymorphic.
Estimated hours taken: 20 These changes make `var' and `term' polymorphic. This allows us to make variables and terms representing types of a different type to those representing program terms and those representing insts. These changes do not *fix* any existing problems (for instance there was a messy conflation of program variables and inst variables, and where necessary I've just called varset__init(InstVarSet) with an XXX comment). NEWS: Mention the changes to the standard library. library/term.m: Make term, var and var_supply polymorphic. Add new predicates: term__generic_term/1 term__coerce/2 term__coerce_var/2 term__coerce_var_supply/2 library/varset.m: Make varset polymorphic. Add the new predicate: varset__coerce/2 compiler/prog_data.m: Introduce type equivalences for the different kinds of vars, terms, and varsets that we use (tvar and tvarset were already there but have been changed to use the polymorphic var and term). Also change the various kinds of items to use the appropriate kinds of var/varset. compiler/*.m: Thousands of boring changes to make the compiler type correct with the different types for type, program and inst vars and varsets. |
||
|
|
a70b59e83c |
Add a test to find the number of words needed to represent a
configure.in:
Add a test to find the number of words needed to represent a
synchronization term.
boehm_gc/gc.h:
fix a declaration by replacing the args () with (void).
boehm_gc/solaris_pthreads.c:
add a missing include
check the return values of pthread calls.
compiler/*.m:
Add handling for the new HLDS goal type par_conj.
Add handling for the four new LLDS instructions:
init_sync_term
fork
join_and_terminate
join_and_continue
compiler/code_info.m:
add a new alternative for slot_contents - sync_term.
compiler/handle_options.m:
add .par as part of the grade
compiler/hlds_goal.m:
add the new goal type par_conj.
compiler/instmap.m:
add instmap__unify which takes a list of instmaps
and abstractly unifies them.
add unify_instmap_delta which tajes two instmap deltas
and abstractly unifies them.
compiler/llds.m:
add the new llds instructions.
compiler/mode_info.m:
add par_conj as a lock reason.
library/Makefile:
work around a bug in the solaris version pthread.h
library/benchmarking.m:
reference the stack zones from the engine structure
rather than from global variables.
library/{nc,sp}_builtin.nl:
add an op declaration for &.
library/std_util.m:
change references to global variables to references inside
the engine structure.
runtime/Mmakefile:
add mercury_thread.{c,h}
add THREADLIBS to the libraries
runtime/*.{c,h}
Remove some old junk from the previous processes/shrd-mem
changes that found their way into the repository.
Add MR_ prefixes to lots of names.
runtime/mercury_context.c:
Add init_thread_stuff for creating and initializing a
context structure for the current thread.
runtime/mercury_context.h:
add a field to the mercury context which stores the thread id
of the thread where this context originated.
add various macros for implementing the new llds instructions.
runtime/mercury_engine.c:
initialize the engine structure, rather than a bunch of globals.
runtime/mercury_engine.h:
declare the mercury_engine structure.
runtime/mercury_regorder.h:
if MR_THREAD_SAFE, and there is at least one global register
then use mr0 as a pointer to the mercury engine structure.
scripts/init_grade_options.sh-subr
add thread_safe
scripts/mgnuc.in
add THREAD_OPTS
scripts/ml.in:
add THREAD_LIBS
|
||
|
|
247b1c24b9 |
Fix various invasions of the user's namespace by `mercury_builtin.m',
Estimated hours taken: 6
Fix various invasions of the user's namespace by `mercury_builtin.m',
by splitting mercury_builtin.m into two modules, called builtin.m and
private_builtin.m, and ensuring that the latter is imported as if
by `:- use_module' rather than `:- import_module'.
library/builtin.m:
library/private_builtin.m:
Split mercury_builtin.m into two modules, builtin.m,
which contains stuff intended to be public,
and private_builtin.m, which contains implementation
details that are not supposed to be public.
library/mercury_builtin.m:
Add a comment saying that this module is no longer used, and
should eventually be removed. I have not removed it yet, since
that would prevent bootstrapping with the current compiler. It
will be removed as a seperate change later, once all the
changes have propagated.
compiler/prog_util.m:
Change the definition of mercury_private_builtin_module/1 and
mercury_public_builtin_module so that instead of automatically
importing mercury_builtin.m as if by `import_module', the
copiler will now automatically import builtin.m as if by
`import_module' and private_builtin.m as if by `use_module'.
compiler/polymorphism.m:
Change a call to mercury_private_builtin_module/1 for
unsafe_promise_unique to instead call mercury_public_builtin_module/1.
compiler/unify_proc.m:
Avoid hard-coding "mercury_builtin" by instead
calling one of mercury_{private,public}_builtin_module/1.
runtime/mercury_type_info.[ch]:
library/term.m:
library/std_util.m:
compiler/code_util.m:
Change a few hard-coded instances of "mercury_builtin"
to "builtin" or "private_builtin" as appropriate.
runtime/mercury_trace_util.c:
runtime/mercury_trace_internal.c:
library/prolog.m:
compiler/*.m:
Update comments that refer to "mercury_builtin" to instead
refer to either "builtin" or "private_builtin".
doc/Mmakefile:
Don't include the interface to private_builtin.m in the
library reference manual.
tools/bootcheck:
Add `-p'/`--copy-profiler' option. This is needed to get
the above changes to bootstrap.
tools/test_mercury:
Pass `-p' to tools/bootcheck.
tests/term/*.trans_opt_exp:
s/mercury_builtin/builtin/g
|
||
|
|
75354e38bb |
Deforestation.
Estimated hours taken: 400
Deforestation.
This increases the code size of the compiler by ~80k when compiling
with --intermodule-optimization --deforestation.
The improvement from deforestation is not measurable for mmc -C make_hlds.m.
Compile time for make_hlds.m increased from 50.7 seconds to 52.2 seconds
when running deforestation.
compiler/simplify.m
compiler/common.m
Provide a nicer interface for simplifying a goal,
not an entire procedure.
Rework the interface to avoid manipulating lots of booleans.
Return an estimate of the improvement in cost from simplification.
Remove failing cases and disjuncts.
Add an option to optimize common structures even across calls.
Remove code to merge branched goals, since that is now
done by deforestation.
Fix a bug: the code to collect instmap_deltas for cases was not
including the switched-on variable in the instmap_delta,
which caused an abort in merge_instmap_delta if the switched
on variable was further instantiated in the switch.
This came up while compiling the compiler with --deforestation.
compiler/det_report.
Output duplicate call warnings even if --warn-simple-code is not set.
XXX fix the same problem with `:- pragma obsolete'.
compiler/code_aux.m
Update code_aux__cannot_loop to use termination information.
compiler/hlds_pred.m
compiler/dnf.m
Pass the type_info_varmap and typeclass_info_varmap
into hlds_pred__define_new_pred.
Restrict the variables of the new procedure onto the variables
of the goal.
Make sure all relevant type_infos are passed into the new
procedure if --typeinfo-liveness is set.
compiler/modes.m
compiler/unique_modes.m
compiler/mode_info.m
compiler/modecheck_unify.m
Put `how_to_check_goal' into the mode_info, rather
than passing it around.
Add a field to the `check_unique_modes' case which
controls whether unique modes is allowed to choose
a different procedure. For deforestation, this is
not allowed, since it could result in choosing a less
efficient procedure after generalisation.
compiler/options.m
New options:
--deforestation
--deforestation-depth-limit
Safety net for termination of the algorithm.
--deforestation-cost-factor
Fudge factor for working out whether deforestation
was worthwhile.
--deforestation-vars-threshold
Like --inline-vars-threshold.
Enable deforestation at -O3.
Removed an unnecessary mode for option_defaults_2, since it
resulted in a warning about disjuncts which cannot succeed.
compiler/handle_options.m
--no-reorder-conj implies --no-deforestation.
compiler/inlining.m
Separate code to rename goals into inlining__do_inline_call.
compiler/hlds_goal.m
Added predicates goal_list_nonlocals, goal_list_instmap_delta
and goal_list_determinism to approximate information about
conjunctions.
compiler/hlds_module.m
Added module_info_set_pred_proc_info to put an updated
pred_info and proc_info back into the module_info.
compiler/hlds_out.m
Exported hlds_out__write_instmap for debugging of deforestation.
Bracket module names on constructors where necessary.
compiler/mercury_compile.m
Call deforestation.
Use the new interface to simplify.m.
compiler/intermod.m
Put recursive predicates with a top-level branched goal
into `.opt' files.
goal_util.m
Added goal_calls_pred_id to work out if a predicate is
recursive before mode analysis.
Export goal_util__goals_goal_vars for use by deforestation.
Give a better message for a missing variable in a substitution.
compiler/instmap.m
Give a better message for inst_merge failing.
compiler/notes/compiler_design.m
Document the new modules.
library/varset.m
Add varset__select to project a varset's names and values
onto a set of variables.
doc/user_guide.texi
Document deforestation.
Remove a reference to a non-existent option, --no-specialize.
util/mdemangle.c
profiler/demangle.m
tests/misc_tests/mdemangle_test.{exp,inp}
Handle the `DeforestationIn__' predicate names introduced by
deforestation, similar to the `IntroducedFrom__' for lambda goals.
New files:
deforest.m Deforestation.
pd_cost.m Cost estimation.
pd_debug.m Debugging output.
pd_info.m State type and version control.
pd_term.m Termination checking.
pd_util.m Utility predicates
|
||
|
|
11d8161692 |
Add support for nested modules.
Estimated hours taken: 50
Add support for nested modules.
- module names may themselves be module-qualified
- modules may contain `:- include_module' declarations
which name sub-modules
- a sub-module has access to all the declarations in the
parent module (including its implementation section).
This support is not yet complete; see the BUGS and LIMITATIONS below.
LIMITATIONS
- source file names must match module names
(just as they did previously)
- mmc doesn't allow path names on the command line any more
(e.g. `mmc --make-int ../library/foo.m').
- import_module declarations must use the fully-qualified module name
- module qualifiers must use the fully-qualified module name
- no support for root-qualified module names
(e.g. `:parent:child' instead of `parent:child').
- modules may not be physically nested (only logical nesting, via
`include_module').
BUGS
- doesn't check that the parent module is imported/used before allowing
import/use of its sub-modules.
- doesn't check that there is an include_module declaration in the
parent for each module claiming to be a child of that parent
- privacy of private modules is not enforced
-------------------
NEWS:
Mention that we support nested modules.
library/ops.m:
library/nc_builtin.nl:
library/sp_builtin.nl:
compiler/mercury_to_mercury.m:
Add `include_module' as a new prefix operator.
Change the associativity of `:' from xfy to yfx
(since this made parsing module qualifiers slightly easier).
compiler/prog_data.m:
Add new `include_module' declaration.
Change the `module_name' and `module_specifier' types
from strings to sym_names, so that module names can
themselves be module qualified.
compiler/modules.m:
Add predicates module_name_to_file_name/2 and
file_name_to_module_name/2.
Lots of changes to handle parent module dependencies,
to create parent interface (`.int0') files, to read them in,
to output correct dependencies information for them to the
`.d' and `.dep' files, etc.
Rewrite a lot of the code to improve the readability
(add comments, use subroutines, better variable names).
Also fix a couple of bugs:
- generate_dependencies was using the transitive implementation
dependencies rather than the transitive interface dependencies
to compute the `.int3' dependencies when writing `.d' files
(this bug was introduced during crs's changes to support
`.trans_opt' files)
- when creating the `.int' file, it was reading in the
interfaces for modules imported in the implementation section,
not just those in the interface section.
This meant that the compiler missed a lot of errors.
library/graph.m:
library/lexer.m:
library/term.m:
library/term_io.m:
library/varset.m:
compiler/*.m:
Add `:- import_module' declarations to the interface needed
by declarations in the interface. (The previous version
of the compiler did not detect these missing interface imports,
due to the above-mentioned bug in modules.m.)
compiler/mercury_compile.m:
compiler/intermod.m:
Change mercury_compile__maybe_grab_optfiles and
intermod__grab_optfiles so that they grab the opt files for
parent modules as well as the ones for imported modules.
compiler/mercury_compile.m:
Minor changes to handle parent module dependencies.
(Also improve the wording of the warning about trans-opt
dependencies.)
compiler/make_hlds.m:
compiler/module_qual.m:
Ignore `:- include_module' declarations.
compiler/module_qual.m:
A couple of small changes to handle nested module names.
compiler/prog_out.m:
compiler/prog_util.m:
Add new predicates string_to_sym_name/3 (prog_util.m) and
sym_name_to_string/{2,3} (prog_out.m).
compiler/*.m:
Replace many occurrences of `string' with `module_name'.
Change code that prints out module names or converts
them to strings or filenames to handle the fact that
module names are now sym_names intead of strings.
Also change a few places (e.g. in intermod.m, hlds_module.m)
where the code assumed that any qualified symbol was
fully-qualified.
compiler/prog_io.m:
compiler/prog_io_goal.m:
Move sym_name_and_args/3, parse_qualified_term/4 and
parse_qualified_term/5 preds from prog_io_goal.m to prog_io.m,
since they are very similar to the parse_symbol_name/2 predicate
already in prog_io.m. Rewrite these predicates, both
to improve maintainability, and to handle the newly
allowed syntax (module-qualified module names).
Rename parse_qualified_term/5 as `parse_implicit_qualified_term'.
compiler/prog_io.m:
Rewrite the handling of `:- module' and `:- end_module'
declarations, so that it can handle nested modules.
Add code to parse `include_module' declarations.
compiler/prog_util.m:
compiler/*.m:
Add new predicates mercury_public_builtin_module/1 and
mercury_private_builtin_module/1 in prog_util.m.
Change most of the hard-coded occurrences of "mercury_builtin"
to call mercury_private_builtin_module/1 or
mercury_public_builtin_module/1 or both.
compiler/llds_out.m:
Add llds_out__sym_name_mangle/2, for mangling module names.
compiler/special_pred.m:
compiler/mode_util.m:
compiler/clause_to_proc.m:
compiler/prog_io_goal.m:
compiler/lambda.m:
compiler/polymorphism.m:
Move the predicates in_mode/1, out_mode/1, and uo_mode/1
from special_pred.m to mode_util.m, and change various
hard-coded definitions to instead call these predicates.
compiler/polymorphism.m:
Ensure that the type names `type_info' and `typeclass_info' are
module-qualified in the generated code. This avoids a problem
where the code generated by polymorphism.m was not considered
type-correct, due to the type `type_info' not matching
`mercury_builtin:type_info'.
compiler/check_typeclass.m:
Simplify the code for check_instance_pred and
get_matching_instance_pred_ids.
compiler/mercury_compile.m:
compiler/modules.m:
Disallow directory names in command-line arguments.
compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
compiler/modules.m:
Add a `--make-private-interface' option.
The private interface file `<module>.int0' contains
all the declarations in the module; it is used for
compiling sub-modules.
scripts/Mmake.rules:
scripts/Mmake.vars.in:
Add support for creating `.int0' and `.date0' files
by invoking mmc with `--make-private-interface'.
doc/user_guide.texi:
Document `--make-private-interface' and the `.int0'
and `.date0' file extensions.
doc/reference_manual.texi:
Document nested modules.
util/mdemangle.c:
profiler/demangle.m:
Demangle names with multiple module qualifiers.
tests/general/Mmakefile:
tests/general/string_format_test.m:
tests/general/string_format_test.exp:
tests/general/string__format_test.m:
tests/general/string__format_test.exp:
tests/general/.cvsignore:
Change the `:- module string__format_test' declaration in
`string__format_test.m' to `:- module string_format_test',
because with the original declaration the `__' was taken
as a module qualifier, which lead to an error message.
Hence rename the file accordingly, to avoid the warning
about file name not matching module name.
tests/invalid/Mmakefile:
tests/invalid/missing_interface_import.m:
tests/invalid/missing_interface_import.err_exp:
Regression test to check that the compiler reports
errors for missing `import_module' in the interface section.
tests/invalid/*.err_exp:
tests/warnings/unused_args_test.exp:
tests/warnings/unused_import.exp:
Update the expected diagnostics output for the test cases to
reflect a few minor changes to the warning messages.
tests/hard_coded/Mmakefile:
tests/hard_coded/parent.m:
tests/hard_coded/parent.child.m:
tests/hard_coded/parent.exp:
tests/hard_coded/parent2.m:
tests/hard_coded/parent2.child.m:
tests/hard_coded/parent2.exp:
Two simple tests case for the use of nested modules with
separate compilation.
|
||
|
|
73131e8df3 |
Undo Zoltan's bogus update of all the copyright dates.
Estimated hours taken: 0.75 library/*.m: compiler/*.m: Undo Zoltan's bogus update of all the copyright dates. The dates in the copyright header should reflect the years in which the file was modified (and no, changes to the copyright header itself don't count as modifications). |
||
|
|
bb4442ddc1 |
Update copyright dates for 1998.
Estimated hours taken: 0.5 compiler/*.m: Update copyright dates for 1998. |
||
|
|
bf824facde |
Make Mercury cope with impure code
The purpose of this diff is to allow Mercury programs to contain
impure Mercury code without the compiler changing its behavior
inappropriately, while still allowing the compiler to aggressively
optimize pure code. To do this, we require impure predicates to be so
declared, and calls to impure predicates to be flagged as such. We
also allow predicates implemented in terms of impure predicates to be
promised to be pure; lacking such a promise, any predicate that calls
an impure predicate is assumed to be impure.
At the moment, we don't allow impure functions (only predicates),
though some of the work necessary to support them has been done.
Note that to make the operators work properly, the precedence of the
`pred' and `func' operators has been changed from 1199 to 800.
Estimated hours taken: 150
compiler/purity.m:
New compiler pass for purity checking.
compiler/hlds_goal.m:
Add `impure' and `semipure' to the goal_feature enum.
compiler/hlds_out.m:
compiler/typecheck.m:
compiler/special_pred.m:
Fixed code that prints predicate name to write something more
helpful for special (compiler-generated) predicates. Added
code to print new markers. Added purity argument to
mercury_output_pred_type. New public predicate
special_pred_description/2 provides an english description for
each compiler-generated predicate.
compiler/hlds_pred.m:
Add `impure' and `semipure' to marker enum. Added new
public predicates to get predicate purity and whether or not
it's promised to be pure.
compiler/prog_data.m:
compiler/mercury_to_mercury.m:
compiler/prog_io.m:
compiler/prog_io_goal.m:
compiler/prog_io_pragma.m:
compiler/prog_io_dcg.m:
compiler/prog_util.m:
compiler/equiv_type.m:
compiler/intermod.m:
compiler/mercury_to_c.m:
compiler/module_qual.m:
Add purity argument to pred and func items. Add new `impure'
and `semipure' operators. Add promise_pure pragma. Add
purity/2 wrapper to goal_expr type.
compiler/make_hlds.m:
compiler/mercury_to_goedel.m:
Added purity argument to module_add_{pred,func},
clauses_info_add_pragma_c_code, and to pred and func items.
Handle promise_pure pragma. Handle purity/2 wrapper used to
handle user-written impurity annotations on goals.
compiler/mercury_compile.m:
Add purity checking pass between type and mode checking.
compiler/mode_errors.m:
Distinguish mode errors caused by impure goals preventing
goals being delayed.
compiler/modes.m:
Don't delay impure goals, and ensure before scheduling an
impure goal that no goals are delayed. Actually, we go ahead
and try to schedule goals even if impurity causes a problem,
and then if it still doesn't mode check, then we report an
ordinary mode error. Only if the clause would be mode correct
except for an impure goal do we report it as an impurity problem.
compiler/simplify.m:
Don't optimize away non-pure duplicate calls. We could do
better and still optimize duplicate semipure goals without an
intervening impure goal, but it's probably not worth the
trouble. Also don't eliminate impure goals on a failing branch.
compiler/notes/compiler_design.html:
Documented purity checking pass.
doc/reference_manual.texi:
Document purity system.
doc/transition_guide.texi:
library/nc_builtin.nl:
library/ops.m:
library/sp_builtin.nl:
New operators and new precdence for `pred' and `func'
operators.
tests/hard_coded/purity.m
tests/hard_coded/purity.exp
tests/hard_coded/Mmakefile:
tests/invalid/purity.m
tests/invalid/purity_nonsense.m
tests/invalid/purity.err_exp
tests/invalid/purity_nonsense.err_exp
tests/invalid/Mmakefile:
Test cases for purity.
|
||
|
|
04b720630b |
Update the copyright messages so that (a) they contain the correct years
and (b) they say "Copyright (C) ... _The_ University of Melbourne". |
||
|
|
9b7f11c6dd |
Reorganisation of modules to do with the inst data type.
Estimated hours taken: 20 Reorganisation of modules to do with the inst data type. This is actually the first installment of the alias tracking mode checker in disguise. A very good disguise. The rationale for this reorganisation is to reduce coupling in the part of the mode checker which is _not_ in this change (ie most of it). Alias tracking requires a new kind of inst, alias(inst_key), where an inst_key is a handle on some other sub-inst. With it goes a data structure in which to store dereferenced insts and all the operations which go with it. This code will go in the new module inst.m so that it doesn't have to go in prog_data.m. (I briefly considered putting it in instmap.m however this introduces some bad coupling since instmap.m imports hlds_module.m. Putting it in prog_data.m would cause hlds_*.m to depend on prog_data.m, but we have designed things so that the dependencies go in the other direction.) The remainder of the reorganisation is a general cleanup: the inst testing predicates (inst_is_*) have been moved out of mode_util because they are not actually operations on modes at all, and have been moved into inst_match. inst_match has then been split because otherwise it would be 2000 lines long and will get significantly bigger when aliasing is added. Roughly speaking, any operations which create new insts from old ones have been moved into a new module, inst_util while any operations which test the values of insts remain in inst_match. Also included are the removal of some NU-Prologisms since the NU-Prolog version of the compiler is no longer supported. Two changes here: - Removal of some when declarations. - A gross hack in inst_is_*_2, where two copies of the same inst were passed into the predicate so that one could be switched on. Thank NU-Prolog's lack of common subexpression elimination. compiler/inst.m: New module which contains the data types inst, uniqueness, pred_inst_info, bound_inst. compiler/inst_util.m: New module which contains predicates which perform mode checking-like operations on insts. Moved in: abstractly_unify_inst, abstractly_unify_inst_functor, inst_merge, make_mostly_uniq_inst (from inst_match.m) compiler/inst_match.m: Moved out: inst_merge, make_mostly_uniq_inst, abstractly_unify_inst, abstractly_unify_inst_functor (to inst_util.m) Moved in: inst_is_*, inst_list_is_*, bound_inst_list_is_* (from mode_util.m) Now exported: unique_matches_initial/2, unique_matches_final/2 inst_contains_instname/3, pred_inst_matches/3 (They are required by inst_util.m, and they are useful in their own right.) compiler/instmap.m: instmap_delta_lookup_var/3 reincarnated as instmap_delta_search_var/3. The reason for this change is that previously, instmap_delta_lookup_var simply returned `free' if the searched-for var did not occur in the instmap_delta. This is somewhat non-obvious behaviour. instmap_delta_search_var/3 fails in such a situation. compiler/mode_util.m: Moved out: inst_is_*, inst_list_is_*, bound_inst_list_is_* (to inst_match.m) (These are not really operations on modes.) compiler/modecheck_call.m: Moved in modecheck_higher_order_func_call/5, from modecheck_unify.m compiler/modecheck_unify.m: Moved out modecheck_higher_order_func_call/5, to modecheck_call.m where it should have been all along. compiler/prog_data.m: Moved out the types inst, uniqueness, pred_inst_info, bound_inst (to inst.m). compiler/common.m: compiler/cse_detection.m: compiler/fact_table.m: compiler/higher_order.m: compiler/hlds_data.m: compiler/hlds_goal.m: compiler/hlds_out.m: compiler/intermod.m: compiler/liveness.m: compiler/llds.m: compiler/make_hlds.m: compiler/mercury_to_mercury.m: compiler/mode_debug.m: compiler/mode_errors.m: compiler/mode_info.m: compiler/modes.m: compiler/module_qual.m: compiler/polymorphism.m: compiler/prog_io.m: compiler/prog_io_util.m: compiler/prog_util.m: compiler/simplify.m: compiler/switch_detection.m: compiler/unify_proc.m: compiler/unique_modes.m: Miscellaneous minor changes to cope with the above changes. compiler/notes/compiler_design.html: Document the new modules. |
||
|
|
a15c032df7 |
Flesh out the code already here for traversing module_infos,
Estimated hours taken: 4 passes_aux: Flesh out the code already here for traversing module_infos, making it suitable to handle all the passes of the back end. mercury_compile: Use the traversal code in passes_aux to invoke the back end passes over each procvedure in turn. Print a one-line message for each predicate if -v is given (this fixes a long-standing bug). excess.m, follow_code.m, follow_vars.m, live_vars.m, lveness.m, store_alloc.m: Remove the code to traverse module_infos, since it is now unnecessary. export.m: Remove an unused argument from export__produce_header_file_2. others: Move imports from interfaces to implementations, or in some cases remove them altogether. |
||
|
|
66c9b90738 |
Split the expansion of equivlance types from prog_util.m
Estimated hours taken: 0.75 prog_util.m, equiv_type.m: Split the expansion of equivlance types from prog_util.m into a new file equiv_type.m. Use slightly clearer predicate names, starting with equiv_type__ rather than prog_util__ of course. mercury_compile.pp, mercury_to_goedel.m: Changed to use equiv_type rather than prog_util. mercury_to_goedel.m: Move some import_module declarations from the interface to the implementation section, since they weren't needed by the interface. |
||
|
|
52929b12e0 |
Recommit my earlier (buggy) change to avoid looping during the
Estimated hours taken: 1 compiler/prog_util.m: Recommit my earlier (buggy) change to avoid looping during the expansion of equivalence types for `:- type foo == bar(foo)', with the bug fixed this time. (The bug was that I was passing down the wrong set of type ids when processing the arguments - since we process things bottom-up, the current type-id has not yet been expanded when processing the arguments, and it shouldn't be included in the set at that point.) |
||
|
|
f0db37abbd |
Back out my previous change to avoid looping for
Estimated hours taken: 0.5 compiler/prog_util.m: Back out my previous change to avoid looping for `:- type foo == bar(foo)', since my change was buggy --- it meant that we failed to expand some equivalence types that we should have. |
||
|
|
7109800147 |
Fix a bug in the expansion of equivalence types:
Estimated hours taken: 2 compiler/prog_util.m: Fix a bug in the expansion of equivalence types: the loop detection code was not quite right, and so it looped for `:- type foo == bar(foo)'. |
||
|
|
5d9e4158f7 |
Module qualification of types, insts and modes.
Estimated hours taken: 45
Module qualification of types, insts and modes.
Added a new interface file - <module>.int3. This contains the
short interface qualified as much as possible given the information
in the current module.
When producing the .int and .int2 files for a module, the compiler uses
the information in the .int3 files of modules imported in the interface
to fully module qualify all items. The .int2 file is just a fully
qualified version of the .int3 file. The .int3 file cannot be overwritten
by the fully qualified version in the .int2 file because then mmake would
not be able to tell when the interface files that depend on that .int3
file really need updating.
The --warn-interface-imports option can be used to check whether
a module imported in the interface really needs to be imported in
the interface.
compiler/module_qual.m
Module qualify all types, insts and modes. Also checks for modules
imported in the interface of a module that do not need to be.
compiler/modules.m
The .int file for a module now depends on the .int3 files of imported
modules. Added code to generate the make rule for the .int file in the
.d file. There is now a file .date2 which records the last time the
.int2 file was updated.
The .int3 files are made using the --make-short-interface option
introduced a few weeks ago.
compiler/options.m
Added option --warn-interface-imports to enable warning about interface
imports which need not be in the interface. This is off by default
because a lot of modules in the library import list.m when they only
need the type list, which is defined in mercury_builtin.m.
Removed option --builtin-module, since the mercury_builtin name is wired
into the compiler in a large number of places.
compiler/prog_util.m
Added a predicates construct_qualified_term/3 and construct_qualfied_term/4
which take a sym_name, a list of argument term and a context for the /4
version and give a :/2 term.
compiler/type_util.m
Modified type_to_type_id to handle qualified types. Also added predicates
construct_type/3 and construct_type/4 which take a sym_name and a list of
types and return a type by calling prog_util:construct_qualified_term.
compiler/modes.m
On the first iteration of mode analysis, module qualify the modes of
lambda expressions.
compiler/mode_info.m
Added field to mode_info used to decide whether or not to module qualify
lambda expressions.
compiler/mode_errors.m
Added dummy mode error for when module qualification fails so that mode
analysis will stop.
Added code to strip mercury_builtin qualifiers from error messages to
improve readability.
compiler/typecheck.m
Strip builtin qualifiers from error messages.
compiler/llds.m
compiler/llds_out.m
compiler/opt_util.m
compiler/opt_debug.m
Change the format of labels produced for the predicates to use the
qualified version of the type name.
compiler/mercury_compile.pp
Call module_qual__module_qualify_items and make_short_interface.
Remove references to undef_modes.m and undef_types.m
compiler/undef_modes.m
compiler/undef_types.m
Removed, since their functionality is now in module_qual.m.
compiler/prog_io.m
Changed to qualify the subjects of type, mode and inst declarations.
compiler/*.m
Changes to stop various parts of the compiler from throwing away
module qualifiers.
Qualified various mercury_builtin builtins, e.g. in, out, term etc.
where they are wired in to the compiler.
compiler/hlds_data.m
The mode_table and user_inst_table are now abstract types each
storing the {mode | inst}_id to hlds__{mode | inst}_defn maps
and a list of mode_ids or inst_ids. This was done to improve the
efficiency of module qualifying the modes of lambda expressions
during mode analysis.
module_info_optimize/2 now sorts the lists of ids.
The hlds_module interface to the mode and inst tables has not changed.
compiler/hlds_module.m
Added yet another predicate to search the predicate table.
predicate_table_search_pf_sym_arity searches for predicates or
functions matching the given sym_name, arity and pred_or_func.
compiler/higher_order.m
Changed calls to solutions/2 to list__filter/3. Eliminated unnecessary
requantification of goals.
compiler/unused_args.m
Improved abstraction slightly.
|
||
|
|
c588526f03 |
Add a predicate to rename variables in the kinds of goals we have in
Estimated hours taken: 1 prog_util: Add a predicate to rename variables in the kinds of goals we have in items. (We already have similar predicates for terms and for hlds_goals). prog_io: We used to expand ( p ; q ) in DCG clauses to become ( p(DCG1, DCG2) ; q(DCG1, DCG3), DCG2 = DCG3 ). These extra unifications can pile up rather badly; in the new version of lexer.m, two 128-way switches each ended up with 90 unifications in the last arm. This is very bad for performance. Instead of adding unifications to make sure that both arms of a disjunction put the final stream value in the same variable, we now use renaming when possible. |
||
|
|
f89d46df5e |
Fix a bug (caused by a cut-and-paste variable numbering error) in
Estimated hours taken: 0.5 compiler/prog_util.m: Fix a bug (caused by a cut-and-paste variable numbering error) in the expansion of equivalence types in `:- func' declarations. (Thanks to Tyson for the bug report.) |
||
|
|
4133ba3cf3 |
Change the expansion of equivalence types to use an O(N log N)
Estimated hours taken: 4 prog_util.m: Change the expansion of equivalence types to use an O(N log N) algorithm rather than an O(N * N) one. This change cuts the compilation time for live_vars.m (a bad case as far as equivalence types are concerned, since it imports so many modules) by more than 15%. |
||
|
|
649b6908c3 |
Rename branch_delay_slot to have_delay_slot.
Estimated hours taken: 8 options.m: Rename branch_delay_slot to have_delay_slot. Set optimize_delay_slot in -O2 only if have_delay_slot was set earlier. This is possible now because the default optimization level is now set in mc. mercury_compile: Change verbose output a bit to be more consistent. dead_proc_elim: Export the predicates that will eventually be needed by inlining.m. inlining.m: Use the information about the number of times each procedure is called to inline local nonrecursive procedures that are called exactly once. EXCEPT that this is turned off at the moment, since the inlining of parse_dcg_goal_2 in prog_io, which this change enables, causes the compiler to emit incorrect code. prog_io: Moved the data type definitions to prog_data. (Even though prog_io.m is ten times the size of prog_data.m, the sizes of the .c files are not too dissimilar.) |
||
|
|
f839ec8f78 |
Expand eqivalence types in `:- func' declarations.
Estimated hours taken: 0.25 compiler/prog_util.m: Expand eqivalence types in `:- func' declarations. |
||
|
|
3b36da6e77 |
Implement functional syntax. You can now use `:- func' in a similar manner
Estimated hours taken: 12 Implement functional syntax. You can now use `:- func' in a similar manner to `:- pred'. For example, `:- func foo(int, int) = int.' declares a function, and `:- mode foo(in, in) = out.' defines a mode for it. You can write clauses for functions, such as `foo(X, Y) = Z :- Z is 2*X + Y.' Any term in the head or body of a clause can be a function call, e.g. `bar(X, Y, foo(X, Y))'. Until we have implemented a proper Mercury debugger, this syntax should not be used (except that I might reimplement the functions provided by Prolog's is/2 predicate using this syntax, rather than the current special-case hack in the parser). prog_io.m: Add syntax for declaring and defining functions. Disallow the use of `=' to define modes, as in `:- mode foo = bar.' (Instead, you should use `::'. `==' is also allowed.) Also, use higher-order predicates to simplify some of the rather repetitious parsing code. mercury_to_mercury.m, mercury_to_goedel.m, make_hlds.m, modules.m: Handle new functional syntax. typecheck.m: Add support for functions, function types such as `func(int) = int', and currying. (But there's currently no equivalent to call/N for functions, so function types and currying aren't very useful yet.) undef_types.m: Add support for function types. modes.m: Convert function calls into predicate calls. (This must be done after typechecking is complete, so I put it in mode analysis.) hlds.m: Add new field `pred_or_func' to the pred_info. hlds_out.m: Print out the `pred_or_func' field. higher_order.m, unused_args.m, lambda.m, dnf.m: Pass extra pred_or_func argument to pred_info_init to specify that the thing being created is a predicate, not a function. constraint.m, dependency_graph.m, hlds_out.m: `mercury_output_mode_subdecl' has been renamed `mercury_output_pred_mode_subdecl'. prog_util.m: Add new predicate split_type_and_mode/3. llds.m: Print out /* code for predicate '*'/3 in mode 0 */ rather than /* code for predicate */3 in mode 0 */ to avoid a syntax error in the generated C code. |
||
|
|
6d7f4b9b30 |
Undo dylan's changes in the names of some library entities,
Estimated hours taken: 1.5 Undo dylan's changes in the names of some library entities, by applying the following sed script s/term_atom/term__atom/g s/term_string/term__string/g s/term_integer/term__integer/g s/term_float/term__float/g s/term_context/term__context/g s/term_functor/term__functor/g s/term_variable/term__variable/g s/_term__/_term_/g s/std_util__bool_/bool__/g to all the `.m' and `.pp' files in the compiler and library directories. The reason for undoing these changes was to minimize incompatibilities with 0.4 (and besides, the changes were not a really good idea in the first place). I also moved `bool' to a separate module. The main reason for that change is to ensure that the `__' prefix is only used when it genuinely represents a module qualifier. (That's what dylan's changes were trying to acheive, but `term__' does genuinely represent a module qualifier.) compiler/*.m: Apply sed script above; where appropriate, add `bool' to the list of imported modules. |
||
|
|
3ab8d92226 |
Change names with badly placed double underscores (ie where the part of
Estimated hours taken: _2___ Change names with badly placed double underscores (ie where the part of a name before a double underscore is not the same as the module name.) Reflect changes in the library interface. compiler/*: Use the newer, more correct form of the term and bool names. Predicates "bool__" are now "std_util__bool" and labels of the term ADT are now "term_" instead of "term__". compiler/vn*.m: change all names "vn__*" to a correct module prefix. All the names remain qualified. compiler/hlds.m: s/\<is_builtin__/hlds__is_builtin_/g s/\<dependency_info__/hlds__dependency_info_/g compiler/unify_proc.m: s/\<unify_proc_info__/unify_proc__info_/g compiler/transform.m: s/\<reschedule__conj/transform__reschedule_conj/g |
||
|
|
bebe96be34 |
Look inside blocks introduced by value numbering when looking
frameopt: Look inside blocks introduced by value numbering when looking restorations of succip. value_number, opt_util: If we are using conservative garbage collection, disable value numbering for blocks that allocate more than one cell on the heap. This allows value numbering of most blocks to work in the absence of -DALL_INTERIOR_POINTERS. all other source files: Clean up "blank" lines that nevertheless contain space or tab characters. |
||
|
|
ac4f8ba0fb |
Add copyright messages.
compiler/*: Add copyright messages. Change all occurences of *.nl in comments to *.m. compiler/mercury_compile.pp: Change the output to the .dep files to use *.m rather than *.nl. (NOTE: this means that `mmake' will not work any more if you call your files *.nl!!!) |
||
|
|
280479f7ee |
Fix bug in make_proc_label: for unification predicates,
code_util.nl: Fix bug in make_proc_label: for unification predicates, look at the _last_ argument to determine the type for name mangling, not the first, since we introduce extra higher-order arguments at the start. make_hlds.nl, hlds.nl: Ensure that the proc_info head_vars has the right length even for imported predicates. This fixes a problem with --polymorphism. make_hlds, unify_proc.nl, prog_util.nl: Output unification procedures for equivalence types. polymorphism.nl: Ensure that this works even for unification procedures for equivalence types, which are a bit wierd since they are not quite type correct. typecheck.nl: Don't attempt to typecheck unification predicates, since they are already type-correct when we construct them. In particular don't typecheck unification procedures for equivalence types, since it would report a spurious error. mercury_to_mercury.nl: Remove a superfluous duplicate clause. |
||
|
|
c074b02970 |
In term__create_var, use bit reversals rather than random numbers
term.nl: In term__create_var, use bit reversals rather than random numbers to ensure that the binary trees remain balanced. call_gen.nl: For polymorphic unifications, generate a call to fatal_error(). code_gen.nl, hlds.nl, make_hlds.nl, modes.nl, unify_proc.nl: Move the unify_request data structure from code_info to the HLDS, and move the unify_request handling from code_gen.nl to modes.nl. This is because we now generate HLDS code rather than LLDS code for complicated unifications. code_util.nl, hlds_out.nl: Do some special name mangling for =/2. float.nl, typecheck.nl, undef_types.nl, term.nl, hlds.nl: Until we implement `float' properly, define it as an abstract type in float.nl. hlds.nl, make_hlds.nl: Rename `local_pred, imported_pred, exported_pred' to just `local, imported, exported' since they also apply to types, etc., not just to preds. mercury_compile.pp, mercury_to_goedel.nl, prog_util.nl: Replace to goedel__ prefixes in prog_util.nl with prog_util__. std_util.nl: Change the code for semidet_succeed to avoid determinism warning. |
||
|
|
d8c9479872 |
Override the MERCURY_LIB_OBJS variable when invoking ml.
Makefile.mercury: Override the MERCURY_LIB_OBJS variable when invoking ml. This avoids some bootstrapping problems. Also, add mercury_compile.nu. Makefile.common: Bump NU-Prolog's -u option up to 2000 (8M), to avoid some memory problems. array.nl, bintree.nl, char.nl, dir.nl, globals.nl, list.nl, map.nl, modes.nl, prog_util.nl, stack.nl, std_util.nl, string.nl, term.nl: Avoid the use of implied modes. code_info.nl, bimap.nl, make_hlds.nl, mercury_compile.nl, mercury_to_mercury.nl, unify_proc.nl: Fix determinism errors which had previously not been discovered because of either implied modes or running out of memory. (Note that I had to change the interface to bimap__lookup, since it's not possible to make it bidirectional.) code_util.nl, llds.nl, opt_debug.nl, value_number.nl: Rename `operator' as `binary_op'. hlds.nl, code_info.nl, unify_gen.nl, llds.nl, opt_debug.nl, switch_gen.nl: *** Handle simple cases of higher-order pred terms. *** (We don't yet handle taking the address of an overloaded predicate or a predicate with multiple modes. We don't handle closures. call/1 and call/N are not yet implemented. This has not yet been tested.) make_hlds.nl: Modify the mode priority ordering so that semidet modes get selected before det ones. llds.nl: Don't include the priority part of the mode number in the mangled label name. *** Note: this will break some things! *** mercury_compile.nl: Move the NU-Prolog hacks into mercury_compile.nu.nl. switch_gen.nl: Fix a simple logic bug in handling the grab/slap of the code_info. prog_io.nl, builtins.nl, int.nl: Fix bugs and omissions with handling of the new arithmetic operators. prog_io.nl: As a quick hack, strip off calls to io__gc_call (this avoids spurious error messages which are due to the fact that we don't get mode analysis right in those cases). |
||
|
|
07245508b4 |
Fix errors in mode declarations (the errors were only detected
prog_util.nl: Fix errors in mode declarations (the errors were only detected once I fixed det analysis for switches). |
||
|
|
534e5c221e |
Fix lots of determinism problems.
*.nl: Fix lots of determinism problems. |
||
|
|
987bef62be |
Add determinism declarations. Fix a few determinism problems.
*.nl: Add determinism declarations. Fix a few determinism problems. |
||
|
|
30f5e18b2f |
Remove map__search_insert; it's not needed and it's not
bintree.nl, map.nl, varset.nl: Remove map__search_insert; it's not needed and it's not really useful. bintree.nl: Fix determinism problem in bintree__from_list_2. options.nl, det_analysis.nl, make_hlds.nl: Add options to suppress determinism warnings. det_analysis.nl, hlds.nl, modes.nl: Allow the delta-instmap to be `unreachable'. hlds_out.nl: Output the delta-instmap. Output conjunctions differently in verbose mode. llds.nl: Fix determinism problem. Change GOTO(LABEL(...)) into GOTO_LABEL(...) which can be more efficient. map.nl: Add map__overlay/3. typecheck.nl, modes.nl, mode_errors.nl, options.nl, hlds_out.nl. Split the old `debug' option into debug-types and debug-modes. Change the default for the `modecheck' option to `yes'. Add a new verbose-dump-hlds option, and use that instead of the very-verbose option in hlds_out.nl. mode_util.nl: Export mode_get_insts/4. Add instmap_lookup_var (moved from modes.nl). Add apply_instmap_delta. modes.nl, term.nl, prog_util.nl: Add determinism annotations. term.nl, prog_io.nl: Fix bugs in when declarations. std_util.nl, prog_io.nl: Add a maybe(T) type to std_util.nl. Rename the maybe(T) type in prog_io.nl as maybe1(T). |
||
|
|
94d9c1abb9 |
Use det_pred(...), semidet_pred(...), nondet_pred(...)
mercury_builtin.nl: Use det_pred(...), semidet_pred(...), nondet_pred(...) rather than call_pred(...) for the higher-order predicate modes. prog_io.nl, io.nl, varset.nl, etc. Add determinism annotations. hlds.nl, make_hlds.nl, LOTS of other files: Reorganize the way the predicate table works. Make hlds.nl a bit more modular. Change call/4 to call/5. Remove all/2 from the hlds. Changed pred_id to an integer. Added pred_call_id which is similar to the old pred_id. Makefile: Add a rule for creating *.hlds_dump. array.nl: Fix determinism error. det_analysis.nl: Fix a bug in printing determinism warnings. fix_errors.sed: Modify this so it allows all the `inferred nondet' determinism errors but none of the `inferred semidet' ones. llds.nl: Rename llds__pred_mode_id as llds__proc_id. mode_errors.nl: Finally got around to implementing Zoltan's suggestions about the error messages from the mode analysis. If an error occurs in a conjunction, only one error message is printed out - the first error which doesn't relate to a head unification. modes.nl: Handle X = f(X) properly. NB: determinism analysis and code generation still get it wrong! undef_modes, undef_insts: I've broken the error message code, since it's not easy to print pred_ids. I just changed it so that it didn't print the pred_ids out. Should fix this properly at some stage... |
||
|
|
8bf2aacf0b |
Rename a whole bunch of predicates.
*.nl: Rename a whole bunch of predicates. Apart from some manual changes to list.nl, the changes were all generated by applying the following sed script: /[^a-zA-Z_]goedel_expand(/s/goedel_expand(/prog_util__expand(/g /[^a-zA-Z_]goedel_replace(/s/goedel_replace(/prog_util__replace(/g /[^a-zA-Z_]to_upper(/s/to_upper(/char__to_upper(/g /[^a-zA-Z_]to_lower(/s/to_lower(/char__to_lower(/g /[^a-zA-Z_]is_upper(/s/is_upper(/char__is_upper(/g /[^a-zA-Z_]is_lower(/s/is_lower(/char__is_lower(/g /[^a-zA-Z_]is_alpha(/s/is_alpha(/char__is_alpha(/g /[^a-zA-Z_]is_alnum(/s/is_alnum(/char__is_alnum(/g /[^a-zA-Z_]is_alpha_or_underscore(/s/is_alpha_or_underscore(/char__is_alpha_or_underscore(/g /[^a-zA-Z_]is_alnum_or_underscore(/s/is_alnum_or_underscore(/char__is_alnum_or_underscore(/g /[^a-zA-Z_]is_digit(/s/is_digit(/char__is_digit(/g /[^a-zA-Z_]lower_upper(/s/lower_upper(/char__lower_upper(/g /[^a-zA-Z_]io__op(/s/io__op(/term_io__op(/g /[^a-zA-Z_]io__current_ops(/s/io__current_ops(/term_io__current_ops(/g /[^a-zA-Z_]io__read_term(/s/io__read_term(/term_io__read_term(/g /[^a-zA-Z_]io__write_term(/s/io__write_term(/term_io__write_term(/g /[^a-zA-Z_]io__write_constant(/s/io__write_constant(/term_io__write_constant(/g /[^a-zA-Z_]io__write_variable(/s/io__write_variable(/term_io__write_variable(/g /[^a-zA-Z_]mercury_quote_string(/s/mercury_quote_string(/term_io__quote_string(/g /[^a-zA-Z_]mercury_quote_atom(/s/mercury_quote_atom(/term_io__quote_atom(/g /[^a-zA-Z_]mercury_quote_char(/s/mercury_quote_char(/term_io__quote_char(/g /[^a-zA-Z_]mercury_quote_single_char(/s/mercury_quote_single_char(/term_io__quote_single_char(/g /[^a-zA-Z_]delay_info_/s/delay_info_/delay_info__/g /[^a-zA-Z_]process_options(/s/process_options(/getopt__process_options(/g /[^a-zA-Z_]lookup_option(/s/lookup_option(/globals__lookup_option(/g /[^a-zA-Z_]append(/s/append(/list__append(/g /[^a-zA-Z_]member(/s/member(/list__member(/g /[^a-zA-Z_]merge(/s/merge(/list__merge(/g /[^a-zA-Z_]member_chk(/s/member_chk(/list__member_chk(/g /[^a-zA-Z_]length(/s/length(/list__length(/g /[^a-zA-Z_]condense(/s/condense(/list__condense(/g /[^a-zA-Z_]same_length(/s/same_length(/list__same_length(/g /[^a-zA-Z_]split_list(/s/split_list(/list__split_list(/g /[^a-zA-Z_]reverse(/s/reverse(/list__reverse(/g /[^a-zA-Z_]delete(/s/delete(/list__delete(/g /[^a-zA-Z_]delete_first(/s/delete_first(/list__delete_first(/g /[^a-zA-Z_]sort(/s/sort(/list__sort(/g /[^a-zA-Z_]nth_member_search(/s/nth_member_search(/list__nth_member_search(/g /[^a-zA-Z_]nth_member_lookup(/s/nth_member_lookup(/list__nth_member_lookup(/g /^goedel_expand(/s/goedel_expand(/prog_util__expand(/g /^goedel_replace(/s/goedel_replace(/prog_util__replace(/g /^to_upper(/s/to_upper(/char__to_upper(/g /^to_lower(/s/to_lower(/char__to_lower(/g /^is_upper(/s/is_upper(/char__is_upper(/g /^is_lower(/s/is_lower(/char__is_lower(/g /^is_alpha(/s/is_alpha(/char__is_alpha(/g /^is_alnum(/s/is_alnum(/char__is_alnum(/g /^is_alpha_or_underscore(/s/is_alpha_or_underscore(/char__is_alpha_or_underscore(/g /^is_alnum_or_underscore(/s/is_alnum_or_underscore(/char__is_alnum_or_underscore(/g /^is_digit(/s/is_digit(/char__is_digit(/g /^lower_upper(/s/lower_upper(/char__lower_upper(/g /^io__op(/s/io__op(/term_io__op(/g /^io__current_ops(/s/io__current_ops(/term_io__current_ops(/g /^io__read_term(/s/io__read_term(/term_io__read_term(/g /^io__write_term(/s/io__write_term(/term_io__write_term(/g /^io__write_constant(/s/io__write_constant(/term_io__write_constant(/g /^io__write_variable(/s/io__write_variable(/term_io__write_variable(/g /^mercury_quote_string(/s/mercury_quote_string(/term_io__quote_string(/g /^mercury_quote_atom(/s/mercury_quote_atom(/term_io__quote_atom(/g /^mercury_quote_char(/s/mercury_quote_char(/term_io__quote_char(/g /^mercury_quote_single_char(/s/mercury_quote_single_char(/term_io__quote_single_char(/g /^delay_info_/s/delay_info_/delay_info__/g /^process_options(/s/process_options(/getopt__process_options(/g /^lookup_option(/s/lookup_option(/globals__lookup_option(/g /^append(/s/append(/list__append(/g /^member(/s/member(/list__member(/g /^merge(/s/merge(/list__merge(/g /^member_chk(/s/member_chk(/list__member_chk(/g /^length(/s/length(/list__length(/g /^condense(/s/condense(/list__condense(/g /^same_length(/s/same_length(/list__same_length(/g /^split_list(/s/split_list(/list__split_list(/g /^reverse(/s/reverse(/list__reverse(/g /^delete(/s/delete(/list__delete(/g /^delete_first(/s/delete_first(/list__delete_first(/g /^sort(/s/sort(/list__sort(/g /^nth_member_search(/s/nth_member_search(/list__nth_member_search(/g /^nth_member_lookup(/s/nth_member_lookup(/list__nth_member_lookup(/g /[^a-zA-Z_]delete_all(/s/delete_all(/list__delete_all(/g /^delete_all(/s/delete_all(/list__delete_all(/g |
||
|
|
019ee742f8 |
Break modes.nl up into separate modules.
modes.nl, mode_errors.nl, delay_info.nl, mode_info.nl, undef_modes.nl: Break modes.nl up into separate modules. toplevel.nl (plus LOTS of other files): Change the way module imports are handled. Fix the resulting missing import problems found in most of the modules. mode_util.nl: Add predicate inst_is_bound_to_functors/3. switch_detection.nl: New file. Still very incomplete. meta.nl: Remove. This file was old junk. |
||
|
|
0ad664520e |
Rename various things for consistency:
s/term_functor/term__functor/g s/term_atom/term__atom/g s/term_string/term__string/g s/term_int/term__int/g s/term_float/term__float/g s/term_variable/term__variable/g /:- mode.*[^a-zA-Z_]input,/s/input,/in,/g /[^a-zA-Z_]input,.*)/s/input,/in,/g /:- mode.*[^a-zA-Z_]output,/s/output,/out,/g /[^a-zA-Z_]output,.*)/s/output,/out,/g /:- mode.*[^a-zA-Z_]input)/s/input)/in)/g /:- mode.*[^a-zA-Z_]output)/s/output)/out)/g /[a-z]info/s/info/_info/g /__info/s/__info/_info/g |
||
|
|
4178752860 |
Fix bugs in the implicit quantification.
make_hlds.nl: Fix bugs in the implicit quantification. Makefile, doit.nl: Add stack.nl. det_analysis.nl: Fix minor bug in the error message. interpreter.nl: Print out the answers to the query. mercury_to_mercury: Added mercury_output_hlds_goal. Also export mercury_output_vars. modes.nl: Handle reordering of conjunctions. Handle variable locking in all cases. (Complete, but probably needs some bug fixes.) prog_util.nl: Fix another goddamned bug in the type-checker - I thought we'd killed the last of those! This one was a problem in the expansion of equivalence types - failed for map(map(...)). |