[m-rev.] For review: Bug fix for Java grade RTTI definitions

James Goddard goddardjames at yahoo.com
Tue Feb 24 18:16:02 AEDT 2004


Estimated hours taken: 4
Branches: main

Bug fix for Java grade RTTI definitions.

compiler/rtti_to_mlds.m:
	Re-ordered the output of definitions so that subdefinitions always
	appear before the definition which uses them.
	This is neccessary because in Java, static intializers are performed at
	runtime in textual order, and if a definition relies on another static
	variable for its constructor but said variable has not been
	initialized, then it is treated as `null' by the JVM with no warning.
	This change should not effect the other back-ends.


Index: rtti_to_mlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rtti_to_mlds.m,v
retrieving revision 1.48
diff -u -d -r1.48 rtti_to_mlds.m
--- rtti_to_mlds.m	20 Feb 2004 02:18:47 -0000	1.48
+++ rtti_to_mlds.m	23 Feb 2004 06:11:51 -0000
@@ -80,7 +80,7 @@
 			Initializer, ExtraDefns),
 		rtti_entity_name_and_init_to_defn(Name, RttiId, Initializer,
 			MLDS_Defn),
-		MLDS_Defns = [MLDS_Defn | ExtraDefns]
+		MLDS_Defns = list__append(ExtraDefns, [MLDS_Defn])
 	).
 
 :- pred rtti_name_and_init_to_defn(rtti_type_ctor::in, ctor_rtti_name::in,
@@ -501,7 +501,8 @@
 			enum_value_ordered_table),
 		FunctorInit = gen_init_rtti_name(ModuleName, RttiTypeCtor,
 			enum_name_ordered_table),
-		Defns = [ByValueDefn, ByNameDefn | EnumFunctorDescs]
+		Defns = list__append(
+			EnumFunctorDescs, [ByValueDefn, ByNameDefn])
 	;
 		TypeCtorDetails = du(_, DuFunctors, DuByPtag, DuByName),
 		DuFunctorDefnLists = list__map(
@@ -516,8 +517,8 @@
 			du_ptag_ordered_table),
 		FunctorInit = gen_init_rtti_name(ModuleName, RttiTypeCtor,
 			du_name_ordered_table),
-		Defns = [ByNameDefn |
-			list__append(ByPtagDefns, DuFunctorDefns)]
+		Defns = list__append(
+			DuFunctorDefns, [ByNameDefn | ByPtagDefns])
 	;
 		TypeCtorDetails = reserved(_, MaybeResFunctors, ResFunctors,
 			DuByPtag, MaybeResByName),
@@ -599,7 +600,7 @@
 		gen_init_maybe(ml_string_type, gen_init_string, MaybeArgName)
 	]),
 	rtti_id_and_init_to_defn(RttiId, Init, MLDS_Defn),
-	MLDS_Defns = [MLDS_Defn | SubDefns].
+	MLDS_Defns = list__append(SubDefns, [MLDS_Defn]).
 
 :- func gen_du_functor_desc(module_info, rtti_type_ctor, du_functor)
 	= list(mlds__defn).
@@ -686,7 +687,7 @@
 		ExistInfoInit
 	]),
 	rtti_id_and_init_to_defn(RttiId, Init, MLDS_Defn),
-	MLDS_Defns = [MLDS_Defn | SubDefns].
+	MLDS_Defns = list__append(SubDefns, [MLDS_Defn]).
 
 :- func gen_res_addr_functor_desc(module_info, rtti_type_ctor,
 	reserved_functor) = mlds__defn.
@@ -844,7 +845,7 @@
 	gen_pseudo_type_info_array(ModuleInfo, TypeRttiDatas, Init, SubDefns),
 	RttiName = field_types(Ordinal),
 	rtti_name_and_init_to_defn(RttiTypeCtor, RttiName, Init, MLDS_Defn),
-	MLDS_Defns = [MLDS_Defn | SubDefns].
+	MLDS_Defns = list__append(SubDefns, [MLDS_Defn]).
 
 %-----------------------------------------------------------------------------%
 
@@ -911,7 +912,7 @@
 	RttiName = du_ptag_ordered_table,
  	Init = init_array(list__append(PtagInitPrefix, PtagInits)),
 	rtti_name_and_init_to_defn(RttiTypeCtor, RttiName, Init, MLDS_Defn),
-	MLDS_Defns = [MLDS_Defn | SubDefns].
+	MLDS_Defns = list__append(SubDefns, [MLDS_Defn]).
 
 :- func gen_du_ptag_ordered_table_body(module_name, rtti_type_ctor,
 	assoc_list(int, sectag_table), int) = list(mlds__initializer).
@@ -998,7 +999,7 @@
 			du_ptag_ordered_table)
 	]),
 	rtti_id_and_init_to_defn(RttiId, Init, MLDS_Defn),
-	MLDS_Defns = [MLDS_Defn | SubDefns].
+	MLDS_Defns = list__append(SubDefns, [MLDS_Defn]).
 
 :- func gen_res_addr_functor_table(module_name, rtti_type_ctor,
 	list(reserved_functor)) = mlds__defn.
--------------------------------------------------------------------------
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