[m-rev.] diff: add --seperate-assemblies option

Peter Ross peter.ross at miscrit.be
Tue Aug 14 23:33:19 AEST 2001


Hi,

I will check this in once I have verified it doesn't stuff up building
of the library.

===================================================================


Estimated hours taken: 3
Branches: main

Add the option --seperate-assemblies which places sub-modules into
seperate assemblies on the IL backend.

This is needed because if you wish to insert a strongly named assembly
which contains sub-modules into the GAC then you need to have a .hash
entry for every sub-module.  This is not trivial to obtain as for nested
sub-modules we haven't even generated the sub-module yet so obtaining
the hash is distinctly non trivial.

compiler/options.m:
    Add the --seperate-assemblies option.

compiler/ilasm.m:
    Output the correct assembly name.

compiler/mlds_to_il.m:
    Output the correct .assembly declarations.

compiler/modules.m:
    Fix a bug where we were outputing module names with the wrong
    seperator.

Index: compiler/ilasm.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ilasm.m,v
retrieving revision 1.19
diff -u -r1.19 ilasm.m
--- compiler/ilasm.m	13 Aug 2001 01:39:31 -0000	1.19
+++ compiler/ilasm.m	14 Aug 2001 13:23:30 -0000
@@ -1428,17 +1428,26 @@
 	ilasm_info::out, io__state::di, io__state::uo) is det.
 output_structured_name(structured_name(Asm, DottedName, NestedClasses),
 		Info, Info) -->
+	globals__io_lookup_bool_option(separate_assemblies, SeparateAssemblies),
 	( { Asm = assembly(Assembly) },
 		maybe_output_quoted_assembly_name(Assembly, Info)
 	; { Asm = module(Module, Assembly) },
-		(
-			{ Info ^ current_assembly \= "" },
-			{ string__prefix(Module, Info ^ current_assembly) }
-		->
-			{ quote_id(Module ++ ".dll", QuotedModuleName) },
-			io__format("[.module %s]", [s(QuotedModuleName)])
-		;
-			maybe_output_quoted_assembly_name(Assembly, Info)
+		( { SeparateAssemblies = yes },
+			maybe_output_quoted_assembly_name(Module, Info)
+		; { SeparateAssemblies = no },
+			(
+				{ Info ^ current_assembly \= "" },
+				{ string__prefix(Module,
+						Info ^ current_assembly) }
+			->
+				{ quote_id(Module ++ ".dll",
+						QuotedModuleName) },
+				io__format("[.module %s]",
+						[s(QuotedModuleName)])
+			;
+				maybe_output_quoted_assembly_name(Assembly,
+						Info)
+			)
 		)
 	),
 	output_dotted_name(DottedName),
Index: compiler/mlds_to_il.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.72
diff -u -r1.72 mlds_to_il.m
--- compiler/mlds_to_il.m	14 Aug 2001 10:18:35 -0000	1.72
+++ compiler/mlds_to_il.m	14 Aug 2001 13:23:32 -0000
@@ -206,7 +206,9 @@
 	globals__io_lookup_bool_option(il_byref_tailcalls, ByRefTailCalls,
 			IO3, IO4),
 	globals__io_lookup_bool_option(sign_assembly, SignAssembly,
-			IO4, IO),
+			IO4, IO5),
+	globals__io_lookup_bool_option(separate_assemblies, SeparateAssemblies,
+			IO5, IO),
 
 	IlInfo0 = il_info_init(ModuleName, AssemblyName, Imports,
 			ILDataRep, DebugIlAsm, VerifiableCode, ByRefTailCalls),
@@ -232,11 +234,15 @@
 	;
 			% If the package name is qualified then the
 			% we have a sub-module which shouldn't be placed
-			% in its own assembly.
-		( PackageName = unqualified(_) ->
-			ThisAssembly = [assembly(AssemblyName)]
-		;
+			% in its own assembly provided we have
+			% --no-separate-assemblies
+		(
+			PackageName = qualified(_, _),
+			SeparateAssemblies = no
+		->
 			ThisAssembly = []
+		;
+			ThisAssembly = [assembly(AssemblyName)]
 		),
 
 			% XXX at a later date we should make foreign
@@ -250,7 +256,7 @@
 			ForeignCodeAssemblerRefs),
 		AssemblerRefs = list__append(ForeignCodeAssemblerRefs, Imports)
 	),
-	generate_extern_assembly(AssemblyName, SignAssembly,
+	generate_extern_assembly(AssemblyName, SignAssembly, SeparateAssemblies,
 			AssemblerRefs, ExternAssemblies),
 	Namespace = [namespace(NamespaceName, ILDecls)],
 	ILAsm = list__condense([ThisAssembly, ExternAssemblies, Namespace]).
@@ -3560,11 +3566,11 @@
 %-----------------------------------------------------------------------------
 
 	% Generate extern decls for any assembly we reference.
-:- pred mlds_to_il__generate_extern_assembly(string::in, bool::in,
+:- pred mlds_to_il__generate_extern_assembly(string::in, bool::in, bool::in,
 		mlds__imports::in, list(decl)::out) is det.
 
 mlds_to_il__generate_extern_assembly(CurrentAssembly, SignAssembly,
-		Imports, AllDecls) :-
+		SeparateAssemblies, Imports, AllDecls) :-
 	( SignAssembly = yes,
 		AsmDecls = mercury_strong_name_assembly_decls
 	; SignAssembly = no,
@@ -3576,13 +3582,19 @@
 			Assembly \= "mercury",
 			Decl = [extern_assembly(Assembly, AsmDecls)]
 		; AsmName = module(ModuleName, Assembly),
-			( Assembly = CurrentAssembly ->
-				ModuleStr = ModuleName ++ ".dll",
-				Decl = [file(ModuleStr),
-					extern_module(ModuleStr)]
-			;
-				Assembly \= "mercury",
-				Decl = [extern_assembly(Assembly, AsmDecls)]
+			( SeparateAssemblies = no,
+				( Assembly = CurrentAssembly ->
+					ModuleStr = ModuleName ++ ".dll",
+					Decl = [file(ModuleStr),
+						extern_module(ModuleStr)]
+				;
+					Assembly \= "mercury",
+					Decl = [extern_assembly(Assembly,
+							AsmDecls)]
+				)
+			; SeparateAssemblies = yes,
+				Decl = [extern_assembly(ModuleName,
+						AsmDecls)]
 			)
 		)
 	),
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.191
diff -u -r1.191 modules.m
--- compiler/modules.m	12 Aug 2001 13:29:12 -0000	1.191
+++ compiler/modules.m	14 Aug 2001 13:23:34 -0000
@@ -2094,7 +2094,7 @@
 			% Also add the variable ILASM_KEYFLAG-<module> which
 			% is used to build the command line for ilasm.
 		( { Target = il, SignAssembly = yes } ->
-			{ prog_out__sym_name_to_string(ModuleName,
+			{ prog_out__sym_name_to_string(ModuleName, ".",
 					ModuleNameString) },
 			module_name_to_file_name(ModuleName, ".il",
 					no, IlFileName),
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.335
diff -u -r1.335 options.m
--- compiler/options.m	12 Aug 2001 13:29:14 -0000	1.335
+++ compiler/options.m	14 Aug 2001 13:23:36 -0000
@@ -122,6 +122,7 @@
 		;	dump_rl
 		;	dump_rl_bytecode
 		;	sign_assembly
+		;	separate_assemblies
 	% Language semantics options
 		;	reorder_conj
 		;	reorder_disj
@@ -578,6 +579,7 @@
 	dump_rl			-	bool(no),
 	dump_rl_bytecode	-	bool(no),
 	sign_assembly		-	bool(no),
+	separate_assemblies	-	bool(no),
 	generate_schemas	-	bool(no)
 ]).
 option_defaults_2(language_semantics_option, [
@@ -1021,6 +1023,7 @@
 long_option("dump-rl",			dump_rl).
 long_option("dump-rl-bytecode",		dump_rl_bytecode).
 long_option("sign-assembly",		sign_assembly).
+long_option("separate-assemblies",	separate_assemblies).
 long_option("generate-schemas",		generate_schemas).
 
 % language semantics options
@@ -1953,7 +1956,11 @@
 		"\tTo use assemblies created with this command all the Mercury",
 		"\tmodules must be compiled with this option enabled.",
 		"\tThis option is specific to the IL backend, and is likely",
-		"\tto be deprecated at a later date."
+		"\tto be deprecated at a later date.",
+
+		"--separate-assemblies",
+		"\tPlace sub-modules in separate assemblies.",
+		"\tThis option is specific to the IL backend."
 	]).
 
 :- pred options_help_semantics(io__state::di, io__state::uo) is det.
@@ -2122,7 +2129,7 @@
 XXX The following options are not documented,
 because they are currently not useful.
 The idea was for you to be able to use --profile-calls
-and --profile-time seperately, but that doesn't work
+and --profile-time separately, but that doesn't work
 because compiling with --profile-time instead of
 --profile-calls results in different code addresses, 
 so you can't combine the data from versions of

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