mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-15 13:55:07 +00:00
Estimated hours taken: 16
Branches: main
Type_desc__get_functor looks up the types of the arguments of a function
symbol. This predicate used to abort when an argument has an existential
type. This diff makes type_desc__get_functor work even in that case.
However, since in such cases the type of an argument is not a ground type,
this diff has to add the concept of a pseudo_type_desc, a descriptor for
a not necessarily ground type. Pseudo_type_descs are implemented as
MR_PseudoTypeInfos.
runtime/mercury_type_info.[ch]:
Add new macros to operate on pseudo_type_infos. Most have a structure
modelled on corresponding macros operating on type_infos.
Provide versions of MR_get_arg_type_info, MR_compare_type_info,
MR_unify_type_info, MR_collapse_equivalences,
MR_type_params_vector_to_list, MR_create_type_info and
MR_create_type_info_maybe_existq that work on pseudo_type_infos,
not type_infos.
Change MR_pseudo_type_info_vector_to_type_info_list, which implements
the core of get_functor, to return pseudo_type_infos instead of
type_infos, and rename it to reflect this fact.
Change to four-space indentation to reduce the number of lines
that have to be wrapped.
runtime/mercury_make_type_info_body.h:
Generalize the code for creating type_infos to also be handle
pseudo_type_infos.
Change to four-space indentation to reduce the number of lines
that have to be wrapped.
runtime/mercury_type_desc.[ch]:
Provide versions of MR_make_type_ctor_desc and MR_type_ctor_and_args
that work on pseudo_type_infos, not type_infos.
Change to four-space indentation to reduce the number of lines
that have to be wrapped.
runtime/mercury_builtin_types.[ch]:
runtime/mercury_builtin_types_proc_layouts.h:
runtime/mercury_hlc_types.h:
runtime/mercury_unify_compare_body.h:
Add the C types, global variables and functions necessary for the
new builtin Mercury type pseudo_type_desc. This type must be builtin,
because its structure (MR_PseudoTypeInfo) is defined in C, and as such
cannot be unified, compared, deconstructed etc without hand-written
C code.
runtime/mercury_deep_copy.c:
runtime/mercury_deep_copy_body.h:
Handle the copying of pseudo_type_infos/pseudo_type_descs. This code
is almost the same as the code to copy type_infos, but must of course
handle type variables, and the arguments are themselves copied as
pseudo_type_infos, not type_infos.
runtime/mercury_types.h:
Since deep copy needs to create pseudo_type_infos, provide a version
of the MR_PseudoTypeInfo type without const.
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
Handle pseudo_type_descs just as we handle type_descs: neither can be
constructed, nor do they have function symbols with named arguments.
runtime/mercury_ml_expand_body.c:
Provide code to deconstruct pseudo_type_descs. This code is almost
the same as the code to deconstruct type_descs, but must of course
handle type variables, and the arguments are themselves
pseudo_type_descs, not type_descs.
runtime/mercury_tabling.c:
Catch attempts to table pseudo_type_infos.
runtime/mercury_tags.h:
Add macros for constructing lists of
pseudo_type_infos/pseudo_type_descs.
runtime/mercury_wrapper.[ch]:
Define global variables holding the addresses of the typeinfos for
describing pseudo_type_descs and lists of pseudo_type_descs.
runtime/mercury_init.c:
Add the extern declarations required by new code in mkinit.c.
util/mkinit.c:
Make the addresses of the typeinfos for describing pseudo_type_descs
and lists of pseudo_type_descs, defined in the library, known to the
runtime.
library/type_desc.m:
Add a new builtin type, pseudo_type_desc, for describing possibly
nonground types.
Add utility predicates for operating on pseudo_type_descs.
library/private_builtin.m:
Handle the new builtin type.
Add builtin typeinfos for describing pseudo_type_descs and lists of
pseudo_type_descs, since some functions in the runtime need them
for memory profiling.
library/rtti_implementation.m:
Handle the new builtin type, mostly by ignoring it, since the backends
that use this module do not have any notion of pseudo_type_infos.
Bring the module up to date with our formatting guidelines.
library/construct.m:
Make get_functor return a list of pseudo_type_descs instead of
type_descs.
Change the name of the version of get_functor that returns argument
names, to distinguish it from the base version by more than just the
arity.
Make the order of predicates more logical.
library/std_util.m:
Change the name of the version of get_functor that returns argument
names, to distinguish it from the base version by more than just the
arity.
However, this name change is effectively the only change: both
get_functor and get_functor_with_names still return lists of
type_descs. This means that they will throw exceptions in the presence
of existential types, but code using them need no algorithmic changes.
library/term.m:
library/term_to_xml.m:
Add module qualifiers as necessary; no algorithmic changes.
library/list.m:
Add two general-purpose predicates, all_true and all_false,
for use in the other library modules.
compiler/ml_util.m:
compiler/mlds_to_gcc.m:
compiler/rtti.m:
compiler/type_ctor_info.m:
Make sure we handle the new builtin type as a builtin type, and not
try to have the compiler create a type_ctor_info for it.
deep_profiler/canonical.m:
Delete the local definition of all_true.
tests/hard_coded/construct_test.{m,exp}:
Update this test case to test the ability to retrieve the names of the
fields of function symbols with existential types.
Add module qualifications as necessary.
tests/hard_coded/construct_test_exist.{m,exp}:
Add a tougher test case to print the types of the arguments of
function symbols with existential types.
tests/hard_coded/Mmakefile:
Add the new test case, and sort the names of the tests.
20 lines
706 B
Plaintext
20 lines
706 B
Plaintext
5 functors in this type
|
|
4 - f15/3 [E513, list(E514), E514] [_, _, _]
|
|
3 - f14/2 [E513, list(E514)] [_, _]
|
|
2 - f13/3 [int, E513, list(E513)] [_, _, _]
|
|
1 - f12/1 [int] [_]
|
|
0 - f11/0 [] []
|
|
|
|
2 functors in this type
|
|
1 - f22/5 [int, E513, list(E513), E513, float] [f21name, f22name, f23name, f24name, f25name]
|
|
0 - f21/0 [] []
|
|
|
|
2 functors in this type
|
|
1 - f32/4 [int, pair(int, E513), tree234(int, pair(string, pair(E513, E514))), string] [f31name, f32name, f33name, f34name]
|
|
0 - f31/2 [int, string] [_, _]
|
|
|
|
2 functors in this type
|
|
1 - f32/4 [int, pair(list(int), E513), tree234(list(int), pair(float, pair(E513, E514))), float] [f31name, f32name, f33name, f34name]
|
|
0 - f31/2 [list(int), float] [_, _]
|
|
|