Commit Graph

168 Commits

Author SHA1 Message Date
Simon Taylor
b7c4a317e9 Add MR_ prefixes to the remaining non-prefixed symbols.
Estimated hours taken: 4
Branches: main

Add MR_ prefixes to the remaining non-prefixed symbols.

This change will require all workspaces to be updated
The compiler will start generating references to MR_TRUE,
MR_bool, etc., which are not defined in the old runtime
header files.

runtime/mercury_std.h:
	Add MR_ prefixes to bool, TRUE, FALSE, max, min,
	streq, strdiff, strtest, strntest, strneq, strndiff,
	strntest, NO_RETURN.

	Delete a commented out definition of `reg'.

runtime/mercury_tags.h:
	Add an MR_ prefix to TAGBITS.

configure.in:
runtime/mercury_goto.h:
runtime/machdeps/i386_regs.h/mercury_goto.h:
	Add an MR_ prefix to PIC.

runtime/mercury_conf_param.h:
	Allow non-prefixed PIC and HIGHTAGS to be defined on
	the command line.

runtime/mercury_bootstrap.h:
	Add backwards compatibility definitions.

RESERVED_MACRO_NAMES:
	Remove the renamed macros.

compiler/export.m:
compiler/ml_code_gen.m:
	Use MR_bool rather than MR_Bool (MR_Bool is
	meant to be for references to the Mercury type
	bool__bool).

runtime/mercury_types.h:
	Add a comment the MR_Bool is for references to
	bool__bool.

*/*.c:
*/*.h:
*/*.m:
	Add MR_ prefixes.
2002-02-18 07:01:33 +00:00
Simon Taylor
c66cea0665 Add MR_ prefixes to uses of configuration macros.
Estimated hours taken: 2.5
Branches: main

Add MR_ prefixes to uses of configuration macros.
Bootcheck now succeeds with MR_NO_CONF_BACKWARDS_COMPAT.

Mmake.common.in:
	Define MR_NO_CONF_BACKWARDS_COMPAT when checking
	for namespace cleanliness.

RESERVED_MACRO_NAMES:
	Remove the configuration macros.

runtime/mercury_conf_bootstrap.h:
	Remove a duplicate definition of BOXED_FLOAT.

configure.in:
*/*.c:
*/*.h:
*/*.m:
	Add MR_ prefixes.
2002-02-13 09:56:49 +00:00
Ralph Becket
5c79e4e823 Fixed a bug in string__to_float/2 which did not fail when it
Estimated hours taken: 1
Branches: main

library/string.m:
	Fixed a bug in string__to_float/2 which did not fail when it
	should have (i.e. it now also fails if the string argument
	has preceding whitespace or any trailing characters.)

tests/general/string_to_float.m:
tests/general/string_to_float.exp:
tests/general/Mmakefile:
	Added test cases.
2002-02-12 01:39:58 +00:00
Tyson Dowd
cdaafbf4b0 Soon foreign_proc will be impure by default unless given a promise_pure
Estimated hours taken: 8
Branches: main

Soon foreign_proc will be impure by default unless given a promise_pure
or promise_semipure attribute.  The syntax has been accepted for some
time, we now add the necessary declarations.

browser/dl.m:
compiler/timestamp.m:
library/*.m:
tests/hard_coded/unused_float_box_test.m:
	Add promise_pure and promise_semipure declarations for foreign_procs.
2002-01-20 07:32:32 +00:00
Simon Taylor
d4fced7014 Fix my last change. The destructive modes of
Estimated hours taken: 0.25
Branches: main, release

NEWS:
library/string.m:
	Fix my last change. The destructive modes of
	string__set_char aren't buggy, the implementation
	of the static ground term optimization is.
2001-10-26 07:55:47 +00:00
Simon Taylor
4c2ac8eb5a Remove the buggy destructive update modes of string__set_char,
Estimated hours taken: 0.25
Branches: main, release

NEWS:
library/string.m:
	Remove the buggy destructive update modes of string__set_char,
	string__set_char_det and string__unsafe_set_char (they cause
	crashes when applied to constant strings).
2001-10-26 06:52:16 +00:00
Zoltan Somogyi
45db754973 Fix some English errors in comments.
Estimated hours taken: 0.1
Branches: main

library/string.m:
	Fix some English errors in comments.
2001-10-09 04:03:14 +00:00
Yoann Dubreuil
1920fce20f Implementation of string__unsafe_set_char, string__append_iii,
Estimated hours taken: 1
User: ydu
Branches: main


library/string.m:
	Implementation of string__unsafe_set_char, string__append_iii,
	string__append_ooi_3 in MC++
2001-09-12 09:09:56 +00:00
Yoann Dubreuil
8e8ba517c9 Implementation of string__set_char, from_rev_list, float_to_string, contains_char, set_char in Mercury and MC++
Estimated hours taken: 4
User: ydu
Branches: main

library/string.m:
	Implementation of string__set_char, from_rev_list, float_to_string, contains_char, set_char in Mercury and MC++
2001-09-10 11:40:57 +00:00
Yoann Dubreuil
88534454cc Implementation of string__substring in Mercury
Estimated hours taken: 1
User: ydu
Branches: main

library/string.m:
	Implementation of string__substring in Mercury
2001-09-07 15:04:01 +00:00
Yoann Dubreuil
cb5310c901 Implementation of string__join_list in C#
Estimated hours taken: 1
User: ydu
Branches: main

library/string.m:
 	Implementation of string__join_list in C#
2001-09-06 12:05:20 +00:00
Yoann Dubreuil
0433d78631 Implementation of string__to_float in MC++
Estimated hours taken: 0.5
User: ydu
Branches: main

library/string.m:
	Implementation of string__to_float in MC++
2001-09-04 15:12:23 +00:00
Yoann Dubreuil
203265cbca Provide a Mercury implementation of string__append_list.
Estimated hours taken: 0.25
User: ydu
Branches: main

library/string.m:
	Provide a Mercury implementation of string__append_list.
2001-09-04 10:57:59 +00:00
Tyson Dowd
ed3e5c22fa Implement string__append_list and various formatting functions
Estimated hours taken: 6
Branches: main

library/string.m:
	Implement string__append_list and various formatting functions
	in C#.
	Implement a very simple (and incomplete) conversion of printf style
	formatting to .NET formatting.  It is probably a better idea to
	implement printf formatting in Mercury in future, as neither
	.NET nor Java provides printf.

runtime/mercury_mcpp.cpp:
	Add some code to manipulate Mercury lists in the low-level data
	representation.
2001-08-28 12:48:52 +00:00
Tyson Dowd
404e633644 The MC++ interface for functions is buggy.
Estimated hours taken: 10
Branches: main

The MC++ interface for functions is buggy.
This change generates errors in most cases where a function is
implemented in MC++, and removes all the occurances of such functions
from the library.

compiler/mlds_to_il.m:
        Abort if a function is implemented in MC++.  We don't catch the
        case of functions that return int, as it is difficult to be sure
        this isn't just a semidet predicate (which works and is used).
        However this catches a lot of cases where we were silently
        generating bad code so it is better than nothing.

library/Mmakefile:
	Add flags to control debugging (commented out for the moment).
	Move the .NET flags together.

library/builtin.m:
library/float.m:
library/io.m:
library/math.m:
library/sparse_bitset.m:
library/std_util.m:
library/string.m:
	Implement functions in C#, as functions don't work when a
	foreign_proc is MC++.
	This fixes several latent bugs in the library.

runtime/Mmakefile:
	Add support for debugging (commented out for the moment).

runtime/mercury_mcpp.cpp:
	Add code to manipulate low level data structures (so we can do
	this from C# as well as MC++).
2001-08-14 10:19:02 +00:00
Fergus Henderson
272439cf41 Fix a bug in Zoltan's previous change: update the mode of
Estimated hours taken: 0.1
Branches: main

library/string.m:
	Fix a bug in Zoltan's previous change: update the mode of
	string__append_list and string__join_list in the `pragma
	foreign_proc("MC++", ...)' definitions for those predicates,
	to match the mode declaration.
2001-08-13 01:18:04 +00:00
Zoltan Somogyi
f4b091cb5b When printing messages about errors involving overloaded types, print each
Estimated hours taken: 14
Branches: main

When printing messages about errors involving overloaded types, print each
type only once.

compiler/typecheck.m:
	Detect and eliminate duplicate type names in error messages about
	overloaded types.

	When a variable has more than one type, print each type on a line of
	its own, to make the output easier to read. (Since type names currently
	have too many parentheses, further improvements are still possible.)

compiler/mercury_to_mercury.m:
	Provide a mechanism to turn a type into a string without printing it,
	so that it can be checked againt the representations of other types.

	This required changing many of the predicates in this module so that
	instead of doing I/O directly, they go through a typeclass interface
	which has two implementations: one does I/O while the other gathers
	output in a string.

	The performance impact of this change should be acceptable, since I/O
	is slow compared to computation anyway.

compiler/purity.m:
	Provide a predicate that returns a purity prefix as a string, to
	accompany another that prints it out.

compiler/check_typeclass.m:
compiler/prog_util.m:
	Minor changes to conform to the naming scheme now used in
	mercury_to_mercury.m, in particular to the fact the operations of the
	form x_to_string are now functions, not predicates.

	The functionality of prog_util should be unaffected. In check_typeclass
	we may now print more detailed error messages than before.

library/string.m:
	Declare the outputs append, append_list and join_list to be unique.
	Their implementations already return unique strings; declaring them to
	be unique help avoid redundant copying in mercury_to_mercury.m.

library/term_io.m:
	Add alternative versions of some output predicates that return their
	"output" in a string instead.

	Factor out some common code.

tests/invalid/overloading.{m,exp}:
	A test exercising the error message affected by the change.

tests/invalid/Mmakefile:
	Enable the new test.

NEWS:
	Announce the changes in the library.
2001-08-10 08:29:38 +00:00
Fergus Henderson
58585732bf Fix a bug in Tyson's previous change:
Estimated hours taken: 2
Branches: main

library/string.m:
	Fix a bug in Tyson's previous change:
	in string__to_int_list, cast the value from System.Char
	to MR_Integer (i.e. System.Int32) before boxing it.
2001-08-03 17:13:35 +00:00
Zoltan Somogyi
28a5a9dad0 Fix a bug in string__join_list pointed out by Fergus; the length
Estimated hours taken: 1
Branches: main

library/string.m:
	Fix a bug in string__join_list pointed out by Fergus; the length
	calculation and the string copying now use the same logic.

library/tests/hard_coded/join_list.{m,exp}:
	A new test case to exercise string__join_list.

library/tests/hard_coded/Mmakefile:
	Enable the new test.
2001-08-01 00:31:41 +00:00
Tyson Dowd
e9d95ada12 Change calls to mercury::runtime::convert to System::Covert.
Estimated hours taken: 2
Branches: main

library/builtin.m:
library/private_builtin.m:
library/sparse_bitset.m:
library/string.m:
	Change calls to mercury::runtime::convert to System::Covert.
	Use __box instead of mercury::runtime::Convert::ToObject

runtime/Mmakefile:
	Add a rule to remove the DOTNET_DLLS for clean_local.

runtime/mercury_il.il:
	Remove ConvertImpl class, use unbox and ldobj instead of ToInt32.

runtime/mercury_mcpp.cpp:
	Remove Convert class.

runtime/mercury_mcpp.h:
	Use __box instead of mercury::runtime::Convert::ToObject

scripts/Mmake.rules:
	Put the local include directory before the installed one when
	compiling with MC++.
	Also fix the rule for .cpp.dll to be the same as the subdir
	rule.
2001-07-31 10:08:03 +00:00
Peter Ross
d6408abb8c Fix a bug in first_char(in, in, out) where we doing an extra incorrect
Estimated hours taken: 0.25
Branches: main

string.m:
    Fix a bug in first_char(in, in, out) where we doing an extra incorrect
    string comparison.
2001-07-26 09:49:31 +00:00
Peter Ross
c5545d096b Implement string__sub_string_search in MC++.
Estimated hours taken: 0.2
Branches: main

library/string.m:
    Implement string__sub_string_search in MC++.
2001-07-25 16:04:50 +00:00
Zoltan Somogyi
84884dd672 Add a function string__join_list(Separator, Strings), which is like
Estimated hours taken: 0.5
Branches: main

library/string.m:
	Add a function string__join_list(Separator, Strings), which is like
	string__append_list, except it puts Separator between adjacent strings
	in Strings.
2001-06-29 03:30:27 +00:00
Zoltan Somogyi
04e614485d Implement deep profiling; merge the changes on the deep2 branch back
Estimated hours taken: 500
Branches: main

Implement deep profiling; merge the changes on the deep2 branch back
onto the trunk.

The main documentation on the general architecture of the deep profiler
is the deep profiling paper.

doc/user_guide.texi:
	Document how to use the deep profiler.

deep_profiler:
deep_profiler/Mmakefile:
	A new directory holding the deep profiler and its mmakefile.

Mmakefile:
	Add targets for the new directory.

	Add support for removing inappropriate files from directories.

deep_profiler/interface.m:
	The deep profiler consists of two programs: mdprof_cgi.m, which acts
	as a CGI "script", and mdprof_server.m, which implements the server
	process that the CGI script talks to. Interface.m defines the
	interface between them.

script/mdprof.in:
	A shell script template. ../configure uses it to generate mdprof,
	which is a wrapper around mdprof_cgi that tells it how to find
	mdprof_server.

deep_profiler/mdprof_cgi.m:
	The CGI "script" program.

deep_profiler/mdprof_server.m:
	The top level predicates of the server.

deep_profiler/profile.m:
	The main data structures of the server and their operations.

deep_profiler/read_profile.m:
	Code for reading in profiling data files.

deep_profiler/startup.m:
	Code for post-processing the information in profiling data files,
	propagating costs from procedures to their ancestors and performing
	various kinds of summaries.

deep_profiler/server.m:
	Code for responding to requests from the CGI script.

deep_profiler/cliques.m:
	Code to find cliques in graphs.

deep_profiler/array_util.m:
deep_profiler/util.m:
	Utility predicates.

deep_profiler/dense_bitset.m:
	An implementation of (part of) the set ADT with dense bit vectors.

deep_profiler/measurements.m:
	Operations on profiling measurements.

deep_profiler/timeout.m:
	An implementation of a timeout facility.

deep_profiler/conf.m:
	Functions that depend on autoconfigured settings.

configure.in:
	Find out what command to use to find the name of the local host.

	Install deep profiling versions of the standard library along with the
	other profiling versions.

runtime/mercury_conf.h.in:
	Add some macros for deep_profiler/conf.m to use.

library/profiling_builtin.m:
runtime/mercury_deep_call_port_body.h:
runtime/mercury_deep_leave_port_body.h:
runtime/mercury_deep_redo_port_body.h:
	A new library module that implements deep profiling primitives.
	Some of these primitives have many versions, whose common code is
	factor is factored out in three new include files in the runtime.

compiler/deep_profiling.m:
	New module to perform the program transformations described in the
	paper.

compiler/notes/compiler_design.html:
	Document the new compiler module.

compiler/mercury_compiler.m:
	Invoke the new module in deep profiling grades. Allow global static
	data to be generated by deep_profiling.m.

compiler/options.m:
	Add options to turn on deep profiling and (for benchmarking purposes)
	control its implementation.

	Add an optiooption disable tailcall optimization in the LLDS backend,
	to help benchmarking deep profiling.

compiler/jumpopt.m:
compiler/optimize.m:
	Obey the option to disable tailcalls.

compiler/handle_options.m:
	Handle the implications of deep profiling.

compiler/modules.m:
	In deep profiling grades, automatically import profiling_builtin.m.

compiler/prog_util.m:
doc/Makefile:
library/library.m:
	Handle the new builtin module.

compiler/export.m:
	In deep profiling grades, wrap deep profiling code around exported
	procedures to handle the "unscheduled call" aspects of callbacks to
	Mercury from the foreign language.

compiler/higher_order.m:
profiler/demangle.m:
util/demangle.c:
	When creating a name for a higher-order-specialized predicate, include
	the mode number in the name.

compiler/add_trail_ops.m:
compiler/type_util.m:
	Move c_pointer_type from add_trail_ops to type_util, so it can also be
	used by deep_profiling.m.

compiler/hlds_goal.m:
	Add a new goal feature that marks a tail call, for use by
	deep_profiling.m.

compiler/hlds_pred.m:
	Add a new field to proc_info structures for use by deep_profiling.m.

	Add a mechanism for getting proc_ids for procedure clones.

	Remove next_proc_id, an obsolete and unused predicate.

compiler/hlds_data.m:
	Add a new cons_id to refer to the proc_static structure of a procedure.

compiler/bytecode_gen.m:
compiler/code_util.m:
compiler/dependency_graph.m:
compiler/hlds_out.m:
compiler/mercury_to_mercury.m:
compiler/ml_unify_gen.m:
compiler/opt_debug.m:
compiler/prog_rep.m:
compiler/rl_exprn.m:
compiler/switch_util.m:
compiler/unify_gen.m:
	Trivial changes to handle the new cons_id, goal feature and/or
	proc_info argument.

compiler/rtti.m:
	Add a utility predicate for extracting pred_id and proc_id from an
	rtti_proc_label, for use by hlds_out.m

compiler/layout.m:
compiler/layout_out.m:
compiler/llds.m:
compiler/llds_common.m:
	Add support for proc_static and call_site_static structures.

compiler/layout_out.m:
compiler/llds_out.m:
	Add code for the output of proc_static structures.

compiler/code_util.m:
	Make code_util__make_proc_label_from_rtti a function, and export it.

util/mkinit.c:
compiler/llds_out.m:
compiler/layout.m:
compiler/modules.m:
	Add support for a fourth per-module C function, for writing out
	proc_static structures (and the call_site_static structures they
	contains).

	Since proc_static structures can be referred to from LLDS code (and not
	just from other static structures and compiler-generated C code),
	reorganize the declarations of static structures slightly.

	Change the schema for the name of the first per-module C function
	slightly, to make it the addition of the fourth function easier.
	The scheme now is:

		mercury__<modulename>__init
		mercury__<modulename>__init_type_tables
		mercury__<modulename>__init_debugger
		mercury__<modulename>__write_out_proc_statics

	Improve formatting of the generated C code.

library/*.m:
runtime/mercury.c:
runtime/mercury_context.c:
runtime/mercury_engine.c:
runtime/mercury_ho_call.c:
runtime/mercury_tabling.c:
runtime/mercury_trace_base.c:
runtime/mercury_wrapper.c:
trace/mercrury_trace.[ch]:
trace/mercrury_trace_declarative.c:
trace/mercrury_trace_external.c:
trace/mercrury_trace_internal.c:
	Conform to the new scheme for initialization functions for hand-written
	modules.

compiler/mercury_compile.m:
library/benchmarking.m:
runtime/mercury_conf_param.h:
runtime/mercury.h:
runtime/mercury_engine.c:
runtime/mercury_goto.c:
runtime/mercury_grade.h:
runtime/mercury_ho_call.c:
runtime/mercury_label.[ch]:
runtime/mercury_prof.[ch]:
	Add an MR_MPROF_ prefix in front of the C macros used to control the
	old profiler.

compiler/handle_options.m:
runtime/mercury_grade.h:
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
	Make deep profiling completely separate from the old profiling system,
	by making the deep profiling grade independent of MR_MPROF_PROFILE_TIME
	and the compiler option --profile-time.

library/array.m:
library/builtin.m:
library/std_util.m:
runtime/mercury_hand_unify_body.h:
runtime/mercury_hand_compare_body.h:
	In deep profiling grades, wrap the deep profiling call, exit, fail
	and redo codes around the bodies of hand-written unification
	and comparison procedures.

	Make the reporting of array bounds violations switchable between
	making them fatal errors, as we currently, and reporting them by
	throwing an exception. Throwing an exception makes debugging code
	using arrays easier, but since exceptions aren't (yet) propagated
	across engine boundaries, we keep the old behaviour as the default;
	the new behaviour is for implementors.

runtime/mercury_deep_profiling_hand.h:
	New file that defines macros for use in Mercury predicates whose
	definition is in hand-written C code.

library/exception.m:
runtime/mercury_exception_catch_body.h:
runtime/mercury_stacks.h:
	In deep profiling grades, wrap the deep profiling call, exit, fail
	and redo codes around the bodies of the various modes of builtin_catch.

	Provide a function that C code can use to throw exceptions.

library/benchmarking.m:
library/exception.m:
library/gc.m:
library/std_util.m:
runtime/mercury_context.[ch]:
runtime/mercury_engine.[ch]:
runtime/mercury_debug.c:
runtime/mercury_deep_copy.c:
runtime/mercury_overflow.h:
runtime/mercury_regs.h:
runtime/mercury_stacks.h:
runtime/mercury_thread.c:
runtime/mercury_wrapper.c:
	Add prefixes to the names of the fields in the engine and context
	structures, to make code using them easier to understand and modify.

runtime/mercury_deep_profiling.[ch]:
	New module containing support functions for deep profiling and
	functions for writing out a deep profiling data file at the end of
	execution.

runtime/mercury_debug.[ch]:
	Add support for debugging deep profiling.

	Add support for watching the value at a given address.

	Make the buffered/unbuffered nature of debugging output controllable
	via the -du option.

	Print register contents only if -dr is specified.

runtime/mercury_goto.h:
runtime/mercury_std.h:
	Use the macros in mercury_std.h instead of defining local variants.

runtime/mercury_goto.h:
runtime/mercury_stack_layout.h:
runtime/mercury_stack_trace.c:
runtime/mercury_tabling.c:
trace/mercury_trace.c:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
trace/mercury_trace_vars.c:
	Standardize some of the macro names with those used in the debugger
	paper.

runtime/mercury_heap.h:
	Add support for memory profiling with the deep profiler.

runtime/mercury_prof.[ch]:
runtime/mercury_prof_time.[ch]:
	Move the functionality that both the old profiler and the deep profiler
	need into the new module mercury_prof_time. Leave mercury_prof
	containing stuff that is only relevant to the old profiler.

runtime/mercury_prof.[ch]:
runtime/mercury_strerror.[ch]:
	Move the definition of strerror from mercury_prof to its own file.

runtime/mercury_wrapper.[ch]:
	Add support for deep profiling.

	Add suppory for controlling whether debugging output is buffered or
	not.

	Add support for watching the value at a given address.

runtime/Mmakefile:
	Mention all the added files.

scripts/mgnuc.in:
	Add an option for turning on deep profiling.

	Add options for controlling the details of deep profiling. These
	are not documented because they are intended only for benchmarking
	the deep profiler itself, for the paper; they are not for general use.

tools/bootcheck:
	Compile the deep_profiler directory as well as the other directories
	containing Mercury code.

	Turn off the creation of deep profiling data files during bootcheck,
	since all but one of these in each directory will be overwritten
	anyway.

	Add support for turning on --keep-objs by default in a workspace.

tools/speedtest:
	Preserve any deep profiling data files created by the tests.

trace/mercury_trace.c:
	Trap attempts to perform retries in deep profiling grades, since they
	would lead to core dumps otherwise.

util/Mmakefile:
	Avoid compile-time warnings when compiling getopt.

tests/*/Mmakefile:
tests/*/*/Mmakefile:
	In deep profiling grades, switch off the tests that test features
	that don't work with deep profiling, either by design or because
	the combination hasn't been implemented yet.
2001-05-31 06:00:27 +00:00
Tyson Dowd
fec4b7733b Check for foreign_proc, as we require it to work if we wish to
Estimated hours taken: 2
Branches: main release

configure.in:
	Check for foreign_proc, as we require it to work if we wish to
	bootstrap.

library/*.m:
	Turn foreign_code/3+ into foreign_proc by applying the
	following subsitutions:

	First turn all foreign_code into foreign_proc:
		s/foreign_code\(/foreign_proc\(/g

	Then turn back any foreign_proc with a string as its second
	argument.
		s/foreign_proc(\("[A-Za-z0-9+]*",[ \t\n]*")/foreign_code$1/g
2001-03-15 07:42:27 +00:00
Fergus Henderson
b6708a0801 Various fixes for the GCC back-end.
Estimated hours taken: 4

Various fixes for the GCC back-end.

library/array.m:
library/private_builtin.m:
library/sparse_bitset.m:
library/string.m:
library/table_builtin.m:
library/time.m:
	Add #includes for header files needed by these modules.

compiler/modules.m:
	Add the extra object files needed for the GCC back-end
	(and for fact tables) to the .pic_os list as well as to
	the .os list.

compiler/gcc.m:
	Delete the second copy of a duplicated paragraph in the comments.

compiler/mlds_to_gcc.m:
	Fix a bug that showed up after my recent change which added
	an MLDS->MLDS optimization that converted assignments into
	initializers.  The bug was that the code here didn't handle
	the case when an initializer for a local variable refers to
	another local variable declared earlier in the same block.
2001-02-26 01:34:09 +00:00
Fergus Henderson
90106ca1da Avoid the use of `long double', because this causes problems
Estimated hours taken: 1

library/string.m:
	Avoid the use of `long double', because this causes problems
	with lcc on Linux, since lcc does not use the same
	representation for `long double' as gcc and glibc.
	(lcc treats `long double' as 8 bytes, the same as `double',
	whereas `gcc' has a 12-byte `long double'.)
	The code here was using `long double' just in case `MR_Float'
	was `long double', but currently `MR_Float' is only ever
	`double' or `float', not `long double', so that isn't needed.

	This is a bug in lcc on Linux (lcc is not a conforming hosted
	C implementation), but we may as well work around it.
2001-02-12 04:31:07 +00:00
Tyson Dowd
53f2dbc1b4 First implementation of the standard library in managed C++.
Estimated hours taken: 200

First implementation of the standard library in managed C++.

configure.in:
	Autodetect the .NET SDK, and set MS_DOTNET_SDK_DIR based on it.
	Find the IL assembler, and set ILASM.

compiler/inlining.m:
	Turn off inlining of pragma_foreign_code with the IL backend.

compiler/mlds_to_c.m:
	Add a comment questioning the foreign language interfacing still to be
        done in this backend, and remove the "inline target code" from
        this list (since it has been completed).

compiler/mlds_to_il.m:
	Generate code for :- external.  We generate a forwarding
	function to the expected implementation in
	<modulename>__c_code.cpp

	Rename all the classes to use MixedCase, and to put them in the
	mercury.runtime namespace.

compiler/mlds_to_ilasm.m:
	Don't use the System or mercury namespaces by default.
	Change the names of the runtime cpp files to mercury_mcpp.dll
	and mercury_il.dll.
	Use c_util to output unops and binops.

doc/user_guide.texi:
	Document MS_CL_NOASM, MS_CLFLAGS and EXTRA_MS_CLFLAGS.

library/*.m:
	Rename pragma c_code as pragma foreign_code("C", ...).
	Add pragma foreign_code for MC++.
	Only a fraction of the predicates are implemented, everything
	else simply throws and exception when called.
	Implementations of predicates marked with :- external are
	provided as pragma foreign_code, but are commented out.

library/Mmakefile:
runtime/Mmakefile:
	Add targets for building the dlls for the library.

runtime/mercury_mcpp.cpp:
runtime/mercury_mcpp.h:
	Implementation of the runtime.

runtime/mercury_il.il:
	This file mainly implements things that can't be written in
	managed C++ (e.g. function pointers).

scripts/Mmake.rules:
scripts/Mmake.vars.in:
        Add rules for generating .dlls and .exes from .ils and .cpps.
2001-01-01 04:04:05 +00:00
Zoltan Somogyi
d4920def3b Add missing MR_ prefixes.
Estimated hours taken: 0.5

library/*.m:
	Add missing MR_ prefixes.
2000-11-28 05:52:00 +00:00
Zoltan Somogyi
090552c993 Make everything in the runtime use MR_ prefixes, and make the compiler
Estimated hours taken: 10

Make everything in the runtime use MR_ prefixes, and make the compiler
bootstrap with -DMR_NO_BACKWARDS_COMPAT.

runtime/mercury_*.[ch]
	Add MR_ prefixes to all functions, global variables and almost all
	macros that could pollute the namespace. The (intentional) exceptions
	are

	1. some function, variable, type and label names that already start
	   with MR_, mercury_, Mercury or _entry;
	2. some standard C macros in mercury_std.h;
	3. the macros used in autoconfiguration (since they are used in scripts
	   as well as the runtime, the MR_ prefix may not be appropriate for
	   those).

	In some cases, I deleted things instead of adding prefixes
	if the "things" were obsolete and not user visible.

runtime/mercury_bootstrap.h:
	Provide MR_-less forms of the macros for bootstrapping and for
	backward compatibility for user code.

runtime/mercury_debug.[ch]:
	Add a FILE * parameter to a function that needs it.

compiler/code_info.m:
compiler/export.m:
compiler/fact_table.m:
compiler/llds.m:
compiler/llds_out.m:
compiler/pragma_c_gen.m:
compiler/trace.m:
	Add MR_ prefixes to the C code generated by the compiler.

library/*.m:
	Add MR_ prefixes to handwritten code.

trace/mercury_trace_*.c:
util/mkinit.c:
	Add MR_ prefixes as necessary.

extras/concurrency/semaphore.m:
	Add MR_ prefixes as necessary.
2000-11-23 02:01:11 +00:00
Mark Brown
f2b701e9d5 Fix a comment.
Estimated hours taken: 0

library/string.m:
	Fix a comment.
2000-11-18 13:59:29 +00:00
Fergus Henderson
1351851723 Work around a GNU C problem in grade asm_fast.gc.tr.debug,
Estimated hours taken: 1

library/string.m:
	Work around a GNU C problem in grade asm_fast.gc.tr.debug,
	where gcc failed to compile the recently-added `set_char' procedures,
	aborting with the following message:

		string.c: In function `string_module70':
		string.c:46208: fixed or forbidden register 3 (bx) was
			spilled for class GENERAL_REGS.
		This may be due to a compiler bug or to impossible asm
		statements or clauses.

	The work-around was to move the code which actually sets the
	character into a separate C function.
2000-11-16 05:29:31 +00:00
Michael Day
f8fbb8338e Allows checking string length without losing uniqueness and adds
Estimated hours taken: 2.5

Allows checking string length without losing uniqueness and adds
predicates to allow changing arbitrary characters in a string, handy for
implementation of string streams.

library/string.m:
        Added a new mode definition to string__length/2 using unique input
        so as not to destroy uniqueness when checking string length. Also
        modified the mode definition of string__length/1 to use unique
	output.

        Added three new predicates, string__set_char, set_char_det and
	unsafe_set_char that allow changing arbitrary characters in a
        string. These function similarly to the corresponding index,
	index_det and unsafe_index predicates. There are also functional
        forms of set_char_det and unsafe_set_char.

	Also changes index implementation to use MR_Unsigned not MR_Word.
2000-11-13 08:06:16 +00:00
Simon Taylor
dedcf29a30 Make the function versions of predicates appear in the
Estimated hours taken: 2.5

library/*.m
	Make the function versions of predicates appear in the
	Mercury Library Reference Manual.
2000-11-12 08:51:39 +00:00
Zoltan Somogyi
d0ce4439bc Fix C compiler warnings about shadowing String and about
Estimated hours taken: 0.2

library/string.m:
	Fix C compiler warnings about shadowing String and about
	casting away const.
2000-11-06 04:32:20 +00:00
Simon Taylor
b8625dc7ef Recode string__sub_string_search using the C library
Estimated hours taken: 0.5

library/string.m:
	Recode string__sub_string_search using the C library
	function strstr(). This reduces the time taken
	by `mmc -C make_hlds' by almost 5%.

	Add a comment warning about the efficiency of
	string__first_char.
2000-10-26 05:25:07 +00:00
Zoltan Somogyi
1c8cb6faf2 Get the compiler to bootstrap with -DMR_NO_BACKWARDS_COMPAT.
Estimated hours taken: 2

Get the compiler to bootstrap with -DMR_NO_BACKWARDS_COMPAT.

compiler/c_util.m:
compiler/rtti_out.m:
	Add MR_ prefixes to various type names in generated code.

compiler/*.m:
browser/*.m:
library/*.m:
	Add MR_prefixes to various type and function names in pragma C code.

runtime/*.[ch]:
trace/*.[ch]:
	Add MR_prefixes to various type and function names in
	hand-written code.
2000-10-16 01:34:14 +00:00
Ralph Becket
2d6142f7a9 Efficiency improvements to string.m (mainly changing predicates
Estimated hours taken: 1

Efficiency improvements to string.m (mainly changing predicates
that used the costly string__first_char/3 to cheaper, alternative
methods).

Added det function versions of the string-to-int predicates.

library/string.m:
	string__base_string_to_int/3 now uses string__foldl2/6.
	string__is_{alpha,alpha_or_underscore,alnum_or_underscore}/1
	now use string__all_match/2.
	string__det_to_int/1 and string__det_base_string_to_int/2
	functions added.
2000-09-28 07:40:40 +00:00
Fergus Henderson
31eadee813 Fix a bug in petdr's recent changes to string__format that
Estimated hours taken: 1.5

Fix a bug in petdr's recent changes to string__format that
broke things in non-gc grades on sparcs.

runtime/mercury_string.c:
	In MR_make_string(), wrap calls to restore/save_transient_hp()
	around the call to MR_make_aligned_string_msg(), as mentioned
	in the documentation for MR_make_aligned_string_msg().

runtime/mercury_string.h:
	Document that calls to MR_make_string need to be wrapped inside
	calls to save/restore_transient_hp().

library/string.m:
	Wrap calls to MR_make_string inside calls to
	save/restore_transient_hp().
2000-09-14 15:24:51 +00:00
Fergus Henderson
1b7c19450b Document that the current implementation treats null characters
Estimated hours taken: 0.25

library/string.m:
	Document that the current implementation treats null characters
	as string terminators.

	Also change the "main authors" from "fjh, dylan" to "fjh, petdr",
	since petdr has replaced all of dylan's code for string__format.
2000-09-14 08:20:34 +00:00
Ralph Becket
be317defc3 Small additions to list and string.
Estimated hours taken: .5

Small additions to list and string.

library/list.m:
	Added func ++/2 as a synonym for list__append/2.

library/string.m:
	Added func ++/2 as a synonym for string__append/2.

Index: list.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/list.m,v
retrieving revision 1.92
diff -u -r1.92 list.m
--- list.m	2000/07/19 03:41:54	1.92
+++ list.m	2000/09/08 15:51:52
@@ -86,7 +86,11 @@
 	% to a rewrite rule.
 :- promise all [L,H,T] ( append([H], T, L) <=> L = [H|T] ).

+	% L1 ++ L2 = L :- list__append(L1, L2, L).
+	%
+:- func list(T) ++ list(T) = list(T).

+
 	% list__remove_suffix(List, Suffix, Prefix):
 	%	The same as list__append(Prefix, Suffix, List) except that
 	%	this is semidet whereas list__append(out, in, in) is nondet.
@@ -1321,3 +1325,9 @@
 	P = ( pred(X::in, Y::in, Z::out) is det :- Z = F(X, Y) ),
 	list__merge_and_remove_dups(P, Xs, Ys, Zs).

+% ---------------------------------------------------------------------------- %
+
+L1 ++ L2 = list__append(L1, L2).
+
+% ---------------------------------------------------------------------------- %
+% ---------------------------------------------------------------------------- %
Index: string.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/string.m,v
retrieving revision 1.127
diff -u -r1.127 string.m
--- string.m	2000/08/17 09:58:05	1.127
+++ string.m	2000/09/08 15:51:57
@@ -34,6 +34,11 @@
 %       that it is semidet.  Use string__remove_suffix instead.
 % :- mode string__append(out, in, in) is semidet.

+:- func string ++ string = string.
+%	S1 ++ S2 = S :- string__append(S1, S2, S).
+%
+%	Nicer syntax.
+
 :- pred string__remove_suffix(string, string, string).
 :- mode string__remove_suffix(in, in, out) is semidet.
 %	string__remove_suffix(String, Suffix, Prefix):
@@ -1874,6 +1879,10 @@
 	  else
 		preceding_boundary(SepP, String, I - 1)
 	).
+
+% ---------------------------------------------------------------------------- %
+
+S1 ++ S2 = string__append(S1, S2).

 % ---------------------------------------------------------------------------- %
 % ---------------------------------------------------------------------------- %
2000-09-08 15:53:16 +00:00
Peter Ross
4bcba99d86 Avoid the cast to long before printing integers.
Estimated hours taken: 1

Avoid the cast to long before printing integers.  This cast is
problematic when printing negative integers with the format string "%x".
For instance on the alpha a long is 64 bits and a MR_integer is 32 bits,
so printing -31 is printed as ffffffffffffffe1 instead of ffffffe1.

configure.in:
    Determine the length modifier to use for MR_Integer.

runtime/mercury_conf.h.in:
    Record the length modifer using the #define
    MR_INTEGER_LENGTH_MODIFIER.

library/string.m:
    Add a new function int_length_modifier which returns the length
    modifier to use for a MR_Integer.
    Add an extra argument to make_format which is the length modifier to
    use when constructing the format string.
2000-08-17 09:58:06 +00:00
Peter Ross
1cdc18cce9 Fix a bug where "%.f" wasn't parsed as a valid format string.
Estimated hours taken: 0.5

library/string.m:
    Fix a bug where "%.f" wasn't parsed as a valid format string.  If no
    number follows the '.' the precision should default to 0, which is
    what is now done.
2000-08-10 16:34:16 +00:00
Peter Ross
c848ef1e93 Reimplement string__format so that it uses less memory and it's
Estimated hours taken: 24

Reimplement string__format so that it uses less memory and it's
behaviour is closer to the C standard.

library/string.m:
    Reimplement string__format.  The new implementation parses the
    format string building a control structure.  The control structure
    is then traversed to generate the output.
    Implement string__to_char_list in C.
    Implement string__append_list in C as this results in no garbage
    being generated due to the creation of the intermediate strings,
    which can be quite a significant saving.
    Remove the string__append_list(out, in) mode as it generates an
    infinite number of solutions.
    Use MR_allocate_aligned_string_msg for all memory allocations.

runtime/mercury_string.h:
    Add a new macro MR_allocate_aligned_string_msg which allocates
    word aligned space for storage of a string in.

runtime/mercury_string.c:
    Define a new function MR_make_string which provides sprintf like
    functionality for creating MR_Strings.  This function is safe from
    buffer overflows providing the vsnprintf function is available.

runtime/Mmakefile:
    Add mercury_string.c

configure.in:
    Check for the vsnprintf function.

runtime/mercury_conf.h.in:
    Define HAVE_VSNPRINTF.
2000-08-10 09:01:17 +00:00
Peter Ross
30fc249c77 Add some MR_ prefixes.
Estimated hours taken: 0.2

string.m:
    Add some MR_ prefixes.
2000-08-08 09:30:02 +00:00
Peter Ross
73fc817310 Add MR_ prefixes as required.
Estimated hours taken: 1

library/string.m:
    Add MR_ prefixes as required.
2000-08-08 09:13:44 +00:00
Zoltan Somogyi
b3bb237aac Fix syntax error.
Estimated hours taken: 0.1

library/string.m:
	Fix syntax error.
2000-04-27 10:24:25 +00:00
Ralph Becket
687e33f261 Added function to string.m to split strings up into lists of `words'.
Estimated hours taken: .5

Added function to string.m to split strings up into lists of `words'.

library/string.m
	Added string__length/1 function.

library/string.m
	Added function string__words/2.
2000-04-27 09:31:46 +00:00
Fergus Henderson
a636a6ba82 Fix an inconsistency in the manual, which was using
Estimated hours taken: 0.25

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

library/string.m:
	Use `multi' rather than `multidet', to match the
	language reference manual.
2000-03-20 09:01:49 +00:00
Zoltan Somogyi
e475da1d2c Put MR_ prefixes on uses of string_const(), make_aligned_string()
Estimated hours taken: 0.2

library/*.m:
	Put MR_ prefixes on uses of string_const(), make_aligned_string()
	variants, and COMPARE_EQUAL and friends, in order to allow bootstrap
	with -DMR_NO_BACKWARDS_COMPAT.
1999-11-15 10:12:19 +00:00