Commit Graph

16 Commits

Author SHA1 Message Date
Zoltan Somogyi
e4b0328ade Provide a mechanism for declaring foreign types that can be operated on by
Estimated hours taken: 4
Branches: main

Provide a mechanism for declaring foreign types that can be operated on by
compare_representation. The intended use of the mechanism is to declare
a foreign type to represent proc_layouts in the declarative debugger,
as part of the representation of atoms; since atoms are keys in maps
in the oracle, they are input to compare_representation.

Since we don't want the result of compare_representation to change as
execution proceeds, we require an assertion that the foreign value is
stable, i.e. that the value of the foreign type variable completely
determines the data it points to, directly and indirectly. Proc_layouts
are static, so this is not a problem. Being able to do the comparison
requires the foreign type to be an integral type or a pointer, which
is what the existing can_pass_as_mercury_type assertion promises.
The stability is promised by a new assertion.

For foreign types that have both assertions, we use a new type_ctor_rep,
which differs from the existing type_ctor_rep for foreign types by doing
a real comparison instead of an abort in compare_representation.

doc/reference_manual.texi:
	Document the new kind of assertion.

compiler/prog_data.m:
	Add the new kind of assertion.

compiler/prog_io_pragma.m:
	Parse the new kind of assertion.

compiler/rtti.m:
	Add the representation of the new type_ctor_rep. Factor out the
	stability of c_pointers as well as foreign types.

compiler/type_ctor_info.m:
	Generate the new type_ctor_rep for types with both assertions.

compiler/foreign.m:
	Export a predicate for use by type_ctor_info.m.

compiler/mercury_to_mercury.m:
	Print the new assertion.

compiler/*.m:
	Minor changes to conform to the diffs above.

	Use state variable notation.

library/rtti_implementation.m:
	Handle the new type_ctor_rep.

runtime/mercury_mcpp.h:
runtime/mercury_type_info.h:
java/runtime/TypeCtorRep.java:
	Add the new type_ctor_rep to the runtime.

runtime/mercury_mcpp.h:
runtime/mercury_type_info.h:
compiler/type_ctor_info.m:
	Increment the rtti version number.

	When we rely on the availability of this new capability,
	we should add a test for the new rtti version number to configure.in.

runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_term_size.h:
	Handle stable foreign types the same way as other foreign types.

runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.h:
runtime/mercury_unify_compare_body.h:
	Handle stable foreign types in a useful manner, relying on the
	assertions behind them.

tests/hard_coded/stable_foreign.{m,exp}:
	A test case for the handling of values of a stable foreign type.

tests/hard_coded/Mmakefile:
	Enable the new test case.
2004-06-28 04:50:10 +00:00
Zoltan Somogyi
112ddad251 Delete the univ type_ctor_rep, since we haven't used it in a long time,
Estimated hours taken: 2
Branches: main

Delete the univ type_ctor_rep, since we haven't used it in a long time,
and add two new type_ctor_reps: one for subgoals, so that they won't have
to be treated specially when deconstructed, and one for a future type,
stable_c_pointer, which is the same as c_pointer except that it guarantees
that the entire data structure it points to, directly and indirectly is
read only, which means that its values can be tabled. The intention is
to use stable_c_pointers to represent robdds.

runtime/mercury_type_info.h:
	Make the change above.

runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_ml_expand_body.h:
runtime/mercury_tabling.c:
runtime/mercury_unify_compare_body.h:
	Handle the two new type_ctor_reps, and delete the code handling univs.

compiler/mlds_to_gcc.m:
java/runtime/TypeCtorRep.java:
library/private_builtin.m:
runtime/mercury_mcpp.h:
runtime/mercury_mcpp.cpp:
	Update the list of type_ctor_reps, including fixing some old errors
	in some files.

library/rtti_implementation.m:
	Update the list of type_ctor_reps, and modify the routines that
	interpret the RTTI accordingly.
2003-05-13 08:52:09 +00:00
Zoltan Somogyi
207832f8a7 Make sure that every switch in the runtime on type constructor representations
Estimated hours taken: 1
Branches: main

Make sure that every switch in the runtime on type constructor representations
covers all the possible type_ctor_rep values. By using switches with no default
value, gcc will warn about any missing cases. To protect against illegal
values, we check whether the integer we convert to the MR_TypeCtorRep enum
is the right range. To protect against silent failures on platforms which
do not have a warning for missing cases, enforce a rule that all switch cases
return to the caller, instead of falling through to code that returns. (We
had no switches that were followed by any code more substantial than return,
and we are not likely to need one in the future either.)

runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_ml_expand_body.h:
runtime/mercury_tabling.c:
runtime/mercury_unify_compare_body.h:
	Make the change described above. In some files, eliminating gcc
	warnings required adding previously unhandled cases.

runtime/mercury_type_info.h:
	Add a macro for doing the range test.
2003-05-13 06:09:03 +00:00
Zoltan Somogyi
9489e15291 *** empty log message *** 2003-05-02 21:44:17 +00:00
Ralph Becket
a8ffd3680c Change the compiler and tools so that .' and not :' is now used as the
Estimated hours taken: 14
Branches: main

Change the compiler and tools so that `.' and not `:' is now used as the
module separator in all output.

Infix `.' now has associativity yfx and priority 10.

NEWS:
	Report the change.

configure.in:
	Amend the test for an up-to-date Mercury compiler to check whether
	it recognises `.' as a module qualifier.

compiler/code_gen.m:
compiler/error_util.m:
compiler/hlds_out.m:
compiler/prog_out.m:
compiler/prog_util.m:
compiler/rl_exprn.m:
compiler/rl_gen.m:
compiler/source_file_map.m:
compiler/unused_args.m:
library/io.m:
library/rtti_implementation.m:
library/type_desc.m:
runtime/mercury_debug.c:
runtime/mercury_deconstruct.c:
runtime/mercury_stack_trace.c:
	Change `:' to `.' as module separator for output.

compiler/mercury_to_mercury.m:
compiler/prog_io_typeclass.m:
	As above.
	Fixed a bug where `.' was not being recognised as a module separator.

doc/reference_manual.texi:
	Report the change.

library/term_io.m:
	Ensure that infix `.' is written without surrounding spaces.

tests/hard_coded/dot_separator.m:
tests/hard_coded/dot_separator.exp:
tests/hard_coded/Mmakefile:
	Test case added.
2003-01-17 05:57:20 +00:00
Zoltan Somogyi
404abb0c57 Another step towards RTTI in Mercury.
Estimated hours taken: 32
Branches: main

Another step towards RTTI in Mercury.

This step redefines the representation of type_ctor_infos inside the compiler
to be identical to the representation we will need for efficient interpretation
of RTTI data structures in Mercury, following on from an earlier step which
did the same for (pseudo)typeinfos.

Instead of the type_ctor_info being broken down into its components in
type_ctor_info.m, the breakdown process is now performed in rtti_out.m (for the
LLDS backend) and rtti_to_mlds.m (for the MLDS backend). Eventually, the IL and
Java backends will stop using rtti_to_mlds.m for this purpose, and will instead
write out the type_ctor_data structures as static data to be interpreted
directly.

We now predefine the C types representing type_info and pseudo_type_infos
for types of arity up to 20 for the LLDS C backend as well as for the
MLDS C backend. The LLDS backend can define them for higher arities
on demand; the MLDS backend (for now) still cannot.

runtime/mercury_type_info.h:
	To be able to represent all the kinds of types we now support

	- add a data structure for converting values of reserved_addr types
	  from their printable representation to their internal representation
	  (it was previously missing), and

	- add a type_ctor_rep to represent foreign types.

	Add missing MR_ prefixes on some field names.

	Add typedefs for all the types that the rtti_names can refer to.
	There were already such typedefs in runtime/mercury.h for the MLDS
	grades, we now have them for the LLDS grades too.

	Predefine the C types representing type_info and pseudo_type_infos
	for types of arity up to 20. There were already such typedefs in
	runtime/mercury.h for the MLDS grades, we now have them for the
	LLDS grades too.

runtime/mercury.h:
	Delete the typedefs that are now in mercury_type_info.h.

runtime/mercury.h:
	Delete the definitions of the C types representing type_info and
	pseudo_type_infos, since these are now in mercury_type_info.h.
	#include mercury_type_info.h.

compiler/rtti.m:
	Add new, purely Mercury data structures for representing
	type_ctor_infos and their components, designed both for efficient
	interpretation and as a source for the generation of static data
	structures in C.

	This entailed deleting most of the alternatives of the rtti_data type
	while preserving their rtti_name equivalents; the deleted alternatives
	represent tables are no longer created in type_ctor_info.m but which
	are created dynamically in rtti_out.m and rtti_to_mlds.m (which need
	a way for one table to refer to another).

	Centralize the correspondence between rtti_names and the C and Java
	types of the corresponding structures (the C and Java names differ in
	prefixes only). Among other things, this remove the double maintenance
	problem we have previously with the LLDS and MLDS backends maintaining
	their own maps of the correspondence.

	Add utility predicates on the new data structures for use by both
	rtti_out.m and rtti_to_mlds.m.

compiler/hlds_module.m:
	Always store the ids of unification and comparison procedures in
	type_ctor_gen_infos, to simplify their handling.

compiler/type_ctor_info.m:
	Generate the new data structures for representing type_ctor_infos.

	Conform to the changed data structures for type_ctor_gen_infos.

compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
	Rewrite substantial parts of these modules to convert the new data
	structures for representing type_ctor_infos to sets of discrete
	structures dynamically.

	Most of the dynamically created structures are unique by construction,
	but this is not true for typeinfos and pseudo-typeinfos. Therefore
	add mechanisms to ensure that we don't generate redundant structures
	representing typeinfos and pseudo-typeinfos.

compiler/mlds_to_c.m:
compiler/mlds_to_java.m:
	Use the standard mechanisms for creating C and Java type names.

compiler/mlds_to_gcc.m:
	Conform to the changed data structures in rtti.m and
	mercury_type_info.h.

compiler/opt_debug.m:
	Conform to the changed data structures in rtti.m.

compiler/dead_proc_elim.m:
	Conform to the changed data structures for type_ctor_gen_infos.

compiler/pseudo_type_info.m:
	Add a predicate to construct a representation of a type that may or may
	not be ground.

compiler/mlds_to_gcc.m:
java/runtime/TypeCtorRep.java:
library/private_builtin.m:
library/rtti_implemenation.m:
runtime/mercury_mcpp.{cpp,h}:
	Add the type_ctor_rep for foreign types to the lists of type_ctor_reps.

library/construct.m:
library/deconstruct.m:
	Add missing MR_ prefixes on field names.

runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_ml_expand_body.h:
runtime/mercury_tabling.c:
runtime/mercury_type_info.c:
runtime/mercury_unify_compare_body.h:
	Handle the type_ctor_rep for foreign types.

	Add missing MR_ prefixes on field names.

library/list.m:
	Add two utility predicates, is_empty and is_not_empty, for use with
	higher order code.

NEWS:
	Mention the new predicates in list.m. Delete a duplicate entry.
2002-08-01 11:52:29 +00:00
Zoltan Somogyi
43fbf4b956 A step towards RTTI in Mercury.
Estimated hours taken: 40
Branches: main

A step towards RTTI in Mercury.

This step redefines the representation of pseudo-typeinfos inside the compiler
to be identical to the representation we will need for efficient interpretation
of RTTI data structures in Mercury. Later steps will do likewise for
typectorinfos. In the end, we will have two implementations of RTTI:
the current low-level, very efficient one written in C, which will be used
by the C backends (both LLDS and MLDS), and a new, higher-level one
which will use Mercury data structures and Mercury predicates for
interpretation (along the lines of library/rtti_implementation.m)
for the Java and IL backends.

A large part of this change concerns the fact that pseudo-typeinfos can now
contain typeinfos as well as other pseudo-typeinfos, and they do in the
frequent case that the type of an argument is ground. Given that typeinfos
are just special cases of pseudo-typeinfos, the code for handling the two
types is usually similar, with common code factored out when relevant.

In the process of redesigning the data structures concerning (pseudo-)
typeinfos, I also fixed an old naming scheme that has become misleading.
The representation of a (pseudo-) typeinfo depends on whether the principal
type constructor is fixed arity or not. We used to denote this distinction
with the phrases first-order vs higher-order, since at first the only variable
arity type constructors were pred and func. However, this hasn't been true
since we added tuples. I have changed the naming scheme to be fixed-arity vs
variable-arity.

compiler/rtti.m:
	Add new, purely Mercury data structures for representing typeinfos
	and pseudo-typeinfos, designed both for efficient interpretation
	and as a source for the generation of static data structures in C.

compiler/pseudo_type_info.m:
	Delete the type definitions here, since they are superseded by the new
	definitions in rtti.m.

	Add predicates for constructing typeinfos as well as pseudo-typeinfos,
	since now we need those too.

	Conform to the changed data structures for (pseudo-) typeinfos.

compiler/ll_pseudo_type_info.m:
compiler/ml_closure_gen.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/opt_debug.m:
compiler/type_ctor_info.m:
	Conform to the changed data structures for (pseudo-) typeinfos.

compiler/mlds.m:
	Since the MLDS now refers to type_infos, add their type
	(mlds__type_info_type) to the list of types the MLDS knows about.

compiler/ml_code_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
	Handle mlds__type_info_type.

compiler/mlds_to_gcc.m:
	Conform to the changed data structures for (pseudo-) typeinfos,
	and handle mlds__type_info_type.

runtime/mercury_bootstrap.h:
	Override the compiler-generated names of the type_ctor_infos of the
	variable arity type constructors. The MLDS backend requires these
	to be module qualified; the LLDS backend requires them to be
	unqualified. This is a problem because the same code now generates
	the compiler's internal representation of pseudo-typeinfos for both
	backends.

	The temporary solution is to have the compiler generate these names
	module qualified, and have these macros convert them to the unqualified
	form. (The long term solution should be to always module qualify
	everything, but doing that is for another change.)

runtime/mercury_type_info.h:
	Change the naming scheme from first order vs higher order to fixed
	arity vs variable arity.

library/construct.m:
library/deconstruct.m:
runtime/mercury.c:
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_make_type_info_body.h:
runtime/mercury_ml_expand_body.h:
runtime/mercury_tabling.c:
runtime/mercury_type_desc.c:
runtime/mercury_type_info.c:
runtime/mercury_unify_compare_body.h:
	Conform to the new naming scheme.

runtime/mercury.h:
	Conform to the new naming scheme.

	Declare fixed and variable arity types for typeinfos as well as
	pseudo-typeinfos, since pseudo-typeinfos can now refer to typeinfos.
2002-04-12 01:24:25 +00:00
Zoltan Somogyi
62c3375f5d Fix the RTTI of type_descs and type_ctor_descs.
Estimated hours taken: 40
Branches: main

Fix the RTTI of type_descs and type_ctor_descs. Make comparisons between
type_ctor_descs and type_ctor_infos (and therefore between type_descs and
type_infos) more predictable and consistent across backends by basing them
on programmer-visible attributes instead of accident of location in the
executable.

runtime/mercury_type_desc.[ch]:
	Implement unification and comparison functions for type_ctor_descs.
	(The unification and comparison functions for type_infos also double
	as the unification and comparison functions for type_descs.)

	Make the comparison function work on the module name, type name and
	arity instead of the address of the type_ctor_info structure. This
	ensures consistency across back ends.

	Add some useful macros.

runtime/mercury_type_info.[ch]:
	Make the comparison function on type_ctor_infos also work on module
	name, type name and arity. Since this makes comparison slower, add
	specialized unification functions for type_infos and type_ctor_infos.

runtime/mercury_type_info.h:
runtime/mercury_mcpp.{h,cpp}:
runtime/mercury.h:
library/private_builtin.m:
library/rtti_implementation.m:
java/runtime/TypeCtorRep.java:
compiler/mlds_to_gcc.m:
	Add type_ctor_reps for type_descs and type_ctor_descs. Type_ctor_descs
	definitely need it, since their representation is very low level and
	not shared with anything else. Type_descs could use the type_ctor_rep
	of type_infos, since type_descs and type_infos share the same
	representation at the moment. However, we add a new one because
	profiling cares about the conceptual distinction between type_infos
	and type_descs.

library/type_desc.m:
	Delete the Mercury "definition" of type_desc, because it is misleading.
	Implement it as a builtin type.

runtime/mercury.[ch]:
	Implement type_ctor_desc as a builtin type.

	Add missing implementations of unify/compare on type_ctor_infos.

runtime/mercury_deconstruct.c:
runtime/mercury_ml_expand_body.h:
	Implement deconstruction for type_descs and type_ctor_descs.

runtime/mercury_ho_call.c:
runtime/mercury_unify_compare_body.h:
	Implement unify and compare for type_descs and type_ctor_descs.

	Implement unify for type_infos, type_ctor_infos, type_descs and
	type_ctor_descs by calling the relevant unification function,
	not the relevant comparison function, since the unification
	function will be faster.

runtime/mercury_deep_copy_body.h:
runtime/mercury_construct.c:
runtime/mercury_tabling.c:
	Minor changes to handle type_descs and type_ctor_descs.

trace/mercury_trace_vars.c:
	Enable the printing of type_descs and type_ctor_descs.

tests/debugger/type_desc_test.{m,inp,exp,exp2}:
	New test case to check the printing of type_descs and type_ctor_descs.

tests/debugger/Mmakefile:
	Enable the new test case.

tests/hard_coded/type_ctor_desc_manip.{m,exp}:
	New test case to check the deconstruction and comparison of type_descs
	and (especially) type_ctor_descs. Before this change, we got different
	results for comparisons of type_ctor_descs, results that were
	inconsistent with the results of comparisons of the type_descs
	that the type_ctor_descs were derived from.

tests/hard_coded/Mmakefile:
	Enable the new test case.
2002-03-27 05:18:58 +00:00
Zoltan Somogyi
7570fac833 Some of fjh's review comments on my change to enable the deconstruction and
Estimated hours taken: 3
Branches: main

Some of fjh's review comments on my change to enable the deconstruction and
printing of igher order terms arrived after I committed that change. This diff
addresses those comments.

library/deconstruct.m:
	Specify what happens with include_details_cc.


runtime/mercury_deconstruct.c:
	Add a second argument to MR_expand_type_name that specifies whether
	the name of the type specified by the first argument should be wrapped
	in <<>> or not.

runtime/mercury_ml_expand_body.h:
 	Handle type_ctor_infos by returning the type name (without <<>>) as
	a zero-arity functor.

runtime/mercury_type_info.[ch]:
	Delete the code for expanding out type_ctor_info "equivalences", since
	as Fergus pointed out the concepts doesn't make sense.

trace/mercury_trace_internal.c:
	When the user turns the printing of optional values off or on,
	make that change take effect immediately.

tests/debugger/queens.{inp,exp*}:
	Test the immediate nature of the print_optionals command.

NEWS:
	Announce the print_optionals command.
2002-03-12 03:40:42 +00:00
Fergus Henderson
c4c11ef5ac Fix incorrect handling of transient registers:
Estimated hours taken: 4
Branches: main

runtime/mercury_ml_expand_body.h:
	Fix incorrect handling of transient registers:
	- Delete the incorrect wrapping of
	  MR_restore_transient_hp()/MR_save_transient_hp()
	  around calls to the FUNCTION MR_expand_type_name(),
	  which expects the heap pointer to be saved (if transient);
	  the hp is already saved (if transient) before the call,
	  and trying to restore it immediately after a call to
	  a C function has returned will just fill it with garbage.
	- Wrap MR_restore_transient_hp()/MR_save_transient_hp()
	  around calls to the MACRO MR_make_aligned_string,
	  because it expects the hp register to be valid,
	  and because it can allocate heap.

runtime/mercury_ml_expand_body.h:
runtime/mercury_deconstruct.c:
	Add default cases that call MR_fatal_error() to a couple of switch
	statements, to supress gcc warnings about uninitialized variables.
2002-02-22 01:14:18 +00:00
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
Zoltan Somogyi
fcccbd166f Reorganize deconstruct.m so that each predicate that deconstructs terms has
Estimated hours taken: 12
Branches: main

Reorganize deconstruct.m so that each predicate that deconstructs terms has
three variants:

- One that aborts when attempting to deconstruct non-canonical terms.

- One that succeeds when attempting to deconstruct a term of a non-canonical
  type, but returns a constant such as "<<noncanonical>>" for such
  deconstructions. It still aborts when deconstructing a noncanonical term
  of an ordinarily canonical type, which can happen with HAL if the term
  is currently a variable.

- One that succeeds when attempting to deconstruct non-canonical terms of both
  kinds, but whose determinism requires its caller to be in a committed choice
  context.

Each of the predicates function, arg, named_arg, deconstruct and
limited_deconstruct now has an extra argument that selects one of the three
variants above. Each of these predicates now has three modes, one for each
value of this argument. The separate predicates with _cc at the ends of their
names are now superseded by one of these modes.

At the same time, I also eliminated the distinction between arg and argument.
Arg used to check if the returned argument was of the expected type, and fail
if it wasn't, while argument used to return a univ. The new arg now returns
a value of an existential type, which the caller can now typecheck or put
into a univ as it pleases.

The descriptions of the changes:

library/deconstruct.m:
	Implement the changes discussed above. Work around a bug by making
	the foreign_procs return a univ from which we later extract the value;
	this inefficiency should be fixed later, when the typechecker has been
	fixed to allow different clauses to return existentially typed values.

library/std_util.m:
	Reimplement the forwarding predicates that call deconstruct.m in terms
	of its new interface.

library/io.m:
	Make use of the new functionality in deconstruct.m to offer versions
	of io__print and io__write that allow the user to choose how to print
	noncanonical terms.

library/private_builtin.m:
	Export the `sorry' predicate for use in deconstruct.m and elsewhere.

runtime/mercury_deconstruct.[ch]:
runtime/mercury_ml_expand_body.h:
runtime/mercury_ml_arg_body.h:
runtime/mercury_ml_deconstruct_body.h:
runtime/mercury_ml_functor_body.h:
	Implement the new functionality.

library/store.m:
extras/trailed_update/tr_store.m:
	Conform to the new interfaces of some functions in the updated files
	in the runtime.

tests/debugger/polymorphic_output.exp*:
	Update for an updated error message.

tests/hard_coded/deconstruct_arg.{m,exp*}:
	Update the test case to test the committed choice versions of the
	deconstruction predicates as well as the usual versions. (The aborting
	versions cannot all be tested in a single test case.)
2002-02-04 05:23:10 +00:00
Zoltan Somogyi
2b559ad054 Move the RTTI-related parts of std_util.m to three new modules in the standard
Estimated hours taken: 8
Branches: main

Move the RTTI-related parts of std_util.m to three new modules in the standard
library, and (in the case of embedded C code) to new modules in the runtime.
The main reason for this is to allow a reorganization of some of the
RTTi-related functionality without breaking backward compatibility. However,
the new arrangement should also be easier to maintain.

Use a separate type_ctor_rep for functions, to distinguish them from predicates
for RTTI code. (At one point, I thought this could avoid the need for the
change to the initialization files mentioned below. It can't, but it is a good
idea in any case.)

library/std_util.m:
	Remove the functionality moved to the new modules, and replace them
	with type equivalences and forwarding code. There are no changes in
	the meanings of the user-visible predicates, with two exceptions.

	- First, the true, equivalence-expanded names of what used to be
	  std_util:type_desc and std_util:type_ctor_desc are now
	  type_desc:type_desc and type_desc: type_ctor_desc.
	- Second, deconstructing a function term now yields
	  "<<function>>" instead of "<<predicate>>".

	The intention is that the RTTI predicates in std_util.m will continue
	to work in a backwards-compatible manner for the near future, i.e. as
	the new modules are updated, the code in std_util will be updated to
	maintain the same functionality, modulo improvements such as avoiding
	unwanted exceptions. When the RTTI functionality in the other modules
	has stabilised, the RTTI predicates in std_util.m should be marked
	obsolete.

	The exported but non-documented functionality of std_util has been
	moved to one of the new modules without forwarding code, with one
	of the moved predicates being turned into the function it should have
	been in the first place.

library/construct.m:
library/deconstruct.m:
library/type_desc.m:
	Three new modules for the code moved from std_util.m.

library/library.m:
compiler/modules.m:
	Record the names of the three new library modules.

runtime/mercury.[ch]:
compiler/mlds_to_il.m:
	Record that type_desc is now in type_desc.m, not std_util.m.

compiler/static_term.m:
	Import the deconstruct module, since we are using its undocumented
	facilities.

runtime/Mmakefile:
	Mention the two new modules.

runtime/mercury_construct.[ch]:
runtime/mercury_type_desc.[ch]:
	Two new modules holding the C functions that used to be in foreign_code
	in std_util, now using MR_ instead of ML_ prefixes, and being more
	consistent about indentation.

runtime/mercury_type_info.h:
	Add a new type_ctor_rep for functions, separate from predicates.
	(It reuses the EQUIV_VAR type_ctor_rep, which hasn't been used
	in ages.)

	Use type_ctor_reps to distinguish between the type_ctor_infos of
	pred/0 and func/0. However, to create higher order typeinfos, we
	still need to know the addresses of the type_ctor_infos for
	pred/0 and func/0, and we still need to know the address of the
	type_ctor_info for tuples to create typeinfos for tuples. Since
	these three type_ctor_infos are defined in the library,
	we cannot access them directly from the runtime. We therefore need
	to access them indirectly in the usual manner, via address_of
	variables initialized by mkinit-generated code.

library/builtin.m:
library/private_builtin.m:
library/rtti_implementation.m:
runtime/mercury.c:
runtime/mercury_mcpp.{h,cpp}:
java/TypeCtorRep.java:
	Updates to accommondate the new function type_ctor_rep.

runtime/mercury_type_info.[ch]:
	Add some functions from foreign_code in std_util that fit in best here.

runtime/mercury_ml_expand_body.h:
runtime/mercury_tabling.h:
runtime/mercury_unify_compare_body.h:
	Delete the code for handling EQUIV_VAR, and add code for handling
	functions.

runtime/mercury_init.h:
runtime/mercury_wrapper.[ch]:
	Add three variables holding the address of the type_ctor_infos
	representing functions, predicates and tuples.

util/mkinit.c:
	Fill in these three variables.

tests/general/accumulator/construct.{m,exp}:
tests/general/accumulator/deconstruct.{m,exp}:
tests/hard_coded/construct.{m,exp}:
	Rename these tests by adding a _test at the ends of their names,
	in order to avoid collisions with the names of the new standard library
	modules. The test cases have not changed, with the exception of the :-
	module declaration of course.

tests/general/accumulator/Mmakefile:
tests/general/accumulator/INTRODUCED:
tests/hard_coded/Mmakefile:
	Record the name changes.

tests/hard_coded/existential_float.exp:
	Updated the expected output to reflect that deconstructions now print
	"<<function>>" instead of "<<predicate>>" when appropriate.

tests/hard_coded/higher_order_type_manip.exp:
	Updated the expected output to reflect the new name of what used to be
	std_util:type_desc.

trace/mercury_trace_browse.c:
trace/mercury_trace_external.c:
trace/mercury_trace_help.c:
	#include type_desc.h instead of std_util.h, since the C functions
	we want to call are now defined there.

trace/mercury_trace_vars.c:
	Update to account for the movement of type_desc from std_util to
	type_desc, and ensure that we don't refer to any type_ctor_infos
	in MLDS grades.
2002-01-30 05:09:13 +00:00
Zoltan Somogyi
b5c571c500 This is the first half of a change that removes redundant fields from
Estimated hours taken: 12
Branches: main

This is the first half of a change that removes redundant fields from
type_ctor_info structures.

configure.in:
	Do not require an exact match on the RTTI version number.

runtime/mercury_type_info.h:
	Update the RTTI version number.

	Add the new definition of type_ctor_infos.

	Add prefixes to the fields in type_ctor_infos that did not already have
	them.

	Provide macros to access the fields in the changed part of
	type_ctor_infos in a way that works with both the old and new
	type_ctor_info structures.

	Move some stuff so that macros that logically belong together are next
	to each other.

runtime/mercury_mcpp.h:
	Update the RTTI version number and the macros for defining
	type_ctor_infos.

library/rtti_implementation.m:
	Update the mechanism for access to type_ctor_info fields.

	Add prefixes to field names and use RTTI-version-independent macros
	as necessary.

compiler/hlds_module.m:
compiler/rtti.m:
	Delete obsolete fields from the terms from which type_ctor_info
	structures are derived.

compiler/dead_proc_elim.m:
	Minor changes to conform to this change in data structure.

compiler/type_ctor_info.m:
	Minor changes to conform to this change in data structure.
	Update the RTTI version number.

compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
	Output the new type_ctor_info structure.

compiler/llds_out.m:
compiler/mlds_to_c.m:
	Emit a #define to select the new type_ctor_info structure.

library/std_util.m:
runtime/mercury.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_ho_call.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_tabling.c:
runtime/mercury_type_info.c:
runtime/mercury_type_tables.c:
runtime/mercury_unify_compare_body.h:
tests/hard_coded/type_tables.m:
trace/mercury_trace.c:
	Add prefixes to field names and use RTTI-version-independent macros
	as necessary.
2002-01-25 08:23:39 +00:00
Zoltan Somogyi
0ddb8857b5 This is the second half of a change that reduces the size of type_ctor_info
Estimated hours taken: 8
Branches: main

This is the second half of a change that reduces the size of type_ctor_info
structures, and moves the version number to the start (immediately after the
arity) to make future changes easier.

This is a bootstrapping change; you will need to recompile all your files
after it is installed. The bootstrap tag is bootstrap_20020111_grade_v4.

configure.in:
	Require the use of a compiler that implements the first half of this
	change.

runtime/mercury_bootstrap.h:
	Add synonyms for use until this change is installed on all machines.

runtime/mercury_deconstruct.c:
	Make some code RTTI-version independent.

runtime/mercury_grade.h:
	Increment the grade version number to prevent linking of code of that
	doesn't understand the new type_ctor_info structure with code that
	requires it.

runtime/mercury_type_info.h:
	Delete the old versions of the type_ctor_info structure and update
	the appropriate macros.
2002-01-11 04:43:32 +00:00
Zoltan Somogyi
ce62be8669 Add committed choice versions of the functions and predicates that deconstruct
Estimated hours taken: 12
Branches: main

Add committed choice versions of the functions and predicates that deconstruct
terms. These versions succeed even if the the term being deconstructed is of a
non-canonical type.

NEWS:
	Mention the new procedures.

library/std_util.m:
	Add the following procedures: functor_cc, argument_cc, det_argument_cc,
	named_argument_cc, det_named_argument_cc, deconstruct_cc and
	limited_deconstruct_cc.

	To avoid code duplication, factor out the code common to several
	procedures and put it into three new files in the runtime directory,
	mercury_ml_{fuctor,arg,deconstruct__body.h.

	Add arguments to the various expansion functions to control what they
	should do for non-canonical types. Move them to mercury_deconstruct.c
	in the runtime directory to make it easier to access them from other
	places.

	Fix some bugs in the code for det_arg and family in the computation
	of abort messages.

library/store.m:
extras/trailed_update/tr_store.m:
trace/mercury_trace_vars.c:
	Adjust the references to the expansion functions.

runtime/mercury_deconstruct.[ch]:
	A new module to contain the expansion functions.

runtime/mercury_ml_arg_body.h:
runtime/mercury_ml_deconstruct_body.h:
runtime/mercury_ml_functor_body.h:
	New files to contain the bodies of the std_util procedures for
	deconstructing terms.

runtime/mercury_deconstruct_macros.h:
	A new header file for macros used in several places.

library/Mmakefile:
runtime/Mmakefile:
	Add the new files to the required lists.
2002-01-09 06:41:35 +00:00