[m-rev.] diff: switch on how_to_construct/0
Julien Fischer
juliensf at csse.unimelb.edu.au
Tue Jun 12 17:10:46 AEST 2007
Estimated hours taken: 0.5
Branches: main
Switch on the how_to_construct/0 type in more places. This makes
it easier to identify places that may need to be updated when that
type changes.
compiler/interval.m:
compiler/quantification.m:
compiler/structure_reuse.indirect.m:
Replaces if-then-elses with switches.
Julien.
Index: compiler/interval.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/interval.m,v
retrieving revision 1.28
diff -u -r1.28 interval.m
--- compiler/interval.m 23 May 2007 10:09:17 -0000 1.28
+++ compiler/interval.m 12 Jun 2007 07:08:07 -0000
@@ -349,10 +349,13 @@
(
Unification = construct(CellVar, _ConsId, ArgVars, _,
HowToConstruct, _, _),
- ( HowToConstruct = reuse_cell(_) ->
+ (
+ HowToConstruct = reuse_cell(_),
unexpected(this_file, "build_interval_info_in_goal: reuse")
;
- true
+ ( HowToConstruct = construct_statically(_)
+ ; HowToConstruct = construct_dynamically
+ )
),
require_in_regs(ArgVars, !IntervalInfo),
require_access([CellVar | ArgVars], !IntervalInfo)
Index: compiler/quantification.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/quantification.m,v
retrieving revision 1.115
diff -u -r1.115 quantification.m
--- compiler/quantification.m 6 Jan 2007 09:23:49 -0000 1.115
+++ compiler/quantification.m 12 Jun 2007 07:08:07 -0000
@@ -510,10 +510,14 @@
get_lambda_outside(!.Info, LambdaOutsideVars),
TypeInfoVars = get_unify_typeinfos(Unification0),
( Unification0 = construct(_, _, _, _, How, _, SubInfo) ->
- ( How = reuse_cell(cell_to_reuse(ReuseVar0, _, SetArgs)) ->
+ (
+ How = reuse_cell(cell_to_reuse(ReuseVar0, _, SetArgs)),
MaybeSetArgs = yes(SetArgs),
MaybeReuseVar = yes(ReuseVar0)
;
+ ( How = construct_statically(_)
+ ; How = construct_dynamically
+ ),
MaybeSetArgs = no,
MaybeReuseVar = no
),
@@ -1118,10 +1122,14 @@
!Set, !LambdaSet) :-
insert(!.Set, LHS, !:Set),
( Unification = construct(_, _, _, _, How, _, SubInfo) ->
- ( How = reuse_cell(cell_to_reuse(ReuseVar, _, SetArgs)) ->
+ (
+ How = reuse_cell(cell_to_reuse(ReuseVar, _, SetArgs)),
MaybeSetArgs = yes(SetArgs),
insert(!.Set, ReuseVar, !:Set)
;
+ ( How = construct_statically(_)
+ ; How = construct_dynamically
+ ),
MaybeSetArgs = no
),
(
Index: compiler/structure_reuse.indirect.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/structure_reuse.indirect.m,v
retrieving revision 1.9
diff -u -r1.9 structure_reuse.indirect.m
--- compiler/structure_reuse.indirect.m 26 Jan 2007 05:06:47 -0000 1.9
+++ compiler/structure_reuse.indirect.m 12 Jun 2007 07:08:07 -0000
@@ -292,13 +292,27 @@
!.AnalysisInfo ^ sharing_as)
;
GoalExpr0 = unify(_, _, _, Unification, _),
- % Record the statically constructed variables:
- ( Unification = construct(Var, _, _, _,
- construct_statically(_), _, _) ->
- !:AnalysisInfo = !.AnalysisInfo ^ static_vars :=
- set.insert(!.AnalysisInfo ^ static_vars, Var)
+ % Record the statically constructed variables.
+ (
+ Unification = construct(Var, _, _, _, HowToConstruct, _, _),
+ (
+ HowToConstruct = construct_statically(_),
+ !:AnalysisInfo = !.AnalysisInfo ^ static_vars :=
+ set.insert(!.AnalysisInfo ^ static_vars, Var)
+ ;
+ ( HowToConstruct = construct_dynamically
+ ; HowToConstruct = reuse_cell(_)
+ )
+ )
;
- true
+ ( Unification = deconstruct(_, _, _, _, _, _)
+ ; Unification = assign(_, _)
+ ; Unification = simple_test(_, _)
+ )
+ ;
+ Unification = complicated_unify(_, _, _),
+ unexpected(this_file,
+ "complicated unification in indirect structure sharing analysis.")
),
!:AnalysisInfo = !.AnalysisInfo ^ sharing_as :=
add_unify_sharing(ModuleInfo, ProcInfo, Unification,
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list