mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-15 13:55:07 +00:00
Add MR_TYPECTOR_REP_* to the type_ctor_info to describe the
Estimated hours taken: 30 (including debugging) Add MR_TYPECTOR_REP_* to the type_ctor_info to describe the representation of this type. We want to do this because it allows us to check quickly to see what kind of data representation is being used. Previously this information was spread throughout the type_ctor_layout and type_ctor_functors data structures. It was complex to interpret and contained a lot of unnecessary duplication. We can now omit data structures such as the type_ctor_layout in many cases (it is only necessary for discriminated unions). Because we rule out some of the possible alternatives, the encodings used in the type_ctor_layout can be simplified. Also, the functors indicator in type_ctor_functors can be removed, as it subsumed by this data structure. Use this representation in code that uses RTTI. compiler/base_type_info.m: Add a missing alternative to the type_ctor_rep (this was a bug). library/array.m: library/builtin.m: library/private_builtin.m: runtime/mercury_bootstrap.c: Use MR_TYPECTOR_REP_* in the type_ctor_infos for builtin types. library/std_util.m: runtime/mercury_deep_copy_body.h: runtime/mercury_tabling.c: Use MR_TYPECTOR_REP_* and MR_DISCUNION_TAG_* to dispatch on data representations. Also, fix a bug in deep_copy when copying floating point values. I'm not sure when this stopped working, or if this is exactly the right fix, but it is more correct than the previous code. runtime/mercury_type_info.c: runtime/mercury_type_info.h: Update code to use MR_TYPECTOR_REP_*. Use a struct for type_ctor_info. tests/hard_coded/Mmakefile: tests/hard_coded/deep_copy.m: tests/hard_coded/deep_copy.exp: Add a test case for deep_copy.
This commit is contained in:
@@ -281,7 +281,7 @@ mercury_data_array__type_ctor_info_array_1_struct {
|
||||
Code * f2;
|
||||
Code * f3;
|
||||
Code * f4;
|
||||
Code * f5;
|
||||
Word f5;
|
||||
Word * f6;
|
||||
Word * f7;
|
||||
Word * f8;
|
||||
@@ -291,7 +291,7 @@ mercury_data_array__type_ctor_info_array_1_struct {
|
||||
ENTRY(mercury____Unify___array__array_1_0),
|
||||
ENTRY(mercury____Index___array__array_1_0),
|
||||
ENTRY(mercury____Compare___array__array_1_0),
|
||||
(Word *) &mercury_data_array__type_ctor_layout_array_1,
|
||||
MR_TYPECTOR_REP_ARRAY,
|
||||
(Word *) &mercury_data_array__type_ctor_functors_array_1,
|
||||
(Word *) &mercury_data_array__type_ctor_layout_array_1,
|
||||
string_const(""array"", 5),
|
||||
|
||||
Reference in New Issue
Block a user