[m-rev.] diff/for review: using pred origins to fix bad purity error messages

Zoltan Somogyi zs at cs.mu.OZ.AU
Fri Jan 21 17:22:11 AEDT 2005


The diff is mostly quite boring, but I would welcome feedback on the new
naming scheme for lambda and other compiler-generated predicates in the
debugger. (The names seen by the linker haven't changed at all.)

Some updates of .exp2 files will come later, after bootchecks in other grades.

Zoltan.

Get the purity check pass to not issue warnings about unnecessary purity
annotations on compiler-generated predicates. The problem I am addressing
is that when an optimization such as type specialization creates a clone of
a predicate, that predicate gets all the original predicate's annotations.
During the creation of a .opt file, purity checking sees the clauses of the
original predicate and knows that the annotation is not redundant, but doesn't
know that about the copy, since it has no definition at all (it doesn't need
one).

The fix is to put into each pred_info an indication of where the predicate
came from, and to never warn about unnecessary purity annotations of predicates
that the programmer didn't write.

This diff also uses the origin indication to record human-usable names of
compiler-generated or compiler-transformed predicates in RTTI for use by the
debugger.

compiler/hlds_pred.m:
	Replace two fields in pred_infos, that say (a) whether the predicate
	is a special (unify/compare/index/init) predicate and (b) whether
	it is a type class method implementation, with an origin field saying
	where the predicate came from. This field has several alternatives,
	special preds and type class method implementation being only two.

	Make the predicates that create pred_infos take an argument specifing
	where the predicate comes from.

	Replace a copy of one of the old fields in rtti_proc_labels with
	the new one.

	Make the name of the existing function more descriptive.

compiler/purity.m:
	Use the origin field to suppress unnecessary annotation warnings for
	compiler-generated predicates.

compiler/layout_out.m:
	Use the origin field to generate more human-friendly names for
	predicates, instead of the existing linker-friendly names. The
	debugger doesn't insist on predicate names being unique, even
	within a module.

compiler/*.m:
	Conform to the changed interface of hlds_pred.m. The most significant
	changes were for recording the origin of new predicates. In one case
	(dnf.m) it also involved passing the required information down to the
	place where the new predicates were created through the dnf_info tuple
	instead of separate arguments, and switching to state variable
	notation.

tests/debugger/*.exp*:
tests/debugger/declarative/*.exp*:
tests/hard_coded/*.exp*:
	Update the expected outputs to expect human-friendly predicate names.

cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/accumulator.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/accumulator.m,v
retrieving revision 1.35
diff -u -b -r1.35 accumulator.m
--- compiler/accumulator.m	19 Jan 2005 03:10:28 -0000	1.35
+++ compiler/accumulator.m	19 Jan 2005 04:52:41 -0000
@@ -373,7 +373,7 @@
 	identify_recursive_calls(PredId, ProcId, C, RecCallIds),
 	M = list__length(Rec),
 	attempt_transform_2(RecCallIds, C, M, Rec, HeadVars, InitialInstMap,
-		TopLevel, DoLCO, FullyStrict, PredInfo,
+		TopLevel, DoLCO, FullyStrict, PredId, PredInfo,
 		!ProcInfo, !ModuleInfo, Warnings).
 
 	%
@@ -390,11 +390,12 @@
 	%
 :- pred attempt_transform_2(list(goal_id)::in, goal_store::in, int::in,
 	hlds_goals::in, prog_vars::in, instmap::in, top_level::in,
-	bool::in, bool::in, pred_info::in, proc_info::in, proc_info::out,
-	module_info::in, module_info::out, warnings::out) is semidet.
+	bool::in, bool::in, pred_id::in, pred_info::in,
+	proc_info::in, proc_info::out, module_info::in, module_info::out,
+	warnings::out) is semidet.
 
 attempt_transform_2([Id | Ids], C, M, Rec, HeadVars, InitialInstMap, TopLevel,
-		DoLCO, FullyStrict, PredInfo, !ProcInfo, !ModuleInfo,
+		DoLCO, FullyStrict, PredId, PredInfo, !ProcInfo, !ModuleInfo,
 		Warnings) :-
 	(
 		proc_info_vartypes(!.ProcInfo, VarTypes0),
@@ -406,17 +407,16 @@
 		stage2(Id, C, Sets, OutPrime, Out, !.ModuleInfo, !.ProcInfo,
 			VarSet, VarTypes, Accs, BaseCase, BasePairs,
 			Substs, CS, Warnings0),
-
 		stage3(Id, Accs, VarSet, VarTypes, C, CS, Substs,
 			HeadToCallSubst, CallToHeadSubst,
-			BaseCase, BasePairs, Sets, TopLevel, PredInfo,
-			!ProcInfo, !ModuleInfo)
+			BaseCase, BasePairs, Sets, Out, TopLevel,
+			PredId, PredInfo, !ProcInfo, !ModuleInfo)
 	->
 		Warnings = Warnings0
 	;
 		attempt_transform_2(Ids, C, M, Rec, HeadVars, InitialInstMap,
 			TopLevel, DoLCO, FullyStrict,
-			PredInfo, !ProcInfo, !ModuleInfo, Warnings)
+			PredId, PredInfo, !ProcInfo, !ModuleInfo, Warnings)
 	).
 
 %-----------------------------------------------------------------------------%
@@ -1137,7 +1137,7 @@
 
 stage2(N - K, GoalStore, Sets, OutPrime, Out, ModuleInfo, ProcInfo0,
 		!:VarSet, !:VarTypes, Accs, BaseCase, BasePairs,
-		Substs, CS, Warnings) :-
+		!:Substs, CS, Warnings) :-
 	Sets = sets(Before0, Assoc, ConstructAssoc, Construct, Update, _),
 	Before = Before0 `union` set_upto(N, K-1),
 
@@ -1162,15 +1162,14 @@
 	proc_info_vartypes(ProcInfo0, !:VarTypes),
 
 	substs_init(set__to_sorted_list(InitAccs), !VarSet, !VarTypes,
-		Substs0),
+		!:Substs),
+
+	set__list_to_set(OutPrime, OutPrimeSet),
+	process_assoc_set(set__to_sorted_list(Assoc), GoalStore, OutPrimeSet,
+		ModuleInfo, !Substs, !VarSet, !VarTypes, CS, Warnings),
 
-	process_assoc_set(set__to_sorted_list(Assoc), GoalStore,
-		set__list_to_set(OutPrime), ModuleInfo, Substs0, Substs1,
-		!VarSet, !VarTypes, CS, Warnings),
-
-	process_update_set(set__to_sorted_list(Update), GoalStore,
-		set__list_to_set(OutPrime), ModuleInfo,
-		Substs1, Substs, !VarSet, !VarTypes, UpdateOut,
+	process_update_set(set__to_sorted_list(Update), GoalStore, OutPrimeSet,
+		ModuleInfo, !Substs, !VarSet, !VarTypes, UpdateOut,
 		UpdateAccOut, BasePairs),
 
 	Accs = set__to_sorted_list(InitAccs) `append` UpdateAccOut,
@@ -1280,7 +1279,7 @@
 		module_info_pred_info(ModuleInfo, PredId, PredInfo),
 		ModuleName = pred_info_module(PredInfo),
 		PredName = pred_info_name(PredInfo),
-		Arity = pred_info_arity(PredInfo),
+		Arity = pred_info_orig_arity(PredInfo),
 		(
 			has_heuristic(ModuleName, PredName, Arity)
 		->
@@ -1488,17 +1487,19 @@
 :- pred stage3(goal_id::in, prog_vars::in, prog_varset::in, vartypes::in,
 	goal_store::in, goal_store::in, substs::in, subst::in,
 	subst::in, base::in, list(pair(prog_var))::in, sets::in,
-	top_level::in, pred_info::in, proc_info::in, proc_info::out,
-	module_info::in, module_info::out) is det.
+	prog_vars::in, top_level::in, pred_id::in, pred_info::in,
+	proc_info::in, proc_info::out, module_info::in, module_info::out)
+	is det.
 
 stage3(RecCallId, Accs, VarSet, VarTypes, C, CS, Substs,
 		HeadToCallSubst, CallToHeadSubst, BaseCase, BasePairs,
-		Sets, TopLevel, OrigPredInfo, !OrigProcInfo, !ModuleInfo) :-
+		Sets, Out, TopLevel, OrigPredId, OrigPredInfo, !OrigProcInfo,
+		!ModuleInfo) :-
 
 	acc_proc_info(Accs, VarSet, VarTypes, Substs, !.OrigProcInfo,
 		AccTypes, AccProcInfo),
-	acc_pred_info(AccTypes, AccProcInfo, OrigPredInfo, AccProcId,
-		AccPredInfo),
+	acc_pred_info(AccTypes, Out, AccProcInfo, OrigPredId, OrigPredInfo,
+		AccProcId, AccPredInfo),
 	AccName = unqualified(pred_info_name(AccPredInfo)),
 
 	module_info_get_predicate_table(!.ModuleInfo, PredTable0),
@@ -1578,21 +1579,23 @@
 	%
 	% Construct the pred_info for the introduced predicate
 	%
-:- pred acc_pred_info(list(type)::in, proc_info::in, pred_info::in,
-		proc_id::out, pred_info::out) is det.
+:- pred acc_pred_info(list(type)::in, prog_vars::in, proc_info::in,
+	pred_id::in, pred_info::in, proc_id::out, pred_info::out) is det.
 
-acc_pred_info(NewTypes, NewProcInfo, PredInfo, NewProcId, NewPredInfo) :-
+acc_pred_info(NewTypes, OutVars, NewProcInfo, OrigPredId, OrigPredInfo,
+		NewProcId, NewPredInfo) :-
 
 		% PredInfo stuff that must change.
-	pred_info_arg_types(PredInfo, TypeVarSet, ExistQVars, Types0),
+	pred_info_arg_types(OrigPredInfo, TypeVarSet, ExistQVars, Types0),
 
-	ModuleName = pred_info_module(PredInfo),
-	Name = pred_info_name(PredInfo),
-	PredOrFunc = pred_info_is_pred_or_func(PredInfo),
-	pred_info_context(PredInfo, PredContext),
-	pred_info_get_markers(PredInfo, Markers),
-	pred_info_get_class_context(PredInfo, ClassContext),
-	pred_info_get_aditi_owner(PredInfo, Owner),
+	ModuleName = pred_info_module(OrigPredInfo),
+	Name = pred_info_name(OrigPredInfo),
+	PredOrFunc = pred_info_is_pred_or_func(OrigPredInfo),
+	pred_info_context(OrigPredInfo, PredContext),
+	pred_info_get_markers(OrigPredInfo, Markers),
+	pred_info_get_class_context(OrigPredInfo, ClassContext),
+	pred_info_get_aditi_owner(OrigPredInfo, Owner),
+	pred_info_get_origin(OrigPredInfo, OldOrigin),
 
 	set__init(Assertions),
 
@@ -1605,7 +1608,9 @@
 	make_pred_name_with_context(ModuleName, "AccFrom", PredOrFunc, Name,
 		Line, Counter, SymName),
 
-	pred_info_create(ModuleName, SymName, PredOrFunc, PredContext,
+	OutVarNums = list__map(term__var_to_int, OutVars),
+	Origin = transformed(accumulator(OutVarNums), OldOrigin, OrigPredId),
+	pred_info_create(ModuleName, SymName, PredOrFunc, PredContext, Origin,
 		local, Markers, Types, TypeVarSet, ExistQVars, ClassContext,
 		Assertions, Owner, NewProcInfo, NewProcId, NewPredInfo).
 
Index: compiler/assertion.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/assertion.m,v
retrieving revision 1.32
diff -u -b -r1.32 assertion.m
--- compiler/assertion.m	21 Jan 2005 03:27:34 -0000	1.32
+++ compiler/assertion.m	21 Jan 2005 03:34:48 -0000
@@ -735,7 +735,7 @@
 	( is_defined_in_implementation_section(ImportStatus) = yes ->
 		goal_info_get_context(GoalInfo, Context),
 		PredOrFunc = pred_info_is_pred_or_func(CallPredInfo),
-		Arity = pred_info_arity(CallPredInfo),
+		Arity = pred_info_orig_arity(CallPredInfo),
 		write_assertion_interface_error(Context,
 			call(PredOrFunc, SymName, Arity), !Module, !IO)
 	;
@@ -757,7 +757,7 @@
 		PredOrFunc = pred_info_is_pred_or_func(PragmaPredInfo),
 		Name = pred_info_name(PragmaPredInfo),
 		SymName = unqualified(Name),
-		Arity = pred_info_arity(PragmaPredInfo),
+		Arity = pred_info_orig_arity(PragmaPredInfo),
 		write_assertion_interface_error(Context,
 			call(PredOrFunc, SymName, Arity), !Module, !IO)
 	;
Index: compiler/bytecode_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/bytecode_gen.m,v
retrieving revision 1.86
diff -u -b -r1.86 bytecode_gen.m
--- compiler/bytecode_gen.m	21 Jan 2005 03:27:35 -0000	1.86
+++ compiler/bytecode_gen.m	21 Jan 2005 03:34:48 -0000
@@ -83,7 +83,7 @@
 			ProcsCode, !IO),
 		predicate_name(ModuleInfo, PredId, PredName),
 		list__length(ProcIds, ProcsCount),
-		Arity = pred_info_arity(PredInfo),
+		Arity = pred_info_orig_arity(PredInfo),
 		bytecode_gen__get_is_func(PredInfo, IsFunc),
 		EnterCode = node([enter_pred(PredName, Arity, IsFunc,
 			ProcsCount)]),
Index: compiler/check_typeclass.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/check_typeclass.m,v
retrieving revision 1.61
diff -u -b -r1.61 check_typeclass.m
--- compiler/check_typeclass.m	19 Jan 2005 05:52:59 -0000	1.61
+++ compiler/check_typeclass.m	21 Jan 2005 03:34:48 -0000
@@ -428,7 +428,7 @@
 	MethodName0 = pred_info_name(PredInfo),
 	PredModule = pred_info_module(PredInfo),
 	MethodName = qualified(PredModule, MethodName0),
-	PredArity = pred_info_arity(PredInfo),
+	PredArity = pred_info_orig_arity(PredInfo),
 	PredOrFunc = pred_info_is_pred_or_func(PredInfo),
 	adjust_func_arity(PredOrFunc, Arity, PredArity),
 	pred_info_procedures(PredInfo, ProcTable),
@@ -723,20 +723,16 @@
 		PredArity, ArgTypes, Markers, Context, Status, ClausesInfo,
 		ModuleInfo0, ModuleInfo1, QualInfo0, QualInfo, !IO),
 
-	pred_info_init(InstanceModuleName, PredName, PredArity, PredOrFunc,
-		Context, Status, none, Markers,
-		ArgTypes, ArgTypeVars, ExistQVars, ClassContext, Proofs,
-		User, ClausesInfo, PredInfo0),
-	pred_info_set_clauses_info(ClausesInfo, PredInfo0, PredInfo1),
-
 	% Fill in some information in the pred_info which is
 	% used by polymorphism to make sure the type-infos
 	% and typeclass-infos are added in the correct order.
 	MethodConstraints = instance_method_constraints(ClassId,
-			InstanceTypes, InstanceConstraints,
-			ClassMethodClassContext),
-	pred_info_set_maybe_instance_method_constraints(
-		yes(MethodConstraints), PredInfo1, PredInfo2),
+		InstanceTypes, InstanceConstraints, ClassMethodClassContext),
+	pred_info_init(InstanceModuleName, PredName, PredArity, PredOrFunc,
+		Context, instance_method(MethodConstraints), Status, none,
+		Markers, ArgTypes, ArgTypeVars, ExistQVars, ClassContext,
+		Proofs, User, ClausesInfo, PredInfo0),
+	pred_info_set_clauses_info(ClausesInfo, PredInfo0, PredInfo1),
 
 		% Add procs with the expected modes and determinisms
 	AddProc = (pred(ModeAndDet::in, NewProcId::out,
@@ -747,7 +743,7 @@
 			OldPredInfo, NewPredInfo, NewProcId)
 	),
 	list__map_foldl(AddProc, ArgModes, InstanceProcIds,
-		PredInfo2, PredInfo),
+		PredInfo1, PredInfo),
 
 	module_info_get_predicate_table(ModuleInfo1, PredicateTable1),
 	module_info_get_partial_qualifier_info(ModuleInfo1, PQInfo),
Index: compiler/clause_to_proc.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/clause_to_proc.m,v
retrieving revision 1.44
diff -u -b -r1.44 clause_to_proc.m
--- compiler/clause_to_proc.m	19 Jan 2005 03:10:29 -0000	1.44
+++ compiler/clause_to_proc.m	19 Jan 2005 04:52:42 -0000
@@ -85,7 +85,7 @@
 		% for this function.  (N.B. functions which can
 		% fail must be explicitly declared as semidet.)
 		%
-		PredArity = pred_info_arity(PredInfo0),
+		PredArity = pred_info_orig_arity(PredInfo0),
 		FuncArity = PredArity - 1,
 		in_mode(InMode),
 		out_mode(OutMode),
Index: compiler/code_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/code_gen.m,v
retrieving revision 1.133
diff -u -b -r1.133 code_gen.m
--- compiler/code_gen.m	19 Jan 2005 03:10:29 -0000	1.133
+++ compiler/code_gen.m	19 Jan 2005 04:52:43 -0000
@@ -379,7 +379,7 @@
 		ProcLabel, !GlobalData),
 
 	Name = pred_info_name(PredInfo),
-	Arity = pred_info_arity(PredInfo),
+	Arity = pred_info_orig_arity(PredInfo),
 
 	code_info__get_label_counter(CodeInfo, LabelCounter),
 	(
@@ -425,7 +425,7 @@
 	(
 		PredModule = pred_info_module(PredInfo),
 		PredName = pred_info_name(PredInfo),
-		PredArity = pred_info_arity(PredInfo),
+		PredArity = pred_info_orig_arity(PredInfo),
 		no_type_info_builtin(PredModule, PredName, PredArity)
 	->
 			% These predicates should never be traced,
@@ -436,13 +436,11 @@
 		globals__set_trace_level_none(Globals0, Globals1),
 		module_info_set_globals(Globals1, !ModuleInfo)
 	;
-		pred_info_get_maybe_special_pred(PredInfo, yes(_)),
+		pred_info_get_origin(PredInfo, special_pred(_)),
 		globals__get_trace_level(Globals0, TraceLevel),
-		UC_TraceLevel =
-			trace_level_for_unify_compare(TraceLevel)
+		UC_TraceLevel = trace_level_for_unify_compare(TraceLevel)
 	->
-		globals__set_trace_level(UC_TraceLevel,
-			Globals0, Globals1),
+		globals__set_trace_level(UC_TraceLevel, Globals0, Globals1),
 		module_info_set_globals(Globals1, !ModuleInfo)
 	;
 		true
@@ -830,7 +828,7 @@
 	module_info_pred_info(ModuleInfo, PredId, PredInfo),
 	ModuleName = pred_info_module(PredInfo),
 	PredName = pred_info_name(PredInfo),
-	Arity = pred_info_arity(PredInfo),
+	Arity = pred_info_orig_arity(PredInfo),
 
 	PushMsg = code_gen__push_msg(ModuleInfo, PredId, ProcId),
 	( CodeModel = model_non ->
@@ -1402,7 +1400,7 @@
 	PredName = pred_info_name(PredInfo),
 	proc_id_to_int(ProcId, ProcNum),
 	string__int_to_string(ProcNum, ProcStr),
-	Arity = pred_info_arity(PredInfo),
+	Arity = pred_info_orig_arity(PredInfo),
 	int_to_string(Arity, ArityStr),
 	PredOrFunc = pred_info_is_pred_or_func(PredInfo),
 
@@ -1452,9 +1450,9 @@
 	PredOrFunc = pred_info_is_pred_or_func(PredInfo),
 	ModuleName = pred_info_module(PredInfo),
 	PredName = pred_info_name(PredInfo),
-	Arity = pred_info_arity(PredInfo),
-	pred_info_get_maybe_special_pred(PredInfo, MaybeSpecial),
-	( MaybeSpecial = yes(SpecialId - TypeCtor) ->
+	Arity = pred_info_orig_arity(PredInfo),
+	pred_info_get_origin(PredInfo, Origin),
+	( Origin = special_pred(SpecialId - TypeCtor) ->
 		code_gen__find_arg_type_ctor_name(TypeCtor, TypeName),
 		special_pred_name_arity(SpecialId, SpecialPredName, _),
 		string__append_list([SpecialPredName, "_for_", TypeName],
Index: compiler/dead_proc_elim.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/dead_proc_elim.m,v
retrieving revision 1.94
diff -u -b -r1.94 dead_proc_elim.m
--- compiler/dead_proc_elim.m	19 Jan 2005 03:10:31 -0000	1.94
+++ compiler/dead_proc_elim.m	19 Jan 2005 04:52:43 -0000
@@ -792,7 +792,7 @@
 	(
 		PredModule = pred_info_module(PredInfo),
 		PredName = pred_info_name(PredInfo),
-		PredArity = pred_info_arity(PredInfo),
+		PredArity = pred_info_orig_arity(PredInfo),
 		(
 			% Don't eliminate special preds since they won't
 			% be actually called from the HLDS until after
Index: compiler/deforest.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/deforest.m,v
retrieving revision 1.42
diff -u -b -r1.42 deforest.m
--- compiler/deforest.m	19 Jan 2005 03:10:31 -0000	1.42
+++ compiler/deforest.m	19 Jan 2005 04:52:44 -0000
@@ -1154,8 +1154,8 @@
 			% Create the new version.
 			%
 
-			pd_info__define_new_pred(DeforestGoal, PredProcId,
-				CallGoal, !PDInfo),
+			pd_info__define_new_pred(created(deforestation),
+				DeforestGoal, PredProcId, CallGoal, !PDInfo),
 			PredProcId = proc(PredId, _),
 
 			pd_info_get_module_info(!.PDInfo, ModuleInfo),
Index: compiler/det_report.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/det_report.m,v
retrieving revision 1.96
diff -u -b -r1.96 det_report.m
--- compiler/det_report.m	21 Jan 2005 03:27:36 -0000	1.96
+++ compiler/det_report.m	21 Jan 2005 03:34:49 -0000
@@ -326,7 +326,7 @@
 	proc_info_declared_determinism(ProcInfo, MaybeDetism),
 	(
 		pred_info_name(PredInfo) = "main",
-		pred_info_arity(PredInfo) = 2,
+		pred_info_orig_arity(PredInfo) = 2,
 		pred_info_is_exported(PredInfo),
 		MaybeDetism = yes(DeclaredDetism),
 		DeclaredDetism \= det,
@@ -871,7 +871,7 @@
 	module_info_pred_info(ModuleInfo, PredId, PredInfo),
 	PredName = pred_info_name(PredInfo),
 	PredOrFunc = pred_info_is_pred_or_func(PredInfo),
-	pred_info_get_maybe_special_pred(PredInfo, MaybeSpecial),
+	pred_info_get_origin(PredInfo, Origin),
 	%
 	% if the error was in a call to a type-specific unification predicate
 	% (i.e. in the unification itself), then don't print out the predicate
@@ -879,7 +879,7 @@
 	% both out. (The latter can happen if there is a determinism error
 	% in a function call inside some unification.)
 	%
-	( MaybeSpecial = yes(unify - _) ->
+	( Origin = special_pred(unify - _) ->
 		(
 			CallUnifyContext = yes(
 				call_unify_context(LHS, RHS, UC)),
Index: compiler/dnf.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/dnf.m,v
retrieving revision 1.55
diff -u -b -r1.55 dnf.m
--- compiler/dnf.m	14 Jun 2004 04:16:02 -0000	1.55
+++ compiler/dnf.m	17 Jan 2005 08:15:57 -0000
@@ -53,7 +53,7 @@
 :- pred dnf__transform_module(bool::in, maybe(set(pred_proc_id))::in,
 	module_info::in, module_info::out) is det.
 
-:- pred dnf__transform_proc(proc_info::in, pred_info::in,
+:- pred dnf__transform_proc(proc_info::in, pred_info::in, pred_id::in,
 	maybe(set(pred_proc_id))::in, module_info::in, module_info::out,
 	proc_info::out, list(pred_id)::in, list(pred_id)::out) is det.
 
@@ -85,14 +85,14 @@
 :- pred dnf__transform_preds(list(pred_id)::in, bool::in,
 	maybe(set(pred_proc_id))::in, module_info::in, module_info::out) is det.
 
-dnf__transform_preds([], _, _, ModuleInfo, ModuleInfo).
+dnf__transform_preds([], _, _, !ModuleInfo).
 dnf__transform_preds([PredId | PredIds0], TransformAll, MaybeNonAtomic,
-		ModuleInfo0, ModuleInfo) :-
+		!ModuleInfo) :-
 	(
 		(
 			TransformAll = yes
 		;
-			module_info_preds(ModuleInfo0, PredTable),
+			module_info_preds(!.ModuleInfo, PredTable),
 			map__lookup(PredTable, PredId, PredInfo),
 			pred_info_get_markers(PredInfo, Markers),
 			( check_marker(Markers, dnf)
@@ -100,26 +100,24 @@
 			)
 		)
 	->
-		dnf__transform_pred(PredId, MaybeNonAtomic,
-			ModuleInfo0, ModuleInfo1, NewPredIds),
+		dnf__transform_pred(PredId, MaybeNonAtomic, !ModuleInfo,
+			NewPredIds),
 		list__append(NewPredIds, PredIds0, PredIds1)
 	;
-		PredIds1 = PredIds0,
-		ModuleInfo1 = ModuleInfo0
+		PredIds1 = PredIds0
 	),
 	dnf__transform_preds(PredIds1, TransformAll, MaybeNonAtomic,
-		ModuleInfo1, ModuleInfo).
+		!ModuleInfo).
 
 :- pred dnf__transform_pred(pred_id::in, maybe(set(pred_proc_id))::in,
 	module_info::in, module_info::out, list(pred_id)::out) is det.
 
-dnf__transform_pred(PredId, MaybeNonAtomic, ModuleInfo0, ModuleInfo,
-		NewPredIds) :-
-	module_info_preds(ModuleInfo0, PredTable0),
+dnf__transform_pred(PredId, MaybeNonAtomic, !ModuleInfo, NewPredIds) :-
+	module_info_preds(!.ModuleInfo, PredTable0),
 	map__lookup(PredTable0, PredId, PredInfo0),
 	ProcIds = pred_info_non_imported_procids(PredInfo0),
 	dnf__transform_procs(ProcIds, PredId, MaybeNonAtomic,
-		ModuleInfo0, ModuleInfo, [], NewPredIds).
+		!ModuleInfo, [], NewPredIds).
 
 :- pred dnf__transform_procs(list(proc_id)::in, pred_id::in,
 	maybe(set(pred_proc_id))::in, module_info::in, module_info::out,
@@ -127,14 +125,14 @@
 
 dnf__transform_procs([], _, _, !ModuleInfo, NewPredIds, NewPredIds).
 dnf__transform_procs([ProcId | ProcIds], PredId, MaybeNonAtomic,
-		!ModuleInfo, NewPredIds0, NewPredIds) :-
+		!ModuleInfo, !NewPredIds) :-
 	module_info_preds(!.ModuleInfo, PredTable0),
 	map__lookup(PredTable0, PredId, PredInfo0),
 	pred_info_procedures(PredInfo0, ProcTable0),
 	map__lookup(ProcTable0, ProcId, ProcInfo0),
 
-	dnf__transform_proc(ProcInfo0, PredInfo0, MaybeNonAtomic,
-		!ModuleInfo, ProcInfo, NewPredIds0, NewPredIds1),
+	dnf__transform_proc(ProcInfo0, PredInfo0, PredId, MaybeNonAtomic,
+		!ModuleInfo, ProcInfo, !NewPredIds),
 
 	map__det_update(ProcTable0, ProcId, ProcInfo, ProcTable),
 	pred_info_set_procedures(ProcTable, PredInfo0, PredInfo),
@@ -145,11 +143,12 @@
 	module_info_set_preds(PredTable, !ModuleInfo),
 
 	dnf__transform_procs(ProcIds, PredId, MaybeNonAtomic,
-		!ModuleInfo, NewPredIds1, NewPredIds).
+		!ModuleInfo, !NewPredIds).
 
-dnf__transform_proc(ProcInfo0, PredInfo0, MaybeNonAtomic,
-		!ModuleInfo, ProcInfo, NewPredIds0, NewPredIds) :-
+dnf__transform_proc(ProcInfo0, PredInfo0, PredId, MaybeNonAtomic,
+		!ModuleInfo, ProcInfo, !NewPredIds) :-
 	PredName = pred_info_name(PredInfo0),
+	pred_info_get_origin(PredInfo0, Origin),
 	pred_info_typevarset(PredInfo0, TVarSet),
 	pred_info_get_markers(PredInfo0, Markers),
 	pred_info_get_class_context(PredInfo0, ClassContext),
@@ -160,41 +159,46 @@
 	proc_info_vartypes(ProcInfo0, VarTypes),
 	proc_info_typeinfo_varmap(ProcInfo0, TVarMap),
 	proc_info_typeclass_info_varmap(ProcInfo0, TCVarMap),
-	DnfInfo = dnf_info(TVarSet, VarTypes, ClassContext,
-		VarSet, InstVarSet, Markers, TVarMap, TCVarMap, Owner),
+	DnfInfo = dnf_info(PredId, Origin, PredName, TVarSet, VarTypes,
+		ClassContext, VarSet, InstVarSet, Markers, TVarMap, TCVarMap,
+		Owner),
 
 	proc_info_get_initial_instmap(ProcInfo0, !.ModuleInfo, InstMap),
 	dnf__transform_goal(Goal0, InstMap, MaybeNonAtomic, !ModuleInfo,
-		PredName, DnfInfo, Goal, NewPredIds0, NewPredIds),
+		DnfInfo, Goal, !NewPredIds),
 	proc_info_set_goal(Goal, ProcInfo0, ProcInfo).
 
 %-----------------------------------------------------------------------------%
 
-:- type dnf_info --->	dnf_info(
-				tvarset,
-				map(prog_var, type),
-				class_constraints,
-				prog_varset,
-				inst_varset,
-				pred_markers,
-				map(tvar, type_info_locn),
-				map(class_constraint, prog_var),
-				aditi_owner
+:- type dnf_info
+	--->	dnf_info(
+			orig_pred_id	:: pred_id,
+			orig_origin	:: pred_origin,
+			orig_pred_name	:: string,
+			orig_tvarset	:: tvarset,
+			orig_vartypes	:: vartypes,
+			orig_classes	:: class_constraints,
+			orig_varset	:: prog_varset,
+			orig_instvarset	:: inst_varset,
+			orig_markers	:: pred_markers,
+			orig_ti_locns	:: map(tvar, type_info_locn),
+			orig_tcis	:: map(class_constraint, prog_var),
+			orig_owner	:: aditi_owner
 			).
 
 :- pred dnf__transform_goal(hlds_goal::in, instmap::in,
 	maybe(set(pred_proc_id))::in, module_info::in, module_info::out,
-	string::in, dnf_info::in, hlds_goal::out,
-	list(pred_id)::in, list(pred_id)::out) is det.
+	dnf_info::in, hlds_goal::out, list(pred_id)::in, list(pred_id)::out)
+	is det.
 
-dnf__transform_goal(Goal0, InstMap0, MaybeNonAtomic, ModuleInfo0, ModuleInfo,
-		Base, DnfInfo, Goal, NewPredIds0, NewPredIds) :-
+dnf__transform_goal(Goal0, InstMap0, MaybeNonAtomic, !ModuleInfo,
+		DnfInfo, Goal, !NewPredIds) :-
 	Goal0 = GoalExpr0 - GoalInfo,
 	(
 		GoalExpr0 = conj(Goals0),
 		dnf__transform_conj(Goals0, InstMap0, MaybeNonAtomic,
-			ModuleInfo0, ModuleInfo, Base, counter__init(0), _,
-			DnfInfo, Goals, NewPredIds0, NewPredIds),
+			!ModuleInfo, counter__init(0), _, DnfInfo, Goals,
+			!NewPredIds),
 		Goal = conj(Goals) - GoalInfo
 	;
 		GoalExpr0 = par_conj(_Goals0),
@@ -202,56 +206,45 @@
 	;
 		GoalExpr0 = some(Vars, CanRemove, SomeGoal0),
 		dnf__make_goal_literal(SomeGoal0, InstMap0, MaybeNonAtomic,
-			ModuleInfo0, ModuleInfo, no, yes, Base,
-			counter__init(0), _, DnfInfo, SomeGoal,
-			NewPredIds0, NewPredIds),
+			!ModuleInfo, no, yes, counter__init(0), _, DnfInfo,
+			SomeGoal, !NewPredIds),
 		Goal = some(Vars, CanRemove, SomeGoal) - GoalInfo
 	;
 		GoalExpr0 = not(NegGoal0),
 		dnf__make_goal_literal(NegGoal0, InstMap0, MaybeNonAtomic,
-			ModuleInfo0, ModuleInfo, yes, no, Base,
-			counter__init(0), _, DnfInfo, NegGoal,
-			NewPredIds0, NewPredIds),
+			!ModuleInfo, yes, no, counter__init(0), _, DnfInfo,
+			NegGoal, !NewPredIds),
 		Goal = not(NegGoal) - GoalInfo
 	;
 		GoalExpr0 = disj(Goals0),
 		dnf__transform_disj(Goals0, InstMap0, MaybeNonAtomic,
-			ModuleInfo0, ModuleInfo, Base, counter__init(0),
-			DnfInfo, Goals, NewPredIds0, NewPredIds),
+			!ModuleInfo, counter__init(0), DnfInfo, Goals,
+			!NewPredIds),
 		Goal = disj(Goals) - GoalInfo
 	;
 		GoalExpr0 = switch(Var, CanFail, Cases0),
 		dnf__transform_switch(Cases0, InstMap0, MaybeNonAtomic,
-			ModuleInfo0, ModuleInfo, Base, counter__init(0),
-			DnfInfo, Cases, NewPredIds0, NewPredIds),
+			!ModuleInfo, counter__init(0), DnfInfo, Cases,
+			!NewPredIds),
 		Goal = switch(Var, CanFail, Cases) - GoalInfo
 	;
 		GoalExpr0 = if_then_else(Vars, Cond0, Then0, Else0),
 		% XXX should handle nonempty Vars
 		dnf__transform_ite(Cond0, Then0, Else0, InstMap0,
-			MaybeNonAtomic, ModuleInfo0, ModuleInfo, Base,
-			counter__init(0), DnfInfo, Cond, Then, Else,
-			NewPredIds0, NewPredIds),
+			MaybeNonAtomic, !ModuleInfo, counter__init(0), DnfInfo,
+			Cond, Then, Else, !NewPredIds),
 		Goal = if_then_else(Vars, Cond, Then, Else) - GoalInfo
 	;
 		GoalExpr0 = generic_call(_, _, _, _),
-		ModuleInfo = ModuleInfo0,
-		NewPredIds = NewPredIds0,
 		Goal = Goal0
 	;
 		GoalExpr0 = call(_, _, _, _, _, _),
-		ModuleInfo = ModuleInfo0,
-		NewPredIds = NewPredIds0,
 		Goal = Goal0
 	;
 		GoalExpr0 = unify(_, _, _, _, _),
-		ModuleInfo = ModuleInfo0,
-		NewPredIds = NewPredIds0,
 		Goal = Goal0
 	;
 		GoalExpr0 = foreign_proc(_, _, _, _, _, _),
-		ModuleInfo = ModuleInfo0,
-		NewPredIds = NewPredIds0,
 		Goal = Goal0
 	;
 		GoalExpr0 = shorthand(_),
@@ -263,157 +256,140 @@
 
 :- pred dnf__transform_disj(list(hlds_goal)::in, instmap::in,
 	maybe(set(pred_proc_id))::in, module_info::in, module_info::out,
-	string::in, counter::in, dnf_info::in, list(hlds_goal)::out,
+	counter::in, dnf_info::in, list(hlds_goal)::out,
 	list(pred_id)::in, list(pred_id)::out) is det.
 
-dnf__transform_disj([], _, _, ModuleInfo, ModuleInfo, _, _, _, [],
-		NewPredIds, NewPredIds).
-dnf__transform_disj([Goal0 | Goals0], InstMap0, MaybeNonAtomic,
-		ModuleInfo0, ModuleInfo, Base, Counter0, DnfInfo,
-		[Goal | Goals], NewPredIds0, NewPredIds) :-
+dnf__transform_disj([], _, _, !ModuleInfo, _, _, [], !NewPredIds).
+dnf__transform_disj([Goal0 | Goals0], InstMap0, MaybeNonAtomic, !ModuleInfo,
+		!.Counter, DnfInfo, [Goal | Goals], !NewPredIds) :-
 	Goal0 = _ - GoalInfo,
 	goal_to_conj_list(Goal0, ConjList0),
 	dnf__transform_conj(ConjList0, InstMap0, MaybeNonAtomic,
-		ModuleInfo0, ModuleInfo1, Base, Counter0, Counter1, DnfInfo,
-		ConjList, NewPredIds0, NewPredIds1),
+		!ModuleInfo, !Counter, DnfInfo, ConjList, !NewPredIds),
 	conj_list_to_goal(ConjList, GoalInfo, Goal),
 	dnf__transform_disj(Goals0, InstMap0, MaybeNonAtomic,
-		ModuleInfo1, ModuleInfo, Base, Counter1, DnfInfo,
-		Goals, NewPredIds1, NewPredIds).
+		!ModuleInfo, !.Counter, DnfInfo, Goals, !NewPredIds).
 
 :- pred dnf__transform_switch(list(case)::in, instmap::in,
 	maybe(set(pred_proc_id))::in, module_info::in, module_info::out,
-	string::in, counter::in, dnf_info::in, list(case)::out,
-	list(pred_id)::in, list(pred_id)::out) is det.
+	counter::in, dnf_info::in,
+	list(case)::out, list(pred_id)::in, list(pred_id)::out) is det.
 
-dnf__transform_switch([], _, _, ModuleInfo, ModuleInfo, _, _, _, [],
-		NewPredIds, NewPredIds).
-dnf__transform_switch([Case0 | Cases0], InstMap0, MaybeNonAtomic,
-		ModuleInfo0, ModuleInfo, Base, Counter0, DnfInfo,
-		[Case | Cases], NewPredIds0, NewPredIds) :-
+dnf__transform_switch([], _, _, !ModuleInfo, _, _, [], !NewPredIds).
+dnf__transform_switch([Case0 | Cases0], InstMap0, MaybeNonAtomic, !ModuleInfo,
+		!.Counter, DnfInfo, [Case | Cases], !NewPredIds) :-
 	Case0 = case(ConsId, Goal0),
 	goal_to_conj_list(Goal0, ConjList0),
 	% XXX should adjust instmap to account for binding of switch variable
-	dnf__transform_conj(ConjList0, InstMap0, MaybeNonAtomic,
-		ModuleInfo0, ModuleInfo1, Base, Counter0, Counter1, DnfInfo,
-		ConjList, NewPredIds0, NewPredIds1),
+	dnf__transform_conj(ConjList0, InstMap0, MaybeNonAtomic, !ModuleInfo,
+		!Counter, DnfInfo, ConjList, !NewPredIds),
 	Goal0 = _ - GoalInfo,
 	conj_list_to_goal(ConjList, GoalInfo, Goal),
 	Case = case(ConsId, Goal),
-	dnf__transform_switch(Cases0, InstMap0, MaybeNonAtomic,
-		ModuleInfo1, ModuleInfo, Base, Counter1, DnfInfo,
-		Cases, NewPredIds1, NewPredIds).
+	dnf__transform_switch(Cases0, InstMap0, MaybeNonAtomic, !ModuleInfo,
+		!.Counter, DnfInfo, Cases, !NewPredIds).
 
 :- pred dnf__transform_ite(hlds_goal::in, hlds_goal::in, hlds_goal::in,
-	instmap::in, maybe(set(pred_proc_id))::in, module_info::in,
-	module_info::out, string::in, counter::in, dnf_info::in,
+	instmap::in, maybe(set(pred_proc_id))::in,
+	module_info::in, module_info::out, counter::in, dnf_info::in,
 	hlds_goal::out, hlds_goal::out, hlds_goal::out,
 	list(pred_id)::in, list(pred_id)::out) is det.
 
-dnf__transform_ite(Cond0, Then0, Else0, InstMap0, MaybeNonAtomic,
-		ModuleInfo0, ModuleInfo, Base, Counter0, DnfInfo,
-		Cond, Then, Else, NewPredIds0, NewPredIds) :-
+dnf__transform_ite(Cond0, Then0, Else0, InstMap0, MaybeNonAtomic, !ModuleInfo,
+		!.Counter, DnfInfo, Cond, Then, Else, !NewPredIds) :-
 	Cond0 = _ - CondInfo,
-	dnf__make_goal_literal(Cond0, InstMap0, MaybeNonAtomic,
-		ModuleInfo0, ModuleInfo1, yes, no, Base, Counter0, Counter1,
-		DnfInfo, Cond, NewPredIds0, NewPredIds1),
+	dnf__make_goal_literal(Cond0, InstMap0, MaybeNonAtomic, !ModuleInfo,
+		yes, no, !Counter, DnfInfo, Cond, !NewPredIds),
 	goal_info_get_instmap_delta(CondInfo, InstMapDelta),
 	instmap__apply_instmap_delta(InstMap0, InstMapDelta, InstMap1),
 	Then0 = _ - ThenInfo,
 	goal_to_conj_list(Then0, ThenList0),
-	dnf__transform_conj(ThenList0, InstMap1, MaybeNonAtomic,
-		ModuleInfo1, ModuleInfo2, Base, Counter1, Counter2, DnfInfo,
-		ThenList, NewPredIds1, NewPredIds2),
+	dnf__transform_conj(ThenList0, InstMap1, MaybeNonAtomic, !ModuleInfo,
+		!Counter, DnfInfo, ThenList, !NewPredIds),
 	conj_list_to_goal(ThenList, ThenInfo, Then),
 	Else0 = _ - ElseInfo,
 	goal_to_conj_list(Else0, ElseList0),
-	dnf__transform_conj(ElseList0, InstMap0, MaybeNonAtomic,
-		ModuleInfo2, ModuleInfo, Base, Counter2, _, DnfInfo,
-		ElseList, NewPredIds2, NewPredIds),
+	dnf__transform_conj(ElseList0, InstMap0, MaybeNonAtomic, !ModuleInfo,
+		!.Counter, _, DnfInfo, ElseList, !NewPredIds),
 	conj_list_to_goal(ElseList, ElseInfo, Else).
 
 %-----------------------------------------------------------------------------%
 
 :- pred dnf__transform_conj(list(hlds_goal)::in, instmap::in,
 	maybe(set(pred_proc_id))::in, module_info::in, module_info::out,
-	string::in, counter::in, counter::out, dnf_info::in,
+	counter::in, counter::out, dnf_info::in,
 	list(hlds_goal)::out, list(pred_id)::in, list(pred_id)::out) is det.
 
-dnf__transform_conj([], _, _, ModuleInfo, ModuleInfo, _, Counter, Counter,
-		_, [], NewPreds, NewPreds).
-dnf__transform_conj([Goal0 | Goals0], InstMap0, MaybeNonAtomic,
-		ModuleInfo0, ModuleInfo, Base, Counter0, Counter, DnfInfo,
-		[Goal | Goals], NewPredIds0, NewPredIds) :-
-	dnf__make_goal_literal(Goal0, InstMap0, MaybeNonAtomic,
-		ModuleInfo0, ModuleInfo1, no, no, Base, Counter0, Counter1,
-		DnfInfo, Goal, NewPredIds0, NewPredIds1),
+dnf__transform_conj([], _, _, !ModuleInfo, !Counter, _, [], !NewPreds).
+dnf__transform_conj([Goal0 | Goals0], InstMap0, MaybeNonAtomic, !ModuleInfo,
+		!Counter, DnfInfo, [Goal | Goals], !NewPredIds) :-
+	dnf__make_goal_literal(Goal0, InstMap0, MaybeNonAtomic, !ModuleInfo,
+		no, no, !Counter, DnfInfo, Goal, !NewPredIds),
 	Goal0 = _ - GoalInfo0,
 	goal_info_get_instmap_delta(GoalInfo0, InstMapDelta),
 	instmap__apply_instmap_delta(InstMap0, InstMapDelta, InstMap1),
-	dnf__transform_conj(Goals0, InstMap1, MaybeNonAtomic,
-		ModuleInfo1, ModuleInfo, Base, Counter1, Counter, DnfInfo,
-		Goals, NewPredIds1, NewPredIds).
+	dnf__transform_conj(Goals0, InstMap1, MaybeNonAtomic, !ModuleInfo,
+		!Counter, DnfInfo, Goals, !NewPredIds).
 
 %-----------------------------------------------------------------------------%
 
 :- pred dnf__make_goal_literal(hlds_goal::in, instmap::in,
 	maybe(set(pred_proc_id))::in, module_info::in, module_info::out,
-	bool::in, bool::in, string::in, counter::in, counter::out,
-	dnf_info::in, hlds_goal::out, list(pred_id)::in, list(pred_id)::out)
-	is det.
+	bool::in, bool::in, counter::in, counter::out, dnf_info::in,
+	hlds_goal::out, list(pred_id)::in, list(pred_id)::out) is det.
 
-dnf__make_goal_literal(Goal0, InstMap0, MaybeNonAtomic, ModuleInfo0,
-		ModuleInfo, InNeg, InSome, Base, Counter0, Counter,
-		DnfInfo, Goal, NewPredIds0, NewPredIds) :-
+dnf__make_goal_literal(Goal0, InstMap0, MaybeNonAtomic, !ModuleInfo,
+		InNeg, InSome, !Counter, DnfInfo, Goal, !NewPredIds) :-
 	(
-		dnf__is_considered_literal_goal(Goal0,
-			InNeg, InSome, MaybeNonAtomic)
+		dnf__is_considered_literal_goal(Goal0, InNeg, InSome,
+			MaybeNonAtomic)
 	->
-		Goal = Goal0,
-		Counter = Counter0,
-		ModuleInfo = ModuleInfo0,
-		NewPredIds = NewPredIds0
-	;
-		module_info_get_predicate_table(ModuleInfo0, PredTable0),
-		dnf__get_new_pred_name(PredTable0, Base, Name,
-			Counter0, Counter),
-		dnf__define_new_pred(Goal0, Goal, InstMap0, Name, DnfInfo,
-			ModuleInfo0, ModuleInfo, NewPredId),
-		NewPredIds = [NewPredId | NewPredIds0]
+		Goal = Goal0
+	;
+		module_info_get_predicate_table(!.ModuleInfo, PredTable0),
+		OrigPredId = DnfInfo ^ orig_pred_id,
+		OrigOrigin = DnfInfo ^ orig_origin,
+		OrigPredName = DnfInfo ^ orig_pred_name,
+		dnf__get_new_pred_name(PredTable0, OrigPredName, Name, Num,
+			!Counter),
+		Origin = transformed(dnf(Num), OrigOrigin, OrigPredId),
+		dnf__define_new_pred(Origin, Goal0, Goal, InstMap0, Name,
+			DnfInfo, !ModuleInfo, NewPredId),
+		!:NewPredIds = [NewPredId | !.NewPredIds]
 	).
 
 :- pred dnf__get_new_pred_name(predicate_table::in, string::in, string::out,
-	counter::in, counter::out) is det.
+	int::out, counter::in, counter::out) is det.
 
-dnf__get_new_pred_name(PredTable, Base, Name, Counter0, Counter) :-
-	counter__allocate(N, Counter0, Counter1),
+dnf__get_new_pred_name(PredTable, Base, Name, Num, !Counter) :-
+	counter__allocate(N, !Counter),
 	string__int_to_string(N, Suffix),
 	string__append_list([Base, "__part_", Suffix], TrialName),
 	( predicate_table_search_name(PredTable, TrialName, _) ->
-		dnf__get_new_pred_name(PredTable, Base, Name, Counter1, Counter)
+		dnf__get_new_pred_name(PredTable, Base, Name, Num, !Counter)
 	;
 		Name = TrialName,
-		Counter = Counter1
+		Num = N
 	).
 
-:- pred dnf__define_new_pred(hlds_goal::in, hlds_goal::out, instmap::in,
-	string::in, dnf_info::in, module_info::in, module_info::out,
-	pred_id::out) is det.
-
-dnf__define_new_pred(Goal0, Goal, InstMap0, PredName, DnfInfo,
-		ModuleInfo0, ModuleInfo, PredId) :-
-	DnfInfo = dnf_info(TVarSet, VarTypes, ClassContext,
-			VarSet, InstVarSet, Markers, TVarMap, TCVarMap, Owner),
+:- pred dnf__define_new_pred(pred_origin::in, hlds_goal::in, hlds_goal::out,
+	instmap::in, string::in, dnf_info::in,
+	module_info::in, module_info::out, pred_id::out) is det.
+
+dnf__define_new_pred(Origin, Goal0, Goal, InstMap0, PredName, DnfInfo,
+		!ModuleInfo, PredId) :-
+	DnfInfo = dnf_info(_, _, _, TVarSet, VarTypes, ClassContext, VarSet,
+		InstVarSet, Markers, TVarMap, TCVarMap, Owner),
 	Goal0 = _GoalExpr - GoalInfo,
 	goal_info_get_nonlocals(GoalInfo, NonLocals),
 	set__to_sorted_list(NonLocals, ArgVars),
 		% This ClassContext is a conservative approximation.
 		% We could get rid of some constraints on variables
 		% that are not part of the goal.
-	hlds_pred__define_new_pred(Goal0, Goal, ArgVars, _, InstMap0, PredName,
-		TVarSet, VarTypes, ClassContext, TVarMap, TCVarMap,
+	hlds_pred__define_new_pred(Origin, Goal0, Goal, ArgVars, _, InstMap0,
+		PredName, TVarSet, VarTypes, ClassContext, TVarMap, TCVarMap,
 		VarSet, InstVarSet, Markers, Owner, address_is_not_taken,
-		ModuleInfo0, ModuleInfo, PredProcId),
+		!ModuleInfo, PredProcId),
 	PredProcId = proc(PredId, _).
 
 %-----------------------------------------------------------------------------%
Index: compiler/equiv_type_hlds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/equiv_type_hlds.m,v
retrieving revision 1.9
diff -u -b -r1.9 equiv_type_hlds.m
--- compiler/equiv_type_hlds.m	21 Jan 2005 03:27:37 -0000	1.9
+++ compiler/equiv_type_hlds.m	21 Jan 2005 03:34:49 -0000
@@ -298,7 +298,7 @@
 	ItemId = item_id(pred_or_func_to_item_type(
 			pred_info_is_pred_or_func(!.PredInfo)),
 			qualified(pred_info_module(!.PredInfo), PredName) -
-				pred_info_arity(!.PredInfo)),
+				pred_info_orig_arity(!.PredInfo)),
 	equiv_type__finish_recording_expanded_items(ItemId,
 		!.EquivTypeInfo, MaybeRecompInfo0, MaybeRecompInfo),
 	module_info_set_maybe_recompilation_info(MaybeRecompInfo,
Index: compiler/exception_analysis.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/exception_analysis.m,v
retrieving revision 1.4
diff -u -b -r1.4 exception_analysis.m
--- compiler/exception_analysis.m	21 Jan 2005 03:27:37 -0000	1.4
+++ compiler/exception_analysis.m	21 Jan 2005 03:34:49 -0000
@@ -299,15 +299,14 @@
 			ModuleName = pred_info_module(CallPredInfo),
 			any_mercury_builtin_module(ModuleName),
 			Name = pred_info_name(CallPredInfo),
-			Arity = pred_info_arity(CallPredInfo),
+			Arity = pred_info_orig_arity(CallPredInfo),
 			( SpecialPredId = compare
 			; SpecialPredId = unify ),
 			special_pred_name_arity(SpecialPredId, Name,
 				Arity)
 		;
-			pred_info_get_maybe_special_pred(CallPredInfo,
-				MaybeSpecial),
-			MaybeSpecial = yes(SpecialPredId - _),
+			pred_info_get_origin(CallPredInfo, Origin),
+			Origin = special_pred(SpecialPredId - _),
 			( SpecialPredId = compare
 			; SpecialPredId = unify )
 		)	
@@ -662,7 +661,7 @@
 	->
 		ModuleName = pred_info_module(PredInfo),
 		Name       = pred_info_name(PredInfo),
-		Arity      = pred_info_arity(PredInfo),
+		Arity      = pred_info_orig_arity(PredInfo),
 		PredOrFunc = pred_info_is_pred_or_func(PredInfo),
 		ProcIds    = pred_info_procids(PredInfo),
 		%
Index: compiler/fact_table.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/fact_table.m,v
retrieving revision 1.57
diff -u -b -r1.57 fact_table.m
--- compiler/fact_table.m	19 Jan 2005 03:10:33 -0000	1.57
+++ compiler/fact_table.m	19 Jan 2005 04:52:45 -0000
@@ -771,7 +771,7 @@
 	( ProcIDs = [] ->
 		% There are no declared modes so report an error.
 		PredString = pred_info_name(!.PredInfo),
-		Arity = pred_info_arity(!.PredInfo),
+		Arity = pred_info_orig_arity(!.PredInfo),
 		string__format(
 			"Error: no modes declared for fact table `%s/%d'.\n",
 			[s(PredString), i(Arity)], Msg),
Index: compiler/higher_order.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/higher_order.m,v
retrieving revision 1.122
diff -u -b -r1.122 higher_order.m
--- compiler/higher_order.m	21 Jan 2005 03:27:37 -0000	1.122
+++ compiler/higher_order.m	21 Jan 2005 03:34:50 -0000
@@ -61,7 +61,7 @@
 :- import_module transform_hlds__inlining.
 
 :- import_module assoc_list, bool, char, int, list, map, require, set.
-:- import_module std_util, string, varset, term.
+:- import_module std_util, string, varset, term, counter.
 
 	% Iterate collecting requests and processing them until there
 	% are no more requests remaining.
@@ -80,12 +80,11 @@
 	Params = ho_params(HigherOrder, TypeSpec,
 		UserTypeSpec, SizeLimit, ArgLimit),
 	map__init(NewPreds0),
-	NextHOid0 = 1,
 	map__init(GoalSizes0),
 	set__init(Requests0),
 	map__init(VersionInfo0),
 	Info0 = higher_order_global_info(Requests0, NewPreds0, VersionInfo0,
-		!.ModuleInfo, GoalSizes0, Params, NextHOid0),
+		!.ModuleInfo, GoalSizes0, Params, counter__init(1)),
 
 	module_info_predids(!.ModuleInfo, PredIds0),
 	module_info_type_spec_info(!.ModuleInfo,
@@ -193,7 +192,7 @@
 		module_info			:: module_info,
 		goal_sizes			:: goal_sizes,
 		ho_params			:: ho_params,
-		next_higher_order_id		:: int
+		next_higher_order_id		:: counter
 						% Number identifying
 						% a specialized version.
 	).
@@ -1297,7 +1296,8 @@
 			% specialized version of the pred.
 			FindResult = request(Request),
 			Result = not_specialized,
-			( CanRequest = yes ->
+			(
+				CanRequest = yes,
 				set__insert(!.Info ^ global_info ^ requests,
 					Request, Requests),
 				update_changed_status(!.Info ^ changed,
@@ -1306,7 +1306,7 @@
 					^ requests := Requests)
 					^ changed := Changed
 			;
-				true
+				CanRequest = no
 			)
 		;
 			FindResult = no_request,
@@ -1882,7 +1882,7 @@
 	module_info_pred_info(ModuleInfo, CalledPred, CalledPredInfo),
 	mercury_public_builtin_module = pred_info_module(CalledPredInfo),
 	PredName = pred_info_name(CalledPredInfo),
-	PredArity = pred_info_arity(CalledPredInfo),
+	PredArity = pred_info_orig_arity(CalledPredInfo),
 	special_pred_name_arity(SpecialId, PredName, PredArity),
 	special_pred_get_type(SpecialId, Args, Var),
 	map__lookup(VarTypes, Var, SpecialPredType),
@@ -2290,7 +2290,7 @@
 	globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO),
 	PredModule = pred_info_module(PredInfo),
 	PredName = pred_info_name(PredInfo),
-	Arity = pred_info_arity(PredInfo),
+	Arity = pred_info_orig_arity(PredInfo),
 	pred_info_arg_types(PredInfo, Types),
 	list__length(Types, ActualArity),
 	maybe_write_request(VeryVerbose, ModuleInfo, "Request for",
@@ -2437,12 +2437,13 @@
 	Request = request(Caller, CalledPredProc, CallArgs, ExtraTypeInfoTVars,
 		HOArgs, ArgTypes, TypeInfoLiveness, CallerTVarSet,
 		IsUserTypeSpec, Context),
+	Caller = proc(CallerPredId, CallerProcId),
 	ModuleInfo0 = !.Info ^ module_info,
 	module_info_pred_proc_info(ModuleInfo0, CalledPredProc,
 		PredInfo0, ProcInfo0),
 
 	Name0 = pred_info_name(PredInfo0),
-	Arity = pred_info_arity(PredInfo0),
+	Arity = pred_info_orig_arity(PredInfo0),
 	PredOrFunc = pred_info_is_pred_or_func(PredInfo0),
 	PredModule = pred_info_module(PredInfo0),
 	globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO),
@@ -2459,7 +2460,6 @@
 		% are derived from the names of predicates, duplicate predicate
 		% names lead to duplicate global variable names and hence to
 		% link errors.
-		Caller = proc(CallerPredId, CallerProcId),
 		predicate_name(ModuleInfo0, CallerPredId, PredName0),
 		proc_id_to_int(CallerProcId, CallerProcInt),
 
@@ -2472,6 +2472,7 @@
 			[PredName0, "_", int_to_string(CallerProcInt), "_",
 			int_to_string(higher_order_arg_order_version)]),
 		SymName = qualified(PredModule, PredName),
+		Transform = higher_order_type_specialization(CallerProcInt),
 		NewProcId = CallerProcId,
 		% For exported predicates the type specialization must
 		% be exported.
@@ -2481,11 +2482,13 @@
 	;
 		IsUserTypeSpec = no,
 		NewProcId = hlds_pred__initial_proc_id,
-		NextHOid = !.Info ^ next_higher_order_id,
-		!:Info = !.Info ^ next_higher_order_id := NextHOid + 1,
-		string__int_to_string(NextHOid, IdStr),
+		IdCounter0 = !.Info ^ next_higher_order_id,
+		counter__allocate(Id, IdCounter0, IdCounter),
+		!:Info = !.Info ^ next_higher_order_id := IdCounter,
+		string__int_to_string(Id, IdStr),
 		string__append_list([Name0, "__ho", IdStr], PredName),
 		SymName = qualified(PredModule, PredName),
+		Transform = higher_order_specialization(Id),
 		Status = local
 	),
 
@@ -2494,6 +2497,7 @@
 		qualified(PredModule, Name0), Arity, ActualArity,
 		yes(PredName), HOArgs, Context, !IO),
 
+	pred_info_get_origin(PredInfo0, OrigOrigin),
 	pred_info_typevarset(PredInfo0, TypeVarSet),
 	pred_info_get_markers(PredInfo0, MarkerList),
 	pred_info_get_goal_type(PredInfo0, GoalType),
@@ -2511,7 +2515,8 @@
 	ClausesInfo = clauses_info(EmptyVarSet, EmptyVarTypes,
 		EmptyTVarNameMap, EmptyVarTypes, [], [],
 		EmptyTIMap, EmptyTCIMap, no),
-	pred_info_init(PredModule, SymName, Arity, PredOrFunc, Context,
+	Origin = transformed(Transform, OrigOrigin, CallerPredId),
+	pred_info_init(PredModule, SymName, Arity, PredOrFunc, Context, Origin,
 		Status, GoalType, MarkerList, Types, ArgTVarSet, ExistQVars,
 		ClassContext, EmptyProofs, Owner, ClausesInfo, NewPredInfo0),
 	pred_info_set_typevarset(TypeVarSet, NewPredInfo0, NewPredInfo1),
@@ -2589,7 +2594,7 @@
 		proc(PredId, _) = unshroud_pred_proc_id(ShroudedPredProcId),
 		module_info_pred_info(ModuleInfo, PredId, PredInfo),
 		Name = pred_info_name(PredInfo),
-		Arity = pred_info_arity(PredInfo),
+		Arity = pred_info_orig_arity(PredInfo),
 			% adjust message for type_infos
 		DeclaredArgNo = ArgNo - NumToDrop,
 		io__write_string("HeadVar__", !IO),
Index: compiler/hlds_error_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_error_util.m,v
retrieving revision 1.6
diff -u -b -r1.6 hlds_error_util.m
--- compiler/hlds_error_util.m	19 Jan 2005 03:10:35 -0000	1.6
+++ compiler/hlds_error_util.m	19 Jan 2005 04:52:46 -0000
@@ -75,13 +75,13 @@
 	module_info_pred_info(Module, PredId, PredInfo),
 	ModuleName = pred_info_module(PredInfo),
 	PredName = pred_info_name(PredInfo),
-	Arity = pred_info_arity(PredInfo),
+	Arity = pred_info_orig_arity(PredInfo),
 	PredOrFunc = pred_info_is_pred_or_func(PredInfo),
 	PredOrFuncStr = pred_or_func_to_string(PredOrFunc),
 	adjust_func_arity(PredOrFunc, OrigArity, Arity),
 	pred_info_get_markers(PredInfo, Markers),
-	pred_info_get_maybe_special_pred(PredInfo, MaybeSpecial),
-	( MaybeSpecial = yes(SpecialId - TypeCtor) ->
+	pred_info_get_origin(PredInfo, Origin),
+	( Origin = special_pred(SpecialId - TypeCtor) ->
 		special_pred_description(SpecialId, Descr),
 		TypeCtor = TypeSymName - TypeArity,
 		( TypeArity = 0 ->
@@ -113,7 +113,7 @@
 	module_info_pred_info(Module, PredId, PredInfo),
 	ModuleName = pred_info_module(PredInfo),
 	PredName = pred_info_name(PredInfo),
-	Arity = pred_info_arity(PredInfo),
+	Arity = pred_info_orig_arity(PredInfo),
 	PredOrFunc = pred_info_is_pred_or_func(PredInfo),
 	list__length(ArgModes0, NumArgModes),
 	% We need to strip off the extra type_info arguments inserted at the
Index: compiler/hlds_module.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_module.m,v
retrieving revision 1.105
diff -u -b -r1.105 hlds_module.m
--- compiler/hlds_module.m	19 Jan 2005 03:10:35 -0000	1.105
+++ compiler/hlds_module.m	19 Jan 2005 04:52:46 -0000
@@ -1432,7 +1432,7 @@
 	map__det_remove(AccessibilityTable0, PredId, _, AccessibilityTable),
 	Module = pred_info_module(PredInfo),
 	Name = pred_info_name(PredInfo),
-	Arity = pred_info_arity(PredInfo),
+	Arity = pred_info_orig_arity(PredInfo),
 	IsPredOrFunc = pred_info_is_pred_or_func(PredInfo),
 	(
 		IsPredOrFunc = predicate,
@@ -1849,7 +1849,7 @@
 		Func_N_Index0, Func_NA_Index0, Func_MNA_Index0),
 	Module = pred_info_module(PredInfo),
 	Name = pred_info_name(PredInfo),
-	Arity = pred_info_arity(PredInfo),
+	Arity = pred_info_orig_arity(PredInfo),
 	(
 		MaybePredId = yes(PredId),
 		NextPredId = NextPredId0
@@ -2016,7 +2016,7 @@
 	;
 		Name = pred_info_name(PredInfo),
 		PredOrFunc = pred_info_is_pred_or_func(PredInfo),
-		Arity = pred_info_arity(PredInfo),
+		Arity = pred_info_orig_arity(PredInfo),
 		PredOrFuncStr = prog_out__pred_or_func_to_str(PredOrFunc),
 		string__int_to_string(Arity, ArityString),
 		( ProcIds = [] ->
@@ -2112,7 +2112,7 @@
 	map__lookup(Preds, PredId, PredInfo),
 	ModuleName = pred_info_module(PredInfo),
 	PredName = pred_info_name(PredInfo),
-	Arity = pred_info_arity(PredInfo).
+	Arity = pred_info_orig_arity(PredInfo).
 
 predicate_module(ModuleInfo, PredId, ModuleName) :-
 	module_info_preds(ModuleInfo, Preds),
@@ -2127,6 +2127,6 @@
 predicate_arity(ModuleInfo, PredId, Arity) :-
 	module_info_preds(ModuleInfo, Preds),
 	map__lookup(Preds, PredId, PredInfo),
-	Arity = pred_info_arity(PredInfo).
+	Arity = pred_info_orig_arity(PredInfo).
 
 %-----------------------------------------------------------------------------%
Index: compiler/hlds_out.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_out.m,v
retrieving revision 1.343
diff -u -b -r1.343 hlds_out.m
--- compiler/hlds_out.m	19 Jan 2005 03:10:35 -0000	1.343
+++ compiler/hlds_out.m	19 Jan 2005 04:52:46 -0000
@@ -353,11 +353,11 @@
 	module_info_pred_info(ModuleInfo, PredId, PredInfo),
 	Module = pred_info_module(PredInfo),
 	Name = pred_info_name(PredInfo),
-	Arity = pred_info_arity(PredInfo),
+	Arity = pred_info_orig_arity(PredInfo),
 	PredOrFunc = pred_info_is_pred_or_func(PredInfo),
-	pred_info_get_maybe_special_pred(PredInfo, MaybeSpecial),
+	pred_info_get_origin(PredInfo, Origin),
 	(
-		MaybeSpecial = yes(SpecialId - TypeCtor)
+		Origin = special_pred(SpecialId - TypeCtor)
 	->
 		special_pred_description(SpecialId, Descr),
 		io__write_string(Descr, !IO),
@@ -997,9 +997,9 @@
 			true
 		),
 
-		pred_info_get_maybe_instance_method_constraints(PredInfo,
-			MaybeCs),
-		( MaybeCs = yes(MethodConstraints) ->
+		pred_info_get_origin(PredInfo, Origin),
+		(
+			Origin = instance_method(MethodConstraints),
 			MethodConstraints = instance_method_constraints(
 				ClassId, InstanceTypes, InstanceConstraints,
 				ClassMethodConstraints),
@@ -1028,9 +1028,28 @@
 				mercury_output_constraint(TVarSet,
 					AppendVarNums), !IO),
 			io__nl(!IO)
-
 		;
-			true
+			Origin = special_pred(_),
+			io__write_string("% special pred\n", !IO)
+		;
+			Origin = transformed(Transformation, _, OrigPredId),
+			io__write_string("% transformed from ", !IO),
+			write_pred_id(ModuleInfo, OrigPredId, !IO),
+			io__write_string(": ", !IO),
+			io__write(Transformation, !IO),
+			io__nl(!IO)
+		;
+			Origin = created(Creation),
+			io__write_string("% created: ", !IO),
+			io__write(Creation, !IO),
+			io__nl(!IO)
+		;
+			Origin = assertion(_, _),
+			io__write_string("% assertion\n", !IO)
+		;
+			Origin = lambda(_, _)
+		;
+			Origin = user(_)
 		)
 	;
 		true
Index: compiler/hlds_pred.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_pred.m,v
retrieving revision 1.154
diff -u -b -r1.154 hlds_pred.m
--- compiler/hlds_pred.m	19 Jan 2005 03:10:36 -0000	1.154
+++ compiler/hlds_pred.m	19 Jan 2005 04:52:47 -0000
@@ -150,7 +150,7 @@
 		% pred_info, using procedures
 		%	pred_info_is_imported/1,
 		%	pred_info_is_pseudo_imported/1,
-		%	pred_info_get_maybe_special_pred_info/1
+		%	pred_info_get_origin/1
 		% respectively.
 		% We store booleans here, rather than storing the
 		% pred_info, to avoid retaining a reference to the
@@ -163,7 +163,7 @@
 
 		pred_is_imported	::	bool,
 		pred_is_pseudo_imported	::	bool,
-		pred_is_special_pred	::	maybe(special_pred),
+		pred_info_origin	::	pred_origin,
 
 		% The following boolean holds a value computed from the
 		% proc_info, using procedure_is_exported/2
@@ -399,8 +399,8 @@
 
 	% returns yes if the status indicates that the item was
 	% exported to importing modules (not just to sub-modules).
-:- pred status_is_exported_to_non_submodules(import_status::in,
-		bool::out) is det.
+:- pred status_is_exported_to_non_submodules(import_status::in, bool::out)
+	is det.
 
 	% returns yes if the status indicates that the item was
 	% in any way imported -- that is, if it was defined in
@@ -626,20 +626,97 @@
 :- pred type_info_locn_set_var(prog_var::in,
 	type_info_locn::in, type_info_locn::out) is det.
 
+:- type pred_transformation
+	--->	higher_order_specialization(
+			int	% Sequence number among the higher order
+				% specializations of the original predicate.
+		)
+	;	higher_order_type_specialization(
+			int	% The procedure number of the original
+				% procedure.
+		)
+	;	type_specialization(
+			assoc_list(int, type)
+				% The substitution from type variables
+				% (represented by the integers) to types
+				% (represented by the terms).
+		)
+	;	unused_argument_elimination(
+			list(int)
+				% The list of eliminated argument numbers.
+		)
+	;	accumulator(
+			list(int)
+				% The list of the numbers of the variables
+				% in the original predicate interface that have
+				% been converted to accumulators.
+		)
+	;	loop_invariant(
+			int	% The procedure number of the original
+				% procedure.
+		)
+	;	table_generator
+	;	dnf(
+			int	% This predicate was originally part of a
+				% predicate transformed into disjunctive normal
+				% form; this integers gives the part number.
+		).
+
+:- type pred_creation
+	--->	aditi_magic
+	;	aditi_magic_interface
+	;	aditi_magic_supp
+	;	aditi_join
+	;	aditi_rl_exprn
+	;	deforestation.
+
+:- type pred_origin
+	--->	special_pred(special_pred)
+				% If the predicate is a unify, compare,
+				% index or initialisation predicate, specify
+				% which one, and for which type constructor.
+	;	instance_method(instance_method_constraints)
+				% If this predicate is a class method
+				% implementation, record extra information
+				% about the class context to allow
+				% polymorphism.m to correctly set up the extra
+				% type_info and typeclass_info arguments.
+	;	transformed(pred_transformation, pred_origin, pred_id)
+				% The predicate is a transformed version of
+				% another predicate, whose origin and identity
+				% are given by the second and third arguments.
+	;	created(pred_creation)
+				% The predicate was created by the compiler,
+				% and there is no information available on
+				% where it came from. (Mostly because such
+				% relationships are fuzzy in the aditi
+				% backend.)
+	;	assertion(string, int)
+				% The predicate represents an assertion.
+	;	lambda(string, int)
+				% The predicate is a higher-order manifest
+				% constant. The arguments specify its location
+				% in the source, as a filename/line number
+				% pair.
+	;	user(sym_name).
+				% The predicate is a normal user-written
+				% predicate; the string is its name.
+
 	% pred_info_init(ModuleName, SymName, Arity, PredOrFunc, Context,
-	%	Status, GoalType, Markers, ArgTypes, TypeVarSet, ExistQVars,
-	%	ClassContext, ClassProofs, User, ClausesInfo, PredInfo)
+	%	Origin, Status, GoalType, Markers, ArgTypes, TypeVarSet,
+	%	ExistQVars, ClassContext, ClassProofs, User, ClausesInfo,
+	%	PredInfo)
 	%
 	% Return a pred_info whose fields are filled in from the information
 	% (direct and indirect) in the arguments, and from defaults.
 
 :- pred pred_info_init(module_name::in, sym_name::in, arity::in,
-	pred_or_func::in, prog_context::in, import_status::in, goal_type::in,
-	pred_markers::in, list(type)::in, tvarset::in, existq_tvars::in,
-	class_constraints::in, constraint_proof_map::in, aditi_owner::in,
-	clauses_info::in, pred_info::out) is det.
+	pred_or_func::in, prog_context::in, pred_origin::in, import_status::in,
+	goal_type::in, pred_markers::in, list(type)::in, tvarset::in,
+	existq_tvars::in, class_constraints::in, constraint_proof_map::in,
+	aditi_owner::in, clauses_info::in, pred_info::out) is det.
 
-	% pred_info_create(ModuleName, SymName, PredOrFunc, Context,
+	% pred_info_create(ModuleName, SymName, PredOrFunc, Context, Origin,
 	%	Status, Markers, TypeVarSet, ExistQVars, ArgTypes,
 	%	ClassContext, Assertions, User, ProcInfo, ProcId, PredInfo)
 	%
@@ -649,14 +726,14 @@
 	% and its proc_id is returned as the second last argument.
 
 :- pred pred_info_create(module_name::in, sym_name::in, pred_or_func::in,
-	prog_context::in, import_status::in, pred_markers::in,
+	prog_context::in, pred_origin::in, import_status::in, pred_markers::in,
 	list(type)::in, tvarset::in, existq_tvars::in, class_constraints::in,
 	set(assert_id)::in, aditi_owner::in, proc_info::in, proc_id::out,
 	pred_info::out) is det.
 
-	% hlds_pred__define_new_pred(Goal, CallGoal, Args, ExtraArgs, InstMap,
-	% 	PredName, TVarSet, VarTypes, ClassContext, TVarMap, TCVarMap,
-	%	VarSet, Markers, Owner, IsAddressTaken,
+	% hlds_pred__define_new_pred(Origin, Goal, CallGoal, Args, ExtraArgs,
+	% 	InstMap, PredName, TVarSet, VarTypes, ClassContext,
+	%	TVarMap, TCVarMap, VarSet, Markers, Owner, IsAddressTaken,
 	%	ModuleInfo0, ModuleInfo, PredProcId)
 	%
 	% Create a new predicate for the given goal, returning a goal to
@@ -664,12 +741,13 @@
 	% type_infos and typeclass_infos required by typeinfo liveness
 	% which were added to the front of the argument list.
 
-:- pred hlds_pred__define_new_pred(hlds_goal::in, hlds_goal::out,
-	list(prog_var)::in, list(prog_var)::out, instmap::in, string::in,
-	tvarset::in, vartypes::in, class_constraints::in, type_info_varmap::in,
-	typeclass_info_varmap::in, prog_varset::in, inst_varset::in,
-	pred_markers::in, aditi_owner::in, is_address_taken::in,
-	module_info::in, module_info::out, pred_proc_id::out) is det.
+:- pred hlds_pred__define_new_pred(pred_origin::in,
+	hlds_goal::in, hlds_goal::out, list(prog_var)::in, list(prog_var)::out,
+	instmap::in, string::in, tvarset::in, vartypes::in,
+	class_constraints::in, type_info_varmap::in, typeclass_info_varmap::in,
+	prog_varset::in, inst_varset::in, pred_markers::in, aditi_owner::in,
+	is_address_taken::in, module_info::in, module_info::out,
+	pred_proc_id::out) is det.
 
 	% Various predicates for accessing the information stored in the
 	% pred_id and pred_info data structures.
@@ -679,9 +757,9 @@
 :- func pred_info_module(pred_info) =  module_name.
 :- func pred_info_name(pred_info) = string.
 
-	% pred_info_arity returns the arity of the predicate
+	% pred_info_orig_arity returns the arity of the predicate
 	% *not* counting inserted type_info arguments for polymorphic preds.
-:- func pred_info_arity(pred_info) = arity.
+:- func pred_info_orig_arity(pred_info) = arity.
 
 	% N-ary functions are converted into N+1-ary predicates.
 	% (Clauses are converted in make_hlds, but calls to functions
@@ -693,6 +771,7 @@
 :- func pred_info_is_pred_or_func(pred_info) = pred_or_func.
 
 :- pred pred_info_context(pred_info::in, prog_context::out) is det.
+:- pred pred_info_get_origin(pred_info::in, pred_origin::out) is det.
 :- pred pred_info_import_status(pred_info::in, import_status::out) is det.
 :- pred pred_info_get_goal_type(pred_info::in, goal_type::out) is det.
 :- pred pred_info_get_markers(pred_info::in, pred_markers::out) is det.
@@ -709,16 +788,14 @@
 	constraint_proof_map::out) is det.
 :- pred pred_info_get_unproven_body_constraints(pred_info::in,
 	list(class_constraint)::out) is det.
-:- pred pred_info_get_maybe_special_pred(pred_info::in,
-	maybe(special_pred)::out) is det.
-:- pred pred_info_get_maybe_instance_method_constraints(pred_info::in,
-	maybe(instance_method_constraints)::out) is det.
 :- pred pred_info_get_assertions(pred_info::in, set(assert_id)::out) is det.
 :- pred pred_info_get_aditi_owner(pred_info::in, string::out) is det.
 :- pred pred_info_get_indexes(pred_info::in, list(index_spec)::out) is det.
 :- pred pred_info_clauses_info(pred_info::in, clauses_info::out) is det.
 :- pred pred_info_procedures(pred_info::in, proc_table::out) is det.
 
+:- pred pred_info_set_origin(pred_origin::in,
+	pred_info::in, pred_info::out) is det.
 :- pred pred_info_set_import_status(import_status::in,
 	pred_info::in, pred_info::out) is det.
 :- pred pred_info_set_goal_type(goal_type::in,
@@ -737,11 +814,6 @@
 	pred_info::in, pred_info::out) is det.
 :- pred pred_info_set_unproven_body_constraints(list(class_constraint)::in,
 	pred_info::in, pred_info::out) is det.
-:- pred pred_info_set_maybe_special_pred(maybe(special_pred)::in,
-	pred_info::in, pred_info::out) is det.
-:- pred pred_info_set_maybe_instance_method_constraints(
-	maybe(instance_method_constraints)::in,
-	pred_info::in, pred_info::out) is det.
 :- pred pred_info_set_assertions(set(assert_id)::in,
 	pred_info::in, pred_info::out) is det.
 :- pred pred_info_set_aditi_owner(string::in, pred_info::in, pred_info::out)
@@ -1001,7 +1073,7 @@
 				% module in which pred occurs
 		name		:: string,
 				% predicate name
-		arity		:: arity,
+		orig_arity	:: arity,
 				% the arity of the pred
 				% (*not* counting any inserted
 				% type_info arguments)
@@ -1010,6 +1082,8 @@
 				% a predicate or a function
 		context		:: prog_context,
 				% the location (line #) of the :- pred decl.
+		pred_origin	:: pred_origin,
+				% where did the predicate come from.
 
 		import_status	:: import_status,
 		goal_type	:: goal_type,
@@ -1068,20 +1142,6 @@
 				% post_typecheck.m will report a type
 				% error).
 
-		maybe_special_pred :: maybe(special_pred),
-				% If the predicate is a unify, compare
-				% or index predicate, specify which
-				% one, and for which type constructor.
-		maybe_instance_method_constraints
-				:: maybe(instance_method_constraints),
-				% If this predicate is a class method
-				% implementation, record extra
-				% information about the class context
-				% to allow polymorphism.m to
-				% correctly set up the extra
-				% type_info and typeclass_info
-				% arguments.
-
 		inst_graph_info	:: inst_graph_info,
 				% The predicate's inst graph, for constraint
 				% based mode analysis.
@@ -1107,7 +1167,7 @@
 		procedures	:: proc_table
 	).
 
-pred_info_init(ModuleName, SymName, Arity, PredOrFunc, Context,
+pred_info_init(ModuleName, SymName, Arity, PredOrFunc, Context, Origin,
 		Status, GoalType, Markers, ArgTypes, TypeVarSet, ExistQVars,
 		ClassContext, ClassProofs, User, ClausesInfo, PredInfo) :-
 	unqualify_name(SymName, PredName),
@@ -1116,21 +1176,19 @@
 	list__delete_elems(TVars, ExistQVars, HeadTypeParams),
 	Attributes = [],
 	UnprovenBodyConstraints = [],
-	MaybeUCI = no,
-	MaybeInstanceConstraints = no,
 	set__init(Assertions),
 	Indexes = [],
 	map__init(Procs),
 	PredInfo = pred_info(PredModuleName, PredName, Arity, PredOrFunc,
-		Context, Status, GoalType, Markers, Attributes,
+		Context, Origin, Status, GoalType, Markers, Attributes,
 		ArgTypes, TypeVarSet, TypeVarSet, ExistQVars, HeadTypeParams,
 		ClassContext, ClassProofs, UnprovenBodyConstraints,
-		MaybeUCI, MaybeInstanceConstraints, inst_graph_info_init, [],
-		Assertions, User, Indexes, ClausesInfo, Procs).
+		inst_graph_info_init, [], Assertions, User, Indexes,
+		ClausesInfo, Procs).
 
-pred_info_create(ModuleName, SymName, PredOrFunc, Context, Status, Markers,
-		ArgTypes, TypeVarSet, ExistQVars, ClassContext, Assertions,
-		User, ProcInfo, ProcId, PredInfo) :-
+pred_info_create(ModuleName, SymName, PredOrFunc, Context, Origin, Status,
+		Markers, ArgTypes, TypeVarSet, ExistQVars, ClassContext,
+		Assertions, User, ProcInfo, ProcId, PredInfo) :-
 	list__length(ArgTypes, Arity),
 	proc_info_varset(ProcInfo, VarSet),
 	proc_info_vartypes(ProcInfo, VarTypes),
@@ -1142,8 +1200,6 @@
 	list__delete_elems(TVars, ExistQVars, HeadTypeParams),
 	UnprovenBodyConstraints = [],
 	Indexes = [],
-	MaybeUCI = no,
-	MaybeInstanceConstraints = no,
 
 	% The empty list of clauses is a little white lie.
 	Clauses = [],
@@ -1161,16 +1217,16 @@
 	map__det_insert(Procs0, ProcId, ProcInfo, Procs),
 
 	PredInfo = pred_info(ModuleName, PredName, Arity, PredOrFunc,
-		Context, Status, clauses, Markers, Attributes,
+		Context, Origin, Status, clauses, Markers, Attributes,
 		ArgTypes, TypeVarSet, TypeVarSet, ExistQVars, HeadTypeParams,
 		ClassContext, ClassProofs, UnprovenBodyConstraints,
-		MaybeUCI, MaybeInstanceConstraints, inst_graph_info_init, [],
-		Assertions, User, Indexes, ClausesInfo, Procs).
+		inst_graph_info_init, [], Assertions, User, Indexes,
+		ClausesInfo, Procs).
 
-hlds_pred__define_new_pred(Goal0, Goal, ArgVars0, ExtraTypeInfos, InstMap0,
-		PredName, TVarSet, VarTypes0, ClassContext, TVarMap, TCVarMap,
-		VarSet0, InstVarSet, Markers, Owner, IsAddressTaken,
-		ModuleInfo0, ModuleInfo, PredProcId) :-
+hlds_pred__define_new_pred(Origin, Goal0, Goal, ArgVars0, ExtraTypeInfos,
+		InstMap0, PredName, TVarSet, VarTypes0, ClassContext,
+		TVarMap, TCVarMap, VarSet0, InstVarSet, Markers, Owner,
+		IsAddressTaken, ModuleInfo0, ModuleInfo, PredProcId) :-
 	Goal0 = _GoalExpr - GoalInfo,
 	goal_info_get_instmap_delta(GoalInfo, InstMapDelta),
 	instmap__apply_instmap_delta(InstMap0, InstMapDelta, InstMap),
@@ -1222,14 +1278,14 @@
 	),
 
 	MaybeDeclaredDetism = no,
-	proc_info_create(Context,VarSet, VarTypes, ArgVars, InstVarSet,
+	proc_info_create(Context, VarSet, VarTypes, ArgVars, InstVarSet,
 		ArgModes, MaybeDeclaredDetism, Detism, Goal0, 
 		TVarMap, TCVarMap, IsAddressTaken, ProcInfo0),
 	proc_info_set_maybe_termination_info(TermInfo, ProcInfo0, ProcInfo),
 
 	set__init(Assertions),
 
-	pred_info_create(ModuleName, SymName, predicate, Context,
+	pred_info_create(ModuleName, SymName, predicate, Context, Origin,
 		ExportStatus, Markers, ArgTypes, TVarSet, ExistQVars,
 		ClassContext, Assertions, Owner, ProcInfo, ProcId, PredInfo),
 
@@ -1260,10 +1316,11 @@
 
 pred_info_module(PI) = PI ^ module_name.
 pred_info_name(PI) = PI ^ name.
-pred_info_arity(PI) = PI ^ arity.
+pred_info_orig_arity(PI) = PI ^ orig_arity.
 
 pred_info_is_pred_or_func(PI) = PI ^ is_pred_or_func.
 pred_info_context(PI, PI ^ context).
+pred_info_get_origin(PI, PI ^ pred_origin).
 pred_info_import_status(PI, PI ^ import_status).
 pred_info_get_goal_type(PI, PI ^ goal_type).
 pred_info_get_markers(PI, PI ^ markers).
@@ -1275,15 +1332,13 @@
 pred_info_get_class_context(PI, PI ^ class_context).
 pred_info_get_constraint_proofs(PI, PI ^ constraint_proofs).
 pred_info_get_unproven_body_constraints(PI, PI ^ unproven_body_constraints).
-pred_info_get_maybe_special_pred(PI, PI ^ maybe_special_pred).
-pred_info_get_maybe_instance_method_constraints(PI,
-	PI ^ maybe_instance_method_constraints).
 pred_info_get_assertions(PI, PI ^ assertions).
 pred_info_get_aditi_owner(PI, PI ^ aditi_owner).
 pred_info_get_indexes(PI, PI ^ indexes).
 pred_info_clauses_info(PI, PI ^ clauses_info).
 pred_info_procedures(PI, PI ^ procedures).
 
+pred_info_set_origin(X, PI, PI ^ pred_origin := X).
 pred_info_set_import_status(X, PI, PI ^ import_status := X).
 pred_info_set_goal_type(X, PI, PI ^ goal_type := X).
 pred_info_set_markers(X, PI, PI ^ markers := X).
@@ -1294,10 +1349,6 @@
 pred_info_set_constraint_proofs(X, PI, PI ^ constraint_proofs := X).
 pred_info_set_unproven_body_constraints(X, PI,
 	PI ^ unproven_body_constraints := X).
-pred_info_set_maybe_special_pred(X, PI,
-	PI ^ maybe_special_pred := X).
-pred_info_set_maybe_instance_method_constraints(X, PI,
-	PI ^ maybe_instance_method_constraints := X).
 pred_info_set_assertions(X, PI, PI ^ assertions := X).
 pred_info_set_aditi_owner(X, PI, PI ^ aditi_owner := X).
 pred_info_set_indexes(X, PI, PI ^ indexes := X).
@@ -1427,7 +1478,7 @@
 		ImportStatus = external(ExternalImportStatus),
 		status_is_exported(ExternalImportStatus, yes)
 	;
-		pred_info_get_maybe_special_pred(PredInfo, yes(SpecialPred)),
+		pred_info_get_origin(PredInfo, special_pred(SpecialPred)),
 		SpecialPred = SpecialId - TypeCtor,
 		module_info_types(ModuleInfo, TypeTable),
 		% If the search fails, then TypeCtor must be a builtin type
@@ -1550,7 +1601,7 @@
 	PredOrFunc = pred_info_is_pred_or_func(PredInfo),
 	Module = pred_info_module(PredInfo),
 	Name = pred_info_name(PredInfo),
-	Arity = pred_info_arity(PredInfo).
+	Arity = pred_info_orig_arity(PredInfo).
 
 %-----------------------------------------------------------------------------%
 
@@ -2508,7 +2559,7 @@
 		InterfaceTypeInfoLiveness) :-
 	PredModule = pred_info_module(PredInfo),
 	PredName = pred_info_name(PredInfo),
-	PredArity = pred_info_arity(PredInfo),
+	PredArity = pred_info_orig_arity(PredInfo),
 	( no_type_info_builtin(PredModule, PredName, PredArity) ->
 		InterfaceTypeInfoLiveness = no
 	;
@@ -2554,7 +2605,7 @@
 body_should_use_typeinfo_liveness(PredInfo, Globals, BodyTypeInfoLiveness) :-
 	PredModule = pred_info_module(PredInfo),
 	PredName = pred_info_name(PredInfo),
-	PredArity = pred_info_arity(PredInfo),
+	PredArity = pred_info_orig_arity(PredInfo),
 	( no_type_info_builtin(PredModule, PredName, PredArity) ->
 		BodyTypeInfoLiveness = no
 	;
@@ -2789,7 +2840,7 @@
 	pred_info_is_pred_or_func(PredInfo) = function,
 	Module = pred_info_module(PredInfo),
 	Name = pred_info_name(PredInfo),
-	PredArity = pred_info_arity(PredInfo),
+	PredArity = pred_info_orig_arity(PredInfo),
 	adjust_func_arity(function, FuncArity, PredArity),
 	is_field_access_function_name(ModuleInfo, qualified(Module, Name),
 		FuncArity, _, _).
@@ -2827,7 +2878,7 @@
 pred_info_is_builtin(PredInfo) :-
 	ModuleName = pred_info_module(PredInfo),
 	PredName = pred_info_name(PredInfo),
-	Arity = pred_info_arity(PredInfo),
+	Arity = pred_info_orig_arity(PredInfo),
 	ProcId = hlds_pred__initial_proc_id,
 	is_inline_builtin(ModuleName, PredName, ProcId, Arity).
 
@@ -2835,7 +2886,7 @@
 	module_info_pred_info(ModuleInfo, PredId, PredInfo),
 	ModuleName = pred_info_module(PredInfo),
 	PredName = pred_info_name(PredInfo),
-	Arity = pred_info_arity(PredInfo),
+	Arity = pred_info_orig_arity(PredInfo),
 	module_info_globals(ModuleInfo, Globals),
 	globals__lookup_bool_option(Globals, inline_builtins, InlineBuiltins),
 	(
@@ -2866,7 +2917,7 @@
 prog_varset_init(VarSet) :- varset__init(VarSet).
 
 is_unify_or_compare_pred(PredInfo) :-
-	pred_info_get_maybe_special_pred(PredInfo, yes(_)).
+	pred_info_get_origin(PredInfo, special_pred(_)). % XXX bug
 
 %-----------------------------------------------------------------------------%
 
@@ -2937,7 +2988,7 @@
 hlds_pred__pred_info_is_aditi_aggregate(PredInfo) :-
 	Module = pred_info_module(PredInfo),
 	Name = pred_info_name(PredInfo),
-	Arity = pred_info_arity(PredInfo),
+	Arity = pred_info_orig_arity(PredInfo),
 	hlds_pred__aditi_aggregate(Module, Name, Arity).
 
 :- pred hlds_pred__aditi_aggregate(sym_name::in, string::in, int::in)
Index: compiler/intermod.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/intermod.m,v
retrieving revision 1.164
diff -u -b -r1.164 intermod.m
--- compiler/intermod.m	19 Jan 2005 03:10:37 -0000	1.164
+++ compiler/intermod.m	19 Jan 2005 04:52:48 -0000
@@ -318,7 +318,7 @@
 		% HeadVar1 = X, HeadVar2 = Y, etc. which will be optimized away
 		% later.  To counter for this, we add the arity to the
 		% size thresholds.
-		Arity = pred_info_arity(PredInfo),
+		Arity = pred_info_orig_arity(PredInfo),
 
 		% Predicates with `class_method' markers contain
 		% class_method_call goals which can't be written
@@ -1759,7 +1759,7 @@
 intermod__write_pragmas(PredInfo, !IO) :-
 	Module = pred_info_module(PredInfo),
 	Name = pred_info_name(PredInfo),
-	Arity = pred_info_arity(PredInfo),
+	Arity = pred_info_orig_arity(PredInfo),
 	PredOrFunc = pred_info_is_pred_or_func(PredInfo),
 	SymName = qualified(Module, Name),
 	pred_info_get_markers(PredInfo, Markers),
@@ -2158,9 +2158,8 @@
 		import_status_to_write(Status)
 	->
 		(
-			pred_info_get_maybe_special_pred(PredInfo0,
-				MaybeSpecial),
-			MaybeSpecial = yes(unify - _)
+			pred_info_get_origin(PredInfo0, Origin),
+			Origin = special_pred(unify - _)
 		->
 			NewStatus = pseudo_exported
 		;
Index: compiler/lambda.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/lambda.m,v
retrieving revision 1.94
diff -u -b -r1.94 lambda.m
--- compiler/lambda.m	21 Jan 2005 03:27:38 -0000	1.94
+++ compiler/lambda.m	21 Jan 2005 03:34:50 -0000
@@ -464,6 +464,7 @@
 		module_info_next_lambda_count(LambdaCount,
 			ModuleInfo0, ModuleInfo1),
 		goal_info_get_context(LambdaGoalInfo, OrigContext),
+		term__context_file(OrigContext, OrigFile),
 		term__context_line(OrigContext, OrigLine),
 		make_pred_name_with_context(ModuleName, "IntroducedFrom",
 			PredOrFunc, OrigPredName, OrigLine,
@@ -566,9 +567,10 @@
 		set__init(Assertions),
 
 		pred_info_create(ModuleName, PredName, PredOrFunc,
-			LambdaContext, local, LambdaMarkers,
-			ArgTypes, TVarSet, ExistQVars, Constraints,
-			Assertions, Owner, ProcInfo, ProcId, PredInfo),
+			LambdaContext, lambda(OrigFile, OrigLine), local,
+			LambdaMarkers, ArgTypes, TVarSet, ExistQVars,
+			Constraints, Assertions, Owner, ProcInfo, ProcId,
+			PredInfo),
 
 		% save the new predicate in the predicate table
 
Index: compiler/layout_out.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/layout_out.m,v
retrieving revision 1.40
diff -u -b -r1.40 layout_out.m
--- compiler/layout_out.m	19 Jan 2005 03:10:38 -0000	1.40
+++ compiler/layout_out.m	19 Jan 2005 04:52:49 -0000
@@ -96,8 +96,9 @@
 :- import_module ll_backend__code_util.
 :- import_module parse_tree__prog_data.
 :- import_module parse_tree__prog_out.
+:- import_module parse_tree__mercury_to_mercury.
 
-:- import_module int, char, string, require, std_util, list.
+:- import_module int, char, string, require, std_util, list, varset.
 
 output_layout_data_defn(label_layout_data(ProcLabel, LabelNum, ProcLayoutAddr,
 		MaybePort, MaybeIsHidden, LabelNumber, MaybeGoalPath,
@@ -683,7 +684,8 @@
 
 		output_proc_layout_data_defn_start(RttiProcLabel, Kind,
 			Traversal, !IO),
-		output_layout_proc_id_group(ProcLabel, !IO),
+		Origin = RttiProcLabel ^ pred_info_origin,
+		output_layout_proc_id_group(ProcLabel, Origin, !IO),
 		(
 			MaybeExecTrace = no,
 			io__write_string("NULL,\n", !IO)
@@ -793,11 +795,12 @@
 detism_to_c_detism(cc_nondet) =	  "MR_DETISM_CCNON".
 detism_to_c_detism(cc_multidet) = "MR_DETISM_CCMULTI".
 
-:- pred output_layout_proc_id_group(proc_label::in, io::di, io::uo) is det.
+:- pred output_layout_proc_id_group(proc_label::in, pred_origin::in,
+	io::di, io::uo) is det.
 
-output_layout_proc_id_group(ProcLabel, !IO) :-
+output_layout_proc_id_group(ProcLabel, Origin, !IO) :-
 	io__write_string("{\n", !IO),
-	output_proc_id(ProcLabel, !IO),
+	output_proc_id(ProcLabel, Origin, !IO),
 	io__write_string("},\n", !IO).
 
 :- pred output_layout_no_proc_id_group(io::di, io::uo) is det.
@@ -1005,7 +1008,7 @@
 	LayoutName = closure_proc_id(CallerProcLabel, SeqNo, ClosureProcLabel),
 	output_layout_name_storage_type_name(LayoutName, yes, !IO),
 	io__write_string(" = {\n{\n", !IO),
-	output_proc_id(ClosureProcLabel, !IO),
+	output_proc_id(ClosureProcLabel, lambda(FileName, LineNumber), !IO),
 	io__write_string("},\n", !IO),
 	prog_out__sym_name_to_string(ModuleName, ModuleNameStr),
 	quote_and_write_string(ModuleNameStr, !IO),
@@ -1018,12 +1021,13 @@
 	io__write_string("\n};\n", !IO),
 	decl_set_insert(data_addr(layout_addr(LayoutName)), !DeclSet).
 
-:- pred output_proc_id(proc_label::in, io::di, io::uo) is det.
+:- pred output_proc_id(proc_label::in, pred_origin::in, io::di, io::uo) is det.
 
-output_proc_id(ProcLabel, !IO) :-
+output_proc_id(ProcLabel, Origin, !IO) :-
 	(
 		ProcLabel = proc(DefiningModule, PredOrFunc, DeclaringModule,
-			Name, Arity, Mode),
+			PredName0, Arity, Mode),
+		PredName = origin_name(Origin, PredName0),
 		prog_out__sym_name_to_string(DefiningModule,
 			DefiningModuleStr),
 		prog_out__sym_name_to_string(DeclaringModule,
@@ -1034,7 +1038,7 @@
 		io__write_string(",\n", !IO),
 		quote_and_write_string(DefiningModuleStr, !IO),
 		io__write_string(",\n", !IO),
-		quote_and_write_string(Name, !IO),
+		quote_and_write_string(PredName, !IO),
 		io__write_string(",\n", !IO),
 		io__write_int(Arity, !IO),
 		io__write_string(",\n", !IO),
@@ -1043,6 +1047,9 @@
 	;
 		ProcLabel = special_proc(DefiningModule, SpecialPredId,
 			TypeModule, TypeName, TypeArity, Mode),
+		TypeCtor = qualified(TypeModule, TypeName) - TypeArity,
+		PredName0 = special_pred_name(SpecialPredId, TypeCtor),
+		PredName = origin_name(Origin, PredName0),
 		prog_out__sym_name_to_string(DefiningModule,
 			DefiningModuleStr),
 		prog_out__sym_name_to_string(TypeModule, TypeModuleStr),
@@ -1052,8 +1059,6 @@
 		io__write_string(",\n", !IO),
 		quote_and_write_string(DefiningModuleStr, !IO),
 		io__write_string(",\n", !IO),
-		TypeCtor = qualified(TypeModule, TypeName) - TypeArity,
-		PredName = special_pred_name(SpecialPredId, TypeCtor),
 		quote_and_write_string(PredName, !IO),
 		io__write_string(",\n", !IO),
 		io__write_int(TypeArity, !IO),
@@ -1061,6 +1066,93 @@
 		io__write_int(Mode, !IO),
 		io__write_string("\n", !IO)
 	).
+
+:- func origin_name(pred_origin, string) = string.
+
+origin_name(Origin, Name0) = Name :-
+	(
+		Origin = lambda(FileName0, LineNum),
+		( string__append("IntroducedFrom", _, Name0) ->
+			( string__remove_suffix(FileName0, ".m", FileName1) ->
+				FileName2 = FileName1
+			;
+				FileName2 = FileName0
+			),
+			string__replace_all(FileName2, ".", "_", FileName),
+			string__format("lambda_%s_%d",
+				[s(FileName), i(LineNum)], Name)
+		;
+			% If the lambda pred has a meaningful name, use it.
+			% This happens when the lambda is a partial application
+			% that happens to supply zero arguments.
+			Name = Name0
+		)
+	;
+		Origin = special_pred(_SpecialPredId - _TypeCtor),
+		Name = Name0
+		% We can't use the following code until we have adapted the
+		% code in the runtime and trace directories to handle the names
+		% of special preds the same way as we do user-defined names.
+% 		(
+% 			SpecialPredId = unify,
+% 			SpecialName = "unify"
+% 		;
+% 			SpecialPredId = compare,
+% 			SpecialName = "compare"
+% 		;
+% 			SpecialPredId = index,
+% 			SpecialName = "index"
+% 		;
+% 			SpecialPredId = initialise,
+% 			SpecialName = "init"
+% 		),
+% 		TypeCtor = TypeSymName - TypeArity,
+% 		TypeName = sym_name_to_string(TypeSymName),
+% 		string__format("%s_for_%s_%d",
+% 			[s(SpecialName), s(TypeName), i(TypeArity)], Name)
+	;
+		Origin = transformed(Transform, OldOrigin, _),
+		OldName = origin_name(OldOrigin, ""),
+		( OldName = "" ->
+			Name = Name0
+		;
+			Name = OldName ++ "_" ++ pred_transform_name(Transform)
+		)
+	;
+		Origin = instance_method(_),
+		Name = Name0
+	;
+		Origin = created(_),
+		Name = Name0
+	;
+		Origin = assertion(_, _),
+		Name = Name0
+	;
+		Origin = user(_),
+		Name = Name0
+	).
+
+:- func pred_transform_name(pred_transformation) = string.
+
+pred_transform_name(higher_order_specialization(Seq)) =
+	"ho" ++ int_to_string(Seq).
+pred_transform_name(higher_order_type_specialization(Proc)) =
+	"hoproc" ++ int_to_string(Proc).
+pred_transform_name(type_specialization(Substs)) =
+	string__join_list("_", list__map(subst_to_name, Substs)).
+pred_transform_name(unused_argument_elimination(Posns)) = "ua_" ++
+	string__join_list("_", list__map(int_to_string, Posns)).
+pred_transform_name(accumulator(Posns)) = "acc_" ++
+	string__join_list("_", list__map(int_to_string, Posns)).
+pred_transform_name(loop_invariant(Proc)) = "inv_" ++ int_to_string(Proc).
+pred_transform_name(table_generator) = "table_gen".
+pred_transform_name(dnf(N)) = "dnf_" ++ int_to_string(N).
+
+:- func subst_to_name(pair(int, type)) = string.
+
+subst_to_name(TVar - Type) =
+	string__format("%d/%s",
+		[i(TVar), s(mercury_term_to_string(Type, varset__init, no))]).
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/loop_inv.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/loop_inv.m,v
retrieving revision 1.14
diff -u -b -r1.14 loop_inv.m
--- compiler/loop_inv.m	19 Jan 2005 03:10:39 -0000	1.14
+++ compiler/loop_inv.m	19 Jan 2005 04:52:49 -0000
@@ -760,6 +760,7 @@
     hlds_pred__proc_info_inst_varset(ProcInfo, InstVarSet),
     hlds_pred__pred_info_get_markers(PredInfo, Markers),
     hlds_pred__pred_info_get_aditi_owner(PredInfo, Owner),
+    hlds_pred__pred_info_get_origin(PredInfo, OrigOrigin),
 
     PredName = hlds_pred__pred_info_name(PredInfo),
     hlds_goal__goal_info_get_context(GoalInfo, Context),
@@ -776,7 +777,9 @@
 
         % Put in oven at gas mark 11 and bake.
         %
+    Origin = transformed(loop_invariant(ProcNo), OrigOrigin, PredId),
     hlds_pred__define_new_pred(
+        Origin,         % in    - The origin of this new predicate
         Goal,           % in    - The goal for the new aux proc.
         CallAux,        % out   - How we can call the new aux proc.
         AuxHeadVars,    % in    - The args for the new aux proc.
Index: compiler/magic.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/magic.m,v
retrieving revision 1.49
diff -u -b -r1.49 magic.m
--- compiler/magic.m	21 Jan 2005 03:27:38 -0000	1.49
+++ compiler/magic.m	21 Jan 2005 03:34:51 -0000
@@ -660,8 +660,8 @@
 	{ ClassConstraints = constraints([], []) },
 	{ set__init(Assertions) },
 	{ pred_info_create(Module, NewName, PredOrFunc, Context,
-		Status, Markers, ArgTypes, TVarSet, ExistQVars,
-		ClassConstraints, Assertions, Owner, ProcInfo0,
+		created(aditi_magic), Status, Markers, ArgTypes, TVarSet,
+		ExistQVars, ClassConstraints, Assertions, Owner, ProcInfo0,
 		NewProcId, NewPredInfo0) },
 	{ pred_info_set_indexes(Indexes, NewPredInfo0, NewPredInfo) },
 
@@ -880,11 +880,11 @@
 	{ map__init(TVarMap) },
 	{ map__init(TCVarMap) },
 	{ varset__init(TVarSet) },
-	{ hlds_pred__define_new_pred(Goal, CallGoal, HeadVars, ExtraArgs,
-		InstMap, PredName, TVarSet, VarTypes, ClassContext, TVarMap,
-		TCVarMap, VarSet, InstVarSet, Markers, Owner,
-		address_is_not_taken, ModuleInfo1, ModuleInfo2,
-		LocalPredProcId) },
+	{ hlds_pred__define_new_pred(created(aditi_magic_interface),
+		Goal, CallGoal, HeadVars, ExtraArgs, InstMap, PredName,
+		TVarSet, VarTypes, ClassContext, TVarMap, TCVarMap,
+		VarSet, InstVarSet, Markers, Owner, address_is_not_taken,
+		ModuleInfo1, ModuleInfo2, LocalPredProcId) },
 	{ ExtraArgs = [] ->
 		true
 	;
@@ -1159,8 +1159,8 @@
 	ExistQVars = [],
 	set__init(Assertions),
 	pred_info_create(PredModule, qualified(PredModule, NewPredName),
-		predicate, DummyContext, exported, Markers,
-		NewArgTypes, TVarSet, ExistQVars,
+		predicate, DummyContext, created(aditi_join), exported,
+		Markers, NewArgTypes, TVarSet, ExistQVars,
 		ClassContext, Assertions, User,
 		JoinProcInfo, JoinProcId, JoinPredInfo),
 
@@ -1297,9 +1297,9 @@
 	{ ExistQVars = [] },
 	{ set__init(Assertions) },
 	{ pred_info_create(ModuleName, SymName, predicate, Context,
-		local, Markers, AllArgTypes, TVarSet, ExistQVars,
-		ClassConstraints, Assertions, Owner, ProcInfo, MagicProcId,
-		MagicPredInfo) },
+		created(aditi_magic), local, Markers, AllArgTypes,
+		TVarSet, ExistQVars, ClassConstraints, Assertions, Owner,
+		ProcInfo, MagicProcId, MagicPredInfo) },
 
 	{ module_info_get_predicate_table(ModuleInfo0, PredTable0) },
 	{ predicate_table_insert(MagicPredInfo, MagicPredId,
Index: compiler/magic_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/magic_util.m,v
retrieving revision 1.44
diff -u -b -r1.44 magic_util.m
--- compiler/magic_util.m	21 Jan 2005 03:27:39 -0000	1.44
+++ compiler/magic_util.m	21 Jan 2005 03:34:51 -0000
@@ -1109,10 +1109,11 @@
 	{ map__init(TCVarMap) },
 	{ proc_info_varset(ProcInfo, VarSet) },
 	{ unqualify_name(NewName, NewPredName) },
-	{ hlds_pred__define_new_pred(SuppGoal, SuppCall, SuppArgs, ExtraArgs,
-		InstMap, NewPredName, TVarSet, VarTypes, ClassConstraints,
-		TVarMap, TCVarMap, VarSet, InstVarSet, Markers, Owner,
-		address_is_not_taken, ModuleInfo0, ModuleInfo, _) },
+	{ hlds_pred__define_new_pred(created(aditi_magic_supp), SuppGoal,
+		SuppCall, SuppArgs, ExtraArgs, InstMap, NewPredName, TVarSet,
+		VarTypes, ClassConstraints, TVarMap, TCVarMap, VarSet,
+		InstVarSet, Markers, Owner, address_is_not_taken,
+		ModuleInfo0, ModuleInfo, _) },
 	{ ExtraArgs = [] ->
 		true
 	;
Index: compiler/make_hlds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make_hlds.m,v
retrieving revision 1.493
diff -u -b -r1.493 make_hlds.m
--- compiler/make_hlds.m	21 Jan 2005 03:27:39 -0000	1.493
+++ compiler/make_hlds.m	21 Jan 2005 03:34:52 -0000
@@ -1682,9 +1682,13 @@
 
 			ModuleName = pred_info_module(PredInfo0),
 			pred_info_get_aditi_owner(PredInfo0, Owner),
+			pred_info_get_origin(PredInfo0, OrigOrigin),
+			SubstDesc = list__map(subst_desc, Subst),
+			Origin = transformed(type_specialization(SubstDesc),
+				OrigOrigin, PredId),
 			pred_info_init(ModuleName, SpecName, PredArity,
-				PredOrFunc, Context, Status, none, Markers,
-				Types, TVarSet, ExistQVars,
+				PredOrFunc, Context, Origin, Status,
+				none, Markers, Types, TVarSet, ExistQVars,
 				ClassContext, Proofs,
 				Owner, Clauses, NewPredInfo0),
 			pred_info_set_procedures(Procs,
@@ -1749,6 +1753,10 @@
 		TransformInfo = transform_info(ModuleInfo1, Info0)
 	).
 
+:- func subst_desc(pair(tvar, type)) = pair(int, type).
+
+subst_desc(TVar - Type) = var_to_int(TVar) - Type.
+
 	% Check that the type substitution for a `:- pragma type_spec'
 	% declaration is valid.
 	% A type substitution is invalid if:
@@ -1968,7 +1976,7 @@
 report_pragma_type_spec(PredInfo0, Context) -->
 	{ Module = pred_info_module(PredInfo0) },
 	{ Name = pred_info_name(PredInfo0) },
-	{ Arity = pred_info_arity(PredInfo0) },
+	{ Arity = pred_info_orig_arity(PredInfo0) },
 	{ PredOrFunc = pred_info_is_pred_or_func(PredInfo0) },
 	prog_out__write_context(Context),
 	io__write_string("In `:- pragma type_spec' declaration for "),
@@ -3735,7 +3743,7 @@
 		list__foldl(add_marker, MarkersList, Markers0, Markers),
 		globals__io_lookup_string_option(aditi_user, Owner, !IO),
 		pred_info_init(ModuleName, PredName, Arity, PredOrFunc,
-			Context, Status, none, Markers,
+			Context, user(PredName), Status, none, Markers,
 			Types, TVarSet, ExistQVars, ClassContext, Proofs,
 			Owner, ClausesInfo, PredInfo0),
 		(
@@ -4218,7 +4226,7 @@
 	pred_info_get_markers(PredInfo2, Markers2),
 	add_marker(calls_are_fully_qualified, Markers2, Markers),
 	pred_info_set_markers(Markers, PredInfo2, PredInfo3),
-	pred_info_set_maybe_special_pred(yes(SpecialPredId - TypeCtor),
+	pred_info_set_origin(special_pred(SpecialPredId - TypeCtor),
 		PredInfo3, PredInfo),
 	map__det_update(Preds0, PredId, PredInfo, Preds),
 	module_info_set_preds(Preds, !Module).
@@ -4288,6 +4296,7 @@
 	),
 	special_pred_name_arity(SpecialPredId, _, Arity),
 	clauses_info_init(Arity, ClausesInfo0),
+	Origin = special_pred(SpecialPredId - TypeCtor),
 	adjust_special_pred_status(SpecialPredId, Status0, Status),
 	map__init(Proofs),
 	init_markers(Markers),
@@ -4298,16 +4307,14 @@
 	module_info_globals(!.Module, Globals),
 	globals__lookup_string_option(Globals, aditi_user, Owner),
 	pred_info_init(ModuleName, PredName, Arity, predicate, Context,
-		Status, none, Markers, ArgTypes, TVarSet, ExistQVars,
+		Origin, Status, none, Markers, ArgTypes, TVarSet, ExistQVars,
 		ClassContext, Proofs, Owner, ClausesInfo0, PredInfo0),
-	pred_info_set_maybe_special_pred(yes(SpecialPredId - TypeCtor),
-		PredInfo0, PredInfo1),
 	ArgLives = no,
 	varset__init(InstVarSet),
 		% Should not be any inst vars here so it's ok to use a
 		% fresh inst_varset.
 	add_new_proc(InstVarSet, Arity, ArgModes, yes(ArgModes), ArgLives,
-		yes(Det), Context, address_is_not_taken, PredInfo1, PredInfo,
+		yes(Det), Context, address_is_not_taken, PredInfo0, PredInfo,
 		_),
 
 	module_info_get_predicate_table(!.Module, PredicateTable0),
@@ -4410,7 +4417,8 @@
 	;
 		preds_add_implicit_report_error(ModuleName, PredOrFunc,
 			PredName, Arity, Status, IsClassMethod, MContext,
-			"mode declaration", PredId, !ModuleInfo, !IO)
+			user(PredName), "mode declaration", PredId,
+			!ModuleInfo, !IO)
 	),
 
 		% Lookup the pred_info for this predicate
@@ -4475,35 +4483,39 @@
 
 :- pred preds_add_implicit_report_error(module_name::in, pred_or_func::in,
 	sym_name::in, arity::in, import_status::in, bool::in, prog_context::in,
-	string::in, pred_id::out, module_info::in, module_info::out,
-	io::di, io::uo) is det.
+	pred_origin::in, string::in, pred_id::out,
+	module_info::in, module_info::out, io::di, io::uo) is det.
 
 preds_add_implicit_report_error(ModuleName, PredOrFunc, PredName, Arity,
-		Status, IsClassMethod, Context, Description, PredId,
+		Status, IsClassMethod, Context, Origin, Description, PredId,
 		!ModuleInfo, !IO) :-
 	maybe_undefined_pred_error(PredName, Arity, PredOrFunc, Status,
 		IsClassMethod, Context, Description, !IO),
-	( PredOrFunc = function ->
+	(
+		PredOrFunc = function,
 		adjust_func_arity(function, FuncArity, Arity),
 		maybe_check_field_access_function(PredName, FuncArity,
 			Status, Context, !.ModuleInfo, !IO)
 	;
-		true
+		PredOrFunc = predicate
 	),
 	module_info_get_predicate_table(!.ModuleInfo, PredicateTable0),
 	preds_add_implicit(!.ModuleInfo, ModuleName, PredName, Arity, Status,
-		Context, PredOrFunc, PredId, PredicateTable0, PredicateTable),
+		Context, Origin, PredOrFunc, PredId,
+		PredicateTable0, PredicateTable),
 	module_info_set_predicate_table(PredicateTable, !ModuleInfo).
 
 :- pred preds_add_implicit(module_info::in, module_name::in, sym_name::in,
-	arity::in, import_status::in, prog_context::in, pred_or_func::in,
-	pred_id::out, predicate_table::in, predicate_table::out) is det.
+	arity::in, import_status::in, prog_context::in, pred_origin::in,
+	pred_or_func::in, pred_id::out,
+	predicate_table::in, predicate_table::out) is det.
 
 preds_add_implicit(ModuleInfo, ModuleName, PredName, Arity, Status, Context,
-		PredOrFunc, PredId, !PredicateTable) :-
+		Origin, PredOrFunc, PredId, !PredicateTable) :-
 	clauses_info_init(Arity, ClausesInfo),
 	preds_add_implicit_2(ClausesInfo, ModuleInfo, ModuleName, PredName,
-		Arity, Status, Context, PredOrFunc, PredId, !PredicateTable).
+		Arity, Status, Context, Origin, PredOrFunc, PredId,
+		!PredicateTable).
 
 :- pred preds_add_implicit_for_assertion(prog_vars::in, module_info::in,
 	module_name::in, sym_name::in, arity::in, import_status::in,
@@ -4513,16 +4525,20 @@
 preds_add_implicit_for_assertion(HeadVars, ModuleInfo, ModuleName, PredName,
 		Arity, Status, Context, PredOrFunc, PredId, !PredicateTable) :-
 	clauses_info_init_for_assertion(HeadVars, ClausesInfo),
+	term__context_file(Context, FileName),
+	term__context_line(Context, LineNum),
 	preds_add_implicit_2(ClausesInfo, ModuleInfo, ModuleName, PredName,
-		Arity, Status, Context, PredOrFunc, PredId, !PredicateTable).
+		Arity, Status, Context, assertion(FileName, LineNum),
+		PredOrFunc, PredId, !PredicateTable).
 
 :- pred preds_add_implicit_2(clauses_info::in, module_info::in,
 	module_name::in, sym_name::in, arity::in, import_status::in,
-	prog_context::in, pred_or_func::in, pred_id::out,
+	prog_context::in, pred_origin::in, pred_or_func::in, pred_id::out,
 	predicate_table::in, predicate_table::out) is det.
 
 preds_add_implicit_2(ClausesInfo, ModuleInfo, ModuleName, PredName, Arity,
-		Status, Context, PredOrFunc, PredId, !PredicateTable) :-
+		Status, Context, Origin, PredOrFunc, PredId,
+		!PredicateTable) :-
 	varset__init(TVarSet0),
 	make_n_fresh_vars("T", Arity, TypeVars, TVarSet0, TVarSet),
 	term__var_list_to_term_list(TypeVars, Types),
@@ -4537,7 +4553,7 @@
 	module_info_globals(ModuleInfo, Globals),
 	globals__lookup_string_option(Globals, aditi_user, Owner),
 	pred_info_init(ModuleName, PredName, Arity, PredOrFunc, Context,
-		Status, none, Markers0, Types, TVarSet, ExistQVars,
+		Origin, Status, none, Markers0, Types, TVarSet, ExistQVars,
 		ClassContext, Proofs, Owner, ClausesInfo, PredInfo0),
 	add_marker(infer_type, Markers0, Markers),
 	pred_info_set_markers(Markers, PredInfo0, PredInfo),
@@ -4633,7 +4649,8 @@
 		;
 			preds_add_implicit_report_error(ModuleName,
 				PredOrFunc, PredName, Arity, Status, no,
-				Context, "clause", PredId, !ModuleInfo, !IO)
+				Context, user(PredName), "clause", PredId,
+				!ModuleInfo, !IO)
 		)
 	),
 		% Lookup the pred_info for this pred,
@@ -5054,7 +5071,7 @@
 		PredId = PredId0
 	;
 		preds_add_implicit_report_error(ModuleName, PredOrFunc,
-			PredName, Arity, Status, no, Context,
+			PredName, Arity, Status, no, Context, user(PredName),
 			"`:- pragma import' declaration", PredId,
 			!ModuleInfo, !IO)
 	),
@@ -5174,14 +5191,15 @@
 	list__length(PVars, Arity),
 		% print out a progress message
 	globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO),
-	( VeryVerbose = yes ->
+	(
+		VeryVerbose = yes,
 		io__write_string("% Processing `:- pragma foreign_proc' for ",
 			!IO),
 		hlds_out__write_simple_call_id(PredOrFunc, PredName/Arity,
 			!IO),
 		io__write_string("...\n", !IO)
 	;
-		true
+		VeryVerbose = no
 	),
 
 	globals__io_get_backend_foreign_languages(BackendForeignLangs, !IO),
@@ -5198,7 +5216,7 @@
 		PredId = PredId0
 	;
 		preds_add_implicit_report_error(ModuleName, PredOrFunc,
-			PredName, Arity, Status, no, Context,
+			PredName, Arity, Status, no, Context, user(PredName),
 			"`:- pragma foreign_proc' declaration",
 			PredId, !ModuleInfo, !IO)
 	),
@@ -5317,8 +5335,7 @@
 
 	% Find out if we are tabling a predicate or a function
 	(
-		MaybePredOrFunc = yes(PredOrFunc0)
-	->
+		MaybePredOrFunc = yes(PredOrFunc0),
 		PredOrFunc = PredOrFunc0,
 
 			% Lookup the pred declaration in the predicate table.
@@ -5337,10 +5354,12 @@
 
 			preds_add_implicit_report_error(ModuleName, PredOrFunc,
 				PredName, Arity, Status, no, Context,
-				Message1, PredId, !ModuleInfo, !IO),
+				user(PredName), Message1, PredId, !ModuleInfo,
+				!IO),
 			PredIds = [PredId]
 		)
 	;
+		MaybePredOrFunc = no,
 		(
 			predicate_table_search_sym_arity(PredicateTable0,
 				is_fully_qualified, PredName,
@@ -5354,7 +5373,7 @@
 
 			preds_add_implicit_report_error(ModuleName,
 				predicate, PredName, Arity, Status, no,
-				Context, Message1, PredId,
+				Context, user(PredName), Message1, PredId,
 				!ModuleInfo, !IO),
 			PredIds = [PredId]
 		)
@@ -8940,7 +8959,7 @@
 	{ pred_info_context(PredInfo, Context) },
 	{ Module = pred_info_module(PredInfo) },
 	{ Name = pred_info_name(PredInfo) },
-	{ Arity = pred_info_arity(PredInfo) },
+	{ Arity = pred_info_orig_arity(PredInfo) },
 	io__set_exit_status(1),
 	prog_out__write_context(Context),
 	io__write_string("Error: no mode declaration for type class method\n"),
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.321
diff -u -b -r1.321 mercury_compile.m
--- compiler/mercury_compile.m	21 Jan 2005 03:32:14 -0000	1.321
+++ compiler/mercury_compile.m	21 Jan 2005 03:34:53 -0000
@@ -2576,7 +2576,7 @@
 		(
 			PredModule = pred_info_module(PredInfo),
 			PredName = pred_info_name(PredInfo),
-			PredArity = pred_info_arity(PredInfo),
+			PredArity = pred_info_orig_arity(PredInfo),
 			no_type_info_builtin(PredModule, PredName, PredArity)
 		->
 				% These predicates should never be traced,
Index: compiler/ml_code_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_code_util.m,v
retrieving revision 1.87
diff -u -b -r1.87 ml_code_util.m
--- compiler/ml_code_util.m	21 Jan 2005 03:27:41 -0000	1.87
+++ compiler/ml_code_util.m	21 Jan 2005 03:34:53 -0000
@@ -1077,7 +1077,7 @@
 	% to type_infos that don't get passed
 	PredModule = pred_info_module(PredInfo),
 	PredName = pred_info_name(PredInfo),
-	PredArity = pred_info_arity(PredInfo),
+	PredArity = pred_info_orig_arity(PredInfo),
 	( no_type_info_builtin(PredModule, PredName, PredArity) ->
 		FuncParams = ml_gen_params(ModuleInfo, HeadVarNames, HeadTypes,
 			HeadModes, PredOrFunc, CodeModel)
@@ -1385,8 +1385,8 @@
 		PredName, PredArity, _ArgTypes, PredId, ProcId,
 		_HeadVarsWithNames, _ArgModes, Detism,
 		PredIsImported, _PredIsPseudoImported,
-		IsSpecialPred, _ProcIsExported, _ProcIsImported),
-	( IsSpecialPred = yes(SpecialPred - TypeCtor) ->
+		Origin, _ProcIsExported, _ProcIsImported),
+	( Origin = special_pred(SpecialPred - TypeCtor) ->
 		(
 			% All type_ctors other than tuples here should be
 			% module qualified, since builtin types are handled
Index: compiler/mode_errors.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mode_errors.m,v
retrieving revision 1.83
diff -u -b -r1.83 mode_errors.m
--- compiler/mode_errors.m	19 Jan 2005 03:10:46 -0000	1.83
+++ compiler/mode_errors.m	19 Jan 2005 04:52:56 -0000
@@ -1016,7 +1016,7 @@
 	{ PredName = pred_info_name(PredInfo) },
 	{ Name = unqualified(PredName) },
 	{ pred_info_context(PredInfo, Context) },
-	{ PredArity = pred_info_arity(PredInfo) },
+	{ PredArity = pred_info_orig_arity(PredInfo) },
 	{ proc_info_argmodes(ProcInfo, ArgModes0) },
 
 	% We need to strip off the extra type_info arguments inserted at the
Index: compiler/modes.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modes.m,v
retrieving revision 1.290
diff -u -b -r1.290 modes.m
--- compiler/modes.m	21 Jan 2005 03:27:43 -0000	1.290
+++ compiler/modes.m	21 Jan 2005 03:34:54 -0000
@@ -2253,7 +2253,7 @@
 	% type_info arguments get argument numbers less than or equal to 0.
 	%
 compute_arg_offset(PredInfo, ArgOffset) :-
-	OrigArity = pred_info_arity(PredInfo),
+	OrigArity = pred_info_orig_arity(PredInfo),
 	pred_info_arg_types(PredInfo, ArgTypes),
 	list__length(ArgTypes, CurrentArity),
 	ArgOffset = OrigArity - CurrentArity.
@@ -2750,7 +2750,7 @@
 	),
 	(
 		pred_info_name(PredInfo) = "main",
-		pred_info_arity(PredInfo) = 2,
+		pred_info_orig_arity(PredInfo) = 2,
 		pred_info_is_exported(PredInfo),
 		\+ check_mode_of_main(Modes, !.ModuleInfo)
 	->
Index: compiler/passes_aux.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/passes_aux.m,v
retrieving revision 1.65
diff -u -b -r1.65 passes_aux.m
--- compiler/passes_aux.m	19 Jan 2005 03:10:50 -0000	1.65
+++ compiler/passes_aux.m	19 Jan 2005 04:52:57 -0000
@@ -650,7 +650,7 @@
 	{ module_info_pred_proc_info(ModuleInfo, PredId, ProcId,
 		PredInfo, ProcInfo) },
 	{ PredName = pred_info_name(PredInfo) },
-	{ Arity = pred_info_arity(PredInfo) },
+	{ Arity = pred_info_orig_arity(PredInfo) },
 	{ PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
 	{ proc_info_context(ProcInfo, Context) },
 	{ proc_info_argmodes(ProcInfo, ArgModes0) },
Index: compiler/pd_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/pd_info.m,v
retrieving revision 1.16
diff -u -b -r1.16 pd_info.m
--- compiler/pd_info.m	19 Jan 2005 03:10:50 -0000	1.16
+++ compiler/pd_info.m	19 Jan 2005 04:52:58 -0000
@@ -373,8 +373,8 @@
 
 	% Create a new predicate for the input goal, returning a
 	% goal which calls the new predicate.
-:- pred pd_info__define_new_pred(hlds_goal::in, pred_proc_id::out,
-	hlds_goal::out, pd_info::in, pd_info::out) is det.
+:- pred pd_info__define_new_pred(pred_origin::in, hlds_goal::in,
+	pred_proc_id::out, hlds_goal::out, pd_info::in, pd_info::out) is det.
 
 	% Add a version to the table.
 :- pred pd_info__register_version(pred_proc_id::in, version_info::in,
@@ -594,7 +594,7 @@
 
 %-----------------------------------------------------------------------------%
 
-pd_info__define_new_pred(Goal, PredProcId, CallGoal, !PDInfo) :-
+pd_info__define_new_pred(Origin, Goal, PredProcId, CallGoal, !PDInfo) :-
 	pd_info_get_instmap(!.PDInfo, InstMap),
 	Goal = _ - GoalInfo,
 	goal_info_get_nonlocals(GoalInfo, NonLocals),
@@ -624,10 +624,10 @@
 	proc_info_inst_varset(ProcInfo, InstVarSet),
 	% XXX handle the extra typeinfo arguments for
 	% --typeinfo-liveness properly.
-	hlds_pred__define_new_pred(Goal, CallGoal, Args, _ExtraArgs, InstMap,
-		Name, TVarSet, VarTypes, ClassContext, TVarMap, TCVarMap,
-		VarSet, InstVarSet, Markers, Owner, address_is_not_taken,
-		ModuleInfo0, ModuleInfo, PredProcId),
+	hlds_pred__define_new_pred(Origin, Goal, CallGoal, Args, _ExtraArgs,
+		InstMap, Name, TVarSet, VarTypes, ClassContext,
+		TVarMap, TCVarMap, VarSet, InstVarSet, Markers, Owner,
+		address_is_not_taken, ModuleInfo0, ModuleInfo, PredProcId),
 	pd_info_set_module_info(ModuleInfo, !PDInfo).
 
 %-----------------------------------------------------------------------------%
Index: compiler/polymorphism.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/polymorphism.m,v
retrieving revision 1.258
diff -u -b -r1.258 polymorphism.m
--- compiler/polymorphism.m	21 Jan 2005 03:27:45 -0000	1.258
+++ compiler/polymorphism.m	21 Jan 2005 03:34:55 -0000
@@ -425,7 +425,7 @@
 		;
 			PredModule = pred_info_module(PredInfo),
 			PredName = pred_info_name(PredInfo),
-			PredArity = pred_info_arity(PredInfo),
+			PredArity = pred_info_orig_arity(PredInfo),
 			no_type_info_builtin(PredModule, PredName, PredArity)
 		)
 	->
@@ -696,10 +696,14 @@
 polymorphism__setup_headvars(PredInfo, HeadVars0, HeadVars, ExtraArgModes,
 		HeadTypeVars, UnconstrainedTVars, ExtraHeadTypeInfoVars,
 		ExistHeadTypeClassInfoVars, !Info) :-
-	pred_info_get_maybe_instance_method_constraints(PredInfo,
-		MaybeInstanceMethodConstraints),
-	(
-		MaybeInstanceMethodConstraints = no,
+	pred_info_get_origin(PredInfo, Origin),
+	( Origin = instance_method(InstanceMethodConstraints) ->
+		polymorphism__setup_headvars_instance_method(PredInfo,
+			InstanceMethodConstraints, HeadVars0, HeadVars,
+			ExtraArgModes, HeadTypeVars, UnconstrainedTVars,
+			ExtraHeadTypeInfoVars, ExistHeadTypeClassInfoVars,
+			!Info)
+	;
 		pred_info_get_class_context(PredInfo, ClassContext),
 		ExtraHeadVars0 = [],
 		ExtraArgModes0 = [],
@@ -712,14 +716,6 @@
 			ExtraArgModes, HeadTypeVars, UnconstrainedTVars,
 			ExtraHeadTypeInfoVars, ExistHeadTypeClassInfoVars,
 			!Info)
-	;
-		MaybeInstanceMethodConstraints =
-			yes(InstanceMethodConstraints),
-		polymorphism__setup_headvars_instance_method(PredInfo,
-			InstanceMethodConstraints, HeadVars0, HeadVars,
-			ExtraArgModes, HeadTypeVars, UnconstrainedTVars,
-			ExtraHeadTypeInfoVars, ExistHeadTypeClassInfoVars,
-			!Info)
 	).
 
 	%
@@ -1032,7 +1028,7 @@
 	module_info_pred_info(ModuleInfo, PredId, PredInfo),
 	PredModule = pred_info_module(PredInfo),
 	PredName = pred_info_name(PredInfo),
-	PredArity = pred_info_arity(PredInfo),
+	PredArity = pred_info_orig_arity(PredInfo),
 
 	( no_type_info_builtin(PredModule, PredName, PredArity) ->
 		Goal = Goal0 - GoalInfo0
@@ -1789,7 +1785,7 @@
 
 	PredModule = pred_info_module(PredInfo),
 	PredName = pred_info_name(PredInfo),
-	PredArity = pred_info_arity(PredInfo),
+	PredArity = pred_info_orig_arity(PredInfo),
 	(
 		(
 			% Optimize for the common case of non-polymorphic call
Index: compiler/post_typecheck.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/post_typecheck.m,v
retrieving revision 1.68
diff -u -b -r1.68 post_typecheck.m
--- compiler/post_typecheck.m	21 Jan 2005 03:27:45 -0000	1.68
+++ compiler/post_typecheck.m	21 Jan 2005 03:34:55 -0000
@@ -806,7 +806,7 @@
 		% program entry point main/2.
 		%
 		pred_info_name(PredInfo) = "main",
-		pred_info_arity(PredInfo) = 2,
+		pred_info_orig_arity(PredInfo) = 2,
 		pred_info_is_exported(PredInfo)
 	->
 		%
@@ -936,8 +936,8 @@
 		% but the polymorphic unify needs to be able to call
 		% the semidet mode.)
 		%
-		pred_info_get_maybe_special_pred(!.PredInfo, MaybeSpecial),
-		MaybeSpecial = yes(unify - _)
+		pred_info_get_origin(!.PredInfo, Origin),
+		Origin = special_pred(unify - _)
 	->
 		true
 	;
@@ -1095,7 +1095,7 @@
 report_aditi_pragma(PredInfo, ErrorPieces) :-
 	Module = pred_info_module(PredInfo),
 	Name = pred_info_name(PredInfo),
-	Arity = pred_info_arity(PredInfo),
+	Arity = pred_info_orig_arity(PredInfo),
 	PredOrFunc = pred_info_is_pred_or_func(PredInfo),
 	pred_info_get_markers(PredInfo, Markers),
 	( check_marker(Markers, base_relation) ->
Index: compiler/pragma_c_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/pragma_c_gen.m,v
retrieving revision 1.73
diff -u -b -r1.73 pragma_c_gen.m
--- compiler/pragma_c_gen.m	21 Jan 2005 03:27:45 -0000	1.73
+++ compiler/pragma_c_gen.m	21 Jan 2005 03:34:55 -0000
@@ -714,7 +714,7 @@
 	module_info_pred_info(ModuleInfo, PredId, PredInfo),
 	ModuleName = pred_info_module(PredInfo),
 	PredName = pred_info_name(PredInfo),
-	Arity = pred_info_arity(PredInfo),
+	Arity = pred_info_orig_arity(PredInfo),
 	pragma_c_gen__struct_name(ModuleName, PredName, Arity, ProcId,
 		StructName),
 	SaveStructDecl = pragma_c_struct_ptr_decl(StructName, "LOCALS"),
Index: compiler/proc_label.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/proc_label.m,v
retrieving revision 1.9
diff -u -b -r1.9 proc_label.m
--- compiler/proc_label.m	21 Jan 2005 03:27:46 -0000	1.9
+++ compiler/proc_label.m	21 Jan 2005 03:34:55 -0000
@@ -62,9 +62,9 @@
 	RttiProcLabel = rtti_proc_label(PredOrFunc, ThisModule,
 		PredModule, PredName, PredArity, _ArgTypes, _PredId, ProcId,
 		_ProcHeadVarsWithNames, _ArgModes, _CodeModel,
-		PredIsImported, _PredIsPseudoImported, IsSpecialPred,
+		PredIsImported, _PredIsPseudoImported, Origin,
 		_ProcIsExported, _ProcIsImported),
-	( IsSpecialPred = yes(SpecialPred - TypeCtor) ->
+	( Origin = special_pred(SpecialPred - TypeCtor) ->
 		(
 			% All type_ctors other than tuples here should be
 			% module qualified, since builtin types are
Index: compiler/purity.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/purity.m,v
retrieving revision 1.70
diff -u -b -r1.70 purity.m
--- compiler/purity.m	21 Jan 2005 03:27:47 -0000	1.70
+++ compiler/purity.m	21 Jan 2005 03:34:56 -0000
@@ -761,14 +761,20 @@
 	(
 		% The declared purity must match any promises.
 		% (A promise of impure means no promise was made).
-		PromisedPurity \= (impure), DeclaredPurity \= PromisedPurity
+		PromisedPurity \= (impure),
+		DeclaredPurity \= PromisedPurity
 	->
 		PurityCheckResult = inconsistent_promise
 	;
 		% You shouldn't promise pure unnecessarily.
 		% It's OK in the case of foreign_procs though.
-		PromisedPurity \= (impure), ActualPurity = PromisedPurity,
-		not pred_info_pragma_goal_type(PredInfo)
+		% There is also no point in warning about compiler-generated
+		% predicates.
+		PromisedPurity \= (impure),
+		ActualPurity = PromisedPurity,
+		not pred_info_pragma_goal_type(PredInfo),
+		pred_info_get_origin(PredInfo, Origin),
+		not ( Origin = transformed(_, _, _) ; Origin = created(_) )
 	->
 		PurityCheckResult = unnecessary_promise_pure
 	;
Index: compiler/recompilation.usage.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/recompilation.usage.m,v
retrieving revision 1.15
diff -u -b -r1.15 recompilation.usage.m
--- compiler/recompilation.usage.m	21 Jan 2005 03:27:47 -0000	1.15
+++ compiler/recompilation.usage.m	21 Jan 2005 03:34:56 -0000
@@ -817,7 +817,7 @@
 	module_info_pred_info(ModuleInfo, PredId, PredInfo),
 	PredOrFunc = pred_info_is_pred_or_func(PredInfo),
 	PredModule = pred_info_module(PredInfo),
-	PredArity = pred_info_arity(PredInfo),
+	PredArity = pred_info_orig_arity(PredInfo),
 	pred_info_get_exist_quant_tvars(PredInfo, PredExistQVars),
 	adjust_func_arity(PredOrFunc, OrigArity, PredArity),
 	(
Index: compiler/rl.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rl.m,v
retrieving revision 1.31
diff -u -b -r1.31 rl.m
--- compiler/rl.m	21 Jan 2005 03:27:47 -0000	1.31
+++ compiler/rl.m	21 Jan 2005 03:34:56 -0000
@@ -1072,7 +1072,7 @@
 	PredProcId = proc(PredId, _),
 	module_info_pred_info(ModuleInfo, PredId, PredInfo),
 	PredName = pred_info_name(PredInfo),
-	Arity = pred_info_arity(PredInfo),
+	Arity = pred_info_orig_arity(PredInfo),
 	rl__get_entry_proc_name(ModuleInfo, PredProcId,
 		PredInfo, PredName, Arity, ProcName).
 
@@ -1156,7 +1156,7 @@
 	PredModule0 = pred_info_module(PredInfo),
 	prog_out__sym_name_to_string(PredModule0, PredModule),
 	pred_info_get_aditi_owner(PredInfo, Owner),
-	PredArity = pred_info_arity(PredInfo),
+	PredArity = pred_info_orig_arity(PredInfo),
 	string__format("%s__%i", [s(PredName), i(PredArity)], RelName),
 	pred_info_arg_types(PredInfo, ArgTypes0),
 	type_util__remove_aditi_state(ArgTypes0, ArgTypes0, ArgTypes),
Index: compiler/rl_dump.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rl_dump.m,v
retrieving revision 1.12
diff -u -b -r1.12 rl_dump.m
--- compiler/rl_dump.m	14 Jun 2004 04:16:33 -0000	1.12
+++ compiler/rl_dump.m	17 Jan 2005 07:08:14 -0000
@@ -87,7 +87,7 @@
 		io__write_string("base relation `"),
 		{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
 		{ PredName = pred_info_name(PredInfo) },
-		{ PredArity = pred_info_arity(PredInfo) },
+		{ PredArity = pred_info_orig_arity(PredInfo) },
 		io__write_string(PredName),
 		io__write_string("'/"),
 		io__write_int(PredArity)
Index: compiler/rl_exprn.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rl_exprn.m,v
retrieving revision 1.46
diff -u -b -r1.46 rl_exprn.m
--- compiler/rl_exprn.m	21 Jan 2005 03:27:47 -0000	1.46
+++ compiler/rl_exprn.m	21 Jan 2005 03:34:56 -0000
@@ -1089,10 +1089,11 @@
 
 	{ ClassContext = constraints([], []) },
 	{ PredArgs = [InputTupleVar, OutputTupleVar] },
-	{ hlds_pred__define_new_pred(Goal, _CallGoal, PredArgs, _ExtraArgs,
-		InitialInstMap, ProcName, TVarSet, VarTypes, ClassContext,
-		TVarMap, TCVarMap, VarSet, InstVarSet, Markers, Owner,
-		IsAddressTaken, ModuleInfo0, ModuleInfo1, PredProcId) },
+	{ hlds_pred__define_new_pred(created(aditi_rl_exprn), Goal, _CallGoal,
+		PredArgs, _ExtraArgs, InitialInstMap, ProcName, TVarSet,
+		VarTypes, ClassContext, TVarMap, TCVarMap, VarSet, InstVarSet,
+		Markers, Owner, IsAddressTaken, ModuleInfo0, ModuleInfo1,
+		PredProcId) },
 
 	{ PredProcId = proc(PredId, ProcId) },
 	{ rtti__id_to_c_identifier(
@@ -1595,7 +1596,7 @@
 	rl_exprn_info::in, rl_exprn_info::out) is det.
 
 rl_exprn__call_body(PredId, ProcId, PredInfo, ProcInfo, Fail, Args, Code) -->
-	{ pred_info_get_maybe_special_pred(PredInfo, MaybeSpecial) },
+	{ pred_info_get_origin(PredInfo, Origin) },
 	(
 		{ pred_info_is_builtin(PredInfo) }
 	->
@@ -1611,7 +1612,7 @@
 		% Handle unify/2 specially, since it is possibly recursive,
 		% which will cause the code below to fall over. Also, magic.m
 		% doesn't add type_info arguments yet.
-		{ MaybeSpecial = yes(unify - _) },
+		{ Origin = special_pred(unify - _) },
 		{ list__reverse(Args, [Arg1, Arg2 | _]) },
 		{ hlds_pred__in_in_unification_proc_id(ProcId) }
 	->
@@ -1622,7 +1623,7 @@
 	;
 		% Handle compare/3 specially for the same reason
 		% as unify/2 above.
-		{ MaybeSpecial = yes(compare - _) },
+		{ Origin = special_pred(compare - _) },
 		{ list__reverse(Args, [Arg2, Arg1, Res | _]) }
 	->
 		rl_exprn_info_lookup_var(Arg1, Arg1Loc),
@@ -2182,7 +2183,7 @@
 		)
 	;
 		{ prog_out__sym_name_to_string(PredModule0, PredModule) },
-		{ Arity = pred_info_arity(PredInfo) },
+		{ Arity = pred_info_orig_arity(PredInfo) },
 		{ string__format("Sorry, not implemented in Aditi: %s.%s/%i",
 			[s(PredModule), s(PredName), i(Arity)], Msg) },
 		{ error(Msg) }
@@ -2305,7 +2306,7 @@
 	PredModule = pred_info_module(PredInfo),
 	PredModule = unqualified(PredModuleName),
 	PredName = pred_info_name(PredInfo),
-	PredArity0 = pred_info_arity(PredInfo),
+	PredArity0 = pred_info_orig_arity(PredInfo),
 	hlds_pred__proc_id_to_int(ProcId, ProcInt),
 	adjust_func_arity(PredOrFunc, PredArity, PredArity0),
 	rl_exprn__simple_extra_builtin(PredOrFunc, PredModuleName,
Index: compiler/rl_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rl_gen.m,v
retrieving revision 1.18
diff -u -b -r1.18 rl_gen.m
--- compiler/rl_gen.m	21 Jan 2005 03:27:48 -0000	1.18
+++ compiler/rl_gen.m	21 Jan 2005 03:34:57 -0000
@@ -394,7 +394,7 @@
 	rl_info_get_module_info(ModuleInfo),
 	{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
 	{ PredName = pred_info_name(PredInfo) },
-	{ PredArity = pred_info_arity(PredInfo) },
+	{ PredArity = pred_info_orig_arity(PredInfo) },
 	{ string__int_to_string(PredArity, PredArityStr) },
 	{ string__append_list([PredName, "/", PredArityStr, " ", S0], S1) },
 	add_pred_name_and_arity(PredProcIds, S1, S).
@@ -750,7 +750,7 @@
 	{ module_info_pred_proc_info(ModuleInfo, PredId, ProcId,
 		PredInfo, ProcInfo) },
 	{ PredName = pred_info_name(PredInfo) },
-	{ PredArity = pred_info_arity(PredInfo) },
+	{ PredArity = pred_info_orig_arity(PredInfo) },
 	rl_info_write_message("Generating RL for `%s'/%i\n",
 		[s(PredName), i(PredArity)]),
 	{ proc_info_headvars(ProcInfo, HeadVars) },
@@ -1525,7 +1525,7 @@
 	{ Module0 = pred_info_module(PredInfo) },
 	{ prog_out__sym_name_to_string(Module0, Module) },
 	{ Name = pred_info_name(PredInfo) },
-	{ Arity = pred_info_arity(PredInfo) },
+	{ Arity = pred_info_orig_arity(PredInfo) },
 	rl_info_write_message("Generating call to %s.%s/%i\n",
 		[s(Module), s(Name), i(Arity)]),
 	(
Index: compiler/rl_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rl_info.m,v
retrieving revision 1.8
diff -u -b -r1.8 rl_info.m
--- compiler/rl_info.m	20 Jul 2004 16:06:40 -0000	1.8
+++ compiler/rl_info.m	17 Jan 2005 07:09:57 -0000
@@ -502,7 +502,7 @@
 		{ PredModule0 = pred_info_module(PredInfo) },
 		{ prog_out__sym_name_to_string(PredModule0, PredModule) },
 		{ PredName = pred_info_name(PredInfo) },
-		{ Arity = pred_info_arity(PredInfo) },
+		{ Arity = pred_info_orig_arity(PredInfo) },
 		rl_info_get_next_relation_id(RelationId),
 		{ string__format("%s-%s.%s/%i-%i",
 			[s(ProcRelStr), s(PredModule), s(PredName),
Index: compiler/rl_key.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rl_key.m,v
retrieving revision 1.20
diff -u -b -r1.20 rl_key.m
--- compiler/rl_key.m	21 Jan 2005 03:27:48 -0000	1.20
+++ compiler/rl_key.m	21 Jan 2005 03:34:57 -0000
@@ -682,13 +682,13 @@
 	{ PredModule = pred_info_module(PredInfo) },
 	{ PredName = pred_info_name(PredInfo) },
 	{ list__length(Args, Arity) },
-	{ pred_info_get_maybe_special_pred(PredInfo, MaybeSpecial) },
+	{ pred_info_get_origin(PredInfo, Origin) },
 	(
 		{ hlds_pred__in_in_unification_proc_id(ProcId) },
 		{
 			is_builtin_unify_pred(PredModule, PredName, Arity)
 		;
-			MaybeSpecial = yes(unify - _)
+			Origin = special_pred(unify - _)
 		}
 	->
 		% Find the last two arguments, the rest will be type_infos.
@@ -705,7 +705,7 @@
 		->
 			CompareType = CompareTypePrime
 		;
-			MaybeSpecial = yes(compare - _),
+			Origin = special_pred(compare - _),
 			% We could do better here
 			CompareType = unknown
 		}
Index: compiler/rl_out.pp
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rl_out.pp,v
retrieving revision 1.24
diff -u -b -r1.24 rl_out.pp
--- compiler/rl_out.pp	20 Oct 2004 09:44:59 -0000	1.24
+++ compiler/rl_out.pp	21 Jan 2005 05:05:59 -0000
@@ -149,7 +149,7 @@
 		{ PredModule0 = pred_info_module(PredInfo) }, 
 		{ prog_out__sym_name_to_string(PredModule0, PredModule) },
 		{ PredName = pred_info_name(PredInfo) },
-		{ PredArity0 = pred_info_arity(PredInfo) },
+		{ PredArity0 = pred_info_orig_arity(PredInfo) },
 		{ string__int_to_string(PredArity0, PredArity) },
 		{ rl_out__get_proc_schema(ModuleInfo, RelInfo,
 			[InputRel, OutputRel], SchemaString) },
Index: compiler/rtti.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rtti.m,v
retrieving revision 1.53
diff -u -b -r1.53 rtti.m
--- compiler/rtti.m	19 Jan 2005 03:10:54 -0000	1.53
+++ compiler/rtti.m	19 Jan 2005 04:53:01 -0000
@@ -959,7 +959,7 @@
 	PredOrFunc = pred_info_is_pred_or_func(PredInfo),
 	PredModule = pred_info_module(PredInfo),
 	PredName = pred_info_name(PredInfo),
-	Arity = pred_info_arity(PredInfo),
+	Arity = pred_info_orig_arity(PredInfo),
 	pred_info_arg_types(PredInfo, ArgTypes),
 	proc_info_varset(ProcInfo, ProcVarSet),
 	proc_info_headvars(ProcInfo, ProcHeadVars),
@@ -970,7 +970,7 @@
 	PredIsPseudoImp = (pred_info_is_pseudo_imported(PredInfo) -> yes ; no),
 	ProcIsExported = (procedure_is_exported(ModuleInfo, PredInfo, ProcId)
 		-> yes ; no),
-	pred_info_get_maybe_special_pred(PredInfo, PredMaybeSpecial),
+	pred_info_get_origin(PredInfo, Origin),
 	ProcHeadVarsWithNames = list__map((func(Var) = Var - Name :-
 			Name = varset__lookup_name(ProcVarSet, Var)
 		), ProcHeadVars),
@@ -989,7 +989,7 @@
 	ProcLabel = rtti_proc_label(PredOrFunc, ThisModule, PredModule,
 		PredName, Arity, ArgTypes, PredId, ProcId,
 		ProcHeadVarsWithNames, ProcArgModes, ProcDetism,
-		PredIsImported, PredIsPseudoImp, PredMaybeSpecial,
+		PredIsImported, PredIsPseudoImp, Origin,
 		ProcIsExported, ProcIsImported).
 
 rtti__proc_label_pred_proc_id(ProcLabel, PredId, ProcId) :-
Index: compiler/table_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/table_gen.m,v
retrieving revision 1.75
diff -u -b -r1.75 table_gen.m
--- compiler/table_gen.m	21 Jan 2005 03:27:49 -0000	1.75
+++ compiler/table_gen.m	21 Jan 2005 03:34:57 -0000
@@ -1542,7 +1542,8 @@
 	( map__search(!.GenMap, PredId, GeneratorPredIdPrime) ->
 		GeneratorPredId = GeneratorPredIdPrime
 	;
-		clone_pred_info(PredInfo0, GeneratorPredId, !TableInfo),
+		clone_pred_info(PredId, PredInfo0, GeneratorPredId,
+			!TableInfo),
 		map__det_insert(!.GenMap, PredId, GeneratorPredId, !:GenMap)
 	),
 
@@ -1709,16 +1710,16 @@
 	module_info_set_preds(PredTable, ModuleInfo0, ModuleInfo),
 	!:TableInfo = !.TableInfo ^ table_module_info := ModuleInfo.
 
-:- pred clone_pred_info(pred_info::in, pred_id::out,
+:- pred clone_pred_info(pred_id::in, pred_info::in, pred_id::out,
 	table_info::in, table_info::out) is det.
 
-clone_pred_info(PredInfo0, GeneratorPredId, !TableInfo) :-
+clone_pred_info(OrigPredId, PredInfo0, GeneratorPredId, !TableInfo) :-
 	% We don't have any procedures for the generator yet. We will copy
 	% the consumers' procedures later, one by one, as they are transformed.
 
 	ModuleName = pred_info_module(PredInfo0),
 	PredName0 = pred_info_name(PredInfo0),
-	Arity0 = pred_info_arity(PredInfo0),
+	Arity0 = pred_info_orig_arity(PredInfo0),
 	PredOrFunc = pred_info_is_pred_or_func(PredInfo0),
 	pred_info_context(PredInfo0, Context),
 	% The generator is local even if the original predicate is exported.
@@ -1731,6 +1732,7 @@
 	pred_info_get_class_context(PredInfo0, ClassContext),
 	pred_info_get_constraint_proofs(PredInfo0, ClassProofs),
 	pred_info_get_aditi_owner(PredInfo0, Owner),
+	pred_info_get_origin(PredInfo0, OrigOrigin),
 	pred_info_clauses_info(PredInfo0, ClausesInfo),
 
 	PredName = qualified(ModuleName, "GeneratorFor_" ++ PredName0),
@@ -1742,9 +1744,11 @@
 	list__filter(filter_marker, MarkerList0, MarkerList),
 	marker_list_to_markers(MarkerList, Markers),
 
+	Origin = transformed(table_generator, OrigOrigin, OrigPredId),
 	pred_info_init(ModuleName, PredName, Arity, PredOrFunc, Context,
-		Status, GoalType, Markers, ArgTypes, TypeVarSet, ExistQVars,
-		ClassContext, ClassProofs, Owner, ClausesInfo, PredInfo),
+		Origin, Status, GoalType, Markers, ArgTypes, TypeVarSet,
+		ExistQVars, ClassContext, ClassProofs, Owner, ClausesInfo,
+		PredInfo),
 
 	ModuleInfo0 = !.TableInfo ^ table_module_info,
 	module_info_get_predicate_table(ModuleInfo0, PredTable0),
@@ -2866,7 +2870,7 @@
 
 	Module = pred_info_module(PredInfo),
 	Name = pred_info_name(PredInfo),
-	Arity = pred_info_arity(PredInfo),
+	Arity = pred_info_orig_arity(PredInfo),
 	PredOrFunc = pred_info_is_pred_or_func(PredInfo),
 	PredOrFuncStr = pred_or_func_to_str(PredOrFunc),
 	prog_out__sym_name_to_string(qualified(Module, Name), NameStr),
Index: compiler/termination.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/termination.m,v
retrieving revision 1.46
diff -u -b -r1.46 termination.m
--- compiler/termination.m	19 Jan 2005 03:10:56 -0000	1.46
+++ compiler/termination.m	19 Jan 2005 04:53:02 -0000
@@ -661,15 +661,14 @@
 		(
 			ModuleName = pred_info_module(PredInfo),
 			Name = pred_info_name(PredInfo),
-			Arity = pred_info_arity(PredInfo),
+			Arity = pred_info_orig_arity(PredInfo),
 			special_pred_name_arity(SpecPredId0, Name, Arity),
 			any_mercury_builtin_module(ModuleName)
 		->
 			SpecialPredId = SpecPredId0
 		;
-			pred_info_get_maybe_special_pred(PredInfo,
-				MaybeSpecial),
-			MaybeSpecial = yes(SpecialPredId - _)
+			pred_info_get_origin(PredInfo, Origin),
+			Origin = special_pred(SpecialPredId - _)
 		)
 	->
 		set_generated_terminates(ProcIds, SpecialPredId, !ProcTable)
Index: compiler/trace_params.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/trace_params.m,v
retrieving revision 1.21
diff -u -b -r1.21 trace_params.m
--- compiler/trace_params.m	19 Jan 2005 03:10:57 -0000	1.21
+++ compiler/trace_params.m	19 Jan 2005 04:53:03 -0000
@@ -148,9 +148,8 @@
 	( TraceLevel = none ->
 		EffTraceLevel = none
 	;
-		pred_info_get_maybe_special_pred(PredInfo, MaybeSpecialPred),
-		(
-			MaybeSpecialPred = yes(SpecialPred - _),
+		pred_info_get_origin(PredInfo, Origin),
+		( Origin = special_pred(SpecialPred - _) ->
 			% Unify and compare predicates can be called from
 			% the generic unify and compare predicates in
 			% builtin.m, so they can be called from outside this
@@ -177,7 +176,6 @@
 				EffTraceLevel = TraceLevel
 			)
 		;
-			MaybeSpecialPred = no,
 			pred_info_import_status(PredInfo, Status),
 			(
 				TraceLevel = shallow,
Index: compiler/type_class_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/type_class_info.m,v
retrieving revision 1.6
diff -u -b -r1.6 type_class_info.m
--- compiler/type_class_info.m	19 Jan 2005 03:10:57 -0000	1.6
+++ compiler/type_class_info.m	19 Jan 2005 04:53:03 -0000
@@ -109,7 +109,7 @@
 	ClassProc = hlds_class_proc(PredId, _ProcId),
 	module_info_pred_info(ModuleInfo, PredId, PredInfo),
 	MethodName = pred_info_name(PredInfo),
-	Arity = pred_info_arity(PredInfo),
+	Arity = pred_info_orig_arity(PredInfo),
 	PredOrFunc = pred_info_is_pred_or_func(PredInfo),
 	MethodId = tc_method_id(MethodName, Arity, PredOrFunc).
 
Index: compiler/typecheck.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/typecheck.m,v
retrieving revision 1.361
diff -u -b -r1.361 typecheck.m
--- compiler/typecheck.m	21 Jan 2005 03:27:50 -0000	1.361
+++ compiler/typecheck.m	21 Jan 2005 03:34:58 -0000
@@ -555,8 +555,7 @@
 			Inferring = no,
 			pred_info_set_head_type_params(HeadTypeParams2,
 				!PredInfo),
-			pred_info_get_maybe_instance_method_constraints(
-				!.PredInfo, MaybeInstanceMethodConstraints0),
+			pred_info_get_origin(!.PredInfo, Origin0),
 
 			%
 			% leave the original argtypes etc., but
@@ -575,8 +574,7 @@
 				ExistQVars1 = [],
 				ArgTypes1 = ArgTypes0,
 				PredConstraints1 = PredConstraints,
-				MaybeInstanceMethodConstraints1 =
-					MaybeInstanceMethodConstraints0
+				Origin1 = Origin0
 			;
 				apply_var_renaming_to_var_list(ExistQVars0,
 					ExistTypeRenaming, ExistQVars1),
@@ -587,9 +585,7 @@
 					ExistTypeRenaming,
 					PredConstraints, PredConstraints1),
 				rename_instance_method_constraints(
-					ExistTypeRenaming,
-					MaybeInstanceMethodConstraints0,
-					MaybeInstanceMethodConstraints1)
+					ExistTypeRenaming, Origin0, Origin1)
 			),
 
 			% rename them all to match the new typevarset
@@ -600,16 +596,14 @@
 			apply_variable_renaming_to_constraints(TVarRenaming,
 				PredConstraints1, RenamedOldConstraints),
 			rename_instance_method_constraints(TVarRenaming,
-				MaybeInstanceMethodConstraints1,
-				MaybeInstanceMethodConstraints),
+				Origin1, Origin),
 
 			% save the results in the pred_info
 			pred_info_set_arg_types(TypeVarSet, ExistQVars,
 				RenamedOldArgTypes, !PredInfo),
 			pred_info_set_class_context(RenamedOldConstraints,
 				!PredInfo),
-			pred_info_set_maybe_instance_method_constraints(
-				MaybeInstanceMethodConstraints, !PredInfo),
+			pred_info_set_origin(Origin, !PredInfo),
 
 			Changed = no
 		),
@@ -666,12 +660,11 @@
 	StubClause = clause([], Body, mercury, Context).
 
 :- pred rename_instance_method_constraints(map(tvar, tvar)::in,
-	maybe(instance_method_constraints)::in,
-	maybe(instance_method_constraints)::out) is det.
+	pred_origin::in,
+	pred_origin::out) is det.
 
-rename_instance_method_constraints(_, no, no).
-rename_instance_method_constraints(Renaming,
-		yes(Constraints0), yes(Constraints)) :-
+rename_instance_method_constraints(Renaming, Origin0, Origin) :-
+	( Origin0 = instance_method(Constraints0) ->
 	Constraints0 = instance_method_constraints(ClassId,
 		InstanceTypes0, InstanceConstraints0,
 		ClassMethodClassContext0),
@@ -683,7 +676,11 @@
 		ClassMethodClassContext0, ClassMethodClassContext),
 	Constraints = instance_method_constraints(ClassId,
 		InstanceTypes, InstanceConstraints,
-		ClassMethodClassContext).
+			ClassMethodClassContext),
+		Origin = instance_method(Constraints)
+	;
+		Origin = Origin0
+	).
 
 	%
 	% infer which of the head variable
@@ -839,8 +836,8 @@
 	% check if the predicate is a compiler-generated special
 	% predicate, and if so, for which type
 	%
-	pred_info_get_maybe_special_pred(PredInfo, MaybeSpecial),
-	MaybeSpecial = yes(_SpecialId - TypeCtor),
+	pred_info_get_origin(PredInfo, Origin),
+	Origin = special_pred(_SpecialId - TypeCtor),
 	%
 	% check that the special pred isn't one of the builtin
 	% types which don't have a hlds_type_defn
@@ -882,7 +879,7 @@
 		pred_info_context(!.PredInfo, Context),
 		FuncModule = pred_info_module(!.PredInfo),
 		FuncName = pred_info_name(!.PredInfo),
-		PredArity = pred_info_arity(!.PredInfo),
+		PredArity = pred_info_orig_arity(!.PredInfo),
 		adjust_func_arity(function, FuncArity, PredArity),
 		FuncSymName = qualified(FuncModule, FuncName),
 		create_atomic_unification(FuncRetVal,
@@ -1765,7 +1762,7 @@
 typecheck_find_arities(_, [], []).
 typecheck_find_arities(Preds, [PredId | PredIds], [Arity | Arities]) :-
 	map__lookup(Preds, PredId, PredInfo),
-	Arity = pred_info_arity(PredInfo),
+	Arity = pred_info_orig_arity(PredInfo),
 	typecheck_find_arities(Preds, PredIds, Arities).
 
 :- pred typecheck_call_overloaded_pred(list(pred_id)::in, list(prog_var)::in,
@@ -2952,7 +2949,7 @@
 
 make_pred_cons_info(_Info, PredId, PredTable, FuncArity, _, !ConsInfos) :-
 	map__lookup(PredTable, PredId, PredInfo),
-	PredArity = pred_info_arity(PredInfo),
+	PredArity = pred_info_orig_arity(PredInfo),
 	IsPredOrFunc = pred_info_is_pred_or_func(PredInfo),
 	pred_info_get_class_context(PredInfo, ClassContext),
 	pred_info_arg_types(PredInfo, PredTypeVarSet, PredExistQVars,
Index: compiler/unify_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unify_gen.m,v
retrieving revision 1.145
diff -u -b -r1.145 unify_gen.m
--- compiler/unify_gen.m	21 Jan 2005 03:27:51 -0000	1.145
+++ compiler/unify_gen.m	21 Jan 2005 03:34:59 -0000
@@ -436,12 +436,10 @@
 	),
 	code_info__get_module_info(!.CI, ModuleInfo),
 	RttiProcLabel = make_rtti_proc_label(ModuleInfo, PredId, ProcId),
-	IsSpecial = RttiProcLabel ^ pred_is_special_pred,
-	(
-		IsSpecial = yes(_),
+	Origin = RttiProcLabel ^ pred_info_origin,
+	( Origin = special_pred(_) ->
 		UserOrUCI = uci
 	;
-		IsSpecial = no,
 		UserOrUCI = user
 	),
 	ProcKind = proc_layout_proc_id(UserOrUCI),
Index: compiler/unused_args.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unused_args.m,v
retrieving revision 1.99
diff -u -b -r1.99 unused_args.m
--- compiler/unused_args.m	21 Jan 2005 03:27:51 -0000	1.99
+++ compiler/unused_args.m	21 Jan 2005 03:34:59 -0000
@@ -330,7 +330,7 @@
 		PredModule = pred_info_module(PredInfo),
 		PredOrFunc = pred_info_is_pred_or_func(PredInfo),
 		PredName = pred_info_name(PredInfo),
-		PredArity = pred_info_arity(PredInfo),
+		PredArity = pred_info_orig_arity(PredInfo),
 		FuncId = pred_or_func_name_arity_to_func_id(PredOrFunc,
 			PredName, PredArity, ProcId),
 		module_info_analysis_info(!.ModuleInfo, AnalysisInfo0),
@@ -861,7 +861,7 @@
 			Intermod = yes,
 			module_info_analysis_info(!.ModuleInfo, AnalysisInfo0),
 			PredOrFunc = pred_info_is_pred_or_func(OrigPredInfo),
-			PredArity = pred_info_arity(OrigPredInfo),
+			PredArity = pred_info_orig_arity(OrigPredInfo),
 			ModuleId = module_name_to_module_id(PredModule),
 			FuncId = pred_or_func_name_arity_to_func_id(PredOrFunc,
 				PredName, PredArity, ProcId),
@@ -995,13 +995,13 @@
 :- pred make_new_pred_info(module_info::in, list(int)::in, import_status::in,
 	pred_proc_id::in, pred_info::in, pred_info::out) is det.
 
-make_new_pred_info(ModuleInfo, UnusedArgs, Status, proc(_PredId, ProcId),
+make_new_pred_info(ModuleInfo, UnusedArgs, Status, proc(PredId, ProcId),
 		!PredInfo) :-
 	PredModule = pred_info_module(!.PredInfo),
 	Name0 = pred_info_name(!.PredInfo),
 	PredOrFunc = pred_info_is_pred_or_func(!.PredInfo),
 	pred_info_arg_types(!.PredInfo, Tvars, ExistQVars, ArgTypes0),
-	pred_info_get_maybe_special_pred(!.PredInfo, MaybeSpecial),
+	pred_info_get_origin(!.PredInfo, OrigOrigin),
 		% create a unique new pred name using the old proc_id
 	(
 		string__prefix(Name0, "__"),
@@ -1009,7 +1009,7 @@
 	->
 		(
 				% fix up special pred names
-			MaybeSpecial = yes(_SpecialId - TypeCtor)
+			OrigOrigin = special_pred(_SpecialId - TypeCtor)
 		->
 			type_util__type_ctor_module(ModuleInfo,
 				TypeCtor, TypeModule),
@@ -1044,7 +1044,7 @@
 	% link errors.
 	proc_id_to_int(ProcId, ProcInt),
 	add_sym_name_suffix(Name2, "_" ++ int_to_string(ProcInt), Name),
-	Arity = pred_info_arity(!.PredInfo),
+	Arity = pred_info_orig_arity(!.PredInfo),
 	pred_info_typevarset(!.PredInfo, TypeVars),
 	remove_listof_elements(ArgTypes0, 1, UnusedArgs, ArgTypes),
 	pred_info_context(!.PredInfo, Context),
@@ -1054,7 +1054,9 @@
 	pred_info_get_class_context(!.PredInfo, ClassContext),
 	pred_info_get_aditi_owner(!.PredInfo, Owner),
 	map__init(EmptyProofs),
-	pred_info_init(PredModule, Name, Arity, PredOrFunc, Context,
+	Origin = transformed(unused_argument_elimination(UnusedArgs),
+		OrigOrigin, PredId),
+	pred_info_init(PredModule, Name, Arity, PredOrFunc, Context, Origin,
 		Status, GoalType, Markers, ArgTypes, Tvars, ExistQVars,
 		ClassContext, EmptyProofs, Owner, ClausesInfo, !:PredInfo),
 	pred_info_set_typevarset(TypeVars, !PredInfo).
@@ -1578,7 +1580,7 @@
 	->
 		Module = pred_info_module(PredInfo),
 		Name = pred_info_name(PredInfo),
-		Arity = pred_info_arity(PredInfo),
+		Arity = pred_info_orig_arity(PredInfo),
 		PredOrFunc = pred_info_is_pred_or_func(PredInfo),
 		io__set_output_stream(OptStream, OldOutput, !IO),
 		proc_id_to_int(ProcId, ModeNum),
@@ -1608,7 +1610,7 @@
 
 		% Strip off the extra type_info arguments
 		% inserted at the front by polymorphism.m
-		NumToDrop = NumHeadVars - pred_info_arity(PredInfo),
+		NumToDrop = NumHeadVars - pred_info_orig_arity(PredInfo),
 		adjust_unused_args(NumToDrop, UnusedArgs0, UnusedArgs),
 		(
 			UnusedArgs = [_ | _],
@@ -1630,7 +1632,7 @@
 	{ PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
 	{ Module = pred_info_module(PredInfo) },
 	{ Name = pred_info_name(PredInfo) },
-	{ Arity = pred_info_arity(PredInfo) },
+	{ Arity = pred_info_orig_arity(PredInfo) },
 	prog_out__write_context(Context),
 	io__write_string("In "),
 	write_pred_or_func(PredOrFunc),
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
Index: tests/debugger/higher_order.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/higher_order.exp,v
retrieving revision 1.5
diff -u -b -r1.5 higher_order.exp
--- tests/debugger/higher_order.exp	16 Nov 2004 00:16:39 -0000	1.5
+++ tests/debugger/higher_order.exp	18 Jan 2005 23:53:37 -0000
@@ -42,23 +42,23 @@
 mdb> step
       E8:     C5 CALL pred higher_order.domap/3-0 (det)
 mdb> print *
-       HeadVar__1             	'IntroducedFrom__pred__main__21__1'([6])
+       HeadVar__1             	lambda_higher_order_21([6])
        HeadVar__2             	[[1, 2], [3, 4, 5]]
 mdb> finish
       E9:     C5 EXIT pred higher_order.domap/3-0 (det)
 mdb> print *
-       HeadVar__1             	'IntroducedFrom__pred__main__21__1'([6])
+       HeadVar__1             	lambda_higher_order_21([6])
        HeadVar__2             	[[1, 2], [3, 4, 5]]
        HeadVar__3             	[[6, 1, 2], [6, 3, 4, 5]]
 mdb> step
      E10:     C6 CALL pred higher_order.domap/3-0 (det)
 mdb> print *
-       HeadVar__1             	'IntroducedFrom__pred__main__22__2'(["a"])
+       HeadVar__1             	lambda_higher_order_22(["a"])
        HeadVar__2             	[["one", "two"], ["three", "four", "five"]]
 mdb> finish
      E11:     C6 EXIT pred higher_order.domap/3-0 (det)
 mdb> print *
-       HeadVar__1             	'IntroducedFrom__pred__main__22__2'(["a"])
+       HeadVar__1             	lambda_higher_order_22(["a"])
        HeadVar__2             	[["one", "two"], ["three", "four", "five"]]
        HeadVar__3             	[["a", "one", "two"], ["a", "three", "four", "five"]]
 mdb> continue -S
Index: tests/debugger/lambda_expr.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/lambda_expr.exp,v
retrieving revision 1.2
diff -u -b -r1.2 lambda_expr.exp
--- tests/debugger/lambda_expr.exp	16 Nov 2004 00:16:39 -0000	1.2
+++ tests/debugger/lambda_expr.exp	18 Jan 2005 07:46:23 -0000
@@ -5,24 +5,24 @@
 Contexts will not be printed.
 mdb> register --quiet
 mdb> step
-      E2:     C2 CALL pred lambda_expr.IntroducedFrom__pred__main__18__1/2-0 (det)
+      E2:     C2 CALL pred lambda_expr.lambda_lambda_expr_18/2-0 (det)
 mdb> print
-IntroducedFrom__pred__main__18__1(1, _)
+lambda_lambda_expr_18(1, _)
 mdb> up
 Ancestor level set to 1:
    1  pred lambda_expr.main/2-0 (det)
 mdb> print P
-       P                      	'IntroducedFrom__pred__main__18__1'
+       P                      	lambda_lambda_expr_18
 mdb> finish ; print
-      E3:     C2 EXIT pred lambda_expr.IntroducedFrom__pred__main__18__1/2-0 (det)
-IntroducedFrom__pred__main__18__1(1, 2)
+      E3:     C2 EXIT pred lambda_expr.lambda_lambda_expr_18/2-0 (det)
+lambda_lambda_expr_18(1, 2)
 mdb> retry
-      E2:     C2 CALL pred lambda_expr.IntroducedFrom__pred__main__18__1/2-0 (det)
+      E2:     C2 CALL pred lambda_expr.lambda_lambda_expr_18/2-0 (det)
 mdb> print
-IntroducedFrom__pred__main__18__1(1, _)
+lambda_lambda_expr_18(1, _)
 mdb> finish
-      E3:     C2 EXIT pred lambda_expr.IntroducedFrom__pred__main__18__1/2-0 (det)
+      E3:     C2 EXIT pred lambda_expr.lambda_lambda_expr_18/2-0 (det)
 mdb> print
-IntroducedFrom__pred__main__18__1(1, 2)
+lambda_lambda_expr_18(1, 2)
 mdb> continue
 2
cvs diff: Diffing tests/debugger/declarative
Index: tests/debugger/declarative/find_origin.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/declarative/find_origin.exp,v
retrieving revision 1.2
diff -u -b -r1.2 find_origin.exp
--- tests/debugger/declarative/find_origin.exp	6 Jan 2005 03:20:11 -0000	1.2
+++ tests/debugger/declarative/find_origin.exp	21 Jan 2005 06:09:07 -0000
@@ -12,19 +12,19 @@
 browser> mark
 monotest4(t(101), t(101))
 Valid? n
-Call IntroducedFrom__pred__monotest4__86__1(t(101), t(3))
+Call lambda_find_origin_86(t(101), t(3))
 No solutions.
 Complete? y
-IntroducedFrom__pred__monotest4__86__1(t(101), t(101))
+lambda_find_origin_86(t(101), t(101))
 Valid? y
-Call IntroducedFrom__pred__monotest4__86__1(t(101), t(2))
+Call lambda_find_origin_86(t(101), t(2))
 No solutions.
 Complete? y
-Call IntroducedFrom__pred__monotest4__86__1(t(101), t(1))
+Call lambda_find_origin_86(t(101), t(1))
 No solutions.
 Complete? y
 Found incorrect contour:
-IntroducedFrom__pred__monotest4__86__1(t(101), t(101))
+lambda_find_origin_86(t(101), t(101))
 monotest4(t(101), t(101))
 Is this a bug? y
       E4:     C3 EXIT pred find_origin.monotest4/2-0 (det)
@@ -46,13 +46,13 @@
 browser> quit
 polytest4(u("hello"), u("hello"))
 Valid? no
-IntroducedFrom__pred__polytest4__148__2(u(string), u(u("hello")), u(u("hello")))
+lambda_find_origin_148(u(string), u(u("hello")), u(u("hello")))
 Valid? y
-Call IntroducedFrom__pred__polytest4__148__2(u(string), u(u("hello")), v(u("hello")))
+Call lambda_find_origin_148(u(string), u(u("hello")), v(u("hello")))
 No solutions.
 Complete? y
 Found incorrect contour:
-IntroducedFrom__pred__polytest4__148__2(u(string), u(u("hello")), u(u("hello")))
+lambda_find_origin_148(u(string), u(u("hello")), u(u("hello")))
 polytest4(u("hello"), u("hello"))
 Is this a bug? y
       E7:     C5 EXIT pred find_origin.polytest4/2-0 (det)
Index: tests/debugger/declarative/higher_order.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/declarative/higher_order.exp,v
retrieving revision 1.3
diff -u -b -r1.3 higher_order.exp
--- tests/debugger/declarative/higher_order.exp	6 Jan 2005 03:20:12 -0000	1.3
+++ tests/debugger/declarative/higher_order.exp	21 Jan 2005 06:09:25 -0000
@@ -11,10 +11,10 @@
 mdb> dd
 p(3, 81)
 Valid? no
-q('IntroducedFrom__pred__p__16__1', 3, 81)
+q(lambda_higher_order_16, 3, 81)
 Valid? yes
 Found incorrect contour:
-q('IntroducedFrom__pred__p__16__1', 3, 81)
+q(lambda_higher_order_16, 3, 81)
 p(3, 81)
 Is this a bug? yes
        7:      2  2 EXIT pred higher_order.p/2-0 (det) higher_order.m:15 (higher_order.m:9)
Index: tests/debugger/declarative/ho2.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/declarative/ho2.exp,v
retrieving revision 1.3
diff -u -b -r1.3 ho2.exp
--- tests/debugger/declarative/ho2.exp	6 Jan 2005 03:20:12 -0000	1.3
+++ tests/debugger/declarative/ho2.exp	21 Jan 2005 06:09:39 -0000
@@ -11,10 +11,10 @@
 mdb> dd
 p(0, 3, 27)
 Valid? no
-q('IntroducedFrom__pred__p__22__1'(3), 3, 27)
+q(lambda_ho2_22(3), 3, 27)
 Valid? yes
 Found incorrect contour:
-q('IntroducedFrom__pred__p__22__1'(3), 3, 27)
+q(lambda_ho2_22(3), 3, 27)
 p(0, 3, 27)
 Is this a bug? yes
        7:      2  2 EXIT pred ho2.p/3-0 (det) ho2.m:21 (ho2.m:9)
@@ -26,7 +26,7 @@
 p(1, 3, 27)
 Valid? no
 Found incorrect contour:
-q('IntroducedFrom__pred__p__22__1'(3), 3, 27)
+q(lambda_ho2_22(3), 3, 27)
 p(1, 3, 27)
 Is this a bug? yes
       13:      5  2 EXIT pred ho2.p/3-0 (det) ho2.m:21 (ho2.m:10)
@@ -37,10 +37,10 @@
 mdb> dd
 p(2, 4, 64)
 Valid? no
-q('IntroducedFrom__pred__p__22__1'(4), 4, 64)
+q(lambda_ho2_22(4), 4, 64)
 Valid? yes
 Found incorrect contour:
-q('IntroducedFrom__pred__p__22__1'(4), 4, 64)
+q(lambda_ho2_22(4), 4, 64)
 p(2, 4, 64)
 Is this a bug? yes
       19:      8  2 EXIT pred ho2.p/3-0 (det) ho2.m:21 (ho2.m:11)
Index: tests/debugger/declarative/trust.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/declarative/trust.exp,v
retrieving revision 1.8
diff -u -b -r1.8 trust.exp
--- tests/debugger/declarative/trust.exp	6 Jan 2005 03:20:13 -0000	1.8
+++ tests/debugger/declarative/trust.exp	21 Jan 2005 06:10:00 -0000
@@ -4,20 +4,20 @@
 Command echo enabled.
 mdb> trust trust_1.
 Ambiguous predicate or function specification. The matches are:
-0: pred trust_1.IntroducedFrom__pred__w_cmp__15__1/3
+0: pred trust_1.lambda_trust_1_15/3
 1: pred trust_1.w_cmp/3
 
 Which predicate or function do you want to trust (0-1 or *)? *
-Trusting pred trust_1.IntroducedFrom__pred__w_cmp__15__1/3
+Trusting pred trust_1.lambda_trust_1_15/3
 Trusting pred trust_1.w_cmp/3
 mdb> trusted
 Trusted Objects:
-1: predicate trust_1.IntroducedFrom__pred__w_cmp__15__1/3
+1: predicate trust_1.lambda_trust_1_15/3
 2: predicate trust_1.w_cmp/3
 mdb> untrust 2
 mdb> trusted
 Trusted Objects:
-1: predicate trust_1.IntroducedFrom__pred__w_cmp__15__1/3
+1: predicate trust_1.lambda_trust_1_15/3
 mdb> untrust 1
 mdb> trusted
 There are no trusted modules, predicates or functions.
@@ -80,7 +80,7 @@
 Valid? trust
 concat(w("aaa"), w("bbb"), w("aaabbb"))
 Valid? trust module
-IntroducedFrom__pred__w_cmp__15__1(w("aaB"), w("aAB"), '=')
+lambda_trust_1_15(w("aaB"), w("aAB"), '=')
 Valid? trust module
 Found incorrect contour:
 w_cmp('=', w("aaB"), w("aAB"))
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
Index: tests/hard_coded/deconstruct_arg.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/deconstruct_arg.exp,v
retrieving revision 1.5
diff -u -b -r1.5 deconstruct_arg.exp
--- tests/hard_coded/deconstruct_arg.exp	17 Jan 2003 05:57:04 -0000	1.5
+++ tests/hard_coded/deconstruct_arg.exp	21 Jan 2005 06:10:48 -0000
@@ -220,7 +220,7 @@
 functor newline arity 0 []
 
 std_util    functor: <<predicate>>/0
-deconstruct functor: IntroducedFrom__pred__main__85__1/1
+deconstruct functor: lambda_deconstruct_arg_85/1
 std_util    argument 0 of '<<predicate>>' doesn't exist
 deconstruct argument 0 of '<<predicate>>' is [1, 2]
 std_util    argument 1 of '<<predicate>>' doesn't exist
@@ -229,12 +229,12 @@
 deconstruct argument 2 of '<<predicate>>' doesn't exist
 std_util    deconstruct: functor <<predicate>> arity 0
 []
-deconstruct deconstruct: functor IntroducedFrom__pred__main__85__1 arity 1
+deconstruct deconstruct: functor lambda_deconstruct_arg_85 arity 1
 [[1, 2]]
 std_util    limited deconstruct 3 of '<<predicate>>'
 functor <<predicate>> arity 0 []
 deconstruct limited deconstruct 3 of '<<predicate>>'
-functor IntroducedFrom__pred__main__85__1 arity 1 [[1, 2]]
+functor lambda_deconstruct_arg_85 arity 1 [[1, 2]]
 
 std_util    functor: {}/2
 deconstruct functor: {}/2
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
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