Commit Graph

220 Commits

Author SHA1 Message Date
Peter Ross
77a1261d3b Merge the foreign_type pragma changes from the dotnet branch to the main
Estimated hours taken: 10
Branches: main

Merge the foreign_type pragma changes from the dotnet branch to the main
branch, plus do some more development work to generalise the change.

compiler/prog_data.m:
    Add a type to hold the data from parsing a pragma foreign_type decl.

compiler/prog_io_pragma.m:
    Parse the pragma foreign_type.  This code is currently commented
    out, while we decide on the syntax.

compiler/hlds_data.m:
    Add a new alternative to hlds_type_body where the body of the type
    is a foreign type.

compiler/make_hlds.m:
    Place the foreign_type pragmas into the HLDS.

compiler/foreign.m:
    Implement to_type_string which replaces export__type_to_type_string,
    unlike export__type_to_type_string foreign__to_type_string takes an
    argument specifying which language the representation is meant to be
    in.  to_type_string also needs to take a module_info to handle
    foreign_types correctly.  To avoid the need for the module_info to
    be passed around the MLDS backend we provide a new type
    exported_type which provides enough information for an alternate
    version of to_type_string to be called.

compiler/export.m:
    Delete export__type_to_type_string.

compiler/llds.m:
    Since foreign__to_type_string needs a module_info, we add a new
    field to pragma_c_arg_decl which is the result of calling
    foreign__to_type_string.  This avoids threading the module_info
    around various llds passes.

compiler/mlds.m:
    Record with in the mercury_type the exported_type, this avoids
    passing the module_info around the MLDS backend.
    Also add the foreign_type alternative to mlds__type.
    Update mercury_type_to_mlds_type so that it handles types which are
    foreign types.

compiler/mlds_to_il.m:
    Convert a mlds__foreign_type into an ilds__type.

compiler/ilds.m:
    The CLR spec requires that System.Object and System.String be
    treated specially in the IL assembly so add them as simple types.

compiler/ilasm.m:
    Before outputting a class name into the IL assembly check whether it
    it can be simplified to a builtin type, and if so output that name
    instead as required by the ECMA spec.
    Changes for the addition of string and object as simple types.

doc/reference_manual.texi:
    Document the new pragma, this is currently commented out because it
    refers to syntax that has not yet been finalised.

compiler/fact_table.m:
compiler/llds_out.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_simplify_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_csharp.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_java.m:
compiler/mlds_to_mcpp.m:
compiler/pragma_c_gen.m:
compiler/rtti_to_mlds.m:
    Changes to handle using foreign__to_type_string.

compiler/hlds_out.m:
compiler/intermod.m:
compiler/magic_util.m:
compiler/ml_type_gen.m:
compiler/recompilation_usage.m:
compiler/recompilation_version.m:
compiler/term_util.m:
compiler/type_ctor_info.m:
compiler/unify_proc.m:
    Changes to handle the new hlds_type_body.

compiler/mercury_to_mercury.m:
    Output the pragma foreign_type declaration.

compiler/module_qual.m:
    Qualify the pragma foreign_type declarations.

compiler/modules.m:
    Pragma foreign_type is allowed in the interface.
2001-10-24 13:34:41 +00:00
David Overton
4f79ef0b59 Implement a change to the mode system suggested by Ralph Becket to make use of
Estimated hours taken: 12
Branches: main

Implement a change to the mode system suggested by Ralph Becket to make use of
higher order functions a bit easier.

During mode checking of higher order calls, if the variable being called has a
higher-order function type, but only a ground inst with no higher-order
information, assume that it has the default function modes.

Also, when doing anything that might cause a variable's inst to lose higher
order mode information, report a mode error if the variable has a non-standard
higher order function mode.  Situations where this may occur are at call sites,
exit sites and when merging insts at the end of a branched goal.

Note that because of this restriction, this change is not backwards compatible.

compiler/inst_util.m:
	Define some predicates to check for and produce pred_inst_infos for
	default function modes.
	In 'inst_merge', ensure that higher order inst information is not lost
	from non-standard function insts.

compiler/inst_match.m:
	In 'inst_matches_initial' and 'inst_matches_final', ensure that higher
	order inst information is not lost from non-standard function insts.
	Also allow 'inst_matches_{initial,final,binding}' to succeed
	where the first inst is a standard function inst and the
	second is ground.

compiler/modecheck_call.m:
	In 'modecheck_higher_order_call', if the variable to be called has no
	pred_inst_info, but the correct higher-order function type, assume it
	has the default function modes.

mode_util.m:
pd_util.m:
	Before replacing a ground inst with 'ground(Uniq, none)', ensure that it
	does not contain any nonstandard function insts.

tests/hard_coded/Mmakefile:
tests/hard_coded/ho_func_default_inst.m:
tests/hard_coded/ho_func_default_inst.exp:
tests/invalid/Mmakefile:
tests/invalid/ho_default_func_1.m:
tests/invalid/ho_default_func_1.err_exp:
tests/invalid/ho_default_func_2.m:
tests/invalid/ho_default_func_2.err_exp:
tests/invalid/ho_default_func_3.m:
tests/invalid/ho_default_func_3.err_exp:
	Add some test cases.

tests/invalid/Mmakefile:
tests/invalid/ho_default_func_4.m:
tests/invalid/ho_default_func_4.err_exp:
tests/invalid/inst_matches_final_bug.m:
tests/invalid/inst_matches_final_bug.err_exp:
	Add some test cases which we do not yet pass due to a bug in
	inst_matches_final.

NEWS:
doc/reference_manual.tex:
	Document the change.
2001-10-12 05:23:51 +00:00
Simon Taylor
a082239edb Put version identifiers in the documentation.
Estimated hours taken: 1.5
Branches: main, release

Put version identifiers in the documentation.

doc/Mmakefile:
	Preprocess the `.texi' files to produce `.texi_pp' files.
	The `.texi_pp' files contain the contents of the `.texi'
	files with the string <VERSION> replaced by the value
	of $(VERSION), which is taken from the file VERSION
	in the top-level `mercury' directory.

	The rules to automatically generate the `.texi' files
	for the library reference manual now generate `.texi_pp' files.
	This makes it clearer that they are not to be edited.

	Fix a bug which was causing the library documentation on the
	web page to be out of date -- library_1.html needs to depend
	on library-chapters.texi_pp.

doc/faq.texi:
doc/library.texi:
doc/reference_manual.texi:
doc/transition_guide.texi:
doc/user_guide.texi:
	Add version information.

	Put a proper heading at the top of mercury_ref.info.

doc/mercury.html.in:
doc/mercury.info.in:
doc/mercury.html:
doc/mercury.info:
	Add `.in' files which are preprocessed as for the `.texi' files.
	Remove the old unpreprocessed versions.

doc/texi2html:
	Allow `.texi_pp' as a suffix for the texinfo files to process.

w3/information/Makefile
	Create the VERSION file, and include it in the generated
	Mmake.common.
2001-10-03 11:37:56 +00:00
Simon Taylor
5544aed7ff Change the list constructor from ./2' to [|]/2'. `./2' will
Estimated hours taken: 3
Branches: main

Change the list constructor from `./2' to `[|]/2'. `./2' will
eventually become the module qualification operator.

library/parser.m:
library/io.m:
library/sparse_bitset.m:
library/std_util.m:
library/term_io.m:
compiler/mercury_to_mercury.m:
compiler/prog_io_dcg.m:
compiler/prog_io_goal.m:
compiler/prog_io_pragma.m:
compiler/prog_io_typeclass.m:
compiler/prog_io_util.m:
browser/interactive_query.m:
extras/moose/grammar.m:
extras/moose/moose.m:
extras/morphine/source/generate_call_site_cov.m:
extras/xml/xml.encoding.m:
samples/muz/higher_order.m:
tests/debugger/declarative/app.m:
tests/dppd/transpose_impl.m:
tests/hard_coded/ground_dd.m:
tests/hard_coded/split_c_files.m:
	Change all references to `./2' to use `[|]/2' instead.

compiler/typecheck.m:
	Handle `./2' as a special case in `report_error_undef_cons'.

	Warn about module list not being imported if `[|]/2' is undefined.

compiler/llds_out.m:
util/mdemangle.c:
profiler/demangle.m:
	Add name conversions for `[|]' (f_cons) and `[]' (f_nil).

NEWS:
doc/reference_manual.texi:
w3/tutorial/lists-n-things.m4:
	Document the changes.

tests/debugger/{,declarative}/*.exp*:
	Update test case results. For some tests the output changed
	because they output lists in the non-pretty format. For others,
	the output changed because the alphabetical ordering of the
	constructors of type `list/1' changed, so the numbering of
	the switch branches in the goal paths changed.
2001-09-25 09:37:12 +00:00
Simon Taylor
efdfb2d927 Make the documentation for the determinism
Estimated hours taken: 0.25
Branches: main, release

doc/reference_manual.texi:
	Make the documentation for the determinism
	categories more precise with respect to calls
	which do not return.

	Change documentation referring to require__error/1 to
	also refer to exception__throw/1.
2001-09-23 09:51:38 +00:00
Simon Taylor
e6c2f69c43 Fix bugs in the transformation and examples for field update.
Estimated hours taken: 0.2
Branches: main, release

doc/reference_manual.texi:
	Fix bugs in the transformation and examples for field update.
2001-08-17 03:52:35 +00:00
Fergus Henderson
20dd5d5cb9 Work around a bug in texi2html that caused an @dots{} construct to
Estimated hours taken: 0.25
Branches: main, release

doc/reference_manual.texi:
	Work around a bug in texi2html that caused an @dots{} construct to
	be left in the generated HTML file.
	Also use ">>" rather than "->" in a couple of mode declarations.
2001-07-31 18:02:11 +00:00
Tyson Dowd
b0d7da6a01 Add a field to clauses_info to record whether we have any
Estimated hours taken: 20
Branches: main

compiler/hlds_pred.m:
	Add a field to clauses_info to record whether we have any
	foreign_proc clauses.

	Add a new goal type clauses_and_pragmas to describe predicates
	that have procedures implemented using both pragmas and clauses.

	Add pred_info_pragma_goal_type and pred_info_clause_goal_type
	to simplify cases where we are just interested whether the goal
	types might contain pragmas or goals.

compiler/make_hlds.m:
	Record errors if we try to add a foreign_proc that will replace
	a Mercury clause that is not mode-specific, or if we try to add
	a non-mode specific Mercury clause that will replace a foreign
	proc.
	Otherwise, we allow a foreign_proc to replace mode-specific
	Mercury clauses.
	Set the goal type for potentially mixed mercury/foreign_proc
	clauses as "clauses".
	Add Mercury clauses only for modes not yet covered by
	foreign_proc clauses.  Checking this could be a performance
	problem so we check the have_foreign_clauses boolean so
	that we don't need to search all the clauses every time we add a
	Mercury clause (only when there are foreign_clauses to search for).

	Traverse clauses and decide upon our course of action (add
	new foreign_proc clause, ignore new foreign_proc clause, replace
	existing clause, split existing clause and add new clause)
	all in one go.

compiler/clause_to_proc.m:
compiler/higher_order.m:
compiler/hlds_out.m:
compiler/make_hlds.m:
compiler/purity.m:
compiler/polymorphism.m:
compiler/unify_proc.m:
	Handle have_foreign_clauses field in clauses_info.
	Handle clauses_and_pragmas goal type.

compiler/intermod.m:
	Handle clauses_and_pragmas goal type.
	Handle all clauses in a single pass, since we now know on a
	clause by clause basis whether they are foreign_proc clauses
	or Mercury clauses we can simplify the traversal of all clauses
	down to a single pass.

doc/reference_manual.texi:
doc/user_guide.texi:
	Document the ability to mix mode-specific Mercury and
	foreign_proc clauses.

	Document the behaviour of the implementation when it comes to
	specific backends (that is, the preferred foreign languages list).
	Also a few fixes from fjh's review that didn't quite make it
	into the review.
2001-07-31 14:30:15 +00:00
Simon Taylor
5d45571081 Fix the documentation of variable scoping.
Estimated hours taken: 0.2
Branches: main, release

doc/reference_manual.texi:
	Fix the documentation of variable scoping.
	The scope of type variables in a predicate or
	function declaration extends over any
	`:- pragma type_spec' declarations for
	that predicate or function.
2001-07-25 15:49:53 +00:00
Tyson Dowd
079742ef9e Move most of the foreign language information into the reference
Estimated hours taken: 0.2
Branches: main

doc/reference_manual.texi:
doc/user_guide.texi:
	Move most of the foreign language information into the reference
	manual.  Only default language settings remain in the user's
	guide.
2001-07-25 14:13:35 +00:00
Fergus Henderson
3b65d1da85 Improve the documentation of the foreign language interface.
Estimated hours taken: 2
Branches: main

Improve the documentation of the foreign language interface.

doc/reference_manual.texi:
	Document the semantics of "pragma foreign_decl" and "pragma
	foreign_code", rather than leaving them implementation-defined.

	In the "Foreign Language Interface" chapter, document that all
	Mercury implementations should support the C interface.
	This fixes an inconsistency between the F.L.I. chapter,
	which said that it was implementation-specific,
	and the C interface chapter, which said that all
	Mercury implementations should support linking with C code.

doc/reference_manual.texi:
doc/user_guide.texi:
	Various other minor improvements: fix typos, improve wording, etc.
2001-07-23 16:53:04 +00:00
Tyson Dowd
b994075a22 Add support for foreign_proc("il", ....)
Estimated hours taken: 50
Branches: main


Add support for foreign_proc("il", ....)

To use it, you need to give the options
	--use-foreign-language il
	--backend-foreign-language il

Begin documenting foreign_proc.


compiler/foreign.m:
compiler/globals.m:
	Handle the addition of il as a language option.

compiler/inlining.m:
	Mention that we don't allow il code to be inlined yet and give a
	pointer into ml_code_gen.m which has the reason along with the
	offending code.

compiler/il_peephole.m:
compiler/ilasm.m:
	Handle the addition of il_asm_code as inlineable code.

compiler/ilds.m:
	Add a handwritten scope to the different scope types.

compiler/ml_code_gen.m:
	Handle the generation of code for IL foreign language interfacing.
	Put the max_stack_size attribute into IL foreign language code.
	Document the problem with inlining.

compiler/ml_elim_nested.m:
	Handle the new field in blocks indicating whether the block contains
	handwritten code.

compiler/mlds.m:
	Add lang_il as a possible target language.
	Add attributes to target code (max_stack_size is the only one so far).

compiler/mlds_to_c.m:
compiler/mlds_to_csharp.m:
compiler/mlds_to_java.m:
compiler/mlds_to_mcpp.m:
	Handle the addition of il as a language option.

compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
	Generate inline code for foreign_proc using IL.

compiler/prog_data.m:
	Add il as a language option.

	Add extra attributes to the pragma_foreign_proc_attributes.
	Currently there is just one extra attribute, max_stack_size.

compiler/prog_io_pragma.m:
	Parse max_stack_size as an attribute on foreign_proc.
	Improve error message output: previously we tried to parse the
	third term of a foreign_proc, and then tried to parse the second term
	(which we will accept for "c_code" but not foreign_proc).
	But we should give the error message as if the "c_code" handling is
	not present, as this will eventually go away.
	Check for foreign_language attributes such as max_stack_size.

doc/reference_manual.texi:
	Add a section for foreign_proc (and other multi-language foreign
	language interfacing pragmas).
	At the moment we have some reasonable documentation for "C" and
	"IL" foreign_proc, and some documentation on foreign_decl and
	foreign_code for C.

doc/user_guide.texi:
	The language and implementation specific documentation of
	the foreign language interface.
2001-07-18 10:21:03 +00:00
Simon Taylor
678586ba77 Fix syntax errors in the documentation for DCG field selection
Estimated hours taken: 0.1
Branches: main, release

doc/reference_manual.texi:
	Fix syntax errors in the documentation for DCG field selection
	(SourceForge bug #432592).
2001-06-13 04:28:17 +00:00
Fergus Henderson
b49887bcc7 Update to the version from GNU TexInfo 4.0.
Estimated hours taken: 0.5
Branches: main

doc/texinfo.tex:
	Update to the version from GNU TexInfo 4.0.

doc/*.texi:
	Move the table of contents from the end of the document
	to the start of the document (just after the title page).
	The only reason that it was at the end was that previous
	versions of TexInfo didn't support putting it at the start.
2001-06-04 06:31:38 +00:00
Fergus Henderson
b973fb0b9d Add support for using different clauses for different modes of a
Estimated hours taken: 8
Branches: main

Add support for using different clauses for different modes of a
predicate or function, using mode annotations on the clauses.

compiler/make_hlds.m:
	Add support for mode annotations on clauses.

compiler/module_qual.m:
	Add new routine qualify_clause_mode_list, for use by make_hlds.m.

compiler/mode_errors.m:
	Export output_mode_decl, for use by make_hlds.m

compiler/purity.m:
	Treat procedures with different clauses for different modes
	as impure, unless promised pure.

compiler/notes/compiler_design.html:
	Specify when module qualification of modes in
	clause mode annotations is done (in make_hlds.m).

NEWS:
doc/reference_manual.texi:
	Document the new feature.
2001-05-16 04:51:04 +00:00
Fergus Henderson
36bb97d223 Fix a bug where the compiler was silently accepting invalid code.
Estimated hours taken: 6
Branches: main, release

Fix a bug where the compiler was silently accepting invalid code.

doc/reference_manual.texi:
	Document that type class methods must have their modes and
	determinism explicitly declared.

compiler/make_hlds.m:
	Report errors for predicate type class methods with no modes
	or with modes but no determinism.

compiler/check_typeclass.m:
compiler/polymorphism.m:
	Handle the case where a method has no declared determinism:
	since make_hlds.m will have already reported the error,
	we just need to avoid aborting or issuing spurious flow-on errors.

tests/invalid/Mmakefile:
tests/invalid/typeclass_missing_mode.m:
tests/invalid/typeclass_missing_mode.err_exp:
tests/invalid/typeclass_missing_mode_2.m:
tests/invalid/typeclass_missing_mode_2.err_exp:
tests/invalid/typeclass_missing_det.m:
tests/invalid/typeclass_missing_det.err_exp:
tests/invalid/typeclass_missing_det_2.m:
tests/invalid/typeclass_missing_det_2.err_exp:
tests/invalid/typeclass_missing_det_3.m:
tests/invalid/typeclass_missing_det_3.err_exp:
	Add some regression tests.

tests/invalid/tc_err1.err_exp:
	Update the expected output for this existing test.
2001-04-29 07:54:37 +00:00
Simon Taylor
a3819d359c Fix the handling of purity in the optimization and tabling passes.
Estimated hours taken: 15
Branches: main

Fix the handling of purity in the optimization and tabling passes.
Without this change tests/tabling/unused_args.m fails with
inter-module optimization.

compiler/purity.m:
compiler/post_typecheck.m:
	Allow purity checking to be rerun on a single procedure
	without requiring an io__state. If the purity is worse
	(due to inlining a predicate with a `:- pragma promise_pure'
	declaration), add `promised_pure' or `promised_semipure'
	to the pred_info.

compiler/hlds_out.m:
compiler/hlds_pred.m:
compiler/intermod.m:
compiler/make_hlds.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/prog_data.m:
compiler/prog_io_pragma.m:
compiler/purity.m:
doc/reference_manual.texi:
NEWS:
	Implement `:- pragma promise_semipure'. This is needed if
	an predicate marked `promised_pure' which calls impure
	predicates is inlined into  a semipure predicate.

compiler/inlining.m:
	Make sure the purity markers on the goal_infos are correct
	after inlining predicates which are promised pure.

	Export a predicate inlining__can_inline_proc which is used
	by deforestation to determine whether inlining a procedure
	will change the semantics or will break code generator invariants.

compiler/deforest.m:
	Use the same method as inlining.m to work out whether
	a procedure can be inlined. Don't inline predicates which
	are promised pure because the extra impurity which
	will be propagated through the goal will stop deforestation
	working on the goal.

compiler/simplify.m:
	Make sure the goal_info resulting from converting a singleton
	switch into a conjunction has the correct purity.

compiler/table_gen.m:
	Make sure the purity markers on the generated goal_infos are
	correct.

	Make sure that call_table_gen goal features cannot be removed
	by optimization passes.

	Don't put unnecessary `impure' markers on calls to error/1.

tests/debugger/loopcheck.exp:
tests/debugger/retry.exp:
	Adjust the expected output. The change to ensure that
	`call_table_gen' goal features can't be removed alters
	the goal paths slightly.

tests/invalid/impure_method_impl.m:
	Adjust the expected output now that predicates can
	be promised semipure.
2001-03-27 05:23:23 +00:00
Fergus Henderson
09807ccab2 Fix a cut-and-paste error pointed out by Nick Nethercote.
Estimated hours taken: 0.1
Branches: main, release

doc/reference_manual.texi:
	Fix a cut-and-paste error pointed out by Nick Nethercote.
2001-03-15 06:32:06 +00:00
David Jeffery
29baab7783 Fix a bug reported by petdr on October 30th last year.
Estimated hours taken: 12

Fix a bug reported by petdr on October 30th last year.

compiler/polymorphism.m:
        When looking up the variable which contains a typeclass info for
        a particular constraint to be passed to a call, handle the case where
        there is *no* variable for such a constraint. This occurs in the case
        where the producer of the variable occurs later on in the goal (but
        will get re-ordered by the mode checker). The solution is to just
        create a variable for the typeclass info, and whenever creating
        a `head' variable to hold a constraint being produced by a call,
        check first whether there is already a variable allocated for that
        constraint.

doc/reference_manual.texi:
        Delete mention of this bug from the "Known Bugs"  in the existential
        types section.

tests/hard_coded/typeclasses/Mmakefile:
tests/hard_coded/typeclasses/reordered_existential_constraint.exp:
tests/hard_coded/typeclasses/reordered_existential_constraint.m:
        A test case for this. (Not the same as petdr's original test case,
        but much simpler and exhibits the same bug).
2001-02-12 05:14:58 +00:00
Fergus Henderson
87349dbdde Fix some formatting errors
Estimated hours taken: 0.25

doc/reference_manual.texi:
doc/user_guide.texi:
	Fix some formatting errors
	(s/@item/@itemx/ in appropriate places).
2001-01-11 09:34:22 +00:00
Simon Taylor
550e253206 Allow field access functions to take extra arguments.
Estimated hours taken: 5

Allow field access functions to take extra arguments.
Change the field update function names from `'field:='/2' to `'field :='/2'.

compiler/make_hlds.m:
        Handle field names with arguments.

compiler/hlds_pred.m:
        Add " :=" as the suffix for a field update function,
        rather than ":=".

compiler/typecheck.m:
        Update instances of `field:='/2 in comments.

compiler/det_util.m:
compiler/simplify.m:
        `det_info_vartypes' was defined using the `field:=' syntax.
        Change it into a normal predicate for bootstrapping.

library/array.m:
library/bt_array.m:
library/map.m:
        Add field access functions `elem/2' and `'elem :='/3'.
        For maps, the `elem' function calls `map__search',
        so add field access functions `det_elem' and `det_elem :='
        to call `map__lookup' and `map__det_update'.

NEWS:
doc/reference_manual.tex:
        Document the changes.

        Improve readability by changing occurrences
        of `X^field' to `X ^ field'.

tests/hard_coded/typeclasses/record_syntax.{m,exp}:
        Test field names with arguments.

tests/invalid/record_syntax_errors.err_exp:
	Update the expected output.
2000-12-13 00:00:55 +00:00
Mark Brown
35cb0d2267 Update remaining occurrences of the old mode syntax.
Estimated hours taken: 0.1

doc/reference_manual.texi:
	Update remaining occurrences of the old mode syntax.
2000-11-17 05:52:47 +00:00
Simon Taylor
47f1ab1b04 Commit Fergus' suggested improvements for my last change.
Estimated hours taken: 0.1

doc/reference_manual.texi:
	Commit Fergus' suggested improvements for my last change.
2000-11-07 11:09:47 +00:00
Simon Taylor
9aeb9ca557 Add a reference to the "DCG-goals" section from the
Estimated hours taken: 0.1

doc/reference_manual.texi:
	Add a reference to the "DCG-goals" section from the
	"Record syntax" section, to make it easier to
	find the DCG record syntax goals.
2000-11-07 00:47:45 +00:00
David Jeffery
ccb7abc9ba Change the table of builtin operators section so that it uses `@example'
Estimated hours taken: 1

doc/reference_manual.texi:
        Change the table of builtin operators section so that it uses `@example'
        for the table layout, rather than `@multitable', which texi2html does
        not handle properly. This fixes a bug reported by Ralph Becket.
2000-11-01 02:06:25 +00:00
Peter Ross
f90a1f16cc Fix some syntax and semantic errors in an example of instance
Estimated hours taken: 0.25

reference_manual.texi:
    Fix some syntax and semantic errors in an example of instance
    declarations.
2000-10-30 15:50:40 +00:00
Fergus Henderson
12788ee29c Disable the `factt_non' test case in hl* grade,
Estimated hours taken: 0.25

tests/hard_coded/Mmakefile:
	Disable the `factt_non' test case in hl* grade,
	since we don't pass it.

doc/reference_manual.texi:
	Document that nondet fact tables are not supported by the
	`--high-level-code' back-end.
2000-10-24 01:10:08 +00:00
Simon Taylor
2c1efdf543 Fix a bug reported by Ralph Becket which caused a compiler abort
Estimated hours taken: 1

Fix a bug reported by Ralph Becket which caused a compiler abort
if the user declared the modes but not the types for a field
access function.

compiler/typecheck.m:
	In the clause introduced when the user declares the modes
	of a field access function, make sure the var-functor
	unification can only be interpreted as a field access,
	not a recursive function call.

	Add field labels to the typecheck_info type.

tests/invalid/record_syntax_errors.m:
tests/invalid/record_syntax_errors.err_exp:
	Add a test case.

doc/reference_manual.texi:
	Clarify the documentation.
2000-10-10 06:23:32 +00:00
Simon Taylor
3cf329a739 Fix bugs in explicit type qualification.
Estimated hours taken: 4

Fix bugs in explicit type qualification.

compiler/make_hlds.m:
	Make the code to handle type qualification expressions match
	the documentation. Variables occurring in type qualifications
	but not in the predicate's argument types are local to the
	clause in which they occur.

	Don't export clauses_info_init -- it's not used anywhere else.

	Add field labels to the qual_info type.

compiler/hlds_pred.m:
compiler/*.m:
	Add a field to the clauses_info to contain the mapping from
	type variable names to type variables for the head types.
	This needs to be maintained because type variables added
	while processing type qualifications in a clause should
	not be added to the map used for other clauses.

compiler/typecheck.m:
	Apply substitutions to the explicit vartypes at the end
	of each pass of typechecking to keep them in sync with
	the type variables in the argument types.

compiler/type_util.m:
	Add a predicate type_util__apply_variable_renaming_to_type_map
	for use by typecheck.m.

doc/reference_manual.texi:
	Add some more comments about the handling of explicit type
	qualifications to the documentation about valid type assignments.

	Change references to existential type _qualifiers_ to consistently
	refer to existential type _quantifiers_.

tests/hard_coded/type_qual.{m,exp}:
	Add some more tests.

tests/hard_coded/Mmakefile:
	Pass `--infer-all' to mmc when compiling type_qual.m.
2000-09-25 04:23:19 +00:00
Fergus Henderson
8d811e2b09 Enable the support for explicit type qualification,
Estimated hours taken: 1.5

Enable the support for explicit type qualification,
using `with_type` as the operator.

compiler/make_hlds.m:
compiler/hlds_out.m:
	Use `with_type` as the type qualification operator.

tests/hard_coded/type_qual.m:
tests/hard_coded/type_qual.inp:
tests/hard_coded/type_qual.exp:
	Test the new feature.

doc/reference_manual.texi:
	Document the new feature.
	Also make a few improvements to the documentation of
	data-terms, record syntax, and variable scoping.

NEWS:
	Mention the new feature.
2000-09-21 09:44:05 +00:00
Fergus Henderson
da9dc64c8f Allow typeclass instance declarations to contain more than one clause
Estimated hours taken: 5

Allow typeclass instance declarations to contain more than one clause
for each method.

Also improve some error messages.

compiler/check_typeclass.m:
	Allow typeclass instance declarations to contain more than one
	clause for each method, by combining the different clauses
	for each method into a single definition.

	Rewrite the code to check for bogus method names in instance
	declarations.  This rewrite was necessitated by the change
	mentioned above, but also improved the quality of the error
	message (it now prints the name of the bogus method)
	and fixed some bugs that sometimes resulted in spurious
	flow-on error messages.

	Fix some problems where we were not passing the correct arity
	for functions (e.g. to make_introduced_pred_name).

tests/invalid/Mmakefile:
tests/invalid/typeclass_bogus_method.m:
tests/invalid/typeclass_bogus_method.err_exp:
	Add a new regression test.

tests/invalid/tc_err*.err_exp:
tests/invalid/typeclass_test_*.err_exp:
	Update the expected output for these test cases,
	to reflect the improved error messages.

doc/reference_manual.texi:
	Update the documentation to reflect this change.

NEWS:
	Mention that we now allow clauses in instance declarations.
2000-09-20 11:59:46 +00:00
Fergus Henderson
db94d0e0ab Apply Ralph Beckett's suggested fix for some wording problems
Estimated hours taken: 0.25

doc/reference_manual.texi:
	Apply Ralph Beckett's suggested fix for some wording problems
	with the restrictions on typeclass instances.
2000-09-20 11:45:37 +00:00
David Jeffery
6cfb9823f3 Add the list of valid operators to the reference manual.
Estimated hours taken: 2

Add the list of valid operators to the reference manual.

doc/reference_manual.texi:
        Add a table of valid operators.
library/ops.m:
        Add a note indicating that reference_manual.texi needs to be kept
        in sync with the operator table.
2000-09-19 04:46:50 +00:00
Simon Taylor
46a8da81cb Implement builtin tuple types, similar to those in Haskell.
Estimated hours taken: 30

Implement builtin tuple types, similar to those in Haskell.

Tuples are constructed and deconstructed using
the syntax X = {Arg1, Arg2, ...}.
Tuples have type `{Arg1, Arg2, ...}'.

Unary tuples (X = {Arg}) do work, unlike in Haskell. The rationale
for this is that it is useful to be able to construct unary tuples
to be passed to a polymorphic predicate which uses std_util__deconstruct
to deal with a tuple of any arity. Since this is probably the only
use for unary tuples, it's not really worth the effort of treating
them as no_tag types, so we don't.

The type-infos for tuples have the same structure as for higher-order
types. There is a single type_ctor_info for tuples, and the arity
is placed before the argument type_infos.

library/parser.m:
	Change the way '{}/N' terms are parsed, so that the parsed
	representation is consistent with the way other functors
	are represented (previously the arguments were left as
	unparsed ','/2 terms). This avoids special case code
	in prog_io__parse_qualified_term, term__term_to_type
	and term__type_to_term.

compiler/prog_io_dcg.m:
compiler/prog_io_util.m:
	Handle the new structure of '{}/N' terms when parsing DCG escapes
	by converting the argument list back into a single ','/2 term.

compiler/module_qual.m:
	Treat tuples as a builtin type.

compiler/typecheck.m:
	Typecheck tuple constructors.

compiler/mode_util.m:
	Propagate types into tuple bound insts.

compiler/type_util.m:
	Add type_is_tuple/2 and type_id_is_tuple/1 to identify tuple types.
	Add tuples to the list of types which are not atomic types.

	Handle tuple types in `type_constructors' and
	`get_cons_id_arg_types' and `switch_type_num_functors'.

compiler/tabling.m:
	Handle tabling of tuples.

compiler/term_util.m:
	Handle tuples in the code to compute functor norms.

compiler/magic_util.m:
compiler/rl.m:
compiler/rl_key.m:
	Handle tuple types in the Aditi back end.

compiler/mercury_to_mercury.m:
library/io.m:
library/term_io.m:
	Handle output of '{}/N' terms.

compiler/higher_order.m:
compiler/simplify.m:
	Don't specialize complicated unifications of tuple
	types into calls to a specific unification procedure --
	even if the procedure were implemented, it probably
	wouldn't be that much more efficient.

compiler/unify_proc.m:
	Generate unification procedures for complicated unifications
	of tuples (other than in-in unifications). These are generated
	lazily as required.

compiler/make_hlds.m:
	Export add_special_pred for use by unify_proc.m.

compiler/polymorphism.m:
	Export polymorphism__process_pred for use by unify_proc.m.

compiler/bytecode_gen.m:
compiler/code_util.m:
compiler/ml_code_util.m:
	Handle unify procedure names and tags for tuple types.

compiler/mlds_to_c.m:
	Output tuple types as MR_Tuple.

compiler/ml_unify_gen.m:
	Compute the field types for tuples.

compiler/polymorphism.m:
compiler/pseudo_type_info.m:
	Treat tuple type_infos in a similar way to higher-order type_infos.

compiler/hlds_data.m:
	Document how cons_ids for tuple types are represented.

compiler/switch_gen.m:
compiler/table_gen.m:
	Add tuple types to switches on type_util__builtin_type.

compiler/llds_out.m:
util/mdemangle.c:
profiler/demangle.m:
	Transform items named "{}" to "f_tuple" when mangling symbols.

library/builtin.m:
	Define the type_ctor_info used for tuples.

library/private_builtin.m:
	Add `builtin_unify_tuple/2' and `builtin_compare_tuple/3',
	both of which abort. All comparisons and in-in unifications
	of tuples are performed by the generic unification functions
	in runtime/mercury_ho_call.c and runtime/mercury.c.

library/std_util.m:
	Implement the various RTTI functions for tuples.

	Encode tuple `TypeCtorDesc's in a similar way to that
	used for higher-order types. This has the consequence that the limit
	on the arity of higher-order types is now MAX_VIRTUAL_REG,
	rather than 2*MAX_VIRTUAL_REG.

	Avoid calling MR_GC_free for the type-info vector returned
	from ML_expand() for tuples because unlike the vectors
	for du types, it is not copied.

runtime/mercury_type_info.h:
	Add macros for extracting fields from tuple type-infos.
	These just call the macros for extracting fields from higher-order
	type-infos.

	Add a macro MR_type_ctor_rep_is_variable_arity(), which
	returns TRUE for tuples and higher-order types.

	The distinction between higher-order and first-order types
	is now misnamed -- the distinction is really between fixed arity
	types and builtin variable arity types. I'm not sure whether
	it's worth renaming everything.

runtime/mercury.h:
runtime/mercury.c:
	Define unification and comparison of tuples in
	high-level code grades.

runtime/mercury_deep_copy_body.h:
runtime/mercury_make_type_info_body.h:
runtime/mercury_tabling.c:
runtime/mercury_unify_compare_body.h:
	Handle tuple types in code which traverses data using RTTI.

tests/hard_coded/construct.{m,exp}:
tests/hard_coded/expand.{m,exp}:
	Test RTTI functions from std_util.m applied to tuples.

tests/hard_coded/tuple_test.{m,exp}:
	Test unification, comparison, term_to_type etc. applied to tuples.

tests/hard_coded/deep_copy.{m,exp}:
	Test deep copy of tuples.

tests/hard_coded/typeclasses/tuple_instance.{m,exp}:
	Test instance declarations for tuples.

tests/tabling/expand_tuple.{m,exp}:
	Test tabling of tuples.

tests/hard_coded/write.m:
	Add some module qualifications for code which uses
	`{}/1' constructors which are not tuples.

tests/invalid/errors2.{m,err_exp,err_exp2}:
	Test handling of tuples in type errors messages.

NEWS:
doc/reference_manual.texi:
w3/news/newsdb.inc:
	Document tuples.

doc/transition_guide.texi:
	Document the change to the parsing of '{}/N' terms.
2000-09-18 11:53:19 +00:00
Fergus Henderson
4d0dff1860 Allow typeclass instance declarations to contain clauses, as an
Estimated hours taken: 10

Allow typeclass instance declarations to contain clauses, as an
alternative to the current `pred(<MethodName>) is <ImplName>)' syntax.
This avoids the need for the user to explicitly define names for
procedures that just implement type class methods.

XXX Note that currently we only permit one clause per method.

compiler/prog_data.m:
	Change the second `sym_name' field of `instance_method'
	into a new type `instance_proc_def', which has two alternatives.
	The first, `name(sym_name)', is for the old syntax.
	The second, `clauses(list(item))', is for the new syntax.

compiler/prog_io_typeclass.m:
	Parse the new syntax.

compiler/make_hlds.m:
	Add new predicate `produce_instance_method_clauses',
	for use by check_typeclass.m.  This handles the generation of
	HLDS clauses_infos for both the old and new syntax for
	instance method definitions.
	Return the qual_info produced by `parse_tree_to_hlds',
	so that it can be passed to `produce_instance_method_clauses'.

compiler/mercury_compile.m:
	Pass the qual_info returned by make_hlds.m to check_typeclass.m.

compiler/check_typeclass.m:
	Move the code which produces HLDS definitions for instance
	methods into `produce_instance_method_clauses' in make_hlds.m.
	Thread the io__state and qual_info throughout most of the code,
	since this they are needed to process the new syntax.
	(The io__state is needed so we can spit out warnings about
	singleton variables in clauses in type class methods, and
	the qual_info is needed to handle explicit type qualifiers
	in such clauses.)

compiler/mercury_to_mercury.m:
	Output the new syntax.

tests/hard_coded/typeclasses/Mmakefile:
tests/hard_coded/typeclasses/instance_clauses.m:
tests/hard_coded/typeclasses/instance_clauses.exp:
	A test case for the new feature.

doc/reference_manual.texi:
	Document the new feature.
2000-09-16 00:08:32 +00:00
Tyson Dowd
401298c013 Make the syntax for defining modes and insts similar to type equivalence.
Estimated hours taken: 2

Make the syntax for defining modes and insts similar to type equivalence.

Old syntax:
	:- inst foo = someinstdefn.
	:- mode foo :: someinst -> someotherinst.

New syntax:
	:- inst foo == someinstdefn.
	:- mode foo == someinst >> someotherinst.

The old syntax is still supported.  For `::' and `->' it may eventually
be phased out (but it doesn't cause many problems apart from possible
confusion of users, so it's a low priority).

In the case of `:- inst' we could already use `==' or `=', however we
now make `==' the standard syntax.  Again, we support both and probably
will for quite some time.

NEWS:
	Mention these changes.

compiler/prog_io.m:
	Make `==' the standard operator for `:- inst <InstDefn>.'
	declarations.

	Make `==' and `>>' the standard operators for
	`:- mode foo == someinst >> someotherinst'.
	`::' and `->' are still supported.

compiler/prog_io_util.m:
	Make `>>' the standard operator for inline mode declarations.
	`->' is still supported.

doc/reference_manual.texi:
	Update the syntax in the reference manual.
	Mention that `::' and `->' is deprecated.

tests/valid/Mmakefile:
tests/valid/mode_syntax.m:
	Add a new test of the new syntax.

compiler/fact_table.m:
	Fix a typo (missing quote) in the verbose messages for fact tables.
2000-09-15 11:25:02 +00:00
Tyson Dowd
db64a3588d Add MR_ prefixes to the types used when generating C code.
Estimated hours taken: 4

Add MR_ prefixes to the types used when generating C code.
This means types such as Word, String, Bool, Float become MR_Word,
MR_String, MR_Bool, MR_Float.  Also define MR_Box for both the LLDS and
MLDS backends so we can use it uniformly.

This is very important in environments where String or Bool have already
been used as system types (for example, managed C++).  And besides, we
should do it anyway as part of the grand namespace cleanup.

I have fixed all of the uses of the non-prefixed types in the runtime
and trace directories.  I haven't done it for the library and compiler
directories yet (no promises that I will do it in future either).  But
if you see a non-prefixed type in code from now on, please consider it a
bug and fix it.

mercury_bootstrap.h contains #defines to map the non-prefixed types into
the prefixed ones.  Like many of the other namespace cleaning backwards
compatibility macros, this can be turned off with
MR_NO_BACKWARDS_COMPAT.

This shouldn't break any code, but this kind of change affects so many
things that of course there could be problems lurking in there somewhere.

If you start getting errors from the C compiler after this change is
installed, you will want to make sure you at least have the runtime
system updated so that you are getting the backwards compatibility
definitions in mercury_bootstrap.h.  Then if you continue to have
problems you can bug me about it.

compiler/export.m:
compiler/llds_out.m:
compiler/mlds_to_c.m:
	Use MR_Word, MR_Float, MR_Bool, etc when generating C.

doc/reference_manual.texi:
	Update the reference manual to talk about MR_Word, MR_String,
	MR_Char, etc.

runtime/mercury_bootstrap.h:
	Add bootstrapping typedefs.

runtime/*:
trace/*:
	Change Word, Float, Bool, Code, String, etc to
	MR_Word, MR_Float, MR_Bool, MR_Code, MR_String.
2000-08-03 06:19:31 +00:00
Simon Taylor
7b5b1c0a34 Minor improvements to the Aditi documentation.
Estimated hours taken: 1

Minor improvements to the Aditi documentation.

doc/reference_manual.texi:
doc/user_guide.texi:
	Fix the formatting of the Aditi entries in the menus -- texinfo
	doesn't like @ifset commands in menus.

	Remove references to extras/aditi. The transaction interface
	is distributed as part of Aditi.

	State that Aditi memoing doesn't work yet.
2000-06-01 08:47:37 +00:00
Simon Taylor
bbbac5099a The Aditi transaction paper published a few years ago contained
Estimated hours taken: 0.5

The Aditi transaction paper published a few years ago contained
a small error which I included in my code -- the state arguments
passed into queries to ensure that database predicates are only
called from within a transaction should have mode `mui' rather
than `ui'. Compiling queries with the alias branch mode checker
confirms this.

Because `mui' modes do not yet work on the main branch, `aditi_mui'
(equivalent to `in') is used instead. This change replaces
all instances of `aditi_ui' with `aditi_mui'.

compiler/*.m:
doc/*.texi:
extras/aditi/*:
tests/valid/aditi*.m:
tests/invalid/aditi*.m:
	s/aditi_ui/aditi_mui
2000-05-05 06:08:23 +00:00
Tyson Dowd
79d75acdb0 Add impure functions to Mercury, clean up the purity module somewhat,
Estimated hours taken: 30

Add impure functions to Mercury, clean up the purity module somewhat,
fix some bugs in purity, update and expand the purity documentation,
and re-organize the purity checks.

Impure functions can be declared just like impure preds.
However, they can only be called in an explicit unification preceeded
by a purity level:

	impure X = some_impure_func(Y, Z)

The bug fixed was the fact that closures of impure predicates
were only being detected when using lambda syntax.  Purity information
was discarded and impure closures could be created like this:

	Pred = some_impure_pred

You could then use this predicate anywhere you like without any purity
declarations.

compiler/hlds_module.m:
	Add get_pred_id pred which will return the pred_id of a
	predicate matching a given type.  This is like
	get_pred_and_proc_id, but only gets the information we are
	interested in, and is semidet.
	We need a semidet version to handle cases where type inference
	cannot infer a type before the limit is reached, but we try to
	purity check this code.  (The bug mentioned above was stopping
	us from purity checking the test case for this before).

compiler/make_hlds.m:
	Check for "impure" unifications with expressions that are not
	function calls and issue appropriate error messages.
	When unravelling impure function call unifications, put the input
	parameter unifications (if any) before the actual call.
	Only mark the goal_info for the function call as impure.

compiler/mercury_to_goedel.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/prog_data.m:
compiler/prog_io.m:
compiler/prog_io_dcg.m:
compiler/prog_io_goal.m:
compiler/prog_util.m:
	Add purity information to unify goals.
	Don't assume unify goals are pure.

compiler/purity.m:
	Allow impure functions.
	Check unification goals for purity (not just lambda unification).
	Check unifications that are transformed into calls to make sure
	the call is purity correct.
	Put purity checking logic into separate predicates.
	Use an enum to return different errors and warnings.
	(The last two changes make it much easier to see the
	similarities between checking goals and checking predicates for
	purity correctness).
	Give different error messages for impure functions (highlight
	that you need to use them in an explicit unification).
	Handle unknown predicate lookups (can occur when unifying with
	a higher order term whose type could not be inferred).
	Add a few comments delineating where changes might need to be
	made to make foreign code impure by default in future.

compiler/notes/authors.html:
	Add Peter Schachte to the authors list.

doc/reference_manual.texi:
	Document impure functions.
	Expand more on what impure predicates/functions can do.
	Explain the concept of worst purity, and use it to explain the
	"inferred purity"/"declared purity" concepts.
	Make it more explicit that only impure goals obey
	strict-sequential like semantics.

tests/invalid/type_inf_loop.err_exp2:
	Fix this test case to reflect the new error message new that we
	check the purity of this code correctly (or rather, we correctly
	fail to be able to purity check this code).

tests/hard_coded/Mmakefile:
tests/hard_coded/purity.exp:
tests/hard_coded/purity.m:
tests/hard_coded/purity/Mmakefile:
tests/hard_coded/purity/impure_func_t1.m:
tests/hard_coded/purity/purity.m:
tests/hard_coded/purity/runtests:
	Remove purity tests from the hard_coded directory, give it a
	sub-directory of its own.

tests/invalid/Mmakefile:
tests/invalid/purity.err_exp:
tests/invalid/purity.m:
tests/invalid/purity_nonsense.err_exp:
tests/invalid/purity_nonsense.m:
tests/invalid/purity/Mmakefile:
tests/invalid/purity/impure_func_t2.err_exp:
tests/invalid/purity/impure_func_t2.m:
tests/invalid/purity/impure_func_t3.err_exp:
tests/invalid/purity/impure_func_t3.m:
tests/invalid/purity/impure_func_t4.err_exp:
tests/invalid/purity/impure_func_t4.m:
tests/invalid/purity/impure_func_t5.err_exp:
tests/invalid/purity/impure_func_t5.m:
tests/invalid/purity/impure_pred_t1.err_exp:
tests/invalid/purity/impure_pred_t1.m:
tests/invalid/purity/impure_pred_t2.err_exp:
tests/invalid/purity/impure_pred_t2.m:
tests/invalid/purity/purity.err_exp:
tests/invalid/purity/purity.m:
tests/invalid/purity/purity_nonsense.err_exp:
tests/invalid/purity/purity_nonsense.m:
tests/invalid/purity/runtests:
	Remove purity tests from the invalid directory, give it a
	sub-directory of its own.
2000-04-22 07:12:53 +00:00
Simon Taylor
20938c3dec Uncomment the Aditi sections of the Mercury documentation.
Estimated hours taken: 1

doc/reference_manual.texi
doc/user_guide.texi
	Uncomment the Aditi sections of the Mercury documentation.
2000-04-20 06:26:42 +00:00
Simon Taylor
7622eb1d36 Finish the implementation of Aditi updates.
Estimated hours taken: 120

Finish the implementation of Aditi updates.

compiler/hlds_goal.m:
	Refactor the aditi_builtin type so that operations with
	similar syntax and implementations are grouped together.

	Add operations to delete a single tuple (`aditi_delete') and
	to modify tuples (`aditi_bulk_modify').

compiler/*.m:
	Minor changes required by refactoring the aditi_builtin type.

compiler/make_hlds.m:
	Parse `aditi_delete' and `aditi_bulk_modify' goals.

	Parse a nicer syntax for `aditi_bulk_delete' and
	`aditi_bulk_insert' goals
	(e.g. aditi_bulk_delete(p(_, X, _) :- X > 2)).

compiler/rl_out.pp:
	For each base relation, generate RL procedures to apply
	deletions and modifications to the relation. `aditi_bulk_modify'
	takes a closure which produces tuples which contain both the
	attributes of the tuple to delete and the tuple to insert. The
	modification RL procedure performs two projections on the
	closure result to produce the tuples to delete and the tuples
	to delete.

	The input stream to the rl_PROC_delete RL instruction must contain
	only tuples taken from the relation to delete from -- the deletion
	is done using the tuple-id rather than the tuple contents.
	The generated deletion procedure performs a semi-join of the
	relation to delete from with the relation containing the
	tuples to delete.

compiler/rl.m:
	Add predicates to generate the names of the modification
	and deletion RL procedures generated for each base relation.

compiler/rl_exprn.m:
	Generate the projection expressions required by the modification
	RL procedures generated for each base relation.

	Generate the equi-join expressions required by the modification
	and deletion RL procedures generated for each base relation.

compiler/unify_gen.m:
	Implement code generation for `aditi_bottom_up' closures.

compiler/rl.m:
compiler/magic.m:
	Factor out the code used to create the name of the RL procedure
	used to interface top-down Mercury to Aditi, for use by unify_gen.m
	to generate `aditi_bottom_up' closures.

compiler/code_util.m:
	Add predicate code_util__make_user_proc_label, which constructs
	a label name from the given all the individual pieces of information
	used to construct it, rather than just a pred_id and proc_id.
	This is used to produce the RL procedure name for an `aditi_bottom_up'
	closure, so that the code doesn't have to work out what the pred_id
	of the magic sets transformed procedure is.

compiler/magic.m:
	Always create new procedures to interface Mercury to Aditi,
	to make it easier for unify_gen.m to work out what the name
	of the interface procedure is -- don't optimize the case of
	a predicate with no input arguments.

	Alter the goal generated for the interface procedures so
	that it doesn't matter whether the interface procedure
	and the procedure it interfaces to are compiled together
	by rl_gen.m -- the old code generated for these procedures
	assumed they were compiled separately, which wasn't always the
	case.

	Don't pass a `magic_info' through the code to generate the
	C interface procedures -- only the module_info field was
	required.

compiler/magic_util.m:
compiler/magic.m:
compiler/context.m:
	Don't pass a `magic_info' through
	magic_util__create_input_test_unifications --
	only the module_info and proc_info fields were used.

compiler/post_typecheck.m:
compiler/magic_util.m:
	Don't report errors for the second `aditi__state' argument
	of the closure passed to `aditi_bulk_modify'.

compiler/purity.m:
	Change the mode of the second `aditi__state' argument
	of the closure passed to `aditi_bulk_modify' to `unused'.

compiler/call_gen.m:
	Generate `aditi_delete' and `aditi_bulk_modify'.

	Remove the `aditi__state' from the tuple to insert passed
	to an `aditi_insert' or `aditi_delete' operation -- the relation
	on disk does not contain the `aditi__state' attribute.

extras/aditi/aditi.m:
	Implement the updates.

	Allocate all memory on the Mercury heap to avoid memory
	leaks when a transaction aborts.

	Uncaught exceptions within a transaction now cause
	the transaction to abort, and the exception is rethrown
	to the caller.

	If using trailing, add trail entries for the output relation
	and cursor created for a call to an Aditi procedure, so that
	they will be cleaned up if only one solution of the call
	is needed or if an exception is thrown.

	Include line numbers in the debugging messages if an Aditi API
	function fails.

compiler/llds.m:
compiler/*.m:
	Rename the `do_aditi_modify' label to `do_aditi_bulk_modify' -- we
	may eventually want to implement a modification goal type which
	doesn't produce all modified tuples before applying the update.

doc/reference_manual.texi:
	Document `aditi_delete' and `aditi_bulk_modify'.

	Add some extra spacing in the Aditi update section to
	improve readability.

tests/valid/aditi_update.m:
tests/invalid/aditi_update_errors.m:
tests/invalid/aditi_update_errors.err_exp:
tests/invalid/aditi_update_mode_errors.m:
tests/invalid/aditi_update_mode_errors.err_exp:
	Changed to fit in with the new syntax.

tests/valid/Mmakefile:
	Code generation for Aditi updates now works, so enable full
	compilation of the aditi_update.m test case, rather than
	just checking for errors.
2000-04-14 08:39:24 +00:00
Fergus Henderson
83660cb0c8 Apply some corrections that Warwick spotted in his
Estimated hours taken: 0.25

Apply some corrections that Warwick spotted in his
review of my recent trailing changes.

runtime/mercury_context.c:
	Fix a couple of bugs in init_context(): the ticket_counter
	should be initialized to 1, not 0, and we need to also
	initialize the ticket_high_water field.

compiler/notes/trailing.html:
doc/reference_manual.texi:
	Fix typos.
2000-03-22 14:45:43 +00:00
Fergus Henderson
a636a6ba82 Fix an inconsistency in the manual, which was using
Estimated hours taken: 0.25

doc/reference_manual.texi:
	Fix an inconsistency in the manual, which was using
	`multidet' and `multi' inconsistently: s/multidet/multi/g

library/string.m:
	Use `multi' rather than `multidet', to match the
	language reference manual.
2000-03-20 09:01:49 +00:00
Fergus Henderson
84c8146d0d Fix several bugs in the trail handling.
Estimated hours taken: 20

Fix several bugs in the trail handling.
Also improve the documentation of trailing, and add a new macro
MR_choicepoint_newer() to the public trailing interface.

The bugs which this change fixes are:
  - choice point ids were being reused after commits,
    rather than only after backtracking;
  - for if-then-elses with nondet conditions, the generated code was
    using MR_commit rather than MR_solve as the MR_untrail_reason;
  - for semidet disjunctions, when committing to a particular disjunct
    the generated code was not calling MR_reset_ticket(..., MR_commit)
    to invoke function trail entries, and was also leaking a trail ticket
  - the all-solutions predicates in std_util.m were leaking trail
    tickets (i.e. allocating them but not pruning or discarding them).

runtime/mercury_trail.h:
runtime/mercury_regorder.h:
runtime/mercury_regs.h:
runtime/mercury_wrapper.c:
runtime/mercury_context.h:
runtime/mercury_engine.h:
	A bunch of changes to add a new virtual register
	`MR_ticket_high_water':
	- in mercury_trail.h, add MR_ticket_high_water_var variable;
	- in mercury_regorder.h, add MR_ticket_high_water macro;
	- in mercury_regs.h, add MR_TICKET_HIGH_WATER_RN macro;
	- in mercury_wrapper.c, change
	  print_register_usage_counts() to handle
	  MR_TICKET_HIGH_WATER_RN.
	- in mercury_context.h and mercury_engine.h,
	  add code to save/restore this new register when
	  appropriate.

runtime/mercury_trail.h:
	- Change MR_store_ticket() so that it does
	  `MR_ticket_counter = ++MR_ticket_high_water'
	  rather than just `MR_ticket_counter++'.
	- Add new macros MR_prune_ticket() and MR_prune_tickets_to(),
	  which only reset MR_ticket_counter, not MR_ticket_high_water.
	- Change the old macros MR_discard_ticket() and MR_discard_tickets_to()
	  so that they reset both MR_ticket_high_water and MR_ticket_counter.
	- Add new macro MR_choicepoint_newer().
	- Enclose macro arguments in parentheses.
	- Some minor changes to the documentation.

doc/reference_manual.texi:
	Document MR_choicepoint_newer().
	Update the documentation to reflect the fact that exceptions
	are now a standard part of Mercury.
	Clarify the documentation in the "Avoiding Redundant Trailing"
	section, and add a longish example.

compiler/notes/trailing.html:
	Add some documentation on the trail and how we manage it.

compiler/llds.m:
compiler/mlds.m:
	Add new `prune_ticket' and `prune_tickets_to' instructions,
	corresponding to the new macros defined in runtime/mercury_trail.h.
	Comment out the `discard_tickets_to' instruction, since it
	is no longer used in the compiler (the MR_discard_tickets_to()
	macro is only used by library/exception.m and the debugger's
	retry command).
	Replace the duplicated documentation in mlds.m with a pointer
	to llds.m.

compiler/ite_gen.m:
compiler/code_gen.m:
compiler/code_info.m:
	Change the trail handling code generated after commits
	so that the ticket is pruned rather than discarded.

compiler/ite_gen.m:
	When generating the reset_ticket instruction for
	if-then-elses with nondet conditions, use `solve'
	rather than `commit' as the reset_trail_reason.

compiler/disj_gen.m:
	Add code to generate a reset_ticket(..., commit)
	instruction at the end of every non-last disjunct
	in semidet disjunctions.

compiler/dupelim.m:
compiler/livemap.m:
compiler/llds_common.m:
compiler/llds_out.m:
compiler/ml_elim_nested.m:
compiler/middle_rec.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/value_number.m:
compiler/vn_*.m:
	Trivial modifications to handle the changes to the
	trailing instructions.

library/exception.m:
	Change the trail handling code so that when the goal in an
	exception handler succeeds (rather than failing or throwing an
	exception), the trail ticket we created on entry to the
	handler is pruned rather than discarded.

library/std_util.m:
	Add a new impure predicate `discard_trail_ticket', which calls
	MR_discard_ticket(), and call it in `builtin_aggregate' and
	`do_while' to discard the ticket that gets allocated by the
	call to MR_store_ticket() in `get_registers'.
2000-03-20 05:27:30 +00:00
Fergus Henderson
6a7ade6973 Replace some old documentation about a planned
Estimated hours taken: 0.75

doc/reference_manual.texi:
	Replace some old documentation about a planned
	`unique [X]' quantifier with a description of
	the `promise_only_solution' function in the
	standard library.
2000-03-08 13:16:50 +00:00
Fergus Henderson
56b7456d88 Generalize the higher-order term syntax:
Estimated hours taken: 3

Generalize the higher-order term syntax:
in `Foo(Args)', allow Foo to be any term,
not just a variable.

doc/reference_manual.texi:
	Document the new higher-order term syntax.

library/parser.m:
	Implement the new higher-order term syntax.

tests/hard_coded/Mmakefile:
tests/hard_coded/higher_order_syntax2.m:
tests/hard_coded/higher_order_syntax2.exp:

NEWS:
	Mention this change.
2000-02-16 08:36:20 +00:00
Tyson Dowd
f9b942b30e Allow functions to be declared by supplying the determinism but not the
Estimated hours taken: 12

Allow functions to be declared by supplying the determinism but not the
modes (we assume the default modes).

compiler/make_hlds.m:
	Assume default modes if determinism is declared without modes
	in the :- func declaration.

compiler/prog_io.m:
	Don't give an error message for determinism without modes for
	function.

compiler/prog_io_goal.m:
	Update documentation to reflect default mode syntax.
	Assume default modes if determinism is declared without modes
	in lambda expressions.

compiler/prog_util.m:
	Mention that declaring modes for some but not all of the
	arguments of a function will be noticed in prog_io, so shouldn't
	be a concern in this code.

doc/reference_manual.texi:
	Document the new syntax.

tests/valid/Mmakefile:
tests/valid/func_default_modes.m:
	A test case for the new syntax.
2000-02-16 07:28:13 +00:00
Fergus Henderson
c7ae3c205f Fix some typos / formatting errors in the documentation
Estimated hours taken: 0.25

doc/reference_manual.texi:
	Fix some typos / formatting errors in the documentation
	of backquotes.
2000-02-11 05:04:05 +00:00
Fergus Henderson
5d081641d8 Some minor clarifications to the documentation of type classes.
Estimated hours taken: 0.25

doc/reference_manual.texi:
	Some minor clarifications to the documentation of type classes.
2000-02-11 05:00:36 +00:00