[m-rev.] EDCG diff1

Peter Nicholas MALKIN pnmalk at students.cs.mu.oz.au
Thu Mar 15 19:23:33 AEDT 2001


Index: compiler/accumulator.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/accumulator.m,v
retrieving revision 1.18
diff -u -r1.18 accumulator.m
--- compiler/accumulator.m	2000/10/13 13:55:13	1.18
+++ compiler/accumulator.m	2001/03/13 00:11:49
@@ -547,7 +547,7 @@
 
 is_recursive_case(Goals, proc(PredId, ProcId)) :-
 	list__append(_Initial, [RecursiveCall | _Final], Goals),
-	RecursiveCall = call(PredId, ProcId, _, _, _, _) - _.
+	RecursiveCall = call(PredId, ProcId, _, _, _, _, _) - _.
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
@@ -604,7 +604,7 @@
 	P = (pred(Key::out) is nondet :-
 		goal_store__member(GoalStore, Key, Goal - _InstMap),
 		Key = rec - _,
-		Goal = call(PredId, ProcId, _, _, _, _) - _
+		Goal = call(PredId, ProcId, _, _, _, _, _) - _
 	),
 	solutions(P, Ids).
 
@@ -634,7 +634,7 @@
 	(
 		list__take(K, Rec, InitialGoals),
 		list__drop(K-1, Rec, FinalGoals),
-		FinalGoals = [call(_, _, Args, _, _, _) - _ | Rest]
+		FinalGoals = [call(_, _, Args, _, _, _, _) - _ | Rest]
 	->
 		goal_list_instmap_delta(InitialGoals, InitInstMapDelta),
 		instmap__apply_instmap_delta(InitialInstMap,
@@ -856,7 +856,7 @@
 assoc(N - I, K, GoalStore, sets(Before, _, _, _, _, _),
 		FullyStrict, VarTypes, ModuleInfo) :-
 	goal_store__lookup(GoalStore, N - I, LaterGoal - LaterInstMap),
-	LaterGoal = call(PredId, ProcId, Args, _, _, _) - _,
+	LaterGoal = call(PredId, ProcId, Args, _, _, _, _) - _,
 	is_associative(PredId, ProcId, ModuleInfo, Args, _),
 	(
 		member_lessthan_goalid(GoalStore, N - I, _N - J,
@@ -922,7 +922,7 @@
 
 	set__singleton_set(Assoc `intersect` Ancestors, AssocId),
 	goal_store__lookup(GoalStore, AssocId, AssocGoal - _AssocInstMap),
-	AssocGoal = call(PredId, _, _, _, _, _) - _,
+	AssocGoal = call(PredId, _, _, _, _, _, _) - _,
 
 	is_associative_construction(ConsId, PredId, ModuleInfo),
 	(
@@ -950,7 +950,7 @@
 update(N - I, K, GoalStore, sets(Before, _, _, _, _, _),
 		FullyStrict, VarTypes, ModuleInfo) :-
 	goal_store__lookup(GoalStore, N - I, LaterGoal - LaterInstMap),
-	LaterGoal = call(PredId, ProcId, Args, _, _, _) - _,
+	LaterGoal = call(PredId, ProcId, Args, _, _, _, _) - _,
 	is_update(PredId, ProcId, ModuleInfo, Args, _),
 	(
 		member_lessthan_goalid(GoalStore, N - I, _N - J,
@@ -1269,7 +1269,7 @@
 
 	lookup_call(GS, Id, Goal - InstMap),
 
-	Goal = call(PredId, ProcId, Args, _, _, _) - GoalInfo,
+	Goal = call(PredId, ProcId, Args, _, _, _, _) - GoalInfo,
 	is_associative(PredId, ProcId, ModuleInfo, Args, AssocInfo),
 	AssocInfo = assoc(Vars, AssocOutput, IsCommutative),
 	set__singleton_set(Vars `intersect` OutPrime, DuringAssocVar),
@@ -1377,7 +1377,7 @@
 				UpdateSubst0),
 	lookup_call(GS, Id, Goal - _InstMap),
 
-	Goal = call(PredId, ProcId, Args, _, _, _) - _GoalInfo,
+	Goal = call(PredId, ProcId, Args, _, _, _, _) - _GoalInfo,
 	is_update(PredId, ProcId, ModuleInfo, Args, StateVarA - StateVarB),
 
 	(
@@ -1493,7 +1493,8 @@
 	
 %-----------------------------------------------------------------------------%
 
-:- inst call = bound(call(ground, ground, ground, ground, ground, ground)).
+:- inst call = bound(call(ground, ground, ground, ground, ground, ground, 
+		ground)).
 :- inst hlds_call = bound('-'(call, ground)).
 :- inst call_goal = bound('-'(hlds_call, ground)).
 
@@ -1505,7 +1506,7 @@
 lookup_call(GoalStore, Id, Call - InstMap) :-
 	goal_store__lookup(GoalStore, Id, Goal - InstMap),
 	(
-		Goal = call(_, _, _, _, _, _) - _
+		Goal = call(_, _, _, _, _, _, _) - _
 	->
 		Call = Goal
 	;
@@ -1699,8 +1700,9 @@
 :- mode create_acc_call(in(hlds_call), in, in, in, in) = out(hlds_call) is det.
 
 create_acc_call(OrigCall, Accs, AccPredId, AccProcId, AccName) = Call :-
-	OrigCall = call(_PredId, _ProcId, Args, Builtin, Context, _Name) - GI,
-	Call = call(AccPredId, AccProcId, Accs `append` Args,
+	OrigCall = call(_PredId, _ProcId, Args, EDCGArgs, Builtin, Context, 
+		_Name) - GI,
+	Call = call(AccPredId, AccProcId, Accs `append` Args, EDCGArgs,
 			Builtin, Context, AccName) - GI.
 
 	%
Index: compiler/add_trail_ops.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/add_trail_ops.m,v
retrieving revision 1.1
diff -u -r1.1 add_trail_ops.m
--- compiler/add_trail_ops.m	2000/12/13 12:12:52	1.1
+++ compiler/add_trail_ops.m	2001/03/13 00:18:24
@@ -244,7 +244,8 @@
 	{ Goal = conj([StoreTicketGoal, IfThenElse]) }.
 
 
-goal_expr_add_trail_ops(call(A,B,C,D,E,F), GI, call(A,B,C,D,E,F) - GI) --> [].
+goal_expr_add_trail_ops(call(A,B,C,D,E,F,G), GI, call(A,B,C,D,E,F,G) - GI) 
+	--> [].
 
 goal_expr_add_trail_ops(generic_call(A,B,C,D), GI, generic_call(A,B,C,D) - GI)
 	--> [].
@@ -274,6 +275,8 @@
 goal_expr_add_trail_ops(bi_implication(_, _), _, _) -->
 	% these should have been expanded out by now
 	{ error("goal_expr_add_trail_ops: unexpected bi_implication") }.
+goal_expr_add_trail_ops(edcg_goal(_, _, _), _, _) --> 
+	{ error("goal_expr_add_trail_ops: unexpected edcg_goal") }.
 
 :- pred conj_add_trail_ops(hlds_goals::in, hlds_goals::out,
 		trail_ops_info::in, trail_ops_info::out) is det.
@@ -495,7 +498,7 @@
 		error(ErrorMessage)
 
 	),
-	Call = call(PredId, ProcId, Args, not_builtin, no,
+	Call = call(PredId, ProcId, Args, [], not_builtin, no,
 		qualified(BuiltinModule, PredName)),
 	set__init(NonLocals0),
 	set__insert_list(NonLocals0, Args, NonLocals),
Index: compiler/assertion.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/assertion.m,v
retrieving revision 1.11
diff -u -r1.11 assertion.m
--- compiler/assertion.m	2001/03/05 10:30:59	1.11
+++ compiler/assertion.m	2001/03/12 15:35:43
@@ -144,8 +144,8 @@
 		CommutativeVars) :-
 	assertion__goal(AssertId, Module, Goal),
 	equivalent(Goal, P, Q),
-	P = call(PredId, _, VarsP, _, _, _) - _,
-	Q = call(PredId, _, VarsQ, _, _, _) - _,
+	P = call(PredId, _, VarsP, _, _, _, _) - _,
+	Q = call(PredId, _, VarsQ, _, _, _, _) - _,
 	commutative_var_ordering(VarsP, VarsQ, CallVars, CommutativeVars).
 
 	%
@@ -393,8 +393,8 @@
 
 process_two_linked_calls(Goals, UniversiallyQuantifiedVars, PredId,
 		LinkingVar, Vars, VarsA) :-
-	Goals = [call(PredId, _, VarsA, _, _, _) - _,
-			call(PredId, _, VarsB, _, _, _) - _],
+	Goals = [call(PredId, _, VarsA, _, _, _, _) - _,
+			call(PredId, _, VarsB, _, _, _, _) - _],
 
 		% Determine the linking variable, L.
 		% By definition it must be existentially quantified and
@@ -446,7 +446,7 @@
 		Goal = conj(Goals) - _
 	->
 		list__member(Call, Goals),
-		Call = call(PredId, _, _, _, _, _) - _,
+		Call = call(PredId, _, _, _, _, _, _) - _,
 		list__delete(Goals, Call, Unifications),
 		P = (pred(G::in) is semidet :-
 			not (
@@ -456,7 +456,7 @@
 		),
 		list__filter(P, Unifications, [])
 	;
-		Goal = call(PredId, _, _, _, _, _) - _
+		Goal = call(PredId, _, _, _, _, _, _) - _
 	).
 
 %-----------------------------------------------------------------------------%
@@ -469,7 +469,7 @@
 	pred_info_clauses_info(PredInfo, ClausesInfo),
 	clauses_info_clauses(ClausesInfo, Clauses),
 	(
-		Clauses = [clause(_ProcIds, Goal0, _Context)]
+		Clauses = [clause(_ProcIds, Goal0, _MaybeEdcg, _Context)]
 	->
 		assertion__normalise_goal(Goal0, Goal)
 	;
@@ -521,8 +521,8 @@
 
 equal_goals(conj(GoalAs) - _, conj(GoalBs) - _, Subst0, Subst) :-
 	equal_goals_list(GoalAs, GoalBs, Subst0, Subst).
-equal_goals(call(PredId, _, VarsA, _, _, _) - _,
-		call(PredId, _, VarsB, _, _, _) - _, Subst0, Subst) :-
+equal_goals(call(PredId, _, VarsA, _, _, _, _) - _,
+		call(PredId, _, VarsB, _, _, _, _) - _, Subst0, Subst) :-
 	equal_vars(VarsA, VarsB, Subst0, Subst).
 equal_goals(generic_call(Type, VarsA, _, _) - _,
 		generic_call(Type, VarsB, _, _) - _, Subst0, Subst) :-
@@ -558,6 +558,8 @@
 	    bi_implication(LeftGoalB, RightGoalB) - _, Subst0, Subst) :-
 	equal_goals(LeftGoalA, LeftGoalB, Subst0, Subst1),
 	equal_goals(RightGoalA, RightGoalB, Subst1, Subst).
+equal_goals(edcg_goal(_, _, _) - _, edcg_goal(_, _, _) - _, Subst, Subst) :-
+	error("assertion__equal_goals: unexpected edcg_goal").
 
 :- pred equal_vars(prog_vars::in, prog_vars::in, subst::in,
 		subst::out) is semidet.
@@ -649,7 +651,7 @@
 	%
 :- pred assertion__normalise_goal(hlds_goal::in, hlds_goal::out) is det.
 
-assertion__normalise_goal(call(A,B,C,D,E,F) - GI, call(A,B,C,D,E,F) - GI).
+assertion__normalise_goal(call(A,B,C,D,E,F,G) - GI, call(A,B,C,D,E,F,G) - GI).
 assertion__normalise_goal(generic_call(A,B,C,D) - GI, generic_call(A,B,C,D)-GI).
 assertion__normalise_goal(unify(A,B,C,D,E) - GI, unify(A,B,C,D,E) - GI).
 assertion__normalise_goal(pragma_foreign_code(A,B,C,D,E,F,G) - GI,
@@ -675,7 +677,10 @@
 		bi_implication(LHS, RHS) - GI) :-
 	assertion__normalise_goal(LHS0, LHS),
 	assertion__normalise_goal(RHS0, RHS).
+assertion__normalise_goal(edcg_goal(A,B,C) - GI, edcg_goal(A,B,C)-GI) :-
+	error("assertion__normalise_goal: unexpected edcg_goal").
 
+
 %-----------------------------------------------------------------------------%
 
 :- pred assertion__normalise_conj(hlds_goals::in, hlds_goals::out) is det.
@@ -705,7 +710,7 @@
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
-assertion__in_interface_check(call(PredId,_,_,_,_,SymName) - GoalInfo,
+assertion__in_interface_check(call(PredId,_,_,_,_,_,SymName) - GoalInfo,
 		_PredInfo, Module0, Module) -->
 	{ module_info_pred_info(Module0, PredId, CallPredInfo)  },
 	{ pred_info_import_status(CallPredInfo, ImportStatus) },
@@ -768,6 +773,8 @@
 		Module0, Module) -->
 	assertion__in_interface_check(LHS, PredInfo, Module0, Module1),
 	assertion__in_interface_check(RHS, PredInfo, Module1, Module).
+assertion__in_interface_check(edcg_goal(_,_,_) - _, _, Module, Module) --> 
+        { error("assertion__in_interface_check: unexpected edcg_goal") }.
 
 %-----------------------------------------------------------------------------%
 
@@ -802,6 +809,8 @@
 assertion__in_interface_check_unify_rhs(lambda_goal(_,_,_,_,_,_,_,Goal),
 		_Var, _Context, PredInfo, Module0, Module) -->
 	assertion__in_interface_check(Goal, PredInfo, Module0, Module).
+assertion__in_interface_check_unify_rhs(edcg_op(_,_),_,_,_,_,_) -->
+	{ error("assertion__in_interface_check_unify_rhs: unexpected edcg_op") }.
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/bytecode_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/bytecode_gen.m,v
retrieving revision 1.59
diff -u -r1.59 bytecode_gen.m
--- compiler/bytecode_gen.m	2001/02/19 02:05:57	1.59
+++ compiler/bytecode_gen.m	2001/03/12 15:35:43
@@ -196,7 +196,7 @@
 			ByteInfo = ByteInfo0
 		)
 	;
-		GoalExpr = call(PredId, ProcId, ArgVars, BuiltinState, _, _),
+		GoalExpr = call(PredId, ProcId, ArgVars, _, BuiltinState, _, _),
 		( BuiltinState = not_builtin ->
 			goal_info_get_determinism(GoalInfo, Detism),
 			bytecode_gen__call(PredId, ProcId, ArgVars, Detism,
@@ -286,6 +286,10 @@
 		GoalExpr = bi_implication(_, _),
 		% these should have been expanded out by now
 		error("bytecode_gen__goal_expr: unexpected bi_implication")
+	;
+		GoalExpr = edcg_goal(_, _, _),
+		% these should have been expanded out by now
+		error("bytecode_gen__goal_expr: unexpected edcg_goal")
 	).
 
 %---------------------------------------------------------------------------%
Index: compiler/clause_to_proc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/clause_to_proc.m,v
retrieving revision 1.29
diff -u -r1.29 clause_to_proc.m
--- compiler/clause_to_proc.m	2001/01/17 01:41:50	1.29
+++ compiler/clause_to_proc.m	2001/03/12 15:35:43
@@ -207,7 +207,7 @@
 
 select_matching_clauses([], _, []).
 select_matching_clauses([Clause | Clauses], ProcId, MatchingClauses) :-
-	Clause = clause(ProcIds, _, _),
+	Clause = clause(ProcIds, _, _, _),
 	% an empty list here means that the clause applies to all procs
 	( ProcIds = [] ->
 		MatchingClauses = [Clause | MatchingClauses1]
@@ -222,7 +222,7 @@
 
 get_clause_goals([], []).
 get_clause_goals([Clause | Clauses], Goals) :-
-	Clause = clause(_, Goal, _),
+	Clause = clause(_, Goal, _, _),
 	goal_to_disj_list(Goal, GoalList),
 	list__append(GoalList, Goals1, Goals),
 	get_clause_goals(Clauses, Goals1).
Index: compiler/code_aux.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_aux.m,v
retrieving revision 1.61
diff -u -r1.61 code_aux.m
--- compiler/code_aux.m	2000/11/23 04:32:28	1.61
+++ compiler/code_aux.m	2001/03/12 15:35:43
@@ -89,7 +89,7 @@
 	code_aux__contains_only_builtins(Cond),
 	code_aux__contains_only_builtins(Then),
 	code_aux__contains_only_builtins(Else).
-code_aux__contains_only_builtins_2(call(_, _, _, BuiltinState, _, _)) :-
+code_aux__contains_only_builtins_2(call(_, _, _, _, BuiltinState, _, _)) :-
 	BuiltinState = inline_builtin.
 code_aux__contains_only_builtins_2(unify(_, _, _, Uni, _)) :-
 	(
@@ -166,7 +166,7 @@
 	code_aux__goal_cannot_loop_aux(MaybeModuleInfo, Then),
 	code_aux__goal_cannot_loop_aux(MaybeModuleInfo, Else).
 code_aux__goal_cannot_loop_expr(MaybeModuleInfo,
-		call(PredId, ProcId, _, _, _, _)) :-
+		call(PredId, ProcId, _, _, _, _, _)) :-
 	MaybeModuleInfo = yes(ModuleInfo),
 	module_info_pred_proc_info(ModuleInfo, PredId, ProcId, _, ProcInfo),
 	proc_info_get_maybe_termination_info(ProcInfo, MaybeTermInfo),
@@ -198,7 +198,7 @@
 code_aux__goal_is_flat_2(some(_Vars, _, Goal)) :-
 	code_aux__goal_is_flat(Goal).
 code_aux__goal_is_flat_2(generic_call(_, _, _, _)).
-code_aux__goal_is_flat_2(call(_, _, _, _, _, _)).
+code_aux__goal_is_flat_2(call(_, _, _, _, _, _, _)).
 code_aux__goal_is_flat_2(unify(_, _, _, _, _)).
 code_aux__goal_is_flat_2(pragma_foreign_code(_, _, _, _, _, _, _)).
 
@@ -243,7 +243,7 @@
 :- mode code_aux__is_recursive_call(in, in) is semidet.
 
 code_aux__is_recursive_call(Goal, CodeInfo) :-
-	Goal = call(CallPredId, CallProcId, _, BuiltinState, _, _),
+	Goal = call(CallPredId, CallProcId, _, _, BuiltinState, _, _),
 	BuiltinState = not_builtin,
 	code_info__get_pred_id(PredId, CodeInfo, _),
 	PredId = CallPredId,
Index: compiler/code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_gen.m,v
retrieving revision 1.94
diff -u -r1.94 code_gen.m
--- compiler/code_gen.m	2001/02/19 02:05:57	1.94
+++ compiler/code_gen.m	2001/03/12 15:35:43
@@ -1132,7 +1132,7 @@
 	call_gen__generate_generic_call(CodeModel, GenericCall, Args,
 		Modes, Det, GoalInfo, Code).
 
-code_gen__generate_goal_2(call(PredId, ProcId, Args, BuiltinState, _, _),
+code_gen__generate_goal_2(call(PredId, ProcId, Args, _, BuiltinState, _, _),
 		GoalInfo, CodeModel, Code) -->
 	(
 		{ BuiltinState = not_builtin }
@@ -1158,6 +1158,9 @@
 code_gen__generate_goal_2(bi_implication(_, _), _, _, _) -->
 	% these should have been expanded out by now
 	{ error("code_gen__generate_goal_2: unexpected bi_implication") }.
+code_gen__generate_goal_2(edcg_goal(_, _, _), _, _, _) -->
+	% these should have been expanded out by now
+	{ error("code_gen__generate_goal_2: unexpected edcg_goal") }.
 
 %---------------------------------------------------------------------------%
 
Index: compiler/code_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_util.m,v
retrieving revision 1.129
diff -u -r1.129 code_util.m
--- compiler/code_util.m	2000/11/23 04:32:32	1.129
+++ compiler/code_util.m	2001/03/12 15:35:43
@@ -463,7 +463,7 @@
 	is det.
 
 code_util__goal_may_allocate_heap_2(generic_call(_, _, _, _), yes).
-code_util__goal_may_allocate_heap_2(call(_, _, _, Builtin, _, _), May) :-
+code_util__goal_may_allocate_heap_2(call(_, _, _, _, Builtin, _, _), May) :-
 	( Builtin = inline_builtin ->
 		May = no
 	;
@@ -506,6 +506,8 @@
 	;
 		code_util__goal_may_allocate_heap(G2, May)
 	).
+code_util__goal_may_allocate_heap_2(edcg_goal(_, _, _), _) :-
+        error("code_util__goal_may_allocate_heap_2: unexpected edcg_goal").
 
 :- pred code_util__goal_list_may_allocate_heap(list(hlds_goal)::in, bool::out)
 	is det.
@@ -542,7 +544,7 @@
 	is det.
 
 code_util__goal_may_alloc_temp_frame_2(generic_call(_, _, _, _), no).
-code_util__goal_may_alloc_temp_frame_2(call(_, _, _, _, _, _), no).
+code_util__goal_may_alloc_temp_frame_2(call(_, _, _, _, _, _, _), no).
 code_util__goal_may_alloc_temp_frame_2(unify(_, _, _, _, _), no).
 	% We cannot safely say that a C code fragment does not allocate
 	% temporary nondet frames without knowing all the #defined macros
@@ -582,6 +584,8 @@
 	;
 		code_util__goal_may_alloc_temp_frame(G2, May)
 	).
+code_util__goal_may_alloc_temp_frame_2(edcg_goal(_, _, _), _) :-
+        error("code_util__goal_may_alloc_temp_frame_2: unexpected edcg_goal").
 
 :- pred code_util__goal_list_may_alloc_temp_frame(list(hlds_goal)::in,
 	bool::out) is det.
@@ -730,7 +734,7 @@
 
 code_util__cannot_stack_flush_2(unify(_, _, _, Unify, _)) :-
 	Unify \= complicated_unify(_, _, _).
-code_util__cannot_stack_flush_2(call(_, _, _, BuiltinState, _, _)) :-
+code_util__cannot_stack_flush_2(call(_, _, _, _, BuiltinState, _, _)) :-
 	BuiltinState = inline_builtin.
 code_util__cannot_stack_flush_2(conj(Goals)) :-
 	code_util__cannot_stack_flush_goals(Goals).
@@ -778,7 +782,7 @@
 	Goal = GoalExpr - GoalInfo,
 	(
 		(
-			GoalExpr = call(_, _, _, BuiltinState, _, _),
+			GoalExpr = call(_, _, _, _, BuiltinState, _, _),
 			BuiltinState \= inline_builtin
 		;
 			GoalExpr = generic_call(_, _, _, _)
@@ -813,7 +817,7 @@
 		0, 0).
 code_util__count_recursive_calls_2(pragma_foreign_code(_, _, _, _, _, _, _),
 		_, _, 0, 0).
-code_util__count_recursive_calls_2(call(CallPredId, CallProcId, _, _, _, _),
+code_util__count_recursive_calls_2(call(CallPredId, CallProcId, _, _, _, _, _),
 		PredId, ProcId, Count, Count) :-
 	(
 		PredId = CallPredId,
@@ -846,6 +850,10 @@
 		_, _, _, _) :-
 	% these should have been expanded out by now
 	error("code_util__count_recursive_calls_2: unexpected bi_implication").
+code_util__count_recursive_calls_2(edcg_goal(_, _, _),
+		_, _, _, _) :-
+	% these should have been expanded out by now
+	error("code_util__count_recursive_calls_2: unexpected edcg_goal").
 
 :- pred code_util__count_recursive_calls_conj(list(hlds_goal),
 	pred_id, proc_id, int, int, int, int).
Index: compiler/common.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/common.m,v
retrieving revision 1.59
diff -u -r1.59 common.m
--- compiler/common.m	2000/10/13 13:55:16	1.59
+++ compiler/common.m	2001/03/13 00:18:42
@@ -667,7 +667,7 @@
 		->
 			hlds_pred__initial_proc_id(ProcId),
 			GoalExpr = call(PredId, ProcId, [FromVar, ToVar],
-				inline_builtin, no, TypeCast)
+				[], inline_builtin, no, TypeCast)
 		;
 			error("common__generate_assign: \
 				can't find unsafe_type_cast")
Index: compiler/context.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/context.m,v
retrieving revision 1.3
diff -u -r1.3 context.m
--- compiler/context.m	2000/04/14 08:37:46	1.3
+++ compiler/context.m	2001/03/12 15:35:44
@@ -358,7 +358,7 @@
 	{ pred_info_module(PredInfo, PredModule) },
 	{ pred_info_name(PredInfo, PredName) },
 	magic_info_get_curr_pred_proc_id(proc(PredId, ProcId)),
-	{ CallGoal = call(PredId, ProcId, Args, not_builtin, no, 
+	{ CallGoal = call(PredId, ProcId, Args, [], not_builtin, no, 
 			qualified(PredModule, PredName)) - RecGoalInfo },
 
 	magic_info_get_magic_vars(Vars),
@@ -424,7 +424,7 @@
 	magic_info_get_curr_pred_proc_id(proc(PredId, ProcId)),
 	magic_info_get_magic_vars(MagicVars),
 	{ list__append(MagicVars, Args0, Args) },
-	{ RecGoal = call(PredId, ProcId, Args, not_builtin, no, 
+	{ RecGoal = call(PredId, ProcId, Args, [], not_builtin, no, 
 			qualified(PredModule, PredName)) - RecGoalInfo },
 	
 	{ list__reverse(CallList, RevCallList) },
@@ -518,7 +518,7 @@
 		{ pred_info_name(PredInfo, PredName) },
 		magic_info_get_magic_vars(MagicVars),
 		{ list__append(MagicVars, NewArgs, AllArgs) },
-		{ RecGoal = call(PredId, ProcId, AllArgs, not_builtin, no, 
+		{ RecGoal = call(PredId, ProcId, AllArgs, [], not_builtin, no, 
 			qualified(PredModule, PredName)) - GoalInfo },
 		{ SetupCall = [RecGoal | Tests] }
 	;
@@ -564,7 +564,7 @@
 	{ goal_info_init(NonLocals, InstMapDelta, nondet, GoalInfo) },
 
 	{ MagicCall = call(MagicPredId, MagicProcId, MagicArgs, 
-			not_builtin, no, PredName) - GoalInfo }.
+			[], not_builtin, no, PredName) - GoalInfo }.
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/cse_detection.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/cse_detection.m,v
retrieving revision 1.68
diff -u -r1.68 cse_detection.m
--- compiler/cse_detection.m	2000/12/08 06:50:13	1.68
+++ compiler/cse_detection.m	2001/03/12 15:35:44
@@ -219,8 +219,8 @@
 detect_cse_in_goal_2(generic_call(A,B,C,D), _, _, CseInfo, CseInfo,
 	no, generic_call(A,B,C,D)).
 
-detect_cse_in_goal_2(call(A,B,C,D,E,F), _, _, CseInfo, CseInfo, no,
-	call(A,B,C,D,E,F)).
+detect_cse_in_goal_2(call(A,B,C,D,E,F,G), _, _, CseInfo, CseInfo, no,
+	call(A,B,C,D,E,F,G)).
 
 detect_cse_in_goal_2(unify(A,B0,C,D,E), _, InstMap0, CseInfo0, CseInfo, Redo,
 		unify(A,B,C,D,E)) :-
@@ -288,6 +288,10 @@
 detect_cse_in_goal_2(bi_implication(_, _), _, _, _, _, _, _) :-
 	% these should have been expanded out by now
 	error("detect_cse_in_goal_2: unexpected bi_implication").
+
+detect_cse_in_goal_2(edcg_goal(_, _, _), _, _, _, _, _, _) :-
+	% these should have been expanded out by now
+	error("detect_cse_in_goal_2: unexpected edcg_goal").
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/dead_proc_elim.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/dead_proc_elim.m,v
retrieving revision 1.63
diff -u -r1.63 dead_proc_elim.m
--- compiler/dead_proc_elim.m	2000/11/17 17:47:00	1.63
+++ compiler/dead_proc_elim.m	2001/03/12 15:35:44
@@ -462,7 +462,7 @@
 		Needed2, Needed).
 dead_proc_elim__examine_expr(generic_call(_,_,_,_), _,
 		Queue, Queue, Needed, Needed).
-dead_proc_elim__examine_expr(call(PredId, ProcId, _,_,_,_),
+dead_proc_elim__examine_expr(call(PredId, ProcId, _,_,_,_,_),
 		CurrProc, Queue0, Queue, Needed0, Needed) :-
 	queue__put(Queue0, proc(PredId, ProcId), Queue),
 	( proc(PredId, ProcId) = CurrProc ->
@@ -513,6 +513,9 @@
 dead_proc_elim__examine_expr(bi_implication(_,_), _, _, _, _, _) :-
 	% these should have been expanded out by now
 	error("detect_cse_in_goal_2: unexpected bi_implication").
+dead_proc_elim__examine_expr(edcg_goal(_,_,_), _, _, _, _, _) :-
+	% these should have been expanded out by now
+	error("detect_cse_in_goal_2: unexpected edcg_goal").
 
 %-----------------------------------------------------------------------------%
 
@@ -854,7 +857,7 @@
 :- pred dead_pred_elim_process_clause(clause::in, dead_pred_info::in, 
 		dead_pred_info::out) is det.
 
-dead_pred_elim_process_clause(clause(_, Goal, _)) -->
+dead_pred_elim_process_clause(clause(_, Goal, _, _)) -->
 	pre_modecheck_examine_goal(Goal).
 
 :- pred pre_modecheck_examine_goal(hlds_goal::in, 
@@ -879,7 +882,7 @@
 	pre_modecheck_examine_goal(Goal).
 pre_modecheck_examine_goal(some(_, _, Goal) - _) -->
 	pre_modecheck_examine_goal(Goal).
-pre_modecheck_examine_goal(call(_, _, _, _, _, PredName) - _) -->
+pre_modecheck_examine_goal(call(_, _, _, _, _, _, PredName) - _) -->
 	dead_pred_info_add_pred_name(PredName).
 pre_modecheck_examine_goal(pragma_foreign_code(_, _, _, _, _, _, _) - _) -->
 	[].
@@ -888,6 +891,9 @@
 pre_modecheck_examine_goal(bi_implication(_, _) - _) -->
 	% these should have been expanded out by now
 	{ error("pre_modecheck_examine_goal: unexpected bi_implication") }.
+pre_modecheck_examine_goal(edcg_goal(_, _, _) - _) -->
+	% these should have been expanded out by now
+	{ error("pre_modecheck_examine_goal: unexpected edcg_goal") }.
 
 :- pred pre_modecheck_examine_unify_rhs(unify_rhs::in, 
 		dead_pred_info::in, dead_pred_info::out) is det.
@@ -901,6 +907,8 @@
 	).
 pre_modecheck_examine_unify_rhs(lambda_goal(_, _, _, _, _, _, _, Goal)) -->
 	pre_modecheck_examine_goal(Goal).
+pre_modecheck_examine_unify_rhs(edcg_op(_, _)) -->
+	{ error("pre_modecheck_examine_unify_rhs: unexpected edcg_op") }.
 
 :- pred dead_pred_info_add_pred_name(sym_name::in, dead_pred_info::in, 
 		dead_pred_info::out) is det.
Index: compiler/deforest.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/deforest.m,v
retrieving revision 1.18
diff -u -r1.18 deforest.m
--- compiler/deforest.m	2000/11/17 17:47:01	1.18
+++ compiler/deforest.m	2001/03/12 15:35:44
@@ -214,7 +214,7 @@
 	deforest__goal(Goal0, Goal).
 
 deforest__goal(Goal0, Goal) -->
-	{ Goal0 = call(PredId, ProcId, Args, _, _, Name) - _ },
+	{ Goal0 = call(PredId, ProcId, Args, _, _, _, Name) - _ },
 	deforest__call(PredId, ProcId, Args, Name, Goal0, Goal).
 	
 deforest__goal(Goal, Goal) -->
@@ -224,6 +224,10 @@
 	% these should have been expanded out by now
 	{ error("deforest__goal: unexpected bi_implication") }.
 
+deforest__goal(edcg_goal(_, _, _) - _, _) -->
+	% these should have been expanded out by now
+	{ error("deforest__goal: unexpected edcg_goal") }.
+
 %-----------------------------------------------------------------------------%
 
 :- pred deforest__disj(list(hlds_goal)::in, list(hlds_goal)::out,
@@ -292,7 +296,7 @@
 	{ Goal = GoalExpr - _ },
 	( { goal_util__goal_is_branched(GoalExpr) } ->
 		pd_util__get_branch_vars_goal(Goal, MaybeBranchInfo)
-	; { GoalExpr = call(PredId, ProcId, Args, _, _, _) } ->
+	; { GoalExpr = call(PredId, ProcId, Args, _, _, _, _) } ->
 		pd_info_get_proc_arg_info(ProcBranchInfos),
 		(
 			{ map__search(ProcBranchInfos, 
@@ -470,8 +474,8 @@
 		{ Optimized0 = no },
 		{ Goals = [] }
 	;
-		{ EarlierGoal = call(PredId1, _, _, _, _, _) - _ },
-		{ LaterGoal = call(PredId2, _, _, _, _, _) - _ }
+		{ EarlierGoal = call(PredId1, _, _, _, _, _, _) - _ },
+		{ LaterGoal = call(PredId2, _, _, _, _, _, _) - _ }
 	->
 		%
 		% If both goals are calls create a new predicate
@@ -495,7 +499,7 @@
 		%
 		{ EarlierGoal = EarlierGoalExpr - _ },
 		{ goal_util__goal_is_branched(EarlierGoalExpr) },
-		{ LaterGoal = call(PredId, ProcId, _, _, _, _) - _ },
+		{ LaterGoal = call(PredId, ProcId, _, _, _, _, _) - _ },
 		{ PredProcId = proc(PredId, ProcId) },
 		{ PredProcId \= CurrPredProcId },
 		\+ { set__member(PredProcId, Parents0) }
@@ -609,9 +613,9 @@
 		% Check whether either of the goals to be
 		% deforested can't be inlined.
 		( 
-			{ EarlierGoal = call(PredId, _, _, _, _, _) - _ }
+			{ EarlierGoal = call(PredId, _, _, _, _, _, _) - _ }
 		;
-			{ LaterGoal = call(PredId, _, _, _, _, _) - _ }
+			{ LaterGoal = call(PredId, _, _, _, _, _, _) - _ }
 		),
 		{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
 		{ pred_info_get_markers(PredInfo, Markers) },
@@ -805,8 +809,8 @@
 	pd_info_get_module_info(ModuleInfo0),
 	pd_info_lookup_option(deforestation_vars_threshold, VarsOpt),
 	(
-		{ EarlierGoal = call(PredId1, ProcId1, Args1, _, _, _) - _ },
-		{ LaterGoal = call(PredId2, ProcId2, _, _, _, _) - _ },
+		{ EarlierGoal = call(PredId1, ProcId1, Args1, _, _, _, _) - _ },
+		{ LaterGoal = call(PredId2, ProcId2, _, _, _, _, _) - _ },
 
 		( 
 				% no threshold set.
@@ -998,7 +1002,7 @@
 
 	{ pred_info_module(CalledPredInfo, PredModule) },
 	{ pred_info_name(CalledPredInfo, PredName) },
-	{ Goal = call(PredId, ProcId, Args, not_builtin, no, 
+	{ Goal = call(PredId, ProcId, Args, [], not_builtin, no, 
 			qualified(PredModule, PredName)) - GoalInfo }.
 	
 :- pred deforest__create_deforest_call_args(list(prog_var)::in, list(type)::in,
@@ -1189,7 +1193,7 @@
 		VersionArgTypes, FirstGoal, BetweenGoals, LastGoal, 
 		ConjNonLocals, VarSet0, VarTypes0, Versions, Renaming) :-
 
-	FirstGoal = call(FirstPredId, FirstProcId, FirstArgs, _, _, _) - _,
+	FirstGoal = call(FirstPredId, FirstProcId, FirstArgs, _, _, _, _) - _,
 
 	%
 	% Look up the version which the first goal calls.
@@ -1224,7 +1228,7 @@
 					NonGeneralisedProcId),
 	goal_to_conj_list(VersionGoal, VersionGoalList),
 	VersionGoalList = [call(NonGeneralisedPredId, NonGeneralisedProcId,
-				_, _, _, _) - _ | _],
+				_, _, _, _, _) - _ | _],
 
 	%
 	% Find a renaming from the argument variables of the generalised
@@ -1249,7 +1253,7 @@
 	% Only fill in as much as pd_util__goals_match actually looks at.
 	goal_info_init(GoalInfo),
 	NonGeneralFirstGoal = call(NonGeneralisedPredId, 
-		NonGeneralisedProcId, NewArgs, not_builtin, 
+		NonGeneralisedProcId, NewArgs, [], not_builtin, 
 		no, unqualified("")) - GoalInfo,
 	deforest__create_conj(NonGeneralFirstGoal, BetweenGoals, LastGoal, 
 		ConjNonLocals, GoalToMatch),
Index: compiler/dependency_graph.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/dependency_graph.m,v
retrieving revision 1.51
diff -u -r1.51 dependency_graph.m
--- compiler/dependency_graph.m	2001/02/27 21:42:55	1.51
+++ compiler/dependency_graph.m	2001/03/12 15:35:44
@@ -310,7 +310,7 @@
 dependency_graph__add_arcs_in_goal_2(generic_call(_, _, _, _),
 		_Caller, DepGraph, DepGraph).
 
-dependency_graph__add_arcs_in_goal_2(call(PredId, ProcId, _, Builtin, _, _),
+dependency_graph__add_arcs_in_goal_2(call(PredId, ProcId, _, _, Builtin, _, _),
 			Caller, DepGraph0, DepGraph) :-
 	(
 		Builtin = inline_builtin
@@ -355,6 +355,9 @@
 	dependency_graph__add_arcs_in_list([LHS, RHS], Caller,
 			DepGraph0, DepGraph).
 
+dependency_graph__add_arcs_in_goal_2(edcg_goal(_, _, _), _, _, _) :-
+	error("dependency_graph__add_arcs_in_goal_2: unexpected edcg_goal").
+
 %-----------------------------------------------------------------------------%
 
 :- pred dependency_graph__add_arcs_in_list(list(hlds_goal), relation_key,
@@ -720,7 +723,7 @@
 	process_aditi_goal(IsNeg, Goal, Map0, Map).
 process_aditi_goal(_IsNeg, not(Goal) - _, Map0, Map) -->
 	process_aditi_goal(yes, Goal, Map0, Map).
-process_aditi_goal(IsNeg, call(PredId, ProcId, Args, _, _, _) - _, 
+process_aditi_goal(IsNeg, call(PredId, ProcId, Args, _, _, _, _) - _, 
 		Map0, Map) -->
 	aditi_scc_info_handle_call(IsNeg, PredId, ProcId, Args, Map0, Map).
 
@@ -742,6 +745,9 @@
 process_aditi_goal(_, bi_implication(_, _) - _, _, _) -->
 	% these should have been expanded out by now
 	{ error("process_aditi_goal: unexpected bi_implication") }.
+process_aditi_goal(_, edcg_goal(_, _, _) - _, _, _) -->
+	% these should have been expanded out by now
+	{ error("process_aditi_goal: unexpected edcg_goal") }.
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/det_analysis.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/det_analysis.m,v
retrieving revision 1.148
diff -u -r1.148 det_analysis.m
--- compiler/det_analysis.m	2000/11/17 17:47:03	1.148
+++ compiler/det_analysis.m	2001/03/12 15:35:44
@@ -454,9 +454,9 @@
 	% This is the point at which annotations start changing
 	% when we iterate to fixpoint for global determinism inference.
 
-det_infer_goal_2(call(PredId, ModeId0, A, B, C, N), GoalInfo, _, SolnContext,
+det_infer_goal_2(call(PredId, ModeId0, A, B, C, D, N), GoalInfo, _, SolnContext,
 		DetInfo, _, _,
-		call(PredId, ModeId, A, B, C, N), Detism, Msgs) :-
+		call(PredId, ModeId, A, B, C, D, N), Detism, Msgs) :-
 	det_lookup_detism(DetInfo, PredId, ModeId0, Detism0),
 	%
 	% Make sure we don't try to call a committed-choice pred
@@ -680,6 +680,10 @@
 det_infer_goal_2(bi_implication(_, _), _, _, _, _, _, _, _, _, _) :-
 	% these should have been expanded out by now
 	error("det_infer_goal_2: unexpected bi_implication").
+
+det_infer_goal_2(edcg_goal(_, _, _), _, _, _, _, _, _, _, _, _) :-
+	% these should have been expanded out by now
+	error("det_infer_goal_2: unexpected edcg_goal").
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/det_report.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/det_report.m,v
retrieving revision 1.65
diff -u -r1.65 det_report.m
--- compiler/det_report.m	2000/12/06 05:52:04	1.65
+++ compiler/det_report.m	2001/03/12 15:35:44
@@ -558,7 +558,7 @@
 		Diagnosed2),
 	{ bool__or(Diagnosed1, Diagnosed2, Diagnosed) }.
 
-det_diagnose_goal_2(call(PredId, ModeId, _, _, CallContext, _), GoalInfo,
+det_diagnose_goal_2(call(PredId, ModeId, _, _, _, CallContext, _), GoalInfo,
 		Desired, Actual, _, DetInfo, yes) -->
 	{ goal_info_get_context(GoalInfo, Context) },
 	det_diagnose_atomic_goal(Desired, Actual,
@@ -658,6 +658,10 @@
 det_diagnose_goal_2(bi_implication(_, _), _, _, _, _, _, _) -->
 	% these should have been expanded out by now
 	{ error("det_diagnose_goal_2: unexpected bi_implication") }.
+
+det_diagnose_goal_2(edcg_goal(_, _, _), _, _, _, _, _, _) -->
+	% these should have been expanded out by now
+	{ error("det_diagnose_goal_2: unexpected edcg_goal") }.
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/dnf.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/dnf.m,v
retrieving revision 1.42
diff -u -r1.42 dnf.m
--- compiler/dnf.m	2000/11/17 17:47:05	1.42
+++ compiler/dnf.m	2001/03/12 15:35:44
@@ -228,7 +228,7 @@
 		NewPredIds = NewPredIds0,
 		Goal = Goal0
 	;
-		GoalExpr0 = call(_, _, _, _, _, _),
+		GoalExpr0 = call(_, _, _, _, _, _, _),
 		ModuleInfo = ModuleInfo0,
 		NewPredIds = NewPredIds0,
 		Goal = Goal0
@@ -246,6 +246,10 @@
 		GoalExpr0 = bi_implication(_, _),
 		% these should have been expanded out by now
 		error("dnf__transform_goal: unexpected bi_implication")
+	;
+		GoalExpr0 = edcg_goal(_, _, _),
+		% these should have been expanded out by now
+		error("dnf__transform_goal: unexpected edcg_goal")
 	).
 
 %-----------------------------------------------------------------------------%
@@ -442,7 +446,7 @@
 	% in implied modes.
 dnf__is_atomic_expr(MaybeNonAtomic, _, _, conj([Call | Tests]), IsAtomic) :-
 	(
-		Call = call(_, _, _, _, _, _) - _,
+		Call = call(_, _, _, _, _, _, _) - _,
 		MaybeNonAtomic = yes(NonAtomic),	
 		dnf__goals_free_of_nonatomic(Tests, NonAtomic)
 	->
@@ -452,7 +456,7 @@
 	).
 dnf__is_atomic_expr(_, _, _, par_conj(_, _), no).
 dnf__is_atomic_expr(_, _, _, generic_call(_, _, _, _), yes).
-dnf__is_atomic_expr(_, _, _, call(_, _, _, _, _, _), yes).
+dnf__is_atomic_expr(_, _, _, call(_, _, _, _, _, _, _), yes).
 dnf__is_atomic_expr(_, _, _, switch(_, _, _, _), no).
 dnf__is_atomic_expr(_, _, _, unify(_, _, _, _, _), yes).
 dnf__is_atomic_expr(_, _, _, disj(_, _), no).
@@ -475,6 +479,8 @@
 dnf__is_atomic_expr(_, _, _, if_then_else(_, _, _, _, _), no).
 dnf__is_atomic_expr(_, _, _, pragma_foreign_code(_, _, _, _, _, _, _), yes).
 dnf__is_atomic_expr(_, _, _, bi_implication(_, _), no).
+dnf__is_atomic_expr(_, _, _, edcg_goal(_, _, _), _) :-
+        error("dnf__is_atomic_expr: unexpected edcg_goal").
 
 :- pred dnf__free_of_nonatomic(hlds_goal::in,
 	set(pred_proc_id)::in) is semidet.
@@ -483,7 +489,7 @@
 	dnf__goals_free_of_nonatomic(Goals, NonAtomic).
 dnf__free_of_nonatomic(par_conj(Goals, _) - _, NonAtomic) :-
 	dnf__goals_free_of_nonatomic(Goals, NonAtomic).
-dnf__free_of_nonatomic(call(PredId, ProcId, _, _, _, _) - _, NonAtomic) :-
+dnf__free_of_nonatomic(call(PredId, ProcId, _, _, _, _, _) - _, NonAtomic) :-
 	\+ set__member(proc(PredId, ProcId), NonAtomic).
 dnf__free_of_nonatomic(switch(_, _, Cases, _) - _, NonAtomic) :-
 	dnf__cases_free_of_nonatomic(Cases, NonAtomic).
Index: compiler/equiv_type.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/equiv_type.m,v
retrieving revision 1.24
diff -u -r1.24 equiv_type.m
--- compiler/equiv_type.m	2000/11/25 10:41:54	1.24
+++ compiler/equiv_type.m	2001/03/12 15:35:45
@@ -120,12 +120,16 @@
 	equiv_type__replace_in_type_defn(TypeDefn0, VarSet0, EqvMap,
 				TypeDefn, VarSet, ContainsCirc).
 
+equiv_type__replace_in_item(etype_defn(VarSet0, Name, etype_defn(Type0)),
+		EqvMap, etype_defn(VarSet, Name, etype_defn(Type)), no):-
+	equiv_type__replace_in_type(Type0, VarSet0, EqvMap, Type, VarSet).
+
 equiv_type__replace_in_item(
 		pred(TypeVarSet0, InstVarSet, ExistQVars, PredName,
-			TypesAndModes0, Det, Cond, Purity, ClassContext0),
+			TypesAndModes0, EDCGForms, Det, Cond, Purity, ClassContext0),
 		EqvMap,
 		pred(TypeVarSet, InstVarSet, ExistQVars, PredName,
-			TypesAndModes, Det, Cond, Purity, ClassContext),
+			TypesAndModes, EDCGForms, Det, Cond, Purity, ClassContext),
 		no) :-
 	equiv_type__replace_in_class_constraints(ClassContext0, TypeVarSet0, 
 				EqvMap, ClassContext, TypeVarSet1),
Index: compiler/excess.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/excess.m,v
retrieving revision 1.35
diff -u -r1.35 excess.m
--- compiler/excess.m	2000/11/17 17:47:06	1.35
+++ compiler/excess.m	2001/03/12 15:35:45
@@ -126,7 +126,7 @@
 		Goal = GoalExpr0 - GoalInfo0,
 		ElimVars = ElimVars0
 	;
-		GoalExpr0 = call(_, _, _, _, _, _),
+		GoalExpr0 = call(_, _, _, _, _, _, _),
 		Goal = GoalExpr0 - GoalInfo0,
 		ElimVars = ElimVars0
 	;
@@ -141,6 +141,10 @@
 		GoalExpr0 = bi_implication(_, _),
 		% these should have been expanded out by now
 		error("detect_cse_in_goal_2: unexpected bi_implication")
+	;
+		GoalExpr0 = edcg_goal(_, _, _),
+		% these should have been expanded out by now
+		error("detect_cse_in_goal_2: unexpected edcg_goal")
 	).
 
 %-----------------------------------------------------------------------------%
Index: compiler/follow_code.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/follow_code.m,v
retrieving revision 1.60
diff -u -r1.60 follow_code.m
--- compiler/follow_code.m	2000/11/17 17:47:08	1.60
+++ compiler/follow_code.m	2001/03/12 15:35:45
@@ -118,7 +118,7 @@
 move_follow_code_in_goal_2(generic_call(A,B,C,D),
 			generic_call(A,B,C,D), _, R, R).
 
-move_follow_code_in_goal_2(call(A,B,C,D,E,F), call(A,B,C,D,E,F), _, R, R).
+move_follow_code_in_goal_2(call(A,B,C,D,E,F,G), call(A,B,C,D,E,F,G), _, R, R).
 
 move_follow_code_in_goal_2(unify(A,B,C,D,E), unify(A,B,C,D,E), _, R, R).
 
@@ -129,6 +129,10 @@
 	% these should have been expanded out by now
 	error("move_follow_code_in_goal_2: unexpected bi_implication").
 
+move_follow_code_in_goal_2(edcg_goal(_, _, _), _, _, _, _) :-
+	% these should have been expanded out by now
+	error("move_follow_code_in_goal_2: unexpected edcg_goal").
+
 %-----------------------------------------------------------------------------%
 
 	% move_follow_code_in_disj is used both for disjunction and
@@ -315,7 +319,7 @@
 
 move_follow_code_is_builtin(unify(_, _, _, Unification, _) - _GoalInfo) :-
 	Unification \= complicated_unify(_, _, _).
-move_follow_code_is_builtin(call(_, _, _, Builtin, _, _) - _GoalInfo) :-
+move_follow_code_is_builtin(call(_, _, _, _, Builtin, _, _) - _GoalInfo) :-
 	Builtin = inline_builtin.
 
 %-----------------------------------------------------------------------------%
Index: compiler/follow_vars.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/follow_vars.m,v
retrieving revision 1.60
diff -u -r1.60 follow_vars.m
--- compiler/follow_vars.m	2000/11/23 04:32:35	1.60
+++ compiler/follow_vars.m	2001/03/12 15:35:45
@@ -211,6 +211,10 @@
 	% these should have been expanded out by now
 	error("find_follow_vars_in_goal_2: unexpected bi_implication").
 
+find_follow_vars_in_goal_expr(edcg_goal(_, _, _), _, _, _, _, _, _, _) :-
+	% these should have been expanded out by now
+	error("find_follow_vars_in_goal_2: unexpected edcg_goal").
+
 find_follow_vars_in_goal_expr(
 		generic_call(GenericCall, Args, Modes, Det),
 		VarTypes, ModuleInfo, _FollowVarsMap0, _NextNonReserved0,
@@ -233,9 +237,9 @@
 	find_follow_vars_from_sequence(EffInVars, FirstInput, FollowVarsMap1,
 		FollowVarsMap, NextNonReserved).
 
-find_follow_vars_in_goal_expr(call(PredId, ProcId, Args, State, E,F),
+find_follow_vars_in_goal_expr(call(PredId, ProcId, Args, D, State, F,G),
 		_, ModuleInfo, FollowVarsMap0, NextNonReserved0,
-		call(PredId, ProcId, Args, State, E,F),
+		call(PredId, ProcId, Args, D, State, F,G),
 		FollowVarsMap, NextNonReserved) :-
 	( State = inline_builtin ->
 		FollowVarsMap = FollowVarsMap0,
@@ -410,7 +414,7 @@
 	(
 		Goal0 = GoalExpr0 - _,
 		(
-			GoalExpr0 = call(_, _, _, BuiltinState, _, _),
+			GoalExpr0 = call(_, _, _, _, BuiltinState, _, _),
 			BuiltinState = inline_builtin
 		;
 			GoalExpr0 = unify(_, _, _, Unification, _),
Index: compiler/goal_path.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/goal_path.m,v
retrieving revision 1.12
diff -u -r1.12 goal_path.m
--- compiler/goal_path.m	2000/11/23 04:32:18	1.12
+++ compiler/goal_path.m	2001/03/12 15:35:45
@@ -85,7 +85,7 @@
 	fill_goal_slots(Cond0, [ite_cond | Path0], SlotInfo, Cond),
 	fill_goal_slots(Then0, [ite_then | Path0], SlotInfo, Then),
 	fill_goal_slots(Else0, [ite_else | Path0], SlotInfo, Else).
-fill_expr_slots(call(A,B,C,D,E,F), _, _, _, call(A,B,C,D,E,F)).
+fill_expr_slots(call(A,B,C,D,E,F,G), _, _, _, call(A,B,C,D,E,F,G)).
 fill_expr_slots(generic_call(A,B,C,D), _, _, _, generic_call(A,B,C,D)).
 fill_expr_slots(unify(A,B,C,D,E), _, _, _, unify(A,B,C,D,E)).
 fill_expr_slots(pragma_foreign_code(A,B,C,D,E,F,G), _, _, _,
@@ -93,6 +93,9 @@
 fill_expr_slots(bi_implication(_, _), _, _, _, _) :-
 	% these should have been expanded out by now
 	error("fill_expr_slots: unexpected bi_implication").
+fill_expr_slots(edcg_goal(_, _, _), _, _, _, _) :-
+	% these should have been expanded out by now
+	error("fill_expr_slots: unexpected edcg_goal").
 
 :- pred fill_conj_slots(list(hlds_goal)::in, goal_path::in, int::in,
 	slot_info::in, list(hlds_goal)::out) is det.
Index: compiler/goal_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/goal_util.m,v
retrieving revision 1.67
diff -u -r1.67 goal_util.m
--- compiler/goal_util.m	2000/11/17 17:47:11	1.67
+++ compiler/goal_util.m	2001/03/14 05:02:03
@@ -77,6 +77,10 @@
 :- pred goal_util__generic_call_vars(generic_call, list(prog_var)).
 :- mode goal_util__generic_call_vars(in, out) is det.
 
+	% Return all variables in the head of an edcg goal.
+:- pred goal_util__edcg_goal_head_vars(edcg_goal_info, list(prog_var)).
+:- mode goal_util__edcg_goal_head_vars(in, out) is det.
+
 	%
 	% goal_util__extra_nonlocal_typeinfos(TypeInfoMap, TypeClassInfoMap,
 	%		VarTypes, ExistQVars, NonLocals, NonLocalTypeInfos):
@@ -267,6 +271,17 @@
 	goal_util__rename_var(V, Must, Subn, N),
 	goal_util__rename_var_list(Vs, Must, Subn, Ns).
 
+:- pred goal_util__rename_edcg_var_list(
+	assoc_list(edcg_arg, list(prog_var)), bool, map(prog_var, prog_var),
+	assoc_list(edcg_arg, list(prog_var))).		
+:- mode goal_util__rename_edcg_var_list(in, in, in, out) is det.
+
+goal_util__rename_edcg_var_list([], _Must, _Subn, []).
+goal_util__rename_edcg_var_list([EDCGArg - Vars0 | Rest0], Must, Subn,
+		[EDCGArg - Vars | Rest]) :-
+	goal_util__rename_var_list(Vars0, Must, Subn, Vars),
+	goal_util__rename_edcg_var_list(Rest0, Must, Subn, Rest).
+
 :- pred goal_util__rename_var(var(V), bool, map(var(V), var(V)),
 		var(V)).
 :- mode goal_util__rename_var(in, in, in, out) is det.
@@ -362,10 +377,11 @@
 	goal_util__rename_var_list(Args0, Must, Subn, Args).
 
 goal_util__name_apart_2(
-		call(PredId, ProcId, Args0, Builtin, Context, Sym),
+		call(PredId, ProcId, Args0, EDCGArgs0, Builtin, Context, Sym),
 		Must, Subn,
-		call(PredId, ProcId, Args, Builtin, Context, Sym)) :-
-	goal_util__rename_var_list(Args0, Must, Subn, Args).
+		call(PredId, ProcId, Args, EDCGArgs, Builtin, Context, Sym)) :-
+	goal_util__rename_var_list(Args0, Must, Subn, Args),
+	goal_util__rename_edcg_var_list(EDCGArgs0, Must, Subn, EDCGArgs).
 
 goal_util__name_apart_2(unify(TermL0,TermR0,Mode,Unify0,Context), Must, Subn,
 		unify(TermL,TermR,Mode,Unify,Context)) :-
@@ -382,6 +398,31 @@
 	goal_util__rename_vars_in_goal(LHS0, Must, Subn, LHS),
 	goal_util__rename_vars_in_goal(RHS0, Must, Subn, RHS).
 
+goal_util__name_apart_2(edcg_goal(EdcgGoalInfo0, Inferred, Goal0), Must, Subn,
+		edcg_goal(EdcgGoalInfo, Inferred, Goal)) :-
+	goal_util__rename_vars_in_goal(Goal0, Must, Subn, Goal),
+	goal_util__rename_edcg_goal_head(EdcgGoalInfo0, Must, Subn,
+		EdcgGoalInfo).
+
+:- pred goal_util__rename_edcg_goal_head(edcg_goal_info, bool, 
+		map(prog_var, prog_var), edcg_goal_info).
+:- mode goal_util__rename_edcg_goal_head(in, in, in, out) is det.
+
+goal_util__rename_edcg_goal_head([], _, _, []).
+goal_util__rename_edcg_goal_head([EDCGArg - changed(Var10, Var20) | Rest0],
+		Must, Subn, [EDCGArg - changed(Var1, Var2) | Rest]) :-
+	goal_util__rename_var(Var10, Must, Subn, Var1),
+	goal_util__rename_var(Var20, Must, Subn, Var2),
+	goal_util__rename_edcg_goal_head(Rest0, Must, Subn, Rest).
+goal_util__rename_edcg_goal_head([EDCGArg - passed(Var0) | Rest0],
+		Must, Subn, [EDCGArg - passed(Var) | Rest]) :-
+	goal_util__rename_var(Var0, Must, Subn, Var),
+	goal_util__rename_edcg_goal_head(Rest0, Must, Subn, Rest).
+goal_util__rename_edcg_goal_head([EDCGArg - produced(Var0) | Rest0],
+		Must, Subn, [EDCGArg - produced(Var) | Rest]) :-
+	goal_util__rename_var(Var0, Must, Subn, Var),
+	goal_util__rename_edcg_goal_head(Rest0, Must, Subn, Rest).
+
 %-----------------------------------------------------------------------------%
 
 :- pred goal_util__name_apart_list(list(hlds_goal), bool,
@@ -416,6 +457,8 @@
 goal_util__rename_unify_rhs(functor(Functor, ArgVars0), Must, Subn,
 			functor(Functor, ArgVars)) :-
 	goal_util__rename_var_list(ArgVars0, Must, Subn, ArgVars).
+goal_util__rename_unify_rhs(edcg_op(B, C), _Must, _Subn, 
+		edcg_op(B, C)).
 goal_util__rename_unify_rhs(
 	    lambda_goal(PredOrFunc, EvalMethod, FixModes, NonLocals0,
 	    		Vars0, Modes, Det, Goal0),
@@ -581,8 +624,11 @@
 	set__insert_list(Set0, Vars0, Set1),
 	set__insert_list(Set1, ArgVars, Set).
 
-goal_util__goal_vars_2(call(_, _, ArgVars, _, _, _), Set0, Set) :-
-	set__insert_list(Set0, ArgVars, Set).
+goal_util__goal_vars_2(call(_, _, ArgVars, EDCGArgVars, _, _, _), Set0, Set) :-
+	set__insert_list(Set0, ArgVars, Set1),
+	assoc_list__values(EDCGArgVars, EDCGVars0),
+	list__condense(EDCGVars0, EDCGVars),
+	set__insert_list(Set1, EDCGVars, Set).
 
 goal_util__goal_vars_2(conj(Goals), Set0, Set) :-
 	goal_util__goals_goal_vars(Goals, Set0, Set).
@@ -618,6 +664,11 @@
 	goal_util__goal_vars_2(LHS, Set0, Set1),
 	goal_util__goal_vars_2(RHS, Set1, Set).
 
+goal_util__goal_vars_2(edcg_goal(EDCGArgs0, _, Goal - _), Set0, Set) :-
+	goal_util__edcg_goal_head_vars(EDCGArgs0, EDCGVars),
+	set__insert_list(Set0, EDCGVars, Set1),
+	goal_util__goal_vars_2(Goal, Set1, Set).
+
 goal_util__goals_goal_vars([], Set, Set).
 goal_util__goals_goal_vars([Goal - _ | Goals], Set0, Set) :-
 	goal_util__goal_vars_2(Goal, Set0, Set1),
@@ -638,6 +689,7 @@
 	set__insert(Set0, X, Set).
 goal_util__rhs_goal_vars(functor(_Functor, ArgVars), Set0, Set) :-
 	set__insert_list(Set0, ArgVars, Set).
+goal_util__rhs_goal_vars(edcg_op(_, _), Set, Set).
 goal_util__rhs_goal_vars(
 		lambda_goal(_, _, _, NonLocals, LambdaVars, _M, _D, Goal - _), 
 		Set0, Set) :-
@@ -649,6 +701,22 @@
 goal_util__generic_call_vars(class_method(Var, _, _, _), [Var]).
 goal_util__generic_call_vars(aditi_builtin(_, _), []).
 
+goal_util__edcg_goal_head_vars(FormVars, Vars) :-
+	goal_util__edcg_goal_head_vars_2(FormVars, [], Vars).
+
+:- pred goal_util__edcg_goal_head_vars_2(edcg_goal_info, list(prog_var), 
+		list(prog_var)).
+:- mode goal_util__edcg_goal_head_vars_2(in, in, out) is det.
+
+goal_util__edcg_goal_head_vars_2([_ - changed(Var1, Var2)|FormVars], 
+		Vars0, Vars) :-
+	goal_util__edcg_goal_head_vars_2(FormVars, Var1.Var2.Vars0, Vars).
+goal_util__edcg_goal_head_vars_2([_ - passed(Var)|FormVars], Vars0, Vars) :-
+	goal_util__edcg_goal_head_vars_2(FormVars, Var.Vars0, Vars).
+goal_util__edcg_goal_head_vars_2([_ - produced(Var)|FormVars], Vars0, Vars) :-
+	goal_util__edcg_goal_head_vars_2(FormVars, Var.Vars0, Vars).
+goal_util__edcg_goal_head_vars_2([], Vars, Vars).
+
 %-----------------------------------------------------------------------------%
 
 goal_util__extra_nonlocal_typeinfos(TypeVarMap, TypeClassVarMap, VarTypes,
@@ -705,7 +773,7 @@
 clause_list_size(Clauses, GoalSize) :-
 	GetClauseSize =
 		(pred(Clause::in, Size0::in, Size::out) is det :-
-			Clause = clause(_, ClauseGoal, _),
+			Clause = clause(_, ClauseGoal, _, _),
 			goal_size(ClauseGoal, ClauseSize),
 			Size = Size0 + ClauseSize
 		),
@@ -751,7 +819,7 @@
 goal_expr_size(some(_, _, Goal), Size) :-
 	goal_size(Goal, Size1),
 	Size is Size1 + 1.
-goal_expr_size(call(_, _, _, _, _, _), 1).
+goal_expr_size(call(_, _, _, _, _, _, _), 1).
 goal_expr_size(generic_call(_, _, _, _), 1).
 goal_expr_size(unify(_, _, _, _, _), 1).
 goal_expr_size(pragma_foreign_code(_, _, _, _, _, _, _), 1).
@@ -759,6 +827,9 @@
 	goal_size(LHS, Size1),
 	goal_size(RHS, Size2),
 	Size is Size1 + Size2 + 1.
+goal_expr_size(edcg_goal(_, _, Goal), Size) :-
+	goal_size(Goal, Size1),
+	Size is Size1 + 1.
 
 %-----------------------------------------------------------------------------%
 %
@@ -817,8 +888,10 @@
 goal_expr_calls(not(Goal), PredProcId) :-
 	goal_calls(Goal, PredProcId).
 goal_expr_calls(some(_, _, Goal), PredProcId) :-
+	goal_calls(Goal, PredProcId).
+goal_expr_calls(call(PredId, ProcId, _, _, _, _, _), proc(PredId, ProcId)).
+goal_expr_calls(edcg_goal(_, _, Goal), PredProcId) :-
 	goal_calls(Goal, PredProcId).
-goal_expr_calls(call(PredId, ProcId, _, _, _, _), proc(PredId, ProcId)).
 
 %-----------------------------------------------------------------------------%
 %
@@ -878,7 +951,7 @@
 	goal_calls_pred_id(Goal, PredId).
 goal_expr_calls_pred_id(some(_, _, Goal), PredId) :-
 	goal_calls_pred_id(Goal, PredId).
-goal_expr_calls_pred_id(call(PredId, _, _, _, _, _), PredId).
+goal_expr_calls_pred_id(call(PredId, _, _, _, _, _, _), PredId).
 
 %-----------------------------------------------------------------------------%
  
Index: compiler/higher_order.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/higher_order.m,v
retrieving revision 1.83
diff -u -r1.83 higher_order.m
--- compiler/higher_order.m	2000/12/11 04:52:24	1.83
+++ compiler/higher_order.m	2001/03/14 05:56:09
@@ -475,7 +475,7 @@
 
 		% check whether this call could be specialized
 traverse_goal_2(Goal0, Goal) -->
-	{ Goal0 = call(_,_,_,_,_,_) - _ },
+	{ Goal0 = call(_,_,_,_,_,_,_) - _ },
 	maybe_specialize_call(Goal0, Goal).
 
 		% if-then-elses are handled as disjunctions
@@ -510,6 +510,10 @@
 	% these should have been expanded out by now
 	{ error("traverse_goal_2: unexpected bi_implication") }.
 
+traverse_goal_2(edcg_goal(_, _, _) - _, _) -->
+	% these should have been expanded out by now
+	{ error("traverse_goal_2: unexpected edcg_goal") }.
+
 		% To process a disjunction, we process each disjunct with the
 		% specialization information before the goal, then merge the
 		% results to give the specialization information after the
@@ -984,7 +988,7 @@
 	instmap_delta_insert(InstMapDelta0, ResultVar,
 		ground(shared, none), InstMapDelta),
 	goal_info_init(NonLocals, InstMapDelta, det, GoalInfo),
-	CallGoal = call(PredId, ProcId, CallArgs, not_builtin,
+	CallGoal = call(PredId, ProcId, CallArgs, [], not_builtin,
 		MaybeContext, SymName) - GoalInfo,
 	get_typeclass_info_args_2(TypeClassInfoVar, PredId, ProcId, SymName,
 		MakeResultType, Args, Index + 1, Goals, Vars,
@@ -1005,7 +1009,8 @@
 	code_util__builtin_state(ModuleInfo, PredId, ProcId, Builtin),
 
 	MaybeContext = no,
-	Goal1 = call(PredId, ProcId, AllArgs, Builtin, MaybeContext, SymName),
+	Goal1 = call(PredId, ProcId, AllArgs, [], Builtin, MaybeContext, 
+			SymName),
 	higher_order_info_update_changed_status(changed, Info0, Info1),
 	maybe_specialize_call(Goal1 - GoalInfo, Goal - _, Info1, Info).
 
@@ -1017,9 +1022,9 @@
 	Info0 = info(PredVars, Requests0, NewPreds, PredProcId,
 			PredInfo0, ProcInfo0, Module0, Params, Changed0),
 	(
-		Goal0 = call(_, _, _, _, _, _)
+		Goal0 = call(_, _, _, _, _, _, _)
 	->
-		Goal0 = call(CalledPred, CalledProc, Args0, IsBuiltin,
+		Goal0 = call(CalledPred, CalledProc, Args0, EDCGArgs, IsBuiltin,
 					MaybeContext, _SymName0)
 	;
 		error("higher_order.m: call expected")
@@ -1134,7 +1139,8 @@
 
 				list__append(ExtraTypeInfoVars, Args1, Args),
 				CallGoal = call(NewCalledPred, NewCalledProc,
-					Args, IsBuiltin, MaybeContext, NewName),
+					Args, EDCGArgs, IsBuiltin, MaybeContext,
+					NewName),
 				list__append(ExtraTypeInfoGoals,
 					[CallGoal - GoalInfo], GoalList),
 				Goal = conj(GoalList),
@@ -1793,7 +1799,7 @@
 				NeedIntCast = no,
 				NewCallArgs = [ComparisonResult, Arg1, Arg2],
 				Goal = call(SpecialPredId, SpecialProcId,
-					NewCallArgs, not_builtin,
+					NewCallArgs, [], not_builtin,
 					MaybeContext, SymName),
 				Info = Info0
 			;
@@ -1807,7 +1813,7 @@
 				NewCallArgs = [ComparisonResult,
 					CastArg1, CastArg2],
 				Call = call(SpecialPredId, SpecialProcId,
-					NewCallArgs, not_builtin,
+					NewCallArgs, [], not_builtin,
 					MaybeContext, SymName),
 				set__list_to_set([ComparisonResult,
 					Arg1, Arg2], NonLocals),
@@ -1896,7 +1902,7 @@
 					UnwrappedArg1, UnwrappedArg2],
 				SpecialGoal = call(SpecialPredId,
 					SpecialProcId, NewCallArgs,
-					not_builtin, MaybeContext, SymName),
+					[], not_builtin, MaybeContext, SymName),
 				goal_info_init(NonLocals, InstMapDelta, Detism,
 					GoalInfo),
 				Goal = conj([ExtractGoal1, ExtractGoal2,
@@ -1914,7 +1920,7 @@
 					CastArg1, CastArg2],
 				SpecialGoal = call(SpecialPredId,
 					SpecialProcId, NewCallArgs,
-					not_builtin, MaybeContext, SymName),
+					[], not_builtin, MaybeContext, SymName),
 				goal_info_init(NonLocals, InstMapDelta, Detism,
 					GoalInfo),
 				Goal = conj([ExtractGoal1, CastGoal1,
@@ -1938,7 +1944,7 @@
 			list__append(TypeInfoArgs, SpecialPredArgs, CallArgs)
 		),
 		Goal = call(SpecialPredId, SpecialProcId, CallArgs,
-			not_builtin, MaybeContext, SymName)
+			[], not_builtin, MaybeContext, SymName)
 	).
 
 :- pred find_special_proc((type)::in, special_pred_id::in, sym_name::out,
@@ -2067,7 +2073,7 @@
 	instmap_delta_from_assoc_list([CastArg - ground(shared, none)],
 		InstMapDelta),
 	goal_info_init(NonLocals, InstMapDelta, det, GoalInfo),
-	Goal = call(PredId, ProcId, [Arg, CastArg], inline_builtin,
+	Goal = call(PredId, ProcId, [Arg, CastArg], [], inline_builtin,
 		no, qualified(MercuryBuiltin, "unsafe_type_cast")) - GoalInfo.
 
 :- pred unwrap_no_tag_arg((type)::in, sym_name::in, prog_var::in,
Index: compiler/hlds_goal.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_goal.m,v
retrieving revision 1.85
diff -u -r1.85 hlds_goal.m
--- compiler/hlds_goal.m	2001/03/13 12:40:09	1.85
+++ compiler/hlds_goal.m	2001/03/14 13:45:15
@@ -14,7 +14,7 @@
 
 :- import_module hlds_data, hlds_pred, prog_data, (inst), instmap.
 :- import_module llds.	% XXX needed for `lval'
-:- import_module bool, char, list, set, map, std_util.
+:- import_module bool, char, list, set, map, std_util, assoc_list.
 
 %-----------------------------------------------------------------------------%
 
@@ -43,6 +43,7 @@
 			pred_id,	% which predicate are we calling?
 			proc_id,	% which mode of the predicate?
 			list(prog_var),	% the list of argument variables
+			edcgs,	% the list of edcg argument variables
 			builtin_state,	% is the predicate builtin, and if yes,
 					% do we generate inline code for it?
 			maybe(call_unify_context),
@@ -205,9 +206,14 @@
 		% then the quantification would be wrong.
 
 	;	bi_implication(hlds_goal, hlds_goal)
-
+	; 	edcg_goal(
+			edcg_goal_info, % goal head edcg forms and vars
+			edcg_forms,	% inferred goal head edcg forms
+			hlds_goal
+		)
 	.
 
+
 %-----------------------------------------------------------------------------%
 %
 % Information for generic_calls
@@ -291,6 +297,7 @@
 :- type unify_rhs
 	--->	var(prog_var)
 	;	functor(cons_id, list(prog_var))
+	;	edcg_op(edcg_arg, edcg_operator)
 	;	lambda_goal(
 			pred_or_func, 
 			lambda_eval_method,
@@ -462,7 +469,10 @@
 	;	call(
 			call_id,	% the name and arity of the predicate
 			int		% the argument number (first arg == 1)
-		).
+		)
+	;
+		edcg_goal
+	.
 
 	% A unify_sub_context describes the location of sub-unification
 	% (which is unifying one argument of a term)
@@ -550,6 +560,34 @@
 
 %-----------------------------------------------------------------------------%
 %
+% Information for edcg arguments
+%
+
+:- type edcg_goal_info == assoc_list(edcg_arg, form_var).
+
+:- type edcg_operator
+	--->	current
+	;	next.
+
+:- type form_var
+	--->	changed(prog_var, prog_var)
+	;	passed(prog_var)
+	;	produced(prog_var).
+
+:- type edcgs		== assoc_list(edcg_arg, list(prog_var)).
+
+:- pred edcg_operator_to_string(edcg_operator, string).
+:- mode edcg_operator_to_string(in, out) is det.
+:- mode edcg_operator_to_string(out, in) is semidet.
+
+:- type atomic_goal_id == int.
+
+:- pred init_atomic_goal_id(atomic_goal_id::out) is det.
+
+:- pred new_atomic_goal_id(atomic_goal_id::in, atomic_goal_id::out) is det.
+
+%-----------------------------------------------------------------------------%
+%
 % Information for all kinds of goals
 %
 
@@ -674,6 +712,12 @@
 :- pred goal_info_set_goal_path(hlds_goal_info, goal_path, hlds_goal_info).
 :- mode goal_info_set_goal_path(in, in, out) is det.
 
+:- pred goal_info_get_atomic_goal_id(hlds_goal_info, atomic_goal_id).
+:- mode goal_info_get_atomic_goal_id(in, out) is det.
+
+:- pred goal_info_set_atomic_goal_id(hlds_goal_info, atomic_goal_id, hlds_goal_info).
+:- mode goal_info_set_atomic_goal_id(in, in, out) is det.
+
 :- pred goal_get_nonlocals(hlds_goal, set(prog_var)).
 :- mode goal_get_nonlocals(in, out) is det.
 
@@ -686,7 +730,6 @@
 :- pred goal_info_resume_vars_and_loc(resume_point, set(prog_var), resume_locs).
 :- mode goal_info_resume_vars_and_loc(in, out, out) is det.
 
-
 :- type goal_feature
 	--->	constraint	% This is included if the goal is
 				% a constraint.  See constraint.m
@@ -856,6 +899,13 @@
 			unify_main_context, unify_sub_contexts, hlds_goal).
 :- mode create_atomic_unification(in, in, in, in, in, out) is det.
 
+	% Create the hlds_goal for a unification, filling in all the as yet
+	% unknown slots with dummy values.
+:- pred create_atomic_unification(prog_var, unify_rhs, prog_context,
+			unify_main_context, unify_sub_contexts, atomic_goal_id,
+			hlds_goal).
+:- mode create_atomic_unification(in, in, in, in, in, in, out) is det.
+
 	%
 	% Produce a goal to construct a given constant.
 	% These predicates all fill in the non-locals, instmap_delta
@@ -1104,7 +1154,7 @@
 :- implementation.
 
 :- import_module det_analysis, prog_util, type_util.
-:- import_module require, string, term, varset.
+:- import_module int, require, string, term, varset.
 
 %-----------------------------------------------------------------------------%
 %
@@ -1130,6 +1180,19 @@
 
 %-----------------------------------------------------------------------------%
 %
+% Information for edcg arguments
+%
+
+edcg_operator_to_string(current, "$").
+edcg_operator_to_string(next, "$=").
+
+init_atomic_goal_id(0).
+
+new_atomic_goal_id(Id0, Id) :-
+	Id is Id0 + 1.
+
+%-----------------------------------------------------------------------------%
+%
 % Information stored with all kinds of goals
 %
 
@@ -1224,9 +1287,16 @@
 				% labels of the resumption point will be
 				% needed. (See compiler/notes/allocation.html)
 
-		goal_path :: goal_path
+		goal_path :: goal_path,
 				% The path to this goal from the root in
 				% reverse order.
+
+		atomic_goal_id :: atomic_goal_id
+				% Each atomic goal needs to have its own unique
+				% identifier for EDCG expansion. The identifier
+				% indicates which atomic goal the goal
+				% originated from. For non-atomic goals the
+				% value has no meaning.
 	).
 
 
@@ -1240,9 +1310,10 @@
 	set__init(NonLocals),
 	term__context_init(Context),
 	set__init(Features),
+	init_atomic_goal_id(Id),
 	GoalInfo = goal_info(PreBirths, PostBirths, PreDeaths, PostDeaths,
 		Detism, InstMapDelta, Context, NonLocals, no, Features,
-		no_resume_point, []).
+		no_resume_point, [], Id).
 
 goal_info_init(Context, GoalInfo) :-
 	goal_info_init(GoalInfo0),
@@ -1283,6 +1354,8 @@
 
 goal_info_get_goal_path(GoalInfo, GoalInfo ^ goal_path).
 
+goal_info_get_atomic_goal_id(GoalInfo0, GoalInfo0 ^ atomic_goal_id).
+
 goal_info_set_pre_births(GoalInfo0, PreBirths,
 		GoalInfo0 ^ pre_births := PreBirths).
 
@@ -1322,6 +1395,9 @@
 goal_info_set_goal_path(GoalInfo0, GoalPath,
 		GoalInfo0 ^ goal_path := GoalPath).
 
+goal_info_set_atomic_goal_id(GoalInfo0, Id, 
+		GoalInfo0 ^ atomic_goal_id := Id).
+
 goal_info_add_feature(GoalInfo0, Feature, GoalInfo) :-
 	goal_info_get_features(GoalInfo0, Features0),
 	set__insert(Features0, Feature, Features),
@@ -1487,7 +1563,7 @@
 		GoalExpr = conj(Goals),
 		HasForeign = goal_list_has_foreign(Goals)
 	;
-		GoalExpr = call(_, _, _, _, _, _),
+		GoalExpr = call(_, _, _, _, _, _, _),
 		HasForeign = no
 	;
 		GoalExpr = generic_call(_, _, _, _),
@@ -1533,6 +1609,9 @@
 		->	yes
 		;	no
 		)
+	;
+		GoalExpr = edcg_goal(_, _, Goal2),
+		HasForeign = goal_has_foreign(Goal2)
 	).
 
 goal_list_has_foreign([]) = no.
@@ -1548,7 +1627,7 @@
 goal_is_atomic(conj([])).
 goal_is_atomic(disj([], _)).
 goal_is_atomic(generic_call(_,_,_,_)).
-goal_is_atomic(call(_,_,_,_,_,_)).
+goal_is_atomic(call(_,_,_,_,_,_,_)).
 goal_is_atomic(unify(_,_,_,_,_)).
 goal_is_atomic(pragma_foreign_code(_,_,_,_,_,_,_)).
 
@@ -1639,7 +1718,7 @@
 set_goal_contexts_2(Context, not(Goal0), not(Goal)) :-
 	set_goal_contexts(Context, Goal0, Goal).	
 set_goal_contexts_2(_, Goal, Goal) :-
-	Goal = call(_, _, _, _, _, _).
+	Goal = call(_, _, _, _, _, _, _).
 set_goal_contexts_2(_, Goal, Goal) :-
 	Goal = generic_call(_, _, _, _).
 set_goal_contexts_2(_, Goal, Goal) :-
@@ -1650,16 +1729,26 @@
 		bi_implication(LHS, RHS)) :-
 	set_goal_contexts(Context, LHS0, LHS),
 	set_goal_contexts(Context, RHS0, RHS).
+set_goal_contexts_2(Context, edcg_goal(A, B, Goal0),
+		edcg_goal(A, B, Goal)) :-
+	set_goal_contexts(Context, Goal0, Goal).
 
 %-----------------------------------------------------------------------------%
 
 create_atomic_unification(A, B, Context, UnifyMainContext, UnifySubContext,
 		Goal) :-
+	init_atomic_goal_id(GoalId),
+	create_atomic_unification(A, B, Context, UnifyMainContext,
+		UnifySubContext, GoalId, Goal).
+
+create_atomic_unification(A, B, Context, UnifyMainContext, UnifySubContext,
+		GoalId, Goal) :-
 	UMode = ((free - free) -> (free - free)),
 	Mode = ((free -> free) - (free -> free)),
 	UnifyInfo = complicated_unify(UMode, can_fail, []),
 	UnifyC = unify_context(UnifyMainContext, UnifySubContext),
-	goal_info_init(Context, GoalInfo),
+	goal_info_init(Context, GoalInfo0),
+	goal_info_set_atomic_goal_id(GoalInfo0, GoalId, GoalInfo),
 	Goal = unify(A, B, Mode, UnifyInfo, UnifyC) - GoalInfo.
 
 %-----------------------------------------------------------------------------%
Index: compiler/hlds_module.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_module.m,v
retrieving revision 1.65
diff -u -r1.65 hlds_module.m
--- compiler/hlds_module.m	2001/02/27 21:42:55	1.65
+++ compiler/hlds_module.m	2001/03/14 12:53:16
@@ -30,7 +30,7 @@
 
 :- import_module hlds_out, prog_out, prog_util.
 :- import_module typecheck, modules.
-:- import_module bool, require, int, string.
+:- import_module bool, require, int, string, assoc_list.
 
 %-----------------------------------------------------------------------------%
 
@@ -183,6 +183,12 @@
 :- pred module_info_set_instances(module_info, instance_table, module_info).
 :- mode module_info_set_instances(in, in, out) is det.
 
+:- pred module_info_edcgs(module_info, edcg_table).
+:- mode module_info_edcgs(in, out) is det.
+
+:- pred module_info_set_edcgs(module_info, edcg_table, module_info).
+:- mode module_info_set_edcgs(in, in, out) is det.
+
 :- pred module_info_superclasses(module_info, superclass_table).
 :- mode module_info_superclasses(in, out) is det.
 
@@ -478,6 +484,7 @@
 		superclass_table ::		superclass_table,
 		assertion_table ::		assertion_table,
 		ctor_field_table ::		ctor_field_table,
+		edcg_table ::			edcg_table,
 		cell_counter ::			counter
 					% cell count, passed into code_info
 					% and used to generate unique label
@@ -557,6 +564,7 @@
 
 	map__init(ClassTable),
 	map__init(InstanceTable),
+	edcg_table_init(EDCGTable),
 	map__init(SuperClassTable),
 
 	% the builtin modules are automatically imported
@@ -575,7 +583,7 @@
 	ModuleInfo = module(ModuleSubInfo, PredicateTable, Requests,
 		UnifyPredMap, QualifierInfo, Types, Insts, Modes, Ctors,
 		ClassTable, SuperClassTable, InstanceTable, AssertionTable,
-		FieldNameTable, counter__init(1)).
+		FieldNameTable, EDCGTable, counter__init(1)).
 
 %-----------------------------------------------------------------------------%
 
@@ -594,6 +602,7 @@
 module_info_superclasses(MI, MI ^ superclass_table).
 module_info_assertion_table(MI, MI ^ assertion_table).
 module_info_ctor_field_table(MI, MI ^ ctor_field_table).
+module_info_edcgs(MI, MI ^ edcg_table).
 module_info_get_cell_counter(MI, MI ^ cell_counter).
 
 %-----------------------------------------------------------------------------%
@@ -614,6 +623,7 @@
 module_info_set_superclasses(MI, S, MI ^ superclass_table := S).
 module_info_set_assertion_table(MI, A, MI ^ assertion_table := A).
 module_info_set_ctor_field_table(MI, CF, MI ^ ctor_field_table := CF).
+module_info_set_edcgs(MI, EDCGTable, MI ^ edcg_table := EDCGTable).
 module_info_set_cell_counter(MI, CC, MI ^ cell_counter := CC).
 
 %-----------------------------------------------------------------------------%
@@ -982,6 +992,11 @@
 :- pred predicate_table_optimize(predicate_table, predicate_table).
 :- mode predicate_table_optimize(in, out) is det.
 
+	% Get pred_info for a particular pred_id.
+
+:- pred predicate_table_pred_info(predicate_table, pred_id, pred_info).
+:- mode predicate_table_pred_info(in, in, out) is det.
+
 	% Get the pred_id->pred_info map.
 
 :- pred predicate_table_get_preds(predicate_table, pred_table).
@@ -1257,6 +1272,18 @@
 				Pred_N_Index, Pred_NA_Index, Pred_MNA_Index,
 				Func_N_Index, Func_NA_Index, Func_MNA_Index).
 
+predicate_table_pred_info(PredicateTable, PredId, PredInfo) :-
+		predicate_table_get_preds(PredicateTable, Preds),
+		( map__search(Preds, PredId, PredInfoPrime) ->
+			PredInfo = PredInfoPrime
+		;
+			pred_id_to_int(PredId, PredInt),
+			string__int_to_string(PredInt, PredStr),
+			string__append("cannot find predicate number ",
+				PredStr, Msg),
+			error(Msg)
+		).
+
 predicate_table_get_preds(PredicateTable, Preds) :-
 	PredicateTable = predicate_table(Preds, _, _, _, _, _, _, _, _).
 
@@ -1279,17 +1306,31 @@
 	map__det_remove(Preds0, PredId, PredInfo, Preds),
 	pred_info_module(PredInfo, Module),
 	pred_info_name(PredInfo, Name),
-	pred_info_arity(PredInfo, Arity),
+	pred_info_arity(PredInfo, TotalArity),
 	pred_info_get_is_pred_or_func(PredInfo, IsPredOrFunc),
 	(
 		IsPredOrFunc = predicate,
-		predicate_table_remove_from_index(Module, Name, Arity, PredId,
-			PredN0, PredN, PredNA0, PredNA, PredMNA0, PredMNA),
+		predicate_table_remove_from_index(Module, Name, TotalArity,
+			PredId, PredN0, PredN1, PredNA0, PredNA1, PredMNA0,
+			PredMNA1),
+		pred_info_visual_arity(PredInfo, VisualArity),
+		(
+			TotalArity = VisualArity
+		->
+			PredN = PredN1,
+			PredNA = PredNA1,
+			PredMNA = PredMNA1
+		;
+			% Remove predicate with visual arity.
+			predicate_table_remove_from_index(Module, Name,
+				VisualArity, PredId, PredN1, PredN, PredNA1,
+				PredNA, PredMNA1, PredMNA)
+		),
 		PredicateTable = predicate_table(Preds, NextPredId, PredIds, 
 			PredN, PredNA, PredMNA, FuncN0, FuncNA0, FuncMNA0)
 	;
 		IsPredOrFunc = function,
-		FuncArity is Arity - 1,
+		FuncArity is TotalArity - 1,
 		predicate_table_remove_from_index(Module, Name, FuncArity, 
 			PredId, FuncN0, FuncN, FuncNA0, FuncNA, 
 			FuncMNA0, FuncMNA),
@@ -1623,7 +1664,8 @@
 				Func_N_Index0, Func_NA_Index0, Func_MNA_Index0),
 	pred_info_module(PredInfo, Module),
 	pred_info_name(PredInfo, Name),
-	pred_info_arity(PredInfo, Arity),
+	pred_info_arity(PredInfo, TotalArity),
+	pred_info_visual_arity(PredInfo, VisualArity),
 
 		% allocate a new pred_id
 	PredId = NextPredId0,
@@ -1634,11 +1676,24 @@
 	pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
 	( 
 		PredOrFunc = predicate,
-		predicate_table_do_insert(Module, Name, Arity,
+		predicate_table_do_insert(Module, Name, TotalArity,
 			NeedQual, MaybeQualInfo, PredId,
-			Pred_N_Index0, Pred_N_Index, 
-			Pred_NA_Index0, Pred_NA_Index,
-			Pred_MNA_Index0, Pred_MNA_Index),
+			Pred_N_Index0, Pred_N_Index1, 
+			Pred_NA_Index0, Pred_NA_Index1,
+			Pred_MNA_Index0, Pred_MNA_Index1),
+		(
+			TotalArity = VisualArity
+		->
+			Pred_N_Index = Pred_N_Index1,
+			Pred_NA_Index = Pred_NA_Index1,
+			Pred_MNA_Index = Pred_MNA_Index1
+		;
+			predicate_table_do_insert(Module, Name, VisualArity,
+				NeedQual, MaybeQualInfo, PredId,
+				Pred_N_Index1, Pred_N_Index,
+				Pred_NA_Index1, Pred_NA_Index,
+				Pred_MNA_Index1, Pred_MNA_Index)
+		),
 
 		Func_N_Index = Func_N_Index0,
 		Func_NA_Index = Func_NA_Index0,
@@ -1646,7 +1701,7 @@
 	;
 		PredOrFunc = function,
 
-		FuncArity is Arity - 1,
+		FuncArity is TotalArity - 1,
 
 		predicate_table_do_insert(Module, Name, FuncArity,
 			NeedQual, MaybeQualInfo, PredId,
@@ -1827,3 +1882,118 @@
 	pred_info_arity(PredInfo, Arity).
 
 %-----------------------------------------------------------------------------%
+
+:- interface.  
+
+	% Predicates to manipulate the edcg_table data structure
+
+:- type edcg_table.
+
+:- type etype_info      ==      pair(etype_defn, term__context).
+:- type emode_info      ==      pair(emode_defn, term__context).
+
+:- type etype_table     ==      map(edcg_arg, etype_info).
+:- type emode_table     ==      map(edcg_arg, emode_info).
+
+:- type  etype_or_emode
+	--->    edcg_type
+	;       edcg_mode.
+
+	% Assumes that etype declaration does not already exist.
+:- pred edcg_table_add_etype(edcg_table, edcg_arg, etype_defn, term__context,
+		edcg_table).
+:- mode edcg_table_add_etype(in, in, in, in, out) is det.
+
+	% Assumes that emode declaration does not already exist.
+:- pred edcg_table_add_emode(edcg_table, edcg_arg, emode_defn, term__context,
+		edcg_table).
+:- mode edcg_table_add_emode(in, in, in, in, out) is det.
+
+:- pred edcg_table_fetch_edcg_type(edcg_arg, edcg_table, type).
+:- mode edcg_table_fetch_edcg_type(in, in, out) is det.
+
+:- pred edcg_table_fetch_edcg_mode(edcg_arg, form, edcg_table,
+		list(mode)).
+:- mode edcg_table_fetch_edcg_mode(in, in, in, out) is semidet.
+
+:- pred edcg_table_fetch_context(edcg_table, edcg_arg, etype_or_emode,
+		term__context).
+:- mode edcg_table_fetch_context(in, in, in, out) is semidet.
+
+:- pred etype_or_emode_to_string(etype_or_emode::in, string::out) is det.
+
+:- pred edcg_table_get_etype_table(edcg_table, etype_table).
+:- mode edcg_table_get_etype_table(in, out) is det.
+
+%-----------------------------------------------------------------------------%
+
+:- implementation.
+
+:- type edcg_table
+	---> edcg_table(etype_table, emode_table).
+
+:- pred edcg_table_init(edcg_table::out) is det.
+
+edcg_table_init(edcg_table(HtypeTable, HmodeTable)) :-
+	map__init(HtypeTable),
+	map__init(HmodeTable).
+
+edcg_table_add_etype(EDCGTable0, EDCGArg, HtypeDefn, Context,
+		EDCGTable) :-
+	edcg_table_get_etype_table(EDCGTable0, HtypeTable0),
+	map__set(HtypeTable0, EDCGArg, HtypeDefn - Context, HtypeTable),
+	edcg_table_set_etype_table(EDCGTable0, HtypeTable, EDCGTable).
+
+edcg_table_add_emode(EDCGTable0, EDCGArg, HmodeDefn, Context,
+		EDCGTable) :-
+	edcg_table_get_emode_table(EDCGTable0, HmodeTable0),
+	map__set(HmodeTable0, EDCGArg, HmodeDefn - Context, HmodeTable),
+	edcg_table_set_emode_table(EDCGTable0, HmodeTable, EDCGTable).
+
+edcg_table_fetch_edcg_type(EDCGArg, EDCGTable,  Type) :-
+	edcg_table_get_etype_table(EDCGTable, HtypeTable),
+	(
+		map__search(HtypeTable, EDCGArg, etype_defn(Type0) - _)
+	->
+		Type0 = Type
+	;
+		error("edcg_table_get_etype_table: EDCG argument not found.")
+	).
+
+edcg_table_fetch_edcg_mode(EDCGArg, Form, EDCGTable,
+		ModeList) :-
+	edcg_table_get_emode_table(EDCGTable, HmodeTable),
+	map__search(HmodeTable, EDCGArg, HmodeDefn - _),
+	get_edcg_modes(Form, HmodeDefn, ModeList).
+
+edcg_table_fetch_context(EDCGTable, EDCGArg, edcg_mode,
+		Context) :-
+	edcg_table_get_emode_table(EDCGTable, HmodeTable),
+       	map__search(HmodeTable, EDCGArg, _ - Context).
+
+edcg_table_fetch_context(EDCGTable, EDCGArg, edcg_type,
+		Context) :-
+	edcg_table_get_etype_table(EDCGTable, HtypeTable),
+	map__search(HtypeTable, EDCGArg, _ - Context).
+
+etype_or_emode_to_string(edcg_type, "etype").
+etype_or_emode_to_string(edcg_mode, "emode").
+
+edcg_table_get_etype_table(edcg_table(HtypeTable,_), HtypeTable).
+
+:- pred edcg_table_get_emode_table(edcg_table, emode_table).
+:- mode edcg_table_get_emode_table(in, out) is det.
+
+edcg_table_get_emode_table(edcg_table(_,HmodeTable), HmodeTable).
+
+:- pred edcg_table_set_etype_table(edcg_table, etype_table, edcg_table).
+:- mode edcg_table_set_etype_table(in, in, out) is det.
+
+edcg_table_set_etype_table(edcg_table(_,B), HtypeTable,
+		edcg_table(HtypeTable,B)).
+
+:- pred edcg_table_set_emode_table(edcg_table, emode_table, edcg_table).
+:- mode edcg_table_set_emode_table(in, in, out) is det.
+
+edcg_table_set_emode_table(edcg_table(A,_), HmodeTable,
+		edcg_table(A,HmodeTable)).
Index: compiler/hlds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_out.m,v
retrieving revision 1.255
diff -u -r1.255 hlds_out.m
--- compiler/hlds_out.m	2001/03/05 10:30:59	1.255
+++ compiler/hlds_out.m	2001/03/14 13:57:28
@@ -251,7 +251,7 @@
 
 % HLDS modules.
 :- import_module mercury_to_mercury, purity, special_pred, instmap.
-:- import_module termination, term_errors, check_typeclass.
+:- import_module termination, term_errors, check_typeclass, edcg.
 
 % RL back-end modules (XXX should avoid using those here).
 :- import_module rl.
@@ -592,6 +592,10 @@
 	hlds_out__write_call_arg_id(CallId, ArgNum, Markers),
 	io__write_string(":\n").
 
+hlds_out__write_unify_main_context(First, edcg_goal, Context, no) -->
+	hlds_out__start_in_message(First, Context),
+	io__write_string("EDCG goal head:\n").
+
 :- pred hlds_out__write_unify_sub_contexts(bool, unify_sub_contexts,
 	prog_context, bool, io__state, io__state).
 :- mode hlds_out__write_unify_sub_contexts(in, in, in, out, di, uo) is det.
@@ -912,7 +916,7 @@
 	io__write_list(HeadVars, ", ", PrintVar),
 	io__write_string("] (\n"),
 
-	{ Clause = clause(_Modes, Goal, _Context) },
+	{ Clause = clause(_Modes, Goal, _, _Context) },
 	hlds_out__write_goal_a(Goal, ModuleInfo, VarSet, AppendVarnums,
 			Indent+1, ").\n", TypeQual).
 
@@ -939,6 +943,7 @@
 		Clause = clause(
 			Modes,
 			Goal,
+			MaybeEdcg,
 			_Context
 		),
 		Indent1 is Indent + 1
@@ -959,7 +964,13 @@
 	( { Goal = conj([]) - _GoalInfo } ->
 		io__write_string(".\n")
 	;
-		io__write_string(" :-\n"),
+		(
+			{ MaybeEdcg = edcg_yes }
+		->
+			io__write_string(" -->>\n")
+		;
+			io__write_string(" :-\n")
+		),
 		hlds_out__write_goal_a(Goal, ModuleInfo, VarSet, AppendVarnums,
 			Indent1, ".\n", TypeQual)
 	).
@@ -1451,7 +1462,7 @@
 		ArgVars, VarSet, AppendVarnums, Indent, Follow)
     ).
 
-hlds_out__write_goal_2(call(PredId, ProcId, ArgVars, Builtin,
+hlds_out__write_goal_2(call(PredId, ProcId, ArgVars, EDCGArgVars, Builtin,
 			MaybeUnifyContext, PredName),
 		ModuleInfo, VarSet, AppendVarnums, Indent, Follow, TypeQual) -->
 	globals__io_lookup_string_option(dump_hlds_options, Verbose),
@@ -1492,6 +1503,7 @@
 	),
 	hlds_out__write_sym_name_and_args(PredName, NewArgVars, VarSet,
 			AppendVarnums),
+	hlds_out__write_edcg_call(EDCGArgVars, VarSet, AppendVarnums),
 	io__write_string(Follow),
 	( { string__contains_char(Verbose, 'l') } ->
 		{ pred_id_to_int(PredId, PredNum) },
@@ -1635,6 +1647,101 @@
 	io__write_string(")"),
 	io__write_string(Follow).
 
+hlds_out__write_goal_2(edcg_goal(EdcgGoalInfo, _Inferred, EdcgGoal), 
+		ModuleInfo, VarSet, AppendVarnums, Indent, Follow, TypeQual) -->
+	hlds_out__write_edcg_goal(EdcgGoalInfo, EdcgGoal, ModuleInfo, VarSet,	
+		AppendVarnums, Indent, Follow, TypeQual).
+
+:- pred hlds_out__write_edcg_call(assoc_list(edcg_arg, list(prog_var)),
+		prog_varset, bool, io__state, io__state).
+:- mode hlds_out__write_edcg_call(in, in, in, di, uo) is det.
+
+hlds_out__write_edcg_call([], _, _) --> [].
+hlds_out__write_edcg_call([EDCGArg - Vars | Rest], VarSet, AppendVarnums)
+		-->
+	io__write_string("+edcg("),
+	hlds_out__write_edcg_call_2([EDCGArg - Vars | Rest], VarSet, 
+		AppendVarnums),
+	io__write_string(")").
+
+:- pred hlds_out__write_edcg_call_2(assoc_list(edcg_arg, list(prog_var)),
+		prog_varset, bool, io__state, io__state).
+:- mode hlds_out__write_edcg_call_2(in, in, in, di, uo) is det.
+
+hlds_out__write_edcg_call_2([], _, _) --> [].
+hlds_out__write_edcg_call_2([EDCGArg - Vars], VarSet, AppendVarnums) -->
+	hlds_out__write_sym_name_and_args(EDCGArg, Vars, VarSet, 
+		AppendVarnums).
+hlds_out__write_edcg_call_2([EDCGArg0 - Vars0, EDCGArg1 - Vars1 | Rest],
+		VarSet, AppendVarnums) -->
+	hlds_out__write_sym_name_and_args(EDCGArg0, Vars0, VarSet, 
+		AppendVarnums),
+	io__write_string(", "),
+	hlds_out__write_edcg_call_2([EDCGArg1 - Vars1 | Rest], VarSet,
+		AppendVarnums).
+
+:- pred hlds_out__write_edcg_goal(edcg_goal_info, hlds_goal, 
+		module_info, prog_varset, bool, int, string, maybe_vartypes,
+		io__state, io__state).
+:- mode hlds_out__write_edcg_goal(in, in, in, in, in, in, in, in, 
+		di, uo) is det.
+
+hlds_out__write_edcg_goal(EdcgGoalInfos, Goal, ModuleInfo, VarSet, 
+		AppendVarnums, Indent0, Follow, TypeQual)  -->
+	hlds_out__write_indent(Indent0),
+	io__write_string("(\n"),
+	{ Indent is Indent0 + 1 },
+	hlds_out__write_edcg_goal_head(EdcgGoalInfos, VarSet, AppendVarnums,
+		Indent, Follow),
+	hlds_out__write_indent(Indent0),
+	io__write_string("-->>\n"),
+	hlds_out__write_goal_a(Goal, ModuleInfo, VarSet, AppendVarnums,
+		Indent, Follow, TypeQual),
+	hlds_out__write_indent(Indent0),
+	io__write_string(")\n").
+
+:- pred hlds_out__write_edcg_goal_head(edcg_goal_info, prog_varset, bool,
+		int, string, io__state, io__state).
+:- mode hlds_out__write_edcg_goal_head(in, in, in, in, in, di, uo) is det.
+
+hlds_out__write_edcg_goal_head([], _, _, _, _) --> [].
+hlds_out__write_edcg_goal_head([EdcgGoalInfo], VarSet, AppendVarnums, 
+		Indent, Follow) -->
+	hlds_out__write_indent(Indent),
+	hlds_out__write_edcg_goal_info(EdcgGoalInfo, VarSet, AppendVarnums),
+	io__write_string(Follow).
+hlds_out__write_edcg_goal_head([EdcgGoalInfo1,EdcgGoalInfo2|Rest], 
+		VarSet, AppendVarnums, Indent, Follow) -->
+	hlds_out__write_indent(Indent),
+	hlds_out__write_edcg_goal_info(EdcgGoalInfo1, VarSet, AppendVarnums),
+	io__write_string(","),
+	io__write_string(Follow),
+	hlds_out__write_edcg_goal_head([EdcgGoalInfo2|Rest], VarSet,
+		AppendVarnums, Indent, Follow).
+
+:- pred hlds_out__write_edcg_goal_info(pair(edcg_arg, form_var),
+		prog_varset, bool, io__state, io__state).
+:- mode hlds_out__write_edcg_goal_info(in, in, in, di, uo) is det.
+
+hlds_out__write_edcg_goal_info(EDCGArg - changed(Var1, Var2), VarSet,
+		AppendVarnums) -->
+	prog_out__write_sym_name(EDCGArg),
+	io__write_string(" is "),
+	hlds_out__write_sym_name_and_args(unqualified("changed"), [Var1, Var2],
+		VarSet, AppendVarnums).
+hlds_out__write_edcg_goal_info(EDCGArg - passed(Var), VarSet, 
+		AppendVarnums) -->
+	prog_out__write_sym_name(EDCGArg),
+	io__write_string(" is "),
+	hlds_out__write_sym_name_and_args(unqualified("passed"), [Var],
+		VarSet, AppendVarnums).
+hlds_out__write_edcg_goal_info(EDCGArg - produced(Var), VarSet, 
+		AppendVarnums) -->
+	prog_out__write_sym_name(EDCGArg),
+	io__write_string(" is "),
+	hlds_out__write_sym_name_and_args(unqualified("produced"), [Var],
+		VarSet, AppendVarnums).
+
 :- pred hlds_out__write_varnum_list(list(prog_var), io__state, io__state).
 :- mode hlds_out__write_varnum_list(in, di, uo) is det.
 
@@ -1911,7 +2018,10 @@
 	;
 		[]
 	).
-
+hlds_out__write_unify_rhs_3(edcg_op(EDCGArg, Op), _, _, _, _, _, _, _) -->
+	{ edcg_operator_to_string(Op, OpString) },
+	io__write_string(OpString),
+	mercury_output_bracketed_sym_name(EDCGArg).
 hlds_out__write_unify_rhs_3(
 		lambda_goal(PredOrFunc, EvalMethod, _, NonLocals, Vars, Modes,
 		Det, Goal),

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