[m-rev.] trivial diff: move code into prog_type
Mark Brown
mark at cs.mu.OZ.AU
Sun Apr 3 03:11:10 AEST 2005
Hi,
This addresses one of Julien's recent review comments.
Cheers,
Mark.
Estimated hours taken: 0.1
Branches: main
compiler/prog_type.m:
compiler/prog_util.m:
Move some predicates dealing with typeclass constraints from
prog_util to prog_type.
compiler/check_typeclass.m:
compiler/cse_detection.m:
compiler/recompilation.version.m:
Minor changes to the imported modules.
Index: compiler/check_typeclass.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/check_typeclass.m,v
retrieving revision 1.65
diff -u -r1.65 check_typeclass.m
--- compiler/check_typeclass.m 1 Apr 2005 14:28:54 -0000 1.65
+++ compiler/check_typeclass.m 2 Apr 2005 16:36:24 -0000
@@ -77,6 +77,7 @@
:- import_module parse_tree__mercury_to_mercury.
:- import_module parse_tree__prog_data.
:- import_module parse_tree__prog_out.
+:- import_module parse_tree__prog_type.
:- import_module parse_tree__prog_util.
:- import_module assoc_list.
Index: compiler/cse_detection.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/cse_detection.m,v
retrieving revision 1.82
diff -u -r1.82 cse_detection.m
--- compiler/cse_detection.m 1 Apr 2005 14:28:54 -0000 1.82
+++ compiler/cse_detection.m 2 Apr 2005 16:37:26 -0000
@@ -49,7 +49,7 @@
:- import_module libs__globals.
:- import_module libs__options.
:- import_module parse_tree__prog_data.
-:- import_module parse_tree__prog_util.
+:- import_module parse_tree__prog_type.
:- import_module assoc_list.
:- import_module bool.
Index: compiler/prog_type.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/prog_type.m,v
retrieving revision 1.2
diff -u -r1.2 prog_type.m
--- compiler/prog_type.m 1 Apr 2005 14:29:01 -0000 1.2
+++ compiler/prog_type.m 2 Apr 2005 16:28:22 -0000
@@ -19,6 +19,7 @@
:- import_module parse_tree.prog_data.
:- import_module list.
+:- import_module map.
%-----------------------------------------------------------------------------%
@@ -83,6 +84,38 @@
:- pred construct_higher_order_func_type(purity::in, lambda_eval_method::in,
list(type)::in, (type)::in, (type)::out) is det.
+%-----------------------------------------------------------------------------%
+%
+% Utility predicates dealing with typeclass constraints.
+%
+
+:- pred apply_rec_subst_to_prog_constraints(tsubst::in, prog_constraints::in,
+ prog_constraints::out) is det.
+
+:- pred apply_rec_subst_to_prog_constraint_list(tsubst::in,
+ list(prog_constraint)::in, list(prog_constraint)::out) is det.
+
+:- pred apply_rec_subst_to_prog_constraint(tsubst::in, prog_constraint::in,
+ prog_constraint::out) is det.
+
+:- pred apply_subst_to_prog_constraints(tsubst::in, prog_constraints::in,
+ prog_constraints::out) is det.
+
+:- pred apply_subst_to_prog_constraint_list(tsubst::in,
+ list(prog_constraint)::in, list(prog_constraint)::out) is det.
+
+:- pred apply_subst_to_prog_constraint(tsubst::in, prog_constraint::in,
+ prog_constraint::out) is det.
+
+:- pred apply_variable_renaming_to_prog_constraints(map(tvar, tvar)::in,
+ prog_constraints::in, prog_constraints::out) is det.
+
+:- pred apply_variable_renaming_to_prog_constraint_list(map(tvar, tvar)::in,
+ list(prog_constraint)::in, list(prog_constraint)::out) is det.
+
+:- pred apply_variable_renaming_to_prog_constraint(map(tvar, tvar)::in,
+ prog_constraint::in, prog_constraint::out) is det.
+
% constraint_list_get_tvars(Constraints, TVars):
% return the list of type variables contained in a
% list of constraints
@@ -347,6 +380,54 @@
term.context_init(Context).
%-----------------------------------------------------------------------------%
+
+apply_rec_subst_to_prog_constraints(Subst, Constraints0, Constraints) :-
+ Constraints0 = constraints(UnivCs0, ExistCs0),
+ apply_rec_subst_to_prog_constraint_list(Subst, UnivCs0, UnivCs),
+ apply_rec_subst_to_prog_constraint_list(Subst, ExistCs0, ExistCs),
+ Constraints = constraints(UnivCs, ExistCs).
+
+apply_rec_subst_to_prog_constraint_list(Subst, !Constraints) :-
+ list__map(apply_rec_subst_to_prog_constraint(Subst), !Constraints).
+
+apply_rec_subst_to_prog_constraint(Subst, Constraint0, Constraint) :-
+ Constraint0 = constraint(ClassName, Types0),
+ term__apply_rec_substitution_to_list(Types0, Subst, Types),
+ Constraint = constraint(ClassName, Types).
+
+apply_subst_to_prog_constraints(Subst,
+ constraints(UniversalCs0, ExistentialCs0),
+ constraints(UniversalCs, ExistentialCs)) :-
+ apply_subst_to_prog_constraint_list(Subst, UniversalCs0, UniversalCs),
+ apply_subst_to_prog_constraint_list(Subst, ExistentialCs0,
+ ExistentialCs).
+
+apply_subst_to_prog_constraint_list(Subst, !Constraints) :-
+ list__map(apply_subst_to_prog_constraint(Subst), !Constraints).
+
+apply_subst_to_prog_constraint(Subst, Constraint0, Constraint) :-
+ Constraint0 = constraint(ClassName, Types0),
+ term__apply_substitution_to_list(Types0, Subst, Types),
+ Constraint = constraint(ClassName, Types).
+
+apply_variable_renaming_to_prog_constraints(Renaming, Constraints0,
+ Constraints) :-
+ Constraints0 = constraints(UnivConstraints0, ExistConstraints0),
+ apply_variable_renaming_to_prog_constraint_list(Renaming,
+ UnivConstraints0, UnivConstraints),
+ apply_variable_renaming_to_prog_constraint_list(Renaming,
+ ExistConstraints0, ExistConstraints),
+ Constraints = constraints(UnivConstraints, ExistConstraints).
+
+apply_variable_renaming_to_prog_constraint_list(Renaming, !Constraints) :-
+ list.map(apply_variable_renaming_to_prog_constraint(Renaming),
+ !Constraints).
+
+apply_variable_renaming_to_prog_constraint(Renaming, !Constraint) :-
+ !.Constraint = constraint(ClassName, ClassArgTypes0),
+ term.apply_variable_renaming_to_list(ClassArgTypes0, Renaming,
+ ClassArgTypes),
+ !:Constraint = constraint(ClassName, ClassArgTypes).
constraint_list_get_tvars(Constraints, TVars) :-
list.map(constraint_get_tvars, Constraints, TVarsList),
Index: compiler/prog_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/prog_util.m,v
retrieving revision 1.74
diff -u -r1.74 prog_util.m
--- compiler/prog_util.m 1 Apr 2005 14:29:01 -0000 1.74
+++ compiler/prog_util.m 2 Apr 2005 16:29:17 -0000
@@ -17,7 +17,6 @@
:- import_module parse_tree__prog_data.
:- import_module list.
-:- import_module map.
:- import_module std_util.
:- import_module term.
:- import_module varset.
@@ -285,35 +284,6 @@
%-----------------------------------------------------------------------------%
-:- pred apply_rec_subst_to_prog_constraints(tsubst::in, prog_constraints::in,
- prog_constraints::out) is det.
-
-:- pred apply_rec_subst_to_prog_constraint_list(tsubst::in,
- list(prog_constraint)::in, list(prog_constraint)::out) is det.
-
-:- pred apply_rec_subst_to_prog_constraint(tsubst::in, prog_constraint::in,
- prog_constraint::out) is det.
-
-:- pred apply_subst_to_prog_constraints(tsubst::in, prog_constraints::in,
- prog_constraints::out) is det.
-
-:- pred apply_subst_to_prog_constraint_list(tsubst::in,
- list(prog_constraint)::in, list(prog_constraint)::out) is det.
-
-:- pred apply_subst_to_prog_constraint(tsubst::in, prog_constraint::in,
- prog_constraint::out) is det.
-
-:- pred apply_variable_renaming_to_prog_constraints(map(tvar, tvar)::in,
- prog_constraints::in, prog_constraints::out) is det.
-
-:- pred apply_variable_renaming_to_prog_constraint_list(map(tvar, tvar)::in,
- list(prog_constraint)::in, list(prog_constraint)::out) is det.
-
-:- pred apply_variable_renaming_to_prog_constraint(map(tvar, tvar)::in,
- prog_constraint::in, prog_constraint::out) is det.
-
-%-----------------------------------------------------------------------------%
-
:- implementation.
:- import_module parse_tree__mercury_to_mercury.
@@ -738,56 +708,6 @@
;
error("hlds_pred__get_state_args_det")
).
-
-%-----------------------------------------------------------------------------%
-
-apply_rec_subst_to_prog_constraints(Subst, Constraints0, Constraints) :-
- Constraints0 = constraints(UnivCs0, ExistCs0),
- apply_rec_subst_to_prog_constraint_list(Subst, UnivCs0, UnivCs),
- apply_rec_subst_to_prog_constraint_list(Subst, ExistCs0, ExistCs),
- Constraints = constraints(UnivCs, ExistCs).
-
-apply_rec_subst_to_prog_constraint_list(Subst, !Constraints) :-
- list__map(apply_rec_subst_to_prog_constraint(Subst), !Constraints).
-
-apply_rec_subst_to_prog_constraint(Subst, Constraint0, Constraint) :-
- Constraint0 = constraint(ClassName, Types0),
- term__apply_rec_substitution_to_list(Types0, Subst, Types),
- Constraint = constraint(ClassName, Types).
-
-apply_subst_to_prog_constraints(Subst,
- constraints(UniversalCs0, ExistentialCs0),
- constraints(UniversalCs, ExistentialCs)) :-
- apply_subst_to_prog_constraint_list(Subst, UniversalCs0, UniversalCs),
- apply_subst_to_prog_constraint_list(Subst, ExistentialCs0,
- ExistentialCs).
-
-apply_subst_to_prog_constraint_list(Subst, !Constraints) :-
- list__map(apply_subst_to_prog_constraint(Subst), !Constraints).
-
-apply_subst_to_prog_constraint(Subst, Constraint0, Constraint) :-
- Constraint0 = constraint(ClassName, Types0),
- term__apply_substitution_to_list(Types0, Subst, Types),
- Constraint = constraint(ClassName, Types).
-
-apply_variable_renaming_to_prog_constraints(Renaming, Constraints0,
- Constraints) :-
- Constraints0 = constraints(UnivConstraints0, ExistConstraints0),
- apply_variable_renaming_to_prog_constraint_list(Renaming,
- UnivConstraints0, UnivConstraints),
- apply_variable_renaming_to_prog_constraint_list(Renaming,
- ExistConstraints0, ExistConstraints),
- Constraints = constraints(UnivConstraints, ExistConstraints).
-
-apply_variable_renaming_to_prog_constraint_list(Renaming, !Constraints) :-
- list.map(apply_variable_renaming_to_prog_constraint(Renaming),
- !Constraints).
-
-apply_variable_renaming_to_prog_constraint(Renaming, !Constraint) :-
- !.Constraint = constraint(ClassName, ClassArgTypes0),
- term.apply_variable_renaming_to_list(ClassArgTypes0, Renaming,
- ClassArgTypes),
- !:Constraint = constraint(ClassName, ClassArgTypes).
%-----------------------------------------------------------------------------%
:- end_module prog_util.
Index: compiler/recompilation.version.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/recompilation.version.m,v
retrieving revision 1.15
diff -u -r1.15 recompilation.version.m
--- compiler/recompilation.version.m 1 Apr 2005 14:29:01 -0000 1.15
+++ compiler/recompilation.version.m 2 Apr 2005 16:49:30 -0000
@@ -44,7 +44,7 @@
:- import_module hlds__hlds_out.
:- import_module parse_tree__mercury_to_mercury.
:- import_module parse_tree__prog_io.
-:- import_module parse_tree__prog_util.
+:- import_module parse_tree__prog_type.
:- import_module assoc_list.
:- import_module bool.
--------------------------------------------------------------------------
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