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.
This commit is contained in:
Zoltan Somogyi
2004-06-28 04:50:10 +00:00
parent 35834907f5
commit e4b0328ade
23 changed files with 292 additions and 80 deletions

View File

@@ -2,7 +2,7 @@
** vim:ts=4 sw=4 expandtab
*/
/*
** Copyright (C) 2003 The University of Melbourne.
** Copyright (C) 2003-2004 The University of Melbourne.
** This file may only be copied under the terms of the GNU Library General
** Public License - see the file COPYING.LIB in the Mercury distribution.
*/
@@ -280,6 +280,7 @@ try_again:
case MR_TYPECTOR_REP_C_POINTER:
case MR_TYPECTOR_REP_STABLE_C_POINTER:
case MR_TYPECTOR_REP_FOREIGN:
case MR_TYPECTOR_REP_STABLE_FOREIGN:
#ifdef MR_DEBUG_TERM_SIZES
if (MR_heapdebug && MR_lld_print_enabled) {
printf("MR_term_size: c_pointer/foreign %p\n", (void *) term);