Commit Graph

494 Commits

Author SHA1 Message Date
Peter Wang
ea45fb3083 Make the Java backend use generics in the output.
Branches: main, 10.04

Make the Java backend use generics in the output.  We do not use generics
everywhere, only where it interfaces with hand written code:

- in classes generated for Mercury types
- in the signatures of foreign_exported procedures
- in the variables which interface with foreign_proc code

Make `--java-export-ref-out' be the default.  Both changes will require users
to update their code so we might as well make them together.


compiler/mlds.m:
compiler/ml_proc_gen.m:
compiler/ml_type_gen.m:
        Record type parameters for classes generated for Mercury types.

        Record universally quantified type variables for exported procedures.

        Assume `--java-export-ref-out'.

compiler/mlds_to_java.m:
        Output type variables in the appropriate places in the Java output.

compiler/ml_code_util.m:
        Add functions to return the MLDS types for jmercury.runtime.MercuryType
        and MercuryEnum.

compiler/ml_elim_nested.m:
compiler/ml_global_data.m:
compiler/ml_optimize.m:
compiler/ml_tailcall.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
        Conform to previous changes.

compiler/hlds_pred.m:
        Change a wrong use of a type synonym.

compiler/options.m:
        Make `--java-export-ref-out' into a synonym for
        compiler_sufficiently_recent.  This may be used to test if the compiler
        supports that behaviour, and for compatibility with existing makefiles.

        Add an option for testing if the compiler generates Java code with
        generics.

doc/reference_manual.texi:
        Update manual to mention use of generics.

        Remove description of `--no-java-export-ref-out'.

library/exception.m:
library/io.m:
library/list.m:
library/rtti_implementation.m:
library/string.m:
library/type_desc.m:
        Update code to comply with use of generics and `--java-export-ref-out'.

tests/hard_coded/exceptions/Mmakefile:
        Allow `java' grade testing in this directory.
2010-04-15 02:56:02 +00:00
Ian MacLarty
8d365b4056 Change string.base_string_to_int so that it doesn't fail if the base is 10 and
the integer is int.min_int.  The previous behaviour seems unintuitive and means
we can't use the literal -2147483648 in Mercury programs on 32 bit machines,
even though that number can be represented in 32 bits.

library/string.m:
    If the integer to be parsed is negative, then use a negative accumulator,
    so that if the number is int.min_int it doesn't cause an overflow.

tests/general/base_string_to_int_test.exp:
tests/general/base_string_to_int_test.m:
    Test it.
2010-01-14 06:55:53 +00:00
Zoltan Somogyi
4ebe3d0d7e Stop storing globals in the I/O state, and divide mercury_compile.m
Estimated hours taken: 60
Branches: main

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

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

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

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

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

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

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

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

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

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

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

	Give the fields of the globals structure a distinguishing prefix.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	Rename some predicates to avoid ambiguity.

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

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

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

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

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

	Conform to the changes above.

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

	Conform to the changes above.

	Convert these modules to our current programming style.

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

	Conform to the changes above.

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

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

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

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

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

compiler/add_pragma.m:
	Add notes.

compiler/string.m:
NEWS:
	Add a det version of remove_suffix, for use by new code above.
2009-10-14 05:28:53 +00:00
Peter Wang
ac3d1c6027 Expose correct types to Java foreign code, e.g. a variable with a non-foreign
Branches: main

Expose correct types to Java foreign code, e.g. a variable with a non-foreign
type like `list(T)' is now visible to Java foreign code with the type
`list.List_1' instead of `java.lang.Object'.

A complication is that foreign code for mutables is generated in the compiler
frontend, which doesn't know about the types used by the backends.  For Java,
mutable variables had the generic type `Object' (except for primitives types)
but as we now generate foreign procs with the correct variable types, the code
for accessing a mutable would be type incorrect, e.g.

        X = mutable_var;  /* list.List_1 = Object */

Here we handle generated mutable predicates as a special case, using `Object'
for the global variable and argument types and generating typecasts as before.
The correct fix would be to move mutable code generation into the backends.


compiler/make_hlds_passes.m:
        Make Java mutable variables always have the type `java.lang.Object'.

        Mark Java mutable predicates with `may_not_duplicate' attributes, as
        the generated code doesn't contain class-qualifiers for the mutable
        variable, so copying that code into other Java files won't work.

compiler/mlds.m:
        Add a new target code component `target_code_type(Type)' which is a
        placeholder for a type, to be substituted by the backend when target
        code is being printed out.

compiler/ml_code_gen.m:
        Generate Java foreign procs using `target_code_type' to declare local
        variables, except for mutable predicates as described above.

        Rename a predicate shared for C and Java.

        Assign dummy type variables the value `null' in the Java backend
        instead of `0'.

compiler/foreign.m:
        Add a comment for `exported_type_to_string'.

compiler/mlds_to_java.m:
        Handle the addition of `target_code_type'.

        Output `java.lang.Output' for builtin dummy types.  We were
        inconsistent as to whether builtin dummy types should be represented by
        `int' or `Object'.

        Output line number context in another spot.

compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_il.m:
        Conform to the addition of `target_code_type'.

library/exception.m:
library/io.m:
library/list.m:
library/rtti_implementation.m:
library/string.m:
library/type_desc.m:
        Delete casts in some Java foreign code which are no longer required.
2009-09-02 05:48:02 +00:00
Zoltan Somogyi
f507f7d514 Fix some ambiguities.
Estimated hours taken: 0.1
Branches: main

library/string.m:
        Fix some ambiguities.
2009-09-02 00:41:40 +00:00
Zoltan Somogyi
680ca11021 Provide C implementations of some predicates that test all characters
Estimated hours taken: 1
Branches: main

library/string.m:
	Provide C implementations of some predicates that test all characters
	in a string. The Mercury implementation uses higher order calls
	to cross-module predicates, and thus has substantially higher overhead
	than a direct C implementation.

	This matters because some of these predicates are heavily used
	by the name mangling algorithm, and thus can be responsible for
	a significant chunk of the compiler's runtime.
2009-08-30 23:13:54 +00:00
Peter Wang
fe4c25c16f Some changes to the Java implementation of the standard library.
Branches: main

Some changes to the Java implementation of the standard library.

library/array.m:
        Use System.arraycopy and java.util.Arrays.fill and avoid using
        reflection to work with arrays in some places.

library/dir.m:
        Implement dir.current_directory.

library/rtti_implementation.m:
        Fix typos where expanded type_infos were not being used.

library/string.m:
        Make string.c_pointer_to_string handle null pointers.

tests/hard_coded/sub-modules/Mmakefile:
        Enable testing of java grade in this directory.

tests/hard_coded/sub-modules/non_word_mutable.m:
tests/hard_coded/sub-modules/sm_exp_bug.m:
        Add Java foreign code.
2009-08-14 06:11:46 +00:00
Peter Wang
83e4aca25e Rename exported enumeration values without ML_ prefixes.
Branches: main

library/bool.m:
library/builtin.m:
        Rename exported enumeration values without ML_ prefixes.

library/list.m:
        Add `empty_list', `cons', `is_empty', `det_head' and `det_tail' methods
        for manipulating lists from Java foreign code.

        Add wrapper class `ListIterator<E>' that allows iteration over
        Mercury lists using Java for-each syntax (undocumented for now).

doc/reference_manual.texi:
doc/user_guide.texi:
        Update documentation pertaining to Java foreign language interface.

library/bitmap.m:
library/rtti_implementation.m:
library/string.m:
        Conform to renamings.

        Use for-each syntax in some places.
2009-08-12 01:56:26 +00:00
Peter Wang
ae1caac4e3 Add Java foreign_proc implementation of string.float_to_string.
Branches: main

library/string.m:
        Add Java foreign_proc implementation of string.float_to_string.
2009-07-10 05:00:08 +00:00
Peter Wang
2cdc6845ad Add Java versions of string functions.
Branches: main

library/string.m:
        Add Java versions of string functions.

        Fix integer overflow in slow version of substring/4, as can happen when
        someone passes max_int for Count.

tests/hard_coded/Mmakefile:
tests/hard_coded/contains_char_2.exp:
tests/hard_coded/contains_char_2.m:
tests/hard_coded/string_append_iii.exp:
tests/hard_coded/string_append_iii.m:
tests/hard_coded/string_append_ioi.exp:
tests/hard_coded/string_append_ioi.m:
tests/hard_coded/string_append_ooi.exp:
tests/hard_coded/string_append_ooi.m:
tests/hard_coded/string_set_char.exp:
tests/hard_coded/string_set_char.m:
tests/hard_coded/string_split_2.exp:
tests/hard_coded/string_split_2.m:
tests/hard_coded/string_sub_string_search.exp:
tests/hard_coded/string_sub_string_search.m:
tests/hard_coded/string_substring.exp:
tests/hard_coded/string_substring.m:
        Add some test cases.
2009-06-29 06:21:49 +00:00
Peter Wang
1b648d0ac2 Put all Mercury-generated Java classes into the package `jmercury' and
Branches: main

Put all Mercury-generated Java classes into the package `jmercury' and
runtime classes into `jmercury.runtime'.  The Mercury module hierarchy is
not reflected in the package name.  We name sub-module classes using
their fully-qualified module names with `__' between components, e.g.
`bit_buffer.read' produces `class bit_buffer__read'.

As all generated Java code is in the same package we don't need to package
qualify identifiers, and we don't need the hack to avoid clashing package
and class names.  It also makes it easier to write Java foreign code because
generated Java class names are easier to predict from Mercury module names.

The package names are not `mercury' and `mercury.runtime' because on
case-insensitive file systems we may end up with a `mercury' directory
that could be confused with the `Mercury' directory.


compiler/java_names.m:
        Delete code related to mangling package names.

        Remove the extra `mercury' prefix added to standard library module
        names, as it is redundant with `jmercury'.

        Change runtime package name.

compiler/mlds_to_java.m:
        Make generated code follow the new packaging scheme.

        Don't automatically import all runtime classes.  It doesn't seem
        necessary.

        Update for new packaging scheme.

compiler/file_names.m:
        Fix Java file paths for the new packaging scheme.

compiler/module_cmds.m:
compiler/rtti.m:
library/array.m:
library/backjump.m:
library/benchmarking.m:
library/bitmap.m:
library/builtin.m:
library/exception.m:
library/io.m:
library/library.m:
library/mutvar.m:
library/private_builtin.m:
library/rtti_implementation.m:
library/store.m:
library/string.m:
library/time.m:
library/type_desc.m:
java/runtime/*.java:
        Rename package names.

        Delete unnecessary package qualification.

compiler/mlds.m:
        Add some XXXs to be fixed later.

library/Mmakefile:
        Update for new packaging scheme.

        Let mmake --use-mmc-make work in this directory.
2009-06-17 07:48:16 +00:00
Peter Wang
79e0b9eb1d Work on RTTI implementation for Java.
Branches: main

Work on RTTI implementation for Java.

library/construct.m:
library/type_desc.m:
        Properly distinguish between type_infos and type_descs.  These are not
        the same in Java grades (for now, at least).
        Use special purpose conversion functions instead of unsafe_casts.

        Don't call erlang_rtti_implementation.m predicates in other grades.

library/rtti_implementation.m:
        Properly distinguish between type_infos and type_descs.
        Use special purpose conversion functions instead of unsafe_casts.

        Implement some stub predicates for Java.

        Fix get_arg_type_info which assumed the usual low-level type_info
        representation.  In Java we have a TypeInfo_Struct class with a
        distinct array for type_info arguments so all the indices to access
        arguments were wrong.

        Try to be consistent about how variables are numbered (start from 1).

        Rename some predicates to make them less ambiguous.

        Don't use field access to call functions as it is confusing.

        Update unsafe_get_enum_value for an earlier change where I renamed the
        `value' field in enumeration classes to `MR_value'.

library/stream.string_writer.m:
library/string.m:
        Convert type_infos to type_descs properly.

library/erlang_rtti_implementation.m:
        Unrelated: use private_builtin.unsafe_type_cast instead of a
        foreign_proc.

library/io.m:
        Unrelated: add Java implementation of io.stdout_stream_2/1.

java/runtime/TypeInfo_Struct.java:
        Add a copy method.
2009-06-10 03:31:57 +00:00
Peter Wang
08eec03b2e Add Java implementation of gmtime_to_timestamp_2.
compiler/timestamp.m:
        Add Java implementation of gmtime_to_timestamp_2.

library/io.m:
library/time.m:
        Make Java implementation of io.file_modification_time return the
        correct type.

library/string.m:
        Make generic version of string.to_char_list avoid bounds checks
        per character.

        Add Java implementations of string.semidet_from_char_list,
        string.append_list.
2009-06-03 07:07:41 +00:00
Peter Wang
c7f4dca5c1 Support generating Java archives (.jar) with `mmc --make'.
Branches: main

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

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

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

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

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

compiler/write_deps_file.m:
        Conform to renaming.

library/string.m:
NEWS:
        Add string.remove_prefix_if_present/2.
2009-05-11 05:24:08 +00:00
Peter Wang
dd53891e9f Assorted library fixes and stubs for the Java backend.
Branches: main

java/runtime/ForeignEnumFunctorDesc.java:
java/runtime/TypeCtorInfo_Struct.java:
java/runtime/TypeFunctors.java:
library/backjump.m:
library/builtin.m:
library/io.m:
library/math.m:
library/mutvar.m:
library/par_builtin.m:
library/private_builtin.m:
library/region_builtin.m:
library/rtti_implementation.m:
library/store.m:
library/string.m:
library/thread.semaphore.m:
library/time.m:
library/type_desc.m:
        Assorted library fixes and stubs for the Java backend.
2009-04-22 03:03:17 +00:00
Ralph Becket
51b8f762e8 Only check for overflow when converting strings to ints when the base is 10.
Estimated hours taken: 0.5
Branches: main

Only check for overflow when converting strings to ints when the base is 10.
Other number bases are assumed to denote bit patterns and no overflow test
is employed.

NEWS:
	Mention the change.

library/string.m:
	Amend accumulate_int to perform an overflow check on base 10 numbers.

tests/general/Mmakefile:
tests/general/test_string_to_int_overflow.m:
tests/general/test_string_to_int_overflow.exp:
	Add a test case.
2009-02-03 06:44:01 +00:00
Julien Fischer
8e98471e5b Back out Ralph's recent change to the string module since it breaks boostrapping
on 32-bit machines; the lexer is no longer able to recognise some hex literals
used in the compiler.

NEWS:
library/string.m:
	Back out the change.
2009-01-29 06:55:12 +00:00
Ralph Becket
4692b728e3 Add parsing_utils.m to the library, providing support for recursive descent
parsers.

NEWS:
	Report the addition of parsing_utils.m to the library.

library/library.m:
	Include parsing_utils.m.

library/parsing_utils.m:
	Added.

library/string.m:
	Make string.to_int fail on overflow.  Amend comments to reflect this.

tests/general/Mmakefile:
tests/general/test_parsing_utils.exp:
tests/general/test_parsing_utils.m:
	Test case for parsing_utils.m.
2009-01-28 07:19:42 +00:00
Zoltan Somogyi
1487b63417 Speed up hashing by eliminating a check that cannot fail.
Estimated hours taken: 0.1
Branches: main

library/string.m:
	Speed up hashing by eliminating a check that cannot fail.
2008-09-03 04:39:16 +00:00
Peter Wang
2736b1a184 Add `may_not_duplicate' attributes on some "C" foreign_procs to prevent
Estimated hours taken: 0.5
Branches: main

library/construct.m:
library/dir.m:
library/io.m:
library/store.m:
library/string.m:
library/term_size_prof_builtin.m:
library/thread.m:
library/version_array.m:
	Add `may_not_duplicate' attributes on some "C" foreign_procs to prevent
	them being written to `.opt' files.

	It works around a problem with opt-exporting `thread.spawn' (which
	happens to be not worth opt-exporting).
2008-08-29 06:13:09 +00:00
Zoltan Somogyi
c230af079f Fix comment formatting.
Estimated hours taken: 0.1
Branches: main

library/string.m:
	Fix comment formatting.
2008-08-13 03:34:01 +00:00
Peter Wang
79ac85e03e Replace `string.remove_suffix' by a version that doesn't create
Estimated hours taken: 0.1
Branches: main

library/string.m:
	Replace `string.remove_suffix' by a version that doesn't create
	intermediate character lists.
2008-06-26 03:08:19 +00:00
Peter Wang
45fa707fe8 Add `no_sharing' annotations to some C foreign_procs.
Branches: main

library/exception.m:
library/io.m:
library/string.m:
library/type_desc.m:
	Add `no_sharing' annotations to some C foreign_procs.
2008-04-28 05:13:06 +00:00
Julien Fischer
8fbc2ee720 Document what the string comparison operation for each backend is.
Estimated hours taken: 0.2
Branches: main

Document what the string comparison operation for each backend is.
(XXX Should the Erlang backend be documented here - it doesn't seem to be?)

library/string.m:
  	Document how string comparison is implemented.
2008-03-04 03:11:51 +00:00
Julien Fischer
7213d883d9 Add some new predicates to the string module.
Estimated hours taken: 1
Branches: main

Add some new predicates to the string module.

library/string:
	Add a new predicate string.is_all_digits/1 that tests whether a string
	consists entirely of decimal digits.

	Export the predicate string.all_match/2.

	Add string.remove_prefix/3 which is a synonym for the string.append(in, uo, in)
	except that it has a more meaningful name and the argument ordering is more
	convenient for use with higher-order code.

profiler/demangle.m:
	Do not define remove_prefix/3 here; use the one from the standard library
	instead.

NEWS:
	Announce the new additions.

tests/general/string_test.m:
tests/general/string_test_2.m:
tests/general/string_test_2.exp:
	Add a test for remove_prefix/3.

	Update the syntax used in these files, e.g. replace DCGs with
	state variables etc.

tests/general/.cvsignore:
	Ignore generated files.
2008-02-11 14:55:33 +00:00
Zoltan Somogyi
8adf26081d Factor out duplicate tests in an effort to make the code more
Estimated hours taken: 1
Branches: main

library/string.m:
	Factor out duplicate tests in an effort to make the code more
	understandable (though it should be faster too).
2007-12-30 05:24:57 +00:00
Zoltan Somogyi
672f77c4ec Add a new compiler option. --inform-ite-instead-of-switch.
Estimated hours taken: 20
Branches: main

Add a new compiler option. --inform-ite-instead-of-switch. If this is enabled,
the compiler will generate informational messages about if-then-elses that
it thinks should be converted to switches for the sake of program reliability.

Act on the output generated by this option.

compiler/simplify.m:
	Implement the new option.

	Fix an old bug that could cause us to generate warnings about code
	that was OK in one duplicated copy but not in another (where a switch
	arm's code is duplicated due to the case being selected for more than
	one cons_id).

compiler/options.m:
	Add the new option.

	Add a way to test for the bug fix in simplify.

doc/user_guide.texi:
	Document the new option.

NEWS:
	Mention the new option.

library/*.m:
mdbcomp/*.m:
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
	Convert if-then-elses to switches at most of the sites suggested by the
	new option. At the remaining sites, switching to switches would have
	nontrivial downsides. This typically happens with the switched-on type
	has many functors, and we treat one or two specially (e.g. cons/2 in
	the cons_id type).

	Perform misc cleanups in the vicinity of the if-then-else to switch
	conversions.

	In a few cases, improve the error messages generated.

compiler/accumulator.m:
compiler/hlds_goal.m:
	(Rename and) move insts for particular kinds of goal from
	accumulator.m to hlds_goal.m, to allow them to be used in other
	modules. Using these insts allowed us to eliminate some if-then-elses
	entirely.

compiler/exprn_aux.m:
	Instead of fixing some if-then-elses, delete the predicates containing
	them, since they aren't used, and (as pointed out by the new option)
	would need considerable other fixing if they were ever needed again.

compiler/lp_rational.m:
	Add prefixes to the names of the function symbols on some types,
	since without those prefixes, it was hard to figure out what type
	the switch corresponding to an old if-then-else was switching on.

tests/invalid/reserve_tag.err_exp:
	Expect a new, improved error message.
2007-11-23 07:36:01 +00:00
Zoltan Somogyi
9469c4ec96 Fix formatting.
Estimated hours taken: 0.1
Branches: main

library/string.m:
library/tree234.m:
	Fix formatting.
2007-09-10 04:45:07 +00:00
Peter Wang
19405c1dd8 Set float.max to a sensible value for Erlang.
Estimated hours taken: 0.2
Branches: main

library/float.m:
	Set float.max to a sensible value for Erlang.

library/string.m:
	Bump up the precision of the Erlang implementation of
	string.lowlevel_float_to_string to match the maximum on the C
	backends.
2007-08-31 03:05:05 +00:00
Peter Wang
75512d9cb9 Change the representation of Mercury strings in the Erlang backend to use
Estimated hours taken: 30
Branches: main

Change the representation of Mercury strings in the Erlang backend to use
binaries instead of the conventional list of integers representation.
Binaries require much less space and provide O(1) indexing (among other
things), although some operations are faster with lists of integers.  I did
not notice much speed difference with the Mercury compiler either way, though.

The HiPE compiler seems not to treat binaries in static data structures
efficiently as it does for lists, so we stick to the list representation
for strings in RTTI data to avoid a big performance drop.

compiler/elds.m:
	Modify the ELDS to allow two string representations, elds_binary and
	elds_list_of_ints.

compiler/elds_to_erlang.m:
compiler/erl_call_gen.m:
compiler/erl_code_gen.m:
compiler/erl_code_util.m:
compiler/erl_rtti.m:
compiler/erl_unify_gen.m:
	Conform to the change in the ELDS.

library/dir.m:
library/erlang_builtin.m:
library/erlang_rtti_implementation.m:
library/io.m:
library/library.m:
library/string.m:
	Update foreign code to account for the new string representation.

	Make the io module use `raw' streams, i.e. don't spawn a separate
	process to handle the file as we have our own process as well.

	Also set read_ahead and delayed_write options to enable caching and
	reduce the number of system calls.

util/mkinit_erl.c:
	Add a comment about the string representation in _init.erl files
	for initialising environment variable values.

doc/reference_manual.texi:
	Update the documentation.
2007-08-17 02:08:40 +00:00
Ralph Becket
67ec243a51 Define pretty_printer formatters for some common standard library types.
Estimated hours taken: 4
Branches: main

Define pretty_printer formatters for some common standard library types.
Include these formatters in the default pretty_printer formatter_map.
Add a useful function to the pretty_printer interface.

library/array.m:
library/char.m:
library/float.m:
library/int.m:
library/list.m:
library/string.m:
library/tree234.m:
	Add <type>_to_doc functions.

library/pretty_printer.m:
	Added function format_arg/1.
	Initialise the default formatter_map to use the <type>_to_doc
	functions.

tests/hard_coded/Mmakefile:
tests/hard_coded/test_pretty_printer_defaults.exp:
tests/hard_coded/test_pretty_printer_defaults.m:
	Test case.
2007-08-14 04:21:09 +00:00
Peter Wang
f02a336799 Fix the Erlang-specific implementation of sub_string_search_start/4,
Estimated hours taken: 0.2
Branches: main

library/string.m:
	Fix the Erlang-specific implementation of sub_string_search_start/4,
	which was wrong for empty string patterns.
2007-07-09 04:02:18 +00:00
Peter Wang
dc199e5e4e Override list.reverse with a more efficient version for Erlang.
Branches: main

library/list.m:
	Override list.reverse with a more efficient version for Erlang.

library/string.m:
	Add efficient implementations of semidet_from_char_list/2,
	sub_string_search_start/4 and substring/4 for Erlang.
2007-07-06 08:04:28 +00:00
Peter Wang
abb1e7d578 Fix an off-by-one bug in string.split_at_separator.
Estimated hours taken: 1
Branches: main

library/string.m:
	Fix an off-by-one bug in string.split_at_separator.  The index in the
	initial call to split_at_separator2 was one past the end of the
	string, which worked in the C backends because strings are NUL
	terminated.

	Rename split_at_separator2 to split_at_separator_2 and make it more
	readable.

tests/hard_coded/string_split.exp:
tests/hard_coded/string_split.m:
	Add a couple of cases which seem more likely to fail with an incorrect
	implementation.
2007-06-06 02:09:45 +00:00
Peter Ross
e3f8bbf9aa Implement the TypeCtorInfo RTTI so that generic compare
Estimated hours taken: 16
Branches: main

Implement the TypeCtorInfo RTTI so that generic compare
and unify work via rtti_implementation.

However after discussion with zs, this current design of
RTTI has to be adapted to become more erlang specific, due
to the different data representation on the erlang backend.
The current code will serve as a template for this new design
though, which is why it is being checked in.

Add various erlang library implementations which are
needed to run useful programs when testing the erlang backend.

compiler/elds.m:
	Add a type_info_id.

compiler/elds_to_erlang.m:
	We now generate type_ctor_info's so call them.

compiler/erl_rtti.m:
	After discussions with zs, type_info and pseudo_type_infos
	should never occur on the erlang backend as they are needed
	for gc and the debugger so throw an exception for them.
	Add an implementation of creating a static type_info, but which
	isn't used in case we need it again later.
	Create type_ctor_info with all the fields except the
	TypeFunctors, the TypeLayout and the FunctorNumberMap

compiler/special_pred.m:
	Make sure we generate RTTI for the builtin types.

library/builtin.m:
library/char.m:
library/exception.m:
library/float.m:
library/int.m:
library/io.m:
library/lexer.m:
library/math.m:
library/mutvar.m:
library/ops.m:
library/par_builtin.m:
library/private_builtin.m:
library/rtti_implementation.m:
library/solutions.m:
library/store.m:
library/string.m:
library/table_builtin.m:
library/thread.semaphore.m:
library/time.m:
library/type_desc.m:
	Erlang implementations of std library functions.
2007-05-30 08:16:09 +00:00
Ian MacLarty
a2f2b40851 Move the string builder stream from extras to the standard library.
Estimated hours taken: 0.5
Branches: main.

Move the string builder stream from extras to the standard library.

library/string.builder.m:
	Move stream_util.string_builder to string.builder.

	Use builtin.copy instead of unsafe_promise_unique in the implementation
	of put/4 for the string builder stream.

library/string.m:
	Include string.builder.

tests/hard_coded/Mmakefile:
tests/hard_coded/string_builder_test.exp:
tests/hard_coded/string_builder_test.m:
	Add a test case.

extras/Mmakefile:
extras/README:
extras/stream/Mmakefile:
extras/stream/README:
extras/stream/impure.m:
extras/stream/lowlevel.m:
extras/stream/stream_old.m:
extras/stream/stream_util.m:
extras/stream/stream_util.string_builder.m:
extras/stream/tests/Makefile:
extras/stream/tests/stream_util_test.exp:
extras/stream/tests/stream_util_test.m:
	Completely remove the streams modules from extras.  These modules
	are all deprecated now.
2007-04-20 05:18:40 +00:00
Peter Wang
b23c0dc171 Introduce a standard way to read lines and files efficiently but generically
Estimated hours taken: 2
Branches: main

Introduce a standard way to read lines and files efficiently but generically
using stream.get/4.

library/string.m:
	Add the types string.line and string.text_file.

library/io.m:
	Make io.input_stream instances of stream.reader with units
	string.line and string.text_file.

compiler/error_util.m:
	Rename error_util.line to error_line to disambiguate it from
	string.line.

extras/net/tcp.m:
	Remove the tcp.line type and use string.line instead.

NEWS:
	Announce the change.
2007-04-20 00:48:50 +00:00
Simon Taylor
5647714667 Make all functions which create strings from characters throw an exception
Estimated hours taken: 15
Branches: main

Make all functions which create strings from characters throw an exception
or fail if the list of characters contains a null character.

This removes a potential source of security vulnerabilities where one
part of the program performs checks against the whole of a string passed
in by an attacker (processing the string as a list of characters or using
`unsafe_index' to look past the null character), but then passes the string
to another part of the program or an operating system call that only sees
up to the first null character.  Even if Mercury stored the length with
the string, allowing the creation of strings containing nulls would be a
bad idea because it would be too easy to pass a string to foreign code
without checking.

For examples see:
<http://insecure.org/news/P55-07.txt>
<http://www.securiteam.com/securitynews/5WP0B1FKKQ.html>
<http://www.securityfocus.com/archive/1/445788>
<http://www.securityfocus.com/archive/82/368750>
<http://secunia.com/advisories/16420/>

NEWS:
	Document the change.

library/string.m:
	Throw an exception if null characters are found in
	string.from_char_list and string.from_rev_char_list.

	Add string.from_char_list_semidet and string.from_rev_char_list_semidet
	which fail rather throwing an exception.  This doesn't match the
	normal naming convention, but string.from_{,rev_}char_list are widely
	used, so changing their determinism would be a bit too disruptive.

	Don't allocate an unnecessary extra word for each string created by
	from_char_list and from_rev_char_list.

	Explain that to_upper and to_lower only work on un-accented
	Latin letters.

library/lexer.m:
	Check for invalid characters when reading Mercury strings and
	quoted names.

	Improve error messages by skipping to the end of any string
	or quoted name containing an error.  Previously we just stopped
	processing at the error leaving an unmatched quote.

library/io.m:
	Make io.read_line_as_string and io.read_file_as_string return
	an error code if the input file contains a null character.

	Fix an XXX: '\0\' is not recognised as a character constant,
	but char.det_from_int can be used to make a null character.

library/char.m:
	Explain the workaround for '\0\' not being accepted as a char
	constant.

	Explain that to_upper and to_lower only work on un-accented
	Latin letters.

compiler/layout.m:
compiler/layout_out.m:
compiler/c_util.m:
compiler/stack_layout.m:
compiler/llds.m:
compiler/mlds.m:
compiler/ll_backend.*.m:
compiler/ml_backend.*.m:
	Don't pass around strings containing null characters (the string
	tables for the debugger).  This doesn't cause any problems now,
	but won't work with the accurate garbage collector.  Use lists
	of strings instead, and add the null characters when writing the
	strings out.

tests/hard_coded/null_char.{m,exp}:
	Change an existing test case to test that creation of a string
	containing a null throws an exception.

tests/hard_coded/null_char.exp2:
	Deleted because alternative output is no longer needed.

tests/invalid/Mmakefile:
tests/invalid/null_char.m:
tests/invalid/null_char.err_exp:
	Test error messages for construction of strings containing null
	characters by the lexer.

tests/invalid/unicode{1,2}.err_exp:
	Update the expected output after the change to the handling of
	invalid quoted names and strings.
2007-03-18 23:35:04 +00:00
Ralph Becket
427c7518ec Improve the readability of float output from the debugger and io.print etc.
Estimated hours taken: 4
Branches: main

Improve the readability of float output from the debugger and io.print etc.
by pruning redundant trailing zeroes.

NEWS:
	Mention the change.

library/string.m:
runtime/mercury_float.c:
	Make string.float_to_string trim redundant trailing zeroes.
	The behaviour of string.format etc. is unchanged.

tests/debugger/ambiguity.exp:
tests/debugger/field_names.exp:
tests/debugger/higher_order.exp:
tests/debugger/print_table.exp:
tests/hard_coded/common_type_cast.exp:
tests/hard_coded/constant_prop_1.exp:
tests/hard_coded/construct_test.exp:
tests/hard_coded/deconstruct_arg.exp:
tests/hard_coded/deep_copy.exp:
tests/hard_coded/deep_copy_exist.exp:
tests/hard_coded/dense_lookup_switch2.exp:
tests/hard_coded/dense_lookup_switch_non.exp:
tests/hard_coded/existential_float.exp:
tests/hard_coded/expand.exp:
tests/hard_coded/final_excp.exp:
tests/hard_coded/float_field.exp:
tests/hard_coded/float_gv.exp:
tests/hard_coded/float_reg.exp:
tests/hard_coded/float_rounding_bug.exp:
tests/hard_coded/init_excp.exp:
tests/hard_coded/mutable_excp.exp:
tests/hard_coded/pragma_import.exp:
tests/hard_coded/prince_frameopt.exp:
tests/hard_coded/string_string.exp:
tests/hard_coded/unused_float_box_test.exp:
tests/hard_coded/write.exp:
tests/hard_coded/write_binary.exp:
tests/hard_coded/write_reg1.exp:
tests/hard_coded/write_xml.exp:
tests/hard_coded/sub-modules/non_word_mutable.exp:
tests/hard_coded/typeclasses/arbitrary_constraint_class.exp:
tests/hard_coded/typeclasses/arbitrary_constraint_pred_1.exp:
tests/hard_coded/typeclasses/arbitrary_constraint_pred_2.exp:
tests/hard_coded/typeclasses/existential_rtti.exp:
tests/hard_coded/typeclasses/func_default_mode_bug.exp:
tests/hard_coded/typeclasses/mode_decl_order_bug.exp:
tests/hard_coded/typeclasses/module_test.exp:
tests/hard_coded/typeclasses/typeclass_exist_method.exp:
tests/invalid/error_in_list.err_exp:
tests/invalid/errors2.err_exp:
tests/invalid/purity/purity_type_error.err_exp:
tests/mmc_make/complex_test.exp:
tests/recompilation/add_type_re.exp.1:
tests/recompilation/type_spec_rename_var_r.exp.1:
tests/recompilation/type_spec_rename_var_r.exp.2:
tests/recompilation/type_spec_unname_var_r.exp.1:
tests/recompilation/type_spec_unname_var_r.exp.2:
	Updated expected test case output.
2007-02-15 00:41:59 +00:00
Ondrej Bojar
1ab474865c A few handy functions for splitting a string added.
Estimated hours taken: 3
Branches: main

A few handy functions for splitting a string added.

library/string.m:
    Added remove_suffix_if_present, split_at_separator, split_at_char,
    split_at_string

tests/hard_coded/string_split.m:
    A simple test of split_at_* functions.

tests/hard_coded/string_split.exp:
    Expected results of the tests of split_at_* functions.

tests/hard_coded/string_various.m:
    Created. Added testcase for remove_suffix_if_present.

tests/hard_coded/string_various.exp:
    Created. Added results for remove_suffix_if_present.

NEWS:
    Added a comment that the functions have been added.
2007-02-02 05:39:58 +00:00
Julien Fischer
7290c64875 This is the second part of Jon Morgan's change that adds support for
Estimated hours taken: 6
Branches: main

This is the second part of Jon Morgan's change that adds support for
IL foreign exports.  This part adds foreign_export declarations for IL
to the standard library.

configure.in:
	Require the installed compiler to support pragma foreign_export
	for IL.

library/*.m:
	Add a foreign_export("IL") for every existing foreign_export("C").

	Convert a couple of `pragma export' statements to `pragma
	foreign_export'.
2007-01-18 07:33:05 +00:00
Zoltan Somogyi
7b7dabb89a Extend this optimization to handle temporaries being both defined in
Estimated hours taken: 12
Branches: main

compiler/use_local_vars.m:
	Extend this optimization to handle temporaries being both defined in
	and used by foreign_proc_code instructions. This should eliminate
	unnecessary accesses to the MR_fake_reg array, and thus speed up
	programs that use foreign code a lot, including typeclass- and
	tabling-intensive programs, since those features are implemented using
	inline foreign code. I/O intensive should also benefit, but not much,
	since the cost of the I/O itself overwhelms the cost of the
	MR_fake_reg accesses.

	Group together the LLDS instructions that are handled similarly.
	Factor out some common code.

compiler/opt_util.m:
	Allow for the fact that foreign_proc_codes can now refer to
	temporaries.

compiler/opt_debug.m:
	Print more useful information about foreign_proc_code components.

compiler/prog_data.m:
	Rename the types and function symbols of the recently added
	foreign_proc attributes to avoid clashing with the keywords
	representing them in source code.

	Add a new foreign_proc attribute, proc_may_duplicate that governs
	whether the body of foreign code is allowed to be duplicated.

compiler/table_gen.m:
	Include does_not_affect_liveness among the annotations for the
	foreign_proc calls generated by this module. Some of these procedures
	affect memory beyond their arguments, but that memory is in tables,
	not in unlisted registers.

	Allow some of the smaller code fragments generated by this module
	to be duplicated.

compiler/inlining.m:
	Respect the may_not_duplicate foreign_proc attribute.

compiler/pragma_c_gen.m:
	Transmit any annotations about liveness from the HLDS to the LLDS,
	since without does_not_affect_liveness annotations use_local_vars.m
	cannot optimize foreign_proc_codes.

	Transmit any annotations about may_duplicate from the HLDS to the LLDS,
	since with them jumpopt can do a better job.

compiler/llds.m:
	Use the new foreign_proc attribute instead of a boolean to represent
	whether a foreign code fragment may be duplicated.

compiler/simplify.m:
	Generate an error message if a may_duplicate or may_not_duplicate
	attribute on a foreign_proc conflicts with a no_inline or inline pragma
	(respectively) on the predicate it belongs to.

compiler/hlds_pred.m:
	Fix some comment rot.

compiler/jumpopt.m:
compiler/livemap.m:
compiler/proc_gen.m:
compiler/trace_gen.m:
	Conform to the changes above.

doc/reference_manual.texi:
	Document the new foreign_proc attribute.

library/array.m:
library/builtin.m:
library/char.m:
library/dir.m:
library/float.m:
library/int.m:
library/io.m:
library/lexer.m:
library/math.m:
library/private_builtin.m:
library/string.m:
library/version_array.m:
	Add does_not_affect_liveness annotations to the C foreign_procs that
	deserve them.

configure.in:
	Require the installed compiler to support does_not_affect_liveness.

tests/invalid/test_may_duplicate.{m,err_exp}:
	Add a new test case to test the error checking code in simplify.m.

tests/invalid/Mmakefile:
	Enable the new test case.
2007-01-15 02:24:04 +00:00
Zoltan Somogyi
f1bf8a2fed Minor improvements in mslice/mdice output formats.
Estimated hours taken: 3
Branches: main

Minor improvements in mslice/mdice output formats.

library/string.m:
	Add format_table_max, a version of format_table that allows the caller
	to specify a maximum width for each column. If a column exceeds that
	maximum, format_table_max adds a newline, and starts the line again
	at the correct position for the next column.

mdbcomp/slice_and_dice.m:
	Use format_table_max instead of format_table to generate the tables
	containing slice data.

slice/mslice.m:
slice/mdice.m:
	Add some options that callers can use to specify the max widths of
	the predicate name, path/port and filename/linenumber fields. Pass
	the values of these options on to slice_and_dice.m.

	Make the default sort string print the most frequently executed events,
	not the ones from the predicates that come first in the lexicographic
	sequence.

slice/Mmakefile:
	Fix some missing dependencies.

doc/user_guide.texi:
	Document the new options.
2006-12-07 05:10:38 +00:00
Julien Fischer
9cd94b5c72 Various minor cleanups and syntax updates for the standard library.
Estimated hours taken: 1
Branches: main

Various minor cleanups and syntax updates for the standard library.
There are no changes to any algorithms.

library/injection.m:
library/set.m:
library/sparse_bitset.m:
	Use promise_equivalent_clauses where appropriate.

library/set_ordlist.m:
library/set_unordlist.m:
	Convert these module to 4-space indentation:
		Convert these module to 4-space indentation

library/*.m:
	Convert some if-then-elses into switches.

	Remove unnecessary module qualification - this is related
	mainly to the breakup of std_util and the fact that on
	the 0.13 branche we had two versions of the all-solutions
	predicates.

	Various other style cleanups.

vim/syntax/mercury.vim:
	Highlight promise_equivalent_clauses appropriately.
2006-10-23 00:33:04 +00:00
Zoltan Somogyi
f9cac21e3e Get rid of a bunch more ambiguities by renaming predicates, mostly
Estimated hours taken: 8
Branches: main

Get rid of a bunch more ambiguities by renaming predicates, mostly
in polymorphism.m, {abstract,build,ordering}_mode_constraints.m, prog_type.m,
and opt_debug.m in the compiler directory and term_io.m, term.m, parser.m,
and string.m in the library.

In some cases, when the library and the compiler defined the same predicate
with the same code, delete the compiler's copy and give it access to the
library's definition by exporting the relevant predicate (in the undocumented
part of the library module's interface).

NEWS:
	Mention that the names of some library functions have changed.

library/*.m:
compiler/*.m:
mdbcomp/*.m:
browser/*.m:
	Make the changes mentioned above, and conform to them.

test/general/string_test.m:
test/hard_coded/string_strip.m:
test/hard_coded/string_strip.exp:
	Conform to the above changes.
2006-09-20 09:42:28 +00:00
Julien Fischer
553fb3f7d9 Use pragma foreign_export' in preference to pragma export' throughout
Estimated hours taken: 1
Branches: main

Use `pragma foreign_export' in preference to `pragma export' throughout
the Mercury distribution.

Convert more of the extras distribution to four-space indentation and
other minor cleanups.

browser/*.m:
library/*.m:
samples/*:
extras/*:
	As above.
2006-08-31 11:09:54 +00:00
Mark Brown
ca5e5db854 Add string.from_c_pointer as a synonym for string.c_pointer_to_string,
Estimated hours taken: 0.1
Branches: main

library/string.m:
	Add string.from_c_pointer as a synonym for string.c_pointer_to_string,
	for consistency with other similar predicates/functions.

NEWS:
	Mention the new predicates/functions.
2006-08-22 03:56:00 +00:00
Mark Brown
0731932d14 Construct strings representing c_pointer addresses.
Estimated hours taken: 2
Branches: main

runtime/mercury_ml_expand_body.h:
	Construct strings representing c_pointer addresses.  Used in the
	implementation of functor and deconstruct.

library/deconstruct.m:
	Document the behaviour of functor and deconstruct for c_pointers.

library/string.m:
	Export c_pointer_to_string for getting a string representation
	of the pointer address.

library/io.m:
library/rtti_implementation.m:
	Use c_pointer_to_string/1 to print c_pointers.

	Update comments.

library/pprint.m:
	Undo Ralph's earlier change, since it is no longer required.

tests/debugger/Mmakefile:
tests/debugger/declarative/Mmakefile:
	Canonicalize the output of test cases in which c_pointers appear.

tests:
	Update the expected output of test cases.
2006-08-22 02:33:54 +00:00
Julien Fischer
98894f79cc Add the equivalences text_input_stream == input_stream and
Estimated hours taken: 0.2
Branches: main, release

library/io.m:
	Add the equivalences text_input_stream == input_stream and
	text_output_stream == output_stream.  The text_ versions are less
	ambiguous then the existing ones.

	s/IO/I\/O/ (previously we used a mixture of both).

	Reformat some documentation.

library/pqueue.m:
	Fix a spot where the conversion to 4-space indentation had gone awry.

library/dir.m:
	Reposition a section heading.

library/string.m:
browser/declarative_tree.m:
compiler/java_util.m:
compiler/mercury_compile.m:
compiler/typecheck.m:
	Fix some typos.
2006-07-28 04:54:04 +00:00
Julien Fischer
e0f5ac47db Make it easier for vi to jump past the initial comments
Estimated hours taken: 0.1
Branches: main

library/*.m:
	Make it easier for vi to jump past the initial comments
	at the head of a module.
2006-04-19 05:18:00 +00:00