mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-13 04:44:39 +00:00
Estimated hours taken: 2 Branches: main compiler/*.m: Import only one compiler module per line. Sort the blocks of imports. This makes it easier to merge in changes. In a couple of places, remove unnecessary imports.
66 lines
2.0 KiB
Mathematica
66 lines
2.0 KiB
Mathematica
%-----------------------------------------------------------------------------%
|
|
% Copyright (C) 2003 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: mmc_analysis.m
|
|
% Main author: stayl
|
|
%
|
|
% Specify Mercury compiler analyses to be used with the
|
|
% inter-module analysis framework.
|
|
%-----------------------------------------------------------------------------%
|
|
:- module transform_hlds__mmc_analysis.
|
|
|
|
:- interface.
|
|
|
|
:- import_module analysis.
|
|
:- import_module hlds__hlds_pred.
|
|
:- import_module parse_tree__prog_data.
|
|
|
|
:- type mmc ---> mmc.
|
|
|
|
:- instance compiler(mmc).
|
|
|
|
:- func module_name_to_module_id(module_name) = module_id.
|
|
:- func module_id_to_module_name(module_id) = module_name.
|
|
|
|
:- func pred_or_func_name_arity_to_func_id(pred_or_func,
|
|
string, arity, proc_id) = func_id.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module hlds__hlds_out.
|
|
:- import_module parse_tree__modules.
|
|
:- import_module parse_tree__prog_out.
|
|
:- import_module parse_tree__prog_util.
|
|
:- import_module transform_hlds__unused_args.
|
|
|
|
:- import_module bool, std_util, string.
|
|
|
|
:- instance compiler(mmc) where [
|
|
compiler_name(mmc) = "mmc",
|
|
|
|
analyses(mmc, "unused_args") =
|
|
'new analysis_type'(
|
|
unit1 `with_type` unit(unused_args_func_info),
|
|
unit1 `with_type` unit(any_call),
|
|
unit1 `with_type` unit(unused_args_answer)),
|
|
|
|
module_id_to_file_name(mmc, ModuleId, Ext, FileName) -->
|
|
module_name_to_file_name(module_id_to_module_name(ModuleId),
|
|
Ext, yes, FileName)
|
|
].
|
|
|
|
module_name_to_module_id(ModuleName) = ModuleId :-
|
|
sym_name_to_string(ModuleName, ModuleId).
|
|
|
|
module_id_to_module_name(ModuleId) = ModuleName :-
|
|
string_to_sym_name(ModuleId, ".", ModuleName).
|
|
|
|
pred_or_func_name_arity_to_func_id(PredOrFunc, Name, Arity, ProcId) = FuncId :-
|
|
hlds_out__simple_call_id_to_string(
|
|
PredOrFunc - unqualified(Name)/Arity, FuncId0),
|
|
proc_id_to_int(ProcId, ProcInt),
|
|
FuncId = FuncId0 ++ "-" ++ int_to_string(ProcInt).
|
|
|