[m-dev.] diff: MLDS back-end: fix generation of #includes

Fergus Henderson fjh at cs.mu.OZ.AU
Sat May 13 23:55:43 AEST 2000


With this bug fix, the only manual intervention needed to bootstrap
the MLDS back-end is setting LIBRARY_INTERMODULE=no.

--------------------

Estimated hours taken: 2

Fix the generation of `#include' directives for the MLDS back-end.

compiler/hlds_module.m:
	Add a new field `indirectly_imported_module_specifiers'
	to the module_info.

compiler/make_hlds.m:
	Add code to set up the appropriate values in the new field.

compiler/ml_code_gen.m:
	Include the indirectly imported modules in the MLDS imports list.
	This is needed because the MLDS code can refer to type_ctor_infos
	etc. from the indirectly imported modules.

runtime/mercury.h
	Delete some hacks that were work-arounds for this bug.

Workspace: /home/pgrad/fjh/ws/hg
Index: compiler/hlds_module.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_module.m,v
retrieving revision 1.54
diff -u -d -r1.54 hlds_module.m
--- compiler/hlds_module.m	2000/05/13 04:41:32	1.54
+++ compiler/hlds_module.m	2000/05/13 04:59:59
@@ -216,6 +216,14 @@
 		set(module_specifier)).
 :- mode module_info_get_imported_module_specifiers(in, out) is det.
 
+:- pred module_add_indirectly_imported_module_specifiers(
+		list(module_specifier), module_info, module_info).
+:- mode module_add_indirectly_imported_module_specifiers(in, in, out) is det.
+
+:- pred module_info_get_indirectly_imported_module_specifiers(module_info,
+		set(module_specifier)).
+:- mode module_info_get_indirectly_imported_module_specifiers(in, out) is det.
+
 %-----------------------------------------------------------------------------%
 
 :- pred module_info_name(module_info, module_name).
@@ -470,8 +478,12 @@
 					% number of the structure types defined
 					% so far for model_non pragma C codes
 		imported_module_specifiers ::	set(module_specifier),
-					% All the imported module specifiers
-					% (used during type checking).
+					% All the directly imported module
+					% specifiers (used during type
+					% checking, and by the MLDS back-end)
+		indirectly_imported_module_specifiers :: set(module_specifier),
+					% All the indirectly imported modules
+					% (used by the MLDS back-end)
 		do_aditi_compilation ::		do_aditi_compilation,
 					% are there any local Aditi predicates
 					% for which Aditi-RL must be produced.
@@ -508,13 +520,14 @@
 	mercury_public_builtin_module(PublicBuiltin),
 	mercury_private_builtin_module(PrivateBuiltin),
 	set__list_to_set([PublicBuiltin, PrivateBuiltin], ImportedModules),
+	set__init(IndirectlyImportedModules),
 
 	assertion_table_init(AssertionTable),
 	map__init(FieldNameTable),
 
 	ModuleSubInfo = module_sub(Name, Globals, [], [], no, 0, 0, [], 
 		[], StratPreds, UnusedArgInfo, 0, ImportedModules,
-		no_aditi_compilation, TypeSpecInfo),
+		IndirectlyImportedModules, no_aditi_compilation, TypeSpecInfo),
 	ModuleInfo = module(ModuleSubInfo, PredicateTable, Requests,
 		UnifyPredMap, QualifierInfo, Types, Insts, Modes, Ctors,
 		ClassTable, SuperClassTable, InstanceTable, AssertionTable,
@@ -581,6 +594,8 @@
 	MI^sub_info^model_non_pragma_types_so_far).
 module_info_get_imported_module_specifiers(MI,
 	MI^sub_info^imported_module_specifiers).
+module_info_get_indirectly_imported_module_specifiers(MI,
+	MI^sub_info^indirectly_imported_module_specifiers).
 module_info_type_spec_info(MI, MI^sub_info^type_spec_info).
 module_info_get_do_aditi_compilation(MI,
 	MI^sub_info^do_aditi_compilation).
@@ -613,9 +628,11 @@
 module_info_set_model_non_pragma_count(MI, NewVal,
 	MI^sub_info^model_non_pragma_types_so_far := NewVal).
 module_add_imported_module_specifiers(ModuleSpecifiers, MI,
-	MI^sub_info^imported_module_specifiers :=
-		set__insert_list(MI^sub_info^imported_module_specifiers,
-			ModuleSpecifiers)).
+	MI^sub_info^imported_module_specifiers := set__insert_list(
+		MI^sub_info^imported_module_specifiers, ModuleSpecifiers)).
+module_add_indirectly_imported_module_specifiers(Modules, MI,
+	MI^sub_info^indirectly_imported_module_specifiers := set__insert_list(
+		MI^sub_info^indirectly_imported_module_specifiers, Modules)).
 module_info_set_type_spec_info(MI, NewVal,
 	MI^sub_info^type_spec_info := NewVal).
 module_info_set_do_aditi_compilation(MI,
Index: compiler/make_hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make_hlds.m,v
retrieving revision 1.334
diff -u -d -r1.334 make_hlds.m
--- compiler/make_hlds.m	2000/04/22 07:11:45	1.334
+++ compiler/make_hlds.m	2000/05/13 04:46:29
@@ -235,7 +235,8 @@
 			{ module_add_imported_module_specifiers(Specifiers,
 				Module0, Module) }
 		;
-			{ Module = Module0 }
+			{ module_add_indirectly_imported_module_specifiers(
+				Specifiers, Module0, Module) }
 		)
 	; { ModuleDefn = use(module(Specifiers)) } ->
 		{ Status = Status0 },
@@ -244,7 +245,8 @@
 			{ module_add_imported_module_specifiers(Specifiers,
 				Module0, Module) }
 		;
-			{ Module = Module0 }
+			{ module_add_indirectly_imported_module_specifiers(
+				Specifiers, Module0, Module) }
 		)
 	; { ModuleDefn = include_module(_) } ->
 		{ Status = Status0 },
Index: compiler/ml_code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_gen.m,v
retrieving revision 1.40
diff -u -d -r1.40 ml_code_gen.m
--- compiler/ml_code_gen.m	2000/05/10 07:12:49	1.40
+++ compiler/ml_code_gen.m	2000/05/13 04:38:56
@@ -628,7 +628,6 @@
 % TODO:
 %	- `pragma export'
 %	- complicated `pragma c_code'
-%	- typeclass_infos and class method calls
 %	- high level data representation
 %	  (i.e. generate MLDS type declarations for user-defined types)
 %	...
@@ -702,9 +701,12 @@
 :- mode ml_gen_imports(in, out) is det.
 
 ml_gen_imports(ModuleInfo, MLDS_ImportList) :-
-	module_info_get_imported_module_specifiers(ModuleInfo, ImportSet),
-	set__to_sorted_list(ImportSet, ImportList),
-	MLDS_ImportList = list__map(mercury_module_name_to_mlds, ImportList).
+	module_info_get_imported_module_specifiers(ModuleInfo, DirectImports),
+	module_info_get_indirectly_imported_module_specifiers(ModuleInfo,
+		IndirectImports),
+	AllImports = DirectImports `set__union` IndirectImports,
+	MLDS_ImportList = list__map(mercury_module_name_to_mlds,
+		set__to_sorted_list(AllImports)).
 
 :- pred ml_gen_defns(module_info, mlds__defns, io__state, io__state).
 :- mode ml_gen_defns(in, out, di, uo) is det.

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