[m-rev.] diff: add support for assembly declarations to IL

Tyson Dowd trd at cs.mu.OZ.AU
Tue Apr 10 22:40:48 AEST 2001


Hi,

This is the first of a bunch of changes I made during the March DevLab.

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


Estimated hours taken: 1
Branches: main 

compiler/ilasm.m:
compiler/mlds_to_il.m:
	Add support for assembly declarations such as version numbers,
	file hashes and public key tokens, which were previously
	unavailable in our IL backend.  We don't yet use any of these
	declarations.


Index: compiler/ilasm.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ilasm.m,v
retrieving revision 1.5
diff -u -r1.5 ilasm.m
--- compiler/ilasm.m	2001/03/16 04:17:46	1.5
+++ compiler/ilasm.m	2001/04/10 11:13:35
@@ -72,8 +72,9 @@
 
 
 		% .assembly extern
-		% declares an assembly name
-	;	extern_assembly(ilds__id)
+		% declares an assembly name, and possibly its strong
+		% name/version number.
+	;	extern_assembly(ilds__id, list(assembly_decl))
 
 		% .assembly
 		% defines an assembly
@@ -86,6 +87,11 @@
 	;	some [T] comment_thing(T)
 	;	comment(string).
 
+:- type assembly_decl 
+	--->	version(int, int, int, int)	% version number
+	;	hash(list(int8))		% hash 
+	;	public_key_token(list(int8)).	% public key token
+
 	% a method definition is just a list of body decls.
 :- type method_defn == list(method_body_decl).
 
@@ -313,11 +319,14 @@
 		[]
 	).
 
-ilasm__output_decl(extern_assembly(AsmName)) --> 
+ilasm__output_decl(extern_assembly(AsmName, AssemblyDecls)) --> 
 	io__write_string(".assembly extern "),
 	output_id(AsmName),
-	io__write_string(" { }").
+	io__write_string("{\n"),
+	io__write_list(AssemblyDecls, "\n\t", output_assembly_decl),
+	io__write_string("\n}\n").
 
+
 ilasm__output_decl(assembly(AsmName)) --> 
 	io__write_string(".assembly "),
 	output_id(AsmName),
@@ -1337,6 +1346,22 @@
 	io__write_string("bytearray("),
 	io__write_list(Bytes, " ", output_hexbyte),
 	io__write_string(")").
+
+:- pred ilasm__output_assembly_decl(assembly_decl::in, 
+	io__state::di, io__state::uo) is det.
+
+ilasm__output_assembly_decl(version(A, B, C, D)) -->
+	io__format(".ver %d:%d:%d:%d", [i(A), i(B), i(C), i(D)]).
+ilasm__output_assembly_decl(public_key_token(Token)) -->
+	io__write_string(".publickeytoken = ( "),
+	io__write_list(Token, " ", output_hexbyte),
+	io__write_string(" ) ").
+ilasm__output_assembly_decl(hash(Hash)) -->
+	io__write_string(".hash = ( "),
+	io__write_list(Hash, " ", output_hexbyte),
+	io__write_string(" ) ").
+
+
 
 :- pred output_float64(float64::in, io__state::di, io__state::uo) is det.
 output_float64(float64(Float)) -->
Index: compiler/mlds_to_il.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.15
diff -u -r1.15 mlds_to_il.m
--- compiler/mlds_to_il.m	2001/03/16 04:17:46	1.15
+++ compiler/mlds_to_il.m	2001/04/10 12:29:39
@@ -2398,7 +2398,7 @@
 	Gen = (pred(Import::in, Decl::out) is semidet :-
 		ClassName = mlds_module_name_to_class_name(Import),
 		ClassName = [TopLevel | _],
-		Decl = extern_assembly(TopLevel)
+		Decl = extern_assembly(TopLevel, [])
 	),
 	list__filter_map(Gen, Imports, Decls0),
 	list__sort_and_remove_dups(Decls0, Decls).


-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't everyone's cup of fur.
     trd at cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
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