cvs diff: Bug fix for layouts

Tyson Richard DOWD trd at students.cs.mu.oz.au
Tue Mar 18 23:17:42 AEDT 1997


Could someone please review this? I don't mind who does it. 

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

Estimated hours taken: 2

Fix a bug in the output of base_type_layout information - pointers were
being tagged when the tags weren't wanted.

compiler/base_type_layout:
	- Move code for creating simple vectors into a predicate of
	  its own - `base_type_layout__simple_vector', and tag these
	  vectors separately.
	- When creating arrays of pointers to simple vectors, use
	  `base_type_layout__simple_vector' so that the pointers
	  are un-tagged.

Index: compiler/base_type_layout.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/base_type_layout.m,v
retrieving revision 1.14
diff -u -r1.14 base_type_layout.m
--- base_type_layout.m	1997/02/23 06:05:18	1.14
+++ base_type_layout.m	1997/02/25 05:54:57
@@ -841,20 +841,36 @@
 
 	% For simple tags:
 	%
-	% Tag 1, with a pointer to an array containing:
+	% Tag 1, with a pointer to a simple vector.
+
+:- pred base_type_layout__handle_simple(list(pair(cons_id, cons_tag)), 
+	layout_info, layout_info, list(maybe(rval))).
+:- mode base_type_layout__handle_simple(in, in, out, out) is det.
+
+base_type_layout__handle_simple(ConsList, LayoutInfo0, LayoutInfo, Rval) :-
+	base_type_layout__simple_vector(ConsList, LayoutInfo0, LayoutInfo1,
+		EndRvals),
+	base_type_layout__get_next_label(LayoutInfo1, NextLabel),
+	base_type_layout__incr_next_label(LayoutInfo1, LayoutInfo),
+	base_type_layout__tag_value(simple, Tag),
+	base_type_layout__encode_create(LayoutInfo, Tag, EndRvals, no, 
+		NextLabel, Rval).
+
+	% Create a simple vector.
+	%
 	%	N - the arity of this functor 
 	%	N pseudo-typeinfos (of the arguments)
 	%	- a string constant (the name of the functor)
 	%	- tag information
 
-:- pred base_type_layout__handle_simple(list(pair(cons_id, cons_tag)), 
+:- pred base_type_layout__simple_vector(list(pair(cons_id, cons_tag)), 
 	layout_info, layout_info, list(maybe(rval))).
-:- mode base_type_layout__handle_simple(in, in, out, out) is det.
+:- mode base_type_layout__simple_vector(in, in, out, out) is det.
 
-base_type_layout__handle_simple([], _, _, _) :-
+base_type_layout__simple_vector([], _, _, _) :-
 	error("base_type_layout: no constructors for simple tag").
-base_type_layout__handle_simple([ConsId - ConsTag | _], LayoutInfo0, 
-		LayoutInfo, Rval) :-
+base_type_layout__simple_vector([ConsId - ConsTag | _], LayoutInfo0, 
+		LayoutInfo, EndRvals) :-
 	( 
 		ConsId = cons(SymName, _Arity)
 	->
@@ -863,20 +879,14 @@
 		error("base_type_layout: simple tag with no constructor")
 	),
 	base_type_layout__get_cons_args(LayoutInfo0, ConsId, ConsArgs),
-	base_type_layout__get_next_label(LayoutInfo0, NextLabel),
-	base_type_layout__incr_next_label(LayoutInfo0, LayoutInfo1),
 	list__length(ConsArgs, NumArgs),
 	base_type_layout__generate_pseudo_type_infos(ConsArgs, 
-		LayoutInfo1, LayoutInfo2, PseudoTypeInfos),
-	base_type_layout__encode_cons_tag(ConsTag, ConsTagRvals, LayoutInfo2,
+		LayoutInfo0, LayoutInfo1, PseudoTypeInfos),
+	base_type_layout__encode_cons_tag(ConsTag, ConsTagRvals, LayoutInfo1,
 		LayoutInfo),
-	list__append(PseudoTypeInfos, 
+	list__append([yes(const(int_const(NumArgs))) | PseudoTypeInfos], 
 		[yes(const(string_const(ConsString))) | ConsTagRvals], 
-		EndRvals),
-	base_type_layout__tag_value(simple, Tag),
-	base_type_layout__encode_create(LayoutInfo, Tag, 
-		[yes(const(int_const(NumArgs))) | EndRvals], no, NextLabel, 
-		Rval).
+		EndRvals).
 
 
 	% For complicated tags:
@@ -1006,10 +1016,16 @@
 	list__foldr(
 		lambda([ConsPair::in, Acc::in, NewAcc::out] is det, (
 			Acc = Rvals0 - LayoutInfoA,
-			base_type_layout__handle_simple([ConsPair], LayoutInfoA,
-				LayoutInfoB, Rval1),
-			list__append(Rval1, Rvals0, Rvals1),
-			NewAcc = Rvals1 - LayoutInfoB)),
+			base_type_layout__simple_vector([ConsPair], LayoutInfoA,
+				LayoutInfoB, VectorRvalList),
+			base_type_layout__get_next_label(LayoutInfoB,
+				NextLabel),
+			base_type_layout__incr_next_label(LayoutInfoB,
+				LayoutInfoC),
+			VectorRval = yes(create(0, VectorRvalList, no, 
+				NextLabel)),
+			Rvals1 = [VectorRval | Rvals0],
+			NewAcc = Rvals1 - LayoutInfoC)),
 		ConsList, [] - LayoutInfo0, VectorRvals - LayoutInfo),
 	Rvals = [DuIndicatorRval, LengthRval | VectorRvals].
 
-- 
       Tyson Dowd           # "Well, let's just say, 'if your VCR is
                            #  still blinking 12:00, you don't
     trd at cs.mu.oz.au        #  want Linux'". 
http://www.cs.mu.oz.au/~trd #  --Bruce Perens, Debian's Fearless Leader



More information about the developers mailing list