mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-14 13:23:53 +00:00
The main aim of this change is to make the overall, high-level structure of the compiler clearer, and to encourage better encapsulation of the major components. compiler/libs.m: compiler/backend_libs.m: compiler/parse_tree.m: compiler/hlds.m: compiler/check_hlds.m: compiler/transform_hlds.m: compiler/bytecode_backend.m: compiler/aditi_backend.m: compiler/ml_backend.m: compiler/ll_backend.m: compiler/top_level.m: New files. One module for each of the major components of the Mercury compiler. These modules contain (as separate sub-modules) all the other modules in the Mercury compiler, except gcc.m and mlds_to_gcc.m. Mmakefile: compiler/Mmakefile: Handle the fact that the top-level module is now `top_level', not `mercury_compile' (since `mercury_compile' is a sub-module of `top_level'). compiler/Mmakefile: Update settings of *FLAGS-<modulename> to use the appropriate nested module names. compiler/recompilation_check.m: compiler/recompilation_version.m: compiler/recompilation_usage.m: compiler/recompilation.check.m: compiler/recompilation.version.m: compiler/recompilation.version.m: Convert the `recompilation_*' modules into sub-modules of the `recompilation' module. compiler/*.m: compiler/*.pp: Module-qualify the module names in `:- module', `:- import_module', and `:- use_module' declarations. compiler/base_type_info.m: compiler/base_type_layout.m: Deleted these unused empty modules. compiler/prog_data.m: compiler/globals.m: Move the `foreign_language' type from prog_data to globals. compiler/mlds.m: compiler/ml_util.m: compiler/mlds_to_il.m: Import `globals', for `foreign_language'. Mmake.common.in: trace/Mmakefile: runtime/Mmakefile: Rename the %.check.c targets as %.check_hdr.c, to avoid conflicts with compiler/recompilation.check.c.
115 lines
4.1 KiB
Mathematica
115 lines
4.1 KiB
Mathematica
%-----------------------------------------------------------------------------%
|
|
% Copyright (C) 1997, 1999-2000, 2002 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.
|
|
%-----------------------------------------------------------------------------%
|
|
%
|
|
% inst.m - Contains the (inst) data type.
|
|
% Main author: bromage
|
|
%
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
:- module (parse_tree__inst).
|
|
:- interface.
|
|
|
|
% This module should NOT import hlds*.m. Any types which are needed in
|
|
% both the insts and in the HLDS should be defined here, rather than
|
|
% in hlds*.m, because insts are part of the parse tree and the parse tree
|
|
% should not depend on the HLDS.
|
|
%
|
|
% XXX Currently we have to import hlds_data for the `cons_id' type.
|
|
% I think the cons_ids in insts only use a subset of the functors
|
|
% of the `cons_id' type, and so we could define a new type
|
|
% `abstract_cons_id' and use that here instead of `cons_id'.
|
|
|
|
:- import_module parse_tree__prog_data, hlds__hlds_data.
|
|
:- import_module list, map, set.
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
:- type (inst)
|
|
---> any(uniqueness)
|
|
; free
|
|
; free(type)
|
|
; bound(uniqueness, list(bound_inst))
|
|
% The list(bound_inst) must be sorted
|
|
; ground(uniqueness, ground_inst_info)
|
|
% The ground_inst_info holds extra information
|
|
% about the ground inst.
|
|
; not_reached
|
|
; inst_var(inst_var)
|
|
% constrained_inst_vars is a set of inst
|
|
% variables that are constrained to have the
|
|
% same uniqueness as and to match_final the
|
|
% specified inst.
|
|
; constrained_inst_vars(set(inst_var), inst)
|
|
% A defined_inst is possibly recursive
|
|
% inst whose value is stored in the
|
|
% inst_table. This is used both for
|
|
% user-defined insts and for
|
|
% compiler-generated insts.
|
|
; defined_inst(inst_name)
|
|
% An abstract inst is a defined inst which
|
|
% has been declared but not actually been
|
|
% defined (yet).
|
|
; abstract_inst(sym_name, list(inst)).
|
|
|
|
:- type uniqueness
|
|
---> shared % there might be other references
|
|
; unique % there is only one reference
|
|
; mostly_unique % there is only one reference
|
|
% but there might be more on
|
|
% backtracking
|
|
; clobbered % this was the only reference, but
|
|
% the data has already been reused
|
|
; mostly_clobbered.
|
|
% this was the only reference, but
|
|
% the data has already been reused;
|
|
% however, there may be more references
|
|
% on backtracking, so we will need to
|
|
% restore the old value on backtracking
|
|
|
|
% The ground_inst_info type gives extra information about ground insts.
|
|
:- type ground_inst_info
|
|
---> higher_order(pred_inst_info)
|
|
% The ground inst is higher-order.
|
|
; none.
|
|
% No extra information is available.
|
|
|
|
% higher-order predicate terms are given the inst
|
|
% `ground(shared, higher_order(PredInstInfo))'
|
|
% where the PredInstInfo contains the extra modes and the determinism
|
|
% for the predicate. Note that the higher-order predicate term
|
|
% itself must be ground.
|
|
|
|
:- type pred_inst_info
|
|
---> pred_inst_info(
|
|
pred_or_func, % is this a higher-order func
|
|
% mode or a higher-order pred
|
|
% mode?
|
|
list(mode), % the modes of the additional
|
|
% (i.e. not-yet-supplied)
|
|
% arguments of the pred;
|
|
% for a function, this includes
|
|
% the mode of the return value
|
|
% as the last element of the
|
|
% list.
|
|
determinism % the determinism of the
|
|
% predicate or function
|
|
).
|
|
|
|
:- type bound_inst ---> functor(cons_id, list(inst)).
|
|
|
|
:- type inst_var_sub == map(inst_var, inst).
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
:- implementation.
|
|
|
|
% Empty for now.
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
%-----------------------------------------------------------------------------%
|