mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-23 13:23:47 +00:00
083d376e6598628362ee91c2da170febd83590f4
13 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
bda87983d4 |
Move some code to new io.error_util module.
This reduces the size of io.m a bit. The other reason for moving the
code is to allow modules that occur in a dependency cycle with io.m
to read results from io.error_util.trans_opt, whereas they may have
been prevented from reading io.trans_opt.
library/io.m:
library/io.error_util.m:
Move is_error, throw_on_error and other similar predicates to a
new undocumented submodule of io.m.
Also move the support functions/predicates used by those predicates.
Make io.make_io_error_from_system_error and
io.make_io_error_from_windows_error call the implementations in
io.error_util.m.
library/MODULES_UNDOC:
library/library.m:
List the new submodule as undocumented.
library/benchmarking.m:
library/bitmap.m:
library/dir.m:
library/io.call_system.m:
library/io.file.m:
Import the new submodule.
|
||
|
|
e163ea91b6 |
Carve io.text_read.m out of io.m, and ...
... move the implementation of flush_*output to io.stream_ops.m.
In both cases, improve the predicate names a bit.
Add a distinguishing prefix to the names of the function symbols of a type,
to reduce the number of times the function symbol names ok, error and eof
are overloaded from ridiculous to slighly less ridiculous :-(
Move related predicate arguments next to each other.
library/io.text_read.m:
New submodule containing the code that implement the predicates
that read values of non-primitive types, all but one of which are text.
library/io.stream_ops.m:
Move the implementation of flushing output here from io.m.
library/io.m:
Delete the code moved to the above modules.
library/MODULES_UNDOC:
library/library.m:
List the new submodule as undocumented.
library/Mercury.options:
Allow io.text_read.m, instead of io.m, to define an inst for a type
that has a definition in a foreign language as well as Mercury.
This diff moves this inst definition to io.text_read.m.
|
||
|
|
05fd615471 |
Carve io.stream_ops.m out of io.m.
Also, move foreign code pieces still in io.m that belong in
previously-carved-out modules to those modules.
library/io.m:
library/io.stream_ops.m:
As above. The new private submodule contains the implementations
(helper predicates) of the operations that
- open and close streams,
- get and set offsets in those streams,
- get and set line numbers on streams,
- return the standard streams, and
- set streams as the current streams.
library/io.m:
Make some previously private includes public, to allow modules outside
of io.m to refer to the C# and Java symbols they define. These includes
are in the second, undocumented interface section of io.m.
Delete the foreign code moved to io.primitives_{read,write}.m,
as well as the foreign code moved to io.stream_ops.m.
Change {get,set}_{line_number,output_line_number}/3, which used
to be implemented directly using foreign_procs, to implement them
in terms of their arity-4 counterparts which take an explicit stream
argument, which now are in io.stream_ops.m. This can yield a slowdown,
but it should be so small as to be unmeasurable on all non-microbenchmark
workloads.
Move related code together.
Update module qualifications in C# and Java code.
Delete the second #include of mercury_library_types.h.
Delete the MR_{initial,final}_io_state macros.
library/MODULES_UNDOC:
library/library.m:
List the new submodule as undocumented.
library/io.primitives_read.m:
library/io.primitives_write.m:
Move the C, C# and Java code related to reading and writing values
of primitive types here from io.m. Put them into one foreign_decl
and one foreign_code per language.
Update module qualifications in C# and Java code.
library/benchmarking.m:
library/bitmap.m:
library/io.call_system.m:
Update module qualifications in C# and Java code.
library/stm_builtin.m:
Replace uses of the MR_{initial,final}_io_state macros with their bodies.
|
||
|
|
f3d7165a3a |
Carve io.primitives_{read,write}.m out of io.m.
library/io.m:
library/io.primitives_read.m:
library/io.primitives_write.m:
As above. The two new private submodules contain the implementations
(helper predicates) of the operations that respectively read and write
values of primitive types.
library/MODULES_UNDOC:
library/library.m:
List the new submodules as undocumented.
|
||
|
|
80e1a47397 |
Carve io.stream_db.m out of io.m.
library/io.m:
library/io.stream_db.m:
Move the data types describing the stream database, and the
predicates and functions managing and accessing it, to the new
submodule io.stream_db.m. Move the declarations and definitions
of the global variables holding the dabase accordingly.
library/MODULES_UNDOC:
library/library.m:
List the new module as an undocumented new module.
browser/browse.m:
browser/browser_info.m:
library/stream.string_writer.m:
Get stream information from the new module.
|
||
|
|
c2df9af6a8 |
Document and announce the system RNG module.
library/random.system_rng.m:
Document what sources of randomness are used by the C backends.
library/MODULES_DOC:
library/MODULES_UNDOC:
Include random.system_rng module in the library documentation.
NEWS:
Announce the random.system_rng module.
|
||
|
|
65566350b5 |
Add the system random number generator interface.
This is work-in-progress, currently only the C# and Java backends
are supported. Support for the C backends will be added separately.
library/random.system_rng.m:
A new submodule containing the system RNG.
library/random.m:
library/library.m:
Include the new submodule.
library/MODULES_UNDOC:
Do not generate documentation for the new submodule.
|
||
|
|
c28a79a382 |
Delete Erlang-specific standard library modules.
library/MODULES_UNDOC:
library/Mercury.options:
library/construct.m:
library/deconstruct.m:
library/erlang_builtin.m:
library/erlang_rtti_implementation.m:
library/library.m:
library/type_desc.m:
Delete erlang_builtin and erlang_rtti_implementation modules.
|
||
|
|
57856d36fc |
Include the uint64 and int64 modules in the library documentation.
library/MODULES_DOC:
library/MODULES_UNDOC:
As above.
|
||
|
|
f519e26173 |
Add builtin 64-bit integer types -- Part 1.
Add the new builtin types: int64 and uint64.
Support for these new types will need to be bootstrapped over several changes.
This is the first such change and does the following:
- Extends the compiler to recognise 'int64' and 'uint64' as builtin types.
- Extends the set of builtin arithmetic, bitwise and relational operators
to cover the new types.
- Adds the new internal option '--unboxed-int64s' to the compiler; this will be
used to control whether 64-bit integer types are boxed or not.
- Extends all of the code generators to handle the new types.
- Extends the runtimes to support the new types.
- Adds new modules to the standard library intend to contain basic operations
on the new types. (These are currently empty and not documented.)
There are bunch of limitations marks with "XXX INT64"; these will be lifted in
part 2 of this change. Also, 64-bit integer types are currently always boxed,
again this limitation will be lifted in later changes.
compiler/options.m:
Add the new option --unboxed-int64s.
compiler/prog_type.m:
compiler/prog_data.m:
compiler/builtin_lib_types.m:
Recognise int64 and uint64 as builtin types.
compiler/builtin_ops.m:
Add builtin operations for the new types.
compiler/hlds_data.m:
Add new tag types for the new types.
compiler/ctgc.selector.m:
compiler/dead_proc_elim.m:
compiler/export.m:
compiler/foreign.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/hlds_code_util.m:
compiler/hlds_dependency_graph.m:
compiler/hlds_out_pred.m:
compiler/hlds_out_util.m:
compiler/implementation_defined_literals.m:
compiler/inst_check.m:
compiler/mercury_to_mercury.m:
compiler/mode_util.m:
compiler/module_qual.qualify_items.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/parse_tree_to_term.m:
compiler/parse_type_name.m:
compiler/polymorphism.m:
compiler/prog_out.m:
compiler/prog_util.m:
compiler/rbmm.execution_path.m:
compiler/rtti.m:
compiler/table_gen.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/unify_gen.m:
compiler/unify_proc.m:
compiler/unused_imports.m:
compiler/xml_documentation.m:
Conform to the above changes to the parse tree and HLDS.
compiler/c_util.m:
Support writing out constants of the new types.
compiler/llds.m:
Add a representation for constants of the new types to the LLDS.
compiler/stack_layout.m:
Add a new field to the stack layout params that records whether
64-bit integers are boxed or not.
compiler/call_gen.:m
compiler/code_info.m:
compiler/disj_gen.m:
compiler/dupproc.m:
compiler/exprn_aux.m:
compiler/global_data.m:
compiler/jumpopt.m:
compiler/llds_out_data.m:
compiler/llds_out_instr.m:
compiler/lookup_switch.m:
compiler/mercury_compile_llds_back_end.m:
compiler/prog_rep.m:
compiler/prog_rep_tables.m:
compiler/var_locn.m b/compiler/var_locn.m:
Support the new types in the LLDS code generator.
compiler/mlds.m:
Support constants of the new types in the MLDS.
compiler/ml_call_gen.m:
compiler/ml_code_util.m:
compiler/ml_global_data.m:
compiler/ml_rename_classes.m:
compiler/ml_top_gen.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
compiler/mlds_to_target_util.m:
compiler/rtti_to_mlds.m:
Conform to the above changes to the MLDS.
compiler/mlds_to_c.m:
compiler/mlds_to_cs.m:
compiler/mlds_to_java.m:
Generate the appropriate target code for constants of the new types
and operations involving them.
compiler/bytecode.m:
compiler/bytecode_gen.m:
Handle the new types in the bytecode generator; we just abort if we
encounter them for now.
compiler/elds.m:
compiler/elds_to_erlang.m:
compiler/erl_call_gen.m:
compiler/erl_code_util.m:
compiler/erl_unify_gen.m:
Handle the new types in the Erlang code generator.
library/private_builtin.m:
Add placeholders for the builtin unify and compare operations for
the new types. Since the bootstrapping compiler will not recognise
the new types we give them polymorphic arguments. These can be
replaced after this change has bootstrapped.
Update the Java list of TypeCtorRep constants here.
library/int64.m:
library/uint64.m:
New modules that will eventually contain builtin operations on the new
types.
library/library.m:
library/MODULES_UNDOC:
Do not include the above modules in the library documentation for now.
library/construct.m:
library/erlang_rtti_implementation.m:
library/rtti_implementation.m:
library/table_statistics.m:
deep_profiler/program_representation_utils.m:
mdbcomp/program_representation.m:
Handle the new types.
configure.ac:
runtime/mercury_conf.h.in:
Define the macro MR_BOXED_INT64S. For now it is always defined, support for
unboxed 64-bit integers will be enabled in a later change.
runtime/mercury_dotnet.cs.in:
java/runtime/TypeCtorRep.java:
runtime/mercury_type_info.h:
Update the list of type_ctor reps.
runtime/mercury.h:
runtime/mercury_int.[ch]:
Add macros for int64 / uint64 -> MR_Word conversion, boxing and
unboxing.
Add functions for hashing 64-bit integer types suitable for use
with the tabling mechanism.
runtime/mercury_tabling.[ch]:
Add additional HashTableSlot structs for 64-bit integer types.
Omit the '%' character from the conversion specifiers we pass via
the 'key_format' argument to the macros that generate the table lookup
function. This is so we can use the C99 exact size integer conversion
specifiers (e.g. PRIu64 etc.) directly here.
runtime/mercury_hash_lookup_or_add_body.h:
Add the '%' character that was omitted above to the call to debug_key_msg.
runtime/mercury_memory.h:
Add new builtin allocation sites for boxed 64-bit integer types.
runtime/mercury_builtin_types.[ch]:
runtime/mercury_builitn_types_proc_layouts.h:
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_ml_expand_body.h:
runtime/mercury_table_type_body.h:
runtime/mercury_tabling_macros.h:
runtime/mercury_tabling_preds.h:
runtime/mercury_term_size.c:
runtime/mercury_unify_compare_body.h:
Add the new builtin types and handle them throughout the runtime.
runtime/Mmakefile:
Add mercury_int.c to the list of .c files.
doc/reference_manual.texi:
Add the new types to the list of reserved type names.
Add the mapping from the new types to their target language types.
These are commented out for now.
|
||
|
|
df8a5a5273 |
Enable library documentation for fixed size integers.
library/MODULES_DOC:
library/MODULES_UNDOC:
As above.
|
||
|
|
8a240ba3f0 |
Add builtin 8, 16 and 32 bit integer types -- Part 1.
Add the new builtin types: int8, uint8, int16, uint16, int32 and uint32.
Support for these new types will need to be bootstrapped over several changes.
This is the first such change and does the following:
- Extends the compiler to recognise 'int8', 'uint8', 'int16', 'uint16', 'int32'
and 'uint32' as builtin types.
- Extends the set of builtin arithmetic, bitwise and relational operators to
cover the new types.
- Extends all of the code generators to handle new types. There currently lots
of limitations and placeholders marked by 'XXX FIXED SIZE INT'. These will
be lifted in later changes.
- Extends the runtimes to support the new types.
- Adds new modules to the standard library intended to hold the basic
operations on the new types. (These are currently empty and not documented.)
This change does not introduce the two 64-bit types, 'int64' and 'uint64'.
Their implementation is more complicated and is best left to a separate change.
compiler/prog_type.m:
compiler/prog_data.m:
compiler/builtin_lib_types.m:
Recognise int8, uint8, int16, uint16, int32 and uint32 as builtin types.
Add new type, int_type/0,that enumerates all the possible integer types.
Extend the cons_id/0 type to cover the new types.
compiler/builtin_ops.m:
Parameterize the integer operations in the unary_op/0 and binary_op/0
types by the new int_type/0 type.
Add builtin operations for all the new types.
compiler/hlds_data.m:
Add new tag types for the new types.
compiler/hlds_pred.m:
Parameterize integers in the table_trie_step/0 type.
compiler/ctgc.selector.m:
compiler/dead_proc_elim.m:
compiler/export.m:
compiler/foreign.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/hlds_code_util.m:
compiler/hlds_dependency_graph.m:
compiler/hlds_out_pred.m:
compiler/hlds_out_util.m:
compiler/implementation_defined_literals.m:
compiler/inst_check.m:
compiler/mercury_to_mercury.m:
compiler/mode_util.m:
compiler/module_qual.qualify_items.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/parse_tree_out_info.m:
compiler/parse_tree_to_term.m:
compiler/parse_type_name.m:
compiler/polymorphism.m:
compiler/prog_out.m:
compiler/prog_rep.m:
compiler/prog_rep_tables.m:
compiler/prog_util.m:
compiler/rbmm.exection_path.m:
compiler/rtti.m:
compiler/rtti_to_mlds.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/type_constraints.m:
compiler/type_ctor_info.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/unify_gen.m:
compiler/unify_proc.m:
compiler/unused_imports.m:
compiler/xml_documentation.m:
Conform to the above changes to the parse tree and HLDS.
compiler/c_util.m:
Support generating the builtin operations for the new types.
doc/reference_manual.texi:
Add the new types to the list of reserved type names.
Add the mapping from the new types to their target language types.
These are commented out for now.
compiler/llds.m:
Replace the lt_integer/0 and lt_unsigned functors of the llds_type/0,
with a single lt_int/1 functor that is parameterized by the int_type/0
type.
Add a representations for constants of the new types to the LLDS.
compiler/call_gen.m:
compiler/dupproc.m:
compiler/exprn_aux.m:
compiler/global_data.m:
compiler/jumpopt.m:
compiler/llds_out_data.m:
compiler/llds_out_global.m:
compiler/llds_out_instr.m:
compiler/lookup_switch.m:
compiler/middle_rec.m:
compiler/peephole.m:
compiler/pragma_c_gen.m:
compiler/stack_layout.m:
compiler/string_switch.m:
compiler/switch_gen.m:
compiler/tag_switch.m:
compiler/trace_gen.m:
compiler/transform_llds.m:
Support the new types in the LLDS code generator.
compiler/mlds.m:
Support constants of the new types in the MLDS.
compiler/ml_accurate_gc.m:
compiler/ml_call_gen.m:
compiler/ml_code_util.m:
compiler/ml_disj_gen.m:
compiler/ml_foreign_proc_gen.m:
compiler/ml_global_data.m:
compiler/ml_lookup_switch.m:
compiler/ml_simplify_switch.m:
compiler/ml_string_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
compiler/mlds_to_target_util.m:
Conform to the above changes to the MLDS.
compiler/mlds_to_c.m:
compiler/mlds_to_cs.m:
compiler/mlds_to_java.m:
Generate the appropriate target code for constants of the new
types and operations involving them.
compiler/bytecode.m:
compiler/bytecode_gen.m:
Handle the new types in the bytecode generator; we just abort if we
encounter them for now.
compiler/elds.m:
compiler/elds_to_erlang.m:
compiler/erl_call_gen.m:
compiler/erl_code_util.m:
compiler/erl_rtti.m:
compiler/erl_unify_gen.m:
Handle the new types in the Erlang code generator.
library/private_builtin.m:
Add placeholders for the builtin unify and compare operations for
the new types. Since the bootstrapping compiler will not recognise
the new types we give the polymorphic arguments. These can be
replaced after this change has bootstrapped.
Update the Java list of TypeCtorRep constants.
library/int8.m:
library/int16.m:
library/int32.m:
library/uint8.m:
library/uint16.m:
library/uint32.m:
New modules that will eventually contain builtin operations
on the new types.
library/library.m:
library/MODULES_UNDOC:
Do not include the above modules in the library documentation
for now.
library/construct.m:
library/erlang_rtti_implementation.m:
library/rtti_implementation.m:
deep_profiler/program_representation_utils.m:
mdbcomp/program_representation.m:
Handle the new types.
runtime/mercury_dotnet.cs.in:
java/runtime/TypeCtorRep.java:
runtime/mercury_type_info.h:
Update the list of TypeCtorReps.
configure.ac:
runtime/mercury_conf.h.in:
Check for the header stdint.h.
runtime/mercury_std.h:
Include stdint.h; abort if that header is no present.
runtime/mercury_builtin_types.[ch]:
runtime/mercury_builtin_types_proc_layouts.h:
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_ml_expand_body.h
runtime/mercury_table_type_body.h:
runtime/mercury_tabling_macros.h:
runtime/mercury_tabling_preds.h:
runtime/mercury_term_size.c:
runtime/mercury_unify_compare_body.h:
Add the new builtin types and handle them throughout the runtime.
|
||
|
|
a9208b47a8 |
Specialize ALL calls to string.format and io.format.
Previously, we specialized calls to string.format and io.format only if
the format string specified no flags, widths, precisions or non-default
bases for any conversion. We now specialize calls to those predicates
regardless of the format string. To make this possible, we now have two
copies of the code to parse format strings.
library/string.parse_runtime.m:
This new module, carved out out library/string.format.m, contains
one of those copies. As the name suggests, this copy is used by
the runtime system.
compiler/parse_string_format.m:
This new module contains the other copy. As its location suggests,
this copy is used by the compiler. The separate copy is necessary
because the compiler's parsing needs are different from the runtime's.
The main reason for the separation is that the compiler needs to be
able to handle cases where widths and predicates are given by manifest
constants, as well as when they are given by the values of variables
at runtime (when the format string contains conversion specifiers
such as "%*d"). Having the runtime handle this extra complexity
would have inevitably increased the runtime's format string interpretation
overhead, which is undesirable.
The other reason is that compiler can afford to postprocess the result
of the parsing in order to avoid having to concatenate two or more
constant strings at runtime.
library/string.parse_util.m:
Types and predicates that are common to the library and compiler copies
of the format string parsing code.
compiler/format_call.m:
We used to check whether format strings match the supplied list
of values to be printed by invoking string.format on dummy inputs
of the supplied types, and seeing whether you got an exception.
We now call parse_string_format.m instead. Not only does this
avoid shenanigans with exceptions (which the deep profiler cannot
yet handle), but it also allows us to specialize all calls
to string.format and io.format. We therefore do so.
We used to specialize calls to io.format by creating a single string
to be printed (using the machinery needed to specialize calls to
string.format), and then printing that. This did unnecessary memory
allocations to hold the intermediate strings. We now simply print
each component one after the other, which avoids this overhead.
library/string.format.m:
Add versions of the predicates that print chars, strings, ints and floats
that are specialized to each possible situation about whether the caller
specifies a width and/or a precision. This means that format_call.m
doesn't have to generate code that allocates cells on the heap.
Remove the code that was moved to new submodules of string.m.
compiler/simplify_proc.m:
List the predicates in string.format.m that the compiler
may generate calls to in the list of such predicates that we maintain
to prevent dead_pred_elim from deleting them before format_call.m
gets a chance to do its work.
compiler/module_imports.m:
If the code of the module calls a predicate named "format" that
may refer to string.format or io.format, then implicitly import
the modules that contain the types and predicates that the code
generated by format_call.m will refer to. Note that since this
module_imports.m works on Mercury code that has not been module
qualified yet, we have to use a conservative approximation.
Reorganize the way we discover what library modules we have to
implicitly import. Instead of a separate boolean for each piece
of functionality that needs an implicit import, put them together
into a structure. Due to Peter's work on argument packing some
years back, this is now more efficient as well as more convenient
that passing around a bunch of booleans. Also switch to passing
around the structure as an accumulator, instead of having to do
bool.ors all over the place.
Since the code for computing the list of modules to be implicitly
imported can sometimes add a library module to the list twice,
sort that list and remove any duplicates.
To make this possible, remove the version of the main predicate
that appends the implicitly imported module names to a list of
module names passed by our caller, since we don't want to sort
THAT list of module names.
Give the remaining version of that predicate that does this
a name that better matches the names of related predicates.
compiler/modules.m:
Conform to the change in module_imports.m. Mark some suspicious code
with XXXs.
Remove some redundant comments.
compiler/options.m:
doc/user_guide.texi:
Add a new option that tells format_call.m what it should do
when it finds more than one problem with a format string: whether
it should print a message only for the first problem, or for all
the problems. (The default is the latter.)
library/MODULES_DOC:
A list of the all the Mercury source files in the library that
should be included in the user guide.
library/MODULES_UNDOC:
A list of the all the Mercury source files in the library that
should NOT be included in the user guide.
library/library.m:
Include the new publicly visible new submodule of string.m,
(string.parse_util). And both string.parse_util and string.parse_runtime
(which is NOT visible from outside string.m) to the list of modules
in the Mercury standard library.
Update the rules for where new library modules should be documented
to account for non-publically-visible submodules, which we haven't had
before. Document the need to include new modules in either MODULES_DOC
or MODULES_UNDOC.
mdbcomp/builtin_modules.m:
Provide convenient access for format_call.m to the names of the
submodules of string.m that it needs access to.
library/Mmakefile:
Add a new target, check_doc_undoc, which checks whether any source files
are missing from MODULES_DOC or MODULES_UNDOC.
doc/Mmakefile:
Read the list of modules to be documented from MODULES_DOC. This replaces
old code that tried to list all the undocumented modules, but missed one:
it referred to erlang_conf.m instead of erlang_builtin.m.
When creating the library documentation, filter out any lines that
contain the string NOTE_TO_IMPLEMENTORS. We now use this mechanism
to include reminders to implementors in what would otherwise be a
publically visible part of string.m.
tools/bootcheck:
Copy MODULES_DOC and MODULES_UNDOC to the stage 2 and 3 library
directories, since the check_doc_undoc target, which is invoked by
"make all" in the library directory, needs them.
compiler/hlds_out_module.m:
When dumping out the table of types, dump out discriminated union types
in a style that follows our recommended coding style.
|