Commit Graph

108 Commits

Author SHA1 Message Date
Zoltan Somogyi
8caba4e15d Make it possible to compile a module (e.g. std_util) without debugging,
Estimated hours taken: 18

Make it possible to compile a module (e.g. std_util) without debugging,
while still allowing debuggable code called from that module via higher-order
predicates (e.g. solutions) to have a proper stack trace.

compiler/options.m:
	Add the new option --stack-trace-higher-order.

compiler/mercury_compile.m:
	Always invoke continuation_info and stack_layout, since it is no
	longer the case that either all procedures or none get layout
	structures generated for them, and the other modules are in a better
	position to make that decision.

compiler/continuation_info.m:
	Handle the extra tests required by the change to mercury_compile.m.

	When we gather info about a procedure, remember whether that
	procedure must have a procedure layout that includes the procedure id
	section.

compiler/stack_layout.m:
	Use the flag remembered by continuation_info to help decide
	whether we need procedure layout structures.

	Fix an old space wastage: after generating marker saying that
	the second and later groups of fields of a procedure layout are
	not present, do not generate another marker saying that the
	third group of fields is not present. Since it was in the wrong
	position, it did not have the right meaning; it only worked because,
	due to the presence of the first marker, it was never looked at anyway.

compiler/code_gen.m:
	Use the new capability of continuation_info.m to require
	procedure layouts including procedure id sections for any predicate
	that has higher-order arguments, if --stack-trace-higher-order is set.

compiler/globals.m:
	Rename want_return_layouts as want_return_var_layouts, since this
	is a more accurate representation of what the predicate does.

compiler/call_gen.m:
compiler/code_info.m:
	Conform to the change in globals.m.

compiler/llds_out.m:
	Separate the c_modules containing compiler-generated code into two
	groups, those that define labels that have stack layouts and those
	that don't. In most cases one or the other category will be empty,
	but with --stack-trace-higher-order, the c_modules containing
	higher-order procedures will have stack layouts, while others will
	not.

	Reorganize the way the way the initialization functions are generated,
	by putting c_modules falling into different categories into different
	bunches. c_module falling into the first category always have their
	initialization code included, while those in the second category
	have it included only if the old flag MR_MAY_NEED_INITIALIZATION
	is set.

	Delete the obsolete #define of MR_STACK_TRACE_THIS_MODULE.

	Improve some predicate names, in an effort to prevent confusion
	about what a "file" is (since the code uses more than one meaning,
	given the presence of --split-c-files).

compiler/pragma_c_gen.m:
	Fix an old bug: s/NONDET_FIXED_SIZE/MR_NONDET_FIXED_SIZE/.
	Required for the change to library/string.m.

doc/user_guide.texi:
	Document the new option.

runtime/mercury_goto.c:
	Simplify the conditions under which labels get added to the label
	table with:

	- The macros init_{entry,label,local}_ai always add
	the label to the label table without a layout structure.

	- The macros init_{entry,label,local}_sl always add it with a layout
	structure.

	- Whether the macros init_{entry,label,local} with no suffix
	add the label to the label table depends on the values of other
	configuration parameters, but they will never include a layout
	structure.

	The intended use is that any label that has a layout structure should
	be initialized with a _sl macro. Any other label that should always
	be in the label table if the label table is needed at all (labels
	such as do_fail) should be initialized with _ai. Everything else
	should be initialized with a suffixless macro.

runtime/mercury_conf_params.c:
	Remove MR_USE_STACK_LAYOUTS and MR_STACK_TRACE_THIS_MODULE, since
	due to the simplification of mercury_goto.h, they are not used anymore.

runtime/mercury_stack_layout.h:
	Remove the old macros for creating layout structures with bogus
	contents, and replace them with new macros for creating layout
	structures with meaningful contents.

runtime/mercury_engine.c:
runtime/mercury_wrapper.c:
	Remove bogus layout structures. Ensure the labels defined here
	always get into the label table.

runtime/mercury_ho_call.c:
	Remove bogus layout structures. Add proper ones where necessary.

runtime/mercury_bootstrap.c:
runtime/mercury_type_info.c:
	Remove bogus layout structures.

runtime/mercury_boostrap.h:
	Add this new file for bootstrapping purposes.

	Temporarily #define NONDET_FIXED_SIZE as MR_NONDET_FIXED_SIZE, since
	pragma_c_gen.m refers to the former until the update to it gets
	installed.

runtime/Mmakefile:
	Add a reference to mercury_boostrap.h.

library/builtin.m:
	Remove bogus layout structures.

library/array.m:
library/benchmarking.m:
library/private_builtin.m:
	Remove bogus layout structures. Add proper ones.

library/std_util.m:
	Remove bogus layout structures. Add proper ones.

	Replace references to framevar(n) with references to MR_framevar(n+1).

	Fix an old bug in code under #ifndef COMPACT_ARGS: in the
	implementation of mercury____Compare___std_util__univ_0_0_i1, the
	succip register was not being saved across the call to
	mercury__compare_3_0.

library/string.m:
	Remove the need for bogus layout structures, by converting the
	implementation of string__append(out, out, in) from hand-written
	C module into nondet pragma C code.
1998-11-05 03:53:48 +00:00
Fergus Henderson
674d66cbad Fix a bug in string__format: it was not reporting an error
Estimated hours taken: 0.75

library/string.m:
	Fix a bug in string__format: it was not reporting an error
	in the case where the argument list had more elements
	than was appropriate for the format string.

tests/general/Mmakefile:
tests/general/string_format_test_2.m:
tests/general/string_format_test_2.exp:
tests/general/string_format_test_3.m:
tests/general/string_format_test_3.exp:
	Test cases for the above-mentioned bug fix.
1998-10-27 15:36:42 +00:00
Thomas Conway
e5e42d0184 Improve the multi-threaded execution support.
Estimated hours taken: 1.5

Improve the multi-threaded execution support.

runtime/mercury_context.{c,h}:
	Move the code for runnext from the .h file to the .c file -
	it is reasonably large (in the thread_safe grades) so avoiding
	the duplication is handy. It also makes debugging much easier!

	Also, make scheduling a context as runnable append it to the
	end of the runqueue, rather than consing it to the front. This
	yeilds more useful behaviour for concurrent code that wants to
	yeild in favour of any other runnable context.

library/math.m:
library/string.m:
library/io.m:
	Add thread_safe to the flags for a whole bunch of predicates and
	functions that are thread-safe.
1998-08-24 04:47:03 +00:00
Thomas Conway
d6798de1c9 Convert
Estimated hours taken: 0.5

library/*.m:
	Convert
		:- pragma(c_code, ...
	to
		:- pragma c_code(...

	and introduce will_not_call_mercury in places where it is implicit
	(this is in preparation for changing the default to may_call_mercury).
1998-08-03 00:19:49 +00:00
Fergus Henderson
986b631dc6 Add code to parse terms from strings rather than from streams.
Estimated hours taken: 24

Add code to parse terms from strings rather than from streams.
The original intention for this change was twofold:
to increase expressiveness and to improve efficiency.
However, for the moment I have given up on the goal of
improving efficiency.

library/io.m:
	Add io__read_file_as_string/{4,5}, for efficiently
	reading a whole file into a single string.
	Add io__read_from_string/5, for reading terms of
	any type from a string.
	(Should that instead be named string__read instead?)

library/string.m:
	Implement string__substring/4 more efficiently,
	using `pragma c_code' rather than by calling
	string__right(string__left(...)).
	Export string__unsafe_index/3, and add new exported
	predicate string__unsafe_substring/4 -- these
	are versions of string__index and string__substring
	that don't check for range errors.  They are
	needed to get reasonable efficiency when dealing
	with very large strings.

library/string.nu.nl:
	Add Prolog implementations of string__substring
	and string__unsafe_substring.

library/lexer.m:
	Add lexer__string_get_token_list/{5,6}, for parsing
	tokens from a string.  This required adding
	`string_' versions of most of the lexical analysis routines.
	XXX lots of code duplication, I'm afraid.
	XXX the string versions are not as efficiency as they
	    could ideally be.

library/parser.m:
	Add new predicates parser__read_term_from_string/{4,6}
	and parser__parse_token_list.

compiler/bytecode_gen.m:
compiler/error_util.m:
compiler/fact_table.m:
compiler/term_errors.m:
	Minor changes to use term__context as an ADT rather than
	as a concrete data type.

In addition, I made the following changes, which I am NOT committing.

compiler/prog_io.m:
	Change to use io__read_file_as_string and
	parser__read_term_from_string.
	(Not committed because the existing method is
	in currently more efficient.)

library/term.m:
	Add new alternative term__detailed_context to the term__context type.
	This alternative can record both the start and end of a term rather
	than just the end.
	(The lexer now has almost all the necessary support for detailed
	contexts, but enabling it would have some potentially significant
	efficiency costs, and curently the parser uses only single contexts
	rather than ranges; so currently this is not used.)
1998-05-21 16:52:20 +00:00
Fergus Henderson
f2f730c7e0 Add a couple of comments.
Estimated hours taken: 0.1

library/string.m:
	Add a couple of comments.
1998-05-20 16:09:25 +00:00
Fergus Henderson
002ad1c8d8 Fix a bug in string__base_string_to_int:
Estimated hours taken: 1

library/string.m:
	Fix a bug in string__base_string_to_int:
	it was handling MININT incorrectly.

tests/hard_coded/Mmakefile:
tests/hard_coded/minint_bug.m:
tests/hard_coded/minint_bug.exp:
	Regression test.
1998-03-18 14:16:20 +00:00
Fergus Henderson
a999899f71 Fix profiling problems caused by the hand-coded low-level C code
Estimated hours taken: 1.5

Fix profiling problems caused by the hand-coded low-level C code
not setting up the profiling information correctly.

library/std_util.m:
	Fix some typos in the "caller" argument of call() instructions
	in the hand-coded low-level C code for builtin_aggregate/4.

library/string.m:
library/benchmarking.m:
library/std_util.m:
	Add calls to set_prof_current_proc() at resumption labels
	in hand-coded low-level C code.
	For string__append_3_3, use tailcall() rather than GOTO,
	so that we set prof_current_proc.
1998-01-30 02:15:05 +00:00
Fergus Henderson
7cb525fde3 Undo Zoltan's bogus update of all the copyright dates.
Estimated hours taken: 0.5

library/*.m:
compiler/*.m:
	Undo Zoltan's bogus update of all the copyright dates.
	The dates in the copyright header should reflect the years
	in which the file was modified (and no, changes to the
	copyright header itself don't count as modifications).
1998-01-23 12:33:43 +00:00
Zoltan Somogyi
9ae7acc593 Update all the copyright dates for 1998.
Estimated hours taken: 0.5

library/*.m:
	Update all the copyright dates for 1998.
1998-01-13 10:01:32 +00:00
David Jeffery
7406335105 This change implements typeclasses. Included are the necessary changes to
Estimated hours taken: 500 or so

This change implements typeclasses. Included are the necessary changes to
the compiler, runtime and library.

compiler/typecheck.m:
	Typecheck the constraints on a pred by adding constraints for each
	call to a pred/func with constraints, and eliminating constraints
	by applying context reduction.

	While reducing the constraints, keep track of the proofs so that
	polymorphism can produce the tyepclass_infos for eliminated
	constraints.

compiler/polymorphism.m:
	Perform the source-to-source transformation which turns code with
	typeclass constraints into code without constraints, but with extra
	"typeclass_info", or "dictionary" parameters.

	Also, rather than always having a type_info directly for each type
	variable, sometimes the type_info is hidden inside a typeclass_info.

compiler/bytecode*.m:
	Insert some code to abort if bytecode generation is used when
	typeclasses are used.
compiler/call_gen.m:
	Generate code for a class_method_call, which forms the body of a class
	method (by selecting the appropriate proc from the typeclass_info).
compiler/dead_proc_elim.m:
	Don't eliminate class methods if they are potentially used outside
	the module
compiler/hlds_data.m:
	Define data types to store:
		- the typeclass definitions
		- the instances of a class
		- "constraint_proof". ie. the proofs of redundancy of a
		  constraint. This info is used by polymorphism to construct the
		  typeclass_infos for a constraint.
		- the "base_tyepclass_info_constant", which is analagous the
		  the base_type_info_constant
compiler/hlds_data.m:
	Define the class_method_call goal. This goal is inserted into the
	body of class method procs, and is responsible for selecting the
	appropriate part of the typeclass_info to call.
compiler/hlds_data.m:
	Add the class table and instance table to the module_info.
compiler/hlds_out.m:
	Output info about base_typeclass_infos and class_method_calls
compiler/hlds_pred.m:
	Change the representation of the locations of type_infos from "var"
	to type_info_locn, which is either a var, or part of a typeclass_info,
	since now the typeclass_infos contain the type_infos for the type that
	they constrain.

	Add constraints to the pred_info.

	Add constraint_proofs to the pred_info (so that typeclass.m can
	annotate the pred_info with the reasons that constraints were
	eliminated, so that polymorphism.m can in turn generate the
	typeclass_infos for the constraints).

	Add the "class_method" marker.

compiler/lambda.m:
	A feable attempt at adding class ontexts to lambda expressions,
	untested and almost certainly not working.
compiler/llds_out.m:
	Output the code addresses for do_*det_class_method, and output
	appropriately mangled symbol names for base_typeclass_infos.
compiler/make_hlds.m:
	Add constraints to the types on pred and func decls, and add
	class and instance declarations to the class_table and instance_table
	respectively.
compiler/mercury_compile.m:
	Add the check_typeclass pass.
compiler/mercury_to_mercury.m:
	Output constraints of pred and funcs, and output typeclass and instance
	declarations.
compiler/module_qual.m:
	Module qualify typeclass names in pred class contexts, and qualify the
	typeclass and instance decls themselves.
compiler/modules.m:
	Output typeclass declarations in the short interface too.
compiler/prog_data.m:
	Add the "typeclass" and "instance" items. Define the types to store
	information about the declarations, including class contexts on pred
	and func decls.
compiler/prog_io.m:
	Parse constraints on pred and func declarations.
compiler/prod_out.m:
	Output class contexts on pred and func decls.
compiler/type_util.m:
	Add preds to apply a substitution to a class_constraint, and to
	a list of class constraints. Add type_list_matches_exactly/2. Also
	add typeclass_info and base_typeclass_info as types which should not
	be optimised as no_tag types (seeing that we cheat a bit about their
	representation).
compiler/notes/compiler_design.html:
	Add notes on module qualification of class contexts. Needs expansion
	to include more stuff on typeclasses.
compiler/*.m:
	Various minor changes.

New Files:
compiler/base_typeclass_info.m:
	Produce one base_typeclass_info for each instance declaration.
compiler/prog_io_typeclass.m:
	Parse typeclass and instance declarations.
compiler/check_typeclass.m:
	Check the conformance of an instance declaration to the typeclass
	declaration, including building up a proof of how superclass
	constraints are satisfied so that polymorphism.m is able to construct
	the typeclass_info, including the superclass typeclass_infos.

library/mercury_builtin.m:
	Implement that base_typeclass_info and typeclass_info types, as
	well as the predicates type_info_from_typeclass_info/3 to extract
	a type_info from a typeclass_info, and superclass_from_typeclass_info/3
	for extracting superclasses.
library/ops.m:
	Add "typeclass" and "instance" as operators.
library/string.m:
	Add a (in, uo) mode for string__length/3.

runtime/mercury_ho_call.c:
	Implement do_call_*det_class_method, which are the pieces of code
	responsible for extracting the correct code address from the
	typeclass_info, setting up the arguments correctly, then executing
	the code.
runtime/mercury_type_info.h:
	Macros for accessing the typeclass_info structure.
1997-12-19 03:10:47 +00:00
Tyson Dowd
f9170a0563 Add library and runtime support for stack layouts.
Estimated hours taken: 30

Add library and runtime support for stack layouts.

library/array.m:
library/benchmarking.m:
library/mercury_builtin.m:
library/std_util.m:
library/string.m:
runtime/mercury_engine.c:
runtime/mercury_ho_call.c:
runtime/mercury_type_info.c:
	Add MR_MAKE_STACK_LAYOUT_* macros to add basic stack layouts for
	handwritten C code.

runtime/mercury_type_info.c:
	Remove some duplicate label declarations.

runtime/mercury_calls.h:
	Don't use ASM_FIXUP_REGS in calls with NATIVE_GC - we don't
	want (or need) to use it. We define all labels as entry labels
	anyway, so an ASM_FIXUP_REGS is done at each label.

runtime/mercury_label.c:
runtime/mercury_label.h:
runtime/mercury_goto.h:
	Insert references to stack layouts into the label table.
	Use the label table when NATIVE_GC is defined.
	Modify the way labels are declared so they have the necessary
	scope.

runtime/mercury_imp.h:
	Include mercury_accurate_gc.h

runtime/mercury_accurate_gc.h:
	Add some macros to define stack layouts for handwritten
	code, and access various fields of the stack layouts.

util/mkinit.c:
	Add NATIVE_GC to the #ifdef .... that controls the running of
	the initialization code for each module. NATIVE_GC requires the
	label table to be initialized.
	Fix this code so the two instances of this list of #defines are
	replaced by a single string constant. I've been bitten _twice_
	by this double definition, and I refuse to be bitten again.

compiler/stack_layout.m:
	Rename MR_LIVE_LVAL to Mr_Live_Lval in the documentation.
1997-12-03 07:05:13 +00:00
Fergus Henderson
c17f3a3573 Add some comments.
Estimated hours taken: 0.25.

library/string.m:
	Add some comments.
1997-10-11 16:11:25 +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
3abc0e7a3e Fix a bug in string__substring: it counting the start
Estimated hours taken: 0.5

library/string.m:
	Fix a bug in string__substring: it counting the start
	position from the end of the string, rather than (as documented)
	from the start of the string.
1997-07-23 16:25:38 +00:00
Thomas Conway
5eedc40f9d Fix a performance bug which meant that it took about 3 cpu minutes for
Estimated hours taken: 2

Fix a performance bug which meant that it took about 3 cpu minutes for
hydra to quote an 85K string in order to io__write it out. The bug was
that string__first_char(in, out, out) has a cost of O(n) in the length
of the string, and term_io__write_escaped_string called it successively
to escape each character of the string. The fix was to add a predicate
string__foldl which is equivalent to
	string__to_char_list(Str, Chars), list__foldl(Closure, Chars, Acc0, Acc)
except that its implementation avoids the intermediate list.

library/string.m:
	add string__foldl (described above)
	add the local predicate string__unsafe_index which doesn't do a
	range check to make sure that the index lies within the string.
	It is called by string__foldl.

library/term_io.m:
	implement term_io__write_escaped_string in terms of string__foldl
	instead of a loop calling string__first_char. The old version had
	a cost O(n^2), the new version a cost of O(n).

NEWS:
	mention string__foldl
1997-07-01 01:40:37 +00:00
Fergus Henderson
b418dcd623 Fix a documentation bug: `-' in a string__format specifier
Estimated hours taken: 0.5

library/string.m:
	Fix a documentation bug: `-' in a string__format specifier
	means left-justification, not right-justification.
1997-06-02 07:00:18 +00:00
Tyson Dowd
257c17f8c9 Remove references to `character' since use of it is discouraged.
Estimated hours taken: 0.05

compiler/llds_out.m:
compiler/mercury_to_goedel.m:
compiler/options.m:
library/lexer.m:
library/string.m:
library/term_io.m:
	Remove references to `character' since use of it is discouraged.
	Use `char' instead.
1997-05-28 07:41:30 +00:00
Fergus Henderson
90dc9ba63e Export a few new predicates from the library, after moving the around
Estimated hours taken: 2

Export a few new predicates from the library, after moving the around
and renaming them, since they seem to be quite useful.

library/char.m:
	Add char__digit_to_int, char__int_to_digit, and char__det_int_to_digit.
	(These are renamed and exported versions of the old
	predicates string__char_to_digit and string__det_char_to_digit
	from `string.m'.)

library/string.m:
	Add string__from_rev_char_list.
	(This is a renamed version of lexer__rev_char_list_to_string.)
	Use char__int_to_digit etc.

library/lexer.m:
	Use string__from_rev_char_list.
1997-05-23 01:21:10 +00:00
Tyson Dowd
cbcb23d17b Enable --warn-interface-imports by default.
Estimated hours taken: 3

Enable --warn-interface-imports by default. This was turned off while
list and term were defined in mercury_builtin.m, since it caused many
warnings.

Fix all the unused interface imports that have been added since then.

compiler/options.m:
	Enable --warn-interface-imports by default.

compiler/module_qual.m:
	Fix formatting inconsistencies with module names in warning
	messages. (".m" was not appended to module names if there was
	only one module).

compiler/*.m:
library/*.m:
tests/invalid/type_loop.m:
tests/warnings/*.m:
	Remove usused interface imports, or move them into
	implementation (mostly bool, list and std_util).
1997-05-21 02:16:53 +00:00
Fergus Henderson
7b687a4a71 Support 8-bit characters, including '\0'. (Previously we didn't
support them because NU-Prolog couldn't support them.)
This required two main changes:
(a) eliminating places where we explicitly assumed that character codes
    ranged from 1 to 127.
(b) making sure that all conversions from `Char' to `Integer' are done
    by first explicitly casting to `UnsignedChar'.  This is necessary
    to avoid potential problems on C compilers for which `char' is signed.

library/char.m:
library/char.nu.nl:
	Replace the implementation of char__to_int as a big table
	with an implementation using pragma c_code, so that it doesn't
	assume that character codes range from 1 to 127.
	Move the old implementation into a new file char.nu.nl,
	since it's still needed for Prolog support.
	Add new predicates char__min_char_value/1 and char__max_char_value/1.

library/Mmakefile:
	Add char.nu.nl to the list of files needed for Prolog support.

library/lexer.m:
	Rewrite io__get_token_[12] in the original (less efficient) way
	that they were written before conway's change in revision 1.17,
	to avoid assuming anything about the range of character codes.
	(Once this change has bootstrapped, it might be worth going back
	to the efficient version, modified of course to assume that
	character codes range from 0..255 rather than 1..127.
	However, at least for bootstrapping we need to use the less
	efficient version.)

runtime/mercury_string.h:
	Add `UnsignedChar' typedef.

library/string.m:
	In string__to_int_list, make sure that the conversion from
	`Char' to `Integer' is done by first explicitly casting to
	`UnsignedChar'.
	Also a few other minor fixes:
		- remove an old XXX by using make_aligned_string()
		- use `size_t' rather than `Word' for a string length;
		- add a missing `const'
		- remove an unnecessary cast to (char)
		- change a `while (--p >= Str) { ...' to
		  `while (p > Str) { p--; ...', because pointing to
		  one before the start of an array is not strictly
		  ANSI-conformant.

compiler/switch_detection.m:
compiler/dense_switch.m:
	Use char__min_char_value and char__max_char_value to avoid
	assuming 7-bit chars.  (We still don't get cross-compilation
	between platforms with different size characters right yet,
	but that's not a major issue right now.)

compiler/export.m:
	Make sure that conversions from `Char' to `Word'
	are done by first explicitly casting to `UnsignedChar'.

NEWS:
	Mention that we now support 8-bit characters.
	Mention the new predicates char__min_char_value/1 and
	char__max_char_value/1, as well as int__int_min, int__int_max,
	int__bits_per_int (which were added previously, with different
	names, but not mentioned in the NEWS file).
	Also make minor cleanups to a few of the other messages.
1997-02-19 05:36:24 +00:00
Fergus Henderson
c6f37bedee When converting floats to strings, make sure we always use
Estimated hours taken: 0.5

library/io.m:
library/string.m:
	When converting floats to strings, make sure we always use
	"%#.15g" rather than "%.15g", to ensure that the result always
	has a decimal point and hence fits the syntax of a Mercury
	floating point literal.  (This was already the case for
	io__write_float/3, but we had forgotten to fix io__write_float/4
	and string__float_to_string.)
1997-01-13 11:45:51 +00:00
Zoltan Somogyi
2c922363d1 Adapt Fergus' suggestions about the -D change.
Estimated hours taken: 0.1

Adapt Fergus' suggestions about the -D change.
1996-12-22 06:44:52 +00:00
Zoltan Somogyi
025d999674 Add string__occurs, a predicate that tests whether a character
Estimated hours taken: 0.1

string:
	Add string__occurs, a predicate that tests whether a character
	occurs within a string.
1996-12-22 06:08:17 +00:00
Zoltan Somogyi
bc87721ded Minor cleanup of the hand-written C code, e.g. make sure that we
Estimated hours taken: 2

io.m, std_util, string, uniq_array:
	Minor cleanup of the hand-written C code, e.g. make sure that we
	follow the standard order (unify, index, compare, term_to_type and
	type_to_term).

mercury_builtin:
	Check that terms converted to type "string" have no arguments.
1996-08-03 12:07:12 +00:00
Fergus Henderson
85597fab7c Add #include of <stdio.h> and <string.h> to avoid
Estimated hours taken: 0.25

library/string.m:
	Add #include of <stdio.h> and <string.h> to avoid
	warnings about undeclared functions in the pragma c_code.
1996-08-01 19:30:40 +00:00
Fergus Henderson
639c42ebcc Fix some bugs in string__format.
Estimated hours taken: 2

Fix some bugs in string__format.

library/string.m:
	Fix a bug where `string__format("%e", [f(0.0)], S)' would
	go into an infinite loop.
	Fix the "%x" conversion so that it uses lower-case hexadecimal
	digits (rather than using uppercase like "%X")
	Also, use the float operators rather than builtin_float_lt,
	builtin_float_times, etc., and use float__abs rather than defining
	our own string__float_abs.
1996-07-24 08:21:57 +00:00
Fergus Henderson
3702767080 Fix a couple of bugs with regard to floating point precision.
Estimated hours taken: 0.5

Fix a couple of bugs with regard to floating point precision.

library/string.m:
	Make sure that in string__float_to_string and string__float_to_f_string
	we use 15 digits of precision rather than the default 6 digits.
1996-07-24 07:31:00 +00:00
Fergus Henderson
b9d9944645 When printing floating point numbers, by default use 15 digits
Estimated hours taken: 2

library/{io.m,string.m}:
	When printing floating point numbers, by default use 15 digits
	of precision rather than 6.
1996-06-10 08:36:09 +00:00
Zoltan Somogyi
5dcb259676 Shut up a warning.
Estimated hours taken: 0.1

string:
	Shut up a warning.
1996-05-31 01:17:25 +00:00
Zoltan Somogyi
87acc4b618 Add reverse modes for the arithmetic predicates and functions,
Estimated hours taken: 6

float, int:
	Add reverse modes for the arithmetic predicates and functions,
	and make unary plus and minus builtins.

io.m, mercury_builtin, std_util, string:
	Make the C code work with --args compact.
	In std_util, reduce the number of comment formats used from 4 to 2.
1996-05-29 10:58:02 +00:00
Zoltan Somogyi
4cff2e339d Add comments showing the future backward modes of arithmetic
Estimated hours taken: 0.5

int, float:
	Add comments showing the future backward modes of arithmetic
	operators; their order is important.

io:
	Add the ability to print strings on binary files, and fix a bug
	in the declaration of io__write_byte/4.

string:
	Removed spaces from ends of lines, etc.
1996-05-15 07:22:35 +00:00
Peter Ross
262aeb0550 Add multi_map to the import_module line so that it get's included
Estimated hours taken: 0.5

library/library.m:
	Add multi_map to the import_module line so that it get's included
	in the library.

library/string.m:
	Add a hidden predicate so that float's get printed correctly by
	string__format.

	If float was smaller the 1e-4 it string__float_to_string converts
	it to the form x.xxxxxe-xx and when you print %f.2 you get
	x.xx not 0.00 as you should.
1996-04-19 14:56:13 +00:00
Fergus Henderson
5fd7e20662 Fix bug in which not all of the necessary initialization functions were
Estimated hours taken: 2

Fix bug in which not all of the necessary initialization functions were
being called (this bug broke profiling).

library/{io.m,mercury_builtin.m,std_util.m,string.m,uniq_array.m}:
	Make sure that there is an INIT function for every BEGIN_MODULE.

library/Mmake:
	Add dependency of library.init on library.dep, to ensure that
	it gets remade when a new module is added.
	Include all the INIT functions defined in pragma(c_code) in *.m
	in library.init.

library/io.m:
	Suppress a spurious warning about unused variable _HeapSpace.
	Remove an unused label.

library/getopt.m:
	Fix incorrect `:- module getopt3.' declaration.
1996-03-11 15:04:44 +00:00
Fergus Henderson
a3a0536af1 Change rule for libmercury.opt.a so that it doesn't recompile
Estimated hours taken: 4

library/Mmake:
	Change rule for libmercury.opt.a so that it doesn't recompile
	everything when anything changes.  Add a rule for installing it.

library/*.m:
	Use pragma(c_code, "...") rather than pragma(c_header_code, "...")
	for C code that is definitions not declarations, so that it works
	with --split-c-files.
1996-03-07 08:53:32 +00:00
Fergus Henderson
39eaab90c0 Move the C implementation of various builtins from the `runtime' directory
Estimated hours taken: 24

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

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

Also a few other miscellaneous changes.

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

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

library/std_util.m:
	Fix the implementation of report_statistics so that it gives
	useful information when using conservative garbage collection.
1996-02-28 14:52:32 +00:00
Fergus Henderson
23b3e9d352 Undo dylan's changes in the names of some library entities,
Estimated hours taken: 1.5

Undo dylan's changes in the names of some library entities,
by applying the following sed script

	s/term_atom/term__atom/g
	s/term_string/term__string/g
	s/term_integer/term__integer/g
	s/term_float/term__float/g
	s/term_context/term__context/g
	s/term_functor/term__functor/g
	s/term_variable/term__variable/g
	s/_term__/_term_/g
	s/std_util__bool_/bool__/g

to all the `.m' and `.pp' files in the compiler and library directories.
The reason for undoing these changes was to minimize incompatibilities
with 0.4 (and besides, the changes were not a really good idea in the first
place).

I also moved `bool' from std_util.m to a separate module.
The main reason for that change is to ensure that the `__' prefix is
only used when it genuinely represents a module qualifier.
(That's what dylan's changes were trying to acheive, but `term__'
does genuinely represent a module qualifier.)

library/bool.m:
	New file, containing stuff previously in std_util.m.
library/*.m:
	Apply sed script above;
	where appropriate, add `bool' to the list of imported modules.
1996-02-03 17:37:07 +00:00
Fergus Henderson
f85b8c514e Allow string__from_char_list to be used bidirectionally.
Estimated hours taken: 1

library/string.m:
	Allow string__from_char_list to be used bidirectionally.
	(XXX reverse mode is unfortunately semidet not det.)
1995-12-28 01:48:03 +00:00
Dylan Shuttleworth
3b03d4bdf2 A sub-string search is needed to find "__" in token labels.
Estimated hours taken: 1+4__
	(Includes time to find string__right/3 documentation error).

A sub-string search is needed to find "__" in token labels.  A KNS search
would be nice, but I'm looking for a particular case where the KNS algorithm
isn't as nice as a brute-force one.

compiler/string.m
	string__sub_string_search/3 is currently a brute force algorithm.

	The changes in string__format are mainly different variable
	names, re-ordered predicate arguements, etc., so as to be
	more like the standard.
1995-11-07 05:36:48 +00:00
Fergus Henderson
07bce464b0 Fix documentation bug reported by dylan.
Estimated hours taken: 0.25

Fix documentation bug reported by dylan.

library/string.m:
	Change the documentation of string__right to match the code.
1995-11-07 04:07:42 +00:00
Dylan Shuttleworth
b69d6ed347 Fix some bugs in string__duplicate_char/3 and string__format/3.
string.m:
	Fix some bugs in string__duplicate_char/3 and string__format/3.
	Modify some comments, and improve style (still bad).
1995-10-25 01:09:17 +00:00
Fergus Henderson
8848809e66 Fix omission in dylan's change: error message should now refer to
string.m:
	Fix omission in dylan's change: error message should now refer to
	char__to_int not char_to_int.  (Thanks to Philip Dart for reporting
	this one.)
1995-10-18 13:22:02 +00:00
Dylan Shuttleworth
eade28c8b1 Allow predicate and mode definitions, and predicate calls to have
compiler/*
	Allow predicate and mode definitions, and predicate calls to have
	module qualifiers.  This allows a restricted form of predicate
	name overloading.

compiler/llds.m, prog_io.m
	In addition to above, these modules now write some labels in `*.c'
	output files with module-name qualifiers.  Predicate `main/2',
	predicates of `mercury_builtin' and special predicates with names
	like `__*__' are not qualified.

compiler/mercury_to_goedel.m
	This module is probably a little more broken than before, as
	module:qualifiers are ignored.



library/char.*, *
	Change some predicate names from `char_*' to `char__*' for better
	consistency, nicer `c' labels.

library/*, compiler/*
	Change calls to predicates `char_*' to `char__*'.
1995-10-17 04:55:22 +00:00
Fergus Henderson
fa5226ee67 Improve the documentation.
library/*.m:
	Improve the documentation.
	Add a "Stability: low/medium/high" comment to all modules,
	which describes the stability of the interface to that module.

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

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

term.m:
	Use the type `comparison_result' from mercury_builtin.m,
	rather than defining an identical type `comparison'.
1995-10-05 11:31:52 +00:00
Fergus Henderson
95460edf24 Allow leading plus or minus sign in string__base_string_to_int.
string.m:
	Allow leading plus or minus sign in string__base_string_to_int.
1995-10-03 02:57:28 +00:00
Fergus Henderson
52426b9d0b Fix bug in string__base_string_to_int_2: need to check that input
string.m:
	Fix bug in string__base_string_to_int_2: need to check that input
	is valid digits for the base.
	(Thanks to warwick for this fix.)
1995-09-19 13:19:06 +00:00
Fergus Henderson
82fab40578 Significantly improve the documentation: use a more uniform
list.m:
	Significantly improve the documentation: use a more uniform
	documentation style, order the pred declarations more logically,
	and add documentation for predicates that didn't have any.

	Rename list__sort as list__sort_and_remove_dups, to better
	reflect its semantics.

	Remove list__split3.

	Export list__take and list__drop.

	Add list__merge_sort in the implementation section.
	(We should probably make list__sort use a merge sort
	algorithm rather than calling list__qsort, but we may
	need a more carefully optimized version of list__merge_sort
	that the naive one I've added.)

set.m, string.m, bintree_set.m:

	Rename list__sort as list__sort_and_remove_dups.
1995-08-26 05:55:50 +00:00
Fergus Henderson
27896cf074 A couple of minor fixes to layout and spelling.
library/string.m:
	A couple of minor fixes to layout and spelling.
1995-08-18 06:02:00 +00:00
Dylan Shuttleworth
436f8ab86c A small ordering change to improve nu-prolog compatability, and
string.m
	A small ordering change to improve nu-prolog compatability, and
	another to improve reliability.
1995-08-16 02:18:15 +00:00
Dylan Shuttleworth
7ad4736e29 string__format. A small bug in precision calculation fixed.
string.m
	string__format.  A small bug in precision calculation fixed.
			 import_module lines rationalised.
1995-07-31 04:12:25 +00:00