[m-dev.] trivial diff: minor improvement to MLDS backend

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Nov 10 15:12:48 AEDT 1999


Estimated hours taken: 0.25

Improve abstraction in the MLDS back-end slightly,
by using an equivalence type `mlds__arguments' for the
`assoc_list(mlds__entity_name, mlds__type)' type
used for function argument types.

compiler/mlds.m:
	Add the equivalence type.

compiler/ml_code_gen.m:
compiler/ml_elim_nested.m:
compiler/mlds_to_c.m:
compiler/mlds.m:
	Use the new equivalence type rather than hard-coding its value.

Workspace: /d-drive/home/hg/fjh/mercury
Index: compiler/ml_code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_gen.m,v
retrieving revision 1.14
diff -u -d -r1.14 ml_code_gen.m
--- compiler/ml_code_gen.m	1999/11/09 01:36:13	1.14
+++ compiler/ml_code_gen.m	1999/11/10 04:11:45
@@ -593,7 +593,7 @@
 :- import_module globals, options.
 
 :- import_module string, int, bool, varset, term.
-:- import_module list, assoc_list, map, set, stack.
+:- import_module list, map, set, stack.
 :- import_module require, std_util.
 
 %-----------------------------------------------------------------------------%
@@ -3454,7 +3454,7 @@
 	% and modes, generate the MLDS argument list declaration.
 	%
 :- pred ml_gen_arg_decls(module_info, list(prog_var), list(prog_type),
-		list(mode), prog_varset, assoc_list(entity_name, mlds__type)).
+		list(mode), prog_varset, mlds__arguments).
 :- mode ml_gen_arg_decls(in, in, in, in, in, out) is det.
 
 ml_gen_arg_decls(ModuleInfo, HeadVars, HeadTypes, HeadModes, VarSet,
Index: compiler/ml_elim_nested.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_elim_nested.m,v
retrieving revision 1.1
diff -u -d -r1.1 ml_elim_nested.m
--- compiler/ml_elim_nested.m	1999/11/08 22:27:52	1.1
+++ compiler/ml_elim_nested.m	1999/11/10 03:46:11
@@ -129,7 +129,7 @@
 %-----------------------------------------------------------------------------%
 
 :- implementation.
-:- import_module int, list, assoc_list, std_util, string, require.
+:- import_module int, list, std_util, string, require.
 % the following imports are needed for mangling pred names
 :- import_module hlds_pred, prog_data, prog_out.
 
@@ -223,7 +223,7 @@
 	% Add any arguments which are used in nested functions
 	% to the local_vars field in the elim_info.
 	%
-:- pred ml_maybe_add_args(assoc_list(mlds__entity_name, mlds__type), mlds__statement,
+:- pred ml_maybe_add_args(mlds__arguments, mlds__statement,
 		mlds_module_name, mlds__context, elim_info, elim_info).
 :- mode ml_maybe_add_args(in, in, in, in, in, out) is det.
 
@@ -244,7 +244,7 @@
 	% Generate code to copy any arguments which are used in nested functions
 	% to the environment struct.
 	%
-:- pred ml_maybe_copy_args(assoc_list(mlds__entity_name, mlds__type), mlds__statement,
+:- pred ml_maybe_copy_args(mlds__arguments, mlds__statement,
 		mlds_module_name, mlds__context, mlds__defns, mlds__statements).
 :- mode ml_maybe_copy_args(in, in, in, in, out, out) is det.
 
Index: compiler/mlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds.m,v
retrieving revision 1.11
diff -u -d -r1.11 mlds.m
--- compiler/mlds.m	1999/11/08 22:27:52	1.11
+++ compiler/mlds.m	1999/11/10 03:43:03
@@ -399,9 +399,11 @@
 
 :- type mlds__func_params
 	---> mlds__func_params(
-		assoc_list(entity_name, mlds__type), % arguments (inputs)
-		list(mlds__type)		% return values (outputs)
+		mlds__arguments,	% names and types of arguments (inputs)
+		list(mlds__type)	% types of return values (outputs)
 	).
+
+:- type mlds__arguments == assoc_list(mlds__entity_name, mlds__type).
 
 	% An mlds__func_signature is like an mlds__func_params
 	% except that it only includes the function's type, not
Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.10
diff -u -d -r1.10 mlds_to_c.m
--- compiler/mlds_to_c.m	1999/11/08 22:27:52	1.10
+++ compiler/mlds_to_c.m	1999/11/10 03:54:29
@@ -28,7 +28,7 @@
 :- import_module hlds_pred. % for `pred_proc_id'.
 :- import_module prog_data, prog_out.
 
-:- import_module bool, int, string, list, assoc_list, term, std_util, require.
+:- import_module bool, int, string, list, term, std_util, require.
 
 %-----------------------------------------------------------------------------%
 
@@ -456,8 +456,8 @@
 	mlds_output_fully_qualified_name(Name, mlds_output_name),
 	mlds_output_params(Indent, Name, Parameters).
 
-:- pred mlds_output_params(int, qualified_entity_name,
-		assoc_list(entity_name, mlds__type), io__state, io__state).
+:- pred mlds_output_params(int, qualified_entity_name, mlds__arguments,
+		io__state, io__state).
 :- mode mlds_output_params(in, in, in, di, uo) is det.
 
 mlds_output_params(Indent, FuncName, Parameters) -->

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list