[m-rev.] for review: Fix MR_named_arg_num for RTTI changes introduced with subtypes.
Peter Wang
novalazy at gmail.com
Wed Apr 7 16:27:46 AEST 2021
runtime/mercury_deconstruct.c:
Use MR_index_or_search_ptag_layout to search du type layouts by
primary tag and MR_index_or_search_sectag_functor to search
sectag_alternatives by secondary tag, as required for subtypes.
(MR_named_arg_num is used by the debugger.)
---
runtime/mercury_deconstruct.c | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/runtime/mercury_deconstruct.c b/runtime/mercury_deconstruct.c
index 7888cefa7..01c104247 100644
--- a/runtime/mercury_deconstruct.c
+++ b/runtime/mercury_deconstruct.c
@@ -127,7 +127,6 @@ MR_named_arg_num(MR_TypeInfo type_info, MR_Word *term_ptr,
const char *arg_name, int *arg_num_ptr)
{
MR_TypeCtorInfo type_ctor_info;
- MR_DuTypeLayout du_type_layout;
const MR_DuPtagLayout *ptag_layout;
const MR_DuFunctorDesc *functor_desc;
const MR_NotagFunctorDesc *notag_functor_desc;
@@ -147,39 +146,28 @@ MR_named_arg_num(MR_TypeInfo type_info, MR_Word *term_ptr,
case MR_TYPECTOR_REP_DU_USEREQ:
case MR_TYPECTOR_REP_DU:
data = *term_ptr;
- du_type_layout = MR_type_ctor_layout(type_ctor_info).MR_layout_du;
+
ptag = MR_tag(data);
- // XXX SUBTYPE cannot index du_type_layout for subtypes
- ptag_layout = &du_type_layout[ptag];
+ MR_index_or_search_ptag_layout(ptag, ptag_layout);
switch (ptag_layout->MR_sectag_locn) {
case MR_SECTAG_NONE:
case MR_SECTAG_NONE_DIRECT_ARG:
- // We can index MR_sectag_alternatives for
- // MR_SECTAG_NONE_*.
- functor_desc = ptag_layout->MR_sectag_alternatives[0];
+ sectag = 0;
break;
case MR_SECTAG_LOCAL_REST_OF_WORD:
sectag = MR_unmkbody(data);
- // XXX SUBTYPE cannot index MR_sectag_alternatives
- functor_desc = ptag_layout->MR_sectag_alternatives[sectag];
break;
case MR_SECTAG_LOCAL_BITS:
sectag = MR_unmkbody(data) &
((1 << ptag_layout->MR_sectag_numbits) - 1);
- // XXX SUBTYPE cannot index MR_sectag_alternatives
- functor_desc = ptag_layout->MR_sectag_alternatives[sectag];
break;
case MR_SECTAG_REMOTE_FULL_WORD:
sectag = MR_field(ptag, data, 0);
- // XXX SUBTYPE cannot index MR_sectag_alternatives
- functor_desc = ptag_layout->MR_sectag_alternatives[sectag];
break;
case MR_SECTAG_REMOTE_BITS:
sectag = MR_field(ptag, data, 0) &
((1 << ptag_layout->MR_sectag_numbits) - 1);
- // XXX SUBTYPE cannot index MR_sectag_alternatives
- functor_desc = ptag_layout->MR_sectag_alternatives[sectag];
break;
case MR_SECTAG_VARIABLE:
MR_fatal_error("MR_named_arg_num(): unexpected variable");
@@ -187,6 +175,9 @@ MR_named_arg_num(MR_TypeInfo type_info, MR_Word *term_ptr,
MR_fatal_error("MR_named_arg_num(): invalid sectag_locn");
}
+ MR_index_or_search_sectag_functor(ptag_layout, sectag,
+ functor_desc);
+
if (functor_desc->MR_du_functor_arg_names == NULL) {
return MR_FALSE;
}
--
2.30.0
More information about the reviews
mailing list