[m-rev.] for review: Use consistent integer types for some RTTI fields.
Peter Wang
novalazy at gmail.com
Mon Nov 19 14:37:00 AEDT 2018
On Sat, 17 Nov 2018 17:32:50 +1100 (AEDT), "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
>
>
> On Sat, 17 Nov 2018 15:05:58 +1100, Peter Wang <novalazy at gmail.com> wrote:
> > diff --git a/compiler/rtti.m b/compiler/rtti.m
> > index 43cce7dab..c91e34f17 100644
> > --- a/compiler/rtti.m
> > +++ b/compiler/rtti.m
> >
> > :- type type_ctor_data
> > ---> type_ctor_data(
> > - tcr_version :: int,
> > + tcr_version :: int8,
> > tcr_module_name :: module_name,
> > tcr_type_name :: string,
> > tcr_arity :: int,
> > tcr_unify_pred :: univ,
> > tcr_compare_pred :: univ,
> > tcr_flags :: set(type_ctor_flag),
> > tcr_rep_details :: type_ctor_details
> > ).
>
> Changing the signedness of fields in the runtime is tricky, because
> you will get warnings from the C compiler, which we normally regard
> as errors.
One situation: we change a field from signed to unsigned in the runtime,
but the bootstrap compiler populates the field with a *negative* value.
Do you have any other problems in mind?
> However, changing the signedness of these fields in the compiler
> is trivial. If I were you, for each field you want to change to unsigned
> in the runtime, go ahead and change it to unsigned in the *compiler*
> right now, since that should minimize disruption. Just take a snapshot
> of your changes before you do it, so you can undo it quickly if some parts
> of the compiler insist on stuffing a *meaningful* negative value in there anyway.
Done.
> > @@ -185,21 +186,21 @@
> > foreign_enum_ordinal_table :: map(int, foreign_enum_functor),
> > foreign_enum_name_table :: map(string,
> > foreign_enum_functor),
> > foreign_enum_functor_number_mapping
> > :: list(int)
> > )
> > ; tcd_du(
> > du_axioms :: equality_axioms,
> > du_functors :: list(du_functor),
> > du_value_table :: ptag_map,
> > - du_name_table :: map(string, map(int, du_functor)),
> > + du_name_table :: map(string, map(int16, du_functor)),
> > du_functor_number_mapping
> > :: list(int)
> > )
>
> Shouldn't the last field be changed to int16s (or uint16s) as well?
The list elements are functor numbers by lexicographical order.
I've changed the element type to uint32 to match the type used for
functor ordinals, which must have the same range.
> This raises another point. What is the maximum number of function symbols
> that a type is allowed to have? This code says that number must fit in 16 bits;
> other code says only that it must fit in 32 bits. We should
>
> - decide on one or the other,
> - document the decision in the reference manual, and
> - define a C type in the runtime and a Mercury type in the compiler
> that aliases uint16_t or uint32_t, and use that consistently.
By "this code", did you mean the int16 in the type of du_name_table?
That represents functor arities, not functor numbers.
> > @@ -257,21 +258,21 @@
> > nt_subtype_info :: functor_subtype_info
> > ).
> >
> > % Descriptor for a functor in a du type.
> > %
> > % This type mostly corresponds to the C type MR_DuFunctorDesc.
> > %
> > :- type du_functor
> > ---> du_functor(
> > du_name :: string,
> > - du_orig_arity :: int,
> > + du_orig_arity :: int16,
> > du_ordinal :: int,
> > du_rep :: du_rep,
> > du_arg_infos :: list(du_arg_info),
> > du_exist_info :: maybe(exist_info),
> > du_subtype_info :: functor_subtype_info
> > ).
>
> We should do steps 2 and 3 above for the maximum arity
> of a function symbol as well, though I don't think anyone will argue
> for allowing arities that don't fit in 16 bits. For predicates, the maximum
> arity we allow is either 1023 or 1024 (I don't recall which), and we should
> probably use the same number here.
Seems fine.
> > get_functor_du(TypeCtorRep, TypeInfo, TypeCtorInfo, FunctorNumber,
> > FunctorName, Arity, PseudoTypeInfoList, Names) :-
> > TypeFunctors = get_type_ctor_functors(TypeCtorInfo),
> > DuFunctorDesc = TypeFunctors ^ du_functor_desc(TypeCtorRep, FunctorNumber),
> >
> > FunctorName = DuFunctorDesc ^ du_functor_name,
> > - Arity = DuFunctorDesc ^ du_functor_arity,
> > + Arity = int16.to_int(DuFunctorDesc ^ du_functor_arity),
>
> Any reason why you convert this to int here (and elsewhere in this module)?
>
In this case, Arity is passed to list.duplicate.
In other cases, existing code or public interfaces use int for arities.
I don't think there's any gain to sticking with int16s after the value
has been extracted (and working with int16s increases the chances of
overflow, admittedly by a miniscule amount in this case ;)
> Apart from the above concerns, the diff is fine.
>
> Any reason for sending this diff with more than the standard three lines of context?
No, I just had my workspace configured to show more context by default.
Thanks for the review. I've addressed your other comments and committed
the change. Interdiff follows.
Peter
diff --git a/compiler/add_special_pred.m b/compiler/add_special_pred.m
index 1ad6ac251..2547879e9 100644
--- a/compiler/add_special_pred.m
+++ b/compiler/add_special_pred.m
@@ -502,7 +502,7 @@ collect_type_defn_for_tuple(TypeCtor, Type, TVarSet, TypeBody, Context) :-
make_tuple_args_and_repns(Context, TupleArgTypes, CtorArgs, CtorArgRepns),
- Ordinal = 0,
+ Ordinal = 0u32,
CtorSymName = unqualified("{}"),
Ctor = ctor(Ordinal, MaybeExistConstraints, CtorSymName,
CtorArgs, TupleArity, Context),
diff --git a/compiler/du_type_layout.m b/compiler/du_type_layout.m
index 588e3bb98..148db7335 100644
--- a/compiler/du_type_layout.m
+++ b/compiler/du_type_layout.m
@@ -750,7 +750,7 @@ decide_simple_type_notag(_ModuleInfo, Params, TypeCtor, TypeDefn0, Body0,
% if the arg type is a 64 bit float on a 32 bit platform.
SingleArgRepn = ctor_arg_repn(MaybeSingleArgFieldName, SingleArgType,
apw_full(arg_only_offset(0), cell_offset(0)), SingleArgContext),
- SingleCtorRepn = ctor_repn(0, no_exist_constraints,
+ SingleCtorRepn = ctor_repn(0u32, no_exist_constraints,
SingleCtorSymName, SingleCtorTag, [SingleArgRepn], 1,
SingleCtorContext),
insert_ctor_repn_into_map(SingleCtorRepn, map.init, CtorRepnMap),
diff --git a/compiler/erl_rtti.m b/compiler/erl_rtti.m
index ad42f5458..5e3848b54 100644
--- a/compiler/erl_rtti.m
+++ b/compiler/erl_rtti.m
@@ -103,19 +103,19 @@ maybe_get_special_predicate(Univ) =
% aborting on reserved types, and specially handling the list type.
%
:- func erlang_type_ctor_details(module_name, string,
- int, type_ctor_details) = erlang_type_ctor_details.
+ uint16, type_ctor_details) = erlang_type_ctor_details.
erlang_type_ctor_details(ModuleName, TypeName, Arity, Details) = D :-
( if
ModuleName = unqualified("list"),
TypeName = "list",
- Arity = 1
+ Arity = 1u16
then
D = erlang_list
else if
ModuleName = unqualified("array"),
TypeName = "array",
- Arity = 1
+ Arity = 1u16
then
D = erlang_array
else
@@ -153,9 +153,9 @@ erlang_type_ctor_details_2(CtorDetails) = Details :-
;
CtorDetails = tcd_notag(_, NoTagFunctor),
NoTagFunctor = notag_functor(Name, TypeInfo, ArgName, SubtypeInfo),
- OrigArity = 1i16,
- Ordinal = 0,
- FunctorNum = 0,
+ OrigArity = 1u16,
+ Ordinal = 0u32,
+ FunctorNum = 0u32,
ArgTypeInfo = convert_to_rtti_maybe_pseudo_type_info_or_self(TypeInfo),
ArgPosWidth = apw_full(arg_only_offset(0), cell_offset(0)),
ArgInfos = [du_arg_info(ArgName, ArgTypeInfo, ArgPosWidth)],
@@ -178,17 +178,17 @@ erlang_type_ctor_details_2(CtorDetails) = Details :-
% Convert an enum_functor into the equivalent erlang_du_functor
%
-:- pred convert_enum_functor(enum_functor::in, int::in, erlang_du_functor::out)
- is det.
+:- pred convert_enum_functor(enum_functor::in, uint32::in,
+ erlang_du_functor::out) is det.
convert_enum_functor(EnumFunctor, FunctorNum, ErlangFunctor) :-
EnumFunctor = enum_functor(Name, Ordinal),
- ErlangFunctor = erlang_du_functor(Name, 0i16, Ordinal, FunctorNum,
+ ErlangFunctor = erlang_du_functor(Name, 0u16, Ordinal, FunctorNum,
erlang_atom_raw(Name), [], no, functor_subtype_none).
% Convert a du_functor into the equivalent erlang_du_functor
%
-:- pred convert_du_functor(du_functor::in, int::in, erlang_du_functor::out)
+:- pred convert_du_functor(du_functor::in, uint32::in, erlang_du_functor::out)
is det.
convert_du_functor(Functor, FunctorNum, ErlangFunctor) :-
@@ -574,8 +574,8 @@ type_ctor_data_to_elds(ModuleInfo, TypeCtorData, RttiDefns) :-
),
ELDSTypeCtorData = elds_tuple([
- elds_term(elds_int(Arity)),
- elds_term(elds_int8(Version)),
+ elds_term(elds_uint16(Arity)),
+ elds_term(elds_uint8(Version)),
UnifyExpr,
CompareExpr,
elds_term(elds_list_of_ints(sym_name_to_string(ModuleName))),
diff --git a/compiler/erl_unify_gen.m b/compiler/erl_unify_gen.m
index 886f55bf9..589a1eb7f 100644
--- a/compiler/erl_unify_gen.m
+++ b/compiler/erl_unify_gen.m
@@ -102,6 +102,7 @@
:- import_module int.
:- import_module list.
:- import_module require.
+:- import_module uint16.
%-----------------------------------------------------------------------------%
@@ -352,7 +353,8 @@ cons_id_to_expr(ConsId, Args, DummyVarReplacement, Expr, !Info) :-
pred_const_to_closure(ShroudedPredProcId, Args, Expr, !Info)
;
ConsId = type_ctor_info_const(ModuleName, TypeCtor, Arity),
- RttiTypeCtor = rtti_type_ctor(ModuleName, TypeCtor, Arity),
+ RttiTypeCtor = rtti_type_ctor(ModuleName, TypeCtor,
+ uint16.det_from_int(Arity)),
RttiId = elds_rtti_type_ctor_id(RttiTypeCtor),
Expr = elds_rtti_ref(RttiId)
;
diff --git a/compiler/erlang_rtti.m b/compiler/erlang_rtti.m
index 1ccf3ffcf..bc365961c 100644
--- a/compiler/erlang_rtti.m
+++ b/compiler/erlang_rtti.m
@@ -46,10 +46,10 @@
%
:- type erlang_type_ctor_data
---> erlang_type_ctor_data(
- etcr_version :: int8,
+ etcr_version :: uint8,
etcr_module_name :: module_name,
etcr_type_name :: string,
- etcr_arity :: int,
+ etcr_arity :: uint16,
%
% It is possible that the type doesn't have
@@ -109,13 +109,13 @@
:- type erlang_du_functor
---> erlang_du_functor(
edu_name :: string,
- edu_orig_arity :: int16,
+ edu_orig_arity :: uint16,
% The declaration order of the functor.
- edu_ordinal :: int,
+ edu_ordinal :: uint32,
% The lexicographic order of the functor.
- edu_lex :: int,
+ edu_lex :: uint32,
% erlang atom which represents the functor
% currently encoded version of name
diff --git a/compiler/hlds_data.m b/compiler/hlds_data.m
index 3ebe192de..db8b307a5 100644
--- a/compiler/hlds_data.m
+++ b/compiler/hlds_data.m
@@ -957,7 +957,7 @@ set_type_defn_prev_errors(X, !Defn) :-
---> ctor_repn(
% The ordinal number of the functor. The first functor
% in a type definition has ordinal number 0.
- cr_ordinal :: int,
+ cr_ordinal :: uint32,
% Existential constraints, if any.
cr_maybe_exist :: maybe_cons_exist_constraints,
diff --git a/compiler/llds_out_data.m b/compiler/llds_out_data.m
index 624202d19..be8d8a780 100644
--- a/compiler/llds_out_data.m
+++ b/compiler/llds_out_data.m
@@ -182,6 +182,7 @@
:- import_module require.
:- import_module string.
:- import_module uint.
+:- import_module uint16.
:- import_module uint8.
%----------------------------------------------------------------------------%
@@ -1455,7 +1456,7 @@ output_rval_const(Info, Const, !IO) :-
)
).
-:- pred output_type_ctor_addr(module_name::in, string::in, int::in,
+:- pred output_type_ctor_addr(module_name::in, string::in, uint16::in,
io::di, io::uo) is det.
output_type_ctor_addr(Module0, Name, Arity, !IO) :-
@@ -1467,7 +1468,7 @@ output_type_ctor_addr(Module0, Name, Arity, !IO) :-
% We don't need to mangle the module name, but we do need to convert it
% to a C identifier in the standard fashion.
ModuleStr = sym_name_mangle(Module),
- ( if Arity = 0 then
+ ( if Arity = 0u16 then
( if
ModuleStr = "builtin",
builtin_type_to_type_ctor_addr(Name, Macro)
@@ -1486,7 +1487,7 @@ output_type_ctor_addr(Module0, Name, Arity, !IO) :-
else
io.format("MR_CTOR0_ADDR(%s, %s)", [s(ModuleStr), s(Name)], !IO)
)
- else if Arity = 1 then
+ else if Arity = 1u16 then
( if
Name = "list",
ModuleStr = "list"
@@ -1502,7 +1503,7 @@ output_type_ctor_addr(Module0, Name, Arity, !IO) :-
)
else
io.format("MR_CTOR_ADDR(%s, %s, %d)",
- [s(ModuleStr), s(Name), i(Arity)], !IO)
+ [s(ModuleStr), s(Name), i(uint16.to_int(Arity))], !IO)
).
:- pred builtin_type_to_type_ctor_addr(string::in, string::out) is semidet.
diff --git a/compiler/ml_unify_gen_construct.m b/compiler/ml_unify_gen_construct.m
index 4ff06f770..a24347a58 100644
--- a/compiler/ml_unify_gen_construct.m
+++ b/compiler/ml_unify_gen_construct.m
@@ -117,6 +117,7 @@
:- import_module require.
:- import_module term.
:- import_module uint.
+:- import_module uint16.
:- import_module uint8.
%---------------------------------------------------------------------------%
@@ -181,7 +182,8 @@ ml_generate_construction_unification(LHSVar, ConsId, RHSVars, ArgModes,
ConsTag = type_ctor_info_tag(ModuleName0, TypeName, TypeArity),
ModuleName = fixup_builtin_module(ModuleName0),
MLDS_Module = mercury_module_name_to_mlds(ModuleName),
- RttiTypeCtor = rtti_type_ctor(ModuleName, TypeName, TypeArity),
+ RttiTypeCtor = rtti_type_ctor(ModuleName, TypeName,
+ uint16.det_from_int(TypeArity)),
RttiId = ctor_rtti_id(RttiTypeCtor, type_ctor_type_ctor_info),
Const = mlconst_data_addr_rtti(MLDS_Module, RttiId),
ConstRval = ml_cast(LHS_MLDS_Type, ml_const(Const))
@@ -1850,7 +1852,8 @@ ml_gen_const_struct_arg_tag(ConsTag, Type, MLDS_Type, Rval) :-
ConsTag = type_ctor_info_tag(ModuleName0, TypeName, TypeArity),
ModuleName = fixup_builtin_module(ModuleName0),
MLDS_Module = mercury_module_name_to_mlds(ModuleName),
- RttiTypeCtor = rtti_type_ctor(ModuleName, TypeName, TypeArity),
+ RttiTypeCtor = rtti_type_ctor(ModuleName, TypeName,
+ uint16.det_from_int(TypeArity)),
RttiId = ctor_rtti_id(RttiTypeCtor, type_ctor_type_ctor_info),
Const = mlconst_data_addr_rtti(MLDS_Module, RttiId),
Rval = ml_cast(MLDS_Type, ml_const(Const))
diff --git a/compiler/ml_util.m b/compiler/ml_util.m
index e8c52329b..2ef15a21e 100644
--- a/compiler/ml_util.m
+++ b/compiler/ml_util.m
@@ -127,6 +127,9 @@
:- func gen_init_int16(int16) = mlds_initializer.
:- func gen_init_uint16(uint16) = mlds_initializer.
+:- func gen_init_int32(int32) = mlds_initializer.
+:- func gen_init_uint32(uint32) = mlds_initializer.
+
:- func gen_init_boxed_int(int) = mlds_initializer.
:- func gen_init_string(string) = mlds_initializer.
@@ -877,6 +880,9 @@ gen_init_uint8(Int) = init_obj(ml_const(mlconst_uint8(Int))).
gen_init_int16(Int) = init_obj(ml_const(mlconst_int16(Int))).
gen_init_uint16(Int) = init_obj(ml_const(mlconst_uint16(Int))).
+gen_init_int32(Int) = init_obj(ml_const(mlconst_int32(Int))).
+gen_init_uint32(Int) = init_obj(ml_const(mlconst_uint32(Int))).
+
gen_init_boxed_int(Int) =
init_obj(ml_box(mlds_builtin_type_int(int_type_int),
ml_const(mlconst_int(Int)))).
diff --git a/compiler/opt_debug.m b/compiler/opt_debug.m
index 15c730e65..8bae85467 100644
--- a/compiler/opt_debug.m
+++ b/compiler/opt_debug.m
@@ -544,46 +544,46 @@ dump_pred_proc_id(proc(PredId, ProcId)) =
dump_rtti_type_ctor(rtti_type_ctor(ModuleName, TypeName, Arity)) =
"rtti_type_ctor(" ++ sym_name_mangle(ModuleName) ++ ", "
- ++ name_mangle(TypeName) ++ int_to_string(Arity) ++ ")".
+ ++ name_mangle(TypeName) ++ uint16_to_string(Arity) ++ ")".
dump_rtti_name(RttiName) = Str :-
(
RttiName = type_ctor_exist_locns(Ordinal),
- Str = "exist_locns_" ++ int_to_string(Ordinal)
+ Str = "exist_locns_" ++ uint32_to_string(Ordinal)
;
RttiName = type_ctor_exist_locn,
Str = "exist_loc"
;
RttiName = type_ctor_exist_tc_constr(Ordinal, TCCNum, Arity),
- Str = "exist_tc_constr_" ++ int_to_string(Ordinal) ++ "_"
+ Str = "exist_tc_constr_" ++ uint32_to_string(Ordinal) ++ "_"
++ int_to_string(TCCNum) ++ "_" ++ int_to_string(Arity)
;
RttiName = type_ctor_exist_tc_constrs(Ordinal),
- Str = "exist_tc_constrs_" ++ int_to_string(Ordinal)
+ Str = "exist_tc_constrs_" ++ uint32_to_string(Ordinal)
;
RttiName = type_ctor_exist_info(Ordinal),
- Str = "exist_info_" ++ int_to_string(Ordinal)
+ Str = "exist_info_" ++ uint32_to_string(Ordinal)
;
RttiName = type_ctor_field_names(Ordinal),
- Str = "field_names_" ++ int_to_string(Ordinal)
+ Str = "field_names_" ++ uint32_to_string(Ordinal)
;
RttiName = type_ctor_field_types(Ordinal),
- Str = "field_types_" ++ int_to_string(Ordinal)
+ Str = "field_types_" ++ uint32_to_string(Ordinal)
;
RttiName = type_ctor_field_locns(Ordinal),
- Str = "field_locns_" ++ int_to_string(Ordinal)
+ Str = "field_locns_" ++ uint32_to_string(Ordinal)
;
RttiName = type_ctor_enum_functor_desc(Ordinal),
- Str = "enum_functor_desc_" ++ int_to_string(Ordinal)
+ Str = "enum_functor_desc_" ++ uint32_to_string(Ordinal)
;
RttiName = type_ctor_foreign_enum_functor_desc(Ordinal),
- Str = "foreign_enum_functor_desc_" ++ int_to_string(Ordinal)
+ Str = "foreign_enum_functor_desc_" ++ uint32_to_string(Ordinal)
;
RttiName = type_ctor_notag_functor_desc,
Str = "notag_functor_desc_"
;
RttiName = type_ctor_du_functor_desc(Ordinal),
- Str = "du_functor_desc_" ++ int_to_string(Ordinal)
+ Str = "du_functor_desc_" ++ uint32_to_string(Ordinal)
;
RttiName = type_ctor_enum_name_ordered_table,
Str = "enum_name_ordered_table"
diff --git a/compiler/parse_type_defn.m b/compiler/parse_type_defn.m
index 201f59dc1..0862e8e9b 100644
--- a/compiler/parse_type_defn.m
+++ b/compiler/parse_type_defn.m
@@ -77,10 +77,10 @@
:- import_module parse_tree.prog_type.
:- import_module bag.
-:- import_module int.
:- import_module maybe.
:- import_module require.
:- import_module set.
+:- import_module uint32.
:- import_module unit.
parse_solver_type_defn_item(ModuleName, VarSet, ArgTerms, Context, SeqNum,
@@ -246,13 +246,13 @@ du_type_rhs_ctors_and_where_terms(Term, CtorsTerm, MaybeWhereTerm) :-
parse_maybe_exist_quant_constructors(ModuleName, VarSet, Term,
MaybeConstructors) :-
disjunction_to_one_or_more(Term, one_or_more(HeadBodyTerm, TailBodyTerms)),
- parse_maybe_exist_quant_constructors_loop(ModuleName, VarSet, 0,
+ parse_maybe_exist_quant_constructors_loop(ModuleName, VarSet, 0u32,
HeadBodyTerm, TailBodyTerms, MaybeConstructors).
% Try to parse the term as a list of constructors.
%
:- pred parse_maybe_exist_quant_constructors_loop(module_name::in, varset::in,
- int::in, term::in, list(term)::in,
+ uint32::in, term::in, list(term)::in,
maybe1(one_or_more(constructor))::out) is det.
parse_maybe_exist_quant_constructors_loop(ModuleName, VarSet, CurOrdinal,
@@ -271,7 +271,7 @@ parse_maybe_exist_quant_constructors_loop(ModuleName, VarSet, CurOrdinal,
;
TailTerms = [HeadTailTerm | TailTailTerms],
parse_maybe_exist_quant_constructors_loop(ModuleName, VarSet,
- CurOrdinal + 1, HeadTailTerm, TailTailTerms,
+ CurOrdinal + 1u32, HeadTailTerm, TailTailTerms,
MaybeTailConstructors),
( if
MaybeHeadConstructor = ok1(HeadConstructor),
@@ -287,7 +287,7 @@ parse_maybe_exist_quant_constructors_loop(ModuleName, VarSet, CurOrdinal,
).
:- pred parse_maybe_exist_quant_constructor(module_name::in, varset::in,
- int::in, term::in, maybe1(constructor)::out) is det.
+ uint32::in, term::in, maybe1(constructor)::out) is det.
parse_maybe_exist_quant_constructor(ModuleName, VarSet, Ordinal, Term,
MaybeConstructor) :-
@@ -311,8 +311,8 @@ parse_maybe_exist_quant_constructor(ModuleName, VarSet, Ordinal, Term,
MaybeConstructor)
).
-:- pred parse_constructor(module_name::in, varset::in, int::in, list(tvar)::in,
- term::in, maybe1(constructor)::out) is det.
+:- pred parse_constructor(module_name::in, varset::in, uint32::in,
+ list(tvar)::in, term::in, maybe1(constructor)::out) is det.
parse_constructor(ModuleName, VarSet, Ordinal, ExistQVars, Term,
MaybeConstructor) :-
diff --git a/compiler/prog_data.m b/compiler/prog_data.m
index 76a1927f1..8ed8f0540 100644
--- a/compiler/prog_data.m
+++ b/compiler/prog_data.m
@@ -383,7 +383,7 @@ cons_id_is_const_struct(ConsId, ConstNum) :-
---> ctor(
% The ordinal number of the functor. The first functor
% in a type definition has ordinal number 0.
- cons_ordinal :: int,
+ cons_ordinal :: uint32,
% Existential constraints, if any.
cons_maybe_exist :: maybe_cons_exist_constraints,
diff --git a/compiler/pseudo_type_info.m b/compiler/pseudo_type_info.m
index 92f79efbd..153037be0 100644
--- a/compiler/pseudo_type_info.m
+++ b/compiler/pseudo_type_info.m
@@ -72,6 +72,7 @@
:- import_module list.
:- import_module require.
:- import_module term.
+:- import_module uint16.
%---------------------------------------------------------------------------%
@@ -108,7 +109,8 @@ construct_pseudo_type_info(Type, NumUnivQTvars, ExistQTvars, PseudoTypeInfo) :-
TypeName = unqualify_name(QualTypeName),
sym_name_get_module_name_default(QualTypeName,
unqualified("builtin"), TypeModule),
- RttiTypeCtor = rtti_type_ctor(TypeModule, TypeName, Arity),
+ RttiTypeCtor = rtti_type_ctor(TypeModule, TypeName,
+ uint16.det_from_int(Arity)),
generate_pseudo_args(TypeArgs, NumUnivQTvars, ExistQTvars,
PseudoArgs),
expect(check_arity(PseudoArgs, Arity), $pred, "arity mismatch"),
@@ -172,7 +174,8 @@ construct_type_info(Type, TypeInfo) :-
TypeName = unqualify_name(QualTypeName),
sym_name_get_module_name_default(QualTypeName,
unqualified("builtin"), TypeModule),
- RttiTypeCtor = rtti_type_ctor(TypeModule, TypeName, Arity),
+ RttiTypeCtor = rtti_type_ctor(TypeModule, TypeName,
+ uint16.det_from_int(Arity)),
generate_plain_args(TypeArgs, TypeInfoArgs),
expect(check_arity(TypeInfoArgs, Arity), $pred, "arity mismatch"),
(
diff --git a/compiler/rtti.m b/compiler/rtti.m
index c91e34f17..8e2945b8f 100644
--- a/compiler/rtti.m
+++ b/compiler/rtti.m
@@ -103,7 +103,7 @@
---> rtti_type_ctor(
module_name, % module name
string, % type ctor's name
- arity % type ctor's arity
+ uint16 % type ctor's arity
).
% A var_arity_ctor_id uniquely identifies a variable arity type
@@ -123,10 +123,10 @@
%
:- type type_ctor_data
---> type_ctor_data(
- tcr_version :: int8,
+ tcr_version :: uint8,
tcr_module_name :: module_name,
tcr_type_name :: string,
- tcr_arity :: int,
+ tcr_arity :: uint16,
tcr_unify_pred :: univ,
tcr_compare_pred :: univ,
tcr_flags :: set(type_ctor_flag),
@@ -174,28 +174,28 @@
enum_axioms :: equality_axioms,
enum_is_dummy :: enum_maybe_dummy,
enum_functors :: list(enum_functor),
- enum_value_table :: map(int, enum_functor),
+ enum_value_table :: map(uint32, enum_functor),
enum_name_table :: map(string, enum_functor),
enum_functor_number_mapping
- :: list(int)
+ :: list(uint32)
)
; tcd_foreign_enum(
foreign_enum_language :: foreign_language,
foreign_enum_axioms :: equality_axioms,
foreign_enum_functors :: list(foreign_enum_functor),
- foreign_enum_ordinal_table :: map(int, foreign_enum_functor),
+ foreign_enum_ordinal_table :: map(uint32, foreign_enum_functor),
foreign_enum_name_table :: map(string,
foreign_enum_functor),
foreign_enum_functor_number_mapping
- :: list(int)
+ :: list(uint32)
)
; tcd_du(
du_axioms :: equality_axioms,
du_functors :: list(du_functor),
du_value_table :: ptag_map,
- du_name_table :: map(string, map(int16, du_functor)),
+ du_name_table :: map(string, map(uint16, du_functor)),
du_functor_number_mapping
- :: list(int)
+ :: list(uint32)
)
; tcd_notag(
notag_axioms :: equality_axioms,
@@ -232,7 +232,7 @@
:- type enum_functor
---> enum_functor(
enum_name :: string,
- enum_ordinal :: int
+ enum_ordinal :: uint32
).
% Descriptor for a functor in a foreign enum type.
@@ -242,7 +242,7 @@
:- type foreign_enum_functor
---> foreign_enum_functor(
foreign_enum_name :: string,
- foreign_enum_ordinal :: int,
+ foreign_enum_ordinal :: uint32,
foreign_enum_value :: string
).
@@ -265,8 +265,8 @@
:- type du_functor
---> du_functor(
du_name :: string,
- du_orig_arity :: int16,
- du_ordinal :: int,
+ du_orig_arity :: uint16,
+ du_ordinal :: uint32,
du_rep :: du_rep,
du_arg_infos :: list(du_arg_info),
du_exist_info :: maybe(exist_info),
@@ -294,8 +294,8 @@
%
:- type exist_info
---> exist_info(
- exist_num_plain_typeinfos :: int16,
- exist_num_typeinfos_in_tcis :: int16,
+ exist_num_plain_typeinfos :: uint16,
+ exist_num_typeinfos_in_tcis :: uint16,
exist_typeclass_constraints :: list(tc_constraint),
exist_typeinfo_locns :: list(exist_typeinfo_locn)
).
@@ -309,16 +309,16 @@
:- type exist_typeinfo_locn
---> plain_typeinfo(
% The typeinfo is stored directly in the cell, at this offset.
- int16
+ uint16
)
; typeinfo_in_tci(
% The typeinfo is stored indirectly in the typeclass info
% stored at this offset in the cell.
- int16,
+ uint16,
% To find the typeinfo inside the typeclass info structure,
% give this integer to the MR_typeclass_info_type_info macro.
- int16
+ uint16
).
% These tables let the runtime system interpret values in memory
@@ -339,8 +339,7 @@
---> sectag_table(
sectag_locn :: sectag_locn,
sectag_num_bits :: int8,
- % XXX The number of sharers *should* fit in a 32 bit number.
- sectag_num_sharers :: uint,
+ sectag_num_sharers :: uint32,
sectag_map :: stag_map
).
@@ -614,20 +613,20 @@
; tc_rtti_id(tc_name, tc_rtti_name).
:- type ctor_rtti_name
- ---> type_ctor_exist_locns(int) % functor ordinal
+ ---> type_ctor_exist_locns(uint32) % functor ordinal
; type_ctor_exist_locn
- ; type_ctor_exist_tc_constr(int, int, int) % functor ordinal,
+ ; type_ctor_exist_tc_constr(uint32, int, int) % functor ordinal,
% constraint ordinal,
% constraint arity
- ; type_ctor_exist_tc_constrs(int) % functor ordinal
- ; type_ctor_exist_info(int) % functor ordinal
- ; type_ctor_field_names(int) % functor ordinal
- ; type_ctor_field_types(int) % functor ordinal
- ; type_ctor_field_locns(int) % functor ordinal
- ; type_ctor_enum_functor_desc(int) % functor ordinal
- ; type_ctor_foreign_enum_functor_desc(int) % functor ordinal
+ ; type_ctor_exist_tc_constrs(uint32) % functor ordinal
+ ; type_ctor_exist_info(uint32) % functor ordinal
+ ; type_ctor_field_names(uint32) % functor ordinal
+ ; type_ctor_field_types(uint32) % functor ordinal
+ ; type_ctor_field_locns(uint32) % functor ordinal
+ ; type_ctor_enum_functor_desc(uint32) % functor ordinal
+ ; type_ctor_foreign_enum_functor_desc(uint32) % functor ordinal
; type_ctor_notag_functor_desc
- ; type_ctor_du_functor_desc(int) % functor ordinal
+ ; type_ctor_du_functor_desc(uint32) % functor ordinal
; type_ctor_enum_name_ordered_table
; type_ctor_enum_value_ordered_table
; type_ctor_foreign_enum_name_ordered_table
@@ -784,7 +783,7 @@
% Given a type constructor with the given details, return `yes(NumPtags)'
% where NumPtags is the number of primary tag values used by the type,
- % or `no' if the type constructor doesn't reserve primary tags.
+ % or `no' if the type constructor doesn't use primary tags.
%
:- func type_ctor_details_num_ptags(type_ctor_details) = maybe(int).
@@ -1046,13 +1045,13 @@ pti_get_rtti_type_ctor(type_var(_)) = _ :-
var_arity_id_to_rtti_type_ctor(pred_type_info) = Ctor :-
Builtin = mercury_public_builtin_module,
- Ctor = rtti_type_ctor(Builtin, "pred", 0).
+ Ctor = rtti_type_ctor(Builtin, "pred", 0u16).
var_arity_id_to_rtti_type_ctor(func_type_info) = Ctor :-
Builtin = mercury_public_builtin_module,
- Ctor = rtti_type_ctor(Builtin, "func", 0).
+ Ctor = rtti_type_ctor(Builtin, "func", 0u16).
var_arity_id_to_rtti_type_ctor(tuple_type_info) = Ctor :-
Builtin = mercury_public_builtin_module,
- Ctor = rtti_type_ctor(Builtin, "tuple", 0).
+ Ctor = rtti_type_ctor(Builtin, "tuple", 0u16).
rtti_id_maybe_element_has_array_type(item_type(RttiId)) =
rtti_id_has_array_type(RttiId).
@@ -1174,7 +1173,7 @@ name_to_string(RttiTypeCtor, RttiName) = Str :-
mangle_rtti_type_ctor(RttiTypeCtor, ModuleName, TypeName, A_str),
(
RttiName = type_ctor_exist_locns(Ordinal),
- string.int_to_string(Ordinal, O_str),
+ O_str = string.uint32_to_string(Ordinal),
string.append_list([ModuleName, "__exist_locns_",
TypeName, "_", A_str, "_", O_str], Str)
;
@@ -1183,43 +1182,43 @@ name_to_string(RttiTypeCtor, RttiName) = Str :-
TypeName, "_", A_str], Str)
;
RttiName = type_ctor_exist_tc_constr(Ordinal, TCCNum, _),
- string.int_to_string(Ordinal, O_str),
- string.int_to_string(TCCNum, N_str),
+ O_str = string.uint32_to_string(Ordinal),
+ N_str = string.int_to_string(TCCNum),
string.append_list([ModuleName, "__exist_tc_constr_",
TypeName, "_", A_str, "_", O_str, "_", N_str], Str)
;
RttiName = type_ctor_exist_tc_constrs(Ordinal),
- string.int_to_string(Ordinal, O_str),
+ O_str = string.uint32_to_string(Ordinal),
string.append_list([ModuleName, "__exist_tc_constrs_",
TypeName, "_", A_str, "_", O_str], Str)
;
RttiName = type_ctor_exist_info(Ordinal),
- string.int_to_string(Ordinal, O_str),
+ O_str = string.uint32_to_string(Ordinal),
string.append_list([ModuleName, "__exist_info_",
TypeName, "_", A_str, "_", O_str], Str)
;
RttiName = type_ctor_field_names(Ordinal),
- string.int_to_string(Ordinal, O_str),
+ O_str = string.uint32_to_string(Ordinal),
string.append_list([ModuleName, "__field_names_",
TypeName, "_", A_str, "_", O_str], Str)
;
RttiName = type_ctor_field_types(Ordinal),
- string.int_to_string(Ordinal, O_str),
+ O_str = string.uint32_to_string(Ordinal),
string.append_list([ModuleName, "__field_types_",
TypeName, "_", A_str, "_", O_str], Str)
;
RttiName = type_ctor_field_locns(Ordinal),
- string.int_to_string(Ordinal, O_str),
+ O_str = string.uint32_to_string(Ordinal),
string.append_list([ModuleName, "__field_locns_",
TypeName, "_", A_str, "_", O_str], Str)
;
RttiName = type_ctor_enum_functor_desc(Ordinal),
- string.int_to_string(Ordinal, O_str),
+ O_str = string.uint32_to_string(Ordinal),
string.append_list([ModuleName, "__enum_functor_desc_",
TypeName, "_", A_str, "_", O_str], Str)
;
RttiName = type_ctor_foreign_enum_functor_desc(Ordinal),
- string.int_to_string(Ordinal, O_str),
+ O_str = string.uint32_to_string(Ordinal),
string.append_list([ModuleName, "__foreign_enum_functor_desc_",
TypeName, "_", A_str, "_", O_str], Str)
;
@@ -1228,7 +1227,7 @@ name_to_string(RttiTypeCtor, RttiName) = Str :-
TypeName, "_", A_str], Str)
;
RttiName = type_ctor_du_functor_desc(Ordinal),
- string.int_to_string(Ordinal, O_str),
+ O_str = string.uint32_to_string(Ordinal),
string.append_list([ModuleName, "__du_functor_desc_",
TypeName, "_", A_str, "_", O_str], Str)
;
@@ -1433,7 +1432,7 @@ mangle_rtti_type_ctor(RttiTypeCtor, ModuleName, TypeName, ArityStr) :-
),
ModuleName = sym_name_mangle(ModuleNameSym),
TypeName = name_mangle(TypeName0),
- string.int_to_string(TypeArity, ArityStr).
+ ArityStr = string.uint16_to_string(TypeArity).
:- pred mangle_rtti_type_class_name(tc_name::in,
string::out, string::out, string::out) is det.
@@ -1665,7 +1664,7 @@ type_ctor_rep_to_string(TypeCtorData, TargetPrefixes, RepStr) :-
TypeCtorDetails = tcd_foreign(IsStable),
ModuleName = TypeCtorData ^ tcr_module_name,
TypeName = TypeCtorData ^ tcr_type_name,
- TypeArity = TypeCtorData ^ tcr_arity,
+ TypeArity = uint16.to_int(TypeCtorData ^ tcr_arity),
TypeCtor = type_ctor(qualified(ModuleName, TypeName), TypeArity),
( if type_ctor_is_array(TypeCtor) then
% XXX This is a kludge to allow accurate GC to trace arrays.
diff --git a/compiler/rtti_out.m b/compiler/rtti_out.m
index fc1cff3c1..f11f551ac 100644
--- a/compiler/rtti_out.m
+++ b/compiler/rtti_out.m
@@ -125,6 +125,8 @@
:- import_module assoc_list.
:- import_module counter.
:- import_module int.
+:- import_module int16.
+:- import_module int32.
:- import_module int8.
:- import_module map.
:- import_module maybe.
@@ -133,6 +135,8 @@
:- import_module require.
:- import_module string.
:- import_module uint.
+:- import_module uint16.
+:- import_module uint32.
:- import_module uint8.
:- import_module univ.
@@ -636,11 +640,11 @@ output_type_ctor_data_defn(Info, TypeCtorData, !DeclSet, !IO) :-
output_generic_rtti_data_defn_start(Info,
ctor_rtti_id(RttiTypeCtor, type_ctor_type_ctor_info), !DeclSet, !IO),
io.write_string(" = {\n\t", !IO),
- % MR_type_ctor_arity
- io.write_int(TypeArity, !IO),
+ % MR_type_ctor_arity -- XXX MAKE_FIELD_UNSIGNED
+ io.write_int(uint16.to_int(TypeArity), !IO),
io.write_string(",\n\t", !IO),
% MR_type_ctor_version
- io.write_int8(Version, !IO),
+ io.write_uint8(Version, !IO),
io.write_string(",\n\t", !IO),
% MR_type_ctor_num_ptags
MaybeNumPtags = type_ctor_details_num_ptags(TypeCtorDetails),
@@ -693,16 +697,16 @@ output_type_ctor_data_defn(Info, TypeCtorData, !DeclSet, !IO) :-
io.write_string("{ 0 }", !IO)
),
io.write_string(",\n\t", !IO),
- % MR_type_ctor_num_functors
+ % MR_type_ctor_num_functors -- XXX MAKE_FIELD_UNSIGNED
MaybeNumFunctors = type_ctor_details_num_functors(TypeCtorDetails),
(
MaybeNumFunctors = yes(NumFunctors),
- NumFunctorsEncoding = NumFunctors
+ NumFunctorsEncoding = int32.det_from_int(NumFunctors)
;
MaybeNumFunctors = no,
- NumFunctorsEncoding = -1
+ NumFunctorsEncoding = -1i32
),
- io.write_int(NumFunctorsEncoding, !IO),
+ io.write_int32(NumFunctorsEncoding, !IO),
io.write_string(",\n\t", !IO),
% MR_type_ctor_flags
io.write_uint16(encode_type_ctor_flags(Flags), !IO),
@@ -789,7 +793,7 @@ output_type_ctor_details_defn(Info, RttiTypeCtor, TypeCtorDetails,
TypeCtorDetails = tcd_notag(_, NotagFunctor),
output_notag_functor_defn(Info, RttiTypeCtor, NotagFunctor,
!DeclSet, !IO),
- output_functor_number_map(Info, RttiTypeCtor, [0], !DeclSet, !IO),
+ output_functor_number_map(Info, RttiTypeCtor, [0u32], !DeclSet, !IO),
MaybeLayoutName = yes(type_ctor_notag_functor_desc),
MaybeFunctorsName = yes(type_ctor_notag_functor_desc),
HaveFunctorNumberMap = yes
@@ -833,8 +837,8 @@ output_enum_functor_defn(Info, RttiTypeCtor, EnumFunctor, !DeclSet, !IO) :-
% MR_enum_functor_name
c_util.output_quoted_string_cur_stream(FunctorName, !IO),
io.write_string(""",\n\t", !IO),
- % MR_enum_functor_ordinal
- io.write_int(Ordinal, !IO),
+ % MR_enum_functor_ordinal -- XXX MAKE_FIELD_UNSIGNED
+ io.write_int32(int32.cast_from_uint32(Ordinal), !IO),
io.write_string("\n};\n", !IO).
:- pred output_foreign_enum_functor_defn(llds_out_info::in, rtti_type_ctor::in,
@@ -852,8 +856,8 @@ output_foreign_enum_functor_defn(Info, RttiTypeCtor, ForeignEnumFunctor,
% MR_foreign_enum_functor_name
c_util.output_quoted_string_cur_stream(FunctorName, !IO),
io.write_string(""",\n\t", !IO),
- % MR_foreign_enum_functor_ordinal
- io.write_int(FunctorOrdinal, !IO),
+ % MR_foreign_enum_functor_ordinal -- XXX MAKE_FIELD_UNSIGNED
+ io.write_int32(int32.cast_from_uint32(FunctorOrdinal), !IO),
io.write_string(",\n\t", !IO),
% MR_foreign_enum_functor_value
io.write_string(FunctorValue, !IO),
@@ -943,8 +947,8 @@ output_du_functor_defn(Info, RttiTypeCtor, DuFunctor, !DeclSet, !IO) :-
% MR_du_functor_name
c_util.output_quoted_string_cur_stream(FunctorName, !IO),
io.write_string(""",\n\t", !IO),
- % MR_du_functor_orig_arity
- io.write_int16(OrigArity, !IO),
+ % MR_du_functor_orig_arity -- XXX MAKE_FIELD_UNSIGNED
+ io.write_int16(int16.cast_from_uint16(OrigArity), !IO),
io.write_string(",\n\t", !IO),
% MR_du_functor_arg_type_contains_var
ContainsVarBitVector = compute_contains_var_bit_vector(ArgTypes),
@@ -960,32 +964,32 @@ output_du_functor_defn(Info, RttiTypeCtor, DuFunctor, !DeclSet, !IO) :-
(
SectagAndLocn = sectag_locn_none,
Locn = "MR_SECTAG_NONE",
- Stag = -1,
+ StagEncoding = -1i32,
NumSectagBits = 0u8
;
SectagAndLocn = sectag_locn_none_direct_arg,
Locn = "MR_SECTAG_NONE_DIRECT_ARG",
- Stag = -1,
+ StagEncoding = -1i32,
NumSectagBits = 0u8
;
SectagAndLocn = sectag_locn_local_rest_of_word(StagUint),
Locn = "MR_SECTAG_LOCAL_REST_OF_WORD",
- Stag = uint.cast_to_int(StagUint),
+ StagEncoding = int32.det_from_int(uint.cast_to_int(StagUint)),
NumSectagBits = 0u8
;
SectagAndLocn = sectag_locn_local_bits(StagUint, NumSectagBits, _Mask),
Locn = "MR_SECTAG_LOCAL_BITS",
- Stag = uint.cast_to_int(StagUint)
+ StagEncoding = int32.det_from_int(uint.cast_to_int(StagUint))
;
SectagAndLocn = sectag_locn_remote_word(StagUint),
Locn = "MR_SECTAG_REMOTE_FULL_WORD",
- Stag = uint.cast_to_int(StagUint),
+ StagEncoding = int32.det_from_int(uint.cast_to_int(StagUint)),
NumSectagBits = 0u8
;
SectagAndLocn = sectag_locn_remote_bits(StagUint, NumSectagBits,
_Mask),
Locn = "MR_SECTAG_REMOTE_BITS",
- Stag = uint.cast_to_int(StagUint)
+ StagEncoding = int32.det_from_int(uint.cast_to_int(StagUint))
),
% MR_du_functor_sectag_locn
io.write_string(Locn, !IO),
@@ -993,11 +997,11 @@ output_du_functor_defn(Info, RttiTypeCtor, DuFunctor, !DeclSet, !IO) :-
% MR_du_functor_primary
io.write_uint8(PtagUint8, !IO),
io.write_string(",\n\t", !IO),
- % MR_du_functor_secondary
- io.write_int(Stag, !IO),
+ % MR_du_functor_secondary -- XXX MAKE_FIELD_UNSIGNED
+ io.write_int32(StagEncoding, !IO),
io.write_string(",\n\t", !IO),
- % MR_du_functor_ordinal
- io.write_int(Ordinal, !IO),
+ % MR_du_functor_ordinal -- XXX MAKE_FIELD_UNSIGNED
+ io.write_int32(int32.cast_from_uint32(Ordinal), !IO),
io.write_string(",\n\t", !IO),
% MR_du_functor_arg_types
io.write_string("(MR_PseudoTypeInfo *) ", !IO), % cast away const
@@ -1062,7 +1066,7 @@ output_functor_subtype_info(FunctorSubtypeInfo, !IO) :-
%-----------------------------------------------------------------------------%
:- pred output_exist_locns_array(llds_out_info::in, rtti_type_ctor::in,
- int::in, list(exist_typeinfo_locn)::in,
+ uint32::in, list(exist_typeinfo_locn)::in,
decl_set::in, decl_set::out, io::di, io::uo) is det.
output_exist_locns_array(Info, RttiTypeCtor, Ordinal, Locns, !DeclSet, !IO) :-
@@ -1081,7 +1085,7 @@ output_exist_locns_array(Info, RttiTypeCtor, Ordinal, Locns, !DeclSet, !IO) :-
io.write_string("};\n", !IO)
).
-:- pred make_exist_tc_constr_id(rtti_type_ctor::in, int::in,
+:- pred make_exist_tc_constr_id(rtti_type_ctor::in, uint32::in,
int::in, int::in, rtti_id::out) is det.
make_exist_tc_constr_id(RttiTypeCtor, Ordinal, TCNum, Arity, RttiId) :-
@@ -1089,7 +1093,7 @@ make_exist_tc_constr_id(RttiTypeCtor, Ordinal, TCNum, Arity, RttiId) :-
RttiId = ctor_rtti_id(RttiTypeCtor, RttiName).
:- pred output_exist_constraints_data(llds_out_info::in, rtti_type_ctor::in,
- int::in, list(tc_constraint)::in, decl_set::in, decl_set::out,
+ uint32::in, list(tc_constraint)::in, decl_set::in, decl_set::out,
io::di, io::uo) is det.
output_exist_constraints_data(Info, RttiTypeCtor, Ordinal, Constraints,
@@ -1104,7 +1108,7 @@ output_exist_constraints_data(Info, RttiTypeCtor, Ordinal, Constraints,
!IO),
io.write_string("\n};\n", !IO).
-:- pred output_exist_info(llds_out_info::in, rtti_type_ctor::in, int::in,
+:- pred output_exist_info(llds_out_info::in, rtti_type_ctor::in, uint32::in,
exist_info::in, decl_set::in, decl_set::out, io::di, io::uo) is det.
output_exist_info(Info, RttiTypeCtor, Ordinal, ExistInfo, !DeclSet, !IO) :-
@@ -1122,15 +1126,15 @@ output_exist_info(Info, RttiTypeCtor, Ordinal, ExistInfo, !DeclSet, !IO) :-
ctor_rtti_id(RttiTypeCtor, type_ctor_exist_info(Ordinal)),
!DeclSet, !IO),
io.write_string(" = {\n\t", !IO),
- % MR_exist_typeinfos_plain
- io.write_int16(Plain, !IO),
+ % MR_exist_typeinfos_plain -- XXX MAKE_FIELD_UNSIGNED
+ io.write_int16(int16.cast_from_uint16(Plain), !IO),
io.write_string(",\n\t", !IO),
- % MR_exist_typeinfos_in_tci
- io.write_int16(InTci, !IO),
+ % MR_exist_typeinfos_in_tci -- XXX MAKE_FIELD_UNSIGNED
+ io.write_int16(int16.cast_from_uint16(InTci), !IO),
io.write_string(",\n\t", !IO),
% MR_exist_tcis
list.length(Constraints, Tci),
- io.write_int(Tci, !IO),
+ io.write_int16(int16.det_from_int(Tci), !IO),
io.write_string(",\n\t", !IO),
% MR_exist_typeinfo_locns
output_ctor_rtti_id(RttiTypeCtor, type_ctor_exist_locns(Ordinal), !IO),
@@ -1146,7 +1150,7 @@ output_exist_info(Info, RttiTypeCtor, Ordinal, ExistInfo, !DeclSet, !IO) :-
),
io.write_string("\n};\n", !IO).
-:- pred output_du_arg_types(llds_out_info::in, rtti_type_ctor::in, int::in,
+:- pred output_du_arg_types(llds_out_info::in, rtti_type_ctor::in, uint32::in,
list(rtti_maybe_pseudo_type_info_or_self)::in,
decl_set::in, decl_set::out, io::di, io::uo) is det.
@@ -1165,7 +1169,7 @@ output_du_arg_types(Info, RttiTypeCtor, Ordinal, ArgTypes, !DeclSet, !IO) :-
output_cast_addr_of_rtti_datas("(MR_PseudoTypeInfo) ", ArgTypeDatas, !IO),
io.write_string("};\n", !IO).
-:- pred output_du_arg_names(llds_out_info::in, rtti_type_ctor::in, int::in,
+:- pred output_du_arg_names(llds_out_info::in, rtti_type_ctor::in, uint32::in,
list(maybe(string))::in, decl_set::in, decl_set::out,
io::di, io::uo) is det.
@@ -1178,7 +1182,7 @@ output_du_arg_names(Info, RttiTypeCtor, Ordinal, MaybeNames, !DeclSet, !IO) :-
output_maybe_quoted_strings(MaybeNames, !IO),
io.write_string("};\n", !IO).
-:- pred output_du_arg_locns(llds_out_info::in, rtti_type_ctor::in, int::in,
+:- pred output_du_arg_locns(llds_out_info::in, rtti_type_ctor::in, uint32::in,
list(du_arg_info)::in, bool::out, decl_set::in, decl_set::out,
io::di, io::uo) is det.
@@ -1288,7 +1292,7 @@ output_du_arg_locns_loop([ArgInfo | ArgInfos], !IO) :-
%-----------------------------------------------------------------------------%
:- pred output_enum_value_ordered_table(llds_out_info::in, rtti_type_ctor::in,
- map(int, enum_functor)::in, decl_set::in, decl_set::out,
+ map(uint32, enum_functor)::in, decl_set::in, decl_set::out,
io::di, io::uo) is det.
output_enum_value_ordered_table(Info, RttiTypeCtor, FunctorMap,
@@ -1318,7 +1322,7 @@ output_enum_name_ordered_table(Info, RttiTypeCtor, FunctorMap,
io.write_string("};\n", !IO).
:- pred output_foreign_enum_ordinal_ordered_table(llds_out_info::in,
- rtti_type_ctor::in, map(int, foreign_enum_functor)::in,
+ rtti_type_ctor::in, map(uint32, foreign_enum_functor)::in,
decl_set::in, decl_set::out, io::di, io::uo) is det.
output_foreign_enum_ordinal_ordered_table(Info, RttiTypeCtor, FunctorMap,
@@ -1348,7 +1352,7 @@ output_foreign_enum_name_ordered_table(Info, RttiTypeCtor, FunctorMap,
io.write_string("};\n", !IO).
:- pred output_du_name_ordered_table(llds_out_info::in, rtti_type_ctor::in,
- map(string, map(int16, du_functor))::in, decl_set::in, decl_set::out,
+ map(string, map(uint16, du_functor))::in, decl_set::in, decl_set::out,
io::di, io::uo) is det.
output_du_name_ordered_table(Info, RttiTypeCtor, NameArityMap,
@@ -1412,7 +1416,7 @@ output_du_ptag_ordered_table_body(RttiTypeCtor,
_SectagMap),
io.write_string("\t{ ", !IO),
% MR_sectag_sharers
- io.write_uint(NumSharers, !IO),
+ io.write_uint32(NumSharers, !IO),
io.write_string(", ", !IO),
% MR_sectag_locn
rtti.sectag_locn_to_string(SectagLocn, _TargetPrefixes, LocnStr),
@@ -1446,7 +1450,7 @@ make_code_addr(ProcLabel) =
%-----------------------------------------------------------------------------%
:- pred output_functor_number_map(llds_out_info::in, rtti_type_ctor::in,
- list(int)::in, decl_set::in, decl_set::out, io::di, io::uo) is det.
+ list(uint32)::in, decl_set::in, decl_set::out, io::di, io::uo) is det.
output_functor_number_map(Info, RttiTypeCtor, FunctorNumberMap,
!DeclSet, !IO) :-
@@ -1454,9 +1458,17 @@ output_functor_number_map(Info, RttiTypeCtor, FunctorNumberMap,
ctor_rtti_id(RttiTypeCtor, type_ctor_functor_number_map),
!DeclSet, !IO),
io.write_string(" = {\n\t", !IO),
- io.write_list(FunctorNumberMap, ",\n\t", io.write_int, !IO),
+ io.write_list(FunctorNumberMap, ",\n\t", output_functor_number_map_value,
+ !IO),
io.write_string("\n};\n\t", !IO).
+:- pred output_functor_number_map_value(uint32::in, io::di, io::uo) is det.
+
+output_functor_number_map_value(NumUint32, !IO) :-
+ % XXX MAKE_FIELD_UNSIGNED
+ Num = uint32.cast_to_int(NumUint32),
+ io.write_int(Num, !IO).
+
%-----------------------------------------------------------------------------%
:- type data_group
@@ -1730,7 +1742,7 @@ init_rtti_data_if_nec(Data, !IO) :-
MangledTypeName = name_mangle(TypeName),
io.write_string(MangledTypeName, !IO),
io.write_string("_", !IO),
- io.write_int(Arity, !IO),
+ io.write_uint16(Arity, !IO),
io.write_string("_0);\n", !IO)
;
Data = rtti_data_base_typeclass_info(TCName, _ModuleName, ClassArity,
@@ -1968,18 +1980,18 @@ output_exist_locn(Locn, !IO) :-
(
Locn = plain_typeinfo(SlotInCell),
io.write_string("{ ", !IO),
- % MR_exist_arg_num
- io.write_int16(SlotInCell, !IO),
+ % MR_exist_arg_num -- XXX MAKE_FIELD_UNSIGNED
+ io.write_int16(int16.cast_from_uint16(SlotInCell), !IO),
% MR_exist_offset_in_tci
io.write_string(", -1 }", !IO)
;
Locn = typeinfo_in_tci(SlotInCell, SlotInTci),
io.write_string("{ ", !IO),
- % MR_exist_arg_num
- io.write_int16(SlotInCell, !IO),
+ % MR_exist_arg_num -- XXX MAKE_FIELD_UNSIGNED
+ io.write_int16(int16.cast_from_uint16(SlotInCell), !IO),
io.write_string(", ", !IO),
- % MR_exist_offset_in_tci
- io.write_int16(SlotInTci, !IO),
+ % MR_exist_offset_in_tci -- XXX MAKE_FIELD_UNSIGNED
+ io.write_int16(int16.cast_from_uint16(SlotInTci), !IO),
io.write_string(" }", !IO)
).
diff --git a/compiler/rtti_to_mlds.m b/compiler/rtti_to_mlds.m
index 0ea55abab..12a1f5e63 100644
--- a/compiler/rtti_to_mlds.m
+++ b/compiler/rtti_to_mlds.m
@@ -79,12 +79,15 @@
:- import_module map.
:- import_module maybe.
:- import_module int16.
+:- import_module int32.
:- import_module int8.
:- import_module pair.
:- import_module require.
:- import_module set.
:- import_module term.
:- import_module uint.
+:- import_module uint16.
+:- import_module uint32.
:- import_module uint8.
:- import_module univ.
@@ -240,27 +243,39 @@ gen_init_rtti_data_defn(ModuleInfo, Target, RttiData, !GlobalData) :-
CompareUniv, CompareInitializer, !GlobalData),
Initializer = init_struct(mlds_rtti_type(item_type(RttiId)), [
- gen_init_int(TypeArity), % MR_type_ctor_arity
- gen_init_int8(Version), % MR_type_ctor_version
- gen_init_int8(NumPtagsEncoding), % MR_type_ctor_num_ptags
- gen_init_type_ctor_rep(TypeCtorData), % MR_type_ctor_rep_CAST_ME
- UnifyInitializer, % MR_type_ctor_unify_pred
- CompareInitializer, % MR_type_ctor_compare_pred
- gen_init_string(TypeModuleName), % MR_type_ctor_module_name
- gen_init_string(TypeName), % MR_type_ctor_name
+ % MR_type_ctor_arity -- XXX MAKE_FIELD_UNSIGNED
+ gen_init_int(uint16.to_int(TypeArity)),
+ % MR_type_ctor_version
+ gen_init_uint8(Version),
+ % MR_type_ctor_num_ptags
+ gen_init_int8(NumPtagsEncoding),
+ % MR_type_ctor_rep_CAST_ME
+ gen_init_type_ctor_rep(TypeCtorData),
+ % MR_type_ctor_unify_pred
+ UnifyInitializer,
+ % MR_type_ctor_compare_pred
+ CompareInitializer,
+ % MR_type_ctor_module_name
+ gen_init_string(TypeModuleName),
+ % MR_type_ctor_name
+ gen_init_string(TypeName),
% In the C back-end, these two "structs" are actually unions.
% We need to use `init_struct' here so that the initializers
% get enclosed in curly braces.
+ % MR_type_ctor_functors
init_struct(mlds_rtti_type(item_type(FunctorsRttiId)), [
FunctorsInfo
- ]), % MR_type_ctor_functors
+ ]),
+ % MR_type_ctor_layout
init_struct(mlds_rtti_type(item_type(LayoutRttiId)), [
LayoutInfo
- ]), % MR_type_ctor_layout
- gen_init_int(NumFunctorsEncoding), % MR_type_ctor_num_functors
- gen_init_uint16(encode_type_ctor_flags(Flags)),
+ ]),
+ % MR_type_ctor_num_functors
+ gen_init_int(NumFunctorsEncoding),
% MR_type_ctor_flags
- NumberMapInfo % MR_type_ctor_functor_number_map
+ gen_init_uint16(encode_type_ctor_flags(Flags)),
+ % MR_type_ctor_functor_number_map
+ NumberMapInfo
% These two are commented out while the corresponding fields of the
% MR_TypeCtorInfo_Struct type are commented out.
@@ -676,7 +691,7 @@ gen_functors_layout_info(ModuleInfo, Target, RttiTypeCtor, TypeCtorDetails,
type_ctor_functor_number_map)
;
TypeCtorDetails = tcd_notag(_, NotagFunctor),
- gen_functor_number_map(RttiTypeCtor, [0], !GlobalData),
+ gen_functor_number_map(RttiTypeCtor, [0u32], !GlobalData),
LayoutInitializer = gen_init_rtti_name(ModuleName, RttiTypeCtor,
type_ctor_notag_functor_desc),
FunctorInitializer = gen_init_rtti_name(ModuleName, RttiTypeCtor,
@@ -713,8 +728,10 @@ gen_enum_functor_desc(_ModuleInfo, RttiTypeCtor, EnumFunctor, !GlobalData) :-
RttiName = type_ctor_enum_functor_desc(Ordinal),
RttiId = ctor_rtti_id(RttiTypeCtor, RttiName),
Initializer = init_struct(mlds_rtti_type(item_type(RttiId)), [
- gen_init_string(FunctorName), % MR_enum_functor_name
- gen_init_int(Ordinal) % MR_enum_functor_ordinal
+ % MR_enum_functor_name
+ gen_init_string(FunctorName),
+ % MR_enum_functor_ordinal -- XXX MAKE_FIELD_UNSIGNED
+ gen_init_int32(int32.cast_from_uint32(Ordinal))
]),
rtti_id_and_init_to_defn(RttiId, Initializer, !GlobalData).
@@ -728,9 +745,12 @@ gen_foreign_enum_functor_desc(_ModuleInfo, Lang, RttiTypeCtor,
RttiName = type_ctor_foreign_enum_functor_desc(Ordinal),
RttiId = ctor_rtti_id(RttiTypeCtor, RttiName),
Initializer = init_struct(mlds_rtti_type(item_type(RttiId)), [
- gen_init_string(FunctorName), % MR_foreign_enum_functor_name
- gen_init_int(Ordinal), % MR_foreign_enum_functor_ordinal
- gen_init_foreign(Lang, Value) % MR_foreign_enum_functor_value
+ % MR_foreign_enum_functor_name
+ gen_init_string(FunctorName),
+ % MR_foreign_enum_functor_ordinal -- XXX MAKE_FIELD_UNSIGNED
+ gen_init_int32(int32.cast_from_uint32(Ordinal)),
+ % MR_foreign_enum_functor_value
+ gen_init_foreign(Lang, Value)
]),
rtti_id_and_init_to_defn(RttiId, Initializer, !GlobalData).
@@ -783,7 +803,7 @@ gen_du_functor_desc(ModuleInfo, Target, RttiTypeCtor, DuFunctor,
ArgInfos = [],
ArgTypeInitializer = gen_init_null_pointer(
mlds_rtti_type(item_type(
- ctor_rtti_id(RttiTypeCtor, type_ctor_field_types(0)))))
+ ctor_rtti_id(RttiTypeCtor, type_ctor_field_types(0u32)))))
),
(
HaveArgNames = yes,
@@ -795,7 +815,7 @@ gen_du_functor_desc(ModuleInfo, Target, RttiTypeCtor, DuFunctor,
HaveArgNames = no,
ArgNameInitializer = gen_init_null_pointer(
mlds_rtti_type(item_type(
- ctor_rtti_id(RttiTypeCtor, type_ctor_field_names(0)))))
+ ctor_rtti_id(RttiTypeCtor, type_ctor_field_names(0u32)))))
),
gen_field_locns(ModuleInfo, RttiTypeCtor, Ordinal, ArgInfos, HaveArgLocns,
!GlobalData),
@@ -807,7 +827,7 @@ gen_du_functor_desc(ModuleInfo, Target, RttiTypeCtor, DuFunctor,
HaveArgLocns = no,
ArgLocnsInitializer = gen_init_null_pointer(
mlds_rtti_type(item_type(
- ctor_rtti_id(RttiTypeCtor, type_ctor_field_locns(0)))))
+ ctor_rtti_id(RttiTypeCtor, type_ctor_field_locns(0u32)))))
),
(
MaybeExistInfo = yes(ExistInfo),
@@ -819,7 +839,7 @@ gen_du_functor_desc(ModuleInfo, Target, RttiTypeCtor, DuFunctor,
MaybeExistInfo = no,
ExistInfoInitializer = gen_init_null_pointer(
mlds_rtti_type(item_type(
- ctor_rtti_id(RttiTypeCtor, type_ctor_exist_info(0)))))
+ ctor_rtti_id(RttiTypeCtor, type_ctor_exist_info(0u32)))))
),
(
Rep = du_ll_rep(Ptag, SectagAndLocn),
@@ -860,15 +880,17 @@ gen_du_functor_desc(ModuleInfo, Target, RttiTypeCtor, DuFunctor,
),
RttiName = type_ctor_du_functor_desc(Ordinal),
RttiId = ctor_rtti_id(RttiTypeCtor, RttiName),
+ ArityInt16 = int16.cast_from_uint16(Arity), % XXX MAKE_FIELD_UNSIGNED
+ OrdinalInt32 = int32.cast_from_uint32(Ordinal), % XXX MAKE_FIELD_UNSIGNED
Initializer = init_struct(mlds_rtti_type(item_type(RttiId)), [
gen_init_string(FunctorName), % MR_du_functor_name
- gen_init_int16(Arity), % MR_du_functor_orig_arity
+ gen_init_int16(ArityInt16), % MR_du_functor_orig_arity
gen_init_uint16(ContainsVarBitVector),
% MR_du_functor_arg_type_contains_var
gen_init_sectag_locn(Locn), % MR_du_functor_sectag_locn
gen_init_uint8(PtagUint8), % MR_du_functor_primary
gen_init_int(Stag), % MR_du_functor_secondary
- gen_init_int(Ordinal), % MR_du_functor_ordinal
+ gen_init_int32(OrdinalInt32), % MR_du_functor_ordinal
ArgTypeInitializer, % MR_du_functor_arg_types
ArgNameInitializer, % MR_du_functor_arg_names
ArgLocnsInitializer, % MR_du_functor_arg_locns
@@ -886,18 +908,21 @@ gen_du_functor_desc(ModuleInfo, Target, RttiTypeCtor, DuFunctor,
gen_init_exist_locn(RttiTypeCtor, ExistTypeInfoLocn) = Initializer :-
(
- ExistTypeInfoLocn = typeinfo_in_tci(SlotInCell, SlotInTci)
+ ExistTypeInfoLocn = typeinfo_in_tci(SlotInCell, SlotInTci),
+ SlotInTciEncoding = int16.cast_from_uint16(SlotInTci)
;
ExistTypeInfoLocn = plain_typeinfo(SlotInCell),
- SlotInTci = -1i16
+ SlotInTciEncoding = -1i16
),
RttiId = ctor_rtti_id(RttiTypeCtor, type_ctor_exist_locn),
Initializer = init_struct(mlds_rtti_type(item_type(RttiId)), [
- gen_init_int16(SlotInCell), % MR_exist_arg_num
- gen_init_int16(SlotInTci) % MR_exist_offset_in_tci
+ % MR_exist_arg_num -- XXX MAKE_FIELD_UNSIGNED
+ gen_init_int16(int16.cast_from_uint16(SlotInCell)),
+ % MR_exist_offset_in_tci
+ gen_init_int16(SlotInTciEncoding)
]).
-:- pred gen_exist_locns_array(module_info::in, rtti_type_ctor::in, int::in,
+:- pred gen_exist_locns_array(module_info::in, rtti_type_ctor::in, uint32::in,
list(exist_typeinfo_locn)::in, ml_global_data::in, ml_global_data::out)
is det.
@@ -930,15 +955,15 @@ gen_tc_constraint(ModuleInfo, Target, MakeRttiId, Constraint, RttiId,
]),
rtti_id_and_init_to_defn(RttiId, Initializer, !GlobalData).
-:- pred make_exist_tc_constr_id(rtti_type_ctor::in, int::in, int::in, int::in,
- rtti_id::out) is det.
+:- pred make_exist_tc_constr_id(rtti_type_ctor::in, uint32::in, int::in,
+ int::in, rtti_id::out) is det.
make_exist_tc_constr_id(RttiTypeCtor, Ordinal, TCNum, Arity, RttiId) :-
RttiName = type_ctor_exist_tc_constr(Ordinal, TCNum, Arity),
RttiId = ctor_rtti_id(RttiTypeCtor, RttiName).
:- pred gen_exist_info(module_info::in, mlds_target_lang::in,
- rtti_type_ctor::in, int::in, exist_info::in,
+ rtti_type_ctor::in, uint32::in, exist_info::in,
ml_global_data::in, ml_global_data::out) is det.
gen_exist_info(ModuleInfo, Target, RttiTypeCtor, Ordinal, ExistInfo,
@@ -973,19 +998,23 @@ gen_exist_info(ModuleInfo, Target, RttiTypeCtor, Ordinal, ExistInfo,
gen_exist_locns_array(ModuleInfo, RttiTypeCtor, Ordinal, Locns,
!GlobalData),
Initializer = init_struct(mlds_rtti_type(item_type(RttiId)), [
- gen_init_int16(Plain), % MR_exist_typeinfos_plain
- gen_init_int16(InTci), % MR_exist_typeinfos_in_tci
+ % MR_exist_typeinfos_plain -- XXX MAKE_FIELD_UNSIGNED
+ gen_init_int16(int16.cast_from_uint16(Plain)),
+ % MR_exist_typeinfos_in_tci -- XXX MAKE_FIELD_UNSIGNED
+ gen_init_int16(int16.cast_from_uint16(InTci)),
+ % MR_exist_tcis -- XXX MAKE_FIELD_UNSIGNED
gen_init_int16(int16.det_from_int(Tci)),
- % MR_exist_tcis
+ % MR_exist_typeinfo_locns
gen_init_rtti_name(ModuleName, RttiTypeCtor,
type_ctor_exist_locns(Ordinal)),
- % MR_exist_typeinfo_locns
- ConstrInitializer % MR_exist_constraints
+ % MR_exist_constraints
+ ConstrInitializer
]),
rtti_id_and_init_to_defn(RttiId, Initializer, !GlobalData).
:- pred gen_field_types(module_info::in, mlds_target_lang::in,
- rtti_type_ctor::in, int::in, list(rtti_maybe_pseudo_type_info_or_self)::in,
+ rtti_type_ctor::in, uint32::in,
+ list(rtti_maybe_pseudo_type_info_or_self)::in,
ml_global_data::in, ml_global_data::out) is det.
gen_field_types(ModuleInfo, Target, RttiTypeCtor, Ordinal, Types,
@@ -998,7 +1027,7 @@ gen_field_types(ModuleInfo, Target, RttiTypeCtor, Ordinal, Types,
rtti_name_and_init_to_defn(RttiTypeCtor, RttiName, Initializer,
!GlobalData).
-:- pred gen_field_names(module_info::in, rtti_type_ctor::in, int::in,
+:- pred gen_field_names(module_info::in, rtti_type_ctor::in, uint32::in,
list(maybe(string))::in, ml_global_data::in, ml_global_data::out) is det.
gen_field_names(_ModuleInfo, RttiTypeCtor, Ordinal, MaybeNames, !GlobalData) :-
@@ -1009,7 +1038,7 @@ gen_field_names(_ModuleInfo, RttiTypeCtor, Ordinal, MaybeNames, !GlobalData) :-
rtti_name_and_init_to_defn(RttiTypeCtor, RttiName, Initializer,
!GlobalData).
-:- pred gen_field_locns(module_info::in, rtti_type_ctor::in, int::in,
+:- pred gen_field_locns(module_info::in, rtti_type_ctor::in, uint32::in,
list(du_arg_info)::in, bool::out, ml_global_data::in, ml_global_data::out)
is det.
@@ -1115,7 +1144,7 @@ gen_field_locn(RttiId, ArgInfo, ArgLocnInitializer) :-
%-----------------------------------------------------------------------------%
:- pred gen_enum_value_ordered_table(module_info::in, rtti_type_ctor::in,
- map(int, enum_functor)::in,
+ map(uint32, enum_functor)::in,
ml_global_data::in, ml_global_data::out) is det.
gen_enum_value_ordered_table(ModuleInfo, RttiTypeCtor, EnumByValue,
@@ -1145,7 +1174,7 @@ gen_enum_name_ordered_table(ModuleInfo, RttiTypeCtor, EnumByName,
!GlobalData).
:- pred gen_foreign_enum_ordinal_ordered_table(module_info::in,
- rtti_type_ctor::in, map(int, foreign_enum_functor)::in,
+ rtti_type_ctor::in, map(uint32, foreign_enum_functor)::in,
ml_global_data::in, ml_global_data::out) is det.
gen_foreign_enum_ordinal_ordered_table(ModuleInfo, RttiTypeCtor,
@@ -1214,11 +1243,15 @@ gen_du_ptag_ordered_table_body(ModuleName, RttiTypeCtor, CurPtag,
RttiName = type_ctor_du_ptag_layout(Ptag),
RttiId = ctor_rtti_id(RttiTypeCtor, RttiName),
Initializer = init_struct(mlds_rtti_type(item_type(RttiId)), [
- gen_init_uint(NumSharers), % MR_sectag_sharers
- gen_init_sectag_locn(SectagLocn), % MR_sectag_locn
+ % MR_sectag_sharers
+ gen_init_uint32(NumSharers),
+ % MR_sectag_locn
+ gen_init_sectag_locn(SectagLocn),
+ % MR_sectag_alternatives
gen_init_rtti_name(ModuleName, RttiTypeCtor,
- type_ctor_du_stag_ordered_table(Ptag)), % MR_sectag_alternatives
- gen_init_int8(NumSectagBits) % MR_sectag_numbits
+ type_ctor_du_stag_ordered_table(Ptag)),
+ % MR_sectag_numbits
+ gen_init_int8(NumSectagBits)
]),
CurPtag = ptag(CurPtagUint8),
NextPtag = ptag(CurPtagUint8 + 1u8),
@@ -1242,7 +1275,7 @@ gen_du_stag_ordered_table(ModuleName, RttiTypeCtor, Ptag - SectagTable,
!GlobalData).
:- pred gen_du_name_ordered_table(module_info::in, rtti_type_ctor::in,
- map(string, map(int16, du_functor))::in,
+ map(string, map(uint16, du_functor))::in,
ml_global_data::in, ml_global_data::out) is det.
gen_du_name_ordered_table(ModuleInfo, RttiTypeCtor, NameArityMap,
@@ -1258,15 +1291,22 @@ gen_du_name_ordered_table(ModuleInfo, RttiTypeCtor, NameArityMap,
rtti_name_and_init_to_defn(RttiTypeCtor, RttiName, Initializer,
!GlobalData).
-:- pred gen_functor_number_map(rtti_type_ctor::in, list(int)::in,
+:- pred gen_functor_number_map(rtti_type_ctor::in, list(uint32)::in,
ml_global_data::in, ml_global_data::out) is det.
gen_functor_number_map(RttiTypeCtor, FunctorNumberMap, !GlobalData) :-
- Initializer = gen_init_array(gen_init_int, FunctorNumberMap),
+ Initializer = gen_init_array(gen_init_functor_number, FunctorNumberMap),
RttiName = type_ctor_functor_number_map,
rtti_name_and_init_to_defn(RttiTypeCtor, RttiName, Initializer,
!GlobalData).
+:- func gen_init_functor_number(uint32) = mlds_initializer.
+
+gen_init_functor_number(NumUint32) = Init :-
+ % XXX MAKE_FIELD_UNSIGNED
+ Num = uint32.cast_to_int(NumUint32),
+ Init = gen_init_int(Num).
+
%-----------------------------------------------------------------------------%
:- func gen_init_rtti_names_array(module_name, rtti_type_ctor,
diff --git a/compiler/stack_layout.m b/compiler/stack_layout.m
index de1f84eff..24381d5d5 100644
--- a/compiler/stack_layout.m
+++ b/compiler/stack_layout.m
@@ -2174,7 +2174,7 @@ represent_live_value_type_and_var_num(VarNumMap, LiveValueType, TypeRval,
:- pred represent_special_live_value_type(string::in, rval::out) is det.
represent_special_live_value_type(SpecialTypeName, Rval) :-
- RttiTypeCtor = rtti_type_ctor(unqualified(""), SpecialTypeName, 0),
+ RttiTypeCtor = rtti_type_ctor(unqualified(""), SpecialTypeName, 0u16),
DataId =
rtti_data_id(ctor_rtti_id(RttiTypeCtor, type_ctor_type_ctor_info)),
Rval = const(llconst_data_addr(DataId, no)).
diff --git a/compiler/type_ctor_info.m b/compiler/type_ctor_info.m
index 452ad1f63..a2beb2ab7 100644
--- a/compiler/type_ctor_info.m
+++ b/compiler/type_ctor_info.m
@@ -89,7 +89,6 @@
:- import_module assoc_list.
:- import_module bool.
:- import_module int.
-:- import_module int16.
:- import_module int8.
:- import_module map.
:- import_module maybe.
@@ -98,8 +97,8 @@
:- import_module set.
:- import_module string.
:- import_module term.
-:- import_module uint.
:- import_module uint16.
+:- import_module uint32.
:- import_module univ.
:- import_module varset.
@@ -413,8 +412,9 @@ construct_type_ctor_info(TypeCtorGenInfo, ModuleInfo, RttiData) :-
; TypeBody = hlds_abstract_type(_)
)
),
- TypeCtorData = type_ctor_data(Version, ModuleName, TypeName, TypeArity,
- UnifyUniv, CompareUniv, !.Flags, Details)
+ TypeCtorData = type_ctor_data(Version, ModuleName, TypeName,
+ uint16.det_from_int(TypeArity), UnifyUniv, CompareUniv,
+ !.Flags, Details)
),
RttiData = rtti_data_type_ctor_info(TypeCtorData).
@@ -486,9 +486,9 @@ impl_type_ctor("table_builtin", "ml_subgoal", 0, impl_ctor_subgoal).
% generate them) as well as the code in the runtime that uses RTTI
% to conform to whatever changes the new version introduces.
%
-:- func type_ctor_info_rtti_version = int8.
+:- func type_ctor_info_rtti_version = uint8.
-type_ctor_info_rtti_version = 17i8.
+type_ctor_info_rtti_version = 17u8.
%---------------------------------------------------------------------------%
@@ -535,7 +535,7 @@ make_mercury_enum_details(CtorRepns, IsDummy, EqualityAxioms, Details) :-
expect(unify(IsDummy, enum_is_not_dummy), $pred,
"more than one ctor but dummy")
),
- make_enum_functors(CtorRepns, IsDummy, 0, EnumFunctors),
+ make_enum_functors(CtorRepns, IsDummy, 0u32, EnumFunctors),
ValueMap0 = map.init,
NameMap0 = map.init,
list.foldl2(make_enum_maps, EnumFunctors,
@@ -553,7 +553,7 @@ make_mercury_enum_details(CtorRepns, IsDummy, EqualityAxioms, Details) :-
% is constructed.
%
:- pred make_enum_functors(list(constructor_repn)::in, enum_maybe_dummy::in,
- int::in, list(enum_functor)::out) is det.
+ uint32::in, list(enum_functor)::out) is det.
make_enum_functors([], _, _, []).
make_enum_functors([FunctorRepn | FunctorRepns], IsDummy, CurOrdinal,
@@ -567,7 +567,8 @@ make_enum_functors([FunctorRepn | FunctorRepns], IsDummy, CurOrdinal,
expect(unify(Arity, 0), $pred, "functor in enum has nonzero arity"),
(
IsDummy = enum_is_not_dummy,
- expect(unify(ConsTag, int_tag(int_tag_int(CurOrdinal))), $pred,
+ CurOrdinalInt = uint32.cast_to_int(CurOrdinal),
+ expect(unify(ConsTag, int_tag(int_tag_int(CurOrdinalInt))), $pred,
"enum functor's tag is not the expected int_tag")
;
IsDummy = enum_is_dummy,
@@ -576,10 +577,10 @@ make_enum_functors([FunctorRepn | FunctorRepns], IsDummy, CurOrdinal,
),
FunctorName = unqualify_name(SymName),
EnumFunctor = enum_functor(FunctorName, CurOrdinal),
- make_enum_functors(FunctorRepns, IsDummy, CurOrdinal + 1, EnumFunctors).
+ make_enum_functors(FunctorRepns, IsDummy, CurOrdinal + 1u32, EnumFunctors).
:- pred make_enum_maps(enum_functor::in,
- map(int, enum_functor)::in, map(int, enum_functor)::out,
+ map(uint32, enum_functor)::in, map(uint32, enum_functor)::out,
map(string, enum_functor)::in, map(string, enum_functor)::out) is det.
make_enum_maps(EnumFunctor, !ValueMap, !NameMap) :-
@@ -596,7 +597,7 @@ make_enum_maps(EnumFunctor, !ValueMap, !NameMap) :-
type_ctor_details::out) is det.
make_foreign_enum_details(Lang, CtorRepns, EqualityAxioms, Details) :-
- make_foreign_enum_functors(Lang, CtorRepns, 0, ForeignEnumFunctors),
+ make_foreign_enum_functors(Lang, CtorRepns, 0u32, ForeignEnumFunctors),
OrdinalMap0 = map.init,
NameMap0 = map.init,
list.foldl2(make_foreign_enum_maps, ForeignEnumFunctors,
@@ -614,7 +615,7 @@ make_foreign_enum_details(Lang, CtorRepns, EqualityAxioms, Details) :-
% structure is constructed.
%
:- pred make_foreign_enum_functors(foreign_language::in,
- list(constructor_repn)::in, int::in,
+ list(constructor_repn)::in, uint32::in,
list(foreign_enum_functor)::out) is det.
make_foreign_enum_functors(_, [], _, []).
@@ -658,12 +659,12 @@ make_foreign_enum_functors(Lang, [FunctorRepn | FunctorRepns], CurOrdinal,
FunctorName = unqualify_name(SymName),
ForeignEnumFunctor = foreign_enum_functor(FunctorName, CurOrdinal,
ForeignTagValue),
- make_foreign_enum_functors(Lang, FunctorRepns, CurOrdinal + 1,
+ make_foreign_enum_functors(Lang, FunctorRepns, CurOrdinal + 1u32,
ForeignEnumFunctors).
:- pred make_foreign_enum_maps(foreign_enum_functor::in,
- map(int, foreign_enum_functor)::in,
- map(int, foreign_enum_functor)::out,
+ map(uint32, foreign_enum_functor)::in,
+ map(uint32, foreign_enum_functor)::out,
map(string, foreign_enum_functor)::in,
map(string, foreign_enum_functor)::out) is det.
@@ -686,7 +687,7 @@ make_foreign_enum_maps(ForeignEnumFunctor, !OrdinalMap, !NameMap) :-
int::in, equality_axioms::in, type_ctor_details::out) is det.
make_du_details(ModuleInfo, Ctors, TypeArity, EqualityAxioms, Details) :-
- make_du_functors(ModuleInfo, Ctors, 0, TypeArity, DuFunctors),
+ make_du_functors(ModuleInfo, Ctors, 0u32, TypeArity, DuFunctors),
list.foldl(make_du_ptag_ordered_table, DuFunctors, map.init, DuPtagTable),
FunctorNumberMap = make_functor_number_map(Ctors),
list.foldl(make_du_name_ordered_table, DuFunctors,
@@ -703,7 +704,7 @@ make_du_details(ModuleInfo, Ctors, TypeArity, EqualityAxioms, Details) :-
% this is how the type layout structure is constructed.
%
:- pred make_du_functors(module_info::in, list(constructor_repn)::in,
- int::in, int::in, list(du_functor)::out) is det.
+ uint32::in, int::in, list(du_functor)::out) is det.
make_du_functors(_, [], _, _, []).
make_du_functors(ModuleInfo, [CtorRepn | CtorRepns],
@@ -727,11 +728,11 @@ make_du_functors(ModuleInfo, [CtorRepn | CtorRepns],
),
list.map_foldl(generate_du_arg_info(TypeArity, ExistTVars),
ConsArgRepns, ArgInfos, functor_subtype_none, FunctorSubtypeInfo),
- DuFunctor = du_functor(FunctorName, int16.det_from_int(Arity), CurOrdinal,
+ DuFunctor = du_functor(FunctorName, uint16.det_from_int(Arity), CurOrdinal,
DuRep, ArgInfos, MaybeExistInfo, FunctorSubtypeInfo),
make_du_functors(ModuleInfo, CtorRepns,
- CurOrdinal + 1, TypeArity, DuFunctors).
+ CurOrdinal + 1u32, TypeArity, DuFunctors).
:- pred get_du_rep(cons_tag::in, du_rep::out) is det.
@@ -860,7 +861,7 @@ generate_exist_info(ExistConstraints, ClassTable, ExistInfo) :-
map.init(LocnMap0),
list.foldl2(
( pred(T::in, N0::in, N::out, Lm0::in, Lm::out) is det :-
- Locn = plain_typeinfo(int16.det_from_int(N0)),
+ Locn = plain_typeinfo(uint16.det_from_int(N0)),
map.det_insert(T, Locn, Lm0, Lm),
N = N0 + 1
), UnconstrainedTVars, 0, TIsPlain, LocnMap0, LocnMap1),
@@ -874,8 +875,8 @@ generate_exist_info(ExistConstraints, ClassTable, ExistInfo) :-
map.lookup(LocnMap, TVar, Locn)
), ExistTVars, ExistLocns),
ExistInfo = exist_info(
- int16.det_from_int(TIsPlain),
- int16.det_from_int(TIsInTCIs),
+ uint16.det_from_int(TIsPlain),
+ uint16.det_from_int(TIsInTCIs),
TCConstraints,
ExistLocns
).
@@ -893,8 +894,8 @@ find_type_info_index(Constraints, ClassTable, StartSlot, TVar, !LocnMap) :-
list.length(ClassDefn ^ classdefn_supers, NumSuperClasses),
RealTypeInfoIndex = TypeInfoIndex + NumSuperClasses,
Locn = typeinfo_in_tci(
- int16.det_from_int(Slot),
- int16.det_from_int(RealTypeInfoIndex)
+ uint16.det_from_int(Slot),
+ uint16.det_from_int(RealTypeInfoIndex)
),
map.det_insert(TVar, Locn, !LocnMap).
@@ -969,19 +970,19 @@ make_du_ptag_ordered_table(DuFunctor, !PtagTable) :-
expect(unify(NumSectagBits0, NumSectagBits), $pred,
"sectag num bits disagreement"),
map.det_insert(Sectag, DuFunctor, SectagMap0, SectagMap),
- SectagTable = sectag_table(Locn0, NumSectagBits0, NumSharers0 + 1u,
+ SectagTable = sectag_table(Locn0, NumSectagBits0, NumSharers0 + 1u32,
SectagMap),
map.det_update(Ptag, SectagTable, !PtagTable)
else
SectagMap = map.singleton(Sectag, DuFunctor),
- SectagTable = sectag_table(SectagLocn, NumSectagBits, 1u,
+ SectagTable = sectag_table(SectagLocn, NumSectagBits, 1u32,
SectagMap),
map.det_insert(Ptag, SectagTable, !PtagTable)
).
:- pred make_du_name_ordered_table(du_functor::in,
- map(string, map(int16, du_functor))::in,
- map(string, map(int16, du_functor))::out) is det.
+ map(string, map(uint16, du_functor))::in,
+ map(string, map(uint16, du_functor))::out) is det.
make_du_name_ordered_table(DuFunctor, !NameTable) :-
Name = DuFunctor ^ du_name,
@@ -999,21 +1000,28 @@ make_du_name_ordered_table(DuFunctor, !NameTable) :-
% Construct the array mapping ordinal constructor numbers
% to lexicographic constructor numbers.
%
-:- func make_functor_number_map(list(constructor_repn)) = list(int).
+:- func make_functor_number_map(list(constructor_repn)) = list(uint32).
make_functor_number_map(OrdinalCtors) = OrdinalToLexicographicSeqNums :-
OrdinalCtorNames = list.map(ctor_name_arity, OrdinalCtors),
list.sort(OrdinalCtorNames, LexicographicCtorNames),
LexicographicSeqNums = 0 `..` (list.length(OrdinalCtors) - 1),
map.from_corresponding_lists(LexicographicCtorNames, LexicographicSeqNums,
- LexicographicCtorNameToSeqNumMap),
- map.apply_to_list(OrdinalCtorNames, LexicographicCtorNameToSeqNumMap,
- OrdinalToLexicographicSeqNums).
+ CtorNameToSeqNumMap),
+ list.map(lookup_functor_number(CtorNameToSeqNumMap),
+ OrdinalCtorNames, OrdinalToLexicographicSeqNums).
:- func ctor_name_arity(constructor_repn) = {sym_name, arity}.
ctor_name_arity(Ctor) = {Ctor ^ cr_name, list.length(Ctor ^ cr_args)}.
+:- pred lookup_functor_number(map({sym_name, arity}, int)::in,
+ {sym_name, arity}::in, uint32::out) is det.
+
+lookup_functor_number(CtorNameToSeqNumMap, CtorName, SeqNumUint32) :-
+ map.lookup(CtorNameToSeqNumMap, CtorName, SeqNum),
+ SeqNumUint32 = uint32.det_from_int(SeqNum).
+
%---------------------------------------------------------------------------%
compute_contains_var_bit_vector(ArgTypes) = Vector :-
diff --git a/compiler/type_util.m b/compiler/type_util.m
index 57162a98e..ad8c8953d 100644
--- a/compiler/type_util.m
+++ b/compiler/type_util.m
@@ -1211,7 +1211,7 @@ type_constructors(ModuleInfo, Type, Constructors) :-
CtorArgs = list.map(
(func(ArgType) = ctor_arg(no, ArgType, Context)),
TypeArgs),
- Constructors = [ctor(0, MaybeExistConstraints, unqualified("{}"),
+ Constructors = [ctor(0u32, MaybeExistConstraints, unqualified("{}"),
CtorArgs, list.length(CtorArgs), Context)]
else
module_info_get_type_table(ModuleInfo, TypeTable),
diff --git a/compiler/unify_gen_construct.m b/compiler/unify_gen_construct.m
index 198801357..ff9a23fb3 100644
--- a/compiler/unify_gen_construct.m
+++ b/compiler/unify_gen_construct.m
@@ -89,6 +89,7 @@
:- import_module require.
:- import_module string.
:- import_module term.
+:- import_module uint16.
%---------------------------------------------------------------------------%
@@ -150,7 +151,8 @@ generate_construction_unification(LHSVar, ConsId, RHSVars, ArgModes,
TypedRval = typed_rval(ConstRval, _Type)
;
ConsTag = type_ctor_info_tag(ModuleName, TypeName, TypeArity),
- RttiTypeCtor = rtti_type_ctor(ModuleName, TypeName, TypeArity),
+ RttiTypeCtor = rtti_type_ctor(ModuleName, TypeName,
+ uint16.det_from_int(TypeArity)),
DataId = rtti_data_id(ctor_rtti_id(RttiTypeCtor,
type_ctor_type_ctor_info)),
ConstRval = const(llconst_data_addr(DataId, no))
@@ -1401,7 +1403,8 @@ generate_const_struct_arg_tag(UnboxedFloats, UnboxedInt64s,
TypedRval = typed_rval(Rval, lt_data_ptr)
;
ConsTag = type_ctor_info_tag(ModuleName, TypeName, TypeArity),
- RttiTypeCtor = rtti_type_ctor(ModuleName, TypeName, TypeArity),
+ RttiTypeCtor = rtti_type_ctor(ModuleName, TypeName,
+ uint16.det_from_int(TypeArity)),
DataId = rtti_data_id(ctor_rtti_id(RttiTypeCtor,
type_ctor_type_ctor_info)),
Rval = const(llconst_data_addr(DataId, no)),
diff --git a/library/rtti_implementation.m b/library/rtti_implementation.m
index 8109290ea..85b9b426c 100644
--- a/library/rtti_implementation.m
+++ b/library/rtti_implementation.m
@@ -143,6 +143,7 @@
:- import_module char.
:- import_module int.
:- import_module int16.
+:- import_module int32.
:- import_module maybe.
:- import_module require.
:- import_module string.
@@ -1263,7 +1264,7 @@ type_info_get_functor_ordinal(TypeInfo, FunctorNum, Ordinal) :-
TypeFunctors = get_type_ctor_functors(TypeCtorInfo),
DuFunctorDesc = TypeFunctors ^ du_functor_desc(TypeCtorRep,
FunctorNum),
- Ordinal = du_functor_ordinal(DuFunctorDesc)
+ Ordinal = int32.to_int(du_functor_ordinal(DuFunctorDesc))
;
( TypeCtorRep = tcr_equiv
; TypeCtorRep = tcr_equiv_ground
@@ -2821,7 +2822,7 @@ deconstruct_2(Term, TypeInfo, TypeCtorInfo, TypeCtorRep, NonCanon,
FunctorDesc = PTagEntry ^ du_sectag_alternatives(SecTag)
),
Functor = FunctorDesc ^ du_functor_name,
- Ordinal = FunctorDesc ^ du_functor_ordinal,
+ Ordinal = int32.to_int(FunctorDesc ^ du_functor_ordinal),
Arity = int16.to_int(FunctorDesc ^ du_functor_arity),
Arguments = iterate(0, Arity - 1,
get_arg_univ(Term, SecTagLocn, FunctorDesc, TypeInfo))
@@ -5049,7 +5050,7 @@ du_functor_primary(DuFunctorDesc) = DuFunctorDesc ^ unsafe_index(4).
Primary = DuFunctorDesc.du_functor_primary;
").
-:- func du_functor_secondary(du_functor_desc) = int.
+:- func du_functor_secondary(du_functor_desc) = int32.
du_functor_secondary(DuFunctorDesc) = DuFunctorDesc ^ unsafe_index(5).
@@ -5067,7 +5068,7 @@ du_functor_secondary(DuFunctorDesc) = DuFunctorDesc ^ unsafe_index(5).
Secondary = DuFunctorDesc.du_functor_secondary;
").
-:- func du_functor_ordinal(du_functor_desc) = int.
+:- func du_functor_ordinal(du_functor_desc) = int32.
du_functor_ordinal(DuFunctorDesc) = DuFunctorDesc ^ unsafe_index(6).
diff --git a/runtime/mercury_dotnet.cs.in b/runtime/mercury_dotnet.cs.in
index dc1e232cf..e897581a9 100644
--- a/runtime/mercury_dotnet.cs.in
+++ b/runtime/mercury_dotnet.cs.in
@@ -370,7 +370,7 @@ public class PseudoTypeInfo {
public class TypeCtorInfo_Struct : PseudoTypeInfo {
public int arity;
- public sbyte type_ctor_version;
+ public byte type_ctor_version;
public sbyte type_ctor_num_ptags;
public TypeCtorRep type_ctor_rep;
public object unify_pred;
@@ -410,7 +410,7 @@ public class TypeCtorInfo_Struct : PseudoTypeInfo {
public void init(
int type_arity,
- sbyte version,
+ byte version,
sbyte num_ptags,
TypeCtorRep rep,
object unify_proc,
diff --git a/runtime/mercury_type_info.h b/runtime/mercury_type_info.h
index a69b73e2c..796c62c8d 100644
--- a/runtime/mercury_type_info.h
+++ b/runtime/mercury_type_info.h
@@ -745,7 +745,7 @@ typedef const MR_TypeClassConstraintStruct *MR_TypeClassConstraint;
// macro.
typedef struct {
- MR_int_least16_t MR_exist_arg_num; // XXX make unsigned?
+ MR_int_least16_t MR_exist_arg_num; // XXX MAKE_FIELD_UNSIGNED
MR_int_least16_t MR_exist_offset_in_tci; // negative is possible
} MR_DuExistLocn;
@@ -780,7 +780,7 @@ typedef struct {
// typeclass_info in the functor is derived.
typedef struct {
- // XXX make first three fields unsigned?
+ // XXX MAKE_FIELD_UNSIGNED - first three fields
MR_int_least16_t MR_exist_typeinfos_plain;
MR_int_least16_t MR_exist_typeinfos_in_tci;
MR_int_least16_t MR_exist_tcis;
@@ -889,7 +889,7 @@ typedef struct {
// next to a local secondary tag (MR_SECTAG_LOCAL_BITS), the value of
// the MR_arg_offset field will be -2.
- MR_int_least8_t MR_arg_shift; // XXX make unsigned?
+ MR_int_least8_t MR_arg_shift; // XXX MAKE_FIELD_UNSIGNED
MR_int_least8_t MR_arg_bits;
// If MR_arg_bits is 0, then the argument occupies the entire word
// at the offset given by MR_arg_offset within the term's memory cell.
@@ -965,12 +965,15 @@ typedef enum {
typedef struct {
MR_ConstString MR_du_functor_name;
- MR_int_least16_t MR_du_functor_orig_arity; // XXX make unsigned?
+ MR_int_least16_t MR_du_functor_orig_arity;
+ // XXX MAKE_FIELD_UNSIGNED
MR_uint_least16_t MR_du_functor_arg_type_contains_var;
MR_Sectag_Locn MR_du_functor_sectag_locn;
MR_uint_least8_t MR_du_functor_primary;
MR_int_least32_t MR_du_functor_secondary; // -1 = no sectag
- MR_int_least32_t MR_du_functor_ordinal; // XXX make unsigned?
+ // XXX MAKE_FIELD_UNSIGNED
+ MR_int_least32_t MR_du_functor_ordinal;
+ // XXX MAKE_FIELD_UNSIGNED
const MR_PseudoTypeInfo *MR_du_functor_arg_types;
const MR_ConstString *MR_du_functor_arg_names;
const MR_DuArgLocn *MR_du_functor_arg_locns;
@@ -1015,7 +1018,7 @@ typedef const MR_DuFunctorDesc *MR_DuFunctorDescPtr;
typedef struct {
MR_ConstString MR_enum_functor_name;
- MR_int_least32_t MR_enum_functor_ordinal; // XXX make unsigned?
+ MR_int_least32_t MR_enum_functor_ordinal; // XXX MAKE_FIELD_UNSIGNED
} MR_EnumFunctorDesc;
typedef const MR_EnumFunctorDesc *MR_EnumFunctorDescPtr;
@@ -1024,7 +1027,8 @@ typedef const MR_EnumFunctorDesc *MR_EnumFunctorDescPtr;
typedef struct {
MR_ConstString MR_foreign_enum_functor_name;
- MR_int_least32_t MR_foreign_enum_functor_ordinal; // XXX make unsigned?
+ MR_int_least32_t MR_foreign_enum_functor_ordinal;
+ // XXX MAKE_FIELD_UNSIGNED
MR_Integer MR_foreign_enum_functor_value;
} MR_ForeignEnumFunctorDesc;
@@ -1200,6 +1204,7 @@ typedef union {
// Map from ordinal (declaration order) functor numbers to lexicographic
// functor numbers which can be passed to construct.construct.
+// XXX MAKE_FIELD_UNSIGNED (also change to 16 or 32-bits later)
typedef const MR_Integer *MR_FunctorNumberMap;
@@ -1214,8 +1219,8 @@ typedef const MR_Integer *MR_FunctorNumberMap;
// files listed at the top of this file, as well as in the macros below.
struct MR_TypeCtorInfo_Struct {
- MR_Integer MR_type_ctor_arity; // XXX make unsigned?
- MR_int_least8_t MR_type_ctor_version; // XXX make unsigned?
+ MR_Integer MR_type_ctor_arity; // XXX MAKE_FIELD_UNSIGNED
+ MR_uint_least8_t MR_type_ctor_version;
MR_int_least8_t MR_type_ctor_num_ptags; // negative if not DU
MR_TypeCtorRepInt MR_type_ctor_rep_CAST_ME;
MR_ProcAddr MR_type_ctor_unify_pred;
@@ -1225,6 +1230,7 @@ struct MR_TypeCtorInfo_Struct {
MR_TypeFunctors MR_type_ctor_functors;
MR_TypeLayout MR_type_ctor_layout;
MR_int_least32_t MR_type_ctor_num_functors; // negative if no symbols
+ // XXX MAKE_FIELD_UNSIGNED
MR_uint_least16_t MR_type_ctor_flags;
MR_FunctorNumberMap MR_type_ctor_functor_number_map;
More information about the reviews
mailing list