[m-rev.] for review: further simplify compiler dependency graph

Julien Fischer juliensf at cs.mu.OZ.AU
Tue Mar 22 14:25:58 AEDT 2005


For review by anyone.

Estimated hours taken: 1
Branches: main

Break the cycle in the package dependency graph between the
hlds and backend_libs packages by moving yet more of the
contents of the foreign module into the new prog_foreign
module.  There are no changes to any code other than
moving it around.

compiler/foreign.m:
compiler/prog_foreign.m:
	Shift most of the types related to the foreign language
	interface into the latter module.

	Fix a typo in a comment at the beginning of prog_foreign.m.

	Clean up the formatting of comments in foreign.m.

compiler/hlds.m:
	Update the comment about why the transform_hlds package
	is imported here.

compiler/*.m:
	Minor changes caused by the above.

Julien.

Workspace:/home/swordfish/juliensf/ws71
Index: compiler/export.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/export.m,v
retrieving revision 1.84
diff -u -r1.84 export.m
--- compiler/export.m	21 Mar 2005 04:45:44 -0000	1.84
+++ compiler/export.m	22 Mar 2005 02:42:46 -0000
@@ -18,10 +18,10 @@

 :- interface.

-:- import_module backend_libs__foreign.
 :- import_module hlds__hlds_module.
 :- import_module mdbcomp__prim_data.
 :- import_module parse_tree__prog_data.
+:- import_module parse_tree__prog_foreign.

 :- import_module io.

Index: compiler/foreign.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/foreign.m,v
retrieving revision 1.46
diff -u -r1.46 foreign.m
--- compiler/foreign.m	22 Mar 2005 01:19:37 -0000	1.46
+++ compiler/foreign.m	22 Mar 2005 03:08:34 -0000
@@ -24,76 +24,36 @@
 :- import_module libs__globals.
 :- import_module mdbcomp__prim_data.
 :- import_module parse_tree__prog_data.
+:- import_module parse_tree__prog_foreign.

-:- import_module bool, io, list, std_util, string, term.
+:- import_module bool, io, list, std_util, string.

-:- type foreign_decl_info 		== list(foreign_decl_code).
-					% in reverse order
-:- type foreign_body_info		== list(foreign_body_code).
-					% in reverse order
-
-:- type foreign_decl_code
-	--->	foreign_decl_code(
-			foreign_language,
-			foreign_decl_is_local,
-			string,
-			prog_context
-		).
-
-:- type foreign_body_code
-	--->	foreign_body_code(
-			foreign_language,
-			string,
-			prog_context
-		).
-
-:- type foreign_export_defns == list(foreign_export).
-:- type foreign_export_decls
-	--->	foreign_export_decls(
-			foreign_decl_info,
-			list(foreign_export_decl)
-		).
-
-:- type foreign_export_decl
-	--->	foreign_export_decl(
-			foreign_language,	% language of the export
-			string,			% return type
-			string,			% function name
-			string			% argument declarations
-		).
-
-	% Some code from a `pragma foreign_code' declaration that is not
-	% associated with a given procedure.
-:- type user_foreign_code
-	--->	user_foreign_code(
-			foreign_language,	% language of this code
-			string,			% code
-			term__context		% source code location
-		).
-
-	% the code for `pragma export' is generated directly as strings
-	% by export.m.
-:- type foreign_export	==	string.
+%-----------------------------------------------------------------------------%

 	% A type which is used to determine the string representation of a
 	% mercury type for various foreign languages.
+	%
 :- type exported_type.

 	% Given a type which is not defined as a foreign type, get the
 	% exported_type representation of that type.
+	%
 :- func non_foreign_type((type)) = exported_type.

 	% Does the foreign_type_body contain a definition usable
 	% when compiling to the given target.
+	%
 :- pred have_foreign_type_for_backend(compilation_target::in,
 	foreign_type_body::in, bool::out) is det.

 	% Given an arbitary mercury type, get the exported_type representation
 	% of that type on the current backend.
+	%
 :- func to_exported_type(module_info, (type)) = exported_type.

 	% Does the implementation of the given foreign type body on
 	% the current backend use a user-defined comparison predicate.
+	%
 :- func foreign_type_body_has_user_defined_eq_comp_pred(module_info,
 	foreign_type_body) = unify_compare is semidet.

@@ -101,6 +61,7 @@
 	% a foreign_type_body, return the name of the foreign language type
 	% the identity of any user-defined unify/compare predicates, and the
 	% assertions applicable to that backend.
+	%
 :- pred foreign_type_body_to_exported_type(module_info::in,
 	foreign_type_body::in, sym_name::out, maybe(unify_compare)::out,
 	list(foreign_type_assertion)::out) is det.
@@ -108,24 +69,28 @@
 	% Given the exported_type representation for a type, determine
 	% whether or not it is a foreign type, and if yes, return the foreign
 	% type's assertions.
+	%
 :- func is_foreign_type(exported_type) = maybe(list(foreign_type_assertion)).

 	% Given a representation of a type, determine the string which
 	% corresponds to that type in the specified foreign language,
 	% for use with foreign language interfacing (`pragma export' or
 	% `pragma foreign_proc').
+	%
 :- func to_type_string(foreign_language, exported_type) = string.
 :- func to_type_string(foreign_language, module_info, (type)) = string.

 	% Filter the decls for the given foreign language.
 	% The first return value is the list of matches, the second is
 	% the list of mis-matches.
+	%
 :- pred filter_decls(foreign_language::in, foreign_decl_info::in,
 	foreign_decl_info::out, foreign_decl_info::out) is det.

 	% Filter the module imports for the given foreign language.
 	% The first return value is the list of matches, the second is
 	% the list of mis-matches.
+	%
 :- pred filter_imports(foreign_language::in,
 	foreign_import_module_info::in, foreign_import_module_info::out,
 	foreign_import_module_info::out) is det.
@@ -133,6 +98,7 @@
 	% Filter the bodys for the given foreign language.
 	% The first return value is the list of matches, the second is
 	% the list of mis-matches.
+	%
 :- pred filter_bodys(foreign_language::in, foreign_body_info::in,
 	foreign_body_info::out, foreign_body_info::out) is det.

@@ -147,6 +113,7 @@
 	% code.
 	% XXX This implementation is currently incomplete, so in future
 	% this interface may change.
+	%
 :- pred extrude_pragma_implementation(list(foreign_language)::in,
 	list(pragma_var)::in, sym_name::in, pred_or_func::in, prog_context::in,
 	module_info::in, module_info::out,
@@ -169,6 +136,7 @@

 	% The name of the #define which can be used to guard declarations with
 	% to prevent entities being declared twice.
+	%
 :- func decl_guard(sym_name) = string.

 %-----------------------------------------------------------------------------%
@@ -187,7 +155,6 @@
 :- import_module libs__globals.
 :- import_module parse_tree__error_util.
 :- import_module parse_tree__modules.
-:- import_module parse_tree__prog_foreign.
 :- import_module parse_tree__prog_out.
 :- import_module parse_tree__prog_util.
 :- import_module parse_tree__prog_type.
Index: compiler/hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds.m,v
retrieving revision 1.216
diff -u -r1.216 hlds.m
--- compiler/hlds.m	19 Jan 2005 03:10:34 -0000	1.216
+++ compiler/hlds.m	22 Mar 2005 02:12:21 -0000
@@ -51,7 +51,7 @@
 :- import_module libs.
 :- import_module check_hlds.		% needed for unify_proc__unify_proc_id,
 					% etc.
-:- import_module transform_hlds.	% needed for term_util
+:- import_module transform_hlds.	% needed for term_util, mmc_analysis

 :- end_module hlds.

Index: compiler/hlds_module.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_module.m,v
retrieving revision 1.110
diff -u -r1.110 hlds_module.m
--- compiler/hlds_module.m	10 Mar 2005 02:35:57 -0000	1.110
+++ compiler/hlds_module.m	22 Mar 2005 02:39:41 -0000
@@ -22,8 +22,6 @@
 :- interface.

 :- import_module analysis.
-:- import_module backend_libs.
-:- import_module backend_libs__foreign.
 :- import_module check_hlds__unify_proc.
 :- import_module hlds__hlds_data.
 :- import_module hlds__hlds_pred.
@@ -32,6 +30,7 @@
 :- import_module mdbcomp__prim_data.
 :- import_module parse_tree__module_qual.
 :- import_module parse_tree__prog_data.
+:- import_module parse_tree__prog_foreign.
 :- import_module recompilation.

 :- import_module relation, map, std_util, list, set, multi_map.
Index: compiler/llds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds.m,v
retrieving revision 1.309
diff -u -r1.309 llds.m
--- compiler/llds.m	19 Jan 2005 03:10:38 -0000	1.309
+++ compiler/llds.m	22 Mar 2005 02:42:21 -0000
@@ -17,7 +17,6 @@
 :- interface.

 :- import_module backend_libs__builtin_ops.
-:- import_module backend_libs__foreign.
 :- import_module backend_libs__rtti.
 :- import_module hlds__code_model.
 :- import_module hlds__hlds_goal.
@@ -27,6 +26,7 @@
 :- import_module ll_backend__layout.
 :- import_module mdbcomp__prim_data.
 :- import_module parse_tree__prog_data.
+:- import_module parse_tree__prog_foreign.

 :- import_module bool, list, assoc_list, map, set, std_util, counter, term.

Index: compiler/ml_code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_gen.m,v
retrieving revision 1.148
diff -u -r1.148 ml_code_gen.m
--- compiler/ml_code_gen.m	10 Mar 2005 02:35:58 -0000	1.148
+++ compiler/ml_code_gen.m	22 Mar 2005 02:51:26 -0000
@@ -798,6 +798,7 @@
 :- import_module ml_backend__ml_unify_gen.
 :- import_module parse_tree__error_util.
 :- import_module parse_tree__modules.
+:- import_module parse_tree__prog_foreign.
 :- import_module parse_tree__prog_util.
 :- import_module parse_tree__prog_type.

Index: compiler/mlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds.m,v
retrieving revision 1.118
diff -u -r1.118 mlds.m
--- compiler/mlds.m	21 Jan 2005 03:27:41 -0000	1.118
+++ compiler/mlds.m	22 Mar 2005 02:43:38 -0000
@@ -338,6 +338,7 @@
 :- import_module libs__globals.
 :- import_module mdbcomp__prim_data.
 :- import_module parse_tree__prog_data.
+:- import_module parse_tree__prog_foreign.

 :- import_module bool, list, std_util, map.

Index: compiler/prog_foreign.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/prog_foreign.m,v
retrieving revision 1.1
diff -u -r1.1 prog_foreign.m
--- compiler/prog_foreign.m	21 Mar 2005 04:45:50 -0000	1.1
+++ compiler/prog_foreign.m	22 Mar 2005 03:07:34 -0000
@@ -18,7 +18,7 @@
 % profiler/demangle.m, util/mdemangle.c and compiler/name_mangle.m.

 % Main authors: trd, dgj.
-% These code was originally part of the foreign module and was moved here.
+% This code was originally part of the foreign module and was moved here.

 %-----------------------------------------------------------------------------%

@@ -31,6 +31,61 @@
 :- import_module mdbcomp.prim_data.

 :- import_module bool.
+:- import_module list.
+:- import_module string.
+:- import_module term.
+
+%-----------------------------------------------------------------------------%
+
+:- type foreign_decl_info 		== list(foreign_decl_code).
+					% in reverse order
+:- type foreign_body_info		== list(foreign_body_code).
+					% in reverse order
+
+:- type foreign_decl_code
+	--->	foreign_decl_code(
+			foreign_language,
+			foreign_decl_is_local,
+			string,
+			prog_context
+		).
+
+:- type foreign_body_code
+	--->	foreign_body_code(
+			foreign_language,
+			string,
+			prog_context
+		).
+
+:- type foreign_export_defns == list(foreign_export).
+:- type foreign_export_decls
+	--->	foreign_export_decls(
+			foreign_decl_info,
+			list(foreign_export_decl)
+		).
+
+:- type foreign_export_decl
+	--->	foreign_export_decl(
+			foreign_language,	% language of the export
+			string,			% return type
+			string,			% function name
+			string			% argument declarations
+		).
+
+	% Some code from a `pragma foreign_code' declaration that is not
+	% associated with a given procedure.
+	%
+:- type user_foreign_code
+	--->	user_foreign_code(
+			foreign_language,	% language of this code
+			string,			% code
+			term__context		% source code location
+		).
+
+	% the code for `pragma export' is generated directly as strings
+	% by export.m.
+	%
+:- type foreign_export	==	string.

 %-----------------------------------------------------------------------------%

@@ -137,8 +192,6 @@

 :- import_module char.
 :- import_module int.
-:- import_module list.
-:- import_module string.

 %-----------------------------------------------------------------------------%



--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list