59 Commits

Author SHA1 Message Date
Julien Fischer
0b92543c5e Fix more library documentation errors.
library/*.m:
   As above.
2026-01-23 19:53:58 +11:00
Zoltan Somogyi
3f72528869 Update module stability levels. 2025-08-11 22:32:52 +02:00
Julien Fischer
db37031c3f Update copyright notices in standard library.
library/*.m:
     As above.
2024-08-08 00:04:42 +10:00
Zoltan Somogyi
daba30c48e Stop using higher order insts as modes ...
... in a third batch of library modules.
2023-07-26 22:26:51 +02:00
Zoltan Somogyi
66873a528a Fix the handling of status in add_pragma.m.
compiler/add_pragma.m:
    The status checks in this module used to check for only one
    of the four possible combinations of <is pragma exported, is the
    pred the pragma is for expored>, even though we may want to generate
    errors or warnings in three of those combinations. Fix this.

    If an ambiguous pragma applies to more than one predicate, handle
    the status checks of each separately.

    When adding fact table pragmas to the HLDS, replace several lines
    of code that reuse an existing largish predicate with the single line
    of code from that predicate that we actually need.

    Stop representing the statuses of pragmas using the pred_status type,
    since the item_mercury_status that all items come with is adequate
    for all our needs, and is impossible to confuse with the status
    of the pred_info they refer to.

library/exception.m:
library/require.m:
    Move termination pragmas for exported predicates and functions
    from the implementation section to the interface section. This
    avoids a warning that we now generate in such situations.

tests/term/exception_analysis_test.trans_opt_exp:
tests/term/exception_analysis_test2.trans_opt_exp:
    Expected improved termination analysis results now that we export
    termination pragmas that used to be kept private.

tests/warnings/foreign_term_invalid.{m,exp}:
    Avoid warnings about keeping decl pragmas about exported predicates
    private by moving them into the interface.

    Fix the formatting of the top-of-module comment.

    Expect updated line numbers.

tests/warnings/pragma_term_conflict.{m,exp}:
    Don't avoid a warning about keeping decl pragmas about exported predicates
    private. Instead, document it as an additional purpose of this test.

    Expect both the extra warning and updated line numbers.

tests/invalid/pragma_export.{m,err_exp}:
    A new test case for testing the error message for inappropriately
    exported pragmas.

tests/invalid/Mmakefile:
    Enable the new test case.
2022-09-24 19:12:18 +10:00
Julien Fischer
e7d28ff90f Update copyright notices in stdlib.
library/*.m:
    As above.
2022-06-07 21:51:03 +10:00
Zoltan Somogyi
0d7c8a7654 Specify pred or func for all pragmas.
*/*.m:
    As above.

configure.ac:
    Require the installed compiler to support this capability.
2021-06-16 15:23:58 +10:00
Zoltan Somogyi
a12692a0de Replace /* */ comments with // in the library.
Keep the old style comments where they do not go to the end of the line,
or where it is important that the comment line not have a // on it.
2018-06-21 18:55:08 +02:00
Mark Brown
d465fa53cb Update the COPYING.LIB file and references to it.
Discussion of these changes can be found on the Mercury developers
mailing list archives from June 2018.

COPYING.LIB:
    Add a special linking exception to the LGPL.

*:
    Update references to COPYING.LIB.

    Clean up some minor errors that have accumulated in copyright
    messages.
2018-06-09 17:43:12 +10:00
Zoltan Somogyi
95ff02b1bf Add options to check the ordering of module contents.
One option, --warn-non-contiguous-decls, generates warnings if the
mode declarations of a predicate or function aren't in a contiguous block
immediately following the pred or func declaration. Since this is a rare
kind of "style error", this option is enabled by default.

Two options, --warn-inconsistent-pred-order-clauses and
--warn-inconsistent-pred-order-foreign-procs, warn about inconsistencies
between (a) the order in which predicates (and functions) are declared,
and (b) the order in which they are defined. The two options differ in
their scope. The latter applies to all predicates and functions defined
in the module, while the former applies only to those whose definitions
include Mercury clauses.

Since an exported predicate or function may need nonexported auxiliary
predicates and/or functions, imposing a single order the declarations and
definitions of *all* the predicates and functions in a module is not a good
idea. Instead, both options divide the predicates and functions defined
in a module two groups, the exported and the nonexported, and expect
a consistent order only within each group.

The result is output that looks like this:

    time.m:021: Warning: the order of the declarations and definitions of the
    time.m:021:   exported predicates is inconsistent, as shown by this diff:
    time.m:021:
    time.m:021:   --- declaration order
    time.m:021:   +++ definition order
    time.m:021:   @@ -1,7 +1,7 @@
    time.m:021:    predicate `clock'/3
    time.m:021:   -predicate `time'/3
    time.m:021:    predicate `times'/4
    time.m:021:    function `clk_tck'/0
    time.m:021:   +predicate `time'/3
    time.m:021:    function `difftime'/2
    time.m:021:    predicate `localtime'/4
    time.m:021:    function `localtime'/1

compiler/options.m:
doc/user_guide.texi:
    Add the new options.

compiler/style_checks.m:
    A new module that generates the new warnings if warranted.

compiler/check_hlds.m:
compiler/notes/compiler_design.html:
    Include and document the new module.

compiler/mercury_compile_front_end.m:
    Invoke the new module if any of the three new options is set.

compiler/hlds_pred.m:
    Record the item number of every predicate, function, and mode declaration
    in the module being compiled. We need this for information for the
    new warnings.

compiler/hlds_module.m:
    Record the context of the module declaration. We use this context
    for warnings about inconsistent order, since there isn't a better one.

compiler/hlds_clauses.m:
    Add a mechanism to retrieve the item numbers of a set of clauses
    even if they are contiguous.

    Document some old data types.

compiler/error_util.m:
    Add a new phase for style checks.

compiler/accumulator.m:
compiler/add_class.m:
compiler/add_mutable_aux_preds.m:
compiler/add_pragma_tabling.m:
compiler/add_pred.m:
compiler/add_solver.m:
compiler/add_special_pred.m:
compiler/check_typeclass.m:
compiler/clause_to_proc.m:
compiler/from_ground_term_util.m:
compiler/lambda.m:
compiler/make_hlds.m:
compiler/make_hlds_passes.m:
compiler/mercury_compile.m:
compiler/par_loop_control.m:
compiler/polymorphism.m:
compiler/stm_expand.m:
compiler/table_gen.m:
compiler/unify_proc.m:
    Conform the changes to the HLDS above.

compiler/typecheck_errors.m:
    Fix style of error messages.

library/array2d.m:
library/assoc_list.m:
library/benchmarking.m:
library/bit_buffer.write.m:
library/bool.m:
library/builtin.m:
library/construct.m:
library/cord.m:
library/counter.m:
library/float.m:
library/injection.m:
library/lazy.m:
library/lexer.m:
library/ops.m:
library/private_builtin.m:
library/profiling_builtin.m:
library/prolog.m:
library/queue.m:
library/rational.m:
library/require.m:
library/stack.m:
library/std_util.m:
library/store.m:
library/thread.semaphore.m:
library/tree234.m:
library/univ.m:
library/version_store.m:
    Move declarations or definitions around to avoid some of the warnings
    that we can now generate. (There are many more left.)

    Make some minor style improvements in the process.

tests/warnings/inconsistent_pred_order.{m,exp}:
tests/warnings/non_contiguous_decls.{m,exp}:
    New test cases to test the new options. They are both copies of
    tests/benchmarks/queens.m, with intentionally-screwed-up style.

tests/warnings/Mmakefile:
    Enable the new test cases.

tests/warnings/Mercury.options:
    Specify the options being tested for the new test cases.

tests/benchmarks/queens.m:
    Bring the style of this module up to date (before copying it).

tests/invalid/mode_decl_in_wrong_section.err_exp:
    Expect the warnings we now generate.
2016-10-15 17:26:32 +11:00
Zoltan Somogyi
f0ffbbc13c Convert (C->T;E) to (if C then T else E). 2015-12-01 05:35:29 +11:00
Zoltan Somogyi
7f9791aa26 Standardize divider line lengths in the library.
library/*.m:
    As above.

tool/stdlines:
    A new shell script to do the job.
2014-11-23 22:05:34 +11:00
Zoltan Somogyi
9f61bf03d3 Clean up library/string.m.
library/string.m:
    Avoid unnecessary use of higher order code in the implementation of
    string.format. Avoid the unnecessary insertion of empty manifest strings
    between actual format conversions.

    Represent the optional width and precision in string.format as integers,
    not strings, since the strings take up more space and require more time
    to create and to process.

    Simplify the code implementing word_wrap.

    Give some variables better names.

    Clarify some documentation.

    Call unexpected instead of error in cases where the source of a problem
    can only be a software bug inside string.m, and not bad input supplied
    from outside of it.

    Don't mention the arity of a predicate that is the source of an exception,
    since the predicate's identity is unambiguous even without the arity,
    and since other exceptions also don't mention arities.

library/require.m:
    Add two-argument versions of error/1 and func_error/1, to allow
    the name of the predicate and the error message to be passed separately,
    possible with the first being specified as $pred. string.m had several
    places where these were being appended on the fly.

library/char.m:
    Clarify some code.

NEWS:
    Mention the additions to require.m.
2014-11-10 11:29:02 +11:00
Zoltan Somogyi
414cc0da9d Delete dead code.
Estimated hours taken: 0.1
Branches: main

library/require.m:
	Delete dead code.
2011-04-08 01:50:50 +00:00
Zoltan Somogyi
d0bc6f93d8 Fix some things I found while chasing Mantis bug 103.
Estimated hours taken: 0.5
Branches: main

Fix some things I found while chasing Mantis bug 103.

compiler/handle_options.m:
	Add a dump alias to make debugging lco easier.

compiler/instmap.m:
	Add a utility predicate for use by (a now-unneeded version of) lco.m.

compiler/unify_gen.m:
	Minor cleanups.

library/require.m:
	Add four-argument versions of expect and expect_not, to allow
	all uses of this_file to be replaced by $module, $pred.

NEWS:
	Document the new predicates in require.m, as well as expect_not/3,
	which I added earlier.
2011-03-08 07:45:30 +00:00
Zoltan Somogyi
b3fa535100 A rewrite of the state variable transformation from the ground up.
Estimated hours taken: 60
Branches: main

A rewrite of the state variable transformation from the ground up.

The initial aim was to avoid situations (encountered in the g12 project)
in which the old state variable transformation generated code that
did not satisfy the mode checker, due to unnecessary unifications.
The new system tries hard to minimize the number of unifications added to the
program. It does this by relying extensively on the idea that in a branched
structure such as an disjunction, if two branches both update the same state
variable, and the variables representing the last state of the state variable
in the two branches are (say) X and Y, and we pick X to represent the current
state after the disjunction, then we don't have to put the assignment X := Y
into the second branch; instead, we can RENAME Y to X in that branch.
To avoid renaming a goal several times (for itself, for its parent, for its
grandparent etc), we delay all renamings until the end, when we do it all
in one traversal.

The old state var system was opaque and hard to understand, partly because
its basic operations did different things in different contexts. The new system
is a much more direct expression of the intuitive meaning of state variables;
it keeps track of their state much as the programmer writing the original code
would. It should therefore be significantly easier to understand and to modify
in the future.

The new system can also detect more kinds of errors in the use of state
variables. For example it can discover that some branches of a disjunction or
if-then-else set the initial value of a state variable and some do not.
This is ok if the non-setting-branch cannot succeed; if it can, then it is
a bug. We therefore generate messages about such branches, but print them
only if mode analysis finds a bug in the procedure, since in that case,
the lack of initialization may be the cause of the bug.

doc/reference_manual.texi:
	Replaced an old example that didn't know what it was talking about,
	and thoroughly confused the issue of what is legal use of state
	variables and what is not.

compiler/state_var.m:
	Rewrite this module along the lines mentioned above.

compiler/options.m:
	Add two new options. One, warn-state-var-shadowing, controls whether
	we generate warnings for one state var shadowing another (which
	G12 has lots of). The other, --allow-defn-for-builtins, is for
	developers only; it is needed to bootstrap changes that add new
	builtins. I needed this for a form of the state variable transformation
	that used calls to a new builtin predicate to copy the values of state
	variables in branches that did not modify them, even though other
	branches did. I ultimately used unifications to do this copying,
	for reasons documented in state_var.m.

compiler/add_clause.m:
compiler/add_pragma.m:
	Respect the new --allow-defn-for-builtins option.
	(Previously, we changed the code that now looks up the value of the
	option.)

doc/user_guide.texi:
	Document the --warn-state-var-shadowing option.

	Fix some old documentation about dump options.

compiler/simplify.m:
	Fix an old oversight: list the predicates in table_builtin.m that may
	have calls introduced to them by table_gen.m.

compiler/superhomogeneous.m:
compiler/field_access.m:
compiler/add_clause.m:
compiler/goal_expr_to_goal.m:
	Together with state_var.m, these modules contain the transformation
	from the parse tree to the HLDS. Since the change to state_var.m
	involves significant changes in its interface (such as separating out
	the persistent and location-dependent aspects of the information needed
	by the state variable transformation), and needing callbacks at
	different points than the old transformation, these modules had to
	change extensively as well to conform.

	goal_expr_to_goal.m is a new module carved out of add_clause.m.
	It deserves a module of its own because its code has a significantly
	different purpose than add_clause.m. The two separate modules each
	have much better cohesion than the old conjoined module did.

	In superhomogeneous.m, replace two predicates that did the same thing
	with one predicate.

compiler/make_hlds.m:
compiler/notes/compiler_design.html.m:
	Mention the new module.

compiler/hlds_goal.m:
	Add a mechanism to do the kind of incremental renaming that the state
	variable transformation needs.

	Add some utility predicates needed by the new code in other modules.

compiler/hlds_clause.m:
compiler/hlds_pred.m:
	Add an extra piece of information to clauses and proc_infos:
	a list of informational messages generated by the state variable
	transformation about some branches of branched goals not giving initial
	values to some state variables, while other branches do.

	The state variable transformation fills in this field in clauses
	where relevant.

compiler/clause_to_proc.m:
	Copy this list of messages from clauses to proc_infos.

compiler/modes.m:
	When generating an error message for a procedure, include this list
	of messages from the state var transformation in the output.

compiler/handle_options.m:
	Add a dump alias for debugging the state var transformation.

compiler/hlds_out_goal.m:
	Add a predicate that is useful in trace messages when debugging
	the compiler.

compiler/hlds_out_pred.m:
	Print goal path and goal id information in clauses as well as
	proc_infos, since the state var transformation now uses goal ids.

compiler/prog_item.m:
	In lists of quantified vars in scope headers, separate out the vars
	introduced as !S from those introduced as !.S and !:S. This makes it
	easier for the state var transformation to handle them.

	Document that we expect lists of quantified variables and state
	variables to contain no duplicates. The state var transformation
	is slightly simpler if we impose this requirement, and quantifying
	a variable twice in the same scope does not make sense, and is
	therefore almost certainly an error.

compiler/prog_io_util.m:
	Generate error messages when a variable or state variable IS
	listed twice in the same quantification list.

	Factor out some code used to generate error messages.

compiler/typecheck.m:
	Conform to the changes above.

	Break a very large predicate into two smaller pieces.

compiler/add_class.m:
compiler/add_pragma.m:
compiler/add_pred.m:
compiler/assertion.m:
compiler/dead_proc_elim.m:
compiler/dependency_graph.m:
compiler/goal_path.m:
compiler/goal_util.m:
compiler/headvar_names.m:
compiler/hhf.m:
compiler/hlds_out_module.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/mercury_to_mercury.m:
compiler/module_imports.m:
compiler/module_qual.m:
compiler/post_typecheck.m:
compiler/prog_io_goal.m:
compiler/prog_util.m:
compiler/purity.m:
compiler/unify_proc.m:
compiler/unused_imports.m:
	Conform to the changes above.

compiler/mode_constraints.m:
compiler/modules.m:
compiler/structure_reuse.analysis.m:
	Avoid the warnings we now generate about one state variable shadowing
	another.

browser/declarative_user.m:
compiler/hlds_out_util.m:
compiler/ordering_mode_constraints.m:
compiler/table_gen.m:
deep_profiler/read_profile.m:
	Improve programming style.

library/require.m:
	Add expect_not, a negated version of expect.

library/varset.m:
	Return lists of new variables in order, not reverse order.

mdbcomp/mdbcomp.goal_path.m:
compiler/prog_mode.m:
	Add a utility predicate.

tests/debugger/tailrec1.exp:
tests/invalid/any_passed_as_ground.err_exp:
tests/invalid/bad_sv_unify_msg.err_exp:
tests/invalid/state_vars_test1.err_exp:
tests/invalid/state_vars_test4.err_exp:
tests/invalid/try_bad_params.err_exp:
tests/invalid/try_detism.err_exp:
tests/invalid/purity/impure_pred_t1_fixed.err_exp:
tests/invalid/purity/impure_pred_t2.err_exp:
	Update the expected outputs of these test cases to account for
	incidental changes in variable numbers and goal paths after this
	change.

tests/general/state_vars_tests.{m,exp}:
	Remove the code that expected the state var transformation to do
	something that was actually AGAINST the reference manual: treating
	the step from the condition to the then part of an if-then-else
	expression (not a goal) as a sequence point.

tests/general/state_vars_trace.m:
	Add a test case that is not enabled yet, since we don't pass it.

tests/hard_coded/bit_buffer_test.m:
	Fix a bug in the test itself: the introduction of a state var twice
	in the same scope.

tests/hard_coded/try_syntax_6.m:
	Avoid a warning about state var shadowing.

tests/hard_coded/if_then_else_expr_state_var.{m,exp}:
	A new test to check the proper handling of state vars in if-then-else
	expressions.

tests/hard_coded/Mmakefile:
	Enable the new test.
2011-03-07 03:59:43 +00:00
Zoltan Somogyi
8a28e40c9b Add the predicates sorry, unexpected and expect to library/error.m.
Estimated hours taken: 2
Branches: main

Add the predicates sorry, unexpected and expect to library/error.m.

compiler/compiler_util.m:
library/error.m:
	Move the predicates sorry, unexpected and expect from compiler_util
	to error.

	Put the predicates in error.m into the same order as their
	declarations.

compiler/*.m:
	Change imports as needed.

compiler/lp.m:
compiler/lp_rational.m:
	Change imports as needed, and some minor cleanups.

deep_profiler/*.m:
	Switch to using the new library predicates, instead of calling error
	directly. Some other minor cleanups.

NEWS:
	Mention the new predicates in the standard library.
2010-12-15 06:30:36 +00:00
Julien Fischer
df7e71aa0f Move the type software_error/0 from the require module into the exception
Estimated hours taken: 0.2
Branches: main

Move the type software_error/0 from the require module into the exception
module.  This breaks the (immediate) cyclic dependency between those two
modules (there may still be indirect ones).

library/require.m:
	Delete the definition of the type software_error/0.

library/exception.m
	Add the definition here.

	Replace calls to error/1 with calls to throw/1.

NEWS:
	Mention this change.
2006-12-21 03:00:48 +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
Julien Fischer
5e92224eec Improve the library reference manual by formatting the beginning of
Estimated hours taken: 0.2
Branches: main, release

library/*.m:
	Improve the library reference manual by formatting the beginning of
	library modules consistently.

library/integer.m:
	Fix some bad indentation.
2006-04-13 06:08:05 +00:00
Julien Fischer
459847a064 Move the univ, maybe, pair and unit types from std_util into their own
Estimated hours taken: 18
Branches: main

Move the univ, maybe, pair and unit types from std_util into their own
modules.  std_util still contains the general purpose higher-order programming
constructs.

library/std_util.m:
	Move univ, maybe, pair and unit (plus any other related types
	and procedures) into their own modules.

library/maybe.m:
	New module.  This contains the maybe and maybe_error types and
	the associated procedures.

library/pair.m:
	New module.  This contains the pair type and associated procedures.

library/unit.m:
	New module. This contains the types unit/0 and unit/1.

library/univ.m:
	New module. This contains the univ type and associated procedures.

library/library.m:
	Add the new modules.

library/private_builtin.m:
	Update the declaration of the type_ctor_info struct for univ.

runtime/mercury.h:
	Update the declaration for the type_ctor_info struct for univ.

runtime/mercury_mcpp.h:
runtime/mercury_hlc_types.h:
	Update the definition of MR_Univ.

runtime/mercury_init.h:
	Fix a comment: ML_type_name is now exported from type_desc.m.

compiler/mlds_to_il.m:
	Update the the name of the module that defines univs (which are
	handled specially by the il code generator.)

library/*.m:
compiler/*.m:
browser/*.m:
mdbcomp/*.m:
profiler/*.m:
deep_profiler/*.m:
	Conform to the above changes.  Import the new modules where they
	are needed; don't import std_util where it isn't needed.

	Fix formatting in lots of modules.  Delete duplicate module
	imports.

tests/*:
	Update the test suite to confrom to the above changes.
2006-03-29 08:09:58 +00:00
Zoltan Somogyi
ef55b420fd Remove from std_util.m the predicates that merely call predicates in
Estimated hours taken: 12
Branches: main

Remove from std_util.m the predicates that merely call predicates in
the type_desc, construct and deconstruct modules, to reduce clutter
in std_util.m.

library/std_util.m:
	Remove those predicates from std_util.m.

library/deconstruct.m:
	Add a type we need that was previously defined in std_util.m.

library/construct.m:
	Delete some module qualifications that have now become unnecessary,

browser/browse.m:
browser/browser_info.m:
browser/declarative_tree.m:
browser/dl.m:
browser/help.m:
browser/sized_pretty.m:
browser/term_rep.m:
compiler/bytecode_gen.m:
compiler/llds_out.m:
compiler/mlds_to_il.m:
compiler/mlds_to_managed.m:
library/assoc_list.m:
library/hash_table.m:
library/io.m:
library/pprint.m:
library/private_builtin.m:
library/prolog.m:
library/require.m:
library/rtti_implementation.m:
library/store.m:
library/term.m:
library/term_to_xml.m:
library/version_hash_table.m:
mdbcomp/program_representation.m:
	Import type_desc.m, construct.m and/or deconstruct.m to provide
	definitions of functions or predicates that up till now were in
	std_util.m. Modify the calls if the called function or predicate
	had a slightly different interface in std_util.m.

	Also, convert term_to_xml.m to four-space indentation, and delete
	unnecessary module qualifications in term.m.

tests/debugger/polymorphic_output.{m,inp,exp,exp2}:
tests/hard_coded/copy_pred_2.m:
tests/hard_coded/deconstruct_arg.exp:
tests/hard_coded/deconstruct_arg.exp2:
tests/hard_coded/deconstruct_arg.m:
tests/hard_coded/elim_special_pred.m:
tests/hard_coded/existential_bound_tvar.m:
tests/hard_coded/expand.m:
tests/hard_coded/foreign_type2.m:
tests/hard_coded/higher_order_type_manip.m:
tests/hard_coded/nullary_ho_func.m:
tests/hard_coded/tuple_test.m:
tests/hard_coded/type_ctor_desc.m:
tests/hard_coded/type_qual.m:
tests/hard_coded/write_xml.m:
tests/hard_coded/sub-modules/class.m:
tests/hard_coded/sub-modules/nested.m:
tests/hard_coded/sub-modules/nested2.m:
tests/hard_coded/sub-modules/nested3.m:
tests/hard_coded/sub-modules/parent.m:
tests/hard_coded/sub-modules/parent2.child.m:
tests/hard_coded/typeclasses/existential_rtti.m:
tests/recompilation/type_qual_re.m.1:
cvs update: Updating tests/submodules
cvs update: Updating tests/tabling
cvs update: Updating tests/term
cvs update: Updating tests/tools
cvs update: Updating tests/trailing
cvs update: Updating tests/typeclasses
cvs update: Updating tests/valid
tests/valid/agc_unbound_typevars.m:
tests/valid/agc_unbound_typevars2.m:
tests/valid/agc_unused_in.m:
	Replace references to the deleted predicates in std_util with
	references to the equivalent predicates in type_desc, construct
	and/or deconstruct. In test cases that already tested both the
	functionality in std_util and in the other modules, simply delete
	the part exercising std_util.
2006-03-22 02:56:44 +00:00
Zoltan Somogyi
b293bd999d Replace __ with . as the module qualifier everywhere.
Estimated hours taken: 1
Branches: main

library/*.m:
	Replace __ with . as the module qualifier everywhere.

tests/hard_coded/test_injection.exp:
	Replace __ with . as the module qualifier in expected exceptions.
2006-03-07 22:23:58 +00:00
Zoltan Somogyi
57b8f436eb Convert to four-space indentation most of the library modules that
Estimated hours taken: 4
Branches: main

library/*.m:
	Convert to four-space indentation most of the library modules that
	weren't already indented that way. Use predmode syntax where possible.
	In some modules, shorten long lines by deleting module name prefixes.
	Fix departures from our coding standards.

	In some modules, simplify code, mostly using field names and/or state
	variables.

	There are no changes in algorithms, except for neg_list in integer.m.
2005-10-17 11:35:22 +00:00
Zoltan Somogyi
88c7539230 Import only one module per line, as we already do in the compiler
Estimated hours taken: 0.3
Branches: main

library/*.m:
	Import only one module per line, as we already do in the compiler
	directory.
2005-06-16 04:08:07 +00:00
Peter Ross
84865227e1 Change report_lookup_error so that it reports which key
Estimated hours taken: 0.25
Branches: main, version-0_12-branch

library/require.m:
	Change report_lookup_error so that it reports which key
	couldn't be found rather than just reporting the functor of
	the key.
2005-02-01 13:51:23 +00:00
Julien Fischer
5651c3d791 Bring the interface of this module into line with
Estimated hours taken: 0.1
Branches: main

library/require.m:
	Bring the interface of this module into line with
	with our current coding standards.
2005-01-14 07:21:09 +00:00
Ian MacLarty
6fba720b49 Add the operation transform_value to map, tree234 and rbtree.
Estimated hours taken: 2
Branches: main

Add the operation transform_value to map, tree234 and rbtree.  This applies a
higher order argument to a value in the map.  Often a value needs to be updated
using its previous value.  Currently this requires two lookups of the key.
With transform_value only one lookup is required.

NEWS
	Mention the new predicate.

library/map.m
library/rbtree.m
library/tree234.m
	Add transform_value.

library/require.m
	Add a version of report_lookup_error that doesn't take a value
	argument, since the value argument is not available in transform_value.

tests/hard_coded/Mmakefile
tests/hard_coded/transform_value.exp
tests/hard_coded/transform_value.m
	Test transform_value.
2005-01-13 11:04:38 +00:00
Julien Fischer
8aeed71e6d Add pragma terminates declarations to exception.builtin_throw/1,
Estimated hours taken: 1
Branches: main

Add pragma terminates declarations to exception.builtin_throw/1,
exception.throw/1 and require.error/1.

The point of this change is to try and reduce the number of cases of
possible non-termination being reported in the standard library due to
calls to require.error/1 or exception.throw/1.

Ideally we would only need provide a terminates declaration for
builtin_throw/1 but in practice the structure of the module dependency graph
means that error/1 is marked as non-terminating and certain calls to throw/1
are also considered to be non-terminating.

library/exception.m:
	Add pragma terminates declaration for builtin_throw/1 and
	throw/1.
library/require.m:
	Add pragma terminates declaration for error/1.
2003-11-13 17:06:11 +00:00
Ralph Becket
cd6258f67a Changed mode of result of func_error/1 from unused' to out' to
Estimated hours taken: 0.1
Branches: main

library/require.m:
	Changed mode of result of func_error/1 from `unused' to `out' to
	avoid mode problems with functions that call func_error/1 in a
	result.
2002-01-15 03:03:23 +00:00
Ralph Becket
b523b5df82 Additions to list.m and require.m.
Estimated hours taken: 2
Branches: main

Additions to list.m and require.m.

library/require.m:
	Added func_error/1, a func version of the error/1 pred.

library/list.m:
	Added cc_multi modes to list__fold[lr]/4 preds.
	Added list__map_corresponding/3 and list__map_corresponding3/4.

tests/general/map_corresponding.m:
	Added test cases for list__map_corresponding/3 and
	list__map_corresponding3/4.

tests/general/map_corresponding.exp:
	Expected output for above test cases.

tests/general/Mmakefile:
	Include the new test case.

NEWS:
	Recorded new additions.
2001-12-14 01:06:02 +00:00
Fergus Henderson
35474ce0ce Move exception handling into the standard library,
Estimated hours taken: 8

Move exception handling into the standard library,
and change error/1 so that it throws an exception.

This has two advantages: one is that user code can now catch
exceptions caused by calls to error/1, the other is that the
debugger handles calls to error/1 more gracefully (by virtue
of its existing support for exception handling).

extras/exceptions/exception.m:
library/exception.m:
	Move exception.m from `extras' into the standard library.
	Change the code for handling uncaught exceptions so that
	it prints out the same diagnostics that error/1 used to print out
	(i.e. a stack trace and the last debugger event number).

extras/exceptions/Mmakefile:
extras/exceptions/test_exceptions.exp:
extras/exceptions/test_exceptions.m:
extras/exceptions/test_exceptions_func.exp:
extras/exceptions/test_exceptions_func.m:
extras/exceptions/test_uncaught_exception.exp:
extras/exceptions/test_uncaught_exception.m
tests/hard_coded/exceptions/Mmakefile:
tests/hard_coded/exceptions/test_exceptions.exp:
tests/hard_coded/exceptions/test_exceptions.m:
tests/hard_coded/exceptions/test_exceptions_func.exp:
tests/hard_coded/exceptions/test_exceptions_func.m:
tests/hard_coded/exceptions/test_uncaught_exception.exp:
tests/hard_coded/exceptions/test_uncaught_exception.exp2:
tests/hard_coded/exceptions/test_uncaught_exception.m
	Move the exception test cases from extras/exceptions to
	a new directory tests/hard_coded/exceptions.
	Also, change the expected output for the `test_uncaught_exception'
	test case, since it now prints out more information.

tests/hard_coded/Mmakefile:
	Add `exceptions' to the list of subdirectories.

extras/exceptions/README:
	Delete this file, since the files that it refers to have now
	all been moved elsewhere.

library/require.m:
	Change error/1 so that it throws an exception.

library/library.m:
	Add exceptions.m to the list of modules in the standard library.
1999-08-31 12:57:21 +00:00
Zoltan Somogyi
1d107c82ad Add predicates to perform lower-bound and upper-bound searching, in which
Estimated hours taken: 3

Add predicates to perform lower-bound and upper-bound searching, in which
if a search for a key fails, we return the next lower (or higher) key and
its associated value.

library/bintree.m:
library/rbtree.m:
library/tree234.m:
library/map.m:
	Add lower-bound and upper-bound search and lookup predicates.

	Add plain lookup predicates where missing, or move them next
	to their corresponding search preds.

	Make the handling of lookup errors more uniform.

library/require.m:
	Move map__lookup_error here as report_lookup_error, for use
	by bintree, rbtree and tree234, as well as map.
1999-03-07 23:41:05 +00:00
Fergus Henderson
14a25f4af5 Fix a bug caused by zs's recent change to runtime/mercury_stack_trace.{h,c}:
Estimated hours taken: 0.25

Fix a bug caused by zs's recent change to runtime/mercury_stack_trace.{h,c}:

library/require.m:
library/math.m:
	Update calls to MR_dump_stack() to pass as the new
	`include_trace_data' argument the value `FALSE'.
1998-11-13 14:06:56 +00:00
Fergus Henderson
6b59d488f0 Remove bogus layout structure for the hand-coded procedure
Estimated hours taken: 0.25

library/require.m:
	Remove bogus layout structure for the hand-coded procedure
	require__error_internal/1 -- it doesn't create a stack frame,
	so it doesn't need a layout structure.
1998-11-09 05:32:30 +00:00
Zoltan Somogyi
a4ccdeacc9 Fix an old bug: #include mercury_trace_base.h, not mercury_trace.h.
Estimated hours taken: 0.1

library/require.m:
	Fix an old bug: #include mercury_trace_base.h, not mercury_trace.h.
1998-09-30 07:09:10 +00:00
Fergus Henderson
67c8ad9b0e Fix a bug that broke error/1 in grades jump.*' and fast.*'.
Estimated hours taken: 0.5

Fix a bug that broke error/1 in grades `jump.*' and `fast.*'.

library/require.m:
	Rename the C module `require_module_internal' as
	`require_internal_module', to be consistent with the names
	used for other C modules defined in the Mercury library.
	Add code to ensure that the initialization function
	for this module gets run.
1998-07-12 16:28:48 +00:00
Fergus Henderson
6f3f7b0575 Add missing `#include' of "mercury_trace.h", needed
Estimated hours taken: 0.1

library/require.m:
	Add missing `#include' of "mercury_trace.h", needed
	for MR_trace_report().
1998-05-28 11:13:59 +00:00
Tyson Dowd
71e69a8f31 Fix stack traces dying in -O-1.
Estimated hours taken: 3

Fix stack traces dying in -O-1.

error/1 is usually generated with no stack frame, but in -O-1 it is
generated with one (but doesn't need it).  error/1 passes
MR_dump_stack MR_succip and MR_sp, and MR_dump_stack assumes that
MR_succip is for the topmost stack frame, but if error/1 has a stack
frame, this is not true.

library/require.m:
	Make sure the caller of MR_dump_stack has no stack frame
	by using handwritten code.  We call the handwritten code
	from error/1, and so we have the nice side effect that
	error now appears in the stack dump.

runtime/mercury_stack_trace.h:
	Document that MR_dump_stack assumes the succip is for the
	topmost stack frame.

runtime/mercury_label.h:
	Fix a comment, layout info is for a label, not a procedure.
1998-04-18 08:13:26 +00:00
Zoltan Somogyi
67d8308260 Same as previous message. 1998-04-08 11:36:13 +00:00
Tyson Dowd
caba46b200 Implement nondet stack dumps.
Estimated hours taken: 1

Implement nondet stack dumps.

library/require.m:
	Call MR_dump_stack with MR_curfr.

runtime/mercury_stack_trace.c:
runtime/mercury_stack_trace.h:
	Get MR_curfr as input.
	If we hit a nondet stack frame, handle moving down a frame a
	little differently.
1998-04-07 05:13:30 +00:00
Tyson Dowd
f58ee880df Add support for stack dumps, do a stack dump from error/1.
Estimated hours taken: 12

Add support for stack dumps, do a stack dump from error/1.


compiler/Mmakefile:
library/Mmakefile:
profiler/Mmakefile:
runtime/Mmakefile:
	Insert EXTRA_MGNUCFLAGS before CFLAGS or EXTRA_CFLAGS
	becasue mgnuc stops processing its options when it
	encounters a non-mgnuc option.

library/require.m:
	Call MR_dump_stack if error is called.

runtime/Mmakefile:
runtime/mercury_imp.h:
	Add #includes of new files.

runtime/mercury_type_info.h:
	Remove conditional definition of MR_STATIC_CODE_ADDRESSES
	(moved into mercury_conf.h.in).

runtime/mercury_accurate_gc.h:
	Remove stack_layout stuff, leave this file for accurate
	GC specific definitions.

runtime/mercury_conf.h.in:
	Add conditional definitions of MR_INSERT_LABELS,
	MR_USE_STACK_LAYOUTS, MR_NEED_INITIALIZATION_CODE and
	MR_STATIC_CODE_ADDRESSES, depending on various other options.

runtime/mercury_goto.h:
	Insert labels into label table if MR_INSERT_LABELS is defined,
	rather than NATIVE_GC.

util/mkinit.c:
	Initialize if MR_NEED_INITIALIZATION_CODE is defined, rather than
	NATIVE_GC.

runtime/mercury_stack_layout.h:
	All the old stack layout definitions from mercury_accurate_gc.h.
	Add code for MR_DETISM_DET_CODE_MODEL.

runtime/mercury_stack_trace.c:
runtime/mercury_stack_trace.h:
	Implement MR_dump_stack which just provides a dump of the stack
	as far as possible.
	Set MR_INSERT_LABELS and MR_USE_STACK_LAYOUTS if MR_STACK_TRACE
	is set.

runtime/mercury_grade.h:
	Add _strce if stack tracing is enabled in the grade.  This
	might not be a permanent change.

runtime/mercury_ho_call.c:
	Remove unused label declarations.

scripts/mgnuc.in:
	Add --stack-trace and --no-stack-trace options.
	Consolidate some duplicate code.
1998-03-11 06:01:17 +00:00
Fergus Henderson
7cb525fde3 Undo Zoltan's bogus update of all the copyright dates.
Estimated hours taken: 0.5

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).
1998-01-23 12:33:43 +00:00
Zoltan Somogyi
9ae7acc593 Update all the copyright dates for 1998.
Estimated hours taken: 0.5

library/*.m:
	Update all the copyright dates for 1998.
1998-01-13 10:01:32 +00:00
Fergus Henderson
69faf90865 Add `:- pragma no_inline(error/1).', since inlining error/1
Estimated hours taken: 0.25

library/require.m:
	Add `:- pragma no_inline(error/1).', since inlining error/1
	results in bigger code with no improvement in speed.
1997-11-02 12:31:06 +00:00
Fergus Henderson
04b720630b Update the copyright messages so that (a) they contain the correct years
and (b) they say "Copyright (C) ... _The_ University of Melbourne".
1997-07-27 15:09:59 +00:00
Fergus Henderson
b27166f31d Add #include <stdio.h>.
Estimated hours taken: 0.25

library/math.m:
library/require.m:
	Add #include <stdio.h>.
1997-02-08 17:19:16 +00:00
Fergus Henderson
39eaab90c0 Move the C implementation of various builtins from the `runtime' directory
Estimated hours taken: 24

Move the C implementation of various builtins from the `runtime' directory
to inside pragma(c_code) declarations in the `library' directory sources.

library/{io,string,require,std_util,mercury_builtin}.m:
	Add lots of pragma(c_code) and pragma(c_header_code) declarations.

Also a few other miscellaneous changes.

library/list.m:
	Fix a bug in the as yet unused list__merge_sort.

library/io.m:
	Combine io__do_open_{input,output,append} into a single
	predicate io__do_open.

library/std_util.m:
	Fix the implementation of report_statistics so that it gives
	useful information when using conservative garbage collection.
1996-02-28 14:52:32 +00:00
Fergus Henderson
fa5226ee67 Improve the documentation.
library/*.m:
	Improve the documentation.
	Add a "Stability: low/medium/high" comment to all modules,
	which describes the stability of the interface to that module.

ops.m:
	Add `:' as an infix operator.

require.m:
	Implement require/1, since higher-order predicates now work.

term.m:
	Use the type `comparison_result' from mercury_builtin.m,
	rather than defining an identical type `comparison'.
1995-10-05 11:31:52 +00:00
Fergus Henderson
93a755d563 Add copyright notices.
library/*:
	Add copyright notices.
1995-03-28 16:19:34 +00:00