Commit Graph

121 Commits

Author SHA1 Message Date
Mark Brown
784dc26cab Fix bugs that were stopping *.res and *.out files being cleaned up properly.
Estimated hours taken: 0.5

Fix bugs that were stopping *.res and *.out files being cleaned up properly.

tests/Mmake.common:
tests/general/accumulator/Mmakefile:
tests/invalid/Mmakefile:
tests/misc_tests/Mmakefile:
tests/tabling/Mmakefile:
tests/term/Mmakefile:
tests/valid/Mmakefile:
tests/warnings/Mmakefile:
	Make cleaning tasks depend on (real)clean_local rather than
	(real)clean.  This is because tests/startup and tests/shutdown
	use the *_local targets.

tests/general/Mmakefile:
	Fix bugs in the recursive mmake calls.
1999-07-14 17:04:41 +00:00
Peter Ross
f897757c22 Update the .cvsignore file.
Estimated hours taken: 0.25

Update the .cvsignore file.
1999-07-14 00:56:21 +00:00
Simon Taylor
2725b1a331 Aditi update syntax, type and mode checking.
Estimated hours taken: 220

Aditi update syntax, type and mode checking.

Change the hlds_goal for constructions in preparation for
structure reuse to avoid making multiple conflicting changes.

compiler/hlds_goal.m:
	Merge `higher_order_call' and `class_method_call' into a single
	`generic_call' goal type. This also has alternatives for the
	various Aditi builtins for which type declarations can't
	be written.

	Remove the argument types field from higher-order/class method calls.
	It wasn't used often, and wasn't updated by optimizations
	such as inlining. The types can be obtained from the vartypes
	field of the proc_info.

	Add a `lambda_eval_method' field to lambda_goals.

	Add a field to constructions to identify which RL code fragment should
	be used for an top-down Aditi closure.

	Add fields to constructions to hold structure reuse information.
	This is currently ignored -- the changes to implement structure
	reuse will be committed to the alias branch.
	This is included here to avoid lots of CVS conflicts caused by
	changing the definition of `hlds_goal' twice.

	Add a field to `some' goals to specify whether the quantification
	can be removed. This is used to make it easier to ensure that
	indexes are used for updates.

	Add a field to lambda_goals to describe whether the modes were
	guessed by the compiler and may need fixing up after typechecking
	works out the argument types.

	Add predicate `hlds_goal__generic_call_id' to work out a call_id
	for a generic call for use in error messages.

compiler/purity.m:
compiler/post_typecheck.m:
	Fill in the modes of Aditi builtin calls and closure constructions.
	This needs to know which are the `aditi__state' arguments, so
	it must be done after typechecking.

compiler/prog_data.m:
	Added `:- type sym_name_and_arity ---> sym_name/arity'.

	Add a type `lambda_eval_method', which describes how a closure
	is to be executed. The alternatives are normal Mercury execution,
	bottom-up execution by Aditi and top-down execution by Aditi.

compiler/prog_out.m:
	Add predicate `prog_out__write_sym_name_and_arity', which
	replaces duplicated inline code in a few places.

compiler/hlds_data.m:
	Add a `lambda_eval_method' field to `pred_const' cons_ids and
	`pred_closure_tag' cons_tags.

compiler/hlds_pred.m:
	Remove type `pred_call_id', replace it with type `simple_call_id',
	which combines a `pred_or_func' and a `sym_name_and_arity'.

	Add a type `call_id' which describes all the different types of call,
	including normal calls, higher-order and class-method calls
	and Aditi builtins.

	Add `aditi_top_down' to the type `marker'.

	Remove `aditi_interface' from type `marker'. Interfacing to
	Aditi predicates is now handled by `generic_call' hlds_goals.

	Add a type `rl_exprn_id' which identifies a predicate to
	be executed top-down by Aditi.
	Add a `maybe(rl_exprn_id)'  field to type `proc_info'.

	Add predicate `adjust_func_arity' to convert between the arity
	of a function to its arity as a predicate.

	Add predicates `get_state_args' and `get_state_args_det' to
	extract the DCG state arguments from an argument list.

	Add predicate `pred_info_get_call_id' to get a `simple_call_id'
	for a predicate for use in error messages.

compiler/hlds_out.m:
	Write the new representation for call_ids.

	Add a predicate `hlds_out__write_call_arg_id' which
	replaces similar code in mode_errors.m and typecheck.m.

compiler/prog_io_goal.m:
	Add support for `aditi_bottom_up' and `aditi_top_down' annotations
	on pred expressions.

compiler/prog_io_util.m:
compiler/prog_io_pragma.m:
	Add predicates
	- `prog_io_util:parse_name_and_arity' to parse `SymName/Arity'
		(moved from prog_io_pragma.m).
	- `prog_io_util:parse_pred_or_func_name_and_arity to parse
		`pred SymName/Arity' or `func SymName/Arity'.
	- `prog_io_util:parse_pred_or_func_and_args' to parse terms resembling
		a clause head (moved from prog_io_pragma.m).

compiler/type_util.m:
	Add support for `aditi_bottom_up' and `aditi_top_down' annotations
	on higher-order types.

	Add predicates `construct_higher_order_type',
	`construct_higher_order_pred_type' and
	`construct_higher_order_func_type' to avoid some code duplication.

compiler/mode_util.m:
	Add predicate `unused_mode/1', which returns `builtin:unused'.
	Add functions `aditi_di_mode/0', `aditi_ui_mode/0' and
	`aditi_uo_mode/0' which return `in', `in', and `out', but will
	be changed to return `di', `ui' and `uo' when alias tracking
	is implemented.

compiler/goal_util.m:
	Add predicate `goal_util__generic_call_vars' which returns
	any arguments to a generic_call which are not in the argument list,
	for example the closure passed to a higher-order call or
	the typeclass_info for a class method call.

compiler/llds.m:
compiler/exprn_aux.m:
compiler/dupelim.m:
compiler/llds_out.m:
compiler/opt_debug.m:
	Add builtin labels for the Aditi update operations.

compiler/hlds_module.m:
	Add predicate predicate_table_search_pf_sym, used for finding
	possible matches for a call with the wrong number of arguments.

compiler/intermod.m:
	Don't write predicates which build `aditi_top_down' goals,
	because there is currently no way to tell importing modules
	which RL code fragment to use.

compiler/simplify.m:
	Obey the `cannot_remove' field of explicit quantification goals.

compiler/make_hlds.m:
	Parse Aditi updates.

	Don't typecheck clauses for which syntax errors in Aditi updates
	are found - this avoids spurious "undefined predicate `aditi_insert/3'"
	errors.

	Factor out some common code to handle terms of the form `Head :- Body'.
	Factor out common code in the handling of pred and func expressions.

compiler/typecheck.m:
	Typecheck Aditi builtins.

	Allow the argument types of matching predicates to be adjusted
	when typechecking the higher-order arguments of Aditi builtins.

	Change `typecheck__resolve_pred_overloading' to take a list of
	argument types rather than a `map(var, type)' and a list of
	arguments to allow a transformation to be performed on the
	argument types before passing them.

compiler/error_util.m:
	Move the part of `report_error_num_args' which writes
	"wrong number of arguments (<x>; expected <y>)" from
	typecheck.m for use by make_hlds.m when reporting errors
	for Aditi builtins.

compiler/modes.m:
compiler/unique_modes.m:
compiler/modecheck_call.m:
	Modecheck Aditi builtins.

compiler/lambda.m:
	Handle the markers for predicates introduced for
	`aditi_top_down' and `aditi_bottom_up' lambda expressions.

compiler/polymorphism.m:
	Add extra type_infos to `aditi_insert' calls
	describing the tuple to insert.

compiler/call_gen.m:
	Generate code for Aditi builtins.

compiler/unify_gen.m:
compiler/bytecode_gen.m:
	Abort on `aditi_top_down' and `aditi_bottom_up' lambda
	expressions - code generation for them is not yet implemented.

compiler/magic.m:
	Use the `aditi_call' generic_call rather than create
	a new procedure for each Aditi predicate called from C.

compiler/rl_out.pp:
compiler/rl_gen.m:
compiler/rl.m:
	Move some utility code used by magic.m and call_gen.m into rl.m.

	Remove an XXX comment about reference counting being not yet
	implemented - Evan has fixed that.

library/ops.m:
compiler/mercury_to_mercury.m:
doc/transition_guide.texi:
	Add unary prefix operators `aditi_bottom_up' and `aditi_top_down',
	used as qualifiers on lambda expressions.
	Add infix operator `==>' to separate the tuples in an
	`aditi_modify' call.

compiler/follow_vars.m:
	Thread a `map(prog_var, type)' through, needed because
	type information is no longer held in higher-order call goals.

compiler/table_gen.m:
	Use the `make_*_construction' predicates in hlds_goal.m
	to construct constants.

compiler/*.m:
	Trivial changes to add extra fields to hlds_goal structures.

doc/reference_manual.texi:
	Document Aditi updates.

	Use @samp{pragma base_relation} instead of
	@samp{:- pragma base_relation} throughout the Aditi documentation
	to be consistent with other parts of the reference manual.

tests/valid/Mmakefile:
tests/valid/aditi_update.m:
tests/valid/aditi.m:
	Test case.

tests/valid/Mmakefile:
	Remove some hard-coded --intermodule-optimization rules which are
	no longer needed because `mmake depend' is now run in this directory.

tests/invalid/*.err_exp:
	Fix expected output for changes in reporting of call_ids
	in typecheck.m.

tests/invalid/Mmakefile
tests/invalid/aditi_update_errors.{m,err_exp}:
tests/invalid/aditi_update_mode_errors.{m,err_exp}:
	Test error messages for Aditi updates.

tests/valid/aditi.m:
tests/invalid/aditi.m:
	Cut down version of extras/aditi/aditi.m to provide basic declarations
	for Aditi compilation such as `aditi__state' and the modes
	`aditi_di', `aditi_uo' and `aditi_ui'. Installing extras/aditi/aditi.m
	somewhere would remove the need for these.
1999-07-13 08:55:28 +00:00
Fergus Henderson
58eb75f18c Fix a quoting bug that caused the compiler to generate `.opt' files
Estimated hours taken: 1

Fix a quoting bug that caused the compiler to generate `.opt' files
containing syntax errors.

compiler/mercury_to_mercury.m:
compiler/hlds_out.m:
	Fix some more quoting problems: it was not properly quoting
	certain subterms when they occurred immediately before the final
	`.' at the end of a term.

tests/valid/intermod_quote2.m:
	Add some regression tests for the above bug fix.

tests/valid/Mmakefile:
	Fix a bug in the Mmakefile that meant that the intermod_quote
	test didn't work properly when --use-subdirs was enabled.
1999-06-09 16:39:47 +00:00
Zoltan Somogyi
dc03496d06 Rewrite significant parts of minimal model tabling so that it works
Estimated hours taken: 130

Rewrite significant parts of minimal model tabling so that it works
in a much wider variety of situations, including coups. Also, clean up
the tabling implementation to make it more maintainable, and introduce
a new grade component, .mm, that enables minimal model tabling.
(Minimal model tabling requires distributed fat, and we don't want to
incur such costs unless necessary.)

compiler/options.m:
	Add a new option --use-minimal-model, which for now is documented
	as "not for general use". This option is a grade option, and is
	required if minimal model tabling is to work.

compiler/handle_options.m:
	When --use-minimal-model is given, do not allow nondet frame hijacks,
	since minimal model tabling cannot cope with hijacks.

	Make --use-minimal-model a grade component.

compiler/code_info.m:
	When --use-minimal-model is given, insert calls to MR_commit_{mark,cut}
	around goals being committed across. This is now necessary, so that we
	can detect and handle sitations where a goal being committed across
	starts but does not complete a tabled goal.

compiler/table_gen.m:
	Rename many of the tabling helper predicates, using a naming scheme
	that separates predicates used for model_non procedures from those
	used to implement simpler forms of tabling, while bringing out
	the parallels between these two sets of predicates.

	When calls to two tabling helper predicates always occur
	one after the other, merge the two into one.

	Generate and use more meaningful variable names; having all of the
	several variables inserted by this transformation named TableVar
	was quite confusing.

library/private_builtin.m:
	Reorganize this file, to separate out the different sections.
	The contents of the non-tabling sections were not modified, only
	moved around.

	Rename the predicates referred to by table_gen.m.

	Move most of the type declarations and complex code out of here,
	into runtime/mercury_tabling.c. This makes it easier to debug them,
	since (a) creating a new executable is quicker, since you don't have
	to wait for lots of mercury compiler invocations, and (b) gdb doesn't
	get confused by #line directives. It also makes it easier to write
	them, since you don't have to !&(*U&( remember to double all your
	double quotes and to backslash all your backslashes.

runtime/mercury_grade.h:
	Include a grade component reflecting whether MR_USE_MINIMAL_MODEL
	is defined.

runtime/mercury_conf_param.h:
	Document MR_USE_MINIMAL_MODEL.

runtime/mercury_stacks.[ch]:
	The changes to tabling require the addition of two new stacks,
	the generator stack and the cut stack. This module defines the
	structures of the frames of these stacks and provides the
	operations on these stacks.

	The header file also contains some additional macros that return
	the addresses of fixed nondet stack slots, not their contents,
	for use by tabling code.

runtime/mercury_context.[ch]:
runtime/mercury_memory.[ch]:
runtime/mercury_wrapper.[ch]:
	Declare and set up the two new stacks, both in saved contexts and in
	the active context, if MR_USE_MINIMAL_MODEL is defined.

runtime/mercury_regorder.h:
	Add four new global virtual machine registers to hold pointers
	to the memory areas of the two new stacks and the current offsets
	within them. These are defined whether MR_USE_MINIMAL_MODEL is defined
	or not, since the cost is minimal and the potential bugs we avoid
	would be hard to track down.

runtime/mercury_engine.h:
runtime/mercury_wrapper.c:
	Add support for a new debugging flag, -dS, which prints the contents
	of the nondet stack at several points during tabling.

runtime/mercury_tabling.[ch]:
	The implementation of the new tabling system. Much of the new code here
	is stuff moved from library/private_builtin.m, but in a significantly
	rewritten form. There is also substantial new code, e.g. to handle
	the extension of saved stack segments, and to manage dependencies
	between subgoals in general.

	Improve the documentation considerably.

	Replace lists stored as Mercury data structures with lists stored
	as linked structures in the usual C fashion. This allows us to use
	debuggers such as ddd on these data structures, whose complexity
	requires this.

	Ensure that global names start with MR_.

runtime/mercury_init.h:
	Explicitly include mercury_regs.h at the start. Without this,
	we get an error, because now mercury_wrappers.h, which mercury_init.h
	includes, also includes mercury_regs.h, but not before functions
	have been declared.

runtime/Mmakefile:
	Refer to the new file mercury_stacks.c (mercury_stacks.h already
	existed, but the module consisted entirely of macros.)

	Fix a sorting error.

scripts/{init,parse,final}_grade_options.sh-subr:
scripts/mgnuc.in:
	Handle the new grade component.

tests/tabling/*
	Add several new test cases that we now pass, most of which we couldn't
	pass before. Also add some new test cases that we don't pass yet,
	due to interactions between tabling and negated contexts.

trace/mercury_trace_internal.c:
	If MR_USE_MINIMAL_MODEL is defined, add a new command to print
	the generator stack. (The new command is deliberately not documented
	in doc/mdb_doc yet, since (a) it is intended for developers only,
	and (b) there is no way to test MR_USE_MINIMAL_MODEL in mdb_doc.)
1999-04-20 11:48:56 +00:00
Fergus Henderson
6f1f6bcb17 Fix some bugs where we were not properly escaping special characters in
Estimated hours taken: 0.75

Fix some bugs where we were not properly escaping special characters in
C strings in the generated code.

compiler/llds_out.m:
	Change a number of places to call output_quoted_c_string instead of
	io__write_string, so that special characters will be properly escaped.
	Add new predicate llds_out__quote_c_string, for use by pragma_c_gen.m.

compiler/pragma_c_gen.m:
	Call llds_out__quite_c_string, to ensure that special characters
	in the generated "pragma_c_raw_code" are properly escaped.

tests/valid/int64.m:
tests/valid/Mmakefile:
	Regression test for the above-mentioned bug fix.
1999-01-27 08:34:38 +00:00
Fergus Henderson
c62f8aa480 Fix a bug with unique mode inference.
Estimated hours taken: 4

Fix a bug with unique mode inference.

compiler/modes.m:
compiler/unify_proc.m:
	When doing unique mode inference, save a copy of the old
	procedure bodies, and use this to restore the old procedure
	bodies before each pass.  This avoids problems where
	modes.m was doing optimizations based on incomplete
	information obtained in passes before the fixpoint.

	Note that we already did this for ordinary mode inference, by
	copying the clauses from the clauses_info, so this was only a
	problem for unique mode inference.  But I've also changed that
	code so that doesn't copies stuff from the clauses_info before
	the first pass, since that is already done by post_typecheck.m.
	Now it only does does the copying for the second and subsequent
	passes.

tests/valid/Mmakefile:
tests/valid/uniq_mode_inf_bug.m:
	Add a test case for the above-mentioned bug.
1998-11-11 00:28:02 +00:00
Fergus Henderson
3918c620e4 Fix a bug: according to the ISO Prolog standard, it should allow
Estimated hours taken: 0.5

library/parser.m:
	Fix a bug: according to the ISO Prolog standard, it should allow
	terms of the form `{}(foo)' or `[](foo)'.

tests/valid/Mmakefile:
tests/valid/parsing_bug.m:
tests/valid/parsing_bug_main.m:
	Regression test.
1998-11-11 00:13:43 +00:00
Fergus Henderson
2f91d35f3f Fix a bug introduced by my earlier change to add the new alternative
Estimated hours taken: 0.5

compiler/make_hlds.m:
	Fix a bug introduced by my earlier change to add the new alternative
	`exported_to_submodules' to the `import_status' type: I forgot to add
	a clause for that alternative to the predicate `combine_status_2/3'.
	(The compiler didn't complain because the pred was semidet.)

tests/valid/Mmakefile:
tests/valid/nested_mod_type_bug.m:
	Regression test.
1998-11-10 22:23:06 +00:00
Simon Taylor
cc5f924841 Fix a loop in inst_MSG caused by not keeping track
Estimated hours taken: 1

compiler/pd_util.m:
	Fix a loop in inst_MSG caused by not keeping track
	of the set of already expanded insts.

tests/valid/deforest_loop.m:
	Regression test.
1998-11-03 05:32:03 +00:00
Simon Taylor
de55141f43 Fix a bug - deforestation and simplify rerun quantification
Estimated hours taken: 1

compiler/simplify.m:
	Fix a bug - deforestation and simplify rerun quantification
	which can introduce new variables, but these variables were
	not in the proc_info in the predicate table which det_analysis
	looks up.

tests/valid/deforest_rerun_det.m:
	Test case.
1998-11-03 05:28:31 +00:00
Zoltan Somogyi
68a6586ca4 Fix bugs in the handling of temporaries.
Estimated hours taken: 10

Fix bugs in the handling of temporaries.

compiler/code_info.m:
	Reorganize the way temporary slots are handled. Create a stack slot
	to slot_contents map that is part of the permanent state, so each
	slot can be used for only one purpose within a procedure; this is
	to make garbage collection of these slots possible. Make the set
	of temporary slots in use be part of the location dependent state.

	At the ends of branched control structures, consider a temp slot
	in use if it was in use at the end of any branch. (Previously,
	we considered it live after the control structure if it was live
	at the end of the last branch. We got that right for branched
	structures that manipulate temp slots, i.e. disjunctions and
	if-then-elses, but we got it wrong for switches.

	Rename some predicates to get rid of the double meaning of the word
	"discard" as applied to a temporary, which used to mean either
	"release the slot" or "execute the discard_ticket operation".
	It now means only the latter; the word "release" refers to the former.

compiler/disj_gen.m:
compiler/ite_gen.m:
	Conform to the new method of handling temporary slots.

tests/valid/complex_failure.m:
tests/valid/semi_fail_in_non_ite.m:
	Copies of the test cases from tests/general.

tests/valid/Mmakefile:
	Enable the new test cases, running them with --use-trail.

	Unfortunately, we cannot just specify --use-trail for them
	in tests/general, since that would cause a link error in the usual
	case that the runtime being linked with is not in a trailing grade.
1998-11-03 01:36:00 +00:00
David Overton
2ec641b797 Fix a bug with quoting of module-qualified terms in .opt files.
Estimated hours taken: 0.5

Fix a bug with quoting of module-qualified terms in .opt files.
Add a test case for this bug.

compiler/hlds_out.m:
	Add a version of `hlds_out__write_functor' which has a
	`needs_quotes' argument.  Call this new predicate from
	`hlds_out__write_qualified_functor' to ensure that functors
	are properly quoted after the `:'.

compiler/mercury_to_mercury.m:
	Export `mercury_output_term/6' so it can be called by
	`hlds_out__write_functor/7'.

tests/valid/Mmakefile:
	Add the new test case.

tests/valid/intermod_quote.m:
tests/valid/intermod_quote2.m:
	New test case for this bug.
1998-10-28 01:52:03 +00:00
Zoltan Somogyi
c10175956e Ignore the CLEAN file.
Estimated hours taken: 0.1

tests/*/.cvsignore:
	Ignore the CLEAN file.
1998-09-30 04:23:44 +00:00
Fergus Henderson
ac2d173322 Disable the typeclass related tests in jump.*' and fast.*'
Estimated hours taken: 0.5

tests/valid/Mmakefile:
	Disable the typeclass related tests in `jump.*' and `fast.*'
	grades, since the `func_method.m' tests was failing in those
	grades due to the initializer for the base_typeclass_info
	containing a pointer and hence being non-const in those grades,
	resulting in an error from gcc.
1998-09-21 11:27:18 +00:00
Simon Taylor
ddfcaa0818 Fix a bug in the computation of the modes of introduced
Estimated hours taken: 0.5

compiler/lambda.m:
	Fix a bug in the computation of the modes of introduced
	predicates.

tests/valid/lambda_output.m:
	Test case.
1998-09-10 06:30:21 +00:00
Simon Taylor
2727699e93 Fix a bug where cse_detection failed to hoist a common deconstruction for
Estimated hours taken: 5

Fix a bug where cse_detection failed to hoist a common deconstruction for
a one-armed switch out where switch_detection expected it to, due to a
call getting in the way. This resulted in switch_detection not finding
a switch necessary to prove determinism correctness.

compiler/switch_detection.m:
compiler/cse_detection.m:
	Make both modules use the same code to find deconstructions of
	non-local variables of disjunctions.

tests/valid/switch_detection_bug2.m:
	Test case, taken from samples/diff.
1998-09-10 06:18:48 +00:00
Fergus Henderson
2bf6b45696 Another fix to make things work with my change to
Estimated hours taken: 0.1

Another fix to make things work with my change to
ensure that the declarations and definitions for data constants
specify the same linkage (extern or static).

tests/valid/intermod_lambda.m:
	Add definitions for types which were declared but not defined.
1998-09-04 10:12:42 +00:00
Fergus Henderson
381b7dc22d Another fix to make things work with my change to
Estimated hours taken: 0.5

Another fix to make things work with my change to
ensure that the declarations and definitions for data constants
specify the same linkage (extern or static).

tests/valid/headvar_not_found.m:
tests/valid/subtype_switch.m:
	Add definitions for types which were declared but not defined.
1998-09-04 10:08:56 +00:00
David Jeffery
6fbaea4104 Added missing ".m" from the end of a filename.
Estimated hours taken: 0.001

tests/valid/Mmakefile:
	Added missing ".m" from the end of a filename.
1998-08-04 03:44:50 +00:00
David Jeffery
6145542814 Add a test case for a function as a typeclass method.
Estimated hours taken: 0.1


tests/valid/typeclasses/func_method.m:
        Add a test case for a function as a typeclass method. The non-locals
        were not being set correctly, which caused a software error in this
        case.
tests/valid/typeclasses/Mmakefile:
        Turn this test on.
1998-07-29 06:28:17 +00:00
Fergus Henderson
ce012270fb Change the tests for grade jump' and fast' so that they also
Estimated hours taken: 1

tests/valid/Mmakefile:
tests/debugger/Mmakefile:
	Change the tests for grade `jump' and `fast' so that they also
	catch grades `jump.gc', `fast.gc', etc.
1998-07-12 18:15:16 +00:00
David Jeffery
51f11d354e When building the type-infos to be packaged inside a typeclass-info,
compiler/polymorphism.m:
        When building the type-infos to be packaged inside a typeclass-info,
        apply the variable type bindings first.

tests/valid/instance_unconstrained_tvar.m:
        Test case for this.
tests/valid/Mmakefile:
        Turn this test on. Also turn another test on which I mistakenly
        turned off in my previous commit (because the test was failing).
1998-06-19 00:43:17 +00:00
David Jeffery
e4fba268ec Fix test case... the compiler was getting tripped up by a different bug than
Estimated hours taken: 1/4

Fix test case... the compiler was getting tripped up by a different bug than
the one this was meant to be testing.

ts/valid/instance_superclass.m:
	Fixed so it doesn't have an unbound type variable.
	(Actually, I don't really see why the compiler thinks it is unbound).
1998-06-18 04:11:45 +00:00
David Jeffery
7e8fbfcb1a New typeclass test case.
Estimated hours taken: 1/4

New typeclass test case.

tests/valid/instance_superclass.m:
	New test case.
tests/valid/Mmakefile:
	Updated to run the new test.
1998-06-18 04:03:23 +00:00
Fergus Henderson
eae7eec887 Allow modules to be put in source files whose names do not directly match
Estimated hours taken: 10

Allow modules to be put in source files whose names do not directly match
their the module names.  When looking for the source for a module such
as `foo:bar:baz', search for it first in `foo.bar.baz.m', then in `bar.baz.m',
and finally in `baz.m'.

compiler/prog_io.m:
	Change prog_io__read_module so that it returns the name of
	the module read, as determined by the `:- module' declaration.
	Add predicate `check_module_has_expected_name', for checking
	that this name matches what was expected.

compiler/modules.m:
	Add read_mod_from_file, for reading a module given the file name,
	and generated_file_dependencies, for generating the dependencies
	of a module given the file name.  (As opposed to the module name.)
	Change read_mod and read_mod_ignore_errors so that they
	search for `.m' files as described above, and return the name
	of the source file read.
	Also improve the efficiency of read_dependencies slightly:
	when reading in `.int' files, there's no need to call
	split_into_submodules, because we generate a seperate
	`.int' file for each submodule anyway.

compiler/mercury_compile.m:
	Change the handling of command-line arguments.
	Arguments ending with `.m' are assumed to be file names,
	and other arguments are assumed to be module names.
	For file names, call read_mod_from_file instead of read_mod.

compiler/handle_options.m:
	Change help message to reflect the above change to the semantics
	of command-line arguments.

compiler/intermod.m:
compiler/trans_opt.m:
	Fix a bug: call prog_io__read_opt_file instead of prog_io__read_module.

doc/user_guide.texi:
	Document the above change to the semantics of command-line arguments.
	Update the "libraries" chapter to reflect our support for nested
	modules.

tests/*/*.m:
tests/*/*.exp:
	Fix a few incorrect module names in `:- module' declarations.
1998-05-29 08:57:42 +00:00
Zoltan Somogyi
564d358da3 Avoid about half of the slow "mmake realclean"s required by a bootcheck.
Estimated hours taken: 0.5

Avoid about half of the slow "mmake realclean"s required by a bootcheck.

tests/*/runtests:
	Concentrate all the actions performed before the test and after
	a successful tests (both of which involve an "mmake realclean")
	into two scripts, tests/{startup,shutdown}.

tests/shutdown:
	Clean up the directory, and touch the file CLEAN.

tests/startup:
	If the file CLEAN exists and is the most recent file in the directory,
	consider the directory clean to beging with. Otherwise, run mmake
	realclean.
1998-05-13 04:06:38 +00:00
Fergus Henderson
f3b7548ac4 Fix a problem reported by Baudouin Le Charlier <ble@info.fundp.ac.be>
where switch detection was getting confused by explicit existential
quantifications.

compiler/switch_detection.m:
	When detecting switches, traverse through some/2 goals.
	Also simplify the code a bit.

tests/valid/Mmakefile:
tests/valid/some_switch.m:
	Regression test for the above change.
1998-05-12 17:05:06 +00:00
Fergus Henderson
49c25842cf Fix a problem reported by Baudouin Le Charlier <ble@info.fundp.ac.be>
where switch detection was getting confused by explicit existential
quantifications.

compiler/switch_detection.m:
	When detecting switches, traverse through some/2 goals.
	Also simplify the code a bit.

tests/valid/Mmakefile:
tests/valid/some_switch.m:
	Regression test for the above change.
1998-05-12 17:05:04 +00:00
Zoltan Somogyi
cd31eecf88 When reporting the results, print the options that controlled
Estimated hours taken: 0.2

tests/runtests:
tests/*/runtests:
	When reporting the results, print the options that controlled
	the tests, so you don't have to search for them.

tests/*/runtests:
	Clean up the directory if the tests are successful, in order
	to reduce disk space usage.
1998-04-23 09:28:39 +00:00
Fergus Henderson
40f7fad627 Fix some code rot in the rules for `make clean';
Estimated hours taken: 0.5

Makefile:
tests/valid/Mmakefile:
tests/invalid/Mmakefile:
	Fix some code rot in the rules for `make clean';
	amoung other things, change them so that they
	handle `--use-subdirs' correctly.
1998-04-09 03:59:12 +00:00
Fergus Henderson
5653ad9190 Change a hard-coded test for `$file.o' so that it will
Estimated hours taken: 0.25

tests/valid/runtests:
tests/valid/Mmakefile:
	Change a hard-coded test for `$file.o' so that it will
	work with --use-subdirs.
1998-03-30 13:25:05 +00:00
Fergus Henderson
7ebc79e927 Fix some problems with the `--use-subdirs' option.
Estimated hours taken: 6

Fix some problems with the `--use-subdirs' option.
The compiler itself now compiles and bootstraps fine with --use-subdirs.

compiler/modules.m:
	Put `.h' files in the source directory, rather than
	in the `Mercury/hs' subdirectory.

compiler/mercury_compile.m:
scripts/Mmake.rules:
	If `--use-subdirs' is enabled, pass `-I.' to the C compiler,
	so that #include statements work relative to the source directory
	rather than relative to the `Mercury/cs' subdirectory.

scripts/Mmake.vars.in:
	Define $(cs_subdir), $(os_subdir) etc. variables;
	these are set to the directory to use for .c, .o, etc. files,
	(including the trailing `/'), or to the empty string,
	if --use-subdirs is not set.

scripts/Mmake.rules:
	Use $(cs_subdir), $(os_subdir) etc. to avoid the code
	duplication created by my previous change to handle
	--use-subdirs.
	Also add lots of comments, and reorder the code
	in a more logical order.

Mmakefile:
library/Mmakefile:
compiler/Mmakefile:
profiler/Mmakefile:
tests/term/Mmakefile:
tests/valid/Mmakefile:
	Use $(cs_subdir), $(os_subdir) etc. to fix a few hard-coded
	file-names (e.g. *.dep, *_init.[co], tree234.o) that were
	used in some of the rules.

library/Mmakefile:
	Add `rm -f tags' to the rule for `mmake realclean'.

tools/bootcheck:
	Add `--use-subdirs' option (defaults to setting of the
	MMAKE_USE_SUBDIRS environment variable).
	Change the code which compares the stage2 & stage3 C files
	to use the appropriate location for them based on the
	setting of this option.
1998-03-20 02:58:33 +00:00
Simon Taylor
c76b0fb370 Fix a bug: recompute_instmap_delta wasn't recomputing
Estimated hours taken: 1

compiler/mode_util.m
	Fix a bug: recompute_instmap_delta wasn't recomputing
	the instmap_deltas of lambda goals.

tests/valid/lambda_recompute.m
	Regression test.
1998-02-28 11:33:46 +00:00
Simon Taylor
4ab55e32a5 Fix a bug in the optimization where polymorphism.m passes a
Estimated hours taken: 5

Fix a bug in the optimization where polymorphism.m passes a
base_type_info in place of a type_info for non-polymorphic types.
The type of the variable was `base_type_info' not `type_info'.
This caused inlining.m to be unable to compute a type substitution,
and code_util__cons_id_to_tag aborted on an unsubstituted type
variable.

compiler/mercury_builtin.m
compiler/code_util.m
	Add a new builtin, unsafe_type_cast/2, used by common.m
	to preserve type correctness.
	Make unsafe_promise_unique/2 a builtin, since it is basically
	the same as unsafe_type_cast/2.

compiler/polymorphism.m
	Set the type of a `base_type_info' passed where a `type_info'
	is expected to `type_info'.
	Don't add the type_info argument for unsafe_type_cast, since it is
	not needed and would make the code in common.m more complicated.

compiler/common.m
	Generate a call to unsafe_type_cast rather than an assignment
	unification when the assignment would not be type correct.

tests/valid/inlining_bug.m
	Regression test.

tests/general/common_type_cast.m
tests/general/common_type_cast.exp
	Test of type casts.
1998-02-25 00:12:16 +00:00
Simon Taylor
e3e2a9a870 Add the test case for modules.m which was committed
Estimated hours taken: 0.01

tests/valid/Mmakefile
	Add the test case for modules.m which was committed
	previously to the list of tests.
1998-02-09 00:44:42 +00:00
Simon Taylor
9d07a2ccdb Fix a bug reported by Tomas By which caused multiple
Estimated hours taken: 0.5

Fix a bug reported by Tomas By which caused multiple
definition errors when two modules used a third
module, and one of the modules imported the other.

compiler/modules.m
	Delay processing of short interfaces until all long
	interfaces have been read to avoid reading both
	the long and short interface for a module.

tests/valid/module_*.m
	Add a test case.
1998-02-07 09:55:52 +00:00
Simon Taylor
4dbad44fc9 Remove some mode errors which were not detected
Estimated hours taken: 0.1

tests/valid/intermod_lambda2.m
tests/valid/intermod_test2.m
	Remove some mode errors which were not detected
	because mode analysis was never run - only `.opt'
	files are produced for these modules.
1998-02-04 12:10:42 +00:00
Fergus Henderson
fbe9a332a6 Modify the code to avoid a (spurious in this case, as it happens)
Estimated hours taken: 0.25

tests/valid/agc_graph.m:
	Modify the code to avoid a (spurious in this case, as it happens)
	"Sorry, not implemented" message for abstract exported polymorphic
	equivalence types whose bodies have fewer type variables than their
	heads.
1998-01-29 14:21:33 +00:00
Fergus Henderson
cabfd6bd1a Fix a problem where the use of explicit quantifiers lead to
Estimated hours taken: 1

compiler/quantification.m:
	Fix a problem where the use of explicit quantifiers lead to
	spurious warnings about unbound type variables, by deleting
	explicit quantifiers during quantification (once the
	variables have been renamed apart, the explicit quantifiers
	are no longer needed).

tests/valid/Mmakefile:
tests/valid/explicit_quant.m:
	Regression test.
1998-01-22 07:29:47 +00:00
Fergus Henderson
e22c6fd3d2 Fix a bug introduced in stayl's changes to add support for
Estimated hours taken: 1

compiler/modules.m:
	Fix a bug introduced in stayl's changes to add support for
	`use_module': it was not reading in the `.int2' files
	for modules indirectly imported from `.int' files.

tests/valid/Mmakefile:
tests/valid/module_a.m:
tests/valid/module_b.m:
tests/valid/module_c.m:
tests/valid/module_d.m:
	A regression test for the above-mentioned bug.
1998-01-09 12:35:16 +00:00
Tyson Dowd
e96e89c657 Turn off the accurate GC tests for "jump" and "fast" grades.
Estimated hours taken: 0.5

tests/valid/Mmakefile:
tests/valid/runtests:
	Turn off the accurate GC tests for "jump" and "fast" grades.
1998-01-06 04:16:17 +00:00
Fergus Henderson
82744e5b95 Add new options for disabling some warnings, so that they
Estimated hours taken: 1

Add new options for disabling some warnings, so that they
can be disabled by `--inhibit-warnings'.

compiler/options.m:
	Add new options `warn-missing-module-name'
	and `warn-wrong-module-name' (enabled by default),
	and ensure that `--inhibit-warnings' disables these options.

compiler/prog_io.m:
	Add code to conditionalize the printing of warnings
	based on the settings of the new options.

doc/user_guide.texi:
	Document the new options.

tests/valid/Mmakefile:
tests/valid/inhibit_warn_test.m:
	A regression test.
1998-01-05 08:40:43 +00:00
Fergus Henderson
0b337ee174 Handle inference of mostly-unique (not just unique) modes.
Estimated hours taken: 25

Handle inference of mostly-unique (not just unique) modes.

compiler/unique_modes.m:
	Change the handling of calls so that if the mode originally selected
	by ordinary mode analysis (modes.m) won't work, then it now calls
	modecheck_call_pred to introduce a new mode for the predicate.

compiler/unify_proc.m:
	Generalize the existing "unify request queue" so that
	it can handle requests for any kind of predicate, not
	just for unification predicates, and hence rename the
	`unify_request' table which contains it as the `proc_request' table.

compiler/hlds_module.m:
	Rename the `unify_request' table as the `proc_request' table.

compiler/modecheck_call.m:
	When introducing new modes for predicates, do this by adding them
	to the request queue.  This ensures that when we do get around
	to processing predicates added in unique mode analysis, we will
	run mode analysis, switch detection, and determinism analysis
	before doing unique mode analysis.  To make this work, we
	need to pass down a `maybe(determinism)' argument indicating
	the determinism of the newly added procedure.  unique_modes.m
	sets this to the determinism inferred for the mode originally
	inferred by modes.m.  That should be OK, because uniqueness
	should not affect determinism.
	Also change modecheck_call_proc to return a `Changed' flag
	indicating whether we need to rerun fixpoint analysis.
	And change `get_var_insts_and_lives' to return `dead' for
	mostly_unique modes, not just for unique modes, so that
	we can infer `mdi' modes.

compiler/modes.m:
	Instead of analyzing everything to a fixpoint, and then
	analyzing the queued unification procedures, change it so
	that analysis of queued procedures is part of each fixpoint
	iteration.
	When doing ordinary mode analysis for calls, pass `no' as the
	new `maybe(determinism)' argument to modecheck_call_pred.

compiler/constraint.m:
compiler/cse_detection.m:
	Ignore the new output argument for modecheck_call_proc.

compiler/mode_util.m:
	Add code to insts_to_mode to recognize `muo', `mui', and `mdi'
	modes and use the corresponding abbreviations (previously this
	was done only for `uo', `ui', `di', `in' and `out').

tests/valid/mostly_uniq_mode_inf.m:
	A test case for the above change.
1998-01-05 07:26:32 +00:00
Fergus Henderson
239e96ec59 Clean up the handling of unbound type variables.
Estimated hours taken: 8

Clean up the handling of unbound type variables.
Fix a bug with unbound type variables in lambda expressions.
Run purity analysis, modechecking etc. even if there were type errors.

compiler/mercury_compile.m:
	Run purity analysis, modechecking etc. even if there were type
	errors.  This fixes a bug (inconsistency between the code and
	the comments) that seems to have been introduced in stayl's
	change to mercury_compile.m (revision 1.25) to add intermodule
	unused argument elimination: the comment said "continue,
	even if type checking found errors", but the code did not
	continue.

	This change was needed to ensure that we still report a warning
	message about unused type variables for tests/invalid/error2.m;
	without it, we stop after type checking and don't do purity
	analysis, and so don't report the warning.

compiler/typecheck.m:
compiler/purity.m:
	Move the code for checking for unbound type variables
	from typecheck.m to purity.m.  It needs to be done
	*after* type inference has been completed, so it
	can't be done in the ordinary type checking/inference
	passes.  Add code to purity.m to bind the
	unbound type variables to the builtin type `void'.

compiler/polymorphism.m:
	Comment out old code to bind unbound type variables
	to `void'; the old code was incomplete, and this
	is now done in purity.m.

compiler/notes/compiler_design.html:
	Document the above changes.

tests/valid/Mmakefile:
tests/valid/unbound_tvar_in_lambda.m:
	Regression test for the above-mentioned bug with unbound type
	variables in lambda expressions.

tests/warnings/singleton_test.exp:
tests/invalid/errors2.err_exp:
	Change the expected warning message for unbound type variables.
	The error context is not as precise as it used to be, I'm afraid:
	we only know which function/predicate the error occurred in,
	not which clause.  Also it now comes out in a different order
	relative to the other error messages.

tests/invalid/errors2.err_exp:
tests/invalid/funcs_as_preds.err_exp:
	Add some new error/warning messages that are output now that
	we run mode and determinism analysis even if there are type errors.
1998-01-02 00:11:41 +00:00
Fergus Henderson
9fc30fa8bb Change unique mode analysis (unique_modes.m) so that it does the same
Estimated hours taken: 4

Change unique mode analysis (unique_modes.m) so that it does the same
fixpoint analysis that ordinary mode analysis (modes.m) does.

This is a first step towards mode inference of "mostly-unique" modes.
Unique mode analysis still won't introduce any new modes, but it may
now change the final insts of inferred modes from `unique' to `mostly_unique'.

The next step (not included in this diff) will be to change the handling of
calls in unique_modes.m so that it does introduce new modes.

Also change things so that the inferred modes are normally printed
only after unique mode analysis, with determinism annotations attached.

compiler/modes.m:
	Add an extra WhatToCheck parameter to lots of predicates,
	so they can also be used for checking unique modes.
	Add a few small new bits of code to handle the
	`WhatToCheck = check_unique_modes' case.

compiler/unique_modes.m:
	Call the routines in modes.m rather than special casing things.
	The checking of goals is still special-cased, since for
	example unique_modes does not do reordering, but the traversal
	of modules and procedures now uses code from modes.m.

compiler/mode_errors.m:
	Add an extra bool parameter to write_mode_inference_messages
	indicating whether or not to print determinism annotations.

tests/valid/Mmakefile:
tests/valid/mostly_uniq_mode_inf.m:
	Test case for the above change.
1997-11-24 23:10:38 +00:00
Fergus Henderson
bd0cb6e90f Fix duplicate mode declaration errors.
Estimated hours taken: 0.25

tests/valid/qualified_cons_id.m:
library/int.m:
	Fix duplicate mode declaration errors.
1997-11-23 05:19:24 +00:00
Fergus Henderson
5d0414bbab For the tests of accurate gc, just add `--gc accurate'
Estimated hours taken: 0.5

tests/Mmake.common:
tests/valid/Mmakefile:
	For the tests of accurate gc, just add `--gc accurate'
	to GRADEFLAGS, rather than setting GRADE=asm_fast.agc.
	Otherwise the tests fail on systems for which we
	don't support asm_fast.* grades.
1997-11-22 17:14:02 +00:00
Andrew Bromage
04125e10ba Fix a bug in the writing of .opt files.
Estimated hours taken: 1

Fix a bug in the writing of .opt files.

The problem occurs when you have a pragma inline declaration for an
exported function.  The declaration:

:- func addone(int) = int.
:- pragma inline(addone/1).
addone(I) = I + 1.

gets written to the .opt file as:

:- pragma inline((foo:addone)/2).

That is, the arity of the _predicate_ version is written rather than
the arity of the _function_.

compiler/intermod.m:
compiler/mercury_to_mercury.m:
	Add a pred_or_func argument to mercury_output_pragma_decl,
	and use that to determine the declared arity.

tests/valid/intermod_test.m:
tests/valid/intermod_test2.m:
	Regression test.
1997-11-21 00:38:57 +00:00
Zoltan Somogyi
9721c4b090 Recompute nonlocal sets before starting liveness computations
Estimated hours taken: 4

compiler/liveness.m:
	Recompute nonlocal sets before starting liveness computations
	in order to avoid a compiler abort. The new version could in
	some cases also lead to the generation of better code through
	saving fewer variables across disjuncts.

tests/valid/liveness_nonlocals.m:
	Test case to exercise the fix.

tests/valid/Mmakefile:
	Enable the new test case.
1997-10-16 07:01:58 +00:00