diff: bug fixes for rl_out.m

Simon Taylor stayl at cs.mu.OZ.AU
Fri Apr 16 12:44:09 AEST 1999



Estimated hours taken: 0.5

compiler/rl_out.m:
	Make sure all the output relations for a projection are initialised.
	Fix a syntax error in the generated code for union-diff.


Index: rl_out.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/rl_out.m,v
retrieving revision 1.5
diff -u -u -r1.5 rl_out.m
--- rl_out.m	1999/03/19 04:47:39	1.5
+++ rl_out.m	1999/04/16 02:20:26
@@ -965,7 +965,23 @@
 		),
 
 		rl_out__generate_exprn(Cond0, OutputSchemaOffset, CondExprn),
+
+		%
+		% Initialise the other output relations.
+		%
 		{ assoc_list__keys(OtherOutputs, OtherOutputRels) },
+		list__map_foldl(
+		    (pred(TheOutput::in, RelInitCode::out, in, out) is det -->
+			rl_out__generate_instr(init(TheOutput) - "",
+				RelInitCode)
+		    ),
+		    OtherOutputRels, OtherOutputInitCodeList),
+		{ list__foldl(
+		    (pred(InitCode::in, Tree0::in, Tree::out) is det :-
+			Tree = tree(Tree0, InitCode)
+		    ),
+		    OtherOutputInitCodeList, empty, OtherOutputInitCode) },
+
 		{ list__map(rl__output_rel_relation,
 			OtherOutputRels, OtherOutputRelations ) },
 		rl_out__get_rel_var_list(OtherOutputRelations, VarListCode),
@@ -979,7 +995,8 @@
 			tree(ExprnListCode,
 			node([rl_PROC_expr_list_nil])
 		))))) },
-		rl_out__generate_stream_instruction(Output, InstrCode, Code)
+		rl_out__generate_stream_instruction(Output, InstrCode, Code0),
+		{ Code = tree(OtherOutputInitCode, Code0) }
 	).
 rl_out__generate_instr(union(Output, Inputs, Type) - _, Code) -->
 	{ UnionCode = rl_PROC_union_sm },
@@ -1007,12 +1024,15 @@
 	{ InstrCode =
 		tree(node([
 			rl_PROC_uniondiff_btree,
-			rl_PROC_indexed_var(DiInputAddr, 0, IndexConst),
-			rl_PROC_setrel(UoOutputAddr, DiInputAddr)
+			rl_PROC_indexed_var(DiInputAddr, 0, IndexConst)
 		]),
 		StreamCode
 	) },
-	rl_out__generate_stream_instruction(Diff, InstrCode, Code).
+	rl_out__generate_stream_instruction(Diff, InstrCode, Code0),
+	{ Code =
+		tree(Code0,
+		node([rl_PROC_setrel(UoOutputAddr, DiInputAddr)])
+	) }.
 rl_out__generate_instr(sort(Output, Input, Attrs) - _, Code) -->
 	rl_out__generate_stream(Input, StreamCode),
 	rl_out_info_get_output_relation_schema(Output, OutputSchema),



More information about the developers mailing list