[m-dev.] trivial diff: MLDS back-end: minor source cleanup

Fergus Henderson fjh at cs.mu.OZ.AU
Thu May 18 02:01:25 AEST 2000


Estimated hours taken: 0.5

compiler/ml_code_util.m:
compiler/ml_call_gen.m:
compiler/ml_unify_gen.m:
	Eliminate some code duplication, by using the existing
	subroutines ml_gen_assign and ml_qualify_var in a number
	of places where there code was duplicated.

Workspace: /home/pgrad/fjh/ws/hg
Index: compiler/ml_call_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_call_gen.m,v
retrieving revision 1.9
diff -u -d -r1.9 ml_call_gen.m
--- compiler/ml_call_gen.m	2000/05/11 21:10:30	1.9
+++ compiler/ml_call_gen.m	2000/05/17 15:50:38
@@ -588,9 +588,8 @@
 			% and the caller type is the destination type.
 			{ ml_gen_box_or_unbox_rval(CalleeType, CallerType,
 				lval(ArgLval), ConvertedArgRval) },
-			{ AssignStmt = assign(VarLval, ConvertedArgRval) },
-			{ AssignStatement = mlds__statement(atomic(AssignStmt),
-				mlds__make_context(Context)) },
+			{ AssignStatement = ml_gen_assign(VarLval,
+				ConvertedArgRval, Context) },
 			{ ConvStatements = [AssignStatement] }
 		)
 	).
Index: compiler/ml_code_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_util.m,v
retrieving revision 1.11
diff -u -d -r1.11 ml_code_util.m
--- compiler/ml_code_util.m	2000/05/11 21:10:30	1.11
+++ compiler/ml_code_util.m	2000/05/17 15:47:00
@@ -964,10 +964,8 @@
 		=(MLDSGenInfo),
 		{ ml_gen_info_get_output_vars(MLDSGenInfo, OutputVars) },
 		{ ml_gen_info_get_varset(MLDSGenInfo, VarSet) },
-		{ ml_gen_info_get_module_name(MLDSGenInfo, ModuleName) },
-		{ MLDS_Module = mercury_module_name_to_mlds(ModuleName) },
 		{ VarName = ml_gen_var_name(VarSet, Var) },
-		{ VarLval = var(qual(MLDS_Module, VarName)) },
+		ml_qualify_var(VarName, VarLval),
 		{ MLDS_Type = mercury_type_to_mlds_type(Type) },
 		% output variables are passed by reference...
 		{ list__member(Var, OutputVars) ->
@@ -1107,10 +1105,7 @@
 	% the success or failure of model_semi procedures.)
 	%
 ml_success_lval(SucceededLval) -->
-	=(MLDSGenInfo),
-	{ ml_gen_info_get_module_name(MLDSGenInfo, ModuleName) },
-	{ MLDS_Module = mercury_module_name_to_mlds(ModuleName) },
-	{ SucceededLval = var(qual(MLDS_Module, "succeeded")) }.
+	ml_qualify_var("succeeded", SucceededLval).
 
 	% Return an rval which will test the value of the `succeeded' flag.
 	% (`succeeded' is a boolean variable used to record
@@ -1125,10 +1120,7 @@
 	%
 ml_gen_set_success(Value, Context, MLDS_Statement) -->
 	ml_success_lval(Succeeded),
-	{ Assign = assign(Succeeded, Value) },
-	{ MLDS_Stmt = atomic(Assign) },
-	{ MLDS_Statement = mlds__statement(MLDS_Stmt,
-		mlds__make_context(Context)) }.
+	{ MLDS_Statement = ml_gen_assign(Succeeded, Value, Context) }.
 
 %-----------------------------------------------------------------------------%
 
@@ -1143,10 +1135,7 @@
 		mlds__native_bool_type, Context).
 
 ml_cond_var_lval(CondVar, CondVarLval) -->
-	=(MLDSGenInfo),
-	{ ml_gen_info_get_module_name(MLDSGenInfo, ModuleName) },
-	{ MLDS_Module = mercury_module_name_to_mlds(ModuleName) },
-	{ CondVarLval = var(qual(MLDS_Module, ml_gen_cond_var_name(CondVar))) }.
+	ml_qualify_var(ml_gen_cond_var_name(CondVar), CondVarLval).
 
 ml_gen_test_cond_var(CondVar, CondVarRval) -->
 	ml_cond_var_lval(CondVar, CondVarLval),
@@ -1154,10 +1143,7 @@
 	
 ml_gen_set_cond_var(CondVar, Value, Context, MLDS_Statement) -->
 	ml_cond_var_lval(CondVar, CondVarLval),
-	{ Assign = assign(CondVarLval, Value) },
-	{ MLDS_Stmt = atomic(Assign) },
-	{ MLDS_Statement = mlds__statement(MLDS_Stmt,
-		mlds__make_context(Context)) }.
+	{ MLDS_Statement = ml_gen_assign(CondVarLval, Value, Context) }.
 
 %-----------------------------------------------------------------------------%
 
@@ -1173,12 +1159,9 @@
 	% is not used.)
 	%
 ml_initial_cont(Cont) -->
-	=(MLDSGenInfo),
-	{ ml_gen_info_get_module_name(MLDSGenInfo, ModuleName) },
-	{ MLDS_Module = mercury_module_name_to_mlds(ModuleName) },
-	{ ContRval = lval(var(qual(MLDS_Module, "cont"))) },
-	{ ContEnvRval = lval(var(qual(MLDS_Module, "cont_env_ptr"))) },
-	{ Cont = success_cont(ContRval, ContEnvRval) }.
+	ml_qualify_var("cont", ContLval),
+	ml_qualify_var("cont_env_ptr", ContEnvLval),
+	{ Cont = success_cont(lval(ContLval), lval(ContEnvLval)) }.
 
 	% Generate code to call the current success continuation.
 	% This is used for generating success when in a model_non context.
@@ -1218,11 +1201,8 @@
 	% Note that we generate this as a dangling reference.
 	% The ml_elim_nested pass will insert the declaration
 	% of the env_ptr variable.
-ml_get_env_ptr(EnvPtrRval) -->
-	=(MLDSGenInfo),
-	{ ml_gen_info_get_module_name(MLDSGenInfo, ModuleName) },
-	{ MLDS_Module = mercury_module_name_to_mlds(ModuleName) },
-	{ EnvPtrRval = lval(var(qual(MLDS_Module, "env_ptr"))) }.
+ml_get_env_ptr(lval(EnvPtrLval)) -->
+	ml_qualify_var("env_ptr", EnvPtrLval).
 
 	% Return an rval for a pointer to the current environment
 	% (the set of local variables in the containing procedure).
Index: compiler/ml_unify_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_unify_gen.m,v
retrieving revision 1.8
diff -u -d -r1.8 ml_unify_gen.m
--- compiler/ml_unify_gen.m	2000/05/15 19:38:54	1.8
+++ compiler/ml_unify_gen.m	2000/05/17 15:56:48
@@ -578,13 +578,13 @@
 	%
 	{ ClosureName = "closure" },
 	{ ClosureArgName = "closure_arg" },
+	{ MLDS_Context = mlds__make_context(Context) },
 	{ ClosureDecl = ml_gen_mlds_var_decl(var(ClosureName),
 		mlds__generic_env_ptr_type, MLDS_Context) },
 	ml_qualify_var(ClosureName, ClosureLval),
 	ml_qualify_var(ClosureArgName, ClosureArgLval),
-	{ AssignClosure = assign(ClosureLval, lval(ClosureArgLval)) },
-	{ MLDS_Context = mlds__make_context(Context) },
-	{ InitClosure = mlds__statement(atomic(AssignClosure), MLDS_Context) },
+	{ InitClosure = ml_gen_assign(ClosureLval, lval(ClosureArgLval),
+		Context) },
 
 	%
 	% if the wrapper function is model_non, then

-- 
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