Commit Graph

88 Commits

Author SHA1 Message Date
Simon Taylor
79dcbbef15 User-guided type specialization.
Estimated hours taken: 60

User-guided type specialization.

compiler/prog_data.m:
compiler/prog_io_pragma.m:
compiler/modules.m:
compiler/module_qual.m:
compiler/mercury_to_mercury.m:
	Handle `:- pragma type_spec'.

compiler/prog_io_pragma.m:
	Factor out some common code to parse predicate names with arguments.

compiler/hlds_module.m:
	Added a field to the module_sub_info to hold information about
	user-requested type specializations, filled in by make_hlds.m
	and not used by anything after higher_order.m.

compiler/make_hlds.m:
	For each `:- pragma type_spec' declaration, introduce a new predicate
	which just calls the predicate to be specialized with the
	specified argument types. This forces higher_order.m to produce
	the specialized versions.

compiler/higher_order.m:
	Process the user-requested type specializations first to ensure
	that they get the correct names.
	Allow partial matches against user-specified versions, e.g.
		map__lookup(map(int, list(int)), int, list(int)) matches
		map__lookup(map(int, V), int, V).
	Perform specialization where a typeclass constraint matches a
	known instance, but the construction of the typeclass_info is
	done in the calling module.
	Give slightly more informative progress messages.

compiler/dead_proc_elim.m:
	Remove specializations for dead procedures.

compiler/prog_io_util.m:
	Change the definition of the `maybe1' and `maybe_functor' types
	to avoid the need for copying to convert between `maybe1'
	and `maybe1(generic)'.
	Changed the interface of `make_pred_name_with_context' to allow
	creation of predicate names for type specializations which describe
	the type substitution.

compiler/make_hlds.m:
compiler/prog_io_pragma.m:
	Make the specification of pragma declarations in error
	messages consistent. (There are probably some more to
	be fixed elsewhere for termination and tabling).

compiler/intermod.m:
	Write type specialization pragmas for predicates declared
	in `.opt' files.

compiler/mercury_to_mercury.m:
	Export `mercury_output_item' for use by intermod.m.

compiler/options.m:
	Add an option `--user-guided-type-specialization' enabled
	with `-O2' or higher.

compiler/handle_options.m:
	`--type-specialization' implies `--user-guided-type-specialization'.

compiler/hlds_goal.m:
	Add predicates to construct constants. These are duplicated
	in several other places, I'll fix that as a separate change.

compiler/type_util.m:
	Added functions `int_type/0', `string_type/0', `float_type/0'
	and `char_type/0' which return the builtin types.
	These are duplicated in several other places,
	I'll fix that as a separate change.

library/private_builtin.m:
	Added `instance_constraint_from_typeclass_info/3' to extract
	the typeclass_infos for a constraint on an instance declaration.
	This is useful for specializing class method calls.
	Added `thread_safe' to various `:- pragma c_code's.
	Added `:- pragma inline' declarations for `builtin_compare_*', which
	are important for user-guided type specialization. (`builtin_unify_*'
	are simple enough to go in the `.opt' files automatically).

compiler/polymorphism.m:
	`instance_constraint_from_typeclass_info/3' does not need type_infos.
	Add `instance_constraint_from_typeclass_info/3' to the
	list of `typeclass_info_manipulator's which higher_order.m
	can interpret.

NEWS:
doc/reference_manual.texi:
doc/user_guide.texi
	Document the new pragma and option.

tests/invalid/Mmakefile:
tests/invalid/type_spec.m:
tests/invalid/type_spec.err_exp:
	Test error reporting for invalid type specializations.

tests/hard_coded/Mmakefile:
tests/invalid/type_spec.m:
tests/invalid/type_spec.exp:
	Test type specialization.
1999-04-23 01:03:51 +00:00
Simon Taylor
d348b24af5 Fix an old-style `:- pragma c_code' declaration.
Estimated hours taken: 0.1

samples/c_calls_mercury/c_main_int.m:
	Fix an old-style `:- pragma c_code' declaration.

samples/c_calls_mercury/mercury_lib.m:
	Add a missing import.
1999-03-24 03:20:29 +00:00
Tyson Dowd
90ec6ff89d Add rot13 examples to the samples directory.
Estimated hours taken: 8

Add rot13 examples to the samples directory.

Note: Estimated time is time for contributors, mainly.

samples/README:
samples/c_interface/README:
	Fix the README files, they were a little inaccurate in
	describing some files and directories.
1998-11-19 06:18:23 +00:00
Fergus Henderson
5a8099255a Add Philip Dart's `muz' program,
Estimated hours taken: 0.1

samples/muz/*:
	Add Philip Dart's `muz' program,
	as an example of a program written in Mercury.
1998-11-07 05:42:46 +00:00
Fergus Henderson
dc4678527c Simplify the code a little.
Estimated hours taken: 0.1

samples/cat.m:
	Simplify the code a little.
1998-11-04 17:41:20 +00:00
Simon Taylor
869ba64018 Convert a call to copy to unsafe_promise_unique, since copy
Estimated hours taken: 0.25

samples/diff/globals.m:
	Convert a call to copy to unsafe_promise_unique, since copy
	is buggy at the moment.
1998-09-21 06:46:32 +00:00
Andrew Bromage
b3af56e8fa Modified files
Estimated hours taken: 30

Modified files
--------------

samples/diff/Mmakefile:
	Minor documentation update.

samples/diff/README:
samples/diff/TODO:
	Update stuff that's now done, do a couple of minor wording
	changes.

samples/diff/diff.m:
	Fix case of identical filenames (which implicitly assumed
	no_diff_implies_no_output).  Add new match pass, call the
	new diff algorithm.

samples/diff/diff_out.m:
	Add --cvs-merge-conflict output style.  Slight reorganisation
	of top-level predicate.  Lots of small fixes to use better
	syntax (e.g. functional style for integer maths operations).

samples/diff/difftype.m:
	Added first_mentioned_positions/3, last_mentioned_positions/3,
	add_edit/4.

samples/diff/file.m:
	Use io__read_line_as_string.

samples/diff/filter.m:
	Minor syntax/wording changes.

samples/diff/options.m:
	Update all the newly handled options.

New files
---------

samples/diff/myers.m:
	New diff algorithm.

samples/diff/match.m:
	New pass to match common lines in the files to be diffed.

Removed file
------------

samples/diff/lcss.m:
	Functionality replaced by myers.m.
1998-09-15 04:54:41 +00:00
Andrew Bromage
586c5e16c6 Implement io__read_line_as_string/{3,4}.
Estimated hours taken: 10

library/io.m:
library/io.nu.nl:
	Implement io__read_line_as_string/{3,4}.

	Also sneaked in here are some trivial whitespace fixes in some
	of the pragma c_code which did not comply with our coding
	standards (to do with type casting).

samples/cat.m:
samples/sort.m:
	Use io__read_line_as_string.

tests/general/Mmakefile:
tests/general/read_line_as_string.exp:
tests/general/read_line_as_string.m:
	Test case for io__read_line_as_string.

NEWS:
	Mention the above change.
1998-09-09 06:05:30 +00:00
Fergus Henderson
cd44fb99e9 #include "mercury_imp.h" instead of "imp.h".
Estimated hours taken: 0.25

samples/c_interface/cplusplus_calls_mercury/cpp_main.cc:
	#include "mercury_imp.h" instead of "imp.h".
1998-09-02 06:51:32 +00:00
Fergus Henderson
7d780ffe2a #include "mercury_init.h" instead of "init.h".
Estimated hours taken: 0.25

samples/c_interface/simpler_cplusplus_calls_mercury/cpp_main.cc:
	#include "mercury_init.h" instead of "init.h".
1998-09-02 06:49:19 +00:00
Fergus Henderson
1b307c24ad #include "mercury_init.h" instead of "init.h".
Estimated hours taken: 0.25

samples/c_interface/simpler_c_calls_mercury/c_main.c:
	#include "mercury_init.h" instead of "init.h".
1998-09-02 06:47:19 +00:00
Fergus Henderson
dc919accb8 Add an example of interfacing to Fortran code from Mercury.
samples/c_interface/mercury_calls_fortran/*:
	Add an example of interfacing to Fortran code from Mercury.
1998-05-19 10:13:59 +00:00
Andrew Bromage
bc0a109801 Modified files
Estimated hours taken: 30

Modified files
--------------

samples/diff/README:
	Info about this new version.  Put the existing READMEs in
	reverse order, so that they'll be in the most sensible order
	for someone reading top-down.

samples/diff/Mmakefile:
	Supply more detail about which bit of this program GCC 2.7.2
	under Digital Unix 3.2 doesn't compile properly.

samples/diff/diff.m:
	Slight reorganisation.  Accept options, remove some high
	coupling betweem diff__do_diff and lcss.m.

samples/diff/file.m:
	Add support for attaching a filename to a file.

samples/diff/lcss.m:
	Add more documentation, one slight performance improvement.
	lcss__to_diff now works on the reversed LCSS, to avoid going
	to the trouble of reversing it.

New files
---------

samples/diff/TODO:
	Meaning should be obvious.

samples/diff/diff_out.m:
	Replacement for diffs.m (which was never a very good name).
	Now contains code to display a diff in lots more output
	styles than previously supported.

samples/diff/difftype.m:
	Replacement for lcsstype.m.  Contains the type of a diff (but
	not of an lcss, which is now local to lcss.m, hence the
	renaming).

samples/diff/filter.m:
	Contains code to filter a diff before being displayed.  This
	is only required if the user specified that they didn't want
	to see part of the diff (e.g. with --ignore-blank-lines).

samples/diff/globals.m:
samples/diff/options.m:
	Support for option handling.

Removed files
-------------

samples/diff/diffs.m:
	Functionality moved to diff_out.m.

samples/diff/lcsstype.m:
	Functionality moved to difftype.m.
1998-01-13 00:52:08 +00:00
Fergus Henderson
086d75a334 New file. An example of the use of tr_store.m.
Estimated hours taken: 0.1

extras/trailed_update/samples/interpreter.m:
	New file.  An example of the use of tr_store.m.

samples/interpreter.m:
	Add pointer to extras/trailed_update/samples/interpreter.m.

extras/trailed_update/Mmakefile:
extras/trailed_update/samples/interpreter.inp:
extras/trailed_update/samples/interpreter.exp:
extras/trailed_update/samples/vqueens.exp:
	New files.  Some testing infrastructure.
1997-09-29 15:25:58 +00:00
Andrew Bromage
e72e23910e No longer GPL, now public domain.
samples/e.m:
samples/eliza.m:
	No longer GPL, now public domain.
1997-09-12 02:17:13 +00:00
Thomas Conway
8d79000cf8 Place various bits of sample code in the public domain.
Estimated hours taken: 0.1

Place various bits of sample code in the public domain.

extras/complex_numbers/samples/fft.m:
extras/graphics/samples/calc/calc.m:
extras/graphics/samples/maze/maze.m:
samples/ultra_sub.m:
	place the source in the public domain.
1997-09-11 22:08:56 +00:00
Fergus Henderson
2c4bd735b4 Add comment "This source file is hereby placed in the public domain".
Estimated hours taken: 0.25

samples/*:
	Add comment "This source file is hereby placed in the public domain".
1997-09-10 11:01:12 +00:00
Fergus Henderson
7d46fde7f3 Update to use the new mercury_init() and mercury_terminate()
samples/c_interface/simpler_c_calls_mercury/README:
samples/c_interface/simpler_c_calls_mercury/c_main.c:
samples/c_interface/simpler_c_calls_mercury/mercury_lib.m:
samples/c_interface/simpler_cplusplus_calls_mercury/README:
samples/c_interface/simpler_cplusplus_calls_mercury/cpp_main.cc:
samples/c_interface/simpler_cplusplus_calls_mercury/mercury_lib.m:
	Update to use the new mercury_init() and mercury_terminate()
	functions.
1997-09-06 13:04:32 +00:00
Fergus Henderson
f5af5c9b20 Update to use the new mercury_init() and mercury_terminate()
Estimated hours taken: 1

samples/c_interface/simpler_c_calls_mercury/README:
samples/c_interface/simpler_c_calls_mercury/c_main.c:
samples/c_interface/simpler_c_calls_mercury/mercury_lib.m:
samples/c_interface/simpler_cplusplus_calls_mercury/README:
samples/c_interface/simpler_cplusplus_calls_mercury/cpp_main.cc:
samples/c_interface/simpler_cplusplus_calls_mercury/mercury_lib.m:
	Update to use the new mercury_init() and mercury_terminate()
	functions.
1997-09-06 13:03:58 +00:00
Andrew Bromage
2eee071261 Added a new sample program, e.m, and fixed some out-of-date
Estimated hours taken: 3

Added a new sample program, e.m, and fixed some out-of-date
documentation.

samples/Mmakefile:
samples/e.m:
	Sample program 'e' which calculates the base of natural
	logarithms to lots of digits (if you're prepared to wait).

samples/README:
	Added documentation for e.m, updated documentation for
	samples/diff/* to reflect recent changes.
1997-07-28 21:52:35 +00:00
Andrew Bromage
34ecf2050a Minor documentation fix.
Estimated hours taken: 0.05

Minor documentation fix.

samples/diff/README:
	It was, of course, not the fix which caused diff to bomb out,
	it was the problem solved by the fix.
1997-07-28 20:02:48 +00:00
Andrew Bromage
fb95516511 Added a clitic which was left out of the previous by mistake.
Estimated hours taken: very little

samples/diff/README:
	Added a clitic which was left out of the previous by mistake.
1997-07-28 06:03:49 +00:00
Andrew Bromage
5d9c15639c General cleanup and bug fix for diff. Features of this diff:
Estimated hours taken: 4

General cleanup and bug fix for diff.  Features of this diff:

	- Changed indenting so it more closely matches the
	  coding standard.

	- Bug fix which was causing it to bomb out if the two
	  files were identical.

	- Update to use unique arrays (array.m).

samples/diff/README:
	Added something which resembles this log message.

samples/diff/Mmakefile:
	Turned C optimisation off to get around a gcc 2.7.2 bug.

samples/diff/diff.m:
samples/diff/diffs.m:
samples/diff/file.m:
samples/diff/lcss.m:
samples/diff/lcsstype.m:
	Changes detailed above.
1997-07-28 06:00:55 +00:00
Fergus Henderson
04b720630b Update the copyright messages so that (a) they contain the correct years
and (b) they say "Copyright (C) ... _The_ University of Melbourne".
1997-07-27 15:09:59 +00:00
Fergus Henderson
cb3e03212c Add new directory with new files README, c_main.c, Mmakefile,
samples/c_interface/simpler_c_calls_mercury:
	Add new directory with new files README, c_main.c, Mmakefile,
	and mercury_lib.m.  These files demonstrate how to interface
	to C using a C main() top-level rather than with a Mercury
	main/2 top-level.

samples/c_interface/simpler_cplusplus_calls_mercury:
	Same as above, but using C++ rather than C.
1997-07-25 03:55:51 +00:00
Fergus Henderson
9aaa21696f Add new directory with new files README, c_main.c, Mmakefile,
Estimated hours taken: 3

samples/c_interface/simpler_c_calls_mercury:
	Add new directory with new files README, c_main.c, Mmakefile,
	and mercury_lib.m.  These files demonstrate how to interface
	to C using a C main() top-level rather than with a Mercury
	main/2 top-level.

samples/c_interface/simpler_cplusplus_calls_mercury:
	Same as above, but using C++ rather than C.
1997-07-25 03:55:18 +00:00
Fergus Henderson
f4a5dce039 Fix a couple of singleton variable warnings by prepending `_'
Estimated hours taken: 0.25

samples/diff/lcss.m:
	Fix a couple of singleton variable warnings by prepending `_'
	to the name of a couple of unused variable.
1997-04-15 05:02:33 +00:00
Fergus Henderson
ddb73722b9 Rename all the Mmake' files as Mmakefile'. This is necessary to
avoid confusion between `Mmake' and `mmake' on case-insensitive file
systems.
1997-02-13 21:38:45 +00:00
Fergus Henderson
8235e7af29 Rename all the Mmake' files as Mmakefile'.
Estimated hours taken: 0.5

Rename all the `Mmake' files as `Mmakefile'.  This is necessary to
avoid confusion between `Mmake' and `mmake' on case-insensitive file
systems.
1997-02-13 21:37:32 +00:00
Fergus Henderson
53aa3ff948 The #include of "mercury_lib.h" should be the first #include,
Estimated hours taken: 0.25

samples/c_calls_mercury/c_main.c:
	The #include of "mercury_lib.h" should be the first #include,
	because that includes "imp.h" which may define global
	register variables that need to be declared before any
	inline functions in other header files.
1997-02-01 13:54:05 +00:00
Fergus Henderson
d988e8c82e Add an example of Mercury calling C++ code.
Estimated hours taken: 0.25

samples/c_interface/mercury_calls_cplusplus/*:
	Add an example of Mercury calling C++ code.
1997-01-31 19:04:47 +00:00
Fergus Henderson
0b1322d17c Add an example of C++ code caling Mercury code.
Estimated hours taken: 0.5

samples/cplusplus_calls_mercury/*:
	Add an example of C++ code caling Mercury code.
1997-01-31 18:57:02 +00:00
Fergus Henderson
4d4fb31484 Add a .cvsignore file.
Estimated hours taken: 0.1

samples/c_interface/mercury_calls_c:
	Add a .cvsignore file.
1997-01-17 07:58:16 +00:00
Fergus Henderson
b060c3897f Add a .cvsignore file to get CVS to ignore automatically-generated
Estimated hours taken: 0.1

samples/c_interface/c_calls_mercury:
	Add a .cvsignore file to get CVS to ignore automatically-generated
	files.
1997-01-17 07:55:45 +00:00
Fergus Henderson
fedf4f472d Update now that exporting semidet procedures works.
Estimated hours taken: 0.5

samples/c_interface/c_calls_mercury:
	Update now that exporting semidet procedures works.
	Add some examples of exporting functions.
1996-12-20 17:50:20 +00:00
Fergus Henderson
aadb280399 Remove the line "MCFLAGS=--no-optimize-dead-procs # XXX work-around
Estimated hours taken: 0.25

samples/c_interface/c_calls_mercury/Mmake:
	Remove the line "MCFLAGS=--no-optimize-dead-procs # XXX work-around
	for compiler bug", since the bug it refers to has been fixed.
1996-12-14 20:35:42 +00:00
Fergus Henderson
6a7d427f99 Committed the changes sent by Marnix Klooster <marnix@worldonline.nl>.
Estimated hours taken: 0.5

samples/diff:
	Committed the changes sent by Marnix Klooster <marnix@worldonline.nl>.
	His description of the changes:

	The major changes I made were

	* Moved code for manipulating and displaying diffs to a separate
	  module called diffs.m (and changed their calls in diff.m).  The type
	  'lcss,' needed both by the rest of lcss.m and by diffs.m, was moved
	  to a new module lcsstype.m.

	* Made lcss.m independent of files, and allowed it to process any kind
	  of list by adding polymorphism.  (The file processing calls have
	  been moved to diff.m.)

	* Added type synonyms 'pos' and 'segment' in diffs.m to clarify the
	  types.  Renamed 'single_diff' to 'edit'.

	* Added end-of-file match to the generated lcss, thereby allowing the
	  to_diff predicate to be simplified considerably.

	* Numbered lists from 0 internally in the lcss-algorithm.  This made
	  to_diff simpler still, but also forced changes in the diff-printing
	  part.

	* Removed the swapping in find_lcss, because it doesn't seem to help.

	* The array(string) representing a file in file.m was also renumbered
	  to begin with 0.

	* Added and corrected comments.

	Have fun,

	 <><

	Marnix
	--
	Marnix Klooster
	marnix@worldonline.nl
1996-10-29 17:11:56 +00:00
Fergus Henderson
7100cacc35 Add new file expand_terms to the list of programs.
Estimated hours taken: 0.1

samples/Mmake:
	Add new file expand_terms to the list of programs.
1996-07-25 17:17:47 +00:00
Fergus Henderson
8275d8af9b Mention the new file expand_terms.m.
Estimated hours taken: 0.1

samples/README:
	Mention the new file expand_terms.m.
1996-07-25 17:14:21 +00:00
Fergus Henderson
c50b78c6b2 A new example, showing how to emulate Prolog's expand_term.
Estimated hours taken: 1

samples/expand_terms:
	A new example, showing how to emulate Prolog's expand_term.
1996-07-25 17:09:47 +00:00
Fergus Henderson
f83f6fe53e Update the documentation to reflect the new semantics
Estimated hours taken: 0.25

samples/committed_choice.m:
	Update the documentation to reflect the new semantics
	(commutative v.s. strict sequential).
1996-07-25 15:49:19 +00:00
Fergus Henderson
2d69792a1b Remove an obsolete comment.
Estimated hours taken: 0.25

samples/all_solutions.m:
	Remove an obsolete comment.
1996-07-15 14:14:21 +00:00
Fergus Henderson
5fb6b8421f Add a file describing the contents of the samples directory.
Estimated hours taken: 0.25

samples/README:
	Add a file describing the contents of the samples directory.
1996-06-11 04:50:57 +00:00
Fergus Henderson
78896d77ca Add another example of the use of the C interface.
Estimated hours taken: 0.25

samples/c_interface/short_example.m:
	Add another example of the use of the C interface.
1996-06-11 04:37:09 +00:00
Fergus Henderson
fb0c3822aa Add a new directory containing an example of the use of the
Estimated hours taken: 0.5

samples/c_interface/c_calls_mercury/*:
	Add a new directory containing an example of the use of the
	C interface.
1996-06-11 04:35:25 +00:00
Fergus Henderson
4c540ddb7b Add missing #include to suppress compiler warning.
Estimated hours taken: 0.1

samples/C_Interface/mercury_calls_c/c_main.c:
	Add missing #include to suppress compiler warning.
1996-06-11 03:55:16 +00:00
Fergus Henderson
553a278171 Add an example of using the Mercury->C interface.
Estimated hours taken: 0.5

samples/C_interface/c_calls_mercury/*:
	Add an example of using the Mercury->C interface.
1996-05-25 07:18:14 +00:00
Zoltan Somogyi
dd9619d20b s/varset__lookup/varset__search/
Estimated hours taken: 0.1

interpreter:
	s/varset__lookup/varset__search/
1996-03-17 04:22:44 +00:00
Fergus Henderson
3cea9507db Add `interpreter.m' to the samples directory.
Estimated hours taken: 0.1

Add `interpreter.m' to the samples directory.
1996-03-03 22:56:52 +00:00
Fergus Henderson
b67c6e6ee1 Due to popular demand, I have finally succumbed and written a
Estimated hours taken: 0.5

samples/calculator.m:
	Due to popular demand, I have finally succumbed and written a
	"nicer" version of this.
1996-03-01 13:25:56 +00:00