[m-rev.] diff: generating code for conjunctions
Zoltan Somogyi
zs at csse.unimelb.edu.au
Wed May 25 18:01:29 AEST 2011
compiler/code_gen.m:
Make the predicate that generates code for sequential conjunctions
tail recursive without lcmc.
Zoltan.
Index: compiler/code_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/code_gen.m,v
retrieving revision 1.183
diff -u -b -r1.183 code_gen.m
--- compiler/code_gen.m 23 May 2011 05:08:00 -0000 1.183
+++ compiler/code_gen.m 25 May 2011 07:09:41 -0000
@@ -240,8 +240,7 @@
GoalExpr = conj(ConjType, Goals),
(
ConjType = plain_conj,
- generate_goals(Goals, CodeModel, Codes, !CI),
- Code = cord_list_to_cord(Codes)
+ generate_goals(Goals, CodeModel, cord.init, Code, !CI)
;
ConjType = parallel_conj,
par_conj_gen.generate_par_conj(Goals, GoalInfo, CodeModel, Code,
@@ -311,21 +310,21 @@
%---------------------------------------------------------------------------%
- % Generate a conjoined series of goals. Note of course, that with a
- % conjunction, state information flows directly from one conjunct
- % to the next.
+ % Generate a conjoined series of goals. State information flows directly
+ % from one conjunct to the next.
%
-:- pred generate_goals(hlds_goals::in, code_model::in,
- list(llds_code)::out, code_info::in, code_info::out) is det.
+:- pred generate_goals(list(hlds_goal)::in, code_model::in,
+ llds_code::in, llds_code::out, code_info::in, code_info::out) is det.
-generate_goals([], _, [], !CI).
-generate_goals([Goal | Goals], CodeModel, [Code | Codes], !CI) :-
- generate_goal(CodeModel, Goal, Code, !CI),
+generate_goals([], _, !Code, !CI).
+generate_goals([Goal | Goals], CodeModel, !Code, !CI) :-
+ generate_goal(CodeModel, Goal, GoalCode, !CI),
+ !:Code = !.Code ++ GoalCode,
get_instmap(!.CI, Instmap),
( instmap_is_unreachable(Instmap) ->
- Codes = []
+ true
;
- generate_goals(Goals, CodeModel, Codes, !CI)
+ generate_goals(Goals, CodeModel, !Code, !CI)
).
%---------------------------------------------------------------------------%
--------------------------------------------------------------------------
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