[m-rev.] trivial diff: rename (and redefine) type ilds.param/0
Julien Fischer
juliensf at csse.unimelb.edu.au
Fri Aug 31 16:35:22 AEST 2007
Estimated hours taken: 0.2
Branches: main
compiler/ilds.m:
Rename the type `param'/0 to `il_method_param'/0 and redefine
it as a d.u. rather than an equivalence for a pair.
compiler/ilasm.m:
compiler/mlds_to_il.m:
Conform to the above change.
Add a utility function.
Julien.
Index: ilasm.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ilasm.m,v
retrieving revision 1.50
diff -u -r1.50 ilasm.m
--- ilasm.m 19 Jan 2007 07:04:15 -0000 1.50
+++ ilasm.m 31 Aug 2007 06:31:25 -0000
@@ -707,7 +707,7 @@
;
ArgTypes = [_ | _],
io.write_string("(\n\t\t", !IO),
- ilasm.write_list(ArgTypes, ",\n\t\t", output_param, !Info, !IO),
+ ilasm.write_list(ArgTypes, ",\n\t\t", output_method_param, !Info, !IO),
io.write_string("\n\t)", !IO)
).
@@ -741,15 +741,20 @@
io.write_string(" ", !IO),
output_id(Id, !IO).
-:- pred output_param(pair(il_type, maybe(ilds.id))::in,
- ilasm_info::in, ilasm_info::out, io::di, io::uo) is det.
+:- pred output_method_param(il_method_param::in,
+ ilasm_info::in, ilasm_info::out,
+ io::di, io::uo) is det.
-output_param(Type - no, !Info, !IO) :-
- output_type(Type, !Info, !IO).
-output_param(Type - yes(Id), !Info, !IO) :-
+output_method_param(MethodParam, !Info, !IO) :-
+ MethodParam = il_method_param(Type, MaybeId),
output_type(Type, !Info, !IO),
- io.write_string(" ", !IO),
- output_id(Id, !IO).
+ (
+ MaybeId = no
+ ;
+ MaybeId = yes(Id),
+ io.write_string(" ", !IO),
+ output_id(Id, !IO)
+ ).
:- pred output_type(il_type::in, ilasm_info::in, ilasm_info::out,
io::di, io::uo) is det.
Index: ilds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ilds.m,v
retrieving revision 1.27
diff -u -r1.27 ilds.m
--- ilds.m 31 Aug 2007 05:59:22 -0000 1.27
+++ ilds.m 31 Aug 2007 06:31:25 -0000
@@ -29,7 +29,6 @@
:- import_module bool.
:- import_module list.
:- import_module maybe.
-:- import_module pair.
%-----------------------------------------------------------------------------%
@@ -39,18 +38,21 @@
% A method parameter.
%
-:- type param == pair(
- il_type, % Type of the parameter.
- maybe(ilds.id) % Name of the parameter (if any).
- ).
-
+:- type il_method_param
+ ---> il_method_param(
+ ilmp_type :: il_type,
+ % The type of the parameter.
+ ilmp_maybe_id :: maybe(ilds.id)
+ % The name of the parameter (if any).
+ ).
+
% A method signature.
%
:- type signature
---> signature(
call_conv, % calling convention
ret_type, % return type
- list(param) % parameters
+ list(il_method_param) % parameters
).
% A method reference.
Index: mlds_to_il.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.191
diff -u -r1.191 mlds_to_il.m
--- mlds_to_il.m 21 Aug 2007 17:40:33 -0000 1.191
+++ mlds_to_il.m 31 Aug 2007 06:31:25 -0000
@@ -1137,8 +1137,8 @@
ClassName = mlds_module_name_to_class_name(NewModuleName),
ILSignature = signature(_, ILRetType, ILParams),
+ TypeParams = il_method_params_to_il_types(ILParams),
- assoc_list.keys(ILParams, TypeParams),
list.map_foldl(
(pred(_::in, Instr::out, Num::in, Num+1::out) is det :-
Instr = ldarg(index(Num))
@@ -1743,9 +1743,10 @@
ReturnParam, MemberName, TypeParams))]
;
load(Function, FunctionLoadInstrs, !Info),
- list.length(TypeParams, Length),
- list.duplicate(Length, no, NoList),
- assoc_list.from_corresponding_lists(TypeParams, NoList, ParamsList),
+ MakeMethodParam = (func(MethodType) = MethodParam :-
+ MethodParam = il_method_param(MethodType, no)
+ ),
+ ParamsList = list.map(MakeMethodParam, TypeParams),
Instrs0 = [calli(signature(call_conv(no, default),
ReturnParam, ParamsList))]
),
@@ -1981,7 +1982,7 @@
sorry(this_file, "multiple return values")
),
MethodName = !.Info ^ csharp_method_name,
- assoc_list.keys(Params, TypeParams),
+ TypeParams = il_method_params_to_il_types(Params),
list.map_foldl((pred(_::in, Instr::out,
Num::in, Num + 1::out) is det :-
Instr = ldarg(index(Num))),
@@ -3083,12 +3084,13 @@
ILSignature = signature(call_conv(no, default), Param, ILInputTypes).
:- func input_param_to_ilds_type(il_data_rep, mlds_module_name, mlds_argument)
- = ilds.param.
+ = il_method_param.
-input_param_to_ilds_type(DataRep, _ModuleName, Arg) = ILType - yes(Id) :-
+input_param_to_ilds_type(DataRep, _ModuleName, Arg) = MethodParam :-
Arg = mlds_argument(EntityName, MldsType, _GCStatement),
mangle_entity_name(EntityName, Id),
- ILType = mlds_type_to_ilds_type(DataRep, MldsType).
+ ILType = mlds_type_to_ilds_type(DataRep, MldsType),
+ MethodParam = il_method_param(ILType, yes(Id)).
:- func mlds_type_to_ilds_simple_type(il_data_rep, mlds_type)
= ilds.simple_type.
@@ -4640,6 +4642,13 @@
maybe_map_fold(P, yes(T), _, !:V, !U) :-
P(T, !:V, !U).
+:- func il_method_params_to_il_types(list(il_method_param)) = list(il_type).
+
+il_method_params_to_il_types([]) = [].
+il_method_params_to_il_types([ il_method_param(Type, _) | Params]) =
+ [ Type | Types ] :-
+ Types = il_method_params_to_il_types(Params).
+
%-----------------------------------------------------------------------------%
:- func this_file = string.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list