mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-18 23:35:25 +00:00
Estimated hours taken: 4 Branches: main Various cleanups for the modules in the compiler directory. The are no changes to algorithms except the replacement of some if-then-elses that would naturally be switches with switches and the replacement of most of the calls to error/1. compiler/*.m: Convert calls to error/1 to calls to unexpected/2 or sorry/2 as appropriate throughout most or the compiler. Fix inaccurate assertion failure messages, e.g. identifying the assertion failure as taking place in the wrong module. Add :- end_module declarations. Fix formatting problems and bring the positioning of comments into line with our current coding standards. Fix some overlong lines. Convert some more modules to 4-space indentation. Fix some spots where previous conversions to 4-space indentation have stuffed the formatting of the code up. Fix a bunch of typos in comments. Use state variables in more places; use library predicates from the sv* modules where appropriate. Delete unnecessary and duplicate module imports. Misc. other small cleanups.
93 lines
3.4 KiB
Mathematica
93 lines
3.4 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ft=mercury ts=4 sw=4 et
|
|
%---------------------------------------------------------------------------%
|
|
% Copyright (C) 1997-1998, 2003-2005 The University of Melbourne.
|
|
% This file may only be copied under the terms of the GNU General
|
|
% Public License - see the file COPYING in the Mercury distribution.
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% File: commit_gen.m.
|
|
% Main authors: conway, fjh, zs.
|
|
%
|
|
% The predicates of this module generate code for performing commits.
|
|
%
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module ll_backend__commit_gen.
|
|
:- interface.
|
|
|
|
:- import_module hlds.code_model.
|
|
:- import_module hlds.hlds_goal.
|
|
:- import_module ll_backend.code_info.
|
|
:- import_module ll_backend.llds.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- pred generate_commit(add_trail_ops::in, code_model::in,
|
|
hlds_goal::in, code_tree::out, code_info::in, code_info::out) is det.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- implementation.
|
|
|
|
:- import_module libs.compiler_util.
|
|
:- import_module libs.tree.
|
|
:- import_module ll_backend.code_gen.
|
|
|
|
:- import_module std_util.
|
|
:- import_module string.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
|
|
generate_commit(AddTrailOps, OuterCodeModel, Goal, Code, !Info) :-
|
|
Goal = _ - InnerGoalInfo,
|
|
goal_info_get_code_model(InnerGoalInfo, InnerCodeModel),
|
|
(
|
|
OuterCodeModel = model_det,
|
|
(
|
|
InnerCodeModel = model_det,
|
|
code_gen__generate_goal(InnerCodeModel, Goal, Code, !Info)
|
|
;
|
|
InnerCodeModel = model_semi,
|
|
unexpected(this_file, "generate_commit: " ++
|
|
"semidet model in det context")
|
|
;
|
|
InnerCodeModel = model_non,
|
|
code_info__prepare_for_det_commit(AddTrailOps, CommitInfo,
|
|
PreCommit, !Info),
|
|
code_gen__generate_goal(InnerCodeModel, Goal, GoalCode, !Info),
|
|
code_info__generate_det_commit(CommitInfo, Commit, !Info),
|
|
Code = tree(PreCommit, tree(GoalCode, Commit))
|
|
)
|
|
;
|
|
OuterCodeModel = model_semi,
|
|
(
|
|
InnerCodeModel = model_det,
|
|
code_gen__generate_goal(InnerCodeModel, Goal, Code, !Info)
|
|
;
|
|
InnerCodeModel = model_semi,
|
|
code_gen__generate_goal(InnerCodeModel, Goal, Code, !Info)
|
|
;
|
|
InnerCodeModel = model_non,
|
|
code_info__prepare_for_semi_commit(AddTrailOps, CommitInfo,
|
|
PreCommit, !Info),
|
|
code_gen__generate_goal(InnerCodeModel, Goal, GoalCode, !Info),
|
|
code_info__generate_semi_commit(CommitInfo, Commit, !Info),
|
|
Code = tree(PreCommit, tree(GoalCode, Commit))
|
|
)
|
|
;
|
|
OuterCodeModel = model_non,
|
|
code_gen__generate_goal(InnerCodeModel, Goal, Code, !Info)
|
|
).
|
|
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- func this_file = string.
|
|
|
|
this_file = "commit_gen.m".
|
|
|
|
%---------------------------------------------------------------------------%
|
|
:- end_module commit_gen.
|
|
%---------------------------------------------------------------------------%
|